/** * gtk_text_attributes_copy_values: * @src: a #GtkTextAttributes * @dest: another #GtkTextAttributes * * Copies the values from @src to @dest so that @dest has * the same values as @src. Frees existing values in @dest. */ void gtk_text_attributes_copy_values (GtkTextAttributes *src, GtkTextAttributes *dest) { guint orig_refcount; if (src == dest) return; /* Remove refs */ if (dest->tabs) pango_tab_array_free (dest->tabs); if (dest->font) pango_font_description_free (dest->font); if (dest->pg_bg_color) gdk_color_free (dest->pg_bg_color); if (dest->pg_bg_rgba) gdk_rgba_free (dest->pg_bg_rgba); if (dest->appearance.rgba[0]) gdk_rgba_free (dest->appearance.rgba[0]); if (dest->appearance.rgba[1]) gdk_rgba_free (dest->appearance.rgba[1]); /* Copy */ orig_refcount = dest->refcount; *dest = *src; if (src->tabs) dest->tabs = pango_tab_array_copy (src->tabs); dest->language = src->language; if (src->font) dest->font = pango_font_description_copy (src->font); if (src->pg_bg_color) dest->pg_bg_color = gdk_color_copy (src->pg_bg_color); if (src->pg_bg_rgba) dest->pg_bg_rgba = gdk_rgba_copy (src->pg_bg_rgba); if (src->appearance.rgba[0]) dest->appearance.rgba[0] = gdk_rgba_copy (src->appearance.rgba[0]); if (src->appearance.rgba[1]) dest->appearance.rgba[1] = gdk_rgba_copy (src->appearance.rgba[1]); dest->refcount = orig_refcount; }
void app_init_colors (App * app) { GdkRGBA active_color = { 1, 0, 0, 1 }; GdkRGBA inactive_color = { 0, 1, 0, 1 }; app->active_color = g_new0 (GdkRGBA, 1); app->inactive_color = g_new0 (GdkRGBA, 1); app->active_color = gdk_rgba_copy (&active_color); app->inactive_color = gdk_rgba_copy (&inactive_color); }
static void biji_note_obj_set_rgba_internal (BijiNoteObj *n, GdkRGBA *rgba) { n->priv->color = gdk_rgba_copy(rgba); g_signal_emit (G_OBJECT (n), biji_obj_signals[NOTE_COLOR_CHANGED],0); }
void xmr_label_set_color(XmrLabel *label, const gchar *color) { GdkRGBA gdk_color; XmrLabelPrivate *priv; g_return_if_fail(label != NULL); priv = label->priv; if (color == NULL) { gdk_rgba_free(priv->current_color); priv->current_color = gdk_rgba_copy(&priv->default_color); } else { if (gdk_rgba_parse(&gdk_color, color)) { priv->current_color->red = gdk_color.red; priv->current_color->green = gdk_color.green; priv->current_color->blue = gdk_color.blue; // always set to 1.0 priv->current_color->alpha = 1.0; } } gtk_widget_queue_draw(GTK_WIDGET(label)); }
static void unico_draw_focus (DRAW_ARGS) { GdkRGBA *fill_color, *border_color; GtkStateFlags state; gint focus_pad, line_width; gint radius; state = gtk_theming_engine_get_state (engine); gtk_theming_engine_get_style (engine, "focus-padding", &focus_pad, "focus-line-width", &line_width, NULL); /* Skip rendering if focus-line-width is 0 or less. */ if (line_width < 1) return; /* Use the outline attributes for the focus properties to avoid using * custom attributes. Outlines don't have a fill, so hardcode the fill * color to be the same color as the border, but with 20% of its alpha. */ gtk_theming_engine_get (engine, state, "outline-color", &border_color, "outline-offset", &radius, NULL); fill_color = gdk_rgba_copy (border_color); fill_color->alpha = border_color->alpha * 0.2; x += focus_pad; y += focus_pad; width -= focus_pad * 2; height -= focus_pad * 2; cairo_save (cr); cairo_set_line_width (cr, line_width); /* first layer, background */ unico_cairo_round_rect (cr, x, y, width, height, radius, SIDE_ALL, GTK_JUNCTION_NONE); gdk_cairo_set_source_rgba (cr, fill_color); cairo_fill (cr); /* second layer, border */ unico_cairo_round_rect_inner (cr, x, y, width, height, radius, SIDE_ALL, GTK_JUNCTION_NONE); gdk_cairo_set_source_rgba (cr, border_color); cairo_stroke (cr); cairo_restore (cr); gdk_rgba_free (border_color); gdk_rgba_free (fill_color); }
GdkRGBA* warlock_color_button_get_color (WarlockColorButton *button) { if (button->active) return gdk_rgba_copy (button->color); else return NULL; }
static void gtk_numerable_icon_init (GtkNumerableIcon *self) { GdkRGBA bg; GdkRGBA fg; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_NUMERABLE_ICON, GtkNumerableIconPrivate); gdk_rgba_parse (&bg, DEFAULT_BACKGROUND); gdk_rgba_parse (&fg, DEFAULT_FOREGROUND); self->priv->background = gdk_rgba_copy (&bg); self->priv->foreground = gdk_rgba_copy (&fg); self->priv->icon_size = 48; }
static gboolean parseBackgroundColor(const char *optionName, const char *value, gpointer data, GError **error) { GdkRGBA rgba; if (gdk_rgba_parse(&rgba, value)) { backgroundColor = gdk_rgba_copy(&rgba); return TRUE; } g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, "Failed to parse '%s' as RGBA color", value); return FALSE; }
static void biji_note_obj_set_rgba_internal (BijiNoteObj *n, GdkRGBA *rgba) { n->priv->color = gdk_rgba_copy(rgba); n->priv->icon_needs_update = TRUE; biji_note_id_set_last_metadata_change_date_now (n->priv->id); biji_note_obj_save_note (n); /* Make editor & notebook know about this change */ g_signal_emit (G_OBJECT (n), biji_obj_signals[NOTE_COLOR_CHANGED],0); g_signal_emit (G_OBJECT (n), biji_obj_signals[NOTE_CHANGED],0); }
void _gtk_modifier_style_set_color_property (GtkModifierStyle *style, GType widget_type, const gchar *prop_name, const GdkRGBA *color) { GtkModifierStylePrivate *priv; const GdkRGBA *old_color; gchar *str; g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); g_return_if_fail (g_type_is_a (widget_type, GTK_TYPE_WIDGET)); g_return_if_fail (prop_name != NULL); priv = style->priv; str = g_strdup_printf ("-%s-%s", g_type_name (widget_type), prop_name); old_color = g_hash_table_lookup (priv->color_properties, str); if ((!color && !old_color) || (color && old_color && gdk_rgba_equal (color, old_color))) { g_free (str); return; } if (color) { g_hash_table_insert (priv->color_properties, str, gdk_rgba_copy (color)); } else { g_hash_table_remove (priv->color_properties, str); g_free (str); } g_signal_emit (style, signals[CHANGED], 0); _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style)); }
static void xmr_label_init(XmrLabel *label) { XmrLabelPrivate *priv; GtkStyleContext *context; label->priv = G_TYPE_INSTANCE_GET_PRIVATE(label, XMR_TYPE_LABEL, XmrLabelPrivate); priv = label->priv; priv->timeout_id = 0; priv->text = NULL; priv->layout = NULL; priv->current_x = 0; context = gtk_widget_get_style_context(GTK_WIDGET(label)); gtk_style_context_lookup_color(context, "text_color", &priv->default_color); if (priv->default_color.alpha <= 0) priv->default_color.alpha = 1.0; priv->current_color = gdk_rgba_copy(&priv->default_color); gtk_widget_set_app_paintable(GTK_WIDGET(label), TRUE); }
static void gtk_numerable_icon_update_properties_from_style (GtkNumerableIcon *self) { GtkStyleContext *style = self->priv->style; GtkWidgetPath *path, *saved; cairo_pattern_t *pattern = NULL; GdkRGBA background, foreground; PangoFontDescription *font = NULL; /* save an unmodified copy of the original widget path, in order * to restore it later */ path = gtk_widget_path_copy (gtk_style_context_get_path (style)); saved = gtk_widget_path_copy (path); if (!gtk_widget_path_is_type (path, GTK_TYPE_NUMERABLE_ICON)) { /* append our GType to the style context to fetch appropriate colors */ gtk_widget_path_append_type (path, GTK_TYPE_NUMERABLE_ICON); gtk_style_context_set_path (style, path); } gtk_style_context_get_background_color (style, gtk_style_context_get_state (style), &background); gtk_style_context_get_color (style, gtk_style_context_get_state (style), &foreground); if (self->priv->background != NULL) gdk_rgba_free (self->priv->background); self->priv->background = gdk_rgba_copy (&background); if (self->priv->foreground != NULL) gdk_rgba_free (self->priv->foreground); self->priv->foreground = gdk_rgba_copy (&foreground); gtk_style_context_get (style, gtk_style_context_get_state (style), GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &pattern, NULL); if (pattern != NULL) { if (self->priv->background_image != NULL) cairo_pattern_destroy (self->priv->background_image); self->priv->background_image = pattern; } gtk_style_context_get (style, gtk_style_context_get_state (style), GTK_STYLE_PROPERTY_FONT, &font, NULL); if (font != NULL) { if (self->priv->font != NULL) pango_font_description_free (self->priv->font); self->priv->font = font; } gtk_numerable_icon_ensure_emblem (self); /* restore original widget path */ gtk_style_context_set_path (style, saved); gtk_widget_path_free (path); gtk_widget_path_free (saved); }
void _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest, GtkTextTag** tags, guint n_tags) { guint n = 0; guint left_margin_accumulative = 0; guint right_margin_accumulative = 0; while (n < n_tags) { GtkTextTag *tag = tags[n]; GtkTextAttributes *vals = tag->priv->values; g_assert (tag->priv->table != NULL); if (n > 0) g_assert (tags[n]->priv->priority > tags[n-1]->priv->priority); if (tag->priv->bg_color_set) { if (dest->appearance.rgba[0]) { gdk_rgba_free (dest->appearance.rgba[0]); dest->appearance.rgba[0] = NULL; } if (vals->appearance.rgba[0]) dest->appearance.rgba[0] = gdk_rgba_copy (vals->appearance.rgba[0]); dest->appearance.draw_bg = TRUE; } if (tag->priv->fg_color_set) { if (dest->appearance.rgba[1]) { gdk_rgba_free (dest->appearance.rgba[1]); dest->appearance.rgba[1] = NULL; } if (vals->appearance.rgba[1]) dest->appearance.rgba[1] = gdk_rgba_copy (vals->appearance.rgba[1]); } if (tag->priv->pg_bg_color_set) { if (dest->pg_bg_rgba) { gdk_rgba_free (dest->pg_bg_rgba); dest->pg_bg_rgba = NULL; } if (dest->pg_bg_color) { gdk_color_free (dest->pg_bg_color); dest->pg_bg_color = NULL; } if (vals->pg_bg_rgba) dest->pg_bg_rgba = gdk_rgba_copy (vals->pg_bg_rgba); if (vals->pg_bg_color) dest->pg_bg_color = gdk_color_copy (vals->pg_bg_color); } if (vals->font) { if (dest->font) pango_font_description_merge (dest->font, vals->font, TRUE); else dest->font = pango_font_description_copy (vals->font); } /* multiply all the scales together to get a composite */ if (tag->priv->scale_set) dest->font_scale *= vals->font_scale; if (tag->priv->justification_set) dest->justification = vals->justification; if (vals->direction != GTK_TEXT_DIR_NONE) dest->direction = vals->direction; if (tag->priv->left_margin_set) { if (tag->priv->accumulative_margin) left_margin_accumulative += vals->left_margin; else dest->left_margin = vals->left_margin; } if (tag->priv->indent_set) dest->indent = vals->indent; if (tag->priv->rise_set) dest->appearance.rise = vals->appearance.rise; if (tag->priv->right_margin_set) { if (tag->priv->accumulative_margin) right_margin_accumulative += vals->right_margin; else dest->right_margin = vals->right_margin; } if (tag->priv->pixels_above_lines_set) dest->pixels_above_lines = vals->pixels_above_lines; if (tag->priv->pixels_below_lines_set) dest->pixels_below_lines = vals->pixels_below_lines; if (tag->priv->pixels_inside_wrap_set) dest->pixels_inside_wrap = vals->pixels_inside_wrap; if (tag->priv->tabs_set) { if (dest->tabs) pango_tab_array_free (dest->tabs); dest->tabs = pango_tab_array_copy (vals->tabs); } if (tag->priv->wrap_mode_set) dest->wrap_mode = vals->wrap_mode; if (tag->priv->underline_set) dest->appearance.underline = vals->appearance.underline; if (tag->priv->strikethrough_set) dest->appearance.strikethrough = vals->appearance.strikethrough; if (tag->priv->invisible_set) dest->invisible = vals->invisible; if (tag->priv->editable_set) dest->editable = vals->editable; if (tag->priv->bg_full_height_set) dest->bg_full_height = vals->bg_full_height; if (tag->priv->language_set) dest->language = vals->language; ++n; } dest->left_margin += left_margin_accumulative; dest->right_margin += right_margin_accumulative; }
void _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest, GtkTextTag** tags, guint n_tags) { guint n = 0; guint left_margin_accumulative = 0; guint right_margin_accumulative = 0; while (n < n_tags) { GtkTextTag *tag = tags[n]; GtkTextAttributes *vals = tag->priv->values; g_assert (tag->priv->table != NULL); if (n > 0) g_assert (tags[n]->priv->priority > tags[n-1]->priv->priority); if (tag->priv->bg_color_set) { if (dest->appearance.rgba[0]) { gdk_rgba_free (dest->appearance.rgba[0]); dest->appearance.rgba[0] = NULL; } if (vals->appearance.rgba[0]) dest->appearance.rgba[0] = gdk_rgba_copy (vals->appearance.rgba[0]); dest->appearance.draw_bg = TRUE; } if (tag->priv->fg_color_set) { if (dest->appearance.rgba[1]) { gdk_rgba_free (dest->appearance.rgba[1]); dest->appearance.rgba[1] = NULL; } if (vals->appearance.rgba[1]) dest->appearance.rgba[1] = gdk_rgba_copy (vals->appearance.rgba[1]); } if (tag->priv->pg_bg_color_set) { if (dest->pg_bg_rgba) { gdk_rgba_free (dest->pg_bg_rgba); dest->pg_bg_rgba = NULL; } if (dest->pg_bg_color) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS gdk_color_free (dest->pg_bg_color); dest->pg_bg_color = NULL; G_GNUC_END_IGNORE_DEPRECATIONS } if (vals->pg_bg_rgba) dest->pg_bg_rgba = gdk_rgba_copy (vals->pg_bg_rgba); G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (vals->pg_bg_color) dest->pg_bg_color = gdk_color_copy (vals->pg_bg_color); G_GNUC_END_IGNORE_DEPRECATIONS } if (vals->font) { if (dest->font) pango_font_description_merge (dest->font, vals->font, TRUE); else dest->font = pango_font_description_copy (vals->font); } /* multiply all the scales together to get a composite */ if (tag->priv->scale_set) dest->font_scale *= vals->font_scale; if (tag->priv->justification_set) dest->justification = vals->justification; if (vals->direction != GTK_TEXT_DIR_NONE) dest->direction = vals->direction; if (tag->priv->left_margin_set) { if (tag->priv->accumulative_margin) left_margin_accumulative += vals->left_margin; else dest->left_margin = vals->left_margin; } if (tag->priv->indent_set) dest->indent = vals->indent; if (tag->priv->rise_set) dest->appearance.rise = vals->appearance.rise; if (tag->priv->right_margin_set) { if (tag->priv->accumulative_margin) right_margin_accumulative += vals->right_margin; else dest->right_margin = vals->right_margin; } if (tag->priv->pixels_above_lines_set) dest->pixels_above_lines = vals->pixels_above_lines; if (tag->priv->pixels_below_lines_set) dest->pixels_below_lines = vals->pixels_below_lines; if (tag->priv->pixels_inside_wrap_set) dest->pixels_inside_wrap = vals->pixels_inside_wrap; if (tag->priv->tabs_set) { if (dest->tabs) pango_tab_array_free (dest->tabs); dest->tabs = pango_tab_array_copy (vals->tabs); } if (tag->priv->wrap_mode_set) dest->wrap_mode = vals->wrap_mode; if (tag->priv->underline_set) dest->appearance.underline = vals->appearance.underline; if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&vals->appearance)) { GdkRGBA rgba; GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&vals->appearance, &rgba); GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&dest->appearance, &rgba); GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&dest->appearance, TRUE); } if (tag->priv->strikethrough_set) dest->appearance.strikethrough = vals->appearance.strikethrough; if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&vals->appearance)) { GdkRGBA rgba; GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&vals->appearance, &rgba); GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&dest->appearance, &rgba); GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&dest->appearance, TRUE); } if (tag->priv->invisible_set) dest->invisible = vals->invisible; if (tag->priv->editable_set) dest->editable = vals->editable; if (tag->priv->bg_full_height_set) dest->bg_full_height = vals->bg_full_height; if (tag->priv->language_set) dest->language = vals->language; if (tag->priv->fallback_set) dest->no_fallback = vals->no_fallback; if (tag->priv->letter_spacing_set) dest->letter_spacing = vals->letter_spacing; if (tag->priv->font_features_set) dest->font_features = g_strdup (vals->font_features); ++n; }