diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-26 02:46:54 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-26 02:46:54 +0800 |
commit | 95c5dbcfc4214c63c93318344f5b6de091677d5e (patch) | |
tree | 56ef3ecaf51b0dc473fd880c6debac7f1b752098 /src/ephy-toolbars-model.c | |
parent | e22d66b927f60c384f96c47aa5d4519ceb4f9c47 (diff) | |
download | gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar.gz gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar.bz2 gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar.lz gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar.xz gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.tar.zst gsoc2013-epiphany-95c5dbcfc4214c63c93318344f5b6de091677d5e.zip |
Update.
2003-04-25 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/egg/egg-toolbars-model.c:
* lib/egg/eggtoolbar.c:
Update.
* src/bookmarks/ephy-bookmark-properties.c:
(toolbar_checkbox_changed_cb), (build_ui),
(ephy_bookmark_properties_init):
* src/bookmarks/ephy-bookmarks-editor.c: (cmd_show_in_the_toolbar),
(cmd_delete), (ephy_bookmarks_editor_update_menu),
(ephy_bookmarks_editor_init):
* src/bookmarks/ephy-bookmarks.h:
* src/ephy-toolbars-model.c: (ephy_toolbars_model_new),
(get_item_pos), (get_action_name), (get_toolbar_pos),
(ephy_toolbars_model_remove_bookmark),
(ephy_toolbars_model_add_bookmark),
(ephy_toolbars_model_has_bookmark):
* src/ephy-toolbars-model.h:
Implement the checkbox to add bookmarks to the toolbar.
Diffstat (limited to 'src/ephy-toolbars-model.c')
-rwxr-xr-x | src/ephy-toolbars-model.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c index c67d427e3..99d55c295 100755 --- a/src/ephy-toolbars-model.c +++ b/src/ephy-toolbars-model.c @@ -22,6 +22,8 @@ #include "ephy-shell.h" #include "ephy-debug.h" +#include <string.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); @@ -168,3 +170,131 @@ ephy_toolbars_model_new (void) return t; } + +static int +get_item_pos (EphyToolbarsModel *model, + int toolbar_pos, + const char *name) +{ + int i, n_items; + + n_items = egg_toolbars_model_n_items + (EGG_TOOLBARS_MODEL (model), toolbar_pos); + + 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), toolbar_pos, i, + &is_separator); + if (!is_separator && strcmp (name, i_name) == 0) + { + return i; + } + } + + return -1; +} + +static char * +get_action_name (gboolean topic, gulong id) +{ + char *action_name; + + if (topic) + { + action_name = g_strdup_printf ("GoTopicId%ld", id); + } + else + { + action_name = g_strdup_printf ("GoBookmarkId%ld", id); + } + + return action_name; +} + +static int +get_toolbar_pos (EphyToolbarsModel *model, + const char *name) +{ + int i, n_toolbars; + + 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); + if (strcmp (name, t_name) == 0) + { + return i; + } + } + + return -1; +} + +void +ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id) +{ + char *action_name; + int toolbar_position, position; + + action_name = get_action_name (topic, id); + + toolbar_position = get_toolbar_pos (model, "BookmarksToolbar"); + g_return_if_fail (toolbar_position != -1); + + position = get_item_pos (model, toolbar_position, action_name); + + egg_toolbars_model_remove_item (EGG_TOOLBARS_MODEL (model), + toolbar_position, position); + + g_free (action_name); +} + +void +ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id) +{ + char *action_name; + int toolbar_position; + + action_name = get_action_name (topic, id); + + toolbar_position = get_toolbar_pos (model, "BookmarksToolbar"); + g_return_if_fail (toolbar_position != -1); + + egg_toolbars_model_add_item (EGG_TOOLBARS_MODEL (model), + toolbar_position, -1, + 0, action_name); + + g_free (action_name); +} + +gboolean +ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id) +{ + char *action_name; + int toolbar_position, position; + + action_name = get_action_name (topic, id); + + toolbar_position = get_toolbar_pos (model, "BookmarksToolbar"); + g_return_val_if_fail (toolbar_position != -1, FALSE); + position = get_item_pos (model, toolbar_position, action_name); + + g_free (action_name); + + return (position != -1); +} |