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 {
42 public StatusIconA() {
47 this.stock = Gtk.Stock.REFRESH;
48 this.tooltip_text = "GitLive";
49 this.title = "vgitlive";
51 this.set_name("vgitlive");
52 this.set_visible(true);
54 var menu = new MenuA();
57 this.activate.connect( () =>{
59 //print(Array.prototype.slice.call(arguments).join(','));
61 //var menu = this.get('menu');
73 //Gtk.get_current_event_device ()
77 this.position_menu, 0,
78 Gtk.get_current_event_time()
84 //var a = new Gdk.Rectangle();
85 // needs direction=inout setting in gir to work (in bugzilla @present)
86 //this.el.get_geometry(g,a,null);
88 // should check to see if @ top or bottom I guess..
89 //menu.el.get_toplevel().move(a.x, a.y +a.height);
90 //menu.el.get_toplevel().move(10,10);
96 class MenuA : Gtk.Menu
98 public ImageMenuItem pause;
99 public ImageMenuItem resume;
103 this.pause = new ImageMenuItemA();
104 this.append(this.pause);
105 this.resume = new ImageMenuItemB();
106 this.append(this.resume);
107 this.append(new ImageMenuItemC());
108 this.append(new ImageMenuItemD());
109 this.append(new ImageMenuItemE());
110 this.append(new ImageMenuItemF());
111 this.append(new ImageMenuItemG());
118 class ImageMenuItemA : ImageMenuItem {
120 public ImageMenuItemA()
122 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
124 var image = new Gtk.Image();
125 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
126 this.set_image (image);
128 this.label= "Pause Commits";
129 this.always_show_image = true;
130 this.accel_group = null;
132 this.activate.connect( () => {
133 statusicon.paused = true;
135 //GitMonitor.GitMonitor.stop();
136 // this.el.label = status ? 'Resume' : 'Pause';
137 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
146 class ImageMenuItemB : ImageMenuItem {
148 public ImageMenuItemB()
151 var image = new Gtk.Image();
152 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
153 this.set_image (image);
154 this.label= "Start Commits";
155 this.always_show_image = true;
156 this.accel_group = null;
158 this.activate.connect( () => {
159 //GitMonitor.GitMonitor.start();
160 statusicon.paused = false;
163 // this.el.label = status ? 'Resume' : 'Pause';
164 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
173 class ImageMenuItemC : ImageMenuItem {
175 public ImageMenuItemC()
178 var image = new Gtk.Image();
179 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
180 this.set_image (image);
181 this.label= "Pull (Refresh) All";
182 this.always_show_image = true;
183 this.accel_group = null;
185 this.activate.connect( () => {
187 imports.GitMonitor.GitMonitor.stop();
190 var tr = imports.Scm.Repo.Repo.list();
191 for (var i= 0; i< tr.length;i++) {
192 this.parent.parent.el.set_from_stock( i%2 ? Gtk.STOCK_FULLSCREEN : Gtk.STOCK_LEAVE_FULLSCREEN );
195 if (!repo.autocommit()) {
196 //??? should we ignore ones not on autocommit..
200 this.parent.parent.el.set_tooltip_text("pull: " + repo.name);
202 var str = repo.pull();
203 // do not care if it's already in sycn..
204 if (str.match(/Already up-to-date/)) {
207 var notification = new Notify.Notification({
208 summary: "Updated " + repo.name,
211 notification.set_timeout(20);
215 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_RECORD );
216 print(JSON.stringify(e));
217 print("notification or push errror- probably to many in queue..");
218 imports.gitlive.errorDialog(e.message);
222 this.parent.parent.el.set_tooltip_text(this.parent.parent.tooltip_text);
227 imports.GitMonitor.GitMonitor.start();
237 class ImageMenuItemD : ImageMenuItem {
239 public ImageMenuItemD()
242 var image = new Gtk.Image();
243 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
244 this.set_image (image);
245 this.label= "Update Timesheet";
246 this.always_show_image = true;
247 this.accel_group = null;
249 this.activate.connect( () => {
250 //var ret = imports.FixBug.FixBug.show();
257 class ImageMenuItemE : ImageMenuItem {
259 public ImageMenuItemE()
262 var image = new Gtk.Image();
263 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
264 this.set_image (image);
265 this.label= "Manage Clones";
266 this.always_show_image = true;
267 this.accel_group = null;
269 this.activate.connect( () => {
270 //var ret = imports.Clones.Clones.show();
277 class ImageMenuItemF : ImageMenuItem {
279 public ImageMenuItemF()
282 var image = new Gtk.Image();
283 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
284 this.set_image (image);
285 this.label= "About Gitlive";
286 this.always_show_image = true;
287 this.accel_group = null;
289 this.activate.connect( () => {
290 //var ret = imports.Clones.Clones.show();
292 var msg = new Gtk.AboutDialog();
293 msg.program_name = "Git Live";
295 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
296 msg.website_label= "Roo J Solutions Ltd.";
297 msg.license = "LGPL";
298 msg.authors = { "Alan Knowles <alan@roojs.com>" };
307 class ImageMenuItemG : ImageMenuItem {
309 public ImageMenuItemG()
312 var image = new Gtk.Image();
313 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
314 this.set_image (image);
316 this.always_show_image = true;
317 this.accel_group = null;
319 this.activate.connect( () => {
322 //var ret = imports.Clones.Clones.show();