aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarksbar-model.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-06-11 03:05:53 +0800
committerChristian Persch <chpe@src.gnome.org>2004-06-11 03:05:53 +0800
commit27ae6e03f698835c1683c03b7cfc0e401d0f601f (patch)
treee0071b3ad7fa45afb0d97930a4deacde7c51ccaf /src/bookmarks/ephy-bookmarksbar-model.c
parentee67c4e456ce1bee49da717ee86ae85e76499e6d (diff)
downloadgsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar.gz
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar.bz2
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar.lz
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar.xz
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.tar.zst
gsoc2013-epiphany-27ae6e03f698835c1683c03b7cfc0e401d0f601f.zip
Merging bookmarksbar-separation branch.
2004-06-10 Christian Persch <chpe@cvs.gnome.org> Merging bookmarksbar-separation branch.
Diffstat (limited to 'src/bookmarks/ephy-bookmarksbar-model.c')
-rwxr-xr-xsrc/bookmarks/ephy-bookmarksbar-model.c114
1 files changed, 45 insertions, 69 deletions
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,