[Gnucash-changes] r13701 - gnucash/trunk - Add a context menu to the reconcile window. Fixes 120830.

David Hampton hampton at cvs.gnucash.org
Sat Mar 25 18:51:29 EST 2006


Author: hampton
Date: 2006-03-25 18:51:28 -0500 (Sat, 25 Mar 2006)
New Revision: 13701
Trac: http://svn.gnucash.org/trac/changeset/13701

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/gnome/window-reconcile.c
Log:
Add a context menu to the reconcile window.  Fixes 120830.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-25 21:03:46 UTC (rev 13700)
+++ gnucash/trunk/ChangeLog	2006-03-25 23:51:28 UTC (rev 13701)
@@ -1,3 +1,8 @@
+2006-03-25  David Hampton  <david at hampton-pc.rainbolthampton.net>
+
+	* src/gnome/window-reconcile.c: Add a context menu to the
+	reconcile window.  Fixes 120830.
+
 2006-03-25  Derek Atkins  <derek at ihtfp.com>
 
 	* src/gnome-utils/test/Makefile.am:

Modified: gnucash/trunk/src/gnome/window-reconcile.c
===================================================================
--- gnucash/trunk/src/gnome/window-reconcile.c	2006-03-25 21:03:46 UTC (rev 13700)
+++ gnucash/trunk/src/gnome/window-reconcile.c	2006-03-25 23:51:28 UTC (rev 13701)
@@ -802,6 +802,86 @@
   recnRecalculateBalance(recnData);
 }
 
+/** Popup a contextual menu.  This function ends up being called when
+ *  the user right-clicks in the context of a window, or uses the
+ *  keyboard context-menu request key combination (Shift-F10 by
+ *  default).
+ *
+ *  @param recnData This is a data structure describing the
+ *  Reconciliation Window.
+ *
+ *  @param event The event parameter passed to the "button-press"
+ *  callback.  May be null if there was no event (aka keyboard
+ *  request).
+ */
+static void
+do_popup_menu(RecnWindow *recnData, GdkEventButton *event)
+{
+  GtkWidget *menu;
+  int button, event_time;
+
+  menu = gtk_ui_manager_get_widget(recnData->ui_merge, "/MainPopup");
+  if (!menu) {
+    return;
+  }
+
+  if (event) {
+    button = event->button;
+    event_time = event->time;
+  } else {
+    button = 0;
+    event_time = gtk_get_current_event_time ();
+  }
+
+  gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
+}
+
+
+/** Callback function invoked when the user requests that Gnucash
+ *  popup the contextual menu via the keyboard context-menu request
+ *  key combination (Shift-F10 by default).
+ *
+ *  @param recnData This is a data structure describing the
+ *  Reconciliation Window.
+ *
+ *  @param widget Whatever widget had focus when the user issued the
+ *  keyboard context-menu request.
+ *
+ *  @return Always returns TRUE to indicate that the menu request was
+ *  handled.
+ */
+static gboolean
+gnc_reconcile_window_popup_menu_cb (GtkWidget *widget,
+				    RecnWindow *recnData)
+{
+  do_popup_menu(recnData, NULL);
+  return TRUE;
+}
+
+
+/*  Callback function invoked when the user clicks in the content of
+ *  any Gnucash window.  If this was a "right-click" then Gnucash will
+ *  popup the contextual menu.
+ */
+static gboolean
+gnc_reconcile_window_button_press_cb (GtkWidget *widget,
+				      GdkEventButton *event,
+				      RecnWindow *recnData)
+{
+  GtkCList *this_list;
+  gint row, column;
+
+  if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+    this_list = GTK_CLIST(widget);
+    gtk_clist_get_selection_info(this_list, event->x, event->y, &row, &column);
+    gtk_clist_select_row(this_list, row, column);
+    do_popup_menu(recnData, event);
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
 static GNCSplitReg *
 gnc_reconcile_window_open_register(RecnWindow *recnData)
 {
@@ -942,6 +1022,9 @@
   g_signal_connect(list, "toggle_reconciled",
                    G_CALLBACK(gnc_reconcile_window_list_cb),
                    recnData);
+  g_signal_connect(list, "button_press_event",
+                   G_CALLBACK(gnc_reconcile_window_button_press_cb),
+                   recnData);
   g_signal_connect(list, "double_click_split",
                    G_CALLBACK(gnc_reconcile_window_double_click_cb),
                    recnData);
@@ -1503,6 +1586,9 @@
 				      gnc_toolbar_change_cb, recnData);
   }
 
+  g_signal_connect(recnData->window, "popup-menu",
+		   G_CALLBACK(gnc_reconcile_window_popup_menu_cb), recnData);
+
   statusbar = gtk_statusbar_new();
   gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), TRUE);
   gtk_box_pack_end(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);



More information about the gnucash-changes mailing list