Move app file gnome code under app-file module.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5407 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-09-21 23:32:20 +00:00
parent 4da79c54cf
commit 0d25b496e1
14 changed files with 212 additions and 72 deletions

View File

@ -709,6 +709,7 @@ AC_OUTPUT(
rpm/Makefile
src/Makefile
src/app-file/Makefile
src/app-file/gnome/Makefile
src/app-utils/Makefile
src/app-utils/test/Makefile
src/backend/Makefile

View File

@ -37,10 +37,12 @@ gnucash_LDADD = \
-Lnetwork-utils -Lnetwork-utils/.libs \
-Lapp-utils -Lapp-utils/.libs \
-Lapp-file -Lapp-file/.libs \
-Lapp-file/gnome -Lapp-file/gnome/.libs \
gnc-module/libgncmodule.la \
gnome-utils/libgncmod-gnome-utils.la \
app-utils/libgncmod-app-utils.la \
app-file/libgncmod-app-file.la \
app-file/gnome/libgncmod-app-file-gnome.la \
engine/libgncmod-engine.la \
engine/libgw-engine.la \
engine/libgw-glib.la \

View File

@ -42,6 +42,7 @@ app-utils utils for the gnucash app framework (component
mgr, cmd line processing, gettext stuff, etc)
app-file application-level file handling
app-file-gnome gnome-specific application-level file handling
gnome-utils Extensions and utilities for using Gnome/Gtk
with GnuCash, including new widgets.

View File

@ -1,4 +1,4 @@
SUBDIRS = . #test
SUBDIRS = . gnome
pkglib_LTLIBRARIES = libgncmod-app-file.la

View File

@ -0,0 +1,6 @@
Makefile
Makefile.in
*.lo
*.la
.deps
.libs

View File

@ -0,0 +1,33 @@
SUBDIRS = . #test
pkglib_LTLIBRARIES = libgncmod-app-file-gnome.la
CFLAGS = @CFLAGS@ ${GLIB_CFLAGS} ${G_WRAP_COMPILE_ARGS}
INCLUDES = -I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/app-file \
${GNOME_INCLUDEDIR} \
${GUILE_INCS}
libgncmod_app_file_gnome_la_SOURCES = \
gnc-file-dialog.c \
gnc-file-history.c \
gncmod-app-file-gnome.c
gncincludedir = ${GNC_INCLUDE_DIR}
gncinclude_HEADERS = \
gnc-file-history-gnome.h
libgncmod_app_file_gnome_la_LDFLAGS = -module
libgncmod_app_file_gnome_la_LIBADD = \
-L${top_srcdir}/src/gnc-module \
-L${top_srcdir}/src/gnc-module/.libs -lgncmodule \
-L${top_srcdir}/src/app-file \
-L${top_srcdir}/src/app-file/.libs -lgncmod-app-file \
${GNOMEUI_LIBS} \
${GNOME_LIBDIR} \
${GLIB_LIBS}

View File

@ -1,5 +1,5 @@
/********************************************************************\
* dialog-filebox.c -- the file dialog box *
* gnc-file-dialog.c -- the file dialog box *
* Copyright (C) 1997 Robin D. Clark <rclark@cs.hmc.edu> *
* Copyright (C) 1998-99 Rob Browning <rlb@cs.utexas.edu> *
* Copyright (C) 2000 Linas Vepstas <linas@linas.org> *
@ -32,12 +32,11 @@
#include "gnc-ui.h"
#include "messages.h"
typedef struct _FileBoxInfo FileBoxInfo;
struct _FileBoxInfo
typedef struct
{
GtkFileSelection *file_box;
char *file_name;
};
} FileBoxInfo;
/* Global filebox information */
static FileBoxInfo fb_info = {NULL, NULL};

View File

@ -0,0 +1,30 @@
/********************************************************************\
* gnc-file-history-gnome.h -- functions to maintain file-history *
* 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_FILE_HISTORY_GNOME_H
#define GNC_FILE_HISTORY_GNOME_H
#include "gnc-file-history.h"
void gnc_file_history_add_after (const char *menu_string);
#endif

View File

@ -1,5 +1,5 @@
/********************************************************************\
* file-history.c -- functions to maintain file history menu *
* gnc-file-history.c -- functions to maintain file history menu *
* Copyright (C) 2000 Robby Stephenson *
* *
* This program is free software; you can redistribute it and/or *
@ -24,11 +24,20 @@
#include <gnome.h>
#include "gnc-file-history.h"
#include "gnc-file-history-gnome.h"
#include "gnc-file.h"
static GSList *history_list = NULL;
static gint num_menu_entries = -1;
static char *add_after_string = NULL;
void
gnc_file_history_add_after (const char *menu_string)
{
g_free (add_after_string);
add_after_string = g_strdup (menu_string);
}
static void
gnc_history_config_write (void)
@ -37,26 +46,27 @@ gnc_history_config_write (void)
char *key;
GSList *tmp;
if(history_list == NULL)
if (history_list == NULL)
return;
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int(key);
g_free(key);
key = g_strdup_printf ("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int (key);
g_free (key);
gnome_config_clean_section("/GnuCash/History/");
gnome_config_push_prefix("/GnuCash/History/");
gnome_config_set_int("MaxFiles", max_files);
gnome_config_clean_section ("/GnuCash/History/");
gnome_config_push_prefix ("/GnuCash/History/");
gnome_config_set_int ("MaxFiles", max_files);
for(tmp = history_list; tmp != NULL; tmp = tmp->next) {
key = g_strdup_printf("File%d", i);
gnome_config_set_string(key, (char *)tmp->data);
for (tmp = history_list; tmp != NULL; tmp = tmp->next)
{
key = g_strdup_printf ("File%d", i);
gnome_config_set_string (key, tmp->data);
g_free(key);
i++;
}
gnome_config_sync();
gnome_config_pop_prefix();
gnome_config_sync ();
gnome_config_pop_prefix ();
}
static void
@ -65,27 +75,30 @@ gnc_history_get_list (void)
int max_files, i;
char *key, *filename;
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int(key);
g_free(key);
key = g_strdup_printf ("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int (key);
g_free (key);
gnome_config_push_prefix("/GnuCash/History/");
gnome_config_push_prefix ("/GnuCash/History/");
for(i = 0; i < max_files; i++) {
key = g_strdup_printf("File%d", i);
filename = gnome_config_get_string(key);
for (i = 0; i < max_files; i++)
{
key = g_strdup_printf ("File%d", i);
filename = gnome_config_get_string (key);
if(filename == NULL) {
if(filename == NULL)
{
g_free(key);
break;
}
history_list = g_slist_prepend(history_list, filename);
g_free(key);
history_list = g_slist_prepend (history_list, filename);
g_free (key);
}
gnome_config_pop_prefix();
gnome_config_pop_prefix ();
history_list = g_slist_reverse(history_list);
history_list = g_slist_reverse (history_list);
}
static void
@ -105,39 +118,40 @@ gnc_history_add_file (const char *newfile)
if (newfile == NULL)
return;
gnome_config_push_prefix("/GnuCash/History/");
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int_with_default(key, &used_default);
g_free(key);
gnome_config_push_prefix ("/GnuCash/History/");
key = g_strdup_printf ("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
max_files = gnome_config_get_int_with_default (key, &used_default);
g_free (key);
if(used_default)
gnome_config_set_int("MaxFiles", max_files);
if (used_default)
gnome_config_set_int ("MaxFiles", max_files);
if(history_list == NULL)
if (history_list == NULL)
gnc_history_get_list ();
i = 0;
tmp = history_list;
while(tmp != NULL && i < max_files)
while (tmp != NULL && i < max_files)
{
if(!matched && /* no match yet */
((i == max_files - 1) || /* last entry */
(strcmp(newfile, (char *)tmp->data) == 0)) ) { /* filename match */
g_free(tmp->data);
if (!matched && /* no match yet */
((i == max_files - 1) || /* last entry */
(strcmp(newfile, (char *)tmp->data) == 0))) /* filename match */
{
g_free (tmp->data);
matched = TRUE;
}
else
{
new_list = g_slist_prepend(new_list, tmp->data);
new_list = g_slist_prepend (new_list, tmp->data);
}
i++;
tmp = tmp->next;
}
new_list = g_slist_reverse(new_list);
new_list = g_slist_prepend(new_list, g_strdup(newfile));
g_slist_free(history_list);
new_list = g_slist_reverse (new_list);
new_list = g_slist_prepend (new_list, g_strdup (newfile));
g_slist_free (history_list);
history_list = new_list;
gnc_history_config_write ();
@ -161,10 +175,10 @@ gnc_history_add_file (const char *newfile)
const char *
gnc_history_get_last (void)
{
if(history_list == NULL)
if (history_list == NULL)
gnc_history_get_list ();
if(history_list == NULL)
if (history_list == NULL)
return NULL;
return history_list->data;
@ -190,21 +204,22 @@ gnc_history_update_menu (GtkWidget * app_w)
return;
g_return_if_fail (GNOME_IS_APP (app_w));
g_return_if_fail (add_after_string != NULL);
app = GNOME_APP (app_w);
di = gnome_app_get_dock_item_by_name(app, GNOME_APP_MENUBAR_NAME);
di = gnome_app_get_dock_item_by_name (app, GNOME_APP_MENUBAR_NAME);
if (di == NULL)
return;
menushell = gnome_dock_item_get_child(di);
menushell = gnome_dock_item_get_child (di);
if (menushell == NULL)
return;
if (!gnome_app_find_menu_pos (menushell, GNOME_MENU_FILE_PATH, &pos))
return;
path = g_strdup_printf("%s%s", GNOME_MENU_FILE_PATH, "New _Account Tree");
path = g_strdup_printf ("%s%s", GNOME_MENU_FILE_PATH, add_after_string);
if (!gnome_app_find_menu_pos (menushell, path, &pos))
return;
@ -217,28 +232,28 @@ gnc_history_update_menu (GtkWidget * app_w)
data = gtk_object_get_data (GTK_OBJECT (app), "gnc_num_history");
num_entries = GPOINTER_TO_INT (data);
gnome_app_remove_menu_range(app, GNOME_MENU_FILE_PATH,
pos, 1 + num_entries);
gnome_app_remove_menu_range (app, GNOME_MENU_FILE_PATH,
pos, 1 + num_entries);
}
if(history_list == NULL)
gnc_history_get_list();
if (history_list == NULL)
gnc_history_get_list ();
if (history_list == NULL)
return;
n = g_slist_length(history_list);
n = g_slist_length (history_list);
/* one separator, plus one for each filename entry, plus one for end */
menu = g_new(GnomeUIInfo, 2+n);
menu = g_new (GnomeUIInfo, 2 + n);
menu->type = GNOME_APP_UI_SEPARATOR;
for(i = 1; i <= n; i++)
for (i = 1; i <= n; i++)
{
(menu+i)->type = GNOME_APP_UI_ITEM;
/* get the file name */
file = g_slist_nth_data(history_list, i - 1);
file = g_slist_nth_data (history_list, i - 1);
if (file == NULL)
file = "";
@ -249,17 +264,18 @@ gnc_history_update_menu (GtkWidget * app_w)
count++;
/* make the name, doubling the underscores to prevent underlining */
name = g_new(char, strlen(file) + count + 1);
for (p = file, q = name; *p != '\0'; p++) {
name = g_new (char, strlen(file) + count + 1);
for (p = file, q = name; *p != '\0'; p++)
{
*q++ = *p;
if (*p == '_')
*q++ = '_';
}
*q = '\0';
(menu+i)->label = g_strdup_printf("_%d. %s", i, name);
(menu+i)->label = g_strdup_printf ("_%d. %s", i, name);
g_free(name);
g_free (name);
(menu+i)->hint = NULL;
@ -272,7 +288,7 @@ gnc_history_update_menu (GtkWidget * app_w)
}
(menu+i)->type = GNOME_APP_UI_ENDOFINFO;
gnome_app_insert_menus(GNOME_APP(app), path, menu);
gnome_app_insert_menus (GNOME_APP(app), path, menu);
num_menu_entries = n;
gtk_object_set_data (GTK_OBJECT (app), "gnc_set_history", app);
@ -280,8 +296,8 @@ gnc_history_update_menu (GtkWidget * app_w)
GINT_TO_POINTER (num_menu_entries));
for (i = 1; i <= n; i++)
g_free((menu+i)->label);
g_free ((menu+i)->label);
g_free(menu);
g_free(path);
g_free (menu);
g_free (path);
}

View File

@ -0,0 +1,49 @@
/*********************************************************************
* gncmod-app-file-gnome.c
* module definition/initialization app-level gnome file interface
*
* Copyright (c) 2001 Linux Developers Group, Inc.
*********************************************************************/
#include <stdio.h>
#include <guile/gh.h>
#include <glib.h>
#include <libguile/strports.h>
#include <libguile/modules.h>
#include "gnc-file-p.h"
#include "gnc-module.h"
#include "gnc-module-api.h"
/* version of the gnc module system interface we require */
int gnc_module_system_interface = 0;
/* module versioning uses libtool semantics. */
int gnc_module_current = 0;
int gnc_module_revision = 0;
int gnc_module_age = 0;
char *
gnc_module_path(void) {
return g_strdup("gnucash/app-file/gnome");
}
char *
gnc_module_description(void) {
return g_strdup("Application level file interface for Gnome");
}
int
gnc_module_init(int refcount) {
/* load the calculation module (we depend on it) */
if(!gnc_module_load("gnucash/app-file", 0)) {
return FALSE;
}
return TRUE;
}
int
gnc_module_end(int refcount) {
return TRUE;
}

View File

@ -8,7 +8,6 @@ libgncgnome_a_SOURCES = \
dialog-column-view.c \
dialog-commodities.c \
dialog-dup-trans.c \
dialog-filebox.c \
dialog-fincalc.c \
dialog-find-transactions.c \
dialog-new-user.c \
@ -25,7 +24,6 @@ libgncgnome_a_SOURCES = \
dialog-scheduledxaction.c \
druid-hierarchy.c \
druid-stock-split.c \
file-history.c \
file-utils.c \
gnc-network.c \
gnc-splash.c \
@ -106,6 +104,7 @@ INCLUDES = \
-I${top_srcdir}/src/network-utils \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/app-file \
-I${top_srcdir}/src/app-file/gnome \
-I${top_srcdir}/src/backend/file \
-I${top_srcdir}/src/g-wrap \
-I${top_srcdir}/src/gnome-utils \

View File

@ -50,6 +50,7 @@
#include "gnc-engine.h"
#include "gnc-file-dialog.h"
#include "gnc-file-history.h"
#include "gnc-file-history-gnome.h"
#include "gnc-file.h"
#include "gnc-gui-query.h"
#include "gnc-menu-extensions.h"
@ -1137,13 +1138,14 @@ 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_("_Windows"), gnc_windows_menu_template),
// GNOEMUIINFO_SUBTREE(N_("_Developer Options"), gnc_developer_menu_template),
GNOMEUIINFO_MENU_HELP_TREE(gnc_help_menu_template),
GNOMEUIINFO_END
};
gnome_mdi_set_menubar_template(GNOME_MDI(maininfo->mdi),
gnc_main_menu_template);
gnc_file_history_add_after ("New _Account Tree");
}
/********************************************************************

View File

@ -16,9 +16,11 @@ LDADD = \
-L${top_srcdir}/src/app-utils -L${top_srcdir}/src/app-utils/.libs \
-L${top_srcdir}/src/gnome-utils -L${top_srcdir}/src/gnome-utils/.libs \
-L${top_srcdir}/src/app-file -L${top_srcdir}/src/app-file/.libs \
-L${top_srcdir}/src/app-file/gnome -L${top_srcdir}/src/app-file/gnome/.libs \
${top_srcdir}/src/gnc-module/libgncmodule.la \
${top_srcdir}/src/engine/libgncmod-engine.la \
${top_srcdir}/src/app-utils/libgncmod-app-utils.la \
${top_srcdir}/src/app-file/gnome/libgncmod-app-file-gnome.la \
${top_srcdir}/src/gnome-utils/libgncmod-gnome-utils.la \
../libgncmod-binary-import.la \
${top_srcdir}/src/engine/libgw-engine.la \

View File

@ -146,7 +146,7 @@
;; Hopefully we can gradually make them autoloading.
(gnc:module-load "gnucash/engine" 0)
(gnc:module-load "gnucash/app-utils" 0)
(gnc:module-load "gnucash/app-file" 0)
(gnc:module-load "gnucash/app-file/gnome" 0)
(gnc:module-load "gnucash/register/ledger-core" 0)
(gnc:module-load "gnucash/register/register-core" 0)
(gnc:module-load "gnucash/register/register-gnome" 0)