changeset 11960:082a2a9aa998

[gaim-migrate @ 14251] commit what i was working on, as it shouldn't effect anything. I'll try to get this closer to finished tonight. Btw, what am I supposed to do with the return value of gaim_signal_connect()? None of the disconnect functions seem to take it. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Thu, 03 Nov 2005 15:10:01 +0000
parents 6f8869d95c09
children 8c7eb5245bb9
files src/gtkstatusbox.c src/gtkstatusbox.h
diffstat 2 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkstatusbox.c	Thu Nov 03 13:49:23 2005 +0000
+++ b/src/gtkstatusbox.c	Thu Nov 03 15:10:01 2005 +0000
@@ -112,6 +112,12 @@
 }
 
 static void
+account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus, GtkGaimStatusBox* status_box)
+{
+	/*update_to_reflect_current_status(status_box);*/
+}
+
+static void
 gtk_gaim_status_box_set_property(GObject *object, guint param_id,
                                  const GValue *value, GParamSpec *pspec)
 {
@@ -120,6 +126,14 @@
 	switch (param_id) {
 	case PROP_ACCOUNT:
 		statusbox->account = g_value_get_pointer(value);
+
+		/* FIXME: call this in the destroy function too, if we had one */
+		if (0 && statusbox->status_changed_signal)
+			;/*gaim_signals_disconnect_by_handle(statusbox->status_changed_signal);*/
+		if (statusbox->account)
+			statusbox->status_changed_signal = gaim_signal_connect(gaim_accounts_get_handle(), "account_status_changed",
+			                                                       statusbox, GAIM_CALLBACK(account_status_changed_cb),
+			                                                       statusbox);
 		gtk_gaim_status_box_regenerate(statusbox);
 		break;
 	default:
@@ -183,6 +197,7 @@
 	if (!title)
 		title = "";
 
+
 	if (status_box->error) {
 		text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>",
 							   title, status_box->error);
@@ -199,6 +214,13 @@
 		text = g_strdup_printf("%s", title);
 	}
 
+	if (status_box->account) {
+		char *text2 = g_strdup_printf("%s\n<span size=\"smaller\">%s</span>", gaim_account_get_username(status_box->account), text);
+		g_free(text);
+		text = text2;
+	}
+
+
 	if (status_box->connecting)
 		pixbuf = status_box->connecting_pixbufs[status_box->connecting_index];
 	else if (status_box->error)
@@ -390,6 +412,7 @@
 									gaim_status_type_get_name(status_type),
 									NULL);
 		}
+		gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); /* set something active to avoid blowing up */
 	}
 
 }
@@ -739,7 +762,7 @@
 	GtkGaimStatusBoxItemType type;
 	char *text, *sec_text;
 	GdkPixbuf *pixbuf;
-	GList *accounts, *node;
+	GList *accounts = NULL, *node;
 
 	status_box = GTK_GAIM_STATUS_BOX(box);
 
@@ -781,9 +804,13 @@
 
 	/*
 	 * Show the message box whenever 'type' allows for a
-	 * message attribute on any protocol that is enabled.
+	 * message attribute on any protocol that is enabled,
+	 * or our protocol, if we have account set
 	 */
-	accounts = gaim_accounts_get_all_active();
+	if (status_box->account)
+		accounts = g_list_prepend(accounts, status_box->account);
+	else
+		accounts = gaim_accounts_get_all_active();
 	status_box->imhtml_visible = FALSE;
 	for (node = accounts; node != NULL; node = node->next)
 	{
--- a/src/gtkstatusbox.h	Thu Nov 03 13:49:23 2005 +0000
+++ b/src/gtkstatusbox.h	Thu Nov 03 15:10:01 2005 +0000
@@ -114,6 +114,8 @@
 	char *title;
 	char *desc;
 	char *error;
+
+	gulong status_changed_signal;
 };
 
 struct _GtkGaimStatusBoxClass