46 #include "gnucash-sheet.h"
47 #include "gnucash-sheetP.h"
48 #include "gnucash-style.h"
50 #include "table-gnome.h"
55 #include "gnc-ledger-display.h"
71 GNCHeaderWidths widths;
79 if (table->ui_data == NULL)
85 sheet = GNUCASH_SHEET (table->ui_data);
87 widths = gnc_header_widths_new ();
89 gnucash_sheet_get_header_widths (sheet, widths);
91 node = gnc_table_layout_get_cells (table->layout);
92 for (; node; node = node->next)
97 width = gnc_header_widths_get_width (widths, cell->cell_name);
100 key = g_strdup_printf(
"%s_width", cell->cell_name);
101 if ((width > 0) && (!cell->expandable))
103 g_key_file_set_integer (state_file, state_section, key, width);
105 else if (g_key_file_has_key (state_file, state_section, key, NULL))
106 g_key_file_remove_key (state_file, state_section, key, NULL);
110 gnc_header_widths_destroy (widths);
121 if (table->ui_data == NULL)
124 sheet = GNUCASH_SHEET (table->ui_data);
126 gnucash_sheet_redraw_help (sheet);
130 table_destroy_cb (
Table *table)
137 if (table->ui_data == NULL)
140 sheet = GNUCASH_SHEET (table->ui_data);
142 g_object_unref (sheet);
144 table->ui_data = NULL;
159 GNCHeaderWidths widths;
169 g_return_if_fail (widget != NULL);
170 g_return_if_fail (GNUCASH_IS_REGISTER (widget));
172 PINFO(
"state_section=%s",state_section);
174 ENTER(
"widget=%p, data=%p", widget,
"");
177 greg = GNUCASH_REGISTER (widget);
178 sheet = GNUCASH_SHEET (greg->sheet);
179 table = sheet->table;
181 table->gui_handlers.redraw_help = table_ui_redraw_cb;
182 table->gui_handlers.destroy = table_destroy_cb;
183 table->ui_data = sheet;
185 g_object_ref (sheet);
189 widths = gnc_header_widths_new ();
191 if (state_section &&
gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
193 node = gnc_table_layout_get_cells (table->layout);
194 for (; node; node = node->next)
198 if (cell->expandable)
202 key = g_strdup_printf(
"%s_width", cell->cell_name);
203 value = g_key_file_get_integer (state_file, state_section, key, NULL);
205 gnc_header_widths_set_width (widths, cell->cell_name, value);
210 gnucash_sheet_create_styles (sheet);
212 gnucash_sheet_set_header_widths (sheet, widths);
214 gnucash_sheet_compile_styles (sheet);
216 gnucash_sheet_table_load (sheet, TRUE);
217 gnucash_sheet_cursor_set_from_table (sheet, TRUE);
218 gnucash_sheet_redraw_all (sheet);
220 gnc_header_widths_destroy (widths);
226 gnc_table_refresh_gui (
Table * table, gboolean do_scroll)
235 g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
237 sheet = GNUCASH_SHEET(table->ui_data);
239 gnucash_sheet_styles_recompile (sheet);
240 gnucash_sheet_table_load (sheet, do_scroll);
241 gnucash_sheet_redraw_all (sheet);
246 gnc_table_refresh_cursor_gnome (
Table * table,
252 if (!table || !table->ui_data)
255 g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
257 if (gnc_table_virtual_cell_out_of_bounds (table, vcell_loc))
260 sheet = GNUCASH_SHEET (table->ui_data);
262 gnucash_sheet_cursor_set_from_table (sheet, do_scroll);
264 if (gnucash_sheet_block_set_from_table (sheet, vcell_loc))
266 gnucash_sheet_recompute_block_offsets (sheet);
267 gnucash_sheet_set_scroll_region (sheet);
268 gnucash_sheet_compute_visible_range (sheet);
269 gnucash_sheet_redraw_all (sheet);
272 gnucash_sheet_redraw_block (sheet, vcell_loc);
276 gnc_table_show_range (
Table *table,
282 if (!table || !table->ui_data)
285 g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
287 if (gnc_table_virtual_cell_out_of_bounds (table, start_loc))
290 if (gnc_table_virtual_cell_out_of_bounds (table, end_loc))
293 sheet = GNUCASH_SHEET (table->ui_data);
295 gnucash_sheet_show_range (sheet, start_loc, end_loc);
299 gnc_table_gnome_init (
void)
303 gui_handlers.cursor_refresh = gnc_table_refresh_cursor_gnome;
Functions to load, save and get gui state.
#define PINFO(format, args...)
void gnc_table_set_default_gui_handlers(TableGUIHandlers *gui_handlers)
#define ENTER(format, args...)
GKeyFile * gnc_state_get_current(void)
void gnc_table_save_state(Table *table, gchar *state_section)
void gnc_table_init_gui(GtkWidget *widget, gchar *state_section)
All type declarations for the whole Gnucash engine.
Generic api to store and retrieve preferences.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Declarations for the Table object.
#define LEAVE(format, args...)
const gchar * QofLogModule