def __init__(self): gtk.Menu.__init__(self) self.item_available = gtk.ImageMenuItem(_("Available")) self.item_available.set_image(icon_factory.load_image(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)) self.item_available.connect("activate", lambda w: self._set_status("available")) self.item_available.show() self.append(self.item_available) self.item_offline = gtk.ImageMenuItem(_("Offline")) self.item_offline.set_image(icon_factory.load_image(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)) self.item_offline.connect("activate", lambda w: self._set_status("offline")) self.item_offline.show() self.append(self.item_offline) self.item_away = gtk.ImageMenuItem(_("Away")) self.item_away.set_image(icon_factory.load_image(gtk.STOCK_NO, gtk.ICON_SIZE_MENU)) self.item_away.connect("activate", lambda w: self._set_status("away")) self.item_away.show() self.append(self.item_away) self.item_invisible = gtk.ImageMenuItem(_("Invisible")) self.item_invisible.set_image(icon_factory.load_image("status-invisible", gtk.ICON_SIZE_MENU)) self.item_invisible.connect("activate", lambda w: self._set_status("invisible")) self.item_invisible.show() self.append(self.item_invisible)
def __init__(self, tooltips): img = icon_factory.load_image("gnome-settings-default-applications", gtk.ICON_SIZE_LARGE_TOOLBAR) gtk.ToolButton.__init__(self, img, _("Install & Update")) self.set_tooltip(tooltips, _("Manage software on this computer")) # Find the installer command to run if os.path.isfile("/usr/bin/gnome-app-install"): cmd = "/usr/bin/gnome-app-install" elif os.path.isfile("/sbin/yast2"): # OpenSuSE specific cmd = "/sbin/yast2 sw_single" else: raise NotImplementedError, "No software manager found" # Try to run via sudo helper, either gksudo or gnomesu if os.path.isfile("/usr/bin/gksudo"): cmd = "/usr/bin/gksudo %s" % cmd elif os.path.isfile("/usr/bin/gnomesu"): cmd = "/usr/bin/gnomesu %s" % cmd elif os.path.isfile("/opt/gnome/bin/gnomesu"): # OpenSuSE specific cmd = "/opt/gnome/bin/gnomesu %s" % cmd self.cmd = cmd
def __init__(self, accel_group=None): gtk.ToolItem.__init__(self) self.search_timeout = 0 self.default_search_text = _("Search") box = gtk.HBox(False, 0) box.show() try: img = icon_factory.load_image(gtk.STOCK_FIND, 16) img.show() ev_box = gtk.EventBox() ev_box.set_property('visible-window', False) ev_box.add(img) ev_box.show() self.clearbtn = gtk.EventBox() self.clearbtn.set_property('visible-window', False) self.clearbtn.set_size_request(16, -1) self.clearbtn.show() self.clearbtn.connect("button-release-event", lambda w, ev: self.emit("clear")) self.iconentry = iconentry.IconEntry() self.iconentry.pack_widget(ev_box, True) self.iconentry.pack_widget(self.clearbtn, False) align = gtk.Alignment(0.5, 0.5) align.set_padding(0, 0, 0, 10) align.add(self.iconentry) align.show() box.pack_start(align, False, False, 0) self.entry = self.iconentry.get_entry() except NameError: self.clearbtn = None self.iconentry = None self.entry = gtk.Entry() box.pack_start(self.entry, False, False, 10) self.entry.set_width_chars(14) self.entry.set_text(self.default_search_text) self.entry.show() self.entry.connect("activate", lambda w: self._typing_timeout()) self.entry.connect("focus-in-event", lambda w, x: self._entry_focus_in()) self.entry.connect("key-press-event", self._entry_key_press) # Hold on to this id so we can block emission when initially clearing text self.change_handler_id = self.entry.connect( "changed", lambda w: self._queue_search()) if accel_group: # Focus on Ctrl-L self.entry.add_accelerator("grab-focus", accel_group, ord('l'), gtk.gdk.CONTROL_MASK, 0) self.add(box) self.show_all()
def __init__(self, tooltips): img = icon_factory.load_image("stock_person", gtk.ICON_SIZE_LARGE_TOOLBAR) gtk.ToolButton.__init__(self, img, _("New Person")) self.set_tooltip(tooltips, _("Add a new contact person"))
def do_search(self, text): if self.clearbtn and not self.clearbtn.child: img = icon_factory.load_image(gtk.STOCK_CLOSE, 16) img.show() self.clearbtn.add(img)
def __init__(self, tooltips): img = icon_factory.load_image("gnome-fs-desktop", gtk.ICON_SIZE_LARGE_TOOLBAR) gtk.ToolButton.__init__(self, img, _("Show Desktop")) self.set_tooltip(tooltips, "Hide all windows and show the desktop")
def __init__(self, tooltips): img = icon_factory.load_image("gnome-settings", gtk.ICON_SIZE_LARGE_TOOLBAR) gtk.ToolButton.__init__(self, img, _("Settings")) self.set_tooltip(tooltips, _("Manage settings and preferences"))
def __init__(self, type, screen=None, time=None): gtk.MessageDialog.__init__(self, type=gtk.MESSAGE_WARNING) if not time: time = gobject.get_current_time() self.dialog_type = type self.set_skip_pager_hint(True) self.set_skip_taskbar_hint(True) self.set_keep_above(True) self.stick() self.timeout_id = 0 self.set_title("") self.connect("destroy", self._destroy) self.connect("response", self._response) if type is self.SHUTDOWN: icon_name = "gnome-shutdown" primary_text = _("Shut down this computer now?") try: if gpm_dbus.AllowedSuspend(): btn = self.add_button(_("_Sleep"), self.RESPONSE_SUSPEND_TO_RAM) btn.set_image( icon_factory.load_image("gnome-session-suspend.png", gtk.ICON_SIZE_BUTTON)) if gpm_dbus.AllowedHibernate(): btn = self.add_button(_("_Hibernate"), self.RESPONSE_SUSPEND_TO_DISK) btn.set_image( icon_factory.load_image("gnome-session-hibernate.png", gtk.ICON_SIZE_BUTTON)) except dbus.DBusException: pass btn = self.add_button(_("_Reboot"), self.RESPONSE_REBOOT) btn.set_image( icon_factory.load_image("gnome-session-reboot.png", gtk.ICON_SIZE_BUTTON)) self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) btn = self.add_button(_("Shut _Down"), self.RESPONSE_SHUTDOWN) btn.set_image( icon_factory.load_image("gnome-session-halt.png", gtk.ICON_SIZE_BUTTON)) self.timed_out_response = self.RESPONSE_SHUTDOWN elif type is self.LOGOUT: icon_name = "gnome-logout" primary_text = _("Log out of this computer now?") self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) btn = self.add_button(_("_Log Out"), self.RESPONSE_LOGOUT) btn.set_image( icon_factory.load_image("gnome-session-logout.png", gtk.ICON_SIZE_BUTTON)) self.timed_out_response = self.RESPONSE_LOGOUT else: assert False, "Not reached" # GTK before 2.10 crashes when setting a custom icon in message dialogs if gtk.gtk_version[2] >= 10: self.image.set_from_icon_name(icon_name, gtk.ICON_SIZE_DIALOG) self.set_markup("<span size=\"larger\" weight=\"bold\">%s</span>" % primary_text) self.set_default_response(gtk.RESPONSE_CANCEL) if screen: self.set_screen(screen) self.set_timeout()