Re: "Connect to Server" dialog & new panel menu layout
- From: Vincent Untz <vincent vuntz net>
- To: Alexander Larsson <alexl redhat com>
- Cc: nautilus-list gnome org
- Subject: Re: "Connect to Server" dialog & new panel menu layout
- Date: Wed, 12 Jan 2005 19:20:33 +0100
Le mercredi 12 janvier 2005 �6:24 +0100, Alexander Larsson a �it :
> On Wed, 2005-01-12 at 15:17 +0100, Vincent Untz wrote:
> > Hi guys,
> >
> > Since the 2.9.4 release, the panel has a brand new layout for the
> > menu bar. See http://bugzilla.gnome.org/show_bug.cgi?id=161613 for
> > more informations.
> >
> > I'd like to add a "Connect to Server" button to the menu. This
> > would open the very same dialog than the one in nautilus. As Mark
> > commented in the above bug, it's not that great to copy & paste
> > the code from nautilus.
> >
> > Thus, I'm left with three possibilities to make this happen:
> >
> > 1) Move the code from nautilus to the panel
> > 2) Add a "--connect-server" argument to nautilus
> > 3) Wait for a libgnomevfsui library
> >
> > I'm not sure 1) is a great idea since the dialog has its place in
> > nautilus too. 3) won't happen for 2.10, so I'm left with option 2).
> >
> > Does adding a "--connect-server" argument to nautilus sound
> > reasonable?
>
> I think:
> 4) Create a separate executable that ships with nautilus that just links
> in nautilus-connect-server.c and whatever else is needed. Then launch
> that.
>
> is better.
Here we go. Patch is attached.
Some comments:
* I did not call nautilus_module_init(). Is it needed?
* I couldn't think of a better way than all the #ifdefs...
* I'm calling gtk_widget_hide (dialog) and not destroying it because
destroying it means quitting the program
* I'm using eel_run_simple_dialog() because eel_show_error_dialog()
is not blocking
Vincent
--
Les gens heureux ne sont pas press�
? nautilus-connect-server
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/src/Makefile.am,v
retrieving revision 1.157
diff -u -p -r1.157 Makefile.am
--- Makefile.am 11 Jan 2005 09:39:27 -0000 1.157
+++ Makefile.am 12 Jan 2005 18:14:15 -0000
@@ -5,6 +5,7 @@ SUBDIRS=file-manager
bin_PROGRAMS= \
nautilus \
nautilus-file-management-properties \
+ nautilus-connect-server \
$(NULL)
INCLUDES = \
@@ -125,6 +126,19 @@ 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-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: nautilus-connect-server-dialog-main.c
===================================================================
RCS file: nautilus-connect-server-dialog-main.c
diff -N nautilus-connect-server-dialog-main.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ nautilus-connect-server-dialog-main.c 12 Jan 2005 18:14:15 -0000
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-connect-server-main.c - Start the "Connect to Server" dialog.
+
+ Copyright (C) 2005 Vincent Untz
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. 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 <eel/eel-preferences.h>
+
+#include "nautilus-connect-server-dialog.h"
+
+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 ();
+
+ g_signal_connect (dialog, "destroy", gtk_main_quit, NULL);
+ gtk_widget_show (dialog);
+
+ gtk_main ();
+
+ return 0;
+}
Index: 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
--- nautilus-connect-server-dialog.c 1 Oct 2004 11:33:00 -0000 1.10
+++ nautilus-connect-server-dialog.c 12 Jan 2005 18:14:15 -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>
@@ -37,6 +40,10 @@
#include "nautilus-location-entry.h"
#include <libnautilus-private/nautilus-global-preferences.h>
+#ifdef NAUTILUS_CONNECT_SERVER_PROGRAM
+#include <libgnomeui/gnome-url.h>
+#endif
+
/* TODO:
* - dns-sd fill out servers
* - pre-fill user?
@@ -45,7 +52,9 @@
*/
struct _NautilusConnectServerDialogDetails {
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
NautilusApplication *application;
+#endif
GtkWidget *table;
@@ -112,6 +121,33 @@ nautilus_connect_server_dialog_destroy (
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
+#ifdef NAUTILUS_CONNECT_SERVER_PROGRAM
+static void
+show_uri (NautilusConnectServerDialog *dialog,
+ const char *uri)
+{
+ GError *error = NULL;
+ GdkScreen *screen;
+ char *error_message;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (dialog));
+ gnome_url_show_on_screen (uri, screen, &error);
+
+ if (error) {
+ error_message = g_strdup_printf (_("Can't display location \"%s\""),
+ uri);
+ eel_run_simple_dialog (GTK_WIDGET (dialog), FALSE,
+ GTK_MESSAGE_ERROR,
+ error_message, error->message,
+ _("Can't Display Location"),
+ GTK_STOCK_OK, NULL);
+
+ g_error_free (error);
+ g_free (error_message);
+ }
+}
+#endif
+
static void
connect_to_server (NautilusConnectServerDialog *dialog)
{
@@ -284,18 +320,23 @@ connect_to_server (NautilusConnectServer
}
gnome_vfs_connect_to_server (uri, name, icon);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
+ gtk_widget_hide (GTK_WIDGET (dialog));
if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
nautilus_application_present_spatial_window (dialog->details->application,
NULL,
uri,
gtk_widget_get_screen (GTK_WIDGET (dialog)));
+#else
+ show_uri (dialog, uri);
+#endif
}
g_free (uri);
g_free (name);
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
@@ -303,10 +344,13 @@ response_callback (NautilusConnectServer
int response_id,
gpointer data)
{
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
NautilusWindow *window;
+#endif
switch (response_id) {
case RESPONSE_BROWSE:
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (dialog->details->application,
gtk_widget_get_screen (GTK_WIDGET (dialog)));
@@ -317,6 +361,10 @@ response_callback (NautilusConnectServer
"network:///",
gtk_widget_get_screen (GTK_WIDGET (dialog)));
}
+#else
+ gtk_widget_hide (GTK_WIDGET (dialog));
+ show_uri (dialog, "network:///");
+#endif
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case RESPONSE_CONNECT:
@@ -715,18 +763,23 @@ nautilus_connect_server_dialog_init (Nau
}
GtkWidget *
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
nautilus_connect_server_dialog_new (NautilusWindow *window)
+#else
+nautilus_connect_server_dialog_new (void)
+#endif
{
GtkWidget *dialog;
dialog = gtk_widget_new (NAUTILUS_TYPE_CONNECT_SERVER_DIALOG, NULL);
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
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;
+#endif
return dialog;
}
Index: 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
--- nautilus-connect-server-dialog.h 6 Nov 2003 16:07:02 -0000 1.1
+++ nautilus-connect-server-dialog.h 12 Jan 2005 18:14:15 -0000
@@ -25,7 +25,9 @@
#define NAUTILUS_CONNECT_SERVER_DIALOG_H
#include <gtk/gtkdialog.h>
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
#include "nautilus-window.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))
@@ -46,6 +48,10 @@ struct _NautilusConnectServerDialogClass
};
GType nautilus_connect_server_dialog_get_type (void);
+#ifndef NAUTILUS_CONNECT_SERVER_PROGRAM
GtkWidget* nautilus_connect_server_dialog_new (NautilusWindow *window);
+#else
+GtkWidget* nautilus_connect_server_dialog_new (void);
+#endif
#endif /* NAUTILUS_CONNECT_SERVER_DIALOG_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]