Kaydet (Commit) b28e30b3 authored tarafından Enrico Tröger's avatar Enrico Tröger

Improved "Find usage", so it displays not "null" for unsaved files in the…

Improved "Find usage", so it displays not "null" for unsaved files in the results, and unsaved file are also clickable.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@524 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst c1068c02
2006-07-02 Enrico Tröger <enrico.troeger@uvena.de>
* src/callbacks.c, src/msgwindow.c, src/utils.c:
Improved "Find usage", so it displays not "null" for unsaved files
in the results, and unsaved file are also clickable.
2006-07-02 Nick Treleaven <nick.treleaven@btinternet.com>
* src/callbacks.c: For Find Usage, ignore unnamed files.
......
......@@ -1305,7 +1305,7 @@ on_find_usage1_activate (GtkMenuItem *menuitem,
gtk_list_store_clear(msgwindow.store_msg);
for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
{
if (doc_list[i].sci && doc_list[i].file_name)
if (doc_list[i].is_valid)
{
ttf.chrg.cpMin = 0;
ttf.chrg.cpMax = sci_get_length(doc_list[i].sci);
......@@ -1320,9 +1320,12 @@ on_find_usage1_activate (GtkMenuItem *menuitem,
buffer = g_malloc0(sci_get_line_length(doc_list[i].sci, line) + 1);
sci_get_line(doc_list[i].sci, line, buffer);
short_file_name = g_path_get_basename(doc_list[i].file_name);
if (doc_list[i].file_name == NULL)
short_file_name = g_strdup(GEANY_STRING_UNTITLED);
else
short_file_name = g_path_get_basename(doc_list[i].file_name);
string = g_strdup_printf("%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer));
msgwin_msg_add(line + 1, doc_list[i].file_name, string);
msgwin_msg_add(line + 1, i, string);
g_free(buffer);
g_free(short_file_name);
......@@ -1408,18 +1411,17 @@ on_tree_view_button_press_event (GtkWidget *widget,
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreeSelection *selection;
gchar *file;
gint idx;
gint line;
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
gtk_tree_model_get(model, &iter, 0, &line, 1, &file, -1);
if (file && strlen (file) > 0)
gtk_tree_model_get(model, &iter, 0, &line, 1, &idx, -1);
if (idx >= 0 && doc_list[idx].is_valid)
{
utils_goto_file_line(file, FALSE, line);
utils_goto_line(idx, line);
}
g_free(file);
}
}
else if (GPOINTER_TO_INT(user_data) == 5)
......
......@@ -64,7 +64,7 @@ void msgwin_prepare_msg_tree_view(void)
GtkTreeViewColumn *column;
GtkTreeSelection *select;
msgwindow.store_msg = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_COLOR, G_TYPE_STRING);
msgwindow.store_msg = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(msgwindow.tree_msg), GTK_TREE_MODEL(msgwindow.store_msg));
renderer = gtk_cell_renderer_text_new();
......@@ -151,7 +151,7 @@ void msgwin_compiler_add(gint msg_color, gboolean scroll, gchar const *format, .
// adds string to the msg treeview
void msgwin_msg_add(gint line, gchar *file, gchar *string)
void msgwin_msg_add(gint line, gint idx, gchar *string)
{
GtkTreeIter iter;
static gint state = 0;
......@@ -159,7 +159,7 @@ void msgwin_msg_add(gint line, gchar *file, gchar *string)
if (! app->msgwindow_visible) return;
gtk_list_store_append(msgwindow.store_msg, &iter);
gtk_list_store_set(msgwindow.store_msg, &iter, 0, line, 1, file, 2, ((state++ % 2) == 0) ? &white : &dark, 3, string, -1);
gtk_list_store_set(msgwindow.store_msg, &iter, 0, line, 1, idx, 2, ((state++ % 2) == 0) ? &white : &dark, 3, string, -1);
}
......
......@@ -65,7 +65,7 @@ void msgwin_prepare_status_tree_view(void);
void msgwin_prepare_compiler_tree_view(void);
void msgwin_msg_add(gint line, gchar *file, gchar *string);
void msgwin_msg_add(gint line, gint idx, gchar *string);
void msgwin_compiler_add(gint msg_color, gboolean scroll, gchar const *format, ...);
......
......@@ -509,31 +509,22 @@ gint utils_get_local_tag(gint idx, const gchar *qual_name)
gboolean utils_goto_file_line(const gchar *file, gboolean is_tm_filename, gint line)
{
gint page_num;
gint file_idx = document_find_by_filename(file, is_tm_filename);
gboolean ret;
if (file_idx < 0) return FALSE;
page_num = gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook), GTK_WIDGET(doc_list[file_idx].sci));
ret = utils_goto_line(file_idx, line);
// finally switch to the page
gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), page_num);
return ret;
return utils_goto_line(file_idx, line);
}
gboolean utils_goto_line(gint idx, gint line)
{
gint page_num;
line--; // the User counts lines from 1, we begin at 0 so bring the User line to our one
if (idx == -1 || line < 0)
{
if (idx == -1 || ! doc_list[idx].is_valid || line < 0)
return FALSE;
}
// mark the tag and ensure that we have arround 5 lines visible around the mark
sci_goto_line(doc_list[idx].sci, line - 5, FALSE);
......@@ -542,6 +533,10 @@ gboolean utils_goto_line(gint idx, gint line)
sci_marker_delete_all(doc_list[idx].sci, 0);
sci_set_marker_at_line(doc_list[idx].sci, line, TRUE, 0);
// finally switch to the page
page_num = gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook), GTK_WIDGET(doc_list[idx].sci));
gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), page_num);
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment