From e966a21544f0d4958c62c40ff7874d0eba023118 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Tue, 09 Aug 2011 13:23:40 +0000 Subject: Initial GTK3 theme that is just a copy of the gnome Adwaita theme. --- diff --git a/Makefile.am b/Makefile.am index 4f78c3a..ea51bb2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS = cursor icons gtk +SUBDIRS = cursor icons gtk gtk3 diff --git a/configure.ac b/configure.ac index 3295310..55d4ff5 100644 --- a/configure.ac +++ b/configure.ac @@ -22,10 +22,14 @@ if test -z "$ICON_SLICER"; then AC_MSG_ERROR([icon-slicer is required]) fi -PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.0.0,, +PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.16.0,, AC_MSG_ERROR([GTK+-2.0 is required to compile sugar-artwork])) -PKG_CHECK_MODULES(ENGINE, gtk+-2.0 >= 2.0 gobject-2.0 >= 2.0 cairo >= 0.1.1) +PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.0.0,, + AC_MSG_ERROR([GTK+-3.0 is required to compile sugar-artwork])) + +PKG_CHECK_MODULES(ENGINE, gtk+-2.0 >= 2.16 gobject-2.0 >= 2.0 cairo >= 0.1.1) +PKG_CHECK_MODULES(ENGINE3, gtk+-3.0 >= 3.0 gobject-2.0 >= 2.0 cairo >= 0.1.1) GTK_VERSION=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0` AC_SUBST(GTK_VERSION) @@ -63,4 +67,8 @@ icons/scalable/status/Makefile gtk/Makefile gtk/engine/Makefile gtk/theme/Makefile +gtk3/Makefile +gtk3/engine/Makefile +gtk3/theme/Makefile +gtk3/theme/assets/Makefile ]) diff --git a/gtk3/Makefile.am b/gtk3/Makefile.am new file mode 100644 index 0000000..bda97ca --- /dev/null +++ b/gtk3/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = engine theme \ No newline at end of file diff --git a/gtk3/engine/Makefile.am b/gtk3/engine/Makefile.am new file mode 100644 index 0000000..c4b5c57 --- /dev/null +++ b/gtk3/engine/Makefile.am @@ -0,0 +1,17 @@ +enginedir = $(libdir)/gtk-3.0/$(GTK_VERSION)/theming-engines +engine_LTLIBRARIES = libsugar.la + +INCLUDES = \ + $(ENGINE3_CFLAGS) + +libsugar_la_SOURCES = \ + sugar_utils.h \ + sugar_utils.c \ + sugar_engine.c + +libsugar_la_LDFLAGS = -module -avoid-version -no-undefined -export-symbols $(top_srcdir)/gtk3/engine/engine.symbols +libsugar_la_LIBADD = $(ENGINE3_LIBS) + +EXTRA_DIST = engine.symbols + +-include $(top_srcdir)/git.mk diff --git a/gtk3/engine/engine.symbols b/gtk3/engine/engine.symbols new file mode 100644 index 0000000..6ad8c2e --- /dev/null +++ b/gtk3/engine/engine.symbols @@ -0,0 +1,4 @@ +g_module_check_init +theme_init +theme_exit +create_engine diff --git a/gtk3/engine/sugar_engine.c b/gtk3/engine/sugar_engine.c new file mode 100644 index 0000000..710efc0 --- /dev/null +++ b/gtk3/engine/sugar_engine.c @@ -0,0 +1,1667 @@ +/* Adwaita - a GTK+ engine + * + * Copyright (C) 2011 Carlos Garnacho + * Copyright (C) 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Carlos Garnacho + * Cosimo Cecchi + * + * Project contact: + */ + +#include +#include +#include +#include + +#include "sugar_utils.h" + +#define ADWAITA_NAMESPACE "sugar" + +typedef struct _AdwaitaEngine AdwaitaEngine; +typedef struct _AdwaitaEngineClass AdwaitaEngineClass; + +struct _AdwaitaEngine +{ + GtkThemingEngine parent_object; +}; + +struct _AdwaitaEngineClass +{ + GtkThemingEngineClass parent_class; +}; + +#define ADWAITA_TYPE_ENGINE (sugar_engine_get_type ()) +#define ADWAITA_ENGINE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ADWAITA_TYPE_ENGINE, AdwaitaEngine)) +#define ADWAITA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ADWAITA_TYPE_ENGINE, AdwaitaEngineClass)) +#define ADWAITA_IS_ENGINE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ADWAITA_TYPE_ENGINE)) +#define ADWAITA_IS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ADWAITA_TYPE_ENGINE)) +#define ADWAITA_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ADWAITA_TYPE_ENGINE, AdwaitaEngineClass)) + +GType sugar_engine_get_type (void) G_GNUC_CONST; +void sugar_engine_register_types (GTypeModule *module); + +G_DEFINE_DYNAMIC_TYPE (AdwaitaEngine, sugar_engine, GTK_TYPE_THEMING_ENGINE) + +void +sugar_engine_register_types (GTypeModule *module) +{ + sugar_engine_register_type (module); +} + +static void +sugar_engine_init (AdwaitaEngine *self) +{ +} + +static void +sugar_engine_render_arrow (GtkThemingEngine *engine, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size) +{ + double line_width; + GtkStateFlags state; + GdkRGBA color; + + cairo_save (cr); + + line_width = size / 3.0 / sqrt (2); + cairo_set_line_width (cr, line_width); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + + cairo_translate (cr, x + size / 2.0, y + size / 2.0); + cairo_rotate (cr, angle - G_PI_2); + cairo_translate (cr, size / 4.0, 0); + + cairo_scale (cr, + (size / (size + line_width)), + (size / (size + line_width))); + + cairo_move_to (cr, -size / 2.0, -size / 2.0); + cairo_rel_line_to (cr, size / 2.0, size / 2.0); + cairo_rel_line_to (cr, - size / 2.0, size / 2.0); + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_color (engine, state, &color); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) && + !(state & GTK_STATE_FLAG_INSENSITIVE) && !(state & GTK_STATE_FLAG_PRELIGHT)) + { + GdkRGBA *arrow_color; + + gtk_theming_engine_get (engine, state, + "-sugar-menuitem-arrow-color", &arrow_color, + NULL); + + if (arrow_color != NULL) + color = *arrow_color; + + gdk_rgba_free (arrow_color); + } + + gdk_cairo_set_source_rgba (cr, &color); + cairo_stroke (cr); + + cairo_restore (cr); +} + +static void +sugar_engine_render_focus (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkRGBA *fill_color, *border_color = NULL; + cairo_pattern_t *pattern = NULL; + GtkStateFlags state; + gint line_width, focus_pad; + gint border_radius; + gboolean use_dashes; + double dashes[2] = { 2.0, 0.2 }; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get (engine, state, + "-sugar-focus-border-color", &border_color, + "-sugar-focus-fill-color", &fill_color, + "-sugar-focus-border-radius", &border_radius, + "-sugar-focus-border-gradient", &pattern, + "-sugar-focus-border-dashes", &use_dashes, + NULL); + + gtk_theming_engine_get_style (engine, + "focus-line-width", &line_width, + "focus-padding", &focus_pad, + NULL); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) && + gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL)) + { + /* as we render the tab smaller than the whole allocation, we need + * to recenter and resize the focus on the tab. + */ + y += 3.0; + height -= 3.0; + } + + cairo_save (cr); + cairo_set_line_width (cr, line_width); + + if (line_width > 1) + _cairo_round_rectangle_sides (cr, border_radius, + x, y, width, height, + SIDE_ALL, GTK_JUNCTION_NONE); + else + _cairo_round_rectangle_sides (cr, border_radius, + x + 0.5, y + 0.5, + width - 1, height - 1, + SIDE_ALL, GTK_JUNCTION_NONE); + + /* if we have a fill color, draw the fill */ + if (fill_color != NULL) + { + gdk_cairo_set_source_rgba (cr, fill_color); + cairo_fill_preserve (cr); + } + + if (use_dashes) + cairo_set_dash (cr, dashes, 1, 0.0); + + /* if we have a gradient, draw the gradient, otherwise + * draw the line if we have a color for it. + */ + if (pattern != NULL) + { + style_pattern_set_matrix (pattern, width, height, FALSE); + cairo_set_source (cr, pattern); + } + else if (border_color != NULL) + { + gdk_cairo_set_source_rgba (cr, border_color); + } + + cairo_stroke (cr); + cairo_restore (cr); + + if (pattern != NULL) + cairo_pattern_destroy (pattern); + + if (border_color != NULL) + gdk_rgba_free (border_color); + + if (fill_color != NULL) + gdk_rgba_free (fill_color); +} + +static void +render_check_menuitem (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkRGBA color; + GtkStateFlags state; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_color (engine, state, &color); + + if (!(state & GTK_STATE_FLAG_ACTIVE)) + return; + + cairo_save (cr); + + cairo_translate (cr, x, y); + + cairo_set_line_width (cr, 2.0); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + + cairo_move_to (cr, 0.5 + (width * 0.08), (height * 0.67)); + cairo_line_to (cr, 0.5 + (width * 0.32), (height * 0.90)); + cairo_line_to (cr, 0.5 + (width * 0.80), (height * 0.33)); + + gdk_cairo_set_source_rgba (cr, &color); + cairo_stroke (cr); + + cairo_restore (cr); +} + +static void +sugar_engine_render_check (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + gboolean res; + + if (gtk_theming_engine_has_class (engine, + GTK_STYLE_CLASS_MENUITEM)) + { + render_check_menuitem (engine, cr, + x, y, width, height); + + return; + } + + res = sugar_render_from_assets_common (engine, cr, + x, y + 2.0, width, height); + + if (!res) + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_check + (engine, cr, x, y, width, height); +} + +static void +render_radio_menuitem (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkRGBA color; + GtkStateFlags state; + double radius; + + state = gtk_theming_engine_get_state (engine); + + if (!(state & GTK_STATE_FLAG_ACTIVE)) + return; + + gtk_theming_engine_get_color (engine, state, &color); + + radius = MAX (height / 2.0, width / 2.0) * 0.58; + + cairo_save (cr); + + cairo_translate (cr, x + width / 2.0, y + height * 0.67); + cairo_arc (cr, + 0, 0, + radius, + 0, 4 * G_PI); + + gdk_cairo_set_source_rgba (cr, &color); + cairo_fill (cr); + + cairo_restore (cr); +} + +static void +sugar_engine_render_option (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + gboolean res; + + if (gtk_theming_engine_has_class (engine, + GTK_STYLE_CLASS_MENUITEM)) + { + render_radio_menuitem (engine, cr, x, y, width, height); + return; + } + + res = sugar_render_from_assets_common (engine, cr, + x, y + 2.0, width, height); + + if (!res) + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_option + (engine, cr, x, y, width, height); +} + +static void +draw_tab_arcs (cairo_t *cr, + gdouble curve_width, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + cairo_arc (cr, + curve_width, 6.0, + 2.5, + G_PI, G_PI + G_PI_2); + + cairo_arc (cr, + width - curve_width, 6.0, + 2.5, + G_PI + G_PI_2, 2 * G_PI); +} + +static void +draw_tab_shape_active (cairo_t *cr, + gdouble curve_width, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + cairo_move_to (cr, 0, height); + + draw_tab_arcs (cr, curve_width, x, y, width, height); + + cairo_line_to (cr, width, height); +} + +static void +render_notebook_extension (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side) +{ + gint tab_curvature; + GdkRGBA *color, border_color, background_color; + GtkStateFlags state; + gdouble angle = 0; + cairo_pattern_t *pattern = NULL, *background_pattern = NULL; + cairo_matrix_t matrix; + + gtk_theming_engine_get_style (engine, + "tab-curvature", &tab_curvature, + NULL); + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_background_color (engine, state, &background_color); + gtk_theming_engine_get_border_color (engine, state, &border_color); + gtk_theming_engine_get (engine, state, + "-sugar-selected-tab-color", &color, + "-sugar-border-gradient", &pattern, + "background-image", &background_pattern, + NULL); + + cairo_save (cr); + cairo_set_line_width (cr, 1.0); + + if (gap_side == GTK_POS_TOP) + { + angle = G_PI; + cairo_translate (cr, width, height); + } + + if (gap_side == GTK_POS_BOTTOM) + cairo_translate (cr, + x + 0.5, + (state & GTK_STATE_FLAG_ACTIVE) ? + y + 1.0 : y); + else if (gap_side == GTK_POS_TOP) + cairo_translate (cr, + x - 0.5, + (state & GTK_STATE_FLAG_ACTIVE) ? + y - 1.0 : y); + + cairo_rotate (cr, angle); + + width -= 1.0; + draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height); + + if (background_pattern != NULL) + { + cairo_matrix_init_scale (&matrix, + 1. / width, + 1. / height); + cairo_pattern_set_matrix (background_pattern, &matrix); + cairo_set_source (cr, background_pattern); + } + else + { + gdk_cairo_set_source_rgba (cr, &background_color); + } + + cairo_fill (cr); + + if (state & GTK_STATE_FLAG_ACTIVE) + { + draw_tab_shape_active (cr, tab_curvature, 0, 0, width, 6.0); + gdk_cairo_set_source_rgba (cr, color); + cairo_fill (cr); + } + + draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height); + + if (state & GTK_STATE_FLAG_ACTIVE) + { + style_pattern_set_matrix (pattern, width, height - 6.0, FALSE); + cairo_set_source (cr, pattern); + } + else + { + gdk_cairo_set_source_rgba (cr, &border_color); + } + + cairo_stroke (cr); + + gdk_rgba_free (color); + + if (pattern != NULL) + cairo_pattern_destroy (pattern); + + if (background_pattern != NULL) + cairo_pattern_destroy (background_pattern); + + cairo_restore (cr); +} + +static void +sugar_engine_render_extension (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side) +{ + GtkStateFlags state; + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) && + ((gap_side == GTK_POS_TOP) || (gap_side == GTK_POS_BOTTOM))) + { + render_notebook_extension (engine, cr, x, y, width, height, gap_side); + return; + } + + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_extension + (engine, cr, + x, y, width, height, + gap_side); + + state = gtk_theming_engine_get_state (engine); + + if (state & GTK_STATE_FLAG_ACTIVE) + { + GdkRGBA *fill; + + gtk_theming_engine_get (engine, state, + "-sugar-selected-tab-color", &fill, + NULL); + + switch (gap_side) + { + case GTK_POS_BOTTOM: + cairo_rectangle (cr, + x + 1, y + 1, + width - 2, 3); + break; + case GTK_POS_TOP: + cairo_rectangle (cr, + x + 1, y + height - 4, + width - 2, 3); + break; + case GTK_POS_RIGHT: + cairo_rectangle (cr, + x + 1, y + 1, + 3, height - 2); + break; + case GTK_POS_LEFT: + cairo_rectangle (cr, + x + width - 4, y + 1, + 3, height - 2); + break; + } + + gdk_cairo_set_source_rgba (cr, fill); + cairo_fill (cr); + + gdk_rgba_free (fill); + } +} + +static void +draw_menu_bar_item_shape (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble w, + gdouble h, + gboolean for_fill) +{ + /* draw a round rectangle without the bottom side */ + cairo_move_to (cr, x+radius, y); + cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2); + cairo_line_to (cr, x+w, y+h); + + if (for_fill) + cairo_line_to (cr, x, y+h); + else + cairo_move_to (cr, x, y+h); + + cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5); +} + +static void +render_menubar_active_frame (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble w, + gdouble h) +{ + GtkStateFlags state; + GdkRGBA color; + gint radius, border_width; + GtkBorder border; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_border_color (engine, state, &color); + gtk_theming_engine_get_border (engine, state, &border); + gtk_theming_engine_get (engine, state, + "border-radius", &radius, + NULL); + + border_width = MIN (MIN (border.top, border.bottom), + MIN (border.left, border.right)); + + if (border_width > 1) + { + x += (gdouble) border_width / 2; + y += (gdouble) border_width / 2; + w -= border_width; + h -= border_width; + } + else if (border_width == 1) + { + x += 0.5; + y += 0.5; + w -= 1; + h -= 1; + } + + cairo_save (cr); + + cairo_set_line_width (cr, border_width); + draw_menu_bar_item_shape (cr, radius, x, y, w, h, FALSE); + + gdk_cairo_set_source_rgba (cr, &color); + cairo_stroke (cr); + + cairo_restore (cr); +} + +static void +render_frame_default (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + cairo_pattern_t *pattern = NULL; + GtkStateFlags state; + GtkBorder border; + gint border_radius; + GtkBorderStyle border_style; + GtkJunctionSides junctions; + + state = gtk_theming_engine_get_state (engine); + + gtk_theming_engine_get (engine, state, + "-sugar-border-gradient", &pattern, + "border-style", &border_style, + NULL); + + if (pattern == NULL || border_style == GTK_BORDER_STYLE_NONE) + { + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_frame + (engine, cr, + x, y, width, height); + + return; + } + + cairo_save (cr); + + gtk_theming_engine_get (engine, state, + "border-radius", &border_radius, + NULL); + gtk_theming_engine_get_border (engine, state, &border); + junctions = gtk_theming_engine_get_junction_sides (engine); + + style_pattern_set_matrix (pattern, width, height, TRUE); + + _cairo_uneven_frame (cr, border_radius, + x, y, width, height, + &border, junctions); + cairo_set_source (cr, pattern); + + cairo_fill (cr); + + cairo_restore (cr); + + cairo_pattern_destroy (pattern); +} + +static void +sugar_engine_render_frame (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + const GtkWidgetPath *path; + GtkRegionFlags flags = 0; + gint len; + GtkStateFlags state; + + state = gtk_theming_engine_get_state (engine); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) + { + render_menubar_active_frame (engine, cr, x, y, width, height); + return; + } + + path = gtk_theming_engine_get_path (engine); + len = gtk_widget_path_length (path); + + cairo_save (cr); + + if (gtk_widget_path_iter_has_region (path, len - 2, + GTK_STYLE_REGION_COLUMN_HEADER, + &flags)) + { + GdkRGBA color; + + if ((flags & GTK_REGION_LAST) != 0) + goto out; + + /* Column header */ + if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL) + { + cairo_move_to (cr, x + 0.5, y + 2); + cairo_line_to (cr, x + 0.5, y + height - 4); + } + else + { + cairo_move_to (cr, x + width - 0.5, y + 2); + cairo_line_to (cr, x + width - 0.5, y + height - 4); + } + + gtk_theming_engine_get_border_color (engine, state, &color); + + cairo_set_line_width (cr, 1); + gdk_cairo_set_source_rgba (cr, &color); + cairo_stroke (cr); + } + else + { + sugar_trim_allocation_for_scale (engine, + &x, &y, + &width, &height); + render_frame_default (engine, cr, x, y, width, height); + } + +out: + cairo_restore (cr); +} + +static void +render_menubar_active_background (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble w, + gdouble h) +{ + GtkStateFlags state; + GdkRGBA color; + gint radius; + GtkBorder border; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_border_color (engine, state, &color); + gtk_theming_engine_get_border (engine, state, &border); + gtk_theming_engine_get (engine, state, + "border-radius", &radius, + NULL); + + gtk_theming_engine_get_background_color (engine, state, &color); + + /* omit all the border but the bottom line */ + x += border.left; + y += border.top; + w -= border.left + border.right; + h -= border.top; + + cairo_save (cr); + cairo_translate (cr, x, y); + + draw_menu_bar_item_shape (cr, radius, 0, 0, w, h, TRUE); + + gdk_cairo_set_source_rgba (cr, &color); + cairo_fill (cr); + + cairo_restore (cr); +} + +static void +render_inset_lines (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags state; + GtkBorder border; + GdkRGBA *inset_left, *inset_right, *inset_top, *inset_bottom; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_border (engine, state, &border); + + gtk_theming_engine_get (engine, state, + "-sugar-inset-left", &inset_left, + "-sugar-inset-right", &inset_right, + "-sugar-inset-top", &inset_top, + "-sugar-inset-bottom", &inset_bottom, + NULL); + + cairo_save (cr); + cairo_set_line_width (cr, 1.0); + + if (inset_left != NULL) + { + cairo_move_to (cr, + x + border.left + 0.5, + y + border.top + 1.0); + cairo_line_to (cr, + x + border.left + 1, + y + height - border.bottom - 1.0); + + gdk_cairo_set_source_rgba (cr, inset_left); + cairo_stroke (cr); + + gdk_rgba_free (inset_left); + } + + if (inset_right != NULL) + { + cairo_move_to (cr, + x + width - border.right - 0.5, + y + border.top + 1.0); + cairo_line_to (cr, + x + width - border.right - 0.5, + y + height - border.bottom - 1.0); + + gdk_cairo_set_source_rgba (cr, inset_right); + cairo_stroke (cr); + + gdk_rgba_free (inset_right); + } + + if (inset_top != NULL) + { + cairo_move_to (cr, + x + border.left + 1.0, + y + border.top + 0.5); + cairo_line_to (cr, + x + width - border.right - 1.0, + y + border.top + 0.5); + + gdk_cairo_set_source_rgba (cr, inset_top); + cairo_stroke (cr); + + gdk_rgba_free (inset_top); + } + + if (inset_bottom != NULL) + { + cairo_move_to (cr, + x + border.left + 1.0, + y + height - border.bottom - 0.5); + cairo_line_to (cr, + x + width - border.right - 1.0, + y + height - border.bottom - 0.5); + + gdk_cairo_set_source_rgba (cr, inset_bottom); + cairo_stroke (cr); + + gdk_rgba_free (inset_bottom); + } + + cairo_restore (cr); +} + +static void +sugar_engine_render_background (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) + { + render_menubar_active_background (engine, cr, x, y, width, height); + return; + } + + sugar_trim_allocation_for_scale (engine, + &x, &y, + &width, &height); + + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_background + (engine, cr, x, y, + width, height); + + render_inset_lines (engine, cr, x, y, width, height); +} + +static void +sugar_engine_render_expander (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkRGBA fg; + GtkStateFlags state; + gdouble side, offset; + gint line_width; + GtkBorder border; + + side = floor (MIN (width, height)); + + /* make sure the side length is always odd */ + if (((gint) side % 2) == 0) + side -= 1.0; + + x += width / 2 - side / 2; + y += height / 2 - side / 2; + + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_background + (engine, cr, x, y, side, side); + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_frame + (engine, cr, x, y, side, side); + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_color (engine, state, &fg); + gtk_theming_engine_get_border (engine, state, &border); + + line_width = 1; + offset = (1 + line_width / 2.0); + + cairo_save (cr); + + cairo_set_line_width (cr, line_width); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, + x + border.left + offset, + y + side / 2); + cairo_line_to (cr, + x + side - (border.right + offset), + y + side / 2); + + if ((state & GTK_STATE_FLAG_ACTIVE) == 0) + { + cairo_move_to (cr, + x + side / 2, + y + border.top + offset); + cairo_line_to (cr, + x + side / 2, + y + side - (border.bottom + offset)); + } + + cairo_stroke (cr); + + cairo_restore (cr); +} + +static void +sugar_engine_render_activity (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags state; + + cairo_save (cr); + state = gtk_theming_engine_get_state (engine); + + sugar_trim_allocation_for_scale (engine, + &x, &y, + &width, &height); + + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_activity + (engine, cr, + x, y, width, height); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR)) + { + cairo_pattern_t *pattern = NULL; + + gtk_theming_engine_get (engine, state, + "-sugar-progressbar-pattern", &pattern, + NULL); + + if (pattern != NULL) + { + style_pattern_set_matrix (pattern, 20, 20, TRUE); + cairo_rectangle (cr, x, y, width, height); + cairo_set_source (cr, pattern); + cairo_fill (cr); + + cairo_pattern_destroy (pattern); + } + } + + cairo_restore (cr); + + render_inset_lines (engine, cr, x, y, width, height); +} + +static void +draw_round_slider (cairo_t *cr, + gdouble width, + gdouble height) +{ + cairo_arc (cr, (width) / 2.0, (height) / 2.0, + MIN (height / 2.0, width / 2.0) - 0.5, + 0, 2 * G_PI); + cairo_close_path (cr); +} + +static void +draw_mark_slider (cairo_t *cr, + gdouble width, + gdouble height, + gboolean marks_below, + GtkOrientation orientation) +{ + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + + if (marks_below) + { + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + cairo_move_to (cr, 0, height / 2.0 + 3.0); + cairo_arc (cr, 2.5, 3.5, + 2.0, + G_PI, G_PI + G_PI_2); + + cairo_arc (cr, width - 2.5, 3.5, + 2.0, + G_PI + G_PI_2, 2 * G_PI); + + cairo_line_to (cr, width, height / 2.0 + 3.0); + cairo_line_to (cr, width / 2.0, height); + cairo_line_to (cr, 0, height / 2.0 + 3.0); + + cairo_close_path (cr); + } + else + { + cairo_move_to (cr, width / 2.0, 0); + cairo_arc (cr, width - 2.5, 2.5, + 2.0, + G_PI + G_PI_2, 2 * G_PI); + + cairo_arc (cr, width - 2.5, height - 2.5, + 2.0, + 0, G_PI_2); + + cairo_line_to (cr, width / 2.0, height); + cairo_line_to (cr, 0, height / 2.0); + cairo_line_to (cr, width / 2.0, 0); + + cairo_close_path (cr); + } + } + else + { + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + cairo_move_to (cr, width, height / 2.0 - 3.0); + cairo_arc (cr, width - 2.5, height - 3.5, + 2.0, + 0, G_PI_2); + + cairo_arc (cr, 2.5, height - 3.5, + 2.0, + G_PI_2, G_PI); + + cairo_line_to (cr, 0, height / 2.0 - 3.0); + cairo_line_to (cr, width / 2.0, 0); + cairo_line_to (cr, width, height / 2.0 - 3.0); + + cairo_close_path (cr); + } + else + { + cairo_move_to (cr, width / 2.0, height); + cairo_arc (cr, 2.5, height - 2.5, + 2.0, + G_PI_2, G_PI); + + cairo_arc (cr, 2.5, 2.5, + 2.0, + G_PI, G_PI + G_PI_2); + + cairo_line_to (cr, width / 2.0, 0); + cairo_line_to (cr, width, height / 2.0); + cairo_line_to (cr, width / 2.0, height); + + cairo_close_path (cr); + } + } +} + +static void +render_switch_lines (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + GtkStateFlags state; + GdkRGBA *lines_color; + + state = gtk_theming_engine_get_state (engine); + + if (state & GTK_STATE_FLAG_INSENSITIVE) + return; + + gtk_theming_engine_get (engine, state, + "-sugar-switch-grip-color", &lines_color, + NULL); + + cairo_save (cr); + + cairo_translate (cr, + x + width / 2.0 - 4.0, + y + height / 2.0 - 3.0); + + cairo_move_to (cr, 0.0, 0.0); + cairo_set_line_width (cr, 2.0); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + + cairo_line_to (cr, 0.0, 6.0); + cairo_move_to (cr, 4.0, 0.0); + cairo_line_to (cr, 4.0, 6.0); + cairo_move_to (cr, 8.0, 0.0); + cairo_line_to (cr, 8.0, 6.0); + + gdk_cairo_set_source_rgba (cr, lines_color); + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_rgba_free (lines_color); +} + +static void +sugar_engine_render_slider (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + const GtkWidgetPath *path; + + path = gtk_theming_engine_get_path (engine); + cairo_save (cr); + + if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE)) + { + cairo_pattern_t *pattern, *border_pattern; + GtkStateFlags state; + GdkRGBA color; + gboolean marks_above = FALSE, marks_below = FALSE; + + if (gtk_theming_engine_has_class + (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE)) + marks_above = TRUE; + else if (gtk_theming_engine_has_class + (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW)) + marks_below = TRUE; + + cairo_translate (cr, x, y); + + if ((marks_above && marks_below) || + (!marks_above && !marks_below)) + draw_round_slider (cr, width, height); + else + draw_mark_slider (cr, width, height, marks_below, orientation); + + state = gtk_theming_engine_get_state (engine); + cairo_set_line_width (cr, 1.0); + + gtk_theming_engine_get (engine, state, + "background-image", &pattern, + NULL); + + if (pattern != NULL) + { + style_pattern_set_matrix (pattern, width, height, FALSE); + cairo_set_source (cr, pattern); + } + else + { + gtk_theming_engine_get_background_color (engine, state, &color); + gdk_cairo_set_source_rgba (cr, &color); + } + + cairo_fill_preserve (cr); + + gtk_theming_engine_get (engine, state, + "-sugar-border-gradient", &border_pattern, + NULL); + + if (border_pattern != NULL) + { + style_pattern_set_matrix (border_pattern, width, height, FALSE); + cairo_set_source (cr, border_pattern); + } + else + { + gtk_theming_engine_get_border_color (engine, state, &color); + gdk_cairo_set_source_rgba (cr, &color); + } + + cairo_stroke (cr); + + if (pattern != NULL) + cairo_pattern_destroy (pattern); + + if (border_pattern != NULL) + cairo_pattern_destroy (border_pattern); + } + else + { + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_slider + (engine, cr, + x, y, width, height, + orientation); + + render_inset_lines (engine, cr, x, y, width, height); + + if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH)) + render_switch_lines (engine, cr, x, y, width, height, orientation); + } + + cairo_restore (cr); +} + +static void +sugar_engine_render_handle (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP)) + { + GdkRGBA bg; + GtkJunctionSides sides; + GtkStateFlags state; + int lx, ly; + int x_down; + int y_down; + int dots; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_background_color (engine, state, &bg); + + /* The number of dots fitting into the area. Just hardcoded to 3 right now. */ + /* dots = MIN (width - 2, height - 2) / 3; */ + dots = 3; + + cairo_save (cr); + + sides = gtk_theming_engine_get_junction_sides (engine); + + switch (sides) + { + case GTK_JUNCTION_CORNER_TOPRIGHT: + x_down = 0; + y_down = 0; + cairo_translate (cr, x + width - 4*dots, y + 1); + break; + case GTK_JUNCTION_CORNER_BOTTOMRIGHT: + x_down = 0; + y_down = 1; + cairo_translate (cr, x + width - 4*dots, y + height + 1 - 4*dots); + break; + case GTK_JUNCTION_CORNER_BOTTOMLEFT: + x_down = 1; + y_down = 1; + cairo_translate (cr, x + 2, y + height + 1 - 4*dots); + break; + case GTK_JUNCTION_CORNER_TOPLEFT: + x_down = 1; + y_down = 0; + cairo_translate (cr, x + 2, y + 1); + break; + default: + /* Not implemented. */ + return; + } + + for (lx = 0; lx < dots; lx++) /* horizontally */ + { + for (ly = 0; ly <= lx; ly++) /* vertically */ + { + int mx, my; + mx = x_down * dots + (1 - x_down * 2) * lx - x_down; + my = y_down * dots + (1 - y_down * 2) * ly - y_down; + + gdk_cairo_set_source_rgba (cr, &bg); + cairo_arc (cr, + mx * 4 - 1 + 1.5, + my * 4 - 1 + 1.5, + 1.5, + 0, G_PI * 2.0); + + cairo_fill (cr); + } + } + + cairo_restore (cr); + } + else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR)) + { + GdkRGBA fg; + GtkStateFlags state; + gdouble xx, yy; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_color (engine, state, &fg); + + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_background + (engine, cr, x, y, width, height); + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_frame + (engine, cr, x, y, width, height); + + cairo_save (cr); + cairo_set_line_width (cr, 2.0); + gdk_cairo_set_source_rgba (cr, &fg); + + if (width > height) + { + for (xx = x + width / 2 - 12; xx <= x + width / 2 + 12; xx += 6) + { + cairo_arc (cr, xx, y + height / 2.0, + 1.0, + 0, G_PI * 2.0); + cairo_fill (cr); + } + } + else + { + for (yy = y + height / 2 - 12; yy <= y + height / 2 + 12; yy += 6) + { + cairo_arc (cr, x + width / 2.0, yy, + 1.0, + 0, G_PI * 2.0); + cairo_fill (cr); + } + } + + cairo_restore (cr); + } + else + { + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_handle + (engine, cr, + x, y, width, height); + } +} + +/* taken from gtkthemingengine.c */ +static GdkPixbuf * +scale_or_ref (GdkPixbuf *src, + gint width, + gint height) +{ + if (width == gdk_pixbuf_get_width (src) && + height == gdk_pixbuf_get_height (src)) + return g_object_ref (src); + else + return gdk_pixbuf_scale_simple (src, + width, height, + GDK_INTERP_BILINEAR); +} + +static gboolean +lookup_icon_size (GtkThemingEngine *engine, + GtkIconSize size, + gint *width, + gint *height) +{ + GdkScreen *screen; + GtkSettings *settings; + + screen = gtk_theming_engine_get_screen (engine); + settings = gtk_settings_get_for_screen (screen); + + return gtk_icon_size_lookup_for_settings (settings, size, width, height); +} + +/* Kudos to the gnome-panel guys. */ +static void +colorshift_pixbuf (GdkPixbuf *src, + GdkPixbuf *dest, + gint shift) +{ + gint i, j; + gint width, height, has_alpha, src_rowstride, dest_rowstride; + guchar *target_pixels; + guchar *original_pixels; + guchar *pix_src; + guchar *pix_dest; + int val; + guchar r, g, b; + + has_alpha = gdk_pixbuf_get_has_alpha (src); + width = gdk_pixbuf_get_width (src); + height = gdk_pixbuf_get_height (src); + src_rowstride = gdk_pixbuf_get_rowstride (src); + dest_rowstride = gdk_pixbuf_get_rowstride (dest); + original_pixels = gdk_pixbuf_get_pixels (src); + target_pixels = gdk_pixbuf_get_pixels (dest); + + for (i = 0; i < height; i++) + { + pix_dest = target_pixels + i * dest_rowstride; + pix_src = original_pixels + i * src_rowstride; + + for (j = 0; j < width; j++) + { + r = *(pix_src++); + g = *(pix_src++); + b = *(pix_src++); + + val = r + shift; + *(pix_dest++) = CLAMP (val, 0, 255); + + val = g + shift; + *(pix_dest++) = CLAMP (val, 0, 255); + + val = b + shift; + *(pix_dest++) = CLAMP (val, 0, 255); + + if (has_alpha) + *(pix_dest++) = *(pix_src++); + } + } +} + +static GdkPixbuf * +sugar_engine_render_icon_pixbuf (GtkThemingEngine *engine, + const GtkIconSource *source, + GtkIconSize size) +{ + GdkPixbuf *base_pixbuf; + GdkPixbuf *scaled; + GdkPixbuf *stated; + GtkStateFlags state; + gint width = 1; + gint height = 1; + + cairo_surface_t *stated_surface; + cairo_t *cr; + + base_pixbuf = gtk_icon_source_get_pixbuf (source); + state = gtk_theming_engine_get_state (engine); + + g_return_val_if_fail (base_pixbuf != NULL, NULL); + + if (size != (GtkIconSize) -1 && + !lookup_icon_size (engine, size, &width, &height)) + { + g_warning (G_STRLOC ": invalid icon size '%d'", size); + return NULL; + } + + /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise, + * leave it alone. + */ + if (size != (GtkIconSize) -1 && + gtk_icon_source_get_size_wildcarded (source)) + scaled = scale_or_ref (base_pixbuf, width, height); + else + scaled = g_object_ref (base_pixbuf); + + /* If the state was wildcarded, then generate a state. */ + if (gtk_icon_source_get_state_wildcarded (source)) + { + if (state & GTK_STATE_FLAG_INSENSITIVE) + { + /* dim the pixbuf with a 0.5 alpha black layer */ + stated_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, + gdk_pixbuf_get_width (scaled), + gdk_pixbuf_get_height (scaled)); + cr = cairo_create (stated_surface); + + gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0); + cairo_paint (cr); + + cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5); + cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN); + cairo_paint (cr); + + stated = gdk_pixbuf_get_from_surface (stated_surface, + 0, 0, + cairo_image_surface_get_width (stated_surface), + cairo_image_surface_get_height (stated_surface)); + + g_object_unref (scaled); + cairo_destroy (cr); + cairo_surface_destroy (stated_surface); + } + else if (state & GTK_STATE_FLAG_PRELIGHT) + { + stated = gdk_pixbuf_copy (scaled); + colorshift_pixbuf (scaled, stated, 30); + g_object_unref (scaled); + } + else + { + stated = scaled; + } + } + else + { + stated = scaled; + } + + return stated; +} + +static void +sugar_engine_render_line (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + const GtkWidgetPath *path; + + path = gtk_theming_engine_get_path (engine); + + if ((gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MARK) && + gtk_widget_path_is_type (path, GTK_TYPE_SCALE)) || + (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR) && + gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW))) + { + GtkStateFlags state; + GdkRGBA bg; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_background_color (engine, state, &bg); + + cairo_save (cr); + + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); + cairo_set_line_width (cr, 1); + + cairo_move_to (cr, x0 + 0.5, y0 + 0.5); + cairo_line_to (cr, x1 + 0.5, y1 + 0.5); + + gdk_cairo_set_source_rgba (cr, &bg); + cairo_stroke (cr); + + cairo_restore (cr); + } + else + { + GTK_THEMING_ENGINE_CLASS (sugar_engine_parent_class)->render_line + (engine, cr, + x0, y0, x1, y1); + } +} + +static void +sugar_engine_class_init (AdwaitaEngineClass *klass) +{ + GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass); + + engine_class->render_arrow = sugar_engine_render_arrow; + engine_class->render_focus = sugar_engine_render_focus; + engine_class->render_check = sugar_engine_render_check; + engine_class->render_option = sugar_engine_render_option; + engine_class->render_extension = sugar_engine_render_extension; + engine_class->render_frame = sugar_engine_render_frame; + engine_class->render_background = sugar_engine_render_background; + engine_class->render_expander = sugar_engine_render_expander; + engine_class->render_activity = sugar_engine_render_activity; + engine_class->render_slider = sugar_engine_render_slider; + engine_class->render_handle = sugar_engine_render_handle; + engine_class->render_icon_pixbuf = sugar_engine_render_icon_pixbuf; + engine_class->render_line = sugar_engine_render_line; + + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("focus-border-color", + "Focus border color", + "Focus border color", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_int ("focus-border-radius", + "Focus border radius", + "Focus border radius", + 0, G_MAXINT, 0, + 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("focus-border-gradient", + "Focus border gradient", + "Focus border gradient", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("focus-fill-color", + "Focus fill color", + "Focus fill color", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("selected-tab-color", + "Selected tab color", + "Selected tab color", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("border-gradient", + "Border gradient", + "Border gradient", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boolean ("focus-border-dashes", + "Focus border uses dashes", + "Focus border uses dashes", + FALSE, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("menuitem-arrow-color", + "Menuitem arrow color", + "Menuitem arrow color", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("switch-grip-color", + "Switch grip color", + "Switch grip color", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("inset-left", + "Inset line left", + "Inset line left", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("inset-right", + "Inset line right", + "Inset line right", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("inset-top", + "Inset line top", + "Inset line top", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("inset-bottom", + "Inset line bottom", + "Inset line bottom", + GDK_TYPE_RGBA, 0)); + gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL, + g_param_spec_boxed ("progressbar-pattern", + "Progressbar pattern", + "Progressbar pattern", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); +} + +static void +sugar_engine_class_finalize (AdwaitaEngineClass *klass) +{ +} + +G_MODULE_EXPORT void +theme_init (GTypeModule *module) +{ + sugar_engine_register_types (module); +} + +G_MODULE_EXPORT void +theme_exit (void) +{ +} + +G_MODULE_EXPORT GtkThemingEngine * +create_engine (void) +{ + return GTK_THEMING_ENGINE (g_object_new (ADWAITA_TYPE_ENGINE, + "name", "sugar", + NULL)); +} diff --git a/gtk3/engine/sugar_utils.c b/gtk3/engine/sugar_utils.c new file mode 100644 index 0000000..a1814c1 --- /dev/null +++ b/gtk3/engine/sugar_utils.c @@ -0,0 +1,246 @@ +/* Adwaita - a GTK+ engine + * + * Copyright (C) 2011 Carlos Garnacho + * Copyright (C) 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Carlos Garnacho + * Cosimo Cecchi + * + * Project contact: + */ + +#include "sugar_utils.h" + +void +sugar_trim_allocation_for_scale (GtkThemingEngine *engine, + gdouble *x, + gdouble *y, + gdouble *width, + gdouble *height) +{ + const GtkWidgetPath *path; + + path = gtk_theming_engine_get_path (engine); + + if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) && + (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH) || + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))) + { + /* Render GtkScale trough thinner */ + if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL)) + { + *y += *height / 2.0 - 2.0; + *height = 4; + } + else + { + *x += *width / 2.0 - 2.0; + *width = 4; + } + } +} + +void +_cairo_round_rectangle_sides (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + guint sides, + GtkJunctionSides junction) +{ + radius = CLAMP (radius, 0, MIN (width / 2, height / 2)); + + if (sides & SIDE_RIGHT) + { + if (radius == 0 || + (junction & GTK_JUNCTION_CORNER_TOPRIGHT)) + cairo_move_to (cr, x + width, y); + else + { + cairo_new_sub_path (cr); + cairo_arc (cr, x + width - radius, y + radius, radius, - G_PI / 4, 0); + } + + if (radius == 0 || + (junction & GTK_JUNCTION_CORNER_BOTTOMRIGHT)) + cairo_line_to (cr, x + width, y + height); + else + cairo_arc (cr, x + width - radius, y + height - radius, radius, 0, G_PI / 4); + } + + if (sides & SIDE_BOTTOM) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_CORNER_BOTTOMRIGHT)) + { + if ((sides & SIDE_RIGHT) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + width - radius, y + height - radius, radius, G_PI / 4, G_PI / 2); + } + else if ((sides & SIDE_RIGHT) == 0) + cairo_move_to (cr, x + width, y + height); + + if (radius == 0 || + (junction & GTK_JUNCTION_CORNER_BOTTOMLEFT)) + cairo_line_to (cr, x, y + height); + else + cairo_arc (cr, x + radius, y + height - radius, radius, G_PI / 2, 3 * (G_PI / 4)); + } + else + cairo_move_to (cr, x, y + height); + + if (sides & SIDE_LEFT) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_CORNER_BOTTOMLEFT)) + { + if ((sides & SIDE_BOTTOM) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + radius, y + height - radius, radius, 3 * (G_PI / 4), G_PI); + } + else if ((sides & SIDE_BOTTOM) == 0) + cairo_move_to (cr, x, y + height); + + if (radius == 0 || + (junction & GTK_JUNCTION_CORNER_TOPLEFT)) + cairo_line_to (cr, x, y); + else + cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI + G_PI / 4); + } + + if (sides & SIDE_TOP) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_CORNER_TOPLEFT)) + { + if ((sides & SIDE_LEFT) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + radius, y + radius, radius, 5 * (G_PI / 4), 3 * (G_PI / 2)); + } + else if ((sides & SIDE_LEFT) == 0) + cairo_move_to (cr, x, y); + + if (radius == 0 || + (junction & GTK_JUNCTION_CORNER_TOPRIGHT)) + cairo_line_to (cr, x + width, y); + else + cairo_arc (cr, x + width - radius, y + radius, radius, 3 * (G_PI / 2), - G_PI / 4); + } +} + +void +_cairo_uneven_frame (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkBorder *border, + GtkJunctionSides junction) +{ + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + cairo_set_line_width (cr, 1); + + _cairo_round_rectangle_sides (cr, (gdouble) radius, + x, y, + width, height, + SIDE_ALL, junction); + + _cairo_round_rectangle_sides (cr, (gdouble) radius, + x + border->left, + y + border->top, + width - border->left - border->right, + height - border->top - border->bottom, + SIDE_ALL, junction); +} + +/* Set the appropriate matrix for + * patterns coming from the style context + */ +void +style_pattern_set_matrix (cairo_pattern_t *pattern, + gdouble width, + gdouble height, + gboolean repeat) +{ + cairo_matrix_t matrix; + gint w, h; + + if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE) + { + cairo_surface_t *surface; + + cairo_pattern_get_surface (pattern, &surface); + w = cairo_image_surface_get_width (surface); + h = cairo_image_surface_get_height (surface); + } + else + w = h = 1; + + cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height); + cairo_pattern_set_matrix (pattern, &matrix); + + if (repeat) + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); +} + +gboolean +sugar_render_from_assets_common (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + gboolean retval = FALSE; + GtkStateFlags state; + cairo_pattern_t *asset = NULL; + cairo_surface_t *surface = NULL; + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get (engine, state, + "background-image", &asset, + NULL); + + if (asset != NULL) + cairo_pattern_get_surface (asset, &surface); + + if (surface != NULL) + { + cairo_save (cr); + + cairo_set_source_surface (cr, surface, x, y); + cairo_scale (cr, + width / cairo_image_surface_get_width (surface), + height / cairo_image_surface_get_height (surface)); + + cairo_paint (cr); + + cairo_restore (cr); + retval = TRUE; + } + + if (asset != NULL) + cairo_pattern_destroy (asset); + + return retval; +} diff --git a/gtk3/engine/sugar_utils.h b/gtk3/engine/sugar_utils.h new file mode 100644 index 0000000..6d80d67 --- /dev/null +++ b/gtk3/engine/sugar_utils.h @@ -0,0 +1,80 @@ +/* Adwaita - a GTK+ engine + * + * Copyright (C) 2011 Carlos Garnacho + * Copyright (C) 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Carlos Garnacho + * Cosimo Cecchi + * + * Project contact: + */ + +#include + +#ifndef __ADWAITA_UTILS_H__ +#define __ADWAITA_UTILS_H__ + +enum { + SIDE_LEFT = 1, + SIDE_BOTTOM = 1 << 1, + SIDE_RIGHT = 1 << 2, + SIDE_TOP = 1 << 3, + SIDE_ALL = 0xF +}; + +gboolean +sugar_render_from_assets_common (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); + +void +sugar_trim_allocation_for_scale (GtkThemingEngine *engine, + gdouble *x, + gdouble *y, + gdouble *width, + gdouble *height); + +void +style_pattern_set_matrix (cairo_pattern_t *pattern, + gdouble width, + gdouble height, + gboolean repeat); + +void +_cairo_uneven_frame (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkBorder *border, + GtkJunctionSides junction); + +void +_cairo_round_rectangle_sides (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + guint sides, + GtkJunctionSides junction); + +#endif /* __ADWAITA_UTILS_H__ */ diff --git a/gtk3/theme/Makefile.am b/gtk3/theme/Makefile.am new file mode 100644 index 0000000..9f1ea5e --- /dev/null +++ b/gtk3/theme/Makefile.am @@ -0,0 +1,14 @@ +SUBDIRS = assets + +themedir = $(datadir)/themes/sugar/gtk-3.0 +theme_DATA = \ + gtk.css \ + gtk-dark.css \ + gtk-widgets.css \ + gtk-widgets-assets.css \ + gtk-widgets-assets-dark.css \ + settings.ini + +EXTRA_DIST = $(theme_DATA) + +-include $(top_srcdir)/git.mk diff --git a/gtk3/theme/assets/Makefile.am b/gtk3/theme/assets/Makefile.am new file mode 100644 index 0000000..ce4d43b --- /dev/null +++ b/gtk3/theme/assets/Makefile.am @@ -0,0 +1,24 @@ +assetsdir = $(datadir)/themes/Adwaita/gtk-3.0/assets +assets_DATA = \ + checkbox-checked.svg \ + checkbox-checked-dark.svg \ + checkbox-checked-insensitive.svg \ + checkbox-checked-insensitive-dark.svg \ + checkbox-unchecked.svg \ + checkbox-unchecked-dark.svg \ + checkbox-unchecked-insensitive.svg \ + checkbox-unchecked-insensitive-dark.svg \ + checkbox-mixed.svg \ + checkbox-mixed-dark.svg \ + radio-selected.svg \ + radio-selected-dark.svg \ + radio-selected-insensitive.svg \ + radio-selected-insensitive-dark.svg \ + radio-unselected.svg \ + radio-unselected-dark.svg \ + radio-unselected-insensitive.svg \ + radio-unselected-insensitive-dark.svg \ + radio-mixed.svg \ + radio-mixed-dark.svg + +EXTRA_DIST = $(assets_DATA) \ No newline at end of file diff --git a/gtk3/theme/assets/checkbox-checked-dark.svg b/gtk3/theme/assets/checkbox-checked-dark.svg new file mode 100644 index 0000000..40e88b5 --- /dev/null +++ b/gtk3/theme/assets/checkbox-checked-dark.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-checked-insensitive-dark.svg b/gtk3/theme/assets/checkbox-checked-insensitive-dark.svg new file mode 100644 index 0000000..0bc65b8 --- /dev/null +++ b/gtk3/theme/assets/checkbox-checked-insensitive-dark.svg @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-checked-insensitive.svg b/gtk3/theme/assets/checkbox-checked-insensitive.svg new file mode 100644 index 0000000..326d133 --- /dev/null +++ b/gtk3/theme/assets/checkbox-checked-insensitive.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-checked-scalable.svg b/gtk3/theme/assets/checkbox-checked-scalable.svg new file mode 100644 index 0000000..f2492f1 --- /dev/null +++ b/gtk3/theme/assets/checkbox-checked-scalable.svg @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-checked.svg b/gtk3/theme/assets/checkbox-checked.svg new file mode 100644 index 0000000..f2492f1 --- /dev/null +++ b/gtk3/theme/assets/checkbox-checked.svg @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-mixed-dark.svg b/gtk3/theme/assets/checkbox-mixed-dark.svg new file mode 100644 index 0000000..d94482a --- /dev/null +++ b/gtk3/theme/assets/checkbox-mixed-dark.svg @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-mixed.svg b/gtk3/theme/assets/checkbox-mixed.svg new file mode 100644 index 0000000..ff8ee97 --- /dev/null +++ b/gtk3/theme/assets/checkbox-mixed.svg @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-unchecked-dark.svg b/gtk3/theme/assets/checkbox-unchecked-dark.svg new file mode 100644 index 0000000..759b1bb --- /dev/null +++ b/gtk3/theme/assets/checkbox-unchecked-dark.svg @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-unchecked-insensitive-dark.svg b/gtk3/theme/assets/checkbox-unchecked-insensitive-dark.svg new file mode 100644 index 0000000..982c566 --- /dev/null +++ b/gtk3/theme/assets/checkbox-unchecked-insensitive-dark.svg @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-unchecked-insensitive.svg b/gtk3/theme/assets/checkbox-unchecked-insensitive.svg new file mode 100644 index 0000000..d5a6bd6 --- /dev/null +++ b/gtk3/theme/assets/checkbox-unchecked-insensitive.svg @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/gtk3/theme/assets/checkbox-unchecked.svg b/gtk3/theme/assets/checkbox-unchecked.svg new file mode 100644 index 0000000..42760cb --- /dev/null +++ b/gtk3/theme/assets/checkbox-unchecked.svg @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-mixed-dark.svg b/gtk3/theme/assets/radio-mixed-dark.svg new file mode 100644 index 0000000..e33a89a --- /dev/null +++ b/gtk3/theme/assets/radio-mixed-dark.svg @@ -0,0 +1,426 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-mixed.svg b/gtk3/theme/assets/radio-mixed.svg new file mode 100644 index 0000000..5a5658f --- /dev/null +++ b/gtk3/theme/assets/radio-mixed.svg @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-selected-dark.svg b/gtk3/theme/assets/radio-selected-dark.svg new file mode 100644 index 0000000..caafcc9 --- /dev/null +++ b/gtk3/theme/assets/radio-selected-dark.svg @@ -0,0 +1,539 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-selected-insensitive-dark.svg b/gtk3/theme/assets/radio-selected-insensitive-dark.svg new file mode 100644 index 0000000..5e5768a --- /dev/null +++ b/gtk3/theme/assets/radio-selected-insensitive-dark.svg @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-selected-insensitive.svg b/gtk3/theme/assets/radio-selected-insensitive.svg new file mode 100644 index 0000000..09eb693 --- /dev/null +++ b/gtk3/theme/assets/radio-selected-insensitive.svg @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-selected.svg b/gtk3/theme/assets/radio-selected.svg new file mode 100644 index 0000000..178c4b3 --- /dev/null +++ b/gtk3/theme/assets/radio-selected.svg @@ -0,0 +1,350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-unselected-dark.svg b/gtk3/theme/assets/radio-unselected-dark.svg new file mode 100644 index 0000000..f614fa9 --- /dev/null +++ b/gtk3/theme/assets/radio-unselected-dark.svg @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-unselected-insensitive-dark.svg b/gtk3/theme/assets/radio-unselected-insensitive-dark.svg new file mode 100644 index 0000000..c7ca7dd --- /dev/null +++ b/gtk3/theme/assets/radio-unselected-insensitive-dark.svg @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-unselected-insensitive.svg b/gtk3/theme/assets/radio-unselected-insensitive.svg new file mode 100644 index 0000000..2c7c606 --- /dev/null +++ b/gtk3/theme/assets/radio-unselected-insensitive.svg @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/gtk3/theme/assets/radio-unselected.svg b/gtk3/theme/assets/radio-unselected.svg new file mode 100644 index 0000000..7cf1539 --- /dev/null +++ b/gtk3/theme/assets/radio-unselected.svg @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/gtk3/theme/gtk-dark.css b/gtk3/theme/gtk-dark.css new file mode 100644 index 0000000..afe7131 --- /dev/null +++ b/gtk3/theme/gtk-dark.css @@ -0,0 +1,107 @@ +/* dark colormap */ + +@define-color theme_base_color #333333; +@define-color theme_text_color #ddddde; +@define-color theme_bg_color #222222; +@define-color theme_fg_color @theme_text_color; +@define-color theme_selected_bg_color #f57900; +@define-color theme_selected_fg_color #ffffff; + +@define-color menu_bg_color shade (@theme_bg_color, 0.4); +@define-color menu_fg_color #ffffff; + +@define-color theme_tooltip_bg_color #000000; +@define-color theme_tooltip_fg_color #eeeeee; + +@define-color button_gradient_color_a #363636; +@define-color button_gradient_color_b #222222; +@define-color button_border #111111; + +@define-color button_active_gradient_color_a #000000; +@define-color button_active_gradient_color_b shade (@button_active_gradient_color_a, 0.93); + +@define-color button_hover_gradient_color_a shade (@button_gradient_color_a, 1.07); +@define-color button_hover_gradient_color_b @theme_base_color; + +@define-color insensitive_bg_color #0b0b0d; +@define-color insensitive_fg_color #585458; +@define-color insensitive_border_color shade (@internal_element_color, 0.70); + +@define-color inactive_frame_color shade (@theme_bg_color, 1.19); + +@define-color notebook_border #111111; +@define-color notebook_active_tab_border alpha (@theme_selected_bg_color, 1.0); +@define-color notebook_selected_tab_color alpha (@theme_selected_bg_color, 0.75); + +@define-color notebook_tab_gradient_a shade (@button_gradient_color_a, 0.8); +@define-color notebook_tab_gradient_b shade (@button_gradient_color_b, 0.8); + +@define-color switch_slider_color #111113; +@define-color switch_slider_border #a5b8cc; + +@define-color highlighted_border @button_border; +@define-color internal_element_color #77757a; + +@define-color progressbar_background_a alpha (@theme_fg_color, 0.70); +@define-color progressbar_background_b alpha (@theme_fg_color, 0.45); +@define-color progressbar_border alpha (@theme_fg_color, 0.60); +@define-color progressbar_pattern #000000; + +@define-color focused_entry_border @theme_selected_bg_color; +@define-color focused_entry_inset alpha (@theme_selected_bg_color, 0.50); + +@define-color toolbar_gradient_base #080808; +@define-color toolbar_gradient_step1 #0a0a0a; +@define-color toolbar_gradient_step2 #111111; +@define-color toolbar_gradient_final #151515; + +@define-color toolbar_active_button_color #222222; + +@define-color expander_row_selected_color alpha (@theme_base_color, 0.60); + +@define-color menu_controls_color #aaa8ac; + +@define-color keyboard_focus_border_a alpha (@theme_fg_color, 0.30); +@define-color keyboard_focus_border_b alpha (@theme_fg_color, 0.10); + +@define-color trough_bg_color_a #000000; +@define-color trough_bg_color_b #111111; + +@define-color frame_color #756a7f; + +@define-color active_switch_bg_color_a shade (@theme_selected_bg_color, 0.85); +@define-color active_switch_bg_color_b @theme_selected_bg_color; + +@define-color scale_fill shade (@insensitive_border_color, 0.90); +@define-color scale_border_a shade (@internal_element_color, 0.90); +@define-color scale_border_b shade (@internal_element_color, 0.65); + +/* FIXME: needs dark colors from here */ +@define-color link_color #4a90d9; +@define-color warning_color #f57900; +@define-color error_color #cc0000; +@define-color success_color #4e9a06; + +@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); + +@define-color os_chrome_bg_color black; +@define-color os_chrome_fg_color #ccc; +@define-color os_chrome_selected_bg_color #333; +@define-color os_chrome_selected_fg_color white; + +@define-color chrome_bg_color #1e1a17; +@define-color chrome_fg_color #fff; + +@define-color scale_progress_fill #2c85e2; +@define-color scale_progress_border #1864b2; +@define-color scale_progress_border_b #3e90e5; + +@import url("gtk-widgets-assets-dark.css"); +@import url("gtk-widgets.css"); diff --git a/gtk3/theme/gtk-widgets-assets-dark.css b/gtk3/theme/gtk-widgets-assets-dark.css new file mode 100644 index 0000000..9a5ddee --- /dev/null +++ b/gtk3/theme/gtk-widgets-assets-dark.css @@ -0,0 +1,66 @@ +/************************* + * Check and Radio items * + *************************/ + +/* draw regular check and radio items using our SVG assets */ +.check, +.check row:selected, +.check row:selected:focused { + background-image: url ("assets/checkbox-unchecked-dark.svg"); +} + +.check:insensitive, +.check row:selected:insensitive, +.check row:selected:focused:insensitive { + background-image: url ("assets/checkbox-unchecked-insensitive-dark.svg"); +} + +.check:active, +.check row:selected:active, +.check row:selected:focused:active { + background-image: url ("assets/checkbox-checked-dark.svg"); +} + +.check:active:insensitive, +.check row:selected:active:insensitive, +.check row:selected:focused:active:insensitive +{ + background-image: url ("assets/checkbox-checked-insensitive-dark.svg"); +} + +.check:inconsistent, +.check row:selected:inconsistent, +.check row:selected:focused:inconsistent { + background-image: url ("assets/checkbox-mixed-dark.svg"); +} + +.radio, +.radio row:selected, +.radio row:selected:focused { + background-image: url ("assets/radio-unselected-dark.svg"); +} + +.radio:insensitive, +.radio row:selected:insensitive, +.radio row:selected:focused:insensitive { + background-image: url ("assets/radio-unselected-insensitive-dark.svg"); +} + +.radio:active, +.radio row:selected:active, +.radio row:selected:focused:active { + background-image: url ("assets/radio-selected-dark.svg"); +} + +.radio:active:insensitive, +.radio row:selected:active:insensitive, +.radio row:selected:focused:active:insensitive { + background-image: url ("assets/radio-selected-insensitive-dark.svg"); +} + +.radio:inconsistent, +.radio row:selected:inconsistent, +.radio row:selected:focused:inconsistent { + background-image: url ("assets/radio-mixed-dark.svg"); +} + diff --git a/gtk3/theme/gtk-widgets-assets.css b/gtk3/theme/gtk-widgets-assets.css new file mode 100644 index 0000000..a1bc8e7 --- /dev/null +++ b/gtk3/theme/gtk-widgets-assets.css @@ -0,0 +1,65 @@ +/************************* + * Check and Radio items * + *************************/ + +/* draw regular check and radio items using our SVG assets */ +.check, +.check row:selected, +.check row:selected:focused { + background-image: url ("assets/checkbox-unchecked.svg"); +} + +.check:insensitive, +.check row:selected:insensitive, +.check row:selected:focused:insensitive { + background-image: url ("assets/checkbox-unchecked-insensitive.svg"); +} + +.check:active, +.check row:selected:active, +.check row:selected:focused:active { + background-image: url ("assets/checkbox-checked.svg"); +} + +.check:active:insensitive, +.check row:selected:active:insensitive, +.check row:selected:focused:active:insensitive +{ + background-image: url ("assets/checkbox-checked-insensitive.svg"); +} + +.check:inconsistent, +.check row:selected:inconsistent, +.check row:selected:focused:inconsistent { + background-image: url ("assets/checkbox-mixed.svg"); +} + +.radio, +.radio row:selected, +.radio row:selected:focused { + background-image: url ("assets/radio-unselected.svg"); +} + +.radio:insensitive, +.radio row:selected:insensitive, +.radio row:selected:focused:insensitive { + background-image: url ("assets/radio-unselected-insensitive.svg"); +} + +.radio:active, +.radio row:selected:active, +.radio row:selected:focused:active { + background-image: url ("assets/radio-selected.svg"); +} + +.radio:active:insensitive, +.radio row:selected:active:insensitive, +.radio row:selected:focused:active:insensitive { + background-image: url ("assets/radio-selected-insensitive.svg"); +} + +.radio:inconsistent, +.radio row:selected:inconsistent, +.radio row:selected:focused:inconsistent { + background-image: url ("assets/radio-mixed.svg"); +} diff --git a/gtk3/theme/gtk-widgets.css b/gtk3/theme/gtk-widgets.css new file mode 100644 index 0000000..e93c29f --- /dev/null +++ b/gtk3/theme/gtk-widgets.css @@ -0,0 +1,1252 @@ +* { + engine: adwaita; + padding: 1; + + /* Style properties */ + -GtkToolButton-icon-spacing: 4; + + -GtkTextView-error-underline-color: @error_color; + + -GtkPaned-handle-size: 5; + + -GtkCheckButton-indicator-size: 16; + -GtkCheckMenuItem-indicator-size: 12; + + /* The size for scrollbars. The slider is 2px smaller, but we keep it + * up so that the whole area is sensitive to button presses for the + * slider. The stepper button is larger in both directions, the slider + * only in the width + */ + + -GtkScrolledWindow-scrollbar-spacing: 0; + -GtkScrolledWindow-scrollbars-within-bevel: 1; + + -GtkToolItemGroup-expander-size: 12; + -GtkExpander-expander-size: 12; + -GtkToolbar-internal-padding: 4; /* ??? */ + + -GtkMenu-horizontal-padding: 0; + -GtkMenu-vertical-padding: 0; + + -GtkWidget-link-color: @link_color; + -GtkWidget-visited-link-color: @link_color; + -GtkIMHtml-hyperlink-color: @link_color; + -GtkHTML-link-color: @link_color; + + -GtkWidget-wide-separators: 1; + + -WnckTasklist-fade-overlay-rect: 0; + + -GtkEntry-inner-border: 2; + -GtkEntry-progress-border: 0; + + /* Style */ + background-color: @theme_bg_color; + color: @theme_fg_color; + + -GtkWidget-focus-padding: 2; + -GtkWidget-focus-line-width: 1; + -adwaita-focus-border-color: alpha (@theme_text_color, 0.4); + -adwaita-focus-border-radius: 2; + -adwaita-focus-fill-color: none; + -adwaita-focus-border-gradient: none; + -adwaita-focus-border-dashes: 1; + + -adwaita-inset-left: none; + -adwaita-inset-right: none; + -adwaita-inset-top: none; + -adwaita-inset-bottom: none; +} + +/*************** + * Base States * + ***************/ +*:hover { + background-color: shade (@theme_bg_color, 1.02); + color: @theme_fg_color; +} + +*:selected { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; +} + +*:selected:focused { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; +} + +*:insensitive { + background-color: @insensitive_bg_color; + color: @insensitive_fg_color; + border-color: @insensitive_border_color; +} + +*:active { + background-color: shade (@theme_bg_color, 0.915); +} + +.background { + border-style: none; + border-width: 0; + border-radius: 0; +} + +.tooltip { + padding: 4 4; + border-style: none; + background-color: @theme_tooltip_bg_color; + color: @theme_tooltip_fg_color; +} + +.grip { + background-color: shade (@inactive_frame_color, 0.93); +} + +.rubberband { + background-color: alpha (@theme_selected_bg_color, 0.35); + border-color: @theme_selected_bg_color; + border-style: solid; + border-width: 1; + border-radius: 2; +} + +.pane-separator { + border-style: none; + border-width: 0; + color: shade (@inactive_frame_color, 0.80); +} + +.pane-separator:prelight, +.pane-separator:selected { + color: @theme_text_color; +} + +/**************** + * Text Entries * + ****************/ +.entry, +.toolbar.entry { + background-color: @theme_base_color; + background-image: none; + + border-radius: 2; + border-width: 1; + border-style: solid; + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@internal_element_color, 1.14)), + to (shade (@internal_element_color, 1.37))); + + padding: 3; + + -adwaita-inset-top: alpha (@switch_slider_color, 0.50); +} + +.entry:focused { + border-color: @focused_entry_border; + -adwaita-border-gradient: none; + + -adwaita-inset-top: @focused_entry_inset; +} + +.entry:insensitive { + background-color: @insensitive_bg_color; + -adwaita-border-gradient: none; + + -adwaita-inset-top: none; +} + +.entry.progressbar { + /* FIXME: need correct colors/gradient */ + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; + + border-width: 1; + border-radius: 1; + border-color: @progressbar_border; + + -adwaita-progressbar-pattern: none; +} + +/***************** + * GtkSpinButton * + *****************/ +.spinbutton, +.spinbutton:focused { + padding: 3 2; + + -adwaita-inset-top: none; +} + +.spinbutton.button, +.spinbutton.button:prelight, +.spinbutton.button:active { + color: @internal_element_color; + background-image: none; + background-color: @theme_base_color; + border-width: 1; + border-style: none; +} + +/**************** + * Progress bar * + ****************/ +.progressbar, +.progressbar row, +.progressbar row:hover, +.progressbar row:selected, +.progressbar row:selected:focused { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@progressbar_background_a), + to (@progressbar_background_b)); + + border-radius: 3; + border-style: solid; + border-width: 1; + border-color: @progressbar_border; + + -adwaita-inset-top: alpha (@theme_base_color, 0.20); + -adwaita-progressbar-pattern: -gtk-gradient (linear, + left top, right bottom, + from (alpha (@progressbar_pattern, 0.00)), + color-stop (0.49, alpha (@progressbar_pattern, 0.00)), + color-stop (0.50, alpha (@progressbar_pattern, 0.10)), + to (alpha (@progressbar_pattern, 0.10))); +} + +GtkProgressBar.trough, +.trough row, +.trough row:hover { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@trough_bg_color_a), + to (@trough_bg_color_b)); + + border-width: 1; + border-style: solid; + border-radius: 3; + border-color: shade (@inactive_frame_color, 0.925); +} + +.trough row:selected, +.trough row:selected:focused { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (mix (@trough_bg_color_a, @theme_selected_bg_color, 0.25)), + to (mix (@trough_bg_color_b, @theme_selected_bg_color, 0.25))); +} + +GtkProgressBar, +.trough row { + padding: 0; +} + +/************ + * GtkScale * + ************/ +GtkScale { + -GtkScale-slider-length: 16; + -GtkRange-slider-width: 22; + -GtkRange-trough-border: 0; +} + +GtkScale.slider { + border-width: 1; + border-radius: 3; + + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@theme_base_color), + to (@switch_slider_color)); + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@internal_element_color, 0.90)), + to (shade (@internal_element_color, 1.35))); +} + +GtkScale.slider:insensitive { + background-image: none; + -adwaita-border-gradient: none; +} + +GtkScale.scale-has-marks-below.slider.horizontal { + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@internal_element_color, 0.90)), + to (shade (@internal_element_color, 1.35))); +} + +GtkScale.scale-has-marks-below.slider.vertical { + -adwaita-border-gradient: -gtk-gradient (linear, + left top, right top, + from (shade (@internal_element_color, 0.90)), + to (shade (@internal_element_color, 1.35))); +} + +GtkScale.scale-has-marks-above.slider.horizontal { + -adwaita-border-gradient: -gtk-gradient (linear, + left bottom, left top, + from (shade (@internal_element_color, 0.90)), + to (shade (@internal_element_color, 1.35))); +} + +GtkScale.scale-has-marks-above.slider.vertical { + -adwaita-border-gradient: -gtk-gradient (linear, + right top, left top, + from (shade (@internal_element_color, 0.90)), + to (shade (@internal_element_color, 1.35))); +} + +GtkScale.trough { + border-width: 1; + border-radius: 2; + border-style: solid; + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (@scale_border_a), + to (@scale_border_b)); + background-color: @scale_fill; +} + +GtkScale.trough.horizontal { + -adwaita-inset-bottom: alpha (@theme_base_color, 0.50); +} + +GtkScale.trough.vertical { + -adwaita-inset-right: alpha (@theme_base_color, 0.50); +} + +GtkScale.trough:insensitive { + background-color: @insensitive_bg_color; + background-image: none; + + -adwaita-border-gradient: none; + -adwaita-inset-bottom: none; +} + +GtkScale.progressbar { + background-color: @scale_progress_fill; + + border-width: 1; + border-radius: 3; + border-style: solid; + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (@scale_progress_border_a), + to (@scale_progress_border_b)); + -adwaita-progressbar-pattern: none; +} + +GtkScale.mark { + background-color: shade (@theme_bg_color, 0.56); +} + +GtkFrame, +GtkCalendar { + padding: 2; +} + +.frame { + color: lighter (@theme_fg_color); + border-style: none; + border-width: 0; +} + +/***************** + * Notebooks and * + * tabs * + *****************/ +.notebook { + padding: 2; + + border-color: @notebook_border; + border-style: solid; + border-width: 1; + border-radius: 0; + + background-color: @theme_base_color; + + -GtkNotebook-tab-overlap: 8; + -GtkNotebook-tab-curvature: 6; +} + +.notebook tab { + padding: 3 8 0; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@notebook_tab_gradient_a), + to (@notebook_tab_gradient_b)); + + -adwaita-focus-border-radius: 2; +} + +.notebook tab:active { + border-width: 1; + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (@notebook_active_tab_border), + to (@notebook_border)); + + -adwaita-selected-tab-color: @notebook_selected_tab_color; + background-color: @theme_base_color; + background-image: none; +} + +.notebook tab .button, +.notebook tab .button:hover, +.notebook tab .button:hover:active { + border-style: none; + background-color: alpha (@theme_bg_color, 0.0); + background-image: none; +} + +/************** + * ComboBoxes * + **************/ + +GtkComboBox { + padding: 1 2; + + -GtkWidget-focus-padding: 0; + -GtkWidget-focus-line-width: 0; + + -GtkComboBox-arrow-scaling: 0.5; + -GtkComboBox-shadow-type: 2; +} + +GtkComboBox .button { + color: @internal_element_color; + padding: 1; +} + +GtkComboBox .button:prelight { + color: shade (@internal_element_color, 0.66); +} + +/************** + * Scrollbars * + **************/ + +.scrollbar { + background-image: none; + border-style: solid; + -GtkRange-trough-border: 2; + -GtkRange-arrow-scaling: 0.444; + -GtkRange-slider-width: 18; + -GtkRange-stepper-size: 18; + -GtkScrollbar-min-slider-length: 30; /* minimum size for the slider. sadly can't be in '.slider' where it belongs */ + + -GtkRange-stepper-spacing: 1; + -GtkRange-trough-under-steppers: 1; +} + +.scrollbar.trough { + background-image: none; + background-color: shade (@theme_bg_color, 0.882); + border-width: 0; + border-radius: 0; +} + +.scrollbar.slider, +.scrollbar.button { + background-image: none; + background-color: @theme_base_color; + border-color: @button_border; + border-radius: 3; + border-width: 1; +} + +.scrollbar.slider:prelight { + background-image: none; + background-color: @theme_base_color; + border-color: shade (@highlighted_border, 0.964); +} + +.scrollbar.slider:prelight:active { + background-image: none; + background-color: @theme_base_color; + border-color: @theme_selected_bg_color; +} + +.scrollbar.button { + color: @internal_element_color; +} + +.scrollbar.button:prelight { + background-image: none; + background-color: @theme_base_color; + border-color: shade (@highlighted_border, 0.964) +} + +.scrollbar.button:prelight:active { + background-image: none; + background-color: @theme_base_color; + border-color: shade (@highlighted_border, 0.964) +} + +.scrollbar.button:insensitive { + color: lighter (@internal_element_color); + background-color: @theme_base_color; +} + +.scrollbar.slider:insensitive { + background-color: @theme_base_color; +} + +.scrollbar.trough:insensitive { + background-color: shade (@theme_bg_color, 0.882); +} + +/*********** + * Buttons * + ***********/ +.button { + padding: 1 4; + + -adwaita-focus-fill-color: alpha (@theme_base_color, 0.35); + -adwaita-focus-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (alpha (@keyboard_focus_border_a, 0.62)), + to (alpha (@keyboard_focus_border_b, 0.62))); + -adwaita-focus-border-radius: 1; + -adwaita-focus-border-dashes: 0; + -GtkWidget-focus-line-width: 2; + + -GtkButton-child-displacement-x: 1; + -GtkButton-child-displacement-y: 1; + -GtkButton-image-spacing: 4; + -GtkButton-interior-focus: true; + -GtkButton-default-border: 0; + -GtkButton-inner-border: 0; + + border-radius: 2; + border-width: 1; + border-color: @button_border; + border-style: solid; + + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_gradient_color_a), + to (@button_gradient_color_b)); +} + +.button:hover, +.toolbar.button:hover { + border-color: @button_border; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_hover_gradient_color_a), + to (@button_hover_gradient_color_b)); +} + +.button:active, +.toolbar .button:active, +.button:hover:active, +.toolbar.button:hover:active { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_active_gradient_color_a), + to (alpha (@button_active_gradient_color_b, 0.13))); + border-color: @highlighted_border; +} + +.button:insensitive { + background-image: none; + background-color: @insensitive_bg_color; + color: @insensitive_fg_color; +} + +.button.default { + border-width: 2; + border-color: shade (@button_border, 1.10); +} + +/********* + * Menus * + *********/ + +* .menu { + background-color: @menu_bg_color; + color: @menu_fg_color; +} + +.menu { + border-style: solid; + border-width: 0; + border-radius: 0; + border-color: @inactive_frame_color; + + -GtkMenuItem-arrow-scaling: 0.4; +} + +/* this controls the general appearance of the menubar */ +.menubar { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@theme_bg_color), + color-stop (0.45, shade (@theme_bg_color, 0.97)), + to (shade (@theme_bg_color, 0.99))); + border-width: 0; + border-style: none; + padding: 4; + color: @theme_text_color; + + -GtkWidget-window-dragging: true; + -GtkMenuBar-internal-padding: 0; +} + +.menubar.menuitem { + border-width: 0; + border-style: none; + padding: 3 5; +} + +/* remove the image from the prelight areas */ +.menubar.menuitem:prelight { + background-image: none; + background-color: @menu_bg_color; + color: @menu_fg_color; + + border-style: solid; + border-radius: 5; + border-width: 0; + border-color: @inactive_frame_color; +} + +.menuitem:insensitive { + /* there is some weird alpha precomposing issues with this - ghosts on dark background */ + color: mix (@menu_fg_color, @menu_bg_color, 0.8); + background-color: shade (@menu_bg_color, 1.10); +} + +.menuitem { + -adwaita-menuitem-arrow-color: @menu_controls_color; + padding: 4; +} + +.menuitem.accelerator { + color: alpha (@menu_fg_color, 0.4); +} + +.menuitem.accelerator:prelight, +.menuitem.accelerator:active { + color: alpha (@menu_fg_color, 0.3); +} + +.menuitem:active, +.menuitem:prelight { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; + border-style: solid; + border-width: 0; + border-radius: 0; + border-color: darker (@theme_selected_bg_color); +} + +.menu.separator { + border-color: @inactive_frame_color; + + -GtkSeparatorMenuItem-horizontal-padding: 0; + -GtkWidget-separator-height: 1; +} + +/* menu radio and check items are drawn differently */ +.menu.check:active { + color: @menu_controls_color; +} + +.menu.radio:active { + color: @menu_controls_color; +} + +.menu.check:prelight { + color: @theme_selected_fg_color; +} + +.menu.radio:prelight { + color: @theme_selected_fg_color; +} + +/************ + * Toolbars * + ************/ +.toolbar { + border-style: solid; + border-color: darker (@theme_bg_color); + border-width: 1; + border-radius: 0; + padding: 1; +} + +.toolbar:insensitive { + color: alpha (@theme_fg_color, 0.6); +} + +/******************** + * Primary Toolbars * + ********************/ + +.primary-toolbar.toolbar { + background-image: -gtk-gradient (linear, + left top, + left bottom, + from (@toolbar_gradient_base), + color-stop (0.16, @toolbar_gradient_step1), + color-stop (0.90, @toolbar_gradient_step2), + to (@toolbar_gradient_final)); + border-width: 1 0 1 0; + border-radius: 0; + border-style: solid; + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@theme_bg_color, 0.56)), + to (shade (@theme_bg_color, 0.83))); + + padding: 2; + + -GtkWidget-window-dragging: true; + -GtkToolbar-button-relief: 0; +} + +.primary-toolbar.toolbar:insensitive { + background-image: none; + background-color: shade (@theme_bg_color, 0.97); + + border-style: solid; + border-width: 1 0 1 0; + -adwaita-border-gradient: none; + border-color: shade (@theme_bg_color, 0.91); +} + +/* primary toolbar buttons */ +.primary-toolbar.toolbar.button { + border-style: none; + border-width: 1; + border-radius: 4; + background-image: none; + background-color: alpha (@theme_base_color, 0.0); + + -adwaita-focus-border-radius: 3; + -adwaita-focus-fill-color: alpha (@theme_base_color, 0.20); + -adwaita-focus-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (alpha (shade (@toolbar_active_button_color, 1.25), 0.90)), + to (alpha (@toolbar_active_button_color, 0.62))); +} + +.primary-toolbar.toolbar.button:insensitive { + border-style: none; + border-width: 0; + + color: @insensitive_fg_color; + + background-image: none; + background-color: alpha (@theme_base_color, 0.0); + -GtkWidget-focus-line-width: 0; +} + +.primary-toolbar.toolbar.button:hover { + border-style: none; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (alpha (@theme_base_color, 0.0)), + color-stop (0.54, alpha (shade (@theme_base_color, 0.92), 0.49)), + to (alpha (@theme_base_color, 0.0))); +} + +.primary-toolbar.toolbar.button:active { + border-style: solid; + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@toolbar_active_button_color, 0.8)), + to (shade (@toolbar_active_button_color, 1.4))); + + background-image: -gtk-gradient (linear, + left top, left bottom, + from (shade (@toolbar_gradient_base, 0.95)), + to (alpha (shade (@toolbar_gradient_base, 0.85), 0.0))); + + color: @theme_fg_color; +} + +.primary-toolbar.toolbar.button:active:hover { + border-style: solid; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (alpha (shade (@toolbar_gradient_base, 0.96), 0.7)), + to (alpha (shade (@toolbar_gradient_base, 1.14), 0.0))); + + color: @theme_base_color; +} + +.primary-toolbar.toolbar.button:active:insensitive { + border-color: @insensitive_border_color; + + -adwaita-border-gradient: none; + background-image: none; +} + +.primary-toolbar.toolbar GtkSeparatorToolItem { + -GtkWidget-wide-separators: 1; + -GtkWidget-separator-width: 1; + + border-style: solid; + border-width: 1; + border-color: shade (@theme_bg_color, 0.56); + -adwaita-border-gradient: none; +} + +/* primary toolbar raised buttons */ +.primary-toolbar.toolbar.raised.button { + border-width: 1; + border-style: solid; + + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_gradient_color_a), + to (@button_gradient_color_b)); + + -GtkWidget-focus-line-width: 2; +} + +.primary-toolbar.toolbar.raised.button:insensitive { + background-image: none; +} + +.primary-toolbar.toolbar.raised.button:hover { + border-color: @button_border; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_hover_gradient_color_a), + to (@button_hover_gradient_color_b)); + border-width: 1; + border-style: solid; +} + +.primary-toolbar.toolbar.raised.button:hover:active, +.primary-toolbar.toolbar.raised.button:active { + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@button_active_gradient_color_a), + to (alpha (@button_active_gradient_color_b, 0.13))); + background-color: @theme_base_color; + + border-color: @highlighted_border; + border-width: 1; + border-style: solid; +} + +.primary-toolbar.toolbar.raised.button:insensitive:active { + border-style: solid; + border-width: 1; + background-image: none; +} + +/* progressbars on primary toolbar entries are special */ +.primary-toolbar.toolbar.entry.progressbar { + /* FIXME: need correct colors/gradient */ + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@trough_bg_color_a), + to (@trough_bg_color_b)); + + border-width: 0; + border-radius: 2; + border-color: shade (@inactive_frame_color, 0.925); + + color: @theme_text_color; + + -adwaita-progressbar-pattern: none; +} + +/******************* + * Inline toolbars * + *******************/ + +.inline-toolbar.toolbar { + border-width: 1; + border-radius: 3; + border-style: solid; + + background-image: -gtk-gradient (linear, + left top, + left bottom, + from (@toolbar_gradient_base), + color-stop (0.16, @toolbar_gradient_step1), + color-stop (0.90, @toolbar_gradient_step2), + color-stop (0.98, @toolbar_gradient_final), + color-stop (0.99, shade (@theme_bg_color, 0.83)), + to (shade (@theme_bg_color, 0.83))); +} + +/************* + * GtkSwitch * + *************/ + +GtkSwitch { + font: bold condensed 10; +} + +GtkSwitch.trough { + color: shade (@internal_element_color, 0.60); + border-radius: 1; + border-width: 1; + border-style: solid; + border-color: shade (@frame_color, 1.22); + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@trough_bg_color_a), + to (@trough_bg_color_b)); + + -adwaita-inset-bottom: alpha (@theme_base_color, 0.24); +} + +GtkSwitch.trough:active { + color: @theme_base_color; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@active_switch_bg_color_a), + to (@active_switch_bg_color_b)); + + -adwaita-border-gradient: -gtk-gradient (linear, + left top, left bottom, + from (shade (@theme_selected_bg_color, 0.70)), + to (shade (@theme_selected_bg_color, 0.94))); +} + +GtkSwitch.trough:insensitive { + background-image: none; + background-color: shade (@theme_bg_color, 0.9); + -adwaita-border-gradient: none; + + -adwaita-inset-bottom: none; +} + +GtkSwitch.slider { + border-width: 1; + border-radius: 1; + border-color: shade (@frame_color, 1.31); + border-style: solid; + padding: 2; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@theme_base_color), + to (@switch_slider_color)); + + -adwaita-switch-grip-color: shade (@switch_slider_color, 0.97); + + -adwaita-inset-top: @switch_slider_color; + -adwaita-inset-bottom: alpha (@theme_base_color, 0.50); +} + +GtkSwitch.slider:active { + border-color: @switch_slider_border; +} + +GtkSwitch.slider:insensitive { + border-style: none; + background-image: none; + background-color: @insensitive_bg_color; + + -adwaita-inset-top: none; + -adwaita-inset-bottom: none; +} + +GtkStatusbar { + padding: 5; + color: @theme_fg_color; + -GtkStatusbar-shadow-type: none; +} + +GtkScrolledWindow.frame { + border-style: solid; + border-color: darker (@theme_bg_color); + border-width: 1; + border-radius: 3; +} + +GtkViewport, +GtkIconView { + border-radius: 3; + padding: 0; +} + +GtkIconView.view.cell:selected, +GtkIconView.view.cell:selected:focused { + background-color: @theme_selected_bg_color; + border-radius: 4; + + /* FIXME: this probably needs to be better; + * see https://bugzilla.gnome.org/show_bug.cgi?id=644157 + */ + -adwaita-focus-border-color: @progressbar_border; + -adwaita-focus-border-radius: 3; + -adwaita-focus-border-dashes: 0; +} + +.view { + background-color: @theme_base_color; + color: @theme_fg_color; + border-radius: 0; + border-width: 3; +} + +GtkTreeView { + -GtkTreeView-vertical-separator: 0; + -GtkTreeView-expander-size: 9; + + -GtkWidget-focus-line-width: 1; + -adwaita-focus-border-radius: 0; + -adwaita-focus-border-dashes: 0; + -adwaita-focus-border-color: @keyboard_focus_border_a; +} + +GtkTreeView.separator { + background-color: darker (@theme_bg_color); +} + +column-header { + padding: 1 2; +} + +column-header .button { + border-width: 0; + border-radius: 0; +} + +row:hover { + border-width: 0; +} + +row:insensitive { + border-width: 0; +} + +row:selected:focused { + border-width: 0; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@progressbar_border), + color-stop (0.02, @progressbar_border), + color-stop (0.03, @theme_selected_bg_color), + color-stop (0.97, @theme_selected_bg_color), + color-stop (0.98, @progressbar_border), + to (@progressbar_border)); + background-color: @theme_selected_bg_color; +} + +row:selected { + border-width: 0; + background-image: -gtk-gradient (linear, + left top, left bottom, + from (@theme_selected_bg_color), + to (@theme_selected_bg_color)); +} + +.cell { + color: @theme_text_color; + padding: 2; + border-width: 0; +} + +.cell:selected { + background-color: @theme_selected_bg_color; +} + +.expander { + border-style: solid; + border-width: 1; + border-radius: 2; + border-color: @internal_element_color; + + color: @internal_element_color; + background-color: @theme_base_color; +} + +.expander:active { + border-style: solid; + border-width: 1; + + color: @internal_element_color; + border-color: @internal_element_color; + + background-color: @theme_base_color; +} + +.expander:prelight { + border-style: solid; + border-width: 1; + + color: @internal_element_color; + border-color: @internal_element_color; + + background-color: shade (@theme_bg_color, 1.02); +} + +.expander row:selected, +.expander row:selected:focused { + border-style: solid; + border-width: 1; + + border-color: @expander_row_selected_color; + color: @expander_row_selected_color; + background-color: @theme_selected_bg_color; +} + +/* Calendars */ +GtkCalendar.view { + border-radius: 3; + border-style: solid; + border-width: 1; + padding: 2; +} + +GtkCalendar.header { + border-radius: 0; + background-image: -gtk-gradient (linear, + left top, + left bottom, + from (shade (@theme_bg_color, 1.04)), + to (shade (@theme_bg_color, 0.89))); + border-width: 0; +} + +GtkCalendar.button { + background-image: -gtk-gradient (linear, + left top, + left bottom, + from (rgba (0, 0, 0, 0)), + to (rgba (0, 0, 0, 0))); +} + +.highlight, +GtkCalendar.highlight { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; + border-radius: 0; + padding: 0; + border-width: 0; +} + +.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; +} + +.dim-label { + color: mix (@theme_fg_color, @theme_bg_color, 0.50); +} + +.sidebar, +.sidebar.view { + background-color: shade (@theme_bg_color, 0.99); +} + +ApDocView, /* Abiword */ +EogScrollView, /* Eog */ +CheeseThumbView /* Cheese */ +{ + background-color: @chrome_bg_color; + -EogScrollView-shadow-type: none; +} + +/* gnome-terminal */ +TerminalScreen { + background-color: @theme_base_color; + color: @theme_fg_color; + -TerminalScreen-background-darkness: 0.95; +} + +/********************** + * Fallback Mode Panel + **********************/ + +PanelWidget, +PanelApplet, +PanelApplet > GtkMenuBar.menubar, +.gnome-panel-menu-bar, +PanelAppletFrame, +PanelMenuBar.menubar, +PanelToplevel { + background-color: @os_chrome_bg_color; + background-image: none; + color: @os_chrome_fg_color; +} + +ClockBox, +.gnome-panel-menu-bar { + font: bold; +} + +PanelApplet > GtkMenuBar.menubar.menuitem:prelight, +.gnome-panel-menu-bar.menuitem:prelight { + background-color: @os_chrome_selected_bg_color; + color: @os_chrome_selected_fg_color; + border-color: lighter (@os_chrome_selected_bg_color); +} + +/* panel buttons (clock, tasklist etc) */ +PanelApplet GtkToggleButton { + background-color: @os_chrome_bg_color; + background-image: none; + border-color: @os_chrome_bg_color; + border-width: 1; + color: @os_chrome_fg_color; +} + +PanelApplet GtkToggleButton:prelight:active, +PanelApplet GtkToggleButton:active { + background-color: @os_chrome_selected_bg_color; + background-image: none; + border-color: lighter (@os_chrome_selected_bg_color); + border-width: 1; + color: @os_chrome_selected_fg_color; +} + +PanelApplet GtkToggleButton:prelight { + background-color: @os_chrome_bg_color; + background-image: none; + border-color: @os_chrome_bg_color; + border-width: 1; + color: @os_chrome_selected_fg_color; +} + +NaTrayApplet { + -NaTrayApplet-icon-padding: 12; + -NaTrayApplet-icon-size: 16; +} + +WnckPager, WnckTasklist { + background-color: @os_chrome_selected_bg_color; + background-image: none; + color: @os_chrome_fg_color; +} + +GsmFailWhaleDialog, +GsmFailWhaleDialog * { + background-color: @os_chrome_bg_color; + background-image: none; + color: @os_chrome_fg_color; +} diff --git a/gtk3/theme/gtk.css b/gtk3/theme/gtk.css new file mode 100644 index 0000000..a1eb610 --- /dev/null +++ b/gtk3/theme/gtk.css @@ -0,0 +1,111 @@ +/* Default color scheme */ +@define-color base_color #ffffff; +@define-color bg_color #ededed; +@define-color tooltip_bg_color #343434; +@define-color selected_bg_color #4a90d9; +@define-color text_color #2e3436; +@define-color fg_color #2e3436; +@define-color tooltip_fg_color #ffffff; +@define-color selected_fg_color #ffffff; + +/* Colormap actually used by the theme, to be overridden in other css files */ +@define-color theme_base_color @base_color; +@define-color theme_text_color @text_color; +@define-color theme_bg_color @bg_color; +@define-color theme_fg_color @fg_color; +@define-color theme_tooltip_bg_color @tooltip_bg_color; +@define-color theme_tooltip_fg_color @tooltip_fg_color; +@define-color theme_selected_bg_color @selected_bg_color; +@define-color theme_selected_fg_color @selected_fg_color; + +@define-color menu_bg_color shade (@theme_bg_color, 0.45); +@define-color menu_fg_color #ffffff; +@define-color menu_controls_color #aaaaaa; + +@define-color link_color #4a90d9; +@define-color frame_color #8a9580; +@define-color inactive_frame_color #c7ccc1; +@define-color warning_color #f57900; +@define-color error_color #cc0000; +@define-color success_color #4e9a06; + +@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); + +@define-color keyboard_focus_border_a #a2c9f1; +@define-color keyboard_focus_border_b #6794cf; + +@define-color os_chrome_bg_color black; +@define-color os_chrome_fg_color #ccc; +@define-color os_chrome_selected_bg_color #333; +@define-color os_chrome_selected_fg_color white; + +@define-color chrome_bg_color #1e1a17; +@define-color chrome_fg_color #fff; + +@define-color focused_entry_border #579eea; +@define-color focused_entry_inset alpha (#d7e4f1, 0.50); + +@define-color button_gradient_color_a #f4f6f4; +@define-color button_gradient_color_b #d7dad7; +@define-color button_border #a7aba7; + +@define-color button_hover_gradient_color_a @theme_base_color; +@define-color button_hover_gradient_color_b shade (@button_gradient_color_a, 0.94); + +@define-color button_active_gradient_color_a #a2a9a2; +@define-color button_active_gradient_color_b shade (@button_active_gradient_color_a, 0.83); + +@define-color insensitive_bg_color #f4f4f2; +@define-color insensitive_fg_color #a7aba7; +@define-color insensitive_border_color shade (@internal_element_color, 1.37); + +@define-color trough_bg_color_a #ccccc7; +@define-color trough_bg_color_b #e4e4e1; + +@define-color active_switch_bg_color_a #509ae7; +@define-color active_switch_bg_color_b #84b8ee; + +@define-color switch_slider_color #eeeeec; +@define-color switch_slider_border #2a79cb; + +@define-color progressbar_background_a #76b0ec; +@define-color progressbar_background_b #1f72c6; +@define-color progressbar_border #3277bf; +@define-color progressbar_pattern #000000; + +@define-color internal_element_color #888a85; + +@define-color scale_fill @insensitive_border_color; +@define-color scale_border_a @internal_element_color; +@define-color scale_border_b shade (@internal_element_color, 1.25); +@define-color scale_progress_fill #2c85e2; +@define-color scale_progress_border_a #1864b2; +@define-color scale_progress_border_b #3e90e5; + +@define-color highlighted_border #8a8f8a; + +@define-color notebook_border #a6a6a6; +@define-color notebook_active_tab_border #1372d3; +@define-color notebook_selected_tab_color #8dc0f3; + +@define-color notebook_tab_gradient_a @theme_base_color; +@define-color notebook_tab_gradient_b @switch_slider_color; + +@define-color toolbar_gradient_base #aaaa9e; +@define-color toolbar_gradient_step1 #bcbcb4; +@define-color toolbar_gradient_step2 #d9d9d7; +@define-color toolbar_gradient_final #e5e5e2; + +@define-color toolbar_active_button_color #909081; + +@define-color expander_row_selected_color #acccee; + +@import url("gtk-widgets-assets.css"); +@import url("gtk-widgets.css"); diff --git a/gtk3/theme/settings.ini b/gtk3/theme/settings.ini new file mode 100644 index 0000000..1a08b65 --- /dev/null +++ b/gtk3/theme/settings.ini @@ -0,0 +1,3 @@ +[Settings] +gtk-color-scheme = "base_color:#ffffff\nbg_color:#ededed\ntooltip_bg_color:#343434\nselected_bg_color:#4a90d9\ntext_color:#2e3436\nfg_color:#2e3436;\ntooltip_fg_color:#ffffff\nselected_fg_color:#ffffff" +gtk-auto-mnemonics = 1 -- cgit v0.9.1