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());
74 pubic StatusIconA statusicon;
76 class StatusIconA : StatusIcon {
80 public StatusIconA() {
86 this.stock = Gtk.STOCK_REFRESH;
87 this.tooltip_text = "GitLive";
88 this.title = "gitlive";
90 this.set_name("gitlive");
93 var menu = new MenuA();
96 this.popup_menu.connect( (button,event_time) =>{
98 //print(Array.prototype.slice.call(arguments).join(','));
100 //var menu = this.get('menu');
102 this.menu.show_all();
112 //Gtk.get_current_event_device ()
123 //var a = new Gdk.Rectangle();
124 // needs direction=inout setting in gir to work (in bugzilla @present)
125 //this.el.get_geometry(g,a,null);
127 // should check to see if @ top or bottom I guess..
128 //menu.el.get_toplevel().move(a.x, a.y +a.height);
129 //menu.el.get_toplevel().move(10,10);
137 public ImageMenuItem pause;
138 public ImageMenuItem resume;
142 this.pause = new ImageMenuItemA();
143 this.append(this.pause);
144 this.resume = new ImageMenuItemB();
145 this.append(this.resume);
149 class ImageMenuItemA : ImageMenuItem {
151 public ImageMenuItemA()
153 this.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
154 this.label= "Pause Commits";
155 this.always_show_image = true;
156 this.accel_group = null;
158 this.activate.connect( () => {
159 statusicon.paused = true;
161 //GitMonitor.GitMonitor.stop();
162 // this.el.label = status ? 'Resume' : 'Pause';
163 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
172 class ImageMenuItemB : ImageMenuItem {
174 public ImageMenuItemB()
176 this.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
177 this.label= "Start Commits";
178 this.always_show_image = true;
179 this.accel_group = null;
181 this.activate.connect( () => {
182 //GitMonitor.GitMonitor.start();
183 statusicon.paused = false;
186 // this.el.label = status ? 'Resume' : 'Pause';
187 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
203 this.el = XObject.isSeed ?
204 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
205 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
207 XObject.prototype.init.call(this);
209 label: 'Pull (Refresh) All',
210 always_show_image : true,
215 activate : function () {
216 imports.GitMonitor.GitMonitor.stop();
219 var tr = imports.Scm.Repo.Repo.list();
220 for (var i= 0; i< tr.length;i++) {
221 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
224 if (!repo.autocommit()) {
225 //??? should we ignore ones not on autocommit..
229 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
231 var str = repo.pull();
232 // do not care if it's already in sycn..
233 if (str.match(/Already up-to-date/)) {
236 var notification = new Notify.Notification({
237 summary: "Updated " + repo.name,
240 notification.set_timeout(20);
244 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
245 print(JSON.stringify(e));
246 print("notification or push errror- probably to many in queue..");
247 imports.gitlive.errorDialog(e.message);
251 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
256 imports.GitMonitor.GitMonitor.start();
262 this.el = XObject.isSeed ?
263 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
264 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
266 XObject.prototype.init.call(this);
268 label: 'Update Timesheet',
269 always_show_image : true,
275 activate : function () {
276 var ret = imports.FixBug.FixBug.show();
285 this.el = XObject.isSeed ?
286 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
287 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
288 XObject.prototype.init.call(this);
290 label: 'Manage Clones',
291 always_show_image : true,
297 activate : function () {
298 var ret = imports.Clones.Clones.show();
309 this.el = XObject.isSeed ?
310 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
311 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
313 XObject.prototype.init.call(this);
315 label: 'About GitLive',
318 activate : function () {
319 var msg = new Gtk.AboutDialog({
320 program_name : "Git Live",
322 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
323 website_label: 'RooJS Consulting',
326 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
336 this.el = XObject.isSeed ?
337 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
338 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
340 XObject.prototype.init.call(this);
345 activate : function () {