Ejemplo n.º 1
0
void
gnc_table_save_state (Table *table, gchar * state_key)
{
    GnucashSheet *sheet;
    GNCHeaderWidths widths;
    GList *node;
    gchar *key;
    
    if (!table)
        return;

    if (table->ui_data == NULL)
        return;

    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
        return;

    sheet = GNUCASH_SHEET (table->ui_data);

    widths = gnc_header_widths_new ();

    gnucash_sheet_get_header_widths (sheet, widths);

    node = gnc_table_layout_get_cells (table->layout);
    for (; node; node = node->next)
    {
        BasicCell *cell = node->data;
        int width;

        width = gnc_header_widths_get_width (widths, cell->cell_name);
        if (width <= 0)
            continue;

        if (cell->expandable)
            continue;

        /* Remember whether the column is visible */
        key = g_strdup_printf("%s_width", cell->cell_name);
        // FIXME the actual state saving is currently not implemented
        g_free(key);
    }

    gnc_header_widths_destroy (widths);
}
Ejemplo n.º 2
0
/* If any of the cells have GUI specific components that need
 * initialization, initialize them now. The realize() callback
 * on the cursor cell is how we inform the cell handler that
 * now is the time to initialize its GUI.  */
void
gnc_table_realize_gui (Table * table)
{
    GList *cells;
    GList *node;

    if (!table) return;
    if (!table->ui_data) return;

    cells = gnc_table_layout_get_cells (table->layout);

    for (node = cells; node; node = node->next)
    {
        BasicCell *cell = node->data;

        if (cell->gui_realize)
            cell->gui_realize (cell, table->ui_data);
    }
}
Ejemplo n.º 3
0
void
gnc_table_save_cells (Table *table, gpointer save_data)
{
    TableSaveHandler save_handler;
    GList * cells;
    GList * node;

    g_return_if_fail (table);

    /* ignore any changes to read-only tables */
    if (gnc_table_model_read_only (table->model))
        return;

    // gnc_table_leave_update (table, table->current_cursor_loc);

    save_handler = gnc_table_model_get_pre_save_handler (table->model);
    if (save_handler)
        save_handler (save_data, table->model->handler_user_data);

    cells = gnc_table_layout_get_cells (table->layout);
    for (node = cells; node; node = node->next)
    {
        BasicCell * cell = node->data;
        TableSaveCellHandler save_cell_handler;

        if (!cell) continue;

        if (!gnc_table_layout_get_cell_changed (table->layout,
                                                cell->cell_name, TRUE))
            continue;

        save_cell_handler = gnc_table_model_get_save_handler (table->model,
                            cell->cell_name);
        if (save_cell_handler)
            save_cell_handler (cell, save_data, table->model->handler_user_data);
    }

    save_handler = gnc_table_model_get_post_save_handler (table->model);
    if (save_handler)
        save_handler (save_data, table->model->handler_user_data);
}
Ejemplo n.º 4
0
void
gnc_table_init_gui (GtkWidget *widget, gchar * state_key)
{
    GNCHeaderWidths widths;
    GnucashSheet *sheet;
    GnucashRegister *greg;
    Table *table;
    GList *node;
    gchar *key;
    guint value;
 
    // Stuff for per-register settings load.
    g_return_if_fail (widget != NULL);
    g_return_if_fail (GNUCASH_IS_REGISTER (widget));
    
    PINFO("state_key=%s",state_key);
    
    ENTER("widget=%p, data=%p", widget, "");
    

    greg = GNUCASH_REGISTER (widget);
    sheet = GNUCASH_SHEET (greg->sheet);
    table = sheet->table;

    table->gui_handlers.redraw_help = table_ui_redraw_cb;
    table->gui_handlers.destroy = table_destroy_cb;
    table->ui_data = sheet;

    g_object_ref (sheet);

    /* config the cell-block styles */

    widths = gnc_header_widths_new ();

    if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
    {
        node = gnc_table_layout_get_cells (table->layout);
        for (; node; node = node->next)
        {
            BasicCell *cell = node->data;

            if (cell->expandable)
                continue;

            /* Remember whether the column is visible */
            key = g_strdup_printf("%s_width", cell->cell_name);
            // FIXME the actual state loading is currently not implemented
            value = 0;
            if (value != 0)
                gnc_header_widths_set_width (widths, cell->cell_name, value);
            g_free(key);
        }
    }

    gnucash_sheet_create_styles (sheet);

    gnucash_sheet_set_header_widths (sheet, widths);

    gnucash_sheet_compile_styles (sheet);

    gnucash_sheet_table_load (sheet, TRUE);
    gnucash_sheet_cursor_set_from_table (sheet, TRUE);
    gnucash_sheet_redraw_all (sheet);

    gnc_header_widths_destroy (widths);

    LEAVE(" ");
}
Ejemplo n.º 5
0
static void
gnucash_register_configure (GnucashSheet *sheet, gchar * state_section)
{
    GNCHeaderWidths widths;
    Table *table;
    GList *node;
    gchar *key;
    guint value;
    GKeyFile *state_file = gnc_state_get_current();

    // Stuff for per-register settings load.
    g_return_if_fail (sheet != NULL);
    g_return_if_fail (GNUCASH_IS_SHEET (sheet));

    PINFO("state_section=%s",state_section);

    ENTER("sheet=%p, data=%p", sheet, "");

    table = sheet->table;
    gnc_table_init_gui (table);
    table->ui_data = sheet;

    g_object_ref (sheet);

    /* config the cell-block styles */

    widths = gnc_header_widths_new ();

    if (state_section && gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
    {
        node = gnc_table_layout_get_cells (table->layout);
        for (; node; node = node->next)
        {
            BasicCell *cell = node->data;

            if (cell->expandable)
                continue;

            /* Remember whether the column is visible */
            key = g_strdup_printf("%s_width", cell->cell_name);
            value = g_key_file_get_integer (state_file, state_section, key, NULL);
            if (value != 0)
                gnc_header_widths_set_width (widths, cell->cell_name, value);
            g_free(key);
        }
    }

    gnucash_sheet_create_styles (sheet);

    gnucash_sheet_set_header_widths (sheet, widths);

    gnucash_sheet_compile_styles (sheet);

    gnucash_sheet_table_load (sheet, TRUE);
    gnucash_sheet_cursor_set_from_table (sheet, TRUE);
    gnucash_sheet_redraw_all (sheet);

    gnc_header_widths_destroy (widths);

    LEAVE(" ");
}