comparison pidgin/gtkprefs.c @ 25718:4bc74deeb503

propagate from branch 'im.pidgin.pidgin' (head 434563a4b8fadb9593c241db4bb5ffd0bf2c0627) to branch 'im.pidgin.soc.2008.vv' (head 59d05cb38af9346d82ce57477273f7b381054bcc)
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 09 Aug 2008 02:24:38 +0000
parents 12a16471f94e
children 89d873e217c1
comparison
equal deleted inserted replaced
23742:de8f2d3e538a 25718:4bc74deeb503
143 143
144 type = GPOINTER_TO_INT(g_object_get_data(w, "type")); 144 type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
145 145
146 if (type == PURPLE_PREF_INT) { 146 if (type == PURPLE_PREF_INT) {
147 int_value = GPOINTER_TO_INT(g_object_get_data(w, "value")); 147 int_value = GPOINTER_TO_INT(g_object_get_data(w, "value"));
148
149 purple_prefs_set_int(key, int_value); 148 purple_prefs_set_int(key, int_value);
150 } 149 }
151 else if (type == PURPLE_PREF_STRING) { 150 else if (type == PURPLE_PREF_STRING) {
152 str_value = (const char *)g_object_get_data(w, "value"); 151 str_value = (const char *)g_object_get_data(w, "value");
153
154 purple_prefs_set_string(key, str_value); 152 purple_prefs_set_string(key, str_value);
155 } 153 }
156 else if (type == PURPLE_PREF_BOOLEAN) { 154 else if (type == PURPLE_PREF_BOOLEAN) {
157 purple_prefs_set_bool(key, 155 purple_prefs_set_bool(key,
158 GPOINTER_TO_INT(g_object_get_data(w, "value"))); 156 GPOINTER_TO_INT(g_object_get_data(w, "value")));
943 _("Always"), "always", 941 _("Always"), "always",
944 _("On unread messages"), "pending", 942 _("On unread messages"), "pending",
945 _("Never"), "never", 943 _("Never"), "never",
946 NULL); 944 NULL);
947 gtk_size_group_add_widget(sg, label); 945 gtk_size_group_add_widget(sg, label);
948 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); 946 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
949 947
950 vbox = pidgin_make_frame(ret, _("Conversation Window Hiding")); 948 vbox = pidgin_make_frame(ret, _("Conversation Window Hiding"));
951 label = pidgin_prefs_dropdown(vbox, _("_Hide new IM conversations:"), 949 label = pidgin_prefs_dropdown(vbox, _("_Hide new IM conversations:"),
952 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/im/hide_new", 950 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/im/hide_new",
953 _("Never"), "never", 951 _("Never"), "never",
954 _("When away"), "away", 952 _("When away"), "away",
955 _("Always"), "always", 953 _("Always"), "always",
956 NULL); 954 NULL);
957 gtk_size_group_add_widget(sg, label); 955 gtk_size_group_add_widget(sg, label);
958 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); 956 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
959 957
960 958
961 /* All the tab options! */ 959 /* All the tab options! */
962 vbox = pidgin_make_frame(ret, _("Tabs")); 960 vbox = pidgin_make_frame(ret, _("Tabs"));
963 961
988 _("Left Vertical"), GTK_POS_LEFT|8, 986 _("Left Vertical"), GTK_POS_LEFT|8,
989 _("Right Vertical"), GTK_POS_RIGHT|8, 987 _("Right Vertical"), GTK_POS_RIGHT|8,
990 #endif 988 #endif
991 NULL); 989 NULL);
992 gtk_size_group_add_widget(sg, label); 990 gtk_size_group_add_widget(sg, label);
993 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); 991 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
994 992
995 names = pidgin_conv_placement_get_options(); 993 names = pidgin_conv_placement_get_options();
996 label = pidgin_prefs_dropdown_from_list(vbox2, _("N_ew conversations:"), 994 label = pidgin_prefs_dropdown_from_list(vbox2, _("N_ew conversations:"),
997 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/placement", names); 995 PURPLE_PREF_STRING, PIDGIN_PREFS_ROOT "/conversations/placement", names);
998 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); 996 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
2017 g_object_unref(sg); 2015 g_object_unref(sg);
2018 2016
2019 return ret; 2017 return ret;
2020 } 2018 }
2021 2019
2020 #ifdef USE_VV
2021
2022 /* get a GList of pairs name / device */
2023 static GList *
2024 get_device_items(const GstElement *element,
2025 const GList *devices)
2026 {
2027 GList *ret = NULL;
2028
2029 for(; devices ; devices = devices->next) {
2030 gchar *name = purple_media_get_device_name(GST_ELEMENT(element), devices->data);
2031 ret = g_list_append(ret, name);
2032 ret = g_list_append(ret, g_value_dup_string(devices->data));
2033 }
2034
2035 return ret;
2036 }
2037
2038 /*
2039 * Test functions to run video preview
2040 */
2041 static gboolean
2042 preview_video_bus_call(GstBus *bus, GstMessage *msg, gpointer pipeline)
2043 {
2044 switch(GST_MESSAGE_TYPE(msg)) {
2045 case GST_MESSAGE_EOS:
2046 purple_debug_info("preview-video", "End of Stream\n");
2047 break;
2048 case GST_MESSAGE_ERROR: {
2049 gchar *debug = NULL;
2050 GError *err = NULL;
2051
2052 gst_message_parse_error(msg, &err, &debug);
2053
2054 purple_debug_error("preview-video", "Error: %s\n", err->message);
2055 g_error_free(err);
2056
2057 if (debug) {
2058 purple_debug_error("preview-video", "details: %s\n", debug);
2059 g_free (debug);
2060 }
2061 break;
2062 }
2063 default:
2064 return TRUE;
2065 }
2066
2067 gst_element_set_state(pipeline, GST_STATE_NULL);
2068 gst_object_unref(GST_PIPELINE(pipeline));
2069 return TRUE;
2070 }
2071
2072 static void
2073 preview_button_clicked(GtkWidget *widget, gpointer *data)
2074 {
2075 const char *plugin = purple_prefs_get_string("/purple/media/video/plugin");
2076 const char *device = purple_prefs_get_string("/purple/media/video/device");
2077 GstBus *bus;
2078
2079 /* create a preview window... */
2080 GstElement *pipeline = NULL;
2081 GError *p_err;
2082
2083 gchar *test_pipeline_str = NULL;
2084
2085 if (strlen(device) > 0)
2086 test_pipeline_str = g_strdup_printf("%s device=\"%s\" !" \
2087 " ffmpegcolorspace !" \
2088 " autovideosink",
2089 plugin, device);
2090 else
2091 test_pipeline_str = g_strdup_printf("%s ! ffmpegcolorspace !" \
2092 " autovideosink", plugin);
2093
2094 pipeline = gst_parse_launch (test_pipeline_str, &p_err);
2095
2096 g_free(test_pipeline_str);
2097
2098 bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
2099 gst_bus_add_watch(bus, preview_video_bus_call, pipeline);
2100 gst_object_unref(bus);
2101
2102 gst_element_set_state(pipeline, GST_STATE_PLAYING);
2103 }
2104
2105 static void
2106 media_plugin_changed_cb(const gchar *name, PurplePrefType type,
2107 gconstpointer value, gpointer data)
2108 {
2109 GtkWidget *hbox = data;
2110 GtkWidget *dd = NULL;
2111 GtkWidget *preview_button = NULL;
2112 const char *plugin = value;
2113 const char *device = purple_prefs_get_string("/purple/media/video/device");
2114 GstElement *video = purple_media_get_element(plugin);
2115 GList *video_devices = purple_media_get_devices(video);
2116 GList *video_items = get_device_items(video, video_devices);
2117 GList *list;
2118 g_list_free(video_devices);
2119
2120 if (video_items == NULL) {
2121 video_items = g_list_prepend(video_items, g_strdup(""));
2122 video_items = g_list_prepend(video_items, g_strdup("Default"));
2123 }
2124
2125 if (g_list_find(video_items, device) == NULL)
2126 {
2127 purple_prefs_set_string("/purple/media/video/device",
2128 g_list_next(video_items)->data);
2129 }
2130
2131 list = gtk_container_get_children(GTK_CONTAINER(hbox));
2132
2133 while (list) {
2134 gtk_widget_destroy(list->data);
2135 list = g_list_delete_link(list, list);
2136 }
2137
2138 dd = pidgin_prefs_dropdown_from_list(hbox, _("_Device:"), PURPLE_PREF_STRING,
2139 "/purple/media/video/device",
2140 video_items);
2141
2142 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2143
2144 preview_button = gtk_button_new_with_mnemonic(_("_Preview"));
2145 g_signal_connect(G_OBJECT(preview_button), "clicked",
2146 G_CALLBACK(preview_button_clicked), video);
2147
2148 gtk_container_add(GTK_CONTAINER(hbox), preview_button);
2149
2150 gtk_widget_show_all(hbox);
2151 }
2152
2153 static GtkWidget *
2154 media_page()
2155 {
2156 GtkWidget *ret;
2157 GtkWidget *vbox;
2158 GtkWidget *hbox;
2159 GtkWidget *dd;
2160 GtkWidget *preview_button;
2161 GtkSizeGroup *sg;
2162 const char *plugin = purple_prefs_get_string("/purple/media/video/plugin");
2163 const char *device = purple_prefs_get_string("/purple/media/video/device");
2164
2165 GstElement *video = purple_media_get_element(plugin);
2166 GstElement *audio = purple_media_get_element("alsasrc");
2167
2168 GList *video_devices = purple_media_get_devices(video);
2169 GList *audio_devices = purple_media_get_devices(audio);
2170
2171 GList *video_items = get_device_items(video, video_devices);
2172 GList *audio_items = get_device_items(audio, audio_devices);
2173
2174 g_list_free(video_devices);
2175 g_list_free(audio_devices);
2176
2177 if (video_items == NULL) {
2178 video_items = g_list_prepend(video_items, "");
2179 video_items = g_list_prepend(video_items, "Default");
2180 }
2181
2182 if (g_list_find(video_items, device) == NULL)
2183 {
2184 purple_prefs_set_string("/purple/media/video/device",
2185 g_list_next(video_items)->data);
2186 }
2187
2188 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
2189 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
2190
2191 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2192
2193 vbox = pidgin_make_frame (ret, _("Video Input"));
2194
2195 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2196 dd = pidgin_prefs_dropdown(vbox, _("_Plugin:"), PURPLE_PREF_STRING,
2197 "/purple/media/video/plugin",
2198 _("Default"), "gconfvideosrc",
2199 _("Video4Linux"), "v4lsrc",
2200 _("Video4Linux2"), "v4l2src",
2201 _("Video Test Source"), "videotestsrc",
2202 NULL);
2203
2204 gtk_size_group_add_widget(sg, dd);
2205 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2206
2207 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2208 dd = pidgin_prefs_dropdown_from_list(hbox, _("_Device:"), PURPLE_PREF_STRING,
2209 "/purple/media/video/device",
2210 video_items);
2211
2212 purple_prefs_connect_callback(prefs, "/purple/media/video/plugin",
2213 media_plugin_changed_cb, hbox);
2214
2215 g_signal_connect_swapped(hbox, "destroy",
2216 G_CALLBACK(purple_prefs_disconnect_by_handle), hbox);
2217
2218 gtk_size_group_add_widget(sg, dd);
2219 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2220
2221 preview_button = gtk_button_new_with_mnemonic(_("_Preview"));
2222 g_signal_connect(G_OBJECT(preview_button), "clicked",
2223 G_CALLBACK(preview_button_clicked), video);
2224
2225 gtk_container_add(GTK_CONTAINER(hbox), preview_button);
2226 gtk_container_add(GTK_CONTAINER(vbox), hbox);
2227
2228 vbox = pidgin_make_frame (ret, _("Audio Input"));
2229 dd = pidgin_prefs_dropdown_from_list(vbox, _("_Device:"), PURPLE_PREF_STRING,
2230 "/purple/media/audio/device",
2231 audio_items);
2232
2233 gtk_size_group_add_widget(sg, dd);
2234 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
2235
2236 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
2237 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2238
2239 gtk_widget_show_all(ret);
2240
2241 return ret;
2242 }
2243
2244 #endif /* USE_VV */
2022 2245
2023 static void 2246 static void
2024 set_idle_away(PurpleSavedStatus *status) 2247 set_idle_away(PurpleSavedStatus *status)
2025 { 2248 {
2026 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status)); 2249 purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status));
2142 static void prefs_notebook_init(void) { 2365 static void prefs_notebook_init(void) {
2143 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page++); 2366 prefs_notebook_add_page(_("Interface"), interface_page(), notebook_page++);
2144 prefs_notebook_add_page(_("Conversations"), conv_page(), notebook_page++); 2367 prefs_notebook_add_page(_("Conversations"), conv_page(), notebook_page++);
2145 prefs_notebook_add_page(_("Smiley Themes"), theme_page(), notebook_page++); 2368 prefs_notebook_add_page(_("Smiley Themes"), theme_page(), notebook_page++);
2146 prefs_notebook_add_page(_("Sounds"), sound_page(), notebook_page++); 2369 prefs_notebook_add_page(_("Sounds"), sound_page(), notebook_page++);
2370
2371 #ifdef USE_VV
2372 prefs_notebook_add_page(_("Media"), media_page(), notebook_page++);
2373 #endif
2147 prefs_notebook_add_page(_("Network"), network_page(), notebook_page++); 2374 prefs_notebook_add_page(_("Network"), network_page(), notebook_page++);
2148 #ifndef _WIN32 2375 #ifndef _WIN32
2149 /* We use the registered default browser in windows */ 2376 /* We use the registered default browser in windows */
2150 /* if the user is running gnome 2.x or Mac OS X, hide the browsers tab */ 2377 /* if the user is running gnome 2.x or Mac OS X, hide the browsers tab */
2151 if ((purple_running_gnome() == FALSE) && (purple_running_osx() == FALSE)) { 2378 if ((purple_running_gnome() == FALSE) && (purple_running_osx() == FALSE)) {
2266 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default"); 2493 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default");
2267 2494
2268 /* Smiley Callbacks */ 2495 /* Smiley Callbacks */
2269 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/smileys/theme", 2496 purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/smileys/theme",
2270 smiley_theme_pref_cb, NULL); 2497 smiley_theme_pref_cb, NULL);
2498
2499 #ifdef USE_VV
2500 purple_prefs_add_none("/purple/media");
2501 purple_prefs_add_none("/purple/media/video");
2502 purple_prefs_add_string("/purple/media/video/plugin", "gconfvideosrc");
2503 purple_prefs_add_string("/purple/media/video/device", "");
2504 purple_prefs_add_none("/purple/media/audio");
2505 purple_prefs_add_string("/purple/media/audio/device", "");
2506 #endif /* USE_VV */
2271 2507
2272 pidgin_prefs_update_old(); 2508 pidgin_prefs_update_old();
2273 } 2509 }
2274 2510
2275 void pidgin_prefs_update_old() 2511 void pidgin_prefs_update_old()