Trying to upload all related projects
[easy-deb-chroot] / diablo / easymer / src / usr / bin / ae-menu.py
diff --git a/diablo/easymer/src/usr/bin/ae-menu.py b/diablo/easymer/src/usr/bin/ae-menu.py
new file mode 100755 (executable)
index 0000000..7fd5e37
--- /dev/null
@@ -0,0 +1,90 @@
+#! /usr/bin/env python
+
+import gobject
+import gtk
+import os
+import csv
+import string
+import hildon
+from ae_xpm import STI
+
+class aeMenu():
+    def __init__(self):
+        self.statusIcon = gtk.StatusIcon()
+        self.statusIcon.connect('activate', self.on_activate)
+        self.stis = STI()
+        sti = gtk.gdk.pixbuf_new_from_xpm_data(self.stis.get_pixbuf(0))
+        self.statusIcon.set_from_pixbuf(sti)
+        if os.path.exists("/home/user/.ae-menu"):
+          self.rdr_mmenu = csv.reader(open("/home/user/.ae-menu", "rb"), delimiter=':')
+
+        #gobject.timeout_add(30000, self.chkdir)
+
+    def on_activate(self, si):
+        self.clicked_icon()
+
+    def chkdir(self):
+        str1=''
+
+    def clicked_icon(self):
+
+        menu = gtk.Menu()
+
+        if os.path.exists("/home/user/.ae-menu"):
+          rdr_mmenu = csv.reader(open("/home/user/.ae-menu", "rb"), delimiter=':')
+
+          for rowitem in rdr_mmenu:
+            # rowitem[0] = label
+            # rowitem[1] = command
+            item1 = gtk.MenuItem(rowitem[0])
+            menu.append(item1)
+            item1.connect_object("activate", self.cmd_run, rowitem[1], rowitem[0])
+            item1.show()
+
+        quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
+        menu.append(quit)
+        quit.connect_object("activate", gtk.main_quit, "menu.quit")
+        quit.show()
+        
+        # menu.show_all()
+        menu.popup(None, None, gtk.status_icon_position_menu, 0, gtk.get_current_event_time(), self.statusIcon)
+
+    def cmd_run(self, cmnd, appname):
+       # for some reason, I have to create a widget to pass to the banner.
+       throwaway = hildon.Window()
+       cmdmsg = "Starting '%s'" % (appname)
+       hildon.hildon_banner_show_information(throwaway, None, cmdmsg) 
+       os.system(cmnd+' &')
+
+    def popbox(self, something):
+        w = gtk.Window()
+        w.set_title('test')
+        w.connect('destroy', self.on_ok_clicked, w)
+        w.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+
+        str1 = something
+        str2 = 'test'
+        l1 = gtk.Label(str1)
+        l2 = gtk.Label(str2)
+        hboxu = gtk.VBox(True, 0)
+        hboxu.pack_start(l1, False, False, 10)
+        hboxu.pack_start(l2, False, False, 10)
+
+        b = gtk.Button('OK', gtk.STOCK_OK)
+        b.connect('clicked', self.on_ok_clicked, w)
+        vboxd = gtk.VBox(True, 0)
+        vboxd.pack_start(b, False, False, 0)
+
+        vbox = gtk.HBox(False, 0)
+        vbox.pack_start(hboxu, False, False, 20)
+        vbox.pack_start(vboxd, False, False, 20)
+        w.add(vbox)
+
+        w.show_all() 
+
+    def on_ok_clicked(self, button, window):
+        window.hide()
+
+if __name__ == "__main__":
+    tbd = aeMenu()
+    gtk.main()