Mercurial > pidgin.yaz
changeset 11811:924c6ba240e6
[gaim-migrate @ 14102]
sf patch #1335954, from Sadrul Habib Chowdhury
Add "Apply" button the Saved-status dialog
Is this good?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 25 Oct 2005 06:15:13 +0000 |
parents | 42b5b3015d9e |
children | b72ea98397c5 |
files | src/gtkprefs.c src/gtksavedstatuses.c |
diffstat | 2 files changed, 67 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkprefs.c Tue Oct 25 05:34:13 2005 +0000 +++ b/src/gtkprefs.c Tue Oct 25 06:15:13 2005 +0000 @@ -1663,11 +1663,11 @@ "/gaim/gtk/idle/report", vbox); vbox = gaim_gtk_make_frame (ret, _("Auto-away")); - button = gaim_gtk_prefs_checkbox(_("Set away _when idle"), + button = gaim_gtk_prefs_checkbox(_("Change status when _idle"), "/core/away/away_when_idle", vbox); select = gaim_gtk_prefs_labeled_spin_button(vbox, - _("_Minutes before setting away:"), "/core/away/mins_before_away", + _("_Minutes before changing status:"), "/core/away/mins_before_away", 1, 24 * 60, sg); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_toggle_sensitive), select); @@ -1675,13 +1675,19 @@ hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(vbox), hbox); - label = gtk_label_new_with_mnemonic(_("Away m_essage:")); + label = gtk_label_new_with_mnemonic(_("Change _status to:")); gtk_size_group_add_widget(sg, label); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gaim_gtk_toggle_sensitive), label); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + /* + * TODO: Need to allow users to choose a GaimSavedStatus + * to use when going idle-away. Or figure out a + * better UI for this. + */ + if (!gaim_prefs_get_bool("/core/away/away_when_idle")) { gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
--- a/src/gtksavedstatuses.c Tue Oct 25 05:34:13 2005 +0000 +++ b/src/gtksavedstatuses.c Tue Oct 25 06:15:13 2005 +0000 @@ -42,6 +42,9 @@ enum { + /* A hidden column containing a pointer to the GaimStatusType */ + STATUS_WINDOW_COLUMN_STATUS, + STATUS_WINDOW_COLUMN_TITLE, STATUS_WINDOW_COLUMN_TYPE, STATUS_WINDOW_COLUMN_MESSAGE, @@ -61,6 +64,7 @@ GtkWidget *window; GtkListStore *model; GtkWidget *treeview; + GtkWidget *use_button; GtkWidget *modify_button; GtkWidget *delete_button; } StatusWindow; @@ -128,6 +132,39 @@ } static void +status_window_use_cb(GtkButton *button, StatusWindow *dialog) +{ + GtkTreeSelection *selection; + GtkTreeIter iter; + GaimSavedStatus *saved_status; + GList *list; + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); + + if (gtk_tree_selection_count_selected_rows(selection) != 1) + /* + * This shouldn't happen because the "Use" button should have + * been grayed out. Oh well. + */ + return; + + list = gtk_tree_selection_get_selected_rows(selection, NULL); + + if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), + &iter, list->data)) + { + gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, + STATUS_WINDOW_COLUMN_STATUS, &saved_status, + -1); + + gaim_savedstatus_activate(saved_status); + } + + g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); + g_list_free(list); +} + +static void status_window_add_cb(GtkButton *button, gpointer user_data) { gaim_gtk_status_editor_show(NULL); @@ -137,13 +174,9 @@ status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - char *title; GaimSavedStatus *status; - gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1); - - status = gaim_savedstatus_find(title); - g_free(title); + gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_STATUS, &status, -1); gaim_gtk_status_editor_show(status); } @@ -211,7 +244,7 @@ get_selected_helper(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - *((gboolean *)user_data) = TRUE; + *((gboolean *)user_data)++; } #endif @@ -219,16 +252,17 @@ status_selected_cb(GtkTreeSelection *sel, gpointer user_data) { StatusWindow *dialog = user_data; - gboolean selected = FALSE; + int num_selected; #if GTK_CHECK_VERSION(2,2,0) - selected = (gtk_tree_selection_count_selected_rows(sel) > 0); + num_selected = gtk_tree_selection_count_selected_rows(sel); #else - gtk_tree_selection_selected_foreach(sel, get_selected_helper, &selected); + gtk_tree_selection_selected_foreach(sel, get_selected_helper, &num_selected); #endif - gtk_widget_set_sensitive(dialog->modify_button, selected); - gtk_widget_set_sensitive(dialog->delete_button, selected); + gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1)); + gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0)); + gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0)); } static void @@ -248,6 +282,7 @@ gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, + STATUS_WINDOW_COLUMN_STATUS, saved_status, STATUS_WINDOW_COLUMN_TITLE, title, STATUS_WINDOW_COLUMN_TYPE, type, STATUS_WINDOW_COLUMN_MESSAGE, message, @@ -304,6 +339,7 @@ /* Create the list model */ dialog->model = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS, + G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); @@ -436,6 +472,17 @@ gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox); + /* Use button */ + /* TODO: It might be better if the button said "Use" or "Activate" */ + button = gtk_button_new_from_stock(GTK_STOCK_APPLY); + dialog->use_button = button; + gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); + gtk_widget_set_sensitive(button, FALSE); + gtk_widget_show(button); + + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(status_window_use_cb), dialog); + /* Add button */ button = gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);