Thu, 09 Feb 2006 04:14:54 +0000
[gaim-migrate @ 15562]
Is there any reason we use gtk_widget_show() everywhere instead of
gtk_widget_show_all()
| 12024 | 1 | /** |
|
12050
a7d5a2430722
[gaim-migrate @ 14345]
Mark Doliner <markdoliner@pidgin.im>
parents:
12046
diff
changeset
|
2 | * @file gtkmedia.h Voice and Video UI |
| 12024 | 3 | * @ingroup gtkui |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 7 | * Gaim is the legal property of its developers, whose names are too numerous | |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 10 | * | |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | ||
|
12046
5630b420f500
[gaim-migrate @ 14341]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
26 | #include "internal.h" |
|
5630b420f500
[gaim-migrate @ 14341]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
27 | |
| 12024 | 28 | #ifdef HAVE_VV |
| 29 | ||
|
12046
5630b420f500
[gaim-migrate @ 14341]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
30 | #include "debug.h" |
| 12024 | 31 | #include "gtkconv.h" |
| 32 | #include "gtkmedia.h" | |
| 33 | ||
| 34 | typedef struct { | |
| 35 | GtkWidget *call_pane; | |
| 36 | GtkWidget *bbox; | |
| 37 | } GaimGtkVoiceChat; | |
| 38 | ||
| 39 | ||
| 40 | static void gaim_gtk_media_new_voice_chat(GaimVoiceChat *vc) | |
| 41 | { | |
| 42 | GaimGtkVoiceChat *gvc = g_new0(GaimGtkVoiceChat, 1); | |
| 43 | gaim_voice_chat_set_ui_data(vc, gvc); | |
| 44 | ||
| 45 | } | |
| 46 | ||
| 47 | static void gaim_gtk_media_destroy(GaimVoiceChat *vc) | |
| 48 | { | |
| 49 | GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gaim_connection_get_account(gaim_voice_chat_get_connection(vc)), | |
| 50 | gaim_voice_chat_get_name(vc)); | |
|
12046
5630b420f500
[gaim-migrate @ 14341]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
51 | GaimGtkVoiceChat *gvc = (GaimGtkVoiceChat*)gaim_voice_chat_get_ui_data(vc); |
| 12024 | 52 | gaim_conversation_write(conv, NULL, _("Call ended."), GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 53 | gtk_widget_destroy(gvc->call_pane); | |
| 54 | g_free(gvc); | |
| 55 | } | |
| 56 | ||
| 57 | static void gaim_gtk_media_state_change(GaimVoiceChat *vc, GaimMediaState state) | |
| 58 | { | |
| 59 | GaimGtkVoiceChat *gvc = (GaimGtkVoiceChat*)gaim_voice_chat_get_ui_data(vc); | |
| 60 | GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gaim_connection_get_account(gaim_voice_chat_get_connection(vc)), | |
| 61 | gaim_voice_chat_get_name(vc)); | |
| 62 | GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 63 | GtkWidget *hbox, *bbox; | |
| 64 | GtkWidget *button; | |
| 65 | char *msg = NULL; | |
| 66 | ||
| 67 | switch (state) { | |
| 68 | case GAIM_MEDIA_STATE_CALLING: | |
| 69 | msg = g_strdup_printf(_("Calling %s"), gaim_voice_chat_get_name(vc)); | |
| 70 | gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 71 | g_free(msg); | |
| 72 | hbox = gtk_hbox_new(FALSE, 6); | |
| 73 | button = gtk_button_new_with_label(_("End Call")); | |
| 74 | g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_terminate), vc); | |
| 75 | gvc->call_pane = hbox; | |
| 76 | gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, 0, 0); | |
| 77 | gtk_box_pack_end(GTK_BOX(gtkconv->tab_cont), hbox, FALSE, 0, 0); | |
| 78 | gtk_widget_show_all(hbox); | |
| 79 | break; | |
| 80 | case GAIM_MEDIA_STATE_RECEIVING: | |
| 81 | msg = g_strdup_printf(_("Receiving call from %s"), gaim_voice_chat_get_name(vc)); | |
| 82 | gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 83 | g_free(msg); | |
| 84 | hbox = gtk_hbox_new(FALSE, 6); | |
| 85 | bbox = gvc->bbox = gtk_hbutton_box_new(); | |
| 86 | gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 87 | gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
| 88 | gtk_container_add(GTK_CONTAINER(hbox), bbox); | |
| 89 | button = gtk_button_new_with_label(_("Reject Call")); | |
| 90 | g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_reject), vc); | |
| 91 | gvc->call_pane = hbox; | |
| 92 | gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, 0, 0); | |
| 93 | gtk_box_pack_end(GTK_BOX(gtkconv->tab_cont), hbox, FALSE, 0, 0); | |
| 94 | ||
| 95 | button = gtk_button_new_with_label(_("Accept call")); | |
| 96 | g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_accept), vc); | |
| 97 | gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, 0, 0); | |
| 98 | ||
| 99 | gtk_widget_show_all(hbox); | |
| 100 | break; | |
| 101 | case GAIM_MEDIA_STATE_IN_PROGRESS: | |
| 102 | msg = g_strdup_printf(_("Connected to %s"), gaim_voice_chat_get_name(vc)); | |
| 103 | gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 104 | g_free(msg); | |
| 105 | if (gvc->bbox) { | |
| 106 | gtk_widget_destroy(gvc->bbox); | |
| 107 | gvc->bbox = NULL; | |
| 108 | button = gtk_button_new_with_label(_("End Call")); | |
| 109 | g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gaim_voice_chat_terminate), vc); | |
| 110 | gtk_box_pack_end(GTK_BOX(gvc->call_pane), button, FALSE, 0, 0); | |
| 111 | gtk_widget_show(button); | |
| 112 | } | |
| 113 | button = gtk_check_button_new_with_mnemonic(_("_Mute")); | |
| 114 | gtk_box_pack_start(GTK_BOX(gvc->call_pane), button, FALSE, 0, 0); | |
| 115 | gtk_widget_show(button); | |
| 116 | break; | |
| 117 | default: | |
| 118 | break; | |
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | ||
| 123 | static GaimMediaUiOps ui_ops = | |
| 124 | { | |
| 125 | gaim_gtk_media_new_voice_chat, | |
| 126 | gaim_gtk_media_destroy, | |
| 127 | gaim_gtk_media_state_change | |
| 128 | }; | |
| 129 | ||
| 130 | void gaim_gtk_media_init(void) | |
| 131 | { | |
| 132 | gaim_debug_info("gtkmedia","Initialising\n"); | |
| 133 | gaim_media_set_ui_ops(&ui_ops); | |
| 134 | } | |
| 135 | ||
| 136 | #endif /* HAVE_VV */ |