def check_version(self): gtk.gdk.threads_enter() version = TweakSettings.get_version() if version > VERSION: dialog = QuestionDialog(_('A newer version: %s is available online.\nWould you like to update?' % version), title = _('Software Update')) update = False if dialog.run() == gtk.RESPONSE_YES: update = True dialog.destroy() if update: UpdateManager(self.get_toplevel()) gtk.gdk.threads_leave()
def on_change_icon_clicked(self, widget): dialog = gtk.FileChooserDialog(_('Choose a new logo'),action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = (gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)) filter = gtk.FileFilter() filter.set_name(_("PNG image (*.png)")) filter.add_mime_type("image/png") dialog.set_current_folder(os.path.expanduser('~')) dialog.add_filter(filter) dest = os.path.expanduser('~/.icons/%s/24x24/places/start-here.png' % self.__setting.get_icon_theme()) revert_button = dialog.action_area.get_children()[-1] if not os.path.exists(dest): revert_button.set_sensitive(False) filename = '' response = dialog.run() if response == gtk.RESPONSE_ACCEPT: filename = dialog.get_filename() if filename: pixbuf = gtk.gdk.pixbuf_new_from_file(filename) w, h = pixbuf.get_width(), pixbuf.get_height() if w != 24 or h != 24: ErrorDialog(_("The size isn't suitable for the panel.\nIt should be 24x24.")).launch() else: os.system('mkdir -p %s' % os.path.dirname(dest)) os.system('cp %s %s' % (filename, dest)) image = gtk.image_new_from_file(dest) widget.set_image(image) dialog.destroy() elif response == gtk.RESPONSE_DELETE_EVENT: os.remove(dest) image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24)) widget.set_image(image) dialog.destroy() else: dialog.destroy() return dialog = QuestionDialog(_('Do you want your changes to take effect immediately?')) if dialog.run() == gtk.RESPONSE_YES: os.system('killall gnome-panel') dialog.destroy()
def on_restore_directory(self, widget): model, iter = self.get_selection().get_selected() userdir = model.get_value(iter, COLUMN_DIR) dialog = QuestionDialog(_('Ubuntu Tweak will restore the chosen ' 'directory to the default location.\n' 'However, you must move your files back into place by yourself.\n' 'Do you wish to continue?')) if dialog.run() == gtk.RESPONSE_YES: newdir = os.path.join(os.getenv("HOME"), self.uf.get_restorename(userdir)) self.uf.set_userdir(userdir, newdir) model.set_value(iter, COLUMN_PATH, newdir) if not os.path.exists(newdir): os.mkdir(newdir) elif os.path.isfile(newdir): os.remove(newdir) os.mkdir(newdir) self.emit('changed') dialog.destroy()
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()