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( () => {
253 GitMonitor.gitmonitor.stop();
254 var tr = GitRepo.list();
258 for (var i= 0; i< tr.length;i++) {
259 statusicon.set_from_stock(
260 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
262 var repo = tr.index(i);
263 //if (!repo.autocommit()) {
264 //??? should we ignore ones not on autocommit..
268 statusicon.set_tooltip_text("pull: " + repo.name);
269 var str = repo.pull();
270 // do not care if it's already in sycn..
271 if (Regex.match_simple ("Already up-to-date", str) ) {
274 var notification = new Notify.Notification(
275 "Updated " + repo.name,
281 notification.set_timeout(20);
285 print("notification or push errror- probably to many in queue..");
286 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
299 var tr = GitRepo.list();
301 GitMonitor.gitmonitor.stop();
304 var total = tr.length;
306 for (var i= 0; i< tr.length;i++) {
307 statusicon.set_from_stock(
308 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
310 var repo = tr.index(i);
311 //if (!repo.autocommit()) {
312 //??? should we ignore ones not on autocommit..
316 statusicon.set_tooltip_text("pull: " + repo.name);
318 repo.pull_async((res) => {
321 if (!Regex.match_simple ("Already up-to-date", res) ) {
324 str += str.length > 0 ? "\n" : "";
325 str += "Updated: " +repo.name + "\n" + res +"\n";
328 var notification = new Notify.Notification(
333 notification.set_timeout(20);
335 statusicon.set_tooltip_text("Gitlive");
338 GitMonitor.gitmonitor.start();
341 // do not care if it's already in sycn..
347 // print("notification or push errror- probably to many in queue..");
348 // statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
364 class ImageMenuItemD : ImageMenuItem {
366 public ImageMenuItemD()
369 var image = new Gtk.Image();
370 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
371 this.set_image (image);
372 this.label= "Update Timesheet";
373 this.always_show_image = true;
374 this.accel_group = null;
376 this.activate.connect( () => {
377 //var ret = imports.FixBug.FixBug.show();
384 class ImageMenuItemE : ImageMenuItem {
386 public ImageMenuItemE()
389 var image = new Gtk.Image();
390 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
391 this.set_image (image);
392 this.label= "Manage Clones";
393 this.always_show_image = true;
394 this.accel_group = null;
396 this.activate.connect( () => {
397 //var ret = imports.Clones.Clones.show();
404 class ImageMenuItemF : ImageMenuItem {
406 public ImageMenuItemF()
409 var image = new Gtk.Image();
410 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
411 this.set_image (image);
412 this.label= "About Gitlive";
413 this.always_show_image = true;
414 this.accel_group = null;
416 this.activate.connect( () => {
417 //var ret = imports.Clones.Clones.show();
419 var msg = new Gtk.AboutDialog();
420 msg.program_name = "Git Live";
422 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
423 msg.website_label= "Roo J Solutions Ltd.";
424 msg.license = "LGPL";
425 msg.authors = { "Alan Knowles <alan@roojs.com>" };
434 class ImageMenuItemG : ImageMenuItem {
436 public ImageMenuItemG()
439 var image = new Gtk.Image();
440 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
441 this.set_image (image);
443 this.always_show_image = true;
444 this.accel_group = null;
446 this.activate.connect( () => {
449 //var ret = imports.Clones.Clones.show();