From: fujiwarat Date: Fri, 17 May 2013 03:12:54 +0000 (+0900) Subject: Let users know the default hotkey is Super+space with libnotify. X-Git-Tag: 1.5.3~21 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fibus.git;a=commitdiff_plain;h=62f07b7a6904b8b03a59f3baf413becb2d5d9e14 Let users know the default hotkey is Super+space with libnotify. Review URL: https://codereview.appspot.com/9407043 --- diff --git a/configure.ac b/configure.ac index 3036792..781bbf5 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # # ibus - The Input Bus # -# Copyright (c) 2007-2010 Peng Huang -# Copyright (c) 2007-2010 Red Hat, Inc. +# Copyright (c) 2007-2013 Peng Huang +# Copyright (c) 2007-2013 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -498,6 +498,21 @@ if test x"$enable_engine" = x"yes"; then enable_engine="yes (enabled, use --disable-engine to disable)" fi +# --disable-libnotify +AC_ARG_ENABLE(libnotify, + AS_HELP_STRING([--disable-libnotify], + [Disable to link libnotify]), + [enable_libnotify=$enableval], + [enable_libnotify=yes] +) +AM_CONDITIONAL([ENABLE_LIBNOTIFY], [test x"$enable_libnotify" = x"yes"]) +if test x"$enable_libnotify" = x"yes"; then + PKG_CHECK_MODULES(LIBNOTIFY, [ + libnotify >= 0.7 + ]) + enable_libnotify="yes (enabled, use --disable-libnotify to disable)" +fi + # Check iso-codes. PKG_CHECK_MODULES(ISOCODES, [ iso-codes @@ -574,6 +589,7 @@ Build options: No snooper regexes "$NO_SNOOPER_APPS" Panel icon "$IBUS_ICON_KEYBOARD" Enable surrounding-text $enable_surrounding_text + Enable libnotify $enable_libnotify Run test cases $enable_tests ]) diff --git a/data/ibus.schemas.in b/data/ibus.schemas.in index 9263adc..9cfe83b 100644 --- a/data/ibus.schemas.in +++ b/data/ibus.schemas.in @@ -42,6 +42,20 @@ + /schemas/desktop/ibus/general/version + /desktop/ibus/general/version + ibus + string + + + Saved version number + The saved version number will be used to check the + difference between the version of the previous installed + ibus and one of the current ibus. + + + + /schemas/desktop/ibus/general/hotkey/trigger /desktop/ibus/general/hotkey/trigger ibus diff --git a/ui/gtk3/Makefile.am b/ui/gtk3/Makefile.am index 43454bc..2038814 100644 --- a/ui/gtk3/Makefile.am +++ b/ui/gtk3/Makefile.am @@ -2,8 +2,8 @@ # # ibus - The Input Bus # -# Copyright (c) 2007-2010 Peng Huang -# Copyright (c) 2007-2010 Red Hat, Inc. +# Copyright (c) 2007-2013 Peng Huang +# Copyright (c) 2007-2013 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -83,6 +83,21 @@ AM_VALAFLAGS = \ --pkg=xi \ $(NULL) +if ENABLE_LIBNOTIFY +AM_CFLAGS += \ + @LIBNOTIFY_CFLAGS@ \ + $(NULL) + +AM_LDADD += \ + @LIBNOTIFY_LIBS@ \ + $(NULL) + +AM_VALAFLAGS += \ + --pkg=libnotify \ + -D ENABLE_LIBNOTIFY \ + $(NULL) +endif + libexec_PROGRAMS = ibus-ui-gtk3 ibus_ui_gtk3_SOURCES = \ diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index 0c793f4..39aca08 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -298,6 +298,95 @@ class Panel : IBus.PanelService { var_embed_preedit); } + private int compare_versions(string version1, string version2) { + string[] version1_list = version1.split("."); + string[] version2_list = version2.split("."); + int major1, minor1, micro1, major2, minor2, micro2; + + if (version1 == version2) { + return 0; + } + + // The initial dconf value of "version" is "". + if (version1 == "") { + return -1; + } + if (version2 == "") { + return 1; + } + + assert(version1_list.length >= 3); + assert(version2_list.length >= 3); + + major1 = int.parse(version1_list[0]); + minor1 = int.parse(version1_list[1]); + micro1 = int.parse(version1_list[2]); + + major2 = int.parse(version2_list[0]); + minor2 = int.parse(version2_list[1]); + micro2 = int.parse(version2_list[2]); + + if (major1 == minor1 && minor1 == minor2 && micro1 == micro2) { + return 0; + } + if ((major1 > major2) || + (major1 == major2 && minor1 > minor2) || + (major1 == major2 && minor1 == minor2 && + micro1 > micro2)) { + return 1; + } + return -1; + } + + private void update_version_1_5_3() { +#if ENABLE_LIBNOTIFY + if (!Notify.is_initted()) { + Notify.init ("ibus"); + } + + var notification = new Notify.Notification( + _("IBus Update"), + _("Super+space is now the default hotkey."), + "ibus"); + notification.set_timeout(30 * 1000); + notification.set_category("hotkey"); + + try { + notification.show(); + } catch (GLib.Error e){ + warning ("Notification is failed for IBus 1.5.3: %s", e.message); + } +#else + warning(_("Super+space is now the default hotkey.")); +#endif + } + + private void set_version() { + Variant var_prev_version = m_config.get_value("general", "version"); + Variant var_current_version = null; + string prev_version = "".dup(); + string current_version = null; + + if (var_prev_version != null) { + prev_version = var_prev_version.dup_string(); + } + + if (compare_versions(prev_version, "1.5.3") < 0) { + update_version_1_5_3(); + } + + current_version = "%d.%d.%d".printf(IBus.MAJOR_VERSION, + IBus.MINOR_VERSION, + IBus.MICRO_VERSION); + + if (prev_version == current_version) { + return; + } + + var_current_version = new Variant.string(current_version); + m_config.set_value("general", "version", var_current_version); + } + public void set_config(IBus.Config config) { if (m_config != null) { m_config.value_changed.disconnect(config_value_changed_cb); @@ -325,11 +414,12 @@ class Panel : IBus.PanelService { bind_switch_shortcut(null); set_switcher_delay_time(null); set_embed_preedit_text(null); + set_custom_font(); + + set_version(); } else { update_engines(null, null); } - - set_custom_font(); } private void exec_setxkbmap(IBus.EngineDesc engine) {