def event_command(self, widget, event):
     widget.unselect_all()
     model = widget.get_model()
     iter = model.get_iter(event)
     command = model.get_value(iter, 2)
     GLib.spawn_command_line_async(command)
     self.popover.hide()
Example #2
0
 def _edit_tag(self, action, variant):
     """
         Run tag editor
     """
     album_path = Lp.albums.get_path(self._object_id)
     GLib.spawn_command_line_async("%s \"%s\"" % (self._tag_editor,
                                                  album_path))
Example #3
0
    def convert_files(self, action, shell):
        page = shell.props.selected_page
        if not hasattr(page, "get_entry_view"):
            return

        entries = page.get_entry_view().get_selected_entries()
        cmdline = 'ftransc_qt ' + " ".join(entry.get_playback_uri() for entry in entries)
        GLib.spawn_command_line_async(cmdline)
Example #4
0
    def send_to(self, action, shell):
        page = shell.props.selected_page
        if not hasattr(page, "get_entry_view"):
            return

        entries = page.get_entry_view().get_selected_entries()
        cmdline = 'nautilus-sendto ' + " ".join(entry.get_playback_uri() for entry in entries)
        GLib.spawn_command_line_async(cmdline)
Example #5
0
    def send_to(self, action, shell):
        page = shell.props.selected_page
        if not hasattr(page, "get_entry_view"):
            return

        entries = page.get_entry_view().get_selected_entries()
        cmdline = 'nautilus-sendto ' + " ".join(entry.get_playback_uri()
                                                for entry in entries)
        GLib.spawn_command_line_async(cmdline)
Example #6
0
def invoke_action(_notification, name):
    """Invoke action with `name`."""
    if name == 'default':
        action = config['actions']['default']
        command = config['actions'][action]
    else:
        command = config['actions'][name]

    logger.info('Action "%s" invoked by user, running command: %s', name,
                command)
    GLib.spawn_command_line_async(command)
 def __on_manage_cb(self):
     res, i = self.selection.get_selected()
     if not(i is None):
         val = self.profile_store.get_value(i, COLUMN['dir'])
         command = (HANDLE_PROFILE_CMD) % val
         print(command)
         try:
             GLib.spawn_command_line_async(command)
         except Exception as e:
             print(g(ERR_SPAWN) % command)
             print(e)
 def _sync_inhibitor(self):
     if (self._dfile.is_start_at_login_enabled()):
         GLib.spawn_command_line_async(self._inhibitor_path)
         return True
     else:
         bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
         bus.call('org.gnome.tweak-tool.lid-inhibitor',
                  '/org/gnome/tweak_tool/lid_inhibitor',
                  'org.gtk.Actions', 'Activate',
                  GLib.Variant('(sava{sv})',
                               ('quit', [], {})), None, 0, -1, None)
         return False
 def _sync_inhibitor(self):
     if (self._dfile.is_start_at_login_enabled()):
         GLib.spawn_command_line_async(self._inhibitor_path)
         return True
     else:
         bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
         bus.call('org.gnome.tweak-tool.lid-inhibitor',
                  '/org/gnome/tweak_tool/lid_inhibitor',
                  'org.gtk.Actions',
                  'Activate',
                  GLib.Variant('(sava{sv})', ('quit', [], {})),
                  None, 0, -1, None)
         return False
    def on_close_clicked(self, *args):
        '''
        Exit the application when the window is closed. Optionally launch
        'xfce4-panel --preferences' if the application is launched with
        '--from-profile' option.
        '''
        if self.from_panel:
            path = GLib.find_program_in_path('xfce4-panel')

            if path != None:
                GLib.spawn_command_line_async(path + ' --preferences')

        Gtk.main_quit()
Example #11
0
    def __on_decide_policy(self, view, decision, decision_type):
        """
            Navigation policy
            @param view as WebKit2.WebView
            @param decision as WebKit2.NavigationPolicyDecision
            @param decision_type as WebKit2.PolicyDecisionType
            @return bool
        """
        # Always accept response
        if decision_type == WebKit2.PolicyDecisionType.RESPONSE:
            decision.use()
            return False

        url = decision.get_navigation_action().get_request().get_uri()
        # WTF is this?
        if url == "about:blank":
            decision.ignore()
            return True

        # Refused non allowed words
        found = False
        for word in self.__allowed_words:
            if word in url:
                found = True
                break
        if self.__allowed_words and not found:
            decision.ignore()
            return True

        # On clicked, if external wanted, launch user browser and stop
        # If navigation not allowed, stop
        if self.__open_link == OpenLink.NEW and\
                self.__get_domain(url) != self.__current_domain:
            GLib.spawn_command_line_async("xdg-open \"%s\"" % url)
            decision.ignore()
            return True
        elif self.__open_link == OpenLink.NONE:
            decision.ignore()
            return True
        # Use click, load page
        elif decision.get_navigation_action().get_navigation_type() ==\
                WebKit2.NavigationType.LINK_CLICKED:
            decision.use()
            return False
        # If external domain, do not load
        elif self.__get_domain(url) != self.__current_domain:
            decision.ignore()
            return True
        self.__current_domain = self.__get_domain(url)
        decision.use()
        return False
Example #12
0
    def _on_decide_policy(self, view, decision, decision_type):
        """
            Navigation policy
            @param view as WebKit2.WebView
            @param decision as WebKit2.NavigationPolicyDecision
            @param decision_type as WebKit2.PolicyDecisionType
            @return bool
        """
        # Always accept response
        if decision_type == WebKit2.PolicyDecisionType.RESPONSE:
            decision.use()
            return False

        url = decision.get_navigation_action().get_request().get_uri()
        # WTF is this?
        if url == "about:blank":
            decision.ignore()
            return True

        # Refused non allowed words
        found = False
        for word in self._allowed_words:
            if word in url:
                found = True
                break
        if self._allowed_words and not found:
            decision.ignore()
            return True

        # On clicked, if external wanted, launch user browser and stop
        # If navigation not allowed, stop
        if self._open_link == OpenLink.NEW and\
                self._get_domain(url) != self._current_domain:
            GLib.spawn_command_line_async("xdg-open \"%s\"" % url)
            decision.ignore()
            return True
        elif self._open_link == OpenLink.NONE:
            decision.ignore()
            return True
        # Use click, load page
        elif decision.get_navigation_action().get_navigation_type() ==\
                WebKit2.NavigationType.LINK_CLICKED:
            decision.use()
            return False
        # If external domain, do not load
        elif self._get_domain(url) != self._current_domain:
            decision.ignore()
            return True
        self._current_domain = self._get_domain(url)
        decision.use()
        return False
Example #13
0
 def _on_navigation_policy(self, view, frame, request, navigation_action,
                           policy_decision):
     """
         Disallow navigation, launch in external browser
         @param view as WebKit.WebView
         @param frame as WebKit.WebFrame
         @param request as WebKit.NetworkRequest
         @param navigation_action as WebKit.WebNavigationAction
         @param policy_decision as WebKit.WebPolicyDecision
         @return bool
     """
     if self._wikia_url == request.get_uri():
         return False
     elif request.get_uri() != 'about:blank':
         GLib.spawn_command_line_async("xdg-open \"%s\"" %
                                       request.get_uri())
     return True
Example #14
0
 def _on_navigation_policy(self, view, frame, request,
                           navigation_action, policy_decision):
     """
         Disallow navigation, launch in external browser
         @param view as WebKit.WebView
         @param frame as WebKit.WebFrame
         @param request as WebKit.NetworkRequest
         @param navigation_action as WebKit.WebNavigationAction
         @param policy_decision as WebKit.WebPolicyDecision
         @return bool
     """
     if self._wikia_url == request.get_uri():
         return False
     elif request.get_uri() != 'about:blank':
         GLib.spawn_command_line_async("xdg-open \"%s\"" %
                                       request.get_uri())
     return True
Example #15
0
 def _on_decide_policy(self, view, decision, decision_type):
     """
         Disallow navigation, launch in external browser
         @param view as WebKit2.WebView
         @param decision as WebKit2.NavigationPolicyDecision
         @param decision_type as WebKit2.PolicyDecisionType
         @return bool
     """
     if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION:
         if decision.get_navigation_action().get_navigation_type() == WebKit2.NavigationType.LINK_CLICKED or (
             self._current not in decision.get_navigation_action().get_request().get_uri()
             and decision.get_navigation_action().get_request().get_uri() != "about:blank"
         ):
             decision.ignore()
             GLib.spawn_command_line_async('xdg-open "%s"' % decision.get_request().get_uri())
         return True
     decision.use()
     return False
    def __build_controls(self):
        icon_size_label = Gtk.Label(g(ICON_SIZE_TEXT))
        self.icon_size_spin = Gtk.SpinButton.new_with_range(SPIN_START,
            SPIN_END, SPIN_STEP)
        
        def_profile_label = Gtk.Label(g(DEF_PROFILE_TEXT))
        self.def_profile = Gtk.Switch()
        
        split_view_label = Gtk.Label(g(SPLIT_VIEW_TEXT))
        self.split_view = Gtk.Switch()
        
        show_icons_label = Gtk.Label(g(SHOW_ICONS_TEXT))
        self.show_icons = Gtk.Switch()
        
        hide_non_xdg_label = Gtk.Label(g(HIDE_NON_XDG_TEXT))
        self.hide_non_xdg = Gtk.Switch()
        
        self.manage_default = Gtk.Button(g(MANAGE_DEFAULT))
        
        manage_default_label = Gtk.Label(g(MANAGE_DEFAULT))
        self.manage_default = Gtk.Button.new_from_stock(Gtk.STOCK_OPEN)
        self.manage_default.connect('clicked', lambda w:
                GLib.spawn_command_line_async(HANDLE_MAIN_PROFILE_CMD))
        
        table = Gtk.Table(TableSize.ROWS, TableSize.COLUMNS, False)

        top_attach = 0
        bottom_attach = 1

        def add_row(label, control, y1, y2):
            table.attach(label, ColumnAttach.LEFT, ColumnAttach.CENTER, y1, y2,
                Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
                Gtk.AttachOptions.SHRINK, PADDING, PADDING)
            table.attach(control, ColumnAttach.CENTER, ColumnAttach.RIGHT,
                y1, y2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK,
                PADDING, PADDING)
            label.set_alignment(MiscAlignment.LEFT, MiscAlignment.CENTER)
            return [ y1 + 1, y2 + 1]
        
        [ top_attach, bottom_attach ] = add_row(def_profile_label,
            self.def_profile, top_attach, bottom_attach)
        [ top_attach, bottom_attach ] = add_row(split_view_label,
            self.split_view, top_attach, bottom_attach)
        [ top_attach, bottom_attach ] = add_row(show_icons_label,
            self.show_icons, top_attach, bottom_attach)
        [ top_attach, bottom_attach ] = add_row(hide_non_xdg_label,
            self.hide_non_xdg, top_attach, bottom_attach)
        [ top_attach, bottom_attach ] = add_row(icon_size_label,
            self.icon_size_spin, top_attach, bottom_attach)
        [ top_attach, bottom_attach ] = add_row(manage_default_label,
            self.manage_default, top_attach, bottom_attach)

        table.set_property('row-spacing', SPACING)
        table.set_property('column-spacing', SPACING)
        table.set_property('border-width', 2 * PADDING)
        
        return table
Example #17
0
 def _on_decide_policy(self, view, decision, decision_type):
     """
         Disallow navigation, launch in external browser
         @param view as WebKit2.WebView
         @param decision as WebKit2.NavigationPolicyDecision
         @param decision_type as WebKit2.PolicyDecisionType
         @return bool
     """
     if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION:
         if decision.get_navigation_action().get_navigation_type() ==\
            WebKit2.NavigationType.LINK_CLICKED or (self._current not
            in decision.get_navigation_action().get_request().get_uri() and
            decision.get_navigation_action().get_request().get_uri() !=
            'about:blank'):
             decision.ignore()
             GLib.spawn_command_line_async("xdg-open \"%s\"" %
                                           decision.get_request().get_uri())
         return True
     decision.use()
     return False
Example #18
0
    def apply_command(self, action, data):
        def uri_to_filename(uri):
            uri = unquote(uri)
            if uri[0:8] == '\'file://':
                return uri[0] + uri[8:]
            else:
                return ''

        def quote_file_name(fn):
            return '\'' + fn.replace('\'', '\'\\\'\'') + '\''

        page = self.shell.props.selected_page
        if not hasattr(page, "get_entry_view"):
            return

        entries = page.get_entry_view().get_selected_entries()
        cmdline = self.settings["command"]
        Umacro = ' '.join(
            quote_file_name(entry.get_playback_uri()) for entry in entries)
        Fmacro = ' '.join(
            uri_to_filename(quote_file_name(entry.get_playback_uri()))
            for entry in entries)
        if cmdline.find('%f') != -1 or cmdline.find('%u') != -1:
            if len(entries) != 1:
                print(
                    "\x1b[150G selected " + str(len(entries)) +
                    " elements, macroses %f and %u acceptable only with one element, I think so"
                )
                return
        if (((cmdline.find('%F')!=-1) or (cmdline.find('%f')!=-1)) and not Fmacro.lstrip()) or \
           (((cmdline.find('%U')!=-1) or (cmdline.find('%u')!=-1)) and not Umacro.lstrip()):
            print("\x1b[150G Not enought filenames/urls to call " + cmdline)
            return

        cmdline = cmdline.replace('%F', Fmacro).replace('%U', Umacro).replace(
            '%f', Fmacro).replace('%u', Umacro)
        print("\x1b[150G command=" + cmdline)
        GLib.spawn_command_line_async(cmdline)
Example #19
0
 def finished(*args, **kwargs):
     GLib.spawn_command_line_async(CONTROL_PANEL_COMMAND)
     Gtk.main_quit()
Example #20
0
 def launch_audio_settings(self, data):
     GLib.spawn_command_line_async("gnome-control-center sound")
 def launch_audio_settings (self, data):
     GLib.spawn_command_line_async ("gnome-control-center sound")
Example #22
0
 def finished(*args, **kwargs):
     GLib.spawn_command_line_async('ubuntuone-control-panel-gtk')
     Gtk.main_quit()