diff -Nru fcitx-qimpanel-0.1.6/debian/changelog fcitx-qimpanel-0.1.6/debian/changelog --- fcitx-qimpanel-0.1.6/debian/changelog 2014-07-27 17:05:29.000000000 -0400 +++ fcitx-qimpanel-0.1.6/debian/changelog 2014-08-29 12:27:33.000000000 -0400 @@ -1,3 +1,11 @@ +fcitx-qimpanel (0.1.6-0ubuntu2) utopic; urgency=medium + + * debian/patches/0001-Customize-system-tray-menu-under-Unity.patch: + - Move Fcitx engine list to top-level menu and add indicator-keyboard + options under Unity. + + -- William Hua Fri, 29 Aug 2014 12:26:50 -0400 + fcitx-qimpanel (0.1.6-0ubuntu1) utopic; urgency=low * New upstream release diff -Nru fcitx-qimpanel-0.1.6/debian/patches/0001-Customize-system-tray-menu-under-Unity.patch fcitx-qimpanel-0.1.6/debian/patches/0001-Customize-system-tray-menu-under-Unity.patch --- fcitx-qimpanel-0.1.6/debian/patches/0001-Customize-system-tray-menu-under-Unity.patch 1969-12-31 19:00:00.000000000 -0500 +++ fcitx-qimpanel-0.1.6/debian/patches/0001-Customize-system-tray-menu-under-Unity.patch 2014-08-29 12:28:09.000000000 -0400 @@ -0,0 +1,199 @@ +diff --git a/system_tray_menu.cpp b/system_tray_menu.cpp +index 7551aaa..431e349 100644 +--- a/system_tray_menu.cpp ++++ b/system_tray_menu.cpp +@@ -72,8 +72,12 @@ void SystemTrayMenu::init() + SLOT(triggerUpdateSyncMenu())); + #endif + +- QObject::connect(this, SIGNAL(aboutToShow()), this, +- SLOT(triggerUpdateMainMenu())); ++ if (isUnity()) ++ QObject::connect(this, SIGNAL(aboutToShow()), this, ++ SLOT(triggerUpdateIMListMenu())); ++ else ++ QObject::connect(this, SIGNAL(aboutToShow()), this, ++ SLOT(triggerUpdateMainMenu())); + + QObject::connect(this, SIGNAL(triggered(QAction*)), this, + SLOT(menuItemOnClick(QAction *))); +@@ -120,6 +124,11 @@ void SystemTrayMenu::triggerUpdateMainMenu() + this->addAction(QIcon::fromTheme("help-contents"), tr("Online &Help!")); + this->addSeparator(); + ++ if (isUnity()) { ++ appendIMListToMenu(this, mIMList); ++ this->addSeparator(); ++ } ++ + foreach(const KimpanelProperty &prop, this->mStatusMenuList) { + menu = new MyAction(QIcon::fromTheme(prop.icon), prop.label, this); + menu->setProp(prop); +@@ -128,7 +137,8 @@ void SystemTrayMenu::triggerUpdateMainMenu() + this->addSeparator(); + + this->addMenu(mVKListMenu); +- this->addMenu(mIMListMenu); ++ if (!isUnity()) ++ this->addMenu(mIMListMenu); + this->addMenu(mSkinMenu); + this->addSeparator(); + +@@ -140,6 +150,13 @@ void SystemTrayMenu::triggerUpdateMainMenu() + #endif + this->addSeparator(); + ++ if (isUnity()) { ++ this->addAction(tr("Character Map")); ++ this->addAction(tr("Keyboard Layout Chart")); ++ this->addAction(tr("Text Entry Settings…")); ++ this->addSeparator(); ++ } ++ + this->addAction(QIcon::fromTheme("view-refresh"), tr("Restart")); + this->addAction(QIcon::fromTheme("application-exit"), tr("Exit")); + } +@@ -180,25 +197,30 @@ void SystemTrayMenu::doUpdateVKListMenu(const QList &prop_list + + void SystemTrayMenu::doUpdateIMListMenu(const QList &prop_list) + { ++ mIMListMenu->clear(); ++ appendIMListToMenu(mIMListMenu, prop_list); ++} ++ ++void SystemTrayMenu::appendIMListToMenu(QMenu *menu, const QList &prop_list) ++{ + bool checked = false; +- MyAction *firstMenu = NULL, *menu; ++ MyAction *firstAction = NULL, *action; + QList::const_iterator iter; + +- mIMListMenu->clear(); + for (iter = prop_list.begin(); iter != prop_list.end(); ++ iter) { +- menu = new MyAction(QIcon::fromTheme(iter->icon), iter->label, this); +- menu->setProp(*iter); +- mIMListMenu->addAction(menu); +- if (firstMenu == NULL) +- firstMenu = menu; +- menu->setCheckable(true); ++ action = new MyAction(QIcon::fromTheme(iter->icon), iter->label, this); ++ action->setProp(*iter); ++ menu->addAction(action); ++ if (firstAction == NULL) ++ firstAction = action; ++ action->setCheckable(true); + if (iter->label == this->mCurtIMLabel) { + checked = true; +- menu->setChecked(true); ++ action->setChecked(true); + } + } +- if (!checked) +- firstMenu->setChecked(true); ++ if (!checked && firstAction) ++ firstAction->setChecked(true); + } + + void SystemTrayMenu::execMenu(const QList &prop_list) +@@ -210,7 +232,12 @@ void SystemTrayMenu::execMenu(const QList &prop_list) + doUpdateVKListMenu(prop_list); + break; + case updateIMListMenu: +- doUpdateIMListMenu(prop_list); ++ if (isUnity()) { ++ mIMList = prop_list; ++ triggerUpdateMainMenu(); ++ } else { ++ doUpdateIMListMenu(prop_list); ++ } + break; + //case updateThemerMenu: + // tmpMenu = mSkinMenu; +@@ -256,7 +283,7 @@ void SystemTrayMenu::restart() + } + } + +-void SystemTrayMenu::startChildApp(const char *app_exe) ++void SystemTrayMenu::startChildApp(const char *app_exe, const char * const argv[]) + { + /* exec command */ + pid_t child_pid; +@@ -272,7 +299,7 @@ void SystemTrayMenu::startChildApp(const char *app_exe) + perror("fork"); + _exit(1); + } else if (grandchild_pid == 0) { /* grandchild process */ +- execvp(app_exe, NULL); ++ execvp(app_exe, const_cast(argv)); + perror("execvp"); + _exit(1); + } else { +@@ -424,6 +451,31 @@ void SystemTrayMenu::menuItemOnClick(QAction *action) + qDebug()<<"SystemTrayMenu::ConfigureDown"; + syncConfigDown(); + #endif ++ } else if (tr("Character Map") == action->text()) { ++ startChildApp("gucharmap"); ++ } else if (tr("Keyboard Layout Chart") == action->text()) { ++ const char *argv[4] = { "gkbd-keyboard-display", "-l", NULL, NULL }; ++ ++ QString layout = "us"; ++ QList::const_iterator i; ++ for (i = mIMList.begin(); i != mIMList.end(); ++i) { ++ if (i->label == mCurtIMLabel) { ++ if (i->key.startsWith("/Fcitx/im/fcitx-keyboard-")) { ++ layout = i->key.mid(strlen("/Fcitx/im/fcitx-keyboard-")); ++ } ++ break; ++ } ++ } ++ QByteArray bytes = layout.toLatin1(); ++ int separator = bytes.indexOf('-'); ++ if (separator != -1) ++ bytes[separator] = '\t'; ++ argv[2] = bytes.constData(); ++ ++ startChildApp("gkbd-keyboard-display", argv); ++ } else if (tr("Text Entry Settings…") == action->text()) { ++ const char *argv[4] = { "unity-control-center", "region", "layouts", NULL }; ++ startChildApp("unity-control-center", argv); + } else { + MyAction *myAction = (MyAction *)action; + if (myAction->getProp().key != "") { +@@ -431,3 +483,9 @@ void SystemTrayMenu::menuItemOnClick(QAction *action) + } + } + } ++ ++bool SystemTrayMenu::isUnity() ++{ ++ const char *desktop = getenv("XDG_CURRENT_DESKTOP"); ++ return desktop && !strcmp(desktop, "Unity"); ++} +diff --git a/system_tray_menu.h b/system_tray_menu.h +index fc14ad9..5e70da7 100644 +--- a/system_tray_menu.h ++++ b/system_tray_menu.h +@@ -66,7 +66,8 @@ public slots: + private: + void doUpdateVKListMenu(const QList &prop_list); + void doUpdateIMListMenu(const QList &prop_list); +- void startChildApp(const char *app_exe); ++ void appendIMListToMenu(QMenu *menu, const QList &prop_list); ++ void startChildApp(const char *app_exe, const char * const argv[] = NULL); + #ifndef DISABLE_UK_SYNC + void syncConfigUp(); + void syncConfigDown(); +@@ -75,9 +76,13 @@ public: + void restart(); + + private: ++ static bool isUnity(); ++ ++private: + QString mCurtIMLabel; + //前两个用不到,见后端KimpanelRegisterAllStatus()函数 + #define StatusMenuSkip (2) ++ QList mIMList; + QList mStatusMenuList; + SkinMenu *mSkinMenu; + QMenu *mVKListMenu; diff -Nru fcitx-qimpanel-0.1.6/debian/patches/series fcitx-qimpanel-0.1.6/debian/patches/series --- fcitx-qimpanel-0.1.6/debian/patches/series 1969-12-31 19:00:00.000000000 -0500 +++ fcitx-qimpanel-0.1.6/debian/patches/series 2014-08-29 12:26:38.000000000 -0400 @@ -0,0 +1 @@ +0001-Customize-system-tray-menu-under-Unity.patch