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");
90 this.popup_menu.connect( (button,event_time) =>{
92 //print(Array.prototype.slice.call(arguments).join(','));
94 //var menu = this.get('menu');
99 this.menu.resume.show();
100 this.menu.pause.hide();
102 this.menu.resume.hide();
103 this.menu.pause.show();
106 //Gtk.get_current_event_device ()
116 this.menu = new MenuA();
119 //var a = new Gdk.Rectangle();
120 // needs direction=inout setting in gir to work (in bugzilla @present)
121 //this.el.get_geometry(g,a,null);
123 // should check to see if @ top or bottom I guess..
124 //menu.el.get_toplevel().move(a.x, a.y +a.height);
125 //menu.el.get_toplevel().move(10,10);
133 public ImageMenuItem pause;
134 public ImageMenuItem resume;
138 this.pause = new Gtk.ImageMenuItemA();
139 this.add(this.pause);
140 this.resume = new Gtk.ImageMenuItemB();
141 this.add(this.resume);
145 class ImageMenuItemA : ImageMenuItem {
162 this.el = XObject.isSeed ?
163 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE)
164 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PAUSE, null);
165 XObject.prototype.init.call(this);
167 label: 'Pause Commits',
169 always_show_image : true,
175 activate : function () {
176 this.parent.parent.paused = true;
177 imports.GitMonitor.GitMonitor.stop();
178 // this.el.label = status ? 'Resume' : 'Pause';
179 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
187 this.el = XObject.isSeed ?
188 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY)
189 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_MEDIA_PLAY, null);
190 XObject.prototype.init.call(this);
192 label: 'Resume Commits',
193 always_show_image : true,
199 activate : function () {
200 this.parent.parent.paused = false;
201 imports.GitMonitor.GitMonitor.start();
202 //var status = this.el.label == 'Pause' ? 1 : 0
203 // this.el.label = status ? 'Resume' : 'Pause';
212 this.el = XObject.isSeed ?
213 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
214 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
216 XObject.prototype.init.call(this);
218 label: 'Pull (Refresh) All',
219 always_show_image : true,
224 activate : function () {
225 imports.GitMonitor.GitMonitor.stop();
228 var tr = imports.Scm.Repo.Repo.list();
229 for (var i= 0; i< tr.length;i++) {
230 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
233 if (!repo.autocommit()) {
234 //??? should we ignore ones not on autocommit..
238 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
240 var str = repo.pull();
241 // do not care if it's already in sycn..
242 if (str.match(/Already up-to-date/)) {
245 var notification = new Notify.Notification({
246 summary: "Updated " + repo.name,
249 notification.set_timeout(20);
253 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
254 print(JSON.stringify(e));
255 print("notification or push errror- probably to many in queue..");
256 imports.gitlive.errorDialog(e.message);
260 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
265 imports.GitMonitor.GitMonitor.start();
271 this.el = XObject.isSeed ?
272 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
273 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
275 XObject.prototype.init.call(this);
277 label: 'Update Timesheet',
278 always_show_image : true,
284 activate : function () {
285 var ret = imports.FixBug.FixBug.show();
294 this.el = XObject.isSeed ?
295 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
296 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
297 XObject.prototype.init.call(this);
299 label: 'Manage Clones',
300 always_show_image : true,
306 activate : function () {
307 var ret = imports.Clones.Clones.show();
318 this.el = XObject.isSeed ?
319 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
320 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
322 XObject.prototype.init.call(this);
324 label: 'About GitLive',
327 activate : function () {
328 var msg = new Gtk.AboutDialog({
329 program_name : "Git Live",
331 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
332 website_label: 'RooJS Consulting',
335 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
345 this.el = XObject.isSeed ?
346 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
347 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
349 XObject.prototype.init.call(this);
354 activate : function () {