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();
301 var total = tr.length;
303 for (var i= 0; i< tr.length;i++) {
304 statusicon.set_from_stock(
305 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
307 var repo = tr.index(i);
308 //if (!repo.autocommit()) {
309 //??? should we ignore ones not on autocommit..
313 statusicon.set_tooltip_text("pull: " + repo.name);
315 repo.pull_async((out result) {
317 if (!Regex.match_simple ("Already up-to-date", str) ) {
320 str += str.length > 0 ? "\n" : "";
321 str += "Updated: " +repo.name + "\n" + res +"\n";
324 var notification = new Notify.Notification(
329 notification.set_timeout(20);
331 statusicon.set_tooltip_text("Gitlive");
334 GitMonitor.gitmonitor.start();
337 // do not care if it's already in sycn..
343 // print("notification or push errror- probably to many in queue..");
344 // statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
350 statusicon.set_tooltip_text("Gitlive");
360 class ImageMenuItemD : ImageMenuItem {
362 public ImageMenuItemD()
365 var image = new Gtk.Image();
366 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
367 this.set_image (image);
368 this.label= "Update Timesheet";
369 this.always_show_image = true;
370 this.accel_group = null;
372 this.activate.connect( () => {
373 //var ret = imports.FixBug.FixBug.show();
380 class ImageMenuItemE : ImageMenuItem {
382 public ImageMenuItemE()
385 var image = new Gtk.Image();
386 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
387 this.set_image (image);
388 this.label= "Manage Clones";
389 this.always_show_image = true;
390 this.accel_group = null;
392 this.activate.connect( () => {
393 //var ret = imports.Clones.Clones.show();
400 class ImageMenuItemF : ImageMenuItem {
402 public ImageMenuItemF()
405 var image = new Gtk.Image();
406 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
407 this.set_image (image);
408 this.label= "About Gitlive";
409 this.always_show_image = true;
410 this.accel_group = null;
412 this.activate.connect( () => {
413 //var ret = imports.Clones.Clones.show();
415 var msg = new Gtk.AboutDialog();
416 msg.program_name = "Git Live";
418 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
419 msg.website_label= "Roo J Solutions Ltd.";
420 msg.license = "LGPL";
421 msg.authors = { "Alan Knowles <alan@roojs.com>" };
430 class ImageMenuItemG : ImageMenuItem {
432 public ImageMenuItemG()
435 var image = new Gtk.Image();
436 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
437 this.set_image (image);
439 this.always_show_image = true;
440 this.accel_group = null;
442 this.activate.connect( () => {
445 //var ret = imports.Clones.Clones.show();