Make ui_set_statusbar() use printf-style arguments & assume the
message should not be overridden. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1032 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
3537731023
commit
01988714b3
@ -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@btinternet.com>
|
||||
|
@ -706,7 +706,7 @@ static void build_exit_cb(GPid child_pid, gint status, gpointer user_data)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
@ -982,9 +982,7 @@ void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean
|
||||
{
|
||||
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 @@ gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search
|
||||
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;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ void msgwin_compiler_add(gint msg_color, gboolean scroll, const gchar *format, .
|
||||
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 @@ void msgwin_status_add(const gchar *format, ...)
|
||||
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();
|
||||
|
10
src/search.c
10
src/search.c
@ -888,7 +888,7 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
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 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
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 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
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 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
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);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ recent_file_activate_cb (GtkMenuItem *menuitem,
|
||||
|
||||
/* 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 @@ void ui_set_statusbar(const gchar *text, gboolean allow_override)
|
||||
}
|
||||
|
||||
|
||||
/* 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 @@ void ui_update_statusbar(gint idx, gint pos)
|
||||
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 @@ void ui_update_statusbar(gint idx, gint pos)
|
||||
(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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user