forked from AuroraMiddleware/gtk
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master See merge request GNOME/gtk!2453
This commit is contained in:
commit
174c9a938e
@ -1896,6 +1896,48 @@ validate_more_details (GtkEntry *entry,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mode_switch_state_set (GtkSwitch *sw, gboolean state)
|
||||
{
|
||||
GtkWidget *dialog = gtk_widget_get_ancestor (GTK_WIDGET (sw), GTK_TYPE_DIALOG);
|
||||
GtkWidget *scale = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "level_scale"));
|
||||
GtkWidget *label = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "error_label"));
|
||||
|
||||
if (!state ||
|
||||
(gtk_range_get_value (GTK_RANGE (scale)) > 50))
|
||||
{
|
||||
gtk_widget_hide (label);
|
||||
gtk_switch_set_state (sw, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_show (label);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
level_scale_value_changed (GtkRange *range)
|
||||
{
|
||||
GtkWidget *dialog = gtk_widget_get_ancestor (GTK_WIDGET (range), GTK_TYPE_DIALOG);
|
||||
GtkWidget *sw = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "mode_switch"));
|
||||
GtkWidget *label = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "error_label"));
|
||||
|
||||
if (gtk_switch_get_active (GTK_SWITCH (sw)) &&
|
||||
!gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
||||
(gtk_range_get_value (range) > 50))
|
||||
{
|
||||
gtk_widget_hide (label);
|
||||
gtk_switch_set_state (GTK_SWITCH (sw), TRUE);
|
||||
}
|
||||
else if (gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
||||
(gtk_range_get_value (range) <= 50))
|
||||
{
|
||||
gtk_switch_set_state (GTK_SWITCH (sw), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@ -1978,6 +2020,8 @@ activate (GApplication *app)
|
||||
"osd_frame_pressed", (GCallback)osd_frame_pressed,
|
||||
"age_entry_changed", (GCallback)age_entry_changed,
|
||||
"validate_more_details", (GCallback)validate_more_details,
|
||||
"mode_switch_state_set", (GCallback)mode_switch_state_set,
|
||||
"level_scale_value_changed", (GCallback)level_scale_value_changed,
|
||||
NULL);
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
g_object_unref (scope);
|
||||
@ -2101,6 +2145,13 @@ activate (GApplication *app)
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "circular_button");
|
||||
g_signal_connect (widget, "clicked", G_CALLBACK (show_dialog), dialog);
|
||||
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "level_scale");
|
||||
g_object_set_data (G_OBJECT (dialog), "level_scale", widget);
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "mode_switch");
|
||||
g_object_set_data (G_OBJECT (dialog), "mode_switch", widget);
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "error_label");
|
||||
g_object_set_data (G_OBJECT (dialog), "error_label", widget);
|
||||
|
||||
dialog = (GtkWidget *)gtk_builder_get_object (builder, "selection_dialog");
|
||||
g_object_set_data (G_OBJECT (window), "selection_dialog", dialog);
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "text3");
|
||||
|
@ -3078,6 +3078,7 @@ bad things might happen.</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="draw-value">0</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<signal name="value-changed" handler="level_scale_value_changed"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">2</property>
|
||||
@ -3105,6 +3106,7 @@ bad things might happen.</property>
|
||||
<object class="GtkSwitch" id="mode_switch">
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<signal name="state-set" handler="mode_switch_state_set"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">3</property>
|
||||
@ -3112,12 +3114,11 @@ bad things might happen.</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="switch_error">
|
||||
<object class="GtkLabel" id="error_label">
|
||||
<property name="visible">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label">Error!</property>
|
||||
<property name="visible" bind-source="mode_switch" bind-property="active"></property>
|
||||
<property name="label">Level too low</property>
|
||||
<style>
|
||||
<class name="error"/>
|
||||
</style>
|
||||
|
@ -2782,7 +2782,6 @@ gtk_label_get_measuring_layout (GtkLabel *self,
|
||||
PangoLayout *existing_layout,
|
||||
int width)
|
||||
{
|
||||
PangoRectangle rect;
|
||||
PangoLayout *copy;
|
||||
|
||||
if (existing_layout != NULL)
|
||||
@ -2820,13 +2819,17 @@ gtk_label_get_measuring_layout (GtkLabel *self,
|
||||
* can just return the current layout, because for measuring purposes, it will be
|
||||
* identical.
|
||||
*/
|
||||
pango_layout_get_extents (self->layout, NULL, &rect);
|
||||
if ((width == -1 || rect.width <= width) &&
|
||||
!pango_layout_is_wrapped (self->layout) &&
|
||||
if (!pango_layout_is_wrapped (self->layout) &&
|
||||
!pango_layout_is_ellipsized (self->layout))
|
||||
{
|
||||
g_object_ref (self->layout);
|
||||
return self->layout;
|
||||
PangoRectangle rect;
|
||||
|
||||
if (width == -1)
|
||||
return g_object_ref (self->layout);
|
||||
|
||||
pango_layout_get_extents (self->layout, NULL, &rect);
|
||||
if (rect.width <= width)
|
||||
return g_object_ref (self->layout);
|
||||
}
|
||||
|
||||
copy = pango_layout_copy (self->layout);
|
||||
|
Loading…
Reference in New Issue
Block a user