2010-08-10 15:26:07 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Intel, Inc
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-08-10 15:26:07 +01:00
|
|
|
*
|
|
|
|
* Author: Thomas Wood <thomas.wood@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2011-02-10 20:30:57 +00:00
|
|
|
#include <string.h>
|
2012-05-22 11:34:20 -04:00
|
|
|
#include <glib.h>
|
2011-02-10 20:30:57 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2012-05-22 11:34:20 -04:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2011-02-17 20:59:55 +01:00
|
|
|
#include <gdesktop-enums.h>
|
2011-02-10 20:30:57 +00:00
|
|
|
|
2010-08-10 15:26:07 +01:00
|
|
|
#include "cc-background-panel.h"
|
|
|
|
|
2019-05-21 20:17:14 -03:00
|
|
|
#include "cc-background-chooser.h"
|
2011-02-10 12:29:29 +00:00
|
|
|
#include "cc-background-item.h"
|
2019-05-22 18:55:17 -03:00
|
|
|
#include "cc-background-preview.h"
|
2013-01-04 13:17:31 +01:00
|
|
|
#include "cc-background-resources.h"
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-10 20:30:57 +00:00
|
|
|
#define WP_PATH_ID "org.gnome.desktop.background"
|
2013-08-19 21:00:48 +02:00
|
|
|
#define WP_LOCK_PATH_ID "org.gnome.desktop.screensaver"
|
2011-03-09 13:33:08 +00:00
|
|
|
#define WP_URI_KEY "picture-uri"
|
2021-11-27 17:53:52 +05:00
|
|
|
#define WP_URI_DARK_KEY "picture-uri-dark"
|
2011-02-10 20:30:57 +00:00
|
|
|
#define WP_OPTIONS_KEY "picture-options"
|
|
|
|
#define WP_SHADING_KEY "color-shading-type"
|
|
|
|
#define WP_PCOLOR_KEY "primary-color"
|
|
|
|
#define WP_SCOLOR_KEY "secondary-color"
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2021-12-19 17:11:57 +05:00
|
|
|
#define INTERFACE_PATH_ID "org.gnome.desktop.interface"
|
|
|
|
#define INTERFACE_COLOR_SCHEME_KEY "color-scheme"
|
|
|
|
|
2017-09-25 14:16:09 -04:00
|
|
|
struct _CcBackgroundPanel
|
2010-08-10 15:26:07 +01:00
|
|
|
{
|
2017-09-25 14:16:09 -04:00
|
|
|
CcPanel parent_instance;
|
|
|
|
|
2012-05-22 11:34:20 -04:00
|
|
|
GDBusConnection *connection;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2010-10-14 13:01:31 +02:00
|
|
|
GSettings *settings;
|
2013-08-19 21:00:48 +02:00
|
|
|
GSettings *lock_settings;
|
2021-12-19 17:11:57 +05:00
|
|
|
GSettings *interface_settings;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2021-12-19 21:41:53 +05:00
|
|
|
GDBusProxy *proxy;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-10 20:30:57 +00:00
|
|
|
CcBackgroundItem *current_background;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2019-05-27 13:00:26 -03:00
|
|
|
CcBackgroundChooser *background_chooser;
|
2022-06-15 19:12:10 +00:00
|
|
|
CcBackgroundPreview *default_preview;
|
2021-12-19 17:11:57 +05:00
|
|
|
CcBackgroundPreview *dark_preview;
|
2022-06-15 19:12:10 +00:00
|
|
|
GtkToggleButton *default_toggle;
|
2021-12-19 17:11:57 +05:00
|
|
|
GtkToggleButton *dark_toggle;
|
2010-08-10 15:26:07 +01:00
|
|
|
};
|
|
|
|
|
2017-09-25 14:16:09 -04:00
|
|
|
CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel)
|
|
|
|
|
2024-02-15 12:27:46 +01:00
|
|
|
static void on_settings_changed (CcBackgroundPanel *self);
|
|
|
|
|
2021-12-19 17:11:57 +05:00
|
|
|
static void
|
|
|
|
load_custom_css (CcBackgroundPanel *self)
|
|
|
|
{
|
|
|
|
g_autoptr(GtkCssProvider) provider = NULL;
|
|
|
|
|
|
|
|
provider = gtk_css_provider_new ();
|
|
|
|
gtk_css_provider_load_from_resource (provider, "/org/gnome/control-center/background/preview.css");
|
|
|
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
|
|
|
GTK_STYLE_PROVIDER (provider),
|
|
|
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-06-15 19:12:10 +00:00
|
|
|
reload_color_scheme_toggles (CcBackgroundPanel *self)
|
2021-12-19 17:11:57 +05:00
|
|
|
{
|
|
|
|
GDesktopColorScheme scheme;
|
|
|
|
|
|
|
|
scheme = g_settings_get_enum (self->interface_settings, INTERFACE_COLOR_SCHEME_KEY);
|
|
|
|
|
|
|
|
if (scheme == G_DESKTOP_COLOR_SCHEME_DEFAULT)
|
|
|
|
{
|
2022-06-15 19:12:10 +00:00
|
|
|
gtk_toggle_button_set_active (self->default_toggle, TRUE);
|
2021-12-19 17:11:57 +05:00
|
|
|
}
|
|
|
|
else if (scheme == G_DESKTOP_COLOR_SCHEME_PREFER_DARK)
|
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (self->dark_toggle, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-15 19:12:10 +00:00
|
|
|
gtk_toggle_button_set_active (self->default_toggle, FALSE);
|
2021-12-19 17:11:57 +05:00
|
|
|
gtk_toggle_button_set_active (self->dark_toggle, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-19 21:41:53 +05:00
|
|
|
static void
|
|
|
|
transition_screen (CcBackgroundPanel *self)
|
|
|
|
{
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
if (!self->proxy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_dbus_proxy_call_sync (self->proxy,
|
|
|
|
"ScreenTransition",
|
|
|
|
NULL,
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
-1,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
g_warning ("Couldn't transition screen: %s", error->message);
|
|
|
|
}
|
|
|
|
|
2021-12-19 17:11:57 +05:00
|
|
|
static void
|
|
|
|
set_color_scheme (CcBackgroundPanel *self,
|
|
|
|
GDesktopColorScheme color_scheme)
|
|
|
|
{
|
2021-12-19 21:41:53 +05:00
|
|
|
GDesktopColorScheme scheme;
|
|
|
|
|
|
|
|
scheme = g_settings_get_enum (self->interface_settings,
|
|
|
|
INTERFACE_COLOR_SCHEME_KEY);
|
|
|
|
|
|
|
|
/* We have to check the equality manually to avoid starting an unnecessary
|
|
|
|
* screen transition */
|
|
|
|
if (color_scheme == scheme)
|
|
|
|
return;
|
|
|
|
|
|
|
|
transition_screen (self);
|
|
|
|
|
2021-12-19 17:11:57 +05:00
|
|
|
g_settings_set_enum (self->interface_settings,
|
|
|
|
INTERFACE_COLOR_SCHEME_KEY,
|
|
|
|
color_scheme);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Color schemes */
|
|
|
|
|
|
|
|
static void
|
2022-06-15 19:12:10 +00:00
|
|
|
on_color_scheme_toggle_active_cb (CcBackgroundPanel *self)
|
2021-12-19 17:11:57 +05:00
|
|
|
{
|
2022-06-15 19:12:10 +00:00
|
|
|
if (gtk_toggle_button_get_active (self->default_toggle))
|
2021-12-19 17:11:57 +05:00
|
|
|
set_color_scheme (self, G_DESKTOP_COLOR_SCHEME_DEFAULT);
|
|
|
|
else if (gtk_toggle_button_get_active (self->dark_toggle))
|
|
|
|
set_color_scheme (self, G_DESKTOP_COLOR_SCHEME_PREFER_DARK);
|
|
|
|
}
|
|
|
|
|
2021-12-19 21:41:53 +05:00
|
|
|
static void
|
|
|
|
got_transition_proxy_cb (GObject *source_object,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
CcBackgroundPanel *self = data;
|
|
|
|
|
|
|
|
self->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
|
|
|
|
|
|
|
if (self->proxy == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Error creating proxy: %s", error->message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-19 17:11:57 +05:00
|
|
|
/* Background */
|
|
|
|
|
2010-12-15 16:46:53 +00:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
update_preview (CcBackgroundPanel *self)
|
2010-12-15 16:46:53 +00:00
|
|
|
{
|
2013-08-19 21:00:48 +02:00
|
|
|
CcBackgroundItem *current_background;
|
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
current_background = self->current_background;
|
|
|
|
cc_background_preview_set_item (self->default_preview, current_background);
|
|
|
|
cc_background_preview_set_item (self->dark_preview, current_background);
|
2010-12-16 13:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-22 11:34:20 -04:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
reload_current_bg (CcBackgroundPanel *self)
|
2011-02-14 09:40:06 +00:00
|
|
|
{
|
2017-09-04 10:42:56 +12:00
|
|
|
CcBackgroundItem *configured;
|
2020-02-11 15:14:07 +01:00
|
|
|
GSettings *settings = NULL;
|
2017-09-04 10:42:56 +12:00
|
|
|
g_autofree gchar *uri = NULL;
|
2021-11-27 17:53:52 +05:00
|
|
|
g_autofree gchar *dark_uri = NULL;
|
2017-09-04 10:42:56 +12:00
|
|
|
g_autofree gchar *pcolor = NULL;
|
|
|
|
g_autofree gchar *scolor = NULL;
|
2012-05-22 11:34:20 -04:00
|
|
|
|
|
|
|
/* initalise the current background information from settings */
|
2023-05-31 15:24:04 +12:00
|
|
|
settings = self->settings;
|
2013-08-19 21:00:48 +02:00
|
|
|
uri = g_settings_get_string (settings, WP_URI_KEY);
|
2012-05-22 11:34:20 -04:00
|
|
|
if (uri && *uri == '\0')
|
2019-05-25 22:58:00 -03:00
|
|
|
g_clear_pointer (&uri, g_free);
|
|
|
|
|
2021-11-27 17:53:52 +05:00
|
|
|
|
2012-05-22 11:34:20 -04:00
|
|
|
configured = cc_background_item_new (uri);
|
|
|
|
|
2021-11-27 17:53:52 +05:00
|
|
|
dark_uri = g_settings_get_string (settings, WP_URI_DARK_KEY);
|
2013-08-19 21:00:48 +02:00
|
|
|
pcolor = g_settings_get_string (settings, WP_PCOLOR_KEY);
|
|
|
|
scolor = g_settings_get_string (settings, WP_SCOLOR_KEY);
|
2012-05-22 11:34:20 -04:00
|
|
|
g_object_set (G_OBJECT (configured),
|
|
|
|
"name", _("Current background"),
|
2021-11-27 17:53:52 +05:00
|
|
|
"uri-dark", dark_uri,
|
2013-08-19 21:00:48 +02:00
|
|
|
"placement", g_settings_get_enum (settings, WP_OPTIONS_KEY),
|
|
|
|
"shading", g_settings_get_enum (settings, WP_SHADING_KEY),
|
2012-05-22 11:34:20 -04:00
|
|
|
"primary-color", pcolor,
|
|
|
|
"secondary-color", scolor,
|
|
|
|
NULL);
|
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
g_clear_object (&self->current_background);
|
|
|
|
self->current_background = configured;
|
2013-08-19 21:00:48 +02:00
|
|
|
cc_background_item_load (configured, NULL);
|
2011-02-14 13:11:59 +00:00
|
|
|
|
2024-02-15 12:35:43 +01:00
|
|
|
cc_background_chooser_set_active_item (self->background_chooser, configured);
|
2011-02-14 13:11:59 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 15:19:56 -04:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
reset_settings_if_defaults (CcBackgroundPanel *self,
|
2023-04-19 15:19:56 -04:00
|
|
|
GSettings *settings,
|
|
|
|
gboolean check_dark)
|
|
|
|
{
|
|
|
|
gsize i;
|
|
|
|
const char *keys[] = {
|
|
|
|
WP_URI_KEY, /* this key needs to be first */
|
|
|
|
WP_URI_DARK_KEY,
|
|
|
|
WP_OPTIONS_KEY,
|
|
|
|
WP_SHADING_KEY,
|
|
|
|
WP_PCOLOR_KEY,
|
|
|
|
WP_SCOLOR_KEY,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; keys[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
g_autoptr (GVariant) default_value = NULL;
|
|
|
|
g_autoptr (GVariant) user_value = NULL;
|
|
|
|
gboolean setting_is_default;
|
|
|
|
|
|
|
|
if (!check_dark && g_str_equal (keys[i], WP_URI_DARK_KEY))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default_value = g_settings_get_default_value (settings, keys[i]);
|
|
|
|
user_value = g_settings_get_value (settings, keys[i]);
|
|
|
|
|
|
|
|
setting_is_default = g_variant_equal (default_value, user_value);
|
|
|
|
|
|
|
|
/* As a courtesy to distros that are a little lackadaisical about making sure
|
|
|
|
* schema defaults match the settings in the background item with the default
|
|
|
|
* picture, we only look at the URI to determine if we shouldn't clean out dconf.
|
|
|
|
*
|
|
|
|
* In otherwords, we still clean out the picture-uri key from dconf when a user
|
|
|
|
* selects the default background in control-center, even if after selecting it
|
|
|
|
* e.g., primary-color still mismatches with schema defaults.
|
|
|
|
*/
|
|
|
|
if (g_str_equal (keys[i], WP_URI_KEY) && !setting_is_default)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (setting_is_default)
|
|
|
|
g_settings_reset (settings, keys[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings_apply (settings);
|
|
|
|
}
|
|
|
|
|
2011-02-14 19:05:56 +00:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
set_background (CcBackgroundPanel *self,
|
2013-08-19 21:00:48 +02:00
|
|
|
GSettings *settings,
|
2021-11-27 17:53:52 +05:00
|
|
|
CcBackgroundItem *item,
|
|
|
|
gboolean set_dark)
|
2011-02-14 19:05:56 +00:00
|
|
|
{
|
2012-05-22 11:34:20 -04:00
|
|
|
GDesktopBackgroundStyle style;
|
2011-02-11 03:51:38 +00:00
|
|
|
CcBackgroundItemFlags flags;
|
2019-05-25 22:58:00 -03:00
|
|
|
g_autofree gchar *filename = NULL;
|
|
|
|
const char *uri;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-14 19:05:56 +00:00
|
|
|
if (item == NULL)
|
2010-08-10 15:26:07 +01:00
|
|
|
return;
|
|
|
|
|
2011-02-11 18:04:57 +00:00
|
|
|
uri = cc_background_item_get_uri (item);
|
2011-02-11 03:51:38 +00:00
|
|
|
flags = cc_background_item_get_flags (item);
|
2011-02-10 20:30:57 +00:00
|
|
|
|
2019-05-25 22:58:00 -03:00
|
|
|
g_settings_set_string (settings, WP_URI_KEY, uri);
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2021-11-27 17:53:52 +05:00
|
|
|
if (set_dark)
|
|
|
|
{
|
|
|
|
const char *uri_dark;
|
|
|
|
|
|
|
|
uri_dark = cc_background_item_get_uri_dark (item);
|
|
|
|
|
|
|
|
if (uri_dark && uri_dark[0])
|
|
|
|
g_settings_set_string (settings, WP_URI_DARK_KEY, uri_dark);
|
|
|
|
else
|
|
|
|
g_settings_set_string (settings, WP_URI_DARK_KEY, uri);
|
|
|
|
}
|
|
|
|
|
2011-02-14 09:40:06 +00:00
|
|
|
/* Also set the placement if we have a URI and the previous value was none */
|
2011-02-11 03:51:38 +00:00
|
|
|
if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT)
|
2011-02-14 09:40:06 +00:00
|
|
|
{
|
2013-08-19 21:00:48 +02:00
|
|
|
g_settings_set_enum (settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item));
|
2011-02-14 09:40:06 +00:00
|
|
|
}
|
|
|
|
else if (uri != NULL)
|
|
|
|
{
|
2013-08-19 21:00:48 +02:00
|
|
|
style = g_settings_get_enum (settings, WP_OPTIONS_KEY);
|
2011-02-14 09:40:06 +00:00
|
|
|
if (style == G_DESKTOP_BACKGROUND_STYLE_NONE)
|
2013-08-19 21:00:48 +02:00
|
|
|
g_settings_set_enum (settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item));
|
2011-02-14 09:40:06 +00:00
|
|
|
}
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-11 03:51:38 +00:00
|
|
|
if (flags & CC_BACKGROUND_ITEM_HAS_SHADING)
|
2013-08-19 21:00:48 +02:00
|
|
|
g_settings_set_enum (settings, WP_SHADING_KEY, cc_background_item_get_shading (item));
|
2011-02-11 03:51:38 +00:00
|
|
|
|
2013-08-19 21:00:48 +02:00
|
|
|
g_settings_set_string (settings, WP_PCOLOR_KEY, cc_background_item_get_pcolor (item));
|
|
|
|
g_settings_set_string (settings, WP_SCOLOR_KEY, cc_background_item_get_scolor (item));
|
2010-12-15 16:46:53 +00:00
|
|
|
|
2019-05-25 22:58:00 -03:00
|
|
|
/* Apply all changes */
|
|
|
|
g_settings_apply (settings);
|
2011-02-14 09:40:06 +00:00
|
|
|
|
2023-04-19 15:19:56 -04:00
|
|
|
/* Clean out dconf if the user went back to distro defaults */
|
2023-05-31 15:24:04 +12:00
|
|
|
reset_settings_if_defaults (self, settings, set_dark);
|
2010-08-10 15:26:07 +01:00
|
|
|
}
|
|
|
|
|
2011-10-03 15:48:23 -04:00
|
|
|
static void
|
2021-12-19 17:11:57 +05:00
|
|
|
on_chooser_background_chosen_cb (CcBackgroundPanel *self,
|
|
|
|
CcBackgroundItem *item)
|
2011-10-03 15:48:23 -04:00
|
|
|
{
|
2024-02-15 12:27:46 +01:00
|
|
|
g_signal_handlers_block_by_func (self->settings, on_settings_changed, self);
|
|
|
|
|
2021-11-27 17:53:52 +05:00
|
|
|
set_background (self, self->settings, item, TRUE);
|
|
|
|
set_background (self, self->lock_settings, item, FALSE);
|
2024-02-15 12:27:46 +01:00
|
|
|
|
|
|
|
on_settings_changed (self);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (self->settings, on_settings_changed, self);
|
2013-08-19 21:00:48 +02:00
|
|
|
}
|
|
|
|
|
2019-05-27 13:00:26 -03:00
|
|
|
static void
|
2019-11-20 14:41:30 +13:00
|
|
|
on_add_picture_button_clicked_cb (CcBackgroundPanel *self)
|
2019-05-27 13:00:26 -03:00
|
|
|
{
|
|
|
|
cc_background_chooser_select_file (self->background_chooser);
|
|
|
|
}
|
|
|
|
|
2019-05-21 13:48:46 -03:00
|
|
|
static const char *
|
|
|
|
cc_background_panel_get_help_uri (CcPanel *panel)
|
|
|
|
{
|
|
|
|
return "help:gnome-help/look-background";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_background_panel_dispose (GObject *object)
|
|
|
|
{
|
2023-05-31 15:24:04 +12:00
|
|
|
CcBackgroundPanel *self = CC_BACKGROUND_PANEL (object);
|
2019-05-21 13:48:46 -03:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
g_clear_object (&self->settings);
|
|
|
|
g_clear_object (&self->lock_settings);
|
|
|
|
g_clear_object (&self->interface_settings);
|
|
|
|
g_clear_object (&self->proxy);
|
2019-05-21 13:48:46 -03:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_background_panel_finalize (GObject *object)
|
|
|
|
{
|
2023-05-31 15:24:04 +12:00
|
|
|
CcBackgroundPanel *self = CC_BACKGROUND_PANEL (object);
|
2019-05-21 13:48:46 -03:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
g_clear_object (&self->current_background);
|
2019-05-21 13:48:46 -03:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_background_panel_class_init (CcBackgroundPanelClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
2019-05-21 20:17:14 -03:00
|
|
|
g_type_ensure (CC_TYPE_BACKGROUND_CHOOSER);
|
2019-05-22 18:55:17 -03:00
|
|
|
g_type_ensure (CC_TYPE_BACKGROUND_PREVIEW);
|
2019-05-21 20:17:14 -03:00
|
|
|
|
2019-05-21 13:48:46 -03:00
|
|
|
panel_class->get_help_uri = cc_background_panel_get_help_uri;
|
|
|
|
|
|
|
|
object_class->dispose = cc_background_panel_dispose;
|
|
|
|
object_class->finalize = cc_background_panel_finalize;
|
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/background/cc-background-panel.ui");
|
|
|
|
|
2019-05-27 13:00:26 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, background_chooser);
|
2022-06-15 19:12:10 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, default_preview);
|
2021-12-19 17:11:57 +05:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, dark_preview);
|
2022-06-15 19:12:10 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, default_toggle);
|
2021-12-19 17:11:57 +05:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, dark_toggle);
|
2019-05-21 13:48:46 -03:00
|
|
|
|
2022-06-15 19:12:10 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_color_scheme_toggle_active_cb);
|
2019-05-21 20:17:14 -03:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_chooser_background_chosen_cb);
|
2019-05-27 13:00:26 -03:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_add_picture_button_clicked_cb);
|
2019-05-21 13:48:46 -03:00
|
|
|
}
|
|
|
|
|
2012-08-15 21:12:07 -04:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
on_settings_changed (CcBackgroundPanel *self)
|
2012-08-15 21:12:07 -04:00
|
|
|
{
|
2023-05-31 15:24:04 +12:00
|
|
|
reload_current_bg (self);
|
|
|
|
update_preview (self);
|
2012-08-15 21:12:07 -04:00
|
|
|
}
|
|
|
|
|
2010-08-10 15:26:07 +01:00
|
|
|
static void
|
2023-05-31 15:24:04 +12:00
|
|
|
cc_background_panel_init (CcBackgroundPanel *self)
|
2010-08-10 15:26:07 +01:00
|
|
|
{
|
2013-01-04 13:17:31 +01:00
|
|
|
g_resources_register (cc_background_get_resource ());
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
self->connection = g_application_get_dbus_connection (g_application_get_default ());
|
2019-05-21 13:48:46 -03:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
self->settings = g_settings_new (WP_PATH_ID);
|
|
|
|
g_settings_delay (self->settings);
|
2020-02-11 15:14:07 +01:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
self->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
|
|
|
|
g_settings_delay (self->lock_settings);
|
2013-08-19 21:00:48 +02:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
self->interface_settings = g_settings_new (INTERFACE_PATH_ID);
|
2021-12-19 17:11:57 +05:00
|
|
|
|
2020-02-11 15:14:07 +01:00
|
|
|
/* Load the background */
|
2023-05-31 15:24:04 +12:00
|
|
|
reload_current_bg (self);
|
|
|
|
update_preview (self);
|
2010-12-16 13:07:55 +00:00
|
|
|
|
2013-08-19 21:00:48 +02:00
|
|
|
/* Background settings */
|
2023-05-31 15:24:04 +12:00
|
|
|
g_signal_connect_object (self->settings, "changed", G_CALLBACK (on_settings_changed), self, G_CONNECT_SWAPPED);
|
2021-12-19 17:11:57 +05:00
|
|
|
|
|
|
|
/* Interface settings */
|
2023-05-31 15:24:04 +12:00
|
|
|
reload_color_scheme_toggles (self);
|
2021-12-19 17:11:57 +05:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
g_signal_connect_object (self->interface_settings,
|
2021-12-19 17:11:57 +05:00
|
|
|
"changed::" INTERFACE_COLOR_SCHEME_KEY,
|
2022-06-15 19:12:10 +00:00
|
|
|
G_CALLBACK (reload_color_scheme_toggles),
|
2023-05-31 15:24:04 +12:00
|
|
|
self,
|
2021-12-19 17:11:57 +05:00
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
2021-12-19 21:41:53 +05:00
|
|
|
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
NULL,
|
|
|
|
"org.gnome.Shell",
|
|
|
|
"/org/gnome/Shell",
|
|
|
|
"org.gnome.Shell",
|
|
|
|
NULL,
|
|
|
|
got_transition_proxy_cb,
|
2023-05-31 15:24:04 +12:00
|
|
|
self);
|
2021-12-19 21:41:53 +05:00
|
|
|
|
2023-05-31 15:24:04 +12:00
|
|
|
load_custom_css (self);
|
2010-08-10 15:26:07 +01:00
|
|
|
}
|