[hamster-applet/workspaces] saving workspace mapping in gconf and checking those instead of desktop name, when switching workspa
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet/workspaces] saving workspace mapping in gconf and checking those instead of desktop name, when switching workspa
- Date: Tue, 19 Jan 2010 12:36:02 +0000 (UTC)
commit f785053aea88e77f7c967347acba5c11ff14afae
Author: Toms Bauģis <toms baugis gmail com>
Date: Tue Jan 19 12:35:50 2010 +0000
saving workspace mapping in gconf and checking those instead of desktop name, when switching workspaces
data/preferences.ui | 89 ++++++++++++++++++++++-----------------------
hamster/applet.py | 6 +++-
hamster/configuration.py | 3 +-
hamster/preferences.py | 26 ++++++++++---
4 files changed, 71 insertions(+), 53 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index 61c0d05..1182a93 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -724,8 +724,8 @@
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
- <object class="GtkCheckButton" id="workspace_tracking_name">
- <property name="label" translatable="yes">Switch activities if workspace name matches an earlier activity</property>
+ <object class="GtkCheckButton" id="workspace_tracking_memory">
+ <property name="label" translatable="yes">Resume the last activity when returning to a workspace</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -733,17 +733,53 @@
<signal name="toggled" handler="on_workspace_tracking_toggled"/>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="workspace_tracking_memory">
- <property name="label" translatable="yes">Resume the last activity when returning to a workspace</property>
+ <object class="GtkVBox" id="vbox9">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_workspace_tracking_toggled"/>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="workspace_tracking_name">
+ <property name="label" translatable="yes">Start new activity when switching workspaces:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_workspace_tracking_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment12">
+ <property name="visible">True</property>
+ <property name="top_padding">5</property>
+ <property name="left_padding">24</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow5">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="workspace_list">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
@@ -765,46 +801,9 @@
</child>
</object>
<packing>
- <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkFrame" id="frame4">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow5">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="workspace_list">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label12">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">1</property>
- <property name="ypad">2</property>
- <property name="label" translatable="yes">_Workspace:</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="padding">2</property>
- <property name="position">1</property>
- </packing>
- </child>
</object>
</child>
</object>
diff --git a/hamster/applet.py b/hamster/applet.py
index 489fe7b..e1057ba 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -610,8 +610,12 @@ class HamsterApplet(object):
activity = None
if "name" in self.workspace_tracking:
# first try to look up activity by desktop name
+ mapping = conf.get("workspace_mapping")
+
+ parsed_activity = None
+ if new < len(mapping):
+ parsed_activity = stuff.parse_activity_input(mapping[new])
- parsed_activity = stuff.parse_activity_input(current_workspace.get_name())
if parsed_activity:
category_id = None
if parsed_activity.category_name:
diff --git a/hamster/configuration.py b/hamster/configuration.py
index 8e99349..8a786ed 100644
--- a/hamster/configuration.py
+++ b/hamster/configuration.py
@@ -198,7 +198,8 @@ class GConfStore(Singleton):
'keybinding' : "<Super>H", # Key binding to summon hamster
'overview_window_box' : [], # X, Y, W, H
'overview_window_maximized' : False, # Is overview window maximized
- 'workspace_tracking' : [], # Should hamster switch activities on workspace change 0,1,2
+ 'workspace_tracking' : [], # Should hamster switch activities on workspace change 0,1,2
+ 'workspace_mapping' : [], # Mapping between workspace numbers and activities
}
def __init__(self):
diff --git a/hamster/preferences.py b/hamster/preferences.py
index 6bee733..158a22a 100755
--- a/hamster/preferences.py
+++ b/hamster/preferences.py
@@ -192,7 +192,7 @@ class PreferencesEditor:
self.wActivityColumn.set_expand(True)
self.wActivityCell = gtk.CellRendererText()
self.wActivityCell.set_property('editable', True)
-# self.wActivityCell.connect('edited', self.category_edited_cb, self.category_store)
+ self.wActivityCell.connect('edited', self.on_workspace_activity_edited)
self.wNameColumn.pack_start(self.wNameCell, True)
self.wNameColumn.set_attributes(self.wNameCell)
@@ -231,11 +231,12 @@ class PreferencesEditor:
cell.set_property('text', str(name))
def on_workspace_created(self, screen, workspace, user_data=None):
- self.workspace_store.append([
- workspace.get_number(),
- workspace,
- u'Not implemented'
- ])
+ workspace_number = workspace.get_number()
+ activity = ""
+ if workspace_number < len(self.workspace_mapping):
+ activity = self.workspace_mapping[workspace_number]
+
+ self.workspace_store.append([workspace_number, workspace, activity])
def on_workspace_deleted(self, screen, workspace, user_data=None):
row = self.workspace_store.get_iter_first()
@@ -247,6 +248,15 @@ class PreferencesEditor:
else:
row = self.workspace_store.iter_next(row)
+ def on_workspace_activity_edited(self, cell, path, value):
+ index = int(path)
+ while index >= len(self.workspace_mapping):
+ self.workspace_mapping.append("")
+
+ self.workspace_mapping[index] = value
+ conf.set("workspace_mapping", self.workspace_mapping)
+ self.workspace_store[path][2] = value
+
def load_config(self, *args):
self.get_widget("shutdown_track").set_active(conf.get("stop_on_shutdown"))
self.get_widget("idle_track").set_active(conf.get("enable_timeout"))
@@ -263,6 +273,9 @@ class PreferencesEditor:
self.tags = [tag["name"] for tag in runtime.storage.get_tags(autocomplete=True)]
self.get_widget("autocomplete_tags").set_text(", ".join(self.tags))
+ self.workspace_mapping = conf.get("workspace_mapping")
+ self.get_widget("workspace_list").set_sensitive(self.get_widget("workspace_tracking_name").get_active())
+
def on_autocomplete_tags_view_focus_out_event(self, view, event):
buf = self.get_widget("autocomplete_tags")
@@ -713,6 +726,7 @@ class PreferencesEditor:
def on_workspace_tracking_toggled(self, checkbox):
workspace_tracking = []
+ self.get_widget("workspace_list").set_sensitive(self.get_widget("workspace_tracking_name").get_active())
if self.get_widget("workspace_tracking_name").get_active():
workspace_tracking.append("name")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]