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 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 ()
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()
143 this.set_from_stock( Gtk.Stock.MEDIA_PLAY );
144 this.label= "Start Commits";
145 this.always_show_image = true;
146 this.accel_group = null;
148 this.activate.connect( () => {
149 //GitMonitor.GitMonitor.start();
150 statusicon.paused = false;
153 // this.el.label = status ? 'Resume' : 'Pause';
154 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
170 this.el = XObject.isSeed ?
171 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
172 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
174 XObject.prototype.init.call(this);
176 label: 'Pull (Refresh) All',
177 always_show_image : true,
182 activate : function () {
183 imports.GitMonitor.GitMonitor.stop();
186 var tr = imports.Scm.Repo.Repo.list();
187 for (var i= 0; i< tr.length;i++) {
188 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
191 if (!repo.autocommit()) {
192 //??? should we ignore ones not on autocommit..
196 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
198 var str = repo.pull();
199 // do not care if it's already in sycn..
200 if (str.match(/Already up-to-date/)) {
203 var notification = new Notify.Notification({
204 summary: "Updated " + repo.name,
207 notification.set_timeout(20);
211 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
212 print(JSON.stringify(e));
213 print("notification or push errror- probably to many in queue..");
214 imports.gitlive.errorDialog(e.message);
218 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
223 imports.GitMonitor.GitMonitor.start();
229 this.el = XObject.isSeed ?
230 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
231 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
233 XObject.prototype.init.call(this);
235 label: 'Update Timesheet',
236 always_show_image : true,
242 activate : function () {
243 var ret = imports.FixBug.FixBug.show();
252 this.el = XObject.isSeed ?
253 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
254 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
255 XObject.prototype.init.call(this);
257 label: 'Manage Clones',
258 always_show_image : true,
264 activate : function () {
265 var ret = imports.Clones.Clones.show();
276 this.el = XObject.isSeed ?
277 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
278 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
280 XObject.prototype.init.call(this);
282 label: 'About GitLive',
285 activate : function () {
286 var msg = new Gtk.AboutDialog({
287 program_name : "Git Live",
289 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
290 website_label: 'RooJS Consulting',
293 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
303 this.el = XObject.isSeed ?
304 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
305 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
307 XObject.prototype.init.call(this);
312 activate : function () {