[gtk/wip/matthiasc/context-menu: 1/2] Add gtk_widget_set_context_menu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/context-menu: 1/2] Add gtk_widget_set_context_menu
- Date: Sat, 26 Jan 2019 23:57:06 +0000 (UTC)
commit a37d173022d12849510c616beb6df8e85f95bf45
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 26 18:50:14 2019 -0500
Add gtk_widget_set_context_menu
This lets apps associate a menu model with a widget.
It is up to individual widgets to use it.
gtk/gtkwidget.c | 22 ++++++++++++++++++++++
gtk/gtkwidget.h | 7 +++++++
gtk/gtkwidgetprivate.h | 2 ++
3 files changed, 31 insertions(+)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 05aa11b692..eb2f764bef 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13585,3 +13585,25 @@ gtk_widget_get_height (GtkWidget *widget)
border.top - border.bottom -
padding.top - padding.bottom;
}
+
+void
+gtk_widget_set_context_menu (GtkWidget *widget,
+ GMenuModel *menu)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (menu == NULL || G_IS_MENU_MODEL (menu));
+
+ g_set_object (&priv->context_menu, menu);
+}
+
+GMenuModel *
+gtk_widget_get_context_menu (GtkWidget *widget)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ return priv->context_menu;
+}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index a9aba23eb7..f39cff30b2 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1044,6 +1044,13 @@ void gtk_widget_snapshot_child (GtkWidget *widget,
GtkWidget *child,
GtkSnapshot *snapshot);
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_set_context_menu (GtkWidget *widget,
+ GMenuModel *menu);
+GDK_AVAILABLE_IN_ALL
+GMenuModel * gtk_widget_get_context_menu (GtkWidget *widget);
+
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRequisition, gtk_requisition_free)
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index f658811358..d3b08aa93f 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -176,6 +176,8 @@ struct _GtkWidgetPrivate
/* Pointer cursor */
GdkCursor *cursor;
+
+ GMenuModel *context_menu;
};
GtkCssNode * gtk_widget_get_css_node (GtkWidget *widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]