aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Bordoley <bordoley@msu.edu>2003-03-27 21:39:33 +0800
committerDave Bordoley <Bordoley@src.gnome.org>2003-03-27 21:39:33 +0800
commitd5be47a8e46ac8a35e41f296a95bb5ddcf7365e8 (patch)
tree397fc387ec6374fd9641709fdc9947de1ccf3621 /src
parent1ee9df3c80f558d2e05c7204ef8d682bba938886 (diff)
downloadgsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar.gz
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar.bz2
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar.lz
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar.xz
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.tar.zst
gsoc2013-epiphany-d5be47a8e46ac8a35e41f296a95bb5ddcf7365e8.zip
Reorganize the menus a bit. Unifiy topic/bookmarks rename/delete items.
2003-03-27 David Bordoley <bordoley@msu.edu> * 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.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c182
-rw-r--r--src/bookmarks/ephy-node-view.c25
-rw-r--r--src/bookmarks/ephy-node-view.h4
-rw-r--r--src/bookmarks/ephy-topics-selector.c42
4 files changed, 204 insertions, 49 deletions
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, "<shift><control>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, "<control>X",
+ NULL, G_CALLBACK (cmd_cut), NULL },
+
+ { "Copy", N_("_Copy"), GTK_STOCK_COPY, "<control>C",
+ NULL, G_CALLBACK (cmd_copy), NULL },
+
+ { "Paste", N_("_Paste"), GTK_STOCK_PASTE, "<control>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, "<control>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, "<alt>Return",
NULL, G_CALLBACK (cmd_bookmark_properties), NULL },
@@ -154,21 +164,6 @@ cmd_add_topic (EggAction *action,
}
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,
@@ -472,6 +527,22 @@ bookmarks_filter (EphyBookmarksEditor *editor,
}
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,
EphyBookmarksEditor *editor)
@@ -490,6 +561,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)
{
char *search_text;
@@ -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);
@@ -636,10 +718,18 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
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 <gtk/gtktreeviewcolumn.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkcellrendererpixbuf.h>
+#include <gtk/gtkwindow.h>
#include <libgnome/gnome-i18n.h>
#include "eggtreemodelfilter.h"
@@ -661,6 +662,30 @@ ephy_node_view_get_selection (EphyNodeView *view)
}
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)
{
GList *list;
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 <gtk/gtkliststore.h>
#include <gtk/gtkcellrenderertoggle.h>
#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtktreeselection.h>
#include <gtk/gtktreeview.h>
+#include <gdk/gdkkeysyms.h>
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);