From 828fc553b4523f90cb707d474808a10174a91ad4 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 9 Aug 2010 11:10:52 +0900 Subject: [PATCH] eekboard: use libnotify to display notification. --- configure.ac | 2 ++ src/Makefile.am | 6 ++++-- src/eekboard.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 1336e0ee..f714f66d 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,8 @@ PKG_CHECK_MODULES([LIBFAKEKEY], [libfakekey], , [AC_MSG_ERROR([libfakekey not found])]) PKG_CHECK_MODULES([CSPI], [cspi-1.0], , [AC_MSG_ERROR([AT-SPI C not found])]) +PKG_CHECK_MODULES([NOTIFY], [libnotify], , + [AC_MSG_ERROR([libnotify not found])]) AC_MSG_CHECKING([whether you enable Vala language support]) AC_ARG_ENABLE(vala, diff --git a/src/Makefile.am b/src/Makefile.am index 30e4b45a..a1a5478c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,8 @@ eekboard_CFLAGS = \ $(XKB_CFLAGS) \ $(LIBXKLAVIER_CFLAGS) \ $(LIBFAKEKEY_CFLAGS) \ - $(CSPI_CFLAGS) + $(CSPI_CFLAGS) \ + $(NOTIFY_CFLAGS) eekboard_LDFLAGS = \ $(top_builddir)/eek/libeek.la \ @@ -38,7 +39,8 @@ eekboard_LDFLAGS = \ $(XKB_LIBS) \ $(LIBXKLAVIER_LIBS) \ $(LIBFAKEKEY_LIBS) \ - $(CSPI_LIBS) + $(CSPI_LIBS) \ + $(NOTIFY_LIBS) if HAVE_CLUTTER eekboard_CFLAGS += $(CLUTTER_CFLAGS) $(CLUTTER_GTK_CFLAGS) diff --git a/src/eekboard.c b/src/eekboard.c index b2344387..fbcf57bd 100644 --- a/src/eekboard.c +++ b/src/eekboard.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,7 @@ struct _Eekboard { gboolean accessibility_enabled; Display *display; FakeKey *fakekey; + GConfClient *gconfc; GtkWidget *widget, *window; gint width, height; XklEngine *engine; @@ -1161,6 +1163,20 @@ print_option_group (XklConfigRegistry *registry, NULL); } +static void +on_notify_never_show (NotifyNotification *notification, + char *action, + gpointer user_data) +{ + Eekboard *eekboard = user_data; + GError *error; + + gconf_client_set_bool (eekboard->gconfc, + "/apps/eekboard/inhibit-startup-notify", + TRUE, + &error); +} + int main (int argc, char *argv[]) { @@ -1170,8 +1186,8 @@ main (int argc, char *argv[]) gboolean accessibility_enabled = FALSE; Eekboard *eekboard; GtkWidget *widget, *vbox, *menubar, *window; - GConfClient *gconfc; GOptionContext *context; + GConfClient *gconfc; GError *error; context = g_option_context_new ("eekboard"); @@ -1189,6 +1205,7 @@ main (int argc, char *argv[]) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif + error = NULL; gconfc = gconf_client_get_default (); if (gconf_client_get_bool (gconfc, "/desktop/gnome/interface/accessibility", @@ -1274,13 +1291,35 @@ main (int argc, char *argv[]) gtk_widget_show_all (window); gtk_widget_set_size_request (widget, -1, -1); + notify_init ("eekboard"); eekboard->window = window; + eekboard->gconfc = gconfc; if (eekboard->accessibility_enabled) { - fprintf (stderr, + NotifyNotification *notification; + + error = NULL; + if (!gconf_client_get_bool (eekboard->gconfc, + "/apps/eekboard/inhibit-startup-notify", + &error)) { + notification = notify_notification_new + ("eekboard started in background", "As GNOME accessibility support enabled, " "eekboard is starting without a window.\n" "To make eekboard show up, click on some window with " - "an editable widget.\n"); + "an editable widget.", + NULL, + NULL); + notify_notification_add_action + (notification, + "dont-ask", + "Don't show up", + NOTIFY_ACTION_CALLBACK(on_notify_never_show), + eekboard, + NULL); + error = NULL; + notify_notification_show (notification, &error); + } + gtk_widget_hide (window); focusListener = SPI_createAccessibleEventListener (a11y_focus_listener,