aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog215
-rw-r--r--data/ui/Makefile.am1
-rw-r--r--data/ui/epiphany-fs-toolbar.xml5
-rw-r--r--data/ui/epiphany-toolbar.xml8
-rw-r--r--embed/mozilla/Makefile.am1
-rwxr-xr-xlib/egg/egg-editable-toolbar.c186
-rwxr-xr-xlib/egg/egg-editable-toolbar.h3
-rwxr-xr-xlib/egg/egg-toolbars-model.c70
-rwxr-xr-xlib/egg/egg-toolbars-model.h27
-rw-r--r--lib/egg/eggmarshalers.c82
-rw-r--r--lib/egg/eggmarshalers.h16
-rw-r--r--lib/egg/eggmarshalers.list2
-rw-r--r--src/Makefile.am1
-rw-r--r--src/bookmarks/Makefile.am4
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c14
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c43
-rw-r--r--src/bookmarks/ephy-bookmarks.c115
-rw-r--r--src/bookmarks/ephy-bookmarks.h114
-rwxr-xr-xsrc/bookmarks/ephy-bookmarksbar-model.c114
-rwxr-xr-xsrc/bookmarks/ephy-bookmarksbar-model.h26
-rw-r--r--src/bookmarks/ephy-bookmarksbar.c60
-rw-r--r--src/ephy-shell.c29
-rw-r--r--src/ephy-shell.h7
-rwxr-xr-xsrc/ephy-toolbars-model.c551
-rwxr-xr-xsrc/ephy-toolbars-model.h29
-rw-r--r--src/ephy-window.c95
-rw-r--r--src/ephy-window.h2
-rwxr-xr-xsrc/toolbar.c407
-rw-r--r--src/toolbar.h8
-rw-r--r--src/window-commands.c42
30 files changed, 1121 insertions, 1156 deletions
diff --git a/ChangeLog b/ChangeLog
index da42bfcbf..041b45789 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,218 @@
+2004-06-10 Christian Persch <chpe@cvs.gnome.org>
+
+ Merging bookmarksbar-separation branch.
+
+2004-06-09 Marco Pesenti Gritti <marco@gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c: (drag_data_get_cb),
+ (set_item_drag_source):
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml),
+ (impl_get_item_id), (impl_get_item_data),
+ (egg_toolbars_model_class_init),
+ (egg_toolbars_model_get_item_data):
+ * lib/egg/egg-toolbars-model.h:
+ * src/ephy-toolbars-model.c: (impl_get_item_data),
+ (impl_get_item_id), (ephy_toolbars_model_class_init):
+
+ s/get_item_name/get_item_data
+
+ Do not assume data isnt changing, use the id
+ and convert later instead.
+
+2004-06-09 Marco Pesenti Gritti <marco@gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c: (drag_data_get_cb),
+ (set_item_drag_source), (create_item_from_action), (create_item),
+ (drag_data_received_cb), (egg_editable_toolbar_set_edit_mode):
+ * lib/egg/egg-toolbar-editor.c: (model_has_action):
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_item_nth):
+ * lib/egg/egg-toolbars-model.h:
+ * src/ephy-toolbars-model.c: (get_toolbar_and_item_pos),
+ (ephy_toolbars_model_class_init), (item_added):
+
+ Retain custom types when moving items around
+
+2004-06-10 Marco Pesenti Gritti <marco@gnome.org>
+
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ (toolbar_items_changed_cb), (cmd_show_in_bookmarks_bar),
+
+ Block the signal when removing bookmarks from toolbars.
+
+ (ephy_bookmarks_editor_get_property):
+ * src/bookmarks/ephy-bookmarksbar-model.c:
+ (ephy_bookmarksbar_model_remove_bookmark):
+
+ Remove all copy of a bookmark from toolbar, not just one
+ of them.
+
+2004-06-10 Christian Persch <chpe@cvs.gnome.org>
+
+ * src/bookmarks/ephy-bookmarksbar-model.c:
+ (ephy_bookmarksbar_model_finalize):
+ * src/ephy-toolbars-model.c: (ephy_toolbars_model_finalize):
+
+ Save models on exit.
+
+2004-06-10 Marco Pesenti Gritti <marco@gnome.org>
+
+ * src/bookmarks/ephy-bookmarksbar-model.c: (item_added_cb):
+ * src/bookmarks/ephy-bookmarksbar.c: (remove_action_from_model),
+ (bookmark_destroy_cb), (ephy_bookmarksbar_action_request):
+
+ Cleanup the toolbars model when destroying a bookmark
+ action. Remove the cleanup code from the model.
+
+2004-06-10 Marco Pesenti Gritti <marco@gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c: (toolbar_drag_motion_cb),
+ (egg_editable_toolbar_get_model):
+ * lib/egg/egg-editable-toolbar.h:
+ * lib/egg/egg-toolbars-model.h:
+
+ Add a getter for the model.
+ Add a flag to accept only tool items as source.
+
+ * src/bookmarks/ephy-bookmarksbar.c:
+ * src/ephy-toolbars-model.c: (update_flags_and_save_changes):
+ * src/toolbar.c: (toolbar_added_cb), (toolbar_realize),
+ (toolbar_unrealize), (toolbar_class_init), (toolbar_finalize):
+
+ Fixup dnd targets and use the new flag for main toolbar.
+
+2004-06-10 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_class_init):
+ * src/bookmarks/ephy-bookmarks.c: (get_item_type_forward_cb),
+ (get_item_id_forward_cb), (get_item_data_forward_cb),
+ (ephy_bookmarks_get_toolbars_model):
+ * src/ephy-shell.c: (ephy_shell_get_toolbars_model):
+ * src/ephy-toolbars-model.c: (ephy_toolbars_model_load),
+ (ephy_toolbars_model_init):
+ * src/ephy-toolbars-model.h:
+
+ Forward get_item_[type|id|data] from toolbars model to
+ bookmarksbar model. That way we can have bookmarks/topics also
+ on the main toolbar.
+
+2004-06-10 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/egg/egg-toolbars-model.c: (_egg_accumulator_STRING),
+ (egg_toolbars_model_class_init), (egg_toolbars_model_get_item_id),
+ (egg_toolbars_model_get_item_data),
+ (egg_toolbars_model_get_item_type):
+ * lib/egg/egg-toolbars-model.h:
+ * lib/egg/eggmarshalers.c:
+ (_egg_marshal_BOOLEAN__OBJECT_STRING_STRING),
+ (_egg_marshal_STRING__POINTER),
+ (_egg_marshal_STRING__STRING_STRING):
+ * lib/egg/eggmarshalers.h:
+ * lib/egg/eggmarshalers.list:
+
+ Make get_item_[type|id|data] signals.
+
+2004-06-08 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c: (find_action), (create_item),
+ (egg_editable_toolbar_construct), (egg_editable_toolbar_realize),
+ (egg_editable_toolbar_unrealize), (egg_editable_toolbar_set_model),
+ (egg_editable_toolbar_set_merge),
+ (egg_editable_toolbar_set_property),
+ (egg_editable_toolbar_get_property),
+ (egg_editable_toolbar_class_init), (egg_editable_toolbar_init),
+ (egg_editable_toolbar_set_edit_mode):
+ * lib/egg/egg-editable-toolbar.h:
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_load),
+ (egg_toolbars_model_init):
+
+ Only construct the toolbar on realize. When setting a different model,
+ unrealize the toolbar. Connect to model only while realized, fixes
+ crashes when setting flags on the toolbars model.
+
+ * data/ui/epiphany-bookmarksbar.xml:
+ * data/ui/epiphany-fs-toolbar.xml:
+ * data/ui/epiphany-toolbar.xml:
+
+ Separated. Fix root name to be "toolbars" which is the name we
+ save the model with.
+
+ * src/bookmarks/ephy-bookmarksbar-model.c:
+ (ephy_bookmarksbar_model_get_type), (get_toolbar_and_item_pos),
+ (get_toolbar_pos), (ephy_bookmarksbar_model_get_action_name),
+ (ephy_bookmarksbar_model_get_node),
+ (ephy_bookmarksbar_model_add_bookmark),
+ (ephy_bookmarksbar_model_remove_bookmark),
+ (ephy_bookmarksbar_model_has_bookmark), (save_changes_idle),
+ (save_changes), (update_flags_and_save_changes),
+ (bookmark_destroy_cb), (item_added_cb), (impl_add_item),
+ (impl_get_item_id), (impl_get_item_type), (load_toolbars),
+ (ephy_bookmarksbar_model_init), (ephy_bookmarksbar_model_finalize),
+ (ephy_bookmarksbar_model_set_property),
+ (ephy_bookmarksbar_model_get_property),
+ (ephy_bookmarksbar_model_class_init),
+ (ephy_bookmarksbar_model_new):
+ * src/bookmarks/ephy-bookmarksbar-model.h:
+ * src/ephy-toolbars-model.c: (save_changes_idle), (save_changes),
+ (update_flags_and_save_changes), (get_toolbar_pos),
+ (load_toolbars), (ephy_toolbars_model_init),
+ (ephy_toolbars_model_finalize), (ephy_toolbars_model_class_init),
+ (ephy_toolbars_model_new):
+ * src/ephy-toolbars-model.h:
+
+ Split toolbars model in bookmarks and non-bookmarks parts.
+
+ * src/bookmarks/ephy-bookmarksbar.c: (ephy_bookmarksbar_get_type),
+ (go_location_cb), (bookmark_destroy_cb),
+ (ephy_bookmarksbar_action_request), (toolbar_added_cb),
+ (ephy_bookmarksbar_set_window), (ephy_bookmarksbar_realize),
+ (ephy_bookmarksbar_unrealize), (ephy_bookmarksbar_init),
+ (ephy_bookmarksbar_finalize), (ephy_bookmarksbar_set_property),
+ (ephy_bookmarksbar_get_property), (ephy_bookmarksbar_class_init),
+ (ephy_bookmarksbar_new):
+ * src/bookmarks/ephy-bookmarksbar.h:
+ * src/toolbar.c: (go_location_cb), (toolbar_set_property),
+ (toolbar_get_property), (toolbar_class_init), (toolbar_set_window),
+ (toolbar_init), (toolbar_new), (toolbar_set_location),
+ (toolbar_update_navigation_actions):
+ * src/toolbar.h:
+ * src/ephy-window.c: (get_chromes_visibility),
+ (sync_chromes_visibility), (ephy_window_fullscreen),
+ (ephy_window_unfullscreen), (action_request_forward_cb),
+ (ephy_window_init), (ephy_window_get_toolbar),
+ (ephy_window_get_bookmarksbar):
+ * src/ephy-window.h:
+ * src/window-commands.c: (window_cmd_view_fullscreen),
+ (toolbar_editor_destroy_cb), (toolbar_editor_response_cb),
+ (window_cmd_edit_toolbar):
+
+ Split toolbars in bookmarks and non-bookmarks toolbars.
+
+ * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init_defaults),
+ (ephy_bookmarks_get_toolbars_model), (ephy_bookmarks_set_property),
+ (ephy_bookmarks_get_property), (ephy_bookmarks_class_init),
+ (ephy_bookmarks_finalize):
+ * src/bookmarks/ephy-bookmarks.h:
+ * src/ephy-shell.c: (ephy_shell_get_toolbars_model):
+ * src/ephy-shell.h:
+
+ Made bookmarksbar toolbars model a service of EphyBookmarks.
+
+ * src/bookmarks/ephy-bookmark-properties.c:
+ (ephy_bookmark_properties_set_property),
+ (toolbar_checkbox_changed_cb), (build_ui),
+ (ephy_bookmark_properties_init):
+ * src/bookmarks/ephy-bookmarks-editor.c:
+ (cmd_show_in_bookmarks_bar), (ephy_bookmarks_editor_update_menu),
+ (toolbar_items_changed_cb), (ephy_bookmarks_editor_init):
+
+ Adapt to changes above.
+
+ * data/ui/Makefile.am:
+ * src/Makefile.am:
+ * src/bookmarks/Makefile.am:
+
+ Makefile changes.
+
2004-06-09 Christian Persch <chpe@cvs.gnome.org>
* data/default-prefs.js:
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index f834511cd..4fd9a45f2 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -1,5 +1,6 @@
xmldir = $(pkgdatadir)
xml_DATA = \
+ epiphany-bookmarksbar.xml \
epiphany-fs-toolbar.xml \
epiphany-bookmark-editor-ui.xml \
epiphany-ui.xml \
diff --git a/data/ui/epiphany-fs-toolbar.xml b/data/ui/epiphany-fs-toolbar.xml
index 2eec09e81..daca39b1f 100644
--- a/data/ui/epiphany-fs-toolbar.xml
+++ b/data/ui/epiphany-fs-toolbar.xml
@@ -1,4 +1,5 @@
-<editabletoolbar>
+<?xml version="1.0"?>
+<toolbars version="1.0">
<toolbar name="Toolbar" style="icons-only">
<toolitem name="NavigationBack"/>
<toolitem name="NavigationForward"/>
@@ -7,4 +8,4 @@
<toolitem name="Location"/>
<toolitem name="Spinner"/>
</toolbar>
-</editabletoolbar>
+</toolbars>
diff --git a/data/ui/epiphany-toolbar.xml b/data/ui/epiphany-toolbar.xml
index 030f2e987..b1cb0f73d 100644
--- a/data/ui/epiphany-toolbar.xml
+++ b/data/ui/epiphany-toolbar.xml
@@ -1,4 +1,5 @@
-<editabletoolbar>
+<?xml version="1.0"?>
+<toolbars version="1.0">
<available>
<toolitem name="NavigationBack"/>
<toolitem name="NavigationForward"/>
@@ -38,7 +39,4 @@
<toolitem name="Location"/>
<toolitem name="ToolbarGo"/>
</toolbar>
-<toolbar name="BookmarksBar">
-</toolbar>
-</editabletoolbar>
-
+</toolbars>
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 17824d88a..a2f7f8238 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -19,6 +19,7 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT)/mimetype \
-I$(MOZILLA_INCLUDE_ROOT)/necko \
-I$(MOZILLA_INCLUDE_ROOT)/nkcache \
+ -I$(MOZILLA_INCLUDE_ROOT)/pipboot \
-I$(MOZILLA_INCLUDE_ROOT)/pipnss \
-I$(MOZILLA_INCLUDE_ROOT)/shistory \
-I$(MOZILLA_INCLUDE_ROOT)/uriloader \
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 572068877..649935b1b 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -177,7 +177,6 @@ find_action (EggEditableToolbar *t,
l = gtk_ui_manager_get_action_groups (t->priv->merge);
- g_return_val_if_fail (EGG_IS_EDITABLE_TOOLBAR (t), NULL);
g_return_val_if_fail (name != NULL, NULL);
for (; l != NULL; l = l->next)
@@ -365,6 +364,8 @@ create_item_from_action (EggEditableToolbar *t,
}
else
{
+ g_return_val_if_fail (action_name != NULL, NULL);
+
g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
0, action_name);
@@ -600,6 +601,24 @@ toolbar_drag_motion_cb (GtkWidget *widget,
int index;
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolItem *item;
+ GtkWidget *source;
+
+ source = gtk_drag_get_source_widget (context);
+ if (source)
+ {
+ EggTbModelFlags flags;
+ int pos;
+
+ pos = get_toolbar_position (etoolbar, widget);
+ flags = egg_toolbars_model_get_flags (etoolbar->priv->model, pos);
+
+ if ((flags & EGG_TB_MODEL_ACCEPT_ITEMS_ONLY) &&
+ !GTK_IS_TOOL_ITEM (source))
+ {
+ gdk_drag_status (context, 0, time);
+ return FALSE;
+ }
+ }
target = gtk_drag_dest_find_target (widget, context, NULL);
if (target == GDK_NONE)
@@ -864,33 +883,13 @@ item_removed_cb (EggToolbarsModel *model,
}
static void
-toolbars_clean (EggEditableToolbar *t)
-{
- GList *children, *l;
-
- if (t->priv->fixed_toolbar)
- {
- unset_fixed_style (t);
- unparent_fixed (t);
- }
-
- children = gtk_container_get_children (GTK_CONTAINER (t));
-
- for (l = children; l != NULL; l = l->next)
- {
- gtk_widget_destroy (GTK_WIDGET (l->data));
- }
-
- g_list_free (children);
-}
-
-static void
egg_editable_toolbar_construct (EggEditableToolbar *t)
{
int i, l, n_items, n_toolbars;
EggToolbarsModel *model = t->priv->model;
g_return_if_fail (model != NULL);
+ g_return_if_fail (t->priv->merge != NULL);
n_toolbars = egg_toolbars_model_n_toolbars (model);
@@ -944,74 +943,108 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
}
}
- update_fixed (t);
+ update_fixed (t);
}
static void
-egg_editable_toolbar_set_model (EggEditableToolbar *t,
- EggToolbarsModel *model)
+egg_editable_toolbar_realize (GtkWidget *widget)
{
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
- g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (t));
+ EggEditableToolbar *toolbar = EGG_EDITABLE_TOOLBAR (widget);
+ EggToolbarsModel *model = toolbar->priv->model;
- if (t->priv->model == model) return;
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
- if (t->priv->model)
+ g_return_if_fail (model != NULL);
+
+ egg_editable_toolbar_construct (toolbar);
+
+ g_signal_connect (model, "item_added",
+ G_CALLBACK (item_added_cb), toolbar);
+ g_signal_connect (model, "item_removed",
+ G_CALLBACK (item_removed_cb), toolbar);
+ g_signal_connect (model, "toolbar_added",
+ G_CALLBACK (toolbar_added_cb), toolbar);
+ g_signal_connect (model, "toolbar_removed",
+ G_CALLBACK (toolbar_removed_cb), toolbar);
+ g_signal_connect (model, "toolbar_changed",
+ G_CALLBACK (toolbar_changed_cb), toolbar);
+}
+
+static void
+egg_editable_toolbar_unrealize (GtkWidget *widget)
+{
+ EggEditableToolbar *toolbar = EGG_EDITABLE_TOOLBAR (widget);
+ EggToolbarsModel *model = toolbar->priv->model;
+ GList *children, *l;
+
+ g_return_if_fail (model != NULL);
+
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (item_added_cb), toolbar);
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (item_removed_cb), toolbar);
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (toolbar_added_cb), toolbar);
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (toolbar_removed_cb), toolbar);
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (toolbar_changed_cb), toolbar);
+
+ if (toolbar->priv->fixed_toolbar)
{
- g_signal_handlers_disconnect_by_func
- (t->priv->model, G_CALLBACK (item_added_cb), t);
- g_signal_handlers_disconnect_by_func
- (t->priv->model, G_CALLBACK (item_removed_cb), t);
- g_signal_handlers_disconnect_by_func
- (t->priv->model, G_CALLBACK (toolbar_added_cb), t);
- g_signal_handlers_disconnect_by_func
- (t->priv->model, G_CALLBACK (toolbar_removed_cb), t);
- g_signal_handlers_disconnect_by_func
- (t->priv->model, G_CALLBACK (toolbar_changed_cb), t);
-
- g_object_unref (t->priv->model);
+ unset_fixed_style (toolbar);
+ unparent_fixed (toolbar);
}
- t->priv->model = g_object_ref (model);
+ children = gtk_container_get_children (GTK_CONTAINER (toolbar));
- toolbars_clean (t);
- if (t->priv->merge != NULL)
+ for (l = children; l != NULL; l = l->next)
{
- egg_editable_toolbar_construct (t);
+ gtk_widget_destroy (GTK_WIDGET (l->data));
}
- g_signal_connect_object (model, "item_added",
- G_CALLBACK (item_added_cb), t, 0);
- g_signal_connect_object (model, "item_removed",
- G_CALLBACK (item_removed_cb), t, 0);
- g_signal_connect_object (model, "toolbar_added",
- G_CALLBACK (toolbar_added_cb), t, 0);
- g_signal_connect_object (model, "toolbar_removed",
- G_CALLBACK (toolbar_removed_cb), t, 0);
- g_signal_connect_object (model, "toolbar_changed",
- G_CALLBACK (toolbar_changed_cb), t, 0);
+ g_list_free (children);
+
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
-egg_editable_toolbar_set_merge (EggEditableToolbar *t,
- GtkUIManager *merge)
+egg_editable_toolbar_set_model (EggEditableToolbar *toolbar,
+ EggToolbarsModel *model)
{
- g_return_if_fail (GTK_IS_UI_MANAGER (merge));
- g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (t));
+ GtkWidget *widget = GTK_WIDGET (toolbar);
- if (t->priv->merge == merge) return;
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
+ g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar));
- if (t->priv->merge)
+ if (toolbar->priv->model == model) return;
+
+ if (GTK_WIDGET_VISIBLE (widget))
{
- g_object_unref (t->priv->merge);
+ gtk_widget_hide (widget);
}
- t->priv->merge = g_object_ref (merge);
+ if(GTK_WIDGET_REALIZED (widget))
+ {
+ gtk_widget_unrealize (widget);
+ }
- if (t->priv->model != NULL)
+ if (toolbar->priv->model)
{
- egg_editable_toolbar_construct (t);
+ g_object_unref (toolbar->priv->model);
}
+
+ toolbar->priv->model = g_object_ref (model);
+}
+
+static void
+egg_editable_toolbar_set_merge (EggEditableToolbar *t,
+ GtkUIManager *merge)
+{
+ g_return_if_fail (GTK_IS_UI_MANAGER (merge));
+ g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (t));
+
+ t->priv->merge = g_object_ref (merge);
}
static void
@@ -1030,6 +1063,9 @@ egg_editable_toolbar_set_property (GObject *object,
case PROP_TOOLBARS_MODEL:
egg_editable_toolbar_set_model (t, g_value_get_object (value));
break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -1049,6 +1085,9 @@ egg_editable_toolbar_get_property (GObject *object,
case PROP_TOOLBARS_MODEL:
g_value_set_object (value, t->priv->model);
break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -1056,6 +1095,7 @@ static void
egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -1063,6 +1103,9 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
object_class->set_property = egg_editable_toolbar_set_property;
object_class->get_property = egg_editable_toolbar_get_property;
+ widget_class->realize = egg_editable_toolbar_realize;
+ widget_class->unrealize = egg_editable_toolbar_unrealize;
+
egg_editable_toolbar_signals[ACTION_REQUEST] =
g_signal_new ("action_request",
G_OBJECT_CLASS_TYPE (object_class),
@@ -1093,10 +1136,6 @@ static void
egg_editable_toolbar_init (EggEditableToolbar *t)
{
t->priv = EGG_EDITABLE_TOOLBAR_GET_PRIVATE (t);
-
- t->priv->merge = NULL;
- t->priv->edit_mode = FALSE;
- t->priv->dragged_item = NULL;
}
static void
@@ -1158,7 +1197,7 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
GtkToolItem *item;
const char *action_name, *type;
gboolean is_separator;
- GtkAction *action;
+ GtkAction *action = NULL;
egg_toolbars_model_item_nth (etoolbar->priv->model, i, l,
&is_separator, &action_name, &type);
@@ -1416,3 +1455,10 @@ _egg_editable_toolbar_new_separator_image (void)
return image;
}
+
+EggToolbarsModel *
+egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar)
+{
+ return etoolbar->priv->model;
+}
+
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index c946472bd..0e5b72cd9 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -54,12 +54,13 @@ struct EggEditableToolbarClass
GtkVBoxClass parent_class;
void (* action_request) (EggEditableToolbar *etoolbar,
- char *action_name);
+ const char *action_name);
};
GType egg_editable_toolbar_get_type (void);
GtkWidget *egg_editable_toolbar_new (GtkUIManager *merge,
EggToolbarsModel *model);
+EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar);
void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
gboolean mode);
gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar);
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 3949e54d9..c4ed3217e 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -35,6 +35,9 @@ enum
TOOLBAR_ADDED,
TOOLBAR_CHANGED,
TOOLBAR_REMOVED,
+ GET_ITEM_TYPE,
+ GET_ITEM_ID,
+ GET_ITEM_DATA,
LAST_SIGNAL
};
@@ -442,6 +445,8 @@ egg_toolbars_model_load (EggToolbarsModel *t,
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
+ if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
+
doc = xmlParseFile (xml_file);
if (doc == NULL)
{
@@ -450,7 +455,6 @@ egg_toolbars_model_load (EggToolbarsModel *t,
}
root = xmlDocGetRootElement (doc);
- t->priv->toolbars = g_node_new (NULL);
parse_toolbars (t, root->children);
xmlFreeDoc (doc);
@@ -496,6 +500,23 @@ impl_get_item_type (EggToolbarsModel *t,
return NULL;
}
+static gboolean
+_egg_accumulator_STRING (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ gboolean continue_emission;
+ const char *retval;
+
+ retval = g_value_get_string (handler_return);
+ g_value_set_string (return_accu, retval);
+ continue_emission = !retval || !retval[0];
+
+ return continue_emission;
+}
+
+
static void
egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
{
@@ -545,6 +566,30 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
+ egg_toolbars_model_signals[GET_ITEM_TYPE] =
+ g_signal_new ("get_item_type",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_type),
+ _egg_accumulator_STRING, NULL,
+ _egg_marshal_STRING__POINTER,
+ G_TYPE_STRING, 1, G_TYPE_POINTER);
+ egg_toolbars_model_signals[GET_ITEM_ID] =
+ g_signal_new ("get_item_id",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_id),
+ _egg_accumulator_STRING, NULL,
+ _egg_marshal_STRING__STRING_STRING,
+ G_TYPE_STRING, 2, G_TYPE_STRING, G_TYPE_STRING);
+ egg_toolbars_model_signals[GET_ITEM_DATA] =
+ g_signal_new ("get_item_data",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_data),
+ _egg_accumulator_STRING, NULL,
+ _egg_marshal_STRING__STRING_STRING,
+ G_TYPE_STRING, 2, G_TYPE_STRING, G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (EggToolbarsModelPrivate));
}
@@ -554,7 +599,7 @@ egg_toolbars_model_init (EggToolbarsModel *t)
{
t->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (t);
- t->priv->toolbars = NULL;
+ t->priv->toolbars = g_node_new (NULL);
}
static void
@@ -702,8 +747,11 @@ egg_toolbars_model_get_item_id (EggToolbarsModel *t,
const char *type,
const char *name)
{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_id (t, type, name);
+ char *retval;
+
+ g_signal_emit (t, egg_toolbars_model_signals[GET_ITEM_ID], 0, type, name, &retval);
+
+ return retval;
}
char *
@@ -711,14 +759,20 @@ egg_toolbars_model_get_item_data (EggToolbarsModel *t,
const char *type,
const char *id)
{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_data (t, type, id);
+ char *retval;
+
+ g_signal_emit (t, egg_toolbars_model_signals[GET_ITEM_DATA], 0, type, id, &retval);
+
+ return retval;
}
char *
egg_toolbars_model_get_item_type (EggToolbarsModel *t,
GdkAtom type)
{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_type (t, type);
+ char *retval;
+
+ g_signal_emit (t, egg_toolbars_model_signals[GET_ITEM_TYPE], 0, type, &retval);
+
+ return retval;
}
diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h
index f9ca2105c..565b9ae01 100755
--- a/lib/egg/egg-toolbars-model.h
+++ b/lib/egg/egg-toolbars-model.h
@@ -41,11 +41,12 @@ typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
typedef enum
{
- EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
- EGG_TB_MODEL_ICONS_ONLY = 1 << 1,
- EGG_TB_MODEL_TEXT_ONLY = 1 << 2,
- EGG_TB_MODEL_ICONS_TEXT = 1 << 3,
- EGG_TB_MODEL_ICONS_TEXT_HORIZ = 1 << 4,
+ EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
+ EGG_TB_MODEL_ICONS_ONLY = 1 << 1,
+ EGG_TB_MODEL_TEXT_ONLY = 1 << 2,
+ EGG_TB_MODEL_ICONS_TEXT = 1 << 3,
+ EGG_TB_MODEL_ICONS_TEXT_HORIZ = 1 << 4,
+ EGG_TB_MODEL_ACCEPT_ITEMS_ONLY = 1 << 5
} EggTbModelFlags;
struct EggToolbarsModel
@@ -73,6 +74,14 @@ struct EggToolbarsModelClass
int position);
void (* toolbar_removed) (EggToolbarsModel *group,
int position);
+ char * (* get_item_type) (EggToolbarsModel *model,
+ GdkAtom dnd_type);
+ char * (* get_item_id) (EggToolbarsModel *model,
+ const char *type,
+ const char *data);
+ char * (* get_item_data) (EggToolbarsModel *model,
+ const char *type,
+ const char *id);
/* Virtual Table */
gboolean (* add_item) (EggToolbarsModel *t,
@@ -80,14 +89,6 @@ struct EggToolbarsModelClass
int position,
const char *id,
const char *type);
- char * (* get_item_type) (EggToolbarsModel *t,
- GdkAtom dnd_type);
- char * (* get_item_id) (EggToolbarsModel *t,
- const char *type,
- const char *data);
- char * (* get_item_data) (EggToolbarsModel *t,
- const char *type,
- const char *id);
};
GType egg_toolbars_model_get_type (void);
diff --git a/lib/egg/eggmarshalers.c b/lib/egg/eggmarshalers.c
index f2749951d..1d336db0e 100644
--- a/lib/egg/eggmarshalers.c
+++ b/lib/egg/eggmarshalers.c
@@ -1,4 +1,4 @@
-#include "eggmarshalers.h"
+
#include <glib-object.h>
@@ -556,3 +556,83 @@ _egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure,
g_value_set_boolean (return_value, v_return);
}
+/* STRING:POINTER (eggmarshalers.list:18) */
+void
+_egg_marshal_STRING__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gchar* (*GMarshalFunc_STRING__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_STRING__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gchar* v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_STRING__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_take_string (return_value, v_return);
+}
+
+/* STRING:STRING,STRING (eggmarshalers.list:19) */
+void
+_egg_marshal_STRING__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gchar* (*GMarshalFunc_STRING__STRING_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_STRING__STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gchar* v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_STRING__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+
+ g_value_take_string (return_value, v_return);
+}
+
diff --git a/lib/egg/eggmarshalers.h b/lib/egg/eggmarshalers.h
index c375dbc04..af720ee2b 100644
--- a/lib/egg/eggmarshalers.h
+++ b/lib/egg/eggmarshalers.h
@@ -121,6 +121,22 @@ extern void _egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
+/* STRING:POINTER (eggmarshalers.list:18) */
+extern void _egg_marshal_STRING__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* STRING:STRING,STRING (eggmarshalers.list:19) */
+extern void _egg_marshal_STRING__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
G_END_DECLS
#endif /* ___egg_marshal_MARSHAL_H__ */
diff --git a/lib/egg/eggmarshalers.list b/lib/egg/eggmarshalers.list
index d443ca7cd..7b79b0f3a 100644
--- a/lib/egg/eggmarshalers.list
+++ b/lib/egg/eggmarshalers.list
@@ -15,3 +15,5 @@ VOID:OBJECT,ENUM,BOXED
VOID:BOXED
BOOLEAN:BOOLEAN
BOOLEAN:OBJECT,STRING,STRING
+STRING:POINTER
+STRING:STRING,STRING
diff --git a/src/Makefile.am b/src/Makefile.am
index 906a6a579..3c765c7cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,7 +94,6 @@ libephymain_la_SOURCES = \
ephy-tab.h \
ephy-tabs-menu.c \
ephy-toolbars-model.c \
- ephy-toolbars-model.h \
ephy-window.c \
pdm-dialog.c \
popup-commands.c \
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
index 104254cbf..3b2b130ae 100644
--- a/src/bookmarks/Makefile.am
+++ b/src/bookmarks/Makefile.am
@@ -29,6 +29,8 @@ NOINST_H_FILES = \
ephy-bookmarks-export.h \
ephy-bookmarks-import.h \
ephy-bookmarks-menu.h \
+ ephy-bookmarksbar-model.h \
+ ephy-bookmarksbar.h \
ephy-bookmark-properties.h \
ephy-new-bookmark.h \
ephy-topic-action.h \
@@ -41,6 +43,8 @@ libephybookmarks_la_SOURCES = \
ephy-bookmarks-export.c \
ephy-bookmarks-import.c \
ephy-bookmarks-menu.c \
+ ephy-bookmarksbar-model.c \
+ ephy-bookmarksbar.c \
ephy-bookmark-properties.c \
ephy-new-bookmark.c \
ephy-topic-action.c \
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 2b6325add..f984124b8 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -22,7 +22,7 @@
#include "config.h"
#endif
-#include "ephy-toolbars-model.h"
+#include "ephy-bookmarksbar-model.h"
#include "ephy-bookmark-properties.h"
#include "ephy-topics-selector.h"
#include "ephy-debug.h"
@@ -64,7 +64,7 @@ struct EphyBookmarkPropertiesPrivate
GtkWidget *location_entry;
GtkWidget *topics_selector;
- EphyToolbarsModel *tb_model;
+ EphyBookmarksBarModel *tb_model;
};
enum
@@ -155,6 +155,8 @@ ephy_bookmark_properties_set_property (GObject *object,
{
case PROP_BOOKMARKS:
selector->priv->bookmarks = g_value_get_object (value);
+ selector->priv->tb_model = EPHY_BOOKMARKSBAR_MODEL
+ (ephy_bookmarks_get_toolbars_model (selector->priv->bookmarks));
break;
case PROP_BOOKMARK:
ephy_bookmark_properties_set_bookmark
@@ -260,12 +262,12 @@ toolbar_checkbox_changed_cb (GtkWidget *checkbox, EphyBookmarkProperties *props)
if (state)
{
- ephy_toolbars_model_add_bookmark
+ ephy_bookmarksbar_model_add_bookmark
(props->priv->tb_model, FALSE, id);
}
else
{
- ephy_toolbars_model_remove_bookmark
+ ephy_bookmarksbar_model_remove_bookmark
(props->priv->tb_model, id);
}
}
@@ -402,7 +404,7 @@ build_ui (EphyBookmarkProperties *editor)
checkbox = gtk_check_button_new_with_mnemonic (_("_Show in bookmarks bar"));
id = ephy_node_get_id (editor->priv->bookmark);
- state = ephy_toolbars_model_has_bookmark (editor->priv->tb_model, id);
+ state = ephy_bookmarksbar_model_has_bookmark (editor->priv->tb_model, id);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), state);
g_signal_connect (checkbox, "toggled",
G_CALLBACK (toolbar_checkbox_changed_cb), editor);
@@ -427,8 +429,6 @@ ephy_bookmark_properties_init (EphyBookmarkProperties *editor)
editor->priv = EPHY_BOOKMARK_PROPERTIES_GET_PRIVATE (editor);
editor->priv->bookmark = NULL;
- editor->priv->tb_model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
}
GtkWidget *
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 5a8b71976..0cc0158a0 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003 Marco Pesenti Gritti <mpeseng@tin.it>
+ * Copyright (C) 2003, 2004 Marco Pesenti Gritti <mpeseng@tin.it>
*
* 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
@@ -56,7 +56,7 @@
#include "ephy-gui.h"
#include "ephy-stock-icons.h"
#include "ephy-search-entry.h"
-#include "ephy-toolbars-model.h"
+#include "ephy-bookmarksbar-model.h"
#include "ephy-favicon-cache.h"
#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
@@ -141,7 +141,7 @@ struct EphyBookmarksEditorPrivate
GtkUIManager *ui_merge;
GtkActionGroup *action_group;
int priority_col;
- EphyToolbarsModel *tb_model;
+ EphyBookmarksBarModel *tb_model;
GHashTable *props_dialogs;
GtkTreeViewColumn *title_col;
@@ -322,6 +322,15 @@ get_target_window (EphyBookmarksEditor *editor)
}
static void
+toolbar_items_changed_cb (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ EphyBookmarksEditor *editor)
+{
+ ephy_bookmarks_editor_update_menu (editor);
+}
+
+static void
cmd_show_in_bookmarks_bar (GtkAction *action,
EphyBookmarksEditor *editor)
{
@@ -353,13 +362,19 @@ cmd_show_in_bookmarks_bar (GtkAction *action,
if (state)
{
- ephy_toolbars_model_add_bookmark
+ ephy_bookmarksbar_model_add_bookmark
(editor->priv->tb_model, topic, id);
}
else
{
- ephy_toolbars_model_remove_bookmark
+ g_signal_handlers_block_by_func
+ (editor->priv->tb_model,
+ G_CALLBACK (toolbar_items_changed_cb), editor);
+ ephy_bookmarksbar_model_remove_bookmark
(editor->priv->tb_model, id);
+ g_signal_handlers_unblock_by_func
+ (editor->priv->tb_model,
+ G_CALLBACK (toolbar_items_changed_cb), editor);
}
g_list_free (selection);
@@ -981,7 +996,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
gulong id;
id = ephy_node_get_id (node);
- show_in_bookmarks_bar = ephy_toolbars_model_has_bookmark
+ show_in_bookmarks_bar = ephy_bookmarksbar_model_has_bookmark
(editor->priv->tb_model, id);
priority = ephy_node_get_property_int
@@ -1001,7 +1016,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
g_return_if_fail (node != NULL);
id = ephy_node_get_id (node);
- show_in_bookmarks_bar = ephy_toolbars_model_has_bookmark
+ show_in_bookmarks_bar = ephy_bookmarksbar_model_has_bookmark
(editor->priv->tb_model, id);
g_list_free (selected);
@@ -1653,23 +1668,15 @@ ephy_bookmarks_editor_get_property (GObject *object,
}
static void
-toolbar_items_changed_cb (EphyToolbarsModel *model,
- int toolbar_position,
- int position,
- EphyBookmarksEditor *editor)
-{
- ephy_bookmarks_editor_update_menu (editor);
-}
-
-static void
ephy_bookmarks_editor_init (EphyBookmarksEditor *editor)
{
editor->priv = EPHY_BOOKMARKS_EDITOR_GET_PRIVATE (editor);
editor->priv->props_dialogs = g_hash_table_new (g_direct_hash,
g_direct_equal);
- editor->priv->tb_model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
+ editor->priv->tb_model = EPHY_BOOKMARKSBAR_MODEL
+ (ephy_bookmarks_get_toolbars_model
+ (ephy_shell_get_bookmarks (ephy_shell)));
g_signal_connect (editor->priv->tb_model, "item_added",
G_CALLBACK (toolbar_items_changed_cb), editor);
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 6e765e6d6..be9884956 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2002-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -30,7 +31,7 @@
#include "ephy-debug.h"
#include "ephy-tree-model-node.h"
#include "ephy-node-common.h"
-#include "ephy-toolbars-model.h"
+#include "ephy-bookmarksbar-model.h"
#include "ephy-bookmarks-export.h"
#include "ephy-bookmarks-import.h"
#include "ephy-prefs.h"
@@ -50,7 +51,7 @@
struct EphyBookmarksPrivate
{
- EphyToolbarsModel *toolbars_model;
+ EphyBookmarksBarModel *toolbars_model;
gboolean init_defaults;
gboolean dirty;
guint save_timeout_id;
@@ -160,22 +161,84 @@ ephy_bookmarks_init_defaults (EphyBookmarks *eb)
bmk = ephy_bookmarks_add (eb, _(default_bookmarks[i].title),
_(default_bookmarks[i].location));
- ephy_toolbars_model_add_bookmark (eb->priv->toolbars_model, FALSE,
- ephy_node_get_id (bmk));
+ ephy_bookmarksbar_model_add_bookmark (eb->priv->toolbars_model, FALSE,
+ ephy_node_get_id (bmk));
}
}
-static void
-ephy_bookmarks_set_toolbars_model (EphyBookmarks *eb, EphyToolbarsModel *model)
+static char *
+get_item_type_forward_cb (EggToolbarsModel *model,
+ GdkAtom type,
+ EggToolbarsModel *bookmarksbar_model)
+{
+ char *retval;
+
+ g_signal_emit_by_name (bookmarksbar_model, "get_item_type",
+ type, &retval);
+
+ return retval;
+}
+
+static char *
+get_item_id_forward_cb (EggToolbarsModel *model,
+ const char *type,
+ const char *name,
+ EggToolbarsModel *bookmarksbar_model)
+{
+ char *retval;
+
+ g_signal_emit_by_name (bookmarksbar_model, "get_item_id",
+ type, name, &retval);
+
+ return retval;
+}
+
+static char *
+get_item_data_forward_cb (EggToolbarsModel *model,
+ const char *type,
+ const char *id,
+ EggToolbarsModel *bookmarksbar_model)
+{
+ char *retval;
+
+ g_signal_emit_by_name (bookmarksbar_model, "get_item_data",
+ type, id, &retval);
+
+ return retval;
+}
+
+EggToolbarsModel *
+ephy_bookmarks_get_toolbars_model (EphyBookmarks *eb)
{
- eb->priv->toolbars_model = model;
- g_object_add_weak_pointer (G_OBJECT(eb->priv->toolbars_model),
- (gpointer *)&eb->priv->toolbars_model);
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- if (eb->priv->init_defaults)
+ if (eb->priv->toolbars_model == NULL)
{
- ephy_bookmarks_init_defaults (eb);
+ GObject *toolbars_model;
+
+ eb->priv->toolbars_model = EPHY_BOOKMARKSBAR_MODEL
+ (ephy_bookmarksbar_model_new (eb));
+
+ /* forward those signals, so that bookmarks can also be on the main model */
+ toolbars_model = ephy_shell_get_toolbars_model (ephy_shell, FALSE);
+
+ g_signal_connect_after (toolbars_model, "get_item_type",
+ G_CALLBACK (get_item_type_forward_cb),
+ eb->priv->toolbars_model);
+ g_signal_connect_after (toolbars_model, "get_item_id",
+ G_CALLBACK (get_item_id_forward_cb),
+ eb->priv->toolbars_model);
+ g_signal_connect_after (toolbars_model, "get_item_data",
+ G_CALLBACK (get_item_data_forward_cb),
+ eb->priv->toolbars_model);
+
+ if (eb->priv->init_defaults)
+ {
+ ephy_bookmarks_init_defaults (eb);
+ }
}
+
+ return EGG_TOOLBARS_MODEL (eb->priv->toolbars_model);
}
static void
@@ -184,16 +247,8 @@ ephy_bookmarks_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- EphyBookmarks *eb;
-
- eb = EPHY_BOOKMARKS (object);
-
- switch (prop_id)
- {
- case PROP_TOOLBARS_MODEL:
- ephy_bookmarks_set_toolbars_model (eb, g_value_get_object (value));
- break;
- }
+ /* no writable properties */
+ g_assert_not_reached ();
}
static void
@@ -202,14 +257,12 @@ ephy_bookmarks_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- EphyBookmarks *eb;
-
- eb = EPHY_BOOKMARKS (object);
+ EphyBookmarks *eb = EPHY_BOOKMARKS (object);
switch (prop_id)
{
case PROP_TOOLBARS_MODEL:
- g_value_set_object (value, eb->priv->toolbars_model);
+ g_value_set_object (value, ephy_bookmarks_get_toolbars_model (eb));
break;
}
}
@@ -238,11 +291,11 @@ ephy_bookmarks_class_init (EphyBookmarksClass *klass)
g_object_class_install_property (object_class,
PROP_TOOLBARS_MODEL,
- g_param_spec_object ("toolbars_model",
+ g_param_spec_object ("toolbars-model",
"Toolbars model",
"Toolbars model",
- EPHY_TYPE_TOOLBARS_MODEL,
- G_PARAM_READWRITE));
+ EPHY_TYPE_BOOKMARKSBAR_MODEL,
+ G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof(EphyBookmarksPrivate));
}
@@ -763,10 +816,10 @@ ephy_bookmarks_finalize (GObject *object)
g_object_unref (eb->priv->db);
- if (eb->priv->toolbars_model)
+ LOG ("Unref bookmarks toolbars model")
+ if (eb->priv->toolbars_model != NULL)
{
- g_object_remove_weak_pointer (G_OBJECT(eb->priv->toolbars_model),
- (gpointer *)&eb->priv->toolbars_model);
+ g_object_unref (eb->priv->toolbars_model);
}
g_free (eb->priv->xml_file);
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 14b352e0a..26c83832e 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -24,6 +25,7 @@
#include <glib-object.h>
#include "ephy-node.h"
+#include "egg-toolbars-model.h"
G_BEGIN_DECLS
@@ -34,103 +36,105 @@ G_BEGIN_DECLS
#define EPHY_IS_BOOKMARKS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_BOOKMARKS))
#define EPHY_BOOKMARKS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_BOOKMARKS, EphyBookmarksClass))
-typedef struct EphyBookmarksClass EphyBookmarksClass;
-typedef struct EphyBookmarks EphyBookmarks;
-typedef struct EphyBookmarksPrivate EphyBookmarksPrivate;
+typedef struct EphyBookmarksClass EphyBookmarksClass;
+typedef struct EphyBookmarks EphyBookmarks;
+typedef struct EphyBookmarksPrivate EphyBookmarksPrivate;
enum
{
- EPHY_NODE_BMK_PROP_TITLE = 2,
- EPHY_NODE_BMK_PROP_LOCATION = 3,
- EPHY_NODE_BMK_PROP_KEYWORDS = 4,
- EPHY_NODE_KEYWORD_PROP_NAME = 5,
- EPHY_NODE_BMK_PROP_ICON = 7,
- EPHY_NODE_KEYWORD_PROP_PRIORITY = 8
+ EPHY_NODE_BMK_PROP_TITLE = 2,
+ EPHY_NODE_BMK_PROP_LOCATION = 3,
+ EPHY_NODE_BMK_PROP_KEYWORDS = 4,
+ EPHY_NODE_KEYWORD_PROP_NAME = 5,
+ EPHY_NODE_BMK_PROP_ICON = 7,
+ EPHY_NODE_KEYWORD_PROP_PRIORITY = 8
};
struct EphyBookmarks
{
- GObject parent;
+ GObject parent;
/*< private >*/
- EphyBookmarksPrivate *priv;
+ EphyBookmarksPrivate *priv;
};
struct EphyBookmarksClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* tree_changed) (EphyBookmarks *eb);
+ void (* tree_changed) (EphyBookmarks *eb);
};
-GType ephy_bookmarks_get_type (void);
+GType ephy_bookmarks_get_type (void);
-EphyBookmarks *ephy_bookmarks_new (void);
+EphyBookmarks *ephy_bookmarks_new (void);
-EphyNode *ephy_bookmarks_get_from_id (EphyBookmarks *eb,
- long id);
+EphyNode *ephy_bookmarks_get_from_id (EphyBookmarks *eb,
+ long id);
+
+EggToolbarsModel *ephy_bookmarks_get_toolbars_model (EphyBookmarks *eb);
/* Bookmarks */
-EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
- const char *title,
- const char *url);
+EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
+ const char *title,
+ const char *url);
-EphyNode* ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
- const char *url);
+EphyNode* ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
+ const char *url);
-void ephy_bookmarks_set_icon (EphyBookmarks *eb,
- const char *url,
- const char *icon);
+void ephy_bookmarks_set_icon (EphyBookmarks *eb,
+ const char *url,
+ const char *icon);
-void ephy_bookmarks_set_address (EphyBookmarks *eb,
- EphyNode *bookmark,
- const char *address);
+void ephy_bookmarks_set_address (EphyBookmarks *eb,
+ EphyNode *bookmark,
+ const char *address);
-char *ephy_bookmarks_solve_smart_url (EphyBookmarks *eb,
- const char *smart_url,
- const char *content);
+char *ephy_bookmarks_solve_smart_url (EphyBookmarks *eb,
+ const char *smart_url,
+ const char *content);
/* Keywords */
-EphyNode *ephy_bookmarks_add_keyword (EphyBookmarks *eb,
- const char *name);
+EphyNode *ephy_bookmarks_add_keyword (EphyBookmarks *eb,
+ const char *name);
-EphyNode *ephy_bookmarks_find_keyword (EphyBookmarks *eb,
- const char *name,
- gboolean partial_match);
+EphyNode *ephy_bookmarks_find_keyword (EphyBookmarks *eb,
+ const char *name,
+ gboolean partial_match);
-void ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
- EphyNode *keyword);
+void ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
+ EphyNode *keyword);
-gboolean ephy_bookmarks_has_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
+gboolean ephy_bookmarks_has_keyword (EphyBookmarks *eb,
+ EphyNode *keyword,
+ EphyNode *bookmark);
-void ephy_bookmarks_set_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
+void ephy_bookmarks_set_keyword (EphyBookmarks *eb,
+ EphyNode *keyword,
+ EphyNode *bookmark);
-void ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark);
+void ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
+ EphyNode *keyword,
+ EphyNode *bookmark);
-char *ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
- EphyNode *node);
+char *ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
+ EphyNode *node);
/* Favorites */
-EphyNode *ephy_bookmarks_get_favorites (EphyBookmarks *eb);
+EphyNode *ephy_bookmarks_get_favorites (EphyBookmarks *eb);
/* Root */
-EphyNode *ephy_bookmarks_get_keywords (EphyBookmarks *eb);
+EphyNode *ephy_bookmarks_get_keywords (EphyBookmarks *eb);
-EphyNode *ephy_bookmarks_get_bookmarks (EphyBookmarks *eb);
+EphyNode *ephy_bookmarks_get_bookmarks (EphyBookmarks *eb);
-EphyNode *ephy_bookmarks_get_not_categorized (EphyBookmarks *eb);
+EphyNode *ephy_bookmarks_get_not_categorized (EphyBookmarks *eb);
-EphyNode *ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb);
+EphyNode *ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb);
G_END_DECLS
diff --git a/src/bookmarks/ephy-bookmarksbar-model.c b/src/bookmarks/ephy-bookmarksbar-model.c
index cc5bdf773..fc969fddc 100755
--- a/src/bookmarks/ephy-bookmarksbar-model.c
+++ b/src/bookmarks/ephy-bookmarksbar-model.c
@@ -188,9 +188,9 @@ ephy_bookmarksbar_model_add_bookmark (EphyBookmarksBarModel *model,
name = ephy_bookmarksbar_model_get_action_name (model, id);
egg_toolbars_model_add_item (EGG_TOOLBARS_MODEL (model),
- toolbar_position, -1, name,
- topic ? EPHY_DND_TOPIC_TYPE :
- EPHY_DND_URL_TYPE);
+ toolbar_position, -1, name,
+ topic ? EPHY_DND_TOPIC_TYPE :
+ EPHY_DND_URL_TYPE);
g_free (name);
}
@@ -198,19 +198,19 @@ void
ephy_bookmarksbar_model_remove_bookmark (EphyBookmarksBarModel *model,
long id)
{
-/* char *action_name;
+ char *action_name;
int toolbar, position;
action_name = ephy_bookmarksbar_model_get_action_name (model, id);
g_return_if_fail (action_name != NULL);
- if (get_toolbar_and_item_pos (model, action_name, &toolbar, &position))
+ while (get_toolbar_and_item_pos (model, action_name, &toolbar, &position))
{
egg_toolbars_model_remove_item (EGG_TOOLBARS_MODEL (model),
toolbar, position);
}
- g_free (action_name);*/
+ g_free (action_name);
}
gboolean
@@ -285,74 +285,27 @@ update_flags_and_save_changes (EphyBookmarksBarModel *model)
}
static void
-bookmark_destroy_cb (EphyNode *node,
- EphyBookmarksBarModel *model)
-{
- long id;
-
- id = ephy_node_get_id (node);
- ephy_bookmarksbar_model_remove_bookmark (model, id);
-}
-
-static void
item_added_cb (EphyBookmarksBarModel *model,
int toolbar_position,
int position)
{
- EphyNode *node;
- const char *i_name;
- gboolean is_separator;
-
- egg_toolbars_model_item_nth (EGG_TOOLBARS_MODEL (model), toolbar_position,
- position, &is_separator, &i_name, NULL);
- if (!is_separator && g_str_has_prefix (i_name, "GoBookmark-"))
- {
- node = ephy_bookmarksbar_model_get_node (model, i_name);
- g_return_if_fail (node != NULL);
-
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (model));
- }
-
save_changes (model);
}
static char *
-impl_get_item_name (EggToolbarsModel *eggmodel,
- const char *type,
- const char *id)
+impl_get_item_type (EggToolbarsModel *model,
+ GdkAtom type)
{
- EphyBookmarksBarModel *model = EPHY_BOOKMARKSBAR_MODEL (eggmodel);
- EphyNode *node;
-
- if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
+ if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
{
- char *uri;
-
- node = ephy_bookmarksbar_model_get_node (model, id);
- g_return_val_if_fail (node != NULL, NULL);
-
- uri = ephy_bookmarks_get_topic_uri
- (model->priv->bookmarks, node);
-
- return uri;
+ return g_strdup (EPHY_DND_TOPIC_TYPE);
}
- else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
+ else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type)
{
- const char *name;
-
- node = ephy_bookmarksbar_model_get_node (model, id);
- g_return_val_if_fail (node != NULL, NULL);
-
- name = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
-
- return g_strdup (name);
+ return g_strdup (EPHY_DND_URL_TYPE);
}
- return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_name (eggmodel, type, id);
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_type (model, type);
}
static char *
@@ -422,19 +375,39 @@ impl_get_item_id (EggToolbarsModel *eggmodel,
}
static char *
-impl_get_item_type (EggToolbarsModel *model,
- GdkAtom type)
+impl_get_item_data (EggToolbarsModel *eggmodel,
+ const char *type,
+ const char *id)
{
- if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
+ EphyBookmarksBarModel *model = EPHY_BOOKMARKSBAR_MODEL (eggmodel);
+ EphyNode *node;
+
+ if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
{
- return g_strdup (EPHY_DND_TOPIC_TYPE);
+ char *uri;
+
+ node = ephy_bookmarksbar_model_get_node (model, id);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ uri = ephy_bookmarks_get_topic_uri
+ (model->priv->bookmarks, node);
+
+ return uri;
}
- else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type)
+ else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
{
- return g_strdup (EPHY_DND_URL_TYPE);
+ const char *name;
+
+ node = ephy_bookmarksbar_model_get_node (model, id);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ name = ephy_node_get_property_string
+ (node, EPHY_NODE_BMK_PROP_LOCATION);
+
+ return g_strdup (name);
}
- return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_type (model, type);
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_data (eggmodel, type, id);
}
static void
@@ -527,6 +500,9 @@ ephy_bookmarksbar_model_finalize (GObject *object)
model->priv->timeout = 0;
}
+ /* FIXME: instead of saving on exit, we should detect when items data changes */
+ save_changes_idle (model);
+
g_free (model->priv->xml_file);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -572,9 +548,9 @@ ephy_bookmarksbar_model_class_init (EphyBookmarksBarModelClass *klass)
object_class->set_property = ephy_bookmarksbar_model_set_property;
object_class->get_property = ephy_bookmarksbar_model_get_property;
- eggclass->get_item_name = impl_get_item_name;
- eggclass->get_item_id = impl_get_item_id;
eggclass->get_item_type = impl_get_item_type;
+ eggclass->get_item_id = impl_get_item_id;
+ eggclass->get_item_data = impl_get_item_data;
g_object_class_install_property (object_class,
PROP_BOOKMARKS,
diff --git a/src/bookmarks/ephy-bookmarksbar-model.h b/src/bookmarks/ephy-bookmarksbar-model.h
index ac39f9325..41c7efef3 100755
--- a/src/bookmarks/ephy-bookmarksbar-model.h
+++ b/src/bookmarks/ephy-bookmarksbar-model.h
@@ -51,25 +51,25 @@ struct EphyBookmarksBarModelClass
EggToolbarsModelClass parent_class;
};
-GType ephy_bookmarksbar_model_get_type (void);
+GType ephy_bookmarksbar_model_get_type (void);
-EggToolbarsModel *ephy_bookmarksbar_model_new (EphyBookmarks *bookmarks);
+EggToolbarsModel *ephy_bookmarksbar_model_new (EphyBookmarks *bookmarks);
-char *ephy_bookmarksbar_model_get_action_name (EphyBookmarksBarModel *model,
- long id);
+char *ephy_bookmarksbar_model_get_action_name (EphyBookmarksBarModel *model,
+ long id);
-EphyNode *ephy_bookmarksbar_model_get_node (EphyBookmarksBarModel *model,
- const char *action_name);
+EphyNode *ephy_bookmarksbar_model_get_node (EphyBookmarksBarModel *model,
+ const char *action_name);
-void ephy_bookmarksbar_model_add_bookmark (EphyBookmarksBarModel *model,
- gboolean topic,
- long id);
+void ephy_bookmarksbar_model_add_bookmark (EphyBookmarksBarModel *model,
+ gboolean topic,
+ long id);
-void ephy_bookmarksbar_model_remove_bookmark (EphyBookmarksBarModel *model,
- long id);
+void ephy_bookmarksbar_model_remove_bookmark (EphyBookmarksBarModel *model,
+ long id);
-gboolean ephy_bookmarksbar_model_has_bookmark (EphyBookmarksBarModel *model,
- long id);
+gboolean ephy_bookmarksbar_model_has_bookmark (EphyBookmarksBarModel *model,
+ long id);
G_END_DECLS
diff --git a/src/bookmarks/ephy-bookmarksbar.c b/src/bookmarks/ephy-bookmarksbar.c
index 144d7c25e..511b635fa 100644
--- a/src/bookmarks/ephy-bookmarksbar.c
+++ b/src/bookmarks/ephy-bookmarksbar.c
@@ -42,9 +42,8 @@
static GtkTargetEntry drag_targets[] =
{
- { EGG_TOOLBAR_ITEM_TYPE, 0, 0 },
- { EPHY_DND_TOPIC_TYPE, 0, 1 },
- { EPHY_DND_URL_TYPE, 0, 2 }
+ { EPHY_DND_TOPIC_TYPE, 0, 0 },
+ { EPHY_DND_URL_TYPE, 0, 1 }
};
static int n_drag_targets = G_N_ELEMENTS (drag_targets);
@@ -145,30 +144,73 @@ go_location_cb (GtkAction *action,
}
}
+static gboolean
+remove_action_from_model (EggToolbarsModel *model, const char *name)
+{
+ int n_toolbars, n_items, t, i;
+
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+
+ for (t = 0; t < n_toolbars; t++)
+ {
+ n_items = egg_toolbars_model_n_items (model, t);
+
+ for (i = 0; i < n_items; i++)
+ {
+ const char *i_name;
+ gboolean is_separator;
+
+ egg_toolbars_model_item_nth (model, t , i, &is_separator,
+ &i_name, NULL);
+ g_return_val_if_fail (i_name != NULL, FALSE);
+
+ if (strcmp (i_name, name) == 0)
+ {
+ egg_toolbars_model_remove_item (model, t, i);
+
+ if (!remove_action_from_model (model, name))
+ {
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
static void
bookmark_destroy_cb (EphyNode *node,
EphyBookmarksBar *toolbar)
{
+ EggToolbarsModel *model;
GtkAction *action;
char *name;
long id;
+
+ model = toolbar->priv->toolbars_model;
id = ephy_node_get_id (node);
name = ephy_bookmarksbar_model_get_action_name
- (EPHY_BOOKMARKSBAR_MODEL (toolbar->priv->toolbars_model),
- id);
+ (EPHY_BOOKMARKSBAR_MODEL (model), id);
+ remove_action_from_model (model, name);
- action = gtk_action_group_get_action (toolbar->priv->action_group, name);
- g_return_if_fail (action != NULL);
+ model = EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model
+ (ephy_shell, FALSE));
+ remove_action_from_model (model, name);
- gtk_action_group_remove_action (toolbar->priv->action_group, action);
+ action = gtk_action_group_get_action (toolbar->priv->action_group, name);
+ if (action)
+ {
+ gtk_action_group_remove_action (toolbar->priv->action_group, action);
+ }
g_free (name);
}
static void
ephy_bookmarksbar_action_request (EggEditableToolbar *eggtoolbar,
- const char *name)
+ const char *name)
{
EphyBookmarksBar *toolbar = EPHY_BOOKMARKSBAR (eggtoolbar);
GtkAction *action = NULL;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 78060acf6..d61f6075a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -39,6 +40,7 @@
#include "toolbar.h"
#include "ephy-session.h"
#include "downloader-view.h"
+#include "egg-toolbars-model.h"
#include "ephy-toolbars-model.h"
#include "ephy-automation.h"
#include "print-dialog.h"
@@ -63,7 +65,7 @@ struct EphyShellPrivate
BonoboGenericFactory *automation_factory;
EphySession *session;
EphyBookmarks *bookmarks;
- EphyToolbarsModel *toolbars_model;
+ EggToolbarsModel *toolbars_model;
EggToolbarsModel *fs_toolbars_model;
EphyExtensionsManager *extensions_manager;
GtkWidget *bme;
@@ -664,11 +666,16 @@ ephy_shell_get_toolbars_model (EphyShell *shell, gboolean fullscreen)
{
if (shell->priv->fs_toolbars_model == NULL)
{
+ gboolean success;
const char *xml;
shell->priv->fs_toolbars_model = egg_toolbars_model_new ();
xml = ephy_file ("epiphany-fs-toolbar.xml");
- egg_toolbars_model_load (shell->priv->fs_toolbars_model, xml);
+ g_return_val_if_fail (xml != NULL, NULL);
+
+ success = egg_toolbars_model_load
+ (shell->priv->fs_toolbars_model, xml);
+ g_return_val_if_fail (success, NULL);
}
return G_OBJECT (shell->priv->fs_toolbars_model);
@@ -678,16 +685,22 @@ ephy_shell_get_toolbars_model (EphyShell *shell, gboolean fullscreen)
if (shell->priv->toolbars_model == NULL)
{
EphyBookmarks *bookmarks;
+ EggToolbarsModel *bookmarksbar_model;
- bookmarks = ephy_shell_get_bookmarks (shell);
+ shell->priv->toolbars_model = ephy_toolbars_model_new ();
- shell->priv->toolbars_model = ephy_toolbars_model_new (bookmarks);
+ /* get the bookmarks toolbars model. we have to do this
+ * before loading the toolbars model from disk, since
+ * this will connect the get_item_* signals
+ */
+ bookmarks = ephy_shell_get_bookmarks (shell);
+ bookmarksbar_model = ephy_bookmarks_get_toolbars_model (bookmarks);
- g_object_set (bookmarks, "toolbars_model",
- shell->priv->toolbars_model, NULL);
+ /* ok, now we can load the model */
+ ephy_toolbars_model_load
+ (EPHY_TOOLBARS_MODEL (shell->priv->toolbars_model));
}
-
return G_OBJECT (shell->priv->toolbars_model);
}
}
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 1c5e07a05..d3d9233c3 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -117,11 +118,11 @@ EphyTab *ephy_shell_new_tab (EphyShell *shell,
const char *url,
EphyNewTabFlags flags);
-GObject *ephy_shell_get_session (EphyShell *shell);
+GObject *ephy_shell_get_session (EphyShell *shell);
EphyBookmarks *ephy_shell_get_bookmarks (EphyShell *shell);
-GObject *ephy_shell_get_toolbars_model (EphyShell *shell,
+GObject *ephy_shell_get_toolbars_model (EphyShell *shell,
gboolean fullscreen);
GObject *ephy_shell_get_extensions_manager (EphyShell *shell);
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index 0df59cb0a..b730b93e2 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2002 Marco Pesenti Gritti
+ * Copyright (C) 2002-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -23,54 +24,27 @@
#endif
#include "ephy-toolbars-model.h"
-#include "ephy-dnd.h"
-#include "ephy-bookmarks.h"
-#include "ephy-node-common.h"
#include "ephy-file-helpers.h"
-#include "ephy-history.h"
-#include "ephy-embed-shell.h"
-#include "ephy-shell.h"
#include "ephy-debug.h"
-#include "ephy-string.h"
#include <string.h>
-#include <glib/gi18n.h>
-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);
-
-#define EPHY_TOOLBARS_XML_VERSION "1.0"
-
-enum
-{
- ACTION_ADDED,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_BOOKMARKS
-};
-
-enum
-{
- URL,
- NAME
-};
-
-static GObjectClass *parent_class = NULL;
+#define EPHY_TOOLBARS_XML_FILE "epiphany-toolbars-2.xml"
+#define EPHY_TOOLBARS_XML_VERSION "1.0"
#define EPHY_TOOLBARS_MODEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOOLBARS_MODEL, EphyToolbarsModelPrivate))
struct EphyToolbarsModelPrivate
{
- EphyBookmarks *bookmarks;
char *xml_file;
- gboolean loading;
+ guint timeout;
};
+static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass);
+static void ephy_toolbars_model_init (EphyToolbarsModel *model);
+
+static GObjectClass *parent_class = NULL;
+
GType
ephy_toolbars_model_get_type (void)
{
@@ -98,207 +72,75 @@ ephy_toolbars_model_get_type (void)
return type;
}
-char *
-ephy_toolbars_model_get_action_name (EphyToolbarsModel *model,
- long id)
+static gboolean
+save_changes_idle (EphyToolbarsModel *model)
{
- return g_strdup_printf ("GoBookmark-%ld", id);
-}
+ LOG ("Saving toolbars model")
-EphyNode *
-ephy_toolbars_model_get_node (EphyToolbarsModel *model,
- const char *action_name)
-{
- EphyBookmarks *bookmarks = EPHY_TOOLBARS_MODEL (model)->priv->bookmarks;
- long node_id;
+ egg_toolbars_model_save
+ (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file,
+ EPHY_TOOLBARS_XML_VERSION);
- if (!ephy_string_to_int (action_name + strlen ("GoBookmark-"), &node_id))
- {
- return NULL;
- }
+ model->priv->timeout = 0;
- return ephy_bookmarks_get_from_id (bookmarks, node_id);
+ /* don't run again */
+ return FALSE;
}
static void
-bookmark_destroy_cb (EphyNode *node,
- EphyToolbarsModel *model)
-{
- long id;
-
- id = ephy_node_get_id (node);
- ephy_toolbars_model_remove_bookmark (model, id);
-}
-
-static char *
-impl_get_item_data (EggToolbarsModel *t,
- const char *type,
- const char *id)
+save_changes (EphyToolbarsModel *model)
{
- EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (t);
- EphyNode *node;
-
- if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
- {
- char *uri;
-
- node = ephy_toolbars_model_get_node (model, id);
- g_return_val_if_fail (node != NULL, NULL);
-
- uri = ephy_bookmarks_get_topic_uri
- (model->priv->bookmarks, node);
-
- return uri;
- }
- else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
+ if (model->priv->timeout == 0)
{
- const char *name;
-
- node = ephy_toolbars_model_get_node (model, id);
- g_return_val_if_fail (node != NULL, NULL);
-
- name = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
-
- return g_strdup (name);
+ model->priv->timeout =
+ g_idle_add ((GSourceFunc) save_changes_idle, model);
}
-
- return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_data (t, type, id);
}
-static char *
-impl_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *name)
+static void
+update_flags_and_save_changes (EphyToolbarsModel *model)
{
- EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (t);
- EphyBookmarks *bookmarks = model->priv->bookmarks;
-
- if (strcmp (type, EPHY_DND_TOPIC_TYPE) == 0)
- {
- EphyNode *topic;
-
- topic = ephy_bookmarks_find_keyword (bookmarks, name, FALSE);
- if (topic == NULL) return NULL;
-
- return ephy_toolbars_model_get_action_name
- (model, ephy_node_get_id (topic));
- }
- else if (strcmp (type, EPHY_DND_URL_TYPE) == 0)
- {
- EphyNode *node = NULL;
- gchar **netscape_url;
-
- netscape_url = g_strsplit (name, "\n", 2);
- node = ephy_bookmarks_find_bookmark (bookmarks, netscape_url[URL]);
-
- if (!node)
- {
- /* Create the bookmark, it does not exist */
- EphyHistory *gh;
- const char *icon;
- const char *title;
-
- title = netscape_url[NAME];
- if (title == NULL || *title == '\0')
- {
- title = _("Untitled");
- }
-
- node = ephy_bookmarks_add (bookmarks, title, netscape_url[URL]);
-
- if (node != NULL)
- {
- gh = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
- icon = ephy_history_get_icon (gh, netscape_url[URL]);
-
- if (icon)
- {
- ephy_bookmarks_set_icon (bookmarks, netscape_url[URL], icon);
- }
- }
- }
-
- g_strfreev (netscape_url);
-
- if (node == NULL) return NULL;
-
- return ephy_toolbars_model_get_action_name
- (model, ephy_node_get_id (node));
- }
+ EggToolbarsModel *eggmodel = EGG_TOOLBARS_MODEL (model);
+ int i, n_toolbars;
+ int flag = EGG_TB_MODEL_ACCEPT_ITEMS_ONLY;
- return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_data (t, type, name);
-}
+ n_toolbars = egg_toolbars_model_n_toolbars (eggmodel);
-static char *
-impl_get_item_type (EggToolbarsModel *t,
- GdkAtom type)
-{
- if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type)
- {
- return g_strdup (EPHY_DND_TOPIC_TYPE);
- }
- else if (gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE) == type)
+ if (n_toolbars <= 1)
{
- return g_strdup (EPHY_DND_URL_TYPE);
+ flag |= EGG_TB_MODEL_NOT_REMOVABLE;
}
- return EGG_TOOLBARS_MODEL_CLASS (parent_class)->get_item_type (t, type);
-}
-
-static gboolean
-get_toolbar_and_item_pos (EphyToolbarsModel *model,
- const char *action_name,
- int *toolbar,
- int *position)
-{
- int n_toolbars, n_items;
- int t,i;
-
- n_toolbars = egg_toolbars_model_n_toolbars (EGG_TOOLBARS_MODEL (model));
-
- for (t = 0; t < n_toolbars; t++)
+ for (i = 0; i < n_toolbars; i++)
{
- n_items = egg_toolbars_model_n_items
- (EGG_TOOLBARS_MODEL (model), t);
-
- for (i = 0; i < n_items; i++)
- {
- const char *i_name;
- gboolean is_separator;
-
- egg_toolbars_model_item_nth (EGG_TOOLBARS_MODEL (model),
- t, i, &is_separator, &i_name, NULL);
- g_return_val_if_fail (i_name != NULL, FALSE);
+ const char *t_name;
+ EggTbModelFlags flags;
- if (strcmp (i_name, action_name) == 0)
- {
- if (toolbar) *toolbar = t;
- if (position) *position = i;
+ t_name = egg_toolbars_model_toolbar_nth (eggmodel, i);
+ g_return_if_fail (t_name != NULL);
- return TRUE;
- }
- }
+ flags = egg_toolbars_model_get_flags (eggmodel, i);
+ egg_toolbars_model_set_flags (eggmodel, flags | flag, i);
}
- return FALSE;
+ save_changes (model);
}
static int
-get_toolbar_pos (EphyToolbarsModel *model,
+get_toolbar_pos (EggToolbarsModel *model,
const char *name)
{
int i, n_toolbars;
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
for (i = 0; i < n_toolbars; i++)
{
const char *t_name;
- t_name = egg_toolbars_model_toolbar_nth
- (EGG_TOOLBARS_MODEL (model), i);
+ t_name = egg_toolbars_model_toolbar_nth (model, i);
+ g_return_val_if_fail (t_name != NULL, -1);
if (strcmp (name, t_name) == 0)
{
return i;
@@ -308,289 +150,108 @@ get_toolbar_pos (EphyToolbarsModel *model,
return -1;
}
-static void
-connect_item (EphyToolbarsModel *model,
- const char *name)
-{
- EphyNode *node;
-
- if (g_str_has_prefix (name, "GoBookmark-"))
- {
- node = ephy_toolbars_model_get_node (model, name);
- g_return_if_fail (node != NULL);
-
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (model));
- }
-}
-
-static void
-update_toolbar_removeable_flag (EggToolbarsModel *model)
+void
+ephy_toolbars_model_load (EphyToolbarsModel *model)
{
- int i, n_toolbars;
- int flag = 0;
+ EggToolbarsModel *eggmodel = EGG_TOOLBARS_MODEL (model);
+ gboolean success;
- n_toolbars = egg_toolbars_model_n_toolbars (model);
-
- /* If there is only one toolbar and the bookmarks bar */
- if (n_toolbars <= 2)
- {
- flag = EGG_TB_MODEL_NOT_REMOVABLE;
- }
+ success = egg_toolbars_model_load (eggmodel, model->priv->xml_file);
+ LOG ("Loading the toolbars was %ssuccessful", success ? "" : "un")
- for (i = 0; i < n_toolbars; i++)
+ /* maybe an old format, try to migrate: load the old layout, and
+ * remove the BookmarksBar toolbar
+ */
+ if (success == FALSE)
{
- const char *t_name;
+ char *old_xml;
+ int toolbar;
- t_name = egg_toolbars_model_toolbar_nth (model, i);
- g_return_if_fail (t_name != NULL);
+ old_xml = g_build_filename (ephy_dot_dir (),
+ "epiphany-toolbars.xml",
+ NULL);
+ success = egg_toolbars_model_load (eggmodel, old_xml);
+ g_free (old_xml);
- if (!(strcmp (t_name, "BookmarksBar") == 0))
+ if (success)
{
- egg_toolbars_model_set_flags (model, flag, i);
+ toolbar = get_toolbar_pos (eggmodel, "BookmarksBar");
+ if (toolbar != -1)
+ {
+ egg_toolbars_model_remove_toolbar (eggmodel, toolbar);
+ }
}
- }
-}
-
-static void
-ephy_toolbars_model_set_bookmarks (EphyToolbarsModel *model, EphyBookmarks *bookmarks)
-{
- EggToolbarsModel *egg_model = EGG_TOOLBARS_MODEL (model);
- gboolean success = FALSE;
-
- model->priv->bookmarks = g_object_ref (bookmarks);
-
- model->priv->loading = TRUE;
- if (g_file_test (model->priv->xml_file, G_FILE_TEST_EXISTS))
- {
- success = egg_toolbars_model_load (egg_model,
- model->priv->xml_file);
+ LOG ("Migration was %ssuccessful", success ? "" : "un")
}
+ /* Still no success, load the default toolbars */
if (success == FALSE)
{
- const char *default_xml;
-
- default_xml = ephy_file ("epiphany-toolbar.xml");
- egg_toolbars_model_load (egg_model, default_xml);
+ success = egg_toolbars_model_load
+ (eggmodel, ephy_file ("epiphany-toolbar.xml"));
+ LOG ("Loading the default toolbars was %ssuccessful", success ? "" : "un")
}
- /* ensure that we have a BookmarksBar */
- if (get_toolbar_pos (model, "BookmarksBar") == -1)
+ /* Ensure we have at least 1 toolbar */
+ if (egg_toolbars_model_n_toolbars (eggmodel) < 1)
{
- egg_toolbars_model_add_toolbar
- (EGG_TOOLBARS_MODEL (model), -1, "BookmarksBar");
+ egg_toolbars_model_add_toolbar (eggmodel, 0, "DefaultToolbar");
}
-
- model->priv->loading = FALSE;
}
static void
-ephy_toolbars_model_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_toolbars_model_init (EphyToolbarsModel *model)
{
- EphyToolbarsModel *model;
-
- model = EPHY_TOOLBARS_MODEL (object);
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- ephy_toolbars_model_set_bookmarks (model, g_value_get_object (value));
- break;
- }
+ model->priv = EPHY_TOOLBARS_MODEL_GET_PRIVATE (model);
+
+ model->priv->xml_file = g_build_filename (ephy_dot_dir (),
+ EPHY_TOOLBARS_XML_FILE,
+ NULL);
+
+ g_signal_connect_after (model, "item_added",
+ G_CALLBACK (save_changes), NULL);
+ g_signal_connect_after (model, "item_removed",
+ G_CALLBACK (save_changes), NULL);
+ g_signal_connect_after (model, "toolbar_added",
+ G_CALLBACK (update_flags_and_save_changes), NULL);
+ g_signal_connect_after (model, "toolbar_removed",
+ G_CALLBACK (update_flags_and_save_changes), NULL);
}
static void
-ephy_toolbars_model_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_toolbars_model_finalize (GObject *object)
{
- EphyToolbarsModel *model;
-
- model = EPHY_TOOLBARS_MODEL (object);
+ EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (object);
- switch (prop_id)
+ if (model->priv->timeout != 0)
{
- case PROP_BOOKMARKS:
- g_value_set_object (value, model->priv->bookmarks);
- break;
+ g_source_remove (model->priv->timeout);
+ model->priv->timeout = 0;
}
+
+ /* FIXME: we should detect when item data changes, and save then instead */
+ save_changes_idle (model);
+
+ g_free (model->priv->xml_file);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- EggToolbarsModelClass *etm_class;
-
- etm_class = EGG_TOOLBARS_MODEL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_toolbars_model_finalize;
- object_class->set_property = ephy_toolbars_model_set_property;
- object_class->get_property = ephy_toolbars_model_get_property;
-
- etm_class->get_item_id = impl_get_item_id;
- etm_class->get_item_data = impl_get_item_data;
- etm_class->get_item_type = impl_get_item_type;
-
- g_object_class_install_property (object_class,
- PROP_BOOKMARKS,
- g_param_spec_object ("bookmarks",
- "Bookmarks",
- "Bookmarks",
- EPHY_TYPE_BOOKMARKS,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof(EphyToolbarsModelPrivate));
-}
-
-static void
-save_changes (EphyToolbarsModel *model)
-{
- if (!model->priv->loading)
- {
- egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
- model->priv->xml_file,
- EPHY_TOOLBARS_XML_VERSION);
- }
-}
-
-static void
-item_added (EphyToolbarsModel *model, int toolbar_position, int position)
-{
- const char *i_name;
- gboolean is_separator;
-
- egg_toolbars_model_item_nth (EGG_TOOLBARS_MODEL (model), toolbar_position,
- position, &is_separator, &i_name, NULL);
- if (!is_separator)
- {
- connect_item (model, i_name);
- }
-
- save_changes (model);
-}
-
-static void
-item_removed (EphyToolbarsModel *model, int toolbar_position, int position)
-{
- save_changes (model);
-}
-
-static void
-toolbar_added (EphyToolbarsModel *model, int position)
-{
- save_changes (model);
- update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
-}
-
-static void
-toolbar_removed (EphyToolbarsModel *model, int position)
-{
- save_changes (model);
- update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
-}
-
-static void
-ephy_toolbars_model_init (EphyToolbarsModel *t)
-{
- t->priv = EPHY_TOOLBARS_MODEL_GET_PRIVATE (t);
-
- t->priv->bookmarks = NULL;
- t->priv->loading = FALSE;
- t->priv->xml_file = g_build_filename (ephy_dot_dir (),
- "epiphany-toolbars.xml",
- NULL);
-
- g_signal_connect (t, "item_added", G_CALLBACK (item_added), NULL);
- g_signal_connect (t, "item_removed", G_CALLBACK (item_removed), NULL);
- g_signal_connect (t, "toolbar_added", G_CALLBACK (toolbar_added), NULL);
- g_signal_connect (t, "toolbar_removed", G_CALLBACK (toolbar_removed), NULL);
-}
-
-static void
-ephy_toolbars_model_finalize (GObject *object)
-{
- EphyToolbarsModel *t = EPHY_TOOLBARS_MODEL (object);
- save_changes (t);
-
- g_object_unref (t->priv->bookmarks);
-
- g_free (t->priv->xml_file);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-EphyToolbarsModel *
-ephy_toolbars_model_new (EphyBookmarks *bookmarks)
-{
- return EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL,
- "bookmarks", bookmarks,
- NULL));
-}
-
-void
-ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model,
- long id)
-{
- char *action_name;
- int toolbar, position;
-
- action_name = ephy_toolbars_model_get_action_name (model, id);
- g_return_if_fail (action_name != NULL);
-
- if (get_toolbar_and_item_pos (model, action_name, &toolbar, &position))
- {
- egg_toolbars_model_remove_item (EGG_TOOLBARS_MODEL (model),
- toolbar, position);
- }
-
- g_free (action_name);
-}
-
-void
-ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model,
- gboolean topic,
- long id)
-{
- char *name;
- int toolbar_position;
-
- toolbar_position = get_toolbar_pos (model, "BookmarksBar");
- g_return_if_fail (toolbar_position != -1);
-
- name = ephy_toolbars_model_get_action_name (model, id);
- egg_toolbars_model_add_item (EGG_TOOLBARS_MODEL (model),
- toolbar_position, -1, name,
- topic ? EPHY_DND_TOPIC_TYPE :
- EPHY_DND_URL_TYPE);
- g_free (name);
+ g_type_class_add_private (object_class, sizeof (EphyToolbarsModelPrivate));
}
-gboolean
-ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
- long id)
+EggToolbarsModel *
+ephy_toolbars_model_new (void)
{
- char *action_name;
- gboolean found;
- int toolbar, pos;
-
- action_name = ephy_toolbars_model_get_action_name (model, id);
- g_return_val_if_fail (action_name != NULL, FALSE);
-
- found = get_toolbar_and_item_pos (model, action_name, &toolbar, &pos);
-
- g_free (action_name);
-
- return found;
+ return EGG_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL, NULL));
}
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index 09f2aed55..8c71f0c98 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -33,9 +34,9 @@ G_BEGIN_DECLS
#define EPHY_IS_TOOLBARS_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TOOLBARS_MODEL))
#define EPHY_TOOLBARS_MODEL_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TOOLBARS_MODEL, EphyToolbarsModelClass))
-typedef struct EphyToolbarsModelClass EphyToolbarsModelClass;
-typedef struct EphyToolbarsModel EphyToolbarsModel;
-typedef struct EphyToolbarsModelPrivate EphyToolbarsModelPrivate;
+typedef struct EphyToolbarsModelClass EphyToolbarsModelClass;
+typedef struct EphyToolbarsModel EphyToolbarsModel;
+typedef struct EphyToolbarsModelPrivate EphyToolbarsModelPrivate;
struct EphyToolbarsModel
{
@@ -50,25 +51,11 @@ struct EphyToolbarsModelClass
EggToolbarsModelClass parent_class;
};
-GType ephy_toolbars_model_get_type (void);
+GType ephy_toolbars_model_get_type (void);
-EphyToolbarsModel *ephy_toolbars_model_new (EphyBookmarks *bookmarks);
+EggToolbarsModel *ephy_toolbars_model_new (void);
-void ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model,
- gboolean topic,
- long id);
-
-gboolean ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
- long id);
-
-void ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model,
- long id);
-
-char *ephy_toolbars_model_get_action_name (EphyToolbarsModel *model,
- long id);
-
-EphyNode *ephy_toolbars_model_get_node (EphyToolbarsModel *model,
- const char *action_name);
+void ephy_toolbars_model_load (EphyToolbarsModel *model);
G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index d9f241fa1..9de3366ae 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2000, 2001, 2002, 2003 Marco Pesenti Gritti
+ * Copyright (C) 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -40,7 +41,9 @@
#include "ephy-debug.h"
#include "ephy-file-helpers.h"
#include "ephy-statusbar.h"
+#include "egg-editable-toolbar.h"
#include "toolbar.h"
+#include "ephy-bookmarksbar.h"
#include "popup-commands.h"
#include "ephy-encoding-menu.h"
#include "ephy-tabs-menu.h"
@@ -318,6 +321,7 @@ struct EphyWindowPrivate
GtkWidget *menu_dock;
GtkWidget *exit_fullscreen_popup;
Toolbar *toolbar;
+ GtkWidget *bookmarksbar;
GtkWidget *statusbar;
GtkActionGroup *action_group;
GtkActionGroup *popups_action_group;
@@ -472,13 +476,13 @@ get_chromes_visibility (EphyWindow *window, gboolean *show_menubar,
switch (window->priv->mode)
{
case EPHY_WINDOW_MODE_NORMAL:
- *show_menubar = flags & EPHY_EMBED_CHROME_MENUBAR;
- *show_statusbar = flags & EPHY_EMBED_CHROME_STATUSBAR;
- *show_toolbar = flags & EPHY_EMBED_CHROME_TOOLBAR;
- *show_bookmarksbar = flags & EPHY_EMBED_CHROME_BOOKMARKSBAR;
+ *show_menubar = (flags & EPHY_EMBED_CHROME_MENUBAR) != 0;
+ *show_statusbar = (flags & EPHY_EMBED_CHROME_STATUSBAR) != 0;
+ *show_toolbar = (flags & EPHY_EMBED_CHROME_TOOLBAR) != 0;
+ *show_bookmarksbar = (flags & EPHY_EMBED_CHROME_BOOKMARKSBAR) != 0;
break;
case EPHY_WINDOW_MODE_FULLSCREEN:
- *show_toolbar = flags & EPHY_EMBED_CHROME_TOOLBAR;
+ *show_toolbar = (flags & EPHY_EMBED_CHROME_TOOLBAR) != 0;
*show_menubar = *show_statusbar = *show_bookmarksbar = FALSE;
break;
default:
@@ -500,27 +504,10 @@ sync_chromes_visibility (EphyWindow *window)
(GTK_UI_MANAGER (window->ui_merge), "/menubar");
g_assert (menubar != NULL);
- if (show_menubar)
- {
- gtk_widget_show (menubar);
- }
- else
- {
- gtk_widget_hide (menubar);
- }
-
- toolbar_set_visibility (window->priv->toolbar, show_toolbar,
- show_bookmarksbar);
-
-
- if (show_statusbar)
- {
- gtk_widget_show (window->priv->statusbar);
- }
- else
- {
- gtk_widget_hide (window->priv->statusbar);
- }
+ g_object_set (G_OBJECT (menubar), "visible", show_menubar, NULL);
+ g_object_set (G_OBJECT (window->priv->toolbar), "visible", show_toolbar, NULL);
+ g_object_set (G_OBJECT (window->priv->bookmarksbar), "visible", show_bookmarksbar, NULL);
+ g_object_set (G_OBJECT (window->priv->statusbar), "visible", show_statusbar, NULL);
}
static void
@@ -560,6 +547,9 @@ ephy_window_fullscreen (EphyWindow *window)
"size-changed", G_CALLBACK (size_changed_cb),
window);
+ g_object_set (G_OBJECT (window->priv->toolbar), "ToolbarsModel",
+ ephy_shell_get_toolbars_model (ephy_shell, TRUE), NULL);
+
sync_chromes_visibility (window);
}
@@ -575,6 +565,9 @@ ephy_window_unfullscreen (EphyWindow *window)
gtk_widget_destroy (window->priv->exit_fullscreen_popup);
window->priv->exit_fullscreen_popup = NULL;
+ g_object_set (G_OBJECT (window->priv->toolbar), "ToolbarsModel",
+ ephy_shell_get_toolbars_model (ephy_shell, FALSE), NULL);
+
sync_chromes_visibility (window);
}
@@ -1917,6 +1910,14 @@ browse_with_caret_notifier (GConfClient *client,
}
static void
+action_request_forward_cb (GObject *toolbar,
+ const char *name,
+ GObject *bookmarksbar)
+{
+ g_signal_emit_by_name (bookmarksbar, "action_request", name);
+}
+
+static void
ephy_window_init (EphyWindow *window)
{
EphyExtension *manager;
@@ -1945,6 +1946,7 @@ ephy_window_init (EphyWindow *window)
gtk_box_pack_start (GTK_BOX (window->priv->main_vbox),
GTK_WIDGET (window->priv->notebook),
TRUE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (window->priv->notebook));
window->priv->statusbar = ephy_statusbar_new ();
gtk_box_pack_start (GTK_BOX (window->priv->main_vbox),
@@ -1961,8 +1963,21 @@ ephy_window_init (EphyWindow *window)
window->priv->enc_menu = ephy_encoding_menu_new (window);
window->priv->bmk_menu = ephy_bookmarks_menu_new (window);
- /* create the toolbar */
+ /* create the toolbars */
window->priv->toolbar = toolbar_new (window);
+ window->priv->bookmarksbar = ephy_bookmarksbar_new (window);
+
+ /* forward the toolbar's action_request signal to the bookmarks toolbar,
+ * so the user can also have bookmarks on the normal toolbar
+ */
+ g_signal_connect (window->priv->toolbar, "action_request",
+ G_CALLBACK (action_request_forward_cb),
+ window->priv->bookmarksbar);
+
+ /* Add the toolbars to the window */
+ gtk_box_pack_end (GTK_BOX (window->priv->menu_dock),
+ window->priv->bookmarksbar,
+ FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (window->priv->menu_dock),
GTK_WIDGET (window->priv->toolbar),
FALSE, FALSE, 0);
@@ -1973,10 +1988,6 @@ ephy_window_init (EphyWindow *window)
manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell));
ephy_extension_attach_window (manager, window);
- /* show widgets */
- gtk_widget_show (GTK_WIDGET (window->priv->toolbar));
- gtk_widget_show (GTK_WIDGET (window->priv->notebook));
-
g_signal_connect (window, "window-state-event",
G_CALLBACK (ephy_window_state_event_cb),
window);
@@ -2150,9 +2161,7 @@ ephy_window_set_print_preview (EphyWindow *window, gboolean enabled)
* ephy_window_get_toolbar:
* @window: an #EphyWindow
*
- * Returns this window's toolbar as an #EggEditableToolbar. Note that this
- * toolbar is uneditable outside of Epiphany itself (i.e., extensions should not
- * access it).
+ * Returns this window's toolbar as an #EggEditableToolbar.
*
* Return value: an #EggEditableToolbar
**/
@@ -2165,6 +2174,22 @@ ephy_window_get_toolbar (EphyWindow *window)
}
/**
+ * ephy_window_get_bookmarksbar:
+ * @window: an #EphyWindow
+ *
+ * Returns this window's bookmarks toolbar, which is an #EggEditableToolbar.
+ *
+ * Return value: an #EggEditableToolbar
+ **/
+GtkWidget *
+ephy_window_get_bookmarksbar (EphyWindow *window)
+{
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+
+ return GTK_WIDGET (window->priv->bookmarksbar);
+}
+
+/**
* ephy_window_get_notebook:
* @window: an #EphyWindow
*
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 4370c8081..e1c6f4261 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -71,6 +71,8 @@ void ephy_window_set_print_preview (EphyWindow *window,
GtkWidget *ephy_window_get_toolbar (EphyWindow *window);
+GtkWidget *ephy_window_get_bookmarksbar (EphyWindow *window);
+
GtkWidget *ephy_window_get_notebook (EphyWindow *window);
GtkWidget *ephy_window_get_statusbar (EphyWindow *window);
diff --git a/src/toolbar.c b/src/toolbar.c
index 2a24815bd..d2a0d79e5 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -1,6 +1,7 @@
/*
- * Copyright (C) 2000 Marco Pesenti Gritti
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
* Copyright (C) 2001, 2002 Jorn Baayen
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -24,57 +25,42 @@
#endif
#include "toolbar.h"
-#include "ephy-file-helpers.h"
-#include "ephy-shell.h"
-#include "ephy-location-entry.h"
-#include "ephy-dnd.h"
-#include "ephy-spinner.h"
-#include "ephy-location-action.h"
#include "ephy-favicon-action.h"
-#include "ephy-topic-action.h"
#include "ephy-go-action.h"
+#include "ephy-location-entry.h"
+#include "ephy-location-action.h"
#include "ephy-navigation-action.h"
-#include "ephy-bookmark-action.h"
+#include "ephy-spinner.h"
+#include "ephy-dnd.h"
+#include "ephy-topic-action.h"
#include "ephy-zoom-action.h"
-#include "window-commands.h"
-#include "ephy-string.h"
-#include "ephy-debug.h"
-#include "ephy-new-bookmark.h"
+#include "ephy-shell.h"
#include "ephy-stock-icons.h"
-#include "ephy-toolbars-model.h"
+#include "window-commands.h"
#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtkuimanager.h>
-#include <gtk/gtktoolbar.h>
static void toolbar_class_init (ToolbarClass *klass);
static void toolbar_init (Toolbar *t);
static void toolbar_finalize (GObject *object);
static void toolbar_set_window (Toolbar *t, EphyWindow *window);
-static void
-toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void
-toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GtkTargetEntry drag_targets[] = {
- { EGG_TOOLBAR_ITEM_TYPE, 0, 0 },
- { EPHY_DND_TOPIC_TYPE, 0, 1 },
- { EPHY_DND_URL_TYPE, 0, 2 },
+static GtkTargetEntry drag_targets[] =
+{
+ { EGG_TOOLBAR_ITEM_TYPE, 0, 0 },
+ { EPHY_DND_TOPIC_TYPE, 0, 1 },
+ { EPHY_DND_URL_TYPE, 0, 2 }
};
static int n_drag_targets = G_N_ELEMENTS (drag_targets);
enum
{
PROP_0,
- PROP_EPHY_WINDOW
+ PROP_WINDOW
};
static GObjectClass *parent_class = NULL;
@@ -86,13 +72,9 @@ static GObjectClass *parent_class = NULL;
struct ToolbarPrivate
{
EphyWindow *window;
- GtkUIManager *ui_merge;
GtkActionGroup *action_group;
- gboolean visibility;
gboolean updating_address;
GtkWidget *spinner;
- GtkWidget *favicon;
- GtkWidget *go;
guint disable_arbitrary_url_notifier_id;
};
@@ -166,43 +148,7 @@ arbitrary_url_notifier (GConfClient *client,
static void
go_location_cb (GtkAction *action, char *location, EphyWindow *window)
{
- GdkEvent *event;
- gboolean new_tab = FALSE;
-
- event = gtk_get_current_event ();
- if (event != NULL)
- {
- if (event->type == GDK_BUTTON_RELEASE)
- {
- guint modifiers, button, state;
-
- modifiers = gtk_accelerator_get_default_mod_mask ();
- button = event->button.button;
- state = event->button.state;
-
- /* middle-click or control-click */
- if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
- (button == 2))
- {
- new_tab = TRUE;
- }
- }
-
- gdk_event_free (event);
- }
-
- if (new_tab)
- {
- ephy_shell_new_tab (ephy_shell, window,
- ephy_window_get_active_tab (window),
- location,
- EPHY_NEW_TAB_OPEN_PAGE |
- EPHY_NEW_TAB_IN_EXISTING_WINDOW);
- }
- else
- {
- ephy_window_load_url (window, location);
- }
+ ephy_window_load_url (window, location);
}
static void
@@ -212,131 +158,112 @@ zoom_to_level_cb (GtkAction *action, float zoom, EphyWindow *window)
}
static void
-bookmark_destroy_cb (EphyNode *node,
- Toolbar *t)
+toolbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GtkAction *action;
- char *name;
- EphyToolbarsModel *model;
- long id;
+ Toolbar *t = EPHY_TOOLBAR (object);
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ toolbar_set_window (t, g_value_get_object (value));
+ break;
+ }
+}
- id = ephy_node_get_id (node);
- name = ephy_toolbars_model_get_action_name (model, id);
- action = gtk_action_group_get_action (t->priv->action_group, name);
- if (action)
- {
- gtk_action_group_remove_action (t->priv->action_group, action);
- }
+static void
+toolbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ /* no readable properties */
+ g_assert_not_reached ();
+}
+
+static void
+toolbar_added_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *toolbar)
+{
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth (model, position);
+ g_return_if_fail (t_name != NULL);
- g_free (name);
+ egg_editable_toolbar_set_drag_dest
+ (toolbar, drag_targets, n_drag_targets, t_name);
}
static void
-toolbar_ensure_action (Toolbar *t,
- const char *name)
+toolbar_realize (GtkWidget *widget)
{
- GtkAction *action = NULL;
- EphyToolbarsModel *model;
- EphyBookmarks *bookmarks;
- EphyNode *bmks, *topics;
+ EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (widget);
+ Toolbar *toolbar = EPHY_TOOLBAR (widget);
+ EggToolbarsModel *model = egg_editable_toolbar_get_model (eggtoolbar);
+ int i, n_toolbars;
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- bmks = ephy_bookmarks_get_bookmarks (bookmarks);
- topics = ephy_bookmarks_get_keywords (bookmarks);
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
- LOG ("Ensure action %s", name)
+ g_signal_connect (model, "toolbar_added",
+ G_CALLBACK (toolbar_added_cb), toolbar);
- if (g_str_has_prefix (name, "GoBookmark-"))
+ /* now that the toolbar has been constructed, set drag dests */
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+ for (i = 0; i < n_toolbars; i++)
{
- EphyNode *node;
+ const char *t_name;
- node = ephy_toolbars_model_get_node (model,name);
- g_return_if_fail (node != NULL);
+ t_name = egg_toolbars_model_toolbar_nth (model, i);
+ g_return_if_fail (t_name != NULL);
- if (ephy_node_has_child (topics, node))
- {
- action = ephy_topic_action_new (name, ephy_node_get_id (node));
- }
- else if (ephy_node_has_child (bmks, node))
- {
- action = ephy_bookmark_action_new (name, ephy_node_get_id (node));
- }
+ egg_editable_toolbar_set_drag_dest
+ (eggtoolbar, drag_targets, n_drag_targets, t_name);
+ }
+}
- g_return_if_fail (action != NULL);
+static void
+toolbar_unrealize (GtkWidget *widget)
+{
+ EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (widget);
+ Toolbar *toolbar = EPHY_TOOLBAR (widget);
+ EggToolbarsModel *model = egg_editable_toolbar_get_model (eggtoolbar);
- g_signal_connect (action, "go_location",
- G_CALLBACK (go_location_cb), t->priv->window);
- gtk_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (toolbar_added_cb), toolbar);
- ephy_node_signal_connect_object (node,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (t));
- }
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
toolbar_class_init (ToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = toolbar_finalize;
object_class->set_property = toolbar_set_property;
object_class->get_property = toolbar_get_property;
+ widget_class->realize = toolbar_realize;
+ widget_class->unrealize = toolbar_unrealize;
g_object_class_install_property (object_class,
- PROP_EPHY_WINDOW,
+ PROP_WINDOW,
g_param_spec_object ("window",
"Window",
"Parent window",
EPHY_TYPE_WINDOW,
- G_PARAM_READWRITE |
+ G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (object_class, sizeof(ToolbarPrivate));
}
static void
-toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- Toolbar *t = EPHY_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_EPHY_WINDOW:
- toolbar_set_window (t, g_value_get_object (value));
- break;
- }
-}
-
-static void
-toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- Toolbar *t = EPHY_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_EPHY_WINDOW:
- g_value_set_object (value, t->priv->window);
- break;
- }
-}
-
-static void
sync_user_input_cb (EphyLocationAction *action, GParamSpec *pspec, Toolbar *t)
{
EphyTab *tab;
@@ -453,120 +380,22 @@ toolbar_setup_actions (Toolbar *t)
}
static void
-action_request_cb (EggEditableToolbar *etoolbar,
- char *action_name,
- gpointer data)
-{
- toolbar_ensure_action (EPHY_TOOLBAR (etoolbar), action_name);
-}
-
-static void
-init_bookmarks_toolbar (Toolbar *t)
-{
- EphyToolbarsModel *model;
- int i, n_toolbars;
-
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- 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, "BookmarksBar") == 0)
- {
- egg_editable_toolbar_set_drag_dest
- (EGG_EDITABLE_TOOLBAR (t),
- drag_targets, n_drag_targets,
- t_name);
- egg_toolbars_model_set_flags
- (EGG_TOOLBARS_MODEL (model),
- EGG_TB_MODEL_NOT_REMOVABLE, i);
- }
- }
-}
-
-static void
-init_normal_mode (Toolbar *t)
-{
- EphyToolbarsModel *model;
-
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
-
- g_object_set (G_OBJECT (t),
- "ToolbarsModel", model,
- NULL);
- init_bookmarks_toolbar (t);
-}
-
-static void
-init_fullscreen_mode (Toolbar *t)
-{
- EggToolbarsModel *model;
-
- model = EGG_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, TRUE));
-
- g_object_set (G_OBJECT (t),
- "ToolbarsModel", model,
- NULL);
-}
-
-static gboolean
-window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, Toolbar *t)
-{
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
- {
- gboolean fullscreen;
-
- fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
- if (fullscreen)
- {
- init_fullscreen_mode (t);
- }
- else
- {
- init_normal_mode (t);
- }
- }
-
- return FALSE;
-}
-
-static void
toolbar_set_window (Toolbar *t, EphyWindow *window)
{
+ GtkUIManager *manager;
+
g_return_if_fail (t->priv->window == NULL);
t->priv->window = window;
- t->priv->ui_merge = GTK_UI_MANAGER (window->ui_merge);
+ manager = GTK_UI_MANAGER (window->ui_merge);
toolbar_setup_actions (t);
- gtk_ui_manager_insert_action_group (t->priv->ui_merge,
+ gtk_ui_manager_insert_action_group (manager,
t->priv->action_group, 1);
- g_signal_connect (t, "action_request",
- G_CALLBACK (action_request_cb),
- NULL);
- g_signal_connect_object (window, "window-state-event",
- G_CALLBACK (window_state_event_cb),
- t, 0);
t->priv->disable_arbitrary_url_notifier_id = eel_gconf_notification_add
(CONF_LOCKDOWN_DISABLE_ARBITRARY_URL,
(GConfClientNotifyFunc)arbitrary_url_notifier, t);
-
- g_object_set (G_OBJECT (t),
- "MenuMerge", t->priv->ui_merge,
- NULL);
-
- init_normal_mode (t);
}
static void
@@ -604,11 +433,6 @@ toolbar_init (Toolbar *t)
{
t->priv = EPHY_TOOLBAR_GET_PRIVATE (t);
- t->priv->window = NULL;
- t->priv->ui_merge = NULL;
- t->priv->visibility = TRUE;
- t->priv->updating_address = FALSE;
-
create_spinner (t);
}
@@ -616,10 +440,15 @@ static void
toolbar_finalize (GObject *object)
{
Toolbar *t = EPHY_TOOLBAR (object);
+ EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (object);
eel_gconf_notification_remove
(t->priv->disable_arbitrary_url_notifier_id);
+ g_signal_handlers_disconnect_by_func
+ (egg_editable_toolbar_get_model (eggtoolbar),
+ G_CALLBACK (toolbar_added_cb), t);
+
g_object_unref (t->priv->action_group);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -632,6 +461,8 @@ toolbar_new (EphyWindow *window)
{
return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR,
"window", window,
+ "MenuMerge", window->ui_merge,
+ "ToolbarsModel", ephy_shell_get_toolbars_model (ephy_shell, FALSE),
NULL));
}
@@ -666,9 +497,6 @@ toolbar_set_location (Toolbar *t,
GtkActionGroup *action_group;
GtkAction *action;
- LOG ("toolbar set location %s", address)
- LOG ("updating is %d", t->priv->updating_address)
-
if (t->priv->updating_address) return;
action_group = t->priv->action_group;
@@ -722,55 +550,6 @@ toolbar_update_navigation_actions (Toolbar *t, gboolean back, gboolean forward,
}
void
-toolbar_set_visibility (Toolbar *t,
- gboolean normal_toolbars,
- gboolean bmk_toolbars)
-{
- EphyToolbarsModel *model;
- int i, n_toolbars;
-
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- 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, "BookmarksBar") == 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);
- }
- }
- }
-}
-
-void
toolbar_update_zoom (Toolbar *t, float zoom)
{
GtkActionGroup *action_group;
diff --git a/src/toolbar.h b/src/toolbar.h
index ff58e3f35..8ed3a52a3 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2002 Jorn Baayen
- *
+ * Copyright (C) 2003-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003-2004 Christian Persch
+ *
* 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)
@@ -78,10 +80,6 @@ void toolbar_update_navigation_actions (Toolbar *t,
void toolbar_update_zoom (Toolbar *t,
float zoom);
-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 266e9e405..83d5aeae7 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -42,7 +42,7 @@
#include "ephy-state.h"
#include "ephy-gui.h"
#include "ephy-zoom.h"
-#include "ephy-toolbars-model.h"
+#include "egg-toolbars-model.h"
#include "egg-editable-toolbar.h"
#include "egg-toolbar-editor.h"
@@ -592,6 +592,9 @@ void
window_cmd_view_fullscreen (GtkAction *action,
EphyWindow *window)
{
+ /* Otherwise the other toolbar layout shows briefly while switching */
+ gtk_widget_hide (ephy_window_get_toolbar (window));
+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
{
gtk_window_fullscreen (GTK_WINDOW (window));
@@ -806,30 +809,26 @@ window_cmd_edit_prefs (GtkAction *action,
static void
toolbar_editor_destroy_cb (GtkWidget *tbe,
- Toolbar *t)
+ EphyWindow *window)
{
- egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (t), FALSE);
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
+ (ephy_window_get_toolbar (window)), FALSE);
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
+ (ephy_window_get_bookmarksbar (window)), FALSE);
}
static void
toolbar_editor_response_cb (GtkDialog *dialog,
gint response_id,
- gpointer data)
+ EggToolbarsModel *model)
{
- EphyToolbarsModel *model;
- int n;
-
switch (response_id)
{
case GTK_RESPONSE_CLOSE:
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case RESPONSE_ADD_TOOLBAR:
- model = EPHY_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- n = egg_toolbars_model_n_toolbars (EGG_TOOLBARS_MODEL (model));
- egg_toolbars_model_add_toolbar (EGG_TOOLBARS_MODEL (model),
- n - 1, "UserCreated");
+ egg_toolbars_model_add_toolbar (model, -1, "UserCreated");
break;
case GTK_RESPONSE_HELP:
ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "to-edit-toolbars");
@@ -842,31 +841,28 @@ window_cmd_edit_toolbar (GtkAction *action,
EphyWindow *window)
{
GtkWidget *editor;
- EphyToolbarsModel *model;
+ EggToolbarsModel *model;
GtkWidget *t;
GtkWidget *dialog;
- model = EPHY_TOOLBARS_MODEL
+ model = EGG_TOOLBARS_MODEL
(ephy_shell_get_toolbars_model (ephy_shell, FALSE));
t = ephy_window_get_toolbar (window);
dialog = gtk_dialog_new ();
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_title (GTK_WINDOW (dialog), _("Toolbar Editor"));
- gtk_window_set_transient_for (GTK_WINDOW (dialog),
- GTK_WINDOW (window));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- editor = egg_toolbar_editor_new
- (GTK_UI_MANAGER (window->ui_merge),
- EGG_TOOLBARS_MODEL (model));
+ editor = egg_toolbar_editor_new (GTK_UI_MANAGER (window->ui_merge), model);
egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
ephy_file ("epiphany-toolbar.xml"));
gtk_container_set_border_width (GTK_CONTAINER (EGG_TOOLBAR_EDITOR (editor)), 5);
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
g_signal_connect (editor, "destroy",
- G_CALLBACK (toolbar_editor_destroy_cb),
- t);
+ G_CALLBACK (toolbar_editor_destroy_cb), window);
gtk_widget_show (editor);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
@@ -881,7 +877,7 @@ window_cmd_edit_toolbar (GtkAction *action,
GTK_STOCK_HELP, GTK_RESPONSE_HELP);
g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (toolbar_editor_response_cb), NULL);
+ G_CALLBACK (toolbar_editor_response_cb), model);
ephy_state_add_window (dialog,
"toolbar_editor",
500, 330,
@@ -889,6 +885,8 @@ window_cmd_edit_toolbar (GtkAction *action,
gtk_widget_show (dialog);
egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (t), TRUE);
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (ephy_window_get_bookmarksbar (window)), TRUE);
}
void