[aravis] viewer: show a notification whan saving image snapshot.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] viewer: show a notification whan saving image snapshot.
- Date: Mon, 18 Jun 2012 15:00:07 +0000 (UTC)
commit d3ef366aa8a954f5a83da6b9f8a6cbca3fac2060
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Jun 18 16:57:14 2012 +0200
viewer: show a notification whan saving image snapshot.
We really should not rely on libnotify, as it requires desktop
with notification support. Perhaps a text displayed in the image area ?
At least, I'd like to keep the quick save button, as it doesn't require user
interaction other than a button click.
configure.ac | 17 ++++++++++++++---
viewer/arvviewer.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1192238..b54c613 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,10 @@ AC_ARG_ENABLE(gtk3,
[ --enable-gtk3 build viewer with gtk+-3.0],
[enable_gtk3=$enableval],
[enable_gtk3=no])
+AC_ARG_ENABLE(notify,
+ [ --enable-notify build viewer with libnotify],
+ [enable_notify=$enableval],
+ [enable_notify=no])
AC_ARG_ENABLE(cpp_test,
[ --enable-cpp-test build c++ test],
[enable_cpp_test=$enableval],
@@ -53,7 +57,6 @@ PKG_PROG_PKG_CONFIG([0.14])
ARAVIS_REQUIREMENTS="glib-2.0 >= 2.26 gobject-2.0 gio-2.0 libxml-2.0 gthread-2.0"
ARAVIS_GSTREAMER_REQUIREMENTS="gstreamer-base-0.10 >= 0.10.31 gstreamer-app-0.10 gstreamer-interfaces-0.10"
-
PKG_CHECK_MODULES(ARAVIS, [$ARAVIS_REQUIREMENTS])
AC_SUBST(ARAVIS_CFLAGS)
@@ -69,6 +72,13 @@ else
fi
AM_CONDITIONAL(ARAVIS_WITH_GTK3, test "x$enable_gtk3" = "xyes")
+if test "x$enable_notify" = "xyes"; then
+ PKG_CHECK_MODULES(Notify, "libnotify")
+ ARAVIS_VIEWER_REQUIREMENTS+=" libnotify"
+ AC_DEFINE([ARAVIS_WITH_NOTIFY], 1, [Use libnotify])
+fi
+AM_CONDITIONAL(ARAVIS_WITH_NOTIFY, test "x$enable_notify" = "xyes")
+
build_viewer=no
if test "x$enable_viewer" = "xyes"; then
PKG_CHECK_MODULES([ARAVIS_VIEWER], [$ARAVIS_VIEWER_REQUIREMENTS],
@@ -128,9 +138,10 @@ AC_OUTPUT
echo ""
echo "Configuration:"
echo ""
-echo " Build viewer: $build_viewer"
-echo " Build gstreamer plugin: $build_gst_plugin"
echo " Compiler: ${CC}"
echo " Compiler flags: ${ARAVIS_CFLAGS}"
echo " Linker flags: ${ARAVIS_LIBS}"
echo ""
+echo " Build viewer: $build_viewer"
+echo " Build gstreamer plugin: $build_gst_plugin"
+echo ""
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index 3c43aa8..2352df5 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -30,6 +30,9 @@
#include <stdlib.h>
#include <math.h>
#include <glib/gi18n-lib.h>
+#ifdef ARAVIS_WITH_NOTIFY
+#include <libnotify/notify.h>
+#endif
static char *arv_viewer_option_debug_domains = NULL;
static gboolean arv_viewer_option_auto_socket_buffer = FALSE;
@@ -77,6 +80,10 @@ typedef struct {
guint exposure_update_event;
gulong video_window_xid;
+
+#ifdef ARAVIS_WITH_NOTIFY
+ NotifyNotification *notification;
+#endif
} ArvViewer;
double
@@ -378,6 +385,17 @@ arv_viewer_snapshot_cb (GtkButton *button, ArvViewer *viewer)
path = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES),
"Aravis", filename, NULL);
g_file_set_contents (path, viewer->last_buffer->data, viewer->last_buffer->size, NULL);
+
+#ifdef ARAVIS_WITH_NOTIFY
+ if (viewer->notification) {
+ notify_notification_update (viewer->notification,
+ "Snapshot saved to Image folder",
+ path,
+ "gtk-save");
+ notify_notification_show (viewer->notification, NULL);
+ }
+#endif
+
g_free (path);
g_free (filename);
g_free (date_string);
@@ -556,6 +574,11 @@ arv_viewer_free (ArvViewer *viewer)
{
g_return_if_fail (viewer != NULL);
+#ifdef ARAVIS_WITH_NOTIFY
+ if (viewer->notification)
+ g_object_unref (viewer->notification);
+#endif
+
if (viewer->exposure_update_event > 0)
g_source_remove (viewer->exposure_update_event);
if (viewer->gain_update_event > 0)
@@ -648,6 +671,10 @@ arv_viewer_new (void)
viewer->auto_gain_clicked = g_signal_connect (viewer->auto_gain_toggle, "clicked",
G_CALLBACK (arv_viewer_auto_gain_cb), viewer);
+#ifdef ARAVIS_WITH_NOTIFY
+ viewer->notification = notify_notification_new (NULL, NULL, NULL);
+#endif
+
return viewer;
}
@@ -707,6 +734,10 @@ main (int argc,char *argv[])
arv_debug_enable (arv_viewer_option_debug_domains);
+#ifdef ARAVIS_WITH_NOTIFY
+ notify_init ("Aravis Viewer");
+#endif
+
viewer = arv_viewer_new ();
arv_viewer_update_device_list_cb (viewer);
@@ -714,6 +745,10 @@ main (int argc,char *argv[])
gtk_main ();
+#ifdef ARAVIS_WITH_NOTIFY
+ notify_uninit ();
+#endif
+
/* For debug purpose only */
arv_shutdown ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]