[gnome-builder/wip/gtk4-port: 854/1774] libide/gui: try to locate non-workspace contexts
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 854/1774] libide/gui: try to locate non-workspace contexts
- Date: Mon, 11 Jul 2022 22:31:26 +0000 (UTC)
commit f6d4ed7d203a90d41c58c6e6ec5a2009af28b097
Author: Christian Hergert <chergert redhat com>
Date: Mon May 2 20:43:24 2022 -0700
libide/gui: try to locate non-workspace contexts
In case we have a window that has a context property but is not an
IdeWorkspace (such as IdePreferencesWindow).
src/libide/gui/ide-gui-global.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/src/libide/gui/ide-gui-global.c b/src/libide/gui/ide-gui-global.c
index 006955ef3..d4314bbb5 100644
--- a/src/libide/gui/ide-gui-global.c
+++ b/src/libide/gui/ide-gui-global.c
@@ -144,6 +144,8 @@ ide_widget_set_context_handler (gpointer widget,
ide_widget_notify_root_cb (widget, NULL, NULL);
}
+static gboolean dummy_cb (gpointer) { return G_SOURCE_REMOVE; }
+
/**
* ide_widget_get_context:
* @widget: a #GtkWidget
@@ -164,6 +166,27 @@ ide_widget_get_context (GtkWidget *widget)
if (IDE_IS_WORKSPACE (toplevel))
return ide_workspace_get_context (IDE_WORKSPACE (toplevel));
+ if (toplevel != NULL)
+ {
+ GObjectClass *object_class = G_OBJECT_GET_CLASS (toplevel);
+ GParamSpec *pspec = g_object_class_find_property (object_class, "context");
+
+ if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
+ g_type_is_a (pspec->value_type, IDE_TYPE_CONTEXT))
+ {
+ g_auto(GValue) value = G_VALUE_INIT;
+ IdeContext *ret;
+
+ g_value_init (&value, IDE_TYPE_CONTEXT);
+ g_object_get_property (G_OBJECT (toplevel), "context", &value);
+
+ ret = g_value_dup_object (&value);
+ g_idle_add_full (G_PRIORITY_LOW, dummy_cb, ret, g_object_unref);
+
+ return ret;
+ }
+ }
+
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]