Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!1823
This commit is contained in:
Matthias Clasen 2020-05-04 12:31:25 +00:00
commit 837b141747
2 changed files with 6 additions and 100 deletions

View File

@ -461,16 +461,12 @@ gtk_frame_set_label_align (GtkFrame *frame,
g_return_if_fail (GTK_IS_FRAME (frame));
xalign = CLAMP (xalign, 0.0, 1.0);
if (priv->label_xalign == xalign)
return;
g_object_freeze_notify (G_OBJECT (frame));
if (xalign != priv->label_xalign)
{
priv->label_xalign = xalign;
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_XALIGN]);
}
g_object_thaw_notify (G_OBJECT (frame));
gtk_widget_queue_resize (GTK_WIDGET (frame));
priv->label_xalign = xalign;
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_XALIGN]);
gtk_widget_queue_allocate (GTK_WIDGET (frame));
}
/**
@ -521,7 +517,7 @@ gtk_frame_size_allocate (GtkWidget *widget,
gtk_widget_measure (priv->label_widget, GTK_ORIENTATION_VERTICAL, width,
&label_height, NULL, NULL, NULL);
label_allocation.x = new_allocation.x + (new_allocation.width - width) * xalign;
label_allocation.x = new_allocation.x + (new_allocation.width - label_width) * xalign;
label_allocation.y = new_allocation.y - label_height;
label_allocation.height = label_height;
label_allocation.width = label_width;

View File

@ -18,78 +18,6 @@
#include <gtk/gtk.h>
#include <math.h>
static void
spin_hpadding_cb (GtkSpinButton *spin, gpointer user_data)
{
GtkWidget *frame = user_data;
GtkCssProvider *provider;
GtkStyleContext *context;
gchar *data;
GtkBorder pad;
context = gtk_widget_get_style_context (frame);
provider = g_object_get_data (G_OBJECT (frame), "provider");
if (provider == NULL)
{
provider = gtk_css_provider_new ();
g_object_set_data (G_OBJECT (frame), "provider", provider);
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
gtk_style_context_save (context);
gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
gtk_style_context_get_padding (context, &pad);
gtk_style_context_restore (context);
data = g_strdup_printf ("frame { padding: %dpx %dpx }",
pad.top,
(gint)gtk_spin_button_get_value (spin));
gtk_css_provider_load_from_data (provider, data, -1);
g_free (data);
gtk_widget_queue_resize (frame);
}
static void
spin_vpadding_cb (GtkSpinButton *spin, gpointer user_data)
{
GtkWidget *frame = user_data;
GtkCssProvider *provider;
GtkStyleContext *context;
gchar *data;
GtkBorder pad;
context = gtk_widget_get_style_context (frame);
provider = g_object_get_data (G_OBJECT (frame), "provider");
if (provider == NULL)
{
provider = gtk_css_provider_new ();
g_object_set_data (G_OBJECT (frame), "provider", provider);
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
gtk_style_context_save (context);
gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
gtk_style_context_get_padding (context, &pad);
gtk_style_context_restore (context);
data = g_strdup_printf ("frame { padding: %dpx %dpx }",
(gint)gtk_spin_button_get_value (spin),
pad.left);
gtk_css_provider_load_from_data (provider, data, -1);
g_free (data);
gtk_widget_queue_resize (frame);
}
/* Function to normalize rounding errors in FP arithmetic to
our desired limits */
@ -172,24 +100,6 @@ int main (int argc, char **argv)
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_xalign_cb), frame);
gtk_grid_attach (grid, widget, 1, 0, 1, 1);
/* Spin to control vertical padding */
widget = gtk_label_new ("vertical padding:");
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
widget = gtk_spin_button_new_with_range (0, 250, 1);
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_vpadding_cb), frame);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 0);
gtk_grid_attach (grid, widget, 1, 1, 1, 1);
/* Spin to control horizontal padding */
widget = gtk_label_new ("horizontal padding:");
gtk_grid_attach (grid, widget, 0, 2, 1, 1);
widget = gtk_spin_button_new_with_range (0, 250, 1);
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_hpadding_cb), frame);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 0);
gtk_grid_attach (grid, widget, 1, 2, 1, 1);
gtk_widget_show (window);
while (!done)