1 //<script type="text/javascript">
5 * Status icon and menu for component of gitlive.
7 * Implements XObject - however we want to control initialization.
11 * Currently only does a few things
17 var Gtk = imports.gi.Gtk;
18 var Gdk = imports.gi.Gdk;
19 var Gio = imports.gi.Gio;
20 var GLib = imports.gi.GLib;
21 var Notify = imports.gi.Notify;
23 var Git = imports.Git;
24 var XObject = imports.XObject.XObject;
26 //var gitlive = imports.gitlive;
29 var StatusIcon = new XObject({
31 paused : false, // on!
32 xtype : Gtk.StatusIcon,
33 stock : Gtk.STOCK_MEDIA_PLAY,
34 tooltip_text : 'GitLive',
36 //'popup-menu' : function( w, event, event_time) {
37 'activate' : function( w, event, event_time) {
38 print(Array.prototype.slice.call(arguments).join(','));
40 menu = this.get('menu');
44 this.get(!this.paused ? 'resume' : 'pause' ).el.hide();
46 menu.el.popup(null, null,Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time());
47 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
52 var a = new Gdk.Rectangle();
53 // needs direction=inout setting in gir to work (in bugzilla @present)
54 this.el.get_geometry(g,a,null);
56 // should check to see if @ top or bottom I guess..
57 menu.el.get_toplevel().move(a.x, a.y +a.height);
69 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE);
70 XObject.prototype.init.call(this);
72 label: 'Pause Commits',
74 always_show_image : true,
80 activate : function () {
81 this.parent.parent.paused = true;
82 imports.gitlive.monitor.stop();
83 // this.el.label = status ? 'Resume' : 'Pause';
84 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
92 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY);
93 XObject.prototype.init.call(this);
95 label: 'Resume Commits',
96 always_show_image : true,
102 activate : function () {
103 this.parent.parent.paused = false;
104 imports.gitlive.monitor.start();
105 //var status = this.el.label == 'Pause' ? 1 : 0
106 // this.el.label = status ? 'Resume' : 'Pause';
107 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PLAY);
115 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
116 XObject.prototype.init.call(this);
118 label: 'Pull (Refresh) All',
119 always_show_image : true,
124 activate : function () {
125 imports.gitlive.monitor.stop();
127 var f = Gio.file_new_for_path(imports.gitlive.gitlive);
128 var file_enum = f.enumerate_children(
129 Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null);
131 var next_file = null;
133 while ((next_file = file_enum.next_file(null)) != null) {
135 var fn = imports.gitlive.gitlive + '/' + next_file.get_display_name();
136 if (! GLib.file_test(fn + '/.git', GLib.FileTest.IS_DIR)) {
141 var res = Git.run(fn, 'pull' );
142 if (res.result * 1 == 0) {
144 var notification = new Notify.Notification({
145 summary: "Updated " + fn,
148 notification.set_timeout(1000);
152 imports.gitlive.errorDialog(res.stderr);
153 // should also update modules ideally.
158 file_enum.close(null);
161 imports.gitlive.monitor.start();
168 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
169 XObject.prototype.init.call(this);
171 label: 'Manage Clones',
172 always_show_image : true,
178 activate : function () {
190 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT);
191 XObject.prototype.init.call(this);
193 label: 'About GitLive',
196 activate : function () {
197 var msg = new Gtk.AboutDialog({
198 program_name : "Git Live",
200 website: 'http://git.akbkhome.com',
201 website_label: 'AK BK Consulting (git repo)',
204 msg.set_authors([ "Alan Knowles <alan@akbkhome.com>" ]);
213 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT);
214 XObject.prototype.init.call(this);
219 activate : function () {