Changeset 27:d95d48685969 for src
- Timestamp:
- 02/25/12 10:14:12 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 added
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/mlx.py
r26 r27 12 12 import time 13 13 14 appIndicator = False 15 14 16 if os.name=="nt" or "FORCE_PYGTK" in os.environ: 15 17 print "Using PyGTK" … … 18 20 import gtk 19 21 import gobject 22 try: 23 import appindicator 24 appIndicator = True 25 except Exception, e: 26 pass 20 27 else: 21 28 print "Using PyGObject" … … 23 30 from gi.repository import Gtk as gtk 24 31 from gi.repository import GObject as gobject 32 from gi.repository import AppIndicator3 as appindicator 33 appIndicator = True 25 34 26 35 import cairo … … 56 65 win = gtk.Window() 57 66 win.set_title("MAVA Logger X " + const.VERSION) 67 win.set_icon_from_file("logo.ico") 58 68 win.connect("delete-event", gtk.main_quit) 59 69 … … 586 596 self._logView.scroll_mark_onscreen(buffer.get_insert()) 587 597 598 class TrackerStatusIcon(gtk.StatusIcon): 599 def __init__(self): 600 gtk.StatusIcon.__init__(self) 601 menu = ''' 602 <ui> 603 <menubar name="Menubar"> 604 <menu action="Menu"> 605 <menuitem action="Search"/> 606 <menuitem action="Preferences"/> 607 <separator/> 608 <menuitem action="About"/> 609 </menu> 610 </menubar> 611 </ui> 612 ''' 613 actions = [ 614 ('Menu', None, 'Menu'), 615 ('Search', None, '_Search...', None, 'Search files with MetaTracker', self.on_activate), 616 ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences...', None, 'Change MetaTracker preferences', self.on_preferences), 617 ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about)] 618 ag = gtk.ActionGroup('Actions') 619 ag.add_actions(actions) 620 self.manager = gtk.UIManager() 621 self.manager.insert_action_group(ag, 0) 622 self.manager.add_ui_from_string(menu) 623 self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent 624 search = self.manager.get_widget('/Menubar/Menu/Search') 625 search.get_children()[0].set_markup('<b>_Search...</b>') 626 search.get_children()[0].set_use_underline(True) 627 search.get_children()[0].set_use_markup(True) 628 #search.get_children()[1].set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU) 629 self.set_from_stock(gtk.STOCK_FIND) 630 self.set_tooltip('Tracker Desktop Search') 631 self.set_visible(True) 632 self.connect('activate', self.on_activate) 633 self.connect('popup-menu', self.on_popup_menu) 634 635 def on_activate(self, data): 636 os.spawnlpe(os.P_NOWAIT, 'tracker-search-tool', os.environ) 637 638 def on_popup_menu(self, status, button, time): 639 self.menu.popup(None, None, None, button, time) 640 641 def on_preferences(self, data): 642 print 'preferences' 643 644 def on_about(self, data): 645 dialog = gtk.AboutDialog() 646 dialog.set_name('Tracker') 647 dialog.set_version('0.5.0') 648 dialog.set_comments('A desktop indexing and search tool') 649 dialog.set_website('www.freedesktop.org/Tracker') 650 dialog.run() 651 dialog.destroy() 652 588 653 def main(): 589 654 """The main operation of the program.""" 590 655 gobject.threads_init() 656 657 # menu = gtk.Menu() 658 # item = gtk.MenuItem() 659 # item.set_label("Menu Item") 660 # item.show() 661 # menu.append(item) 662 663 # menu.show() 664 665 # if appIndicator: 666 # if pygobject: 667 # ind = appindicator.Indicator.new ("mava-logger-x", 668 # "/home/vi/munka/repules/mlx/src/logo.ico", 669 # #"indicator-messages", 670 # appindicator.IndicatorCategory.APPLICATION_STATUS) 671 # ind.set_status (appindicator.IndicatorStatus.ACTIVE) 672 # else: 673 # ind = appindicator.Indicator ("mava-logger-x", 674 # "/home/vi/munka/repules/mlx/src/logo.ico", 675 # appindicator.CATEGORY_APPLICATION_STATUS) 676 # ind.set_status (appindicator.STATUS_ACTIVE) 677 678 # ind.set_menu(menu) 679 # #ind.set_icon("distributor-logo") 680 # else: 681 # def popup_menu(status, button, time): 682 # menu.popup(None, None, gtk.status_icon_position_menu, 683 # button, time, status) 684 # statusIcon = gtk.StatusIcon() 685 # #statusIcon.set_from_stock(gtk.STOCK_FIND) 686 # statusIcon.set_from_file("logo.ico") 687 # statusIcon.set_tooltip_markup("MAVA Logger X") 688 # statusIcon.set_visible(True) 689 # statusIcon.connect('popup-menu', popup_menu) 690 591 691 gui = GUI() 592 692 gui.build() 593 693 gui.run() 594 694 595 695 if __name__ == "__main__": 596 696 main()
Note:
See TracChangeset
for help on using the changeset viewer.