display: Show insensitive apply button for invalid configurations
When the user creates temporary invalid configurations the dialog used to hide the apply button as if no change had been done so far. Change this to show the normal "Apply"/"Cancel" titlebar but make the "Apply" button insensitive and modify the title to indicate the error. Unfortunately we don't currently get the reason in a way that we could translate it. Ideally we would special case common error scenarios and present the user with a better explanation or even correct the mistake. See https://bugzilla.gnome.org/show_bug.cgi?id=790891 for the related mutter bug. https://bugzilla.gnome.org/show_bug.cgi?id=790792
This commit is contained in:
parent
d918b02c1f
commit
adf5a42f01
1 changed files with 46 additions and 36 deletions
|
@ -87,6 +87,8 @@ struct _CcDisplayPanelPrivate
|
||||||
|
|
||||||
GtkWidget *main_titlebar;
|
GtkWidget *main_titlebar;
|
||||||
GtkWidget *apply_titlebar;
|
GtkWidget *apply_titlebar;
|
||||||
|
GtkWidget *apply_titlebar_apply;
|
||||||
|
GtkWidget *apply_titlebar_warning;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -283,6 +285,8 @@ reset_titlebar (CcDisplayPanel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->apply_titlebar);
|
g_clear_object (&priv->apply_titlebar);
|
||||||
|
g_clear_object (&priv->apply_titlebar_apply);
|
||||||
|
g_clear_object (&priv->apply_titlebar_warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2590,17 +2594,15 @@ on_toplevel_key_press (GtkWidget *button,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_apply_titlebar (CcDisplayPanel *panel)
|
show_apply_titlebar (CcDisplayPanel *panel, gboolean is_applicable)
|
||||||
{
|
{
|
||||||
CcDisplayPanelPrivate *priv = panel->priv;
|
CcDisplayPanelPrivate *priv = panel->priv;
|
||||||
GtkWidget *header, *button, *toplevel;
|
|
||||||
GtkSizeGroup *size_group;
|
GtkSizeGroup *size_group;
|
||||||
|
|
||||||
if (priv->apply_titlebar)
|
if (!priv->apply_titlebar)
|
||||||
return;
|
{
|
||||||
|
GtkWidget *header, *button, *toplevel;
|
||||||
priv->apply_titlebar = header = gtk_header_bar_new ();
|
priv->apply_titlebar = header = gtk_header_bar_new ();
|
||||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), _("Apply Changes?"));
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
||||||
|
|
||||||
|
@ -2614,7 +2616,7 @@ show_apply_titlebar (CcDisplayPanel *panel)
|
||||||
g_signal_connect_object (toplevel, "key-press-event", G_CALLBACK (on_toplevel_key_press),
|
g_signal_connect_object (toplevel, "key-press-event", G_CALLBACK (on_toplevel_key_press),
|
||||||
button, G_CONNECT_SWAPPED);
|
button, G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
button = gtk_button_new_with_mnemonic (_("_Apply"));
|
priv->apply_titlebar_apply = button = gtk_button_new_with_mnemonic (_("_Apply"));
|
||||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||||
gtk_size_group_add_widget (size_group, button);
|
gtk_size_group_add_widget (size_group, button);
|
||||||
g_signal_connect_object (button, "clicked", G_CALLBACK (apply_current_configuration),
|
g_signal_connect_object (button, "clicked", G_CALLBACK (apply_current_configuration),
|
||||||
|
@ -2631,6 +2633,20 @@ show_apply_titlebar (CcDisplayPanel *panel)
|
||||||
|
|
||||||
gtk_window_set_titlebar (GTK_WINDOW (toplevel), priv->apply_titlebar);
|
gtk_window_set_titlebar (GTK_WINDOW (toplevel), priv->apply_titlebar);
|
||||||
g_object_ref (priv->apply_titlebar);
|
g_object_ref (priv->apply_titlebar);
|
||||||
|
g_object_ref (priv->apply_titlebar_apply);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_applicable)
|
||||||
|
{
|
||||||
|
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->apply_titlebar), _("Apply Changes?"));
|
||||||
|
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (priv->apply_titlebar), NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->apply_titlebar), _("Changes Cannot be Applied"));
|
||||||
|
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (priv->apply_titlebar), _("This could be due to hardware limitations."));
|
||||||
|
}
|
||||||
|
gtk_widget_set_sensitive (priv->apply_titlebar_apply, is_applicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2640,12 +2656,6 @@ update_apply_button (CcDisplayPanel *panel)
|
||||||
gboolean config_equal;
|
gboolean config_equal;
|
||||||
CcDisplayConfig *applied_config;
|
CcDisplayConfig *applied_config;
|
||||||
|
|
||||||
if (!cc_display_config_is_applicable (priv->current_config))
|
|
||||||
{
|
|
||||||
reset_titlebar (panel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_config = cc_display_config_manager_get_current (priv->manager);
|
applied_config = cc_display_config_manager_get_current (priv->manager);
|
||||||
|
|
||||||
config_equal = cc_display_config_equal (priv->current_config,
|
config_equal = cc_display_config_equal (priv->current_config,
|
||||||
|
@ -2655,7 +2665,7 @@ update_apply_button (CcDisplayPanel *panel)
|
||||||
if (config_equal)
|
if (config_equal)
|
||||||
reset_titlebar (panel);
|
reset_titlebar (panel);
|
||||||
else
|
else
|
||||||
show_apply_titlebar (panel);
|
show_apply_titlebar (panel, cc_display_config_is_applicable (priv->current_config));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue