def _setup_history(self): self.hview = CuemiacHistoryView(self._core.get_history()) self.hview.connect("match-selected", self.__on_history_match_selected) self.hview.show() self.history_popup = CuemiacHistoryPopup (self.tray.button_arrow, self.applet, self.hview)
class DeskbarApplet (gnomeapplet.Applet, AbstractCuemiacDeskbarIcon): def __init__(self, applet): gnomeapplet.Applet.__init__(self) AbstractCuemiacDeskbarIcon.__init__(self) self.applet = applet self.handler_size_allocate_id = self.applet.connect ("size-allocate", self.on_allocate) self.applet.set_applet_flags (gnomeapplet.EXPAND_MINOR) self.applet.set_background_widget(self.applet) self.tray = CuemiacAppletButton(applet) self.tray.connect('toggled-main', self.on_toggled_main) self.tray.connect('toggled-arrow', self.on_toggled_arrow) self.applet.add(self.tray) self.tray.show() self.__style_applied = False self.force_no_focus_applet() self.setup_menu() self._setup_mvc() self._set_image(self.applet.get_size()) self._setup_history() self.applet.show_all() def force_no_focus_applet(self): # Fixes bug #542861: Deskbar applet has a pixel border if not self.__style_applied: gtk.rc_parse_string (""" style \"deskbar-applet-button-style\" { GtkWidget::focus-line-width = 0 GtkWidget::focus-padding = 0 } widget \"*.deskbar-applet-button\" style \"deskbar-applet-button-style\" """) self.__style_applied = False self.applet.set_name("deskbar-applet-button") def _setup_history(self): self.hview = CuemiacHistoryView(self._core.get_history()) self.hview.connect("match-selected", self.__on_history_match_selected) self.hview.show() self.history_popup = CuemiacHistoryPopup (self.tray.button_arrow, self.applet, self.hview) def on_allocate(self, applet, alloc): if self.applet.get_orient () in [gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN]: size_alloc = alloc.height else: size_alloc = alloc.width self._set_image(size_alloc) def _set_image(self, size_alloc): """ @param size_alloc: The space that's available in pixels """ pixbuf = self.get_deskbar_icon(size_alloc) self.applet.handler_block(self.handler_size_allocate_id) self.tray.set_button_image_from_pixbuf(pixbuf) # If we unblock immediately we get an infinite loop glib.timeout_add(100, self.unblock_allocate) def unblock_allocate(self): self.applet.handler_unblock (self.handler_size_allocate_id) return False def on_toggled_main(self, widget): self.set_active (not self.get_active(), gtk.get_current_event_time()) def on_toggled_arrow(self, widget): self._controller.on_quit() if self.history_popup.get_property("visible"): self.history_popup.popdown() else: self.history_popup.popup() def get_reference_widget(self): return self.tray def get_applet(self): return self.applet def on_loaded(self, sender): AbstractCuemiacDeskbarIcon.on_loaded (self, sender) self.tray.set_sensitive(True) def setup_menu(self): self.applet.setup_menu_from_file ( deskbar.SHARED_DATA_DIR, "Deskbar_Applet.xml", None, [ ("About", lambda a,b: self._controller.on_show_about(a)), ("Prefs", lambda a,b: self._controller.on_show_preferences(a)), ("Clear", lambda a,b: self._controller.on_clear_history(a),), ("Help", lambda a,b: self._controller.on_show_help(a),) ]) def __on_history_match_selected(self, history, text, action): self._controller.on_history_match_selected(history, text, action) self.tray.set_active_arrow(False)
class DeskbarApplet (mateapplet.Applet, AbstractCuemiacDeskbarIcon): def __init__(self, applet): mateapplet.Applet.__init__(self) AbstractCuemiacDeskbarIcon.__init__(self) self.applet = applet self.handler_size_allocate_id = self.applet.connect ("size-allocate", self.on_allocate) self.applet.set_applet_flags (mateapplet.EXPAND_MINOR) self.applet.set_background_widget(self.applet) self.tray = CuemiacAppletButton(applet) self.tray.connect('toggled-main', self.on_toggled_main) self.tray.connect('toggled-arrow', self.on_toggled_arrow) self.applet.add(self.tray) self.tray.show() self.__style_applied = False self.force_no_focus_applet() self.setup_menu() self._setup_mvc() self._set_image(self.applet.get_size()) self._setup_history() self.applet.show_all() def force_no_focus_applet(self): # Fixes bug #542861: Deskbar applet has a pixel border if not self.__style_applied: gtk.rc_parse_string (""" style \"deskbar-applet-button-style\" { GtkWidget::focus-line-width = 0 GtkWidget::focus-padding = 0 } widget \"*.deskbar-applet-button\" style \"deskbar-applet-button-style\" """) self.__style_applied = False self.applet.set_name("deskbar-applet-button") def _setup_history(self): self.hview = CuemiacHistoryView(self._core.get_history()) self.hview.connect("match-selected", self.__on_history_match_selected) self.hview.show() self.history_popup = CuemiacHistoryPopup (self.tray.button_arrow, self.applet, self.hview) def on_allocate(self, applet, alloc): if self.applet.get_orient () in [mateapplet.ORIENT_UP, mateapplet.ORIENT_DOWN]: size_alloc = alloc.height else: size_alloc = alloc.width self._set_image(size_alloc) def _set_image(self, size_alloc): """ @param size_alloc: The space that's available in pixels """ pixbuf = self.get_deskbar_icon(size_alloc) self.applet.handler_block(self.handler_size_allocate_id) self.tray.set_button_image_from_pixbuf(pixbuf) # If we unblock immediately we get an infinite loop glib.timeout_add(100, self.unblock_allocate) def unblock_allocate(self): self.applet.handler_unblock (self.handler_size_allocate_id) return False def on_toggled_main(self, widget): self.set_active (not self.get_active(), gtk.get_current_event_time()) def on_toggled_arrow(self, widget): self._controller.on_quit() if self.history_popup.get_property("visible"): self.history_popup.popdown() else: self.history_popup.popup() def get_reference_widget(self): return self.tray def get_applet(self): return self.applet def on_loaded(self, sender): AbstractCuemiacDeskbarIcon.on_loaded (self, sender) self.tray.set_sensitive(True) def setup_menu(self): self.applet.setup_menu_from_file ( deskbar.SHARED_DATA_DIR, "Deskbar_Applet.xml", None, [ ("About", lambda a,b: self._controller.on_show_about(a)), ("Prefs", lambda a,b: self._controller.on_show_preferences(a)), ("Clear", lambda a,b: self._controller.on_clear_history(a),), ("Help", lambda a,b: self._controller.on_show_help(a),) ]) def __on_history_match_selected(self, history, text, action): self._controller.on_history_match_selected(history, text, action) self.tray.set_active_arrow(False)