[geary/pantheon_mail: 25/32] remove menubutton from pill-toolbar.vala and convert menus using it
- From: Javier Jardón Cabezas <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/pantheon_mail: 25/32] remove menubutton from pill-toolbar.vala and convert menus using it
- Date: Wed, 25 Nov 2015 19:52:51 +0000 (UTC)
commit e09e4d059ea67a0eab2d0266d67cb0eea0385ce8
Author: Daniel Foré <daniel elementary io>
Date: Tue Nov 24 11:48:54 2015 -0800
remove menubutton from pill-toolbar.vala and convert menus using it
src/client/components/main-toolbar.vala | 9 ++--
src/client/components/pill-toolbar.vala | 57 +++++++++++----------------
src/client/composer/composer-headerbar.vala | 58 +++++++++++++--------------
src/client/composer/composer-toolbar.vala | 26 ++++++------
4 files changed, 70 insertions(+), 80 deletions(-)
---
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 0be32b9..cef2e3a 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -74,10 +74,11 @@ public class MainToolbar : Gtk.Box {
GearyApplication.instance.load_ui_file("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);
+
+ Gtk.MenuButton empty = new Gtk.MenuButton();
+ empty.image = new Gtk.Image.from_icon_name("edit-clear", Gtk.IconSize.LARGE_TOOLBAR);
+ empty.popup = empty_menu;
+ empty.tooltip_text = _("Empty Spam or Trash folders");
// Search
insert.clear();
diff --git a/src/client/components/pill-toolbar.vala b/src/client/components/pill-toolbar.vala
index 559058c..a2e714f 100644
--- a/src/client/components/pill-toolbar.vala
+++ b/src/client/components/pill-toolbar.vala
@@ -14,31 +14,31 @@
public interface PillBar : Gtk.Container {
protected abstract Gtk.ActionGroup action_group { get; set; }
protected abstract Gtk.SizeGroup size { get; set; }
-
+
public abstract void pack_start(Gtk.Widget widget);
public abstract void pack_end(Gtk.Widget widget);
-
+
protected virtual void initialize(Gtk.ActionGroup toolbar_action_group) {
action_group = toolbar_action_group;
size = new Gtk.SizeGroup(Gtk.SizeGroupMode.VERTICAL);
}
-
+
public virtual void add_start(Gtk.Widget widget) {
pack_start(widget);
size.add_widget(widget);
}
-
+
public virtual void add_end(Gtk.Widget widget) {
pack_end(widget);
size.add_widget(widget);
}
-
+
public virtual void setup_button(Gtk.Button b, string? icon_name, string action_name,
bool show_label = false) {
b.related_action = action_group.get_action(action_name);
b.tooltip_text = b.related_action.tooltip;
b.related_action.notify["tooltip"].connect(() => { b.tooltip_text = b.related_action.tooltip; });
-
+
// 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
@@ -46,7 +46,7 @@ public interface PillBar : Gtk.Container {
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) {
@@ -54,48 +54,37 @@ public interface PillBar : Gtk.Container {
image.set_pixel_size(16);
b.image = image;
}
-
+
// Unity buttons are a bit tight
if (GearyApplication.instance.is_running_unity && b.image != null)
b.image.margin = b.image.margin + 4;
-
+
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;
-
+
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
@@ -106,15 +95,15 @@ public interface PillBar : Gtk.Container {
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;
}
}
@@ -125,11 +114,11 @@ public interface PillBar : Gtk.Container {
public class PillHeaderbar : Gtk.HeaderBar, PillBar {
protected Gtk.ActionGroup action_group { get; set; }
protected Gtk.SizeGroup size { get; set; }
-
+
public PillHeaderbar(Gtk.ActionGroup toolbar_action_group) {
initialize(toolbar_action_group);
}
-
+
public bool close_button_at_end() {
string layout;
bool at_end = false;
@@ -154,16 +143,16 @@ public class PillHeaderbar : Gtk.HeaderBar, PillBar {
public class PillToolbar : Gtk.Box, PillBar {
protected Gtk.ActionGroup action_group { get; set; }
protected Gtk.SizeGroup size { get; set; }
-
+
public PillToolbar(Gtk.ActionGroup toolbar_action_group) {
Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 6);
initialize(toolbar_action_group);
}
-
+
public new void pack_start(Gtk.Widget widget) {
base.pack_start(widget, false, false, 0);
}
-
+
public new void pack_end(Gtk.Widget widget) {
base.pack_end(widget, false, false, 0);
}
diff --git a/src/client/composer/composer-headerbar.vala b/src/client/composer/composer-headerbar.vala
index 3c8f46f..25d7a81 100644
--- a/src/client/composer/composer-headerbar.vala
+++ b/src/client/composer/composer-headerbar.vala
@@ -5,26 +5,26 @@
*/
public class ComposerHeaderbar : PillHeaderbar {
-
+
public ComposerWidget.ComposerState state { get; set; }
public bool show_pending_attachments { get; set; default = false; }
public bool send_enabled { get; set; default = false; }
-
+
private Gtk.Button recipients;
private Gtk.Label recipients_label;
private Gtk.Box detach_start;
private Gtk.Box detach_end;
-
+
public ComposerHeaderbar(Gtk.ActionGroup action_group) {
base(action_group);
-
+
show_close_button = false;
-
+
bool rtl = (get_direction() == Gtk.TextDirection.RTL);
-
+
// Toolbar setup.
Gee.List<Gtk.Button> insert = new Gee.ArrayList<Gtk.Button>();
-
+
// Window management.
detach_start = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
Gtk.Button detach_button = create_toolbar_button(null, ComposerWidget.ACTION_DETACH);
@@ -35,7 +35,7 @@ public class ComposerHeaderbar : PillHeaderbar {
detach_button.set_margin_right(6);
detach_start.pack_start(detach_button);
detach_start.pack_start(new Gtk.Separator(Gtk.Orientation.VERTICAL));
-
+
detach_end = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
detach_button = create_toolbar_button(null, ComposerWidget.ACTION_DETACH);
detach_button.set_relief(Gtk.ReliefStyle.NONE);
@@ -45,15 +45,15 @@ public class ComposerHeaderbar : PillHeaderbar {
detach_button.set_margin_left(6);
detach_end.pack_end(detach_button);
detach_end.pack_end(new Gtk.Separator(Gtk.Orientation.VERTICAL));
-
+
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_DISCARD));
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_SAVE));
Gtk.Box close_buttons = create_pill_buttons(insert, false);
insert.clear();
-
+
Gtk.Button send_button = create_toolbar_button(null, ComposerWidget.ACTION_SEND, true);
send_button.get_style_context().add_class("suggested-action");
-
+
Gtk.Box attach_buttons = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
Gtk.Button attach_only = create_toolbar_button(null, ComposerWidget.ACTION_ADD_ATTACHMENT);
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_ADD_ATTACHMENT));
@@ -61,14 +61,14 @@ public class ComposerHeaderbar : PillHeaderbar {
Gtk.Box attach_pending = create_pill_buttons(insert, false);
attach_buttons.pack_start(attach_only);
attach_buttons.pack_start(attach_pending);
-
+
recipients = new Gtk.Button();
recipients.set_relief(Gtk.ReliefStyle.NONE);
recipients_label = new Gtk.Label(null);
recipients_label.set_ellipsize(Pango.EllipsizeMode.END);
recipients.add(recipients_label);
recipients.clicked.connect(() => { state = ComposerWidget.ComposerState.INLINE; });
-
+
bind_property("state", recipients, "visible", BindingFlags.SYNC_CREATE,
(binding, source_value, ref target_value) => {
target_value = (state == ComposerWidget.ComposerState.INLINE_COMPACT);
@@ -79,7 +79,7 @@ public class ComposerHeaderbar : PillHeaderbar {
bind_property("show-pending-attachments", attach_pending, "visible",
BindingFlags.SYNC_CREATE);
bind_property("send-enabled", send_button, "sensitive", BindingFlags.SYNC_CREATE);
-
+
add_start(detach_start);
add_start(attach_buttons);
add_start(recipients);
@@ -88,20 +88,18 @@ public class ComposerHeaderbar : PillHeaderbar {
add_end(close_buttons);
add_end(detach_end);
#endif
- // Application button for when taking over main header bar. If we exported an app menu,
- // we don't need this.
- if (!Gtk.Settings.get_default().gtk_shell_shows_app_menu) {
- Gtk.Menu application_menu = new Gtk.Menu.from_model(
- GearyApplication.instance.controller.app_menu);
- Gtk.Button menu_button = create_menu_button(null, application_menu,
- ComposerWidget.ACTION_GEAR_MENU);
- add_end(menu_button);
- bind_property("state", menu_button, "visible", BindingFlags.SYNC_CREATE,
- (binding, source_value, ref target_value) => {
- target_value = (state == ComposerWidget.ComposerState.NEW);
- return true;
- });
- }
+
+ Gtk.MenuButton menu = new Gtk.MenuButton();
+ menu.image = new Gtk.Image.from_icon_name("open-menu", Gtk.IconSize.LARGE_TOOLBAR);
+ menu.popup = new Gtk.Menu.from_model(GearyApplication.instance.controller.app_menu);
+ menu.tooltip_text = _("Menu");
+
+ add_end(menu);
+ bind_property("state", menu, "visible", BindingFlags.SYNC_CREATE,
+ (binding, source_value, ref target_value) => {
+ target_value = (state == ComposerWidget.ComposerState.NEW);
+ return true;
+ });
#if GTK_3_12
add_end(detach_end);
add_end(close_buttons);
@@ -125,12 +123,12 @@ public class ComposerHeaderbar : PillHeaderbar {
}
});
}
-
+
public void set_recipients(string label, string tooltip) {
recipients_label.label = label;
recipients.tooltip_text = tooltip;
}
-
+
private void set_detach_button_side() {
bool at_end = close_button_at_end();
detach_start.visible = !at_end;
diff --git a/src/client/composer/composer-toolbar.vala b/src/client/composer/composer-toolbar.vala
index 3ae3983..2b22dd8 100644
--- a/src/client/composer/composer-toolbar.vala
+++ b/src/client/composer/composer-toolbar.vala
@@ -5,42 +5,44 @@
*/
public class ComposerToolbar : PillToolbar {
-
+
public string label_text { get; set; }
-
+
public ComposerToolbar(Gtk.ActionGroup toolbar_action_group, Gtk.Menu menu) {
base(toolbar_action_group);
-
+
Gee.List<Gtk.Button> insert = new Gee.ArrayList<Gtk.Button>();
-
+
// Font formatting.
insert.add(create_toggle_button(null, ComposerWidget.ACTION_BOLD));
insert.add(create_toggle_button(null, ComposerWidget.ACTION_ITALIC));
insert.add(create_toggle_button(null, ComposerWidget.ACTION_UNDERLINE));
insert.add(create_toggle_button(null, ComposerWidget.ACTION_STRIKETHROUGH));
add_start(create_pill_buttons(insert, false, true));
-
+
// Indent level.
insert.clear();
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_INDENT));
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_OUTDENT));
add_start(create_pill_buttons(insert, false));
-
+
// Link.
insert.clear();
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_INSERT_LINK));
add_start(create_pill_buttons(insert));
-
+
// Remove formatting.
insert.clear();
insert.add(create_toolbar_button(null, ComposerWidget.ACTION_REMOVE_FORMAT));
add_start(create_pill_buttons(insert));
-
+
// Menu.
- insert.clear();
- insert.add(create_menu_button(null, menu, ComposerWidget.ACTION_MENU));
- add_end(create_pill_buttons(insert));
-
+ Gtk.MenuButton more = new Gtk.MenuButton();
+ more.image = new Gtk.Image.from_icon_name("view-more-symbolic", Gtk.IconSize.MENU);
+ more.popup = menu;
+ more.tooltip_text = _("More options");
+ pack_end(more);
+
Gtk.Label label = new Gtk.Label(null);
label.get_style_context().add_class("dim-label");
bind_property("label-text", label, "label", BindingFlags.SYNC_CREATE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]