anjuta r3726 - in trunk: . plugins/document-manager plugins/file-manager plugins/search plugins/sourceview



Author: jhs
Date: Thu Feb 28 10:17:52 2008
New Revision: 3726
URL: http://svn.gnome.org/viewvc/anjuta?rev=3726&view=rev

Log:
2008-02-28  Johannes Schmid <jhs gnome org>

	* plugins/document-manager/anjuta-docman.c:
	(anjuta_docman_page_destroy):
	Do not unref widget because the GtkNotebook will unref them
	
	* plugins/file-manager/file-view.c: (file_view_refresh):
	* plugins/search/search_preferences.c: (search_preferences_init):
	Fixed a memory leaks
	
	* plugins/sourceview/sourceview.c: (sourceview_add_monitor),
	(ieditor_get_offset), (ieditor_iface_init),
	(idocument_get_filename), (ilanguage_get_supported_languages),
	(autodetect_language):
	
	Fixed memory leaks and implemented ianjuta_editor_get_offset() which
	was missing.

Modified:
   trunk/ChangeLog
   trunk/plugins/document-manager/anjuta-docman.c
   trunk/plugins/file-manager/file-view.c
   trunk/plugins/search/search_preferences.c
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/plugins/document-manager/anjuta-docman.c
==============================================================================
--- trunk/plugins/document-manager/anjuta-docman.c	(original)
+++ trunk/plugins/document-manager/anjuta-docman.c	Thu Feb 28 10:17:52 2008
@@ -370,15 +370,10 @@
 static void
 anjuta_docman_page_destroy (AnjutaDocmanPage *page)
 {
-	if (page)
-	{
-		if (page->widget && GTK_IS_WIDGET (page->widget))
-		/* CHECKME just unref in case other plugins hold ref on the page or its contents ? */
-			gtk_widget_destroy (page->widget);
-		if (page->box && GTK_IS_WIDGET (page->box))
-			gtk_widget_destroy (page->box);	/* the tab-label parent-widget */
-		g_free (page);
-	}
+	/* Notebook holds a reference on the widget of page and destroys
+	 * them properly
+	 */
+	g_free (page);
 }
 
 static void

Modified: trunk/plugins/file-manager/file-view.c
==============================================================================
--- trunk/plugins/file-manager/file-view.c	(original)
+++ trunk/plugins/file-manager/file-view.c	Thu Feb 28 10:17:52 2008
@@ -147,6 +147,7 @@
 	
 	tree_path = gtk_tree_path_new_first ();
 	gtk_tree_view_expand_row (GTK_TREE_VIEW (view), tree_path, FALSE);
+	gtk_tree_path_free (tree_path);
 	if (remember_open)
 	{
 		priv->refresh_idle_id = g_idle_add (file_view_expand_row_idle, view);

Modified: trunk/plugins/search/search_preferences.c
==============================================================================
--- trunk/plugins/search/search_preferences.c	(original)
+++ trunk/plugins/search/search_preferences.c	Thu Feb 28 10:17:52 2008
@@ -583,4 +583,5 @@
 	}
 	
 	search_preferences_activate_default(default_pref);
+	g_free(default_pref);
 }

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Thu Feb 28 10:17:52 2008
@@ -264,11 +264,14 @@
 
 	if (monitor_enabled)
 	{
+		gchar* uri;
 		g_return_val_if_fail(sv->priv->monitor == NULL, FALSE);
-		DEBUG_PRINT ("Monitor added for %s", anjuta_document_get_uri(sv->priv->document)); 	
-		gnome_vfs_monitor_add(&sv->priv->monitor, anjuta_document_get_uri(sv->priv->document),
+		DEBUG_PRINT ("Monitor added for %s", anjuta_document_get_uri(sv->priv->document));
+		uri = anjuta_document_get_uri(sv->priv->document);
+		gnome_vfs_monitor_add(&sv->priv->monitor, uri,
 							  GNOME_VFS_MONITOR_FILE,
-						  on_sourceview_uri_changed, sv);
+							  on_sourceview_uri_changed, sv);
+		g_free (uri);
 	}
 	return FALSE; /* for g_idle_add */
 }
@@ -848,6 +851,19 @@
 	return IANJUTA_ITERABLE (cell);
 }
 
+static gint
+ieditor_get_offset (IAnjutaEditor* editor, GError **e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
+	GtkTextIter iter;
+	
+	gtk_text_buffer_get_iter_at_mark(buffer, &iter, 
+									 gtk_text_buffer_get_insert(buffer));
+	
+	return gtk_text_iter_get_offset (&iter);
+}
+
 /* Return line of cursor */
 static gint ieditor_get_lineno(IAnjutaEditor *editor, GError **e)
 {
@@ -1082,6 +1098,7 @@
 	iface->get_text = ieditor_get_text;
 	iface->get_text_all = ieditor_get_text_all;
 	iface->get_position = ieditor_get_position;
+	iface->get_offset = ieditor_get_offset;
 	iface->get_lineno = ieditor_get_lineno;
 	iface->get_length = ieditor_get_length;
 	iface->get_current_word = ieditor_get_current_word;
@@ -1160,10 +1177,9 @@
 static const gchar* idocument_get_filename(IAnjutaDocument *editor, GError **e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	if (sv->priv->filename != NULL)
-		return sv->priv->filename;
-	else
-		return anjuta_document_get_short_name_for_display(sv->priv->document);
+	if (sv->priv->filename == NULL)
+		sv->priv->filename = anjuta_document_get_short_name_for_display(sv->priv->document);
+	return sv->priv->filename;
 }
 
 static void 
@@ -1825,17 +1841,20 @@
 ilanguage_get_supported_languages (IAnjutaEditorLanguage *ilanguage,
 								   GError **err)
 {
-	GStrv langs;
-	GStrv lang;
-	GList* list = NULL;
-	g_object_get (gtk_source_language_manager_get_default(), "language-ids", &langs, NULL);
-	
-	for (lang = langs; *lang != NULL; lang++)
-	{
-		list = g_list_append (list, *lang);
-	}
-	
-	return list;
+	/* Cache the list */
+	static GList* languages = NULL;
+	if (!languages)
+	{
+		GStrv langs;
+		GStrv lang;
+		g_object_get (gtk_source_language_manager_get_default(), "language-ids", &langs, NULL);
+		
+		for (lang = langs; *lang != NULL; lang++)
+		{
+			languages = g_list_append (languages, *lang);
+		}
+	}		
+	return languages;
 }
 
 static const gchar*
@@ -1881,9 +1900,11 @@
 				g_signal_emit_by_name (G_OBJECT(sv), "language-changed", 
 									   detected_language);
 				gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (sv->priv->document), language);
+				g_strfreev (mime_types);
 				goto out;
 			}
 		}
+		g_strfreev (mime_types);
 	}
 	out:
 		g_strfreev(languages);



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