diff -Nurp gtk-recordmydesktop-0.3.8/src/rmdTrayIcon.py gtk-recordmydesktop-0.3.8-indicator/src/rmdTrayIcon.py --- gtk-recordmydesktop-0.3.8/src/rmdTrayIcon.py 2008-11-23 16:09:17.000000000 +0100 +++ gtk-recordmydesktop-0.3.8-indicator/src/rmdTrayIcon.py 2011-02-27 10:23:05.130400007 +0100 @@ -40,6 +40,11 @@ if gtk.pygtk_version[0]==2 and gtk.pygtk USE_EGG=0 if USE_EGG==1: import egg.trayicon +try: + import appindicator + has_indicator = True +except ImportError: + has_indicator = False import rmdSelect as isel import rmdTrayPopup as iTP import rmdMonitor as imon @@ -79,7 +84,9 @@ class trayIcon(object): def __buttonPressEGG__(self,widget,event=None): self.__buttonPress__(event.button) def __set_icon__(self,widget,icon): - if USE_EGG==1: + if has_indicator: + self.indicator.set_icon (icon) + elif USE_EGG==1: widget.set_from_stock(icon,gtk.ICON_SIZE_SMALL_TOOLBAR) else: widget.set_from_stock(icon) @@ -100,11 +107,13 @@ class trayIcon(object): #self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_RECORD,gtk.ICON_SIZE_SMALL_TOOLBAR) self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_RECORD) self.state=0 + self._update_indicator_menu() self.__stopRMD__() elif self.state == 2 : #self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_STOP,gtk.ICON_SIZE_SMALL_TOOLBAR) self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_STOP) self.state=1 + self._update_indicator_menu() self.__pauseRMD__() @@ -115,12 +124,43 @@ class trayIcon(object): #self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_PAUSE,gtk.ICON_SIZE_SMALL_TOOLBAR) self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_PAUSE) self.state=2 + self._update_indicator_menu() self.__pauseRMD__() elif self.state ==2: #self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_STOP,gtk.ICON_SIZE_SMALL_TOOLBAR) self.__set_icon__(self.trayIcon,gtk.STOCK_MEDIA_STOP) self.state=1 + self._update_indicator_menu() self.__pauseRMD__() + + + def _update_indicator_menu(self): + if has_indicator: + if self.state == 1: + self.tray_popup.popupmenu_recorditem.hide() + self.tray_popup.popupmenu_continueitem.hide() + self.tray_popup.popupmenu_stopitem.show() + self.tray_popup.popupmenu_pauseitem.show() + self.tray_popup.popupmenu_selectarea.set_sensitive(False) + self.tray_popup.popupmenu_prefs_widget.set_sensitive(False) + self.tray_popup.popupmenu_quititem.set_sensitive(False) + elif self.state == 2: + self.tray_popup.popupmenu_recorditem.hide() + self.tray_popup.popupmenu_continueitem.show() + self.tray_popup.popupmenu_stopitem.hide() + self.tray_popup.popupmenu_pauseitem.hide() + self.tray_popup.popupmenu_selectarea.set_sensitive(False) + self.tray_popup.popupmenu_prefs_widget.set_sensitive(False) + self.tray_popup.popupmenu_quititem.set_sensitive(False) + else: + self.tray_popup.popupmenu_recorditem.show() + self.tray_popup.popupmenu_continueitem.hide() + self.tray_popup.popupmenu_stopitem.hide() + self.tray_popup.popupmenu_pauseitem.hide() + self.tray_popup.popupmenu_selectarea.set_sensitive(True) + self.tray_popup.popupmenu_prefs_widget.set_sensitive(True) + self.tray_popup.popupmenu_quititem.set_sensitive(True) + def record_ext(self,button=None): if self.state == 0: if self.optionsOpen[0]==1: @@ -133,6 +173,7 @@ class trayIcon(object): self.__execRMD__() def __execRMD__(self): + self._update_indicator_menu() self.parent.close_advanced() self.parent.update() self.ch_err="" @@ -329,14 +370,22 @@ class trayIcon(object): def __init__(self,parent): self.parent=parent #self.parent.values=values - if USE_EGG==1: + if has_indicator: + self.indicator = appindicator.Indicator ("gtk-recordmydesktop", + gtk.STOCK_MEDIA_RECORD, + appindicator.CATEGORY_APPLICATION_STATUS) + self.indicator.set_status (appindicator.STATUS_ACTIVE) + self.tray_popup=iTP.TrayPopupMenu(self.parent,self.parent.values,self.optionsOpen, tray_icon=self) + self.indicator.set_menu(self.tray_popup.popupmenu) + self.trayIcon = None + elif USE_EGG==1: self.event_box = gtk.EventBox() self.trayIcon=gtk.Image() self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_RECORD, gtk.ICON_SIZE_SMALL_TOOLBAR) self.event_box.add(self.trayIcon) self.tray_container = egg.trayicon.TrayIcon("recordMyDesktop") self.tray_container.add(self.event_box) - self.tray_popup=iTP.TrayPopupMenu(self.parent,self.parent.values,self.optionsOpen) + self.tray_popup=iTP.TrayPopupMenu(gtk.Menu,self.parent.values,self.optionsOpen) self.event_box.connect("button-press-event", self.__buttonPressEGG__) self.tray_container.show_all() else: @@ -345,6 +394,7 @@ class trayIcon(object): self.tray_popup=iTP.TrayPopupMenu(self.parent,self.parent.values,self.optionsOpen) self.trayIcon.connect("activate",self.__buttonPressNoEGG_Activate__) self.trayIcon.connect("popup-menu",self.__buttonPressNoEGG_Popup__) + #gtk.main() diff -Nurp gtk-recordmydesktop-0.3.8/src/rmdTrayPopup.py gtk-recordmydesktop-0.3.8-indicator/src/rmdTrayPopup.py --- gtk-recordmydesktop-0.3.8/src/rmdTrayPopup.py 2008-11-23 16:09:17.000000000 +0100 +++ gtk-recordmydesktop-0.3.8-indicator/src/rmdTrayPopup.py 2011-02-27 10:25:43.290400010 +0100 @@ -25,6 +25,11 @@ import gtk import locale, gettext +try: + import appindicator + has_indicator = True +except ImportError: + has_indicator = False import rmdConfig _ = gettext.gettext gettext.textdomain('gtk-recordMyDesktop') @@ -35,19 +40,29 @@ from rmdStrings import * class TrayPopupMenu: options=None - def __init__(self,parent,values,optionsOpen): + def __init__(self,parent,values,optionsOpen,tray_icon=None): self.parent=parent self.optionsOpen=optionsOpen self.values=values + self.tray_icon=tray_icon self._setup_popup_menu() self.selector = None self.popupmenu.show_all() + if has_indicator: + self.popupmenu_continueitem.hide() + self.popupmenu_stopitem.hide() + self.popupmenu_pauseitem.hide() def _setup_popup_menu(self): self.popupmenu = gtk.Menu() - self._setup_about() + if has_indicator: + self._setup_record() + self._setup_continue() + self._setup_stop() + self._setup_pause() self._setup_prefs_widget() self._setup_select_area() + self._setup_about() self._setup_quit() def _prefs_widget(self,button): @@ -99,6 +114,33 @@ class TrayPopupMenu: self.popupmenu_quititem.connect('activate', self._quit) self.popupmenu.add(self.popupmenu_quititem) + def _setup_record(self): + self.popupmenu_recorditem = gtk.ImageMenuItem(gtk.STOCK_MEDIA_RECORD) + self.popupmenu_recorditem.connect('activate', self._record_stop) + self.popupmenu.add(self.popupmenu_recorditem) + + def _setup_continue(self): + self.popupmenu_continueitem = gtk.ImageMenuItem(gtk.STOCK_MEDIA_RECORD, False) + self.popupmenu_continueitem.set_label(_("Continue recording")) + self.popupmenu_continueitem.connect('activate', self._pause_continue) + self.popupmenu.add(self.popupmenu_continueitem) + + def _setup_stop(self): + self.popupmenu_stopitem = gtk.ImageMenuItem(gtk.STOCK_MEDIA_STOP) + self.popupmenu_stopitem.connect('activate', self._record_stop) + self.popupmenu.add(self.popupmenu_stopitem) + + def _record_stop(self, button): + self.tray_icon.__buttonPress__(1) + + def _setup_pause(self): + self.popupmenu_pauseitem = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PAUSE) + self.popupmenu_pauseitem.connect('activate', self._pause_continue) + self.popupmenu.add(self.popupmenu_pauseitem) + + def _pause_continue(self, button): + self.tray_icon.__buttonPress__(3) + def _quit(self, button): gtk.main_quit()