aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-24 22:48:34 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-24 22:48:34 +0800
commitb0f66eed569bdc92c55cb8c39f62b5694b7f62b3 (patch)
tree16b2f0a1106cdf05e2a7a05c0572f656307a1e2e
parent459e4b6f3a76d3904c84127b1147a14676586ed7 (diff)
downloadgsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar.gz
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar.bz2
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar.lz
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar.xz
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.tar.zst
gsoc2013-epiphany-b0f66eed569bdc92c55cb8c39f62b5694b7f62b3.zip
Implement the data part of the toolbar editor. Partial implementation of
2003-01-24 Marco Pesenti Gritti <marco@it.gnome.org> * NEWS: * configure.in: * data/ui/epiphany-toolbar.xml.in: * lib/egg/Makefile.am: * lib/widgets/Makefile.am: * lib/widgets/ephy-editable-toolbar.c: (ephy_editable_toolbar_get_type), (find_action), (add_action_to_list), (parse_item_list), (parse_toolbars), (load_defaults), (load_toolbar), (toolbar_list_to_xml), (toolbar_list_to_string), (do_merge), (ephy_editable_toolbar_set_merge), (ephy_editable_toolbar_set_property), (ephy_editable_toolbar_get_property), (ephy_editable_toolbar_class_init), (ephy_editable_toolbar_init), (ephy_editable_toolbar_save), (ephy_editable_toolbar_finalize), (ephy_editable_toolbar_new): * lib/widgets/ephy-editable-toolbar.h: * src/Makefile.am: * src/bookmarks/Makefile.am: * src/bookmarks/ephy-bookmark-action.c: (ephy_bookmark_action_get_type), (create_tool_item), (ephy_bookmark_action_sync_label), (connect_proxy), (ephy_bookmark_action_set_property), (ephy_bookmark_action_get_property), (ephy_bookmark_action_class_init), (ephy_bookmark_action_init), (ephy_bookmark_action_new): * src/bookmarks/ephy-bookmark-action.h: * src/ephy-tab.c: (ephy_tab_finalize), (ephy_tab_set_location): * src/toolbar.c: (toolbar_get_type), (toolbar_set_window), (editable_toolbar_request_action), (toolbar_init), (toolbar_finalize): * src/toolbar.h: Implement the data part of the toolbar editor. Partial implementation of Bookmark action. Try to fix crashes when switching tabs.
-rw-r--r--NEWS6
-rw-r--r--data/ui/epiphany-toolbar.xml.in40
-rw-r--r--lib/egg/Makefile.am6
-rw-r--r--lib/widgets/Makefile.am2
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c450
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.h59
-rw-r--r--src/Makefile.am1
-rw-r--r--src/bookmarks/Makefile.am5
-rw-r--r--src/bookmarks/ephy-bookmark-action.c208
-rw-r--r--src/bookmarks/ephy-bookmark-action.h52
-rw-r--r--src/ephy-tab.c6
-rwxr-xr-xsrc/toolbar.c46
-rw-r--r--src/toolbar.h6
13 files changed, 851 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index e69de29bb..ea0d2ca6c 100644
--- a/NEWS
+++ b/NEWS
@@ -0,0 +1,6 @@
+0.4.3
+
+- Rewrite toolbars/menus using EggMenu
+ (Because of this the toolbar editor
+ is temporarily removed)
+- Several bugfixes
diff --git a/data/ui/epiphany-toolbar.xml.in b/data/ui/epiphany-toolbar.xml.in
index 0a46f0fe8..b95092dcf 100644
--- a/data/ui/epiphany-toolbar.xml.in
+++ b/data/ui/epiphany-toolbar.xml.in
@@ -1,15 +1,27 @@
-<Root>
-<dockitem name="toolbar1">
- <toolitem name="ViewBackTItem" verb="NavigationBack"/>
- <toolitem name="ViewForwardTItem" verb="NavigationForward"/>
- <toolitem name="ViewStopTItem" verb="ViewStop"/>
- <toolitem name="ViewReloadTItem" verb="ViewReload"/>
- <separator name="ToolbarSep1"/>
- <toolitem name="GoHomeTItem" verb="GoHome"/>
- <separator name="ToolbarSep2"/>
- <toolitem name="FaviconTItem" verb="Favicon"/>
- <toolitem name="LocationTItem" verb="Location"/>
- <toolitem name="SpinnerTItem" verb="Spinner"/>
-</dockitem>
-</Root>
+<editabletoolbar>
+<available>
+ <toolitem verb="NavigationBack"/>
+ <toolitem verb="NavigationForward"/>
+ <toolitem verb="ViewStop"/>
+ <toolitem verb="ViewReload"/>
+ <toolitem verb="GoHome"/>
+ <toolitem verb="Favicon"/>
+ <toolitem verb="Location"/>
+ <toolitem verb="Spinner"/>
+</available>
+<default>
+<toolbar>
+ <toolitem verb="NavigationBack"/>
+ <toolitem verb="NavigationForward"/>
+ <toolitem verb="ViewStop"/>
+ <toolitem verb="ViewReload"/>
+ <separator/>
+ <toolitem verb="GoHome"/>
+ <separator/>
+ <toolitem verb="Favicon"/>
+ <toolitem verb="Location"/>
+ <toolitem verb="Spinner"/>
+</toolbar>
+</default>
+</editabletoolbar>
diff --git a/lib/egg/Makefile.am b/lib/egg/Makefile.am
index 93abfd0d3..b903ca315 100644
--- a/lib/egg/Makefile.am
+++ b/lib/egg/Makefile.am
@@ -36,7 +36,8 @@ noinst_HEADERS = \
eggtoolitem.h \
eggseparatortoolitem.h \
eggtoolbar.h \
- eggtoolbutton.h
+ eggtoolbutton.h \
+ eggmarshalers.h
eggmarshalers.h:
cd $(srcdir) \
@@ -52,8 +53,5 @@ eggmarshalers.c:
egg-marshal.c: eggmarshalers.h eggmarshalers.c
-noinst_HEADERS = \
- eggmarshalers.h
-
EXTRA_DIST= \
eggmarshalers.list
diff --git a/lib/widgets/Makefile.am b/lib/widgets/Makefile.am
index 23aad4b01..6008f39cc 100644
--- a/lib/widgets/Makefile.am
+++ b/lib/widgets/Makefile.am
@@ -21,6 +21,8 @@ libephywidgets_la_SOURCES = \
ephy-arrow-toolbutton.h \
ephy-autocompletion-window.c \
ephy-autocompletion-window.h \
+ ephy-editable-toolbar.c \
+ ephy-editable-toolbar.h \
ephy-ellipsizing-label.c \
ephy-ellipsizing-label.h \
ephy-location-entry.c \
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
new file mode 100755
index 000000000..8ba8e50d7
--- /dev/null
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2000 Marco Pesenti Gritti
+ * (C) 2001, 2002 Jorn Baayen
+ *
+ * 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.
+ */
+
+#include "ephy-editable-toolbar.h"
+#include "ephy-file-helpers.h"
+#include "ephy-debug.h"
+
+#include <libxml/parser.h>
+
+static void ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass);
+static void ephy_editable_toolbar_init (EphyEditableToolbar *t);
+static void ephy_editable_toolbar_finalize (GObject *object);
+
+enum
+{
+ PROP_0,
+ PROP_MENU_MERGE
+};
+
+enum
+{
+ REQUEST_ACTION,
+ LAST_SIGNAL
+};
+
+static GObjectClass *parent_class = NULL;
+
+static gint EphyEditableToolbarSignals[LAST_SIGNAL];
+
+struct EphyEditableToolbarPrivate
+{
+ EggMenuMerge *merge;
+ EggAction *separator;
+ GList *available_actions;
+ GList *toolbars;
+ char *filename;
+};
+
+GType
+ephy_editable_toolbar_get_type (void)
+{
+ static GType ephy_editable_toolbar_type = 0;
+
+ if (ephy_editable_toolbar_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyEditableToolbarClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) ephy_editable_toolbar_class_init,
+ NULL,
+ NULL, /* class_data */
+ sizeof (EphyEditableToolbar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ephy_editable_toolbar_init
+ };
+
+ ephy_editable_toolbar_type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyEditableToolbar",
+ &our_info, 0);
+ }
+
+ return ephy_editable_toolbar_type;
+
+}
+
+static EggAction *
+find_action (EphyEditableToolbar *t, const char *name)
+{
+ GList *l = t->priv->merge->action_groups;
+ EggAction *action = NULL;
+
+ for (; l != NULL; l = l->next)
+ {
+ EggAction *tmp;
+
+ tmp = egg_action_group_get_action
+ (EGG_ACTION_GROUP (l->data), name);
+ if (tmp) action = tmp;
+ }
+
+ return action;
+}
+
+static void
+add_action_to_list (EphyEditableToolbar *t, GList **list, const char *name)
+{
+ EggAction *action = NULL;
+
+ action = find_action (t, name);
+
+ if (!action)
+ {
+ g_signal_emit (t, EphyEditableToolbarSignals[REQUEST_ACTION], 0, name);
+ }
+
+ action = find_action (t, name);
+
+ if (action)
+ {
+ *list = g_list_append (*list, action);
+ }
+}
+
+static void
+parse_item_list (EphyEditableToolbar *t,
+ xmlNodePtr child,
+ GList **actions)
+{
+ while (child)
+ {
+ if (xmlStrEqual (child->name, "toolitem"))
+ {
+ xmlChar *verb;
+
+ verb = xmlGetProp (child, "verb");
+ add_action_to_list (t, actions, verb);
+
+ xmlFree (verb);
+ }
+ else if (xmlStrEqual (child->name, "separator"))
+ {
+ *actions = g_list_append
+ (*actions, t->priv->separator);
+ }
+
+ child = child->next;
+ }
+}
+
+static void
+parse_toolbars (EphyEditableToolbar *t,
+ xmlNodePtr child,
+ GList **toolbars)
+{
+ while (child)
+ {
+ if (xmlStrEqual (child->name, "toolbar"))
+ {
+ GList *list = NULL;
+
+ parse_item_list (t, child->children, &list);
+ *toolbars = g_list_append (*toolbars, list);
+ }
+
+ child = child->next;
+ }
+}
+
+static void
+load_defaults (EphyEditableToolbar *t)
+{
+ xmlDocPtr doc;
+ xmlNodePtr child;
+ xmlNodePtr root;
+ const char *xml_filepath;
+
+ LOG ("Load default toolbar info")
+
+ xml_filepath = ephy_file ("epiphany-toolbar.xml");
+
+ doc = xmlParseFile (xml_filepath);
+ root = xmlDocGetRootElement (doc);
+
+ child = root->children;
+ while (child)
+ {
+ if (xmlStrEqual (child->name, "available"))
+ {
+ parse_item_list (t, child->children,
+ &t->priv->available_actions);
+ }
+ else if (xmlStrEqual (child->name, "default") &&
+ t->priv->toolbars == NULL)
+ {
+ parse_toolbars (t, child->children,
+ &t->priv->toolbars);
+ }
+
+ child = child->next;
+ }
+}
+
+static void
+load_toolbar (EphyEditableToolbar *t)
+{
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ const char *xml_filepath = t->priv->filename;
+
+ LOG ("Load custom toolbar")
+
+ if (!g_file_test (xml_filepath, G_FILE_TEST_EXISTS)) return;
+
+ doc = xmlParseFile (xml_filepath);
+ root = xmlDocGetRootElement (doc);
+
+ parse_toolbars (t, root->children,
+ &t->priv->toolbars);
+}
+
+static xmlDocPtr
+toolbar_list_to_xml (EphyEditableToolbar *t, GList *tl)
+{
+ GList *l1, *l2;
+ xmlDocPtr doc;
+
+ xmlIndentTreeOutput = TRUE;
+ doc = xmlNewDoc ("1.0");
+ doc->children = xmlNewDocNode (doc, NULL, "toolbars", NULL);
+
+ for (l1 = tl; l1 != NULL; l1 = l1->next)
+ {
+ xmlNodePtr tnode;
+
+ tnode = xmlNewChild (doc->children, NULL, "toolbar", NULL);
+
+ for (l2 = l1->data; l2 != NULL; l2 = l2->next)
+ {
+ xmlNodePtr node;
+ EggAction *action = EGG_ACTION (l2->data);
+
+ if (action == t->priv->separator)
+ {
+ node = xmlNewChild (tnode, NULL, "separator", NULL);
+ }
+ else
+ {
+ node = xmlNewChild (tnode, NULL, "toolitem", NULL);
+ xmlSetProp (node, "verb", action->name);
+ }
+ }
+ }
+
+ return doc;
+}
+
+static char *
+toolbar_list_to_string (EphyEditableToolbar *t, GList *tl)
+{
+ GString *s;
+ GList *l1, *l2;
+ char *result;
+
+ s = g_string_new (NULL);
+ g_string_append (s, "<Root>");
+ for (l1 = tl; l1 != NULL; l1 = l1->next)
+ {
+ int i = 0;
+
+ g_string_append_printf
+ (s, "<dockitem name=\"Toolbar%d\">",
+ g_list_index (tl, l1->data));
+
+ for (l2 = l1->data; l2 != NULL; l2 = l2->next)
+ {
+ EggAction *action = EGG_ACTION (l2->data);
+
+ if (action == t->priv->separator)
+ {
+ g_string_append_printf
+ (s, "<separator name=\"ToolItem%d\"/>", i);
+ }
+ else
+ {
+ g_string_append_printf
+ (s, "<toolitem name=\"ToolItem%d\" verb=\"%s\"/>",
+ i, action->name);
+ }
+
+ i++;
+ }
+
+ g_string_append (s, "</dockitem>");
+ }
+ g_string_append (s, "</Root>");
+
+ result = s->str;
+
+ g_string_free (s, FALSE);
+
+ return result;
+}
+
+static void
+do_merge (EphyEditableToolbar *t)
+{
+ GList *tl;
+ char *str;
+
+ tl = t->priv->toolbars;
+
+ str = toolbar_list_to_string (t, tl);
+
+ LOG ("Merge UI\n%s", str)
+
+ egg_menu_merge_add_ui_from_string
+ (t->priv->merge, str, -1, NULL);
+ egg_menu_merge_ensure_update (t->priv->merge);
+
+ g_free (str);
+}
+
+static void
+ephy_editable_toolbar_set_merge (EphyEditableToolbar *t, EggMenuMerge *merge)
+{
+ t->priv->merge = merge;
+
+ LOG ("Got MenuMerge")
+
+ load_toolbar (t);
+ load_defaults (t);
+ do_merge (t);
+}
+
+static void
+ephy_editable_toolbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEditableToolbar *t = EPHY_EDITABLE_TOOLBAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_MENU_MERGE:
+ ephy_editable_toolbar_set_merge (t, g_value_get_object (value));
+ break;
+ }
+}
+
+static void
+ephy_editable_toolbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEditableToolbar *t = EPHY_EDITABLE_TOOLBAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_MENU_MERGE:
+ g_value_set_object (value, t->priv->merge);
+ break;
+ }
+}
+
+static void
+ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_editable_toolbar_finalize;
+
+ object_class->set_property = ephy_editable_toolbar_set_property;
+ object_class->get_property = ephy_editable_toolbar_get_property;
+
+ EphyEditableToolbarSignals[REQUEST_ACTION] =
+ g_signal_new
+ ("request_action", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP,
+ G_STRUCT_OFFSET (EphyEditableToolbarClass, request_action),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ g_object_class_install_property (object_class,
+ PROP_MENU_MERGE,
+ g_param_spec_object ("MenuMerge",
+ "MenuMerge",
+ "Menu merge",
+ EGG_TYPE_MENU_MERGE,
+ G_PARAM_READWRITE));
+}
+
+static void
+ephy_editable_toolbar_init (EphyEditableToolbar *t)
+{
+ t->priv = g_new0 (EphyEditableToolbarPrivate, 1);
+
+ t->priv->merge = NULL;
+ t->priv->available_actions = NULL;
+ t->priv->toolbars = NULL;
+ t->priv->filename = g_build_filename (ephy_dot_dir (), "toolbar.xml", NULL);
+ t->priv->separator = g_object_new (EGG_TYPE_ACTION, NULL);
+}
+
+static void
+ephy_editable_toolbar_save (EphyEditableToolbar *t)
+{
+ xmlDocPtr doc;
+
+ doc = toolbar_list_to_xml (t, t->priv->toolbars);
+ xmlSaveFormatFile (t->priv->filename, doc, 1);
+ xmlFreeDoc (doc);
+}
+
+static void
+ephy_editable_toolbar_finalize (GObject *object)
+{
+ EphyEditableToolbar *t = EPHY_EDITABLE_TOOLBAR (object);
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (object));
+
+ ephy_editable_toolbar_save (t);
+
+ g_object_unref (t->priv->separator);
+ g_free (t->priv->filename);
+
+ g_free (t->priv);
+
+ LOG ("EphyEditableToolbar finalized")
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+EphyEditableToolbar *
+ephy_editable_toolbar_new (EggMenuMerge *merge)
+{
+ EphyEditableToolbar *t;
+
+ t = EPHY_EDITABLE_TOOLBAR (g_object_new (EPHY_EDITABLE_TOOLBAR_TYPE,
+ "MenuMerge", merge,
+ NULL));
+
+ g_return_val_if_fail (t->priv != NULL, NULL);
+
+ return t;
+}
diff --git a/lib/widgets/ephy-editable-toolbar.h b/lib/widgets/ephy-editable-toolbar.h
new file mode 100755
index 000000000..21b195b6d
--- /dev/null
+++ b/lib/widgets/ephy-editable-toolbar.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ *
+ * 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.
+ */
+
+#ifndef EPHY_EDITABLE_TOOLBAR_H
+#define EPHY_EDITABLE_TOOLBAR_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include "egg-menu-merge.h"
+
+G_BEGIN_DECLS
+
+typedef struct EphyEditableToolbarClass EphyEditableToolbarClass;
+
+#define EPHY_EDITABLE_TOOLBAR_TYPE (ephy_editable_toolbar_get_type ())
+#define EPHY_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_EDITABLE_TOOLBAR_TYPE, EphyEditableToolbar))
+#define EPHY_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_EDITABLE_TOOLBAR_TYPE, EphyEditableToolbarClass))
+#define IS_EPHY_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_EDITABLE_TOOLBAR_TYPE))
+#define IS_EPHY_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_EDITABLE_TOOLBAR_TYPE))
+
+typedef struct EphyEditableToolbar EphyEditableToolbar;
+typedef struct EphyEditableToolbarPrivate EphyEditableToolbarPrivate;
+
+struct EphyEditableToolbar
+{
+ GObject parent_object;
+ EphyEditableToolbarPrivate *priv;
+};
+
+struct EphyEditableToolbarClass
+{
+ GObjectClass parent_class;
+
+ void (* request_action) (EphyEditableToolbar *etoolbar,
+ const char *action_name);
+};
+
+GType ephy_editable_toolbar_get_type (void);
+
+EphyEditableToolbar *ephy_editable_toolbar_new (EggMenuMerge *merge);
+
+G_END_DECLS
+
+#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index bf4fdb8a2..81f3a02a6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,6 +58,7 @@ epiphany_SOURCES = \
ephy-location-action.h \
ephy-main.c \
ephy-navigation-action.c \
+ ephy-navigation-action.h \
ephy-shell.c \
ephy-shell.h \
ephy-spinner-action.c \
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
index 098462cfa..24fa968da 100644
--- a/src/bookmarks/Makefile.am
+++ b/src/bookmarks/Makefile.am
@@ -3,6 +3,7 @@ INCLUDES = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/embed \
-I$(top_srcdir)/lib/widgets \
+ -I$(top_srcdir)/lib/egg \
$(WARN_CFLAGS) \
$(EPIPHANY_DEPENDENCY_CFLAGS) \
-DSHARE_DIR=\"$(pkgdatadir)\" \
@@ -17,6 +18,8 @@ INCLUDES = \
noinst_LTLIBRARIES = libephybookmarks.la
libephybookmarks_la_SOURCES = \
+ ephy-bookmark-action.c \
+ ephy-bookmark-action.h \
ephy-bookmarks.c \
ephy-bookmarks.h \
ephy-bookmarks-editor.c \
@@ -31,5 +34,3 @@ libephybookmarks_la_SOURCES = \
ephy-node-view.h \
ephy-tree-model-node.c \
ephy-tree-model-node.h
-
-
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
new file mode 100644
index 000000000..8ce9e9f4c
--- /dev/null
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ *
+ * 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.
+ */
+
+#include "ephy-bookmark-action.h"
+#include "ephy-bookmarks.h"
+#include "ephy-shell.h"
+#include "eggtoolitem.h"
+#include "ephy-debug.h"
+
+static void ephy_bookmark_action_init (EphyBookmarkAction *action);
+static void ephy_bookmark_action_class_init (EphyBookmarkActionClass *class);
+
+struct EphyBookmarkActionPrivate
+{
+ int bookmark_id;
+};
+
+enum
+{
+ PROP_0,
+ PROP_BOOKMARK_ID
+};
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_bookmark_action_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type)
+ {
+ static const GTypeInfo type_info =
+ {
+ sizeof (EphyBookmarkActionClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) ephy_bookmark_action_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (EphyBookmarkAction),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ephy_bookmark_action_init,
+ };
+
+ type = g_type_register_static (EGG_TYPE_ACTION,
+ "EphyBookmarkAction",
+ &type_info, 0);
+ }
+ return type;
+}
+
+static GtkWidget *
+create_tool_item (EggAction *action)
+{
+ GtkWidget *item;
+ GtkWidget *button;
+ GtkWidget *hbox;
+ GtkWidget *label;
+
+ item = (* EGG_ACTION_CLASS (parent_class)->create_tool_item) (action);
+
+ button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_show (button);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (button), hbox);
+
+ label = gtk_label_new (NULL);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (item), button);
+ g_object_set_data (G_OBJECT (item), "button", label);
+
+ return item;
+}
+
+static void
+ephy_bookmark_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
+{
+ GtkLabel *label;
+
+ LOG ("Set bookmark action proxy label to %s", action->label)
+
+ label = GTK_LABEL (g_object_get_data (G_OBJECT (proxy), "button"));
+ g_return_if_fail (label != NULL);
+
+ gtk_label_set_label (label, action->label);
+}
+
+static void
+connect_proxy (EggAction *action, GtkWidget *proxy)
+{
+ (* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
+
+ ephy_bookmark_action_sync_label (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::label",
+ G_CALLBACK (ephy_bookmark_action_sync_label), proxy, 0);
+}
+
+static void
+ephy_bookmark_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarkAction *bmk;
+
+ bmk = EPHY_BOOKMARK_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARK_ID:
+ bmk->priv->bookmark_id = g_value_get_int (value);
+ break;
+ }
+}
+
+static void
+ephy_bookmark_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarkAction *bmk;
+
+ bmk = EPHY_BOOKMARK_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_BOOKMARK_ID:
+ g_value_set_boolean (value, bmk->priv->bookmark_id);
+ break;
+ }
+}
+
+static void
+ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
+{
+ EggActionClass *action_class;
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
+ action_class = EGG_ACTION_CLASS (class);
+
+ action_class->toolbar_item_type = EGG_TYPE_TOOL_ITEM;
+ action_class->create_tool_item = create_tool_item;
+ action_class->connect_proxy = connect_proxy;
+
+ object_class->set_property = ephy_bookmark_action_set_property;
+ object_class->get_property = ephy_bookmark_action_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_BOOKMARK_ID,
+ g_param_spec_int ("bookmark_id",
+ "bookmark_id",
+ "bookmark_id",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+}
+
+static void
+ephy_bookmark_action_init (EphyBookmarkAction *action)
+{
+ action->priv = g_new0 (EphyBookmarkActionPrivate, 1);
+}
+
+EggAction *
+ephy_bookmark_action_new (const char *name, guint id)
+{
+ EphyNode *bmk;
+ const char *title;
+ EphyBookmarks *bookmarks;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+
+ bmk = ephy_node_get_from_id (id);
+ g_return_val_if_fail (bmk != NULL, NULL);
+
+ title = ephy_node_get_property_string
+ (bmk, EPHY_NODE_BMK_PROP_TITLE);
+
+ return EGG_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION,
+ "name", name,
+ "label", title,
+ NULL));
+}
+
diff --git a/src/bookmarks/ephy-bookmark-action.h b/src/bookmarks/ephy-bookmark-action.h
new file mode 100644
index 000000000..ca67b0d0c
--- /dev/null
+++ b/src/bookmarks/ephy-bookmark-action.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ *
+ * 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.
+ */
+
+#ifndef EPHY_BOOKMARK_ACTION_H
+#define EPHY_BOOKMARK_ACTION_H
+
+#include <gtk/gtk.h>
+#include <egg-action.h>
+
+#define EPHY_TYPE_BOOKMARK_ACTION (ephy_bookmark_action_get_type ())
+#define EPHY_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkAction))
+#define EPHY_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass))
+#define EPHY_IS_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION))
+#define EPHY_IS_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION))
+#define EPHY_BOOKMARK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass))
+
+typedef struct _EphyBookmarkAction EphyBookmarkAction;
+typedef struct _EphyBookmarkActionClass EphyBookmarkActionClass;
+typedef struct EphyBookmarkActionPrivate EphyBookmarkActionPrivate;
+
+struct _EphyBookmarkAction
+{
+ EggAction parent;
+ EphyBookmarkActionPrivate *priv;
+};
+
+struct _EphyBookmarkActionClass
+{
+ EggActionClass parent_class;
+};
+
+GType ephy_bookmark_action_get_type (void);
+
+EggAction *ephy_bookmark_action_new (const char *name,
+ guint id);
+
+#endif
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 98f04fad1..9b3e53c5a 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -289,6 +289,8 @@ ephy_tab_finalize (GObject *object)
g_object_unref (tab->priv->event);
}
+ g_free (tab->priv->location);
+
g_free (tab->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -1001,10 +1003,10 @@ ephy_tab_get_favicon_url (EphyTab *tab)
void
ephy_tab_set_location (EphyTab *tab,
- char *location)
+ char *location)
{
if (tab->priv->location) g_free (tab->priv->location);
- tab->priv->location = location;
+ tab->priv->location = g_strdup (location);
}
void
diff --git a/src/toolbar.c b/src/toolbar.c
index c97311fc8..7edc38490 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -28,9 +28,13 @@
#include "ephy-location-action.h"
#include "ephy-favicon-action.h"
#include "ephy-navigation-action.h"
+#include "ephy-bookmark-action.h"
#include "window-commands.h"
+#include "ephy-string.h"
#include "ephy-debug.h"
+#include <string.h>
+
static void toolbar_class_init (ToolbarClass *klass);
static void toolbar_init (Toolbar *t);
static void toolbar_finalize (GObject *object);
@@ -86,7 +90,7 @@ toolbar_get_type (void)
(GInstanceInitFunc) toolbar_init
};
- toolbar_type = g_type_register_static (G_TYPE_OBJECT,
+ toolbar_type = g_type_register_static (EPHY_EDITABLE_TOOLBAR_TYPE,
"Toolbar",
&our_info, 0);
}
@@ -149,14 +153,6 @@ toolbar_get_property (GObject *object,
}
static void
-toolbar_setup_widgets (Toolbar *t)
-{
- egg_menu_merge_add_ui_from_file
- (t->priv->ui_merge, ephy_file ("epiphany-toolbar.xml"), NULL);
- egg_menu_merge_ensure_update (t->priv->ui_merge);
-}
-
-static void
go_location_cb (EggAction *action, char *location, EphyWindow *window)
{
EphyEmbed *embed;
@@ -243,7 +239,29 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
toolbar_setup_actions (t);
egg_menu_merge_insert_action_group (t->priv->ui_merge,
t->priv->action_group, 1);
- toolbar_setup_widgets (t);
+ g_object_set (t, "MenuMerge", t->priv->ui_merge, NULL);
+}
+
+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
@@ -254,6 +272,10 @@ 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
@@ -272,14 +294,14 @@ toolbar_finalize (GObject *object)
g_return_if_fail (p != NULL);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
g_object_unref (t->priv->action_group);
egg_menu_merge_remove_action_group (merge, t->priv->action_group);
g_free (t->priv);
LOG ("Toolbar finalized")
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
}
Toolbar *
diff --git a/src/toolbar.h b/src/toolbar.h
index 15cfa855a..649156165 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -19,7 +19,9 @@
#ifndef TOOLBAR_H
#define TOOLBAR_H
+#include "ephy-editable-toolbar.h"
#include "ephy-window.h"
+
#include <glib-object.h>
#include <glib.h>
@@ -37,13 +39,13 @@ typedef struct ToolbarPrivate ToolbarPrivate;
struct Toolbar
{
- GObject parent_object;
+ EphyEditableToolbar parent_object;
ToolbarPrivate *priv;
};
struct ToolbarClass
{
- GObjectClass parent_class;
+ EphyEditableToolbarClass parent_class;
};
GType toolbar_get_type (void);