class Nautilus(TweakPage): """Nautilus Settings""" def __init__(self): TweakPage.__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.pack_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.pack_start(box, False, False, 0) if not DISABLE: update_apt_cache(True) self.packageWorker = PackageWorker() 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.pack_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) state = self.packageWorker.perform_action(widget.get_toplevel(), to_add, to_rm) if state == 0: self.button.set_sensitive(False) InfoDialog(_("Update successful!")).launch() else: InfoDialog(_("Update failed!")).launch() update_apt_cache() 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)
class Compiz(TweakPage, CompizSetting): """Compiz Fusion tweak""" def __init__(self): TweakPage.__init__(self) self.create_interface() def create_interface(self): if module_check.has_apt(): update_apt_cache(True) self.packageWorker = PackageWorker() 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 module_check.has_ccm() and module_check.has_right_compiz(): hbox = gtk.HBox(False, 0) hbox.pack_start(self.create_edge_setting(), True, False, 0) edge_setting = SinglePack('Edge Settings', hbox) self.pack_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.pack_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.pack_start(box, False, False, 0) if module_check.has_apt(): update_apt_cache(True) 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.pack_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.pack_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): i = widget.get_active() if i == 4: widget.previous = None else: plugin = self.context.Plugins[plugins[i]] setting = plugin.Display[plugins_settings[plugins[i]]] setting.Value = edge self.context.Write() widget.previous = plugins[i] def create_edge_combo_box(self, edge): combobox = gtk.combo_box_new_text() combobox.append_text(_("Expo")) combobox.append_text(_("Show Windows")) combobox.append_text(_("Show Desktop")) combobox.append_text(_("Widget")) combobox.append_text("-") combobox.set_active(4) combobox.previous = None for k, v in plugins_settings.items(): plugin = self.context.Plugins[k] #TODO The plugin should be turned off when it is unused. if not plugin.Enabled: plugin.Enabled = True self.context.Write() setting = plugin.Display[v] if setting.Value == edge: combobox.previous = k combobox.set_active(plugins.index(k)) 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.packageWorker.perform_action(widget.get_toplevel(), to_add, to_rm) self.button.set_sensitive(False) InfoDialog(_("Update successful!")).launch() update_apt_cache() 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)