[anjuta] document-manager: bgo#621424 - No easy way to delete a bookmark
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] document-manager: bgo#621424 - No easy way to delete a bookmark
- Date: Fri, 17 Dec 2010 16:28:20 +0000 (UTC)
commit 0ec0c6d12d646459c4e04c8e92f8ffbb31392194
Author: Johannes Schmid <jhs gnome org>
Date: Fri Dec 17 17:27:59 2010 +0100
document-manager: bgo#621424 - No easy way to delete a bookmark
plugins/document-manager/action-callbacks.c | 6 +-
plugins/document-manager/action-callbacks.h | 2 +-
plugins/document-manager/anjuta-bookmarks.c | 47 +++++++++++++++++++-
plugins/document-manager/anjuta-bookmarks.h | 1 +
.../document-manager/anjuta-document-manager.xml | 2 +-
plugins/document-manager/plugin.c | 6 +-
6 files changed, 55 insertions(+), 9 deletions(-)
---
diff --git a/plugins/document-manager/action-callbacks.c b/plugins/document-manager/action-callbacks.c
index 130b47a..163774d 100644
--- a/plugins/document-manager/action-callbacks.c
+++ b/plugins/document-manager/action-callbacks.c
@@ -943,7 +943,7 @@ on_previous_document (GtkAction *action, gpointer user_data)
}
void
-on_bookmark_add_activate (GtkAction *action, gpointer user_data)
+on_bookmark_toggle_activate (GtkAction *action, gpointer user_data)
{
IAnjutaDocument *doc;
DocmanPlugin *plugin;
@@ -952,8 +952,8 @@ on_bookmark_add_activate (GtkAction *action, gpointer user_data)
if (doc && IANJUTA_IS_EDITOR(doc))
{
IAnjutaEditor* editor = IANJUTA_EDITOR(doc);
- anjuta_bookmarks_add (ANJUTA_BOOKMARKS (plugin->bookmarks), editor,
- ianjuta_editor_get_lineno (editor, NULL), NULL, TRUE);
+ anjuta_bookmarks_toggle (ANJUTA_BOOKMARKS (plugin->bookmarks), editor,
+ ianjuta_editor_get_lineno (editor, NULL));
}
}
diff --git a/plugins/document-manager/action-callbacks.h b/plugins/document-manager/action-callbacks.h
index ccb408b..9fc3a7b 100644
--- a/plugins/document-manager/action-callbacks.h
+++ b/plugins/document-manager/action-callbacks.h
@@ -98,7 +98,7 @@ void on_repeat_quicksearch (GtkAction *action, gpointer user_data);
void on_next_document (GtkAction *action, gpointer user_data);
void on_previous_document (GtkAction *action, gpointer user_data);
-void on_bookmark_add_activate (GtkAction *action, gpointer user_data);
+void on_bookmark_toggle_activate (GtkAction *action, gpointer user_data);
void on_bookmark_next_activate (GtkAction *action, gpointer user_data);
void on_bookmark_prev_activate (GtkAction *action, gpointer user_data);
void on_bookmarks_clear_activate (GtkAction *action, gpointer user_data);
diff --git a/plugins/document-manager/anjuta-bookmarks.c b/plugins/document-manager/anjuta-bookmarks.c
index d309c61..2fd7e2a 100644
--- a/plugins/document-manager/anjuta-bookmarks.c
+++ b/plugins/document-manager/anjuta-bookmarks.c
@@ -324,7 +324,7 @@ anjuta_bookmarks_init (AnjutaBookmarks *bookmarks)
bookmarks);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK(on_selection_changed),
bookmarks);
@@ -742,6 +742,51 @@ anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* sessio
gtk_list_store_clear (GTK_LIST_STORE (priv->model));
}
+void
+anjuta_bookmarks_toggle (AnjutaBookmarks* bookmarks,
+ IAnjutaEditor* editor,
+ gint line)
+{
+ AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+
+ g_return_if_fail (bookmarks != NULL);
+ g_return_if_fail (editor != NULL);
+
+ /* Check if there is a bookmark in that line already */
+ if (ianjuta_markable_is_marker_set (IANJUTA_MARKABLE (editor),
+ line, IANJUTA_MARKABLE_BOOKMARK, NULL))
+ {
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (priv->model, &iter))
+ {
+ do
+ {
+ gint handle;
+ gint location;
+ gtk_tree_model_get (priv->model, &iter,
+ COLUMN_HANDLE, &handle, -1);
+
+ /* Update location if necessary */
+ location = ianjuta_markable_location_from_handle (IANJUTA_MARKABLE (editor),
+ handle, NULL);
+ gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
+ COLUMN_LINE, location, -1 );
+ if (line == location)
+ {
+ GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree));
+ gtk_tree_selection_select_iter (selection, &iter);
+ anjuta_bookmarks_remove (bookmarks);
+ }
+ }
+ while (gtk_tree_model_iter_next (priv->model, &iter));
+ }
+ }
+ else
+ {
+ anjuta_bookmarks_add (bookmarks, editor, line, NULL, TRUE);
+ }
+}
+
static void
read_bookmarks (AnjutaBookmarks* bookmarks, xmlNodePtr marks)
{
diff --git a/plugins/document-manager/anjuta-bookmarks.h b/plugins/document-manager/anjuta-bookmarks.h
index e6da281..af0dd14 100644
--- a/plugins/document-manager/anjuta-bookmarks.h
+++ b/plugins/document-manager/anjuta-bookmarks.h
@@ -54,6 +54,7 @@ void anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gi
const gchar* title, gboolean use_selection);
void anjuta_bookmarks_add_file (AnjutaBookmarks* bookmarks, GFile* file,
gint line, const gchar* title);
+void anjuta_bookmarks_toggle (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line);
void anjuta_bookmarks_remove (AnjutaBookmarks* bookmarks);
void anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* session);
void anjuta_bookmarks_session_load (AnjutaBookmarks* bookmarks, AnjutaSession* session);
diff --git a/plugins/document-manager/anjuta-document-manager.xml b/plugins/document-manager/anjuta-document-manager.xml
index 3da2bc6..a0c3f0b 100644
--- a/plugins/document-manager/anjuta-document-manager.xml
+++ b/plugins/document-manager/anjuta-document-manager.xml
@@ -107,7 +107,7 @@
<menuitem name="CloseOther" action="ActionFileCloseOther" />
<separator />
<menu name="DocumentsBookmarks" action="ActionMenuBookmark">
- <menuitem name="AddBookmark" action="ActionBookmarkAdd" />
+ <menuitem name="ToggleBookmark" action="ActionBookmarkToggle" />
<separator />
<menuitem name="NextBookmark" action="ActionBookmarkNext" />
<menuitem name="PrevBookmark" action="ActionBookmarkPrev" />
diff --git a/plugins/document-manager/plugin.c b/plugins/document-manager/plugin.c
index e8d6f9f..28cf0b6 100644
--- a/plugins/document-manager/plugin.c
+++ b/plugins/document-manager/plugin.c
@@ -377,9 +377,9 @@ static GtkActionEntry actions_documents[] = {
static GtkActionEntry actions_bookmarks[] = {
{ "ActionMenuBookmark", NULL, N_("Bookmar_k"), NULL, NULL, NULL},
- { "ActionBookmarkAdd", GTK_STOCK_ADD, N_("_Add Bookmark"),
- "<control>k", N_("Add a bookmark at the current line position"),
- G_CALLBACK (on_bookmark_add_activate)},
+ { "ActionBookmarkToggle", GTK_STOCK_ADD, N_("_Toggle Bookmark"),
+ "<control>k", N_("Toggle bookmark at the current line position"),
+ G_CALLBACK (on_bookmark_toggle_activate)},
{ "ActionBookmarkPrev", ANJUTA_STOCK_BOOKMARK_PREV, N_("_Previous Bookmark"),
"<control>comma", N_("Jump to the previous bookmark in the file"),
G_CALLBACK (on_bookmark_prev_activate)},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]