aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-embed-persist.c
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 /embed/ephy-embed-persist.c
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 'embed/ephy-embed-persist.c')
-rw-r--r--embed/ephy-embed-persist.c673
1 files changed, 318 insertions, 355 deletions
diff --git a/embed/ephy-embed-persist.c b/embed/ephy-embed-persist.c
index 54581e52b..231bf3064 100644
--- a/embed/ephy-embed-persist.c
+++ b/embed/ephy-embed-persist.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
+ * Copyright (C) 2000-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
@@ -18,474 +19,436 @@
* $Id$
*/
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ephy-embed-persist.h"
-#include "ephy-debug.h"
-#include "mozilla-embed.h"
#include "mozilla-embed-persist.h"
+#include "ephy-debug.h"
enum
{
- COMPLETED,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_EMBED,
- PROP_SOURCE,
- PROP_DEST,
- PROP_MAX_SIZE,
- PROP_FLAGS,
- PROP_HANDLER
+ PROP_0,
+ PROP_DEST,
+ PROP_EMBED,
+ PROP_FILECHOOSER_TITLE,
+ PROP_FILECHOOSER_PARENT,
+ PROP_FLAGS,
+ PROP_HANDLER,
+ PROP_MAX_SIZE,
+ PROP_PERSISTKEY,
+ PROP_SOURCE,
};
#define EPHY_EMBED_PERSIST_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_PERSIST, EphyEmbedPersistPrivate))
struct EphyEmbedPersistPrivate
{
- char *dir;
- char *src;
- PersistHandlerInfo *handler;
+ char *dest;
+ char *source;
+ char *fc_title;
+ char *persist_key;
EphyEmbed *embed;
int max_size;
EmbedPersistFlags flags;
+ GtkWindow *fc_parent;
};
-static void
-ephy_embed_persist_class_init (EphyEmbedPersistClass *klass);
-static void
-ephy_embed_persist_init (EphyEmbedPersist *ges);
-static void
-ephy_embed_persist_finalize (GObject *object);
-static void
-ephy_embed_persist_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void
-ephy_embed_persist_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gresult
-impl_set_source (EphyEmbedPersist *persist,
- const char *url);
-static gresult
-impl_set_dest (EphyEmbedPersist *persist,
- const char *dir);
-static gresult
-impl_set_max_size (EphyEmbedPersist *persist,
- int kb_size);
-static gresult
-impl_set_embed (EphyEmbedPersist *persist,
- EphyEmbed *embed);
-static gresult
-impl_set_flags (EphyEmbedPersist *persist,
- EmbedPersistFlags flags);
-static gresult
-impl_set_handler (EphyEmbedPersist *persist,
- const char *command,
- gboolean need_terminal);
+static void ephy_embed_persist_class_init (EphyEmbedPersistClass *klass);
+static void ephy_embed_persist_init (EphyEmbedPersist *ges);
+
+enum
+{
+ COMPLETED,
+ LAST_SIGNAL
+};
-static GObjectClass *parent_class = NULL;
static guint ephy_embed_persist_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
GType
ephy_embed_persist_get_type (void)
{
static GType ephy_embed_persist_type = 0;
- if (ephy_embed_persist_type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (EphyEmbedPersistClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) ephy_embed_persist_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EphyEmbedPersist),
- 0, /* n_preallocs */
- (GInstanceInitFunc) ephy_embed_persist_init
- };
-
- ephy_embed_persist_type = g_type_register_static (G_TYPE_OBJECT,
- "EphyEmbedPersist",
- &our_info, 0);
- }
-
- return ephy_embed_persist_type;
+ if (ephy_embed_persist_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyEmbedPersistClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) ephy_embed_persist_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EphyEmbedPersist),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ephy_embed_persist_init
+ };
+
+ ephy_embed_persist_type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyEmbedPersist",
+ &our_info, 0);
+ }
+
+ return ephy_embed_persist_type;
}
-static void
-ephy_embed_persist_class_init (EphyEmbedPersistClass *klass)
+void
+ephy_embed_persist_set_dest (EphyEmbedPersist *persist,
+ const char *value)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- object_class->finalize = ephy_embed_persist_finalize;
- object_class->set_property = ephy_embed_persist_set_property;
- object_class->get_property = ephy_embed_persist_get_property;
-
- klass->set_source = impl_set_source;
- klass->set_dest = impl_set_dest;
- klass->set_embed = impl_set_embed;
- klass->set_max_size = impl_set_max_size;
- klass->set_flags = impl_set_flags;
- klass->set_handler = impl_set_handler;
-
- /* init signals */
- ephy_embed_persist_signals[COMPLETED] =
- g_signal_new ("completed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyEmbedPersistClass, completed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_EMBED,
- g_param_spec_object ("embed",
- "Embed",
- "The embed containing the document",
- G_TYPE_OBJECT,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SOURCE,
- g_param_spec_string ("source",
- "Source",
- "Url of the document to save",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_DEST,
- g_param_spec_string ("dest",
- "Destination",
- "Destination directory",
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_MAX_SIZE,
- g_param_spec_int ("max_size",
- "Maxsize",
- "Maximum size of the file",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_FLAGS,
- g_param_spec_int ("flags",
- "Flags",
- "Flags",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_HANDLER,
- g_param_spec_pointer ("handler",
- "Handler",
- "Handler",
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof(EphyEmbedPersistPrivate));
+ persist->priv->dest = g_strdup (value);
}
-static void
-ephy_embed_persist_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+void
+ephy_embed_persist_set_embed (EphyEmbedPersist *persist,
+ EphyEmbed *value)
{
- EphyEmbedPersist *persist;
- PersistHandlerInfo *h;
-
- persist = EPHY_EMBED_PERSIST (object);
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- switch (prop_id)
- {
- case PROP_EMBED:
- ephy_embed_persist_set_embed (persist,
- g_value_get_object (value));
- break;
- case PROP_SOURCE:
- ephy_embed_persist_set_source (persist,
- g_value_get_string (value));
- break;
- case PROP_DEST:
- ephy_embed_persist_set_dest (persist,
- g_value_get_string (value));
- break;
- case PROP_MAX_SIZE:
- ephy_embed_persist_set_max_size (persist,
- g_value_get_int (value));
- break;
- case PROP_FLAGS:
- ephy_embed_persist_set_flags
- (persist,
- (EmbedPersistFlags)g_value_get_int (value));
- break;
- case PROP_HANDLER:
- h = (PersistHandlerInfo *)g_value_get_pointer (value);
- ephy_embed_persist_set_handler
- (persist, h->command, h->need_terminal);
- break;
- }
+ persist->priv->embed = value;
}
-static void
-ephy_embed_persist_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+void
+ephy_embed_persist_set_fc_title (EphyEmbedPersist *persist,
+ const char *value)
{
- EphyEmbedPersist *persist;
-
- persist = EPHY_EMBED_PERSIST (object);
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- switch (prop_id)
- {
- case PROP_EMBED:
- g_value_set_object (value, persist->priv->embed);
- break;
- case PROP_SOURCE:
- g_value_set_string (value, persist->priv->src);
- break;
- case PROP_DEST:
- g_value_set_string (value, persist->priv->dir);
- break;
- case PROP_MAX_SIZE:
- g_value_set_int (value, persist->priv->max_size);
- break;
- case PROP_FLAGS:
- g_value_set_int (value, (int)persist->priv->flags);
- break;
- case PROP_HANDLER:
- g_value_set_pointer (value, persist->priv->handler);
- }
+ persist->priv->fc_title = g_strdup (value);
}
-static void
-ephy_embed_persist_init (EphyEmbedPersist *persist)
+void
+ephy_embed_persist_set_fc_parent (EphyEmbedPersist *persist,
+ GtkWindow *value)
{
- persist->priv = EPHY_EMBED_PERSIST_GET_PRIVATE (persist);
-
- persist->priv->src = NULL;
- persist->priv->dir = NULL;
- persist->priv->handler = NULL;
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- LOG ("Embed persist init")
+ persist->priv->fc_parent = value;
}
-static void
-ephy_embed_persist_finalize (GObject *object)
+void
+ephy_embed_persist_set_flags (EphyEmbedPersist *persist,
+ EmbedPersistFlags value)
{
- EphyEmbedPersist *persist = EPHY_EMBED_PERSIST (object);
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- g_free (persist->priv->dir);
- g_free (persist->priv->src);
-
- if (persist->priv->handler)
- {
- g_free (persist->priv->handler->command);
- g_free (persist->priv->handler);
- }
+ persist->priv->flags = value;
+}
- LOG ("Embed persist finalize")
+void
+ephy_embed_persist_set_max_size (EphyEmbedPersist *persist,
+ int value)
+{
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ persist->priv->max_size = value;
}
-
-EphyEmbedPersist *
-ephy_embed_persist_new (EphyEmbed *embed)
+void
+ephy_embed_persist_set_persist_key (EphyEmbedPersist *persist,
+ const char *value)
{
- EphyEmbedPersist *persist;
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
- persist = EPHY_EMBED_PERSIST (g_object_new (MOZILLA_TYPE_EMBED_PERSIST,
- "embed", embed,
- NULL));
-
- return persist;
+ persist->priv->persist_key = g_strdup (value);
}
-gresult
+void
ephy_embed_persist_set_source (EphyEmbedPersist *persist,
- const char *url)
+ const char *value)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_source (persist, url);
+ g_return_if_fail (EPHY_IS_EMBED_PERSIST (persist));
+
+ persist->priv->source = g_strdup (value);
}
-gresult
-ephy_embed_persist_get_source (EphyEmbedPersist *persist,
- const char **url)
+const char *
+ephy_embed_persist_get_dest (EphyEmbedPersist *persist)
{
- *url = persist->priv->src;
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
- return G_OK;
+ return persist->priv->dest;
}
-gresult
-ephy_embed_persist_get_dest (EphyEmbedPersist *persist,
- const char **dir)
+EphyEmbed *
+ephy_embed_persist_get_embed (EphyEmbedPersist *persist)
{
- *dir = persist->priv->dir;
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
- return G_OK;
+ return persist->priv->embed;
}
-gresult
-ephy_embed_persist_set_dest (EphyEmbedPersist *persist,
- const char *dir)
+const char *
+ephy_embed_persist_get_fc_title (EphyEmbedPersist *persist)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_dest (persist, dir);
-}
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
-gresult
-ephy_embed_persist_cancel (EphyEmbedPersist *persist)
-{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->cancel (persist);
+ return persist->priv->fc_title;
}
-gresult
-ephy_embed_persist_save (EphyEmbedPersist *persist)
+GtkWindow *
+ephy_embed_persist_get_fc_parent (EphyEmbedPersist *persist)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->save (persist);
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
+
+ return persist->priv->fc_parent;
}
-gresult
-ephy_embed_persist_set_max_size (EphyEmbedPersist *persist,
- int kb_size)
+EmbedPersistFlags
+ephy_embed_persist_get_flags (EphyEmbedPersist *persist)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_max_size (persist, kb_size);
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), 0);
+
+ return persist->priv->flags;
}
-gresult
-ephy_embed_persist_set_embed (EphyEmbedPersist *persist,
- EphyEmbed *embed)
+int
+ephy_embed_persist_get_max_size (EphyEmbedPersist *persist)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_embed (persist, embed);
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), 0);
+
+ return persist->priv->max_size;
}
-gresult
-ephy_embed_persist_get_embed (EphyEmbedPersist *persist,
- EphyEmbed **embed)
+const char *
+ephy_embed_persist_get_persist_key (EphyEmbedPersist *persist)
{
- *embed = persist->priv->embed;
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
- return G_OK;
+ return persist->priv->persist_key;
}
-gresult
-ephy_embed_persist_set_flags (EphyEmbedPersist *persist,
- EmbedPersistFlags flags)
+const char *
+ephy_embed_persist_get_source (EphyEmbedPersist *persist)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_flags (persist, flags);
+ g_return_val_if_fail (EPHY_IS_EMBED_PERSIST (persist), NULL);
+
+ return persist->priv->source;
}
-gresult
-ephy_embed_persist_get_flags (EphyEmbedPersist *persist,
- EmbedPersistFlags *flags)
+static void
+ephy_embed_persist_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- *flags = persist->priv->flags= persist->priv->flags;
+ EphyEmbedPersist *persist = EPHY_EMBED_PERSIST (object);
- return G_OK;
+ switch (prop_id)
+ {
+ case PROP_DEST:
+ ephy_embed_persist_set_dest (persist, g_value_get_string (value));
+ break;
+ case PROP_EMBED:
+ ephy_embed_persist_set_embed (persist, g_value_get_object (value));
+ break;
+ case PROP_FILECHOOSER_TITLE:
+ ephy_embed_persist_set_fc_title (persist, g_value_get_string (value));
+ break;
+ case PROP_FILECHOOSER_PARENT:
+ ephy_embed_persist_set_fc_parent (persist, g_value_get_object (value));
+ break;
+ case PROP_FLAGS:
+ ephy_embed_persist_set_flags (persist, g_value_get_int (value));
+ break;
+ case PROP_MAX_SIZE:
+ ephy_embed_persist_set_max_size (persist, g_value_get_int (value));
+ break;
+ case PROP_PERSISTKEY:
+ ephy_embed_persist_set_persist_key (persist, g_value_get_string (value));
+ break;
+ case PROP_SOURCE:
+ ephy_embed_persist_set_source (persist, g_value_get_string (value));
+ break;
+ }
}
-gresult
-ephy_embed_persist_set_handler (EphyEmbedPersist *persist,
- const char *command,
- gboolean need_terminal)
+static void
+ephy_embed_persist_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
- return klass->set_handler (persist, command, need_terminal);
+ EphyEmbedPersist *persist = EPHY_EMBED_PERSIST (object);
+
+ switch (prop_id)
+ {
+ case PROP_DEST:
+ g_value_set_string (value, ephy_embed_persist_get_dest (persist));
+ break;
+ case PROP_EMBED:
+ g_value_set_object (value, ephy_embed_persist_get_embed (persist));
+ break;
+ case PROP_FILECHOOSER_TITLE:
+ g_value_set_string (value, ephy_embed_persist_get_fc_title (persist));
+ break;
+ case PROP_FILECHOOSER_PARENT:
+ g_value_set_object (value, ephy_embed_persist_get_fc_parent (persist));
+ break;
+ case PROP_FLAGS:
+ g_value_set_int (value, ephy_embed_persist_get_flags (persist));
+ break;
+ case PROP_MAX_SIZE:
+ g_value_set_int (value, ephy_embed_persist_get_max_size (persist));
+ break;
+ case PROP_PERSISTKEY:
+ g_value_set_string (value, ephy_embed_persist_get_persist_key (persist));
+ break;
+ case PROP_SOURCE:
+ g_value_set_string (value, ephy_embed_persist_get_source (persist));
+ break;
+ }
}
-static gresult
-impl_set_handler (EphyEmbedPersist *persist,
- const char *command,
- gboolean need_terminal)
+static void
+ephy_embed_persist_init (EphyEmbedPersist *persist)
{
- persist->priv->handler = g_new0 (PersistHandlerInfo, 1);
- persist->priv->handler->command = g_strdup (command);
- persist->priv->handler->need_terminal = need_terminal;
+ persist->priv = EPHY_EMBED_PERSIST_GET_PRIVATE (persist);
- g_object_notify (G_OBJECT(persist), "handler");
+ LOG ("EphyEmbedPersist initialising %p", persist)
- return G_OK;
+ persist->priv->dest = NULL;
+ persist->priv->source = NULL;
+ persist->priv->fc_title = NULL;
+ persist->priv->fc_parent = NULL;
+ persist->priv->flags = 0;
+ persist->priv->max_size = 0;
+ persist->priv->persist_key = NULL;
}
-static gresult
-impl_set_flags (EphyEmbedPersist *persist,
- EmbedPersistFlags flags)
+static void
+ephy_embed_persist_finalize (GObject *object)
{
- persist->priv->flags = flags;
+ EphyEmbedPersist *persist = EPHY_EMBED_PERSIST (object);
+
+ g_free (persist->priv->dest);
+ g_free (persist->priv->source);
+ g_free (persist->priv->fc_title);
+ g_free (persist->priv->persist_key);
- g_object_notify (G_OBJECT(persist), "flags");
+ LOG ("EphyEmbedPersist finalised %p", object)
- return G_OK;
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static gresult
-impl_set_source (EphyEmbedPersist *persist,
- const char *url)
+static void
+ephy_embed_persist_class_init (EphyEmbedPersistClass *klass)
{
- persist->priv->src = g_strdup(url);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_object_notify (G_OBJECT(persist), "source");
+ parent_class = g_type_class_peek_parent (klass);
- return G_OK;
-}
+ object_class->finalize = ephy_embed_persist_finalize;
+ object_class->set_property = ephy_embed_persist_set_property;
+ object_class->get_property = ephy_embed_persist_get_property;
-static gresult
-impl_set_dest (EphyEmbedPersist *persist,
- const char *dir)
-{
- persist->priv->dir = g_strdup (dir);
+ /* init signals */
+ ephy_embed_persist_signals[COMPLETED] =
+ g_signal_new ("completed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyEmbedPersistClass, completed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- g_object_notify (G_OBJECT(persist), "dest");
+ g_object_class_install_property (object_class,
+ PROP_DEST,
+ g_param_spec_string ("dest",
+ "Destination",
+ "Destination file path",
+ NULL,
+ G_PARAM_READWRITE));
- return G_OK;
-}
+ g_object_class_install_property (object_class,
+ PROP_EMBED,
+ g_param_spec_object ("embed",
+ "Embed",
+ "The embed containing the document",
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
-static gresult
-impl_set_max_size (EphyEmbedPersist *persist,
- int kb_size)
-{
- persist->priv->max_size = kb_size;
+ g_object_class_install_property (object_class,
+ PROP_FILECHOOSER_TITLE,
+ g_param_spec_string ("filechooser-title",
+ "Filechooser title",
+ "Title to use if showing filechooser",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_FILECHOOSER_PARENT,
+ g_param_spec_object ("filechooser-parent",
+ "Filechooser parent",
+ "The parent window for the filechooser",
+ GTK_TYPE_WINDOW,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_FLAGS,
+ g_param_spec_int ("flags",
+ "Flags",
+ "Flags",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_MAX_SIZE,
+ g_param_spec_int ("max_size",
+ "Maxsize",
+ "Maximum size of the file",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
- g_object_notify (G_OBJECT(persist), "max_size");
+ g_object_class_install_property (object_class,
+ PROP_PERSISTKEY,
+ g_param_spec_string ("persist-key",
+ "persist key",
+ "Path persistence gconf key",
+ NULL,
+ G_PARAM_READWRITE));
- return G_OK;
+ g_object_class_install_property (object_class,
+ PROP_SOURCE,
+ g_param_spec_string ("source",
+ "Source",
+ "Url of the document to save",
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof(EphyEmbedPersistPrivate));
}
-static gresult
-impl_set_embed (EphyEmbedPersist *persist,
- EphyEmbed *embed)
+gresult
+ephy_embed_persist_cancel (EphyEmbedPersist *persist)
{
- persist->priv->embed = embed;
+ EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
+ return klass->cancel (persist);
+}
- g_object_notify (G_OBJECT(persist), "embed");
+gresult
+ephy_embed_persist_save (EphyEmbedPersist *persist)
+{
+ EphyEmbedPersistClass *klass = EPHY_EMBED_PERSIST_GET_CLASS (persist);
+ return klass->save (persist);
+}
- return G_OK;
+EphyEmbedPersist *
+ephy_embed_persist_new (EphyEmbed *embed)
+{
+ return EPHY_EMBED_PERSIST (g_object_new (MOZILLA_TYPE_EMBED_PERSIST,
+ "embed", embed,
+ NULL));
}