[dconf-editor] Make quit_button_stack private.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make quit_button_stack private.
- Date: Sun, 20 Jan 2019 10:36:21 +0000 (UTC)
commit bd6c704f291c5cd49338c97ec4dc86227aa75a26
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Jan 20 05:35:45 2019 +0100
Make quit_button_stack private.
editor/base-headerbar.vala | 36 +++++++++++++++++++++++++++++-------
editor/dconf-headerbar.vala | 43 +++++++++++++++++++++++++++----------------
2 files changed, 56 insertions(+), 23 deletions(-)
---
diff --git a/editor/base-headerbar.vala b/editor/base-headerbar.vala
index 68f18d2..8377a5c 100644
--- a/editor/base-headerbar.vala
+++ b/editor/base-headerbar.vala
@@ -187,16 +187,38 @@ private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
}
/*\
- * * default widgets
+ * * quit button stack
\*/
- [GtkChild] private Button go_back_button;
- [GtkChild] private Separator ltr_left_separator;
- [GtkChild] private Label title_label;
- [GtkChild] private MenuButton info_button;
- [GtkChild] private Separator ltr_right_separator;
+ [GtkChild] private Stack quit_button_stack;
+
+ protected void add_named_widget_to_quit_button_stack (Widget widget, string name)
+ {
+ quit_button_stack.add_named (widget, name);
+ }
+
+ protected void set_quit_button_stack_child (string name)
+ {
+ quit_button_stack.set_visible_child_name (name);
+ }
+
+ protected void set_quit_button_stack_visibility (bool visible) // TODO better
+ {
+ if (visible)
+ quit_button_stack.show ();
+ else
+ quit_button_stack.hide ();
+ }
+
+ /*\
+ * * default widgets
+ \*/
- [GtkChild] protected Stack quit_button_stack;
+ [GtkChild] private Button go_back_button;
+ [GtkChild] private Separator ltr_left_separator;
+ [GtkChild] private Label title_label;
+ [GtkChild] private MenuButton info_button;
+ [GtkChild] private Separator ltr_right_separator;
protected void set_default_widgets_states (string? title_label_text_or_null,
bool show_go_back_button,
diff --git a/editor/dconf-headerbar.vala b/editor/dconf-headerbar.vala
index 93cdace..c5d2970 100644
--- a/editor/dconf-headerbar.vala
+++ b/editor/dconf-headerbar.vala
@@ -35,9 +35,12 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
construct
{
- 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);
+ // delay mode quit_button_stack buttons
+ add_show_modifications_button ();
+ add_modification_actions_button ();
+
+ // modifications view three-dots button
+ 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);
@@ -72,13 +75,17 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
* * modifications buttons and actions
\*/
- private Button show_modifications_button; // for selecting as stack child only
- private MenuButton modification_actions_button; // for selecting as stack child only
private MenuButton modifications_actions_button;
private GLib.Menu changes_pending_menu; // for selecting as menu only
private GLib.Menu quit_delayed_mode_menu; // for selecting as menu only
- private static void add_show_modifications_button (out Button show_modifications_button, ref Stack
quit_button_stack)
+ private inline void add_show_modifications_button ()
+ {
+ Button show_modifications_button;
+ create_show_modifications_button (out show_modifications_button);
+ add_named_widget_to_quit_button_stack (show_modifications_button, "show-modifications");
+ }
+ private static inline void create_show_modifications_button (out Button show_modifications_button)
{
show_modifications_button = new Button.from_icon_name ("document-open-recent-symbolic");
show_modifications_button.valign = Align.CENTER;
@@ -86,10 +93,15 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
show_modifications_button.get_style_context ().add_class ("titlebutton");
show_modifications_button.visible = true;
- quit_button_stack.add (show_modifications_button);
}
- private static void add_modification_actions_button (out MenuButton modification_actions_button, ref
Stack quit_button_stack)
+ private inline void add_modification_actions_button ()
+ {
+ MenuButton modification_actions_button;
+ create_modification_actions_button (out modification_actions_button);
+ add_named_widget_to_quit_button_stack (modification_actions_button, "modification-actions");
+ }
+ private static inline void create_modification_actions_button (out MenuButton
modification_actions_button)
{
modification_actions_button = new MenuButton ();
Image view_more_image = new Image.from_icon_name ("document-open-recent-symbolic", IconSize.BUTTON);
@@ -108,7 +120,6 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
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)
@@ -150,13 +161,13 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
{
modifications_actions_button.set_menu_model (changes_pending_menu);
if (mode_is_temporary)
- quit_button_stack.set_visible_child (modification_actions_button);
+ set_quit_button_stack_child ("modification-actions");
}
else
{
modifications_actions_button.set_menu_model (quit_delayed_mode_menu);
if (mode_is_temporary)
- quit_button_stack.set_visible_child_name ("quit-button");
+ set_quit_button_stack_child ("quit-button");
}
}
@@ -248,17 +259,17 @@ private class DConfHeaderBar : BookmarksHeaderBar, AdaptativeWidget
if (modifications_mode_on)
{
- quit_button_stack.hide ();
+ set_quit_button_stack_visibility (false);
}
else
{
- quit_button_stack.show ();
+ set_quit_button_stack_visibility (true);
if (delay_mode)
- quit_button_stack.set_visible_child (show_modifications_button);
+ set_quit_button_stack_child ("show-modifications");
else if (has_pending_changes)
- quit_button_stack.set_visible_child (modification_actions_button);
+ set_quit_button_stack_child ("modification-actions");
else
- quit_button_stack.set_visible_child_name ("quit-button");
+ set_quit_button_stack_child ("quit-button");
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]