pidgin/gtkrequest.c

changeset 42098
9f746a79d7c4
parent 42097
f29c4d466cf5
child 42099
4313c029db44
equal deleted inserted replaced
42097:f29c4d466cf5 42098:9f746a79d7c4
70 } multifield; 70 } multifield;
71 71
72 struct 72 struct
73 { 73 {
74 gboolean savedialog; 74 gboolean savedialog;
75 gchar *name;
76 75
77 } file; 76 } file;
78 77
79 } u; 78 } u;
80 79
2184 2183
2185 return data; 2184 return data;
2186 } 2185 }
2187 2186
2188 static void 2187 static void
2189 file_ok_check_if_exists_cb(G_GNUC_UNUSED GtkWidget *widget, gint response, 2188 pidgin_request_file_folder_response_cb(G_GNUC_UNUSED GtkWidget *widget,
2190 PidginRequestData *data) 2189 gint response, PidginRequestData *data)
2191 { 2190 {
2192 GFile *current_path; 2191 GFile *current_path;
2193 2192
2194 if (response != GTK_RESPONSE_ACCEPT) { 2193 if (response != GTK_RESPONSE_ACCEPT) {
2195 if (data->cbs[0] != NULL) 2194 if (data->cbs[0] != NULL)
2196 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, NULL); 2195 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, NULL);
2197 purple_request_close(data->type, data); 2196 purple_request_close(data->type, data);
2198 return; 2197 return;
2199 } 2198 }
2200 2199
2201 data->u.file.name = gtk_file_chooser_get_current_name(GTK_FILE_CHOOSER(data->dialog));
2202 current_path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(data->dialog)); 2200 current_path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(data->dialog));
2203 if (current_path != NULL) { 2201 if (current_path != NULL) {
2204 gchar *current_folder = g_file_get_path(current_path); 2202 gchar *current_folder = g_file_get_path(current_path);
2205 if (data->u.file.savedialog) { 2203 if (data->u.file.savedialog) {
2206 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder", current_folder); 2204 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder", current_folder);
2208 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", current_folder); 2206 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", current_folder);
2209 } 2207 }
2210 g_free(current_folder); 2208 g_free(current_folder);
2211 } 2209 }
2212 if (data->cbs[1] != NULL) { 2210 if (data->cbs[1] != NULL) {
2213 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, data->u.file.name); 2211 GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(data->dialog));
2212 char *filename = g_file_get_path(file);
2213 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, filename);
2214 g_free(filename);
2215 g_object_unref(file);
2214 } 2216 }
2215 purple_request_close(data->type, data); 2217 purple_request_close(data->type, data);
2216 2218
2217 g_clear_object(&current_path); 2219 g_clear_object(&current_path);
2218 } 2220 }
2289 } 2291 }
2290 2292
2291 g_clear_object(&file); 2293 g_clear_object(&file);
2292 #endif 2294 #endif
2293 2295
2294 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(filesel)), "response", 2296 g_signal_connect(G_OBJECT(filesel), "response",
2295 G_CALLBACK(file_ok_check_if_exists_cb), data); 2297 G_CALLBACK(pidgin_request_file_folder_response_cb), data);
2296 2298
2297 #if 0 2299 #if 0
2298 /* FIXME: Not implemented for native dialogs. */ 2300 /* FIXME: Not implemented for native dialogs. */
2299 pidgin_auto_parent_window(filesel); 2301 pidgin_auto_parent_window(filesel);
2300 #endif 2302 #endif
2334 NULL); 2336 NULL);
2335 2337
2336 g_object_unref(path); 2338 g_object_unref(path);
2337 } 2339 }
2338 2340
2339 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(dirsel)), "response", 2341 g_signal_connect(G_OBJECT(dirsel), "response",
2340 G_CALLBACK(file_ok_check_if_exists_cb), data); 2342 G_CALLBACK(pidgin_request_file_folder_response_cb), data);
2341 2343
2342 data->dialog = dirsel; 2344 data->dialog = dirsel;
2343 #if 0 2345 #if 0
2344 /* FIXME: Not implemented for native dialogs. */ 2346 /* FIXME: Not implemented for native dialogs. */
2345 pidgin_auto_parent_window(dirsel); 2347 pidgin_auto_parent_window(dirsel);
2394 gtk_window_destroy(GTK_WINDOW(data->dialog)); 2396 gtk_window_destroy(GTK_WINDOW(data->dialog));
2395 } 2397 }
2396 2398
2397 if (type == PURPLE_REQUEST_FIELDS) 2399 if (type == PURPLE_REQUEST_FIELDS)
2398 purple_request_fields_destroy(data->u.multifield.fields); 2400 purple_request_fields_destroy(data->u.multifield.fields);
2399 else if (type == PURPLE_REQUEST_FILE)
2400 g_free(data->u.file.name);
2401 2401
2402 g_free(data); 2402 g_free(data);
2403 } 2403 }
2404 2404
2405 GtkWindow * 2405 GtkWindow *

mercurial