2 * Status icon and menu for component of gitlive.
4 * Implements XObject - however we want to control initialization.
8 * Currently only does a few things
15 // valac --pkg gtk+-3.0 StatusIcon.vala -o /tmp/StatusIcon
17 //var gitlive = imports.gitlive;
23 static int main (string[] args) {
24 // A reference to our file
36 //public StatusIconA statusicon;
38 public class StatusIconA : StatusIcon {
40 public bool paused = false;
41 public static StatusIconA statusicon;
43 public StatusIconA() {
48 this.stock = Gtk.Stock.REFRESH;
49 this.tooltip_text = "GitLive";
50 this.title = "gitlive";
52 this.set_name("gitlive");
53 this.set_visible(true);
55 var menu = new MenuA();
57 this.button_press_event.connect( ( ev ) =>{
58 print("button press event called\n");
69 // public void popup (Gtk.Widget? parent_menu_shell, Gtk.Widget? parent_menu_item,
70 // [CCode (scope = "async")] Gtk.MenuPositionFunc? func, uint button, uint32 activate_time);
71 //Gtk.get_current_event_device ()
77 ev.button, ev.time // time
83 this.popup_menu.connect( ( button, time) =>{
84 //this.button_press_event.connect( ( ) =>{
86 //print(Array.prototype.slice.call(arguments).join(','));
87 print("menu activiate called\n");
88 //var menu = this.get('menu');
99 // public void popup (Gtk.Widget? parent_menu_shell, Gtk.Widget? parent_menu_item,
100 // [CCode (scope = "async")] Gtk.MenuPositionFunc? func, uint button, uint32 activate_time);
101 //Gtk.get_current_event_device ()
112 //var a = new Gdk.Rectangle();
113 // needs direction=inout setting in gir to work (in bugzilla @present)
114 //this.el.get_geometry(g,a,null);
116 // should check to see if @ top or bottom I guess..
117 //menu.el.get_toplevel().move(a.x, a.y +a.height);
118 //menu.el.get_toplevel().move(10,10);
127 this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
133 this.set_from_stock( Gtk.Stock.MEDIA_PLAY );
137 public void refreshing()
139 this.set_from_stock( Gtk.Stock.REFRESH );
142 public void pauseError()
146 Timeout.add_full(Priority.LOW, 500, () => {
151 this.set_from_stock( flag == true ? Gtk.Stock.MEDIA_RECORD
152 : Gtk.Stock.MEDIA_PAUSE);
159 class MenuA : Gtk.Menu
161 public ImageMenuItem pause;
162 public ImageMenuItem resume;
166 this.pause = new ImageMenuItemA();
167 this.append(this.pause);
168 this.resume = new ImageMenuItemB();
169 this.append(this.resume);
170 this.append(new ImageMenuItemC());
171 this.append(new ImageMenuItemD());
172 this.append(new ImageMenuItemE());
173 this.append(new ImageMenuItemF());
174 this.append(new ImageMenuItemG());
181 class ImageMenuItemA : ImageMenuItem {
183 public ImageMenuItemA()
185 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
187 var image = new Gtk.Image();
188 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
189 this.set_image (image);
191 this.label= "Pause Commits";
192 this.always_show_image = true;
193 this.accel_group = null;
195 this.activate.connect( () => {
196 statusicon.paused = true;
197 GitMonitor.gitmonitor.stop();
199 // this.el.label = status ? 'Resume' : 'Pause';
200 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
209 class ImageMenuItemB : ImageMenuItem {
211 public ImageMenuItemB()
214 var image = new Gtk.Image();
215 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
216 this.set_image (image);
217 this.label= "Start Commits";
218 this.always_show_image = true;
219 this.accel_group = null;
221 this.activate.connect( () => {
222 GitMonitor.gitmonitor.start();
223 statusicon.paused = false;
226 // this.el.label = status ? 'Resume' : 'Pause';
227 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
237 class ImageMenuItemC : ImageMenuItem {
239 public ImageMenuItemC()
242 var image = new Gtk.Image();
243 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
244 this.set_image (image);
245 this.label= "Pull (Refresh) All";
246 this.always_show_image = true;
247 this.accel_group = null;
249 this.activate.connect( () => {
250 GitMonitor.gitmonitor.stop();
251 var tr = GitRepo.list();
257 for (var i= 0; i< tr.length;i++) {
258 statusicon.set_from_stock(
259 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
261 var repo = tr.index(i);
262 //if (!repo.autocommit()) {
263 //??? should we ignore ones not on autocommit..
267 statusicon.set_tooltip_text("pull: " + repo.name);
268 var str = repo.pull();
269 // do not care if it's already in sycn..
270 if (Regex.match_simple ("Already up-to-date", str) ) {
273 var notification = new Notify.Notification(
274 "Updated " + repo.name,
280 notification.set_timeout(20);
284 print("notification or push errror- probably to many in queue..");
285 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
297 var tr = GitRepo.list();
299 GitMonitor.gitmonitor.stop();
302 var total = tr.length;
304 for (var i= 0; i< tr.length;i++) {
305 statusicon.set_from_stock(
306 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
308 var repo = tr.index(i);
309 //if (!repo.autocommit()) {
310 //??? should we ignore ones not on autocommit..
314 statusicon.set_tooltip_text("pull: " + repo.name);
316 repo.pull_async.begin((obj, res) => {
318 if (!Regex.match_simple ("Already up-to-date", str) ) {
321 str += str.length > 0 ? "\n" : "";
322 str += "Updated: " +repo.name + "\n" + res +"\n";
325 var notification = new Notify.Notification(
330 notification.set_timeout(20);
332 statusicon.set_tooltip_text("Gitlive");
335 GitMonitor.gitmonitor.start();
338 // do not care if it's already in sycn..
344 // print("notification or push errror- probably to many in queue..");
345 // statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
361 class ImageMenuItemD : ImageMenuItem {
363 public ImageMenuItemD()
366 var image = new Gtk.Image();
367 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
368 this.set_image (image);
369 this.label= "Update Timesheet";
370 this.always_show_image = true;
371 this.accel_group = null;
373 this.activate.connect( () => {
374 //var ret = imports.FixBug.FixBug.show();
381 class ImageMenuItemE : ImageMenuItem {
383 public ImageMenuItemE()
386 var image = new Gtk.Image();
387 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
388 this.set_image (image);
389 this.label= "Manage Clones";
390 this.always_show_image = true;
391 this.accel_group = null;
393 this.activate.connect( () => {
394 //var ret = imports.Clones.Clones.show();
401 class ImageMenuItemF : ImageMenuItem {
403 public ImageMenuItemF()
406 var image = new Gtk.Image();
407 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
408 this.set_image (image);
409 this.label= "About Gitlive";
410 this.always_show_image = true;
411 this.accel_group = null;
413 this.activate.connect( () => {
414 //var ret = imports.Clones.Clones.show();
416 var msg = new Gtk.AboutDialog();
417 msg.program_name = "Git Live";
419 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
420 msg.website_label= "Roo J Solutions Ltd.";
421 msg.license = "LGPL";
422 msg.authors = { "Alan Knowles <alan@roojs.com>" };
431 class ImageMenuItemG : ImageMenuItem {
433 public ImageMenuItemG()
436 var image = new Gtk.Image();
437 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
438 this.set_image (image);
440 this.always_show_image = true;
441 this.accel_group = null;
443 this.activate.connect( () => {
446 //var ret = imports.Clones.Clones.show();