From 4bda0f453caf3779a6d8e6f3e1bd201b2549b494 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Wed, 8 Aug 2001 18:24:54 +0000 Subject: New function. Set the sensitivity of the subscribe buttons based on 2001-08-08 Peter Williams * subscribe-dialog.c (sc_selection_changed): New function. Set the sensitivity of the subscribe buttons based on whether any folders are selected. (menu_item_selected): If getting the widget for the first time, hook up sc_selection_changed. svn path=/trunk/; revision=11800 --- mail/ChangeLog | 8 ++++++++ mail/subscribe-dialog.c | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/mail/ChangeLog b/mail/ChangeLog index 83db8c5aa9..5d43a91671 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,11 @@ +2001-08-08 Peter Williams + + * subscribe-dialog.c (sc_selection_changed): New function. Set the + sensitivity of the subscribe buttons based on whether any folders + are selected. + (menu_item_selected): If getting the widget for the first time, + hook up sc_selection_changed. + 2001-08-08 Peter Williams * mail-ops.c (mail_update_subfolders): Change this gtk_object_ref diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index c075bbfa00..7ab8ba38df 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -1313,6 +1313,21 @@ kill_default_view (SubscribeDialog *sc) gtk_widget_set_sensitive (sc->priv->refresh_button, TRUE); } +static void +sc_selection_changed (GtkObject *obj, gpointer user_data) +{ + SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); + gboolean sensitive; + + if (e_selection_model_selected_count (E_SELECTION_MODEL (obj))) + sensitive = TRUE; + else + sensitive = FALSE; + + gtk_widget_set_sensitive (sc->priv->sub_button, sensitive); + gtk_widget_set_sensitive (sc->priv->unsub_button, sensitive); +} + static void menu_item_selected (GtkMenuItem *item, gpointer user_data) { @@ -1323,9 +1338,16 @@ menu_item_selected (GtkMenuItem *item, gpointer user_data) if (sd->widget == NULL) { GtkWidget *widget; + ESelectionModel *esm; + ETree *tree; widget = store_data_get_widget (sd); gtk_box_pack_start (GTK_BOX (sc->priv->hbox), widget, TRUE, TRUE, 0); + + tree = e_tree_scrolled_get_tree (E_TREE_SCROLLED (widget)); + esm = e_tree_get_selection_model (tree); + gtk_signal_connect (GTK_OBJECT (esm), "selection_changed", sc_selection_changed, sc); + sc_selection_changed ((GtkObject *)esm, sc); } if (sc->priv->current_widget == sc->priv->default_widget) -- cgit