anjuta r4055 - in trunk: . libanjuta/interfaces plugins/document-manager plugins/editor plugins/glade plugins/sourceview plugins/symbol-browser



Author: jhs
Date: Sat Jul  5 15:08:05 2008
New Revision: 4055
URL: http://svn.gnome.org/viewvc/anjuta?rev=4055&view=rev

Log:
2008-07-05  Johannes Schmid  <jhs gnome org>

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/document-manager/action-callbacks.c
	(on_close_file_activate):
	Fixed a crasher due to g_free vs. g_object_unref
	
	* plugins/document-manager/anjuta-docman.c
	(anjuta_docman_update_page_label):
	* plugins/editor/text_editor.c (isavable_is_read_only),
	(isavable_iface_init):
	* plugins/glade/anjuta-design-document.c:
	* plugins/sourceview/anjuta-view.c (anjuta_view_cut_clipboard):
	* plugins/sourceview/sourceview-io.c (sourceview_io_get_read_only):
	* plugins/sourceview/sourceview-io.h:
	* plugins/sourceview/sourceview-private.h:
	* plugins/sourceview/sourceview.c (on_file_changed),
	(on_read_only_dialog_response), (on_open_finish), (on_save_finish),
	(ifile_savable_is_read_only), (isavable_iface_init),
	(idocument_cut):
	#357697 â readonly file can be edited
	
	* plugins/symbol-browser/plugin.c (project_root_added):
	#539551 â AutoComplete doesn\'t work

Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/document-manager/action-callbacks.c
   trunk/plugins/document-manager/anjuta-docman.c
   trunk/plugins/editor/text_editor.c
   trunk/plugins/glade/anjuta-design-document.c
   trunk/plugins/sourceview/anjuta-view.c
   trunk/plugins/sourceview/sourceview-io.c
   trunk/plugins/sourceview/sourceview-io.h
   trunk/plugins/sourceview/sourceview-private.h
   trunk/plugins/sourceview/sourceview.c
   trunk/plugins/symbol-browser/plugin.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Sat Jul  5 15:08:05 2008
@@ -131,6 +131,18 @@
 		 * Return value: TRUE if dirty, FALSE otherwise.
 		 */
 		gboolean is_dirty ();
+		
+		/**
+		 * ianjuta_file_savable_is_read_only:
+		 * @obj: Self
+		 * @err: Error propagation and reporting
+		 * 
+		 * Return is the file is read-only
+		 *
+		 * Return value: TRUE if read-only, FALSE otherwise.
+		 */
+		gboolean is_read_only ();
+
 	}
 }
 

Modified: trunk/plugins/document-manager/action-callbacks.c
==============================================================================
--- trunk/plugins/document-manager/action-callbacks.c	(original)
+++ trunk/plugins/document-manager/action-callbacks.c	Sat Jul  5 15:08:05 2008
@@ -204,7 +204,7 @@
 									 uri, doc, on_save_prompt_save_editor,
 									 docman);
 		g_free (uri);
-		g_free (file);
+		g_object_unref (file);
 		
 		switch (gtk_dialog_run (GTK_DIALOG (save_prompt)))
 		{

Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c	(original)
+++ trunk/plugins/document-manager/anjuta-docman.c	Sat Jul  5 15:08:05 2008
@@ -1372,6 +1372,7 @@
 	GFile* file;
 	const gchar* doc_filename;
 	gchar* dirty_char;
+	gchar* read_only;
 	gchar* label;
 	
 	if (doc == NULL)
@@ -1389,12 +1390,20 @@
 	{
 		dirty_char = "*";
 	}
+	if (ianjuta_file_savable_is_read_only (IANJUTA_FILE_SAVABLE (doc), NULL))
+	{
+		read_only = _("[read-only]");
+	}
+	else
+	{
+		read_only = "";
+	}
 	
 	file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL);
 	if (file)
 	{
 		basename = g_file_get_basename (file);
-		label = g_strconcat(dirty_char, basename, NULL);
+		label = g_strconcat(dirty_char, basename, read_only, NULL);
 		gtk_label_set_text (GTK_LABEL (page->label), label);
 		gtk_label_set_text (GTK_LABEL (page->menu_label), label);
 		g_free (label);
@@ -1403,7 +1412,7 @@
 	}
 	else if ((doc_filename = ianjuta_document_get_filename (doc, NULL)) != NULL)
 	{
-		label = g_strconcat (dirty_char, doc_filename, NULL);
+		label = g_strconcat (dirty_char, doc_filename, read_only, NULL);
 		gtk_label_set_text (GTK_LABEL (page->label), label);
 		gtk_label_set_text (GTK_LABEL (page->menu_label), label);
 		g_free (label);

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Sat Jul  5 15:08:05 2008
@@ -2728,6 +2728,12 @@
 	/* DEBUG_PRINT("set_dirty: Not implemented in EditorPlugin"); */
 }
 
+static gboolean
+isavable_is_read_only (IAnjutaFileSavable* savable, GError** e)
+{
+	/* FIXME */
+	return FALSE;
+}
 
 static void
 isavable_iface_init (IAnjutaFileSavableIface *iface)
@@ -2736,6 +2742,7 @@
 	iface->save_as = isavable_save_as;
 	iface->set_dirty = isavable_set_dirty;
 	iface->is_dirty = isavable_is_dirty;
+	iface->is_read_only = isavable_is_read_only;
 }
 
 static void

Modified: trunk/plugins/glade/anjuta-design-document.c
==============================================================================
--- trunk/plugins/glade/anjuta-design-document.c	(original)
+++ trunk/plugins/glade/anjuta-design-document.c	Sat Jul  5 15:08:05 2008
@@ -245,6 +245,13 @@
 	}
 }
 
+static gboolean
+ifile_savable_is_read_only (IAnjutaFileSavable* savable, GError** e)
+{
+	// FIXME
+	return FALSE;
+}
+
 static void
 ifile_savable_iface_init(IAnjutaFileSavableIface *iface)
 {
@@ -252,6 +259,7 @@
 	iface->save_as = ifile_savable_save_as;
 	iface->set_dirty = ifile_savable_set_dirty;
 	iface->is_dirty = ifile_savable_is_dirty;
+	iface->is_read_only = ifile_savable_is_read_only;
 }
 
 /* Return true if editor can redo */

Modified: trunk/plugins/sourceview/anjuta-view.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.c	(original)
+++ trunk/plugins/sourceview/anjuta-view.c	Sat Jul  5 15:08:05 2008
@@ -397,6 +397,9 @@
 	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
 	g_return_if_fail (buffer != NULL);
 
+	if (!gtk_text_view_get_editable (GTK_TEXT_VIEW(view)))
+		return;
+	
 	clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
 					      GDK_SELECTION_CLIPBOARD);
 

Modified: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.c	(original)
+++ trunk/plugins/sourceview/sourceview-io.c	Sat Jul  5 15:08:05 2008
@@ -490,6 +490,28 @@
 	
 }
 
+gboolean
+sourceview_io_get_read_only (SourceviewIO* sio)
+{
+	GFileInfo* file_info;
+	gboolean retval;
+	
+	if (!sio->file)
+		return FALSE;
+	
+	file_info = g_file_query_info (sio->file,
+								   G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+								   G_FILE_QUERY_INFO_NONE,
+								   NULL,
+								   NULL);
+	if (!file_info)
+		return FALSE;
+	
+	retval = !g_file_info_get_attribute_boolean (file_info,
+												G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+	g_object_unref (file_info);
+	return retval;
+}
 
 SourceviewIO*
 sourceview_io_new (Sourceview* sv)

Modified: trunk/plugins/sourceview/sourceview-io.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.h	(original)
+++ trunk/plugins/sourceview/sourceview-io.h	Sat Jul  5 15:08:05 2008
@@ -71,6 +71,7 @@
 gchar* sourceview_io_get_filename (SourceviewIO* sio);
 void sourceview_io_set_filename (SourceviewIO* sio, const gchar* filename);
 gchar* sourceview_io_get_mime_type (SourceviewIO* sio);
+gboolean sourceview_io_get_read_only (SourceviewIO* sio);
 SourceviewIO* sourceview_io_new (Sourceview* sv);
 
 G_END_DECLS

Modified: trunk/plugins/sourceview/sourceview-private.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-private.h	(original)
+++ trunk/plugins/sourceview/sourceview-private.h	Sat Jul  5 15:08:05 2008
@@ -41,6 +41,7 @@
 	
 	/* IO */
 	SourceviewIO* io;
+	gboolean read_only;
 	
 	/* Preferences */
 	AnjutaPreferences* prefs;

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Sat Jul  5 15:08:05 2008
@@ -319,12 +319,7 @@
 	
 	g_signal_connect (G_OBJECT(message_area), "response",
 					  G_CALLBACK (on_reload_dialog_response),
-					  sv);
-
-	/*g_signal_connect_swapped (G_OBJECT(message_area), "delete-event",
-					  G_CALLBACK (gtk_widget_destroy),
-					  dlg);*/
-					  
+					  sv);					  
 	ianjuta_document_manager_set_message_area (docman, doc, message_area, NULL);
 	
 	return FALSE;
@@ -362,12 +357,60 @@
 	g_object_unref(G_OBJECT(sv));
 }
 
+static void
+on_read_only_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
+{
+	if (res == GTK_RESPONSE_YES)
+	{
+		gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view),
+									TRUE);
+		sv->priv->read_only = FALSE;
+		g_signal_emit_by_name (sv, "save-point", TRUE);
+	}
+	gtk_widget_destroy (message_area);
+}
+
 /* Called when document is loaded completly */
 static void 
 on_open_finish(SourceviewIO* io, Sourceview* sv)
 {
 	const gchar *lang;
-	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
+	
+	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);		
+	
+	if (sourceview_io_get_read_only (io))
+	{
+		AnjutaShell* shell = ANJUTA_PLUGIN (sv->priv->plugin)->shell;
+		IAnjutaDocumentManager* docman = 
+			anjuta_shell_get_interface (shell, IAnjutaDocumentManager, NULL);
+		g_return_if_fail (docman != NULL);
+		IAnjutaDocument* doc = IANJUTA_DOCUMENT (sv);
+		gchar* filename = sourceview_io_get_filename (io);
+		gchar* buff = g_strdup_printf ("The file '%s' is read-only! Edit anyway?",
+									   filename);
+		GtkWidget* message_area;
+		g_free (filename);
+		
+		message_area = anjuta_message_area_new (buff, GTK_STOCK_DIALOG_WARNING);
+		anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+										GTK_STOCK_YES,
+										GTK_RESPONSE_YES);
+		anjuta_message_area_add_button (ANJUTA_MESSAGE_AREA (message_area),
+										GTK_STOCK_NO,
+										GTK_RESPONSE_NO);
+		g_free (buff);
+		
+		g_signal_connect (G_OBJECT(message_area), "response",
+						  G_CALLBACK (on_read_only_dialog_response),
+						  sv);
+		
+		sv->priv->read_only = TRUE;
+		
+		ianjuta_document_manager_set_message_area (docman, doc, message_area, NULL);
+	}
+	else
+		gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view), TRUE);
+
     g_signal_emit_by_name(G_OBJECT(sv), "save_point",
 						  TRUE);
 	
@@ -387,8 +430,6 @@
 
 	lang = ianjuta_editor_language_get_language(IANJUTA_EDITOR_LANGUAGE(sv), NULL);
 	g_signal_emit_by_name (sv, "language-changed", lang);
-
-	gtk_text_view_set_editable (GTK_TEXT_VIEW (sv->priv->view), TRUE);
 	
 	/* Get rid of reference from ifile_open */
 	g_object_unref(G_OBJECT(sv));
@@ -426,6 +467,7 @@
 	const gchar* lang;
 	GFile* file = sourceview_io_get_file(sio);
 	gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(sv->priv->document), FALSE);
+	sv->priv->read_only = FALSE;
 	g_signal_emit_by_name(G_OBJECT(sv), "saved", file);
 	g_signal_emit_by_name(G_OBJECT(sv), "save_point", TRUE);
 	g_object_unref (file);
@@ -638,6 +680,13 @@
 	return gtk_text_buffer_get_modified(GTK_TEXT_BUFFER(sv->priv->document));
 }
 
+static gboolean
+ifile_savable_is_read_only (IAnjutaFileSavable* file, GError** e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW (file);
+	return sv->priv->read_only;
+}
+
 static void
 isavable_iface_init (IAnjutaFileSavableIface *iface)
 {
@@ -645,6 +694,7 @@
 	iface->save_as = ifile_savable_save_as;
 	iface->set_dirty = ifile_savable_set_dirty;
 	iface->is_dirty = ifile_savable_is_dirty;
+	iface->is_read_only = ifile_savable_is_read_only;
 }
 
 static void
@@ -1156,6 +1206,7 @@
 idocument_cut(IAnjutaDocument* edit, GError** ee)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	
 	g_signal_handlers_block_by_func (sv->priv->document, on_insert_text, sv);
 	anjuta_view_cut_clipboard(sv->priv->view);
 	g_signal_handlers_unblock_by_func (sv->priv->document, on_insert_text, sv);

Modified: trunk/plugins/symbol-browser/plugin.c
==============================================================================
--- trunk/plugins/symbol-browser/plugin.c	(original)
+++ trunk/plugins/symbol-browser/plugin.c	Sat Jul  5 15:08:05 2008
@@ -400,18 +400,23 @@
 	/* Load from project */
 	if (anjuta_preferences_get_int (sv_plugin->prefs,
 											"symbol_browser.tags_auto_load"))
-	{
+	{		
+		gchar* pref_symbols = anjuta_preferences_get (sv_plugin->prefs, SYMBOL_BROWSER_TAGS);
 		gchar* dirname = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
 		GList* packages = ianjuta_project_manager_get_packages (pm, NULL);
 		GList* node;
-		GString* str = g_string_new ("");
+		GString* str = g_string_new (pref_symbols);
+		g_free (pref_symbols);
 		for (node = packages; node != NULL; node = g_list_next (node))
 		{
 			gchar* pathname = g_build_filename (dirname, node->data, NULL);
-			if (str->len)
-				g_string_append_c (str, ':');
-			g_string_append (str, pathname);
-			g_string_append (str, ".anjutatags.gz");
+			if (!strstr (str->str, pathname))
+			{
+				if (str->len)
+					g_string_append_c (str, ':');
+				g_string_append (str, pathname);
+				g_string_append (str, ".anjutatags.gz");
+			}
 			g_free (pathname);
 		}
 		g_list_foreach (packages, (GFunc) g_free, NULL);



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