From 79e6da77da6c9189b264beb8a038e494041c653e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 13 Jun 2012 15:23:25 +0000 Subject: [PATCH] Bug #677859 - Depreciated functions in Gtk+2.24 GtkComboBox related fixes Patch by Robert Fewell git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22215 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../business-gnome/business-gnome-utils.c | 24 +- src/business/business-gnome/dialog-payment.c | 11 +- .../gtkbuilder/dialog-payment.glade | 30 +- src/gnome-utils/assistant-xml-encoding.c | 11 +- src/gnome-utils/dialog-commodity.c | 145 ++---- src/gnome-utils/dialog-commodity.h | 12 +- src/gnome-utils/dialog-file-access.c | 46 +- src/gnome-utils/dialog-options.c | 8 +- src/gnome-utils/gnc-account-sel.c | 10 +- src/gnome-utils/gnc-account-sel.h | 2 +- src/gnome-utils/gnc-currency-edit.c | 20 +- src/gnome-utils/gnc-currency-edit.h | 4 +- src/gnome-utils/gnc-date-delta.c | 18 +- src/gnome-utils/gnc-gtk-utils.c | 90 ++-- src/gnome-utils/gnc-gtk-utils.h | 8 +- src/gnome-utils/gnc-period-select.c | 12 +- .../gtkbuilder/dialog-commodity.glade | 482 ++++++++++-------- src/gnome/dialog-price-editor.c | 109 ++-- src/gnome/dialog-print-check.c | 11 +- src/gnome/gtkbuilder/dialog-price.glade | 158 ++++-- .../qif-import/assistant-qif-import.c | 48 +- .../report-gnome/dialog-report-style-sheet.c | 5 +- 22 files changed, 646 insertions(+), 618 deletions(-) diff --git a/src/business/business-gnome/business-gnome-utils.c b/src/business/business-gnome/business-gnome-utils.c index 5055b756c2..85fe81f0c0 100644 --- a/src/business/business-gnome/business-gnome-utils.c +++ b/src/business/business-gnome/business-gnome-utils.c @@ -316,15 +316,16 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, GList *acct_types, GList *acct_commodities) { GtkListStore *store; + GtkTreeIter iter; GList *list, *node; - char *text; + const gchar *text; - g_return_val_if_fail (combo && GTK_IS_COMBO_BOX_ENTRY(combo), NULL); + g_return_val_if_fail (combo && GTK_IS_COMBO_BOX(combo), NULL); g_return_val_if_fail (book, NULL); g_return_val_if_fail (acct_types, NULL); /* Figure out if anything is set in the combo */ - text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); + text = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(combo))))); g_object_set_data (G_OBJECT(combo), "book", book); list = gnc_account_get_descendants (gnc_book_get_root_account (book)); @@ -357,11 +358,12 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, } name = gnc_account_get_full_name (account); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), name); + gtk_list_store_append(store, &iter); + gtk_list_store_set (store, &iter, 0, name, -1); + /* Save the first account name in case no account name was set */ if (!text || g_strcmp0 (text, "") == 0) { - g_free (text); /* This is ok, even if text is already NULL */ text = g_strdup (name); } g_free(name); @@ -370,10 +372,7 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, g_list_free (list); - gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(combo), text); - - if (text) - g_free (text); + gnc_cbwe_set_by_string(GTK_COMBO_BOX(combo), text); return gnc_account_select_combo_get_active (combo); } @@ -381,17 +380,18 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, Account * gnc_account_select_combo_get_active (GtkWidget *combo) { - gchar *text; + const gchar *text; QofBook *book; - if (!combo || !GTK_IS_COMBO_BOX_ENTRY(combo)) + if (!combo || !GTK_IS_COMBO_BOX(combo)) return NULL; book = g_object_get_data (G_OBJECT(combo), "book"); if (!book) return NULL; - text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); + text = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(combo))))); + if (!text || g_strcmp0 (text, "") == 0) return NULL; diff --git a/src/business/business-gnome/dialog-payment.c b/src/business/business-gnome/dialog-payment.c index ef82db8a9c..4c0ad4bfb4 100644 --- a/src/business/business-gnome/dialog-payment.c +++ b/src/business/business-gnome/dialog-payment.c @@ -103,7 +103,7 @@ void gnc_ui_payment_window_set_postaccount (PaymentWindow *pw, const Account* ac g_assert(account); { gchar *acct_string = gnc_account_get_full_name (account); - gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(pw->post_combo), acct_string); + gnc_cbwe_set_by_string(GTK_COMBO_BOX(pw->post_combo), acct_string); g_free(acct_string); } } @@ -752,8 +752,8 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) pw->num_entry = GTK_WIDGET (gtk_builder_get_object (builder, "num_entry")); pw->memo_entry = GTK_WIDGET (gtk_builder_get_object (builder, "memo_entry")); pw->post_combo = GTK_WIDGET (gtk_builder_get_object (builder, "post_combo")); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( pw->post_combo ), 0 ); - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(pw->post_combo)); + gtk_combo_box_set_entry_text_column( GTK_COMBO_BOX( pw->post_combo ), 0 ); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(pw->post_combo)); label = GTK_WIDGET (gtk_builder_get_object (builder, "owner_label")); box = GTK_WIDGET (gtk_builder_get_object (builder, "owner_box")); @@ -792,7 +792,7 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) if (postacct) { gchar *acct_string = gnc_account_get_full_name (postacct); - gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(pw->post_combo), acct_string); + gnc_cbwe_set_by_string(GTK_COMBO_BOX(pw->post_combo), acct_string); gnc_payment_dialog_post_to_changed(pw); g_free(acct_string); } @@ -837,7 +837,8 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) const gchar *text; const char *acct_type; - text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(pw->post_combo)); + text = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(pw->post_combo))))); + if (!text || safe_strcmp (text, "") == 0) { diff --git a/src/business/business-gnome/gtkbuilder/dialog-payment.glade b/src/business/business-gnome/gtkbuilder/dialog-payment.glade index fb71d443f4..41469afb20 100644 --- a/src/business/business-gnome/gtkbuilder/dialog-payment.glade +++ b/src/business/business-gnome/gtkbuilder/dialog-payment.glade @@ -1,6 +1,6 @@ - + True False @@ -75,11 +75,19 @@ False 12 - + True False post_combo_model + True + 0 + + + False + True + + @@ -485,6 +493,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic gtk-cancel + False True True True @@ -502,6 +511,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic gtk-ok + False True True True @@ -551,22 +561,6 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - - - 01-01-2011 - 35006 - Invoice - 100,00 € - - - - 05-10-2011 - Test-VS3 - Credit Note - - 50,00 € - - 100 diff --git a/src/gnome-utils/assistant-xml-encoding.c b/src/gnome-utils/assistant-xml-encoding.c index c73e9aa8db..7d03042228 100644 --- a/src/gnome-utils/assistant-xml-encoding.c +++ b/src/gnome-utils/assistant-xml-encoding.c @@ -626,22 +626,21 @@ gxi_update_progress_bar (const gchar *message, double percentage) static void gxi_update_default_enc_combo (GncXmlImportData *data) { - GtkComboBox *combo; + GtkComboBoxText *combo; GList *enc_iter; /* add encodings list */ if (data->default_encoding_combo) gtk_widget_destroy (data->default_encoding_combo); - data->default_encoding_combo = gtk_combo_box_new_text (); - combo = GTK_COMBO_BOX (data->default_encoding_combo); + data->default_encoding_combo = gtk_combo_box_text_new(); + combo = GTK_COMBO_BOX_TEXT (data->default_encoding_combo); for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next) { - gtk_combo_box_append_text ( + gtk_combo_box_text_append_text ( combo, g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data))); } - gtk_combo_box_set_active ( - combo, + gtk_combo_box_set_active (GTK_COMBO_BOX(combo), g_list_index (data->encodings, GUINT_TO_POINTER (data->default_encoding))); /* show encodings */ diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c index 1d6cdfa94b..272a7ec5bc 100644 --- a/src/gnome-utils/dialog-commodity.c +++ b/src/gnome-utils/dialog-commodity.c @@ -112,9 +112,9 @@ gnc_ui_select_commodity_create(const gnc_commodity * orig_sel, dialog_commodity_mode mode); void gnc_ui_select_commodity_new_cb(GtkButton * button, gpointer user_data); -void gnc_ui_select_commodity_changed_cb(GtkComboBoxEntry *cbe, +void gnc_ui_select_commodity_changed_cb(GtkComboBox *cbwe, gpointer user_data); -void gnc_ui_select_commodity_namespace_changed_cb(GtkComboBoxEntry *cbe, +void gnc_ui_select_commodity_namespace_changed_cb(GtkComboBox *cbwe, gpointer user_data); /* The commodity creation window */ @@ -249,55 +249,21 @@ gnc_ui_select_commodity_create(const gnc_commodity * orig_sel, GtkWidget *button, *label; builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "dialog-commodity.glade", "liststore1"); + gnc_builder_add_from_file (builder, "dialog-commodity.glade", "liststore2"); gnc_builder_add_from_file (builder, "dialog-commodity.glade", "Security Selector Dialog"); gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, retval); retval->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Security Selector Dialog")); - retval->namespace_combo = GTK_WIDGET(gtk_builder_get_object (builder, "ss_namespace_cbe")); - retval->commodity_combo = GTK_WIDGET(gtk_builder_get_object (builder, "ss_commodity_cbe")); + retval->namespace_combo = GTK_WIDGET(gtk_builder_get_object (builder, "ss_namespace_cbwe")); + retval->commodity_combo = GTK_WIDGET(gtk_builder_get_object (builder, "ss_commodity_cbwe")); retval->select_user_prompt = GTK_WIDGET(gtk_builder_get_object (builder, "select_user_prompt")); retval->ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "ss_ok_button")); label = GTK_WIDGET(gtk_builder_get_object (builder, "item_label")); - /* namespace List Store - create here as we get an error if created in builder */ - { - GtkListStore *store; - GtkTreeIter iter; - gchar string[] = "Dummy namespace Line"; - - store = gtk_list_store_new( 1, G_TYPE_STRING ); - - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, 0, string, -1 ); - - gtk_combo_box_set_model( GTK_COMBO_BOX( retval->namespace_combo ), - GTK_TREE_MODEL( store ) ); - g_object_unref( G_OBJECT( store ) ); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( retval->namespace_combo ), 0 ); - } - - /* commodity List Store - create here as we get an error if created in builder */ - { - GtkListStore *store; - GtkTreeIter iter; - gchar string[] = "Dummy commodity Line"; - - store = gtk_list_store_new( 1, G_TYPE_STRING ); - - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, 0, string, -1 ); - - gtk_combo_box_set_model( GTK_COMBO_BOX( retval->commodity_combo ), - GTK_TREE_MODEL( store ) ); - g_object_unref( G_OBJECT( store ) ); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( retval->commodity_combo ), 0 ); - } - - gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0); - gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->commodity_combo), 0); - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->namespace_combo)); - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(retval->commodity_combo)); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(retval->namespace_combo)); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(retval->commodity_combo)); gtk_label_set_text (GTK_LABEL (retval->select_user_prompt), ""); @@ -395,27 +361,28 @@ gnc_ui_select_commodity_new_cb(GtkButton * button, * Commodity Selection dialog. It should not be used outside of the * dialog-commodity.c file. * - * @param cbe A pointer to the commodity name entry widget in the + * @param cbwe A pointer to the commodity name entry widget in the * dialog. * * @param user_data A pointer to the data structure describing the * current state of the commodity picker. */ void -gnc_ui_select_commodity_changed_cb (GtkComboBoxEntry *cbe, +gnc_ui_select_commodity_changed_cb (GtkComboBox *cbwe, gpointer user_data) { SelectCommodityWindow * w = user_data; - gchar *namespace, *fullname; + gchar *namespace; + const gchar *fullname; gboolean ok; - ENTER("cbe=%p, user_data=%p", cbe, user_data); + ENTER("cbwe=%p, user_data=%p", cbwe, user_data); namespace = gnc_ui_namespace_picker_ns (w->namespace_combo); - fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(w->commodity_combo)); + fullname = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(w->commodity_combo))))); + DEBUG("namespace=%s, name=%s", namespace, fullname); w->selection = gnc_commodity_table_find_full(gnc_get_current_commodities(), namespace, fullname); - g_free(fullname); g_free(namespace); ok = (w->selection != NULL); @@ -435,20 +402,20 @@ gnc_ui_select_commodity_changed_cb (GtkComboBoxEntry *cbe, * Commodity Selection dialog. It should not be used outside of the * dialog-commodity.c file. * - * @param cbe A pointer to the commodity namespace entry widget in + * @param cbwe A pointer to the commodity namespace entry widget in * the dialog. * * @param user_data A pointer to the data structure describing the * current state of the commodity picker. */ void -gnc_ui_select_commodity_namespace_changed_cb (GtkComboBoxEntry *cbe, +gnc_ui_select_commodity_namespace_changed_cb (GtkComboBox *cbwe, gpointer user_data) { SelectCommodityWindow * w = user_data; gchar *namespace; - ENTER("cbe=%p, user_data=%p", cbe, user_data); + ENTER("cbwe=%p, user_data=%p", cbwe, user_data); namespace = gnc_ui_namespace_picker_ns (w->namespace_combo); DEBUG("namespace=%s", namespace); gnc_ui_update_commodity_picker(w->commodity_combo, namespace, NULL); @@ -472,7 +439,7 @@ collate(gconstpointer a, gconstpointer b) void -gnc_ui_update_commodity_picker (GtkWidget *cbe, +gnc_ui_update_commodity_picker (GtkWidget *cbwe, const gchar * namespace, const gchar * init_string) { @@ -482,15 +449,16 @@ gnc_ui_update_commodity_picker (GtkWidget *cbe, GtkComboBox *combo_box; GtkEntry *entry; GtkTreeModel *model; + GtkTreeIter iter; gnc_commodity_table *table; gint current = 0, match = 0; gchar *name; - g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY(cbe)); + g_return_if_fail(GTK_IS_COMBO_BOX(cbwe)); g_return_if_fail(namespace); /* Erase the old entries */ - combo_box = GTK_COMBO_BOX(cbe); + combo_box = GTK_COMBO_BOX(cbwe); model = gtk_combo_box_get_model(combo_box); gtk_list_store_clear(GTK_LIST_STORE(model)); @@ -514,7 +482,9 @@ gnc_ui_update_commodity_picker (GtkWidget *cbe, for (iterator = commodity_items; iterator; iterator = iterator->next) { name = (char *)iterator->data; - gtk_combo_box_append_text(combo_box, name); + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, name, -1); + if (init_string && g_utf8_collate(name, init_string) == 0) match = current; current++; @@ -663,19 +633,20 @@ gnc_ui_update_fq_info (CommodityWindow *cw) * gnc_ui_update_namespace_picker ********************************************************************/ void -gnc_ui_update_namespace_picker (GtkWidget *cbe, +gnc_ui_update_namespace_picker (GtkWidget *cbwe, const char * init_string, dialog_commodity_mode mode) { GtkComboBox *combo_box; GtkTreeModel *model; + GtkTreeIter iter; GList *namespaces, *node; gint current = 0, match = 0; - g_return_if_fail(GTK_IS_COMBO_BOX_ENTRY (cbe)); + g_return_if_fail(GTK_IS_COMBO_BOX (cbwe)); /* Erase the old entries */ - combo_box = GTK_COMBO_BOX(cbe); + combo_box = GTK_COMBO_BOX(cbwe); model = gtk_combo_box_get_model(combo_box); gtk_list_store_clear(GTK_LIST_STORE(model)); gtk_combo_box_set_active(combo_box, -1); @@ -708,7 +679,7 @@ gnc_ui_update_namespace_picker (GtkWidget *cbe, break; } - /* stick them in the combobox */ + /* add them to the combobox */ namespaces = g_list_sort(namespaces, collate); for (node = namespaces; node; node = node->next) { @@ -716,7 +687,11 @@ gnc_ui_update_namespace_picker (GtkWidget *cbe, continue; /* Hide the template entry */ if (g_utf8_collate(node->data, "template" ) != 0) - gtk_combo_box_append_text(combo_box, node->data); + { + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, node->data, -1); + } + if (init_string && (g_utf8_collate(node->data, init_string) == 0)) match = current; current++; @@ -728,22 +703,21 @@ gnc_ui_update_namespace_picker (GtkWidget *cbe, gchar * -gnc_ui_namespace_picker_ns (GtkWidget *cbe) +gnc_ui_namespace_picker_ns (GtkWidget *cbwe) { - gchar *namespace; + const gchar *namespace; - g_return_val_if_fail(GTK_IS_COMBO_BOX_ENTRY (cbe), NULL); + g_return_val_if_fail(GTK_IS_COMBO_BOX (cbwe), NULL); - namespace = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbe)); + namespace = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(cbwe))))); if (safe_strcmp (namespace, GNC_COMMODITY_NS_ISO) == 0) { /* In case the user types in ISO4217, map it to CURRENCY. */ - g_free(namespace); return g_strdup(GNC_COMMODITY_NS_CURRENCY); } else - return namespace; + return g_strdup(namespace); } @@ -755,15 +729,16 @@ gnc_ui_commodity_quote_info_cb (GtkWidget *w, gpointer data) { CommodityWindow *cw = data; gboolean get_quote, allow_src, active; - gchar *text; + const gchar *text; gint i; ENTER(" "); get_quote = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)); - text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cw->namespace_combo)); + text = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(cw->namespace_combo))))); + allow_src = !gnc_commodity_namespace_is_iso(text); - g_free(text); + gtk_widget_set_sensitive(cw->source_label, get_quote && allow_src); for (i = SOURCE_SINGLE; i < SOURCE_MAX; i++) @@ -929,11 +904,11 @@ gnc_ui_quote_tz_menu_create(void) order to be portable to non GNU OSes, we may have to support whatever we add here manually on those systems. */ - combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Use local time")); + combo = gtk_combo_box_text_new(); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), _("Use local time")); for (itemstr = &known_timezones[0]; *itemstr; itemstr++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), *itemstr); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), *itemstr); } gtk_widget_show(combo); @@ -967,6 +942,7 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace, parent, selected_namespace, fullname, mnemonic); builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "dialog-commodity.glade", "liststore2"); gnc_builder_add_from_file (builder, "dialog-commodity.glade", "adjustment1"); gnc_builder_add_from_file (builder, "dialog-commodity.glade", "Security Dialog"); @@ -993,10 +969,9 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace, /* Get widget pointers */ retval->fullname_entry = GTK_WIDGET(gtk_builder_get_object (builder, "fullname_entry")); retval->mnemonic_entry = GTK_WIDGET(gtk_builder_get_object (builder, "mnemonic_entry")); - retval->namespace_combo = GTK_WIDGET(gtk_builder_get_object (builder, "namespace_cbe")); + retval->namespace_combo = GTK_WIDGET(gtk_builder_get_object (builder, "namespace_cbwe")); retval->code_entry = GTK_WIDGET(gtk_builder_get_object (builder, "code_entry")); - retval->fraction_spinbutton = GTK_WIDGET(gtk_builder_get_object (builder, - "fraction_spinbutton")); + retval->fraction_spinbutton = GTK_WIDGET(gtk_builder_get_object (builder, "fraction_spinbutton")); retval->ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "ok_button")); retval->get_quote_check = GTK_WIDGET(gtk_builder_get_object (builder, "get_quote_check")); retval->source_label = GTK_WIDGET(gtk_builder_get_object (builder, "source_label")); @@ -1004,23 +979,6 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace, retval->source_button[SOURCE_MULTI] = GTK_WIDGET(gtk_builder_get_object (builder, "multi_source_button")); retval->quote_tz_label = GTK_WIDGET(gtk_builder_get_object (builder, "quote_tz_label")); - /* namespace List Store - create here as we get an error if created in builder */ - { - GtkListStore *store; - GtkTreeIter iter; - gchar string[] = "Dummy namespace Line"; - - store = gtk_list_store_new( 1, G_TYPE_STRING ); - - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, 0, string, -1 ); - - gtk_combo_box_set_model( GTK_COMBO_BOX( retval->namespace_combo ), - GTK_TREE_MODEL( store ) ); - g_object_unref( G_OBJECT( store ) ); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( retval->namespace_combo ), 0 ); - } - /* Build custom widgets */ box = GTK_WIDGET(gtk_builder_get_object (builder, "single_source_box")); if (gnc_commodity_namespace_is_iso(selected_namespace)) @@ -1108,8 +1066,7 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace, /* Fill in any data, top to bottom */ gtk_entry_set_text (GTK_ENTRY (retval->fullname_entry), fullname ? fullname : ""); gtk_entry_set_text (GTK_ENTRY (retval->mnemonic_entry), mnemonic ? mnemonic : ""); - gnc_cbe_add_completion(GTK_COMBO_BOX_ENTRY(retval->namespace_combo)); - gtk_combo_box_remove_text(GTK_COMBO_BOX(retval->namespace_combo), 0); + gnc_cbwe_add_completion(GTK_COMBO_BOX(retval->namespace_combo)); gnc_ui_update_namespace_picker(retval->namespace_combo, selected_namespace, include_iso ? DIAG_COMM_ALL : DIAG_COMM_NON_CURRENCY); diff --git a/src/gnome-utils/dialog-commodity.h b/src/gnome-utils/dialog-commodity.h index 29f6d73361..67e459cdd9 100644 --- a/src/gnome-utils/dialog-commodity.h +++ b/src/gnome-utils/dialog-commodity.h @@ -212,7 +212,7 @@ gnc_ui_edit_commodity_modal(gnc_commodity *commodity, /** Given a combo box, fill in the known commodity namespaces and then * select one. * - * @param cbe The widget to populate with information. + * @param cbwe The widget to populate with information. * * @param sel The namespace that should be initially selected when * the combo box appears. @@ -224,25 +224,25 @@ gnc_ui_edit_commodity_modal(gnc_commodity *commodity, * * @note The returned string must be freed by the caller. */ -void gnc_ui_update_namespace_picker(GtkWidget *cbe, +void gnc_ui_update_namespace_picker(GtkWidget *cbwe, const gchar *sel, dialog_commodity_mode mode); /** Given a combo box, return the currently selected namespaces. * - * @param cbe The combo box of namespaces. + * @param cbwe The combo box of namespaces. * * @return The currently selected namespace. * * @note This string is owned by the engine and must not be freed by * the caller. */ -gchar *gnc_ui_namespace_picker_ns (GtkWidget *cbe); +gchar *gnc_ui_namespace_picker_ns (GtkWidget *cbwe); /** Given a combo box, fill in all the known commodities for the * specified namespace, and then select one. * - * @param cbe The widget to populate with information. + * @param cbwe The widget to populate with information. * * @param namespace All commodities with this namespace will be added * to the combo box. @@ -250,7 +250,7 @@ gchar *gnc_ui_namespace_picker_ns (GtkWidget *cbe); * @param sel The commodity that should be initially selected when * the combo box appears. */ -void gnc_ui_update_commodity_picker(GtkWidget *cbe, +void gnc_ui_update_commodity_picker(GtkWidget *cbwe, const gchar *namespace, const gchar *sel); /** @} */ diff --git a/src/gnome-utils/dialog-file-access.c b/src/gnome-utils/dialog-file-access.c index 7c0e7a8026..c2a481f7ba 100644 --- a/src/gnome-utils/dialog-file-access.c +++ b/src/gnome-utils/dialog-file-access.c @@ -49,23 +49,23 @@ typedef struct FileAccessWindow /* Parts of the dialog */ int type; - GtkWidget* dialog; - GtkWidget* frame_file; - GtkWidget* frame_database; - GtkWidget* readonly_checkbutton; - GtkFileChooser* fileChooser; - gchar *starting_dir; - GtkComboBox* cb_uri_type; - GtkEntry* tf_host; - GtkEntry* tf_database; - GtkEntry* tf_username; - GtkEntry* tf_password; + GtkWidget *dialog; + GtkWidget *frame_file; + GtkWidget *frame_database; + GtkWidget *readonly_checkbutton; + GtkFileChooser *fileChooser; + gchar *starting_dir; + GtkComboBoxText *cb_uri_type; + GtkEntry *tf_host; + GtkEntry *tf_database; + GtkEntry *tf_username; + GtkEntry *tf_password; } FileAccessWindow; void gnc_ui_file_access_file_activated_cb( GtkFileChooser *chooser, FileAccessWindow *faw ); void gnc_ui_file_access_response_cb( GtkDialog *, gint, GtkDialog * ); -static void cb_uri_type_changed_cb( GtkComboBox* cb ); +static void cb_uri_type_changed_cb( GtkComboBoxText* cb ); static gchar* geturl( FileAccessWindow* faw ) @@ -85,7 +85,7 @@ geturl( FileAccessWindow* faw ) password = gtk_entry_get_text( faw->tf_password ); file = gtk_file_chooser_get_filename( faw->fileChooser ); - type = gtk_combo_box_get_active_text( faw->cb_uri_type ); + type = gtk_combo_box_text_get_active_text(faw->cb_uri_type ); if ( gnc_uri_is_file_protocol( type ) ) { if ( file == NULL ) /* file protocol was chosen but no filename was set */ @@ -208,7 +208,7 @@ set_widget_sensitivity_for_uri_type( FileAccessWindow* faw, const gchar* uri_typ } static void -cb_uri_type_changed_cb( GtkComboBox* cb ) +cb_uri_type_changed_cb( GtkComboBoxText* cb ) { GtkWidget* dialog; FileAccessWindow* faw; @@ -221,7 +221,7 @@ cb_uri_type_changed_cb( GtkComboBox* cb ) faw = g_object_get_data( G_OBJECT(dialog), "FileAccessWindow" ); g_return_if_fail( faw != NULL ); - type = gtk_combo_box_get_active_text( cb ); + type = gtk_combo_box_text_get_active_text( cb ); set_widget_sensitivity_for_uri_type( faw, type ); } @@ -348,7 +348,7 @@ gnc_ui_file_access( int type ) gnc_ui_file_access_file_activated_cb, faw, NULL ); uri_type_container = GTK_WIDGET(gtk_builder_get_object (builder, "vb_uri_type_container" )); - faw->cb_uri_type = GTK_COMBO_BOX(gtk_combo_box_new_text()); + faw->cb_uri_type = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()); gtk_container_add( GTK_CONTAINER(uri_type_container), GTK_WIDGET(faw->cb_uri_type) ); gtk_box_set_child_packing( GTK_BOX(uri_type_container), GTK_WIDGET(faw->cb_uri_type), /*expand*/TRUE, /*fill*/FALSE, /*padding*/0, GTK_PACK_START ); @@ -406,27 +406,27 @@ gnc_ui_file_access( int type ) access_method_index = -1; if ( need_access_method_file ) { - gtk_combo_box_append_text( faw->cb_uri_type, "file" ); + gtk_combo_box_text_append_text( faw->cb_uri_type, "file" ); active_access_method_index = ++access_method_index; } if ( need_access_method_mysql ) { - gtk_combo_box_append_text( faw->cb_uri_type, "mysql" ); + gtk_combo_box_text_append_text( faw->cb_uri_type, "mysql" ); ++access_method_index; } if ( need_access_method_postgres ) { - gtk_combo_box_append_text( faw->cb_uri_type, "postgres" ); + gtk_combo_box_text_append_text( faw->cb_uri_type, "postgres" ); ++access_method_index; } if ( need_access_method_sqlite3 ) { - gtk_combo_box_append_text( faw->cb_uri_type, "sqlite3" ); + gtk_combo_box_text_append_text( faw->cb_uri_type, "sqlite3" ); active_access_method_index = ++access_method_index; } if ( need_access_method_xml ) { - gtk_combo_box_append_text( faw->cb_uri_type, "xml" ); + gtk_combo_box_text_append_text( faw->cb_uri_type, "xml" ); ++access_method_index; // Set XML as default if it is offered (which mean we are in @@ -442,8 +442,8 @@ gnc_ui_file_access( int type ) /* Hide the frame that's not required for the active access method so either only * the File or only the Database frame are presented. */ - gtk_combo_box_set_active( faw->cb_uri_type, active_access_method_index ); - set_widget_sensitivity_for_uri_type( faw, gtk_combo_box_get_active_text( faw->cb_uri_type ) ); + gtk_combo_box_set_active(GTK_COMBO_BOX(faw->cb_uri_type), active_access_method_index ); + set_widget_sensitivity_for_uri_type( faw, gtk_combo_box_text_get_active_text( faw->cb_uri_type )); } void diff --git a/src/gnome-utils/dialog-options.c b/src/gnome-utils/dialog-options.c index 99d80aedb1..6d30fac017 100644 --- a/src/gnome-utils/dialog-options.c +++ b/src/gnome-utils/dialog-options.c @@ -538,11 +538,11 @@ gnc_option_create_date_widget (GNCOption *option) * see http://bugzilla.gnome.org/show_bug.cgi?id=303717 , see * also gnc_option_create_multichoice_widget() below. */ char *string; - rel_widget = gtk_combo_box_new_text(); + rel_widget = gtk_combo_box_text_new(); for (i = 0; i < num_values; i++) { string = gnc_option_permissible_value_name(option, i); - gtk_combo_box_append_text(GTK_COMBO_BOX(rel_widget), string); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(rel_widget), string); g_free(string); } @@ -712,12 +712,12 @@ gnc_option_create_multichoice_widget(GNCOption *option) see http://bugzilla.gnome.org/show_bug.cgi?id=303717 */ char *itemstring; /* char *description; */ - widget = gtk_combo_box_new_text(); + widget = gtk_combo_box_text_new(); for (i = 0; i < num_values; i++) { itemstring = gnc_option_permissible_value_name(option, i); /* description = gnc_option_permissible_value_description(option, i); */ - gtk_combo_box_append_text(GTK_COMBO_BOX(widget), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), (itemstring && *itemstring) ? _(itemstring) : ""); /*, (description && *description) ? _(description) : "" */ /* Maybe the per-item tooltip will simply be added as such an diff --git a/src/gnome-utils/gnc-account-sel.c b/src/gnome-utils/gnc-account-sel.c index 76a59c7235..9236ccc9a0 100644 --- a/src/gnome-utils/gnc-account-sel.c +++ b/src/gnome-utils/gnc-account-sel.c @@ -155,18 +155,16 @@ gnc_account_sel_init (GNCAccountSel *gas) g_object_set(gas, "spacing", 2, (gchar*)NULL); gas->store = gtk_list_store_new(NUM_ACCT_COLS, G_TYPE_STRING, G_TYPE_POINTER); - widget = - gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(gas->store), ACCT_COL_NAME); - gas->combo = GTK_COMBO_BOX_ENTRY(widget); - gtk_combo_box_set_model(GTK_COMBO_BOX(widget), - GTK_TREE_MODEL(gas->store)); + widget = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(gas->store)); + gas->combo = GTK_COMBO_BOX(widget); + gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(widget), ACCT_COL_NAME); g_object_unref(gas->store); g_signal_connect_swapped(gas->combo, "changed", G_CALLBACK(combo_changed_cb), gas); gtk_container_add( GTK_CONTAINER(gas), widget ); /* Add completion. */ - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(widget)); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(widget)); /* Get the accounts, place into combo list */ gas_populate_list( gas ); diff --git a/src/gnome-utils/gnc-account-sel.h b/src/gnome-utils/gnc-account-sel.h index a8b66020b1..04e937e205 100644 --- a/src/gnome-utils/gnc-account-sel.h +++ b/src/gnome-utils/gnc-account-sel.h @@ -44,7 +44,7 @@ typedef struct gboolean initDone; gboolean isModal; GtkListStore *store; - GtkComboBoxEntry *combo; + GtkComboBox *combo; GList *acctTypeFilters; GList *acctCommodityFilters; gint eventHandlerId; diff --git a/src/gnome-utils/gnc-currency-edit.c b/src/gnome-utils/gnc-currency-edit.c index 9495dfd6dd..ef74837345 100644 --- a/src/gnome-utils/gnc-currency-edit.c +++ b/src/gnome-utils/gnc-currency-edit.c @@ -107,7 +107,7 @@ gnc_currency_edit_get_type (void) NULL }; - currency_edit_type = g_type_register_static (GTK_TYPE_COMBO_BOX_ENTRY, + currency_edit_type = g_type_register_static (GTK_TYPE_COMBO_BOX, "GNCCurrencyEdit", ¤cy_edit_info, 0); } @@ -157,10 +157,17 @@ gnc_currency_edit_init (GNCCurrencyEdit *gce) static void add_item(gnc_commodity *commodity, GNCCurrencyEdit *gce) { + GtkTreeModel *model; + GtkTreeIter iter; const char *string; + model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce)); + string = gnc_commodity_get_printname(commodity); - gtk_combo_box_append_text(GTK_COMBO_BOX(gce), string); + + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, string, -1); + } @@ -198,13 +205,16 @@ gnc_currency_edit_new (void) store = gtk_list_store_new (1, G_TYPE_STRING); gce = g_object_new (GNC_TYPE_CURRENCY_EDIT, "model", store, - "text-column", 0, + "has-entry", TRUE, NULL); g_object_unref (store); + /* Set the column for the text */ + gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(gce), 0); + /* Now the signals to make sure the user can't leave the widget without a valid currency. */ - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(gce)); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(gce)); /* Fill in all the data. */ fill_currencies (gce); @@ -237,7 +247,7 @@ gnc_currency_edit_set_currency (GNCCurrencyEdit *gce, g_return_if_fail(currency != NULL); printname = gnc_commodity_get_printname(currency); - gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(gce), printname); + gnc_cbwe_set_by_string(GTK_COMBO_BOX(gce), printname); } diff --git a/src/gnome-utils/gnc-currency-edit.h b/src/gnome-utils/gnc-currency-edit.h index 347157262b..a8c1e1cd8f 100644 --- a/src/gnome-utils/gnc-currency-edit.h +++ b/src/gnome-utils/gnc-currency-edit.h @@ -67,12 +67,12 @@ typedef struct { - GtkComboBoxEntry combobox; + GtkComboBox combobox; } GNCCurrencyEdit; typedef struct { - GtkComboBoxEntryClass combobox; + GtkComboBoxClass combobox; } GNCCurrencyEditClass; /** Return the GType for the GNCCurrencyEdit currency selection widget. diff --git a/src/gnome-utils/gnc-date-delta.c b/src/gnome-utils/gnc-date-delta.c index cf1030ec5c..882fc2a627 100644 --- a/src/gnome-utils/gnc-date-delta.c +++ b/src/gnome-utils/gnc-date-delta.c @@ -70,7 +70,7 @@ static GtkHBoxClass *parent_class; /** * gnc_date_delta_get_type: * - * Returns the GtkType for the GNCDateDelta widget + * Returns the GType for the GNCDateDelta widget */ GType gnc_date_delta_get_type (void) @@ -212,13 +212,13 @@ set_units (GtkComboBox *combo, GNCDateDelta *gdd) static void fill_units_combo(GNCDateDelta *gdd) { - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->units_combo), _("Days")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->units_combo), _("Weeks")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->units_combo), _("Months")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->units_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->units_combo), _("Years")); g_signal_connect (gdd->units_combo, "changed", @@ -242,9 +242,9 @@ set_polarity (GtkComboBox *combo, GNCDateDelta *gdd) static void fill_polarity_combo(GNCDateDelta *gdd) { - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->polarity_combo), _("Ago")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gdd->polarity_combo), + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gdd->polarity_combo), _("From Now")); g_signal_connect (gdd->polarity_combo, "changed", @@ -265,13 +265,13 @@ create_children (GNCDateDelta *gdd) g_signal_connect(gdd->value_spin, "changed", G_CALLBACK(value_changed), gdd); - gdd->units_combo = gtk_combo_box_new_text(); + gdd->units_combo = gtk_combo_box_text_new(); fill_units_combo(gdd); gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->units_combo), 0); gtk_box_pack_start(GTK_BOX(gdd), gdd->units_combo, FALSE, FALSE, 0); gtk_widget_show(gdd->units_combo); - gdd->polarity_combo = gtk_combo_box_new_text(); + gdd->polarity_combo = gtk_combo_box_text_new(); fill_polarity_combo(gdd); gtk_combo_box_set_active(GTK_COMBO_BOX(gdd->polarity_combo), 0); gtk_box_pack_start(GTK_BOX(gdd), gdd->polarity_combo, FALSE, FALSE, 0); diff --git a/src/gnome-utils/gnc-gtk-utils.c b/src/gnome-utils/gnc-gtk-utils.c index 1d0f55313a..4dc971e022 100644 --- a/src/gnome-utils/gnc-gtk-utils.c +++ b/src/gnome-utils/gnc-gtk-utils.c @@ -29,16 +29,16 @@ #define CHANGED_ID "changed_id" -/** Find an entry in the GtkComboBoxEntry by its text value, and set +/** Find an entry in the GtkComboBox by its text value, and set * the widget to that value. This function also records the index of * that text value for use when the user leaves the widget. * - * @param cbe A pointer to a GtkComboBoxEntry widget. + * @param cbwe A pointer to a GtkComboBox with entry widget. * * @param text The entry text to find in the model of the combo box * entry. */ void -gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, +gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text) { GtkTreeModel *model; @@ -47,15 +47,15 @@ gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, gint column, index, id; gboolean match; - model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe)); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbwe)); if (!gtk_tree_model_get_iter_first(model, &iter)) { /* empty tree */ - gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), -1); + gtk_combo_box_set_active(GTK_COMBO_BOX(cbwe), -1); return; } - column = gtk_combo_box_entry_get_text_column(cbe); + column = gtk_combo_box_get_entry_text_column(cbwe); do { gtk_tree_model_get(model, &iter, column, &tree_string, -1); @@ -65,36 +65,36 @@ gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, continue; /* Found a matching string */ - id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbe), CHANGED_ID)); - g_signal_handler_block(cbe, id); - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cbe), &iter); - g_signal_handler_unblock(cbe, id); + id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbwe), CHANGED_ID)); + g_signal_handler_block(cbwe, id); + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cbwe), &iter); + g_signal_handler_unblock(cbwe, id); - index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbe)); - g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index)); + index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbwe)); + g_object_set_data(G_OBJECT(cbwe), LAST_INDEX, GINT_TO_POINTER(index)); return; } while (gtk_tree_model_iter_next(model, &iter)); } -/** The GtkComboBoxEntry widget has changed its value. If the widget +/** The GtkComboBox with entry widget has changed its value. If the widget * now points to another valid entry string then record the index of * that string for use when the user leaves the widget. * * @param widget Unused. * - * @param cbe A pointer to a GtkComboBoxEntry widget. */ + * @param cbwe A pointer to a GtkComboBox widget. */ static void -gnc_cbe_changed_cb (GtkComboBox *widget, - GtkComboBoxEntry *cbe) +gnc_cbwe_changed_cb (GtkComboBox *widget, + GtkComboBox *cbwe) { gint index; index = gtk_combo_box_get_active(widget); if (index == -1) return; - g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index)); + g_object_set_data(G_OBJECT(cbwe), LAST_INDEX, GINT_TO_POINTER(index)); } @@ -113,19 +113,19 @@ gnc_cbe_changed_cb (GtkComboBox *widget, * @param comp_iter The iter in the completion's temporary model * that represents the user selected match. * - * @param cbe A pointer to a currency entry widget. */ + * @param cbwe A pointer to a currency entry widget. */ static gboolean -gnc_cbe_match_selected_cb (GtkEntryCompletion *completion, - GtkTreeModel *comp_model, - GtkTreeIter *comp_iter, - GtkComboBoxEntry *cbe) +gnc_cbwe_match_selected_cb (GtkEntryCompletion *completion, + GtkTreeModel *comp_model, + GtkTreeIter *comp_iter, + GtkComboBox *cbwe) { gint column; gchar *text; - column = gtk_combo_box_entry_get_text_column(cbe); + column = gtk_combo_box_get_entry_text_column(cbwe); gtk_tree_model_get(comp_model, comp_iter, column, &text, -1); - gnc_cbe_set_by_string(cbe, text); + gnc_cbwe_set_by_string(cbwe, text); g_free(text); return FALSE; } @@ -142,40 +142,40 @@ gnc_cbe_match_selected_cb (GtkEntryCompletion *completion, * * @param event Unused. * - * @param cbe A pointer to a currency entry widget. */ + * @param cbwe A pointer to a currency entry widget. */ static gboolean -gnc_cbe_focus_out_cb (GtkEntry *entry, - GdkEventFocus *event, - GtkComboBoxEntry *cbe) +gnc_cbwe_focus_out_cb (GtkEntry *entry, + GdkEventFocus *event, + GtkComboBox *cbwe) { const gchar *text; gint index; /* Make a final attempt to match the current text. */ text = gtk_entry_get_text(entry); - gnc_cbe_set_by_string(cbe, text); + gnc_cbwe_set_by_string(cbwe, text); /* Get the last known index (which may have just been set). */ - index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbe), LAST_INDEX)); - gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), index); + index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cbwe), LAST_INDEX)); + gtk_combo_box_set_active(GTK_COMBO_BOX(cbwe), index); return FALSE; } void -gnc_cbe_add_completion (GtkComboBoxEntry *cbe) +gnc_cbwe_add_completion (GtkComboBox *cbwe) { GtkEntry *entry; GtkEntryCompletion *completion; GtkTreeModel *model; - entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe))); + entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbwe))); completion = gtk_entry_get_completion(entry); if (completion) return; /* No completion yet? Set one up. */ completion = gtk_entry_completion_new(); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe)); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbwe)); gtk_entry_completion_set_model(completion, model); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); @@ -184,7 +184,7 @@ gnc_cbe_add_completion (GtkComboBoxEntry *cbe) } void -gnc_cbe_require_list_item (GtkComboBoxEntry *cbe) +gnc_cbwe_require_list_item (GtkComboBox *cbwe) { GtkEntry *entry; GtkEntryCompletion *completion; @@ -193,33 +193,33 @@ gnc_cbe_require_list_item (GtkComboBoxEntry *cbe) gint index, id; /* Ensure completion is set up. */ - gnc_cbe_add_completion(cbe); + gnc_cbwe_add_completion(cbwe); /* If an item in the combo box isn't already selected, then force * select the first item. Take care, the combo box may not have been * filled yet. */ - entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe))); + entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbwe))); completion = gtk_entry_get_completion(entry); - index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbe)); + index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbwe)); if (index == -1) { model = gtk_entry_completion_get_model(completion); if (gtk_tree_model_get_iter_first(model, &iter)) { - gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(cbwe), 0); index = 0; } } - g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index)); + g_object_set_data(G_OBJECT(cbwe), LAST_INDEX, GINT_TO_POINTER(index)); /* Now the signals to make sure the user can't leave the widget without a valid match. */ - id = g_signal_connect(cbe, "changed", - G_CALLBACK(gnc_cbe_changed_cb), cbe); + id = g_signal_connect(cbwe, "changed", + G_CALLBACK(gnc_cbwe_changed_cb), cbwe); g_signal_connect(completion, "match_selected", - G_CALLBACK(gnc_cbe_match_selected_cb), cbe); + G_CALLBACK(gnc_cbwe_match_selected_cb), cbwe); g_signal_connect(entry, "focus-out-event", - G_CALLBACK(gnc_cbe_focus_out_cb), cbe); + G_CALLBACK(gnc_cbwe_focus_out_cb), cbwe); - g_object_set_data(G_OBJECT(cbe), CHANGED_ID, GINT_TO_POINTER(id)); + g_object_set_data(G_OBJECT(cbwe), CHANGED_ID, GINT_TO_POINTER(id)); } diff --git a/src/gnome-utils/gnc-gtk-utils.h b/src/gnome-utils/gnc-gtk-utils.h index 33c5b5798e..d2b0a1a557 100644 --- a/src/gnome-utils/gnc-gtk-utils.h +++ b/src/gnome-utils/gnc-gtk-utils.h @@ -1,5 +1,5 @@ /********************************************************************\ - * gnc-gtk-utils.c -- utility functions based on glib functions * + * gnc-gtk-utils.h -- utility functions based on glib functions * * Copyright (C) 2006 David Hampton * * * * This program is free software; you can redistribute it and/or * @@ -41,9 +41,9 @@ @{ */ -void gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, const gchar *text); -void gnc_cbe_add_completion (GtkComboBoxEntry *cbe); -void gnc_cbe_require_list_item (GtkComboBoxEntry *cbe); +void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text); +void gnc_cbwe_add_completion (GtkComboBox *cbwe); +void gnc_cbwe_require_list_item (GtkComboBox *cbwe); /** @} */ diff --git a/src/gnome-utils/gnc-period-select.c b/src/gnome-utils/gnc-period-select.c index faca6f86e2..13b7ea0168 100644 --- a/src/gnome-utils/gnc-period-select.c +++ b/src/gnome-utils/gnc-period-select.c @@ -256,14 +256,14 @@ gnc_period_select_set_fy_end (GncPeriodSelect *period, const GDate *fy_end) for (i = GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i < GNC_ACCOUNTING_PERIOD_FYEAR_LAST; i++) { label = priv->start ? _(start_strings[i]) : _(end_strings[i]); - gtk_combo_box_append_text(GTK_COMBO_BOX(priv->selector), label); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label); } } else { for (i = GNC_ACCOUNTING_PERIOD_FYEAR_LAST - 1; i >= GNC_ACCOUNTING_PERIOD_FYEAR_LAST; i--) { - gtk_combo_box_remove_text(GTK_COMBO_BOX(priv->selector), i); + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(priv->selector), i); } } } @@ -286,7 +286,7 @@ gnc_period_select_set_date_common (GncPeriodSelect *period, const GDate *date) { priv->date_align = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(priv->date_align), 0, 0, 6, 0); - gtk_box_pack_start_defaults(GTK_BOX(period), priv->date_align); + gtk_box_pack_start(GTK_BOX(period), priv->date_align, TRUE, TRUE, 0); priv->date_label = gtk_label_new(""); gtk_container_add(GTK_CONTAINER(priv->date_align), priv->date_label); gtk_widget_show_all(priv->date_align); @@ -619,11 +619,11 @@ gnc_period_select_new (gboolean starting_labels) /* Set up private data structures */ priv = GNC_PERIOD_SELECT_GET_PRIVATE(period); - priv->selector = gtk_combo_box_new_text(); + priv->selector = gtk_combo_box_text_new(); priv->start = starting_labels; /* Add the internal widgets to the hbox */ - gtk_box_pack_start_defaults(GTK_BOX(period), priv->selector); + gtk_box_pack_start(GTK_BOX(period), priv->selector, TRUE, TRUE, 0); gtk_widget_show(priv->selector); /* Find out when the combo box changes */ @@ -634,7 +634,7 @@ gnc_period_select_new (gboolean starting_labels) for (i = 0; i < GNC_ACCOUNTING_PERIOD_CYEAR_LAST; i++) { label = starting_labels ? _(start_strings[i]) : _(end_strings[i]); - gtk_combo_box_append_text(GTK_COMBO_BOX(priv->selector), label); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->selector), label); } /* Track changes to date formatting */ diff --git a/src/gnome-utils/gtkbuilder/dialog-commodity.glade b/src/gnome-utils/gtkbuilder/dialog-commodity.glade index a5d7ae9078..091f06e273 100644 --- a/src/gnome-utils/gtkbuilder/dialog-commodity.glade +++ b/src/gnome-utils/gtkbuilder/dialog-commodity.glade @@ -1,7 +1,218 @@ - + - + + False + 6 + Select security/currency + False + dialog + + + True + False + 12 + + + True + False + end + + + gtk-new + False + True + True + True + True + False + True + + + False + False + 0 + + + + + gtk-cancel + False + True + True + True + True + True + False + True + + + False + False + 1 + + + + + gtk-ok + False + True + True + True + True + False + True + + + False + False + 2 + + + + + False + True + end + 0 + + + + + True + False + 3 + 3 + 12 + 6 + + + True + False + 0 + Select user information here... + center + + + 3 + GTK_FILL + + + + + + True + False + 12 + + + True + False + 0 + _Type: + True + center + + + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + False + 12 + + + True + False + 0 + _Security/currency: + True + center + + + + + 2 + 3 + GTK_FILL + GTK_FILL + + + + + True + False + liststore2 + True + 0 + + + + True + True + + + + + 1 + 3 + 1 + 2 + GTK_FILL + + + + + True + False + liststore1 + True + 0 + + + + True + True + + + + + 1 + 3 + 2 + 3 + GTK_FILL + + + + + True + True + 1 + + + + + + ss_new_button + ss_cancel_button + ss_ok_button + + + + 1 + 100000000 + 10000 + 1 + 10 + False 6 @@ -9,18 +220,19 @@ True dialog - + True False 12 - + True False end gtk-cancel + False True True True @@ -38,6 +250,7 @@ gtk-ok + False True True True @@ -55,6 +268,7 @@ gtk-help + False True True True @@ -94,7 +308,7 @@ 6 7 GTK_FILL - + @@ -104,13 +318,11 @@ True Enter the full name of the commodity. Example: Cisco Systems Inc., or Apple Computer, Inc. Enter the full name of the commodity. Example: Cisco Systems Inc., or Apple Computer, Inc. - + True True False False - True - True @@ -118,7 +330,7 @@ 2 1 2 - + @@ -128,13 +340,11 @@ True Enter the ticker symbol for the commodity (e.g. CSCO or AAPL). If you are retrieving quotes online, this field must exactly match the ticker symbol used by the quote source (including case). Enter the ticker symbol for the commodity (e.g. CSCO or AAPL). If you are retrieving quotes online, this field must exactly match the ticker symbol used by the quote source (including case). - + True True False False - True - True @@ -142,7 +352,7 @@ 2 2 3 - + @@ -152,20 +362,18 @@ True Enter a unique code used to identify the commodity. Or, you may safely leave this field blank. Enter a unique code used to identify the commodity. Or, you may safely leave this field blank. - + True True False False - True - True 1 2 4 5 - + @@ -193,12 +401,10 @@ True Enter the smallest fraction of the commodity which can be traded. For stocks which can only be traded in whole numbers, enter 1. Enter the smallest fraction of the commodity which can be traded. For stocks which can only be traded in whole numbers, enter 1. - + True False False - True - True adjustment1 1 @@ -231,7 +437,7 @@ 7 8 GTK_FILL - + @@ -245,7 +451,7 @@ 2 GTK_FILL - + @@ -400,7 +606,6 @@ _Type: True center - namespace_cbe @@ -522,6 +727,7 @@ _Get Online Quotes + False True True False @@ -548,6 +754,7 @@ Si_ngle: + False True True False @@ -577,6 +784,7 @@ _Multiple: + False True True False @@ -606,6 +814,7 @@ _Unknown: + False True True False @@ -651,17 +860,25 @@ - + True False + liststore2 + True + 0 + + + True + True + + 1 2 3 4 - GTK_FILL GTK_FILL @@ -728,199 +945,26 @@ help_button - - False - 6 - Select security/currency - False - dialog - - - True - False - 12 - - - True - False - end - - - gtk-new - True - True - True - True - False - True - - - False - False - 0 - - - - - gtk-cancel - True - True - True - True - True - False - True - - - False - False - 1 - - - - - gtk-ok - True - True - True - True - False - True - - - False - False - 2 - - - - - False - True - end - 0 - - - - - True - False - 3 - 3 - 12 - 6 - - - True - False - 0 - Select user information here... - center - - - 3 - GTK_FILL - - - - - - True - False - 12 - - - True - False - 0 - _Type: - True - center - ss_namespace_cbe - - - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - False - 12 - - - True - False - 0 - _Security/currency: - True - center - ss_commodity_cbe - - - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - True - False - - - - 1 - 3 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - False - - - - 1 - 3 - 2 - 3 - GTK_FILL - GTK_FILL - - - - - True - True - 1 - - - - - - ss_new_button - ss_cancel_button - ss_ok_button - + + + + + + + + Dummy commodity Line + + - - 1 - 100000000 - 10000 - 1 - 10 + + + + + + + + Dummy namespace Line + + - \ No newline at end of file + diff --git a/src/gnome/dialog-price-editor.c b/src/gnome/dialog-price-editor.c index c2a8c68bce..95e1e2708e 100644 --- a/src/gnome/dialog-price-editor.c +++ b/src/gnome/dialog-price-editor.c @@ -65,8 +65,8 @@ typedef struct GNCPriceDB *price_db; GNCPriceEditType type; - GtkWidget * namespace_cbe; - GtkWidget * commodity_cbe; + GtkWidget * namespace_cbwe; + GtkWidget * commodity_cbwe; GtkWidget * currency_edit; GtkWidget * date_edit; GtkWidget * source_entry; @@ -83,11 +83,10 @@ typedef struct } PriceEditDialog; - void pedit_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data); void pedit_data_changed_cb (GtkWidget *w, gpointer data); -void pedit_commodity_ns_changed_cb (GtkComboBoxEntry *cbe, gpointer data); -void pedit_commodity_changed_cb (GtkComboBoxEntry *cbe, gpointer data); +void pedit_commodity_ns_changed_cb (GtkComboBox *cbwe, gpointer data); +void pedit_commodity_changed_cb (GtkComboBox *cbwe, gpointer data); static void @@ -157,9 +156,9 @@ price_to_gui (PriceEditDialog *pedit_dialog) { namespace = gnc_commodity_get_namespace(commodity); fullname = gnc_commodity_get_printname(commodity); - gnc_ui_update_namespace_picker(pedit_dialog->namespace_cbe, + gnc_ui_update_namespace_picker(pedit_dialog->namespace_cbwe, namespace, DIAG_COMM_ALL); - gnc_ui_update_commodity_picker(pedit_dialog->commodity_cbe, + gnc_ui_update_commodity_picker(pedit_dialog->commodity_cbwe, namespace, fullname); currency = gnc_price_get_currency (pedit_dialog->price); @@ -201,14 +200,16 @@ gui_to_price (PriceEditDialog *pedit_dialog) { gnc_commodity *commodity; gnc_commodity *currency; - gchar *namespace, *fullname; + gchar *namespace; + const gchar *fullname; const char *source; const char *type; gnc_numeric value; Timespec date; - namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbe); - fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(pedit_dialog->commodity_cbe)); + namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbwe); + fullname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(pedit_dialog->commodity_cbwe))))); + commodity = gnc_commodity_table_find_full(gnc_get_current_commodities(), namespace, fullname); if (!commodity) return _("You must select a Security."); @@ -244,7 +245,6 @@ gui_to_price (PriceEditDialog *pedit_dialog) gnc_price_commit_edit (pedit_dialog->price); g_free(namespace); - g_free(fullname); return NULL; } @@ -312,33 +312,35 @@ pedit_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data) void -pedit_commodity_ns_changed_cb (GtkComboBoxEntry *cbe, gpointer data) +pedit_commodity_ns_changed_cb (GtkComboBox *cbwe, gpointer data) { PriceEditDialog *pedit_dialog = data; gchar *namespace; gnc_prices_set_changed (pedit_dialog, TRUE); - namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbe); - gnc_ui_update_commodity_picker (pedit_dialog->commodity_cbe, namespace, NULL); + namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbwe); + gnc_ui_update_commodity_picker (pedit_dialog->commodity_cbwe, namespace, NULL); g_free(namespace); } void -pedit_commodity_changed_cb (GtkComboBoxEntry *cbe, gpointer data) +pedit_commodity_changed_cb (GtkComboBox *cbwe, gpointer data) { - gnc_commodity *commodity = NULL; - gnc_commodity *currency = NULL; - gchar *namespace, *fullname; - GList *price_list; + gnc_commodity *commodity = NULL; + gnc_commodity *currency = NULL; + gchar *namespace; + const gchar *fullname; + GList *price_list; PriceEditDialog *pedit_dialog = data; gnc_prices_set_changed (pedit_dialog, TRUE); - namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbe); - fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(pedit_dialog->commodity_cbe)); + namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbwe); + fullname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(pedit_dialog->commodity_cbwe))))); + commodity = gnc_commodity_table_find_full(gnc_get_current_commodities(), namespace, fullname); if (commodity) @@ -363,7 +365,6 @@ pedit_commodity_changed_cb (GtkComboBoxEntry *cbe, gpointer data) } g_free(namespace); - g_free(fullname); } @@ -388,11 +389,12 @@ gnc_price_pedit_dialog_create (GtkWidget *parent, GtkWidget *box; GtkWidget *w; GtkWidget *label; - gchar *namespace; - + gchar *namespace; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-price.glade", "liststore1"); + gnc_builder_add_from_file (builder, "dialog-price.glade", "liststore2"); + gnc_builder_add_from_file (builder, "dialog-price.glade", "liststore3"); gnc_builder_add_from_file (builder, "dialog-price.glade", "Price Dialog"); pedit_dialog->session = session; @@ -406,55 +408,19 @@ gnc_price_pedit_dialog_create (GtkWidget *parent, if (parent != NULL) gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); - w = GTK_WIDGET(gtk_builder_get_object (builder, "namespace_cbe")); - pedit_dialog->namespace_cbe = w; + w = GTK_WIDGET(gtk_builder_get_object (builder, "namespace_cbwe")); + pedit_dialog->namespace_cbwe = w; - /* namespace List Store - create here as we get an error if created in builder */ - { - GtkListStore *store; - GtkTreeIter iter; - gchar string[] = "Dummy namespace Line"; - - store = gtk_list_store_new( 1, G_TYPE_STRING ); - - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, 0, string, -1 ); - - gtk_combo_box_set_model( GTK_COMBO_BOX( pedit_dialog->namespace_cbe ), - GTK_TREE_MODEL( store ) ); - g_object_unref( G_OBJECT( store ) ); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( pedit_dialog->namespace_cbe ), 0 ); - } - - gtk_combo_box_remove_text(GTK_COMBO_BOX(pedit_dialog->namespace_cbe), 0); gnc_ui_update_namespace_picker(w, NULL, DIAG_COMM_ALL); - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(pedit_dialog->namespace_cbe)); - gtk_combo_box_set_active(GTK_COMBO_BOX(pedit_dialog->namespace_cbe), 1); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(pedit_dialog->namespace_cbwe)); + gtk_combo_box_set_active(GTK_COMBO_BOX(pedit_dialog->namespace_cbwe), 1); - w = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_cbe")); - pedit_dialog->commodity_cbe = w; + w = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_cbwe")); + pedit_dialog->commodity_cbwe = w; - /* commodity List Store - create here as we get an error if created in builder */ - { - GtkListStore *store; - GtkTreeIter iter; - gchar string[] = "Dummy commodity Line"; - - store = gtk_list_store_new( 1, G_TYPE_STRING ); - - gtk_list_store_append( store, &iter ); - gtk_list_store_set( store, &iter, 0, string, -1 ); - - gtk_combo_box_set_model( GTK_COMBO_BOX( pedit_dialog->commodity_cbe ), - GTK_TREE_MODEL( store ) ); - g_object_unref( G_OBJECT( store ) ); - gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( pedit_dialog->commodity_cbe ), 0 ); - } - - gtk_combo_box_remove_text(GTK_COMBO_BOX(pedit_dialog->commodity_cbe), 0); - gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(pedit_dialog->commodity_cbe)); - namespace = gnc_ui_namespace_picker_ns(pedit_dialog->namespace_cbe); - gnc_ui_update_commodity_picker(pedit_dialog->commodity_cbe, namespace, NULL); + gnc_cbwe_require_list_item(GTK_COMBO_BOX(pedit_dialog->commodity_cbwe)); + namespace = gnc_ui_namespace_picker_ns(pedit_dialog->namespace_cbwe); + gnc_ui_update_commodity_picker(pedit_dialog->commodity_cbwe, namespace, NULL); g_free(namespace); box = GTK_WIDGET(gtk_builder_get_object (builder, "currency_box")); @@ -479,10 +445,9 @@ gnc_price_pedit_dialog_create (GtkWidget *parent, g_signal_connect (G_OBJECT (GNC_DATE_EDIT (w)->date_entry), "changed", G_CALLBACK (pedit_data_changed_cb), pedit_dialog); gtk_entry_set_activates_default(GTK_ENTRY(GNC_DATE_EDIT(w)->date_entry), TRUE); - label = GTK_WIDGET(gtk_builder_get_object (builder, "date_label")); + label = GTK_WIDGET(gtk_builder_get_object (builder, "date__label")); gnc_date_make_mnemonic_target (GNC_DATE_EDIT(w), label); - w = GTK_WIDGET(gtk_builder_get_object (builder, "source_entry")); pedit_dialog->source_entry = w; @@ -607,7 +572,7 @@ gnc_price_edit_dialog (GtkWidget * parent, refresh_handler, close_handler, pedit_dialog); gnc_gui_component_set_session (component_id, pedit_dialog->session); - gtk_widget_grab_focus (pedit_dialog->commodity_cbe); + gtk_widget_grab_focus (pedit_dialog->commodity_cbwe); gtk_widget_show (pedit_dialog->dialog); } diff --git a/src/gnome/dialog-print-check.c b/src/gnome/dialog-print-check.c index 4889551a14..5fd09c9bab 100644 --- a/src/gnome/dialog-print-check.c +++ b/src/gnome/dialog-print-check.c @@ -2550,7 +2550,7 @@ gnc_print_check_format_changed (GtkComboBox *widget, { GtkListStore *p_store; GtkTreeModel *f_model; - GtkTreeIter f_iter; + GtkTreeIter f_iter, iter; gboolean sensitive; gint pnum; check_format_t *format; @@ -2578,21 +2578,24 @@ gnc_print_check_format_changed (GtkComboBox *widget, pcd->position_max = g_slist_length(format->positions); /* -1 for 0 base, +1 for custom entry */ for (elem = format->positions; elem; elem = g_slist_next(elem)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(pcd->position_combobox), elem->data); + gtk_list_store_append(GTK_LIST_STORE(p_store), &iter); + gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, elem->data, -1); } } else { /* Invent a "Top" position if format has no positions */ pcd->position_max = 1; - gtk_combo_box_append_text(GTK_COMBO_BOX(pcd->position_combobox), _("Top")); + gtk_list_store_append(GTK_LIST_STORE(p_store), &iter); + gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _("Top"), -1); } } else { pcd->position_max = 0; } - gtk_combo_box_append_text(GTK_COMBO_BOX(pcd->position_combobox), _("Custom")); + gtk_list_store_append(GTK_LIST_STORE(p_store), &iter); + gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _("Custom"), -1); /* If there's only one thing in the position combobox, make it insensitive */ sensitive = (pcd->position_max > 0); diff --git a/src/gnome/gtkbuilder/dialog-price.glade b/src/gnome/gtkbuilder/dialog-price.glade index e9a0a62e88..ef6da55f7b 100644 --- a/src/gnome/gtkbuilder/dialog-price.glade +++ b/src/gnome/gtkbuilder/dialog-price.glade @@ -1,7 +1,6 @@ - + - True False @@ -9,18 +8,19 @@ False dialog - + True False 6 - + True False end gtk-cancel + False True True True @@ -37,6 +37,7 @@ gtk-ok + False True True True @@ -76,12 +77,13 @@ 2 GTK_FILL - + Delete _manually entered prices + False True True False @@ -95,12 +97,13 @@ 3 4 GTK_FILL - + Delete _last price for a stock + False True True False @@ -114,7 +117,7 @@ 4 5 GTK_FILL - + @@ -128,7 +131,7 @@ 1 2 GTK_FILL - + @@ -142,8 +145,8 @@ 2 3 - - + + @@ -184,18 +187,19 @@ dialog - + True False 6 - + True False end gtk-cancel + False True True True @@ -212,6 +216,7 @@ gtk-apply + False True True True @@ -227,6 +232,7 @@ gtk-ok + False True True True @@ -257,33 +263,6 @@ 2 12 6 - - - True - False - - - - 1 - 2 - 1 - 2 - - - - - - 250 - True - False - - - - 1 - 2 - GTK_FILL - - True @@ -292,11 +271,11 @@ _Namespace: True center - namespace_cbe + namespace_cbwe GTK_FILL - + @@ -307,13 +286,13 @@ _Security: True center - commodity_cbe + commodity_cbwe 1 2 GTK_FILL - + @@ -329,11 +308,11 @@ 2 3 GTK_FILL - + - + True False 0 @@ -345,7 +324,7 @@ 3 4 GTK_FILL - + @@ -361,7 +340,7 @@ 4 5 GTK_FILL - + @@ -378,7 +357,7 @@ 5 6 GTK_FILL - + @@ -394,7 +373,7 @@ 6 7 GTK_FILL - + @@ -437,8 +416,6 @@ False False False - True - True @@ -446,7 +423,7 @@ 2 4 5 - + @@ -488,6 +465,49 @@ GTK_FILL + + + 250 + True + False + liststore3 + True + 0 + + + + True + True + + + + + 1 + 2 + + + + + True + False + liststore2 + True + 0 + + + + True + True + + + + + 1 + 2 + 1 + 2 + + True @@ -514,18 +534,19 @@ - + True False 6 - + True False end gtk-close + False True True True @@ -556,8 +577,6 @@ True False 3 - automatic - automatic in @@ -578,6 +597,7 @@ gtk-add + False True True True @@ -596,6 +616,7 @@ gtk-remove + False True False True @@ -614,6 +635,7 @@ + False True False True @@ -671,6 +693,7 @@ + False True True True @@ -727,6 +750,7 @@ + False True True True @@ -824,4 +848,26 @@ + + + + + + + + Dummy commodity Line + + + + + + + + + + + Dummy namespace Line + + + diff --git a/src/import-export/qif-import/assistant-qif-import.c b/src/import-export/qif-import/assistant-qif-import.c index b24b4d6846..f688ec018d 100644 --- a/src/import-export/qif-import/assistant-qif-import.c +++ b/src/import-export/qif-import/assistant-qif-import.c @@ -834,6 +834,7 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w { QIFAssistantPage *retval = g_new0(QIFAssistantPage, 1); + GtkListStore *store; GtkWidget *table; GtkWidget *label; gchar *title = NULL; @@ -922,8 +923,14 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind); /* Namespace entry */ - retval->namespace_combo = gtk_combo_box_entry_new_text(); - gnc_cbe_add_completion(GTK_COMBO_BOX_ENTRY(retval->namespace_combo)); + store = gtk_list_store_new (1, G_TYPE_STRING); + retval->namespace_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store)); + g_object_unref(store); + + /* Set the column for the text */ + gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0); + + gnc_cbwe_add_completion(GTK_COMBO_BOX(retval->namespace_combo)); label = gtk_label_new_with_mnemonic( _("_Exchange or abbreviation type:")); gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->namespace_combo); @@ -1885,26 +1892,28 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, SCM_CDR(parse_return), scm_str2symbol("date"))) != SCM_BOOL_F) { - gint n_items; + GtkComboBox *combo_box; + GtkTreeModel *model; + GtkTreeIter iter; /* Block the date call back */ g_signal_handlers_block_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind ); + /* Clear the date format combo box. */ + combo_box = GTK_COMBO_BOX(wind->date_format_combo); + model = gtk_combo_box_get_model(combo_box); + gtk_list_store_clear(GTK_LIST_STORE(model)); + gtk_combo_box_set_active(GTK_COMBO_BOX(wind->date_format_combo), -1); - n_items = gtk_tree_model_iter_n_children( - gtk_combo_box_get_model(GTK_COMBO_BOX(wind->date_format_combo)), - NULL); - while (n_items-- > 0) - gtk_combo_box_remove_text(GTK_COMBO_BOX(wind->date_format_combo), 0); /* Add the formats for the user to select from. */ while (scm_is_list(date_formats) && !scm_is_null(date_formats)) { - gtk_combo_box_append_text(GTK_COMBO_BOX(wind->date_format_combo), - SCM_SYMBOL_CHARS(SCM_CAR(date_formats))); + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, SCM_SYMBOL_CHARS(SCM_CAR(date_formats)), -1); + date_formats = SCM_CDR(date_formats); } - gtk_combo_box_set_active(GTK_COMBO_BOX(wind->date_format_combo), -1 ); /* Unblock the date call back */ g_signal_handlers_unblock_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind ); @@ -2017,6 +2026,8 @@ void gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data) { QIFImportWindow * wind = user_data; + GtkTreeModel *model; + GtkTreeIter iter; GtkAssistant *assistant = GTK_ASSISTANT(wind->window); gint num = gtk_assistant_get_current_page (assistant); @@ -2027,7 +2038,10 @@ gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data) gchar *text; /* Get the selected date format. */ - text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(wind->date_format_combo)); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(wind->date_format_combo)); + gtk_combo_box_get_active_iter (GTK_COMBO_BOX(wind->date_format_combo), &iter); + gtk_tree_model_get( model, &iter, 0, &text, -1 ); + if (!text) { g_critical("QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL."); @@ -2635,10 +2649,10 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant, GtkWidget *page = gtk_assistant_get_nth_page (assistant, num); QIFAssistantPage *qpage = g_object_get_data(G_OBJECT(page), "page_struct"); - gchar *ns; + const gchar *ns; /* Get any entered namespace. */ - ns = gtk_combo_box_get_active_text(GTK_COMBO_BOX(qpage->namespace_combo)); + ns = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(qpage->namespace_combo))))); /* Update the namespaces available to select. */ if (!ns || !ns[0]) @@ -2648,8 +2662,6 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant, DIAG_COMM_ALL); else gnc_ui_update_namespace_picker(qpage->namespace_combo, ns, DIAG_COMM_ALL); - - g_free(ns); } @@ -2822,8 +2834,7 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, 0); /* The default currency. */ - gchar *currname = - gtk_combo_box_get_active_text(GTK_COMBO_BOX(wind->currency_picker)); + const gchar *currname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(wind->currency_picker))))); /* Raise the busy flag so the assistant can't be canceled unexpectedly. */ wind->busy = TRUE; @@ -2858,7 +2869,6 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, progress), SCM_EOL); gnc_progress_dialog_pop(wind->convert_progress); - g_free(currname); if (retval == SCM_BOOL_T) { diff --git a/src/report/report-gnome/dialog-report-style-sheet.c b/src/report/report-gnome/dialog-report-style-sheet.c index 571beb6116..3533507680 100644 --- a/src/report/report-gnome/dialog-report-style-sheet.c +++ b/src/report/report-gnome/dialog-report-style-sheet.c @@ -179,6 +179,7 @@ gnc_style_sheet_new (StyleSheetDialog * ssd) SCM new_ss = SCM_BOOL_F; GtkWidget * template_combo; GtkTreeModel * template_model; + GtkTreeIter iter; GtkWidget * name_entry; gint dialog_retval; GList *template_names = NULL; @@ -218,8 +219,8 @@ gnc_style_sheet_new (StyleSheetDialog * ssd) template_names = g_list_prepend (template_names, (gpointer)orig_name); /* The displayed name should be translated */ - gtk_combo_box_prepend_text(GTK_COMBO_BOX(template_combo), - _(orig_name)); + gtk_list_store_append(GTK_LIST_STORE(template_model), &iter); + gtk_list_store_set (GTK_LIST_STORE(template_model), &iter, 0, _(orig_name), -1); } gtk_combo_box_set_active(GTK_COMBO_BOX(template_combo), 0);