mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Save and restore register column widths.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2935 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9b07ec0629
commit
4c09eff04f
@ -519,7 +519,7 @@ gnc_get_window_size(const char *prefix, int *width, int *height)
|
||||
int w, h;
|
||||
char *name;
|
||||
|
||||
if (gnc_lookup_boolean_option("General", "Save Window Geometry", FALSE))
|
||||
if (gnc_lookup_boolean_option("General", "Save Window Geometry", TRUE))
|
||||
{
|
||||
name = g_strconcat(prefix, "_width", NULL);
|
||||
w = gnc_lookup_number_option("__gui", name, 0.0);
|
||||
|
@ -351,8 +351,6 @@ gnucash_header_auto_resize_column (GnucashHeader *header, gint col)
|
||||
gnucash_cursor_configure (GNUCASH_CURSOR(sheet->cursor));
|
||||
item_edit_configure (ITEM_EDIT(sheet->item_editor));
|
||||
|
||||
gnucash_sheet_update_adjustments (sheet);
|
||||
|
||||
gnucash_header_reconfigure (header);
|
||||
gnucash_sheet_set_scroll_region (sheet);
|
||||
gnucash_sheet_update_adjustments (sheet);
|
||||
|
@ -118,9 +118,6 @@ typedef struct {
|
||||
gint top_block_offset;
|
||||
gint left_block_offset;
|
||||
|
||||
gint default_width;
|
||||
gint default_height;
|
||||
|
||||
gint width; /* the width in pixels of the sheet */
|
||||
gint height;
|
||||
|
||||
|
@ -190,14 +190,13 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
|
||||
cd = g_table_index (dimensions->cell_dimensions,
|
||||
row, col);
|
||||
|
||||
if (cd->pixel_width >= 0)
|
||||
continue;
|
||||
|
||||
cb_cell = gnc_cellblock_get_cell (cursor, row, col);
|
||||
|
||||
text = cb_cell->sample_text;
|
||||
|
||||
if (text)
|
||||
if (cd->pixel_width > 0)
|
||||
width = cd->pixel_width;
|
||||
else if (text)
|
||||
{
|
||||
width = gdk_string_width (font, text);
|
||||
width += 2 * CELL_HPADDING;
|
||||
@ -446,6 +445,8 @@ gnucash_sheet_set_col_width (GnucashSheet *sheet, int col, int width)
|
||||
{
|
||||
CellDimensions *cd;
|
||||
SheetBlockStyle *style;
|
||||
int total;
|
||||
int diff;
|
||||
|
||||
g_return_if_fail (sheet != NULL);
|
||||
g_return_if_fail (GNUCASH_IS_SHEET(sheet));
|
||||
@ -461,9 +462,12 @@ gnucash_sheet_set_col_width (GnucashSheet *sheet, int col, int width)
|
||||
cd = gnucash_style_get_cell_dimensions (style, 0, col);
|
||||
|
||||
/* adjust the overall width of this style */
|
||||
diff = cd->pixel_width - width;
|
||||
cd->pixel_width = width;
|
||||
|
||||
set_dimensions_pass_two (sheet, width);
|
||||
total = MAX (sheet->window_width, sheet->width - diff);
|
||||
|
||||
set_dimensions_pass_two (sheet, total);
|
||||
set_dimensions_pass_three (sheet);
|
||||
}
|
||||
|
||||
@ -667,7 +671,7 @@ gnucash_sheet_style_new (GnucashSheet *sheet, CellBlock *cursor,
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_sheet_compile_styles (GnucashSheet *sheet)
|
||||
gnucash_sheet_create_styles (GnucashSheet *sheet)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -677,6 +681,13 @@ gnucash_sheet_compile_styles (GnucashSheet *sheet)
|
||||
for (i = 0; i < GNUCASH_NUM_CURSORS; i++)
|
||||
sheet->cursor_styles[i] =
|
||||
gnucash_sheet_style_new (sheet, sheet->cursors[i], i);
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_sheet_compile_styles (GnucashSheet *sheet)
|
||||
{
|
||||
g_return_if_fail (sheet != NULL);
|
||||
g_return_if_fail (GNUCASH_IS_SHEET (sheet));
|
||||
|
||||
gnucash_sheet_styles_set_dimensions (sheet, DEFAULT_STYLE_WIDTH);
|
||||
}
|
||||
@ -925,6 +936,9 @@ gnucash_sheet_set_header_widths (GnucashSheet *sheet, int *header_widths)
|
||||
if (cb_cell->cell_type < 0)
|
||||
continue;
|
||||
|
||||
if (header_widths[cb_cell->cell_type] < 0)
|
||||
continue;
|
||||
|
||||
cd->pixel_width = header_widths[cb_cell->cell_type];
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ void gnucash_sheet_styles_set_dimensions (GnucashSheet *sheet, int width);
|
||||
|
||||
void gnucash_sheet_style_destroy (GnucashSheet *sheet, SheetBlockStyle *style);
|
||||
|
||||
void gnucash_sheet_create_styles (GnucashSheet *sheet);
|
||||
|
||||
void gnucash_sheet_compile_styles (GnucashSheet *sheet);
|
||||
|
||||
void gnucash_sheet_styles_recompile (GnucashSheet *sheet);
|
||||
|
@ -40,8 +40,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <gnome.h>
|
||||
#include <guile/gh.h>
|
||||
|
||||
#include "cellblock.h"
|
||||
#include "global-options.h"
|
||||
#include "table-allgui.h"
|
||||
#include "splitreg.h"
|
||||
#include "util.h"
|
||||
@ -56,6 +58,7 @@ table_destroy_cb(Table *table)
|
||||
{
|
||||
int header_widths[CELL_TYPE_COUNT];
|
||||
GnucashSheet *sheet;
|
||||
SCM alist;
|
||||
int i;
|
||||
|
||||
if (table == NULL)
|
||||
@ -71,6 +74,25 @@ table_destroy_cb(Table *table)
|
||||
|
||||
gnucash_sheet_get_header_widths (sheet, header_widths);
|
||||
|
||||
alist = SCM_EOL;
|
||||
if (gnc_lookup_boolean_option("General", "Save Window Geometry", TRUE))
|
||||
for (i = 0; i < CELL_TYPE_COUNT; i++)
|
||||
{
|
||||
const char *name;
|
||||
SCM assoc;
|
||||
|
||||
if (header_widths[i] <= 0)
|
||||
continue;
|
||||
|
||||
name = xaccSplitRegisterGetCellTypeName (i);
|
||||
assoc = gh_cons (gh_str02scm(name),
|
||||
gh_int2scm(header_widths[i]));
|
||||
|
||||
alist = gh_cons (assoc, alist);
|
||||
}
|
||||
|
||||
gnc_set_option ("__gui", "reg_column_widths", alist);
|
||||
|
||||
gtk_widget_unref(GTK_WIDGET(sheet));
|
||||
|
||||
table->ui_data = NULL;
|
||||
@ -79,10 +101,13 @@ table_destroy_cb(Table *table)
|
||||
void
|
||||
gnc_table_init_gui (gncUIWidget widget, void *data)
|
||||
{
|
||||
int header_widths[CELL_TYPE_COUNT];
|
||||
SplitRegister *sr;
|
||||
GnucashSheet *sheet;
|
||||
GnucashRegister *greg;
|
||||
Table *table;
|
||||
SCM alist;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GNUCASH_IS_REGISTER (widget));
|
||||
@ -112,6 +137,39 @@ gnc_table_init_gui (gncUIWidget widget, void *data)
|
||||
gnucash_sheet_set_cursor (sheet, sr->split_cursor,
|
||||
GNUCASH_CURSOR_SPLIT);
|
||||
|
||||
for (i = 0; i < CELL_TYPE_COUNT; i++)
|
||||
header_widths[i] = -1;
|
||||
|
||||
if (gnc_lookup_boolean_option("General", "Save Window Geometry", TRUE))
|
||||
alist = gnc_lookup_option ("__gui", "reg_column_widths",
|
||||
SCM_EOL);
|
||||
else
|
||||
alist = SCM_EOL;
|
||||
|
||||
while (gh_list_p(alist) && !gh_null_p(alist))
|
||||
{
|
||||
const char *name;
|
||||
CellType ctype;
|
||||
SCM assoc;
|
||||
|
||||
assoc = gh_car (alist);
|
||||
alist = gh_cdr (alist);
|
||||
|
||||
name = gh_scm2newstr(gh_car (assoc), NULL);
|
||||
ctype = xaccSplitRegisterGetCellTypeFromName (name);
|
||||
if (name)
|
||||
free(name);
|
||||
|
||||
if (ctype == NO_CELL)
|
||||
continue;
|
||||
|
||||
header_widths[ctype] = gh_scm2int(gh_cdr (assoc));
|
||||
}
|
||||
|
||||
gnucash_sheet_create_styles (sheet);
|
||||
|
||||
gnucash_sheet_set_header_widths (sheet, header_widths);
|
||||
|
||||
gnucash_sheet_compile_styles (sheet);
|
||||
|
||||
gnc_table_refresh_header (table);
|
||||
|
@ -568,7 +568,8 @@
|
||||
name
|
||||
default-value)
|
||||
(let* ((value default-value)
|
||||
(value->string (lambda () (gnc:value->string value))))
|
||||
(value->string (lambda ()
|
||||
(string-append "'" (gnc:value->string value)))))
|
||||
(gnc:make-option
|
||||
section name "" 'internal #f
|
||||
(lambda () value)
|
||||
|
@ -564,6 +564,10 @@ the current value of the path."
|
||||
(gnc:make-internal-option
|
||||
"__gui" "reg_stock_win_width" 0))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-internal-option
|
||||
"__gui" "reg_column_widths" '()))
|
||||
|
||||
|
||||
;; This needs to be after all the global options definitions
|
||||
(if (gnc:debugging?)
|
||||
|
Loading…
Reference in New Issue
Block a user