aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-toolbars-model.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-08-09 00:21:19 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-08-09 00:21:19 +0800
commitddf8fccbe9c2afd3c432c06bf2240c398732c279 (patch)
tree2ae582aa50b0a99a7345e79ce56a5002711bab41 /src/ephy-toolbars-model.c
parentfdba09646384da9c8526371507f75be15c9f2c17 (diff)
downloadgsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar.gz
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar.bz2
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar.lz
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar.xz
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.tar.zst
gsoc2013-epiphany-ddf8fccbe9c2afd3c432c06bf2240c398732c279.zip
Update
2003-08-08 Marco Pesenti Gritti <marco@it.gnome.org> * lib/egg/egg-toolbars-model.c: * lib/egg/egg-toolbars-model.h: Update * src/ephy-toolbars-model.c: (get_toolbar_and_item_pos), (impl_add_item), (ephy_toolbars_model_class_init), (get_toolbar_pos): Do not add duped bookmarks to toolbars
Diffstat (limited to 'src/ephy-toolbars-model.c')
-rwxr-xr-xsrc/ephy-toolbars-model.c103
1 files changed, 64 insertions, 39 deletions
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index 6bfce6264..3933be965 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -228,6 +228,69 @@ impl_get_item_type (EggToolbarsModel *t,
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++)
+ {
+ 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;
+
+ i_name = egg_toolbars_model_item_nth
+ (EGG_TOOLBARS_MODEL (model), t, i,
+ &is_separator);
+ g_return_val_if_fail (i_name != NULL, FALSE);
+
+ if (strcmp (i_name, action_name) == 0)
+ {
+ if (toolbar) *toolbar = t;
+ if (position) *position = i;
+
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+impl_add_item (EggToolbarsModel *t,
+ int toolbar_position,
+ int position,
+ const char *id,
+ const char *type)
+{
+ EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (t);
+ gboolean is_bookmark;
+
+ is_bookmark = strcmp (type, EPHY_DND_TOPIC_TYPE) == 0 ||
+ strcmp (type, EPHY_DND_URL_TYPE) == 0;
+
+ if (!is_bookmark || !get_toolbar_and_item_pos (model, id, NULL, NULL))
+ {
+ return EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item
+ (t, toolbar_position, position, id, type);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
static void
connect_item (EphyToolbarsModel *model,
const char *name)
@@ -322,6 +385,7 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
object_class->set_property = ephy_toolbars_model_set_property;
object_class->get_property = ephy_toolbars_model_get_property;
+ etm_class->add_item = impl_add_item;
etm_class->get_item_id = impl_get_item_id;
etm_class->get_item_name = impl_get_item_name;
etm_class->get_item_type = impl_get_item_type;
@@ -454,45 +518,6 @@ get_toolbar_pos (EphyToolbarsModel *model,
return -1;
}
-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++)
- {
- 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;
-
- i_name = egg_toolbars_model_item_nth
- (EGG_TOOLBARS_MODEL (model), t, i,
- &is_separator);
- g_return_val_if_fail (i_name != NULL, FALSE);
-
- if (strcmp (i_name, action_name) == 0)
- {
- *toolbar = t;
- *position = i;
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
void
ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model,
long id)