[gtk+] container: Remove focus_child pointer
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] container: Remove focus_child pointer
- Date: Fri, 31 Mar 2017 07:55:12 +0000 (UTC)
commit 885bcd9fe4b6b4ecb003570ea0520cf42ec737a9
Author: Timm Bäder <mail baedert org>
Date: Wed Feb 8 10:02:47 2017 +0100
container: Remove focus_child pointer
Use GtkWidget's instead.
gtk/gtkcontainer.c | 36 ++++++------------------------------
gtk/gtkwidget.c | 3 +++
2 files changed, 9 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index a5d40d5..aedd504 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -276,8 +276,6 @@
struct _GtkContainerPrivate
{
- GtkWidget *focus_child;
-
GdkFrameClock *resize_clock;
guint resize_handler;
@@ -1590,12 +1588,7 @@ gtk_container_remove_unimplemented (GtkContainer *container,
static void
gtk_container_init (GtkContainer *container)
{
- GtkContainerPrivate *priv;
-
container->priv = gtk_container_get_instance_private (container);
- priv = container->priv;
-
- priv->focus_child = NULL;
}
static void
@@ -1607,8 +1600,6 @@ gtk_container_destroy (GtkWidget *widget)
if (priv->restyle_pending)
priv->restyle_pending = FALSE;
- g_clear_object (&priv->focus_child);
-
/* do this before walking child widgets, to avoid
* removing children from focus chain one by one.
*/
@@ -2059,47 +2050,33 @@ static void
gtk_container_real_set_focus_child (GtkContainer *container,
GtkWidget *child)
{
- GtkContainerPrivate *priv;
+ GtkWidget *focus_child;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
- priv = container->priv;
-
- if (child != priv->focus_child)
- {
- if (priv->focus_child)
- g_object_unref (priv->focus_child);
- priv->focus_child = child;
- if (priv->focus_child)
- g_object_ref (priv->focus_child);
- }
-
+ focus_child = gtk_widget_get_focus_child (GTK_WIDGET (container));
/* check for h/v adjustments
*/
- if (priv->focus_child)
+ if (focus_child)
{
GtkAdjustment *hadj;
GtkAdjustment *vadj;
GtkAllocation allocation;
- GtkWidget *focus_child;
gint x, y;
hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);
vadj = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
if (hadj || vadj)
{
-
- focus_child = priv->focus_child;
-
while (gtk_widget_get_focus_child (focus_child))
focus_child = gtk_widget_get_focus_child (focus_child);
- gtk_widget_translate_coordinates (focus_child, priv->focus_child,
+ gtk_widget_translate_coordinates (focus_child, focus_child,
0, 0, &x, &y);
- _gtk_widget_get_allocation (priv->focus_child, &allocation);
+ _gtk_widget_get_allocation (focus_child, &allocation);
x += allocation.x;
y += allocation.y;
@@ -2647,11 +2624,10 @@ gtk_container_focus_move (GtkContainer *container,
GList *children,
GtkDirectionType direction)
{
- GtkContainerPrivate *priv = container->priv;
GtkWidget *focus_child;
GtkWidget *child;
- focus_child = priv->focus_child;
+ focus_child = gtk_widget_get_focus_child (GTK_WIDGET (container));
while (children)
{
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index f89351a..233dd68 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15739,6 +15739,9 @@ gtk_widget_set_focus_child (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (child == priv->focus_child)
+ return;
+
if (child != NULL)
{
g_return_if_fail (GTK_IS_WIDGET (child));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]