Add Gtk resource file with the default CSS file

This commit is contained in:
Alexander Larsson 2012-01-12 19:14:33 +01:00
parent 739ab8548d
commit 4f0cc6572b
5 changed files with 409 additions and 366 deletions

View File

@ -466,6 +466,7 @@ gtk_private_h_sources = \
gtkrecentchooserdefault.h \
gtkrecentchooserprivate.h \
gtkrecentchooserutils.h \
gtkresources.h \
gtkroundedboxprivate.h \
gtkscaleprivate.h \
gtksearchengine.h \
@ -707,6 +708,7 @@ gtk_base_c_sources = \
gtkrecentchooser.c \
gtkrecentfilter.c \
gtkrecentmanager.c \
gtkresources.c \
gtkroundedbox.c \
gtkscale.c \
gtkscalebutton.c \
@ -897,12 +899,14 @@ gtk_built_public_sources = \
# built headers that don't get installed
gtk_built_private_headers = \
gtkresources.h \
gtkmarshalers.h \
gtkbuiltincache.h \
gtkprivatetypebuiltins.h \
gtkwin32css.h
gtk_built_sources = \
gtkresources.c \
gtktypebuiltins.c \
gtktypefuncs.c \
gtkmarshalers.c \
@ -994,6 +998,12 @@ gtktypebuiltins.c: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtk
&& cp xgen-gtbc gtktypebuiltins.c \
&& rm -f xgen-gtbc
gtkresources.h: gtk.gresource.xml
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header --manual-register
gtkresources.c: gtk.gresource.xml gtk-default.css
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) gtk.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source --manual-register
gtkprivatetypebuiltins.h: stamp-gtkprivatetypebuiltins.h
@true

363
gtk/gtk-default.css Normal file
View File

@ -0,0 +1,363 @@
@define-color fg_color #000;
@define-color bg_color #dcdad5;
@define-color text_color #000;
@define-color base_color #fff;
@define-color selected_bg_color #4b6983;
@define-color selected_fg_color #fff;
@define-color tooltip_bg_color #eee1b3;
@define-color tooltip_fg_color #000;
@define-color placeholder_text_color #808080;
@define-color info_fg_color rgb (181, 171, 156);
@define-color info_bg_color rgb (252, 252, 189);
@define-color warning_fg_color rgb (173, 120, 41);
@define-color warning_bg_color rgb (250, 173, 61);
@define-color question_fg_color rgb (97, 122, 214);
@define-color question_bg_color rgb (138, 173, 212);
@define-color error_fg_color rgb (166, 38, 38);
@define-color error_bg_color rgb (237, 54, 54);
* {
background-color: @bg_color;
color: @fg_color;
border-color: shade (@bg_color, 0.6);
padding: 2;
border-width: 0;
}
*:prelight {
background-color: shade (@bg_color, 1.05);
color: shade (@fg_color, 1.3);
}
*:selected {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.expander, GtkTreeView.view.expander {
color: #fff;
}
.expander:prelight,
GtkTreeView.view.expander:selected:prelight {
color: @text_color;
}
.expander:active {
transition: 200ms linear;
}
*:insensitive {
border-color: shade (@bg_color, 0.7);
background-color: shade (@bg_color, 0.9);
color: shade (@bg_color, 0.7);
}
.view {
border-width: 0;
border-radius: 0;
background-color: @base_color;
color: @text_color;
}
.view:selected {
background-color: shade (@bg_color, 0.9);
color: @fg_color;
}
.view:selected:focused {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.view column:sorted row,
.view column:sorted row:prelight {
background-color: shade (@bg_color, 0.85);
}
.view column:sorted row:nth-child(odd),
.view column:sorted row:nth-child(odd):prelight {
background-color: shade (@bg_color, 0.8);
}
.view row,
.view row:prelight {
background-color: @base_color;
color: @text_color;
}
.view row:nth-child(odd),
.view row:nth-child(odd):prelight {
background-color: shade (@base_color, 0.93);
}
.view row:selected:focused {
background-color: @selected_bg_color;
}
.view row:selected {
background-color: darker (@bg_color);
color: @selected_fg_color;
}
.view.cell.trough,
.view.cell.trough:hover,
.view.cell.trough:selected,
.view.cell.trough:selected:focused {
background-color: @bg_color;
color: @fg_color;
}
.view.cell.progressbar,
.view.cell.progressbar:hover,
.view.cell.progressbar:selected,
.view.cell.progressbar:selected:focused {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.rubberband {
background-color: alpha (@fg_color, 0.25);
border-color: @fg_color;
border-style: solid;
border-width: 1;
}
.tooltip,
.tooltip * {
background-color: @tooltip_bg_color;
color: @tooltip_fg_color;
border-color: @tooltip_fg_color;
border-width: 1;
border-style: solid;
}
.button,
.slider {
border-style: outset;
border-width: 2;
}
.button:active {
background-color: shade (@bg_color, 0.7);
border-style: inset;
}
.button:prelight,
.slider:prelight {
background-color: @selected_bg_color;
color: @selected_fg_color;
border-color: shade (@selected_bg_color, 0.7);
}
.trough {
background-color: darker (@bg_color);
border-style: inset;
border-width: 1;
padding: 0;
}
.entry {
border-style: inset;
border-width: 2;
background-color: @base_color;
color: @text_color;
}
.entry:insensitive {
background-color: shade (@base_color, 0.9);
color: shade (@base_color, 0.7);
}
.entry:active {
background-color: #c4c2bd;
color: #000;
}
.progressbar,
.entry.progressbar,
.cell.progressbar {
background-color: @selected_bg_color;
border-color: shade (@selected_bg_color, 0.7);
color: @selected_fg_color;
border-style: outset;
border-width: 1;
}
GtkCheckButton:hover,
GtkCheckButton:selected,
GtkRadioButton:hover,
GtkRadioButton:selected {
background-color: shade (@bg_color, 1.05);
}
.check, .radio,
.cell.check, .cell.radio,
.cell.check:hover, .cell.radio:hover {
border-style: solid;
border-width: 1;
background-color: @base_color;
border-color: @fg_color;
}
.check:active, .radio:active,
.check:hover, .radio:hover {
background-color: @base_color;
border-color: @fg_color;
color: @text_color;
}
.check:selected, .radio:selected {
background-color: darker (@bg_color);
color: @selected_fg_color;
border-color: @selected_fg_color;
}
.check:selected:focused, .radio:selected:focused {
background-color: @selected_bg_color;
}
.menuitem.check, .menuitem.radio {
color: @fg_color;
border-style: none;
border-width: 0;
}
.popup {
border-style: outset;
border-width: 1;
}
.viewport {
border-style: inset;
border-width: 2;
}
.notebook {
border-style: outset;
border-width: 1;
}
.frame {
border-style: inset;
border-width: 1;
}
GtkScrolledWindow.frame {
padding: 0;
}
.menu,
.menubar,
.toolbar {
border-style: outset;
border-width: 1;
}
.menu:hover,
.menubar:hover,
.menuitem:hover,
.menuitem.check:hover,
.menuitem.radio:hover {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
GtkSpinButton.button {
border-width: 1;
}
.scale.slider:hover,
GtkSpinButton.button:hover {
background-color: shade (@bg_color, 1.05);
border-color: shade (@bg_color, 0.8);
}
GtkSwitch.trough:active {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
GtkToggleButton.button:inconsistent {
border-style: outset;
border-width: 1px;
background-color: shade (@bg_color, 0.9);
border-color: shade (@bg_color, 0.7);
}
GtkLabel:selected {
background-color: shade (@bg_color, 0.9);
}
GtkLabel:selected:focused {
background-color: @selected_bg_color;
}
.spinner:active {
transition: 750ms linear loop;
}
.info {
background-color: @info_bg_color;
color: @info_fg_color;
}
.warning {
background-color: @warning_bg_color;
color: @warning_fg_color;
}
.question {
background-color: @question_bg_color;
color: @question_fg_color;
}
.error {
background-color: @error_bg_color;
color: @error_fg_color;
}
.highlight {
background-color: @selected_bg_color;
color: @selected_fg_color;
}
.light-area-focus {
color: #000;
}
.dark-area-focus {
color: #fff;
}
GtkCalendar.view {
border-width: 1;
border-style: inset;
padding: 1;
}
GtkCalendar.view:inconsistent {
color: darker (@bg_color);
}
GtkCalendar.header {
background-color: @bg_color;
border-style: outset;
border-width: 2;
}
GtkCalendar.highlight {
border-width: 0;
}
GtkCalendar.button {
background-color: @bg_color;
}
GtkCalendar.button:hover {
background-color: lighter (@bg_color);
color: @fg_color;
}
.menu * {
border-width: 0;
padding: 2;
}

6
gtk/gtk.gresource.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/libgtk">
<file>gtk-default.css</file>
</gresource>
</gresources>

View File

@ -2745,6 +2745,32 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
return result;
}
static gboolean
_gtk_css_provider_load_from_resource (GtkCssProvider *css_provider,
const gchar *resource_path)
{
GFile *file;
char *uri, *escaped;
gboolean result;
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
g_return_val_if_fail (resource_path != NULL, FALSE);
escaped = g_uri_escape_string (resource_path,
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
uri = g_strconcat ("resource://", escaped, NULL);
g_free (escaped);
file = g_file_new_for_uri (uri);
g_free (uri);
result = gtk_css_provider_load_from_file (css_provider, file, NULL);
g_object_unref (file);
return result;
}
/**
* gtk_css_provider_get_default:
*
@ -2761,374 +2787,9 @@ gtk_css_provider_get_default (void)
if (G_UNLIKELY (!provider))
{
const gchar *str =
"@define-color fg_color #000; \n"
"@define-color bg_color #dcdad5; \n"
"@define-color text_color #000; \n"
"@define-color base_color #fff; \n"
"@define-color selected_bg_color #4b6983; \n"
"@define-color selected_fg_color #fff; \n"
"@define-color tooltip_bg_color #eee1b3; \n"
"@define-color tooltip_fg_color #000; \n"
"@define-color placeholder_text_color #808080; \n"
"\n"
"@define-color info_fg_color rgb (181, 171, 156);\n"
"@define-color info_bg_color rgb (252, 252, 189);\n"
"@define-color warning_fg_color rgb (173, 120, 41);\n"
"@define-color warning_bg_color rgb (250, 173, 61);\n"
"@define-color question_fg_color rgb (97, 122, 214);\n"
"@define-color question_bg_color rgb (138, 173, 212);\n"
"@define-color error_fg_color rgb (166, 38, 38);\n"
"@define-color error_bg_color rgb (237, 54, 54);\n"
"\n"
"* {\n"
" background-color: @bg_color;\n"
" color: @fg_color;\n"
" border-color: shade (@bg_color, 0.6);\n"
" padding: 2;\n"
" border-width: 0;\n"
"}\n"
"\n"
"*:prelight {\n"
" background-color: shade (@bg_color, 1.05);\n"
" color: shade (@fg_color, 1.3);\n"
"}\n"
"\n"
"*:selected {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
".expander, GtkTreeView.view.expander {\n"
" color: #fff;\n"
"}\n"
"\n"
".expander:prelight,\n"
"GtkTreeView.view.expander:selected:prelight {\n"
" color: @text_color;\n"
"}\n"
"\n"
".expander:active {\n"
" transition: 200ms linear;\n"
"}\n"
"\n"
"*:insensitive {\n"
" border-color: shade (@bg_color, 0.7);\n"
" background-color: shade (@bg_color, 0.9);\n"
" color: shade (@bg_color, 0.7);\n"
"}\n"
"\n"
".view {\n"
" border-width: 0;\n"
" border-radius: 0;\n"
" background-color: @base_color;\n"
" color: @text_color;\n"
"}\n"
".view:selected {\n"
" background-color: shade (@bg_color, 0.9);\n"
" color: @fg_color;\n"
"}\n"
"\n"
".view:selected:focused {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
".view column:sorted row,\n"
".view column:sorted row:prelight {\n"
" background-color: shade (@bg_color, 0.85);\n"
"}\n"
"\n"
".view column:sorted row:nth-child(odd),\n"
".view column:sorted row:nth-child(odd):prelight {\n"
" background-color: shade (@bg_color, 0.8);\n"
"}\n"
"\n"
".view row,\n"
".view row:prelight {\n"
" background-color: @base_color;\n"
" color: @text_color;\n"
"}\n"
"\n"
".view row:nth-child(odd),\n"
".view row:nth-child(odd):prelight {\n"
" background-color: shade (@base_color, 0.93); \n"
"}\n"
"\n"
".view row:selected:focused {\n"
" background-color: @selected_bg_color;\n"
"}\n"
"\n"
".view row:selected {\n"
" background-color: darker (@bg_color);\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
".view.cell.trough,\n"
".view.cell.trough:hover,\n"
".view.cell.trough:selected,\n"
".view.cell.trough:selected:focused {\n"
" background-color: @bg_color;\n"
" color: @fg_color;\n"
"}\n"
"\n"
".view.cell.progressbar,\n"
".view.cell.progressbar:hover,\n"
".view.cell.progressbar:selected,\n"
".view.cell.progressbar:selected:focused {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
".rubberband {\n"
" background-color: alpha (@fg_color, 0.25);\n"
" border-color: @fg_color;\n"
" border-style: solid;\n"
" border-width: 1;\n"
"}\n"
"\n"
".tooltip,\n"
".tooltip * {\n"
" background-color: @tooltip_bg_color; \n"
" color: @tooltip_fg_color; \n"
" border-color: @tooltip_fg_color; \n"
" border-width: 1;\n"
" border-style: solid;\n"
"}\n"
"\n"
".button,\n"
".slider {\n"
" border-style: outset; \n"
" border-width: 2; \n"
"}\n"
"\n"
".button:active {\n"
" background-color: shade (@bg_color, 0.7);\n"
" border-style: inset; \n"
"}\n"
"\n"
".button:prelight,\n"
".slider:prelight {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
" border-color: shade (@selected_bg_color, 0.7);\n"
"}\n"
"\n"
".trough {\n"
" background-color: darker (@bg_color);\n"
" border-style: inset;\n"
" border-width: 1;\n"
" padding: 0;\n"
"}\n"
"\n"
".entry {\n"
" border-style: inset;\n"
" border-width: 2;\n"
" background-color: @base_color;\n"
" color: @text_color;\n"
"}\n"
"\n"
".entry:insensitive {\n"
" background-color: shade (@base_color, 0.9);\n"
" color: shade (@base_color, 0.7);\n"
"}\n"
".entry:active {\n"
" background-color: #c4c2bd;\n"
" color: #000;\n"
"}\n"
"\n"
".progressbar,\n"
".entry.progressbar, \n"
".cell.progressbar {\n"
" background-color: @selected_bg_color;\n"
" border-color: shade (@selected_bg_color, 0.7);\n"
" color: @selected_fg_color;\n"
" border-style: outset;\n"
" border-width: 1;\n"
"}\n"
"\n"
"GtkCheckButton:hover,\n"
"GtkCheckButton:selected,\n"
"GtkRadioButton:hover,\n"
"GtkRadioButton:selected {\n"
" background-color: shade (@bg_color, 1.05);\n"
"}\n"
"\n"
".check, .radio,"
".cell.check, .cell.radio,\n"
".cell.check:hover, .cell.radio:hover {\n"
" border-style: solid;\n"
" border-width: 1;\n"
" background-color: @base_color;\n"
" border-color: @fg_color;\n"
"}\n"
"\n"
".check:active, .radio:active,\n"
".check:hover, .radio:hover {\n"
" background-color: @base_color;\n"
" border-color: @fg_color;\n"
" color: @text_color;\n"
"}\n"
"\n"
".check:selected, .radio:selected {\n"
" background-color: darker (@bg_color);\n"
" color: @selected_fg_color;\n"
" border-color: @selected_fg_color;\n"
"}\n"
"\n"
".check:selected:focused, .radio:selected:focused {\n"
" background-color: @selected_bg_color;\n"
"}\n"
"\n"
".menuitem.check, .menuitem.radio {\n"
" color: @fg_color;\n"
" border-style: none;\n"
" border-width: 0;\n"
"}\n"
"\n"
".popup {\n"
" border-style: outset;\n"
" border-width: 1;\n"
"}\n"
"\n"
".viewport {\n"
" border-style: inset;\n"
" border-width: 2;\n"
"}\n"
"\n"
".notebook {\n"
" border-style: outset;\n"
" border-width: 1;\n"
"}\n"
"\n"
".frame {\n"
" border-style: inset;\n"
" border-width: 1;\n"
"}\n"
"\n"
"GtkScrolledWindow.frame {\n"
" padding: 0;\n"
"}\n"
"\n"
".menu,\n"
".menubar,\n"
".toolbar {\n"
" border-style: outset;\n"
" border-width: 1;\n"
"}\n"
"\n"
".menu:hover,\n"
".menubar:hover,\n"
".menuitem:hover,\n"
".menuitem.check:hover,\n"
".menuitem.radio:hover {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
"GtkSpinButton.button {\n"
" border-width: 1;\n"
"}\n"
"\n"
".scale.slider:hover,\n"
"GtkSpinButton.button:hover {\n"
" background-color: shade (@bg_color, 1.05);\n"
" border-color: shade (@bg_color, 0.8);\n"
"}\n"
"\n"
"GtkSwitch.trough:active {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
"GtkToggleButton.button:inconsistent {\n"
" border-style: outset;\n"
" border-width: 1px;\n"
" background-color: shade (@bg_color, 0.9);\n"
" border-color: shade (@bg_color, 0.7);\n"
"}\n"
"\n"
"GtkLabel:selected {\n"
" background-color: shade (@bg_color, 0.9);\n"
"}\n"
"\n"
"GtkLabel:selected:focused {\n"
" background-color: @selected_bg_color;\n"
"}\n"
"\n"
".spinner:active {\n"
" transition: 750ms linear loop;\n"
"}\n"
"\n"
".info {\n"
" background-color: @info_bg_color;\n"
" color: @info_fg_color;\n"
"}\n"
"\n"
".warning {\n"
" background-color: @warning_bg_color;\n"
" color: @warning_fg_color;\n"
"}\n"
"\n"
".question {\n"
" background-color: @question_bg_color;\n"
" color: @question_fg_color;\n"
"}\n"
"\n"
".error {\n"
" background-color: @error_bg_color;\n"
" color: @error_fg_color;\n"
"}\n"
"\n"
".highlight {\n"
" background-color: @selected_bg_color;\n"
" color: @selected_fg_color;\n"
"}\n"
"\n"
".light-area-focus {\n"
" color: #000;\n"
"}\n"
"\n"
".dark-area-focus {\n"
" color: #fff;\n"
"}\n"
"GtkCalendar.view {\n"
" border-width: 1;\n"
" border-style: inset;\n"
" padding: 1;\n"
"}\n"
"\n"
"GtkCalendar.view:inconsistent {\n"
" color: darker (@bg_color);\n"
"}\n"
"\n"
"GtkCalendar.header {\n"
" background-color: @bg_color;\n"
" border-style: outset;\n"
" border-width: 2;\n"
"}\n"
"\n"
"GtkCalendar.highlight {\n"
" border-width: 0;\n"
"}\n"
"\n"
"GtkCalendar.button {\n"
" background-color: @bg_color;\n"
"}\n"
"\n"
"GtkCalendar.button:hover {\n"
" background-color: lighter (@bg_color);\n"
" color: @fg_color;\n"
"}\n"
"\n"
".menu * {\n"
" border-width: 0;\n"
" padding: 2;\n"
"}\n"
"\n";
provider = gtk_css_provider_new ();
if (!gtk_css_provider_load_from_data (provider, str, -1, NULL))
if (!_gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/gtk-default.css"))
{
g_error ("Failed to load the internal default CSS.");
}

View File

@ -122,6 +122,7 @@
#include "gtkmodulesprivate.h"
#include "gtkprivate.h"
#include "gtkrecentmanager.h"
#include "gtkresources.h"
#include "gtkselectionprivate.h"
#include "gtksettingsprivate.h"
#include "gtktooltip.h"
@ -709,6 +710,8 @@ do_post_parse_initialization (int *argc,
g_warning ("Whoever translated default:LTR did so wrongly.\n");
}
_gtk_register_resource ();
/* do what the call to gtk_type_init() used to do */
g_type_init ();