diff --git a/src/gnome/MainWindow.c b/src/gnome/MainWindow.c index 0a4bdb1095..0de23fe1b7 100644 --- a/src/gnome/MainWindow.c +++ b/src/gnome/MainWindow.c @@ -114,7 +114,7 @@ main_window_init(AccountGroup *accts) { {"
/File/New", "N", NULL, NULL}, {"
/File/Open", "O", file_cmd_open, NULL}, - {"
/File/Save", "S", NULL, NULL}, + {"
/File/Save", "S", file_cmd_save, NULL}, {"
/File/Save as", NULL, NULL, NULL}, {"
/File/", NULL, NULL, NULL}, {"
/File/Quit", "Q", file_cmd_quit, NULL }, diff --git a/src/gnome/Makefile b/src/gnome/Makefile index 623f1b7b13..8afa322cac 100644 --- a/src/gnome/Makefile +++ b/src/gnome/Makefile @@ -28,12 +28,12 @@ srcdir = . CC = gcc -INCLPATH = -I.. -I../.. -I../engine -I../register -I./../../include +INCLPATH = -I.. -I../.. -I../engine -I../register -I./../../include CFLAGS = -O2 -Wall -g -Wall -I/usr/X11R6/include ${INCLPATH} LDFLAGS = -g -Wall LIBS = -lpng -ljpeg -lz -lm -lSM -lICE -lXpm -L/usr/X11R6/lib $(shell gtk-config --libs) \ - -lgnomeui -lgnome -lgnomesupport + -lgnomeui -lgnome -lgnomesupport -lgdk_imlib -ltiff -ldl TARGET = ../../xacc.gtk.bin STATIC = ../../xacc-static.gtk.bin @@ -42,7 +42,7 @@ OTHER_OBJS := ../obj/gnome/*.o ../engine/obj/*.o ../register/obj/gnome/*.o ###################################################################### # See Makefile.common for information about these variables. -GNOME_SRCS := main.c MainWindow.c MenuBar.c RegWindow.c +GNOME_SRCS := main.c MainWindow.c MenuBar.c RegWindow.c Dialogs.c # AccWindow.c AccountMenu.c AdjBWindow.c \ # BuildMenu.c Destroy.c FileBox.c HelpWindow.c \ # RecnWindow.c RegWindow.c Reports.c TextBox.c \ diff --git a/src/gnome/Makefile.in b/src/gnome/Makefile.in index 1838e080a4..e4154f8d3f 100644 --- a/src/gnome/Makefile.in +++ b/src/gnome/Makefile.in @@ -28,7 +28,7 @@ srcdir = @srcdir@ VPATH = @srcdir@ CC = @CC@ -INCLPATH = -I.. -I../.. -I../engine -I../register -I@srcdir@/../../include -I/usr/lib/gnome-libs/include +INCLPATH = -I.. -I../.. -I../engine -I../register -I@srcdir@/../../include CFLAGS = @CFLAGS@ @X_CFLAGS@ ${INCLPATH} LDFLAGS = @LDFLAGS@ diff --git a/src/gnome/RegWindow.c b/src/gnome/RegWindow.c index fa427966e2..8041ee271e 100644 --- a/src/gnome/RegWindow.c +++ b/src/gnome/RegWindow.c @@ -470,6 +470,7 @@ regWindowLedger(Account *lead_acc, Account **acclist, int ledger_type) regData->dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(regData->dialog), windowname); /* when the window is given the "delete_event" signal (this is given @@ -486,6 +487,9 @@ regWindowLedger(Account *lead_acc, Account **acclist, int ledger_type) gtk_signal_connect (GTK_OBJECT (regData->dialog), "destroy", GTK_SIGNAL_FUNC (destroy), (gpointer) regData); + + +#if 0 /* Create a PanedWindow Manager for the dialog box... the paned * window is the parent of the two forms which comprise the two * areas of the dialog box */ @@ -495,7 +499,6 @@ regWindowLedger(Account *lead_acc, Account **acclist, int ledger_type) * group. Put is another way: it is REALLY annoying to have to * put the mouse in the cell being edited. */ -#if 0 pane = XtVaCreateWidget( "pane", xmPanedWindowWidgetClass, regData->dialog, XmNsashWidth, 1, @@ -1051,8 +1054,8 @@ cancelCB( GtkWidget * mw, XtPointer cd, XtPointer cb ) Local Variables: tab-width: 2 indent-tabs-mode: nil - mode: c-mode + mode: c c-indentation-style: gnu - eval: (c-set-offset 'block-open '-) + eval: (c-set-offset 'substatement-open 0) End: */ diff --git a/src/gnome/main.c b/src/gnome/main.c index 2a5e221ecd..b184ae5b8c 100644 --- a/src/gnome/main.c +++ b/src/gnome/main.c @@ -61,8 +61,8 @@ gchar *accRes[] ={ "equity" }; - -void file_ok_sel (GtkWidget *w, GtkFileSelection *fs) +void +file_ok_sel (GtkWidget *w, GtkFileSelection *fs) { datafile = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); @@ -82,16 +82,30 @@ void file_ok_sel (GtkWidget *w, GtkFileSelection *fs) main_window_init(topgroup); } -void gnucash_shutdown (GtkWidget *widget, gpointer *data) +void +gnucash_shutdown (GtkWidget *widget, gpointer *data) { gtk_main_quit (); } -void file_cmd_open (GtkWidget *widget, gpointer data) +void +file_cmd_open (GtkWidget *widget, gpointer data) { g_print ( "Menu Command: file open\n" ); } +void +file_cmd_save(GtkWidget *widget, gpointer data) +{ + /* hack alert -- Somehow make sure all in-progress edits get committed! */ + if (NULL == datafile) { + fprintf(stderr, "Can't save file. No open file\n"); + return; + } + xaccWriteAccountGroup(datafile, topgroup); + xaccAccountGroupMarkSaved(topgroup); +} + void file_cmd_quit (GtkWidget *widget, gpointer data) { gtk_main_quit(); @@ -113,6 +127,14 @@ int main( int argc, char *argv[] ) { // gtk_init ( &argc, &argv ); + + if(argc > 1) { + /* Gnome is a pain about this if we don't handle it first + We need real arg parsing here later */ + datafile = argv[1]; + argc--; + argv++; + } gnome_init ("GnuCash", NULL, argc, argv, 0, NULL); @@ -130,55 +152,6 @@ main( int argc, char *argv[] ) } filebox = gtk_file_selection_new ( "Open..." ); - - /* read in the filename (should be the first arg after all - * the X11 stuff */ - if( argc > 1 ) - { - datafile = argv[1]; - - if( datafile != NULL ) - { - - /* load the accounts data from datafile*/ - topgroup = xaccReadAccountGroup (datafile); - - if ( topgroup == NULL ) - { - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *label; - - dialog = gtk_dialog_new (); - - button = gtk_button_new_with_label ( "Ok" ); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, - TRUE, TRUE, 0); - gtk_widget_show ( button ); - - label = gtk_label_new (" \nInvalid filename \nNew file started.\n "); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, - TRUE, 0); - gtk_widget_show ( label ); - gtk_widget_show ( dialog ); - - topgroup = xaccMallocAccountGroup(); - } - } - /* Create main window */ - main_window_init(topgroup); - } - else - { - /* Filebox code here */ - gtk_widget_show ( filebox ); - } - - /* Check to see if this is a valid datafile */ - if ( datafile != NULL ) - topgroup = xaccReadAccountGroup (datafile); - - /* Callbacks for File Box and Stuff */ gtk_signal_connect (GTK_OBJECT (filebox), "delete_event", @@ -192,8 +165,41 @@ main( int argc, char *argv[] ) /* Connect the cancel_button to also kill the app */ gtk_signal_connect_object ( GTK_OBJECT (GTK_FILE_SELECTION (filebox)->cancel_button), "clicked", (GtkSignalFunc) gtk_exit, NULL ); - + /* read in the filename (should be the first arg after all + * the X11 stuff */ + if( datafile != NULL ) { + + /* load the accounts data from datafile*/ + topgroup = xaccReadAccountGroup (datafile); + + if ( topgroup == NULL ) + { + GtkWidget *dialog; + GtkWidget *button; + GtkWidget *label; + + dialog = gtk_dialog_new (); + + button = gtk_button_new_with_label ( "Ok" ); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, + TRUE, TRUE, 0); + gtk_widget_show ( button ); + + label = gtk_label_new (" \nInvalid filename \nNew file started.\n "); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, + TRUE, 0); + gtk_widget_show ( label ); + gtk_widget_show ( dialog ); + + topgroup = xaccMallocAccountGroup(); + } + /* Create main window */ + main_window_init(topgroup); + } else { + /* Filebox code here */ + gtk_widget_show ( filebox ); + } /* Enter event loop */ gtk_main(); diff --git a/src/gnome/main.h b/src/gnome/main.h index 824634b818..66d26fc62e 100644 --- a/src/gnome/main.h +++ b/src/gnome/main.h @@ -53,8 +53,10 @@ void gnucash_shutdown (GtkWidget *widget, gpointer *data); void file_cmd_open (GtkWidget *widget, gpointer data); void file_cmd_quit (GtkWidget *widget, gpointer data); +void file_cmd_save (GtkWidget *widget, gpointer data); void prepare_app ( void ); + /** GLOBALS *********************************************************/ extern char *helpPath; extern GtkWidget *app;