static void gtk_check_button_update_node_state (GtkWidget *widget) { GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); GtkCssImageBuiltinType image_type; GtkStateFlags state; if (!priv->indicator_widget) return; state = gtk_widget_get_state_flags (widget); /* XXX: This is somewhat awkward here, but there's no better * way to update the icon */ if (state & GTK_STATE_FLAG_CHECKED) image_type = GTK_IS_RADIO_BUTTON (widget) ? GTK_CSS_IMAGE_BUILTIN_OPTION : GTK_CSS_IMAGE_BUILTIN_CHECK; else if (state & GTK_STATE_FLAG_INCONSISTENT) image_type = GTK_IS_RADIO_BUTTON (widget) ? GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT : GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT; else image_type = GTK_CSS_IMAGE_BUILTIN_NONE; gtk_icon_set_image (GTK_ICON (priv->indicator_widget), image_type); gtk_widget_set_state_flags (priv->indicator_widget, state, TRUE); }
static void close_button_class_init(CloseButtonClass* klass) { GTK_WIDGET_CLASS(klass)->draw = [] (GtkWidget* self, cairo_t* cr) { gtk_widget_draw(GTK_WIDGET(CLOSE_BUTTON(self)->priv->img), cr); return TRUE; }; GTK_WIDGET_CLASS(klass)->state_flags_changed = [] (GtkWidget* self, GtkStateFlags prev_state) { auto* img = CLOSE_BUTTON(self)->priv->img; if (!img) return; auto new_flags = gtk_widget_get_state_flags(self); auto const& deco_style = decoration::Style::Get(); auto file = deco_style->ThemedFilePath(CLOSE_BUTTON_INACTIVE_FILE, {PKGDATADIR"/"}); if (((new_flags & GTK_STATE_FLAG_PRELIGHT) && !gtk_widget_get_can_focus(self)) || (new_flags & GTK_STATE_FLAG_FOCUSED)) { auto const& basename = (new_flags & GTK_STATE_FLAG_ACTIVE) ? CLOSE_BUTTON_ACTIVE_FILE : CLOSE_BUTTON_FOCUSED_FILE; file = deco_style->ThemedFilePath(basename, {PKGDATADIR"/"}); } gtk_image_set_from_file(img, file.c_str()); return GTK_WIDGET_CLASS(close_button_parent_class)->state_flags_changed(self, prev_state); }; G_OBJECT_CLASS(klass)->finalize = [] (GObject* self) { CLOSE_BUTTON(self)->priv->img = nullptr; return G_OBJECT_CLASS(close_button_parent_class)->finalize(self); }; }
static void image_menuitem_set_size_request (GtkWidget *menuitem, GtkIconSize icon_size) { GtkStyleContext *context; GtkStateFlags state; GtkBorder padding, border; int border_width; int icon_height; int req_height; if (!gtk_icon_size_lookup (icon_size, NULL, &icon_height)) return; /* If we don't have a pixmap for this menuitem * at least make sure its the same height as * the rest. * This is a bit ugly, since we should keep this in sync with what's in * gtk_menu_item_size_request() */ context = gtk_widget_get_style_context (menuitem); state = gtk_widget_get_state_flags (menuitem); gtk_style_context_get_padding (context, state, &padding); gtk_style_context_get_border (context, state, &border); border_width = gtk_container_get_border_width (GTK_CONTAINER (menuitem)); req_height = icon_height; req_height += (border_width * 2) + padding.top + padding.bottom + border.top + border.bottom; gtk_widget_set_size_request (menuitem, -1, req_height); }
static void panel_frame_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) { PanelFrame *frame = (PanelFrame *) widget; GtkBin *bin = (GtkBin *) widget; GtkStyleContext *context; GtkWidget *child; GtkBorder padding; int border_width; context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimal_height = 1; *natural_height = 1; child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) gtk_widget_get_preferred_height (child, minimal_height, natural_height); *minimal_height += border_width; *natural_height += border_width; if (frame->edges & PANEL_EDGE_TOP) { *minimal_height += padding.top; *natural_height += padding.top; } if (frame->edges & PANEL_EDGE_BOTTOM) { *minimal_height += padding.bottom; *natural_height += padding.bottom; } }
static void gm_cell_renderer_bitext_update_style (GmCellRendererBitext* renderer, GtkWidget* widget) { GtkStyleContext *style = NULL; GtkStateFlags state; PangoAttrList *attr_list = NULL; PangoAttribute *attr_size = NULL; const PangoFontDescription* font = NULL; style = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); attr_list = pango_attr_list_new (); /* we want the secondary text smaller */ gtk_style_context_get (style, state, "font", &font, NULL); attr_size = pango_attr_size_new ((int) (pango_font_description_get_size (font) * 0.8)); attr_size->start_index = strlen (renderer->priv->primary_text) + 1; attr_size->end_index = (guint) - 1; pango_attr_list_insert (attr_list, attr_size); g_object_set (renderer, "visible", TRUE, "weight", PANGO_WEIGHT_NORMAL, "attributes", attr_list, NULL); pango_attr_list_unref (attr_list); }
static inline void gtk_switch_paint_handle (GtkWidget *widget, cairo_t *cr, GdkRectangle *box) { GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkStateFlags state; state = gtk_widget_get_state_flags (widget); if (priv->is_active) state |= GTK_STATE_FLAG_ACTIVE; gtk_style_context_save (context); gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_render_slider (context, cr, box->x, box->y, box->width, box->height, GTK_ORIENTATION_HORIZONTAL); gtk_style_context_restore (context); }
static gboolean draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data) { RenderGradientFunc func = data; GtkAllocation allocation; GtkStyleContext *style; GdkRGBA color; style = gtk_widget_get_style_context (widget); gtk_style_context_save (style); gtk_style_context_set_state (style, gtk_widget_get_state_flags (widget)); gtk_style_context_lookup_color (style, "foreground-color", &color); gtk_style_context_restore (style); gtk_widget_get_allocation (widget, &allocation); cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); (* func) ( cr, allocation.width, allocation.height); return FALSE; }
static void on_preview_draw (GtkWidget *drawing_area, cairo_t *cr, gpointer data) { ScreenshotDialog *dialog = data; GtkStyleContext *context; int width, height; width = gtk_widget_get_allocated_width (drawing_area); height = gtk_widget_get_allocated_height (drawing_area); if (!dialog->preview_image || gdk_pixbuf_get_width (dialog->preview_image) != width || gdk_pixbuf_get_height (dialog->preview_image) != height) { g_clear_object (&dialog->preview_image); dialog->preview_image = gdk_pixbuf_scale_simple (dialog->screenshot, width, height, GDK_INTERP_BILINEAR); } context = gtk_widget_get_style_context (drawing_area); gtk_style_context_save (context); gtk_style_context_set_state (context, gtk_widget_get_state_flags (drawing_area)); gtk_render_icon (context, cr, dialog->preview_image, 0, 0); gtk_style_context_restore (context); }
static gboolean window_menu_on_draw (GtkWidget *widget, cairo_t *cr, gpointer data) { GtkStyleContext *context; GtkStateFlags state; WindowMenu *window_menu = data; if (!gtk_widget_has_focus (window_menu->applet)) return FALSE; state = gtk_widget_get_state_flags (widget); context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); gtk_style_context_set_state (context, state); cairo_save (cr); gtk_render_focus (context, cr, 0., 0., gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); cairo_restore (cr); gtk_style_context_restore (context); return FALSE; }
static gboolean gs_review_bar_draw (GtkWidget *widget, cairo_t *cr) { GtkStyleContext *context; gdouble y_offset, bar_height; GdkRGBA color; context = gtk_widget_get_style_context (widget); /* don't fill the complete height (too heavy beside GtkLabel of that height) */ y_offset = floor (0.15 * gtk_widget_get_allocated_height (widget)); bar_height = gtk_widget_get_allocated_height (widget) - (y_offset * 2); gtk_render_background (context, cr, 0, y_offset, gtk_widget_get_allocated_width (widget), bar_height); cairo_rectangle (cr, 0, y_offset, round (GS_REVIEW_BAR (widget)->fraction * gtk_widget_get_allocated_width (widget)), bar_height); gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget), &color); cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); cairo_fill (cr); return GTK_WIDGET_CLASS (gs_review_bar_parent_class)->draw (widget, cr); }
static void gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { GtkStyleContext *context; GtkBorder padding; GtkStateFlags state; GtkWidget *parent; guint border_width; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get_padding (context, state, &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimum = *natural = (border_width * 2) + padding.top + padding.bottom; parent = gtk_widget_get_parent (widget); if (GTK_IS_MENU (parent) && gtk_menu_get_tearoff_state (GTK_MENU (parent))) { *minimum += ARROW_SIZE; *natural += ARROW_SIZE; } else { *minimum += padding.top + 4; *natural += padding.top + 4; } }
static gboolean xfce_arrow_button_draw (GtkWidget *widget, cairo_t *cr) { gint x, y, w; GtkStyleContext *context; xfce_arrow_button_thickness thickness; GtkAllocation allocation; if (G_LIKELY (gtk_widget_is_drawable (widget))) { context = gtk_widget_get_style_context (widget); xfce_arrow_button_get_thickness (context, &thickness); gtk_widget_get_allocation (widget, &allocation); w = MIN (allocation.height - 2 * thickness.y, allocation.width - 2 * thickness.x); w = MIN (w, ARROW_WIDTH); x = (allocation.width - w) / 2; y = (allocation.height - w) / 2; GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); gtk_style_context_save (context); gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget)); gtk_render_arrow (context, cr, G_PI, x, y, w); gtk_style_context_restore (context); } return TRUE; }
static void resize_window(GtkWidget *widget, guint width, guint height, gpointer data) { VteTerminal *terminal; if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) { gint owidth, oheight, char_width, char_height, column_count, row_count; GtkBorder padding; terminal = VTE_TERMINAL(widget); gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight); /* Take into account border overhead. */ char_width = vte_terminal_get_char_width (terminal); char_height = vte_terminal_get_char_height (terminal); column_count = vte_terminal_get_column_count (terminal); row_count = vte_terminal_get_row_count (terminal); gtk_style_context_get_padding(gtk_widget_get_style_context(widget), gtk_widget_get_state_flags(widget), &padding); owidth -= char_width * column_count + padding.left + padding.right; oheight -= char_height * row_count + padding.top + padding.bottom; gtk_window_resize(GTK_WINDOW(data), width + owidth, height + oheight); } }
static gboolean swatch_key_press (GtkWidget *widget, GdkEventKey *event) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); if (event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_ISO_Enter|| event->keyval == GDK_KEY_KP_Enter || event->keyval == GDK_KEY_KP_Space) { if (swatch->priv->has_color && swatch->priv->selectable && (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0) gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE); else g_signal_emit (swatch, signals[ACTIVATE], 0); return TRUE; } if (GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->key_press_event (widget, event)) return TRUE; return FALSE; }
static cairo_surface_t * ev_document_misc_render_thumbnail_frame (GtkWidget *widget, int width, int height, gboolean inverted_colors, GdkPixbuf *source_pixbuf, cairo_surface_t *source_surface) { GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkStateFlags state = gtk_widget_get_state_flags (widget); int width_r, height_r; int width_f, height_f; cairo_surface_t *surface; cairo_t *cr; GtkBorder border = {0, }; if (source_surface) { width_r = cairo_image_surface_get_width (source_surface); height_r = cairo_image_surface_get_height (source_surface); } else if (source_pixbuf) { g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL); width_r = gdk_pixbuf_get_width (source_pixbuf); height_r = gdk_pixbuf_get_height (source_pixbuf); } else { width_r = width; height_r = height; } gtk_style_context_save (context); gtk_style_context_add_class (context, "page-thumbnail"); if (inverted_colors) gtk_style_context_add_class (context, "inverted"); gtk_style_context_get_border (context, state, &border); width_f = width_r + border.left + border.right; height_f = height_r + border.top + border.bottom; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width_f, height_f); cr = cairo_create (surface); if (source_surface) { cairo_set_source_surface (cr, source_surface, border.left, border.top); cairo_paint (cr); } else if (source_pixbuf) { gdk_cairo_set_source_pixbuf (cr, source_pixbuf, border.left, border.top); cairo_paint (cr); } else { gtk_render_background (context, cr, 0, 0, width_f, height_f); } gtk_render_frame (context, cr, 0, 0, width_f, height_f); cairo_destroy (cr); gtk_style_context_restore (context); return surface; }
static void swatch_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); gtk_css_node_set_state (swatch->priv->overlay_node, gtk_widget_get_state_flags (widget)); }
static gboolean gtk_switch_motion (GtkWidget *widget, GdkEventMotion *event) { GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; /* if this is a direct toggle we don't handle motion */ if (priv->in_press) return GDK_EVENT_PROPAGATE; if (ABS (event->x - priv->drag_start) < priv->drag_threshold) return GDK_EVENT_STOP; if (event->state & GDK_BUTTON1_MASK) { gint position = event->x - priv->offset; GtkAllocation allocation; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; gint width, focus_width, focus_pad; gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_style_context_get_padding (context, state, &padding); gtk_style_context_restore (context); gtk_widget_get_allocation (widget, &allocation); width = allocation.width - 2 * (focus_width + focus_pad); /* constrain the handle within the trough width */ if (position > (width / 2) - padding.right) priv->handle_x = width / 2 - padding.right; else if (position < padding.left) priv->handle_x = 0; else priv->handle_x = position; priv->is_dragging = TRUE; /* we need to redraw the handle */ gtk_widget_queue_draw (widget); return GDK_EVENT_STOP; } return GDK_EVENT_PROPAGATE; }
static gboolean anaconda_disk_overview_focus_changed(GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { GtkStateFlags new_state; new_state = gtk_widget_get_state_flags(widget) & ~GTK_STATE_FOCUSED; if (event->in) new_state |= GTK_STATE_FOCUSED; gtk_widget_set_state_flags(widget, new_state, TRUE); return FALSE; }
static gboolean gtk_cell_view_draw (GtkWidget *widget, cairo_t *cr) { GtkCellView *cellview; GdkRectangle area; GtkCellRendererState state; cellview = GTK_CELL_VIEW (widget); /* render cells */ area.x = 0; area.y = 0; area.width = gtk_widget_get_allocated_width (widget); area.height = gtk_widget_get_allocated_height (widget); /* "blank" background */ if (cellview->priv->background_set) { gdk_cairo_rectangle (cr, &area); gdk_cairo_set_source_rgba (cr, &cellview->priv->background); cairo_fill (cr); } /* set cell data (if available) */ if (cellview->priv->displayed_row) gtk_cell_view_set_cell_data (cellview); else if (cellview->priv->model) return FALSE; if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_PRELIGHT) state = GTK_CELL_RENDERER_PRELIT; else if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE) state = GTK_CELL_RENDERER_INSENSITIVE; else state = 0; /* Render the cells */ gtk_cell_area_render (cellview->priv->area, cellview->priv->context, widget, cr, &area, &area, state, FALSE); return FALSE; }
static gint gtk_widget_get_font_size (GtkWidget *widget) { const PangoFontDescription *font; font = gtk_style_context_get_font (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget)); return pango_font_description_get_size (font) / PANGO_SCALE; }
static void gtk_switch_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; gint height, focus_width, focus_pad; PangoLayout *layout; PangoRectangle logical_rect; gchar *str; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); if (priv->is_active) state |= GTK_STATE_FLAG_ACTIVE; gtk_style_context_save (context); gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_style_context_get_padding (context, state, &padding); height = padding.top + padding.bottom; gtk_style_context_restore (context); gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); height += 2 * (focus_width + focus_pad); str = g_strdup_printf ("%s%s", C_("switch", "ON"), C_("switch", "OFF")); layout = gtk_widget_create_pango_layout (widget, str); pango_layout_get_extents (layout, NULL, &logical_rect); pango_extents_to_pixels (&logical_rect, NULL); height += MAX (DEFAULT_SLIDER_HEIGHT, logical_rect.height); g_object_unref (layout); g_free (str); if (minimum) *minimum = height; if (natural) *natural = height; }
GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget) { #if GTK_CHECK_VERSION(3,0,0) return gtk_widget_get_state_flags(widget); #else #if GTK_CHECK_VERSION(2,18,0) return gtk_widget_get_state(widget); #else return 0; /* FIXME */ #endif #endif }
static void panel_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { PanelFrame *frame = (PanelFrame *) widget; GtkBin *bin = (GtkBin *) widget; GtkStyleContext *context; GtkBorder padding; GtkAllocation child_allocation; GtkAllocation child_allocation_current; GtkWidget *child; int border_width; gtk_widget_set_allocation (widget, allocation); context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); child_allocation.x = allocation->x + border_width; child_allocation.y = allocation->y + border_width; child_allocation.width = allocation->width - 2 * border_width; child_allocation.height = allocation->height - 2 * border_width; if (frame->edges & PANEL_EDGE_LEFT) { child_allocation.x += padding.left; child_allocation.width -= padding.left; } if (frame->edges & PANEL_EDGE_TOP) { child_allocation.y += padding.top; child_allocation.height -= padding.top; } if (frame->edges & PANEL_EDGE_RIGHT) child_allocation.width -= padding.left; if (frame->edges & PANEL_EDGE_BOTTOM) child_allocation.height -= padding.top; child = gtk_bin_get_child (bin); gtk_widget_get_allocation (child, &child_allocation_current); if (gtk_widget_get_mapped (widget) && (child_allocation.x != child_allocation_current.x || child_allocation.y != child_allocation_current.y || child_allocation.width != child_allocation_current.width || child_allocation.height != child_allocation_current.height)) gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE); if (child && gtk_widget_get_visible (child)) gtk_widget_size_allocate (child, &child_allocation); }
static gboolean _lib_ratings_draw_callback(GtkWidget *widget, cairo_t *crf, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_ratings_t *d = (dt_lib_ratings_t *)self->data; if(!darktable.control->running) return TRUE; GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); cairo_surface_t *cst = dt_cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); cairo_t *cr = cairo_create(cst); GtkStyleContext *context = gtk_widget_get_style_context(widget); gtk_render_background(context, cr, 0, 0, allocation.width, allocation.height); /* get current style */ GdkRGBA fg_color; gtk_style_context_get_color(context, gtk_widget_get_state_flags(widget), &fg_color); /* lets draw stars */ int x = 0; cairo_set_line_width(cr, 1.5); gdk_cairo_set_source_rgba(cr, &fg_color); d->current = 0; for(int k = 0; k < 5; k++) { /* outline star */ dt_draw_star(cr, STAR_SIZE / 2.0 + x, STAR_SIZE / 2.0, STAR_SIZE / 2.0, STAR_SIZE / 4.0); if(x < d->pointerx) { cairo_fill_preserve(cr); cairo_set_source_rgba(cr, fg_color.red, fg_color.green, fg_color.blue, fg_color.alpha * 0.5); cairo_stroke(cr); gdk_cairo_set_source_rgba(cr, &fg_color); if((k + 1) > d->current) d->current = (k + 1); } else cairo_stroke(cr); x += STAR_SIZE + STAR_SPACING; } /* blit memsurface onto widget*/ cairo_destroy(cr); cairo_set_source_surface(crf, cst, 0, 0); cairo_paint(crf); cairo_surface_destroy(cst); return 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 void gtk_switch_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural) { GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; gint width, slider_width, focus_width, focus_pad; PangoLayout *layout; PangoRectangle logical_rect; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get_padding (context, state, &padding); width = padding.left + padding.right; gtk_widget_style_get (widget, "slider-width", &slider_width, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); width += 2 * (focus_width + focus_pad); /* Translators: if the "on" state label requires more than three * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for * the state */ layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON")); pango_layout_get_extents (layout, NULL, &logical_rect); pango_extents_to_pixels (&logical_rect, NULL); width += MAX (logical_rect.width, slider_width); /* Translators: if the "off" state label requires more than three * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state */ pango_layout_set_text (layout, C_("switch", "OFF"), -1); pango_layout_get_extents (layout, NULL, &logical_rect); pango_extents_to_pixels (&logical_rect, NULL); width += MAX (logical_rect.width, slider_width); g_object_unref (layout); if (minimum) *minimum = width; if (natural) *natural = width; }
static gboolean emoticon_tool_button_emoticon_release_event_cb (EEmoticonToolButton *button, GdkEventButton *event, GtkButton *emoticon_button) { GtkStateFlags state; state = gtk_widget_get_state_flags (GTK_WIDGET (button)); if (state != GTK_STATE_FLAG_NORMAL) gtk_button_clicked (emoticon_button); return FALSE; }
static void gtk_message_row_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state_flags) { GtkMessageRowPrivate *priv = GTK_MESSAGE_ROW (widget)->priv; GtkStateFlags flags; flags = gtk_widget_get_state_flags (widget); gtk_widget_set_visible (priv->extra_buttons_box, flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED)); GTK_WIDGET_CLASS (gtk_message_row_parent_class)->state_flags_changed (widget, previous_state_flags); }
static void update_node_state (GtkCheckMenuItem *check_menu_item) { GtkCheckMenuItemPrivate *priv = check_menu_item->priv; GtkStateFlags state; state = gtk_widget_get_state_flags (GTK_WIDGET (check_menu_item)); if (priv->inconsistent) state |= GTK_STATE_FLAG_INCONSISTENT; if (priv->active) state |= GTK_STATE_FLAG_CHECKED; gtk_css_node_set_state (priv->indicator_node, state); }
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); }