0008-renderer-Convert-Gtk2-to-Gtk3.patch 9.0 KB

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