[meld] newdifftab: Use encoding fileloaders for the new tab UI



commit 2d51b7e36c03bbf4bad3951b0143a527b74d8f54
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Oct 23 05:24:58 2016 +1000

    newdifftab: Use encoding fileloaders for the new tab UI
    
    This needs extra hooks in meldwindow to work at all.

 data/ui/tab-placeholder.ui |  105 ++++++++++++++++++++++++++++++++++++++++++++
 meld/newdifftab.py         |   20 ++++++--
 2 files changed, 120 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/tab-placeholder.ui b/data/ui/tab-placeholder.ui
index a97b360..53207fc 100644
--- a/data/ui/tab-placeholder.ui
+++ b/data/ui/tab-placeholder.ui
@@ -2,6 +2,108 @@
 <interface>
   <requires lib="gtk+" version="2.18"/>
   <!-- interface-naming-policy toplevel-contextual -->
+  <object class="MeldFileChooserDialog" id="filechooserdialog0">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="role">GtkFileChooserDialog</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="filechooserdialog-vbox0">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="filechooserdialog-action_area0">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="MeldFileChooserDialog" id="filechooserdialog1">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="role">GtkFileChooserDialog</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="filechooserdialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="filechooserdialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="MeldFileChooserDialog" id="filechooserdialog2">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="role">GtkFileChooserDialog</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="filechooserdialog-vbox2">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="filechooserdialog-action_area2">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
   <object class="GtkWindow" id="window">
     <property name="can_focus">False</property>
     <child>
@@ -254,6 +356,7 @@
                                 <property name="can_focus">False</property>
                                 <property name="create_folders">False</property>
                                 <property name="title" translatable="yes">Select Third File</property>
+                                <property name="dialog">filechooserdialog2</property>
                                 <signal name="file-set" handler="on_file_set" swapped="no"/>
                               </object>
                               <packing>
@@ -269,6 +372,7 @@
                                 <property name="can_focus">False</property>
                                 <property name="create_folders">False</property>
                                 <property name="title" translatable="yes">Select Second File</property>
+                                <property name="dialog">filechooserdialog1</property>
                                 <signal name="file-set" handler="on_file_set" swapped="no"/>
                               </object>
                               <packing>
@@ -284,6 +388,7 @@
                                 <property name="can_focus">False</property>
                                 <property name="create_folders">False</property>
                                 <property name="title" translatable="yes">Select First File</property>
+                                <property name="dialog">filechooserdialog0</property>
                                 <signal name="file-set" handler="on_file_set" swapped="no"/>
                               </object>
                               <packing>
diff --git a/meld/newdifftab.py b/meld/newdifftab.py
index 2e4fb0c..6e34714 100644
--- a/meld/newdifftab.py
+++ b/meld/newdifftab.py
@@ -40,10 +40,12 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
 
     def __init__(self, parentapp):
         GObject.GObject.__init__(self)
+        file_choosers = ["filechooserdialog0", "filechooserdialog1",
+                         "filechooserdialog2"]
         gnomeglade.Component.__init__(self, "tab-placeholder.ui",
-                                      "new_comparison_tab")
+                                      "new_comparison_tab", file_choosers)
         self.map_widgets_into_lists(["file_chooser", "dir_chooser",
-                                     "vc_chooser"])
+                                     "vc_chooser", "filechooserdialog"])
         self.button_types = [self.button_type_file, self.button_type_dir,
                              self.button_type_vc]
         self.diff_methods = (parentapp.append_filediff,
@@ -106,9 +108,17 @@ class NewDiffTab(LabeledObjectMixin, GObject.GObject, gnomeglade.Component):
 
     def on_button_compare_clicked(self, *args):
         type_choosers = (self.file_chooser, self.dir_chooser, self.vc_chooser)
-        compare_gfiles = [c.get_file() for c in
-                         type_choosers[self.diff_type][:self._get_num_paths()]]
-        tab = self.diff_methods[self.diff_type](compare_gfiles)
+        choosers = type_choosers[self.diff_type][:self._get_num_paths()]
+        compare_gfiles = [chooser.get_file() for chooser in choosers]
+
+        compare_kwargs = {}
+        if self.diff_type == 0:
+            chooserdialogs = self.filechooserdialog[:self._get_num_paths()]
+            encodings = [chooser.get_encoding() for chooser in chooserdialogs]
+            compare_kwargs = {'encodings': encodings}
+
+        tab = self.diff_methods[self.diff_type](
+            compare_gfiles, **compare_kwargs)
         recent_comparisons.add(tab)
         self.emit('diff-created', tab)
 


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