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
20 GLib = imports.gi.GLib;
21 Notify = imports.gi.Notify;
24 XObject = imports.XObject.XObject
25 gitlive = imports.gitlive;
28 StatusIcon = new XObject({
30 paused : false, // on!
31 xtype : Gtk.StatusIcon,
32 stock : Gtk.STOCK_MEDIA_PLAY,
33 tooltip_text : 'GitLive',
35 //'popup-menu' : function( w, event, event_time) {
36 'activate' : function( w, event, event_time) {
37 print(Array.prototype.slice.call(arguments).join(','));
39 menu = this.get('menu');
43 this.get(!this.paused ? 'resume' : 'pause' ).el.hide();
45 menu.el.popup(null, null,Gtk.StatusIcon.position_menu , this.el , 1, Gtk.get_current_event_time());
46 //menu.el.popup(null, null,null, null, 1, Gtk.get_current_event_time());
51 var a = new Gdk.Rectangle();
52 // needs direction=inout setting in gir to work (in bugzilla @present)
53 this.el.get_geometry(g,a,null);
55 // should check to see if @ top or bottom I guess..
56 menu.el.get_toplevel().move(a.x, a.y +a.height);
68 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PAUSE);
69 XObject.prototype.init.call(this);
71 label: 'Pause Commits',
73 always_show_image : true,
79 activate : function () {
80 this.parent.parent.paused = true;
81 gitlive.monitor.stop();
82 // this.el.label = status ? 'Resume' : 'Pause';
83 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PAUSE );
91 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_MEDIA_PLAY);
92 XObject.prototype.init.call(this);
94 label: 'Resume Commits',
95 always_show_image : true,
101 activate : function () {
102 this.parent.parent.paused = false;
103 gitlive.monitor.start();
104 //var status = this.el.label == 'Pause' ? 1 : 0
105 // this.el.label = status ? 'Resume' : 'Pause';
106 this.parent.parent.el.set_from_stock( Gtk.STOCK_MEDIA_PLAY);
114 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
115 XObject.prototype.init.call(this);
117 label: 'Pull (Refresh) All',
118 always_show_image : true,
123 activate : function () {
124 gitlive.monitor.stop();
126 var f = Gio.file_new_for_path(gitlive.gitlive);
127 var file_enum = f.enumerate_children(
128 Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null);
130 var next_file = null;
133 while ((next_file = file_enum.next_file(null)) != null) {
135 var fn = 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 var notification = new Notify.Notification({
143 summary: "Updated " + fn,
146 notification.set_timeout(500);
148 // should also update modules ideally.
150 err.push(e.toString());
154 gitlive.errorDialog(err.join("\n"));
158 file_enum.close(null);
161 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" ]);
213 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT);
214 XObject.prototype.init.call(this);
219 activate : function () {