anjuta r4529 - in trunk: . plugins/document-manager
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4529 - in trunk: . plugins/document-manager
- Date: Sun, 4 Jan 2009 22:50:49 +0000 (UTC)
Author: jhs
Date: Sun Jan 4 22:50:49 2009
New Revision: 4529
URL: http://svn.gnome.org/viewvc/anjuta?rev=4529&view=rev
Log:
2009-01-04 Johannes Schmid <jhs gnome org>
* plugins/document-manager/action-callbacks.c
(on_bookmark_add_activate), (on_bookmark_next_activate),
(on_bookmark_prev_activate), (on_bookmarks_clear_activate):
* plugins/document-manager/action-callbacks.h:
* plugins/document-manager/anjuta-bookmarks.c (line_compare),
(get_bookmarks_for_editor), (anjuta_bookmarks_next),
(anjuta_bookmarks_prev), (anjuta_bookmarks_clear):
* plugins/document-manager/anjuta-bookmarks.h:
* plugins/document-manager/anjuta-document-manager.ui:
* plugins/document-manager/plugin.c (register_stock_icons):
Added menuitems for add/next/prev/clear bookmark. Bookmark interface is now
complete again
Modified:
trunk/ChangeLog
trunk/plugins/document-manager/action-callbacks.c
trunk/plugins/document-manager/action-callbacks.h
trunk/plugins/document-manager/anjuta-bookmarks.c
trunk/plugins/document-manager/anjuta-bookmarks.h
trunk/plugins/document-manager/anjuta-document-manager.ui
trunk/plugins/document-manager/plugin.c
Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c (original)
+++ trunk/plugins/document-manager/action-callbacks.c Sun Jan 4 22:50:49 2009
@@ -44,6 +44,7 @@
#include "plugin.h"
#include "file_history.h"
#include "search-box.h"
+#include "anjuta-bookmarks.h"
static IAnjutaDocument *
get_current_document (gpointer user_data)
@@ -906,3 +907,56 @@
gtk_notebook_set_current_page (notebook,
cur_page);
}
+
+void
+on_bookmark_add_activate (GtkAction *action, gpointer user_data)
+{
+ IAnjutaDocument *doc;
+ DocmanPlugin *plugin;
+ doc = get_current_document (user_data);
+ plugin = ANJUTA_PLUGIN_DOCMAN (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);
+ }
+}
+
+void
+on_bookmark_next_activate (GtkAction *action, gpointer user_data)
+{
+ IAnjutaDocument *doc;
+ DocmanPlugin *plugin;
+ doc = get_current_document (user_data);
+ plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
+ if (doc && IANJUTA_IS_EDITOR(doc))
+ {
+ IAnjutaEditor* editor = IANJUTA_EDITOR(doc);
+ anjuta_bookmarks_next (ANJUTA_BOOKMARKS (plugin->bookmarks), editor,
+ ianjuta_editor_get_lineno (editor, NULL));
+ }
+}
+
+void
+on_bookmark_prev_activate (GtkAction *action, gpointer user_data)
+{
+ IAnjutaDocument *doc;
+ DocmanPlugin *plugin;
+ doc = get_current_document (user_data);
+ plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
+ if (doc && IANJUTA_IS_EDITOR(doc))
+ {
+ IAnjutaEditor* editor = IANJUTA_EDITOR(doc);
+ anjuta_bookmarks_prev (ANJUTA_BOOKMARKS (plugin->bookmarks), editor,
+ ianjuta_editor_get_lineno (editor, NULL));
+ }
+}
+
+void
+on_bookmarks_clear_activate (GtkAction *action, gpointer user_data)
+{
+ DocmanPlugin *plugin;
+ plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
+ anjuta_bookmarks_clear (ANJUTA_BOOKMARKS(plugin->bookmarks));
+}
Modified: trunk/plugins/document-manager/action-callbacks.h
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.h (original)
+++ trunk/plugins/document-manager/action-callbacks.h Sun Jan 4 22:50:49 2009
@@ -97,4 +97,9 @@
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_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);
+
#endif
Modified: trunk/plugins/document-manager/anjuta-bookmarks.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-bookmarks.c (original)
+++ trunk/plugins/document-manager/anjuta-bookmarks.c Sun Jan 4 22:50:49 2009
@@ -664,3 +664,100 @@
xmlFreeDoc (doc);
}
+
+static gint
+line_compare (gconstpointer line1, gconstpointer line2)
+{
+ gint l1 = GPOINTER_TO_INT(line1);
+ gint l2 = GPOINTER_TO_INT(line2);
+ return l2 - l1;
+}
+
+static GList*
+get_bookmarks_for_editor (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor)
+{
+ AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+ GList* marks = NULL;
+ GtkTreeIter iter;
+ GFile* file;
+ if (!gtk_tree_model_get_iter_first (priv->model, &iter))
+ return NULL;
+ file = ianjuta_file_get_file (IANJUTA_FILE(editor), NULL);
+ if (!file)
+ return NULL;
+ do
+ {
+ GFile* bookmark_file;
+ gint line;
+ gtk_tree_model_get (priv->model,
+ &iter,
+ COLUMN_FILE, &bookmark_file,
+ COLUMN_LINE, &line,
+ -1);
+ if (g_file_equal (file, bookmark_file))
+ marks = g_list_insert_sorted (marks, GINT_TO_POINTER(line), line_compare);
+ g_object_unref (bookmark_file);
+ }
+ while (gtk_tree_model_iter_next (priv->model, &iter));
+ g_object_unref (file);
+
+ return marks;
+}
+
+void
+anjuta_bookmarks_next (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor,
+ gint line)
+{
+ IAnjutaIterable* end_pos;
+ gint end_line;
+ GList* marks = get_bookmarks_for_editor (bookmarks, editor);
+ GList* node;
+
+ end_pos = ianjuta_editor_get_end_position (editor, NULL);
+ end_line = ianjuta_editor_get_line_from_position (editor, end_pos, NULL);
+ g_object_unref (end_pos);
+
+ for (node = marks; node != NULL; node = g_list_next (node))
+ {
+ gint node_line = GPOINTER_TO_INT (node->data);
+ if (node_line > line)
+ {
+ ianjuta_editor_goto_line (editor, node_line, NULL);
+ }
+ }
+ g_list_free (marks);
+}
+
+void
+anjuta_bookmarks_prev (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor,
+ gint line)
+{
+ IAnjutaIterable* end_pos;
+ gint end_line;
+ GList* marks = get_bookmarks_for_editor (bookmarks, editor);
+ GList* node;
+
+ end_pos = ianjuta_editor_get_end_position (editor, NULL);
+ end_line = ianjuta_editor_get_line_from_position (editor, end_pos, NULL);
+ g_object_unref (end_pos);
+
+ marks = g_list_reverse (marks);
+
+ for (node = marks; node != NULL; node = g_list_next (node))
+ {
+ gint node_line = GPOINTER_TO_INT (node->data);
+ if (node_line < line)
+ {
+ ianjuta_editor_goto_line (editor, node_line, NULL);
+ }
+ }
+ g_list_free (marks);
+}
+
+void anjuta_bookmarks_clear (AnjutaBookmarks* bookmarks)
+{
+ AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+ GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree));
+ gtk_tree_selection_select_all (selection);
+ anjuta_bookmarks_remove (bookmarks);
+}
Modified: trunk/plugins/document-manager/anjuta-bookmarks.h
==============================================================================
--- trunk/plugins/document-manager/anjuta-bookmarks.h (original)
+++ trunk/plugins/document-manager/anjuta-bookmarks.h Sun Jan 4 22:50:49 2009
@@ -58,6 +58,12 @@
void anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* session);
void anjuta_bookmarks_session_load (AnjutaBookmarks* bookmarks, AnjutaSession* session);
+void anjuta_bookmarks_next (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor,
+ gint line);
+void anjuta_bookmarks_prev (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor,
+ gint line);
+void anjuta_bookmarks_clear (AnjutaBookmarks* bookmarks);
+
G_END_DECLS
#endif /* _ANJUTA_BOOKMARKS_H_ */
Modified: trunk/plugins/document-manager/anjuta-document-manager.ui
==============================================================================
--- trunk/plugins/document-manager/anjuta-document-manager.ui (original)
+++ trunk/plugins/document-manager/anjuta-document-manager.ui Sun Jan 4 22:50:49 2009
@@ -103,6 +103,15 @@
<menuitem name="SaveAll" action="ActionFileSaveAll" />
<menuitem name="CloseAll" action="ActionFileCloseAll" />
<separator />
+ <menu name="DocumentsBookmarks" action="ActionMenuBookmark">
+ <menuitem name="AddBookmark" action="ActionBookmarkAdd" />
+ <separator />
+ <menuitem name="NextBookmark" action="ActionBookmarkNext" />
+ <menuitem name="PrevBookmark" action="ActionBookmarkPrev" />
+ <separator />
+ <menuitem name="ClearBookmarks" action="ActionBookmarksClear" />
+ </menu>
+ <separator />
<menuitem name="PreviousDocument" action="ActionDocumentsPrevious" />
<menuitem name="NextDocument" action="ActionDocumentsNext" />
<separator />
Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c (original)
+++ trunk/plugins/document-manager/plugin.c Sun Jan 4 22:50:49 2009
@@ -55,6 +55,9 @@
#define ICON_FILE "anjuta-document-manager-plugin-48.png"
#define ANJUTA_PIXMAP_BOOKMARK_TOGGLE "anjuta-bookmark-toggle"
+#define ANJUTA_PIXMAP_BOOKMARK_PREV "anjuta-bookmark-prev"
+#define ANJUTA_PIXMAP_BOOKMARK_NEXT "anjuta-bookmark-next"
+#define ANJUTA_PIXMAP_BOOKMARK_CLEAR "anjuta-bookmark-clear"
#define ANJUTA_PIXMAP_FOLD_TOGGLE "anjuta-fold-toggle"
#define ANJUTA_PIXMAP_FOLD_CLOSE "anjuta-fold-close"
@@ -85,6 +88,9 @@
#define ANJUTA_STOCK_BLOCK_START "anjuta-block-start"
#define ANJUTA_STOCK_BLOCK_END "anjuta-block-end"
#define ANJUTA_STOCK_BOOKMARK_TOGGLE "anjuta-bookmark-toggle"
+#define ANJUTA_STOCK_BOOKMARK_PREV "anjuta-bookmark-previous"
+#define ANJUTA_STOCK_BOOKMARK_NEXT "anjuta-bookmark-next"
+#define ANJUTA_STOCK_BOOKMARK_CLEAR "anjuta-bookmark-clear"
#define ANJUTA_STOCK_GOTO_LINE "anjuta-goto-line"
#define ANJUTA_STOCK_HISTORY_NEXT "anjuta-history-next"
#define ANJUTA_STOCK_HISTORY_PREV "anjuta-history-prev"
@@ -366,6 +372,22 @@
G_CALLBACK (on_next_document)},
};
+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)},
+ { "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)},
+ { "ActionBookmarkNext", ANJUTA_STOCK_BOOKMARK_NEXT, N_("_Next Bookmark"),
+ "<control>period", N_("Jump to the next bookmark in the file"),
+ G_CALLBACK (on_bookmark_next_activate)},
+ { "ActionBookmarksClear", ANJUTA_STOCK_BOOKMARK_CLEAR, N_("_Clear All Bookmarks"),
+ NULL, N_("Clear bookmarks"),
+ G_CALLBACK (on_bookmarks_clear_activate)},
+ };
+
struct ActionGroupInfo {
GtkActionEntry *group;
gint size;
@@ -393,7 +415,8 @@
{ actions_style, G_N_ELEMENTS (actions_style), "ActionGroupEditorStyle", N_("Editor syntax highlighting styles") },
{ actions_format, G_N_ELEMENTS (actions_format), "ActionGroupEditorFormat", N_("Editor text formating") },
{ actions_search, G_N_ELEMENTS (actions_search), "ActionGroupEditorSearch", N_("Simple searching") },
- { actions_documents, G_N_ELEMENTS (actions_documents), "ActionGroupDocuments", N_("Documents") }
+ { actions_documents, G_N_ELEMENTS (actions_documents), "ActionGroupDocuments", N_("Documents") },
+ { actions_bookmarks, G_N_ELEMENTS (actions_bookmarks), "ActionGroupBookmarks", N_("Bookmarks") }
};
static struct ActionToggleGroupInfo action_toggle_groups[] = {
@@ -862,6 +885,9 @@
REGISTER_ICON_FULL (ANJUTA_PIXMAP_INDENT_INC, ANJUTA_STOCK_INDENT_INC);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_BLOCK_SELECT, ANJUTA_STOCK_BLOCK_SELECT);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_BOOKMARK_TOGGLE, ANJUTA_STOCK_BOOKMARK_TOGGLE);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_BOOKMARK_PREV, ANJUTA_STOCK_BOOKMARK_PREV);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_BOOKMARK_NEXT, ANJUTA_STOCK_BOOKMARK_NEXT);
+ REGISTER_ICON_FULL (ANJUTA_PIXMAP_BOOKMARK_CLEAR, ANJUTA_STOCK_BOOKMARK_CLEAR);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_BLOCK_START, ANJUTA_STOCK_BLOCK_START);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_BLOCK_END, ANJUTA_STOCK_BLOCK_END);
REGISTER_ICON_FULL (ANJUTA_PIXMAP_GOTO_LINE, ANJUTA_STOCK_GOTO_LINE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]