[gnome-builder] gtk: add helper to get IdeContext from widget hierarchy
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gtk: add helper to get IdeContext from widget hierarchy
- Date: Mon, 23 Mar 2015 23:23:21 +0000 (UTC)
commit 18906d4959ba17e47f9d738f7c8bcbf18a5dc864
Author: Christian Hergert <christian hergert me>
Date: Tue Feb 10 15:11:01 2015 -0800
gtk: add helper to get IdeContext from widget hierarchy
src/util/gb-widget.c | 16 ++++++++++++++++
src/util/gb-widget.h | 2 ++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/util/gb-widget.c b/src/util/gb-widget.c
index ff79c19..a6d7454 100644
--- a/src/util/gb-widget.c
+++ b/src/util/gb-widget.c
@@ -256,3 +256,19 @@ gb_widget_activate_action (GtkWidget *widget,
g_warning ("Failed to resolve action %s.%s", prefix, action_name);
}
+
+IdeContext *
+gb_widget_get_context (GtkWidget *widget)
+{
+ GbWorkbench *workbench;
+ IdeContext *context = NULL;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ if ((workbench = gb_widget_get_workbench (widget)))
+ context = gb_workbench_get_context (workbench);
+
+ g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL);
+
+ return context;
+}
diff --git a/src/util/gb-widget.h b/src/util/gb-widget.h
index 5bca324..e2f1246 100644
--- a/src/util/gb-widget.h
+++ b/src/util/gb-widget.h
@@ -20,6 +20,7 @@
#define GB_WIDGET_H
#include <gtk/gtk.h>
+#include <ide.h>
#include "gb-workbench-types.h"
@@ -32,6 +33,7 @@ G_BEGIN_DECLS
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), \
TN, field)
+IdeContext *gb_widget_get_context (GtkWidget *widget);
void gb_widget_add_style_class (gpointer widget,
const gchar *class_name);
cairo_surface_t *gb_widget_snapshot (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]