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
14 var Gtk = imports.gi.Gtk;
15 var Gdk = imports.gi.Gdk;
16 var Gio = imports.gi.Gio;
17 var GLib = imports.gi.GLib;
18 var Notify = imports.gi.Notify;
20 var XObject = imports.XObject.XObject;
22 //var gitlive = imports.gitlive;
25 var StatusIcon = new XObject({
27 paused : false, // on!
28 xtype : Gtk.StatusIcon,
30 stock : Gtk.STOCK_REFRESH,
31 tooltip_text : 'GitLive',
33 XObject.prototype.init.call(this);
34 this.el.set_name('gitlive');
37 //'popup-menu' : function( w, event, event_time) {
38 'activate' : function( w, event, event_time) {
39 print(Array.prototype.slice.call(arguments).join(','));
41 var menu = this.get('menu');
45 this.get(!this.paused ? 'resume' : 'pause' ).el.hide();
46 print("MENU EL: " + menu.el);
47 print("POPUP: " + typeof(menu.el.popup));
50 menu.el.popup(null, null,Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time());
51 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
56 var a = new Gdk.Rectangle();
57 // needs direction=inout setting in gir to work (in bugzilla @present)
58 this.el.get_geometry(g,a,null);
60 // should check to see if @ top or bottom I guess..
61 menu.el.get_toplevel().move(a.x, a.y +a.height);
74 this.el = XObject.isSeed ?
75 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE)
76 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PAUSE, null);
77 XObject.prototype.init.call(this);
79 label: 'Pause Commits',
81 always_show_image : true,
87 activate : function () {
88 this.parent.parent.paused = true;
89 imports.GitMonitor.GitMonitor.stop();
90 // this.el.label = status ? 'Resume' : 'Pause';
91 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
99 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY);
100 XObject.prototype.init.call(this);
102 label: 'Resume Commits',
103 always_show_image : true,
109 activate : function () {
110 this.parent.parent.paused = false;
111 imports.GitMonitor.GitMonitor.start();
112 //var status = this.el.label == 'Pause' ? 1 : 0
113 // this.el.label = status ? 'Resume' : 'Pause';
122 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
123 XObject.prototype.init.call(this);
125 label: 'Pull (Refresh) All',
126 always_show_image : true,
131 activate : function () {
132 imports.GitMonitor.GitMonitor.stop();
135 var tr = imports.Scm.Repo.Repo.list();
136 for (var i= 0; i< tr.length;i++) {
137 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
140 if (!repo.autocommit()) {
141 //??? should we ignore ones not on autocommit..
145 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
147 var str = repo.pull();
148 // do not care if it's already in sycn..
149 if (str.match(/Already up-to-date/)) {
152 var notification = new Notify.Notification({
153 summary: "Updated " + repo.name,
156 notification.set_timeout(20);
160 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
161 print(JSON.stringify(e));
162 print("notification or push errror- probably to many in queue..");
163 imports.gitlive.errorDialog(e.message);
167 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
172 imports.GitMonitor.GitMonitor.start();
178 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE);
179 XObject.prototype.init.call(this);
181 label: 'Update Timesheet',
182 always_show_image : true,
188 activate : function () {
189 var ret = imports.FixBug.FixBug.show();
198 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
199 XObject.prototype.init.call(this);
201 label: 'Manage Clones',
202 always_show_image : true,
208 activate : function () {
209 var ret = imports.Clones.Clones.show();
220 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT);
221 XObject.prototype.init.call(this);
223 label: 'About GitLive',
226 activate : function () {
227 var msg = new Gtk.AboutDialog({
228 program_name : "Git Live",
230 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
231 website_label: 'RooJS Consulting',
234 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
243 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT);
244 XObject.prototype.init.call(this);
249 activate : function () {