# HG changeset patch
# Node ID d9d45ab044d8
# Parent  0d5319e4b836
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -40,8 +40,9 @@ typedef struct
 	PurpleRequestType type;
 
 	void *user_data;
-	/* May be GtkWidget or GtkNativeDialog */
+	/* May be GtkWidget or GtkFileDialog. */
 	gpointer dialog;
+	GCancellable *cancellable;
 
 	GtkWidget *ok_button;
 
@@ -2002,38 +2003,91 @@ pidgin_request_fields(const char *title,
 }
 
 static void
-pidgin_request_file_folder_response_cb(G_GNUC_UNUSED GtkWidget *widget,
-                                       gint response, PidginRequestData *data)
+pidgin_request_file_response_cb(GObject *obj, GAsyncResult *result,
+                                gpointer user_data)
 {
-	GFile *current_path;
-
-	if (response != GTK_RESPONSE_ACCEPT) {
-		if (data->cbs[0] != NULL)
-			((PurpleRequestFileCb)data->cbs[0])(data->user_data, NULL);
-		purple_request_close(data->type, data);
+	PidginRequestData *data = user_data;
+	GFile *path = NULL;
+	GFile *parent = NULL;
+	GError *error = NULL;
+
+	if(data->u.file.savedialog) {
+		path = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(obj), result,
+		                                   &error);
+	} else {
+		path = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(obj), result,
+		                                   &error);
+	}
+	if(path == NULL) {
+		if(!g_error_matches(error, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED)) {
+			if(data->cbs[0] != NULL) {
+				((PurpleRequestFileCb)data->cbs[0])(data->user_data, NULL);
+			}
+			purple_request_close(data->type, data);
+		}
+		g_clear_error(&error);
 		return;
 	}
 
-	current_path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(data->dialog));
-	if (current_path != NULL) {
-		gchar *current_folder = g_file_get_path(current_path);
+	parent = g_file_get_parent(path);
+	if(parent != NULL) {
+		char *current_folder = g_file_get_path(parent);
 		if (data->u.file.savedialog) {
-			purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder", current_folder);
+			purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_save_folder",
+			                      current_folder);
 		} else {
-			purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder", current_folder);
+			purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder",
+			                      current_folder);
 		}
 		g_free(current_folder);
 	}
-	if (data->cbs[1] != NULL) {
-		GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(data->dialog));
-		char *filename = g_file_get_path(file);
+
+	if(data->cbs[1] != NULL) {
+		char *filename = g_file_get_path(path);
 		((PurpleRequestFileCb)data->cbs[1])(data->user_data, filename);
 		g_free(filename);
-		g_object_unref(file);
 	}
+
+	g_clear_object(&parent);
+	g_clear_object(&path);
+	g_clear_object(&data->cancellable);
 	purple_request_close(data->type, data);
-
-	g_clear_object(&current_path);
+}
+
+static void
+pidgin_request_folder_response_cb(GObject *obj, GAsyncResult *result,
+                                  gpointer user_data)
+{
+	PidginRequestData *data = user_data;
+	GFile *path = NULL;
+	char *folder = NULL;
+	GError *error = NULL;
+
+	path = gtk_file_dialog_select_folder_finish(GTK_FILE_DIALOG(obj), result,
+	                                            &error);
+	if(path == NULL) {
+		if(!g_error_matches(error, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED)) {
+			if(data->cbs[0] != NULL) {
+				((PurpleRequestFileCb)data->cbs[0])(data->user_data, NULL);
+			}
+			purple_request_close(data->type, data);
+		}
+		g_clear_error(&error);
+		return;
+	}
+
+	folder = g_file_get_path(path);
+	purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder",
+	                      folder);
+
+	if(data->cbs[1] != NULL) {
+		((PurpleRequestFileCb)data->cbs[1])(data->user_data, folder);
+	}
+
+	g_free(folder);
+	g_clear_object(&path);
+	g_clear_object(&data->cancellable);
+	purple_request_close(data->type, data);
 }
 
 static void *
@@ -2043,9 +2097,8 @@ pidgin_request_file(const char *title, c
                     gpointer user_data)
 {
 	PidginRequestData *data;
-	GtkFileChooserNative *filesel;
+	GtkFileDialog *dialog = NULL;
 #ifdef _WIN32
-	GFile *file = NULL;
 	const gchar *current_folder;
 	gboolean folder_set = FALSE;
 #endif
@@ -2059,21 +2112,17 @@ pidgin_request_file(const char *title, c
 	data->cbs[1] = ok_cb;
 	data->u.file.savedialog = savedialog;
 
-	filesel = gtk_file_chooser_native_new(
-	        title ? title
-	              : (savedialog ? _("Save File...") : _("Open File...")),
-	        NULL,
-	        savedialog ? GTK_FILE_CHOOSER_ACTION_SAVE
-	                   : GTK_FILE_CHOOSER_ACTION_OPEN,
-	        savedialog ? _("_Save") : _("_Open"), _("_Cancel"));
-
-	if ((filename != NULL) && (*filename != '\0')) {
+	data->dialog = dialog = gtk_file_dialog_new();
+	gtk_file_dialog_set_title(dialog,
+	                          title ? title
+	                                : (savedialog ? _("Save File...")
+	                                              : _("Open File...")));
+
+	if(!purple_strempty(filename)) {
 		GFile *path = g_file_new_for_path(filename);
 
-		if(savedialog) {
-			gtk_file_chooser_set_file(GTK_FILE_CHOOSER(filesel), path, NULL);
-		} else if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
-			gtk_file_chooser_set_file(GTK_FILE_CHOOSER(filesel), path, NULL);
+		if(savedialog || g_file_test(filename, G_FILE_TEST_EXISTS)) {
+			gtk_file_dialog_set_initial_file(dialog, path);
 		}
 
 		g_object_unref(path);
@@ -2086,40 +2135,39 @@ pidgin_request_file(const char *title, c
 		current_folder = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/filelocations/last_open_folder");
 	}
 
-	if ((filename == NULL || *filename == '\0' || !g_file_test(filename, G_FILE_TEST_EXISTS)) &&
-		(current_folder != NULL) && (*current_folder != '\0'))
+	if((purple_strempty(filename) || !g_file_test(filename, G_FILE_TEST_EXISTS)) &&
+	   !purple_strempty(current_folder))
 	{
-		file = g_file_new_for_path(current_folder);
-		folder_set = gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filesel), file, NULL);
+		GFile *file = g_file_new_for_path(current_folder);
+		gtk_file_dialog_set_initial_folder(dialog, file, NULL);
+		folder_set = TRUE;
+		g_clear_object(&file);
 	}
 
-	if (!folder_set && (filename == NULL || *filename == '\0' || !g_file_test(filename, G_FILE_TEST_EXISTS))) {
+	if(!folder_set &&
+	   (purple_strempty(filename) || !g_file_test(filename, G_FILE_TEST_EXISTS)))
+	{
 		char *my_documents = wpurple_get_special_folder(CSIDL_PERSONAL);
 
-		g_clear_object(&file);
-
 		if (my_documents != NULL) {
-			file = g_file_new_for_path(my_documents);
-			gtk_file_chooser_set_current_folder(
-					GTK_FILE_CHOOSER(filesel), file, NULL);
+			GFile *file = g_file_new_for_path(my_documents);
+
+			gtk_file_dialog_set_initial_folder(dialog, file);
 
 			g_free(my_documents);
+			g_clear_object(&file);
 		}
 	}
-
-	g_clear_object(&file);
 #endif
 
-	g_signal_connect(G_OBJECT(filesel), "response",
-	                 G_CALLBACK(pidgin_request_file_folder_response_cb), data);
-
-#if 0
-	/* FIXME: Not implemented for native dialogs. */
-	pidgin_auto_parent_window(filesel);
-#endif
-
-	data->dialog = filesel;
-	gtk_native_dialog_show(GTK_NATIVE_DIALOG(filesel));
+	data->cancellable = g_cancellable_new();
+	if(savedialog) {
+		gtk_file_dialog_save(dialog, NULL, data->cancellable,
+		                     pidgin_request_file_response_cb, data);
+	} else {
+		gtk_file_dialog_open(dialog, NULL, data->cancellable,
+		                     pidgin_request_file_response_cb, data);
+	}
 
 	return (void *)data;
 }
@@ -2131,7 +2179,7 @@ pidgin_request_folder(const char *title,
                       gpointer user_data)
 {
 	PidginRequestData *data;
-	GtkFileChooserNative *dirsel;
+	GtkFileDialog *dialog = NULL;
 
 	data = g_new0(PidginRequestData, 1);
 	data->type = PURPLE_REQUEST_FOLDER;
@@ -2142,29 +2190,18 @@ pidgin_request_folder(const char *title,
 	data->cbs[1] = ok_cb;
 	data->u.file.savedialog = FALSE;
 
-	dirsel = gtk_file_chooser_native_new(
-	        title ? title : _("Select Folder..."), NULL,
-	        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _("_OK"), _("_Cancel"));
-
-	if ((dirname != NULL) && (*dirname != '\0')) {
+	data->cancellable = g_cancellable_new();
+	data->dialog = dialog = gtk_file_dialog_new();
+	gtk_file_dialog_set_title(dialog, title ? title : _("Select Folder..."));
+
+	if(!purple_strempty(dirname)) {
 		GFile *path = g_file_new_for_path(dirname);
-
-		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dirsel), path,
-		                                    NULL);
-
+		gtk_file_dialog_set_initial_folder(dialog, path);
 		g_object_unref(path);
 	}
 
-	g_signal_connect(G_OBJECT(dirsel), "response",
-	                 G_CALLBACK(pidgin_request_file_folder_response_cb), data);
-
-	data->dialog = dirsel;
-#if 0
-	/* FIXME: Not implemented for native dialogs. */
-	pidgin_auto_parent_window(dirsel);
-#endif
-
-	gtk_native_dialog_show(GTK_NATIVE_DIALOG(dirsel));
+	gtk_file_dialog_select_folder(dialog, NULL, data->cancellable,
+	                              pidgin_request_folder_response_cb, data);
 
 	return (void *)data;
 }
@@ -2202,11 +2239,13 @@ pidgin_close_request(PurpleRequestType t
 {
 	PidginRequestData *data = (PidginRequestData *)ui_handle;
 
-	g_free(data->cbs);
+	if(data->cancellable != NULL) {
+		g_cancellable_cancel(data->cancellable);
+	}
 
 	if (type == PURPLE_REQUEST_FILE || type == PURPLE_REQUEST_FOLDER) {
-		/* Will be a GtkNativeDialog, not GtkDialog. */
-		g_object_unref(data->dialog);
+		/* Will be a GtkFileDialog, not GtkDialog. */
+		g_clear_object(&data->dialog);
 	} else {
 		pidgin_window_detach_children(GTK_WINDOW(data->dialog));
 
@@ -2217,6 +2256,8 @@ pidgin_close_request(PurpleRequestType t
 		g_clear_object(&data->u.multifield.page);
 	}
 
+	g_clear_object(&data->cancellable);
+	g_free(data->cbs);
 	g_free(data);
 }
 
@@ -2230,7 +2271,7 @@ pidgin_request_get_dialog_window(void *u
 
 	if (data->type == PURPLE_REQUEST_FILE ||
 	    data->type == PURPLE_REQUEST_FOLDER) {
-		/* Not a GtkWidget, but a GtkFileChooserNative. Eventually this function
+		/* Not a GtkWidget, but a GtkFileDialog. Eventually this function
 		 * should not be needed, once we don't need to auto-parent. */
 		return NULL;
 	}
diff --git a/pidgin/gtkwhiteboard.c b/pidgin/gtkwhiteboard.c
--- a/pidgin/gtkwhiteboard.c
+++ b/pidgin/gtkwhiteboard.c
@@ -399,60 +399,56 @@ pidgin_whiteboard_button_clear_press(G_G
 }
 
 static void
-pidgin_whiteboard_save_response(GtkNativeDialog *self, gint response_id,
+pidgin_whiteboard_save_response(GObject *obj, GAsyncResult *result,
                                 gpointer data)
 {
 	PidginWhiteboard *gtkwb = (PidginWhiteboard *)data;
+	GFile *file = NULL;
+	char *filename = NULL;
 	GdkPixbuf *pixbuf;
-
-	if(response_id == GTK_RESPONSE_ACCEPT) {
-		gboolean success;
-		GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(self));
-		gchar *filename = g_file_get_path(file);
-
-		pixbuf = gdk_pixbuf_get_from_surface(gtkwb->surface, 0, 0,
-		                                     gtkwb->width, gtkwb->height);
+	gboolean success;
 
-		success = gdk_pixbuf_save(pixbuf, filename, "png", NULL,
-		                          "compression", "9", NULL);
-		g_object_unref(pixbuf);
-
-		if (success) {
-			purple_debug_info("gtkwhiteboard", "whiteboard saved to \"%s\"",
-			                  filename);
-		} else {
-			purple_notify_error(NULL, _("Whiteboard"),
-			                    _("Unable to save the file"), NULL, NULL);
-			purple_debug_error("gtkwhiteboard", "whiteboard "
-			                   "couldn't be saved to \"%s\"", filename);
-		}
-
-		g_free(filename);
-		g_object_unref(file);
+	file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(obj), result, NULL);
+	if(file == NULL) {
+		return;
 	}
 
-	g_object_unref(self);
+	filename = g_file_get_path(file);
+	pixbuf = gdk_pixbuf_get_from_surface(gtkwb->surface, 0, 0,
+	                                     gtkwb->width, gtkwb->height);
+
+	success = gdk_pixbuf_save(pixbuf, filename, "png", NULL,
+	                          "compression", "9", NULL);
+	g_object_unref(pixbuf);
+
+	if (success) {
+		purple_debug_info("gtkwhiteboard", "whiteboard saved to \"%s\"",
+		                  filename);
+	} else {
+		purple_notify_error(NULL, _("Whiteboard"),
+		                    _("Unable to save the file"), NULL, NULL);
+		purple_debug_error("gtkwhiteboard",
+		                   "whiteboard couldn't be saved to \"%s\"", filename);
+	}
+
+	g_free(filename);
+	g_object_unref(file);
 }
 
-
 static void
 pidgin_whiteboard_button_save_press(G_GNUC_UNUSED GtkWidget *widget,
                                     gpointer _gtkwb)
 {
 	PidginWhiteboard *gtkwb = _gtkwb;
-	GtkFileChooserNative *chooser;
-
-	chooser = gtk_file_chooser_native_new(_("Save File"), GTK_WINDOW(gtkwb),
-	                                      GTK_FILE_CHOOSER_ACTION_SAVE,
-	                                      _("_Save"), _("_Cancel"));
+	GtkFileDialog *dialog;
 
-	gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser),
-	                                  "whiteboard.png");
-
-	g_signal_connect(chooser, "response",
-	                 G_CALLBACK(pidgin_whiteboard_save_response), gtkwb);
-
-	gtk_native_dialog_show(GTK_NATIVE_DIALOG(chooser));
+	dialog = gtk_file_dialog_new();
+	gtk_file_dialog_set_title(dialog, _("Save File"));
+	gtk_file_dialog_set_modal(dialog, TRUE);
+	gtk_file_dialog_set_initial_name(dialog, "whiteboard.png");
+	gtk_file_dialog_save(dialog, GTK_WINDOW(gtkwb), NULL,
+	                     pidgin_whiteboard_save_response, gtkwb);
+	g_object_unref(dialog);
 }
 
 static void
diff --git a/pidgin/pidginaccounteditor.c b/pidgin/pidginaccounteditor.c
--- a/pidgin/pidginaccounteditor.c
+++ b/pidgin/pidginaccounteditor.c
@@ -48,7 +48,7 @@ struct _PidginAccountEditor {
 	/* User Options */
 	GtkWidget *alias;
 
-	GtkFileChooserNative *avatar_dialog;
+	GtkFileDialog *avatar_dialog;
 	GdkPixbuf *avatar_pixbuf;
 	GtkWidget *avatar_row;
 	GtkWidget *use_custom_avatar;
@@ -963,17 +963,17 @@ pidgin_account_editor_username_changed_c
 }
 
 static void
-pidgin_account_editor_avatar_response_cb(GtkNativeDialog *self,
-                                         gint response_id, gpointer data)
+pidgin_account_editor_avatar_response_cb(GObject *obj, GAsyncResult *result,
+                                         gpointer data)
 {
 	PidginAccountEditor *editor = data;
+	GFile *file = NULL;
 
-	if(response_id == GTK_RESPONSE_ACCEPT) {
+	file = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(obj), result, NULL);
+	if(file != NULL) {
 		GError *error = NULL;
-		GFile *file = NULL;
-		gchar *filename = NULL;
+		char *filename = NULL;
 
-		file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(self));
 		filename = g_file_get_path(file);
 
 		g_clear_object(&editor->avatar_pixbuf);
@@ -999,20 +999,14 @@ pidgin_account_editor_avatar_set_clicked
                                             gpointer data)
 {
 	PidginAccountEditor *editor = data;
+	GtkRoot *root = NULL;
 
-	editor->avatar_dialog = gtk_file_chooser_native_new(_("Buddy Icon"),
-	                                                    GTK_WINDOW(editor),
-	                                                    GTK_FILE_CHOOSER_ACTION_OPEN,
-	                                                    _("_Open"),
-	                                                    _("_Cancel"));
-	gtk_native_dialog_set_transient_for(GTK_NATIVE_DIALOG(editor->avatar_dialog),
-	                                    GTK_WINDOW(editor));
-
-	g_signal_connect(G_OBJECT(editor->avatar_dialog), "response",
-	                 G_CALLBACK(pidgin_account_editor_avatar_response_cb),
-	                 editor);
-
-	gtk_native_dialog_show(GTK_NATIVE_DIALOG(editor->avatar_dialog));
+	root = gtk_widget_get_root(GTK_WIDGET(editor));
+	editor->avatar_dialog = gtk_file_dialog_new();
+	gtk_file_dialog_set_title(editor->avatar_dialog, _("Buddy Icon"));
+	gtk_file_dialog_set_modal(editor->avatar_dialog, TRUE);
+	gtk_file_dialog_open(editor->avatar_dialog, GTK_WINDOW(root), NULL,
+	                     pidgin_account_editor_avatar_response_cb, editor);
 }
 
 static void
diff --git a/pidgin/pidginavatar.c b/pidgin/pidginavatar.c
--- a/pidgin/pidginavatar.c
+++ b/pidgin/pidginavatar.c
@@ -294,6 +294,7 @@ pidgin_avatar_set_custom_cb(G_GNUC_UNUSE
 
 	gtk_file_dialog_open(dialog, window, NULL,
 	                     pidgin_avatar_set_custom_dialog_cb, avatar);
+	g_clear_object(&dialog);
 }
 
 static void
diff --git a/pidgin/pidgindebug.c b/pidgin/pidgindebug.c
--- a/pidgin/pidgindebug.c
+++ b/pidgin/pidgindebug.c
@@ -107,89 +107,81 @@ view_near_bottom(PidginDebugWindow *win)
 }
 
 static void
-save_response_cb(GtkNativeDialog *self, gint response_id, gpointer data)
+save_response_cb(GObject *obj, GAsyncResult *result, gpointer data)
 {
 	PidginDebugWindow *win = (PidginDebugWindow *)data;
-
-	if(response_id == GTK_RESPONSE_ACCEPT) {
-		GFile *file = NULL;
-		GFileOutputStream *output = NULL;
-		GtkTextIter start, end;
-		GDateTime *date = NULL;
-		gchar *date_str = NULL;
-		gchar *tmp = NULL;
-		GError *error = NULL;
-
-		file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(self));
-		output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_NONE, NULL,
-		                        &error);
-		g_object_unref(file);
-
-		if(output == NULL) {
-			purple_debug_error("debug",
-			                   "Unable to open file to save debug log: %s",
-			                   error->message);
-			g_error_free(error);
-			g_object_unref(self);
-			return;
-		}
-
-		date = g_date_time_new_now_local();
-		date_str = g_date_time_format(date, "%c");
-		g_date_time_unref(date);
+	GFile *file = NULL;
+	GFileOutputStream *output = NULL;
+	GtkTextIter start, end;
+	GDateTime *date = NULL;
+	char *date_str = NULL;
+	char *tmp = NULL;
+	GError *error = NULL;
 
-		tmp = g_strdup_printf("Pidgin Debug Log : %s\n", date_str);
-		g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
-		                          NULL, NULL, &error);
-		g_free(tmp);
-		g_free(date_str);
-
-		if(error != NULL) {
-			purple_debug_error("debug", "Unable to save debug log: %s",
-			                   error->message);
-			g_error_free(error);
-			g_object_unref(output);
-			g_object_unref(self);
-			return;
-		}
+	file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(obj), result, NULL);
+	if(file == NULL) {
+		return;
+	}
 
-		gtk_text_buffer_get_bounds(win->buffer, &start, &end);
-		tmp = gtk_text_buffer_get_text(win->buffer, &start, &end, TRUE);
-		g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
-		                          NULL, NULL, &error);
-		g_free(tmp);
+	output = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_NONE, NULL,
+	                        &error);
+	g_clear_object(&file);
 
-		if(error != NULL) {
-			purple_debug_error("debug", "Unable to save debug log: %s",
-			                   error->message);
-			g_error_free(error);
-			g_object_unref(output);
-			g_object_unref(self);
-			return;
-		}
-
-		g_object_unref(output);
+	if(output == NULL) {
+		purple_debug_error("debug",
+		                   "Unable to open file to save debug log: %s",
+		                   error->message);
+		g_error_free(error);
+		return;
 	}
 
-	g_object_unref(self);
+	date = g_date_time_new_now_local();
+	date_str = g_date_time_format(date, "%c");
+	g_date_time_unref(date);
+
+	tmp = g_strdup_printf("Pidgin Debug Log : %s\n", date_str);
+	g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
+	                          NULL, NULL, &error);
+	g_free(tmp);
+	g_free(date_str);
+
+	if(error != NULL) {
+		purple_debug_error("debug", "Unable to save debug log: %s",
+		                   error->message);
+		g_error_free(error);
+		g_object_unref(output);
+		return;
+	}
+
+	gtk_text_buffer_get_bounds(win->buffer, &start, &end);
+	tmp = gtk_text_buffer_get_text(win->buffer, &start, &end, TRUE);
+	g_output_stream_write_all(G_OUTPUT_STREAM(output), tmp, strlen(tmp),
+	                          NULL, NULL, &error);
+	g_free(tmp);
+
+	if(error != NULL) {
+		purple_debug_error("debug", "Unable to save debug log: %s",
+		                   error->message);
+		g_error_free(error);
+		g_object_unref(output);
+		return;
+	}
+
+	g_object_unref(output);
 }
 
 static void
 save_cb(G_GNUC_UNUSED GtkWidget *w, PidginDebugWindow *win)
 {
-	GtkFileChooserNative *filesel;
-
-	filesel = gtk_file_chooser_native_new(_("Save Debug Log"), GTK_WINDOW(win),
-	                                      GTK_FILE_CHOOSER_ACTION_SAVE,
-	                                      _("_Save"), _("_Cancel"));
+	GtkFileDialog *dialog;
 
-	gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(filesel),
-	                                  "purple-debug.log");
-
-	g_signal_connect(filesel, "response", G_CALLBACK(save_response_cb), win);
-
-	gtk_native_dialog_set_modal(GTK_NATIVE_DIALOG(filesel), TRUE);
-	gtk_native_dialog_show(GTK_NATIVE_DIALOG(filesel));
+	dialog = gtk_file_dialog_new();
+	gtk_file_dialog_set_title(dialog, _("Save Debug Log"));
+	gtk_file_dialog_set_modal(dialog, TRUE);
+	gtk_file_dialog_set_initial_name(dialog, "purple-debug.log");
+	gtk_file_dialog_save(dialog, GTK_WINDOW(win), NULL,
+	                     save_response_cb, win);
+	g_clear_object(&dialog);
 }
 
 static void
