[geary] Removed the PillBar classes (i.e. PillBar, PillHeaderbar and PillToolbar). Bug 773728.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Removed the PillBar classes (i.e. PillBar, PillHeaderbar and PillToolbar). Bug 773728.
- Date: Tue, 15 Nov 2016 10:44:33 +0000 (UTC)
commit 8189e4caddd9c33fbebdadd32491dd926eb38158
Author: Niels De Graef <nielsdegraef gmail com>
Date: Mon Oct 31 12:25:21 2016 +0100
Removed the PillBar classes (i.e. PillBar, PillHeaderbar and PillToolbar). Bug 773728.
Signed-off-by: Niels De Graef <nielsdegraef gmail com>
po/POTFILES.in | 1 -
src/CMakeLists.txt | 1 -
src/client/components/main-toolbar.vala | 217 ++++++++++++++++++++++++-------
src/client/components/pill-toolbar.vala | 182 --------------------------
4 files changed, 170 insertions(+), 231 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1cdf068..af45d4c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -30,7 +30,6 @@ src/client/components/main-toolbar.vala
src/client/components/main-window.vala
src/client/components/monitored-progress-bar.vala
src/client/components/monitored-spinner.vala
-src/client/components/pill-toolbar.vala
src/client/components/search-bar.vala
src/client/components/status-bar.vala
src/client/components/stock.vala
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d85e034..bc8d728 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -339,7 +339,6 @@ client/components/main-toolbar.vala
client/components/main-window.vala
client/components/monitored-progress-bar.vala
client/components/monitored-spinner.vala
-client/components/pill-toolbar.vala
client/components/search-bar.vala
client/components/status-bar.vala
client/components/stock.vala
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 6f9441e..2d6e13c 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -6,6 +6,7 @@
// Draws the main toolbar.
public class MainToolbar : Gtk.Box {
+ private Gtk.ActionGroup action_group;
public FolderPopover copy_folder_menu { get; private set; default = new FolderPopover(); }
public FolderPopover move_folder_menu { get; private set; default = new FolderPopover(); }
public string account { get; set; }
@@ -16,18 +17,20 @@ public class MainToolbar : Gtk.Box {
public bool search_open { get; set; default = false; }
public bool find_open { get; set; default = false; }
public int left_pane_width { get; set; }
-
- private PillHeaderbar folder_header;
- private PillHeaderbar conversation_header;
+
+ private Gtk.HeaderBar folder_header;
+ private Gtk.HeaderBar conversation_header;
private Gtk.Button archive_button;
private Gtk.Button trash_delete_button;
private Binding guest_header_binding;
-
+
public MainToolbar() {
Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 0);
-
- folder_header = new PillHeaderbar(GearyApplication.instance.actions);
- conversation_header = new PillHeaderbar(GearyApplication.instance.actions);
+
+ this.action_group = GearyApplication.instance.actions;
+
+ folder_header = new Gtk.HeaderBar();
+ conversation_header = new Gtk.HeaderBar();
folder_header.get_style_context().add_class("geary-titlebar");
folder_header.get_style_context().add_class("geary-titlebar-left");
conversation_header.get_style_context().add_class("geary-titlebar");
@@ -52,88 +55,87 @@ public class MainToolbar : Gtk.Box {
BindingFlags.SYNC_CREATE);
this.bind_property("show-close-button-right", conversation_header, "show-close-button",
BindingFlags.SYNC_CREATE);
-
+
// Assemble mark menu.
GearyApplication.instance.load_ui_resource("toolbar_mark_menu.ui");
Gtk.Menu mark_menu = (Gtk.Menu)
GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarMarkMenu");
mark_menu.foreach(GtkUtil.show_menuitem_accel_labels);
-
+
// Toolbar setup.
Gee.List<Gtk.Button> insert = new Gee.ArrayList<Gtk.Button>();
-
+
// Compose.
- insert.add(folder_header.create_toolbar_button("text-editor-symbolic",
+ insert.add(create_toolbar_button("text-editor-symbolic",
GearyController.ACTION_NEW_MESSAGE));
- folder_header.add_start(folder_header.create_pill_buttons(insert, false));
-
+ add_start(folder_header, create_pill_buttons(insert, false));
+
// Assemble the empty menu
GearyApplication.instance.load_ui_resource("toolbar_empty_menu.ui");
Gtk.Menu empty_menu = (Gtk.Menu)
GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarEmptyMenu");
empty_menu.foreach(GtkUtil.show_menuitem_accel_labels);
insert.clear();
- insert.add(folder_header.create_menu_button(null, empty_menu,
- GearyController.ACTION_EMPTY_MENU));
- Gtk.Box empty = folder_header.create_pill_buttons(insert, false);
-
+ insert.add(create_menu_button(null, empty_menu, GearyController.ACTION_EMPTY_MENU));
+ Gtk.Box empty = create_pill_buttons(insert, false);
+
// Search
insert.clear();
- Gtk.Button search_button = folder_header.create_toggle_button(
- "preferences-system-search-symbolic", GearyController.ACTION_TOGGLE_SEARCH);
+ Gtk.Button search_button = create_toggle_button("preferences-system-search-symbolic",
+ GearyController.ACTION_TOGGLE_SEARCH);
this.bind_property("search-open", search_button, "active",
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
insert.add(search_button);
- Gtk.Box search = folder_header.create_pill_buttons(insert, false);
-
- folder_header.add_end(new Gtk.Separator(Gtk.Orientation.VERTICAL));
- folder_header.add_end(search);
- folder_header.add_end(empty);
-
+ Gtk.Box search = create_pill_buttons(insert, false);
+
+ add_end(folder_header, new Gtk.Separator(Gtk.Orientation.VERTICAL));
+ add_end(folder_header, search);
+ add_end(folder_header, empty);
+
// Reply buttons
insert.clear();
- insert.add(conversation_header.create_toolbar_button("mail-reply-sender-symbolic",
+ insert.add(create_toolbar_button("mail-reply-sender-symbolic",
GearyController.ACTION_REPLY_TO_MESSAGE));
- insert.add(conversation_header.create_toolbar_button("mail-reply-all-symbolic",
+ insert.add(create_toolbar_button("mail-reply-all-symbolic",
GearyController.ACTION_REPLY_ALL_MESSAGE));
- insert.add(conversation_header.create_toolbar_button("mail-forward-symbolic",
+ insert.add(create_toolbar_button("mail-forward-symbolic",
GearyController.ACTION_FORWARD_MESSAGE));
- conversation_header.add_start(conversation_header.create_pill_buttons(insert));
-
+ add_start(conversation_header, create_pill_buttons(insert));
+
// Mark, copy, move.
insert.clear();
- insert.add(conversation_header.create_menu_button("marker-symbolic", mark_menu,
+ insert.add(create_menu_button("marker-symbolic", mark_menu,
GearyController.ACTION_MARK_AS_MENU));
- insert.add(conversation_header.create_popover_button("tag-symbolic", copy_folder_menu,
+ insert.add(create_popover_button("tag-symbolic", copy_folder_menu,
GearyController.ACTION_COPY_MENU));
- insert.add(conversation_header.create_popover_button("folder-symbolic", move_folder_menu,
+ insert.add(create_popover_button("folder-symbolic", move_folder_menu,
GearyController.ACTION_MOVE_MENU));
- conversation_header.add_start(conversation_header.create_pill_buttons(insert));
+ add_start(conversation_header, create_pill_buttons(insert));
// Archive, undo, find
insert.clear();
- insert.add(archive_button = conversation_header.create_toolbar_button(null,
GearyController.ACTION_ARCHIVE_MESSAGE, true));
- insert.add(trash_delete_button = conversation_header.create_toolbar_button(null,
GearyController.ACTION_TRASH_MESSAGE, false));
- Gtk.Box archive_trash_delete = conversation_header.create_pill_buttons(insert);
+ insert.add(archive_button = create_toolbar_button(null, GearyController.ACTION_ARCHIVE_MESSAGE,
true));
+ insert.add(trash_delete_button = create_toolbar_button(null, GearyController.ACTION_TRASH_MESSAGE,
false));
+ Gtk.Box archive_trash_delete = create_pill_buttons(insert);
insert.clear();
- insert.add(conversation_header.create_toolbar_button(null, GearyController.ACTION_UNDO,
+ insert.add(create_toolbar_button(null, GearyController.ACTION_UNDO,
false));
- Gtk.Box undo = conversation_header.create_pill_buttons(insert);
+ Gtk.Box undo = create_pill_buttons(insert);
- Gtk.Button find_button = folder_header.create_toggle_button(
+ Gtk.Button find_button = create_toggle_button(
"preferences-system-search-symbolic", GearyController.ACTION_TOGGLE_FIND);
this.bind_property("find-open", find_button, "active",
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
insert.clear();
insert.add(find_button);
- Gtk.Box find = conversation_header.create_pill_buttons(insert);
+ Gtk.Box find = create_pill_buttons(insert);
+
+ add_end(conversation_header, find);
+ add_end(conversation_header, undo);
+ add_end(conversation_header, archive_trash_delete);
- conversation_header.add_end(find);
- conversation_header.add_end(undo);
- conversation_header.add_end(archive_trash_delete);
-
pack_start(folder_header, false, false);
pack_start(conversation_header, true, true);
-
+
Gtk.Settings.get_default().notify["gtk-decoration-layout"].connect(set_window_buttons);
realize.connect(set_window_buttons);
}
@@ -141,7 +143,7 @@ public class MainToolbar : Gtk.Box {
public void update_trash_button(bool is_trash) {
string action_name = (is_trash ? GearyController.ACTION_TRASH_MESSAGE
: GearyController.ACTION_DELETE_MESSAGE);
- conversation_header.setup_button(trash_delete_button, null, action_name, false);
+ setup_button(trash_delete_button, null, action_name, false);
}
public void set_conversation_header(Gtk.HeaderBar header) {
@@ -176,4 +178,125 @@ public class MainToolbar : Gtk.Box {
conversation_header.decoration_layout = ":" + buttons[1];
}
+ // PILLBAR METHODS
+ public virtual void add_start(Gtk.HeaderBar header_bar, Gtk.Widget widget) {
+ header_bar.pack_start(widget);
+ }
+
+ public virtual void add_end(Gtk.HeaderBar header_bar, Gtk.Widget widget) {
+ header_bar.pack_end(widget);
+ }
+
+ public virtual void setup_button(Gtk.Button b, string? icon_name, string action_name,
+ bool show_label = false) {
+ Gtk.Action related_action = action_group.get_action(action_name);
+ b.focus_on_click = false;
+ b.tooltip_text = related_action.tooltip;
+ related_action.notify["tooltip"].connect(() => { b.tooltip_text = related_action.tooltip; });
+ b.related_action = related_action;
+
+ // Load icon by name with this fallback order: specified icon name, the action's icon name,
+ // the action's stock ID ... although stock IDs are being deprecated, that's how we specify
+ // the icon in the GtkActionEntry (also being deprecated) and GTK+ 3.14 doesn't support that
+ // any longer
+ string? icon_to_load = icon_name ?? b.related_action.icon_name;
+ if (icon_to_load == null)
+ icon_to_load = b.related_action.stock_id;
+
+ // set pixel size to force GTK+ to load our images from our installed directory, not the theme
+ // directory
+ if (icon_to_load != null) {
+ Gtk.Image image = new Gtk.Image.from_icon_name(icon_to_load, Gtk.IconSize.MENU);
+ image.set_pixel_size(16);
+ b.image = image;
+ }
+
+ b.always_show_image = true;
+
+ if (!show_label)
+ b.label = null;
+ }
+
+ /**
+ * Given an icon and action, creates a button that triggers the action.
+ */
+ public virtual Gtk.Button create_toolbar_button(string? icon_name, string action_name, bool show_label =
false) {
+ Gtk.Button b = new Gtk.Button();
+ setup_button(b, icon_name, action_name, show_label);
+
+ return b;
+ }
+
+ /**
+ * Given an icon and action, creates a toggle button that triggers the action.
+ */
+ public virtual Gtk.Button create_toggle_button(string? icon_name, string action_name) {
+ Gtk.ToggleButton b = new Gtk.ToggleButton();
+ setup_button(b, icon_name, action_name);
+
+ return b;
+ }
+
+ /**
+ * Given an icon, menu, and action, creates a button that triggers the menu and the action.
+ */
+ public virtual Gtk.MenuButton create_menu_button(string? icon_name, Gtk.Menu? menu, string action_name) {
+ Gtk.MenuButton b = new Gtk.MenuButton();
+ setup_button(b, icon_name, action_name);
+ b.popup = menu;
+
+ if (b.related_action != null) {
+ b.related_action.activate.connect(() => {
+ b.clicked();
+ });
+ // Null out the action since by connecting it to clicked
+ // above, invoking would cause an infinite loop otherwise.
+ b.related_action = null;
+ }
+
+ return b;
+ }
+
+ /**
+ * Given an icon, popover, and action, creates a button that triggers the popover and the action.
+ */
+ public virtual Gtk.MenuButton create_popover_button(string? icon_name, Gtk.Popover? popover, string
action_name) {
+ Gtk.MenuButton b = new Gtk.MenuButton();
+ setup_button(b, icon_name, action_name);
+ b.set_popover(popover);
+ b.clicked.connect(() => popover.show_all());
+
+ if (b.related_action != null) {
+ b.related_action.activate.connect(() => {
+ b.clicked();
+ });
+ // Null out the action since by connecting it to clicked
+ // above, invoking would cause an infinite loop otherwise.
+ b.related_action = null;
+ }
+
+ return b;
+ }
+
+ /**
+ * Given a list of buttons, creates a "pill-style" tool item that can be appended to this
+ * toolbar. Optionally adds spacers "before" and "after" the buttons (those terms depending
+ * on Gtk.TextDirection)
+ */
+ public virtual Gtk.Box create_pill_buttons(Gee.Collection<Gtk.Button> buttons,
+ bool before_spacer = true, bool after_spacer = false) {
+ Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
+ box.valign = Gtk.Align.CENTER;
+ box.halign = Gtk.Align.CENTER;
+
+ if (buttons.size > 1) {
+ box.get_style_context().add_class(Gtk.STYLE_CLASS_RAISED);
+ box.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
+ }
+
+ foreach(Gtk.Button button in buttons)
+ box.add(button);
+
+ return box;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]