[gnome-flashback] simplify Status Notifier Watcher code



commit 5a43d27ffd50569f7fa1cbe1caa6eb243f79a2b2
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Aug 30 14:25:03 2016 +0300

    simplify Status Notifier Watcher code

 configure.ac                            |   12 +-----
 gnome-flashback/Makefile.am             |    8 ----
 gnome-flashback/gf-application.c        |   23 ++++++++---
 gnome-flashback/libwatcher/Makefile.am  |   31 ---------------
 gnome-flashback/libwatcher/gf-watcher.c |   65 -------------------------------
 gnome-flashback/libwatcher/gf-watcher.h |   32 ---------------
 6 files changed, 19 insertions(+), 152 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 89741e2..0ae86a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,7 +88,7 @@ dnl **************************************************************************
 
 AC_ARG_WITH([libstatus-notifier],
             [AS_HELP_STRING([--with-libstatus-notifier],
-                           [Build with libstatus-notifier (experimental)])],
+                            [Build with libstatus-notifier (experimental)])],
             [with_libstatus_notifier="$withval"],
             [with_libstatus_notifier=no])
 
@@ -118,6 +118,7 @@ UPOWER_GLIB_REQUIRED=0.99.0
 
 PKG_CHECK_MODULES([GNOME_FLASHBACK], [
   gtk+-3.0 >= $GTK_REQUIRED
+  $LIBSTATUS_NOTIFIER_PKG
 ])
 
 PKG_CHECK_MODULES([AUDIO_DEVICE_SELECTION], [
@@ -237,14 +238,6 @@ PKG_CHECK_MODULES([SOUND_APPLET], [
   $LIBSTATUS_NOTIFIER_PKG
 ])
 
-AS_IF([test "x$with_libstatus_notifier" = "xyes"], [
-  PKG_CHECK_MODULES([WATCHER], [
-    glib-2.0 >= $GLIB_REQUIRED
-    gtk+-3.0 >= $GTK_REQUIRED
-    $LIBSTATUS_NOTIFIER_PKG
-  ])
-])
-
 PKG_CHECK_MODULES([WORKAROUNDS], [
   glib-2.0 >= $GLIB_REQUIRED
   gtk+-3.0 >= $GTK_REQUIRED
@@ -312,7 +305,6 @@ AC_CONFIG_FILES([
   gnome-flashback/libshell/Makefile
   gnome-flashback/libsound-applet/Makefile
   gnome-flashback/libsound-applet/gvc/Makefile
-  gnome-flashback/libwatcher/Makefile
   gnome-flashback/libworkarounds/Makefile
 
   po/Makefile.in
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 090bab1..a3befcd 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -22,10 +22,6 @@ SUBDIRS = \
        libworkarounds \
        $(NULL)
 
-if WITH_LIBSTATUS_NOTIFIER
-SUBDIRS += libwatcher
-endif
-
 bin_PROGRAMS = \
        gnome-flashback \
        $(NULL)
@@ -74,10 +70,6 @@ gnome_flashback_LDADD = \
        $(top_builddir)/gnome-flashback/libworkarounds/libworkarounds.la \
        $(NULL)
 
-if WITH_LIBSTATUS_NOTIFIER
-gnome_flashback_LDADD += $(top_builddir)/gnome-flashback/libwatcher/libwatcher.la
-endif
-
 gf-resources.c: flashback.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) 
--generate-dependencies $(srcdir)/flashback.gresource.xml)
        $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name gf $<
 
diff --git a/gnome-flashback/gf-application.c b/gnome-flashback/gf-application.c
index 62e02a0..7d1b65f 100644
--- a/gnome-flashback/gf-application.c
+++ b/gnome-flashback/gf-application.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 - 2015 Alberts Muktupāvels
+ * Copyright (C) 2014-2016 Alberts Muktupāvels
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@
 #include "libworkarounds/gf-workarounds.h"
 
 #ifdef WITH_LIBSTATUS_NOTIFIER
-#include "libwatcher/gf-watcher.h"
+#include <libstatus-notifier/sn.h>
 #endif
 
 struct _GfApplication
@@ -74,7 +74,7 @@ struct _GfApplication
   GfWorkarounds          *workarounds;
 
 #ifdef WITH_LIBSTATUS_NOTIFIER
-  GfWatcher              *watcher;
+  SnWatcher              *watcher;
 #endif
 };
 
@@ -172,12 +172,23 @@ settings_changed (GSettings   *settings,
   SETTING_CHANGED (sound, "sound-applet", gf_sound_applet_new)
   SETTING_CHANGED (workarounds, "workarounds", gf_workarounds_new)
 
+#undef SETTING_CHANGED
+
 #ifdef WITH_LIBSTATUS_NOTIFIER
-  SETTING_CHANGED (watcher, "watcher", gf_watcher_new)
+  if (key == NULL || g_strcmp0 (key, "watcher") == 0)
+    {
+      if (g_settings_get_boolean (settings, "watcher"))
+        {
+          if (application->watcher == NULL)
+            application->watcher = sn_watcher_new (SN_WATCHER_FLAGS_NONE);
+        }
+      else
+        {
+          g_clear_object (&application->watcher);
+        }
+    }
 #endif
 
-#undef SETTING_CHANGED
-
   if (application->input_settings)
     gf_input_settings_set_display_config (application->input_settings,
                                           application->config);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]