[california] Use symbolic icons instead of text labels in popover buttons
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Use symbolic icons instead of text labels in popover buttons
- Date: Thu, 21 Aug 2014 01:03:20 +0000 (UTC)
commit a9bceb09767f554729df83af3872cf1ce96612dd
Author: Jim Nelson <jim yorba org>
Date: Wed Aug 20 16:48:18 2014 -0700
Use symbolic icons instead of text labels in popover buttons
src/host/host-quick-create-event.vala | 6 ++
src/host/host-show-event.vala | 22 ++++--
src/rc/quick-create-event.ui | 105 ++++++++++++++++++--------
src/toolkit/toolkit-rotating-button-box.vala | 56 ++++++++------
4 files changed, 126 insertions(+), 63 deletions(-)
---
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index fe7a89a..a721dda 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -38,6 +38,9 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
private Gtk.ComboBoxText calendar_combo_box;
[GtkChild]
+ private Gtk.Box action_button_box;
+
+ [GtkChild]
private Gtk.Button create_button;
private Toolkit.ComboBoxTextModel<Backing.CalendarSource> model;
@@ -56,6 +59,9 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
clear_text_connector.connect_to(details_entry);
details_entry.bind_property("text", create_button, "sensitive", BindingFlags.SYNC_CREATE,
transform_text_to_sensitivity);
+
+ action_button_box.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
+ action_button_box.get_style_context().add_class(Gtk.STYLE_CLASS_RAISED);
}
private bool transform_text_to_sensitivity(Binding binding, Value source_value, ref Value target_value) {
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 2bd4534..399fe49 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -61,8 +61,12 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
private Toolkit.RotatingButtonBox rotating_button_box = new Toolkit.RotatingButtonBox();
- private Gtk.Button update_button = new Gtk.Button.with_mnemonic(_("_Edit"));
- private Gtk.Button remove_button = new Gtk.Button.with_mnemonic(_("_Delete"));
+ private Gtk.Box action_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
+ private Gtk.Button update_button = new Gtk.Button.from_icon_name("accessories-text-editor-symbolic",
+ Gtk.IconSize.BUTTON);
+ private Gtk.Button remove_button = new Gtk.Button.from_icon_name("list-remove-symbolic",
+ Gtk.IconSize.BUTTON);
+
private Gtk.Label delete_label = new Gtk.Label(_("Delete"));
private Gtk.Button remove_all_button = new Gtk.Button.with_mnemonic(_("A_ll Events"));
private Gtk.Button remove_this_button = new Gtk.Button.with_mnemonic(_("_This Event"));
@@ -74,6 +78,14 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
Calendar.System.instance.is_24hr_changed.connect(build_display);
Calendar.System.instance.today_changed.connect(build_display);
+ update_button.tooltip_text = _("Edit event");
+ remove_button.tooltip_text = _("Delete event");
+
+ action_box.pack_end(update_button, false, false);
+ action_box.pack_end(remove_button, false, false);
+ action_box.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
+ action_box.get_style_context().add_class(Gtk.STYLE_CLASS_RAISED);
+
remove_button.get_style_context().add_class("destructive-action");
remove_this_button.get_style_context().add_class("destructive-action");
remove_this_future_button.get_style_context().add_class("destructive-action");
@@ -86,8 +98,7 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
remove_this_future_button.clicked.connect(on_remove_future_button_clicked);
cancel_remove_button.clicked.connect(on_cancel_remove_recurring_button_clicked);
- rotating_button_box.pack_end(FAMILY_NORMAL, remove_button);
- rotating_button_box.pack_end(FAMILY_NORMAL, update_button);
+ rotating_button_box.pack_end(FAMILY_NORMAL, action_box, false, true);
delete_label.xalign = 1.0f;
delete_label.get_style_context().add_class(Gtk.STYLE_CLASS_DIM_LABEL);
@@ -99,8 +110,7 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
rotating_button_box.get_family_container(FAMILY_REMOVING).homogeneous = false;
- rotating_button_box.expand = true;
- rotating_button_box.halign = Gtk.Align.FILL;
+ rotating_button_box.vexpand = true;
rotating_button_box.valign = Gtk.Align.END;
rotating_button_box_container.add(rotating_button_box);
}
diff --git a/src/rc/quick-create-event.ui b/src/rc/quick-create-event.ui
index d310c07..24cd1b3 100644
--- a/src/rc/quick-create-event.ui
+++ b/src/rc/quick-create-event.ui
@@ -142,64 +142,105 @@
</packing>
</child>
<child>
- <object class="GtkButtonBox" id="buttonbox1">
+ <object class="GtkBox" id="button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
<property name="margin_top">8</property>
<property name="vexpand">True</property>
<property name="spacing">8</property>
- <property name="homogeneous">True</property>
- <property name="layout_style">end</property>
<child>
<object class="GtkButton" id="help_button">
- <property name="label" translatable="yes">_Help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Quick Add help</property>
+ <property name="halign">start</property>
+ <property name="relief">none</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_help_button_clicked" object="CaliforniaHostQuickCreateEvent"
swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="icon_name">help</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
- <property name="secondary">True</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="edit_button">
- <property name="label" translatable="yes">_Edit</property>
+ <object class="GtkBox" id="action_button_box">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_edit_button_clicked" object="CaliforniaHostQuickCreateEvent"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="create_button">
- <property name="label" translatable="yes">_Create</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_create_button_clicked"
object="CaliforniaHostQuickCreateEvent" swapped="no"/>
- <style>
- <class name="suggested-action"/>
- </style>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="edit_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Edit event details</property>
+ <property name="halign">end</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_edit_button_clicked"
object="CaliforniaHostQuickCreateEvent" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="icon_name">accessories-text-editor-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="create_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Create event</property>
+ <property name="halign">end</property>
+ <property name="hexpand">False</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_create_button_clicked"
object="CaliforniaHostQuickCreateEvent" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="icon_name">list-add-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/src/toolkit/toolkit-rotating-button-box.vala b/src/toolkit/toolkit-rotating-button-box.vala
index 07a5f53..8121fb0 100644
--- a/src/toolkit/toolkit-rotating-button-box.vala
+++ b/src/toolkit/toolkit-rotating-button-box.vala
@@ -24,7 +24,6 @@ public class RotatingButtonBox : Gtk.Stack {
public const string PROP_FAMILY = "family";
public Gtk.Orientation ORIENTATION = Gtk.Orientation.HORIZONTAL;
- public Gtk.ButtonBoxStyle LAYOUT_STYLE = Gtk.ButtonBoxStyle.END;
public int SPACING = 8;
/**
@@ -32,7 +31,7 @@ public class RotatingButtonBox : Gtk.Stack {
*/
public string? family { get; set; }
- private Gee.HashMap<string, Gtk.ButtonBox> button_boxes = new Gee.HashMap<string, Gtk.ButtonBox>();
+ private Gee.HashMap<string, Gtk.Box> boxes = new Gee.HashMap<string, Gtk.Box>();
private Gtk.Popover? parent_popover = null;
private bool parent_popover_modal = false;
@@ -70,44 +69,51 @@ public class RotatingButtonBox : Gtk.Stack {
}
/**
- * Pack a Gtk.Button at the start of a particular family, creating the family if necessary.
+ * Pack a Gtk.Widget at the start of a particular family, creating the family if necessary.
*
* See Gtk.Box.pack_start().
*/
- public void pack_start(string family, Gtk.Widget widget) {
- get_family_container(family).pack_start(widget);
+ public void pack_start(string family, Gtk.Widget widget, bool expand = true, bool fill = true,
+ int padding = 0) {
+ get_family_container(family).pack_start(widget, expand, fill, padding);
}
/**
- * Pack a Gtk.Button at the end of a particular family, creating the family if necessary.
+ * Pack a Gtk.Widget at the end of a particular family, creating the family if necessary.
*
* See Gtk.Box.pack_end().
*/
- public void pack_end(string family, Gtk.Widget widget) {
- get_family_container(family).pack_end(widget);
+ public void pack_end(string family, Gtk.Widget widget, bool expand = true, bool fill = true,
+ int padding = 0) {
+ get_family_container(family).pack_end(widget, expand, fill, padding);
}
/**
- * Direct access to the Gtk.ButtonBox holding the named family.
+ * Direct access to the Gtk.Box holding the named family.
*
* If the family doesn't exist, it will be created.
*/
- public Gtk.ButtonBox get_family_container(string family) {
- if (button_boxes.has_key(family))
- return button_boxes.get(family);
+ public Gtk.Box get_family_container(string family) {
+ if (boxes.has_key(family))
+ return boxes.get(family);
- // create new family of buttons
- Gtk.ButtonBox button_box = new Gtk.ButtonBox(ORIENTATION);
- button_box.layout_style = LAYOUT_STYLE;
- button_box.spacing = SPACING;
+ // create new family ... this widget is currently hardcoded for boxes grouping
+ // their children at the horizontal end, more work would need to be done to make
+ // this a general purpose widget
+ Gtk.Box box = new Gtk.ButtonBox(ORIENTATION);
+ box.expand = true;
+ box.halign = Gtk.Align.END;
+ box.valign = Gtk.Align.END;
+ box.spacing = SPACING;
+ box.homogeneous = false;
// add to internal lookup
- button_boxes.set(family, button_box);
+ boxes.set(family, box);
// add to Gtk.Stack using the family name
- add_named(button_box, family);
+ add_named(box, family);
- return button_box;
+ return box;
}
/**
@@ -117,14 +123,14 @@ public class RotatingButtonBox : Gtk.Stack {
* widget heirarchy. This is useful for sizing purposes.
*/
public void show_hide_family(string family, bool show) {
- if (!button_boxes.has_key(family))
+ if (!boxes.has_key(family))
return;
- Gtk.ButtonBox button_box = button_boxes.get(family);
+ Gtk.Box box = boxes.get(family);
bool shown = false;
- foreach (Gtk.Widget widget in get_children()) {
- if (widget == button_box) {
+ foreach (Gtk.Widget widget in get_children()) {
+ if (widget == box) {
shown = true;
break;
@@ -132,9 +138,9 @@ public class RotatingButtonBox : Gtk.Stack {
}
if (show && !shown)
- add_named(button_box, family);
+ add_named(box, family);
else if (!show && shown)
- remove(button_box);
+ remove(box);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]