Accepting request 155901 from home:ftake:branches:M17N

Add a shell extension for GNOME 3.6

OBS-URL: https://build.opensuse.org/request/show/155901
OBS-URL: https://build.opensuse.org/package/show/M17N/ibus?expand=0&rev=58
This commit is contained in:
Hillwood Yang 2013-02-21 01:27:19 +00:00 committed by Git OBS Bridge
parent da0bfc0338
commit 4934327121
5 changed files with 154 additions and 22 deletions

View File

@ -1,6 +1,11 @@
ibus README for SuSE
How to start using ibus
Note:
Since GNOME 3.6 does not support IBus 1.4, IBus's indicator icon is not placed on GNOME panel in the top of screen
by default. This package includes a GNOME shell extension named IBus 1.4 indicator to resolve this problem.
Please enable the extension manually from gnome-tweak-tool GUI if you need the indicator on the panel.
English:
0:Note: ibus don't support QT3 immodule,

View File

@ -1,23 +1,12 @@
diff -Nur ibus-1.4.2/ui/gtk/panel.py ibus-1.4.2-new/ui/gtk/panel.py
--- ibus-1.4.2/ui/gtk/panel.py 2012-08-22 22:16:51.000000000 +0800
+++ ibus-1.4.2-new/ui/gtk/panel.py 2013-02-08 23:57:47.465504005 +0800
@@ -103,19 +103,6 @@
self.__status_icon = gtk.StatusIcon()
- # gnome-shell checks XClassHint.res_class with ShellTrayIcon.
- # gtk_status_icon_set_name() can set XClassHint.res_class .
- # However gtk_status_icon_new() also calls gtk_window_realize() so
- # gtk_status_icon_set_visible() needs to be called to set WM_CLASS
- # so that gtk_window_realize() is called later again.
- # set_title is for gnome-shell notificationDaemon in bottom right.
- self.__status_icon.set_visible(False)
- # gtk_status_icon_set_name() is not available in pygtk2 2.17
- if hasattr(self.__status_icon, 'set_name'):
diff -ru ibus-1.4.2.org/ui/gtk/panel.py ibus-1.4.2/ui/gtk/panel.py
--- ibus-1.4.2.org/ui/gtk/panel.py 2012-08-22 23:16:51.000000000 +0900
+++ ibus-1.4.2/ui/gtk/panel.py 2013-02-11 16:40:38.328356131 +0900
@@ -112,7 +112,7 @@
self.__status_icon.set_visible(False)
# gtk_status_icon_set_name() is not available in pygtk2 2.17
if hasattr(self.__status_icon, 'set_name'):
- self.__status_icon.set_name('ibus-ui-gtk')
- self.__status_icon.set_title(_("IBus Panel"))
- # Hide icon until bus get the name owner.
- #self.__status_icon.set_visible(True)
self.__status_icon.connect("popup-menu", self.__status_icon_popup_menu_cb)
self.__status_icon.connect("activate", self.__status_icon_activate_cb)
self.__status_icon.set_from_icon_name(ICON_KEYBOARD)
+ self.__status_icon.set_name('ibus-ui-gtk-14')
self.__status_icon.set_title(_("IBus Panel"))
# Hide icon until bus get the name owner.
#self.__status_icon.set_visible(True)

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Sat Feb 16 15:59:12 UTC 2013 - ftake@geeko.jp
- better solution for bnc#802967
* add ibus_indicator-14.patch: a shell extension for GNOME 3.6
* update ibus-fix-tray-icon-on-gnome-3.6.patch
-------------------------------------------------------------------
Sat Feb 9 13:13:13 CST 2013 - hillwood@linuxfans.org

View File

@ -33,7 +33,10 @@ Patch0: ibus-python-install-dir.patch
Patch1: ibus-fix-default-preload-engines.patch
# PATCH-FIX-OPENSUSE ibus-fix-docs-build-error.patch
Patch2: ibus-fix-docs-build-error.patch
# PATCH-FIX-OPENSUSE ibus-fix-tray-icon-on-gnome-3.6.patch
Patch3: ibus-fix-tray-icon-on-gnome-3.6.patch
# PATCH-FIX-OPENSUSE ibus_indicator-14.patch
Patch4: ibus_indicator-14.patch
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1+
Group: System/I18n/Chinese
@ -134,6 +137,7 @@ docs for ibus.
%patch2 -p1
%if 0%{suse_version} >= 1230
%patch3 -p1
%patch4 -p1
%endif
%build
@ -188,6 +192,11 @@ ln -sf %{_datadir}/icons/hicolor/48x48/apps/ibus-keyboard.png \
cat %{name}.schemas_list %{domain_name}.lang > %{name}.lst
%fdupes -s $RPM_BUILD_ROOT
%if 0%{suse_version} >= 1230
install -m755 -d %{buildroot}%{_datadir}/gnome-shell/extensions/ibus_indicator-14@ftake.github.com
install -m644 ibus_indicator-14@ftake.github.com/* %{buildroot}%{_datadir}/gnome-shell/extensions/ibus_indicator-14@ftake.github.com
%endif
%clean
rm -rf %buildroot
@ -232,6 +241,12 @@ rm -rf %buildroot
%{_datadir}/icons/hicolor/*/apps/*
%{_datadir}/pixmaps/*
%{_prefix}/%{_lib}/ibus
%if 0%{suse_version} >= 1230
%dir %{_datadir}/gnome-shell/
%dir %{_datadir}/gnome-shell/extensions/
%dir %{_datadir}/gnome-shell/extensions/ibus_indicator-14@ftake.github.com/
%{_datadir}/gnome-shell/extensions/ibus_indicator-14@ftake.github.com/*
%endif
%files -n libibus-1_0-0
%defattr(-,root,root,-)

116
ibus_indicator-14.patch Normal file
View File

@ -0,0 +1,116 @@
diff -ruN ibus-1.4.2.org/ibus_indicator-14@ftake.github.com/extension.js ibus-1.4.2/ibus_indicator-14@ftake.github.com/extension.js
--- ibus-1.4.2.org/ibus_indicator-14@ftake.github.com/extension.js 1970-01-01 09:00:00.000000000 +0900
+++ ibus-1.4.2/ibus_indicator-14@ftake.github.com/extension.js 2013-02-17 00:46:21.244945766 +0900
@@ -0,0 +1,107 @@
+const Main = imports.ui.main
+const Shell = imports.gi.Shell
+const Panel = imports.ui.panel
+const Lang = imports.lang
+const PanelMenu = imports.ui.panelMenu
+const NotificationDaemon = imports.ui.notificationDaemon;
+
+let addIndicator = null
+
+const AddIndicator = new Lang.Class({
+ Name: 'AddIndicator',
+
+ _init: function() {
+ Main.notificationDaemon._trayManager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded))
+ Main.notificationDaemon._trayManager.connect('tray-icon-removed', Lang.bind(this, this._onTrayIconRemoved))
+ Panel.PANEL_ITEM_IMPLEMENTATIONS['ibus-ui-gtk-14'] = null;
+ },
+
+ _onTrayIconAdded: function(manager, actor) {
+ if (actor.wm_class == 'ibus-ui-gtk-14') {
+ // for patched IBus 1.4
+ this._icon = actor;
+ this._addIBusIndicator();
+ } else if (actor.wm_class == 'ibus-ui-gtk') {
+ try {
+ var IBus = imports.gi.IBus
+ if (!('new_async' in IBus.Bus)) {
+ // This IBus does not support GNOME 3.6
+ this._icon = actor;
+ this._addIBusIndicator();
+ }
+ } catch (e) {
+ IBus = null
+ log(e)
+ }
+ }
+ },
+
+ _addIBusIndicator: function() {
+ if (this._enabled && this._icon) {
+ this._removeFromNotificationDaemon();
+ this._icon.height = Panel.PANEL_ICON_SIZE
+ this._icon.queue_redraw()
+ this._indicator = new PanelMenu.Button()
+ this._indicator.actor.add_actor(this._icon)
+ Main.panel.addToStatusArea('ibus-ui-gtk-14', this._indicator, 0, 'right')
+ NotificationDaemon.STANDARD_TRAY_ICON_IMPLEMENTATIONS['ibus-ui-gtk-14'] = 'keyboard'
+ }
+ },
+
+ _removeIBusIndicator: function() {
+ if (this._indicator) {
+ this._indicator.actor.remove_actor(this._icon);
+// this._icon.unparent();
+ this._indicator.destroy();
+ this._indicator = null;
+ }
+ },
+
+ _onTrayIconRemoved: function(manager, actor) {
+ if (actor.wm_class == 'ibus-ui-gtk-14' || actor.wm_class == 'ibus-ui-gtk') {
+ this._removeIBusIndicator();
+ this._icon = null;
+ }
+ },
+
+ _removeFromNotificationDaemon: function() {
+ if (this._icon) {
+ let source = Main.notificationDaemon._lookupSource(null, this._icon.pid, true);
+ if (source) {
+ this._icon.get_parent().remove_actor(this._icon)
+// this._icon.unparent()
+ source.destroy();
+ }
+ }
+ },
+
+ _enabled: false,
+ enable: function() {
+ this._enabled = true;
+ this._addIBusIndicator();
+ },
+
+ disable: function() {
+ this._enabled = false;
+ this._removeIBusIndicator();
+ NotificationDaemon.STANDARD_TRAY_ICON_IMPLEMENTATIONS['ibus-ui-gtk-14'] = undefined;
+ if (this._icon) {
+ //Main.notificationDaemon._onTrayIconAdded(null, this._icon);
+ Main.notificationDaemon._getSource(
+ this._icon.title || this._icon.wm_class || C_("program", "Unknown"),
+ this._icon.pid, null, null, this._icon);
+ }
+ }
+})
+
+function init() {
+ addIndicator = new AddIndicator();
+}
+
+function enable() {
+ addIndicator.enable();
+}
+
+function disable() {
+ addIndicator.disable();
+}
diff -ruN ibus-1.4.2.org/ibus_indicator-14@ftake.github.com/metadata.json ibus-1.4.2/ibus_indicator-14@ftake.github.com/metadata.json
--- ibus-1.4.2.org/ibus_indicator-14@ftake.github.com/metadata.json 1970-01-01 09:00:00.000000000 +0900
+++ ibus-1.4.2/ibus_indicator-14@ftake.github.com/metadata.json 2013-02-17 00:46:29.038879855 +0900
@@ -0,0 +1 @@
+{"shell-version": ["3.6"], "uuid": "ibus_indicator-14@ftake.github.com", "name": "IBus 1.4 indicator", "description": "An indicator for IBus 1.4"}