[meld/deprecation-cleanup: 44/48] filediff: Move save confirmation dialog to resource loading
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/deprecation-cleanup: 44/48] filediff: Move save confirmation dialog to resource loading
- Date: Sun, 2 Dec 2018 02:45:49 +0000 (UTC)
commit ca4c58fdc17d01a4727e0d5639b9e4e9e041c0c8
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Dec 2 10:40:54 2018 +1000
filediff: Move save confirmation dialog to resource loading
data/ui/filediff.ui | 96 -----------------------------
meld/filediff.py | 13 ++--
meld/resources/meld.gresource.xml | 1 +
meld/resources/ui/save-confirm-dialog.ui | 100 +++++++++++++++++++++++++++++++
4 files changed, 109 insertions(+), 101 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index 1c9f51d8..a6d29c21 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -179,102 +179,6 @@
</object>
</child>
</object>
- <object class="GtkMessageDialog" id="check_save_dialog">
- <property name="can_focus">False</property>
- <property name="type_hint">dialog</property>
- <property name="skip_taskbar_hint">True</property>
- <property name="message_type">warning</property>
- <property name="text" translatable="yes">Save changes to documents before closing?</property>
- <property name="secondary_text" translatable="yes">If you don’t save, changes will be permanently
lost.</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <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_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">expand</property>
- <child>
- <object class="GtkButton" id="close_button">
- <property name="label" translatable="yes">Close _without Saving</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">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_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>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="save_button">
- <property name="label" translatable="yes">_Save</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">2</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_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <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="-7">close_button</action-widget>
- <action-widget response="-6">cancel_button</action-widget>
- <action-widget response="-5">save_button</action-widget>
- </action-widgets>
- </object>
<object class="GtkWindow" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/meld/filediff.py b/meld/filediff.py
index 6f975609..9ba3051c 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -850,9 +850,12 @@ class FileDiff(MeldDoc, Component):
modified = [b.get_modified() for b in buffers]
labels = [b.data.label for b in buffers]
if any(modified):
- dialog = Component("filediff.ui", "check_save_dialog")
- dialog.widget.set_transient_for(self.widget.get_toplevel())
- message_area = dialog.widget.get_message_area()
+ builder = Gtk.Builder.new_from_resource(
+ '/org/gnome/meld/ui/save-confirm-dialog.ui')
+ dialog = builder.get_object('save-confirm-dialog')
+ dialog.set_transient_for(self.widget.get_toplevel())
+ message_area = dialog.get_message_area()
+
buttons = []
for label, should_save in zip(labels, modified):
button = Gtk.CheckButton.new_with_label(label)
@@ -862,9 +865,9 @@ class FileDiff(MeldDoc, Component):
button, expand=False, fill=True, padding=0)
buttons.append(button)
message_area.show_all()
- response = dialog.widget.run()
+ response = dialog.run()
try_save = [b.get_active() for b in buttons]
- dialog.widget.destroy()
+ dialog.destroy()
if response == Gtk.ResponseType.OK and any(try_save):
for i in range(self.num_panes):
if try_save[i]:
diff --git a/meld/resources/meld.gresource.xml b/meld/resources/meld.gresource.xml
index 7bb9defa..fe4739c4 100644
--- a/meld/resources/meld.gresource.xml
+++ b/meld/resources/meld.gresource.xml
@@ -13,5 +13,6 @@
<file>ui/patch-dialog.ui</file>
<file>ui/push-dialog.ui</file>
<file>ui/revert-dialog.ui</file>
+ <file>ui/save-confirm-dialog.ui</file>
</gresource>
</gresources>
diff --git a/meld/resources/ui/save-confirm-dialog.ui b/meld/resources/ui/save-confirm-dialog.ui
new file mode 100644
index 00000000..3b613fc1
--- /dev/null
+++ b/meld/resources/ui/save-confirm-dialog.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkMessageDialog" id="save-confirm-dialog">
+ <property name="can_focus">False</property>
+ <property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="message_type">warning</property>
+ <property name="text" translatable="yes">Save changes to documents before closing?</property>
+ <property name="secondary_text" translatable="yes">If you don’t save, changes will be permanently
lost.</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <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_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">expand</property>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label" translatable="yes">Close _without Saving</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_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>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="save_button">
+ <property name="label" translatable="yes">_Save</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">2</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_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <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="-7">close_button</action-widget>
+ <action-widget response="-6">cancel_button</action-widget>
+ <action-widget response="-5">save_button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]