display: Make rebuilding variable a counter

We need to also set rebuilding while updating some other UI elements.
Make it into a counter to allow for recursive setting.
Note that additional checks for rebuilding will be added in later
commits.
This commit is contained in:
Benjamin Berg 2019-03-20 14:59:36 +01:00
parent 21bb6416be
commit 98d20659b7

View file

@ -63,7 +63,7 @@ struct _CcDisplayPanel
CcDisplayConfig *current_config; CcDisplayConfig *current_config;
CcDisplayMonitor *current_output; CcDisplayMonitor *current_output;
gboolean rebuilding; gint rebuilding_counter;
CcDisplayArrangement *arrangement; CcDisplayArrangement *arrangement;
CcDisplaySettings *settings; CcDisplaySettings *settings;
@ -480,7 +480,7 @@ on_config_type_toggled_cb (CcDisplayPanel *panel,
{ {
CcDisplayConfigType type; CcDisplayConfigType type;
if (panel->rebuilding) if (panel->rebuilding_counter > 0)
return; return;
if (!panel->current_config) if (!panel->current_config)
@ -554,7 +554,7 @@ on_primary_display_selected_index_changed_cb (CcDisplayPanel *panel)
gint idx = hdy_combo_row_get_selected_index (panel->primary_display_row); gint idx = hdy_combo_row_get_selected_index (panel->primary_display_row);
g_autoptr(CcDisplayMonitor) output = NULL; g_autoptr(CcDisplayMonitor) output = NULL;
if (idx < 0 || panel->rebuilding) if (idx < 0 || panel->rebuilding_counter > 0)
return; return;
output = g_list_model_get_item (G_LIST_MODEL (panel->primary_display_list), idx); output = g_list_model_get_item (G_LIST_MODEL (panel->primary_display_list), idx);
@ -633,6 +633,8 @@ set_current_output (CcDisplayPanel *panel,
if (!changed && !force) if (!changed && !force)
return; return;
panel->rebuilding_counter++;
if (changed && cc_panel_get_selected_type (panel) == CC_DISPLAY_CONFIG_SINGLE) if (changed && cc_panel_get_selected_type (panel) == CC_DISPLAY_CONFIG_SINGLE)
{ {
if (output) if (output)
@ -684,6 +686,8 @@ set_current_output (CcDisplayPanel *panel,
cc_display_settings_set_selected_output (panel->settings, panel->current_output); cc_display_settings_set_selected_output (panel->settings, panel->current_output);
cc_display_arrangement_set_selected_output (panel->arrangement, panel->current_output); cc_display_arrangement_set_selected_output (panel->arrangement, panel->current_output);
} }
panel->rebuilding_counter--;
} }
static void static void
@ -692,7 +696,7 @@ rebuild_ui (CcDisplayPanel *panel)
guint n_outputs, n_active_outputs, n_usable_outputs; guint n_outputs, n_active_outputs, n_usable_outputs;
GList *outputs, *l; GList *outputs, *l;
panel->rebuilding = TRUE; panel->rebuilding_counter++;
g_list_store_remove_all (panel->primary_display_list); g_list_store_remove_all (panel->primary_display_list);
gtk_list_store_clear (panel->output_selection_list); gtk_list_store_clear (panel->output_selection_list);
@ -793,7 +797,7 @@ rebuild_ui (CcDisplayPanel *panel)
gtk_stack_set_visible_child_name (panel->output_selection_stack, "multi-selection"); gtk_stack_set_visible_child_name (panel->output_selection_stack, "multi-selection");
} }
panel->rebuilding = FALSE; panel->rebuilding_counter--;
update_apply_button (panel); update_apply_button (panel);
} }