class QuickLists(TweakModule):
    __title__ = _('QuickLists Editor')
    __desc__ = _('Unity Launcher QuickLists Editor')
    __icon__ = 'plugin-unityshell'
    __category__ = 'desktop'
    __desktop__ = ['ubuntu', 'ubuntu-2d']
    __utactive__ = True

    (DESKTOP_FILE,
     DESKTOP_ICON,
     DESKTOP_NAME,
     DESKTOP_ENTRY) = range(4)

    (ACTION_NAME,
     ACTION_FULLNAME,
     ACTION_EXEC,
     ACTION_ENABLED,
     ACTION_ENTRY) = range(5)

    def __init__(self):
        TweakModule.__init__(self, 'quicklists.ui')

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith('/') and os.path.exists(desktop_file):
                path = desktop_file
            else:
                if os.path.exists('/usr/share/applications/%s' % desktop_file):
                    path = '/usr/share/applications/%s' % desktop_file
                else:
                    log.debug("No desktop file avaialbe in for %s" % desktop_file)
                    continue
            try:
                entry = NewDesktopEntry(path)
            except Exception, e:
                log_traceback(log)
                continue

            self.icon_model.append((path,\
                                    icon.get_from_name(entry.getIcon(), size=32),\
                                    entry.getName(),
                                    entry))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
Exemple #2
0
class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,)),
        'load_feature': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,))
    }

    def __init__(self):
        GObject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.recently_used_settings = GSetting('com.ubuntu-tweak.tweak.recently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self.load_cips()
        self.setup_recently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.recently_used_settings.connect_notify(self.setup_recently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()
        log.debug("All clips to load: %s" % clips)

        if clips and clips != ['']:
            loader = ModuleLoader('clips')

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    clip.show_all()
                    self.clipvbox.pack_start(clip, False, False, 0)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
Exemple #3
0
class QuickLists(TweakModule):
    __title__ = _("QuickLists Editor")
    __desc__ = _("Unity Launcher QuickLists Editor")
    __icon__ = "plugin-unityshell"
    __category__ = "desktop"
    __desktop__ = ["ubuntu", "ubuntu-2d"]
    __utactive__ = True

    (DESKTOP_FILE, DESKTOP_ICON, DESKTOP_NAME, DESKTOP_ENTRY) = range(4)

    (ACTION_NAME, ACTION_FULLNAME, ACTION_EXEC, ACTION_ENABLED, ACTION_ENTRY) = range(5)

    def __init__(self):
        TweakModule.__init__(self, "quicklists.ui")

        self.launcher_setting = GSetting("com.canonical.Unity.Launcher.favorites")
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect("changed", self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith("/") and os.path.exists(desktop_file):
                path = desktop_file
            else:
                user_path = os.path.join(NewDesktopEntry.user_folder, desktop_file)
                system_path = os.path.join(NewDesktopEntry.system_folder, desktop_file)

                if os.path.exists(user_path):
                    path = user_path
                elif os.path.exists(system_path):
                    path = system_path
                else:
                    log.debug("No desktop file avaialbe in for %s" % desktop_file)
                    continue
            try:
                entry = NewDesktopEntry(path)
            except Exception, e:
                log_traceback(log)
                continue

            self.icon_model.append((path, icon.get_from_name(entry.getIcon(), size=32), entry.getName(), entry))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
Exemple #4
0
class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module':
        (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_STRING, )),
        'load_feature':
        (GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_STRING, ))
    }

    def __init__(self):
        GObject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.recently_used_settings = GSetting(
            'com.ubuntu-tweak.tweak.recently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self.load_cips()
        self.setup_recently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.recently_used_settings.connect_notify(self.setup_recently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()
        log.debug("All clips to load: %s" % clips)

        if clips and clips != ['']:
            loader = ModuleLoader('clips')

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    clip.show_all()
                    self.clipvbox.pack_start(clip, False, False, 0)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
Exemple #5
0
class CheckButton(Gtk.CheckButton):
    def __str__(self):
        return '<CheckButton with key: %s>' % self.setting.key

    def __init__(self, label=None, key=None,
                 default=None, tooltip=None, backend=GConf):
        gobject.GObject.__init__(self, label=label)
        if backend == GConf:
            self.setting = GconfSetting(key=key, default=default, type=bool)
        elif backend == Gio:
            self.setting = GSetting(key=key, default=default, type=bool)

        self.set_active(self.setting.get_value())
        if tooltip:
            self.set_tooltip_text(tooltip)

        self.setting.connect_notify(self.on_value_changed)
        self.connect('toggled', self.on_button_toggled)

    def on_value_changed(self, *args):
        self.set_active(self.setting.get_value())

    def on_button_toggled(self, widget):
        self.setting.set_value(self.get_active())
class FontButton(Gtk.FontButton):
    def __init__(self, key=None, default=None, backend='gconf'):
        GObject.GObject.__init__(self)
        self.set_use_font(True)
        self.set_use_size(True)

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, default=default, type=str)
        else:
            self._setting = GSetting(key=key, default=default, type=str)

        self.on_value_changed()

        self.connect('font-set', self.on_font_set)
        self._setting.connect_notify(self.on_value_changed)

    def on_font_set(self, widget):
        self._setting.set_value(self.get_font_name())

    def on_value_changed(self, *args):
        string = self._setting.get_value()

        if string:
            self.set_font_name(string)
Exemple #7
0
class QuickLists(TweakModule):
    __title__ = _('QuickLists Editor')
    __desc__ = _('Unity Launcher QuickLists Editor')
    __icon__ = 'plugin-unityshell'
    __category__ = 'desktop'
    __desktop__ = ['ubuntu', 'ubuntu-2d']
    __utactive__ = True

    (DESKTOP_FILE,
     DESKTOP_ICON,
     DESKTOP_NAME,
     DESKTOP_ENTRY) = range(4)

    (ACTION_NAME,
     ACTION_FULLNAME,
     ACTION_EXEC,
     ACTION_ENABLED,
     ACTION_ENTRY) = range(5)

    QUANTAL_SPECIFIC_ITEMS = {
        'unity://running-apps': _('Running Apps'),
        'unity://expo-icon': _('Workspace Switcher'),
        'unity://devices': _('Devices')
    }

    UNITY_WEBAPPS_ACTION_PATTERN = re.compile('^S\d{1}$')

    def __init__(self):
        TweakModule.__init__(self, 'quicklists.ui')

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith('/') and os.path.exists(desktop_file):
                path = desktop_file
            else:
                if desktop_file.startswith('application://'):
                    desktop_file = desktop_file.split('application://')[1]
                    log.debug("Desktop file for quantal: %s" % desktop_file)

                user_path = os.path.join(NewDesktopEntry.user_folder, desktop_file)
                system_path = os.path.join(NewDesktopEntry.system_folder, desktop_file)

                if os.path.exists(user_path):
                    path = user_path
                elif os.path.exists(system_path):
                    path = system_path
                else:
                    path = desktop_file

            try:
                entry = NewDesktopEntry(path)

                self.icon_model.append((path,
                                        icon.get_from_name(entry.getIcon(), size=32),
                                        entry.getName(),
                                        entry))
            except Exception, e:
                log_traceback(log)
                if path in self.QUANTAL_SPECIFIC_ITEMS.keys():
                    self.icon_model.append((path,
                                            icon.get_from_name('plugin-unityshell', size=32),
                                            self.QUANTAL_SPECIFIC_ITEMS[path],
                                            None))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)
Exemple #8
0
class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,)),
        'load_feature': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            (GObject.TYPE_STRING,))
    }

    (DIRECTION_UP, DIRECTION_DOWN) = ('UP', 'DOWN')
    direction = None

    def __init__(self):
        GObject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.rencently_used_settings = GSetting('com.ubuntu-tweak.tweak.rencently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self._up_clips = []
        self._showed_clips = []
        self._down_clips = []

        self.load_cips()
        self.setup_rencently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.connect('draw', self.on_draw_event)
        self.rencently_used_settings.connect_notify(self.setup_rencently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def on_draw_event(self, widget, event):
        self.slide_clips()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()

        if clips and clips != ['']:
            loader = ModuleLoader('clips')

            self._clips = []
            self._up_clips = []
            self._showed_clips = []
            self._down_clips = []
            self.clipvbox.set_data('direction', 0)

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    self._clips.append(clip)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
Exemple #9
0
class ClipPage(Gtk.VBox, GuiBuilder):
    __gsignals__ = {
        'load_module': (gobject.SIGNAL_RUN_FIRST,
                            gobject.TYPE_NONE,
                            (gobject.TYPE_STRING,)),
        'load_feature': (gobject.SIGNAL_RUN_FIRST,
                            gobject.TYPE_NONE,
                            (gobject.TYPE_STRING,))
    }

    max_recently_used_size = 200

    (DIRECTION_UP, DIRECTION_DOWN) = ('UP', 'DOWN')
    direction = None

    def __init__(self):
        gobject.GObject.__init__(self)
        GuiBuilder.__init__(self, 'clippage.ui')

        self.rencently_used_settings = GSetting('com.ubuntu-tweak.tweak.rencently-used')
        self.clips_settings = GSetting('com.ubuntu-tweak.tweak.clips')

        self._up_clips = []
        self._showed_clips = []
        self._down_clips = []

        self.load_cips()
        self.setup_rencently_used()

        self.pack_start(self.get_object('hbox1'), True, True, 0)
        self.connect('expose-event', self.on_expose_event)
        self.rencently_used_settings.connect_notify(self.setup_rencently_used)
        self.clips_settings.connect_notify(self.load_cips, True)

        self.show()

    def on_expose_event(self, widget, event):
        frame_width = int(self.get_allocation().width / 4.5)

        if frame_width > self.max_recently_used_size:
            frame_width = self.max_recently_used_size
        self.rencently_frame.set_size_request(frame_width, -1)

        self.slide_clips()

    def load_cips(self, a=None, b=None, do_remove=False):
        log.debug("Load clips, do_remove: %s" % do_remove)

        if do_remove:
            for child in self.clipvbox.get_children():
                log.debug("Remove clip: %s" % child)
                self.clipvbox.remove(child)

        clips = self.clips_settings.get_value()

        if clips != ['']:
            loader = ModuleLoader('clips')

            self._up_clips = []
            self._showed_clips = []
            self._down_clips = []
            self.clipvbox.set_data('direction', 0)

            for name in clips:
                try:
                    ClipClass = loader.get_module(name)
                    log.debug("Load clip: %s" % name)
                    clip = ClipClass()
                    clip.connect('load_module', self._on_module_button_clicked)
                    clip.connect('load_feature', self.on_clip_load_feature)
                    clip.show()
                    self.clipvbox.pack_start(clip, False, False, 0)
                except Exception, e:
                    log.error(traceback.print_exc())
                    if name in self.clips_settings.get_value():
                        new_list = self.clips_settings.get_value().remove(name)
                        self.clips_settings.set_value(new_list)
Exemple #10
0
class QuickLists(TweakModule):
    __title__ = _('QuickLists Editor')
    __desc__ = _('Unity Launcher QuickLists Editor')
    __icon__ = 'plugin-unityshell'
    __category__ = 'desktop'
    __desktop__ = ['ubuntu', 'ubuntu-2d']
    __utactive__ = True

    (DESKTOP_FILE,
     DESKTOP_ICON,
     DESKTOP_NAME,
     DESKTOP_ENTRY) = range(4)

    (ACTION_NAME,
     ACTION_FULLNAME,
     ACTION_EXEC,
     ACTION_ENABLED,
     ACTION_ENTRY) = range(5)

    def __init__(self):
        TweakModule.__init__(self, 'quicklists.ui')

        self.launcher_setting = GSetting('com.canonical.Unity.Launcher.favorites')
        self.launcher_setting.connect_notify(self.update_launch_icon_model)

        self.action_view.get_selection().connect('changed', self.on_action_selection_changed)

        self.update_launch_icon_model()

        self.add_start(self.main_paned)

    @log_func(log)
    def update_launch_icon_model(self, *args):
        self.icon_model.clear()

        for desktop_file in self.launcher_setting.get_value():
            log.debug('Processing with "%s"...' % desktop_file)
            if desktop_file.startswith('/') and os.path.exists(desktop_file):
                path = desktop_file
            else:
                user_path = os.path.join(NewDesktopEntry.user_folder, desktop_file)
                system_path = os.path.join(NewDesktopEntry.system_folder, desktop_file)

                if os.path.exists(user_path):
                    path = user_path
                elif os.path.exists(system_path):
                    path = system_path
                else:
                    log.debug("No desktop file avaialbe in for %s" % desktop_file)
                    continue
            try:
                entry = NewDesktopEntry(path)
            except Exception, e:
                log_traceback(log)
                continue

            self.icon_model.append((path,\
                                    icon.get_from_name(entry.getIcon(), size=32),\
                                    entry.getName(),
                                    entry))

        first_iter = self.icon_model.get_iter_first()
        if first_iter:
            self.icon_view.get_selection().select_iter(first_iter)