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));
49 var isSeed = typeof(Seed) != 'undefined';
51 menu.el.popup(null, null, Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time());
52 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
57 Gtk.get_current_event_device ()
58 menu.el.popup_for_device(
59 Gtk.get_current_event_device (),
60 null, null,null, null, null,
61 1, Gtk.get_current_event_time());
65 //var a = new Gdk.Rectangle();
66 // needs direction=inout setting in gir to work (in bugzilla @present)
67 //this.el.get_geometry(g,a,null);
69 // should check to see if @ top or bottom I guess..
70 //menu.el.get_toplevel().move(a.x, a.y +a.height);
71 menu.el.get_toplevel().move(10,10);
84 this.el = XObject.isSeed ?
85 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE)
86 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PAUSE, null);
87 XObject.prototype.init.call(this);
89 label: 'Pause Commits',
91 always_show_image : true,
97 activate : function () {
98 this.parent.parent.paused = true;
99 imports.GitMonitor.GitMonitor.stop();
100 // this.el.label = status ? 'Resume' : 'Pause';
101 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
109 this.el = XObject.isSeed ?
110 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY)
111 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PLAY, null);
112 XObject.prototype.init.call(this);
114 label: 'Resume Commits',
115 always_show_image : true,
121 activate : function () {
122 this.parent.parent.paused = false;
123 imports.GitMonitor.GitMonitor.start();
124 //var status = this.el.label == 'Pause' ? 1 : 0
125 // this.el.label = status ? 'Resume' : 'Pause';
134 this.el = XObject.isSeed ?
135 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
136 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
138 XObject.prototype.init.call(this);
140 label: 'Pull (Refresh) All',
141 always_show_image : true,
146 activate : function () {
147 imports.GitMonitor.GitMonitor.stop();
150 var tr = imports.Scm.Repo.Repo.list();
151 for (var i= 0; i< tr.length;i++) {
152 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
155 if (!repo.autocommit()) {
156 //??? should we ignore ones not on autocommit..
160 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
162 var str = repo.pull();
163 // do not care if it's already in sycn..
164 if (str.match(/Already up-to-date/)) {
167 var notification = new Notify.Notification({
168 summary: "Updated " + repo.name,
171 notification.set_timeout(20);
175 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
176 print(JSON.stringify(e));
177 print("notification or push errror- probably to many in queue..");
178 imports.gitlive.errorDialog(e.message);
182 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
187 imports.GitMonitor.GitMonitor.start();
193 this.el = XObject.isSeed ?
194 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
195 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
197 XObject.prototype.init.call(this);
199 label: 'Update Timesheet',
200 always_show_image : true,
206 activate : function () {
207 var ret = imports.FixBug.FixBug.show();
216 this.el = XObject.isSeed ?
217 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
218 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
219 XObject.prototype.init.call(this);
221 label: 'Manage Clones',
222 always_show_image : true,
228 activate : function () {
229 var ret = imports.Clones.Clones.show();
240 this.el = XObject.isSeed ?
241 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
242 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
244 XObject.prototype.init.call(this);
246 label: 'About GitLive',
249 activate : function () {
250 var msg = new Gtk.AboutDialog({
251 program_name : "Git Live",
253 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
254 website_label: 'RooJS Consulting',
257 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
267 this.el = XObject.isSeed ?
268 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
269 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
271 XObject.prototype.init.call(this);
276 activate : function () {