[kupfer: 59/67] preferences: Allow configuring icon renderer



commit f138a09719c07c00f3d64aced10f834f0eca9ace
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Mar 19 01:53:40 2011 +0100

    preferences: Allow configuring icon renderer

 data/preferences.ui      |   31 +++++++++++++++++++++++
 kupfer/ui/preferences.py |   60 +++++++++++++++++++++++++++++-----------------
 2 files changed, 69 insertions(+), 22 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index d083dde..7b3befb 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -143,6 +143,37 @@
                             <property name="position">2</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkFrame" id="frame5">
+                            <property name="visible">True</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment8">
+                                <property name="visible">True</property>
+                                <property name="top_padding">6</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkComboBox" id="icons_combobox">
+                                    <property name="visible">True</property>
+                                    <signal name="changed" handler="on_icons_combobox_changed"/>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child type="label">
+                              <object class="GtkLabel" id="label12">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">&lt;b&gt;Icons&lt;/b&gt;</property>
+                                <property name="use_markup">True</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
diff --git a/kupfer/ui/preferences.py b/kupfer/ui/preferences.py
index 2528190..b10532f 100644
--- a/kupfer/ui/preferences.py
+++ b/kupfer/ui/preferences.py
@@ -119,20 +119,28 @@ class PreferencesWindowController (pretty.OutputMixin):
 		checkusecommandkeys.set_active(setctl.get_use_command_keys())
 
 		# List store with columns (Name, ID) 
+		# Make alternative comboboxes
 		terminal_combobox = builder.get_object("terminal_combobox")
-		terminal_combobox_store = gtk.ListStore(gobject.TYPE_STRING,
-		                                        gobject.TYPE_STRING)
-		terminal_combobox.set_model(terminal_combobox_store)
-		terminal_combobox_cell = gtk.CellRendererText()
-		terminal_combobox.pack_start(terminal_combobox_cell, True)
-		terminal_combobox.add_attribute(terminal_combobox_cell, 'text', 0)
-
-		self._update_terminal_combobox(terminal_combobox,
-		                               terminal_combobox_store)
+		icons_combobox = builder.get_object("icons_combobox")
+
+		def make_combobox_model(combobox):
+			combobox_store = gtk.ListStore(gobject.TYPE_STRING,
+			                               gobject.TYPE_STRING)
+			combobox.set_model(combobox_store)
+			combobox_cell = gtk.CellRendererText()
+			combobox.pack_start(combobox_cell, True)
+			combobox.add_attribute(combobox_cell, 'text', 0)
+
+		make_combobox_model(terminal_combobox)
+		make_combobox_model(icons_combobox)
+
+		self._update_alternative_combobox('terminal', terminal_combobox)
+		self._update_alternative_combobox('icon_renderer', icons_combobox)
 		self.terminal_combobox = terminal_combobox
-		self.terminal_combobox_store = terminal_combobox_store
+		self.icons_combobox = icons_combobox
 		setctl.connect("alternatives-changed", self._on_alternatives_changed)
 
+
 		# Plugin List
 		columns = [
 			{"key": "plugin_id", "type": str },
@@ -764,20 +772,26 @@ class PreferencesWindowController (pretty.OutputMixin):
 			term_id = widget.get_model().get_value(itr, 1)
 			setctl.set_preferred_tool('terminal', term_id)
 
-	def _update_terminal_combobox(self, combobox, combobox_store):
+	def on_icons_combobox_changed(self, widget):
+		setctl = settings.GetSettingsController()
+		itr = widget.get_active_iter()
+		if itr:
+			term_id = widget.get_model().get_value(itr, 1)
+			setctl.set_preferred_tool('icon_renderer', term_id)
+
+	def _update_alternative_combobox(self, category_key, combobox):
 		"""
-		Terminals changed
+		Alternatives changed
 		"""
-		print "_update_terminal_combobox"
+		combobox_store = combobox.get_model()
 		combobox_store.clear()
 		setctl = settings.GetSettingsController()
-		term_id = setctl.get_preferred_tool('terminal')
-		print term_id
-		# fill in the available terminals
-		terminals = utils.locale_sort(
-				setctl.get_valid_alternative_ids('terminal'), key=lambda t:t[1])
+		term_id = setctl.get_preferred_tool(category_key)
+		# fill in the available alternatives
+		alternatives = utils.locale_sort(
+				setctl.get_valid_alternative_ids(category_key), key=lambda t:t[1])
 		term_iter = None
-		for (id_, name) in terminals:
+		for (id_, name) in alternatives:
 			_it = combobox_store.append((name, id_))
 			if id_ == term_id:
 				term_iter = _it
@@ -787,9 +801,11 @@ class PreferencesWindowController (pretty.OutputMixin):
 
 	def _on_alternatives_changed(self, setctl, category_key):
 		if category_key == 'terminal':
-			self._update_terminal_combobox(
-					self.terminal_combobox,
-					self.terminal_combobox_store)
+			self._update_alternative_combobox(category_key,
+					self.terminal_combobox)
+		elif category_key == 'icon_renderer':
+			self._update_alternative_combobox(category_key,
+					self.icons_combobox)
 
 	def show(self):
 		self.window.present()



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