From d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8 Mon Sep 17 00:00:00 2001 From: David Bordoley Date: Thu, 27 Mar 2003 13:39:33 +0000 Subject: Reorganize the menus a bit. Unifiy topic/bookmarks rename/delete items. 2003-03-27 David Bordoley * data/ui/epiphany-bookmark-editor-ui.xml.in: * src/bookmarks/ephy-bookmarks-editor.c: (cmd_rename), (cmd_delete), (cmd_cut), (cmd_copy), (cmd_paste), (cmd_select_all), (keyword_node_key_pressed_cb), (keyword_node_show_popup_cb), (ephy_bookmarks_editor_construct): Reorganize the menus a bit. Unifiy topic/bookmarks rename/delete items. Add text editting menu items to the edit menu. Add a topic context menu. * src/bookmarks/ephy-node-view.[c-h]: (ephy_node_view_select_all), (ephy_node_view_has_focus): New functions. * src/bookmarks/ephy-topics-selector.c: (set_sort_column_id), (topic_clicked), (ephy_topics_build_ui): Sort topics case insensitively. Add/remove topics using a single click. --- ChangeLog | 19 +++ data/ui/epiphany-bookmark-editor-ui.xml.in | 25 ++-- src/bookmarks/ephy-bookmarks-editor.c | 182 +++++++++++++++++++++-------- src/bookmarks/ephy-node-view.c | 25 ++++ src/bookmarks/ephy-node-view.h | 4 + src/bookmarks/ephy-topics-selector.c | 42 ++++++- 6 files changed, 239 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee997ce59..c87e3cfe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-03-27 David Bordoley + + * data/ui/epiphany-bookmark-editor-ui.xml.in: + * src/bookmarks/ephy-bookmarks-editor.c: (cmd_rename), + (cmd_delete), (cmd_cut), (cmd_copy), (cmd_paste), + (cmd_select_all), (keyword_node_key_pressed_cb), + (keyword_node_show_popup_cb), (ephy_bookmarks_editor_construct): + Reorganize the menus a bit. Unifiy topic/bookmarks + rename/delete items. Add text editting menu items + to the edit menu. Add a topic context menu. + + * src/bookmarks/ephy-node-view.[c-h]: (ephy_node_view_select_all), + (ephy_node_view_has_focus): + New functions. + + * src/bookmarks/ephy-topics-selector.c: (set_sort_column_id), + (topic_clicked), (ephy_topics_build_ui): + Sort topics case insensitively. Add/remove topics using a single click. + 2003-03-26 Patanjali Somayaji Added help support, help manual and scrollkeeper updates diff --git a/data/ui/epiphany-bookmark-editor-ui.xml.in b/data/ui/epiphany-bookmark-editor-ui.xml.in index a3f3c33cb..64232c111 100644 --- a/data/ui/epiphany-bookmark-editor-ui.xml.in +++ b/data/ui/epiphany-bookmark-editor-ui.xml.in @@ -6,17 +6,19 @@ - + + + + - - - - - + + + + @@ -27,11 +29,16 @@ - - + + - + + + + + + diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index fdbba76c9..39587c4e6 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -58,19 +58,23 @@ static void cmd_open_bookmarks_in_tabs (EggAction *action, EphyBookmarksEditor *editor); static void cmd_open_bookmarks_in_browser (EggAction *action, EphyBookmarksEditor *editor); -static void cmd_remove_bookmarks (EggAction *action, +static void cmd_delete (EggAction *action, EphyBookmarksEditor *editor); static void cmd_bookmark_properties (EggAction *action, EphyBookmarksEditor *editor); static void cmd_add_topic (EggAction *action, EphyBookmarksEditor *editor); -static void cmd_remove_topic (EggAction *action, +static void cmd_rename (EggAction *action, EphyBookmarksEditor *editor); -static void cmd_rename_bookmark (EggAction *action, +static void cmd_close (EggAction *action, EphyBookmarksEditor *editor); -static void cmd_rename_topic (EggAction *action, +static void cmd_cut (EggAction *action, EphyBookmarksEditor *editor); -static void cmd_close (EggAction *action, +static void cmd_copy (EggAction *action, + EphyBookmarksEditor *editor); +static void cmd_paste (EggAction *action, + EphyBookmarksEditor *editor); +static void cmd_select_all (EggAction *action, EphyBookmarksEditor *editor); struct EphyBookmarksEditorPrivate @@ -121,17 +125,23 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = { { "OpenInTab", N_("Open In New _Tab"), NULL, "O", NULL, G_CALLBACK (cmd_open_bookmarks_in_tabs), NULL }, - { "RenameBookmark", N_("_Rename Bookmark"), NULL, NULL, - NULL, G_CALLBACK (cmd_rename_bookmark), NULL }, + { "Cut", N_("Cu_t"), GTK_STOCK_CUT, "X", + NULL, G_CALLBACK (cmd_cut), NULL }, + + { "Copy", N_("_Copy"), GTK_STOCK_COPY, "C", + NULL, G_CALLBACK (cmd_copy), NULL }, + + { "Paste", N_("_Paste"), GTK_STOCK_PASTE, "V", + NULL, G_CALLBACK (cmd_paste), NULL }, - { "RenameTopic", N_("R_ename Topic"), NULL, NULL, - NULL, G_CALLBACK (cmd_rename_topic), NULL }, + { "SelectAll", N_("Select _All"), NULL, "A", + NULL, G_CALLBACK (cmd_select_all), NULL }, - { "RemoveBookmark", N_("_Delete Bookmark"), GTK_STOCK_DELETE, NULL, - NULL, G_CALLBACK (cmd_remove_bookmarks), NULL }, + { "Rename", N_("_Rename"), NULL, "F2", + NULL, G_CALLBACK (cmd_rename), NULL }, - { "RemoveTopic", N_("D_elete Topic"), NULL, NULL, - NULL, G_CALLBACK (cmd_remove_topic), NULL }, + { "Delete", N_("_Delete"), GTK_STOCK_DELETE, NULL, + NULL, G_CALLBACK (cmd_delete), NULL }, { "Properties", N_("_Properties"), GTK_STOCK_PROPERTIES, "Return", NULL, G_CALLBACK (cmd_bookmark_properties), NULL }, @@ -153,21 +163,6 @@ cmd_add_topic (EggAction *action, ephy_node_view_edit (editor->priv->key_view); } -static void -cmd_remove_topic (EggAction *action, - EphyBookmarksEditor *editor) -{ - GList *selection; - - selection = ephy_node_view_get_selection (editor->priv->key_view); - if (selection) - { - EphyNode *node = EPHY_NODE (selection->data); - ephy_bookmarks_remove_keyword (editor->priv->bookmarks, node); - g_list_free (selection); - } -} - static void cmd_close (EggAction *action, EphyBookmarksEditor *editor) @@ -176,17 +171,17 @@ cmd_close (EggAction *action, } static void -cmd_rename_topic (EggAction *action, - EphyBookmarksEditor *editor) -{ - ephy_node_view_edit (editor->priv->key_view); -} - -static void -cmd_rename_bookmark (EggAction *action, - EphyBookmarksEditor *editor) -{ - ephy_node_view_edit (editor->priv->bm_view); +cmd_rename (EggAction *action, + EphyBookmarksEditor *editor) +{ + if (ephy_node_view_has_focus (editor->priv->bm_view)) + { + ephy_node_view_edit (editor->priv->bm_view); + } + else if (ephy_node_view_has_focus (editor->priv->key_view)) + { + ephy_node_view_edit (editor->priv->key_view); + } } static GtkWidget * @@ -261,10 +256,17 @@ cmd_open_bookmarks_in_browser (EggAction *action, } static void -cmd_remove_bookmarks (EggAction *action, - EphyBookmarksEditor *editor) +cmd_delete (EggAction *action, + EphyBookmarksEditor *editor) { - ephy_node_view_remove (editor->priv->bm_view); + if (ephy_node_view_has_focus (editor->priv->bm_view)) + { + ephy_node_view_remove (editor->priv->bm_view); + } + else if (ephy_node_view_has_focus (editor->priv->key_view)) + { + ephy_node_view_remove (editor->priv->key_view); + } } static void @@ -290,6 +292,59 @@ cmd_bookmark_properties (EggAction *action, } } +static void +cmd_cut (EggAction *action, + EphyBookmarksEditor *editor) +{ + GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor)); + + if (GTK_IS_EDITABLE (widget)) + { + gtk_editable_cut_clipboard (GTK_EDITABLE (widget)); + } +} + +static void +cmd_copy (EggAction *action, + EphyBookmarksEditor *editor) +{ + GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor)); + + if (GTK_IS_EDITABLE (widget)) + { + gtk_editable_copy_clipboard (GTK_EDITABLE (widget)); + } +} + +static void +cmd_paste (EggAction *action, + EphyBookmarksEditor *editor) +{ + GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor)); + + if (GTK_IS_EDITABLE (widget)) + { + gtk_editable_paste_clipboard (GTK_EDITABLE (widget)); + } +} + +static void +cmd_select_all (EggAction *action, + EphyBookmarksEditor *editor) +{ + GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor)); + + if (GTK_IS_EDITABLE (widget)) + { + gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); + } + else if (ephy_node_view_has_focus (editor->priv->bm_view)) + { + ephy_node_view_select_all (editor->priv->bm_view); + } +} + + GType ephy_bookmarks_editor_get_type (void) { @@ -418,12 +473,12 @@ ephy_bookmarks_editor_show_popup_cb (GtkWidget *view, EphyBookmarksEditor *editor) { GtkWidget *widget; - + widget = egg_menu_merge_get_widget (editor->priv->ui_merge, "/popups/EphyBookmarkEditorPopup"); gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, gtk_get_current_event_time ()); -} +} static void ephy_bookmarks_editor_key_pressed_cb (GtkWidget *view, @@ -471,6 +526,22 @@ bookmarks_filter (EphyBookmarksEditor *editor, ephy_node_filter_done_changing (editor->priv->bookmarks_filter); } +static void +keyword_node_key_pressed_cb (GtkWidget *view, + GdkEventKey *event, + EphyBookmarksEditor *editor) +{ + switch (event->keyval) + { + case GDK_Delete: + ephy_node_view_remove (editor->priv->key_view); + break; + + default: + break; + } +} + static void keyword_node_selected_cb (EphyNodeView *view, EphyNode *node, @@ -489,6 +560,17 @@ keyword_node_selected_cb (EphyNodeView *view, } } +static void +keyword_node_show_popup_cb (GtkWidget *view, EphyBookmarksEditor *editor) +{ + GtkWidget *widget; + + widget = egg_menu_merge_get_widget (editor->priv->ui_merge, + "/popups/EphyBookmarkKeywordPopup"); + gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2, + gtk_get_current_event_time ()); +} + static void search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor) { @@ -617,7 +699,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_container_add (GTK_CONTAINER (editor->priv->menu_dock), hbox); gtk_widget_show (hbox); - + g_assert (editor->priv->bookmarks); node = ephy_bookmarks_get_keywords (editor->priv->bookmarks); @@ -635,11 +717,19 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) gtk_widget_set_size_request (GTK_WIDGET (key_view), 130, -1); gtk_widget_show (GTK_WIDGET (key_view)); editor->priv->key_view = key_view; + g_signal_connect (G_OBJECT (key_view), + "key_press_event", + G_CALLBACK (keyword_node_key_pressed_cb), + editor); g_signal_connect (G_OBJECT (key_view), "node_selected", G_CALLBACK (keyword_node_selected_cb), editor); - + g_signal_connect (G_OBJECT (key_view), + "show_popup", + G_CALLBACK (keyword_node_show_popup_cb), + editor); + vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); diff --git a/src/bookmarks/ephy-node-view.c b/src/bookmarks/ephy-node-view.c index 4270d58f2..d3b578179 100644 --- a/src/bookmarks/ephy-node-view.c +++ b/src/bookmarks/ephy-node-view.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "eggtreemodelfilter.h" @@ -660,6 +661,30 @@ ephy_node_view_get_selection (EphyNodeView *view) return list; } +void +ephy_node_view_select_all (EphyNodeView *view) +{ + GtkTreeSelection *sel = gtk_tree_view_get_selection (view->priv->treeview); + gtk_tree_selection_select_all (sel); +} + +gboolean +ephy_node_view_has_focus (EphyNodeView *view) +{ + GtkWidget *window; + GtkWidget *focused_widget; + + window = gtk_widget_get_toplevel (view->priv->treeview); + focused_widget = gtk_window_get_focus (GTK_WINDOW(window)); + + if (view->priv->treeview == focused_widget) + { + return TRUE; + } + + return FALSE; +} + void ephy_node_view_remove (EphyNodeView *view) { diff --git a/src/bookmarks/ephy-node-view.h b/src/bookmarks/ephy-node-view.h index 47b429cd7..ee404d159 100644 --- a/src/bookmarks/ephy-node-view.h +++ b/src/bookmarks/ephy-node-view.h @@ -74,6 +74,10 @@ void ephy_node_view_remove (EphyNodeView *view); GList *ephy_node_view_get_selection (EphyNodeView *view); +void ephy_node_view_select_all (EphyNodeView *view); + +gboolean ephy_node_view_has_focus (EphyNodeView *view); + void ephy_node_view_set_browse_mode (EphyNodeView *view); void ephy_node_view_select_node (EphyNodeView *view, diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c index 4bfbe3681..97023550c 100644 --- a/src/bookmarks/ephy-topics-selector.c +++ b/src/bookmarks/ephy-topics-selector.c @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include static void ephy_topics_selector_class_init (EphyTopicsSelectorClass *klass); static void ephy_topics_selector_init (EphyTopicsSelector *editor); @@ -295,6 +297,39 @@ ephy_topics_selector_apply (EphyTopicsSelector *editor) while (gtk_tree_model_iter_next (model, &iter)); } +static gboolean +set_sort_column_id (GtkListStore *model) +{ + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), + COL_TOPIC, + GTK_SORT_ASCENDING); + return FALSE; +} + +static gboolean +topic_clicked (GtkTreeView *tree_view, + GdkEventButton *event, + EphyTopicsSelector *selector) +{ + GtkTreePath *path; + + if (event->window != gtk_tree_view_get_bin_window (tree_view)) + return FALSE; + + if (gtk_tree_view_get_path_at_pos (tree_view, + (gint) event->x, + (gint) event->y, + &path, NULL, + NULL, NULL)) + { + gchar *path_str = gtk_tree_path_to_string (path); + topic_toggled (NULL, path_str, selector); + g_free(path_str); + } + + return FALSE; +} + static void ephy_topics_build_ui (EphyTopicsSelector *editor) { @@ -308,13 +343,12 @@ ephy_topics_build_ui (EphyTopicsSelector *editor) treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); + g_idle_add ((GSourceFunc) set_sort_column_id, model); gtk_widget_show (treeview); g_object_unref (model); /* Has topic column */ renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (renderer, "toggled", - G_CALLBACK (topic_toggled), editor); column = gtk_tree_view_column_new_with_attributes ("", renderer, "active", COL_HAS_TOPIC, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); @@ -323,7 +357,9 @@ ephy_topics_build_ui (EphyTopicsSelector *editor) column = gtk_tree_view_column_new_with_attributes ("Description", renderer, "text", COL_TOPIC, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); - + + g_signal_connect (G_OBJECT (treeview), "button_press_event", + G_CALLBACK (topic_clicked), editor); fill_model (editor); gtk_container_add (GTK_CONTAINER (editor), treeview); -- cgit v1.2.3