Mercurial > pidgin.yaz
comparison pidgin/gtkdocklet.c @ 15501:d75099d2567e
gaim_gtk to pidgin. I hope
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 03 Feb 2007 07:23:11 +0000 |
parents | 5fe8042783c1 |
children | 6fde15c1dcfc |
comparison
equal
deleted
inserted
replaced
15500:45ecefd0ce3a | 15501:d75099d2567e |
---|---|
91 get_pending_list(guint max) | 91 get_pending_list(guint max) |
92 { | 92 { |
93 GList *l_im = NULL; | 93 GList *l_im = NULL; |
94 GList *l_chat = NULL; | 94 GList *l_chat = NULL; |
95 | 95 |
96 l_im = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, | 96 l_im = pidgin_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, |
97 GAIM_UNSEEN_TEXT, | 97 GAIM_UNSEEN_TEXT, |
98 FALSE, max); | 98 FALSE, max); |
99 | 99 |
100 l_chat = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_CHAT, | 100 l_chat = pidgin_conversations_find_unseen_list(GAIM_CONV_TYPE_CHAT, |
101 GAIM_UNSEEN_NICK, | 101 GAIM_UNSEEN_NICK, |
102 FALSE, max); | 102 FALSE, max); |
103 | 103 |
104 if (l_im != NULL && l_chat != NULL) | 104 if (l_im != NULL && l_chat != NULL) |
105 return g_list_concat(l_im, l_chat); | 105 return g_list_concat(l_im, l_chat); |
142 /* set tooltip if messages are pending */ | 142 /* set tooltip if messages are pending */ |
143 if (ui_ops->set_tooltip) { | 143 if (ui_ops->set_tooltip) { |
144 GString *tooltip_text = g_string_new(""); | 144 GString *tooltip_text = g_string_new(""); |
145 for (l = convs, count = 0 ; l != NULL ; l = l->next, count++) { | 145 for (l = convs, count = 0 ; l != NULL ; l = l->next, count++) { |
146 if (GAIM_IS_GTK_CONVERSATION(l->data)) { | 146 if (GAIM_IS_GTK_CONVERSATION(l->data)) { |
147 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION((GaimConversation *)l->data); | 147 PidginConversation *gtkconv = PIDGIN_CONVERSATION((GaimConversation *)l->data); |
148 if (count == DOCKLET_TOOLTIP_LINE_LIMIT - 1) | 148 if (count == DOCKLET_TOOLTIP_LINE_LIMIT - 1) |
149 g_string_append(tooltip_text, _("Right-click for more unread messages...\n")); | 149 g_string_append(tooltip_text, _("Right-click for more unread messages...\n")); |
150 else | 150 else |
151 g_string_append_printf(tooltip_text, | 151 g_string_append_printf(tooltip_text, |
152 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), | 152 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), |
185 DockletStatus tmpstatus = DOCKLET_STATUS_OFFLINE; | 185 DockletStatus tmpstatus = DOCKLET_STATUS_OFFLINE; |
186 | 186 |
187 GaimAccount *account = (GaimAccount*)l->data; | 187 GaimAccount *account = (GaimAccount*)l->data; |
188 GaimStatus *account_status; | 188 GaimStatus *account_status; |
189 | 189 |
190 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) | 190 if (!gaim_account_get_enabled(account, PIDGIN_UI)) |
191 continue; | 191 continue; |
192 | 192 |
193 if (gaim_account_is_disconnected(account)) | 193 if (gaim_account_is_disconnected(account)) |
194 continue; | 194 continue; |
195 | 195 |
304 if (!strcmp(val, "always")) { | 304 if (!strcmp(val, "always")) { |
305 if (ui_ops->create) { | 305 if (ui_ops->create) { |
306 if (!visible) | 306 if (!visible) |
307 ui_ops->create(); | 307 ui_ops->create(); |
308 else if (!visibility_manager) { | 308 else if (!visibility_manager) { |
309 gaim_gtk_blist_visibility_manager_add(); | 309 pidgin_blist_visibility_manager_add(); |
310 visibility_manager = TRUE; | 310 visibility_manager = TRUE; |
311 } | 311 } |
312 } | 312 } |
313 } else if (!strcmp(val, "never")) { | 313 } else if (!strcmp(val, "never")) { |
314 if (visible && ui_ops->destroy) | 314 if (visible && ui_ops->destroy) |
315 ui_ops->destroy(); | 315 ui_ops->destroy(); |
316 } else { | 316 } else { |
317 if (visibility_manager) { | 317 if (visibility_manager) { |
318 gaim_gtk_blist_visibility_manager_remove(); | 318 pidgin_blist_visibility_manager_remove(); |
319 visibility_manager = FALSE; | 319 visibility_manager = FALSE; |
320 } | 320 } |
321 docklet_update_status(); | 321 docklet_update_status(); |
322 } | 322 } |
323 | 323 |
384 static void | 384 static void |
385 show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data) | 385 show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data) |
386 { | 386 { |
387 GaimSavedStatus *saved_status; | 387 GaimSavedStatus *saved_status; |
388 saved_status = gaim_savedstatus_get_current(); | 388 saved_status = gaim_savedstatus_get_current(); |
389 gaim_gtk_status_editor_show(FALSE, | 389 pidgin_status_editor_show(FALSE, |
390 gaim_savedstatus_is_transient(saved_status) ? saved_status : NULL); | 390 gaim_savedstatus_is_transient(saved_status) ? saved_status : NULL); |
391 } | 391 } |
392 | 392 |
393 static void | 393 static void |
394 activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) | 394 activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) |
434 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | 434 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
435 | 435 |
436 if (sf) | 436 if (sf) |
437 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | 437 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
438 | 438 |
439 pixbuf = gaim_gtk_create_gaim_icon_with_status(primitive, 0.5); | 439 pixbuf = pidgin_create_gaim_icon_with_status(primitive, 0.5); |
440 image = gtk_image_new_from_pixbuf(pixbuf); | 440 image = gtk_image_new_from_pixbuf(pixbuf); |
441 g_object_unref(pixbuf); | 441 g_object_unref(pixbuf); |
442 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | 442 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); |
443 | 443 |
444 gtk_widget_show_all(menuitem); | 444 gtk_widget_show_all(menuitem); |
487 g_list_free(popular_statuses); | 487 g_list_free(popular_statuses); |
488 | 488 |
489 gaim_separator(submenu); | 489 gaim_separator(submenu); |
490 | 490 |
491 new_menu_item_with_gaim_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); | 491 new_menu_item_with_gaim_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); |
492 new_menu_item_with_gaim_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(gaim_gtk_status_window_show), NULL, 0, 0, NULL); | 492 new_menu_item_with_gaim_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); |
493 | 493 |
494 return menuitem; | 494 return menuitem; |
495 } | 495 } |
496 | 496 |
497 static void | 497 static void |
518 if (l == NULL) { | 518 if (l == NULL) { |
519 gtk_widget_set_sensitive(menuitem, FALSE); | 519 gtk_widget_set_sensitive(menuitem, FALSE); |
520 gaim_debug_warning("docklet", | 520 gaim_debug_warning("docklet", |
521 "status indicates messages pending, but no conversations with unseen messages were found."); | 521 "status indicates messages pending, but no conversations with unseen messages were found."); |
522 } else { | 522 } else { |
523 gaim_gtk_conversations_fill_menu(submenu, l); | 523 pidgin_conversations_fill_menu(submenu, l); |
524 g_list_free(l); | 524 g_list_free(l); |
525 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | 525 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
526 } | 526 } |
527 } else { | 527 } else { |
528 gtk_widget_set_sensitive(menuitem, FALSE); | 528 gtk_widget_set_sensitive(menuitem, FALSE); |
529 } | 529 } |
530 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | 530 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
531 | 531 |
532 gaim_separator(menu); | 532 gaim_separator(menu); |
533 | 533 |
534 menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL); | 534 menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(pidgindialogs_im), NULL, 0, 0, NULL); |
535 if (status == DOCKLET_STATUS_OFFLINE) | 535 if (status == DOCKLET_STATUS_OFFLINE) |
536 gtk_widget_set_sensitive(menuitem, FALSE); | 536 gtk_widget_set_sensitive(menuitem, FALSE); |
537 | 537 |
538 menuitem = docklet_status_submenu(); | 538 menuitem = docklet_status_submenu(); |
539 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | 539 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
540 | 540 |
541 gaim_separator(menu); | 541 gaim_separator(menu); |
542 | 542 |
543 gaim_new_item_from_stock(menu, _("Accounts"), GAIM_STOCK_ACCOUNTS, G_CALLBACK(gaim_gtk_accounts_window_show), NULL, 0, 0, NULL); | 543 gaim_new_item_from_stock(menu, _("Accounts"), GAIM_STOCK_ACCOUNTS, G_CALLBACK(pidgin_accounts_window_show), NULL, 0, 0, NULL); |
544 gaim_new_item_from_stock(menu, _("Plugins"), GAIM_STOCK_PLUGIN, G_CALLBACK(gaim_gtk_plugin_dialog_show), NULL, 0, 0, NULL); | 544 gaim_new_item_from_stock(menu, _("Plugins"), GAIM_STOCK_PLUGIN, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL); |
545 gaim_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(gaim_gtk_prefs_show), NULL, 0, 0, NULL); | 545 gaim_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL); |
546 | 546 |
547 gaim_separator(menu); | 547 gaim_separator(menu); |
548 | 548 |
549 menuitem = gtk_check_menu_item_new_with_label(_("Mute Sounds")); | 549 menuitem = gtk_check_menu_item_new_with_label(_("Mute Sounds")); |
550 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | 550 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gaim_prefs_get_bool("/gaim/gtk/sound/mute")); |
578 | 578 |
579 /************************************************************************** | 579 /************************************************************************** |
580 * public api for ui_ops | 580 * public api for ui_ops |
581 **************************************************************************/ | 581 **************************************************************************/ |
582 void | 582 void |
583 gaim_gtk_docklet_clicked(int button_type) | 583 pidgin_docklet_clicked(int button_type) |
584 { | 584 { |
585 switch (button_type) { | 585 switch (button_type) { |
586 case 1: | 586 case 1: |
587 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) { | 587 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) { |
588 GList *l = get_pending_list(1); | 588 GList *l = get_pending_list(1); |
589 if (l != NULL) { | 589 if (l != NULL) { |
590 gaim_gtkconv_present_conversation((GaimConversation *)l->data); | 590 pidginconv_present_conversation((GaimConversation *)l->data); |
591 g_list_free(l); | 591 g_list_free(l); |
592 } | 592 } |
593 } else { | 593 } else { |
594 gaim_gtk_blist_toggle_visibility(); | 594 pidgin_blist_toggle_visibility(); |
595 } | 595 } |
596 break; | 596 break; |
597 case 3: | 597 case 3: |
598 docklet_menu(); | 598 docklet_menu(); |
599 break; | 599 break; |
600 } | 600 } |
601 } | 601 } |
602 | 602 |
603 void | 603 void |
604 gaim_gtk_docklet_embedded() | 604 pidgin_docklet_embedded() |
605 { | 605 { |
606 if (!visibility_manager | 606 if (!visibility_manager |
607 && strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "pending")) { | 607 && strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "pending")) { |
608 gaim_gtk_blist_visibility_manager_add(); | 608 pidgin_blist_visibility_manager_add(); |
609 visibility_manager = TRUE; | 609 visibility_manager = TRUE; |
610 } | 610 } |
611 visible = TRUE; | 611 visible = TRUE; |
612 docklet_update_status(); | 612 docklet_update_status(); |
613 if (ui_ops && ui_ops->update_icon) | 613 if (ui_ops && ui_ops->update_icon) |
614 ui_ops->update_icon(status); | 614 ui_ops->update_icon(status); |
615 } | 615 } |
616 | 616 |
617 void | 617 void |
618 gaim_gtk_docklet_remove() | 618 pidgin_docklet_remove() |
619 { | 619 { |
620 if (visible) { | 620 if (visible) { |
621 if (visibility_manager) { | 621 if (visibility_manager) { |
622 gaim_gtk_blist_visibility_manager_remove(); | 622 pidgin_blist_visibility_manager_remove(); |
623 visibility_manager = FALSE; | 623 visibility_manager = FALSE; |
624 } | 624 } |
625 if (docklet_blinking_timer) { | 625 if (docklet_blinking_timer) { |
626 g_source_remove(docklet_blinking_timer); | 626 g_source_remove(docklet_blinking_timer); |
627 docklet_blinking_timer = 0; | 627 docklet_blinking_timer = 0; |
630 status = DOCKLET_STATUS_OFFLINE; | 630 status = DOCKLET_STATUS_OFFLINE; |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 void | 634 void |
635 gaim_gtk_docklet_set_ui_ops(struct docklet_ui_ops *ops) | 635 pidgin_docklet_set_ui_ops(struct docklet_ui_ops *ops) |
636 { | 636 { |
637 ui_ops = ops; | 637 ui_ops = ops; |
638 } | 638 } |
639 | 639 |
640 void* | 640 void* |
641 gaim_gtk_docklet_get_handle() | 641 pidgin_docklet_get_handle() |
642 { | 642 { |
643 static int i; | 643 static int i; |
644 return &i; | 644 return &i; |
645 } | 645 } |
646 | 646 |
647 void | 647 void |
648 gaim_gtk_docklet_init() | 648 pidgin_docklet_init() |
649 { | 649 { |
650 void *conn_handle = gaim_connections_get_handle(); | 650 void *conn_handle = gaim_connections_get_handle(); |
651 void *conv_handle = gaim_conversations_get_handle(); | 651 void *conv_handle = gaim_conversations_get_handle(); |
652 void *accounts_handle = gaim_accounts_get_handle(); | 652 void *accounts_handle = gaim_accounts_get_handle(); |
653 void *docklet_handle = gaim_gtk_docklet_get_handle(); | 653 void *docklet_handle = pidgin_docklet_get_handle(); |
654 | 654 |
655 gaim_prefs_add_none("/gaim/gtk/docklet"); | 655 gaim_prefs_add_none("/gaim/gtk/docklet"); |
656 gaim_prefs_add_bool("/gaim/gtk/docklet/blink", FALSE); | 656 gaim_prefs_add_bool("/gaim/gtk/docklet/blink", FALSE); |
657 gaim_prefs_add_string("/gaim/gtk/docklet/show", "always"); | 657 gaim_prefs_add_string("/gaim/gtk/docklet/show", "always"); |
658 gaim_prefs_connect_callback(docklet_handle, "/gaim/gtk/docklet/show", | 658 gaim_prefs_connect_callback(docklet_handle, "/gaim/gtk/docklet/show", |
683 | 683 |
684 enable_join_chat = online_account_supports_chat(); | 684 enable_join_chat = online_account_supports_chat(); |
685 } | 685 } |
686 | 686 |
687 void | 687 void |
688 gaim_gtk_docklet_uninit() | 688 pidgin_docklet_uninit() |
689 { | 689 { |
690 if (visible && ui_ops && ui_ops->destroy) | 690 if (visible && ui_ops && ui_ops->destroy) |
691 ui_ops->destroy(); | 691 ui_ops->destroy(); |
692 } | 692 } |