comparison pidgin/gtkblist.c @ 17044:c28f4593f723

Pack connection error buttons the same way the statusbox is. Fixes #120
author Sean Egan <seanegan@gmail.com>
date Fri, 11 May 2007 21:25:24 +0000
parents 777cdaa3b904
children 0be41b604566
comparison
equal deleted inserted replaced
17043:8ad7750b0391 17044:c28f4593f723
3955 enabled ? PURPLE_CALLBACK(purple_account_connect) : 3955 enabled ? PURPLE_CALLBACK(purple_account_connect) :
3956 PURPLE_CALLBACK(ce_enable_account_cb)); 3956 PURPLE_CALLBACK(ce_enable_account_cb));
3957 g_free(primary); 3957 g_free(primary);
3958 gtk_widget_destroy(GTK_WIDGET(widget)); 3958 gtk_widget_destroy(GTK_WIDGET(widget));
3959 g_hash_table_remove(gtkblist->connection_errors, account); 3959 g_hash_table_remove(gtkblist->connection_errors, account);
3960 if (gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)) == NULL) {
3961 gtk_widget_hide(gtkblist->error_buttons);
3962 }
3960 } 3963 }
3961 3964
3962 /* Add some buttons that show connection errors */ 3965 /* Add some buttons that show connection errors */
3963 static void 3966 static void
3964 create_connection_error_buttons(gpointer key, gpointer value, 3967 create_connection_error_buttons(gpointer key, gpointer value,
3975 text = g_strdup_printf(_("<span color=\"red\">%s disconnected: %s</span>"), 3978 text = g_strdup_printf(_("<span color=\"red\">%s disconnected: %s</span>"),
3976 purple_account_get_username(account), 3979 purple_account_get_username(account),
3977 escaped); 3980 escaped);
3978 g_free(escaped); 3981 g_free(escaped);
3979 3982
3980 hbox = gtk_hbox_new(FALSE, 0); 3983 hbox = gtk_hbox_new(FALSE, 6);
3981 3984
3982 /* Create the icon */ 3985 /* Create the icon */
3983 if ((status_type = purple_account_get_status_type_with_primitive(account, 3986 if ((status_type = purple_account_get_status_type_with_primitive(account,
3984 PURPLE_STATUS_OFFLINE))) { 3987 PURPLE_STATUS_OFFLINE))) {
3985 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); 3988 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
3986 if (pixbuf != NULL) { 3989 if (pixbuf != NULL) {
3987 image = gtk_image_new_from_pixbuf(pixbuf); 3990 image = gtk_image_new_from_pixbuf(pixbuf);
3988 g_object_unref(pixbuf); 3991 g_object_unref(pixbuf);
3989 3992
3990 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 3993 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
3991 PIDGIN_HIG_BOX_SPACE);
3992 } 3994 }
3993 } 3995 }
3994 3996
3995 /* Create the text */ 3997 /* Create the text */
3996 label = gtk_label_new(""); 3998 label = gtk_label_new("");
3997 gtk_label_set_markup(GTK_LABEL(label), text); 3999 gtk_label_set_markup(GTK_LABEL(label), text);
3998 g_free(text); 4000 g_free(text);
3999 #if GTK_CHECK_VERSION(2,6,0) 4001 #if GTK_CHECK_VERSION(2,6,0)
4000 g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL); 4002 g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
4001 #endif 4003 #endif
4002 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 4004 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
4003 PIDGIN_HIG_BOX_SPACE);
4004 4005
4005 /* Create the actual button and put the icon and text on it */ 4006 /* Create the actual button and put the icon and text on it */
4006 button = gtk_button_new(); 4007 button = gtk_button_new();
4007 gtk_container_add(GTK_CONTAINER(button), hbox); 4008 gtk_container_add(GTK_CONTAINER(button), hbox);
4008 g_signal_connect(G_OBJECT(button), "clicked", 4009 g_signal_connect(G_OBJECT(button), "clicked",
4009 G_CALLBACK(connection_error_button_clicked_cb), 4010 G_CALLBACK(connection_error_button_clicked_cb),
4010 account); 4011 account);
4011 gtk_widget_show_all(button); 4012 gtk_widget_show_all(button);
4012 gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, 4013 gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button,
4013 FALSE, FALSE, 0); 4014 FALSE, FALSE, 0);
4015 gtk_widget_show_all(gtkblist->error_buttons);
4014 } 4016 }
4015 4017
4016 void 4018 void
4017 pidgin_blist_update_account_error_state(PurpleAccount *account, const char *text) 4019 pidgin_blist_update_account_error_state(PurpleAccount *account, const char *text)
4018 { 4020 {
4474 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->scrollbook, FALSE, FALSE, 0); 4476 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->scrollbook, FALSE, FALSE, 0);
4475 4477
4476 /* Create an empty vbox used for showing connection errors */ 4478 /* Create an empty vbox used for showing connection errors */
4477 gtkblist->error_buttons = gtk_vbox_new(FALSE, 0); 4479 gtkblist->error_buttons = gtk_vbox_new(FALSE, 0);
4478 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0); 4480 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0);
4479 4481 gtk_container_set_border_width(GTK_CONTAINER(gtkblist->error_buttons), 3);
4482
4480 /* Add the statusbox */ 4483 /* Add the statusbox */
4481 gtkblist->statusbox = pidgin_status_box_new(); 4484 gtkblist->statusbox = pidgin_status_box_new();
4482 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); 4485 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0);
4483 gtk_widget_set_name(gtkblist->statusbox, "pidgin_blist_statusbox"); 4486 gtk_widget_set_name(gtkblist->statusbox, "pidgin_blist_statusbox");
4484 gtk_container_set_border_width(GTK_CONTAINER(gtkblist->statusbox), 3); 4487 gtk_container_set_border_width(GTK_CONTAINER(gtkblist->statusbox), 3);
4571 purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", 4574 purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation",
4572 gtkblist, PURPLE_CALLBACK(conversation_deleting_cb), 4575 gtkblist, PURPLE_CALLBACK(conversation_deleting_cb),
4573 gtkblist); 4576 gtkblist);
4574 4577
4575 gtk_widget_hide(gtkblist->headline_hbox); 4578 gtk_widget_hide(gtkblist->headline_hbox);
4579 gtk_widget_hide(gtkblist->error_buttons);
4576 4580
4577 /* emit our created signal */ 4581 /* emit our created signal */
4578 purple_signal_emit(handle, "gtkblist-created", list); 4582 purple_signal_emit(handle, "gtkblist-created", list);
4579 } 4583 }
4580 4584