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);
73 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE);
74 XObject.prototype.init.call(this);
76 label: 'Pause Commits',
78 always_show_image : true,
84 activate : function () {
85 this.parent.parent.paused = true;
86 imports.GitMonitor.GitMonitor.stop();
87 // this.el.label = status ? 'Resume' : 'Pause';
88 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
96 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY);
97 XObject.prototype.init.call(this);
99 label: 'Resume Commits',
100 always_show_image : true,
106 activate : function () {
107 this.parent.parent.paused = false;
108 imports.GitMonitor.GitMonitor.start();
109 //var status = this.el.label == 'Pause' ? 1 : 0
110 // this.el.label = status ? 'Resume' : 'Pause';
119 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
120 XObject.prototype.init.call(this);
122 label: 'Pull (Refresh) All',
123 always_show_image : true,
128 activate : function () {
129 imports.GitMonitor.GitMonitor.stop();
132 var tr = imports.Scm.Repo.Repo.list();
133 for (var i= 0; i< tr.length;i++) {
134 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
137 if (!repo.autocommit()) {
138 //??? should we ignore ones not on autocommit..
142 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
144 var str = repo.pull();
145 // do not care if it's already in sycn..
146 if (str.match(/Already up-to-date/)) {
149 var notification = new Notify.Notification({
150 summary: "Updated " + repo.name,
153 notification.set_timeout(20);
157 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
158 print(JSON.stringify(e));
159 print("notification or push errror- probably to many in queue..");
160 imports.gitlive.errorDialog(e.message);
164 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
169 imports.GitMonitor.GitMonitor.start();
175 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
176 XObject.prototype.init.call(this);
178 label: 'Manage Clones',
179 always_show_image : true,
185 activate : function () {
186 var ret = imports.Clones.Clones.show();
197 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT);
198 XObject.prototype.init.call(this);
200 label: 'About GitLive',
203 activate : function () {
204 var msg = new Gtk.AboutDialog({
205 program_name : "Git Live",
207 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
208 website_label: 'RooJS Consulting',
211 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
220 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT);
221 XObject.prototype.init.call(this);
226 activate : function () {