2001-09-13 Dave Peticolas <dave@krondo.com>

* src/guile/gw-gnc-spec.scm: remove some unused wrappings

	* src/gnome-utils/Makefile.am: enable test dir

	* src/gnome-utils/dialog-commodity.c: refactor help handler

	* src/gnome-utils/gnc-account-tree.c: refactor account group handler

	* src/gnome-utils/gnc-html.c: refactor help url handler

	* src/gnome/glade/commodity.glade: name help button

	* src/gnome/top-level.c: add in new handlers

	* src/gnome/window-main.c: remove toplevel api


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5371 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-09-14 07:01:40 +00:00
parent 0978192084
commit e18ba9e1b6
13 changed files with 173 additions and 76 deletions

View File

@ -1,3 +1,21 @@
2001-09-13 Dave Peticolas <dave@krondo.com>
* src/guile/gw-gnc-spec.scm: remove some unused wrappings
* src/gnome-utils/Makefile.am: enable test dir
* src/gnome-utils/dialog-commodity.c: refactor help handler
* src/gnome-utils/gnc-account-tree.c: refactor account group handler
* src/gnome-utils/gnc-html.c: refactor help url handler
* src/gnome/glade/commodity.glade: name help button
* src/gnome/top-level.c: add in new handlers
* src/gnome/window-main.c: remove toplevel api
2001-09-06 Dave Peticolas <dave@krondo.com>
* src/engine/Makefile.am: install public headers

View File

@ -21,8 +21,6 @@
#ifndef GNC_UI_H
#define GNC_UI_H
#include "config.h"
#include <glib.h>
#include "gnc-ui-common.h"
@ -111,7 +109,7 @@ void gnc_ui_hierarchy_druid (void);
void gnc_ui_shutdown (void);
void gnc_ui_destroy_all_subwindows (void);
gncUIWidget gnc_ui_get_toplevel(void);
gncUIWidget gnc_ui_get_toplevel (void);
gboolean gnc_ui_can_cancel_save (void);

View File

@ -1,4 +1,4 @@
SUBDIRS = . #test
SUBDIRS = . test
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la
@ -39,6 +39,7 @@ libgncmod_gnome_utils_la_SOURCES = \
gnc-html-history.c \
gnc-html-guppi.c \
gnc-html.c \
gnc-mdi-utils.c \
gnc-menu-extensions.c \
gncmod-gnome-utils.c \
gtkselect.c \

View File

@ -35,7 +35,7 @@
#include "window-help.h"
struct _selectcommoditywindow {
struct select_commodity_window {
GtkWidget * dialog;
GtkWidget * namespace_combo;
GtkWidget * commodity_combo;
@ -45,7 +45,7 @@ struct _selectcommoditywindow {
void * callback_data;
};
struct _commoditywindow {
struct commodity_window {
GtkWidget * dialog;
GtkWidget * fullname_entry;
GtkWidget * mnemonic_entry;
@ -60,6 +60,8 @@ struct _commoditywindow {
};
static gnc_commodity_help_callback help_callback = NULL;
static SelectCommodityWindow *
gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
gnc_commodity_callback callback,
@ -86,6 +88,13 @@ select_modal_callback(const gnc_commodity * arg, void * data) {
*((const gnc_commodity **)data) = arg;
}
void
gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb)
{
help_callback = cb;
}
/********************************************************************
* gnc_ui_select_commodity_modal()
********************************************************************/
@ -441,6 +450,7 @@ gnc_ui_new_commodity_create(const char * selected_namespace,
gnc_commodity_callback callback,
void * callback_data) {
CommodityWindow * retval = g_new0(CommodityWindow, 1);
GtkWidget *help_button;
GladeXML *xml;
char *namespace;
@ -458,6 +468,10 @@ gnc_ui_new_commodity_create(const char * selected_namespace,
(xml, "gnc_ui_commodity_help_cb",
GTK_SIGNAL_FUNC (gnc_ui_commodity_help_cb), retval);
help_button = glade_xml_get_widget (xml, "help_button");
if (!help_callback)
gtk_widget_hide (help_button);
retval->dialog = glade_xml_get_widget (xml, "Commodity Dialog");
retval->edit_commodity = NULL;
@ -668,7 +682,8 @@ gnc_ui_commodity_ok_cb(GtkButton * button,
static void
gnc_ui_commodity_help_cb(GtkButton * button,
gpointer user_data) {
helpWindow(NULL, _("Help"), HH_COMMODITY);
if (help_callback)
help_callback ();
}

View File

@ -29,11 +29,14 @@
#include "gnc-commodity.h"
#include "gnc-engine.h"
typedef struct _selectcommoditywindow SelectCommodityWindow;
typedef struct _commoditywindow CommodityWindow;
typedef struct select_commodity_window SelectCommodityWindow;
typedef struct commodity_window CommodityWindow;
typedef void (* gnc_commodity_callback)(const gnc_commodity *, void * data);
typedef void (* gnc_commodity_help_callback)(void);
void gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb);
void gnc_ui_select_commodity_destroy(SelectCommodityWindow * w);
void gnc_ui_commodity_destroy(CommodityWindow * w);

View File

@ -56,6 +56,8 @@ static guint account_tree_signals[LAST_SIGNAL];
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GUI;
static GNCAccountTreeGroupCB group_cb = NULL;
/** Static function declarations **************************************/
static void gnc_account_tree_init(GNCAccountTree *tree);
@ -82,6 +84,12 @@ static void gnc_account_tree_update_column_visibility (GNCAccountTree *tree);
static void gnc_account_tree_destroy(GtkObject *object);
void
gnc_account_tree_set_group_handler (GNCAccountTreeGroupCB cb)
{
group_cb = cb;
}
GtkType
gnc_account_tree_get_type (void)
{
@ -366,10 +374,13 @@ gnc_account_tree_refresh(GNCAccountTree * tree)
root_account = xaccAccountLookup (&tree->root_account);
gnc_account_tree_fill(tree, expanded_accounts,
gnc_account_tree_insert_row(tree, NULL, NULL,
root_account),
gncGetCurrentGroup());
if (!group_cb)
g_warning ("No account group handler.");
gnc_account_tree_fill (tree, expanded_accounts,
gnc_account_tree_insert_row (tree, NULL, NULL,
root_account),
group_cb ? group_cb () : NULL);
gtk_clist_columns_autosize(clist);

View File

@ -26,6 +26,7 @@
#include <gtk/gtkctree.h>
#include "Group.h"
#include "gnc-ui-util.h"
#ifdef __cplusplus
@ -38,20 +39,21 @@ extern "C" {
#define IS_GNC_ACCOUNT_TREE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_GNC_ACCOUNT_TREE))
#define IS_GNC_ACCOUNT_TREE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_GNC_ACCOUNT_TREE))
typedef struct _GNCAccountTree GNCAccountTree;
typedef struct _GNCAccountTreeClass GNCAccountTreeClass;
typedef struct _AccountViewInfo AccountViewInfo;
typedef struct GNCAccountTree_s GNCAccountTree;
typedef struct GNCAccountTreeClass_s GNCAccountTreeClass;
typedef struct AccountViewInfo_s AccountViewInfo;
typedef gboolean (*AccountFilter) (Account *account, gpointer user_data);
typedef AccountGroup * (*GNCAccountTreeGroupCB) (void);
struct _AccountViewInfo
struct AccountViewInfo_s
{
gboolean include_type[NUM_ACCOUNT_TYPES];
gboolean show_field[NUM_ACCOUNT_FIELDS];
};
struct _GNCAccountTree
struct GNCAccountTree_s
{
GtkCTree ctree;
@ -79,7 +81,7 @@ struct _GNCAccountTree
gboolean ignore_unselect;
};
struct _GNCAccountTreeClass
struct GNCAccountTreeClass_s
{
GtkCTreeClass parent_class;
@ -97,6 +99,8 @@ struct _GNCAccountTreeClass
* public functions *
***********************************************************/
void gnc_account_tree_set_group_handler (GNCAccountTreeGroupCB cb);
GtkType gnc_account_tree_get_type (void);
GtkWidget * gnc_account_tree_new (void);

View File

@ -57,7 +57,6 @@
#include "gnc-network.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "window-help.h"
#include "window-main.h"
#include "messages.h"
@ -863,26 +862,6 @@ gnc_html_submit_cb(GtkHTML * html, const gchar * method,
}
/********************************************************************
* gnc_html_open_help
* open a help window
********************************************************************/
static void
gnc_html_open_help(gnc_html * html, const gchar * location,
const gchar * label, int newwin) {
gnc_help_window * help = NULL;
if(newwin) {
help = gnc_help_window_new();
gnc_help_window_show_help(help, location, label);
}
else {
gnc_html_show_url(html, URL_TYPE_FILE, location, label, 0);
}
}
/********************************************************************
* gnc_html_open_scm
* insert some scheme-generated HTML
@ -1009,10 +988,6 @@ gnc_html_show_url(gnc_html * html, URLType type,
}
switch(type) {
case URL_TYPE_HELP:
gnc_html_open_help(html, location, label, new_window);
break;
case URL_TYPE_SCHEME:
gnc_html_open_scm(html, location, label, new_window);
break;

View File

@ -0,0 +1,60 @@
/********************************************************************\
* gnc-mdi-util.c -- utility functions for gnome/mdi *
* Copyright (C) 2001 Linux Developers Group *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
#include "config.h"
#include <gnome.h>
#include "gnc-ui.h"
gncUIWidget
gnc_ui_get_toplevel (void)
{
GList *containers = gtk_container_get_toplevels ();
GnomeApp *app = NULL;
for (; containers; containers = containers->next)
{
GtkWidget *w = containers->data;
GnomeMDI *mdi;
if (!GNOME_IS_APP (w))
continue;
app = GNOME_APP (w);
mdi = gtk_object_get_data (GTK_OBJECT (w), "gnc_mdi");
if (!mdi)
continue;
app = gnome_mdi_get_active_window (mdi);
break;
}
if (app)
return GTK_WIDGET (app);
return NULL;
}

View File

@ -308,7 +308,7 @@
<widget>
<class>GtkButton</class>
<name>button68</name>
<name>help_button</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -856,6 +856,7 @@ Click &quot;Back&quot; to review your currency selections.</text>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Add</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
@ -865,6 +866,7 @@ Click &quot;Back&quot; to review your currency selections.</text>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Remove</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
@ -873,6 +875,7 @@ Click &quot;Back&quot; to review your currency selections.</text>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Edit</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
</widget>
</widget>

View File

@ -42,10 +42,12 @@
#include "combocell.h"
#include "date.h"
#include "dialog-account.h"
#include "dialog-commodity.h"
#include "dialog-transfer.h"
#include "dialog-utils.h"
#include "file-utils.h"
#include "global-options.h"
#include "gnc-account-tree.h"
#include "gnc-component-manager.h"
#include "gnc-engine-util.h"
#include "gnc-menu-extensions.h"
@ -119,36 +121,24 @@ static SCM register_font_callback_id = SCM_UNDEFINED;
static SCM register_hint_font_callback_id = SCM_UNDEFINED;
/* ============================================================== */
gboolean
gnucash_ui_is_running(void)
{
return gnome_is_running;
}
/* ============================================================== */
gboolean
gnucash_ui_is_terminating(void)
{
return gnome_is_terminating;
}
/* ============================================================== */
GNCMainInfo *
gnc_ui_get_data(void)
gnc_ui_get_data (void)
{
return app;
}
gncUIWidget
gnc_ui_get_toplevel(void) {
/* FIXME */
return gnc_main_window_get_toplevel(app);
}
gboolean
gnc_ui_can_cancel_save (void)
{
@ -373,6 +363,34 @@ gnc_html_options_url_cb (const char *location, const char *label,
}
}
static gboolean
gnc_html_help_url_cb (const char *location, const char *label,
gboolean new_window, GNCURLResult *result)
{
g_return_val_if_fail (location != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
if (new_window)
{
gnc_help_window * help;
help = gnc_help_window_new ();
gnc_help_window_show_help (help, location, label);
result->load_to_stream = FALSE;
}
else
result->load_to_stream = TRUE;
return TRUE;
}
static void
gnc_commodity_help_cb (void)
{
helpWindow (NULL, _("Help"), HH_COMMODITY);
}
/* ============================================================== */
/* These gnucash_ui_init and gnucash_ui functions are just hacks to get
@ -523,6 +541,11 @@ gnucash_ui_init(void)
gnc_html_register_url_cb);
gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_html_report_url_cb);
gnc_html_register_url_handler (URL_TYPE_OPTIONS, gnc_html_options_url_cb);
gnc_html_register_url_handler (URL_TYPE_HELP, gnc_html_help_url_cb);
gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
gnc_account_tree_set_group_handler (gncGetCurrentGroup);
/* initialize gnome MDI and set up application window defaults */
app = gnc_main_window_new();

View File

@ -134,6 +134,9 @@ gnc_main_window_app_created_cb(GnomeMDI * mdi, GnomeApp * app,
/* enable save and restore of menubar positions */
gnome_app_enable_layout_config( app, TRUE );
/* flag the app as gnc mdi created */
gtk_object_set_data (GTK_OBJECT (app), "gnc_mdi", mdi);
/* add the summarybar */
summarybar = gnc_main_window_summary_new();
@ -668,22 +671,6 @@ gnc_main_window_child_refresh(gpointer data) {
}
/********************************************************************
* gnc_main_window_get_toplevel()
* get the currently-active top-level widget
********************************************************************/
GtkWidget *
gnc_main_window_get_toplevel(GNCMainInfo * wind) {
GnomeApp *app = gnome_mdi_get_active_window(GNOME_MDI(wind->mdi));
if (app)
return GTK_WIDGET(app);
return NULL;
}
/********************************************************************
* menu/toolbar data structures and callbacks
* these are the "templates" that are installed in every toplevel

View File

@ -58,7 +58,6 @@ gboolean gnc_main_window_can_cancel_save (GNCMainInfo *wind);
void gnc_main_window_save(GNCMainInfo * wind, char * session);
void gnc_main_window_restore(GNCMainInfo * wind,
const char * session);
GtkWidget * gnc_main_window_get_toplevel(GNCMainInfo * wind);
void gnc_main_window_create_child_toolbar(GNCMainInfo * mi,
GNCMainChildInfo * child);
void gnc_main_window_add_child(GNCMainInfo * main,