* src/gnome-utils/gw-gnome-utils-spec.scm: g-wrap new funcs

* src/gnome-utils/gncmod-gnome-utils.c: remove #include cruft

* src/gnome-utils/gnc-html.c: remove #include cruft

* src/gnome-utils/gnc-gnome-utils.h: new file

* src/gnome-utils/gnc-gnome-utils.c: new file -- init and shutdown
functions

* src/gnome-utils/argv-list-converters.h: add

* src/gnome-utils/argv-list-converters.c: add

* src/gnome-utils/Makefile.am: add new files


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6407 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-12-21 07:41:54 +00:00
parent 9bebd787bd
commit 318a1dd55f
8 changed files with 371 additions and 4 deletions

View File

@@ -8,7 +8,6 @@ AM_CFLAGS = \
-I${top_srcdir}/src/network-utils \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src \
-I${top_srcdir}/src/gnome \
${GUILE_INCS} \
${GUPPI_CFLAGS} \
${GLIB_CFLAGS} \
@@ -21,6 +20,7 @@ AM_CFLAGS = \
libgncmod_gnome_utils_la_SOURCES = \
cursors.c \
argv-list-converters.c \
dialog-commodity.c \
dialog-options.c \
dialog-utils.c \
@@ -33,6 +33,7 @@ libgncmod_gnome_utils_la_SOURCES = \
gnc-date-edit.c \
gnc-frequency.c \
gnc-general-select.c \
gnc-gnome-utils.c \
gnc-gui-query.c \
gnc-html-history.c \
gnc-html-guppi.c \
@@ -58,6 +59,7 @@ gncinclude_HEADERS = \
gnc-date-edit.h \
gnc-frequency.h \
gnc-general-select.h \
gnc-gnome-utils.h \
gnc-gui-query.h \
gnc-html-history.h \
gnc-html-guppi.h \
@@ -69,6 +71,7 @@ gncinclude_HEADERS = \
window-help.h
noinst_HEADERS = \
argv-list-converters.h \
gnc-dir.h
libgncmod_gnome_utils_la_LDFLAGS = -module

View File

@@ -0,0 +1,130 @@
/********************************************************************\
* argv-list-converters.c *
* Copyright (C) 2000 Gnumatic, Inc *
* Copyright (C) 2000 James LewisMoss *
* *
* 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 <guile/gh.h>
#include <glib.h>
#include "argv-list-converters.h"
char**
gnc_scheme_list_to_nulltermcharpp(int prelen, const char **prepend, SCM list)
{
SCM next = list;
char **ret;
int len = 0;
int loc;
if(gh_pair_p(list))
{
int i;
len = gh_length(list) + prelen;
ret = g_new(char *, len + 1);
ret[len] = NULL;
for(i = 0; i < prelen; i++)
{
ret[i] = g_strdup(prepend[i]);
}
}
else
{
return NULL;
}
loc = prelen;
while(gh_pair_p(next))
{
SCM scm_string = gh_car(next);
next = gh_cdr(next);
if(gh_string_p(scm_string))
{
char *onestr = gh_scm2newstr(scm_string, 0);
ret[loc] = g_strdup (onestr);
if (onestr)
free (onestr);
}
else
{
int i;
for (i = 0; i < loc; i++)
g_free (ret[i]);
g_free(ret);
return NULL;
}
loc++;
}
return ret;
}
SCM
gnc_argvarr_to_scheme_list(int argc, const char** argv)
{
int i;
SCM ret = SCM_EOL;
for(i = 0; i < argc; i++)
{
/* FIXME: when we drop support older guiles,
* drop the (char *) coercion. */
ret = gh_cons(gh_str02scm((char *) argv[i]), ret);
}
return gh_reverse(ret);
}
void
gnc_free_argv(char** argv)
{
char **now = argv;
if(!argv)
{
return;
}
while(*now != 0)
{
g_free(*now);
now++;
}
g_free(argv);
}
int
argv_length(char** nulltermlist)
{
int ret = 0;
if(!nulltermlist)
{
return 0;
}
while(nulltermlist[ret] != 0)
ret++;
return ret;
}

View File

@@ -0,0 +1,58 @@
/********************************************************************\
* argv-list-converters.h *
* Copyright (C) 2000 Gnumatic, Inc *
* Copyright (C) 2000 James LewisMoss *
* *
* 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 *
\********************************************************************/
#ifndef ARGV_LIST_CONVERTERS_H
#define ARGV_LIST_CONVERTERS_H
/*
* This function takes a SCM value. Determines whether it is a list
* and whether that list contains only strings and returns a null
* terminated array of strings (char*'s)
*/
char** gnc_scheme_list_to_nulltermcharpp(int prelen, const char **prepend,
SCM list);
/*
* This function takes a length and char** and makes a scheme list
* with similar contents
*/
SCM gnc_argvarr_to_scheme_list(int argc, const char** argv);
/*
* Frees the strings and the argv array
*/
void gnc_free_argv(char** argv);
/*
* print out the argv array in a nice manner
*/
void print_argv(char **argv);
/*
* get the length of null terminated char* array
*/
int argv_length(char** nulltermlist);
#endif

View File

@@ -0,0 +1,124 @@
/********************************************************************\
* gnc-gnome-utils.c -- utility functions for gnome for GnuCash *
* 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 <guile/gh.h>
#ifdef GTKHTML_HAVE_GCONF
#include <gconf/gconf.h>
#endif
#ifdef USE_GUPPI
#include "gnc-html-guppi.h"
#endif
#include "argv-list-converters.h"
#include "gnc-gnome-utils.h"
#include "gnc-html.h"
static char**
gnc_scm2argv (SCM scm, int prelen, const char **prependargv)
{
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
return gnc_scheme_list_to_nulltermcharpp (prelen, prependargv, scm);
}
static SCM
gnc_argv2scm (int len, const char **rest)
{
return gnc_argvarr_to_scheme_list (len, rest);
}
static const char *default_argv[] = {"", 0};
static const struct poptOption nullPoptTable[] = {
{ NULL, 0, 0, NULL, 0 }
};
SCM
gnc_gnome_init (const char * arg0,
const char * progname,
const char * version,
SCM command_line)
{
poptContext returnedPoptContext;
int restargc;
char **restargv;
char **restargv2;
SCM ret = command_line;
if (arg0)
default_argv[0] = arg0;
restargv = gnc_scm2argv (command_line, 1, default_argv);
if (!restargv)
{
restargv = g_new (char*, 2);
restargv[0] = g_strdup (default_argv[0]);
restargv[1] = NULL;
}
restargc = argv_length (restargv);
gnome_init_with_popt_table (progname, version, restargc, restargv,
nullPoptTable, 0, &returnedPoptContext);
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);
}
#endif
/* this must come after using the poptGetArgs return value */
poptFreeContext (returnedPoptContext);
gnc_free_argv (restargv);
/* initialization required for gtkhtml */
gdk_rgb_init ();
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
#ifdef USE_GUPPI
/* initialize guppi handling in gnc-html */
gnc_html_guppi_init ();
#endif
return ret;
}
void
gnc_gnome_shutdown (void)
{
#ifdef USE_GUPPI
gnc_html_guppi_shutdown();
#endif
}

View File

@@ -0,0 +1,34 @@
/********************************************************************\
* gnc-gnome-utils.h -- utility functions for gnome for GnuCash *
* 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 *
* *
\********************************************************************/
#ifndef GNC_GNOME_UTILS_H
#define GNC_GNOME_UTILS_H
SCM gnc_gnome_init (const char * arg0,
const char * progname,
const char * version,
SCM command_line);
void gnc_gnome_shutdown (void);
#endif

View File

@@ -53,7 +53,6 @@
#include "gnc-html.h"
#include "gnc-http.h"
#include "gnc-html-history.h"
#include "gnc-network.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "messages.h"

View File

@@ -8,8 +8,6 @@
#include <stdio.h>
#include <guile/gh.h>
#include <glib.h>
#include <libguile/strports.h>
#include <libguile/modules.h>
#include "gnc-module.h"
#include "gnc-module-api.h"

View File

@@ -45,6 +45,7 @@
"#include <druid-utils.h>\n"
"#include <gnc-amount-edit.h>\n"
"#include <gnc-date-edit.h>\n"
"#include <gnc-gnome-utils.h>\n"
"#include <gnc-gui-query.h>\n"
"#include <gnc-html.h>\n"
"#include <gnc-mdi-utils.h>\n"
@@ -53,6 +54,26 @@
"#include <print-session.h>\n"
)))
(gw:wrap-function
mod
'gnc:gnome-init
'<gw:scm>
"gnc_gnome_init"
'(((<gw:m-chars-caller-owned> gw:const) arg0)
((<gw:m-chars-caller-owned> gw:const) progname)
((<gw:m-chars-caller-owned> gw:const) version)
(<gw:scm> command-line))
"Initialize the GnuCash gnome system.")
(gw:wrap-function
mod
'gnc:gnome-shutdown
'<gw:void>
"gnc_gnome_shutdown"
'()
"Shutdown the GnuCash gnome system.")
(let ((nnt (gw:wrap-non-native-type
mod
'<gnc:UIWidget>