? .nautilus-connect-server-dialog.c.swp
? nautilus-connect-server-dialog.glade
? nautilus-connect-server-dialog.gladep
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/src/Makefile.am,v
retrieving revision 1.155
diff -u -p -r1.155 Makefile.am
--- a/Makefile.am	18 Feb 2004 11:59:02 -0000	1.155
+++ b/Makefile.am	29 May 2004 13:43:08 -0000
@@ -164,6 +164,7 @@ gladedir = $(datadir)/nautilus/glade
 glade_DATA = \
 	nautilus-bookmarks-window.glade			\
 	nautilus-file-management-properties.glade	\
+	nautilus-connect-server-dialog.glade		\
 	$(NULL)
 
 CLEANFILES = \
Index: nautilus-connect-server-dialog.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-connect-server-dialog.c,v
retrieving revision 1.7
diff -u -p -r1.7 nautilus-connect-server-dialog.c
--- a/nautilus-connect-server-dialog.c	6 Feb 2004 17:25:36 -0000	1.7
+++ b/nautilus-connect-server-dialog.c	29 May 2004 13:43:09 -0000
@@ -28,15 +28,23 @@
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-vfs-extensions.h>
+#include <gtk/gtk.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtktable.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkstock.h>
+#include <glade/glade.h>
 #include "nautilus-location-entry.h"
 
 struct _NautilusConnectServerDialogDetails {
 	GtkWidget *name_entry;
 	GtkWidget *uri_entry;
+	
+	GtkWidget *notebook;
+	GtkWidget *remove_button;
+
+	GtkListStore *recent_servers_list;
+	GtkListStore *favourite_servers_list;
 };
 
 static void  nautilus_connect_server_dialog_class_init       (NautilusConnectServerDialogClass *class);
@@ -117,9 +125,14 @@ connect_to_server (NautilusConnectServer
 		}
 
 		gnome_vfs_connect_to_server (uri, name, icon);
+
+		/*
+		 * XXX: Add code to store recent servers
+		 */
+
 		gtk_widget_destroy (GTK_WIDGET (dialog));
 	}
-		g_free (name);
+	g_free (name);
 	g_free (uri);
 }
 
@@ -153,6 +166,47 @@ entry_activate_callback (GtkEntry *entry
 }
 
 static void
+server_selected_callback (GtkTreeSelection	*selection,
+			  gpointer		user_data)
+{
+	NautilusConnectServerDialog *dialog;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	gchar *name, *uri;
+
+	dialog = NAUTILUS_CONNECT_SERVER_DIALOG (user_data);
+
+	if (gtk_tree_selection_get_selected (selection, &model, &iter))
+	{
+		gtk_widget_set_sensitive (dialog->details->remove_button,
+				(gtk_notebook_get_current_page (GTK_NOTEBOOK (dialog->details->notebook)) == 0));
+		
+		gtk_tree_model_get (model, &iter, 0, &name, 1, &uri, -1);
+		
+		gtk_entry_set_text (GTK_ENTRY (dialog->details->name_entry), g_strdup (name));
+		gtk_entry_set_text (GTK_ENTRY (dialog->details->uri_entry), g_strdup (uri));
+
+		g_free (name);
+		g_free (uri);
+	}
+	else
+	{
+		gtk_widget_set_sensitive (dialog->details->remove_button, FALSE);
+	}
+}
+
+static void
+notebook_changed_page_cb (GtkNotebook		*notebook,
+			  GtkNotebookPage	*page,
+			  guint			page_num,
+			  gpointer		user_data)
+{
+	GtkWidget *button = GTK_WIDGET (user_data);
+
+	gtk_widget_set_sensitive (button, (page_num == 0));
+}
+
+static void
 nautilus_connect_server_dialog_class_init (NautilusConnectServerDialogClass *class)
 {
 	GObjectClass *gobject_class;
@@ -168,79 +222,105 @@ nautilus_connect_server_dialog_class_ini
 static void
 nautilus_connect_server_dialog_init (NautilusConnectServerDialog *dialog)
 {
-	GtkWidget *label;
-	GtkWidget *table;
-	char *text;
+	GladeXML *xml;
+	GtkWidget *widget, *widget2;
+	GtkCellRenderer *renderer;
+	GtkTreeIter iter;
+	
+	xml = glade_xml_new (GLADEDIR "/nautilus-connect-server-dialog.glade", NULL, NULL);
+	widget2 = glade_xml_get_widget (xml, "cts_vbox");
+	widget = glade_xml_get_widget (xml, "cts_table");
+	/* this unparents the table from the container in glade, and attaches it to our new table,
+	 * while hacky, it means I don't have to think about things outside this function */
+	g_object_ref (widget);
+	gtk_container_remove (GTK_CONTAINER (widget2), widget);
+	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), widget, TRUE, TRUE, 0);
+	g_object_unref (widget);
 	
 	dialog->details = g_new0 (NautilusConnectServerDialogDetails, 1);
 
 	gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server"));
-	gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
+	gtk_window_set_default_size (GTK_WINDOW (dialog), 500, -1);
 	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
 
-	table = gtk_table_new (3, 2, FALSE);
-	gtk_container_set_border_width (GTK_CONTAINER (table), 5);
-	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
-			    table, TRUE, TRUE, 0);
-	gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-	gtk_table_set_col_spacings (GTK_TABLE (table), 12);
-	gtk_widget_show (table);
-	
-	label = gtk_label_new_with_mnemonic (_("Link _name:"));
-	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-	gtk_widget_show (label);
-	gtk_table_attach (GTK_TABLE (table), label,
-			  0, 1,
-			  0, 1,
-			  GTK_FILL, GTK_FILL,
-			  0, 0);
-	
-	dialog->details->name_entry = gtk_entry_new ();
-	gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->name_entry);
-	gtk_widget_show (dialog->details->name_entry);
-	gtk_table_attach (GTK_TABLE (table), dialog->details->name_entry,
-			  1, 2,
-			  0, 1,
-			  GTK_FILL | GTK_EXPAND, GTK_FILL,
-			  0, 0);
-
-	
-	label = gtk_label_new_with_mnemonic (_("_Location (URL):"));
-	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-	gtk_widget_show (label);
-	gtk_table_attach (GTK_TABLE (table), label,
-			  0, 1,
-			  1, 2,
-			  GTK_FILL, GTK_FILL,
-			  0, 0);
-	
-	dialog->details->uri_entry = nautilus_location_entry_new ();
-	gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->uri_entry);
+	dialog->details->name_entry = glade_xml_get_widget (xml, "cto_link_name");
+	dialog->details->uri_entry = glade_xml_get_widget (xml, "cto_link_url");
 	g_signal_connect (dialog->details->uri_entry,
 			  "activate", 
 			  G_CALLBACK (entry_activate_callback),
 			  dialog);
-	gtk_widget_show (dialog->details->uri_entry);
-	gtk_table_attach (GTK_TABLE (table), dialog->details->uri_entry,
-			  1, 2,
-			  1, 2,
-			  GTK_FILL | GTK_EXPAND, GTK_FILL,
-			  0, 0);
-	text = g_strdup_printf ("<small><i><b>%s </b>ftp://ftp.gnome.org</i></small>", _("Example:"));
-	label = gtk_label_new (text);
-	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
-	gtk_widget_show (label);
-	g_free (text);
-	gtk_table_attach (GTK_TABLE (table), label,
-			  1, 2,
-			  2, 3,
-			  GTK_FILL | GTK_EXPAND, GTK_FILL,
-			  0, 0);
-	/*	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
-		label, TRUE, TRUE, 0);*/
 
+	dialog->details->notebook = glade_xml_get_widget (xml, "cts_notebook");
+	dialog->details->remove_button = glade_xml_get_widget (xml, "cts_remove_button");
+	g_signal_connect (GTK_NOTEBOOK (dialog->details->notebook), "switch-page",
+			G_CALLBACK (notebook_changed_page_cb), dialog->details->remove_button);
+	/* FIXME: attach a clicked signal to widget2 */
+	
+	dialog->details->favourite_servers_list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+	dialog->details->recent_servers_list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+	/*
+	 * some mockup values
+	 */
+	gtk_list_store_append (dialog->details->favourite_servers_list, &iter);
+	gtk_list_store_set (dialog->details->favourite_servers_list, &iter,
+			0, "home on mussel",
+			1, "sftp://mussel.waix.ucc.gu.uwa.edu.au/home/ucc/davyd",
+			-1);
+
+	gtk_list_store_append (dialog->details->favourite_servers_list, &iter);
+	gtk_list_store_set (dialog->details->favourite_servers_list, &iter,
+			0, "home on billy",
+			1, "sftp://billy.angrygoats.net/home/davyd",
+			-1);
+
+	gtk_list_store_append (dialog->details->favourite_servers_list, &iter);
+	gtk_list_store_set (dialog->details->favourite_servers_list, &iter,
+			0, "home on oracle",
+			1, "sftp://oracle.bridgewayconsulting.com.au/home/davyd",
+			-1);
+	
+	gtk_list_store_append (dialog->details->favourite_servers_list, &iter);
+	gtk_list_store_set (dialog->details->favourite_servers_list, &iter,
+			0, "webserver",
+			1, "sftp://mussel.waix.ucc.gu.uwa.edu.au/services/http",
+			-1);
+	/*
+	 * end mockup values
+	 */
+	/*
+	 * the favourites treeview
+	 */
+	widget = glade_xml_get_widget (xml, "cts_favourites_treeview");
+	gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (dialog->details->favourite_servers_list));
+	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), "changed",
+				G_CALLBACK (server_selected_callback), dialog);
+	/* FIXME: row-activated signal belongs here */
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget), -1,
+			_("Server"), renderer,
+			"text", 0, NULL);
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget), -1,
+			_("URL"), renderer,
+			"text", 1, NULL);
+	/*
+	 * the recent entries treeview
+	 */
+	widget = glade_xml_get_widget (xml, "cts_recent_treeview");
+	gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (dialog->details->recent_servers_list));
+	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), "changed",
+				G_CALLBACK (server_selected_callback), dialog);
+	/* FIXME: row-activated signal belongs here too */
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget), -1,
+			_("Server"), renderer,
+			"text", 0, NULL);
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget), -1,
+			_("URL"), renderer,
+			"text", 1, NULL);
+	
 	gtk_dialog_add_button (GTK_DIALOG (dialog),
 			       GTK_STOCK_CANCEL,
 			       GTK_RESPONSE_CANCEL);
@@ -253,6 +333,9 @@ nautilus_connect_server_dialog_init (Nau
 	g_signal_connect (dialog, "response",
 			  G_CALLBACK (response_callback),
 			  dialog);
+
+	g_object_unref (xml);
+	gtk_widget_show_all (GTK_WIDGET (dialog));
 }
 
 GtkWidget *
