private uint m_focus_candidate;
private bool m_show_cursor;
+ private const string LABELS[] = {
+ "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.",
+ "9.", "0.", "a.", "b.", "c.", "d.", "e.", "f."
+ };
+
public signal void candidate_clicked(uint index, uint button, uint state);
public signal void page_up();
public signal void page_down();
show_all();
}
- public void set_labels(string[] labels) {
- if (labels == null) {
- const string labels[] = {
- "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.",
- "9.", "0.", "a.", "b.", "c.", "d.", "e.", "f."
- };
- for (int i = 0 ; i < 16; i++)
- m_labels[i].set_text(labels[i]);
- } else {
- int i = 0;
- foreach (string label in labels)
- m_labels[i].set_text(label);
- }
+ public void set_labels(IBus.Text[] labels) {
+ int i;
+ for (i = 0; i < int.min(16, labels.length); i++)
+ m_labels[i].set_text(labels[i].get_text());
+ for (; i < 16; i++)
+ m_labels[i].set_text(LABELS[i]);
}
public void set_candidates(IBus.Text[] candidates,
w.destroy();
}
- const string labels[] = {
- "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.",
- "9.", "0.", "a.", "b.", "c.", "d.", "e.", "f."
- };
-
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));
m_candidates = {};
m_widgets = {};
for (int i = 0; i < 16; i++) {
- Gtk.Label label = new Gtk.Label(labels[i]);
+ Gtk.Label label = new Gtk.Label(LABELS[i]);
label.set_alignment(0.0f, 0.5f);
label.show();
m_labels += label;
m_candidates = {};
m_widgets = {};
for (int i = 0; i < 16; i++) {
- Gtk.Label label = new Gtk.Label(labels[i]);
+ Gtk.Label label = new Gtk.Label(LABELS[i]);
label.set_alignment(0.0f, 0.5f);
label.show();
m_labels += label;
m_candidate_area.set_vertical(vertical);
}
+ private void set_orientation(IBus.Orientation orientation) {
+ switch (orientation) {
+ case IBus.Orientation.VERTICAL:
+ m_candidate_area.set_vertical(true);
+ break;
+ case IBus.Orientation.HORIZONTAL:
+ m_candidate_area.set_vertical(false);
+ break;
+ case IBus.Orientation.SYSTEM:
+ m_candidate_area.set_vertical(m_vertical);
+ break;
+ }
+ }
+
public void set_cursor_location(int x, int y, int width, int height) {
Gdk.Rectangle location = Gdk.Rectangle(){
x = x, y = y, width = width, height = height };
adjust_window_position();
}
- public void set_labels(string[] labels) {
+ private void set_labels(IBus.Text[] labels) {
m_candidate_area.set_labels(labels);
}
IBus.Text[] candidates = {};
uint cursor_in_page = 0;
bool show_cursor = true;
+ IBus.Text[] labels = {};
+ IBus.Orientation orientation = IBus.Orientation.SYSTEM;
if (table != null) {
uint page_size = table.get_page_size();
uint page_end_pos = uint.min(page_start_pos + page_size, ncandidates);
for (uint i = page_start_pos; i < page_end_pos; i++)
candidates += table.get_candidate(i);
+
+ for (uint i = 0; i < page_size; i++) {
+ IBus.Text? label = table.get_label(i);
+ if (label != null)
+ labels += label;
+ }
+
+ orientation = (IBus.Orientation)table.get_orientation();
}
m_candidate_area.set_candidates(candidates, cursor_in_page, show_cursor);
+ set_labels(labels);
+ set_orientation(orientation);
+
if (candidates.length != 0)
m_candidate_area.show_all();
else