[Gnucash-changes] r13803 - gnucash/trunk - Parse the old
~/.gnome/GnuCash MDI document file to see which 1.8
David Hampton
hampton at cvs.gnucash.org
Tue Apr 18 22:35:41 EDT 2006
Author: hampton
Date: 2006-04-18 22:35:39 -0400 (Tue, 18 Apr 2006)
New Revision: 13803
Trac: http://svn.gnucash.org/trac/changeset/13803
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/gnome/top-level.c
gnucash/trunk/src/report/report-gnome/window-report.c
gnucash/trunk/src/report/report-gnome/window-report.h
Log:
Parse the old ~/.gnome/GnuCash MDI document file to see which 1.8
reports should be opened the first time gnucash2 starts.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-04-18 19:28:30 UTC (rev 13802)
+++ gnucash/trunk/ChangeLog 2006-04-19 02:35:39 UTC (rev 13803)
@@ -1,3 +1,10 @@
+2006-04-18 David Hampton <hampton at employees.org>
+
+ * src/report/report-gnome/window-report.[ch]:
+ * src/gnome/top-level.c: Parse the old ~/.gnome/GnuCash MDI
+ document file to see which 1.8 reports should be opened the first
+ time gnucash2 starts.
+
2006-04-18 Christian Stimming <stimming at tuhh.de>
* po/fr.po: Updated French translation by Jonathan Ernst.
Modified: gnucash/trunk/src/gnome/top-level.c
===================================================================
--- gnucash/trunk/src/gnome/top-level.c 2006-04-18 19:28:30 UTC (rev 13802)
+++ gnucash/trunk/src/gnome/top-level.c 2006-04-19 02:35:39 UTC (rev 13803)
@@ -252,7 +252,7 @@
SCM_BOOL_F));
/* At this point the reports have only been loaded into
memory. Now we create their ui component. */
- gnc_reports_show_all();
+ gnc_reports_show_all(session);
#endif
LEAVE("old");
Modified: gnucash/trunk/src/report/report-gnome/window-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.c 2006-04-18 19:28:30 UTC (rev 13802)
+++ gnucash/trunk/src/report/report-gnome/window-report.c 2006-04-19 02:35:39 UTC (rev 13803)
@@ -37,6 +37,7 @@
#include "dialog-options.h"
#include "file-utils.h"
+#include "gnc-gkeyfile-utils.h"
#include "gnc-report.h"
#include "gnc-ui.h"
#include "option-util.h"
@@ -47,8 +48,8 @@
#include "gnc-report.h"
#define WINDOW_REPORT_CM_CLASS "window-report"
+#define MDI_CHILD_CONFIG "mdi_child_config"
-
/********************************************************************
*
********************************************************************/
@@ -320,79 +321,52 @@
}
-static gboolean
-remove_invalid_report(gpointer key, gpointer val, gpointer data)
+void
+gnc_reports_show_all(QofSession *session)
{
- SCM report = val;
- gchar *name = NULL;
+ GKeyFile *keyfile;
+ const gchar *home, *url;
+ gchar *encoded_url, *mdi_file, *mdi_group, *value;
+ gchar **keys, **key;
+ gint report_id;
- if (NULL == (name = gnc_report_name(report)))
- return TRUE;
+ url = qof_session_get_url(session);
+ if (!url)
+ return;
+ encoded_url = gnc_html_encode_string(url);
+ if (!encoded_url)
+ return;
- g_free(name);
- return FALSE;
-}
+ home = g_get_home_dir();
+ if (!home) {
+ g_free(encoded_url);
+ return;
+ }
-static gboolean
-remove_old_report(gpointer key, gpointer val, gpointer data)
-{
- SCM report = val;
- GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG(data);
- gchar *name = NULL;
- gchar *msg;
- gint response;
-
- name = gnc_report_name(report);
- msg = g_strdup_printf(_("Do you want to display '%s'?"), name);
- gtk_message_dialog_set_markup(dialog, msg);
- response = gtk_dialog_run(GTK_DIALOG(dialog));
- g_free(msg);
- g_free(name);
- return (response == GTK_RESPONSE_NO);
-}
+ mdi_file = g_build_filename(home, ".gnome", "GnuCash", (gchar *)NULL);
+ mdi_group = g_strdup_printf("MDI : %s", encoded_url);
-static void
-show_report(gpointer key, gpointer val, gpointer data)
-{
- gnc_main_window_open_report(*(gint *)key, NULL);
-}
-
-void
-gnc_reports_show_all(void)
-{
- GHashTable *reports = gnc_reports_get_global();
-
- if (reports) {
- GtkWidget *dialog;
- guint num_reports;
- gint response;
- gchar *msg;
-
- g_hash_table_foreach_remove(reports, remove_invalid_report, NULL);
- num_reports = g_hash_table_size(reports);
- if (num_reports > 3) {
- msg = g_strdup_printf(
- _("GnuCash has found %d reports from an earlier version of "
- "GnuCash but can't tell which ones you had open. You will "
- "now have the option to open each report or not. From now "
- "on, GnuCash will remember which reports you leave open, so "
- "you won't see this message again."), num_reports);
- dialog = gtk_message_dialog_new(
- NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK_CANCEL, msg);
- response = gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- g_free(msg);
- if (response == GTK_RESPONSE_OK) {
- GtkWidget *dialog = gtk_message_dialog_new(
- NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO, NULL);
- g_hash_table_foreach_remove(reports, remove_old_report,
- dialog);
- gtk_widget_destroy(dialog);
- g_hash_table_foreach(reports, show_report, NULL);
- }
- } else
- g_hash_table_foreach(reports, show_report, NULL);
+ keyfile = gnc_key_file_load_from_file (mdi_file, FALSE, FALSE);
+ if (keyfile) {
+ keys = g_key_file_get_keys(keyfile, mdi_group, NULL, NULL);
+ if (keys) {
+ for (key = keys; *key; key++) {
+ if (!strncmp(*key, MDI_CHILD_CONFIG, sizeof(MDI_CHILD_CONFIG)))
+ continue;
+ value = g_key_file_get_string(keyfile, mdi_group, *key, NULL);
+ if (!value)
+ continue;
+ if (sscanf(value, "gnc-report:id=%d", &report_id) == 1) {
+ gnc_main_window_open_report(report_id, NULL);
+ }
+ g_free(value);
+ }
+ g_strfreev(keys);
}
+ g_key_file_free(keyfile);
+ }
+
+ g_free(mdi_file);
+ g_free(mdi_group);
+ g_free(encoded_url);
}
Modified: gnucash/trunk/src/report/report-gnome/window-report.h
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.h 2006-04-18 19:28:30 UTC (rev 13802)
+++ gnucash/trunk/src/report/report-gnome/window-report.h 2006-04-19 02:35:39 UTC (rev 13803)
@@ -26,6 +26,7 @@
#include <libguile.h>
#include "gnc-html.h"
+#include "qof.h"
typedef struct gnc_report_window_s gnc_report_window;
@@ -45,5 +46,5 @@
// module[/plugin]-init
void gnc_report_init (void);
-void gnc_reports_show_all(void);
+void gnc_reports_show_all (QofSession *session);
#endif
More information about the gnucash-changes
mailing list