Kaydet (Commit) 35a1df7f authored tarafından Nick Treleaven's avatar Nick Treleaven

Remember Find in files directory for opening grep results

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@650 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 5ea85c2b
2006-07-29 Nick Treleaven <nick.treleaven@btinternet.com>
* src/msgwindow.c, src/msgwindow.h, src/callbacks.c, src/search.c:
Remember Find in files directory for opening grep results.
2006-07-28 Enrico Tröger <enrico.troeger@uvena.de> 2006-07-28 Enrico Tröger <enrico.troeger@uvena.de>
* src/search.c, src/callbacks.c, src/dialogs.c: * src/search.c, src/callbacks.c, src/dialogs.c:
......
...@@ -2086,14 +2086,15 @@ on_find_in_files_dialog_response (GtkDialog *dialog, ...@@ -2086,14 +2086,15 @@ on_find_in_files_dialog_response (GtkDialog *dialog,
locale_dir = g_locale_from_utf8(utf8_dir, -1, NULL, NULL, NULL); locale_dir = g_locale_from_utf8(utf8_dir, -1, NULL, NULL, NULL);
if (locale_dir == NULL) locale_dir = g_strdup(utf8_dir); if (locale_dir == NULL) locale_dir = g_strdup(utf8_dir);
gtk_combo_box_prepend_text(GTK_COMBO_BOX(user_data), search_text); if (search_find_in_files(search_text, locale_dir, opts))
search_find_in_files(search_text, locale_dir, opts); {
gtk_combo_box_prepend_text(GTK_COMBO_BOX(user_data), search_text);
gtk_widget_hide(app->find_in_files_dialog);
}
g_free(locale_dir); g_free(locale_dir);
gtk_widget_hide(app->find_in_files_dialog);
} }
else else
msgwin_status_add(_("No text to find.")); msgwin_status_add(_("No text to find."));
} }
else else
gtk_widget_hide(app->find_in_files_dialog); gtk_widget_hide(app->find_in_files_dialog);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "callbacks.h" #include "callbacks.h"
#include "msgwindow.h" #include "msgwindow.h"
#include "utils.h" #include "utils.h"
#include "search.h"
#include "document.h" #include "document.h"
#include <string.h> #include <string.h>
...@@ -39,6 +38,9 @@ ...@@ -39,6 +38,9 @@
static GdkColor dark = {0, 58832, 58832, 58832}; static GdkColor dark = {0, 58832, 58832, 58832};
static GdkColor white = {0, 65535, 65535, 65535}; static GdkColor white = {0, 65535, 65535, 65535};
gchar *find_in_files_dir = NULL;
static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line); static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line);
...@@ -323,7 +325,6 @@ gboolean msgwin_goto_messages_file_line() ...@@ -323,7 +325,6 @@ gboolean msgwin_goto_messages_file_line()
static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line) static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line)
{ {
gchar *end = NULL; gchar *end = NULL;
gchar *path;
gchar **fields; gchar **fields;
gchar *pattern; // pattern to split the error message into some fields gchar *pattern; // pattern to split the error message into some fields
guint field_min_len; // used to detect errors after parsing guint field_min_len; // used to detect errors after parsing
...@@ -369,10 +370,8 @@ static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint * ...@@ -369,10 +370,8 @@ static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *
cur_idx = document_get_cur_idx(); cur_idx = document_get_cur_idx();
if (cur_idx >= 0 && doc_list[cur_idx].is_valid) if (cur_idx >= 0 && doc_list[cur_idx].is_valid)
{ {
path = g_path_get_dirname(doc_list[cur_idx].file_name); *filename = g_strconcat(find_in_files_dir, G_DIR_SEPARATOR_S,
*filename = g_strconcat(path, G_DIR_SEPARATOR_S,
fields[field_idx_file] + skip_dot_slash, NULL); fields[field_idx_file] + skip_dot_slash, NULL);
g_free(path);
} }
g_strfreev(fields); g_strfreev(fields);
......
...@@ -58,6 +58,8 @@ typedef struct msgwin ...@@ -58,6 +58,8 @@ typedef struct msgwin
msgwin msgwindow; msgwin msgwindow;
extern gchar *find_in_files_dir;
void msgwin_prepare_msg_tree_view(void); void msgwin_prepare_msg_tree_view(void);
......
...@@ -110,6 +110,8 @@ gboolean search_find_in_files(const gchar *search_text, const gchar *dir, fif_op ...@@ -110,6 +110,8 @@ gboolean search_find_in_files(const gchar *search_text, const gchar *dir, fif_op
} }
else else
{ {
g_free(find_in_files_dir);
find_in_files_dir = g_strdup(dir);
utils_set_up_io_channel(stdout_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL, utils_set_up_io_channel(stdout_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
search_read_io, NULL); search_read_io, NULL);
g_child_watch_add(child_pid, search_close_pid, NULL); g_child_watch_add(child_pid, search_close_pid, NULL);
...@@ -167,7 +169,7 @@ static GSList *search_get_file_list(const gchar *path, gint *length) ...@@ -167,7 +169,7 @@ static GSList *search_get_file_list(const gchar *path, gint *length)
dir = g_dir_open(path, 0, &error); dir = g_dir_open(path, 0, &error);
if (error) if (error)
{ {
geany_debug("Could not open directory (%s)", error->message); msgwin_status_add(_("Could not open directory (%s)"), error->message);
g_error_free(error); g_error_free(error);
*length = 0; *length = 0;
return NULL; return NULL;
...@@ -197,12 +199,10 @@ static gboolean search_read_io (GIOChannel *source, ...@@ -197,12 +199,10 @@ static gboolean search_read_io (GIOChannel *source,
{ {
if (condition & (G_IO_IN | G_IO_PRI)) if (condition & (G_IO_IN | G_IO_PRI))
{ {
//GIOStatus s;
gchar *msg; gchar *msg;
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg) while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
{ {
//if (s != G_IO_STATUS_NORMAL && s != G_IO_STATUS_EOF) break;
msgwin_msg_add(-1, -1, g_strstrip(msg)); msgwin_msg_add(-1, -1, g_strstrip(msg));
g_free(msg); g_free(msg);
} }
......
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