[meld] Add and use a new Revert dialog, based on the gedit UI
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add and use a new Revert dialog, based on the gedit UI
- Date: Sun, 28 Apr 2013 02:49:28 +0000 (UTC)
commit db12e5c14c1d0ee95d78065d787ac3f4857f2458
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Apr 28 12:47:31 2013 +1000
Add and use a new Revert dialog, based on the gedit UI
data/ui/filediff.ui | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
meld/filediff.py | 16 +++++++++-
2 files changed, 94 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index 50610ab..cf4c61b 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -101,6 +101,86 @@
<action-widget response="-5">save_button</action-widget>
</action-widgets>
</object>
+ <object class="GtkMessageDialog" id="revert_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</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">Revert 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="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <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_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="revert_button">
+ <property name="label">gtk-revert-to-saved</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</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_vbox">
+ <property name="visible">False</property>
+ <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_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="title" translatable="yes">window1</property>
diff --git a/meld/filediff.py b/meld/filediff.py
index f7c786a..37595cf 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1623,8 +1623,20 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return -1
def on_reload_activate(self, *extra):
- primary = _("Save changes to documents before reloading?")
- if self.check_save_modified(primary) != gtk.RESPONSE_CANCEL:
+ response = gtk.RESPONSE_OK
+ unsaved = [b.data.label for b in self.textbuffer if b.data.modified]
+ if unsaved:
+ ui_path = paths.ui_dir("revert.ui")
+ dialog = gnomeglade.Component(ui_path, "revert_dialog")
+ dialog.widget.set_transient_for(self.widget.get_toplevel())
+ # FIXME: Should be packed into dialog.widget.get_message_area(),
+ # but this is unbound on currently required PyGTK.
+ filelist = "\n".join(["\t" + f for f in unsaved])
+ dialog.widget.props.secondary_text += filelist
+ response = dialog.widget.run()
+ dialog.widget.destroy()
+
+ if response == gtk.RESPONSE_OK:
files = [b.data.filename for b in self.textbuffer[:self.num_panes]]
self.set_files(files)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]