r17134 - gnucash/branches/2.2/src/gnome - [r17061] Improve cancel behavior in reconciliation window.

Andreas Köhler andi5 at cvs.gnucash.org
Sat Apr 26 12:49:46 EDT 2008


Author: andi5
Date: 2008-04-26 12:49:46 -0400 (Sat, 26 Apr 2008)
New Revision: 17134
Trac: http://svn.gnucash.org/trac/changeset/17134

Modified:
   gnucash/branches/2.2/src/gnome/window-reconcile.c
Log:
[r17061] Improve cancel behavior in reconciliation window.

Allow cancelling the window by pressing ESC.  Always let the user
confirm the cancel on changes, even when closing the window with the
window manager.


Modified: gnucash/branches/2.2/src/gnome/window-reconcile.c
===================================================================
--- gnucash/branches/2.2/src/gnome/window-reconcile.c	2008-04-26 16:49:37 UTC (rev 17133)
+++ gnucash/branches/2.2/src/gnome/window-reconcile.c	2008-04-26 16:49:46 UTC (rev 17134)
@@ -134,6 +134,9 @@
 static gnc_numeric recnRecalculateBalance (RecnWindow *recnData);
 
 static void   recn_destroy_cb (GtkWidget *w, gpointer data);
+static void   recn_cancel (RecnWindow *recnData);
+static gboolean recn_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer data);
+static gboolean recn_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data);
 static void   recnFinishCB (GtkAction *action, RecnWindow *recnData);
 static void   recnPostponeCB (GtkAction *action, gpointer data);
 static void   recnCancelCB (GtkAction *action, gpointer data);
@@ -1609,6 +1612,10 @@
 
   g_signal_connect (recnData->window, "destroy",
                     G_CALLBACK(recn_destroy_cb), recnData);
+  g_signal_connect (recnData->window, "delete_event",
+                    G_CALLBACK(recn_delete_cb), recnData);
+  g_signal_connect (recnData->window, "key_press_event",
+                    G_CALLBACK(recn_key_press_cb), recnData);
 
 
   /* The main area */
@@ -1800,7 +1807,49 @@
   g_free (recnData);
 }
 
+static void
+recn_cancel(RecnWindow *recnData)
+{
+  gboolean changed = FALSE;
 
+  if (gnc_reconcile_list_changed(GNC_RECONCILE_LIST(recnData->credit)))
+    changed = TRUE;
+  if (gnc_reconcile_list_changed(GNC_RECONCILE_LIST(recnData->debit)))
+    changed = TRUE;
+
+  if (changed)
+  {
+    const char *message = _("You have made changes to this reconcile "
+                            "window. Are you sure you want to cancel?");
+    if (!gnc_verify_dialog(recnData->window, FALSE, message))
+      return;
+  }
+
+  gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
+}
+
+static gboolean
+recn_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+  RecnWindow *recnData = data;
+
+  recn_cancel(recnData);
+  return TRUE;
+}
+
+static gboolean
+recn_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+  RecnWindow *recnData = data;
+
+  if (event->keyval == GDK_Escape) {
+    recn_cancel(recnData);
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+
 /********************************************************************\
  * find_payment_account                                             *
  *   find an account that 'looks like' a payment account for the    *
@@ -1964,22 +2013,7 @@
 recnCancelCB (GtkAction *action, gpointer data)
 {
   RecnWindow *recnData = data;
-  gboolean changed = FALSE;
-
-  if (gnc_reconcile_list_changed(GNC_RECONCILE_LIST(recnData->credit)))
-    changed = TRUE;
-  if (gnc_reconcile_list_changed(GNC_RECONCILE_LIST(recnData->debit)))
-    changed = TRUE;
-
-  if (changed)
-  {
-    const char *message = _("You have made changes to this reconcile "
-                            "window. Are you sure you want to cancel?");
-    if (!gnc_verify_dialog(recnData->window, FALSE, message))
-      return;
-  }
-
-  gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
+  recn_cancel(recnData);
 }
 
 /** An array of all of the actions provided by the main window code.



More information about the gnucash-changes mailing list