static void bg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA) { GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_get_background_color(sc, state, &gdkRGBA); if (gdkRGBA.alpha <= 0) { widget = gtk_widget_get_parent(GTK_WIDGET(ContainerWidget())); sc = gtk_widget_get_style_context(widget); gtk_style_context_get_background_color(sc, state, &gdkRGBA); } }
static void cell_set_background (EmpathyPersonaView *self, GtkCellRenderer *cell, gboolean is_active) { if (is_active) { GdkRGBA color; GtkStyleContext *style; style = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color); /* Here we take the current theme colour and add it to * the colour for white and average the two. This * gives a colour which is inline with the theme but * slightly whiter. */ empathy_make_color_whiter (&color); g_object_set (cell, "cell-background-rgba", &color, NULL); } else { g_object_set (cell, "cell-background-rgba", NULL, NULL); } }
/* function to highlight label */ void highlight(GtkWidget *eventbox) { GtkWidget *label, *lighted_eventbox, *lighted_label; GList *child; GtkStyleContext *context; GdkRGBA selected_fg, selected_bg; /* get label from eventbox */ child = gtk_container_get_children(GTK_CONTAINER(eventbox)); label = child->data; /* prepare highlight colors */ context = gtk_widget_get_style_context(label); gtk_style_context_get_color(context, GTK_STATE_FLAG_SELECTED, &selected_fg); gtk_style_context_get_background_color(context, GTK_STATE_FLAG_SELECTED, &selected_bg); /* clearcolor previous highlighted label */ lighted_eventbox = g_object_get_data(G_OBJECT(builder), "lighted_eventbox"); if(lighted_eventbox) { child = gtk_container_get_children(GTK_CONTAINER(lighted_eventbox)); lighted_label = child->data; clearcolor(lighted_label, lighted_eventbox); } /* apply color */ gtk_widget_override_color(label, GTK_STATE_FLAG_NORMAL, &selected_fg); gtk_widget_override_background_color(eventbox, GTK_STATE_FLAG_NORMAL, &selected_bg); /* set current eventbox as lighted */ g_object_set_data(G_OBJECT(builder), "lighted_eventbox", eventbox); }
wxColor DrawingUtils::GetPanelBgColour() { #ifdef __WXGTK__ static bool intitialized(false); static wxColour bgColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); if( !intitialized ) { // try to get the background colour from a menu GtkWidget *menu = gtk_window_new(GTK_WINDOW_TOPLEVEL); #ifdef __WXGTK3__ GdkRGBA col; GtkStyleContext* context = gtk_widget_get_style_context( menu ); gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &col); bgColour = wxColour(col); #else GtkStyle *def = gtk_rc_get_style( menu ); if(!def) def = gtk_widget_get_default_style(); if(def) { GdkColor col = def->bg[GTK_STATE_NORMAL]; bgColour = wxColour(col); } #endif gtk_widget_destroy( menu ); intitialized = true; } return bgColour; #else return wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); #endif }
static void _gtk_theming_background_init_context (GtkThemingBackground *bg) { bg->flags = gtk_style_context_get_state (bg->context); gtk_style_context_get_border (bg->context, bg->flags, &bg->border); gtk_style_context_get_padding (bg->context, bg->flags, &bg->padding); gtk_style_context_get_background_color (bg->context, bg->flags, &bg->bg_color); /* In the CSS box model, by default the background positioning area is * the padding-box, i.e. all the border-box minus the borders themselves, * which determines also its default size, see * http://dev.w3.org/csswg/css3-background/#background-origin * * In the future we might want to support different origins or clips, but * right now we just shrink to the default. */ _gtk_rounded_box_init_rect (&bg->border_box, 0, 0, bg->paint_area.width, bg->paint_area.height); _gtk_rounded_box_apply_border_radius_for_context (&bg->border_box, bg->context, bg->junction); bg->padding_box = bg->border_box; _gtk_rounded_box_shrink (&bg->padding_box, bg->border.top, bg->border.right, bg->border.bottom, bg->border.left); }
wxColor DrawingUtils::GetMenuBarBgColour() { #ifdef __WXGTK__ static bool intitialized(false); static wxColour textColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR)); if( !intitialized ) { // try to get the background colour from a menu GtkWidget *menuBar = gtk_menu_bar_new(); #ifdef __WXGTK3__ GdkRGBA col; GtkStyleContext* context = gtk_widget_get_style_context( menuBar ); gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &col); textColour = wxColour(col); #else GtkStyle *def = gtk_rc_get_style( menuBar ); if(!def) def = gtk_widget_get_default_style(); if(def) { GdkColor col = def->bg[GTK_STATE_NORMAL]; textColour = wxColour(col); } #endif gtk_widget_destroy( menuBar ); intitialized = true; } return textColour; #else return wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR); #endif }
static gboolean draw_box_back (GtkWidget *widget, cairo_t *cr, gpointer user_data) { GtkStyleContext *context; GdkRGBA acolor; int width; int height; context = gtk_widget_get_style_context (widget); width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); cairo_paint (cr); draw_rounded_rectangle (cr, 1.0, 0.0, 0.0, height/10, width-1, height-1); gtk_style_context_get_background_color (context, GTK_STATE_NORMAL, &acolor); color_reverse (&acolor); acolor.alpha = BACKGROUND_ALPHA; gdk_cairo_set_source_rgba (cr, &acolor); cairo_fill(cr); return FALSE; }
static void style_context_changed (GtkStyleContext *style_context, GbTerminalView *self) { GtkStateFlags state; GdkRGBA fg; GdkRGBA bg; g_assert (GTK_IS_STYLE_CONTEXT (style_context)); g_assert (GB_IS_TERMINAL_VIEW (self)); state = gtk_style_context_get_state (style_context); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; gtk_style_context_get_color (style_context, state, &fg); gtk_style_context_get_background_color (style_context, state, &bg); G_GNUC_END_IGNORE_DEPRECATIONS; if (bg.alpha == 0.0) { gdk_rgba_parse (&bg, "#f6f7f8"); } vte_terminal_set_colors (self->terminal_top, &fg, &bg, solarized_palette, G_N_ELEMENTS (solarized_palette)); if (self->terminal_bottom) vte_terminal_set_colors (self->terminal_bottom, &fg, &bg, solarized_palette, G_N_ELEMENTS (solarized_palette)); }
static void get_color (gint i, gfloat * r, gfloat * g, gfloat * b) { static GdkRGBA c; static bool_t valid = FALSE; gfloat h, s, v, n; if (! valid) { /* we want a color that matches the current theme * selected color of a GtkEntry should be reasonable */ GtkStyleContext * style = gtk_style_context_new (); GtkWidgetPath * path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_ENTRY); gtk_style_context_set_path (style, path); gtk_widget_path_free (path); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, & c); g_object_unref (style); valid = TRUE; } rgb_to_hsv (c.red, c.green, c.blue, & h, & s, & v); if (s < 0.1) /* monochrome theme? use blue instead */ { h = 5; s = 0.75; } n = i / (gfloat) (bands - 1); s = 1 - 0.9 * n; v = 0.75 + 0.25 * n; hsv_to_rgb (h, s, v, r, g, b); }
static void bmwi_context_changed_cb(GtkStyleContext * context, BalsaMimeWidget * mw) { GdkRGBA rgba; gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &rgba); gtk_widget_override_background_color(mw->widget, GTK_STATE_FLAG_NORMAL, &rgba); }
static void cloud_map (GtkWidget *widget) { GTK_WIDGET_CLASS (parent_class)->map (widget); GtkStyleContext *style_context; GdkRGBA color; style_context = gtk_widget_get_style_context (widget); gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &color); gtk_widget_override_background_color (GDAUI_CLOUD (widget)->priv->tview, GTK_STATE_FLAG_NORMAL, &color); }
static cairo_surface_t * tile_surface (cairo_surface_t *surface, int width, int height) { cairo_surface_t *copy; cairo_t *cr; if (surface == NULL) { copy = gdk_window_create_similar_surface (gdk_get_default_root_window (), CAIRO_CONTENT_COLOR, width, height); } else { copy = cairo_surface_create_similar (surface, cairo_surface_get_content (surface), width, height); } cr = cairo_create (copy); if (surface != NULL) { cairo_pattern_t *pattern; cairo_set_source_surface (cr, surface, 0.0, 0.0); pattern = cairo_get_source (cr); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); } else { GtkStyleContext *context; GdkRGBA bg; context = gtk_style_context_new (); gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (gtk_css_provider_get_default ()), GTK_STYLE_PROVIDER_PRIORITY_THEME); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); gdk_cairo_set_source_rgba(cr, &bg); g_object_unref (G_OBJECT (context)); } cairo_paint (cr); if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy (copy); copy = NULL; } cairo_destroy(cr); return copy; }
void GR_UnixCairoGraphics::init3dColors(GtkWidget* w) { GtkStyleContext* pCtxt = gtk_widget_get_style_context(w); GdkRGBA rgba, rgba_; gtk_style_context_get_color (pCtxt, GTK_STATE_FLAG_NORMAL, &rgba); m_3dColors[CLR3D_Foreground] = _convertGdkRGBA(rgba); gtk_style_context_get_background_color (pCtxt, GTK_STATE_FLAG_PRELIGHT, &rgba); m_3dColors[CLR3D_Highlight] = _convertGdkRGBA(rgba); gtk_style_context_get_background_color (pCtxt, GTK_STATE_FLAG_NORMAL, &rgba); m_3dColors[CLR3D_Background] = _convertGdkRGBA(rgba); rgba_.alpha = 1.; // we don't really care, abiword does not use transparency rgba_.red = rgba.red + .1; double f, rf = 1. + .1 / rgba.red; if (rf > 1. / rgba.red) rf = 1. / rgba.red; f = 1. + .1 / rgba.green; if (f < rf) rf = f; f = 1. + .1 / rgba.blue; if (f < rf) rf = f; rgba_.red = rgba.red * rf; rgba_.green = rgba.green* rf; rgba_.blue = rgba.blue * rf; m_3dColors[CLR3D_BevelUp] = _convertGdkRGBA(rgba_); rf = 1. - .1 / rgba.red; f = 1. - .1 / rgba.green; if (f > rf) rf = f; f = 1. - .1 / rgba.blue; if (f > rf) rf = f; if (rf < .5) rf = .5; rgba_.red = rgba.red * rf; rgba_.green = rgba.green* rf; rgba_.blue = rgba.blue * rf; m_3dColors[CLR3D_BevelDown] = _convertGdkRGBA(rgba_); m_bHave3DColors = true; }
static gboolean _lib_darktable_draw_callback(GtkWidget *widget, cairo_t *cr, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_darktable_t *d = (dt_lib_darktable_t *)self->data; /* get the current style */ GdkRGBA color; PangoFontDescription *font_desc = NULL; GtkStateFlags state = gtk_widget_get_state_flags(widget); GtkStyleContext *context = gtk_widget_get_style_context(widget); gtk_style_context_get_background_color(context, state, &color); gtk_style_context_get(context, state, "font", &font_desc, NULL); /* fill background */ gdk_cairo_set_source_rgba(cr, &color); cairo_paint(cr); /* paint icon image */ if(d->image) { cairo_set_source_surface(cr, d->image, 0, (int)DT_PIXEL_APPLY_DPI(7)); cairo_rectangle(cr, 0, 0, d->image_width + (int)DT_PIXEL_APPLY_DPI(8), d->image_height + (int)DT_PIXEL_APPLY_DPI(8)); cairo_fill(cr); } /* create a pango layout and print fancy name/version string */ PangoLayout *layout; layout = gtk_widget_create_pango_layout(widget, NULL); pango_font_description_set_weight(font_desc, PANGO_WEIGHT_BOLD); pango_font_description_set_absolute_size(font_desc, DT_PIXEL_APPLY_DPI(25) * PANGO_SCALE); pango_layout_set_font_description(layout, font_desc); pango_layout_set_text(layout, PACKAGE_NAME, -1); cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5); cairo_move_to(cr, d->image_width + DT_PIXEL_APPLY_DPI(2.0), DT_PIXEL_APPLY_DPI(5.0)); pango_cairo_show_layout(cr, layout); /* print version */ pango_font_description_set_absolute_size(font_desc, DT_PIXEL_APPLY_DPI(10) * PANGO_SCALE); pango_layout_set_font_description(layout, font_desc); pango_layout_set_text(layout, PACKAGE_VERSION, -1); cairo_move_to(cr, d->image_width + DT_PIXEL_APPLY_DPI(4.0), DT_PIXEL_APPLY_DPI(30.0)); cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.3); pango_cairo_show_layout(cr, layout); /* cleanup */ g_object_unref(layout); return TRUE; }
static gboolean on_countdown_draw(GtkWidget* pie, cairo_t* cr, WindowData* windata) { GtkAllocation allocation; GtkStyleContext* style; GdkRGBA color; GdkRGBA fg_color; cairo_t* context; cairo_surface_t* surface; double r, g, b; context = gdk_cairo_create(gtk_widget_get_window(GDK_WINDOW(windata->pie_countdown))); #if GTK_CHECK_VERSION(3, 0, 0) style = gtk_widget_get_style_context(windata->win); cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); gtk_widget_get_allocation(pie, &allocation); surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); cairo_set_source_surface (cr, surface, 0, 0); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); #if GTK_CHECK_VERSION (3, 0, 0) gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &fg_color); r = color.red; g = color.green; b = color.blue; cairo_set_source_rgba(cr, r, g, b, BACKGROUND_ALPHA); cairo_paint(cr); if (windata->timeout > 0) { gdouble pct = (gdouble) windata->remaining / (gdouble) windata->timeout; gdk_cairo_set_source_rgba(cr, &fg_color); cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS); cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2); cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS); cairo_fill(cr); } cairo_destroy(cr); cairo_set_source_surface(context, surface, 0, 0); cairo_paint(context); cairo_surface_destroy(surface); cairo_destroy(context); return TRUE; }
/* draw callback for the drawing area */ static gboolean draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data) { GtkStyleContext *context; GdkRGBA rgba; context = gtk_widget_get_style_context (widget); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba); gdk_cairo_set_source_rgba (cr, &rgba); cairo_paint (cr); return TRUE; }
static void draw_volume_boxes (GsdMediaKeysWindow *window, cairo_t *cr, double percentage, double _x0, double _y0, double width, double height) { gdouble x1; GtkStyleContext *context; GdkRGBA acolor; height = round (height) - 1; width = round (width) - 1; x1 = round ((width - 1) * percentage); context = gtk_widget_get_style_context (GTK_WIDGET (window)); /* bar background */ gtk_style_context_get_background_color (context, GTK_STATE_NORMAL, &acolor); gsd_osd_window_color_shade (&acolor, DARKNESS_MULT); gsd_osd_window_color_reverse (&acolor); acolor.alpha = GSD_OSD_WINDOW_FG_ALPHA / 2; gsd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height); gdk_cairo_set_source_rgba (cr, &acolor); cairo_fill (cr); /* bar progress */ if (percentage < 0.01) return; gtk_style_context_get_background_color (context, GTK_STATE_NORMAL, &acolor); acolor.alpha = GSD_OSD_WINDOW_FG_ALPHA; gsd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, x1, height); gdk_cairo_set_source_rgba (cr, &acolor); cairo_fill (cr); }
void ev_document_misc_paint_one_page (cairo_t *cr, GtkWidget *widget, GdkRectangle *area, GtkBorder *border, gboolean highlight, gboolean inverted_colors) { GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkStateFlags state = gtk_widget_get_state_flags (widget); GdkRGBA fg, bg, shade_bg; gtk_style_context_save (context); gtk_style_context_get_background_color (context, state, &bg); gtk_style_context_get_color (context, state, &fg); gtk_style_context_get_color (context, state, &shade_bg); gtk_style_context_restore (context); shade_bg.alpha *= 0.5; gdk_cairo_set_source_rgba (cr, highlight ? &fg : &shade_bg); cairo_rectangle (cr, area->x, area->y, area->width - border->right + border->left, area->height - border->bottom + border->top); cairo_rectangle (cr, area->x + area->width - border->right, area->y + border->right - border->left, border->right, area->height - border->right + border->left); cairo_rectangle (cr, area->x + border->bottom - border->top, area->y + area->height - border->bottom, area->width - border->bottom + border->top, border->bottom); cairo_fill (cr); if (inverted_colors) cairo_set_source_rgb (cr, 0, 0, 0); else cairo_set_source_rgb (cr, 1, 1, 1); cairo_rectangle (cr, area->x + border->left, area->y + border->top, area->width - (border->left + border->right), area->height - (border->top + border->bottom)); cairo_fill (cr); }
/* Handle exposure events for the color picker's drawing area */ static gint gtk_color_button_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data) { GtkColorButton *button = GTK_COLOR_BUTTON (data); cairo_pattern_t *checkered; if (gtk_color_button_has_alpha (button)) { cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK); cairo_paint (cr); cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT); cairo_scale (cr, CHECK_SIZE, CHECK_SIZE); checkered = _gtk_color_chooser_get_checkered_pattern (); cairo_mask (cr, checkered); cairo_pattern_destroy (checkered); gdk_cairo_set_source_rgba (cr, &button->priv->rgba); } else { cairo_set_source_rgb (cr, button->priv->rgba.red, button->priv->rgba.green, button->priv->rgba.blue); } cairo_paint (cr); if (!gtk_widget_is_sensitive (GTK_WIDGET (button))) { GtkStyleContext *context; GdkRGBA color; context = gtk_widget_get_style_context (widget); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color); gdk_cairo_set_source_rgba (cr, &color); checkered = _gtk_color_chooser_get_checkered_pattern (); cairo_mask (cr, checkered); cairo_pattern_destroy (checkered); } return FALSE; }
static void set_fade (AboutRenderer *r, AboutState *state, double f) { GtkStyleContext *ctxt = gtk_widget_get_style_context (state->anim_area); PangoAttrList *attrlist = pango_layout_get_attributes (r->layout); GdkRGBA col, bg, fg; PangoAttribute *attr; gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_NORMAL, &fg); gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_NORMAL, &bg); col = blend_colors (&bg, &fg, f); attr = pango_attr_foreground_new (col.red * 65535., col.green * 65535., col.blue * 65535.); pango_attr_list_change (attrlist, attr); pango_layout_set_attributes (r->layout, attrlist); }
static gboolean avatar_image_draw (GtkWidget *widget, cairo_t *cr) { GiggleAvatarImagePriv *priv = GET_PRIV (widget); GtkRequisition requisition; GtkStyleContext *context; GdkRGBA rgba; float xalign, yalign; double x, y; gint width, height; int w, h; gtk_widget_get_preferred_size (widget, &requisition, NULL); width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); context = gtk_widget_get_style_context (widget); w = requisition.width; h = requisition.height; gtk_misc_get_alignment (GTK_MISC (widget), &xalign, &yalign); cairo_translate (cr, (int) ((width - w) * xalign), (int) ((height - h) * yalign)); rounded_rectangle (cr, 0.5, 0.5, w - 1, h - 1, MIN (w, h) * 0.2); gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &rgba); gdk_cairo_set_source_rgba (cr, &rgba); cairo_fill_preserve (cr); if (priv->pixbuf) { x = (w - gdk_pixbuf_get_width (priv->pixbuf)) * 0.5; y = (h - gdk_pixbuf_get_height (priv->pixbuf)) * 0.5; gdk_cairo_set_source_pixbuf (cr, priv->pixbuf, x, y); cairo_fill_preserve (cr); } gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba); gdk_cairo_set_source_rgba (cr, &rgba); cairo_set_line_width (cr, 1); cairo_stroke (cr); return TRUE; }
static void swatch_activated (GOColorPalette *pal, GtkBin *button) { GList *tmp = gtk_container_get_children (GTK_CONTAINER (gtk_bin_get_child (button))); GtkWidget *swatch = (tmp != NULL) ? tmp->data : NULL; GtkStyleContext *style_ctx; GdkRGBA rgba; g_list_free (tmp); g_return_if_fail (swatch != NULL); style_ctx = gtk_widget_get_style_context (swatch); gtk_style_context_get_background_color (style_ctx, GTK_STATE_FLAG_NORMAL, &rgba); set_color (pal, GO_COLOR_FROM_GDK_RGBA (rgba), FALSE, TRUE, FALSE); }
static void update_style (GtkWidget *widget) { GtkStyleContext *context; GdkRGBA bg; decor_color_t spot_color; context = gtk_widget_get_style_context (widget); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &bg); spot_color.r = bg.red; spot_color.g = bg.green; spot_color.b = bg.blue; shade (&spot_color, &_title_color[0], 1.05); shade (&_title_color[0], &_title_color[1], 0.85); }
static void pgd_selections_drawing_area_realize (GtkWidget *area, PgdSelectionsDemo *demo) { GtkStyleContext *style_context = gtk_widget_get_style_context (area); GdkRGBA rgba; gtk_widget_add_events (area, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); g_object_set (area, "has-tooltip", TRUE, NULL); gtk_style_context_get_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba); gtk_color_button_set_rgba (GTK_COLOR_BUTTON (demo->fg_color_button), &rgba); gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba); gtk_color_button_set_rgba (GTK_COLOR_BUTTON (demo->bg_color_button), &rgba); }
void app_init_colors (App * app) { app->background_color = g_new0 (GdkRGBA, 1); app->strokes_color = g_new0 (GdkRGBA, 1); //fetch system colors GET_UI_ELEMENT (GtkWidget, window1); GtkStyleContext *context; context = gtk_widget_get_style_context (window1); gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, app->background_color); gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, app->strokes_color); }
//! //! @brief To be written //! void gw_kanjipadwindow_draw_candidates (GwKanjipadWindow *window) { //Declarations GwKanjipadWindowPrivate *priv; //gint width; //gint height; int i; cairo_t *cr; GtkStyleContext *context; GtkStateFlags state; GdkRGBA bgcolor; //Initializations priv = window->priv; //height = gtk_widget_get_allocated_height (GTK_WIDGET (priv->candidates)); //width = gtk_widget_get_allocated_width (GTK_WIDGET (priv->candidates)); cr = cairo_create (priv->ksurface); context = gtk_widget_get_style_context (GTK_WIDGET (priv->candidates)); state = gtk_widget_get_state_flags (GTK_WIDGET (priv->drawingarea)); gtk_style_context_get_background_color (context, state, &bgcolor); cairo_save (cr); gdk_cairo_set_source_rgba (cr, &bgcolor); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint (cr); cairo_fill (cr); cairo_restore (cr); for (i = 0; i < priv->total_candidates; i++) { if (strcmp (priv->kselected, priv->kanji_candidates[i]) == 0) _kanjipadwindow_draw_candidate_character (window, i, 1); else _kanjipadwindow_draw_candidate_character (window, i, -1); } gtk_widget_queue_draw (GTK_WIDGET (priv->candidates)); cairo_destroy (cr); cr = NULL; }
static void cheese_widget_spinner_invert (GtkWidget *spinner, GtkWidget *parent) { GtkStyleContext *context; guint i; for (i = GTK_STATE_NORMAL; i <= GTK_STATE_INSENSITIVE; i++) { GdkRGBA fg, bg; context = gtk_widget_get_style_context (spinner); gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg); gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg); gtk_widget_override_color (spinner, i, &bg); gtk_widget_override_background_color (spinner, i, &fg); gtk_widget_override_color (parent, i, &bg); gtk_widget_override_background_color (parent, i, &fg); } }
static gboolean color_swatch_draw_cb (GtkWidget *drawing_area, cairo_t *cr) { GtkStyleContext *style_context; GdkRGBA rgba; GdkRectangle rect; style_context = gtk_widget_get_style_context (drawing_area); if (!style_context) return FALSE; gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &rgba); gdk_cairo_get_clip_rectangle (cr, &rect); gdk_cairo_set_source_rgba (cr, &rgba); gdk_cairo_rectangle (cr, &rect); cairo_fill (cr); return FALSE; }
static void style_display_item (GtkWidget *widget, GcrDisplayItem *item) { #if GTK_CHECK_VERSION (2,91,6) GtkStyleContext *style; GdkRGBA color; style = gtk_widget_get_style_context (GTK_WIDGET (widget)); gtk_style_context_save (style); gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); gtk_style_context_restore (style); gtk_widget_override_background_color (item->details_widget, GTK_STATE_NORMAL, &color); #else GtkStyle *style = gtk_widget_get_style (widget); gtk_widget_modify_bg (item->details_widget, GTK_STATE_NORMAL, &style->base[GTK_STATE_NORMAL]); #endif }
static GdkPixbuf * load_pixbuf (GsdMediaKeysWindow *window, const char *name, int icon_size) { GtkIconTheme *theme; GtkIconInfo *info; GdkPixbuf *pixbuf; GtkStyleContext *context; GdkRGBA color; if (window != NULL && gtk_widget_has_screen (GTK_WIDGET (window))) { theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))); } else { theme = gtk_icon_theme_get_default (); } context = gtk_widget_get_style_context (GTK_WIDGET (window)); gtk_style_context_get_background_color (context, GTK_STATE_NORMAL, &color); info = gtk_icon_theme_lookup_icon (theme, name, icon_size, GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK); if (info == NULL) { g_warning ("Failed to load '%s'", name); return NULL; } pixbuf = gtk_icon_info_load_symbolic (info, &color, NULL, NULL, NULL, NULL, NULL); gtk_icon_info_free (info); return pixbuf; }