StatusIcon.vala
[gitlive] / StatusIcon.vala
index a65ba84..af125a4 100644 (file)
@@ -18,7 +18,7 @@
 
 
 using Gtk;
-
+/*
 
 static int main (string[] args) {
     // A reference to our file
@@ -30,14 +30,15 @@ static int main (string[] args) {
      
 
 }
+ */
 
 
-public StatusIconA statusicon;
+//public StatusIconA statusicon;
  
 public class StatusIconA : StatusIcon {
 
-    bool paused = false;
+    public bool paused = false;
+    public static StatusIconA statusicon;
      
     public StatusIconA() {
         
@@ -46,18 +47,20 @@ public class StatusIconA : StatusIcon {
          //title : 'gitlive',
         this.stock = Gtk.Stock.REFRESH;
         this.tooltip_text = "GitLive";
-        this.title = "vgitlive";
+        this.title = "gitlive";
         
-        this.set_name("vgitlive");
+        this.set_name("gitlive");
         this.set_visible(true);      
         
         var menu = new MenuA();
-                 
-         
-        this.activate.connect( () =>{
-            
+        menu.ref();       
+
+           
+       this.popup_menu.connect( (  button,   time) =>{
+       //this.button_press_event.connect( (  ) =>{
+               
             //print(Array.prototype.slice.call(arguments).join(','));
-            
+            print("menu activiate called\n");
             //var menu = this.get('menu');
             
             menu.show_all();
@@ -69,17 +72,18 @@ public class StatusIconA : StatusIcon {
                 menu.resume.hide();
                 menu.pause.show();
             }
-              
+              //               public void popup (Gtk.Widget? parent_menu_shell, Gtk.Widget? parent_menu_item,
+                    // [CCode (scope = "async")] Gtk.MenuPositionFunc? func, uint button, uint32 activate_time);
             //Gtk.get_current_event_device ()
             menu.popup(
-                    
+
                         null, null,
-                        this.position_menu, 0,
-                         Gtk.get_current_event_time()
+                       this.position_menu,
+                       
+                    button,  time //   time
             );
                         
             
-            
             //var g = { };
             //var a = new Gdk.Rectangle();
             //  needs direction=inout setting in gir to work (in bugzilla @present)
@@ -88,11 +92,18 @@ public class StatusIconA : StatusIcon {
             // should check to see if @ top or bottom I guess..
             //menu.el.get_toplevel().move(a.x, a.y +a.height);
             //menu.el.get_toplevel().move(10,10);
+            //return false;
               
         }); 
         
     }
     
+    void pause()
+    {
+               this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
+    }
+    
+    
     class MenuA : Gtk.Menu
     {
         public ImageMenuItem pause;
@@ -123,7 +134,7 @@ public class StatusIconA : StatusIcon {
                 
                 var  image = new Gtk.Image();
                 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
-               this.set_image (image);
+                this.set_image (image);
                 
                 this.label= "Pause Commits";
                 this.always_show_image = true;
@@ -131,8 +142,8 @@ public class StatusIconA : StatusIcon {
                 
                 this.activate.connect( () => {
                     statusicon.paused = true;
-                    
-                    //GitMonitor.GitMonitor.stop();
+                    GitMonitor.gitmonitor.stop();
+
                    // this.el.label  = status ? 'Resume' : 'Pause';
                     statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
                     
@@ -150,13 +161,13 @@ public class StatusIconA : StatusIcon {
                 
                 var  image = new Gtk.Image();
                 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
-               this.set_image (image);
+                this.set_image (image);
                 this.label= "Start Commits";
                 this.always_show_image = true;
                 this.accel_group = null;
                 
                 this.activate.connect( () => {
-                    //GitMonitor.GitMonitor.start();
+                    GitMonitor.gitmonitor.start();
                     statusicon.paused = false;
                     
                     //
@@ -170,6 +181,7 @@ public class StatusIconA : StatusIcon {
             
         }
         
+        
         class ImageMenuItemC : ImageMenuItem {
             
             public ImageMenuItemC()
@@ -177,56 +189,52 @@ public class StatusIconA : StatusIcon {
                 
                 var  image = new Gtk.Image();
                 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
-               this.set_image (image);
+                this.set_image (image);
                 this.label= "Pull (Refresh) All";
                 this.always_show_image = true;
                 this.accel_group = null;
                 
                 this.activate.connect( () => {
-                    /*
-                   imports.GitMonitor.GitMonitor.stop();
-                           
-                            
-                            var tr = imports.Scm.Repo.Repo.list();
-                            for (var i= 0; i< tr.length;i++) {
-                                this.parent.parent.el.set_from_stock( i%2 ?  Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
+                    GitMonitor.gitmonitor.stop();
+                    var tr = GitRepo.list();
+                    for (var i= 0; i< tr.length;i++) {
+                        statusicon.set_from_stock( i%2 == 0 ?  Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
                                 
-                                var repo = tr[i];
-                                if (!repo.autocommit()) {
-                                    //??? should we ignore ones not on autocommit..
-                                    continue;
-                                }
-                                try {
-                                    this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
-                               
-                                    var str = repo.pull();
+                        var repo = tr.index(i);
+                        //if (!repo.autocommit()) {
+                            //??? should we ignore ones not on autocommit..
+                        //    continue;
+                        //}
+                        try {
+                            statusicon.set_tooltip_text("pull: " + repo.name);
+                            var str = repo.pull();
                                     // do not care if it's already in sycn..
-                                    if (str.match(/Already up-to-date/)) {
-                                        continue;
-                                    }
-                                    var notification = new Notify.Notification({
-                                       summary: "Updated " + repo.name,
-                                       body : str
-                                   });
-                                   notification.set_timeout(20);
-                                   notification.show();
-                                   
-                                } catch(e) {
-                                    this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
-                                    print(JSON.stringify(e));
-                                    print("notification or push errror- probably to many in queue..");
-                                    imports.gitlive.errorDialog(e.message);
-
-                                }
+                            if (Regex.match_simple ("Already up-to-date", str) ) {
+                                continue;
                             }
-                            this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
-                               
+                            var notification = new Notify.Notification( 
+                                     "Updated " + repo.name,
+                                     str,
+                                       "dialog-information"
+                                   
+                            );
+                        
+                            notification.set_timeout(20);
+                            notification.show();
+                                     
+                        } catch(Error e) {
+                            print("notification or push errror- probably to many in queue..");
+                            statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
+                            print(e.message);
                             
+                        }        
+
+                    } 
+                    statusicon.set_tooltip_text("Gitlive");
                              
-                          
-                            imports.GitMonitor.GitMonitor.start();
-                    
-                    */
+                            
+                    GitMonitor.gitmonitor.start();         
+                           
                 });
             }
             
@@ -261,7 +269,7 @@ public class StatusIconA : StatusIcon {
                 
                 var  image = new Gtk.Image();
                 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
-               this.set_image (image);
+                this.set_image (image);
                 this.label= "Manage Clones";
                 this.always_show_image = true;
                 this.accel_group = null;
@@ -281,7 +289,7 @@ public class StatusIconA : StatusIcon {
                 
                 var  image = new Gtk.Image();
                 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
-               this.set_image (image);
+                this.set_image (image);
                 this.label= "About Gitlive";
                 this.always_show_image = true;
                 this.accel_group = null;
@@ -330,4 +338,4 @@ public class StatusIconA : StatusIcon {
 }
       
                 
-                  
\ No newline at end of file
+