Plugins might want to open file relatively to certain directory
so make it possible by this patch.
Signed-off-by: Jiří Techet <[email protected]>
---
plugins/geanyfunctions.h | 2 ++
src/msgwindow.c | 23 +++++++++++++++++++----
src/msgwindow.h | 4 +++-
src/plugindata.h | 1 +
src/plugins.c | 3 ++-
src/search.c | 3 +--
6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/plugins/geanyfunctions.h b/plugins/geanyfunctions.h
index 892a0e6..1282400 100644
--- a/plugins/geanyfunctions.h
+++ b/plugins/geanyfunctions.h
@@ -296,6 +296,8 @@
geany_functions->p_msgwin->msgwin_clear_tab
#define msgwin_switch_tab \
geany_functions->p_msgwin->msgwin_switch_tab
+#define msgwin_set_messages_dir \
+ geany_functions->p_msgwin->msgwin_set_messages_dir
#define encodings_convert_to_utf8 \
geany_functions->p_encodings->encodings_convert_to_utf8
#define encodings_convert_to_utf8_from_charset \
diff --git a/src/msgwindow.c b/src/msgwindow.c
index 6cbc853..20a83c0 100644
--- a/src/msgwindow.c
+++ b/src/msgwindow.c
@@ -84,6 +84,21 @@ void msgwin_show_hide_tabs(void)
}
+/**
+ * When a message with a filename is clicked in the message window, the file is
+ * searched relatively to the path provided by this function and opened when found.
+ * Whan the directory is not provided, the path has to be absolute in order to
+ * open the file.
+ *
+ * @param messages_dir The directory.
+ **/
+void msgwin_set_messages_dir(const gchar *messages_dir)
+{
+ g_free(msgwindow.messages_dir);
+ msgwindow.messages_dir = g_strdup(messages_dir);
+}
+
+
void msgwin_init(void)
{
msgwindow.notebook = ui_lookup_widget(main_widgets.window, "notebook_info");
@@ -91,7 +106,7 @@ void msgwin_init(void)
msgwindow.tree_msg = ui_lookup_widget(main_widgets.window, "treeview4");
msgwindow.tree_compiler = ui_lookup_widget(main_widgets.window, "treeview5");
msgwindow.scribble = ui_lookup_widget(main_widgets.window, "textview_scribble");
- msgwindow.find_in_files_dir = NULL;
+ msgwindow.messages_dir = NULL;
prepare_status_tree_view();
prepare_msg_tree_view();
@@ -107,7 +122,7 @@ void msgwin_init(void)
void msgwin_finalize(void)
{
- g_free(msgwindow.find_in_files_dir);
+ g_free(msgwindow.messages_dir);
}
@@ -1056,8 +1071,8 @@ static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *
parse_file_line(&data, filename, line);
/* FIF dir should be set, but a plugin might not have set it */
- if (msgwindow.find_in_files_dir != NULL)
- make_absolute(filename, msgwindow.find_in_files_dir);
+ if (msgwindow.messages_dir != NULL)
+ make_absolute(filename, msgwindow.messages_dir);
}
diff --git a/src/msgwindow.h b/src/msgwindow.h
index 4533733..384373b 100644
--- a/src/msgwindow.h
+++ b/src/msgwindow.h
@@ -69,7 +69,7 @@ typedef struct
GtkWidget *popup_msg_menu;
GtkWidget *popup_compiler_menu;
GtkWidget *notebook;
- gchar *find_in_files_dir;
+ gchar *messages_dir;
} MessageWindow;
extern MessageWindow msgwindow;
@@ -98,6 +98,8 @@ void msgwin_status_add(const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void msgwin_show_hide_tabs(void);
+void msgwin_set_messages_dir(const gchar *messages_dir);
+
void msgwin_menu_add_common_items(GtkMenu *menu);
diff --git a/src/plugindata.h b/src/plugindata.h
index f650ed7..e2f5b65 100644
--- a/src/plugindata.h
+++ b/src/plugindata.h
@@ -502,6 +502,7 @@ typedef struct MsgWinFuncs
const gchar *format, ...) G_GNUC_PRINTF (4, 5);
void (*msgwin_clear_tab) (gint tabnum);
void (*msgwin_switch_tab) (gint tabnum, gboolean show);
+ void (*msgwin_set_messages_dir) (const gchar *base_dir);
}
MsgWinFuncs;
diff --git a/src/plugins.c b/src/plugins.c
index 9afe687..1adff79 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -263,7 +263,8 @@ static MsgWinFuncs msgwin_funcs = {
&msgwin_compiler_add,
&msgwin_msg_add,
&msgwin_clear_tab,
- &msgwin_switch_tab
+ &msgwin_switch_tab,
+ &msgwin_set_messages_dir
};
static EncodingFuncs encoding_funcs = {
diff --git a/src/search.c b/src/search.c
index 3587b0c..3f7ff9a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1477,8 +1477,7 @@ search_find_in_files(const gchar *utf8_search_text, const gchar *dir, const gcha
ui_progress_bar_start(_("Searching..."));
- g_free(msgwindow.find_in_files_dir);
- msgwindow.find_in_files_dir = g_strdup(dir);
+ msgwin_set_messages_dir(dir);
/* we can pass 'enc' without strdup'ing it here because it's a global const string and
* always exits longer than the lifetime of this function */
utils_set_up_io_channel(stdout_fd, G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel