mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Update to use the gnome2 initialization routine. Migrate functions.
Use the gnome2 file locate functionality. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9361 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -4,6 +4,10 @@ PWD := $(shell pwd)
|
||||
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la libgw-gnome-utils.la
|
||||
|
||||
AM_CFLAGS = \
|
||||
-DPREFIX=\"${prefix}\" \
|
||||
-DSYSCONFDIR=\"${GNC_CONFIGDIR}\" \
|
||||
-DDATADIR=\"${GNC_SHAREDIR}\" \
|
||||
-DLIBDIR=\"${GNC_LIBDIR}\" \
|
||||
-I${top_srcdir}/src/gnc-module \
|
||||
-I${top_srcdir}/src/engine \
|
||||
-I${top_srcdir}/src/backend/file \
|
||||
@@ -64,8 +68,7 @@ libgncmod_gnome_utils_la_SOURCES = \
|
||||
gtkselect.c \
|
||||
misc-gnome-utils.c \
|
||||
print-session.c \
|
||||
search-param.c \
|
||||
window-help.c
|
||||
search-param.c
|
||||
|
||||
gncincludedir = ${GNC_INCLUDE_DIR}
|
||||
gncinclude_HEADERS = \
|
||||
@@ -108,8 +111,7 @@ gncinclude_HEADERS = \
|
||||
gnc-tree-view-account.h \
|
||||
gtkselect.h \
|
||||
misc-gnome-utils.h \
|
||||
print-session.h \
|
||||
window-help.h
|
||||
print-session.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
argv-list-converters.h \
|
||||
@@ -175,8 +177,7 @@ gnc-dir.h: gnc-dir.h.in ${top_builddir}/config.status
|
||||
rm -f $@.tmp
|
||||
sed < $< > $@.tmp \
|
||||
-e 's:@-GNC_ACCOUNTS_DIR-@:${GNC_ACCOUNTS_DIR}:g' \
|
||||
-e 's:@-GNC_GLADE_DIR-@:${GNC_GLADE_DIR}:g' \
|
||||
-e 's:@-GNC_PIXMAP_DIR-@:${GNC_PIXMAP_DIR}:g'
|
||||
-e 's:@-GNC_GLADE_DIR-@:${GNC_GLADE_DIR}:g'
|
||||
mv $@.tmp $@
|
||||
|
||||
gnc-version.h: _gnc-version.h
|
||||
@@ -226,3 +227,14 @@ gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h: \
|
||||
BUILT_SOURCES += gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h
|
||||
DISTCLEANFILES = gnucash g-wrapped .scm-links ${SCM_FILE_LINKS} \
|
||||
gw-gnome-utils.html
|
||||
|
||||
#
|
||||
# I hate inconsistent standards. Autotools puts help files into
|
||||
# ${datadir}/gnome/help/${program} while the gnome2 libraries expect
|
||||
# them in ${pkgdatadir}/gnome/help/${program}.
|
||||
#
|
||||
install-data-hook:
|
||||
ln -sf ../gnome ${pkgdatadir}
|
||||
|
||||
uninstall-hook:
|
||||
rm -f ${pkgdatadir}/gnome
|
||||
|
||||
@@ -131,28 +131,6 @@ gnc_build_option_menu(GNCOptionInfo *option_info, gint num_options)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_pixmap *
|
||||
* returns a GnomePixmap widget given a pixmap filename *
|
||||
* *
|
||||
* Args: none *
|
||||
* Returns: GnomePixmap widget or NULL if there was a problem *
|
||||
\*******************************************************************/
|
||||
GtkWidget *
|
||||
gnc_get_pixmap (const char *name)
|
||||
{
|
||||
GtkWidget *pixmap;
|
||||
char *fullname;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
fullname = g_strconcat (GNC_PIXMAP_DIR, "/", name, NULL);
|
||||
pixmap = gnome_pixmap_new_from_file (fullname);
|
||||
g_free (fullname);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_toolbar_style *
|
||||
* returns the current toolbar style for gnucash toolbars *
|
||||
|
||||
@@ -51,15 +51,6 @@ GtkWidget * gnc_build_option_menu (GNCOptionInfo *option_info,
|
||||
gint num_options);
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* Returns a GnomePixmap widget given a pixmap filename *
|
||||
* *
|
||||
* Args: Filename of pixmap file *
|
||||
* Returns: GnomePixmap widget or NULL if there was a problem *
|
||||
\*******************************************************************/
|
||||
GtkWidget * gnc_get_pixmap (const char *name);
|
||||
|
||||
|
||||
GnomeMDIMode gnc_get_mdi_mode(void);
|
||||
GtkToolbarStyle gnc_get_toolbar_style (void);
|
||||
void gnc_get_deficit_color (GdkColor *color);
|
||||
|
||||
@@ -26,37 +26,8 @@
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "druid-utils.h"
|
||||
#include "gnc-dir.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_imlib_image *
|
||||
* returns a GdkImlibImage object given a pixmap filename *
|
||||
* *
|
||||
* Args: none *
|
||||
* Returns: GnomePixmap widget or NULL if there was a problem *
|
||||
\*******************************************************************/
|
||||
static GdkPixbuf *
|
||||
gnc_druid_get_pixmap (const char *name)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
char *fullname;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
fullname = g_strconcat (GNC_PIXMAP_DIR, "/", name, NULL);
|
||||
pixbuf = gdk_pixbuf_new_from_file (fullname, &error);
|
||||
if (error != NULL) {
|
||||
g_assert (pixbuf == NULL);
|
||||
fprintf (stderr, "Pixbuf is NULL: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
g_free (fullname);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
#include "gnc-gnome-utils.h"
|
||||
|
||||
void
|
||||
gnc_druid_set_watermark_images (GnomeDruid *druid,
|
||||
@@ -68,8 +39,8 @@ gnc_druid_set_watermark_images (GnomeDruid *druid,
|
||||
GtkWidget *page;
|
||||
|
||||
page_list = gtk_container_get_children(GTK_CONTAINER(druid));
|
||||
top_pixbuf = gnc_druid_get_pixmap(top_path);
|
||||
side_pixbuf = gnc_druid_get_pixmap(side_path);
|
||||
top_pixbuf = gnc_gnome_get_gdkpixbuf(top_path);
|
||||
side_pixbuf = gnc_gnome_get_gdkpixbuf(side_path);
|
||||
|
||||
for (item = page_list; item; item = g_list_next(item)) {
|
||||
page = item->data;
|
||||
@@ -100,7 +71,7 @@ gnc_druid_set_logo_image (GnomeDruid *druid, char *image_path)
|
||||
GtkWidget *page;
|
||||
|
||||
page_list = gtk_container_get_children(GTK_CONTAINER(druid));
|
||||
logo_pixbuf = gnc_druid_get_pixmap(image_path);
|
||||
logo_pixbuf = gnc_gnome_get_gdkpixbuf(image_path);
|
||||
|
||||
for (item = page_list; item; item = g_list_next(item)) {
|
||||
page = item->data;
|
||||
|
||||
@@ -37,10 +37,14 @@
|
||||
#include "argv-list-converters.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-trace.h"
|
||||
|
||||
#include <libgnomeui/gnome-window-icon.h>
|
||||
#include <gnc-dir.h>
|
||||
|
||||
static short module = MOD_GUI;
|
||||
static GnomeProgram *gnucash_program = NULL;
|
||||
|
||||
static char**
|
||||
gnc_scm2argv (SCM scm, int prelen, const char **prependargv)
|
||||
{
|
||||
@@ -66,11 +70,14 @@ gnc_gnome_init (const char * arg0,
|
||||
const char * version,
|
||||
SCM command_line)
|
||||
{
|
||||
poptContext returnedPoptContext;
|
||||
poptContext returnedPoptContext; /* owned by the library */
|
||||
int restargc;
|
||||
char *fullname;
|
||||
char **restargv;
|
||||
char **restargv2;
|
||||
SCM ret = command_line;
|
||||
GError *error = NULL;
|
||||
GValue value = { 0, };
|
||||
|
||||
if (arg0)
|
||||
default_argv[0] = arg0;
|
||||
@@ -85,23 +92,27 @@ gnc_gnome_init (const char * arg0,
|
||||
|
||||
restargc = argv_length (restargv);
|
||||
|
||||
gnome_init_with_popt_table (progname, version, restargc, restargv,
|
||||
nullPoptTable, 0, &returnedPoptContext);
|
||||
gnucash_program =
|
||||
gnome_program_init("gnucash", version, LIBGNOMEUI_MODULE,
|
||||
restargc, restargv,
|
||||
GNOME_PARAM_POPT_TABLE, nullPoptTable,
|
||||
GNOME_PROGRAM_STANDARD_PROPERTIES,
|
||||
GNOME_PARAM_NONE);
|
||||
|
||||
g_value_init(&value, G_TYPE_POINTER);
|
||||
g_object_get_property (G_OBJECT (gnucash_program),
|
||||
GNOME_PARAM_POPT_CONTEXT, &value);
|
||||
returnedPoptContext = g_value_get_pointer (&value);
|
||||
restargv2 = (char**) poptGetArgs (returnedPoptContext);
|
||||
ret = gnc_argv2scm (argv_length (restargv2), (const char**)restargv2);
|
||||
|
||||
#ifdef GTKHTML_HAVE_GCONF
|
||||
{
|
||||
GError * gerror;
|
||||
|
||||
if (!gconf_init (restargc, restargv, &gerror))
|
||||
g_error_free (gerror);
|
||||
if (!gconf_init (restargc, restargv, &error))
|
||||
g_error_free (error);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* this must come after using the poptGetArgs return value */
|
||||
poptFreeContext (returnedPoptContext);
|
||||
gnc_free_argv (restargv);
|
||||
|
||||
/* initialization required for gtkhtml */
|
||||
@@ -110,8 +121,20 @@ gnc_gnome_init (const char * arg0,
|
||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||
|
||||
/* use custom icon */
|
||||
gnome_window_icon_set_default_from_file (GNC_PIXMAP_DIR"/gnucash-icon.png");
|
||||
|
||||
fullname = gnome_program_locate_file (gnucash_program,
|
||||
GNOME_FILE_DOMAIN_APP_PIXMAP,
|
||||
"gnucash-icon.png", TRUE, NULL);
|
||||
if (fullname) {
|
||||
gtk_window_set_default_icon_from_file (fullname, &error);
|
||||
g_free(fullname);
|
||||
if (error) {
|
||||
PERR ("Could not set default icon: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
} else {
|
||||
PERR ("Could not locate pixmap file %s", "gnucash-icon.png");
|
||||
}
|
||||
|
||||
#ifdef USE_GUPPI
|
||||
/* initialize guppi handling in gnc-html */
|
||||
gnc_html_guppi_init ();
|
||||
@@ -127,3 +150,107 @@ gnc_gnome_shutdown (void)
|
||||
gnc_html_guppi_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
gnc_gnome_locate_file (const char *name)
|
||||
{
|
||||
char *fullname;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
fullname = gnome_program_locate_file (gnucash_program,
|
||||
GNOME_FILE_DOMAIN_APP_PIXMAP,
|
||||
name, TRUE, NULL);
|
||||
if (fullname == NULL) {
|
||||
PERR ("Could not locate file %s", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fullname;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_gnome_help (const char *file_name, const char *anchor)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
DEBUG ("Attempting to opening help file %s", file_name);
|
||||
if (gnome_help_display (file_name, anchor, &error))
|
||||
return;
|
||||
|
||||
g_assert(error != NULL);
|
||||
PERR ("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_gnome_get_pixmap *
|
||||
* returns a GnomePixmap widget given a pixmap filename *
|
||||
* *
|
||||
* Args: none *
|
||||
* Returns: GnomePixmap widget or NULL if there was a problem *
|
||||
\*******************************************************************/
|
||||
GtkWidget *
|
||||
gnc_gnome_get_pixmap (const char *name)
|
||||
{
|
||||
GtkWidget *pixmap;
|
||||
char *fullname;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
fullname = gnome_program_locate_file (gnucash_program,
|
||||
GNOME_FILE_DOMAIN_APP_PIXMAP,
|
||||
name, TRUE, NULL);
|
||||
if (fullname == NULL) {
|
||||
PERR ("Could not locate pixmap file %s", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG ("Loading pixmap file %s", fullname);
|
||||
pixmap = gnome_pixmap_new_from_file (fullname);
|
||||
if (pixmap == NULL) {
|
||||
PERR ("Could not load pixmap");
|
||||
}
|
||||
g_free (fullname);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_gnome_get_gdkpixbuf *
|
||||
* returns a GdkImlibImage object given a pixmap filename *
|
||||
* *
|
||||
* Args: none *
|
||||
* Returns: GdkPixbuf or NULL if there was a problem *
|
||||
\*******************************************************************/
|
||||
GdkPixbuf *
|
||||
gnc_gnome_get_gdkpixbuf (const char *name)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
char *fullname;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
fullname = gnome_program_locate_file (gnucash_program,
|
||||
GNOME_FILE_DOMAIN_APP_PIXMAP,
|
||||
name, TRUE, NULL);
|
||||
|
||||
if (fullname == NULL) {
|
||||
PERR ("Could not locate pixbuf file %s", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG ("Loading pixbuf file %s", fullname);
|
||||
pixbuf = gdk_pixbuf_new_from_file (fullname, &error);
|
||||
if (error != NULL) {
|
||||
g_assert (pixbuf == NULL);
|
||||
PERR ("Could not load pixbuf: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
g_free (fullname);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* gnc-gnome-utils.h -- utility functions for gnome for GnuCash *
|
||||
* Copyright (C) 2001 Linux Developers Group *
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -21,14 +22,91 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/** @addtogroup Utils
|
||||
@{ */
|
||||
/** @file gnc-gnome-utils.h
|
||||
@brief Gnome specific utility functions.
|
||||
@author Copyright (C) 2001 Linux Developers Group
|
||||
@author Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*/
|
||||
|
||||
#ifndef GNC_GNOME_UTILS_H
|
||||
#define GNC_GNOME_UTILS_H
|
||||
|
||||
#ifdef LIBGUILEH
|
||||
/** Initialize the Gnome libraries.
|
||||
*
|
||||
* @param arg0 The running application as it appears to a user.
|
||||
*
|
||||
* @param program The compiled name of the application. "gnucash"
|
||||
*
|
||||
* @param version The program version. (e.g. 1.8.7)
|
||||
*
|
||||
* @param command_line A scheme list containing all of the command
|
||||
* line arguments (or all of the arguments notyet pasrsed in scheme).
|
||||
*
|
||||
* @return The initial command_line argument minus any arguments
|
||||
* parsed by this function.
|
||||
*/
|
||||
SCM gnc_gnome_init (const char * arg0,
|
||||
const char * progname,
|
||||
const char * version,
|
||||
SCM command_line);
|
||||
#endif
|
||||
|
||||
/** Shutdown/cleanup any gnome related libraries. */
|
||||
void gnc_gnome_shutdown (void);
|
||||
|
||||
|
||||
/** Given a file name, find the file in the directories associated
|
||||
* with this application. This routine will display an error message
|
||||
* if it can't find the file.
|
||||
*
|
||||
* @param name The name of the file to be found.
|
||||
*
|
||||
* @return the full path name of the file, or NULL of the file can't
|
||||
* be found.
|
||||
*/
|
||||
char *gnc_gnome_locate_file (const char *name);
|
||||
|
||||
|
||||
/** Launch the default gnome help browser and open to a given link
|
||||
* within a given file. This routine will display an error message
|
||||
* if it can't find the help file or can't open the help browser.
|
||||
*
|
||||
* @param file_name The name of the help file.
|
||||
*
|
||||
* @param anchor The anchor the help browser should scroll to..
|
||||
*
|
||||
* @return the full path name of the file, or NULL of the file can't
|
||||
* be found.
|
||||
*/
|
||||
void gnc_gnome_help (const char *file_name,
|
||||
const char *anchor);
|
||||
|
||||
|
||||
/** Given a file name, find and load the requested pixmap. This
|
||||
* routine will display an error message if it can't find the file or
|
||||
* load the pixmap.
|
||||
*
|
||||
* @param name The name of the pixmap file to load.
|
||||
*
|
||||
* @return A pointer to the pixmap, or NULL of the file couldn't
|
||||
* be found or loaded..
|
||||
*/
|
||||
GtkWidget * gnc_gnome_get_pixmap (const char *name);
|
||||
|
||||
|
||||
/** Given a file name, find and load the requested pixbuf. This
|
||||
* routine will display an error message if it can't find the file or
|
||||
* load the pixbuf.
|
||||
*
|
||||
* @param name The name of the pixbuf file to load.
|
||||
*
|
||||
* @return A pointer to the pixbuf, or NULL of the file couldn't
|
||||
* be found or loaded..
|
||||
*/
|
||||
GdkPixbuf * gnc_gnome_get_gdkpixbuf (const char *name);
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-splash.h"
|
||||
#include "gnc-version.h"
|
||||
|
||||
@@ -61,7 +61,7 @@ gnc_show_splash_screen (void)
|
||||
gtk_window_set_title (GTK_WINDOW (splash), "GnuCash");
|
||||
gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER);
|
||||
|
||||
pixmap = gnc_get_pixmap ("gnucash_splash.png");
|
||||
pixmap = gnc_gnome_get_pixmap ("gnucash_splash.png");
|
||||
|
||||
if (!pixmap)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user