Mercurial > pidgin.yaz
changeset 21384:5c26dc790c71
Break creating and removing generic error boxes by account into their own
functions.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Wed, 31 Oct 2007 00:57:26 +0000 |
parents | f02eaf4cc032 |
children | 821dc8ba9e3f |
files | pidgin/gtkblist.c |
diffstat | 1 files changed, 23 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Wed Oct 31 00:32:11 2007 +0000 +++ b/pidgin/gtkblist.c Wed Oct 31 00:57:26 2007 +0000 @@ -4358,10 +4358,10 @@ #define BUTTON_DATA_KEY_ACCOUNT "account" -/* Add some buttons that show connection errors */ -static GtkWidget * -create_connection_error_button(PurpleAccount *account, - const PurpleConnectionErrorInfo *err) +/* Add a button showing the connection error message */ +static void +add_generic_connection_error_button(PurpleAccount *account, + const PurpleConnectionErrorInfo *err) { gchar *escaped, *text; GtkWidget *button, *label, *image, *hbox; @@ -4402,7 +4402,9 @@ account); gtk_widget_show_all(button); - return button; + gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, + FALSE, FALSE, 0); + gtk_widget_show_all(gtkblist->error_buttons); } static gboolean @@ -4416,15 +4418,25 @@ } static void +remove_generic_connection_error_button(PurpleAccount *account) +{ + GtkButton *button; + GList *l = NULL; + GList *children = gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)); + l = g_list_find_custom(children, account, (GCompareFunc) find_account_button); + if (l) { /* it may have already been removed by being clicked on */ + button = GTK_BUTTON(l->data); + remove_error_button(button); + } + g_list_free(children); +} + +static void update_account_error_state(PurpleAccount *account, const PurpleConnectionErrorInfo *old, const PurpleConnectionErrorInfo *new, PidginBuddyList *gtkblist) { - GList *children = NULL; - GList *l = NULL; - GtkWidget *button; - /* For backwards compatibility: */ if (new) pidgin_blist_update_account_error_state(account, new->description); @@ -4432,21 +4444,11 @@ pidgin_blist_update_account_error_state(account, NULL); if (old) { - children = gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)); - l = g_list_find_custom(children, account, (GCompareFunc) find_account_button); - if (l) { /* it may have already been removed by being clicked on */ - button = GTK_WIDGET(l->data); - remove_error_button(GTK_BUTTON(button)); - } - g_list_free(l); - l = NULL; + remove_generic_connection_error_button(account); } if (new) { - button = create_connection_error_button(account, new); - gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, - FALSE, FALSE, 0); - gtk_widget_show_all(gtkblist->error_buttons); + add_generic_connection_error_button(account, new); } }