From 56b18a72cbde121e7999846d99bb3e8eb91d4068 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 29 Apr 2003 08:50:19 +0000 Subject: Remove add_icon_column func and add the functionality to the normal 2003-04-29 Marco Pesenti Gritti * lib/widgets/ephy-node-view.c: (ephy_node_view_add_column): * lib/widgets/ephy-node-view.h: Remove add_icon_column func and add the functionality to the normal add_column. The icon will be packed in the same column. * src/bookmarks/ephy-bookmarks-editor.c: (entry_selection_changed_cb), (add_entry_monitor), (add_text_renderer_monitor), (cmd_add_topic), (cmd_rename), (build_search_box), (ephy_bookmarks_editor_construct), (toolbar_items_changed_cb), (ephy_bookmarks_editor_init): Fix for api change. Deal with 2 more sensitivity cases: bookmarks added by dnd to the toolbar and treeview text renderers. Remove hints until we have more columns. * src/ephy-history-window.c: (ephy_history_window_construct): Fix for new api * src/ephy-toolbars-model.c: (impl_add_item): Dont check if normal items are already in the toolbar: fix warnings. --- src/bookmarks/ephy-bookmarks-editor.c | 71 +++++++++++++++++++++++++---------- src/ephy-history-window.c | 11 ++---- src/ephy-toolbars-model.c | 12 ++++-- 3 files changed, 64 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index cf4c7c619..d314ab660 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -82,6 +82,7 @@ static void ephy_bookmarks_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor); static void search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor); @@ -203,6 +204,36 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = { }; static guint ephy_bookmark_popup_n_entries = G_N_ELEMENTS (ephy_bookmark_popup_entries); +static void +entry_selection_changed_cb (GtkWidget *widget, GParamSpec *pspec, EphyBookmarksEditor *editor) +{ + ephy_bookmarks_editor_update_menu (editor); +} + +static void +add_entry_monitor (EphyBookmarksEditor *editor, GtkWidget *entry) +{ + g_signal_connect (G_OBJECT (entry), + "notify::selection-bound", + G_CALLBACK (entry_selection_changed_cb), + editor); + g_signal_connect (G_OBJECT (entry), + "notify::cursor-position", + G_CALLBACK (entry_selection_changed_cb), + editor); +} + +static void +add_text_renderer_monitor (EphyBookmarksEditor *editor) +{ + GtkWidget *entry; + + entry = gtk_window_get_focus (GTK_WINDOW (editor)); + g_return_if_fail (GTK_IS_EDITABLE (entry)); + + add_entry_monitor (editor, entry); +} + static void cmd_add_topic (EggAction *action, EphyBookmarksEditor *editor) @@ -213,6 +244,7 @@ cmd_add_topic (EggAction *action, _("Type a topic")); ephy_node_view_select_node (EPHY_NODE_VIEW (editor->priv->key_view), node); ephy_node_view_edit (EPHY_NODE_VIEW (editor->priv->key_view)); + add_text_renderer_monitor (editor); } static void @@ -234,6 +266,7 @@ cmd_rename (EggAction *action, { ephy_node_view_edit (EPHY_NODE_VIEW (editor->priv->key_view)); } + add_text_renderer_monitor (editor); } static GtkWidget * @@ -937,12 +970,6 @@ search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor) g_free (search_text); } -static void -search_selection_changed_cb (GtkWidget *widget, GParamSpec *pspec, EphyBookmarksEditor *editor) -{ - ephy_bookmarks_editor_update_menu (editor); -} - static GtkWidget * build_search_box (EphyBookmarksEditor *editor) { @@ -960,14 +987,7 @@ build_search_box (EphyBookmarksEditor *editor) g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (search_entry_changed_cb), editor); - g_signal_connect (G_OBJECT (entry), - "notify::selection-bound", - G_CALLBACK (search_selection_changed_cb), - editor); - g_signal_connect (G_OBJECT (entry), - "notify::cursor-position", - G_CALLBACK (search_selection_changed_cb), - editor); + add_entry_monitor (editor, entry); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -1139,7 +1159,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) EPHY_NODE_KEYWORD_PROP_NAME, EPHY_NODE_KEYWORD_PROP_PRIORITY, EPHY_NODE_VIEW_AUTO_SORT | - EPHY_NODE_VIEW_EDITABLE); + EPHY_NODE_VIEW_EDITABLE, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), key_view); gtk_widget_set_size_request (key_view, 130, -1); gtk_widget_show (key_view); @@ -1186,16 +1206,15 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) /* Bookmarks View */ bm_view = ephy_node_view_new (node, editor->priv->bookmarks_filter); add_focus_monitor (editor, bm_view); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (bm_view), TRUE); ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view), bmk_drag_types, n_bmk_drag_types, EPHY_NODE_BMK_PROP_LOCATION); - ephy_node_view_add_icon_column (EPHY_NODE_VIEW (bm_view), provide_favicon); ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Title"), G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, -1, EPHY_NODE_VIEW_AUTO_SORT | - EPHY_NODE_VIEW_EDITABLE); + EPHY_NODE_VIEW_EDITABLE, + provide_favicon); gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view); gtk_widget_show (bm_view); editor->priv->bm_view = bm_view; @@ -1216,7 +1235,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) "changed", G_CALLBACK (view_selection_changed_cb), editor); - + ephy_state_add_window (GTK_WIDGET(editor), "bookmarks_editor", 450, 400); @@ -1315,10 +1334,24 @@ 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 = g_new0 (EphyBookmarksEditorPrivate, 1); editor->priv->tb_model = ephy_shell_get_toolbars_model (ephy_shell); + + g_signal_connect (editor->priv->tb_model, "item_added", + G_CALLBACK (toolbar_items_changed_cb), editor); + g_signal_connect (editor->priv->tb_model, "item_removed", + G_CALLBACK (toolbar_items_changed_cb), editor); } diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index cb6fc9a27..3f4fd8540 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -872,12 +872,12 @@ ephy_history_window_construct (EphyHistoryWindow *editor) EPHY_NODE_PAGE_PROP_LOCATION); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sites_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - ephy_node_view_add_icon_column (EPHY_NODE_VIEW (sites_view), provide_favicon); ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"), G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, EPHY_NODE_PAGE_PROP_PRIORITY, - EPHY_NODE_VIEW_AUTO_SORT); + EPHY_NODE_VIEW_AUTO_SORT, + provide_favicon); gtk_container_add (GTK_CONTAINER (scrolled_window), sites_view); gtk_widget_show (sites_view); editor->priv->sites_view = sites_view; @@ -915,15 +915,12 @@ ephy_history_window_construct (EphyHistoryWindow *editor) EPHY_NODE_PAGE_PROP_LOCATION); col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, - -1, EPHY_NODE_VIEW_USER_SORT); + -1, EPHY_NODE_VIEW_USER_SORT, NULL); gtk_tree_view_column_set_max_width (col, 250); col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Location"), G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, - -1, EPHY_NODE_VIEW_USER_SORT); + -1, EPHY_NODE_VIEW_USER_SORT, NULL); gtk_tree_view_column_set_max_width (col, 200); -/* col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Last Visit"), - G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LAST_VISIT, - -1, EPHY_NODE_VIEW_USER_SORT);*/ gtk_container_add (GTK_CONTAINER (scrolled_window), pages_view); gtk_widget_show (pages_view); editor->priv->pages_view = pages_view; diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c index f4fb3a0d2..43a081e22 100755 --- a/src/ephy-toolbars-model.c +++ b/src/ephy-toolbars-model.c @@ -78,7 +78,7 @@ impl_add_item (EggToolbarsModel *t, EphyBookmarks *bookmarks; char *action_name = NULL; const char *res; - gboolean topic = FALSE; + gboolean topic = FALSE, normal_item = FALSE; int id = -1; LOG ("Add item %s", name) @@ -88,7 +88,7 @@ impl_add_item (EggToolbarsModel *t, if (gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) == type) { GList *nodes; - + topic = TRUE; nodes = ephy_dnd_node_list_extract_nodes (name); id = ephy_node_get_id (EPHY_NODE (nodes->data)); @@ -99,16 +99,20 @@ impl_add_item (EggToolbarsModel *t, { GList *nodes; - topic = FALSE; nodes = ephy_dnd_node_list_extract_nodes (name); id = ephy_node_get_id (EPHY_NODE (nodes->data)); action_name = g_strdup_printf ("GoBookmarkId%d", id); g_list_free (nodes); } + else + { + normal_item = TRUE; + } res = action_name ? action_name : name; - if (!ephy_toolbars_model_has_bookmark (EPHY_TOOLBARS_MODEL (t), topic, id)) + if (normal_item || + !ephy_toolbars_model_has_bookmark (EPHY_TOOLBARS_MODEL (t), topic, id)) { EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item (t, toolbar_position, position, type, res); -- cgit v1.2.3