[gnome-builder] greeter: use Directory filter by default
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] greeter: use Directory filter by default
- Date: Mon, 27 Nov 2017 05:02:32 +0000 (UTC)
commit 4c95888edb67f31d225efbee84879b194d89a4a7
Author: Christian Hergert <chergert redhat com>
Date: Sun Nov 26 20:41:18 2017 -0800
greeter: use Directory filter by default
Most people seem to be thinking about their projects in terms
of a "project directory". Since we can auto-discover the build
system within that directory, we no longer need to default to
selecting project files. It was at odds with inode/directory
content-type in file-chooser because that requires SELECT_FOLDER
file chooser action.
src/libide/directory/directory.plugin | 1 +
src/libide/greeter/ide-greeter-perspective.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/libide/directory/directory.plugin b/src/libide/directory/directory.plugin
index ebf74f0..9fe1c48 100644
--- a/src/libide/directory/directory.plugin
+++ b/src/libide/directory/directory.plugin
@@ -9,4 +9,5 @@ Hidden=true
X-Build-System-Priority=10000000
X-Project-File-Filter-Name=Directory
X-Project-File-Filter-Content-Type=inode/directory
+X-Project-File-Filter-Priority=-100
Embedded=ide_directory_register_types
diff --git a/src/libide/greeter/ide-greeter-perspective.c b/src/libide/greeter/ide-greeter-perspective.c
index ba7d24c..c47f328 100644
--- a/src/libide/greeter/ide-greeter-perspective.c
+++ b/src/libide/greeter/ide-greeter-perspective.c
@@ -297,6 +297,7 @@ ide_greeter_perspective_open_clicked (IdeGreeterPerspective *self,
PeasEngine *engine;
const GList *list;
GtkFileFilter *all_filter;
+ gint64 last_priority = G_MAXINT64;
g_assert (IDE_IS_GREETER_PERSPECTIVE (self));
g_assert (GTK_IS_BUTTON (open_button));
@@ -338,6 +339,7 @@ ide_greeter_perspective_open_clicked (IdeGreeterPerspective *self,
const gchar *pattern;
const gchar *content_type;
const gchar *name;
+ const gchar *priority;
gchar **patterns;
gchar **content_types;
gint i;
@@ -351,6 +353,7 @@ ide_greeter_perspective_open_clicked (IdeGreeterPerspective *self,
pattern = peas_plugin_info_get_external_data (plugin_info, "X-Project-File-Filter-Pattern");
content_type = peas_plugin_info_get_external_data (plugin_info, "X-Project-File-Filter-Content-Type");
+ priority = peas_plugin_info_get_external_data (plugin_info, "X-Project-File-Filter-Priority");
if (pattern == NULL && content_type == NULL)
continue;
@@ -389,6 +392,18 @@ ide_greeter_perspective_open_clicked (IdeGreeterPerspective *self,
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ /* Look at the priority to set the default file filter. */
+ if (priority != NULL)
+ {
+ gint64 pval = g_ascii_strtoll (priority, NULL, 10);
+
+ if (pval < last_priority)
+ {
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
+ last_priority = pval;
+ }
+ }
+
g_strfreev (patterns);
g_strfreev (content_types);
}
@@ -399,7 +414,9 @@ ide_greeter_perspective_open_clicked (IdeGreeterPerspective *self,
self,
G_CONNECT_SWAPPED);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), all_filter);
+ /* If unset, set the default filter */
+ if (last_priority == G_MAXINT64)
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), all_filter);
settings = g_settings_new ("org.gnome.builder");
projects_dir = g_settings_get_string (settings, "projects-directory");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]