[seed] Fixing ProgramInvocationName in system module
- From: Danilo Cesar Lemes de Paula <danilocesar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seed] Fixing ProgramInvocationName in system module
- Date: Thu, 23 Jun 2016 00:58:54 +0000 (UTC)
commit 0a2cce27c33c6041f8745184480adac38e2788e1
Author: Danilo Cesar Lemes de Paula <danilo cesar collabora co uk>
Date: Wed Jun 22 21:52:22 2016 -0300
Fixing ProgramInvocationName in system module
The older module used to return a dummy "GnomeWeather" for string,
which was wrong.
libseed/seed-engine.c | 53 ++++++++++++++++++++-----------------
libseed/seed-engine.h | 2 +-
libseed/seed-private.h | 1 +
libseed/seed.h | 1 +
modules/gjs/system/seed-system.c | 15 +----------
5 files changed, 33 insertions(+), 39 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 28d5807..3c524f5 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -1691,28 +1691,31 @@ seed_arg_no_debug_cb(const char* key, const char* value, gpointer user_data)
}
#endif /* SEED_ENABLE_DEBUG */
-static GOptionEntry seed_args[] = {
-#ifdef SEED_ENABLE_DEBUG
- { "seed-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_debug_cb,
- "Seed debugging messages to show. Comma separated list of: all, misc, "
- "finalization, initialization, construction, invocation, signal, "
- "structs, gtype.",
- "FLAGS" },
- { "seed-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_no_debug_cb,
- "Disable Seed debugging", "FLAGS" },
-#endif /* SEED_ENABLE_DEBUG */
- { "seed-version", 0, 0, G_OPTION_ARG_NONE, &seed_arg_print_version,
- "Print libseed version", 0 },
- {
- NULL,
- },
-};
-
GOptionGroup*
-seed_get_option_group(void)
+seed_get_option_group(SeedEngine* eng)
{
GOptionGroup* group;
+ GOptionEntry seed_args[] = {
+#ifdef SEED_ENABLE_DEBUG
+ { "seed-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_debug_cb,
+ "Seed debugging messages to show. Comma separated list of: all, "
+ "misc, "
+ "finalization, initialization, construction, invocation, signal, "
+ "structs, gtype.",
+ "FLAGS" },
+ { "seed-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_no_debug_cb,
+ "Disable Seed debugging", "FLAGS" },
+#endif /* SEED_ENABLE_DEBUG */
+ { "seed-version", 0, 0, G_OPTION_ARG_NONE, &seed_arg_print_version,
+ "Print libseed version", 0 },
+ { "program-name", 0, 0, G_OPTION_ARG_STRING, &eng->program_name,
+ "Program Name", 0 },
+ {
+ NULL,
+ },
+ };
+
group = g_option_group_new("seed", "Seed Options", "Show Seed Options",
NULL, NULL);
g_option_group_add_entries(group, seed_args);
@@ -1721,7 +1724,7 @@ seed_get_option_group(void)
}
static gboolean
-seed_parse_args(int* argc, char*** argv)
+seed_parse_args(SeedEngine* eng, int* argc, char*** argv)
{
GOptionContext* option_context;
GOptionGroup* seed_group;
@@ -1734,8 +1737,7 @@ seed_parse_args(int* argc, char*** argv)
g_option_context_set_help_enabled(option_context, TRUE);
/* Initiate any command line options from the backend */
-
- seed_group = seed_get_option_group();
+ seed_group = seed_get_option_group(eng);
g_option_context_add_group(option_context, seed_group);
if (!g_option_context_parse(option_context, argc, argv, &error)) {
@@ -1747,6 +1749,9 @@ seed_parse_args(int* argc, char*** argv)
ret = FALSE;
}
+ if (!eng->program_name)
+ eng->program_name = g_strdup(*argv[0]);
+
g_option_context_free(option_context);
return ret;
@@ -1799,7 +1804,9 @@ seed_init_constrained_with_context_and_group(gint* argc,
#endif
g_log_set_handler("GLib-GObject", G_LOG_LEVEL_WARNING, seed_log_handler, 0);
- if ((argc != 0) && seed_parse_args(argc, argv) == FALSE) {
+ eng = (SeedEngine*) g_malloc(sizeof(SeedEngine));
+
+ if ((argc != 0) && seed_parse_args(eng, argc, argv) == FALSE) {
SEED_NOTE(MISC, "failed to parse arguments.");
return FALSE;
}
@@ -1815,8 +1822,6 @@ seed_init_constrained_with_context_and_group(gint* argc,
pthread_key_create(&seed_next_gobject_wrapper_key, NULL);
- eng = (SeedEngine*) g_malloc(sizeof(SeedEngine));
-
context_group = group;
eng->context = context;
diff --git a/libseed/seed-engine.h b/libseed/seed-engine.h
index 9652344..0905420 100644
--- a/libseed/seed-engine.h
+++ b/libseed/seed-engine.h
@@ -84,6 +84,6 @@ JSValueRef seed_simple_evaluate(JSContextRef ctx,
const gchar* script,
JSValueRef* exception);
-GOptionGroup* seed_get_option_group(void);
+GOptionGroup* seed_get_option_group(SeedEngine* engine);
#endif
diff --git a/libseed/seed-private.h b/libseed/seed-private.h
index 6fde94e..880a6c6 100644
--- a/libseed/seed-private.h
+++ b/libseed/seed-private.h
@@ -41,6 +41,7 @@ struct _SeedEngine
gchar** search_path;
JSContextGroupRef group;
+ gchar* program_name;
};
#include "seed-debug.h"
diff --git a/libseed/seed.h b/libseed/seed.h
index 5f2a724..f00c129 100644
--- a/libseed/seed.h
+++ b/libseed/seed.h
@@ -66,6 +66,7 @@ typedef struct _SeedEngine
gchar** search_path;
SeedContextGroup group;
+ gchar* program_name;
} SeedEngine;
/*
diff --git a/modules/gjs/system/seed-system.c b/modules/gjs/system/seed-system.c
index 867acca..8928497 100644
--- a/modules/gjs/system/seed-system.c
+++ b/modules/gjs/system/seed-system.c
@@ -196,7 +196,6 @@ SeedObject
gjs_compat_define_system_stuff(SeedEngine* eng)
{
SeedContext context = eng->context;
- char* program_name = "gnome-weather";
SeedObject module;
gboolean ret;
@@ -206,23 +205,11 @@ gjs_compat_define_system_stuff(SeedEngine* eng)
SeedValue seed = seed_object_get_property(context, eng->global, "Seed");
SeedValue argv = seed_object_get_property(context, seed, "argv");
- g_print("Seed: %p\n", seed);
- g_print("Argv: %p\n", argv);
-
- // gjs_context = (GjsContext*) JS_GetContextPrivate(context);
- // g_object_get(gjs_context,
- // "program-name", &program_name,
- // NULL);
-
- // if (!gjs_string_from_utf8(context, program_name,
- // -1, &value))
- // goto out;
-
/* The name is modeled after program_invocation_name,
part of the glibc */
ret = seed_object_set_property(
context, module, "programInvocationName",
- (SeedValue) seed_value_from_string(context, program_name, NULL));
+ (SeedValue) seed_value_from_string(context, eng->program_name, NULL));
g_print("Module: %d\n", ret);
ret = seed_object_set_property(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]