[meld] Pack FileDiff file selectors into a box to allow for future replacement



commit 85011d5ce3644645edae05f17dde62b1fab00266
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Wed Dec 5 05:07:03 2012 +1000

    Pack FileDiff file selectors into a box to allow for future replacement
    
    Different file selectors (i.e., history based or similar) will need a
    different selector, but repacking things in the table is messy, and
    plays havoc with keeping consistent column sizing. This commit adds
    currently-unused HBoxes around the file selectors, and sticks them in
    a size group to ensure that we get consistent column sizes.

 data/ui/filediff.ui |   48 +++++++++++++++++++++++++++++++++++++++---------
 meld/filediff.py    |   15 ++++++++++++++-
 2 files changed, 53 insertions(+), 10 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index cf25b3f..3322aba 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -117,10 +117,20 @@
               <placeholder/>
             </child>
             <child>
-              <object class="HistoryFileEntry" id="fileentry2">
+              <object class="GtkHBox" id="selector_hbox2">
                 <property name="visible">True</property>
-                <property name="history-id">fileentry</property>
-                <signal handler="on_fileentry_activate" name="activate"/>
+                <property name="can_focus">False</property>
+                <child>
+                <object class="HistoryFileEntry" id="fileentry2">
+                  <property name="visible">True</property>
+                  <property name="history-id">fileentry</property>
+                  <signal handler="on_fileentry_activate" name="activate"/>
+                </object>
+                <packing>
+                  <property name="expand">True</property>
+                  <property name="fill">True</property>
+                </packing>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">5</property>
@@ -130,10 +140,20 @@
               </packing>
             </child>
             <child>
-              <object class="HistoryFileEntry" id="fileentry1">
+              <object class="GtkHBox" id="selector_hbox1">
                 <property name="visible">True</property>
-                <property name="history-id">fileentry</property>
-                <signal handler="on_fileentry_activate" name="activate"/>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="HistoryFileEntry" id="fileentry1">
+                    <property name="visible">True</property>
+                    <property name="history-id">fileentry</property>
+                    <signal handler="on_fileentry_activate" name="activate"/>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">3</property>
@@ -143,10 +163,20 @@
               </packing>
             </child>
             <child>
-              <object class="HistoryFileEntry" id="fileentry0">
+              <object class="GtkHBox" id="selector_hbox0">
                 <property name="visible">True</property>
-                <property name="history-id">fileentry</property>
-                <signal handler="on_fileentry_activate" name="activate"/>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="HistoryFileEntry" id="fileentry0">
+                    <property name="visible">True</property>
+                    <property name="history-id">fileentry</property>
+                    <signal handler="on_fileentry_activate" name="activate"/>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">1</property>
diff --git a/meld/filediff.py b/meld/filediff.py
index f927f97..ef82966 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -158,7 +158,18 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         """
         melddoc.MeldDoc.__init__(self, prefs)
         gnomeglade.Component.__init__(self, paths.ui_dir("filediff.ui"), "filediff")
-        self.map_widgets_into_lists(["textview", "fileentry", "diffmap", "scrolledwindow", "linkmap", "statusimage", "msgarea_mgr", "vbox"])
+        self.map_widgets_into_lists(["textview", "fileentry", "diffmap",
+                                     "scrolledwindow", "linkmap",
+                                     "statusimage", "msgarea_mgr", "vbox",
+                                     "selector_hbox"])
+
+        # This SizeGroup isn't actually necessary for FileDiff; it's for
+        # handling non-homogenous selectors in FileComp. It's also fragile.
+        column_sizes = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+        column_sizes.set_ignore_hidden(True)
+        for widget in self.selector_hbox:
+            column_sizes.add_widget(widget)
+
         self.warned_bad_comparison = False
         # Some sourceviews bind their own undo mechanism, which we replace
         gtk.binding_entry_remove(srcviewer.GtkTextView, gtk.keysyms.z,
@@ -1576,12 +1587,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             toshow =  self.scrolledwindow[:n] + self.fileentry[:n]
             toshow += self.vbox[:n] + self.msgarea_mgr[:n]
             toshow += self.linkmap[:n-1] + self.diffmap[:n]
+            toshow += self.selector_hbox[:n]
             for widget in toshow:
                 widget.show()
 
             tohide =  self.statusimage + self.scrolledwindow[n:] + self.fileentry[n:]
             tohide += self.vbox[n:] + self.msgarea_mgr[n:]
             tohide += self.linkmap[n-1:] + self.diffmap[n:]
+            tohide += self.selector_hbox[n:]
             for widget in tohide:
                 widget.hide()
 



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