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 = "vgitlive";
52 this.set_name("vgitlive");
53 this.set_visible(true);
55 var menu = new MenuA();
59 this.popup_menu.connect( ( button, time) =>{
61 //print(Array.prototype.slice.call(arguments).join(','));
62 print("menu activiate called\n");
63 //var menu = this.get('menu');
75 //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);
100 class MenuA : Gtk.Menu
102 public ImageMenuItem pause;
103 public ImageMenuItem resume;
107 this.pause = new ImageMenuItemA();
108 this.append(this.pause);
109 this.resume = new ImageMenuItemB();
110 this.append(this.resume);
111 this.append(new ImageMenuItemC());
112 this.append(new ImageMenuItemD());
113 this.append(new ImageMenuItemE());
114 this.append(new ImageMenuItemF());
115 this.append(new ImageMenuItemG());
122 class ImageMenuItemA : ImageMenuItem {
124 public ImageMenuItemA()
126 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
128 var image = new Gtk.Image();
129 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
130 this.set_image (image);
132 this.label= "Pause Commits";
133 this.always_show_image = true;
134 this.accel_group = null;
136 this.activate.connect( () => {
137 statusicon.paused = true;
138 GitMonitor.gitmonitor.stop();
140 // this.el.label = status ? 'Resume' : 'Pause';
141 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
150 class ImageMenuItemB : ImageMenuItem {
152 public ImageMenuItemB()
155 var image = new Gtk.Image();
156 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
157 this.set_image (image);
158 this.label= "Start Commits";
159 this.always_show_image = true;
160 this.accel_group = null;
162 this.activate.connect( () => {
163 GitMonitor.gitmonitor.start();
164 statusicon.paused = false;
167 // this.el.label = status ? 'Resume' : 'Pause';
168 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
178 class ImageMenuItemC : ImageMenuItem {
180 public ImageMenuItemC()
183 var image = new Gtk.Image();
184 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
185 this.set_image (image);
186 this.label= "Pull (Refresh) All";
187 this.always_show_image = true;
188 this.accel_group = null;
190 this.activate.connect( () => {
191 GitMonitor.gitmonitor.stop();
192 var tr = GitRepo.list();
193 for (var i= 0; i< tr.length;i++) {
194 statusicon.set_from_stock( i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
196 var repo = tr.index(i);
197 //if (!repo.autocommit()) {
198 //??? should we ignore ones not on autocommit..
202 statusicon.set_tooltip_text("pull: " + repo.name);
203 var str = repo.pull();
204 // do not care if it's already in sycn..
205 if (Regex.match_simple ("Already up-to-date", str) ) {
208 var notification = new Notify.Notification(
209 "Updated " + repo.name,
215 notification.set_timeout(20);
219 print("notification or push errror- probably to many in queue..");
220 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
226 statusicon.set_tooltip_text("Gitlive");
229 GitMonitor.gitmonitor.start();
238 class ImageMenuItemD : ImageMenuItem {
240 public ImageMenuItemD()
243 var image = new Gtk.Image();
244 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
245 this.set_image (image);
246 this.label= "Update Timesheet";
247 this.always_show_image = true;
248 this.accel_group = null;
250 this.activate.connect( () => {
251 //var ret = imports.FixBug.FixBug.show();
258 class ImageMenuItemE : ImageMenuItem {
260 public ImageMenuItemE()
263 var image = new Gtk.Image();
264 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
265 this.set_image (image);
266 this.label= "Manage Clones";
267 this.always_show_image = true;
268 this.accel_group = null;
270 this.activate.connect( () => {
271 //var ret = imports.Clones.Clones.show();
278 class ImageMenuItemF : ImageMenuItem {
280 public ImageMenuItemF()
283 var image = new Gtk.Image();
284 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
285 this.set_image (image);
286 this.label= "About Gitlive";
287 this.always_show_image = true;
288 this.accel_group = null;
290 this.activate.connect( () => {
291 //var ret = imports.Clones.Clones.show();
293 var msg = new Gtk.AboutDialog();
294 msg.program_name = "Git Live";
296 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
297 msg.website_label= "Roo J Solutions Ltd.";
298 msg.license = "LGPL";
299 msg.authors = { "Alan Knowles <alan@roojs.com>" };
308 class ImageMenuItemG : ImageMenuItem {
310 public ImageMenuItemG()
313 var image = new Gtk.Image();
314 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
315 this.set_image (image);
317 this.always_show_image = true;
318 this.accel_group = null;
320 this.activate.connect( () => {
323 //var ret = imports.Clones.Clones.show();