2001-04-13 Bill Gribble <grib@billgribble.com>

* Bug fixes and a couple of new features for MDI stuff.

	* src/scm/prefs.scm: new option to set MDI mode (prefs/general)

	* src/gnome/{window-acct-tree.c,window-report.c,window-main.c}:
	bug fixes to handle runtime MDI mode changes.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3963 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-04-13 21:30:39 +00:00
parent 314acd7439
commit f99447e9f8
9 changed files with 259 additions and 28 deletions

View File

@@ -1,3 +1,12 @@
2001-04-13 Bill Gribble <grib@billgribble.com>
* Bug fixes and a couple of new features for MDI stuff.
* src/scm/prefs.scm: new option to set MDI mode (prefs/general)
* src/gnome/{window-acct-tree.c,window-report.c,window-main.c}:
bug fixes to handle runtime MDI mode changes.
2001-04-13 Dave Peticolas <dave@krondo.com>
* src/scm/report/*: update several reports to use

View File

@@ -1,3 +1,49 @@
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.36.
* cat-id-tbl.c: Remove file.
* stamp-cat-id: Remove file.
2001-03-14 Dave Peticolas <dave@krondo.com>
* da.po: add Danish translation

View File

@@ -24,6 +24,8 @@
#include "config.h"
#include <gnome.h>
#include "account-tree.h"
#include "dialog-utils.h"
#include "global-options.h"
@@ -318,6 +320,33 @@ gnc_get_toolbar_style(void)
return tbstyle;
}
/********************************************************************
* gnc_get_mdi_mode *
* returns the current Gnome MDI mode preference *
********************************************************************/
GnomeMDIMode
gnc_get_mdi_mode(void) {
GnomeMDIMode mode = GNOME_MDI_DEFAULT_MODE;
char * mode_string = gnc_lookup_multichoice_option("General",
"Application MDI mode",
"");
if(!safe_strcmp(mode_string, "mdi-notebook")) {
mode = GNOME_MDI_NOTEBOOK;
}
else if(!safe_strcmp(mode_string, "mdi-toplevel")) {
mode = GNOME_MDI_TOPLEVEL;
}
else if(!safe_strcmp(mode_string, "mdi-modal")) {
mode = GNOME_MDI_MODAL;
}
else if(!safe_strcmp(mode_string, "mdi-default")) {
mode = GNOME_MDI_DEFAULT_MODE;
}
if(mode_string) free(mode_string);
return mode;
}
/********************************************************************\
* gnc_get_deficit_color *

View File

@@ -59,6 +59,7 @@ GtkWidget * gnc_get_pixmap (const char *name);
GdkImlibImage * gnc_get_gdk_imlib_image (const char *name);
GtkToolbarStyle gnc_get_toolbar_style (void);
GnomeMDIMode gnc_get_mdi_mode(void);
void gnc_get_deficit_color (GdkColor *color);
void gnc_set_label_color (GtkWidget *label, gnc_numeric value);

View File

@@ -91,33 +91,41 @@ struct GNCAcctTreeWin_p
/********************************************************************
* acct_labeler
* fixme: we need to be able to dynamically select account tab names
********************************************************************/
static GtkWidget *
gnc_acct_tree_view_labeler(GnomeMDIChild * child, GtkWidget * current,
gpointer user_data) {
GNCMainChildInfo * mc = gtk_object_get_user_data(GTK_OBJECT(child));
GNCAcctTreeWin * win = mc->user_data;
GNCAcctTreeWin * win = NULL;
char * name = NULL;
if(win) {
name = gnc_option_db_lookup_string_option(win->odb,
"Account Tree",
"Name of account view",
NULL);
if(mc) {
win = mc->user_data;
if(win) {
name = gnc_option_db_lookup_string_option(win->odb,
"Account Tree",
"Name of account view",
NULL);
}
else {
name = strdup("Accounts");
}
g_free(mc->title);
mc->title = g_strdup(name);
}
else {
name = strdup("Accounts");
}
if(current == NULL) {
return gtk_label_new(name);
current = gtk_label_new(name);
}
else {
gtk_label_set_text(GTK_LABEL(current), name);
return current;
}
gtk_label_set_justify(GTK_LABEL(current), GTK_JUSTIFY_LEFT);
return current;
}
@@ -130,6 +138,7 @@ gnc_acct_tree_view_destroy(GtkObject * obj, gpointer user_data) {
gnc_acct_tree_window_destroy(w);
g_free(mc->toolbar_info);
g_free(mc->menu_info);
g_free(mc->title);
g_free(mc);
}
@@ -148,15 +157,19 @@ gnc_acct_tree_view_new(GnomeMDIChild * child, gpointer user_data) {
mc->contents = gnc_acct_tree_window_get_widget(win);
mc->child = child;
mc->app = NULL;
mc->toolbar = NULL;
mc->component_id = gnc_register_gui_component(WINDOW_ACCT_TREE_CM_CLASS,
NULL, NULL, mc);
mc->user_data = win;
/* set the child name that will get used to save app state */
mc->child->name = g_strdup_printf("gnc-acct-tree:id=%d",
win->options_id);
mc->title = g_strdup("Accounts");
gtk_object_set_user_data(GTK_OBJECT(child), mc);
/* set the child name that will get used to save app state */
gnome_mdi_child_set_name(mc->child,
g_strdup_printf("gnc-acct-tree:id=%d",
win->options_id));
gtk_signal_connect(GTK_OBJECT(child), "destroy",
gnc_acct_tree_view_destroy, mc);

View File

@@ -82,10 +82,36 @@ static gint
gnc_main_window_remove_view_cb(GnomeMDI * mdi, GnomeMDIChild * child,
gpointer data) {
GNCMainInfo * mainwin = data;
if(mainwin->last_active == child) {
mainwin->last_active = NULL;
}
gtk_object_destroy(GTK_OBJECT(child));
return TRUE;
}
/********************************************************************
* gnc_main_window_app_destroyed_cb()
* called when a top-level GnomeApp is destroyed.
********************************************************************/
static void
gnc_main_window_app_destroyed_cb(GnomeApp * app, gpointer user_data) {
GNCMainInfo * mainwin = user_data;
GNCMainChildInfo * mc = NULL;
GList * child;
for(child = mainwin->children; child; child = child->next) {
mc = child->data;
if(mc && mc->toolbar && mc->app && (mc->app == app)) {
/* we need to pull the toolbar out to prevent its being
* destroyed */
gtk_widget_ref(mc->toolbar);
gtk_container_remove(GTK_CONTAINER(mc->toolbar->parent), mc->toolbar);
}
}
}
/********************************************************************
* gnc_main_window_app_created_cb()
* called when a new top-level GnomeApp is created.
@@ -108,6 +134,10 @@ gnc_main_window_app_created_cb(GnomeMDI * mdi, GnomeApp * app,
statusbar = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER);
gnome_app_set_statusbar(app, statusbar);
/* add a signal to preserve the toolbar on destroy */
gtk_signal_connect(GTK_OBJECT(app), "destroy",
gnc_main_window_app_destroyed_cb, mainwin);
/* set up extensions menu and hints */
gnc_extensions_menu_setup(app);
}
@@ -120,15 +150,24 @@ gnc_main_window_app_created_cb(GnomeMDI * mdi, GnomeApp * app,
********************************************************************/
static void
gnc_main_window_child_changed_cb(GnomeMDI * mdi, GnomeMDIChild * oldchild,
gnc_main_window_child_changed_cb(GnomeMDI * mdi, GnomeMDIChild * not_used,
gpointer data) {
GNCMainInfo * mainwin = data;
GNCMainChildInfo * childwin =
gtk_object_get_user_data(GTK_OBJECT(mdi->active_child));
GNCMainChildInfo * oldchildwin;
GnomeMDIChild * oldchild = mainwin->last_active;
GnomeUIInfo * hintinfo;
GnomeApp * new_app = gnome_mdi_get_app_from_view(childwin->contents);
char * window_title;
/* set the window title */
if(childwin && new_app) {
window_title = g_strdup_printf("%s - GnuCash", childwin->title);
gtk_window_set_title(GTK_WINDOW(new_app), window_title);
g_free(window_title);
}
/* hide the old toolbar, if needed */
if(oldchild) {
oldchildwin = gtk_object_get_user_data(GTK_OBJECT(oldchild));
@@ -137,12 +176,29 @@ gnc_main_window_child_changed_cb(GnomeMDI * mdi, GnomeMDIChild * oldchild,
gtk_widget_hide(GTK_WIDGET(oldchildwin->toolbar)->parent);
}
}
/* show the new one */
if(childwin && childwin->toolbar) {
if(childwin->app) {
if(childwin->app && (childwin->app == new_app)) {
gtk_widget_show(GTK_WIDGET(childwin->toolbar)->parent);
}
else if(childwin->app) {
/* we need to move the toolbar to a new APP (mdi mode probably
* changed) */
if(GTK_WIDGET(childwin->toolbar)->parent) {
gtk_widget_ref(GTK_WIDGET(childwin->toolbar));
gtk_container_remove(GTK_CONTAINER
(GTK_WIDGET(childwin->toolbar)->parent),
GTK_WIDGET(childwin->toolbar));
}
childwin->app = new_app;
gnome_app_add_toolbar(GNOME_APP(childwin->app),
GTK_TOOLBAR(childwin->toolbar),
"Toolbar", GNOME_DOCK_ITEM_BEH_NORMAL,
GNOME_DOCK_TOP, 1, 0, 0);
gtk_toolbar_set_style(GTK_TOOLBAR(childwin->toolbar),
gnc_get_toolbar_style());
}
else {
childwin->app = new_app;
gnome_app_add_toolbar(GNOME_APP(childwin->app),
@@ -156,7 +212,9 @@ gnc_main_window_child_changed_cb(GnomeMDI * mdi, GnomeMDIChild * oldchild,
/* install menu hints if relevant */
if(mdi->active_child) {
/* the arg to this callback is SUPPOSED to be the last active child,
* but it gets to be NULL under some circumstances */
mainwin->last_active = mdi->active_child;
hintinfo = gnome_mdi_get_menubar_info(new_app);
if(hintinfo) {
gnome_app_install_menu_hints(new_app, hintinfo);
@@ -204,6 +262,21 @@ gnc_main_window_configure_toolbar_cb (gpointer data)
}
}
/********************************************************************
* gnc_main_window_configure_mdi_cb
* called when the MDI mode option is changed
********************************************************************/
static void
gnc_main_window_configure_mdi_cb (gpointer data)
{
GNCMainInfo * mi = data;
GnomeMDIMode mode = gnc_get_mdi_mode();
gnome_mdi_set_mode(mi->mdi, mode);
}
/********************************************************************
* gnc_main_window_create_child()
* open an MDI child given a config string (URL). This is used
@@ -247,7 +320,8 @@ gnc_main_window_new(void) {
retval->component_id =
gnc_register_gui_component (WINDOW_MAIN_CM_CLASS, NULL, NULL,
retval);
retval->last_active = NULL;
/* these menu and toolbar options are the ones that are always
* available */
gnc_main_window_create_menus(retval);
@@ -256,13 +330,18 @@ gnc_main_window_new(void) {
* inserted */
gnome_mdi_set_child_menu_path(GNOME_MDI(retval->mdi),
"_File");
gnome_mdi_set_mode(retval->mdi, GNOME_MDI_NOTEBOOK);
gnome_mdi_set_child_list_path(GNOME_MDI(retval->mdi),
"_Windows/");
retval->toolbar_change_callback_id =
gnc_register_option_change_callback(gnc_main_window_configure_toolbar_cb,
retval,
"General", "Toolbar Buttons");
retval->mdi_change_callback_id =
gnc_register_option_change_callback(gnc_main_window_configure_mdi_cb,
retval,
"General", "Application MDI mode");
/* handle top-level signals */
gtk_signal_connect(GTK_OBJECT(retval->mdi), "destroy",
@@ -286,7 +365,6 @@ gnc_main_window_new(void) {
static char *
gnc_main_window_child_save_func(GnomeMDIChild * child, gpointer user_data) {
printf("child save func '%p': '%s'\n", child, child->name);
return g_strdup(child->name);
}
@@ -333,12 +411,11 @@ gnc_main_window_destroy(GNCMainInfo * wind) {
void
gnc_main_window_save(GNCMainInfo * wind) {
printf("entering gnome_mdi_save_state\n");
gnome_mdi_save_state(GNOME_MDI(wind->mdi),
"/GnuCash/MDI Session");
printf("left gnome_mdi_save_state\n");
}
/********************************************************************
* gnc_main_window_child_refresh(GNCMainChildInfo * child)
* send an update event to the child
@@ -347,7 +424,18 @@ gnc_main_window_save(GNCMainInfo * wind) {
void
gnc_main_window_child_refresh(gpointer data) {
GNCMainChildInfo *child = data;
char * window_title;
gnome_mdi_child_set_name(child->child, child->child->name);
gnome_mdi_update_child(gnc_ui_get_data()->mdi, child->child);
/* pesky child_set_name tries to change the window title... set
* it back. */
if((gnc_ui_get_data()->mdi->active_child == child->child) &&
child->app) {
window_title = g_strdup_printf("%s - GnuCash", child->title);
gtk_window_set_title(GTK_WINDOW(child->app), window_title);
g_free(window_title);
}
}
@@ -432,6 +520,9 @@ gnc_main_window_file_close_cb(GtkWidget * widget, GnomeMDI * mdi) {
gtk_widget_destroy(GTK_WIDGET(inf->toolbar)->parent);
inf->toolbar = NULL;
}
if(gnc_ui_get_data()->last_active == mdi->active_child) {
gnc_ui_get_data()->last_active = NULL;
}
gnome_mdi_remove_child(mdi, mdi->active_child, FALSE);
}
else {
@@ -650,6 +741,11 @@ gnc_main_window_create_menus(GNCMainInfo * maininfo) {
GNOMEUIINFO_END
};
static GnomeUIInfo gnc_windows_menu_template[] =
{
GNOMEUIINFO_END
};
static GnomeUIInfo gnc_developer_menu_template[] =
{
GNOMEUIINFO_END
@@ -661,6 +757,7 @@ gnc_main_window_create_menus(GNCMainInfo * maininfo) {
GNOMEUIINFO_SUBTREE(N_("_Tools"), gnc_tools_menu_template),
GNOMEUIINFO_SUBTREE(N_("_Settings"), gnc_settings_menu_template),
GNOMEUIINFO_SUBTREE(N_("_Devel Options"), gnc_developer_menu_template),
GNOMEUIINFO_SUBTREE(N_("_Windows"), gnc_windows_menu_template),
GNOMEUIINFO_MENU_HELP_TREE(gnc_help_menu_template),
GNOMEUIINFO_END
};
@@ -727,6 +824,7 @@ gnc_main_window_create_child_toolbar(GNCMainInfo * mi,
memcpy(cur, post_tb, sizeof(post_tb));
child->toolbar = GTK_WIDGET(tb);
child->toolbar_info = tbinfo;
child->toolbar_size =
(sizeof(pre_tb) + sizeof(post_tb)) / sizeof(GnomeUIInfo) +

View File

@@ -28,9 +28,11 @@
#include <guile/gh.h>
typedef struct {
GnomeMDI * mdi;
GnomeMDI * mdi;
GnomeMDIChild * last_active;
int component_id;
SCM toolbar_change_callback_id;
SCM mdi_change_callback_id;
GList * children;
} GNCMainInfo;
@@ -46,6 +48,7 @@ typedef struct {
int component_id;
void * user_data;
char * title;
} GNCMainChildInfo;

View File

@@ -98,20 +98,23 @@ gnc_report_window_view_labeler(GnomeMDIChild * child, GtkWidget * current,
else {
name = strdup(_("(Report not found)"));
}
g_free(rwin->title);
rwin->title = g_strdup(name);
}
else {
name = strdup(_("Report"));
}
if(current == NULL) {
GtkWidget * label = gtk_label_new(name);
current = gtk_label_new(name);
free(name);
return label;
}
else {
gtk_label_set_text(GTK_LABEL(current), name);
free(name);
return current;
}
gtk_label_set_justify(GTK_LABEL(current), GTK_JUSTIFY_LEFT);
return current;
}
static void
@@ -122,6 +125,7 @@ gnc_report_window_view_destroy(GtkObject * obj, gpointer user_data) {
g_free(mc->toolbar_info);
g_free(mc->menu_info);
g_free(mc->title);
g_free(mc);
}
@@ -141,8 +145,10 @@ gnc_report_window_view_new(GnomeMDIChild * child, gpointer user_data) {
mc->contents = gnc_report_window_get_container(win);
mc->app = NULL;
mc->toolbar = NULL;
mc->user_data = win;
mc->child = child;
mc->title = g_strdup("Report");
gnc_main_window_add_child(maininfo, mc);
@@ -153,6 +159,10 @@ gnc_report_window_view_new(GnomeMDIChild * child, gpointer user_data) {
type, url_location, url_label, 0);
gtk_object_set_user_data(GTK_OBJECT(child), mc);
/* make sure menu entry and label get refreshed */
gnome_mdi_child_set_name(child, child->name);
gtk_signal_connect(GTK_OBJECT(child), "destroy",
gnc_report_window_view_destroy, mc);

View File

@@ -383,6 +383,28 @@ transaction.") #t))
(N_ "Text only")
(N_ "Show text only"))))))
(gnc:register-configuration-option
(gnc:make-multichoice-option
(N_ "General") (N_ "Application MDI mode")
"ba" (N_ "Choose how new windows are created for reports and account trees.")
'mdi-notebook
(list (list->vector
(list 'mdi-notebook
(N_ "Notebook")
(N_ "New windows are created as notebook tabs in the current top-level window")))
(list->vector
(list 'mdi-toplevel
(N_ "Top-level")
(N_ "Create a new top-level window for each report or account tree")))
(list->vector
(list 'mdi-modal
(N_ "Single window")
(N_ "One window is used for all displays (select contents through Window menu)")))
(list->vector
(list 'mdi-default
(N_ "Use GNOME default")
(N_ "Default MDI mode can be set in the GNOME Control Center"))))))
(gnc:register-configuration-option
(gnc:make-multichoice-option
(N_ "General") (N_ "Account Separator")