[gtk/wip/matthiasc/context-menu: 1/2] Add gtk_widget_set_context_menu



commit eedd5f0b5b20333d90758e52e06435bbbdcb7881
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 +++++++
 2 files changed, 29 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)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]