aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-26 18:45:56 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-26 18:45:56 +0800
commiteb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b (patch)
tree9c1ae176d61be345a8d3295aa9e43e48a43464da /lib
parenta34a545dbe35d250c5f5743634909ad2a45f423b (diff)
downloadgsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.gz
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.bz2
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.lz
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.xz
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.tar.zst
gsoc2013-epiphany-eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b.zip
Port to new gtk+ file chooser.
2003-10-26 Christian Persch <chpe@cvs.gnome.org> Port to new gtk+ file chooser. * data/epiphany.schemas.in: * lib/ephy-prefs.h: Add key for remembering upload path. * embed /Makefile.am: * embed/downloader-view.c: * embed/ephy-embed-persist.c: (ephy_embed_persist_get_type), (ephy_embed_persist_set_dest), (ephy_embed_persist_set_embed), (ephy_embed_persist_set_fc_title), (ephy_embed_persist_set_fc_parent), (ephy_embed_persist_set_flags), (ephy_embed_persist_set_max_size), (ephy_embed_persist_set_persist_key), (ephy_embed_persist_set_source), (ephy_embed_persist_get_dest), (ephy_embed_persist_get_embed), (ephy_embed_persist_get_fc_title), (ephy_embed_persist_get_fc_parent), (ephy_embed_persist_get_flags), (ephy_embed_persist_get_max_size), (ephy_embed_persist_get_persist_key), (ephy_embed_persist_get_source), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_finalize), (ephy_embed_persist_class_init), (ephy_embed_persist_cancel), (ephy_embed_persist_save), (ephy_embed_persist_new): * embed/ephy-embed-persist.h: * embed/ephy-embed-popup-control.c: (save_url), (save_property_url), (background_download_completed), (embed_popup_set_image_as_background_cmd), (embed_popup_copy_image_location_cmd): * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: * embed/ephy-favicon-cache.c: (ephy_favicon_cache_get_type), (ephy_favicon_cache_new), (icon_is_obsolete), (icons_added_cb), (remove_obsolete_icons), (ephy_favicon_cache_init), (favicon_download_completed_cb), (ephy_favicon_cache_download), (ephy_favicon_cache_get): * embed/mozilla/MozDownload.cpp: * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/mozilla-embed-persist.cpp: * embed/mozilla/mozilla-embed-single.cpp: * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: Simplify EphyEmbedPersist implementation. Augment it with properties for showing a file chooser to select persist destination. Port all callers to new interfaces. * embed/ephy-embed-single.c: (ephy_embed_single_remove_passwords): * embed/ephy-embed-single.h: * embed/ephy-embed-utils.c: * embed/ephy-embed-utils.h: Obsolete and removed. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: Misc cleanups. * embed/mozilla/FilePicker.cpp: * embed/mozilla/FilePicker.h: Port to new file chooser class. * embed/mozilla/Makefile.am: * lib/Makefile.am: * lib/ephy-file-chooser.c: (ephy_file_chooser_get_type), (current_folder_changed_cb), (ephy_file_chooser_init), (ephy_file_chooser_finalize), (ephy_file_chooser_set_persist_key), (ephy_file_chooser_set_property), (ephy_file_chooser_get_property), (ephy_file_chooser_class_init), (ephy_file_chooser_new): * lib/ephy-file-chooser.h: * src/bookmarks/ephy-bookmarks-editor.c: (import_from_file_response_cb), (import_dialog_response_cb): New file chooser wrapper class; ported file chooser callers to it.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/ephy-file-chooser.c238
-rw-r--r--lib/ephy-file-chooser.h66
-rw-r--r--lib/ephy-prefs.h1
4 files changed, 307 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7caefb55d..955be57ae 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -19,6 +19,7 @@ NOINST_H_FILES = \
ephy-bonobo-extensions.h \
ephy-debug.h \
ephy-dnd.h \
+ ephy-file-chooser.h \
ephy-file-helpers.h \
ephy-glade.h \
ephy-gui.h \
@@ -50,6 +51,7 @@ libephy_la_SOURCES = \
ephy-dialog.h \
ephy-dnd.c \
ephy-dnd.h \
+ ephy-file-chooser.c \
ephy-file-helpers.c \
ephy-file-helpers.h \
ephy-glade.c \
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c
new file mode 100644
index 000000000..1f2f853d2
--- /dev/null
+++ b/lib/ephy-file-chooser.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003 Christian Persch
+ *
+ * This program 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, or (at your option)
+ * any later version.
+ *
+ * This program 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ephy-file-chooser.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-state.h"
+#include "ephy-debug.h"
+
+#include <gtk/gtkstock.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+#define EPHY_FILE_CHOOSER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_FILE_CHOOSER, EphyFileChooserPrivate))
+
+struct EphyFileChooserPrivate
+{
+ char *persist_key;
+};
+
+static void ephy_file_chooser_class_init (EphyFileChooserClass *klass);
+static void ephy_file_chooser_init (EphyFileChooser *dialog);
+
+enum
+{
+ PROP_0,
+ PROP_PERSIST_KEY
+};
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_file_chooser_get_type (void)
+{
+ static GType ephy_file_chooser_type = 0;
+
+ if (ephy_file_chooser_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyFileChooserClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_file_chooser_class_init,
+ NULL,
+ NULL,
+ sizeof (EphyFileChooser),
+ 0,
+ (GInstanceInitFunc) ephy_file_chooser_init
+ };
+
+ ephy_file_chooser_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG,
+ "EphyFileChooser",
+ &our_info, 0);
+ }
+
+ return ephy_file_chooser_type;
+}
+
+static void
+current_folder_changed_cb (GtkFileChooser *chooser, EphyFileChooser *dialog)
+{
+ if (dialog->priv->persist_key)
+ {
+ char *dir;
+
+ dir = gtk_file_chooser_get_current_folder (chooser);
+ if (dir != NULL)
+ {
+ eel_gconf_set_string (dialog->priv->persist_key, dir);
+ g_free (dir);
+ }
+ }
+}
+
+static void
+ephy_file_chooser_init (EphyFileChooser *dialog)
+{
+ dialog->priv = EPHY_FILE_CHOOSER_GET_PRIVATE (dialog);
+
+ dialog->priv->persist_key = NULL;
+
+ g_signal_connect (dialog, "current-folder-changed",
+ G_CALLBACK (current_folder_changed_cb), dialog);
+
+ ephy_state_add_window (GTK_WIDGET (dialog), "file_chooser",
+ 400, 300,
+ EPHY_STATE_WINDOW_SAVE_SIZE |
+ EPHY_STATE_WINDOW_SAVE_POSITION);
+}
+
+static void
+ephy_file_chooser_finalize (GObject *object)
+{
+ EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
+
+ g_free (dialog->priv->persist_key);
+
+ LOG ("EphyFileChooser finalised")
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+ephy_file_chooser_set_persist_key (EphyFileChooser *dialog, const char *key)
+{
+ dialog->priv->persist_key = g_strdup (key);
+
+ if (key != NULL)
+ {
+ char *uri;
+
+ uri = eel_gconf_get_string (key);
+
+ if (uri != NULL)
+ {
+ char *expanded;
+
+ expanded = gnome_vfs_expand_initial_tilde (uri);
+
+ gtk_file_chooser_set_current_folder
+ (GTK_FILE_CHOOSER (dialog), expanded);
+
+ g_free (expanded);
+ g_free (uri);
+ }
+ }
+}
+
+static void
+ephy_file_chooser_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
+
+ switch (prop_id)
+ {
+ case PROP_PERSIST_KEY:
+ ephy_file_chooser_set_persist_key (dialog, g_value_get_string (value));
+ break;
+ }
+}
+
+static void
+ephy_file_chooser_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyFileChooser *dialog = EPHY_FILE_CHOOSER (object);
+
+ switch (prop_id)
+ {
+ case PROP_PERSIST_KEY:
+ g_value_set_string (value, dialog->priv->persist_key);
+ break;
+ }
+}
+
+static void
+ephy_file_chooser_class_init (EphyFileChooserClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_file_chooser_finalize;
+ object_class->get_property = ephy_file_chooser_get_property;
+ object_class->set_property = ephy_file_chooser_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_PERSIST_KEY,
+ g_param_spec_string ("persist-key",
+ "Persist Key",
+ "The gconf key to which to persist the selected directory",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (object_class, sizeof (EphyFileChooserPrivate));
+}
+
+EphyFileChooser *
+ephy_file_chooser_new (const char *title,
+ GtkWidget *parent,
+ GtkFileChooserAction action,
+ const char *persist_key)
+{
+ EphyFileChooser *dialog;
+
+ dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
+ "local-only", TRUE,
+ "title", title,
+ "action", action,
+ "persist-key", persist_key,
+ NULL));
+
+ if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
+ {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, EPHY_RESPONSE_OPEN,
+ NULL);
+ }
+ else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, EPHY_RESPONSE_SAVE,
+ NULL);
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+
+ return dialog;
+}
diff --git a/lib/ephy-file-chooser.h b/lib/ephy-file-chooser.h
new file mode 100644
index 000000000..f4061e9fc
--- /dev/null
+++ b/lib/ephy-file-chooser.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2003 Christian Persch
+ *
+ * This program 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, or (at your option)
+ * any later version.
+ *
+ * This program 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_FILE_CHOOSER_H
+#define EPHY_FILE_CHOOSER_H
+
+#include <glib-object.h>
+
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkfilechooserdialog.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_FILE_CHOOSER (ephy_file_chooser_get_type ())
+#define EPHY_FILE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_FILE_CHOOSER, EphyFileChooser))
+#define EPHY_FILE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EPHY_TYPE_FILE_CHOOSER, EphyFileChooserClass))
+#define EPHY_IS_FILE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_FILE_CHOOSER))
+#define EPHY_IS_FILE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_FILE_CHOOSER))
+#define EPHY_FILE_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_FILE_CHOOSER, EphyFileChooserClass))
+
+typedef struct EphyFileChooserPrivate EphyFileChooserPrivate;
+
+enum
+{
+ EPHY_RESPONSE_OPEN = 2,
+ EPHY_RESPONSE_SAVE = 3
+};
+
+typedef struct
+{
+ GtkFileChooserDialog parent;
+ EphyFileChooserPrivate *priv;
+} EphyFileChooser;
+
+typedef struct
+{
+ GtkFileChooserDialogClass parent_class;
+} EphyFileChooserClass;
+
+GType ephy_file_chooser_get_type (void);
+
+EphyFileChooser *ephy_file_chooser_new (const char *title,
+ GtkWidget *parent,
+ GtkFileChooserAction action,
+ const char *persist_key);
+
+G_END_DECLS
+
+#endif
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 0ecb6360f..844d6f7bf 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -35,6 +35,7 @@ G_BEGIN_DECLS
#define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage"
#define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open"
#define CONF_STATE_DOWNLOADING_DIR "/apps/epiphany/directories/download"
+#define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload"
/* System prefs */
#define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command"