[Gnucash-changes] r13694 - gnucash/trunk/src/report/report-gnome - When opening GnuCash for the first time since 1.8.x, allow the user to

Chris Shoemaker chris at cvs.gnucash.org
Thu Mar 23 21:01:18 EST 2006


Author: chris
Date: 2006-03-23 21:01:18 -0500 (Thu, 23 Mar 2006)
New Revision: 13694
Trac: http://svn.gnucash.org/trac/changeset/13694

Modified:
   gnucash/trunk/src/report/report-gnome/window-report.c
Log:
   When opening GnuCash for the first time since 1.8.x, allow the user to 
   choose which reports (if any) to open.  If the user cancels the dialog,
   no reports are opened, otherwise, for each report, they are asked whether
   or not they want to open it.  However, if there are less than 4 reports
   the dialog is skipped and the reports are just opened.  Closes bug#335188.

   Note: if someone implements a solution that opened only precisely the
   reports that were left open in 1.8.x, it's fine to remove this extra code.


Modified: gnucash/trunk/src/report/report-gnome/window-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/window-report.c	2006-03-24 00:20:00 UTC (rev 13693)
+++ gnucash/trunk/src/report/report-gnome/window-report.c	2006-03-24 02:01:18 UTC (rev 13694)
@@ -333,6 +333,24 @@
     return FALSE;
 }
 
+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, *str = _("Do you want to display '%s'?");
+    gint response;
+    
+    name = gnc_report_name(report);
+    msg = g_strdup_printf(str, 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);
+}    
+
 static void
 show_report(gpointer key, gpointer val, gpointer data)
 {
@@ -345,7 +363,36 @@
     GHashTable *reports = gnc_reports_get_global();
     
     if (reports) {
+        GtkWidget *dialog;
+        guint num_reports;
+        gint response;
+        gchar *msg, *str = 
+            _("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.");
+        
         g_hash_table_foreach_remove(reports, remove_invalid_report, NULL);
-        g_hash_table_foreach(reports, show_report, NULL);
+        num_reports = g_hash_table_size(reports);
+        if (num_reports > 3) {
+            msg = g_strdup_printf(str, 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);
     }
 }



More information about the gnucash-changes mailing list