def recreate_tray(self, *args): """ Recreate a tray icon if the notification area unexpectedly quits. """ try: self.tray.destroy() except: pass self.tray = "" self.tray = Tray(self.specto, self) self.specto.watch_db.count_changed_watches()
def __init__(self): self.DEBUG = DEBUG import gettext #this is for the glade files self.glade_gettext = gettext.textdomain("specto") self.logger = Logger(self) self.check_instance() #see if specto is already running self.util = util self.PATH = self.util.get_path() self.specto_gconf = specto_gconf self.check_default_settings( ) #if this is the first run of specto, set the default values for gconf. Whenever you add some gconf preference for specto, this function will also need to be updated. self.GTK = GTK if GTK: self.tray = Tray(self) self.icon_theme = gtk.icon_theme_get_default() self.watch_db = {} self.watch_io = Watch_io() watch_value_db = self.watch_io.read_options() self.preferences_initialized = False self.notifier_initialized = False #listen for gconf keys self.specto_gconf.notify_entry("debug_mode", self.key_changed, "debug") self.connection_manager = conmgr.get_net_listener() if GTK: if self.specto_gconf.get_entry("always_show_icon") == False: #if the user has not requested the tray icon to be shown at all times, it's impossible that the notifier is hidden on startup, so we must show it. self.notifier_keep_hidden = False self.toggle_notifier() elif self.specto_gconf.get_entry("show_notifier") == True: self.notifier_keep_hidden = False self.toggle_notifier() elif self.specto_gconf.get_entry("show_notifier") == False: self.notifier_keep_hidden = True self.toggle_notifier() self.notifier_keep_hidden = False else: #just in case the entry was never created in gconf self.notifier_keep_hidden = False self.toggle_notifier() self.create_all_watches(watch_value_db) if GTK: gtk.main() else: self.go = gobject.MainLoop() self.go.run()
def __init__(self, specto): """ In this init we are going to display the main notifier window. """ self.specto = specto uifile = os.path.join(self.specto.PATH, "uis/notifier.ui") windowname = "notifier" self.builder = gtk.Builder() self.builder.set_translation_domain("specto") self.builder.add_from_file(uifile) self.notifier = self.builder.get_object("notifier") if INDICATOR: self.indicator = Indicator(specto) self.tray = None else: self.tray = Tray(specto, self) self.indicator = None if SOUND: self.sound = Sound() else: self.sound = None self.balloon = NotificationToast(specto, self) self.preferences_initialized = False #create tree self.iter = {} self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING, pango.Weight) #catch some events dic = { "on_add_activate": self.show_add_watch_menu, "on_edit_activate": self.show_edit_watch, "on_clear_all_activate": self.mark_all_as_read, "on_preferences_activate": self.show_preferences, "on_refresh_activate": self.refresh_all_watches, "on_close_activate": self.close_event, "on_quit_activate": self.delete_event, "on_import_watches_activate": self.import_watches, "on_export_watches_activate": self.export_watches, "on_error_log_activate": self.show_error_log, "on_display_all_watches_activate": self.toggle_show_deactivated_watches, "on_display_toolbar_activate": self.toggle_display_toolbar, "on_help_activate": self.show_help, "on_about_activate": self.show_about, "on_treeview_row_activated": self.open_watch_callback, "on_btnOpen_clicked": self.open_watch_callback, "on_btnClear_clicked": self.mark_watch_as_read, "on_treeview_cursor_changed": self.show_watch_info, "on_btnEdit_clicked": self.show_edit_watch, "on_by_watch_type_activate": self.sort_type, "on_by_name_activate": self.sort_name, "on_by_watch_active_activate": self.sort_active, "on_remove_clicked": self.remove_watch, "on_clear_activate": self._mark_watch_as_read, "on_remove_activate": self.remove_watch } self.builder.connect_signals(dic) self.notifier.set_icon_from_file(self.specto.LOGO_PATH) self.specto.notifier_initialized = True self.create_notifier_gui() self.stop_refresh = False