mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Parse the old ~/.gnome/GnuCash MDI document file to see which 1.8
reports should be opened the first time gnucash2 starts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13803 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2006-04-18 David Hampton <hampton@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@tuhh.de>
|
2006-04-18 Christian Stimming <stimming@tuhh.de>
|
||||||
|
|
||||||
* po/fr.po: Updated French translation by Jonathan Ernst.
|
* po/fr.po: Updated French translation by Jonathan Ernst.
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ gnc_restore_all_state (gpointer session, gpointer unused)
|
|||||||
SCM_BOOL_F));
|
SCM_BOOL_F));
|
||||||
/* At this point the reports have only been loaded into
|
/* At this point the reports have only been loaded into
|
||||||
memory. Now we create their ui component. */
|
memory. Now we create their ui component. */
|
||||||
gnc_reports_show_all();
|
gnc_reports_show_all(session);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LEAVE("old");
|
LEAVE("old");
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "dialog-options.h"
|
#include "dialog-options.h"
|
||||||
#include "file-utils.h"
|
#include "file-utils.h"
|
||||||
|
#include "gnc-gkeyfile-utils.h"
|
||||||
#include "gnc-report.h"
|
#include "gnc-report.h"
|
||||||
#include "gnc-ui.h"
|
#include "gnc-ui.h"
|
||||||
#include "option-util.h"
|
#include "option-util.h"
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
#include "gnc-report.h"
|
#include "gnc-report.h"
|
||||||
|
|
||||||
#define WINDOW_REPORT_CM_CLASS "window-report"
|
#define WINDOW_REPORT_CM_CLASS "window-report"
|
||||||
|
#define MDI_CHILD_CONFIG "mdi_child_config"
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
@@ -320,79 +321,52 @@ gnc_report_init (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
remove_invalid_report(gpointer key, gpointer val, gpointer data)
|
|
||||||
{
|
|
||||||
SCM report = val;
|
|
||||||
gchar *name = NULL;
|
|
||||||
|
|
||||||
if (NULL == (name = gnc_report_name(report)))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
g_free(name);
|
|
||||||
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;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
show_report(gpointer key, gpointer val, gpointer data)
|
|
||||||
{
|
|
||||||
gnc_main_window_open_report(*(gint *)key, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_reports_show_all(void)
|
gnc_reports_show_all(QofSession *session)
|
||||||
{
|
{
|
||||||
GHashTable *reports = gnc_reports_get_global();
|
GKeyFile *keyfile;
|
||||||
|
const gchar *home, *url;
|
||||||
if (reports) {
|
gchar *encoded_url, *mdi_file, *mdi_group, *value;
|
||||||
GtkWidget *dialog;
|
gchar **keys, **key;
|
||||||
guint num_reports;
|
gint report_id;
|
||||||
gint response;
|
|
||||||
gchar *msg;
|
url = qof_session_get_url(session);
|
||||||
|
if (!url)
|
||||||
g_hash_table_foreach_remove(reports, remove_invalid_report, NULL);
|
return;
|
||||||
num_reports = g_hash_table_size(reports);
|
encoded_url = gnc_html_encode_string(url);
|
||||||
if (num_reports > 3) {
|
if (!encoded_url)
|
||||||
msg = g_strdup_printf(
|
return;
|
||||||
_("GnuCash has found %d reports from an earlier version of "
|
|
||||||
"GnuCash but can't tell which ones you had open. You will "
|
home = g_get_home_dir();
|
||||||
"now have the option to open each report or not. From now "
|
if (!home) {
|
||||||
"on, GnuCash will remember which reports you leave open, so "
|
g_free(encoded_url);
|
||||||
"you won't see this message again."), num_reports);
|
return;
|
||||||
dialog = gtk_message_dialog_new(
|
}
|
||||||
NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
|
|
||||||
GTK_BUTTONS_OK_CANCEL, msg);
|
mdi_file = g_build_filename(home, ".gnome", "GnuCash", (gchar *)NULL);
|
||||||
response = gtk_dialog_run(GTK_DIALOG(dialog));
|
mdi_group = g_strdup_printf("MDI : %s", encoded_url);
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
g_free(msg);
|
keyfile = gnc_key_file_load_from_file (mdi_file, FALSE, FALSE);
|
||||||
if (response == GTK_RESPONSE_OK) {
|
if (keyfile) {
|
||||||
GtkWidget *dialog = gtk_message_dialog_new(
|
keys = g_key_file_get_keys(keyfile, mdi_group, NULL, NULL);
|
||||||
NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
|
if (keys) {
|
||||||
GTK_BUTTONS_YES_NO, NULL);
|
for (key = keys; *key; key++) {
|
||||||
g_hash_table_foreach_remove(reports, remove_old_report,
|
if (!strncmp(*key, MDI_CHILD_CONFIG, sizeof(MDI_CHILD_CONFIG)))
|
||||||
dialog);
|
continue;
|
||||||
gtk_widget_destroy(dialog);
|
value = g_key_file_get_string(keyfile, mdi_group, *key, NULL);
|
||||||
g_hash_table_foreach(reports, show_report, NULL);
|
if (!value)
|
||||||
}
|
continue;
|
||||||
} else
|
if (sscanf(value, "gnc-report:id=%d", &report_id) == 1) {
|
||||||
g_hash_table_foreach(reports, show_report, NULL);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
|
|
||||||
#include "gnc-html.h"
|
#include "gnc-html.h"
|
||||||
|
#include "qof.h"
|
||||||
|
|
||||||
typedef struct gnc_report_window_s gnc_report_window;
|
typedef struct gnc_report_window_s gnc_report_window;
|
||||||
|
|
||||||
@@ -45,5 +46,5 @@ void gnc_report_raise_editor(SCM report);
|
|||||||
// module[/plugin]-init
|
// module[/plugin]-init
|
||||||
void gnc_report_init (void);
|
void gnc_report_init (void);
|
||||||
|
|
||||||
void gnc_reports_show_all(void);
|
void gnc_reports_show_all (QofSession *session);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user