Ignore:
Timestamp:
02/25/12 10:14:12 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Created icons, reorganized sources and made the Windows installer work

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/mlx/mlx.py

    r26 r27  
    1212import time
    1313
     14appIndicator = False
     15
    1416if os.name=="nt" or "FORCE_PYGTK" in os.environ:
    1517    print "Using PyGTK"
     
    1820    import gtk
    1921    import gobject
     22    try:
     23        import appindicator
     24        appIndicator = True
     25    except Exception, e:
     26        pass
    2027else:
    2128    print "Using PyGObject"
     
    2330    from gi.repository import Gtk as gtk
    2431    from gi.repository import GObject as gobject
     32    from gi.repository import AppIndicator3 as appindicator
     33    appIndicator = True
    2534
    2635import cairo
     
    5665        win = gtk.Window()
    5766        win.set_title("MAVA Logger X " + const.VERSION)
     67        win.set_icon_from_file("logo.ico")
    5868        win.connect("delete-event", gtk.main_quit)
    5969
     
    586596        self._logView.scroll_mark_onscreen(buffer.get_insert())
    587597
     598class 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
    588653def main():
    589654    """The main operation of the program."""
    590655    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
    591691    gui = GUI()
    592692    gui.build()
    593693    gui.run()
    594              
     694
    595695if __name__ == "__main__":
    596696    main()
Note: See TracChangeset for help on using the changeset viewer.