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
36 public StatusIconA statusicon;
38 public class StatusIconA : StatusIcon {
42 public StatusIconA() {
48 this.stock = Gtk.Stock.REFRESH;
49 this.tooltip_text = "GitLive";
50 this.title = "gitlive";
52 this.set_name("gitlive");
55 var menu = new MenuA();
58 this.popup_menu.connect( (button,event_time) =>{
60 //print(Array.prototype.slice.call(arguments).join(','));
62 //var menu = this.get('menu');
74 //Gtk.get_current_event_device ()
78 this.position_menu, button,
85 //var a = new Gdk.Rectangle();
86 // needs direction=inout setting in gir to work (in bugzilla @present)
87 //this.el.get_geometry(g,a,null);
89 // should check to see if @ top or bottom I guess..
90 //menu.el.get_toplevel().move(a.x, a.y +a.height);
91 //menu.el.get_toplevel().move(10,10);
97 class MenuA : Gtk.Menu
99 public ImageMenuItem pause;
100 public ImageMenuItem resume;
104 this.pause = new ImageMenuItemA();
105 this.append(this.pause);
106 this.resume = new ImageMenuItemB();
107 this.append(this.resume);
111 class ImageMenuItemA : ImageMenuItem {
113 public ImageMenuItemA()
115 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
117 var image = new Gtk.Image();
118 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
119 this.set_image (image);
121 this.label= "Pause Commits";
122 this.always_show_image = true;
123 this.accel_group = null;
125 this.activate.connect( () => {
126 statusicon.paused = true;
128 //GitMonitor.GitMonitor.stop();
129 // this.el.label = status ? 'Resume' : 'Pause';
130 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
139 class ImageMenuItemB : ImageMenuItem {
141 public ImageMenuItemB()
144 var image = new Gtk.Image();
145 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
146 this.set_image (image);
147 this.label= "Start Commits";
148 this.always_show_image = true;
149 this.accel_group = null;
151 this.activate.connect( () => {
152 //GitMonitor.GitMonitor.start();
153 statusicon.paused = false;
156 // this.el.label = status ? 'Resume' : 'Pause';
157 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
173 this.el = XObject.isSeed ?
174 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
175 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
177 XObject.prototype.init.call(this);
179 label: 'Pull (Refresh) All',
180 always_show_image : true,
185 activate : function () {
186 imports.GitMonitor.GitMonitor.stop();
189 var tr = imports.Scm.Repo.Repo.list();
190 for (var i= 0; i< tr.length;i++) {
191 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
194 if (!repo.autocommit()) {
195 //??? should we ignore ones not on autocommit..
199 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
201 var str = repo.pull();
202 // do not care if it's already in sycn..
203 if (str.match(/Already up-to-date/)) {
206 var notification = new Notify.Notification({
207 summary: "Updated " + repo.name,
210 notification.set_timeout(20);
214 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
215 print(JSON.stringify(e));
216 print("notification or push errror- probably to many in queue..");
217 imports.gitlive.errorDialog(e.message);
221 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
226 imports.GitMonitor.GitMonitor.start();
232 this.el = XObject.isSeed ?
233 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
234 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
236 XObject.prototype.init.call(this);
238 label: 'Update Timesheet',
239 always_show_image : true,
245 activate : function () {
246 var ret = imports.FixBug.FixBug.show();
255 this.el = XObject.isSeed ?
256 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
257 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
258 XObject.prototype.init.call(this);
260 label: 'Manage Clones',
261 always_show_image : true,
267 activate : function () {
268 var ret = imports.Clones.Clones.show();
279 this.el = XObject.isSeed ?
280 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
281 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
283 XObject.prototype.init.call(this);
285 label: 'About GitLive',
288 activate : function () {
289 var msg = new Gtk.AboutDialog({
290 program_name : "Git Live",
292 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
293 website_label: 'RooJS Consulting',
296 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
306 this.el = XObject.isSeed ?
307 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
308 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
310 XObject.prototype.init.call(this);
315 activate : function () {