mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Robby Stephenson's patch to add file history selections to the main menu.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2272 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
b3a395f842
commit
9b2153ccdb
@ -535,7 +535,7 @@ Rob Browning <rlb@cs.utexas.edu> abused everyone for not using perl,
|
||||
Dave Peticolas <peticola@cs.ucdavis.edu> hacks obsessively on
|
||||
GnuCash. But he can stop anytime he wants to. Really.
|
||||
|
||||
Bill Gribble <grib@cs.utexas.edu> works magic. If your checks print
|
||||
Bill Gribble <grib@billgribble.com> works magic. If your checks print
|
||||
wrong, blame him. If you don't like the amount printed on your
|
||||
checks, blame him. If you don't like your your bank balances,
|
||||
your bank, or your life, blame him too.
|
||||
@ -601,7 +601,7 @@ Christopher Seawood <cls@seawood.org> for XbaeMatrix core dump
|
||||
Mike Simons <msimons@fsimons01.erols.com> misc configure.in patches
|
||||
Richard Skelton <rich@brake.demon.co.uk> for Solaris cleanup
|
||||
Henning Spruth <spruth@bigfoot.com> for German text & euro date rework
|
||||
Robby Stephenson <parys@freewwweb.com> register patch
|
||||
Robby Stephenson <robby.stephenson@usa.net> register & file history patches
|
||||
Herbert Thoma <tma@iis.fhg.de> gnome register & euro support patches
|
||||
Diane Trout <detrout@earthlink.net> scheme qif import patch
|
||||
Richard Wackerbarth <rkw@dataplex.net> patch to gnc-prices
|
||||
|
@ -206,7 +206,7 @@
|
||||
<dd>hacks obsessively on GnuCash. But he can stop anytime he
|
||||
wants to. Really.</dd>
|
||||
|
||||
<dt> <a href="mailto:grib@cs.utexas.edu"> Bill Gribble
|
||||
<dt> <a href="mailto:grib@billgribble.com"> Bill Gribble
|
||||
</a></dt>
|
||||
|
||||
<dd>works magic. If your checks print wrong, blame him.
|
||||
@ -477,9 +477,10 @@
|
||||
|
||||
<dd>for German text and euro date rework</dd>
|
||||
|
||||
<dt> <a href="mailto:parys@freewwweb.com"> Robby Stephenson</a></dt>
|
||||
<dt> <a href="mailto:robby.stephenson@usa.net"> Robby
|
||||
Stephenson</a></dt>
|
||||
|
||||
<dd>register patch</dd>
|
||||
<dd>register & file history patches</dd>
|
||||
|
||||
<dt> <a href="mailto:tma@iis.fhg.de"> Herbert Thoma</a></dt>
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "Destroy.h"
|
||||
#include "util.h"
|
||||
#include "ui-callbacks.h"
|
||||
#include "file-history.h"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
// static short module = MOD_GUI;
|
||||
@ -279,6 +280,7 @@ gncPostFileOpen (const char * filename)
|
||||
/* clean up old stuff, and then we're outta here. */
|
||||
xaccLogDisable();
|
||||
xaccLogSetBaseName (newfile);
|
||||
gnc_history_add_file (newfile);
|
||||
/* destroy open windows first, before destroying the group itself */
|
||||
xaccGroupWindowDestroy (oldgrp);
|
||||
xaccFreeAccountGroup (oldgrp);
|
||||
@ -375,6 +377,7 @@ gncFileSave (void)
|
||||
/* check for i/o error, put up appropriate error message */
|
||||
io_error = xaccGetFileIOError();
|
||||
newfile = xaccSessionGetFilePath(current_session);
|
||||
gnc_history_add_file(newfile);
|
||||
SHOW_IO_ERR_MSG(io_error);
|
||||
|
||||
/* going down -- abandon ship */
|
||||
|
31
src/file-history.h
Normal file
31
src/file-history.h
Normal file
@ -0,0 +1,31 @@
|
||||
/********************************************************************\
|
||||
* file-history.h -- functions to maintain file-history menu *
|
||||
* Copyright (C) 2000 Robby Stephenson *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __HISTORY_H__
|
||||
#define __HISTORY_H__
|
||||
|
||||
#define MAX_HISTORY 4
|
||||
|
||||
void gnc_history_add_file(char *);
|
||||
void gnc_history_update_menu();
|
||||
|
||||
#endif
|
@ -70,7 +70,7 @@ GNOME_SRCS := top-level.c window-main.c window-register.c window-adjust.c \
|
||||
extensions.c query-user.c reconcile-list.c \
|
||||
window-report.c global-options.c gnc-dateedit.c \
|
||||
dialog-qif-import.c glade-gnc-dialogs.c gnc-datedelta.c \
|
||||
dialog-account-picker.c print-session.c \
|
||||
dialog-account-picker.c print-session.c file-history.c \
|
||||
dialog-print-check.c dialog-find-transactions.c
|
||||
######################################################################
|
||||
|
||||
|
197
src/gnome/file-history.c
Normal file
197
src/gnome/file-history.c
Normal file
@ -0,0 +1,197 @@
|
||||
/********************************************************************\
|
||||
* file-history.c -- functions to maintain file history menu *
|
||||
* Copyright (C) 2000 Robby Stephenson *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "file-history.h"
|
||||
#include "FileDialog.h"
|
||||
#include "ui-callbacks.h"
|
||||
#include "messages.h"
|
||||
#include "util.h"
|
||||
|
||||
static GSList *history_list = NULL;
|
||||
static gint num_menu_entries = -1;
|
||||
|
||||
static void
|
||||
__gnc_history_config_write()
|
||||
{
|
||||
int max_files, i = 0;
|
||||
char *key;
|
||||
GSList *tmp;
|
||||
|
||||
if(history_list == NULL)
|
||||
return;
|
||||
|
||||
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
|
||||
max_files = gnome_config_get_int(key);
|
||||
g_free(key);
|
||||
|
||||
gnome_config_clean_section("/GnuCash/History/");
|
||||
gnome_config_push_prefix("/GnuCash/History/");
|
||||
gnome_config_set_int("MaxFiles", max_files);
|
||||
|
||||
for(tmp = history_list; tmp != NULL; tmp = tmp->next) {
|
||||
key = g_strdup_printf("File%d", i);
|
||||
gnome_config_set_string(key, (char *)tmp->data);
|
||||
g_free(key);
|
||||
i++;
|
||||
}
|
||||
|
||||
gnome_config_sync();
|
||||
gnome_config_pop_prefix();
|
||||
}
|
||||
|
||||
static void
|
||||
__gnc_history_get_list()
|
||||
{
|
||||
int max_files, i;
|
||||
char *key, *filename;
|
||||
|
||||
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
|
||||
max_files = gnome_config_get_int(key);
|
||||
g_free(key);
|
||||
|
||||
gnome_config_push_prefix("/GnuCash/History/");
|
||||
|
||||
for(i = 0; i < max_files; i++) {
|
||||
key = g_strdup_printf("File%d", i);
|
||||
filename = gnome_config_get_string(key);
|
||||
|
||||
if(filename == NULL) {
|
||||
g_free(key);
|
||||
break;
|
||||
}
|
||||
history_list = g_slist_prepend(history_list, filename);
|
||||
g_free(key);
|
||||
}
|
||||
|
||||
gnome_config_pop_prefix();
|
||||
|
||||
history_list = g_slist_reverse(history_list);
|
||||
}
|
||||
|
||||
static void
|
||||
__gnc_history_file_cb(GtkWidget *w, char *data)
|
||||
{
|
||||
gncFileOpenFile(data);
|
||||
gnc_refresh_main_window();
|
||||
}
|
||||
|
||||
void
|
||||
gnc_history_add_file(char *newfile)
|
||||
{
|
||||
int i, max_files;
|
||||
gboolean used_default, matched = FALSE;
|
||||
char *key = NULL;
|
||||
GSList *tmp, *new_list = NULL;
|
||||
|
||||
if (newfile == NULL)
|
||||
return;
|
||||
|
||||
gnome_config_push_prefix("/GnuCash/History/");
|
||||
key = g_strdup_printf("/GnuCash/History/MaxFiles=%d", MAX_HISTORY);
|
||||
max_files = gnome_config_get_int_with_default(key, &used_default);
|
||||
g_free(key);
|
||||
|
||||
if(used_default)
|
||||
gnome_config_set_int("MaxFiles", max_files);
|
||||
|
||||
if(history_list == NULL)
|
||||
__gnc_history_get_list();
|
||||
|
||||
i = 0;
|
||||
tmp = history_list;
|
||||
while(tmp != NULL && i < max_files) {
|
||||
if(!matched && /* no match yet */
|
||||
((i == max_files - 1) || /* last entry */
|
||||
(strcmp(newfile, (char *)tmp->data) == 0)) ) { /* filename match */
|
||||
g_free(tmp->data);
|
||||
matched = TRUE;
|
||||
} else {
|
||||
new_list = g_slist_prepend(new_list, tmp->data);
|
||||
}
|
||||
i++;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
new_list = g_slist_reverse(new_list);
|
||||
new_list = g_slist_prepend(new_list, g_strdup(newfile));
|
||||
g_slist_free(history_list);
|
||||
history_list = new_list;
|
||||
|
||||
__gnc_history_config_write();
|
||||
}
|
||||
|
||||
void
|
||||
gnc_history_update_menu()
|
||||
{
|
||||
GnomeApp *app;
|
||||
GnomeUIInfo *menu;
|
||||
char *path;
|
||||
int i, n;
|
||||
|
||||
app = GNOME_APP(gnc_get_ui_data());
|
||||
if (app == NULL)
|
||||
return;
|
||||
|
||||
gnome_app_remove_menu_range(app, _("_File/"), 7, 1+num_menu_entries);
|
||||
|
||||
if(history_list == NULL)
|
||||
__gnc_history_get_list();
|
||||
|
||||
if(history_list == NULL)
|
||||
return;
|
||||
|
||||
n = g_slist_length(history_list);
|
||||
/* one separator, plus one for each filename entry, plus one for end */
|
||||
menu = g_new(GnomeUIInfo, 2+n);
|
||||
|
||||
menu->type = GNOME_APP_UI_SEPARATOR;
|
||||
|
||||
for(i = 1; i <= n; i++) {
|
||||
(menu+i)->type = GNOME_APP_UI_ITEM;
|
||||
(menu+i)->label = g_strdup_printf("_%d. %s", i,
|
||||
(char *)g_slist_nth_data(history_list,
|
||||
i-1));
|
||||
(menu+i)->hint = NULL;
|
||||
|
||||
(menu+i)->moreinfo = (gpointer)__gnc_history_file_cb;
|
||||
(menu+i)->user_data = (char *)g_slist_nth_data(history_list, i-1);
|
||||
(menu+i)->unused_data = NULL;
|
||||
(menu+i)->pixmap_type = 0;
|
||||
(menu+i)->pixmap_info = NULL;
|
||||
(menu+i)->accelerator_key = 0;
|
||||
}
|
||||
(menu+i)->type = GNOME_APP_UI_ENDOFINFO;
|
||||
|
||||
path = g_strdup_printf("%s/%s", _("_File"), IMPORT_QIF_E_STR_N);
|
||||
gnome_app_insert_menus(GNOME_APP(app), path, menu);
|
||||
num_menu_entries = n;
|
||||
g_free(path);
|
||||
|
||||
for(i = 1; i <= n; i++)
|
||||
g_free( (menu+i)->label );
|
||||
|
||||
g_free(menu);
|
||||
}
|
@ -217,7 +217,7 @@ adjBWindow(Account *account)
|
||||
GtkWidget *dialog, *frame, *vbox;
|
||||
AdjBWindow *adjBData;
|
||||
gchar *title;
|
||||
|
||||
|
||||
FETCH_FROM_LIST(AdjBWindow, adjBList, account, account, adjBData);
|
||||
|
||||
title = gnc_adjb_make_window_name(account);
|
||||
@ -245,12 +245,15 @@ adjBWindow(Account *account)
|
||||
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
{
|
||||
GtkTooltips *tooltips;
|
||||
GtkWidget *hbox, *vbox;
|
||||
GtkWidget *amount, *date;
|
||||
GtkWidget *label;
|
||||
GtkWidget *label, *entry;
|
||||
gchar *currency;
|
||||
gchar *string;
|
||||
|
||||
tooltips = gtk_tooltips_new();
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 5);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
|
||||
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
||||
@ -281,10 +284,15 @@ adjBWindow(Account *account)
|
||||
gtk_box_pack_start(GTK_BOX(vbox), date, TRUE, TRUE, 0);
|
||||
adjBData->date_entry = date;
|
||||
|
||||
entry = GNC_DATE_EDIT(date)->date_entry;
|
||||
gtk_tooltips_set_tip(tooltips, entry, TOOLTIP_ADJUST_DATE, NULL);
|
||||
|
||||
amount = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), amount, TRUE, TRUE, 0);
|
||||
adjBData->balance_entry = amount;
|
||||
|
||||
gtk_tooltips_set_tip(tooltips, amount, TOOLTIP_ADJUST_AMOUNT, NULL);
|
||||
|
||||
currency = xaccAccountGetCurrency(account);
|
||||
string = xaccPrintAmount(0.0, PRTSEP, currency);
|
||||
gtk_entry_set_text(GTK_ENTRY(amount), string);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "dialog-edit.h"
|
||||
#include "dialog-qif-import.h"
|
||||
#include "dialog-find-transactions.h"
|
||||
#include "file-history.h"
|
||||
#include "Scrub.h"
|
||||
#include "util.h"
|
||||
#include "gnc.h"
|
||||
@ -194,6 +195,7 @@ gnc_refresh_main_window()
|
||||
{
|
||||
xaccRecomputeGroupBalance(gncGetCurrentGroup());
|
||||
gnc_ui_refresh_statusbar();
|
||||
gnc_history_update_menu(GNOME_APP(gnc_get_ui_data()));
|
||||
gnc_account_tree_refresh_all();
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,9 @@
|
||||
/* Tooltip phrases */
|
||||
#define TOOLTIP_ADJUST_N N_("Adjust the balance of the selected account")
|
||||
#define TOOLTIP_ADJUST _(TOOLTIP_ADJUST_N)
|
||||
#define TOOLTIP_ADJUST_AMOUNT _("Enter the new balance")
|
||||
#define TOOLTIP_ADJUST_DATE _("Enter the date you want the balance "\
|
||||
"adjusted")
|
||||
#define TOOLTIP_ADJUST_END_N N_("Adjust the ending balance")
|
||||
#define TOOLTIP_ADJUST_END _(TOOLTIP_ADJUST_END_N)
|
||||
#define TOOLTIP_ADJUST_REG_N N_("Adjust the balance of the main account "\
|
||||
|
@ -155,6 +155,9 @@
|
||||
"Your reports probably shouldn't have an "
|
||||
"option like this.") #f))
|
||||
|
||||
(gnc:options-set-default-section gnc:*hello-world-options*
|
||||
"Hello, World!")
|
||||
|
||||
gnc:*hello-world-options*)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user