diff options
author | Milan Crha <mcrha@redhat.com> | 2009-08-06 02:03:51 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-08-11 04:38:49 +0800 |
commit | 22fea30cfd43793c828b26782cd21918699a415f (patch) | |
tree | f650f4547e84d2b56387cfd4410fa1e8f05d7489 | |
parent | 1f56992e474023ceca14e57515019cccabd0d083 (diff) | |
download | gsoc2013-evolution-22fea30cfd43793c828b26782cd21918699a415f.tar.gz gsoc2013-evolution-22fea30cfd43793c828b26782cd21918699a415f.tar.zst gsoc2013-evolution-22fea30cfd43793c828b26782cd21918699a415f.zip |
Bug #401530 - [imap-features] imap-headers.glade issues
-rw-r--r-- | plugins/imap-features/imap-headers.c | 36 | ||||
-rw-r--r-- | plugins/imap-features/imap-headers.glade | 2 |
2 files changed, 25 insertions, 13 deletions
diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c index 7bb819cf0e..baa6ee43dc 100644 --- a/plugins/imap-features/imap-headers.c +++ b/plugins/imap-features/imap-headers.c @@ -185,32 +185,41 @@ static void epif_add_header (GtkButton *button, EPImapFeaturesData *ui) { GtkTreeModel *model; - GtkTreeIter iter, first; + GtkTreeIter iter; + GtkTreeSelection *selection; model = gtk_tree_view_get_model (ui->custom_headers_tree); gtk_tree_store_append (GTK_TREE_STORE(model), &iter, NULL); gtk_tree_store_set (GTK_TREE_STORE(model), &iter, 0, gtk_entry_get_text (ui->entry_header), -1); - if (gtk_tree_model_get_iter_first (model, &first)!=FALSE) - gtk_widget_set_sensitive (GTK_WIDGET (ui->remove_header), TRUE); + selection = gtk_tree_view_get_selection (ui->custom_headers_tree); + gtk_tree_selection_select_iter (selection, &iter); gtk_entry_set_text (ui->entry_header, ""); epif_add_sensitivity (ui); } static void +epif_tv_selection_changed (GtkTreeSelection *selection, GtkWidget *button) +{ + g_return_if_fail (selection != NULL); + g_return_if_fail (button != NULL); + + gtk_widget_set_sensitive (button, gtk_tree_selection_get_selected (selection, NULL, NULL)); +} + +static void epif_remove_header_clicked (GtkButton *button, EPImapFeaturesData *ui) { GtkTreeSelection *select; GtkTreeModel *model; - GtkTreeIter iter, first; + GtkTreeIter iter; GtkTreePath *path; gboolean valid = TRUE; select = gtk_tree_view_get_selection (ui->custom_headers_tree); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { + if (gtk_tree_selection_get_selected (select, &model, &iter)) { path = gtk_tree_model_get_path (model, &iter); gtk_tree_store_remove(GTK_TREE_STORE(model), &iter); @@ -224,9 +233,6 @@ epif_remove_header_clicked (GtkButton *button, EPImapFeaturesData *ui) gtk_tree_selection_select_iter (select, &iter); } - if (gtk_tree_model_get_iter_first (model, &first)==FALSE) - gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); - epif_add_sensitivity (ui); } @@ -257,7 +263,8 @@ org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data) GladeXML *gladexml; GtkCellRenderer *renderer; GtkTreeViewColumn *column; - GtkTreeIter first, iter; + GtkTreeIter iter; + GtkTreeSelection *selection; gboolean use_imap = g_getenv ("USE_IMAP") != NULL; ui = g_new0 (EPImapFeaturesData, 1); @@ -287,6 +294,8 @@ org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data) ui->store = gtk_tree_store_new (1, G_TYPE_STRING); gtk_tree_view_set_model (ui->custom_headers_tree, GTK_TREE_MODEL(ui->store)); + selection = gtk_tree_view_get_selection (ui->custom_headers_tree); + if (url) { gchar *custom_headers; @@ -299,6 +308,9 @@ org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data) if (strlen(g_strstrip(ui->custom_headers_array[i]))) { gtk_tree_store_append (ui->store, &iter, NULL); gtk_tree_store_set (ui->store, &iter, 0, ui->custom_headers_array[i], -1); + + if (i == 0) + gtk_tree_selection_select_iter (selection, &iter); } i++; } @@ -320,14 +332,14 @@ org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data) gtk_tree_view_append_column (ui->custom_headers_tree , column); gtk_widget_set_sensitive (GTK_WIDGET (ui->add_header), FALSE); - if (gtk_tree_model_get_iter_first (gtk_tree_view_get_model (ui->custom_headers_tree), &first)==FALSE) - gtk_widget_set_sensitive (GTK_WIDGET (ui->remove_header), FALSE); + epif_tv_selection_changed (selection, GTK_WIDGET (ui->remove_header)); g_signal_connect (ui->all_headers, "toggled", G_CALLBACK (epif_fetch_all_headers_toggled), ui); g_signal_connect (ui->add_header, "clicked", G_CALLBACK (epif_add_header), ui); g_signal_connect (ui->remove_header, "clicked", G_CALLBACK (epif_remove_header_clicked), ui); g_signal_connect (ui->entry_header, "changed", G_CALLBACK (epif_entry_changed), ui); g_signal_connect (ui->entry_header, "activate", G_CALLBACK (epif_add_header), ui); + g_signal_connect (selection, "changed", G_CALLBACK (epif_tv_selection_changed), ui->remove_header); gtk_notebook_append_page ((GtkNotebook *)(data->parent), vbox, gtk_label_new(_("IMAP Headers"))); gtk_widget_show_all (vbox); diff --git a/plugins/imap-features/imap-headers.glade b/plugins/imap-features/imap-headers.glade index 3a8810147e..85ca962a9c 100644 --- a/plugins/imap-features/imap-headers.glade +++ b/plugins/imap-features/imap-headers.glade @@ -83,7 +83,7 @@ The more headers you have the more time it will take to download.</property> <widget class="GtkRadioButton" id="allHeaders"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Fetch A_ll Headers</property> + <property name="label" translatable="yes">_Fetch All Headers</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> |