Revision: 524 Author: eht16 Date: 2006-07-02 04:32:06 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=524&view=rev
Log Message: ----------- Improved "Find usage", so it displays not "null" for unsaved files in the results, and unsaved file are also clickable.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/msgwindow.c trunk/src/msgwindow.h trunk/src/utils.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-07-02 11:21:31 UTC (rev 523) +++ trunk/ChangeLog 2006-07-02 11:32:06 UTC (rev 524) @@ -1,3 +1,10 @@ +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.
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-07-02 11:21:31 UTC (rev 523) +++ trunk/src/callbacks.c 2006-07-02 11:32:06 UTC (rev 524) @@ -1305,7 +1305,7 @@ 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 @@ 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 @@ 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)
Modified: trunk/src/msgwindow.c =================================================================== --- trunk/src/msgwindow.c 2006-07-02 11:21:31 UTC (rev 523) +++ trunk/src/msgwindow.c 2006-07-02 11:32:06 UTC (rev 524) @@ -64,7 +64,7 @@ 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 @@
// 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 @@ 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); }
Modified: trunk/src/msgwindow.h =================================================================== --- trunk/src/msgwindow.h 2006-07-02 11:21:31 UTC (rev 523) +++ trunk/src/msgwindow.h 2006-07-02 11:32:06 UTC (rev 524) @@ -65,7 +65,7 @@
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, ...);
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-07-02 11:21:31 UTC (rev 523) +++ trunk/src/utils.c 2006-07-02 11:32:06 UTC (rev 524) @@ -509,31 +509,22 @@
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 @@ 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; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.