[meld/deprecation-cleanup: 43/48] filediff: Move revert dialog to resource loading



commit 79140bae26b67b9041cee34c4ab233703958fbc3
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Dec 2 10:36:21 2018 +1000

    filediff: Move revert dialog to resource loading

 data/ui/filediff.ui                | 75 ------------------------------------
 meld/filediff.py                   | 12 +++---
 meld/resources/meld.gresource.xml  |  1 +
 meld/resources/ui/revert-dialog.ui | 79 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 80 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index e49766f0..1c9f51d8 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -831,79 +831,4 @@
       </object>
     </child>
   </object>
-  <object class="GtkMessageDialog" id="revert_dialog">
-    <property name="can_focus">False</property>
-    <property name="type_hint">dialog</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="message_type">question</property>
-    <property name="text" translatable="yes">Discard unsaved changes to documents?</property>
-    <property name="secondary_text" translatable="yes">Changes made to the following documents will be 
permanently lost:</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">6</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">expand</property>
-            <child>
-              <object class="GtkButton" id="cancel_button1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="revert_button">
-                <property name="label" translatable="yes">_Discard</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </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>
-          <object class="GtkVBox" id="extra_vbox1">
-            <property name="can_focus">False</property>
-            <child>
-              <placeholder/>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancel_button1</action-widget>
-      <action-widget response="-5">revert_button</action-widget>
-    </action-widgets>
-  </object>
 </interface>
diff --git a/meld/filediff.py b/meld/filediff.py
index 56872e78..6f975609 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1702,17 +1702,19 @@ class FileDiff(MeldDoc, Component):
         if not unsaved:
             return True
 
-        dialog = Component("filediff.ui", "revert_dialog")
-        dialog.widget.set_transient_for(self.widget.get_toplevel())
+        builder = Gtk.Builder.new_from_resource(
+            '/org/gnome/meld/ui/revert-dialog.ui')
+        dialog = builder.get_object('revert_dialog')
+        dialog.set_transient_for(self.widget.get_toplevel())
 
         filelist = Gtk.Label("\n".join(["\t• " + f for f in unsaved]))
         filelist.props.xalign = 0.0
         filelist.show()
-        message_area = dialog.widget.get_message_area()
+        message_area = dialog.get_message_area()
         message_area.pack_start(filelist, expand=False, fill=True, padding=0)
 
-        response = dialog.widget.run()
-        dialog.widget.destroy()
+        response = dialog.run()
+        dialog.destroy()
         return response == Gtk.ResponseType.OK
 
     def on_revert_activate(self, *extra):
diff --git a/meld/resources/meld.gresource.xml b/meld/resources/meld.gresource.xml
index 97b63fa9..7bb9defa 100644
--- a/meld/resources/meld.gresource.xml
+++ b/meld/resources/meld.gresource.xml
@@ -12,5 +12,6 @@
     <file>ui/commit-dialog.ui</file>
     <file>ui/patch-dialog.ui</file>
     <file>ui/push-dialog.ui</file>
+    <file>ui/revert-dialog.ui</file>
   </gresource>
 </gresources>
diff --git a/meld/resources/ui/revert-dialog.ui b/meld/resources/ui/revert-dialog.ui
new file mode 100644
index 00000000..009a974e
--- /dev/null
+++ b/meld/resources/ui/revert-dialog.ui
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkMessageDialog" id="revert_dialog">
+    <property name="can_focus">False</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="message_type">question</property>
+    <property name="text" translatable="yes">Discard unsaved changes to documents?</property>
+    <property name="secondary_text" translatable="yes">Changes made to the following documents will be 
permanently lost:</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">expand</property>
+            <child>
+              <object class="GtkButton" id="cancel_button1">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="revert_button">
+                <property name="label" translatable="yes">_Discard</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </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>
+          <object class="GtkVBox" id="extra_vbox1">
+            <property name="can_focus">False</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancel_button1</action-widget>
+      <action-widget response="-5">revert_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>


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