[gtk/wip/matthiasc/context-menu: 80/91] Add gtk_widget_set_context_menu



commit 1326883544e94e47a571797a46fa96ef41c965cc
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 c9a4772d4c..5525c6d320 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13593,3 +13593,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]