aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-30 05:06:40 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-30 05:06:40 +0800
commitdff9e866bb4f2fc18074d5c638733ee860746f9b (patch)
tree654f9332e949ce91c5d2f5c9a61280c874ce0ab5 /src
parentec52d432955e2e2d5467a8da01c8ce929388325c (diff)
downloadgsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.gz
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.bz2
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.lz
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.xz
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.zst
gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.zip
Complete (or nearly) toolbar editor implementation. Bookmarks are
2003-01-29 Marco Pesenti Gritti <marco@it.gnome.org> * lib/ephy-bonobo-extensions.c: (ephy_bonobo_clear_path), (ephy_bonobo_replace_path): * lib/ephy-bonobo-extensions.h: * lib/ephy-marshal.list: * lib/ephy-string.c: (ephy_str_to_int): * lib/ephy-string.h: * lib/widgets/ephy-editable-toolbar.c: (impl_get_action), (add_action), (parse_item_list), (add_toolbar), (parse_toolbars), (load_defaults), (load_toolbar), (drag_data_received_cb), (setup_toolbar_drag), (ensure_toolbars_min_size), (do_merge), (ephy_editable_toolbar_class_init), (editor_get_dimensions), (hide_editor), (editor_close_cb), (editor_add_toolbar_cb), (editor_drag_data_received_cb), (editor_drag_data_delete_cb), (setup_editor), (button_press_cb), (show_editor), (ephy_editable_toolbar_edit), (ephy_editable_toolbar_get_action): * lib/widgets/ephy-editable-toolbar.h: * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_bookmark_id): * src/bookmarks/ephy-bookmarks.h: * src/session.c: (session_load): * src/toolbar.c: (go_location_cb), (toolbar_get_action), (toolbar_class_init), (toolbar_init): Complete (or nearly) toolbar editor implementation. Bookmarks are implemented too, but some minor problems are stopping them to work.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks.c20
-rw-r--r--src/bookmarks/ephy-bookmarks.h3
-rw-r--r--src/session.c2
-rwxr-xr-xsrc/toolbar.c94
4 files changed, 80 insertions, 39 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 5e9d539f3..7e1d2bdd5 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -659,6 +659,26 @@ ephy_bookmarks_add (EphyBookmarks *eb,
return bm;
}
+guint
+ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb,
+ const char *url)
+{
+ EphyNode *node;
+
+ g_static_rw_lock_reader_lock (eb->priv->bookmarks_hash_lock);
+ node = g_hash_table_lookup (eb->priv->bookmarks_hash, url);
+ g_static_rw_lock_reader_unlock (eb->priv->bookmarks_hash_lock);
+
+ if (node)
+ {
+ return ephy_node_get_id (node);
+ }
+ else
+ {
+ return -1;
+ }
+}
+
void
ephy_bookmarks_set_icon (EphyBookmarks *eb,
const char *url,
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index d2b1d7915..169e5a841 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -69,6 +69,9 @@ EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
const char *smart_url,
const char *keywords);
+guint ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb,
+ const char *url);
+
void ephy_bookmarks_set_icon (EphyBookmarks *eb,
const char *url,
const char *icon);
diff --git a/src/session.c b/src/session.c
index d050a9dcd..431edef02 100644
--- a/src/session.c
+++ b/src/session.c
@@ -604,7 +604,7 @@ session_load (Session *session,
{
if (strcmp (child->name, "window") == 0)
{
- gint x = 0, y = 0, width = 0, height = 0;
+ gulong x = 0, y = 0, width = 0, height = 0;
xmlChar *tmp;
tmp = xmlGetProp (child, "x");
diff --git a/src/toolbar.c b/src/toolbar.c
index ff5f9cba1..29ae4665f 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -100,17 +100,72 @@ toolbar_get_type (void)
}
static void
+go_location_cb (EggAction *action, char *location, EphyWindow *window)
+{
+ EphyEmbed *embed;
+
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (embed != NULL);
+
+ ephy_embed_load_url (embed, location);
+}
+
+static EggAction *
+toolbar_get_action (EphyEditableToolbar *etoolbar,
+ const char *type,
+ const char *name)
+{
+ Toolbar *t = TOOLBAR (etoolbar);
+ EggAction *action = NULL;
+ EphyBookmarks *bookmarks;
+ gulong id = 0;
+
+ if (type && (strcmp (type, EPHY_DND_URL_TYPE) == 0))
+ {
+ char action_name[255];
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ id = ephy_bookmarks_get_bookmark_id (bookmarks, name);
+
+ snprintf (action_name, 255, "GoBookmarkId%ld", id);
+ action = ephy_bookmark_action_new (name, id);
+ }
+ else if (g_str_has_prefix (name, "GoBookmarkId"))
+ {
+ ephy_str_to_int (name + strlen ("GoBookmarkId"), &id);
+ }
+
+ if (action)
+ {
+ g_signal_connect (action, "go_location",
+ G_CALLBACK (go_location_cb), t->priv->window);
+ egg_action_group_add_action (t->priv->action_group, action);
+ g_object_unref (action);
+ }
+ else
+ {
+ action = EPHY_EDITABLE_TOOLBAR_CLASS
+ (parent_class)->get_action (etoolbar, type, name);
+ }
+
+ return action;
+}
+
+static void
toolbar_class_init (ToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ EphyEditableToolbarClass *eet_class;
parent_class = g_type_class_peek_parent (klass);
+ eet_class = EPHY_EDITABLE_TOOLBAR_CLASS (klass);
object_class->finalize = toolbar_finalize;
-
object_class->set_property = toolbar_set_property;
object_class->get_property = toolbar_get_property;
+ eet_class->get_action = toolbar_get_action;
+
g_object_class_install_property (object_class,
PROP_EPHY_WINDOW,
g_param_spec_object ("EphyWindow",
@@ -153,17 +208,6 @@ toolbar_get_property (GObject *object,
}
static void
-go_location_cb (EggAction *action, char *location, EphyWindow *window)
-{
- EphyEmbed *embed;
-
- embed = ephy_window_get_active_embed (window);
- g_return_if_fail (embed != NULL);
-
- ephy_embed_load_url (embed, location);
-}
-
-static void
toolbar_setup_actions (Toolbar *t)
{
EggAction *action;
@@ -246,28 +290,6 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
}
static void
-editable_toolbar_request_action (Toolbar *t,
- const char *name,
- EphyEditableToolbar *etoolbar)
-{
- guint id;
-
- if (g_str_has_prefix (name, "GoBookmark") &&
- ephy_str_to_int (name + strlen ("GoBookmark"), &id))
- {
- EggAction *action;
-
- LOG ("Create an action for bookmark %d", id)
-
- action = ephy_bookmark_action_new (name, id);
- g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb), t->priv->window);
- egg_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
- }
-}
-
-static void
toolbar_init (Toolbar *t)
{
t->priv = g_new0 (ToolbarPrivate, 1);
@@ -275,10 +297,6 @@ toolbar_init (Toolbar *t)
t->priv->window = NULL;
t->priv->ui_merge = NULL;
t->priv->visibility = TRUE;
-
- g_signal_connect (t, "request_action",
- G_CALLBACK (editable_toolbar_request_action),
- EPHY_EDITABLE_TOOLBAR (t));
}
static void