Skip to content

Commit 79140ba

Browse files
committed
filediff: Move revert dialog to resource loading
1 parent f63e2e2 commit 79140ba

4 files changed

Lines changed: 87 additions & 80 deletions

File tree

data/ui/filediff.ui

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -831,79 +831,4 @@
831831
</object>
832832
</child>
833833
</object>
834-
<object class="GtkMessageDialog" id="revert_dialog">
835-
<property name="can_focus">False</property>
836-
<property name="type_hint">dialog</property>
837-
<property name="skip_taskbar_hint">True</property>
838-
<property name="message_type">question</property>
839-
<property name="text" translatable="yes">Discard unsaved changes to documents?</property>
840-
<property name="secondary_text" translatable="yes">Changes made to the following documents will be permanently lost:</property>
841-
<child internal-child="vbox">
842-
<object class="GtkBox" id="dialog-vbox2">
843-
<property name="visible">True</property>
844-
<property name="can_focus">False</property>
845-
<property name="orientation">vertical</property>
846-
<property name="spacing">6</property>
847-
<child internal-child="action_area">
848-
<object class="GtkButtonBox" id="dialog-action_area2">
849-
<property name="visible">True</property>
850-
<property name="can_focus">False</property>
851-
<property name="layout_style">expand</property>
852-
<child>
853-
<object class="GtkButton" id="cancel_button1">
854-
<property name="label">gtk-cancel</property>
855-
<property name="visible">True</property>
856-
<property name="can_focus">True</property>
857-
<property name="receives_default">True</property>
858-
<property name="use_underline">True</property>
859-
<property name="use_stock">True</property>
860-
</object>
861-
<packing>
862-
<property name="expand">False</property>
863-
<property name="fill">True</property>
864-
<property name="position">0</property>
865-
</packing>
866-
</child>
867-
<child>
868-
<object class="GtkButton" id="revert_button">
869-
<property name="label" translatable="yes">_Discard</property>
870-
<property name="visible">True</property>
871-
<property name="can_focus">True</property>
872-
<property name="receives_default">True</property>
873-
<property name="use_underline">True</property>
874-
</object>
875-
<packing>
876-
<property name="expand">False</property>
877-
<property name="fill">True</property>
878-
<property name="position">1</property>
879-
</packing>
880-
</child>
881-
</object>
882-
<packing>
883-
<property name="expand">False</property>
884-
<property name="fill">True</property>
885-
<property name="pack_type">end</property>
886-
<property name="position">0</property>
887-
</packing>
888-
</child>
889-
<child>
890-
<object class="GtkVBox" id="extra_vbox1">
891-
<property name="can_focus">False</property>
892-
<child>
893-
<placeholder/>
894-
</child>
895-
</object>
896-
<packing>
897-
<property name="expand">True</property>
898-
<property name="fill">True</property>
899-
<property name="position">3</property>
900-
</packing>
901-
</child>
902-
</object>
903-
</child>
904-
<action-widgets>
905-
<action-widget response="-6">cancel_button1</action-widget>
906-
<action-widget response="-5">revert_button</action-widget>
907-
</action-widgets>
908-
</object>
909834
</interface>

meld/filediff.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,17 +1702,19 @@ def check_unsaved_changes(self, buffers=None):
17021702
if not unsaved:
17031703
return True
17041704

1705-
dialog = Component("filediff.ui", "revert_dialog")
1706-
dialog.widget.set_transient_for(self.widget.get_toplevel())
1705+
builder = Gtk.Builder.new_from_resource(
1706+
'/org/gnome/meld/ui/revert-dialog.ui')
1707+
dialog = builder.get_object('revert_dialog')
1708+
dialog.set_transient_for(self.widget.get_toplevel())
17071709

17081710
filelist = Gtk.Label("\n".join(["\t• " + f for f in unsaved]))
17091711
filelist.props.xalign = 0.0
17101712
filelist.show()
1711-
message_area = dialog.widget.get_message_area()
1713+
message_area = dialog.get_message_area()
17121714
message_area.pack_start(filelist, expand=False, fill=True, padding=0)
17131715

1714-
response = dialog.widget.run()
1715-
dialog.widget.destroy()
1716+
response = dialog.run()
1717+
dialog.destroy()
17161718
return response == Gtk.ResponseType.OK
17171719

17181720
def on_revert_activate(self, *extra):

meld/resources/meld.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<file>ui/commit-dialog.ui</file>
1313
<file>ui/patch-dialog.ui</file>
1414
<file>ui/push-dialog.ui</file>
15+
<file>ui/revert-dialog.ui</file>
1516
</gresource>
1617
</gresources>

meld/resources/ui/revert-dialog.ui

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<requires lib="gtk+" version="3.20"/>
4+
<object class="GtkMessageDialog" id="revert_dialog">
5+
<property name="can_focus">False</property>
6+
<property name="type_hint">dialog</property>
7+
<property name="skip_taskbar_hint">True</property>
8+
<property name="message_type">question</property>
9+
<property name="text" translatable="yes">Discard unsaved changes to documents?</property>
10+
<property name="secondary_text" translatable="yes">Changes made to the following documents will be permanently lost:</property>
11+
<child internal-child="vbox">
12+
<object class="GtkBox" id="dialog-vbox2">
13+
<property name="visible">True</property>
14+
<property name="can_focus">False</property>
15+
<property name="orientation">vertical</property>
16+
<property name="spacing">6</property>
17+
<child internal-child="action_area">
18+
<object class="GtkButtonBox" id="dialog-action_area2">
19+
<property name="visible">True</property>
20+
<property name="can_focus">False</property>
21+
<property name="layout_style">expand</property>
22+
<child>
23+
<object class="GtkButton" id="cancel_button1">
24+
<property name="label">gtk-cancel</property>
25+
<property name="visible">True</property>
26+
<property name="can_focus">True</property>
27+
<property name="receives_default">True</property>
28+
<property name="use_underline">True</property>
29+
<property name="use_stock">True</property>
30+
</object>
31+
<packing>
32+
<property name="expand">False</property>
33+
<property name="fill">True</property>
34+
<property name="position">0</property>
35+
</packing>
36+
</child>
37+
<child>
38+
<object class="GtkButton" id="revert_button">
39+
<property name="label" translatable="yes">_Discard</property>
40+
<property name="visible">True</property>
41+
<property name="can_focus">True</property>
42+
<property name="receives_default">True</property>
43+
<property name="use_underline">True</property>
44+
</object>
45+
<packing>
46+
<property name="expand">False</property>
47+
<property name="fill">True</property>
48+
<property name="position">1</property>
49+
</packing>
50+
</child>
51+
</object>
52+
<packing>
53+
<property name="expand">False</property>
54+
<property name="fill">True</property>
55+
<property name="pack_type">end</property>
56+
<property name="position">0</property>
57+
</packing>
58+
</child>
59+
<child>
60+
<object class="GtkVBox" id="extra_vbox1">
61+
<property name="can_focus">False</property>
62+
<child>
63+
<placeholder/>
64+
</child>
65+
</object>
66+
<packing>
67+
<property name="expand">True</property>
68+
<property name="fill">True</property>
69+
<property name="position">3</property>
70+
</packing>
71+
</child>
72+
</object>
73+
</child>
74+
<action-widgets>
75+
<action-widget response="-6">cancel_button1</action-widget>
76+
<action-widget response="-5">revert_button</action-widget>
77+
</action-widgets>
78+
</object>
79+
</interface>

0 commit comments

Comments
 (0)