app/widgets/Makefile.am moved to libgimpwidgets.

2004-07-26  Sven Neumann  <sven@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/gimpcellrenderertoggle.[ch]: moved to libgimpwidgets.

	* app/widgets/gimpcomponenteditor.c
	* app/widgets/gimpcontainertreeview.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimptoolview.c
	* app/widgets/widgets-types.h

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets.def
	* libgimpwidgets/gimpwidgets.h
	* libgimpwidgets/gimpwidgetsmarshal.list
	* libgimpwidgets/gimpwidgetstypes.h
	* libgimpwidgets/gimpcellrenderertoggle.[ch]: custom toggle cell
	renderer moved here from app/widgets.

	* libgimpwidgets/gimpcellrenderercolor.[ch]: unified code with the
	new toggle cell renderer.
This commit is contained in:
Sven Neumann 2004-07-26 21:09:16 +00:00 committed by Sven Neumann
parent a2b85a62b0
commit 744bebc83c
23 changed files with 205 additions and 628 deletions

View File

@ -1,3 +1,26 @@
2004-07-26 Sven Neumann <sven@gimp.org>
* app/widgets/Makefile.am
* app/widgets/gimpcellrenderertoggle.[ch]: moved to libgimpwidgets.
* app/widgets/gimpcomponenteditor.c
* app/widgets/gimpcontainertreeview.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimptoolview.c
* app/widgets/widgets-types.h
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets.def
* libgimpwidgets/gimpwidgets.h
* libgimpwidgets/gimpwidgetsmarshal.list
* libgimpwidgets/gimpwidgetstypes.h
* libgimpwidgets/gimpcellrenderertoggle.[ch]: custom toggle cell
renderer moved here from app/widgets.
* libgimpwidgets/gimpcellrenderercolor.[ch]: unified code with the
new toggle cell renderer.
2004-07-26 Michael Natterer <mitch@gimp.org>
* app/pdb/procedural_db.[ch] (procedural_db_free_data): new

View File

@ -37,8 +37,6 @@ libappwidgets_a_sources = \
gimpbufferview.h \
gimpcellrendereraccel.c \
gimpcellrendereraccel.h \
gimpcellrenderertoggle.c \
gimpcellrenderertoggle.h \
gimpcellrendererviewable.c \
gimpcellrendererviewable.h \
gimpchanneltreeview.c \

View File

@ -1,465 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcellrenderertoggle.c
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpmarshal.h"
#include "gimpcellrenderertoggle.h"
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
enum
{
CLICKED,
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_STOCK_ID,
PROP_STOCK_SIZE
};
static void gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass);
static void gimp_cell_renderer_toggle_init (GimpCellRendererToggle *toggle);
static void gimp_cell_renderer_toggle_finalize (GObject *object);
static void gimp_cell_renderer_toggle_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
static void gimp_cell_renderer_toggle_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *rectangle,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
static void gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
static void gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
GtkWidget *widget);
static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
static GtkCellRendererToggleClass *parent_class = NULL;
GType
gimp_cell_renderer_toggle_get_type (void)
{
static GType cell_type = 0;
if (! cell_type)
{
static const GTypeInfo cell_info =
{
sizeof (GimpCellRendererToggleClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_cell_renderer_toggle_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpCellRendererToggle),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_cell_renderer_toggle_init,
};
cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE,
"GimpCellRendererToggle",
&cell_info, 0);
}
return cell_type;
}
static void
gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
{
GObjectClass *object_class;
GtkCellRendererClass *cell_class;
object_class = G_OBJECT_CLASS (klass);
cell_class = GTK_CELL_RENDERER_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
toggle_cell_signals[CLICKED] =
g_signal_new ("clicked",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpCellRendererToggleClass, clicked),
NULL, NULL,
gimp_marshal_VOID__STRING_FLAGS,
G_TYPE_NONE, 2,
G_TYPE_STRING,
GDK_TYPE_MODIFIER_TYPE);
object_class->finalize = gimp_cell_renderer_toggle_finalize;
object_class->get_property = gimp_cell_renderer_toggle_get_property;
object_class->set_property = gimp_cell_renderer_toggle_set_property;
cell_class->get_size = gimp_cell_renderer_toggle_get_size;
cell_class->render = gimp_cell_renderer_toggle_render;
cell_class->activate = gimp_cell_renderer_toggle_activate;
g_object_class_install_property (object_class,
PROP_STOCK_ID,
g_param_spec_string ("stock_id",
NULL, NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_STOCK_SIZE,
g_param_spec_enum ("stock_size",
NULL, NULL,
GTK_TYPE_ICON_SIZE,
DEFAULT_ICON_SIZE,
G_PARAM_READWRITE));
}
static void
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
{
GTK_CELL_RENDERER (cell)->xpad = 0;
GTK_CELL_RENDERER (cell)->ypad = 0;
cell->stock_id = NULL;
cell->stock_size = DEFAULT_ICON_SIZE;
}
static void
gimp_cell_renderer_toggle_finalize (GObject *object)
{
GimpCellRendererToggle *toggle;
toggle = GIMP_CELL_RENDERER_TOGGLE (object);
if (toggle->stock_id)
{
g_free (toggle->stock_id);
toggle->stock_id = NULL;
}
if (toggle->pixbuf)
{
g_object_unref (toggle->pixbuf);
toggle->pixbuf = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_cell_renderer_toggle_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
GimpCellRendererToggle *toggle;
toggle = GIMP_CELL_RENDERER_TOGGLE (object);
switch (param_id)
{
case PROP_STOCK_ID:
g_value_set_string (value, toggle->stock_id);
break;
case PROP_STOCK_SIZE:
g_value_set_enum (value, toggle->stock_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gimp_cell_renderer_toggle_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCellRendererToggle *toggle;
toggle = GIMP_CELL_RENDERER_TOGGLE (object);
switch (param_id)
{
case PROP_STOCK_ID:
if (toggle->stock_id)
g_free (toggle->stock_id);
toggle->stock_id = g_value_dup_string (value);
break;
case PROP_STOCK_SIZE:
toggle->stock_size = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
if (toggle->pixbuf)
{
g_object_unref (toggle->pixbuf);
toggle->pixbuf = NULL;
}
}
static void
gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
GimpCellRendererToggle *toggle;
gint calc_width;
gint calc_height;
gint pixbuf_width;
gint pixbuf_height;
toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
if (!toggle->stock_id)
{
GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell,
widget,
cell_area,
x_offset, y_offset,
width, height);
return;
}
if (!toggle->pixbuf)
gimp_cell_renderer_toggle_create_pixbuf (toggle, widget);
pixbuf_width = gdk_pixbuf_get_width (toggle->pixbuf);
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
calc_width = (pixbuf_width +
(gint) cell->xpad * 2 + widget->style->xthickness * 2);
calc_height = (pixbuf_height +
(gint) cell->ypad * 2 + widget->style->ythickness * 2);
if (x_offset) *x_offset = 0;
if (y_offset) *y_offset = 0;
if (cell_area)
{
if (x_offset)
{
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
(1.0 - cell->xalign) : cell->xalign) *
(cell_area->width - calc_width));
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - calc_height);
*y_offset = MAX (*y_offset, 0);
}
}
if (width) *width = calc_width;
if (height) *height = calc_height;
}
static void
gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags)
{
GimpCellRendererToggle *toggle;
GdkRectangle toggle_rect;
GdkRectangle draw_rect;
GtkStateType state;
gboolean active;
toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
if (!toggle->stock_id)
{
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget,
background_area,
cell_area, expose_area,
flags);
return;
}
gimp_cell_renderer_toggle_get_size (cell, widget, cell_area,
&toggle_rect.x,
&toggle_rect.y,
&toggle_rect.width,
&toggle_rect.height);
toggle_rect.x += cell_area->x + cell->xpad;
toggle_rect.y += cell_area->y + cell->ypad;
toggle_rect.width -= cell->xpad * 2;
toggle_rect.height -= cell->ypad * 2;
if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
return;
active =
gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (cell));
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
{
if (GTK_WIDGET_HAS_FOCUS (widget))
state = GTK_STATE_SELECTED;
else
state = GTK_STATE_ACTIVE;
}
else
{
if (GTK_CELL_RENDERER_TOGGLE (cell)->activatable)
state = GTK_STATE_NORMAL;
else
state = GTK_STATE_INSENSITIVE;
}
if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect) &&
(flags & GTK_CELL_RENDERER_PRELIT))
gtk_paint_shadow (widget->style,
window,
state,
active ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
&draw_rect,
widget, NULL,
toggle_rect.x, toggle_rect.y,
toggle_rect.width, toggle_rect.height);
if (active)
{
toggle_rect.x += widget->style->xthickness;
toggle_rect.y += widget->style->ythickness;
toggle_rect.width -= widget->style->xthickness * 2;
toggle_rect.height -= widget->style->ythickness * 2;
if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
gdk_draw_pixbuf (window,
widget->style->black_gc,
toggle->pixbuf,
/* pixbuf 0, 0 is at toggle_rect.x, toggle_rect.y */
draw_rect.x - toggle_rect.x,
draw_rect.y - toggle_rect.y,
draw_rect.x,
draw_rect.y,
draw_rect.width,
draw_rect.height,
GDK_RGB_DITHER_NORMAL,
0, 0);
}
}
static gboolean
gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GtkCellRendererToggle *celltoggle;
celltoggle = GTK_CELL_RENDERER_TOGGLE (cell);
if (celltoggle->activatable)
{
GdkModifierType state = 0;
if (event && ((GdkEventAny *) event)->type == GDK_BUTTON_PRESS)
state = ((GdkEventButton *) event)->state;
gimp_cell_renderer_toggle_clicked (GIMP_CELL_RENDERER_TOGGLE (cell),
path, state);
return TRUE;
}
return FALSE;
}
static void
gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
GtkWidget *widget)
{
if (toggle->pixbuf)
g_object_unref (toggle->pixbuf);
toggle->pixbuf = gtk_widget_render_icon (widget,
toggle->stock_id,
toggle->stock_size, NULL);
}
GtkCellRenderer *
gimp_cell_renderer_toggle_new (const gchar *stock_id)
{
return g_object_new (GIMP_TYPE_CELL_RENDERER_TOGGLE,
"stock_id", stock_id,
NULL);
}
void
gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state)
{
g_return_if_fail (GIMP_IS_CELL_RENDERER_TOGGLE (cell));
g_return_if_fail (path != NULL);
g_signal_emit (cell, toggle_cell_signals[CLICKED], 0, path, state);
}

View File

@ -1,67 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcellrenderertoggle.h
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CELL_RENDERER_TOGGLE_H__
#define __GIMP_CELL_RENDERER_TOGGLE_H__
#include <gtk/gtkcellrenderertoggle.h>
#define GIMP_TYPE_CELL_RENDERER_TOGGLE (gimp_cell_renderer_toggle_get_type ())
#define GIMP_CELL_RENDERER_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CELL_RENDERER_TOGGLE, GimpCellRendererToggle))
#define GIMP_CELL_RENDERER_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CELL_RENDERER_TOGGLE, GimpCellRendererToggleClass))
#define GIMP_IS_CELL_RENDERER_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CELL_RENDERER_TOGGLE))
#define GIMP_IS_CELL_RENDERER_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CELL_RENDERER_TOGGLE))
#define GIMP_CELL_RENDERER_TOGGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CELL_RENDERER_TOGGLE, GimpCellRendererToggleClass))
typedef struct _GimpCellRendererToggleClass GimpCellRendererToggleClass;
struct _GimpCellRendererToggle
{
GtkCellRendererToggle parent_instance;
gchar *stock_id;
GtkIconSize stock_size;
GdkPixbuf *pixbuf;
};
struct _GimpCellRendererToggleClass
{
GtkCellRendererToggleClass parent_class;
void (* clicked) (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state);
};
GType gimp_cell_renderer_toggle_get_type (void) G_GNUC_CONST;
GtkCellRenderer * gimp_cell_renderer_toggle_new (const gchar *stock_id);
void gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state);
#endif /* __GIMP_CELL_RENDERER_TOGGLE_H__ */

View File

@ -30,7 +30,6 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcellrendererviewable.h"
#include "gimpcomponenteditor.h"
#include "gimpmenufactory.h"

View File

@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "base/temp-buf.h"
@ -33,7 +35,6 @@
#include "core/gimpcontext.h"
#include "core/gimpviewable.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcellrendererviewable.h"
#include "gimpcontainertreeview.h"
#include "gimpcontainertreeview-dnd.h"

View File

@ -42,7 +42,6 @@
#include "vectors/gimpvectors.h"
#include "gimpchanneltreeview.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcontainerview.h"
#include "gimpdnd.h"
#include "gimpdocked.h"

View File

@ -45,7 +45,6 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcellrendererviewable.h"
#include "gimpcontainerview.h"
#include "gimpdnd.h"

View File

@ -32,7 +32,6 @@
#include "core/gimpcontext.h"
#include "core/gimptoolinfo.h"
#include "gimpcellrenderertoggle.h"
#include "gimpcontainertreeview.h"
#include "gimpcontainerview.h"
#include "gimppreviewrenderer.h"

View File

@ -178,7 +178,6 @@ typedef struct _GimpPreviewRendererVectors GimpPreviewRendererVectors;
/* cell renderers */
typedef struct _GimpCellRendererAccel GimpCellRendererAccel;
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
typedef struct _GimpCellRendererViewable GimpCellRendererViewable;

View File

@ -31,6 +31,23 @@ GIMP_IS_CELL_RENDERER_COLOR_CLASS
GIMP_CELL_RENDERER_COLOR_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpcellrenderertoggle</FILE>
<TITLE>GimpCellRendererToggle</TITLE>
GimpCellRendererToggle
gimp_cell_renderer_toggle_new
gimp_cell_renderer_toggle_clicked
<SUBSECTION Standard>
GimpCellRendererToggleClass
GIMP_CELL_RENDERER_TOGGLE
GIMP_IS_CELL_RENDERER_TOGGLE
GIMP_TYPE_CELL_RENDERER_TOGGLE
gimp_cell_renderer_toggle_get_type
GIMP_CELL_RENDERER_TOGGLE_CLASS
GIMP_IS_CELL_RENDERER_TOGGLE_CLASS
GIMP_CELL_RENDERER_TOGGLE_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpchainbutton</FILE>
<TITLE>GimpChainButton</TITLE>

View File

@ -6,6 +6,7 @@
gimp_button_get_type
gimp_cell_renderer_color_get_type
gimp_cell_renderer_toggle_get_type
gimp_chain_button_get_type
gimp_color_area_get_type
gimp_color_button_get_type

View File

@ -9,13 +9,11 @@ GimpCellRendererColor
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GimpCellRendererColor ##### -->
<para>
@ -27,12 +25,12 @@ GimpCellRendererColor
</para>
<!-- ##### ARG GimpCellRendererColor:icon-size ##### -->
<!-- ##### ARG GimpCellRendererColor:opaque ##### -->
<para>
</para>
<!-- ##### ARG GimpCellRendererColor:opaque ##### -->
<!-- ##### ARG GimpCellRendererColor:stock-size ##### -->
<para>
</para>

View File

@ -0,0 +1,60 @@
<!-- ##### SECTION Title ##### -->
GimpCellRendererToggle
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GimpCellRendererToggle ##### -->
<para>
</para>
<!-- ##### SIGNAL GimpCellRendererToggle::clicked ##### -->
<para>
</para>
@gimpcellrenderertoggle: the object which received the signal.
@arg1:
@arg2:
<!-- ##### ARG GimpCellRendererToggle:stock-id ##### -->
<para>
</para>
<!-- ##### ARG GimpCellRendererToggle:stock-size ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_cell_renderer_toggle_new ##### -->
<para>
</para>
@stock_id:
@Returns:
<!-- ##### FUNCTION gimp_cell_renderer_toggle_clicked ##### -->
<para>
</para>
@cell:
@path:
@state:

View File

@ -66,6 +66,8 @@ libgimpwidgets_2_0_la_sources = \
gimpbutton.h \
gimpcellrenderercolor.c \
gimpcellrenderercolor.h \
gimpcellrenderertoggle.c\
gimpcellrenderertoggle.h\
gimpchainbutton.c \
gimpchainbutton.h \
gimpcolorarea.c \

View File

@ -32,6 +32,9 @@
#include "gimpcellrenderercolor.h"
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_MENU
enum
{
PROP_0,
@ -126,9 +129,9 @@ gimp_cell_renderer_color_class_init (GimpCellRendererColorClass *klass)
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_SIZE,
g_param_spec_int ("icon_size", NULL, NULL,
g_param_spec_int ("icon_size", NULL, NULL,
0, G_MAXINT,
GTK_ICON_SIZE_MENU,
DEFAULT_ICON_SIZE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}

View File

@ -42,7 +42,7 @@ struct _GimpCellRendererColor
GimpRGB color;
gboolean opaque;
gint size;
GtkIconSize size;
gint border;
};

View File

@ -1,32 +1,32 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcellrenderertoggle.c
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
* Copyright (C) 2003-2004 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpmarshal.h"
#include "gimpwidgetstypes.h"
#include "gimpwidgetsmarshal.h"
#include "gimpcellrenderertoggle.h"
@ -48,7 +48,6 @@ enum
static void gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass);
static void gimp_cell_renderer_toggle_init (GimpCellRendererToggle *toggle);
static void gimp_cell_renderer_toggle_finalize (GObject *object);
static void gimp_cell_renderer_toggle_get_property (GObject *object,
@ -99,14 +98,14 @@ gimp_cell_renderer_toggle_get_type (void)
static const GTypeInfo cell_info =
{
sizeof (GimpCellRendererToggleClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_cell_renderer_toggle_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
NULL, /* class_data */
sizeof (GimpCellRendererToggle),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_cell_renderer_toggle_init,
0, /* n_preallocs */
NULL /* instance_init */
};
cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE,
@ -120,11 +119,8 @@ gimp_cell_renderer_toggle_get_type (void)
static void
gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
{
GObjectClass *object_class;
GtkCellRendererClass *cell_class;
object_class = G_OBJECT_CLASS (klass);
cell_class = GTK_CELL_RENDERER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -134,7 +130,7 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpCellRendererToggleClass, clicked),
NULL, NULL,
gimp_marshal_VOID__STRING_FLAGS,
_gimp_widgets_marshal_VOID__STRING_FLAGS,
G_TYPE_NONE, 2,
G_TYPE_STRING,
GDK_TYPE_MODIFIER_TYPE);
@ -152,24 +148,16 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
g_param_spec_string ("stock_id",
NULL, NULL,
NULL,
G_PARAM_READWRITE));
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_STOCK_SIZE,
g_param_spec_enum ("stock_size",
NULL, NULL,
GTK_TYPE_ICON_SIZE,
DEFAULT_ICON_SIZE,
G_PARAM_READWRITE));
}
static void
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *cell)
{
GTK_CELL_RENDERER (cell)->xpad = 0;
GTK_CELL_RENDERER (cell)->ypad = 0;
cell->stock_id = NULL;
cell->stock_size = DEFAULT_ICON_SIZE;
g_param_spec_int ("stock_size",
NULL, NULL,
0, G_MAXINT,
DEFAULT_ICON_SIZE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
@ -199,9 +187,7 @@ gimp_cell_renderer_toggle_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpCellRendererToggle *toggle;
toggle = GIMP_CELL_RENDERER_TOGGLE (object);
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
switch (param_id)
{
@ -209,7 +195,7 @@ gimp_cell_renderer_toggle_get_property (GObject *object,
g_value_set_string (value, toggle->stock_id);
break;
case PROP_STOCK_SIZE:
g_value_set_enum (value, toggle->stock_size);
g_value_set_int (value, toggle->stock_size);
break;
default:
@ -224,9 +210,7 @@ gimp_cell_renderer_toggle_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpCellRendererToggle *toggle;
toggle = GIMP_CELL_RENDERER_TOGGLE (object);
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
switch (param_id)
{
@ -236,7 +220,7 @@ gimp_cell_renderer_toggle_set_property (GObject *object,
toggle->stock_id = g_value_dup_string (value);
break;
case PROP_STOCK_SIZE:
toggle->stock_size = g_value_get_enum (value);
toggle->stock_size = g_value_get_int (value);
break;
default:
@ -260,14 +244,12 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
gint *width,
gint *height)
{
GimpCellRendererToggle *toggle;
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
gint calc_width;
gint calc_height;
gint pixbuf_width;
gint pixbuf_height;
toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
if (!toggle->stock_id)
{
GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell,
@ -321,14 +303,12 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
GdkRectangle *expose_area,
GtkCellRendererState flags)
{
GimpCellRendererToggle *toggle;
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
GdkRectangle toggle_rect;
GdkRectangle draw_rect;
GtkStateType state;
gboolean active;
toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
if (!toggle->stock_id)
{
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget,
@ -386,8 +366,8 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
toggle_rect.x += widget->style->xthickness;
toggle_rect.y += widget->style->ythickness;
toggle_rect.width -= widget->style->xthickness * 2;
toggle_rect.height -= widget->style->ythickness * 2;
toggle_rect.height -= widget->style->ythickness * 2;
if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
gdk_draw_pixbuf (window,
widget->style->black_gc,
@ -413,11 +393,9 @@ gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GtkCellRendererToggle *celltoggle;
GtkCellRendererToggle *toggle = GTK_CELL_RENDERER_TOGGLE (cell);
celltoggle = GTK_CELL_RENDERER_TOGGLE (cell);
if (celltoggle->activatable)
if (toggle->activatable)
{
GdkModifierType state = 0;
@ -445,6 +423,21 @@ gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
toggle->stock_size, NULL);
}
/**
* gimp_cell_renderer_toggle_new:
* @stock_id: the stock_id of the icon to use for the active state
*
* Creates a custom version of the #GtkCellRendererToggle. Instead of
* showing the standard toggle button, it shows a stock icon if the
* cell is active and no icon otherwise. This cell renderer is for
* example used in the Layers treeview to indicate and control the
* layer's visibility by showing %GIMP_STOCK_VISIBLE.
*
* Return value: a new #GimpCellRendererToggle
*
* Since: GIMP 2.2
**/
GtkCellRenderer *
gimp_cell_renderer_toggle_new (const gchar *stock_id)
{
@ -453,6 +446,16 @@ gimp_cell_renderer_toggle_new (const gchar *stock_id)
NULL);
}
/**
* gimp_cell_renderer_toggle_clicked:
* @cell: a #GimpCellRendererToggle
* @path:
* @state:
*
* Emits the "clicked" signal from a #GimpCellRendererToggle.
*
* Since: GIMP 2.2
**/
void
gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,

View File

@ -1,29 +1,29 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcellrenderertoggle.h
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
* Copyright (C) 2003-2004 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CELL_RENDERER_TOGGLE_H__
#define __GIMP_CELL_RENDERER_TOGGLE_H__
#include <gtk/gtkcellrenderertoggle.h>
G_BEGIN_DECLS
#define GIMP_TYPE_CELL_RENDERER_TOGGLE (gimp_cell_renderer_toggle_get_type ())
@ -39,7 +39,7 @@ typedef struct _GimpCellRendererToggleClass GimpCellRendererToggleClass;
struct _GimpCellRendererToggle
{
GtkCellRendererToggle parent_instance;
gchar *stock_id;
GtkIconSize stock_size;
GdkPixbuf *pixbuf;
@ -62,6 +62,8 @@ GtkCellRenderer * gimp_cell_renderer_toggle_new (const gchar *stock_id);
void gimp_cell_renderer_toggle_clicked (GimpCellRendererToggle *cell,
const gchar *path,
GdkModifierType state);
G_END_DECLS
#endif /* __GIMP_CELL_RENDERER_TOGGLE_H__ */

View File

@ -4,6 +4,9 @@ EXPORTS
gimp_button_new
gimp_cell_renderer_color_get_type
gimp_cell_renderer_color_new
gimp_cell_renderer_toggle_clicked
gimp_cell_renderer_toggle_get_type
gimp_cell_renderer_toggle_new
gimp_chain_button_get_active
gimp_chain_button_get_type
gimp_chain_button_new

View File

@ -28,6 +28,7 @@
#include <libgimpwidgets/gimpbutton.h>
#include <libgimpwidgets/gimpcellrenderercolor.h>
#include <libgimpwidgets/gimpcellrenderertoggle.h>
#include <libgimpwidgets/gimpchainbutton.h>
#include <libgimpwidgets/gimpcolorarea.h>
#include <libgimpwidgets/gimpcolorbutton.h>

View File

@ -27,5 +27,6 @@ VOID: INT, INT
VOID: OBJECT
VOID: OBJECT, INT
VOID: POINTER, POINTER
VOID: STRING, FLAGS
BOOLEAN: POINTER

View File

@ -57,6 +57,7 @@ typedef enum
typedef struct _GimpButton GimpButton;
typedef struct _GimpCellRendererColor GimpCellRendererColor;
typedef struct _GimpCellRendererToggle GimpCellRendererToggle;
typedef struct _GimpChainButton GimpChainButton;
typedef struct _GimpColorArea GimpColorArea;
typedef struct _GimpColorButton GimpColorButton;