[nautilus-sendto] main: Handle delete events as well



commit cd2f0c559f0284c1e6f1bf73605600c1816bb53c
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Nov 4 17:29:19 2010 +0000

    main: Handle delete events as well
    
    So that the dialog will close on "Escape" or when closing
    from the window manager.

 src/nautilus-sendto-command.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-sendto-command.c b/src/nautilus-sendto-command.c
index 9ff3b23..952e0a9 100644
--- a/src/nautilus-sendto-command.c
+++ b/src/nautilus-sendto-command.c
@@ -83,7 +83,7 @@ static const GOptionEntry entries[] = {
 };
 
 static void
-destroy_dialog (GtkWidget *widget, gpointer data)
+destroy_dialog (void)
 {
         gtk_main_quit ();
 }
@@ -103,7 +103,6 @@ send_callback (GObject      *object,
 	       GAsyncResult *res,
 	       gpointer      user_data)
 {
-	NautilusSendto *nst = (NautilusSendto *) user_data;
 	NautilusSendtoSendStatus status;
 
 	status = nautilus_sendto_plugin_send_files_finish (NAUTILUS_SENDTO_PLUGIN (object),
@@ -112,7 +111,7 @@ send_callback (GObject      *object,
 	g_message ("send_callback %d", status);
 
 	if (status == NST_SEND_STATUS_SUCCESS_DONE) {
-		destroy_dialog (NULL, NULL);
+		destroy_dialog ();
 	} else if (status == NST_SEND_STATUS_SUCCESS) {
 		//FIXME make the buttons into a single close button
 	} else if (status == NST_SEND_STATUS_FAILED) {
@@ -123,7 +122,7 @@ send_callback (GObject      *object,
 }
 
 static void
-send_button_cb (GtkWidget *widget, NautilusSendto *nst)
+send_button_cb (NautilusSendto *nst)
 {
 	GtkTreeModel *model;
 	GtkTreeSelection *treeselection;
@@ -160,6 +159,24 @@ send_button_cb (GtkWidget *widget, NautilusSendto *nst)
 }
 
 static void
+dialog_response_cb (GtkDialog      *dialog,
+		    int             response_id,
+		    NautilusSendto *nst)
+{
+	switch (response_id) {
+	case GTK_RESPONSE_CANCEL:
+	case GTK_RESPONSE_DELETE_EVENT:
+		destroy_dialog ();
+		break;
+	case GTK_RESPONSE_OK:
+		send_button_cb (nst);
+		break;
+	default:
+		g_warning ("Unhandled dialog response '%d'", response_id);
+	}
+}
+
+static void
 can_send_cb (NautilusSendtoPlugin *plugin,
 	     const char           *id,
 	     gboolean              can_send,
@@ -462,10 +479,8 @@ nautilus_sendto_create_ui (NautilusSendto *nst)
 	g_free (title);
 
 	set_model_for_options_treeview (nst);
-	g_signal_connect (G_OBJECT (nst->cancel_button), "clicked",
-			  G_CALLBACK (destroy_dialog), NULL);
-	g_signal_connect (G_OBJECT (nst->send_button), "clicked",
-			  G_CALLBACK (send_button_cb), nst);
+	g_signal_connect (G_OBJECT (nst->dialog), "response",
+			  G_CALLBACK (dialog_response_cb), nst);
 
 	gtk_widget_show (nst->dialog);
 }



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