Re: "Connect to Server" dialog & new panel menu layout



Hi,

Le jeudi 13 janvier 2005 �4:45 +0100, Alexander Larsson a �it :
> On Wed, 2005-01-12 at 19:20 +0100, Vincent Untz wrote:
> > Here we go. Patch is attached.
> > 
> > Some comments:
> >    * I did not call nautilus_module_init(). Is it needed?
> No.
> 
> >    * I couldn't think of a better way than all the #ifdefs...
> 
> Does those work at all? I would assume that
> nautilus-connect-server-dialog.o only get built once. Can't you pass it
> a NULL for the NautilusWindow, and then create your own
> nautilus_application_present_spatial_window() in
> nautilus-connect-server-dialog-main.c that uses
> gnome_url_show_on_screen().

New patch is attached. I made the patch less intrusive.

However, I don't see how nautilus-connect-server-dialog.o can only get
built once: to use another
nautilus_application_present_spatial_window(), I need to define it
somewhere. So there'll be a conditional include...

The other way I can do it is #include "nautilus-connect-server-dialog.c"
in nautilus-connect-server-dialog-main.c... Hacky way, but should work.

Vincent

-- 
Les gens heureux ne sont pas press�
? depcomp
? stamp-h1
Index: src/.cvsignore
===================================================================
RCS file: /cvs/gnome/nautilus/src/.cvsignore,v
retrieving revision 1.9
diff -u -p -r1.9 .cvsignore
--- src/.cvsignore	10 Mar 2003 22:10:51 -0000	1.9
+++ src/.cvsignore	13 Jan 2005 18:58:46 -0000
@@ -4,8 +4,7 @@ Makefile
 Makefile.in
 nautilus
 nautilus-file-management-properties
-nautilus-server-connect
-nautilus-server-connect.desktop
+nautilus-connect-server
 nautilus-shell-interface-common.c
 nautilus-shell-interface-skels.c
 nautilus-shell-interface-stubs.c
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/src/Makefile.am,v
retrieving revision 1.157
diff -u -p -r1.157 Makefile.am
--- src/Makefile.am	11 Jan 2005 09:39:27 -0000	1.157
+++ src/Makefile.am	13 Jan 2005 18:58:46 -0000
@@ -5,6 +5,7 @@ SUBDIRS=file-manager
 bin_PROGRAMS=					\
 	nautilus				\
 	nautilus-file-management-properties	\
+	nautilus-connect-server			\
 	$(NULL)
 
 INCLUDES =							\
@@ -125,6 +126,20 @@ nautilus_file_management_properties_SOUR
 	nautilus-file-management-properties.h		\
 	nautilus-file-management-properties-main.c	\
 	$(NULL)
+
+nautilus_connect_server_SOURCES= \
+	nautilus-connect-server-dialog.c	\
+	nautilus-connect-server-dialog.h	\
+	nautilus-connect-server-dialog-main.c	\
+	nautilus-connect-server-dialog-main.h	\
+	nautilus-location-entry.c		\
+	nautilus-location-entry.h		\
+	$(NULL)
+
+nautilus_connect_server_CFLAGS= \
+	-DNAUTILUS_CONNECT_SERVER_PROGRAM	\
+	$(NULL)
+
 
 $(nautilus_shell_interface_idl_sources): nautilus_shell_interface_idl_stamp
 nautilus_shell_interface_idl_stamp: nautilus-shell-interface.idl $(ORBIT_IDL)
Index: src/nautilus-connect-server-dialog-main.c
===================================================================
RCS file: src/nautilus-connect-server-dialog-main.c
diff -N src/nautilus-connect-server-dialog-main.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/nautilus-connect-server-dialog-main.c	13 Jan 2005 18:58:46 -0000
@@ -0,0 +1,145 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-connect-server-main.c - Start the "Connect to Server" dialog.
+ * Nautilus
+ *
+ * Copyright (C) 2005 Vincent Untz
+ *
+ * Nautilus is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Nautilus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Vincent Untz <vincent vuntz net>
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtkmain.h>
+#include <gtk/gtkwidget.h>
+
+#include <libgnome/gnome-program.h>
+#include <libgnomeui/gnome-ui-init.h>
+#include <libgnomeui/gnome-url.h>
+
+#include <eel/eel-preferences.h>
+#include <eel/eel-stock-dialogs.h>
+
+#include "nautilus-connect-server-dialog-main.h"
+#include "nautilus-connect-server-dialog.h"
+
+static int open_dialogs;
+
+static void
+dialog_destroyed (GtkWidget *widget,
+		  gpointer   user_data)
+{
+	if (--open_dialogs <= 0)
+		gtk_main_quit ();
+}
+
+static void
+show_uri (const char *uri,
+	  GdkScreen  *screen)
+{
+	GtkDialog *error_dialog;
+	GError    *error;
+	char      *error_message;
+
+	error = NULL;
+	gnome_url_show_on_screen (uri, screen, &error);
+
+	if (error) {
+		error_message = g_strdup_printf (_("Can't display location \"%s\""),
+						 uri);
+
+		error_dialog = eel_show_error_dialog (error_message,
+						      error->message,
+						      _("Can't Display Location"),
+						      NULL);
+
+		open_dialogs++;
+
+		g_signal_connect (error_dialog, "destroy",
+				  G_CALLBACK (dialog_destroyed), NULL);
+
+		gtk_window_set_screen (GTK_WINDOW (error_dialog), screen);
+
+		g_error_free (error);
+		g_free (error_message);
+	}
+}
+
+NautilusWindow *
+nautilus_application_create_navigation_window (NautilusApplication *application,
+					       GdkScreen           *screen)
+{
+	NautilusWindow *window;
+
+	window = g_malloc (sizeof (NautilusWindow));
+	window->screen = screen;
+
+	return window;
+}
+
+NautilusWindow *
+nautilus_application_present_spatial_window   (NautilusApplication *application,
+					       NautilusWindow      *requesting_window,
+					       const char          *location,
+					       GdkScreen           *screen)
+{
+	show_uri (location, screen);
+
+	return NULL;
+}
+
+void
+nautilus_window_go_to (NautilusWindow *window,
+		       const char     *location)
+{
+	g_assert (window != NULL);
+
+	show_uri (location, window->screen);
+	g_free (window);
+}
+
+int
+main (int argc, char *argv[])
+{
+	GtkWidget *dialog;
+
+	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	gnome_program_init ("nautilus-connect-server", VERSION,
+			    LIBGNOMEUI_MODULE, argc, argv,
+			    NULL);
+
+	eel_preferences_init ("/apps/nautilus");
+
+	dialog = nautilus_connect_server_dialog_new (NULL);
+
+	open_dialogs = 1;
+	g_signal_connect (dialog, "destroy",
+			  G_CALLBACK (dialog_destroyed), NULL);
+
+	gtk_widget_show (dialog);
+
+	gtk_main ();
+	
+	return 0;
+}
Index: src/nautilus-connect-server-dialog-main.h
===================================================================
RCS file: src/nautilus-connect-server-dialog-main.h
diff -N src/nautilus-connect-server-dialog-main.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/nautilus-connect-server-dialog-main.h	13 Jan 2005 18:58:46 -0000
@@ -0,0 +1,45 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-connect-server-main.h - Start the "Connect to Server" dialog.
+ * Nautilus
+ *
+ * Copyright (C) 2005 Vincent Untz
+ *
+ * Nautilus is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Nautilus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Vincent Untz <vincent vuntz net>
+ */
+
+#ifndef NAUTILUS_CONNECT_SERVER_DIALOG_MAIN_H
+#define NAUTILUS_CONNECT_SERVER_DIALOG_MAIN_H
+
+typedef char      NautilusApplication;
+typedef struct {
+	NautilusApplication *application;
+	GdkScreen           *screen;
+} NautilusWindow;
+
+NautilusWindow *nautilus_application_create_navigation_window (NautilusApplication *application,
+							       GdkScreen           *screen);
+NautilusWindow *nautilus_application_present_spatial_window   (NautilusApplication *application,
+							       NautilusWindow      *requesting_window,
+							       const char          *location,
+							       GdkScreen           *screen);
+void            nautilus_window_go_to                         (NautilusWindow      *window,
+							       const char          *location);
+
+#endif /* NAUTILUS_CONNECT_SERVER_DIALOG_MAIN_H */
Index: src/nautilus-connect-server-dialog.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-connect-server-dialog.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-connect-server-dialog.c
--- src/nautilus-connect-server-dialog.c	1 Oct 2004 11:33:00 -0000	1.10
+++ src/nautilus-connect-server-dialog.c	13 Jan 2005 18:58:46 -0000
@@ -29,7 +29,10 @@
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-vfs-extensions.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
+#include <glib/gi18n.h>
 #include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
 #include <gtk/gtktable.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkstock.h>
@@ -724,9 +727,8 @@ nautilus_connect_server_dialog_new (Naut
 	if (window) {
 		gtk_window_set_screen (GTK_WINDOW (dialog),
 				       gtk_window_get_screen (GTK_WINDOW (window)));
+		NAUTILUS_CONNECT_SERVER_DIALOG (dialog)->details->application = window->application;
 	}
-
-	NAUTILUS_CONNECT_SERVER_DIALOG (dialog)->details->application = window->application;
 
 	return dialog;
 }
Index: src/nautilus-connect-server-dialog.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-connect-server-dialog.h,v
retrieving revision 1.1
diff -u -p -r1.1 nautilus-connect-server-dialog.h
--- src/nautilus-connect-server-dialog.h	6 Nov 2003 16:07:02 -0000	1.1
+++ src/nautilus-connect-server-dialog.h	13 Jan 2005 18:58:46 -0000
@@ -25,7 +25,11 @@
 #define NAUTILUS_CONNECT_SERVER_DIALOG_H
 
 #include <gtk/gtkdialog.h>
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
 #include "nautilus-window.h"
+#else
+#include "nautilus-connect-server-dialog-main.h"
+#endif
 
 #define NAUTILUS_TYPE_CONNECT_SERVER_DIALOG         (nautilus_connect_server_dialog_get_type ())
 #define NAUTILUS_CONNECT_SERVER_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CONNECT_SERVER_DIALOG, NautilusConnectServerDialog))


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