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 | |
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.
-rw-r--r-- | ChangeLog | 23 | ||||
-rwxr-xr-x | lib/egg/egg-toolbars-model.c | 5 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.c | 48 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-properties.c | 42 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 56 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.h | 3 | ||||
-rwxr-xr-x | src/ephy-toolbars-model.c | 130 | ||||
-rwxr-xr-x | src/ephy-toolbars-model.h | 16 |
8 files changed, 276 insertions, 47 deletions
@@ -1,3 +1,26 @@ +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. + 2003-04-25 David Bordoley <bordoley@msu.edu> * src/ephy-history-window.c: (cmd_bookmark_page): diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c index cc54e6fb1..8d92da83a 100755 --- a/lib/egg/egg-toolbars-model.c +++ b/lib/egg/egg-toolbars-model.c @@ -223,6 +223,7 @@ impl_add_item (EggToolbarsModel *t, GNode *parent_node; GNode *node; EggToolbarsItem *item; + int real_position; g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), NULL); g_return_val_if_fail (name != NULL, NULL); @@ -232,8 +233,10 @@ impl_add_item (EggToolbarsModel *t, node = g_node_new (item); g_node_insert (parent_node, position, node); + real_position = g_node_child_position (parent_node, node); + g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_ADDED], 0, - toolbar_position, position); + toolbar_position, real_position); return item->action_name; } diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index 154e432fd..cccf43ac0 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -109,6 +109,8 @@ static gboolean egg_toolbar_focus (GtkWidget *widget, GtkDirectionType dir); static void egg_toolbar_screen_changed (GtkWidget *widget, GdkScreen *previous_screen); +static void egg_toolbar_map (GtkWidget *widget); +static void egg_toolbar_unmap (GtkWidget *widget); static void egg_toolbar_drag_leave (GtkWidget *widget, GdkDragContext *context, @@ -269,7 +271,9 @@ egg_toolbar_class_init (EggToolbarClass *klass) widget_class->screen_changed = egg_toolbar_screen_changed; widget_class->realize = egg_toolbar_realize; widget_class->unrealize = egg_toolbar_unrealize; - + widget_class->map = egg_toolbar_map; + widget_class->unmap = egg_toolbar_unmap; + widget_class->drag_leave = egg_toolbar_drag_leave; widget_class->drag_motion = egg_toolbar_drag_motion; @@ -561,6 +565,28 @@ egg_toolbar_get_property (GObject *object, } static void +egg_toolbar_map (GtkWidget *widget) +{ + EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (widget); + + GTK_WIDGET_CLASS (parent_class)->map (widget); + + if (priv->event_window) + gdk_window_show_unraised (priv->event_window); +} + +static void +egg_toolbar_unmap (GtkWidget *widget) +{ + EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (widget); + + if (priv->event_window) + gdk_window_hide (priv->event_window); + + GTK_WIDGET_CLASS (parent_class)->unmap (widget); +} + +static void egg_toolbar_paint_space_line (GtkWidget *widget, GdkRectangle *area, EggToolItem *item) @@ -910,6 +936,15 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) gtk_widget_style_get (widget, "internal_padding", &border_width, NULL); border_width += GTK_CONTAINER (toolbar)->border_width; + if (GTK_WIDGET_REALIZED (widget)) + { + gdk_window_move_resize (priv->event_window, + allocation->x + border_width, + allocation->y + border_width, + allocation->width - border_width * 2, + allocation->height - border_width * 2); + } + gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button), &arrow_requisition); @@ -1326,7 +1361,7 @@ style_change_notify (EggToolbar *toolbar) static void icon_size_change_notify (EggToolbar *toolbar) -{ +{ if (!toolbar->icon_size_set) { /* pretend it was set, then unset, thus reverting to new default */ @@ -1549,7 +1584,6 @@ egg_toolbar_drag_motion (GtkWidget *widget, } gdk_window_show (priv->drag_highlight); - gdk_window_raise (priv->drag_highlight); gdk_drag_status (context, context->suggested_action, time_); @@ -2176,9 +2210,11 @@ egg_toolbar_unset_icon_size (EggToolbar *toolbar) GtkSettings *settings = toolbar_get_settings (toolbar); if (settings) - g_object_get (settings, - "gtk-toolbar-icon-size", &size, - NULL); + { + g_object_get (settings, + "gtk-toolbar-icon-size", &size, + NULL); + } else size = DEFAULT_ICON_SIZE; diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c index 9d6fde632..fe2b2df76 100644 --- a/src/bookmarks/ephy-bookmark-properties.c +++ b/src/bookmarks/ephy-bookmark-properties.c @@ -54,6 +54,8 @@ struct EphyBookmarkPropertiesPrivate GtkWidget *title_entry; GtkWidget *location_entry; GtkWidget *topics_selector; + + EphyToolbarsModel *tb_model; }; enum @@ -215,22 +217,6 @@ bookmark_properties_response_cb (GtkDialog *dialog, } static void -update_checkbox (EphyBookmarkProperties *props, GtkWidget *checkbox, gulong prop) -{ - GValue value = { 0, }; - gboolean state; - - state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); - - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, state); - ephy_node_set_property (props->priv->bookmark, - prop, - &value); - g_value_unset (&value); -} - -static void update_entry (EphyBookmarkProperties *props, GtkWidget *entry, guint prop) { GValue value = { 0, }; @@ -276,7 +262,23 @@ location_entry_changed_cb (GtkWidget *entry, EphyBookmarkProperties *props) static void toolbar_checkbox_changed_cb (GtkWidget *checkbox, EphyBookmarkProperties *props) { - update_checkbox (props, checkbox, EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR); + gboolean state; + gulong id; + + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); + + id = ephy_node_get_id (props->priv->bookmark); + + if (state) + { + ephy_toolbars_model_add_bookmark + (props->priv->tb_model, FALSE, id); + } + else + { + ephy_toolbars_model_remove_bookmark + (props->priv->tb_model, FALSE, id); + } } static void @@ -317,6 +319,7 @@ build_ui (EphyBookmarkProperties *editor) char *str; const char *tmp; gboolean state; + gulong id; g_signal_connect (G_OBJECT (editor), "response", @@ -403,8 +406,8 @@ build_ui (EphyBookmarkProperties *editor) GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); checkbox = gtk_check_button_new_with_mnemonic (_("_Show in the bookmarks toolbar")); - state = ephy_node_get_property_boolean (editor->priv->bookmark, - EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR); + id = ephy_node_get_id (editor->priv->bookmark); + state = ephy_toolbars_model_has_bookmark (editor->priv->tb_model, FALSE, id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), state); g_signal_connect (checkbox, "toggled", G_CALLBACK (toolbar_checkbox_changed_cb), editor); @@ -429,6 +432,7 @@ ephy_bookmark_properties_init (EphyBookmarkProperties *editor) editor->priv = g_new0 (EphyBookmarkPropertiesPrivate, 1); editor->priv->bookmark = NULL; + editor->priv->tb_model = ephy_shell_get_toolbars_model (ephy_shell); } GtkWidget * diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 2e6302430..9ec953774 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -123,6 +123,7 @@ struct EphyBookmarksEditorPrivate EggMenuMerge *ui_merge; EggActionGroup *action_group; int priority_col; + EphyToolbarsModel *tb_model; }; enum @@ -253,18 +254,20 @@ cmd_show_in_the_toolbar (EggAction *action, { EphyNode *node; GList *selection; - GValue value = { 0, }; - gboolean state; + gboolean state, topic; + gulong id; if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view))) { selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view)); + topic = FALSE; } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view))) { selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view)); + topic = TRUE; } else { @@ -272,15 +275,19 @@ cmd_show_in_the_toolbar (EggAction *action, } node = EPHY_NODE (selection->data); - + id = ephy_node_get_id (node); state = EGG_TOGGLE_ACTION (action)->active; - g_value_init (&value, G_TYPE_BOOLEAN); - g_value_set_boolean (&value, state); - ephy_node_set_property (node, - EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR, - &value); - g_value_unset (&value); + if (state) + { + ephy_toolbars_model_add_bookmark + (editor->priv->tb_model, topic, id); + } + else + { + ephy_toolbars_model_remove_bookmark + (editor->priv->tb_model, topic, id); + } g_list_free (selection); } @@ -349,14 +356,14 @@ cmd_delete (EggAction *action, { EphyNodeViewPriority priority; GList *selected; - EphyNode *node; - + EphyNode *node; + selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view)); node = EPHY_NODE (selected->data); priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); if (priority == -1) priority = EPHY_NODE_VIEW_NORMAL_PRIORITY; - + if (priority == EPHY_NODE_VIEW_NORMAL_PRIORITY) { ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->key_view)); @@ -629,15 +636,17 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) { EphyNode *node = EPHY_NODE (selected->data); EphyNodeViewPriority priority; + gulong id; + + id = ephy_node_get_id (node); + show_in_toolbar = ephy_toolbars_model_has_bookmark + (editor->priv->tb_model, TRUE, id); priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); if (priority == -1) priority = EPHY_NODE_VIEW_NORMAL_PRIORITY; key_normal = (priority == EPHY_NODE_VIEW_NORMAL_PRIORITY); - show_in_toolbar = ephy_node_get_property_boolean - (node, EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR); - g_list_free (selected); } @@ -645,9 +654,11 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) if (bmk_focus && selected) { EphyNode *node = EPHY_NODE (selected->data); + gulong id; - show_in_toolbar = ephy_node_get_property_boolean - (node, EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR); + id = ephy_node_get_id (node); + show_in_toolbar = ephy_toolbars_model_has_bookmark + (editor->priv->tb_model, FALSE, id); g_list_free (selected); } @@ -706,7 +717,16 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) g_object_set (action, "sensitive", select_all, NULL); action = egg_action_group_get_action (action_group, "ShowInToolbar"); g_object_set (action, "sensitive", can_show_in_toolbar, NULL); + + g_signal_handlers_block_by_func + (G_OBJECT (EGG_TOGGLE_ACTION (action)), + G_CALLBACK (cmd_show_in_the_toolbar), + editor); egg_toggle_action_set_active (EGG_TOGGLE_ACTION (action), show_in_toolbar); + g_signal_handlers_unblock_by_func + (G_OBJECT (EGG_TOGGLE_ACTION (action)), + G_CALLBACK (cmd_show_in_the_toolbar), + editor); } static void @@ -1242,4 +1262,6 @@ static void ephy_bookmarks_editor_init (EphyBookmarksEditor *editor) { editor->priv = g_new0 (EphyBookmarksEditorPrivate, 1); + + editor->priv->tb_model = ephy_shell_get_toolbars_model (ephy_shell); } diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h index bb22e1a5c..0ab70af8e 100644 --- a/src/bookmarks/ephy-bookmarks.h +++ b/src/bookmarks/ephy-bookmarks.h @@ -44,8 +44,7 @@ enum EPHY_NODE_KEYWORD_PROP_NAME = 5, EPHY_NODE_BMK_PROP_SMART_LOCATION = 6, EPHY_NODE_BMK_PROP_ICON = 7, - EPHY_NODE_KEYWORD_PROP_PRIORITY = 8, - EPHY_NODE_BMK_PROP_SHOW_IN_TOOLBAR = 9 + EPHY_NODE_KEYWORD_PROP_PRIORITY = 8 }; struct EphyBookmarks 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); +} diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h index f01230494..dd84859f2 100755 --- a/src/ephy-toolbars-model.h +++ b/src/ephy-toolbars-model.h @@ -49,9 +49,21 @@ struct EphyToolbarsModelClass char *action_name); }; -GType ephy_toolbars_model_get_type (void); +GType ephy_toolbars_model_get_type (void); -EphyToolbarsModel *ephy_toolbars_model_new (void); +EphyToolbarsModel *ephy_toolbars_model_new (void); + +void ephy_toolbars_model_add_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id); + +gboolean ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id); + +void ephy_toolbars_model_remove_bookmark (EphyToolbarsModel *model, + gboolean topic, + gulong id); G_END_DECLS |