mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
patches from Dave Peticolas <peticola@morpheus.cs.ucdavis.edu>
Date: Sun, 17 Oct 1999 18:01:53 -0700 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1939 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
04b7c965f3
commit
1b257312ea
@ -67,7 +67,7 @@ OTHER_OBJS += $(wildcard @top_srcdir@/src/g-wrap/obj/gnome/*.o)
|
||||
######################################################################
|
||||
# See Makefile.common for information about these variables.
|
||||
GNOME_SRCS := top-level.c window-main.c window-register.c window-adjust.c \
|
||||
window-help.c \
|
||||
window-help.c cursors.c account-tree.c \
|
||||
ui-callbacks.c window-reconcile.c \
|
||||
dialog-options.c dialog-filebox.c \
|
||||
dialog-add.c dialog-edit.c \
|
||||
|
247
src/gnome/account-tree.c
Normal file
247
src/gnome/account-tree.c
Normal file
@ -0,0 +1,247 @@
|
||||
/********************************************************************\
|
||||
* account-tree.c -- The tree of accounts in the main window, and *
|
||||
* associated helper and callback functions for *
|
||||
* GnuCash. *
|
||||
* Copyright (C) 1998,1999 Jeremy Collins *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "top-level.h"
|
||||
#include "gnucash.h"
|
||||
#include "messages.h"
|
||||
#include "AccWindow.h"
|
||||
#include "FileDialog.h"
|
||||
#include "account-tree.h"
|
||||
#include "account-treeP.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_create_account_tree *
|
||||
* creates the account tree *
|
||||
* *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
GtkWidget *
|
||||
gnc_create_account_tree()
|
||||
{
|
||||
GtkWidget *ctree;
|
||||
gchar *ctitles[] = {ACC_NAME_STR,
|
||||
DESC_STR,
|
||||
BALN_STR,
|
||||
NULL};
|
||||
gint num_titles = 0;
|
||||
|
||||
while (ctitles[num_titles] != NULL)
|
||||
num_titles++;
|
||||
|
||||
/* Create ctree */
|
||||
ctree = gtk_ctree_new_with_titles(num_titles, 0, ctitles);
|
||||
|
||||
gtk_clist_set_shadow_type (GTK_CLIST(ctree), GTK_SHADOW_IN);
|
||||
|
||||
{
|
||||
GtkStyle *st = gtk_widget_get_style(GTK_WIDGET(ctree));
|
||||
GdkFont *font = NULL;
|
||||
gint width;
|
||||
gint i;
|
||||
|
||||
if (st != NULL)
|
||||
font = st->font;
|
||||
|
||||
if (font != NULL)
|
||||
for (i = 0; i < num_titles; i++)
|
||||
{
|
||||
width = gdk_string_width(font, ctitles[i]);
|
||||
gtk_clist_set_column_min_width(GTK_CLIST(ctree), i, width + 5);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"button_press_event",
|
||||
GTK_SIGNAL_FUNC(gnc_ctree_button_press_cb),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"tree_select_row",
|
||||
GTK_SIGNAL_FUNC(gnc_acct_ctree_select_cb),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"tree_unselect_row",
|
||||
GTK_SIGNAL_FUNC(gnc_acct_ctree_unselect_cb),
|
||||
NULL);
|
||||
|
||||
gtk_object_set_data(GTK_OBJECT(gnc_get_ui_data()), "ctree", ctree);
|
||||
|
||||
return ctree;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_ui_refresh_tree *
|
||||
* refreshes the account tree *
|
||||
* *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_ui_refresh_tree()
|
||||
{
|
||||
GtkCTree *ctree;
|
||||
AccountGroup *accts;
|
||||
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"ctree");
|
||||
|
||||
accts = gncGetCurrentGroup();
|
||||
|
||||
gtk_clist_freeze(GTK_CLIST(ctree));
|
||||
|
||||
gtk_clist_clear(GTK_CLIST(ctree));
|
||||
|
||||
gnc_ui_acct_ctree_fill(ctree, NULL, accts);
|
||||
|
||||
gtk_clist_thaw(GTK_CLIST(ctree));
|
||||
|
||||
gtk_clist_columns_autosize(GTK_CLIST(ctree));
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_ctree_button_press_cb(GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
GtkCTree *ctree = GTK_CTREE(widget);
|
||||
GtkCList *clist = GTK_CLIST(widget);
|
||||
GtkCTreeNode *node;
|
||||
Account *account, *old_acct;
|
||||
gint x, y, row, column;
|
||||
|
||||
if (event->window == clist->clist_window) {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
|
||||
if (!gtk_clist_get_selection_info(clist, x, y, &row, &column))
|
||||
return FALSE;
|
||||
|
||||
node = gtk_ctree_node_nth (ctree, row);
|
||||
account = gtk_ctree_node_get_row_data(ctree, node);
|
||||
|
||||
if (event->type == GDK_2BUTTON_PRESS) {
|
||||
/* so the the button_release will leave it selected */
|
||||
gtk_ctree_unselect (ctree, node);
|
||||
/* this will stop the node from being collapsed/expanded */
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "button_press_event");
|
||||
regWindowSimple ( account );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_acct_ctree_select_cb(GtkWidget *widget, GtkCTreeNode *row,
|
||||
gint column, gpointer user_data)
|
||||
{
|
||||
Account *account;
|
||||
|
||||
account = (Account *)gtk_ctree_node_get_row_data(GTK_CTREE(widget),
|
||||
GTK_CTREE_NODE(row));
|
||||
|
||||
gtk_object_set_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account", account);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_acct_ctree_unselect_cb(GtkWidget *widget, GtkCTreeNode *row,
|
||||
gint column, gpointer user_data)
|
||||
{
|
||||
gtk_object_set_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_acct_ctree_fill(GtkCTree *ctree, GtkCTreeNode *parent,
|
||||
AccountGroup *accts)
|
||||
{
|
||||
Account *acc;
|
||||
AccountGroup *acc_children;
|
||||
GtkCTreeNode *sibling = NULL;
|
||||
gint totalAccounts = xaccGroupGetNumAccounts(accts);
|
||||
gint currentAccount;
|
||||
|
||||
/* Add each account to the tree */
|
||||
for ( currentAccount = 0;
|
||||
currentAccount < totalAccounts;
|
||||
currentAccount++ )
|
||||
{
|
||||
acc = xaccGroupGetAccount(accts, currentAccount);
|
||||
acc_children = xaccAccountGetChildren (acc);
|
||||
|
||||
gnc_tree_insert_row(ctree, parent, &sibling, acc);
|
||||
|
||||
/* If this account has children,
|
||||
* then we need to build a subtree and fill it.
|
||||
*/
|
||||
if(acc_children)
|
||||
{
|
||||
/* Call gnc_ui_accWindow_tree_fill to fill this new subtree */
|
||||
gnc_ui_acct_ctree_fill(ctree, sibling, acc_children );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_insert_row (GtkCTree *ctree, GtkCTreeNode *parent,
|
||||
GtkCTreeNode **sibling, Account *acc)
|
||||
{
|
||||
AccountGroup *acc_children = xaccAccountGetChildren (acc);
|
||||
int acc_type = xaccAccountGetType (acc);
|
||||
double dbalance;
|
||||
gchar *text[3];
|
||||
|
||||
/* fill in the balance column */
|
||||
dbalance = xaccAccountGetBalance (acc);
|
||||
|
||||
/* if the account has children, add in thier balance */
|
||||
if (acc_children)
|
||||
dbalance += xaccGroupGetBalance (acc_children);
|
||||
|
||||
/* the meaning of "balance" for income and expense
|
||||
* accounts is reversed, since a deposit of a paycheck in a
|
||||
* bank account will appear as a debit of the corresponding
|
||||
* amount in the income account */
|
||||
if ((EXPENSE == acc_type) || (INCOME == acc_type))
|
||||
dbalance = -dbalance;
|
||||
|
||||
text[0] = xaccAccountGetName(acc);
|
||||
text[1] = xaccAccountGetDescription(acc);
|
||||
text[2] = xaccPrintAmount (dbalance, PRTSYM | PRTSEP);
|
||||
|
||||
*sibling = gtk_ctree_insert_node (ctree, parent, *sibling, text, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Set the user_data for the tree item to the account it */
|
||||
/* represents. */
|
||||
gtk_ctree_node_set_row_data(GTK_CTREE(ctree), *sibling, acc);
|
||||
}
|
27
src/gnome/account-tree.h
Normal file
27
src/gnome/account-tree.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*******************************************************************\
|
||||
* account-tree.h -- public GNOME account tree functions *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __ACCOUNT_TREE_H__
|
||||
#define __ACCOUNT_TREE_H__
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
GtkWidget * gnc_create_account_tree(void);
|
||||
void gnc_ui_refresh_tree(void);
|
||||
|
||||
#endif
|
46
src/gnome/account-treeP.h
Normal file
46
src/gnome/account-treeP.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*******************************************************************\
|
||||
* account-tree.h -- private GNOME account tree functions *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __ACCOUNT_TREEP_H__
|
||||
#define __ACCOUNT_TREEP_H__
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
static gint gnc_ctree_button_press_cb(GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
|
||||
static gint gnc_acct_ctree_select_cb(GtkWidget *widget,
|
||||
GtkCTreeNode *row,
|
||||
gint column,
|
||||
gpointer user_data);
|
||||
|
||||
static gint gnc_acct_ctree_unselect_cb(GtkWidget *widget,
|
||||
GtkCTreeNode *row,
|
||||
gint column,
|
||||
gpointer user_data);
|
||||
|
||||
static void gnc_tree_insert_row (GtkCTree *ctree,
|
||||
GtkCTreeNode *parent,
|
||||
GtkCTreeNode **sibling,
|
||||
Account *acc);
|
||||
|
||||
static void gnc_ui_acct_ctree_fill(GtkCTree *ctree,
|
||||
GtkCTreeNode *parent,
|
||||
AccountGroup *accts);
|
||||
|
||||
#endif
|
89
src/gnome/cursors.c
Normal file
89
src/gnome/cursors.c
Normal file
@ -0,0 +1,89 @@
|
||||
/********************************************************************\
|
||||
* cursor.c -- functions for changing cursors *
|
||||
* *
|
||||
* 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 <gnome.h>
|
||||
|
||||
#include "ui-callbacks.h"
|
||||
|
||||
#include "cursors.h"
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_ui_set_cursor *
|
||||
* sets the cursor to the specified type *
|
||||
* *
|
||||
* Args: w - the widget over which to change the cursor *
|
||||
* type - the type of cursor to make *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_ui_set_cursor (GdkWindow *win, int type)
|
||||
{
|
||||
GdkCursor *cursor = NULL;
|
||||
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
if (type != GNC_CURSOR_NORMAL)
|
||||
cursor = gdk_cursor_new(type);
|
||||
|
||||
gdk_window_set_cursor (win, cursor);
|
||||
|
||||
if (type != GNC_CURSOR_NORMAL)
|
||||
gdk_cursor_destroy(cursor);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_set_busy_cursor *
|
||||
* sets the cursor to the busy watch *
|
||||
* *
|
||||
* Args: w - the widget over which to make cursor busy *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_set_busy_cursor(GtkWidget *w)
|
||||
{
|
||||
if (w)
|
||||
gnc_ui_set_cursor(w->window, GNC_CURSOR_BUSY);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_unset_busy_cursor *
|
||||
* sets the cursor to the default cursor *
|
||||
* *
|
||||
* Args: w - the widget over which to make cursor normal *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_unset_busy_cursor(GtkWidget *w)
|
||||
{
|
||||
if (w)
|
||||
gnc_ui_set_cursor(w->window, GNC_CURSOR_NORMAL);
|
||||
}
|
||||
|
||||
/************************* END OF FILE ******************************\
|
||||
\********************************************************************/
|
@ -1,22 +1,7 @@
|
||||
#ifndef CURSORS_H
|
||||
#define CURSORS_H
|
||||
|
||||
|
||||
#define GNC_CURSOR_NORMAL 0
|
||||
#define GNC_CURSOR_BUSY 1
|
||||
#define GNC_CURSOR_LAST 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
int type;
|
||||
} GncCursorDef;
|
||||
|
||||
|
||||
extern GncCursorDef gnc_cursors[];
|
||||
|
||||
void gnc_ui_init_cursors (void);
|
||||
void gnc_ui_shutdown_cursors (void);
|
||||
|
||||
#define GNC_CURSOR_NORMAL (-1)
|
||||
#define GNC_CURSOR_BUSY GDK_WATCH
|
||||
|
||||
#endif /* CURSORS_H */
|
||||
|
@ -538,11 +538,7 @@ gnc_ui_accWindow_create_callback(GtkWidget * dialog, gpointer data)
|
||||
xaccAccountSetName(account, n);
|
||||
else
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
msgbox = gnome_message_box_new ( "You must enter a valid name for the account",
|
||||
GNOME_MESSAGE_BOX_ERROR, "Ok", NULL );
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
gnc_error_dialog("You must enter a valid name for the account");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -551,11 +547,7 @@ gnc_ui_accWindow_create_callback(GtkWidget * dialog, gpointer data)
|
||||
xaccAccountSetType (account, accData->type);
|
||||
else
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
msgbox = gnome_message_box_new ( "You must select a type for the account",
|
||||
GNOME_MESSAGE_BOX_ERROR, "Ok", NULL );
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
gnc_error_dialog("You must select a type for the account");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -606,8 +598,6 @@ gnc_ui_accWindow_create_callback(GtkWidget * dialog, gpointer data)
|
||||
{
|
||||
GtkWidget *app = gnc_get_ui_data();
|
||||
GtkCTree *ctree = gtk_object_get_data(GTK_OBJECT(app), "ctree");
|
||||
GtkCTreeNode *ctreeParent = gtk_object_get_data(GTK_OBJECT(app),
|
||||
"ctree_parent");
|
||||
double dbalance = xaccAccountGetBalance(account);
|
||||
GtkCTreeNode *newRow = NULL;
|
||||
GtkCTreeNode *parentRow;
|
||||
@ -621,11 +611,12 @@ gnc_ui_accWindow_create_callback(GtkWidget * dialog, gpointer data)
|
||||
text[2] = buf;
|
||||
|
||||
/* Find the parent account row & add our new account to it... */
|
||||
parentRow = gtk_ctree_find_by_row_data(GTK_CTREE(ctree), ctreeParent,
|
||||
parentRow = gtk_ctree_find_by_row_data(GTK_CTREE(ctree), NULL,
|
||||
accData->parentAccount);
|
||||
newRow = gtk_ctree_insert_node (ctree, parentRow, newRow, text, 0,
|
||||
NULL, NULL, NULL, NULL, /* PIXMAP INFO */
|
||||
TRUE, TRUE);
|
||||
|
||||
newRow = gtk_ctree_insert_node (ctree, parentRow, newRow, text, 0,
|
||||
NULL, NULL, NULL, NULL, /* PIXMAP INFO */
|
||||
TRUE, TRUE);
|
||||
|
||||
gtk_ctree_node_set_row_data(GTK_CTREE(ctree), newRow, account);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ gnc_ui_EditAccWindow_finished_callback(GtkWidget *dialog, gpointer data)
|
||||
if (strcmp (oldval, n)) {
|
||||
char buff[1000];
|
||||
sprintf (buff, EDIT_CURRENCY_MSG, oldval, n);
|
||||
if (verifyBox (buff)) {
|
||||
if (gnc_verify_dialog (buff, GNC_T)) {
|
||||
xaccAccountSetCurrency (acc, n);
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ gnc_ui_EditAccWindow_finished_callback(GtkWidget *dialog, gpointer data)
|
||||
if (strcmp (oldval, n)) {
|
||||
char buff[1000];
|
||||
sprintf (buff, EDIT_SECURITY_MSG, oldval, n);
|
||||
if (verifyBox (buff)) {
|
||||
if (gnc_verify_dialog (buff, GNC_T)) {
|
||||
xaccAccountSetSecurity (acc, n);
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ gnc_ui_EditAccWindow_finished_callback(GtkWidget *dialog, gpointer data)
|
||||
|
||||
xaccAccountCommitEdit (acc);
|
||||
|
||||
refreshMainWindow();
|
||||
gnc_refresh_main_window();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,21 @@
|
||||
/********************************************************************\
|
||||
* query-user.c -- functions for creating dialogs for GnuCash *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
@ -5,6 +23,8 @@
|
||||
#include "messages.h"
|
||||
#include "top-level.h"
|
||||
#include "query-user.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/********************************************************************
|
||||
gnc_foundation_query_dialog
|
||||
@ -16,18 +36,20 @@
|
||||
Upon entry, dialog_result must point to an integer value of 0. This
|
||||
function will put up a dialog with the requested buttons and will not
|
||||
return until someone has set *dialog_result to a non-zero value.
|
||||
Clicking yes will set *dialog_result to -1, no to -2 and cancel to
|
||||
-3. The positive values are reserved for the caller.
|
||||
Clicking yes or ok will set *dialog_result to GNC_QUERY_YES, no to
|
||||
GNC_QUERY_NO and cancel to GNC_QUERY_CANCEL. These values are all
|
||||
negative; positive values are reserved for the caller.
|
||||
|
||||
Each of the *_allowed arguments indicates whether or not the dialog
|
||||
should contain a button of that type. default_answer may be set to
|
||||
-1 for "yes" (or OK), -2 for "no", and -3 for "cancel". If you allow
|
||||
both yes and OK buttons, and set -1 as the default answer, which
|
||||
button is the default is undefined, but the result is the same either
|
||||
way, and why would be doing that anyhow?
|
||||
GNC_QUERY_YES for "yes" (or OK), GNC_QUERY_NO for "no", and
|
||||
GNC_QUERY_CANCEL for "cancel". If you allow both yes and OK buttons,
|
||||
and set GNC_QUERY_YES as the default answer, which button is the
|
||||
default is undefined, but the result is the same either way, and why
|
||||
would you be doing that anyhow?
|
||||
|
||||
The function will return 0 if all went well, and non-zero if there
|
||||
was a failure of any sort. If there was a failure, you cannot trust
|
||||
was a failure of any sort. If there was a failure, you cannot trust
|
||||
the value of *dialog_result.
|
||||
|
||||
FIXME: We need more system call error checking in here!
|
||||
@ -37,19 +59,19 @@
|
||||
static void
|
||||
foundation_query_yes_cb(GtkWidget *w, gpointer data) {
|
||||
int *result = (int *) data;
|
||||
*result = -1;
|
||||
*result = GNC_QUERY_YES;
|
||||
}
|
||||
|
||||
static void
|
||||
foundation_query_no_cb(GtkWidget *w, gpointer data) {
|
||||
int *result = (int *) data;
|
||||
*result = -2;
|
||||
*result = GNC_QUERY_NO;
|
||||
}
|
||||
|
||||
static void
|
||||
foundation_query_cancel_cb(GtkWidget *w, gpointer data) {
|
||||
int *result = (int *) data;
|
||||
*result = -3;
|
||||
*result = GNC_QUERY_CANCEL;
|
||||
}
|
||||
|
||||
int
|
||||
@ -62,152 +84,147 @@ gnc_foundation_query_dialog(const gchar *title,
|
||||
gncBoolean cancel_allowed,
|
||||
int *dialog_result) {
|
||||
|
||||
GtkWidget *parent = gnc_get_ui_data();
|
||||
GtkWidget *verify_box = NULL;
|
||||
GtkWidget *query_dialog = NULL;
|
||||
|
||||
gchar *button_names[5] = {NULL, NULL, NULL, NULL, NULL};
|
||||
int button_count = 0;
|
||||
const gchar *button_names[5] = {NULL, NULL, NULL, NULL, NULL};
|
||||
GtkSignalFunc button_func[5] = {NULL, NULL, NULL, NULL, NULL};
|
||||
|
||||
int button_count = 0;
|
||||
int default_button = 0;
|
||||
|
||||
/* FIXME: These should be nana checks, but nana seems broken right now... */
|
||||
#if 0
|
||||
I(yes_allowed || ok_allowed || no_allowed || cancel_allowed);
|
||||
I((default_answer == -1) && (yes_allowed || ok_allowed));
|
||||
I((default_answer == -2) && no_allowed);
|
||||
I((default_answer == -3) && cancel_allowed);
|
||||
#endif
|
||||
assert(yes_allowed || ok_allowed || no_allowed || cancel_allowed);
|
||||
assert((default_answer == GNC_QUERY_YES) ||
|
||||
(default_answer == GNC_QUERY_NO) ||
|
||||
(default_answer == GNC_QUERY_CANCEL));
|
||||
assert((default_answer != GNC_QUERY_YES) || (yes_allowed || ok_allowed));
|
||||
assert((default_answer != GNC_QUERY_NO) || no_allowed);
|
||||
assert((default_answer != GNC_QUERY_CANCEL) || cancel_allowed);
|
||||
|
||||
if(yes_allowed) {
|
||||
button_names[button_count] = GNOME_STOCK_BUTTON_YES;
|
||||
button_func[button_count] = GTK_SIGNAL_FUNC(foundation_query_yes_cb);
|
||||
if(-1 == default_answer) default_button = button_count;
|
||||
if(GNC_QUERY_YES == default_answer) default_button = button_count;
|
||||
button_count++;
|
||||
}
|
||||
if(ok_allowed) {
|
||||
button_names[button_count] = GNOME_STOCK_BUTTON_OK;
|
||||
button_func[button_count] = GTK_SIGNAL_FUNC(foundation_query_yes_cb);
|
||||
if(-1 == default_answer) default_button = button_count;
|
||||
if(GNC_QUERY_YES == default_answer) default_button = button_count;
|
||||
button_count++;
|
||||
}
|
||||
if(no_allowed) {
|
||||
button_names[button_count] = GNOME_STOCK_BUTTON_NO;
|
||||
button_func[button_count] = GTK_SIGNAL_FUNC(foundation_query_no_cb);
|
||||
if(-2 == default_answer) default_button = button_count;
|
||||
if(GNC_QUERY_NO == default_answer) default_button = button_count;
|
||||
button_count++;
|
||||
}
|
||||
if(cancel_allowed) {
|
||||
button_names[button_count] = GNOME_STOCK_BUTTON_CANCEL;
|
||||
button_func[button_count] = GTK_SIGNAL_FUNC(foundation_query_cancel_cb);
|
||||
if(-3 == default_answer) default_button = button_count;
|
||||
if(GNC_QUERY_CANCEL == default_answer) default_button = button_count;
|
||||
button_count++;
|
||||
}
|
||||
|
||||
/* FIXME: I have no idea why gcc needs this coercion right now... */
|
||||
verify_box = gnome_dialog_newv(title, (const gchar **) button_names);
|
||||
query_dialog = gnome_dialog_newv(title, button_names);
|
||||
|
||||
// gnome_dialog_set_modal(GNOME_DIALOG(verify_box));
|
||||
gtk_window_set_modal(GTK_WINDOW(query_dialog), GNC_T);
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(verify_box), default_button);
|
||||
gnome_dialog_set_close(GNOME_DIALOG(verify_box), TRUE);
|
||||
gnome_dialog_set_default(GNOME_DIALOG(query_dialog), default_button);
|
||||
gnome_dialog_set_close(GNOME_DIALOG(query_dialog), TRUE);
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(query_dialog),
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < button_count; i++) {
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(verify_box), i,
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(query_dialog), i,
|
||||
GTK_SIGNAL_FUNC(button_func[i]),
|
||||
(gpointer) dialog_result);
|
||||
GINT_TO_POINTER(dialog_result));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(contents) {
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(verify_box)->vbox),
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(query_dialog)->vbox),
|
||||
contents, FALSE, FALSE, 0);
|
||||
gtk_widget_show(contents);
|
||||
}
|
||||
|
||||
gtk_widget_show(verify_box);
|
||||
|
||||
setBusyCursor(parent);
|
||||
|
||||
gtk_widget_show(query_dialog);
|
||||
|
||||
while(*dialog_result == 0) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
/* User supplied value, dialog not automatically closed. */
|
||||
if(*dialog_result > 0) gnome_dialog_close(GNOME_DIALOG(verify_box));
|
||||
if (*dialog_result > 0)
|
||||
gnome_dialog_close(GNOME_DIALOG(query_dialog));
|
||||
|
||||
unsetBusyCursor(parent);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
queryBox
|
||||
|
||||
display text, and wait for yes, no, or cancel, depending on the
|
||||
arguments. Each of the *_allowed arguments indicates whether or not
|
||||
the dialog should contain a button of that type. default_answer may
|
||||
be set to 1 for "yes" (or OK), 2 for "no", and 3 for "cancel". If
|
||||
you allow both yes and OK buttons, and set 1 as the default answer,
|
||||
which button is the default is undefined, but the result is the same
|
||||
either way, and why would be doing that anyhow?
|
||||
|
||||
This function returns 1 for yes (or OK), 2 for no, and 3 for cancel.
|
||||
If there was an unrecorverable error of some kind, it returns a
|
||||
negative value.
|
||||
|
||||
NOTE: This function does not return until the dialog is closed.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
queryBox(const char *text,
|
||||
int default_answer,
|
||||
gncBoolean yes_allowed,
|
||||
gncBoolean ok_allowed,
|
||||
gncBoolean no_allowed,
|
||||
gncBoolean cancel_allowed) {
|
||||
|
||||
int dialog_result = 0;
|
||||
int foundation_default;
|
||||
int result;
|
||||
GtkWidget *verify_text_widget = NULL;
|
||||
|
||||
/* FIXME: These should be nana checks, but nana seems broken right now... */
|
||||
#if 0
|
||||
I(yes_allowed || ok_allowed || no_allowed || cancel_allowed);
|
||||
I((default_answer == 1) && (yes_allowed || ok_allowed));
|
||||
I((default_answer == 2) && no_allowed);
|
||||
I((default_answer == 3) && cancel_allowed);
|
||||
#endif
|
||||
|
||||
/* Switch to what foundation expects */
|
||||
default_answer = -default_answer;
|
||||
/********************************************************************\
|
||||
* gnc_verify_dialog *
|
||||
* display a message, and asks the user to press "Yes" or "No" *
|
||||
* *
|
||||
* NOTE: This function does not return until the dialog is closed *
|
||||
* *
|
||||
* Args: text - the message to display *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
gncBoolean
|
||||
gnc_verify_dialog( const char *message,
|
||||
gncBoolean yes_is_default ) {
|
||||
GtkWidget *verify_box = NULL;
|
||||
|
||||
verify_text_widget = gtk_label_new(text);
|
||||
if(!verify_text_widget) return -1;
|
||||
verify_box = gnome_message_box_new(message,
|
||||
GNOME_MESSAGE_BOX_QUESTION,
|
||||
GNOME_STOCK_BUTTON_YES,
|
||||
GNOME_STOCK_BUTTON_NO,
|
||||
NULL);
|
||||
|
||||
if(gnc_foundation_query_dialog(text,
|
||||
verify_text_widget,
|
||||
default_answer,
|
||||
yes_allowed,
|
||||
ok_allowed,
|
||||
no_allowed,
|
||||
cancel_allowed,
|
||||
&dialog_result) == 0) {
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box),
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
switch(dialog_result) {
|
||||
case -1: result = 1; break;
|
||||
case -2: result = 2; break;
|
||||
case -3: result = 3; break;
|
||||
default: result = -1; break;
|
||||
}
|
||||
} else {
|
||||
result = -1;
|
||||
}
|
||||
gnome_dialog_set_default(GNOME_DIALOG(verify_box),
|
||||
yes_is_default ? 0 : 1);
|
||||
|
||||
return(result);
|
||||
return (gnome_dialog_run_and_close(GNOME_DIALOG(verify_box)) == 0);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_info_dialog *
|
||||
* displays an information dialog box *
|
||||
* *
|
||||
* Args: message - the information message to display *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_info_dialog(const char *message) {
|
||||
GtkWidget *info_box = NULL;
|
||||
|
||||
info_box = gnome_ok_dialog_parented(message,
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(info_box));
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_error_dialog *
|
||||
* displays an error dialog box *
|
||||
* *
|
||||
* Args: message - the error message to display *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_error_dialog(const char *message) {
|
||||
GtkWidget *error_box = NULL;
|
||||
|
||||
error_box = gnome_error_dialog_parented(message,
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(error_box));
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
@ -338,17 +355,23 @@ gnc_choose_item_from_list_dialog(const char *title, SCM list_items) {
|
||||
|
||||
if(gnc_foundation_query_dialog(title,
|
||||
vbox,
|
||||
3, /* cancel */
|
||||
GNC_QUERY_CANCEL, /* cancel */
|
||||
GNC_F, /* yes_allowed */
|
||||
GNC_F, /* ok_allowed */
|
||||
GNC_F, /* no_allowed */
|
||||
GNC_T, /* cancel_allowed */
|
||||
&dialog_result) == 0) {
|
||||
switch(dialog_result) {
|
||||
case 1: result = gh_cons(gh_symbol2scm("result"), scm_result); break;
|
||||
case -1: result = SCM_BOOL_F; break;
|
||||
case -2: result = SCM_BOOL_F; break;
|
||||
case -3: result = gh_symbol2scm("cancel"); break;
|
||||
case 1:
|
||||
result = gh_cons(gh_symbol2scm("result"), scm_result);
|
||||
break;
|
||||
case GNC_QUERY_YES:
|
||||
case GNC_QUERY_NO:
|
||||
result = SCM_BOOL_F;
|
||||
break;
|
||||
case GNC_QUERY_CANCEL:
|
||||
result = gh_symbol2scm("cancel");
|
||||
break;
|
||||
default: result = SCM_BOOL_F; break;
|
||||
}
|
||||
} else {
|
||||
|
@ -4,15 +4,15 @@
|
||||
#include "gnc-common.h"
|
||||
#include <guile/gh.h>
|
||||
|
||||
/* Only implemented in GNOME version right now. */
|
||||
int queryBox(const char *text,
|
||||
int default_answer,
|
||||
gncBoolean yes_allowed,
|
||||
gncBoolean ok_allowed,
|
||||
gncBoolean no_allowed,
|
||||
gncBoolean cancel_allowed);
|
||||
enum
|
||||
{
|
||||
GNC_QUERY_YES = -1,
|
||||
GNC_QUERY_NO = -2,
|
||||
GNC_QUERY_CANCEL = -3
|
||||
};
|
||||
|
||||
void gnc_info_dialog( const char *message );
|
||||
|
||||
SCM gnc_choose_item_from_list_dialog(const char *title, SCM list_items);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,10 +21,12 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <guile/gh.h>
|
||||
#include <gnome.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "window-main.h"
|
||||
#include "Account.h"
|
||||
#include "FileIO.h"
|
||||
#include "FileBox.h"
|
||||
@ -43,79 +45,128 @@
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
GtkWidget *app;
|
||||
static GtkWidget *app = NULL;
|
||||
|
||||
gncUIWidget gnc_get_ui_data() {
|
||||
static int gnome_is_running = FALSE;
|
||||
static int gnome_is_initialized = FALSE;
|
||||
static int gnome_is_terminating = FALSE;
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
gnucash_ui_is_running() {
|
||||
return gnome_is_running;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
gnucash_ui_is_terminating() {
|
||||
return gnome_is_terminating;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
gncUIWidget
|
||||
gnc_get_ui_data() {
|
||||
return app;
|
||||
}
|
||||
|
||||
/* These gnucash_lowlev and gnucash_ui functions are just hacks to get
|
||||
/* ============================================================== */
|
||||
|
||||
/* These gnucash_ui_init and gnucash_ui functions are just hacks to get
|
||||
the guile stuff up and running. Expect a more formal definition of
|
||||
what they should do soon, and expect that the open/select functions
|
||||
will be merged with the code in FMB_OPEN in MainWindow.c */
|
||||
|
||||
int
|
||||
gnucash_lowlev_app_init()
|
||||
gnucash_ui_init()
|
||||
{
|
||||
#if DEBUG_MEMORY
|
||||
char *blk;
|
||||
DEBUG("Initializing memory");
|
||||
blk = (char *)_malloc(8192);
|
||||
_free(blk);
|
||||
printf(" coresize = %d\n",_coresize());
|
||||
DEBUG("Done initializing memory");
|
||||
#endif
|
||||
ENTER ("gnucash_lowlev_app_init");
|
||||
|
||||
printf ("\n\n"
|
||||
"This is a development version. It may or may not work. \n"
|
||||
"Report bugs and other problems to http://www.gnucash.org/ \n"
|
||||
"The last stable version was gnucash-1.2.0 \n"
|
||||
"The next stable version will be gnucash-1.4.x \n"
|
||||
"\n\n");
|
||||
|
||||
{
|
||||
int fake_argc = 1;
|
||||
char *fake_argv[] = {"gnucash"};
|
||||
|
||||
/* We're going to have to have other ways to handle X and GUI
|
||||
specific args...
|
||||
int fake_argc = 1;
|
||||
char *fake_argv[] = {"gnucash"};
|
||||
|
||||
ENTER ("gnucash_ui_init");
|
||||
|
||||
/* We're going to have to have other ways to handle X and GUI
|
||||
specific args...
|
||||
|
||||
For now, use fake_argv and fake_argc...
|
||||
*/
|
||||
if (!gnome_is_initialized) {
|
||||
gnome_init("GnuCash", NULL, fake_argc, fake_argv);
|
||||
gnome_is_initialized = TRUE;
|
||||
|
||||
app = gnome_app_new ( "GnuCash", "GnuCash" );
|
||||
|
||||
For now, use fake_argv and fake_argc...
|
||||
*/
|
||||
gnome_init("GnuCash", NULL, fake_argc, fake_argv);
|
||||
app = gnome_app_new ( "gnucash", "GnuCash" );
|
||||
|
||||
{
|
||||
/* Use a nicer font IMO, if available */
|
||||
char font[] = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*";
|
||||
GtkStyle *st = gtk_widget_get_default_style();
|
||||
GdkFont *f = gdk_font_load(font);
|
||||
if(st && f) {
|
||||
st->font = f;
|
||||
st->font = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LEAVE ("gnucash_lowlev_app_init");
|
||||
/* Make the main window. */
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
LEAVE ("gnucash_ui_init");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
void
|
||||
gnc_ui_shutdown (void)
|
||||
{
|
||||
if (gnome_is_running && !gnome_is_terminating) {
|
||||
gnome_is_terminating = TRUE;
|
||||
gtk_widget_hide(app);
|
||||
gtk_main_quit();
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
void
|
||||
gnc_ui_destroy (void)
|
||||
{
|
||||
if (!gnome_is_initialized)
|
||||
return;
|
||||
|
||||
if (app != NULL) {
|
||||
gtk_widget_destroy(app);
|
||||
app = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
gnucash_lowlev_app_main()
|
||||
{
|
||||
/* Make main window */
|
||||
mainWindow();
|
||||
|
||||
gtk_widget_realize (app);
|
||||
|
||||
gnc_ui_main()
|
||||
{
|
||||
/* Initialize gnome */
|
||||
gnucash_ui_init();
|
||||
|
||||
gnc_refresh_main_window();
|
||||
gtk_widget_show(app);
|
||||
|
||||
gnome_is_running = TRUE;
|
||||
|
||||
/* Enter gnome event loop */
|
||||
gtk_main();
|
||||
|
||||
gnome_is_running = FALSE;
|
||||
gnome_is_terminating = FALSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* hack alert -- all we do below is rename some functions ... fix this someday */
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
gnucash_ui_open_file(const char name[]) {
|
||||
@ -123,6 +174,8 @@ gnucash_ui_open_file(const char name[]) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
gnucash_ui_select_file() {
|
||||
gncFileOpen();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************\
|
||||
* util.c -- utility functions that are used everywhere else for *
|
||||
* xacc (X-Accountant) *
|
||||
* ui-callbacks.c -- Generic callback functions for gnucash *
|
||||
* *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -29,28 +29,13 @@
|
||||
|
||||
#include "messages.h"
|
||||
#include "top-level.h"
|
||||
#include "cursors.h"
|
||||
#include "query-user.h"
|
||||
#include "ui-callbacks.h"
|
||||
#include "util.h"
|
||||
|
||||
GncCursorDef gnc_cursors[GNC_CURSOR_LAST] = {
|
||||
{ NULL, GDK_ARROW },
|
||||
{ NULL, GDK_WATCH },
|
||||
};
|
||||
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
#if 0
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
|
||||
extern XtAppContext app;
|
||||
extern int realized;
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* dateCB -- ensures the data the user enters in the date field *
|
||||
* is in a valid format. *
|
||||
@ -107,8 +92,7 @@ dateCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
* a valid format. *
|
||||
* *
|
||||
* Args: mw - the widget that called us *
|
||||
* cd - *
|
||||
* cb - the callback struct *
|
||||
* data - callback user data *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
@ -143,171 +127,7 @@ amountCB(GtkWidget *w, gpointer data)
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* noeditCB *
|
||||
* makes an Xbae matrix non-editable *
|
||||
* *
|
||||
* Args: mw - the widget that called us *
|
||||
* cd - *
|
||||
* cb - *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
noeditCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
XbaeMatrixEnterCellCallbackStruct *cbs =
|
||||
(XbaeMatrixEnterCellCallbackStruct * )cb;
|
||||
|
||||
cbs->doit = False;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* destroyShellCB *
|
||||
* a callback to destroy a widget (cd, not w, because we want to *
|
||||
* destroy a window, not a button!) *
|
||||
* *
|
||||
* Args: mw - the widget that called us *
|
||||
* cd - the widget to destroy *
|
||||
* cb - *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
destroyShellCB( Widget w, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
Widget window = (Widget)cd;
|
||||
|
||||
XtDestroyWidget(window);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
gnc_ui_init_cursors (void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < GNC_CURSOR_LAST; i++)
|
||||
gnc_cursors[i].cursor = gdk_cursor_new( gnc_cursors[i].type);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ui_shutdown_cursors(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < GNC_CURSOR_LAST; i++)
|
||||
gdk_cursor_destroy (gnc_cursors[i].cursor);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ui_set_cursor (GdkWindow *win, int type)
|
||||
{
|
||||
if ( -1 < type && type < GNC_CURSOR_LAST)
|
||||
if (win)
|
||||
gdk_window_set_cursor (win, gnc_cursors[type].cursor);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* setBusyCursor *
|
||||
* sets the cursor to the busy watch *
|
||||
* *
|
||||
* Args: w - the widget over which to make cursor busy *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
setBusyCursor(GtkWidget *w)
|
||||
{
|
||||
|
||||
if (w)
|
||||
gnc_ui_set_cursor(w->window, GNC_CURSOR_BUSY);
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* unsetBusyCursor *
|
||||
* sets the cursor to the default cursor *
|
||||
* *
|
||||
* Args: w - the widget over which to make cursor normal *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
unsetBusyCursor(GtkWidget *w)
|
||||
{
|
||||
|
||||
if (w)
|
||||
gnc_ui_set_cursor(w->window, GNC_CURSOR_NORMAL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
**************** VERIFYBOX STUFF ***********************************
|
||||
\********************************************************************/
|
||||
|
||||
/********************************************************************\
|
||||
* verifyBox *
|
||||
* display a message, and asks the user to press "Yes" or "No" *
|
||||
* *
|
||||
* NOTE: This function does not return until the dialog is closed *
|
||||
* *
|
||||
* Args: parent - the parent widget *
|
||||
* title - the title of the window *
|
||||
* text - the message to display *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
gncBoolean
|
||||
verifyBox( const char *text ) {
|
||||
return(queryBox(text, 3, TRUE, FALSE, TRUE, FALSE) == 1);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
*********************************************************************
|
||||
\********************************************************************/
|
||||
|
||||
static void
|
||||
error_cb_ok(GtkWidget *w, gpointer data) {
|
||||
*((gboolean *) data) = TRUE;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* errorBox *
|
||||
* displays an error dialog box *
|
||||
* *
|
||||
* Args: w - the parent widget *
|
||||
* message - the error message to display *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
errorBox(const char *message) {
|
||||
GtkWidget *parent = gnc_get_ui_data();
|
||||
GtkWidget *error_box = NULL;
|
||||
GtkWidget *error_text = NULL;
|
||||
gboolean finished = FALSE;
|
||||
|
||||
error_box = gnome_dialog_new("GnuCash: error",
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
NULL);
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(error_box), 0,
|
||||
GTK_SIGNAL_FUNC(error_cb_ok),
|
||||
(gpointer) &finished);
|
||||
// gnome_dialog_set_modal(GNOME_DIALOG(error_box));
|
||||
gnome_dialog_set_default(GNOME_DIALOG(error_box), 0);
|
||||
gnome_dialog_set_close(GNOME_DIALOG(error_box), TRUE);
|
||||
|
||||
error_text = gtk_label_new(message);
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(error_box)->vbox),
|
||||
error_text, FALSE, FALSE, 0);
|
||||
gtk_widget_show(error_text);
|
||||
|
||||
gtk_widget_show(error_box);
|
||||
|
||||
setBusyCursor(parent);
|
||||
|
||||
while(!finished) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
unsetBusyCursor(parent);
|
||||
}
|
||||
|
||||
/************************* END OF FILE ******************************\
|
||||
\********************************************************************/
|
||||
|
@ -299,7 +299,7 @@ htmlWindow( GtkWidget *parent,
|
||||
HTMLWindow *hw = *hwinp;
|
||||
char * text=0x0;
|
||||
|
||||
// setBusyCursor( parent );
|
||||
// gnc_set_busy_cursor( parent );
|
||||
|
||||
historyInsert (&(hw->history), htmlfile);
|
||||
if (htmltext) text = strdup (htmltext);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************\
|
||||
* MainWindow.c -- the main window, and associated helper functions *
|
||||
* and callback functions for xacc (X-Accountant) *
|
||||
* window-main.c -- the main window, and associated helper functions*
|
||||
* and callback functions for GnuCash *
|
||||
* Copyright (C) 1998,1999 Jeremy Collins *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "AccWindow.h"
|
||||
#include "dialog-options.h"
|
||||
#include "FileDialog.h"
|
||||
@ -37,12 +36,13 @@
|
||||
#include "version.h"
|
||||
#include "window-mainP.h"
|
||||
#include "window-help.h"
|
||||
#include "account-tree.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
static short show_categories = 1;
|
||||
|
||||
enum {
|
||||
FMB_NEW,
|
||||
@ -53,149 +53,139 @@ enum {
|
||||
FMB_QUIT,
|
||||
};
|
||||
|
||||
enum {
|
||||
VIEW_CTREE_BALANCE,
|
||||
VIEW_CTREE_DESCRIPTION,
|
||||
VIEW_CTREE_TYPE,
|
||||
};
|
||||
|
||||
/** STRUCTURES ******************************************************/
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
static void gnc_ui_options_cb( GtkWidget *, gpointer );
|
||||
static void gnc_ui_add_account( GtkWidget *, gpointer );
|
||||
static void gnc_ui_delete_account_cb( GtkWidget *, gpointer );
|
||||
static void gnc_ui_about_cb( GtkWidget *, gpointer );
|
||||
static void gnc_ui_help_cb( GtkWidget *, gpointer );
|
||||
static void gnc_ui_reports_cb( GtkWidget *, gchar * );
|
||||
static void gnc_ui_view_cb( GtkWidget *, gint );
|
||||
static void gnc_ui_filemenu_cb( GtkWidget *, gint *);
|
||||
static void gnc_ui_mainWindow_toolbar_open( GtkWidget *, gpointer );
|
||||
static void gnc_ui_mainWindow_toolbar_edit( GtkWidget *, gpointer );
|
||||
static void gnc_ui_refresh_statusbar();
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
char *HELP_ROOT = "";
|
||||
short show_categories = 1;
|
||||
extern GtkWidget *app;
|
||||
|
||||
/** Menus ***********************************************************/
|
||||
static GnomeUIInfo filemenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("New"), N_("Create New File."),
|
||||
gnc_ui_filemenu_cb, (gpointer)FMB_NEW, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW,
|
||||
0, 0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Open"), N_("Open File."),
|
||||
gnc_ui_filemenu_cb, (gpointer)FMB_OPEN, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
|
||||
0,0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Save"), N_("Save File."),
|
||||
gnc_ui_filemenu_cb, (gpointer)FMB_SAVE, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE,
|
||||
0, 0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Import"), N_("Import QIF File."),
|
||||
gnc_ui_filemenu_cb, (gpointer)FMB_IMPORT, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CONVERT,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Exit"), N_("Exit Gnucash."),
|
||||
gnc_ui_filemenu_cb, (gpointer)FMB_QUIT, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_QUIT,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_END
|
||||
GNOMEUIINFO_MENU_NEW_ITEM(N_("New"),
|
||||
N_("Create New File."),
|
||||
gnc_ui_filemenu_cb,
|
||||
GINT_TO_POINTER(FMB_NEW)),
|
||||
GNOMEUIINFO_MENU_OPEN_ITEM(gnc_ui_filemenu_cb,
|
||||
GINT_TO_POINTER(FMB_OPEN)),
|
||||
GNOMEUIINFO_MENU_SAVE_ITEM(gnc_ui_filemenu_cb,
|
||||
GINT_TO_POINTER(FMB_SAVE)),
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Import"), N_("Import QIF File."),
|
||||
gnc_ui_filemenu_cb, GINT_TO_POINTER(FMB_IMPORT), NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CONVERT,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
GNOMEUIINFO_MENU_EXIT_ITEM(gnc_ui_filemenu_cb,
|
||||
GINT_TO_POINTER(FMB_QUIT)),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo viewmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Hide categories"), N_("Hide"),
|
||||
gnc_ui_view_cb, 0, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_END
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Hide categories"), N_("Hide"),
|
||||
gnc_ui_view_cb, 0, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo showmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Show categories"), N_("Show"),
|
||||
gnc_ui_view_cb, 0, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_END
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Show categories"), N_("Show"),
|
||||
gnc_ui_view_cb, 0, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo reportsmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Balance"), N_("BalanceReport"),
|
||||
gnc_ui_reports_cb, "report-baln.phtml", NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Profit & Loss"), N_("ProfitLoss"),
|
||||
gnc_ui_reports_cb, "report-pnl.phtml", NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
|
||||
GNOMEUIINFO_END
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Balance"), N_("BalanceReport"),
|
||||
gnc_ui_reports_cb, "report-baln.phtml", NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Profit & Loss"), N_("ProfitLoss"),
|
||||
gnc_ui_reports_cb, "report-pnl.phtml", NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo optionsmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Preferences"), N_("Preferences"),
|
||||
gnc_ui_options_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Preferences"), N_("Preferences"),
|
||||
gnc_ui_options_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
#if 0
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Gnucash News"), N_("News"),
|
||||
gnc_ui_news_callback, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL},
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Gnucash News"), N_("News"),
|
||||
gnc_ui_news_callback, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF,
|
||||
0, 0, NULL
|
||||
},
|
||||
#endif
|
||||
GNOMEUIINFO_END
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
|
||||
static GnomeUIInfo accountsmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("View"), N_("View Account"),
|
||||
gnc_ui_mainWindow_toolbar_open, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
|
||||
0, 0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Edit"), N_("Edit Account"),
|
||||
gnc_ui_mainWindow_toolbar_edit, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Add"), N_("Add Account"),
|
||||
gnc_ui_add_account, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL},
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Remove"), N_("Remove Account"),
|
||||
gnc_ui_delete_account_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_END
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("View"), N_("View Account"),
|
||||
gnc_ui_mainWindow_toolbar_open, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
|
||||
0, 0, NULL
|
||||
},
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Edit"), N_("Edit Account"),
|
||||
gnc_ui_mainWindow_toolbar_edit, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Add"), N_("Add Account"),
|
||||
gnc_ui_add_account, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL
|
||||
},
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Remove"), N_("Remove Account"),
|
||||
gnc_ui_delete_account_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
|
||||
static GnomeUIInfo helpmenu[] = {
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("About"), N_("About Gnucash."),
|
||||
gnc_ui_about_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT, 0, 0, NULL},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{GNOME_APP_UI_ITEM,
|
||||
N_("Help"), N_("Gnucash Help."),
|
||||
gnc_ui_help_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL},
|
||||
GNOMEUIINFO_END
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("About"), N_("About Gnucash."),
|
||||
gnc_ui_about_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{
|
||||
GNOME_APP_UI_ITEM,
|
||||
N_("Help"), N_("Gnucash Help."),
|
||||
gnc_ui_help_cb, NULL, NULL,
|
||||
GNOME_APP_PIXMAP_NONE, NULL,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
|
||||
@ -204,24 +194,24 @@ static GnomeUIInfo scriptsmenu[] = {
|
||||
};
|
||||
|
||||
static GnomeUIInfo mainmenu[] = {
|
||||
GNOMEUIINFO_SUBTREE(N_("File"), filemenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("View"), viewmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Accounts"), accountsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Reports"), reportsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Options"), optionsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Extensions"), scriptsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Help"), helpmenu),
|
||||
GNOMEUIINFO_END
|
||||
GNOMEUIINFO_MENU_FILE_TREE(filemenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("View"), viewmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Accounts"), accountsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Reports"), reportsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Options"), optionsmenu),
|
||||
GNOMEUIINFO_SUBTREE(N_("Extensions"), scriptsmenu),
|
||||
GNOMEUIINFO_MENU_HELP_TREE(helpmenu),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
/** TOOLBAR ************************************************************/
|
||||
GnomeUIInfo toolbar[] =
|
||||
static GnomeUIInfo toolbar[] =
|
||||
{
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
N_("Open"),
|
||||
N_("Open File."),
|
||||
gnc_ui_filemenu_cb,
|
||||
(gpointer)FMB_OPEN,
|
||||
GINT_TO_POINTER(FMB_OPEN),
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_OPEN, 'o', (GDK_CONTROL_MASK), NULL
|
||||
@ -230,7 +220,7 @@ GnomeUIInfo toolbar[] =
|
||||
N_("Save"),
|
||||
N_("Save File."),
|
||||
gnc_ui_filemenu_cb,
|
||||
(gpointer)FMB_SAVE,
|
||||
GINT_TO_POINTER(FMB_SAVE),
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_SAVE, 's', (GDK_CONTROL_MASK), NULL
|
||||
@ -239,7 +229,7 @@ GnomeUIInfo toolbar[] =
|
||||
N_("Import"),
|
||||
N_("Import QIF File."),
|
||||
gnc_ui_filemenu_cb,
|
||||
(gpointer)FMB_IMPORT,
|
||||
GINT_TO_POINTER(FMB_IMPORT),
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_CONVERT, 'i', (GDK_CONTROL_MASK), NULL
|
||||
@ -286,7 +276,7 @@ GnomeUIInfo toolbar[] =
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
N_("Exit"),
|
||||
N_("Exit GnuCash."),
|
||||
gnc_shutdown,
|
||||
gnc_ui_exit_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
@ -296,57 +286,6 @@ GnomeUIInfo toolbar[] =
|
||||
};
|
||||
|
||||
|
||||
static gint
|
||||
ctree_button_press(GtkWidget *widget, GdkEventButton *event)
|
||||
{
|
||||
GtkCTree *ctree = GTK_CTREE(widget);
|
||||
GtkCList *clist = GTK_CLIST(widget);
|
||||
GtkCTreeNode *node;
|
||||
Account *account, *old_acct;
|
||||
gint x, y, row, column;
|
||||
|
||||
if (event->window == clist->clist_window) {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
|
||||
if (!gtk_clist_get_selection_info(clist, x, y, &row, &column))
|
||||
return FALSE;
|
||||
|
||||
node = gtk_ctree_node_nth (ctree, row);
|
||||
account = gtk_ctree_node_get_row_data(ctree, node);
|
||||
|
||||
|
||||
if (event->type == GDK_2BUTTON_PRESS) {
|
||||
/* so the the button_release will leave it selected */
|
||||
gtk_ctree_unselect (ctree, node);
|
||||
/* this will stop the node from being collapsed/expanded */
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "button_press_event");
|
||||
regWindowSimple ( account );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
acct_ctree_select(GtkWidget *widget, GtkCTreeNode *row, gint column)
|
||||
{
|
||||
Account *account;
|
||||
|
||||
account = (Account *)gtk_ctree_node_get_row_data(GTK_CTREE(widget), GTK_CTREE_NODE(row));
|
||||
gtk_object_set_data(GTK_OBJECT(app), "selected_account", account);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
acct_ctree_unselect(GtkWidget *widget, GtkCTreeNode *row, gint column)
|
||||
{
|
||||
gtk_object_set_data(GTK_OBJECT(app), "selected_account", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_refresh_statusbar()
|
||||
{
|
||||
@ -404,11 +343,12 @@ gnc_ui_refresh_statusbar()
|
||||
strcat (buf, " ] [ Profits: ");
|
||||
amt = xaccPrintAmount (profits, PRTSYM | PRTSEP);
|
||||
strcat (buf, amt);
|
||||
strcat (buf, "]");
|
||||
strcat (buf, " ]");
|
||||
|
||||
statusbar = gtk_object_get_data(GTK_OBJECT(app), "statusbar");
|
||||
statusbar = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"statusbar");
|
||||
|
||||
context_id = gtk_statusbar_get_context_id( GTK_STATUSBAR(statusbar),
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar),
|
||||
"Statusbar");
|
||||
|
||||
gtk_statusbar_push( GTK_STATUSBAR(statusbar), context_id, buf);
|
||||
@ -417,150 +357,28 @@ gnc_ui_refresh_statusbar()
|
||||
|
||||
/* Required for compatibility with Motif code... */
|
||||
void
|
||||
refreshMainWindow()
|
||||
gnc_refresh_main_window()
|
||||
{
|
||||
gnc_ui_refresh_statusbar();
|
||||
gnc_ui_refresh_tree();
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ui_acct_ctree_fill(GtkCTree *ctree, GtkCTreeNode *parent, AccountGroup *accts)
|
||||
{
|
||||
GtkCTreeNode *sibling;
|
||||
gint totalAccounts = xaccGroupGetNumAccounts(accts);
|
||||
gint currentAccount;
|
||||
gchar *text[3];
|
||||
|
||||
sibling = NULL;
|
||||
|
||||
/* Add each account to the tree */
|
||||
for ( currentAccount = 0;
|
||||
currentAccount < totalAccounts;
|
||||
currentAccount++ )
|
||||
{
|
||||
Account *acc = xaccGroupGetAccount(accts, currentAccount);
|
||||
int acc_type = xaccAccountGetType (acc);
|
||||
AccountGroup *acc_children = xaccAccountGetChildren (acc);
|
||||
gchar buf[BUFSIZE];
|
||||
GtkWidget *popup;
|
||||
double dbalance = 0.0;
|
||||
|
||||
/* fill in the balance column */
|
||||
dbalance = xaccAccountGetBalance (acc);
|
||||
/* if the account has children, add in thier balance */
|
||||
if (acc_children) {
|
||||
dbalance += xaccGroupGetBalance (acc_children);
|
||||
}
|
||||
|
||||
/* the meaning of "balance" for income and expense
|
||||
* accounts is reversed, since a deposit of a paycheck in a
|
||||
* bank account will appear as a debit of the corresponding
|
||||
* amount in the income account */
|
||||
if ((EXPENSE == acc_type) ||
|
||||
(INCOME == acc_type) ) {
|
||||
dbalance = -dbalance;
|
||||
}
|
||||
xaccSPrintAmount (buf, dbalance, PRTSYM | PRTSEP);
|
||||
|
||||
text[0] = xaccAccountGetName(acc);
|
||||
text[1] = xaccAccountGetDescription(acc);
|
||||
text[2] = xaccPrintAmount (dbalance, PRTSYM | PRTSEP);
|
||||
|
||||
sibling = gtk_ctree_insert_node (ctree, parent, sibling, text, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
FALSE, FALSE);
|
||||
|
||||
/* Set the user_data for the tree item to the account it */
|
||||
/* represents. */
|
||||
gtk_ctree_node_set_row_data(GTK_CTREE(ctree), sibling, acc);
|
||||
|
||||
popup = gnome_popup_menu_new(accountsmenu);
|
||||
gnome_popup_menu_attach (GTK_WIDGET(popup), GTK_WIDGET(ctree), NULL);
|
||||
|
||||
// gtk_ctree_toggle_expansion(GTK_CTREE(ctree), GTK_CTREE_NODE(sibling));
|
||||
|
||||
|
||||
/* If this account has children,
|
||||
* then we need to build a subtree and fill it
|
||||
*/
|
||||
if(acc_children)
|
||||
{
|
||||
/* Call gnc_ui_accWindow_tree_fill to fill this new subtree */
|
||||
gnc_ui_acct_ctree_fill(ctree, sibling, acc_children );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tree_set_row_text (GtkCTree *ctree, GtkCTreeNode *node, gpointer data)
|
||||
gnc_ui_exit_cb ( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
Account *acc = (Account *)gtk_ctree_node_get_row_data(ctree, node);
|
||||
AccountGroup *hasChildren = xaccAccountGetChildren(acc);
|
||||
int acc_type = xaccAccountGetType (acc);
|
||||
double balance;
|
||||
gchar *text[3];
|
||||
int i;
|
||||
|
||||
hasChildren = xaccAccountGetChildren(acc);
|
||||
|
||||
balance = xaccAccountGetBalance(acc) + xaccGroupGetBalance(hasChildren);
|
||||
|
||||
if ((EXPENSE == acc_type) || (INCOME == acc_type))
|
||||
balance = -balance;
|
||||
|
||||
text[0] = xaccAccountGetName(acc);
|
||||
text[1] = xaccAccountGetDescription(acc);
|
||||
text[2] = xaccPrintAmount (balance, PRTSYM | PRTSEP);
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
gtk_ctree_node_set_text (ctree, node, i, text[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* refresh_tree *
|
||||
* refreshes the main window *
|
||||
* *
|
||||
* Args: tree - the tree that will get destroyed.. *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_ui_refresh_tree()
|
||||
{
|
||||
GtkCTree *ctree;
|
||||
GtkCTreeNode *parent;
|
||||
AccountGroup *accts;
|
||||
|
||||
parent = gtk_object_get_data(GTK_OBJECT(app), "ctree_parent");
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(app), "ctree");
|
||||
|
||||
accts = gncGetCurrentGroup();
|
||||
|
||||
gtk_clist_freeze(GTK_CLIST(ctree));
|
||||
|
||||
gtk_ctree_pre_recursive(ctree, parent, (GtkCTreeFunc)tree_set_row_text, NULL);
|
||||
|
||||
gnc_ui_acct_ctree_fill(ctree, parent, accts);
|
||||
|
||||
gtk_clist_thaw(GTK_CLIST(ctree));
|
||||
gtk_clist_columns_autosize(GTK_CLIST(ctree));
|
||||
|
||||
gnc_shutdown(0);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_about_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
helpWindow( GTK_WIDGET(app), ABOUT_STR, HH_ABOUT );
|
||||
helpWindow( GTK_WIDGET(gnc_get_ui_data()), ABOUT_STR, HH_ABOUT );
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_help_cb ( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
helpWindow( GTK_WIDGET(app), HELP_STR, HH_MAIN );
|
||||
helpWindow( GTK_WIDGET(gnc_get_ui_data()), HELP_STR, HH_MAIN );
|
||||
}
|
||||
|
||||
static void
|
||||
@ -576,28 +394,26 @@ gnc_ui_add_account ( GtkWidget *widget, gpointer data )
|
||||
Account *account;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(widget));
|
||||
account = gtk_object_get_data(GTK_OBJECT(app), "selected_account");
|
||||
account = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account");
|
||||
|
||||
accWindow((AccountGroup*)account);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_delete_account_finish_cb ( GtkWidget *widget, gpointer data )
|
||||
gnc_ui_delete_account ( Account *account )
|
||||
{
|
||||
GtkCTreeNode *deleteRow;
|
||||
GtkCTreeNode *parentRow;
|
||||
GtkCTree *ctree;
|
||||
Account *account = data;
|
||||
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(app), "ctree");
|
||||
parentRow = gtk_object_get_data(GTK_OBJECT(app), "ctree_parent");
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()), "ctree");
|
||||
|
||||
/* Step 1: Delete the actual account */
|
||||
xaccRemoveAccount ( account );
|
||||
xaccFreeAccount ( account );
|
||||
|
||||
/* Step 2: Find the GtkCTreeNode that matches this account */
|
||||
deleteRow = gtk_ctree_find_by_row_data(GTK_CTREE(ctree), parentRow, account);
|
||||
deleteRow = gtk_ctree_find_by_row_data(GTK_CTREE(ctree), NULL, account);
|
||||
|
||||
/* Step 3: Delete the GtkCTreeNode we just found */
|
||||
gtk_ctree_remove_node(GTK_CTREE(ctree), deleteRow);
|
||||
@ -613,29 +429,18 @@ gnc_ui_delete_account_cb ( GtkWidget *widget, gpointer data )
|
||||
Account *account;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(widget));
|
||||
account = gtk_object_get_data(GTK_OBJECT(app), "selected_account");
|
||||
|
||||
account = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account");
|
||||
|
||||
if (account)
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
|
||||
msgbox = gnome_message_box_new ( " Are you sure you want to delete this account. ",
|
||||
GNOME_MESSAGE_BOX_WARNING,
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
GNOME_STOCK_BUTTON_CANCEL, NULL );
|
||||
gnome_dialog_button_connect (GNOME_DIALOG (msgbox), 0,
|
||||
GTK_SIGNAL_FUNC (gnc_ui_delete_account_finish_cb),
|
||||
account);
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
if (gnc_verify_dialog("Are you sure you want to delete this account?",
|
||||
GNC_F))
|
||||
gnc_ui_delete_account(account);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
msgbox = gnome_message_box_new(ACC_DEL_MSG, GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
gnc_error_dialog(ACC_DEL_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,20 +451,17 @@ gnc_ui_mainWindow_toolbar_open ( GtkWidget *widget, gpointer data )
|
||||
GtkWidget *toplevel;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(widget));
|
||||
account = gtk_object_get_data(GTK_OBJECT(app), "selected_account");
|
||||
account = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account");
|
||||
|
||||
if(account)
|
||||
{
|
||||
PINFO ("calling regWindowSimple(%p)\n", account);
|
||||
regWindowSimple ( account );
|
||||
PINFO ("calling regWindowSimple(%p)\n", account);
|
||||
regWindowSimple ( account );
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
msgbox = gnome_message_box_new ( " You must select an account to open first. ",
|
||||
GNOME_MESSAGE_BOX_ERROR, "Ok", NULL );
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
gnc_error_dialog("You must select an account to open first.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,7 +472,8 @@ gnc_ui_mainWindow_toolbar_edit ( GtkWidget *widget, gpointer data )
|
||||
Account *account;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(widget));
|
||||
account = gtk_object_get_data(GTK_OBJECT(app), "selected_account");
|
||||
account = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()),
|
||||
"selected_account");
|
||||
|
||||
if (account)
|
||||
{
|
||||
@ -678,10 +481,7 @@ gnc_ui_mainWindow_toolbar_edit ( GtkWidget *widget, gpointer data )
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *msgbox;
|
||||
msgbox = gnome_message_box_new(ACC_EDIT_MSG, GNOME_MESSAGE_BOX_ERROR, "Ok", NULL);
|
||||
gtk_window_set_modal(GTK_WINDOW(msgbox) ,TRUE );
|
||||
gtk_widget_show ( msgbox );
|
||||
gnc_error_dialog(ACC_EDIT_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -702,21 +502,25 @@ gnc_ui_view_cb(GtkWidget *widget, gint viewType)
|
||||
|
||||
GtkWidget *ctree;
|
||||
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(app), "ctree");
|
||||
ctree = gtk_object_get_data(GTK_OBJECT(gnc_get_ui_data()), "ctree");
|
||||
|
||||
if(show_categories == 1)
|
||||
{
|
||||
/* Widget label -> Hide Categories */
|
||||
gnome_app_remove_menus (GNOME_APP(app), "View/Hide categories", 1);
|
||||
gnome_app_insert_menus (GNOME_APP(app), "View/", showmenu);
|
||||
gnome_app_remove_menus (GNOME_APP(gnc_get_ui_data()),
|
||||
"View/Hide categories", 1);
|
||||
gnome_app_insert_menus (GNOME_APP(gnc_get_ui_data()),
|
||||
"View/", showmenu);
|
||||
gtk_clist_set_column_visibility(GTK_CLIST(ctree), 2, FALSE);
|
||||
show_categories = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Widget lable -> Show Categories */
|
||||
gnome_app_remove_menus (GNOME_APP(app), "View/Show categories", 1);
|
||||
gnome_app_insert_menus (GNOME_APP(app), "View/", viewmenu);
|
||||
gnome_app_remove_menus (GNOME_APP(gnc_get_ui_data()),
|
||||
"View/Show categories", 1);
|
||||
gnome_app_insert_menus (GNOME_APP(gnc_get_ui_data()),
|
||||
"View/", viewmenu);
|
||||
gtk_clist_set_column_visibility(GTK_CLIST(ctree), 2, TRUE);
|
||||
show_categories = 1;
|
||||
}
|
||||
@ -727,20 +531,21 @@ gnc_ui_view_cb(GtkWidget *widget, gint viewType)
|
||||
* only remove the INCOME/EXPENSE accounts... or add them... instead of
|
||||
* just wiping the whole thing out and starting over.
|
||||
*/
|
||||
refreshMainWindow();
|
||||
gnc_refresh_main_window();
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ui_filemenu_cb(GtkWidget *widget, gint *menuItem)
|
||||
static void
|
||||
gnc_ui_filemenu_cb(GtkWidget *widget, gpointer menuItem)
|
||||
{
|
||||
switch((gint)menuItem)
|
||||
switch(GPOINTER_TO_INT(menuItem))
|
||||
{
|
||||
case FMB_OPEN: gncFileOpen();
|
||||
refreshMainWindow();
|
||||
gnc_refresh_main_window();
|
||||
break;
|
||||
case FMB_SAVE: gncFileSave();
|
||||
break;
|
||||
case FMB_IMPORT: gncFileQIFImport();
|
||||
gnc_refresh_main_window();
|
||||
break;
|
||||
case FMB_QUIT: gnc_shutdown(0);
|
||||
break;
|
||||
@ -748,49 +553,44 @@ gnc_ui_filemenu_cb(GtkWidget *widget, gint *menuItem)
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_ui_mainWindow_delete_cb(GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
gnc_shutdown(0);
|
||||
|
||||
/* Don't delete the window, we'll handle things ourselves. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gnc_ui_mainWindow_destroy_cb(GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
mainWindow() {
|
||||
GtkWidget *scrolled_win;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *statusbar;
|
||||
GtkWidget *ctree;
|
||||
GtkCTreeNode *parent = NULL;
|
||||
AccountGroup *accts = gncGetCurrentGroup();
|
||||
gchar *ctitles[] = {ACC_NAME_STR, DESC_STR, BALN_STR};
|
||||
mainWindow()
|
||||
{
|
||||
GtkWidget *app = gnc_get_ui_data();
|
||||
GtkWidget *popup;
|
||||
GtkWidget *scrolled_win;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *statusbar;
|
||||
GtkWidget *ctree;
|
||||
|
||||
/* Create ctree */
|
||||
ctree = gtk_ctree_new_with_titles(3, 0, ctitles);
|
||||
ctree = gnc_create_account_tree();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"button_press_event",
|
||||
GTK_SIGNAL_FUNC(ctree_button_press),
|
||||
NULL);
|
||||
|
||||
/* Connect the signal to the tree_select_row event */
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"tree_select_row",
|
||||
GTK_SIGNAL_FUNC(acct_ctree_select),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ctree),
|
||||
"tree_unselect_row",
|
||||
GTK_SIGNAL_FUNC(acct_ctree_unselect),
|
||||
NULL);
|
||||
|
||||
gtk_object_set_data(GTK_OBJECT(app), "ctree", ctree);
|
||||
gtk_object_set_data(GTK_OBJECT(app), "ctree_parent", parent);
|
||||
popup = gnome_popup_menu_new(accountsmenu);
|
||||
gnome_popup_menu_attach (GTK_WIDGET(popup), GTK_WIDGET(ctree), NULL);
|
||||
|
||||
gnome_app_create_toolbar(GNOME_APP(app), toolbar);
|
||||
gnome_app_create_menus (GNOME_APP(app), mainmenu);
|
||||
|
||||
/* Cram accounts into the ctree widget & make sure the columns are sized correctly */
|
||||
gtk_clist_freeze(GTK_CLIST(ctree));
|
||||
gnc_ui_acct_ctree_fill(GTK_CTREE(ctree), parent, accts);
|
||||
gtk_clist_thaw(GTK_CLIST(ctree));
|
||||
|
||||
gtk_clist_columns_autosize(GTK_CLIST(ctree));
|
||||
gtk_clist_set_shadow_type (GTK_CLIST(ctree), GTK_SHADOW_IN);
|
||||
|
||||
/* Create main vbox */
|
||||
main_vbox = gtk_vbox_new( FALSE, 0 );
|
||||
gnome_app_set_contents ( GNOME_APP ( app ), main_vbox );
|
||||
@ -807,11 +607,12 @@ mainWindow() {
|
||||
|
||||
/* create statusbar and pack it into the main_vbox */
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_object_set_data (GTK_OBJECT (app), "statusbar", statusbar);
|
||||
gtk_object_set_data (GTK_OBJECT (app),
|
||||
"statusbar", statusbar);
|
||||
gtk_widget_show (statusbar);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), statusbar, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_set_usize ( GTK_WIDGET(app), 500, 400 );
|
||||
gtk_widget_set_usize ( GTK_WIDGET(app), 500, 400 );
|
||||
|
||||
{
|
||||
SCM run_danglers = gh_eval_str("gnc:hook-run-danglers");
|
||||
@ -819,30 +620,28 @@ mainWindow() {
|
||||
SCM window = POINTER_TOKEN_to_SCM(make_POINTER_TOKEN("gncUIWidget", app));
|
||||
gh_call2(run_danglers, hook, window);
|
||||
}
|
||||
|
||||
|
||||
/* Attach delete and destroy signals to the main window */
|
||||
gtk_signal_connect (GTK_OBJECT (app), "delete_event",
|
||||
GTK_SIGNAL_FUNC (gnc_ui_mainWindow_delete_cb),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (app), "destroy_event",
|
||||
GTK_SIGNAL_FUNC (gnc_ui_mainWindow_destroy_cb),
|
||||
NULL);
|
||||
|
||||
/* Show everything now that it is created */
|
||||
|
||||
gtk_widget_show(main_vbox);
|
||||
gtk_widget_show(ctree);
|
||||
gtk_widget_show(app);
|
||||
|
||||
refreshMainWindow();
|
||||
|
||||
gnc_refresh_main_window();
|
||||
}
|
||||
|
||||
/* OLD_GNOME_CODE */
|
||||
|
||||
void
|
||||
gnc_ui_shutdown (GtkWidget *widget, gpointer *data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
/********************* END OF FILE **********************************/
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
tab-width: 2
|
||||
indent-tabs-mode: nil
|
||||
mode: c
|
||||
c-indentation-style: gnu
|
||||
|
26
src/gnome/window-main.h
Normal file
26
src/gnome/window-main.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*******************************************************************\
|
||||
* window-main.h -- public GNOME main window functions *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* *
|
||||
* 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. *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __WINDOW_MAIN_H__
|
||||
#define __WINDOW_MAIN_H__
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
void mainWindow(void);
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************\
|
||||
* MainWindowP.h -- private GNOME main window functions *
|
||||
* window-main.h -- private GNOME main window functions *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -30,53 +30,25 @@
|
||||
#include "config.h"
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
void gnc_ui_refreshMainWindow( void );
|
||||
void gnc_ui_mainWindow(AccountGroup *);
|
||||
void gnc_ui_refresh_tree ( void );
|
||||
void gnc_ui_acct_tree_fill ( GtkTree *, AccountGroup *);
|
||||
static void gnc_ui_refresh_statusbar(void);
|
||||
static void gnc_ui_exit_cb(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_about_cb(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_help_cb(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_reports_cb(GtkWidget *widget, gchar *report);
|
||||
static void gnc_ui_add_account(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_delete_account_cb(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_mainWindow_toolbar_open(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_mainWindow_toolbar_edit(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_options_cb(GtkWidget *widget, gpointer data);
|
||||
static void gnc_ui_view_cb(GtkWidget *widget, gint viewType);
|
||||
static void gnc_ui_filemenu_cb(GtkWidget *widget, gpointer menuItem);
|
||||
|
||||
#if 0
|
||||
static gboolean gnc_ui_mainWindow_delete_cb(GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data);
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
enum {
|
||||
FMB_NEW,
|
||||
FMB_OPEN,
|
||||
FMB_IMPORT,
|
||||
FMB_SAVE,
|
||||
FMB_SAVEAS,
|
||||
FMB_QUIT,
|
||||
};
|
||||
enum {
|
||||
AMB_NEW,
|
||||
AMB_OPEN,
|
||||
AMB_LEDGER,
|
||||
AMB_EDIT,
|
||||
AMB_DEL,
|
||||
AMB_TRNS,
|
||||
AMB_RPRT,
|
||||
AMB_SHOW,
|
||||
AMB_CAT,
|
||||
};
|
||||
enum {
|
||||
HMB_ABOUT,
|
||||
HMB_ACC,
|
||||
HMB_REGWIN,
|
||||
HMB_RECNWIN,
|
||||
HMB_ADJBWIN,
|
||||
HMB_MAIN,
|
||||
HMB_LIC,
|
||||
};
|
||||
static gboolean gnc_ui_mainWindow_destroy_cb(GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
tab-width: 2
|
||||
indent-tabs-mode: nil
|
||||
mode: c-mode
|
||||
c-indentation-style: gnu
|
||||
eval: (c-set-offset 'block-open '-)
|
||||
End:
|
||||
*/
|
||||
|
@ -289,7 +289,7 @@ startRecnWindow(GtkWidget *parent, Account *acc, double *diff)
|
||||
int acc_type;
|
||||
char *title = NULL;
|
||||
|
||||
setBusyCursor(parent);
|
||||
gnc_set_busy_cursor(parent);
|
||||
|
||||
/* Get the previous ending balance. Use the published
|
||||
* account interface for this, since the ending balance
|
||||
@ -361,7 +361,7 @@ startRecnWindow(GtkWidget *parent, Account *acc, double *diff)
|
||||
gtk_widget_show(end_value);
|
||||
gtk_widget_show(dialog);
|
||||
|
||||
unsetBusyCursor(parent);
|
||||
gnc_unset_busy_cursor(parent);
|
||||
|
||||
|
||||
result = -1;
|
||||
@ -379,7 +379,7 @@ startRecnWindow(GtkWidget *parent, Account *acc, double *diff)
|
||||
if(sscanf(str, "%lf", &val ) == 1) {
|
||||
*diff = dendBalance - val;
|
||||
} else {
|
||||
errorBox(N_("Ending balance must be a number."));
|
||||
gnc_error_dialog(N_("Ending balance must be a number."));
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
@ -414,7 +414,7 @@ recnWindow(GtkWidget *parent, Account *acc)
|
||||
|
||||
FETCH_FROM_LIST(RecnWindow, recnList, acc, acc, recnData);
|
||||
|
||||
setBusyCursor(parent);
|
||||
gnc_set_busy_cursor(parent);
|
||||
|
||||
recnData->ddiff = ddiff;
|
||||
|
||||
@ -513,7 +513,7 @@ recnWindow(GtkWidget *parent, Account *acc)
|
||||
/* and then refresh the total/difference balance fields: */
|
||||
recnRecalculateBalance(recnData);
|
||||
|
||||
unsetBusyCursor(parent);
|
||||
gnc_unset_busy_cursor(parent);
|
||||
|
||||
return recnData;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ regWindowLedger(xaccLedgerDisplay *ledger) {
|
||||
}
|
||||
assert(windowname);
|
||||
|
||||
setBusyCursor(gnc_get_ui_data());
|
||||
gnc_set_busy_cursor(gnc_get_ui_data());
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(register_vbox), table_frame, TRUE, TRUE, 0);
|
||||
regData->dialog = table_frame;
|
||||
@ -459,7 +459,7 @@ regWindowLedger(xaccLedgerDisplay *ledger) {
|
||||
|
||||
ledger->dirty = 1;
|
||||
xaccLedgerDisplayRefresh (ledger);
|
||||
unsetBusyCursor(gnc_get_ui_data());
|
||||
gnc_unset_busy_cursor(gnc_get_ui_data());
|
||||
|
||||
return regData;
|
||||
}
|
||||
@ -635,8 +635,11 @@ deleteCB(GtkWidget *widget, gpointer data)
|
||||
/* ask for user confirmation before performing
|
||||
* permanent damage */
|
||||
trans = xaccSplitGetParent (split);
|
||||
sprintf (buf, TRANS_DEL_MSG, xaccSplitGetMemo (split), xaccTransGetDescription (trans));
|
||||
if (!verifyBox(buf)) return;
|
||||
sprintf (buf, TRANS_DEL_MSG, xaccSplitGetMemo (split),
|
||||
xaccTransGetDescription (trans));
|
||||
|
||||
if (!gnc_verify_dialog(buf, GNC_F))
|
||||
return;
|
||||
|
||||
/* make a copy of all of the accounts that will be
|
||||
* affected by this deletion, so that we can update
|
||||
@ -660,7 +663,7 @@ deleteCB(GtkWidget *widget, gpointer data)
|
||||
xaccAccountCommitEdit (acc);
|
||||
xaccAccListDisplayRefresh (affected_accounts);
|
||||
free (affected_accounts);
|
||||
refreshMainWindow ();
|
||||
gnc_refresh_main_window ();
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
|
Loading…
Reference in New Issue
Block a user