SF.net SVN: geany: [1032] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sat Nov 25 16:33:38 UTC 2006


Revision: 1032
          http://svn.sourceforge.net/geany/?rev=1032&view=rev
Author:   ntrel
Date:     2006-11-25 08:33:38 -0800 (Sat, 25 Nov 2006)

Log Message:
-----------
Make ui_set_statusbar() use printf-style arguments & assume the
message should not be overridden.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/document.c
    trunk/src/msgwindow.c
    trunk/src/search.c
    trunk/src/ui_utils.c
    trunk/src/ui_utils.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/ChangeLog	2006-11-25 16:33:38 UTC (rev 1032)
@@ -11,6 +11,10 @@
    of the files changed.
    Show the filename when replacing text over a range.
    Add DOC_FILENAME() null-safe macro to get the filename at doc_idx.
+ * src/build.c, src/ui_utils.h, src/msgwindow.c, src/search.c,
+   src/document.c, src/ui_utils.c:
+   Make ui_set_statusbar() use printf-style arguments & assume the
+   message should not be overridden.
 
 
 2006-11-24  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/build.c	2006-11-25 16:33:38 UTC (rev 1032)
@@ -706,7 +706,7 @@
 		{
 			gchar *msg = _("Compilation finished successfully.");
 			msgwin_compiler_add(COLOR_BLUE, TRUE, msg);
-			if (! app->msgwindow_visible) ui_set_statusbar(msg, FALSE);
+			if (! app->msgwindow_visible) ui_set_statusbar("%s", msg);
 		}
 #endif
 	}

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/document.c	2006-11-25 16:33:38 UTC (rev 1032)
@@ -982,9 +982,7 @@
 	{
 		if (! inc)
 		{
-			gchar *msg = g_strdup_printf(_("\"%s\" was not found."), text);
-			ui_set_statusbar(msg, FALSE);
-			g_free(msg);
+			ui_set_statusbar(_("\"%s\" was not found."), text);
 		}
 		utils_beep();
 		sci_goto_pos(doc_list[idx].sci, start_pos, FALSE);	// clear selection
@@ -1036,10 +1034,7 @@
 		if ((selection_end == 0 && ! search_backwards) ||
 			(selection_end == sci_len && search_backwards))
 		{
-			gchar *msg = g_strdup_printf(_("\"%s\" was not found."), text);
-
-			ui_set_statusbar(msg, FALSE);
-			g_free(msg);
+			ui_set_statusbar(_("\"%s\" was not found."), text);
 			utils_beep();
 			return -1;
 		}

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/msgwindow.c	2006-11-25 16:33:38 UTC (rev 1032)
@@ -169,7 +169,7 @@
 	va_list args;
 
 	va_start(args, format);
-	g_vsnprintf(string, 511, format, args);
+	g_vsnprintf(string, 512, format, args);
 	va_end(args);
 
 	switch (msg_color)
@@ -229,11 +229,11 @@
 	va_list args;
 
 	va_start(args, format);
-	g_vsnprintf(string, 511, format, args);
+	g_vsnprintf(string, 512, format, args);
 	va_end(args);
 
 	// display status message in status bar
-	ui_set_statusbar(string, FALSE);
+	ui_set_statusbar("%s", string);
 
 	// add a timestamp to status messages
 	time_str = utils_get_current_time_string();

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/search.c	2006-11-25 16:33:38 UTC (rev 1032)
@@ -888,7 +888,7 @@
 		case GEANY_RESPONSE_REPLACE_IN_SESSION:
 		{
 			guint n, count = 0;
-			gchar *msg;
+
 			// replace in all documents following notebook tab order
 			for (n = 0; (gint) n < gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)); n++)
 			{
@@ -899,9 +899,7 @@
 				if (document_replace_all(idx, find, replace, search_flags_re,
 					search_replace_escape_re)) count++;
 			}
-			msg = g_strdup_printf(_("Replaced text in %u files."), count);
-			ui_set_statusbar(msg, FALSE);
-			g_free(msg);
+			ui_set_statusbar(_("Replaced text in %u files."), count);
 
 			ui_save_buttons_toggle(doc_list[idx].changed);	// update save all
 			if (close_window) gtk_widget_hide(widgets.replace_dialog);
@@ -1239,7 +1237,7 @@
 	else
 	{
 		guint i;
-		for(i = 0; i < doc_array->len; i++)
+		for (i = 0; i < doc_array->len; i++)
 		{
 			if (doc_list[i].is_valid)
 				if (find_document_usage(i, search_text, flags) > 0) found = TRUE;
@@ -1249,7 +1247,7 @@
 	if (! found) // no matches were found
 	{
 		gchar *text = g_strdup_printf(_("No matches found for '%s'."), search_text);
-		ui_set_statusbar(text, FALSE);
+		ui_set_statusbar("%s", text);
 		msgwin_msg_add(-1, -1, text);
 		g_free(text);
 	}

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/ui_utils.c	2006-11-25 16:33:38 UTC (rev 1032)
@@ -50,7 +50,7 @@
 
 /* allow_override is TRUE if text can be ignored when another message has been set
  * that didn't use allow_override and has not timed out. */
-void ui_set_statusbar(const gchar *text, gboolean allow_override)
+static void set_statusbar(const gchar *text, gboolean allow_override)
 {
 	static glong last_time = 0;
 	GTimeVal timeval;
@@ -73,7 +73,21 @@
 }
 
 
-/* updates the status bar */
+// Display text on the statusbar (without logging it to the Status window).
+void ui_set_statusbar(const gchar *format, ...)
+{
+	gchar string[512];
+	va_list args;
+
+	va_start(args, format);
+	g_vsnprintf(string, 512, format, args);
+	va_end(args);
+
+	set_statusbar(string, FALSE);
+}
+
+
+/* updates the status bar document statistics */
 void ui_update_statusbar(gint idx, gint pos)
 {
 	gchar *text;
@@ -89,9 +103,9 @@
 		if (pos == -1) pos = sci_get_current_position(doc_list[idx].sci);
 		line = sci_get_line_from_position(doc_list[idx].sci, pos);
 
-	   // Add temporary fix for sci infinite loop in Document::GetColumn(int)
-	   // when current pos is beyond document end (can occur when removing
-	   // blocks of selected lines especially esp. brace sections near end of file).
+		// Add temporary fix for sci infinite loop in Document::GetColumn(int)
+		// when current pos is beyond document end (can occur when removing
+		// blocks of selected lines especially esp. brace sections near end of file).
 		if (pos <= sci_get_length(doc_list[idx].sci))
 			col = sci_get_col_from_position(doc_list[idx].sci, pos);
 		else
@@ -108,12 +122,12 @@
 			(doc_list[idx].encoding) ? doc_list[idx].encoding : _("unknown"),
 			(utils_is_unicode_charset(doc_list[idx].encoding)) ? ((doc_list[idx].has_bom) ? _("(with BOM)") : _("(without BOM)")) : "",
 			(doc_list[idx].file_type) ? doc_list[idx].file_type->title : _("unknown"));
-		ui_set_statusbar(text, TRUE); //can be overridden by status messages
+		set_statusbar(text, TRUE);	// can be overridden by status messages
 		g_free(text);
 	}
 	else
 	{
-		ui_set_statusbar("", TRUE); //can be overridden by status messages
+		set_statusbar("", TRUE);	// can be overridden by status messages
 	}
 }
 

Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h	2006-11-25 12:32:22 UTC (rev 1031)
+++ trunk/src/ui_utils.h	2006-11-25 16:33:38 UTC (rev 1032)
@@ -24,9 +24,8 @@
 #ifndef GEANY_UI_UTILS_H
 #define GEANY_UI_UTILS_H 1
 
-/* allow_override is TRUE if text can be ignored when another message has been set
- * that didn't use allow_override and has not timed out. */
-void ui_set_statusbar(const gchar *text, gboolean allow_override);
+// Display text on the statusbar without logging it to the Status window.
+void ui_set_statusbar(const gchar *format, ...) G_GNUC_PRINTF (1, 2);
 
 void ui_update_statusbar(gint idx, gint pos);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list