summaryrefslogtreecommitdiff
path: root/src/nautilus-location-dialog.c
diff options
context:
space:
mode:
authorDave Camp <dave@ximian.com>2003-10-11 17:26:39 +0000
committerDave Camp <campd@src.gnome.org>2003-10-11 17:26:39 +0000
commit20515128ceae1a69f6423404c4b4d402b53669f5 (patch)
treedac6125d54f292a69cba5f239edf9114dca0ac2e /src/nautilus-location-dialog.c
parent5101d9b5618e41c1fad19dc27fb8aa46458de21a (diff)
downloadnautilus-20515128ceae1a69f6423404c4b4d402b53669f5.tar.gz
Add nautilus-location-dialog.[ch] and nautilus-location-entry.[ch]
2003-10-11 Dave Camp <dave@ximian.com> * src/Makefile.am: Add nautilus-location-dialog.[ch] and nautilus-location-entry.[ch] * src/nautilus-location-bar.c: (editable_event_after_callback), (nautilus_location_bar_init): * src/nautilus-location-entry.c: Moved the tab-completing entry into its own widget. * src/nautilus-location-dialog.c * src/nautilus-spatial-window.c: (real_prompt_for_location), (nautilus_spatial_window_class_init): Add an Open Location dialog for the spatial windows.
Diffstat (limited to 'src/nautilus-location-dialog.c')
-rw-r--r--src/nautilus-location-dialog.c191
1 files changed, 191 insertions, 0 deletions
diff --git a/src/nautilus-location-dialog.c b/src/nautilus-location-dialog.c
new file mode 100644
index 000000000..ebbe30f6f
--- /dev/null
+++ b/src/nautilus-location-dialog.c
@@ -0,0 +1,191 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ * Nautilus
+ *
+ * Copyright (C) 2003 Ximian, Inc.
+ *
+ * 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.
+ */
+
+#include <config.h>
+#include "nautilus-location-dialog.h"
+
+#include <eel/eel-gtk-macros.h>
+#include <eel/eel-vfs-extensions.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkstock.h>
+#include "nautilus-location-entry.h"
+
+struct _NautilusLocationDialogDetails {
+ GtkWidget *entry;
+ NautilusWindow *window;
+};
+
+static void nautilus_location_dialog_class_init (NautilusLocationDialogClass *class);
+static void nautilus_location_dialog_init (NautilusLocationDialog *dialog);
+
+EEL_CLASS_BOILERPLATE (NautilusLocationDialog,
+ nautilus_location_dialog,
+ GTK_TYPE_DIALOG)
+enum {
+ RESPONSE_OPEN,
+ RESPONSE_CANCEL
+};
+
+static void
+nautilus_location_dialog_finalize (GObject *object)
+{
+ NautilusLocationDialog *dialog;
+
+ dialog = NAUTILUS_LOCATION_DIALOG (object);
+
+ g_free (dialog->details);
+
+ EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+}
+
+static void
+nautilus_location_dialog_destroy (GtkObject *object)
+{
+ NautilusLocationDialog *dialog;
+
+ dialog = NAUTILUS_LOCATION_DIALOG (object);
+
+ EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+}
+
+static void
+open_current_location (NautilusLocationDialog *dialog)
+{
+ char *uri;
+ char *user_location;
+
+ user_location = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->entry), 0, -1);
+ uri = eel_make_uri_from_input (user_location);
+ g_free (user_location);
+
+ nautilus_window_go_to (dialog->details->window, uri);
+
+ g_free (uri);
+}
+
+static void
+response_callback (NautilusLocationDialog *dialog,
+ int response_id,
+ gpointer data)
+{
+ switch (response_id) {
+ case RESPONSE_OPEN :
+ open_current_location (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+ case GTK_RESPONSE_NONE :
+ case GTK_RESPONSE_DELETE_EVENT :
+ case RESPONSE_CANCEL :
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+ default :
+ g_assert_not_reached ();
+ }
+}
+
+static void
+entry_activate_callback (GtkEntry *entry,
+ gpointer user_data)
+{
+ NautilusLocationDialog *dialog;
+
+ dialog = NAUTILUS_LOCATION_DIALOG (user_data);
+ gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_OPEN);
+}
+
+static void
+nautilus_location_dialog_class_init (NautilusLocationDialogClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkObjectClass *object_class;
+
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = nautilus_location_dialog_finalize;
+
+ object_class = GTK_OBJECT_CLASS (class);
+ object_class->destroy = nautilus_location_dialog_destroy;
+}
+
+static void
+nautilus_location_dialog_init (NautilusLocationDialog *dialog)
+{
+ GtkWidget *box;
+ GtkWidget *label;
+
+ dialog->details = g_new0 (NautilusLocationDialogDetails, 1);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Open Location"));
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+ box = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (box);
+
+ label = gtk_label_new (_("Location:"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 6);
+
+ dialog->details->entry = nautilus_location_entry_new ();
+ g_signal_connect (dialog->details->entry,
+ "activate",
+ G_CALLBACK (entry_activate_callback),
+ dialog);
+
+ gtk_widget_show (dialog->details->entry);
+
+ gtk_box_pack_start (GTK_BOX (box), dialog->details->entry,
+ TRUE, TRUE, 6);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ box, TRUE, TRUE, 12);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL,
+ RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_OPEN,
+ RESPONSE_OPEN);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ RESPONSE_OPEN);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (response_callback),
+ dialog);
+}
+
+GtkWidget *
+nautilus_location_dialog_new (NautilusWindow *window)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_widget_new (NAUTILUS_TYPE_LOCATION_DIALOG, NULL);
+
+ if (window) {
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ NAUTILUS_LOCATION_DIALOG (dialog)->details->window = window;
+ }
+
+ return dialog;
+}