SF.net SVN: geany: [496] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Jun 27 17:07:28 UTC 2006
Revision: 496
Author: ntrel
Date: 2006-06-27 10:07:22 -0700 (Tue, 27 Jun 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=496&view=rev
Log Message:
-----------
Make Status messages override the document statistics using utils_set_statusbar; don't use a fixed buffer for statistics
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/msgwindow.c
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-06-27 15:31:32 UTC (rev 495)
+++ trunk/ChangeLog 2006-06-27 17:07:22 UTC (rev 496)
@@ -13,6 +13,9 @@
* src/geany.h, src/keyfile.c:
Add recent files items in the same order as they were saved.
Remove app->recent_files and use g_strfreev in keyfile.c.
+ * src/utils.c, src/utils.h, src/msgwindow.c:
+ Make Status messages override the document statistics using
+ utils_set_statusbar; don't use a fixed buffer for statistics.
2006-06-26 Enrico Troeger <enrico.troeger at uvena.de>
Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c 2006-06-27 15:31:32 UTC (rev 495)
+++ trunk/src/msgwindow.c 2006-06-27 17:07:22 UTC (rev 496)
@@ -28,6 +28,7 @@
#include "support.h"
#include "callbacks.h"
#include "msgwindow.h"
+#include "utils.h"
static GdkColor dark = {0, 58832, 58832, 58832};
static GdkColor white = {0, 65535, 65535, 65535};
@@ -177,8 +178,7 @@
va_end(args);
// display status message in status bar
- gtk_statusbar_pop(GTK_STATUSBAR(app->statusbar), 1);
- gtk_statusbar_push(GTK_STATUSBAR(app->statusbar), 1, string);
+ utils_set_statusbar(string, FALSE);
gtk_list_store_append(msgwindow.store_status, &iter);
//gtk_list_store_insert(msgwindow.store_status, &iter, 0);
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2006-06-27 15:31:32 UTC (rev 495)
+++ trunk/src/utils.c 2006-06-27 17:07:22 UTC (rev 496)
@@ -89,11 +89,35 @@
}
+/* 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 utils_set_statusbar(const gchar *text, gboolean allow_override)
+{
+ static glong last_time = 0;
+ GTimeVal timeval;
+ const gint GEANY_STATUS_TIMEOUT = 1;
+
+ g_get_current_time(&timeval);
+
+ if (! allow_override)
+ {
+ gtk_statusbar_pop(GTK_STATUSBAR(app->statusbar), 1);
+ gtk_statusbar_push(GTK_STATUSBAR(app->statusbar), 1, text);
+ last_time = timeval.tv_sec;
+ }
+ else
+ if (timeval.tv_sec > last_time + GEANY_STATUS_TIMEOUT)
+ {
+ gtk_statusbar_pop(GTK_STATUSBAR(app->statusbar), 1);
+ gtk_statusbar_push(GTK_STATUSBAR(app->statusbar), 1, text);
+ }
+}
+
+
/* updates the status bar */
void utils_update_statusbar(gint idx, gint pos)
{
- // currently text need in German and C locale about 150 chars
- gchar *text = (gchar*) g_malloc0(250);
+ gchar *text;
const gchar *cur_tag;
guint line, col;
@@ -107,8 +131,8 @@
line = sci_get_line_from_position(doc_list[idx].sci, pos);
col = sci_get_col_from_position(doc_list[idx].sci, pos);
- g_snprintf(text, 250,
-_("%c line: % 4d column: % 3d selection: % 4d %s mode: %s%s cur. function: %s encoding: %s filetype: %s"),
+ // currently text need in German and C locale about 150 chars
+ text = g_strdup_printf(_("%c line: % 4d column: % 3d selection: % 4d %s mode: %s%s cur. function: %s encoding: %s filetype: %s"),
(doc_list[idx].changed) ? 42 : 32,
(line + 1), (col + 1),
sci_get_selected_text_length(doc_list[idx].sci) - 1,
@@ -118,20 +142,16 @@
cur_tag,
(doc_list[idx].encoding) ? doc_list[idx].encoding : _("unknown"),
(doc_list[idx].file_type) ? doc_list[idx].file_type->title : _("unknown"));
- gtk_statusbar_pop(GTK_STATUSBAR(app->statusbar), 1);
- gtk_statusbar_push(GTK_STATUSBAR(app->statusbar), 1, text);
+ utils_set_statusbar(text, TRUE); //can be overridden by status messages
+ g_free(text);
}
else
{
- gtk_statusbar_pop(GTK_STATUSBAR(app->statusbar), 1);
- gtk_statusbar_push(GTK_STATUSBAR(app->statusbar), 1, text);
+ utils_set_statusbar("", TRUE); //can be overridden by status messages
}
-
- g_free(text);
}
-
void utils_update_popup_reundo_items(gint index)
{
gboolean enable_undo;
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2006-06-27 15:31:32 UTC (rev 495)
+++ trunk/src/utils.h 2006-06-27 17:07:22 UTC (rev 496)
@@ -27,6 +27,10 @@
void utils_start_browser(const gchar *uri);
+/* 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 utils_set_statusbar(const gchar *text, gboolean allow_override);
+
void utils_update_statusbar(gint idx, gint pos);
void utils_set_buttons_state(gboolean enable);
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