anjuta r4013 - in trunk: . libanjuta libanjuta/interfaces plugins/document-manager plugins/sourceview



Author: jhs
Date: Fri Jun 13 22:41:29 2008
New Revision: 4013
URL: http://svn.gnome.org/viewvc/anjuta?rev=4013&view=rev

Log:
2008-06-14   Louis-Francis RattÃ-Boulianne  <louisfrancis rb gmail com>

	reviewed by: Johannes Schmid <jhs gnome org>

	* libanjuta/Makefile.am:
	* libanjuta/interfaces/libanjuta.idl:
	* plugins/document-manager/anjuta-docman.c
	(anjuta_docman_update_documents_menu),
	(on_notebook_page_close_button_click), (anjuta_docman_page_init),
	(on_notebook_switch_page), (on_document_save_point),
	(on_document_destroy), (anjuta_docman_remove_document),
	(anjuta_docman_get_page_for_document),
	(anjuta_docman_get_nth_page), (anjuta_docman_set_current_document),
	(anjuta_docman_set_message_area), (anjuta_docman_get_uri),
	(anjuta_docman_present_notebook_page),
	(anjuta_docman_update_page_label),
	(anjuta_docman_delete_all_markers),
	(anjuta_docman_delete_all_indicators), (anjuta_docman_order_tabs),
	(anjuta_docman_get_document_for_uri),
	(anjuta_docman_get_all_doc_widgets):
	* plugins/document-manager/anjuta-docman.h:
	* plugins/document-manager/plugin.c:
	* plugins/sourceview/sourceview.c (on_reload_dialog_response),
	(on_sourceview_uri_changed_prompt):
	
	#530215 â Have a message area like gedit
	
	Commited with a trivial change to make sure it doesn\'t crash when a project is
	closed.

Added:
   trunk/libanjuta/anjuta-message-area.c
   trunk/libanjuta/anjuta-message-area.h
Modified:
   trunk/ChangeLog
   trunk/libanjuta/Makefile.am
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/document-manager/anjuta-docman.c
   trunk/plugins/document-manager/anjuta-docman.h
   trunk/plugins/document-manager/plugin.c
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/libanjuta/Makefile.am
==============================================================================
--- trunk/libanjuta/Makefile.am	(original)
+++ trunk/libanjuta/Makefile.am	Fri Jun 13 22:41:29 2008
@@ -31,6 +31,7 @@
 	anjuta-status.c \
 	anjuta-encodings.c \
 	anjuta-convert.c \
+	anjuta-message-area.c \
 	anjuta-preferences-dialog.c \
 	anjuta-preferences.c \
 	anjuta-plugin.c \
@@ -66,7 +67,8 @@
 	anjuta-command.c \
 	anjuta-command.h \
 	anjuta-async-command.c \
-	anjuta-async-command.h
+	anjuta-async-command.h \
+	anjuta-message-area.h
 
 if HAVE_PLUGIN_GLADE
 
@@ -99,6 +101,7 @@
 	anjuta-status.h \
 	anjuta-encodings.h \
 	anjuta-convert.h \
+	anjuta-message-area.h \
 	anjuta-plugin.h \
 	anjuta-plugin-description.h \
 	anjuta-plugin-manager.h \

Added: trunk/libanjuta/anjuta-message-area.c
==============================================================================
--- (empty file)
+++ trunk/libanjuta/anjuta-message-area.c	Fri Jun 13 22:41:29 2008
@@ -0,0 +1,386 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta-message-area.c
+ * This file is part of anjuta
+ *
+ * Copyright (C) 2005 - Paolo Maggi
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the anjuta Team, 2005. See the AUTHORS file for a
+ * list of people on the anjuta Team.
+ * See the ChangeLog files for a list of changes.
+ *
+ * $Id$
+ */
+
+/* TODO: Style properties */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "anjuta-message-area.h"
+#include "anjuta-utils.h"
+
+#define ANJUTA_MESSAGE_AREA_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+                                                ANJUTA_TYPE_MESSAGE_AREA, \
+                                                AnjutaMessageAreaPrivate))
+
+struct _AnjutaMessageAreaPrivate
+{
+	GtkWidget *label;
+	GtkWidget *image;
+	GtkWidget *action_area;
+
+	gboolean changing_style;
+};
+
+typedef struct _ResponseData ResponseData;
+
+struct _ResponseData
+{
+	gint response_id;
+};
+
+enum {
+	RESPONSE,
+	CLOSE,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE(AnjutaMessageArea, anjuta_message_area, GTK_TYPE_HBOX)
+
+static void
+anjuta_message_area_finalize (GObject *object)
+{
+	G_OBJECT_CLASS (anjuta_message_area_parent_class)->finalize (object);
+}
+
+static ResponseData *
+get_response_data (GtkWidget *widget, gboolean create)
+{
+	ResponseData *ad = g_object_get_data (G_OBJECT (widget),
+	                                      "anjuta-message-area-response-data");
+
+	if (ad == NULL && create)
+	{
+		ad = g_new (ResponseData, 1);
+
+		g_object_set_data_full (G_OBJECT (widget),
+		                        "anjuta-message-area-response-data",
+		                        ad,
+		                        g_free);
+		}
+
+	return ad;
+}
+
+static gboolean
+paint_message_area (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
+{
+	gtk_paint_flat_box (widget->style,
+	                    widget->window,
+	                    GTK_STATE_NORMAL,
+	                    GTK_SHADOW_OUT,
+	                    NULL,
+	                    widget,
+	                    "tooltip",
+	                    widget->allocation.x + 1,
+	                    widget->allocation.y + 1,
+	                    widget->allocation.width - 2,
+	                    widget->allocation.height - 2);
+
+	return FALSE;
+}
+
+static void
+anjuta_message_area_class_init (AnjutaMessageAreaClass *klass)
+{
+	GObjectClass *object_class;
+	GtkBindingSet *binding_set;
+
+	object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = anjuta_message_area_finalize;
+
+	//klass->close = anjuta_message_area_close;
+
+	g_type_class_add_private (object_class, sizeof(AnjutaMessageAreaPrivate));
+
+	signals[RESPONSE] = g_signal_new ("response",
+					  G_OBJECT_CLASS_TYPE (klass),
+					  G_SIGNAL_RUN_LAST,
+					  G_STRUCT_OFFSET (AnjutaMessageAreaClass, response),
+					  NULL, NULL,
+					  g_cclosure_marshal_VOID__INT,
+					  G_TYPE_NONE, 1,
+					  G_TYPE_INT);
+
+	signals[CLOSE] =  g_signal_new ("close",
+					G_OBJECT_CLASS_TYPE (klass),
+					G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+					G_STRUCT_OFFSET (AnjutaMessageAreaClass, close),
+					NULL, NULL,
+					g_cclosure_marshal_VOID__VOID,
+					G_TYPE_NONE, 0);
+
+	binding_set = gtk_binding_set_by_class (klass);
+
+	gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
+}
+
+static void
+style_set (GtkWidget *widget, GtkStyle *prev_style, AnjutaMessageArea *message_area)
+{
+	GtkWidget *window;
+	GtkStyle *style;
+
+	if (message_area->priv->changing_style)
+		return;
+
+	/* This is a hack needed to use the tooltip background color */
+	window = gtk_window_new (GTK_WINDOW_POPUP);
+	gtk_widget_set_name (window, "gtk-tooltip");
+	gtk_widget_ensure_style (window);
+	style = gtk_widget_get_style (window);
+
+	message_area->priv->changing_style = TRUE;
+	gtk_widget_set_style (GTK_WIDGET (message_area), style);
+	message_area->priv->changing_style = FALSE;
+
+	gtk_widget_destroy (window);
+
+	gtk_widget_queue_draw (GTK_WIDGET (message_area));
+}
+
+static void
+anjuta_message_area_init (AnjutaMessageArea *message_area)
+{
+	GtkWidget *main_hbox;
+	GtkWidget *image;
+	GtkWidget *label;
+	
+	message_area->priv = ANJUTA_MESSAGE_AREA_GET_PRIVATE (message_area);
+
+	main_hbox = gtk_hbox_new (FALSE, 16);
+	gtk_widget_show (main_hbox);
+
+	image = gtk_image_new ();
+	gtk_widget_show (image);
+	gtk_box_pack_start (GTK_BOX (main_hbox), image, FALSE, FALSE, 0);
+	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
+	message_area->priv->image = image;
+
+	label = gtk_label_new (NULL);
+	gtk_widget_show (label);
+	gtk_box_pack_start (GTK_BOX (main_hbox), label, TRUE, TRUE, 0);
+	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+	GTK_WIDGET_SET_FLAGS (label, GTK_CAN_FOCUS);
+	gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+	message_area->priv->label = label;
+
+	gtk_widget_show (main_hbox);
+	gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 8);
+
+	message_area->priv->action_area = gtk_vbox_new (TRUE, 8);
+	gtk_widget_show (message_area->priv->action_area);
+	gtk_box_pack_end (GTK_BOX (main_hbox),
+	                  message_area->priv->action_area,
+	                  FALSE,
+	                  FALSE,
+	                  0);
+
+	gtk_box_pack_start (GTK_BOX (message_area),
+	                    main_hbox,
+	                    TRUE,
+	                    TRUE,
+	                    0);
+
+	gtk_widget_set_app_paintable (GTK_WIDGET (message_area), TRUE);
+
+	g_signal_connect (message_area,
+	                  "expose-event",
+	                  G_CALLBACK (paint_message_area),
+	                  NULL);
+
+	/* Note that we connect to style-set on one of the internal
+	 * widgets, not on the message area itself, since gtk does
+	 * not deliver any further style-set signals for a widget on
+	 * which the style has been forced with gtk_widget_set_style() */
+	g_signal_connect (main_hbox,
+	                  "style-set",
+	                  G_CALLBACK (style_set),
+	                  message_area);
+}
+
+static gint
+get_response_for_widget (AnjutaMessageArea *message_area, GtkWidget *widget)
+{
+	ResponseData *rd;
+
+	rd = get_response_data (widget, FALSE);
+	if (!rd)
+		return GTK_RESPONSE_NONE;
+	else
+		return rd->response_id;
+}
+
+static void
+action_widget_activated (GtkWidget *widget, AnjutaMessageArea *message_area)
+{
+	gint response_id;
+
+	response_id = get_response_for_widget (message_area, widget);
+	anjuta_message_area_response (message_area, response_id);
+}
+
+void
+anjuta_message_area_set_text (AnjutaMessageArea *message_area,
+                              const gchar *text)
+{
+	gchar *markup;
+
+	if (text != NULL)
+	{
+		markup = g_strdup_printf ("<b>%s</b>", text);
+		gtk_label_set_markup (GTK_LABEL (message_area->priv->label), markup);
+		g_free (markup);
+	}
+}
+
+void
+anjuta_message_area_set_image (AnjutaMessageArea *message_area,
+                               const gchar *icon_stock_id)
+{
+	if (icon_stock_id != NULL)
+	{
+		gtk_image_set_from_stock (GTK_IMAGE (message_area->priv->image),
+		                          icon_stock_id, GTK_ICON_SIZE_DIALOG);
+	}
+}
+
+static void
+anjuta_message_area_add_action_widget (AnjutaMessageArea *message_area, 
+									   GtkWidget *child, gint response_id)
+{
+	ResponseData *ad;
+	guint signal_id;
+	GClosure *closure;
+
+	g_return_if_fail (ANJUTA_IS_MESSAGE_AREA (message_area));
+	g_return_if_fail (GTK_IS_BUTTON (child));
+
+	ad = get_response_data (child, TRUE);
+
+	ad->response_id = response_id;
+
+	signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
+	closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
+					 G_OBJECT (message_area));
+
+	g_signal_connect_closure_by_id (child,
+	                                signal_id,
+	                                0,
+	                                closure,
+	                                FALSE);
+
+	gtk_box_pack_start (GTK_BOX (message_area->priv->action_area),
+	                             child,
+	                             FALSE,
+	                             FALSE,
+	                             0);
+}
+
+GtkWidget *
+anjuta_message_area_new (const gchar    *text,
+                         const gchar    *icon_stock_id)
+{
+	AnjutaMessageArea *message_area;
+	
+	message_area = g_object_new (ANJUTA_TYPE_MESSAGE_AREA, NULL);
+	anjuta_message_area_set_text (message_area, text);
+	anjuta_message_area_set_image (message_area, icon_stock_id);
+	
+	return GTK_WIDGET (message_area);
+}
+void
+anjuta_message_area_response (AnjutaMessageArea *message_area,
+							  gint			   response_id)
+{
+	g_return_if_fail (ANJUTA_IS_MESSAGE_AREA (message_area));
+
+	g_signal_emit (message_area,
+				   signals[RESPONSE],
+				   0,
+				   response_id);
+}
+
+GtkWidget*
+anjuta_message_area_add_button (AnjutaMessageArea *message_area,
+								const gchar       *button_text,
+								gint               response_id)
+{
+	GtkWidget *button;
+
+	g_return_val_if_fail (ANJUTA_IS_MESSAGE_AREA (message_area), NULL);
+	g_return_val_if_fail (button_text != NULL, NULL);
+
+	button = gtk_button_new_from_stock (button_text);
+
+	GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+
+	gtk_widget_show (button);
+
+	anjuta_message_area_add_action_widget (message_area,
+	                                       button,
+	                                       response_id);
+
+	return button;
+}
+
+GtkWidget *
+anjuta_message_area_add_button_with_stock_image (AnjutaMessageArea *message_area,
+                                                 const gchar	   *text,
+                                                 const gchar	   *stock_id,
+                                                 gint			   response_id)
+{
+	GtkWidget *button;
+
+	g_return_val_if_fail (ANJUTA_IS_MESSAGE_AREA (message_area), NULL);
+	g_return_val_if_fail (text != NULL, NULL);
+	g_return_val_if_fail (stock_id != NULL, NULL);
+
+	button = anjuta_util_button_new_with_stock_image (text, stock_id);
+	gtk_widget_show (button);
+
+	anjuta_message_area_add_action_widget (message_area,
+										   button,
+										   response_id);
+
+	return button;
+}
+

Added: trunk/libanjuta/anjuta-message-area.h
==============================================================================
--- (empty file)
+++ trunk/libanjuta/anjuta-message-area.h	Fri Jun 13 22:41:29 2008
@@ -0,0 +1,111 @@
+/*
+ * anjuta-message-area.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2005 - Paolo Maggi 
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, 
+ * Boston, MA 02111-1307, USA.
+ */
+ 
+/*
+ * Modified by the gedit Team, 2005. See the AUTHORS file for a 
+ * list of people on the gedit Team.  
+ * See the ChangeLog files for a list of changes. 
+ *
+ * $Id$
+ */
+
+#ifndef __ANJUTA_MESSAGE_AREA_H__
+#define __ANJUTA_MESSAGE_AREA_H__
+
+#include <gtk/gtkhbox.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define ANJUTA_TYPE_MESSAGE_AREA              (anjuta_message_area_get_type())
+#define ANJUTA_MESSAGE_AREA(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), ANJUTA_TYPE_MESSAGE_AREA, AnjutaMessageArea))
+#define ANJUTA_MESSAGE_AREA_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), ANJUTA_TYPE_MESSAGE_AREA, AnjutaMessageAreaClass))
+#define ANJUTA_IS_MESSAGE_AREA(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), ANJUTA_TYPE_MESSAGE_AREA))
+#define ANJUTA_IS_MESSAGE_AREA_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_MESSAGE_AREA))
+#define ANJUTA_MESSAGE_AREA_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), ANJUTA_TYPE_MESSAGE_AREA, AnjutaMessageAreaClass))
+
+/* Private structure type */
+typedef struct _AnjutaMessageAreaPrivate AnjutaMessageAreaPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _AnjutaMessageArea AnjutaMessageArea;
+
+struct _AnjutaMessageArea 
+{
+	GtkHBox parent;
+
+	/*< private > */
+	AnjutaMessageAreaPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _AnjutaMessageAreaClass AnjutaMessageAreaClass;
+
+struct _AnjutaMessageAreaClass 
+{
+	GtkHBoxClass parent_class;
+
+	/* Signals */
+	void (* response) (AnjutaMessageArea *message_area, gint response_id);
+
+	/* Keybinding signals */
+	void (* close)    (AnjutaMessageArea *message_area);	
+};
+
+/*
+ * Public methods
+ */
+GType 		 anjuta_message_area_get_type 		(void) G_GNUC_CONST;
+
+GtkWidget	*anjuta_message_area_new      		(const gchar       *text,
+                                                 const gchar       *icon_stock_id);
+
+void         anjuta_message_area_set_text       (AnjutaMessageArea *message_area,
+                                                 const gchar *text);
+
+void         anjuta_message_area_set_image      (AnjutaMessageArea *message_area,
+                                                 const gchar *icon_stock_id);
+
+GtkWidget	*anjuta_message_area_add_button    	(AnjutaMessageArea *message_area,
+                                         		 const gchar       *button_text,
+                                         		 gint               response_id);
+             		 
+GtkWidget	*anjuta_message_area_add_button_with_stock_image 
+                                                (AnjutaMessageArea *message_area, 
+                                                 const gchar       *text, 
+                                                 const gchar       *stock_id, 
+                                                 gint               response_id);
+
+/* Emit response signal */
+void		 anjuta_message_area_response       (AnjutaMessageArea *message_area,
+                                    			 gint               response_id);
+
+G_END_DECLS
+
+#endif  /* __ANJUTA_MESSAGE_AREA_H__  */
+

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Fri Jun 13 22:41:29 2008
@@ -2386,6 +2386,17 @@
 	* Sets the given document as current document.
 	*/
 	void set_current_document (IAnjutaDocument *document);
+
+	/** 
+	* ianjuta_document_manager_set_message_area:
+	* @obj: Self
+	* @document: the document we change the message area.
+	* @message_area: the widget to use as the message area.
+	* @err: Error propagation and reporting.
+	* 
+	* Sets the message area for the given document.
+	*/
+	void set_message_area (IAnjutaDocument *document, GtkWidget *message_area);
 	
 	/**
 	* ianjuta_document_manager_get_doc_widgets:

Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c	(original)
+++ trunk/plugins/document-manager/anjuta-docman.c	Fri Jun 13 22:41:29 2008
@@ -22,6 +22,7 @@
 #include <libanjuta/anjuta-utils.h>
 #include <libanjuta/anjuta-preferences.h>
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-message-area.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-markable.h>
 #include <libanjuta/interfaces/ianjuta-file-savable.h>
@@ -63,7 +64,7 @@
 	AnjutaPreferences *preferences;
 	GList *pages;		/* list of AnjutaDocmanPage's */
 	AnjutaDocmanPage *cur_page;
-	IAnjutaDocument *current_document; /* normally == IANJUTA_DOCUMENT (cur_page->widget) */
+	IAnjutaDocument *current_document; /* normally == IANJUTA_DOCUMENT (cur_page->doc) */
 	
 	GtkWidget *fileselection;
 	
@@ -77,7 +78,9 @@
 };
 
 struct _AnjutaDocmanPage {
-	GtkWidget *widget;	/* notebook-page widget, a GTK_WIDGET (IAnjutaDocument*) */
+	IAnjutaDocument *doc; /* a IAnjutaDocument */
+	GtkWidget *widget;	/* notebook-page widget */
+	GtkWidget *message_area; /* page message area */
 	GtkWidget *box;		/* notebook-tab-label parent widget */
 	GtkWidget *menu_box; /* notebook-tab-menu parent widget */
 	GtkWidget *close_image;
@@ -92,7 +95,7 @@
 
 static void anjuta_docman_order_tabs (AnjutaDocman *docman);
 static void anjuta_docman_update_page_label (AnjutaDocman *docman,
-											 GtkWidget *doc_widget);
+											 IAnjutaDocument *doc);
 static void anjuta_docman_grab_text_focus (AnjutaDocman *docman);
 static gboolean anjuta_docman_sort_pagelist (AnjutaDocman *docman);
 static void on_notebook_switch_page (GtkNotebook *notebook,
@@ -101,6 +104,8 @@
 static AnjutaDocmanPage *
 anjuta_docman_get_page_for_document (AnjutaDocman *docman,
 									IAnjutaDocument *doc);
+static AnjutaDocmanPage *
+anjuta_docman_get_nth_page (AnjutaDocman *docman, gint page_num);
 
 static void
 on_document_toggled (GtkAction* action,
@@ -173,8 +178,7 @@
 		const gchar *tab_name;
 		gchar *accel;
 
-		page = anjuta_docman_get_page_for_document (docman,
-													IANJUTA_DOCUMENT (gtk_notebook_get_nth_page (GTK_NOTEBOOK (docman), i)));
+		page = anjuta_docman_get_nth_page (docman, i);
 
 		/* NOTE: the action is associated to the position of the tab in
 		 * the notebook not to the tab itself! This is needed to work
@@ -242,12 +246,10 @@
 		GList* node;
 		for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
 		{
-			IAnjutaDocument *doc;
 			page = (AnjutaDocmanPage *) node->data;
 			if (page->close_button == GTK_WIDGET (button))
 			{
-				doc = IANJUTA_DOCUMENT (page->widget);
-				anjuta_docman_set_current_document (docman, doc);
+				anjuta_docman_set_current_document (docman, page->doc);
 				break;
 			}
 		}
@@ -355,7 +357,7 @@
 	GtkWidget *close_button;
 	GtkWidget *close_pixmap;
 	GtkWidget *label, *menu_label;
-	GtkWidget *box, *menu_box;
+	GtkWidget *vbox, *box, *menu_box;
 	GtkWidget *event_hbox;
 	GtkWidget *event_box;
 #if !GTK_CHECK_VERSION (2,12,0)
@@ -475,6 +477,10 @@
 	/* menu box */
 	gtk_box_pack_start (GTK_BOX (menu_box), menu_label, TRUE, TRUE, 0);
 	gtk_widget_show_all (menu_box);
+	
+	/* main box */
+	vbox = gtk_vbox_new (FALSE, 0);
+	gtk_box_pack_end (GTK_BOX (vbox), GTK_WIDGET (doc), TRUE, TRUE, 0);
 
 	g_signal_connect (G_OBJECT (close_button), "clicked",
 					  G_CALLBACK (on_notebook_page_close_button_click),
@@ -492,7 +498,9 @@
 					  G_CALLBACK (on_notebook_tab_btnrelease),
 					  docman);
 
-	page->widget = GTK_WIDGET (doc);	/* this is also the notebook-page child widget */
+	page->widget = GTK_WIDGET (vbox);	/* this is the notebook-page child widget */
+	page->doc = doc;
+	page->message_area = NULL;
 	page->box = box;
 	page->close_image = close_pixmap;
 	page->close_button = close_button;
@@ -867,17 +875,17 @@
 
 static void
 on_notebook_switch_page (GtkNotebook *notebook,
-						 GtkNotebookPage *page,
+						 GtkNotebookPage *notebook_page,
 						 gint page_num, AnjutaDocman *docman)
 {
 	if (!docman->priv->shutingdown)
 	{
-		GtkWidget *page_widget;
+		AnjutaDocmanPage *page;
 		gchar* action_name;
 		GtkAction* action;
 		
-		page_widget = gtk_notebook_get_nth_page (notebook, page_num);
-		anjuta_docman_set_current_document (docman, IANJUTA_DOCUMENT (page_widget));
+		page = anjuta_docman_get_nth_page (docman, page_num);
+		anjuta_docman_set_current_document (docman, page->doc);
 		
 		/* activate the right item in the documents menu */
 		action_name = g_strdup_printf ("Tab_%d", page_num);
@@ -902,7 +910,7 @@
 			&& !anjuta_preferences_get_int (docman->priv->preferences, EDITOR_TABS_ORDERING)
 			&& anjuta_preferences_get_int (docman->priv->preferences, EDITOR_TABS_RECENT_FIRST))
 		{
-			gtk_notebook_reorder_child (notebook, page_widget, 0);
+			gtk_notebook_reorder_child (notebook, page->widget, 0);
 		}
 		anjuta_docman_update_documents_menu_status (docman);
 	}
@@ -912,7 +920,7 @@
 on_document_save_point (IAnjutaDocument *doc, gboolean entering,
 						AnjutaDocman *docman)
 {
-	anjuta_docman_update_page_label (docman, GTK_WIDGET (doc));
+	anjuta_docman_update_page_label (docman, doc);
 }
 
 static void
@@ -939,11 +947,11 @@
 			anjuta_docman_set_current_document (docman, NULL);
 		else
 		{
-			GtkWidget *page_widget;
+			AnjutaDocmanPage *next_page;
 			/* set a replacement active document */
 			page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (docman));
-			page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (docman), page_num);
-			anjuta_docman_set_current_document (docman, IANJUTA_DOCUMENT (page_widget));
+			next_page = anjuta_docman_get_nth_page (docman, page_num);
+			anjuta_docman_set_current_document (docman, next_page->doc);
 		}
 	}
 	anjuta_docman_page_destroy (page);
@@ -1074,15 +1082,11 @@
 	if (!doc)
 		return;
 
-	/* removing child-widget unrefs that as well as all tab-related widgets
-		CHECKME except
-		page->close_button, its refcount to 5
-		page->widget, its refcount to 1, & surviving object seems to be used elsewhere */
-	gtk_container_remove (GTK_CONTAINER (docman), GTK_WIDGET (doc));
-
 	page = anjuta_docman_get_page_for_document (docman, doc);
 	if (page)
 	{
+		gtk_container_remove (GTK_CONTAINER (page->widget), GTK_WIDGET(doc));
+		gtk_container_remove (GTK_CONTAINER (docman), page->widget);
 		if (page == docman->priv->cur_page)
 			docman->priv->cur_page = NULL;
 		docman->priv->pages = g_list_remove (docman->priv->pages, (gpointer)page);
@@ -1133,13 +1137,19 @@
 
 		page = node->data;
 		g_assert (page);
-		if (page->widget == GTK_WIDGET (doc))
+		if (page->doc == doc)
 			return page;
 		node = g_list_next (node);
 	}
 	return NULL;
 }
 
+static AnjutaDocmanPage *
+anjuta_docman_get_nth_page (AnjutaDocman *docman, gint page_num)
+{
+	return g_list_nth_data (docman->priv->pages, page_num);
+}
+
 IAnjutaDocument *
 anjuta_docman_get_current_document (AnjutaDocman *docman)
 {
@@ -1191,7 +1201,7 @@
 					gtk_widget_set_sensitive (page->mime_icon, TRUE);
 			}
 			page_num = gtk_notebook_page_num (GTK_NOTEBOOK (docman),
-											  GTK_WIDGET (doc));
+											  page->widget);
 			g_signal_handlers_block_by_func (G_OBJECT (docman),
 											(gpointer) on_notebook_switch_page,
 											(gpointer) docman);
@@ -1259,6 +1269,38 @@
 		g_signal_emit (G_OBJECT (docman), docman_signals[DOC_CHANGED], 0, doc);
 }
 
+void
+anjuta_docman_set_message_area (AnjutaDocman *docman, IAnjutaDocument* doc, 
+                                GtkWidget *message_area)
+{
+	AnjutaDocmanPage *page;
+
+	if (doc != NULL)
+	{
+		page = anjuta_docman_get_page_for_document (docman, doc);
+		if (page->message_area != message_area)
+		{
+			if (page->message_area != NULL)
+				gtk_widget_destroy (page->message_area);
+			
+			page->message_area = message_area;
+			
+			if (message_area == NULL)
+				return;
+
+			gtk_widget_show (message_area);
+			gtk_box_pack_start (GTK_BOX (page->widget),
+			                    message_area,
+			                    FALSE,
+			                    FALSE,
+			                    0);
+			
+			g_object_add_weak_pointer (G_OBJECT (page->message_area), 
+				   					   (gpointer *)&page->message_area);
+		}
+	}
+}
+
 IAnjutaEditor *
 anjuta_docman_goto_uri_line (AnjutaDocman *docman, const gchar *uri, gint lineno)
 {
@@ -1432,11 +1474,10 @@
 		AnjutaDocmanPage *page;
 
 		page = (AnjutaDocmanPage *) node->data;
-		doc = IANJUTA_DOCUMENT (page->widget);
-		if (strcmp (fname, ianjuta_document_get_filename (doc, NULL)) == 0)
+		if (strcmp (fname, ianjuta_document_get_filename (page->doc, NULL)) == 0)
 		{
 			g_free (fname);
-			return ianjuta_file_get_uri (IANJUTA_FILE (doc), NULL);
+			return ianjuta_file_get_uri (IANJUTA_FILE (page->doc), NULL);
 		}
 	}
 	g_free (fname);
@@ -1457,7 +1498,7 @@
 	{
 		AnjutaDocmanPage* page;
 		page = (AnjutaDocmanPage *)node->data;
-		if (page && IANJUTA_DOCUMENT (page->widget) == doc)
+		if (page && page->doc == doc)
 		{
 			gint curindx;
 			curindx = gtk_notebook_page_num (GTK_NOTEBOOK (docman), page->widget);
@@ -1476,17 +1517,15 @@
 }
 
 static void
-anjuta_docman_update_page_label (AnjutaDocman *docman, GtkWidget *page_widget)
+anjuta_docman_update_page_label (AnjutaDocman *docman, IAnjutaDocument *doc)
 {
 	AnjutaDocmanPage *page;
 	gchar *basename;
 	gchar *uri;
-	IAnjutaDocument *doc;
 	const gchar* doc_filename;
 	gchar* dirty_char;
 	gchar* label;
 	
-	doc = IANJUTA_DOCUMENT (page_widget);
 	if (doc == NULL)
 		return;
 
@@ -1540,11 +1579,11 @@
 		AnjutaDocmanPage *page;
 
 		page = (AnjutaDocmanPage *) node->data;
-		if (IANJUTA_IS_EDITOR (page->widget))
+		if (IANJUTA_IS_EDITOR (page->doc))
 		{
 			IAnjutaEditor* te;
 
-			te = IANJUTA_EDITOR (page->widget);
+			te = IANJUTA_EDITOR (page->doc);
 			ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (te), marker, NULL);
 		}
 	}
@@ -1560,15 +1599,15 @@
 		AnjutaDocmanPage *page;
 
 		page = (AnjutaDocmanPage *) node->data;
-		if (IANJUTA_IS_EDITOR (page->widget))
+		if (IANJUTA_IS_EDITOR (page->doc))
 		{
 			gchar *uri;
 
-			uri = ianjuta_file_get_uri (IANJUTA_FILE (page->widget), NULL);
+			uri = ianjuta_file_get_uri (IANJUTA_FILE (page->doc), NULL);
 			if (uri)
 			{
 				g_free (uri);
-				ianjuta_markable_unmark (IANJUTA_MARKABLE (page->widget), -1, -1, NULL);
+				ianjuta_markable_unmark (IANJUTA_MARKABLE (page->doc), -1, -1, NULL);
 			}
 		}
 	}
@@ -1633,7 +1672,8 @@
 anjuta_docman_order_tabs (AnjutaDocman *docman)
 {
 	gint i, num_pages;
-	GtkWidget *page_widget;
+	GList *node;
+	AnjutaDocmanPage *page;
 	order_struct *tab_labels;
 	GtkNotebook *notebook;
 
@@ -1643,6 +1683,7 @@
 	if (num_pages < 2)
 		return;
 	tab_labels = g_new0 (order_struct, num_pages);
+	node = docman->priv->pages;
 	for (i = 0; i < num_pages; i++)
 	{
 /*new0 NULL'ed things already
@@ -1653,11 +1694,12 @@
 		}
 		else
 */
-		if ((page_widget = gtk_notebook_get_nth_page (notebook, i)) != NULL)
+		if (node != NULL && node->data != NULL)
 		{
-			tab_labels[i].m_widget = page_widget; /* CHECKME needed ? */
-			tab_labels[i].m_label = ianjuta_document_get_filename (
-											IANJUTA_DOCUMENT (page_widget), NULL);
+			page = node->data;
+			tab_labels[i].m_widget = page->widget; /* CHECKME needed ? */
+			tab_labels[i].m_label = ianjuta_document_get_filename (page->doc, NULL);
+			node = g_list_next (node);
 		}
 	}
 	qsort (tab_labels, num_pages, sizeof(order_struct), do_ordertab1);
@@ -1718,12 +1760,12 @@
 			AnjutaDocmanPage *page;
 			page = (AnjutaDocmanPage *) node->data;
 
-			if (page && page->widget && IANJUTA_IS_DOCUMENT (page->widget))
+			if (page && page->widget && IANJUTA_IS_DOCUMENT (page->doc))
 			{
 				IAnjutaDocument *doc;
 				gchar *te_uri;
 
-				doc = IANJUTA_DOCUMENT (page->widget);
+				doc = page->doc;
 				te_uri = ianjuta_file_get_uri (IANJUTA_FILE (doc), NULL);
 				if (te_uri)
 				{
@@ -1761,19 +1803,17 @@
 			AnjutaDocmanPage *page;
 			page = (AnjutaDocmanPage *) node->data;
 
-			if (page && page->widget && IANJUTA_IS_DOCUMENT (page->widget))
+			if (page && page->doc && IANJUTA_IS_DOCUMENT (page->doc))
 			{
-				IAnjutaDocument *doc;
 				gchar *te_uri;
 
-				doc = IANJUTA_DOCUMENT (page->widget);
-				te_uri = ianjuta_file_get_uri (IANJUTA_FILE (doc), NULL);
+				te_uri = ianjuta_file_get_uri (IANJUTA_FILE (page->doc), NULL);
 				if (te_uri)
 				{
 					if (strcmp (te_uri, file_uri) == 0)
 					{
 						g_free (te_uri);
-						return doc;
+						return page->doc;
 					}
 					g_free (te_uri);
 				}
@@ -1794,8 +1834,8 @@
 	{
 		AnjutaDocmanPage *page;
 		page = (AnjutaDocmanPage *) node->data;
-		if (page && page->widget)
-			wids = g_list_prepend (wids, page->widget);
+		if (page && page->doc)
+			wids = g_list_prepend (wids, page->doc);
 	}
 	if (wids)
 		wids = g_list_reverse (wids);

Modified: trunk/plugins/document-manager/anjuta-docman.h
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.h	(original)
+++ trunk/plugins/document-manager/anjuta-docman.h	Fri Jun 13 22:41:29 2008
@@ -75,6 +75,9 @@
 
 void anjuta_docman_set_current_document (AnjutaDocman *docman, IAnjutaDocument *doc);
 
+void anjuta_docman_set_message_area (AnjutaDocman *docman, IAnjutaDocument *doc,
+									GtkWidget *message_area);
+
 IAnjutaEditor *anjuta_docman_goto_uri_line (AnjutaDocman *docman,
 											const gchar *uri,
 											gint lineno);

Modified: trunk/plugins/document-manager/plugin.c
==============================================================================
--- trunk/plugins/document-manager/plugin.c	(original)
+++ trunk/plugins/document-manager/plugin.c	Fri Jun 13 22:41:29 2008
@@ -1917,6 +1917,17 @@
 	anjuta_docman_set_current_document (docman, doc);
 }
 
+static void
+ianjuta_docman_set_message_area (IAnjutaDocumentManager *plugin,
+								 IAnjutaDocument *doc,
+								 GtkWidget *message_area,
+								 GError **e)
+{
+	AnjutaDocman *docman;
+	docman = ANJUTA_DOCMAN ((ANJUTA_PLUGIN_DOCMAN (plugin)->docman));
+	anjuta_docman_set_message_area (docman, doc, message_area);
+}
+
 static GList*
 ianjuta_docman_get_doc_widgets (IAnjutaDocumentManager *plugin, GError **e)
 {
@@ -2019,6 +2030,7 @@
 	iface->goto_uri_line_mark = ianjuta_docman_goto_uri_line_mark;
 	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;
 }
 
 /* Implement IAnjutaFile interface */

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Fri Jun 13 22:41:29 2008
@@ -26,6 +26,8 @@
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/anjuta-preferences.h>
 #include <libanjuta/anjuta-encodings.h>
+#include <libanjuta/anjuta-message-area.h>
+#include <libanjuta/anjuta-shell.h>
 #include <libanjuta/interfaces/ianjuta-file.h>
 #include <libanjuta/interfaces/ianjuta-file-savable.h>
 #include <libanjuta/interfaces/ianjuta-markable.h>
@@ -34,6 +36,7 @@
 #include <libanjuta/interfaces/ianjuta-print.h>
 #include <libanjuta/interfaces/ianjuta-language-support.h>
 #include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-editor.h>
 #include <libanjuta/interfaces/ianjuta-editor-selection.h>
 #include <libanjuta/interfaces/ianjuta-editor-assist.h>
@@ -161,7 +164,7 @@
 
 /* Callback for dialog below */
 static void 
-on_reload_dialog_response (GtkWidget *dlg, gint res, Sourceview *sv)
+on_reload_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
 {
 	if (res == GTK_RESPONSE_YES)
 	{
@@ -173,7 +176,7 @@
 		/* Set dirty */
 		gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), TRUE);
 	}
-	gtk_widget_destroy (dlg);
+	gtk_widget_destroy (message_area);
 }
 
 /* Update Monitor on load/save */
@@ -193,42 +196,44 @@
 static gboolean
 on_sourceview_uri_changed_prompt (Sourceview* sv)
 {
-	GtkWidget *dlg;
-	GtkWidget *parent;
+	GtkWidget *message_area;
+	IAnjutaDocumentManager *docman;
+	IAnjutaDocument *doc;
+	AnjutaShell *shell;
 	gchar *buff;
 	
+	g_print ("OK\n");
+	
 	buff =
 		g_strdup_printf (_
-						 ("The file '%s' on the disk is more recent than\n"
+						 ("The file '%s' on the disk is more recent than "
 						  "the current buffer.\nDo you want to reload it?"),
 						 ianjuta_document_get_filename(IANJUTA_DOCUMENT(sv), NULL));
-	
-	parent = gtk_widget_get_toplevel (GTK_WIDGET (sv));
-	
-	dlg = gtk_message_dialog_new (GTK_WINDOW (parent),
-								  GTK_DIALOG_DESTROY_WITH_PARENT,
-								  GTK_MESSAGE_WARNING,
-								  GTK_BUTTONS_NONE, buff);
-	gtk_dialog_add_button (GTK_DIALOG (dlg),
-						   GTK_STOCK_NO,
-						   GTK_RESPONSE_NO);
-	anjuta_util_dialog_add_button (GTK_DIALOG (dlg),
-								   _("_Reload"),
-								   GTK_STOCK_REFRESH,
-								   GTK_RESPONSE_YES);
+
+	shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
+	docman = anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
+	if (!docman)
+  		return TRUE;
+  	doc = IANJUTA_DOCUMENT (sv);
+
+	message_area = anjuta_message_area_new (buff, GTK_STOCK_DIALOG_WARNING);
+	anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+									GTK_STOCK_REFRESH,
+									GTK_RESPONSE_YES);
+	anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+								    GTK_STOCK_CANCEL,
+									GTK_RESPONSE_NO);
 	g_free (buff);
 	
-	gtk_window_set_transient_for (GTK_WINDOW (dlg),
-								  GTK_WINDOW (parent));
-	
-	g_signal_connect (G_OBJECT(dlg), "response",
+	g_signal_connect (G_OBJECT(message_area), "response",
 					  G_CALLBACK (on_reload_dialog_response),
 					  sv);
-	gtk_widget_show (dlg);
 
-	g_signal_connect_swapped (G_OBJECT(dlg), "delete-event",
+	/*g_signal_connect_swapped (G_OBJECT(message_area), "delete-event",
 					  G_CALLBACK (gtk_widget_destroy),
-					  dlg);
+					  dlg);*/
+					  
+	ianjuta_document_manager_set_message_area (docman, doc, message_area, NULL);
 	
 	return FALSE;
 }



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