Refactor object initialization

This commit is contained in:
Takao Fujiwara 2023-12-15 22:35:52 +09:00
parent b10672f7c8
commit 93ea339c0f
2 changed files with 218 additions and 1 deletions

View File

@ -1410,3 +1410,215 @@ index 1b62f656..600526e5 100644
--
2.41.0
From ac46d154e72fdc914e6d34ff1b251c8fcb70ce20 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 7 Dec 2023 20:34:49 +0900
Subject: [PATCH] Refactor object initialization
- client/wayland: Make sure IBusWaylandIM->ibuscontext is NULL
when IBusWaylandIM->context is NULL.
- configure: Set some default help messages.
- ui/gtk3: Make sure to call an error message if display is NULL.
---
client/wayland/ibuswaylandim.c | 10 ++++++----
configure.ac | 18 +++++++++---------
ui/gtk3/panel.vala | 5 +----
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/client/wayland/ibuswaylandim.c b/client/wayland/ibuswaylandim.c
index 9e8f651e..0430538f 100644
--- a/client/wayland/ibuswaylandim.c
+++ b/client/wayland/ibuswaylandim.c
@@ -115,6 +115,10 @@ struct wl_registry *_registry = NULL;
static gboolean _use_sync_mode = 1;
+static void input_method_deactivate
+ (void *data,
+ struct zwp_input_method_v1 *input_method,
+ struct zwp_input_method_context_v1 *context);
static GObject *ibus_wayland_im_constructor (GType type,
guint n_params,
GObjectConstructParam
@@ -1207,10 +1211,8 @@ input_method_activate (void *data,
g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
priv = ibus_wayland_im_get_instance_private (wlim);
- if (priv->context) {
- zwp_input_method_context_v1_destroy (priv->context);
- priv->context = NULL;
- }
+ if (priv->context)
+ input_method_deactivate (data, input_method, context);
priv->serial = 0;
priv->context = context;
diff --git a/configure.ac b/configure.ac
index 50b4a820..dc1410cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -233,7 +233,7 @@ AC_ARG_ENABLE(gtk4,
AS_HELP_STRING([--enable-gtk4],
[Build gtk4 im module]),
[enable_gtk4=$enableval],
- [enable_gtk4=no]
+ [enable_gtk4=yes]
)
AM_CONDITIONAL([ENABLE_GTK4], [test x"$enable_gtk4" = x"yes"])
@@ -276,8 +276,7 @@ if test x"$enable_gtk2" = x"yes"; then
gtk2_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
GTK2_IM_MODULEDIR="$libdir"/gtk-2.0/$gtk2_binary_version/immodules
-else
- enable_gtk2="no (disabled, use --enable-gtk2 to enable)"
+ enable_gtk2="yes (enabled, use --disable-gtk2 to disable)"
fi
if test x"$enable_gtk3" = x"yes"; then
@@ -297,7 +296,6 @@ if test x"$enable_gtk3" = x"yes"; then
gtk3_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
GTK3_IM_MODULEDIR="$libdir"/gtk-3.0/$gtk3_binary_version/immodules
else
- enable_gtk3="no (disabled, use --enable-gtk3 to enable)"
enable_gdk3_wayland=no
fi
if test x"$enable_gdk3_wayland" != x"yes"; then
@@ -313,8 +311,7 @@ if test x"$enable_gtk4" = x"yes"; then
gtk4_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk4`
GTK4_IM_MODULEDIR="$libdir"/gtk-4.0/$gtk4_binary_version/immodules
-else
- enable_gtk4="no (disabled, use --enable-gtk4 to enable)"
+ enable_gtk4="yes (enabled, use --disable-gtk4 to disable)"
fi
if test x"$enable_xim" = x"yes"; then
@@ -331,8 +328,10 @@ if test x"$enable_xim" = x"yes"; then
gtk+-2.0
])
fi
-else
- enable_xim="no (disabled, use --enable-xim to enable)"
+ enable_xim="yes (enabled, use --disable-xim to disable)"
+fi
+if test x"$enable_gtk3" = x"yes"; then
+ enable_gtk3="yes (enabled, use --disable-gtk3 to disable)"
fi
if $PKG_CONFIG --exists x11; then
@@ -363,8 +362,9 @@ if test x"$enable_wayland" = x"yes"; then
AC_SUBST(WAYLAND_PRTCLS_SUBDIR)
WAYLAND_SCANNER_RULES(['$(datadir)/$(WAYLAND_PRTCLS_SUBDIR)'])],
[AC_SUBST(wayland_scanner_rules)])
+ enable_wayland="yes (enabled, use --disable-wayland to disable)"
else
- enable_wayland="no (disabled, use --enable-wayland to enable)"
+ wayland_scanner_rules="./wayland-scanner.mk"
AC_SUBST(wayland_scanner_rules)
fi
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index 783ec842..233dd29c 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -111,10 +111,7 @@ class Panel : IBus.PanelService {
m_is_wayland_im = is_wayland_im;
#if USE_GDK_WAYLAND
- var display = Gdk.Display.get_default();
- Type instance_type = display.get_type();
- Type wayland_type = typeof(GdkWayland.Display);
- m_is_wayland = instance_type.is_a(wayland_type);
+ m_is_wayland = !BindingCommon.default_is_xdisplay();
#else
m_is_wayland = false;
warning("Checking Wayland is disabled");
--
2.41.0
From 8470873979e3435c29d98704f1ac7e1e47e9dc2f Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 14 Dec 2023 23:55:42 +0900
Subject: [PATCH] ui/gtk3: Fix some warnings
- Try to disable Vala warnings with gtk_menu_shell_insert() workaround.
- Stop string_slice() warning with different language lengths.
---
ui/gtk3/panel.vala | 17 ++++++++++-------
ui/gtk3/switcher.vala | 4 +++-
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index 233dd29c..aa9e8664 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -1433,7 +1433,8 @@ class Panel : IBus.PanelService {
item = new Gtk.MenuItem.with_label(_("Preferences"));
item.activate.connect((i) => show_setup_dialog());
- m_sys_menu.append(item);
+ // https://gitlab.gnome.org/GNOME/gtk/-/issues/5870
+ m_sys_menu.insert(item, -1);
#if EMOJI_DICT
item = new Gtk.MenuItem.with_label(_("Emoji Choice"));
@@ -1448,22 +1449,23 @@ class Panel : IBus.PanelService {
*/
panel_extension(event);
});
- m_sys_menu.append(item);
+ // https://gitlab.gnome.org/GNOME/gtk/-/issues/5870
+ m_sys_menu.insert(item, -1);
#endif
item = new Gtk.MenuItem.with_label(_("About"));
item.activate.connect((i) => show_about_dialog());
- m_sys_menu.append(item);
+ m_sys_menu.insert(item, -1);
- m_sys_menu.append(new Gtk.SeparatorMenuItem());
+ m_sys_menu.insert(new Gtk.SeparatorMenuItem(), -1);
item = new Gtk.MenuItem.with_label(_("Restart"));
item.activate.connect((i) => m_bus.exit(true));
- m_sys_menu.append(item);
+ m_sys_menu.insert(item, -1);
item = new Gtk.MenuItem.with_label(_("Quit"));
item.activate.connect((i) => m_bus.exit(false));
- m_sys_menu.append(item);
+ m_sys_menu.insert(item, -1);
m_sys_menu.show_all();
@@ -1488,7 +1490,8 @@ class Panel : IBus.PanelService {
// Show properties and IME switching menu
m_property_manager.create_menu_items(m_ime_menu);
- m_ime_menu.append(new Gtk.SeparatorMenuItem());
+ // https://gitlab.gnome.org/GNOME/gtk/-/issues/5870
+ m_ime_menu.insert(new Gtk.SeparatorMenuItem(), -1);
// Append IMEs
foreach (var engine in m_engines) {
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
index e3fab8d9..26bded99 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
@@ -592,7 +592,9 @@ class Switcher : Gtk.Window {
int index = 0;
foreach (var saved_language in m_xkb_languages.get_values()) {
- if (language == saved_language[0:length])
+ // Duplicated langauge is EN, EN_2 for E.G.
+ if (length <= saved_language.length &&
+ language == saved_language[0:length])
index++;
}
--
2.41.0

View File

@ -58,7 +58,7 @@
Name: ibus
Version: 1.5.29~rc2
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@ -365,6 +365,7 @@ autoreconf -f -i -v
--enable-introspection \
--enable-install-tests \
%{nil}
make -C ui/gtk3 maintainer-clean-generic
%make_build
@ -580,6 +581,10 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Fri Dec 15 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc2-5
- Refactor object initialization
- Fix some warnings
* Tue Dec 05 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc2-4
- Complete preedit signals for PostProcessKeyEvent