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
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2003-03-13 03:02:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 16:16:21 +08:00
|
|
|
#include "libgimpbase/gimpbase.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.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2018-08-06 21:04:44 +08:00
|
|
|
#define DEFAULT_ICON_SIZE 16
|
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
|
|
|
|
|
|
|
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,
|
2018-08-06 21:04:44 +08:00
|
|
|
PROP_ICON_SIZE,
|
2016-10-29 22:47:36 +08:00
|
|
|
PROP_OVERRIDE_BACKGROUND
|
2003-03-13 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
struct _GimpCellRendererTogglePrivate
|
|
|
|
{
|
2011-01-01 01:15:15 +08:00
|
|
|
gchar *icon_name;
|
2018-08-06 21:04:44 +08:00
|
|
|
gint icon_size;
|
2011-01-01 01:15:15 +08:00
|
|
|
gboolean override_background;
|
|
|
|
|
|
|
|
GdkPixbuf *pixbuf;
|
2014-05-08 18:38:50 +08:00
|
|
|
};
|
|
|
|
|
2018-05-03 18:51:36 +08:00
|
|
|
#define GET_PRIVATE(obj) (((GimpCellRendererToggle *) (obj))->priv)
|
2014-05-08 18:38:50 +08:00
|
|
|
|
|
|
|
|
2010-10-15 16:26:34 +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,
|
|
|
|
const GdkRectangle *rectangle,
|
|
|
|
gint *x_offset,
|
|
|
|
gint *y_offset,
|
|
|
|
gint *width,
|
|
|
|
gint *height);
|
|
|
|
static void gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
|
|
|
cairo_t *cr,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
|
|
|
GtkCellRendererState flags);
|
|
|
|
static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *path,
|
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
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
|
|
|
GtkCellRendererState flags);
|
2003-03-13 03:02:51 +08:00
|
|
|
static void gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
|
|
|
|
GtkWidget *widget);
|
|
|
|
|
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpCellRendererToggle, gimp_cell_renderer_toggle,
|
|
|
|
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
|
|
|
|
2018-08-06 21:04:44 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ICON_SIZE,
|
|
|
|
g_param_spec_int ("icon-size",
|
|
|
|
"Icon Size",
|
|
|
|
"The desired icon size to use in pixel (before applying scaling factor)",
|
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));
|
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)
|
|
|
|
{
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
toggle->priv = gimp_cell_renderer_toggle_get_instance_private (toggle);
|
2005-12-21 04:35:23 +08:00
|
|
|
}
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_finalize (GObject *object)
|
|
|
|
{
|
2011-01-01 01:15:15 +08:00
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
|
2014-05-08 18:38:50 +08:00
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
g_clear_pointer (&priv->icon_name, g_free);
|
|
|
|
g_clear_object (&priv->pixbuf);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2011-01-01 01:15:15 +08:00
|
|
|
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
|
|
|
|
2018-08-06 21:04:44 +08:00
|
|
|
case PROP_ICON_SIZE:
|
|
|
|
g_value_set_int (value, priv->icon_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)
|
|
|
|
{
|
2011-01-01 01:15:15 +08:00
|
|
|
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
|
|
|
|
2018-08-06 21:04:44 +08:00
|
|
|
case PROP_ICON_SIZE:
|
|
|
|
priv->icon_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;
|
|
|
|
}
|
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
g_clear_object (&priv->pixbuf);
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-15 16:26:34 +08:00
|
|
|
gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const GdkRectangle *cell_area,
|
|
|
|
gint *x_offset,
|
|
|
|
gint *y_offset,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
2003-03-13 03:02:51 +08:00
|
|
|
{
|
2010-12-15 20:14:18 +08:00
|
|
|
GimpCellRendererToggle *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
|
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (cell);
|
|
|
|
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
|
|
|
GtkBorder border;
|
2018-05-30 22:12:57 +08:00
|
|
|
gint scale_factor;
|
2014-05-08 18:38:50 +08:00
|
|
|
gint calc_width;
|
|
|
|
gint calc_height;
|
|
|
|
gint pixbuf_width;
|
|
|
|
gint pixbuf_height;
|
|
|
|
gfloat xalign;
|
|
|
|
gfloat yalign;
|
|
|
|
gint xpad;
|
|
|
|
gint ypad;
|
|
|
|
|
2018-05-30 22:12:57 +08:00
|
|
|
scale_factor = gtk_widget_get_scale_factor (widget);
|
|
|
|
|
2018-04-29 03:16:20 +08:00
|
|
|
if (! priv->icon_name)
|
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;
|
|
|
|
}
|
|
|
|
|
2010-12-15 20:14:18 +08:00
|
|
|
gtk_style_context_save (context);
|
|
|
|
|
2009-10-18 00:51:48 +08:00
|
|
|
gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
|
|
|
|
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
if (! priv->pixbuf)
|
2003-03-13 03:02:51 +08:00
|
|
|
gimp_cell_renderer_toggle_create_pixbuf (toggle, widget);
|
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
pixbuf_width = gdk_pixbuf_get_width (priv->pixbuf);
|
|
|
|
pixbuf_height = gdk_pixbuf_get_height (priv->pixbuf);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2018-05-30 22:12:57 +08:00
|
|
|
/* The pixbuf size may be bigger than the logical size. */
|
|
|
|
calc_width = pixbuf_width / scale_factor + (gint) xpad * 2;
|
|
|
|
calc_height = pixbuf_height / scale_factor + (gint) ypad * 2;
|
2010-12-15 20:14:18 +08:00
|
|
|
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
|
|
|
|
|
|
|
|
gtk_style_context_get_border (context, 0, &border);
|
|
|
|
calc_width += border.left + border.right;
|
|
|
|
calc_height += border.top + border.bottom;
|
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
|
|
|
}
|
2010-12-15 20:14:18 +08:00
|
|
|
|
|
|
|
gtk_style_context_restore (context);
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
2010-10-15 16:26:34 +08:00
|
|
|
cairo_t *cr,
|
2003-03-13 03:02:51 +08:00
|
|
|
GtkWidget *widget,
|
2010-10-15 16:26:34 +08:00
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
2003-03-13 03:02:51 +08:00
|
|
|
GtkCellRendererState flags)
|
|
|
|
{
|
2010-12-15 20:14:18 +08:00
|
|
|
GimpCellRendererTogglePrivate *priv = GET_PRIVATE (cell);
|
|
|
|
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
2014-05-08 18:38:50 +08:00
|
|
|
GdkRectangle toggle_rect;
|
2011-02-07 00:44:49 +08:00
|
|
|
GtkStateFlags state;
|
2014-05-08 18:38:50 +08:00
|
|
|
gboolean active;
|
2018-05-30 22:12:57 +08:00
|
|
|
gint scale_factor;
|
2014-05-08 18:38:50 +08:00
|
|
|
gint xpad;
|
|
|
|
gint ypad;
|
|
|
|
|
2018-05-30 22:12:57 +08:00
|
|
|
scale_factor = gtk_widget_get_scale_factor (widget);
|
|
|
|
|
2018-04-29 03:16:20 +08:00
|
|
|
if (! priv->icon_name)
|
2003-03-13 03:02:51 +08:00
|
|
|
{
|
2010-10-15 16:26:34 +08:00
|
|
|
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, cr, widget,
|
2003-03-13 03:02:51 +08:00
|
|
|
background_area,
|
2010-10-15 16:26:34 +08:00
|
|
|
cell_area,
|
2003-03-13 03:02:51 +08:00
|
|
|
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)
|
|
|
|
{
|
2016-11-01 19:50:10 +08:00
|
|
|
GdkRGBA *color;
|
2016-10-29 22:47:36 +08:00
|
|
|
|
|
|
|
g_object_get (cell,
|
2016-11-01 19:50:10 +08:00
|
|
|
"cell-background-rgba", &color,
|
2016-10-29 22:47:36 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
gdk_cairo_rectangle (cr, background_area);
|
2016-11-01 19:50:10 +08:00
|
|
|
gdk_cairo_set_source_rgba (cr, color);
|
2016-10-29 22:47:36 +08:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
2016-11-01 19:50:10 +08:00
|
|
|
gdk_rgba_free (color);
|
2016-10-29 22:47:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2010-12-15 20:14:18 +08:00
|
|
|
gtk_style_context_save (context);
|
|
|
|
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
|
2022-02-14 20:24:37 +08:00
|
|
|
gtk_style_context_add_class (context, "toggle-icon");
|
2010-12-15 20:14:18 +08:00
|
|
|
|
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;
|
|
|
|
|
2011-02-07 00:44:49 +08:00
|
|
|
state = gtk_cell_renderer_get_state (cell, widget, flags);
|
|
|
|
|
2003-03-13 03:02:51 +08:00
|
|
|
active =
|
|
|
|
gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (cell));
|
|
|
|
|
2010-12-15 20:14:18 +08:00
|
|
|
if (active)
|
2022-02-14 20:24:37 +08:00
|
|
|
{
|
|
|
|
gtk_style_context_add_class (context, "visible");
|
|
|
|
state |= GTK_STATE_FLAG_ACTIVE;
|
|
|
|
}
|
2010-12-15 20:14:18 +08:00
|
|
|
|
2011-02-07 00:44:49 +08:00
|
|
|
if (! gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
|
|
|
|
state |= GTK_STATE_FLAG_INSENSITIVE;
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2010-12-15 20:14:18 +08:00
|
|
|
gtk_style_context_set_state (context, state);
|
|
|
|
|
2011-02-07 00:44:49 +08:00
|
|
|
if (state & GTK_STATE_FLAG_PRELIGHT)
|
2010-12-15 20:14:18 +08:00
|
|
|
gtk_render_frame (context, cr,
|
2003-03-14 00:49:37 +08:00
|
|
|
toggle_rect.x, toggle_rect.y,
|
|
|
|
toggle_rect.width, toggle_rect.height);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
|
|
|
if (active)
|
|
|
|
{
|
2010-12-15 20:14:18 +08:00
|
|
|
GtkBorder border;
|
|
|
|
gboolean inconsistent;
|
2010-10-15 16:26:34 +08:00
|
|
|
|
2010-12-15 20:14:18 +08:00
|
|
|
gtk_style_context_get_border (context, 0, &border);
|
|
|
|
toggle_rect.x += border.left;
|
2018-05-30 22:12:57 +08:00
|
|
|
toggle_rect.x *= scale_factor;
|
2010-12-15 20:14:18 +08:00
|
|
|
toggle_rect.y += border.top;
|
2018-05-30 22:12:57 +08:00
|
|
|
toggle_rect.y *= scale_factor;
|
2010-12-15 20:14:18 +08:00
|
|
|
toggle_rect.width -= border.left + border.right;
|
|
|
|
toggle_rect.height -= border.top + border.bottom;
|
2004-07-27 05:09:16 +08:00
|
|
|
|
2018-05-30 22:12:57 +08:00
|
|
|
/* For high DPI displays, pixbuf size is bigger than logical size. */
|
|
|
|
cairo_scale (cr, (gdouble) 1.0 / scale_factor, (gdouble) 1.0 / scale_factor);
|
2011-01-01 01:15:15 +08:00
|
|
|
gdk_cairo_set_source_pixbuf (cr, priv->pixbuf,
|
2010-10-15 16:26:34 +08:00
|
|
|
toggle_rect.x, toggle_rect.y);
|
|
|
|
cairo_paint (cr);
|
2010-08-08 21:39:16 +08:00
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
g_object_get (cell,
|
2010-10-15 16:26:34 +08:00
|
|
|
"inconsistent", &inconsistent,
|
|
|
|
NULL);
|
2011-09-24 05:42:09 +08:00
|
|
|
|
2010-10-15 16:26:34 +08:00
|
|
|
if (inconsistent)
|
|
|
|
{
|
2010-12-15 20:14:18 +08:00
|
|
|
GdkRGBA color;
|
|
|
|
|
|
|
|
gtk_style_context_get_color (context, state, &color);
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
2021-02-21 23:52:25 +08:00
|
|
|
cairo_set_line_width (cr, scale_factor * 1.5);
|
2010-10-15 16:26:34 +08:00
|
|
|
cairo_move_to (cr,
|
2021-02-21 23:52:25 +08:00
|
|
|
toggle_rect.x + scale_factor * (toggle_rect.width - 1),
|
|
|
|
toggle_rect.y + scale_factor);
|
2010-10-15 16:26:34 +08:00
|
|
|
cairo_line_to (cr,
|
2021-02-21 23:52:25 +08:00
|
|
|
toggle_rect.x + scale_factor,
|
|
|
|
toggle_rect.y + scale_factor * (toggle_rect.height - 1));
|
2010-10-15 16:26:34 +08:00
|
|
|
cairo_stroke (cr);
|
2010-08-08 21:39:16 +08:00
|
|
|
}
|
2003-03-13 03:02:51 +08:00
|
|
|
}
|
2010-12-15 20:14:18 +08:00
|
|
|
|
|
|
|
gtk_style_context_restore (context);
|
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,
|
2010-10-15 16:26:34 +08:00
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
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
|
|
|
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);
|
|
|
|
|
2011-01-01 01:15:15 +08:00
|
|
|
g_clear_object (&priv->pixbuf);
|
2003-03-13 03:02:51 +08:00
|
|
|
|
2014-05-08 18:38:50 +08:00
|
|
|
if (priv->icon_name)
|
2014-05-07 21:28:51 +08:00
|
|
|
{
|
2021-11-02 22:40:06 +08:00
|
|
|
GdkPixbuf *pixbuf;
|
2018-05-30 22:12:57 +08:00
|
|
|
GdkScreen *screen;
|
|
|
|
GtkIconTheme *icon_theme;
|
|
|
|
GtkIconInfo *icon_info;
|
|
|
|
gchar *icon_name;
|
|
|
|
gint scale_factor;
|
|
|
|
|
|
|
|
scale_factor = gtk_widget_get_scale_factor (widget);
|
|
|
|
screen = gtk_widget_get_screen (widget);
|
|
|
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
|
|
|
|
|
|
|
/* Look for symbolic and fallback to color icon. */
|
|
|
|
icon_name = g_strdup_printf ("%s-symbolic", priv->icon_name);
|
|
|
|
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name,
|
2018-08-06 21:04:44 +08:00
|
|
|
priv->icon_size, scale_factor,
|
2018-05-30 22:12:57 +08:00
|
|
|
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
|
|
|
|
|
|
|
g_free (icon_name);
|
2021-11-02 22:40:06 +08:00
|
|
|
if (! icon_info)
|
2014-05-08 18:38:50 +08:00
|
|
|
{
|
2021-11-02 22:40:06 +08:00
|
|
|
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, "image-missing",
|
|
|
|
priv->icon_size, scale_factor,
|
|
|
|
GTK_ICON_LOOKUP_GENERIC_FALLBACK |
|
|
|
|
GTK_ICON_LOOKUP_USE_BUILTIN);
|
2018-05-30 22:12:57 +08:00
|
|
|
}
|
2021-11-02 22:40:06 +08:00
|
|
|
|
|
|
|
g_return_if_fail (icon_info != NULL);
|
|
|
|
|
|
|
|
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
|
|
|
|
gtk_widget_get_style_context (widget),
|
|
|
|
NULL, NULL);
|
|
|
|
priv->pixbuf = pixbuf;
|
|
|
|
g_object_unref (icon_info);
|
2014-05-07 21:28:51 +08:00
|
|
|
}
|
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.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: a new #GimpCellRendererToggle
|
2004-07-27 05:09:16 +08:00
|
|
|
*
|
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);
|
|
|
|
}
|