summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2016-06-03 19:44:11 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2016-06-03 19:44:11 +0900
commita598ae29223d1ca25e76bf7d7de9703f63ea337e (patch)
tree4e5edc22e880877d871a78a35a4bec812c7e0049
parent3ef21fef0135f7b4fe9611d201f15611734f6c51 (diff)
downloadibus-a598ae29223d1ca25e76bf7d7de9703f63ea337e.tar.gz
ui/gtk3: Fix panel CSS format for GTK 3.20
CSS node names have been changed since GTK 3.20 and the font size and widget color no longer work with the previous node names. BUG=https://github.com/ibus/ibus/issues/1856 Review URL: https://codereview.appspot.com/297380043
-rw-r--r--ui/gtk3/candidatearea.vala16
-rw-r--r--ui/gtk3/handle.vala10
-rw-r--r--ui/gtk3/panel.vala9
3 files changed, 28 insertions, 7 deletions
diff --git a/ui/gtk3/candidatearea.vala b/ui/gtk3/candidatearea.vala
index c969312f..3848f0d8 100644
--- a/ui/gtk3/candidatearea.vala
+++ b/ui/gtk3/candidatearea.vala
@@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2015 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright(c) 2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright(c) 2015-2016 Takao Fujiwara <takao.fujiwara1@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,10 @@ class CandidateArea : Gtk.Box {
private uint m_focus_candidate;
private bool m_show_cursor;
+ private bool m_use_latest_css_format =
+ ((Gtk.MAJOR_VERSION > 3) ||
+ (Gtk.MAJOR_VERSION == 3) && (Gtk.MINOR_VERSION >= 20));
+
private const string LABELS[] = {
"1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.",
"9.", "0.", "a.", "b.", "c.", "d.", "e.", "f."
@@ -103,7 +107,8 @@ class CandidateArea : Gtk.Box {
Pango.AttrList attrs = get_pango_attr_list_from_ibus_text(candidates[i]);
if (i == focus_candidate && show_cursor) {
Gtk.StyleContext context = m_candidates[i].get_style_context();
- Gdk.RGBA color = context.get_color(Gtk.StateFlags.SELECTED);
+ Gdk.RGBA *color = null;
+ context.get(Gtk.StateFlags.SELECTED, "color", out color);
Pango.Attribute pango_attr = Pango.attr_foreground_new(
(uint16)(color.red * uint16.MAX),
(uint16)(color.green * uint16.MAX),
@@ -112,7 +117,12 @@ class CandidateArea : Gtk.Box {
pango_attr.end_index = candidates[i].get_text().length;
attrs.insert((owned)pango_attr);
- color = context.get_background_color(Gtk.StateFlags.SELECTED);
+ color = null;
+ string bg_prop =
+ m_use_latest_css_format
+ ? "-gtk-secondary-caret-color"
+ : "background-color";
+ context.get(Gtk.StateFlags.SELECTED, bg_prop, out color);
pango_attr = Pango.attr_background_new(
(uint16)(color.red * uint16.MAX),
(uint16)(color.green * uint16.MAX),
diff --git a/ui/gtk3/handle.vala b/ui/gtk3/handle.vala
index 1edb5373..bef5e8ba 100644
--- a/ui/gtk3/handle.vala
+++ b/ui/gtk3/handle.vala
@@ -2,7 +2,8 @@
*
* ibus - The Input Bus
*
- * Copyright(c) 2011-2015 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright(c) 2011-2016 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright(c) 2016 Takao Fujiwara <takao.fujiwara1@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -29,6 +30,11 @@ class Handle : Gtk.EventBox {
public signal void move_end();
public Handle() {
+ // Call base class constructor
+ GLib.Object(
+ name : "IBusHandle"
+ );
+
set_size_request(6, -1);
Gdk.EventMask mask = Gdk.EventMask.EXPOSURE_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK |
@@ -42,7 +48,7 @@ class Handle : Gtk.EventBox {
Gtk.CssProvider css_provider = new Gtk.CssProvider();
try {
css_provider.load_from_data(
- "GtkEventBox { background-color: gray }", -1);
+ "#IBusHandle { background-color: gray }", -1);
} catch (GLib.Error error) {
warning("Parse error in Handle: %s", error.message);
}
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index 2ca3a5ef..cc19350b 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2014 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright(c) 2015 Takao Fujwiara <takao.fujiwara1@gmail.com>
+ * Copyright(c) 2015-2016 Takao Fujwiara <takao.fujiwara1@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -543,7 +543,12 @@ class Panel : IBus.PanelService {
return;
}
- string data_format = "GtkLabel { font: %s; }";
+ string data_format = "label { font: %s; }";
+ if (Gtk.MAJOR_VERSION < 3 ||
+ (Gtk.MAJOR_VERSION == 3 && Gtk.MINOR_VERSION < 20)) {
+ data_format = "GtkLabel { font: %s; }";
+ }
+
string data = data_format.printf(font_name);
m_css_provider = new Gtk.CssProvider();