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, syncres) => {
318 var res = fetch_webpage.end(syncres);
320 if (!Regex.match_simple ("Already up-to-date", str) ) {
323 str += str.length > 0 ? "\n" : "";
324 str += "Updated: " +repo.name + "\n" + res +"\n";
327 var notification = new Notify.Notification(
332 notification.set_timeout(20);
334 statusicon.set_tooltip_text("Gitlive");
337 GitMonitor.gitmonitor.start();
340 // do not care if it's already in sycn..
346 // print("notification or push errror- probably to many in queue..");
347 // statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
363 class ImageMenuItemD : ImageMenuItem {
365 public ImageMenuItemD()
368 var image = new Gtk.Image();
369 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
370 this.set_image (image);
371 this.label= "Update Timesheet";
372 this.always_show_image = true;
373 this.accel_group = null;
375 this.activate.connect( () => {
376 //var ret = imports.FixBug.FixBug.show();
383 class ImageMenuItemE : ImageMenuItem {
385 public ImageMenuItemE()
388 var image = new Gtk.Image();
389 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
390 this.set_image (image);
391 this.label= "Manage Clones";
392 this.always_show_image = true;
393 this.accel_group = null;
395 this.activate.connect( () => {
396 //var ret = imports.Clones.Clones.show();
403 class ImageMenuItemF : ImageMenuItem {
405 public ImageMenuItemF()
408 var image = new Gtk.Image();
409 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
410 this.set_image (image);
411 this.label= "About Gitlive";
412 this.always_show_image = true;
413 this.accel_group = null;
415 this.activate.connect( () => {
416 //var ret = imports.Clones.Clones.show();
418 var msg = new Gtk.AboutDialog();
419 msg.program_name = "Git Live";
421 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
422 msg.website_label= "Roo J Solutions Ltd.";
423 msg.license = "LGPL";
424 msg.authors = { "Alan Knowles <alan@roojs.com>" };
433 class ImageMenuItemG : ImageMenuItem {
435 public ImageMenuItemG()
438 var image = new Gtk.Image();
439 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
440 this.set_image (image);
442 this.always_show_image = true;
443 this.accel_group = null;
445 this.activate.connect( () => {
448 //var ret = imports.Clones.Clones.show();