[nautilus] connect-dialog: display a fatal error if GVfs doesn't have methods



commit 1b79a8666fee56cdb704e8757f28acf486f7dc54
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Sep 20 17:37:38 2010 +0200

    connect-dialog: display a fatal error if GVfs doesn't have methods
    
    I.e. when GVfs is not installed.

 src/nautilus-connect-server-dialog.c |   41 +++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-connect-server-dialog.c b/src/nautilus-connect-server-dialog.c
index 47b6ffc..8e15117 100644
--- a/src/nautilus-connect-server-dialog.c
+++ b/src/nautilus-connect-server-dialog.c
@@ -46,6 +46,7 @@
 struct _NautilusConnectServerDialogDetails {
 	NautilusApplication *application;
 
+	GtkWidget *primary_table;
 	GtkWidget *user_details;
 	GtkWidget *port_spinbutton;
 
@@ -187,6 +188,33 @@ dialog_set_connecting (NautilusConnectServerDialog *dialog)
 	gtk_widget_set_sensitive (dialog->details->connect_button, FALSE);
 }
 
+static void
+connect_dialog_gvfs_error (NautilusConnectServerDialog *dialog)
+{
+	GtkWidget *hbox, *image, *content_area, *label;
+
+	connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_ERROR);
+
+	content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar));
+
+	hbox = gtk_hbox_new (FALSE, 6);
+	gtk_container_add (GTK_CONTAINER (content_area), hbox);
+	gtk_widget_show (hbox);
+
+	image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_SMALL_TOOLBAR);
+	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 6);
+	gtk_widget_show (image);
+	
+	label = gtk_label_new (_("Can't load the supported server method list.\n"
+				 "Please check your GVfs installation."));
+	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6);
+	gtk_widget_show (label);
+
+	gtk_widget_set_sensitive (dialog->details->connect_button, FALSE);
+	gtk_widget_set_sensitive (dialog->details->primary_table, FALSE);
+
+	gtk_widget_show (dialog->details->info_bar);
+}
 
 static void
 iconized_entry_restore (gpointer data,
@@ -732,7 +760,16 @@ setup_for_type (NautilusConnectServerDialog *dialog)
 	dialog_cleanup (dialog);
 
 	/* get our method info */
-	gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter);
+	if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo),
+					    &iter)) {
+		/* there are no entries in the combo, something is wrong
+		 * with our GVfs installation.
+		 */
+		connect_dialog_gvfs_error (dialog);
+
+		return;
+	}
+
 	gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)),
 			    &iter, 0, &index, -1);
 	g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
@@ -844,6 +881,8 @@ nautilus_connect_server_dialog_init (NautilusConnectServerDialog *dialog)
 	gtk_container_add (GTK_CONTAINER (alignment), table);
 	gtk_widget_show (table);
 
+	dialog->details->primary_table = table;
+
 	/* first row: server entry + port spinbutton */
 	label = gtk_label_new_with_mnemonic (_("_Server:"));
 	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);



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