Verified Commit 5c94da67 authored by Benjamin Berg's avatar Benjamin Berg Committed by Georges Basile Stavracas Neto

display: Sync scale button state after update

We need to re-sync the scale button scale when updating the state
dynamically. Otherwise changing the resolution will always show a scale
of 100% (first item) rather than the actual active one.
parent f109ee85
......@@ -820,6 +820,23 @@ make_label_for_scale (double scale)
return gtk_label_new (text);
}
static void
scale_buttons_sync (GtkWidget *bbox,
CcDisplayMonitor *output)
{
g_autoptr(GList) children;
GList *l;
children = gtk_container_get_children (GTK_CONTAINER (bbox));
for (l = children; l; l = l->next)
{
GtkWidget *button = l->data;
double scale = *(double*) g_object_get_data (G_OBJECT (button), "scale");
if (scale == cc_display_monitor_get_scale (output))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
}
#define MAX_N_SCALES 5
static void
setup_scale_buttons (GtkWidget *bbox,
......@@ -856,27 +873,12 @@ setup_scale_buttons (GtkWidget *bbox,
group = GTK_RADIO_BUTTON (button);
}
scale_buttons_sync (bbox, output);
gtk_widget_show_all (bbox);
}
#undef MAX_N_SCALES
static void
scale_buttons_sync (GtkWidget *bbox,
CcDisplayMonitor *output)
{
g_autoptr(GList) children;
GList *l;
children = gtk_container_get_children (GTK_CONTAINER (bbox));
for (l = children; l; l = l->next)
{
GtkWidget *button = l->data;
double scale = *(double*) g_object_get_data (G_OBJECT (button), "scale");
if (scale == cc_display_monitor_get_scale (output))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
}
static GtkWidget *
make_scale_row (CcDisplayPanel *panel, CcDisplayMonitor *output)
{
......@@ -896,11 +898,9 @@ make_scale_row (CcDisplayPanel *panel, CcDisplayMonitor *output)
g_object_set_data (G_OBJECT (bbox), "panel", panel);
g_signal_connect_object (output, "mode", G_CALLBACK (setup_scale_buttons),
bbox, G_CONNECT_SWAPPED);
setup_scale_buttons (bbox, output);
g_signal_connect_object (output, "scale", G_CALLBACK (scale_buttons_sync),
bbox, G_CONNECT_SWAPPED);
scale_buttons_sync (bbox, output);
setup_scale_buttons (bbox, output);
gtk_widget_show_all (row);
gtk_widget_set_no_show_all (row, TRUE);
......
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