[gnome-flashback] system-indicators: make gnome-bluetooth optional



commit 8b40638cda867d90a538921f13957871d81f1b86
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Aug 13 23:29:12 2022 +0300

    system-indicators: make gnome-bluetooth optional
    
    https://gitlab.gnome.org/GNOME/gnome-flashback/-/issues/80

 configure.ac                  | 14 ++++++++++++--
 system-indicators/Makefile.am | 17 +++++++++++++++--
 system-indicators/si-applet.c | 10 ++++++++++
 3 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a5da422..2c4d6ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -335,14 +335,24 @@ AC_SUBST([GNOME_PANEL_MODULES_DIR], [$GNOME_PANEL_MODULES_DIR])
 
 PKG_CHECK_MODULES([SYSTEM_INDICATORS], [
   gio-unix-2.0 >= $GLIB_REQUIRED
-  gnome-bluetooth-1.0
   libcanberra-gtk3 >= $CANBERRA_REQUIRED
   libgnome-panel >= $LIBGNOME_PANEL_REQUIRED
   upower-glib
 ])
 
+PKG_CHECK_EXISTS([gnome-bluetooth-1.0], [
+  found_gnome_bluetooth="yes"
+  PKG_CHECK_MODULES([GNOME_BLUETOOTH], [gnome-bluetooth-1.0])
+  AC_DEFINE([HAVE_GNOME_BLUETOOTH], [1],
+            [Define if gnome-desktop is 43.alpha or newer])
+], [
+  found_gnome_bluetooth="no"
+])
+
+AM_CONDITIONAL([HAVE_GNOME_BLUETOOTH], [test "x$found_gnome_bluetooth" = "xyes"])
+
 save_CFLAGS="$CFLAGS"
-CFLAGS=$SYSTEM_INDICATORS_CFLAGS
+CFLAGS=$GNOME_BLUETOOTH_CFLAGS
 AC_MSG_CHECKING([for BLUETOOTH_TYPE_SPEAKERS])
 AC_COMPILE_IFELSE([
   AC_LANG_PROGRAM([
diff --git a/system-indicators/Makefile.am b/system-indicators/Makefile.am
index 54737e1..b52aec6 100644
--- a/system-indicators/Makefile.am
+++ b/system-indicators/Makefile.am
@@ -21,8 +21,6 @@ system_indicators_la_CFLAGS = \
 system_indicators_la_SOURCES = \
        si-applet.c \
        si-applet.h \
-       si-bluetooth.c \
-       si-bluetooth.h \
        si-desktop-menu-item.c \
        si-desktop-menu-item.h \
        si-indicator.c \
@@ -51,4 +49,19 @@ system_indicators_la_LDFLAGS = \
        $(AM_LDFLAGS) \
        $(NULL)
 
+if HAVE_GNOME_BLUETOOTH
+system_indicators_la_SOURCES += \
+       si-bluetooth.c \
+       si-bluetooth.h \
+       $(NULL)
+
+system_indicators_la_CFLAGS += \
+       $(GNOME_BLUETOOTH_CFLAGS) \
+       $(NULL)
+
+system_indicators_la_LIBADD += \
+       $(GNOME_BLUETOOTH_LIBS) \
+       $(NULL)
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/system-indicators/si-applet.c b/system-indicators/si-applet.c
index e1f13d3..54a1703 100644
--- a/system-indicators/si-applet.c
+++ b/system-indicators/si-applet.c
@@ -19,7 +19,9 @@
 #include "si-applet.h"
 
 #include "gvc-mixer-control.h"
+#ifdef HAVE_GNOME_BLUETOOTH
 #include "si-bluetooth.h"
+#endif
 #include "si-input-sources.h"
 #include "si-menu-bar.h"
 #include "si-power.h"
@@ -33,7 +35,9 @@ struct _SiApplet
 
   GvcMixerControl *mixer_control;
 
+#ifdef HAVE_GNOME_BLUETOOTH
   SiIndicator     *bluetooth;
+#endif
   SiIndicator     *input_sources;
   SiIndicator     *power;
   SiIndicator     *volume_input;
@@ -73,6 +77,7 @@ append_power (SiApplet *self)
   gtk_menu_shell_append (GTK_MENU_SHELL (self->menu_bar), item);
 }
 
+#ifdef HAVE_GNOME_BLUETOOTH
 static void
 append_bluetooth (SiApplet *self)
 {
@@ -83,6 +88,7 @@ append_bluetooth (SiApplet *self)
   item = si_indicator_get_menu_item (self->bluetooth);
   gtk_menu_shell_append (GTK_MENU_SHELL (self->menu_bar), item);
 }
+#endif
 
 static void
 append_input_sources (SiApplet *self)
@@ -121,7 +127,9 @@ setup_applet (SiApplet *self)
 
   append_input_sources (self);
   append_volume (self);
+#ifdef HAVE_GNOME_BLUETOOTH
   append_bluetooth (self);
+#endif
   append_power (self);
 }
 
@@ -141,7 +149,9 @@ si_applet_dispose (GObject *object)
 
   g_clear_object (&self->mixer_control);
 
+#ifdef HAVE_GNOME_BLUETOOTH
   g_clear_object (&self->bluetooth);
+#endif
   g_clear_object (&self->input_sources);
   g_clear_object (&self->power);
   g_clear_object (&self->volume_input);


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