def main(): global HAS_INDICATOR gtk.gdk.threads_init() config.loads(); if config.get('no_use_indicator'): HAS_INDICATOR = False try: import dl libc = dl.open('/lib/libc.so.6') libc.call('prctl', 15, 'hotot', 0, 0, 0) except: pass agent.init_notify() app = MainWindow() agent.app = app if HAS_INDICATOR: #TODO the icon is only work when installed to /usr/share/icons/hicolor/ indicator = appindicator.Indicator('hotot', 'hotot', appindicator.CATEGORY_COMMUNICATIONS) indicator.set_status(appindicator.STATUS_ACTIVE) indicator.set_attention_icon(config.get_ui_object('imgs/ic64_hotot.png')) indicator.set_menu(app.menu_tray) pass gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave()
def create_trayicon(self): """ Create status icon and connect signals """ self.trayicon = gtk.StatusIcon() self.trayicon.connect('activate', self.on_trayicon_activate) self.trayicon.connect('popup-menu', self.on_trayicon_popup_menu) self.trayicon.set_tooltip('Hotot: Click to Active.') self.trayicon.set_from_file( config.get_ui_object('imgs/ic64_hotot.png')) self.trayicon.set_visible(True) pass
def init_notify(): notify.set_icon_from_pixbuf( gtk.gdk.pixbuf_new_from_file( config.get_ui_object ('imgs/ic64_hotot.png'))) notify.set_timeout(3000) pass
def build_gui(self): self.window = gtk.Window() gtk.window_set_default_icon_from_file( config.get_ui_object('imgs/ic64_hotot.png')) self.window.set_icon_from_file( config.get_ui_object('imgs/ic64_hotot.png')) self.window.set_default_size(750, 550) self.window.set_title(_("Hotot")) self.window.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox() scrollw = gtk.ScrolledWindow() self.webv = view.MainView() agent.view = self.webv scrollw.add(self.webv) vbox.pack_start(scrollw) vbox.show_all() self.window.add(vbox) self.menu_tray = gtk.Menu() mitem_resume = gtk.MenuItem(_("_Resume/Active")) mitem_resume.connect('activate', self.on_mitem_resume_activate); self.menu_tray.append(mitem_resume) mitem_prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) mitem_prefs.connect('activate', self.on_mitem_prefs_activate); self.menu_tray.append(mitem_prefs) mitem_about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) mitem_about.connect('activate', self.on_mitem_about_activate); self.menu_tray.append(mitem_about) mitem_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT) mitem_quit.connect('activate', self.on_mitem_quit_activate); self.menu_tray.append(mitem_quit) self.menu_tray.show_all() ## support for ubuntu unity indicator-appmenu menubar = gtk.MenuBar() menuitem_file = gtk.MenuItem(_("_File")) menuitem_file_menu = gtk.Menu() mitem_resume = gtk.MenuItem(_("_Resume/Active")) mitem_resume.connect('activate', self.on_mitem_resume_activate); menuitem_file_menu.append(mitem_resume) mitem_prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) mitem_prefs.connect('activate', self.on_mitem_prefs_activate); menuitem_file_menu.append(mitem_prefs) menuitem_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT) menuitem_quit.connect("activate", self.quit) menuitem_file_menu.append(menuitem_quit) menuitem_file.set_submenu(menuitem_file_menu) menubar.append(menuitem_file) menuitem_help = gtk.MenuItem(_("_Help")) menuitem_help_menu = gtk.Menu() menuitem_about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) menuitem_about.connect("activate", self.on_mitem_about_activate) menuitem_help_menu.append(menuitem_about) menuitem_help.set_submenu(menuitem_help_menu) menubar.append(menuitem_help) menubar.set_size_request(0, 0) menubar.show_all() vbox.pack_start(menubar, expand=0, fill=0, padding=0) ## self.window.show() self.window.connect("delete-event", gtk.Widget.hide_on_delete) pass