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
15 // valac --pkg gtk+-3.0 StatusIcon.vala -o /tmp/StatusIcon
17 //var gitlive = imports.gitlive;
23 static int main (string[] args) {
24 // A reference to our file
38 pubic StatusIconA statusicon;
40 class StatusIconA : StatusIcon {
44 public StatusIconA() {
50 this.stock = Gtk.STOCK_REFRESH;
51 this.tooltip_text = "GitLive";
52 this.title = "gitlive";
54 this.set_name("gitlive");
57 var menu = new MenuA();
60 this.popup_menu.connect( (button,event_time) =>{
62 //print(Array.prototype.slice.call(arguments).join(','));
64 //var menu = this.get('menu');
76 //Gtk.get_current_event_device ()
87 //var a = new Gdk.Rectangle();
88 // needs direction=inout setting in gir to work (in bugzilla @present)
89 //this.el.get_geometry(g,a,null);
91 // should check to see if @ top or bottom I guess..
92 //menu.el.get_toplevel().move(a.x, a.y +a.height);
93 //menu.el.get_toplevel().move(10,10);
101 public ImageMenuItem pause;
102 public ImageMenuItem resume;
106 this.pause = new ImageMenuItemA();
107 this.append(this.pause);
108 this.resume = new ImageMenuItemB();
109 this.append(this.resume);
113 class ImageMenuItemA : ImageMenuItem {
115 public ImageMenuItemA()
117 this.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
118 this.label= "Pause Commits";
119 this.always_show_image = true;
120 this.accel_group = null;
122 this.activate.connect( () => {
123 statusicon.paused = true;
125 //GitMonitor.GitMonitor.stop();
126 // this.el.label = status ? 'Resume' : 'Pause';
127 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
136 class ImageMenuItemB : ImageMenuItem {
138 public ImageMenuItemB()
140 this.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
141 this.label= "Start Commits";
142 this.always_show_image = true;
143 this.accel_group = null;
145 this.activate.connect( () => {
146 //GitMonitor.GitMonitor.start();
147 statusicon.paused = false;
150 // this.el.label = status ? 'Resume' : 'Pause';
151 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
167 this.el = XObject.isSeed ?
168 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
169 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
171 XObject.prototype.init.call(this);
173 label: 'Pull (Refresh) All',
174 always_show_image : true,
179 activate : function () {
180 imports.GitMonitor.GitMonitor.stop();
183 var tr = imports.Scm.Repo.Repo.list();
184 for (var i= 0; i< tr.length;i++) {
185 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
188 if (!repo.autocommit()) {
189 //??? should we ignore ones not on autocommit..
193 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
195 var str = repo.pull();
196 // do not care if it's already in sycn..
197 if (str.match(/Already up-to-date/)) {
200 var notification = new Notify.Notification({
201 summary: "Updated " + repo.name,
204 notification.set_timeout(20);
208 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
209 print(JSON.stringify(e));
210 print("notification or push errror- probably to many in queue..");
211 imports.gitlive.errorDialog(e.message);
215 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
220 imports.GitMonitor.GitMonitor.start();
226 this.el = XObject.isSeed ?
227 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
228 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
230 XObject.prototype.init.call(this);
232 label: 'Update Timesheet',
233 always_show_image : true,
239 activate : function () {
240 var ret = imports.FixBug.FixBug.show();
249 this.el = XObject.isSeed ?
250 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
251 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
252 XObject.prototype.init.call(this);
254 label: 'Manage Clones',
255 always_show_image : true,
261 activate : function () {
262 var ret = imports.Clones.Clones.show();
273 this.el = XObject.isSeed ?
274 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
275 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
277 XObject.prototype.init.call(this);
279 label: 'About GitLive',
282 activate : function () {
283 var msg = new Gtk.AboutDialog({
284 program_name : "Git Live",
286 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
287 website_label: 'RooJS Consulting',
290 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
300 this.el = XObject.isSeed ?
301 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
302 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
304 XObject.prototype.init.call(this);
309 activate : function () {