comparison src/gtkstatusselector.c @ 10400:6a043ae92db6

[gaim-migrate @ 11631] I'm about to go home for the holidays, so I figured I'd commit this before I left so someone else could pick up on it while I'm gone. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 19 Dec 2004 20:32:32 +0000
parents 5879593a6a10
children ce098e226486
comparison
equal deleted inserted replaced
10399:aab0c9508318 10400:6a043ae92db6
181 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0); 181 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0);
182 gtk_widget_hide(toolbar); 182 gtk_widget_hide(toolbar);
183 183
184 g_signal_connect(G_OBJECT(entry), "key_press_event", 184 g_signal_connect(G_OBJECT(entry), "key_press_event",
185 G_CALLBACK(key_press_cb), selector); 185 G_CALLBACK(key_press_cb), selector);
186 186 #if 0
187 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", 187 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
188 selector, GAIM_CALLBACK(signed_on_off_cb), 188 selector, GAIM_CALLBACK(signed_on_off_cb),
189 selector); 189 selector);
190 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", 190 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
191 selector, GAIM_CALLBACK(signed_on_off_cb), 191 selector, GAIM_CALLBACK(signed_on_off_cb),
192 selector); 192 selector);
193 193 #endif
194 rebuild_list(selector); 194 rebuild_list(selector);
195 } 195 }
196 196
197 static void 197 static void
198 gaim_gtk_status_selector_finalize(GObject *obj) 198 gaim_gtk_status_selector_finalize(GObject *obj)
293 buffer = 293 buffer =
294 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry)); 294 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry));
295 295
296 gtk_text_buffer_set_text(buffer, text, -1); 296 gtk_text_buffer_set_text(buffer, text, -1);
297 297
298 for (l = gaim_connections_get_all(); l != NULL; l = l->next) 298 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
299 { 299 {
300 GaimConnection *gc = (GaimConnection *)l->data; 300 GaimAccount *account = (GaimAccount*)l->data;
301 GaimAccount *account = gaim_connection_get_account(gc);
302 GaimStatusType *status_type; 301 GaimStatusType *status_type;
302
303 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
304 continue;
303 305
304 status_type = gaim_account_get_status_type(account, 306 status_type = gaim_account_get_status_type(account,
305 status_type_id); 307 status_type_id);
306 308
307 if (status_type == NULL) 309 if (status_type == NULL)
308 continue; 310 continue;
309 311
310 if (gaim_status_type_get_attr(status_type, "message") != NULL) 312 if (gaim_status_type_get_attr(status_type, "message") != NULL)
312 allow_message = TRUE; 314 allow_message = TRUE;
313 } 315 }
314 else 316 else
315 { 317 {
316 gaim_account_set_status(account, 318 gaim_account_set_status(account,
317 status_type_id, TRUE, 319 status_type_id, TRUE,
318 NULL); 320 NULL);
319 } 321 }
320 } 322 }
321 323
322 if (allow_message) 324 if (allow_message)
323 { 325 {
351 gchar *message; 353 gchar *message;
352 GList *l; 354 GList *l;
353 355
354 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry)); 356 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry));
355 357
356 for (l = gaim_connections_get_all(); l != NULL; l = l->next) 358 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
357 { 359 {
358 GaimConnection *gc = (GaimConnection *)l->data; 360 GaimAccount *account = (GaimAccount*)l->data;
359 GaimAccount *account = gaim_connection_get_account(gc);
360 GaimStatusType *status_type; 361 GaimStatusType *status_type;
362
363 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
364 continue;
361 365
362 status_type = gaim_account_get_status_type(account, 366 status_type = gaim_account_get_status_type(account,
363 status_type_id); 367 status_type_id);
364 368
365 if (status_type == NULL) 369 if (status_type == NULL)
491 495
492 static void 496 static void
493 rebuild_list(GaimGtkStatusSelector *selector) 497 rebuild_list(GaimGtkStatusSelector *selector)
494 { 498 {
495 gboolean single_prpl = TRUE; 499 gboolean single_prpl = TRUE;
500 GList *accounts;
501 gboolean enabled = FALSE;
496 GaimAccount *first_account = NULL; 502 GaimAccount *first_account = NULL;
497 const char *first_prpl_type = NULL; 503 const char *first_prpl_type = NULL;
498 GList *l; 504 GList *l;
499 505
500 g_return_if_fail(selector != NULL); 506 g_return_if_fail(selector != NULL);
508 selector->priv->menu = gtk_menu_new(); 514 selector->priv->menu = gtk_menu_new();
509 gtk_widget_show(selector->priv->menu); 515 gtk_widget_show(selector->priv->menu);
510 #endif 516 #endif
511 517
512 /* 518 /*
513 * If no accounts are connected then gray ourself out and get 519 * If no accounts are enabled then gray ourself out and get
514 * outta hee. 520 * outta hee.
515 */ 521 */
516 if (gaim_connections_get_all() == NULL) 522 for(accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) {
523 GaimAccount *a = accounts->data;
524 if (gaim_account_get_enabled(a, GAIM_GTK_UI)) {
525 enabled = TRUE;
526 break;
527 }
528 }
529
530 if (enabled == FALSE)
517 { 531 {
518 gtk_widget_set_sensitive(GTK_WIDGET(selector), FALSE); 532 gtk_widget_set_sensitive(GTK_WIDGET(selector), FALSE);
519 return; 533 return;
520 } 534 }
521 gtk_widget_set_sensitive(GTK_WIDGET(selector), TRUE); 535 gtk_widget_set_sensitive(GTK_WIDGET(selector), TRUE);
524 * If the user only has one IM account or one type of IM account 538 * If the user only has one IM account or one type of IM account
525 * connected, they'll see all their statuses. This is ideal for those 539 * connected, they'll see all their statuses. This is ideal for those
526 * who use only one account, or one single protocol. Everyone else 540 * who use only one account, or one single protocol. Everyone else
527 * gets Available and Away and a list of saved statuses. 541 * gets Available and Away and a list of saved statuses.
528 */ 542 */
529 for (l = gaim_connections_get_all(); l != NULL && single_prpl; l = l->next) 543 for (l = gaim_accounts_get_all(); l != NULL && single_prpl; l = l->next)
530 { 544 {
531 GaimConnection *gc = (GaimConnection *)l->data; 545 GaimAccount *account = l->data;
532 GaimAccount *account = gaim_connection_get_account(gc);
533 GaimPluginProtocolInfo *prpl_info; 546 GaimPluginProtocolInfo *prpl_info;
547 GaimPlugin *plugin;
534 const char *basename; 548 const char *basename;
535 549
536 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 550 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
551 continue;
552
553 plugin = gaim_find_prpl(account->protocol_id);
554 if (!plugin)
555 continue;
556
557 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
537 basename = prpl_info->list_icon(account, NULL); 558 basename = prpl_info->list_icon(account, NULL);
538 559
539 if (first_prpl_type == NULL) 560 if (first_prpl_type == NULL)
540 { 561 {
541 first_prpl_type = basename; 562 first_prpl_type = basename;