summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--gjs-srcs.mk5
-rw-r--r--libgjs-private/gjs-gtk-util.c109
-rw-r--r--libgjs-private/gjs-gtk-util.h42
-rw-r--r--libgjs-private/gjs-util.c81
-rw-r--r--libgjs-private/gjs-util.h6
-rw-r--r--win32/config-msvc.mak2
7 files changed, 88 insertions, 161 deletions
diff --git a/Makefile.am b/Makefile.am
index 1b3b6d9d..dfb36dd4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -94,10 +94,6 @@ endif
# Also, these files used to be a separate library
libgjs_private_source_files = $(gjs_private_srcs)
-if ENABLE_GTK
-libgjs_private_source_files += $(gjs_gtk_private_srcs)
-endif
-
libgjs_la_SOURCES += $(libgjs_private_source_files)
# The built-in modules also used to be compiled separately
diff --git a/gjs-srcs.mk b/gjs-srcs.mk
index 389c3d02..95022596 100644
--- a/gjs-srcs.mk
+++ b/gjs-srcs.mk
@@ -103,11 +103,6 @@ gjs_private_srcs = \
libgjs-private/gjs-gdbus-wrapper.h \
libgjs-private/gjs-util.c \
libgjs-private/gjs-util.h \
- libgjs-private/gjs-gtk-util.h \
- $(NULL)
-
-gjs_gtk_private_srcs = \
- libgjs-private/gjs-gtk-util.c \
$(NULL)
gjs_console_srcs = \
diff --git a/libgjs-private/gjs-gtk-util.c b/libgjs-private/gjs-gtk-util.c
deleted file mode 100644
index 2b4ab563..00000000
--- a/libgjs-private/gjs-gtk-util.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
-/* Copyright 2014 Endless Mobile, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include <stddef.h> // for NULL
-
-#include <girepository.h>
-#include <glib-object.h>
-#include <glib.h>
-
-#include "libgjs-private/gjs-gtk-util.h"
-
-static GParamSpec* gjs_gtk_container_class_find_child_property(
- GIObjectInfo* container_info, GObject* container, const char* property) {
- GIBaseInfo* class_info = NULL;
- GIBaseInfo* find_child_property_fun = NULL;
-
- GIArgument ret;
- GIArgument find_child_property_args[2];
-
- class_info = g_object_info_get_class_struct(container_info);
- find_child_property_fun =
- g_struct_info_find_method(class_info, "find_child_property");
-
- find_child_property_args[0].v_pointer = G_OBJECT_GET_CLASS(container);
- find_child_property_args[1].v_string = (char*)property;
-
- g_function_info_invoke(find_child_property_fun, find_child_property_args, 2,
- NULL, 0, &ret, NULL);
-
- g_clear_pointer(&class_info, g_base_info_unref);
- g_clear_pointer(&find_child_property_fun, g_base_info_unref);
-
- return (GParamSpec*)ret.v_pointer;
-}
-
-void gjs_gtk_container_child_set_property(GObject* container, GObject* child,
- const char* property,
- const GValue* value) {
- GParamSpec* pspec = NULL;
- GIBaseInfo* base_info = NULL;
- GIBaseInfo* child_set_property_fun = NULL;
- GIObjectInfo* container_info;
- GValue value_arg = G_VALUE_INIT;
- GIArgument ret;
-
- GIArgument child_set_property_args[4];
-
- base_info = g_irepository_find_by_name(NULL, "Gtk", "Container");
- container_info = (GIObjectInfo*)base_info;
-
- pspec = gjs_gtk_container_class_find_child_property(container_info,
- container, property);
- if (pspec == NULL) {
- g_warning("%s does not have a property called %s",
- g_type_name(G_OBJECT_TYPE(container)), property);
- goto out;
- }
-
- if ((G_VALUE_TYPE(value) == G_TYPE_POINTER) &&
- (g_value_get_pointer(value) == NULL) &&
- !g_value_type_transformable(G_VALUE_TYPE(value), pspec->value_type)) {
- /* Set an empty value. This will happen when we set a NULL value from
- * JS. Since GJS doesn't know the GParamSpec for this property, it will
- * just put NULL into a G_TYPE_POINTER GValue, which will later fail
- * when trying to transform it to the GParamSpec's GType.
- */
- g_value_init(&value_arg, pspec->value_type);
- } else {
- g_value_init(&value_arg, G_VALUE_TYPE(value));
- g_value_copy(value, &value_arg);
- }
-
- child_set_property_fun =
- g_object_info_find_method(container_info, "child_set_property");
-
- child_set_property_args[0].v_pointer = container;
- child_set_property_args[1].v_pointer = child;
- child_set_property_args[2].v_string = (char*)property;
- child_set_property_args[3].v_pointer = &value_arg;
-
- g_function_info_invoke(child_set_property_fun, child_set_property_args, 4,
- NULL, 0, &ret, NULL);
-
- g_value_unset(&value_arg);
-
-out:
- g_clear_pointer(&pspec, g_param_spec_unref);
- g_clear_pointer(&base_info, g_base_info_unref);
- g_clear_pointer(&child_set_property_fun, g_base_info_unref);
-}
diff --git a/libgjs-private/gjs-gtk-util.h b/libgjs-private/gjs-gtk-util.h
deleted file mode 100644
index 20492aa5..00000000
--- a/libgjs-private/gjs-gtk-util.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
-/* Copyright 2014 Endless Mobile, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef LIBGJS_PRIVATE_GJS_GTK_UTIL_H_
-#define LIBGJS_PRIVATE_GJS_GTK_UTIL_H_
-
-#include <config.h> /* for ENABLE_GTK */
-
-#include <glib-object.h>
-#include <glib.h>
-
-#include "gjs/macros.h"
-
-G_BEGIN_DECLS
-
-GJS_EXPORT
-void gjs_gtk_container_child_set_property(GObject* container, GObject* child,
- const char* property,
- const GValue* value);
-
-G_END_DECLS
-
-#endif /* LIBGJS_PRIVATE_GJS_GTK_UTIL_H_ */
diff --git a/libgjs-private/gjs-util.c b/libgjs-private/gjs-util.c
index f27e4c76..00e3f6d1 100644
--- a/libgjs-private/gjs-util.c
+++ b/libgjs-private/gjs-util.c
@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include <glib-object.h>
+#include <girepository.h>
#include <glib.h>
#include <glib/gi18n.h> /* for bindtextdomain, bind_textdomain_codeset, textdomain */
@@ -204,3 +205,83 @@ int gjs_open_bytes(GBytes* bytes, GError** error) {
g_error("%s is currently supported on UNIX only", __func__);
#endif
}
+
+static GParamSpec* gjs_gtk_container_class_find_child_property(
+ GIObjectInfo* container_info, GObject* container, const char* property) {
+ GIBaseInfo* class_info = NULL;
+ GIBaseInfo* find_child_property_fun = NULL;
+
+ GIArgument ret;
+ GIArgument find_child_property_args[2];
+
+ class_info = g_object_info_get_class_struct(container_info);
+ find_child_property_fun =
+ g_struct_info_find_method(class_info, "find_child_property");
+
+ find_child_property_args[0].v_pointer = G_OBJECT_GET_CLASS(container);
+ find_child_property_args[1].v_string = (char*)property;
+
+ g_function_info_invoke(find_child_property_fun, find_child_property_args, 2,
+ NULL, 0, &ret, NULL);
+
+ g_clear_pointer(&class_info, g_base_info_unref);
+ g_clear_pointer(&find_child_property_fun, g_base_info_unref);
+
+ return (GParamSpec*)ret.v_pointer;
+}
+
+void gjs_gtk_container_child_set_property(GObject* container, GObject* child,
+ const char* property,
+ const GValue* value) {
+ GParamSpec* pspec = NULL;
+ GIBaseInfo* base_info = NULL;
+ GIBaseInfo* child_set_property_fun = NULL;
+ GIObjectInfo* container_info;
+ GValue value_arg = G_VALUE_INIT;
+ GIArgument ret;
+
+ GIArgument child_set_property_args[4];
+
+ base_info = g_irepository_find_by_name(NULL, "Gtk", "Container");
+ container_info = (GIObjectInfo*)base_info;
+
+ pspec = gjs_gtk_container_class_find_child_property(container_info,
+ container, property);
+ if (pspec == NULL) {
+ g_warning("%s does not have a property called %s",
+ g_type_name(G_OBJECT_TYPE(container)), property);
+ goto out;
+ }
+
+ if ((G_VALUE_TYPE(value) == G_TYPE_POINTER) &&
+ (g_value_get_pointer(value) == NULL) &&
+ !g_value_type_transformable(G_VALUE_TYPE(value), pspec->value_type)) {
+ /* Set an empty value. This will happen when we set a NULL value from
+ * JS. Since GJS doesn't know the GParamSpec for this property, it will
+ * just put NULL into a G_TYPE_POINTER GValue, which will later fail
+ * when trying to transform it to the GParamSpec's GType.
+ */
+ g_value_init(&value_arg, pspec->value_type);
+ } else {
+ g_value_init(&value_arg, G_VALUE_TYPE(value));
+ g_value_copy(value, &value_arg);
+ }
+
+ child_set_property_fun =
+ g_object_info_find_method(container_info, "child_set_property");
+
+ child_set_property_args[0].v_pointer = container;
+ child_set_property_args[1].v_pointer = child;
+ child_set_property_args[2].v_string = (char*)property;
+ child_set_property_args[3].v_pointer = &value_arg;
+
+ g_function_info_invoke(child_set_property_fun, child_set_property_args, 4,
+ NULL, 0, &ret, NULL);
+
+ g_value_unset(&value_arg);
+
+out:
+ g_clear_pointer(&pspec, g_param_spec_unref);
+ g_clear_pointer(&base_info, g_base_info_unref);
+ g_clear_pointer(&child_set_property_fun, g_base_info_unref);
+}
diff --git a/libgjs-private/gjs-util.h b/libgjs-private/gjs-util.h
index a1c907c1..945dc8ad 100644
--- a/libgjs-private/gjs-util.h
+++ b/libgjs-private/gjs-util.h
@@ -67,6 +67,12 @@ GType gjs_param_spec_get_value_type (GParamSpec *pspec);
GJS_EXPORT
GType gjs_param_spec_get_owner_type (GParamSpec *pspec);
+/* For imports.overrides.Gtk */
+GJS_EXPORT
+void gjs_gtk_container_child_set_property(GObject* container, GObject* child,
+ const char* property,
+ const GValue* value);
+
/* For tests */
GJS_EXPORT
int gjs_open_bytes(GBytes* bytes, GError** error);
diff --git a/win32/config-msvc.mak b/win32/config-msvc.mak
index 29cfee90..3572c9b6 100644
--- a/win32/config-msvc.mak
+++ b/win32/config-msvc.mak
@@ -90,7 +90,7 @@ INTROSPECTION_INCLUDE_PACKAGES = --include=Gio-2.0 --include=GObject-2.0
# Enable GTK+
!if "$(NO_GTK)" != "1"
GJS_DEFINES = $(GJS_DEFINES) /DENABLE_GTK
-LIBGJS_PRIVATE_SOURCES = $(LIBGJS_PRIVATE_SOURCES) $(gjs_gtk_private_srcs)
+LIBGJS_PRIVATE_SOURCES = $(LIBGJS_PRIVATE_SOURCES)
GJS_INTROSPECTION_CHECK_PACKAGE = gtk+-3.0
INTROSPECTION_INCLUDE_PACKAGES = $(INTROSPECTION_INCLUDE_PACKAGES) --include=Gtk-3.0