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 this.total = tr.length;
306 this.pull_all_error_message = "";
307 for (var i= 0; i< tr.length;i++) {
308 statusicon.set_from_stock(
309 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
311 var repo = tr.index(i);
315 statusicon.set_tooltip_text("pull: " + repo.name);
317 repo.pull_async(this.pullAllCallback);
318 // do not care if it's already in sycn..
330 string pull_all_error_message = "";
332 void pullAllCallback(GitRepo repo, int err, string res)
341 if (!Regex.match_simple ("Already up-to-date", res) ) {
342 var notification = new Notify.Notification(
344 "Updated: " +repo.name + "\n" + res +"\n",
347 notification.set_timeout(20);
353 if (this.total < 1) {
354 if (this.has_error) {
355 GitMonitor.gitmonitor.pauseError(
357 statusicon.set_tooltip_text("Gitlive");
359 GitMonitor.gitmonitor.start();
370 class ImageMenuItemD : ImageMenuItem {
372 public ImageMenuItemD()
375 var image = new Gtk.Image();
376 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
377 this.set_image (image);
378 this.label= "Update Timesheet";
379 this.always_show_image = true;
380 this.accel_group = null;
382 this.activate.connect( () => {
383 //var ret = imports.FixBug.FixBug.show();
390 class ImageMenuItemE : ImageMenuItem {
392 public ImageMenuItemE()
395 var image = new Gtk.Image();
396 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
397 this.set_image (image);
398 this.label= "Manage Clones";
399 this.always_show_image = true;
400 this.accel_group = null;
402 this.activate.connect( () => {
403 //var ret = imports.Clones.Clones.show();
410 class ImageMenuItemF : ImageMenuItem {
412 public ImageMenuItemF()
415 var image = new Gtk.Image();
416 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
417 this.set_image (image);
418 this.label= "About Gitlive";
419 this.always_show_image = true;
420 this.accel_group = null;
422 this.activate.connect( () => {
423 //var ret = imports.Clones.Clones.show();
425 var msg = new Gtk.AboutDialog();
426 msg.program_name = "Git Live";
428 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
429 msg.website_label= "Roo J Solutions Ltd.";
430 msg.license = "LGPL";
431 msg.authors = { "Alan Knowles <alan@roojs.com>" };
440 class ImageMenuItemG : ImageMenuItem {
442 public ImageMenuItemG()
445 var image = new Gtk.Image();
446 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
447 this.set_image (image);
449 this.always_show_image = true;
450 this.accel_group = null;
452 this.activate.connect( () => {
455 //var ret = imports.Clones.Clones.show();