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

set the Open File dialog directory to the same directory as the current file…

set the Open File dialog directory to the same directory as the current file (thanks to Nick Treleaven for this patch)


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@155 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 97099a92
......@@ -70,6 +70,19 @@ void dialogs_show_open_file ()
g_signal_connect((gpointer)app->open_filesel, "selection-changed",
G_CALLBACK(on_file_open_selection_changed), NULL);
}
// set dialog directory to the current file's directory, if present
{
gchar *initdir = utils_get_current_file_dir();
if (initdir != NULL)
{
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(app->open_filesel), initdir);
g_free(initdir);
}
}
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(app->open_filesel));
/* We make sure the dialog is visible. */
gtk_window_present(GTK_WINDOW(app->open_filesel));
......
......@@ -2119,3 +2119,26 @@ void utils_treeviews_showhide(void)
else
gtk_widget_show(app->treeview_notebook);
}
/* Get directory from current file in the notebook.
* Returns dir string that should be freed or NULL, depending on whether current file is valid.
* (thanks to Nick Treleaven for this patch) */
gchar *utils_get_current_file_dir()
{
gint cur_idx = document_get_cur_idx();
if (cur_idx >= 0) // if valid page found
{
// get current filename
const gchar *cur_fname = doc_list[cur_idx].file_name;
if (cur_fname != NULL)
{
// get folder part from current filename
return g_path_get_dirname(cur_fname); // returns "." if no path
}
}
return NULL; // no file open
}
......@@ -199,4 +199,6 @@ gint utils_get_int_from_hexcolor(const gchar *hex);
void utils_treeviews_showhide(void);
gchar *utils_get_current_file_dir();
#endif
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