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 );
111 class MenuA : Gtk.Menu
113 public ImageMenuItem pause;
114 public ImageMenuItem resume;
118 this.pause = new ImageMenuItemA();
119 this.append(this.pause);
120 this.resume = new ImageMenuItemB();
121 this.append(this.resume);
122 this.append(new ImageMenuItemC());
123 this.append(new ImageMenuItemD());
124 this.append(new ImageMenuItemE());
125 this.append(new ImageMenuItemF());
126 this.append(new ImageMenuItemG());
133 class ImageMenuItemA : ImageMenuItem {
135 public ImageMenuItemA()
137 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
139 var image = new Gtk.Image();
140 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
141 this.set_image (image);
143 this.label= "Pause Commits";
144 this.always_show_image = true;
145 this.accel_group = null;
147 this.activate.connect( () => {
148 statusicon.paused = true;
149 GitMonitor.gitmonitor.stop();
151 // this.el.label = status ? 'Resume' : 'Pause';
152 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
161 class ImageMenuItemB : ImageMenuItem {
163 public ImageMenuItemB()
166 var image = new Gtk.Image();
167 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
168 this.set_image (image);
169 this.label= "Start Commits";
170 this.always_show_image = true;
171 this.accel_group = null;
173 this.activate.connect( () => {
174 GitMonitor.gitmonitor.start();
175 statusicon.paused = false;
178 // this.el.label = status ? 'Resume' : 'Pause';
179 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
189 class ImageMenuItemC : ImageMenuItem {
191 public ImageMenuItemC()
194 var image = new Gtk.Image();
195 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
196 this.set_image (image);
197 this.label= "Pull (Refresh) All";
198 this.always_show_image = true;
199 this.accel_group = null;
201 this.activate.connect( () => {
202 GitMonitor.gitmonitor.stop();
203 var tr = GitRepo.list();
204 for (var i= 0; i< tr.length;i++) {
205 statusicon.set_from_stock( i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
207 var repo = tr.index(i);
208 //if (!repo.autocommit()) {
209 //??? should we ignore ones not on autocommit..
213 statusicon.set_tooltip_text("pull: " + repo.name);
214 var str = repo.pull();
215 // do not care if it's already in sycn..
216 if (Regex.match_simple ("Already up-to-date", str) ) {
219 var notification = new Notify.Notification(
220 "Updated " + repo.name,
226 notification.set_timeout(20);
230 print("notification or push errror- probably to many in queue..");
231 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
237 statusicon.set_tooltip_text("Gitlive");
240 GitMonitor.gitmonitor.start();
249 class ImageMenuItemD : ImageMenuItem {
251 public ImageMenuItemD()
254 var image = new Gtk.Image();
255 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
256 this.set_image (image);
257 this.label= "Update Timesheet";
258 this.always_show_image = true;
259 this.accel_group = null;
261 this.activate.connect( () => {
262 //var ret = imports.FixBug.FixBug.show();
269 class ImageMenuItemE : ImageMenuItem {
271 public ImageMenuItemE()
274 var image = new Gtk.Image();
275 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
276 this.set_image (image);
277 this.label= "Manage Clones";
278 this.always_show_image = true;
279 this.accel_group = null;
281 this.activate.connect( () => {
282 //var ret = imports.Clones.Clones.show();
289 class ImageMenuItemF : ImageMenuItem {
291 public ImageMenuItemF()
294 var image = new Gtk.Image();
295 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
296 this.set_image (image);
297 this.label= "About Gitlive";
298 this.always_show_image = true;
299 this.accel_group = null;
301 this.activate.connect( () => {
302 //var ret = imports.Clones.Clones.show();
304 var msg = new Gtk.AboutDialog();
305 msg.program_name = "Git Live";
307 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
308 msg.website_label= "Roo J Solutions Ltd.";
309 msg.license = "LGPL";
310 msg.authors = { "Alan Knowles <alan@roojs.com>" };
319 class ImageMenuItemG : ImageMenuItem {
321 public ImageMenuItemG()
324 var image = new Gtk.Image();
325 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
326 this.set_image (image);
328 this.always_show_image = true;
329 this.accel_group = null;
331 this.activate.connect( () => {
334 //var ret = imports.Clones.Clones.show();