anjuta r4479 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/search plugins/sourceview
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4479 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/search plugins/sourceview
- Date: Tue, 23 Dec 2008 14:57:36 +0000 (UTC)
Author: jhs
Date: Tue Dec 23 14:57:36 2008
New Revision: 4479
URL: http://svn.gnome.org/viewvc/anjuta?rev=4479&view=rev
Log:
2008-12-23 Johannes Schmid <jhs gnome org>
* libanjuta/interfaces/libanjuta.idl:
* plugins/document-manager/anjuta-bookmarks.c (on_add_clicked),
(anjuta_bookmarks_get_text_from_file), (anjuta_bookmarks_get_text),
(anjuta_bookmarks_add), (anjuta_bookmarks_add_file):
* plugins/document-manager/anjuta-bookmarks.h:
* plugins/document-manager/plugin.c (ianjuta_docman_add_bookmark),
(ianjuta_document_manager_iface_init):
* plugins/search/search-replace.c (search_and_replace):
Added new add_bookmark method to document-manager interface and readded
the possibility add bookmarks to all search results.
* plugins/sourceview/sourceview-io.c (set_display_name):
Adding missing unref
Modified:
trunk/ChangeLog
trunk/libanjuta/interfaces/libanjuta.idl
trunk/plugins/document-manager/anjuta-bookmarks.c
trunk/plugins/document-manager/anjuta-bookmarks.h
trunk/plugins/document-manager/plugin.c
trunk/plugins/search/search-replace.c
trunk/plugins/sourceview/sourceview-io.c
Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl (original)
+++ trunk/libanjuta/interfaces/libanjuta.idl Tue Dec 23 14:57:36 2008
@@ -2539,6 +2539,15 @@
*/
void add_document (IAnjutaDocument* document);
+ /*
+ * ianjuta_document_manager_add_bookmark:
+ * @obj: Self
+ * @file: File to add the bookmark
+ * @line: Line of the bookmark
+ *
+ * Add a bookmark
+ */
+ void add_bookmark (GFile* file, gint line);
}
/**
Modified: trunk/plugins/document-manager/anjuta-bookmarks.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-bookmarks.c (original)
+++ trunk/plugins/document-manager/anjuta-bookmarks.c Tue Dec 23 14:57:36 2008
@@ -75,7 +75,7 @@
anjuta_docman_get_current_document (ANJUTA_DOCMAN(priv->docman->docman));
g_return_if_fail (IANJUTA_IS_EDITOR(doc));
IAnjutaEditor* editor = IANJUTA_EDITOR(doc);
- anjuta_bookmarks_add (bookmarks, editor, ianjuta_editor_get_lineno (editor, NULL));
+ anjuta_bookmarks_add (bookmarks, editor, ianjuta_editor_get_lineno (editor, NULL), TRUE);
}
static void
@@ -274,29 +274,16 @@
}
static gchar*
-anjuta_bookmarks_get_text (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line)
+anjuta_bookmarks_get_text_from_file (AnjutaBookmarks* bookmarks, GFile* file, gint line)
{
AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
- IAnjutaSymbolManager* sym_manager;
- /* If we have a (short) selection, take this */
- if (IANJUTA_IS_EDITOR_SELECTION(editor))
- {
- IAnjutaEditorSelection* selection = IANJUTA_EDITOR_SELECTION(editor);
- if (ianjuta_editor_selection_has_selection (selection, NULL))
- {
- gchar* text = ianjuta_editor_selection_get (selection, NULL);
- if (strlen (text) < 100)
- return text;
- g_free (text);
- }
- }
/* If we can get the symbol scope - take it */
- sym_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN(priv->docman)->shell,
- IAnjutaSymbolManager,
- NULL);
+ IAnjutaSymbolManager* sym_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN(priv->docman)->shell,
+ IAnjutaSymbolManager,
+ NULL);
+
if (sym_manager != NULL)
{
- GFile* file = ianjuta_file_get_file(IANJUTA_FILE(editor), NULL);
gchar* path = g_file_get_path (file);
IAnjutaIterable* iter =
ianjuta_symbol_manager_get_scope (sym_manager,
@@ -310,13 +297,49 @@
return g_strdup (ianjuta_symbol_get_name(IANJUTA_SYMBOL(iter), NULL));
}
}
- /* As last chance, take file + line */
- return g_strdup_printf ("%s:%d", ianjuta_document_get_filename(IANJUTA_DOCUMENT(editor), NULL),
- line);
+ {
+ gchar* text;
+ GFileInfo* info;
+ /* As last chance, take file + line */
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+ text = g_strdup_printf ("%s:%d", g_file_info_get_display_name (info),
+ line);
+ g_object_unref (info);
+ return text;
+ }
+}
+
+static gchar*
+anjuta_bookmarks_get_text (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line, gboolean use_selection)
+{
+ /* If we have a (short) selection, take this */
+ if (IANJUTA_IS_EDITOR_SELECTION(editor) && use_selection)
+ {
+ IAnjutaEditorSelection* selection = IANJUTA_EDITOR_SELECTION(editor);
+ if (ianjuta_editor_selection_has_selection (selection, NULL))
+ {
+ gchar* text = ianjuta_editor_selection_get (selection, NULL);
+ if (strlen (text) < 100)
+ return text;
+ g_free (text);
+ }
+ }
+ {
+ GFile* file = ianjuta_file_get_file (IANJUTA_FILE(editor), NULL);
+ gchar* text = anjuta_bookmarks_get_text_from_file (bookmarks,
+ file,
+ line);
+ g_object_unref (file);
+ return text;
+ }
}
void
-anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line)
+anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line, gboolean use_selection)
{
g_return_if_fail (IANJUTA_IS_MARKABLE(editor));
IAnjutaMarkable* markable = IANJUTA_MARKABLE(editor);
@@ -334,7 +357,7 @@
handle = ianjuta_markable_mark (markable, line, IANJUTA_MARKABLE_BOOKMARK, NULL);
gtk_list_store_append (GTK_LIST_STORE(priv->model), &iter);
- text = anjuta_bookmarks_get_text (bookmarks, editor, line);
+ text = anjuta_bookmarks_get_text (bookmarks, editor, line, use_selection);
file = ianjuta_file_get_file(IANJUTA_FILE(editor), NULL);
gtk_list_store_set (GTK_LIST_STORE(priv->model), &iter,
COLUMN_TEXT, text,
@@ -347,19 +370,21 @@
g_object_set (G_OBJECT(priv->renderer), "editable", TRUE, NULL);
- path = gtk_tree_model_get_path (priv->model, &iter);
-
- anjuta_shell_present_widget (ANJUTA_PLUGIN(priv->docman)->shell,
- priv->window, NULL);
- gtk_widget_grab_focus (priv->tree);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->tree), path,
- priv->column, FALSE, 0.0, 0.0);
-
- gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (priv->tree), path,
- priv->column,
- priv->renderer,
- TRUE);
- gtk_tree_path_free (path);
+ if (use_selection)
+ {
+ path = gtk_tree_model_get_path (priv->model, &iter);
+ anjuta_shell_present_widget (ANJUTA_PLUGIN(priv->docman)->shell,
+ priv->window, NULL);
+ gtk_widget_grab_focus (priv->tree);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->tree), path,
+ priv->column, FALSE, 0.0, 0.0);
+
+ gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (priv->tree), path,
+ priv->column,
+ priv->renderer,
+ TRUE);
+ gtk_tree_path_free (path);
+ }
}
void
@@ -394,6 +419,30 @@
}
}
+void
+anjuta_bookmarks_add_file (AnjutaBookmarks* bookmarks, GFile* file, gint line)
+{
+ AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+ IAnjutaDocument* doc;
+ GtkTreeIter iter;
+ if ((doc = anjuta_docman_get_document_for_file (ANJUTA_DOCMAN(priv->docman->docman), file)))
+ {
+ anjuta_bookmarks_add (bookmarks, IANJUTA_EDITOR(doc), line, FALSE);
+ }
+ else
+ {
+ gtk_list_store_append (GTK_LIST_STORE(priv->model), &iter);
+ gchar* text = anjuta_bookmarks_get_text_from_file (bookmarks, file, line);
+ gtk_list_store_set (GTK_LIST_STORE(priv->model), &iter,
+ COLUMN_TEXT, text,
+ COLUMN_FILE, file,
+ COLUMN_LINE, line,
+ COLUMN_HANDLE, -1,
+ -1);
+ g_free (text);
+ }
+}
+
void
anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* session)
{
Modified: trunk/plugins/document-manager/anjuta-bookmarks.h
==============================================================================
--- trunk/plugins/document-manager/anjuta-bookmarks.h (original)
+++ trunk/plugins/document-manager/anjuta-bookmarks.h Tue Dec 23 14:57:36 2008
@@ -50,7 +50,8 @@
GType anjuta_bookmarks_get_type (void) G_GNUC_CONST;
AnjutaBookmarks* anjuta_bookmarks_new (DocmanPlugin* docman);
-void anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line);
+void anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line, gboolean use_selection);
+void anjuta_bookmarks_add_file (AnjutaBookmarks* bookmarks, GFile* file, 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);
Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c (original)
+++ trunk/plugins/document-manager/plugin.c Tue Dec 23 14:57:36 2008
@@ -1980,6 +1980,16 @@
}
static void
+ianjuta_docman_add_bookmark (IAnjutaDocumentManager* plugin,
+ GFile* file,
+ gint line,
+ GError **e)
+{
+ AnjutaBookmarks* bookmarks = ANJUTA_BOOKMARKS (ANJUTA_PLUGIN_DOCMAN(plugin)->bookmarks);
+ anjuta_bookmarks_add_file (bookmarks, file, line);
+}
+
+static void
ianjuta_document_manager_iface_init (IAnjutaDocumentManagerIface *iface)
{
iface->add_buffer = ianjuta_docman_add_buffer;
@@ -1993,6 +2003,7 @@
iface->remove_document = ianjuta_docman_remove_document;
iface->set_current_document = ianjuta_docman_set_current_document;
iface->set_message_area = ianjuta_docman_set_message_area;
+ iface->add_bookmark = ianjuta_docman_add_bookmark;
}
/* Implement IAnjutaFile interface */
Modified: trunk/plugins/search/search-replace.c
==============================================================================
--- trunk/plugins/search/search-replace.c (original)
+++ trunk/plugins/search/search-replace.c Tue Dec 23 14:57:36 2008
@@ -422,23 +422,13 @@
case SA_BOOKMARK:
if (found_line != mi->line)
{
- found_line = mi->line;
-
- if (fb->te == NULL)
- fb->te =
- IANJUTA_EDITOR (ianjuta_document_manager_get_current_document
- (sr->docman, NULL));
-
- if (IANJUTA_IS_MARKABLE (fb->te) &&
- !ianjuta_markable_is_marker_set (
- IANJUTA_MARKABLE(fb->te),
- mi->line,
- IANJUTA_MARKABLE_BOOKMARK,
- NULL))
- {
- //TODO:ianjuta_bookmark_toggle (IANJUTA_BOOKMARK(fb->te),
- // mi->line, FALSE, NULL);
- }
+ GFile* file = g_file_new_for_uri (fb->uri);
+ found_line = mi->line + 1; /* different line count between search and editor */
+ ianjuta_document_manager_add_bookmark (sr->docman,
+ file,
+ found_line,
+ NULL);
+ g_object_unref (file);
}
break;
Modified: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.c (original)
+++ trunk/plugins/sourceview/sourceview-io.c Tue Dec 23 14:57:36 2008
@@ -209,7 +209,7 @@
g_free (sio->filename);
sio->filename = NULL;
}
-
+ g_object_unref (file_info);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]