[gnome-control-center/wip/benzea/display: 1/6] display: Show insensitive apply button for invalid configurations
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/benzea/display: 1/6] display: Show insensitive apply button for invalid configurations
- Date: Thu, 1 Feb 2018 14:51:53 +0000 (UTC)
commit d423cf6ca9f1d9d1c4d92c0e54debdabb9ce898f
Author: Benjamin Berg <bberg redhat com>
Date: Fri Nov 24 15:39:38 2017 +0100
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
panels/display/cc-display-panel.c | 82 +++++++++++++++++++++----------------
1 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 256fc86..a43f5ba 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -87,6 +87,8 @@ struct _CcDisplayPanelPrivate
GtkWidget *main_titlebar;
GtkWidget *apply_titlebar;
+ GtkWidget *apply_titlebar_apply;
+ GtkWidget *apply_titlebar_warning;
};
typedef struct
@@ -280,6 +282,8 @@ reset_titlebar (CcDisplayPanel *self)
}
g_clear_object (&priv->apply_titlebar);
+ g_clear_object (&priv->apply_titlebar_apply);
+ g_clear_object (&priv->apply_titlebar_warning);
}
static void
@@ -2577,47 +2581,59 @@ on_toplevel_key_press (GtkWidget *button,
}
static void
-show_apply_titlebar (CcDisplayPanel *panel)
+show_apply_titlebar (CcDisplayPanel *panel, gboolean is_applicable)
{
CcDisplayPanelPrivate *priv = panel->priv;
- GtkWidget *header, *button, *toplevel;
GtkSizeGroup *size_group;
- if (priv->apply_titlebar)
- return;
+ if (!priv->apply_titlebar)
+ {
+ 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);
+ button = gtk_button_new_with_mnemonic (_("_Cancel"));
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
+ gtk_size_group_add_widget (size_group, button);
+ g_signal_connect_object (button, "clicked", G_CALLBACK (on_screen_changed),
+ panel, G_CONNECT_SWAPPED);
- button = gtk_button_new_with_mnemonic (_("_Cancel"));
- gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
- gtk_size_group_add_widget (size_group, button);
- g_signal_connect_object (button, "clicked", G_CALLBACK (on_screen_changed),
- panel, G_CONNECT_SWAPPED);
+ toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
+ g_signal_connect_object (toplevel, "key-press-event", G_CALLBACK (on_toplevel_key_press),
+ button, G_CONNECT_SWAPPED);
- toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)));
- g_signal_connect_object (toplevel, "key-press-event", G_CALLBACK (on_toplevel_key_press),
- button, G_CONNECT_SWAPPED);
+ priv->apply_titlebar_apply = button = gtk_button_new_with_mnemonic (_("_Apply"));
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+ gtk_size_group_add_widget (size_group, button);
+ g_signal_connect_object (button, "clicked", G_CALLBACK (apply_current_configuration),
+ panel, G_CONNECT_SWAPPED);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
+ GTK_STYLE_CLASS_SUGGESTED_ACTION);
- button = gtk_button_new_with_mnemonic (_("_Apply"));
- gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
- gtk_size_group_add_widget (size_group, button);
- g_signal_connect_object (button, "clicked", G_CALLBACK (apply_current_configuration),
- panel, G_CONNECT_SWAPPED);
- gtk_style_context_add_class (gtk_widget_get_style_context (button),
- GTK_STYLE_CLASS_SUGGESTED_ACTION);
+ gtk_widget_show_all (header);
+ g_object_unref (size_group);
- gtk_widget_show_all (header);
- g_object_unref (size_group);
+ header = gtk_window_get_titlebar (GTK_WINDOW (toplevel));
+ if (header)
+ priv->main_titlebar = g_object_ref (header);
- header = gtk_window_get_titlebar (GTK_WINDOW (toplevel));
- if (header)
- priv->main_titlebar = g_object_ref (header);
+ gtk_window_set_titlebar (GTK_WINDOW (toplevel), priv->apply_titlebar);
+ g_object_ref (priv->apply_titlebar);
+ g_object_ref (priv->apply_titlebar_apply);
+ }
- gtk_window_set_titlebar (GTK_WINDOW (toplevel), priv->apply_titlebar);
- g_object_ref (priv->apply_titlebar);
+ 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
@@ -2627,12 +2643,6 @@ update_apply_button (CcDisplayPanel *panel)
gboolean config_equal;
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);
config_equal = cc_display_config_equal (priv->current_config,
@@ -2642,7 +2652,7 @@ update_apply_button (CcDisplayPanel *panel)
if (config_equal)
reset_titlebar (panel);
else
- show_apply_titlebar (panel);
+ show_apply_titlebar (panel, cc_display_config_is_applicable (priv->current_config));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]