2004-07-27 05:09:16 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2003-03-13 03:02:51 +08:00
|
|
|
*
|
2003-03-13 21:08:37 +08:00
|
|
|
* gimpcellrenderertoggle.c
|
2004-07-27 05:09:16 +08:00
|
|
|
* Copyright (C) 2003-2004 Sven Neumann <sven@gimp.org>
|
2003-03-13 03:02:51 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2004-07-27 05:09:16 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2003-03-13 03:02:51 +08:00
|
|
|
*
|
2004-07-27 05:09:16 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2003-03-13 03:02:51 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2004-07-27 05:09:16 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
2003-03-13 03:02:51 +08:00
|
|
|
*
|
2004-07-27 05:09:16 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2003-03-13 03:02:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-07-27 05:09:16 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2004-07-27 05:09:16 +08:00
|
|
|
#include "gimpwidgetsmarshal.h"
|
2003-03-13 03:02:51 +08:00
|
|
|
#include "gimpcellrenderertoggle.h"
|
|
|
|
|
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpcellrenderertoggle
|
|
|
|
* @title: GimpCellRendererToggle
|
|
|
|
* @short_description: A #GtkCellRendererToggle that displays icons instead
|
|
|
|
* of a checkbox.
|
|
|
|
*
|
|
|
|
* A #GtkCellRendererToggle that displays icons instead of a checkbox.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
|
|
|
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CLICKED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2014-05-07 21:28:51 +08:00
|
|
|
PROP_ICON_NAME,
|
2003-03-13 03:02:51 +08:00
|
|
|
PROP_STOCK_ID,
|
2016-10-29 22:47:36 +08:00
|
|
|
PROP_STOCK_SIZE,
|
|
|
|
PROP_OVERRIDE_BACKGROUND
|
2003-03-13 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
typedef struct _GimpCellRendererTogglePrivate GimpCellRendererTogglePrivate;
|
|
|
|
|
|
|
|
struct _GimpCellRendererTogglePrivate
|
|
|
|
{
|
2016-10-29 22:47:36 +08:00
|
|
|
gchar *icon_name;
|
|
|
|
gboolean override_background;
|
2014-05-08 18:38:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GET_PRIVATE(obj) \
|
|
|
|
G_TYPE_INSTANCE_GET_PRIVATE (obj, \
|
|
|
|
GIMP_TYPE_CELL_RENDERER_TOGGLE, \
|
|
|
|
GimpCellRendererTogglePrivate)
|
|
|
|
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
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);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *path,
|
|
|
|
GdkRectangle *background_area,
|
|
|
|
GdkRectangle *cell_area,
|
|
|
|
GtkCellRendererState flags);
|
2003-03-13 03:02:51 +08:00
|
|
|
static void gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
|
|
|
|
GtkWidget *widget);
|
|
|
|
|
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
G_DEFINE_TYPE (GimpCellRendererToggle, gimp_cell_renderer_toggle,
|
2006-05-15 17:46:31 +08:00
|
|
|
GTK_TYPE_CELL_RENDERER_TOGGLE)
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_cell_renderer_toggle_parent_class
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
|
|
|
|
{
|
2004-07-27 05:09:16 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
toggle_cell_signals[CLICKED] =
|
|
|
|
g_signal_new ("clicked",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpCellRendererToggleClass, clicked),
|
|
|
|
NULL, NULL,
|
|
|
|
_gimp_widgets_marshal_VOID__STRING_FLAGS,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_STRING,
|
2003-03-20 21:22:22 +08:00
|
|
|
GDK_TYPE_MODIFIER_TYPE);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
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;
|
2003-03-19 23:17:13 +08:00
|
|
|
cell_class->activate = gimp_cell_renderer_toggle_activate;
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ICON_NAME,
|
2014-05-07 21:28:51 +08:00
|
|
|
g_param_spec_string ("icon-name",
|
2017-06-07 03:19:17 +08:00
|
|
|
"Icon Name",
|
|
|
|
"The icon to display",
|
2014-05-07 21:28:51 +08:00
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2014-05-08 18:38:50 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_STOCK_ID,
|
2005-03-10 01:02:35 +08:00
|
|
|
g_param_spec_string ("stock-id",
|
2017-06-07 03:19:17 +08:00
|
|
|
"Stock ID",
|
|
|
|
"The icon to display, deprecated",
|
2003-03-13 03:02:51 +08:00
|
|
|
NULL,
|
2006-01-31 00:10:56 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-27 05:09:16 +08:00
|
|
|
G_PARAM_CONSTRUCT));
|
2014-05-08 18:38:50 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_STOCK_SIZE,
|
2005-03-10 01:02:35 +08:00
|
|
|
g_param_spec_int ("stock-size",
|
2017-06-07 03:19:17 +08:00
|
|
|
"Stock Size",
|
|
|
|
"The icon size to use",
|
2004-07-27 05:09:16 +08:00
|
|
|
0, G_MAXINT,
|
|
|
|
DEFAULT_ICON_SIZE,
|
2006-01-31 00:10:56 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-27 05:09:16 +08:00
|
|
|
G_PARAM_CONSTRUCT));
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2016-10-29 22:47:36 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_OVERRIDE_BACKGROUND,
|
|
|
|
g_param_spec_boolean ("override-background",
|
2017-06-07 03:19:17 +08:00
|
|
|
"Override Background",
|
|
|
|
"Draw the background if the row is selected",
|
2016-10-29 22:47:36 +08:00
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
g_type_class_add_private (object_class, sizeof (GimpCellRendererTogglePrivate));
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_init (GimpCellRendererToggle *toggle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_finalize (GObject *object)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
|
|
|
|
|
|
|
|
if (priv->icon_name)
|
|
|
|
{
|
|
|
|
g_free (priv->icon_name);
|
|
|
|
priv->icon_name = NULL;
|
|
|
|
}
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
if (toggle->stock_id)
|
|
|
|
{
|
|
|
|
g_free (toggle->stock_id);
|
|
|
|
toggle->stock_id = NULL;
|
|
|
|
}
|
2008-04-25 16:53:11 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
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)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
2014-05-07 21:28:51 +08:00
|
|
|
case PROP_ICON_NAME:
|
2014-05-08 18:38:50 +08:00
|
|
|
g_value_set_string (value, priv->icon_name);
|
2014-05-07 21:28:51 +08:00
|
|
|
break;
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
case PROP_STOCK_ID:
|
|
|
|
g_value_set_string (value, toggle->stock_id);
|
|
|
|
break;
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
case PROP_STOCK_SIZE:
|
2004-07-27 05:09:16 +08:00
|
|
|
g_value_set_int (value, toggle->stock_size);
|
2003-03-13 03:02:51 +08:00
|
|
|
break;
|
|
|
|
|
2016-10-29 22:47:36 +08:00
|
|
|
case PROP_OVERRIDE_BACKGROUND:
|
|
|
|
g_value_set_boolean (value, priv->override_background);
|
|
|
|
break;
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
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)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
2014-05-07 21:28:51 +08:00
|
|
|
case PROP_ICON_NAME:
|
2014-05-08 18:38:50 +08:00
|
|
|
if (priv->icon_name)
|
|
|
|
g_free (priv->icon_name);
|
|
|
|
priv->icon_name = g_value_dup_string (value);
|
2014-05-07 21:28:51 +08:00
|
|
|
break;
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
case PROP_STOCK_ID:
|
|
|
|
if (toggle->stock_id)
|
2006-04-12 18:53:28 +08:00
|
|
|
g_free (toggle->stock_id);
|
2003-03-13 03:02:51 +08:00
|
|
|
toggle->stock_id = g_value_dup_string (value);
|
|
|
|
break;
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
case PROP_STOCK_SIZE:
|
2004-07-27 05:09:16 +08:00
|
|
|
toggle->stock_size = g_value_get_int (value);
|
2003-03-13 03:02:51 +08:00
|
|
|
break;
|
|
|
|
|
2016-10-29 22:47:36 +08:00
|
|
|
case PROP_OVERRIDE_BACKGROUND:
|
|
|
|
priv->override_background = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
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)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (cell);
|
|
|
|
GtkStyle *style = gtk_widget_get_style (widget);
|
|
|
|
gint calc_width;
|
|
|
|
gint calc_height;
|
|
|
|
gint pixbuf_width;
|
|
|
|
gint pixbuf_height;
|
|
|
|
gfloat xalign;
|
|
|
|
gfloat yalign;
|
|
|
|
gint xpad;
|
|
|
|
gint ypad;
|
|
|
|
|
|
|
|
if (! priv->icon_name && ! toggle->stock_id)
|
2003-03-13 03:02:51 +08:00
|
|
|
{
|
|
|
|
GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell,
|
|
|
|
widget,
|
|
|
|
cell_area,
|
|
|
|
x_offset, y_offset,
|
|
|
|
width, height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-18 00:51:48 +08:00
|
|
|
gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
|
|
|
|
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
|
|
|
|
2005-01-04 05:26:26 +08:00
|
|
|
if (! toggle->pixbuf)
|
2003-03-13 03:02:51 +08:00
|
|
|
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 +
|
2009-10-18 00:51:48 +08:00
|
|
|
(gint) xpad * 2 + style->xthickness * 2);
|
2003-03-13 03:02:51 +08:00
|
|
|
calc_height = (pixbuf_height +
|
2009-10-18 00:51:48 +08:00
|
|
|
(gint) ypad * 2 + style->ythickness * 2);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2005-01-04 05:26:26 +08:00
|
|
|
if (width)
|
|
|
|
*width = calc_width;
|
|
|
|
|
|
|
|
if (height)
|
|
|
|
*height = calc_height;
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
if (cell_area)
|
|
|
|
{
|
|
|
|
if (x_offset)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
|
2009-10-18 00:51:48 +08:00
|
|
|
(1.0 - xalign) : xalign) *
|
2003-03-13 21:43:06 +08:00
|
|
|
(cell_area->width - calc_width));
|
2006-04-12 18:53:28 +08:00
|
|
|
*x_offset = MAX (*x_offset, 0);
|
|
|
|
}
|
2008-04-25 16:53:11 +08:00
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
if (y_offset)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2009-10-18 00:51:48 +08:00
|
|
|
*y_offset = yalign * (cell_area->height - calc_height);
|
2006-04-12 18:53:28 +08:00
|
|
|
*y_offset = MAX (*y_offset, 0);
|
|
|
|
}
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget,
|
|
|
|
GdkRectangle *background_area,
|
|
|
|
GdkRectangle *cell_area,
|
|
|
|
GdkRectangle *expose_area,
|
|
|
|
GtkCellRendererState flags)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (cell);
|
|
|
|
GtkStyle *style = gtk_widget_get_style (widget);
|
|
|
|
GdkRectangle toggle_rect;
|
|
|
|
GdkRectangle draw_rect;
|
|
|
|
GtkStateType state;
|
|
|
|
gboolean active;
|
|
|
|
gint xpad;
|
|
|
|
gint ypad;
|
|
|
|
|
|
|
|
if (! priv->icon_name && ! toggle->stock_id)
|
2003-03-13 03:02:51 +08:00
|
|
|
{
|
|
|
|
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget,
|
|
|
|
background_area,
|
|
|
|
cell_area, expose_area,
|
|
|
|
flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-07 03:19:17 +08:00
|
|
|
if ((flags & GTK_CELL_RENDERER_SELECTED) &&
|
2016-10-29 22:47:36 +08:00
|
|
|
priv->override_background)
|
|
|
|
{
|
|
|
|
gboolean background_set;
|
|
|
|
|
|
|
|
g_object_get (cell,
|
|
|
|
"cell-background-set", &background_set,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (background_set)
|
|
|
|
{
|
|
|
|
cairo_t *cr = gdk_cairo_create (window);
|
|
|
|
GdkColor *color;
|
|
|
|
|
|
|
|
g_object_get (cell,
|
|
|
|
"cell-background-gdk", &color,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gdk_cairo_rectangle (cr, background_area);
|
|
|
|
gdk_cairo_set_source_color (cr, color);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
gdk_color_free (color);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
gimp_cell_renderer_toggle_get_size (cell, widget, cell_area,
|
|
|
|
&toggle_rect.x,
|
|
|
|
&toggle_rect.y,
|
|
|
|
&toggle_rect.width,
|
|
|
|
&toggle_rect.height);
|
|
|
|
|
2009-10-18 00:51:48 +08:00
|
|
|
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
|
|
|
|
|
|
|
toggle_rect.x += cell_area->x + xpad;
|
|
|
|
toggle_rect.y += cell_area->y + ypad;
|
|
|
|
toggle_rect.width -= xpad * 2;
|
|
|
|
toggle_rect.height -= ypad * 2;
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2009-10-18 00:51:48 +08:00
|
|
|
if (gtk_widget_has_focus (widget))
|
2006-04-12 18:53:28 +08:00
|
|
|
state = GTK_STATE_SELECTED;
|
2003-03-13 03:02:51 +08:00
|
|
|
else
|
2006-04-12 18:53:28 +08:00
|
|
|
state = GTK_STATE_ACTIVE;
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-18 00:51:48 +08:00
|
|
|
if (gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
|
2003-03-13 03:02:51 +08:00
|
|
|
state = GTK_STATE_NORMAL;
|
|
|
|
else
|
|
|
|
state = GTK_STATE_INSENSITIVE;
|
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect) &&
|
|
|
|
(flags & GTK_CELL_RENDERER_PRELIT))
|
2008-06-28 23:09:46 +08:00
|
|
|
gtk_paint_shadow (style,
|
2003-03-14 00:49:37 +08:00
|
|
|
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);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
if (active)
|
|
|
|
{
|
2008-06-28 23:09:46 +08:00
|
|
|
toggle_rect.x += style->xthickness;
|
|
|
|
toggle_rect.y += style->ythickness;
|
|
|
|
toggle_rect.width -= style->xthickness * 2;
|
|
|
|
toggle_rect.height -= style->ythickness * 2;
|
2004-07-27 05:09:16 +08:00
|
|
|
|
2003-03-14 00:49:37 +08:00
|
|
|
if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
|
2010-08-08 21:39:16 +08:00
|
|
|
{
|
2011-09-24 05:42:09 +08:00
|
|
|
cairo_t *cr = gdk_cairo_create (window);
|
|
|
|
gboolean inconsistent;
|
2010-08-08 21:39:16 +08:00
|
|
|
|
|
|
|
gdk_cairo_rectangle (cr, &draw_rect);
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, toggle->pixbuf,
|
|
|
|
toggle_rect.x, toggle_rect.y);
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
2011-09-24 05:42:09 +08:00
|
|
|
g_object_get (toggle,
|
|
|
|
"inconsistent", &inconsistent,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (inconsistent)
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
2012-11-09 18:37:01 +08:00
|
|
|
cairo_set_line_width (cr, 1.5);
|
2011-09-24 05:42:09 +08:00
|
|
|
cairo_move_to (cr,
|
2012-11-09 18:37:01 +08:00
|
|
|
toggle_rect.x + toggle_rect.width - 1,
|
|
|
|
toggle_rect.y + 1);
|
2011-09-24 05:42:09 +08:00
|
|
|
cairo_line_to (cr,
|
2012-11-09 18:37:01 +08:00
|
|
|
toggle_rect.x + 1,
|
|
|
|
toggle_rect.y + toggle_rect.height - 1);
|
2011-09-24 05:42:09 +08:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
2010-08-08 21:39:16 +08:00
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *path,
|
|
|
|
GdkRectangle *background_area,
|
|
|
|
GdkRectangle *cell_area,
|
|
|
|
GtkCellRendererState flags)
|
|
|
|
{
|
2004-07-27 05:09:16 +08:00
|
|
|
GtkCellRendererToggle *toggle = GTK_CELL_RENDERER_TOGGLE (cell);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2009-10-18 00:51:48 +08:00
|
|
|
if (gtk_cell_renderer_toggle_get_activatable (toggle))
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
{
|
|
|
|
GdkModifierType state = 0;
|
|
|
|
|
2003-03-28 19:20:24 +08:00
|
|
|
if (event && ((GdkEventAny *) event)->type == GDK_BUTTON_PRESS)
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
state = ((GdkEventButton *) event)->state;
|
|
|
|
|
2003-03-28 19:20:24 +08:00
|
|
|
gimp_cell_renderer_toggle_clicked (GIMP_CELL_RENDERER_TOGGLE (cell),
|
|
|
|
path, state);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (toggle);
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
if (toggle->pixbuf)
|
|
|
|
g_object_unref (toggle->pixbuf);
|
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
if (priv->icon_name)
|
2014-05-07 21:28:51 +08:00
|
|
|
{
|
2014-05-08 18:38:50 +08:00
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
if (! gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
|
|
|
|
toggle->stock_size,
|
|
|
|
&width, &height))
|
|
|
|
{
|
|
|
|
width = 20;
|
|
|
|
height = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
|
|
|
priv->icon_name,
|
|
|
|
MIN (width, height), 0, NULL);
|
2014-05-07 21:28:51 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
toggle->pixbuf = gtk_widget_render_icon (widget,
|
|
|
|
toggle->stock_id,
|
|
|
|
toggle->stock_size, NULL);
|
|
|
|
}
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2004-07-27 05:09:16 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_cell_renderer_toggle_new:
|
2014-05-08 18:38:50 +08:00
|
|
|
* @icon_name: the icon name of the icon to use for the active state
|
2004-07-27 05:09:16 +08:00
|
|
|
*
|
|
|
|
* Creates a custom version of the #GtkCellRendererToggle. Instead of
|
2014-05-08 18:38:50 +08:00
|
|
|
* showing the standard toggle button, it shows a named icon if the
|
2004-07-27 05:09:16 +08:00
|
|
|
* 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
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-07-27 05:09:16 +08:00
|
|
|
**/
|
2003-03-13 03:02:51 +08:00
|
|
|
GtkCellRenderer *
|
2014-05-08 18:38:50 +08:00
|
|
|
gimp_cell_renderer_toggle_new (const gchar *icon_name)
|
2003-03-13 03:02:51 +08:00
|
|
|
{
|
|
|
|
return g_object_new (GIMP_TYPE_CELL_RENDERER_TOGGLE,
|
2014-05-08 18:38:50 +08:00
|
|
|
"icon-name", icon_name,
|
2003-03-13 03:02:51 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2003-03-19 23:17:13 +08:00
|
|
|
|
2004-07-27 05:09:16 +08:00
|
|
|
/**
|
|
|
|
* gimp_cell_renderer_toggle_clicked:
|
2010-07-06 01:04:15 +08:00
|
|
|
* @cell: a #GimpCellRendererToggle
|
|
|
|
* @path: the path to the clicked row
|
|
|
|
* @state: the modifier state
|
2004-07-27 05:09:16 +08:00
|
|
|
*
|
|
|
|
* Emits the "clicked" signal from a #GimpCellRendererToggle.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-07-27 05:09:16 +08:00
|
|
|
**/
|
2003-03-19 23:17:13 +08:00
|
|
|
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);
|
|
|
|
}
|