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( ( button) =>{
62 //print(Array.prototype.slice.call(arguments).join(','));
63 print("menu activiate called\n");
64 //var menu = this.get('menu');
76 //Gtk.get_current_event_device ()
89 //var a = new Gdk.Rectangle();
90 // needs direction=inout setting in gir to work (in bugzilla @present)
91 //this.el.get_geometry(g,a,null);
93 // should check to see if @ top or bottom I guess..
94 //menu.el.get_toplevel().move(a.x, a.y +a.height);
95 //menu.el.get_toplevel().move(10,10);
101 class MenuA : Gtk.Menu
103 public ImageMenuItem pause;
104 public ImageMenuItem resume;
108 this.pause = new ImageMenuItemA();
109 this.append(this.pause);
110 this.resume = new ImageMenuItemB();
111 this.append(this.resume);
112 this.append(new ImageMenuItemC());
113 this.append(new ImageMenuItemD());
114 this.append(new ImageMenuItemE());
115 this.append(new ImageMenuItemF());
116 this.append(new ImageMenuItemG());
123 class ImageMenuItemA : ImageMenuItem {
125 public ImageMenuItemA()
127 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
129 var image = new Gtk.Image();
130 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
131 this.set_image (image);
133 this.label= "Pause Commits";
134 this.always_show_image = true;
135 this.accel_group = null;
137 this.activate.connect( () => {
138 statusicon.paused = true;
139 GitMonitor.gitmonitor.stop();
141 // this.el.label = status ? 'Resume' : 'Pause';
142 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
151 class ImageMenuItemB : ImageMenuItem {
153 public ImageMenuItemB()
156 var image = new Gtk.Image();
157 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
158 this.set_image (image);
159 this.label= "Start Commits";
160 this.always_show_image = true;
161 this.accel_group = null;
163 this.activate.connect( () => {
164 GitMonitor.gitmonitor.start();
165 statusicon.paused = false;
168 // this.el.label = status ? 'Resume' : 'Pause';
169 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
179 class ImageMenuItemC : ImageMenuItem {
181 public ImageMenuItemC()
184 var image = new Gtk.Image();
185 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
186 this.set_image (image);
187 this.label= "Pull (Refresh) All";
188 this.always_show_image = true;
189 this.accel_group = null;
191 this.activate.connect( () => {
192 GitMonitor.gitmonitor.stop();
193 var tr = GitRepo.list();
194 for (var i= 0; i< tr.length;i++) {
195 statusicon.set_from_stock( i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
197 var repo = tr.index(i);
198 //if (!repo.autocommit()) {
199 //??? should we ignore ones not on autocommit..
203 statusicon.set_tooltip_text("pull: " + repo.name);
204 var str = repo.pull();
205 // do not care if it's already in sycn..
206 if (Regex.match_simple ("Already up-to-date", str) ) {
209 var notification = new Notify.Notification(
210 "Updated " + repo.name,
216 notification.set_timeout(20);
220 print("notification or push errror- probably to many in queue..");
221 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
227 statusicon.set_tooltip_text("Gitlive");
230 GitMonitor.gitmonitor.start();
239 class ImageMenuItemD : ImageMenuItem {
241 public ImageMenuItemD()
244 var image = new Gtk.Image();
245 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
246 this.set_image (image);
247 this.label= "Update Timesheet";
248 this.always_show_image = true;
249 this.accel_group = null;
251 this.activate.connect( () => {
252 //var ret = imports.FixBug.FixBug.show();
259 class ImageMenuItemE : ImageMenuItem {
261 public ImageMenuItemE()
264 var image = new Gtk.Image();
265 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
266 this.set_image (image);
267 this.label= "Manage Clones";
268 this.always_show_image = true;
269 this.accel_group = null;
271 this.activate.connect( () => {
272 //var ret = imports.Clones.Clones.show();
279 class ImageMenuItemF : ImageMenuItem {
281 public ImageMenuItemF()
284 var image = new Gtk.Image();
285 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
286 this.set_image (image);
287 this.label= "About Gitlive";
288 this.always_show_image = true;
289 this.accel_group = null;
291 this.activate.connect( () => {
292 //var ret = imports.Clones.Clones.show();
294 var msg = new Gtk.AboutDialog();
295 msg.program_name = "Git Live";
297 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
298 msg.website_label= "Roo J Solutions Ltd.";
299 msg.license = "LGPL";
300 msg.authors = { "Alan Knowles <alan@roojs.com>" };
309 class ImageMenuItemG : ImageMenuItem {
311 public ImageMenuItemG()
314 var image = new Gtk.Image();
315 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
316 this.set_image (image);
318 this.always_show_image = true;
319 this.accel_group = null;
321 this.activate.connect( () => {
324 //var ret = imports.Clones.Clones.show();