/** * gtk_source_style_scheme_chooser_set_style_scheme: * @chooser: a #GtkSourceStyleSchemeChooser * @scheme: a #GtkSourceStyleScheme * * Sets the scheme. * * Since: 3.16 */ void gtk_source_style_scheme_chooser_set_style_scheme (GtkSourceStyleSchemeChooser *chooser, GtkSourceStyleScheme *scheme) { g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_CHOOSER (chooser)); g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme)); GTK_SOURCE_STYLE_SCHEME_CHOOSER_GET_IFACE (chooser)->set_style_scheme (chooser, scheme); }
void _gtk_source_engine_set_style_scheme (GtkSourceEngine *engine, GtkSourceStyleScheme *scheme) { g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine)); g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme) || scheme == NULL); g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->set_style_scheme != NULL); GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->set_style_scheme (engine, scheme); }
static gboolean get_style_rgba (GtkSourceStyleScheme *scheme, const gchar *style_name, int type, GdkRGBA *rgba) { GtkSourceStyle *style; g_assert (!scheme || GTK_SOURCE_IS_STYLE_SCHEME (scheme)); g_assert (style_name != NULL); g_assert (type == FOREGROUND || type == BACKGROUND); g_assert (rgba != NULL); memset (rgba, 0, sizeof *rgba); if (scheme == NULL) return FALSE; if (NULL != (style = gtk_source_style_scheme_get_style (scheme, style_name))) { g_autofree gchar *str = NULL; gboolean set = FALSE; g_object_get (style, type ? "background" : "foreground", &str, type ? "background-set" : "foreground-set", &set, NULL); if (str != NULL) gdk_rgba_parse (rgba, str); return set; } return FALSE; }
gboolean ide_source_style_scheme_apply_style (GtkSourceStyleScheme *style_scheme, const gchar *style_name, GtkTextTag *tag) { g_autofree gchar *foreground = NULL; g_autofree gchar *background = NULL; g_autofree gchar *underline_color = NULL; GdkRGBA underline_rgba; GtkSourceStyle *style; const gchar *colon; PangoUnderline pango_underline; gboolean foreground_set = FALSE; gboolean background_set = FALSE; gboolean bold = FALSE; gboolean bold_set = FALSE; gboolean underline_set = FALSE; gboolean underline_color_set = FALSE; gboolean italic = FALSE; gboolean italic_set = FALSE; g_return_val_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (style_scheme), FALSE); g_return_val_if_fail (style_name != NULL, FALSE); g_object_set (tag, "foreground-set", FALSE, "background-set", FALSE, "weight-set", FALSE, "underline-set", FALSE, "underline-rgba-set", FALSE, "style-set", FALSE, NULL); style = gtk_source_style_scheme_get_style (style_scheme, style_name); if (style == NULL && (colon = strchr (style_name, ':'))) { gchar defname[64]; g_snprintf (defname, sizeof defname, "def%s", colon); style = gtk_source_style_scheme_get_style (style_scheme, defname); if (style == NULL) return FALSE; } g_object_get (style, "background", &background, "background-set", &background_set, "foreground", &foreground, "foreground-set", &foreground_set, "bold", &bold, "bold-set", &bold_set, "pango-underline", &pango_underline, "underline-set", &underline_set, "underline-color", &underline_color, "underline-color-set", &underline_color_set, "italic", &italic, "italic-set", &italic_set, NULL); if (background_set) g_object_set (tag, "background", background, NULL); if (foreground_set) g_object_set (tag, "foreground", foreground, NULL); if (bold_set && bold) g_object_set (tag, "weight", PANGO_WEIGHT_BOLD, NULL); if (italic_set && italic) g_object_set (tag, "style", PANGO_STYLE_ITALIC, NULL); if (underline_set) g_object_set (tag, "underline", pango_underline, NULL); if (underline_color_set && underline_color != NULL) { gdk_rgba_parse (&underline_rgba, underline_color); g_object_set (tag, "underline-rgba", &underline_rgba, NULL); } return TRUE; }