Commit c31d601e authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

sticky-notes: use template for applet preferences

parent b70316e5
Pipeline #167853 passed with stages
in 23 minutes and 22 seconds
......@@ -26,6 +26,8 @@ libsticky_notes_applet_la_SOURCES = \
sticky-notes-applet-callbacks.h \
sticky-notes-callbacks.c \
sticky-notes-callbacks.h \
sticky-notes-preferences.c \
sticky-notes-preferences.h \
util.c \
util.h \
$(NULL)
......
......@@ -344,77 +344,6 @@ void menu_toggle_lock_state(GSimpleAction *action, GVariant *value, gpointer use
g_settings_set_boolean (stickynotes->settings, KEY_LOCKED, locked);
}
/* Menu Callback : Configure preferences */
void menu_preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
StickyNotesApplet *applet = (StickyNotesApplet *) user_data;
stickynotes_applet_update_prefs();
gtk_window_set_screen(GTK_WINDOW(stickynotes->w_prefs), gtk_widget_get_screen(GTK_WIDGET (applet)));
gtk_window_present(GTK_WINDOW(stickynotes->w_prefs));
}
/* Preferences Callback : Save. */
void
preferences_save_cb (gpointer data)
{
gint width = gtk_adjustment_get_value (stickynotes->w_prefs_width);
gint height = gtk_adjustment_get_value (stickynotes->w_prefs_height);
gboolean sys_color = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color));
gboolean sys_font = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font));
gboolean sticky = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky));
gboolean force_default = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force));
gboolean desktop_hide = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop));
if (g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_WIDTH))
g_settings_set_int (stickynotes->settings, KEY_DEFAULT_WIDTH, width);
if (g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_HEIGHT))
g_settings_set_int (stickynotes->settings, KEY_DEFAULT_HEIGHT, height);
if (g_settings_is_writable (stickynotes->settings, KEY_USE_SYSTEM_COLOR))
g_settings_set_boolean (stickynotes->settings, KEY_USE_SYSTEM_COLOR, sys_color);
if (g_settings_is_writable (stickynotes->settings, KEY_USE_SYSTEM_FONT))
g_settings_set_boolean (stickynotes->settings, KEY_USE_SYSTEM_FONT, sys_font);
if (g_settings_is_writable (stickynotes->settings, KEY_STICKY))
g_settings_set_boolean (stickynotes->settings, KEY_STICKY, sticky);
if (g_settings_is_writable (stickynotes->settings, KEY_FORCE_DEFAULT))
g_settings_set_boolean (stickynotes->settings, KEY_FORCE_DEFAULT, force_default);
if (g_settings_is_writable (stickynotes->settings, KEY_DESKTOP_HIDE))
g_settings_set_boolean (stickynotes->settings, KEY_DESKTOP_HIDE, desktop_hide);
}
/* Preferences Callback : Change color. */
void
preferences_color_cb (GtkWidget *button, gpointer data)
{
GdkRGBA color, font_color;
char *color_str, *font_color_str;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color), &color);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color), &font_color);
color_str = gdk_rgba_to_string (&color);
font_color_str = gdk_rgba_to_string (&font_color);
g_settings_set_string (stickynotes->settings, KEY_DEFAULT_COLOR, color_str);
g_settings_set_string (stickynotes->settings, KEY_DEFAULT_FONT_COLOR, font_color_str);
g_free (color_str);
g_free (font_color_str);
}
/* Preferences Callback : Change font. */
void preferences_font_cb (GtkWidget *button, gpointer data)
{
const char *font_str;
font_str = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
g_settings_set_string (stickynotes->settings, KEY_DEFAULT_FONT, font_str);
}
/* Preferences Callback : Apply to existing notes. */
void preferences_apply_cb (GSettings *settings,
const gchar *key,
......@@ -451,6 +380,7 @@ void preferences_apply_cb (GSettings *settings,
}
else if (!strcmp (key, KEY_USE_SYSTEM_COLOR) ||
!strcmp (key, KEY_DEFAULT_FONT_COLOR) ||
!strcmp (key, KEY_DEFAULT_COLOR))
{
for (l = stickynotes->notes; l; l = l->next)
......@@ -484,7 +414,6 @@ void preferences_apply_cb (GSettings *settings,
}
}
stickynotes_applet_update_prefs();
stickynotes_applet_update_menus();
}
......@@ -509,13 +438,5 @@ void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data)
}
else if (response == GTK_RESPONSE_CLOSE)
gtk_widget_hide(GTK_WIDGET(dialog));
}
/* Preferences Callback : Delete */
gboolean preferences_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_widget_hide(widget);
return TRUE;
gtk_widget_destroy(GTK_WIDGET(dialog));
}
......@@ -36,14 +36,9 @@ void menu_hide_notes_cb(GSimpleAction *action, GVariant *parameter, gpointer use
void menu_destroy_all_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
void menu_toggle_lock_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
void menu_toggle_lock_state(GSimpleAction *action, GVariant *value, gpointer user_data);
void menu_preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
/* Callbacks for sticky notes preferences dialog */
void preferences_save_cb(gpointer data);
void preferences_color_cb (GtkWidget *button, gpointer data);
void preferences_font_cb (GtkWidget *button, gpointer data);
void preferences_apply_cb(GSettings *settings, const gchar *key, gpointer user_data);
void preferences_response_cb(GtkWidget *dialog, gint response, gpointer data);
gboolean preferences_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data);
#endif /* __STICKYNOTES_APPLET_CALLBACKS_H__ */
......@@ -22,6 +22,7 @@
#include "sticky-notes-applet-callbacks.h"
#include "sticky-notes.h"
#include "sticky-notes-preferences.h"
#include "gsettings.h"
#include <glib/gi18n-lib.h>
......@@ -32,10 +33,31 @@ G_DEFINE_TYPE (StickyNotesApplet, sticky_notes_applet, GP_TYPE_APPLET)
StickyNotes *stickynotes = NULL;
static void sticky_notes_init (GpApplet *applet);
static void sticky_notes_init_prefs (void);
static void sticky_notes_applet_new (StickyNotesApplet *self);
static void
menu_preferences_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
if (stickynotes->w_prefs != NULL)
{
gtk_window_present (GTK_WINDOW (stickynotes->w_prefs));
return;
}
stickynotes->w_prefs = sticky_notes_preferences_new (stickynotes->settings);
g_object_add_weak_pointer (G_OBJECT (stickynotes->w_prefs),
(gpointer *) &stickynotes->w_prefs);
g_signal_connect (stickynotes->w_prefs,
"response",
G_CALLBACK (preferences_response_cb),
NULL);
gtk_window_present (GTK_WINDOW (stickynotes->w_prefs));
}
static void
menu_help_cb (GSimpleAction *action,
GVariant *parameter,
......@@ -168,8 +190,6 @@ sticky_notes_init (GpApplet *applet)
stickynotes->icon_normal, 30);
stickynotes->visible = TRUE;
sticky_notes_init_prefs ();
g_signal_connect (stickynotes->settings, "changed",
G_CALLBACK (preferences_apply_cb), NULL);
......@@ -182,138 +202,6 @@ sticky_notes_init (GpApplet *applet)
install_check_click_on_desktop ();
}
static void
sticky_notes_init_prefs (void)
{
stickynotes->builder = gtk_builder_new ();
gtk_builder_add_from_resource (stickynotes->builder,
GRESOURCE_PREFIX "/ui/sticky-notes-preferences.ui",
NULL);
stickynotes->w_prefs = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
"preferences_dialog"));
stickynotes->w_prefs_width = gtk_spin_button_get_adjustment (
GTK_SPIN_BUTTON (gtk_builder_get_object (
stickynotes->builder, "width_spin")));
stickynotes->w_prefs_height = gtk_spin_button_get_adjustment (
GTK_SPIN_BUTTON (gtk_builder_get_object (
stickynotes->builder, "height_spin")));
stickynotes->w_prefs_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
"default_color"));
stickynotes->w_prefs_font_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
"prefs_font_color"));
stickynotes->w_prefs_sys_color = GTK_WIDGET (&GTK_CHECK_BUTTON (
gtk_builder_get_object (stickynotes->builder,
"sys_color_check"))->toggle_button);
stickynotes->w_prefs_font = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
"default_font"));
stickynotes->w_prefs_sys_font = GTK_WIDGET (&GTK_CHECK_BUTTON (
gtk_builder_get_object (stickynotes->builder,
"sys_font_check"))->toggle_button);
stickynotes->w_prefs_sticky = GTK_WIDGET (&GTK_CHECK_BUTTON (
gtk_builder_get_object (stickynotes->builder,
"sticky_check"))->toggle_button);
stickynotes->w_prefs_force = GTK_WIDGET (&GTK_CHECK_BUTTON (
gtk_builder_get_object (stickynotes->builder,
"force_default_check"))->toggle_button);
stickynotes->w_prefs_desktop = GTK_WIDGET (&GTK_CHECK_BUTTON (
gtk_builder_get_object (stickynotes->builder,
"desktop_hide_check"))->toggle_button);
g_signal_connect (G_OBJECT (stickynotes->w_prefs), "response",
G_CALLBACK (preferences_response_cb), NULL);
g_signal_connect (G_OBJECT (stickynotes->w_prefs), "delete-event",
G_CALLBACK (preferences_delete_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_width),
"value-changed",
G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_height),
"value-changed",
G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sys_color),
"toggled",
G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (G_OBJECT(stickynotes->w_prefs_sys_font),
"toggled", G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect (G_OBJECT (stickynotes->w_prefs_color),
"color-set", G_CALLBACK (preferences_color_cb), NULL);
g_signal_connect (G_OBJECT (stickynotes->w_prefs_font_color),
"color-set", G_CALLBACK (preferences_color_cb), NULL);
g_signal_connect (G_OBJECT (stickynotes->w_prefs_font),
"font-set", G_CALLBACK (preferences_font_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sticky),
"toggled", G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_force),
"toggled", G_CALLBACK (preferences_save_cb), NULL);
g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_desktop),
"toggled", G_CALLBACK (preferences_save_cb), NULL);
{
GtkSizeGroup *group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "width_label")));
gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "height_label")));
gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "prefs_color_label")));
g_object_unref(group);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_WIDTH))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "width_label")),
FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "width_spin")),
FALSE);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_HEIGHT))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "height_label")),
FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "height_spin")),
FALSE);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_COLOR))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_color_label")),
FALSE);
gtk_widget_set_sensitive (stickynotes->w_prefs_color, FALSE);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_FONT_COLOR))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_font_color_label")),
FALSE);
gtk_widget_set_sensitive (stickynotes->w_prefs_font_color,
FALSE);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_USE_SYSTEM_COLOR))
gtk_widget_set_sensitive (stickynotes->w_prefs_sys_color,
FALSE);
if (!g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_FONT))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_font_label")),
FALSE);
gtk_widget_set_sensitive (stickynotes->w_prefs_font, FALSE);
}
if (!g_settings_is_writable (stickynotes->settings, KEY_USE_SYSTEM_FONT))
gtk_widget_set_sensitive (stickynotes->w_prefs_sys_font,
FALSE);
if (!g_settings_is_writable (stickynotes->settings, KEY_STICKY))
gtk_widget_set_sensitive (stickynotes->w_prefs_sticky, FALSE);
if (!g_settings_is_writable (stickynotes->settings, KEY_FORCE_DEFAULT))
gtk_widget_set_sensitive (stickynotes->w_prefs_force, FALSE);
stickynotes_applet_update_prefs();
}
/* Create a Sticky Notes applet */
static void
sticky_notes_applet_new (StickyNotesApplet *applet)
......@@ -403,101 +291,6 @@ void stickynotes_applet_update_icon(StickyNotesApplet *applet)
g_object_unref(pixbuf2);
}
void
stickynotes_applet_update_prefs (void)
{
gint width, height;
gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
char *font_str;
char *color_str, *font_color_str;
GdkRGBA color, font_color;
width = g_settings_get_int (stickynotes->settings, KEY_DEFAULT_WIDTH);
width = MAX (width, 1);
height = g_settings_get_int (stickynotes->settings, KEY_DEFAULT_HEIGHT);
height = MAX (height, 1);
sys_color = g_settings_get_boolean (stickynotes->settings, KEY_USE_SYSTEM_COLOR);
sys_font = g_settings_get_boolean (stickynotes->settings, KEY_USE_SYSTEM_FONT);
sticky = g_settings_get_boolean (stickynotes->settings, KEY_STICKY);
force_default = g_settings_get_boolean (stickynotes->settings, KEY_FORCE_DEFAULT);
desktop_hide = g_settings_get_boolean (stickynotes->settings, KEY_DESKTOP_HIDE);
font_str = g_settings_get_string (stickynotes->settings, KEY_DEFAULT_FONT);
if (IS_STRING_EMPTY (font_str)) {
g_free (font_str);
font_str = g_strdup ("Sans 10");
}
color_str = g_settings_get_string (stickynotes->settings, KEY_DEFAULT_COLOR);
if (IS_STRING_EMPTY (color_str)) {
g_free (color_str);
color_str = g_strdup ("#ECF833");
}
font_color_str = g_settings_get_string (stickynotes->settings, KEY_DEFAULT_FONT_COLOR);
if (IS_STRING_EMPTY (font_color_str)) {
g_free (font_color_str);
font_color_str = g_strdup ("#000000");
}
gdk_rgba_parse (&color, color_str);
g_free (color_str);
gdk_rgba_parse (&font_color, font_color_str);
g_free (font_color_str);
gtk_adjustment_set_value (stickynotes->w_prefs_width, width);
gtk_adjustment_set_value (stickynotes->w_prefs_height, height);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color),
sys_color);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(stickynotes->w_prefs_sys_font),
sys_font);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky),
sticky);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force),
force_default);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop),
desktop_hide);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color), &color);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color), &font_color);
gtk_font_button_set_font_name (
GTK_FONT_BUTTON (stickynotes->w_prefs_font), font_str);
g_free (font_str);
if (g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_COLOR))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_color_label")),
!sys_color);
gtk_widget_set_sensitive (stickynotes->w_prefs_color,
!sys_color);
}
if (g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_FONT_COLOR))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_font_color_label")),
!sys_color);
gtk_widget_set_sensitive (stickynotes->w_prefs_font_color,
!sys_color);
}
if (g_settings_is_writable (stickynotes->settings, KEY_DEFAULT_FONT))
{
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (
stickynotes->builder, "prefs_font_label")),
!sys_font);
gtk_widget_set_sensitive (stickynotes->w_prefs_font,
!sys_font);
}
}
void stickynotes_applet_update_menus(void)
{
GList *l;
......
......@@ -32,19 +32,7 @@ G_DECLARE_FINAL_TYPE (StickyNotesApplet, sticky_notes_applet,
/* Global Sticky Notes instance */
typedef struct
{
GtkBuilder *builder;
GtkWidget *w_prefs; /* The prefs dialog */
GtkAdjustment *w_prefs_width;
GtkAdjustment *w_prefs_height;
GtkWidget *w_prefs_color;
GtkWidget *w_prefs_font_color;
GtkWidget *w_prefs_sys_color;
GtkWidget *w_prefs_font;
GtkWidget *w_prefs_sys_font;
GtkWidget *w_prefs_sticky;
GtkWidget *w_prefs_force;
GtkWidget *w_prefs_desktop;
GList *notes; /* Linked-List of all the sticky notes */
GList *applets; /* Linked-List of all the applets */
......@@ -88,7 +76,6 @@ typedef enum
extern StickyNotes *stickynotes;
void stickynotes_applet_update_icon(StickyNotesApplet *applet);
void stickynotes_applet_update_prefs(void);
void stickynotes_applet_update_menus(void);
void stickynotes_applet_update_tooltips(void);
......
/*
* Copyright (C) 2020 Alberts Muktupāvels
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "sticky-notes-preferences.h"
#include "gsettings.h"
struct _StickyNotesPreferences
{
GtkDialog parent;
GtkWidget *width_label;
GtkWidget *width_spin;
GtkWidget *height_label;
GtkWidget *height_spin;
GtkWidget *sys_color_check;
GtkWidget *prefs_font_color_label;
GtkWidget *prefs_font_color;
GtkWidget *prefs_color_label;
GtkWidget *default_color;
GtkWidget *sys_font_check;
GtkWidget *prefs_font_label;
GtkWidget *default_font;
GtkWidget *sticky_check;
GtkWidget *force_default_check;
GtkWidget *desktop_hide_check;
GSettings *settings;
};
enum
{
PROP_0,
PROP_SETTINGS,
LAST_PROP
};
static GParamSpec *preferences_properties[LAST_PROP] = { NULL };
G_DEFINE_TYPE (StickyNotesPreferences, sticky_notes_preferences, GTK_TYPE_DIALOG)
static gboolean
int_to_dobule (GValue *value,
GVariant *variant,
gpointer user_data)
{
int int_value;
g_variant_get (variant, "i", &int_value);
g_value_set_double (value, int_value);
return TRUE;
}
static GVariant *
double_to_int (const GValue *value,
const GVariantType *expected_type,
gpointer user_data)
{
double double_value;
double_value = g_value_get_double (value);
return g_variant_new_int32 (double_value);
}
static void
use_system_color_changed_cb (GSettings *settings,
const char *key,
StickyNotesPreferences *self)
{
gboolean use_system_color;
gboolean sensitive;
use_system_color = g_settings_get_boolean (settings, key);
sensitive = !use_system_color &&
g_settings_is_writable (settings, KEY_DEFAULT_FONT_COLOR);
gtk_widget_set_sensitive (self->prefs_font_color_label, sensitive);
gtk_widget_set_sensitive (self->prefs_font_color, sensitive);
sensitive = !use_system_color &&
g_settings_is_writable (settings, KEY_DEFAULT_COLOR);
gtk_widget_set_sensitive (self->prefs_color_label, sensitive);
gtk_widget_set_sensitive (self->default_color, sensitive);
}
static void
use_system_font_changed_cb (GSettings *settings,
const char *key,
StickyNotesPreferences *self)
{
gboolean use_system_font;
gboolean sensitive;
use_system_font = g_settings_get_boolean (settings, key);
sensitive = !use_system_font &&
g_settings_is_writable (settings, KEY_DEFAULT_FONT);
gtk_widget_set_sensitive (self->prefs_font_label, sensitive);
gtk_widget_set_sensitive (self->default_font, sensitive);
}
static gboolean
string_to_rgba (GValue *value,
GVariant *variant,
gpointer user_data)
{
const char *color;
GdkRGBA rgba;
g_variant_get (variant, "&s", &color);
if (!gdk_rgba_parse (&rgba, color))
return FALSE;
g_value_set_boxed (value, &rgba);
return TRUE;
}
static GVariant *
rgba_to_string (const GValue *value,
const GVariantType *expected_type,
gpointer user_data)
{
GdkRGBA *rgba;
char *color;
GVariant *variant;
rgba = g_value_get_boxed (value);
if (rgba == NULL)
return NULL;
color = gdk_rgba_to_string (rgba);
variant = g_variant_new_string (color);
g_free (color);
return variant;
}
static gboolean
string_to_font (GValue *value,
GVariant *variant,
gpointer user_data)
{
const char *color;
g_variant_get (variant, "&s", &color);
if (*color == '\0')
return FALSE;
g_value_set_string (value, color);
return TRUE;
}
static void
sticky_notes_preferences_constructed (GObject *object)
{
StickyNotesPreferences *self;
self = STICKY_NOTES_PREFERENCES (object);
G_OBJECT_CLASS (sticky_notes_preferences_parent_class)->constructed (object);
g_settings_bind_writable (self->settings,
KEY_DEFAULT_WIDTH,
self->width_label,
"sensitive",
FALSE);
g_settings_bind_with_mapping (self->settings,
KEY_DEFAULT_WIDTH,
self->width_spin,
"value",
G_SETTINGS_BIND_DEFAULT,