def get_file_items(self, window, files):
        if len(files) != 1:
            return

        nfile = files[0]

        if nfile.is_directory():
            return

        if nfile.get_mime_type().split("/")[0] != "image":
            return

        menu = FileManager.MenuItem(name="SearchByImageExtension::Engines",
                                    label="Search by image")

        submenu = FileManager.Menu()
        menu.set_submenu(submenu)
        for engine in SEARCH_URLS.keys():
            item = FileManager.MenuItem(
                name=f"SearchByImageExtension::{engine}",
                label=f"Search image on {engine}",
                tip=f"Use {engine} reverse image search on {nfile.get_name()}",
            )
            item.connect("activate", self._search_image, nfile, engine)
            submenu.append_item(item)

        return (menu, )
    def get_file_items(self, window, files):

        """Ensure there are reachable devices"""
        try:
            devices = self.get_reachable_devices()
        except Exception as e:
            raise Exception("Error while getting reachable devices")

        """if there is no reacheable devices don't show this on context menu"""
        if not devices:
            return

        """Ensure that user only select files"""
        for file in files:
            if file.get_uri_scheme() != 'file' or file.is_directory() and os.path.isfile(file):
                return

        self.setup_gettext()
        """If user only select file(s) create menu and sub menu"""
        menu = Nemo.MenuItem(name='KdeConnectSendExtension::KDEConnect_Send',
                             label=_('KDEConnect - Send To'),
                             tip=_('send file(s) with kdeconnect'),
                             icon='kdeconnect')

        sub_menu = Nemo.Menu()

        menu.set_submenu(sub_menu)

        for device in devices:
            item = Nemo.MenuItem(name="KDEConnectSendExtension::Send_File_To",
                                 label=device["name"])
            item.connect('activate', self.menu_activate_cb, files, device["id"], device["name"])
            sub_menu.append_item(item)

        return menu,
Пример #3
0
 def get_file_items(self, window, files):
     """ Tell nemo whether and when to show the menu """
     if len(files) == 0:
         return
     myfile = files[0]
     if not self.is_valid_file(myfile):
         return
     item1 = Nemo.MenuItem(
         name='Nemo::gnupg_scripts_encrypt',
         label=gettext.dgettext('gnupg-scripts',
                                'Encrypt').decode('utf-8', 'replace'),
         tip=gettext.dgettext('gnupg-scripts',
                              'Encrypt the file(s) with GnuPG').decode(
                                  'utf-8', 'replace'),
         icon="gnupg-scripts-encrypt")
     item1.connect('activate', self.menu1_activate_cb, files)
     item2 = Nemo.MenuItem(
         name='Nemo::gnupg_scripts_sign',
         label=gettext.dgettext('gnupg-scripts',
                                'Sign').decode('utf-8', 'replace'),
         tip=gettext.dgettext(
             'gnupg-scripts',
             'Signs the selected file with a detached signature').decode(
                 'utf-8', 'replace'),
         icon="gnupg-scripts-sign")
     item2.connect('activate', self.menu2_activate_cb, files)
     return item1, item2,
    def get_file_items(self, window, files):
        if len(files) != 1: #Only allow for a single folder selection
            return

        folder = files[0]
        if not folder.is_directory(): #Only allow on folders
            return

        #Get the full system path of the selected folder
        folder_uri = urllib.parse.unquote(folder.get_uri()[7:]) if PYTHON3 else urllib.unquote(folder.get_uri()[7:])
        folder_name = os.path.basename(os.path.normpath(folder_uri))

        #Prevents recursion issues
        if folder_name == META_DIR:
            return

        top_menuitem = Nemo.MenuItem(name='NemoRcloneSyncProvider::Sync',
                                     label='Sync',
                                     tip='Perform an rclone sync of this folder to a remote',
                                     icon='network-transmit-receive') #possible icons = "add", "network-transmit-receive"

        submenu = Nemo.Menu()
        top_menuitem.set_submenu(submenu)

        #Was the same folder opened again?
        #Prevents the metadata file from being read multiple times
        if folder_uri != self.last_dir:
            self.meta_object_cache = self.read_meta_file(folder_uri) #Get the sync metadata (if any) for this folder
            self.last_dir = folder_uri
        
        if "places" in self.meta_object_cache:
            places = self.meta_object_cache["places"]
            for p in places:
                #Create a new menu item for every remote path
                if ("label" in p) and ("path" in p):
                    sub_menuitem = Nemo.MenuItem(name=PLUGIN_NAME + "::Place-" + p["label"],
                                     label=p["label"],
                                     tip='Sync to this remote directory',
                                     icon='folder')

                    sub_menuitem.connect('activate', self.on_sync_requested, window, str(folder_uri), str(p["path"]), self.meta_object_cache["first_sync"])

                    submenu.append_item(sub_menuitem)

        #Append a separator
        sum_menuitem_separator = Nemo.MenuItem.new_separator(PLUGIN_NAME + "::Other_separator")
        submenu.append_item(sum_menuitem_separator)

        #Append the "other" option to the menu
        sub_menuitem = Nemo.MenuItem(name=PLUGIN_NAME + "::Other",
                                     label='Other...',
                                     tip='Choose a destination directory not listed here',
                                     icon='folder-saved-search')
        sub_menuitem.connect('activate', self.on_menu_other_activated, window, folder_uri)
        submenu.append_item(sub_menuitem)

        return top_menuitem,
Пример #5
0
    def create_menu_item(self, stream_type, files):
        cast_label = "Cast Selected File"

        if len(files) > 1:
            cast_label += "s"

        menu_label = self.get_menu_name()

        if not menu_label:
            return None

        top_menuitem = FileManager.MenuItem(
            name='CastToTVMenu::CastMenu',
            label=menu_label
        )

        submenu = FileManager.Menu()
        top_menuitem.set_submenu(submenu)

        sub_menuitem_1 = FileManager.MenuItem(
            name='CastToTVMenu::CastFile', label=_(cast_label)
        )
        sub_menuitem_1.connect(
            'activate', self.cast_files_cb, files, stream_type, False
        )
        submenu.append_item(sub_menuitem_1)

        if stream_type == 'VIDEO':
            sub_menuitem_2 = FileManager.MenuItem(
                name='CastTranscodeMenu::Transcode', label=_("Transcode")
            )
            submenu_2 = FileManager.Menu()
            sub_menuitem_2.set_submenu(submenu_2)

            sub_sub_menuitem_1 = FileManager.MenuItem(
                name='CastTranscodeMenu::Video', label=_("Video")
            )
            sub_sub_menuitem_1.connect(
                'activate', self.transcode_files_cb, files, stream_type, False
            )
            submenu_2.append_item(sub_sub_menuitem_1)

            sub_sub_menuitem_3 = FileManager.MenuItem(
                name='CastTranscodeMenu::Video+Audio', label=_("Video + Audio")
            )
            sub_sub_menuitem_3.connect(
                'activate', self.transcode_files_cb, files, stream_type, True
            )
            submenu_2.append_item(sub_sub_menuitem_3)

            submenu.append_item(sub_menuitem_2)

        return top_menuitem
Пример #6
0
    def get_background_items(self, window, file):
        submenu = Nemo.Menu()
        submenu.append_item(
            Nemo.MenuItem(name='ExampleMenuProvider::Bar2',
                          label='Bar2',
                          tip='',
                          icon=''))

        menuitem = Nemo.MenuItem(name='ExampleMenuProvider::Foo2',
                                 label='Foo2',
                                 tip='',
                                 icon='')
        menuitem.set_submenu(submenu)

        return menuitem,
Пример #7
0
    def get_file_items(self, window, files):
        if len(files) != 1:
            return
        file = files[0]
        items = []

        # internal or external file?!
        syncedFile = False
        for reg_path in socketConnect.registered_paths:
            filename = get_local_path(file.get_uri())
            if filename.startswith(reg_path):
                syncedFile = True

        # if it is neither in a synced folder or is a directory
        if (not syncedFile):
            return items

        # create an menu item
        labelStr = "Share with " + appname + "..."
        item = Nemo.MenuItem(name='NemoPython::ShareItem',
                             label=labelStr,
                             tip='Share file %s through ownCloud' %
                             file.get_name())
        item.connect("activate", self.menu_share, file)
        items.append(item)

        return items
Пример #8
0
    def get_file_items(self, window, files):
        top_menuitem = Nemo.MenuItem(name='ExampleMenuProvider::Foo',
                                     label='Foo',
                                     tip='',
                                     icon='')

        submenu = Nemo.Menu()
        top_menuitem.set_submenu(submenu)

        sub_menuitem = Nemo.MenuItem(name='ExampleMenuProvider::Bar',
                                     label='Bar',
                                     tip='',
                                     icon='')
        submenu.append_item(sub_menuitem)

        return top_menuitem,
Пример #9
0
 def get_file_items(self, window, files):
     """
     Return a menu item if some files were selected.
     """
     if not len(files):
         return
     item = Nemo.MenuItem(
         name='NitroShare::SendFiles',
         label="Send with NitroShare...",
     )
     try:
         with open(self._LOCALFILE, 'r') as f:
             d = loads(f.read())
         port = d['port']
         token = d['token']
     except (IOError, KeyError):
         item.set_property('sensitive', False)
     else:
         item.connect(
             'activate',
             self.send_items,
             window,
             [url2pathname(urlparse(x.get_uri()).path) for x in files],
             port,
             token,
         )
     return [item]
Пример #10
0
    def get_file_items(self, window, items):
        """Return the context menu widget.

        Called by Nemo on view changes. items are the currently selected
        items.
        """
        if not items:
            return
        # skip if current theme has no other colors
        if not self.installed_colors:
            return
        # only folders and scheme is file
        if any(item.get_uri_scheme() != "file" or not item.is_directory()
               for item in items):
            return

        widget_a = generate_menu_widget(self.installed_colors,
                                        items,
                                        callback=self.menu_activate_cb)
        widget_b = generate_menu_widget(self.installed_colors,
                                        items,
                                        callback=self.menu_activate_cb)

        menuItem = Nemo.MenuItem(name="NemoFolderColorSwitcher::Widget",
                                 widget_a=widget_a,
                                 widget_b=widget_b)
        return (Nemo.MenuItem.new_separator("NemoFolderColorSwitcher::TopSep"),
                menuItem,
                Nemo.MenuItem.new_separator("NemoFolderColorSwitcher::BotSep"))
Пример #11
0
    def make_menu_item(self, item, id_magic):
        identifier = item.make_magic_id(id_magic)
        menuitem = Nemo.MenuItem(name=identifier,
                                 label=item.make_label(),
                                 tip=item.tooltip,
                                 icon=item.icon)

        return menuitem
Пример #12
0
    def add_menu_device(self, stream_type, files, cast_label, submenu, device,
                        is_short_list):
        if (is_short_list or not device):
            device_config_name = None
            cast_submenu = submenu
            playlist_allowed = self.get_playlist_allowed(stream_type)
        else:
            device_config_name = device['friendlyName']
            cast_submenu = FileManager.Menu()
            name_item = FileManager.MenuItem(name='CastToTVMenu::CastFile',
                                             label=device_config_name)
            name_item.set_submenu(cast_submenu)
            submenu.append_item(name_item)
            playlist_allowed = False
            receiver_type = self.ext_settings.get_string('receiver-type')
            if receiver_type == 'chromecast' or receiver_type == 'playercast':
                if device_config_name == self.ext_settings.get_string(
                        receiver_type + '-name'):
                    playlist_allowed = self.get_playlist_allowed(stream_type)

        cast_item = FileManager.MenuItem(name='CastToTVMenu::CastFile',
                                         label=_(cast_label))
        cast_item.connect('activate', self.cast_files_cb, files, stream_type,
                          device_config_name)
        cast_submenu.append_item(cast_item)

        if playlist_allowed:
            playlist_item = FileManager.MenuItem(
                name='CastToTVMenu::AddToPlaylist', label=_("Add to Playlist"))
            playlist_item.connect('activate', self.add_to_playlist_cb, files,
                                  stream_type)
            cast_submenu.append_item(playlist_item)

        if stream_type == 'VIDEO':
            transcode_item = FileManager.MenuItem(
                name='CastTranscodeMenu::Transcode', label=_("Transcode"))
            transcode_submenu = FileManager.Menu()
            transcode_item.set_submenu(transcode_submenu)

            video_only_item = FileManager.MenuItem(
                name='CastTranscodeMenu::Video', label=_("Video"))
            video_only_item.connect('activate', self.transcode_video_cb, files,
                                    stream_type, False, device_config_name)
            transcode_submenu.append_item(video_only_item)

            audio_only_item = FileManager.MenuItem(
                name='CastTranscodeMenu::Audio', label=_("Audio"))
            audio_only_item.connect('activate', self.transcode_audio_cb, files,
                                    stream_type, device_config_name)
            transcode_submenu.append_item(audio_only_item)

            video_audio_item = FileManager.MenuItem(
                name='CastTranscodeMenu::Video+Audio',
                label=_("Video + Audio"))
            video_audio_item.connect('activate', self.transcode_video_cb,
                                     files, stream_type, True,
                                     device_config_name)
            transcode_submenu.append_item(video_audio_item)

            cast_submenu.append_item(transcode_item)
Пример #13
0
 def get_background_items(self, window, current_folder):
   menu_item = Nemo.MenuItem(
     name  = 'NemoPython::open-in-vscode',
     label = intl('Open in Visual Studio Code'),
     tip   = intl('Opens the current folder in Visual Studio Code'),
     icon  = 'gtk-execute'
   )
   menu_item.connect('activate', self.execute, current_folder)
   return menu_item,
Пример #14
0
 def _create_hide_item(self, files, hidden_path, hidden):
     """Creates the 'Hide file(s)' menu item."""
     item = Nemo.MenuItem(name="NemoHide::HideFile",
                          label=ngettext("_Hide File", "_Hide Files",
                                         len(files)),
                          tip=ngettext("Hide this file", "Hide these files",
                                       len(files)))
     item.connect("activate", self._hide_run, files, hidden_path, hidden)
     return item
Пример #15
0
    def get_file_items(self, window, files):
        """Ensure there are reachable devices"""
        try:
            devices = self.get_reachable_devices()
        except Exception as e:
            raise Exception("Error while getting reachable devices")
        """if there is no reacheable devices don't show this on context menu"""
        if len(devices) == 0:
            return
        """Ensure that user only select files"""
        for file in files:
            if file.get_uri_scheme() != 'file' or file.is_directory():
                return

        self.setup_gettext()
        """If user only select file(s) create menu and sub menu"""
        menu = Nemo.MenuItem(name='SendViaExtension::SendViaKDEConnect',
                             label=_('KDEConnect Send To'),
                             tip=_('send file(s) with kdeconnect'),
                             icon='kdeconnect')

        sub_menu = Nemo.Menu()

        menu.set_submenu(sub_menu)

        for deviceId, deviceName in devices.items():
            item = Nemo.MenuItem(name='SendViaExtension::SendFileTo' +
                                 deviceId,
                                 label=deviceName)
            item.connect('activate', self.send_files, files, deviceId,
                         deviceName)
            sub_menu.append_item(item)

        if len(devices) > 1:
            item = Nemo.MenuItem(
                name='SendViaExtension::SendFileToMultipleDevices',
                label='Multiple Devices')
            item.connect('activate', self.send_to_multiple_devices, files)

            sub_menu.append_item(item)

        return menu,
Пример #16
0
class MtgActions(GObject.GObject, Nemo.MenuProvider):

    def __init__(self):
        try:
            factory = Gtk.IconFactory()
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(ICONPATH)
            iconset = Gtk.IconSet.new_from_pixbuf(pixbuf)
            factory.add("mtg", iconset)
            factory.add_default()
        except: pass

    #def run(self, menu, element_1, element_2):
    #    """Runs the Meld Comparison of selected files/folders"""
    #    subprocess.call("meld %s %s &" % (element_1, element_2), shell=True)

    def meld_save(self, menu, element):
		call(['gedit', ' ', '&'])

    def get_file_items(self, window, sel_items):
        """Adds the 'Add To Audacious Playlist' menu item to the Nemo right-click menu,
           connects its 'activate' signal to the 'run' method passing the list of selected Audio items"""
		call(['gedit', ' ', '&'])
        num_paths = len(sel_items)
        if num_paths == 0: return
        uri_raw = sel_items[0].get_uri()
        if len(uri_raw) < 7: return
        element_1 = urllib.unquote(uri_raw[7:])
         
        top_menuitem = Nemo.MenuItem(name='Mtg::actions',
                                         label=_('MTG Manage'),
                                         tip=_('Tools for managing your MTG Collection'),
                                         icon='mtg')
        submenu = Nemo.Menu()
        top_menuitem.set_submenu(submenu)
        sub_menuitem_save = Nemo.MenuItem(name='Mtg::download_price',
                                              label=_('Reload prices'),
                                              tip=_('Download and show selected cards prices.'),
                                              icon='prices')
        sub_menuitem_save.connect('activate', self.meld_save, element_1)
        submenu.append_item(sub_menuitem_save)
        return top_menuitem
Пример #17
0
    def get_file_items(self, window, files):
        """Return a list of select files to be sent"""

        # Only accept regular files
        for uri in files:
            if uri.get_uri_scheme() != 'file' or uri.is_directory():
                return ()

        # Enumerate capable devices
        devices = []

        for name, action_group in self.devices.values():
            if action_group.get_action_enabled('shareFile'):
                devices.append([name, action_group])

        # No capable devices; don't show menu entry
        if not devices:
            return ()

        # Context Menu Item
        menu = FileManager.MenuItem(
            name='GSConnectShareExtension::Devices',
            label=_('Send To Mobile Device')
        )

        # Context Submenu
        submenu = FileManager.Menu()
        menu.set_submenu(submenu)

        # Context Submenu Items
        for name, action_group in devices:
            item = FileManager.MenuItem(
                name='GSConnectShareExtension::Device' + name,
                label=name
            )

            item.connect('activate', self.send_files, files, action_group)

            submenu.append_item(item)

        return (menu,)
Пример #18
0
    def get_file_items( # pylint: disable=arguments-differ
        self, _, files: list[GObject]) -> list[Nemo.MenuItem]|None:
        '''
        Called when context menu is called with files selected.

        :param files: The currently selected file objects.
        '''
        files = get_files(files) # type: ignore
        try:
            is_iter = iter(files)
            check = all(file.lower().endswith('png') for file in files)
        except TypeError:
            is_iter = False
            check = False
        if check:
            convert = Nemo.MenuItem(
                name="CrushImages",
                label="Optimize image(s) with pngcrush",
                tip="Optimize filesize(s) with pngcrush"
            )
            convert.connect('activate', crush_images, files)
            return [convert]

        if is_iter:
            check = all(file.lower().endswith(EXTENSIONS) for file in files)
        if check:
            convert = Nemo.MenuItem(
                name="ConvertImagetoPNG",
                label="Convert selected image(s) to .png",
                tip="Convert image(s) to .png"
            )
            convert.connect('activate', convert_images, files)

            crush = Nemo.MenuItem(
                name="ConvertandCrush",
                label="Convert to PNG and optimize with pngcrush",
                tip="Convert image(s) to PNG and optimize filesize(s) with\
                    pngcrush"
            )
            crush.connect('activate', convert_and_crush, files)
            return [convert, crush]
 def get_background_items(self, window, folder):
     """ Show 'wipe free space' menu entry """
     if folder.get_uri_scheme() != 'file':
         return
     item = Nemo.MenuItem(
         name='Nemo::wipe_free_space',
         label=gettext.dgettext('truecrypt-helper', 'Wipe free space'),
         tip=gettext.dgettext(
             'truecrypt-helper',
             'Overwrites free space on the current location'))
     item.connect('activate', self.wipe_activate_cb, folder)
     return item,
    def get_file_items(self, window, files):
        if len(files) != 1:
            return

        file = files[0]
        if not file.is_directory() or file.get_uri_scheme() != 'file':
            return

        item = Nemo.MenuItem(name='NemoPython::openterminal_file_item',
                             label='Open Terminal',
                             tip='Open Terminal In %s' % file.get_name())
        item.connect('activate', self.menu_activate_cb, file)
        return item,
Пример #21
0
  def get_file_items(self, window, files):
    if len(files) != 1: return
    selected = files[0]
    if selected.get_uri_scheme() not in ['file']: return

    menu_item = Nemo.MenuItem(
      name  = 'NemoPython::open-in-vscode',
      label = intl('Open in Visual Studio Code'),
      tip   = intl('Opens the selected folder or file in Visual Studio Code'),
      icon  = 'gtk-execute'
    )
    menu_item.connect('activate', self.execute, selected)
    return menu_item,
Пример #22
0
    def get_background_items( # pylint: disable=arguments-differ
        self, _, folder: GObject) -> list[Nemo.MenuItem]|None:
        '''
        Called when context menu is called with no file objects selected.

        :param folder: Nemo's current working directory.
        '''

        folder = urlparse(folder.get_uri()).path
        files = [uqp(os.path.join(folder, f))
                 for f in os.listdir(uqp(folder))
                 if os.path.isfile(uqp(os.path.join(folder, f))) and
                 f.lower().endswith(EXTENSIONS)]

        if all(file.endswith('png') for file in files):
            crush = Nemo.MenuItem(
                name='CrushImages',
                label='Optimize image(s) with pngcrush',
                tip='Optimize image filesizes with pngcrush'
            )
            crush.connect('activate', crush_images, files)
            return [crush]

        if any(file.endswith(EXTENSIONS) for file in files):
            convert = Nemo.MenuItem(
                name="ConvertAllImagestoPNG",
                label="Convert all images to PNG",
                tip="Convert all images to PNG"
            )
            convert.connect('activate', convert_images, files)

            crush = Nemo.MenuItem(
                name='ConvertandCrush',
                label="Convert images to PNG and optimize",
                tip="Convert images to PNG and optimize filesizes with pngcrush"
            )
            crush.connect('activate', convert_and_crush, files)
            return [convert, crush]
Пример #23
0
    def create_menu_item(self, stream_type, files):
        cast_label = "Cast Selected File"
        if len(files) > 1:
            cast_label += "s"

        connected_devices = None
        cast_devices = []
        parsed_devices = []
        receiver_type = self.ext_settings.get_string('receiver-type')

        if not self.ws_data or not self.ws_data['isPlaying']:
            if receiver_type == 'playercast':
                connected_devices = self.get_soup_data('playercasts')
                for friendly_name in connected_devices:
                    full_name = (friendly_name.replace(' ',
                                                       '')).lower() + '.local'
                    device = {"name": full_name, "friendlyName": friendly_name}
                    parsed_devices.append(device)
            if (receiver_type == 'chromecast'
                    or receiver_type == 'playercast'):
                cast_devices = json.loads(
                    self.ext_settings.get_string(receiver_type + '-devices'))
                for device in cast_devices:
                    if ((device['name'].endswith('.local') or device['ip']) and
                        (not connected_devices
                         or device['friendlyName'] not in connected_devices)):
                        parsed_devices.append(device)

        if len(parsed_devices) > 1:
            menu_label = self.get_menu_name(False)
        else:
            menu_label = self.get_menu_name(True)

        if not menu_label:
            return None

        top_menuitem = FileManager.MenuItem(name='CastToTVMenu::CastMenu',
                                            label=menu_label)
        submenu = FileManager.Menu()
        top_menuitem.set_submenu(submenu)

        if len(parsed_devices) > 1:
            for device in parsed_devices:
                self.add_menu_device(stream_type, files, cast_label, submenu,
                                     device, False)
        else:
            self.add_menu_device(stream_type, files, cast_label, submenu, None,
                                 True)

        return top_menuitem
Пример #24
0
    def get_file_items(self, window, files):
        if len(files) != 1:
            return
        f = files[0]
        if f.is_directory():
            menuitem = Nautilus.MenuItem(
                name='MyItem::SomeItem',
                label='Sync settings',
                tip='Sync settings',
                icon='/opt/rclone-sync/rclone-sync.png')

            menuitem.connect('activate', self.on_menu_item_clicked, files)
            return menuitem,
        return
 def get_file_items(self, window, files):
     """ Tell nemo whether and when to show the menu """
     if len(files) != 1:
         return
     myfile = files[0]
     if not (
         ( ( myfile.get_uri_scheme() == 'x-nemo-desktop' ) and 
         ( myfile.get_mime_type() == 'application/x-nemo-link' ) ) or 
         ( myfile.get_uri_scheme() == 'computer') ):
         return        
     item = Nemo.MenuItem(name='Nemo::volume_rename',
                              label=gettext.dgettext('nemo-fslabel', 'Rename volume').decode('utf-8'),
                              tip=gettext.dgettext('nemo-fslabel', 'Renames the current volume').decode('utf-8'))
     item.connect('activate', self.menu_activate_cb, myfile)
     return [item]
Пример #26
0
 def get_file_items(self, window, files):
     """ Tell nemo whether and when to show the menu """
     if len(files) != 1:
         return
     myfile = files[0]
     if not self.is_valid_file(myfile):
         return
     item1 = Nemo.MenuItem(name='Nemo::force_unmount',
                           label=gettext.dgettext(
                               'truecrypt-helper',
                               'Force-Unmount Container'),
                           tip=gettext.dgettext(
                               'truecrypt-helper',
                               'Forcibly Unmounts the selected TrueCrypt '
                               'Container'))
     item1.connect('activate', self.force_close_activate_cb, myfile)
     item2 = Nemo.MenuItem(name='Nemo::tc_unmount',
                           label=gettext.dgettext('truecrypt-helper',
                                                  'Unmount Container'),
                           tip=gettext.dgettext(
                               'truecrypt-helper',
                               'Unmounts the selected TrueCrypt Container'))
     item2.connect('activate', self.close_activate_cb, myfile)
     return item1, item2,
Пример #27
0
 def get_file_items(self, window, sel_items):
     """Adds the 'Replace in Filenames' menu item to the FileBrowser
     right-click menu,
        connects its 'activate' signal to the 'run' method passing the
         selected Directory/File"""
     sel_items = get_files(sel_items)
     if not len(sel_items) > 0:
         return
     item = FileBrowser.MenuItem(
         name='AntiviralMenuProvider::Gtk-antiviral-tools',
         label=_('Scan folder'),
         tip=_('Scan this folder'),
         icon='Gtk-find-and-replace')
     item.connect('activate', self.addfolders, sel_items)
     return item,
Пример #28
0
    def make_menu_item(self, item, id_magic):
        # In the nautilus extension we simply call the following:
        #     return item.make_nautilus_menu_item(id_magic)
        # but this won't work for Nemo because that function tries to
        # explicitly import from Nautilus. Instead we make the menu item here
        # manually, and pass it back out. I don't really know why it wasn't
        # done this way in the first place.

        identifier = item.make_magic_id(id_magic)
        menuitem = Nemo.MenuItem(name=identifier,
                                 label=item.make_label(),
                                 tip=item.tooltip,
                                 icon=item.icon)

        # Was that so hard?
        return menuitem
Пример #29
0
 def get_file_items(self, window, files):
     """ Tell nemo whether and when to show the menu """
     if len(files) != 1:
         return
     myfile = files[0]
     isdrive = self.is_valid_drive(myfile)
     if not isdrive:
         return
     item = Nemo.MenuItem(
         name='Nemo::extvol_close',
         label=gettext.dgettext('extended-volume-manager',
                                'Close extended volume'),
         tip=gettext.dgettext(
             'extended-volume-manager',
             'Closes and Unmounts the selected extended Volume'))
     item.connect('activate', self.close_activate_cb, myfile)
     return item,
    def get_file_items(self, window, files):
        if len(files) != 1:
            return

        fileObj = files[0]
        if fileObj.get_uri_scheme() != 'file':
            return
        if fileObj.is_directory():
            return
        filename = urllib.unquote(fileObj.get_uri())[7:]

        itemEncrypt = Nemo.MenuItem(name='EncryptMenuProvider::Encrypt',
                                    label='Зашифровать',
                                    tip='Зашифровать файл %s' % filename)

        itemEncrypt.connect("activate", self.menu_activate_cb, fileObj)
        return itemEncrypt,