aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.c110
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.h10
-rw-r--r--src/ephy-window.c17
4 files changed, 111 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 5079e0fcd..d226e528a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2004-10-29 Christian Persch <chpe@cvs.gnome.org>
+ * src/bookmarks/ephy-bookmarks-menu.c: (open_bookmark_cb),
+ (open_bookmark_in_tab_cb), (add_action_for_bookmark),
+ (create_submenu), (ephy_bookmarks_menu_rebuild),
+ (ephy_bookmarks_menu_set_property),
+ (ephy_bookmarks_menu_get_property),
+ (ephy_bookmarks_menu_constructor), (ephy_bookmarks_menu_finalize),
+ (ephy_bookmarks_menu_class_init), (ephy_bookmarks_menu_new):
+ * src/bookmarks/ephy-bookmarks-menu.h:
+ * src/ephy-window.c: (open_bookmark_cb), (ephy_window_init):
+
+ Slightly refactor bookmarks menu, to take a configurable path
+ where to merge its UI.
+
+2004-10-29 Christian Persch <chpe@cvs.gnome.org>
+
* src/bookmarks/ephy-topic-action.c: (can_open_in_tabs),
(open_in_tabs_activate_cb), (add_open_in_tabs_menu),
(build_bookmarks_menu), (show_context_menu):
diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c
index a681c97f0..75566ccdc 100644
--- a/src/bookmarks/ephy-bookmarks-menu.c
+++ b/src/bookmarks/ephy-bookmarks-menu.c
@@ -28,6 +28,8 @@
#include "ephy-shell.h"
#include "ephy-node-common.h"
#include "ephy-string.h"
+#include "ephy-marshal.h"
+#include "ephy-gui.h"
#include "ephy-debug.h"
#include <glib/gprintf.h>
@@ -40,7 +42,7 @@
struct _EphyBookmarksMenuPrivate
{
GtkUIManager *manager;
- EphyWindow *window;
+ char *path;
EphyBookmarks *bookmarks;
GtkActionGroup *bmk_actions;
GtkActionGroup *folder_actions;
@@ -50,8 +52,6 @@ struct _EphyBookmarksMenuPrivate
gboolean needs_update;
};
-#define BOOKMARKS_MENU_PATH "/menubar/BookmarksMenu"
-
/* 14 = strlen ("0000000000000000") - strlen ("%x")
* FIXME: for 32bit, 6 is sufficient -> use some #if magic?
*/
@@ -76,9 +76,18 @@ struct _EphyBookmarksMenuPrivate
enum
{
PROP_0,
- PROP_WINDOW
+ PROP_PATH,
+ PROP_UI_MANAGER
+};
+
+enum
+{
+ OPEN,
+ LAST_SIGNAL
};
+static guint signals[LAST_SIGNAL] = { 0 };
+
static void ephy_bookmarks_menu_class_init (EphyBookmarksMenuClass *klass);
static void ephy_bookmarks_menu_init (EphyBookmarksMenu *menu);
@@ -178,7 +187,17 @@ open_bookmark_cb (GtkAction *action,
const char *location,
EphyBookmarksMenu *menu)
{
- ephy_window_load_url (menu->priv->window, location);
+ g_signal_emit (menu, signals[OPEN], 0, location,
+ ephy_gui_is_middle_click ());
+}
+
+static void
+open_bookmark_in_tab_cb (GtkAction *action,
+ const char *location,
+ gboolean dummy,
+ EphyBookmarksMenu *menu)
+{
+ g_signal_emit (menu, signals[OPEN], 0, location, TRUE);
}
#define BMK_ACCEL_PATH_PREFIX "<Actions>/BmkActions/"
@@ -205,6 +224,8 @@ add_action_for_bookmark (EphyBookmarksMenu *menu,
g_signal_connect (action, "open",
G_CALLBACK (open_bookmark_cb), menu);
+ g_signal_connect (action, "open_in_tab",
+ G_CALLBACK (open_bookmark_in_tab_cb), menu);
gtk_action_group_add_action (menu->priv->bmk_actions, action);
g_object_unref (action);
@@ -373,10 +394,10 @@ create_submenu (EphyBookmarksMenu *menu,
if (folders == NULL || folders[0] == NULL)
{
g_strfreev (folders);
- return g_strdup (BOOKMARKS_MENU_PATH);
+ return g_strdup (p->path);
}
- path = g_string_new (BOOKMARKS_MENU_PATH);
+ path = g_string_new (p->path);
for (i = 0; folders[i] != NULL; i++)
{
folder = folders[i];
@@ -486,7 +507,7 @@ ephy_bookmarks_menu_rebuild (EphyBookmarksMenu *menu)
if (ephy_node_get_n_children (not_categorized) > 0)
{
- create_menu (menu, not_categorized, BOOKMARKS_MENU_PATH);
+ create_menu (menu, not_categorized, p->path);
}
g_list_free (node_list);
@@ -541,26 +562,20 @@ ephy_bookmarks_menu_maybe_update (EphyBookmarksMenu *menu)
}
static void
-ephy_bookmarks_menu_set_window (EphyBookmarksMenu *menu,
- EphyWindow *window)
-{
- menu->priv->window = window;
- menu->priv->manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
-}
-
-static void
ephy_bookmarks_menu_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- EphyBookmarksMenu *m = EPHY_BOOKMARKS_MENU (object);
+ EphyBookmarksMenu *menu = EPHY_BOOKMARKS_MENU (object);
switch (prop_id)
{
- case PROP_WINDOW:
- ephy_bookmarks_menu_set_window
- (m, g_value_get_object (value));
+ case PROP_PATH:
+ menu->priv->path = g_value_dup_string (value);
+ break;
+ case PROP_UI_MANAGER:
+ menu->priv->manager = g_value_get_object (value);
break;
}
}
@@ -571,14 +586,8 @@ ephy_bookmarks_menu_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- EphyBookmarksMenu *m = EPHY_BOOKMARKS_MENU (object);
-
- switch (prop_id)
- {
- case PROP_WINDOW:
- g_value_set_object (value, m->priv->window);
- break;
- }
+ /* no readable properties */
+ g_return_if_reached ();
}
static void
@@ -712,7 +721,7 @@ ephy_bookmarks_menu_constructor (GType type,
menu = EPHY_BOOKMARKS_MENU (object);
- g_assert (menu->priv->window != NULL);
+ g_assert (menu->priv->manager != NULL && menu->priv->path != NULL);
menu->priv->bookmarks = ephy_shell_get_bookmarks (ephy_shell);
g_signal_connect_object (menu->priv->bookmarks, "tree_changed",
@@ -739,7 +748,7 @@ ephy_bookmarks_menu_constructor (GType type,
G_OBJECT (menu));
action = gtk_ui_manager_get_action (menu->priv->manager,
- BOOKMARKS_MENU_PATH);
+ menu->priv->path);
g_signal_connect_object (action, "activate",
G_CALLBACK (activate_cb), menu, 0);
@@ -771,6 +780,8 @@ ephy_bookmarks_menu_finalize (GObject *o)
g_object_unref (p->folder_actions);
}
+ g_free (p->path);
+
LOG ("EphyBookmarksMenu finalised %p", o);
G_OBJECT_CLASS (parent_class)->finalize (o);
@@ -788,22 +799,45 @@ ephy_bookmarks_menu_class_init (EphyBookmarksMenuClass *klass)
object_class->set_property = ephy_bookmarks_menu_set_property;
object_class->get_property = ephy_bookmarks_menu_get_property;
+ signals[OPEN] =
+ g_signal_new ("open",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyBookmarksMenuClass, open),
+ NULL, NULL,
+ ephy_marshal_VOID__STRING_BOOLEAN,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
+
+ g_object_class_install_property (object_class,
+ PROP_PATH,
+ g_param_spec_string ("path",
+ "Path",
+ "Merge path",
+ NULL,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (object_class,
- PROP_WINDOW,
- g_param_spec_object ("window",
- "Window",
- "Parent window",
- EPHY_TYPE_WINDOW,
- G_PARAM_READWRITE |
+ PROP_UI_MANAGER,
+ g_param_spec_object ("ui-manager",
+ "UI Manager",
+ "UI Manager",
+ GTK_TYPE_UI_MANAGER,
+ G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof (EphyBookmarksMenuPrivate));
}
EphyBookmarksMenu *
-ephy_bookmarks_menu_new (EphyWindow *window)
+ephy_bookmarks_menu_new (GtkUIManager *manager,
+ const char *path)
{
return EPHY_BOOKMARKS_MENU (g_object_new (EPHY_TYPE_BOOKMARKS_MENU,
- "window", window,
+ "ui-manager", manager,
+ "path", path,
NULL));
}
diff --git a/src/bookmarks/ephy-bookmarks-menu.h b/src/bookmarks/ephy-bookmarks-menu.h
index 890b388fe..b22e55a7f 100644
--- a/src/bookmarks/ephy-bookmarks-menu.h
+++ b/src/bookmarks/ephy-bookmarks-menu.h
@@ -21,7 +21,8 @@
#ifndef EPHY_BOOKMARKS_MENU_H
#define EPHY_BOOKMARKS_MENU_H
-#include "ephy-window.h"
+#include <glib-object.h>
+#include <gtk/gtkuimanager.h>
G_BEGIN_DECLS
@@ -39,6 +40,10 @@ typedef struct _EphyBookmarksMenuPrivate EphyBookmarksMenuPrivate;
struct _EphyBookmarksMenuClass
{
GObjectClass parent_class;
+
+ void (*open) (EphyBookmarksMenu *menu,
+ const char *address,
+ gboolean open_in_new);
};
struct _EphyBookmarksMenu
@@ -51,7 +56,8 @@ struct _EphyBookmarksMenu
GType ephy_bookmarks_menu_get_type (void);
-EphyBookmarksMenu *ephy_bookmarks_menu_new (EphyWindow *window);
+EphyBookmarksMenu *ephy_bookmarks_menu_new (GtkUIManager *manager,
+ const char *path);
G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 4d7942014..73495a6fd 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -329,6 +329,8 @@ static guint ephy_popups_n_entries = G_N_ELEMENTS (ephy_popups_entries);
#define CONF_DESKTOP_BG_PICTURE "/desktop/gnome/background/picture_filename"
#define INSANE_NUMBER_OF_URLS 20
+#define BOOKMARKS_MENU_PATH "/menubar/BookmarksMenu"
+
#define EPHY_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WINDOW, EphyWindowPrivate))
struct _EphyWindowPrivate
@@ -2290,6 +2292,15 @@ action_request_forward_cb (GObject *toolbar,
}
static void
+open_bookmark_cb (EphyBookmarksMenu *menu,
+ const char *location,
+ gboolean open_in_new,
+ EphyWindow *window)
+{
+ ephy_window_load_url (window, location);
+}
+
+static void
ephy_window_init (EphyWindow *window)
{
EphyExtension *manager;
@@ -2326,7 +2337,11 @@ ephy_window_init (EphyWindow *window)
window->priv->tabs_menu = ephy_tabs_menu_new (window);
window->priv->fav_menu = ephy_favorites_menu_new (window);
window->priv->enc_menu = ephy_encoding_menu_new (window);
- window->priv->bmk_menu = ephy_bookmarks_menu_new (window);
+
+ window->priv->bmk_menu = ephy_bookmarks_menu_new (window->priv->manager,
+ BOOKMARKS_MENU_PATH);
+ g_signal_connect (window->priv->bmk_menu, "open",
+ G_CALLBACK (open_bookmark_cb), window);
/* get the toolbars model *before* getting the bookmarksbar model
* (via ephy_bookmarsbar_new()), so that the toolbars model is