Commit ece9ae4b authored by Jasper St. Pierre's avatar Jasper St. Pierre

gtkwindow: Remove resize grips

Resize grips were introduced for GNOME 3.0, before we had any of the
"new GNOME app" features like invisible borders and CSD. With OS X 10.6
and 10.7, Apple has replaced the classic grips in their applications
with invisible borders as well.

New GNOME app designs don't use resize grips anymore and the new
default theme for GTK+, Adwaita, disables them entirely by forcing their
width and height to 0.

They're past their time. Remove the code to support them. This can
always be reverted if some app relies on them.
parent b5eddb0a
......@@ -35,7 +35,6 @@ new_widget_info (const char *name,
else
{
info->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_has_resize_grip (GTK_WINDOW (info->window), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (info->window), 12);
info->include_decorations = FALSE;
gtk_widget_show_all (widget);
......
......@@ -206,8 +206,6 @@ static void gtk_range_get_preferred_height
gint *natural);
static void gtk_range_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_range_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel);
static void gtk_range_realize (GtkWidget *widget);
static void gtk_range_unrealize (GtkWidget *widget);
static void gtk_range_map (GtkWidget *widget);
......@@ -322,7 +320,6 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->get_preferred_width = gtk_range_get_preferred_width;
widget_class->get_preferred_height = gtk_range_get_preferred_height;
widget_class->size_allocate = gtk_range_size_allocate;
widget_class->hierarchy_changed = gtk_range_hierarchy_changed;
widget_class->realize = gtk_range_realize;
widget_class->unrealize = gtk_range_unrealize;
widget_class->map = gtk_range_map;
......@@ -1623,81 +1620,6 @@ gtk_range_get_preferred_height (GtkWidget *widget,
*minimum = *natural = range_rect.height + border.top + border.bottom;
}
static gboolean
modify_allocation_for_window_grip (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
GtkWidget *window, *parent;
GdkRectangle grip_rect;
GdkRectangle translated_rect;
gint x;
gint y;
window = gtk_widget_get_toplevel (widget);
if (!GTK_IS_WINDOW (window))
return FALSE;
if (!gtk_window_resize_grip_is_visible (GTK_WINDOW (window)))
return FALSE;
/* Get the area of the window's corner grip */
gtk_window_get_resize_grip_area (GTK_WINDOW (window), &grip_rect);
x = 0;
y = 0;
/* Translate the stepper's area into window coords.
* This is slightly tricky. We can't just use
* gtk_widget_translate_coordinates (widget, window, 0, 0, &x, &y)
* since that translates wrt to the _current_ allocation
* and will lead to alternating between overlap and nonoverlap
* for successive allocations.
* Therefore, we find the window-widget to whose window allocation
* is relative, and translate from there upwards.
*/
parent = widget;
while (gtk_widget_get_window (parent) == gtk_widget_get_window (widget) &&
parent != window)
{
parent = gtk_widget_get_parent (parent);
}
if (parent == window)
translated_rect = *allocation;
else
{
gtk_widget_translate_coordinates (parent,
window,
allocation->x, allocation->y,
&x, &y);
translated_rect.x = x;
translated_rect.y = y;
translated_rect.width = allocation->width;
translated_rect.height = allocation->height;
}
/* If the stepper button intersects the window resize grip.. */
if (gdk_rectangle_intersect (&grip_rect, &translated_rect, &grip_rect))
{
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
allocation->width -= grip_rect.width;
if (gtk_widget_get_direction (window) == GTK_TEXT_DIR_RTL)
allocation->x += grip_rect.width;
}
else
{
allocation->height -= grip_rect.height;
}
return TRUE;
}
return FALSE;
}
static void
gtk_range_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
......@@ -1705,7 +1627,6 @@ gtk_range_size_allocate (GtkWidget *widget,
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
modify_allocation_for_window_grip (widget, allocation);
gtk_widget_set_allocation (widget, allocation);
priv->recalc_marks = TRUE;
......@@ -1719,30 +1640,6 @@ gtk_range_size_allocate (GtkWidget *widget,
allocation->width, allocation->height);
}
static void
resize_grip_visible_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
gtk_widget_queue_resize (GTK_WIDGET (user_data));
}
static void
gtk_range_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkWidget *window;
if (previous_toplevel)
g_signal_handlers_disconnect_by_func (previous_toplevel,
G_CALLBACK (resize_grip_visible_changed),
widget);
window = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (window))
g_signal_connect (window, "notify::resize-grip-visible",
G_CALLBACK (resize_grip_visible_changed), widget);
}
static void
gtk_range_realize (GtkWidget *widget)
{
......@@ -1762,8 +1659,6 @@ gtk_range_realize (GtkWidget *widget)
g_object_ref (window);
gtk_widget_get_allocation (widget, &allocation);
if (modify_allocation_for_window_grip (widget, &allocation))
gtk_widget_set_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = allocation.x;
......
......@@ -106,13 +106,7 @@ enum
static void gtk_statusbar_update (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
static void gtk_statusbar_realize (GtkWidget *widget);
static void gtk_statusbar_destroy (GtkWidget *widget);
static void gtk_statusbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_statusbar_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel);
static guint statusbar_signals[SIGNAL_LAST] = { 0 };
......@@ -123,10 +117,7 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = gtk_statusbar_realize;
widget_class->destroy = gtk_statusbar_destroy;
widget_class->size_allocate = gtk_statusbar_size_allocate;
widget_class->hierarchy_changed = gtk_statusbar_hierarchy_changed;
class->text_pushed = gtk_statusbar_update;
class->text_popped = gtk_statusbar_update;
......@@ -547,177 +538,3 @@ gtk_statusbar_destroy (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->destroy (widget);
}
/* look for extra children between the frame containing
* the label and where we want to draw the resize grip
*/
static gboolean
has_extra_children (GtkStatusbar *statusbar)
{
GtkStatusbarPrivate *priv = statusbar->priv;
GtkPackType child_pack_type, frame_pack_type;
GtkWidget *child, *frame;
GList *l, *children;
gboolean retval = FALSE;
frame = NULL;
children = _gtk_box_get_children (GTK_BOX (statusbar));
for (l = children; l; l = l->next)
{
frame = l->data;
if (frame == priv->frame)
break;
}
gtk_box_query_child_packing (GTK_BOX (statusbar), frame,
NULL, NULL, NULL, &frame_pack_type);
for (l = l->next; l; l = l->next)
{
child = l->data;
if (!gtk_widget_get_visible (child))
continue;
gtk_box_query_child_packing (GTK_BOX (statusbar), child,
NULL, NULL, NULL, &child_pack_type);
if (frame_pack_type == GTK_PACK_START || child_pack_type == GTK_PACK_END)
{
retval = TRUE;
break;
}
}
g_list_free (children);
return retval;
}
static void
gtk_statusbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
GtkStatusbarPrivate *priv = statusbar->priv;
gboolean extra_children = FALSE;
gboolean has_resize_grip = FALSE;
GdkRectangle rect;
GtkWidget *window;
gint x, y;
GdkRectangle translated_rect;
window = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (window) &&
gtk_window_resize_grip_is_visible (GTK_WINDOW (window)))
{
gtk_window_get_resize_grip_area (GTK_WINDOW (window), &rect);
if (gtk_widget_translate_coordinates (widget, window, 0, 0, &x, &y))
{
translated_rect.x = x;
translated_rect.y = y;
translated_rect.width = allocation->width;
translated_rect.height = allocation->height;
if (gdk_rectangle_intersect (&rect, &translated_rect, NULL))
{
has_resize_grip = TRUE;
extra_children = has_extra_children (statusbar);
/* If there are extra children, we don't want them to occupy
* the space where we draw the resize grip, so we temporarily
* shrink the allocation.
* If there are no extra children, we want the frame to get
* the full allocation, and we fix up the allocation of the
* label afterwards to make room for the grip.
*/
if (extra_children)
{
allocation->width -= rect.width;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
allocation->x += rect.width;
}
}
}
}
/* chain up normally */
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_allocate (widget, allocation);
if (has_resize_grip)
{
if (extra_children)
{
allocation->width += rect.width;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
allocation->x -= rect.width;
gtk_widget_set_allocation (widget, allocation);
}
else
{
GtkAllocation child_allocation, frame_allocation;
GtkWidget *child;
/* Use the frame's child instead of statusbar->label directly, in case
* the label has been replaced by a container as the frame's child
* (and the label reparented into that container).
*/
child = gtk_bin_get_child (GTK_BIN (priv->frame));
gtk_widget_get_allocation (child, &child_allocation);
gtk_widget_get_allocation (priv->frame, &frame_allocation);
if (child_allocation.width + rect.width > frame_allocation.width)
{
/* shrink the label to make room for the grip */
*allocation = child_allocation;
allocation->width = MAX (1, allocation->width - rect.width);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
allocation->x += child_allocation.width - allocation->width;
gtk_widget_size_allocate (child, allocation);
}
}
}
}
static void
resize_grip_visible_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
GtkStatusbar *statusbar = GTK_STATUSBAR (user_data);
GtkStatusbarPrivate *priv = statusbar->priv;
gtk_widget_queue_resize (priv->label);
gtk_widget_queue_resize (priv->frame);
gtk_widget_queue_resize (GTK_WIDGET (statusbar));
}
static void
gtk_statusbar_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkWidget *window;
if (previous_toplevel)
g_signal_handlers_disconnect_by_func (previous_toplevel,
G_CALLBACK (resize_grip_visible_changed),
widget);
window = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (window))
g_signal_connect (window, "notify::resize-grip-visible",
G_CALLBACK (resize_grip_visible_changed), widget);
resize_grip_visible_changed (NULL, NULL, widget);
}
static void
gtk_statusbar_realize (GtkWidget *widget)
{
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize (widget);
resize_grip_visible_changed (NULL, NULL, widget);
}
This diff is collapsed.
......@@ -467,14 +467,14 @@ void gtk_window_set_application (GtkWindow *window,
/* Window grips
*/
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_14
void gtk_window_set_has_resize_grip (GtkWindow *window,
gboolean value);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_14
gboolean gtk_window_get_has_resize_grip (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_14
gboolean gtk_window_resize_grip_is_visible (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_14
gboolean gtk_window_get_resize_grip_area (GtkWindow *window,
GdkRectangle *rect);
......
......@@ -33,8 +33,6 @@
-GtkWidget-focus-padding: 2; // FIXME: do we still need these?
-GtkWidget-focus-line-width: 1; //
-GtkWindow-resize-grip-width: 0;
-GtkWindow-resize-grip-height: 0;
-GtkDialog-button-spacing: 4;
-GtkDialog-action-area-border: 0;
......
......@@ -50,8 +50,6 @@
-GtkWidget-visited-link-color: #184472;
-GtkWidget-focus-padding: 2;
-GtkWidget-focus-line-width: 1;
-GtkWindow-resize-grip-width: 0;
-GtkWindow-resize-grip-height: 0;
-GtkDialog-button-spacing: 4;
-GtkDialog-action-area-border: 0;
-GtkStatusbar-shadow-type: none;
......
......@@ -50,8 +50,6 @@
-GtkWidget-visited-link-color: #2a76c6;
-GtkWidget-focus-padding: 2;
-GtkWidget-focus-line-width: 1;
-GtkWindow-resize-grip-width: 0;
-GtkWindow-resize-grip-height: 0;
-GtkDialog-button-spacing: 4;
-GtkDialog-action-area-border: 0;
-GtkStatusbar-shadow-type: none;
......
......@@ -23,8 +23,6 @@
color: @fg_color;
border-color: shade (@bg_color, 0.6);
padding: 2px;
-GtkWindow-resize-grip-width: 0;
-GtkWindow-resize-grip-height: 0;
-GtkWindow-decoration-button-layout: 'icon:minimize,maximize,close';
}
......
......@@ -324,7 +324,6 @@ int main (int argc, char *argv[])
what = "check";
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
ebox = gtk_event_box_new ();
gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), TRUE);
gtk_container_add (GTK_CONTAINER (window), ebox);
......
......@@ -227,8 +227,6 @@ test_spin_button_arrows (void)
gboolean simsuccess;
double oldval, newval;
gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
child = gtk_bin_get_child (GTK_BIN (window));
gtk_container_add (GTK_CONTAINER (child), spinner);
gtk_widget_show (spinner);
......
......@@ -3,7 +3,6 @@
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="has_resize_grip">False</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment