[gedit/zbrown/deteplification-src: 612/633] Use document folder
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/zbrown/deteplification-src: 612/633] Use document folder
- Date: Sat, 10 Apr 2021 12:48:12 +0000 (UTC)
commit fdb9a706d3d0504888c389120ceee0bd2e461fa5
Author: Jordi Mas <jmas softcatala org>
Date: Fri Mar 26 21:19:26 2021 +0100
Use document folder
gedit/gedit-commands-file.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index d1d440a3e..001899b0c 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -394,6 +394,38 @@ file_chooser_open_done_cb (GeditFileChooserOpen *file_chooser,
g_slist_free_full (files, g_object_unref);
}
+const gchar*
+_get_currrent_doc_location (GeditWindow *window)
+{
+ GFile *default_path = NULL;
+ const gchar *default_uri = NULL;
+
+ if (window != NULL)
+ {
+ GeditDocument *doc;
+
+ doc = gedit_window_get_active_document (window);
+
+ if (doc != NULL)
+ {
+ GtkSourceFile *file = gedit_document_get_file (doc);
+ GFile *location = gtk_source_file_get_location (file);
+
+ if (location != NULL)
+ {
+ default_path = g_file_get_parent (location);
+ }
+ }
+
+ if (default_path != NULL)
+ {
+ default_uri = g_file_get_uri(default_path);
+ }
+ }
+
+ return default_uri;
+}
+
void
_gedit_cmd_file_open (GSimpleAction *action,
GVariant *parameter,
@@ -409,6 +441,8 @@ _gedit_cmd_file_open (GSimpleAction *action,
window = GEDIT_WINDOW (user_data);
}
+ const gchar* default_uri = _get_currrent_doc_location (window);
+
file_chooser = _gedit_file_chooser_open_new ();
if (window != NULL)
@@ -419,6 +453,12 @@ _gedit_cmd_file_open (GSimpleAction *action,
GTK_WINDOW (window));
folder_uri = _gedit_window_get_file_chooser_folder_uri (window, GTK_FILE_CHOOSER_ACTION_OPEN);
+
+ if (default_uri != NULL)
+ {
+ folder_uri = default_uri;
+ }
+
if (folder_uri != NULL)
{
_gedit_file_chooser_set_current_folder_uri (GEDIT_FILE_CHOOSER (file_chooser),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]