[nautilus/open-with: 5/6] autorun: port to GtkAppChooserDialog



commit 789bc6f319e01994cacbda217fed9fdcd3d9c088
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Nov 23 17:59:49 2010 +0100

    autorun: port to GtkAppChooserDialog

 libnautilus-private/nautilus-autorun.c |   62 ++++++++++---------------------
 1 files changed, 20 insertions(+), 42 deletions(-)
---
diff --git a/libnautilus-private/nautilus-autorun.c b/libnautilus-private/nautilus-autorun.c
index 51dc103..32fafb6 100644
--- a/libnautilus-private/nautilus-autorun.c
+++ b/libnautilus-private/nautilus-autorun.c
@@ -39,7 +39,6 @@
 #include "nautilus-file-operations.h"
 #include "nautilus-autorun.h"
 #include "nautilus-program-choosing.h"
-#include "nautilus-open-with-dialog.h"
 #include "nautilus-desktop-icon-file.h"
 #include "nautilus-file-utilities.h"
 
@@ -205,8 +204,6 @@ typedef struct
 	gboolean update_settings;
 	NautilusAutorunComboBoxChanged changed_cb;
 	gpointer user_data;
-
-	gboolean other_application_selected;
 } NautilusAutorunComboBoxData;
 
 static void 
@@ -221,10 +218,18 @@ nautilus_autorun_combobox_data_destroy (NautilusAutorunComboBoxData *data)
 }
 
 static void
-other_application_selected (NautilusOpenWithDialog *dialog,
-			    GAppInfo *app_info,
-			    NautilusAutorunComboBoxData *data)
+app_chooser_dialog_response_cb (GtkDialog *dialog,
+				gint response_id,
+				NautilusAutorunComboBoxData *data)
 {
+	GAppInfo *app_info;
+
+	if (response_id != GTK_RESPONSE_OK) {
+		goto out;
+	}
+
+	app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));
+
 	if (data->changed_cb != NULL) {
 		data->changed_cb (TRUE, FALSE, FALSE, app_info, data->user_data);
 	}
@@ -233,35 +238,15 @@ other_application_selected (NautilusOpenWithDialog *dialog,
 		g_app_info_set_as_default_for_type (app_info,
 						    data->x_content_type,
 						    NULL);
-		data->other_application_selected = TRUE;
 	}
 
-	/* rebuild so we include and select the new application in the list */
-	nautilus_autorun_rebuild_combo_box (data->combo_box);
-}
-
-static void
-handle_dialog_closure (NautilusAutorunComboBoxData *data)
-{
-	if (!data->other_application_selected) {
-		/* reset combo box so we don't linger on "Open with other Application..." */
-		nautilus_autorun_rebuild_combo_box (data->combo_box);
-	}
-}
+	g_object_unref (app_info);
 
-static void
-dialog_response_cb (GtkDialog *dialog,
-                    gint response,
-                    NautilusAutorunComboBoxData *data)
-{
-	handle_dialog_closure (data);
-}
+ out:
+	gtk_widget_destroy (GTK_WIDGET (dialog));
 
-static void
-dialog_destroy_cb (GtkWidget *object,
-                   NautilusAutorunComboBoxData *data)
-{
-	handle_dialog_closure (data);
+	/* rebuild so we include and select the new application in the list */
+	nautilus_autorun_rebuild_combo_box (data->combo_box);
 }
 
 static void 
@@ -336,18 +321,11 @@ combo_box_changed (GtkComboBox *combo_box,
 	{
 		GtkWidget *dialog;
 
-		data->other_application_selected = FALSE;
-
-		dialog = nautilus_add_application_dialog_new (NULL, x_content_type);
-		gtk_window_set_transient_for (GTK_WINDOW (dialog),
-					      GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (combo_box))));
-		g_signal_connect (dialog, "application_selected",
-				  G_CALLBACK (other_application_selected),
-				  data);
+		dialog = gtk_app_chooser_dialog_new_for_content_type (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (combo_box))),
+								      0, x_content_type);
 		g_signal_connect (dialog, "response",
-				  G_CALLBACK (dialog_response_cb), data);
-		g_signal_connect (dialog, "destroy",
-				  G_CALLBACK (dialog_destroy_cb), data);
+				  G_CALLBACK (app_chooser_dialog_response_cb),
+				  data);
 		gtk_widget_show (GTK_WIDGET (dialog));
 
 		break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]