git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2483 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2000-06-20 09:13:32 +00:00
parent e5788c1ba2
commit 24cb209da0
10 changed files with 637 additions and 487 deletions

View File

@@ -1,3 +1,19 @@
2000-06-20 Dave Peticolas <dave@krondo.com>
* src/gnome/dialog-add.c: make this window modeless.
(gnc_ui_accWindow_ok_cb): don't let the user add an account with
the same fully-qualified name as another account.
* src/gnome/top-level.c (gnc_ui_destroy_all_subwindows): destroy
all the account add windows, too.
* src/gnome/window-main.c (gnc_refresh_main_window_title): new
function to put the current filename in the main window title.
(gnc_refresh_main_window): use the above when refreshing.
* src/FileDialog.c (gncFileSaveAs): refresh the main window after
'saving as' to update the filename in the main window.
2000-06-19 Dave Peticolas <dave@krondo.com>
* src/guile/gnc.gwp: take out GUIDs for Groups.

File diff suppressed because it is too large Load Diff

View File

@@ -300,7 +300,7 @@ gncFileOpen (void)
if (!gncFileQuerySave ())
return;
newfile = fileBox( OPEN_STR, "*.xac");
newfile = fileBox( OPEN_STR, "*.gnc");
gncPostFileOpen (newfile);
/* This dialogue can show up early in the startup process.
@@ -413,7 +413,7 @@ gncFileSaveAs (void)
char buf[BUFSIZE];
int io_error, uh_oh = 0;
filename = fileBox( SAVE_STR, "*.xac");
filename = fileBox(SAVE_STR, "*.gnc");
if (!filename) return;
/* check to see if the user did something silly,
@@ -478,6 +478,9 @@ gncFileSaveAs (void)
topgroup = xaccMallocAccountGroup();
}
free (newfile);
gnc_refresh_main_window();
return;
}
@@ -511,6 +514,8 @@ gncFileSaveAs (void)
xaccSessionSetGroup (newsess, oldgrp);
gncFileSave ();
free (newfile);
gnc_refresh_main_window();
}
/* ======================================================== */

View File

@@ -41,6 +41,7 @@ noinst_HEADERS = \
account-treeP.h \
cursors.h \
dialog-account-picker.h \
dialog-add.h \
dialog-budget.h \
dialog-edit.h \
dialog-find-transactions.h \

View File

@@ -125,7 +125,7 @@ gnomeappdir = ${datadir}/gnome/apps/Applications
gnomeapp_DATA = gnucash.desktop
noinst_HEADERS = account-tree.h account-treeP.h cursors.h dialog-account-picker.h dialog-budget.h dialog-edit.h dialog-find-transactions.h dialog-options.h dialog-print-check.h dialog-qif-import.h dialog-transfer.h dialog-utils.h extensions.h glade-cb-gnc-dialogs.h glade-gnc-dialogs.h glade-support-gnc-dialogs.h gnc-currency-edit.h gnc-datedelta.h gnc-dateedit.h gnome-top-level.h print-session.h query-user.h reconcile-list.h reconcile-listP.h window-help.h window-html.h window-main.h window-mainP.h window-reconcile.h window-register.h window-report.h
noinst_HEADERS = account-tree.h account-treeP.h cursors.h dialog-account-picker.h dialog-add.h dialog-budget.h dialog-edit.h dialog-find-transactions.h dialog-options.h dialog-print-check.h dialog-qif-import.h dialog-transfer.h dialog-utils.h extensions.h glade-cb-gnc-dialogs.h glade-gnc-dialogs.h glade-support-gnc-dialogs.h gnc-currency-edit.h gnc-datedelta.h gnc-dateedit.h gnome-top-level.h print-session.h query-user.h reconcile-list.h reconcile-listP.h window-help.h window-html.h window-main.h window-mainP.h window-reconcile.h window-register.h window-report.h
EXTRA_DIST = .cvsignore gnc-dialogs.glade gnucash.desktop

View File

@@ -40,28 +40,55 @@
#include "util.h"
/* This static indicates the debugging module that this .o belongs to. */
struct _accwindow
{
GtkWidget *dialog;
GtkCList *type_list;
AccountEditInfo edit_info;
GNCAccountTree *tree;
Account *newAccount;
GNCAccountType type;
};
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GUI;
static gint last_width = 0;
static gint last_height = 0;
static int _accWindow_last_used_account_type = BANK;
static gchar * default_currency = "USD";
static gboolean default_currency_dynamically_allocated = FALSE;
static GList *account_windows = NULL;
struct _accwindow
/********************************************************************\
* Function: gnc_ui_destroy_account_add_windows - destroy all open *
* account add windows. *
* *
* Args: none *
* Return: none *
\********************************************************************/
void
gnc_ui_destroy_account_add_windows()
{
GtkCList *type_list;
GnomeDialog *dialog;
AccountEditInfo edit_info;
while (account_windows != NULL)
{
dialog = GNOME_DIALOG(account_windows->data);
GNCAccountTree *tree;
Account *parentAccount;
Account *newAccount;
gint type;
};
gnome_dialog_close(dialog);
}
}
/********************************************************************\
@@ -79,10 +106,10 @@ static void
gnc_ui_accWindow_list_select_cb(GtkCList * type_list, gint row, gint column,
GdkEventButton * event, gpointer data)
{
AccWindow * accData = data;
gboolean sensitive;
AccWindow * accData = (AccWindow *) data;
if(accData == NULL)
if (accData == NULL)
return;
if (!gtk_clist_get_selectable(type_list, row))
@@ -234,13 +261,13 @@ gnc_ui_accWindow_list_row_set_active(GtkCList *type_list, gint row,
* data - tells whether is a select or a deselect callack *
* Return: none *
* Notes: data == 0 unselect, data == 1 select *
\********************************************************************/
\********************************************************************/
static void
gnc_ui_accWindow_tree_select(GNCAccountTree *tree,
Account * account,
gpointer data)
{
AccWindow *accData = (AccWindow *) data;
AccWindow *accData = data;
int parentAccType;
gboolean compatible;
gint type;
@@ -250,9 +277,7 @@ gnc_ui_accWindow_tree_select(GNCAccountTree *tree,
/* Deleselect any or select top account */
if (account == NULL || account == accData->newAccount)
{
accData->parentAccount = NULL;
/* sel all list widgets to be selectable */
/* set all list widgets to be selectable */
for (type = 0; type < NUM_ACCOUNT_TYPES; type++)
gtk_clist_set_selectable(accData->type_list, type, TRUE);
@@ -261,8 +286,6 @@ gnc_ui_accWindow_tree_select(GNCAccountTree *tree,
}
else /* Some other account was selected */
{
accData->parentAccount = account;
parentAccType = xaccAccountGetType(account);
/* set the allowable account types for this parent */
@@ -296,9 +319,9 @@ static GtkWidget *
gnc_ui_accWindow_account_tree_box_create(AccWindow * accData)
{
GtkWidget *frame, *scrollWin, *accountTree;
frame = gtk_frame_new(PARENT_ACC_STR);
accountTree = gnc_account_tree_new_with_root(accData->newAccount);
gtk_clist_column_titles_hide(GTK_CLIST(accountTree));
gnc_account_tree_hide_all_but_name(GNC_ACCOUNT_TREE(accountTree));
@@ -371,10 +394,122 @@ gnc_ui_accWindow_create_account(Account * account, Account * parent,
xaccAccountCommitEdit (account);
xaccAccountCommitEdit (parent);
gnc_account_tree_insert_account(gnc_get_current_account_tree(), account);
/* Refresh register so they have this account in their lists */
/* Refresh all registers so they have this account in their lists */
gnc_group_ui_refresh(gncGetCurrentGroup());
/* Refresh the main window. This will also refresh all account lists. */
gnc_refresh_main_window();
}
static int
gnc_ui_accWindow_close_cb(GnomeDialog *dialog, gpointer user_data)
{
AccWindow * accData = user_data;
account_windows = g_list_remove(account_windows, dialog);
if (accData->newAccount != NULL)
{
xaccFreeAccount(accData->newAccount);
accData->newAccount = NULL;
}
g_free(accData);
gdk_window_get_geometry(GTK_WIDGET(dialog)->window, NULL, NULL,
&last_width, &last_height, NULL);
gnc_save_window_size("account_add_win", last_width, last_height);
DEBUG("account add window destroyed\n");
return FALSE;
}
static void
gnc_ui_accWindow_cancel_cb(GtkWidget * widget, gpointer data)
{
AccWindow *accData = data;
gnome_dialog_close(GNOME_DIALOG(accData->dialog));
}
static void
gnc_ui_accWindow_ok_cb(GtkWidget * widget, gpointer data)
{
AccWindow *accData = data;
AccountFieldStrings strings;
Account *parent_account;
gnc_ui_extract_field_strings(&strings, &accData->edit_info);
/* check for valid name */
if (safe_strcmp(strings.name, "") == 0)
{
gnc_error_dialog_parented(GTK_WINDOW(accData->dialog), ACC_NO_NAME_MSG);
gnc_ui_free_field_strings(&strings);
return;
}
parent_account = gnc_account_tree_get_current_account(accData->tree);
if (parent_account == accData->newAccount)
parent_account = NULL;
/* check for a duplicate name */
{
Account *account;
AccountGroup *group;
char separator;
group = gncGetCurrentGroup();
separator = gnc_get_account_separator();
if (parent_account == NULL)
account = xaccGetAccountFromFullName(group, strings.name, separator);
else
{
char *fullname_parent;
char *fullname;
char sep_string[2];
sep_string[0] = separator;
sep_string[1] = '\0';
fullname_parent = xaccAccountGetFullName(parent_account, separator);
fullname = g_strconcat(fullname_parent, sep_string, strings.name, NULL);
account = xaccGetAccountFromFullName(group, fullname, separator);
free(fullname_parent);
g_free(fullname);
}
if (account != NULL)
{
gnc_error_dialog_parented(GTK_WINDOW(accData->dialog), ACC_DUP_NAME_MSG);
gnc_ui_free_field_strings(&strings);
return;
}
}
/* check for valid type */
if (accData->type == BAD_TYPE)
{
gnc_error_dialog_parented(GTK_WINDOW(accData->dialog), ACC_TYPE_MSG);
gnc_ui_free_field_strings(&strings);
return;
}
gnc_ui_accWindow_create_account(accData->newAccount, parent_account,
accData->type, &strings);
gnc_ui_free_field_strings(&strings);
/* so it doesn't get freed on close */
accData->newAccount = NULL;
gnome_dialog_close(GNOME_DIALOG(accData->dialog));
}
@@ -398,18 +533,11 @@ gnc_accWindow_create(AccWindow *accData)
vbox = GNOME_DIALOG(dialog)->vbox;
/* Make this dialog modal */
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
/* parent */
gnome_dialog_set_parent(GNOME_DIALOG(dialog),
GTK_WINDOW(gnc_get_ui_data()));
/* default to ok */
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
/* don't close on buttons */
gnome_dialog_set_close(GNOME_DIALOG(dialog), FALSE);
/* destroy on close */
gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
/* allow grow and shrink, no auto-shrink */
gtk_window_set_policy(GTK_WINDOW(dialog), TRUE, TRUE, FALSE);
@@ -455,6 +583,17 @@ gnc_accWindow_create(AccWindow *accData)
widget = gnc_ui_notes_frame_create(&accData->edit_info.notes_entry);
gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
gnome_dialog_button_connect
(GNOME_DIALOG(dialog), 0,
GTK_SIGNAL_FUNC(gnc_ui_accWindow_ok_cb), accData);
gnome_dialog_button_connect
(GNOME_DIALOG(dialog), 1,
GTK_SIGNAL_FUNC(gnc_ui_accWindow_cancel_cb), accData);
gtk_signal_connect(GTK_OBJECT(dialog), "close",
GTK_SIGNAL_FUNC(gnc_ui_accWindow_close_cb), accData);
return dialog;
}
@@ -469,84 +608,32 @@ gnc_accWindow_create(AccWindow *accData)
AccWindow *
accWindow (AccountGroup *this_is_not_used)
{
static gint last_width = 0;
static gint last_height = 0;
Account *current_account;
AccWindow *accData;
AccWindow *accData = g_new0(AccWindow, 1);
AccountFieldStrings strings;
GtkWidget *dialog;
gint result;
accData = g_new0(AccWindow, 1);
accData->parentAccount = gnc_get_current_account();
accData->newAccount = xaccMallocAccount();
accData->type = _accWindow_last_used_account_type;
xaccAccountSetName(accData->newAccount, NEW_TOP_ACCT_STR);
dialog = gnc_accWindow_create(accData);
accData->dialog = gnc_accWindow_create(accData);
account_windows = g_list_prepend(account_windows, accData->dialog);
if (last_width == 0)
gnc_get_window_size("account_add_win", &last_width, &last_height);
gtk_window_set_default_size(GTK_WINDOW(dialog), last_width, last_height);
gtk_window_set_default_size(GTK_WINDOW(accData->dialog),
last_width, last_height);
gtk_widget_grab_focus(GTK_WIDGET(accData->edit_info.name_entry));
gtk_widget_show_all(dialog);
gtk_widget_show_all(accData->dialog);
gnc_account_tree_select_account(accData->tree, accData->parentAccount, TRUE);
current_account = gnc_get_current_account();
gnc_account_tree_select_account(accData->tree, current_account, TRUE);
while (1)
{
result = gnome_dialog_run(GNOME_DIALOG(dialog));
if (result != 0) /* cancel or delete */
{
xaccFreeAccount(accData->newAccount);
break;
}
gnc_ui_extract_field_strings(&strings, &accData->edit_info);
/* check for valid name */
if (safe_strcmp(strings.name, "") == 0)
{
gnc_error_dialog_parented(GTK_WINDOW(dialog), ACC_NO_NAME_MSG);
gnc_ui_free_field_strings(&strings);
continue;
}
/* check for valid type */
if (accData->type == BAD_TYPE)
{
gnc_error_dialog_parented(GTK_WINDOW(dialog), ACC_TYPE_MSG);
gnc_ui_free_field_strings(&strings);
continue;
}
gnc_ui_accWindow_create_account(accData->newAccount,
accData->parentAccount,
accData->type, &strings);
gnc_ui_free_field_strings(&strings);
break;
}
g_free(accData);
if (result < 0)
return NULL;
DEBUG("destroying account add window\n");
gdk_window_get_geometry(dialog->window, NULL, NULL,
&last_width, &last_height, NULL);
gnc_save_window_size("account_add_win", last_width, last_height);
gtk_widget_destroy(dialog);
return NULL;
return accData;
}
@@ -554,7 +641,6 @@ accWindow (AccountGroup *this_is_not_used)
void
xaccDestroyEditNotesWindow (Account *acc)
{
return;
}

View File

@@ -484,7 +484,7 @@ extra_change_verify(EditAccWindow *editAccData,
static void
gnc_ui_EditAccWindow_ok_cb(GtkWidget * widget, gpointer data)
{
EditAccWindow *editAccData = (EditAccWindow *) data;
EditAccWindow *editAccData = data;
AccountFieldStrings strings;
GHashTable *change_currency;
@@ -858,7 +858,7 @@ editAccWindow(Account *account)
editAccData->dialog = dialog;
editAccData->account = account;
if (last_width == 0)
gnc_get_window_size("account_edit_win", &last_width, &last_height);

View File

@@ -30,6 +30,7 @@
#include "gnome-top-level.h"
#include "window-main.h"
#include "dialog-add.h"
#include "global-options.h"
#include "gnucash-sheet.h"
#include "gnucash-color.h"
@@ -215,6 +216,7 @@ gnc_ui_destroy_all_subwindows (void)
xaccGroupWindowDestroy(gncGetCurrentGroup());
gnc_ui_destroy_help_windows();
gnc_ui_destroy_report_windows();
gnc_ui_destroy_account_add_windows();
}
/* ============================================================== */

View File

@@ -192,6 +192,35 @@ gnc_ui_refresh_statusbar (void)
gnc_set_label_color(main_info->profits_label, profits);
}
static void
gnc_refresh_main_window_title()
{
GtkWidget *main_window;
Session *session;
gchar *filename;
gchar *title;
main_window = gnc_get_ui_data();
if (main_window == NULL)
return;
session = gncGetCurrentSession();
if (session == NULL)
filename = UNTITLED_STR;
else
filename = xaccSessionGetFilePath(session);
if ((filename == NULL) || (*filename == '\0'))
filename = UNTITLED_STR;
title = g_strconcat("GnuCash - ", filename, NULL);
gtk_window_set_title(GTK_WINDOW(main_window), title);
g_free(title);
}
void
gnc_refresh_main_window()
{
@@ -199,6 +228,7 @@ gnc_refresh_main_window()
gnc_ui_refresh_statusbar();
gnc_history_update_menu(GNOME_APP(gnc_get_ui_data()));
gnc_account_tree_refresh_all();
gnc_refresh_main_window_title();
}
static void

View File

@@ -65,6 +65,7 @@
#define ACC_ADJUST_MSG _("To adjust an account's balance, you must "\
"first\nchoose an account to adjust.\n")
#define ACC_BAD_PARENT_MSG _("You must choose a valid parent account.")
#define ACC_DUP_NAME_MSG _("There is already an account with that name.")
#define ACC_NEW_MSG _("Do you want to create a new account?\n"\
"If not, then please select an account\n"\
"to open in the main window.\n")
@@ -655,6 +656,7 @@
#define TRANSACTION_STR _("Transaction")
#define TRANSFER_STR_N N_("Transfer")
#define TRANSFER_STR _(TRANSFER_STR_N)
#define UNTITLED_STR _("Untitled")
#define VALUE_STR _("Value")
#define WARN_STR _("WARNING")
#define WEEKS_STR _("Weeks")