diff options
Diffstat (limited to 'plugins')
140 files changed, 1338 insertions, 892 deletions
diff --git a/plugins/a11y-keyboard/Makefile.am b/plugins/a11y-keyboard/Makefile.am index 0ea0e4a..45078d7 100644 --- a/plugins/a11y-keyboard/Makefile.am +++ b/plugins/a11y-keyboard/Makefile.am @@ -66,6 +66,8 @@ liba11y_keyboard_la_LDFLAGS = \ liba11y_keyboard_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(LIBNOTIFY_LIBS) \ + $(X11_LIBS) \ + $(XINPUT_LIBS) \ $(NULL) if HAVE_LIBATSPI 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 fa8d0df..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 @@ -639,7 +640,6 @@ ax_slowkeys_warning_post_bubble (MsdA11yKeyboardManager *manager, #endif /* HAVE_LIBNOTIFY */ } - static void ax_slowkeys_warning_post_dialog (MsdA11yKeyboardManager *manager, gboolean enabled) @@ -1143,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/Makefile.am b/plugins/background/Makefile.am index ac32ceb..b2ab685 100644 --- a/plugins/background/Makefile.am +++ b/plugins/background/Makefile.am @@ -58,6 +58,7 @@ libbackground_la_LDFLAGS = \ libbackground_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(MATE_DESKTOP_LIBS) \ + $(X11_LIBS) \ $(NULL) plugin_in_files = \ diff --git a/plugins/background/msd-background-manager.c b/plugins/background/msd-background-manager.c index 0ac1615..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 @@ -414,10 +415,16 @@ queue_timeout (MsdBackgroundManager *manager) static void disconnect_session_manager_listener (MsdBackgroundManager* manager) { +#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 diff --git a/plugins/background/msd-background-manager.h b/plugins/background/msd-background-manager.h index c2fb7d0..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 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/Makefile.am b/plugins/clipboard/Makefile.am index d8baed9..414fff1 100644 --- a/plugins/clipboard/Makefile.am +++ b/plugins/clipboard/Makefile.am @@ -31,6 +31,8 @@ libclipboard_la_LDFLAGS = \ libclipboard_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ + $(X11_LIBS) \ + $(XINPUT_LIBS) \ $(NULL) plugin_in_files = \ 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 d99f04f..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 @@ -859,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 641c51c..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 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 d112ae9..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 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 14b67a1..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[]) { 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 a4596cf..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 @@ -44,6 +44,7 @@ struct _MsdHousekeepingManager { guint long_term_cb; guint short_term_cb; GSettings *settings; + gulong config_listener_id; }; G_DEFINE_TYPE (MsdHousekeepingManager, msd_housekeeping_manager, G_TYPE_OBJECT) @@ -63,7 +64,6 @@ typedef struct { glong size; } ThumbData; - static void thumb_data_free (gpointer data) { @@ -245,13 +245,6 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager, g_debug ("Starting housekeeping manager"); mate_settings_profile_start (NULL); - msd_ldsm_setup (FALSE); - - manager->settings = g_settings_new (THUMB_CACHE_SCHEMA); - - g_signal_connect (manager->settings, "changed", - G_CALLBACK (settings_changed_callback), manager); - /* Clean once, a few minutes after start-up */ do_cleanup_soon (manager); @@ -267,7 +260,23 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager, static void msd_housekeeping_manager_finalize (GObject *object) { - msd_housekeeping_manager_stop (MSD_HOUSEKEEPING_MANAGER (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); } @@ -293,11 +302,6 @@ msd_housekeeping_manager_stop (MsdHousekeepingManager *manager) do_cleanup (manager); } } - - g_object_unref (manager->settings); - manager->settings = NULL; - - msd_ldsm_clean (); } static void @@ -311,6 +315,12 @@ msd_housekeeping_manager_class_init (MsdHousekeepingManagerClass *klass) static void msd_housekeeping_manager_init (MsdHousekeepingManager *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 5d481cc..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 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 a0e118d..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 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..cc21f18 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,9 @@ libkeyboard_la_LDFLAGS = \ libkeyboard_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(LIBMATEKBDUI_LIBS) \ + $(MATE_DESKTOP_LIBS) \ + $(X11_LIBS) \ + $(XINPUT_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 8beadea..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) { 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 33fe4e5..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); } @@ -314,13 +316,11 @@ status_icon_popup_menu_cb (GtkStatusIcon *status_icon, 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); @@ -540,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)) ? @@ -582,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]); @@ -660,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; } 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 fe33351..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 @@ -616,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; @@ -722,7 +744,10 @@ 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) { @@ -1039,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) @@ -1047,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 @@ -1060,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); @@ -1079,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; @@ -1133,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) @@ -1401,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, @@ -1423,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); @@ -1465,6 +1595,8 @@ start_media_keys_idle_cb (MsdMediaKeysManager *manager) mate_settings_profile_end (NULL); + manager->priv->start_idle_id = 0; + return FALSE; } @@ -1501,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); @@ -1536,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); @@ -1597,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 @@ -1621,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 * @@ -1646,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 4fb821a..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 diff --git a/plugins/media-keys/msd-media-keys-window.h b/plugins/media-keys/msd-media-keys-window.h index d911e41..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 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 060e675..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 @@ -434,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)) @@ -575,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 4a496b4..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 diff --git a/plugins/sound/msd-sound-manager.h b/plugins/sound/msd-sound-manager.h index 22dd525..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 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 eb9946f..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 diff --git a/plugins/typing-break/msd-typing-break-manager.h b/plugins/typing-break/msd-typing-break-manager.h index b69b6e2..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 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..7316599 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 \ @@ -77,15 +70,17 @@ libxrandr_la_LDFLAGS = \ libxrandr_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(LIBNOTIFY_LIBS) \ - $(MATE_DESKTOP_LIBS) + $(MATE_DESKTOP_LIBS) \ + $(X11_LIBS) \ + $(NULL) plugin_in_files = \ xrandr.mate-settings-plugin.desktop.in 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 96e9455..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) { @@ -1005,7 +1020,6 @@ sanitize (MsdXrandrManager *manager, GPtrArray *array) } } - /* Remove configurations that are duplicates of * configurations earlier in the cycle */ @@ -2240,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); @@ -2653,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 (); @@ -2671,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 @@ -2714,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 * @@ -2744,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 f440992..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* 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/Makefile.am b/plugins/xsettings/Makefile.am index 6e8e50f..e81842f 100644 --- a/plugins/xsettings/Makefile.am +++ b/plugins/xsettings/Makefile.am @@ -38,6 +38,7 @@ libxsettings_la_LDFLAGS = \ libxsettings_la_LIBADD = \ $(SETTINGS_PLUGIN_LIBS) \ $(FONTCONFIG_LIBS) \ + $(X11_LIBS) \ $(NULL) plugin_in_files = \ 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 7e4f743..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,14 @@ #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)) @@ -520,7 +523,7 @@ delayed_toggle_bg_draw (gpointer value) } 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; @@ -534,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)) { @@ -610,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 @@ -660,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 */ |