aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-04-25 23:23:09 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-04-25 23:23:09 +0800
commit7fcf1690b730892033993c1001c08666448f90b1 (patch)
treee1080fc2e0b87abacd9fee7aec64d377ab525bdf /src
parent33a47e1d4cc08edd1006d3bfd85b7a15d350119d (diff)
downloadgsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar.gz
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar.bz2
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar.lz
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar.xz
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.tar.zst
gsoc2013-epiphany-7fcf1690b730892033993c1001c08666448f90b1.zip
Get back toolbar editing functionalities. More work on the bookmarks
2003-04-25 Marco Pesenti Gritti <marco@it.gnome.org> * data/ui/epiphany-toolbar.xml.in: * data/ui/epiphany-ui.xml.in: * lib/egg/egg-editable-toolbar.c: (egg_editable_toolbar_hide), (egg_editable_toolbar_set_drag_dest): * lib/egg/egg-editable-toolbar.h: * src/bookmarks/ephy-topic-action.c: (create_tool_item): * src/ephy-shell.c: (save_toolbars), (ephy_shell_finalize), (ephy_shell_get_toolbars_model): * src/ephy-toolbars-model.c: (impl_add_item), (ephy_toolbars_model_class_init): * src/ephy-toolbars-model.h: * src/ephy-window.c: (ephy_window_set_chrome): * src/toolbar.c: (ensure_bookmark_action), (toolbar_ensure_action), (action_added_cb), (init_bookmarks_toolbar), (toolbar_set_window), (toolbar_new), (toolbar_set_visibility): * src/toolbar.h: * src/window-commands.c: (toolbar_editor_destroy_cb), (window_cmd_edit_toolbar): Get back toolbar editing functionalities. More work on the bookmarks toolbars implementation. The toolbars context menus are regressed but it's not my fault :/ The signal on EggToolbar is borked.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-topic-action.c2
-rw-r--r--src/ephy-shell.c21
-rwxr-xr-xsrc/ephy-toolbars-model.c40
-rwxr-xr-xsrc/ephy-toolbars-model.h3
-rw-r--r--src/ephy-window.c20
-rwxr-xr-xsrc/toolbar.c162
-rw-r--r--src/toolbar.h4
-rw-r--r--src/window-commands.c37
8 files changed, 226 insertions, 63 deletions
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index 4c6319c75..b8d8ab9ee 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -94,7 +94,7 @@ create_tool_item (EggAction *action)
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (hbox), button);
g_object_set_data (G_OBJECT (item), "button", button);
-
+
arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_widget_show (arrow);
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 9d71bfcef..2f21091ac 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -294,6 +294,18 @@ ephy_shell_init (EphyShell *gs)
}
static void
+save_toolbars (EggToolbarsModel *model)
+{
+ char *xml_file;
+
+ xml_file = g_build_filename (ephy_dot_dir (),
+ "toolbar.xml",
+ NULL);
+ egg_toolbars_model_save (model, xml_file);
+ g_free (xml_file);
+}
+
+static void
ephy_shell_finalize (GObject *object)
{
EphyShell *gs;
@@ -307,6 +319,13 @@ ephy_shell_finalize (GObject *object)
g_assert (ephy_shell == NULL);
+ LOG ("Unref toolbars model")
+ if (gs->priv->toolbars_model)
+ {
+ save_toolbars (EGG_TOOLBARS_MODEL (gs->priv->toolbars_model));
+ g_object_unref (G_OBJECT (gs->priv->toolbars_model));
+ }
+
LOG ("Unref session")
if (gs->priv->session)
{
@@ -648,8 +667,6 @@ ephy_shell_get_toolbars_model (EphyShell *gs)
if (gs->priv->toolbars_model == NULL)
{
gs->priv->toolbars_model = ephy_toolbars_model_new ();
- egg_toolbars_model_load (EGG_TOOLBARS_MODEL (gs->priv->toolbars_model),
- ephy_file ("epiphany-toolbar.xml"));
}
return gs->priv->toolbars_model;
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index da842e719..c67d427e3 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -26,6 +26,14 @@ static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass);
static void ephy_toolbars_model_init (EphyToolbarsModel *t);
static void ephy_toolbars_model_finalize (GObject *object);
+enum
+{
+ ACTION_ADDED,
+ LAST_SIGNAL
+};
+
+static guint ephy_toolbars_model_signals[LAST_SIGNAL] = { 0 };
+
static GObjectClass *parent_class = NULL;
struct EphyToolbarsModelPrivate
@@ -68,7 +76,10 @@ impl_add_item (EggToolbarsModel *t,
const char *name)
{
EphyBookmarks *bookmarks;
- char *res = NULL;
+ char *action_name = NULL;
+ const char *res;
+
+ LOG ("Add item %s", name)
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
@@ -79,24 +90,27 @@ impl_add_item (EggToolbarsModel *t,
nodes = ephy_dnd_node_list_extract_nodes (name);
id = ephy_node_get_id (EPHY_NODE (nodes->data));
- res = g_strdup_printf ("GoTopicId%d", id);
+ action_name = g_strdup_printf ("GoTopicId%d", id);
g_list_free (nodes);
}
- else if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
+ else if (gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE) == type)
{
GList *nodes;
int id;
nodes = ephy_dnd_node_list_extract_nodes (name);
id = ephy_node_get_id (EPHY_NODE (nodes->data));
- res = g_strdup_printf ("GoBookmarkId%d", id);
+ action_name = g_strdup_printf ("GoBookmarkId%d", id);
g_list_free (nodes);
}
- else
- {
- EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item
- (t, toolbar_position, position, type, name);
- }
+
+ res = action_name ? action_name : name;
+
+ g_signal_emit (G_OBJECT (t),
+ ephy_toolbars_model_signals[ACTION_ADDED], 0, res);
+
+ EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item
+ (t, toolbar_position, position, type, res);
return res;
}
@@ -114,6 +128,14 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
object_class->finalize = ephy_toolbars_model_finalize;
etm_class->add_item = impl_add_item;
+
+ ephy_toolbars_model_signals[ACTION_ADDED] =
+ g_signal_new ("action_added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyToolbarsModelClass, action_added),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index 4ebf48057..f01230494 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -44,6 +44,9 @@ struct EphyToolbarsModel
struct EphyToolbarsModelClass
{
EggToolbarsModelClass parent_class;
+
+ void (* action_added) (EggToolbarsModel *group,
+ char *action_name);
};
GType ephy_toolbars_model_get_type (void);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 357c4e84d..8152b0019 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -821,23 +821,9 @@ ephy_window_set_chrome (EphyWindow *window,
gtk_widget_hide (window->priv->menubar);
}
- if (flags & EMBED_CHROME_PERSONALTOOLBARON)
- {
- }
- else
- {
- }
-
- if (flags & EMBED_CHROME_TOOLBARON)
- {
-/* egg_editable_toolbar_show
- (EGG_EDITABLE_TOOLBAR (window->priv->toolbar));*/
- }
- else
- {
-/* egg_editable_toolbar_hide
- (EGG_EDITABLE_TOOLBAR (window->priv->toolbar));*/
- }
+ toolbar_set_visibility (window->priv->toolbar,
+ flags & EMBED_CHROME_TOOLBARON,
+ flags & EMBED_CHROME_PERSONALTOOLBARON);
if (flags & EMBED_CHROME_STATUSBARON)
{
diff --git a/src/toolbar.c b/src/toolbar.c
index 1525edddc..4f4203874 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -35,7 +35,6 @@
#include "ephy-string.h"
#include "ephy-debug.h"
#include "ephy-new-bookmark.h"
-/*#include "egg-toolbars-group.h"*/
#include "ephy-stock-icons.h"
#include <string.h>
@@ -55,6 +54,11 @@ toolbar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
+static GtkTargetEntry drag_targets[] = {
+ { EPHY_DND_TOPIC_TYPE, 0, 0 },
+ { EPHY_DND_BOOKMARK_TYPE, 0, 1 },
+};
+static int n_drag_targets = G_N_ELEMENTS (drag_targets);
enum
{
@@ -115,9 +119,10 @@ go_location_cb (EggAction *action, char *location, EphyWindow *window)
ephy_embed_load_url (embed, location);
}
-/*
+
+
static EggAction *
-get_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id, const char *action_name)
+ensure_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id, const char *action_name)
{
EggAction *action;
@@ -129,43 +134,40 @@ get_bookmark_action (Toolbar *t, EphyBookmarks *bookmarks, gulong id, const char
G_CALLBACK (go_location_cb), t->priv->window);
egg_action_group_add_action (t->priv->action_group, action);
g_object_unref (action);
-
- return action;
}
-static EggAction *
-toolbar_get_action (EggEditableToolbar *etoolbar,
- const char *name)
+static void
+toolbar_ensure_action (Toolbar *t,
+ const char *name)
{
- Toolbar *t = TOOLBAR (etoolbar);
EggAction *action = NULL;
gulong id = 0;
EphyBookmarks *bookmarks;
+ LOG ("Ensure action %s", name)
+
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- if (action)
- {
- return action;
- }
- else if (g_str_has_prefix (name, "GoBookmarkId"))
+ if (g_str_has_prefix (name, "GoBookmarkId"))
{
- LOG ("Create action %s", name)
if (!ephy_str_to_int (name + strlen ("GoBookmarkId"), &id))
{
- return NULL;
+ return;
}
- action = get_bookmark_action (t, bookmarks, id, name);
+ LOG ("Create action %s", name)
+
+ action = ensure_bookmark_action (t, bookmarks, id, name);
}
else if (g_str_has_prefix (name, "GoTopicId"))
{
- LOG ("Create action %s", name)
if (!ephy_str_to_int (name + strlen ("GoTopicId"), &id))
{
- return NULL;
+ return;
}
+ LOG ("Create action %s", name)
+
action = ephy_topic_action_new (name, id);
g_signal_connect (action, "go_location",
G_CALLBACK (go_location_cb),
@@ -173,10 +175,8 @@ toolbar_get_action (EggEditableToolbar *etoolbar,
egg_action_group_add_action (t->priv->action_group, action);
g_object_unref (action);
}
-
- return action;
}
-*/
+
static void
toolbar_class_init (ToolbarClass *klass)
{
@@ -311,8 +311,47 @@ toolbar_setup_actions (Toolbar *t)
}
static void
+action_added_cb (EphyToolbarsModel *model,
+ char *action_name,
+ Toolbar *t)
+{
+ toolbar_ensure_action (t, action_name);
+}
+
+static void
+init_bookmarks_toolbar (Toolbar *t)
+{
+ EphyToolbarsModel *model;
+ int i, n_toolbars;
+
+ model = ephy_shell_get_toolbars_model (ephy_shell);
+ n_toolbars = egg_toolbars_model_n_toolbars
+ (EGG_TOOLBARS_MODEL (model));
+
+ for (i = 0; i < n_toolbars; i++)
+ {
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth
+ (EGG_TOOLBARS_MODEL (model), i);
+ g_return_if_fail (t_name != NULL);
+
+ if (strcmp (t_name, "BookmarksToolbar") == 0)
+ {
+ egg_editable_toolbar_set_drag_dest
+ (EGG_EDITABLE_TOOLBAR (t),
+ drag_targets, n_drag_targets,
+ t_name);
+ }
+ }
+}
+
+static void
toolbar_set_window (Toolbar *t, EphyWindow *window)
{
+ EphyToolbarsModel *model;
+ char *xml_file;
+
g_return_if_fail (t->priv->window == NULL);
t->priv->window = window;
@@ -322,7 +361,32 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
egg_menu_merge_insert_action_group (t->priv->ui_merge,
t->priv->action_group, 1);
- g_object_set (G_OBJECT (t), "MenuMerge", t->priv->ui_merge, NULL);
+ model = ephy_shell_get_toolbars_model (ephy_shell);
+ g_return_if_fail (model != NULL);
+ g_signal_connect_object (model, "action_added",
+ G_CALLBACK (action_added_cb),
+ t, 0);
+
+ xml_file = g_build_filename (ephy_dot_dir (),
+ "toolbar.xml",
+ NULL);
+ if (g_file_test (xml_file, G_FILE_TEST_EXISTS))
+ {
+ egg_toolbars_model_load
+ (EGG_TOOLBARS_MODEL (model), xml_file);
+ }
+ else
+ {
+ egg_toolbars_model_load (EGG_TOOLBARS_MODEL (model),
+ ephy_file ("epiphany-toolbar.xml"));
+ }
+ g_free (xml_file);
+
+ g_object_set (G_OBJECT (t),
+ "ToolbarsModel", model,
+ "MenuMerge", t->priv->ui_merge,
+ NULL);
+ init_bookmarks_toolbar (t);
}
static void
@@ -411,13 +475,8 @@ Toolbar *
toolbar_new (EphyWindow *window)
{
Toolbar *t;
- EphyToolbarsModel *model;
-
- model = ephy_shell_get_toolbars_model (ephy_shell);
- g_return_val_if_fail (model != NULL, NULL);
t = TOOLBAR (g_object_new (TOOLBAR_TYPE,
- "ToolbarsModel", model,
"EphyWindow", window,
NULL));
@@ -558,3 +617,50 @@ toolbar_update_navigation_actions (Toolbar *t, gboolean back, gboolean forward,
g_object_set (action, "sensitive", !up, NULL);
}
+void
+toolbar_set_visibility (Toolbar *t,
+ gboolean normal_toolbars,
+ gboolean bmk_toolbars)
+{
+ EphyToolbarsModel *model;
+ int i, n_toolbars;
+
+ model = ephy_shell_get_toolbars_model (ephy_shell);
+ n_toolbars = egg_toolbars_model_n_toolbars
+ (EGG_TOOLBARS_MODEL (model));
+
+ for (i = 0; i < n_toolbars; i++)
+ {
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth
+ (EGG_TOOLBARS_MODEL (model), i);
+ g_return_if_fail (t_name != NULL);
+ if (strcmp (t_name, "BookmarksToolbar") == 0)
+ {
+ if (bmk_toolbars)
+ {
+ egg_editable_toolbar_show
+ (EGG_EDITABLE_TOOLBAR (t), t_name);
+ }
+ else
+ {
+ egg_editable_toolbar_hide
+ (EGG_EDITABLE_TOOLBAR (t), t_name);
+ }
+ }
+ else
+ {
+ if (normal_toolbars)
+ {
+ egg_editable_toolbar_show
+ (EGG_EDITABLE_TOOLBAR (t), t_name);
+ }
+ else
+ {
+ egg_editable_toolbar_hide
+ (EGG_EDITABLE_TOOLBAR (t), t_name);
+ }
+ }
+ }
+}
diff --git a/src/toolbar.h b/src/toolbar.h
index 9f4404b8a..98d6790a4 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -74,6 +74,10 @@ void toolbar_update_navigation_actions (Toolbar *t,
gboolean forward,
gboolean up);
+void toolbar_set_visibility (Toolbar *t,
+ gboolean normal_toolbars,
+ gboolean bmk_toolbars);
+
G_END_DECLS
#endif
diff --git a/src/window-commands.c b/src/window-commands.c
index 28c2f725b..8e128e775 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -36,7 +36,10 @@
#include "ephy-new-bookmark.h"
#include "egg-toggle-action.h"
#include "egg-editable-toolbar.h"
+#include "egg-toolbar-editor.h"
+#include "ephy-file-helpers.h"
#include "toolbar.h"
+#include "ephy-state.h"
#include <string.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -638,19 +641,41 @@ window_cmd_edit_prefs (EggAction *action,
gtk_widget_show (GTK_WIDGET(dialog));
}
+static void
+toolbar_editor_destroy_cb (GtkWidget *tbe,
+ Toolbar *t)
+{
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (t), FALSE);
+}
+
void
window_cmd_edit_toolbar (EggAction *action,
EphyWindow *window)
{
- Toolbar *toolbar;
+ GtkWidget *editor;
+ EphyToolbarsModel *model;
+ Toolbar *t;
- toolbar = ephy_window_get_toolbar (window);
-/*
- egg_editable_toolbar_edit (EGG_EDITABLE_TOOLBAR (toolbar),
- GTK_WIDGET (window));*/
+ model = ephy_shell_get_toolbars_model (ephy_shell);
+ t = ephy_window_get_toolbar (window);
+
+ editor = egg_toolbar_editor_new
+ (EGG_MENU_MERGE (window->ui_merge),
+ EGG_TOOLBARS_MODEL (model));
+ ephy_state_add_window (editor,
+ "toolbar_editor",
+ 500, 330);
+ g_signal_connect (editor, "destroy",
+ G_CALLBACK (toolbar_editor_destroy_cb),
+ t);
+ egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
+ ephy_file ("epiphany-toolbar.xml"));
+ gtk_widget_show (editor);
+
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (t), TRUE);
}
-void
+void
window_cmd_help_contents (EggAction *action,
EphyWindow *window)
{