summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2012-11-06 17:31:55 +0900
committerDaiki Ueno <ueno@unixuser.org>2012-11-06 17:31:55 +0900
commit2ad1813370111608491e22e444bffe3607519652 (patch)
tree99041f963109430c21863564e174435a35c6bb32 /ui
parentebfb9ae7fe2af60f9c2b1c1bd56739316c01d097 (diff)
gtk3: use different prev/next icons depending on orientation
Use rotated icons for prev/next buttons on lookup table. BUG=none Review URL: https://codereview.appspot.com/6815080
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk3/candidatearea.vala43
1 files changed, 30 insertions, 13 deletions
diff --git a/ui/gtk3/candidatearea.vala b/ui/gtk3/candidatearea.vala
index 82e03a73..12ab42aa 100644
--- a/ui/gtk3/candidatearea.vala
+++ b/ui/gtk3/candidatearea.vala
@@ -35,6 +35,16 @@ class CandidateArea : Gtk.Box {
"9.", "0.", "a.", "b.", "c.", "d.", "e.", "f."
};
+ private const string PREV_PAGE_ICONS[] = {
+ Gtk.Stock.GO_BACK,
+ Gtk.Stock.GO_UP
+ };
+
+ private const string NEXT_PAGE_ICONS[] = {
+ Gtk.Stock.GO_FORWARD,
+ Gtk.Stock.GO_DOWN
+ };
+
public signal void candidate_clicked(uint index, uint button, uint state);
public signal void page_up();
public signal void page_down();
@@ -42,24 +52,27 @@ class CandidateArea : Gtk.Box {
public signal void cursor_down();
public CandidateArea(bool vertical) {
- GLib.Object(
- orientation: vertical ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL
- );
- m_vertical = vertical;
- recreate_ui();
- show_all();
+ GLib.Object();
+ set_vertical(vertical, true);
}
- public void set_vertical(bool vertical) {
- if (m_vertical == vertical)
+ public void set_vertical(bool vertical, bool force = false) {
+ if (!force && m_vertical == vertical)
return;
m_vertical = vertical;
+ orientation = vertical ?
+ Gtk.Orientation.VERTICAL :
+ Gtk.Orientation.HORIZONTAL;
recreate_ui();
- // Workaround a vala issue https://bugzilla.gnome.org/show_bug.cgi?id=661130
- set_candidates((owned)m_ibus_candidates, m_focus_candidate, m_show_cursor);
- if (m_candidates.length > 0)
+ if (m_ibus_candidates.length > 0) {
+ // Workaround a vala issue
+ // https://bugzilla.gnome.org/show_bug.cgi?id=661130
+ set_candidates((owned)m_ibus_candidates,
+ m_focus_candidate,
+ m_show_cursor);
show_all();
+ }
}
public void set_labels(IBus.Text[] labels) {
@@ -126,12 +139,16 @@ class CandidateArea : Gtk.Box {
Gtk.Button prev_button = new Gtk.Button();
prev_button.clicked.connect((b) => page_up());
- prev_button.set_image(new Gtk.Image.from_icon_name(Gtk.Stock.GO_UP, Gtk.IconSize.MENU));
+ prev_button.set_image(new Gtk.Image.from_stock(
+ PREV_PAGE_ICONS[orientation],
+ Gtk.IconSize.MENU));
prev_button.set_relief(Gtk.ReliefStyle.NONE);
Gtk.Button next_button = new Gtk.Button();
next_button.clicked.connect((b) => page_down());
- next_button.set_image(new Gtk.Image.from_icon_name(Gtk.Stock.GO_DOWN, Gtk.IconSize.MENU));
+ next_button.set_image(new Gtk.Image.from_stock(
+ NEXT_PAGE_ICONS[orientation],
+ Gtk.IconSize.MENU));
next_button.set_relief(Gtk.ReliefStyle.NONE);
if (m_vertical) {