Compare commits

...

19 Commits

Author SHA1 Message Date
Timm Bäder
91824fd7d5 Add gtk_widget_snapshot_child 2017-01-06 09:43:52 +01:00
Timm Bäder
bbc56c0511 switch: Unref child widgets 2017-01-06 09:32:15 +01:00
Timm Bäder
29c38015c7 spinbutton: unref child widgets 2017-01-06 09:32:15 +01:00
Timm Bäder
4d626f0140 widget: Warn if children are left in finalize() 2017-01-06 09:32:15 +01:00
Timm Bäder
f97840cd2d gtkmain: Correctly notify all widgets of a grab 2017-01-06 09:32:15 +01:00
Timm Bäder
7c81cda61c widget: Fix :parent property type
Parent widgets can now also be widgets, not just containers.
2017-01-06 09:32:15 +01:00
Timm Bäder
cd80f98536 testsuite: Stop testing style properties 2017-01-06 09:32:14 +01:00
Timm Bäder
6da9981f34 inspector: Don't try to access child props of non-containers 2017-01-06 09:32:14 +01:00
Timm Bäder
79d1fa0b89 widget: Remove gtk_widget_style_get_property 2017-01-06 09:32:14 +01:00
Timm Bäder
606e80c598 spinbutton: Use widgets for up/down buttons 2017-01-06 09:28:43 +01:00
Timm Bäder
a4573e3809 switch: Use GtkLabels for on/off labels 2017-01-06 09:28:43 +01:00
Timm Bäder
8dabddb782 inspector: Show child widgets of widgets 2017-01-06 09:28:43 +01:00
Timm Bäder
60e55590ea widget: Implement create_path for widgets with no-container parent 2017-01-06 09:28:43 +01:00
Timm Bäder
cbaf063ada widget: Unparent widgets in dispose()
If they have a non-container parent.
2017-01-06 09:28:43 +01:00
Timm Bäder
74dfd67971 widget: Check for containerness before calling container API 2017-01-06 09:28:43 +01:00
Timm Bäder
f3cda60e27 widget: Implement map/unmap with child widgets
Once again, do what GtkContainer did before.
2017-01-06 09:28:41 +01:00
Timm Bäder
d7234790ea widget: Implement show_all
Do what gtk_container_forall did: show_all all children, then the widget
itself.
2017-01-06 09:04:41 +01:00
Timm Bäder
b107fded83 widget: Iterate over child widgets instead of gtk_container_forall 2017-01-06 09:04:41 +01:00
Timm Bäder
be2dbd9bbe widget: Add children and sibling pointers
and a (private) way to access them. We will later use these pointers to
manage children of non-container widgets and containers alike.
2017-01-06 09:04:41 +01:00
14 changed files with 585 additions and 775 deletions

View File

@@ -4566,7 +4566,6 @@ gtk_widget_class_find_style_property
gtk_widget_class_list_style_properties
gtk_widget_send_focus_change
gtk_widget_style_get
gtk_widget_style_get_property
gtk_widget_style_get_valist
gtk_widget_class_set_accessible_type
gtk_widget_class_set_accessible_role

View File

@@ -536,7 +536,7 @@ gtk_box_gadget_snapshot (GtkCssGadget *gadget,
GtkBoxGadgetChild *child = &g_array_index (priv->children, GtkBoxGadgetChild, draw_index);
if (GTK_IS_WIDGET (child->object))
gtk_container_snapshot_child (GTK_CONTAINER (owner), GTK_WIDGET (child->object), snapshot);
gtk_widget_snapshot_child (owner, GTK_WIDGET (child->object), snapshot);
else
gtk_css_gadget_snapshot (GTK_CSS_GADGET (child->object), snapshot);
}

View File

@@ -322,13 +322,10 @@ static gboolean gtk_container_focus_move (GtkContainer *container
GtkDirectionType direction);
static void gtk_container_children_callback (GtkWidget *widget,
gpointer client_data);
static void gtk_container_show_all (GtkWidget *widget);
static gint gtk_container_draw (GtkWidget *widget,
cairo_t *cr);
static void gtk_container_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
static void gtk_container_map (GtkWidget *widget);
static void gtk_container_unmap (GtkWidget *widget);
static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget);
static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
@@ -463,11 +460,8 @@ gtk_container_class_init (GtkContainerClass *class)
widget_class->destroy = gtk_container_destroy;
widget_class->compute_expand = gtk_container_compute_expand;
widget_class->show_all = gtk_container_show_all;
widget_class->snapshot = gtk_container_snapshot;
widget_class->draw = gtk_container_draw;
widget_class->map = gtk_container_map;
widget_class->unmap = gtk_container_unmap;
widget_class->focus = gtk_container_focus;
widget_class->get_request_mode = gtk_container_get_request_mode;
@@ -2991,18 +2985,6 @@ gtk_container_get_focus_hadjustment (GtkContainer *container)
return hadjustment;
}
static void
gtk_container_show_all (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_CONTAINER (widget));
gtk_container_foreach (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_show_all,
NULL);
gtk_widget_show (widget);
}
typedef struct {
GtkWidget *child;
int window_depth;
@@ -3101,36 +3083,6 @@ gtk_container_snapshot (GtkWidget *widget,
snapshot);
}
static void
gtk_container_map_child (GtkWidget *child,
gpointer client_data)
{
if (_gtk_widget_get_visible (child) &&
_gtk_widget_get_child_visible (child) &&
!_gtk_widget_get_mapped (child))
gtk_widget_map (child);
}
static void
gtk_container_map (GtkWidget *widget)
{
GTK_WIDGET_CLASS (parent_class)->map (widget);
gtk_container_forall (GTK_CONTAINER (widget),
gtk_container_map_child,
NULL);
}
static void
gtk_container_unmap (GtkWidget *widget)
{
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback)gtk_widget_unmap,
NULL);
}
static gboolean
gtk_container_should_propagate_draw (GtkContainer *container,
GtkWidget *child,

View File

@@ -2073,8 +2073,17 @@ gtk_grab_notify_foreach (GtkWidget *child,
g_object_ref (child);
if ((was_shadowed || is_shadowed) && GTK_IS_CONTAINER (child))
gtk_container_forall (GTK_CONTAINER (child), gtk_grab_notify_foreach, info);
if (was_shadowed || is_shadowed)
{
GtkWidget *p;
for (p = _gtk_widget_get_first_child (child);
p != NULL;
p = _gtk_widget_get_next_sibling (p))
{
gtk_grab_notify_foreach (p, info);
}
}
if (info->device &&
_gtk_widget_get_device_window (child, info->device))

View File

@@ -175,24 +175,18 @@
* ]|
*/
enum {
UP_PANEL,
DOWN_PANEL
};
struct _GtkSpinButtonPrivate
{
GtkAdjustment *adjustment;
GdkWindow *down_panel;
GdkWindow *up_panel;
GtkCssGadget *gadget;
GtkCssGadget *down_button;
GtkCssGadget *up_button;
GdkWindow *click_child;
GdkWindow *in_child;
GtkWidget *up_button;
GtkGesture *up_click_gesture;
GtkWidget *down_button;
GtkGesture *down_click_gesture;
GtkWidget *click_child;
guint32 timer;
@@ -205,7 +199,6 @@ struct _GtkSpinButtonPrivate
GtkGesture *swipe_gesture;
guint button : 2;
guint digits : 10;
guint need_timer : 1;
guint numeric : 1;
@@ -249,10 +242,7 @@ static void gtk_spin_button_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_spin_button_destroy (GtkWidget *widget);
static void gtk_spin_button_map (GtkWidget *widget);
static void gtk_spin_button_unmap (GtkWidget *widget);
static void gtk_spin_button_realize (GtkWidget *widget);
static void gtk_spin_button_unrealize (GtkWidget *widget);
static void gtk_spin_button_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
@@ -264,16 +254,6 @@ static void gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_spin_button_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
static gint gtk_spin_button_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_spin_button_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_spin_button_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_spin_button_enter_notify (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_spin_button_leave_notify (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_spin_button_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_spin_button_grab_notify (GtkWidget *widget,
@@ -286,6 +266,9 @@ static void gtk_spin_button_value_changed (GtkAdjustment *adjustment,
GtkSpinButton *spin_button);
static gint gtk_spin_button_key_release (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_spin_button_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_spin_button_direction_changed (GtkWidget *widget,
@@ -308,7 +291,7 @@ static void gtk_spin_button_real_change_value (GtkSpinButton *spin,
static gint gtk_spin_button_default_input (GtkSpinButton *spin_button,
gdouble *new_val);
static void gtk_spin_button_default_output (GtkSpinButton *spin_button);
static void update_node_state (GtkSpinButton *spin_button);
static guint spinbutton_signals[LAST_SIGNAL] = {0};
@@ -336,20 +319,13 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
gobject_class->get_property = gtk_spin_button_get_property;
widget_class->destroy = gtk_spin_button_destroy;
widget_class->map = gtk_spin_button_map;
widget_class->unmap = gtk_spin_button_unmap;
widget_class->realize = gtk_spin_button_realize;
widget_class->unrealize = gtk_spin_button_unrealize;
widget_class->measure = gtk_spin_button_measure;
widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->snapshot = gtk_spin_button_snapshot;
widget_class->scroll_event = gtk_spin_button_scroll;
widget_class->button_press_event = gtk_spin_button_button_press;
widget_class->button_release_event = gtk_spin_button_button_release;
widget_class->motion_notify_event = gtk_spin_button_motion_notify;
widget_class->key_release_event = gtk_spin_button_key_release;
widget_class->enter_notify_event = gtk_spin_button_enter_notify;
widget_class->leave_notify_event = gtk_spin_button_leave_notify;
widget_class->focus_out_event = gtk_spin_button_focus_out;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
@@ -676,16 +652,6 @@ swipe_gesture_begin (GtkGesture *gesture,
GdkEventSequence *sequence,
GtkSpinButton *spin_button)
{
GdkEventSequence *current;
const GdkEvent *event;
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (gesture, current);
if (event->any.window == spin_button->priv->up_panel ||
event->any.window == spin_button->priv->down_panel)
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
gtk_widget_grab_focus (GTK_WIDGET (spin_button));
}
@@ -727,14 +693,117 @@ update_node_ordering (GtkSpinButton *spin_button)
}
gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), priv->orientation);
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), priv->up_button);
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), priv->down_button);
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
up_button_pos, priv->up_button,
FALSE, GTK_ALIGN_FILL);
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
down_button_pos, priv->down_button,
FALSE, GTK_ALIGN_FILL);
gtk_box_gadget_remove_widget (GTK_BOX_GADGET (priv->gadget), priv->up_button);
gtk_box_gadget_remove_widget (GTK_BOX_GADGET (priv->gadget), priv->down_button);
gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget),
up_button_pos, priv->up_button);
gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget),
down_button_pos, priv->down_button);
}
static gboolean
gtk_spin_button_stop_spinning (GtkSpinButton *spin)
{
GtkSpinButtonPrivate *priv = spin->priv;
gboolean did_spin = FALSE;
if (priv->timer)
{
g_source_remove (priv->timer);
priv->timer = 0;
priv->need_timer = FALSE;
did_spin = TRUE;
}
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
priv->timer_calls = 0;
priv->click_child = NULL;
return did_spin;
}
static void
start_spinning (GtkSpinButton *spin,
GtkWidget *click_child,
gdouble step)
{
GtkSpinButtonPrivate *priv = spin->priv;
priv->click_child = click_child;
if (!priv->timer)
{
priv->timer_step = step;
priv->need_timer = TRUE;
priv->timer = gdk_threads_add_timeout (TIMEOUT_INITIAL,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin);
g_source_set_name_by_id (priv->timer, "[gtk+] gtk_spin_button_timer");
}
gtk_spin_button_real_spin (spin, click_child == priv->up_button ? step : -step);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
static void
button_pressed_cb (GtkGestureMultiPress *gesture,
int n_pressses,
double x,
double y,
gpointer user_data)
{
GtkSpinButton *spin_button = user_data;
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkWidget *pressed_button = GTK_GESTURE (gesture) == priv->up_click_gesture ?
priv->up_button : priv->down_button;
if (gtk_editable_get_editable (GTK_EDITABLE (spin_button)))
{
int button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
gtk_spin_button_update (spin_button);
if (button == GDK_BUTTON_PRIMARY)
start_spinning (spin_button, pressed_button, gtk_adjustment_get_step_increment (priv->adjustment));
else if (button == GDK_BUTTON_MIDDLE)
start_spinning (spin_button, pressed_button, gtk_adjustment_get_page_increment (priv->adjustment));
}
else
{
gtk_widget_error_bell (GTK_WIDGET (spin_button));
}
}
static void
button_released_cb (GtkGestureMultiPress *gesture,
int n_pressses,
double x,
double y,
gpointer user_data)
{
GtkSpinButton *spin_button = user_data;
GtkSpinButtonPrivate *priv = spin_button->priv;
int button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
gtk_spin_button_stop_spinning (spin_button);
if (button == GDK_BUTTON_SECONDARY)
{
double diff;
if (GTK_GESTURE (gesture) == priv->down_click_gesture)
{
diff = gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment);
if (diff > EPSILON)
gtk_spin_button_real_spin (spin_button, -diff);
}
else if (GTK_GESTURE (gesture) == priv->up_click_gesture)
{
diff = gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_value (priv->adjustment);
if (diff > EPSILON)
gtk_spin_button_real_spin (spin_button, diff);
}
}
}
static void
@@ -747,15 +816,11 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
priv = spin_button->priv;
priv->adjustment = NULL;
priv->down_panel = NULL;
priv->up_panel = NULL;
priv->timer = 0;
priv->climb_rate = 0.0;
priv->timer_step = 0.0;
priv->update_policy = GTK_UPDATE_ALWAYS;
priv->in_child = NULL;
priv->click_child = NULL;
priv->button = 0;
priv->need_timer = FALSE;
priv->timer_calls = 0;
priv->digits = 0;
@@ -766,6 +831,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin_button));
gtk_widget_set_focus_on_click (GTK_WIDGET (spin_button), TRUE);
widget_node = gtk_widget_get_css_node (GTK_WIDGET (spin_button));
@@ -781,32 +847,35 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
-1, gtk_entry_get_gadget (GTK_ENTRY (spin_button)),
TRUE, GTK_ALIGN_FILL);
priv->down_button = gtk_icon_helper_new_named ("button",
GTK_WIDGET (spin_button));
_gtk_icon_helper_set_use_fallback (GTK_ICON_HELPER (priv->down_button), TRUE);
_gtk_icon_helper_set_icon_name (GTK_ICON_HELPER (priv->down_button), "list-remove-symbolic", GTK_ICON_SIZE_MENU);
gtk_css_gadget_add_class (priv->down_button, "down");
gtk_css_node_set_parent (gtk_css_gadget_get_node (priv->down_button), widget_node);
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->down_button), gtk_css_node_get_state (widget_node));
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
-1, priv->down_button,
FALSE, GTK_ALIGN_FILL);
priv->down_button = gtk_button_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_BUTTON);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->down_button), "down");
gtk_widget_set_parent (priv->down_button, GTK_WIDGET (spin_button));
gtk_widget_show (priv->down_button);
gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget),
-1, priv->down_button);
priv->down_click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (priv->down_button));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->down_click_gesture), FALSE);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->down_click_gesture),
GTK_PHASE_CAPTURE);
g_signal_connect (priv->down_click_gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button);
g_signal_connect (priv->down_click_gesture, "released", G_CALLBACK (button_released_cb), spin_button);
priv->up_button = gtk_icon_helper_new_named ("button",
GTK_WIDGET (spin_button));
_gtk_icon_helper_set_use_fallback (GTK_ICON_HELPER (priv->up_button), TRUE);
_gtk_icon_helper_set_icon_name (GTK_ICON_HELPER (priv->up_button), "list-add-symbolic", GTK_ICON_SIZE_MENU);
gtk_css_gadget_add_class (priv->up_button, "up");
gtk_css_node_set_parent (gtk_css_gadget_get_node (priv->up_button), widget_node);
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->up_button), gtk_css_node_get_state (widget_node));
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
-1, priv->up_button,
FALSE, GTK_ALIGN_FILL);
priv->up_button = gtk_button_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->up_button), "up");
gtk_widget_set_parent (priv->up_button, GTK_WIDGET (spin_button));
gtk_widget_show (priv->up_button);
gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget),
-1, priv->up_button);
priv->up_click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (priv->up_button));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->up_click_gesture), FALSE);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->up_click_gesture),
GTK_PHASE_CAPTURE);
g_signal_connect (priv->up_click_gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button);
g_signal_connect (priv->up_click_gesture, "released", G_CALLBACK (button_released_cb), spin_button);
gtk_spin_button_set_adjustment (spin_button, NULL);
update_node_ordering (spin_button);
update_node_state (spin_button);
gtk_widget_add_events (GTK_WIDGET (spin_button), GDK_SCROLL_MASK);
@@ -828,10 +897,12 @@ gtk_spin_button_finalize (GObject *object)
gtk_spin_button_unset_adjustment (spin_button);
g_clear_object (&priv->gadget);
g_clear_object (&priv->down_button);
g_clear_object (&priv->up_button);
g_object_unref (priv->swipe_gesture);
g_object_unref (priv->up_click_gesture);
g_object_unref (priv->down_click_gesture);
g_object_unref (priv->up_button);
g_object_unref (priv->down_button);
G_OBJECT_CLASS (gtk_spin_button_parent_class)->finalize (object);
}
@@ -844,135 +915,16 @@ gtk_spin_button_destroy (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->destroy (widget);
}
static void
gtk_spin_button_map (GtkWidget *widget)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
if (gtk_widget_get_realized (widget) && !gtk_widget_get_mapped (widget))
{
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->map (widget);
gdk_window_show (priv->down_panel);
gdk_window_show (priv->up_panel);
}
}
static void
gtk_spin_button_unmap (GtkWidget *widget)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
if (gtk_widget_get_mapped (widget))
{
gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (widget));
gdk_window_hide (priv->down_panel);
gdk_window_hide (priv->up_panel);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->unmap (widget);
}
}
static gboolean
gtk_spin_button_panel_at_limit (GtkSpinButton *spin_button,
gint panel)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
if (priv->wrap)
return FALSE;
if (panel == UP_PANEL &&
(gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_value (priv->adjustment) <= EPSILON))
return TRUE;
if (panel == DOWN_PANEL &&
(gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) <= EPSILON))
return TRUE;
return FALSE;
}
static GtkStateFlags
gtk_spin_button_panel_get_state (GtkSpinButton *spin_button,
gint panel)
{
GtkStateFlags state;
GtkSpinButtonPrivate *priv = spin_button->priv;
state = gtk_widget_get_state_flags (GTK_WIDGET (spin_button));
state &= ~(GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_DROP_ACTIVE);
if ((state & GTK_STATE_FLAG_INSENSITIVE) ||
gtk_spin_button_panel_at_limit (spin_button, panel) ||
!gtk_editable_get_editable (GTK_EDITABLE (spin_button)))
{
state |= GTK_STATE_FLAG_INSENSITIVE;
}
else
{
GdkWindow *panel_win;
panel_win = panel == UP_PANEL ? priv->up_panel : priv->down_panel;
if (priv->click_child &&
priv->click_child == panel_win)
state |= GTK_STATE_FLAG_ACTIVE;
else if (priv->in_child &&
priv->in_child == panel_win &&
priv->click_child == NULL)
state |= GTK_STATE_FLAG_PRELIGHT;
}
return state;
}
static void
update_node_state (GtkSpinButton *spin_button)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
gtk_css_gadget_set_state (priv->up_button, gtk_spin_button_panel_get_state (spin_button, UP_PANEL));
gtk_css_gadget_set_state (priv->down_button, gtk_spin_button_panel_get_state (spin_button, DOWN_PANEL));
}
static void
gtk_spin_button_realize (GtkWidget *widget)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkAllocation down_allocation, up_allocation;
gboolean return_val;
gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
GDK_KEY_RELEASE_MASK);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->realize (widget);
gtk_css_gadget_get_border_allocation (priv->up_button, &up_allocation, NULL);
gtk_css_gadget_get_border_allocation (priv->down_button, &down_allocation, NULL);
priv->down_panel = gdk_window_new_input (gtk_widget_get_window (widget),
gtk_widget_get_events (widget)
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_POINTER_MOTION_MASK,
&down_allocation);
gtk_widget_register_window (widget, priv->down_panel);
priv->up_panel = gdk_window_new_input (gtk_widget_get_window (widget),
gtk_widget_get_events (widget)
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_POINTER_MOTION_MASK,
&up_allocation);
gtk_widget_register_window (widget, priv->up_panel);
return_val = FALSE;
g_signal_emit (spin_button, spinbutton_signals[OUTPUT], 0, &return_val);
@@ -986,29 +938,6 @@ gtk_spin_button_realize (GtkWidget *widget)
gtk_widget_queue_resize (GTK_WIDGET (spin_button));
}
static void
gtk_spin_button_unrealize (GtkWidget *widget)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->unrealize (widget);
if (priv->down_panel)
{
gtk_widget_unregister_window (widget, priv->down_panel);
gdk_window_destroy (priv->down_panel);
priv->down_panel = NULL;
}
if (priv->up_panel)
{
gtk_widget_unregister_window (widget, priv->up_panel);
gdk_window_destroy (priv->up_panel);
priv->up_panel = NULL;
}
}
/* Callback used when the spin button's adjustment changes.
* We need to redraw the arrows when the adjustments range
* changes, and reevaluate our size request.
@@ -1020,7 +949,6 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data)
GtkSpinButtonPrivate *priv = spin_button->priv;
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
update_node_state (spin_button);
gtk_widget_queue_resize (GTK_WIDGET (spin_button));
}
@@ -1167,21 +1095,6 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
&clip);
gtk_widget_set_clip (widget, &clip);
if (gtk_widget_get_realized (widget))
{
GtkAllocation button_alloc;
gtk_css_gadget_get_border_allocation (priv->down_button, &button_alloc, NULL);
gdk_window_move_resize (priv->down_panel,
button_alloc.x, button_alloc.y,
button_alloc.width, button_alloc.height);
gtk_css_gadget_get_border_allocation (priv->up_button, &button_alloc, NULL);
gdk_window_move_resize (priv->up_panel,
button_alloc.x, button_alloc.y,
button_alloc.width, button_alloc.height);
}
}
static void
@@ -1191,41 +1104,6 @@ gtk_spin_button_snapshot (GtkWidget *widget,
gtk_css_gadget_snapshot (GTK_SPIN_BUTTON(widget)->priv->gadget, snapshot);
}
static gint
gtk_spin_button_enter_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (event->window == priv->down_panel ||
event->window == priv->up_panel)
{
priv->in_child = event->window;
update_node_state (spin);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->enter_notify_event (widget, event);
}
static gint
gtk_spin_button_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (priv->in_child != NULL)
{
priv->in_child = NULL;
update_node_state (spin);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->leave_notify_event (widget, event);
}
static gint
gtk_spin_button_focus_out (GtkWidget *widget,
GdkEventFocus *event)
@@ -1262,7 +1140,6 @@ gtk_spin_button_state_flags_changed (GtkWidget *widget,
}
gtk_css_gadget_set_state (gtk_entry_get_gadget (GTK_ENTRY (widget)), gtk_widget_get_state_flags (widget));
update_node_state (spin);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->state_flags_changed (widget, previous_state);
}
@@ -1292,137 +1169,6 @@ gtk_spin_button_scroll (GtkWidget *widget,
return TRUE;
}
static gboolean
gtk_spin_button_stop_spinning (GtkSpinButton *spin)
{
GtkSpinButtonPrivate *priv = spin->priv;
gboolean did_spin = FALSE;
if (priv->timer)
{
g_source_remove (priv->timer);
priv->timer = 0;
priv->need_timer = FALSE;
did_spin = TRUE;
}
priv->button = 0;
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
priv->timer_calls = 0;
priv->click_child = NULL;
return did_spin;
}
static void
start_spinning (GtkSpinButton *spin,
GdkWindow *click_child,
gdouble step)
{
GtkSpinButtonPrivate *priv;
priv = spin->priv;
priv->click_child = click_child;
if (!priv->timer)
{
priv->timer_step = step;
priv->need_timer = TRUE;
priv->timer = gdk_threads_add_timeout (TIMEOUT_INITIAL,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin);
g_source_set_name_by_id (priv->timer, "[gtk+] gtk_spin_button_timer");
}
gtk_spin_button_real_spin (spin, click_child == priv->up_panel ? step : -step);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
static gint
gtk_spin_button_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (!priv->button)
{
if ((event->window == priv->down_panel) ||
(event->window == priv->up_panel))
{
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
priv->button = event->button;
if (gtk_editable_get_editable (GTK_EDITABLE (widget))) {
gtk_spin_button_update (spin);
if (event->button == GDK_BUTTON_PRIMARY)
start_spinning (spin, event->window, gtk_adjustment_get_step_increment (priv->adjustment));
else if (event->button == GDK_BUTTON_MIDDLE)
start_spinning (spin, event->window, gtk_adjustment_get_page_increment (priv->adjustment));
else
priv->click_child = event->window;
} else
gtk_widget_error_bell (widget);
return TRUE;
}
else
{
return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->button_press_event (widget, event);
}
}
return FALSE;
}
static gint
gtk_spin_button_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (event->button == priv->button)
{
GdkWindow *click_child = priv->click_child;
gtk_spin_button_stop_spinning (spin);
if (event->button == GDK_BUTTON_SECONDARY)
{
gdouble diff;
if (event->window == priv->down_panel &&
click_child == event->window)
{
diff = gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment);
if (diff > EPSILON)
gtk_spin_button_real_spin (spin, -diff);
}
else if (event->window == priv->up_panel &&
click_child == event->window)
{
diff = gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_value (priv->adjustment);
if (diff > EPSILON)
gtk_spin_button_real_spin (spin, diff);
}
}
update_node_state (spin);
gtk_widget_queue_draw (GTK_WIDGET (spin));
return TRUE;
}
else
{
return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->button_release_event (widget, event);
}
}
static gint
gtk_spin_button_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
@@ -1430,20 +1176,6 @@ gtk_spin_button_motion_notify (GtkWidget *widget,
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (priv->button)
return FALSE;
if (event->window == priv->down_panel ||
event->window == priv->up_panel)
{
gdk_event_request_motions (event);
priv->in_child = event->window;
gtk_widget_queue_draw (widget);
return FALSE;
}
if (gtk_gesture_is_recognized (priv->swipe_gesture))
return TRUE;
@@ -1458,7 +1190,7 @@ gtk_spin_button_timer (GtkSpinButton *spin_button)
if (priv->timer)
{
if (priv->click_child == priv->up_panel)
if (priv->click_child == priv->up_button)
gtk_spin_button_real_spin (spin_button, priv->timer_step);
else
gtk_spin_button_real_spin (spin_button, -priv->timer_step);
@@ -1506,8 +1238,6 @@ gtk_spin_button_value_changed (GtkAdjustment *adjustment,
g_signal_emit (spin_button, spinbutton_signals[VALUE_CHANGED], 0);
update_node_state (spin_button);
gtk_widget_queue_draw (GTK_WIDGET (spin_button));
g_object_notify (G_OBJECT (spin_button), "value");

View File

@@ -67,6 +67,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtksettingsprivate.h"
#include "gtkcontainerprivate.h"
#include "fallback-c89.c"
@@ -80,8 +81,6 @@ struct _GtkSwitchPrivate
GtkCssGadget *gadget;
GtkCssGadget *slider_gadget;
PangoLayout *off_layout;
PangoLayout *on_layout;
double handle_pos;
guint tick_id;
@@ -90,6 +89,9 @@ struct _GtkSwitchPrivate
guint state : 1;
guint is_active : 1;
guint in_switch : 1;
GtkWidget *on_label;
GtkWidget *off_label;
};
enum
@@ -279,51 +281,6 @@ gtk_switch_pan_gesture_drag_end (GtkGestureDrag *gesture,
gtk_widget_queue_allocate (GTK_WIDGET (sw));
}
static void
gtk_switch_create_pango_layouts (GtkSwitch *self)
{
GtkSwitchPrivate *priv = self->priv;
g_clear_object (&priv->on_layout);
/* Translators: if the "on" state label requires more than three
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
* the state
*/
priv->on_layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), C_("switch", "ON"));
g_clear_object (&priv->off_layout);
/* Translators: if the "off" state label requires more than three
* glyphs then use WHITE CIRCLE (U+25CB) as the text for the state
*/
priv->off_layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), C_("switch", "OFF"));
}
static void
gtk_switch_screen_changed (GtkWidget *widget,
GdkScreen *prev_screen)
{
gtk_switch_create_pango_layouts (GTK_SWITCH (widget));
}
static void
gtk_switch_style_updated (GtkWidget *widget)
{
GtkSwitch *self = GTK_SWITCH (widget);
GtkStyleContext *context;
GtkCssStyleChange *change;
GTK_WIDGET_CLASS (gtk_switch_parent_class)->style_updated (widget);
context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (context);
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
gtk_switch_create_pango_layouts (self);
}
static gboolean
gtk_switch_enter (GtkWidget *widget,
GdkEventCrossing *event)
@@ -374,7 +331,7 @@ gtk_switch_get_content_size (GtkCssGadget *gadget,
GtkSwitch *self;
GtkSwitchPrivate *priv;
gint slider_minimum, slider_natural;
PangoRectangle on_rect, off_rect;
int on_nat, off_nat;
widget = gtk_css_gadget_get_owner (gadget);
self = GTK_SWITCH (widget);
@@ -386,18 +343,18 @@ gtk_switch_get_content_size (GtkCssGadget *gadget,
&slider_minimum, &slider_natural,
NULL, NULL);
pango_layout_get_pixel_extents (priv->on_layout, NULL, &on_rect);
pango_layout_get_pixel_extents (priv->off_layout, NULL, &off_rect);
gtk_widget_measure (priv->on_label, orientation, for_size, NULL, &on_nat, NULL, NULL);
gtk_widget_measure (priv->off_label, orientation, for_size, NULL, &off_nat, NULL, NULL);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
int text_width = MAX (on_rect.width, off_rect.width);
int text_width = MAX (on_nat, off_nat);
*minimum = 2 * MAX (slider_minimum, text_width);
*natural = 2 * MAX (slider_natural, text_width);
}
else
{
int text_height = MAX (on_rect.height, off_rect.height);
int text_height = MAX (on_nat, off_nat);
*minimum = MAX (slider_minimum, text_height);
*natural = MAX (slider_natural, text_height);
}
@@ -428,8 +385,10 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
{
GtkSwitch *self = GTK_SWITCH (gtk_css_gadget_get_owner (gadget));
GtkSwitchPrivate *priv = self->priv;
GtkAllocation child_alloc;
GtkAllocation slider_alloc;
int min;
slider_alloc.x = allocation->x + round (priv->handle_pos * (allocation->width - allocation->width / 2));
slider_alloc.y = allocation->y;
slider_alloc.width = allocation->width / 2;
@@ -440,6 +399,26 @@ gtk_switch_allocate_contents (GtkCssGadget *gadget,
baseline,
out_clip);
/* Center ON label in left half */
gtk_widget_measure (priv->on_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
child_alloc.x = allocation->x + ((allocation->width / 2) - min) / 2;
child_alloc.width = min;
gtk_widget_measure (priv->on_label, GTK_ORIENTATION_VERTICAL, min, &min, NULL, NULL, NULL);
child_alloc.y = allocation->y + (allocation->height - min) / 2;
child_alloc.height = min;
gtk_widget_size_allocate (priv->on_label, &child_alloc);
/* Center OFF label in right half */
gtk_widget_measure (priv->off_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL);
child_alloc.x = allocation->x + (allocation->width / 2) + ((allocation->width / 2) - min) / 2;
child_alloc.width = min;
gtk_widget_measure (priv->off_label, GTK_ORIENTATION_VERTICAL, min, &min, NULL, NULL, NULL);
child_alloc.y = allocation->y + (allocation->height - min) / 2;
child_alloc.height = min;
gtk_widget_size_allocate (priv->off_label, &child_alloc);
if (gtk_widget_get_realized (GTK_WIDGET (self)))
{
GtkAllocation border_allocation;
@@ -475,7 +454,8 @@ gtk_switch_realize (GtkWidget *widget)
GdkWindow *parent_window;
GtkAllocation allocation;
gtk_widget_set_realized (widget, TRUE);
GTK_WIDGET_CLASS (gtk_switch_parent_class)->realize (widget);
parent_window = gtk_widget_get_parent_window (widget);
gtk_widget_set_window (widget, parent_window);
g_object_ref (parent_window);
@@ -554,23 +534,9 @@ gtk_switch_snapshot_trough (GtkCssGadget *gadget,
{
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
GtkStyleContext *context = gtk_widget_get_style_context (widget);
PangoRectangle rect;
gint label_x, label_y;
pango_layout_get_pixel_extents (priv->on_layout, NULL, &rect);
label_x = x + ((width / 2) - rect.width) / 2;
label_y = y + (height - rect.height) / 2;
gtk_snapshot_render_layout (snapshot, context, label_x, label_y, priv->on_layout);
pango_layout_get_pixel_extents (priv->off_layout, NULL, &rect);
label_x = x + (width / 2) + ((width / 2) - rect.width) / 2;
label_y = y + (height - rect.height) / 2;
gtk_snapshot_render_layout (snapshot, context, label_x, label_y, priv->off_layout);
gtk_widget_snapshot_child (widget, priv->on_label, snapshot);
gtk_widget_snapshot_child (widget, priv->off_label, snapshot);
gtk_css_gadget_snapshot (priv->slider_gadget, snapshot);
@@ -707,16 +673,16 @@ gtk_switch_dispose (GObject *object)
g_clear_object (&priv->pan_gesture);
g_clear_object (&priv->multipress_gesture);
g_clear_object (&priv->on_layout);
g_clear_object (&priv->off_layout);
G_OBJECT_CLASS (gtk_switch_parent_class)->dispose (object);
}
static void
gtk_switch_finalize (GObject *object)
{
GtkSwitchPrivate *priv = GTK_SWITCH (object)->priv;
gtk_switch_end_toggle_animation (GTK_SWITCH (object));
g_object_unref (priv->on_label);
g_object_unref (priv->off_label);
G_OBJECT_CLASS (gtk_switch_parent_class)->finalize (object);
}
@@ -781,8 +747,6 @@ gtk_switch_class_init (GtkSwitchClass *klass)
widget_class->snapshot = gtk_switch_snapshot;
widget_class->enter_notify_event = gtk_switch_enter;
widget_class->leave_notify_event = gtk_switch_leave;
widget_class->screen_changed = gtk_switch_screen_changed;
widget_class->style_updated = gtk_switch_style_updated;
klass->activate = gtk_switch_activate;
klass->state_set = state_set;
@@ -902,7 +866,20 @@ gtk_switch_init (GtkSwitch *self)
GTK_PHASE_BUBBLE);
priv->pan_gesture = gesture;
gtk_switch_create_pango_layouts (self);
/* Translators: if the "on" state label requires more than three
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
* the state
*/
priv->on_label = gtk_label_new (C_("switch", "ON"));
gtk_widget_set_parent (priv->on_label, GTK_WIDGET (self));
gtk_widget_show (priv->on_label);
/* Translators: if the "off" state label requires more than three
* glyphs then use WHITE CIRCLE (U+25CB) as the text for the state
*/
priv->off_label = gtk_label_new (C_("switch", "OFF"));
gtk_widget_set_parent (priv->off_label, GTK_WIDGET (self));
gtk_widget_show (priv->off_label);
}
/**

View File

@@ -944,6 +944,22 @@ gtk_widget_real_snapshot (GtkWidget *widget,
/* nothing to do here */
}
static void
gtk_widget_real_show_all (GtkWidget *widget)
{
GtkWidget *p;
for (p = gtk_widget_get_first_child (widget);
p != NULL;
p = gtk_widget_get_next_sibling (p))
{
if (!GTK_IS_POPOVER (p))
gtk_widget_show_all (p);
}
gtk_widget_show (widget);
}
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
@@ -992,7 +1008,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->activate_signal = 0;
klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
klass->show = gtk_widget_real_show;
klass->show_all = gtk_widget_show;
klass->show_all = gtk_widget_real_show_all;
klass->hide = gtk_widget_real_hide;
klass->map = gtk_widget_real_map;
klass->unmap = gtk_widget_real_unmap;
@@ -1069,8 +1085,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_props[PROP_PARENT] =
g_param_spec_object ("parent",
P_("Parent widget"),
P_("The parent widget of this widget. Must be a Container widget"),
GTK_TYPE_CONTAINER,
P_("The parent widget of this widget."),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE);
widget_props[PROP_WIDTH_REQUEST] =
@@ -3784,6 +3800,10 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->alpha = 255;
priv->window = NULL;
priv->parent = NULL;
priv->first_child = NULL;
priv->last_child = NULL;
priv->prev_sibling = NULL;
priv->next_sibling = NULL;
priv->sensitive = TRUE;
priv->redraw_on_alloc = TRUE;
@@ -3991,8 +4011,11 @@ gtk_widget_unparent (GtkWidget *widget)
if (_gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
if (gtk_container_get_focus_child (GTK_CONTAINER (priv->parent)) == widget)
gtk_container_set_focus_child (GTK_CONTAINER (priv->parent), NULL);
if (GTK_IS_CONTAINER (priv->parent))
{
if (gtk_container_get_focus_child (GTK_CONTAINER (priv->parent)) == widget)
gtk_container_set_focus_child (GTK_CONTAINER (priv->parent), NULL);
}
if (_gtk_widget_is_drawable (priv->parent))
gtk_widget_queue_draw_area (priv->parent,
@@ -4027,7 +4050,22 @@ gtk_widget_unparent (GtkWidget *widget)
priv->child_visible = TRUE;
old_parent = priv->parent;
if (old_parent)
{
if (old_parent->priv->first_child == widget)
old_parent->priv->first_child = priv->next_sibling;
if (old_parent->priv->last_child == widget)
old_parent->priv->last_child = priv->prev_sibling;
if (priv->prev_sibling)
priv->prev_sibling->priv->next_sibling = priv->next_sibling;
if (priv->next_sibling)
priv->next_sibling->priv->prev_sibling = priv->prev_sibling;
}
priv->parent = NULL;
priv->prev_sibling = NULL;
priv->next_sibling = NULL;
/* parent may no longer expand if the removed
* child was expand=TRUE and could therefore
@@ -4450,14 +4488,6 @@ typedef struct {
gboolean enabled;
} DeviceEnableData;
static void
device_enable_foreach (GtkWidget *widget,
gpointer user_data)
{
DeviceEnableData *data = user_data;
gtk_widget_set_device_enabled_internal (widget, data->device, TRUE, data->enabled);
}
static void
device_enable_foreach_window (gpointer win,
gpointer user_data)
@@ -4510,8 +4540,19 @@ gtk_widget_set_device_enabled_internal (GtkWidget *widget,
g_list_foreach (window_list, device_enable_foreach_window, &data);
}
if (recurse && GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), device_enable_foreach, &data);
if (recurse)
{
GtkWidget *child;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
gtk_widget_set_device_enabled_internal (child,
device,
TRUE,
enabled);
}
}
}
static void
@@ -8395,6 +8436,15 @@ gtk_widget_set_parent (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget);
priv->parent = parent;
if (parent)
{
priv->prev_sibling = parent->priv->last_child;
if (parent->priv->last_child)
parent->priv->last_child->priv->next_sibling = widget;
parent->priv->last_child = widget;
if (!parent->priv->first_child)
parent->priv->first_child = widget;
}
parent_flags = _gtk_widget_get_state_flags (parent);
@@ -8457,9 +8507,9 @@ gtk_widget_set_parent (GtkWidget *widget,
* gtk_widget_get_parent:
* @widget: a #GtkWidget
*
* Returns the parent container of @widget.
* Returns the parent widget of @widget.
*
* Returns: (transfer none) (nullable): the parent container of @widget, or %NULL
* Returns: (transfer none) (nullable): the parent widget of @widget, or %NULL
**/
GtkWidget *
gtk_widget_get_parent (GtkWidget *widget)
@@ -8536,10 +8586,7 @@ gtk_widget_propagate_hierarchy_changed_recurse (GtkWidget *widget,
g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel);
do_screen_change (widget, info->previous_screen, info->new_screen);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_propagate_hierarchy_changed_recurse,
client_data);
gtk_widget_forall (widget, gtk_widget_propagate_hierarchy_changed_recurse, client_data);
g_object_unref (widget);
}
@@ -8588,15 +8635,18 @@ gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
gpointer client_data)
{
HierarchyChangedInfo *info = client_data;
GtkWidget *child;
g_object_ref (widget);
do_screen_change (widget, info->previous_screen, info->new_screen);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_propagate_screen_changed_recurse,
client_data);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
gtk_widget_propagate_screen_changed_recurse (child, client_data);
}
g_object_unref (widget);
}
@@ -8628,14 +8678,11 @@ _gtk_widget_propagate_screen_changed (GtkWidget *widget,
}
static void
reset_style_recurse (GtkWidget *widget, gpointer data)
reset_style_recurse (GtkWidget *widget, gpointer user_data)
{
gtk_css_node_invalidate (widget->priv->cssnode, GTK_CSS_CHANGE_ANY);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
reset_style_recurse,
NULL);
gtk_widget_forall (widget, reset_style_recurse, user_data);
}
/**
@@ -8806,8 +8853,7 @@ gtk_widget_push_verify_invariants (GtkWidget *widget)
}
static void
gtk_widget_verify_child_invariants (GtkWidget *widget,
gpointer client_data)
gtk_widget_verify_child_invariants (GtkWidget *widget)
{
/* We don't recurse further; this is a one-level check. */
gtk_widget_verify_invariants (widget);
@@ -8822,21 +8868,22 @@ gtk_widget_pop_verify_invariants (GtkWidget *widget)
if (widget->priv->verifying_invariants_count == 0)
{
GtkWidget *child;
gtk_widget_verify_invariants (widget);
if (GTK_IS_CONTAINER (widget))
/* Check one level of children, because our
* push_verify_invariants() will have prevented some of the
* checks. This does not recurse because if recursion is
* needed, it will happen naturally as each child has a
* push/pop on that child. For example if we're recursively
* mapping children, we'll push/pop on each child as we map
* it.
*/
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
/* Check one level of children, because our
* push_verify_invariants() will have prevented some of the
* checks. This does not recurse because if recursion is
* needed, it will happen naturally as each child has a
* push/pop on that child. For example if we're recursively
* mapping children, we'll push/pop on each child as we map
* it.
*/
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_verify_child_invariants,
NULL);
gtk_widget_verify_child_invariants (child);
}
}
}
@@ -9004,17 +9051,14 @@ gtk_widget_get_font_options (GtkWidget *widget)
}
static void
gtk_widget_set_font_map_recurse (GtkWidget *widget, gpointer data)
gtk_widget_set_font_map_recurse (GtkWidget *widget, gpointer user_data)
{
if (g_object_get_qdata (G_OBJECT (widget), quark_font_map))
return;
gtk_widget_update_pango_context (widget);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_set_font_map_recurse,
data);
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, user_data);
}
/**
@@ -9046,10 +9090,8 @@ gtk_widget_set_font_map (GtkWidget *widget,
g_object_unref);
gtk_widget_update_pango_context (widget);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_set_font_map_recurse,
NULL);
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, NULL);
}
/**
@@ -9371,10 +9413,7 @@ _gtk_widget_scale_changed (GtkWidget *widget)
gtk_widget_queue_draw (widget);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) _gtk_widget_scale_changed,
NULL);
gtk_widget_forall (widget, (GtkCallback)_gtk_widget_scale_changed, NULL);
}
/**
@@ -10247,16 +10286,19 @@ static void
gtk_widget_set_default_direction_recurse (GtkWidget *widget, gpointer data)
{
GtkTextDirection old_dir = GPOINTER_TO_UINT (data);
GtkWidget *child;
g_object_ref (widget);
if (widget->priv->direction == GTK_TEXT_DIR_NONE)
gtk_widget_emit_direction_changed (widget, old_dir);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_set_default_direction_recurse,
data);
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
gtk_widget_set_default_direction_recurse (child, data);
}
g_object_unref (widget);
}
@@ -10340,8 +10382,10 @@ gtk_widget_dispose (GObject *object)
GtkWidgetPrivate *priv = widget->priv;
GSList *sizegroups;
if (priv->parent)
if (priv->parent && GTK_IS_CONTAINER (priv->parent))
gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
else if (priv->parent)
gtk_widget_unparent (widget);
else if (_gtk_widget_get_visible (widget))
gtk_widget_hide (widget);
@@ -10571,6 +10615,19 @@ gtk_widget_finalize (GObject *object)
g_list_free_full (priv->event_controllers, g_free);
priv->event_controllers = NULL;
if (_gtk_widget_get_first_child (widget) != NULL)
{
GtkWidget *child;
g_warning ("Finalizing %s %p, but it still has children left:",
gtk_widget_get_name (widget), widget);
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
g_warning (" - %s %p", gtk_widget_get_name (child), child);
}
}
if (g_object_is_floating (object))
g_warning ("A floating object was finalized. This means that someone\n"
"called g_object_unref() on an object that had only a floating\n"
@@ -10597,10 +10654,21 @@ gtk_widget_real_map (GtkWidget *widget)
if (!_gtk_widget_get_mapped (widget))
{
GtkWidget *p;
priv->mapped = TRUE;
if (_gtk_widget_get_has_window (widget))
gdk_window_show (priv->window);
gdk_window_show (priv->window);
for (p = gtk_widget_get_first_child (widget);
p != NULL;
p = gtk_widget_get_next_sibling (p))
{
if (_gtk_widget_get_visible (p) &&
_gtk_widget_get_child_visible (p) &&
!_gtk_widget_get_mapped (p))
gtk_widget_map (p);
}
}
}
@@ -10619,10 +10687,18 @@ gtk_widget_real_unmap (GtkWidget *widget)
if (_gtk_widget_get_mapped (widget))
{
GtkWidget *child;
priv->mapped = FALSE;
if (_gtk_widget_get_has_window (widget))
gdk_window_hide (priv->window);
gdk_window_hide (priv->window);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
gtk_widget_unmap (child);
}
}
}
@@ -10670,10 +10746,7 @@ gtk_widget_real_unrealize (GtkWidget *widget)
* (for example, gdk_ic_destroy () with destroyed window causes crash.)
*/
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_unrealize,
NULL);
gtk_widget_forall (widget, (GtkCallback)gtk_widget_unrealize, NULL);
if (_gtk_widget_get_has_window (widget))
{
@@ -11074,6 +11147,8 @@ gtk_widget_propagate_state (GtkWidget *widget,
{
GtkWidgetPrivate *priv = widget->priv;
GtkStateFlags new_flags, old_flags = priv->state_flags;
GtkStateData child_data;
GtkWidget *child;
priv->state_flags |= data->flags_to_set;
priv->state_flags &= ~(data->flags_to_unset);
@@ -11145,17 +11220,16 @@ gtk_widget_propagate_state (GtkWidget *widget,
if (!gtk_widget_is_sensitive (widget))
gtk_widget_reset_controllers (widget);
if (GTK_IS_CONTAINER (widget))
/* Make sure to only propagate the right states further */
child_data.flags_to_set = data->flags_to_set & GTK_STATE_FLAGS_DO_PROPAGATE;
child_data.flags_to_unset = data->flags_to_unset & GTK_STATE_FLAGS_DO_PROPAGATE;
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
GtkStateData child_data;
/* Make sure to only propagate the right states further */
child_data.flags_to_set = data->flags_to_set & GTK_STATE_FLAGS_DO_PROPAGATE;
child_data.flags_to_unset = data->flags_to_unset & GTK_STATE_FLAGS_DO_PROPAGATE;
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_propagate_state,
&child_data);
gtk_widget_propagate_state (child, &child_data);
}
g_object_unref (widget);
@@ -11392,61 +11466,6 @@ gtk_widget_class_list_style_properties (GtkWidgetClass *klass,
return pspecs;
}
/**
* gtk_widget_style_get_property:
* @widget: a #GtkWidget
* @property_name: the name of a style property
* @value: location to return the property value
*
* Gets the value of a style property of @widget.
*/
void
gtk_widget_style_get_property (GtkWidget *widget,
const gchar *property_name,
GValue *value)
{
GParamSpec *pspec;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (property_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
g_object_ref (widget);
pspec = g_param_spec_pool_lookup (style_property_spec_pool,
property_name,
G_OBJECT_TYPE (widget),
TRUE);
if (!pspec)
g_warning ("%s: widget class '%s' has no property named '%s'",
G_STRLOC,
G_OBJECT_TYPE_NAME (widget),
property_name);
else
{
GtkStyleContext *context;
const GValue *peek_value;
context = _gtk_widget_get_style_context (widget);
peek_value = _gtk_style_context_peek_style_property (context,
G_OBJECT_TYPE (widget),
pspec);
/* auto-conversion of the caller's value type
*/
if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
g_value_copy (peek_value, value);
else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
g_value_transform (peek_value, value);
else
g_warning ("can't retrieve style property '%s' of type '%s' as value of type '%s'",
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
G_VALUE_TYPE_NAME (value));
}
g_object_unref (widget);
}
/**
* gtk_widget_style_get_valist:
* @widget: a #GtkWidget
@@ -14373,12 +14392,16 @@ gtk_widget_ensure_allocate (GtkWidget *widget)
}
else if (priv->alloc_needed_on_child)
{
GtkWidget *child;
priv->alloc_needed_on_child = FALSE;
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_ensure_allocate,
NULL);
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
gtk_widget_ensure_allocate (child);
}
}
}
@@ -14500,8 +14523,14 @@ _gtk_widget_create_path (GtkWidget *widget)
parent = widget->priv->parent;
if (parent)
if (parent && GTK_IS_CONTAINER (parent))
return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
else if (parent)
{
GtkWidgetPath *path = _gtk_widget_create_path (parent);
gtk_widget_path_append_for_widget (path, widget);
return path;
}
else
{
/* Widget is either toplevel or unparented, treat both
@@ -15655,3 +15684,123 @@ gtk_widget_render (GtkWidget *widget,
gsk_renderer_end_draw_frame (renderer, context);
}
GtkWidget *
gtk_widget_get_first_child (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return widget->priv->first_child;
}
GtkWidget *
gtk_widget_get_last_child (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return widget->priv->last_child;
}
GtkWidget *
gtk_widget_get_next_sibling (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return widget->priv->next_sibling;
}
GtkWidget *
gtk_widget_get_prev_sibling (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return widget->priv->prev_sibling;
}
void
gtk_widget_forall (GtkWidget *widget,
GtkCallback callback,
gpointer user_data)
{
GtkWidget *child;
g_return_if_fail (GTK_IS_WIDGET (widget));
child = gtk_widget_get_first_child (widget);
while (child)
{
GtkWidget *next = gtk_widget_get_next_sibling (child);
callback(child, user_data);
child = next;
}
}
static void
gtk_widget_get_translation_to_child (GtkWidget *widget,
GtkWidget *child,
int *x_out,
int *y_out)
{
GtkAllocation allocation;
GdkWindow *window, *w;
int x, y;
/* translate coordinates. Ugly business, that. */
if (!_gtk_widget_get_has_window (widget))
{
_gtk_widget_get_allocation (widget, &allocation);
x = -allocation.x;
y = -allocation.y;
}
else
{
x = 0;
y = 0;
}
window = _gtk_widget_get_window (widget);
for (w = _gtk_widget_get_window (child); w && w != window; w = gdk_window_get_parent (w))
{
int wx, wy;
gdk_window_get_position (w, &wx, &wy);
x += wx;
y += wy;
}
if (w == NULL)
{
x = 0;
y = 0;
}
if (!_gtk_widget_get_has_window (child))
{
_gtk_widget_get_allocation (child, &allocation);
x += allocation.x;
y += allocation.y;
}
*x_out = x;
*y_out = y;
}
void
gtk_widget_snapshot_child (GtkWidget *widget,
GtkWidget *child,
GtkSnapshot *snapshot)
{
int x, y;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (_gtk_widget_get_parent (child) == widget);
g_return_if_fail (snapshot != NULL);
gtk_widget_get_translation_to_child (widget, child, &x, &y);
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_widget_snapshot (child, snapshot);
gtk_snapshot_translate_2d (snapshot, -x, -y);
}

View File

@@ -988,10 +988,6 @@ GDK_AVAILABLE_IN_ALL
GParamSpec** gtk_widget_class_list_style_properties (GtkWidgetClass *klass,
guint *n_properties);
GDK_AVAILABLE_IN_ALL
void gtk_widget_style_get_property (GtkWidget *widget,
const gchar *property_name,
GValue *value);
GDK_AVAILABLE_IN_ALL
void gtk_widget_style_get_valist (GtkWidget *widget,
const gchar *first_property_name,
va_list var_args);
@@ -1254,6 +1250,15 @@ void gtk_widget_set_font_map (GtkWidget *
GDK_AVAILABLE_IN_3_18
PangoFontMap * gtk_widget_get_font_map (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_first_child (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_last_child (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_next_sibling (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_prev_sibling (GtkWidget *widget);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRequisition, gtk_requisition_free)

View File

@@ -149,12 +149,16 @@ struct _GtkWidgetPrivate
GdkWindow *window;
GList *registered_windows;
/* The widget's parent */
GtkWidget *parent;
GList *event_controllers;
AtkObject *accessible;
/* Widget tree */
GtkWidget *parent;
GtkWidget *prev_sibling;
GtkWidget *next_sibling;
GtkWidget *first_child;
GtkWidget *last_child;
};
GtkCssNode * gtk_widget_get_css_node (GtkWidget *widget);
@@ -296,6 +300,15 @@ void gtk_widget_adjust_baseline_request (GtkWidget *widget,
gint *minimum_baseline,
gint *natural_baseline);
void gtk_widget_forall (GtkWidget *widget,
GtkCallback callback,
gpointer user_data);
void gtk_widget_snapshot_child (GtkWidget *widget,
GtkWidget *child,
GtkSnapshot *snapshot);
/* inline getters */
static inline gboolean
@@ -406,6 +419,30 @@ _gtk_widget_get_allocation (GtkWidget *widget,
*allocation = widget->priv->allocation;
}
static inline GtkWidget *
_gtk_widget_get_prev_sibling (GtkWidget *widget)
{
return widget->priv->prev_sibling;
}
static inline GtkWidget *
_gtk_widget_get_next_sibling (GtkWidget *widget)
{
return widget->priv->next_sibling;
}
static inline GtkWidget *
_gtk_widget_get_first_child (GtkWidget *widget)
{
return widget->priv->first_child;
}
static inline GtkWidget *
_gtk_widget_get_last_child (GtkWidget *widget)
{
return widget->priv->last_child;
}
G_END_DECLS
#endif /* __GTK_WIDGET_PRIVATE_H__ */

View File

@@ -47,6 +47,7 @@ find_widget (GtkWidget *widget,
GtkAllocation new_allocation;
gint x_offset = 0;
gint y_offset = 0;
GtkWidget *child;
gtk_widget_get_allocation (widget, &new_allocation);
@@ -121,9 +122,12 @@ find_widget (GtkWidget *widget,
new_data.found = FALSE;
new_data.first = FALSE;
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback)find_widget,
&new_data);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
find_widget (child, &new_data);
}
data->found = new_data.found;
if (data->found)

View File

@@ -125,6 +125,17 @@ object_tree_widget_get_parent (GObject *object)
return G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (object)));
}
static gboolean
object_tree_widget_get_sensitive (GObject *object)
{
return gtk_widget_get_mapped (GTK_WIDGET (object));
}
typedef struct {
ObjectTreeForallFunc forall_func;
gpointer forall_data;
} ForallData;
static void
object_tree_widget_forall (GObject *object,
ObjectTreeForallFunc forall_func,
@@ -140,6 +151,7 @@ object_tree_widget_forall (GObject *object,
{ GTK_PHASE_NONE, "" }
};
gint i;
GtkWidget *child;
for (i = 0; i < G_N_ELEMENTS (phases); i++)
{
@@ -162,41 +174,13 @@ object_tree_widget_forall (GObject *object,
if (clock)
forall_func (clock, "frame-clock", forall_data);
}
}
static gboolean
object_tree_widget_get_sensitive (GObject *object)
{
return gtk_widget_get_mapped (GTK_WIDGET (object));
}
typedef struct {
ObjectTreeForallFunc forall_func;
gpointer forall_data;
} ForallData;
static void
container_children_callback (GtkWidget *widget,
gpointer client_data)
{
ForallData *forall_data = client_data;
forall_data->forall_func (G_OBJECT (widget), NULL, forall_data->forall_data);
}
static void
object_tree_container_forall (GObject *object,
ObjectTreeForallFunc forall_func,
gpointer forall_data)
{
ForallData data = {
forall_func,
forall_data
};
gtk_container_forall (GTK_CONTAINER (object),
container_children_callback,
&data);
for (child = gtk_widget_get_first_child (GTK_WIDGET (object));
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
forall_func (G_OBJECT (child), NULL, forall_data);
}
}
static void
@@ -456,12 +440,6 @@ static const ObjectTreeClassFuncs object_tree_class_funcs[] = {
object_tree_menu_item_forall,
object_tree_widget_get_sensitive
},
{
gtk_container_get_type,
object_tree_widget_get_parent,
object_tree_container_forall,
object_tree_widget_get_sensitive
},
{
gtk_widget_get_type,
object_tree_widget_get_parent,

View File

@@ -528,7 +528,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
}
parent = gtk_widget_get_parent (GTK_WIDGET (object));
if (!parent)
if (!parent || !GTK_IS_CONTAINER (parent))
{
gtk_widget_hide (GTK_WIDGET (pl));
return TRUE;

View File

@@ -87,12 +87,17 @@ fix_direction_recurse (GtkWidget *widget,
gpointer data)
{
GtkTextDirection dir = GPOINTER_TO_INT (data);
GtkWidget *child;
g_object_ref (widget);
gtk_widget_set_direction (widget, dir);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), fix_direction_recurse, data);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
fix_direction_recurse (child, data);
}
g_object_unref (widget);
}

View File

@@ -343,41 +343,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
g_free (pspecs);
if (g_type_is_a (type, GTK_TYPE_WIDGET))
{
g_object_set (gtk_settings_get_default (), "gtk-theme-name", "Raleigh", NULL);
pspecs = gtk_widget_class_list_style_properties (GTK_WIDGET_CLASS (klass), &n_pspecs);
for (i = 0; i < n_pspecs; ++i)
{
GParamSpec *pspec = pspecs[i];
GValue value = G_VALUE_INIT;
if (pspec->owner_type != type)
continue;
if ((pspec->flags & G_PARAM_READABLE) == 0)
continue;
if (g_type_is_a (type, GTK_TYPE_BUTTON) &&
strcmp (pspec->name, "default-border") == 0)
continue;
if (g_type_is_a (type, GTK_TYPE_WINDOW) &&
(strcmp (pspec->name, "resize-grip-width") == 0 ||
strcmp (pspec->name, "resize-grip-height") == 0 ||
strcmp (pspec->name, "decoration-button-layout") == 0))
continue;
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
gtk_widget_style_get_property (GTK_WIDGET (instance), pspec->name, &value);
check_property ("Style property", pspec, &value);
g_value_unset (&value);
}
g_free (pspecs);
}
if (g_type_is_a (type, GDK_TYPE_WINDOW))
gdk_window_destroy (GDK_WINDOW (instance));
else