Exemplo n.º 1
0
    def __init__(self):
        TweakModule.__init__(self)

        button = WidgetFactory.create("GconfCheckButton", 
                                      label=_('Show advanced permissions in the Nautilus "File Properties" window'),
                                      enable_reset=True,
                                      key="show_advanced_permissions")

        box = ListPack(_("File Browser"), (button, )) 
        self.add_start(box, False, False, 0)

        hbox1 = gtk.HBox(False, 12)
        button = gtk.Button(stock = gtk.STOCK_CLEAR)
        self.set_clean_button_label(button)
        button.connect('clicked', self.on_clean_thumbnails_clicked)
        hbox1.pack_end(button, False, False, 0)

        box = TablePack(_('Thumbnail Settings'), (
                    WidgetFactory.create('GconfSpinButton',
                                                  key='thumbnail_size',
                                                  enable_reset=True,
                                                  min=16, max=512, step=16,
                                                  label=_('Default thumbnail icon size (pixels)')),
                    WidgetFactory.create('GconfSpinButton',
                                                  key='maximum_size',
                                                  enable_reset=True,
                                                  min=-1, max=512, step=1,
                                                  label=_('Maximum thumbnail cache size (megabytes)')),
                    WidgetFactory.create('GconfSpinButton',
                                                  key='maximum_age',
                                                  enable_reset=True,
                                                  min=-1, max=180, step=1,
                                                  label=_('Thumbnail cache time (days)')),
                    hbox1,
            ))
        self.add_start(box, False, False, 0)

        self.PACKAGE_WORKER = PACKAGE_WORKER

        self.nautilus_terminal = AptCheckButton(_('Open folder in terminal'), 'nautilus-open-terminal')
        self.nautilus_terminal.connect('toggled', self.colleague_changed)
        self.nautilus_root = AptCheckButton(_('Open folder with root privileges'), 'nautilus-gksu')
        self.nautilus_root.connect('toggled', self.colleague_changed)
        self.nautilus_wallpaper = AptCheckButton(_('Nautilus with wallpaper'), 'nautilus-wallpaper')
        self.nautilus_wallpaper.connect('toggled', self.colleague_changed)
        box = ListPack(_("Nautilus Extensions"), (
            self.nautilus_terminal,
            self.nautilus_root,
            self.nautilus_wallpaper,
        ))

        self.button = gtk.Button(stock = gtk.STOCK_APPLY)
        self.button.connect("clicked", self.on_apply_clicked, box)
        self.button.set_sensitive(False)
        hbox = gtk.HBox(False, 0)
        hbox.pack_end(self.button, False, False, 0)

        box.vbox.pack_start(hbox, False, False, 0)

        self.add_start(box, False, False, 0)
Exemplo n.º 2
0
    def create_interface(self):
        if module_check.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(_("Install Advanced Desktop Effects Settings Manager"),
                    'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(_("Install Simple Desktop Effects Settings Manager"),
                    'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(_("Install Screenlets Widget Application"),
                    'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if self.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self);

            box = ListPack(_("Window Effects"), (self.snap, self.wobbly_w))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if module_check.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock = gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        else:
            box = ListPack(_("Prerequisite Conditions"), (
                self.advanced_settings,
            ))

            self.button = gtk.Button(stock = gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)
Exemplo n.º 3
0
class Nautilus(TweakModule):
    __title__ = _('Nautilus Settings')
    __desc__ = _('Manage the default file manager')
    __icon__ = ['file-manager', 'nautilus']
    __category__ = 'system'
    __desktop__ = ['gnome', 'une']

    def __init__(self):
        TweakModule.__init__(self)

        button = WidgetFactory.create("GconfCheckButton", 
                                      label=_('Show advanced permissions in the Nautilus "File Properties" window'),
                                      enable_reset=True,
                                      key="show_advanced_permissions")

        box = ListPack(_("File Browser"), (button, )) 
        self.add_start(box, False, False, 0)

        hbox1 = gtk.HBox(False, 12)
        button = gtk.Button(stock = gtk.STOCK_CLEAR)
        self.set_clean_button_label(button)
        button.connect('clicked', self.on_clean_thumbnails_clicked)
        hbox1.pack_end(button, False, False, 0)

        box = TablePack(_('Thumbnail Settings'), (
                    WidgetFactory.create('GconfSpinButton',
                                                  key='thumbnail_size',
                                                  enable_reset=True,
                                                  min=16, max=512, step=16,
                                                  label=_('Default thumbnail icon size (pixels)')),
                    WidgetFactory.create('GconfSpinButton',
                                                  key='maximum_size',
                                                  enable_reset=True,
                                                  min=-1, max=512, step=1,
                                                  label=_('Maximum thumbnail cache size (megabytes)')),
                    WidgetFactory.create('GconfSpinButton',
                                                  key='maximum_age',
                                                  enable_reset=True,
                                                  min=-1, max=180, step=1,
                                                  label=_('Thumbnail cache time (days)')),
                    hbox1,
            ))
        self.add_start(box, False, False, 0)

        self.PACKAGE_WORKER = PACKAGE_WORKER

        self.nautilus_terminal = AptCheckButton(_('Open folder in terminal'), 'nautilus-open-terminal')
        self.nautilus_terminal.connect('toggled', self.colleague_changed)
        self.nautilus_root = AptCheckButton(_('Open folder with root privileges'), 'nautilus-gksu')
        self.nautilus_root.connect('toggled', self.colleague_changed)
        self.nautilus_wallpaper = AptCheckButton(_('Nautilus with wallpaper'), 'nautilus-wallpaper')
        self.nautilus_wallpaper.connect('toggled', self.colleague_changed)
        box = ListPack(_("Nautilus Extensions"), (
            self.nautilus_terminal,
            self.nautilus_root,
            self.nautilus_wallpaper,
        ))

        self.button = gtk.Button(stock = gtk.STOCK_APPLY)
        self.button.connect("clicked", self.on_apply_clicked, box)
        self.button.set_sensitive(False)
        hbox = gtk.HBox(False, 0)
        hbox.pack_end(self.button, False, False, 0)

        box.vbox.pack_start(hbox, False, False, 0)

        self.add_start(box, False, False, 0)

    def set_clean_button_label(self, button):
        try:
            size = os.popen('du -bs ~/.thumbnails').read().split()[0]
        except:
            size = '0'
            button.set_sensitive(False)
        set_label_for_stock_button(button, _('Delete thumbnail cache (Frees %s of disk space)') % filesizeformat(size))

    def on_clean_thumbnails_clicked(self, widget):
        question = QuestionDialog(_('The thumbnail cache will be deleted. Do you wish to continue?'),
            title = _('Warning'))
        if question.run() == gtk.RESPONSE_YES:
            question.destroy()

            dialog = CleanDialog(widget.get_toplevel())
            dialog.run()
            InfoDialog(_('Clean up Successful!')).launch()
            self.set_clean_button_label(widget)
        else:
            question.destroy()

    def on_apply_clicked(self, widget, box):
        to_add = []
        to_rm = []

        for widget in box.items:
            if widget.get_active():
                to_add.append(widget.pkgname)
            else:
                to_rm.append(widget.pkgname)

        self.PACKAGE_WORKER.perform_action(widget.get_toplevel(), to_add, to_rm)
        self.PACKAGE_WORKER.update_apt_cache(True)

        done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

        if done:
            self.button.set_sensitive(False)
            InfoDialog(_('Update Successful!')).launch()
        else:
            InfoDialog(_('Update Failed!')).launch()
            for widget in box.items:
                widget.reset_active()

    def colleague_changed(self, widget):
        if self.nautilus_terminal.get_state() != self.nautilus_terminal.get_active() or\
                self.nautilus_root.get_state() != self.nautilus_root.get_active() or\
                self.nautilus_wallpaper.get_state() != self.nautilus_wallpaper.get_active():
                    self.button.set_sensitive(True)
        else:
            self.button.set_sensitive(False)
Exemplo n.º 4
0
    def create_interface(self):
        if system.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(_("Install Advanced Desktop Effects Settings Manager"),
                    'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(_("Install Simple Desktop Effects Settings Manager"),
                    'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(_("Install Screenlets Widget Application"),
                    'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if CompizPlugin.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self);
            self.viewport = ViewpointSwitcher(_('Enable workspace switching with mouse wheel'))
#            if system.CODENAME == 'natty':
#                self.launcher_autohide = UnityLauncherAutoHide(_('Make the launcher hide automatically after some time inactive'))
#            else:
            self.launcher_autohide = None

            box = ListPack(_("Desktop Effects"), (self.snap,
                                                  self.wobbly_w,
                                                  self.viewport,
                                                  self.launcher_autohide))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if system.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock = gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        elif CompizPlugin.context == None:
            box = ListPack(_("Prerequisite Conditions"), (
                self.advanced_settings,
            ))

            self.button = gtk.Button(stock = gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)
Exemplo n.º 5
0
class Compiz(TweakModule):
    __title__ = _('Compiz Settings')
    __desc__ = _('Settings for some amazing desktop eye-candy')
    __icon__ = ['compiz', 'wmtweaks']
    __category__ = 'desktop'
    __desktop__ = 'gnome'

    def __init__(self):
        TweakModule.__init__(self)

        self.create_interface()

    def create_interface(self):
        if system.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(_("Install Advanced Desktop Effects Settings Manager"),
                    'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(_("Install Simple Desktop Effects Settings Manager"),
                    'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(_("Install Screenlets Widget Application"),
                    'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if CompizPlugin.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self);
            self.viewport = ViewpointSwitcher(_('Enable workspace switching with mouse wheel'))
#            if system.CODENAME == 'natty':
#                self.launcher_autohide = UnityLauncherAutoHide(_('Make the launcher hide automatically after some time inactive'))
#            else:
            self.launcher_autohide = None

            box = ListPack(_("Desktop Effects"), (self.snap,
                                                  self.wobbly_w,
                                                  self.viewport,
                                                  self.launcher_autohide))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if system.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock = gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        elif CompizPlugin.context == None:
            box = ListPack(_("Prerequisite Conditions"), (
                self.advanced_settings,
            ))

            self.button = gtk.Button(stock = gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)

    def combo_box_changed_cb(self, widget, edge):
        """If the current setting is none, then select the add edge"""
        current = widget.current
        text = widget.get_active_text()
        for k, v in plugins.items():
            if v == text:
                text = k
                break

        log.debug("The current value: %s and next value: %s" % (current, text))

        if current:
            # Clean old data
            log.debug("Clean old data from the same box")
            self.set_data(current, None)
            CompizSetting(CompizPlugin(current), plugins_settings[current]).set_value('')

        if self.get_data(text):
            log.debug("Clean old data from the other box")
            current_combox = self.get_data(text)

            if current_combox and current_combox != widget:
                # Set the current value holder to -, and set the current value to None
                current_combox.handler_block_by_func(self.combo_box_changed_cb)
                current_combox.current = None
                self.set_data(text, None)
                current_combox.set_active(self.get_data('max_index'))
                current_combox.handler_unblock_by_func(self.combo_box_changed_cb)

            log.debug("Clean old value, set %s to None" % text)

        if text == '-':
            self.set_data(widget.current, None)
            widget.current = None
        else:
            plugin = CompizPlugin(text)
            plugin.set_enabled(True)
            setting = CompizSetting(plugin, plugins_settings[text])
            setting.set_value(edge)
            widget.current = text
            self.set_data(text, widget)
            log.debug("set the current %s" % text)

    def create_edge_combo_box(self, edge):
        global plugins_settings, plugins
        combobox = gtk.combo_box_new_text()
        combobox.current = None

        enable = False
        count = 0
        for k, v in plugins_settings.items():
            if CompizPlugin.is_available(k, v):
                plugin = CompizPlugin(k)
                combobox.append_text(plugins[k])
                if CompizSetting(plugin, v).get_value() == edge:
                    combobox.current = k
                    combobox.set_active(count)
                    enable = True
                    self.set_data(k, combobox)
                    log.info("The %s is holding %s" % (edge, k))
                count = count + 1
            else:
                plugins.pop(k)
                plugins_settings.pop(k)

        combobox.append_text("-")
        if not enable:
            combobox.set_active(count)
        self.set_data('max_index', count)
        combobox.connect("changed", self.combo_box_changed_cb, edge)

        return combobox

    def create_edge_setting(self):
        hbox = gtk.HBox(False, 0)

        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)

        self.TopLeft = self.create_edge_combo_box("TopLeft")
        vbox.pack_start(self.TopLeft, False, False, 0)

        self.BottomLeft = self.create_edge_combo_box("BottomLeft")
        vbox.pack_end(self.BottomLeft, False, False, 0)

        client = gconf.client_get_default()
        wallpaper = client.get_string("/desktop/gnome/background/picture_filename")

        system_wallpaper = os.path.join(DATA_DIR, "pixmaps/splash.png")
        if wallpaper:
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(wallpaper, 160, 100)
            except gobject.GError:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(system_wallpaper, 160, 100)
        else:
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(system_wallpaper, 160, 100)
        image = gtk.image_new_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        
        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)
        
        self.TopRight = self.create_edge_combo_box("TopRight")
        vbox.pack_start(self.TopRight, False, False, 0)

        self.BottomRight = self.create_edge_combo_box("BottomRight")
        vbox.pack_end(self.BottomRight, False, False, 0)

        return hbox

    def on_apply_clicked(self, widget, box):
        to_add = []
        to_rm = []

        for widget in box.items:
            if widget.get_active():
                to_add.append(widget.pkgname)
            else:
                to_rm.append(widget.pkgname)

        self.PACKAGE_WORKER.perform_action(widget.get_toplevel(), to_add, to_rm)
        self.PACKAGE_WORKER.update_apt_cache(True)

        done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

        if done:
            self.button.set_sensitive(False)
            InfoDialog(_('Update Successful!')).launch()
        else:
            InfoDialog(_('Update Failed!')).launch()
            for widget in box.items:
                widget.reset_active()

        CompizPlugin.update_context()
        self.remove_all_children()
        self.create_interface()

        self.show_all()

    def colleague_changed(self, widget):
        if self.advanced_settings.get_state() != self.advanced_settings.get_active() or\
                self.simple_settings.get_state() != self.simple_settings.get_active() or\
                self.screenlets.get_state() != self.screenlets.get_active():
                    self.button.set_sensitive(True)
        else:
            self.button.set_sensitive(False)
Exemplo n.º 6
0
class Compiz(TweakModule, CompizSetting):
    __title__ = _('Compiz Settings')
    __desc__ = _('Settings for some amazing desktop eye-candy')
    __icon__ = ['compiz', 'wmtweaks']
    __category__ = 'desktop'
    __desktop__ = 'gnome'

    def __init__(self):
        TweakModule.__init__(self)

        self.create_interface()

    def create_interface(self):
        if module_check.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(_("Install Advanced Desktop Effects Settings Manager"),
                    'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(_("Install Simple Desktop Effects Settings Manager"),
                    'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(_("Install Screenlets Widget Application"),
                    'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if self.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self);

            box = ListPack(_("Window Effects"), (self.snap, self.wobbly_w))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if module_check.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock = gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        else:
            box = ListPack(_("Prerequisite Conditions"), (
                self.advanced_settings,
            ))

            self.button = gtk.Button(stock = gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)

    def combo_box_changed_cb(self, widget, edge):
        """If the previous setting is none, then select the add edge"""
        if widget.previous:
            self.change_edge(widget, edge)
        else:
            self.add_edge(widget, edge)

    def change_edge(self, widget, edge):
        previous = widget.previous

        plugin = self.context.Plugins[previous]
        setting = plugin.Display[plugins_settings[previous]]
        setting.Value = ""
        self.context.Write()

        self.add_edge(widget, edge)    

    def add_edge(self, widget, edge):
        text = widget.get_active_text()
        for k, v in plugins.items():
            if v == text:
                text = k
                break

        if text == '-':
            widget.previous = None
        else:
            plugin = self.context.Plugins[text]
            if not plugin.Enabled:
                plugin.Enabled = True
                self.context.Write()
            setting = plugin.Display[plugins_settings[text]]
            setting.Value = edge
            self.context.Write()
            widget.previous = text

    def create_edge_combo_box(self, edge):
        global plugins_settings, plugins
        combobox = gtk.combo_box_new_text()
        combobox.previous = None

        enable = False
        count = 0
        for k, v in plugins_settings.items():
            if self.context.Plugins.has_key(k):
                plugin = self.context.Plugins[k]
                combobox.append_text(plugins[k])
                setting = plugin.Display[v]
                if setting.Value == edge:
                    combobox.previous = k
                    combobox.set_active(count)
                    enable = True
                count = count + 1
            else:
                plugins.pop(k)
                plugins_settings.pop(k)

        combobox.append_text("-")
        if not enable:
            combobox.set_active(count)
        combobox.connect("changed", self.combo_box_changed_cb, edge)

        return combobox

    def create_edge_setting(self):
        hbox = gtk.HBox(False, 0)

        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)

        combobox = self.create_edge_combo_box("TopLeft")
        vbox.pack_start(combobox, False, False, 0)

        combobox = self.create_edge_combo_box("BottomLeft")
        vbox.pack_end(combobox, False, False, 0)

        client = gconf.client_get_default()
        wallpaper = client.get_string("/desktop/gnome/background/picture_filename")

        system_wallpaper = os.path.join(DATA_DIR, "pixmaps/splash.png")
        if wallpaper:
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(wallpaper, 160, 100)
            except gobject.GError:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(system_wallpaper, 160, 100)
        else:
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(system_wallpaper, 160, 100)
        image = gtk.image_new_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        
        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)
        
        combobox = self.create_edge_combo_box("TopRight")
        vbox.pack_start(combobox, False, False, 0)

        combobox = self.create_edge_combo_box("BottomRight")
        vbox.pack_end(combobox, False, False, 0)

        return hbox

    def on_apply_clicked(self, widget, box):
        to_add = []
        to_rm = []

        for widget in box.items:
            if widget.get_active():
                to_add.append(widget.pkgname)
            else:
                to_rm.append(widget.pkgname)

        self.PACKAGE_WORKER.perform_action(widget.get_toplevel(), to_add, to_rm)
        self.PACKAGE_WORKER.update_apt_cache(True)

        done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

        if done:
            self.button.set_sensitive(False)
            InfoDialog(_('Update Successful!')).launch()
        else:
            InfoDialog(_('Update Failed!')).launch()
            for widget in box.items:
                widget.reset_active()

        CompizSetting.update_context()
        self.remove_all_children()
        self.create_interface()

        self.show_all()

    def colleague_changed(self, widget):
        if self.advanced_settings.get_state() != self.advanced_settings.get_active() or\
                self.simple_settings.get_state() != self.simple_settings.get_active() or\
                self.screenlets.get_state() != self.screenlets.get_active():
                    self.button.set_sensitive(True)
        else:
            self.button.set_sensitive(False)
Exemplo n.º 7
0
    def create_interface(self):
        if system.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(
                _("Install Advanced Desktop Effects Settings Manager"),
                'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(
                _("Install Simple Desktop Effects Settings Manager"),
                'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(
                _("Install Screenlets Widget Application"), 'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if CompizPlugin.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self)
            self.viewport = ViewpointSwitcher(
                _('Enable workspace switching with mouse wheel'))
            if system.CODENAME == 'natty':
                self.launcher_autohide = UnityLauncherAutoHide(
                    _('Make the launcher hide automatically after some time inactive'
                      ))
            else:
                self.launcher_autohide = None

            box = ListPack(_("Desktop Effects"),
                           (self.snap, self.wobbly_w, self.viewport,
                            self.launcher_autohide))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if system.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock=gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        elif CompizPlugin.context == None:
            box = ListPack(_("Prerequisite Conditions"),
                           (self.advanced_settings, ))

            self.button = gtk.Button(stock=gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)
Exemplo n.º 8
0
class Compiz(TweakModule):
    __title__ = _('Compiz Settings')
    __desc__ = _('Settings for some amazing desktop eye-candy')
    __icon__ = ['compiz', 'wmtweaks']
    __category__ = 'desktop'
    __desktop__ = 'gnome'

    def __init__(self):
        TweakModule.__init__(self)

        self.create_interface()

    def create_interface(self):
        if system.has_apt() and PACKAGE_WORKER.get_cache():
            self.PACKAGE_WORKER = PACKAGE_WORKER

            self.advanced_settings = AptCheckButton(
                _("Install Advanced Desktop Effects Settings Manager"),
                'compizconfig-settings-manager')
            self.advanced_settings.connect('toggled', self.colleague_changed)
            self.simple_settings = AptCheckButton(
                _("Install Simple Desktop Effects Settings Manager"),
                'simple-ccsm')
            self.simple_settings.connect('toggled', self.colleague_changed)
            self.screenlets = AptCheckButton(
                _("Install Screenlets Widget Application"), 'screenlets')
            self.screenlets.connect('toggled', self.colleague_changed)

        if CompizPlugin.context:
            hbox = gtk.HBox(False, 0)
            hbox.pack_start(self.create_edge_setting(), True, False, 0)
            edge_setting = SinglePack(_(' Workspace Edge Settings'), hbox)
            self.add_start(edge_setting, False, False, 0)

            self.snap = SnapWindow(_("Enable snapping windows"), self)
            self.wobbly_w = WobblyWindow(_("Enable wobbly windows"), self)
            self.viewport = ViewpointSwitcher(
                _('Enable workspace switching with mouse wheel'))
            if system.CODENAME == 'natty':
                self.launcher_autohide = UnityLauncherAutoHide(
                    _('Make the launcher hide automatically after some time inactive'
                      ))
            else:
                self.launcher_autohide = None

            box = ListPack(_("Desktop Effects"),
                           (self.snap, self.wobbly_w, self.viewport,
                            self.launcher_autohide))
            self.add_start(box, False, False, 0)

            button1 = OpacityMenu(_("Enable transparent menus"))
            self.wobbly_m = WobblyMenu(_("Enable wobbly menus"), self)

            box = ListPack(_("Menu Effects"), (button1, self.wobbly_m))
            self.add_start(box, False, False, 0)

            if system.has_apt() and PACKAGE_WORKER.get_cache():
                box = ListPack(_("Useful Extensions"), (
                    self.simple_settings,
                    self.screenlets,
                ))

                self.button = gtk.Button(stock=gtk.STOCK_APPLY)
                self.button.connect("clicked", self.on_apply_clicked, box)
                self.button.set_sensitive(False)
                hbox = gtk.HBox(False, 0)
                hbox.pack_end(self.button, False, False, 0)

                box.vbox.pack_start(hbox, False, False, 0)

                self.add_start(box, False, False, 0)
        elif CompizPlugin.context == None:
            box = ListPack(_("Prerequisite Conditions"),
                           (self.advanced_settings, ))

            self.button = gtk.Button(stock=gtk.STOCK_APPLY)
            self.button.connect("clicked", self.on_apply_clicked, box)
            self.button.set_sensitive(False)
            hbox = gtk.HBox(False, 0)
            hbox.pack_end(self.button, False, False, 0)

            box.vbox.pack_start(hbox, False, False, 0)
            self.add_start(box, False, False, 0)

    def combo_box_changed_cb(self, widget, edge):
        """If the current setting is none, then select the add edge"""
        current = widget.current
        text = widget.get_active_text()
        for k, v in plugins.items():
            if v == text:
                text = k
                break

        log.debug("The current value: %s and next value: %s" % (current, text))

        if current:
            # Clean old data
            log.debug("Clean old data from the same box")
            self.set_data(current, None)
            CompizSetting(CompizPlugin(current),
                          plugins_settings[current]).set_value('')

        if self.get_data(text):
            log.debug("Clean old data from the other box")
            current_combox = self.get_data(text)

            if current_combox and current_combox != widget:
                # Set the current value holder to -, and set the current value to None
                current_combox.handler_block_by_func(self.combo_box_changed_cb)
                current_combox.current = None
                self.set_data(text, None)
                current_combox.set_active(self.get_data('max_index'))
                current_combox.handler_unblock_by_func(
                    self.combo_box_changed_cb)

            log.debug("Clean old value, set %s to None" % text)

        if text == '-':
            self.set_data(widget.current, None)
            widget.current = None
        else:
            plugin = CompizPlugin(text)
            plugin.set_enabled(True)
            setting = CompizSetting(plugin, plugins_settings[text])
            setting.set_value(edge)
            widget.current = text
            self.set_data(text, widget)
            log.debug("set the current %s" % text)

    def create_edge_combo_box(self, edge):
        global plugins_settings, plugins
        combobox = gtk.combo_box_new_text()
        combobox.current = None

        enable = False
        count = 0
        for k, v in plugins_settings.items():
            if CompizPlugin.is_available(k, v):
                plugin = CompizPlugin(k)
                combobox.append_text(plugins[k])
                if CompizSetting(plugin, v).get_value() == edge:
                    combobox.current = k
                    combobox.set_active(count)
                    enable = True
                    self.set_data(k, combobox)
                    log.info("The %s is holding %s" % (edge, k))
                count = count + 1
            else:
                plugins.pop(k)
                plugins_settings.pop(k)

        combobox.append_text("-")
        if not enable:
            combobox.set_active(count)
        self.set_data('max_index', count)
        combobox.connect("changed", self.combo_box_changed_cb, edge)

        return combobox

    def create_edge_setting(self):
        hbox = gtk.HBox(False, 0)

        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)

        self.TopLeft = self.create_edge_combo_box("TopLeft")
        vbox.pack_start(self.TopLeft, False, False, 0)

        self.BottomLeft = self.create_edge_combo_box("BottomLeft")
        vbox.pack_end(self.BottomLeft, False, False, 0)

        client = gconf.client_get_default()
        wallpaper = client.get_string(
            "/desktop/gnome/background/picture_filename")

        system_wallpaper = os.path.join(DATA_DIR, "pixmaps/splash.png")
        if wallpaper:
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                    wallpaper, 160, 100)
            except gobject.GError:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                    system_wallpaper, 160, 100)
        else:
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                system_wallpaper, 160, 100)
        image = gtk.image_new_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)

        vbox = gtk.VBox(False, 0)
        hbox.pack_start(vbox, False, False, 0)

        self.TopRight = self.create_edge_combo_box("TopRight")
        vbox.pack_start(self.TopRight, False, False, 0)

        self.BottomRight = self.create_edge_combo_box("BottomRight")
        vbox.pack_end(self.BottomRight, False, False, 0)

        return hbox

    def on_apply_clicked(self, widget, box):
        to_add = []
        to_rm = []

        for widget in box.items:
            if widget.get_active():
                to_add.append(widget.pkgname)
            else:
                to_rm.append(widget.pkgname)

        self.PACKAGE_WORKER.perform_action(widget.get_toplevel(), to_add,
                                           to_rm)
        self.PACKAGE_WORKER.update_apt_cache(True)

        done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

        if done:
            self.button.set_sensitive(False)
            InfoDialog(_('Update Successful!')).launch()
        else:
            InfoDialog(_('Update Failed!')).launch()
            for widget in box.items:
                widget.reset_active()

        CompizPlugin.update_context()
        self.remove_all_children()
        self.create_interface()

        self.show_all()

    def colleague_changed(self, widget):
        if self.advanced_settings.get_state() != self.advanced_settings.get_active() or\
                self.simple_settings.get_state() != self.simple_settings.get_active() or\
                self.screenlets.get_state() != self.screenlets.get_active():
            self.button.set_sensitive(True)
        else:
            self.button.set_sensitive(False)