void mate_wp_item_update (MateWPItem *item) { GSettings *settings; GdkColor color1 = { 0, 0, 0, 0 }, color2 = { 0, 0, 0, 0 }; gchar *s; settings = g_settings_new (WP_SCHEMA); item->options = g_settings_get_enum (settings, WP_OPTIONS_KEY); item->shade_type = g_settings_get_enum (settings, WP_SHADING_KEY); s = g_settings_get_string (settings, WP_PCOLOR_KEY); if (s != NULL) { gdk_color_parse (s, &color1); g_free (s); } s = g_settings_get_string (settings, WP_SCOLOR_KEY); if (s != NULL) { gdk_color_parse (s, &color2); g_free (s); } g_object_unref (settings); if (item->pcolor != NULL) gdk_color_free (item->pcolor); if (item->scolor != NULL) gdk_color_free (item->scolor); item->pcolor = gdk_color_copy (&color1); item->scolor = gdk_color_copy (&color2); }
static int gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name, Lisp_Object device, Error_behavior errb) { GdkColor color; int result; result = gtk_parse_nearest_color (XDEVICE (device), &color, XSTRING_DATA (name), XSTRING_LENGTH (name), errb); if (!result) return 0; /* Don't allocate the data until we're sure that we will succeed, or the finalize method may get f****d. */ c->data = xnew (struct gtk_color_instance_data); if (result == 3) COLOR_INSTANCE_GTK_DEALLOC (c) = 0; else COLOR_INSTANCE_GTK_DEALLOC (c) = 1; COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color); return 1; }
/* * TODO This should really be replaced with generated code once the codegen * takes care of allocating Boxeds, although having the setters direct in the * constructor is handy. */ JNIEXPORT jlong JNICALL Java_org_gnome_gdk_GdkColorOverride_gdk_1color_1new ( JNIEnv* env, jclass cls, jint _red, jint _green, jint _blue ) { GdkColor blank = { 0, }; GdkColor* result; // blank is allocated locally on the stack blank.red = (gint) _red; blank.green = (gint) _green; blank.blue = (gint) _blue; // copy blank result = gdk_color_copy(&blank); // and finally return (jlong) result; }
/** * 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->font) pango_font_description_free (dest->font); /* Copy */ orig_refcount = dest->refcount; *dest = *src; if (src->tabs) dest->tabs = pango_tab_array_copy (src->tabs); dest->language = src->language; if (dest->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); dest->refcount = orig_refcount; }
static void table_set_bg_color (HTMLEngine *e, HTMLTable *t, GdkColor *c, HTMLUndoDirection dir) { HTMLTableSetAttrUndo *undo; undo = attr_undo_new (HTML_TABLE_BGCOLOR); if (t->bgColor) { undo->attr.color.color = *t->bgColor; undo->attr.color.has_bg_color = TRUE; } else undo->attr.color.has_bg_color = FALSE; html_undo_add_action (e->undo, e, html_undo_action_new ("Set table background color", table_set_bg_color_undo_action, HTML_UNDO_DATA (undo), html_cursor_get_position (e->cursor), html_cursor_get_position (e->cursor)), dir); if (c) { if (!t->bgColor) t->bgColor = gdk_color_copy (c); *t->bgColor = *c; } else { if (t->bgColor) gdk_color_free (t->bgColor); t->bgColor = NULL; } html_engine_queue_draw (e, HTML_OBJECT (t)); }
void termit_tab_set_color_background(struct TermitTab* pTab, const GdkColor* p_color) { if (p_color) { pTab->style.background_color = gdk_color_copy(p_color); vte_terminal_set_color_background(VTE_TERMINAL(pTab->vte), pTab->style.background_color); } }
void gc_set_foreground_xor(GdkGC *gc, GdkColor *col1, GdkColor *col2) { GdkColor newcol; newcol.pixel = XOR(col1->pixel, col2->pixel); newcol.red = XOR(col1->red, col2->red); newcol.green = XOR(col1->green, col2->green); newcol.blue = XOR(col1->blue, col2->blue); gdk_gc_set_foreground(gc, gdk_color_copy(&newcol)); /* memleak? */ }
gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamData data, VikViewport *vp ) { switch ( id ) { case PARAM_COLOR: if ( vcl->color ) gdk_color_free ( vcl->color ); vcl->color = gdk_color_copy( &(data.c)); break; case PARAM_MIN_INC: vcl->deg_inc = data.d / 60.0; break; case PARAM_LINE_THICKNESS: if ( data.u >= 1 && data.u <= 15 ) vcl->line_thickness = data.u; break; } return TRUE; }
void termit_config_get_color(GdkColor** opt, lua_State* ls, int index) { gchar* color_str = NULL; termit_config_get_string(&color_str, ls, index); if (color_str) { GdkColor color = {}; if (gdk_color_parse(color_str, &color) == TRUE) { *opt = gdk_color_copy(&color); TRACE("color_str=%s", color_str); } } g_free(color_str); }
static GdkColor * parse_color(xmlnode *node, const char *tag) { const char *temp = xmlnode_get_attrib(node, tag); GdkColor color; if (temp && gdk_color_parse(temp, &color)) { gdk_colormap_alloc_color(gdk_colormap_get_system(), &color, FALSE, TRUE); return gdk_color_copy(&color); } else { return NULL; } }
static void coord_layer_update_gc ( VikCoordLayer *vcl, VikViewport *vp, const gchar *color ) { GdkColor InitColor; if ( vcl->color ) gdk_color_free ( vcl->color ); gdk_color_parse( color, &InitColor); vcl->color = gdk_color_copy( &InitColor ); if ( vcl->gc ) g_object_unref ( G_OBJECT(vcl->gc) ); vcl->gc = vik_viewport_new_gc_from_color ( vp, vcl->color, vcl->line_thickness ); }
void gs_graph_set_grid_color (GsGraph *graph, const GdkColor *color) { g_return_if_fail (GS_IS_GRAPH (graph)); g_return_if_fail (color != NULL); GdkColor *ncolor = gdk_color_copy (color); g_free (graph->priv->grid_color); graph->priv->grid_color = ncolor; if (graph->priv->show_grid) { gtk_widget_queue_draw (GTK_WIDGET (graph)); } }
void gs_graph_set_axes_color (GsGraph *graph, const GdkColor *color) { g_return_if_fail (GS_IS_GRAPH (graph)); g_return_if_fail (color != NULL); GdkColor *ncolor = gdk_color_copy (color); g_free (graph->priv->axes_color); graph->priv->axes_color = ncolor; if (graph->priv->show_horizontal_axis || graph->priv->show_vertical_axis) { gtk_widget_queue_draw (GTK_WIDGET (graph)); } }
VikCoordLayer *vik_coord_layer_new ( ) { GdkColor InitColor; VikCoordLayer *vcl = VIK_COORD_LAYER ( g_object_new ( VIK_COORD_LAYER_TYPE, NULL ) ); vik_layer_init ( VIK_LAYER(vcl), VIK_LAYER_COORD ); InitColor.pixel = 0; InitColor.red = 65535; InitColor.green = 65535; InitColor.blue = 65535; vcl->gc = NULL; vcl->deg_inc = 1.0/60.0; vcl->line_thickness = 3; vcl->color = gdk_color_copy (&InitColor); return vcl; }
void prefs_set_color_gdk (Prefs *p, Color which, GdkColor *color) { gboolean changed = FALSE; if (p->color[which]) { changed = !gdk_color_equal (color, p->color[which]); gdk_color_free (p->color[which]); } p->color[which] = gdk_color_copy (color); if (changed) { gchar *spec; spec = prefs_colors_to_csvstr (p); gconf_client_set_string (p->gconf_client, PREF_CARD_COLORS, spec, NULL); g_free (spec); } }
static void mate_wp_xml_load_xml (AppearanceData *data, const gchar * filename) { xmlDoc * wplist; xmlNode * root, * list, * wpa; xmlChar * nodelang; const gchar * const * syslangs; GdkColor color1, color2; gint i; wplist = xmlParseFile (filename); if (!wplist) return; syslangs = g_get_language_names (); root = xmlDocGetRootElement (wplist); for (list = root->children; list != NULL; list = list->next) { if (!strcmp ((gchar *)list->name, "wallpaper")) { MateWPItem * wp; gchar *pcolor = NULL, *scolor = NULL; gchar *s; gboolean have_scale = FALSE, have_shade = FALSE; wp = g_new0 (MateWPItem, 1); wp->deleted = mate_wp_xml_get_bool (list, "deleted"); for (wpa = list->children; wpa != NULL; wpa = wpa->next) { if (wpa->type == XML_COMMENT_NODE) { continue; } else if (!strcmp ((gchar *)wpa->name, "filename")) { if (wpa->last != NULL && wpa->last->content != NULL) { const char * none = "(none)"; gchar *content = g_strstrip ((gchar *)wpa->last->content); if (!strcmp (content, none)) wp->filename = g_strdup (content); else if (g_utf8_validate (content, -1, NULL) && g_file_test (content, G_FILE_TEST_EXISTS)) wp->filename = g_strdup (content); else wp->filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL); } else { break; } } else if (!strcmp ((gchar *)wpa->name, "name")) { if (wpa->last != NULL && wpa->last->content != NULL) { nodelang = xmlNodeGetLang (wpa->last); if (wp->name == NULL && nodelang == NULL) { wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content)); } else { for (i = 0; syslangs[i] != NULL; i++) { if (!strcmp (syslangs[i], (gchar *)nodelang)) { g_free (wp->name); wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content)); break; } } } xmlFree (nodelang); } else { break; } } else if (!strcmp ((gchar *)wpa->name, "options")) { if (wpa->last != NULL) { wp->options = wp_item_string_to_option (g_strstrip ((gchar *)wpa->last->content)); have_scale = TRUE; } } else if (!strcmp ((gchar *)wpa->name, "shade_type")) { if (wpa->last != NULL) { wp->shade_type = wp_item_string_to_shading (g_strstrip ((gchar *)wpa->last->content)); have_shade = TRUE; } } else if (!strcmp ((gchar *)wpa->name, "pcolor")) { if (wpa->last != NULL) { pcolor = g_strdup (g_strstrip ((gchar *)wpa->last->content)); } } else if (!strcmp ((gchar *)wpa->name, "scolor")) { if (wpa->last != NULL) { scolor = g_strdup (g_strstrip ((gchar *)wpa->last->content)); } } else if (!strcmp ((gchar *)wpa->name, "text")) { /* Do nothing here, libxml2 is being weird */ } else { g_warning ("Unknown Tag: %s", wpa->name); } } /* Make sure we don't already have this one and that filename exists */ if (wp->filename == NULL || g_hash_table_lookup (data->wp_hash, wp->filename) != NULL) { mate_wp_item_free (wp); g_free (pcolor); g_free (scolor); continue; } /* Verify the colors and alloc some GdkColors here */ if (!have_scale) { s = mateconf_client_get_string (data->client, WP_OPTIONS_KEY, NULL); wp->options = wp_item_string_to_option (s); g_free (s); } if (!have_shade) { s = mateconf_client_get_string (data->client, WP_SHADING_KEY, NULL); wp->shade_type = wp_item_string_to_shading (s); g_free (s); } if (pcolor == NULL) { pcolor = mateconf_client_get_string (data->client, WP_PCOLOR_KEY, NULL); } if (scolor == NULL) { scolor = mateconf_client_get_string (data->client, WP_SCOLOR_KEY, NULL); } gdk_color_parse (pcolor, &color1); gdk_color_parse (scolor, &color2); g_free (pcolor); g_free (scolor); wp->pcolor = gdk_color_copy (&color1); wp->scolor = gdk_color_copy (&color2); if ((wp->filename != NULL && g_file_test (wp->filename, G_FILE_TEST_EXISTS)) || !strcmp (wp->filename, "(none)")) { wp->fileinfo = mate_wp_info_new (wp->filename, data->thumb_factory); if (wp->name == NULL || !strcmp (wp->filename, "(none)")) { g_free (wp->name); wp->name = g_strdup (wp->fileinfo->name); } mate_wp_item_ensure_mate_bg (wp); mate_wp_item_update_description (wp); g_hash_table_insert (data->wp_hash, wp->filename, wp); } else { mate_wp_item_free (wp); wp = NULL; } } } xmlFreeDoc (wplist); }
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; }
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) { dest->appearance.bg_color = vals->appearance.bg_color; dest->appearance.draw_bg = TRUE; } if (tag->priv->fg_color_set) dest->appearance.fg_color = vals->appearance.fg_color; if (tag->priv->pg_bg_color_set) { 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; }
/** * 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); G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (dest->pg_bg_color) gdk_color_free (dest->pg_bg_color); G_GNUC_END_IGNORE_DEPRECATIONS 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]); if (dest->font_features) g_free (dest->font_features); /* 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); G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (src->pg_bg_color) dest->pg_bg_color = gdk_color_copy (src->pg_bg_color); G_GNUC_END_IGNORE_DEPRECATIONS 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]); if (src->font_features) dest->font_features = g_strdup (src->font_features); dest->refcount = orig_refcount; }