[pitivi] prefs: Use GtkStackSidebar for the dialog



commit e0bef00123aa4f20103d47895ca3a4a349507969
Author: Jakub Brindza <jakub brindza gmail com>
Date:   Wed Jun 29 13:15:49 2016 +0100

    prefs: Use GtkStackSidebar for the dialog
    
    Differential Revision: https://phabricator.freedesktop.org/D1143

 data/ui/preferences.ui  |   76 +++++++++++++++++-----------------------------
 pitivi/dialogs/prefs.py |   33 +++-----------------
 2 files changed, 33 insertions(+), 76 deletions(-)
---
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index ebc9004..57a0a19 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -1,13 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.19.0 -->
+<!-- Generated with glade 3.20.0 -->
 <interface>
-  <requires lib="gtk+" version="3.10"/>
-  <object class="GtkListStore" id="liststore1">
-    <columns>
-      <!-- column-name column1 -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
+  <requires lib="gtk+" version="3.16"/>
   <object class="GtkDialog" id="dialog1">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Preferences</property>
@@ -82,62 +76,48 @@
           </packing>
         </child>
         <child>
-          <object class="GtkPaned" id="paned1">
+          <object class="GtkBox">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="position">132</property>
+            <property name="can_focus">False</property>
             <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow1">
+              <object class="GtkStackSidebar" id="sidebar">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
-                <property name="vscrollbar_policy">never</property>
-                <property name="shadow_type">etched-in</property>
-                <child>
-                  <object class="GtkTreeView" id="treeview1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="model">liststore1</property>
-                    <property name="headers_visible">False</property>
-                    <property name="headers_clickable">False</property>
-                    <property name="search_column">0</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection3">
-                        <signal name="changed" handler="_treeSelectionChangedCb" swapped="no"/>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
-                        <property name="title" translatable="yes">Section</property>
-                        <child>
-                          <object class="GtkCellRendererText" id="cellrenderer1"/>
-                          <attributes>
-                            <attribute name="text">0</attribute>
-                          </attributes>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
+                <property name="can_focus">False</property>
+                <property name="vexpand">True</property>
+                <property name="stack">stack</property>
               </object>
               <packing>
-                <property name="resize">False</property>
-                <property name="shrink">False</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="box1">
+              <object class="GtkSeparator">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
                 <property name="orientation">vertical</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkStack" id="stack">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="transition_type">crossfade</property>
                 <child>
                   <placeholder/>
                 </child>
               </object>
               <packing>
-                <property name="resize">True</property>
-                <property name="shrink">False</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index 4337223..8a1f6d6 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -61,22 +61,14 @@ class PreferencesDialog(Loggable):
         builder.add_from_file(os.path.join(get_ui_dir(), "preferences.ui"))
         builder.connect_signals(self)
         self.dialog = builder.get_object("dialog1")
-        self.model = builder.get_object("liststore1")
-        self.treeview = builder.get_object("treeview1")
-        self.contents = builder.get_object("box1")
+        self.sidebar = builder.get_object("sidebar")
+        self.stack = builder.get_object("stack")
         self.revert_button = builder.get_object("revertButton")
         self.factory_settings = builder.get_object("resetButton")
         self.restart_warning = builder.get_object("restartWarning")
 
-        self.sections = {}
         self.__fillContents()
-        req = self.contents.get_preferred_size()[0]
-        min_width = req.width
-        min_height = req.height
-        width = max(min_width, self.settings.prefsDialogWidth)
-        height = max(min_height, self.settings.prefsDialogHeight)
         self.dialog.set_transient_for(app.gui)
-        self.dialog.set_default_size(width, height)
 
     def run(self):
         """Runs the dialog."""
@@ -153,14 +145,11 @@ class PreferencesDialog(Loggable):
                             widgets.FontWidget)
 
     def __fillContents(self):
-        for section in sorted(self.prefs):
-            options = self.prefs[section]
-            self.model.append((section,))
+        for section_id, options in sorted(self.prefs.items()):
             grid = Gtk.Grid()
             grid.set_border_width(SPACING)
             grid.props.column_spacing = SPACING
             grid.props.row_spacing = SPACING / 2
-            self.sections[section] = grid
 
             prefs = []
             for attrname in options:
@@ -213,22 +202,10 @@ class PreferencesDialog(Loggable):
                     grid.attach(revert, 2, y, 1, 1)
                 widget.show()
                 revert.show()
-
-            self.contents.pack_start(grid, False, False, 0)
-
-        self.treeview.get_selection().select_path((0,))
+            grid.show()
+            self.stack.add_titled(grid, section_id, section_id)
         self.factory_settings.set_sensitive(self._canReset())
 
-    def _treeSelectionChangedCb(self, selection):
-        """Updates current when selection changed."""
-        model, _iter = selection.get_selected()
-        section = self.sections[model[_iter][0]]
-        if self._current != section:
-            if self._current:
-                self._current.hide()
-            section.show()
-            self._current = section
-
     def _clearHistory(self):
         # Disable missing docstring
         # pylint: disable=C0111


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