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 pm = typeof(Seed) != 'undefined' ? Gtk.StatusIcon.position_menu : function(in_menu, out_values, y, push_in) {
53 menu.el.popup(null, null, pm , this.el , 1, Gtk.get_current_event_time());
54 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
59 var a = new Gdk.Rectangle();
60 // needs direction=inout setting in gir to work (in bugzilla @present)
61 this.el.get_geometry(g,a,null);
63 // should check to see if @ top or bottom I guess..
64 menu.el.get_toplevel().move(a.x, a.y +a.height);
77 this.el = XObject.isSeed ?
78 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE)
79 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PAUSE, null);
80 XObject.prototype.init.call(this);
82 label: 'Pause Commits',
84 always_show_image : true,
90 activate : function () {
91 this.parent.parent.paused = true;
92 imports.GitMonitor.GitMonitor.stop();
93 // this.el.label = status ? 'Resume' : 'Pause';
94 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
102 this.el = XObject.isSeed ?
103 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY)
104 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PLAY, null);
105 XObject.prototype.init.call(this);
107 label: 'Resume Commits',
108 always_show_image : true,
114 activate : function () {
115 this.parent.parent.paused = false;
116 imports.GitMonitor.GitMonitor.start();
117 //var status = this.el.label == 'Pause' ? 1 : 0
118 // this.el.label = status ? 'Resume' : 'Pause';
127 this.el = XObject.isSeed ?
128 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
129 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
131 XObject.prototype.init.call(this);
133 label: 'Pull (Refresh) All',
134 always_show_image : true,
139 activate : function () {
140 imports.GitMonitor.GitMonitor.stop();
143 var tr = imports.Scm.Repo.Repo.list();
144 for (var i= 0; i< tr.length;i++) {
145 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
148 if (!repo.autocommit()) {
149 //??? should we ignore ones not on autocommit..
153 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
155 var str = repo.pull();
156 // do not care if it's already in sycn..
157 if (str.match(/Already up-to-date/)) {
160 var notification = new Notify.Notification({
161 summary: "Updated " + repo.name,
164 notification.set_timeout(20);
168 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
169 print(JSON.stringify(e));
170 print("notification or push errror- probably to many in queue..");
171 imports.gitlive.errorDialog(e.message);
175 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
180 imports.GitMonitor.GitMonitor.start();
186 this.el = XObject.isSeed ?
187 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
188 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
190 XObject.prototype.init.call(this);
192 label: 'Update Timesheet',
193 always_show_image : true,
199 activate : function () {
200 var ret = imports.FixBug.FixBug.show();
209 this.el = XObject.isSeed ?
210 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
211 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
212 XObject.prototype.init.call(this);
214 label: 'Manage Clones',
215 always_show_image : true,
221 activate : function () {
222 var ret = imports.Clones.Clones.show();
233 this.el = XObject.isSeed ?
234 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
235 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
237 XObject.prototype.init.call(this);
239 label: 'About GitLive',
242 activate : function () {
243 var msg = new Gtk.AboutDialog({
244 program_name : "Git Live",
246 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
247 website_label: 'RooJS Consulting',
250 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
260 this.el = XObject.isSeed ?
261 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
262 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
264 XObject.prototype.init.call(this);
269 activate : function () {