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();
58 this.activate.connect( () =>{
60 //print(Array.prototype.slice.call(arguments).join(','));
62 //var menu = this.get('menu');
74 //Gtk.get_current_event_device ()
78 this.position_menu, 0,
79 Gtk.get_current_event_time()
85 //var a = new Gdk.Rectangle();
86 // needs direction=inout setting in gir to work (in bugzilla @present)
87 //this.el.get_geometry(g,a,null);
89 // should check to see if @ top or bottom I guess..
90 //menu.el.get_toplevel().move(a.x, a.y +a.height);
91 //menu.el.get_toplevel().move(10,10);
97 class MenuA : Gtk.Menu
99 public ImageMenuItem pause;
100 public ImageMenuItem resume;
104 this.pause = new ImageMenuItemA();
105 this.append(this.pause);
106 this.resume = new ImageMenuItemB();
107 this.append(this.resume);
108 this.append(new ImageMenuItemC());
109 this.append(new ImageMenuItemD());
110 this.append(new ImageMenuItemE());
111 this.append(new ImageMenuItemF());
112 this.append(new ImageMenuItemG());
119 class ImageMenuItemA : ImageMenuItem {
121 public ImageMenuItemA()
123 //this.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
125 var image = new Gtk.Image();
126 image.set_from_stock(Gtk.Stock.MEDIA_PAUSE,Gtk.IconSize.MENU );
127 this.set_image (image);
129 this.label= "Pause Commits";
130 this.always_show_image = true;
131 this.accel_group = null;
133 this.activate.connect( () => {
134 statusicon.paused = true;
135 GitMonitor.gitmonitor.stop();
137 // this.el.label = status ? 'Resume' : 'Pause';
138 statusicon.set_from_stock( Gtk.Stock.MEDIA_PAUSE );
147 class ImageMenuItemB : ImageMenuItem {
149 public ImageMenuItemB()
152 var image = new Gtk.Image();
153 image.set_from_stock(Gtk.Stock.MEDIA_PLAY,Gtk.IconSize.MENU );
154 this.set_image (image);
155 this.label= "Start Commits";
156 this.always_show_image = true;
157 this.accel_group = null;
159 this.activate.connect( () => {
160 GitMonitor.gitmonitor.start();
161 statusicon.paused = false;
164 // this.el.label = status ? 'Resume' : 'Pause';
165 statusicon.set_from_stock( Gtk.Stock.MEDIA_PLAY );
175 class ImageMenuItemC : ImageMenuItem {
177 public ImageMenuItemC()
180 var image = new Gtk.Image();
181 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
182 this.set_image (image);
183 this.label= "Pull (Refresh) All";
184 this.always_show_image = true;
185 this.accel_group = null;
187 this.activate.connect( () => {
188 GitMonitor.gitmonitor.stop();
189 var tr = GitRepo.list();
190 for (var i= 0; i< tr.length;i++) {
191 statusicon.set_from_stock( i%2 == 0 ? Gtk.Stock.FULLSCREEN : Gtk.Stock.LEAVE_FULLSCREEN );
193 var repo = tr.index(i);
194 //if (!repo.autocommit()) {
195 //??? should we ignore ones not on autocommit..
199 statusicon.set_tooltip_text("pull: " + repo.name);
200 var str = repo.pull();
201 // do not care if it's already in sycn..
202 if (Regex.match_simple ("Already up-to-date", str) ) {
205 var notification = new Notify.Notification(
206 "Updated " + repo.name,
212 notification.set_timeout(20);
216 print("notification or push errror- probably to many in queue..");
217 statusicon.set_from_stock( Gtk.Stock.MEDIA_RECORD );
223 statusicon.set_tooltip_text("Gitlive");
226 GitMonitor.gitmonitor.start();
235 class ImageMenuItemD : ImageMenuItem {
237 public ImageMenuItemD()
240 var image = new Gtk.Image();
241 image.set_from_stock(Gtk.Stock.SAVE,Gtk.IconSize.MENU );
242 this.set_image (image);
243 this.label= "Update Timesheet";
244 this.always_show_image = true;
245 this.accel_group = null;
247 this.activate.connect( () => {
248 //var ret = imports.FixBug.FixBug.show();
255 class ImageMenuItemE : ImageMenuItem {
257 public ImageMenuItemE()
260 var image = new Gtk.Image();
261 image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU );
262 this.set_image (image);
263 this.label= "Manage Clones";
264 this.always_show_image = true;
265 this.accel_group = null;
267 this.activate.connect( () => {
268 //var ret = imports.Clones.Clones.show();
275 class ImageMenuItemF : ImageMenuItem {
277 public ImageMenuItemF()
280 var image = new Gtk.Image();
281 image.set_from_stock(Gtk.Stock.ABOUT,Gtk.IconSize.MENU );
282 this.set_image (image);
283 this.label= "About Gitlive";
284 this.always_show_image = true;
285 this.accel_group = null;
287 this.activate.connect( () => {
288 //var ret = imports.Clones.Clones.show();
290 var msg = new Gtk.AboutDialog();
291 msg.program_name = "Git Live";
293 msg.website= "http://www.roojs.org/index.php/projects/gitlive.html";
294 msg.website_label= "Roo J Solutions Ltd.";
295 msg.license = "LGPL";
296 msg.authors = { "Alan Knowles <alan@roojs.com>" };
305 class ImageMenuItemG : ImageMenuItem {
307 public ImageMenuItemG()
310 var image = new Gtk.Image();
311 image.set_from_stock(Gtk.Stock.QUIT,Gtk.IconSize.MENU );
312 this.set_image (image);
314 this.always_show_image = true;
315 this.accel_group = null;
317 this.activate.connect( () => {
320 //var ret = imports.Clones.Clones.show();