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