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 {
40 public bool paused = false;
41 public static StatusIconA statusicon;
43 public StatusIconA() {
48 this.stock = Gtk.Stock.REFRESH;
49 this.tooltip_text = "GitLive";
50 this.title = "gitlive";
52 this.set_name("gitlive");
53 this.set_visible(true);
55 var menu = new MenuA();
59 this.popup_menu.connect( ( button, time) =>{
60 //this.button_press_event.connect( ( ) =>{
62 //print(Array.prototype.slice.call(arguments).join(','));
63 print("menu activiate called\n");
64 //var menu = this.get('menu');
75 // public void popup (Gtk.Widget? parent_menu_shell, Gtk.Widget? parent_menu_item,
76 // [CCode (scope = "async")] Gtk.MenuPositionFunc? func, uint button, uint32 activate_time);
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);
103 this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
109 this.set_from_stock( Gtk.Stock.MEDIA_PLAY );
113 public void refreshing()
115 this.set_from_stock( Gtk.Stock.REFRESH );
118 public void pauseError()
122 Timeout.add_full(Priority.LOW, 500, () => {
127 this.set_from_stock( flag == true ? Gtk.Stock.MEDIA_RECORD
128 : Gtk.Stock.MEDIA_PAUSE);
135 class MenuA : Gtk.Menu
137 public ImageMenuItem pause;
138 public ImageMenuItem resume;
142 this.pause = new ImageMenuItemA();
143 this.append(this.pause);
144 this.resume = new ImageMenuItemB();
145 this.append(this.resume);
146 this.append(new ImageMenuItemC());
147 this.append(new ImageMenuItemD());
148 this.append(new ImageMenuItemE());
149 this.append(new ImageMenuItemF());
150 this.append(new ImageMenuItemG());
157 class ImageMenuItemA : ImageMenuItem {
159 public ImageMenuItemA()
161 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
163 var image = new Gtk.Image();
164 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
165 this.set_image (image);
167 this.label= "Pause Commits";
168 this.always_show_image = true;
169 this.accel_group = null;
171 this.activate.connect( () => {
172 statusicon.paused = true;
173 GitMonitor.gitmonitor.stop();
175 // this.el.label = status ? 'Resume' : 'Pause';
176 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
185 class ImageMenuItemB : ImageMenuItem {
187 public ImageMenuItemB()
190 var image = new Gtk.Image();
191 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
192 this.set_image (image);
193 this.label= "Start Commits";
194 this.always_show_image = true;
195 this.accel_group = null;
197 this.activate.connect( () => {
198 GitMonitor.gitmonitor.start();
199 statusicon.paused = false;
202 // this.el.label = status ? 'Resume' : 'Pause';
203 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
213 class ImageMenuItemC : ImageMenuItem {
215 public ImageMenuItemC()
218 var image = new Gtk.Image();
219 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
220 this.set_image (image);
221 this.label= "Pull (Refresh) All";
222 this.always_show_image = true;
223 this.accel_group = null;
225 this.activate.connect( () => {
226 GitMonitor.gitmonitor.stop();
227 var tr = GitRepo.list();
228 for (var i= 0; i< tr.length;i++) {
229 statusicon.set_from_stock(
230 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
232 var repo = tr.index(i);
233 //if (!repo.autocommit()) {
234 //??? should we ignore ones not on autocommit..
238 statusicon.set_tooltip_text("pull: " + repo.name);
239 var str = repo.pull();
240 // do not care if it's already in sycn..
241 if (Regex.match_simple ("Already up-to-date", str) ) {
244 var notification = new Notify.Notification(
245 "Updated " + repo.name,
251 notification.set_timeout(20);
255 print("notification or push errror- probably to many in queue..");
256 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
262 statusicon.set_tooltip_text("Gitlive");
265 GitMonitor.gitmonitor.start();
274 class ImageMenuItemD : ImageMenuItem {
276 public ImageMenuItemD()
279 var image = new Gtk.Image();
280 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
281 this.set_image (image);
282 this.label= "Update Timesheet";
283 this.always_show_image = true;
284 this.accel_group = null;
286 this.activate.connect( () => {
287 //var ret = imports.FixBug.FixBug.show();
294 class ImageMenuItemE : ImageMenuItem {
296 public ImageMenuItemE()
299 var image = new Gtk.Image();
300 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
301 this.set_image (image);
302 this.label= "Manage Clones";
303 this.always_show_image = true;
304 this.accel_group = null;
306 this.activate.connect( () => {
307 //var ret = imports.Clones.Clones.show();
314 class ImageMenuItemF : ImageMenuItem {
316 public ImageMenuItemF()
319 var image = new Gtk.Image();
320 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
321 this.set_image (image);
322 this.label= "About Gitlive";
323 this.always_show_image = true;
324 this.accel_group = null;
326 this.activate.connect( () => {
327 //var ret = imports.Clones.Clones.show();
329 var msg = new Gtk.AboutDialog();
330 msg.program_name = "Git Live";
332 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
333 msg.website_label= "Roo J Solutions Ltd.";
334 msg.license = "LGPL";
335 msg.authors = { "Alan Knowles <alan@roojs.com>" };
344 class ImageMenuItemG : ImageMenuItem {
346 public ImageMenuItemG()
349 var image = new Gtk.Image();
350 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
351 this.set_image (image);
353 this.always_show_image = true;
354 this.accel_group = null;
356 this.activate.connect( () => {
359 //var ret = imports.Clones.Clones.show();