[gtk+/wip/baedert/drawing: 368/371] GtkCheckMenuItem: Remove snapshot-indicator vfunc



commit 951a3c10a759403751a611e68249bf33762c0686
Author: Timm Bäder <mail baedert org>
Date:   Sun Jul 16 17:18:17 2017 +0200

    GtkCheckMenuItem: Remove snapshot-indicator vfunc
    
    Let the widget snapshot all child widgets and control the visibility of
    those child widgets instead.

 gtk/gtkcheckmenuitem.c |   33 ---------------------------------
 gtk/gtkcheckmenuitem.h |    3 ---
 gtk/gtkmodelmenuitem.c |   16 ++--------------
 3 files changed, 2 insertions(+), 50 deletions(-)
---
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index b8d57cd..ac80ce3 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -81,13 +81,9 @@ enum {
   PROP_DRAW_AS_RADIO
 };
 
-static void gtk_check_menu_item_snapshot             (GtkWidget             *widget,
-                                                      GtkSnapshot           *snapshot);
 static void gtk_check_menu_item_activate             (GtkMenuItem           *menu_item);
 static void gtk_check_menu_item_toggle_size_request  (GtkMenuItem           *menu_item,
                                                       gint                  *requisition);
-static void gtk_real_check_menu_item_snapshot_indicator (GtkCheckMenuItem   *check_menu_item,
-                                                      GtkSnapshot           *snapshot);
 static void gtk_check_menu_item_set_property         (GObject               *object,
                                                       guint                  prop_id,
                                                       const GValue          *value,
@@ -204,14 +200,11 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
                                                          FALSE,
                                                          GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
 
-  widget_class->snapshot = gtk_check_menu_item_snapshot;
-
   menu_item_class->activate = gtk_check_menu_item_activate;
   menu_item_class->hide_on_activate = FALSE;
   menu_item_class->toggle_size_request = gtk_check_menu_item_toggle_size_request;
   
   klass->toggled = NULL;
-  klass->snapshot_indicator = gtk_real_check_menu_item_snapshot_indicator;
 
   /**
    * GtkCheckMenuItem::toggled:
@@ -491,23 +484,6 @@ gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
 }
 
 static void
-gtk_check_menu_item_snapshot (GtkWidget   *widget,
-                              GtkSnapshot *snapshot)
-{
-  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget);
-  GtkWidget *child;
-
-  child = gtk_bin_get_child (GTK_BIN (widget));
-
-
-  if (child)
-    gtk_widget_snapshot_child (widget, child, snapshot);
-
-  if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->snapshot_indicator)
-    GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->snapshot_indicator (check_menu_item, snapshot);
-}
-
-static void
 gtk_check_menu_item_activate (GtkMenuItem *menu_item)
 {
   GtkCheckMenuItemPrivate *priv;
@@ -574,15 +550,6 @@ gtk_check_menu_item_direction_changed (GtkWidget        *widget,
 }
 
 static void
-gtk_real_check_menu_item_snapshot_indicator (GtkCheckMenuItem *check_menu_item,
-                                             GtkSnapshot      *snapshot)
-{
-  gtk_widget_snapshot_child (GTK_WIDGET (check_menu_item),
-                             check_menu_item->priv->indicator_widget,
-                             snapshot);
-}
-
-static void
 gtk_check_menu_item_get_property (GObject     *object,
                                   guint        prop_id,
                                   GValue      *value,
diff --git a/gtk/gtkcheckmenuitem.h b/gtk/gtkcheckmenuitem.h
index e31973c..317639b 100644
--- a/gtk/gtkcheckmenuitem.h
+++ b/gtk/gtkcheckmenuitem.h
@@ -59,7 +59,6 @@ struct _GtkCheckMenuItem
  * GtkCheckMenuItemClass:
  * @parent_class: The parent class.
  * @toggled: Signal emitted when the state of the check box is changed.
- * @snapshot_indicator: Called to draw the check indicator.
  */
 struct _GtkCheckMenuItemClass
 {
@@ -68,8 +67,6 @@ struct _GtkCheckMenuItemClass
   /*< public >*/
 
   void (* toggled)             (GtkCheckMenuItem *check_menu_item);
-  void (* snapshot_indicator)   (GtkCheckMenuItem *check_menu_item,
-                                GtkSnapshot      *snapshot);
 
   /*< private >*/
 
diff --git a/gtk/gtkmodelmenuitem.c b/gtk/gtkmodelmenuitem.c
index 1d4a5d4..8d0e0a6 100644
--- a/gtk/gtkmodelmenuitem.c
+++ b/gtk/gtkmodelmenuitem.c
@@ -68,17 +68,6 @@ gtk_model_menu_item_activate (GtkMenuItem *item)
 }
 
 static void
-gtk_model_menu_item_snapshot_indicator (GtkCheckMenuItem *check_item,
-                                        GtkSnapshot      *snapshot)
-{
-  GtkModelMenuItem *item = GTK_MODEL_MENU_ITEM (check_item);
-
-  if (item->has_indicator)
-    GTK_CHECK_MENU_ITEM_CLASS (gtk_model_menu_item_parent_class)
-      ->snapshot_indicator (check_item, snapshot);
-}
-
-static void
 gtk_model_menu_item_set_has_indicator (GtkModelMenuItem *item,
                                        gboolean          has_indicator)
 {
@@ -468,17 +457,16 @@ gtk_model_menu_item_set_property (GObject      *object,
 static void
 gtk_model_menu_item_init (GtkModelMenuItem *item)
 {
+  item->has_indicator = FALSE;
+  gtk_widget_hide (_gtk_check_menu_item_get_indicator_widget (GTK_CHECK_MENU_ITEM (item)));
 }
 
 static void
 gtk_model_menu_item_class_init (GtkModelMenuItemClass *class)
 {
-  GtkCheckMenuItemClass *check_class = GTK_CHECK_MENU_ITEM_CLASS (class);
   GtkMenuItemClass *item_class = GTK_MENU_ITEM_CLASS (class);
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-  check_class->snapshot_indicator = gtk_model_menu_item_snapshot_indicator;
-
   item_class->toggle_size_request = gtk_model_menu_item_toggle_size_request;
   item_class->activate = gtk_model_menu_item_activate;
 


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