[meld] preferences: Move timestamp preference widget to builder-based creation



commit cd2cafe9e9375d0833c3050d62427b04af738ffc
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Dec 6 07:56:55 2013 +1000

    preferences: Move timestamp preference widget to builder-based creation

 data/org.gnome.meld.gschema.xml |    4 ++++
 data/ui/preferences.ui          |   35 +++++++++++++++++++++++++++++++++++
 meld/preferences.py             |   21 +++------------------
 3 files changed, 42 insertions(+), 18 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 051d0c7..b15e4b7 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -20,6 +20,10 @@
 
   <schema id="org.gnome.meld" path="/org/gnome/meld/">
       <!-- Application settings -->
+      <key name="window-size" type="(ii)">
+          <default>(-1, -1)</default>
+          <summary>Default window size</summary>
+      </key>
       <key name="toolbar-visible" type="b">
           <default>true</default>
           <summary>Show toolbar</summary>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index e941e46..d8fe83b 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -33,6 +33,32 @@
       </row>
     </data>
   </object>
+  <object class="GtkListStore" id="timestampstore">
+    <columns>
+      <!-- column-name value -->
+      <column type="gint"/>
+      <!-- column-name label -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0">1</col>
+        <col id="1" translatable="yes">1ns (ext4)</col>
+      </row>
+      <row>
+        <col id="0">100</col>
+        <col id="1" translatable="yes">100ns (NTFS)</col>
+      </row>
+      <row>
+        <col id="0">1000000000</col>
+        <col id="1" translatable="yes">1s (ext2/ext3)</col>
+      </row>
+      <row>
+        <col id="0">2000000000</col>
+        <col id="1" translatable="yes">2s (VFAT)</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="preferencesdialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -668,6 +694,15 @@
                                   <object class="GSettingsIntComboBox" id="combo_timestamp">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
+                                    <property name="model">timestampstore</property>
+                                    <property name="active">0</property>
+                                    <property name="gsettings-column">0</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="combo_timestamp_renderer"/>
+                                      <attributes>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
diff --git a/meld/preferences.py b/meld/preferences.py
index 4cfb4fd..b5dbea6 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -32,12 +32,6 @@ from .util import prefs
 from meld.settings import settings
 
 
-TIMESTAMP_RESOLUTION_PRESETS = [('1ns (ext4)', 1),
-                                ('100ns (NTFS)', 100),
-                                ('1s (ext2/ext3)', 1000000000),
-                                ('2s (VFAT)', 2000000000)]
-
-
 class FilterList(listwidget.ListWidget):
 
     def __init__(self, key, filter_type):
@@ -157,7 +151,7 @@ class GSettingsIntComboBox(GSettingsComboBox):
 
     __gtype_name__ = "GSettingsIntComboBox"
 
-    gsettings_column = GObject.property(type=int, default=1)
+    gsettings_column = GObject.property(type=int, default=0)
     gsettings_value = GObject.property(type=int)
 
 
@@ -165,7 +159,7 @@ class GSettingsBoolComboBox(GSettingsComboBox):
 
     __gtype_name__ = "GSettingsBoolComboBox"
 
-    gsettings_column = GObject.property(type=int, default=1)
+    gsettings_column = GObject.property(type=int, default=0)
     gsettings_value = GObject.property(type=bool, default=False)
 
 
@@ -175,7 +169,7 @@ class PreferencesDialog(gnomeglade.Component):
         gnomeglade.Component.__init__(self, "preferences.ui",
                                       "preferencesdialog",
                                       ["adjustment1", "adjustment2", "fileorderstore",
-                                       "sizegroup_editor"])
+                                       "sizegroup_editor", "timestampstore"])
         self.widget.set_transient_for(parent)
         self.prefs = prefs
 
@@ -233,16 +227,7 @@ class PreferencesDialog(gnomeglade.Component):
         columnlist = ColumnList("folder-columns")
         self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)
 
-        model = Gtk.ListStore(str, int)
-        for i, entry in enumerate(TIMESTAMP_RESOLUTION_PRESETS):
-            model.append(entry)
-        # FIXME: This should all be in the glade
-        self.combo_timestamp.set_model(model)
-        cell = Gtk.CellRendererText()
-        self.combo_timestamp.pack_start(cell, False)
-        self.combo_timestamp.add_attribute(cell, 'text', 0)
         self.combo_timestamp.bind_to('folder-time-resolution')
-
         self.combo_file_order.bind_to('vc-left-is-local')
 
         self.widget.show()


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