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.
This commit is contained in:
parent
d534f67047
commit
f95ded101c
1 changed files with 20 additions and 20 deletions
|
@ -848,6 +848,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,
|
||||
|
@ -888,27 +905,12 @@ setup_scale_buttons (GtkWidget *bbox,
|
|||
group = GTK_RADIO_BUTTON (button);
|
||||
}
|
||||
|
||||
scale_buttons_sync (bbox, output);
|
||||
|
||||
gtk_widget_show (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)
|
||||
{
|
||||
|
@ -930,11 +932,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);
|
||||
|
||||
g_signal_connect_object (output, "mode", G_CALLBACK (scale_row_sync_visibility),
|
||||
row, G_CONNECT_SWAPPED);
|
||||
|
|
Loading…
Add table
Reference in a new issue