[dconf-editor] Allow to apply a change on small window.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Allow to apply a change on small window.
- Date: Wed, 2 Jan 2019 14:36:52 +0000 (UTC)
commit 14fc7f1582bb2e25a1ee9b2cef98010486862f1d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jan 2 15:32:28 2019 +0100
Allow to apply a change on small window.
editor/dconf-headerbar.vala | 38 +++++++++++++++++++++++++++++++++++++-
editor/dconf-window.vala | 6 ++++--
2 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/editor/dconf-headerbar.vala b/editor/dconf-headerbar.vala
index 7063ee1..5bbfde8 100644
--- a/editor/dconf-headerbar.vala
+++ b/editor/dconf-headerbar.vala
@@ -43,6 +43,7 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
add_bookmarks_controller (out bookmarks_controller, ref this);
add_show_modifications_button (out show_modifications_button, ref quit_button_stack);
+ add_modification_actions_button (out modification_actions_button, ref quit_button_stack);
add_modifications_actions_button (out modifications_actions_button, ref this);
construct_changes_pending_menu (out changes_pending_menu);
construct_quit_delayed_mode_menu (out quit_delayed_mode_menu);
@@ -223,6 +224,7 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
\*/
private Button show_modifications_button;
+ private MenuButton modification_actions_button;
private MenuButton modifications_actions_button;
private GLib.Menu changes_pending_menu;
private GLib.Menu quit_delayed_mode_menu;
@@ -238,6 +240,28 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
quit_button_stack.add (show_modifications_button);
}
+ private static void add_modification_actions_button (out MenuButton modification_actions_button, ref
Stack quit_button_stack)
+ {
+ modification_actions_button = new MenuButton ();
+ Image view_more_image = new Image.from_icon_name ("document-open-recent-symbolic", IconSize.BUTTON);
+ modification_actions_button.set_image (view_more_image);
+ modification_actions_button.valign = Align.CENTER;
+ modification_actions_button.get_style_context ().add_class ("titlebutton");
+
+ GLib.Menu change_pending_menu = new GLib.Menu ();
+ /* Translators: when a change is requested, on a small window, entry of the menu of the "delayed
settings button" that appears in place of the close button */
+ change_pending_menu.append (_("Apply"), "ui.apply-delayed-settings");
+
+ /* Translators: when a change is requested, on a small window, entry of the menu of the "delayed
settings button" that appears in place of the close button */
+ change_pending_menu.append (_("Dismiss"), "ui.dismiss-delayed-settings");
+ change_pending_menu.freeze ();
+
+ modification_actions_button.set_menu_model (change_pending_menu);
+
+ modification_actions_button.visible = true;
+ quit_button_stack.add (modification_actions_button);
+ }
+
private static void add_modifications_actions_button (out MenuButton modifications_actions_button, ref
unowned DConfHeaderBar _this)
{
modifications_actions_button = new MenuButton ();
@@ -269,12 +293,22 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
quit_delayed_mode_menu.freeze ();
}
- internal void set_apply_modifications_button_sensitive (bool new_value)
+ private bool has_pending_changes = false;
+ internal void set_has_pending_changes (bool new_value, bool mode_is_temporary)
{
+ has_pending_changes = new_value;
if (new_value)
+ {
modifications_actions_button.set_menu_model (changes_pending_menu);
+ if (mode_is_temporary)
+ quit_button_stack.set_visible_child (modification_actions_button);
+ }
else
+ {
modifications_actions_button.set_menu_model (quit_delayed_mode_menu);
+ if (mode_is_temporary)
+ quit_button_stack.set_visible_child_name ("quit-button");
+ }
}
/*\
@@ -453,6 +487,8 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
quit_button_stack.show ();
if (delay_mode)
quit_button_stack.set_visible_child (show_modifications_button);
+ else if (has_pending_changes)
+ quit_button_stack.set_visible_child (modification_actions_button);
else
quit_button_stack.set_visible_child_name ("quit-button");
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index da12e9d..8e54fb9 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -139,12 +139,14 @@ private class DConfWindow : BrowserWindow
delayed_changes_changed_handler = modifications_handler.delayed_changes_changed.connect (() => {
uint total_changes_count = modifications_handler.dconf_changes_count +
modifications_handler.gsettings_changes_count;
if (total_changes_count == 0)
- headerbar.set_apply_modifications_button_sensitive (false);
+ headerbar.set_has_pending_changes (/* has pending changes */ false,
+ /* mode is not delayed */
!modifications_handler.get_current_delay_mode ());
else
{
if (modifications_handler.mode == ModificationsMode.TEMPORARY && total_changes_count !=
1)
assert_not_reached ();
- headerbar.set_apply_modifications_button_sensitive (true);
+ headerbar.set_has_pending_changes (/* has pending changes */ true,
+ /* mode is not delayed */
!modifications_handler.get_current_delay_mode ());
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]