changeset 11499:6f9fc83ee25c

[gaim-migrate @ 13744] add an account property to the status selector widget. Hopefully I did this right, its been a while. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 10 Sep 2005 21:52:51 +0000
parents ea52fefd3602
children 9fc7d0153332
files src/gtkstatusbox.c src/gtkstatusbox.h
diffstat 2 files changed, 61 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkstatusbox.c	Sat Sep 10 21:10:39 2005 +0000
+++ b/src/gtkstatusbox.c	Sat Sep 10 21:52:51 2005 +0000
@@ -51,6 +51,11 @@
 	NUM_COLUMNS
 };
 
+enum {
+	PROP_0,
+	PROP_ACCOUNT
+};
+
 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass);
 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box);
 
@@ -84,6 +89,39 @@
 }
 
 static void
+gtk_gaim_status_box_get_property(GObject *object, guint param_id,
+                                 GValue *value, GParamSpec *psec)
+{
+	GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object);
+
+	switch (param_id) {
+	case PROP_ACCOUNT:
+		g_value_set_pointer(value, statusbox->account);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec);
+		break;
+	}
+}
+
+static void
+gtk_gaim_status_box_set_property(GObject *object, guint param_id,
+                                 const GValue *value, GParamSpec *pspec)
+{
+	GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object);
+
+	switch (param_id) {
+	case PROP_ACCOUNT:
+		statusbox->account = g_value_get_pointer(value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
+		break;
+	}
+}
+
+
+static void
 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass)
 {
 	GObjectClass *object_class;
@@ -104,6 +142,18 @@
 	container_class->forall = gtk_gaim_status_box_forall;
 
 	object_class = (GObjectClass *)klass;
+
+	object_class->get_property = gtk_gaim_status_box_get_property;
+	object_class->set_property = gtk_gaim_status_box_set_property;
+
+	g_object_class_install_property(object_class,
+	                                PROP_ACCOUNT,
+	                                g_param_spec_pointer("account",
+	                                                     "Account",
+	                                                     "The account, or NULL for all accounts",
+	                                                      G_PARAM_READWRITE
+	                                                     )
+	                               );
 }
 
 static void
@@ -125,7 +175,7 @@
 		title = "";
 
 	if (status_box->error) {
-		text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", 
+		text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>",
 							   title, status_box->error);
 	} else if (status_box->typing) {
 		text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>",
@@ -223,7 +273,7 @@
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL);
 
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE);
-	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); 
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL);
 
@@ -335,6 +385,11 @@
 	return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL);
 }
 
+GtkWidget *
+gtk_gaim_status_box_new_with_account(GaimAccount *account)
+{
+	return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL);
+}
 
 void
 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit)
--- a/src/gtkstatusbox.h	Sat Sep 10 21:10:39 2005 +0000
+++ b/src/gtkstatusbox.h	Sat Sep 10 21:52:51 2005 +0000
@@ -29,6 +29,7 @@
 
 #include <gtk/gtk.h>
 #include "gtkimhtml.h"
+#include "account.h"
 #include <gtk/gtktreemodel.h>
 #include <gtk/gtktreeview.h>
 #if !GTK_CHECK_VERSION(2,6,0)
@@ -59,6 +60,8 @@
 	GtkListStore *store;
 	GtkListStore *dropdown_store;
 
+	GaimAccount *account;
+
 	GtkWidget *vbox, *sw;
 	GtkWidget *imhtml;
 	gboolean imhtml_visible;
@@ -101,6 +104,7 @@
 
 GType         gtk_gaim_status_box_get_type         (void) G_GNUC_CONST;
 GtkWidget    *gtk_gaim_status_box_new              (void);
+GtkWidget    *gtk_gaim_status_box_new_with_account (GaimAccount *);
 
 void
 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit);