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
27 var window = new TestWindow();
37 public class TestButton : Button {
40 this.set_label("Click me");
43 this.clicked.connect (() => {
44 this.label = "Thank you";
52 public class TestWindow : Window {
55 this.title = "First GTK+ Program";
56 this.border_width = 10;
57 this.window_position = WindowPosition.CENTER;
58 this.set_default_size (350, 70);
61 this.destroy.connect (Gtk.main_quit);
64 this.add(new TestButton());
76 class StatusIconA : StatusIcon {
82 public StatusIconA() {
84 this.stock = Gtk.STOCK_REFRESH;
85 this.tooltip_text = "GitLive";
86 this.title = "gitlive";
88 this.set_name("gitlive");
91 var menu = new MenuA();
94 this.popup_menu.connect( (button,event_time) =>{
96 //print(Array.prototype.slice.call(arguments).join(','));
98 //var menu = this.get('menu');
100 this.menu.show_all();
103 this.menu.resume.show();
104 this.menu.pause.hide();
106 this.menu.resume.hide();
107 this.menu.pause.show();
110 //Gtk.get_current_event_device ()
121 //var a = new Gdk.Rectangle();
122 // needs direction=inout setting in gir to work (in bugzilla @present)
123 //this.el.get_geometry(g,a,null);
125 // should check to see if @ top or bottom I guess..
126 //menu.el.get_toplevel().move(a.x, a.y +a.height);
127 //menu.el.get_toplevel().move(10,10);
135 public ImageMenuItem pause;
136 public ImageMenuItem resume;
140 this.pause = new ImageMenuItemA();
141 this.append(this.pause);
142 this.resume = new ImageMenuItemB();
143 this.append(this.resume);
147 class ImageMenuItemA : ImageMenuItem {
149 public ImageMenuItemA()
151 this.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
152 this.label= "Pause Commits";
153 this.always_show_image = true;
154 this.accel_group = null;
156 this.activate.connect( () => {
157 this.parent.parent.paused = true;
158 imports.GitMonitor.GitMonitor.stop();
159 // this.el.label = status ? 'Resume' : 'Pause';
160 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
184 activate : function () {
185 this.parent.parent.paused = true;
186 imports.GitMonitor.GitMonitor.stop();
187 // this.el.label = status ? 'Resume' : 'Pause';
188 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
196 this.el = XObject.isSeed ?
197 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY)
198 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PLAY, null);
199 XObject.prototype.init.call(this);
201 label: 'Resume Commits',
202 always_show_image : true,
208 activate : function () {
209 this.parent.parent.paused = false;
210 imports.GitMonitor.GitMonitor.start();
211 //var status = this.el.label == 'Pause' ? 1 : 0
212 // this.el.label = status ? 'Resume' : 'Pause';
221 this.el = XObject.isSeed ?
222 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
223 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
225 XObject.prototype.init.call(this);
227 label: 'Pull (Refresh) All',
228 always_show_image : true,
233 activate : function () {
234 imports.GitMonitor.GitMonitor.stop();
237 var tr = imports.Scm.Repo.Repo.list();
238 for (var i= 0; i< tr.length;i++) {
239 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
242 if (!repo.autocommit()) {
243 //??? should we ignore ones not on autocommit..
247 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
249 var str = repo.pull();
250 // do not care if it's already in sycn..
251 if (str.match(/Already up-to-date/)) {
254 var notification = new Notify.Notification({
255 summary: "Updated " + repo.name,
258 notification.set_timeout(20);
262 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
263 print(JSON.stringify(e));
264 print("notification or push errror- probably to many in queue..");
265 imports.gitlive.errorDialog(e.message);
269 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
274 imports.GitMonitor.GitMonitor.start();
280 this.el = XObject.isSeed ?
281 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
282 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
284 XObject.prototype.init.call(this);
286 label: 'Update Timesheet',
287 always_show_image : true,
293 activate : function () {
294 var ret = imports.FixBug.FixBug.show();
303 this.el = XObject.isSeed ?
304 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
305 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
306 XObject.prototype.init.call(this);
308 label: 'Manage Clones',
309 always_show_image : true,
315 activate : function () {
316 var ret = imports.Clones.Clones.show();
327 this.el = XObject.isSeed ?
328 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
329 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
331 XObject.prototype.init.call(this);
333 label: 'About GitLive',
336 activate : function () {
337 var msg = new Gtk.AboutDialog({
338 program_name : "Git Live",
340 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
341 website_label: 'RooJS Consulting',
344 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
354 this.el = XObject.isSeed ?
355 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
356 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
358 XObject.prototype.init.call(this);
363 activate : function () {