[hamster-applet] added gsettings schema file and swap-with-calendar boolean that is check on startup and either moves



commit 9823459bade088a6144ac2564d993f3fbaef5e48
Author: Toms BauÄis <toms baugis gmail com>
Date:   Sat Jul 9 12:06:30 2011 +0300

    added gsettings schema file and swap-with-calendar boolean that is check on startup and either moves the calendar to the right or places hamster on the right side

 data/hamster-applet.gschema.xml  |   10 ++++++++++
 src/shell_extension/extension.js |   17 ++++++++++++-----
 wscript                          |   10 +++++++++-
 3 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/data/hamster-applet.gschema.xml b/data/hamster-applet.gschema.xml
new file mode 100644
index 0000000..4fd23c1
--- /dev/null
+++ b/data/hamster-applet.gschema.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <schema id="org.gnome.hamster" path="/org/gnome/hamster/">
+    <key name="swap-with-calendar" type="b">
+      <default>false</default>
+      <summary>Placement</summary>
+      <description>When enabled, time tracker extension will occupy calendar's place and move calendar to the right</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/src/shell_extension/extension.js b/src/shell_extension/extension.js
index 64ad1ab..20b6ef5 100644
--- a/src/shell_extension/extension.js
+++ b/src/shell_extension/extension.js
@@ -15,6 +15,7 @@ const Lang = imports.lang;
 const St = imports.gi.St;
 const Shell = imports.gi.Shell;
 const Main = imports.ui.main;
+const Gio = imports.gi.Gio;
 const PopupMenu = imports.ui.popupMenu;
 const PanelMenu = imports.ui.panelMenu;
 const Util = imports.misc.util;
@@ -188,18 +189,24 @@ HamsterButton.prototype = {
 		PanelMenu.Button.prototype._init.call(this, 0.0);
 
 		this._proxy = new HamsterProxy(DBus.session, 'org.gnome.Hamster', '/org/gnome/Hamster');
-
 		this._proxy.connect('FactsChanged', Lang.bind(this, this.onFactsChanged));
 		this._proxy.connect('ActivitiesChanged', Lang.bind(this, this.onActivitiesChanged));
 		this._proxy.connect('TagsChanged', Lang.bind(this, this.onTagsChanged));
 
+
+
+		this._settings = new Gio.Settings({ schema: 'org.gnome.hamster' });
+
 		this.panel_label = new St.Label({ style_class: 'hamster-label', text: _("Loading...") });
 		this.actor.set_child(this.panel_label);
 
-		moveCalendar();
-
+		if (this._settings.get_boolean("swap-with-calendar")) {
+			moveCalendar();
+			Main.panel._centerBox.add(this.actor);
+		} else {
+			Main.panel._rightBox.add(this.actor);
+		}
 
-		Main.panel._centerBox.add(this.actor, { y_fill: true });
 
 		this.facts = null;
 		this.currentFact = null;
@@ -290,7 +297,7 @@ HamsterButton.prototype = {
 					text += "%02d:%02d".format(fact.endTime.getHours(), fact.endTime.getMinutes());
 				}
 				label.set_text(text)
-				activities.add(label, { row: i, col: 0});
+				activities.add(label, { row: i, col: 0, x_expand: false});
 
 				label = new St.Label({ style_class: 'cell-label'});
 				label.set_text(fact.name)
diff --git a/wscript b/wscript
index cba24a1..d512a12 100644
--- a/wscript
+++ b/wscript
@@ -5,6 +5,7 @@ top = '.'
 out = 'build'
 
 import intltool, gnome
+import os
 
 def configure(conf):
     conf.check_tool('python')
@@ -80,6 +81,9 @@ def build(bld):
     bld.install_files('${DATADIR}/gnome-shell/extensions/hamster gnome org',
                       'src/shell_extension/*')
 
+    # the gsettings schemas - TODO - use whatever default tools there are
+    bld.install_files('${DATADIR}/glib-2.0/schemas',
+                      'data/hamster-applet.gschema.xml')
 
     bld.new_task_gen("subst",
                      source= "org.gnome.hamster.service.in",
@@ -97,11 +101,15 @@ def build(bld):
         gnome.postinstall_schemas('hamster-applet') # Installing GConf schemas
         gnome.postinstall_icons() # Updating the icon cache
 
+        if bld.is_install:
+            print "Compiling schema"
+            ctx.exec_command("glib-compile-schemas '%s'" % os.path.join(ctx.env['DATADIR'], "glib-2.0", "schemas"))
+
+
     bld.add_post_fun(post)
 
 
 def copy_help(ctx):
-    import os
     os.system('cp -R build/default/help/ .')
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]