|
Packit Service |
1d8f1c |
/* vim:set et sts=4 sw=4:
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* ibus - The Input Bus
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* Copyright(c) 2011 Peng Huang <shawn.p.huang@gmail.com>
|
|
Packit Service |
1d8f1c |
* Copyright(c) 2017 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
1d8f1c |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
1d8f1c |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
1d8f1c |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
1d8f1c |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
1d8f1c |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
1d8f1c |
* Lesser General Public License for more details.
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
1d8f1c |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
1d8f1c |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
Packit Service |
1d8f1c |
* USA
|
|
Packit Service |
1d8f1c |
*/
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
class Application {
|
|
Packit Service |
1d8f1c |
private IBus.Bus m_bus;
|
|
Packit Service |
1d8f1c |
private Panel m_panel;
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
public Application(string[] argv) {
|
|
Packit Service |
1d8f1c |
GLib.Intl.bindtextdomain(Config.GETTEXT_PACKAGE,
|
|
Packit Service |
1d8f1c |
Config.GLIB_LOCALE_DIR);
|
|
Packit Service |
1d8f1c |
GLib.Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "UTF-8");
|
|
Packit Service |
1d8f1c |
IBus.init();
|
|
Packit Service |
1d8f1c |
Gtk.init(ref argv);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
m_bus = new IBus.Bus();
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
m_bus.connected.connect(bus_connected);
|
|
Packit Service |
1d8f1c |
m_bus.disconnected.connect(bus_disconnected);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
if (m_bus.is_connected()) {
|
|
Packit Service |
1d8f1c |
init();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
private void init() {
|
|
Packit Service |
1d8f1c |
DBusConnection connection = m_bus.get_connection();
|
|
Packit Service |
1d8f1c |
connection.signal_subscribe("org.freedesktop.DBus",
|
|
Packit Service |
1d8f1c |
"org.freedesktop.DBus",
|
|
Packit Service |
1d8f1c |
"NameAcquired",
|
|
Packit Service |
1d8f1c |
"/org/freedesktop/DBus",
|
|
Packit Service |
1d8f1c |
IBus.SERVICE_PANEL,
|
|
Packit Service |
1d8f1c |
DBusSignalFlags.NONE,
|
|
Packit Service |
1d8f1c |
bus_name_acquired_cb);
|
|
Packit Service |
1d8f1c |
connection.signal_subscribe("org.freedesktop.DBus",
|
|
Packit Service |
1d8f1c |
"org.freedesktop.DBus",
|
|
Packit Service |
1d8f1c |
"NameLost",
|
|
Packit Service |
1d8f1c |
"/org/freedesktop/DBus",
|
|
Packit Service |
1d8f1c |
IBus.SERVICE_PANEL,
|
|
Packit Service |
1d8f1c |
DBusSignalFlags.NONE,
|
|
Packit Service |
1d8f1c |
bus_name_lost_cb);
|
|
Packit Service |
1d8f1c |
var flags =
|
|
Packit Service |
1d8f1c |
IBus.BusNameFlag.ALLOW_REPLACEMENT |
|
|
Packit Service |
1d8f1c |
IBus.BusNameFlag.REPLACE_EXISTING;
|
|
Packit Service |
1d8f1c |
m_bus.request_name(IBus.SERVICE_PANEL, flags);
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
public int run() {
|
|
Packit Service |
1d8f1c |
Gtk.main();
|
|
Packit Service |
1d8f1c |
return 0;
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
private void bus_name_acquired_cb(DBusConnection connection,
|
|
Packit Service |
1d8f1c |
string sender_name,
|
|
Packit Service |
1d8f1c |
string object_path,
|
|
Packit Service |
1d8f1c |
string interface_name,
|
|
Packit Service |
1d8f1c |
string signal_name,
|
|
Packit Service |
1d8f1c |
Variant parameters) {
|
|
Packit Service |
1d8f1c |
debug("signal_name = %s", signal_name);
|
|
Packit Service |
1d8f1c |
m_panel = new Panel(m_bus);
|
|
Packit Service |
1d8f1c |
m_panel.load_settings();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
private void bus_name_lost_cb(DBusConnection connection,
|
|
Packit Service |
1d8f1c |
string sender_name,
|
|
Packit Service |
1d8f1c |
string object_path,
|
|
Packit Service |
1d8f1c |
string interface_name,
|
|
Packit Service |
1d8f1c |
string signal_name,
|
|
Packit Service |
1d8f1c |
Variant parameters) {
|
|
Packit Service |
1d8f1c |
// "Destroy" dbus method was called before this callback is called.
|
|
Packit Service |
1d8f1c |
// "Destroy" dbus method -> ibus_service_destroy()
|
|
Packit Service |
1d8f1c |
// -> g_dbus_connection_unregister_object()
|
|
Packit Service |
1d8f1c |
// -> g_object_unref(m_panel) will be called later with an idle method,
|
|
Packit Service |
1d8f1c |
// which was assigned in the arguments of
|
|
Packit Service |
1d8f1c |
// g_dbus_connection_register_object()
|
|
Packit Service |
1d8f1c |
debug("signal_name = %s", signal_name);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
// unref m_panel
|
|
Packit Service |
1d8f1c |
m_panel.disconnect_signals();
|
|
Packit Service |
1d8f1c |
m_panel = null;
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
private void bus_disconnected(IBus.Bus bus) {
|
|
Packit Service |
1d8f1c |
debug("connection is lost.");
|
|
Packit Service |
1d8f1c |
Gtk.main_quit();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
private void bus_connected(IBus.Bus bus) {
|
|
Packit Service |
1d8f1c |
init();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
public static void main(string[] argv) {
|
|
Packit Service |
1d8f1c |
// https://bugzilla.redhat.com/show_bug.cgi?id=1226465#c20
|
|
Packit Service |
1d8f1c |
// In /etc/xdg/plasma-workspace/env/gtk3_scrolling.sh
|
|
Packit Service |
1d8f1c |
// Plasma deskop sets this variable and prevents Super-space,
|
|
Packit Service |
1d8f1c |
// and Ctrl-Shift-e when ibus-ui-gtk3 runs after the
|
|
Packit Service |
1d8f1c |
// desktop is launched.
|
|
Packit Service |
1d8f1c |
GLib.Environment.unset_variable("GDK_CORE_DEVICE_EVENTS");
|
|
Packit Service |
1d8f1c |
// for Gdk.X11.get_default_xdisplay()
|
|
Packit Service |
1d8f1c |
Gdk.set_allowed_backends("x11");
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
Application app = new Application(argv);
|
|
Packit Service |
1d8f1c |
app.run();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
}
|