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);
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 );
116 this.label= "Pause Commits";
117 this.always_show_image = true;
118 this.accel_group = null;
120 this.activate.connect( () => {
121 statusicon.paused = true;
123 //GitMonitor.GitMonitor.stop();
124 // this.el.label = status ? 'Resume' : 'Pause';
125 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
134 class ImageMenuItemB : ImageMenuItem {
136 public ImageMenuItemB()
138 this.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
139 this.label= "Start Commits";
140 this.always_show_image = true;
141 this.accel_group = null;
143 this.activate.connect( () => {
144 //GitMonitor.GitMonitor.start();
145 statusicon.paused = false;
148 // this.el.label = status ? 'Resume' : 'Pause';
149 statusicon.set_from_stock( Gtk.STOCK_MEDIA_PLAY );
165 this.el = XObject.isSeed ?
166 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
167 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
169 XObject.prototype.init.call(this);
171 label: 'Pull (Refresh) All',
172 always_show_image : true,
177 activate : function () {
178 imports.GitMonitor.GitMonitor.stop();
181 var tr = imports.Scm.Repo.Repo.list();
182 for (var i= 0; i< tr.length;i++) {
183 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
186 if (!repo.autocommit()) {
187 //??? should we ignore ones not on autocommit..
191 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
193 var str = repo.pull();
194 // do not care if it's already in sycn..
195 if (str.match(/Already up-to-date/)) {
198 var notification = new Notify.Notification({
199 summary: "Updated " + repo.name,
202 notification.set_timeout(20);
206 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
207 print(JSON.stringify(e));
208 print("notification or push errror- probably to many in queue..");
209 imports.gitlive.errorDialog(e.message);
213 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
218 imports.GitMonitor.GitMonitor.start();
224 this.el = XObject.isSeed ?
225 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_SAVE)
226 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_SAVE, null);
228 XObject.prototype.init.call(this);
230 label: 'Update Timesheet',
231 always_show_image : true,
237 activate : function () {
238 var ret = imports.FixBug.FixBug.show();
247 this.el = XObject.isSeed ?
248 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_FULLSCREEN)
249 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_FULLSCREEN, null);
250 XObject.prototype.init.call(this);
252 label: 'Manage Clones',
253 always_show_image : true,
259 activate : function () {
260 var ret = imports.Clones.Clones.show();
271 this.el = XObject.isSeed ?
272 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT)
273 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, null);
275 XObject.prototype.init.call(this);
277 label: 'About GitLive',
280 activate : function () {
281 var msg = new Gtk.AboutDialog({
282 program_name : "Git Live",
284 website: 'http://www.roojs.org/index.php/projects/gitlive.html',
285 website_label: 'RooJS Consulting',
288 msg.set_authors([ "Alan Knowles <alan@roojs.com>" ]);
298 this.el = XObject.isSeed ?
299 new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT)
300 : new Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, null);
302 XObject.prototype.init.call(this);
307 activate : function () {