ibus/ibus-HEAD.patch

202 lines
6.7 KiB
Diff
Raw Normal View History

2012-03-18 09:41:41 +00:00
From fe1ec8a1b6f56ceda1f3f4bbb931cce29d946ed9 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
2012-03-18 09:41:41 +00:00
Date: Fri, 16 Mar 2012 21:00:28 +0900
Subject: [PATCH] Set the custom font in ui.gtk3.CandidatePanel.
---
2012-03-18 09:41:41 +00:00
ui/gtk3/candidatearea.vala | 23 +++++++++++++++++++++++
ui/gtk3/candidatepanel.vala | 19 +++++++++++++++++++
ui/gtk3/panel.vala | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+), 0 deletions(-)
2012-03-18 09:41:41 +00:00
diff --git a/ui/gtk3/candidatearea.vala b/ui/gtk3/candidatearea.vala
index 85a830d..5d0e8f7 100644
--- a/ui/gtk3/candidatearea.vala
+++ b/ui/gtk3/candidatearea.vala
@@ -33,6 +33,7 @@ class CandidateArea : Gtk.Box {
private IBus.Text[] m_ibus_candidates;
private uint m_focus_candidate;
private bool m_show_cursor;
+ private Pango.FontDescription m_font_desc;
2012-03-18 09:41:41 +00:00
private const string LABELS[] = {
"1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.",
@@ -240,6 +241,28 @@ class CandidateArea : Gtk.Box {
hbox.pack_start(prev_button, false, false, 0);
hbox.pack_start(next_button, false, false, 0);
}
+
+ udpate_label_font ();
+ }
+
+ private void udpate_label_font () {
+ for (int i = 0; i < m_labels.length; i++) {
+ m_labels[i].override_font(m_font_desc);
+ }
+
+ for (int i = 0; i < m_candidates.length; i++) {
+ m_candidates[i].override_font(m_font_desc);
+ }
+ }
+
+ public void set_custom_font(string? font_name) {
+ if (font_name == null) {
+ m_font_desc = null;
+ } else {
+ m_font_desc = Pango.FontDescription.from_string (font_name);
+ }
+
+ udpate_label_font ();
}
}
diff --git a/ui/gtk3/candidatepanel.vala b/ui/gtk3/candidatepanel.vala
index a029e8f..721db18 100644
--- a/ui/gtk3/candidatepanel.vala
+++ b/ui/gtk3/candidatepanel.vala
@@ -32,6 +32,7 @@ public class CandidatePanel : Gtk.HBox{
private Gtk.Label m_aux_label;
private CandidateArea m_candidate_area;
private HSeparator m_hseparator;
+ private Pango.FontDescription m_font_desc;
private Gdk.Rectangle m_cursor_location;
@@ -268,4 +269,22 @@ public class CandidatePanel : Gtk.HBox{
move(x, y);
}
+
+ public void set_custom_font(string? font_name) {
+ if (font_name == null) {
+ m_font_desc = null;
+ } else {
+ m_font_desc = Pango.FontDescription.from_string (font_name);
+ }
+
+ if (m_preedit_label != null) {
+ m_preedit_label.override_font(m_font_desc);
+ }
+
+ if (m_aux_label != null) {
+ m_aux_label.override_font(m_font_desc);
+ }
+
+ m_candidate_area.set_custom_font(font_name);
+ }
}
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index 53789d2..d927491 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -86,6 +86,36 @@ class Panel : IBus.PanelService {
keybinding_manager.unbind(ACCELERATOR_SWITCH_IME_BACKWARD);
}
2012-03-18 09:41:41 +00:00
+ private void set_custom_font() {
+ bool use_custom_font = false;
+ GLib.Variant var_use_custom_font = m_config.get_value("panel",
+ "use_custom_font");
+
+ if (var_use_custom_font != null) {
+ use_custom_font = var_use_custom_font.get_boolean();
+ }
+
+ if (use_custom_font == false) {
+ m_candidate_panel.set_custom_font(null);
+ return;
+ }
+
+ string font_name = null;
+ GLib.Variant var_custom_font = m_config.get_value("panel",
+ "custom_font");
+ if (var_custom_font != null) {
+ font_name = var_custom_font.dup_string();
+ }
+
+ if (font_name == null) {
+ GLib.Value value = GLib.Value(typeof(string));
+ Gtk.Settings.get_default().get_property("gtk-font-name", ref value);
+ font_name = value.dup_string();
+ }
+
+ m_candidate_panel.set_custom_font(font_name);
+ }
+
public void set_config(IBus.Config config) {
if (m_config != null) {
m_config.value_changed.disconnect(config_value_changed_cb);
@@ -98,11 +128,15 @@ class Panel : IBus.PanelService {
m_config.value_changed.connect(config_value_changed_cb);
m_config.watch("general", "preload_engines");
m_config.watch("general", "engines_order");
+ m_config.watch("panel", "custom_font");
+ m_config.watch("panel", "use_custom_font");
update_engines(m_config.get_value("general", "preload_engines"),
m_config.get_value("general", "engines_order"));
} else {
update_engines(null, null);
}
+
+ set_custom_font();
}
2012-03-18 09:41:41 +00:00
private void switch_engine(int i, bool force = false) {
@@ -150,6 +184,13 @@ class Panel : IBus.PanelService {
Variant variant) {
if (section == "general" && name == "preload_engines") {
update_engines(variant, null);
+ return;
+ }
+
+ if (section == "panel" && (name == "custom_font" ||
+ name == "use_custom_font")) {
+ set_custom_font();
+ return;
}
}
--
1.7.9.1
2012-03-04 13:45:32 +00:00
2012-03-18 09:41:41 +00:00
From 2ce9e82bd492d6addbd629955f9c0399753e8fa2 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
2012-03-18 09:41:41 +00:00
Date: Sun, 18 Mar 2012 18:14:06 +0900
Subject: [PATCH] Show language id on ibus-ui-gtk3.switcher window.
---
2012-03-18 09:41:41 +00:00
ui/gtk3/switcher.vala | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
2012-03-18 09:41:41 +00:00
index 131cad5..73b58d2 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
2012-03-18 09:41:41 +00:00
@@ -155,9 +155,22 @@ class Switcher : Gtk.Window {
for (int i = 0; i < m_engines.length; i++) {
var index = i;
var engine = m_engines[i];
- var button = new Gtk.Button.with_label(engine.get_longname());
+ var longname = engine.get_longname();
+ var language = engine.get_language();
+ var symbol = engine.get_symbol();
+ var id = language;
+
2012-03-18 09:41:41 +00:00
+ if (id.length > 2) {
+ id = id[0:2];
+ }
+ if (symbol.length != 0) {
+ id = symbol;
+ }
+ var label = "%-15s %s".printf(longname, id);
+ var button = new Gtk.Button.with_label(label);
button.set_image(new IconWidget(engine.get_icon(), width));
button.set_relief(Gtk.ReliefStyle.NONE);
+ button.set_alignment(1.0f, 0.0f);
button.show();
button.enter_notify_event.connect((e) => {
--
1.7.9.1