static void context_apply_config(GtkWidget *console) { #if !GTK_CHECK_VERSION(3, 0, 0) gtk_widget_modify_base(console, GTK_STATE_NORMAL, &pref_vte_colour_back); gtk_widget_modify_cursor(console, &pref_vte_colour_fore, &pref_vte_colour_back); #else GString *css_string; GtkStyleContext *context; GtkCssProvider *provider; gchar *css_code, *color, *background_color; color = gdk_rgba_to_string (&pref_vte_colour_fore); background_color = gdk_rgba_to_string (&pref_vte_colour_back); gtk_widget_set_name(console, "scope-console"); context = gtk_widget_get_style_context(console); provider = gtk_css_provider_new(); gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); css_string = g_string_new(NULL); g_string_printf(css_string, "#scope-console { color: %s; background-color: %s; }", color, background_color); css_code = g_string_free(css_string, FALSE); gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(provider), css_code, -1, NULL); g_free(css_code); g_object_unref(provider); #endif ui_widget_modify_font_from_string(console, pref_vte_font); }
static void biji_note_book_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { BijiNoteBook *self = BIJI_NOTE_BOOK (object); GdkRGBA *color; switch (property_id) { case PROP_LOCATION: self->priv->location = g_value_dup_object (value); break; case PROP_ERROR: self->priv->error = g_value_get_pointer (value); break; case PROP_COLOR: color = g_value_get_pointer (value); self->priv->color.red = color->red; self->priv->color.blue = color->blue; self->priv->color.green = color->green; self->priv->color.alpha = color->alpha; g_warning ("book color is not done :%s", gdk_rgba_to_string (&self->priv->color)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void init_css(zathura_t* zathura) { GiraraTemplate* csstemplate = girara_session_get_template(zathura->ui.session); static const char* index_settings[] = { "index-fg", "index-bg", "index-active-fg", "index-active-bg" }; for (size_t s = 0; s < LENGTH(index_settings); ++s) { girara_template_add_variable(csstemplate, index_settings[s]); char* tmp_value = NULL; GdkRGBA rgba = {0, 0, 0, 0}; girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value); if (tmp_value != NULL) { gdk_rgba_parse(&rgba, tmp_value); g_free(tmp_value); } char* color = gdk_rgba_to_string(&rgba); girara_template_set_variable_value(csstemplate, index_settings[s], color); g_free(color); } char* css = g_strdup_printf("%s\n%s", girara_template_get_base(csstemplate), CSS_TEMPLATE_INDEX); girara_template_set_base(csstemplate, css); g_free(css); }
void cb_cpu_color_changed (GsmColorButton *cp, gpointer data) { guint cpu_i = GPOINTER_TO_UINT (data); auto settings = Gio::Settings::create (GSM_GSETTINGS_SCHEMA); /* Get current values */ GVariant *cpu_colors_var = g_settings_get_value (settings->gobj(), GSM_SETTING_CPU_COLORS); gsize children_n = g_variant_n_children(cpu_colors_var); /* Create builder to contruct new setting with updated value for cpu i */ GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); for (guint i = 0; i < children_n; i++) { if(cpu_i == i) { gchar *color; GdkRGBA button_color; gsm_color_button_get_color(cp, &button_color); color = gdk_rgba_to_string (&button_color); g_variant_builder_add(&builder, "(us)", i, color); g_free (color); } else { g_variant_builder_add_value(&builder, g_variant_get_child_value(cpu_colors_var, i)); } } /* Just set the value and let the changed::cpu-colors signal callback do the rest. */ settings->set_value (GSM_SETTING_CPU_COLORS, Glib::wrap (g_variant_builder_end(&builder))); }
static void gtk_css_value_rgba_print (const GtkCssValue *rgba, GString *string) { char *s = gdk_rgba_to_string (&rgba->rgba); g_string_append (string, s); g_free (s); }
static char * rgba_value_to_string (const GValue *value) { const GdkRGBA *rgba = g_value_get_boxed (value); if (rgba == NULL) return g_strdup ("none"); return gdk_rgba_to_string (rgba); }
static void change_settings_color(Gio::Settings& settings, const char *key, GsmColorButton *cp) { GdkRGBA c; char *color; gsm_color_button_get_color(cp, &c); color = gdk_rgba_to_string (&c); settings.set_string (key, color); g_free (color); }
static void change_settings_color(GSettings *settings, const char *key, GSMColorButton *cp) { GdkRGBA c; char *color; gsm_color_button_get_color(cp, &c); color = gdk_rgba_to_string (&c); g_settings_set_string (settings, key, color); g_free (color); }
static void background_color_set (GtkColorButton *color_button, MCData *mc) { GdkRGBA color; gchar *str; gtk_color_button_get_rgba (color_button, &color); str = gdk_rgba_to_string (&color); g_settings_set_string (mc->settings, KEY_CMD_LINE_COLOR_BG, str); g_free (str); }
/* Properties Dialog Callback : Color */ void properties_color_cb (GtkWidget *button, StickyNote *note) { char *color_str = NULL; char *font_color_str = NULL; if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(note->w_def_color))) { #if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color, font_color; gtk_color_button_get_rgba (GTK_COLOR_BUTTON (note->w_color), &color); gtk_color_button_get_rgba (GTK_COLOR_BUTTON (note->w_font_color), &font_color); color_str = gdk_rgba_to_string (&color); font_color_str = gdk_rgba_to_string (&font_color); #else GdkColor color, font_color; gtk_color_button_get_color (GTK_COLOR_BUTTON (note->w_color), &color); gtk_color_button_get_color (GTK_COLOR_BUTTON (note->w_font_color), &font_color); color_str = g_strdup_printf ("#%.2x%.2x%.2x", color.red / 256, color.green / 256, color.blue / 256); font_color_str = g_strdup_printf ("#%.2x%.2x%.2x", font_color.red / 256, font_color.green / 256, font_color.blue / 256); #endif } stickynote_set_color (note, color_str, font_color_str, TRUE); g_free (color_str); g_free (font_color_str); }
static void panel_properties_dialog_background_color_set_from_rgba (PanelPropertiesDialog *dialog, GdkRGBA *color) { char *color_str; color_str = gdk_rgba_to_string (color); g_settings_set_string (dialog->settings_background, PANEL_BACKGROUND_COLOR_KEY, color_str); g_free (color_str); /* make sure all widgets are consistent */ panel_properties_dialog_background_color_update_from_rgba (dialog, color); }
static void update_color (GcalEventWidget *self) { GtkStyleContext *context; GdkRGBA *color; GQuark color_id; gchar *color_str; gchar *css_class; GDateTime *now; gint date_compare; context = gtk_widget_get_style_context (GTK_WIDGET (self)); color = gcal_event_get_color (self->event); now = g_date_time_new_now_local (); date_compare = g_date_time_compare (self->dt_end, now); /* Fades out an event that's earlier than the current date */ gtk_widget_set_opacity (GTK_WIDGET (self), date_compare < 0 ? 0.6 : 1.0); /* Remove the old style class */ if (self->css_class) { gtk_style_context_remove_class (context, self->css_class); g_clear_pointer (&self->css_class, g_free); } color_str = gdk_rgba_to_string (color); color_id = g_quark_from_string (color_str); css_class = g_strdup_printf ("color-%d", color_id); gtk_style_context_add_class (context, css_class); if (INTENSITY (color) > 0.5) { gtk_style_context_remove_class (context, "color-dark"); gtk_style_context_add_class (context, "color-light"); } else { gtk_style_context_remove_class (context, "color-light"); gtk_style_context_add_class (context, "color-dark"); } /* Keep the current style around, so we can remove it later */ self->css_class = css_class; g_clear_pointer (&now, g_date_time_unref); g_free (color_str); }
static GVariant * rgba_to_s (const GValue *value, const GVariantType *expected_type, gpointer user_data) { GdkRGBA *color; gs_free char *s = NULL; color = g_value_get_boxed (value); if (color == NULL) return NULL; s = gdk_rgba_to_string (color); return g_variant_new_string (s); }
static void override_background_color (GtkWidget *widget, GdkRGBA *rgba) { gchar *css; GtkCssProvider *provider; provider = gtk_css_provider_new (); css = g_strdup_printf ("* { background-color: %s; }", gdk_rgba_to_string (rgba)); gtk_css_provider_load_from_data (provider, css, -1, NULL); g_free (css); gtk_style_context_add_provider (gtk_widget_get_style_context (widget), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); }
static GVariant* pd_rgba_to_string_mapping (const GValue *value, const GVariantType *expected_type, gpointer user_data) { GVariant *variant = NULL; GdkRGBA *color; gchar *hex_val; g_return_val_if_fail (G_VALUE_TYPE (value) == GDK_TYPE_RGBA, NULL); g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL); color = g_value_get_boxed (value); hex_val = gdk_rgba_to_string(color); variant = g_variant_new_string (hex_val); g_free (hex_val); return variant; }
static GVariant * panel_properties_dialog_color_set (const GValue *value, const GVariantType *expected_type, gpointer user_data) { GdkRGBA *rgba; gchar *str; GVariant *variant; rgba = g_value_get_boxed (value); if (rgba == NULL) { return NULL; } str = gdk_rgba_to_string (rgba); variant = g_variant_new_string (str); g_free (str); return variant; }
//! //! @brief Callback to set the user selected color to the color swatch for text highlighting //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_swatch_color_changed_cb (GtkWidget *widget, gpointer data) { //Declarations GwSettingsWindow *window; GwApplication *application; LwPreferences *preferences; GdkRGBA color; char *hex_color_string; char *pref_key; char *letter; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); hex_color_string = gdk_rgba_to_string (&color); pref_key = g_strdup_printf ("%s", gtk_buildable_get_name (GTK_BUILDABLE (widget))); letter = strchr(pref_key, '_'); if (letter == NULL) return; *letter = '-'; letter = strchr(letter, '_'); if (letter == NULL) return; *letter = '\0'; //Set the color in the prefs if (pref_key != NULL && hex_color_string != NULL) { lw_preferences_set_string_by_schema (preferences, LW_SCHEMA_HIGHLIGHT, pref_key, hex_color_string); } //Cleanup if (pref_key != NULL) g_free (pref_key); if (hex_color_string != NULL) g_free (hex_color_string); }
char * panel_background_make_string (PanelBackground *background, int x, int y) { PanelBackgroundType effective_type; char *retval; retval = NULL; effective_type = panel_background_effective_type (background); if (effective_type == PANEL_BACK_IMAGE || (effective_type == PANEL_BACK_COLOR && background->has_alpha && (!gdk_window_check_composited_wm(background->window)))) { cairo_surface_t *surface; if (!background->composited_pattern) return NULL; if (cairo_pattern_get_surface (background->composited_pattern, &surface) != CAIRO_STATUS_SUCCESS) return NULL; if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB) return NULL; retval = g_strdup_printf ("pixmap:%d,%d,%d", (guint32)cairo_xlib_surface_get_drawable (surface), x, y); } else if (effective_type == PANEL_BACK_COLOR) { gchar *rgba = gdk_rgba_to_string (&background->color); retval = g_strdup_printf ( "color:%s", rgba); g_free (rgba); } else retval = g_strdup ("none:"); return retval; }
G_MODULE_EXPORT void colorbutton1_color_set_cb(GtkColorButton *widget, EDITOR *e) { #ifdef HAVE_GTK_34 GdkRGBA color; #else GdkColor color; #endif gchar *color_str; gchar *forecolor = NULL; #ifdef HAVE_GTK_34 gtk_color_chooser_get_rgba((GtkColorChooser *)widget, &color); color_str = gdk_rgba_to_string(&color); #else gtk_color_button_get_color((GtkColorButton *)widget, &color); /* FIXME: ugly need something better */ color_str = g_strdup_printf("rgb(%u,%u,%u)", color.red >> 8, color.green >> 8, color.blue >> 8); #endif forecolor = g_strdup_printf("document.execCommand('forecolor', null, '%s');", color_str); editor_execute_script(forecolor, e); g_free(forecolor); }
static gboolean set_background_color (PanelToplevel *toplevel, guint16 *dropped) { GSettings *settings; GdkRGBA color; char *color_str; if (!dropped) return FALSE; settings = get_settings_background_for_toplevel (toplevel); if (!g_settings_is_writable (settings, PANEL_BACKGROUND_TYPE_KEY) || !g_settings_is_writable (settings, PANEL_BACKGROUND_COLOR_KEY)) { g_object_unref (settings); return FALSE; } color.red = dropped [0] / 65535.; color.green = dropped [1] / 65535.; color.blue = dropped [2] / 65535.; color.alpha = 1.; color_str = gdk_rgba_to_string (&color); g_settings_set_string (settings, PANEL_BACKGROUND_COLOR_KEY, color_str); g_settings_set_enum (settings, PANEL_BACKGROUND_TYPE_KEY, PANEL_BACK_COLOR); g_free (color_str); g_object_unref (settings); return TRUE; }
void get_source_parent_name_color (GcalManager *manager, ESource *source, gchar **name, gchar **color) { ESource *parent_source; g_assert (source && E_IS_SOURCE (source)); parent_source = gcal_manager_get_source (manager, e_source_get_parent (source)); if (name != NULL) *name = e_source_dup_display_name (parent_source); if (color != NULL) { GdkRGBA c; get_color_name_from_source (parent_source, &c); *color = gdk_rgba_to_string (&c); } }
static void save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data) { GPtrArray *filters; const gchar *name; LogviewFilter *filter; GdkRGBA *foreground; gboolean foreground_set; GdkRGBA *background; gboolean background_set; gchar *regex, *color; gboolean invisible; GtkTextTag *tag; GString *prefs_string; filters = user_data; filter = LOGVIEW_FILTER (value); name = key; color = NULL; prefs_string = g_string_new (name); g_string_append (prefs_string, DELIMITER); g_object_get (filter, "regex", ®ex, "texttag", &tag, NULL); g_object_get (tag, "foreground-set", &foreground_set, "foreground-rgba", &foreground, "paragraph-background-set", &background_set, "paragraph-background-rgba", &background, "invisible", &invisible, NULL); if (invisible) { g_string_append (prefs_string, "1" DELIMITER); } else { g_string_append (prefs_string, "0" DELIMITER); } if (foreground_set) { color = gdk_rgba_to_string (foreground); g_string_append (prefs_string, color); g_free (color); } if (foreground) { gdk_rgba_free (foreground); } g_string_append (prefs_string, DELIMITER); if (background_set) { color = gdk_rgba_to_string (background); g_string_append (prefs_string, color); g_free (color); } if (background) { gdk_rgba_free (background); } g_string_append (prefs_string, DELIMITER); g_string_append (prefs_string, regex); g_free (regex); g_object_unref (tag); g_ptr_array_add (filters, g_string_free (prefs_string, FALSE)); }
gboolean biji_lazy_serialize_internal (BijiLazySerializer *self) { BijiLazySerializerPrivate *priv = self->priv; GList *tags; GdkRGBA color; gchar *date, *color_str; gboolean retval; const gchar *path; GTimeVal time = {0, 0}; priv->writer = xmlNewTextWriterMemory(priv->buf, 0); // Header xmlTextWriterStartDocument (priv->writer,"1.0","utf-8",NULL); xmlTextWriterStartElement (priv->writer, BAD_CAST "note"); xmlTextWriterWriteAttributeNS (priv->writer, NULL, BAD_CAST "version",NULL, BAD_CAST "1"); xmlTextWriterWriteAttributeNS (priv->writer, BAD_CAST "xmlns", BAD_CAST "link", NULL, BAD_CAST "http://projects.gnome.org/bijiben/link"); xmlTextWriterWriteAttributeNS (priv->writer, BAD_CAST "xmlns", BAD_CAST "size", NULL, BAD_CAST "http://projects.gnome.org/bijiben/size"); xmlTextWriterWriteAttributeNS (priv->writer, NULL, BAD_CAST "xmlns", NULL, BAD_CAST "http://projects.gnome.org/bijiben"); // <Title> serialize_node (priv->writer, "title", (gchar*) biji_item_get_title (BIJI_ITEM (priv->note))); // <text> xmlTextWriterWriteRaw(priv->writer, BAD_CAST "\n "); xmlTextWriterStartElement(priv->writer, BAD_CAST "text"); xmlTextWriterWriteAttributeNS(priv->writer, BAD_CAST "xml", BAD_CAST "space", NULL, BAD_CAST "preserve"); serialize_html (self); // </text> xmlTextWriterEndElement(priv->writer); // <last-change-date> time.tv_sec = biji_item_get_mtime (BIJI_ITEM (priv->note)); date = g_time_val_to_iso8601 (&time); if (date) { serialize_node (priv->writer, "last-change-date", date); g_free (date); } time.tv_sec = biji_note_obj_get_last_metadata_change_date (priv->note); date = g_time_val_to_iso8601 (&time); if (date) { serialize_node (priv->writer, "last-metadata-change-date", date); g_free (date); } time.tv_sec = biji_note_obj_get_create_date (priv->note); date = g_time_val_to_iso8601 (&time); if (date) { serialize_node (priv->writer, "create-date", date); g_free (date); } serialize_node (priv->writer, "cursor-position", "0"); serialize_node (priv->writer, "selection-bound-position", "0"); serialize_node (priv->writer, "width", "0"); serialize_node (priv->writer, "height", "0"); serialize_node (priv->writer, "x", "0"); serialize_node (priv->writer, "y", "0"); if (biji_note_obj_get_rgba (priv->note, &color)) { color_str = gdk_rgba_to_string (&color); serialize_node (priv->writer, "color", color_str); g_free (color_str); } //<tags> xmlTextWriterWriteRaw(priv->writer, BAD_CAST "\n "); xmlTextWriterStartElement (priv->writer, BAD_CAST "tags"); tags = biji_note_obj_get_notebooks (priv->note); g_list_foreach (tags, (GFunc) serialize_tags, priv->writer); xmlTextWriterEndElement (priv->writer); g_list_free (tags); // <open-on-startup> serialize_node (priv->writer, "open-on-startup", "False"); // <note> xmlTextWriterWriteRaw(priv->writer, BAD_CAST "\n "); xmlTextWriterEndElement(priv->writer); xmlFreeTextWriter(priv->writer); path = biji_item_get_uuid (BIJI_ITEM (priv->note)); retval = g_file_set_contents (path, (gchar*) priv->buf->content, -1, NULL); return retval; }
static void gtk_source_map_rebuild_css (GtkSourceMap *map) { GtkSourceMapPrivate *priv; GtkSourceStyleScheme *style_scheme; GtkSourceStyle *style = NULL; GtkTextBuffer *buffer; GString *gstr; gboolean alter_alpha = TRUE; gchar *background = NULL; priv = gtk_source_map_get_instance_private (map); if (priv->view == NULL) { return; } /* * This is where we calculate the CSS that maps the font for the * minimap as well as the styling for the scrubber. * * The font is calculated from #GtkSourceMap:font-desc. We convert this * to CSS using _gtk_source_pango_font_description_to_css(). It gets * applied to the minimap widget via the CSS style provider which we * attach to the child widget in gtk_source_map_init(). * * The rules for calculating the style for the scrubber are as follows. * * If the current style scheme provides a background color for the * scrubber using the "map-overlay" style name, we use that without * any transformations. * * If the style scheme contains a "selection" style scheme, used for * selected text, we use that with a 0.75 alpha value. * * If none of these are met, we take the background from the * #GtkStyleContext using the deprecated * gtk_style_context_get_background_color(). This is non-ideal, but * currently required since we cannot indicate that we want to * alter the alpha for gtk_render_background(). */ gstr = g_string_new (NULL); /* Calculate the font if one has been set */ if (priv->font_desc != NULL) { gchar *css; css = _gtk_source_pango_font_description_to_css (priv->font_desc); g_string_append_printf (gstr, "GtkSourceView { %s }\n", css != NULL ? css : ""); g_free (css); } buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->view)); style_scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer)); if (style_scheme != NULL) { style = gtk_source_style_scheme_get_style (style_scheme, "map-overlay"); if (style != NULL) { /* styling is taking as is only if we found a "map-overlay". */ alter_alpha = FALSE; } else { style = gtk_source_style_scheme_get_style (style_scheme, "selection"); } } if (style != NULL) { g_object_get (style, "background", &background, NULL); } if (background == NULL) { GtkStyleContext *context; GdkRGBA color; /* * We failed to locate a style for both "map-overlay" and for * "selection". That means we need to fallback to using the * selected color for the gtk+ theme. This uses deprecated * API because we have no way to tell gtk_render_background() * to render with an alpha. */ context = gtk_widget_get_style_context (GTK_WIDGET (priv->view)); gtk_style_context_save (context); gtk_style_context_add_class (context, "view"); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color); G_GNUC_END_IGNORE_DEPRECATIONS; gtk_style_context_restore (context); background = gdk_rgba_to_string (&color); /* * Make sure we alter the alpha. It is possible this could be * FALSE here if we found a style for map-overlay but it did * not contain a background color. */ alter_alpha = TRUE; } if (alter_alpha) { GdkRGBA color; gdk_rgba_parse (&color, background); color.alpha = 0.75; g_free (background); background = gdk_rgba_to_string (&color); } if (background != NULL) { g_string_append_printf (gstr, "GtkSourceMap.scrubber {\n" "\tbackground-color: %s;\n" "\tborder-top: 1px solid shade(%s,0.9);\n" "\tborder-bottom: 1px solid shade(%s,0.9);\n" "}\n", background, background, background); } g_free (background); if (gstr->len > 0) { gtk_css_provider_load_from_data (priv->css_provider, gstr->str, gstr->len, NULL); } g_string_free (gstr, TRUE); }
GtkWidget *gtk_paned_new_with_handle(GtkOrientation orientation) { GtkWidget *pnd = gtk_paned_new(orientation); GtkStyleContext *context = gtk_widget_get_style_context(pnd); GtkCssProvider *cssprv = gtk_css_provider_new(); GdkRGBA clrSel = {0.,0.,0.,0.}; char css[2048]; gtk_style_context_lookup_color(context, "bg_color", &clrSel); if (orientation == GTK_ORIENTATION_HORIZONTAL) { sprintf(css, "* {\n -GtkPaned-handle-size: 3; \n } \n .pane-separator.horizontal {\n background-image: -gtk-gradient (linear, left top, left bottom, from (%s), color-stop (0.5, shade (%s, 0.95)), to (%s)); \n -unico-centroid-texture: url(\"%s\");\n }\n", gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), imgOrzHnd); } else { sprintf(css, "* {\n -GtkPaned-handle-size: 3; \n } \n \n .pane-separator.vertical {\n background-image: -gtk-gradient (linear, left top, right top, from (%s), color-stop (0.5, shade (%s, 0.95)), to (%s)); \n -unico-centroid-texture: url(\"%s\");\n }\n", gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), gdk_rgba_to_string(&clrSel), imgVrtHnd); } gtk_style_context_remove_provider(context, GTK_STYLE_PROVIDER (cssprv)); gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER (cssprv), GTK_STYLE_PROVIDER_PRIORITY_USER); gtk_css_provider_load_from_data(cssprv, css, -1, NULL); g_object_unref(cssprv); return pnd; }
static GdkPixbuf * load_symbolic_svg (char *file_data, gsize file_len, int width, int height, const GdkRGBA *fg, const GdkRGBA *success_color, const GdkRGBA *warning_color, const GdkRGBA *error_color, GError **error) { GInputStream *stream; GdkPixbuf *pixbuf; gchar *css_fg; gchar *css_success; gchar *css_warning; gchar *css_error; gchar *data; gchar *svg_width, *svg_height; gchar *escaped_file_data; css_fg = gdk_rgba_to_string (fg); css_success = css_warning = css_error = NULL; css_warning = gdk_rgba_to_string (warning_color); css_error = gdk_rgba_to_string (error_color); css_success = gdk_rgba_to_string (success_color); /* Fetch size from the original icon */ stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL); pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error); g_object_unref (stream); if (!pixbuf) return NULL; svg_width = g_strdup_printf ("%d", gdk_pixbuf_get_width (pixbuf)); svg_height = g_strdup_printf ("%d",gdk_pixbuf_get_height (pixbuf)); g_object_unref (pixbuf); escaped_file_data = g_markup_escape_text (file_data, file_len); data = g_strconcat ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" "<svg version=\"1.1\"\n" " xmlns=\"http://www.w3.org/2000/svg\"\n" " xmlns:xi=\"http://www.w3.org/2001/XInclude\"\n" " width=\"", svg_width, "\"\n" " height=\"", svg_height, "\">\n" " <style type=\"text/css\">\n" " rect,circle,path {\n" " fill: ", css_fg," !important;\n" " }\n" " .warning {\n" " fill: ", css_warning, " !important;\n" " }\n" " .error {\n" " fill: ", css_error ," !important;\n" " }\n" " .success {\n" " fill: ", css_success, " !important;\n" " }\n" " </style>\n" " <xi:include href=\"data:text/xml,", escaped_file_data, "\"/>\n" "</svg>", NULL); g_free (escaped_file_data); g_free (css_fg); g_free (css_warning); g_free (css_error); g_free (css_success); g_free (svg_width); g_free (svg_height); stream = g_memory_input_stream_new_from_data (data, -1, g_free); pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error); g_object_unref (stream); return pixbuf; }
static gchar *_watermark_get_svgdoc(dt_iop_module_t *self, dt_iop_watermark_data_t *data, const dt_image_t *image) { gsize length; gchar *svgdoc = NULL; gchar configdir[PATH_MAX] = { 0 }; gchar datadir[PATH_MAX] = { 0 }; gchar *filename; dt_loc_get_datadir(datadir, sizeof(datadir)); dt_loc_get_user_config_dir(configdir, sizeof(configdir)); g_strlcat(datadir, "/watermarks/", sizeof(datadir)); g_strlcat(configdir, "/watermarks/", sizeof(configdir)); g_strlcat(datadir, data->filename, sizeof(datadir)); g_strlcat(configdir, data->filename, sizeof(configdir)); if(g_file_test(configdir, G_FILE_TEST_EXISTS)) filename = configdir; else if(g_file_test(datadir, G_FILE_TEST_EXISTS)) filename = datadir; else return NULL; gchar *svgdata = NULL; char datetime[200]; // EXIF datetime struct tm tt_exif = { 0 }; if(sscanf(image->exif_datetime_taken, "%d:%d:%d %d:%d:%d", &tt_exif.tm_year, &tt_exif.tm_mon, &tt_exif.tm_mday, &tt_exif.tm_hour, &tt_exif.tm_min, &tt_exif.tm_sec) == 6) { tt_exif.tm_year -= 1900; tt_exif.tm_mon--; } // Current datetime struct tm tt_cur = { 0 }; time_t t = time(NULL); (void)localtime_r(&t, &tt_cur); if(g_file_get_contents(filename, &svgdata, &length, NULL)) { // File is loaded lets substitute strings if found... // Darktable internal svgdoc = _string_substitute(svgdata, "$(DARKTABLE.NAME)", PACKAGE_NAME); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } svgdoc = _string_substitute(svgdata, "$(DARKTABLE.VERSION)", PACKAGE_VERSION); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // Simple text from watermark module gchar buffer[1024]; if (data->font[0] && data->text[0]) { g_snprintf(buffer, sizeof(buffer), "%s", data->text); svgdoc = _string_substitute(svgdata, "$(WATERMARK_TEXT)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } PangoFontDescription *font = pango_font_description_from_string(data->font); const PangoStyle font_style = pango_font_description_get_style(font); const int font_weight = (int)pango_font_description_get_weight(font); g_snprintf(buffer, sizeof(buffer), "%s", pango_font_description_get_family(font)); svgdoc = _string_substitute(svgdata, "$(WATERMARK_FONT_FAMILY)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } switch (font_style) { case PANGO_STYLE_OBLIQUE: g_strlcpy(buffer, "oblique", sizeof(buffer)); break; case PANGO_STYLE_ITALIC: g_strlcpy(buffer, "italic", sizeof(buffer)); break; default: g_strlcpy(buffer, "normal", sizeof(buffer)); break; } svgdoc = _string_substitute(svgdata, "$(WATERMARK_FONT_STYLE)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } g_snprintf(buffer, sizeof(buffer), "%d", font_weight); svgdoc = _string_substitute(svgdata, "$(WATERMARK_FONT_WEIGHT)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } pango_font_description_free(font); } // watermark color GdkRGBA c = { data->color[0], data->color[1], data->color[2], 1.0f }; g_snprintf(buffer, sizeof(buffer), "%s", gdk_rgba_to_string(&c)); svgdoc = _string_substitute(svgdata, "$(WATERMARK_COLOR)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // Current image ID g_snprintf(buffer, sizeof(buffer), "%d", image->id); svgdoc = _string_substitute(svgdata, "$(IMAGE.ID)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // Current image dt_image_print_exif(image, buffer, sizeof(buffer)); svgdoc = _string_substitute(svgdata, "$(IMAGE.EXIF)", buffer); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // Image exif // EXIF date svgdoc = _string_substitute(svgdata, "$(EXIF.DATE)", image->exif_datetime_taken); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.SECOND) -- 00..60 strftime(datetime, sizeof(datetime), "%S", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.SECOND)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.MINUTE) -- 00..59 strftime(datetime, sizeof(datetime), "%M", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.MINUTE)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.HOUR) -- 00..23 strftime(datetime, sizeof(datetime), "%H", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.HOUR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.HOUR_AMPM) -- 01..12 strftime(datetime, sizeof(datetime), "%I %p", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.HOUR_AMPM)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.DAY) -- 01..31 strftime(datetime, sizeof(datetime), "%d", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.DAY)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.MONTH) -- 01..12 strftime(datetime, sizeof(datetime), "%m", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.SHORT_MONTH) -- Jan, Feb, .., Dec, localized strftime(datetime, sizeof(datetime), "%b", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.SHORT_MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.LONG_MONTH) -- January, February, .., December, localized strftime(datetime, sizeof(datetime), "%B", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.LONG_MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.SHORT_YEAR) -- 12 strftime(datetime, sizeof(datetime), "%y", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.SHORT_YEAR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(EXIF.DATE.LONG_YEAR) -- 2012 strftime(datetime, sizeof(datetime), "%Y", &tt_exif); svgdoc = _string_substitute(svgdata, "$(EXIF.DATE.LONG_YEAR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // Current date // $(DATE) -- YYYY: dt_gettime_t(datetime, sizeof(datetime), t); svgdoc = _string_substitute(svgdata, "$(DATE)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.SECOND) -- 00..60 strftime(datetime, sizeof(datetime), "%S", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.SECOND)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.MINUTE) -- 00..59 strftime(datetime, sizeof(datetime), "%M", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.MINUTE)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.HOUR) -- 00..23 strftime(datetime, sizeof(datetime), "%H", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.HOUR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.HOUR_AMPM) -- 01..12 strftime(datetime, sizeof(datetime), "%I %p", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.HOUR_AMPM)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.DAY) -- 01..31 strftime(datetime, sizeof(datetime), "%d", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.DAY)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.MONTH) -- 01..12 strftime(datetime, sizeof(datetime), "%m", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.SHORT_MONTH) -- Jan, Feb, .., Dec, localized strftime(datetime, sizeof(datetime), "%b", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.SHORT_MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.LONG_MONTH) -- January, February, .., December, localized strftime(datetime, sizeof(datetime), "%B", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.LONG_MONTH)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.SHORT_YEAR) -- 12 strftime(datetime, sizeof(datetime), "%y", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.SHORT_YEAR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } // $(DATE.LONG_YEAR) -- 2012 strftime(datetime, sizeof(datetime), "%Y", &tt_cur); svgdoc = _string_substitute(svgdata, "$(DATE.LONG_YEAR)", datetime); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } svgdoc = _string_substitute(svgdata, "$(EXIF.MAKER)", image->camera_maker); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } svgdoc = _string_substitute(svgdata, "$(EXIF.MODEL)", image->camera_model); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } svgdoc = _string_substitute(svgdata, "$(EXIF.LENS)", image->exif_lens); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } svgdoc = _string_substitute(svgdata, "$(IMAGE.FILENAME)", image->filename); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } gchar *basename = g_path_get_basename(image->filename); if(g_strrstr(basename, ".")) *(g_strrstr(basename, ".")) = '\0'; svgdoc = _string_substitute(svgdata, "$(IMAGE.BASENAME)", basename); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } g_free(basename); // TODO: auto generate that code? GList *res; res = dt_metadata_get(image->id, "Xmp.dc.creator", NULL); svgdoc = _string_substitute(svgdata, "$(Xmp.dc.creator)", (res ? res->data : "")); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } if(res) { g_list_free_full(res, &g_free); } res = dt_metadata_get(image->id, "Xmp.dc.publisher", NULL); svgdoc = _string_substitute(svgdata, "$(Xmp.dc.publisher)", (res ? res->data : "")); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } if(res) { g_list_free_full(res, &g_free); } res = dt_metadata_get(image->id, "Xmp.dc.title", NULL); svgdoc = _string_substitute(svgdata, "$(Xmp.dc.title)", (res ? res->data : "")); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } if(res) { g_list_free_full(res, &g_free); } res = dt_metadata_get(image->id, "Xmp.dc.description", NULL); svgdoc = _string_substitute(svgdata, "$(Xmp.dc.description)", (res ? res->data : "")); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } if(res) { g_list_free_full(res, &g_free); } res = dt_metadata_get(image->id, "Xmp.dc.rights", NULL); svgdoc = _string_substitute(svgdata, "$(Xmp.dc.rights)", (res ? res->data : "")); if(svgdoc != svgdata) { g_free(svgdata); svgdata = svgdoc; } if(res) { g_list_free_full(res, &g_free); } } return svgdoc; }
bool zathura_init(zathura_t* zathura) { if (zathura == NULL) { return false; } /* create zathura (config/data) directory */ if (g_mkdir_with_parents(zathura->config.config_dir, 0771) == -1) { girara_error("Could not create '%s': %s", zathura->config.config_dir, strerror(errno)); } if (g_mkdir_with_parents(zathura->config.data_dir, 0771) == -1) { girara_error("Could not create '%s': %s", zathura->config.data_dir, strerror(errno)); } /* load plugins */ zathura_plugin_manager_load(zathura->plugins.manager); /* configuration */ config_load_default(zathura); config_load_files(zathura); /* UI */ if (girara_session_init(zathura->ui.session, "zathura") == false) { goto error_free; } /* girara events */ zathura->ui.session->events.buffer_changed = cb_buffer_changed; zathura->ui.session->events.unknown_command = cb_unknown_command; /* zathura signals */ zathura->signals.refresh_view = g_signal_new("refresh-view", GTK_TYPE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_POINTER); g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "refresh-view", G_CALLBACK(cb_refresh_view), zathura); /* page view */ zathura->ui.page_widget = gtk_grid_new(); gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); if (zathura->ui.page_widget == NULL) { goto error_free; } g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate", G_CALLBACK(cb_view_resized), zathura); GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); /* Connect hadjustment signals */ g_signal_connect(G_OBJECT(hadjustment), "value-changed", G_CALLBACK(cb_view_hadjustment_value_changed), zathura); g_signal_connect(G_OBJECT(hadjustment), "changed", G_CALLBACK(cb_view_hadjustment_changed), zathura); GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); /* Connect vadjustment signals */ g_signal_connect(G_OBJECT(vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura); g_signal_connect(G_OBJECT(vadjustment), "changed", G_CALLBACK(cb_view_vadjustment_changed), zathura); /* page view alignment */ gtk_widget_set_halign(zathura->ui.page_widget, GTK_ALIGN_CENTER); gtk_widget_set_valign(zathura->ui.page_widget, GTK_ALIGN_CENTER); gtk_widget_set_hexpand_set(zathura->ui.page_widget, TRUE); gtk_widget_set_hexpand(zathura->ui.page_widget, FALSE); gtk_widget_set_vexpand_set(zathura->ui.page_widget, TRUE); gtk_widget_set_vexpand(zathura->ui.page_widget, FALSE); gtk_widget_show(zathura->ui.page_widget); /* statusbar */ zathura->ui.statusbar.file = girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL); if (zathura->ui.statusbar.file == NULL) { goto error_free; } zathura->ui.statusbar.buffer = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL); if (zathura->ui.statusbar.buffer == NULL) { goto error_free; } zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL); if (zathura->ui.statusbar.page_number == NULL) { goto error_free; } girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, _("[No name]")); /* signals */ g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura); /* database */ char* database = NULL; girara_setting_get(zathura->ui.session, "database", &database); if (g_strcmp0(database, "plain") == 0) { girara_debug("Using plain database backend."); zathura->database = zathura_plaindatabase_new(zathura->config.data_dir); #ifdef WITH_SQLITE } else if (g_strcmp0(database, "sqlite") == 0) { girara_debug("Using sqlite database backend."); char* tmp = g_build_filename(zathura->config.data_dir, "bookmarks.sqlite", NULL); zathura->database = zathura_sqldatabase_new(tmp); g_free(tmp); #endif } else if (g_strcmp0(database, "null") != 0) { girara_error("Database backend '%s' is not supported.", database); } if (zathura->database == NULL && g_strcmp0(database, "null") != 0) { girara_error("Unable to initialize database. Bookmarks won't be available."); } else { g_object_set(G_OBJECT(zathura->ui.session->command_history), "io", zathura->database, NULL); } g_free(database); /* bookmarks */ zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare, (girara_free_function_t) zathura_bookmark_free); /* jumplist */ int jumplist_size = 20; girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size); zathura->jumplist.max_size = jumplist_size < 0 ? 0 : jumplist_size; zathura->jumplist.list = NULL; zathura->jumplist.size = 0; zathura->jumplist.cur = NULL; /* CSS for index mode */ GiraraTemplate* csstemplate = girara_session_get_template(zathura->ui.session); static const char* index_settings[] = { "index-fg", "index-bg", "index-active-fg", "index-active-bg" }; for (size_t s = 0; s < LENGTH(index_settings); ++s) { girara_template_add_variable(csstemplate, index_settings[s]); char* tmp_value = NULL; GdkRGBA rgba = { 0, 0, 0, 0 }; girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value); if (tmp_value != NULL) { gdk_rgba_parse(&rgba, tmp_value); g_free(tmp_value); } char* color = gdk_rgba_to_string(&rgba); girara_template_set_variable_value(csstemplate, index_settings[s], color); g_free(color); } char* css = g_strdup_printf("%s\n%s", girara_template_get_base(csstemplate), CSS_TEMPLATE_INDEX); girara_template_set_base(csstemplate, css); g_free(css); /* Start D-Bus service */ bool dbus = true; girara_setting_get(zathura->ui.session, "dbus-service", &dbus); if (dbus == true) { zathura->dbus = zathura_dbus_new(zathura); } return true; error_free: if (zathura->ui.page_widget != NULL) { g_object_unref(zathura->ui.page_widget); } return false; }
void gtk_widget_modify_bkg(GtkWidget *widget, GtkStateType state, GdkRGBA* color) { GtkStyleContext *context = gtk_widget_get_style_context(widget); GtkCssProvider *cssprv = gtk_css_provider_new(); char css[2048], strstate[256]; strstate[0] = '\0'; if (state == 0) { //GTK_STATE_FLAG_NORMAL strcat(strstate, ""); } if ((state << 0) == 1) { //GTK_STATE_FLAG_ACTIVE strcat(strstate, ":active"); } if ((state << 1) == 1) { //GTK_STATE_FLAG_PRELIGHT strcat(strstate, ":hoover"); } if ((state << 2) == 1) { //GTK_STATE_FLAG_SELECTED strcat(strstate, ":focus"); } if ((state << 3) == 1) { //GTK_STATE_FLAG_INSENSITIVE strcat(strstate, ":insensitive"); } if ((state << 4) == 1) { //GTK_STATE_FLAG_INCONSISTENT strcat(strstate, ""); } if ((state << 5) == 1) { //GTK_STATE_FLAG_FOCUSED strcat(strstate, "focus"); } //sprintf(css, "%s%s {\n background-color: %s;\n background-image: none;\n }\n", G_OBJECT_TYPE_NAME(widget), strstate, gdk_rgba_to_string(color)); sprintf(css, "%s%s {\n background-image: -gtk-gradient (linear, left top, left bottom, from (shade (%s, 1.1)), color-stop (0.5, shade (%s, 0.85)), to (shade (%s, 1.1)));\n }\n", G_OBJECT_TYPE_NAME(widget), strstate, gdk_rgba_to_string(color), gdk_rgba_to_string(color), gdk_rgba_to_string(color)); gtk_style_context_remove_provider(context, GTK_STYLE_PROVIDER (cssprv)); gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER (cssprv), GTK_STYLE_PROVIDER_PRIORITY_USER); gtk_css_provider_load_from_data(cssprv, css, -1, NULL); g_object_unref(cssprv); }