| 1059 GList *elements = purple_request_field_choice_get_elements(field); |
1059 GList *elements = purple_request_field_choice_get_elements(field); |
| 1060 int num_labels = g_list_length(elements) / 2; |
1060 int num_labels = g_list_length(elements) / 2; |
| 1061 GList *l; |
1061 GList *l; |
| 1062 gpointer *values = g_new(gpointer, num_labels); |
1062 gpointer *values = g_new(gpointer, num_labels); |
| 1063 gpointer default_value; |
1063 gpointer default_value; |
| |
1064 gboolean default_found = FALSE; |
| 1064 int i; |
1065 int i; |
| 1065 |
1066 |
| 1066 default_value = purple_request_field_choice_get_default_value(field); |
1067 default_value = purple_request_field_choice_get_value(field); |
| 1067 if (num_labels > 5 || purple_request_cpar_is_compact(cpar)) |
1068 if (num_labels > 5 || purple_request_cpar_is_compact(cpar)) |
| 1068 { |
1069 { |
| 1069 int default_index = 0; |
1070 int default_index = 0; |
| 1070 widget = gtk_combo_box_text_new(); |
1071 widget = gtk_combo_box_text_new(); |
| 1071 |
1072 |
| 1080 l = g_list_next(l); |
1081 l = g_list_next(l); |
| 1081 value = l->data; |
1082 value = l->data; |
| 1082 l = g_list_next(l); |
1083 l = g_list_next(l); |
| 1083 |
1084 |
| 1084 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text); |
1085 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text); |
| 1085 if (value == default_value) |
1086 if (value == default_value) { |
| 1086 default_index = i; |
1087 default_index = i; |
| |
1088 default_found = TRUE; |
| |
1089 } |
| 1087 values[i++] = value; |
1090 values[i++] = value; |
| 1088 } |
1091 } |
| 1089 |
1092 |
| 1090 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), default_index); |
1093 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), default_index); |
| 1091 |
1094 |
| 1126 g_object_set_data(G_OBJECT(radio), "box", box); |
1129 g_object_set_data(G_OBJECT(radio), "box", box); |
| 1127 |
1130 |
| 1128 if (first_radio == NULL) |
1131 if (first_radio == NULL) |
| 1129 first_radio = radio; |
1132 first_radio = radio; |
| 1130 |
1133 |
| 1131 if (value == default_value) |
1134 if (value == default_value) { |
| 1132 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); |
1135 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); |
| |
1136 default_found = TRUE; |
| |
1137 } |
| 1133 values[i++] = value; |
1138 values[i++] = value; |
| 1134 |
1139 |
| 1135 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0); |
1140 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0); |
| 1136 gtk_widget_show(radio); |
1141 gtk_widget_show(radio); |
| 1137 |
1142 |
| 1138 g_signal_connect(G_OBJECT(radio), "toggled", |
1143 g_signal_connect(G_OBJECT(radio), "toggled", |
| 1139 G_CALLBACK(field_choice_option_cb), field); |
1144 G_CALLBACK(field_choice_option_cb), field); |
| 1140 } |
1145 } |
| 1141 } |
1146 } |
| |
1147 |
| |
1148 if (!default_found && i > 0) |
| |
1149 purple_request_field_choice_set_value(field, values[0]); |
| 1142 |
1150 |
| 1143 g_object_set_data_full(G_OBJECT(widget), "values", values, g_free); |
1151 g_object_set_data_full(G_OBJECT(widget), "values", values, g_free); |
| 1144 |
1152 |
| 1145 return widget; |
1153 return widget; |
| 1146 } |
1154 } |
| 1888 gtk_widget_show(dirsel); |
1896 gtk_widget_show(dirsel); |
| 1889 |
1897 |
| 1890 return (void *)data; |
1898 return (void *)data; |
| 1891 } |
1899 } |
| 1892 |
1900 |
| 1893 #ifdef _WIN32 |
1901 /* if request callback issues another request, it should be attached to the |
| 1894 |
1902 * primary request parent */ |
| 1895 /* Not needed (yet) for non-win32, but should work everywhere. */ |
1903 static void |
| 1896 static void |
1904 pidgin_window_detach_children(GtkWindow* win) |
| 1897 pidgin_window_detach_children(GtkWindow* parent) |
|
| 1898 { |
1905 { |
| 1899 GList *it; |
1906 GList *it; |
| 1900 |
1907 GtkWindow *par; |
| 1901 g_return_if_fail(parent != NULL); |
1908 |
| 1902 |
1909 g_return_if_fail(win != NULL); |
| |
1910 |
| |
1911 par = gtk_window_get_transient_for(win); |
| 1903 it = gtk_window_list_toplevels(); |
1912 it = gtk_window_list_toplevels(); |
| 1904 for (it = g_list_first(it); it != NULL; it = g_list_next(it)) { |
1913 for (it = g_list_first(it); it != NULL; it = g_list_next(it)) { |
| 1905 GtkWindow *win = GTK_WINDOW(it->data); |
1914 GtkWindow *child = GTK_WINDOW(it->data); |
| 1906 if (gtk_window_get_transient_for(win) == parent) |
1915 if (gtk_window_get_transient_for(child) != win) |
| 1907 gtk_window_set_transient_for(win, NULL); |
1916 continue; |
| 1908 } |
1917 if (gtk_window_get_destroy_with_parent(child)) { |
| 1909 } |
1918 #ifdef _WIN32 |
| 1910 |
1919 /* XXX test/verify it: Win32 gtk ignores |
| |
1920 * gtk_window_set_destroy_with_parent(..., FALSE). */ |
| |
1921 gtk_window_set_transient_for(child, NULL); |
| 1911 #endif |
1922 #endif |
| |
1923 continue; |
| |
1924 } |
| |
1925 gtk_window_set_transient_for(child, par); |
| |
1926 } |
| |
1927 } |
| 1912 |
1928 |
| 1913 static void |
1929 static void |
| 1914 pidgin_close_request(PurpleRequestType type, void *ui_handle) |
1930 pidgin_close_request(PurpleRequestType type, void *ui_handle) |
| 1915 { |
1931 { |
| 1916 PidginRequestData *data = (PidginRequestData *)ui_handle; |
1932 PidginRequestData *data = (PidginRequestData *)ui_handle; |
| 1917 |
1933 |
| 1918 g_free(data->cbs); |
1934 g_free(data->cbs); |
| 1919 |
1935 |
| 1920 #ifdef _WIN32 |
|
| 1921 /* Win32 gtk ignores gtk_window_set_destroy_with_parent(..., FALSE). */ |
|
| 1922 pidgin_window_detach_children(GTK_WINDOW(data->dialog)); |
1936 pidgin_window_detach_children(GTK_WINDOW(data->dialog)); |
| 1923 #endif |
|
| 1924 |
1937 |
| 1925 gtk_widget_destroy(data->dialog); |
1938 gtk_widget_destroy(data->dialog); |
| 1926 |
1939 |
| 1927 if (type == PURPLE_REQUEST_FIELDS) |
1940 if (type == PURPLE_REQUEST_FIELDS) |
| 1928 purple_request_fields_destroy(data->u.multifield.fields); |
1941 purple_request_fields_destroy(data->u.multifield.fields); |