def do_places(self, *args): self.liststore.clear() self.places_paths = [] self.places_data = [] #Get the needed config values self.show_computer = self.client.get_bool(group, 'show_computer') self.show_home = self.client.get_int(group, 'show_home') self.show_filesystem = self.client.get_int(group, 'show_filesystem') self.show_local = self.client.get_int(group, 'show_local') self.show_network = self.client.get_int(group, 'show_network') self.show_connect = self.client.get_int(group, 'show_connect') self.show_bookmarks = self.client.get_int(group, 'show_bookmarks') self.show_trash = self.client.get_bool(group, 'show_trash') if self.show_computer and self.nautilus_computer: self.place('computer', _("Computer"), 'exec://nautilus computer:') #Home folder if self.show_home == 2: self.place('user-home', _("Home Folder"), os.environ['HOME']) #Filesystem if self.show_filesystem == 2: self.place('drive-harddisk', _("Filesystem"), '/')
def color2(self, key, text=False): key = 'color_' + key if text: key += '_text' #Make a GtkLabel if not text: label = gtk.Label(_('Background')) else: label = gtk.Label(_('Text')) label.set_alignment(0.0, 0.5) #Get a GdkColor color = gtk.gdk.color_parse(self.settings[key]) #Make a GtkColorButton button = gtk.ColorButton(color) button.key = key button.connect('color-set', self.color_set2) #HBox for the two widgets hbox = gtk.HBox() hbox.pack_start(label) hbox.pack_end(button, False) #Return it return hbox
def update_email_list(self): if self.__current_type is not "email_list": self.email_list() parent = self.__email_list.get_parent() parent.remove(self.__email_list) mail = self.__parent.mail self.__parent.awn.tooltip.set(strMessages(len(mail.subjects))) self.__parent.awn.theme.icon( "unread" if len(mail.subjects) > 0 else "read") if len(mail.subjects) > 0: self.__dialog.set_title( strMessages(len(self.__parent.mail.subjects))) self.__email_list = gtk.Table(len(self.__parent.mail.subjects), 2) self.__email_list.set_col_spacings(10) for i in xrange(len(mail.subjects)): label = gtk.Label("<b>" + str(i + 1) + "</b>") label.set_use_markup(True) self.__email_list.attach(label, 0, 1, i, i + 1) label = gtk.Label(mail.subjects[i]) label.set_use_markup(True) label.set_alignment(0.0, 0.5) self.__email_list.attach(label, 1, 2, i, i + 1) else: self.__dialog.set_title(_("No unread messages")) self.__email_list = gtk.Label("<i>%s</i>" % _("No new messages")) self.__email_list.set_use_markup(True) self.__email_list.show_all() parent.pack_start(self.__email_list)
def create_documents_submenu(self, menu): recent_manager = gtk.recent_manager_get_default() chooser_menu = gtk.RecentChooserMenu(recent_manager) recent_item = self.append_menu_item(menu, _("Recent Documents"), "document-open-recent", None) recent_item.set_submenu(chooser_menu) def set_sensitivity_recent_menu(widget=None): recent_item.set_sensitive(recent_manager.props.size > 0) recent_manager.connect("changed", set_sensitivity_recent_menu) set_sensitivity_recent_menu() def open_recent_document(widget): self.open_uri(widget.get_current_uri()) chooser_menu.connect("item-activated", open_recent_document) chooser_menu.append(gtk.SeparatorMenuItem()) item = self.append_menu_item( chooser_menu, _("Clear Recent Documents"), "gtk-clear", _("Clear all items from the recent documents list")) clear_dialog = self.ClearRecentDocumentsDialog( self.applet, recent_manager.purge_items) def purge_items_cb(widget): clear_dialog.show_all() clear_dialog.deiconify() item.connect("activate", purge_items_cb)
def docklet_empty_trash(self, menu): dialog = gtk.Dialog(_("Confirm deletion"), self, gtk.DIALOG_MODAL, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_icon_name('user-trash-full') vbox = gtk.VBox(False, 6) vbox.set_border_width(12) label1 = gtk.Label() label1.set_markup(_("<big><b>Are you sure you want to delete\nevery item from the trash?</b></big>")) label2 = gtk.Label(_("This action cannot be undone.")) label2.set_alignment(0.0, 0.0) vbox.pack_start(label1, False) vbox.pack_start(label2, False) dialog.vbox.pack_start(vbox) dialog.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_ACCEPT: try: self.trash.empty() except: pass
def main_dialog(self): if self.__dialog is not None: self.awn.dialog.unregister("main") self.__dialog = None self.__dialog = dialog = self.awn.dialog.new("main") for note in self.list_all_notes()[:10]: self.button = gtk.Button(self.__interface.GetNoteTitle(note)) self.button.connect("clicked", self.button_display, note) dialog.add(self.button) dialog.add(gtk.Label(_("Version: %s") % self.__version)) button1 = gtk.Button(_("Search")) button1.connect("clicked", self.display_search) dialog.add(button1) button2 = gtk.Button(_("New Note")) button2.connect("clicked", self.create_note) dialog.add(button2) button3 = gtk.Button(_("New Tagged Note")) button3.connect("clicked", self.create_from_tag_dialog) dialog.add(button3) button4 = gtk.Button(_("View Tagged Note")) button4.connect("clicked", self.view_from_tag_dialog) dialog.add(button4)
def show_about(self, widget): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 48, 48) win = gtk.AboutDialog() win.set_name(_("Feeds Applet")) win.set_copyright('Copyright \xc2\xa9 2009 Sharkbaitbobby') win.set_authors(['Sharkbaitbobby <*****@*****.**>']) win.set_artists(['Victor C.', ' (Icon modified by Sharkbaitbobby)', \ 'Jakub Szypulka']) win.set_comments(_("Applet to monitor web feeds")) win.set_license("This program is free software; you can redistribute it "+\ "and/or modify it under the terms of the GNU General Public License "+\ "as published by the Free Software Foundation; either version 2 of "+\ "the License, or (at your option) any later version.\n\nThis program is "+\ "distributed in the hope that it will be useful, but WITHOUT ANY "+\ "WARRANTY; without even the implied warranty of MERCHANTABILITY or "+\ "FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public "+\ "License for more details.\n\nYou should have received a copy of the GNU "+\ "General Public License along with this program; if not, write to the "+\ "Free Software Foundation, Inc., "+\ "51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.") win.set_wrap_license(True) win.set_logo(pixbuf) win.set_icon_from_file(icon_path) win.set_website('http://wiki.awn-project.org/Feeds_Applet') win.set_website_label('wiki.awn-project.org') win.set_version(__version__) win.run() win.destroy()
def show_menu(self, event): #Create the menu and menu items if they don't exist if not self.menu: #Create the items add_feed = awn.image_menu_item_new_with_label(_("Add Feed")) update = gtk.ImageMenuItem(gtk.STOCK_REFRESH) self.show_only_new_check = gtk.CheckMenuItem(_("Show Only _New Feeds")) sep = gtk.SeparatorMenuItem() prefs_item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) about = gtk.ImageMenuItem(_("_About %s") % _("Feeds Applet")) about.props.always_show_image = True about.set_image(gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU)) #Add icon for "Add Feed" add_icon = gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU) add_feed.set_image(add_icon) if self.client.get_value(GROUP_DEFAULT, 'show_only_new'): self.show_only_new_check.set_active(True) add_feed.connect('activate', self.add_feed_dialog) update.connect('activate', self.update_feeds) self.show_only_new_check.connect('toggled', self.toggle_show_only_new) prefs_item.connect('activate', self.open_prefs) about.connect('activate', self.show_about) #Create the menu self.menu = self.create_default_menu() for item in (add_feed, update, self.show_only_new_check, sep, prefs_item, about): self.menu.append(item) self.menu.show_all() self.popup_gtk_menu (self.menu, event.button, event.time)
def create_display_parameter_list(self): cell_box = self.create_treeview() store = cell_box.liststore ddps = 'device_display_parameters' prefs = self.parent.applet.settings[ddps] for device_pref in prefs: dpv = device_pref.split('|') iface = dpv[0] sum_include = dpv[1] muti_include = dpv[2] current_iter = store.append([ iface, sum_include, muti_include, '', '', '#ff0000', '#ffff00' ]) ifaces = self.parent.netstats.ifaces for iface in sorted(self.parent.netstats.ifaces): if not _('Multi Interface') in iface \ and not _('Sum Interface') in iface and \ not iface in prefs.__str__(): sum_include = True if ifaces[iface]['sum_include'] \ else False multi_include = True if ifaces[iface]['multi_include'] \ else False current_iter = store.append([ iface, sum_include, multi_include, '', '', '#ff0000', '#ffff00' ]) for child in self.prefs_ui.get_object( 'scrolledwindow1').get_children(): self.prefs_ui.get_object('scrolledwindow1').remove(child) del child self.prefs_ui.get_object('scrolledwindow1').add_with_viewport(cell_box) cell_box.show_all()
def setup_context_menu(self): """Add options to the context menu. """ menu = self.applet.dialog.menu menu_index = len(menu) - 1 self.context_menu_unit = gtk.CheckMenuItem( label=_('Use KBps instead of Kbps')) if self.unit == 1: self.context_menu_unit.set_active(True) def menu_opened(widget): self.context_menu_unit.disconnect(self.context_menu_unit_handler) self.context_menu_unit.set_active(self.unit == 1) self.context_menu_unit_handler = self.context_menu_unit.connect( 'toggled', self.call_change_unit) menu.connect("show", menu_opened) self.context_menu_unit_handler = self.context_menu_unit.connect( 'toggled', self.call_change_unit) menu.insert(self.context_menu_unit, menu_index) iface_submenu = self.generate_iface_submenu() self.iface_submenu = iface_submenu map_item = gtk.MenuItem(_("Interfaces")) map_item.set_submenu(iface_submenu) menu.insert(map_item, menu_index + 1) menu.insert(gtk.SeparatorMenuItem(), menu_index + 2)
def color_cb(self, widget, path, model, col_number, name): if col_number == 3: prop = _('Upload') else: prop = _('Download') colorseldlg = gtk.ColorSelectionDialog( _('%s %s Color') % (model[path][0], prop)) colorseldlg.colorsel.set_current_color( gtk.gdk.color_parse(self.get_color(model[path][0], prop.lower()))) response = colorseldlg.run() if response == gtk.RESPONSE_OK: self.color_choice = colorseldlg.colorsel.get_current_color() if model[path][0] in self.parent.netstats.ifaces: self.parent.netstats.ifaces[model[path][0]]['%s_color' \ % prop.lower()] = self.color_choice.to_string() prefs = self.applet.settings['device_display_parameters'] if not prefs: prefs = ['%s|True|True|None|None' % (model[path][0])] if not model[path][0] in prefs.__str__(): prefs.append('%s|True|True|None|None' % (model[path][0])) for i, device_pref in enumerate(prefs): dpv = device_pref.split('|') if dpv[0] == model[path][0]: dpv[col_number] = self.color_choice.to_string() prefs[i] = '|'.join(dpv) model[path][col_number + 2] = self.color_choice.to_string() self.applet.settings['device_display_parameters'] = prefs colorseldlg.hide()
def clear(self): dialog = gtk.Dialog(_("Confirm removal"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, (gtk.STOCK_NO, gtk.RESPONSE_REJECT, gtk.STOCK_YES, gtk.RESPONSE_ACCEPT)) dialog.set_default_response(gtk.RESPONSE_REJECT) align = gtk.Alignment(0.5,0.5,0,0) align.set_padding(10,10,20,20) label = gtk.Label(_("This stack has a <b>folder backend</b>. Do you really want to <b>delete</b> the files from that folder?")) label.set_use_markup(True) label.set_line_wrap(True) align.add(label) align.show_all() dialog.vbox.pack_start(align, True, True, 0) if dialog.run() == gtk.RESPONSE_REJECT: dialog.destroy() return GUITransfer([self.backend_uri.as_uri()], [], 0) # destroy dialog dialog.destroy() Backend.clear(self)
def clear(self): dialog = gtk.Dialog( _("Confirm removal"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, (gtk.STOCK_NO, gtk.RESPONSE_REJECT, gtk.STOCK_YES, gtk.RESPONSE_ACCEPT)) dialog.set_default_response(gtk.RESPONSE_REJECT) align = gtk.Alignment(0.5, 0.5, 0, 0) align.set_padding(10, 10, 20, 20) label = gtk.Label( _("This stack has a <b>folder backend</b>. Do you really want to <b>delete</b> the files from that folder?" )) label.set_use_markup(True) label.set_line_wrap(True) align.add(label) align.show_all() dialog.vbox.pack_start(align, True, True, 0) if dialog.run() == gtk.RESPONSE_REJECT: dialog.destroy() return GUITransfer([self.backend_uri.as_uri()], [], 0) # destroy dialog dialog.destroy() Backend.clear(self)
def on_add_assistant_prepare(self, widget, page): if page is self.ui.get_object('url_page'): if self.from_list: self.ui.get_object('list_box').show() self.ui.get_object('url_box').hide() else: self.ui.get_object('list_box').hide() self.ui.get_object('url_box').show() elif page is self.ui.get_object('wait_page'): if self.from_list: self.ui.get_object('name_box').hide() last_label = self.ui.get_object('last_label') last_label.set_markup( _('''\ This guide has finished.\n\ Press "apply" to add the comic.''')) self.assistant.set_current_page(4) else: self.assistant.set_page_complete(page, False) self.url = self.ui.get_object('url_entry').get_text() self.ui.get_object('wait_label').set_markup( _('Connecting to <i>%s</i>...') % self.url) # Download feed self.feed = self.feeds.get_feed_for_url(self.url) self.__update = self.feed.connect('updated', self.on_feed_updated) self.feed.update()
def __init__(self, applet): self.awn = applet self.awn.errors.module(globals(), "feedparser") self.setup_context_menu() self.back = getattr(Backends(), self.awn.settings["backend"]) self.setup_themes() self.awn.theme.icon("login") self.awn.tooltip.set(_("Mail Applet (Click to Log In)")) self.__dialog = MainDialog(self) # Login from key or dialog self.init_keyring() self.migrate_key() if self.keyring is None: self.__dialog.login_form(True, _("GNOME keyring not available: Password won't be saved")) else: login_data = self.get_data_from_key(self.get_key()) if login_data: self.login(login_data) else: try: # Create a key in default keyring without saving it self.keyring.Key(None) except awnlib.KeyringError: self.__dialog.login_form(True, _("Default GNOME keyring or \"login\" keyring not found:\nPassword won't be saved")) else: self.__dialog.login_form()
def setup_context_menu(self): """Add options to the context menu. """ menu = self.applet.dialog.menu menu_index = len(menu) - 1 self.context_menu_unit = gtk.CheckMenuItem(label=_('Use KBps instead of Kbps')) if self.unit == 1: self.context_menu_unit.set_active(True) def menu_opened(widget): self.context_menu_unit.disconnect(self.context_menu_unit_handler) self.context_menu_unit.set_active(self.unit == 1) self.context_menu_unit_handler = self.context_menu_unit.connect('toggled', self.call_change_unit) menu.connect("show", menu_opened) self.context_menu_unit_handler = self.context_menu_unit.connect('toggled', self.call_change_unit) menu.insert(self.context_menu_unit, menu_index) iface_submenu = self.generate_iface_submenu() self.iface_submenu = iface_submenu map_item = gtk.MenuItem(_("Interfaces")) map_item.set_submenu(iface_submenu) menu.insert(map_item, menu_index + 1) menu.insert(gtk.SeparatorMenuItem(), menu_index + 2)
def update_email_list(self): if self.__current_type is not "email_list": self.email_list() parent = self.__email_list.get_parent() parent.remove(self.__email_list) mail = self.__parent.mail self.__parent.awn.tooltip.set(strMessages(len(mail.subjects))) self.__parent.awn.theme.icon("unread" if len(mail.subjects) > 0 else "read") if len(mail.subjects) > 0: self.__dialog.set_title(strMessages(len(self.__parent.mail.subjects))) self.__email_list = gtk.Table(len(self.__parent.mail.subjects), 2) self.__email_list.set_col_spacings(10) for i in xrange(len(mail.subjects)): label = gtk.Label("<b>" + str(i + 1) + "</b>") label.set_use_markup(True) self.__email_list.attach(label, 0, 1, i, i + 1) label = gtk.Label(mail.subjects[i]) label.set_use_markup(True) label.set_alignment(0.0, 0.5) self.__email_list.attach(label, 1, 2, i, i + 1) else: self.__dialog.set_title(_("No unread messages")) self.__email_list = gtk.Label("<i>%s</i>" % _("No new messages")) self.__email_list.set_use_markup(True) self.__email_list.show_all() parent.pack_start(self.__email_list)
def __init__(self, parent, clear_cb): gtk.MessageDialog.__init__( self, type=gtk.MESSAGE_WARNING, message_format=_("Clear the Recent Documents list?"), buttons=gtk.BUTTONS_CANCEL) awnlib.Dialogs.BaseDialog.__init__(self, parent) self.set_skip_taskbar_hint(False) self.set_title(_("Clear Recent Documents")) self.format_secondary_markup( _("Clearing the Recent Documents list will clear the following:\n\ * All items from the Places > Recent Documents menu item.\n\ * All items from the recent documents list in all applications.")) clear_button = gtk.Button(stock=gtk.STOCK_CLEAR) clear_button.set_image( gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)) def clear_and_hide(widget): self.response(gtk.RESPONSE_CANCEL) clear_cb() clear_button.connect("clicked", clear_and_hide) self.action_area.add(clear_button)
def on_add_assistant_prepare(self, widget, page): if page is self.ui.get_object('url_page'): if self.from_list: self.ui.get_object('list_box').show() self.ui.get_object('url_box').hide() else: self.ui.get_object('list_box').hide() self.ui.get_object('url_box').show() elif page is self.ui.get_object('wait_page'): if self.from_list: self.ui.get_object('name_box').hide() last_label = self.ui.get_object('last_label') last_label.set_markup(_('''\ This guide has finished.\n\ Press "apply" to add the comic.''')) self.assistant.set_current_page(4) else: self.assistant.set_page_complete(page, False) self.url = self.ui.get_object('url_entry').get_text() self.ui.get_object('wait_label').set_markup( _('Connecting to <i>%s</i>...') % self.url) # Download feed self.feed = self.feeds.get_feed_for_url(self.url) self.__update = self.feed.connect('updated', self.on_feed_updated) self.feed.update()
def docklet_icon_menu(self, icon, event, place): menu = self.create_default_menu() if place is not None: #If the place is ejectable if place[2]: eject = awn.image_menu_item_new_with_label(_("Eject")) image = gtk.image_new_from_icon_name('media-eject', gtk.ICON_SIZE_MENU) eject.set_image(image) menu.append(eject) eject.connect('activate', self.docklet_menu_eject, place[4]) elif place[3] == 'trash:///': empty = gtk.MenuItem(_("Empty Trash")) menu.append(empty) if self.trash.props.file_count == 0: empty.set_sensitive(False) empty.connect('activate', self.docklet_empty_trash) prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) prefs.connect('activate', self.open_prefs) menu.append(prefs) about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) about.connect("activate", self.open_about) menu.append(about) menu.show_all() icon.popup_gtk_menu (menu, event.button, event.time)
def __init__(self, parent): """Create a new ComicsManage instance.""" # Connect dialogue events self.ui = gtk.Builder() self.ui.add_from_file(UI_FILE) self.ui.connect_signals(self) self.__parent = parent self.feeds = parent.feeds self.manage_window = self.ui.get_object('manage_window') self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING) self.comics_list = self.ui.get_object('comics_list') selection = self.comics_list.get_selection() selection.connect('changed', self.on_comics_list_selection_changed) selection.set_mode(gtk.SELECTION_MULTIPLE) self.comics_list.set_model(self.model) # Translators: checkbox to show comic self.ui.get_object('toggle_col').set_title(_('Show')) self.ui.get_object('name_col').set_title(_('Comic')) self.load_feeds()
def make_menu(self): """Create the context menu.""" menu = gtk.Menu() # Generate history menu if len(self.feeds.feeds[self.feed_name].items) > 1: history_container = gtk.ImageMenuItem(gtk.STOCK_JUMP_TO) history_menu = gtk.Menu() history_menu.foreach(lambda child: history_menu.remove(child)) items = self.feeds.feeds[self.feed_name].items.items() items.sort(reverse=True) for date, item in items: label = gtk.Label() text = self.get_menu_item_name(item) if self.__current_timestamp == date: label.set_markup("<b>" + text + "</b>") else: label.set_markup(text) align = gtk.Alignment(xalign=0.0) align.add(label) menu_item = gtk.MenuItem() menu_item.data = item menu_item.connect("activate", self.on_history_activated) menu_item.add(align) history_menu.append(menu_item) history_container.set_submenu(history_menu) menu.append(history_container) size_container = gtk.MenuItem(_("Size")) size_menu = gtk.Menu() zoom_normal_item = gtk.ImageMenuItem(gtk.STOCK_ZOOM_100) zoom_normal_item.connect("activate", self.on_normal_activated) zoom_in_item = gtk.ImageMenuItem(gtk.STOCK_ZOOM_IN) zoom_in_item.connect("activate", self.on_larger_activated) zoom_out_item = gtk.ImageMenuItem(gtk.STOCK_ZOOM_OUT) zoom_out_item.connect("activate", self.on_smaller_activated) size_menu.append(zoom_normal_item) size_menu.append(zoom_in_item) size_menu.append(zoom_out_item) size_container.set_submenu(size_menu) menu.append(size_container) show_link_item = gtk.CheckMenuItem(_("Show link")) show_link_item.set_active(self.show_link) show_link_item.connect("toggled", self.on_show_link_toggled) menu.append(show_link_item) save_as_item = gtk.ImageMenuItem(stock_id="gtk-save-as") save_as_item.set_sensitive(not self.__pixbuf is None) save_as_item.connect("activate", self.on_save_as_activated) menu.append(save_as_item) close_item = gtk.ImageMenuItem(stock_id="gtk-close") close_item.connect("activate", self.on_close_activated) menu.append(close_item) menu.show_all() return menu
def about_callback(self, widget): about_dialog = gtk.AboutDialog() about_dialog.set_name(_("Avant Calendar Applet")) about_dialog.set_copyright("Copyright 2007 Mike Desjardins") about_dialog.set_comments(_("A Calendar Applet for the Avant Window Navigator. Images by Deleket.") + \ "\n(http://deleket.deviantart.com)") about_dialog.set_authors(["Mike Desjardins"]) about_dialog.set_artists(["Deleket", "Mike Desjardins"]) about_dialog.connect("response", lambda d, r: d.destroy()) about_dialog.show()
def __init__(self, applet): """ Initialize the entire applet. Create applet icon and main dialog, initialize sensors and load settings. """ self.applet = applet # Init sensors no_sensors = not self.create_all_sensors() # If no sensors were found, display warning massage and icon, then exit if no_sensors: subject = _("Warning from Hardware Sensors: No sensors found") message = _("Install one or more of \ ACPI, HDDTemp, LM-Sensors, nvidia-settings or nvclock and restart the applet.") print subject + ".", message # Show massage with awn notify self.applet.notification.send(subject=subject, body=message, icon=applet_logo) # Show "no sensors found" icon self.applet.icon.file(no_sensors_icon, size=applet.get_size()) self.applet.tooltip.set(message) return self.update_all_sensors() # Get a list of themes def is_dir(path): return os.path.isdir(os.path.join(theme_dir, path)) self.__themes = filter(is_dir, os.listdir(theme_dir)) self.__themes = [theme.replace("_", " ") for theme in self.__themes] self.__themes.sort() # == Settings == # # Load settings, setup rightclick menu and create settings dialog self.setup_preferences() # == Icon == # self.setup_icon() # Recreate upon awn height change self.applet.connect_size_changed(self.height_changed_cb) # == Dialog == # # Create main applet dialog showing selected sensors. main_dialog = self.applet.dialog.new("main", _("Sensors")) self.__main_dialog = self.MainDialog(self, main_dialog)
def do_trash(self): if self.show_trash: count = self.trash.props.file_count if count > 0: self.place('user-trash-full', _("Trash (%d)") % count, 'trash:///') else: self.place('user-trash', _("Trash"), 'trash:///') if gio: self.droppable_places.append('trash:///')
def __update_message(self): charge_percentage = self.handler.applet.backend.get_capacity_percentage() if charge_percentage == 100: body = _("Your battery is fully charged.") else: body = _("Your battery is charged to <b>%d%%</b>.") % charge_percentage self.handler.message.set_property("body", body) try: self.handler.message.show() except glib.GError: pass # Ignore error when no reply has been received
def execute_action(self, action): assert action != _("Show Docklet") if action == _("Lock Screen"): self.lock_screen_cb() elif action == _("Log Out"): self.log_out_cb() elif action == _("Shut Down"): assert self.log_out_cb == self.mate_log_out self.mate_shut_down()
def convert_temperature(self, value): unit = temperature_units[self.applet.settings["temperature-unit"]] try: value = float(value) except ValueError: return "N/A" if _("Fahrenheit") == unit: converted_value = value elif _("Celsius") == unit: converted_value = 5.0 * (value - 32.0) / 9.0 return str(int(round(converted_value)))
def create_from_tag_dialog(self, widget): dialog = self.awn.dialog.new("create_from_tag") available_tags = self.collect_tags() if len(available_tags) > 0: dialog.add(gtk.Label(_("Select a tag:"))) for tag in available_tags: button = gtk.Button(tag) button.connect("clicked", self.create_from_tag, tag) dialog.add(button) else: dialog.add(gtk.Label(_("No tags were created yet"))) dialog.show_all()
def settings_dialog(self): if self.settings_dialog_window is not None: self.settings_dialog_window.grab_focus() self.settings_dialog_window.show_all() return builder = gtk.Builder() builder.add_from_file(os.path.join(os.path.dirname(__file__), ui_file)) if builder is None: print "UI file " + ui_file + " not found." return # get objects label_format = builder.get_object("label_format") label_interval = builder.get_object("label_interval") label_timezone = builder.get_object("label_timezone") entry_format = builder.get_object("entry_format") entry_interval = builder.get_object("entry_interval") entry_timezone = builder.get_object("entry_timezone") button_close = builder.get_object("button_close") button_ok = builder.get_object("button_ok") button_apply = builder.get_object("button_apply") # ensure they exist (assuming their type are correct) if None in (label_format, label_interval, label_timezone, entry_format, entry_interval, entry_timezone, button_close, button_ok, button_apply): print "UI file " + ui_file + " malformed." return # set values from translation and saved settings label_format.set_property("label", _("Format (see strftime)")) label_interval.set_property("label", _("Refresh interval (ms)")) label_timezone.set_property("label", _("Timezone")) entry_format.set_property("text", self.settings["time_format"]) entry_interval.set_property("text", self.settings["refresh_interval"]) entry_timezone.set_property("text", "(not yet)") # TODO timezone # save important objects self.entry_format = entry_format self.entry_interval = entry_interval self.entry_timezone = entry_timezone # create window self.settings_dialog_window = self.applet.dialog.new("preferences") builder.get_object("dialog-vbox1").reparent(self.settings_dialog_window.vbox) self.settings_dialog_window.show_all() # add events self.settings_dialog_window.connect("destroy", self.trigger_cancel, self) button_close.connect("clicked", self.trigger_cancel) button_ok.connect("clicked", self.trigger_ok) button_apply.connect("clicked", self.trigger_apply)
def show_notification(self): if not self.client.get_value(GROUP_DEFAULT, 'notify'): return msg = '' only_greader = True num_messages = 0 if self.num_notify_while_updating != 0: for url, feed in self.feeds.items(): if not isinstance(feed, classes.GoogleReader): if feed.num_notify > 0: only_greader = False notify_entries = [] for entry in feed.entries: if entry['notify'] == True: notify_entries.append(entry) num_messages += 1 if len(notify_entries) == 0: continue if feed.num_notify == 1: msg += "%s\n <a href=\"%s\">%s</a>\n" % (shortify(feed.title), notify_entries[0]['url'], shortify(notify_entries[0]['title'])) elif feed.num_notify == 2: msg += "%s\n <a href='%s'>%s</a>\n <a href='%s'>%s</a>\n" % \ (shortify(feed.title), notify_entries[0]['url'], shortify(notify_entries[0]['title']), notify_entries[1]['url'], shortify(notify_entries[1]['title'])) elif feed.num_notify > 2: msg += _("%s\n <a href='%s'>%s</a>\n <a href='%s'>%s</a>\n(%s More)\n") % \ (shortify(feed.title), notify_entries[0]['url'], shortify(notify_entries[0]['title']), notify_entries[1]['url'], shortify(notify_entries[1]['title']), (feed.num_notify - 2)) feed.num_notify = 0 if num_messages != 0: pynotify.init(_("Feeds Applet")) s = gettext.ngettext("%s New Item - Feeds Applet", "%s New Items - Feeds Applet", self.num_notify_while_updating) % self.num_notify_while_updating notification = pynotify.Notification(s, msg, [icon_path, greader_path][only_greader]) notification.set_timeout(5000) try: notification.show() except glib.GError: pass # Ignore error when no reply has been received
def change_unit(self, widget=None, scaleThresholdSBtn=None, label=None): self.unit = 8 if self.unit == 1 else 1 # normalize and update the label, and normalize the spinbutton if label: if self.unit == 1: label.set_text(_('KBps')) scaleThresholdSBtn.set_value( self.applet.settings['draw_threshold'] / 8) else: label.set_text(_('Kbps')) scaleThresholdSBtn.set_value( self.applet.settings['draw_threshold'] * 8) self.applet.settings['unit'] = self.unit
def drawLoginWindow(cls, *groups): vbox = gtk.VBox(spacing=12) usrE, box = get_label_entry(_("Username:"******"Password:"******"layout": vbox, "callback": cls.__submitLoginWindow, "widgets": [usrE, pwdE], "fill-in": cls.__fillinLoginWindow}
def __update_message(self): charge_percentage = self.handler.applet.backend.get_capacity_percentage( ) if charge_percentage == 100: body = _("Your battery is fully charged.") else: body = _( "Your battery is charged to <b>%d%%</b>.") % charge_percentage self.handler.message.set_property("body", body) try: self.handler.message.show() except glib.GError: pass # Ignore error when no reply has been received
def got_data(self, data): try: parsed = json.loads(data) except: self.error() return self.entries = [] self.num_new = 0 self.num_notify = 0 for message in parsed['data']['children'][:5]: #If it's a private message if message['data']['context'].strip() == '': url = self.inbox_url title = message['data']['subject'] else: url = 'http://www.reddit.com' + message['data']['context'] if message['data']['subject'] == 'comment reply': title = _( "Comment reply from %s") % message['data']['author'] else: title = _("Post reply from %s") % message['data']['author'] new = message['data']['id'] not in self.marked_read and message[ 'data']['new'] if new: self.num_new += 1 notify = False if new and message['data']['id'] not in self.already_notified_about: self.already_notified_about.append(message['data']['id']) notify = True self.num_notify += 1 entry = Entry(url, title, new, notify) entry['id'] = message['data']['id'] self.entries.append(entry) self.applet.feed_updated(self) if self.num_new > 0: self.get_favicon('www.reddit.com-orangered', self.orangered_url) else: self.get_favicon('www.reddit.com')
def enter_notify(self): if not self.applet.dialog.is_visible('main'): if not self.iface in self.netstats.ifaces: self.applet.set_tooltip_text( _('Please select a valid Network Device')) else: self.applet.set_tooltip_text(_('''\ Total Sent: %s - Total Received: %s (All Interfaces)''') % ( self.readable_size( self.netstats.ifaces[self.iface]['tx_sum'] * self.unit, self.unit), self.readable_size( self.netstats.ifaces[self.iface]['rx_sum'] * self.unit, self.unit)))
def make_menu(self): """Generate the context menu.""" # Generate comics menu menu = self.create_default_menu() manage_item = gtk.MenuItem(_('My Comics')) manage_item.connect("activate", self.on_manage_comics_activated) menu.append(manage_item) about_item = gtk.ImageMenuItem(_("_About %s") % applet_display_name) about_item.props.always_show_image = True about_item.set_image( gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU)) menu.append(about_item) about_item.connect("activate", self.on_show_about_activated) menu.show_all() return menu
def process_error(self, result): label = self.ui.get_object('intro_label') if result == Feed.DOWNLOAD_FAILED: label.set_text(_('''\ Failed to download %s. Press "next" to try again.''') % self.url) self.assistant.set_current_page(0) return False elif result == Feed.DOWNLOAD_NOT_FEED: label.set_text(_('''\ The URL is not a valid comic feed. Press "next" to try again''')) self.assistant.set_current_page(0) return False return True
def toggle_display(self, toggle, url): if toggle.get_active(): self.displays[url].show() toggle.set_tooltip_text(_("Hide this feed's items")) toggle.arrow.set(gtk.ARROW_DOWN, gtk.SHADOW_NONE) #Only show one feed at a time for other_toggle in self.toggles: if other_toggle != toggle: other_toggle.set_active(False) else: self.displays[url].hide() toggle.set_tooltip_text(_("Show this feed's items")) toggle.arrow.set(gtk.ARROW_RIGHT, gtk.SHADOW_NONE)
def make_menu(self): """Generate the context menu.""" # Generate comics menu menu = self.create_default_menu() manage_item = gtk.MenuItem(_('My Comics')) manage_item.connect("activate", self.on_manage_comics_activated) menu.append(manage_item) about_item = gtk.ImageMenuItem(_("_About %s") % applet_display_name) about_item.props.always_show_image = True about_item.set_image(gtk.image_new_from_stock(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU)) menu.append(about_item) about_item.connect("activate", self.on_show_about_activated) menu.show_all() return menu
def show_about(self, widget): about = gtk.AboutDialog() awn_icon = self.get_icon() about.set_logo(awn_icon.get_icon_at_size(48)) about.set_icon(awn_icon.get_icon_at_size(64)) about.set_name(_("Media Control Applet")) about.set_copyright("Copyright (c) 2007 Randal Barlow <im.tehk at gmail.com>") about.set_authors(["Randal Barlow <im.tehk at gmail.com>", "Michal Hruby <michal.mhr at gmail.com>"]) about.set_comments(_("Controls your favourite music player.")) about.set_license("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.") about.set_wrap_license(True) about.set_documenters(["Randal Barlow <im.tehk at gmail.com>"]) about.set_artists(["Claudio Benech"]) about.run() about.destroy()
def enter_notify(self): if not self.applet.dialog.is_visible('main'): if not self.iface in self.netstats.ifaces: self.applet.set_tooltip_text( _('Please select a valid Network Device')) else: self.applet.set_tooltip_text( _('''\ Total Sent: %s - Total Received: %s (All Interfaces)''') % (self.readable_size( self.netstats.ifaces[self.iface]['tx_sum'] * self.unit, self.unit), self.readable_size( self.netstats.ifaces[self.iface]['rx_sum'] * self.unit, self.unit)))
def __init__(self, applet): self.applet = applet self.weather_fail = [False, False, False] self.reset_weather_data() self.network_handler = self.NetworkHandler() self.notification = applet.notification.create( _("Network error in Weather"), network_error_message, "dialog-warning", 20) self.setup_context_menu() self.forecaster = forecast.Forecast(self) # Set default icons/titles/dialogs so the applet is informative without data self.set_icon() self.applet.tooltip.set( "%s %s..." % (_("Fetching conditions for"), self.applet.settings['location'])) # Overlays self.__temp_overlay = OverlayText() self.__temp_overlay.props.gravity = gtk.gdk.GRAVITY_SOUTH applet.add_overlay(self.__temp_overlay) disconnect_overlay = OverlayThemedIcon("gtk-disconnect") disconnect_overlay.props.alpha = 1.0 throbber_overlay = OverlayThrobber() for i in (disconnect_overlay, throbber_overlay): i.props.scale = 0.5 i.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST i.props.apply_effects = False applet.add_overlay(i) global overlay_fsm overlay_fsm = OverlayStateMachine(disconnect_overlay, throbber_overlay) def show_map(widget): if self.map_dialog is None: self.fetch_weather_map(show=True) applet.connect("middle-clicked", show_map) # Set up the timer which will refresh the conditions, forecast, and weather map applet.timing.register(self.activate_refresh_cb, update_interval * 60) applet.timing.delay(self.activate_refresh_cb, 1.0)