summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse van den Kieboom <jesse.vandenkieboom@epfl.ch>2012-02-08 17:13:34 +0100
committerJesse van den Kieboom <jesse.vandenkieboom@epfl.ch>2012-02-08 17:43:53 +0100
commit1370804f2b1cbb39875bb6a8a53f5bc5318092f4 (patch)
tree5ed3bbdbb48f3578a5a6039a0767736a256fa108
parent90dbaca92477aeb6e1facac5dd8172e0d5319d4e (diff)
downloadglib-1370804f2b1cbb39875bb6a8a53f5bc5318092f4.tar.gz
Retrieve cwd and environ in local GApplicationCommandLine
https://bugzilla.gnome.org/show_bug.cgi?id=669689
-rw-r--r--gio/gapplicationcommandline.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/gio/gapplicationcommandline.c b/gio/gapplicationcommandline.c
index 0aa0ac99b..ef33cd1a1 100644
--- a/gio/gapplicationcommandline.c
+++ b/gio/gapplicationcommandline.c
@@ -139,9 +139,9 @@ struct _GApplicationCommandLinePrivate
{
GVariant *platform_data;
GVariant *arguments;
- GVariant *cwd;
+ gchar *cwd;
- const gchar **environ;
+ gchar **environ;
gint exit_status;
};
@@ -162,14 +162,14 @@ grok_platform_data (GApplicationCommandLine *cmdline)
if (strcmp (key, "cwd") == 0)
{
if (!cmdline->priv->cwd)
- cmdline->priv->cwd = g_variant_ref (value);
+ cmdline->priv->cwd = g_variant_dup_bytestring (value, NULL);
}
else if (strcmp (key, "environ") == 0)
{
if (!cmdline->priv->environ)
cmdline->priv->environ =
- g_variant_get_bytestring_array (value, NULL);
+ g_variant_dup_bytestring_array (value, NULL);
}
}
@@ -250,8 +250,9 @@ g_application_command_line_finalize (GObject *object)
g_variant_unref (cmdline->priv->platform_data);
if (cmdline->priv->arguments)
g_variant_unref (cmdline->priv->arguments);
- if (cmdline->priv->cwd)
- g_variant_unref (cmdline->priv->cwd);
+
+ g_free (cmdline->priv->cwd);
+ g_strfreev (cmdline->priv->environ);
G_OBJECT_CLASS (g_application_command_line_parent_class)
->finalize (object);
@@ -267,6 +268,22 @@ g_application_command_line_init (GApplicationCommandLine *cmdline)
}
static void
+g_application_command_line_constructed (GObject *object)
+{
+ GApplicationCommandLine *cmdline = G_APPLICATION_COMMAND_LINE (object);
+
+ if (IS_REMOTE (cmdline))
+ return;
+
+ /* In the local case, set cmd and environ */
+ if (!cmdline->priv->cwd)
+ cmdline->priv->cwd = g_get_current_dir ();
+
+ if (!cmdline->priv->environ)
+ cmdline->priv->environ = g_get_environ ();
+}
+
+static void
g_application_command_line_class_init (GApplicationCommandLineClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -274,6 +291,8 @@ g_application_command_line_class_init (GApplicationCommandLineClass *class)
object_class->get_property = g_application_command_line_get_property;
object_class->set_property = g_application_command_line_set_property;
object_class->finalize = g_application_command_line_finalize;
+ object_class->constructed = g_application_command_line_constructed;
+
class->printerr_literal = g_application_command_line_real_printerr_literal;
class->print_literal = g_application_command_line_real_print_literal;
@@ -358,10 +377,7 @@ g_application_command_line_get_arguments (GApplicationCommandLine *cmdline,
const gchar *
g_application_command_line_get_cwd (GApplicationCommandLine *cmdline)
{
- if (cmdline->priv->cwd)
- return g_variant_get_bytestring (cmdline->priv->cwd);
- else
- return NULL;
+ return cmdline->priv->cwd;
}
/**
@@ -392,7 +408,7 @@ g_application_command_line_get_cwd (GApplicationCommandLine *cmdline)
const gchar * const *
g_application_command_line_get_environ (GApplicationCommandLine *cmdline)
{
- return cmdline->priv->environ;
+ return (const gchar **)cmdline->priv->environ;
}
/**