[meld] Modernise the commit dialog UI
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Modernise the commit dialog UI
- Date: Thu, 25 Apr 2013 03:22:58 +0000 (UTC)
commit 305ab322c331d1ce523068ef341e1762c290a454
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Apr 22 07:58:49 2013 +1000
Modernise the commit dialog UI
The commit dialog no longer conforms to the HIG from GNOME 1.4.
HistoryEntry has been split to provide a HistoryCombo class that acts
the same as the entry, but without text editing capabilities.
data/ui/vcview.ui | 388 ++++++++++++++++++++++++----------------------
meld/ui/historyentry.py | 65 ++++++---
meld/vcview.py | 36 ++---
3 files changed, 264 insertions(+), 225 deletions(-)
---
diff --git a/data/ui/vcview.ui b/data/ui/vcview.ui
index a1acebc..28dda75 100644
--- a/data/ui/vcview.ui
+++ b/data/ui/vcview.ui
@@ -227,260 +227,276 @@
<object class="GtkDialog" id="commitdialog">
<property name="width_request">450</property>
<property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="can_focus">False</property>
<property name="title" translatable="yes">Commit</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">True</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
+ <property name="window_position">center</property>
+ <property name="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="homogeneous">False</property>
- <property name="spacing">0</property>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <object class="GtkButton" id="cancelbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="okbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <accelerator key="Return" modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <accelerator key="KP_Enter" modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </object>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
+ <property name="can_focus">False</property>
+ <property name="spacing">18</property>
<child>
- <object class="GtkVBox" id="vbox1">
- <property name="border_width">5</property>
+ <object class="GtkVBox" id="vbox0">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">18</property>
<child>
- <object class="GtkFrame" id="frame2">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow_changed">
- <property name="border_width">10</property>
- <property name="height_request">150</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Commit Files</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkViewport" id="viewport_changed">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">12</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow_changed">
+ <property name="height_request">150</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkLabel" id="changedfiles">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes"/>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <object class="GtkViewport" id="viewport_changed">
+ <property name="can_focus">False</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkLabel" id="changedfiles">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Commit Files</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
- <property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame1">
+ <object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkVBox" id="vbox2">
+ <object class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Log Message</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="border_width">10</property>
- <property name="width_request">320</property>
- <property name="height_request">200</property>
+ <object class="GtkLabel" id="label4">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
- <child>
- <object class="GtkTextView" id="textview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="overwrite">False</property>
- <property name="accepts_tab">True</property>
- <property name="justification">GTK_JUSTIFY_LEFT</property>
- <property name="wrap_mode">GTK_WRAP_NONE</property>
- <property name="cursor_visible">True</property>
- <property name="pixels_above_lines">0</property>
- <property name="pixels_below_lines">0</property>
- <property name="pixels_inside_wrap">0</property>
- <property name="left_margin">0</property>
- <property name="right_margin">0</property>
- <property name="indent">0</property>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="xpad">12</property>
</object>
<packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="previousbox">
+ <object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="previouslogs_label">
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="width_request">320</property>
+ <property name="height_request">200</property>
<property name="visible">True</property>
- <property name="label" translatable="yes">Previous Logs</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">5</property>
- <property name="ypad">5</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="textview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="HistoryEntry" id="previousentry">
- <property name="border_width">5</property>
+ <object class="GtkHBox" id="previousbox">
<property name="visible">True</property>
- <property name="history-id">previousentry</property>
- <signal handler="on_previousentry_activate" name="changed"/>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="previouslogs_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Previous logs:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="HistoryCombo" id="previousentry">
+ <property name="visible">True</property>
+ <property name="history-id">previousentry</property>
+ <signal handler="on_previousentry_activate" name="changed"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="padding">5</property>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Log Message</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
</child>
</object>
<packing>
- <property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <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="cancelbutton1">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</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="okbutton1">
+ <property name="label" translatable="yes">Co_mmit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <accelerator key="KP_Enter" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ <accelerator key="Return" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ </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>
</object>
diff --git a/meld/ui/historyentry.py b/meld/ui/historyentry.py
index 36a8c4c..c584481 100644
--- a/meld/ui/historyentry.py
+++ b/meld/ui/historyentry.py
@@ -35,6 +35,7 @@ from ..util.compat import text_type
MIN_ITEM_LEN = 3
HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT = 10
+
def _remove_item(store, text):
if text is None:
return False
@@ -45,44 +46,35 @@ def _remove_item(store, text):
return True
return False
+
def _clamp_list_store(liststore, max_items):
try:
- it = liststore.get_iter(max_items - 1) # -1 because TreePath counts from 0
+ # -1 because TreePath counts from 0
+ it = liststore.get_iter(max_items - 1)
except ValueError:
return
valid = True
while valid:
valid = liststore.remove(it)
+
def _escape_cell_data_func(col, renderer, model, it, escape_func):
string = model.get(it, 0)
escaped = escape_func(string)
renderer.set("text", escaped)
-class HistoryEntry(gtk.ComboBoxEntry):
- __gtype_name__ = "HistoryEntry"
-
- __gproperties__ = {
- "history-id": (str, "History ID",
- "Identifier associated with entry's history store",
- None, gobject.PARAM_READWRITE),
- }
+class HistoryWidget(object):
def __init__(self, history_id=None, enable_completion=False, **kwargs):
- super(HistoryEntry, self).__init__(**kwargs)
-
self.__history_id = history_id
self.__history_length = HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT
self.__completion = None
self._get_gconf_client()
self.set_model(gtk.ListStore(str))
- self.props.text_column = 0
-
self.set_enable_completion(enable_completion)
-
def do_get_property(self, pspec):
if pspec.name == "history-id":
return self.__history_id
@@ -107,8 +99,8 @@ class HistoryEntry(gtk.ComboBoxEntry):
# We store data under /apps/gnome-settings/ like GnomeEntry did.
if not self.__history_id:
return None
- key = ''.join(["/apps/gnome-settings/","meld","/history-",
- gconf.escape_key(self.__history_id, -1)])
+ key = ''.join(["/apps/gnome-settings/", "meld", "/history-",
+ gconf.escape_key(self.__history_id, -1)])
return key
def _save_history(self):
@@ -132,12 +124,12 @@ class HistoryEntry(gtk.ComboBoxEntry):
store.append((text,))
self._save_history()
- def prepend_text(self, text):
+ def prepend_history(self, text):
if not text:
return
self.__insert_history_item(text, True)
- def append_text(self, text):
+ def append_history(self, text):
if not text:
return
self.__insert_history_item(text, False)
@@ -206,6 +198,39 @@ class HistoryEntry(gtk.ComboBoxEntry):
else:
self.set_cell_data_func(cells[0], None, None)
+
+class HistoryCombo(gtk.ComboBox, HistoryWidget):
+ __gtype_name__ = "HistoryCombo"
+
+ __gproperties__ = {
+ "history-id": (str, "History ID",
+ "Identifier associated with entry's history store",
+ None, gobject.PARAM_READWRITE),
+ }
+
+ def __init__(self, history_id=None, **kwargs):
+ super(HistoryCombo, self).__init__(**kwargs)
+ HistoryWidget.__init__(self, history_id)
+ rentext = gtk.CellRendererText()
+ self.pack_start(rentext, True)
+ self.set_attributes(rentext, text=0)
+
+
+class HistoryEntry(gtk.ComboBoxEntry, HistoryWidget):
+ __gtype_name__ = "HistoryEntry"
+
+ __gproperties__ = {
+ "history-id": (str, "History ID",
+ "Identifier associated with entry's history store",
+ None, gobject.PARAM_READWRITE),
+ }
+
+ def __init__(self, history_id=None, enable_completion=False, **kwargs):
+ super(HistoryEntry, self).__init__(**kwargs)
+ HistoryWidget.__init__(self, history_id, enable_completion)
+ self.props.text_column = 0
+
+
try:
import gconf
except ImportError:
@@ -352,10 +377,10 @@ class HistoryFileEntry(gtk.HBox, gtk.Editable):
last_open[self.props.history_id] = path
def append_history(self, text):
- self.__gentry.append_text(text)
+ self.__gentry.append_history(text)
def prepend_history(self, text):
- self.__gentry.prepend_text(text)
+ self.__gentry.prepend_history(text)
def focus_entry(self):
self.__gentry.focus_entry()
diff --git a/meld/vcview.py b/meld/vcview.py
index 0e1caea..e7fc141 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -82,43 +82,41 @@ _temp_dirs, _temp_files = [], []
atexit.register(cleanup_temp)
-################################################################################
-#
-# CommitDialog
-#
-################################################################################
class CommitDialog(gnomeglade.Component):
+
def __init__(self, parent):
- gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"), "commitdialog")
+ gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"),
+ "commitdialog")
self.parent = parent
- self.widget.set_transient_for( parent.widget.get_toplevel() )
+ self.widget.set_transient_for(parent.widget.get_toplevel())
selected = parent._get_selected_files()
topdir = _commonprefix(selected)
- selected = [ s[len(topdir):] for s in selected ]
- self.changedfiles.set_text( ("(in %s) "%topdir) + " ".join(selected) )
+ selected = [s[len(topdir):] for s in selected]
+ self.changedfiles.set_text("(in %s) %s" % (topdir, " ".join(selected)))
self.widget.show_all()
def run(self):
- self.previousentry.child.set_editable(False)
- self.previousentry.set_active(0)
+ self.previousentry.set_active(-1)
self.textview.grab_focus()
- buf = self.textview.get_buffer()
- buf.place_cursor( buf.get_start_iter() )
- buf.move_mark( buf.get_selection_bound(), buf.get_end_iter() )
response = self.widget.run()
- msg = buf.get_text(buf.get_start_iter(), buf.get_end_iter(), 0)
if response == gtk.RESPONSE_OK:
- self.parent._command_on_selected( self.parent.vc.commit_command(msg) )
- if len(msg.strip()):
- self.previousentry.prepend_text(msg)
+ buf = self.textview.get_buffer()
+ msg = buf.get_text(*buf.get_bounds(), include_hidden_chars=False)
+ self.parent._command_on_selected(
+ self.parent.vc.commit_command(msg))
+ if msg.strip():
+ self.previousentry.prepend_history(msg)
self.widget.destroy()
+
def on_previousentry_activate(self, gentry):
buf = self.textview.get_buffer()
- buf.set_text( gentry.child.get_text() )
+ buf.set_text(gentry.get_active_text())
+
COL_LOCATION, COL_STATUS, COL_REVISION, COL_TAG, COL_OPTIONS, COL_END = \
list(range(tree.COL_END, tree.COL_END+6))
+
class VcTreeStore(tree.DiffTreeStore):
def __init__(self):
tree.DiffTreeStore.__init__(self, 1, [str] * 5)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]