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';
52 //print(JSON.stringify([null, null, Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time()]));
53 print( Gtk.get_current_event_time());
54 menu.el.popup(null, null, Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time());
55 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
60 Gtk.get_current_event_device ()
61 menu.el.popup_for_device(
62 Gtk.get_current_event_device (),
63 null, null,null, null, null,
64 1, Gtk.get_current_event_time());
68 //var a = new Gdk.Rectangle();
69 // needs direction=inout setting in gir to work (in bugzilla @present)
70 //this.el.get_geometry(g,a,null);
72 // should check to see if @ top or bottom I guess..
73 //menu.el.get_toplevel().move(a.x, a.y +a.height);
74 menu.el.get_toplevel().move(10,10);
87 this.el = XObject.isSeed ?
88 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE)
89 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PAUSE, null);
90 XObject.prototype.init.call(this);
92 label: 'Pause Commits',
94 always_show_image : true,
100 activate : function () {
101 this.parent.parent.paused = true;
102 imports.GitMonitor.GitMonitor.stop();
103 // this.el.label = status ? 'Resume' : 'Pause';
104 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
112 this.el = XObject.isSeed ?
113 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY)
114 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PLAY, null);
115 XObject.prototype.init.call(this);
117 label: 'Resume Commits',
118 always_show_image : true,
124 activate : function () {
125 this.parent.parent.paused = false;
126 imports.GitMonitor.GitMonitor.start();
127 //var status = this.el.label == 'Pause' ? 1 : 0
128 // this.el.label = status ? 'Resume' : 'Pause';
137 this.el = XObject.isSeed ?
138 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
139 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
141 XObject.prototype.init.call(this);
143 label: 'Pull (Refresh) All',
144 always_show_image : true,
149 activate : function () {
150 imports.GitMonitor.GitMonitor.stop();
153 var tr = imports.Scm.Repo.Repo.list();
154 for (var i= 0; i< tr.length;i++) {
155 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
158 if (!repo.autocommit()) {
159 //??? should we ignore ones not on autocommit..
163 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
165 var str = repo.pull();
166 // do not care if it's already in sycn..
167 if (str.match(/Already up-to-date/)) {
170 var notification = new Notify.Notification({
171 summary: "Updated " + repo.name,
174 notification.set_timeout(20);
178 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
179 print(JSON.stringify(e));
180 print("notification or push errror- probably to many in queue..");
181 imports.gitlive.errorDialog(e.message);
185 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
190 imports.GitMonitor.GitMonitor.start();
196 this.el = XObject.isSeed ?
197 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
198 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
200 XObject.prototype.init.call(this);
202 label: 'Update Timesheet',
203 always_show_image : true,
209 activate : function () {
210 var ret = imports.FixBug.FixBug.show();
219 this.el = XObject.isSeed ?
220 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
221 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
222 XObject.prototype.init.call(this);
224 label: 'Manage Clones',
225 always_show_image : true,
231 activate : function () {
232 var ret = imports.Clones.Clones.show();
243 this.el = XObject.isSeed ?
244 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
245 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
247 XObject.prototype.init.call(this);
249 label: 'About GitLive',
252 activate : function () {
253 var msg = new Gtk.AboutDialog({
254 program_name : "Git Live",
256 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
257 website_label: 'RooJS Consulting',
260 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
270 this.el = XObject.isSeed ?
271 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
272 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
274 XObject.prototype.init.call(this);
279 activate : function () {