anjuta r4454 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/editor plugins/file-manager plugins/search plugins/sourceview



Author: jhs
Date: Fri Dec 19 11:03:03 2008
New Revision: 4454
URL: http://svn.gnome.org/viewvc/anjuta?rev=4454&view=rev

Log:
2008-12-19  Johannes Schmid  <jhs gnome org>

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/document-manager/Makefile.am:
	* plugins/document-manager/action-callbacks.c:
	* plugins/document-manager/action-callbacks.h:
	* plugins/document-manager/anjuta-bookmarks.c
	(on_document_changed), (on_add_clicked), (on_remove_clicked),
	(on_row_activate), (on_document_added), (on_selection_changed),
	(anjuta_bookmarks_init), (anjuta_bookmarks_finalize),
	(anjuta_bookmarks_class_init), (anjuta_bookmarks_new),
	(anjuta_bookmarks_add), (anjuta_bookmarks_remove),
	(anjuta_bookmarks_session_save), (anjuta_bookmarks_session_load):
	* plugins/document-manager/anjuta-bookmarks.h:
	* plugins/document-manager/anjuta-document-manager.ui:
	* plugins/document-manager/plugin.c (register_stock_icons),
	(activate_plugin), (deactivate_plugin):
	* plugins/document-manager/plugin.h:
	* plugins/editor/aneditor.cxx:
	* plugins/editor/text_editor.c:
	* plugins/search/search-replace.c (search_and_replace):
	* plugins/sourceview/sourceview-io.c (on_save_finished):
	* plugins/sourceview/sourceview.c:
  New bookmark system. Will be extended to remember bookmarks across sessions
  and with some other things soon.

	* plugins/file-manager/file-view.c (file_view_row_activated),
	(file_view_do_popup_menu), (file_view_button_press_event),
	(file_view_popup_menu), (file_view_class_init):
	Fixed mouse actions and popup-menu handling to use the correct gtk+ stuff.

Added:
   trunk/plugins/document-manager/anjuta-bookmarks.c
   trunk/plugins/document-manager/anjuta-bookmarks.h
Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/document-manager/Makefile.am
   trunk/plugins/document-manager/action-callbacks.c
   trunk/plugins/document-manager/action-callbacks.h
   trunk/plugins/document-manager/anjuta-document-manager.ui
   trunk/plugins/document-manager/plugin.c
   trunk/plugins/document-manager/plugin.h
   trunk/plugins/editor/aneditor.cxx
   trunk/plugins/editor/text_editor.c
   trunk/plugins/file-manager/file-view.c
   trunk/plugins/search/search-replace.c
   trunk/plugins/sourceview/sourceview-io.c
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Fri Dec 19 11:03:03 2008
@@ -2341,80 +2341,6 @@
 }
 
 /**
- * SECTION:ianjuta-bookmark
- * @title: IAnjutaBookmark
- * @short_description: Bookmark interface
- * @see_also: 
- * @stability: Unstable
- * @include: libanjuta/interfaces/ianjuta-bookmark.h
- * 
- */
-interface IAnjutaBookmark
-{
-	/**
-	 * ianjuta_bookmark_toggle:
-	 * @obj: Self
-	 * @location: The location where bookmark is toggled.
-	 * @ensure_visible: If the location must be made visible.
-	 * @err: Error propagation and reporting
-	 *
-	 * Toggle bookmark at given @location
-	 *
-	 */
-	void toggle (gint location, gboolean ensure_visible);
-	
-	/**
-	 * ianjuta_bookmark_first:
-	 * @obj: Self
-	 * @err: Error propagation and reporting
-	 *
-	 * Goto first bookmark
-	 *
-	 */
-	void first ();
-	
-	/**
-	 * ianjuta_bookmark_last:
-	 * @obj: Self
-	 * @err: Error propagation and reporting
-	 *
-	 * Goto last bookmark
-	 *
-	 */
-	void last ();
-	
-	/**
-	 * ianjuta_bookmark_next:
-	 * @obj: Self
-	 * @err: Error propagation and reporting
-	 *
-	 * Goto next bookmark
-	 *
-	 */
-	void next ();
-	
-	/**
-	 * ianjuta_bookmark_previous:
-	 * @obj: Self
-	 * @err: Error propagation and reporting
-	 *
-	 * Goto previous bookmark
-	 *
-	 */
-	void previous ();
-	
-	/**
-	 * ianjuta_bookmark_clear_all:
-	 * @obj: Self
-	 * @err: Error propagation and reporting
-	 *
-	 * Clear all bookmarks
-	 *
-	 */
-	void clear_all ();
-}
-
-/**
  * SECTION:ianjuta-editor-factory
  * @title: IAnjutaEditorFactory
  * @short_description: Text editor factory that creates IAnjutaEditor objects

Modified: trunk/plugins/document-manager/Makefile.am
==============================================================================
--- trunk/plugins/document-manager/Makefile.am	(original)
+++ trunk/plugins/document-manager/Makefile.am	Fri Dec 19 11:03:03 2008
@@ -44,7 +44,9 @@
 	file_history.c \
 	file_history.h \
 	search-box.h \
-	search-box.c
+	search-box.c \
+	anjuta-bookmarks.h \
+	anjuta-bookmarks.c
 	
 prefs_glade_files = anjuta-document-manager.glade
 include $(top_srcdir)/scripts/build-schemas.mk

Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c	(original)
+++ trunk/plugins/document-manager/action-callbacks.c	Fri Dec 19 11:03:03 2008
@@ -28,7 +28,6 @@
 #include <libanjuta/interfaces/ianjuta-editor-line-mode.h>
 #include <libanjuta/interfaces/ianjuta-editor-view.h>
 #include <libanjuta/interfaces/ianjuta-editor-folds.h>
-#include <libanjuta/interfaces/ianjuta-bookmark.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-file-savable.h>
 #include <libanjuta/interfaces/ianjuta-print.h>
@@ -606,68 +605,6 @@
 }
 
 void
-on_editor_command_bookmark_toggle_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_toggle (IANJUTA_BOOKMARK (doc),
-								ianjuta_editor_get_lineno (IANJUTA_EDITOR (doc), NULL),
-								FALSE, NULL);
-}
-
-void
-on_editor_command_bookmark_first_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_first (IANJUTA_BOOKMARK (doc), NULL);
-}
-
-void
-on_editor_command_bookmark_next_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_next (IANJUTA_BOOKMARK (doc), NULL);
-}
-
-void
-on_editor_command_bookmark_prev_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_previous (IANJUTA_BOOKMARK (doc), NULL);
-}
-
-void
-on_editor_command_bookmark_last_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_last (IANJUTA_BOOKMARK (doc), NULL);
-}
-
-void
-on_editor_command_bookmark_clear_activate (GtkAction *action, gpointer user_data)
-{
-	IAnjutaDocument *doc;
-
-	doc = get_current_document (user_data);
-	if (doc)
-		ianjuta_bookmark_clear_all (IANJUTA_BOOKMARK (doc), NULL);
-}
-
-void
 on_transform_eolchars1_activate (GtkAction *action, gpointer user_data)
 {
 	IAnjutaDocument *doc;

Modified: trunk/plugins/document-manager/action-callbacks.h
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.h	(original)
+++ trunk/plugins/document-manager/action-callbacks.h	Fri Dec 19 11:03:03 2008
@@ -49,12 +49,6 @@
 void on_editor_command_close_folds_all_activate (GtkAction *action, gpointer user_data);
 void on_editor_command_open_folds_all_activate (GtkAction *action, gpointer user_data);
 void on_editor_command_toggle_fold_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_toggle_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_first_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_next_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_prev_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_last_activate (GtkAction *action, gpointer user_data);
-void on_editor_command_bookmark_clear_activate (GtkAction *action, gpointer user_data);
 
 void on_transform_eolchars1_activate (GtkAction *action, gpointer user_data);
 

Added: trunk/plugins/document-manager/anjuta-bookmarks.c
==============================================================================
--- (empty file)
+++ trunk/plugins/document-manager/anjuta-bookmarks.c	Fri Dec 19 11:03:03 2008
@@ -0,0 +1,328 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta-trunk
+ * Copyright (C) Johannes Schmid 2008 <jhs gnome org>
+ * 
+ * anjuta-trunk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta-trunk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "anjuta-bookmarks.h"
+#include "anjuta-docman.h"
+#include <libanjuta/interfaces/ianjuta-markable.h>
+#include <libanjuta/interfaces/ianjuta-file.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+
+#define BOOKMARKS_GET_PRIVATE(o)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((o), ANJUTA_TYPE_BOOKMARKS, AnjutaBookmarksPrivate))
+
+#define ANJUTA_STOCK_BOOKMARK_TOGGLE          "anjuta-bookmark-toggle"
+
+typedef struct _AnjutaBookmarksPrivate AnjutaBookmarksPrivate;
+
+struct _AnjutaBookmarksPrivate 
+{
+	GtkWidget* window;
+	GtkWidget* tree;
+	GtkTreeModel* model;
+	
+	GtkWidget* button_add;
+	GtkWidget* button_remove;	
+	
+	DocmanPlugin* docman;
+};
+
+enum
+{
+	COLUMN_TEXT = 0,
+	COLUMN_FILE,
+	COLUMN_LINE,
+	COLUMN_HANDLE,
+	N_COLUMNS
+};
+
+G_DEFINE_TYPE (AnjutaBookmarks, anjuta_bookmarks, G_TYPE_OBJECT);
+
+static void
+on_document_changed (AnjutaDocman *docman, IAnjutaDocument *doc,
+					 AnjutaBookmarks *bookmarks)
+{
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	gboolean status =  IANJUTA_IS_EDITOR(doc);
+	gtk_widget_set_sensitive (GTK_WIDGET(priv->button_add), status);
+}
+
+static void
+on_add_clicked (GtkWidget* button, AnjutaBookmarks* bookmarks)
+{
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	IAnjutaDocument* doc =
+		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));						 
+}
+
+static void
+on_remove_clicked (GtkWidget* button, AnjutaBookmarks* bookmarks)
+{					 
+	anjuta_bookmarks_remove (bookmarks);
+}
+
+static void
+on_row_activate (GtkTreeView* view, GtkTreePath* path,
+				 GtkTreeViewColumn* column, AnjutaBookmarks* bookmarks)
+{
+	GtkTreeIter iter;
+	GFile* file;
+	gint line;
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	IAnjutaEditor* editor;
+	gtk_tree_model_get_iter (priv->model, &iter, path);
+	gtk_tree_model_get (priv->model, &iter,
+						COLUMN_FILE, &file,
+						COLUMN_LINE, &line,
+						-1);
+	editor = anjuta_docman_goto_file_line (ANJUTA_DOCMAN(priv->docman->docman), file, line);
+	g_object_unref (file);
+}
+
+static void
+on_document_added (AnjutaDocman* docman, IAnjutaDocument* doc,
+				   AnjutaBookmarks* bookmarks)
+{
+	IAnjutaMarkable* markable;
+	GtkTreeIter iter;
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	
+	if (!IANJUTA_IS_MARKABLE(doc))
+		return;
+	
+	markable = IANJUTA_MARKABLE(doc);
+	if (!gtk_tree_model_get_iter_first (priv->model, &iter))
+		return;
+	do
+	{
+		GFile* file;
+		GFile* editor_file = ianjuta_file_get_file (IANJUTA_FILE(doc), NULL);
+		gint line;
+		gtk_tree_model_get (priv->model, &iter,
+							COLUMN_FILE, &file,
+							COLUMN_LINE, &line,
+							-1);
+		if (g_file_equal (file, editor_file))
+		{
+			if (!ianjuta_markable_is_marker_set (markable,
+												 line,
+												 IANJUTA_MARKABLE_BOOKMARK,
+												 NULL))
+			{
+				int handle = ianjuta_markable_mark (markable, line,
+												   IANJUTA_MARKABLE_BOOKMARK,
+												   NULL);
+				gtk_list_store_set (GTK_LIST_STORE(priv->model),
+									&iter,
+									COLUMN_HANDLE,
+									handle, -1);
+			}
+		}
+		g_object_unref (editor_file);
+		g_object_unref (file);		
+	}
+	while (gtk_tree_model_iter_next (priv->model, &iter));
+	
+	
+}
+
+static void
+on_selection_changed (GtkTreeSelection* selection, AnjutaBookmarks* bookmarks)
+{
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	gboolean status = gtk_tree_selection_get_selected (selection, NULL, NULL);
+	gtk_widget_set_sensitive (priv->button_remove, status);
+}
+
+static void
+anjuta_bookmarks_init (AnjutaBookmarks *bookmarks)
+{
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	GtkCellRenderer* renderer;
+	GtkTreeViewColumn* column;
+	GtkWidget* scrolled_window;
+	GtkWidget* button_box;
+	GtkTreeSelection* selection;
+	
+	priv->window = gtk_vbox_new (FALSE, 5);
+	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window),
+										 GTK_SHADOW_ETCHED_IN);
+	gtk_box_pack_start (GTK_BOX (priv->window), 
+						scrolled_window,
+						TRUE, TRUE, 0);
+	
+	priv->model = GTK_TREE_MODEL(gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, 
+													 G_TYPE_OBJECT, G_TYPE_INT, G_TYPE_INT));
+	priv->tree = gtk_tree_view_new_with_model (priv->model);
+	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(priv->tree), FALSE);
+	renderer = gtk_cell_renderer_text_new();
+	column = gtk_tree_view_column_new_with_attributes ("Bookmark", renderer,
+													   "text", COLUMN_TEXT, NULL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW(priv->tree), column);
+	gtk_container_add (GTK_CONTAINER(scrolled_window),
+					   priv->tree);
+	
+	g_signal_connect (G_OBJECT(priv->tree), "row-activated", G_CALLBACK(on_row_activate),
+					  bookmarks);
+	
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree));
+	g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK(on_selection_changed),
+					  bookmarks);
+	
+	
+	button_box = gtk_hbutton_box_new ();
+	priv->button_add = gtk_button_new_from_stock (GTK_STOCK_ADD);
+	priv->button_remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+	g_signal_connect (G_OBJECT(priv->button_add), "clicked", G_CALLBACK(on_add_clicked), bookmarks);
+	g_signal_connect (G_OBJECT(priv->button_remove), "clicked", G_CALLBACK(on_remove_clicked), bookmarks);
+	gtk_widget_set_sensitive (GTK_WIDGET(priv->button_add), FALSE);
+	gtk_widget_set_sensitive (GTK_WIDGET(priv->button_remove), FALSE);
+	gtk_box_pack_start_defaults (GTK_BOX(button_box), priv->button_add);
+	gtk_box_pack_start_defaults (GTK_BOX(button_box), priv->button_remove);
+
+	gtk_box_pack_start(GTK_BOX(priv->window), 
+					   button_box,
+					   FALSE, FALSE, 0);
+	gtk_widget_show_all (priv->window);
+}
+
+static void
+anjuta_bookmarks_finalize (GObject *object)
+{
+	AnjutaBookmarks* bookmarks = ANJUTA_BOOKMARKS (object);
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	anjuta_shell_remove_widget (ANJUTA_PLUGIN(priv->docman)->shell,
+								priv->window,
+								NULL);
+	
+	G_OBJECT_CLASS (anjuta_bookmarks_parent_class)->finalize (object);
+}
+
+static void
+anjuta_bookmarks_class_init (AnjutaBookmarksClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = anjuta_bookmarks_finalize;
+	
+	g_type_class_add_private (klass, sizeof (AnjutaBookmarksPrivate));
+}
+
+
+AnjutaBookmarks*
+anjuta_bookmarks_new (DocmanPlugin* docman)
+{
+	AnjutaBookmarks* bookmarks = ANJUTA_BOOKMARKS (g_object_new (ANJUTA_TYPE_BOOKMARKS, 
+																 NULL));
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	priv->docman = docman;
+	
+	anjuta_shell_add_widget (ANJUTA_PLUGIN(docman)->shell,
+							 priv->window,
+							 "bookmarks",
+							 _("Bookmarks"),
+							 ANJUTA_STOCK_BOOKMARK_TOGGLE,
+							 ANJUTA_SHELL_PLACEMENT_RIGHT,
+							 NULL);
+	
+	g_signal_connect (G_OBJECT(docman->docman), "document-changed",
+					  G_CALLBACK(on_document_changed), bookmarks);
+	g_signal_connect (G_OBJECT(docman->docman), "document-added",
+					  G_CALLBACK(on_document_added), bookmarks);	
+	return bookmarks;
+}
+
+void
+anjuta_bookmarks_add (AnjutaBookmarks* bookmarks, IAnjutaEditor* editor, gint line)
+{
+	g_return_if_fail (IANJUTA_IS_MARKABLE(editor));
+	IAnjutaMarkable* markable = IANJUTA_MARKABLE(editor);
+	GtkTreeIter iter;
+	gint handle;
+	gchar* text;
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	GFile* file;
+	
+	/* If there is already a marker -> do nothing */
+	if (ianjuta_markable_is_marker_set (markable, line, IANJUTA_MARKABLE_BOOKMARK, NULL))
+		return;
+	
+	handle = ianjuta_markable_mark (markable, line, IANJUTA_MARKABLE_BOOKMARK, NULL);
+	
+	gtk_list_store_append (GTK_LIST_STORE(priv->model), &iter);
+	text = g_strdup_printf ("%s:%d",  ianjuta_document_get_filename(IANJUTA_DOCUMENT(editor), NULL),
+							line);
+	file = ianjuta_file_get_file(IANJUTA_FILE(editor), NULL);
+	gtk_list_store_set (GTK_LIST_STORE(priv->model), &iter, 
+						COLUMN_TEXT, text,
+						COLUMN_FILE, file,
+						COLUMN_LINE, line,
+						COLUMN_HANDLE, handle,
+						-1);
+	g_free(text);
+	g_object_unref (file);
+}
+
+void
+anjuta_bookmarks_remove (AnjutaBookmarks* bookmarks)
+{
+	AnjutaBookmarksPrivate* priv = BOOKMARKS_GET_PRIVATE(bookmarks);
+	GtkTreeIter iter;
+	GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->tree));
+	if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+	{
+		GFile* file;
+		gint line;
+		IAnjutaEditor* editor;
+		gtk_tree_model_get (priv->model, &iter, 
+							COLUMN_FILE, &file,
+							COLUMN_LINE, &line,
+							-1);
+		editor = IANJUTA_EDITOR(anjuta_docman_get_document_for_file (ANJUTA_DOCMAN(priv->docman->docman),
+																	 file));
+		if (editor)
+		{
+			if (ianjuta_markable_is_marker_set (IANJUTA_MARKABLE(editor),
+												line, IANJUTA_MARKABLE_BOOKMARK, NULL))
+			{
+				ianjuta_markable_unmark (IANJUTA_MARKABLE(editor), line,
+										 IANJUTA_MARKABLE_BOOKMARK, NULL);
+			}
+		}
+		g_object_unref (file);
+		
+		gtk_list_store_remove (GTK_LIST_STORE (priv->model), &iter);
+	}
+}
+
+void
+anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* session)
+{
+	/* TODO: Add public function implementation here */
+}
+
+void
+anjuta_bookmarks_session_load (AnjutaBookmarks* bookmarks, AnjutaSession* session)
+{
+	/* TODO: Add public function implementation here */
+}

Added: trunk/plugins/document-manager/anjuta-bookmarks.h
==============================================================================
--- (empty file)
+++ trunk/plugins/document-manager/anjuta-bookmarks.h	Fri Dec 19 11:03:03 2008
@@ -0,0 +1,60 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta-trunk
+ * Copyright (C) Johannes Schmid 2008 <jhs gnome org>
+ * 
+ * anjuta-trunk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta-trunk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _ANJUTA_BOOKMARKS_H_
+#define _ANJUTA_BOOKMARKS_H_
+
+#include <glib-object.h>
+
+#include <libanjuta/interfaces/ianjuta-editor.h>
+#include <libanjuta/anjuta-session.h>
+#include "plugin.h"
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_BOOKMARKS             (anjuta_bookmarks_get_type ())
+#define ANJUTA_BOOKMARKS(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_BOOKMARKS, AnjutaBookmarks))
+#define ANJUTA_BOOKMARKS_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_BOOKMARKS, AnjutaBookmarksClass))
+#define ANJUTA_IS_BOOKMARKS(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_BOOKMARKS))
+#define ANJUTA_IS_BOOKMARKS_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_BOOKMARKS))
+#define ANJUTA_BOOKMARKS_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_BOOKMARKS, AnjutaBookmarksClass))
+
+typedef struct _AnjutaBookmarksClass AnjutaBookmarksClass;
+typedef struct _AnjutaBookmarks AnjutaBookmarks;
+
+struct _AnjutaBookmarksClass
+{
+	GObjectClass parent_class;
+};
+
+struct _AnjutaBookmarks
+{
+	GObject parent_instance;
+};
+
+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_remove (AnjutaBookmarks* bookmarks);
+void anjuta_bookmarks_session_save (AnjutaBookmarks* bookmarks, AnjutaSession* session);
+void anjuta_bookmarks_session_load (AnjutaBookmarks* bookmarks, AnjutaSession* session);
+
+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	Fri Dec 19 11:03:03 2008
@@ -84,18 +84,6 @@
 				<menuitem name="FoldToggle" action="ActionFormatFoldToggle" />
 			</menu>
 			<menu name="Goto" action="ActionMenuGoto">
-				<placeholder name="PlaceHolderBookmarkMenus">
-					<menu name="MenuBookmark" action="ActionMenuBookmark">
-						<menuitem name="Toggle" action="ActionBookmarkToggle" />
-						<separator name="separator11" />
-						<menuitem name="First" action="ActionBookmarkFirst" />
-						<menuitem name="Previous" action="ActionBookmarkPrevious" />
-						<menuitem name="Next" action="ActionBookmarkNext" />
-						<menuitem name="Last" action="ActionBookmarkLast" />
-						<separator name="separator12" />
-						<menuitem name="Clear" action="ActionBookmarkClear" />
-					</menu>
-				</placeholder>
 				<menuitem name="Line" action="ActionEditGotoLine" />
 				<menuitem name="MatchingBrace" action="ActionEditGotoMatchingBrace" />
 				<separator name="separator13"/>
@@ -131,30 +119,13 @@
 			<toolitem name="Redo" action="ActionEditRedo" />
 		</placeholder>
 	</toolbar>
-	<toolbar name="ToolbarBookmark">
-		<placeholder name="PlaceholderBrowserToolbar" >
-			<toolitem name="Toggle" action="ActionBookmarkToggle"/>
-			<toolitem name="First" action="ActionBookmarkFirst"/>
-			<toolitem name="Previous" action="ActionBookmarkPrevious"/>
-			<toolitem name="Next" action="ActionBookmarkNext"/>
-			<toolitem name="Last" action="ActionBookmarkLast"/>
-			<toolitem name="Clear" action="ActionBookmarkClear"/>
-			<separator name="separator19"/>
-			<toolitem name="BlockStart" action="ActionEditGotoBlockStart"/>
-			<toolitem name="BlockEnd" action="ActionEditGotoBlockEnd"/>
-			<separator name="separator20"/>
-		</placeholder>
-	</toolbar>
 	<popup name="PopupDocumentManager">
 		<menuitem name="Cut" action="ActionEditCut" />
 		<menuitem name="Copy" action="ActionEditCopy" />
 		<menuitem name="Paste" action="ActionEditPaste" />
 		<separator name="separator26"/>
-		<menuitem name="Toggle" action="ActionBookmarkToggle" />
 		<menu name="Goto" action="ActionMenuGoto">
 				<separator name="separator27"/>
-				<menuitem name="Previous" action="ActionBookmarkPrevious" />
-				<menuitem name="Next" action="ActionBookmarkNext" />
 				<menuitem name="HistoryPrevious" action="ActionEditGotoHistoryPrev" />
 				<menuitem name="HistoryNext" action="ActionEditGotoHistoryNext" />
 		</menu>

Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c	(original)
+++ trunk/plugins/document-manager/plugin.c	Fri Dec 19 11:03:03 2008
@@ -48,17 +48,13 @@
 #include "action-callbacks.h"
 #include "plugin.h"
 #include "search-box.h"
+#include "anjuta-bookmarks.h"
 
 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-document-manager.ui"
 #define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-document-manager.glade"
 #define ICON_FILE "anjuta-document-manager-plugin-48.png"
 
 #define ANJUTA_PIXMAP_BOOKMARK_TOGGLE     "anjuta-bookmark-toggle"
-#define ANJUTA_PIXMAP_BOOKMARK_FIRST      "anjuta-bookmark-first"
-#define ANJUTA_PIXMAP_BOOKMARK_PREV       "anjuta-bookmark-prev"
-#define ANJUTA_PIXMAP_BOOKMARK_NEXT       "anjuta-bookmark-next"
-#define ANJUTA_PIXMAP_BOOKMARK_LAST       "anjuta-bookmark-last"
-#define ANJUTA_PIXMAP_BOOKMARK_CLEAR      "anjuta-bookmark-clear"
 
 #define ANJUTA_PIXMAP_FOLD_TOGGLE         "anjuta-fold-toggle"
 #define ANJUTA_PIXMAP_FOLD_CLOSE          "anjuta-fold-close"
@@ -89,11 +85,6 @@
 #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_FIRST           "anjuta-bookmark-first"
-#define ANJUTA_STOCK_BOOKMARK_PREV            "anjuta-bookmark-previous"
-#define ANJUTA_STOCK_BOOKMARK_NEXT            "anjuta-bookmark-next"
-#define ANJUTA_STOCK_BOOKMARK_LAST            "anjuta-bookmark-last"
-#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"
@@ -365,28 +356,6 @@
     G_CALLBACK (on_editor_command_toggle_fold_activate)},
 };
 
-static GtkActionEntry actions_bookmark[] = {
-  { "ActionMenuBookmark", NULL, N_("Bookmar_k"), NULL, NULL, NULL},
-  { "ActionBookmarkToggle", ANJUTA_STOCK_BOOKMARK_TOGGLE, N_("_Toggle Bookmark"),
-	"<control>k", N_("Toggle a bookmark at the current line position"),
-    G_CALLBACK (on_editor_command_bookmark_toggle_activate)},
-  { "ActionBookmarkFirst", ANJUTA_STOCK_BOOKMARK_FIRST, N_("_First Bookmark"),
-	NULL, N_("Jump to the first bookmark in the file"),
-    G_CALLBACK (on_editor_command_bookmark_first_activate)},
-  { "ActionBookmarkPrevious", ANJUTA_STOCK_BOOKMARK_PREV, N_("_Previous Bookmark"),
-	"<control>comma", N_("Jump to the previous bookmark in the file"),
-    G_CALLBACK (on_editor_command_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_editor_command_bookmark_next_activate)},
-  { "ActionBookmarkLast", ANJUTA_STOCK_BOOKMARK_LAST, N_("_Last Bookmark"),
-	NULL, N_("Jump to the last bookmark in the file"),
-    G_CALLBACK (on_editor_command_bookmark_last_activate)},
-  { "ActionBookmarkClear", ANJUTA_STOCK_BOOKMARK_CLEAR, N_("_Clear All Bookmarks"),
-	NULL, N_("Clear bookmarks"),
-    G_CALLBACK (on_editor_command_bookmark_clear_activate)},
-};
-
 static GtkActionEntry actions_documents[] = {
   {"ActionMenuDocuments", NULL, N_("_Documents"), NULL, NULL, NULL},
   { "ActionDocumentsPrevious", GTK_STOCK_GO_BACK, N_("Previous Document"),
@@ -423,7 +392,6 @@
 	{ actions_zoom, G_N_ELEMENTS (actions_zoom), "ActionGroupEditorZoom", N_("Editor zoom operations") },
 	{ 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_bookmark, G_N_ELEMENTS (actions_bookmark), "ActionGroupEditorBookmark", N_("Editor bookmarks") },
 	{ actions_search, G_N_ELEMENTS (actions_search), "ActionGroupEditorSearch", N_("Simple searching") },
 	{ actions_documents, G_N_ELEMENTS (actions_documents), "ActionGroupDocuments", N_("Documents") }
 };
@@ -894,11 +862,6 @@
 	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_FIRST, ANJUTA_STOCK_BOOKMARK_FIRST);
-	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_LAST, ANJUTA_STOCK_BOOKMARK_LAST);
-	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);
@@ -1769,6 +1732,9 @@
 	g_signal_connect (G_OBJECT (plugin->shell), "save-prompt",
 					  G_CALLBACK (on_save_prompt), plugin);
 	
+	/* Add bookmarks widget */
+	dplugin->bookmarks = G_OBJECT(anjuta_bookmarks_new (dplugin));
+	
 	dplugin->project_watch_id =
 		anjuta_plugin_add_watch (plugin, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI,
 								 value_added_project_root_uri,
@@ -1818,6 +1784,7 @@
 	/* Widget is removed from the container when destroyed */
 	gtk_widget_destroy (eplugin->docman);
 	gtk_widget_destroy (eplugin->search_box);	/* the default searchbox instance may still be unparented */
+	g_object_unref (eplugin->bookmarks);
 	anjuta_ui_unmerge (ui, eplugin->uiid);
 	node = eplugin->action_groups;
 	while (node)

Modified: trunk/plugins/document-manager/plugin.h
==============================================================================
--- trunk/plugins/document-manager/plugin.h	(original)
+++ trunk/plugins/document-manager/plugin.h	Fri Dec 19 11:03:03 2008
@@ -49,6 +49,9 @@
 	
 	/* Base box of the widget */
 	GtkWidget* vbox;
+	
+	/* Bookmarks */
+	GObject* bookmarks;
 };
 
 struct _DocmanPluginClass{

Modified: trunk/plugins/editor/aneditor.cxx
==============================================================================
--- trunk/plugins/editor/aneditor.cxx	(original)
+++ trunk/plugins/editor/aneditor.cxx	Fri Dec 19 11:03:03 2008
@@ -726,6 +726,11 @@
 
 void AnEditor::BookmarkToggle( int lineno ) {
 	if (lineno == -1)
+		
+		
+		
+		
+		
 		lineno = GetCurrentLineNumber();
 	int state = SendEditor(SCI_MARKERGET, lineno);
 	if ( state & (1 << ANE_MARKER_BOOKMARK))

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Fri Dec 19 11:03:03 2008
@@ -48,7 +48,6 @@
 #include <libanjuta/interfaces/ianjuta-editor-assist.h>
 #include <libanjuta/interfaces/ianjuta-editor-search.h>
 #include <libanjuta/interfaces/ianjuta-editor-hover.h>
-#include <libanjuta/interfaces/ianjuta-bookmark.h>
 #include <libanjuta/interfaces/ianjuta-editor-factory.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-file-savable.h>
@@ -3161,56 +3160,6 @@
 	iface->get_count = iview_get_count;
 }
 
-/* IAnjutaBookmark implementation */
-static void
-ibookmark_toggle(IAnjutaBookmark* view, gint location,
-			  gboolean ensure_visible, GError **e)
-{
-	text_editor_goto_line (TEXT_EDITOR(view), location, FALSE, ensure_visible);
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_TOGGLE, 0, 0);
-}
-
-static void
-ibookmark_first(IAnjutaBookmark* view, GError **e)
-{
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_FIRST, 0, 0);
-}
-
-static void
-ibookmark_last(IAnjutaBookmark* view, GError **e)
-{
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_LAST, 0, 0);
-}
-
-static void
-ibookmark_next(IAnjutaBookmark* view, GError **e)
-{
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_NEXT, 0, 0);
-}
-
-static void
-ibookmark_previous(IAnjutaBookmark* view, GError **e)
-{
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_PREV, 0, 0);
-}
-
-static void
-ibookmark_clear_all(IAnjutaBookmark* view, GError **e)
-{
-	text_editor_command(TEXT_EDITOR(view), ANE_BOOKMARK_CLEAR, 0, 0);
-}
-
-static void
-ibookmark_iface_init(IAnjutaBookmarkIface* iface)
-{
-	iface->toggle = ibookmark_toggle;
-	iface->first = ibookmark_first;
-	iface->last = ibookmark_last;
-	iface->next = ibookmark_next;
-	iface->previous = ibookmark_previous;
-	iface->clear_all = ibookmark_clear_all;
-}
-
 static void
 iindicable_set (IAnjutaIndicable *te, IAnjutaIterable *begin_location,
 				IAnjutaIterable *end_location,
@@ -3659,7 +3608,6 @@
 ANJUTA_TYPE_ADD_INTERFACE(ilanguage, IANJUTA_TYPE_EDITOR_LANGUAGE);
 ANJUTA_TYPE_ADD_INTERFACE(iview, IANJUTA_TYPE_EDITOR_VIEW);
 ANJUTA_TYPE_ADD_INTERFACE(ifolds, IANJUTA_TYPE_EDITOR_FOLDS);
-ANJUTA_TYPE_ADD_INTERFACE(ibookmark, IANJUTA_TYPE_BOOKMARK);
 ANJUTA_TYPE_ADD_INTERFACE(imarkable, IANJUTA_TYPE_MARKABLE);
 ANJUTA_TYPE_ADD_INTERFACE(iindicable, IANJUTA_TYPE_INDICABLE);
 ANJUTA_TYPE_ADD_INTERFACE(iprint, IANJUTA_TYPE_PRINT);

Modified: trunk/plugins/file-manager/file-view.c
==============================================================================
--- trunk/plugins/file-manager/file-view.c	(original)
+++ trunk/plugins/file-manager/file-view.c	Fri Dec 19 11:03:03 2008
@@ -26,14 +26,8 @@
 #include "file-model.h"
 #include "file-view-marshal.h"
 
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-#include <gtk/gtkcellrendererprogress.h>
-#include <gtk/gtktreestore.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtktreemodelsort.h>
-#include <gtk/gtkversion.h>
 #include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
 
 #include <gio/gio.h>
 
@@ -42,8 +36,6 @@
 #define HAVE_TOOLTIP_API (GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 12))
 #include <glib/gi18n.h>
 
-#include <gtk/gtktooltip.h>
-
 #include <libanjuta/anjuta-debug.h>
 
 typedef struct _AnjutaFileViewPrivate AnjutaFileViewPrivate;
@@ -107,90 +99,54 @@
 		return NULL;
 }
 
-static gboolean
-file_view_button_press_event (GtkWidget* widget, GdkEventButton* event)
+static void
+file_view_row_activated (GtkTreeView* widget, GtkTreePath* sort_path,
+						 GtkTreeViewColumn* column)
 {
 	AnjutaFileView* view = ANJUTA_FILE_VIEW (widget);
 	AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view);
 	GtkTreeIter selected;
-	gboolean is_dir;
 	GtkTreePath* path = NULL;
+	gboolean is_dir;
 	GFile* file;
-	gboolean retval = 	
-		GTK_WIDGET_CLASS (file_view_parent_class)->button_press_event (widget,
-																	   event);	
 	
-	DEBUG_PRINT ("%s", "Button pressed");
+	GtkTreeIter select_iter;
+	GtkTreeModel* sort_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
+	gtk_tree_model_get_iter (sort_model, &selected, sort_path);
+	gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(sort_model),
+												   &select_iter, &selected);
+	gtk_tree_model_get (GTK_TREE_MODEL(priv->model), &select_iter,
+						COLUMN_IS_DIR, &is_dir,
+						-1);
+	file = file_model_get_file (priv->model, &select_iter);
 	
-	GtkTreeSelection* selection = 
-		gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
-	
-	if (gtk_tree_selection_get_selected (selection, NULL, &selected))
-	{
-		GtkTreeIter select_iter;
-		GtkTreeModel* sort_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
-		gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(sort_model),
-													   &select_iter, &selected);
-		gtk_tree_model_get (GTK_TREE_MODEL(priv->model), &select_iter,
-							COLUMN_IS_DIR, &is_dir,
-							-1);
-		file = file_model_get_file (priv->model, &select_iter);
+	path = gtk_tree_model_get_path(sort_model, &selected);
 		
-		path = gtk_tree_model_get_path(sort_model, &selected);
-	}
-	else
-	{
-		file = NULL;
-		is_dir = FALSE;
-	}
-		
-	switch (event->button)
+	if (is_dir)
 	{
-		case 1: /* Left mouse button */
+		if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (view),
+										 path))
 		{
-			if (event->type == GDK_2BUTTON_PRESS)
-			{
-				if (is_dir)
-				{
-					if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (view),
-													 path))
-					{
-						gtk_tree_view_expand_row (GTK_TREE_VIEW (view),
-												  path,
-												  FALSE);
-					}
-					else
-					{
-						gtk_tree_view_collapse_row (GTK_TREE_VIEW (view),
-													path);
-					}	
-				}
-				else
-				{
-					g_signal_emit_by_name (G_OBJECT (view),
-										   "file-open",
-										   file);
-				}
-			}
-			break;
+			gtk_tree_view_expand_row (GTK_TREE_VIEW (view),
+									  path,
+									  FALSE);
 		}
-		case 3: /* Right mouse button */
+		else
 		{
-			g_signal_emit_by_name (G_OBJECT (view),
-								   "show-popup-menu",
-								   file,
-								   is_dir,
-								   event->button,
-								   event->time);
-			break;
-		}
+			gtk_tree_view_collapse_row (GTK_TREE_VIEW (view),
+										path);
+		}	
+	}
+	else
+	{
+		g_signal_emit_by_name (G_OBJECT (view),
+							   "file-open",
+							   file);
 	}
 	if (file)
 		g_object_unref (file);
 	if (path)
 		gtk_tree_path_free(path);
-	
-	return retval;
 }
 
 static gboolean
@@ -227,6 +183,69 @@
 																	event);
 }
 
+static void 
+file_view_do_popup_menu (GtkWidget* widget, GdkEventButton* event)
+{
+	AnjutaFileView* view = ANJUTA_FILE_VIEW (widget);
+	AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view);
+	GtkTreeSelection* selection = 
+			gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+	GFile* file = NULL;
+	gboolean is_dir = FALSE;
+	GtkTreeIter selected;
+	gint button, event_time;
+	
+	if (gtk_tree_selection_get_selected (selection, NULL, &selected))
+	{
+		GtkTreeIter select_iter;
+		GtkTreeModel* sort_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
+		gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(sort_model),
+													   &select_iter, &selected);
+		gtk_tree_model_get (GTK_TREE_MODEL(priv->model), &select_iter,
+							COLUMN_IS_DIR, &is_dir,
+							-1);
+		file = file_model_get_file (priv->model, &select_iter);
+		
+	}
+	if (event)
+	{
+		button = event->button;
+		event_time = event->time;
+	}
+	else
+	{
+		button = 0;
+		event_time = gtk_get_current_event_time ();
+	}
+		
+	g_signal_emit_by_name (G_OBJECT(widget), "show-popup-menu",
+						   file, is_dir, button, event_time);
+	if (file)
+		g_object_unref (file);
+}
+
+static gboolean
+file_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
+{
+  /* Ignore double-clicks and triple-clicks */
+  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+    {
+      file_view_do_popup_menu (widget, event);
+      return TRUE;
+    }
+
+ return 	
+		GTK_WIDGET_CLASS (file_view_parent_class)->button_press_event (widget,
+																	   event);
+}
+
+static gboolean
+file_view_popup_menu (GtkWidget* widget)
+{
+	file_view_do_popup_menu(widget, NULL);
+	return TRUE;
+}
+
 static void
 file_view_show_extended_data (AnjutaFileView* view, GtkTreeIter* iter)
 {
@@ -482,6 +501,7 @@
 {
 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
 	GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+	GtkTreeViewClass* tree_class = GTK_TREE_VIEW_CLASS(klass);
 	
 	g_type_class_add_private (klass, sizeof (AnjutaFileViewPrivate));
 	
@@ -534,8 +554,10 @@
 				  G_TYPE_INT,
 				  NULL);
 	
-	widget_class->button_press_event = file_view_button_press_event;
+	tree_class->row_activated = file_view_row_activated;
 	widget_class->key_press_event = file_view_key_press_event;
+	widget_class->popup_menu = file_view_popup_menu;
+	widget_class->button_press_event = file_view_button_press_event;
 	
 	/* Tooltips */
 	widget_class->query_tooltip = file_view_query_tooltip;	

Modified: trunk/plugins/search/search-replace.c
==============================================================================
--- trunk/plugins/search/search-replace.c	(original)
+++ trunk/plugins/search/search-replace.c	Fri Dec 19 11:03:03 2008
@@ -33,7 +33,6 @@
 #include <libanjuta/interfaces/ianjuta-editor.h>
 #include <libanjuta/interfaces/ianjuta-editor-selection.h>
 #include <libanjuta/interfaces/ianjuta-markable.h>
-#include <libanjuta/interfaces/ianjuta-bookmark.h>
 #include <libanjuta/interfaces/ianjuta-indicable.h>
 
 #include "search-replace_backend.h"
@@ -438,8 +437,8 @@
 														IANJUTA_MARKABLE_BOOKMARK,
 														NULL))
 							{
-								ianjuta_bookmark_toggle (IANJUTA_BOOKMARK(fb->te),
-														mi->line, FALSE, NULL);
+								//TODO:ianjuta_bookmark_toggle (IANJUTA_BOOKMARK(fb->te),
+								//						mi->line, FALSE, NULL);
 							}
 						}
 						break;

Modified: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.c	(original)
+++ trunk/plugins/sourceview/sourceview-io.c	Fri Dec 19 11:03:03 2008
@@ -220,8 +220,6 @@
 	g_output_stream_write_finish (G_OUTPUT_STREAM(output_stream),
 								  result,
 								  &err);
-	g_free (sio->write_buffer);
-	sio->write_buffer = NULL;
 	if (err)
 	{
 		g_signal_emit_by_name (sio, "save-failed", err);
@@ -231,9 +229,11 @@
 	{
 		set_display_name (sio);
 		g_output_stream_close(G_OUTPUT_STREAM (output_stream), NULL, NULL);
-		setup_monitor (sio);
 		g_signal_emit_by_name (sio, "save-finished");
+		setup_monitor (sio);
 	}
+	g_free (sio->write_buffer);
+	sio->write_buffer = NULL;
 	g_object_unref (output_stream);
 }
 

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Fri Dec 19 11:03:03 2008
@@ -32,7 +32,6 @@
 #include <libanjuta/interfaces/ianjuta-file-savable.h>
 #include <libanjuta/interfaces/ianjuta-markable.h>
 #include <libanjuta/interfaces/ianjuta-indicable.h>
-#include <libanjuta/interfaces/ianjuta-bookmark.h>
 #include <libanjuta/interfaces/ianjuta-print.h>
 #include <libanjuta/interfaces/ianjuta-language-support.h>
 #include <libanjuta/interfaces/ianjuta-document.h>
@@ -1770,139 +1769,6 @@
 }
 
 static void
-ibookmark_toggle(IAnjutaBookmark* bmark, gint location, gboolean ensure_visible, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkSourceBuffer* buffer = GTK_SOURCE_BUFFER(sv->priv->document);
-	
-	GSList* markers;
-	
-	markers = gtk_source_buffer_get_source_marks_at_line (buffer, LOCATION_TO_LINE (location),
-												   marker_types[IANJUTA_MARKABLE_BOOKMARK]);
-	if (markers != NULL)
-	{
-		GtkTextIter begin;
-		GtkTextIter end;
-		
-		gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer), &begin, LOCATION_TO_LINE (location));
-		gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer), &end, LOCATION_TO_LINE (location));
-		
-		gtk_source_buffer_remove_source_marks (buffer, &begin, &end, 
-										marker_types[IANJUTA_MARKABLE_BOOKMARK]);
-	}
-	else
-	{
-		GtkTextIter line;
-		GtkSourceMark* bookmark;
-		gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer),
-															 &line, LOCATION_TO_LINE (location));
-		
-		bookmark = 
-			gtk_source_buffer_create_source_mark (buffer, NULL,
-											 marker_types [IANJUTA_MARKABLE_BOOKMARK],
-											 &line);
-	}
-}
-
-static void
-goto_bookmark (Sourceview* sv, GtkTextIter* iter, gboolean backward)
-{
-	GtkSourceBuffer* buffer = GTK_SOURCE_BUFFER(sv->priv->document);
-	gboolean found = FALSE;
-	
-	if (backward)
-		found = gtk_source_buffer_backward_iter_to_source_mark (buffer, iter, 
-														 marker_types[IANJUTA_MARKABLE_BOOKMARK]);
-	else
-		found = gtk_source_buffer_forward_iter_to_source_mark (buffer, iter, 
-														marker_types[IANJUTA_MARKABLE_BOOKMARK]);
-	if (found)
-	{
-		ianjuta_editor_goto_line(IANJUTA_EDITOR(sv), 
-								 LINE_TO_LOCATION (gtk_text_iter_get_line (iter)), NULL);
-	}
-}
-
-static void
-ibookmark_first(IAnjutaBookmark* bmark, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkSourceBuffer* buffer = GTK_SOURCE_BUFFER(sv->priv->document);
-	GtkTextIter begin;
-	
-	gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer), &begin, 0);
-	
-	goto_bookmark (sv, &begin, FALSE);
-}
-
-
-static void
-ibookmark_last(IAnjutaBookmark* bmark, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkSourceBuffer* buffer = GTK_SOURCE_BUFFER(sv->priv->document);;
-	GtkTextIter begin;
-	
-	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &begin, -1);
-	
-	goto_bookmark (sv, &begin, TRUE);
-}
-
-static void
-ibookmark_next(IAnjutaBookmark* bmark, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
-	GtkTextIter begin;
-	
-	gtk_text_buffer_get_iter_at_mark (buffer, &begin,
-									  gtk_text_buffer_get_insert (buffer));
-	gtk_text_iter_forward_line (&begin);
-	
-	goto_bookmark (sv, &begin, FALSE);
-}
-
-static void
-ibookmark_previous(IAnjutaBookmark* bmark, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
-	GtkTextIter begin;
-	
-	gtk_text_buffer_get_iter_at_mark (buffer, &begin,
-									  gtk_text_buffer_get_insert (buffer));
-	gtk_text_iter_backward_line (&begin);
-	
-	goto_bookmark (sv, &begin, TRUE);
-
-}
-
-static void
-ibookmark_clear_all(IAnjutaBookmark* bmark, GError** e)
-{
-	Sourceview* sv = ANJUTA_SOURCEVIEW(bmark);
-	GtkSourceBuffer* buffer = GTK_SOURCE_BUFFER(sv->priv->document);
-	GtkTextIter begin;
-	GtkTextIter end;
-	
-	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &begin, 0);
-	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &end, -1);
-	
-	gtk_source_buffer_remove_source_marks (buffer, &begin, &end, marker_types[IANJUTA_MARKABLE_BOOKMARK]);
-}
-
-static void
-ibookmark_iface_init(IAnjutaBookmarkIface* iface)
-{
-	iface->toggle = ibookmark_toggle;
-	iface->first = ibookmark_first;
-	iface->last = ibookmark_last;
-	iface->next = ibookmark_next;
-	iface->previous = ibookmark_previous;
-	iface->clear_all = ibookmark_clear_all;
-}
-
-static void
 iprint_print(IAnjutaPrint* print, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(print);
@@ -2371,7 +2237,6 @@
 ANJUTA_TYPE_ADD_INTERFACE(iselect, IANJUTA_TYPE_EDITOR_SELECTION);
 ANJUTA_TYPE_ADD_INTERFACE(iassist, IANJUTA_TYPE_EDITOR_ASSIST);
 ANJUTA_TYPE_ADD_INTERFACE(iconvert, IANJUTA_TYPE_EDITOR_CONVERT);
-ANJUTA_TYPE_ADD_INTERFACE(ibookmark, IANJUTA_TYPE_BOOKMARK);
 ANJUTA_TYPE_ADD_INTERFACE(iprint, IANJUTA_TYPE_PRINT);
 ANJUTA_TYPE_ADD_INTERFACE(ilanguage, IANJUTA_TYPE_EDITOR_LANGUAGE);
 ANJUTA_TYPE_ADD_INTERFACE(isearch, IANJUTA_TYPE_EDITOR_SEARCH);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]