From 6743c659cd6bc47a1d9a389c29e35c83b8ce10f7 Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Tue, 30 Oct 2007 08:04:20 +0000 Subject: [PATCH] 2007-10-30 [paul] 3.0.2cvs107 * src/expldifdlg.c * src/prefs_account.c * src/prefs_folder_item.c * src/prefs_spelling.c * src/prefs_themes.c * src/wizard.c * src/gtk/gtkaspell.c * src/gtk/gtkaspell.h * src/plugins/spamassassin/spamassassin_gtk.c replace deprecated gtk_option_menu... patch by Pawel Pekala --- ChangeLog | 14 ++ PATCHSETS | 1 + configure.ac | 2 +- src/expldifdlg.c | 113 ++++++------ src/gtk/gtkaspell.c | 194 ++++++++++---------- src/gtk/gtkaspell.h | 17 +- src/plugins/spamassassin/spamassassin_gtk.c | 41 +++-- src/prefs_account.c | 77 +++----- src/prefs_folder_item.c | 67 +++---- src/prefs_spelling.c | 116 ++++-------- src/prefs_themes.c | 72 ++++---- src/wizard.c | 54 ++---- 12 files changed, 351 insertions(+), 417 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb8e7941c..b154474fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-10-30 [paul] 3.0.2cvs107 + + * src/expldifdlg.c + * src/prefs_account.c + * src/prefs_folder_item.c + * src/prefs_spelling.c + * src/prefs_themes.c + * src/wizard.c + * src/gtk/gtkaspell.c + * src/gtk/gtkaspell.h + * src/plugins/spamassassin/spamassassin_gtk.c + replace deprecated gtk_option_menu... + patch by Pawel Pekala + 2007-10-29 [colin] 3.0.2cvs106 * src/plugins/dillo_viewer/dillo_prefs.c diff --git a/PATCHSETS b/PATCHSETS index b0f5b45a3..1a7eb41ab 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3019,3 +3019,4 @@ ( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/edittags.c; ) > 3.0.2cvs104.patchset ( cvs diff -u -r 1.5.2.17 -r 1.5.2.18 src/plugins/dillo_viewer/dillo_prefs.c; cvs diff -u -r 1.2.4.7 -r 1.2.4.8 src/plugins/dillo_viewer/dillo_prefs.h; cvs diff -u -r 1.12.2.23 -r 1.12.2.24 src/plugins/dillo_viewer/dillo_viewer.c; ) > 3.0.2cvs105.patchset ( cvs diff -u -r 1.5.2.18 -r 1.5.2.19 src/plugins/dillo_viewer/dillo_prefs.c; ) > 3.0.2cvs106.patchset +( cvs diff -u -r 1.1.4.27 -r 1.1.4.28 src/expldifdlg.c; cvs diff -u -r 1.105.2.114 -r 1.105.2.115 src/prefs_account.c; cvs diff -u -r 1.52.2.53 -r 1.52.2.54 src/prefs_folder_item.c; cvs diff -u -r 1.5.2.34 -r 1.5.2.35 src/prefs_spelling.c; cvs diff -u -r 1.3.2.52 -r 1.3.2.53 src/prefs_themes.c; cvs diff -u -r 1.1.2.63 -r 1.1.2.64 src/wizard.c; cvs diff -u -r 1.9.2.54 -r 1.9.2.55 src/gtk/gtkaspell.c; cvs diff -u -r 1.5.2.13 -r 1.5.2.14 src/gtk/gtkaspell.h; cvs diff -u -r 1.23.2.44 -r 1.23.2.45 src/plugins/spamassassin/spamassassin_gtk.c; ) > 3.0.2cvs107.patchset diff --git a/configure.ac b/configure.ac index 2469c08f1..1706bee18 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=2 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=106 +EXTRA_VERSION=107 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/expldifdlg.c b/src/expldifdlg.c index 9849f6100..fa9bf43fd 100644 --- a/src/expldifdlg.c +++ b/src/expldifdlg.c @@ -47,6 +47,7 @@ #include "utils.h" #include "manage_window.h" #include "filesel.h" +#include "combobox.h" #define PAGE_FILE_INFO 0 #define PAGE_DN 1 @@ -219,7 +220,6 @@ static gboolean exp_ldif_move_dn( void ) { gboolean retVal = FALSE; gboolean errFlag = FALSE; gchar *suffix; - GtkWidget *menu, *menuItem; gint id; /* Set suffix */ @@ -227,9 +227,7 @@ static gboolean exp_ldif_move_dn( void ) { g_strchug( suffix ); g_strchomp( suffix ); /* Set RDN format */ - menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( expldif_dlg.optmenuRDN ) ); - menuItem = gtk_menu_get_active( GTK_MENU( menu ) ); - id = GPOINTER_TO_INT( g_object_get_data(G_OBJECT(menuItem), "user_data")); + id = combobox_get_active_data(GTK_COMBO_BOX(expldif_dlg.optmenuRDN)); exportldif_set_rdn( _exportCtl_, id ); exportldif_set_suffix( _exportCtl_, suffix ); @@ -426,6 +424,34 @@ static void export_ldif_page_file( gint pageNum, gchar *pageLbl ) { expldif_dlg.entryLdif = entryLdif; } +static void export_ldif_relative_dn_changed(GtkWidget *widget, gpointer data) +{ + gint relativeDN = combobox_get_active_data(GTK_COMBO_BOX(widget)); + GtkLabel *label = GTK_LABEL(data); + + switch(relativeDN) { + case EXPORT_LDIF_ID_UID: + gtk_label_set_text(label, + _("The address book Unique ID is used to create a DN that is " \ + "formatted similar to:\n" \ + " uid=102376,ou=people,dc=claws-mail,dc=org")); + break; + case EXPORT_LDIF_ID_DNAME: + gtk_label_set_text(label, + _("The address book Display Name is used to create a DN that " \ + "is formatted similar to:\n" \ + " cn=John Doe,ou=people,dc=claws-mail,dc=org")); + break; + case EXPORT_LDIF_ID_EMAIL: + gtk_label_set_text(label, + _("The first Email Address belonging to a person is used to " \ + "create a DN that is formatted similar to:\n" \ + " mail=john.doe@domain.com,ou=people,dc=claws-mail,dc=org")); + break; + } + +} + /** * Format notebook distinguished name page. * \param pageNum Page (tab) number. @@ -437,10 +463,11 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { GtkWidget *label; GtkWidget *entrySuffix; GtkWidget *optmenuRDN; + GtkWidget *labelRDN; GtkWidget *checkUseDN; GtkWidget *checkEMail; - GtkWidget *menu; - GtkWidget *menuItem; + GtkListStore *store; + GtkTreeIter iter; GtkTooltips *toolTip; gint top; @@ -456,7 +483,7 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { GTK_NOTEBOOK( expldif_dlg.notebook ), pageNum ), label ); - table = gtk_table_new( 5, 2, FALSE ); + table = gtk_table_new( 6, 2, FALSE ); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); gtk_container_set_border_width( GTK_CONTAINER(table), 8 ); gtk_table_set_row_spacings(GTK_TABLE(table), 8); @@ -490,49 +517,12 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { GTK_FILL, 0, 0, 0); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - menu = gtk_menu_new(); - - menuItem = gtk_menu_item_new_with_label( _( "Unique ID" ) ); - g_object_set_data( G_OBJECT( menuItem ), "user_data", - GINT_TO_POINTER( EXPORT_LDIF_ID_UID ) ); - gtk_menu_append( GTK_MENU(menu), menuItem ); - gtk_widget_show( menuItem ); - toolTip = gtk_tooltips_new(); - gtk_tooltips_set_tip( - GTK_TOOLTIPS(toolTip), menuItem, _( - "The address book Unique ID is used to create a DN that is " \ - "formatted similar to:\n" \ - " uid=102376,ou=people,dc=claws-mail,dc=org" - ), NULL ); - - menuItem = gtk_menu_item_new_with_label( _( "Display Name" ) ); - g_object_set_data( G_OBJECT( menuItem ), "user_data", - GINT_TO_POINTER( EXPORT_LDIF_ID_DNAME ) ); - gtk_menu_append( GTK_MENU(menu), menuItem ); - gtk_widget_show( menuItem ); - toolTip = gtk_tooltips_new(); - gtk_tooltips_set_tip( - GTK_TOOLTIPS(toolTip), menuItem, _( - "The address book Display Name is used to create a DN that " \ - "is formatted similar to:\n" \ - " cn=John Doe,ou=people,dc=claws-mail,dc=org" - ), NULL ); - - menuItem = gtk_menu_item_new_with_label( _( "Email Address" ) ); - g_object_set_data( G_OBJECT( menuItem ), "user_data", - GINT_TO_POINTER( EXPORT_LDIF_ID_EMAIL ) ); - gtk_menu_append( GTK_MENU(menu), menuItem ); - gtk_widget_show( menuItem ); - toolTip = gtk_tooltips_new(); - gtk_tooltips_set_tip( - GTK_TOOLTIPS(toolTip), menuItem, _( - "The first Email Address belonging to a person is used to " \ - "create a DN that is formatted similar to:\n" \ - " mail=john.doe@domain.com,ou=people,dc=claws-mail,dc=org" - ), NULL ); - - optmenuRDN = gtk_option_menu_new(); - gtk_option_menu_set_menu( GTK_OPTION_MENU( optmenuRDN ), menu ); + optmenuRDN = gtkut_sc_combobox_create(NULL, TRUE); + store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuRDN))); + + COMBOBOX_ADD(store, _("Unique ID"), EXPORT_LDIF_ID_UID); + COMBOBOX_ADD(store, _("Display Name"), EXPORT_LDIF_ID_DNAME); + COMBOBOX_ADD(store, _("Email Address"), EXPORT_LDIF_ID_EMAIL); gtk_table_attach(GTK_TABLE(table), optmenuRDN, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0); @@ -549,8 +539,16 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { "the available RDN options that will be used to " \ "create the DN." ), NULL ); - - /* Third row */ + + /* Third row*/ + top++; + labelRDN = gtk_label_new(""); + gtk_label_set_line_wrap(GTK_LABEL(labelRDN), TRUE); + gtk_label_set_justify(GTK_LABEL(labelRDN), GTK_JUSTIFY_CENTER); + gtk_table_attach(GTK_TABLE(table), labelRDN, 0, 2, top, (top + 1), + GTK_FILL, 0, 0, 0); + + /* Fourth row */ top++; checkUseDN = gtk_check_button_new_with_label( _( "Use DN attribute if present in data" ) ); @@ -568,7 +566,7 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { "will be used if the DN user attribute is not found." ), NULL ); - /* Fourth row */ + /* Fifth row */ top++; checkEMail = gtk_check_button_new_with_label( _( "Exclude record if no Email Address" ) ); @@ -586,6 +584,11 @@ static void export_ldif_page_dn( gint pageNum, gchar *pageLbl ) { gtk_widget_show_all(vbox); + g_signal_connect(G_OBJECT(optmenuRDN), "changed", + G_CALLBACK(export_ldif_relative_dn_changed), labelRDN); + gtk_combo_box_set_active(GTK_COMBO_BOX(optmenuRDN), 0); + + expldif_dlg.entrySuffix = entrySuffix; expldif_dlg.optmenuRDN = optmenuRDN; expldif_dlg.checkUseDN = checkUseDN; @@ -754,8 +757,8 @@ static void export_ldif_fill_fields( ExportLdifCtl *ctl ) { ctl->suffix ); } - gtk_option_menu_set_history( - GTK_OPTION_MENU( expldif_dlg.optmenuRDN ), ctl->rdnIndex ); + gtk_combo_box_set_active( + GTK_COMBO_BOX( expldif_dlg.optmenuRDN ), ctl->rdnIndex ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( expldif_dlg.checkUseDN ), ctl->useDN ); gtk_toggle_button_set_active( diff --git a/src/gtk/gtkaspell.c b/src/gtk/gtkaspell.c index 698d14ddb..fd146df6a 100644 --- a/src/gtk/gtkaspell.c +++ b/src/gtk/gtkaspell.c @@ -60,6 +60,7 @@ #include "alertpanel.h" #include "gtkaspell.h" #include "gtk/gtkutils.h" +#include "gtk/combobox.h" #define ASPELL_FASTMODE 1 #define ASPELL_NORMALMODE 2 @@ -87,6 +88,12 @@ RETURN_FALSE_IF_CONFIG_ERROR(); \ } +enum { + SET_GTKASPELL_NAME = 0, + SET_GTKASPELL_FULLNAME = 1, + SET_GTKASPELL_SIZE +}; + typedef struct _GtkAspellCheckers { GSList *checkers; GSList *dictionary_list; @@ -1747,146 +1754,131 @@ static void gtkaspell_free_dictionary_list(GSList *list) g_slist_free(list); } -/* FIXME */ -GtkWidget *gtkaspell_dictionary_option_menu_new_with_refresh(const gchar *aspell_path, +GtkTreeModel *gtkaspell_dictionary_store_new_with_refresh(const gchar *aspell_path, gboolean refresh) { GSList *dict_list, *tmp; - GtkWidget *item; - GtkWidget *menu; + GtkListStore *store; + GtkTreeIter iter; Dictionary *dict; dict_list = gtkaspell_get_dictionary_list(aspell_path, refresh); g_return_val_if_fail(dict_list, NULL); - menu = gtk_menu_new(); + store = gtk_list_store_new(SET_GTKASPELL_SIZE, + G_TYPE_STRING, + G_TYPE_STRING, + -1); for (tmp = dict_list; tmp != NULL; tmp = g_slist_next(tmp)) { dict = (Dictionary *) tmp->data; - item = gtk_menu_item_new_with_label(dict->dictname); - g_object_set_data(G_OBJECT(item), "dict_name", - dict->fullname); - - gtk_menu_append(GTK_MENU(menu), item); - gtk_widget_show(item); + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + SET_GTKASPELL_NAME, dict->dictname, + SET_GTKASPELL_FULLNAME, dict->fullname, + -1); } - gtk_widget_show(menu); - - return menu; + return GTK_TREE_MODEL(store); } -GtkWidget *gtkaspell_dictionary_option_menu_new(const gchar *aspell_path) +GtkTreeModel *gtkaspell_dictionary_store_new(const gchar *aspell_path) { - return gtkaspell_dictionary_option_menu_new_with_refresh + return gtkaspell_dictionary_store_new_with_refresh (aspell_path, TRUE); - } -gchar *gtkaspell_get_dictionary_menu_active_item(GtkWidget *menu) +GtkWidget *gtkaspell_dictionary_combo_new(const gchar *aspell_path, + const gboolean refresh) { - GtkWidget *menuitem; - gchar *dict_fullname; - gchar *label; + GtkWidget *combo; + GtkCellRenderer *renderer; - g_return_val_if_fail(GTK_IS_MENU(menu), NULL); - - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - dict_fullname = (gchar *) g_object_get_data(G_OBJECT(menuitem), - "dict_name"); - g_return_val_if_fail(dict_fullname, NULL); + combo = gtk_combo_box_new_with_model( + gtkaspell_dictionary_store_new_with_refresh(aspell_path, refresh)); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); + gtk_widget_show(combo); + + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),renderer, + "text", SET_GTKASPELL_NAME, NULL); + + return combo; +} - label = g_strdup(dict_fullname); +gchar *gtkaspell_get_dictionary_menu_active_item(GtkComboBox *combo) +{ + GtkTreeIter iter; + GtkTreeModel *model; + gchar *dict_fullname = NULL; + + g_return_val_if_fail(GTK_IS_COMBO_BOX(combo), NULL); + g_return_val_if_fail(gtk_combo_box_get_active_iter(combo, &iter), NULL); + + model = gtk_combo_box_get_model(combo); + if(model == NULL) + return NULL; + + gtk_tree_model_get(model, &iter, + SET_GTKASPELL_FULLNAME, &dict_fullname, + -1); - return label; - + return dict_fullname; } -gint gtkaspell_set_dictionary_menu_active_item(GtkWidget *menu, +gint gtkaspell_set_dictionary_menu_active_item(GtkComboBox *combo, const gchar *dictionary) { - GList *cur; - gint n; - - g_return_val_if_fail(menu != NULL, 0); + GtkTreeModel *model; + GtkTreeIter iter; + gchar *dict_name = NULL; + + g_return_val_if_fail(combo != NULL, 0); g_return_val_if_fail(dictionary != NULL, 0); - g_return_val_if_fail(GTK_IS_OPTION_MENU(menu), 0); - - n = 0; - for (cur = GTK_MENU_SHELL(gtk_option_menu_get_menu( - GTK_OPTION_MENU(menu)))->children; - cur != NULL; cur = cur->next) { - GtkWidget *menuitem; - gchar *dict_name; - - menuitem = GTK_WIDGET(cur->data); - dict_name = g_object_get_data(G_OBJECT(menuitem), - "dict_name"); - if ((dict_name != NULL) && !strcmp2(dict_name, dictionary)) { - gtk_option_menu_set_history(GTK_OPTION_MENU(menu), n); + g_return_val_if_fail(GTK_IS_COMBO_BOX(combo), 0); + if((model = gtk_combo_box_get_model(combo)) == NULL) + return 0; + if((gtk_tree_model_get_iter_first(model, &iter)) == FALSE) + return 0; + + do { + gtk_tree_model_get(model, &iter, + SET_GTKASPELL_FULLNAME, &dict_name, + -1); + + if ((dict_name != NULL) && !strcmp2(dict_name, dictionary)) { + gtk_combo_box_set_active_iter(combo, &iter); + g_free(dict_name); return 1; } - n++; - } - + + g_free(dict_name); + + } while ((gtk_tree_model_iter_next(model, &iter)) == TRUE); + return 0; } -/* FIXME */ -GtkWidget *gtkaspell_sugmode_option_menu_new(gint sugmode) +GtkWidget *gtkaspell_sugmode_combo_new(gint sugmode) { - GtkWidget *menu; - GtkWidget *item; - - menu = gtk_menu_new(); - gtk_widget_show(menu); - - item = gtk_menu_item_new_with_label(_("Fast Mode")); - gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); - g_object_set_data(G_OBJECT(item), "sugmode", - GINT_TO_POINTER(ASPELL_FASTMODE)); - - item = gtk_menu_item_new_with_label(_("Normal Mode")); - gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); - g_object_set_data(G_OBJECT(item), "sugmode", - GINT_TO_POINTER(ASPELL_NORMALMODE)); + GtkWidget *combo = gtkut_sc_combobox_create(NULL, FALSE); + GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model( + GTK_COMBO_BOX(combo))); + GtkTreeIter iter; - item = gtk_menu_item_new_with_label(_("Bad Spellers Mode")); - gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); - g_object_set_data(G_OBJECT(item), "sugmode", - GINT_TO_POINTER(ASPELL_BADSPELLERMODE)); - - return menu; -} - -void gtkaspell_sugmode_option_menu_set(GtkOptionMenu *optmenu, gint sugmode) -{ - g_return_if_fail(GTK_IS_OPTION_MENU(optmenu)); - - g_return_if_fail(sugmode == ASPELL_FASTMODE || - sugmode == ASPELL_NORMALMODE || - sugmode == ASPELL_BADSPELLERMODE); - - gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), sugmode - 1); -} - -gint gtkaspell_get_sugmode_from_option_menu(GtkOptionMenu *optmenu) -{ - gint sugmode; - GtkWidget *item; + g_return_val_if_fail(store != NULL, NULL); - g_return_val_if_fail(GTK_IS_OPTION_MENU(optmenu), -1); + COMBOBOX_ADD(store, _("Fast Mode"), ASPELL_FASTMODE); + COMBOBOX_ADD(store, _("Normal Mode"), ASPELL_NORMALMODE); + COMBOBOX_ADD(store, _("Bad Spellers Mode"), ASPELL_BADSPELLERMODE); - item = gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(optmenu))); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), sugmode - 1); + gtk_widget_show(combo); - sugmode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), - "sugmode")); - - return sugmode; + return combo; } static void use_alternate_dict(GtkAspell *gtkaspell) diff --git a/src/gtk/gtkaspell.h b/src/gtk/gtkaspell.h index f6597239d..6ce7e48e1 100644 --- a/src/gtk/gtkaspell.h +++ b/src/gtk/gtkaspell.h @@ -83,23 +83,22 @@ void gtkaspell_check_backwards (GtkAspell *gtkaspell); void gtkaspell_check_all (GtkAspell *gtkaspell); void gtkaspell_highlight_all (GtkAspell *gtkaspell); -GtkWidget* gtkaspell_dictionary_option_menu_new (const gchar *aspell_path); -GtkWidget* gtkaspell_dictionary_option_menu_new_with_refresh +GtkWidget* gtkaspell_dictionary_combo_new (const gchar *aspell_path, + const gboolean refresh); + +GtkTreeModel* gtkaspell_dictionary_store_new (const gchar *aspell_path); +GtkTreeModel* gtkaspell_dictionary_store_new_with_refresh (const gchar *aspell_path, gboolean refresh); gchar* gtkaspell_get_dictionary_menu_active_item - (GtkWidget *menu); + (GtkComboBox *combo); gint gtkaspell_set_dictionary_menu_active_item - (GtkWidget *menu, + (GtkComboBox *combo, const gchar *dictionary); -GtkWidget* gtkaspell_sugmode_option_menu_new (gint sugmode); - -void gtkaspell_sugmode_option_menu_set (GtkOptionMenu *optmenu, - gint sugmode); +GtkWidget* gtkaspell_sugmode_combo_new (gint sugmode); -gint gtkaspell_get_sugmode_from_option_menu (GtkOptionMenu *optmenu); GSList* gtkaspell_make_config_menu (GtkAspell *gtkaspell); gchar *gtkaspell_get_default_dictionary(GtkAspell *gtkaspell); diff --git a/src/plugins/spamassassin/spamassassin_gtk.c b/src/plugins/spamassassin/spamassassin_gtk.c index add00e29c..f7996d271 100644 --- a/src/plugins/spamassassin/spamassassin_gtk.c +++ b/src/plugins/spamassassin/spamassassin_gtk.c @@ -187,8 +187,15 @@ static void transport_sel_cb(GtkMenuItem *menuitem, gpointer data) { struct SpamAssassinPage *page = (struct SpamAssassinPage *) data; struct Transport *transport; + GtkTreeModel *model; + GtkTreeIter iter; + + g_return_if_fail(gtk_combo_box_get_active_iter( + GTK_COMBO_BOX(page->transport_optmenu), &iter)); + + model = gtk_combo_box_get_model(GTK_COMBO_BOX(page->transport_optmenu)); + gtk_tree_model_get(model, &iter, 1, &transport, -1); - transport = (struct Transport *) g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID); show_transport(page, transport); } @@ -213,7 +220,6 @@ static void spamassassin_create_widget_func(PrefsPage * _page, GtkWidget *transport_label; GtkWidget *transport_optmenu; - GtkWidget *transport_menu; GtkWidget *user_label; GtkWidget *user_entry; @@ -244,6 +250,10 @@ static void spamassassin_create_widget_func(PrefsPage * _page, GtkWidget *mark_as_read_checkbtn; GtkTooltips *tooltips; + + GtkListStore *store; + GtkCellRenderer *renderer; + GtkTreeIter iter; tooltips = gtk_tooltips_new(); @@ -275,13 +285,18 @@ static void spamassassin_create_widget_func(PrefsPage * _page, gtk_label_set_justify(GTK_LABEL(transport_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(transport_label), 1, 0.5); - transport_optmenu = gtk_option_menu_new(); + store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); + transport_optmenu = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(transport_optmenu), + renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(transport_optmenu), + renderer, "text", 0, NULL); gtk_widget_show(transport_optmenu); gtk_table_attach (GTK_TABLE (table_transport), transport_optmenu, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); - transport_menu = gtk_menu_new(); user_label = gtk_label_new(_("User")); gtk_widget_show(user_label); @@ -498,14 +513,11 @@ static void spamassassin_create_widget_func(PrefsPage * _page, active = 0; for (i = 0; i < (sizeof(transports) / sizeof(struct Transport)); i++) { - GtkWidget *menuitem; - - menuitem = gtk_menu_item_new_with_label(gettext(transports[i].name)); - g_object_set_data(G_OBJECT(menuitem), MENU_VAL_ID, &transports[i]); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(transport_sel_cb), page); - gtk_widget_show(menuitem); - gtk_menu_append(GTK_MENU(transport_menu), menuitem); + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + 0, gettext(transports[i].name), + 1, &transports[i], -1); if (config->transport == transports[i].transport) { show_transport(page, &transports[i]); @@ -521,8 +533,9 @@ static void spamassassin_create_widget_func(PrefsPage * _page, config->enable); } } - gtk_option_menu_set_menu(GTK_OPTION_MENU(transport_optmenu), transport_menu); - gtk_option_menu_set_history(GTK_OPTION_MENU(transport_optmenu), active); + gtk_combo_box_set_active(GTK_COMBO_BOX(transport_optmenu), active); + g_signal_connect(G_OBJECT(transport_optmenu), "changed", + G_CALLBACK(transport_sel_cb), page); page->page.widget = vbox1; } diff --git a/src/prefs_account.c b/src/prefs_account.c index eadc5eee6..f9571df04 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -180,9 +180,9 @@ typedef struct ComposePage GtkWidget *autoreplyto_entry; #if USE_ASPELL GtkWidget *checkbtn_enable_default_dictionary; - GtkWidget *optmenu_default_dictionary; + GtkWidget *combo_default_dictionary; GtkWidget *checkbtn_enable_default_alt_dictionary; - GtkWidget *optmenu_default_alt_dictionary; + GtkWidget *combo_default_alt_dictionary; #endif } ComposePage; @@ -548,7 +548,7 @@ static PrefParam compose_param[] = { prefs_set_data_from_toggle, prefs_set_toggle}, {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING, - &compose_page.optmenu_default_dictionary, + &compose_page.combo_default_dictionary, prefs_account_compose_default_dictionary_set_string_from_optmenu, prefs_account_compose_default_dictionary_set_optmenu_from_string}, @@ -557,7 +557,7 @@ static PrefParam compose_param[] = { prefs_set_data_from_toggle, prefs_set_toggle}, {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING, - &compose_page.optmenu_default_alt_dictionary, + &compose_page.combo_default_alt_dictionary, prefs_account_compose_default_dictionary_set_string_from_optmenu, prefs_account_compose_default_dictionary_set_optmenu_from_string}, #else @@ -1802,9 +1802,9 @@ static void compose_create_widget_func(PrefsPage * _page, GtkWidget *frame_dict; GtkWidget *table_dict; GtkWidget *checkbtn_enable_default_dictionary = NULL; - GtkWidget *optmenu_default_dictionary = NULL; + GtkWidget *combo_default_dictionary = NULL; GtkWidget *checkbtn_enable_default_alt_dictionary = NULL; - GtkWidget *optmenu_default_alt_dictionary = NULL; + GtkWidget *combo_default_alt_dictionary = NULL; #endif vbox1 = gtk_vbox_new (FALSE, VSPACING); @@ -1942,15 +1942,12 @@ static void compose_create_widget_func(PrefsPage * _page, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary), tmp_ac_prefs.enable_default_dictionary); - optmenu_default_dictionary = gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table_dict), optmenu_default_dictionary, 1, 2, + combo_default_dictionary = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, TRUE); + gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_dictionary), - gtkaspell_dictionary_option_menu_new( - prefs_common.aspell_path)); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, optmenu_default_dictionary); + SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary); /* Default dictionary */ checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary")); @@ -1959,15 +1956,12 @@ static void compose_create_widget_func(PrefsPage * _page, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary), tmp_ac_prefs.enable_default_alt_dictionary); - optmenu_default_alt_dictionary = gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table_dict), optmenu_default_alt_dictionary, 1, 2, + combo_default_alt_dictionary = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, FALSE); + gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_alt_dictionary), - gtkaspell_dictionary_option_menu_new_with_refresh( - prefs_common.aspell_path, FALSE)); - - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, optmenu_default_alt_dictionary); + SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary); gtk_widget_show_all(table_dict); #endif @@ -1985,22 +1979,19 @@ static void compose_create_widget_func(PrefsPage * _page, page->autoreplyto_entry = autoreplyto_entry; #ifdef USE_ASPELL page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary; - page->optmenu_default_dictionary = optmenu_default_dictionary; + page->combo_default_dictionary = combo_default_dictionary; page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary; - page->optmenu_default_alt_dictionary = optmenu_default_alt_dictionary; + page->combo_default_alt_dictionary = combo_default_alt_dictionary; #endif #ifdef USE_ASPELL /* reset gtkaspell menus */ - if (compose_page.optmenu_default_dictionary != NULL) { - gtk_option_menu_remove_menu(GTK_OPTION_MENU(compose_page.optmenu_default_dictionary)); - gtk_option_menu_set_menu(GTK_OPTION_MENU(compose_page.optmenu_default_dictionary), - gtkaspell_dictionary_option_menu_new( - prefs_common.aspell_path)); - gtk_option_menu_remove_menu(GTK_OPTION_MENU(compose_page.optmenu_default_alt_dictionary)); - gtk_option_menu_set_menu(GTK_OPTION_MENU(compose_page.optmenu_default_alt_dictionary), - gtkaspell_dictionary_option_menu_new_with_refresh( - prefs_common.aspell_path, FALSE)); + if (compose_page.combo_default_dictionary != NULL) { + gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary), + gtkaspell_dictionary_store_new(prefs_common.aspell_path)); + gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary), + gtkaspell_dictionary_store_new_with_refresh( + prefs_common.aspell_path, FALSE)); } #endif @@ -4230,28 +4221,22 @@ static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, static void prefs_account_compose_default_dictionary_set_string_from_optmenu (PrefParam *pparam) { - GtkWidget *menu; - GtkWidget *menuitem; + GtkWidget *combo; gchar **str; g_return_if_fail(*pparam->widget != NULL); - menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget)); - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - if (menuitem == NULL) - return; - + combo = *pparam->widget; str = (gchar **) pparam->data; + g_free(*str); - *str = gtkaspell_get_dictionary_menu_active_item(menu); + *str = gtkaspell_get_dictionary_menu_active_item(GTK_COMBO_BOX(combo)); } static void prefs_account_compose_default_dictionary_set_optmenu_from_string (PrefParam *pparam) { - GtkWidget *optionmenu; - GtkWidget *menu; - GtkWidget *menuitem; + GtkWidget *combo; gchar *dictionary; g_return_if_fail(*pparam->widget != NULL); @@ -4260,12 +4245,10 @@ static void prefs_account_compose_default_dictionary_set_optmenu_from_string if (dictionary == NULL) return; - optionmenu = *pparam->widget; - menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optionmenu)); + combo = *pparam->widget; if (dictionary) - gtkaspell_set_dictionary_menu_active_item(optionmenu, dictionary); - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - gtk_menu_item_activate(GTK_MENU_ITEM(menuitem)); + gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(combo), + dictionary); } #endif diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c index 286b29c7a..20effe940 100644 --- a/src/prefs_folder_item.c +++ b/src/prefs_folder_item.c @@ -123,8 +123,8 @@ struct _FolderItemComposePage #if USE_ASPELL GtkWidget *checkbtn_enable_default_dictionary; GtkWidget *checkbtn_enable_default_alt_dictionary; - GtkWidget *optmenu_default_dictionary; - GtkWidget *optmenu_default_alt_dictionary; + GtkWidget *combo_default_dictionary; + GtkWidget *combo_default_alt_dictionary; #endif /* apply to sub folders */ @@ -716,15 +716,12 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, GtkTreeIter iter; #if USE_ASPELL GtkWidget *checkbtn_enable_default_dictionary = NULL; - GtkWidget *optmenu_default_dictionary = NULL; + GtkWidget *combo_default_dictionary = NULL; GtkWidget *checkbtn_enable_default_alt_dictionary = NULL; - GtkWidget *optmenu_default_alt_dictionary = NULL; + GtkWidget *combo_default_alt_dictionary = NULL; GtkWidget *default_dictionary_rec_checkbtn = NULL; GtkWidget *default_alt_dictionary_rec_checkbtn = NULL; gchar *dictionary; - GtkOptionMenu *optmenu; - GtkWidget *menu; - GtkWidget *menuitem; #endif GtkWidget *request_return_receipt_rec_checkbtn = NULL; GtkWidget *save_copy_to_folder_rec_checkbtn = NULL; @@ -901,25 +898,17 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary), item->prefs->enable_default_dictionary); - optmenu_default_dictionary = gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table), optmenu_default_dictionary, 1, 2, + combo_default_dictionary = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, TRUE); + gtk_table_attach(GTK_TABLE(table), combo_default_dictionary, 1, 2, rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_dictionary), - gtkaspell_dictionary_option_menu_new( - prefs_common.aspell_path)); - dictionary = item->prefs->default_dictionary; - - optmenu = GTK_OPTION_MENU(optmenu_default_dictionary); - - menu = gtk_option_menu_get_menu(optmenu); if (dictionary) - gtkaspell_set_dictionary_menu_active_item(optmenu_default_dictionary, dictionary); - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - gtk_menu_item_activate(GTK_MENU_ITEM(menuitem)); + gtkaspell_set_dictionary_menu_active_item( + GTK_COMBO_BOX(combo_default_dictionary), dictionary); - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, optmenu_default_dictionary); + SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary); default_dictionary_rec_checkbtn = gtk_check_button_new(); gtk_table_attach(GTK_TABLE(table), default_dictionary_rec_checkbtn, 2, 3, @@ -934,25 +923,17 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary), item->prefs->enable_default_alt_dictionary); - optmenu_default_alt_dictionary = gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table), optmenu_default_alt_dictionary, 1, 2, + combo_default_alt_dictionary = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, FALSE); + gtk_table_attach(GTK_TABLE(table), combo_default_alt_dictionary, 1, 2, rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu_default_alt_dictionary), - gtkaspell_dictionary_option_menu_new_with_refresh( - prefs_common.aspell_path, FALSE)); - dictionary = item->prefs->default_alt_dictionary; - - optmenu = GTK_OPTION_MENU(optmenu_default_alt_dictionary); - - menu = gtk_option_menu_get_menu(optmenu); if (dictionary) - gtkaspell_set_dictionary_menu_active_item(optmenu_default_alt_dictionary, dictionary); - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - gtk_menu_item_activate(GTK_MENU_ITEM(menuitem)); + gtkaspell_set_dictionary_menu_active_item( + GTK_COMBO_BOX(combo_default_alt_dictionary), dictionary); - SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, optmenu_default_alt_dictionary); + SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary); default_alt_dictionary_rec_checkbtn = gtk_check_button_new(); gtk_table_attach(GTK_TABLE(table), default_alt_dictionary_rec_checkbtn, 2, 3, @@ -976,9 +957,9 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_, page->optmenu_default_account = optmenu_default_account; #ifdef USE_ASPELL page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary; - page->optmenu_default_dictionary = optmenu_default_dictionary; + page->combo_default_dictionary = combo_default_dictionary; page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary; - page->optmenu_default_alt_dictionary = optmenu_default_alt_dictionary; + page->combo_default_alt_dictionary = combo_default_alt_dictionary; #endif page->request_return_receipt_rec_checkbtn = request_return_receipt_rec_checkbtn; @@ -1015,9 +996,7 @@ static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_) static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage *page) { FolderItemPrefs *prefs = folder->prefs; -#if USE_ASPELL - GtkWidget *menu; -#endif + gboolean all = FALSE; if (folder->path == NULL) @@ -1075,16 +1054,16 @@ static void compose_save_folder_prefs(FolderItem *folder, FolderItemComposePage if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_dictionary_rec_checkbtn))) { prefs->enable_default_dictionary = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_dictionary)); - menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_dictionary)); ASSIGN_STRING(prefs->default_dictionary, - gtkaspell_get_dictionary_menu_active_item(menu)); + gtkaspell_get_dictionary_menu_active_item( + GTK_COMBO_BOX(page->combo_default_dictionary))); } if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->default_alt_dictionary_rec_checkbtn))) { prefs->enable_default_alt_dictionary = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_default_alt_dictionary)); - menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_default_alt_dictionary)); ASSIGN_STRING(prefs->default_alt_dictionary, - gtkaspell_get_dictionary_menu_active_item(menu)); + gtkaspell_get_dictionary_menu_active_item( + GTK_COMBO_BOX(page->combo_default_alt_dictionary))); } #endif diff --git a/src/prefs_spelling.c b/src/prefs_spelling.c index 04dd821a3..ced58433c 100644 --- a/src/prefs_spelling.c +++ b/src/prefs_spelling.c @@ -40,6 +40,7 @@ #include "gtk/prefswindow.h" #include "gtk/filesel.h" #include "gtk/colorsel.h" +#include "gtk/combobox.h" typedef struct _SpellingPage { @@ -60,18 +61,15 @@ typedef struct _SpellingPage GtkWidget *aspell_path_select; GtkWidget *default_dict_label; - GtkWidget *default_dict_optmenu; - GtkWidget *default_dict_optmenu_menu; + GtkWidget *default_dict_combo; GtkWidget *default_alt_dict_label; - GtkWidget *default_alt_dict_optmenu; - GtkWidget *default_alt_dict_optmenu_menu; + GtkWidget *default_alt_dict_combo; GtkWidget *both_dict_check; GtkWidget *sugmode_label; - GtkWidget *sugmode_optmenu; - GtkWidget *sugmode_optmenu_menu; + GtkWidget *sugmode_combo; GtkWidget *misspelled_label; GtkWidget *misspelled_colorbtn; @@ -85,8 +83,6 @@ static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget, { SpellingPage *spelling = (SpellingPage *) data; gchar *file_path; - GtkWidget *new_menu; - GtkWidget *alt_new_menu; file_path = filesel_select_file_open(_("Select dictionaries location"), prefs_common.aspell_path); @@ -97,20 +93,18 @@ static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget, tmp = g_strdup_printf("%s%s", tmp_path, G_DIR_SEPARATOR_S); g_free(tmp_path); - new_menu = gtkaspell_dictionary_option_menu_new(tmp); - gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling->default_dict_optmenu), - new_menu); + gtk_combo_box_set_model(GTK_COMBO_BOX(spelling->default_dict_combo), + gtkaspell_dictionary_store_new(tmp)); - alt_new_menu = gtkaspell_dictionary_option_menu_new_with_refresh(tmp, FALSE); - gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling->default_alt_dict_optmenu), - alt_new_menu); + gtk_combo_box_set_model(GTK_COMBO_BOX(spelling->default_alt_dict_combo), + gtkaspell_dictionary_store_new_with_refresh(tmp, FALSE)); gtk_entry_set_text(GTK_ENTRY(spelling->aspell_path_entry), tmp); /* select first one */ - gtk_option_menu_set_history(GTK_OPTION_MENU( - spelling->default_dict_optmenu), 0); - gtk_option_menu_set_history(GTK_OPTION_MENU( - spelling->default_alt_dict_optmenu), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX( + spelling->default_dict_combo), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX( + spelling->default_alt_dict_combo), 0); g_free(tmp); @@ -154,16 +148,13 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp GtkWidget *table; GtkWidget *default_dict_label; - GtkWidget *default_dict_optmenu; - GtkWidget *default_dict_optmenu_menu; + GtkWidget *default_dict_combo; GtkWidget *default_alt_dict_label; - GtkWidget *default_alt_dict_optmenu; - GtkWidget *default_alt_dict_optmenu_menu; + GtkWidget *default_alt_dict_combo; GtkWidget *sugmode_label; - GtkWidget *sugmode_optmenu; - GtkWidget *sugmode_optmenu_menu; + GtkWidget *sugmode_combo; GtkWidget *both_dict_check; GtkWidget *misspelled_label; @@ -238,16 +229,12 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_label_set_justify(GTK_LABEL(default_dict_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(default_dict_label), 1, 0.5); - default_dict_optmenu = gtk_option_menu_new(); - gtk_widget_show(default_dict_optmenu); - gtk_widget_set_size_request(default_dict_optmenu, 180, -1); - gtk_table_attach (GTK_TABLE (table), default_dict_optmenu, 1, 2, 0, 1, + default_dict_combo = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, TRUE); + gtk_widget_set_size_request(default_dict_combo, 180, -1); + gtk_table_attach (GTK_TABLE (table), default_dict_combo, 1, 2, 0, 1, GTK_SHRINK, 0, 0, 0); - default_dict_optmenu_menu = gtk_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(default_dict_optmenu), - default_dict_optmenu_menu); - default_alt_dict_label = gtk_label_new(_("Default alternate dictionary")); gtk_widget_show(default_alt_dict_label); gtk_table_attach(GTK_TABLE (table), default_alt_dict_label, 0, 1, 1, 2, @@ -256,23 +243,18 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_label_set_justify(GTK_LABEL(default_alt_dict_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(default_alt_dict_label), 1, 0.5); - default_alt_dict_optmenu = gtk_option_menu_new(); - gtk_widget_show(default_alt_dict_optmenu); - gtk_widget_set_size_request(default_alt_dict_optmenu, 180, -1); - gtk_table_attach (GTK_TABLE (table), default_alt_dict_optmenu, 1, 2, 1, 2, + default_alt_dict_combo = gtkaspell_dictionary_combo_new( + prefs_common.aspell_path, FALSE); + gtk_widget_set_size_request(default_alt_dict_combo, 180, -1); + gtk_table_attach (GTK_TABLE (table), default_alt_dict_combo, 1, 2, 1, 2, GTK_SHRINK, 0, 0, 0); - default_alt_dict_optmenu_menu = gtk_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(default_alt_dict_optmenu), - default_alt_dict_optmenu_menu); - both_dict_check = gtk_check_button_new_with_label( _("Check with both dictionaries")); gtk_widget_show(both_dict_check); gtk_table_attach (GTK_TABLE (table), both_dict_check, 1, 2, 2, 3, GTK_SHRINK, 0, 0, 0); - sugmode_label = gtk_label_new(_("Default suggestion mode")); gtk_widget_show(sugmode_label); gtk_table_attach(GTK_TABLE (table), sugmode_label, 0, 1, 3, 4, @@ -281,16 +263,11 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_label_set_justify(GTK_LABEL(sugmode_label), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment(GTK_MISC(sugmode_label), 1, 0.5); - sugmode_optmenu = gtk_option_menu_new(); - gtk_widget_show(sugmode_optmenu); - gtk_widget_set_size_request(sugmode_optmenu, 180, -1); - gtk_table_attach (GTK_TABLE (table), sugmode_optmenu, 1, 2, 3, 4, + sugmode_combo = gtkaspell_sugmode_combo_new(prefs_common.aspell_sugmode); + gtk_widget_set_size_request(sugmode_combo, 180, -1); + gtk_table_attach (GTK_TABLE (table), sugmode_combo, 1, 2, 3, 4, GTK_SHRINK, 0, 0, 0); - sugmode_optmenu_menu = gtk_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu), - sugmode_optmenu_menu); - misspelled_hbox = gtk_hbox_new(FALSE, 10); gtk_widget_show(misspelled_hbox); gtk_box_pack_start(GTK_BOX(vbox1), misspelled_hbox, FALSE, FALSE, 0); @@ -319,7 +296,7 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, misspelled_colorbtn); SET_TOGGLE_SENSITIVITY(enable_aspell_checkbtn, use_alternate_checkbtn); SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, default_alt_dict_label); - SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, default_alt_dict_optmenu); + SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, default_alt_dict_combo); SET_TOGGLE_SENSITIVITY(use_alternate_checkbtn, both_dict_check); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_aspell_checkbtn), @@ -337,17 +314,12 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp g_signal_connect(G_OBJECT(aspell_path_select), "clicked", G_CALLBACK(prefs_spelling_btn_aspell_path_clicked_cb), prefs_spelling); - gtk_option_menu_set_menu(GTK_OPTION_MENU(default_dict_optmenu), - gtkaspell_dictionary_option_menu_new(prefs_common.aspell_path)); - gtkaspell_set_dictionary_menu_active_item(default_dict_optmenu, prefs_common.dictionary); - gtk_option_menu_set_menu(GTK_OPTION_MENU(default_alt_dict_optmenu), - gtkaspell_dictionary_option_menu_new_with_refresh(prefs_common.aspell_path, FALSE)); - gtkaspell_set_dictionary_menu_active_item(default_alt_dict_optmenu, prefs_common.alt_dictionary); - - gtk_option_menu_set_menu(GTK_OPTION_MENU(sugmode_optmenu), - gtkaspell_sugmode_option_menu_new(prefs_common.aspell_sugmode)); - gtkaspell_sugmode_option_menu_set(GTK_OPTION_MENU(sugmode_optmenu), - prefs_common.aspell_sugmode); + gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(default_dict_combo), + prefs_common.dictionary); + + gtkaspell_set_dictionary_menu_active_item(GTK_COMBO_BOX(default_alt_dict_combo), + prefs_common.alt_dictionary); + g_signal_connect(G_OBJECT(misspelled_colorbtn), "clicked", G_CALLBACK(prefs_spelling_colorsel), prefs_spelling); @@ -367,16 +339,11 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp prefs_spelling->aspell_path_entry = aspell_path_entry; prefs_spelling->aspell_path_select = aspell_path_select; prefs_spelling->default_dict_label = default_dict_label; - prefs_spelling->default_dict_optmenu = default_dict_optmenu; - prefs_spelling->default_dict_optmenu_menu - = default_dict_optmenu_menu; + prefs_spelling->default_dict_combo = default_dict_combo; prefs_spelling->default_alt_dict_label = default_alt_dict_label; - prefs_spelling->default_alt_dict_optmenu = default_alt_dict_optmenu; - prefs_spelling->default_alt_dict_optmenu_menu - = default_alt_dict_optmenu_menu; + prefs_spelling->default_alt_dict_combo = default_alt_dict_combo; prefs_spelling->sugmode_label = sugmode_label; - prefs_spelling->sugmode_optmenu = sugmode_optmenu; - prefs_spelling->sugmode_optmenu_menu = sugmode_optmenu_menu; + prefs_spelling->sugmode_combo = sugmode_combo; prefs_spelling->misspelled_label = misspelled_label; prefs_spelling->misspelled_colorbtn = misspelled_colorbtn; prefs_spelling->both_dict_check = both_dict_check; @@ -406,20 +373,15 @@ static void prefs_spelling_save(PrefsPage *_page) g_free(prefs_common.dictionary); prefs_common.dictionary = gtkaspell_get_dictionary_menu_active_item( - gtk_option_menu_get_menu( - GTK_OPTION_MENU( - spelling->default_dict_optmenu))); + GTK_COMBO_BOX(spelling->default_dict_combo)); g_free(prefs_common.alt_dictionary); prefs_common.alt_dictionary = gtkaspell_get_dictionary_menu_active_item( - gtk_option_menu_get_menu( - GTK_OPTION_MENU( - spelling->default_alt_dict_optmenu))); + GTK_COMBO_BOX(spelling->default_alt_dict_combo)); prefs_common.aspell_sugmode = - gtkaspell_get_sugmode_from_option_menu( - GTK_OPTION_MENU(spelling->sugmode_optmenu)); + combobox_get_active_data(GTK_COMBO_BOX(spelling->sugmode_combo)); prefs_common.misspelled_col = spelling->misspell_col; } diff --git a/src/prefs_themes.c b/src/prefs_themes.c index 73ba142f5..e8c2c0c7c 100644 --- a/src/prefs_themes.c +++ b/src/prefs_themes.c @@ -141,7 +141,7 @@ static void prefs_themes_get_themes_and_names (ThemesData *tdata); static int prefs_themes_cmp_name(gconstpointer a, gconstpointer b); static void prefs_themes_free_names (ThemesData *tdata); -static void prefs_themes_set_themes_menu (GtkOptionMenu *opmenu, const ThemesData *tdata); +static void prefs_themes_set_themes_menu (GtkComboBox *combo, const ThemesData *tdata); static gchar *prefs_themes_get_theme_stats (const gchar *dirname); static gboolean prefs_themes_is_system_theme (const gchar *dirname); @@ -262,43 +262,40 @@ static gboolean prefs_themes_is_system_theme(const gchar *dirname) return FALSE; } -static void prefs_themes_set_themes_menu(GtkOptionMenu *opmenu, const ThemesData *tdata) +static void prefs_themes_set_themes_menu(GtkComboBox *combo, const ThemesData *tdata) { + GtkListStore *store; + GtkTreeIter iter; GList *themes = tdata->names; - GtkWidget *menu; - GtkWidget *item; gint i = 0, active = 0; GList *sorted_list = NULL; - g_return_if_fail(opmenu != NULL); - - gtk_option_menu_remove_menu(opmenu); + g_return_if_fail(combo != NULL); /* sort theme data list by data name */ - menu = gtk_menu_new (); while (themes != NULL) { ThemeName *tname = (ThemeName *)(themes->data); sorted_list = g_list_insert_sorted(sorted_list, (gpointer)(tname), - (GCompareFunc)prefs_themes_cmp_name); + (GCompareFunc)prefs_themes_cmp_name); themes = g_list_next(themes); } + store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); + /* feed gtk_menu w/ sorted themes names */ themes = sorted_list; while (themes != NULL) { ThemeName *tname = (ThemeName *)(themes->data); gchar *tpath = (gchar *)(tname->item->data); - item = gtk_menu_item_new_with_label(tname->name); - gtk_widget_show(item); - g_signal_connect(G_OBJECT(item), "activate", - G_CALLBACK(prefs_themes_menu_item_activated_cb), - tname->item->data); - gtk_menu_append(GTK_MENU(menu), item); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + 0, tname->name, + 1, tname->item->data, -1); - if (tdata->displayed != NULL && tdata->displayed == tpath) + if (tdata->displayed != NULL && !strcmp2(tdata->displayed,tpath)) active = i; ++i; @@ -307,8 +304,12 @@ static void prefs_themes_set_themes_menu(GtkOptionMenu *opmenu, const ThemesData g_list_free(sorted_list); - gtk_menu_set_active(GTK_MENU(menu), active); - gtk_option_menu_set_menu (opmenu, menu); + g_signal_connect(G_OBJECT(combo), "changed", + G_CALLBACK(prefs_themes_menu_item_activated_cb), + NULL); + + gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store)); + gtk_combo_box_set_active(combo, active); } static int prefs_themes_cmp_name(gconstpointer a_p, gconstpointer b_p) @@ -410,7 +411,7 @@ void prefs_themes_done(void) debug_print("Finished preferences for themes.\n"); stock_pixmap_themes_list_free(tdata->themes); - prefs_themes_free_names(tdata); + prefs_themes_free_names(tdata); g_free(tdata->page); g_free(tdata); } @@ -422,7 +423,7 @@ static void prefs_themes_btn_use_clicked_cb(GtkWidget *widget, gpointer data) theme_str = tdata->displayed; - g_free(prefs_common.pixmap_theme_path); + g_free(prefs_common.pixmap_theme_path); prefs_common.pixmap_theme_path = g_strdup(theme_str); @@ -478,7 +479,7 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data) alertpanel_notice(_("Theme removed successfully")); /* update interface back to first theme */ prefs_themes_get_themes_and_names(tdata); - prefs_themes_set_themes_menu(GTK_OPTION_MENU(tdata->page->op_menu), tdata); + prefs_themes_set_themes_menu(GTK_COMBO_BOX(tdata->page->op_menu), tdata); prefs_themes_display_global_stats(tdata); tdata->displayed = (gchar *)((g_list_first(tdata->themes))->data); prefs_themes_get_theme_info(tdata); @@ -560,7 +561,7 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data if (NULL != insted) { alertpanel_notice(_("Theme installed successfully")); tdata->displayed = (gchar *)(insted->data); - prefs_themes_set_themes_menu(GTK_OPTION_MENU(tdata->page->op_menu), tdata); + prefs_themes_set_themes_menu(GTK_COMBO_BOX(tdata->page->op_menu), tdata); prefs_themes_display_global_stats(tdata); prefs_themes_get_theme_info(tdata); } @@ -581,10 +582,15 @@ end_inst: static void prefs_themes_menu_item_activated_cb(GtkWidget *widget, gpointer data) { ThemesData *tdata = prefs_themes_data; - gchar *path = (gchar *)data; + gchar *path; + GtkTreeModel *model; + GtkTreeIter iter; - g_return_if_fail(path != NULL); + g_return_if_fail(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter)); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); + gtk_tree_model_get(model, &iter, 1, &path, -1); + tdata->displayed = path; prefs_themes_get_theme_info(tdata); } @@ -805,8 +811,6 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin GtkWidget *vbox2; GtkWidget *hbox3; GtkWidget *menu_themes; - GtkWidget *menu_themes_menu; - GtkWidget *glade_menuitem; GtkWidget *btn_install; GtkWidget *btn_more; GtkWidget *label_global_status; @@ -833,6 +837,7 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin GtkWidget *hbuttonbox1; GtkWidget *btn_use; GtkWidget *btn_remove; + GtkCellRenderer *renderer; vbox1 = gtk_vbox_new (FALSE, VSPACING); gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); @@ -845,14 +850,9 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox3), 5); - menu_themes = gtk_option_menu_new (); + menu_themes = gtk_combo_box_new(); gtk_widget_show (menu_themes); gtk_box_pack_start (GTK_BOX (hbox3), menu_themes, FALSE, FALSE, 0); - menu_themes_menu = gtk_menu_new (); - glade_menuitem = gtk_menu_item_new_with_label (""); - gtk_widget_show (glade_menuitem); - gtk_menu_append (GTK_MENU (menu_themes_menu), glade_menuitem); - gtk_option_menu_set_menu (GTK_OPTION_MENU (menu_themes), menu_themes_menu); btn_install = gtk_button_new_with_label (_("Install new...")); gtk_widget_show (btn_install); @@ -1028,8 +1028,12 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin prefs_themes->op_menu = menu_themes; prefs_themes->page.widget = vbox1; - - prefs_themes_set_themes_menu(GTK_OPTION_MENU(prefs_themes->op_menu), tdata); + + prefs_themes_set_themes_menu(GTK_COMBO_BOX(menu_themes), tdata); + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(menu_themes), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(menu_themes), renderer, + "text", 0, NULL); prefs_themes_get_theme_info(tdata); prefs_themes_display_global_stats(tdata); diff --git a/src/wizard.c b/src/wizard.c index 78119b5eb..e416720cf 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -61,6 +61,7 @@ #include "ssl.h" #endif #include "prefs_common.h" +#include "combobox.h" #ifdef MAEMO #include @@ -571,18 +572,14 @@ static gboolean wizard_write_config(WizardWindow *wizard) static gboolean mailbox_ok = FALSE; PrefsAccount *prefs_account = prefs_account_new(); GList *account_list = NULL; - GtkWidget *menu, *menuitem; gchar *smtp_server, *recv_server; gint smtp_port, recv_port; #if (defined(USE_OPENSSL) || defined (USE_GNUTLS)) SSLType smtp_ssl_type, recv_ssl_type; #endif - menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type)); - menuitem = gtk_menu_get_active(GTK_MENU(menu)); - prefs_account->protocol = GPOINTER_TO_INT - (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID)); - + prefs_account->protocol = combobox_get_active_data( + GTK_COMBO_BOX(wizard->recv_type)); if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) { @@ -909,8 +906,7 @@ static void wizard_email_changed(GtkWidget *widget, gpointer data) WizardWindow *wizard = (WizardWindow *)data; RecvProtocol protocol; gchar *text; - protocol = GPOINTER_TO_INT - (g_object_get_data(G_OBJECT(wizard->recv_type), MENU_VAL_ID)); + protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type)); text = get_default_server(wizard, "smtp"); gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text); @@ -1346,12 +1342,10 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol) } } -static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data) +static void wizard_protocol_changed(GtkComboBox *combo, gpointer data) { WizardWindow *wizard = (WizardWindow *)data; - RecvProtocol protocol; - protocol = GPOINTER_TO_INT - (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID)); + RecvProtocol protocol = combobox_get_active_data(combo); wizard_protocol_change(wizard, protocol); } @@ -1359,11 +1353,11 @@ static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data) static GtkWidget* recv_page (WizardWindow * wizard) { GtkWidget *table = gtk_table_new(1,1, FALSE); - GtkWidget *menu = gtk_menu_new(); - GtkWidget *menuitem; GtkTooltips *tips = gtk_tooltips_new(); GtkWidget *vbox; GtkWidget *hbox; + GtkListStore *store; + GtkTreeIter iter; gchar *text; gint index = 0; @@ -1378,24 +1372,14 @@ static GtkWidget* recv_page (WizardWindow * wizard) hbox = gtk_hbox_new(FALSE, VSPACING_NARROW); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - wizard->recv_type = gtk_option_menu_new(); - - MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(wizard_protocol_changed), - wizard); - - MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(wizard_protocol_changed), - wizard); + wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE); + store = GTK_LIST_STORE(gtk_combo_box_get_model( + GTK_COMBO_BOX(wizard->recv_type))); - MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(wizard_protocol_changed), - wizard); + COMBOBOX_ADD(store, _("POP3"), A_POP3); + COMBOBOX_ADD(store, _("IMAP"), A_IMAP4); + COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL); - gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu); switch(tmpl.recvtype) { case A_POP3: index = 0; @@ -1409,7 +1393,10 @@ static GtkWidget* recv_page (WizardWindow * wizard) default: index = 0; } - gtk_option_menu_set_history(GTK_OPTION_MENU (wizard->recv_type), index); + gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index); + g_signal_connect(G_OBJECT(wizard->recv_type), "changed", + G_CALLBACK(wizard_protocol_changed), + wizard); PACK_BOX(hbox, _("Server type:"), wizard->recv_type); @@ -1511,10 +1498,7 @@ wizard_response_cb (GtkDialog * dialog, int response, gpointer data) int current_page, num_pages; gboolean skip_mailbox_page = FALSE; #ifndef MAEMO - GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type)); - GtkWidget *menuitem = gtk_menu_get_active(GTK_MENU(menu)); - gint protocol = GPOINTER_TO_INT - (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID)); + gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type)); if (protocol == A_IMAP4) { skip_mailbox_page = TRUE; -- 2.25.1