aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-06-16 18:56:04 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-06-16 18:56:04 +0800
commit265c85e8ab0a90f2a7d389f5cd9f750eeadf3e22 (patch)
tree27d5f110e573bdbe64ae0a0d500ddd95fc65c4b0 /embed
parent3241ea896ff4f8939c038ab65f03948d026ed520 (diff)
downloadgsoc2013-epiphany-265c85e8ab0a90f2a7d389f5cd9f750eeadf3e22.tar.gz
gsoc2013-epiphany-265c85e8ab0a90f2a7d389f5cd9f750eeadf3e22.tar.zst
gsoc2013-epiphany-265c85e8ab0a90f2a7d389f5cd9f750eeadf3e22.zip
Merge with popup control, we dont need it for bonobo window anymore.
2003-06-16 Marco Pesenti Gritti <marco@it.gnome.org> * embed/Makefile.am: * embed/ephy-embed-popup-control.c: (ephy_embed_popup_control_get_type), (ephy_embed_popup_control_set_property), (ephy_embed_popup_control_get_property), (ephy_embed_popup_control_class_init), (ephy_embed_popup_control_init), (ephy_embed_popup_control_finalize), (get_popup_path), (ephy_embed_popup_control_show), (setup_element_menu), (setup_document_menu), (ephy_embed_popup_control_set_event), (ephy_embed_popup_control_connect_verbs), (ephy_embed_popup_control_get_event), (embed_popup_copy_location_cmd), (embed_popup_copy_email_cmd), (embed_popup_copy_link_location_cmd), (save_property_url), (embed_popup_open_link_cmd), (embed_popup_download_link_cmd), (embed_popup_save_image_as_cmd), (background_download_completed), (embed_popup_set_image_as_background_cmd), (embed_popup_copy_image_location_cmd), (save_url), (embed_popup_save_page_as_cmd), (embed_popup_save_background_as_cmd), (embed_popup_open_frame_cmd), (embed_popup_reload_frame_cmd), (embed_popup_open_image_cmd), (embed_popup_copy_to_clipboard): * embed/ephy-embed-popup-control.h: Merge with popup control, we dont need it for bonobo window anymore. * embed/mozilla/mozilla-embed-single.cpp: Do not override the UA but set vendor prefs so that mozilla can build it correctly. * lib/ephy-dialog.c: (get_radio_button_active_index), (set_config_from_radiobuttongroup), (set_radiobuttongroup_from_config), (prefs_set_group_sensitivity), (impl_get_value): * lib/ephy-dnd.c: (ephy_dnd_node_list_extract_nodes): * lib/ephy-gui.c: * lib/ephy-gui.h: * lib/ephy-string.c: (ephy_string_shorten), (ephy_string_to_int), (ephy_string_strip_chr), (ephy_string_elide_underscores): * lib/ephy-string.h: * src/ephy-nautilus-view.c: (ephy_nautilus_view_instance_init), (gnv_embed_context_menu_cb), (gnv_embed_location_cb), (gnv_view_from_popup), (gnv_popup_cmd_new_window), (gnv_popup_cmd_image_in_new_window), (gnv_popup_cmd_frame_in_new_window), (gnv_cmd_file_print), (gnv_embed_zoom_change_cb):
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am2
-rw-r--r--embed/ephy-embed-popup-control.c645
-rw-r--r--embed/ephy-embed-popup-control.h20
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp46
4 files changed, 620 insertions, 93 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 6355dbac2..f26c57dc0 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -27,8 +27,6 @@ libephyembed_la_SOURCES = \
ephy-embed-event.h \
ephy-embed-persist.c \
ephy-embed-persist.h \
- ephy-embed-popup.c \
- ephy-embed-popup.h \
ephy-embed-popup-control.c \
ephy-embed-popup-control.h \
ephy-embed-prefs.h \
diff --git a/embed/ephy-embed-popup-control.c b/embed/ephy-embed-popup-control.c
index 866c6789f..2f8b20b8a 100644
--- a/embed/ephy-embed-popup-control.c
+++ b/embed/ephy-embed-popup-control.c
@@ -17,23 +17,131 @@
*/
#include "ephy-embed-popup-control.h"
-#include "ephy-gobject-misc.h"
#include "ephy-bonobo-extensions.h"
+#include "ephy-embed-utils.h"
+#include "ephy-prefs.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-file-helpers.h"
#include <gtk/gtkmain.h>
+#include <string.h>
+#include <bonobo/bonobo-ui-component.h>
+#include <gtk/gtkclipboard.h>
+#include <libgnome/gnome-exec.h>
-enum
+typedef enum
{
- PROP_0,
- PROP_BONOBO_CONTROL
-};
+ EMBED_POPUP_INPUT,
+ EMBED_POPUP_DOCUMENT,
+ EMBED_POPUP_ELEMENT
+} EmbedPopupType;
struct EphyEmbedPopupControlPrivate
{
+ EphyEmbedEvent *event;
+ EphyEmbed *embed;
+ EmbedEventContext context;
+ BonoboUIComponent *ui_component;
+ char *selection;
+ EmbedPopupType popup_type;
BonoboControl *control;
};
static void
+embed_popup_copy_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_copy_email_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_copy_link_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_open_link_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_download_link_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_save_image_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_set_image_as_background_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_copy_image_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_save_page_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_save_background_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_open_frame_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_reload_frame_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+
+static void
+embed_popup_open_image_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname);
+static void
+embed_popup_copy_to_clipboard (EphyEmbedPopupControl *popup, const char *text);
+
+#define DOCUMENT_POPUP_PATH "/popups/EphyEmbedDocumentPopup"
+#define ELEMENT_POPUP_PATH "/popups/EphyEmbedElementPopup"
+#define INPUT_POPUP_PATH "/popups/EphyEmbedInputPopup"
+
+#define EPHY_POPUP_NAVIGATION_ITEMS_PLACEHOLDER "/popups/EphyEmbedDocumentPopup/NavigationItems"
+#define EPHY_POPUP_LINK_ITEMS_PLACEHOLDER "/popups/EphyEmbedElementPopup/LinkItems"
+#define EPHY_POPUP_EMAIL_LINK_ITEMS_PLACEHOLDER "/popups/EphyEmbedElementPopup/EmailLinkItems"
+#define EPHY_POPUP_IMAGE_ITEMS_PLACEHOLDER "/popups/EphyEmbedElementPopup/ImageItems"
+#define EPHY_POPUP_FRAME_ITEMS_PLACEHOLDER "/popups/EphyEmbedDocumentPopup/FrameItems"
+#define EPHY_POPUP_BETWEEN_ELEMENTS1_PLACEHOLDER "/popups/EphyEmbedElementPopup/BetweenElements1"
+#define EPHY_POPUP_SAVE_BG_PATH "/commands/DPSaveBackgroundAs"
+#define EPHY_POPUP_OPEN_IMAGE_PATH "/commands/EPOpenImage"
+
+BonoboUIVerb embed_popup_verbs [] = {
+ BONOBO_UI_VERB ("EPCopyLinkLocation", (BonoboUIVerbFn)embed_popup_copy_link_location_cmd),
+ BONOBO_UI_VERB ("EPDownloadLink", (BonoboUIVerbFn)embed_popup_download_link_cmd),
+ BONOBO_UI_VERB ("EPOpenLink", (BonoboUIVerbFn)embed_popup_open_link_cmd),
+ BONOBO_UI_VERB ("EPOpenImage", (BonoboUIVerbFn)embed_popup_open_image_cmd),
+ BONOBO_UI_VERB ("EPSaveImageAs", (BonoboUIVerbFn)embed_popup_save_image_as_cmd),
+ BONOBO_UI_VERB ("EPSetImageAsBackground", (BonoboUIVerbFn)embed_popup_set_image_as_background_cmd),
+ BONOBO_UI_VERB ("EPCopyImageLocation", (BonoboUIVerbFn)embed_popup_copy_image_location_cmd),
+
+ BONOBO_UI_VERB ("DPCopyLocation", (BonoboUIVerbFn)embed_popup_copy_location_cmd),
+ BONOBO_UI_VERB ("EPCopyEmail", (BonoboUIVerbFn)embed_popup_copy_email_cmd),
+ BONOBO_UI_VERB ("DPSavePageAs", (BonoboUIVerbFn)embed_popup_save_page_as_cmd),
+ BONOBO_UI_VERB ("DPSaveBackgroundAs", (BonoboUIVerbFn)embed_popup_save_background_as_cmd),
+ BONOBO_UI_VERB ("DPOpenFrame", (BonoboUIVerbFn)embed_popup_open_frame_cmd),
+ BONOBO_UI_VERB ("DPReloadFrame", (BonoboUIVerbFn)embed_popup_reload_frame_cmd),
+
+ BONOBO_UI_VERB_END
+};
+
+enum
+{
+ PROP_0,
+ PROP_BONOBO_CONTROL
+};
+
+static void
ephy_embed_popup_control_class_init (EphyEmbedPopupControlClass *klass);
static void
ephy_embed_popup_control_init (EphyEmbedPopupControl *gep);
@@ -52,22 +160,76 @@ ephy_embed_popup_control_get_property (GObject *object,
static void
ephy_embed_popup_control_set_control (EphyEmbedPopupControl *p,
BonoboControl *control);
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_embed_popup_control_get_type (void)
+{
+ static GType ephy_embed_popup_control_type = 0;
+
+ if (ephy_embed_popup_control_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyEmbedPopupControlClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) ephy_embed_popup_control_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EphyEmbedPopupControl),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ephy_embed_popup_control_init
+ };
+
+
+ ephy_embed_popup_control_type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyEmbedPopupControl",
+ &our_info, 0);
+ }
+
+ return ephy_embed_popup_control_type;
+}
+
static void
-ephy_embed_popup_control_show_impl (EphyEmbedPopup *p,
- EphyEmbed *embed);
+ephy_embed_popup_control_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEmbedPopupControl *p = EPHY_EMBED_POPUP_CONTROL (object);
-static EphyEmbedPopupClass *parent_class = NULL;
+ switch (prop_id)
+ {
+ case PROP_BONOBO_CONTROL:
+ ephy_embed_popup_control_set_control (p, g_value_get_object (value));
+ break;
+ }
+}
-MAKE_GET_TYPE (ephy_embed_popup_control, "EphyEmbedPopupControl", EphyEmbedPopupControl,
- ephy_embed_popup_control_class_init, ephy_embed_popup_control_init,
- EPHY_EMBED_POPUP_TYPE);
+static void
+ephy_embed_popup_control_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEmbedPopupControl *p = EPHY_EMBED_POPUP_CONTROL (object);
+
+ switch (prop_id)
+ {
+ case PROP_BONOBO_CONTROL:
+ g_value_set_object (value, p->priv->control);
+ break;
+ }
+}
static void
ephy_embed_popup_control_class_init (EphyEmbedPopupControlClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = EPHY_EMBED_POPUP_CLASS (g_type_class_peek_parent (klass));
+ parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_embed_popup_control_finalize;
object_class->set_property = ephy_embed_popup_control_set_property;
@@ -80,8 +242,6 @@ ephy_embed_popup_control_class_init (EphyEmbedPopupControlClass *klass)
"Bonobo control",
BONOBO_TYPE_CONTROL,
G_PARAM_READWRITE));
-
- EPHY_EMBED_POPUP_CLASS (klass)->show = ephy_embed_popup_control_show_impl;
}
static void
@@ -89,6 +249,9 @@ ephy_embed_popup_control_init (EphyEmbedPopupControl *gep)
{
gep->priv = g_new0 (EphyEmbedPopupControlPrivate, 1);
gep->priv->control = NULL;
+ gep->priv->embed = NULL;
+ gep->priv->event = NULL;
+ gep->priv->ui_component = NULL;
}
static void
@@ -103,41 +266,16 @@ ephy_embed_popup_control_finalize (GObject *object)
g_return_if_fail (gep->priv != NULL);
- g_free (gep->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
+ if (gep->priv->event)
+ {
+ g_object_unref (G_OBJECT (gep->priv->event));
+ }
-static void
-ephy_embed_popup_control_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyEmbedPopupControl *p = EPHY_EMBED_POPUP_CONTROL (object);
-
- switch (prop_id)
- {
- case PROP_BONOBO_CONTROL:
- ephy_embed_popup_control_set_control (p, g_value_get_object (value));
- break;
- }
-}
+ g_free (gep->priv->selection);
-static void
-ephy_embed_popup_control_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyEmbedPopupControl *p = EPHY_EMBED_POPUP_CONTROL (object);
+ g_free (gep->priv);
- switch (prop_id)
- {
- case PROP_BONOBO_CONTROL:
- g_value_set_object (value, p->priv->control);
- break;
- }
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -161,17 +299,38 @@ ephy_embed_popup_control_new (BonoboControl *control)
return p;
}
-static void
-ephy_embed_popup_control_show_impl (EphyEmbedPopup *pp,
- EphyEmbed *embed)
+static const char *
+get_popup_path (EphyEmbedPopupControl *p)
+{
+ const char *result = NULL;
+
+ switch (p->priv->popup_type)
+ {
+ case EMBED_POPUP_INPUT:
+ result = INPUT_POPUP_PATH;
+ break;
+ case EMBED_POPUP_ELEMENT:
+ result = ELEMENT_POPUP_PATH;
+ break;
+ case EMBED_POPUP_DOCUMENT:
+ result = DOCUMENT_POPUP_PATH;
+ break;
+ }
+
+ return result;
+}
+
+void
+ephy_embed_popup_control_show (EphyEmbedPopupControl *pp,
+ EphyEmbed *embed)
{
EphyEmbedPopupControl *p = EPHY_EMBED_POPUP_CONTROL (pp);
BonoboUIComponent *uic = bonobo_control_get_popup_ui_component (p->priv->control);
const char *path;
char *path_dst;
- ephy_embed_popup_set_embed (pp, embed);
- path = ephy_embed_popup_get_popup_path (pp);
+ p->priv->embed = embed;
+ path = get_popup_path (pp);
path_dst = g_strdup_printf ("/popups/button%d", 2);
/* this is a hack because bonobo apis for showing popups are broken */
@@ -179,7 +338,389 @@ ephy_embed_popup_control_show_impl (EphyEmbedPopup *pp,
bonobo_control_do_popup (p->priv->control, 2,
gtk_get_current_event_time ());
+}
+
+static void
+setup_element_menu (EphyEmbedPopupControl *p)
+{
+ gboolean is_link, is_image, is_email_link;
+
+ is_image = p->priv->context & EMBED_CONTEXT_IMAGE;
+ is_email_link = p->priv->context & EMBED_CONTEXT_EMAIL_LINK;
+ is_link = (p->priv->context & EMBED_CONTEXT_LINK) && !is_email_link;
+
+ ephy_bonobo_set_hidden (p->priv->ui_component,
+ EPHY_POPUP_LINK_ITEMS_PLACEHOLDER,
+ !is_link);
+ ephy_bonobo_set_hidden (p->priv->ui_component,
+ EPHY_POPUP_IMAGE_ITEMS_PLACEHOLDER,
+ !is_image);
+ ephy_bonobo_set_hidden (p->priv->ui_component,
+ EPHY_POPUP_EMAIL_LINK_ITEMS_PLACEHOLDER,
+ !is_email_link);
+ ephy_bonobo_set_hidden (p->priv->ui_component,
+ EPHY_POPUP_BETWEEN_ELEMENTS1_PLACEHOLDER,
+ !is_image || (!is_link && !is_email_link));
+}
+
+static void
+setup_document_menu (EphyEmbedPopupControl *p)
+{
+ gboolean is_framed;
+ const GValue *value;
+ gboolean has_background;
+
+ ephy_embed_event_get_property (p->priv->event,
+ "framed_page", &value);
+ is_framed = g_value_get_int (value);
+ ephy_bonobo_set_hidden (BONOBO_UI_COMPONENT(p->priv->ui_component),
+ EPHY_POPUP_FRAME_ITEMS_PLACEHOLDER, !is_framed);
+
+ has_background = ephy_embed_event_has_property (p->priv->event,
+ "background_image");
+ ephy_bonobo_set_hidden (BONOBO_UI_COMPONENT(p->priv->ui_component),
+ EPHY_POPUP_SAVE_BG_PATH, !has_background);
+}
- g_free (path_dst);
+void
+ephy_embed_popup_control_set_event (EphyEmbedPopupControl *p,
+ EphyEmbedEvent *event)
+{
+ EmbedEventContext context;
+
+ if (p->priv->event)
+ {
+ g_object_unref (G_OBJECT (p->priv->event));
+ }
+
+ ephy_embed_event_get_context (event, &context);
+
+ p->priv->context = context;
+
+ p->priv->event = event;
+ g_object_ref (G_OBJECT(event));
+
+ if ((p->priv->context & EMBED_CONTEXT_LINK) ||
+ (p->priv->context & EMBED_CONTEXT_EMAIL_LINK) ||
+ (p->priv->context & EMBED_CONTEXT_IMAGE))
+ {
+ setup_element_menu (p);
+ p->priv->popup_type = EMBED_POPUP_ELEMENT;
+ }
+ else if (p->priv->context & EMBED_CONTEXT_INPUT)
+ {
+ p->priv->popup_type = EMBED_POPUP_INPUT;
+ }
+ else
+ {
+ setup_document_menu (p);
+ p->priv->popup_type = EMBED_POPUP_DOCUMENT;
+ }
}
+void
+ephy_embed_popup_control_connect_verbs (EphyEmbedPopupControl *p,
+ BonoboUIComponent *ui_component)
+{
+
+ p->priv->ui_component = BONOBO_UI_COMPONENT (ui_component);
+
+ bonobo_ui_component_add_verb_list_with_data (BONOBO_UI_COMPONENT(ui_component),
+ embed_popup_verbs,
+ p);
+}
+
+EphyEmbedEvent *
+ephy_embed_popup_control_get_event (EphyEmbedPopupControl *p)
+{
+ g_return_val_if_fail (IS_EPHY_EMBED_POPUP_CONTROL (p), NULL);
+
+ return p->priv->event;
+}
+
+static void
+embed_popup_copy_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ char *location;
+ ephy_embed_get_location (popup->priv->embed, FALSE, &location);
+ embed_popup_copy_to_clipboard (popup, location);
+ g_free (location);
+}
+
+static void
+embed_popup_copy_email_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "email", &value);
+ location = g_value_get_string (value);
+ embed_popup_copy_to_clipboard (popup, location);
+}
+
+static void
+embed_popup_copy_link_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "link", &value);
+ location = g_value_get_string (value);
+ embed_popup_copy_to_clipboard (popup, location);
+}
+
+static void
+save_property_url (EphyEmbedPopupControl *popup,
+ gboolean ask_dest,
+ gboolean show_progress,
+ const char *property)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+ GtkWidget *widget;
+ GtkWidget *window;
+ EphyEmbedPersist *persist;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, property, &value);
+ location = g_value_get_string (value);
+
+ widget = GTK_WIDGET (popup->priv->embed);
+ window = gtk_widget_get_toplevel (widget);
+
+ persist = ephy_embed_persist_new (popup->priv->embed);
+
+ ephy_embed_persist_set_source (persist, location);
+
+ if (show_progress)
+ {
+ ephy_embed_persist_set_flags (persist,
+ EMBED_PERSIST_SHOW_PROGRESS);
+ }
+
+ ephy_embed_utils_save (window,
+ CONF_STATE_DOWNLOADING_DIR,
+ ask_dest,
+ FALSE,
+ persist);
+}
+
+/* commands */
+
+static void
+embed_popup_open_link_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "link", &value);
+ location = g_value_get_string (value);
+
+ ephy_embed_load_url (popup->priv->embed, location);
+}
+
+static void
+embed_popup_download_link_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ save_property_url (popup,
+ eel_gconf_get_boolean
+ (CONF_ASK_DOWNLOAD_DEST),
+ TRUE, "link");
+}
+
+static void
+embed_popup_save_image_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ save_property_url (popup, TRUE, FALSE, "image");
+}
+
+#define CONF_DESKTOP_BG_PICTURE "/desktop/gnome/background/picture_filename"
+#define CONF_DESKTOP_BG_TYPE "/desktop/gnome/background/picture_options"
+
+static void
+background_download_completed (EphyEmbedPersist *persist,
+ gpointer data)
+{
+ const char *bg;
+ char *type;
+
+ ephy_embed_persist_get_dest (persist, &bg);
+ eel_gconf_set_string (CONF_DESKTOP_BG_PICTURE, bg);
+
+ type = eel_gconf_get_string (CONF_DESKTOP_BG_TYPE);
+ if (type || strcmp (type, "none") == 0)
+ {
+ eel_gconf_set_string (CONF_DESKTOP_BG_TYPE,
+ "wallpaper");
+ }
+
+ g_free (type);
+
+ g_object_unref (persist);
+}
+
+static void
+embed_popup_set_image_as_background_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ char *dest, *base;
+ const GValue *value;
+ EphyEmbedPersist *persist;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "image", &value);
+ location = g_value_get_string (value);
+
+ persist = ephy_embed_persist_new (popup->priv->embed);
+
+ base = g_path_get_basename (location);
+ dest = g_build_filename (ephy_dot_dir (),
+ base, NULL);
+
+ ephy_embed_persist_set_source (persist, location);
+ ephy_embed_persist_set_dest (persist, dest);
+
+ ephy_embed_persist_save (persist);
+
+ g_signal_connect (persist, "completed",
+ G_CALLBACK (background_download_completed),
+ NULL);
+
+ g_free (dest);
+ g_free (base);
+}
+
+static void
+embed_popup_copy_image_location_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "image", &value);
+ location = g_value_get_string (value);
+ embed_popup_copy_to_clipboard (popup, location);
+}
+
+static void
+save_url (EphyEmbedPopupControl *popup,
+ gboolean ask_dest,
+ gboolean show_progress,
+ const char *url)
+{
+ GtkWidget *widget;
+ GtkWidget *window;
+ EphyEmbedPersist *persist;
+
+ widget = GTK_WIDGET (popup->priv->embed);
+ window = gtk_widget_get_toplevel (widget);
+
+ persist = ephy_embed_persist_new (popup->priv->embed);
+ ephy_embed_persist_set_source (persist, url);
+
+ if (show_progress)
+ {
+ ephy_embed_persist_set_flags (persist,
+ EMBED_PERSIST_SHOW_PROGRESS);
+ }
+
+ ephy_embed_utils_save (window,
+ CONF_STATE_DOWNLOADING_DIR,
+ ask_dest,
+ FALSE,
+ persist);
+}
+
+static void
+embed_popup_save_page_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ char *location;
+
+ ephy_embed_get_location (popup->priv->embed,
+ FALSE, &location);
+ save_url (popup, TRUE, FALSE, location);
+ g_free (location);
+}
+
+static void
+embed_popup_save_background_as_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ save_property_url (popup, TRUE, FALSE, "background_image");
+}
+
+static void
+embed_popup_open_frame_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ char *location;
+
+ ephy_embed_get_location (popup->priv->embed,
+ FALSE, &location);
+
+ ephy_embed_load_url (popup->priv->embed, location);
+
+ g_free (location);
+}
+
+static void
+embed_popup_reload_frame_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ /* FIXME implement */
+}
+
+static void
+embed_popup_open_image_cmd (BonoboUIComponent *uic,
+ EphyEmbedPopupControl *popup,
+ const char* verbname)
+{
+ EphyEmbedEvent *info;
+ const char *location;
+ const GValue *value;
+
+ info = ephy_embed_popup_control_get_event (popup);
+ ephy_embed_event_get_property (info, "image", &value);
+ location = g_value_get_string (value);
+
+ ephy_embed_load_url (popup->priv->embed, location);
+}
+
+static void
+embed_popup_copy_to_clipboard (EphyEmbedPopupControl *popup, const char *text)
+{
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE),
+ text, -1);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ text, -1);
+}
diff --git a/embed/ephy-embed-popup-control.h b/embed/ephy-embed-popup-control.h
index 4f45efe5f..075e62a9b 100644
--- a/embed/ephy-embed-popup-control.h
+++ b/embed/ephy-embed-popup-control.h
@@ -19,9 +19,11 @@
#ifndef EPHY_EMBED_POPUP_CONTROL_H
#define EPHY_EMBED_POPUP_CONTROL_H
-#include "ephy-embed-popup.h"
#include <bonobo/bonobo-control.h>
+#include "ephy-embed.h"
+#include "ephy-embed-event.h"
+
G_BEGIN_DECLS
typedef struct EphyEmbedPopupControlClass EphyEmbedPopupControlClass;
@@ -44,18 +46,30 @@ typedef struct EphyEmbedPopupControlPrivate EphyEmbedPopupControlPrivate;
struct EphyEmbedPopupControl
{
- EphyEmbedPopup parent;
+ GObject parent;
EphyEmbedPopupControlPrivate *priv;
};
struct EphyEmbedPopupControlClass
{
- EphyEmbedPopupClass parent_class;
+ GObjectClass parent_class;
};
GType ephy_embed_popup_control_get_type (void);
+
EphyEmbedPopupControl *ephy_embed_popup_control_new (BonoboControl *control);
+EphyEmbedEvent *ephy_embed_popup_control_get_event (EphyEmbedPopupControl *p);
+
+void ephy_embed_popup_control_set_event (EphyEmbedPopupControl *p,
+ EphyEmbedEvent *event);
+
+void ephy_embed_popup_control_connect_verbs (EphyEmbedPopupControl *p,
+ BonoboUIComponent *ui_component);
+
+void ephy_embed_popup_control_show (EphyEmbedPopupControl *pp,
+ EphyEmbed *embed);
+
G_END_DECLS
#endif
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index aea368fe0..e5c69ab33 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -37,7 +37,6 @@
#include <time.h>
#include <libgnome/gnome-i18n.h>
#include <string.h>
-#include <sys/utsname.h>
#include "nsBuildID.h"
#include <nsICacheService.h>
#include <nsCOMPtr.h>
@@ -318,34 +317,6 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass)
shell_class->show_file_picker = impl_show_file_picker;
}
-static char *
-build_user_agent ()
-{
- static char *user_agent;
- struct utsname name;
- char *system;
-
- if (uname (&name) == 0)
- {
- system = g_strdup_printf ("%s %s",
- name.sysname,
- name.machine);
- }
- else
- {
- system = g_strdup ("Unknown");
- }
-
- user_agent = g_strdup_printf
- ("Mozilla/5.0 (X11; U; %s) Gecko/%d Epiphany/" VERSION,
- system,
- NS_BUILD_ID/100);
-
- g_free (system);
-
- return user_agent;
-}
-
static void
mozilla_set_default_prefs (MozillaEmbedSingle *mes)
{
@@ -418,11 +389,11 @@ mozilla_set_default_prefs (MozillaEmbedSingle *mes)
pref->SetBoolPref ("browser.enable_automatic_image_resizing", PR_TRUE);
/* User agent */
- char *user_agent;
- user_agent = build_user_agent ();
- pref->SetCharPref ("general.useragent.override", user_agent);
- g_free (user_agent);
+ /* FIXME We need to do this because mozilla doesnt set product
+ sub for embedding apps */
+ pref->SetCharPref ("general.useragent.vendor", "Epiphany");
+ pref->SetCharPref ("general.useragent.vendorSub", VERSION);
}
static char *
@@ -750,7 +721,7 @@ impl_get_encodings (EphyEmbedSingle *shell,
info->encoding = g_strdup (encodings[i].name);
- elided = ephy_str_elide_underscores (_(encodings[i].title));
+ elided = ephy_string_elide_underscores (_(encodings[i].title));
if (elide_underscores)
{
@@ -800,7 +771,7 @@ impl_get_language_groups (EphyEmbedSingle *shell,
info->group = lang_groups[i].group;
/* collate without underscores */
- elided = ephy_str_elide_underscores (info->title);
+ elided = ephy_string_elide_underscores (info->title);
info->key = g_utf8_collate_key (elided, -1);
g_free (elided);
@@ -1069,7 +1040,10 @@ impl_show_file_picker (EphyEmbedSingle *shell,
g_free (expanded_directory);
filePicker->InitWithGtkWidget (parentWidget, title, mode);
- filePicker->SetDefaultString (NS_ConvertUTF8toUCS2(file).get());
+ if (file)
+ {
+ filePicker->SetDefaultString (NS_ConvertUTF8toUCS2(file).get());
+ }
filePicker->SetDisplayDirectory (dir);
PRInt16 retval;