gEDA-dev: [PATCH 1/1] Make the Escape key cancel editing in the multiattrib dialog.
Peter Clifton
pcjc2 at cam.ac.uk
Tue Jul 17 15:53:27 EDT 2007
The previous behaviour where it would quit editing but save the changes is
counter-intuitive for the user.
---
gschem/include/x_multiattrib.h | 1 +
gschem/src/x_multiattrib.c | 34 +++++++++++++++++++++-------------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/gschem/include/x_multiattrib.h b/gschem/include/x_multiattrib.h
index 59a21b8..f3aee9c 100644
--- a/gschem/include/x_multiattrib.h
+++ b/gschem/include/x_multiattrib.h
@@ -87,6 +87,7 @@ struct _CellTextViewClass {
struct _CellTextView {
GtkTextView parent_instance;
+ gboolean editing_canceled;
};
diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index 21fadc8..2ac14c8 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -119,19 +119,21 @@ static void celltextview_cell_editable_init (GtkCellEditableIface *iface);
*
*/
static gboolean celltextview_key_press_event (GtkWidget *widget,
- GdkEventKey *event,
- gpointer data)
+ GdkEventKey *key_event,
+ gpointer data)
{
CellTextView *celltextview = (CellTextView*)widget;
- /* ends editing of cell if one of these keys are pressed */
- if (
- /* the Escape key */
- event->keyval == GDK_Escape ||
- /* the Enter key without the Control modifier */
- (!(event->state & GDK_CONTROL_MASK) &&
- (event->keyval == GDK_Return ||
- event->keyval == GDK_KP_Enter))) {
+ /* If the Escape key is pressed, we flag the edit as canceled */
+ if (key_event->keyval == GDK_Escape)
+ celltextview->editing_canceled = TRUE;
+
+ /* ends editing of cell if one of these keys are pressed or editing is canceled */
+ if (celltextview->editing_canceled == TRUE ||
+ /* the Enter key without the Control modifier */
+ (!(key_event->state & GDK_CONTROL_MASK) &&
+ (key_event->keyval == GDK_Return ||
+ key_event->keyval == GDK_KP_Enter))) {
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (celltextview));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (celltextview));
return TRUE;
@@ -209,8 +211,9 @@ static void celltextview_class_init(CellTextViewClass *klass)
* \par Function Description
*
*/
-static void celltextview_init(CellTextView *self)
+static void celltextview_init(CellTextView *celltextview)
{
+ celltextview->editing_canceled = FALSE;
}
/*! \todo Finish function documentation
@@ -318,17 +321,22 @@ static void cellrenderermultilinetext_editing_done(GtkCellEditable *cell_editabl
cell->focus_out_id = 0;
}
+ gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell),
+ CELL_TEXT_VIEW (cell_editable)->editing_canceled);
+ if (CELL_TEXT_VIEW (cell_editable)->editing_canceled)
+ return;
+
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (cell_editable));
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
new_text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
-
+
path = g_object_get_data (G_OBJECT (cell_editable),
CELL_RENDERER_MULTI_LINE_TEXT_PATH);
g_signal_emit_by_name (cell, "edited", path, new_text);
g_free (new_text);
-
+
}
/*! \todo Finish function documentation
--
1.5.2.3
More information about the geda-dev
mailing list