[gnome-builder] create-project: use ide_path_expand() and ide_path_collapse()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] create-project: use ide_path_expand() and ide_path_collapse()
- Date: Tue, 28 Jun 2016 20:49:41 +0000 (UTC)
commit 055664af09e7beacf6954317ac76e35110bf8d55
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 28 13:48:59 2016 -0700
create-project: use ide_path_expand() and ide_path_collapse()
Now that we have helpers for this, use them instead of open coding.
plugins/create-project/gbp-create-project-widget.c | 41 +++----------------
1 files changed, 7 insertions(+), 34 deletions(-)
---
diff --git a/plugins/create-project/gbp-create-project-widget.c
b/plugins/create-project/gbp-create-project-widget.c
index 361b6ae..db3a8be 100644
--- a/plugins/create-project/gbp-create-project-widget.c
+++ b/plugins/create-project/gbp-create-project-widget.c
@@ -17,10 +17,10 @@
*/
#include <glib/gi18n.h>
+#include <ide.h>
#include <libpeas/peas.h>
#include <stdlib.h>
-#include "ide-macros.h"
#include "gbp-create-project-template-icon.h"
#include "gbp-create-project-widget.h"
@@ -272,38 +272,22 @@ vcs_initializers_foreach_cb (PeasExtensionSet *set,
static gchar *
gbp_create_project_widget_get_directory (GbpCreateProjectWidget *self)
{
- const gchar *text;
-
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- text = gtk_entry_get_text (self->project_location_entry);
-
- if (*text == '~')
- return g_build_filename (g_get_home_dir (),
- &text[1],
- NULL);
-
- return g_strdup (text);
+ return ide_path_expand (gtk_entry_get_text (self->project_location_entry));
}
static void
gbp_create_project_widget_set_directory (GbpCreateProjectWidget *self,
const gchar *filename)
{
- g_autofree gchar *freeme = NULL;
+ g_autofree gchar *collapsed = NULL;
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (self));
- if (filename == NULL)
- filename = g_get_home_dir ();
-
- if (g_str_has_prefix (filename, g_get_home_dir ()))
- {
- freeme = g_build_filename ("~", filename + strlen (g_get_home_dir ()), NULL);
- filename = freeme;
- }
+ collapsed = ide_path_collapse (filename);
- gtk_entry_set_text (self->project_location_entry, filename);
+ gtk_entry_set_text (self->project_location_entry, collapsed);
}
static void
@@ -478,24 +462,13 @@ gbp_create_project_widget_init (GbpCreateProjectWidget *self)
{
g_autoptr(GSettings) settings = NULL;
g_autofree gchar *path = NULL;
- g_autofree char *projects_dir = NULL;
gtk_widget_init_template (GTK_WIDGET (self));
settings = g_settings_new ("org.gnome.builder");
- path = g_settings_get_string (settings, "projects-directory");
-
- if (!ide_str_empty0 (path))
- {
- g_autofree gchar *adjusted = NULL;
- if (!g_path_is_absolute (path))
- projects_dir = g_build_filename (g_get_home_dir (), path, NULL);
- else
- projects_dir = g_steal_pointer (&path);
-
- gbp_create_project_widget_set_directory (self, projects_dir);
- }
+ path = g_settings_get_string (settings, "projects-directory");
+ gbp_create_project_widget_set_directory (self, path);
gtk_flow_box_set_filter_func (self->project_template_chooser,
gbp_create_project_widget_flow_box_filter,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]