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();
39 pubic StatusIconA statusicon;
41 class StatusIconA : StatusIcon {
45 public StatusIconA() {
51 this.stock = Gtk.STOCK_REFRESH;
52 this.tooltip_text = "GitLive";
53 this.title = "gitlive";
55 this.set_name("gitlive");
58 var menu = new MenuA();
61 this.popup_menu.connect( (button,event_time) =>{
63 //print(Array.prototype.slice.call(arguments).join(','));
65 //var menu = this.get('menu');
77 //Gtk.get_current_event_device ()
88 //var a = new Gdk.Rectangle();
89 // needs direction=inout setting in gir to work (in bugzilla @present)
90 //this.el.get_geometry(g,a,null);
92 // should check to see if @ top or bottom I guess..
93 //menu.el.get_toplevel().move(a.x, a.y +a.height);
94 //menu.el.get_toplevel().move(10,10);
102 public ImageMenuItem pause;
103 public ImageMenuItem resume;
107 this.pause = new ImageMenuItemA();
108 this.append(this.pause);
109 this.resume = new ImageMenuItemB();
110 this.append(this.resume);
114 class ImageMenuItemA : ImageMenuItem {
116 public ImageMenuItemA()
118 this.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
119 this.label= "Pause Commits";
120 this.always_show_image = true;
121 this.accel_group = null;
123 this.activate.connect( () => {
124 statusicon.paused = true;
126 //GitMonitor.GitMonitor.stop();
127 // this.el.label = status ? 'Resume' : 'Pause';
128 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
137 class ImageMenuItemB : ImageMenuItem {
139 public ImageMenuItemB()
141 this.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
142 this.label= "Start Commits";
143 this.always_show_image = true;
144 this.accel_group = null;
146 this.activate.connect( () => {
147 //GitMonitor.GitMonitor.start();
148 statusicon.paused = false;
151 // this.el.label = status ? 'Resume' : 'Pause';
152 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
168 this.el = XObject.isSeed ?
169 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
170 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
172 XObject.prototype.init.call(this);
174 label: 'Pull (Refresh) All',
175 always_show_image : true,
180 activate : function () {
181 imports.GitMonitor.GitMonitor.stop();
184 var tr = imports.Scm.Repo.Repo.list();
185 for (var i= 0; i< tr.length;i++) {
186 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
189 if (!repo.autocommit()) {
190 //??? should we ignore ones not on autocommit..
194 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
196 var str = repo.pull();
197 // do not care if it's already in sycn..
198 if (str.match(/Already up-to-date/)) {
201 var notification = new Notify.Notification({
202 summary: "Updated " + repo.name,
205 notification.set_timeout(20);
209 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
210 print(JSON.stringify(e));
211 print("notification or push errror- probably to many in queue..");
212 imports.gitlive.errorDialog(e.message);
216 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
221 imports.GitMonitor.GitMonitor.start();
227 this.el = XObject.isSeed ?
228 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
229 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
231 XObject.prototype.init.call(this);
233 label: 'Update Timesheet',
234 always_show_image : true,
240 activate : function () {
241 var ret = imports.FixBug.FixBug.show();
250 this.el = XObject.isSeed ?
251 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
252 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
253 XObject.prototype.init.call(this);
255 label: 'Manage Clones',
256 always_show_image : true,
262 activate : function () {
263 var ret = imports.Clones.Clones.show();
274 this.el = XObject.isSeed ?
275 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
276 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
278 XObject.prototype.init.call(this);
280 label: 'About GitLive',
283 activate : function () {
284 var msg = new Gtk.AboutDialog({
285 program_name : "Git Live",
287 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
288 website_label: 'RooJS Consulting',
291 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
301 this.el = XObject.isSeed ?
302 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
303 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
305 XObject.prototype.init.call(this);
310 activate : function () {