anjuta r4245 - in trunk: . plugins/macro



Author: sgranjoux
Date: Thu Sep 11 19:36:27 2008
New Revision: 4245
URL: http://svn.gnome.org/viewvc/anjuta?rev=4245&view=rev

Log:
	* plugins/macro/macro-dialog.c:
	Fix a bug (dialog will never be displayed again) when closing
	macro dialog with close button

	* plugins/macro/plugin.c:
	Use correct variable to track current editor

	* plugins/macro/macro-util.c,
	plugins/macro/macro-db.c:
	Fix some memory leaks 


Modified:
   trunk/ChangeLog
   trunk/plugins/macro/macro-db.c
   trunk/plugins/macro/macro-dialog.c
   trunk/plugins/macro/macro-util.c
   trunk/plugins/macro/plugin.c

Modified: trunk/plugins/macro/macro-db.c
==============================================================================
--- trunk/plugins/macro/macro-db.c	(original)
+++ trunk/plugins/macro/macro-db.c	Thu Sep 11 19:36:27 2008
@@ -432,15 +432,16 @@
 		
 	gchar *text;
 	gboolean is_category;
+	gchar *buffer = NULL;
+	
 	gtk_tree_model_get (macro_db_get_model(db), iter,
 						MACRO_TEXT, &text,
 						MACRO_IS_CATEGORY, &is_category, -1);
-	if (is_category)
-		return NULL;
-	else
+	if (!is_category)
 	{
-		gchar* buffer = expand_macro(plugin, text, offset);
-		g_free (text);
-		return buffer;
+		buffer = expand_macro(plugin, text, offset);
 	}
+	g_free (text);
+	
+	return buffer;
 }

Modified: trunk/plugins/macro/macro-dialog.c
==============================================================================
--- trunk/plugins/macro/macro-dialog.c	(original)
+++ trunk/plugins/macro/macro-dialog.c	Thu Sep 11 19:36:27 2008
@@ -323,6 +323,8 @@
 	
 	g_signal_connect (G_OBJECT (dialog), "response",
 			  G_CALLBACK (on_dialog_response), plugin);
+	g_signal_connect (G_OBJECT(dialog), "delete-event",
+			G_CALLBACK(gtk_widget_hide_on_delete), NULL);	
 	g_signal_connect(G_OBJECT(dialog), "key-press-event",
 			G_CALLBACK(on_macro_dialog_key_press_event), plugin);
 	

Modified: trunk/plugins/macro/macro-util.c
==============================================================================
--- trunk/plugins/macro/macro-util.c	(original)
+++ trunk/plugins/macro/macro-util.c	Thu Sep 11 19:36:27 2008
@@ -280,10 +280,9 @@
 {
 	gchar *ptr = txt;
 	gchar *c = txt;
-	gchar *buffer = "";
+	GString *buffer = g_string_new_len (NULL, strlen(txt));
 	gchar *begin;
 	gchar *keyword;
-	gchar *buf = NULL;
 	gchar *expand = NULL;
 	gboolean found_curs = FALSE;
 	
@@ -302,16 +301,15 @@
 				
 					if (expand_keyword(plugin, keyword, &expand))
 					{
-						buf = g_strndup(ptr, begin - ptr);
-						buffer = g_strconcat(buffer, buf, expand, NULL);
+						g_string_append_len (buffer, ptr, begin - ptr);
+						g_string_append (buffer, expand);
 						g_free(expand);
 					}
 					else
 					{
-						buf = g_strndup(ptr, c - ptr + 1);
-						buffer = g_strconcat(buffer, buf, NULL);
+						g_string_append_len (buffer, ptr, c - ptr + 1);
 					}
-					g_free(buf);
+					g_free (keyword);
 			        ptr = c + 1;
 			       break;
 				}	
@@ -322,17 +320,13 @@
 		else if ( !found_curs && *c=='|' )		
 		{
 			found_curs = TRUE;
-			buf = g_strndup(ptr, c - ptr);
-
-			buffer = g_strconcat(buffer, buf, NULL);
-			*offset = strlen(buffer);
+			g_string_append_len (buffer, ptr, c - ptr);
+			*offset = buffer->len;
 			ptr = c + 1;	
 		}    
 		c++;
 	}
-    buf = g_strndup(ptr, c - ptr);
-    buffer = g_strconcat(buffer, buf, NULL);
+	g_string_append_len (buffer, ptr, c - ptr);
 	
-    g_free(buf);
-    return buffer;
+    return g_string_free (buffer, FALSE);
 }

Modified: trunk/plugins/macro/plugin.c
==============================================================================
--- trunk/plugins/macro/plugin.c	(original)
+++ trunk/plugins/macro/plugin.c	Thu Sep 11 19:36:27 2008
@@ -21,6 +21,7 @@
 
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/interfaces/ianjuta-macro.h>
+#include <libanjuta/interfaces/ianjuta-document-manager.h>
 
 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-macro.ui"
 #define ICON_FILE "anjuta-macro.png"
@@ -120,7 +121,7 @@
 
 	macro_plugin->editor_watch_id =
 		anjuta_plugin_add_watch (plugin,
-					 "document_manager_current_editor",
+					 IANJUTA_DOCUMENT_MANAGER_CURRENT_DOCUMENT,
 					 value_added_current_editor,
 					 value_removed_current_editor, NULL);
 					 



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