added new function gimp_cairo_set_focus_line_pattern().

2007-12-16  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpcairo-utils.[ch]: added new function
	gimp_cairo_set_focus_line_pattern().

	* libgimpwidgets/gimpcellrenderercolor.c
	(gimp_cell_renderer_color_render): use the focus line pattern to
	emphasize the selected entry.

	* app/widgets/gimppaletteview.c (gimp_palette_view_expose): use 
the
	new utility function.

	* libgimpwidgets/gimpwidgets.def: updated.


svn path=/trunk/; revision=24371
This commit is contained in:
Sven Neumann 2007-12-16 11:15:36 +00:00 committed by Sven Neumann
parent 6d92a4a67f
commit 75614f65cc
6 changed files with 91 additions and 36 deletions

View File

@ -1,3 +1,17 @@
2007-12-16 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcairo-utils.[ch]: added new function
gimp_cairo_set_focus_line_pattern().
* libgimpwidgets/gimpcellrenderercolor.c
(gimp_cell_renderer_color_render): use the focus line pattern to
emphasize the selected entry.
* app/widgets/gimppaletteview.c (gimp_palette_view_expose): use the
new utility function.
* libgimpwidgets/gimpwidgets.def: updated.
2007-12-15 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/widgets/gimphelp-ids.h
@ -16,7 +30,7 @@
* plug-ins/common/plugin-defs.pl
* plug-ins/common/Makefile.am: updated accordingly
See bug #436145 for the reasons for removing these plug-ins.
See bug #436145 for the reasons for removing this plug-in.
2007-12-14 Sven Neumann <sven@gimp.org>

View File

@ -21,12 +21,11 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
@ -176,7 +175,6 @@ gimp_palette_view_expose (GtkWidget *widget,
{
GimpViewRendererPalette *renderer;
cairo_t *cr;
gint8 *dash_list;
gint row, col;
renderer = GIMP_VIEW_RENDERER_PALETTE (view->renderer);
@ -188,45 +186,22 @@ gimp_palette_view_expose (GtkWidget *widget,
gdk_cairo_region (cr, eevent->region);
cairo_clip (cr);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
widget->allocation.x + col * renderer->cell_width + 0.5,
widget->allocation.y + row * renderer->cell_height + 0.5,
renderer->cell_width,
renderer->cell_height);
cairo_set_line_width (cr, 1.0);
gdk_cairo_set_source_color (cr, &widget->style->fg[GTK_STATE_SELECTED]);
cairo_stroke_preserve (cr);
gtk_widget_style_get (widget,
"focus-line-pattern", (gchar *) &dash_list,
NULL);
if (dash_list[0])
if (gimp_cairo_set_focus_line_pattern (cr, widget))
{
/* Taken straight from gtk_default_draw_focus()
*/
gint n_dashes = strlen ((const gchar *) dash_list);
gdouble *dashes = g_new (gdouble, n_dashes);
gdouble total_length = 0;
gint i;
for (i = 0; i < n_dashes; i++)
{
dashes[i] = dash_list[i];
total_length += dash_list[i];
}
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_set_dash (cr, dashes, n_dashes, 0.5);
g_free (dashes);
gdk_cairo_set_source_color (cr, &widget->style->fg[GTK_STATE_NORMAL]);
cairo_stroke (cr);
}
g_free (dash_list);
cairo_destroy (cr);
}

View File

@ -22,8 +22,9 @@
#include "config.h"
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
@ -64,11 +65,65 @@ gimp_cairo_set_source_rgb (cairo_t *cr,
**/
void
gimp_cairo_set_source_rgba (cairo_t *cr,
GimpRGB *color)
GimpRGB *color)
{
cairo_set_source_rgba (cr, color->r, color->g, color->b, color->a);
}
/**
* gimp_cairo_set_focus_line_pattern:
* @cr: Cairo context
* @widget: widget to draw the focus indicator on
*
* Sets color and dash pattern for stroking a focus line on the given
* @cr. The line pattern is taken from @widget.
*
* Return value: %TRUE if the widget style has a focus line pattern,
* %FALSE otherwise
*
* Since: GIMP 2.6
**/
gboolean
gimp_cairo_set_focus_line_pattern (cairo_t *cr,
GtkWidget *widget)
{
gint8 *dash_list;
gboolean retval = FALSE;
g_return_val_if_fail (cr != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
gtk_widget_style_get (widget,
"focus-line-pattern", (gchar *) &dash_list,
NULL);
if (dash_list[0])
{
/* Taken straight from gtk_default_draw_focus()
*/
gint n_dashes = strlen ((const gchar *) dash_list);
gdouble *dashes = g_new (gdouble, n_dashes);
gdouble total_length = 0;
gint i;
for (i = 0; i < n_dashes; i++)
{
dashes[i] = dash_list[i];
total_length += dash_list[i];
}
cairo_set_dash (cr, dashes, n_dashes, 0.5);
g_free (dashes);
retval = TRUE;
}
g_free (dash_list);
return retval;
}
/**
* gimp_cairo_checkerboard_create:
* @cr: Cairo context

View File

@ -28,6 +28,9 @@ void gimp_cairo_set_source_rgb (cairo_t *cr,
GimpRGB *color);
void gimp_cairo_set_source_rgba (cairo_t *cr,
GimpRGB *color);
gboolean gimp_cairo_set_focus_line_pattern (cairo_t *cr,
GtkWidget *widget);
cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
gint size);
cairo_surface_t * gimp_cairo_surface_create_from_pixbuf (GdkPixbuf *pixbuf);

View File

@ -282,9 +282,16 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
GTK_STATE_SELECTED : GTK_STATE_NORMAL);
}
gdk_cairo_set_source_color (cr, &widget->style->fg[state]);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
gdk_cairo_set_source_color (cr, &widget->style->fg[state]);
cairo_stroke_preserve (cr);
if (state == GTK_STATE_SELECTED &&
gimp_cairo_set_focus_line_pattern (cr, widget))
{
gdk_cairo_set_source_color (cr, &widget->style->fg[GTK_STATE_NORMAL]);
cairo_stroke (cr);
}
cairo_destroy (cr);
}

View File

@ -9,6 +9,7 @@ EXPORTS
gimp_button_get_type
gimp_button_new
gimp_cairo_checkerboard_create
gimp_cairo_set_focus_line_pattern
gimp_cairo_set_source_rgb
gimp_cairo_set_source_rgba
gimp_cairo_surface_create_from_pixbuf