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 );
107 this.set_from_stock( Gtk.Stock.MEDIA_PLAY );
112 this.set_from_stock( Gtk.Stock.REFRESH );
116 class MenuA : Gtk.Menu
118 public ImageMenuItem pause;
119 public ImageMenuItem resume;
123 this.pause = new ImageMenuItemA();
124 this.append(this.pause);
125 this.resume = new ImageMenuItemB();
126 this.append(this.resume);
127 this.append(new ImageMenuItemC());
128 this.append(new ImageMenuItemD());
129 this.append(new ImageMenuItemE());
130 this.append(new ImageMenuItemF());
131 this.append(new ImageMenuItemG());
138 class ImageMenuItemA : ImageMenuItem {
140 public ImageMenuItemA()
142 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
144 var image = new Gtk.Image();
145 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
146 this.set_image (image);
148 this.label= "Pause Commits";
149 this.always_show_image = true;
150 this.accel_group = null;
152 this.activate.connect( () => {
153 statusicon.paused = true;
154 GitMonitor.gitmonitor.stop();
156 // this.el.label = status ? 'Resume' : 'Pause';
157 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
166 class ImageMenuItemB : ImageMenuItem {
168 public ImageMenuItemB()
171 var image = new Gtk.Image();
172 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
173 this.set_image (image);
174 this.label= "Start Commits";
175 this.always_show_image = true;
176 this.accel_group = null;
178 this.activate.connect( () => {
179 GitMonitor.gitmonitor.start();
180 statusicon.paused = false;
183 // this.el.label = status ? 'Resume' : 'Pause';
184 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
194 class ImageMenuItemC : ImageMenuItem {
196 public ImageMenuItemC()
199 var image = new Gtk.Image();
200 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
201 this.set_image (image);
202 this.label= "Pull (Refresh) All";
203 this.always_show_image = true;
204 this.accel_group = null;
206 this.activate.connect( () => {
207 GitMonitor.gitmonitor.stop();
208 var tr = GitRepo.list();
209 for (var i= 0; i< tr.length;i++) {
210 statusicon.set_from_stock( i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
212 var repo = tr.index(i);
213 //if (!repo.autocommit()) {
214 //??? should we ignore ones not on autocommit..
218 statusicon.set_tooltip_text("pull: " + repo.name);
219 var str = repo.pull();
220 // do not care if it's already in sycn..
221 if (Regex.match_simple ("Already up-to-date", str) ) {
224 var notification = new Notify.Notification(
225 "Updated " + repo.name,
231 notification.set_timeout(20);
235 print("notification or push errror- probably to many in queue..");
236 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
242 statusicon.set_tooltip_text("Gitlive");
245 GitMonitor.gitmonitor.start();
254 class ImageMenuItemD : ImageMenuItem {
256 public ImageMenuItemD()
259 var image = new Gtk.Image();
260 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
261 this.set_image (image);
262 this.label= "Update Timesheet";
263 this.always_show_image = true;
264 this.accel_group = null;
266 this.activate.connect( () => {
267 //var ret = imports.FixBug.FixBug.show();
274 class ImageMenuItemE : ImageMenuItem {
276 public ImageMenuItemE()
279 var image = new Gtk.Image();
280 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
281 this.set_image (image);
282 this.label= "Manage Clones";
283 this.always_show_image = true;
284 this.accel_group = null;
286 this.activate.connect( () => {
287 //var ret = imports.Clones.Clones.show();
294 class ImageMenuItemF : ImageMenuItem {
296 public ImageMenuItemF()
299 var image = new Gtk.Image();
300 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
301 this.set_image (image);
302 this.label= "About Gitlive";
303 this.always_show_image = true;
304 this.accel_group = null;
306 this.activate.connect( () => {
307 //var ret = imports.Clones.Clones.show();
309 var msg = new Gtk.AboutDialog();
310 msg.program_name = "Git Live";
312 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
313 msg.website_label= "Roo J Solutions Ltd.";
314 msg.license = "LGPL";
315 msg.authors = { "Alan Knowles <alan@roojs.com>" };
324 class ImageMenuItemG : ImageMenuItem {
326 public ImageMenuItemG()
329 var image = new Gtk.Image();
330 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
331 this.set_image (image);
333 this.always_show_image = true;
334 this.accel_group = null;
336 this.activate.connect( () => {
339 //var ret = imports.Clones.Clones.show();