diff options
Diffstat (limited to 'plugins')
136 files changed, 1611 insertions, 1294 deletions
diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c index 0873f0a..a45ef47 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2020 Colomban Wendling <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -54,16 +55,16 @@ msd_a11y_keyboard_atspi_class_init (MsdA11yKeyboardAtspiClass *klass) } static gboolean -on_key_press_event (const AtspiDeviceEvent *event, - void *user_data G_GNUC_UNUSED) +on_key_press_event (AtspiDeviceEvent *event, + void *user_data G_GNUC_UNUSED) { /* don't ring on capslock itself, that's taken care of by togglekeys * if the user want it. */ - if (event->id == GDK_KEY_Caps_Lock) - return FALSE; - - gdk_display_beep (gdk_display_get_default ()); + if (event->id != GDK_KEY_Caps_Lock) + gdk_display_beep (gdk_display_get_default ()); + /* cast the possible erroneous const away with atspi < 2.40 */ + g_boxed_free (ATSPI_TYPE_DEVICE_EVENT, (gpointer) event); return FALSE; } diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.h b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.h index fc97494..ec0c02b 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.h +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2020 Colomban Wendling <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c index e383ebd..d354db5 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c @@ -2,6 +2,7 @@ * * Copyright © 2001 Ximian, Inc. * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -202,8 +203,7 @@ get_xkb_desc_rec (MsdA11yKeyboardManager *manager) } gdk_x11_display_error_trap_pop_ignored (display); - g_return_val_if_fail (desc != NULL, NULL); - g_return_val_if_fail (desc->ctrls != NULL, NULL); + g_return_val_if_fail (desc != NULL && desc->ctrls != NULL, NULL); g_return_val_if_fail (status == Success, NULL); return desc; @@ -640,7 +640,6 @@ ax_slowkeys_warning_post_bubble (MsdA11yKeyboardManager *manager, #endif /* HAVE_LIBNOTIFY */ } - static void ax_slowkeys_warning_post_dialog (MsdA11yKeyboardManager *manager, gboolean enabled) @@ -1144,7 +1143,6 @@ start_a11y_keyboard_idle_cb (MsdA11yKeyboardManager *manager) return FALSE; } - gboolean msd_a11y_keyboard_manager_start (MsdA11yKeyboardManager *manager, GError **error) diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.h b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.h index b27a00f..050eed6 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.h +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.c b/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.c index ef84510..5679fa4 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.c +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.h b/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.h index 7967107..a2dfd7b 100644 --- a/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.h +++ b/plugins/a11y-keyboard/msd-a11y-keyboard-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c index f0cbb3b..8ef1af6 100644 --- a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c +++ b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -30,9 +31,6 @@ #include <glib-object.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> - -#include <dbus/dbus-glib.h> - #include <gio/gio.h> #include "msd-a11y-preferences-dialog.h" @@ -41,7 +39,6 @@ #define SM_DBUS_PATH "/org/gnome/SessionManager" #define SM_DBUS_INTERFACE "org.gnome.SessionManager" - #define GTKBUILDER_UI_FILE "msd-a11y-preferences-dialog.ui" #define KEY_A11Y_SCHEMA "org.mate.accessibility-keyboard" @@ -343,41 +340,44 @@ config_set_capslock_beep (MsdA11yPreferencesDialog *dialog, gboolean enabled) static gboolean config_have_at_gsettings_condition (const char *condition) { - DBusGProxy *sm_proxy; - DBusGConnection *connection; - GError *error; - gboolean res; - gboolean is_handled; - - error = NULL; - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) { + GDBusProxy *proxy = NULL; + GError *error = NULL; + GVariant *ret; + gboolean is_handled; + + proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + SM_DBUS_NAME, + SM_DBUS_PATH, + SM_DBUS_INTERFACE, + NULL, + &error); + if (proxy == NULL) { g_warning ("Unable to connect to session bus: %s", error->message); - return FALSE; - } - sm_proxy = dbus_g_proxy_new_for_name (connection, - SM_DBUS_NAME, - SM_DBUS_PATH, - SM_DBUS_INTERFACE); - if (sm_proxy == NULL) { + g_error_free (error); return FALSE; } is_handled = FALSE; - res = dbus_g_proxy_call (sm_proxy, - "IsAutostartConditionHandled", - &error, - G_TYPE_STRING, condition, - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &is_handled, - G_TYPE_INVALID); - if (! res) { + ret = g_dbus_proxy_call_sync (proxy, + "IsAutostartConditionHandled", + g_variant_new ("(s)", condition), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { g_warning ("Unable to call IsAutostartConditionHandled (%s): %s", condition, error->message); + g_error_free (error); + } else { + g_variant_get (ret, "(b)", &is_handled); + g_variant_unref (ret); } - g_object_unref (sm_proxy); + g_object_unref (proxy); return is_handled; } @@ -840,7 +840,6 @@ msd_a11y_preferences_dialog_init (MsdA11yPreferencesDialog *dialog) G_CALLBACK (on_response), dialog); - gtk_widget_show_all (GTK_WIDGET (dialog)); } diff --git a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.h b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.h index 4011497..780dfa1 100644 --- a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.h +++ b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-keyboard/test-a11y-preferences-dialog.c b/plugins/a11y-keyboard/test-a11y-preferences-dialog.c index 16d3f92..be2de98 100644 --- a/plugins/a11y-keyboard/test-a11y-preferences-dialog.c +++ b/plugins/a11y-keyboard/test-a11y-preferences-dialog.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/a11y-settings/msd-a11y-settings-manager.c b/plugins/a11y-settings/msd-a11y-settings-manager.c index e1c5302..1b88523 100644 --- a/plugins/a11y-settings/msd-a11y-settings-manager.c +++ b/plugins/a11y-settings/msd-a11y-settings-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-settings/msd-a11y-settings-manager.h b/plugins/a11y-settings/msd-a11y-settings-manager.h index 9f6e3f7..e5bdf69 100644 --- a/plugins/a11y-settings/msd-a11y-settings-manager.h +++ b/plugins/a11y-settings/msd-a11y-settings-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-settings/msd-a11y-settings-plugin.c b/plugins/a11y-settings/msd-a11y-settings-plugin.c index 6759c6f..58588d4 100644 --- a/plugins/a11y-settings/msd-a11y-settings-plugin.c +++ b/plugins/a11y-settings/msd-a11y-settings-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/a11y-settings/msd-a11y-settings-plugin.h b/plugins/a11y-settings/msd-a11y-settings-plugin.h index a19c8a4..71ba344 100644 --- a/plugins/a11y-settings/msd-a11y-settings-plugin.h +++ b/plugins/a11y-settings/msd-a11y-settings-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/background/msd-background-manager.c b/plugins/background/msd-background-manager.c index 686f3df..78a38bf 100644 --- a/plugins/background/msd-background-manager.c +++ b/plugins/background/msd-background-manager.c @@ -4,6 +4,7 @@ * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2007 Red Hat, Inc. * Copyright (C) 2012 Jasmine Hassan <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -49,7 +50,9 @@ #define MATE_SESSION_MANAGER_DBUS_NAME "org.gnome.SessionManager" #define MATE_SESSION_MANAGER_DBUS_PATH "/org/gnome/SessionManager" -struct MsdBackgroundManagerPrivate { +struct _MsdBackgroundManager { + GObject parent; + GSettings *settings; MateBG *bg; cairo_surface_t *surface; @@ -64,10 +67,10 @@ struct MsdBackgroundManagerPrivate { guint timeout_id; GDBusProxy *proxy; - guint proxy_signal_id; + gulong proxy_signal_id; }; -G_DEFINE_TYPE_WITH_PRIVATE (MsdBackgroundManager, msd_background_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (MsdBackgroundManager, msd_background_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; @@ -75,21 +78,21 @@ static gpointer manager_object = NULL; static gboolean msd_can_draw_bg (MsdBackgroundManager *manager) { - return g_settings_get_boolean (manager->priv->settings, MATE_BG_KEY_DRAW_BACKGROUND); + return g_settings_get_boolean (manager->settings, MATE_BG_KEY_DRAW_BACKGROUND); } /* Whether to change background with a fade effect */ static gboolean can_fade_bg (MsdBackgroundManager *manager) { - return g_settings_get_boolean (manager->priv->settings, MATE_BG_KEY_BACKGROUND_FADE); + return g_settings_get_boolean (manager->settings, MATE_BG_KEY_BACKGROUND_FADE); } /* Whether Caja is configured to draw desktop (show-desktop-icons) */ static gboolean caja_can_draw_bg (MsdBackgroundManager *manager) { - return g_settings_get_boolean (manager->priv->settings, MATE_BG_KEY_SHOW_DESKTOP); + return g_settings_get_boolean (manager->settings, MATE_BG_KEY_SHOW_DESKTOP); } static gboolean @@ -105,7 +108,7 @@ caja_is_drawing_bg (MsdBackgroundManager *manager) GdkDisplay *gdk_display; gboolean running = FALSE; - if (!manager->priv->caja_can_draw) + if (!manager->caja_can_draw) return FALSE; caja_prop = XInternAtom (display, "CAJA_DESKTOP_WINDOW_ID", True); @@ -154,28 +157,27 @@ caja_is_drawing_bg (MsdBackgroundManager *manager) static void free_fade (MsdBackgroundManager *manager) { - if (manager->priv->fade != NULL) { - g_object_unref (manager->priv->fade); - manager->priv->fade = NULL; + if (manager->fade != NULL) { + g_object_unref (manager->fade); + manager->fade = NULL; } } static void free_bg_surface (MsdBackgroundManager *manager) { - if (manager->priv->surface != NULL) { - cairo_surface_destroy (manager->priv->surface); - manager->priv->surface = NULL; + if (manager->surface != NULL) { + cairo_surface_destroy (manager->surface); + manager->surface = NULL; } } static void free_scr_sizes (MsdBackgroundManager *manager) { - if (manager->priv->scr_sizes != NULL) { - g_list_foreach (manager->priv->scr_sizes, (GFunc)g_free, NULL); - g_list_free (manager->priv->scr_sizes); - manager->priv->scr_sizes = NULL; + if (manager->scr_sizes != NULL) { + g_list_free_full (manager->scr_sizes, g_free); + manager->scr_sizes = NULL; } } @@ -183,51 +185,48 @@ static void real_draw_bg (MsdBackgroundManager *manager, GdkScreen *screen) { - MsdBackgroundManagerPrivate *p = manager->priv; GdkWindow *window = gdk_screen_get_root_window (screen); gint scale = gdk_window_get_scale_factor (window); gint width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; gint height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale; free_bg_surface (manager); - p->surface = mate_bg_create_surface_scale (p->bg, window, width, height, scale, TRUE); + manager->surface = mate_bg_create_surface_scale (manager->bg, window, width, height, scale, TRUE); - if (p->do_fade) + if (manager->do_fade) { free_fade (manager); - p->fade = mate_bg_set_surface_as_root_with_crossfade (screen, p->surface); - g_signal_connect_swapped (p->fade, "finished", G_CALLBACK (free_fade), manager); + manager->fade = mate_bg_set_surface_as_root_with_crossfade (screen, manager->surface); + g_signal_connect_swapped (manager->fade, "finished", G_CALLBACK (free_fade), manager); } else { - mate_bg_set_surface_as_root (screen, p->surface); + mate_bg_set_surface_as_root (screen, manager->surface); } - p->scr_sizes = g_list_prepend (p->scr_sizes, g_strdup_printf ("%dx%d", width, height)); + manager->scr_sizes = g_list_prepend (manager->scr_sizes, g_strdup_printf ("%dx%d", width, height)); } static void draw_background (MsdBackgroundManager *manager, gboolean may_fade) { - MsdBackgroundManagerPrivate *p = manager->priv; - - if (!p->msd_can_draw || p->draw_in_progress || caja_is_drawing_bg (manager)) + if (!manager->msd_can_draw || manager->draw_in_progress || caja_is_drawing_bg (manager)) return; mate_settings_profile_start (NULL); - GdkDisplay *display = gdk_display_get_default (); + GdkDisplay *display = gdk_display_get_default (); - p->draw_in_progress = TRUE; - p->do_fade = may_fade && can_fade_bg (manager); + manager->draw_in_progress = TRUE; + manager->do_fade = may_fade && can_fade_bg (manager); free_scr_sizes (manager); g_debug ("Drawing background on Screen"); real_draw_bg (manager, gdk_display_get_default_screen (display)); - p->scr_sizes = g_list_reverse (p->scr_sizes); + manager->scr_sizes = g_list_reverse (manager->scr_sizes); - p->draw_in_progress = FALSE; + manager->draw_in_progress = FALSE; mate_settings_profile_end (NULL); } @@ -251,15 +250,13 @@ static void on_screen_size_changed (GdkScreen *screen, MsdBackgroundManager *manager) { - MsdBackgroundManagerPrivate *p = manager->priv; - - if (!p->msd_can_draw || p->draw_in_progress || caja_is_drawing_bg (manager)) + if (!manager->msd_can_draw || manager->draw_in_progress || caja_is_drawing_bg (manager)) return; GdkWindow *window = gdk_screen_get_root_window (screen); gint scale = gdk_window_get_scale_factor (window); gint scr_num = gdk_x11_screen_get_screen_number (screen); - gchar *old_size = g_list_nth_data (manager->priv->scr_sizes, scr_num); + gchar *old_size = g_list_nth_data (manager->scr_sizes, (guint) scr_num); gchar *new_size = g_strdup_printf ("%dx%d", WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale); if (g_strcmp0 (old_size, new_size) != 0) @@ -300,7 +297,7 @@ settings_change_event_idle_cb (MsdBackgroundManager *manager) { mate_settings_profile_start ("settings_change_event_idle_cb"); - mate_bg_load_from_preferences (manager->priv->bg); + mate_bg_load_from_preferences (manager->bg); mate_settings_profile_end ("settings_change_event_idle_cb"); @@ -313,13 +310,11 @@ settings_change_event_cb (GSettings *settings G_GNUC_UNUSED, gint n_keys G_GNUC_UNUSED, MsdBackgroundManager *manager) { - MsdBackgroundManagerPrivate *p = manager->priv; - /* Complements on_bg_handling_changed() */ - p->msd_can_draw = msd_can_draw_bg (manager); - p->caja_can_draw = caja_can_draw_bg (manager); + manager->msd_can_draw = msd_can_draw_bg (manager); + manager->caja_can_draw = caja_can_draw_bg (manager); - if (p->msd_can_draw && p->bg != NULL && !caja_is_drawing_bg (manager)) + if (manager->msd_can_draw && manager->bg != NULL && !caja_is_drawing_bg (manager)) { /* Defer signal processing to avoid making the dconf backend deadlock */ g_idle_add ((GSourceFunc) settings_change_event_idle_cb, manager); @@ -331,42 +326,39 @@ settings_change_event_cb (GSettings *settings G_GNUC_UNUSED, static void setup_background (MsdBackgroundManager *manager) { - MsdBackgroundManagerPrivate *p = manager->priv; - g_return_if_fail (p->bg == NULL); + g_return_if_fail (manager->bg == NULL); - p->bg = mate_bg_new(); + manager->bg = mate_bg_new(); - p->draw_in_progress = FALSE; + manager->draw_in_progress = FALSE; - g_signal_connect(p->bg, "changed", G_CALLBACK (on_bg_changed), manager); + g_signal_connect(manager->bg, "changed", G_CALLBACK (on_bg_changed), manager); - g_signal_connect(p->bg, "transitioned", G_CALLBACK (on_bg_transitioned), manager); + g_signal_connect(manager->bg, "transitioned", G_CALLBACK (on_bg_transitioned), manager); - mate_bg_load_from_gsettings (p->bg, p->settings); + mate_bg_load_from_gsettings (manager->bg, manager->settings); connect_screen_signals (manager); - g_signal_connect (p->settings, "change-event", + g_signal_connect (manager->settings, "change-event", G_CALLBACK (settings_change_event_cb), manager); } static void remove_background (MsdBackgroundManager *manager) { - MsdBackgroundManagerPrivate *p = manager->priv; - disconnect_screen_signals (manager); - g_signal_handlers_disconnect_by_func (p->settings, settings_change_event_cb, manager); + g_signal_handlers_disconnect_by_func (manager->settings, settings_change_event_cb, manager); - if (p->settings != NULL) { - g_object_unref (G_OBJECT (p->settings)); - p->settings = NULL; + if (manager->settings != NULL) { + g_object_unref (manager->settings); + manager->settings = NULL; } - if (p->bg != NULL) { - g_object_unref (G_OBJECT (p->bg)); - p->bg = NULL; + if (manager->bg != NULL) { + g_object_unref (manager->bg); + manager->bg = NULL; } free_scr_sizes (manager); @@ -379,16 +371,14 @@ on_bg_handling_changed (GSettings *settings G_GNUC_UNUSED, const char *key G_GNUC_UNUSED, MsdBackgroundManager *manager) { - MsdBackgroundManagerPrivate *p = manager->priv; - mate_settings_profile_start (NULL); if (caja_is_drawing_bg (manager)) { - if (p->bg != NULL) + if (manager->bg != NULL) remove_background (manager); } - else if (p->msd_can_draw && p->bg == NULL) + else if (manager->msd_can_draw && manager->bg == NULL) { setup_background (manager); } @@ -399,7 +389,7 @@ on_bg_handling_changed (GSettings *settings G_GNUC_UNUSED, static gboolean queue_setup_background (MsdBackgroundManager *manager) { - manager->priv->timeout_id = 0; + manager->timeout_id = 0; setup_background (manager); @@ -409,7 +399,7 @@ queue_setup_background (MsdBackgroundManager *manager) static void queue_timeout (MsdBackgroundManager *manager) { - if (manager->priv->timeout_id > 0) + if (manager->timeout_id > 0) return; /* SessionRunning: now check if Caja is drawing background, and if not, set it. @@ -418,18 +408,23 @@ queue_timeout (MsdBackgroundManager *manager) * session manager that its ready before it sets the background. * https://bugzilla.gnome.org/show_bug.cgi?id=568588 */ - manager->priv->timeout_id = + manager->timeout_id = g_timeout_add_seconds (8, (GSourceFunc) queue_setup_background, manager); } static void disconnect_session_manager_listener (MsdBackgroundManager* manager) { - if (manager->priv->proxy && manager->priv->proxy_signal_id) { - g_signal_handler_disconnect (manager->priv->proxy, - manager->priv->proxy_signal_id); - manager->priv->proxy_signal_id = 0; +#if GLIB_CHECK_VERSION(2,62,0) + if (manager->proxy) { + g_clear_signal_handler (&manager->proxy_signal_id, manager->proxy); + } +#else + if (manager->proxy && manager->proxy_signal_id) { + g_signal_handler_disconnect (manager->proxy, manager->proxy_signal_id); + manager->proxy_signal_id = 0; } +#endif } static void @@ -455,22 +450,22 @@ draw_bg_after_session_loads (MsdBackgroundManager *manager) flags = G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START; - manager->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, - flags, - NULL, /* GDBusInterfaceInfo */ - MATE_SESSION_MANAGER_DBUS_NAME, - MATE_SESSION_MANAGER_DBUS_PATH, - MATE_SESSION_MANAGER_DBUS_NAME, - NULL, /* GCancellable */ - &error); - if (manager->priv->proxy == NULL) { + manager->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + flags, + NULL, /* GDBusInterfaceInfo */ + MATE_SESSION_MANAGER_DBUS_NAME, + MATE_SESSION_MANAGER_DBUS_PATH, + MATE_SESSION_MANAGER_DBUS_NAME, + NULL, /* GCancellable */ + &error); + if (manager->proxy == NULL) { g_warning ("Could not listen to session manager: %s", error->message); g_error_free (error); return; } - manager->priv->proxy_signal_id = g_signal_connect (manager->priv->proxy, + manager->proxy_signal_id = g_signal_connect (manager->proxy, "g-signal", G_CALLBACK (on_session_manager_signal), manager); @@ -480,35 +475,29 @@ gboolean msd_background_manager_start (MsdBackgroundManager *manager, GError **error) { - MsdBackgroundManagerPrivate *p = manager->priv; - g_debug ("Starting background manager"); mate_settings_profile_start (NULL); - p->settings = g_settings_new (MATE_BG_SCHEMA); + manager->settings = g_settings_new (MATE_BG_SCHEMA); - p->msd_can_draw = msd_can_draw_bg (manager); - p->caja_can_draw = caja_can_draw_bg (manager); + manager->msd_can_draw = msd_can_draw_bg (manager); + manager->caja_can_draw = caja_can_draw_bg (manager); - g_signal_connect (p->settings, "changed::" MATE_BG_KEY_DRAW_BACKGROUND, - G_CALLBACK (on_bg_handling_changed), manager); - g_signal_connect (p->settings, "changed::" MATE_BG_KEY_SHOW_DESKTOP, - G_CALLBACK (on_bg_handling_changed), manager); + g_signal_connect (manager->settings, "changed::" MATE_BG_KEY_DRAW_BACKGROUND, + G_CALLBACK (on_bg_handling_changed), manager); + g_signal_connect (manager->settings, "changed::" MATE_BG_KEY_SHOW_DESKTOP, + G_CALLBACK (on_bg_handling_changed), manager); /* If Caja is set to draw the background, it is very likely in our session. * But it might not be started yet, so caja_is_drawing_bg() would fail. * In this case, we wait till the session is loaded, to avoid double-draws. */ - if (p->msd_can_draw) + if (manager->msd_can_draw) { - if (p->caja_can_draw) - { + if (manager->caja_can_draw) draw_bg_after_session_loads (manager); - } else - { setup_background (manager); - } } mate_settings_profile_end (NULL); @@ -521,15 +510,15 @@ msd_background_manager_stop (MsdBackgroundManager *manager) { g_debug ("Stopping background manager"); - if (manager->priv->proxy) + if (manager->proxy) { disconnect_session_manager_listener (manager); - g_object_unref (manager->priv->proxy); + g_object_unref (manager->proxy); } - if (manager->priv->timeout_id != 0) { - g_source_remove (manager->priv->timeout_id); - manager->priv->timeout_id = 0; + if (manager->timeout_id != 0) { + g_source_remove (manager->timeout_id); + manager->timeout_id = 0; } remove_background (manager); @@ -554,17 +543,12 @@ msd_background_manager_finalize (GObject *object) g_return_if_fail (object != NULL); g_return_if_fail (MSD_IS_BACKGROUND_MANAGER (object)); - MsdBackgroundManager *manager = MSD_BACKGROUND_MANAGER (object); - - g_return_if_fail (manager->priv != NULL); - G_OBJECT_CLASS(msd_background_manager_parent_class)->finalize(object); } static void msd_background_manager_init (MsdBackgroundManager* manager) { - manager->priv = msd_background_manager_get_instance_private(manager); } static void diff --git a/plugins/background/msd-background-manager.h b/plugins/background/msd-background-manager.h index 36231a3..8fd4895 100644 --- a/plugins/background/msd-background-manager.h +++ b/plugins/background/msd-background-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -18,51 +19,24 @@ * */ -#ifndef __MSD_BACKGROUND_MANAGER_H -#define __MSD_BACKGROUND_MANAGER_H +#ifndef MSD_BACKGROUND_MANAGER_H +#define MSD_BACKGROUND_MANAGER_H #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS -//class MsdBackgroundManager -//{ - #define MSD_TYPE_BACKGROUND_MANAGER (msd_background_manager_get_type()) - #define MSD_BACKGROUND_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MSD_TYPE_BACKGROUND_MANAGER, MsdBackgroundManager)) - #define MSD_BACKGROUND_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MSD_TYPE_BACKGROUND_MANAGER, MsdBackgroundManagerClass)) - #define MSD_IS_BACKGROUND_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MSD_TYPE_BACKGROUND_MANAGER)) - #define MSD_IS_BACKGROUND_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MSD_TYPE_BACKGROUND_MANAGER)) - #define MSD_BACKGROUND_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MSD_TYPE_BACKGROUND_MANAGER, MsdBackgroundManagerClass)) +#define MSD_TYPE_BACKGROUND_MANAGER (msd_background_manager_get_type()) - typedef struct MsdBackgroundManagerPrivate MsdBackgroundManagerPrivate; +G_DECLARE_FINAL_TYPE (MsdBackgroundManager, msd_background_manager, MSD, BACKGROUND_MANAGER, GObject) - typedef struct { - GObject parent; - MsdBackgroundManagerPrivate* priv; - } MsdBackgroundManager; +MsdBackgroundManager * msd_background_manager_new (void); - typedef struct { - GObjectClass parent_class; - } MsdBackgroundManagerClass; +gboolean msd_background_manager_start (MsdBackgroundManager *manager, + GError **error); - GType - msd_background_manager_get_type (void); +void msd_background_manager_stop (MsdBackgroundManager *manager); - MsdBackgroundManager* - msd_background_manager_new (void); +G_END_DECLS - gboolean - msd_background_manager_start (MsdBackgroundManager* manager, - GError** error); - - void - msd_background_manager_stop (MsdBackgroundManager* manager); -//} - -#ifdef __cplusplus -} -#endif - -#endif /* __MSD_BACKGROUND_MANAGER_H */ +#endif /* MSD_BACKGROUND_MANAGER_H */ diff --git a/plugins/background/msd-background-plugin.c b/plugins/background/msd-background-plugin.c index 7957230..55d88f5 100644 --- a/plugins/background/msd-background-plugin.c +++ b/plugins/background/msd-background-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/background/msd-background-plugin.h b/plugins/background/msd-background-plugin.h index 460c303..9ea5b1a 100644 --- a/plugins/background/msd-background-plugin.h +++ b/plugins/background/msd-background-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/background/test-background.c b/plugins/background/test-background.c index 33d4ea3..a2a5be1 100644 --- a/plugins/background/test-background.c +++ b/plugins/background/test-background.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/clipboard/list.c b/plugins/clipboard/list.c index 7f60bb1..eaadcf8 100644 --- a/plugins/clipboard/list.c +++ b/plugins/clipboard/list.c @@ -1,5 +1,6 @@ /* * Copyright © 2004 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -24,7 +25,6 @@ #include <stdlib.h> #include <list.h> - void list_foreach (List *list, Callback func, @@ -82,7 +82,7 @@ list_find (List *list, List * list_remove (List *list, - void *data) + const void *data) { List *tmp, *prev; diff --git a/plugins/clipboard/list.h b/plugins/clipboard/list.h index 04cf1e1..fcbbf02 100644 --- a/plugins/clipboard/list.h +++ b/plugins/clipboard/list.h @@ -1,5 +1,6 @@ /* * Copyright © 2004 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -23,12 +24,10 @@ #ifndef LIST_H #define LIST_H - typedef struct _List List; typedef void (*Callback) (void *data, void *user_data); - struct _List { void *data; @@ -49,7 +48,7 @@ List *list_find (List *list, ListFindFunc func, void *user_data); List *list_remove (List *list, - void *data); + const void *data); int list_length (List *list); List *list_copy (List *list); diff --git a/plugins/clipboard/msd-clipboard-manager.c b/plugins/clipboard/msd-clipboard-manager.c index fb5ddba..ef4007a 100644 --- a/plugins/clipboard/msd-clipboard-manager.c +++ b/plugins/clipboard/msd-clipboard-manager.c @@ -4,6 +4,7 @@ * Copyright (C) 2007 Anders Carlsson * Copyright (C) 2007 Rodrigo Moya * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -404,7 +405,6 @@ convert_clipboard_manager (MsdClipboardManager *manager, int format; unsigned long nitems; unsigned long remaining; - Atom *targets = NULL; display = gdk_display_get_default (); @@ -415,6 +415,8 @@ convert_clipboard_manager (MsdClipboardManager *manager, */ finish_selection_request (manager, xev, False); } else { + Atom *targets = NULL; + gdk_x11_display_error_trap_push (display); clipboard_manager_watch_cb (manager, @@ -858,7 +860,6 @@ start_clipboard_idle_cb (MsdClipboardManager *manager) { XClientMessageEvent xev; - mate_settings_profile_start (NULL); init_atoms (manager->priv->display); diff --git a/plugins/clipboard/msd-clipboard-manager.h b/plugins/clipboard/msd-clipboard-manager.h index 5e4465a..04ca380 100644 --- a/plugins/clipboard/msd-clipboard-manager.h +++ b/plugins/clipboard/msd-clipboard-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/clipboard/msd-clipboard-plugin.c b/plugins/clipboard/msd-clipboard-plugin.c index 7951c60..5c6fa76 100644 --- a/plugins/clipboard/msd-clipboard-plugin.c +++ b/plugins/clipboard/msd-clipboard-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/clipboard/msd-clipboard-plugin.h b/plugins/clipboard/msd-clipboard-plugin.h index 171282d..6953f17 100644 --- a/plugins/clipboard/msd-clipboard-plugin.h +++ b/plugins/clipboard/msd-clipboard-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/clipboard/xutils.c b/plugins/clipboard/xutils.c index ef57a85..4aba854 100644 --- a/plugins/clipboard/xutils.c +++ b/plugins/clipboard/xutils.c @@ -1,5 +1,6 @@ /* * Copyright © 2004 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -41,7 +42,6 @@ Atom XA_TIMESTAMP; unsigned long SELECTION_MAX_SIZE = 0; - void init_atoms (Display *display) { diff --git a/plugins/clipboard/xutils.h b/plugins/clipboard/xutils.h index 12a00e4..01aab6f 100644 --- a/plugins/clipboard/xutils.h +++ b/plugins/clipboard/xutils.h @@ -1,5 +1,6 @@ /* * Copyright © 2004 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -25,7 +26,6 @@ #include <X11/Xlib.h> - extern Atom XA_ATOM_PAIR; extern Atom XA_CLIPBOARD_MANAGER; extern Atom XA_CLIPBOARD; diff --git a/plugins/common/eggaccelerators.c b/plugins/common/eggaccelerators.c index 9662a3f..0f924d3 100644 --- a/plugins/common/eggaccelerators.c +++ b/plugins/common/eggaccelerators.c @@ -1,5 +1,6 @@ /* eggaccelerators.c * Copyright (C) 2002 Red Hat, Inc.; Copyright 1998, 2001 Tim Janik + * Copyright (C) 2012-2021 MATE Developers * Developed by Havoc Pennington, Tim Janik * * This library is free software; you can redistribute it and/or diff --git a/plugins/common/eggaccelerators.h b/plugins/common/eggaccelerators.h index 8584373..547cf9f 100644 --- a/plugins/common/eggaccelerators.h +++ b/plugins/common/eggaccelerators.h @@ -1,5 +1,6 @@ /* eggaccelerators.h * Copyright (C) 2002 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * Developed by Havoc Pennington * * This library is free software; you can redistribute it and/or @@ -94,5 +95,4 @@ gchar* egg_virtual_accelerator_label (guint accelerator_key, } #endif - #endif /* __EGG_ACCELERATORS_H__ */ diff --git a/plugins/common/msd-input-helper.c b/plugins/common/msd-input-helper.c index 5434014..05fad76 100644 --- a/plugins/common/msd-input-helper.c +++ b/plugins/common/msd-input-helper.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Bastien Nocera <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -120,8 +121,8 @@ touchpad_is_present (void) break; } } - if (device_info != NULL) - XFreeDeviceList (device_info); + + XFreeDeviceList (device_info); return retval; } diff --git a/plugins/common/msd-input-helper.h b/plugins/common/msd-input-helper.h index e46c97e..8f722e4 100644 --- a/plugins/common/msd-input-helper.h +++ b/plugins/common/msd-input-helper.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Bastien Nocera <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/common/msd-keygrab.c b/plugins/common/msd-keygrab.c index a0f4105..0ea0cc1 100644 --- a/plugins/common/msd-keygrab.c +++ b/plugins/common/msd-keygrab.c @@ -3,6 +3,7 @@ * Copyright (C) 2001-2003 Bastien Nocera <[email protected]> * Copyright (C) 2006-2007 William Jon McCann <[email protected]> * Copyright (C) 2008 Jens Granseuer <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -240,7 +241,6 @@ match_key (Key *key, XEvent *event) } /* The key we passed doesn't have a keysym, so try with just the keycode */ - return (key != NULL - && key->state == (event->xkey.state & msd_used_mods) + return (key->state == (event->xkey.state & msd_used_mods) && key_uses_keycode (key, event->xkey.keycode)); } diff --git a/plugins/common/msd-keygrab.h b/plugins/common/msd-keygrab.h index ff633d6..03892ca 100644 --- a/plugins/common/msd-keygrab.h +++ b/plugins/common/msd-keygrab.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Jens Granseuer <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -33,7 +34,6 @@ typedef struct { guint *keycodes; } Key; - void grab_key_unsafe (Key *key, gboolean grab, GSList *screens); diff --git a/plugins/common/msd-osd-window.c b/plugins/common/msd-osd-window.c index bc1ffb6..d241cfb 100644 --- a/plugins/common/msd-osd-window.c +++ b/plugins/common/msd-osd-window.c @@ -4,6 +4,7 @@ * * Copyright (C) 2006-2007 William Jon McCann <[email protected]> * Copyright (C) 2009 Novell, Inc + * Copyright (C) 2012-2021 MATE Developers * * Authors: * William Jon McCann <[email protected]> @@ -440,7 +441,7 @@ msd_osd_window_init (MsdOsdWindow *window) screen = gtk_widget_get_screen (GTK_WIDGET (window)); - window->priv->is_composited = gdk_screen_is_composited (screen); + window->priv->is_composited = (gdk_screen_is_composited (screen) != FALSE); window->priv->scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (window)); if (window->priv->is_composited) { diff --git a/plugins/common/msd-osd-window.h b/plugins/common/msd-osd-window.h index ac3325a..23651d2 100644 --- a/plugins/common/msd-osd-window.h +++ b/plugins/common/msd-osd-window.h @@ -4,6 +4,7 @@ * * Copyright (C) 2006 William Jon McCann <[email protected]> * Copyright (C) 2009 Novell, Inc + * Copyright (C) 2012-2021 MATE Developers * * Authors: * William Jon McCann <[email protected]> diff --git a/plugins/datetime/Makefile.am b/plugins/datetime/Makefile.am index a920100..88b1174 100644 --- a/plugins/datetime/Makefile.am +++ b/plugins/datetime/Makefile.am @@ -5,16 +5,17 @@ polkitdir = $(datadir)/polkit-1/actions dbus_services_in_files = org.mate.SettingsDaemon.DateTimeMechanism.service.in polkit_in_files = org.mate.settingsdaemon.datetimemechanism.policy.in -msd-datetime-mechanism-glue.h: $(srcdir)/msd-datetime-mechanism.xml - $(AM_V_GEN) dbus-binding-tool \ - --prefix=msd_datetime_mechanism --mode=glib-server \ - --output=msd-datetime-mechanism-glue.h \ - $(srcdir)/msd-datetime-mechanism.xml +$(BUILT_SOURCES) : $(srcdir)/msd-datetime-mechanism.xml + $(AM_V_GEN) $(GDBUS_CODEGEN) \ + --interface-prefix org.mate.SettingsDaemon. \ + --c-namespace MateSettings \ + --generate-c-code msd-datetime-generated $< if HAVE_POLKIT libexec_PROGRAMS = msd-datetime-mechanism endif +nodist_msd_datetime_mechanism_SOURCES = $(BUILT_SOURCES) msd_datetime_mechanism_SOURCES = \ msd-datetime-mechanism.c \ msd-datetime-mechanism.h \ @@ -24,7 +25,9 @@ msd_datetime_mechanism_SOURCES = \ if HAVE_POLKIT -BUILT_SOURCES = msd-datetime-mechanism-glue.h +BUILT_SOURCES = \ + msd-datetime-generated.h \ + msd-datetime-generated.c endif AM_CFLAGS = $(WARN_CFLAGS) $(SETTINGS_PLUGIN_CFLAGS) $(POLKIT_CFLAGS) diff --git a/plugins/datetime/msd-datetime-mechanism-main.c b/plugins/datetime/msd-datetime-mechanism-main.c index 473c968..981d8ea 100644 --- a/plugins/datetime/msd-datetime-mechanism-main.c +++ b/plugins/datetime/msd-datetime-mechanism-main.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 David Zeuthen <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -34,128 +35,25 @@ #include <glib.h> #include <glib-object.h> - -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - - #include "msd-datetime-mechanism.h" -static DBusGProxy * -get_bus_proxy (DBusGConnection *connection) -{ - DBusGProxy *bus_proxy; - - bus_proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - return bus_proxy; -} - -#define BUS_NAME "org.mate.SettingsDaemon.DateTimeMechanism" - -static gboolean -acquire_name_on_proxy (DBusGProxy *bus_proxy) -{ - GError *error; - guint result; - gboolean res; - gboolean ret; - - ret = FALSE; - - if (bus_proxy == NULL) { - goto out; - } - - error = NULL; - res = dbus_g_proxy_call (bus_proxy, - "RequestName", - &error, - G_TYPE_STRING, BUS_NAME, - G_TYPE_UINT, 0, - G_TYPE_INVALID, - G_TYPE_UINT, &result, - G_TYPE_INVALID); - if (! res) { - if (error != NULL) { - g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); - g_error_free (error); - } else { - g_warning ("Failed to acquire %s", BUS_NAME); - } - goto out; - } - - if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - if (error != NULL) { - g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); - g_error_free (error); - } else { - g_warning ("Failed to acquire %s", BUS_NAME); - } - goto out; - } - - ret = TRUE; - - out: - return ret; -} - -static DBusGConnection * -get_system_bus (void) -{ - GError *error; - DBusGConnection *bus; - - error = NULL; - bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (bus == NULL) { - g_warning ("Couldn't connect to system bus: %s", error->message); - g_error_free (error); - } - return bus; -} - int main (int argc, char **argv) { GMainLoop *loop; MsdDatetimeMechanism *mechanism; - DBusGProxy *bus_proxy; - DBusGConnection *connection; int ret; ret = 1; - dbus_g_thread_init (); - - connection = get_system_bus (); - if (connection == NULL) { - goto out; - } - - bus_proxy = get_bus_proxy (connection); - if (bus_proxy == NULL) { - g_warning ("Could not construct bus_proxy object; bailing out"); - goto out; - } - - if (!acquire_name_on_proxy (bus_proxy) ) { - g_warning ("Could not acquire name; bailing out"); - goto out; - } + loop = g_main_loop_new (NULL, FALSE); - mechanism = msd_datetime_mechanism_new (); + mechanism = msd_datetime_mechanism_new (loop); if (mechanism == NULL) { goto out; } - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); g_object_unref (mechanism); diff --git a/plugins/datetime/msd-datetime-mechanism.c b/plugins/datetime/msd-datetime-mechanism.c index 4dd569c..3d4bf6b 100644 --- a/plugins/datetime/msd-datetime-mechanism.c +++ b/plugins/datetime/msd-datetime-mechanism.c @@ -1,6 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * vim: set ts=8 sts=8 sw=8 expandtab: * * Copyright (C) 2007 David Zeuthen <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -33,27 +35,87 @@ #include <glib.h> #include <glib-object.h> - -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - #include <polkit/polkit.h> #include "system-timezone.h" - #include "msd-datetime-mechanism.h" -#include "msd-datetime-mechanism-glue.h" +#include "msd-datetime-generated.h" + +#define MSD_DATETIME_DBUS_NAME "org.mate.SettingsDaemon.DateTimeMechanism" +#define MSD_DATETIME_DBUS_PATH "/" + +enum { + PROP_0, + PROP_LOOP, + LAST_PROP +}; + +struct MsdDatetimeMechanismPrivate +{ + MateSettingsDateTimeMechanism *skeleton; + guint bus_name_id; + GMainLoop *loop; + PolkitAuthority *auth; +}; + +static GParamSpec *properties[LAST_PROP] = { NULL }; + +static void msd_datetime_mechanism_dispose (GObject *object); +static gboolean msd_datetime_mechanism_can_set_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data); +static gboolean msd_datetime_mechanism_get_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data); +static gboolean msd_datetime_mechanism_set_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + const gchar *arg_zonefile, + gpointer user_data); + +static gboolean msd_datetime_mechanism_adjust_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gint64 arg_seconds_to_add, + gpointer user_data); +static gboolean msd_datetime_mechanism_can_set_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data); +static gboolean msd_datetime_mechanism_get_hardware_clock_using_utc_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data); +static gboolean msd_datetime_mechanism_set_hardware_clock_using_utc_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gboolean arg_is_using_utc, + gpointer user_data); +static gboolean msd_datetime_mechanism_set_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gint64 arg_seconds_since_epoch, + gpointer user_data); +static gboolean _set_time (MsdDatetimeMechanism *mechanism, + const struct timeval *tv, + GError **error); +static gboolean _check_polkit_for_action (MsdDatetimeMechanism *mechanism, + const char *action, + const char *sender, + GError **error); +static gboolean _rh_update_etc_sysconfig_clock (const char *key, + const char *value, + GError **error); + +G_DEFINE_TYPE_WITH_PRIVATE (MsdDatetimeMechanism, msd_datetime_mechanism, G_TYPE_OBJECT) static gboolean do_exit (gpointer user_data) { + GMainLoop *loop; + + loop = (GMainLoop*)user_data; g_debug ("Exiting due to inactivity"); - exit (1); + g_main_loop_quit (loop); return FALSE; } static void -reset_killtimer (void) +reset_killtimer (GMainLoop *loop) { static guint timer_id = 0; @@ -61,20 +123,9 @@ reset_killtimer (void) g_source_remove (timer_id); } g_debug ("Setting killtimer to 30 seconds..."); - timer_id = g_timeout_add_seconds (30, do_exit, NULL); + timer_id = g_timeout_add_seconds (30, do_exit, loop); } -struct MsdDatetimeMechanismPrivate -{ - DBusGConnection *system_bus_connection; - DBusGProxy *system_bus_proxy; - PolkitAuthority *auth; -}; - -static void msd_datetime_mechanism_finalize (GObject *object); - -G_DEFINE_TYPE_WITH_PRIVATE (MsdDatetimeMechanism, msd_datetime_mechanism, G_TYPE_OBJECT) - GQuark msd_datetime_mechanism_error_quark (void) { @@ -87,7 +138,6 @@ msd_datetime_mechanism_error_quark (void) return ret; } - #define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } GType @@ -113,180 +163,235 @@ msd_datetime_mechanism_error_get_type (void) return etype; } - -static GObject * -msd_datetime_mechanism_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) -{ - MsdDatetimeMechanism *mechanism; - - mechanism = MSD_DATETIME_MECHANISM (G_OBJECT_CLASS (msd_datetime_mechanism_parent_class)->constructor ( - type, - n_construct_properties, - construct_properties)); - - return G_OBJECT (mechanism); -} - -static void -msd_datetime_mechanism_class_init (MsdDatetimeMechanismClass *klass) +static gboolean +msd_datetime_mechanism_adjust_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gint64 seconds_to_add, + gpointer user_data) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + struct timeval tv; + gboolean ret = FALSE; + GError *error = NULL; + MsdDatetimeMechanism *mechanism; - object_class->constructor = msd_datetime_mechanism_constructor; - object_class->finalize = msd_datetime_mechanism_finalize; + mechanism = MSD_DATETIME_MECHANISM (user_data); - dbus_g_object_type_install_info (MSD_DATETIME_TYPE_MECHANISM, &dbus_glib_msd_datetime_mechanism_object_info); + reset_killtimer (mechanism->priv->loop); + g_debug ("AdjustTime(%ld) called", seconds_to_add); - dbus_g_error_domain_register (MSD_DATETIME_MECHANISM_ERROR, NULL, MSD_DATETIME_MECHANISM_TYPE_ERROR); + if (gettimeofday (&tv, NULL) != 0) { + error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error calling gettimeofday(): %s", strerror (errno)); + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + return FALSE; + } -} + if (!_check_polkit_for_action (mechanism, + "org.mate.settingsdaemon.datetimemechanism.settime", + g_dbus_method_invocation_get_sender (invocation), + &error)) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + return FALSE; + } -static void -msd_datetime_mechanism_init (MsdDatetimeMechanism *mechanism) -{ - mechanism->priv = msd_datetime_mechanism_get_instance_private (mechanism); + tv.tv_sec += (time_t) seconds_to_add; + ret = _set_time (mechanism, &tv, &error); + if (!ret) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + } else { + mate_settings_date_time_mechanism_complete_adjust_time (object, invocation); + } + return ret; } -static void -msd_datetime_mechanism_finalize (GObject *object) +static gint +check_can_do (MsdDatetimeMechanism *mechanism, + const char *action, + const char *sender, + GError **error) { - MsdDatetimeMechanism *mechanism; - - g_return_if_fail (object != NULL); - g_return_if_fail (MSD_DATETIME_IS_MECHANISM (object)); + gint value = -1; + PolkitSubject *subject; + PolkitAuthorizationResult *result; - mechanism = MSD_DATETIME_MECHANISM (object); + /* Check that caller is privileged */ + subject = polkit_system_bus_name_new (sender); + result = polkit_authority_check_authorization_sync (mechanism->priv->auth, + subject, + action, + NULL, + 0, + NULL, + error); + g_object_unref (subject); - g_return_if_fail (mechanism->priv != NULL); + if (*error != NULL) { + return value; + } - g_object_unref (mechanism->priv->system_bus_proxy); + if (polkit_authorization_result_get_is_authorized (result)) { + value = 2; + } + else if (polkit_authorization_result_get_is_challenge (result)) { + value = 1; + } + else { + value = 0; + } - G_OBJECT_CLASS (msd_datetime_mechanism_parent_class)->finalize (object); + g_object_unref (result); + return value; } + static gboolean -register_mechanism (MsdDatetimeMechanism *mechanism) +msd_datetime_mechanism_can_set_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data) { + gboolean ret = FALSE; + gint value; GError *error = NULL; + MsdDatetimeMechanism *mechanism; - mechanism->priv->auth = polkit_authority_get_sync (NULL, &error); - if (mechanism->priv->auth == NULL) { - if (error != NULL) { - g_critical ("error getting system bus: %s", error->message); - g_error_free (error); - } - goto error; - } + mechanism = MSD_DATETIME_MECHANISM (user_data); - mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (mechanism->priv->system_bus_connection == NULL) { - if (error != NULL) { - g_critical ("error getting system bus: %s", error->message); - g_error_free (error); - } - goto error; + value = check_can_do (mechanism, + "org.mate.settingsdaemon.datetimemechanism.settime", + g_dbus_method_invocation_get_sender (invocation), + &error); + if (error != NULL) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + ret = FALSE; + } else { + mate_settings_date_time_mechanism_complete_can_set_time (object, invocation, value); + ret = TRUE; } - dbus_g_connection_register_g_object (mechanism->priv->system_bus_connection, "/", - G_OBJECT (mechanism)); - - mechanism->priv->system_bus_proxy = dbus_g_proxy_new_for_name (mechanism->priv->system_bus_connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - reset_killtimer (); - - return TRUE; - -error: - return FALSE; + return ret; } - -MsdDatetimeMechanism * -msd_datetime_mechanism_new (void) +static gboolean +msd_datetime_mechanism_can_set_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data) { - GObject *object; - gboolean res; - - object = g_object_new (MSD_DATETIME_TYPE_MECHANISM, NULL); + gboolean ret = FALSE; + gint value; + GError *error = NULL; + MsdDatetimeMechanism *mechanism; - res = register_mechanism (MSD_DATETIME_MECHANISM (object)); - if (! res) { - g_object_unref (object); - return NULL; + mechanism = MSD_DATETIME_MECHANISM (user_data); + value = check_can_do (mechanism, + "org.mate.settingsdaemon.datetimemechanism.settimezone", + g_dbus_method_invocation_get_sender (invocation), + &error); + if (error != NULL) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + ret = FALSE; + } else { + mate_settings_date_time_mechanism_complete_can_set_timezone (object, invocation, value); + ret = TRUE; } - return MSD_DATETIME_MECHANISM (object); + return ret; } static gboolean -_check_polkit_for_action (MsdDatetimeMechanism *mechanism, DBusGMethodInvocation *context, const char *action) +msd_datetime_mechanism_get_hardware_clock_using_utc_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data G_GNUC_UNUSED) { - const char *sender; - GError *error; - PolkitSubject *subject; - PolkitAuthorizationResult *result; - - error = NULL; + char **lines; + char *data; + gsize len; + gboolean is_utc; + GError *error = NULL; - /* Check that caller is privileged */ - sender = dbus_g_method_get_sender (context); - subject = polkit_system_bus_name_new (sender); + if (!g_file_get_contents ("/etc/adjtime", &data, &len, &error)) { + GError *error2; + error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error reading /etc/adjtime file: %s", error->message); + g_error_free (error); + g_dbus_method_invocation_return_gerror (invocation, error2); + g_error_free (error2); + return FALSE; + } - result = polkit_authority_check_authorization_sync (mechanism->priv->auth, - subject, - action, - NULL, - POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, - NULL, &error); - g_object_unref (subject); + lines = g_strsplit (data, "\n", 0); + g_free (data); - if (error) { - dbus_g_method_return_error (context, error); + if (g_strv_length (lines) < 3) { + error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Cannot parse /etc/adjtime"); + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); - + g_strfreev (lines); return FALSE; } - if (!polkit_authorization_result_get_is_authorized (result)) { + if (strcmp (lines[2], "UTC") == 0) { + is_utc = TRUE; + } else if (strcmp (lines[2], "LOCAL") == 0) { + is_utc = FALSE; + } else { error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_NOT_PRIVILEGED, - "Not Authorized for action %s", action); - dbus_g_method_return_error (context, error); + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Expected UTC or LOCAL at line 3 of /etc/adjtime; found '%s'", + lines[2]); + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); - g_object_unref (result); - + g_strfreev (lines); return FALSE; } + g_strfreev (lines); + mate_settings_date_time_mechanism_complete_get_hardware_clock_using_utc (object, invocation, is_utc); + return TRUE; +} - g_object_unref (result); +static gboolean +msd_datetime_mechanism_get_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gpointer user_data G_GNUC_UNUSED) +{ + gchar *tz; + MsdDatetimeMechanism *mechanism; + + mechanism = MSD_DATETIME_MECHANISM (user_data); + + reset_killtimer (mechanism->priv->loop); + + tz = system_timezone_find (); + + mate_settings_date_time_mechanism_complete_get_timezone (object, invocation, tz); return TRUE; } - static gboolean -_set_time (MsdDatetimeMechanism *mechanism, - const struct timeval *tv, - DBusGMethodInvocation *context) +msd_datetime_mechanism_set_hardware_clock_using_utc_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gboolean using_utc, + gpointer user_data) { - GError *error; - - if (!_check_polkit_for_action (mechanism, context, "org.mate.settingsdaemon.datetimemechanism.settime")) - return FALSE; + GError *error = NULL; + MsdDatetimeMechanism *mechanism; - if (settimeofday (tv, NULL) != 0) { - error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error calling settimeofday({%ld,%ld}): %s", - (gint64) tv->tv_sec, (gint64) tv->tv_usec, - strerror (errno)); - dbus_g_method_return_error (context, error); + mechanism = MSD_DATETIME_MECHANISM (user_data); + if (!_check_polkit_for_action (mechanism, + "org.mate.settingsdaemon.datetimemechanism.configurehwclock", + g_dbus_method_invocation_get_sender (invocation), + &error)) { + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); return FALSE; } @@ -294,153 +399,101 @@ _set_time (MsdDatetimeMechanism *mechanism, if (g_file_test ("/sbin/hwclock", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_EXECUTABLE)) { int exit_status; - if (!g_spawn_command_line_sync ("/sbin/hwclock --systohc", NULL, NULL, &exit_status, &error)) { + char *cmd; + cmd = g_strdup_printf ("/sbin/hwclock %s --systohc", using_utc ? "--utc" : "--localtime"); + if (!g_spawn_command_line_sync (cmd, NULL, NULL, &exit_status, &error)) { GError *error2; error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, MSD_DATETIME_MECHANISM_ERROR_GENERAL, "Error spawning /sbin/hwclock: %s", error->message); g_error_free (error); - dbus_g_method_return_error (context, error2); + g_dbus_method_invocation_return_gerror (invocation, error2); g_error_free (error2); + g_free (cmd); return FALSE; } + g_free (cmd); if (WEXITSTATUS (exit_status) != 0) { error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, MSD_DATETIME_MECHANISM_ERROR_GENERAL, "/sbin/hwclock returned %d", exit_status); - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); return FALSE; } - } - - dbus_g_method_return (context); - return TRUE; -} -static gboolean -_rh_update_etc_sysconfig_clock (DBusGMethodInvocation *context, const char *key, const char *value) -{ - /* On Red Hat / Fedora, the /etc/sysconfig/clock file needs to be kept in sync */ - if (g_file_test ("/etc/sysconfig/clock", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - char **lines; - int n; - gboolean replaced; - char *data; - gsize len; - GError *error; - - error = NULL; - - if (!g_file_get_contents ("/etc/sysconfig/clock", &data, &len, &error)) { - GError *error2; - error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error reading /etc/sysconfig/clock file: %s", error->message); + if (!_rh_update_etc_sysconfig_clock ("UTC=", using_utc ? "true" : "false", &error)) { + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); - dbus_g_method_return_error (context, error2); - g_error_free (error2); return FALSE; } - replaced = FALSE; - lines = g_strsplit (data, "\n", 0); - g_free (data); - - for (n = 0; lines[n] != NULL; n++) { - if (g_str_has_prefix (lines[n], key)) { - g_free (lines[n]); - lines[n] = g_strdup_printf ("%s%s", key, value); - replaced = TRUE; - } - } - if (replaced) { - GString *str; - str = g_string_new (NULL); - for (n = 0; lines[n] != NULL; n++) { - g_string_append (str, lines[n]); - if (lines[n + 1] != NULL) - g_string_append_c (str, '\n'); - } - data = g_string_free (str, FALSE); - len = strlen (data); - if (!g_file_set_contents ("/etc/sysconfig/clock", data, len, &error)) { - GError *error2; - error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error updating /etc/sysconfig/clock: %s", error->message); - g_error_free (error); - dbus_g_method_return_error (context, error2); - g_error_free (error2); - g_free (data); - return FALSE; - } - g_free (data); - } - g_strfreev (lines); } - + mate_settings_date_time_mechanism_complete_set_hardware_clock_using_utc (object, invocation); return TRUE; } -/* exported methods */ - -gboolean -msd_datetime_mechanism_set_time (MsdDatetimeMechanism *mechanism, - gint64 seconds_since_epoch, - DBusGMethodInvocation *context) +static gboolean +msd_datetime_mechanism_set_time_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + gint64 arg_seconds_since_epoch, + gpointer user_data) { + gboolean ret = FALSE; struct timeval tv; + GError *error = NULL; + MsdDatetimeMechanism *mechanism; - reset_killtimer (); - g_debug ("SetTime(%ld) called", seconds_since_epoch); - - tv.tv_sec = (time_t) seconds_since_epoch; - tv.tv_usec = 0; - return _set_time (mechanism, &tv, context); -} - -gboolean -msd_datetime_mechanism_adjust_time (MsdDatetimeMechanism *mechanism, - gint64 seconds_to_add, - DBusGMethodInvocation *context) -{ - struct timeval tv; + mechanism = MSD_DATETIME_MECHANISM (user_data); - reset_killtimer (); - g_debug ("AdjustTime(%ld) called", seconds_to_add); + reset_killtimer (mechanism->priv->loop); + g_debug ("SetTime(%ld) called", arg_seconds_since_epoch); - if (gettimeofday (&tv, NULL) != 0) { - GError *error; - error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error calling gettimeofday(): %s", strerror (errno)); - dbus_g_method_return_error (context, error); + if (!_check_polkit_for_action (mechanism, + "org.mate.settingsdaemon.datetimemechanism.settime", + g_dbus_method_invocation_get_sender (invocation), + &error)) { + g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); return FALSE; } - tv.tv_sec += (time_t) seconds_to_add; - return _set_time (mechanism, &tv, context); -} + tv.tv_sec = (time_t) arg_seconds_since_epoch; + tv.tv_usec = 0; + ret = _set_time (mechanism, &tv, &error); + if (ret == FALSE) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); + } else { + mate_settings_date_time_mechanism_complete_set_time (object, invocation); + } + return ret; +} -gboolean -msd_datetime_mechanism_set_timezone (MsdDatetimeMechanism *mechanism, - const char *zone_file, - DBusGMethodInvocation *context) +static gboolean +msd_datetime_mechanism_set_timezone_handler (MateSettingsDateTimeMechanism *object, + GDBusMethodInvocation *invocation, + const gchar *zonefile, + gpointer user_data) { - GError *error; + GError *error = NULL; + MsdDatetimeMechanism *mechanism; - reset_killtimer (); - g_debug ("SetTimezone('%s') called", zone_file); + mechanism = MSD_DATETIME_MECHANISM (user_data); + reset_killtimer (mechanism->priv->loop); + g_debug ("SetTimezone('%s') called", zonefile); - if (!_check_polkit_for_action (mechanism, context, "org.mate.settingsdaemon.datetimemechanism.settimezone")) + if (!_check_polkit_for_action (mechanism, + "org.mate.settingsdaemon.datetimemechanism.settimezone", + g_dbus_method_invocation_get_sender (invocation), + &error)) { + g_dbus_method_invocation_return_gerror (invocation, error); + g_error_free (error); return FALSE; + } - error = NULL; - - if (!system_timezone_set_from_file (zone_file, &error)) { + if (!system_timezone_set_from_file (zonefile, &error)) { GError *error2; int code; @@ -452,197 +505,356 @@ msd_datetime_mechanism_set_timezone (MsdDatetimeMechanism *mechanism, error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, code, "%s", error->message); + g_error_free (error); - dbus_g_method_return_error (context, error2); + g_dbus_method_invocation_return_gerror (invocation, error2); g_error_free (error2); - return FALSE; } - dbus_g_method_return (context); + mate_settings_date_time_mechanism_complete_set_timezone (object, invocation); return TRUE; } +static void +bus_acquired_handler_cb (GDBusConnection *connection, + const gchar *name G_GNUC_UNUSED, + gpointer user_data) +{ + MsdDatetimeMechanism *mechanism; + GError *error = NULL; + gboolean exported; + + mechanism = MSD_DATETIME_MECHANISM (user_data); + + g_signal_connect (mechanism->priv->skeleton, + "handle-can-set-timezone", + G_CALLBACK (msd_datetime_mechanism_can_set_timezone_handler), + mechanism); + g_signal_connect (mechanism->priv->skeleton, + "handle-set-timezone", + G_CALLBACK (msd_datetime_mechanism_set_timezone_handler), + mechanism); + g_signal_connect (mechanism->priv->skeleton, + "handle-get-timezone", + G_CALLBACK (msd_datetime_mechanism_get_timezone_handler), + mechanism); + + g_signal_connect (mechanism->priv->skeleton, + "handle-can-set-time", + G_CALLBACK (msd_datetime_mechanism_can_set_time_handler), + mechanism); + g_signal_connect (mechanism->priv->skeleton, + "handle-set-time", + G_CALLBACK (msd_datetime_mechanism_set_time_handler), + mechanism); + + g_signal_connect (mechanism->priv->skeleton, + "handle-adjust-time", + G_CALLBACK (msd_datetime_mechanism_adjust_time_handler), + mechanism); + + g_signal_connect (mechanism->priv->skeleton, + "handle-get-hardware-clock-using-utc", + G_CALLBACK (msd_datetime_mechanism_get_hardware_clock_using_utc_handler), + mechanism); + g_signal_connect (mechanism->priv->skeleton, + "handle-set-hardware-clock-using-utc", + G_CALLBACK (msd_datetime_mechanism_set_hardware_clock_using_utc_handler), + mechanism); + + exported = g_dbus_interface_skeleton_export ( + G_DBUS_INTERFACE_SKELETON (mechanism->priv->skeleton), + connection, + MSD_DATETIME_DBUS_PATH, + &error); + if (!exported) + { + g_warning ("Failed to export interface: %s", error->message); + g_error_free (error); + g_main_loop_quit (mechanism->priv->loop); + } +} -gboolean -msd_datetime_mechanism_get_timezone (MsdDatetimeMechanism *mechism, - DBusGMethodInvocation *context) +static void +name_lost_handler_cb (GDBusConnection *connection G_GNUC_UNUSED, + const gchar *name G_GNUC_UNUSED, + gpointer user_data) { - gchar *timezone; + MsdDatetimeMechanism *mechanism; + + mechanism = MSD_DATETIME_MECHANISM (user_data); + g_debug("bus name lost\n"); + + g_main_loop_quit (mechanism->priv->loop); +} - reset_killtimer (); +static void +msd_datetime_mechanism_constructed (GObject *object) +{ + MsdDatetimeMechanism *mechanism; - timezone = system_timezone_find (); + mechanism = MSD_DATETIME_MECHANISM (object); - dbus_g_method_return (context, timezone); + G_OBJECT_CLASS (msd_datetime_mechanism_parent_class)->constructed (object); - return TRUE; + mechanism->priv->bus_name_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, + MSD_DATETIME_DBUS_NAME, + G_BUS_NAME_OWNER_FLAGS_NONE, + bus_acquired_handler_cb, + NULL, + name_lost_handler_cb, mechanism, NULL); } -gboolean -msd_datetime_mechanism_get_hardware_clock_using_utc (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context) +static void +msd_datetime_mechanism_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - char **lines; - char *data; - gsize len; - GError *error; - gboolean is_utc; + MsdDatetimeMechanism *mechanism; - error = NULL; + mechanism = MSD_DATETIME_MECHANISM (object); - if (!g_file_get_contents ("/etc/adjtime", &data, &len, &error)) { - GError *error2; - error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error reading /etc/adjtime file: %s", error->message); - g_error_free (error); - dbus_g_method_return_error (context, error2); - g_error_free (error2); - return FALSE; + switch (prop_id) + { + case PROP_LOOP: + mechanism->priv->loop = g_value_get_pointer (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } + } - lines = g_strsplit (data, "\n", 0); - g_free (data); +static void +msd_datetime_mechanism_class_init (MsdDatetimeMechanismClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); - if (g_strv_length (lines) < 3) { - error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Cannot parse /etc/adjtime"); - dbus_g_method_return_error (context, error); - g_error_free (error); - g_strfreev (lines); - return FALSE; - } + object_class->constructed = msd_datetime_mechanism_constructed; + object_class->set_property = msd_datetime_mechanism_set_property; + object_class->dispose = msd_datetime_mechanism_dispose; + + properties[PROP_LOOP] = + g_param_spec_pointer("loop", + "loop", + "loop", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, LAST_PROP, properties); +} - if (strcmp (lines[2], "UTC") == 0) { - is_utc = TRUE; - } else if (strcmp (lines[2], "LOCAL") == 0) { - is_utc = FALSE; - } else { - error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Expected UTC or LOCAL at line 3 of /etc/adjtime; found '%s'", lines[2]); - dbus_g_method_return_error (context, error); - g_error_free (error); - g_strfreev (lines); - return FALSE; - } - g_strfreev (lines); - dbus_g_method_return (context, is_utc); - return TRUE; +static void +msd_datetime_mechanism_init (MsdDatetimeMechanism *mechanism) +{ + mechanism->priv = msd_datetime_mechanism_get_instance_private (mechanism); + mechanism->priv->skeleton = mate_settings_date_time_mechanism_skeleton_new (); } -gboolean -msd_datetime_mechanism_set_hardware_clock_using_utc (MsdDatetimeMechanism *mechanism, - gboolean using_utc, - DBusGMethodInvocation *context) +static void +msd_datetime_mechanism_dispose (GObject *object) { - GError *error; + MsdDatetimeMechanism *mechanism; - error = NULL; + g_return_if_fail (object != NULL); + g_return_if_fail (MSD_DATETIME_IS_MECHANISM (object)); - if (!_check_polkit_for_action (mechanism, context, - "org.mate.settingsdaemon.datetimemechanism.configurehwclock")) - return FALSE; + mechanism = MSD_DATETIME_MECHANISM (object); - if (g_file_test ("/sbin/hwclock", - G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_EXECUTABLE)) { - int exit_status; - char *cmd; - cmd = g_strdup_printf ("/sbin/hwclock %s --systohc", using_utc ? "--utc" : "--localtime"); - if (!g_spawn_command_line_sync (cmd, NULL, NULL, &exit_status, &error)) { - GError *error2; - error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "Error spawning /sbin/hwclock: %s", error->message); - g_error_free (error); - dbus_g_method_return_error (context, error2); - g_error_free (error2); - g_free (cmd); - return FALSE; - } - g_free (cmd); - if (WEXITSTATUS (exit_status) != 0) { - error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, - MSD_DATETIME_MECHANISM_ERROR_GENERAL, - "/sbin/hwclock returned %d", exit_status); - dbus_g_method_return_error (context, error); + g_return_if_fail (mechanism->priv != NULL); + + if (mechanism->priv->skeleton != NULL) + { + GDBusInterfaceSkeleton *skeleton; + + skeleton = G_DBUS_INTERFACE_SKELETON (mechanism->priv->skeleton); + g_dbus_interface_skeleton_unexport (skeleton); + g_clear_object (&mechanism->priv->skeleton); + } + + if (mechanism->priv->bus_name_id > 0) + { + g_bus_unown_name (mechanism->priv->bus_name_id); + mechanism->priv->bus_name_id = 0; + } + + + G_OBJECT_CLASS (msd_datetime_mechanism_parent_class)->dispose (object); +} + +static gboolean +register_mechanism (MsdDatetimeMechanism *mechanism) +{ + GError *error = NULL; + + mechanism->priv->auth = polkit_authority_get_sync (NULL, &error); + if (mechanism->priv->auth == NULL) { + if (error != NULL) { + g_critical ("error getting system bus: %s", error->message); g_error_free (error); - return FALSE; } + goto error; + } - if (!_rh_update_etc_sysconfig_clock (context, "UTC=", using_utc ? "true" : "false")) - return FALSE; + reset_killtimer (mechanism->priv->loop); - } - dbus_g_method_return (context); return TRUE; + +error: + return FALSE; } -static void -check_can_do (MsdDatetimeMechanism *mechanism, - const char *action, - DBusGMethodInvocation *context) +MsdDatetimeMechanism * +msd_datetime_mechanism_new (GMainLoop *loop) +{ + GObject *object; + gboolean res; + + object = g_object_new (MSD_DATETIME_TYPE_MECHANISM, "loop", loop, NULL); + + res = register_mechanism (MSD_DATETIME_MECHANISM (object)); + if (! res) { + g_object_unref (object); + return NULL; + } + + return MSD_DATETIME_MECHANISM (object); +} + +static gboolean +_check_polkit_for_action (MsdDatetimeMechanism *mechanism, + const char *action, + const char *sender, + GError **error) { - const char *sender; PolkitSubject *subject; PolkitAuthorizationResult *result; - GError *error; /* Check that caller is privileged */ - sender = dbus_g_method_get_sender (context); subject = polkit_system_bus_name_new (sender); - - error = NULL; result = polkit_authority_check_authorization_sync (mechanism->priv->auth, subject, action, NULL, - 0, - NULL, - &error); + POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, + NULL, error); g_object_unref (subject); - if (error) { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; + if (*error != NULL) { + return FALSE; } - if (polkit_authorization_result_get_is_authorized (result)) { - dbus_g_method_return (context, 2); - } - else if (polkit_authorization_result_get_is_challenge (result)) { - dbus_g_method_return (context, 1); - } - else { - dbus_g_method_return (context, 0); + if (!polkit_authorization_result_get_is_authorized (result)) { + *error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_NOT_PRIVILEGED, + "Not Authorized for action %s", action); + g_object_unref (result); + + return FALSE; } g_object_unref (result); -} + return TRUE; +} -gboolean -msd_datetime_mechanism_can_set_time (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context) +static gboolean +_set_time (MsdDatetimeMechanism *mechanism G_GNUC_UNUSED, + const struct timeval *tv, + GError **error) { - check_can_do (mechanism, - "org.mate.settingsdaemon.datetimemechanism.settime", - context); + if (settimeofday (tv, NULL) != 0) { + *error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error calling settimeofday({%ld,%ld}): %s", + (gint64) tv->tv_sec, (gint64) tv->tv_usec, + strerror (errno)); + return FALSE; + } + + if (g_file_test ("/sbin/hwclock", + G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_EXECUTABLE)) { + int exit_status; + if (!g_spawn_command_line_sync ("/sbin/hwclock --systohc", NULL, NULL, &exit_status, error)) { + GError *error2; + error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error spawning /sbin/hwclock: %s", (*error)->message); + g_error_free (*error); + g_propagate_error (error, error2); + return FALSE; + } + if (WEXITSTATUS (exit_status) != 0) { + *error = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "/sbin/hwclock returned %d", exit_status); + return FALSE; + } + } return TRUE; } -gboolean -msd_datetime_mechanism_can_set_timezone (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context) +static gboolean +_rh_update_etc_sysconfig_clock (const char *key, + const char *value, + GError **error) { - check_can_do (mechanism, - "org.mate.settingsdaemon.datetimemechanism.settimezone", - context); + /* On Red Hat / Fedora, the /etc/sysconfig/clock file needs to be kept in sync */ + if (g_file_test ("/etc/sysconfig/clock", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + char **lines; + int n; + gboolean replaced; + char *data; + gsize len; + + if (!g_file_get_contents ("/etc/sysconfig/clock", &data, &len, error)) { + GError *error2; + error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error reading /etc/sysconfig/clock file: %s", (*error)->message); + g_error_free (*error); + g_propagate_error (error, error2); + return FALSE; + } + replaced = FALSE; + lines = g_strsplit (data, "\n", 0); + g_free (data); + + for (n = 0; lines[n] != NULL; n++) { + if (g_str_has_prefix (lines[n], key)) { + g_free (lines[n]); + lines[n] = g_strdup_printf ("%s%s", key, value); + replaced = TRUE; + } + } + if (replaced) { + GString *str; + + str = g_string_new (NULL); + for (n = 0; lines[n] != NULL; n++) { + g_string_append (str, lines[n]); + if (lines[n + 1] != NULL) + g_string_append_c (str, '\n'); + } + data = g_string_free (str, FALSE); + len = strlen (data); + if (!g_file_set_contents ("/etc/sysconfig/clock", data, len, error)) { + GError *error2; + error2 = g_error_new (MSD_DATETIME_MECHANISM_ERROR, + MSD_DATETIME_MECHANISM_ERROR_GENERAL, + "Error updating /etc/sysconfig/clock: %s", (*error)->message); + g_error_free (*error); + g_propagate_error (error, error2); + g_free (data); + return FALSE; + } + g_free (data); + } + g_strfreev (lines); + } return TRUE; } diff --git a/plugins/datetime/msd-datetime-mechanism.h b/plugins/datetime/msd-datetime-mechanism.h index cc3ad73..e15ca95 100644 --- a/plugins/datetime/msd-datetime-mechanism.h +++ b/plugins/datetime/msd-datetime-mechanism.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 David Zeuthen <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -22,11 +23,8 @@ #define MSD_DATETIME_MECHANISM_H #include <glib-object.h> -#include <dbus/dbus-glib.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define MSD_DATETIME_TYPE_MECHANISM (msd_datetime_mechanism_get_type ()) #define MSD_DATETIME_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_DATETIME_TYPE_MECHANISM, MsdDatetimeMechanism)) @@ -61,41 +59,10 @@ typedef enum GType msd_datetime_mechanism_error_get_type (void); #define MSD_DATETIME_MECHANISM_TYPE_ERROR (msd_datetime_mechanism_error_get_type ()) - GQuark msd_datetime_mechanism_error_quark (void); GType msd_datetime_mechanism_get_type (void); -MsdDatetimeMechanism *msd_datetime_mechanism_new (void); - -/* exported methods */ -gboolean msd_datetime_mechanism_get_timezone (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context); -gboolean msd_datetime_mechanism_set_timezone (MsdDatetimeMechanism *mechanism, - const char *zone_file, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_can_set_timezone (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_set_time (MsdDatetimeMechanism *mechanism, - gint64 seconds_since_epoch, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_can_set_time (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_adjust_time (MsdDatetimeMechanism *mechanism, - gint64 seconds_to_add, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_get_hardware_clock_using_utc (MsdDatetimeMechanism *mechanism, - DBusGMethodInvocation *context); - -gboolean msd_datetime_mechanism_set_hardware_clock_using_utc (MsdDatetimeMechanism *mechanism, - gboolean using_utc, - DBusGMethodInvocation *context); +MsdDatetimeMechanism *msd_datetime_mechanism_new (GMainLoop *loop); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* MSD_DATETIME_MECHANISM_H */ diff --git a/plugins/datetime/msd-datetime-mechanism.xml b/plugins/datetime/msd-datetime-mechanism.xml index 1962235..a605459 100644 --- a/plugins/datetime/msd-datetime-mechanism.xml +++ b/plugins/datetime/msd-datetime-mechanism.xml @@ -2,17 +2,14 @@ <node name="/"> <interface name="org.mate.SettingsDaemon.DateTimeMechanism"> <method name="SetTimezone"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="zonefile" direction="in" type="s"/> </method> <method name="GetTimezone"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="timezone" direction="out" type="s"/> </method> <method name="CanSetTimezone"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="value" direction="out" type="i"> <doc:doc> <doc:summary>Whether the caller can set the timezone</doc:summary> @@ -39,11 +36,9 @@ </arg> </method> <method name="SetTime"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="seconds_since_epoch" direction="in" type="x"/> </method> <method name="CanSetTime"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="value" direction="out" type="i"> <doc:doc> <doc:summary>Whether the caller can set the time</doc:summary> @@ -70,16 +65,13 @@ </arg> </method> <method name="AdjustTime"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="seconds_to_add" direction="in" type="x"/> </method> <method name="GetHardwareClockUsingUtc"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="is_using_utc" direction="out" type="b"/> </method> <method name="SetHardwareClockUsingUtc"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="is_using_utc" direction="in" type="b"/> </method> diff --git a/plugins/datetime/system-timezone.c b/plugins/datetime/system-timezone.c index f9fab7a..0672e3b 100644 --- a/plugins/datetime/system-timezone.c +++ b/plugins/datetime/system-timezone.c @@ -3,6 +3,7 @@ * Copyright (C) 2008 Novell, Inc. * * Authors: Vincent Untz <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -280,7 +281,6 @@ system_timezone_monitor_changed (GFileMonitor *handle G_GNUC_UNUSED, g_free (new_tz); } - /* * Code to deal with the system timezone on all distros. * There's no dependency on the SystemTimezone GObject here. @@ -369,7 +369,6 @@ system_timezone_write_etc_timezone (const char *tz, return retval; } - /* Read a file that looks like a key-file (but there's no need for groups) * and get the last value for a specific key */ static char * @@ -695,7 +694,6 @@ recursive_compare (struct stat *localtime_stat, return NULL; } - static gboolean files_are_identical_inode (struct stat *a_stat, struct stat *b_stat, @@ -706,7 +704,6 @@ files_are_identical_inode (struct stat *a_stat, return (a_stat->st_ino == b_stat->st_ino); } - /* Determine if /etc/localtime is a hard link to some file, by looking at * the inodes */ static char * diff --git a/plugins/datetime/system-timezone.h b/plugins/datetime/system-timezone.h index c801348..233f997 100644 --- a/plugins/datetime/system-timezone.h +++ b/plugins/datetime/system-timezone.h @@ -3,6 +3,7 @@ * Copyright (C) 2008 Novell, Inc. * * Authors: Vincent Untz <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -35,7 +36,6 @@ extern "C" { #define SYSTEM_ZONEINFODIR "/usr/share/zoneinfo" #endif - #define SYSTEM_TIMEZONE_TYPE (system_timezone_get_type ()) #define SYSTEM_TIMEZONE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SYSTEM_TIMEZONE_TYPE, SystemTimezone)) #define SYSTEM_TIMEZONE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), SYSTEM_TIMEZONE_TYPE, SystemTimezoneClass)) diff --git a/plugins/dummy/msd-dummy-manager.c b/plugins/dummy/msd-dummy-manager.c index 94855b0..b79b255 100644 --- a/plugins/dummy/msd-dummy-manager.c +++ b/plugins/dummy/msd-dummy-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/dummy/msd-dummy-manager.h b/plugins/dummy/msd-dummy-manager.h index bb4d662..18ba679 100644 --- a/plugins/dummy/msd-dummy-manager.h +++ b/plugins/dummy/msd-dummy-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/dummy/msd-dummy-plugin.c b/plugins/dummy/msd-dummy-plugin.c index e3a6ca9..a26e252 100644 --- a/plugins/dummy/msd-dummy-plugin.c +++ b/plugins/dummy/msd-dummy-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/dummy/msd-dummy-plugin.h b/plugins/dummy/msd-dummy-plugin.h index 1cc3e31..c276876 100644 --- a/plugins/dummy/msd-dummy-plugin.h +++ b/plugins/dummy/msd-dummy-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/housekeeping/msd-disk-space.c b/plugins/housekeeping/msd-disk-space.c index 22b196c..91738e0 100644 --- a/plugins/housekeeping/msd-disk-space.c +++ b/plugins/housekeeping/msd-disk-space.c @@ -2,6 +2,7 @@ * vim: set et sw=8 ts=8: * * Copyright (c) 2008, Novell, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Authors: Vincent Untz <[email protected]> * @@ -40,7 +41,6 @@ #include "msd-ldsm-dialog.h" #include "msd-ldsm-trash-empty.h" - #define GIGABYTE 1024 * 1024 * 1024 #define CHECK_EVERY_X_SECONDS 60 @@ -279,7 +279,6 @@ ldsm_mount_is_user_ignore (const gchar *path) return FALSE; } - static gboolean is_in (const gchar *value, const gchar *set[]) { @@ -612,8 +611,7 @@ msd_ldsm_get_config (void) SETTINGS_MIN_NOTIFY_PERIOD); if (ignore_paths != NULL) { - g_slist_foreach (ignore_paths, (GFunc) g_free, NULL); - g_slist_free (ignore_paths); + g_slist_free_full (ignore_paths, g_free); ignore_paths = NULL; } @@ -636,7 +634,7 @@ msd_ldsm_get_config (void) } static void -msd_ldsm_update_config (GSettings *settings G_GNUC_UNUSED, +msd_ldsm_update_config (GSettings *gsettings G_GNUC_UNUSED, gchar *key G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) { @@ -696,8 +694,7 @@ msd_ldsm_clean (void) } if (ignore_paths) { - g_slist_foreach (ignore_paths, (GFunc) g_free, NULL); - g_slist_free (ignore_paths); + g_slist_free_full (ignore_paths, g_free); } } diff --git a/plugins/housekeeping/msd-disk-space.h b/plugins/housekeeping/msd-disk-space.h index 13d4aa4..ff84a41 100644 --- a/plugins/housekeeping/msd-disk-space.h +++ b/plugins/housekeeping/msd-disk-space.h @@ -4,6 +4,7 @@ * Copyright (c) 2008, Novell, Inc. * * Authors: Vincent Untz <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/housekeeping/msd-housekeeping-manager.c b/plugins/housekeeping/msd-housekeeping-manager.c index 4a76241..367cbb1 100644 --- a/plugins/housekeeping/msd-housekeeping-manager.c +++ b/plugins/housekeeping/msd-housekeeping-manager.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2008 Michael J. Chudobiak <[email protected]> * Copyright (C) 2012 Jasmine Hassan <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -28,7 +29,6 @@ #include "msd-housekeeping-manager.h" #include "msd-disk-space.h" - /* General */ #define INTERVAL_ONCE_A_DAY 24*60*60 #define INTERVAL_TWO_MINUTES 2*60 @@ -38,17 +38,19 @@ #define THUMB_CACHE_KEY_AGE "maximum-age" #define THUMB_CACHE_KEY_SIZE "maximum-size" -struct MsdHousekeepingManagerPrivate { - guint long_term_cb; - guint short_term_cb; +struct _MsdHousekeepingManager { + GObject parent; + + guint long_term_cb; + guint short_term_cb; GSettings *settings; + gulong config_listener_id; }; -G_DEFINE_TYPE_WITH_PRIVATE (MsdHousekeepingManager, msd_housekeeping_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (MsdHousekeepingManager, msd_housekeeping_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; - typedef struct { GDateTime *now; GTimeSpan max_age; @@ -56,14 +58,12 @@ typedef struct { goffset max_size; } PurgeData; - typedef struct { GDateTime *mtime; char *path; glong size; } ThumbData; - static void thumb_data_free (gpointer data) { @@ -155,8 +155,8 @@ purge_thumbnail_cache (MsdHousekeepingManager *manager) g_debug ("housekeeping: checking thumbnail cache size and freshness"); - purge_data.max_age = g_settings_get_int (manager->priv->settings, THUMB_CACHE_KEY_AGE) * G_TIME_SPAN_DAY; - purge_data.max_size = g_settings_get_int (manager->priv->settings, THUMB_CACHE_KEY_SIZE) * 1024 * 1024; + purge_data.max_age = g_settings_get_int (manager->settings, THUMB_CACHE_KEY_AGE) * G_TIME_SPAN_DAY; + purge_data.max_size = g_settings_get_int (manager->settings, THUMB_CACHE_KEY_SIZE) * 1024 * 1024; /* if both are set to -1, we don't need to read anything */ if ((purge_data.max_age < 0) && (purge_data.max_size < 0)) @@ -200,8 +200,7 @@ purge_thumbnail_cache (MsdHousekeepingManager *manager) } } - g_list_foreach (files, (GFunc) thumb_data_free, NULL); - g_list_free (files); + g_list_free_full (files, thumb_data_free); g_date_time_unref (purge_data.now); } @@ -216,16 +215,16 @@ static gboolean do_cleanup_once (MsdHousekeepingManager *manager) { do_cleanup (manager); - manager->priv->short_term_cb = 0; + manager->short_term_cb = 0; return FALSE; } static void do_cleanup_soon (MsdHousekeepingManager *manager) { - if (manager->priv->short_term_cb == 0) { + if (manager->short_term_cb == 0) { g_debug ("housekeeping: will tidy up in 2 minutes"); - manager->priv->short_term_cb = g_timeout_add_seconds (INTERVAL_TWO_MINUTES, + manager->short_term_cb = g_timeout_add_seconds (INTERVAL_TWO_MINUTES, (GSourceFunc) do_cleanup_once, manager); } @@ -246,18 +245,11 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager, g_debug ("Starting housekeeping manager"); mate_settings_profile_start (NULL); - msd_ldsm_setup (FALSE); - - manager->priv->settings = g_settings_new (THUMB_CACHE_SCHEMA); - - g_signal_connect (manager->priv->settings, "changed", - G_CALLBACK (settings_changed_callback), manager); - /* Clean once, a few minutes after start-up */ do_cleanup_soon (manager); /* Clean periodically, on a daily basis. */ - manager->priv->long_term_cb = g_timeout_add_seconds (INTERVAL_ONCE_A_DAY, + manager->long_term_cb = g_timeout_add_seconds (INTERVAL_ONCE_A_DAY, (GSourceFunc) do_cleanup, manager); mate_settings_profile_end (NULL); @@ -265,46 +257,70 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager, return TRUE; } +static void +msd_housekeeping_manager_finalize (GObject *object) +{ + MsdHousekeepingManager *manager = MSD_HOUSEKEEPING_MANAGER (object); + msd_housekeeping_manager_stop (manager); +#if GLIB_CHECK_VERSION(2,62,0) + g_clear_signal_handler (&manager->config_listener_id, + manager->settings); +#else + if (manager->config_listener_id != 0) { + g_signal_handler_disconnect (manager->settings, + manager->config_listener_id); + manager->config_listener_id = 0; + } +#endif + g_object_unref (manager->settings); + manager->settings = NULL; + + msd_ldsm_clean (); + + G_OBJECT_CLASS (msd_housekeeping_manager_parent_class)->finalize (object); +} + void msd_housekeeping_manager_stop (MsdHousekeepingManager *manager) { - MsdHousekeepingManagerPrivate *p = manager->priv; - g_debug ("Stopping housekeeping manager"); - if (p->short_term_cb) { - g_source_remove (p->short_term_cb); - p->short_term_cb = 0; + if (manager->short_term_cb) { + g_source_remove (manager->short_term_cb); + manager->short_term_cb = 0; } - if (p->long_term_cb) { - g_source_remove (p->long_term_cb); - p->long_term_cb = 0; + if (manager->long_term_cb) { + g_source_remove (manager->long_term_cb); + manager->long_term_cb = 0; /* Do a clean-up on shutdown if and only if the size or age * limits have been set to a paranoid level of cleaning (zero) */ - if ((g_settings_get_int (p->settings, THUMB_CACHE_KEY_AGE) == 0) || - (g_settings_get_int (p->settings, THUMB_CACHE_KEY_SIZE) == 0)) { + if ((g_settings_get_int (manager->settings, THUMB_CACHE_KEY_AGE) == 0) || + (g_settings_get_int (manager->settings, THUMB_CACHE_KEY_SIZE) == 0)) { do_cleanup (manager); } } - - g_object_unref (p->settings); - p->settings = NULL; - - msd_ldsm_clean (); } static void msd_housekeeping_manager_class_init (MsdHousekeepingManagerClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = msd_housekeeping_manager_finalize; } static void msd_housekeeping_manager_init (MsdHousekeepingManager *manager) { - manager->priv = msd_housekeeping_manager_get_instance_private (manager); + msd_ldsm_setup (FALSE); + + manager->settings = g_settings_new (THUMB_CACHE_SCHEMA); + manager->config_listener_id = g_signal_connect (manager->settings, "changed", + G_CALLBACK (settings_changed_callback), + manager); } MsdHousekeepingManager * diff --git a/plugins/housekeeping/msd-housekeeping-manager.h b/plugins/housekeeping/msd-housekeeping-manager.h index a336fad..40ed061 100644 --- a/plugins/housekeeping/msd-housekeeping-manager.h +++ b/plugins/housekeeping/msd-housekeeping-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Michael J. Chudobiak <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -18,42 +19,23 @@ * */ -#ifndef __MSD_HOUSEKEEPING_MANAGER_H -#define __MSD_HOUSEKEEPING_MANAGER_H +#ifndef MSD_HOUSEKEEPING_MANAGER_H +#define MSD_HOUSEKEEPING_MANAGER_H #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS -#define MSD_TYPE_HOUSEKEEPING_MANAGER (msd_housekeeping_manager_get_type ()) -#define MSD_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManager)) -#define MSD_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManagerClass)) -#define MSD_IS_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MSD_TYPE_HOUSEKEEPING_MANAGER)) -#define MSD_IS_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_HOUSEKEEPING_MANAGER)) -#define MSD_HOUSEKEEPING_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManagerClass)) +#define MSD_TYPE_HOUSEKEEPING_MANAGER (msd_housekeeping_manager_get_type ()) -typedef struct MsdHousekeepingManagerPrivate MsdHousekeepingManagerPrivate; - -typedef struct { - GObject parent; - MsdHousekeepingManagerPrivate *priv; -} MsdHousekeepingManager; - -typedef struct { - GObjectClass parent_class; -} MsdHousekeepingManagerClass; - -GType msd_housekeeping_manager_get_type (void); +G_DECLARE_FINAL_TYPE (MsdHousekeepingManager, msd_housekeeping_manager, + MSD, HOUSEKEEPING_MANAGER, GObject) MsdHousekeepingManager * msd_housekeeping_manager_new (void); gboolean msd_housekeeping_manager_start (MsdHousekeepingManager *manager, GError **error); void msd_housekeeping_manager_stop (MsdHousekeepingManager *manager); -#ifdef __cplusplus -} -#endif +G_END_DECLS -#endif /* __MSD_HOUSEKEEPING_MANAGER_H */ +#endif /* MSD_HOUSEKEEPING_MANAGER_H */ diff --git a/plugins/housekeeping/msd-housekeeping-plugin.c b/plugins/housekeeping/msd-housekeeping-plugin.c index 8a829fe..3d2b7ed 100644 --- a/plugins/housekeeping/msd-housekeeping-plugin.c +++ b/plugins/housekeeping/msd-housekeeping-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Michael J. Chudobiak <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/housekeeping/msd-housekeeping-plugin.h b/plugins/housekeeping/msd-housekeeping-plugin.h index 15be276..7fb155a 100644 --- a/plugins/housekeeping/msd-housekeeping-plugin.h +++ b/plugins/housekeeping/msd-housekeeping-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Michael J. Chudobiak <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/housekeeping/msd-ldsm-dialog.c b/plugins/housekeeping/msd-ldsm-dialog.c index 74ff606..3b06d09 100644 --- a/plugins/housekeeping/msd-ldsm-dialog.c +++ b/plugins/housekeeping/msd-ldsm-dialog.c @@ -2,6 +2,7 @@ * * msd-ldsm-dialog.c * Copyright (C) Chris Coulson 2009 <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * msd-ldsm-dialog.c is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -182,8 +183,7 @@ ignore_check_button_toggled_cb (GtkToggleButton *button, g_ptr_array_free (array, FALSE); } - g_slist_foreach (ignore_paths, (GFunc) g_free, NULL); - g_slist_free (ignore_paths); + g_slist_free_full (ignore_paths, g_free); g_object_unref (settings); } @@ -450,7 +450,7 @@ msd_ldsm_dialog_new (gboolean other_usable_partitions, button_ignore = gtk_dialog_add_button (GTK_DIALOG (dialog), _("Ignore"), GTK_RESPONSE_CANCEL); - ignore_image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON); + ignore_image = gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button_ignore), ignore_image); gtk_widget_grab_default (button_ignore); diff --git a/plugins/housekeeping/msd-ldsm-dialog.h b/plugins/housekeeping/msd-ldsm-dialog.h index 8b95fb9..7b59c80 100644 --- a/plugins/housekeeping/msd-ldsm-dialog.h +++ b/plugins/housekeeping/msd-ldsm-dialog.h @@ -2,6 +2,7 @@ * * msd-ldsm-dialog.c * Copyright (C) Chris Coulson 2009 <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * msd-ldsm-dialog.c is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/plugins/housekeeping/msd-ldsm-trash-empty.c b/plugins/housekeeping/msd-ldsm-trash-empty.c index 301b6dc..e331dda 100644 --- a/plugins/housekeeping/msd-ldsm-trash-empty.c +++ b/plugins/housekeeping/msd-ldsm-trash-empty.c @@ -3,6 +3,7 @@ * msd-ldsm-trash-empty.c * Copyright (C) Chris Coulson 2009 <[email protected]> * (C) Ryan Lortie 2008 + * Copyright (C) 2012-2021 MATE Developers * * msd-ldsm-trash-empty.c is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/plugins/housekeeping/msd-ldsm-trash-empty.h b/plugins/housekeeping/msd-ldsm-trash-empty.h index 478f0a7..52daa95 100644 --- a/plugins/housekeeping/msd-ldsm-trash-empty.h +++ b/plugins/housekeeping/msd-ldsm-trash-empty.h @@ -2,6 +2,7 @@ * * msd-ldsm-trash-empty.h * Copyright (C) Chris Coulson 2009 <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * msd-ldsm-trash-empty.h is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/plugins/keybindings/dconf-util.c b/plugins/keybindings/dconf-util.c index 10dd4e9..d6040fa 100644 --- a/plugins/keybindings/dconf-util.c +++ b/plugins/keybindings/dconf-util.c @@ -2,6 +2,7 @@ * dconf-util.c: helper API for dconf * * Copyright (C) 2012 Stefano Karapetsas + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/keybindings/dconf-util.h b/plugins/keybindings/dconf-util.h index fe782d9..bdf9c00 100644 --- a/plugins/keybindings/dconf-util.h +++ b/plugins/keybindings/dconf-util.h @@ -2,6 +2,7 @@ * dconf-util.h: helper API for dconf * * Copyright (C) 2012 Stefano Karapetsas + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/keybindings/msd-keybindings-manager.c b/plugins/keybindings/msd-keybindings-manager.c index a7ec128..5ce7f0d 100644 --- a/plugins/keybindings/msd-keybindings-manager.c +++ b/plugins/keybindings/msd-keybindings-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -264,7 +265,6 @@ same_key (const Key *key, const Key *other) } else if (key->keycodes != NULL || other->keycodes != NULL) return FALSE; - return TRUE; } diff --git a/plugins/keybindings/msd-keybindings-manager.h b/plugins/keybindings/msd-keybindings-manager.h index 95b1bed..00b118c 100644 --- a/plugins/keybindings/msd-keybindings-manager.h +++ b/plugins/keybindings/msd-keybindings-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keybindings/msd-keybindings-plugin.c b/plugins/keybindings/msd-keybindings-plugin.c index ddf186a..28fc33f 100644 --- a/plugins/keybindings/msd-keybindings-plugin.c +++ b/plugins/keybindings/msd-keybindings-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keybindings/msd-keybindings-plugin.h b/plugins/keybindings/msd-keybindings-plugin.h index f45d0f8..c29f74a 100644 --- a/plugins/keybindings/msd-keybindings-plugin.h +++ b/plugins/keybindings/msd-keybindings-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keyboard/Makefile.am b/plugins/keyboard/Makefile.am index f8ee695..2e2b83e 100644 --- a/plugins/keyboard/Makefile.am +++ b/plugins/keyboard/Makefile.am @@ -33,6 +33,7 @@ libkeyboard_la_CPPFLAGS = \ libkeyboard_la_CFLAGS = \ $(SETTINGS_PLUGIN_CFLAGS) \ $(LIBMATEKBDUI_CFLAGS) \ + $(MATE_DESKTOP_CFLAGS) \ $(AM_CFLAGS) \ $(WARN_CFLAGS) \ $(NULL) @@ -44,6 +45,7 @@ libkeyboard_la_LDFLAGS = \ libkeyboard_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(LIBMATEKBDUI_LIBS) \ + $(MATE_DESKTOP_LIBS) \ $(NULL) plugin_in_files = \ diff --git a/plugins/keyboard/delayed-dialog.c b/plugins/keyboard/delayed-dialog.c index c2e469e..0968585 100644 --- a/plugins/keyboard/delayed-dialog.c +++ b/plugins/keyboard/delayed-dialog.c @@ -1,5 +1,6 @@ /* * Copyright © 2006 Novell, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/keyboard/delayed-dialog.h b/plugins/keyboard/delayed-dialog.h index 367bf18..a8fb910 100644 --- a/plugins/keyboard/delayed-dialog.h +++ b/plugins/keyboard/delayed-dialog.h @@ -1,5 +1,6 @@ /* * Copyright © 2006 Novell, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,7 +18,6 @@ * 02110-1301, USA. */ - #ifndef __DELAYED_DIALOG_H #define __DELAYED_DIALOG_H diff --git a/plugins/keyboard/msd-keyboard-manager.c b/plugins/keyboard/msd-keyboard-manager.c index 61ef2bd..06bc322 100644 --- a/plugins/keyboard/msd-keyboard-manager.c +++ b/plugins/keyboard/msd-keyboard-manager.c @@ -2,6 +2,7 @@ * * Copyright © 2001 Ximian, Inc. * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -73,7 +74,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (MsdKeyboardManager, msd_keyboard_manager, G_TYPE_OBJ static gpointer manager_object = NULL; - #ifdef HAVE_X11_EXTENSIONS_XKB_H static gboolean xkb_set_keyboard_autorepeat_rate(int delay, int rate) { @@ -201,8 +201,6 @@ apply_settings (GSettings *settings, XKeyboardControl kbdcontrol; gboolean repeat; gboolean click; - int rate; - int delay; int click_volume; int bell_volume; int bell_pitch; @@ -215,8 +213,6 @@ apply_settings (GSettings *settings, repeat = g_settings_get_boolean (settings, KEY_REPEAT); click = g_settings_get_boolean (settings, KEY_CLICK); - rate = g_settings_get_int (settings, KEY_RATE); - delay = g_settings_get_int (settings, KEY_DELAY); click_volume = g_settings_get_int (settings, KEY_CLICK_VOLUME); bell_pitch = g_settings_get_int (settings, KEY_BELL_PITCH); bell_duration = g_settings_get_int (settings, KEY_BELL_DURATION); @@ -233,8 +229,9 @@ apply_settings (GSettings *settings, XAutoRepeatOn (GDK_DISPLAY_XDISPLAY (display)); /* Use XKB in preference */ #ifdef HAVE_X11_EXTENSIONS_XKB_H - rate_set = xkb_set_keyboard_autorepeat_rate (delay, rate); -#endif + rate_set = xkb_set_keyboard_autorepeat_rate (g_settings_get_int (settings, KEY_DELAY), + g_settings_get_int (settings, KEY_RATE)); +#endif /* HAVE_X11_EXTENSIONS_XKB_H */ if (!rate_set) g_warning ("Neither XKeyboard not Xfree86's keyboard extensions are available,\n" "no way to support keyboard autorepeat rate settings"); diff --git a/plugins/keyboard/msd-keyboard-manager.h b/plugins/keyboard/msd-keyboard-manager.h index 2986a5b..b6bddf6 100644 --- a/plugins/keyboard/msd-keyboard-manager.h +++ b/plugins/keyboard/msd-keyboard-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keyboard/msd-keyboard-plugin.c b/plugins/keyboard/msd-keyboard-plugin.c index ed16759..74d7089 100644 --- a/plugins/keyboard/msd-keyboard-plugin.c +++ b/plugins/keyboard/msd-keyboard-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keyboard/msd-keyboard-plugin.h b/plugins/keyboard/msd-keyboard-plugin.h index 39a18d7..8ad16f4 100644 --- a/plugins/keyboard/msd-keyboard-plugin.h +++ b/plugins/keyboard/msd-keyboard-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/keyboard/msd-keyboard-xkb.c b/plugins/keyboard/msd-keyboard-xkb.c index 52cc5c9..4373023 100644 --- a/plugins/keyboard/msd-keyboard-xkb.c +++ b/plugins/keyboard/msd-keyboard-xkb.c @@ -3,6 +3,7 @@ * Copyright (C) 2001 Udaltsoft * * Written by Sergey V. Oudaltsov <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -31,6 +32,8 @@ #include <gtk/gtk.h> #include <gio/gio.h> +#include <libmate-desktop/mate-image-menu-item.h> + #include <libmatekbd/matekbd-status.h> #include <libmatekbd/matekbd-keyboard-drawing.h> #include <libmatekbd/matekbd-desktop-config.h> @@ -149,8 +152,7 @@ apply_desktop_settings (void) matekbd_desktop_config_activate (¤t_desktop_config); show_leds = g_settings_get_boolean (settings_desktop, DUPLICATE_LEDS_KEY); - for (i = sizeof (indicator_icons) / sizeof (indicator_icons[0]); - --i >= 0;) { + for (i = G_N_ELEMENTS (indicator_icons); --i >= 0;) { gtk_status_icon_set_visible (indicator_icons[i], show_leds); } @@ -259,7 +261,9 @@ popup_menu_set_group (GtkMenuItem *item G_GNUC_UNUSED, } static void -status_icon_popup_menu_cb (GtkStatusIcon * icon, guint button, guint time) +status_icon_popup_menu_cb (GtkStatusIcon *status_icon, + guint button, + guint time) { GtkWidget *toplevel; GdkScreen *screen; @@ -312,13 +316,11 @@ status_icon_popup_menu_cb (GtkStatusIcon * icon, guint button, guint time) GtkWidget *img = gtk_image_new_from_pixbuf (pixbuf); item = - gtk_image_menu_item_new_with_label + mate_image_menu_item_new_with_label (*current_name); gtk_widget_show (img); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM + mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), img); - gtk_image_menu_item_set_always_show_image - (GTK_IMAGE_MENU_ITEM (item), TRUE); g_free (image_file); } gtk_widget_show (item); @@ -330,7 +332,7 @@ status_icon_popup_menu_cb (GtkStatusIcon * icon, guint button, guint time) gtk_menu_popup (popup_menu, NULL, NULL, gtk_status_icon_position_menu, - (gpointer) icon, button, time); + (gpointer) status_icon, button, time); } static void @@ -502,8 +504,11 @@ msd_keyboard_xkb_set_post_activation_callback (PostActivationCallback fun, } static GdkFilterReturn -msd_keyboard_xkb_evt_filter (GdkXEvent * xev, GdkEvent * event) +msd_keyboard_xkb_evt_filter (GdkXEvent *xev, + GdkEvent *event, + gpointer data) { + (void) data; XEvent *xevent = (XEvent *) xev; xkl_engine_filter_events (xkl_engine, xevent); return GDK_FILTER_CONTINUE; @@ -535,9 +540,7 @@ msd_keyboard_update_indicator_icons (void) new_state |= (state ? 1 : 0); xkl_debug (160, "Indicators state: %d\n", new_state); - - for (i = sizeof (indicator_icons) / sizeof (indicator_icons[0]); - --i >= 0;) { + for (i = G_N_ELEMENTS (indicator_icons); --i >= 0;) { gtk_status_icon_set_from_icon_name (indicator_icons[i], (new_state & (1 << i)) ? @@ -577,8 +580,7 @@ msd_keyboard_xkb_init (MsdKeyboardManager * kbd_manager) num_lock = XInternAtom (display, "Num Lock", False); scroll_lock = XInternAtom (display, "Scroll Lock", False); - for (i = sizeof (indicator_icons) / sizeof (indicator_icons[0]); - --i >= 0;) { + for (i = G_N_ELEMENTS (indicator_icons); --i >= 0;) { indicator_icons[i] = gtk_status_icon_new_from_icon_name (indicator_off_icon_names[i]); @@ -617,8 +619,7 @@ msd_keyboard_xkb_init (MsdKeyboardManager * kbd_manager) g_signal_connect (settings_kbd, "changed", G_CALLBACK (apply_xkb_settings_cb), NULL); - gdk_window_add_filter (NULL, (GdkFilterFunc) - msd_keyboard_xkb_evt_filter, NULL); + gdk_window_add_filter (NULL, msd_keyboard_xkb_evt_filter, NULL); if (xkl_engine_get_features (xkl_engine) & XKLF_DEVICE_DISCOVERY) @@ -656,8 +657,7 @@ msd_keyboard_xkb_shutdown (void) pa_callback_user_data = NULL; manager = NULL; - for (i = sizeof (indicator_icons) / sizeof (indicator_icons[0]); - --i >= 0;) { + for (i = G_N_ELEMENTS (indicator_icons); --i >= 0;) { g_object_unref (G_OBJECT (indicator_icons[i])); indicator_icons[i] = NULL; } @@ -671,8 +671,7 @@ msd_keyboard_xkb_shutdown (void) XKLL_MANAGE_LAYOUTS | XKLL_MANAGE_WINDOW_STATES); - gdk_window_remove_filter (NULL, (GdkFilterFunc) - msd_keyboard_xkb_evt_filter, NULL); + gdk_window_remove_filter (NULL, msd_keyboard_xkb_evt_filter, NULL); if (settings_desktop != NULL) { g_object_unref (settings_desktop); diff --git a/plugins/keyboard/msd-keyboard-xkb.h b/plugins/keyboard/msd-keyboard-xkb.h index 469a469..e8aef83 100644 --- a/plugins/keyboard/msd-keyboard-xkb.h +++ b/plugins/keyboard/msd-keyboard-xkb.h @@ -4,6 +4,7 @@ * Copyright (C) 2001 Udaltsoft * * Written by Sergey V. Oudaltsov <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/media-keys/Makefile.am b/plugins/media-keys/Makefile.am index 65c3ec2..7111525 100644 --- a/plugins/media-keys/Makefile.am +++ b/plugins/media-keys/Makefile.am @@ -6,16 +6,10 @@ NULL = plugin_LTLIBRARIES = libmedia-keys.la BUILT_SOURCES = \ - msd-media-keys-manager-glue.h \ msd-marshal.h \ msd-marshal.c \ $(NULL) -msd-media-keys-manager-glue.h: msd-media-keys-manager.xml Makefile - $(AM_V_GEN) dbus-binding-tool --prefix=msd_media_keys_manager --mode=glib-server $< > xgen-$(@F) \ - && ( cmp -s xgen-$(@F) $@ || cp xgen-$(@F) $@ ) \ - && rm -f xgen-$(@F) - msd-marshal.c: msd-marshal.list $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=msd_marshal $< --body --prototypes --internal > $@ @@ -137,7 +131,6 @@ gtkbuilder_DATA = \ $(NULL) EXTRA_DIST = \ - msd-media-keys-manager.xml \ msd-marshal.list \ $(plugin_in_files) \ $(gtkbuilder_DATA) diff --git a/plugins/media-keys/acme.h b/plugins/media-keys/acme.h index 412ad59..0c25907 100644 --- a/plugins/media-keys/acme.h +++ b/plugins/media-keys/acme.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2001 Bastien Nocera <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index 14cb02d..5ab8946 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -3,6 +3,7 @@ * Copyright (C) 2001-2003 Bastien Nocera <[email protected]> * Copyright (C) 2006-2007 William Jon McCann <[email protected]> * Copyright (C) 2014 Michal Ratajsky <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -29,9 +30,6 @@ #include <gtk/gtk.h> #include <gio/gio.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - #ifdef HAVE_LIBMATEMIXER #include <libmatemixer/matemixer.h> #endif @@ -43,7 +41,6 @@ #include "mate-settings-profile.h" #include "msd-marshal.h" #include "msd-media-keys-manager.h" -#include "msd-media-keys-manager-glue.h" #include "eggaccelerators.h" #include "acme.h" @@ -58,9 +55,28 @@ #define TOUCHPAD_SCHEMA "org.mate.peripherals-touchpad" #define TOUCHPAD_ENABLED_KEY "touchpad-enabled" +#define SOUND_SCHEMA "org.mate.sound" +#define VOLUME_OVERAMPLIFIABLE_KEY "volume-overamplifiable" + +static const gchar introspection_xml[] = +"<node name='/org/mate/SettingsDaemon/MediaKeys'>" +" <interface name='org.mate.SettingsDaemon.MediaKeys'>" +" <method name='GrabMediaPlayerKeys'>" +" <arg name='application' direction='in' type='s'/>" +" <arg name='time' direction='in' type='u'/>" +" </method>" +" <method name='ReleaseMediaPlayerKeys'>" +" <arg name='application' direction='in' type='s'/>" +" </method>" +" <signal name='MediaPlayerKeyPressed'/>" +" </interface>" +"</node>"; + typedef struct { char *application; + char *dbus_name; guint32 time; + guint watch_id; } MediaPlayer; struct _MsdMediaKeysManagerPrivate @@ -75,6 +91,7 @@ struct _MsdMediaKeysManagerPrivate #endif GtkWidget *dialog; GSettings *settings; + GSettings *sound_settings; GVolumeMonitor *volume_monitor; /* Multihead stuff */ @@ -88,20 +105,20 @@ struct _MsdMediaKeysManagerPrivate GList *media_players; - DBusGConnection *connection; - guint notify[HANDLED_KEYS]; -}; + GDBusNodeInfo *introspection_data; + GDBusConnection *connection; + GCancellable *bus_cancellable; -enum { - MEDIA_PLAYER_KEY_PRESSED, - LAST_SIGNAL -}; + guint start_idle_id; -static guint signals[LAST_SIGNAL] = { 0 }; + guint owner_id; + guint notify[HANDLED_KEYS]; +}; G_DEFINE_TYPE_WITH_PRIVATE (MsdMediaKeysManager, msd_media_keys_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; +static void register_manager (MsdMediaKeysManager *manager); static void init_screens (MsdMediaKeysManager *manager) @@ -130,7 +147,7 @@ acme_error (char * msg) GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - msg, NULL); + "%s", msg); gtk_dialog_set_default_response (GTK_DIALOG (error_dialog), GTK_RESPONSE_OK); gtk_widget_show (error_dialog); @@ -476,26 +493,31 @@ dialog_show (MsdMediaKeysManager *manager) } static void +launch_default_for_uri_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GError *error = NULL; + gchar *uri = user_data; + + if (!g_app_info_launch_default_for_uri_finish (res, &error)) + { + g_warning ("Could not launch '%s': %s", uri, + error->message); + g_clear_error (&error); + } + g_free (uri); +} + +static void do_url_action (MsdMediaKeysManager *manager, const gchar *scheme) { - GError *error = NULL; - GAppInfo *app_info; - - app_info = g_app_info_get_default_for_uri_scheme (scheme); - - if (app_info != NULL) { - if (!g_app_info_launch (app_info, NULL, NULL, &error)) { - g_warning ("Could not launch '%s': %s", - g_app_info_get_commandline (app_info), - error->message); - g_object_unref (app_info); - g_error_free (error); - } - } - else { - g_warning ("Could not find default application for '%s' scheme", scheme); - } + g_app_info_launch_default_for_uri_async (scheme, + NULL, + NULL, + launch_default_for_uri_cb, + g_strdup (scheme)); } static void @@ -600,7 +622,6 @@ do_eject_action (MsdMediaKeysManager *manager) continue; if (score < SCORE_HAS_MEDIA) { fav_drive = drive; - score = SCORE_HAS_MEDIA; break; } } @@ -617,7 +638,7 @@ do_eject_action (MsdMediaKeysManager *manager) if (fav_drive != NULL) fav_drive = g_object_ref (fav_drive); - g_list_foreach (drives, (GFunc) g_object_unref, NULL); + g_list_free_full (drives, g_object_unref); if (fav_drive == NULL) return; @@ -666,7 +687,7 @@ update_dialog (MsdMediaKeysManager *manager, gboolean is_mic) { if (muted) - volume = 0.0; + volume = 0; dialog_init (manager); @@ -706,7 +727,8 @@ do_sound_action (MsdMediaKeysManager *manager, gboolean sound_changed = FALSE; guint volume; guint volume_min, volume_max; - guint volume_step; + gint volume_step; + guint volume_step_scaled; guint volume_last; MateMixerStreamControl *control; @@ -722,17 +744,21 @@ do_sound_action (MsdMediaKeysManager *manager, /* Theoretically the volume limits might be different for different * streams, also the minimum might not always start at 0 */ volume_min = mate_mixer_stream_control_get_min_volume (control); - volume_max = mate_mixer_stream_control_get_normal_volume (control); + if (g_settings_get_boolean (manager->priv->sound_settings, VOLUME_OVERAMPLIFIABLE_KEY)) + volume_max = mate_mixer_stream_control_get_max_volume (control); + else + volume_max = mate_mixer_stream_control_get_normal_volume (control); volume_step = g_settings_get_int (manager->priv->settings, "volume-step"); if (volume_step <= 0 || volume_step > 100) { GVariant *variant = g_settings_get_default_value (manager->priv->settings, "volume-step"); - volume_step = g_variant_get_int32 (variant); + gint32 volume_step_default = g_variant_get_int32 (variant); + volume_step = (gint) volume_step_default; g_variant_unref (variant); } /* Scale the volume step size accordingly to the range used by the control */ - volume_step = (volume_max - volume_min) * volume_step / 100; + volume_step_scaled = (volume_max - volume_min) * (guint) volume_step / 100; volume = volume_last = mate_mixer_stream_control_get_volume (control); @@ -745,11 +771,11 @@ do_sound_action (MsdMediaKeysManager *manager, muted = !muted; break; case VOLUME_DOWN_KEY: - if (volume <= (volume_min + volume_step)) { + if (volume <= (volume_min + volume_step_scaled)) { volume = volume_min; muted = TRUE; } else { - volume -= volume_step; + volume -= volume_step_scaled; muted = FALSE; } break; @@ -757,9 +783,9 @@ do_sound_action (MsdMediaKeysManager *manager, if (muted) { muted = FALSE; if (volume <= volume_min) - volume = volume_min + volume_step; + volume = volume_min + volume_step_scaled; } else - volume = CLAMP (volume + volume_step, + volume = CLAMP (volume + volume_step_scaled, volume_min, volume_max); break; @@ -1038,6 +1064,18 @@ do_display_osd_action (MsdMediaKeysManager *manager) dialog_show (manager); } +static void +free_media_player (MediaPlayer *player) +{ + if (player->watch_id > 0) { + g_bus_unwatch_name (player->watch_id); + player->watch_id = 0; + } + g_free (player->application); + g_free (player->dbus_name); + g_free (player); +} + static gint find_by_application (gconstpointer a, gconstpointer b) @@ -1046,12 +1084,40 @@ find_by_application (gconstpointer a, } static gint +find_by_name (gconstpointer a, + gconstpointer b) +{ + return strcmp (((MediaPlayer *)a)->dbus_name, b); +} + +static gint find_by_time (gconstpointer a, gconstpointer b) { return ((MediaPlayer *)a)->time < ((MediaPlayer *)b)->time; } +static void +name_vanished_handler (GDBusConnection *connection, + const gchar *name, + MsdMediaKeysManager *manager) +{ + GList *iter; + + iter = g_list_find_custom (manager->priv->media_players, + name, + find_by_name); + + if (iter != NULL) { + MediaPlayer *player; + + player = iter->data; + g_debug ("Deregistering vanished %s (dbus_name: %s)", player->application, player->dbus_name); + free_media_player (player); + manager->priv->media_players = g_list_delete_link (manager->priv->media_players, iter); + } +} + /* * Register a new media player. Most applications will want to call * this with time = GDK_CURRENT_TIME. This way, the last registered @@ -1059,14 +1125,15 @@ find_by_time (gconstpointer a, * may want to register with a lower priority (usually 1), to grab * events only nobody is interested. */ -gboolean +static void msd_media_keys_manager_grab_media_player_keys (MsdMediaKeysManager *manager, const char *application, - guint32 time, - GError **error) + const char *dbus_name, + guint32 time) { GList *iter; MediaPlayer *media_player; + guint watch_id; if (time == GDK_CURRENT_TIME) { time = (guint32)(g_get_monotonic_time () / 1000); @@ -1078,51 +1145,70 @@ msd_media_keys_manager_grab_media_player_keys (MsdMediaKeysManager *manager, if (iter != NULL) { if (((MediaPlayer *)iter->data)->time < time) { - g_free (((MediaPlayer *)iter->data)->application); - g_free (iter->data); + MediaPlayer *player = iter->data; + free_media_player (player); manager->priv->media_players = g_list_delete_link (manager->priv->media_players, iter); } else { - return TRUE; + return; } } + watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, + dbus_name, + G_BUS_NAME_WATCHER_FLAGS_NONE, + NULL, + (GBusNameVanishedCallback) name_vanished_handler, + manager, + NULL); + g_debug ("Registering %s at %u", application, time); media_player = g_new0 (MediaPlayer, 1); media_player->application = g_strdup (application); + media_player->dbus_name = g_strdup (dbus_name); media_player->time = time; + media_player->watch_id = watch_id; manager->priv->media_players = g_list_insert_sorted (manager->priv->media_players, media_player, find_by_time); - - return TRUE; } -gboolean +static void msd_media_keys_manager_release_media_player_keys (MsdMediaKeysManager *manager, const char *application, - GError **error) + const char *name) { - GList *iter; + GList *iter = NULL; - iter = g_list_find_custom (manager->priv->media_players, - application, - find_by_application); + g_return_if_fail (application != NULL || name != NULL); + + if (application != NULL) { + iter = g_list_find_custom (manager->priv->media_players, + application, + find_by_application); + } + + if (iter == NULL && name != NULL) { + iter = g_list_find_custom (manager->priv->media_players, + name, + find_by_name); + } if (iter != NULL) { - g_debug ("Deregistering %s", application); - g_free (((MediaPlayer *)iter->data)->application); - g_free (iter->data); + MediaPlayer *player; + + player = iter->data; + g_debug ("Deregistering %s (dbus_name: %s)", application, player->dbus_name); + free_media_player (player); manager->priv->media_players = g_list_delete_link (manager->priv->media_players, iter); } - - return TRUE; } static gboolean msd_media_player_key_pressed (MsdMediaKeysManager *manager, const char *key) { + GError *error = NULL; const char *application = NULL; gboolean have_listeners; @@ -1132,11 +1218,55 @@ msd_media_player_key_pressed (MsdMediaKeysManager *manager, application = ((MediaPlayer *)manager->priv->media_players->data)->application; } - g_signal_emit (manager, signals[MEDIA_PLAYER_KEY_PRESSED], 0, application, key); + if (g_dbus_connection_emit_signal (manager->priv->connection, + NULL, + MSD_MEDIA_KEYS_DBUS_PATH, + MSD_MEDIA_KEYS_DBUS_NAME, + "MediaPlayerKeyPressed", + g_variant_new ("(ss)", application, key), + &error) == FALSE) { + g_debug ("Error emitting signal: %s", error->message); + g_error_free (error); + } return !have_listeners; } +static void +handle_method_call (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + MsdMediaKeysManager *manager = (MsdMediaKeysManager *) user_data; + + g_debug ("Calling method '%s' for media-keys", method_name); + + if (g_strcmp0 (method_name, "ReleaseMediaPlayerKeys") == 0) { + const char *app_name; + + g_variant_get (parameters, "(&s)", &app_name); + msd_media_keys_manager_release_media_player_keys (manager, app_name, sender); + g_dbus_method_invocation_return_value (invocation, NULL); + } else if (g_strcmp0 (method_name, "GrabMediaPlayerKeys") == 0) { + const char *app_name; + guint32 time; + + g_variant_get (parameters, "(&su)", &app_name, &time); + msd_media_keys_manager_grab_media_player_keys (manager, app_name, sender, time); + g_dbus_method_invocation_return_value (invocation, NULL); + } +} + +static const GDBusInterfaceVTable interface_vtable = +{ + .method_call = handle_method_call, +}; + static gboolean do_multimedia_player_action (MsdMediaKeysManager *manager, const char *key) @@ -1400,7 +1530,7 @@ rfkill_appeared_cb (GDBusConnection *connection, g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, 0, NULL, - "org.mate.SettingsDaemon.Rfkill", + "org.mate.SettingsDaemon", "/org/mate/SettingsDaemon/Rfkill", "org.mate.SettingsDaemon.Rfkill", manager->priv->rfkill_cancellable, @@ -1422,6 +1552,7 @@ start_media_keys_idle_cb (MsdMediaKeysManager *manager) manager->priv->volume_monitor = g_volume_monitor_get (); manager->priv->settings = g_settings_new (BINDING_SCHEMA); + manager->priv->sound_settings = g_settings_new (SOUND_SCHEMA); ensure_cancellable (&manager->priv->rfkill_cancellable); @@ -1464,6 +1595,8 @@ start_media_keys_idle_cb (MsdMediaKeysManager *manager) mate_settings_profile_end (NULL); + manager->priv->start_idle_id = 0; + return FALSE; } @@ -1500,7 +1633,8 @@ msd_media_keys_manager_start (MsdMediaKeysManager *manager, GError **error) mate_settings_profile_end ("mate_mixer_context_new"); } #endif - g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager); + manager->priv->start_idle_id = g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager); + g_source_set_name_by_id (manager->priv->start_idle_id, "[mate-settings-daemon] start_media_keys_idle_cb"); mate_settings_profile_end (NULL); @@ -1535,16 +1669,39 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager) priv->settings = NULL; } + if (priv->sound_settings != NULL) { + g_object_unref (priv->sound_settings); + priv->sound_settings = NULL; + } + if (priv->volume_monitor != NULL) { g_object_unref (priv->volume_monitor); priv->volume_monitor = NULL; } + if (priv->start_idle_id != 0) { + g_source_remove (priv->start_idle_id); + priv->start_idle_id = 0; + } + + if (priv->owner_id > 0) { + g_bus_unown_name (priv->owner_id); + priv->owner_id = 0; + } + if (priv->connection != NULL) { - dbus_g_connection_unref (priv->connection); + g_object_unref (priv->connection); priv->connection = NULL; } + if (priv->bus_cancellable != NULL) { + g_cancellable_cancel (priv->bus_cancellable); + g_object_unref (priv->bus_cancellable); + priv->bus_cancellable = NULL; + } + + g_clear_pointer (&priv->introspection_data, g_dbus_node_info_unref); + need_flush = FALSE; dpy = gdk_display_get_default (); gdk_x11_display_error_trap_push (dpy); @@ -1596,22 +1753,29 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager) } static void +msd_media_keys_manager_finalize (GObject *object) +{ + MsdMediaKeysManager *manager; + + g_return_if_fail (object != NULL); + g_return_if_fail (MSD_IS_MEDIA_KEYS_MANAGER (object)); + + manager = MSD_MEDIA_KEYS_MANAGER (object); + + g_return_if_fail (manager->priv != NULL); + + msd_media_keys_manager_stop (manager); + + G_OBJECT_CLASS (msd_media_keys_manager_parent_class)->finalize (object); +} + + +static void msd_media_keys_manager_class_init (MsdMediaKeysManagerClass *klass) { - signals[MEDIA_PLAYER_KEY_PRESSED] = - g_signal_new ("media-player-key-pressed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (MsdMediaKeysManagerClass, media_player_key_pressed), - NULL, - NULL, - msd_marshal_VOID__STRING_STRING, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_STRING); - - dbus_g_object_type_install_info (MSD_TYPE_MEDIA_KEYS_MANAGER, &dbus_glib_msd_media_keys_manager_object_info); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = msd_media_keys_manager_finalize; } static void @@ -1620,23 +1784,50 @@ msd_media_keys_manager_init (MsdMediaKeysManager *manager) manager->priv = msd_media_keys_manager_get_instance_private (manager); } -static gboolean -register_manager (MsdMediaKeysManager *manager) + +static void +on_bus_gotten (GObject *source_object, + GAsyncResult *res, + MsdMediaKeysManager *manager) { + GDBusConnection *connection; GError *error = NULL; - manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (manager->priv->connection == NULL) { - if (error != NULL) { - g_error ("Error getting session bus: %s", error->message); - g_error_free (error); - } - return FALSE; + connection = g_bus_get_finish (res, &error); + if (connection == NULL) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Could not get session bus: %s", error->message); + g_error_free (error); + return; } + manager->priv->connection = connection; + + g_dbus_connection_register_object (connection, + MSD_MEDIA_KEYS_DBUS_PATH, + manager->priv->introspection_data->interfaces[0], + &interface_vtable, + manager, + NULL, + NULL); + + manager->priv->owner_id = g_bus_own_name_on_connection (manager->priv->connection, + "org.mate.SettingsDaemon", + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, + NULL, NULL, NULL, NULL); +} - dbus_g_connection_register_g_object (manager->priv->connection, MSD_MEDIA_KEYS_DBUS_PATH, G_OBJECT (manager)); +static void +register_manager (MsdMediaKeysManager *manager) +{ - return TRUE; + manager->priv->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); + manager->priv->bus_cancellable = g_cancellable_new (); + g_assert (manager->priv->introspection_data != NULL); + + g_bus_get (G_BUS_TYPE_SESSION, + manager->priv->bus_cancellable, + (GAsyncReadyCallback) on_bus_gotten, + manager); } MsdMediaKeysManager * @@ -1645,16 +1836,10 @@ msd_media_keys_manager_new (void) if (manager_object != NULL) { g_object_ref (manager_object); } else { - gboolean res; - manager_object = g_object_new (MSD_TYPE_MEDIA_KEYS_MANAGER, NULL); g_object_add_weak_pointer (manager_object, (gpointer *) &manager_object); - res = register_manager (manager_object); - if (! res) { - g_object_unref (manager_object); - return NULL; - } + register_manager (manager_object); } return MSD_MEDIA_KEYS_MANAGER (manager_object); diff --git a/plugins/media-keys/msd-media-keys-manager.h b/plugins/media-keys/msd-media-keys-manager.h index 2afb5bc..add29d2 100644 --- a/plugins/media-keys/msd-media-keys-manager.h +++ b/plugins/media-keys/msd-media-keys-manager.h @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2014 Michal Ratajsky <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -59,14 +60,6 @@ gboolean msd_media_keys_manager_start (MsdMedia GError **error); void msd_media_keys_manager_stop (MsdMediaKeysManager *manager); -gboolean msd_media_keys_manager_grab_media_player_keys (MsdMediaKeysManager *manager, - const char *application, - guint32 time, - GError **error); -gboolean msd_media_keys_manager_release_media_player_keys (MsdMediaKeysManager *manager, - const char *application, - GError **error); - G_END_DECLS #endif /* __MSD_MEDIA_KEYS_MANAGER_H */ diff --git a/plugins/media-keys/msd-media-keys-manager.xml b/plugins/media-keys/msd-media-keys-manager.xml deleted file mode 100644 index db0552e..0000000 --- a/plugins/media-keys/msd-media-keys-manager.xml +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node> - <interface name="org.mate.SettingsDaemon.MediaKeys"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="msd_media_keys_manager"/> - <method name="GrabMediaPlayerKeys"> - <arg name="application" direction="in" type="s"/> - <arg name="time" direction="in" type="u"/> - </method> - <method name="ReleaseMediaPlayerKeys"> - <arg name="application" direction="in" type="s"/> - </method> - <signal name="MediaPlayerKeyPressed"/> - </interface> -</node> diff --git a/plugins/media-keys/msd-media-keys-plugin.c b/plugins/media-keys/msd-media-keys-plugin.c index d1124c6..c3a2d98 100644 --- a/plugins/media-keys/msd-media-keys-plugin.c +++ b/plugins/media-keys/msd-media-keys-plugin.c @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2014 Michal Ratajsky <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/media-keys/msd-media-keys-plugin.h b/plugins/media-keys/msd-media-keys-plugin.h index 0662009..be459b0 100644 --- a/plugins/media-keys/msd-media-keys-plugin.h +++ b/plugins/media-keys/msd-media-keys-plugin.h @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2014 Michal Ratajsky <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/media-keys/msd-media-keys-window.c b/plugins/media-keys/msd-media-keys-window.c index 9c36641..c632b92 100644 --- a/plugins/media-keys/msd-media-keys-window.c +++ b/plugins/media-keys/msd-media-keys-window.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2006-2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * * This program is free software; you can redistribute it and/or @@ -43,7 +44,7 @@ struct MsdMediaKeysWindowPrivate guint volume_muted : 1; guint mic_muted : 1; guint is_mic :1; - int volume_level; + guint volume_level; GtkImage *image; GtkWidget *progress; @@ -223,7 +224,7 @@ msd_media_keys_window_set_volume_muted (MsdMediaKeysWindow *window, g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window)); if (window->priv->volume_muted != muted) { - window->priv->volume_muted = muted; + window->priv->volume_muted = muted != FALSE; volume_muted_changed (window); } window->priv->is_mic = FALSE; @@ -236,7 +237,7 @@ msd_media_keys_window_set_mic_muted (MsdMediaKeysWindow *window, g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window)); if (window->priv->mic_muted != muted) { - window->priv->mic_muted = muted; + window->priv->mic_muted = muted != FALSE; mic_muted_changed (window); } window->priv->is_mic = TRUE; @@ -244,7 +245,7 @@ msd_media_keys_window_set_mic_muted (MsdMediaKeysWindow *window, void msd_media_keys_window_set_volume_level (MsdMediaKeysWindow *window, - int level) + guint level) { g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window)); @@ -284,26 +285,26 @@ draw_eject (cairo_t *cr, double width, double height) { - int box_height; - int tri_height; - int separation; + double box_height; + double tri_height; + double separation; box_height = height * 0.2; - separation = box_height / 3; + separation = box_height / 3.0; tri_height = height - box_height - separation; cairo_rectangle (cr, _x0, _y0 + height - box_height, width, box_height); cairo_move_to (cr, _x0, _y0 + tri_height); - cairo_rel_line_to (cr, width, 0); - cairo_rel_line_to (cr, -width / 2, -tri_height); - cairo_rel_line_to (cr, -width / 2, tri_height); + cairo_rel_line_to (cr, width, 0.0); + cairo_rel_line_to (cr, -width * 0.5, -tri_height); + cairo_rel_line_to (cr, -width * 0.5, tri_height); cairo_close_path (cr); cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, MSD_OSD_WINDOW_FG_ALPHA); cairo_fill_preserve (cr); - cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, MSD_OSD_WINDOW_FG_ALPHA / 2); - cairo_set_line_width (cr, 2); + cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, MSD_OSD_WINDOW_FG_ALPHA * 0.5); + cairo_set_line_width (cr, 2.0); cairo_stroke (cr); } @@ -418,7 +419,7 @@ render_speaker (MsdMediaKeysWindow *window, { GdkPixbuf *pixbuf; int icon_size; - int n; + guint n; static const char *icon_names[] = { "audio-volume-muted", "audio-volume-low", @@ -605,7 +606,7 @@ draw_action_volume (MsdMediaKeysWindow *window, wave_y0 = speaker_cy; wave_radius = icon_box_width / 2; - draw_waves (cr, wave_x0, wave_y0, wave_radius, window->priv->volume_level); + draw_waves (cr, wave_x0, wave_y0, wave_radius, (int) window->priv->volume_level); } else { /* draw 'mute' cross */ double cross_x0; diff --git a/plugins/media-keys/msd-media-keys-window.h b/plugins/media-keys/msd-media-keys-window.h index 88c3748..92c511e 100644 --- a/plugins/media-keys/msd-media-keys-window.h +++ b/plugins/media-keys/msd-media-keys-window.h @@ -1,6 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- * * Copyright (C) 2006 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -70,7 +71,7 @@ void msd_media_keys_window_set_mic_muted (MsdMediaKeysWindo void msd_media_keys_window_set_volume_muted (MsdMediaKeysWindow *window, gboolean muted); void msd_media_keys_window_set_volume_level (MsdMediaKeysWindow *window, - int level); + guint level); gboolean msd_media_keys_window_is_valid (MsdMediaKeysWindow *window); #ifdef __cplusplus diff --git a/plugins/media-keys/test-media-keys.c b/plugins/media-keys/test-media-keys.c index 51ea1e3..e9f2ed7 100644 --- a/plugins/media-keys/test-media-keys.c +++ b/plugins/media-keys/test-media-keys.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/media-keys/test-media-window.c b/plugins/media-keys/test-media-window.c index 583ecbf..f6f5c35 100644 --- a/plugins/media-keys/test-media-window.c +++ b/plugins/media-keys/test-media-window.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/plugins/mouse/msd-locate-pointer.c b/plugins/mouse/msd-locate-pointer.c index 6009404..e384017 100644 --- a/plugins/mouse/msd-locate-pointer.c +++ b/plugins/mouse/msd-locate-pointer.c @@ -1,6 +1,7 @@ /* msd-locate-pointer.c * * Copyright (C) 2008 Carlos Garnacho <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -48,8 +49,6 @@ struct MsdLocatePointerData gdouble progress; }; -static MsdLocatePointerData *data = NULL; - static void locate_pointer_paint (MsdLocatePointerData *data, cairo_t *cr, @@ -414,6 +413,7 @@ void msd_locate_pointer (GdkDisplay *display) { GdkScreen *screen = gdk_display_get_default_screen (display); + static MsdLocatePointerData *data = NULL; if (data == NULL) { @@ -435,7 +435,6 @@ msd_locate_pointer (GdkDisplay *display) msd_timeline_start (data->timeline); } - #define KEYBOARD_GROUP_SHIFT 13 #define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14)) @@ -576,7 +575,6 @@ set_locate_pointer (void) } } - int main (int argc, char *argv[]) { diff --git a/plugins/mouse/msd-locate-pointer.h b/plugins/mouse/msd-locate-pointer.h index 4e3a8b3..ba4d724 100644 --- a/plugins/mouse/msd-locate-pointer.h +++ b/plugins/mouse/msd-locate-pointer.h @@ -1,5 +1,6 @@ /* * Copyright � 2001 Jonathan Blandford <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 9d1d7c4..92a5f0a 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -75,7 +76,6 @@ #define KEY_HORIZ_TWO_FINGER_SCROLL "horizontal-two-finger-scrolling" #define KEY_TOUCHPAD_ENABLED "touchpad-enabled" - #if 0 /* FIXME need to fork (?) mousetweaks for this to work */ #define MATE_MOUSE_A11Y_SCHEMA "org.mate.accessibility-mouse" #define KEY_MOUSE_A11Y_DWELL_ENABLE "dwell-enable" @@ -117,7 +117,6 @@ static void set_tap_to_click_synaptics (XDeviceInfo *device_info gint two_finger_tap, gint three_finger_tap); - G_DEFINE_TYPE_WITH_PRIVATE (MsdMouseManager, msd_mouse_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; @@ -1626,7 +1625,6 @@ set_mousetweaks_daemon (MsdMouseManager *manager, if (run_daemon) manager->priv->mousetweaks_daemon_running = TRUE; - if (! g_spawn_command_line_async (comm, &error)) { if (error->code == G_SPAWN_ERROR_NOENT && (dwell_enable || delay_enable)) { diff --git a/plugins/mouse/msd-mouse-manager.h b/plugins/mouse/msd-mouse-manager.h index a6b66c0..3ba203a 100644 --- a/plugins/mouse/msd-mouse-manager.h +++ b/plugins/mouse/msd-mouse-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/mouse/msd-mouse-plugin.c b/plugins/mouse/msd-mouse-plugin.c index 730b8ce..e510771 100644 --- a/plugins/mouse/msd-mouse-plugin.c +++ b/plugins/mouse/msd-mouse-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/mouse/msd-mouse-plugin.h b/plugins/mouse/msd-mouse-plugin.h index f9eb865..2809c62 100644 --- a/plugins/mouse/msd-mouse-plugin.h +++ b/plugins/mouse/msd-mouse-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/mouse/msd-timeline.c b/plugins/mouse/msd-timeline.c index 042cd5b..3b6cf79 100644 --- a/plugins/mouse/msd-timeline.c +++ b/plugins/mouse/msd-timeline.c @@ -1,6 +1,7 @@ /* msd-timeline.c * * Copyright (C) 2008 Carlos Garnacho <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -64,7 +65,6 @@ enum { static guint signals [LAST_SIGNAL] = { 0, }; - static void msd_timeline_set_property (GObject *object, guint prop_id, const GValue *value, @@ -646,7 +646,7 @@ msd_timeline_set_loop (MsdTimeline *timeline, g_return_if_fail (MSD_IS_TIMELINE (timeline)); priv = msd_timeline_get_instance_private (timeline); - priv->loop = loop; + priv->loop = (loop != FALSE); g_object_notify (G_OBJECT (timeline), "loop"); } diff --git a/plugins/mouse/msd-timeline.h b/plugins/mouse/msd-timeline.h index f0ed24a..5e69411 100644 --- a/plugins/mouse/msd-timeline.h +++ b/plugins/mouse/msd-timeline.h @@ -1,6 +1,7 @@ /* msdtimeline.c * * Copyright (C) 2008 Carlos Garnacho <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -74,7 +75,6 @@ struct MsdTimelineClass typedef gdouble (*MsdTimelineProgressFunc) (gdouble progress); - GType msd_timeline_get_type (void) G_GNUC_CONST; GType msd_timeline_direction_get_type (void) G_GNUC_CONST; GType msd_timeline_progress_type_get_type (void) G_GNUC_CONST; @@ -119,7 +119,6 @@ void msd_timeline_set_progress_func (MsdTimeline gdouble msd_timeline_get_progress (MsdTimeline *timeline); - #ifdef __cplusplus } #endif diff --git a/plugins/mpris/bus-watch-namespace.c b/plugins/mpris/bus-watch-namespace.c index f1aff23..489c96d 100644 --- a/plugins/mpris/bus-watch-namespace.c +++ b/plugins/mpris/bus-watch-namespace.c @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as diff --git a/plugins/mpris/bus-watch-namespace.h b/plugins/mpris/bus-watch-namespace.h index 215f6be..20c5628 100644 --- a/plugins/mpris/bus-watch-namespace.h +++ b/plugins/mpris/bus-watch-namespace.h @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as diff --git a/plugins/mpris/msd-mpris-manager.c b/plugins/mpris/msd-mpris-manager.c index f9686f1..965bb5c 100644 --- a/plugins/mpris/msd-mpris-manager.c +++ b/plugins/mpris/msd-mpris-manager.c @@ -4,6 +4,7 @@ * 2013 Steve Zesch <[email protected]> * 2007 William Jon McCann <[email protected]> * 2007 Jan Arne Petersen <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -292,7 +293,6 @@ msd_name_vanished (GDBusConnection *connection, } } - gboolean msd_mpris_manager_start (MsdMprisManager *manager, GError **error) diff --git a/plugins/mpris/msd-mpris-manager.h b/plugins/mpris/msd-mpris-manager.h index a5671ec..d43f15e 100644 --- a/plugins/mpris/msd-mpris-manager.h +++ b/plugins/mpris/msd-mpris-manager.h @@ -2,6 +2,7 @@ * * Copyright (C) 2013 Stefano Karapetsas <[email protected]> * 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/mpris/msd-mpris-plugin.c b/plugins/mpris/msd-mpris-plugin.c index 44923ca..fafd3c4 100644 --- a/plugins/mpris/msd-mpris-plugin.c +++ b/plugins/mpris/msd-mpris-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/mpris/msd-mpris-plugin.h b/plugins/mpris/msd-mpris-plugin.h index cf9cf52..087824f 100644 --- a/plugins/mpris/msd-mpris-plugin.h +++ b/plugins/mpris/msd-mpris-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/rfkill/msd-rfkill-manager.c b/plugins/rfkill/msd-rfkill-manager.c index 7a79511..252761d 100644 --- a/plugins/rfkill/msd-rfkill-manager.c +++ b/plugins/rfkill/msd-rfkill-manager.c @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2010,2011 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Author: Bastien Nocera <[email protected]> * @@ -65,9 +66,8 @@ struct MsdRfkillManagerPrivate #define MSD_RFKILL_DBUS_PATH MSD_DBUS_PATH "/Rfkill" static const gchar introspection_xml[] = -"<node>" +"<node name='/org/mate/SettingsDaemon/Rfkill'>" " <interface name='org.mate.SettingsDaemon.Rfkill'>" -" <annotation name='org.freedesktop.DBus.GLib.CSymbol' value='msd_rfkill_manager'/>" " <property name='AirplaneMode' type='b' access='readwrite'/>" " <property name='HardwareAirplaneMode' type='b' access='read'/>" " <property name='HasAirplaneMode' type='b' access='read'/>" @@ -461,7 +461,8 @@ static const GDBusInterfaceVTable interface_vtable = { NULL, handle_get_property, - handle_set_property + handle_set_property, + { 0 } }; static void @@ -490,8 +491,8 @@ on_bus_gotten (GObject *source_object, NULL); manager->priv->name_id = g_bus_own_name_on_connection (connection, - MSD_RFKILL_DBUS_NAME, - G_BUS_NAME_OWNER_FLAGS_NONE, + MSD_DBUS_NAME, + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, NULL, NULL, NULL, diff --git a/plugins/rfkill/msd-rfkill-manager.h b/plugins/rfkill/msd-rfkill-manager.h index 6ca862f..24dfbf2 100644 --- a/plugins/rfkill/msd-rfkill-manager.h +++ b/plugins/rfkill/msd-rfkill-manager.h @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/rfkill/msd-rfkill-plugin.c b/plugins/rfkill/msd-rfkill-plugin.c index a508ca4..5b9f889 100644 --- a/plugins/rfkill/msd-rfkill-plugin.c +++ b/plugins/rfkill/msd-rfkill-plugin.c @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/rfkill/msd-rfkill-plugin.h b/plugins/rfkill/msd-rfkill-plugin.h index 1887d62..d293d74 100644 --- a/plugins/rfkill/msd-rfkill-plugin.h +++ b/plugins/rfkill/msd-rfkill-plugin.h @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2014 Michal Ratajsky <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/rfkill/rfkill-glib.c b/plugins/rfkill/rfkill-glib.c index 6ef1143..37e43d2 100644 --- a/plugins/rfkill/rfkill-glib.c +++ b/plugins/rfkill/rfkill-glib.c @@ -4,6 +4,7 @@ * * Copyright (C) 2012 Bastien Nocera <[email protected]> * Copyright © 2017 Endless Mobile, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -357,7 +358,11 @@ event_cb (GIOChannel *source, print_event (&event); +#if GLIB_CHECK_VERSION (2, 68, 0) + event_ptr = g_memdup2 (&event, sizeof(event)); +#else event_ptr = g_memdup (&event, sizeof(event)); +#endif events = g_list_prepend (events, event_ptr); status = g_io_channel_read_chars (source, @@ -440,7 +445,11 @@ cc_rfkill_glib_open (CcRfkillGlib *rfkill) type_to_string (event.type), event.idx, event.soft, event.hard); +#if GLIB_CHECK_VERSION (2, 68, 0) + event_ptr = g_memdup2 (&event, sizeof(event)); +#else event_ptr = g_memdup (&event, sizeof(event)); +#endif events = g_list_prepend (events, event_ptr); } diff --git a/plugins/rfkill/rfkill-glib.h b/plugins/rfkill/rfkill-glib.h index 4734154..e7dc7a7 100644 --- a/plugins/rfkill/rfkill-glib.h +++ b/plugins/rfkill/rfkill-glib.h @@ -3,6 +3,7 @@ * gnome-bluetooth - Bluetooth integration for GNOME * * Copyright (C) 2012 Bastien Nocera <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * * This program is free software; you can redistribute it and/or modify diff --git a/plugins/rfkill/rfkill.h b/plugins/rfkill/rfkill.h index abb2c66..dbb2527 100644 --- a/plugins/rfkill/rfkill.h +++ b/plugins/rfkill/rfkill.h @@ -5,6 +5,7 @@ * Copyright (C) 2006 - 2007 Ivo van Doorn * Copyright (C) 2007 Dmitry Torokhov * Copyright 2009 Johannes Berg <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/plugins/smartcard/msd-smartcard-manager.c b/plugins/smartcard/msd-smartcard-manager.c index 43d6644..6d1ec4a 100644 --- a/plugins/smartcard/msd-smartcard-manager.c +++ b/plugins/smartcard/msd-smartcard-manager.c @@ -2,6 +2,7 @@ * removal events * * Copyright (C) 2006, 2009 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -290,8 +291,8 @@ msd_smartcard_manager_class_install_signals (MsdSmartcardManagerClass *manager_c } static gboolean -slot_id_equal (CK_SLOT_ID *slot_id_1, - CK_SLOT_ID *slot_id_2) +slot_id_equal (const CK_SLOT_ID *slot_id_1, + const CK_SLOT_ID *slot_id_2) { g_assert (slot_id_1 != NULL); g_assert (slot_id_2 != NULL); @@ -1207,7 +1208,6 @@ msd_smartcard_manager_worker_run (MsdSmartcardManagerWorker *worker) { GError *error; - error = NULL; while (msd_smartcard_manager_worker_watch_for_and_process_event (worker, &error)); diff --git a/plugins/smartcard/msd-smartcard-manager.h b/plugins/smartcard/msd-smartcard-manager.h index c5c9d55..b8b0e7c 100644 --- a/plugins/smartcard/msd-smartcard-manager.h +++ b/plugins/smartcard/msd-smartcard-manager.h @@ -2,6 +2,7 @@ * removal events * * Copyright (C) 2006, 2009 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/smartcard/msd-smartcard-plugin.c b/plugins/smartcard/msd-smartcard-plugin.c index b11deda..3792cb5 100644 --- a/plugins/smartcard/msd-smartcard-plugin.c +++ b/plugins/smartcard/msd-smartcard-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -25,9 +26,6 @@ #include <glib.h> #include <glib-object.h> - -#include <dbus/dbus-glib.h> - #include <gio/gio.h> #include "mate-settings-plugin.h" @@ -36,8 +34,7 @@ struct MsdSmartcardPluginPrivate { MsdSmartcardManager *manager; - DBusGConnection *bus_connection; - + GDBusProxy *screensaver_proxy; guint32 is_active : 1; }; @@ -65,62 +62,82 @@ MATE_SETTINGS_PLUGIN_REGISTER_WITH_PRIVATE (MsdSmartcardPlugin, msd_smartcard_pl static void simulate_user_activity (MsdSmartcardPlugin *plugin) { - DBusGProxy *screensaver_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling screensaver about smart card insertion"); - screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SCREENSAVER_DBUS_NAME, - SCREENSAVER_DBUS_PATH, - SCREENSAVER_DBUS_INTERFACE); - - dbus_g_proxy_call_no_reply (screensaver_proxy, - "SimulateUserActivity", - G_TYPE_INVALID, G_TYPE_INVALID); - - g_object_unref (screensaver_proxy); + ret = g_dbus_proxy_call_sync (plugin->priv->screensaver_proxy, + "SimulateUserActivity", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { + g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); + g_error_free (error); + } else { + g_variant_unref (ret); + } } static void lock_screen (MsdSmartcardPlugin *plugin) { - DBusGProxy *screensaver_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling screensaver to lock screen"); - screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SCREENSAVER_DBUS_NAME, - SCREENSAVER_DBUS_PATH, - SCREENSAVER_DBUS_INTERFACE); - dbus_g_proxy_call_no_reply (screensaver_proxy, - "Lock", - G_TYPE_INVALID, G_TYPE_INVALID); - - g_object_unref (screensaver_proxy); + ret = g_dbus_proxy_call_sync (plugin->priv->screensaver_proxy, + "Lock", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { + g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); + g_error_free (error); + } else { + g_variant_unref (ret); + } } static void force_logout (MsdSmartcardPlugin *plugin) { - DBusGProxy *sm_proxy; - GError *error; - gboolean res; + GDBusProxy *sm_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling session manager to force logout"); - sm_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SM_DBUS_NAME, - SM_DBUS_PATH, - SM_DBUS_INTERFACE); - - error = NULL; - res = dbus_g_proxy_call (sm_proxy, - "Logout", - &error, - G_TYPE_UINT, SM_LOGOUT_MODE_FORCE, - G_TYPE_INVALID, G_TYPE_INVALID); + sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + SM_DBUS_NAME, + SM_DBUS_PATH, + SM_DBUS_INTERFACE, + NULL, + &error); + if (sm_proxy == NULL) { + g_warning ("Unable to contact session manager daemon: %s\n", error->message); + g_error_free (error); + return; + } - if (! res) { + ret = g_dbus_proxy_call_sync (sm_proxy, + "Logout", + g_variant_new ("(u", SM_LOGOUT_MODE_FORCE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); g_error_free (error); + } else { + g_variant_unref (ret); } g_object_unref (sm_proxy); @@ -270,10 +287,18 @@ impl_activate (MateSettingsPlugin *plugin) g_debug ("MsdSmartcardPlugin Activating smartcard plugin"); error = NULL; - smartcard_plugin->priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - - if (smartcard_plugin->priv->bus_connection == NULL) { + smartcard_plugin->priv->screensaver_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + SCREENSAVER_DBUS_NAME, + SCREENSAVER_DBUS_PATH, + SCREENSAVER_DBUS_INTERFACE, + NULL, + &error); + + if (smartcard_plugin->priv->screensaver_proxy == NULL) { g_warning ("MsdSmartcardPlugin Unable to connect to session bus: %s", error->message); + g_error_free (error); return; } @@ -319,7 +344,8 @@ impl_deactivate (MateSettingsPlugin *plugin) g_signal_handlers_disconnect_by_func (smartcard_plugin->priv->manager, smartcard_inserted_cb, smartcard_plugin); - smartcard_plugin->priv->bus_connection = NULL; + if (smartcard_plugin->priv->screensaver_proxy != NULL) + g_object_unref (smartcard_plugin->priv->screensaver_proxy); smartcard_plugin->priv->is_active = FALSE; } diff --git a/plugins/smartcard/msd-smartcard-plugin.h b/plugins/smartcard/msd-smartcard-plugin.h index 64663d3..f16665b 100644 --- a/plugins/smartcard/msd-smartcard-plugin.h +++ b/plugins/smartcard/msd-smartcard-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/smartcard/msd-smartcard.c b/plugins/smartcard/msd-smartcard.c index ab46ca6..b5df5ce 100644 --- a/plugins/smartcard/msd-smartcard.c +++ b/plugins/smartcard/msd-smartcard.c @@ -1,6 +1,7 @@ /* msd-smartcard.c - smartcard object * * Copyright (C) 2006 Ray Strode <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/smartcard/msd-smartcard.h b/plugins/smartcard/msd-smartcard.h index da50b62..2633e31 100644 --- a/plugins/smartcard/msd-smartcard.h +++ b/plugins/smartcard/msd-smartcard.h @@ -1,6 +1,7 @@ /* securitycard.h - api for reading and writing data to a security card * * Copyright (C) 2006 Ray Strode + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/sound/msd-sound-manager.c b/plugins/sound/msd-sound-manager.c index c817e29..0b4fbdc 100644 --- a/plugins/sound/msd-sound-manager.c +++ b/plugins/sound/msd-sound-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Lennart Poettering <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -43,10 +44,14 @@ #include "msd-sound-manager.h" #include "mate-settings-profile.h" -struct MsdSoundManagerPrivate +struct _MsdSoundManager { + GObject parent; + +#ifdef HAVE_PULSE GSettings *settings; GList* monitors; +#endif /* HAVE_PULSE */ guint timeout; }; @@ -54,7 +59,7 @@ struct MsdSoundManagerPrivate static void msd_sound_manager_finalize (GObject *object); -G_DEFINE_TYPE_WITH_PRIVATE (MsdSoundManager, msd_sound_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (MsdSoundManager, msd_sound_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; @@ -184,7 +189,7 @@ static gboolean flush_cb (MsdSoundManager *manager) { flush_cache (); - manager->priv->timeout = 0; + manager->timeout = 0; return FALSE; } @@ -192,12 +197,12 @@ static void trigger_flush (MsdSoundManager *manager) { - if (manager->priv->timeout) - g_source_remove (manager->priv->timeout); + if (manager->timeout) + g_source_remove (manager->timeout); /* We delay the flushing a bit so that we can coalesce * multiple changes into a single cache flush */ - manager->priv->timeout = g_timeout_add (500, (GSourceFunc) flush_cb, manager); + manager->timeout = g_timeout_add (500, (GSourceFunc) flush_cb, manager); } static void @@ -237,7 +242,7 @@ register_directory_callback (MsdSoundManager *manager, if (m != NULL) { g_signal_connect (m, "changed", G_CALLBACK (file_monitor_changed_cb), manager); - manager->priv->monitors = g_list_prepend (manager->priv->monitors, m); + manager->monitors = g_list_prepend (manager->monitors, m); succ = TRUE; } @@ -265,9 +270,9 @@ msd_sound_manager_start (MsdSoundManager *manager, #ifdef HAVE_PULSE /* We listen for change of the selected theme ... */ - manager->priv->settings = g_settings_new (MATE_SOUND_SCHEMA); + manager->settings = g_settings_new (MATE_SOUND_SCHEMA); - g_signal_connect (manager->priv->settings, "changed", G_CALLBACK (gsettings_notify_cb), manager); + g_signal_connect (manager->settings, "changed", G_CALLBACK (gsettings_notify_cb), manager); /* ... and we listen to changes of the theme base directories * in $HOME ...*/ @@ -307,20 +312,20 @@ msd_sound_manager_stop (MsdSoundManager *manager) g_debug ("Stopping sound manager"); #ifdef HAVE_PULSE - if (manager->priv->settings != NULL) { - g_object_unref (manager->priv->settings); - manager->priv->settings = NULL; + if (manager->settings != NULL) { + g_object_unref (manager->settings); + manager->settings = NULL; } - if (manager->priv->timeout) { - g_source_remove (manager->priv->timeout); - manager->priv->timeout = 0; + if (manager->timeout) { + g_source_remove (manager->timeout); + manager->timeout = 0; } - while (manager->priv->monitors) { - g_file_monitor_cancel (G_FILE_MONITOR (manager->priv->monitors->data)); - g_object_unref (manager->priv->monitors->data); - manager->priv->monitors = g_list_delete_link (manager->priv->monitors, manager->priv->monitors); + while (manager->monitors) { + g_file_monitor_cancel (G_FILE_MONITOR (manager->monitors->data)); + g_object_unref (manager->monitors->data); + manager->monitors = g_list_delete_link (manager->monitors, manager->monitors); } #endif } @@ -349,21 +354,14 @@ msd_sound_manager_class_init (MsdSoundManagerClass *klass) static void msd_sound_manager_init (MsdSoundManager *manager) { - manager->priv = msd_sound_manager_get_instance_private (manager); } static void msd_sound_manager_finalize (GObject *object) { - MsdSoundManager *sound_manager; - g_return_if_fail (object != NULL); g_return_if_fail (MSD_IS_SOUND_MANAGER (object)); - sound_manager = MSD_SOUND_MANAGER (object); - - g_return_if_fail (sound_manager->priv); - G_OBJECT_CLASS (msd_sound_manager_parent_class)->finalize (object); } diff --git a/plugins/sound/msd-sound-manager.h b/plugins/sound/msd-sound-manager.h index 8f73bb4..a047343 100644 --- a/plugins/sound/msd-sound-manager.h +++ b/plugins/sound/msd-sound-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Lennart Poettering <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -18,44 +19,26 @@ * */ -#ifndef __MSD_SOUND_MANAGER_H -#define __MSD_SOUND_MANAGER_H +#ifndef MSD_SOUND_MANAGER_H +#define MSD_SOUND_MANAGER_H #include <glib.h> #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS -#define MSD_TYPE_SOUND_MANAGER (msd_sound_manager_get_type ()) -#define MSD_SOUND_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_SOUND_MANAGER, MsdSoundManager)) -#define MSD_SOUND_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), MSD_TYPE_SOUND_MANAGER, MsdSoundManagerClass)) -#define MSD_IS_SOUND_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MSD_TYPE_SOUND_MANAGER)) -#define MSD_IS_SOUND_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_SOUND_MANAGER)) -#define MSD_SOUND_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_SOUND_MANAGER, MsdSoundManagerClass)) +#define MSD_TYPE_SOUND_MANAGER (msd_sound_manager_get_type ()) -typedef struct MsdSoundManagerPrivate MsdSoundManagerPrivate; +G_DECLARE_FINAL_TYPE (MsdSoundManager, msd_sound_manager, + MSD, SOUND_MANAGER, GObject) -typedef struct -{ - GObject parent; - MsdSoundManagerPrivate *priv; -} MsdSoundManager; +MsdSoundManager * msd_sound_manager_new (void); -typedef struct -{ - GObjectClass parent_class; -} MsdSoundManagerClass; +gboolean msd_sound_manager_start (MsdSoundManager *manager, + GError **error); -GType msd_sound_manager_get_type (void) G_GNUC_CONST; +void msd_sound_manager_stop (MsdSoundManager *manager); -MsdSoundManager *msd_sound_manager_new (void); -gboolean msd_sound_manager_start (MsdSoundManager *manager, GError **error); -void msd_sound_manager_stop (MsdSoundManager *manager); +G_END_DECLS -#ifdef __cplusplus -} -#endif - -#endif /* __MSD_SOUND_MANAGER_H */ +#endif /* MSD_SOUND_MANAGER_H */ diff --git a/plugins/sound/msd-sound-plugin.c b/plugins/sound/msd-sound-plugin.c index 998c6ca..2c1411a 100644 --- a/plugins/sound/msd-sound-plugin.c +++ b/plugins/sound/msd-sound-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Lennart Poettering <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/sound/msd-sound-plugin.h b/plugins/sound/msd-sound-plugin.h index e201fbb..b65e446 100644 --- a/plugins/sound/msd-sound-plugin.h +++ b/plugins/sound/msd-sound-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Lennart Poettering <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/typing-break/msd-typing-break-manager.c b/plugins/typing-break/msd-typing-break-manager.c index cff6187..8663b24 100644 --- a/plugins/typing-break/msd-typing-break-manager.c +++ b/plugins/typing-break/msd-typing-break-manager.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -43,29 +44,31 @@ #define MATE_BREAK_SCHEMA "org.mate.typing-break" -struct MsdTypingBreakManagerPrivate +struct _MsdTypingBreakManager { - GPid typing_monitor_pid; - guint typing_monitor_idle_id; - guint child_watch_id; - guint setup_id; + GObject parent; + + GPid typing_monitor_pid; + guint typing_monitor_idle_id; + guint child_watch_id; + guint setup_id; GSettings *settings; }; static void msd_typing_break_manager_finalize (GObject *object); -G_DEFINE_TYPE_WITH_PRIVATE (MsdTypingBreakManager, msd_typing_break_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (MsdTypingBreakManager, msd_typing_break_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; static gboolean typing_break_timeout (MsdTypingBreakManager *manager) { - if (manager->priv->typing_monitor_pid > 0) { - kill (manager->priv->typing_monitor_pid, SIGKILL); + if (manager->typing_monitor_pid > 0) { + kill (manager->typing_monitor_pid, SIGKILL); } - manager->priv->typing_monitor_idle_id = 0; + manager->typing_monitor_idle_id = 0; return FALSE; } @@ -75,8 +78,8 @@ child_watch (GPid pid, int status, MsdTypingBreakManager *manager) { - if (pid == manager->priv->typing_monitor_pid) { - manager->priv->typing_monitor_pid = 0; + if (pid == manager->typing_monitor_pid) { + manager->typing_monitor_pid = 0; g_spawn_close_pid (pid); } } @@ -88,18 +91,18 @@ setup_typing_break (MsdTypingBreakManager *manager, mate_settings_profile_start (NULL); if (! enabled) { - if (manager->priv->typing_monitor_pid != 0) { - manager->priv->typing_monitor_idle_id = g_timeout_add_seconds (3, (GSourceFunc) typing_break_timeout, manager); + if (manager->typing_monitor_pid != 0) { + manager->typing_monitor_idle_id = g_timeout_add_seconds (3, (GSourceFunc) typing_break_timeout, manager); } return; } - if (manager->priv->typing_monitor_idle_id != 0) { - g_source_remove (manager->priv->typing_monitor_idle_id); - manager->priv->typing_monitor_idle_id = 0; + if (manager->typing_monitor_idle_id != 0) { + g_source_remove (manager->typing_monitor_idle_id); + manager->typing_monitor_idle_id = 0; } - if (manager->priv->typing_monitor_pid == 0) { + if (manager->typing_monitor_pid == 0) { GError *error; char *argv[] = { "mate-typing-monitor", "-n", NULL }; gboolean res; @@ -114,19 +117,19 @@ setup_typing_break (MsdTypingBreakManager *manager, | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, - &manager->priv->typing_monitor_pid, + &manager->typing_monitor_pid, &error); if (! res) { /* FIXME: put up a warning */ g_warning ("failed: %s\n", error->message); g_error_free (error); - manager->priv->typing_monitor_pid = 0; + manager->typing_monitor_pid = 0; return; } - manager->priv->child_watch_id = g_child_watch_add (manager->priv->typing_monitor_pid, - (GChildWatchFunc)child_watch, - manager); + manager->child_watch_id = g_child_watch_add (manager->typing_monitor_pid, + (GChildWatchFunc)child_watch, + manager); } mate_settings_profile_end (NULL); @@ -144,7 +147,7 @@ static gboolean really_setup_typing_break (MsdTypingBreakManager *manager) { setup_typing_break (manager, TRUE); - manager->priv->setup_id = 0; + manager->setup_id = 0; return FALSE; } @@ -157,17 +160,17 @@ msd_typing_break_manager_start (MsdTypingBreakManager *manager, g_debug ("Starting typing_break manager"); mate_settings_profile_start (NULL); - manager->priv->settings = g_settings_new (MATE_BREAK_SCHEMA); + manager->settings = g_settings_new (MATE_BREAK_SCHEMA); - g_signal_connect (manager->priv->settings, + g_signal_connect (manager->settings, "changed::enabled", G_CALLBACK (typing_break_enabled_callback), manager); - enabled = g_settings_get_boolean (manager->priv->settings, "enabled"); + enabled = g_settings_get_boolean (manager->settings, "enabled"); if (enabled) { - manager->priv->setup_id = + manager->setup_id = g_timeout_add_seconds (3, (GSourceFunc) really_setup_typing_break, manager); @@ -181,33 +184,31 @@ msd_typing_break_manager_start (MsdTypingBreakManager *manager, void msd_typing_break_manager_stop (MsdTypingBreakManager *manager) { - MsdTypingBreakManagerPrivate *p = manager->priv; - g_debug ("Stopping typing_break manager"); - if (p->setup_id != 0) { - g_source_remove (p->setup_id); - p->setup_id = 0; + if (manager->setup_id != 0) { + g_source_remove (manager->setup_id); + manager->setup_id = 0; } - if (p->child_watch_id != 0) { - g_source_remove (p->child_watch_id); - p->child_watch_id = 0; + if (manager->child_watch_id != 0) { + g_source_remove (manager->child_watch_id); + manager->child_watch_id = 0; } - if (p->typing_monitor_idle_id != 0) { - g_source_remove (p->typing_monitor_idle_id); - p->typing_monitor_idle_id = 0; + if (manager->typing_monitor_idle_id != 0) { + g_source_remove (manager->typing_monitor_idle_id); + manager->typing_monitor_idle_id = 0; } - if (p->typing_monitor_pid > 0) { - kill (p->typing_monitor_pid, SIGKILL); - g_spawn_close_pid (p->typing_monitor_pid); - p->typing_monitor_pid = 0; + if (manager->typing_monitor_pid > 0) { + kill (manager->typing_monitor_pid, SIGKILL); + g_spawn_close_pid (manager->typing_monitor_pid); + manager->typing_monitor_pid = 0; } - if (p->settings != NULL) { - g_object_unref (p->settings); + if (manager->settings != NULL) { + g_object_unref (manager->settings); } } @@ -222,22 +223,14 @@ msd_typing_break_manager_class_init (MsdTypingBreakManagerClass *klass) static void msd_typing_break_manager_init (MsdTypingBreakManager *manager) { - manager->priv = msd_typing_break_manager_get_instance_private (manager); - } static void msd_typing_break_manager_finalize (GObject *object) { - MsdTypingBreakManager *typing_break_manager; - g_return_if_fail (object != NULL); g_return_if_fail (MSD_IS_TYPING_BREAK_MANAGER (object)); - typing_break_manager = MSD_TYPING_BREAK_MANAGER (object); - - g_return_if_fail (typing_break_manager->priv != NULL); - G_OBJECT_CLASS (msd_typing_break_manager_parent_class)->finalize (object); } diff --git a/plugins/typing-break/msd-typing-break-manager.h b/plugins/typing-break/msd-typing-break-manager.h index 9204a96..bf7aaf0 100644 --- a/plugins/typing-break/msd-typing-break-manager.h +++ b/plugins/typing-break/msd-typing-break-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -18,44 +19,23 @@ * */ -#ifndef __MSD_TYPING_BREAK_MANAGER_H -#define __MSD_TYPING_BREAK_MANAGER_H +#ifndef MSD_TYPING_BREAK_MANAGER_H +#define MSD_TYPING_BREAK_MANAGER_H #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS -#define MSD_TYPE_TYPING_BREAK_MANAGER (msd_typing_break_manager_get_type ()) -#define MSD_TYPING_BREAK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_TYPING_BREAK_MANAGER, MsdTypingBreakManager)) -#define MSD_TYPING_BREAK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MSD_TYPE_TYPING_BREAK_MANAGER, MsdTypingBreakManagerClass)) -#define MSD_IS_TYPING_BREAK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MSD_TYPE_TYPING_BREAK_MANAGER)) -#define MSD_IS_TYPING_BREAK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_TYPING_BREAK_MANAGER)) -#define MSD_TYPING_BREAK_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_TYPING_BREAK_MANAGER, MsdTypingBreakManagerClass)) +#define MSD_TYPE_TYPING_BREAK_MANAGER (msd_typing_break_manager_get_type ()) -typedef struct MsdTypingBreakManagerPrivate MsdTypingBreakManagerPrivate; - -typedef struct -{ - GObject parent; - MsdTypingBreakManagerPrivate *priv; -} MsdTypingBreakManager; - -typedef struct -{ - GObjectClass parent_class; -} MsdTypingBreakManagerClass; - -GType msd_typing_break_manager_get_type (void); +G_DECLARE_FINAL_TYPE (MsdTypingBreakManager, msd_typing_break_manager, + MSD, TYPING_BREAK_MANAGER, GObject) MsdTypingBreakManager * msd_typing_break_manager_new (void); gboolean msd_typing_break_manager_start (MsdTypingBreakManager *manager, GError **error); void msd_typing_break_manager_stop (MsdTypingBreakManager *manager); -#ifdef __cplusplus -} -#endif +G_END_DECLS -#endif /* __MSD_TYPING_BREAK_MANAGER_H */ +#endif /* MSD_TYPING_BREAK_MANAGER_H */ diff --git a/plugins/typing-break/msd-typing-break-plugin.c b/plugins/typing-break/msd-typing-break-plugin.c index c47a111..5b9233c 100644 --- a/plugins/typing-break/msd-typing-break-plugin.c +++ b/plugins/typing-break/msd-typing-break-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/typing-break/msd-typing-break-plugin.h b/plugins/typing-break/msd-typing-break-plugin.h index 33cd5e2..198d18d 100644 --- a/plugins/typing-break/msd-typing-break-plugin.h +++ b/plugins/typing-break/msd-typing-break-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xrandr/Makefile.am b/plugins/xrandr/Makefile.am index f0a8815..ccf6f69 100644 --- a/plugins/xrandr/Makefile.am +++ b/plugins/xrandr/Makefile.am @@ -1,8 +1,6 @@ icondir = $(datadir)/icons/hicolor context = apps -BUILT_SOURCES = \ - msd-xrandr-manager-glue.h ICON_FILES = \ msd-xrandr-16.png \ @@ -46,13 +44,8 @@ uninstall-local: plugin_LTLIBRARIES = \ libxrandr.la -msd-xrandr-manager-glue.h: msd-xrandr-manager.xml Makefile - $(AM_V_GEN) dbus-binding-tool --prefix=msd_xrandr_manager --mode=glib-server $< > xgen-$(@F) \ - && ( cmp -s xgen-$(@F) $@ || cp xgen-$(@F) $@ ) \ - && rm -f xgen-$(@F) libxrandr_la_SOURCES = \ - $(BUILT_SOURCES) \ msd-xrandr-plugin.h \ msd-xrandr-plugin.c \ msd-xrandr-manager.h \ @@ -84,8 +77,8 @@ plugin_in_files = \ plugin_DATA = $(plugin_in_files:.mate-settings-plugin.desktop.in=.mate-settings-plugin) -EXTRA_DIST = $(plugin_in_files) $(ICON_FILES) msd-xrandr-manager.xml -CLEANFILES = $(plugin_DATA) $(BUILT_SOURCES) +EXTRA_DIST = $(plugin_in_files) $(ICON_FILES) +CLEANFILES = $(plugin_DATA) DISTCLEANFILES = $(plugin_DATA) $(plugin_DATA): $(plugin_in_files) diff --git a/plugins/xrandr/msd-xrandr-manager.c b/plugins/xrandr/msd-xrandr-manager.c index 0e157a8..78e538f 100644 --- a/plugins/xrandr/msd-xrandr-manager.c +++ b/plugins/xrandr/msd-xrandr-manager.c @@ -2,6 +2,7 @@ * * Copyright (C) 2007 William Jon McCann <[email protected]> * Copyright (C) 2007, 2008 Red Hat, Inc + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -38,7 +39,6 @@ #include <gdk/gdkx.h> #include <gtk/gtk.h> #include <gio/gio.h> -#include <dbus/dbus-glib.h> #define MATE_DESKTOP_USE_UNSTABLE_API #include <libmate-desktop/mate-rr-config.h> @@ -76,12 +76,30 @@ #define MSD_DBUS_PATH "/org/mate/SettingsDaemon" #define MSD_DBUS_NAME "org.mate.SettingsDaemon" -#define MSD_XRANDR_DBUS_PATH MSD_DBUS_PATH "/XRANDR" #define MSD_XRANDR_DBUS_NAME MSD_DBUS_NAME ".XRANDR" +#define MSD_XRANDR_DBUS_PATH MSD_DBUS_PATH "/XRANDR" + +static const gchar introspection_xml[] = +"<node>" +" <interface name='org.mate.SettingsDaemon.XRANDR'>" +" <method name='ApplyConfiguration'>" +" </method>" +" </interface>" +"" +" <interface name='org.mate.SettingsDaemon.XRANDR_2'>" +" <method name='ApplyConfiguration'>" +" <arg name='parent_window_id' type='x' direction='in'/>" +" <arg name='timestamp' type='x' direction='in'/>" +" </method>" +" </interface>" +"</node>"; struct MsdXrandrManagerPrivate { - DBusGConnection *dbus_connection; + GDBusConnection *connection; + GDBusNodeInfo *introspection_data; + GCancellable *bus_cancellable; + guint owner_id; /* Key code of the XF86Display key (Fn-F7 on Thinkpads, Fn-F4 on HP machines, etc.) */ guint switch_video_mode_keycode; @@ -627,9 +645,6 @@ msd_xrandr_manager_2_apply_configuration (MsdXrandrManager *manager, return result; } -/* We include this after the definition of msd_xrandr_manager_apply_configuration() so the prototype will already exist */ -#include "msd-xrandr-manager-glue.h" - static gboolean is_laptop (MateRRScreen *screen, MateRROutputInfo *output) { @@ -785,7 +800,7 @@ find_best_mode (MateRROutput *output) MateRRMode *preferred; MateRRMode **modes; int best_size; - int best_width, best_height, best_rate; + int best_rate; int i; MateRRMode *best_mode; @@ -797,7 +812,7 @@ find_best_mode (MateRROutput *output) if (!modes) return NULL; - best_size = best_width = best_height = best_rate = 0; + best_size = best_rate = 0; best_mode = NULL; for (i = 0; modes[i] != NULL; i++) { @@ -812,8 +827,6 @@ find_best_mode (MateRROutput *output) if (size > best_size) { best_size = size; - best_width = w; - best_height = h; best_rate = r; best_mode = modes[i]; } else if (size == best_size) { @@ -1007,7 +1020,6 @@ sanitize (MsdXrandrManager *manager, GPtrArray *array) } } - /* Remove configurations that are duplicates of * configurations earlier in the cycle */ @@ -2050,11 +2062,10 @@ mirror_outputs_cb(GtkCheckMenuItem *item, gpointer data) struct MsdXrandrManagerPrivate *priv = manager->priv; MateRRScreen *screen = priv->rw_screen; - if (gtk_check_menu_item_get_active(item)){ - + if (gtk_check_menu_item_get_active (item)) { MateRRConfig *config; - config = make_clone_setup (screen); - if (!config || config == NULL){ + + if ((config = make_clone_setup (screen)) == NULL) { error_message (manager, _("Mirroring outputs not supported"), NULL, NULL); } @@ -2243,7 +2254,7 @@ add_menu_items_for_clone (MsdXrandrManager *manager) GtkWidget *item; gulong activate_id; - item = gtk_check_menu_item_new_with_label(_("Same output all monitors")); + item = gtk_check_menu_item_new_with_label(_("Same output on all monitors")); gtk_widget_set_tooltip_text(item, _("Mirror same output to all monitors and turn them on")); gtk_widget_show_all (item); gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), item); @@ -2656,11 +2667,18 @@ msd_xrandr_manager_stop (MsdXrandrManager *manager) manager->priv->rw_screen = NULL; } - if (manager->priv->dbus_connection != NULL) { - dbus_g_connection_unref (manager->priv->dbus_connection); - manager->priv->dbus_connection = NULL; + if (manager->priv->owner_id > 0) { + g_bus_unown_name (manager->priv->owner_id); + manager->priv->owner_id = 0; + } + + if (manager->priv->connection != NULL) { + g_object_unref (manager->priv->connection); + manager->priv->connection = NULL; } + + g_clear_pointer (&manager->priv->introspection_data, g_dbus_node_info_unref); status_icon_stop (manager); log_open (); @@ -2674,8 +2692,6 @@ msd_xrandr_manager_class_init (MsdXrandrManagerClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = msd_xrandr_manager_finalize; - - dbus_g_object_type_install_info (MSD_TYPE_XRANDR_MANAGER, &dbus_glib_msd_xrandr_manager_object_info); } static guint @@ -2717,24 +2733,114 @@ msd_xrandr_manager_finalize (GObject *object) G_OBJECT_CLASS (msd_xrandr_manager_parent_class)->finalize (object); } -static gboolean -register_manager_dbus (MsdXrandrManager *manager) +static void +handle_method_call (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) { - GError *error = NULL; + MsdXrandrManager *manager = (MsdXrandrManager *) user_data; + g_autoptr (GError) error = NULL; - manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (manager->priv->dbus_connection == NULL) { - if (error != NULL) { - g_warning ("Error getting session bus: %s", error->message); - g_error_free (error); - } - return FALSE; + g_debug ("Calling method '%s' for xrandr", method_name); + + if (g_strcmp0 (method_name, "ApplyConfiguration") == 0) { + msd_xrandr_manager_apply_configuration(manager, &error); + if (error != NULL) + g_dbus_method_invocation_return_gerror (invocation, error); + else + g_dbus_method_invocation_return_value (invocation, NULL); } +} - /* Hmm, should we do this in msd_xrandr_manager_start()? */ - dbus_g_connection_register_g_object (manager->priv->dbus_connection, MSD_XRANDR_DBUS_PATH, G_OBJECT (manager)); +static void +handle_method_call2 (GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + MsdXrandrManager *manager = (MsdXrandrManager *) user_data; + g_autoptr (GError) error = NULL; - return TRUE; + g_debug ("Calling method '%s' for xrandr", method_name); + + if (g_strcmp0 (method_name, "ApplyConfiguration") == 0) { + gint64 parent_window_id; + gint64 timestamp; + g_variant_get (parameters, "(xx)", &parent_window_id, ×tamp); + msd_xrandr_manager_2_apply_configuration (manager, parent_window_id, timestamp, &error); + if (error != NULL) + g_dbus_method_invocation_return_gerror (invocation, error); + else + g_dbus_method_invocation_return_value (invocation, NULL); + } +} + +static const GDBusInterfaceVTable interface_vtable = +{ + .method_call = handle_method_call, +}; + +static const GDBusInterfaceVTable interface_vtable2 = +{ + .method_call = handle_method_call2, +}; + +static void +on_bus_gotten (GObject *source_object, + GAsyncResult *res, + MsdXrandrManager *manager) +{ + GDBusConnection *connection; + GError *error = NULL; + + connection = g_bus_get_finish (res, &error); + if (connection == NULL) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning ("Could not get session bus: %s", error->message); + g_error_free (error); + return; + } + manager->priv->connection = connection; + + g_dbus_connection_register_object (connection, + MSD_XRANDR_DBUS_PATH, + manager->priv->introspection_data->interfaces[0], + &interface_vtable, + manager, + NULL, + NULL); + g_dbus_connection_register_object (connection, + MSD_XRANDR_DBUS_PATH, + manager->priv->introspection_data->interfaces[1], + &interface_vtable2, + manager, + NULL, + NULL); + + manager->priv->owner_id = g_bus_own_name_on_connection (manager->priv->connection, + MSD_DBUS_NAME, + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, + NULL, NULL, NULL, NULL); +} + +static void +register_manager_dbus (MsdXrandrManager *manager) +{ + manager->priv->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); + manager->priv->bus_cancellable = g_cancellable_new (); + g_bus_get (G_BUS_TYPE_SESSION, + manager->priv->bus_cancellable, + (GAsyncReadyCallback) on_bus_gotten, + manager); } MsdXrandrManager * @@ -2747,10 +2853,7 @@ msd_xrandr_manager_new (void) g_object_add_weak_pointer (manager_object, (gpointer *) &manager_object); - if (!register_manager_dbus (manager_object)) { - g_object_unref (manager_object); - return NULL; - } + register_manager_dbus (manager_object); } return MSD_XRANDR_MANAGER (manager_object); diff --git a/plugins/xrandr/msd-xrandr-manager.h b/plugins/xrandr/msd-xrandr-manager.h index 8d8f12f..70aac7a 100644 --- a/plugins/xrandr/msd-xrandr-manager.h +++ b/plugins/xrandr/msd-xrandr-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -23,9 +24,7 @@ #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define MSD_TYPE_XRANDR_MANAGER (msd_xrandr_manager_get_type ()) #define MSD_XRANDR_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_XRANDR_MANAGER, MsdXrandrManager)) @@ -54,8 +53,6 @@ gboolean msd_xrandr_manager_start (MsdXrandrManager GError **error); void msd_xrandr_manager_stop (MsdXrandrManager *manager); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __MSD_XRANDR_MANAGER_H */ diff --git a/plugins/xrandr/msd-xrandr-manager.xml b/plugins/xrandr/msd-xrandr-manager.xml deleted file mode 100644 index c82a594..0000000 --- a/plugins/xrandr/msd-xrandr-manager.xml +++ /dev/null @@ -1,23 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node> - <interface name="org.mate.SettingsDaemon.XRANDR"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="msd_xrandr_manager"/> - <method name="ApplyConfiguration"> - <!-- This method is implemented, but deprecated in favor of the - same method in the XRANDR-2 interface defined below. --> - </method> - </interface> - - <interface name="org.mate.SettingsDaemon.XRANDR_2"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="msd_xrandr_manager_2"/> - <method name="ApplyConfiguration"> - <!-- transient-parent window for the confirmation dialog; use 0 - for no parent --> - <arg name="parent_window_id" type="x" direction="in"/> - - <!-- Timestamp used to present the confirmation dialog and (in - the future) for the RANDR calls themselves --> - <arg name="timestamp" type="x" direction="in"/> - </method> - </interface> -</node> diff --git a/plugins/xrandr/msd-xrandr-plugin.c b/plugins/xrandr/msd-xrandr-plugin.c index 0175138..79ae93d 100644 --- a/plugins/xrandr/msd-xrandr-plugin.c +++ b/plugins/xrandr/msd-xrandr-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xrandr/msd-xrandr-plugin.h b/plugins/xrandr/msd-xrandr-plugin.h index 9a80ead..60eb7cf 100644 --- a/plugins/xrandr/msd-xrandr-plugin.h +++ b/plugins/xrandr/msd-xrandr-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xrdb/msd-xrdb-manager.c b/plugins/xrdb/msd-xrdb-manager.c index 7daefb9..f4c35a7 100644 --- a/plugins/xrdb/msd-xrdb-manager.c +++ b/plugins/xrdb/msd-xrdb-manager.c @@ -2,6 +2,7 @@ * * Copyright (C) 2003 Ross Burton <[email protected]> * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -46,7 +47,6 @@ #define USER_X_RESOURCES ".Xresources" #define USER_X_DEFAULTS ".Xdefaults" - struct MsdXrdbManagerPrivate { GtkWidget* widget; }; @@ -69,9 +69,9 @@ append_color_define (GString *string, g_string_append_printf (string, "#define %s #%2.2hx%2.2hx%2.2hx\n", name, - color->red>>8, - color->green>>8, - color->blue>>8); + (unsigned short) (color->red>>8), + (unsigned short) (color->green>>8), + (unsigned short) (color->blue>>8)); } static GdkColor* @@ -236,8 +236,7 @@ scan_for_files (MsdXrdbManager *manager, if (local_error != NULL) { g_propagate_error (error, local_error); - g_slist_foreach (system_list, (GFunc)g_free, NULL); - g_slist_free (system_list); + g_slist_free_full (system_list, g_free); g_free (user_ad); return NULL; } @@ -447,8 +446,7 @@ apply_settings (MsdXrdbManager *manager, } } - g_slist_foreach (list, (GFunc)g_free, NULL); - g_slist_free (list); + g_slist_free_full (list, g_free); error = NULL; append_xresource_file (USER_X_RESOURCES, string, &error); diff --git a/plugins/xrdb/msd-xrdb-manager.h b/plugins/xrdb/msd-xrdb-manager.h index 02e6dbf..1272b35 100644 --- a/plugins/xrdb/msd-xrdb-manager.h +++ b/plugins/xrdb/msd-xrdb-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xrdb/msd-xrdb-plugin.c b/plugins/xrdb/msd-xrdb-plugin.c index 69a3660..ffb7148 100644 --- a/plugins/xrdb/msd-xrdb-plugin.c +++ b/plugins/xrdb/msd-xrdb-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xrdb/msd-xrdb-plugin.h b/plugins/xrdb/msd-xrdb-plugin.h index d21621a..631adc1 100644 --- a/plugins/xrdb/msd-xrdb-plugin.h +++ b/plugins/xrdb/msd-xrdb-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xsettings/fontconfig-monitor.c b/plugins/xsettings/fontconfig-monitor.c index ed4a5a9..a87fc0b 100644 --- a/plugins/xsettings/fontconfig-monitor.c +++ b/plugins/xsettings/fontconfig-monitor.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -73,7 +74,6 @@ monitor_files (GPtrArray *monitors, FcStrListDone (list); } - struct _fontconfig_monitor_handle { GPtrArray *monitors; @@ -143,7 +143,6 @@ stuff_changed (GFileMonitor *monitor G_GNUC_UNUSED, handle->timeout = g_timeout_add_seconds (TIMEOUT_SECONDS, update, data); } - fontconfig_monitor_handle_t * fontconfig_monitor_start (GFunc notify_callback, gpointer notify_data) diff --git a/plugins/xsettings/fontconfig-monitor.h b/plugins/xsettings/fontconfig-monitor.h index 22163e6..9afe3d3 100644 --- a/plugins/xsettings/fontconfig-monitor.h +++ b/plugins/xsettings/fontconfig-monitor.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2008 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xsettings/msd-xsettings-manager.c b/plugins/xsettings/msd-xsettings-manager.c index 33dd16d..c8199da 100644 --- a/plugins/xsettings/msd-xsettings-manager.c +++ b/plugins/xsettings/msd-xsettings-manager.c @@ -2,6 +2,7 @@ * * Copyright (C) 2007 Rodrigo Moya * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 @@ -75,12 +76,17 @@ #define DPI_HIGH_REASONABLE_VALUE 500 /* The minimum resolution at which we turn on a window-scale of 2 */ -#define HIDPI_LIMIT (DPI_FALLBACK * 2) +/* Set this to 90% of 2x DPI_FALLBACK, to catch QHD laptop screens */ +/* that are just below the 2x DPI_FALLBACK mark */ +#define HIDPI_LIMIT (DPI_FALLBACK * 2 * 90 / 100) /* The minimum screen height at which we turn on a window-scale of 2; * below this there just isn't enough vertical real estate for GNOME * apps to work, and it's better to just be tiny */ -#define HIDPI_MIN_HEIGHT 1500 +#define HIDPI_MIN_HEIGHT 1440 + +#define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE)) +#define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1)) typedef struct _TranslationEntry TranslationEntry; typedef void (* TranslationFunc) (MateXSettingsManager *manager, @@ -505,19 +511,19 @@ update_user_env_variable (const gchar *variable, } static gboolean -delayed_toggle_bg_draw (gboolean value) +delayed_toggle_bg_draw (gpointer value) { GSettings *settings; settings = g_settings_new ("org.mate.background"); - g_settings_set_boolean (settings, "show-desktop-icons", value); + g_settings_set_boolean (settings, "show-desktop-icons", GPOINTER_TO_BOOLEAN (value)); g_object_unref (settings); - return FALSE; + return G_SOURCE_REMOVE; } static void -scale_change_workarounds (MateXSettingsManager *manager, int new_scale) +scale_change_workarounds (MateXSettingsManager *manager, int new_scale, int unscaled_dpi) { if (manager->priv->window_scale == new_scale) return; @@ -531,8 +537,11 @@ scale_change_workarounds (MateXSettingsManager *manager, int new_scale) gsettings = g_hash_table_lookup (manager->priv->gsettings, INTERFACE_SCHEMA); /* If enabled, set env variables to properly scale QT applications */ if (g_settings_get_boolean (gsettings, SCALING_FACTOR_QT_KEY)) { - if (!update_user_env_variable ("QT_AUTO_SCREEN_SCALE_FACTOR", "0", &error)) { - g_warning ("There was a problem when setting QT_AUTO_SCREEN_SCALE_FACTOR=0: %s", error->message); + char dpibuf[G_ASCII_DTOSTR_BUF_SIZE]; + g_snprintf (dpibuf, sizeof (dpibuf), "%d", (int) (unscaled_dpi / 1024.0 + 0.5)); + + if (!update_user_env_variable ("QT_FONT_DPI", dpibuf, &error)) { + g_warning ("There was a problem when setting QT_FONT_DPI=%s: %s", dpibuf, error->message); g_clear_error (&error); } if (!update_user_env_variable ("QT_SCALE_FACTOR", new_scale == 2 ? "2" : "1", &error)) { @@ -574,8 +583,8 @@ scale_change_workarounds (MateXSettingsManager *manager, int new_scale) desktop_settings = g_settings_new ("org.mate.background"); if (g_settings_get_boolean (desktop_settings, "show-desktop-icons")) { /* Delay the toggle to allow enough time for the desktop to redraw */ - g_timeout_add_seconds (1, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) FALSE); - g_timeout_add_seconds (2, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) TRUE); + g_timeout_add_seconds (1, delayed_toggle_bg_draw, GBOOLEAN_TO_POINTER (FALSE)); + g_timeout_add_seconds (2, delayed_toggle_bg_draw, GBOOLEAN_TO_POINTER (TRUE)); } g_object_unref (desktop_settings); } @@ -607,7 +616,7 @@ xft_settings_set_xsettings (MateXSettingsManager *manager, } mate_settings_profile_end (NULL); - scale_change_workarounds (manager, settings->window_scale); + scale_change_workarounds (manager, settings->window_scale, settings->dpi); } static void @@ -657,8 +666,8 @@ xft_settings_set_xresources (MateXftSettings *settings) g_debug("xft_settings_set_xresources: orig res '%s'", add_string->str); - update_property (add_string, "Xft.dpi", - g_ascii_dtostr (dpibuf, sizeof (dpibuf), (double) settings->dpi / 1024.0)); + g_snprintf (dpibuf, sizeof (dpibuf), "%d", (int) (settings->scaled_dpi / 1024.0 + 0.5)); + update_property (add_string, "Xft.dpi", dpibuf); update_property (add_string, "Xft.antialias", settings->antialias ? "1" : "0"); update_property (add_string, "Xft.hinting", diff --git a/plugins/xsettings/msd-xsettings-manager.h b/plugins/xsettings/msd-xsettings-manager.h index 86eb32c..908982a 100644 --- a/plugins/xsettings/msd-xsettings-manager.h +++ b/plugins/xsettings/msd-xsettings-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xsettings/msd-xsettings-plugin.c b/plugins/xsettings/msd-xsettings-plugin.c index f8fede1..3a636dd 100644 --- a/plugins/xsettings/msd-xsettings-plugin.c +++ b/plugins/xsettings/msd-xsettings-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xsettings/msd-xsettings-plugin.h b/plugins/xsettings/msd-xsettings-plugin.h index 37d4e15..76df96a 100644 --- a/plugins/xsettings/msd-xsettings-plugin.h +++ b/plugins/xsettings/msd-xsettings-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * 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 diff --git a/plugins/xsettings/xsettings-common.c b/plugins/xsettings/xsettings-common.c index 8e3e04c..8e1b7e6 100644 --- a/plugins/xsettings/xsettings-common.c +++ b/plugins/xsettings/xsettings-common.c @@ -1,5 +1,6 @@ /* * Copyright © 2001 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that diff --git a/plugins/xsettings/xsettings-common.h b/plugins/xsettings/xsettings-common.h index caf0e59..2165b04 100644 --- a/plugins/xsettings/xsettings-common.h +++ b/plugins/xsettings/xsettings-common.h @@ -1,5 +1,6 @@ /* * Copyright © 2001 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c index 3d933d5..8bf4187 100644 --- a/plugins/xsettings/xsettings-manager.c +++ b/plugins/xsettings/xsettings-manager.c @@ -1,5 +1,6 @@ /* * Copyright © 2001 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -282,9 +283,9 @@ xsettings_manager_set_string (XSettingsManager *manager, } XSettingsResult -xsettings_manager_set_color (XSettingsManager *manager, - const char *name, - XSettingsColor *value) +xsettings_manager_set_color (XSettingsManager *manager, + const char *name, + const XSettingsColor *value) { XSettingsSetting setting; diff --git a/plugins/xsettings/xsettings-manager.h b/plugins/xsettings/xsettings-manager.h index 40681ae..55f674b 100644 --- a/plugins/xsettings/xsettings-manager.h +++ b/plugins/xsettings/xsettings-manager.h @@ -1,5 +1,6 @@ /* * Copyright © 2001 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -57,13 +58,11 @@ XSettingsResult xsettings_manager_set_int (XSettingsManager *manager, XSettingsResult xsettings_manager_set_string (XSettingsManager *manager, const char *name, const char *value); -XSettingsResult xsettings_manager_set_color (XSettingsManager *manager, - const char *name, - XSettingsColor *value); +XSettingsResult xsettings_manager_set_color (XSettingsManager *manager, + const char *name, + const XSettingsColor *value); XSettingsResult xsettings_manager_notify (XSettingsManager *manager); - - #ifdef __cplusplus } #endif /* __cplusplus */ |