]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdksettings.c
x11: Store GDK name in xsettings hash table
[~andy/gtk] / gdk / x11 / gdksettings.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /*
19  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
20  * file for a list of people on the GTK+ Team.  See the ChangeLog
21  * files for a list of changes.  These files are distributed with
22  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23  */
24
25 static const struct {
26   const char *xname, *gdkname;
27 } gdk_settings_map[] = {
28   {"Net/DoubleClickTime",     "gtk-double-click-time"},
29   {"Net/DoubleClickDistance", "gtk-double-click-distance"},
30   {"Net/DndDragThreshold",    "gtk-dnd-drag-threshold"},
31   {"Net/CursorBlink",         "gtk-cursor-blink"},
32   {"Net/CursorBlinkTime",     "gtk-cursor-blink-time"},
33   {"Net/ThemeName",           "gtk-theme-name"},
34   {"Net/IconThemeName",       "gtk-icon-theme-name"},
35   {"Gtk/CanChangeAccels",     "gtk-can-change-accels"},
36   {"Gtk/ColorPalette",        "gtk-color-palette"},
37   {"Gtk/FontName",            "gtk-font-name"},
38   {"Gtk/IconSizes",           "gtk-icon-sizes"},
39   {"Gtk/KeyThemeName",        "gtk-key-theme-name"},
40   {"Gtk/ToolbarStyle",        "gtk-toolbar-style"},
41   {"Gtk/ToolbarIconSize",     "gtk-toolbar-icon-size"},
42   {"Gtk/IMPreeditStyle",      "gtk-im-preedit-style"},
43   {"Gtk/IMStatusStyle",       "gtk-im-status-style"},
44   {"Gtk/Modules",             "gtk-modules"},
45   {"Gtk/FileChooserBackend",  "gtk-file-chooser-backend"},
46   {"Gtk/ButtonImages",        "gtk-button-images"},
47   {"Gtk/MenuImages",          "gtk-menu-images"},
48   {"Gtk/MenuBarAccel",        "gtk-menu-bar-accel"},
49   {"Gtk/CursorThemeName",     "gtk-cursor-theme-name"},
50   {"Gtk/CursorThemeSize",     "gtk-cursor-theme-size"},
51   {"Gtk/ShowInputMethodMenu", "gtk-show-input-method-menu"},
52   {"Gtk/ShowUnicodeMenu",     "gtk-show-unicode-menu"},
53   {"Gtk/TimeoutInitial",      "gtk-timeout-initial"},
54   {"Gtk/TimeoutRepeat",       "gtk-timeout-repeat"},
55   {"Gtk/ColorScheme",         "gtk-color-scheme"},
56   {"Gtk/EnableAnimations",    "gtk-enable-animations"},
57   {"Xft/Antialias",           "gtk-xft-antialias"},
58   {"Xft/Hinting",             "gtk-xft-hinting"},
59   {"Xft/HintStyle",           "gtk-xft-hintstyle"},
60   {"Xft/RGBA",                "gtk-xft-rgba"},
61   {"Xft/DPI",                 "gtk-xft-dpi"},
62   {"Net/FallbackIconTheme",   "gtk-fallback-icon-theme"},
63   {"Gtk/TouchscreenMode",     "gtk-touchscreen-mode"},
64   {"Gtk/EnableAccels",        "gtk-enable-accels"},
65   {"Gtk/EnableMnemonics",     "gtk-enable-mnemonics"},
66   {"Gtk/ScrolledWindowPlacement", "gtk-scrolled-window-placement"},
67   {"Gtk/IMModule",            "gtk-im-module"},
68   {"Fontconfig/Timestamp",    "gtk-fontconfig-timestamp"},
69   {"Net/SoundThemeName",      "gtk-sound-theme-name"},
70   {"Net/EnableInputFeedbackSounds", "gtk-enable-input-feedback-sounds"},
71   {"Net/EnableEventSounds",   "gtk-enable-event-sounds"},
72   {"Gtk/CursorBlinkTimeout",  "gtk-cursor-blink-timeout"},
73   {"Gtk/AutoMnemonics",       "gtk-auto-mnemonics"},
74   {"Gtk/VisibleFocus",        "gtk-visible-focus"},
75   {"Gtk/ShellShowsAppMenu",   "gtk-shell-shows-app-menu"},
76   {"Gtk/ShellShowsMenubar",   "gtk-shell-shows-menubar"},
77   {"Gtk/EnablePrimaryPaste",  "gtk-enable-primary-paste"},
78   {"Gtk/RecentFilesMaxAge",   "gtk-recent-files-max-age"},
79   {"Gtk/RecentFilesEnabled",  "gtk-recent-files-enabled"}
80 };
81
82 static const char *
83 gdk_from_xsettings_name (const char *xname)
84 {
85   static GHashTable *hash = NULL;
86   guint i;
87
88   if (G_UNLIKELY (hash == NULL))
89   {
90     hash = g_hash_table_new (g_str_hash, g_str_equal);
91
92     for (i = 0; i < G_N_ELEMENTS (gdk_settings_map); i++)
93       g_hash_table_insert (hash, (gpointer)gdk_settings_map[i].xname,
94                                  (gpointer)gdk_settings_map[i].gdkname);
95   }
96
97   return g_hash_table_lookup (hash, xname);
98 }
99