static void gnc_tree_model_owner_init (GncTreeModelOwner *model) { GncTreeModelOwnerPrivate *priv; gboolean red; ENTER("model %p", model); while (model->stamp == 0) { model->stamp = g_random_int (); } red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED); priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model); priv->book = NULL; priv->owner_list = NULL; priv->owner_type = GNC_OWNER_NONE; priv->negative_color = red ? "red" : NULL; gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED, gnc_tree_model_owner_update_color, model); LEAVE(" "); }
GtkWidget * gnc_main_window_summary_new (void) { GNCMainSummary * retval = g_new0(GNCMainSummary, 1); GtkCellRenderer *textRenderer; int i; retval->datamodel = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); retval->hbox = gtk_hbox_new (FALSE, 5); retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel)); g_object_unref (retval->datamodel); retval->component_id = gnc_register_gui_component (WINDOW_SUMMARYBAR_CM_CLASS, summarybar_refresh_handler, NULL, retval); gnc_gui_component_watch_entity_type (retval->component_id, GNC_ID_ACCOUNT, QOF_EVENT_DESTROY | GNC_EVENT_ITEM_CHANGED); // Allows you to get when the popup menu is present g_signal_connect (retval->totals_combo, "notify::popup-shown",G_CALLBACK (summary_combo_popped), retval); retval->combo_popped = FALSE; for (i = 0; i <= N_COLUMNS; i += 2) { textRenderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new()); gtk_cell_renderer_set_fixed_size (textRenderer, 50, -1); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, TRUE); g_object_set_data (G_OBJECT(textRenderer), "view_column", GINT_TO_POINTER (i)); gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, cdf, retval, NULL); } gtk_container_set_border_width (GTK_CONTAINER (retval->hbox), 2); gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo, TRUE, TRUE, 5); gtk_widget_show (retval->totals_combo); gtk_widget_show (retval->hbox); g_signal_connect_swapped (G_OBJECT (retval->hbox), "destroy", G_CALLBACK (gnc_main_window_summary_destroy_cb), retval); gnc_main_window_summary_refresh(retval); retval->cnxn_id = gnc_prefs_register_cb (GNC_PREFS_GROUP, NULL, prefs_changed_cb, retval); return retval->hbox; }
/** Initialize the registeru for a window. This function is * called as part of the initialization of a window, after all the * plugin menu items have been added to the menu structure. Its job * is to correctly initialize the register. It does this by * installing a function that listens for preference changes. Each * time a preference changes, it kicks off a gui refresh. * * @param plugin A pointer to the gnc-plugin object responsible for * adding/removing the register. * * @param window A pointer to the gnc-main-window that is being initialized. * * @param type Unused */ static void gnc_plugin_register2_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL, gnc_plugin_register2_pref_changed, window); }
void gnc_prefs_init (void) { gnc_gsettings_load_backend(); /* Initialize the core preferences by reading their values from the loaded backend. * Note: of no backend was loaded, these functions will return sane default values. */ file_retain_changed_cb (NULL, NULL, NULL); file_retain_type_changed_cb (NULL, NULL, NULL); file_compression_changed_cb (NULL, NULL, NULL); /* Check for invalid retain_type (days)/retain_days (0) combo. * This can happen either because a user changed the preferences * manually outside of GnuCash, or because the user upgraded from * gnucash version 2.3.15 or older. Back then, 0 retain_days meant * "keep forever". From 2.3.15 on this is controlled via a multiple * choice ("retain_type"). * So if we find a 0 retain_days value with a "days" retain_type, * we will silently and conservatively interpret is as meaning * retain forever ("forever" retain_type). */ if ( (gnc_prefs_get_file_retention_policy () == XML_RETAIN_DAYS) && (gnc_prefs_get_file_retention_days () == 0 ) ) { gnc_prefs_set_file_retention_policy (XML_RETAIN_ALL); gnc_prefs_set_file_retention_days (30); gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER, TRUE); gnc_prefs_set_float (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS, 30); PWARN("retain 0 days policy was set, but this is probably not what the user wanted,\n" "assuming conservative policy 'forever'"); } /* Add hooks to update core preferences whenever the associated preference changes */ gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS, file_retain_changed_cb, NULL); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_NEVER, file_retain_type_changed_cb, NULL); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_DAYS, file_retain_type_changed_cb, NULL); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER, file_retain_type_changed_cb, NULL); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION, file_compression_changed_cb, NULL); }
/** Initialize the registeru for a window. This function is * called as part of the initialization of a window, after all the * plugin menu items have been added to the menu structure. Its job * is to correctly initialize the register. It does this by * installing a function that listens for preference changes. Each * time a preference changes, it kicks off a gui refresh. * * @param plugin A pointer to the gnc-plugin object responsible for * adding/removing the register. * * @param window A pointer to the gnc-main-window that is being initialized. * * @param type Unused */ static void gnc_plugin_register_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL, gnc_plugin_register_pref_changed, window); g_signal_connect(window, "page_changed", G_CALLBACK(gnc_plugin_register_main_window_page_changed), plugin); }
/* Create a new GncPeriodSelect widget which is used to select a * accounting period like "previous month" or "this year". * * @param starting_labels If set to TRUE then all the labels will * refer to the "Start of...". If FALSE, labels will refer to "End * of...". * * @return A GncPeriodSelect widget. */ GtkWidget * gnc_period_select_new (gboolean starting_labels) { GncPeriodSelectPrivate *priv; GncPeriodSelect *period; const gchar *label; gint i; period = g_object_new(GNC_TYPE_PERIOD_SELECT, NULL); /* Set up private data structures */ priv = GNC_PERIOD_SELECT_GET_PRIVATE(period); priv->selector = gtk_combo_box_text_new(); priv->start = starting_labels; /* Add the internal widgets to the hbox */ gtk_box_pack_start(GTK_BOX(period), priv->selector, TRUE, TRUE, 0); gtk_widget_show(priv->selector); /* Find out when the combo box changes */ g_signal_connect(G_OBJECT(priv->selector), "changed", G_CALLBACK(gnc_period_sample_combobox_changed), period); /* Build all the labels except the fiscal year labels */ for (i = 0; i < GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i++) { label = starting_labels ? _(start_strings[i]) : _(end_strings[i]); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label); } /* Track changes to date formatting */ gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_FORMAT, gnc_period_sample_new_date_format, period); return GTK_WIDGET (period); }
static GtkWidget * gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page) { GncPluginPageInvoice *page; GncPluginPageInvoicePrivate *priv; GtkWidget *regWidget, *widget; GncMainWindow *window; ENTER("page %p", plugin_page); page = GNC_PLUGIN_PAGE_INVOICE (plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page); if (priv->widget != NULL) { LEAVE(""); return priv->widget; } priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE); // Set the style context for this page so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(priv->widget), "GncInvoicePage"); gtk_widget_show (priv->widget); widget = gnc_invoice_create_page(priv->iw, page); gtk_widget_show (widget); gtk_box_pack_start(GTK_BOX (priv->widget), widget, TRUE, TRUE, 0); plugin_page->summarybar = gnc_invoice_window_create_summary_bar(priv->iw); gtk_box_pack_start(GTK_BOX (priv->widget), plugin_page->summarybar, FALSE, FALSE, 0); gnc_plugin_page_invoice_summarybar_position_changed(NULL, NULL, page); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_TOP, gnc_plugin_page_invoice_summarybar_position_changed, page); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SUMMARYBAR_POSITION_BOTTOM, gnc_plugin_page_invoice_summarybar_position_changed, page); regWidget = gnc_invoice_get_register(priv->iw); if (regWidget) { g_signal_connect (G_OBJECT (regWidget), "redraw-help", G_CALLBACK (gnc_plugin_page_redraw_help_cb), page); } priv->component_manager_id = gnc_register_gui_component(GNC_PLUGIN_PAGE_INVOICE_NAME, gnc_plugin_page_invoice_refresh_cb, NULL, page); window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); g_signal_connect(window, "page_changed", G_CALLBACK(gnc_plugin_page_invoice_main_window_page_changed), plugin_page); LEAVE(""); return priv->widget; }