comparison src/gtkstatusselector.c @ 10188:5709800d1dee

[gaim-migrate @ 11303] I really like this a lot better... hope I'm not stepping on any toes... committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 15 Nov 2004 03:53:56 +0000
parents 5a1fe52036ad
children 0f86175b41a4
comparison
equal deleted inserted replaced
10187:5a1fe52036ad 10188:5709800d1dee
212 212
213 static void 213 static void
214 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector) 214 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector)
215 { 215 {
216 GtkTreeIter iter; 216 GtkTreeIter iter;
217 217 const char *status_type_id;
218 if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo), 218 char *text;
219 GList *l;
220
221 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo),
219 &iter)) 222 &iter))
220 { 223 {
221 const char *status_type_id; 224 return;
222 char *text; 225 }
223 GList *l; 226
224 227 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter,
225 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter, 228 COLUMN_NAME, &text,
226 COLUMN_NAME, &text, 229 COLUMN_STATUS_TYPE_ID, &status_type_id,
227 COLUMN_STATUS_TYPE_ID, &status_type_id, 230 -1);
228 -1); 231
229 232 if (!strcmp(text, _("New status")))
230 if (!strcmp(text, _("New status"))) 233 {
234 /* TODO */
235 }
236 else
237 {
238 const char *message = "";
239 GtkTextBuffer *buffer;
240 gboolean allow_message = FALSE;
241
242 buffer =
243 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry));
244
245 gtk_text_buffer_set_text(buffer, message, -1);
246
247 for (l = gaim_connections_get_all(); l != NULL; l = l->next)
231 { 248 {
232 /* TODO */ 249 GaimConnection *gc = (GaimConnection *)l->data;
250 GaimAccount *account = gaim_connection_get_account(gc);
251 GaimStatusType *status_type;
252
253 status_type = gaim_account_get_status_type(account,
254 status_type_id);
255
256 if (status_type == NULL)
257 continue;
258
259 if (gaim_status_type_get_attr(status_type, "message") != NULL)
260 {
261 gaim_account_set_status(account,
262 "away", TRUE,
263 "message", message,
264 NULL);
265
266 allow_message = TRUE;
267 }
268 else
269 {
270 gaim_account_set_status(account,
271 "away", TRUE,
272 NULL);
273 }
233 } 274 }
275
276 if (allow_message)
277 gtk_widget_show(selector->priv->sw);
234 else 278 else
235 { 279 gtk_widget_hide(selector->priv->sw);
236 const char *message = "";
237 GtkTextBuffer *buffer;
238 gboolean allow_message = FALSE;
239
240 buffer =
241 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry));
242
243 gtk_text_buffer_set_text(buffer, message, -1);
244
245 for (l = gaim_connections_get_all(); l != NULL; l = l->next)
246 {
247 GaimConnection *gc = (GaimConnection *)l->data;
248 GaimAccount *account = gaim_connection_get_account(gc);
249 GaimStatusType *status_type;
250
251 status_type = gaim_account_get_status_type(account,
252 status_type_id);
253
254 if (status_type == NULL)
255 continue;
256
257 if (gaim_status_type_get_attr(status_type, "message") != NULL)
258 {
259 gaim_account_set_status(account,
260 "away", TRUE,
261 "message", message,
262 NULL);
263
264 allow_message = TRUE;
265 }
266 else
267 {
268 gaim_account_set_status(gaim_connection_get_account(gc),
269 "away", TRUE,
270 NULL);
271 }
272 }
273
274 if (allow_message)
275 gtk_widget_show(selector->priv->sw);
276 else
277 gtk_widget_hide(selector->priv->sw);
278 }
279 } 280 }
280 } 281 }
281 282
282 static void 283 static void
283 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector) 284 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector)