Mercurial > pidgin
comparison src/gtkstatusselector.c @ 10191:0f86175b41a4
[gaim-migrate @ 11306]
Minor changes to the status selector:
-Use the imhtml creation helper thing
-Change the if (new status) to check the type_id instead of the type name
(which could theoretically be NULL)
-Only attempt to set away if the away state was chosen
This definitely still doesn't work for oscar. Just by looking at the
code I don't believe the message input works for anything, as is.
Setting "away" apparently works for MSN, maybe other stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 16 Nov 2004 02:22:16 +0000 |
parents | 5709800d1dee |
children | 7369bf2bf593 |
comparison
equal
deleted
inserted
replaced
10190:e67ecadcbe0f | 10191:0f86175b41a4 |
---|---|
34 | 34 |
35 struct _GaimGtkStatusSelectorPrivate | 35 struct _GaimGtkStatusSelectorPrivate |
36 { | 36 { |
37 GtkWidget *combo; | 37 GtkWidget *combo; |
38 GtkWidget *entry; | 38 GtkWidget *entry; |
39 GtkWidget *sw; | 39 GtkWidget *frame; |
40 | 40 |
41 #if GTK_CHECK_VERSION(2,4,0) | 41 #if GTK_CHECK_VERSION(2,4,0) |
42 GtkListStore *model; | 42 GtkListStore *model; |
43 #endif | 43 #endif |
44 }; | 44 }; |
109 static void | 109 static void |
110 gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector) | 110 gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector) |
111 { | 111 { |
112 GtkWidget *combo; | 112 GtkWidget *combo; |
113 GtkWidget *entry; | 113 GtkWidget *entry; |
114 GtkWidget *sw; | 114 GtkWidget *toolbar; |
115 GtkWidget *frame; | |
115 #if GTK_CHECK_VERSION(2,4,0) | 116 #if GTK_CHECK_VERSION(2,4,0) |
116 GtkCellRenderer *renderer; | 117 GtkCellRenderer *renderer; |
117 #endif | 118 #endif |
118 | 119 |
119 selector->priv = g_new0(GaimGtkStatusSelectorPrivate, 1); | 120 selector->priv = g_new0(GaimGtkStatusSelectorPrivate, 1); |
148 #endif /* GTK < 2.4.0 */ | 149 #endif /* GTK < 2.4.0 */ |
149 | 150 |
150 gtk_widget_show(combo); | 151 gtk_widget_show(combo); |
151 gtk_box_pack_start(GTK_BOX(selector), combo, FALSE, FALSE, 0); | 152 gtk_box_pack_start(GTK_BOX(selector), combo, FALSE, FALSE, 0); |
152 | 153 |
153 selector->priv->sw = sw = gtk_scrolled_window_new(NULL, NULL); | 154 frame = gaim_gtk_create_imhtml(TRUE, &entry, &toolbar); |
154 gtk_box_pack_start(GTK_BOX(selector), sw, TRUE, TRUE, 0); | 155 selector->priv->entry = entry; |
155 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | 156 selector->priv->frame = frame; |
156 GTK_SHADOW_IN); | 157 gtk_widget_set_name(entry, "gaim_gtkstatusselector_imhtml"); |
157 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | 158 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0); |
158 GTK_POLICY_NEVER, | 159 gtk_widget_hide(toolbar); |
159 GTK_POLICY_AUTOMATIC); | |
160 | |
161 selector->priv->entry = entry = gtk_imhtml_new(NULL, NULL); | |
162 gtk_widget_show(entry); | |
163 gtk_container_add(GTK_CONTAINER(sw), entry); | |
164 gtk_widget_set_name(entry, "gaim_gtk_status_selector_imhtml"); | |
165 gtk_imhtml_set_editable(GTK_IMHTML(entry), TRUE); | |
166 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(entry), GTK_WRAP_WORD_CHAR); | |
167 | |
168 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
169 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(entry)); | |
170 | 160 |
171 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | 161 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
172 selector, GAIM_CALLBACK(signed_on_off_cb), | 162 selector, GAIM_CALLBACK(signed_on_off_cb), |
173 selector); | 163 selector); |
174 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | 164 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
213 static void | 203 static void |
214 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector) | 204 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector) |
215 { | 205 { |
216 GtkTreeIter iter; | 206 GtkTreeIter iter; |
217 const char *status_type_id; | 207 const char *status_type_id; |
218 char *text; | 208 const char *text; |
219 GList *l; | 209 GList *l; |
220 | 210 |
221 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo), | 211 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo), |
222 &iter)) | 212 &iter)) |
223 { | 213 { |
227 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter, | 217 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter, |
228 COLUMN_NAME, &text, | 218 COLUMN_NAME, &text, |
229 COLUMN_STATUS_TYPE_ID, &status_type_id, | 219 COLUMN_STATUS_TYPE_ID, &status_type_id, |
230 -1); | 220 -1); |
231 | 221 |
232 if (!strcmp(text, _("New status"))) | 222 if (status_type_id == NULL) |
223 { | |
224 if (!strcmp(text, _("New Status"))) | |
225 { | |
226 /* TODO */ | |
227 } | |
228 } | |
229 else if (!strcmp(status_type_id, "available")) | |
233 { | 230 { |
234 /* TODO */ | 231 /* TODO */ |
235 } | 232 } |
236 else | 233 else if (!strcmp(status_type_id, "away")) |
237 { | 234 { |
238 const char *message = ""; | 235 const char *message = ""; |
239 GtkTextBuffer *buffer; | 236 GtkTextBuffer *buffer; |
240 gboolean allow_message = FALSE; | 237 gboolean allow_message = FALSE; |
241 | 238 |
272 NULL); | 269 NULL); |
273 } | 270 } |
274 } | 271 } |
275 | 272 |
276 if (allow_message) | 273 if (allow_message) |
277 gtk_widget_show(selector->priv->sw); | 274 gtk_widget_show(selector->priv->frame); |
278 else | 275 else |
279 gtk_widget_hide(selector->priv->sw); | 276 gtk_widget_hide(selector->priv->frame); |
280 } | 277 } |
281 } | 278 } |
282 | 279 |
283 static void | 280 static void |
284 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector) | 281 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector) |
403 add_item(selector, "available", _("Available"), | 400 add_item(selector, "available", _("Available"), |
404 load_icon("online.png")); | 401 load_icon("online.png")); |
405 add_item(selector, "away", _("Away"), load_icon("away.png")); | 402 add_item(selector, "away", _("Away"), load_icon("away.png")); |
406 } | 403 } |
407 | 404 |
405 /* TODO: Add saved statuses here? */ | |
406 | |
408 add_item(selector, NULL, _("New Status"), | 407 add_item(selector, NULL, _("New Status"), |
409 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW, | 408 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW, |
410 GTK_ICON_SIZE_MENU, NULL)); | 409 GTK_ICON_SIZE_MENU, NULL)); |
411 } | 410 } |
412 | 411 |