Remove temporary navqueues_ and msgwins_ functions and adjust depending code.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/document-pointer@2689 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
1e8d82f46a
commit
1baa9d3159
@ -10,6 +10,10 @@
|
||||
Make NavQueueFuncs and MsgWinFuncs use a GeanyDocument* instead of an
|
||||
integer index.
|
||||
Adjust plugins to work with these changes.
|
||||
* src/navqueue.c, src/navqueue.h, src/treeviews.c, src/msgwindow.c,
|
||||
src/msgwindow.h, src/search.c, src/plugins.c, src/symbols.c:
|
||||
Remove temporary navqueues_ and msgwins_ functions and adjust
|
||||
depending code.
|
||||
|
||||
|
||||
2008-06-12 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
@ -278,7 +278,7 @@ void msgwin_show_hide(gboolean show)
|
||||
* @param format Printf()-style format string.
|
||||
* @param ... Arguments for the @c format string.
|
||||
**/
|
||||
void msgwins_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
|
||||
void msgwin_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
|
||||
{
|
||||
gchar string[512];
|
||||
va_list args;
|
||||
@ -287,12 +287,12 @@ void msgwins_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gc
|
||||
g_vsnprintf(string, 512, format, args);
|
||||
va_end(args);
|
||||
|
||||
msgwins_msg_add(msg_color, line, doc, string);
|
||||
msgwin_msg_add(msg_color, line, doc, string);
|
||||
}
|
||||
|
||||
|
||||
/* adds string to the msg treeview */
|
||||
void msgwins_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string)
|
||||
void msgwin_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
const GdkColor *color = get_color(msg_color);
|
||||
@ -317,28 +317,6 @@ void msgwins_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar
|
||||
}
|
||||
|
||||
|
||||
/* temporary compatibility functions */
|
||||
void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...)
|
||||
{
|
||||
gchar string[512];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
g_vsnprintf(string, 512, format, args);
|
||||
va_end(args);
|
||||
|
||||
msgwins_msg_add(msg_color, line, documents[idx], string);
|
||||
}
|
||||
|
||||
|
||||
void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string)
|
||||
{
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return;
|
||||
msgwins_msg_add(msg_color, line, documents[idx], string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a status message *without* setting the status bar.
|
||||
* (Use ui_set_statusbar() to display text on the statusbar)
|
||||
@ -523,7 +501,6 @@ gboolean msgwin_goto_compiler_file_line()
|
||||
gchar *string;
|
||||
gboolean ret = FALSE;
|
||||
GdkColor *color;
|
||||
gint old_idx = document_get_cur_idx();
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_compiler));
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
||||
@ -541,7 +518,6 @@ gboolean msgwin_goto_compiler_file_line()
|
||||
if (string != NULL)
|
||||
{
|
||||
gint line;
|
||||
gint idx;
|
||||
gchar *filename, *dir;
|
||||
GtkTreePath *path;
|
||||
|
||||
@ -556,18 +532,20 @@ gboolean msgwin_goto_compiler_file_line()
|
||||
if (filename != NULL && line > -1)
|
||||
{
|
||||
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
|
||||
idx = document_find_by_filename(utf8_filename);
|
||||
GeanyDocument *doc = documents_find_by_filename(utf8_filename);
|
||||
GeanyDocument *old_doc = document_get_current();
|
||||
|
||||
g_free(utf8_filename);
|
||||
|
||||
if (idx < 0) /* file not already open */
|
||||
idx = document_open_file(filename, FALSE, NULL, NULL);
|
||||
if (doc == NULL) /* file not already open */
|
||||
doc = documents_open_file(filename, FALSE, NULL, NULL);
|
||||
|
||||
if (DOC_IDX_VALID(idx))
|
||||
if (doc != NULL)
|
||||
{
|
||||
if (! documents[idx]->changed) /* if modified, line may be wrong */
|
||||
editor_set_indicator_on_line(idx, line - 1);
|
||||
if (! doc->changed) /* if modified, line may be wrong */
|
||||
editor_set_indicator_on_line(DOC_IDX(doc), line - 1);
|
||||
|
||||
ret = navqueue_goto_line(old_idx, idx, line);
|
||||
ret = navqueue_goto_line(old_doc, doc, line);
|
||||
}
|
||||
}
|
||||
g_free(filename);
|
||||
@ -823,14 +801,15 @@ gboolean msgwin_goto_messages_file_line()
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
||||
{
|
||||
gint idx, line, old_idx = document_get_cur_idx();
|
||||
gint line;
|
||||
gchar *string;
|
||||
GeanyDocument *doc;
|
||||
GeanyDocument *old_doc = document_get_current();
|
||||
|
||||
gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, 3, &string, -1);
|
||||
if (line >= 0 && idx >= 0)
|
||||
gtk_tree_model_get(model, &iter, 0, &line, 1, &doc, 3, &string, -1);
|
||||
if (line >= 0 && doc != NULL)
|
||||
{
|
||||
if (DOC_IDX_VALID(idx))
|
||||
ret = navqueue_goto_line(old_idx, idx, line);
|
||||
ret = navqueue_goto_line(old_doc, doc, line);
|
||||
}
|
||||
else if (line < 0 && string != NULL)
|
||||
{
|
||||
@ -839,9 +818,9 @@ gboolean msgwin_goto_messages_file_line()
|
||||
if (filename != NULL && line > -1)
|
||||
{
|
||||
/* use document_open_file to find an already open file, or open it in place */
|
||||
idx = document_open_file(filename, FALSE, NULL, NULL);
|
||||
if (DOC_IDX_VALID(idx))
|
||||
ret = navqueue_goto_line(old_idx, idx, line);
|
||||
doc = documents_open_file(filename, FALSE, NULL, NULL);
|
||||
if (doc != NULL)
|
||||
ret = navqueue_goto_line(old_doc, doc, line);
|
||||
}
|
||||
g_free(filename);
|
||||
}
|
||||
|
@ -84,15 +84,10 @@ void msgwin_switch_tab(gint tabnum, gboolean show);
|
||||
|
||||
void msgwin_clear_tab(gint tabnum);
|
||||
|
||||
void msgwins_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
|
||||
void msgwin_msg_add_fmt(gint msg_color, gint line, GeanyDocument *doc, const gchar *format, ...)
|
||||
G_GNUC_PRINTF (4, 5);
|
||||
|
||||
void msgwins_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string);
|
||||
|
||||
/* temporary compatibility functions */
|
||||
void msgwin_msg_add_fmt(gint msg_color, gint line, gint idx, const gchar *format, ...) G_GNUC_PRINTF (4, 5);
|
||||
|
||||
void msgwin_msg_add(gint msg_color, gint line, gint idx, const gchar *string);
|
||||
void msgwin_msg_add(gint msg_color, gint line, GeanyDocument *doc, const gchar *string);
|
||||
|
||||
void msgwin_compiler_add_fmt(gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
|
@ -144,7 +144,7 @@ static void add_new_position(const gchar *utf8_filename, gint pos)
|
||||
*
|
||||
* @return @a TRUE if the cursor has changed the position to @a line or @a FALSE otherwise.
|
||||
**/
|
||||
gboolean navqueues_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line)
|
||||
gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line)
|
||||
{
|
||||
gint pos;
|
||||
|
||||
@ -171,13 +171,6 @@ gboolean navqueues_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gin
|
||||
}
|
||||
|
||||
|
||||
/* temporary compatibility function */
|
||||
gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line)
|
||||
{
|
||||
return navqueues_goto_line(documents[old_idx], documents[new_idx], line);
|
||||
}
|
||||
|
||||
|
||||
static gboolean goto_file_pos(const gchar *file, gint pos)
|
||||
{
|
||||
gint file_idx = document_find_by_filename(file);
|
||||
|
@ -39,10 +39,7 @@ void navqueue_free(void);
|
||||
void navqueue_remove_file(const gchar *filename);
|
||||
|
||||
|
||||
gboolean navqueues_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line);
|
||||
|
||||
/* temporary compatibility function */
|
||||
gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line);
|
||||
gboolean navqueue_goto_line(GeanyDocument *old_doc, GeanyDocument *new_doc, gint line);
|
||||
|
||||
void navqueue_go_back(void);
|
||||
|
||||
|
@ -194,7 +194,7 @@ static SupportFuncs support_funcs = {
|
||||
static MsgWinFuncs msgwin_funcs = {
|
||||
&msgwin_status_add,
|
||||
&msgwin_compiler_add_fmt,
|
||||
&msgwins_msg_add_fmt,
|
||||
&msgwin_msg_add_fmt,
|
||||
&msgwin_clear_tab,
|
||||
&msgwin_switch_tab
|
||||
};
|
||||
@ -234,7 +234,7 @@ static FiletypeFuncs filetype_funcs = {
|
||||
};
|
||||
|
||||
static NavQueueFuncs navqueue_funcs = {
|
||||
&navqueues_goto_line
|
||||
&navqueue_goto_line
|
||||
};
|
||||
|
||||
static GeanyFunctions geany_functions = {
|
||||
|
15
src/search.c
15
src/search.c
@ -1237,7 +1237,7 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op
|
||||
str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"),
|
||||
tool_prefs.grep_cmd, opts, search_text, dir);
|
||||
utf8_str = utils_get_utf8_from_locale(str);
|
||||
msgwin_msg_add(COLOR_BLUE, -1, -1, utf8_str);
|
||||
msgwin_msg_add(COLOR_BLUE, -1, NULL, utf8_str);
|
||||
utils_free_pointers(str, utf8_str, NULL);
|
||||
ret = TRUE;
|
||||
}
|
||||
@ -1296,7 +1296,7 @@ static gboolean search_read_io (GIOChannel *source,
|
||||
|
||||
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
|
||||
{
|
||||
msgwin_msg_add(COLOR_BLACK, -1, -1, g_strstrip(msg));
|
||||
msgwin_msg_add(COLOR_BLACK, -1, NULL, g_strstrip(msg));
|
||||
g_free(msg);
|
||||
}
|
||||
}
|
||||
@ -1309,6 +1309,7 @@ static gboolean search_read_io (GIOChannel *source,
|
||||
|
||||
static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
|
||||
{
|
||||
/* TODO: port this also to Windows API */
|
||||
#ifdef G_OS_UNIX
|
||||
const gchar *msg = _("Search failed.");
|
||||
gint color = COLOR_DARK_RED;
|
||||
@ -1322,7 +1323,7 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
|
||||
gint count = gtk_tree_model_iter_n_children(
|
||||
GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1;
|
||||
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, -1,
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL,
|
||||
ngettext("Search completed with %d matches.",
|
||||
"Search completed with %d matches.", count),
|
||||
count);
|
||||
@ -1336,7 +1337,7 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data)
|
||||
msg = _("No matches found.");
|
||||
color = COLOR_BLUE;
|
||||
default:
|
||||
msgwin_msg_add(color, -1, -1, msg);
|
||||
msgwin_msg_add(color, -1, NULL, msg);
|
||||
ui_set_statusbar(FALSE, "%s", msg);
|
||||
break;
|
||||
}
|
||||
@ -1375,7 +1376,7 @@ static gint find_document_usage(gint idx, const gchar *search_text, gint flags)
|
||||
count++;
|
||||
line = sci_get_line_from_position(documents[idx]->sci, pos);
|
||||
buffer = sci_get_line(documents[idx]->sci, line);
|
||||
msgwin_msg_add_fmt(COLOR_BLACK, line + 1, idx,
|
||||
msgwin_msg_add_fmt(COLOR_BLACK, line + 1, documents[idx],
|
||||
"%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer));
|
||||
g_free(buffer);
|
||||
|
||||
@ -1415,7 +1416,7 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
if (! found) /* no matches were found */
|
||||
{
|
||||
ui_set_statusbar(FALSE, _("No matches found for \"%s\"."), search_text);
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, _("No matches found for \"%s\"."), search_text);
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, _("No matches found for \"%s\"."), search_text);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1424,7 +1425,7 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
ui_set_statusbar(FALSE, ngettext(
|
||||
"Found %d matches for \"%s\".", "Found %d matches for \"%s\".", count),
|
||||
count, search_text);
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, -1, ngettext(
|
||||
msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, ngettext(
|
||||
"Found %d matches for \"%s\".", "Found %d matches for \"%s\".", count),
|
||||
count, search_text);
|
||||
}
|
||||
|
@ -1206,7 +1206,7 @@ gboolean symbols_goto_tag(const gchar *name, gboolean definition)
|
||||
new_idx = document_open_file(tmtag->atts.entry.file->work_object.file_name, FALSE, NULL, NULL);
|
||||
}
|
||||
|
||||
if (navqueue_goto_line(old_idx, new_idx, tmtag->atts.entry.line))
|
||||
if (navqueue_goto_line(documents[old_idx], documents[new_idx], tmtag->atts.entry.line))
|
||||
return TRUE;
|
||||
}
|
||||
/* if we are here, there was no match and we are beeping ;-) */
|
||||
|
@ -649,9 +649,9 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
|
||||
gtk_tree_model_get(model, &iter, SYMBOLS_COLUMN_LINE, &line, -1);
|
||||
if (line > 0)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
GeanyDocument *doc = document_get_current();
|
||||
|
||||
navqueue_goto_line(idx, idx, line);
|
||||
navqueue_goto_line(doc, doc, line);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user