/* * gfig_brush_changed_callback() is the callback for the brush * selector widget. It reads the brush name from the widget, and * applies this to the current style, as well as the gfig_context->bdesc * values. It then produces a repaint (which will be suppressed if * gfig_context->enable_repaint is FALSE). */ void gfig_brush_changed_callback (GimpBrushSelectButton *button, const gchar *brush_name, gdouble opacity, gint spacing, GimpLayerModeEffects paint_mode, gint width, gint height, const guchar *mask_data, gboolean dialog_closing, gpointer user_data) { Style *current_style; current_style = gfig_context_get_current_style (); current_style->brush_name = g_strdup (brush_name); /* this will soon be unneeded. How soon? */ gfig_context->bdesc.name = g_strdup (brush_name); gfig_context->bdesc.width = width; gfig_context->bdesc.height = height; gimp_context_set_brush (brush_name); gfig_paint_callback (); }
static void brush_preview_drop_brush (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { GimpContext *context = GIMP_CONTEXT (data); gimp_context_set_brush (context, GIMP_BRUSH (viewable)); }
/* * gfig_style_apply() applies the settings from the specified style to * the GIMP core. It does not change any widgets, and does not cause * a repaint. */ void gfig_style_apply (Style *style) { if (gfig_context->debug_styles) g_printerr ("Applying style '%s' -- ", style->name); gimp_context_set_foreground (&style->foreground); gimp_context_set_background (&style->background); if (!gimp_context_set_brush (style->brush_name)) g_message ("Style apply: Failed to set brush to '%s' in style '%s'", style->brush_name, style->name); gimp_context_set_pattern (style->pattern); gimp_context_set_gradient (style->gradient); if (gfig_context->debug_styles) g_printerr ("done.\n"); }
/* * gfig_style_set_content_from_style() sets all of the style control widgets * to values from the specified style. This in turn sets the Gimp core's * values to the same things. Repainting is suppressed while this happens, * so calling this function will not produce a repaint. * */ void gfig_style_set_context_from_style (Style *style) { gboolean enable_repaint; if (gfig_context->debug_styles) g_printerr ("Setting context from style '%s' -- ", style->name); enable_repaint = gfig_context->enable_repaint; gfig_context->enable_repaint = FALSE; gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->fg_color_button), &style->foreground); gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->bg_color_button), &style->background); if (!gimp_context_set_brush (style->brush_name)) g_message ("Style from context: Failed to set brush to '%s'", style->brush_name); gimp_brush_select_button_set_brush (GIMP_BRUSH_SELECT_BUTTON (gfig_context->brush_select), style->brush_name, -1.0, -1, -1); /* FIXME */ gimp_pattern_select_button_set_pattern (GIMP_PATTERN_SELECT_BUTTON (gfig_context->pattern_select), style->pattern); gimp_gradient_select_button_set_gradient (GIMP_GRADIENT_SELECT_BUTTON (gfig_context->gradient_select), style->gradient); gfig_context->bdesc.name = style->brush_name; if (gfig_context->debug_styles) g_printerr ("done.\n"); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (gfig_context->fillstyle_combo), (gint) style->fill_type); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gfig_context->paint_type_toggle), style->paint_type); gfig_context->enable_repaint = enable_repaint; }