[gtk+] widget: Make _gtk_set_simple_clip() take an optional content clip



commit b5a8b7ef3b15c2bc264118294895202a16641168
Author: Benjamin Otte <otte redhat com>
Date:   Wed Aug 20 23:49:00 2014 +0200

    widget: Make _gtk_set_simple_clip() take an optional content clip

 gtk/gtkbox.c           |    4 ++--
 gtk/gtkbutton.c        |    2 +-
 gtk/gtkcolorswatch.c   |    2 +-
 gtk/gtkcombobox.c      |    2 +-
 gtk/gtkentry.c         |    2 +-
 gtk/gtkgrid.c          |    2 +-
 gtk/gtklevelbar.c      |    2 +-
 gtk/gtklistbox.c       |    2 +-
 gtk/gtkpathbar.c       |    4 ++--
 gtk/gtkprogressbar.c   |    2 +-
 gtk/gtkswitch.c        |    2 +-
 gtk/gtktoolbar.c       |    2 +-
 gtk/gtkwidget.c        |    8 +++++++-
 gtk/gtkwidgetprivate.h |    3 ++-
 14 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index be1f3f6..613b5ae 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -803,7 +803,7 @@ gtk_box_size_allocate_no_center (GtkWidget     *widget,
        }
     }
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
@@ -1172,7 +1172,7 @@ gtk_box_size_allocate_with_center (GtkWidget     *widget,
     }
   gtk_widget_size_allocate_with_baseline (priv->center->widget, &child_allocation, baseline);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index ebe4f15..c1f4d0d 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1773,7 +1773,7 @@ gtk_button_size_allocate (GtkWidget     *widget,
       gtk_widget_size_allocate_with_baseline (child, &child_allocation, baseline);
     }
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static gboolean
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index b5329fa..05b6c81 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -645,7 +645,7 @@ swatch_size_allocate (GtkWidget *widget,
                             allocation->width,
                             allocation->height);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static gboolean
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 96ef51a..8b6d81e 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -2768,7 +2768,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
       gtk_widget_size_allocate (child_widget, &child);
     }
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 #undef GTK_COMBO_BOX_ALLOCATE_BUTTON
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 5a9298c..536e048 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3715,7 +3715,7 @@ gtk_entry_size_allocate (GtkWidget     *widget,
         _gtk_entry_completion_resize_popup (completion);
     }
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static gboolean
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index d735e63..ce4a7dc 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -1681,7 +1681,7 @@ gtk_grid_size_allocate (GtkWidget     *widget,
 
   gtk_grid_request_allocate_children (&request);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static gboolean
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index 91d848c..f8b234c 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -581,7 +581,7 @@ gtk_level_bar_size_allocate (GtkWidget     *widget,
 {
   GTK_WIDGET_CLASS (gtk_level_bar_parent_class)->size_allocate (widget, allocation);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 562a15c..83aea78 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -3137,7 +3137,7 @@ gtk_list_box_row_size_allocate (GtkWidget     *widget,
       gtk_widget_size_allocate (child, &child_allocation);
     }
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 /**
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 251f34f..0afef8c 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -551,7 +551,7 @@ gtk_path_bar_size_allocate (GtkWidget     *widget,
   /* No path is set; we don't have to allocate anything. */
   if (path_bar->priv->button_list == NULL)
     {
-      _gtk_widget_set_simple_clip (widget);
+      _gtk_widget_set_simple_clip (widget, NULL);
 
       return;
     }
@@ -773,7 +773,7 @@ gtk_path_bar_size_allocate (GtkWidget     *widget,
   if (needs_reorder)
     child_ordering_changed (path_bar);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index b2b2496..84aeef9 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -450,7 +450,7 @@ gtk_progress_bar_size_allocate (GtkWidget     *widget,
 {
   GTK_WIDGET_CLASS (gtk_progress_bar_parent_class)->size_allocate (widget, allocation);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index e9b4fcc..2050477 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -480,7 +480,7 @@ gtk_switch_size_allocate (GtkWidget     *widget,
   else
     priv->handle_x = 0;
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 5ec5e52..ea05df4 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -1835,7 +1835,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   g_free (allocations);
   g_free (new_states);
 
-  _gtk_widget_set_simple_clip (widget);
+  _gtk_widget_set_simple_clip (widget, NULL);
 }
 
 static void
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 383728d..cb9727b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15548,6 +15548,8 @@ union_with_clip (GtkWidget *widget,
 /*
  * _gtk_widget_set_simple_clip:
  * @widget: a #GtkWidget
+ * @content_clip: Clipping area of the contents or %NULL, if the contents
+ *     do not extent the allocation.
  *
  * This is a convenience function for gtk_widget_set_clip(), if you
  * just want to set the clip for @widget based on its allocation,
@@ -15562,7 +15564,8 @@ union_with_clip (GtkWidget *widget,
  * function and must call gtk_widget_set_clip() yourself.
  **/
 void
-_gtk_widget_set_simple_clip (GtkWidget *widget)
+_gtk_widget_set_simple_clip (GtkWidget     *widget,
+                             GtkAllocation *content_clip)
 {
   GtkStyleContext *context;
   GtkAllocation clip;
@@ -15580,6 +15583,9 @@ _gtk_widget_set_simple_clip (GtkWidget *widget)
   clip.width += extents.left + extents.right;
   clip.height += extents.top + extents.bottom;
 
+  if (content_clip)
+  gdk_rectangle_union (content_clip, &clip, &clip);
+
   if (GTK_IS_CONTAINER (widget))
     gtk_container_forall (GTK_CONTAINER (widget), union_with_clip, &clip);
 
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 9b8fae5..3a825d3 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -134,7 +134,8 @@ GtkStyle *        _gtk_widget_get_style                    (GtkWidget *widget);
 void              _gtk_widget_set_style                    (GtkWidget *widget,
                                                             GtkStyle  *style);
 gboolean          _gtk_widget_supports_clip                (GtkWidget *widget);
-void              _gtk_widget_set_simple_clip              (GtkWidget *widget);
+void              _gtk_widget_set_simple_clip              (GtkWidget *widget,
+                                                            GtkAllocation *content_clip);
 
 typedef gboolean (*GtkCapturedEventHandler) (GtkWidget *widget, GdkEvent *event);
 


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