mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add sorting menu to reconcile window.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2361 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
78486a7178
commit
b91564428a
12
ChangeLog
12
ChangeLog
@ -1,5 +1,17 @@
|
||||
2000-05-20 Dave Peticolas <peticola@cs.ucdavis.edu>
|
||||
|
||||
* src/gnome/window-reconcile.c: add menus to change the sort order
|
||||
of the debits and credits list.
|
||||
|
||||
* src/engine/Query.c: allow the sort order to be set as increasing
|
||||
or decreasing.
|
||||
|
||||
2000-05-19 Dave Peticolas <peticola@cs.ucdavis.edu>
|
||||
|
||||
* src/register/gnome/gnucash-style.c (gnucash_style_init): use
|
||||
default style's font. Unfortunately, there doesn't seem to be a
|
||||
way to get a default italic font, so use the regular one for now.
|
||||
|
||||
* src/gnome/reconcile-list.c: use Queries to get the splits so
|
||||
we can do sorting. Add an api call to change the sort order.
|
||||
|
||||
|
@ -103,6 +103,8 @@ xaccInitQuery(Query * q, QueryTerm * initial_term) {
|
||||
q->primary_sort = BY_STANDARD;
|
||||
q->secondary_sort = BY_NONE;
|
||||
q->tertiary_sort = BY_NONE;
|
||||
|
||||
q->sort_increasing = GNC_T;
|
||||
}
|
||||
|
||||
|
||||
@ -606,24 +608,31 @@ split_cmp_func(sort_type_t how, gconstpointer ga, gconstpointer gb) {
|
||||
|
||||
static int
|
||||
split_sort_func(gconstpointer a, gconstpointer b) {
|
||||
int retval;
|
||||
int retval;
|
||||
int multiplier;
|
||||
|
||||
assert(split_sort_query);
|
||||
|
||||
if (split_sort_query->sort_increasing)
|
||||
multiplier = 1;
|
||||
else
|
||||
multiplier = -1;
|
||||
|
||||
retval = split_cmp_func(split_sort_query->primary_sort, a, b);
|
||||
if((retval == 0) &&
|
||||
(split_sort_query->secondary_sort != BY_NONE)) {
|
||||
retval = split_cmp_func(split_sort_query->secondary_sort, a, b);
|
||||
if((retval == 0) &&
|
||||
(split_sort_query->tertiary_sort != BY_NONE)) {
|
||||
return split_cmp_func(split_sort_query->tertiary_sort, a, b);
|
||||
(split_sort_query->tertiary_sort != BY_NONE)) {
|
||||
retval = split_cmp_func(split_sort_query->tertiary_sort, a, b);
|
||||
return retval * multiplier;
|
||||
}
|
||||
else {
|
||||
return retval;
|
||||
return retval * multiplier;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return retval;
|
||||
return retval * multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1759,6 +1768,14 @@ xaccQuerySetSortOrder(Query * q, sort_type_t primary,
|
||||
q->changed = 1;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQuerySetSortIncreasing
|
||||
*******************************************************************/
|
||||
void
|
||||
xaccQuerySetSortIncreasing(Query * q, gncBoolean increasing)
|
||||
{
|
||||
q->sort_increasing = increasing;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQuerySetMaxSplits
|
||||
|
@ -75,13 +75,14 @@ typedef struct {
|
||||
/* terms is a list of the OR-terms in a sum-of-products
|
||||
* logical expression. */
|
||||
GList * terms;
|
||||
|
||||
|
||||
/* sorting and chopping is independent of the search filter */
|
||||
sort_type_t primary_sort;
|
||||
sort_type_t secondary_sort;
|
||||
sort_type_t tertiary_sort;
|
||||
gncBoolean sort_increasing;
|
||||
int max_splits;
|
||||
|
||||
|
||||
/* cache the results so we don't have to run the whole search
|
||||
* again until it's really necessary */
|
||||
int changed;
|
||||
@ -231,6 +232,7 @@ int xaccSharesMatchPredicate(Split * s, PredicateData * pd);
|
||||
|
||||
void xaccQuerySetSortOrder(Query * q, sort_type_t primary,
|
||||
sort_type_t secondary, sort_type_t tertiary);
|
||||
void xaccQuerySetSortIncreasing(Query * q, gncBoolean increasing);
|
||||
void xaccQuerySetMaxSplits(Query * q, int n);
|
||||
|
||||
|
||||
|
@ -562,6 +562,11 @@ gnc_reconcile_list_set_sort_order(GNCReconcileList *list, sort_type_t key)
|
||||
xaccQuerySetSortOrder(list->query, key,
|
||||
(key == BY_STANDARD) ? BY_NONE : BY_STANDARD,
|
||||
BY_NONE);
|
||||
|
||||
if (list->list_type == RECLIST_DEBIT)
|
||||
return;
|
||||
|
||||
xaccQuerySetSortIncreasing(list->query, !(key == BY_AMOUNT));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -87,6 +87,12 @@ struct _RecnWindow
|
||||
GtkWidget *edit_item; /* Edit transaction menu item */
|
||||
GtkWidget *delete_item; /* Delete transaction menu item */
|
||||
|
||||
GtkWidget *sort_debits_formal; /* Sort debits menu formal */
|
||||
GtkWidget *sort_credits_formal; /* Sort credits menu formal */
|
||||
|
||||
GtkWidget *sort_debits_informal; /* Sort debits menu informal */
|
||||
GtkWidget *sort_credits_informal; /* Sort credits menu informal */
|
||||
|
||||
GtkWidget *edit_popup; /* Edit transaction popup menu item */
|
||||
GtkWidget *delete_popup; /* Delete transaction popup menu item */
|
||||
|
||||
@ -97,6 +103,7 @@ struct _RecnWindow
|
||||
gboolean delete_refresh; /* do a refresh upon a window deletion */
|
||||
};
|
||||
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
static double recnRecalculateBalance( RecnWindow *recnData );
|
||||
|
||||
@ -108,14 +115,15 @@ static void gnc_reconcile_window_set_sensitivity(RecnWindow *recnData);
|
||||
static char * gnc_recn_make_window_name(Account *account);
|
||||
static void gnc_recn_set_window_name(RecnWindow *recnData);
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
static RecnWindow **recnList = NULL;
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
/** IMPLEMENTATIONS *************************************************/
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
@ -467,7 +475,7 @@ gnc_reconcile_window_focus_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_reconcile_window_set_frame_titles(RecnWindow *recnData)
|
||||
gnc_reconcile_window_set_titles(RecnWindow *recnData)
|
||||
{
|
||||
gboolean formal;
|
||||
gchar *title;
|
||||
@ -494,12 +502,27 @@ gnc_reconcile_window_set_frame_titles(RecnWindow *recnData)
|
||||
|
||||
if (!formal)
|
||||
g_free(title);
|
||||
|
||||
if (formal)
|
||||
{
|
||||
gtk_widget_show(recnData->sort_debits_formal);
|
||||
gtk_widget_show(recnData->sort_credits_formal);
|
||||
gtk_widget_hide(recnData->sort_debits_informal);
|
||||
gtk_widget_hide(recnData->sort_credits_informal);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide(recnData->sort_debits_formal);
|
||||
gtk_widget_hide(recnData->sort_credits_formal);
|
||||
gtk_widget_show(recnData->sort_debits_informal);
|
||||
gtk_widget_show(recnData->sort_credits_informal);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_frame_titles_cb(void *data)
|
||||
set_titles_cb(void *data)
|
||||
{
|
||||
gnc_reconcile_window_set_frame_titles(data);
|
||||
gnc_reconcile_window_set_titles(data);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@ -782,6 +805,102 @@ gnc_recn_open_cb(GtkWidget *widget, gpointer data)
|
||||
gnc_register_raise(regData);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_reconcile_sort(RecnWindow *recnData, GNCReconcileListType list_type,
|
||||
sort_type_t sort_code)
|
||||
{
|
||||
GNCReconcileList *list;
|
||||
|
||||
if (list_type == RECLIST_DEBIT)
|
||||
list = GNC_RECONCILE_LIST(recnData->debit);
|
||||
else
|
||||
list = GNC_RECONCILE_LIST(recnData->credit);
|
||||
|
||||
switch(sort_code)
|
||||
{
|
||||
default:
|
||||
case BY_STANDARD:
|
||||
gnc_reconcile_list_set_sort_order(list, BY_STANDARD);
|
||||
break;
|
||||
case BY_NUM:
|
||||
gnc_reconcile_list_set_sort_order(list, BY_NUM);
|
||||
break;
|
||||
case BY_AMOUNT:
|
||||
gnc_reconcile_list_set_sort_order(list, BY_AMOUNT);
|
||||
break;
|
||||
case BY_DESC:
|
||||
gnc_reconcile_list_set_sort_order(list, BY_DESC);
|
||||
break;
|
||||
}
|
||||
|
||||
gnc_reconcile_list_refresh(GNC_RECONCILE_LIST(recnData->debit));
|
||||
gnc_reconcile_list_refresh(GNC_RECONCILE_LIST(recnData->credit));
|
||||
}
|
||||
|
||||
static void
|
||||
sort_debit_standard_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_DEBIT, BY_STANDARD);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_debit_num_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_DEBIT, BY_NUM);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_debit_desc_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_DEBIT, BY_DESC);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_debit_amount_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_DEBIT, BY_AMOUNT);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_credit_standard_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_CREDIT, BY_STANDARD);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_credit_num_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_CREDIT, BY_NUM);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_credit_desc_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_CREDIT, BY_DESC);
|
||||
}
|
||||
|
||||
static void
|
||||
sort_credit_amount_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
|
||||
gnc_reconcile_sort(recnData, RECLIST_CREDIT, BY_AMOUNT);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
|
||||
{
|
||||
@ -815,6 +934,53 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo sort_debit_list[] =
|
||||
{
|
||||
GNOMEUIINFO_RADIOITEM_DATA(STANDARD_ORDER_STR_N, TOOLTIP_STANDARD_ORD_N,
|
||||
sort_debit_standard_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_NUM_STR_N, TOOLTIP_SORT_BY_NUM_N,
|
||||
sort_debit_num_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_DESC_STR_N, TOOLTIP_SORT_BY_DESC_N,
|
||||
sort_debit_desc_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_AMNT_STR_N, TOOLTIP_SORT_BY_AMNT_N,
|
||||
sort_debit_amount_cb, NULL, NULL),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo sort_debit_menu[] =
|
||||
{
|
||||
GNOMEUIINFO_RADIOLIST(sort_debit_list),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo sort_credit_list[] =
|
||||
{
|
||||
GNOMEUIINFO_RADIOITEM_DATA(STANDARD_ORDER_STR_N, TOOLTIP_STANDARD_ORD_N,
|
||||
sort_credit_standard_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_NUM_STR_N, TOOLTIP_SORT_BY_NUM_N,
|
||||
sort_credit_num_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_DESC_STR_N, TOOLTIP_SORT_BY_DESC_N,
|
||||
sort_credit_desc_cb, NULL, NULL),
|
||||
GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_AMNT_STR_N, TOOLTIP_SORT_BY_AMNT_N,
|
||||
sort_credit_amount_cb, NULL, NULL),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo sort_credit_menu[] =
|
||||
{
|
||||
GNOMEUIINFO_RADIOLIST(sort_credit_list),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo sort_menu[] =
|
||||
{
|
||||
GNOMEUIINFO_SUBTREE(DEBITS_STR_N, sort_debit_menu),
|
||||
GNOMEUIINFO_SUBTREE(CREDITS_STR_N, sort_credit_menu),
|
||||
GNOMEUIINFO_SUBTREE(NULL, sort_debit_menu),
|
||||
GNOMEUIINFO_SUBTREE(NULL, sort_credit_menu),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
static GnomeUIInfo account_menu[] =
|
||||
{
|
||||
{
|
||||
@ -898,6 +1064,7 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
|
||||
static GnomeUIInfo reconcile_window_menu[] =
|
||||
{
|
||||
GNOMEUIINFO_SUBTREE(RECONCILE_MENU_STR_N, reconcile_menu),
|
||||
GNOMEUIINFO_SUBTREE(SORT_ORDER_MENU_STR_N, sort_menu),
|
||||
GNOMEUIINFO_SUBTREE(ACCOUNT_MENU_STR_N, account_menu),
|
||||
GNOMEUIINFO_SUBTREE(TRANSACTION_MENU_STR_N, transaction_menu),
|
||||
GNOMEUIINFO_MENU_HELP_TREE(help_menu),
|
||||
@ -906,6 +1073,9 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
|
||||
|
||||
gnc_fill_menu_with_data(reconcile_window_menu, recnData);
|
||||
|
||||
sort_menu[2].label = gnc_get_debit_string(NO_TYPE);
|
||||
sort_menu[3].label = gnc_get_credit_string(NO_TYPE);
|
||||
|
||||
menubar = gtk_menu_bar_new();
|
||||
|
||||
accel_group = gtk_accel_group_new();
|
||||
@ -920,6 +1090,14 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
|
||||
recnData->edit_item = transaction_menu[1].widget;
|
||||
recnData->delete_item = transaction_menu[2].widget;
|
||||
|
||||
recnData->sort_debits_formal = sort_menu[0].widget;
|
||||
recnData->sort_credits_formal = sort_menu[1].widget;
|
||||
recnData->sort_debits_informal = sort_menu[2].widget;
|
||||
recnData->sort_credits_informal = sort_menu[3].widget;
|
||||
|
||||
g_free(sort_menu[2].label);
|
||||
g_free(sort_menu[3].label);
|
||||
|
||||
return menubar;
|
||||
}
|
||||
|
||||
@ -1157,12 +1335,6 @@ recnWindow(GtkWidget *parent, Account *account)
|
||||
(account, RECLIST_CREDIT, recnData,
|
||||
&recnData->credit, &recnData->total_credit);
|
||||
|
||||
gnc_reconcile_window_set_frame_titles(recnData);
|
||||
|
||||
recnData->title_change_cb_id =
|
||||
gnc_register_option_change_callback(set_frame_titles_cb, recnData,
|
||||
"General", "Use accounting labels");
|
||||
|
||||
popup = gnc_recn_create_popup_menu(recnData);
|
||||
gnome_popup_menu_attach(popup, recnData->debit, recnData);
|
||||
gnome_popup_menu_attach(popup, recnData->credit, recnData);
|
||||
@ -1268,6 +1440,12 @@ recnWindow(GtkWidget *parent, Account *account)
|
||||
|
||||
gtk_widget_show_all(recnData->window);
|
||||
|
||||
gnc_reconcile_window_set_titles(recnData);
|
||||
|
||||
recnData->title_change_cb_id =
|
||||
gnc_register_option_change_callback(set_titles_cb, recnData,
|
||||
"General", "Use accounting labels");
|
||||
|
||||
recnRecalculateBalance(recnData);
|
||||
|
||||
gnc_recn_refresh_toolbar(recnData);
|
||||
|
@ -105,7 +105,7 @@ static int last_stock_width = 0;
|
||||
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
RegWindow *regWindowLedger(xaccLedgerDisplay *ledger);
|
||||
RegWindow * regWindowLedger(xaccLedgerDisplay *ledger);
|
||||
static void regRefresh(xaccLedgerDisplay *ledger);
|
||||
static void gnc_reg_refresh_toolbar(RegWindow *regData);
|
||||
static void regDestroy(xaccLedgerDisplay *ledger);
|
||||
@ -322,7 +322,7 @@ gnc_register_style_auto_double_cb(GtkWidget *w, gpointer data)
|
||||
|
||||
|
||||
static void
|
||||
gnc_register_sort(RegWindow *regData, int sort_code)
|
||||
gnc_register_sort(RegWindow *regData, sort_type_t sort_code)
|
||||
{
|
||||
Query *query = regData->ledger->query;
|
||||
|
||||
|
@ -545,12 +545,14 @@
|
||||
#define COMMIT_STR _("Commit")
|
||||
#define CREATE_STR _("Create")
|
||||
#define CREDIT_STR _("Credit")
|
||||
#define CREDITS_STR _("Credits")
|
||||
#define CREDITS_STR_N N_("Credits")
|
||||
#define CREDITS_STR _(CREDITS_STR_N)
|
||||
#define CURRENCY_STR _("Currency")
|
||||
#define DATE_STR _("Date")
|
||||
#define DAYS_STR _("Days")
|
||||
#define DEBIT_STR _("Debit")
|
||||
#define DEBITS_STR _("Debits")
|
||||
#define DEBITS_STR_N N_("Debits")
|
||||
#define DEBITS_STR _(DEBITS_STR_N)
|
||||
#define DECREASE_STR _("Decrease")
|
||||
#define DEFICIT_STR _("Deficit")
|
||||
#define DELETE_STR_N N_("Delete")
|
||||
|
@ -1515,8 +1515,12 @@ gnucash_style_unref (SheetBlockStyle *style)
|
||||
void
|
||||
gnucash_style_init (void)
|
||||
{
|
||||
gnucash_default_font = gdk_font_load (DEFAULT_FONT);
|
||||
gnucash_italic_font = gdk_font_load (ITALIC_FONT);
|
||||
GtkStyle *style;
|
||||
|
||||
style = gtk_widget_get_default_style();
|
||||
|
||||
gnucash_default_font = style->font;
|
||||
gnucash_italic_font = style->font;
|
||||
|
||||
g_assert (gnucash_default_font);
|
||||
g_assert (gnucash_italic_font);
|
||||
|
Loading…
Reference in New Issue
Block a user