[meld] Improve layout of file save dialog
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Improve layout of file save dialog
- Date: Sat, 8 Dec 2012 20:43:06 +0000 (UTC)
commit beb87302741e3362840be0c4fb1a75a8569fbcda
Author: Kai Willadsen <kai willadsen gmail com>
Date: Thu Nov 29 10:52:13 2012 +1000
Improve layout of file save dialog
This commit also removes the old save-on-close dialog.
data/ui/filediff.ui | 278 +++++++++++++++++++--------------------------------
meld/filediff.py | 23 ++--
2 files changed, 113 insertions(+), 188 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index 1f5027b..879f808 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -1,6 +1,106 @@
-<?xml version="1.0"?>
-<!--*- mode: xml -*-->
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkMessageDialog" id="check_save_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">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="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="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_action_appearance">False</property>
+ <property name="use_underline">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="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_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</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_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</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="title" translatable="yes">window1</property>
@@ -289,178 +389,4 @@
</object>
</child>
</object>
- <object class="GtkDialog" id="closedialog">
- <property name="title" translatable="yes">Save modified files?</property>
- <property name="resizable">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="yalign">0</property>
- <property name="xpad">12</property>
- <property name="ypad">12</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon_size">6</property>
- </object>
- </child>
- <child>
- <object class="GtkVBox" id="box">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="xpad">12</property>
- <property name="ypad">12</property>
- <property name="label" translatable="yes">Some files have been modified.
-Which ones would you like to save?</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <object class="GtkButton" id="button_quit">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image25">
- <property name="visible">True</property>
- <property name="stock">gtk-quit</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label10">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Discard Changes</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="button_cancel">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button_ok">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image26">
- <property name="visible">True</property>
- <property name="stock">gtk-save</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label11">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Save Selected</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-7">button_quit</action-widget>
- <action-widget response="-6">button_cancel</action-widget>
- <action-widget response="-5">button_ok</action-widget>
- </action-widgets>
- </object>
</interface>
diff --git a/meld/filediff.py b/meld/filediff.py
index a3ff749..bb766cd 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -774,23 +774,22 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
response = gtk.RESPONSE_OK
modified = [b.data.modified for b in self.textbuffer]
if True in modified:
- dialog = gnomeglade.Component(paths.ui_dir("filediff.ui"), "closedialog")
+ ui_path = paths.ui_dir("filediff.ui")
+ dialog = gnomeglade.Component(ui_path, "check_save_dialog")
dialog.widget.set_transient_for(self.widget.get_toplevel())
buttons = []
for i in range(self.num_panes):
- b = gtk.CheckButton(self.textbuffer[i].data.label)
- b.set_use_underline(False)
- buttons.append(b)
- dialog.box.pack_start(b, 1, 1)
- if not modified[i]:
- b.set_sensitive(0)
- else:
- b.set_active(1)
- dialog.box.show_all()
+ button = gtk.CheckButton(self.textbuffer[i].data.label)
+ button.set_use_underline(False)
+ button.set_sensitive(modified[i])
+ button.set_active(modified[i])
+ dialog.extra_vbox.pack_start(button, expand=True, fill=True)
+ buttons.append(button)
+ dialog.extra_vbox.show_all()
response = dialog.widget.run()
- try_save = [ b.get_active() for b in buttons]
+ try_save = [b.get_active() for b in buttons]
dialog.widget.destroy()
- if response==gtk.RESPONSE_OK:
+ if response == gtk.RESPONSE_OK:
for i in range(self.num_panes):
if try_save[i]:
if not self.save_file(i):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]