From 1baa9d315908099c5d9ee306c2f5e65d9bc566ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 12 Jun 2008 20:45:18 +0000 Subject: [PATCH] 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 --- ChangeLog | 4 ++++ src/msgwindow.c | 63 +++++++++++++++++-------------------------------- src/msgwindow.h | 9 ++----- src/navqueue.c | 9 +------ src/navqueue.h | 5 +--- src/plugins.c | 4 ++-- src/search.c | 15 ++++++------ src/symbols.c | 2 +- src/treeviews.c | 4 ++-- 9 files changed, 42 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index a355aaa0..ba9c39a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/msgwindow.c b/src/msgwindow.c index f23ff40e..0b417ff5 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -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); } diff --git a/src/msgwindow.h b/src/msgwindow.h index 371b1f32..d4899d97 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -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); diff --git a/src/navqueue.c b/src/navqueue.c index 6b7ff202..0f88f101 100644 --- a/src/navqueue.c +++ b/src/navqueue.c @@ -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); diff --git a/src/navqueue.h b/src/navqueue.h index de86e2ce..143e2e4f 100644 --- a/src/navqueue.h +++ b/src/navqueue.h @@ -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); diff --git a/src/plugins.c b/src/plugins.c index 513d13a8..ff023694 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -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 = { diff --git a/src/search.c b/src/search.c index 469b941b..12054a6f 100644 --- a/src/search.c +++ b/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); } diff --git a/src/symbols.c b/src/symbols.c index 636b5762..c9653a45 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -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 ;-) */ diff --git a/src/treeviews.c b/src/treeviews.c index 85dc6f57..51624ac7 100644 --- a/src/treeviews.c +++ b/src/treeviews.c @@ -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;