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();
125 var f = Gio.file_new_for_path(gitlive.gitlive);
126 var file_enum = f.enumerate_children(
127 Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null);
129 var next_file = null;
132 while ((next_file = file_enum.next_file(null)) != null) {
134 var fn = next_file.get_path();
135 if (! GLib.file_test(fn + '/.git', GLib.FileTest.IS_DIR)) {
140 var res = Git.run(fn, [ 'pull' ]);
141 var notification = new Notify.Notification({
142 summary: "Updated " + fn,
145 // should also update modules ideally.
147 err.push(new String(e));
151 gitlive.errordialog(e.join("\n"));
155 file_enum.close(null);
158 gitlive.monitor.start();
165 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_RELOAD);
166 XObject.prototype.init.call(this);
168 label: 'Manage Clones',
169 always_show_image : true,
175 activate : function () {
187 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_ABOUT);
188 XObject.prototype.init.call(this);
190 label: 'About GitLive',
193 activate : function () {
194 var msg = new Gtk.MessageDialog({message_type:
195 Gtk.MessageType.INFO, buttons : Gtk.ButtonsType.OK, text: "GIT Live - auto commits and pushes everything in ~/gitlive"});
204 this.el = new Gtk.ImageMenuItem.from_stock(Gtk.STOCK_QUIT);
205 XObject.prototype.init.call(this);
210 activate : function () {