mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gtk port of xacc
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@607 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7901c4592e
commit
df8e7b5881
138
src/gnome/MainWindow.c
Normal file
138
src/gnome/MainWindow.c
Normal file
@ -0,0 +1,138 @@
|
||||
/********************************************************************\
|
||||
* MainWindow.c -- the main window, and associated helper functions *
|
||||
* and callback functions for xacc (X-Accountant) *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1998 Jeremy Collins *
|
||||
* *
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* *
|
||||
* Author: Rob Clark *
|
||||
* Internet: rclark@cs.hmc.edu *
|
||||
* Address: 609 8th Street *
|
||||
* Huntington Beach, CA 92648-4632 *
|
||||
\********************************************************************/
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
//#include "main_window.h"
|
||||
#include "main.h"
|
||||
|
||||
gchar *clist_titles[] =
|
||||
{
|
||||
"Account Name",
|
||||
"Type",
|
||||
"Balance"
|
||||
};
|
||||
|
||||
struct main_window {
|
||||
|
||||
};
|
||||
|
||||
void main_window_init()
|
||||
{
|
||||
|
||||
GtkWidget *window;
|
||||
GtkWidget *toolBar[5];
|
||||
|
||||
GtkTooltips *tooltip;
|
||||
|
||||
GtkWidget *label;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *button_bar;
|
||||
|
||||
GtkWidget *menubar;
|
||||
|
||||
GtkWidget *clist;
|
||||
GtkWidget *list_item;
|
||||
|
||||
|
||||
GtkAcceleratorTable *accel;
|
||||
|
||||
clist = gtk_clist_new_with_titles(3, clist_titles);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "GnoMoney");
|
||||
|
||||
main_vbox = gtk_vbox_new(FALSE, 1);
|
||||
gtk_container_border_width(GTK_CONTAINER(main_vbox), 1);
|
||||
gtk_container_add(GTK_CONTAINER(window), main_vbox);
|
||||
|
||||
get_main_menu(&menubar, &accel);
|
||||
gtk_window_add_accelerator_table(GTK_WINDOW(window), accel);
|
||||
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
|
||||
gtk_widget_show(menubar);
|
||||
|
||||
/* create a bunch of buttons */
|
||||
|
||||
button_bar = gtk_hbox_new(FALSE, 1);
|
||||
toolBar[0] = gtk_button_new_with_label (" Open ");
|
||||
toolBar[1] = gtk_button_new_with_label (" New ");
|
||||
toolBar[2] = gtk_button_new_with_label (" Edit ");
|
||||
toolBar[3] = gtk_button_new_with_label (" Delete ");
|
||||
toolBar[4] = gtk_button_new_with_label (" Exit ");
|
||||
|
||||
/* Initilize ToolTips */
|
||||
|
||||
/*
|
||||
tooltip = gtk_tooltips_new ();
|
||||
gtk_tooltips_set_tips (tooltip, toolBar[open], "Open an account.");
|
||||
gtk_tooltips_set_tips (tooltip, toolBar[close], "Create a new account.");
|
||||
gtk_tooltips_set_tips (tooltip, toolBar[button3], "Edit selected account");
|
||||
gtk_tooltips_set_tips (tooltip, toolBar[button4], "Delete selected account");
|
||||
gtk_tooltips_set_tips (tooltip, toolBar[exit], "Exit GnoMoney.");
|
||||
*/
|
||||
|
||||
/* Pack the buttons into the toolbar */
|
||||
gtk_box_pack_start(GTK_BOX(button_bar), toolBar[0], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(button_bar), toolBar[1], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(button_bar), toolBar[2], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(button_bar), toolBar[3], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(button_bar), toolBar[4], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(main_vbox), clist, FALSE, FALSE, 1);
|
||||
gtk_box_pack_start(GTK_BOX(main_vbox), button_bar, FALSE, TRUE, 1);
|
||||
|
||||
|
||||
gtk_widget_show(toolBar[open]);
|
||||
gtk_widget_show(toolBar[close]);
|
||||
gtk_widget_show(toolBar[button3]);
|
||||
gtk_widget_show(toolBar[button4]);
|
||||
gtk_widget_show(toolBar[exit]);
|
||||
gtk_widget_show(button_bar);
|
||||
gtk_widget_show(clist);
|
||||
|
||||
gtk_widget_set_usize (window, 400, 400 );
|
||||
gtk_widget_set_usize ( clist, 400, 300 );
|
||||
|
||||
/* Setup some callbacks */
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC (destroy), NULL);
|
||||
|
||||
//gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
||||
// GTK_SIGNAL_FUNC(file_quit_cmd_callback),
|
||||
// "WM destroy");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (gtk_exit), NULL);
|
||||
|
||||
/* Show everything now that it is created */
|
||||
gtk_widget_show(main_vbox);
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 2);
|
||||
gtk_widget_show(window);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/********************* END OF FILE **********************************/
|
85
src/gnome/Makefile
Normal file
85
src/gnome/Makefile
Normal file
@ -0,0 +1,85 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
#
|
||||
######################################################################
|
||||
#********************************************************************
|
||||
#* Makefile -- makefile for xacc/src *
|
||||
#* Copyright (C) 1997 Robin Clark *
|
||||
#* *
|
||||
#* 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, write to the Free Software *
|
||||
#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
#* *
|
||||
#* Author: Robin Clark *
|
||||
#* Internet: rclark@rush.aero.org *
|
||||
#* Address: 609 8th Street *
|
||||
#* Huntington Beach, CA 92648-4632 *
|
||||
#********************************************************************
|
||||
|
||||
srcdir = .
|
||||
CC = gcc
|
||||
INCLPATH = -I/usr/include \
|
||||
-I.. \
|
||||
-I../.. \
|
||||
-I../../include \
|
||||
-I../engine \
|
||||
-I../register \
|
||||
-I/usr/local/include \
|
||||
-I/usr/X11R6/include/. \
|
||||
-I./../../include
|
||||
|
||||
|
||||
CFLAGS = -g
|
||||
LFLAGS = -g
|
||||
LIBS = -lXpm -lgtk -lgdk -lglib -lXext -lXmu -lXt -lXext -lSM -lICE -lX11 -lpng -ljpeg -lz -lm
|
||||
LIBPATH = -L/lib -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib/.
|
||||
TARGET = ../../xacc.gtk.bin
|
||||
|
||||
#LIBREG = ../libregister.a
|
||||
LIBENG = ../libengine.a
|
||||
######################################################################
|
||||
SRCS = main.c MainWindow.c MenuBar.c
|
||||
|
||||
#SRCS = AccWindow.c AccountMenu.c AdjBWindow.c \
|
||||
# BuildMenu.c Destroy.c FileBox.c HelpWindow.c MainWindow.c \
|
||||
# RecnWindow.c RegWindow.c Reports.c TextBox.c \
|
||||
# XferWindow.c main.c xtutil.c
|
||||
#OBJS = ${SRCS:.c=.o} $(LIBENG) ../Ledger.o
|
||||
OBJS = ${SRCS:.c=.o} $(LIBENG)
|
||||
######################################################################
|
||||
|
||||
default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
@echo "++++++"
|
||||
$(CC) $(LFLAGS) $(OBJS) $(LIBPATH) $(LIBS) -o $@
|
||||
|
||||
static: $(STATIC)
|
||||
|
||||
$(STATIC): $(OBJS)
|
||||
@echo "++++++"
|
||||
$(CC) $(LFLAGS) $(OBJS) $(LIBPATH) $(LIBS) -o $@ -static
|
||||
|
||||
.c.o:
|
||||
@echo "+++"
|
||||
$(CC) -c $(CFLAGS) $(INCLPATH) $<
|
||||
|
||||
depend:
|
||||
makedepend -- $(INCLPATH) $(DEFN) -- $(SRCS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ *.bak
|
||||
|
||||
distclean: clean
|
||||
rm -f $(TARGET) $(STATIC) Makefile Makefile.bak config.h
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
87
src/gnome/Makefile.in
Normal file
87
src/gnome/Makefile.in
Normal file
@ -0,0 +1,87 @@
|
||||
#
|
||||
######################################################################
|
||||
#********************************************************************
|
||||
#* Makefile -- makefile for xacc/src *
|
||||
#* Copyright (C) 1997 Robin Clark *
|
||||
#* *
|
||||
#* 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, write to the Free Software *
|
||||
#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
#* *
|
||||
#* Author: Robin Clark *
|
||||
#* Internet: rclark@rush.aero.org *
|
||||
#* Address: 609 8th Street *
|
||||
#* Huntington Beach, CA 92648-4632 *
|
||||
#********************************************************************
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
CC = @CC@
|
||||
INCLPATH = -I/usr/include \
|
||||
-I.. \
|
||||
-I../.. \
|
||||
-I../engine \
|
||||
-I../register \
|
||||
-I/usr/local/include \
|
||||
-I@x_includes@/. \
|
||||
-I@srcdir@/../../include
|
||||
|
||||
# libhtmlw eliminated due to license restrictions
|
||||
# and general brokenness
|
||||
# -I@srcdir@/../../lib/libhtmlw
|
||||
|
||||
CFLAGS = @cflags@
|
||||
LFLAGS = @lflags@
|
||||
LIBS = @LIBS@
|
||||
LIBPATH = -L/lib -L/usr/lib -L/usr/local/lib -L@x_libraries@/.
|
||||
TARGET = ../../xacc.gtk.bin
|
||||
STATIC = ../../xacc-static.bin
|
||||
|
||||
LIBREG = ../libregister.a
|
||||
LIBENG = ../libengine.a
|
||||
######################################################################
|
||||
SRCS = main.c MainWindow.c MenuBar.c
|
||||
|
||||
# SRCS = AccWindow.c AccountMenu.c AdjBWindow.c \
|
||||
# BuildMenu.c Destroy.c FileBox.c HelpWindow.c MainWindow.c \
|
||||
# RecnWindow.c RegWindow.c Reports.c TextBox.c \
|
||||
# XferWindow.c date.c main.c xtutil.c
|
||||
OBJS = ${SRCS:.c=.o} $(LIBENG) $(LIBREG) ../Ledger.o
|
||||
######################################################################
|
||||
|
||||
default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
@echo "++++++"
|
||||
$(CC) $(LFLAGS) $(OBJS) $(LIBPATH) $(LIBS) -o $@
|
||||
|
||||
static: $(STATIC)
|
||||
|
||||
$(STATIC): $(OBJS)
|
||||
@echo "++++++"
|
||||
$(CC) $(LFLAGS) $(OBJS) $(LIBPATH) $(LIBS) -o $@ -static
|
||||
|
||||
.c.o:
|
||||
@echo "+++"
|
||||
$(CC) -c $(CFLAGS) $(INCLPATH) $<
|
||||
|
||||
depend:
|
||||
makedepend -- $(INCLPATH) $(DEFN) -- $(SRCS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ *.bak
|
||||
|
||||
distclean: clean
|
||||
rm -f $(TARGET) $(STATIC) Makefile Makefile.bak config.h
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
156
src/gnome/MenuBar.c
Normal file
156
src/gnome/MenuBar.c
Normal file
@ -0,0 +1,156 @@
|
||||
// WaterMark/GnoMoney
|
||||
// mainMenu.c
|
||||
// from Gtk tutorial
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "main.h"
|
||||
|
||||
static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
|
||||
path);
|
||||
static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
|
||||
key, gchar modifiers, gchar * path);
|
||||
void menus_init(void);
|
||||
void menus_create(GtkMenuEntry * entries, int nmenu_entries);
|
||||
|
||||
|
||||
/* this is the GtkMenuEntry structure used to create new menus. The
|
||||
* first member is the menu definition string. The second, the
|
||||
* default accelerator key used to access this menu function with
|
||||
* the keyboard. The third is the callback function to call when
|
||||
* this menu item is selected (by the accelerator key, or with the
|
||||
* mouse.) The last member is the data to pass to your callback function.
|
||||
*/
|
||||
|
||||
static GtkMenuEntry menu_items[] =
|
||||
{
|
||||
{"<Main>/File/New", "<control>N", NULL, NULL},
|
||||
{"<Main>/File/Open", "<control>O", NULL, NULL},
|
||||
{"<Main>/File/Save", "<control>S", NULL, NULL},
|
||||
{"<Main>/File/Save as", NULL, NULL, NULL},
|
||||
{"<Main>/File/<separator>", NULL, NULL, NULL},
|
||||
{"<Main>/File/Quit", "<control>Q", NULL, "OK, I'll quit"},
|
||||
{"<Main>/Options/General..", NULL, NULL, NULL},
|
||||
{"<Main>/Help/About..", NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
/* calculate the number of menu_item's */
|
||||
static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
||||
|
||||
static int initialize = TRUE;
|
||||
static GtkMenuFactory *factory = NULL;
|
||||
static GtkMenuFactory *subfactory[1];
|
||||
static GHashTable *entry_ht = NULL;
|
||||
|
||||
void get_main_menu(GtkWidget ** menubar, GtkAcceleratorTable ** table)
|
||||
{
|
||||
if (initialize)
|
||||
menus_init();
|
||||
|
||||
if (menubar)
|
||||
*menubar = subfactory[0]->widget;
|
||||
if (table)
|
||||
*table = subfactory[0]->table;
|
||||
}
|
||||
|
||||
void menus_init(void)
|
||||
{
|
||||
if (initialize) {
|
||||
initialize = FALSE;
|
||||
|
||||
factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
subfactory[0] = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
|
||||
|
||||
gtk_menu_factory_add_subfactory(factory, subfactory[0], "<Main>");
|
||||
menus_create(menu_items, nmenu_items);
|
||||
}
|
||||
}
|
||||
|
||||
void menus_create(GtkMenuEntry * entries, int nmenu_entries)
|
||||
{
|
||||
char *accelerator;
|
||||
int i;
|
||||
|
||||
if (initialize)
|
||||
menus_init();
|
||||
|
||||
if (entry_ht)
|
||||
for (i = 0; i < nmenu_entries; i++) {
|
||||
accelerator = g_hash_table_lookup(entry_ht, entries[i].path);
|
||||
if (accelerator) {
|
||||
if (accelerator[0] == '\0')
|
||||
entries[i].accelerator = NULL;
|
||||
else
|
||||
entries[i].accelerator = accelerator;
|
||||
}
|
||||
}
|
||||
gtk_menu_factory_add_entries(factory, entries, nmenu_entries);
|
||||
|
||||
for (i = 0; i < nmenu_entries; i++)
|
||||
if (entries[i].widget) {
|
||||
gtk_signal_connect(GTK_OBJECT(entries[i].widget), "install_accelerator",
|
||||
GTK_SIGNAL_FUNC(menus_install_accel),
|
||||
entries[i].path);
|
||||
gtk_signal_connect(GTK_OBJECT(entries[i].widget), "remove_accelerator",
|
||||
GTK_SIGNAL_FUNC(menus_remove_accel),
|
||||
entries[i].path);
|
||||
}
|
||||
}
|
||||
|
||||
static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
|
||||
key, gchar modifiers, gchar * path)
|
||||
{
|
||||
char accel[64];
|
||||
char *t1, t2[2];
|
||||
|
||||
accel[0] = '\0';
|
||||
if (modifiers & GDK_CONTROL_MASK)
|
||||
strcat(accel, "<control>");
|
||||
if (modifiers & GDK_SHIFT_MASK)
|
||||
strcat(accel, "<shift>");
|
||||
if (modifiers & GDK_MOD1_MASK)
|
||||
strcat(accel, "<alt>");
|
||||
|
||||
t2[0] = key;
|
||||
t2[1] = '\0';
|
||||
strcat(accel, t2);
|
||||
|
||||
/* if (entry_ht) {
|
||||
t1 = g_hash_table_lookup(entry_ht, path);
|
||||
g_free(t1);
|
||||
} else
|
||||
entry_ht = g_hash_table_new(g_string_hash, g_string_equal);
|
||||
*/
|
||||
g_hash_table_insert(entry_ht, path, g_strdup(accel));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
|
||||
path)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (entry_ht) {
|
||||
t = g_hash_table_lookup(entry_ht, path);
|
||||
g_free(t);
|
||||
|
||||
g_hash_table_insert(entry_ht, path, g_strdup(""));
|
||||
}
|
||||
}
|
||||
|
||||
void menus_set_sensitive(char *path, int sensitive)
|
||||
{
|
||||
GtkMenuPath *menu_path;
|
||||
|
||||
if (initialize)
|
||||
menus_init();
|
||||
|
||||
menu_path = gtk_menu_factory_find(factory, path);
|
||||
if (menu_path)
|
||||
gtk_widget_set_sensitive(menu_path->widget, sensitive);
|
||||
else
|
||||
g_warning("Unable to set sensitivity for menu which doesn't exist:
|
||||
%s", path);
|
||||
}
|
18
src/gnome/README
Normal file
18
src/gnome/README
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
This directory contains the Gtk GUI code for the xacc application.
|
||||
|
||||
Whats been done so far:
|
||||
|
||||
File Selection box pops up if no file is specified on the
|
||||
command line. Otherwise the main window starts up.
|
||||
|
||||
|
||||
|
||||
This directory contains the Gtk GUI code for the xacc application.
|
||||
|
||||
Whats been done so far:
|
||||
|
||||
File Selection box pops up if no file is specified on the
|
||||
command line. Otherwise the main window starts up.
|
||||
|
||||
|
164
src/gnome/main.c
Normal file
164
src/gnome/main.c
Normal file
@ -0,0 +1,164 @@
|
||||
/********************************************************************\
|
||||
* main.c -- main for xacc (X-Accountant) *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* *
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* *
|
||||
* Author: Rob Clark *
|
||||
* Internet: rclark@cs.hmc.edu *
|
||||
* Address: 609 8th Street *
|
||||
* Huntington Beach, CA 92648-4632 *
|
||||
\********************************************************************/
|
||||
|
||||
// #include <Xm/Xm.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
#include "FileIO.h"
|
||||
#include "Group.h"
|
||||
#include "util.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
/* Motif GUI includes
|
||||
#include "FileBox.h"
|
||||
|
||||
*/
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
char *datafile = NULL;
|
||||
char *helpPath = NULL;
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *filebox;
|
||||
|
||||
/* The names of the different types of accounts. For resource
|
||||
* specification. Must match the enums in Account.h */
|
||||
/*
|
||||
String accRes[] ={
|
||||
"bank",
|
||||
"cash",
|
||||
"asset",
|
||||
"credit",
|
||||
"liability",
|
||||
"portfolio",
|
||||
"mutual",
|
||||
"income",
|
||||
"expense",
|
||||
"equity"
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
/* Get the selected filename and print it to the console */
|
||||
/* This function should eventually get the filename, and */
|
||||
/* close the filebox. */
|
||||
void file_ok_sel (GtkWidget *w, GtkFileSelection *fs)
|
||||
{
|
||||
datafile = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
|
||||
if( datafile != NULL )
|
||||
{
|
||||
/* load the accounts data from datafile*/
|
||||
topgroup = xaccReadAccountGroup (datafile);
|
||||
/* Close the filebox */
|
||||
gtk_widget_destroy(filebox);
|
||||
}
|
||||
|
||||
if( NULL == topgroup )
|
||||
{
|
||||
topgroup = xaccMallocAccountGroup();
|
||||
topgroup->new = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void destroy (GtkWidget *widget, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* main *
|
||||
* the entry point for the program... sets up the top level widget *
|
||||
* and calls the mainWindow() function which creates the main *
|
||||
* window. *
|
||||
* *
|
||||
* Args: argc, the number of command line arguments, and argv, *
|
||||
* the array of command line args *
|
||||
* Return: *
|
||||
* Global: topgroup - the data from the datafile *
|
||||
* datafile - the name of the user's datafile *
|
||||
* toplevel - the toplevel widget, for creating new windows *
|
||||
* app - the XtAppContext *
|
||||
\********************************************************************/
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
#if DEBUG_MEMORY
|
||||
char *blk;
|
||||
DEBUG("Initializing memory");
|
||||
blk = (char *)_malloc(8192);
|
||||
_free(blk);
|
||||
printf(" coresize = %d\n",_coresize());
|
||||
DEBUG("Done initializing memory");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
filebox = gtk_file_selection_new ("File selection");
|
||||
|
||||
/* read in the filename (should be the first arg after all
|
||||
* the X11 stuff */
|
||||
if( argc > 1 )
|
||||
datafile = argv[1];
|
||||
else
|
||||
{
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filebox), "*");
|
||||
gtk_widget_show(filebox);
|
||||
}
|
||||
|
||||
|
||||
/* Callbacks for File Box and Stuff */
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (filebox), "delete_event",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT(filebox));
|
||||
|
||||
/* Connect the ok_button to file_ok_sel function */
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filebox)->ok_button),
|
||||
"clicked", (GtkSignalFunc) file_ok_sel, filebox );
|
||||
|
||||
/* Connect the cancel_button to destroy the widget */
|
||||
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(filebox)->cancel_button),
|
||||
"clicked", (GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (filebox));
|
||||
|
||||
/* Make main window */
|
||||
main_window_init();
|
||||
|
||||
|
||||
|
||||
/* Enter event loop */
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user