Skip to content

Commit

Permalink
Fix deprecated APIs
Browse files Browse the repository at this point in the history
- Fix deprecated gtk_misc_set_padding(), gtk_widget_set_margin_left(),
  gtk_widget_set_margin_right() in emojilang.py, enginedialog.py,
  setup.ui, candidatearea.vala, candidatepanel.vala, switcher.vala
  since GTK 3.12

- Fix g_new0() argument 1 range [18446744071562067968, 18446744073709551615]
  exceeds maximum object size 9223372036854775807
  [-Walloc-size-larger-than=] by adding g_assert() in ibuscomposetable.c

- Fix gdk_keymap_get_default() with gdk_keymap_get_for_display() in
  bindingcommon.vala

- Fix string.utf8_offset() with string.next_char() in emojier.vala

- Fix Posix.SIGUSR1 with Posix.Signal.USR1 in panel.vala
  • Loading branch information
fujiwarat committed Oct 30, 2019
1 parent 17f8a86 commit 35863d8
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 53 deletions.
1 change: 1 addition & 0 deletions bus/ibusimpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,7 @@ bus_ibus_impl_registry_destroy (BusIBusImpl *ibus)

g_clear_pointer (&ibus->engine_table, g_hash_table_destroy);

/* g_clear_pointer() does not set the cast. */
ibus_object_destroy (IBUS_OBJECT (ibus->registry));
ibus->registry = NULL;

Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ m4_define([ibus_binary_version],

# Required versions of other packages.
m4_define([glib_required_version], [2.46.0])
m4_define([gtk3_required_version], [3.12.0])

# VALA_TARGET_GLIB_VERSION is used by valac --ccode --target-glib .
# VALA_TARGET_GLIB_VERSION and glib_required_version will be different
Expand Down Expand Up @@ -238,7 +239,7 @@ fi
if test x"$enable_gtk3" = x"yes"; then
# check for gtk3
PKG_CHECK_MODULES(GTK3, [
gtk+-3.0
gtk+-3.0 >= gtk3_required_version
])
PKG_CHECK_EXISTS([gdk-wayland-3.0],
[enable_gdk3_wayland=yes],
Expand Down
14 changes: 7 additions & 7 deletions setup/emojilang.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# ibus - The Input Bus
#
# Copyright (c) 2017 Takao Fujiwara <[email protected]>
# Copyright (c) 2017-2019 Takao Fujiwara <[email protected]>
# Copyright (c) 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -83,8 +83,8 @@ def __init__(self, id = None, transient_for = None):
hscrollbar_policy = Gtk.PolicyType.NEVER,
vscrollbar_policy = Gtk.PolicyType.NEVER,
shadow_type = Gtk.ShadowType.IN,
margin_left = 6,
margin_right = 6,
margin_start = 6,
margin_end = 6,
margin_top = 6,
margin_bottom = 6)
self.vbox.add(self.__scrolled)
Expand Down Expand Up @@ -192,8 +192,8 @@ def __padded_label_new(self, text, icon, alignment, direction):
label = Gtk.Label(label = text)
label.set_halign(alignment)
label.set_valign(Gtk.Align.CENTER)
label.set_margin_left(20)
label.set_margin_right(20)
label.set_margin_start(20)
label.set_margin_end(20)
label.set_margin_top(6)
label.set_margin_bottom(6)
hbox.pack_start(label, True, True, 0)
Expand Down Expand Up @@ -235,8 +235,8 @@ def __more_row_new(self):
row.set_tooltip_text(_("More…"))
arrow = Gtk.Image.new_from_icon_name('view-more-symbolic',
Gtk.IconSize.MENU)
arrow.set_margin_left(20)
arrow.set_margin_right(20)
arrow.set_margin_start(20)
arrow.set_margin_end(20)
arrow.set_margin_top(6)
arrow.set_margin_bottom(6)
arrow.set_halign(Gtk.Align.CENTER)
Expand Down
18 changes: 9 additions & 9 deletions setup/enginedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ibus - The Input Bus
#
# Copyright (c) 2015 Peng Huang <[email protected]>
# Copyright (c) 2015 Takao Fujiwara <[email protected]>
# Copyright (c) 2015-2019 Takao Fujiwara <[email protected]>
# Copyright (c) 2013-2015 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -70,8 +70,8 @@ def __init__(self, transient_for = None):
hscrollbar_policy = Gtk.PolicyType.NEVER,
vscrollbar_policy = Gtk.PolicyType.NEVER,
shadow_type = Gtk.ShadowType.IN,
margin_left = 6,
margin_right = 6,
margin_start = 6,
margin_end = 6,
margin_top = 6,
margin_bottom = 6)
self.vbox.add(self.__scrolled)
Expand All @@ -94,8 +94,8 @@ def __init__(self, transient_for = None):
self.__filter_timeout_id = 0
self.__filter_word = None
self.__filter_entry = Gtk.SearchEntry(hexpand = True,
margin_left = 6,
margin_right = 6,
margin_start = 6,
margin_end = 6,
margin_top = 6,
margin_bottom = 6)
self.__filter_entry.set_no_show_all(True)
Expand Down Expand Up @@ -164,8 +164,8 @@ def __padded_label_new(self, text, icon, alignment, direction):
label = Gtk.Label(label = text)
label.set_halign(alignment)
label.set_valign(Gtk.Align.CENTER)
label.set_margin_left(20)
label.set_margin_right(20)
label.set_margin_start(20)
label.set_margin_end(20)
label.set_margin_top(6)
label.set_margin_bottom(6)
hbox.pack_start(label, True, True, 0)
Expand Down Expand Up @@ -205,8 +205,8 @@ def __more_row_new(self):
row.set_tooltip_text(_("More…"))
arrow = Gtk.Image.new_from_icon_name('view-more-symbolic',
Gtk.IconSize.MENU)
arrow.set_margin_left(20)
arrow.set_margin_right(20)
arrow.set_margin_start(20)
arrow.set_margin_end(20)
arrow.set_margin_top(6)
arrow.set_margin_bottom(6)
arrow.set_halign(Gtk.Align.CENTER)
Expand Down
34 changes: 17 additions & 17 deletions setup/setup.ui
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<property name="spacing">18</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
Expand All @@ -105,7 +105,7 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
Expand Down Expand Up @@ -366,7 +366,7 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
Expand Down Expand Up @@ -589,8 +589,8 @@
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<child>
<object class="GtkBox" id="hbox1">
<property name="orientation">horizontal</property>
Expand Down Expand Up @@ -658,7 +658,7 @@
<property name="can_focus">False</property>
<property name="spacing">5</property>
<property name="layout_style">start</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
<child>
<object class="GtkButton" id="button_engine_add">
<property name="label" translatable="yes">_Add</property>
Expand Down Expand Up @@ -811,7 +811,7 @@
<property name="max_width_chars">74</property>
<property name="label" translatable="yes">&lt;small&gt;&lt;i&gt;The active input method can be switched around from the selected ones in the above list by pressing the keyboard shortcut keys or clicking the panel icon.&lt;/i&gt;&lt;/small&gt;</property>
<property name="use_markup">True</property>
<!-- property name="margin_left">0</property -->
<!-- property name="margin_start">0</property -->
</object>
<packing>
<property name="expand">True</property>
Expand Down Expand Up @@ -850,8 +850,8 @@
<property name="spacing">18</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<child>
<object class="GtkFrame" id="frame_emoji1">
<property name="visible">True</property>
Expand All @@ -865,7 +865,7 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
<child>
<object class="GtkLabel" id="label_emoji1">
<property name="visible">True</property>
Expand Down Expand Up @@ -1004,7 +1004,7 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
<property name="row_homogeneous">false</property>
<child>
<object class="GtkLabel" id="label_emoji_font">
Expand Down Expand Up @@ -1187,8 +1187,8 @@
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
Expand All @@ -1202,7 +1202,7 @@
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">24</property>
<property name="margin_start">24</property>
<child>
<object class="GtkCheckButton" id="checkbutton_use_sys_layout">
<property name="label" translatable="yes">Use system keyboard layout</property>
Expand Down Expand Up @@ -1251,7 +1251,7 @@
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="margin_top">6</property>
<property name="margin_left">24</property>
<property name="margin_start">24</property>
<child>
<object class="GtkCheckButton" id="checkbutton_use_global_engine">
<property name="label" translatable="yes">Share the same input method among all applications</property>
Expand Down Expand Up @@ -1348,7 +1348,7 @@ Homepage: https://github.com/ibus/ibus/wiki
<property name="halign">start</property>
<property name="draw_indicator">True</property>
<property name="margin_top">6</property>
<property name="margin_left">12</property>
<property name="margin_start">12</property>
</object>
</child>
<child type="label">
Expand Down
1 change: 1 addition & 0 deletions src/ibuscomposetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ ibus_compose_table_list_add_array (GSList *compose_tables,
int i;
guint16 *ibus_compose_seqs = NULL;

g_assert (length >= 0);
g_return_val_if_fail (data != NULL, compose_tables);
g_return_val_if_fail (max_seq_len <= IBUS_MAX_COMPOSE_LEN, compose_tables);

Expand Down
6 changes: 3 additions & 3 deletions ui/gtk3/bindingcommon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2018 Peng Huang <[email protected]>
* Copyright(c) 2018 Takao Fujwiara <[email protected]>
* Copyright(c) 2018-2019 Takao Fujwiara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -75,8 +75,8 @@ class BindingCommon {
// workaround a bug in gdk vapi vala > 0.18
// https://bugzilla.gnome.org/show_bug.cgi?id=677559
#if VALA_0_18
Gdk.Keymap.get_default().map_virtual_modifiers(
ref switch_modifiers);
Gdk.Keymap.get_for_display(Gdk.Display.get_default()
).map_virtual_modifiers(ref switch_modifiers);
#else
if ((switch_modifiers & Gdk.ModifierType.SUPER_MASK) != 0)
switch_modifiers |= Gdk.ModifierType.MOD4_MASK;
Expand Down
9 changes: 5 additions & 4 deletions ui/gtk3/candidatearea.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2015 Peng Huang <[email protected]>
* Copyright(c) 2015-2017 Takao Fujiwara <[email protected]>
* Copyright(c) 2015-2019 Takao Fujiwara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -215,9 +215,10 @@ class CandidateArea : Gtk.Box {
candidate.show();
m_candidates += candidate;

/* Use Gtk.Widget.set_margin_start() since gtk 3.12 */
label.set_padding(8, 0);
candidate.set_padding(8, 0);
label.set_margin_start (8);
label.set_margin_end (8);
candidate.set_margin_start (8);
candidate.set_margin_end (8);

// Make a copy of i to workaround a bug in vala.
// https://bugzilla.gnome.org/show_bug.cgi?id=628336
Expand Down
10 changes: 5 additions & 5 deletions ui/gtk3/candidatepanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2015 Peng Huang <[email protected]>
* Copyright(c) 2015-2018 Takao Fujiwara <[email protected]>
* Copyright(c) 2015-2019 Takao Fujiwara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -242,16 +242,16 @@ public class CandidatePanel : Gtk.Box{
m_preedit_label.set_size_request(20, -1);
m_preedit_label.set_halign(Gtk.Align.START);
m_preedit_label.set_valign(Gtk.Align.CENTER);
/* Use Gtk.Widget.set_margin_start() since gtk 3.12 */
m_preedit_label.set_padding(8, 0);
m_preedit_label.set_margin_start(8);
m_preedit_label.set_margin_end(8);
m_preedit_label.set_no_show_all(true);

m_aux_label = new Gtk.Label(null);
m_aux_label.set_size_request(20, -1);
m_aux_label.set_halign(Gtk.Align.START);
m_aux_label.set_valign(Gtk.Align.CENTER);
/* Use Gtk.Widget.set_margin_start() since gtk 3.12 */
m_aux_label.set_padding(8, 0);
m_aux_label.set_margin_start(8);
m_aux_label.set_margin_end(8);
m_aux_label.set_no_show_all(true);

m_candidate_area = new CandidateArea(m_vertical_panel_system);
Expand Down
4 changes: 3 additions & 1 deletion ui/gtk3/emojier.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2147,11 +2147,13 @@ public class IBusEmojier : Gtk.ApplicationWindow {
ncandidates));
int char_count = text.text.char_count();
int start_index = -1;
unowned string title = text.text;
for (int i = 0; i < char_count; i++) {
if (text.text.utf8_offset(i).has_prefix(language)) {
if (title.has_prefix(language)) {
start_index = i;
break;
}
title = title.next_char();
}
if (start_index >= 0) {
var attr = new IBus.Attribute(
Expand Down
4 changes: 2 additions & 2 deletions ui/gtk3/panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ class Panel : IBus.PanelService {

private void show_setup_dialog() {
if (m_setup_pid != 0) {
if (Posix.kill(m_setup_pid, Posix.SIGUSR1) == 0)
if (Posix.kill(m_setup_pid, Posix.Signal.USR1) == 0)
return;
m_setup_pid = 0;
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ class Panel : IBus.PanelService {

string copyright =
"Copyright © 2007-2015 Peng Huang\n" +
"Copyright © 2015 Takao Fujiwara\n" +
"Copyright © 2015-2019 Takao Fujiwara\n" +
"Copyright © 2007-2015 Red Hat, Inc.\n";

m_about_dialog.set_copyright(copyright);
Expand Down
9 changes: 5 additions & 4 deletions ui/gtk3/switcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ibus - The Input Bus
*
* Copyright(c) 2011-2016 Peng Huang <[email protected]>
* Copyright(c) 2015-2017 Takao Fujiwara <[email protected]>
* Copyright(c) 2015-2019 Takao Fujiwara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -125,9 +125,10 @@ class Switcher : Gtk.Window {
Atk.Object obj = m_label.get_accessible();
obj.set_role (Atk.Role.STATUSBAR);

/* Use Gtk.Widget.set_margin_start() and
* Gtk.Widget.set_margin_top() since gtk 3.12 */
m_label.set_padding(3, 3);
m_label.set_margin_start(3);
m_label.set_margin_end(3);
m_label.set_margin_top(3);
m_label.set_margin_bottom(3);
vbox.pack_end(m_label, false, false, 0);

grab_focus();
Expand Down

0 comments on commit 35863d8

Please sign in to comment.