[Gnucash-changes] r13832 - gnucash/trunk - Update a report's tab name in the main window when the name in the

David Hampton hampton at cvs.gnucash.org
Sat Apr 22 16:14:42 EDT 2006


Author: hampton
Date: 2006-04-22 16:14:41 -0400 (Sat, 22 Apr 2006)
New Revision: 13832
Trac: http://svn.gnucash.org/trac/changeset/13832

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/gnc-main-window.h
   gnucash/trunk/src/gnome/gnc-plugin-page-register.c
   gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
Update a report's tab name in the main window when the name in the
report options is changed. Fixes #334199.  Also update a register's
tab name if the account name is changed.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-04-22 19:04:02 UTC (rev 13831)
+++ gnucash/trunk/ChangeLog	2006-04-22 20:14:41 UTC (rev 13832)
@@ -1,3 +1,12 @@
+2006-04-22  David Hampton  <hampton at employees.org>
+
+	* src/report/report-gnome/gnc-plugin-page-report.c:
+	* src/gnome-utils/gnc-main-window.[ch]:
+	* src/gnome/gnc-plugin-page-register.c: Update a report's tab name
+	in the main window when the name in the report options is
+	changed. Fixes #334199.  Also update a register's tab name if the
+	account name is changed.
+
 2006-04-22  Christian Stimming  <stimming at tuhh.de>
 
 	* src/gnome/gnc-split-reg.c: Mark string for translation as

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2006-04-22 19:04:02 UTC (rev 13831)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2006-04-22 20:14:41 UTC (rev 13832)
@@ -2796,8 +2796,6 @@
               return;
           }
           if (ei->event_mask & QOF_EVENT_MODIFY) {
-              /* CAS: We need to also handle account renames, but at
-                 least we don't crash for those. */
           }
       }
   }
@@ -2855,32 +2853,18 @@
 }
 
 /** This function is the handler for all event messages from the
- *  engine.  Its purpose is to update the account tree model any time
- *  an account is added to the engine or deleted from the engine.
- *  This change to the model is then propagated to any/all overlying
- *  filters and views.  This function listens to the ADD, REMOVE, and
- *  DESTROY events.
+ *  engine.  Its purpose is to update the register page any time
+ *  an account or transaction is changed.
  *
  *  @internal
  *
- *  @warning There is a "Catch 22" situation here.
- *  gtk_tree_model_row_deleted() can't be called until after the item
- *  has been deleted from the real model (which is the engine's
- *  account tree for us), but once the account has been deleted from
- *  the engine we have no way to determine the path to pass to
- *  row_deleted().  This is a PITA, but the only other choice is to
- *  have this model mirror the engine's accounts instead of
- *  referencing them directly.
+ *  @param entity A pointer to the affected item.
  *
- *  @param entity The guid of the affected item.
+ *  @param event_type The type of the affected item.
  *
- *  @param type The type of the affected item.  This function only
- *  cares about items of type "account".
+ *  @param page A pointer to the register page.
  *
- *  @param event type The type of the event. This function only cares
- *  about items of type ADD, REMOVE, MODIFY, and DESTROY.
- *
- *  @param user_data A pointer to the account tree model.
+ *  @param ed
  */
 static void
 gnc_plugin_page_register_event_handler (QofEntity *entity,
@@ -2894,12 +2878,22 @@
   GtkWidget *window;
 
   g_return_if_fail(page);	/* Required */
-  if (!GNC_IS_TRANS(entity))
+  if (!GNC_IS_TRANS(entity) && !GNC_IS_ACCOUNT(entity))
     return;
 
   ENTER("entity %p of type %d, page %p, event data %p",
 	entity, event_type, page, ed);
 
+  if (GNC_IS_ACCOUNT(entity)) {
+    gchar *label;
+
+    label = gnc_plugin_page_register_get_tab_name(GNC_PLUGIN_PAGE(page));
+    main_window_update_page_name(GNC_PLUGIN_PAGE(page), label);
+    g_free(label);
+    LEAVE("tab name updated");
+    return;
+  }
+
   if (!(event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY))) {
     LEAVE("not a modify");
     return;

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-04-22 19:04:02 UTC (rev 13831)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-04-22 20:14:41 UTC (rev 13832)
@@ -108,8 +108,6 @@
 static void gnc_main_window_setup_window (GncMainWindow *window);
 static void gnc_window_main_window_init (GncWindowIface *iface);
 
-static void main_window_update_page_name (GncMainWindow *window, GncPluginPage *page, const gchar *name_in);
-
 /* Callbacks */
 static void gnc_main_window_add_widget (GtkUIManager *merge, GtkWidget *widget, GncMainWindow *window);
 static void gnc_main_window_switch_page (GtkNotebook *notebook, GtkNotebookPage *notebook_page, gint pos, GncMainWindow *window);
@@ -484,7 +482,7 @@
 	/* Fall through and still show the page. */
       } else {
 	DEBUG("updating page name for %p to %s.", page, name);
-	main_window_update_page_name(window, page, name);
+	main_window_update_page_name(page, name);
 	g_free(name);
       }
     }
@@ -1505,11 +1503,11 @@
   return (*label_p && *entry_p);
 }
 
-static void
-main_window_update_page_name (GncMainWindow *window,
-			      GncPluginPage *page,
+void
+main_window_update_page_name (GncPluginPage *page,
 			      const gchar *name_in)
 {
+  GncMainWindow *window;
   GncMainWindowPrivate *priv;
   GtkWidget *label, *entry;
   gchar *name;
@@ -1528,6 +1526,7 @@
   }
 
   /* Update the plugin */
+  window = GNC_MAIN_WINDOW(page->window);
   priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
   gnc_plugin_page_set_page_name(page, name);
 
@@ -1562,8 +1561,7 @@
     return;
   }
 
-  main_window_update_page_name(GNC_MAIN_WINDOW(page->window), page,
-			       gtk_entry_get_text(GTK_ENTRY(entry)));
+  main_window_update_page_name(page, gtk_entry_get_text(GTK_ENTRY(entry)));
 
   gtk_widget_hide(entry);
   gtk_widget_show(label);

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.h	2006-04-22 19:04:02 UTC (rev 13831)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.h	2006-04-22 20:14:41 UTC (rev 13832)
@@ -146,6 +146,10 @@
 GncPluginPage *gnc_main_window_get_current_page (GncMainWindow *window);
 
 
+void
+main_window_update_page_name (GncPluginPage *page,
+			      const gchar *name_in);
+
 /** Manually add a set of actions to the specified window.  Plugins
  *  whose user interface is not hard coded (e.g. the menu-additions *
  *  plugin) must create their actions at run time, then use this *

Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2006-04-22 19:04:02 UTC (rev 13831)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2006-04-22 20:14:41 UTC (rev 13832)
@@ -546,7 +546,7 @@
 	new_name = gnc_option_db_lookup_string_option(priv->cur_odb, "General",
 						      "Report name", NULL);
 	if (strcmp(old_name, new_name) != 0) {
-	  gnc_plugin_page_set_page_name(GNC_PLUGIN_PAGE(report), new_name);
+	  main_window_update_page_name(GNC_PLUGIN_PAGE(report), new_name);
 	}
 	g_free(new_name);
 
@@ -845,7 +845,6 @@
 
 	report = GNC_PLUGIN_PAGE_REPORT(page);
 	priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
-	printf("%s: reloading is %d\n", __FUNCTION__, priv->reloading);
 	return !priv->reloading;
 }
 



More information about the gnucash-changes mailing list