1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
From b9ae4c57de95a7d73640cce5776540d8d841b0c2 Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Fri, 6 May 2022 16:16:30 +0900
Subject: [PATCH] renderer: Convert Gtk2 to Gtk3
Description: renderer: Convert Gtk2 to Gtk3
Forwarded: Not need
Last-Update: 2022-05-07
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
src/renderer/mozc_renderer_main.cc | 2 +-
src/renderer/renderer.gyp | 7 +++----
src/renderer/unix/candidate_window.cc | 4 ++--
src/renderer/unix/gtk_wrapper.cc | 4 ++--
src/renderer/unix/infolist_window.cc | 4 ++--
src/renderer/unix/pango_wrapper.cc | 15 +++------------
src/renderer/unix/pango_wrapper.h | 3 +--
src/renderer/unix/text_renderer.cc | 5 ++---
src/renderer/unix/text_renderer.h | 3 +--
src/renderer/unix/text_renderer_interface.h | 2 +-
10 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/src/renderer/mozc_renderer_main.cc b/src/renderer/mozc_renderer_main.cc
index 85a0ae10..3b596d67 100644
--- a/src/renderer/mozc_renderer_main.cc
+++ b/src/renderer/mozc_renderer_main.cc
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
#ifdef OS_WIN
mozc::ScopedCOMInitializer com_initializer;
#elif defined(ENABLE_GTK_RENDERER)
- gtk_set_locale();
+ setlocale(LC_ALL, "");
#if !GLIB_CHECK_VERSION(2, 31, 0)
// There are not g_thread_init function in glib>=2.31.0.
// http://developer.gnome.org/glib/2.31/glib-Deprecated-Thread-APIs.html#g-thread-init
diff --git a/src/renderer/renderer.gyp b/src/renderer/renderer.gyp
index 78eb6a75..34141a4a 100644
--- a/src/renderer/renderer.gyp
+++ b/src/renderer/renderer.gyp
@@ -532,15 +532,14 @@
# Required 'cflags' and 'link_settings' will be automatically
# injected into any target which directly or indirectly depends
# on this target.
- 'target_name': 'gtk2_build_environment',
+ 'target_name': 'gtk3_build_environment',
'type': 'none',
'variables': {
'target_pkgs' : [
'glib-2.0',
'gobject-2.0',
'gthread-2.0',
- 'gtk+-2.0',
- 'gdk-2.0',
+ 'gtk+-3.0',
],
},
'all_dependent_settings': {
@@ -583,7 +582,7 @@
'../ipc/ipc.gyp:ipc',
'../protocol/protocol.gyp:genproto_config_proto#host',
'../protocol/protocol.gyp:renderer_proto',
- 'gtk2_build_environment',
+ 'gtk3_build_environment',
'renderer_server',
'renderer_style_handler',
'table_layout',
diff --git a/src/renderer/unix/candidate_window.cc b/src/renderer/unix/candidate_window.cc
index bb0a346b..287f6871 100644
--- a/src/renderer/unix/candidate_window.cc
+++ b/src/renderer/unix/candidate_window.cc
@@ -85,7 +85,7 @@ CandidateWindow::CandidateWindow(TableLayoutInterface *table_layout,
bool CandidateWindow::OnPaint(GtkWidget *widget, GdkEventExpose *event) {
draw_tool_->Reset(
- cairo_factory_->CreateCairoInstance(GetCanvasWidget()->window));
+ cairo_factory_->CreateCairoInstance(gtk_widget_get_window(GetCanvasWidget())));
DrawBackground();
DrawShortcutBackground();
@@ -263,7 +263,7 @@ void CandidateWindow::DrawFrame() {
}
void CandidateWindow::Initialize() {
- text_renderer_->Initialize(GetCanvasWidget()->window);
+ text_renderer_->Initialize(GetCanvasWidget());
}
void CandidateWindow::UpdateScrollBarSize() {
diff --git a/src/renderer/unix/gtk_wrapper.cc b/src/renderer/unix/gtk_wrapper.cc
index 83d206d7..92c5483f 100644
--- a/src/renderer/unix/gtk_wrapper.cc
+++ b/src/renderer/unix/gtk_wrapper.cc
@@ -49,7 +49,7 @@ void GtkWrapper::GSignalConnect(gpointer instance, const gchar *signal,
}
void GtkWrapper::GtkWidgetHideAll(GtkWidget *widget) {
- gtk_widget_hide_all(widget);
+ gtk_widget_hide(widget);
}
void GtkWrapper::GtkWidgetShowAll(GtkWidget *widget) {
@@ -135,7 +135,7 @@ void GtkWrapper::GtkWidgetRealize(GtkWidget *widget) {
void GtkWrapper::GdkWindowSetTypeHint(GtkWidget *widget,
GdkWindowTypeHint hint) {
- gdk_window_set_type_hint(widget->window, hint);
+ gdk_window_set_type_hint(gtk_widget_get_window(widget), hint);
}
} // namespace gtk
diff --git a/src/renderer/unix/infolist_window.cc b/src/renderer/unix/infolist_window.cc
index 253f9659..f76f4c93 100644
--- a/src/renderer/unix/infolist_window.cc
+++ b/src/renderer/unix/infolist_window.cc
@@ -100,7 +100,7 @@ Rect InfolistWindow::GetCandidateColumnInClientCord() const {
bool InfolistWindow::OnPaint(GtkWidget *widget, GdkEventExpose *event) {
draw_tool_->Reset(
- cairo_factory_->CreateCairoInstance(GetCanvasWidget()->window));
+ cairo_factory_->CreateCairoInstance(gtk_widget_get_window(GetCanvasWidget())));
Draw();
return true;
}
@@ -237,7 +237,7 @@ int InfolistWindow::DrawRow(int row, int ypos) {
}
void InfolistWindow::Initialize() {
- text_renderer_->Initialize(GetCanvasWidget()->window);
+ text_renderer_->Initialize(GetCanvasWidget());
}
void InfolistWindow::ReloadFontConfig(const std::string &font_description) {
diff --git a/src/renderer/unix/pango_wrapper.cc b/src/renderer/unix/pango_wrapper.cc
index 8f87699a..545072a3 100644
--- a/src/renderer/unix/pango_wrapper.cc
+++ b/src/renderer/unix/pango_wrapper.cc
@@ -88,21 +88,12 @@ void PangoWrapper::AttributesUnref(PangoAttrList *attribute) {
PangoContext *PangoWrapper::GetContext() { return context_; }
-PangoWrapper::PangoWrapper(GdkDrawable *drawable) : gc_(gdk_gc_new(drawable)) {
- GdkScreen *screen = gdk_drawable_get_screen(drawable);
- renderer_ = gdk_pango_renderer_new(screen);
- gdk_pango_renderer_set_drawable(GDK_PANGO_RENDERER(renderer_), drawable);
- gdk_pango_renderer_set_gc(GDK_PANGO_RENDERER(renderer_), gc_);
- context_ = gdk_pango_context_get();
+PangoWrapper::PangoWrapper(GtkWidget *window) {
+ context_ = gtk_widget_get_pango_context(window);
}
PangoWrapper::~PangoWrapper() {
- gdk_pango_renderer_set_override_color(GDK_PANGO_RENDERER(renderer_),
- PANGO_RENDER_PART_FOREGROUND, nullptr);
- gdk_pango_renderer_set_drawable(GDK_PANGO_RENDERER(renderer_), nullptr);
- gdk_pango_renderer_set_gc(GDK_PANGO_RENDERER(renderer_), nullptr);
- g_object_unref(gc_);
- g_object_unref(context_);
+ g_object_unref(G_OBJECT(context_));
}
} // namespace gtk
diff --git a/src/renderer/unix/pango_wrapper.h b/src/renderer/unix/pango_wrapper.h
index 7c41cc54..c7c7fb04 100644
--- a/src/renderer/unix/pango_wrapper.h
+++ b/src/renderer/unix/pango_wrapper.h
@@ -57,7 +57,7 @@ class PangoLayoutWrapper : public PangoLayoutWrapperInterface {
class PangoWrapper : public PangoWrapperInterface {
public:
- explicit PangoWrapper(GdkDrawable *drawable);
+ explicit PangoWrapper(GtkWidget *window);
virtual ~PangoWrapper();
virtual void RendererDrawLayout(PangoLayoutWrapperInterface *layout, int x,
int y);
@@ -68,7 +68,6 @@ class PangoWrapper : public PangoWrapperInterface {
private:
PangoRenderer *renderer_;
PangoContext *context_;
- GdkGC *gc_;
DISALLOW_COPY_AND_ASSIGN(PangoWrapper);
};
} // namespace gtk
diff --git a/src/renderer/unix/text_renderer.cc b/src/renderer/unix/text_renderer.cc
index 164f01bc..4ba96ea2 100644
--- a/src/renderer/unix/text_renderer.cc
+++ b/src/renderer/unix/text_renderer.cc
@@ -39,9 +39,8 @@ namespace gtk {
TextRenderer::TextRenderer(FontSpecInterface *font_spec)
: font_spec_(font_spec), pango_(nullptr) {}
-
-void TextRenderer::Initialize(GdkDrawable *drawable) {
- pango_.reset(new PangoWrapper(drawable));
+void TextRenderer::Initialize(GtkWidget *window) {
+ pango_.reset(new PangoWrapper(window));
}
void TextRenderer::SetUpPangoLayout(const std::string &str,
diff --git a/src/renderer/unix/text_renderer.h b/src/renderer/unix/text_renderer.h
index c4cd2430..ba36b052 100644
--- a/src/renderer/unix/text_renderer.h
+++ b/src/renderer/unix/text_renderer.h
@@ -50,8 +50,7 @@ class TextRenderer : public TextRendererInterface {
public:
explicit TextRenderer(FontSpecInterface *font_spec);
virtual ~TextRenderer() {}
-
- virtual void Initialize(GdkDrawable *drawable);
+ virtual void Initialize(GtkWidget *window);
virtual Size GetPixelSize(FontSpecInterface::FONT_TYPE font_type,
const std::string &str);
virtual Size GetMultiLinePixelSize(FontSpecInterface::FONT_TYPE font_type,
diff --git a/src/renderer/unix/text_renderer_interface.h b/src/renderer/unix/text_renderer_interface.h
index db823217..9c569f6a 100644
--- a/src/renderer/unix/text_renderer_interface.h
+++ b/src/renderer/unix/text_renderer_interface.h
@@ -44,7 +44,7 @@ class TextRendererInterface {
TextRendererInterface() {}
virtual ~TextRendererInterface() {}
- virtual void Initialize(GdkDrawable *drawable) = 0;
+ virtual void Initialize(GtkWidget *window) = 0;
// Returns boundary rectangle size of actual rendered text.
virtual Size GetPixelSize(FontSpecInterface::FONT_TYPE font_type,
const std::string &str) = 0;
--
2.36.0
|