Mercurial > pidgin.yaz
comparison src/gtkstatusbox.c @ 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 | 62db025d3eb0 |
children | 1116993aadd2 |
comparison
equal
deleted
inserted
replaced
11498:ea52fefd3602 | 11499:6f9fc83ee25c |
---|---|
49 DESC_COLUMN, | 49 DESC_COLUMN, |
50 TYPE_COLUMN, | 50 TYPE_COLUMN, |
51 NUM_COLUMNS | 51 NUM_COLUMNS |
52 }; | 52 }; |
53 | 53 |
54 enum { | |
55 PROP_0, | |
56 PROP_ACCOUNT | |
57 }; | |
58 | |
54 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); | 59 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); |
55 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); | 60 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); |
56 | 61 |
57 GType | 62 GType |
58 gtk_gaim_status_box_get_type (void) | 63 gtk_gaim_status_box_get_type (void) |
82 | 87 |
83 return status_box_type; | 88 return status_box_type; |
84 } | 89 } |
85 | 90 |
86 static void | 91 static void |
92 gtk_gaim_status_box_get_property(GObject *object, guint param_id, | |
93 GValue *value, GParamSpec *psec) | |
94 { | |
95 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
96 | |
97 switch (param_id) { | |
98 case PROP_ACCOUNT: | |
99 g_value_set_pointer(value, statusbox->account); | |
100 break; | |
101 default: | |
102 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec); | |
103 break; | |
104 } | |
105 } | |
106 | |
107 static void | |
108 gtk_gaim_status_box_set_property(GObject *object, guint param_id, | |
109 const GValue *value, GParamSpec *pspec) | |
110 { | |
111 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
112 | |
113 switch (param_id) { | |
114 case PROP_ACCOUNT: | |
115 statusbox->account = g_value_get_pointer(value); | |
116 break; | |
117 default: | |
118 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
119 break; | |
120 } | |
121 } | |
122 | |
123 | |
124 static void | |
87 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) | 125 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
88 { | 126 { |
89 GObjectClass *object_class; | 127 GObjectClass *object_class; |
90 GtkWidgetClass *widget_class; | 128 GtkWidgetClass *widget_class; |
91 GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; | 129 GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; |
102 | 140 |
103 combo_box_forall = container_class->forall; | 141 combo_box_forall = container_class->forall; |
104 container_class->forall = gtk_gaim_status_box_forall; | 142 container_class->forall = gtk_gaim_status_box_forall; |
105 | 143 |
106 object_class = (GObjectClass *)klass; | 144 object_class = (GObjectClass *)klass; |
145 | |
146 object_class->get_property = gtk_gaim_status_box_get_property; | |
147 object_class->set_property = gtk_gaim_status_box_set_property; | |
148 | |
149 g_object_class_install_property(object_class, | |
150 PROP_ACCOUNT, | |
151 g_param_spec_pointer("account", | |
152 "Account", | |
153 "The account, or NULL for all accounts", | |
154 G_PARAM_READWRITE | |
155 ) | |
156 ); | |
107 } | 157 } |
108 | 158 |
109 static void | 159 static void |
110 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | 160 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) |
111 { | 161 { |
123 title = status_box->title; | 173 title = status_box->title; |
124 if (!title) | 174 if (!title) |
125 title = ""; | 175 title = ""; |
126 | 176 |
127 if (status_box->error) { | 177 if (status_box->error) { |
128 text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", | 178 text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", |
129 title, status_box->error); | 179 title, status_box->error); |
130 } else if (status_box->typing) { | 180 } else if (status_box->typing) { |
131 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", | 181 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
132 title, aa_color, _("Typing")); | 182 title, aa_color, _("Typing")); |
133 } else if (status_box->connecting) { | 183 } else if (status_box->connecting) { |
221 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); | 271 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
222 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); | 272 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
223 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | 273 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); |
224 | 274 |
225 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | 275 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
226 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); | 276 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
227 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); | 277 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
228 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | 278 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); |
229 | 279 |
230 status_box->vbox = gtk_vbox_new(0, FALSE); | 280 status_box->vbox = gtk_vbox_new(0, FALSE); |
231 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | 281 status_box->imhtml = gtk_imhtml_new(NULL, NULL); |
333 gtk_gaim_status_box_new() | 383 gtk_gaim_status_box_new() |
334 { | 384 { |
335 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | 385 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); |
336 } | 386 } |
337 | 387 |
388 GtkWidget * | |
389 gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
390 { | |
391 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
392 } | |
338 | 393 |
339 void | 394 void |
340 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) | 395 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) |
341 { | 396 { |
342 GtkTreeIter iter; | 397 GtkTreeIter iter; |