-/* GTK - The GTK+ Toolkit
+/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
#include "gtkrc.h"
#include "gtkintl.h"
#include "gtkwidget.h"
+#include "gtktypeutils.h"
#include "gtkprivate.h"
-#include "gtkalias.h"
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
#include <pango/pangofc-fontmap.h>
#endif
+#ifdef GDK_WINDOWING_QUARTZ
+#define DEFAULT_KEY_THEME "Mac"
+#else
+#define DEFAULT_KEY_THEME NULL
+#endif
+
#define DEFAULT_TIMEOUT_INITIAL 200
#define DEFAULT_TIMEOUT_REPEAT 20
#define DEFAULT_TIMEOUT_EXPAND 500
PROP_RECENT_FILES_LIMIT,
PROP_IM_MODULE,
PROP_RECENT_FILES_MAX_AGE,
- PROP_FONTCONFIG_TIMESTAMP
+ PROP_FONTCONFIG_TIMESTAMP,
+ PROP_SOUND_THEME_NAME,
+ PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
+ PROP_ENABLE_EVENT_SOUNDS,
+ PROP_ENABLE_TOOLTIPS,
+ PROP_TOOLBAR_STYLE,
+ PROP_TOOLBAR_ICON_SIZE,
+ PROP_AUTO_MNEMONICS,
+ PROP_APPLICATION_PREFER_DARK_THEME
};
g_param_spec_string ("gtk-key-theme-name",
P_("Key Theme Name"),
P_("Name of key theme RC file to load"),
- NULL,
+ DEFAULT_KEY_THEME,
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_KEY_THEME_NAME);
NULL);
g_assert (result == PROP_FONT_NAME);
+ /**
+ * GtkSettings:gtk-icon-sizes:
+ *
+ * A list of icon sizes. The list is separated by colons, and
+ * item has the form:
+ *
+ * <replaceable>size-name</replaceable> = <replaceable>width</replaceable> , <replaceable>height</replaceable>
+ *
+ * E.g. "gtk-menu=16,16:gtk-button=20,20:gtk-dialog=48,48".
+ * GTK+ itself use the following named icon sizes: gtk-menu,
+ * gtk-button, gtk-small-toolbar, gtk-large-toolbar, gtk-dnd,
+ * gtk-dialog. Applications can register their own named icon
+ * sizes with gtk_icon_size_register().
+ */
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-icon-sizes",
P_("Icon Sizes"),
*
* A comma-separated list of print backends to use in the print
* dialog. Available print backends depend on the GTK+ installation,
- * and may include "pdf", "cups" or "lpr".
+ * and may include "file", "cups", "lpr" or "papi".
*
* Since: 2.10
*/
/**
* GtkSettings:gtk-im-module:
*
- * Which IM module should be used by default.
+ * Which IM (input method) module should be used by default. This is the
+ * input method that will be used if the user has not explicitly chosen
+ * another input method from the IM context menu.
+ *
+ * See #GtkIMContext and see the #GtkSettings:gtk-show-input-method-menu property.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-im-module",
g_assert (result == PROP_RECENT_FILES_MAX_AGE);
result = settings_install_property_parser (class,
- g_param_spec_int ("gtk-fontconfig-timestamp",
- P_("Fontconfig configuration timestamp"),
- P_("Timestamp of current fontconfig configuration"),
- G_MININT, G_MAXINT, 0,
- GTK_PARAM_READWRITE),
+ g_param_spec_uint ("gtk-fontconfig-timestamp",
+ P_("Fontconfig configuration timestamp"),
+ P_("Timestamp of current fontconfig configuration"),
+ 0, G_MAXUINT, 0,
+ GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
-
+
+ /**
+ * GtkSettings:gtk-sound-theme-name:
+ *
+ * The XDG sound theme to use for event sounds.
+ *
+ * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
+ * for more information on event sounds and sound themes.
+ *
+ * GTK+ itself does not support event sounds, you have to use a loadable
+ * module like the one that comes with libcanberra.
+ *
+ * Since: 2.14
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_string ("gtk-sound-theme-name",
+ P_("Sound Theme Name"),
+ P_("XDG sound theme name"),
+ "freedesktop",
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_SOUND_THEME_NAME);
+
+ /**
+ * GtkSettings:gtk-enable-input-feedback-sounds:
+ *
+ * Whether to play event sounds as feedback to user input.
+ *
+ * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
+ * for more information on event sounds and sound themes.
+ *
+ * GTK+ itself does not support event sounds, you have to use a loadable
+ * module like the one that comes with libcanberra.
+ *
+ * Since: 2.14
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-enable-input-feedback-sounds",
+ /* Translators: this means sounds that are played as feedback to user input */
+ P_("Audible Input Feedback"),
+ P_("Whether to play event sounds as feedback to user input"),
+ TRUE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS);
+
+ /**
+ * GtkSettings:gtk-enable-event-sounds:
+ *
+ * Whether to play any event sounds at all.
+ *
+ * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
+ * for more information on event sounds and sound themes.
+ *
+ * GTK+ itself does not support event sounds, you have to use a loadable
+ * module like the one that comes with libcanberra.
+ *
+ * Since: 2.14
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-enable-event-sounds",
+ P_("Enable Event Sounds"),
+ P_("Whether to play any event sounds at all"),
+ TRUE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_ENABLE_EVENT_SOUNDS);
+
+ /**
+ * GtkSettings:gtk-enable-tooltips:
+ *
+ * Whether tooltips should be shown on widgets.
+ *
+ * Since: 2.14
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-enable-tooltips",
+ P_("Enable Tooltips"),
+ P_("Whether tooltips should be shown on widgets"),
+ TRUE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_ENABLE_TOOLTIPS);
+
+ /**
+ * GtkSettings:toolbar-style:
+ *
+ * The size of icons in default toolbars.
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_enum ("gtk-toolbar-style",
+ P_("Toolbar style"),
+ P_("Whether default toolbars have text only, text and icons, icons only, etc."),
+ GTK_TYPE_TOOLBAR_STYLE,
+ GTK_TOOLBAR_BOTH,
+ GTK_PARAM_READWRITE),
+ gtk_rc_property_parse_enum);
+ g_assert (result == PROP_TOOLBAR_STYLE);
+
+ /**
+ * GtkSettings:toolbar-icon-size:
+ *
+ * The size of icons in default toolbars.
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_enum ("gtk-toolbar-icon-size",
+ P_("Toolbar Icon Size"),
+ P_("The size of icons in default toolbars."),
+ GTK_TYPE_ICON_SIZE,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_PARAM_READWRITE),
+ gtk_rc_property_parse_enum);
+ g_assert (result == PROP_TOOLBAR_ICON_SIZE);
+
+ /**
+ * GtkSettings:gtk-auto-mnemonics:
+ *
+ * Whether mnemonics should be automatically shown and hidden when the user
+ * presses the mnemonic activator.
+ *
+ * Since: 2.20
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-auto-mnemonics",
+ P_("Auto Mnemonics"),
+ P_("Whether mnemonics should be automatically shown and hidden when the user presses the mnemonic activator."),
+ FALSE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_AUTO_MNEMONICS);
+
+ /**
+ * GtkSettings:gtk-application-prefer-dark-theme:
+ *
+ * Whether the application prefers to use a dark theme. If a GTK+ theme
+ * includes a dark variant, it will be used instead of the configured
+ * theme.
+ *
+ * Some applications benefit from minimizing the amount of light pollution that
+ * interferes with the content. Good candidates for dark themes are photo and
+ * video editors that make the actual content get all the attention and minimize
+ * the distraction of the chrome.
+ *
+ * Dark themes should not be used for documents, where large spaces are white/light
+ * and the dark chrome creates too much contrast (web browser, text editor...).
+ *
+ * Since: 2.22
+ */
+ result = settings_install_property_parser (class,
+ g_param_spec_boolean ("gtk-application-prefer-dark-theme",
+ P_("Application prefers a dark theme"),
+ P_("Whether the application prefers to have a dark theme."),
+ FALSE,
+ GTK_PARAM_READWRITE),
+ NULL);
+ g_assert (result == PROP_APPLICATION_PREFER_DARK_THEME);
}
static void
/**
* gtk_settings_get_for_screen:
- * @screen : a #GdkScreen.
- *
+ * @screen: a #GdkScreen.
+ *
* Gets the #GtkSettings object for @screen, creating it if necessary.
*
- * Return value: a #GtkSettings object.
+ * Return value: (transfer none): a #GtkSettings object.
*
* Since: 2.2
*/
gtk_settings_get_for_screen (GdkScreen *screen)
{
GtkSettings *settings;
-
+
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
-
+
settings = g_object_get_data (G_OBJECT (screen), "gtk-settings");
if (!settings)
{
*
* Gets the #GtkSettings object for the default GDK screen, creating
* it if necessary. See gtk_settings_get_for_screen().
- *
- * Return value: a #GtkSettings object. If there is no default
+ *
+ * Return value: (transfer none): a #GtkSettings object. If there is no default
* screen, then returns %NULL.
**/
GtkSettings*
case G_TYPE_FLOAT:
case G_TYPE_DOUBLE:
case G_TYPE_STRING:
+ case G_TYPE_ENUM:
break;
case G_TYPE_BOXED:
if (strcmp (g_param_spec_get_name (pspec), "color-hash") == 0)
GtkBorder border;
GScanner *scanner;
gboolean success = FALSE;
+ int left, right, top, bottom;
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
scanner = gtk_rc_scanner_new ();
g_scanner_input_text (scanner, gstring->str, gstring->len);
- if (get_braced_int (scanner, TRUE, FALSE, &border.left) &&
- get_braced_int (scanner, FALSE, FALSE, &border.right) &&
- get_braced_int (scanner, FALSE, FALSE, &border.top) &&
- get_braced_int (scanner, FALSE, TRUE, &border.bottom))
+ if (get_braced_int (scanner, TRUE, FALSE, &left) &&
+ get_braced_int (scanner, FALSE, FALSE, &right) &&
+ get_braced_int (scanner, FALSE, FALSE, &top) &&
+ get_braced_int (scanner, FALSE, TRUE, &bottom))
{
+ border.left = left;
+ border.right = right;
+ border.top = top;
+ border.bottom = bottom;
g_value_set_boxed (property_value, &border);
success = TRUE;
}
GParamSpec *pspec;
guint property_id;
- settings = gtk_settings_get_for_screen (gdk_drawable_get_screen (event->window));
+ settings = gtk_settings_get_for_screen (gdk_window_get_screen (event->window));
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name);
if (pspec)
if (property_id == PROP_COLOR_SCHEME)
{
GValue value = { 0, };
-
+
g_value_init (&value, G_TYPE_STRING);
if (!gdk_screen_get_setting (settings->screen, pspec->name, &value))
g_value_set_static_string (&value, "");
merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING);
g_value_unset (&value);
}
-
g_object_notify (G_OBJECT (settings), pspec->name);
}
}
static guint last_update_timestamp;
static gboolean last_update_needed;
- gint timestamp;
+ guint timestamp;
g_object_get (settings,
"gtk-fontconfig-timestamp", ×tamp,
PangoFontMap *fontmap = pango_cairo_font_map_get_default ();
gboolean update_needed = FALSE;
- if (PANGO_IS_FC_FONT_MAP (fontmap) &&
- !FcConfigUptoDate (NULL) && FcInitReinitialize ())
+ /* bug 547680 */
+ if (PANGO_IS_FC_FONT_MAP (fontmap) && !FcConfigUptoDate (NULL))
{
- update_needed = TRUE;
pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap));
+ if (FcInitReinitialize ())
+ update_needed = TRUE;
}
last_update_timestamp = timestamp;
}
static gboolean
-add_color_to_hash (gchar *name,
- GdkColor *color,
+add_color_to_hash (gchar *name,
+ GdkColor *color,
GHashTable *target)
{
GdkColor *old;
if (!old || !gdk_color_equal (old, color))
{
g_hash_table_insert (target, g_strdup (name), gdk_color_copy (color));
-
+
return TRUE;
}
}
static gboolean
-add_colors_to_hash_from_string (GHashTable *hash,
+add_colors_to_hash_from_string (GHashTable *hash,
const gchar *colors)
{
gchar *s, *p, *name;
static gboolean
update_color_hash (ColorSchemeData *data,
- const gchar *str,
+ const gchar *str,
GtkSettingsSource source)
{
gboolean changed = FALSE;
gint i;
+ GHashTable *old_hash;
+ GHashTableIter iter;
+ gpointer name;
+ gpointer color;
- if ((str == NULL || *str == '\0') &&
+ if ((str == NULL || *str == '\0') &&
(data->lastentry[source] == NULL || data->lastentry[source][0] == '\0'))
return FALSE;
if (str && data->lastentry[source] && strcmp (str, data->lastentry[source]) == 0)
return FALSE;
- /* For the RC_FILE source we merge the values rather than over-writing
+ /* For the RC_FILE source we merge the values rather than over-writing
* them, since multiple rc files might define independent sets of colors
*/
- if ((source != GTK_SETTINGS_SOURCE_RC_FILE) &&
+ if ((source != GTK_SETTINGS_SOURCE_RC_FILE) &&
data->tables[source] && g_hash_table_size (data->tables[source]) > 0)
{
g_hash_table_unref (data->tables[source]);
}
if (data->tables[source] == NULL)
- data->tables[source] = g_hash_table_new_full (g_str_hash, g_str_equal,
+ data->tables[source] = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) gdk_color_free);
g_free (data->lastentry[source]);
data->lastentry[source] = g_strdup (str);
-
+
changed |= add_colors_to_hash_from_string (data->tables[source], str);
if (!changed)
return FALSE;
-
+
/* Rebuild the merged hash table. */
if (data->color_hash)
- g_hash_table_unref (data->color_hash);
- data->color_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
- (GDestroyNotify) gdk_color_free);
+ {
+ old_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+ (GDestroyNotify) gdk_color_free);
+
+ g_hash_table_iter_init (&iter, data->color_hash);
+ while (g_hash_table_iter_next (&iter, &name, &color))
+ {
+ g_hash_table_insert (old_hash, name, color);
+ g_hash_table_iter_steal (&iter);
+ }
+ }
+ else
+ {
+ old_hash = NULL;
+ }
+
for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
{
if (data->tables[i])
data->color_hash);
}
- return TRUE;
+ if (old_hash)
+ {
+ /* now check if the merged hash has changed */
+ changed = FALSE;
+ if (g_hash_table_size (old_hash) != g_hash_table_size (data->color_hash))
+ changed = TRUE;
+ else
+ {
+ GHashTableIter iter;
+ gpointer key, value, new_value;
+
+ g_hash_table_iter_init (&iter, old_hash);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ new_value = g_hash_table_lookup (data->color_hash, key);
+ if (!new_value || !gdk_color_equal (value, new_value))
+ {
+ changed = TRUE;
+ break;
+ }
+ }
+ }
+
+ g_hash_table_unref (old_hash);
+ }
+ else
+ changed = TRUE;
+
+ return changed;
}
static void
return g_string_free (string, FALSE);
}
-
-
-#define __GTK_SETTINGS_C__
-#include "gtkaliasdef.c"