diff options
author | Colomban Wendling <[email protected]> | 2020-08-07 22:13:06 +0200 |
---|---|---|
committer | Robert Antoni Buj Gelonch <[email protected]> | 2020-08-08 23:24:58 +0200 |
commit | c685b957089beda464724eaa13d28c4d90b88453 (patch) | |
tree | 7b45e83d3bcdade3f5e4b05f74cf0df85d531208 /plugins | |
parent | f04847a9904688db9ea50fe6bc8060258570b85d (diff) | |
download | mate-settings-daemon-c685b957089beda464724eaa13d28c4d90b88453.tar.bz2 mate-settings-daemon-c685b957089beda464724eaa13d28c4d90b88453.tar.xz |
a11y-keyboard: Don't create a dummy object if AT-SPI is not available
Instead guard the caller to only use it if available.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/a11y-keyboard/Makefile.am | 15 | ||||
-rw-r--r-- | plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c | 33 | ||||
-rw-r--r-- | plugins/a11y-keyboard/msd-a11y-keyboard-manager.c | 16 |
3 files changed, 25 insertions, 39 deletions
diff --git a/plugins/a11y-keyboard/Makefile.am b/plugins/a11y-keyboard/Makefile.am index 92072e2..0ea0e4a 100644 --- a/plugins/a11y-keyboard/Makefile.am +++ b/plugins/a11y-keyboard/Makefile.am @@ -42,8 +42,6 @@ liba11y_keyboard_la_SOURCES = \ msd-a11y-keyboard-plugin.c \ msd-a11y-keyboard-manager.h \ msd-a11y-keyboard-manager.c \ - msd-a11y-keyboard-atspi.h \ - msd-a11y-keyboard-atspi.c \ msd-a11y-preferences-dialog.h \ msd-a11y-preferences-dialog.c \ $(NULL) @@ -57,7 +55,6 @@ liba11y_keyboard_la_CPPFLAGS = \ liba11y_keyboard_la_CFLAGS = \ $(SETTINGS_PLUGIN_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ - $(LIBATSPI_CFLAGS) \ $(AM_CFLAGS) \ $(WARN_CFLAGS) \ $(NULL) @@ -69,9 +66,19 @@ liba11y_keyboard_la_LDFLAGS = \ liba11y_keyboard_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(LIBNOTIFY_LIBS) \ - $(LIBATSPI_LIBS) \ $(NULL) +if HAVE_LIBATSPI +liba11y_keyboard_la_SOURCES += \ + msd-a11y-keyboard-atspi.h \ + msd-a11y-keyboard-atspi.c \ + $(NULL) +liba11y_keyboard_la_CFLAGS += \ + $(LIBATSPI_CFLAGS) +liba11y_keyboard_la_LIBADD += \ + $(LIBATSPI_LIBS) +endif + plugin_in_files = \ a11y-keyboard.mate-settings-plugin.desktop.in \ $(NULL) diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c index d4c3ec4..0873f0a 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c @@ -22,8 +22,6 @@ #include "msd-a11y-keyboard-atspi.h" #include <glib-object.h> - -#ifdef HAVE_LIBATSPI #include <gdk/gdk.h> #include <atspi/atspi.h> @@ -152,37 +150,6 @@ msd_a11y_keyboard_atspi_stop (MsdA11yKeyboardAtspi *self) self->listening = FALSE; } -#else /* ! defined(HAVE_LIBATSPI): AT-SPI is not available, provide stubs */ - -struct _MsdA11yKeyboardAtspi -{ - GObject parent; -}; - -G_DEFINE_TYPE (MsdA11yKeyboardAtspi, msd_a11y_keyboard_atspi, G_TYPE_OBJECT) - -static void -msd_a11y_keyboard_atspi_class_init (MsdA11yKeyboardAtspiClass *klass G_GNUC_UNUSED) -{ -} - -static void -msd_a11y_keyboard_atspi_init (MsdA11yKeyboardAtspi *self G_GNUC_UNUSED) -{ -} - -void -msd_a11y_keyboard_atspi_start (MsdA11yKeyboardAtspi *self G_GNUC_UNUSED) -{ -} - -void -msd_a11y_keyboard_atspi_stop (MsdA11yKeyboardAtspi *self G_GNUC_UNUSED) -{ -} - -#endif /* ! defined(HAVE_LIBATSPI) */ - MsdA11yKeyboardAtspi * msd_a11y_keyboard_atspi_new () { diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c index 67a690b..40fbdca 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c @@ -49,11 +49,15 @@ #include "mate-settings-profile.h" #include "msd-a11y-keyboard-manager.h" -#include "msd-a11y-keyboard-atspi.h" +#ifdef HAVE_LIBATSPI +# include "msd-a11y-keyboard-atspi.h" +#endif #include "msd-a11y-preferences-dialog.h" #define CONFIG_SCHEMA "org.mate.accessibility-keyboard" -#define KEY_CAPSLOCK_BEEP_ENABLED "capslock-beep-enable" +#ifdef HAVE_LIBATSPI +# define KEY_CAPSLOCK_BEEP_ENABLED "capslock-beep-enable" +#endif #define NOTIFICATION_TIMEOUT 30 struct MsdA11yKeyboardManagerPrivate @@ -66,7 +70,9 @@ struct MsdA11yKeyboardManagerPrivate GtkWidget *preferences_dialog; GtkStatusIcon *status_icon; XkbDescRec *original_xkb_desc; +#ifdef HAVE_LIBATSPI MsdA11yKeyboardAtspi *capslock_beep; +#endif GSettings *settings; @@ -987,6 +993,7 @@ keyboard_callback (GSettings *settings, maybe_show_status_icon (manager); } +#ifdef HAVE_LIBATSPI static void capslock_beep_callback (GSettings *settings, gchar *key G_GNUC_UNUSED, @@ -997,6 +1004,7 @@ capslock_beep_callback (GSettings *settings, else msd_a11y_keyboard_atspi_stop (manager->priv->capslock_beep); } +#endif static gboolean start_a11y_keyboard_idle_cb (MsdA11yKeyboardManager *manager) @@ -1008,11 +1016,13 @@ start_a11y_keyboard_idle_cb (MsdA11yKeyboardManager *manager) manager->priv->settings = g_settings_new (CONFIG_SCHEMA); +#ifdef HAVE_LIBATSPI manager->priv->capslock_beep = msd_a11y_keyboard_atspi_new (); if (g_settings_get_boolean (manager->priv->settings, KEY_CAPSLOCK_BEEP_ENABLED)) msd_a11y_keyboard_atspi_start (manager->priv->capslock_beep); g_signal_connect (manager->priv->settings, "changed::"KEY_CAPSLOCK_BEEP_ENABLED, G_CALLBACK (capslock_beep_callback), manager); +#endif if (!xkb_enabled (manager)) goto out; @@ -1126,7 +1136,9 @@ msd_a11y_keyboard_manager_stop (MsdA11yKeyboardManager *manager) p->slowkeys_shortcut_val = FALSE; p->stickykeys_shortcut_val = FALSE; +#ifdef HAVE_LIBATSPI g_clear_object (&p->capslock_beep); +#endif } static void |