예제 #1
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(_('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)
예제 #2
0
class Nautilus(TweakModule):
    __title__ = _('Nautilus Settings')
    __desc__ = _('Settings your default file manager')
    __icon__ = ['file-manager', 'nautilus']
    __category__ = 'system'

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

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

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

        boxes = []
        hbox1 = gtk.HBox(False, 5)
        label = gtk.Label(_('Default thumbnail icon size (pixels)'))
        hbox1.pack_start(label, False, False, 0)
        boxes.append(hbox1)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'thumbnail_size',
                                      min = 16, max = 512, step = 16)
        hbox1.pack_end(button, False, False, 0)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'maximum_size',
                                      min = -1, max = 512, step = 1)
        if button:
            hbox2 = gtk.HBox(False, 5)
            label = gtk.Label(_('Maximum size of the thumbnail cache (megabytes)'))

            hbox2.pack_start(label, False, False, 0)
            hbox2.pack_end(button, False, False, 0)
            boxes.append(hbox2)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'maximum_age',
                                      min = -1, max = 180, step = 1)

        if button:
            hbox3 = gtk.HBox(False, 5)
            label = gtk.Label(_('Maximum age for the thumbnail in the cache (days)'))
            hbox3.pack_start(label, False, False, 0)
            hbox3.pack_end(button, False, False, 0)
            boxes.append(hbox3)

        hbox4 = gtk.HBox(False, 5)
        button = gtk.Button(stock = gtk.STOCK_CLEAR)
        self.set_clean_button_label(button)
        button.connect('clicked', self.on_clean_thumbnails_clicked)
        hbox4.pack_end(button, False, False, 0)
        boxes.append(hbox4)

        box = ListPack(_('Thumbnails Settings'), boxes)
        self.add_start(box, False, False, 0)


        if not DISABLE:
            self.package_worker = package_worker

            self.nautilus_terminal = AptCheckButton(_('Nautilus with Open Terminal'), 'nautilus-open-terminal')
            self.nautilus_terminal.connect('toggled', self.colleague_changed)
            self.nautilus_root = AptCheckButton(_('Nautilus 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, _('Clean up the thumbnails cache (will free %s of disk space)') % filesizeformat(size))

    def on_clean_thumbnails_clicked(self, widget):
        question = QuestionDialog(_('The thumbnails cache will be cleaned, 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)
예제 #3
0
class Compiz(TweakModule, CompizSetting):
    __title__ = _('Compiz Settings')
    __desc__ = _('Setting with your amazing eye-candy desktop')
    __icon__ = ['compiz', 'wmtweaks']
    __category__ = 'desktop'

    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(_('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]
            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])
                if not plugin.Enabled:
                    plugin.Enabled = True
                    self.context.Write()
                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/ubuntu-tweak.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)
예제 #4
0
    def __init__(self):
        TweakModule.__init__(self)

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

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

        boxes = []
        hbox1 = gtk.HBox(False, 5)
        label = gtk.Label(_('Default thumbnail icon size (pixels)'))
        hbox1.pack_start(label, False, False, 0)
        boxes.append(hbox1)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'thumbnail_size',
                                      min = 16, max = 512, step = 16)
        hbox1.pack_end(button, False, False, 0)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'maximum_size',
                                      min = -1, max = 512, step = 1)
        if button:
            hbox2 = gtk.HBox(False, 5)
            label = gtk.Label(_('Maximum size of the thumbnail cache (megabytes)'))

            hbox2.pack_start(label, False, False, 0)
            hbox2.pack_end(button, False, False, 0)
            boxes.append(hbox2)

        button = WidgetFactory.create('GconfSpinButton', 
                                      key = 'maximum_age',
                                      min = -1, max = 180, step = 1)

        if button:
            hbox3 = gtk.HBox(False, 5)
            label = gtk.Label(_('Maximum age for the thumbnail in the cache (days)'))
            hbox3.pack_start(label, False, False, 0)
            hbox3.pack_end(button, False, False, 0)
            boxes.append(hbox3)

        hbox4 = gtk.HBox(False, 5)
        button = gtk.Button(stock = gtk.STOCK_CLEAR)
        self.set_clean_button_label(button)
        button.connect('clicked', self.on_clean_thumbnails_clicked)
        hbox4.pack_end(button, False, False, 0)
        boxes.append(hbox4)

        box = ListPack(_('Thumbnails Settings'), boxes)
        self.add_start(box, False, False, 0)


        if not DISABLE:
            self.package_worker = package_worker

            self.nautilus_terminal = AptCheckButton(_('Nautilus with Open Terminal'), 'nautilus-open-terminal')
            self.nautilus_terminal.connect('toggled', self.colleague_changed)
            self.nautilus_root = AptCheckButton(_('Nautilus 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)