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 );
108 this.error_animate= false;
113 this.set_from_stock( Gtk.Stock.REFRESH );
117 this.error_animate = true;
119 Timeout.add_full(Priority.LOW, 500, () => {
121 if (!this.error_animate) {
124 this.set_from_stock( flag == true ? Gtk.Stock.MEDIA_RECORD
125 : Gtk.Stock.MEDIA_PAUSE);
132 class MenuA : Gtk.Menu
134 public ImageMenuItem pause;
135 public ImageMenuItem resume;
139 this.pause = new ImageMenuItemA();
140 this.append(this.pause);
141 this.resume = new ImageMenuItemB();
142 this.append(this.resume);
143 this.append(new ImageMenuItemC());
144 this.append(new ImageMenuItemD());
145 this.append(new ImageMenuItemE());
146 this.append(new ImageMenuItemF());
147 this.append(new ImageMenuItemG());
154 class ImageMenuItemA : ImageMenuItem {
156 public ImageMenuItemA()
158 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
160 var image = new Gtk.Image();
161 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
162 this.set_image (image);
164 this.label= "Pause Commits";
165 this.always_show_image = true;
166 this.accel_group = null;
168 this.activate.connect( () => {
169 statusicon.paused = true;
170 GitMonitor.gitmonitor.stop();
172 // this.el.label = status ? 'Resume' : 'Pause';
173 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
182 class ImageMenuItemB : ImageMenuItem {
184 public ImageMenuItemB()
187 var image = new Gtk.Image();
188 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
189 this.set_image (image);
190 this.label= "Start Commits";
191 this.always_show_image = true;
192 this.accel_group = null;
194 this.activate.connect( () => {
195 GitMonitor.gitmonitor.start();
196 statusicon.paused = false;
199 // this.el.label = status ? 'Resume' : 'Pause';
200 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
210 class ImageMenuItemC : ImageMenuItem {
212 public ImageMenuItemC()
215 var image = new Gtk.Image();
216 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
217 this.set_image (image);
218 this.label= "Pull (Refresh) All";
219 this.always_show_image = true;
220 this.accel_group = null;
222 this.activate.connect( () => {
223 GitMonitor.gitmonitor.stop();
224 var tr = GitRepo.list();
225 for (var i= 0; i< tr.length;i++) {
226 statusicon.set_from_stock(
227 i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
229 var repo = tr.index(i);
230 //if (!repo.autocommit()) {
231 //??? should we ignore ones not on autocommit..
235 statusicon.set_tooltip_text("pull: " + repo.name);
236 var str = repo.pull();
237 // do not care if it's already in sycn..
238 if (Regex.match_simple ("Already up-to-date", str) ) {
241 var notification = new Notify.Notification(
242 "Updated " + repo.name,
248 notification.set_timeout(20);
252 print("notification or push errror- probably to many in queue..");
253 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
259 statusicon.set_tooltip_text("Gitlive");
262 GitMonitor.gitmonitor.start();
271 class ImageMenuItemD : ImageMenuItem {
273 public ImageMenuItemD()
276 var image = new Gtk.Image();
277 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
278 this.set_image (image);
279 this.label= "Update Timesheet";
280 this.always_show_image = true;
281 this.accel_group = null;
283 this.activate.connect( () => {
284 //var ret = imports.FixBug.FixBug.show();
291 class ImageMenuItemE : ImageMenuItem {
293 public ImageMenuItemE()
296 var image = new Gtk.Image();
297 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
298 this.set_image (image);
299 this.label= "Manage Clones";
300 this.always_show_image = true;
301 this.accel_group = null;
303 this.activate.connect( () => {
304 //var ret = imports.Clones.Clones.show();
311 class ImageMenuItemF : ImageMenuItem {
313 public ImageMenuItemF()
316 var image = new Gtk.Image();
317 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
318 this.set_image (image);
319 this.label= "About Gitlive";
320 this.always_show_image = true;
321 this.accel_group = null;
323 this.activate.connect( () => {
324 //var ret = imports.Clones.Clones.show();
326 var msg = new Gtk.AboutDialog();
327 msg.program_name = "Git Live";
329 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
330 msg.website_label= "Roo J Solutions Ltd.";
331 msg.license = "LGPL";
332 msg.authors = { "Alan Knowles <alan@roojs.com>" };
341 class ImageMenuItemG : ImageMenuItem {
343 public ImageMenuItemG()
346 var image = new Gtk.Image();
347 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
348 this.set_image (image);
350 this.always_show_image = true;
351 this.accel_group = null;
353 this.activate.connect( () => {
356 //var ret = imports.Clones.Clones.show();