Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

165
libpika/COPYING Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -0,0 +1,17 @@
PikaUi name="PikaUi"
// Extra metadata for Vala, to deal with
// annotations that GIR can't handle.
//
// For example, GIR function doesn't handle
// varargs, but Vala *can* do this, so we can
// remove the (skip) annotation.
Dialog
.new skip=false
.add_buttons skip=false
IntComboBox
.new skip=false
IntStore
.new skip=false
ProcBrowserDialog
.new skip=false

221
libpika/Makefile.gi Normal file
View File

@ -0,0 +1,221 @@
# Introspectable sources for libpika and libpikaui
PDB_WRAPPERS_C = \
../libpika/pika_pdb.c \
../libpika/pikabrush_pdb.c \
../libpika/pikabrushes_pdb.c \
../libpika/pikabrushselect_pdb.c \
../libpika/pikabuffer_pdb.c \
../libpika/pikachannel_pdb.c \
../libpika/pikacontext_pdb.c \
../libpika/pikadebug_pdb.c \
../libpika/pikadisplay_pdb.c \
../libpika/pikadrawable_pdb.c \
../libpika/pikadrawablecolor_pdb.c \
../libpika/pikadrawableedit_pdb.c \
../libpika/pikadynamics_pdb.c \
../libpika/pikaedit_pdb.c \
../libpika/pikafile_pdb.c \
../libpika/pikafloatingsel_pdb.c \
../libpika/pikafont_pdb.c \
../libpika/pikafonts_pdb.c \
../libpika/pikafontselect_pdb.c \
../libpika/pikapikarc_pdb.c \
../libpika/pikagradient_pdb.c \
../libpika/pikagradients_pdb.c \
../libpika/pikagradientselect_pdb.c \
../libpika/pikahelp_pdb.c \
../libpika/pikaimage_pdb.c \
../libpika/pikaimagecolorprofile_pdb.c \
../libpika/pikaimageconvert_pdb.c \
../libpika/pikaimagegrid_pdb.c \
../libpika/pikaimageguides_pdb.c \
../libpika/pikaimagesamplepoints_pdb.c \
../libpika/pikaimageselect_pdb.c \
../libpika/pikaimagetransform_pdb.c \
../libpika/pikaimageundo_pdb.c \
../libpika/pikaitem_pdb.c \
../libpika/pikaitemtransform_pdb.c \
../libpika/pikalayer_pdb.c \
../libpika/pikamessage_pdb.c \
../libpika/pikapainttools_pdb.c \
../libpika/pikapalette_pdb.c \
../libpika/pikapalettes_pdb.c \
../libpika/pikapaletteselect_pdb.c \
../libpika/pikapattern_pdb.c \
../libpika/pikapatterns_pdb.c \
../libpika/pikapatternselect_pdb.c \
../libpika/pikaprogress_pdb.c \
../libpika/pikaselection_pdb.c \
../libpika/pikatextlayer_pdb.c \
../libpika/pikatexttool_pdb.c \
../libpika/pikavectors_pdb.c
PDB_WRAPPERS_H = \
../libpika/pika_pdb_headers.h \
../libpika/pika_pdb.h \
../libpika/pikabrush_pdb.h \
../libpika/pikabrushes_pdb.h \
../libpika/pikabrushselect_pdb.h \
../libpika/pikabuffer_pdb.h \
../libpika/pikachannel_pdb.h \
../libpika/pikacontext_pdb.h \
../libpika/pikadebug_pdb.h \
../libpika/pikadisplay_pdb.h \
../libpika/pikadrawable_pdb.h \
../libpika/pikadrawablecolor_pdb.h \
../libpika/pikadrawableedit_pdb.h \
../libpika/pikadynamics_pdb.h \
../libpika/pikaedit_pdb.h \
../libpika/pikafile_pdb.h \
../libpika/pikafloatingsel_pdb.h \
../libpika/pikafont_pdb.h \
../libpika/pikafonts_pdb.h \
../libpika/pikafontselect_pdb.h \
../libpika/pikapikarc_pdb.h \
../libpika/pikagradient_pdb.h \
../libpika/pikagradients_pdb.h \
../libpika/pikagradientselect_pdb.h \
../libpika/pikahelp_pdb.h \
../libpika/pikaimage_pdb.h \
../libpika/pikaimagecolorprofile_pdb.h \
../libpika/pikaimageconvert_pdb.h \
../libpika/pikaimagegrid_pdb.h \
../libpika/pikaimageguides_pdb.h \
../libpika/pikaimagesamplepoints_pdb.h \
../libpika/pikaimageselect_pdb.h \
../libpika/pikaimagetransform_pdb.h \
../libpika/pikaimageundo_pdb.h \
../libpika/pikaitem_pdb.h \
../libpika/pikaitemtransform_pdb.h \
../libpika/pikalayer_pdb.h \
../libpika/pikamessage_pdb.h \
../libpika/pikapainttools_pdb.h \
../libpika/pikapalette_pdb.h \
../libpika/pikapalettes_pdb.h \
../libpika/pikapaletteselect_pdb.h \
../libpika/pikapattern_pdb.h \
../libpika/pikapatterns_pdb.h \
../libpika/pikapatternselect_pdb.h \
../libpika/pikaprogress_pdb.h \
../libpika/pikaselection_pdb.h \
../libpika/pikatextlayer_pdb.h \
../libpika/pikatexttool_pdb.h \
../libpika/pikavectors_pdb.h
libpika_built_sources = \
pikaenums.c
libpika_introspectable_headers = \
../libpika/pika.h \
../libpika/pikatypes.h \
../libpika/pikaenums.h \
${PDB_WRAPPERS_H} \
../libpika/pikabatchprocedure.h \
../libpika/pikachannel.h \
../libpika/pikadisplay.h \
../libpika/pikadrawable.h \
../libpika/pikafileprocedure.h \
../libpika/pikapikarc.h \
../libpika/pikaimage.h \
../libpika/pikaimagecolorprofile.h \
../libpika/pikaimagemetadata.h \
../libpika/pikaimageprocedure.h \
../libpika/pikaitem.h \
../libpika/pikalayer.h \
../libpika/pikalayermask.h \
../libpika/pikaloadprocedure.h \
../libpika/pikaparamspecs.h \
../libpika/pikaparamspecs-resource.h \
../libpika/pikapdb.h \
../libpika/pikaplugin.h \
../libpika/pikaprocedure.h \
../libpika/pikaprocedureconfig.h \
../libpika/pikaprogress.h \
../libpika/pikaresource.h \
../libpika/pikaresourceselect.h \
../libpika/pikaresource-subclass.h \
../libpika/pikasaveprocedure.h \
../libpika/pikaselection.h \
../libpika/pikatextlayer.h \
../libpika/pikathumbnailprocedure.h \
../libpika/pikavectors.h
libpika_introspectable = \
$(libpika_introspectable_headers) \
$(libpika_built_sources) \
../libpika/pika.c \
${PDB_WRAPPERS_C} \
../libpika/pikabatchprocedure.c \
../libpika/pikachannel.c \
../libpika/pikadisplay.c \
../libpika/pikadrawable.c \
../libpika/pikafileprocedure.c \
../libpika/pikapikarc.c \
../libpika/pikaimage.c \
../libpika/pikaimagecolorprofile.c \
../libpika/pikaimagemetadata.c \
../libpika/pikaimagemetadata-save.c \
../libpika/pikaimageprocedure.c \
../libpika/pikaitem.c \
../libpika/pikalayer.c \
../libpika/pikalayermask.c \
../libpika/pikaloadprocedure.c \
../libpika/pikaparamspecs.c \
../libpika/pikapdb.c \
../libpika/pikaplugin.c \
../libpika/pikaprocedure.c \
../libpika/pikaprocedureconfig.c \
../libpika/pikaprogress.c \
../libpika/pikaresource.c \
../libpika/pikaresourceselect.c \
../libpika/pikaresource-subclass.c \
../libpika/pikasaveprocedure.c \
../libpika/pikaselection.c \
../libpika/pikatextlayer.c \
../libpika/pikathumbnailprocedure.c \
../libpika/pikavectors.c
libpikaui_introspectable_headers = \
../libpika/pikaui.h \
../libpika/pikauitypes.h \
../libpika/pikaaspectpreview.h \
../libpika/pikabrushselectbutton.h \
../libpika/pikadrawablepreview.h \
../libpika/pikaexport.h \
../libpika/pikafontselectbutton.h \
../libpika/pikagradientselectbutton.h \
../libpika/pikaimagecombobox.h \
../libpika/pikaitemcombobox.h \
../libpika/pikapaletteselectbutton.h \
../libpika/pikapatternselectbutton.h \
../libpika/pikaprocbrowserdialog.h \
../libpika/pikaproceduredialog.h \
../libpika/pikaprocview.h \
../libpika/pikaprogressbar.h \
../libpika/pikapropchooserfactory.h \
../libpika/pikaresourceselectbutton.h \
../libpika/pikasaveproceduredialog.h \
../libpika/pikazoompreview.h
libpikaui_introspectable = \
$(libpikaui_introspectable_headers) \
../libpika/pikaui.c \
../libpika/pikaaspectpreview.c \
../libpika/pikabrushselectbutton.c \
../libpika/pikadrawablepreview.c \
../libpika/pikaexport.c \
../libpika/pikafontselectbutton.c \
../libpika/pikagradientselectbutton.c \
../libpika/pikaimagecombobox.c \
../libpika/pikaitemcombobox.c \
../libpika/pikapaletteselectbutton.c \
../libpika/pikapatternselectbutton.c \
../libpika/pikaprocbrowserdialog.c \
../libpika/pikaproceduredialog.c \
../libpika/pikaprocview.c \
../libpika/pikapropchooserfactory.c \
../libpika/pikasaveproceduredialog.c \
../libpika/pikaprogressbar.c \
../libpika/pikaresourceselectbutton.c \
../libpika/pikazoompreview.c

45
libpika/libpika-intl.h Normal file
View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* libpika-intl.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __LIBPIKA_INTL_H__
#define __LIBPIKA_INTL_H__
#ifndef GETTEXT_PACKAGE
#error "config.h must be included prior to libpika-intl.h"
#endif
#include <libintl.h>
#define _(String) dgettext (GETTEXT_PACKAGE "-libpika", String)
#define Q_(String) g_dpgettext (GETTEXT_PACKAGE "-libpika", String, 0)
#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE "-libpika", Context "\004" String, strlen (Context) + 1)
#undef gettext
#define gettext(String) dgettext (GETTEXT_PACKAGE "-libpika", String)
#undef ngettext
#define ngettext(String1, String2, number) dngettext (GETTEXT_PACKAGE "-libpika", String1, String2, number)
#define N_(String) (String)
#define NC_(Context,String) (String)
#endif /* __LIBPIKA_INTL_H__ */

570
libpika/meson.build Normal file
View File

@ -0,0 +1,570 @@
# Similarly to libpikathumb/pikathumb-enums.c, libpika/pikaenums.c is
# not versionned so we don't use the mkenums_wrap.
# Moreover it is generated in 2 steps, first with common mkenums
# arguments, then concatenating with a "tail" file.
pikaenums_notail = custom_target('pikaenums.c.notail',
input : [ 'pikaenums.h', ],
output: [ 'pikaenums.c.notail', ],
command: [
pika_mkenums,
'--fhead','#include "config.h"\n'
+ '#include <gio/gio.h>\n'
+ '#include <gegl.h>\n'
+ '#undef PIKA_DISABLE_DEPRECATED\n'
+ '#include "libpikabase/pikabase.h"\n'
+ '#include "libpikabase/pikabase-private.h"\n'
+ '#include "libpikaconfig/pikaconfigenums.h"\n'
+ '#include "pikaenums.h"\n',
'--fprod',
'/* enumerations from "@basename@" */',
'--vhead',
'GType\n'+
'@enum_name@_get_type (void)\n'+
'{\n'+
' static const G@Type@Value values[] =\n'+
' {',
'--vprod',
' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
'--vtail',
' { 0, NULL, NULL }\n'+
' };\n',
'--dhead',
' static const Pika@Type@Desc descs[] =\n'+
' {',
'--dprod',
' { @VALUENAME@, @valuedesc@, @valuehelp@ },'+
'@if (\'@valueabbrev@\' ne \'NULL\')@\n'+
' /* Translators: this is an abbreviated version of @valueudesc@.\n'+
' Keep it short. */\n'+
' { @VALUENAME@, @valueabbrev@, NULL },'+
'@endif@',
'--dtail',
libpika_mkenums_dtails,
'@INPUT@',
],
capture: true,
)
pikaenums = custom_target('pikaenums.c',
input : [ pikaenums_notail, 'pikaenums.c.tail', ],
output: [ 'pikaenums.c', ],
command: [ 'cat', '@INPUT@' ],
capture: true,
)
pikauimarshal = gnome.genmarshal('pikauimarshal',
prefix: '_pikaui_marshal',
sources: 'pikauimarshal.list',
install_header: false,
)
pdb_wrappers_sources = [
'pika_pdb.c',
'pikabrush_pdb.c',
'pikabrushes_pdb.c',
'pikabrushselect_pdb.c',
'pikabuffer_pdb.c',
'pikachannel_pdb.c',
'pikacontext_pdb.c',
'pikadebug_pdb.c',
'pikadisplay_pdb.c',
'pikadrawable_pdb.c',
'pikadrawablecolor_pdb.c',
'pikadrawableedit_pdb.c',
'pikadynamics_pdb.c',
'pikaedit_pdb.c',
'pikafile_pdb.c',
'pikafloatingsel_pdb.c',
'pikafont_pdb.c',
'pikafonts_pdb.c',
'pikafontselect_pdb.c',
'pikapikarc_pdb.c',
'pikagradient_pdb.c',
'pikagradients_pdb.c',
'pikagradientselect_pdb.c',
'pikahelp_pdb.c',
'pikaimage_pdb.c',
'pikaimagecolorprofile_pdb.c',
'pikaimageconvert_pdb.c',
'pikaimagegrid_pdb.c',
'pikaimageguides_pdb.c',
'pikaimagesamplepoints_pdb.c',
'pikaimageselect_pdb.c',
'pikaimagetransform_pdb.c',
'pikaimageundo_pdb.c',
'pikaitem_pdb.c',
'pikaitemtransform_pdb.c',
'pikalayer_pdb.c',
'pikamessage_pdb.c',
'pikapainttools_pdb.c',
'pikapalette_pdb.c',
'pikapalettes_pdb.c',
'pikapaletteselect_pdb.c',
'pikapattern_pdb.c',
'pikapatterns_pdb.c',
'pikapatternselect_pdb.c',
'pikaprogress_pdb.c',
'pikaresource_pdb.c',
'pikaselection_pdb.c',
'pikatextlayer_pdb.c',
'pikatexttool_pdb.c',
'pikavectors_pdb.c',
]
pdb_wrappers_headers = [
'pika_pdb_headers.h',
'pika_pdb.h',
'pikabrush_pdb.h',
'pikabrushes_pdb.h',
'pikabrushselect_pdb.h',
'pikabuffer_pdb.h',
'pikachannel_pdb.h',
'pikacontext_pdb.h',
'pikadebug_pdb.h',
'pikadisplay_pdb.h',
'pikadrawable_pdb.h',
'pikadrawablecolor_pdb.h',
'pikadrawableedit_pdb.h',
'pikadynamics_pdb.h',
'pikaedit_pdb.h',
'pikafile_pdb.h',
'pikafloatingsel_pdb.h',
'pikafont_pdb.h',
'pikafonts_pdb.h',
'pikafontselect_pdb.h',
'pikapikarc_pdb.h',
'pikagradient_pdb.h',
'pikagradients_pdb.h',
'pikagradientselect_pdb.h',
'pikahelp_pdb.h',
'pikaimage_pdb.h',
'pikaimagecolorprofile_pdb.h',
'pikaimageconvert_pdb.h',
'pikaimagegrid_pdb.h',
'pikaimageguides_pdb.h',
'pikaimagesamplepoints_pdb.h',
'pikaimageselect_pdb.h',
'pikaimagetransform_pdb.h',
'pikaimageundo_pdb.h',
'pikaitem_pdb.h',
'pikaitemtransform_pdb.h',
'pikalayer_pdb.h',
'pikamessage_pdb.h',
'pikapainttools_pdb.h',
'pikapalette_pdb.h',
'pikapalettes_pdb.h',
'pikapaletteselect_pdb.h',
'pikapattern_pdb.h',
'pikapatterns_pdb.h',
'pikapatternselect_pdb.h',
'pikaprogress_pdb.h',
'pikaresource_pdb.h',
'pikaselection_pdb.h',
'pikatextlayer_pdb.h',
'pikatexttool_pdb.h',
'pikavectors_pdb.h',
]
libpika_sources_introspectable = [
'pika.c',
'pikabatchprocedure.c',
'pikachannel.c',
'pikadisplay.c',
'pikadrawable.c',
'pikafileprocedure.c',
'pikapikarc.c',
'pikaimage.c',
'pikaimagecolorprofile.c',
'pikaimagemetadata.c',
'pikaimagemetadata-save.c',
'pikaimageprocedure.c',
'pikaitem.c',
'pikalayer.c',
'pikalayermask.c',
'pikaloadprocedure.c',
'pikaparamspecs.c',
'pikapdb.c',
'pikaplugin.c',
'pikaprocedure.c',
'pikaprocedureconfig.c',
'pikaprogress.c',
'pikaresource.c',
'pikaresourceselect.c',
'pikasaveprocedure.c',
'pikaselection.c',
'pikatextlayer.c',
'pikathumbnailprocedure.c',
'pikavectors.c',
pikaenums,
pdb_wrappers_sources,
]
libpika_sources = [
libpika_sources_introspectable,
'pika-debug.c',
'pika-shm.c',
'pikagpparams.c',
'pikaparamspecs-desc.c',
'pikapdb_pdb.c',
'pikapdbprocedure.c',
'pikapixbuf.c',
'pikaplugin_pdb.c',
'pikaunit_pdb.c',
'pikaunitcache.c',
'pikatilebackendplugin.c',
]
libpika_headers_introspectable = [
# Order matters. Leave these headers at the top.
'pika.h',
'pikatypes.h',
'pikaenums.h',
# Other headers
'pikabatchprocedure.h',
'pikachannel.h',
'pikadisplay.h',
'pikadrawable.h',
'pikafileprocedure.h',
'pikapikarc.h',
'pikaimage.h',
'pikaimagecolorprofile.h',
'pikaimagemetadata.h',
'pikaimageprocedure.h',
'pikaitem.h',
'pikalayer.h',
'pikalayermask.h',
'pikaloadprocedure.h',
'pikaparamspecs.h',
'pikapdb.h',
'pikaplugin.h',
'pikaprocedure.h',
'pikaprocedureconfig.h',
'pikaprogress.h',
'pikaresource.h',
'pikaresourceselect.h',
'pikasaveprocedure.h',
'pikaselection.h',
'pikatextlayer.h',
'pikathumbnailprocedure.h',
'pikavectors.h',
pdb_wrappers_headers,
]
libpika_headers = [
libpika_headers_introspectable,
'pikaprocedure-params.h',
]
libpikaui_sources_introspectable = [
'pikaaspectpreview.c',
'pikabrushselectbutton.c',
'pikadrawablepreview.c',
'pikaexport.c',
'pikafontselectbutton.c',
'pikagradientselectbutton.c',
'pikaimagecombobox.c',
'pikaitemcombobox.c',
'pikapaletteselectbutton.c',
'pikapatternselectbutton.c',
'pikaprocbrowserdialog.c',
'pikaproceduredialog.c',
'pikaprocview.c',
'pikaprogressbar.c',
'pikapropchooserfactory.c',
'pikaresourceselectbutton.c',
'pikasaveproceduredialog.c',
'pikaui.c',
'pikazoompreview.c',
]
libpikaui_sources = [
libpikaui_sources_introspectable,
pikauimarshal,
'pikapropchooser-private.c',
]
libpikaui_headers_introspectable = [
# Order matters. Leave these headers at the top.
'pikaui.h',
'pikauitypes.h',
# Other headers
'pikaaspectpreview.h',
'pikabrushselectbutton.h',
'pikadrawablepreview.h',
'pikaexport.h',
'pikafontselectbutton.h',
'pikagradientselectbutton.h',
'pikaimagecombobox.h',
'pikaitemcombobox.h',
'pikapaletteselectbutton.h',
'pikapatternselectbutton.h',
'pikaprocbrowserdialog.h',
'pikaproceduredialog.h',
'pikaprocview.h',
'pikaprogressbar.h',
'pikapropchooserfactory.h',
'pikaresourceselectbutton.h',
'pikasaveproceduredialog.h',
'pikazoompreview.h',
]
libpika_introspectable = [
libpika_sources_introspectable,
libpika_headers_introspectable,
]
libpikaui_introspectable = [
libpikaui_sources_introspectable,
libpikaui_headers_introspectable,
]
libpika = library('pika-'+ pika_api_version,
libpika_sources,
include_directories: rootInclude,
dependencies: [
cairo,
gdk_pixbuf,
gegl,
gexiv2,
drmingw,
],
sources: [
pdbgen
],
c_args: [ '-DG_LOG_DOMAIN="LibPika"', '-DPIKA_COMPILATION', ],
link_with: [
libpikabase,
libpikacolor,
libpikaconfig,
libpikamodule,
],
vs_module_defs: 'pika.def',
install: true,
version: so_version,
)
# Define an internal dependency for ease of reuse
libpika_dep = declare_dependency(
dependencies: [
cairo,
gdk_pixbuf,
gegl,
],
link_with: [
libpika,
libpikabase,
libpikacolor,
libpikaconfig,
libpikamath,
libpikamodule,
],
include_directories: rootInclude,
)
libpikaui = library('pikaui-'+ pika_api_version,
libpikaui_sources,
dependencies: [
libpika_dep,
gexiv2,
gtk3,
],
c_args: [ '-DG_LOG_DOMAIN="LibPikaUI"', '-DPIKA_COMPILATION', ],
link_with: [
libpikawidgets,
],
vs_module_defs: 'pikaui.def',
install: true,
version: so_version,
)
# Define an internal dependency for ease of reuse
libpikaui_dep = declare_dependency(
dependencies: [
libpika_dep,
gtk3,
],
link_with: [
libpikaui,
libpikawidgets,
],
include_directories: rootInclude,
)
install_headers(
libpika_headers,
libpikaui_headers_introspectable,
subdir: pika_api_name / 'libpika',
)
### GObject introspection
libpika_introspectable_files = [
libpika_introspectable,
libpikabase_introspectable,
libpikacolor_introspectable,
libpikaconfig_introspectable,
libpikamath_introspectable,
libpikamodule_introspectable,
'pikaparamspecs-body.c'
]
libpikaui_introspectable_files = [
libpikaui_introspectable,
libpikawidgets_introspectable,
]
if meson.is_cross_build() and not get_option('can-crosscompile-gir')
have_gobject_introspection = false
gobject_introspection_warning = '\n '.join(['',
'GObject Introspection is disabled while cross-compiling because',
'GI tools do not manage to properly generate introspection data',
'while cross-compiling. Nevertheless we consider our introspected',
'API as a core component of PIKA, thus you are expected to build',
'this data natively.',
'To forcefully build with GObject Introspection, set:',
'-Dcan-crosscompile-gir=true'
])
warning(gobject_introspection_warning)
warnings += gobject_introspection_warning
elif get_option('b_sanitize') != 'none'
have_gobject_introspection = false
gobject_introspection_warning = '\n '.join(['',
'GObject Introspection is disabled while building with a sanitizer.',
'See: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/375'
])
warning(gobject_introspection_warning)
warnings += gobject_introspection_warning
else
have_gobject_introspection = true
libpika_gir_includes = [
'Babl-0.1',
'cairo-1.0',
'GdkPixbuf-2.0',
'Gegl-0.4',
'Gio-2.0',
'GLib-2.0',
'GObject-2.0',
]
gir_args = [
'-DPIKA_COMPILATION',
'-DPIKA_BASE_COMPILATION',
'-DPIKA_COLOR_COMPILATION',
'-DPIKA_CONFIG_COMPILATION',
'-DPIKA_MATH_COMPILATION',
'-DPIKA_MODULE_COMPILATION',
'-DPIKA_THUMB_COMPILATION',
'-DPIKA_WIDGETS_COMPILATION',
'-DPIKA_DISABLE_DEPRECATED',
'--quiet',
]
libpika_gir = gnome.generate_gir(
libpika,
libpikabase,
libpikacolor,
libpikaconfig,
libpikamath,
libpikamodule,
sources: libpika_introspectable_files,
nsversion: pika_api_version,
namespace: 'Pika',
identifier_prefix: 'Pika',
symbol_prefix: 'pika',
export_packages: 'pika-' + pika_api_version,
header: 'libpika/pika.h',
includes: libpika_gir_includes,
extra_args: gir_args,
include_directories: rootInclude,
install: true,
)
libpikaui_gir = gnome.generate_gir(
libpikaui,
libpikawidgets,
sources: libpikaui_introspectable_files,
nsversion: pika_api_version,
namespace: 'PikaUi',
identifier_prefix: 'Pika',
symbol_prefix: [ 'pika_ui', 'pika' ],
export_packages: 'pika-ui-' + pika_api_version,
header: 'libpika/pikaui.h',
includes: [ libpika_gir_includes, 'Gtk-3.0', libpika_gir[0] ],
extra_args: gir_args,
include_directories: rootInclude,
install: true,
)
if have_vala
vapi_deps = [
'babl-0.1',
'cairo-1.0',
'gdk-pixbuf-2.0',
'gegl-0.4',
'gio-2.0',
'glib-2.0',
'gobject-2.0',
'gtk+-3.0',
]
libpika_vapi = gnome.generate_vapi('pika-' + pika_api_version,
sources: libpika_gir[0],
packages: vapi_deps,
install: true,
)
libpikaui_vapi = gnome.generate_vapi('pika-ui-' + pika_api_version,
sources: libpikaui_gir[0],
packages: vapi_deps + [ libpika_vapi ],
install: true,
)
endif
endif
if have_python and not platform_windows and not platform_osx
# Verify .def files for Windows.
# Ironically we only check this on non-Windows platform, since the
# script expects .so libraries, and I'm not sure that the `nm` tool is
# available on Windows.
# On the other hand, it is how it always has been, since we used to
# only run this on dist step (which we historically run on a GNU/Linux
# machine). And it worked fine until now.
custom_target('check-def-files',
input: [
'../libpikabase/pikabase.def',
'../libpikacolor/pikacolor.def',
'../libpikaconfig/pikaconfig.def',
'../libpika/pika.def',
'../libpika/pikaui.def',
'../libpikamath/pikamath.def',
'../libpikamodule/pikamodule.def',
'../libpikathumb/pikathumb.def',
'../libpikawidgets/pikawidgets.def',
],
depends: [
libpikabase,
libpikacolor,
libpikaconfig,
libpika,
libpikaui,
libpikamath,
libpikamodule,
libpikathumb,
libpikawidgets
],
output: [ 'check-def-files', ],
command: [
python, meson.project_source_root() / 'tools' / 'defcheck.py', meson.project_source_root(),
],
build_by_default: true,
)
endif

417
libpika/pika-debug.c Normal file
View File

@ -0,0 +1,417 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika-debug.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <sys/types.h>
#include <glib.h>
#ifndef G_OS_WIN32
#include "libpikabase/pikasignal.h"
#else
#ifdef HAVE_EXCHNDL
#include <time.h>
#include <exchndl.h>
#endif
#include <signal.h>
#endif
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
# ifdef STRICT
# undef STRICT
# endif
# define STRICT
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif
# define _WIN32_WINNT 0x0601
# include <windows.h>
# include <tlhelp32.h>
# include <processthreadsapi.h>
# undef RGB
#endif
#include "pika.h"
#include "pika-debug.h"
static GLogLevelFlags create_log_level_flags (void);
static void make_visible_libpika_messages (void);
static void pika_message_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer data);
static void pika_fatal_func (const gchar *log_domain,
GLogLevelFlags flags,
const gchar *message,
gpointer data);
static const GDebugKey pika_debug_keys[] =
{
{ "pid", PIKA_DEBUG_PID },
{ "fatal-warnings", PIKA_DEBUG_FATAL_WARNINGS },
{ "fatal-criticals", PIKA_DEBUG_FATAL_CRITICALS },
{ "fw", PIKA_DEBUG_FATAL_WARNINGS },
{ "query", PIKA_DEBUG_QUERY },
{ "init", PIKA_DEBUG_INIT },
{ "run", PIKA_DEBUG_RUN },
{ "quit", PIKA_DEBUG_QUIT }
};
/* Set by pika_debug_configure() to partial parameterize pika_fatal_handler(). */
static PikaStackTraceMode _stack_trace_mode = PIKA_STACK_TRACE_NEVER;
/* Set by _pika_debug_init(). Exported by _pika_get_debug_flags() */
static guint _pika_debug_flags = 0;
/*
* Set _pika_debug_flags, from env var PIKA_PLUGIN_DEBUG if it exists.
* Also ensure GLib default handler prints all log messages for domain LibPika.
*/
void
_pika_debug_init (const gchar *basename)
{
const gchar *env_string = g_getenv ("PIKA_PLUGIN_DEBUG");
const gchar *debug_options;
gint plugin_name_len;
gboolean is_debug_name_match_basename;
if (!env_string) return;
debug_options = strchr (env_string, ',');
/* Does name match basename or name match "all"
* Use strlen to allow basename to have prefix "all" without matching.
*/
/* Safe subtraction of pointers into the same string. */
plugin_name_len = debug_options - env_string;
is_debug_name_match_basename = (
((strlen (basename) == plugin_name_len) &&
(strncmp (basename, env_string, plugin_name_len) == 0)) ||
(strncmp (env_string, "all", plugin_name_len) == 0)
);
if (is_debug_name_match_basename && debug_options)
{
_pika_debug_flags =
g_parse_debug_string (debug_options + 1,
pika_debug_keys,
G_N_ELEMENTS (pika_debug_keys));
}
/* Else assert _pika_debug_flags==0 .
* Only ERROR will be fatal, and fatal handler installed
* (to print according to stack-trace-mode)
*/
make_visible_libpika_messages();
}
guint
_pika_get_debug_flags (void)
{
return _pika_debug_flags;
}
/*
* Configure GLib logging according to PIKA_PLUGIN_DEBUG
*/
void
_pika_debug_configure (PikaStackTraceMode stack_trace_mode)
{
const gchar * const pika_log_domains[] =
{
"LibPika",
"LibPikaBase",
"LibPikaColor",
"LibPikaConfig",
"LibPikaMath",
"LibPikaModule",
"LibPikaThumb",
"LibPikaWidgets"
};
const gchar * const glib_log_domains[] =
{
"GLib",
"GLib-GObject",
"GLib-GIO",
};
gint i;
GLogLevelFlags fatal_mask;
_stack_trace_mode = stack_trace_mode;
/* Set handler for Pika domains, for MESSAGE level.
* i.e. from g_message(), but not from g_info() (rarely used?).
*/
for (i = 0; i < G_N_ELEMENTS (pika_log_domains); i++)
g_log_set_handler (pika_log_domains[i],
G_LOG_LEVEL_MESSAGE,
pika_message_func,
NULL);
/* Also set handler for "" i.e. app domain. */
g_log_set_handler (NULL,
G_LOG_LEVEL_MESSAGE,
pika_message_func,
NULL);
/* Make fatal a subset of log levels (ERROR is always fatal)
* as specified by PIKA_PLUGIN_DEBUG now in _pika_debug_flags
*/
fatal_mask = create_log_level_flags();
g_log_set_always_fatal (fatal_mask);
/* set our custom handler for fatal messages, for many domains. */
/* For the null i.e. "" i.e. app i.e. plugin domain */
g_log_set_handler (NULL,
fatal_mask,
pika_fatal_func,
NULL);
for (i = 0; i < G_N_ELEMENTS (pika_log_domains); i++)
g_log_set_handler (pika_log_domains[i],
fatal_mask,
pika_fatal_func,
NULL);
for (i = 0; i < G_N_ELEMENTS (glib_log_domains); i++)
g_log_set_handler (glib_log_domains[i],
fatal_mask,
pika_fatal_func,
NULL);
}
/*
* Suspend i.e. pause the plugin process.
*/
void
_pika_debug_stop (void)
{
#ifndef G_OS_WIN32
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Waiting for debugger...");
raise (SIGSTOP);
#else
HANDLE hThreadSnap = NULL;
THREADENTRY32 te32 = { 0 };
DWORD opid = GetCurrentProcessId();
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"Debugging (restart externally): %ld",
(long int) opid);
hThreadSnap = CreateToolhelp32Snapshot (TH32CS_SNAPTHREAD, 0);
if (hThreadSnap == INVALID_HANDLE_VALUE)
{
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"error getting threadsnap - debugging impossible");
return;
}
te32.dwSize = sizeof (THREADENTRY32);
if (Thread32First (hThreadSnap, &te32))
{
do
{
if (te32.th32OwnerProcessID == opid)
{
HANDLE hThread = OpenThread (THREAD_SUSPEND_RESUME, FALSE,
te32.th32ThreadID);
SuspendThread (hThread);
CloseHandle (hThread);
}
}
while (Thread32Next (hThreadSnap, &te32));
}
else
{
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "error getting threads");
}
CloseHandle (hThreadSnap);
#endif
}
/* private functions */
/*
* Append domain LibPika to env var G_MESSAGES_DEBUG.
* Per GLib docs, that makes default handler print all levels of log messages,
* from domain LibPika.
* We may yet install non-default handler pika_fatal_func(), for some levels,
* which prints the message and also may generate stack trace.
*
* This does not depend on PIKA_PLUGIN_DEBUG or any plugin names therein.
* This does not affect the Pika app, whose environment is distinct.
* This does not make a plugin's own logged messages visible,
* since the plugin is in a distinct domain.
*/
static void
make_visible_libpika_messages (void)
{
const gchar *debug_messages = g_getenv ("G_MESSAGES_DEBUG");
if (debug_messages)
{
gchar *tmp = g_strconcat (debug_messages, ",LibPika", NULL);
g_setenv ("G_MESSAGES_DEBUG", tmp, TRUE);
g_free (tmp);
}
else
{
g_setenv ("G_MESSAGES_DEBUG", "LibPika", TRUE);
}
}
/* Create GLogLevelFlags for fatal,
* from current fatal flags and from PIKA_PLUGIN_DEBUG env var.
*/
static GLogLevelFlags
create_log_level_flags(void)
{
GLogLevelFlags result;
result = g_log_set_always_fatal (G_LOG_FATAL_MASK);
/* result is the old one, and may have flags set already
* via the GLib G_DEBUG environment variable.
*/
/* Ensure ERROR remains fatal.
* Even if PIKA_PLUGIN_DEBUG is not defined, or defined "=run"
* we install fatal handler for ERROR for all plugins.
*/
result |= G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL;
if (_pika_debug_flags & PIKA_DEBUG_FATAL_WARNINGS)
result |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
if (_pika_debug_flags & PIKA_DEBUG_FATAL_CRITICALS)
result |= G_LOG_LEVEL_CRITICAL;
return result;
}
/*
* Handler for GLib log events of MESSAGE level.
* Signature is GLogFunc
*/
static void
pika_message_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer data)
{
pika_message (message);
}
/*
* Handler for fatal GLib logging events.
* Signature is GLogFunc
*/
static void
pika_fatal_func (const gchar *log_domain,
GLogLevelFlags flags,
const gchar *message,
gpointer data)
{
const gchar *level;
switch (flags & G_LOG_LEVEL_MASK)
{
case G_LOG_LEVEL_WARNING:
level = "WARNING";
break;
case G_LOG_LEVEL_CRITICAL:
level = "CRITICAL";
break;
case G_LOG_LEVEL_ERROR:
level = "ERROR";
break;
default:
level = "FATAL";
break;
}
/* Earlier, pika.c g_set_prgname to short basename; progname is full path. */
/*
* Print message canonical to what GLib's default handler would.
* Except prefix with which plugin using short name i.e. basename
* so reader can distinguish interleaved messages from plugin or app process.
* The log_domain is which library logged the event.
*/
g_printerr ("Plugin %s: %s: %s: %s\n",
g_get_prgname(), log_domain, level, message);
#ifndef G_OS_WIN32
switch (_stack_trace_mode)
{
case PIKA_STACK_TRACE_NEVER:
break;
case PIKA_STACK_TRACE_QUERY:
{
sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
pika_stack_trace_query (log_domain);
}
break;
case PIKA_STACK_TRACE_ALWAYS:
{
sigset_t sigset;
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
pika_stack_trace_print (log_domain, stdout, NULL);
}
break;
}
#endif /* ! G_OS_WIN32 */
/* Do not end with pika_quit().
* We want the plug-in to continue its normal crash course, otherwise
* we won't get the "Plug-in crashed" error in PIKA.
*/
exit (EXIT_FAILURE);
}

48
libpika/pika-debug.h Normal file
View File

@ -0,0 +1,48 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika-debug.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_DEBUG_H__
#define __PIKA_DEBUG_H__
G_BEGIN_DECLS
typedef enum
{
PIKA_DEBUG_PID = 1 << 0,
PIKA_DEBUG_FATAL_WARNINGS = 1 << 1,
PIKA_DEBUG_QUERY = 1 << 2,
PIKA_DEBUG_INIT = 1 << 3,
PIKA_DEBUG_RUN = 1 << 4,
PIKA_DEBUG_QUIT = 1 << 5,
PIKA_DEBUG_FATAL_CRITICALS = 1 << 6,
} PikaDebugFlag;
void _pika_debug_init (const gchar *basename);
void _pika_debug_configure (PikaStackTraceMode stack_trace_mode);
guint _pika_get_debug_flags (void);
void _pika_debug_stop (void);
G_END_DECLS
#endif /* __PIKA_DEBUG_H__ */

32
libpika/pika-private.h Normal file
View File

@ -0,0 +1,32 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika-private.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_PRIVATE_H__
#define __PIKA_PRIVATE_H__
G_BEGIN_DECLS
void _pika_config (GPConfig *config);
G_END_DECLS
#endif /* __PIKA_PRIVATE_H__ */

203
libpika/pika-shm.c Normal file
View File

@ -0,0 +1,203 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika-shm.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#if defined(USE_SYSV_SHM)
#ifdef HAVE_IPC_H
#include <sys/ipc.h>
#endif
#ifdef HAVE_SHM_H
#include <sys/shm.h>
#endif
#elif defined(USE_POSIX_SHM)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <sys/mman.h>
#endif /* USE_POSIX_SHM */
#include <glib.h>
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
# ifdef STRICT
# undef STRICT
# endif
# define STRICT
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif
# define _WIN32_WINNT 0x0601
# include <windows.h>
# include <tlhelp32.h>
# undef RGB
# define USE_WIN32_SHM 1
#endif
#include "pika.h"
#include "pika-shm.h"
#define TILE_MAP_SIZE (pika_tile_width () * pika_tile_height () * 32)
#define ERRMSG_SHM_FAILED "Could not attach to pika shared memory segment"
#ifdef USE_WIN32_SHM
static HANDLE _shm_handle;
#endif
static gint _shm_ID = -1;
static guchar *_shm_addr = NULL;
guchar *
_pika_shm_addr (void)
{
return _shm_addr;
}
void
_pika_shm_open (gint shm_ID)
{
_shm_ID = shm_ID;
if (_shm_ID != -1)
{
#if defined(USE_SYSV_SHM)
/* Use SysV shared memory mechanisms for transferring tile data. */
_shm_addr = (guchar *) shmat (_shm_ID, NULL, 0);
if (_shm_addr == (guchar *) -1)
{
g_error ("shmat() failed: %s\n" ERRMSG_SHM_FAILED,
g_strerror (errno));
}
#elif defined(USE_WIN32_SHM)
/* Use Win32 shared memory mechanisms for transferring tile data. */
gchar fileMapName[128];
wchar_t *w_fileMapName;
/* From the id, derive the file map name */
g_snprintf (fileMapName, sizeof (fileMapName), "PIKA%d.SHM", _shm_ID);
w_fileMapName = g_utf8_to_utf16 (fileMapName, -1, NULL, NULL, NULL);
if (!w_fileMapName)
g_error ("Cannot convert to UTF16");
/* Open the file mapping */
_shm_handle = OpenFileMappingW (FILE_MAP_ALL_ACCESS, 0, w_fileMapName);
g_clear_pointer (&w_fileMapName, g_free);
if (_shm_handle)
{
/* Map the shared memory into our address space for use */
_shm_addr = (guchar *) MapViewOfFile (_shm_handle,
FILE_MAP_ALL_ACCESS,
0, 0, TILE_MAP_SIZE);
/* Verify that we mapped our view */
if (!_shm_addr)
{
g_error ("MapViewOfFile error: %lu... " ERRMSG_SHM_FAILED,
GetLastError ());
}
}
else
{
g_error ("OpenFileMapping error: %lu... " ERRMSG_SHM_FAILED,
GetLastError ());
}
#elif defined(USE_POSIX_SHM)
/* Use POSIX shared memory mechanisms for transferring tile data. */
gchar map_file[32];
gint shm_fd;
/* From the id, derive the file map name */
g_snprintf (map_file, sizeof (map_file), "/pika-shm-%d", _shm_ID);
/* Open the file mapping */
shm_fd = shm_open (map_file, O_RDWR, 0600);
if (shm_fd != -1)
{
/* Map the shared memory into our address space for use */
_shm_addr = (guchar *) mmap (NULL, TILE_MAP_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED,
shm_fd, 0);
/* Verify that we mapped our view */
if (_shm_addr == MAP_FAILED)
{
g_error ("mmap() failed: %s\n" ERRMSG_SHM_FAILED,
g_strerror (errno));
}
close (shm_fd);
}
else
{
g_error ("shm_open() failed: %s\n" ERRMSG_SHM_FAILED,
g_strerror (errno));
}
#endif
}
}
void
_pika_shm_close (void)
{
#if defined(USE_SYSV_SHM)
if ((_shm_ID != -1) && _shm_addr)
shmdt ((char *) _shm_addr);
#elif defined(USE_WIN32_SHM)
if (_shm_handle)
CloseHandle (_shm_handle);
#elif defined(USE_POSIX_SHM)
if ((_shm_ID != -1) && (_shm_addr != MAP_FAILED))
munmap (_shm_addr, TILE_MAP_SIZE);
#endif
}

35
libpika/pika-shm.h Normal file
View File

@ -0,0 +1,35 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika-shm.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_SHM_H__
#define __PIKA_SHM_H__
G_BEGIN_DECLS
guchar * _pika_shm_addr (void);
void _pika_shm_open (gint shm_ID);
void _pika_shm_close (void);
G_END_DECLS
#endif /* __PIKA_SHM_H__ */

1111
libpika/pika.c Normal file

File diff suppressed because it is too large Load Diff

921
libpika/pika.def Normal file
View File

@ -0,0 +1,921 @@
EXPORTS
pika_airbrush
pika_airbrush_default
pika_attach_parasite
pika_batch_procedure_get_interpreter_name
pika_batch_procedure_get_type
pika_batch_procedure_new
pika_batch_procedure_set_interpreter_name
pika_brush_application_mode_get_type
pika_brush_get_angle
pika_brush_get_aspect_ratio
pika_brush_get_by_name
pika_brush_get_hardness
pika_brush_get_info
pika_brush_get_pixels
pika_brush_get_radius
pika_brush_get_shape
pika_brush_get_spacing
pika_brush_get_spikes
pika_brush_get_type
pika_brush_is_generated
pika_brush_new
pika_brush_set_angle
pika_brush_set_aspect_ratio
pika_brush_set_hardness
pika_brush_set_radius
pika_brush_set_shape
pika_brush_set_spacing
pika_brush_set_spikes
pika_brushes_close_popup
pika_brushes_get_list
pika_brushes_popup
pika_brushes_refresh
pika_brushes_set_popup
pika_buffer_delete
pika_buffer_get_bytes
pika_buffer_get_height
pika_buffer_get_image_type
pika_buffer_get_width
pika_buffer_rename
pika_buffers_get_list
pika_channel_combine_masks
pika_channel_copy
pika_channel_get_by_id
pika_channel_get_color
pika_channel_get_opacity
pika_channel_get_show_masked
pika_channel_get_type
pika_channel_new
pika_channel_new_from_component
pika_channel_set_color
pika_channel_set_opacity
pika_channel_set_show_masked
pika_check_custom_color1
pika_check_custom_color2
pika_check_size
pika_check_type
pika_clone
pika_clone_default
pika_context_are_dynamics_enabled
pika_context_enable_dynamics
pika_context_get_antialias
pika_context_get_background
pika_context_get_brush
pika_context_get_brush_angle
pika_context_get_brush_aspect_ratio
pika_context_get_brush_force
pika_context_get_brush_hardness
pika_context_get_brush_size
pika_context_get_brush_spacing
pika_context_get_diagonal_neighbors
pika_context_get_distance_metric
pika_context_get_dynamics
pika_context_get_feather
pika_context_get_feather_radius
pika_context_get_font
pika_context_get_foreground
pika_context_get_gradient
pika_context_get_gradient_blend_color_space
pika_context_get_gradient_repeat_mode
pika_context_get_gradient_reverse
pika_context_get_ink_angle
pika_context_get_ink_blob_angle
pika_context_get_ink_blob_aspect_ratio
pika_context_get_ink_blob_type
pika_context_get_ink_size
pika_context_get_ink_size_sensitivity
pika_context_get_ink_speed_sensitivity
pika_context_get_ink_tilt_sensitivity
pika_context_get_interpolation
pika_context_get_line_cap_style
pika_context_get_line_dash_offset
pika_context_get_line_dash_pattern
pika_context_get_line_join_style
pika_context_get_line_miter_limit
pika_context_get_line_width
pika_context_get_line_width_unit
pika_context_get_mypaint_brush
pika_context_get_opacity
pika_context_get_paint_method
pika_context_get_paint_mode
pika_context_get_palette
pika_context_get_pattern
pika_context_get_sample_criterion
pika_context_get_sample_merged
pika_context_get_sample_threshold
pika_context_get_sample_threshold_int
pika_context_get_sample_transparent
pika_context_get_stroke_method
pika_context_get_transform_direction
pika_context_get_transform_resize
pika_context_list_paint_methods
pika_context_pop
pika_context_push
pika_context_set_antialias
pika_context_set_background
pika_context_set_brush
pika_context_set_brush_angle
pika_context_set_brush_aspect_ratio
pika_context_set_brush_default_hardness
pika_context_set_brush_default_size
pika_context_set_brush_default_spacing
pika_context_set_brush_force
pika_context_set_brush_hardness
pika_context_set_brush_size
pika_context_set_brush_spacing
pika_context_set_default_colors
pika_context_set_defaults
pika_context_set_diagonal_neighbors
pika_context_set_distance_metric
pika_context_set_dynamics
pika_context_set_feather
pika_context_set_feather_radius
pika_context_set_font
pika_context_set_foreground
pika_context_set_gradient
pika_context_set_gradient_blend_color_space
pika_context_set_gradient_fg_bg_hsv_ccw
pika_context_set_gradient_fg_bg_hsv_cw
pika_context_set_gradient_fg_bg_rgb
pika_context_set_gradient_fg_transparent
pika_context_set_gradient_repeat_mode
pika_context_set_gradient_reverse
pika_context_set_ink_angle
pika_context_set_ink_blob_angle
pika_context_set_ink_blob_aspect_ratio
pika_context_set_ink_blob_type
pika_context_set_ink_size
pika_context_set_ink_size_sensitivity
pika_context_set_ink_speed_sensitivity
pika_context_set_ink_tilt_sensitivity
pika_context_set_interpolation
pika_context_set_line_cap_style
pika_context_set_line_dash_offset
pika_context_set_line_dash_pattern
pika_context_set_line_join_style
pika_context_set_line_miter_limit
pika_context_set_line_width
pika_context_set_line_width_unit
pika_context_set_mypaint_brush
pika_context_set_opacity
pika_context_set_paint_method
pika_context_set_paint_mode
pika_context_set_palette
pika_context_set_pattern
pika_context_set_sample_criterion
pika_context_set_sample_merged
pika_context_set_sample_threshold
pika_context_set_sample_threshold_int
pika_context_set_sample_transparent
pika_context_set_stroke_method
pika_context_set_transform_direction
pika_context_set_transform_resize
pika_context_swap_colors
pika_convert_dither_type_get_type
pika_convolve
pika_convolve_default
pika_debug_timer_end
pika_debug_timer_start
pika_default_display
pika_detach_parasite
pika_display_delete
pika_display_get_by_id
pika_display_get_id
pika_display_get_type
pika_display_get_window_handle
pika_display_id_is_valid
pika_display_is_valid
pika_display_name
pika_display_new
pika_display_present
pika_displays_flush
pika_displays_reconnect
pika_dodgeburn
pika_dodgeburn_default
pika_drawable_brightness_contrast
pika_drawable_color_balance
pika_drawable_colorize_hsl
pika_drawable_curves_explicit
pika_drawable_curves_spline
pika_drawable_desaturate
pika_drawable_edit_bucket_fill
pika_drawable_edit_clear
pika_drawable_edit_fill
pika_drawable_edit_gradient_fill
pika_drawable_edit_stroke_item
pika_drawable_edit_stroke_selection
pika_drawable_equalize
pika_drawable_extract_component
pika_drawable_fill
pika_drawable_foreground_extract
pika_drawable_free_shadow
pika_drawable_get_bpp
pika_drawable_get_buffer
pika_drawable_get_by_id
pika_drawable_get_format
pika_drawable_get_height
pika_drawable_get_offsets
pika_drawable_get_shadow_buffer
pika_drawable_get_sub_thumbnail
pika_drawable_get_sub_thumbnail_data
pika_drawable_get_thumbnail
pika_drawable_get_thumbnail_data
pika_drawable_get_thumbnail_format
pika_drawable_get_type
pika_drawable_get_width
pika_drawable_has_alpha
pika_drawable_histogram
pika_drawable_hue_saturation
pika_drawable_invert
pika_drawable_is_gray
pika_drawable_is_indexed
pika_drawable_is_rgb
pika_drawable_levels
pika_drawable_levels_stretch
pika_drawable_mask_bounds
pika_drawable_mask_intersect
pika_drawable_merge_shadow
pika_drawable_offset
pika_drawable_posterize
pika_drawable_shadows_highlights
pika_drawable_threshold
pika_drawable_type
pika_drawable_type_with_alpha
pika_drawable_update
pika_dynamics_get_list
pika_dynamics_refresh
pika_edit_copy
pika_edit_copy_visible
pika_edit_cut
pika_edit_named_copy
pika_edit_named_copy_visible
pika_edit_named_cut
pika_edit_named_paste
pika_edit_named_paste_as_new_image
pika_edit_paste
pika_edit_paste_as_new_image
pika_enums_get_type_names
pika_enums_init
pika_eraser
pika_eraser_default
pika_export_color_profile
pika_export_comment
pika_export_exif
pika_export_iptc
pika_export_thumbnail
pika_export_xmp
pika_file_load
pika_file_load_layer
pika_file_load_layers
pika_file_procedure_get_extensions
pika_file_procedure_get_format_name
pika_file_procedure_get_handles_remote
pika_file_procedure_get_magics
pika_file_procedure_get_mime_types
pika_file_procedure_get_prefixes
pika_file_procedure_get_priority
pika_file_procedure_get_type
pika_file_procedure_set_extensions
pika_file_procedure_set_format_name
pika_file_procedure_set_handles_remote
pika_file_procedure_set_magics
pika_file_procedure_set_mime_types
pika_file_procedure_set_prefixes
pika_file_procedure_set_priority
pika_file_save
pika_file_save_thumbnail
pika_floating_sel_anchor
pika_floating_sel_attach
pika_floating_sel_remove
pika_floating_sel_to_layer
pika_font_get_by_name
pika_font_get_type
pika_fonts_close_popup
pika_fonts_get_list
pika_fonts_popup
pika_fonts_refresh
pika_fonts_set_popup
pika_get_color_configuration
pika_get_default_comment
pika_get_default_unit
pika_get_images
pika_get_module_load_inhibit
pika_get_monitor_resolution
pika_get_num_processors
pika_get_parasite
pika_get_parasite_list
pika_get_pdb
pika_get_plug_in
pika_get_progname
pika_getpid
pika_gradient_get_by_name
pika_gradient_get_custom_samples
pika_gradient_get_number_of_segments
pika_gradient_get_type
pika_gradient_get_uniform_samples
pika_gradient_new
pika_gradient_segment_get_blending_function
pika_gradient_segment_get_coloring_type
pika_gradient_segment_get_left_color
pika_gradient_segment_get_left_pos
pika_gradient_segment_get_middle_pos
pika_gradient_segment_get_right_color
pika_gradient_segment_get_right_pos
pika_gradient_segment_range_blend_colors
pika_gradient_segment_range_blend_opacity
pika_gradient_segment_range_delete
pika_gradient_segment_range_flip
pika_gradient_segment_range_move
pika_gradient_segment_range_redistribute_handles
pika_gradient_segment_range_replicate
pika_gradient_segment_range_set_blending_function
pika_gradient_segment_range_set_coloring_type
pika_gradient_segment_range_split_midpoint
pika_gradient_segment_range_split_uniform
pika_gradient_segment_set_left_color
pika_gradient_segment_set_left_pos
pika_gradient_segment_set_middle_pos
pika_gradient_segment_set_right_color
pika_gradient_segment_set_right_pos
pika_gradients_close_popup
pika_gradients_get_list
pika_gradients_popup
pika_gradients_refresh
pika_gradients_set_popup
pika_heal
pika_heal_default
pika_help
pika_histogram_channel_get_type
pika_icon_theme_dir
pika_image_add_hguide
pika_image_add_sample_point
pika_image_add_vguide
pika_image_attach_parasite
pika_image_clean_all
pika_image_convert_color_profile
pika_image_convert_color_profile_from_file
pika_image_convert_grayscale
pika_image_convert_indexed
pika_image_convert_precision
pika_image_convert_rgb
pika_image_convert_set_dither_matrix
pika_image_crop
pika_image_delete
pika_image_delete_guide
pika_image_delete_sample_point
pika_image_detach_parasite
pika_image_duplicate
pika_image_find_next_guide
pika_image_find_next_sample_point
pika_image_flatten
pika_image_flip
pika_image_floating_sel_attached_to
pika_image_freeze_channels
pika_image_freeze_layers
pika_image_freeze_vectors
pika_image_get_base_type
pika_image_get_by_id
pika_image_get_channel_by_name
pika_image_get_channel_by_tattoo
pika_image_get_channels
pika_image_get_color_profile
pika_image_get_colormap
pika_image_get_component_active
pika_image_get_component_visible
pika_image_get_default_new_layer_mode
pika_image_get_effective_color_profile
pika_image_get_exported_file
pika_image_get_file
pika_image_get_floating_sel
pika_image_get_guide_orientation
pika_image_get_guide_position
pika_image_get_height
pika_image_get_id
pika_image_get_imported_file
pika_image_get_item_position
pika_image_get_layer_by_name
pika_image_get_layer_by_tattoo
pika_image_get_layers
pika_image_get_metadata
pika_image_get_name
pika_image_get_parasite
pika_image_get_parasite_list
pika_image_get_precision
pika_image_get_resolution
pika_image_get_sample_point_position
pika_image_get_selected_channels
pika_image_get_selected_drawables
pika_image_get_selected_layers
pika_image_get_selected_vectors
pika_image_get_selection
pika_image_get_simulation_bpc
pika_image_get_simulation_intent
pika_image_get_simulation_profile
pika_image_get_tattoo_state
pika_image_get_thumbnail
pika_image_get_thumbnail_data
pika_image_get_type
pika_image_get_unit
pika_image_get_vectors
pika_image_get_vectors_by_name
pika_image_get_vectors_by_tattoo
pika_image_get_width
pika_image_get_xcf_file
pika_image_grid_get_background_color
pika_image_grid_get_foreground_color
pika_image_grid_get_offset
pika_image_grid_get_spacing
pika_image_grid_get_style
pika_image_grid_set_background_color
pika_image_grid_set_foreground_color
pika_image_grid_set_offset
pika_image_grid_set_spacing
pika_image_grid_set_style
pika_image_id_is_valid
pika_image_insert_channel
pika_image_insert_layer
pika_image_insert_vectors
pika_image_is_dirty
pika_image_is_valid
pika_image_list_channels
pika_image_list_layers
pika_image_list_selected_channels
pika_image_list_selected_drawables
pika_image_list_selected_layers
pika_image_list_selected_vectors
pika_image_list_vectors
pika_image_lower_item
pika_image_lower_item_to_bottom
pika_image_merge_down
pika_image_merge_layer_group
pika_image_merge_visible_layers
pika_image_metadata_load_finish
pika_image_metadata_load_prepare
pika_image_metadata_load_thumbnail
pika_image_metadata_save_filter
pika_image_metadata_save_finish
pika_image_metadata_save_prepare
pika_image_new
pika_image_new_with_precision
pika_image_pick_color
pika_image_pick_correlate_layer
pika_image_policy_color_profile
pika_image_policy_rotate
pika_image_procedure_get_type
pika_image_procedure_new
pika_image_raise_item
pika_image_raise_item_to_top
pika_image_remove_channel
pika_image_remove_layer
pika_image_remove_vectors
pika_image_reorder_item
pika_image_resize
pika_image_resize_to_layers
pika_image_rotate
pika_image_scale
pika_image_select_color
pika_image_select_contiguous_color
pika_image_select_ellipse
pika_image_select_item
pika_image_select_polygon
pika_image_select_rectangle
pika_image_select_round_rectangle
pika_image_set_color_profile
pika_image_set_color_profile_from_file
pika_image_set_colormap
pika_image_set_component_active
pika_image_set_component_visible
pika_image_set_file
pika_image_set_metadata
pika_image_set_resolution
pika_image_set_selected_channels
pika_image_set_selected_layers
pika_image_set_selected_vectors
pika_image_set_simulation_bpc
pika_image_set_simulation_intent
pika_image_set_simulation_profile
pika_image_set_simulation_profile_from_file
pika_image_set_tattoo_state
pika_image_set_unit
pika_image_take_selected_channels
pika_image_take_selected_layers
pika_image_take_selected_vectors
pika_image_thaw_channels
pika_image_thaw_layers
pika_image_thaw_vectors
pika_image_undo_disable
pika_image_undo_enable
pika_image_undo_freeze
pika_image_undo_group_end
pika_image_undo_group_start
pika_image_undo_is_enabled
pika_image_undo_thaw
pika_image_unset_active_channel
pika_item_attach_parasite
pika_item_delete
pika_item_detach_parasite
pika_item_get_by_id
pika_item_get_children
pika_item_get_color_tag
pika_item_get_expanded
pika_item_get_id
pika_item_get_image
pika_item_get_lock_content
pika_item_get_lock_position
pika_item_get_lock_visibility
pika_item_get_name
pika_item_get_parasite
pika_item_get_parasite_list
pika_item_get_parent
pika_item_get_tattoo
pika_item_get_type
pika_item_get_visible
pika_item_id_is_channel
pika_item_id_is_drawable
pika_item_id_is_layer
pika_item_id_is_layer_mask
pika_item_id_is_selection
pika_item_id_is_text_layer
pika_item_id_is_valid
pika_item_id_is_vectors
pika_item_is_channel
pika_item_is_drawable
pika_item_is_group
pika_item_is_layer
pika_item_is_layer_mask
pika_item_is_selection
pika_item_is_text_layer
pika_item_is_valid
pika_item_is_vectors
pika_item_list_children
pika_item_set_color_tag
pika_item_set_expanded
pika_item_set_lock_content
pika_item_set_lock_position
pika_item_set_lock_visibility
pika_item_set_name
pika_item_set_tattoo
pika_item_set_visible
pika_item_transform_2d
pika_item_transform_flip
pika_item_transform_flip_simple
pika_item_transform_matrix
pika_item_transform_perspective
pika_item_transform_rotate
pika_item_transform_rotate_simple
pika_item_transform_scale
pika_item_transform_shear
pika_item_transform_translate
pika_layer_add_alpha
pika_layer_add_mask
pika_layer_color_space_get_type
pika_layer_composite_mode_get_type
pika_layer_copy
pika_layer_create_mask
pika_layer_flatten
pika_layer_from_mask
pika_layer_get_apply_mask
pika_layer_get_blend_space
pika_layer_get_by_id
pika_layer_get_composite_mode
pika_layer_get_composite_space
pika_layer_get_edit_mask
pika_layer_get_lock_alpha
pika_layer_get_mask
pika_layer_get_mode
pika_layer_get_opacity
pika_layer_get_show_mask
pika_layer_get_type
pika_layer_group_new
pika_layer_is_floating_sel
pika_layer_mask_get_by_id
pika_layer_mask_get_type
pika_layer_mode_get_type
pika_layer_new
pika_layer_new_from_drawable
pika_layer_new_from_pixbuf
pika_layer_new_from_surface
pika_layer_new_from_visible
pika_layer_remove_mask
pika_layer_resize
pika_layer_resize_to_image_size
pika_layer_scale
pika_layer_set_apply_mask
pika_layer_set_blend_space
pika_layer_set_composite_mode
pika_layer_set_composite_space
pika_layer_set_edit_mask
pika_layer_set_lock_alpha
pika_layer_set_mode
pika_layer_set_offsets
pika_layer_set_opacity
pika_layer_set_show_mask
pika_list_images
pika_load_procedure_get_handles_raw
pika_load_procedure_get_thumbnail_loader
pika_load_procedure_get_type
pika_load_procedure_new
pika_load_procedure_set_handles_raw
pika_load_procedure_set_thumbnail_loader
pika_main
pika_message
pika_message_get_handler
pika_message_set_handler
pika_monitor_number
pika_paintbrush
pika_paintbrush_default
pika_palette_add_entry
pika_palette_delete_entry
pika_palette_entry_get_color
pika_palette_entry_get_name
pika_palette_entry_set_color
pika_palette_entry_set_name
pika_palette_get_by_name
pika_palette_get_color_count
pika_palette_get_colors
pika_palette_get_columns
pika_palette_get_type
pika_palette_new
pika_palette_set_columns
pika_palettes_close_popup
pika_palettes_get_list
pika_palettes_popup
pika_palettes_refresh
pika_palettes_set_popup
pika_param_brush_get_type
pika_param_channel_get_type
pika_param_display_get_type
pika_param_drawable_get_type
pika_param_font_get_type
pika_param_gradient_get_type
pika_param_image_get_type
pika_param_item_get_type
pika_param_layer_get_type
pika_param_layer_mask_get_type
pika_param_palette_get_type
pika_param_pattern_get_type
pika_param_resource_get_type
pika_param_selection_get_type
pika_param_spec_brush
pika_param_spec_channel
pika_param_spec_display
pika_param_spec_drawable
pika_param_spec_font
pika_param_spec_get_desc
pika_param_spec_gradient
pika_param_spec_image
pika_param_spec_item
pika_param_spec_layer
pika_param_spec_layer_mask
pika_param_spec_palette
pika_param_spec_pattern
pika_param_spec_resource
pika_param_spec_selection
pika_param_spec_text_layer
pika_param_spec_vectors
pika_param_text_layer_get_type
pika_param_vectors_get_type
pika_pattern_get_by_name
pika_pattern_get_info
pika_pattern_get_pixels
pika_pattern_get_type
pika_patterns_close_popup
pika_patterns_get_list
pika_patterns_popup
pika_patterns_refresh
pika_patterns_set_popup
pika_pdb_dump_to_file
pika_pdb_get_data
pika_pdb_get_data_size
pika_pdb_get_last_error
pika_pdb_get_last_status
pika_pdb_get_type
pika_pdb_lookup_procedure
pika_pdb_procedure_exists
pika_pdb_query_procedures
pika_pdb_run_procedure
pika_pdb_run_procedure_argv
pika_pdb_run_procedure_array
pika_pdb_run_procedure_config
pika_pdb_run_procedure_valist
pika_pdb_set_data
pika_pdb_temp_procedure_name
pika_pencil
pika_pikarc_query
pika_pikarc_set
pika_plug_in_add_menu_branch
pika_plug_in_add_temp_procedure
pika_plug_in_error_quark
pika_plug_in_extension_enable
pika_plug_in_extension_process
pika_plug_in_get_pdb_error_handler
pika_plug_in_get_temp_procedure
pika_plug_in_get_temp_procedures
pika_plug_in_get_type
pika_plug_in_remove_temp_procedure
pika_plug_in_set_help_domain
pika_plug_in_set_pdb_error_handler
pika_procedure_add_argument
pika_procedure_add_argument_from_property
pika_procedure_add_aux_argument
pika_procedure_add_aux_argument_from_property
pika_procedure_add_menu_path
pika_procedure_add_return_value
pika_procedure_add_return_value_from_property
pika_procedure_config_begin_export
pika_procedure_config_begin_run
pika_procedure_config_end_export
pika_procedure_config_end_run
pika_procedure_config_get_procedure
pika_procedure_config_get_type
pika_procedure_config_get_values
pika_procedure_config_has_default
pika_procedure_config_load_default
pika_procedure_config_load_last
pika_procedure_config_load_parasite
pika_procedure_config_save_default
pika_procedure_config_save_last
pika_procedure_config_save_metadata
pika_procedure_config_save_parasite
pika_procedure_config_set_values
pika_procedure_create_config
pika_procedure_extension_ready
pika_procedure_find_argument
pika_procedure_find_aux_argument
pika_procedure_find_return_value
pika_procedure_get_argument_sync
pika_procedure_get_arguments
pika_procedure_get_authors
pika_procedure_get_aux_arguments
pika_procedure_get_blurb
pika_procedure_get_copyright
pika_procedure_get_date
pika_procedure_get_help
pika_procedure_get_help_id
pika_procedure_get_icon_file
pika_procedure_get_icon_name
pika_procedure_get_icon_pixbuf
pika_procedure_get_icon_type
pika_procedure_get_image_types
pika_procedure_get_menu_label
pika_procedure_get_menu_paths
pika_procedure_get_name
pika_procedure_get_plug_in
pika_procedure_get_proc_type
pika_procedure_get_return_values
pika_procedure_get_sensitivity_mask
pika_procedure_get_type
pika_procedure_new
pika_procedure_new_arguments
pika_procedure_new_return_values
pika_procedure_run
pika_procedure_set_argument_sync
pika_procedure_set_attribution
pika_procedure_set_documentation
pika_procedure_set_icon_file
pika_procedure_set_icon_name
pika_procedure_set_icon_pixbuf
pika_procedure_set_image_types
pika_procedure_set_menu_label
pika_procedure_set_sensitivity_mask
pika_progress_cancel
pika_progress_end
pika_progress_get_window_handle
pika_progress_init
pika_progress_init_printf
pika_progress_install_vtable
pika_progress_pulse
pika_progress_set_text
pika_progress_set_text_printf
pika_progress_uninstall
pika_progress_update
pika_quit
pika_resource_delete
pika_resource_duplicate
pika_resource_get_by_id
pika_resource_get_by_name
pika_resource_get_id
pika_resource_get_name
pika_resource_get_type
pika_resource_id_is_brush
pika_resource_id_is_font
pika_resource_id_is_gradient
pika_resource_id_is_palette
pika_resource_id_is_pattern
pika_resource_id_is_valid
pika_resource_is_brush
pika_resource_is_editable
pika_resource_is_font
pika_resource_is_gradient
pika_resource_is_palette
pika_resource_is_pattern
pika_resource_is_valid
pika_resource_rename
pika_resource_select_destroy
pika_resource_select_new
pika_resource_select_set
pika_save_procedure_get_support_comment
pika_save_procedure_get_support_exif
pika_save_procedure_get_support_iptc
pika_save_procedure_get_support_profile
pika_save_procedure_get_support_thumbnail
pika_save_procedure_get_support_xmp
pika_save_procedure_get_type
pika_save_procedure_new
pika_save_procedure_set_support_comment
pika_save_procedure_set_support_exif
pika_save_procedure_set_support_iptc
pika_save_procedure_set_support_profile
pika_save_procedure_set_support_thumbnail
pika_save_procedure_set_support_xmp
pika_selection_all
pika_selection_border
pika_selection_bounds
pika_selection_feather
pika_selection_float
pika_selection_flood
pika_selection_get_by_id
pika_selection_get_type
pika_selection_grow
pika_selection_invert
pika_selection_is_empty
pika_selection_none
pika_selection_save
pika_selection_sharpen
pika_selection_shrink
pika_selection_translate
pika_selection_value
pika_show_help_button
pika_smudge
pika_smudge_default
pika_temp_file
pika_text_fontname
pika_text_get_extents_fontname
pika_text_layer_get_antialias
pika_text_layer_get_base_direction
pika_text_layer_get_by_id
pika_text_layer_get_color
pika_text_layer_get_font
pika_text_layer_get_font_size
pika_text_layer_get_hint_style
pika_text_layer_get_indent
pika_text_layer_get_justification
pika_text_layer_get_kerning
pika_text_layer_get_language
pika_text_layer_get_letter_spacing
pika_text_layer_get_line_spacing
pika_text_layer_get_markup
pika_text_layer_get_text
pika_text_layer_get_type
pika_text_layer_new
pika_text_layer_resize
pika_text_layer_set_antialias
pika_text_layer_set_base_direction
pika_text_layer_set_color
pika_text_layer_set_font
pika_text_layer_set_font_size
pika_text_layer_set_hint_style
pika_text_layer_set_indent
pika_text_layer_set_justification
pika_text_layer_set_kerning
pika_text_layer_set_language
pika_text_layer_set_letter_spacing
pika_text_layer_set_line_spacing
pika_text_layer_set_markup
pika_text_layer_set_text
pika_thumbnail_procedure_get_type
pika_thumbnail_procedure_new
pika_tile_height
pika_tile_width
pika_user_time
pika_vectors_bezier_stroke_conicto
pika_vectors_bezier_stroke_cubicto
pika_vectors_bezier_stroke_lineto
pika_vectors_bezier_stroke_new_ellipse
pika_vectors_bezier_stroke_new_moveto
pika_vectors_copy
pika_vectors_export_to_file
pika_vectors_export_to_string
pika_vectors_get_by_id
pika_vectors_get_strokes
pika_vectors_get_type
pika_vectors_import_from_file
pika_vectors_import_from_string
pika_vectors_new
pika_vectors_new_from_text_layer
pika_vectors_remove_stroke
pika_vectors_stroke_close
pika_vectors_stroke_flip
pika_vectors_stroke_flip_free
pika_vectors_stroke_get_length
pika_vectors_stroke_get_point_at_dist
pika_vectors_stroke_get_points
pika_vectors_stroke_interpolate
pika_vectors_stroke_new_from_points
pika_vectors_stroke_reverse
pika_vectors_stroke_rotate
pika_vectors_stroke_scale
pika_vectors_stroke_translate
pika_version
pika_wm_class

200
libpika/pika.h Normal file
View File

@ -0,0 +1,200 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pika.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_H__
#define __PIKA_H__
#include <cairo.h>
#include <glib-object.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libpikabase/pikabase.h>
#include <libpikacolor/pikacolor.h>
#include <libpikaconfig/pikaconfig.h>
#include <libpikamath/pikamath.h>
#define __PIKA_H_INSIDE__
#include <libpika/pikaenums.h>
#include <libpika/pikatypes.h>
#include <libpika/pikabatchprocedure.h>
#include <libpika/pikachannel.h>
#include <libpika/pikadisplay.h>
#include <libpika/pikadrawable.h>
#include <libpika/pikapikarc.h>
#include <libpika/pikaimage.h>
#include <libpika/pikaimagecolorprofile.h>
#include <libpika/pikaimagemetadata.h>
#include <libpika/pikaimageprocedure.h>
#include <libpika/pikaitem.h>
#include <libpika/pikalayer.h>
#include <libpika/pikalayermask.h>
#include <libpika/pikaloadprocedure.h>
#include <libpika/pikaparamspecs.h>
#include <libpika/pikapdb.h>
#include <libpika/pikaplugin.h>
#include <libpika/pikaprocedureconfig.h>
#include <libpika/pikaprocedure-params.h>
#include <libpika/pikaprogress.h>
#include <libpika/pikaresource.h>
#include <libpika/pikasaveprocedure.h>
#include <libpika/pikaselection.h>
#include <libpika/pikatextlayer.h>
#include <libpika/pikathumbnailprocedure.h>
#include <libpika/pikavectors.h>
/* Resources and their widgets. Order important. */
#include <libpika/pikaresourceselect.h>
#include <libpika/pika_pdb_headers.h>
#undef __PIKA_H_INSIDE__
#ifdef G_OS_WIN32
#include <stdlib.h> /* For __argc and __argv */
#endif
G_BEGIN_DECLS
#define pika_get_data pika_pdb_get_data
#define pika_get_data_size pika_pdb_get_data_size
#define pika_set_data pika_pdb_set_data
/**
* PIKA_MAIN:
* @plug_in_type: The #GType of the plug-in's #PikaPlugIn subclass
*
* A macro that expands to the appropriate main() function for the
* platform being compiled for.
*
* To use this macro, simply place a line that contains just the code
*
* PIKA_MAIN (MY_TYPE_PLUG_IN)
*
* at the toplevel of your file. No semicolon should be used.
*
* Since: 3.0
**/
#ifdef G_OS_WIN32
/* Define WinMain() because plug-ins are built as GUI applications. Also
* define a main() in case some plug-in still is built as a console
* application.
*/
# ifdef __GNUC__
# ifndef _stdcall
# define _stdcall __attribute__((stdcall))
# endif
# endif
# define PIKA_MAIN(plug_in_type) \
struct HINSTANCE__; \
\
int _stdcall \
WinMain (struct HINSTANCE__ *hInstance, \
struct HINSTANCE__ *hPrevInstance, \
char *lpszCmdLine, \
int nCmdShow); \
\
int _stdcall \
WinMain (struct HINSTANCE__ *hInstance, \
struct HINSTANCE__ *hPrevInstance, \
char *lpszCmdLine, \
int nCmdShow) \
{ \
return pika_main (plug_in_type, \
__argc, __argv); \
} \
\
int \
main (int argc, char *argv[]) \
{ \
/* Use __argc and __argv here, too, as they work \
* better with mingw-w64. \
*/ \
return pika_main (plug_in_type, \
__argc, __argv); \
}
#else
# define PIKA_MAIN(plug_in_type) \
int \
main (int argc, char *argv[]) \
{ \
return pika_main (plug_in_type, \
argc, argv); \
}
#endif
/* The main procedure that must be called with the plug-in's
* PikaPlugIn subclass type and the 'argc' and 'argv' that are passed
* to "main".
*/
gint pika_main (GType plug_in_type,
gint argc,
gchar *argv[]);
/* Return the PikaPlugIn singleton of this plug-in process
*/
PikaPlugIn * pika_get_plug_in (void);
/* Return the PikaPDB singleton of this plug-in process
*/
PikaPDB * pika_get_pdb (void);
/* Forcefully causes the pika library to exit and
* close down its connection to main pika application.
*/
void pika_quit (void) G_GNUC_NORETURN;
/* Return various constants given by the PIKA core at plug-in config time.
*/
guint pika_tile_width (void) G_GNUC_CONST;
guint pika_tile_height (void) G_GNUC_CONST;
gboolean pika_show_help_button (void) G_GNUC_CONST;
gboolean pika_export_color_profile (void) G_GNUC_CONST;
gboolean pika_export_comment (void) G_GNUC_CONST;
gboolean pika_export_exif (void) G_GNUC_CONST;
gboolean pika_export_xmp (void) G_GNUC_CONST;
gboolean pika_export_iptc (void) G_GNUC_CONST;
gboolean pika_export_thumbnail (void) G_GNUC_CONST;
gint pika_get_num_processors (void) G_GNUC_CONST;
PikaCheckSize pika_check_size (void) G_GNUC_CONST;
PikaCheckType pika_check_type (void) G_GNUC_CONST;
const PikaRGB * pika_check_custom_color1 (void) G_GNUC_CONST;
const PikaRGB * pika_check_custom_color2 (void) G_GNUC_CONST;
PikaDisplay * pika_default_display (void) G_GNUC_CONST;
const gchar * pika_wm_class (void) G_GNUC_CONST;
const gchar * pika_display_name (void) G_GNUC_CONST;
gint pika_monitor_number (void) G_GNUC_CONST;
guint32 pika_user_time (void) G_GNUC_CONST;
const gchar * pika_icon_theme_dir (void) G_GNUC_CONST;
const gchar * pika_get_progname (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __PIKA_H__ */

287
libpika/pika_pdb.c Normal file
View File

@ -0,0 +1,287 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pika_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pika
* @title: pika
* @short_description: Main functions needed for building a PIKA plug-in.
*
* Main functions needed for building a PIKA plug-in.
* This header includes all other PIKA Library headers.
*
* Also contains some miscellaneous procedures that don't fit in any
* other category.
**/
/**
* pika_version:
*
* Returns the host PIKA version.
*
* This procedure returns the version number of the currently running
* PIKA.
*
* Returns: (transfer full): PIKA version number.
* The returned value must be freed with g_free().
**/
gchar *
pika_version (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *version = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-version",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
version = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return version;
}
/**
* pika_getpid:
*
* Returns the PID of the host PIKA process.
*
* This procedure returns the process ID of the currently running PIKA.
*
* Returns: The PID.
*
* Since: 2.4
**/
gint
pika_getpid (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint pid = 0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-getpid",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
pid = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return pid;
}
/**
* pika_attach_parasite:
* @parasite: The parasite to attach.
*
* Add a global parasite.
*
* This procedure attaches a global parasite. It has no return values.
*
* Returns: TRUE on success.
*
* Since: 2.8
**/
gboolean
pika_attach_parasite (const PikaParasite *parasite)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_PARASITE, parasite,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-attach-parasite",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_detach_parasite:
* @name: The name of the parasite to detach.
*
* Removes a global parasite.
*
* This procedure detaches a global parasite from. It has no return
* values.
*
* Returns: TRUE on success.
*
* Since: 2.8
**/
gboolean
pika_detach_parasite (const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-detach-parasite",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_get_parasite:
* @name: The name of the parasite to find.
*
* Look up a global parasite.
*
* Finds and returns the global parasite that was previously attached.
*
* Returns: (transfer full): The found parasite.
*
* Since: 2.8
**/
PikaParasite *
pika_get_parasite (const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaParasite *parasite = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-get-parasite",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
parasite = PIKA_VALUES_DUP_PARASITE (return_vals, 1);
pika_value_array_unref (return_vals);
return parasite;
}
/**
* pika_get_parasite_list:
*
* List all parasites.
*
* Returns a list of all currently attached global parasites.
*
* Returns: (array zero-terminated=1) (transfer full):
* The names of currently attached parasites.
* The returned value must be freed with g_strfreev().
*
* Since: 2.8
**/
gchar **
pika_get_parasite_list (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **parasites = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-get-parasite-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
parasites = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return parasites;
}
/**
* pika_temp_file:
* @extension: The extension the file will have.
*
* Generates a unique temporary file.
*
* Generates a unique file using the temp path supplied in the user's
* pikarc.
*
* Returns: (transfer full): The new temp file.
**/
GFile *
pika_temp_file (const gchar *extension)
{
PikaValueArray *args;
PikaValueArray *return_vals;
GFile *file = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, extension,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-temp-file",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
file = PIKA_VALUES_DUP_FILE (return_vals, 1);
pika_value_array_unref (return_vals);
return file;
}

46
libpika/pika_pdb.h Normal file
View File

@ -0,0 +1,46 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pika_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_PIKA_PDB_H__
#define __PIKA_PIKA_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gchar* pika_version (void);
gint pika_getpid (void);
gboolean pika_attach_parasite (const PikaParasite *parasite);
gboolean pika_detach_parasite (const gchar *name);
PikaParasite* pika_get_parasite (const gchar *name);
gchar** pika_get_parasite_list (void);
GFile* pika_temp_file (const gchar *extension);
G_END_DECLS
#endif /* __PIKA_PIKA_PDB_H__ */

View File

@ -0,0 +1,81 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pika_pdb_headers.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_PDB_HEADERS_H__
#define __PIKA_PDB_HEADERS_H__
#include <libpika/pika_pdb.h>
#include <libpika/pikabrush_pdb.h>
#include <libpika/pikabrushes_pdb.h>
#include <libpika/pikabrushselect_pdb.h>
#include <libpika/pikabuffer_pdb.h>
#include <libpika/pikachannel_pdb.h>
#include <libpika/pikacontext_pdb.h>
#include <libpika/pikadebug_pdb.h>
#include <libpika/pikadisplay_pdb.h>
#include <libpika/pikadrawable_pdb.h>
#include <libpika/pikadrawablecolor_pdb.h>
#include <libpika/pikadrawableedit_pdb.h>
#include <libpika/pikadynamics_pdb.h>
#include <libpika/pikaedit_pdb.h>
#include <libpika/pikafile_pdb.h>
#include <libpika/pikafloatingsel_pdb.h>
#include <libpika/pikafont_pdb.h>
#include <libpika/pikafonts_pdb.h>
#include <libpika/pikafontselect_pdb.h>
#include <libpika/pikapikarc_pdb.h>
#include <libpika/pikagradient_pdb.h>
#include <libpika/pikagradients_pdb.h>
#include <libpika/pikagradientselect_pdb.h>
#include <libpika/pikahelp_pdb.h>
#include <libpika/pikaimage_pdb.h>
#include <libpika/pikaimagecolorprofile_pdb.h>
#include <libpika/pikaimageconvert_pdb.h>
#include <libpika/pikaimagegrid_pdb.h>
#include <libpika/pikaimageguides_pdb.h>
#include <libpika/pikaimagesamplepoints_pdb.h>
#include <libpika/pikaimageselect_pdb.h>
#include <libpika/pikaimagetransform_pdb.h>
#include <libpika/pikaimageundo_pdb.h>
#include <libpika/pikaitem_pdb.h>
#include <libpika/pikaitemtransform_pdb.h>
#include <libpika/pikalayer_pdb.h>
#include <libpika/pikamessage_pdb.h>
#include <libpika/pikapainttools_pdb.h>
#include <libpika/pikapalette_pdb.h>
#include <libpika/pikapalettes_pdb.h>
#include <libpika/pikapaletteselect_pdb.h>
#include <libpika/pikapattern_pdb.h>
#include <libpika/pikapatterns_pdb.h>
#include <libpika/pikapatternselect_pdb.h>
#include <libpika/pikaprogress_pdb.h>
#include <libpika/pikaresource_pdb.h>
#include <libpika/pikaselection_pdb.h>
#include <libpika/pikatextlayer_pdb.h>
#include <libpika/pikatexttool_pdb.h>
#include <libpika/pikavectors_pdb.h>
#endif /* __PIKA_PDB_HEADERS_H__ */

436
libpika/pikaaspectpreview.c Normal file
View File

@ -0,0 +1,436 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikaaspectpreview.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pikauitypes.h"
#include "pika.h"
#include "libpika-intl.h"
#include "pikaaspectpreview.h"
/**
* SECTION: pikaaspectpreview
* @title: PikaAspectPreview
* @short_description: A widget providing a preview with fixed aspect ratio.
*
* A widget providing a preview with fixed aspect ratio.
**/
enum
{
PROP_0,
PROP_DRAWABLE
};
struct _PikaAspectPreviewPrivate
{
PikaDrawable *drawable;
};
typedef struct
{
gboolean update;
} PreviewSettings;
#define GET_PRIVATE(obj) (((PikaAspectPreview *) (obj))->priv)
static void pika_aspect_preview_constructed (GObject *object);
static void pika_aspect_preview_dispose (GObject *object);
static void pika_aspect_preview_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void pika_aspect_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_aspect_preview_style_updated (GtkWidget *widget);
static void pika_aspect_preview_draw (PikaPreview *preview);
static void pika_aspect_preview_draw_buffer (PikaPreview *preview,
const guchar *buffer,
gint rowstride);
static void pika_aspect_preview_transform (PikaPreview *preview,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y);
static void pika_aspect_preview_untransform (PikaPreview *preview,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y);
static void pika_aspect_preview_set_drawable (PikaAspectPreview *preview,
PikaDrawable *drawable);
G_DEFINE_TYPE_WITH_PRIVATE (PikaAspectPreview, pika_aspect_preview,
PIKA_TYPE_PREVIEW)
#define parent_class pika_aspect_preview_parent_class
static gint pika_aspect_preview_counter = 0;
static void
pika_aspect_preview_class_init (PikaAspectPreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
PikaPreviewClass *preview_class = PIKA_PREVIEW_CLASS (klass);
object_class->constructed = pika_aspect_preview_constructed;
object_class->dispose = pika_aspect_preview_dispose;
object_class->get_property = pika_aspect_preview_get_property;
object_class->set_property = pika_aspect_preview_set_property;
widget_class->style_updated = pika_aspect_preview_style_updated;
preview_class->draw = pika_aspect_preview_draw;
preview_class->draw_buffer = pika_aspect_preview_draw_buffer;
preview_class->transform = pika_aspect_preview_transform;
preview_class->untransform = pika_aspect_preview_untransform;
/**
* PikaAspectPreview:drawable-id:
*
* The drawable the #PikaAspectPreview is attached to.
*
* Since: 2.10
*/
g_object_class_install_property (object_class, PROP_DRAWABLE,
g_param_spec_object ("drawable",
"Drawable",
"The drawable this preview is attached to",
PIKA_TYPE_DRAWABLE,
PIKA_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
pika_aspect_preview_init (PikaAspectPreview *preview)
{
preview->priv = pika_aspect_preview_get_instance_private (preview);
g_object_set (pika_preview_get_area (PIKA_PREVIEW (preview)),
"check-size", pika_check_size (),
"check-type", pika_check_type (),
"check-custom-color1", pika_check_custom_color1 (),
"check-custom-color2", pika_check_custom_color2 (),
NULL);
}
static void
pika_aspect_preview_constructed (GObject *object)
{
gchar *data_name;
PreviewSettings settings;
G_OBJECT_CLASS (parent_class)->constructed (object);
data_name = g_strdup_printf ("%s-aspect-preview-%d",
g_get_prgname (),
pika_aspect_preview_counter++);
if (pika_get_data (data_name, &settings))
{
pika_preview_set_update (PIKA_PREVIEW (object), settings.update);
}
g_object_set_data_full (object, "pika-aspect-preview-data-name",
data_name, (GDestroyNotify) g_free);
}
static void
pika_aspect_preview_dispose (GObject *object)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (object);
const gchar *data_name;
data_name = g_object_get_data (G_OBJECT (object),
"pika-aspect-preview-data-name");
if (data_name)
{
PikaPreview *preview = PIKA_PREVIEW (object);
PreviewSettings settings;
settings.update = pika_preview_get_update (preview);
pika_set_data (data_name, &settings, sizeof (PreviewSettings));
}
g_clear_object (&priv->drawable);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
pika_aspect_preview_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaAspectPreview *preview = PIKA_ASPECT_PREVIEW (object);
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
switch (property_id)
{
case PROP_DRAWABLE:
g_value_set_object (value, priv->drawable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_aspect_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaAspectPreview *preview = PIKA_ASPECT_PREVIEW (object);
switch (property_id)
{
case PROP_DRAWABLE:
pika_aspect_preview_set_drawable (preview, g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_aspect_preview_style_updated (GtkWidget *widget)
{
PikaPreview *preview = PIKA_PREVIEW (widget);
GtkWidget *area = pika_preview_get_area (preview);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (area)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
gint preview_width;
gint preview_height;
gint size;
width = pika_drawable_get_width (priv->drawable);
height = pika_drawable_get_height (priv->drawable);
gtk_widget_style_get (widget,
"size", &size,
NULL);
if (width > height)
{
preview_width = MIN (width, size);
preview_height = (height * preview_width) / width;
}
else
{
preview_height = MIN (height, size);
preview_width = (width * preview_height) / height;
}
pika_preview_set_size (preview, preview_width, preview_height);
}
}
static void
pika_aspect_preview_draw (PikaPreview *preview)
{
GtkWidget *area = pika_preview_get_area (preview);
gint width;
gint height;
pika_preview_get_size (preview, &width, &height);
pika_preview_area_fill (PIKA_PREVIEW_AREA (area),
0, 0,
width, height,
0, 0, 0);
}
static void
pika_aspect_preview_draw_buffer (PikaPreview *preview,
const guchar *buffer,
gint rowstride)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
GtkWidget *area = pika_preview_get_area (preview);
PikaImage *image;
gint width;
gint height;
pika_preview_get_size (preview, &width, &height);
image = pika_item_get_image (PIKA_ITEM (priv->drawable));
if (pika_selection_is_empty (image))
{
pika_preview_area_draw (PIKA_PREVIEW_AREA (area),
0, 0,
width, height,
pika_drawable_type (priv->drawable),
buffer,
rowstride);
}
else
{
GBytes *sel;
GBytes *src;
PikaSelection *selection;
gint w, h;
gint bpp;
selection = pika_image_get_selection (image);
src = pika_drawable_get_thumbnail_data (priv->drawable,
width, height,
&w, &h, &bpp);
sel = pika_drawable_get_thumbnail_data (PIKA_DRAWABLE (selection),
width, height,
&w, &h, &bpp);
pika_preview_area_mask (PIKA_PREVIEW_AREA (area),
0, 0, width, height,
pika_drawable_type (priv->drawable),
g_bytes_get_data (src, NULL),
width * pika_drawable_get_bpp (priv->drawable),
buffer, rowstride,
g_bytes_get_data (sel, NULL), width);
g_bytes_unref (sel);
g_bytes_unref (src);
}
}
static void
pika_aspect_preview_transform (PikaPreview *preview,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
pika_preview_get_size (preview, &width, &height);
*dest_x = (gdouble) src_x * width / pika_drawable_get_width (priv->drawable);
*dest_y = (gdouble) src_y * height / pika_drawable_get_height (priv->drawable);
}
static void
pika_aspect_preview_untransform (PikaPreview *preview,
gint src_x,
gint src_y,
gint *dest_x,
gint *dest_y)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint width;
gint height;
pika_preview_get_size (preview, &width, &height);
*dest_x = (gdouble) src_x * pika_drawable_get_width (priv->drawable) / width;
*dest_y = (gdouble) src_y * pika_drawable_get_height (priv->drawable) / height;
}
static void
pika_aspect_preview_set_drawable (PikaAspectPreview *preview,
PikaDrawable *drawable)
{
PikaAspectPreviewPrivate *priv = GET_PRIVATE (preview);
gint d_width;
gint d_height;
gint width;
gint height;
g_return_if_fail (priv->drawable == NULL);
priv->drawable = drawable;
d_width = pika_drawable_get_width (priv->drawable);
d_height = pika_drawable_get_height (priv->drawable);
if (d_width > d_height)
{
width = MIN (d_width, 512);
height = (d_height * width) / d_width;
}
else
{
height = MIN (d_height, 512);
width = (d_width * height) / d_height;
}
pika_preview_set_bounds (PIKA_PREVIEW (preview), 0, 0, width, height);
if (height > 0)
g_object_set (pika_preview_get_frame (PIKA_PREVIEW (preview)),
"ratio",
(gdouble) d_width / (gdouble) d_height,
NULL);
}
/**
* pika_aspect_preview_new_from_drawable:
* @drawable: (transfer none): a drawable
*
* Creates a new #PikaAspectPreview widget for @drawable_. See also
* pika_drawable_preview_new_from_drawable().
*
* Since: 2.10
*
* Returns: a new #PikaAspectPreview.
**/
GtkWidget *
pika_aspect_preview_new_from_drawable (PikaDrawable *drawable)
{
g_return_val_if_fail (PIKA_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (pika_item_is_valid (PIKA_ITEM (drawable)), NULL);
return g_object_new (PIKA_TYPE_ASPECT_PREVIEW,
"drawable", drawable,
NULL);
}

View File

@ -0,0 +1,75 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikaaspectpreview.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_ASPECT_PREVIEW_H__
#define __PIKA_ASPECT_PREVIEW_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define PIKA_TYPE_ASPECT_PREVIEW (pika_aspect_preview_get_type ())
#define PIKA_ASPECT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_ASPECT_PREVIEW, PikaAspectPreview))
#define PIKA_ASPECT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_ASPECT_PREVIEW, PikaAspectPreviewClass))
#define PIKA_IS_ASPECT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_ASPECT_PREVIEW))
#define PIKA_IS_ASPECT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_ASPECT_PREVIEW))
#define PIKA_ASPECT_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_ASPECT_PREVIEW, PikaAspectPreviewClass))
typedef struct _PikaAspectPreviewPrivate PikaAspectPreviewPrivate;
typedef struct _PikaAspectPreviewClass PikaAspectPreviewClass;
struct _PikaAspectPreview
{
PikaPreview parent_instance;
PikaAspectPreviewPrivate *priv;
};
struct _PikaAspectPreviewClass
{
PikaPreviewClass parent_class;
/* Padding for future expansion */
void (* _pika_reserved1) (void);
void (* _pika_reserved2) (void);
void (* _pika_reserved3) (void);
void (* _pika_reserved4) (void);
void (* _pika_reserved5) (void);
void (* _pika_reserved6) (void);
void (* _pika_reserved7) (void);
void (* _pika_reserved8) (void);
};
GType pika_aspect_preview_get_type (void) G_GNUC_CONST;
GtkWidget * pika_aspect_preview_new_from_drawable (PikaDrawable *drawable);
G_END_DECLS
#endif /* __PIKA_ASPECT_PREVIEW_H__ */

View File

@ -0,0 +1,303 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* pikabatchprocedure.c
* Copyright (C) 2022 Jehan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
#include "pikabatchprocedure.h"
#include "pikapdb_pdb.h"
struct _PikaBatchProcedurePrivate
{
gchar *interpreter_name;
PikaBatchFunc run_func;
gpointer run_data;
GDestroyNotify run_data_destroy;
};
static void pika_batch_procedure_constructed (GObject *object);
static void pika_batch_procedure_finalize (GObject *object);
static void pika_batch_procedure_install (PikaProcedure *procedure);
static PikaValueArray *
pika_batch_procedure_run (PikaProcedure *procedure,
const PikaValueArray *args);
static PikaProcedureConfig *
pika_batch_procedure_create_config (PikaProcedure *procedure,
GParamSpec **args,
gint n_args);
G_DEFINE_TYPE_WITH_PRIVATE (PikaBatchProcedure, pika_batch_procedure,
PIKA_TYPE_PROCEDURE)
#define parent_class pika_batch_procedure_parent_class
static void
pika_batch_procedure_class_init (PikaBatchProcedureClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
PikaProcedureClass *procedure_class = PIKA_PROCEDURE_CLASS (klass);
object_class->constructed = pika_batch_procedure_constructed;
object_class->finalize = pika_batch_procedure_finalize;
procedure_class->install = pika_batch_procedure_install;
procedure_class->run = pika_batch_procedure_run;
procedure_class->create_config = pika_batch_procedure_create_config;
}
static void
pika_batch_procedure_init (PikaBatchProcedure *procedure)
{
procedure->priv = pika_batch_procedure_get_instance_private (procedure);
}
static void
pika_batch_procedure_constructed (GObject *object)
{
PikaProcedure *procedure = PIKA_PROCEDURE (object);
G_OBJECT_CLASS (parent_class)->constructed (object);
PIKA_PROC_ARG_ENUM (procedure, "run-mode",
"Run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_NONINTERACTIVE,
G_PARAM_READWRITE);
PIKA_PROC_ARG_STRING (procedure, "script",
"Batch commands in the target language",
"Batch commands in the target language, which will be run by the interpreter",
"",
G_PARAM_READWRITE);
}
static void
pika_batch_procedure_finalize (GObject *object)
{
PikaBatchProcedure *procedure = PIKA_BATCH_PROCEDURE (object);
g_clear_pointer (&procedure->priv->interpreter_name, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_batch_procedure_install (PikaProcedure *procedure)
{
PikaBatchProcedure *proc = PIKA_BATCH_PROCEDURE (procedure);
g_return_if_fail (proc->priv->interpreter_name != NULL);
PIKA_PROCEDURE_CLASS (parent_class)->install (procedure);
_pika_pdb_set_batch_interpreter (pika_procedure_get_name (procedure),
proc->priv->interpreter_name);
}
#define ARG_OFFSET 2
static PikaValueArray *
pika_batch_procedure_run (PikaProcedure *procedure,
const PikaValueArray *args)
{
PikaBatchProcedure *batch_proc = PIKA_BATCH_PROCEDURE (procedure);
PikaValueArray *remaining;
PikaValueArray *return_values;
PikaRunMode run_mode;
const gchar *cmd;
gint i;
run_mode = PIKA_VALUES_GET_ENUM (args, 0);
cmd = PIKA_VALUES_GET_STRING (args, 1);
remaining = pika_value_array_new (pika_value_array_length (args) - ARG_OFFSET);
for (i = ARG_OFFSET; i < pika_value_array_length (args); i++)
{
GValue *value = pika_value_array_index (args, i);
pika_value_array_append (remaining, value);
}
return_values = batch_proc->priv->run_func (procedure,
run_mode,
cmd,
remaining,
batch_proc->priv->run_data);
pika_value_array_unref (remaining);
return return_values;
}
static PikaProcedureConfig *
pika_batch_procedure_create_config (PikaProcedure *procedure,
GParamSpec **args,
gint n_args)
{
if (n_args > ARG_OFFSET)
{
args += ARG_OFFSET;
n_args -= ARG_OFFSET;
}
else
{
args = NULL;
n_args = 0;
}
return PIKA_PROCEDURE_CLASS (parent_class)->create_config (procedure,
args,
n_args);
}
/* public functions */
/**
* pika_batch_procedure_new:
* @plug_in: a #PikaPlugIn.
* @name: the new procedure's name.
* @interpreter_name: the public-facing name, e.g. "Python 3".
* @proc_type: the new procedure's #PikaPDBProcType.
* @run_func: the run function for the new procedure.
* @run_data: user data passed to @run_func.
* @run_data_destroy: (nullable): free function for @run_data, or %NULL.
*
* Creates a new batch interpreter procedure named @name which will call
* @run_func when invoked.
*
* See pika_procedure_new() for information about @proc_type.
*
* #PikaBatchProcedure is a #PikaProcedure subclass that makes it easier
* to write batch interpreter procedures.
*
* It automatically adds the standard
*
* (#PikaRunMode, #gchar)
*
* arguments of a batch procedure. It is possible to add additional
* arguments.
*
* When invoked via pika_procedure_run(), it unpacks these standard
* arguments and calls @run_func which is a #PikaBatchFunc. The "args"
* #PikaValueArray of #PikaRunSaveFunc only contains additionally added
* arguments.
*
* Returns: a new #PikaProcedure.
*
* Since: 3.0
**/
PikaProcedure *
pika_batch_procedure_new (PikaPlugIn *plug_in,
const gchar *name,
const gchar *interpreter_name,
PikaPDBProcType proc_type,
PikaBatchFunc run_func,
gpointer run_data,
GDestroyNotify run_data_destroy)
{
PikaBatchProcedure *procedure;
g_return_val_if_fail (PIKA_IS_PLUG_IN (plug_in), NULL);
g_return_val_if_fail (pika_is_canonical_identifier (name), NULL);
g_return_val_if_fail (interpreter_name != NULL && g_utf8_validate (interpreter_name, -1, NULL), NULL);
g_return_val_if_fail (proc_type != PIKA_PDB_PROC_TYPE_INTERNAL, NULL);
g_return_val_if_fail (proc_type != PIKA_PDB_PROC_TYPE_EXTENSION, NULL);
g_return_val_if_fail (run_func != NULL, NULL);
procedure = g_object_new (PIKA_TYPE_BATCH_PROCEDURE,
"plug-in", plug_in,
"name", name,
"procedure-type", proc_type,
NULL);
procedure->priv->run_func = run_func;
procedure->priv->run_data = run_data;
procedure->priv->run_data_destroy = run_data_destroy;
pika_batch_procedure_set_interpreter_name (procedure, interpreter_name);
return PIKA_PROCEDURE (procedure);
}
/**
* pika_batch_procedure_set_interpreter_name:
* @procedure: A batch procedure.
* @interpreter_name: A public-facing name for the interpreter, e.g. "Python 3".
*
* Associates an interpreter name with a batch procedure.
*
* This name can be used for any public-facing strings, such as
* graphical interface labels or command line usage. E.g. the command
* line interface could list all available interface, displaying both a
* procedure name and a "pretty printing" title.
*
* Note that since the format name is public-facing, it is recommended
* to localize it at runtime, for instance through gettext, like:
*
* ```c
* pika_batch_procedure_set_interpreter_name (procedure, _("Python 3"));
* ```
*
* Some language would indeed localize even some technical terms or
* acronyms, even if sometimes just to rewrite them with the local
* writing system.
*
* Since: 3.0
**/
void
pika_batch_procedure_set_interpreter_name (PikaBatchProcedure *procedure,
const gchar *interpreter_name)
{
g_return_if_fail (PIKA_IS_BATCH_PROCEDURE (procedure));
g_return_if_fail (interpreter_name != NULL && g_utf8_validate (interpreter_name, -1, NULL));
g_free (procedure->priv->interpreter_name);
procedure->priv->interpreter_name = g_strdup (interpreter_name);
}
/**
* pika_batch_procedure_get_interpreter_name:
* @procedure: A batch procedure object.
*
* Returns the procedure's interpreter name, as set with
* [method@BatchProcedure.set_interpreter_name].
*
* Returns: The procedure's interpreter name.
*
* Since: 3.0
**/
const gchar *
pika_batch_procedure_get_interpreter_name (PikaBatchProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_BATCH_PROCEDURE (procedure), NULL);
return procedure->priv->interpreter_name;
}

View File

@ -0,0 +1,98 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* pikabatchprocedure.h
* Copyright (C) 2022 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_BATCH_PROCEDURE_H__
#define __PIKA_BATCH_PROCEDURE_H__
#include <libpika/pikaprocedure.h>
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
/**
* PikaBatchFunc:
* @procedure: the #PikaProcedure that runs.
* @run_mode: the #PikaRunMode.
* @args: the @procedure's remaining arguments.
* @run_data: (closure): the run_data given in pika_batch_procedure_new().
*
* The batch function is run during the lifetime of the PIKA session,
* each time a plug-in batch procedure is called.
*
* Returns: (transfer full): the @procedure's return values.
*
* Since: 3.0
**/
typedef PikaValueArray * (* PikaBatchFunc) (PikaProcedure *procedure,
PikaRunMode run_mode,
const gchar *command,
const PikaValueArray *args,
gpointer run_data);
#define PIKA_TYPE_BATCH_PROCEDURE (pika_batch_procedure_get_type ())
#define PIKA_BATCH_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_BATCH_PROCEDURE, PikaBatchProcedure))
#define PIKA_BATCH_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_BATCH_PROCEDURE, PikaBatchProcedureClass))
#define PIKA_IS_BATCH_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_BATCH_PROCEDURE))
#define PIKA_IS_BATCH_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_BATCH_PROCEDURE))
#define PIKA_BATCH_PROCEDURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_BATCH_PROCEDURE, PikaBatchProcedureClass))
typedef struct _PikaBatchProcedure PikaBatchProcedure;
typedef struct _PikaBatchProcedureClass PikaBatchProcedureClass;
typedef struct _PikaBatchProcedurePrivate PikaBatchProcedurePrivate;
struct _PikaBatchProcedure
{
PikaProcedure parent_instance;
PikaBatchProcedurePrivate *priv;
};
struct _PikaBatchProcedureClass
{
PikaProcedureClass parent_class;
};
GType pika_batch_procedure_get_type (void) G_GNUC_CONST;
PikaProcedure * pika_batch_procedure_new (PikaPlugIn *plug_in,
const gchar *name,
const gchar *interpreter_name,
PikaPDBProcType proc_type,
PikaBatchFunc run_func,
gpointer run_data,
GDestroyNotify run_data_destroy);
void pika_batch_procedure_set_interpreter_name (PikaBatchProcedure *procedure,
const gchar *interpreter_name);
const gchar * pika_batch_procedure_get_interpreter_name (PikaBatchProcedure *procedure);
G_END_DECLS
#endif /* __PIKA_BATCH_PROCEDURE_H__ */

897
libpika/pikabrush_pdb.c Normal file
View File

@ -0,0 +1,897 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrush_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikabrush
* @title: pikabrush
* @short_description: Installable object used by painting and stroking tools.
*
* Installable object used by painting and stroking tools.
**/
/**
* pika_brush_new:
* @name: The requested name of the new brush.
*
* Create a new generated brush having default parameters.
*
* Creates a new, parametric brush.
*
* Returns: (transfer none): The brush.
*
* Since: 2.2
**/
PikaBrush *
pika_brush_new (const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaBrush *brush = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-new",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
brush = PIKA_VALUES_GET_BRUSH (return_vals, 1);
pika_value_array_unref (return_vals);
return brush;
}
/**
* pika_brush_get_by_name:
* @name: The name of the brush.
*
* Returns the brush with the given name.
*
* Search and return an existing brush with the name in argument, or
* nothing if no brush has this name.
*
* Returns: (transfer none): The brush.
*
* Since: 3.0
**/
PikaBrush *
pika_brush_get_by_name (const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaBrush *brush = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-by-name",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
brush = PIKA_VALUES_GET_BRUSH (return_vals, 1);
pika_value_array_unref (return_vals);
return brush;
}
/**
* pika_brush_is_generated:
* @brush: The brush.
*
* Whether the brush is generated (parametric versus raster).
*
* Returns TRUE when brush is parametric.
*
* Returns: TRUE if the brush is generated.
*
* Since: 2.4
**/
gboolean
pika_brush_is_generated (PikaBrush *brush)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean generated = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-is-generated",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
generated = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return generated;
}
/**
* pika_brush_get_info:
* @brush: The brush.
* @width: (out): The brush width.
* @height: (out): The brush height.
* @mask_bpp: (out): The brush mask bpp.
* @color_bpp: (out): The brush color bpp.
*
* Gets information about the brush.
*
* Gets information about the brush: brush extents (width and height),
* color depth and mask depth (bpp). The color bpp is zero when the
* brush is parametric versus raster.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
pika_brush_get_info (PikaBrush *brush,
gint *width,
gint *height,
gint *mask_bpp,
gint *color_bpp)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-info",
args);
pika_value_array_unref (args);
*width = 0;
*height = 0;
*mask_bpp = 0;
*color_bpp = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*width = PIKA_VALUES_GET_INT (return_vals, 1);
*height = PIKA_VALUES_GET_INT (return_vals, 2);
*mask_bpp = PIKA_VALUES_GET_INT (return_vals, 3);
*color_bpp = PIKA_VALUES_GET_INT (return_vals, 4);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_pixels:
* @brush: The brush.
* @width: (out): The brush width.
* @height: (out): The brush height.
* @mask_bpp: (out): The brush mask bpp.
* @mask_bytes: (out) (transfer full): The brush mask data.
* @color_bpp: (out): The brush color bpp.
* @color_bytes: (out) (transfer full): The brush color data.
*
* Gets information about the brush.
*
* Gets information about the brush: the brush extents (width and
* height) and its pixels data. The color bpp is zero and pixels empty
* when the brush is parametric versus raster.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
pika_brush_get_pixels (PikaBrush *brush,
gint *width,
gint *height,
gint *mask_bpp,
GBytes **mask_bytes,
gint *color_bpp,
GBytes **color_bytes)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-pixels",
args);
pika_value_array_unref (args);
*width = 0;
*height = 0;
*mask_bpp = 0;
*mask_bytes = NULL;
*color_bpp = 0;
*color_bytes = NULL;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*width = PIKA_VALUES_GET_INT (return_vals, 1);
*height = PIKA_VALUES_GET_INT (return_vals, 2);
*mask_bpp = PIKA_VALUES_GET_INT (return_vals, 3);
*mask_bytes = PIKA_VALUES_DUP_BYTES (return_vals, 4);
*color_bpp = PIKA_VALUES_GET_INT (return_vals, 5);
*color_bytes = PIKA_VALUES_DUP_BYTES (return_vals, 6);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_spacing:
* @brush: The brush.
*
* Gets the brush spacing, the stamping frequency.
*
* Returns the spacing setting for the brush. Spacing is an integer
* between 0 and 1000 which represents a percentage of the maximum of
* the width and height of the mask. Both parametric and raster brushes
* have a spacing.
*
* Returns: The brush spacing.
*
* Since: 2.2
**/
gint
pika_brush_get_spacing (PikaBrush *brush)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint spacing = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-spacing",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
spacing = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return spacing;
}
/**
* pika_brush_set_spacing:
* @brush: The brush.
* @spacing: The brush spacing.
*
* Sets the brush spacing.
*
* Set the spacing for the brush. The spacing must be an integer
* between 0 and 1000. Both parametric and raster brushes have a
* spacing. Returns an error when the brush is not editable. Create a
* new or copied brush or to get an editable brush.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_spacing (PikaBrush *brush,
gint spacing)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_INT, spacing,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-spacing",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_shape:
* @brush: The brush.
* @shape: (out): The brush shape.
*
* Gets the shape of a generated brush.
*
* Gets the shape of a generated brush. Returns an error when called
* for a non-parametric brush. The choices for shape are Circle
* (PIKA_BRUSH_GENERATED_CIRCLE), Square (PIKA_BRUSH_GENERATED_SQUARE),
* and Diamond (PIKA_BRUSH_GENERATED_DIAMOND). Other shapes might be
* added in the future.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_shape (PikaBrush *brush,
PikaBrushGeneratedShape *shape)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-shape",
args);
pika_value_array_unref (args);
*shape = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*shape = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_shape:
* @brush: The brush.
* @shape_in: The brush shape.
* @shape_out: (out): The brush shape actually assigned.
*
* Sets the shape of a generated brush.
*
* Sets the shape of a generated brush. Returns an error when brush is
* non-parametric or not editable. The choices for shape are Circle
* (PIKA_BRUSH_GENERATED_CIRCLE), Square (PIKA_BRUSH_GENERATED_SQUARE),
* and Diamond (PIKA_BRUSH_GENERATED_DIAMOND).
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_shape (PikaBrush *brush,
PikaBrushGeneratedShape shape_in,
PikaBrushGeneratedShape *shape_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
PIKA_TYPE_BRUSH_GENERATED_SHAPE, shape_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-shape",
args);
pika_value_array_unref (args);
*shape_out = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*shape_out = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_radius:
* @brush: The brush.
* @radius: (out): The radius of the brush in pixels.
*
* Gets the radius of a generated brush.
*
* Gets the radius of a generated brush. Returns an error when called
* for a non-parametric brush.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_radius (PikaBrush *brush,
gdouble *radius)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-radius",
args);
pika_value_array_unref (args);
*radius = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*radius = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_radius:
* @brush: The brush.
* @radius_in: The desired brush radius in pixel.
* @radius_out: (out): The brush radius actually assigned.
*
* Sets the radius of a generated brush.
*
* Sets the radius for a generated brush. Clamps radius to [0.0,
* 32767.0]. Returns the clamped value. Returns an error when brush is
* non-parametric or not editable.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_radius (PikaBrush *brush,
gdouble radius_in,
gdouble *radius_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_DOUBLE, radius_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-radius",
args);
pika_value_array_unref (args);
*radius_out = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*radius_out = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_spikes:
* @brush: The brush.
* @spikes: (out): The number of spikes on the brush.
*
* Gets the number of spikes for a generated brush.
*
* Gets the number of spikes for a generated brush. Returns an error
* when called for a non-parametric brush.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_spikes (PikaBrush *brush,
gint *spikes)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-spikes",
args);
pika_value_array_unref (args);
*spikes = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*spikes = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_spikes:
* @brush: The brush.
* @spikes_in: The desired number of spikes.
* @spikes_out: (out): The number of spikes actually assigned.
*
* Sets the number of spikes for a generated brush.
*
* Sets the number of spikes for a generated brush. Clamps spikes to
* [2,20]. Returns the clamped value. Returns an error when brush is
* non-parametric or not editable.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_spikes (PikaBrush *brush,
gint spikes_in,
gint *spikes_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_INT, spikes_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-spikes",
args);
pika_value_array_unref (args);
*spikes_out = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*spikes_out = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_hardness:
* @brush: The brush.
* @hardness: (out): The hardness of the brush.
*
* Gets the hardness of a generated brush.
*
* Gets the hardness of a generated brush. The hardness of a brush is
* the amount its intensity fades at the outside edge, as a float
* between 0.0 and 1.0. Returns an error when called for a
* non-parametric brush.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_hardness (PikaBrush *brush,
gdouble *hardness)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-hardness",
args);
pika_value_array_unref (args);
*hardness = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*hardness = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_hardness:
* @brush: The brush.
* @hardness_in: The desired brush hardness.
* @hardness_out: (out): The brush hardness actually assigned.
*
* Sets the hardness of a generated brush.
*
* Sets the hardness for a generated brush. Clamps hardness to [0.0,
* 1.0]. Returns the clamped value. Returns an error when brush is
* non-parametric or not editable.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_hardness (PikaBrush *brush,
gdouble hardness_in,
gdouble *hardness_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_DOUBLE, hardness_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-hardness",
args);
pika_value_array_unref (args);
*hardness_out = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*hardness_out = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_aspect_ratio:
* @brush: The brush.
* @aspect_ratio: (out): The aspect ratio of the brush.
*
* Gets the aspect ratio of a generated brush.
*
* Gets the aspect ratio of a generated brush. Returns an error when
* called for a non-parametric brush. The aspect ratio is a float
* between 0.0 and 1000.0.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_aspect_ratio (PikaBrush *brush,
gdouble *aspect_ratio)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-aspect-ratio",
args);
pika_value_array_unref (args);
*aspect_ratio = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*aspect_ratio = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_aspect_ratio:
* @brush: The brush.
* @aspect_ratio_in: The desired brush aspect ratio.
* @aspect_ratio_out: (out): The brush aspect ratio actually assigned.
*
* Sets the aspect ratio of a generated brush.
*
* Sets the aspect ratio for a generated brush. Clamps aspect ratio to
* [0.0, 1000.0]. Returns the clamped value. Returns an error when
* brush is non-parametric or not editable.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_aspect_ratio (PikaBrush *brush,
gdouble aspect_ratio_in,
gdouble *aspect_ratio_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_DOUBLE, aspect_ratio_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-aspect-ratio",
args);
pika_value_array_unref (args);
*aspect_ratio_out = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*aspect_ratio_out = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_get_angle:
* @brush: The brush.
* @angle: (out): The rotation angle of the brush in degree.
*
* Gets the rotation angle of a generated brush.
*
* Gets the angle of rotation for a generated brush. Returns an error
* when called for a non-parametric brush.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_get_angle (PikaBrush *brush,
gdouble *angle)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-get-angle",
args);
pika_value_array_unref (args);
*angle = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*angle = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brush_set_angle:
* @brush: The brush.
* @angle_in: The desired brush rotation angle in degrees.
* @angle_out: (out): The brush rotation angle actually assigned.
*
* Sets the rotation angle of a generated brush.
*
* Sets the rotation angle for a generated brush. Sets the angle modulo
* 180, in the range [-180.0, 180.0]. Returns the clamped value.
* Returns an error when brush is non-parametric or not editable.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_brush_set_angle (PikaBrush *brush,
gdouble angle_in,
gdouble *angle_out)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_BRUSH, brush,
G_TYPE_DOUBLE, angle_in,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brush-set-angle",
args);
pika_value_array_unref (args);
*angle_out = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
*angle_out = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return success;
}

87
libpika/pikabrush_pdb.h Normal file
View File

@ -0,0 +1,87 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrush_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_BRUSH_PDB_H__
#define __PIKA_BRUSH_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
PikaBrush* pika_brush_new (const gchar *name);
PikaBrush* pika_brush_get_by_name (const gchar *name);
gboolean pika_brush_is_generated (PikaBrush *brush);
gboolean pika_brush_get_info (PikaBrush *brush,
gint *width,
gint *height,
gint *mask_bpp,
gint *color_bpp);
gboolean pika_brush_get_pixels (PikaBrush *brush,
gint *width,
gint *height,
gint *mask_bpp,
GBytes **mask_bytes,
gint *color_bpp,
GBytes **color_bytes);
gint pika_brush_get_spacing (PikaBrush *brush);
gboolean pika_brush_set_spacing (PikaBrush *brush,
gint spacing);
gboolean pika_brush_get_shape (PikaBrush *brush,
PikaBrushGeneratedShape *shape);
gboolean pika_brush_set_shape (PikaBrush *brush,
PikaBrushGeneratedShape shape_in,
PikaBrushGeneratedShape *shape_out);
gboolean pika_brush_get_radius (PikaBrush *brush,
gdouble *radius);
gboolean pika_brush_set_radius (PikaBrush *brush,
gdouble radius_in,
gdouble *radius_out);
gboolean pika_brush_get_spikes (PikaBrush *brush,
gint *spikes);
gboolean pika_brush_set_spikes (PikaBrush *brush,
gint spikes_in,
gint *spikes_out);
gboolean pika_brush_get_hardness (PikaBrush *brush,
gdouble *hardness);
gboolean pika_brush_set_hardness (PikaBrush *brush,
gdouble hardness_in,
gdouble *hardness_out);
gboolean pika_brush_get_aspect_ratio (PikaBrush *brush,
gdouble *aspect_ratio);
gboolean pika_brush_set_aspect_ratio (PikaBrush *brush,
gdouble aspect_ratio_in,
gdouble *aspect_ratio_out);
gboolean pika_brush_get_angle (PikaBrush *brush,
gdouble *angle);
gboolean pika_brush_set_angle (PikaBrush *brush,
gdouble angle_in,
gdouble *angle_out);
G_END_DECLS
#endif /* __PIKA_BRUSH_PDB_H__ */

106
libpika/pikabrushes_pdb.c Normal file
View File

@ -0,0 +1,106 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrushes_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikabrushes
* @title: pikabrushes
* @short_description: Functions for manipulating brushes.
*
* Functions related to getting and setting brushes.
**/
/**
* pika_brushes_refresh:
*
* Refresh current brushes. This function always succeeds.
*
* This procedure retrieves all brushes currently in the user's brush
* path and updates the brush dialogs accordingly.
*
* Returns: TRUE on success.
**/
gboolean
pika_brushes_refresh (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brushes-refresh",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brushes_get_list:
* @filter: An optional regular expression used to filter the list.
*
* Retrieve a complete listing of the available brushes.
*
* This procedure returns a complete listing of available PIKA brushes.
* Each name returned can be used as input to the
* pika_context_set_brush() procedure.
*
* Returns: (array zero-terminated=1) (transfer full): The list of brush names.
* The returned value must be freed with g_strfreev().
**/
gchar **
pika_brushes_get_list (const gchar *filter)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **brush_list = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, filter,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brushes-get-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
brush_list = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return brush_list;
}

41
libpika/pikabrushes_pdb.h Normal file
View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrushes_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_BRUSHES_PDB_H__
#define __PIKA_BRUSHES_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_brushes_refresh (void);
gchar** pika_brushes_get_list (const gchar *filter);
G_END_DECLS
#endif /* __PIKA_BRUSHES_PDB_H__ */

View File

@ -0,0 +1,146 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrushselect_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikabrushselect
* @title: pikabrushselect
* @short_description: Methods of a font chooser dialog
*
* A dialog letting a user choose a brush. Read more at
* pikafontselect.
**/
/**
* pika_brushes_popup:
* @brush_callback: The callback PDB proc to call when user chooses a brush.
* @popup_title: Title of the brush selection dialog.
* @initial_brush_name: The name of the brush to set as the initial choice.
*
* Invokes the PIKA brush selection dialog.
*
* Opens a dialog letting a user choose a brush.
*
* Returns: TRUE on success.
**/
gboolean
pika_brushes_popup (const gchar *brush_callback,
const gchar *popup_title,
const gchar *initial_brush_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, brush_callback,
G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_brush_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brushes-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brushes_close_popup:
* @brush_callback: The name of the callback registered for this pop-up.
*
* Close the brush selection dialog.
*
* Closes an open brush selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_brushes_close_popup (const gchar *brush_callback)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, brush_callback,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brushes-close-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_brushes_set_popup:
* @brush_callback: The name of the callback registered for this pop-up.
* @brush_name: The name of the brush to set as selected.
*
* Sets the selected brush in a brush selection dialog.
*
* Sets the selected brush in a brush selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_brushes_set_popup (const gchar *brush_callback,
const gchar *brush_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, brush_callback,
G_TYPE_STRING, brush_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-brushes-set-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabrushselect_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_BRUSH_SELECT_PDB_H__
#define __PIKA_BRUSH_SELECT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_brushes_popup (const gchar *brush_callback,
const gchar *popup_title,
const gchar *initial_brush_name);
gboolean pika_brushes_close_popup (const gchar *brush_callback);
gboolean pika_brushes_set_popup (const gchar *brush_callback,
const gchar *brush_name);
G_END_DECLS
#endif /* __PIKA_BRUSH_SELECT_PDB_H__ */

View File

@ -0,0 +1,429 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikabrushselectbutton.c
* Copyright (C) 1998 Andy Thomas
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pika.h"
#include "pikauitypes.h"
#include "pikabrushselectbutton.h"
#include "pikauimarshal.h"
#include "libpika-intl.h"
/**
* SECTION: pikabrushselectbutton
* @title: PikaBrushSelectButton
* @short_description: A button which pops up a brush selection dialog.
*
* A button which pops up a brush selection dialog.
**/
#define CELL_SIZE 20
/* A B&W image. mask_data is allocated and must be freed. */
typedef struct _PreviewBitmap
{
gint width;
gint height;
guchar *mask_data;
} _PreviewBitmap;
struct _PikaBrushSelectButton
{
PikaResourceSelectButton parent_instance;
GtkWidget *preview;
GtkWidget *popup;
};
static void pika_brush_select_button_draw_interior (PikaResourceSelectButton *self);
static void pika_brush_select_on_preview_resize (PikaBrushSelectButton *button);
static gboolean pika_brush_select_on_preview_events (GtkWidget *widget,
GdkEvent *event,
PikaBrushSelectButton *button);
static void pika_brush_select_preview_draw (PikaPreviewArea *area,
gint x,
gint y,
_PreviewBitmap mask,
gint rowstride);
static void pika_brush_select_preview_fill_draw (GtkWidget *preview,
_PreviewBitmap mask);
static void pika_brush_select_button_draw (PikaBrushSelectButton *self);
static _PreviewBitmap pika_brush_select_button_get_brush_bitmap (PikaBrushSelectButton *self);
/* Popup methods. */
static void pika_brush_select_button_open_popup (PikaBrushSelectButton *button,
gint x,
gint y);
static void pika_brush_select_button_close_popup (PikaBrushSelectButton *button);
static const GtkTargetEntry drag_target = { "application/x-pika-brush-name", 0, 0 };
G_DEFINE_FINAL_TYPE (PikaBrushSelectButton,
pika_brush_select_button,
PIKA_TYPE_RESOURCE_SELECT_BUTTON)
static void
pika_brush_select_button_class_init (PikaBrushSelectButtonClass *klass)
{
PikaResourceSelectButtonClass *superclass = PIKA_RESOURCE_SELECT_BUTTON_CLASS (klass);
superclass->draw_interior = pika_brush_select_button_draw_interior;
superclass->resource_type = PIKA_TYPE_BRUSH;
}
static void
pika_brush_select_button_init (PikaBrushSelectButton *self)
{
GtkWidget *frame;
GtkWidget *button;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (self), frame, FALSE, FALSE, 0);
self->preview = pika_preview_area_new ();
gtk_widget_add_events (self->preview,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_set_size_request (self->preview, CELL_SIZE, CELL_SIZE);
gtk_container_add (GTK_CONTAINER (frame), self->preview);
g_signal_connect_swapped (self->preview, "size-allocate",
G_CALLBACK (pika_brush_select_on_preview_resize),
self);
g_signal_connect (self->preview, "event",
G_CALLBACK (pika_brush_select_on_preview_events),
self);
button = gtk_button_new_with_mnemonic (_("_Browse..."));
gtk_box_pack_start (GTK_BOX (self), button, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET (self));
pika_resource_select_button_set_drag_target (PIKA_RESOURCE_SELECT_BUTTON (self),
self->preview,
&drag_target);
pika_resource_select_button_set_clickable (PIKA_RESOURCE_SELECT_BUTTON (self),
button);
}
static void
pika_brush_select_button_draw_interior (PikaResourceSelectButton *self)
{
pika_brush_select_button_draw (PIKA_BRUSH_SELECT_BUTTON (self));
}
/**
* pika_brush_select_button_new:
* @title: (nullable): Title of the dialog to use or %NULL to use the default title.
* @resource: (nullable): Initial brush.
*
* Creates a new #GtkWidget that lets a user choose a brush.
* You can put this widget in a plug-in dialog.
*
* When brush is NULL, initial choice is from context.
*
* Returns: A #GtkWidget that you can use in your UI.
*
* Since: 2.4
*/
GtkWidget *
pika_brush_select_button_new (const gchar *title,
PikaResource *resource)
{
GtkWidget *self;
if (resource == NULL)
resource = PIKA_RESOURCE (pika_context_get_brush ());
if (title)
self = g_object_new (PIKA_TYPE_BRUSH_SELECT_BUTTON,
"title", title,
"resource", resource,
NULL);
else
self = g_object_new (PIKA_TYPE_BRUSH_SELECT_BUTTON,
"resource", resource,
NULL);
pika_brush_select_button_draw_interior (PIKA_RESOURCE_SELECT_BUTTON (self));
return self;
}
/* private functions */
/* Draw self.
*
* This knows that we only draw the preview. Gtk draws the browse button.
*/
static void
pika_brush_select_button_draw (PikaBrushSelectButton *self)
{
_PreviewBitmap mask;
mask = pika_brush_select_button_get_brush_bitmap (self);
pika_brush_select_preview_fill_draw (self->preview, mask);
g_free (mask.mask_data);
}
/* Return the mask portion of self's brush's data.
* Caller must free mask_data.
*/
static _PreviewBitmap
pika_brush_select_button_get_brush_bitmap (PikaBrushSelectButton *self)
{
PikaBrush *brush;
gint mask_bpp;
GBytes *mask_data;
gsize mask_size;
gint color_bpp;
GBytes *color_data;
_PreviewBitmap result;
g_object_get (self, "resource", &brush, NULL);
pika_brush_get_pixels (brush,
&result.width,
&result.height,
&mask_bpp,
&mask_data,
&color_bpp,
&color_data);
result.mask_data = g_bytes_unref_to_data (mask_data, &mask_size);
/* Discard any color data, bitmap is B&W i.e. i.e. depth one i.e. a mask */
g_bytes_unref (color_data);
return result;
}
/* On resize event, redraw. */
static void
pika_brush_select_on_preview_resize (PikaBrushSelectButton *self)
{
pika_brush_select_button_draw (self);
}
/* On mouse events in self's preview, popup a zoom view of entire brush */
static gboolean
pika_brush_select_on_preview_events (GtkWidget *widget,
GdkEvent *event,
PikaBrushSelectButton *self)
{
GdkEventButton *bevent;
switch (event->type)
{
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
{
gtk_grab_add (widget);
pika_brush_select_button_open_popup (self,
bevent->x, bevent->y);
}
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
{
gtk_grab_remove (widget);
pika_brush_select_button_close_popup (self);
}
break;
default:
break;
}
return FALSE;
}
/* Draw a PikaPreviewArea with a given bitmap. */
static void
pika_brush_select_preview_draw (PikaPreviewArea *area,
gint x,
gint y,
_PreviewBitmap mask,
gint rowstride)
{
const guchar *src;
guchar *dest;
guchar *buf;
gint i, j;
buf = g_new (guchar, mask.width * mask.height);
src = mask.mask_data;
dest = buf;
for (j = 0; j < mask.height; j++)
{
const guchar *s = src;
for (i = 0; i < mask.width; i++, s++, dest++)
*dest = 255 - *s;
src += rowstride;
}
pika_preview_area_draw (area,
x, y, mask.width, mask.height,
PIKA_GRAY_IMAGE,
buf,
mask.width);
g_free (buf);
}
/* Fill a PikaPreviewArea with a bitmap then draw. */
static void
pika_brush_select_preview_fill_draw (GtkWidget *preview,
_PreviewBitmap mask)
{
PikaPreviewArea *area = PIKA_PREVIEW_AREA (preview);
GtkAllocation allocation;
gint x, y;
gint width, height;
_PreviewBitmap drawn_mask;
gtk_widget_get_allocation (preview, &allocation);
width = MIN (mask.width, allocation.width);
height = MIN (mask.height, allocation.height);
x = ((allocation.width - width) / 2);
y = ((allocation.height - height) / 2);
if (x || y)
pika_preview_area_fill (area,
0, 0,
allocation.width,
allocation.height,
0xFF, 0xFF, 0xFF);
/* Draw same data to new bounds.
* drawn_mask.mask_data points to same array.
*/
drawn_mask.width = width;
drawn_mask.height = height;
drawn_mask.mask_data = mask.mask_data;
pika_brush_select_preview_draw (area,
x, y,
drawn_mask,
mask.width); /* row stride */
/* Caller will free mask.mask_data */
}
/* popup methods. */
static void
pika_brush_select_button_open_popup (PikaBrushSelectButton *self,
gint x,
gint y)
{
GtkWidget *frame;
GtkWidget *preview;
GdkMonitor *monitor;
GdkRectangle workarea;
gint x_org;
gint y_org;
_PreviewBitmap mask;
if (self->popup)
pika_brush_select_button_close_popup (self);
mask = pika_brush_select_button_get_brush_bitmap (self);
if (mask.width <= CELL_SIZE && mask.height <= CELL_SIZE)
return;
self->popup = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_type_hint (GTK_WINDOW (self->popup), GDK_WINDOW_TYPE_HINT_DND);
gtk_window_set_screen (GTK_WINDOW (self->popup),
gtk_widget_get_screen (GTK_WIDGET (self)));
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (self->popup), frame);
gtk_widget_show (frame);
preview = pika_preview_area_new ();
gtk_widget_set_size_request (preview, mask.width, mask.height);
gtk_container_add (GTK_CONTAINER (frame), preview);
gtk_widget_show (preview);
/* decide where to put the popup: near the preview i.e. at mousedown coords */
gdk_window_get_origin (gtk_widget_get_window (self->preview),
&x_org, &y_org);
monitor = pika_widget_get_monitor (GTK_WIDGET (self));
gdk_monitor_get_workarea (monitor, &workarea);
x = x_org + x - (mask.width / 2);
y = y_org + y - (mask.height / 2);
x = CLAMP (x, workarea.x, workarea.x + workarea.width - mask.width);
y = CLAMP (y, workarea.y, workarea.y + workarea.height - mask.height);
gtk_window_move (GTK_WINDOW (self->popup), x, y);
gtk_widget_show (self->popup);
/* Draw popup now. Usual events do not cause a draw. */
pika_brush_select_preview_draw (PIKA_PREVIEW_AREA (preview),
0, 0,
mask,
mask.width);
g_free (mask.mask_data);
}
static void
pika_brush_select_button_close_popup (PikaBrushSelectButton *self)
{
g_clear_pointer (&self->popup, gtk_widget_destroy);
}

View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikabrushselectbutton.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_BRUSH_SELECT_BUTTON_H__
#define __PIKA_BRUSH_SELECT_BUTTON_H__
#include <libpika/pikaresourceselectbutton.h>
G_BEGIN_DECLS
#define PIKA_TYPE_BRUSH_SELECT_BUTTON (pika_brush_select_button_get_type ())
G_DECLARE_FINAL_TYPE (PikaBrushSelectButton,
pika_brush_select_button,
PIKA, BRUSH_SELECT_BUTTON,
PikaResourceSelectButton)
GtkWidget * pika_brush_select_button_new (const gchar *title,
PikaResource *resource);
G_END_DECLS
#endif /* __PIKA_BRUSH_SELECT_BUTTON_H__ */

295
libpika/pikabuffer_pdb.c Normal file
View File

@ -0,0 +1,295 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabuffer_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikabuffer
* @title: pikabuffer
* @short_description: Functions for manipulating cut buffers.
*
* Functions related to named cut buffers.
**/
/**
* pika_buffers_get_list:
* @filter: An optional regular expression used to filter the list.
*
* Retrieve a complete listing of the available buffers.
*
* This procedure returns a complete listing of available named
* buffers.
*
* Returns: (array zero-terminated=1) (transfer full):
* The list of buffer names.
* The returned value must be freed with g_strfreev().
*
* Since: 2.4
**/
gchar **
pika_buffers_get_list (const gchar *filter)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **buffer_list = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, filter,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffers-get-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
buffer_list = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return buffer_list;
}
/**
* pika_buffer_rename:
* @buffer_name: The buffer name.
* @new_name: The buffer's new name.
*
* Renames a named buffer.
*
* This procedure renames a named buffer.
*
* Returns: (transfer full): The real name given to the buffer.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gchar *
pika_buffer_rename (const gchar *buffer_name,
const gchar *new_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *real_name = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_STRING, new_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-rename",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
real_name = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return real_name;
}
/**
* pika_buffer_delete:
* @buffer_name: The buffer name.
*
* Deletes a named buffer.
*
* This procedure deletes a named buffer.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_buffer_delete (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-delete",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_buffer_get_width:
* @buffer_name: The buffer name.
*
* Retrieves the specified buffer's width.
*
* This procedure retrieves the specified named buffer's width.
*
* Returns: The buffer width.
*
* Since: 2.4
**/
gint
pika_buffer_get_width (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint width = 0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-get-width",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
width = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return width;
}
/**
* pika_buffer_get_height:
* @buffer_name: The buffer name.
*
* Retrieves the specified buffer's height.
*
* This procedure retrieves the specified named buffer's height.
*
* Returns: The buffer height.
*
* Since: 2.4
**/
gint
pika_buffer_get_height (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint height = 0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-get-height",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
height = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return height;
}
/**
* pika_buffer_get_bytes:
* @buffer_name: The buffer name.
*
* Retrieves the specified buffer's bytes.
*
* This procedure retrieves the specified named buffer's bytes.
*
* Returns: The buffer bpp.
*
* Since: 2.4
**/
gint
pika_buffer_get_bytes (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint bytes = 0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-get-bytes",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
bytes = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return bytes;
}
/**
* pika_buffer_get_image_type:
* @buffer_name: The buffer name.
*
* Retrieves the specified buffer's image type.
*
* This procedure retrieves the specified named buffer's image type.
*
* Returns: The buffer image type.
*
* Since: 2.4
**/
PikaImageBaseType
pika_buffer_get_image_type (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImageBaseType image_type = 0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-buffer-get-image-type",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
image_type = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return image_type;
}

47
libpika/pikabuffer_pdb.h Normal file
View File

@ -0,0 +1,47 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikabuffer_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_BUFFER_PDB_H__
#define __PIKA_BUFFER_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gchar** pika_buffers_get_list (const gchar *filter);
gchar* pika_buffer_rename (const gchar *buffer_name,
const gchar *new_name);
gboolean pika_buffer_delete (const gchar *buffer_name);
gint pika_buffer_get_width (const gchar *buffer_name);
gint pika_buffer_get_height (const gchar *buffer_name);
gint pika_buffer_get_bytes (const gchar *buffer_name);
PikaImageBaseType pika_buffer_get_image_type (const gchar *buffer_name);
G_END_DECLS
#endif /* __PIKA_BUFFER_PDB_H__ */

103
libpika/pikachannel.c Normal file
View File

@ -0,0 +1,103 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikachannel.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
G_DEFINE_TYPE (PikaChannel, pika_channel, PIKA_TYPE_DRAWABLE)
#define parent_class pika_drawable_parent_class
static void
pika_channel_class_init (PikaChannelClass *klass)
{
}
static void
pika_channel_init (PikaChannel *channel)
{
}
/**
* pika_channel_get_by_id:
* @channel_id: The channel id.
*
* Returns a #PikaChannel representing @channel_id. This function
* calls pika_item_get_by_id() and returns the item if it is channel
* or %NULL otherwise.
*
* Returns: (nullable) (transfer none): a #PikaChannel for @channel_id
* or %NULL if @channel_id does not represent a valid
* channel. The object belongs to libpika and you must not
* modify or unref it.
*
* Since: 3.0
**/
PikaChannel *
pika_channel_get_by_id (gint32 channel_id)
{
PikaItem *item = pika_item_get_by_id (channel_id);
if (PIKA_IS_CHANNEL (item))
return (PikaChannel *) item;
return NULL;
}
/**
* pika_channel_new:
* @image: The image to which to add the channel.
* @name: The channel name.
* @width: The channel width.
* @height: The channel height.
* @opacity: The channel opacity.
* @color: The channel compositing color.
*
* Create a new channel.
*
* This procedure creates a new channel with the specified width and
* height. Name, opacity, and color are also supplied parameters. The
* new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with the pika_image_insert_channel()
* command. Other attributes such as channel show masked, should be
* set with explicit procedure calls. The channel's contents are
* undefined initially.
*
* Returns: (transfer none): The newly created channel.
* The object belongs to libpika and you should not free it.
*/
PikaChannel *
pika_channel_new (PikaImage *image,
const gchar *name,
guint width,
guint height,
gdouble opacity,
const PikaRGB *color)
{
return _pika_channel_new (image,
width,
height,
name,
opacity,
color);
}

67
libpika/pikachannel.h Normal file
View File

@ -0,0 +1,67 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikachannel.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_CHANNEL_H__
#define __PIKA_CHANNEL_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#include <libpika/pikadrawable.h>
#define PIKA_TYPE_CHANNEL (pika_channel_get_type ())
G_DECLARE_DERIVABLE_TYPE (PikaChannel, pika_channel, PIKA, CHANNEL, PikaDrawable)
struct _PikaChannelClass
{
PikaDrawableClass parent_class;
/* Padding for future expansion */
void (*_pika_reserved1) (void);
void (*_pika_reserved2) (void);
void (*_pika_reserved3) (void);
void (*_pika_reserved4) (void);
void (*_pika_reserved5) (void);
void (*_pika_reserved6) (void);
void (*_pika_reserved7) (void);
void (*_pika_reserved8) (void);
};
PikaChannel * pika_channel_get_by_id (gint32 channel_id);
PikaChannel * pika_channel_new (PikaImage *image,
const gchar *name,
guint width,
guint height,
gdouble opacity,
const PikaRGB *color);
G_END_DECLS
#endif /* __PIKA_CHANNEL_H__ */

438
libpika/pikachannel_pdb.c Normal file
View File

@ -0,0 +1,438 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikachannel_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikachannel
* @title: pikachannel
* @short_description: Functions for manipulating channels.
*
* Functions for manipulating channels.
**/
/**
* _pika_channel_new:
* @image: The image to which to add the channel.
* @width: The channel width.
* @height: The channel height.
* @name: The channel name.
* @opacity: The channel opacity.
* @color: The channel compositing color.
*
* Create a new channel.
*
* This procedure creates a new channel with the specified width,
* height, name, opacity and color.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with pika_image_insert_channel().
* Other attributes, such as channel visibility, should be set with
* explicit procedure calls.
* The channel's contents are undefined initially.
*
* Returns: (transfer none): The newly created channel.
**/
PikaChannel *
_pika_channel_new (PikaImage *image,
gint width,
gint height,
const gchar *name,
gdouble opacity,
const PikaRGB *color)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaChannel *channel = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_STRING, name,
G_TYPE_DOUBLE, opacity,
PIKA_TYPE_RGB, color,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-new",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
channel = PIKA_VALUES_GET_CHANNEL (return_vals, 1);
pika_value_array_unref (return_vals);
return channel;
}
/**
* pika_channel_new_from_component:
* @image: The image to which to add the channel.
* @component: The image component.
* @name: The channel name.
*
* Create a new channel from a color component
*
* This procedure creates a new channel from a color component.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with pika_image_insert_channel().
* Other attributes, such as channel visibility, should be set with
* explicit procedure calls.
*
* Returns: (transfer none): The newly created channel.
*
* Since: 2.4
**/
PikaChannel *
pika_channel_new_from_component (PikaImage *image,
PikaChannelType component,
const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaChannel *channel = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_CHANNEL_TYPE, component,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-new-from-component",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
channel = PIKA_VALUES_GET_CHANNEL (return_vals, 1);
pika_value_array_unref (return_vals);
return channel;
}
/**
* pika_channel_copy:
* @channel: The channel to copy.
*
* Copy a channel.
*
* This procedure copies the specified channel and returns the copy.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with pika_image_insert_channel().
*
* Returns: (transfer none): The newly copied channel.
**/
PikaChannel *
pika_channel_copy (PikaChannel *channel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaChannel *channel_copy = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-copy",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
channel_copy = PIKA_VALUES_GET_CHANNEL (return_vals, 1);
pika_value_array_unref (return_vals);
return channel_copy;
}
/**
* pika_channel_combine_masks:
* @channel1: The channel1.
* @channel2: The channel2.
* @operation: The selection operation.
* @offx: x offset between upper left corner of channels: (second - first).
* @offy: y offset between upper left corner of channels: (second - first).
*
* Combine two channel masks.
*
* This procedure combines two channel masks. The result is stored in
* the first channel.
*
* Returns: TRUE on success.
**/
gboolean
pika_channel_combine_masks (PikaChannel *channel1,
PikaChannel *channel2,
PikaChannelOps operation,
gint offx,
gint offy)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel1,
PIKA_TYPE_CHANNEL, channel2,
PIKA_TYPE_CHANNEL_OPS, operation,
G_TYPE_INT, offx,
G_TYPE_INT, offy,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-combine-masks",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_channel_get_show_masked:
* @channel: The channel.
*
* Get the composite method of the specified channel.
*
* This procedure returns the specified channel's composite method. If
* it is TRUE, then the channel is composited with the image so that
* masked regions are shown. Otherwise, selected regions are shown.
*
* Returns: The channel composite method.
**/
gboolean
pika_channel_get_show_masked (PikaChannel *channel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean show_masked = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-get-show-masked",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
show_masked = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return show_masked;
}
/**
* pika_channel_set_show_masked:
* @channel: The channel.
* @show_masked: The new channel composite method.
*
* Set the composite method of the specified channel.
*
* This procedure sets the specified channel's composite method. If it
* is TRUE, then the channel is composited with the image so that
* masked regions are shown. Otherwise, selected regions are shown.
*
* Returns: TRUE on success.
**/
gboolean
pika_channel_set_show_masked (PikaChannel *channel,
gboolean show_masked)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_BOOLEAN, show_masked,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-set-show-masked",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_channel_get_opacity:
* @channel: The channel.
*
* Get the opacity of the specified channel.
*
* This procedure returns the specified channel's opacity.
*
* Returns: The channel opacity.
**/
gdouble
pika_channel_get_opacity (PikaChannel *channel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gdouble opacity = 0.0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-get-opacity",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
opacity = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return opacity;
}
/**
* pika_channel_set_opacity:
* @channel: The channel.
* @opacity: The new channel opacity.
*
* Set the opacity of the specified channel.
*
* This procedure sets the specified channel's opacity.
*
* Returns: TRUE on success.
**/
gboolean
pika_channel_set_opacity (PikaChannel *channel,
gdouble opacity)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_DOUBLE, opacity,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-set-opacity",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_channel_get_color:
* @channel: The channel.
* @color: (out caller-allocates): The channel compositing color.
*
* Get the compositing color of the specified channel.
*
* This procedure returns the specified channel's compositing color.
*
* Returns: TRUE on success.
**/
gboolean
pika_channel_get_color (PikaChannel *channel,
PikaRGB *color)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-get-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
PIKA_VALUES_GET_RGB (return_vals, 1, &*color);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_channel_set_color:
* @channel: The channel.
* @color: The new channel compositing color.
*
* Set the compositing color of the specified channel.
*
* This procedure sets the specified channel's compositing color.
*
* Returns: TRUE on success.
**/
gboolean
pika_channel_set_color (PikaChannel *channel,
const PikaRGB *color)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_CHANNEL, channel,
PIKA_TYPE_RGB, color,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-channel-set-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

64
libpika/pikachannel_pdb.h Normal file
View File

@ -0,0 +1,64 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikachannel_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_CHANNEL_PDB_H__
#define __PIKA_CHANNEL_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL PikaChannel* _pika_channel_new (PikaImage *image,
gint width,
gint height,
const gchar *name,
gdouble opacity,
const PikaRGB *color);
PikaChannel* pika_channel_new_from_component (PikaImage *image,
PikaChannelType component,
const gchar *name);
PikaChannel* pika_channel_copy (PikaChannel *channel);
gboolean pika_channel_combine_masks (PikaChannel *channel1,
PikaChannel *channel2,
PikaChannelOps operation,
gint offx,
gint offy);
gboolean pika_channel_get_show_masked (PikaChannel *channel);
gboolean pika_channel_set_show_masked (PikaChannel *channel,
gboolean show_masked);
gdouble pika_channel_get_opacity (PikaChannel *channel);
gboolean pika_channel_set_opacity (PikaChannel *channel,
gdouble opacity);
gboolean pika_channel_get_color (PikaChannel *channel,
PikaRGB *color);
gboolean pika_channel_set_color (PikaChannel *channel,
const PikaRGB *color);
G_END_DECLS
#endif /* __PIKA_CHANNEL_PDB_H__ */

4269
libpika/pikacontext_pdb.c Normal file

File diff suppressed because it is too large Load Diff

159
libpika/pikacontext_pdb.h Normal file
View File

@ -0,0 +1,159 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikacontext_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_CONTEXT_PDB_H__
#define __PIKA_CONTEXT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_context_push (void);
gboolean pika_context_pop (void);
gboolean pika_context_set_defaults (void);
gboolean pika_context_list_paint_methods (gchar ***paint_methods);
gchar* pika_context_get_paint_method (void);
gboolean pika_context_set_paint_method (const gchar *name);
PikaStrokeMethod pika_context_get_stroke_method (void);
gboolean pika_context_set_stroke_method (PikaStrokeMethod stroke_method);
gboolean pika_context_get_foreground (PikaRGB *foreground);
gboolean pika_context_set_foreground (const PikaRGB *foreground);
gboolean pika_context_get_background (PikaRGB *background);
gboolean pika_context_set_background (const PikaRGB *background);
gboolean pika_context_set_default_colors (void);
gboolean pika_context_swap_colors (void);
gdouble pika_context_get_opacity (void);
gboolean pika_context_set_opacity (gdouble opacity);
PikaLayerMode pika_context_get_paint_mode (void);
gboolean pika_context_set_paint_mode (PikaLayerMode paint_mode);
gdouble pika_context_get_line_width (void);
gboolean pika_context_set_line_width (gdouble line_width);
PikaUnit pika_context_get_line_width_unit (void);
gboolean pika_context_set_line_width_unit (PikaUnit line_width_unit);
PikaCapStyle pika_context_get_line_cap_style (void);
gboolean pika_context_set_line_cap_style (PikaCapStyle cap_style);
PikaJoinStyle pika_context_get_line_join_style (void);
gboolean pika_context_set_line_join_style (PikaJoinStyle join_style);
gdouble pika_context_get_line_miter_limit (void);
gboolean pika_context_set_line_miter_limit (gdouble miter_limit);
gdouble pika_context_get_line_dash_offset (void);
gboolean pika_context_set_line_dash_offset (gdouble dash_offset);
gboolean pika_context_get_line_dash_pattern (gint *num_dashes,
gdouble **dashes);
gboolean pika_context_set_line_dash_pattern (gint num_dashes,
const gdouble *dashes);
PikaBrush* pika_context_get_brush (void);
gboolean pika_context_set_brush (PikaBrush *brush);
gdouble pika_context_get_brush_size (void);
gboolean pika_context_set_brush_size (gdouble size);
gboolean pika_context_set_brush_default_size (void);
gdouble pika_context_get_brush_aspect_ratio (void);
gboolean pika_context_set_brush_aspect_ratio (gdouble aspect);
gdouble pika_context_get_brush_angle (void);
gboolean pika_context_set_brush_angle (gdouble angle);
gdouble pika_context_get_brush_spacing (void);
gboolean pika_context_set_brush_spacing (gdouble spacing);
gboolean pika_context_set_brush_default_spacing (void);
gdouble pika_context_get_brush_hardness (void);
gboolean pika_context_set_brush_hardness (gdouble hardness);
gboolean pika_context_set_brush_default_hardness (void);
gdouble pika_context_get_brush_force (void);
gboolean pika_context_set_brush_force (gdouble force);
gchar* pika_context_get_dynamics (void);
gboolean pika_context_set_dynamics (const gchar *name);
gboolean pika_context_are_dynamics_enabled (void);
gboolean pika_context_enable_dynamics (gboolean enable);
gchar* pika_context_get_mypaint_brush (void);
gboolean pika_context_set_mypaint_brush (const gchar *name);
PikaPattern* pika_context_get_pattern (void);
gboolean pika_context_set_pattern (PikaPattern *pattern);
PikaGradient* pika_context_get_gradient (void);
gboolean pika_context_set_gradient (PikaGradient *gradient);
gboolean pika_context_set_gradient_fg_bg_rgb (void);
gboolean pika_context_set_gradient_fg_bg_hsv_cw (void);
gboolean pika_context_set_gradient_fg_bg_hsv_ccw (void);
gboolean pika_context_set_gradient_fg_transparent (void);
PikaGradientBlendColorSpace pika_context_get_gradient_blend_color_space (void);
gboolean pika_context_set_gradient_blend_color_space (PikaGradientBlendColorSpace blend_color_space);
PikaRepeatMode pika_context_get_gradient_repeat_mode (void);
gboolean pika_context_set_gradient_repeat_mode (PikaRepeatMode repeat_mode);
gboolean pika_context_get_gradient_reverse (void);
gboolean pika_context_set_gradient_reverse (gboolean reverse);
PikaPalette* pika_context_get_palette (void);
gboolean pika_context_set_palette (PikaPalette *palette);
PikaFont* pika_context_get_font (void);
gboolean pika_context_set_font (PikaFont *font);
gboolean pika_context_get_antialias (void);
gboolean pika_context_set_antialias (gboolean antialias);
gboolean pika_context_get_feather (void);
gboolean pika_context_set_feather (gboolean feather);
gboolean pika_context_get_feather_radius (gdouble *feather_radius_x,
gdouble *feather_radius_y);
gboolean pika_context_set_feather_radius (gdouble feather_radius_x,
gdouble feather_radius_y);
gboolean pika_context_get_sample_merged (void);
gboolean pika_context_set_sample_merged (gboolean sample_merged);
PikaSelectCriterion pika_context_get_sample_criterion (void);
gboolean pika_context_set_sample_criterion (PikaSelectCriterion sample_criterion);
gdouble pika_context_get_sample_threshold (void);
gboolean pika_context_set_sample_threshold (gdouble sample_threshold);
gint pika_context_get_sample_threshold_int (void);
gboolean pika_context_set_sample_threshold_int (gint sample_threshold);
gboolean pika_context_get_sample_transparent (void);
gboolean pika_context_set_sample_transparent (gboolean sample_transparent);
gboolean pika_context_get_diagonal_neighbors (void);
gboolean pika_context_set_diagonal_neighbors (gboolean diagonal_neighbors);
GeglDistanceMetric pika_context_get_distance_metric (void);
gboolean pika_context_set_distance_metric (GeglDistanceMetric metric);
PikaInterpolationType pika_context_get_interpolation (void);
gboolean pika_context_set_interpolation (PikaInterpolationType interpolation);
PikaTransformDirection pika_context_get_transform_direction (void);
gboolean pika_context_set_transform_direction (PikaTransformDirection transform_direction);
PikaTransformResize pika_context_get_transform_resize (void);
gboolean pika_context_set_transform_resize (PikaTransformResize transform_resize);
gdouble pika_context_get_ink_size (void);
gboolean pika_context_set_ink_size (gdouble size);
gdouble pika_context_get_ink_angle (void);
gboolean pika_context_set_ink_angle (gdouble angle);
gdouble pika_context_get_ink_size_sensitivity (void);
gboolean pika_context_set_ink_size_sensitivity (gdouble size);
gdouble pika_context_get_ink_tilt_sensitivity (void);
gboolean pika_context_set_ink_tilt_sensitivity (gdouble tilt);
gdouble pika_context_get_ink_speed_sensitivity (void);
gboolean pika_context_set_ink_speed_sensitivity (gdouble speed);
PikaInkBlobType pika_context_get_ink_blob_type (void);
gboolean pika_context_set_ink_blob_type (PikaInkBlobType type);
gdouble pika_context_get_ink_blob_aspect_ratio (void);
gboolean pika_context_set_ink_blob_aspect_ratio (gdouble aspect);
gdouble pika_context_get_ink_blob_angle (void);
gboolean pika_context_set_ink_blob_angle (gdouble angle);
G_GNUC_INTERNAL PikaResource* _pika_context_get_resource (const gchar *type_name);
G_END_DECLS
#endif /* __PIKA_CONTEXT_PDB_H__ */

115
libpika/pikadebug_pdb.c Normal file
View File

@ -0,0 +1,115 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadebug_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadebug
* @title: pikadebug
* @short_description: Debug utility functions
*
* Miscellaneous debug utility functions. Not part of the stable
* library interface.
**/
/**
* pika_debug_timer_start:
*
* Starts measuring elapsed time.
*
* This procedure starts a timer, measuring the elapsed time since the
* call. Each call to this procedure should be matched by a call to
* pika_debug_timer_end(), which returns the elapsed time.
* If there is already an active timer, it is not affected by the call,
* however, a matching pika_debug_timer_end() call is still required.
*
* This is a debug utility procedure. It is subject to change at any
* point, and should not be used in production.
*
* Returns: TRUE on success.
**/
gboolean
pika_debug_timer_start (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-debug-timer-start",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_debug_timer_end:
*
* Finishes measuring elapsed time.
*
* This procedure stops the timer started by a previous
* pika_debug_timer_start() call, and prints and returns the elapsed
* time.
* If there was already an active timer at the time of corresponding
* call to pika_debug_timer_start(), a dummy value is returned.
*
* This is a debug utility procedure. It is subject to change at any
* point, and should not be used in production.
*
* Returns: The elapsed time, in seconds.
**/
gdouble
pika_debug_timer_end (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gdouble elapsed = 0.0;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-debug-timer-end",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
elapsed = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
pika_value_array_unref (return_vals);
return elapsed;
}

41
libpika/pikadebug_pdb.h Normal file
View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadebug_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DEBUG_PDB_H__
#define __PIKA_DEBUG_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_debug_timer_start (void);
gdouble pika_debug_timer_end (void);
G_END_DECLS
#endif /* __PIKA_DEBUG_PDB_H__ */

189
libpika/pikadisplay.c Normal file
View File

@ -0,0 +1,189 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* pikadisplay.c
* Copyright (C) Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
#include "libpikabase/pikawire.h" /* FIXME kill this include */
#include "pikaplugin-private.h"
#include "pikaprocedure-private.h"
enum
{
PROP_0,
PROP_ID,
N_PROPS
};
struct _PikaDisplayPrivate
{
gint id;
};
static void pika_display_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_display_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE_WITH_PRIVATE (PikaDisplay, pika_display, G_TYPE_OBJECT)
#define parent_class pika_display_parent_class
static GParamSpec *props[N_PROPS] = { NULL, };
static void
pika_display_class_init (PikaDisplayClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = pika_display_set_property;
object_class->get_property = pika_display_get_property;
props[PROP_ID] =
g_param_spec_int ("id",
"The display id",
"The display id for internal use",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, N_PROPS, props);
}
static void
pika_display_init (PikaDisplay *display)
{
display->priv = pika_display_get_instance_private (display);
}
static void
pika_display_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaDisplay *display = PIKA_DISPLAY (object);
switch (property_id)
{
case PROP_ID:
display->priv->id = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_display_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaDisplay *display = PIKA_DISPLAY (object);
switch (property_id)
{
case PROP_ID:
g_value_set_int (value, display->priv->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* Public API */
/**
* pika_display_get_id:
* @display: The display.
*
* Returns: the display ID.
*
* Since: 3.0
**/
gint32
pika_display_get_id (PikaDisplay *display)
{
return display ? display->priv->id : -1;
}
/**
* pika_display_get_by_id:
* @display_id: The display id.
*
* Returns a #PikaDisplay representing @display_id.
*
* Returns: (nullable) (transfer none): a #PikaDisplay for @display_id or
* %NULL if @display_id does not represent a valid display.
* The object belongs to libpika and you must not modify or
* unref it.
*
* Since: 3.0
**/
PikaDisplay *
pika_display_get_by_id (gint32 display_id)
{
if (display_id > 0)
{
PikaPlugIn *plug_in = pika_get_plug_in ();
PikaProcedure *procedure = _pika_plug_in_get_procedure (plug_in);
return _pika_procedure_get_display (procedure, display_id);
}
return NULL;
}
/**
* pika_display_is_valid:
* @display: The display to check.
*
* Returns TRUE if the display is valid.
*
* This procedure checks if the given display is valid and refers to
* an existing display.
*
* Returns: Whether the display is valid.
*
* Since: 2.4
**/
gboolean
pika_display_is_valid (PikaDisplay *display)
{
return pika_display_id_is_valid (pika_display_get_id (display));
}

78
libpika/pikadisplay.h Normal file
View File

@ -0,0 +1,78 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* pikadisplay.h
* Copyright (C) Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DISPLAY_H__
#define __PIKA_DISPLAY_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define PIKA_TYPE_DISPLAY (pika_display_get_type ())
#define PIKA_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DISPLAY, PikaDisplay))
#define PIKA_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DISPLAY, PikaDisplayClass))
#define PIKA_IS_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DISPLAY))
#define PIKA_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DISPLAY))
#define PIKA_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_DISPLAY, PikaDisplayClass))
typedef struct _PikaDisplayClass PikaDisplayClass;
typedef struct _PikaDisplayPrivate PikaDisplayPrivate;
struct _PikaDisplay
{
GObject parent_instance;
PikaDisplayPrivate *priv;
};
struct _PikaDisplayClass
{
GObjectClass parent_class;
/* Padding for future expansion */
void (*_pika_reserved1) (void);
void (*_pika_reserved2) (void);
void (*_pika_reserved3) (void);
void (*_pika_reserved4) (void);
void (*_pika_reserved5) (void);
void (*_pika_reserved6) (void);
void (*_pika_reserved7) (void);
void (*_pika_reserved8) (void);
};
GType pika_display_get_type (void) G_GNUC_CONST;
gint32 pika_display_get_id (PikaDisplay *display);
PikaDisplay * pika_display_get_by_id (gint32 display_id);
gboolean pika_display_is_valid (PikaDisplay *display);
G_END_DECLS
#endif /* __PIKA_DISPLAY_H__ */

299
libpika/pikadisplay_pdb.c Normal file
View File

@ -0,0 +1,299 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadisplay_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadisplay
* @title: pikadisplay
* @short_description: Functions to create, delete and flush displays (views) on an image.
*
* Functions to create, delete and flush displays (views) on an image.
**/
/**
* pika_display_id_is_valid:
* @display_id: The display ID to check.
*
* Returns TRUE if the display ID is valid.
*
* This procedure checks if the given display ID is valid and refers to
* an existing display.
*
* Returns: Whether the display ID is valid.
*
* Since: 3.0
**/
gboolean
pika_display_id_is_valid (gint display_id)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean valid = FALSE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, display_id,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-display-id-is-valid",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
valid = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return valid;
}
/**
* pika_display_new:
* @image: The image.
*
* Create a new display for the specified image.
*
* Creates a new display for the specified image. If the image already
* has a display, another is added. Multiple displays are handled
* transparently by PIKA. The newly created display is returned and can
* be subsequently destroyed with a call to pika_display_delete(). This
* procedure only makes sense for use with the PIKA UI, and will result
* in an execution error if called when PIKA has no UI.
*
* Returns: (transfer none): The new display.
**/
PikaDisplay *
pika_display_new (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaDisplay *display = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-display-new",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
display = PIKA_VALUES_GET_DISPLAY (return_vals, 1);
pika_value_array_unref (return_vals);
return display;
}
/**
* pika_display_delete:
* @display: The display to delete.
*
* Delete the specified display.
*
* This procedure removes the specified display. If this is the last
* remaining display for the underlying image, then the image is
* deleted also. Note that the display is closed no matter if the image
* is dirty or not. Better save the image before calling this
* procedure.
*
* Returns: TRUE on success.
**/
gboolean
pika_display_delete (PikaDisplay *display)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DISPLAY, display,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-display-delete",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_display_get_window_handle:
* @display: The display to get the window handle from.
*
* Get a handle to the native window for an image display.
*
* This procedure returns a handle to the native window for a given
* image display. For example in the X backend of GDK, a native window
* handle is an Xlib XID. A value of 0 is returned for an invalid
* display or if this function is unimplemented for the windowing
* system that is being used.
*
* Returns: The native window handle or 0.
*
* Since: 2.4
**/
gint
pika_display_get_window_handle (PikaDisplay *display)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint window = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DISPLAY, display,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-display-get-window-handle",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
window = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return window;
}
/**
* pika_display_present:
* @display: The display to present.
*
* Present the specified display.
*
* This procedure presents the specified display at the top of the
* display stack.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_display_present (PikaDisplay *display)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DISPLAY, display,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-display-present",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_displays_flush:
*
* Flush all internal changes to the user interface
*
* This procedure takes no arguments and returns nothing except a
* success status. Its purpose is to flush all pending updates of image
* manipulations to the user interface. It should be called whenever
* appropriate.
*
* Returns: TRUE on success.
**/
gboolean
pika_displays_flush (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-displays-flush",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_displays_reconnect:
* @old_image: The old image (must have at least one display).
* @new_image: The new image (must not have a display).
*
* Reconnect displays from one image to another image.
*
* This procedure connects all displays of the old_image to the
* new_image. If the old_image has no display or new_image already has
* a display the reconnect is not performed and the procedure returns
* without success. You should rarely need to use this function.
*
* Returns: TRUE on success.
**/
gboolean
pika_displays_reconnect (PikaImage *old_image,
PikaImage *new_image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, old_image,
PIKA_TYPE_IMAGE, new_image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-displays-reconnect",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

47
libpika/pikadisplay_pdb.h Normal file
View File

@ -0,0 +1,47 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadisplay_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DISPLAY_PDB_H__
#define __PIKA_DISPLAY_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_display_id_is_valid (gint display_id);
PikaDisplay* pika_display_new (PikaImage *image);
gboolean pika_display_delete (PikaDisplay *display);
gint pika_display_get_window_handle (PikaDisplay *display);
gboolean pika_display_present (PikaDisplay *display);
gboolean pika_displays_flush (void);
gboolean pika_displays_reconnect (PikaImage *old_image,
PikaImage *new_image);
G_END_DECLS
#endif /* __PIKA_DISPLAY_PDB_H__ */

436
libpika/pikadrawable.c Normal file
View File

@ -0,0 +1,436 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikadrawable.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
#include "pikapixbuf.h"
#include "pikatilebackendplugin.h"
G_DEFINE_ABSTRACT_TYPE (PikaDrawable, pika_drawable, PIKA_TYPE_ITEM)
#define parent_class pika_drawable_parent_class
static void
pika_drawable_class_init (PikaDrawableClass *klass)
{
}
static void
pika_drawable_init (PikaDrawable *drawable)
{
}
/* Public API. */
/**
* pika_drawable_get_by_id:
* @drawable_id: The drawable id.
*
* Returns a #PikaDrawable representing @drawable_id. This function
* calls pika_item_get_by_id() and returns the item if it is drawable
* or %NULL otherwise.
*
* Returns: (nullable) (transfer none): a #PikaDrawable for
* @drawable_id or %NULL if @drawable_id does not represent a
* valid drawable. The object belongs to libpika and you must
* not modify or unref it.
*
* Since: 3.0
**/
PikaDrawable *
pika_drawable_get_by_id (gint32 drawable_id)
{
PikaItem *item = pika_item_get_by_id (drawable_id);
if (PIKA_IS_DRAWABLE (item))
return (PikaDrawable *) item;
return NULL;
}
/**
* pika_drawable_get_thumbnail_data:
* @drawable: the drawable
* @width: the requested thumbnail width (<= 1024 pixels)
* @height: the requested thumbnail height (<= 1024 pixels)
* @actual_width: (out): the resulting thumbnail's actual width
* @actual_height: (out): the resulting thumbnail's actual height
* @bpp: (out): the bytes per pixel of the returned thubmnail data
*
* Retrieves thumbnail data for the drawable identified by @drawable.
* The thumbnail will be not larger than the requested size.
*
* Returns: (transfer full) (nullable): thumbnail data or %NULL if
* @drawable is invalid.
**/
GBytes *
pika_drawable_get_thumbnail_data (PikaDrawable *drawable,
gint width,
gint height,
gint *actual_width,
gint *actual_height,
gint *bpp)
{
GBytes *image_data;
g_return_val_if_fail (actual_width != NULL, NULL);
g_return_val_if_fail (actual_height != NULL, NULL);
g_return_val_if_fail (bpp != NULL, NULL);
_pika_drawable_thumbnail (drawable,
width,
height,
actual_width,
actual_height,
bpp,
&image_data);
return image_data;
}
/**
* pika_drawable_get_thumbnail:
* @drawable: the drawable
* @width: the requested thumbnail width (<= 1024 pixels)
* @height: the requested thumbnail height (<= 1024 pixels)
* @alpha: how to handle an alpha channel
*
* Retrieves a thumbnail pixbuf for the drawable identified by
* @drawable. The thumbnail will be not larger than the requested
* size.
*
* Returns: (transfer full): a new #GdkPixbuf
*
* Since: 2.2
**/
GdkPixbuf *
pika_drawable_get_thumbnail (PikaDrawable *drawable,
gint width,
gint height,
PikaPixbufTransparency alpha)
{
gint thumb_width, thumb_height, thumb_bpp;
GBytes *data;
gsize data_size;
GdkPixbuf *pixbuf = NULL;
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
data = pika_drawable_get_thumbnail_data (drawable,
width,
height,
&thumb_width,
&thumb_height,
&thumb_bpp);
if (data)
pixbuf = _pika_pixbuf_from_data (g_bytes_unref_to_data (data, &data_size),
thumb_width, thumb_height, thumb_bpp,
alpha);
return pixbuf;
}
/**
* pika_drawable_get_sub_thumbnail_data:
* @drawable: the drawable ID
* @src_x: the x coordinate of the area
* @src_y: the y coordinate of the area
* @src_width: the width of the area
* @src_height: the height of the area
* @dest_width: the requested thumbnail width (<= 1024 pixels)
* @dest_height: the requested thumbnail height (<= 1024 pixels)
* @actual_width: (out): the width of the returned thumbnail
* @actual_height: (out): the height of the returned thumbnail
* @bpp: (out): the bytes per pixel of the returned thumbnail data
*
* Retrieves thumbnail data for the drawable identified by @drawable.
* The thumbnail will be not larger than the requested size.
*
* Returns: (transfer full): thumbnail data or %NULL if
* @drawable is invalid.
**/
GBytes *
pika_drawable_get_sub_thumbnail_data (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
gint *actual_width,
gint *actual_height,
gint *bpp)
{
GBytes *image_bytes;
_pika_drawable_sub_thumbnail (drawable,
src_x, src_y,
src_width, src_height,
dest_width,
dest_height,
actual_width,
actual_height,
bpp,
&image_bytes);
return image_bytes;
}
/**
* pika_drawable_get_sub_thumbnail:
* @drawable: the drawable ID
* @src_x: the x coordinate of the area
* @src_y: the y coordinate of the area
* @src_width: the width of the area
* @src_height: the height of the area
* @dest_width: the requested thumbnail width (<= 1024 pixels)
* @dest_height: the requested thumbnail height (<= 1024 pixels)
* @alpha: how to handle an alpha channel
*
* Retrieves a thumbnail pixbuf for the drawable identified by
* @drawable. The thumbnail will be not larger than the requested
* size.
*
* Returns: (transfer full): a new #GdkPixbuf
*
* Since: 2.2
**/
GdkPixbuf *
pika_drawable_get_sub_thumbnail (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
PikaPixbufTransparency alpha)
{
gint thumb_width = dest_width;
gint thumb_height = dest_height;
gint thumb_bpp;
GBytes *data;
gsize data_size;
GdkPixbuf *pixbuf = NULL;
g_return_val_if_fail (src_x >= 0, NULL);
g_return_val_if_fail (src_y >= 0, NULL);
g_return_val_if_fail (src_width > 0, NULL);
g_return_val_if_fail (src_height > 0, NULL);
g_return_val_if_fail (dest_width > 0 && dest_width <= 1024, NULL);
g_return_val_if_fail (dest_height > 0 && dest_height <= 1024, NULL);
data = pika_drawable_get_sub_thumbnail_data (drawable,
src_x, src_y,
src_width, src_height,
dest_width, dest_height,
&thumb_width,
&thumb_height,
&thumb_bpp);
if (data)
pixbuf = _pika_pixbuf_from_data (g_bytes_unref_to_data (data, &data_size),
thumb_width, thumb_height, thumb_bpp,
alpha);
g_bytes_unref (data);
return pixbuf;
}
/**
* pika_drawable_get_buffer:
* @drawable: the ID of the #PikaDrawable to get the buffer for.
*
* Returns a #GeglBuffer of a specified drawable. The buffer can be used
* like any other GEGL buffer. Its data will we synced back with the core
* drawable when the buffer gets destroyed, or when gegl_buffer_flush()
* is called.
*
* Returns: (transfer full): The #GeglBuffer.
*
* See Also: pika_drawable_get_shadow_buffer()
*
* Since: 2.10
*/
GeglBuffer *
pika_drawable_get_buffer (PikaDrawable *drawable)
{
if (pika_item_is_valid (PIKA_ITEM (drawable)))
{
GeglTileBackend *backend;
GeglBuffer *buffer;
backend = _pika_tile_backend_plugin_new (drawable, FALSE);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
return NULL;
}
/**
* pika_drawable_get_shadow_buffer:
* @drawable: the ID of the #PikaDrawable to get the buffer for.
*
* Returns a #GeglBuffer of a specified drawable's shadow tiles. The
* buffer can be used like any other GEGL buffer. Its data will we
* synced back with the core drawable's shadow tiles when the buffer
* gets destroyed, or when gegl_buffer_flush() is called.
*
* Returns: (transfer full): The #GeglBuffer.
*
* Since: 2.10
*/
GeglBuffer *
pika_drawable_get_shadow_buffer (PikaDrawable *drawable)
{
if (pika_item_is_valid (PIKA_ITEM (drawable)))
{
GeglTileBackend *backend;
GeglBuffer *buffer;
backend = _pika_tile_backend_plugin_new (drawable, TRUE);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
return NULL;
}
/**
* pika_drawable_get_format:
* @drawable: the ID of the #PikaDrawable to get the format for.
*
* Returns the #Babl format of the drawable.
*
* Returns: The #Babl format.
*
* Since: 2.10
*/
const Babl *
pika_drawable_get_format (PikaDrawable *drawable)
{
const Babl *format = NULL;
gchar *format_str = _pika_drawable_get_format (drawable);
/* _pika_drawable_get_format() only returns the encoding, so we
* create the actual space from the image's profile
*/
if (format_str)
{
const Babl *space = NULL;
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
if (pika_item_is_layer (PIKA_ITEM (drawable)))
{
PikaColorProfile *profile = pika_image_get_color_profile (image);
if (profile)
{
GError *error = NULL;
space = pika_color_profile_get_space
(profile,
PIKA_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
&error);
if (! space)
{
g_printerr ("%s: failed to create Babl space from "
"profile: %s\n",
G_STRFUNC, error->message);
g_clear_error (&error);
}
g_object_unref (profile);
}
}
if (pika_drawable_is_indexed (drawable))
{
const Babl *palette;
const Babl *palette_alpha;
guchar *colormap;
gint colormap_len, n_colors;
babl_new_palette_with_space (format_str, space,
&palette, &palette_alpha);
if (pika_drawable_has_alpha (drawable))
format = palette_alpha;
else
format = palette;
colormap = pika_image_get_colormap (image, &colormap_len, &n_colors);
if (colormap)
{
babl_palette_set_palette (format,
babl_format_with_space ("R'G'B' u8",
space),
colormap, n_colors);
g_free (colormap);
}
}
else
{
format = babl_format_with_space (format_str, space);
}
g_free (format_str);
}
return format;
}
/**
* pika_drawable_get_thumbnail_format:
* @drawable: the ID of the #PikaDrawable to get the thumbnail format for.
*
* Returns the #Babl thumbnail format of the drawable.
*
* Returns: The #Babl thumbnail format.
*
* Since: 2.10.14
*/
const Babl *
pika_drawable_get_thumbnail_format (PikaDrawable *drawable)
{
const Babl *format = NULL;
gchar *format_str = _pika_drawable_get_thumbnail_format (drawable);
if (format_str)
{
format = babl_format (format_str);
g_free (format_str);
}
return format;
}

98
libpika/pikadrawable.h Normal file
View File

@ -0,0 +1,98 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikadrawable.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DRAWABLE_H__
#define __PIKA_DRAWABLE_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#include <libpika/pikaitem.h>
#define PIKA_TYPE_DRAWABLE (pika_drawable_get_type ())
G_DECLARE_DERIVABLE_TYPE (PikaDrawable, pika_drawable, PIKA, DRAWABLE, PikaItem)
struct _PikaDrawableClass
{
PikaItemClass parent_class;
/* Padding for future expansion */
void (*_pika_reserved1) (void);
void (*_pika_reserved2) (void);
void (*_pika_reserved3) (void);
void (*_pika_reserved4) (void);
void (*_pika_reserved5) (void);
void (*_pika_reserved6) (void);
void (*_pika_reserved7) (void);
void (*_pika_reserved8) (void);
void (*_pika_reserved9) (void);
};
PikaDrawable * pika_drawable_get_by_id (gint32 drawable_id);
GeglBuffer * pika_drawable_get_buffer (PikaDrawable *drawable);
GeglBuffer * pika_drawable_get_shadow_buffer (PikaDrawable *drawable);
const Babl * pika_drawable_get_format (PikaDrawable *drawable);
const Babl * pika_drawable_get_thumbnail_format (PikaDrawable *drawable);
GBytes * pika_drawable_get_thumbnail_data (PikaDrawable *drawable,
gint width,
gint height,
gint *actual_width,
gint *actual_height,
gint *bpp);
GdkPixbuf * pika_drawable_get_thumbnail (PikaDrawable *drawable,
gint width,
gint height,
PikaPixbufTransparency alpha);
GBytes * pika_drawable_get_sub_thumbnail_data (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
gint *actual_width,
gint *actual_height,
gint *bpp);
GdkPixbuf * pika_drawable_get_sub_thumbnail (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
PikaPixbufTransparency alpha);
G_END_DECLS
#endif /* __PIKA_DRAWABLE_H__ */

997
libpika/pikadrawable_pdb.c Normal file
View File

@ -0,0 +1,997 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawable_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadrawable
* @title: pikadrawable
* @short_description: Functions to manipulate drawables.
*
* Functions to manipulate drawables.
**/
/**
* _pika_drawable_get_format:
* @drawable: The drawable.
*
* Returns the drawable's Babl format
*
* This procedure returns the drawable's Babl format.
* Note that the actual PDB procedure only transfers the format's
* encoding. In order to get to the real format, the libbpika C wrapper
* must be used.
*
* Returns: (transfer full): The drawable's Babl format.
* The returned value must be freed with g_free().
*
* Since: 2.10
**/
gchar *
_pika_drawable_get_format (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *format = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-format",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
format = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return format;
}
/**
* _pika_drawable_get_thumbnail_format:
* @drawable: The drawable.
*
* Returns the drawable's thumbnail Babl format
*
* This procedure returns the drawable's thumbnail Babl format.
* Thumbnails are always 8-bit images, see pika_drawable_thumbnail()
* and pika_drawable_sub_thmbnail().
*
* Returns: (transfer full): The drawable's thumbnail Babl format.
* The returned value must be freed with g_free().
*
* Since: 2.10.14
**/
gchar *
_pika_drawable_get_thumbnail_format (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *format = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-thumbnail-format",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
format = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return format;
}
/**
* pika_drawable_type:
* @drawable: The drawable.
*
* Returns the drawable's type.
*
* This procedure returns the drawable's type.
*
* Returns: The drawable's type.
**/
PikaImageType
pika_drawable_type (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImageType type = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-type",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
type = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return type;
}
/**
* pika_drawable_type_with_alpha:
* @drawable: The drawable.
*
* Returns the drawable's type with alpha.
*
* This procedure returns the drawable's type as if had an alpha
* channel. If the type is currently Gray, for instance, the returned
* type would be GrayA. If the drawable already has an alpha channel,
* the drawable's type is simply returned.
*
* Returns: The drawable's type with alpha.
**/
PikaImageType
pika_drawable_type_with_alpha (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImageType type_with_alpha = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-type-with-alpha",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
type_with_alpha = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return type_with_alpha;
}
/**
* pika_drawable_has_alpha:
* @drawable: The drawable.
*
* Returns TRUE if the drawable has an alpha channel.
*
* This procedure returns whether the specified drawable has an alpha
* channel. This can only be true for layers, and the associated type
* will be one of: { RGBA , GRAYA, INDEXEDA }.
*
* Returns: Does the drawable have an alpha channel?
**/
gboolean
pika_drawable_has_alpha (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean has_alpha = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-has-alpha",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
has_alpha = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return has_alpha;
}
/**
* pika_drawable_is_rgb:
* @drawable: The drawable.
*
* Returns whether the drawable is an RGB type.
*
* This procedure returns TRUE if the specified drawable is of type {
* RGB, RGBA }.
*
* Returns: TRUE if the drawable is an RGB type.
**/
gboolean
pika_drawable_is_rgb (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean is_rgb = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-is-rgb",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
is_rgb = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return is_rgb;
}
/**
* pika_drawable_is_gray:
* @drawable: The drawable.
*
* Returns whether the drawable is a grayscale type.
*
* This procedure returns TRUE if the specified drawable is of type {
* Gray, GrayA }.
*
* Returns: TRUE if the drawable is a grayscale type.
**/
gboolean
pika_drawable_is_gray (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean is_gray = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-is-gray",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
is_gray = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return is_gray;
}
/**
* pika_drawable_is_indexed:
* @drawable: The drawable.
*
* Returns whether the drawable is an indexed type.
*
* This procedure returns TRUE if the specified drawable is of type {
* Indexed, IndexedA }.
*
* Returns: TRUE if the drawable is an indexed type.
**/
gboolean
pika_drawable_is_indexed (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean is_indexed = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-is-indexed",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
is_indexed = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return is_indexed;
}
/**
* pika_drawable_get_bpp:
* @drawable: The drawable.
*
* Returns the bytes per pixel.
*
* This procedure returns the number of bytes per pixel.
*
* Returns: Bytes per pixel.
**/
gint
pika_drawable_get_bpp (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint bpp = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-bpp",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
bpp = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return bpp;
}
/**
* pika_drawable_get_width:
* @drawable: The drawable.
*
* Returns the width of the drawable.
*
* This procedure returns the specified drawable's width in pixels.
*
* Returns: Width of drawable.
**/
gint
pika_drawable_get_width (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint width = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-width",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
width = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return width;
}
/**
* pika_drawable_get_height:
* @drawable: The drawable.
*
* Returns the height of the drawable.
*
* This procedure returns the specified drawable's height in pixels.
*
* Returns: Height of drawable.
**/
gint
pika_drawable_get_height (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gint height = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-height",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
height = PIKA_VALUES_GET_INT (return_vals, 1);
pika_value_array_unref (return_vals);
return height;
}
/**
* pika_drawable_get_offsets:
* @drawable: The drawable.
* @offset_x: (out): x offset of drawable.
* @offset_y: (out): y offset of drawable.
*
* Returns the offsets for the drawable.
*
* This procedure returns the specified drawable's offsets. This only
* makes sense if the drawable is a layer since channels are anchored.
* The offsets of a channel will be returned as 0.
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_get_offsets (PikaDrawable *drawable,
gint *offset_x,
gint *offset_y)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-get-offsets",
args);
pika_value_array_unref (args);
*offset_x = 0;
*offset_y = 0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*offset_x = PIKA_VALUES_GET_INT (return_vals, 1);
*offset_y = PIKA_VALUES_GET_INT (return_vals, 2);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_mask_bounds:
* @drawable: The drawable.
* @x1: (out): x coordinate of the upper left corner of selection bounds.
* @y1: (out): y coordinate of the upper left corner of selection bounds.
* @x2: (out): x coordinate of the lower right corner of selection bounds.
* @y2: (out): y coordinate of the lower right corner of selection bounds.
*
* Find the bounding box of the current selection in relation to the
* specified drawable.
*
* This procedure returns whether there is a selection. If there is
* one, the upper left and lower right-hand corners of its bounding box
* are returned. These coordinates are specified relative to the
* drawable's origin, and bounded by the drawable's extents. Please
* note that the pixel specified by the lower right-hand coordinate of
* the bounding box is not part of the selection. The selection ends at
* the upper left corner of this pixel. This means the width of the
* selection can be calculated as (x2 - x1), its height as (y2 - y1).
* Note that the returned boolean does NOT correspond with the returned
* region being empty or not, it always returns whether the selection
* is non_empty. See pika_drawable_mask_intersect() for a boolean
* return value which is more useful in most cases.
*
* Returns: TRUE if there is a selection.
**/
gboolean
pika_drawable_mask_bounds (PikaDrawable *drawable,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean non_empty = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-mask-bounds",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
{
non_empty = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
*x1 = PIKA_VALUES_GET_INT (return_vals, 2);
*y1 = PIKA_VALUES_GET_INT (return_vals, 3);
*x2 = PIKA_VALUES_GET_INT (return_vals, 4);
*y2 = PIKA_VALUES_GET_INT (return_vals, 5);
}
pika_value_array_unref (return_vals);
return non_empty;
}
/**
* pika_drawable_mask_intersect:
* @drawable: The drawable.
* @x: (out): x coordinate of the upper left corner of the intersection.
* @y: (out): y coordinate of the upper left corner of the intersection.
* @width: (out): width of the intersection.
* @height: (out): height of the intersection.
*
* Find the bounding box of the current selection in relation to the
* specified drawable.
*
* This procedure returns whether there is an intersection between the
* drawable and the selection. Unlike pika_drawable_mask_bounds(), the
* intersection's bounds are returned as x, y, width, height.
* If there is no selection this function returns TRUE and the returned
* bounds are the extents of the whole drawable.
*
* Returns: TRUE if the returned area is not empty.
*
* Since: 2.2
**/
gboolean
pika_drawable_mask_intersect (PikaDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean non_empty = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-mask-intersect",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
{
non_empty = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
*x = PIKA_VALUES_GET_INT (return_vals, 2);
*y = PIKA_VALUES_GET_INT (return_vals, 3);
*width = PIKA_VALUES_GET_INT (return_vals, 4);
*height = PIKA_VALUES_GET_INT (return_vals, 5);
}
pika_value_array_unref (return_vals);
return non_empty;
}
/**
* pika_drawable_merge_shadow:
* @drawable: The drawable.
* @undo: Push merge to undo stack?
*
* Merge the shadow buffer with the specified drawable.
*
* This procedure combines the contents of the drawable's shadow buffer
* (for temporary processing) with the specified drawable. The 'undo'
* parameter specifies whether to add an undo step for the operation.
* Requesting no undo is useful for such applications as 'auto-apply'.
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_merge_shadow (PikaDrawable *drawable,
gboolean undo)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_BOOLEAN, undo,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-merge-shadow",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_free_shadow:
* @drawable: The drawable.
*
* Free the specified drawable's shadow data (if it exists).
*
* This procedure is intended as a memory saving device. If any shadow
* memory has been allocated, it will be freed automatically when the
* drawable is removed from the image, or when the plug-in procedure
* which allocated it returns.
*
* Returns: TRUE on success.
*
* Since: 2.6
**/
gboolean
pika_drawable_free_shadow (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-free-shadow",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_update:
* @drawable: The drawable.
* @x: x coordinate of upper left corner of update region.
* @y: y coordinate of upper left corner of update region.
* @width: Width of update region.
* @height: Height of update region.
*
* Update the specified region of the drawable.
*
* This procedure updates the specified region of the drawable. The (x,
* y) coordinate pair is relative to the drawable's origin, not to the
* image origin. Therefore, the entire drawable can be updated using
* (0, 0, width, height).
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_update (PikaDrawable *drawable,
gint x,
gint y,
gint width,
gint height)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_INT, x,
G_TYPE_INT, y,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-update",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_fill:
* @drawable: The drawable.
* @fill_type: The type of fill.
*
* Fill the drawable with the specified fill mode.
*
* This procedure fills the drawable. If the fill mode is foreground
* the current foreground color is used. If the fill mode is
* background, the current background color is used. If the fill type
* is white, then white is used. Transparent fill only affects layers
* with an alpha channel, in which case the alpha channel is set to
* transparent. If the drawable has no alpha channel, it is filled to
* white. No fill leaves the drawable's contents undefined.
* This procedure is unlike pika_drawable_edit_fill() or the bucket
* fill tool because it fills regardless of a selection. Its main
* purpose is to fill a newly created drawable before adding it to the
* image. This operation cannot be undone.
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_fill (PikaDrawable *drawable,
PikaFillType fill_type)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_FILL_TYPE, fill_type,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-fill",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_offset:
* @drawable: The drawable to offset.
* @wrap_around: wrap image around or fill vacated regions.
* @fill_type: fill vacated regions of drawable with background or transparent.
* @offset_x: offset by this amount in X direction.
* @offset_y: offset by this amount in Y direction.
*
* Offset the drawable by the specified amounts in the X and Y
* directions
*
* This procedure offsets the specified drawable by the amounts
* specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to
* TRUE, then portions of the drawable which are offset out of bounds
* are wrapped around. Alternatively, the undefined regions of the
* drawable can be filled with transparency or the background color, as
* specified by the 'fill-type' parameter.
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_offset (PikaDrawable *drawable,
gboolean wrap_around,
PikaOffsetType fill_type,
gint offset_x,
gint offset_y)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_BOOLEAN, wrap_around,
PIKA_TYPE_OFFSET_TYPE, fill_type,
G_TYPE_INT, offset_x,
G_TYPE_INT, offset_y,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-offset",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* _pika_drawable_thumbnail:
* @drawable: The drawable.
* @width: The requested thumbnail width.
* @height: The requested thumbnail height.
* @actual_width: (out): The previews width.
* @actual_height: (out): The previews height.
* @bpp: (out): The previews bpp.
* @thumbnail_data: (out) (transfer full): The thumbnail data.
*
* Get a thumbnail of a drawable.
*
* This function gets data from which a thumbnail of a drawable preview
* can be created. Maximum x or y dimension is 1024 pixels. The pixels
* are returned in RGB[A] or GRAY[A] format. The bpp return value gives
* the number of bytes in the image.
*
* Returns: TRUE on success.
**/
gboolean
_pika_drawable_thumbnail (PikaDrawable *drawable,
gint width,
gint height,
gint *actual_width,
gint *actual_height,
gint *bpp,
GBytes **thumbnail_data)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-thumbnail",
args);
pika_value_array_unref (args);
*actual_width = 0;
*actual_height = 0;
*bpp = 0;
*thumbnail_data = NULL;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*actual_width = PIKA_VALUES_GET_INT (return_vals, 1);
*actual_height = PIKA_VALUES_GET_INT (return_vals, 2);
*bpp = PIKA_VALUES_GET_INT (return_vals, 3);
*thumbnail_data = PIKA_VALUES_DUP_BYTES (return_vals, 4);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* _pika_drawable_sub_thumbnail:
* @drawable: The drawable.
* @src_x: The x coordinate of the area.
* @src_y: The y coordinate of the area.
* @src_width: The width of the area.
* @src_height: The height of the area.
* @dest_width: The thumbnail width.
* @dest_height: The thumbnail height.
* @width: (out): The previews width.
* @height: (out): The previews height.
* @bpp: (out): The previews bpp.
* @thumbnail_data: (out) (transfer full): The thumbnail data.
*
* Get a thumbnail of a sub-area of a drawable drawable.
*
* This function gets data from which a thumbnail of a drawable preview
* can be created. Maximum x or y dimension is 1024 pixels. The pixels
* are returned in RGB[A] or GRAY[A] format. The bpp return value gives
* the number of bytes in the image.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
gboolean
_pika_drawable_sub_thumbnail (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
gint *width,
gint *height,
gint *bpp,
GBytes **thumbnail_data)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_INT, src_x,
G_TYPE_INT, src_y,
G_TYPE_INT, src_width,
G_TYPE_INT, src_height,
G_TYPE_INT, dest_width,
G_TYPE_INT, dest_height,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-sub-thumbnail",
args);
pika_value_array_unref (args);
*width = 0;
*height = 0;
*bpp = 0;
*thumbnail_data = NULL;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*width = PIKA_VALUES_GET_INT (return_vals, 1);
*height = PIKA_VALUES_GET_INT (return_vals, 2);
*bpp = PIKA_VALUES_GET_INT (return_vals, 3);
*thumbnail_data = PIKA_VALUES_DUP_BYTES (return_vals, 4);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_foreground_extract:
* @drawable: The drawable.
* @mode: The algorithm to use.
* @mask: Tri-Map.
*
* Extract the foreground of a drawable using a given trimap.
*
* Image Segmentation by Uniform Color Clustering, see
* https://www.inf.fu-berlin.de/inst/pubs/tr-b-05-07.pdf
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_drawable_foreground_extract (PikaDrawable *drawable,
PikaForegroundExtractMode mode,
PikaDrawable *mask)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_FOREGROUND_EXTRACT_MODE, mode,
PIKA_TYPE_DRAWABLE, mask,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-foreground-extract",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,99 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawable_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DRAWABLE_PDB_H__
#define __PIKA_DRAWABLE_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL gchar* _pika_drawable_get_format (PikaDrawable *drawable);
G_GNUC_INTERNAL gchar* _pika_drawable_get_thumbnail_format (PikaDrawable *drawable);
PikaImageType pika_drawable_type (PikaDrawable *drawable);
PikaImageType pika_drawable_type_with_alpha (PikaDrawable *drawable);
gboolean pika_drawable_has_alpha (PikaDrawable *drawable);
gboolean pika_drawable_is_rgb (PikaDrawable *drawable);
gboolean pika_drawable_is_gray (PikaDrawable *drawable);
gboolean pika_drawable_is_indexed (PikaDrawable *drawable);
gint pika_drawable_get_bpp (PikaDrawable *drawable);
gint pika_drawable_get_width (PikaDrawable *drawable);
gint pika_drawable_get_height (PikaDrawable *drawable);
gboolean pika_drawable_get_offsets (PikaDrawable *drawable,
gint *offset_x,
gint *offset_y);
gboolean pika_drawable_mask_bounds (PikaDrawable *drawable,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gboolean pika_drawable_mask_intersect (PikaDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height);
gboolean pika_drawable_merge_shadow (PikaDrawable *drawable,
gboolean undo);
gboolean pika_drawable_free_shadow (PikaDrawable *drawable);
gboolean pika_drawable_update (PikaDrawable *drawable,
gint x,
gint y,
gint width,
gint height);
gboolean pika_drawable_fill (PikaDrawable *drawable,
PikaFillType fill_type);
gboolean pika_drawable_offset (PikaDrawable *drawable,
gboolean wrap_around,
PikaOffsetType fill_type,
gint offset_x,
gint offset_y);
G_GNUC_INTERNAL gboolean _pika_drawable_thumbnail (PikaDrawable *drawable,
gint width,
gint height,
gint *actual_width,
gint *actual_height,
gint *bpp,
GBytes **thumbnail_data);
G_GNUC_INTERNAL gboolean _pika_drawable_sub_thumbnail (PikaDrawable *drawable,
gint src_x,
gint src_y,
gint src_width,
gint src_height,
gint dest_width,
gint dest_height,
gint *width,
gint *height,
gint *bpp,
GBytes **thumbnail_data);
gboolean pika_drawable_foreground_extract (PikaDrawable *drawable,
PikaForegroundExtractMode mode,
PikaDrawable *mask);
G_END_DECLS
#endif /* __PIKA_DRAWABLE_PDB_H__ */

View File

@ -0,0 +1,849 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawablecolor_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadrawablecolor
* @title: pikadrawablecolor
* @short_description: Functions for manipulating a drawable's color.
*
* Functions for manipulating a drawable's color, including curves and
* histograms.
**/
/**
* pika_drawable_brightness_contrast:
* @drawable: The drawable.
* @brightness: Brightness adjustment.
* @contrast: Contrast adjustment.
*
* Modify brightness/contrast in the specified drawable.
*
* This procedures allows the brightness and contrast of the specified
* drawable to be modified. Both 'brightness' and 'contrast' parameters
* are defined between -1.0 and 1.0.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_brightness_contrast (PikaDrawable *drawable,
gdouble brightness,
gdouble contrast)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_DOUBLE, brightness,
G_TYPE_DOUBLE, contrast,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-brightness-contrast",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_color_balance:
* @drawable: The drawable.
* @transfer_mode: Transfer mode.
* @preserve_lum: Preserve luminosity values at each pixel.
* @cyan_red: Cyan-Red color balance.
* @magenta_green: Magenta-Green color balance.
* @yellow_blue: Yellow-Blue color balance.
*
* Modify the color balance of the specified drawable.
*
* Modify the color balance of the specified drawable. There are three
* axis which can be modified: cyan-red, magenta-green, and
* yellow-blue. Negative values increase the amount of the former,
* positive values increase the amount of the latter. Color balance can
* be controlled with the 'transfer_mode' setting, which allows
* shadows, mid-tones, and highlights in an image to be affected
* differently. The 'preserve-lum' parameter, if TRUE, ensures that the
* luminosity of each pixel remains fixed.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_color_balance (PikaDrawable *drawable,
PikaTransferMode transfer_mode,
gboolean preserve_lum,
gdouble cyan_red,
gdouble magenta_green,
gdouble yellow_blue)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_TRANSFER_MODE, transfer_mode,
G_TYPE_BOOLEAN, preserve_lum,
G_TYPE_DOUBLE, cyan_red,
G_TYPE_DOUBLE, magenta_green,
G_TYPE_DOUBLE, yellow_blue,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-color-balance",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_colorize_hsl:
* @drawable: The drawable.
* @hue: Hue in degrees.
* @saturation: Saturation in percent.
* @lightness: Lightness in percent.
*
* Render the drawable as a grayscale image seen through a colored
* glass.
*
* Desaturates the drawable, then tints it with the specified color.
* This tool is only valid on RGB color images. It will not operate on
* grayscale drawables.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_colorize_hsl (PikaDrawable *drawable,
gdouble hue,
gdouble saturation,
gdouble lightness)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_DOUBLE, hue,
G_TYPE_DOUBLE, saturation,
G_TYPE_DOUBLE, lightness,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-colorize-hsl",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_curves_explicit:
* @drawable: The drawable.
* @channel: The channel to modify.
* @num_values: The number of values in the new curve.
* @values: (array length=num_values) (element-type gdouble): The explicit curve.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The channel can be either an intensity component, or the
* value. The 'values' parameter is an array of doubles which
* explicitly defines how each pixel value in the drawable will be
* modified. Use the pika_drawable_curves_spline() function to modify
* intensity levels with Catmull Rom splines.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_curves_explicit (PikaDrawable *drawable,
PikaHistogramChannel channel,
gint num_values,
const gdouble *values)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HISTOGRAM_CHANNEL, channel,
G_TYPE_INT, num_values,
PIKA_TYPE_FLOAT_ARRAY, NULL,
G_TYPE_NONE);
pika_value_set_float_array (pika_value_array_index (args, 3), values, num_values);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-curves-explicit",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_curves_spline:
* @drawable: The drawable.
* @channel: The channel to modify.
* @num_points: The number of values in the control point array.
* @points: (array length=num_points) (element-type gdouble): The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y, ... }.
*
* Modifies the intensity curve(s) for specified drawable.
*
* Modifies the intensity mapping for one channel in the specified
* drawable. The channel can be either an intensity component, or the
* value. The 'points' parameter is an array of doubles which define a
* set of control points which describe a Catmull Rom spline which
* yields the final intensity curve. Use the
* pika_drawable_curves_explicit() function to explicitly modify
* intensity levels.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_curves_spline (PikaDrawable *drawable,
PikaHistogramChannel channel,
gint num_points,
const gdouble *points)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HISTOGRAM_CHANNEL, channel,
G_TYPE_INT, num_points,
PIKA_TYPE_FLOAT_ARRAY, NULL,
G_TYPE_NONE);
pika_value_set_float_array (pika_value_array_index (args, 3), points, num_points);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-curves-spline",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_extract_component:
* @drawable: The drawable.
* @component: Component (RGB Red (0), RGB Green (1), RGB Blue (2), Hue (3), HSV Saturation (4), HSV Value (5), HSL Saturation (6), HSL Lightness (7), CMYK Cyan (8), CMYK Magenta (9), CMYK Yellow (10), CMYK Key (11), Y'CbCr Y' (12), Y'CbCr Cb (13), Y'CbCr Cr (14), LAB L (15), LAB A (16), LAB B (17), LCH C(ab) (18), LCH H(ab) (19), Alpha (20)).
* @invert: Invert the extracted component.
* @linear: Use linear output instead of gamma corrected.
*
* Extract a color model component.
*
* Extract a color model component.
*
* Returns: TRUE on success.
*
* Since: 2.10.34
**/
gboolean
pika_drawable_extract_component (PikaDrawable *drawable,
gint component,
gboolean invert,
gboolean linear)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_INT, component,
G_TYPE_BOOLEAN, invert,
G_TYPE_BOOLEAN, linear,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-extract-component",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_desaturate:
* @drawable: The drawable.
* @desaturate_mode: The formula to use to desaturate.
*
* Desaturate the contents of the specified drawable, with the
* specified formula.
*
* This procedure desaturates the contents of the specified drawable,
* with the specified formula. This procedure only works on drawables
* of type RGB color.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_desaturate (PikaDrawable *drawable,
PikaDesaturateMode desaturate_mode)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_DESATURATE_MODE, desaturate_mode,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-desaturate",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_equalize:
* @drawable: The drawable.
* @mask_only: Equalization option.
*
* Equalize the contents of the specified drawable.
*
* This procedure equalizes the contents of the specified drawable.
* Each intensity channel is equalized independently. The equalized
* intensity is given as inten' = (255 - inten). The 'mask_only' option
* specifies whether to adjust only the area of the image within the
* selection bounds, or the entire image based on the histogram of the
* selected area. If there is no selection, the entire image is
* adjusted based on the histogram for the entire image.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_equalize (PikaDrawable *drawable,
gboolean mask_only)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_BOOLEAN, mask_only,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-equalize",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_histogram:
* @drawable: The drawable.
* @channel: The channel to query.
* @start_range: Start of the intensity measurement range.
* @end_range: End of the intensity measurement range.
* @mean: (out): Mean intensity value.
* @std_dev: (out): Standard deviation of intensity values.
* @median: (out): Median intensity value.
* @pixels: (out): Alpha-weighted pixel count for entire image.
* @count: (out): Alpha-weighted pixel count for range.
* @percentile: (out): Percentile that range falls under.
*
* Returns information on the intensity histogram for the specified
* drawable.
*
* This tool makes it possible to gather information about the
* intensity histogram of a drawable. A channel to examine is first
* specified. This can be either value, red, green, or blue, depending
* on whether the drawable is of type color or grayscale. Second, a
* range of intensities are specified. The pika_drawable_histogram()
* function returns statistics based on the pixels in the drawable that
* fall under this range of values. Mean, standard deviation, median,
* number of pixels, and percentile are all returned. Additionally, the
* total count of pixels in the image is returned. Counts of pixels are
* weighted by any associated alpha values and by the current selection
* mask. That is, pixels that lie outside an active selection mask will
* not be counted. Similarly, pixels with transparent alpha values will
* not be counted. The returned mean, std_dev and median are in the
* range (0..255) for 8-bit images or if the plug-in is not
* precision-aware, and in the range (0.0..1.0) otherwise.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_histogram (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble start_range,
gdouble end_range,
gdouble *mean,
gdouble *std_dev,
gdouble *median,
gdouble *pixels,
gdouble *count,
gdouble *percentile)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HISTOGRAM_CHANNEL, channel,
G_TYPE_DOUBLE, start_range,
G_TYPE_DOUBLE, end_range,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-histogram",
args);
pika_value_array_unref (args);
*mean = 0.0;
*std_dev = 0.0;
*median = 0.0;
*pixels = 0.0;
*count = 0.0;
*percentile = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*mean = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
*std_dev = PIKA_VALUES_GET_DOUBLE (return_vals, 2);
*median = PIKA_VALUES_GET_DOUBLE (return_vals, 3);
*pixels = PIKA_VALUES_GET_DOUBLE (return_vals, 4);
*count = PIKA_VALUES_GET_DOUBLE (return_vals, 5);
*percentile = PIKA_VALUES_GET_DOUBLE (return_vals, 6);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_hue_saturation:
* @drawable: The drawable.
* @hue_range: Range of affected hues.
* @hue_offset: Hue offset in degrees.
* @lightness: Lightness modification.
* @saturation: Saturation modification.
* @overlap: Overlap other hue channels.
*
* Modify hue, lightness, and saturation in the specified drawable.
*
* This procedure allows the hue, lightness, and saturation in the
* specified drawable to be modified. The 'hue-range' parameter
* provides the capability to limit range of affected hues. The
* 'overlap' parameter provides blending into neighboring hue channels
* when rendering.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_hue_saturation (PikaDrawable *drawable,
PikaHueRange hue_range,
gdouble hue_offset,
gdouble lightness,
gdouble saturation,
gdouble overlap)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HUE_RANGE, hue_range,
G_TYPE_DOUBLE, hue_offset,
G_TYPE_DOUBLE, lightness,
G_TYPE_DOUBLE, saturation,
G_TYPE_DOUBLE, overlap,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-hue-saturation",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_invert:
* @drawable: The drawable.
* @linear: Whether to invert in linear space.
*
* Invert the contents of the specified drawable.
*
* This procedure inverts the contents of the specified drawable. Each
* intensity channel is inverted independently. The inverted intensity
* is given as inten' = (255 - inten). If 'linear' is TRUE, the
* drawable is inverted in linear space.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_invert (PikaDrawable *drawable,
gboolean linear)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_BOOLEAN, linear,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-invert",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_levels:
* @drawable: The drawable.
* @channel: The channel to modify.
* @low_input: Intensity of lowest input.
* @high_input: Intensity of highest input.
* @clamp_input: Clamp input values before applying output levels.
* @gamma: Gamma adjustment factor.
* @low_output: Intensity of lowest output.
* @high_output: Intensity of highest output.
* @clamp_output: Clamp final output values.
*
* Modifies intensity levels in the specified drawable.
*
* This tool allows intensity levels in the specified drawable to be
* remapped according to a set of parameters. The low/high input levels
* specify an initial mapping from the source intensities. The gamma
* value determines how intensities between the low and high input
* intensities are interpolated. A gamma value of 1.0 results in a
* linear interpolation. Higher gamma values result in more high-level
* intensities. Lower gamma values result in more low-level
* intensities. The low/high output levels constrain the final
* intensity mapping--that is, no final intensity will be lower than
* the low output level and no final intensity will be higher than the
* high output level. This tool is only valid on RGB color and
* grayscale images.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_levels (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble low_input,
gdouble high_input,
gboolean clamp_input,
gdouble gamma,
gdouble low_output,
gdouble high_output,
gboolean clamp_output)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HISTOGRAM_CHANNEL, channel,
G_TYPE_DOUBLE, low_input,
G_TYPE_DOUBLE, high_input,
G_TYPE_BOOLEAN, clamp_input,
G_TYPE_DOUBLE, gamma,
G_TYPE_DOUBLE, low_output,
G_TYPE_DOUBLE, high_output,
G_TYPE_BOOLEAN, clamp_output,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-levels",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_levels_stretch:
* @drawable: The drawable.
*
* Automatically modifies intensity levels in the specified drawable.
*
* This procedure allows intensity levels in the specified drawable to
* be remapped according to a set of guessed parameters. It is
* equivalent to clicking the \"Auto\" button in the Levels tool.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_levels_stretch (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-levels-stretch",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_shadows_highlights:
* @drawable: The drawable.
* @shadows: Adjust exposure of shadows.
* @highlights: Adjust exposure of highlights.
* @whitepoint: Shift white point.
* @radius: Spatial extent.
* @compress: Compress the effect on shadows/highlights and preserve midtones.
* @shadows_ccorrect: Adjust saturation of shadows.
* @highlights_ccorrect: Adjust saturation of highlights.
*
* Perform shadows and highlights correction.
*
* This filter allows adjusting shadows and highlights in the image
* separately. The implementation closely follow its counterpart in the
* Darktable photography software.
*
* Returns: TRUE on success.
*
* Since: 2.10.34
**/
gboolean
pika_drawable_shadows_highlights (PikaDrawable *drawable,
gdouble shadows,
gdouble highlights,
gdouble whitepoint,
gdouble radius,
gdouble compress,
gdouble shadows_ccorrect,
gdouble highlights_ccorrect)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_DOUBLE, shadows,
G_TYPE_DOUBLE, highlights,
G_TYPE_DOUBLE, whitepoint,
G_TYPE_DOUBLE, radius,
G_TYPE_DOUBLE, compress,
G_TYPE_DOUBLE, shadows_ccorrect,
G_TYPE_DOUBLE, highlights_ccorrect,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-shadows-highlights",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_posterize:
* @drawable: The drawable.
* @levels: Levels of posterization.
*
* Posterize the specified drawable.
*
* This procedures reduces the number of shades allows in each
* intensity channel to the specified 'levels' parameter.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_posterize (PikaDrawable *drawable,
gint levels)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_INT, levels,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-posterize",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_threshold:
* @drawable: The drawable.
* @channel: The channel to base the threshold on.
* @low_threshold: The low threshold value.
* @high_threshold: The high threshold value.
*
* Threshold the specified drawable.
*
* This procedures generates a threshold map of the specified drawable.
* All pixels between the values of 'low_threshold' and
* 'high_threshold', on the scale of 'channel' are replaced with white,
* and all other pixels with black.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_threshold (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble low_threshold,
gdouble high_threshold)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_HISTOGRAM_CHANNEL, channel,
G_TYPE_DOUBLE, low_threshold,
G_TYPE_DOUBLE, high_threshold,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-threshold",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,110 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawablecolor_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DRAWABLE_COLOR_PDB_H__
#define __PIKA_DRAWABLE_COLOR_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_drawable_brightness_contrast (PikaDrawable *drawable,
gdouble brightness,
gdouble contrast);
gboolean pika_drawable_color_balance (PikaDrawable *drawable,
PikaTransferMode transfer_mode,
gboolean preserve_lum,
gdouble cyan_red,
gdouble magenta_green,
gdouble yellow_blue);
gboolean pika_drawable_colorize_hsl (PikaDrawable *drawable,
gdouble hue,
gdouble saturation,
gdouble lightness);
gboolean pika_drawable_curves_explicit (PikaDrawable *drawable,
PikaHistogramChannel channel,
gint num_values,
const gdouble *values);
gboolean pika_drawable_curves_spline (PikaDrawable *drawable,
PikaHistogramChannel channel,
gint num_points,
const gdouble *points);
gboolean pika_drawable_extract_component (PikaDrawable *drawable,
gint component,
gboolean invert,
gboolean linear);
gboolean pika_drawable_desaturate (PikaDrawable *drawable,
PikaDesaturateMode desaturate_mode);
gboolean pika_drawable_equalize (PikaDrawable *drawable,
gboolean mask_only);
gboolean pika_drawable_histogram (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble start_range,
gdouble end_range,
gdouble *mean,
gdouble *std_dev,
gdouble *median,
gdouble *pixels,
gdouble *count,
gdouble *percentile);
gboolean pika_drawable_hue_saturation (PikaDrawable *drawable,
PikaHueRange hue_range,
gdouble hue_offset,
gdouble lightness,
gdouble saturation,
gdouble overlap);
gboolean pika_drawable_invert (PikaDrawable *drawable,
gboolean linear);
gboolean pika_drawable_levels (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble low_input,
gdouble high_input,
gboolean clamp_input,
gdouble gamma,
gdouble low_output,
gdouble high_output,
gboolean clamp_output);
gboolean pika_drawable_levels_stretch (PikaDrawable *drawable);
gboolean pika_drawable_shadows_highlights (PikaDrawable *drawable,
gdouble shadows,
gdouble highlights,
gdouble whitepoint,
gdouble radius,
gdouble compress,
gdouble shadows_ccorrect,
gdouble highlights_ccorrect);
gboolean pika_drawable_posterize (PikaDrawable *drawable,
gint levels);
gboolean pika_drawable_threshold (PikaDrawable *drawable,
PikaHistogramChannel channel,
gdouble low_threshold,
gdouble high_threshold);
G_END_DECLS
#endif /* __PIKA_DRAWABLE_COLOR_PDB_H__ */

View File

@ -0,0 +1,346 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawableedit_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadrawableedit
* @title: pikadrawableedit
* @short_description: Drawable edit functions (clear, fill, gradient, stroke etc.)
*
* Drawable edit functions (clear, fill, gradient, stroke etc.)
**/
/**
* pika_drawable_edit_clear:
* @drawable: The drawable to clear from.
*
* Clear selected area of drawable.
*
* This procedure clears the specified drawable. If the drawable has an
* alpha channel, the cleared pixels will become transparent. If the
* drawable does not have an alpha channel, cleared pixels will be set
* to the background color. This procedure only affects regions within
* a selection if there is a selection active.
*
* This procedure is affected by the following context setters:
* pika_context_set_background().
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_edit_clear (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-clear",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_edit_fill:
* @drawable: The drawable to fill to.
* @fill_type: The type of fill.
*
* Fill selected area of drawable.
*
* This procedure fills the specified drawable according to fill mode.
* This procedure only affects regions within a selection if there is a
* selection active. If you want to fill the whole drawable, regardless
* of the selection, use pika_drawable_fill().
*
* This procedure is affected by the following context setters:
* pika_context_set_opacity(), pika_context_set_paint_mode(),
* pika_context_set_foreground(), pika_context_set_background(),
* pika_context_set_pattern().
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_edit_fill (PikaDrawable *drawable,
PikaFillType fill_type)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_FILL_TYPE, fill_type,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-fill",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_edit_bucket_fill:
* @drawable: The affected drawable.
* @fill_type: The type of fill.
* @x: The x coordinate of this bucket fill's application.
* @y: The y coordinate of this bucket fill's application.
*
* Fill the area by a seed fill starting at the specified coordinates.
*
* This procedure does a seed fill at the specified coordinates, using
* various parameters from the current context.
* In the case of merged sampling, the x and y coordinates are relative
* to the image's origin; otherwise, they are relative to the
* drawable's origin.
*
* This procedure is affected by the following context setters:
* pika_context_set_opacity(), pika_context_set_paint_mode(),
* pika_context_set_foreground(), pika_context_set_background(),
* pika_context_set_pattern(), pika_context_set_sample_threshold(),
* pika_context_set_sample_merged(),
* pika_context_set_sample_criterion(),
* pika_context_set_diagonal_neighbors(), pika_context_set_antialias().
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_edit_bucket_fill (PikaDrawable *drawable,
PikaFillType fill_type,
gdouble x,
gdouble y)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_FILL_TYPE, fill_type,
G_TYPE_DOUBLE, x,
G_TYPE_DOUBLE, y,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-bucket-fill",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_edit_gradient_fill:
* @drawable: The affected drawable.
* @gradient_type: The type of gradient.
* @offset: Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode dependent.
* @supersample: Do adaptive supersampling.
* @supersample_max_depth: Maximum recursion levels for supersampling.
* @supersample_threshold: Supersampling threshold.
* @dither: Use dithering to reduce banding.
* @x1: The x coordinate of this gradient's starting point.
* @y1: The y coordinate of this gradient's starting point.
* @x2: The x coordinate of this gradient's ending point.
* @y2: The y coordinate of this gradient's ending point.
*
* Draw a gradient between the starting and ending coordinates with the
* specified gradient type.
*
* This tool requires information on the gradient type. It creates the
* specified variety of gradient using the starting and ending
* coordinates as defined for each gradient type. For shapeburst
* gradient types, the context's distance metric is also relevant and
* can be updated with pika_context_set_distance_metric().
*
* This procedure is affected by the following context setters:
* pika_context_set_opacity(), pika_context_set_paint_mode(),
* pika_context_set_foreground(), pika_context_set_background(),
* pika_context_set_gradient() and all gradient property settings,
* pika_context_set_distance_metric().
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_edit_gradient_fill (PikaDrawable *drawable,
PikaGradientType gradient_type,
gdouble offset,
gboolean supersample,
gint supersample_max_depth,
gdouble supersample_threshold,
gboolean dither,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_GRADIENT_TYPE, gradient_type,
G_TYPE_DOUBLE, offset,
G_TYPE_BOOLEAN, supersample,
G_TYPE_INT, supersample_max_depth,
G_TYPE_DOUBLE, supersample_threshold,
G_TYPE_BOOLEAN, dither,
G_TYPE_DOUBLE, x1,
G_TYPE_DOUBLE, y1,
G_TYPE_DOUBLE, x2,
G_TYPE_DOUBLE, y2,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-gradient-fill",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_edit_stroke_selection:
* @drawable: The drawable to stroke to.
*
* Stroke the current selection
*
* This procedure strokes the current selection, painting along the
* selection boundary with the active paint method and brush, or using
* a plain line with configurable properties. The paint is applied to
* the specified drawable regardless of the active selection.
*
* This procedure is affected by the following context setters:
* pika_context_set_opacity(), pika_context_set_paint_mode(),
* pika_context_set_paint_method(), pika_context_set_stroke_method(),
* pika_context_set_foreground(), pika_context_set_brush() and all
* brush property settings, pika_context_set_gradient() and all
* gradient property settings, pika_context_set_line_width() and all
* line property settings, pika_context_set_antialias().
*
* Returns: TRUE on success.
**/
gboolean
pika_drawable_edit_stroke_selection (PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-stroke-selection",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_drawable_edit_stroke_item:
* @drawable: The drawable to stroke to.
* @item: The item to stroke.
*
* Stroke the specified item
*
* This procedure strokes the specified item, painting along its
* outline (e.g. along a path, or along a channel's boundary), with the
* active paint method and brush, or using a plain line with
* configurable properties.
*
* This procedure is affected by the following context setters:
* pika_context_set_opacity(), pika_context_set_paint_mode(),
* pika_context_set_paint_method(), pika_context_set_stroke_method(),
* pika_context_set_foreground(), pika_context_set_brush() and all
* brush property settings, pika_context_set_gradient() and all
* gradient property settings, pika_context_set_line_width() and all
* line property settings, pika_context_set_antialias().
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_drawable_edit_stroke_item (PikaDrawable *drawable,
PikaItem *item)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
PIKA_TYPE_ITEM, item,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-drawable-edit-stroke-item",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,60 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadrawableedit_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DRAWABLE_EDIT_PDB_H__
#define __PIKA_DRAWABLE_EDIT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_drawable_edit_clear (PikaDrawable *drawable);
gboolean pika_drawable_edit_fill (PikaDrawable *drawable,
PikaFillType fill_type);
gboolean pika_drawable_edit_bucket_fill (PikaDrawable *drawable,
PikaFillType fill_type,
gdouble x,
gdouble y);
gboolean pika_drawable_edit_gradient_fill (PikaDrawable *drawable,
PikaGradientType gradient_type,
gdouble offset,
gboolean supersample,
gint supersample_max_depth,
gdouble supersample_threshold,
gboolean dither,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
gboolean pika_drawable_edit_stroke_selection (PikaDrawable *drawable);
gboolean pika_drawable_edit_stroke_item (PikaDrawable *drawable,
PikaItem *item);
G_END_DECLS
#endif /* __PIKA_DRAWABLE_EDIT_PDB_H__ */

View File

@ -0,0 +1,635 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikadrawablepreview.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pikauitypes.h"
#include "pika.h"
#include "pikadrawablepreview.h"
/**
* SECTION: pikadrawablepreview
* @title: PikaDrawablePreview
* @short_description: A widget providing a preview of a #PikaDrawable.
*
* A widget providing a preview of a #PikaDrawable.
**/
#define SELECTION_BORDER 8
enum
{
PROP_0,
PROP_DRAWABLE
};
typedef struct
{
gint x;
gint y;
gboolean update;
} PreviewSettings;
struct _PikaDrawablePreviewPrivate
{
PikaDrawable *drawable;
};
#define GET_PRIVATE(obj) (((PikaDrawablePreview *) (obj))->priv)
static void pika_drawable_preview_constructed (GObject *object);
static void pika_drawable_preview_dispose (GObject *object);
static void pika_drawable_preview_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void pika_drawable_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_drawable_preview_style_updated (GtkWidget *widget);
static void pika_drawable_preview_draw_original (PikaPreview *preview);
static void pika_drawable_preview_draw_thumb (PikaPreview *preview,
PikaPreviewArea *area,
gint width,
gint height);
static void pika_drawable_preview_draw_buffer (PikaPreview *preview,
const guchar *buffer,
gint rowstride);
static void pika_drawable_preview_set_drawable (PikaDrawablePreview *preview,
PikaDrawable *drawable);
G_DEFINE_TYPE_WITH_PRIVATE (PikaDrawablePreview, pika_drawable_preview,
PIKA_TYPE_SCROLLED_PREVIEW)
#define parent_class pika_drawable_preview_parent_class
static gint pika_drawable_preview_counter = 0;
static void
pika_drawable_preview_class_init (PikaDrawablePreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
PikaPreviewClass *preview_class = PIKA_PREVIEW_CLASS (klass);
object_class->constructed = pika_drawable_preview_constructed;
object_class->dispose = pika_drawable_preview_dispose;
object_class->get_property = pika_drawable_preview_get_property;
object_class->set_property = pika_drawable_preview_set_property;
widget_class->style_updated = pika_drawable_preview_style_updated;
preview_class->draw = pika_drawable_preview_draw_original;
preview_class->draw_thumb = pika_drawable_preview_draw_thumb;
preview_class->draw_buffer = pika_drawable_preview_draw_buffer;
/**
* PikaDrawablePreview:drawable-id:
*
* The drawable the #PikaDrawablePreview is attached to.
*
* Since: 2.10
*/
g_object_class_install_property (object_class, PROP_DRAWABLE,
g_param_spec_object ("drawable",
"Drawable",
"The drawable this preview is attached to",
PIKA_TYPE_DRAWABLE,
PIKA_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
pika_drawable_preview_init (PikaDrawablePreview *preview)
{
preview->priv = pika_drawable_preview_get_instance_private (preview);
g_object_set (pika_preview_get_area (PIKA_PREVIEW (preview)),
"check-size", pika_check_size (),
"check-type", pika_check_type (),
"check-custom-color1", pika_check_custom_color1 (),
"check-custom-color2", pika_check_custom_color2 (),
NULL);
}
static void
pika_drawable_preview_constructed (GObject *object)
{
gchar *data_name;
PreviewSettings settings;
G_OBJECT_CLASS (parent_class)->constructed (object);
data_name = g_strdup_printf ("%s-drawable-preview-%d",
g_get_prgname (),
++pika_drawable_preview_counter);
if (pika_get_data (data_name, &settings))
{
pika_preview_set_update (PIKA_PREVIEW (object), settings.update);
pika_scrolled_preview_set_position (PIKA_SCROLLED_PREVIEW (object),
settings.x, settings.y);
}
g_object_set_data_full (object, "pika-drawable-preview-data-name",
data_name, (GDestroyNotify) g_free);
}
static void
pika_drawable_preview_dispose (GObject *object)
{
PikaDrawablePreviewPrivate *priv = GET_PRIVATE (object);
const gchar *data_name;
data_name = g_object_get_data (G_OBJECT (object),
"pika-drawable-preview-data-name");
if (data_name)
{
PikaPreview *preview = PIKA_PREVIEW (object);
PreviewSettings settings;
pika_preview_get_position (preview, &settings.x, &settings.y);
settings.update = pika_preview_get_update (preview);
pika_set_data (data_name, &settings, sizeof (PreviewSettings));
}
g_clear_object (&priv->drawable);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
pika_drawable_preview_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaDrawablePreview *preview = PIKA_DRAWABLE_PREVIEW (object);
switch (property_id)
{
case PROP_DRAWABLE:
g_value_set_object (value,
pika_drawable_preview_get_drawable (preview));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_drawable_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaDrawablePreview *preview = PIKA_DRAWABLE_PREVIEW (object);
switch (property_id)
{
case PROP_DRAWABLE:
pika_drawable_preview_set_drawable (preview,
g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_drawable_preview_style_updated (GtkWidget *widget)
{
PikaPreview *preview = PIKA_PREVIEW (widget);
GtkWidget *area = pika_preview_get_area (preview);
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
if (area)
{
gint xmin, ymin;
gint xmax, ymax;
gint size;
pika_preview_get_bounds (preview, &xmin, &ymin, &xmax, &ymax);
gtk_widget_style_get (widget,
"size", &size,
NULL);
gtk_widget_set_size_request (area,
MIN (xmax - xmin, size),
MIN (ymax - ymin, size));
}
}
static void
pika_drawable_preview_draw_original (PikaPreview *preview)
{
PikaDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
GBytes *buffer;
gint width, height;
gint tn_width, tn_height;
gint xoff, yoff;
gint xmin, ymin;
gint xmax, ymax;
gint bpp;
PikaImageType type;
if (priv->drawable == NULL)
return;
pika_preview_get_size (preview, &width, &height);
pika_preview_get_offsets (preview, &xoff, &yoff);
pika_preview_get_bounds (preview, &xmin, &ymin, &xmax, &ymax);
xoff = CLAMP (xoff, 0, xmax - xmin - width);
yoff = CLAMP (yoff, 0, ymax - ymin - height);
pika_preview_set_offsets (preview, xoff, yoff);
buffer = pika_drawable_get_sub_thumbnail_data (priv->drawable,
xoff + xmin,
yoff + ymin,
width, height,
width, height,
&tn_width, &tn_height, &bpp);
switch (bpp)
{
case 1: type = PIKA_GRAY_IMAGE; break;
case 2: type = PIKA_GRAYA_IMAGE; break;
case 3: type = PIKA_RGB_IMAGE; break;
case 4: type = PIKA_RGBA_IMAGE; break;
default:
g_bytes_unref (buffer);
return;
}
pika_preview_area_draw (PIKA_PREVIEW_AREA (pika_preview_get_area (preview)),
0, 0, tn_width, tn_height, type,
g_bytes_get_data (buffer, NULL), width * bpp);
g_bytes_unref (buffer);
}
static void
pika_drawable_preview_draw_thumb (PikaPreview *preview,
PikaPreviewArea *area,
gint width,
gint height)
{
PikaDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
if (priv->drawable)
_pika_drawable_preview_area_draw_thumb (area, priv->drawable,
width, height);
}
void
_pika_drawable_preview_area_draw_thumb (PikaPreviewArea *area,
PikaDrawable *drawable,
gint width,
gint height)
{
GBytes *buffer;
gint x1, y1, x2, y2;
gint bpp;
gint size = 100;
gint nav_width, nav_height;
gint tn_width, tn_height;
g_return_if_fail (PIKA_IS_PREVIEW_AREA (area));
g_return_if_fail (pika_item_is_valid (PIKA_ITEM (drawable)));
g_return_if_fail (pika_item_is_drawable (PIKA_ITEM (drawable)));
if (_pika_drawable_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
{
width = x2 - x1;
height = y2 - y1;
}
else
{
width = pika_drawable_get_width (drawable);
height = pika_drawable_get_height (drawable);
}
if (width > height)
{
nav_width = MIN (width, size);
nav_height = (height * nav_width) / width;
}
else
{
nav_height = MIN (height, size);
nav_width = (width * nav_height) / height;
}
if (_pika_drawable_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
{
buffer = pika_drawable_get_sub_thumbnail_data (drawable,
x1, y1, x2 - x1, y2 - y1,
nav_width, nav_height,
&tn_width, &tn_height,
&bpp);
}
else
{
buffer = pika_drawable_get_thumbnail_data (drawable,
nav_width, nav_height,
&tn_width, &tn_height,
&bpp);
}
if (buffer)
{
PikaImageType type;
gtk_widget_set_size_request (GTK_WIDGET (area), tn_width, tn_height);
gtk_widget_show (GTK_WIDGET (area));
gtk_widget_realize (GTK_WIDGET (area));
switch (bpp)
{
case 1: type = PIKA_GRAY_IMAGE; break;
case 2: type = PIKA_GRAYA_IMAGE; break;
case 3: type = PIKA_RGB_IMAGE; break;
case 4: type = PIKA_RGBA_IMAGE; break;
default:
g_bytes_unref (buffer);
return;
}
pika_preview_area_draw (area,
0, 0, tn_width, tn_height,
type,
g_bytes_get_data (buffer, NULL), bpp * tn_width);
g_bytes_unref (buffer);
}
}
static void
pika_drawable_preview_draw_area (PikaDrawablePreview *preview,
gint x,
gint y,
gint width,
gint height,
const guchar *buf,
gint rowstride)
{
PikaDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
PikaPreview *pika_preview = PIKA_PREVIEW (preview);
GtkWidget *area = pika_preview_get_area (pika_preview);
PikaImage *image;
gint xmin, ymin;
gint xoff, yoff;
pika_preview_get_bounds (pika_preview, &xmin, &ymin, NULL, NULL);
pika_preview_get_offsets (pika_preview, &xoff, &yoff);
image = pika_item_get_image (PIKA_ITEM (priv->drawable));
if (pika_selection_is_empty (image))
{
pika_preview_area_draw (PIKA_PREVIEW_AREA (area),
x - xoff - xmin,
y - yoff - ymin,
width,
height,
pika_drawable_type (priv->drawable),
buf, rowstride);
}
else
{
gint offset_x, offset_y;
gint mask_x, mask_y;
gint mask_width, mask_height;
gint draw_x, draw_y;
gint draw_width, draw_height;
pika_drawable_get_offsets (priv->drawable, &offset_x, &offset_y);
if (pika_drawable_mask_intersect (priv->drawable,
&mask_x, &mask_y,
&mask_width, &mask_height) &&
pika_rectangle_intersect (mask_x, mask_y,
mask_width, mask_height,
x, y, width, height,
&draw_x, &draw_y,
&draw_width, &draw_height))
{
PikaImageType type;
PikaSelection *selection;
GBytes *src;
GBytes *sel;
gint d_w, d_h, d_bpp;
gint s_w, s_h, s_bpp;
selection = pika_image_get_selection (image);
src = pika_drawable_get_sub_thumbnail_data (priv->drawable,
draw_x, draw_y,
draw_width, draw_height,
draw_width, draw_height,
&d_w, &d_h,
&d_bpp);
sel = pika_drawable_get_sub_thumbnail_data (PIKA_DRAWABLE (selection),
draw_x + offset_x,
draw_y + offset_y,
draw_width, draw_height,
draw_width, draw_height,
&s_w, &s_h,
&s_bpp);
switch (d_bpp)
{
case 1: type = PIKA_GRAY_IMAGE; break;
case 2: type = PIKA_GRAYA_IMAGE; break;
case 3: type = PIKA_RGB_IMAGE; break;
case 4: type = PIKA_RGBA_IMAGE; break;
default:
g_bytes_unref (sel);
g_bytes_unref (src);
return;
}
pika_preview_area_mask (PIKA_PREVIEW_AREA (area),
draw_x - xoff - xmin,
draw_y - yoff - ymin,
draw_width,
draw_height,
type,
g_bytes_get_data (src, NULL), draw_width * d_bpp,
(buf +
(draw_x - x) * d_bpp +
(draw_y - y) * d_w * d_bpp),
rowstride,
g_bytes_get_data (sel, NULL), s_w);
g_bytes_unref (sel);
g_bytes_unref (src);
}
}
}
static void
pika_drawable_preview_draw_buffer (PikaPreview *preview,
const guchar *buffer,
gint rowstride)
{
gint x, y;
gint width, height;
pika_preview_get_position (preview, &x, &y);
pika_preview_get_size (preview, &width, &height);
pika_drawable_preview_draw_area (PIKA_DRAWABLE_PREVIEW (preview),
x, y,
width, height,
buffer, rowstride);
}
static void
pika_drawable_preview_set_drawable (PikaDrawablePreview *drawable_preview,
PikaDrawable *drawable)
{
PikaPreview *preview = PIKA_PREVIEW (drawable_preview);
PikaDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
gint x1, y1, x2, y2;
g_return_if_fail (priv->drawable == NULL);
priv->drawable = drawable;
_pika_drawable_preview_get_bounds (drawable, &x1, &y1, &x2, &y2);
pika_preview_set_bounds (preview, x1, y1, x2, y2);
if (pika_drawable_is_indexed (drawable))
{
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
GtkWidget *area = pika_preview_get_area (preview);
guchar *cmap;
gint num_colors;
cmap = pika_image_get_colormap (image, NULL, &num_colors);
pika_preview_area_set_colormap (PIKA_PREVIEW_AREA (area),
cmap, num_colors);
g_free (cmap);
}
}
#define MAX3(a, b, c) (MAX (MAX ((a), (b)), (c)))
#define MIN3(a, b, c) (MIN (MIN ((a), (b)), (c)))
gboolean
_pika_drawable_preview_get_bounds (PikaDrawable *drawable,
gint *xmin,
gint *ymin,
gint *xmax,
gint *ymax)
{
gint width;
gint height;
gint offset_x;
gint offset_y;
gint x1, y1;
gint x2, y2;
gboolean retval;
g_return_val_if_fail (pika_item_is_valid (PIKA_ITEM (drawable)), FALSE);
g_return_val_if_fail (pika_item_is_drawable (PIKA_ITEM (drawable)), FALSE);
width = pika_drawable_get_width (drawable);
height = pika_drawable_get_height (drawable);
retval = pika_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pika_drawable_get_offsets (drawable, &offset_x, &offset_y);
*xmin = MAX3 (x1 - SELECTION_BORDER, 0, - offset_x);
*ymin = MAX3 (y1 - SELECTION_BORDER, 0, - offset_y);
*xmax = MIN3 (x2 + SELECTION_BORDER, width, width + offset_x);
*ymax = MIN3 (y2 + SELECTION_BORDER, height, height + offset_y);
return retval;
}
/**
* pika_drawable_preview_new_from_drawable:
* @drawable: (transfer none): a drawable
*
* Creates a new #PikaDrawablePreview widget for @drawable.
*
* Returns: A pointer to the new #PikaDrawablePreview widget.
*
* Since: 2.10
**/
GtkWidget *
pika_drawable_preview_new_from_drawable (PikaDrawable *drawable)
{
g_return_val_if_fail (pika_item_is_valid (PIKA_ITEM (drawable)), NULL);
g_return_val_if_fail (pika_item_is_drawable (PIKA_ITEM (drawable)), NULL);
return g_object_new (PIKA_TYPE_DRAWABLE_PREVIEW,
"drawable", drawable,
NULL);
}
/**
* pika_drawable_preview_get_drawable:
* @preview: a #PikaDrawablePreview widget
*
* Returns: (transfer none): the drawable that has been passed to
* pika_drawable_preview_new_from_drawable().
*
* Since: 2.10
**/
PikaDrawable *
pika_drawable_preview_get_drawable (PikaDrawablePreview *preview)
{
g_return_val_if_fail (PIKA_IS_DRAWABLE_PREVIEW (preview), NULL);
return GET_PRIVATE (preview)->drawable;
}

View File

@ -0,0 +1,88 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikadrawablepreview.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_DRAWABLE_PREVIEW_H__
#define __PIKA_DRAWABLE_PREVIEW_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define PIKA_TYPE_DRAWABLE_PREVIEW (pika_drawable_preview_get_type ())
#define PIKA_DRAWABLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DRAWABLE_PREVIEW, PikaDrawablePreview))
#define PIKA_DRAWABLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DRAWABLE_PREVIEW, PikaDrawablePreviewClass))
#define PIKA_IS_DRAWABLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DRAWABLE_PREVIEW))
#define PIKA_IS_DRAWABLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DRAWABLE_PREVIEW))
#define PIKA_DRAWABLE_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_DRAWABLE_PREVIEW, PikaDrawablePreviewClass))
typedef struct _PikaDrawablePreviewPrivate PikaDrawablePreviewPrivate;
typedef struct _PikaDrawablePreviewClass PikaDrawablePreviewClass;
struct _PikaDrawablePreview
{
PikaScrolledPreview parent_instance;
PikaDrawablePreviewPrivate *priv;
};
struct _PikaDrawablePreviewClass
{
PikaScrolledPreviewClass parent_class;
/* Padding for future expansion */
void (* _pika_reserved1) (void);
void (* _pika_reserved2) (void);
void (* _pika_reserved3) (void);
void (* _pika_reserved4) (void);
void (* _pika_reserved5) (void);
void (* _pika_reserved6) (void);
void (* _pika_reserved7) (void);
void (* _pika_reserved8) (void);
};
GType pika_drawable_preview_get_type (void) G_GNUC_CONST;
GtkWidget * pika_drawable_preview_new_from_drawable (PikaDrawable *drawable);
PikaDrawable * pika_drawable_preview_get_drawable (PikaDrawablePreview *preview);
/* for internal use only */
G_GNUC_INTERNAL void _pika_drawable_preview_area_draw_thumb (PikaPreviewArea *area,
PikaDrawable *drawable,
gint width,
gint height);
G_GNUC_INTERNAL gboolean _pika_drawable_preview_get_bounds (PikaDrawable *drawable,
gint *xmin,
gint *ymin,
gint *xmax,
gint *ymax);
G_END_DECLS
#endif /* __PIKA_DRAWABLE_PREVIEW_H__ */

111
libpika/pikadynamics_pdb.c Normal file
View File

@ -0,0 +1,111 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadynamics_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikadynamics
* @title: pikadynamics
* @short_description: Operations related to paint dynamics.
*
* Operations related to paint dynamics.
**/
/**
* pika_dynamics_refresh:
*
* Refresh current paint dynamics. This function always succeeds.
*
* This procedure retrieves all paint dynamics currently in the user's
* paint dynamics path and updates the paint dynamics dialogs
* accordingly.
*
* Returns: TRUE on success.
*
* Since: 2.8
**/
gboolean
pika_dynamics_refresh (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-dynamics-refresh",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_dynamics_get_list:
* @filter: An optional regular expression used to filter the list.
*
* Retrieve the list of loaded paint dynamics.
*
* This procedure returns a list of the paint dynamics that are
* currently available.
*
* Returns: (array zero-terminated=1) (transfer full):
* The list of paint dynamics names.
* The returned value must be freed with g_strfreev().
*
* Since: 2.8
**/
gchar **
pika_dynamics_get_list (const gchar *filter)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **dynamics_list = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, filter,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-dynamics-get-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
dynamics_list = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return dynamics_list;
}

View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikadynamics_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_DYNAMICS_PDB_H__
#define __PIKA_DYNAMICS_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_dynamics_refresh (void);
gchar** pika_dynamics_get_list (const gchar *filter);
G_END_DECLS
#endif /* __PIKA_DYNAMICS_PDB_H__ */

486
libpika/pikaedit_pdb.c Normal file
View File

@ -0,0 +1,486 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaedit_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikaedit
* @title: pikaedit
* @short_description: Edit menu functions (cut, copy, paste, clear, etc.)
*
* Edit menu functions (cut, copy, paste, clear, etc.)
**/
/**
* pika_edit_cut:
* @num_drawables: The number of drawables.
* @drawables: (array length=num_drawables) (element-type PikaItem): The drawables to cut from.
*
* Cut from the specified drawables.
*
* If there is a selection in the image, then the area specified by the
* selection is cut from the specified drawables and placed in an
* internal PIKA edit buffer. It can subsequently be retrieved using
* the pika_edit_paste() command. If there is no selection and only one
* specified drawable, then the specified drawable will be removed and
* its contents stored in the internal PIKA edit buffer. This procedure
* will fail if the selected area lies completely outside the bounds of
* the current drawables and there is nothing to cut from.
*
* Returns: TRUE if the cut was successful, FALSE if there was nothing to copy from.
**/
gboolean
pika_edit_cut (gint num_drawables,
const PikaItem **drawables)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean non_empty = FALSE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, num_drawables,
PIKA_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_NONE);
pika_value_set_object_array (pika_value_array_index (args, 1), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-cut",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
non_empty = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return non_empty;
}
/**
* pika_edit_copy:
* @num_drawables: The number of drawables to save.
* @drawables: (array length=num_drawables) (element-type PikaItem): Drawables to copy from.
*
* Copy from the specified drawables.
*
* If there is a selection in the image, then the area specified by the
* selection is copied from the specified drawables and placed in an
* internal PIKA edit buffer. It can subsequently be retrieved using
* the pika_edit_paste() command. If there is no selection, then the
* specified drawables' contents will be stored in the internal PIKA
* edit buffer. This procedure will fail if the selected area lies
* completely outside the bounds of the current drawables and there is
* nothing to copy from. All the drawables must belong to the same
* image.
*
* Returns: TRUE if the cut was successful, FALSE if there was nothing to copy from.
**/
gboolean
pika_edit_copy (gint num_drawables,
const PikaItem **drawables)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean non_empty = FALSE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, num_drawables,
PIKA_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_NONE);
pika_value_set_object_array (pika_value_array_index (args, 1), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-copy",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
non_empty = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return non_empty;
}
/**
* pika_edit_copy_visible:
* @image: The image to copy from.
*
* Copy from the projection.
*
* If there is a selection in the image, then the area specified by the
* selection is copied from the projection and placed in an internal
* PIKA edit buffer. It can subsequently be retrieved using the
* pika_edit_paste() command. If there is no selection, then the
* projection's contents will be stored in the internal PIKA edit
* buffer.
*
* Returns: TRUE if the copy was successful.
*
* Since: 2.2
**/
gboolean
pika_edit_copy_visible (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean non_empty = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-copy-visible",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
non_empty = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return non_empty;
}
/**
* pika_edit_paste:
* @drawable: The drawable to paste to.
* @paste_into: Clear selection, or paste behind it?
* @num_layers: (out): The newly pasted layers.
*
* Paste buffer to the specified drawable.
*
* This procedure pastes a copy of the internal PIKA edit buffer to the
* specified drawable. The PIKA edit buffer will be empty unless a call
* was previously made to either pika_edit_cut() or pika_edit_copy().
* The \"paste_into\" option specifies whether to clear the current
* image selection, or to paste the buffer \"behind\" the selection.
* This allows the selection to act as a mask for the pasted buffer.
* Anywhere that the selection mask is non-zero, the pasted buffer will
* show through. The pasted data may be a floating selection when
* relevant, layers otherwise. If the image has a floating selection at
* the time of pasting, the old floating selection will be anchored to
* its drawable before the new floating selection is added.
* This procedure returns the new layers (floating or not). If the
* result is a floating selection, it will already be attached to the
* specified drawable, and a subsequent call to floating_sel_attach is
* not needed.
*
* Returns: (array length=num_layers) (element-type PikaLayer) (transfer container):
* The list of pasted layers.
* The returned value must be freed with g_free().
**/
PikaLayer **
pika_edit_paste (PikaDrawable *drawable,
gboolean paste_into,
gint *num_layers)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaLayer **layers = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_BOOLEAN, paste_into,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-paste",
args);
pika_value_array_unref (args);
*num_layers = 0;
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
{
*num_layers = PIKA_VALUES_GET_INT (return_vals, 1);
{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index (return_vals, 2)); if (a) layers = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
}
pika_value_array_unref (return_vals);
return layers;
}
/**
* pika_edit_paste_as_new_image:
*
* Paste buffer to a new image.
*
* This procedure pastes a copy of the internal PIKA edit buffer to a
* new image. The PIKA edit buffer will be empty unless a call was
* previously made to either pika_edit_cut() or pika_edit_copy(). This
* procedure returns the new image or -1 if the edit buffer was empty.
*
* Returns: (transfer none): The new image.
*
* Since: 2.10
**/
PikaImage *
pika_edit_paste_as_new_image (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImage *image = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-paste-as-new-image",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
image = PIKA_VALUES_GET_IMAGE (return_vals, 1);
pika_value_array_unref (return_vals);
return image;
}
/**
* pika_edit_named_cut:
* @num_drawables: The number of drawables.
* @drawables: (array length=num_drawables) (element-type PikaItem): The drawables to cut from.
* @buffer_name: The name of the buffer to create.
*
* Cut into a named buffer.
*
* This procedure works like pika_edit_cut(), but additionally stores
* the cut buffer into a named buffer that will stay available for
* later pasting, regardless of any intermediate copy or cut
* operations.
*
* Returns: (transfer full):
* The real name given to the buffer, or NULL if the cut failed.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gchar *
pika_edit_named_cut (gint num_drawables,
const PikaItem **drawables,
const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *real_name = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, num_drawables,
PIKA_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
pika_value_set_object_array (pika_value_array_index (args, 1), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-named-cut",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
real_name = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return real_name;
}
/**
* pika_edit_named_copy:
* @num_drawables: The number of drawables.
* @drawables: (array length=num_drawables) (element-type PikaItem): The drawables to copy from.
* @buffer_name: The name of the buffer to create.
*
* Copy into a named buffer.
*
* This procedure works like pika_edit_copy(), but additionally stores
* the copied buffer into a named buffer that will stay available for
* later pasting, regardless of any intermediate copy or cut
* operations.
*
* Returns: (transfer full):
* The real name given to the buffer, or NULL if the copy failed.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gchar *
pika_edit_named_copy (gint num_drawables,
const PikaItem **drawables,
const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *real_name = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, num_drawables,
PIKA_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
pika_value_set_object_array (pika_value_array_index (args, 1), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-named-copy",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
real_name = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return real_name;
}
/**
* pika_edit_named_copy_visible:
* @image: The image to copy from.
* @buffer_name: The name of the buffer to create.
*
* Copy from the projection into a named buffer.
*
* This procedure works like pika_edit_copy_visible(), but additionally
* stores the copied buffer into a named buffer that will stay
* available for later pasting, regardless of any intermediate copy or
* cut operations.
*
* Returns: (transfer full):
* The real name given to the buffer, or NULL if the copy failed.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gchar *
pika_edit_named_copy_visible (PikaImage *image,
const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar *real_name = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-named-copy-visible",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
real_name = PIKA_VALUES_DUP_STRING (return_vals, 1);
pika_value_array_unref (return_vals);
return real_name;
}
/**
* pika_edit_named_paste:
* @drawable: The drawable to paste to.
* @buffer_name: The name of the buffer to paste.
* @paste_into: Clear selection, or paste behind it?
*
* Paste named buffer to the specified drawable.
*
* This procedure works like pika_edit_paste() but pastes a named
* buffer instead of the global buffer.
*
* Returns: (transfer none): The new floating selection.
*
* Since: 2.4
**/
PikaLayer *
pika_edit_named_paste (PikaDrawable *drawable,
const gchar *buffer_name,
gboolean paste_into)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaLayer *floating_sel = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_STRING, buffer_name,
G_TYPE_BOOLEAN, paste_into,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-named-paste",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
floating_sel = PIKA_VALUES_GET_LAYER (return_vals, 1);
pika_value_array_unref (return_vals);
return floating_sel;
}
/**
* pika_edit_named_paste_as_new_image:
* @buffer_name: The name of the buffer to paste.
*
* Paste named buffer to a new image.
*
* This procedure works like pika_edit_paste_as_new_image() but pastes
* a named buffer instead of the global buffer.
*
* Returns: (transfer none): The new image.
*
* Since: 2.10
**/
PikaImage *
pika_edit_named_paste_as_new_image (const gchar *buffer_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImage *image = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-edit-named-paste-as-new-image",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
image = PIKA_VALUES_GET_IMAGE (return_vals, 1);
pika_value_array_unref (return_vals);
return image;
}

60
libpika/pikaedit_pdb.h Normal file
View File

@ -0,0 +1,60 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaedit_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_EDIT_PDB_H__
#define __PIKA_EDIT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_edit_cut (gint num_drawables,
const PikaItem **drawables);
gboolean pika_edit_copy (gint num_drawables,
const PikaItem **drawables);
gboolean pika_edit_copy_visible (PikaImage *image);
PikaLayer** pika_edit_paste (PikaDrawable *drawable,
gboolean paste_into,
gint *num_layers);
PikaImage* pika_edit_paste_as_new_image (void);
gchar* pika_edit_named_cut (gint num_drawables,
const PikaItem **drawables,
const gchar *buffer_name);
gchar* pika_edit_named_copy (gint num_drawables,
const PikaItem **drawables,
const gchar *buffer_name);
gchar* pika_edit_named_copy_visible (PikaImage *image,
const gchar *buffer_name);
PikaLayer* pika_edit_named_paste (PikaDrawable *drawable,
const gchar *buffer_name,
gboolean paste_into);
PikaImage* pika_edit_named_paste_as_new_image (const gchar *buffer_name);
G_END_DECLS
#endif /* __PIKA_EDIT_PDB_H__ */

203
libpika/pikaenums.c.tail Normal file
View File

@ -0,0 +1,203 @@
typedef GType (* PikaGetTypeFunc) (void);
static const PikaGetTypeFunc get_type_funcs[] =
{
gegl_distance_metric_get_type,
pika_add_mask_type_get_type,
pika_brush_application_mode_get_type,
pika_brush_generated_shape_get_type,
pika_cap_style_get_type,
pika_channel_ops_get_type,
pika_channel_type_get_type,
pika_clone_type_get_type,
pika_color_management_mode_get_type,
pika_color_rendering_intent_get_type,
pika_color_tag_get_type,
pika_component_type_get_type,
pika_convert_dither_type_get_type,
pika_convert_palette_type_get_type,
pika_convolve_type_get_type,
pika_desaturate_mode_get_type,
pika_dodge_burn_type_get_type,
pika_fill_type_get_type,
pika_foreground_extract_mode_get_type,
pika_gradient_blend_color_space_get_type,
pika_gradient_segment_color_get_type,
pika_gradient_segment_type_get_type,
pika_gradient_type_get_type,
pika_grid_style_get_type,
pika_histogram_channel_get_type,
pika_hue_range_get_type,
pika_icon_type_get_type,
pika_image_base_type_get_type,
pika_image_type_get_type,
pika_ink_blob_type_get_type,
pika_interpolation_type_get_type,
pika_join_style_get_type,
pika_layer_color_space_get_type,
pika_layer_composite_mode_get_type,
pika_layer_mode_get_type,
pika_mask_apply_mode_get_type,
pika_merge_type_get_type,
pika_message_handler_type_get_type,
pika_offset_type_get_type,
pika_orientation_type_get_type,
pika_pdb_error_handler_get_type,
pika_pdb_proc_type_get_type,
pika_pdb_status_type_get_type,
pika_paint_application_mode_get_type,
pika_precision_get_type,
pika_progress_command_get_type,
pika_repeat_mode_get_type,
pika_rotation_type_get_type,
pika_run_mode_get_type,
pika_select_criterion_get_type,
pika_size_type_get_type,
pika_stack_trace_mode_get_type,
pika_stroke_method_get_type,
pika_text_direction_get_type,
pika_text_hint_style_get_type,
pika_text_justification_get_type,
pika_transfer_mode_get_type,
pika_transform_direction_get_type,
pika_transform_resize_get_type,
pika_vectors_stroke_type_get_type
};
static const gchar * const type_names[] =
{
"GeglDistanceMetric",
"PikaAddMaskType",
"PikaBrushApplicationMode",
"PikaBrushGeneratedShape",
"PikaCapStyle",
"PikaChannelOps",
"PikaChannelType",
"PikaCloneType",
"PikaColorManagementMode",
"PikaColorRenderingIntent",
"PikaColorTag",
"PikaComponentType",
"PikaConvertDitherType",
"PikaConvertPaletteType",
"PikaConvolveType",
"PikaDesaturateMode",
"PikaDodgeBurnType",
"PikaFillType",
"PikaForegroundExtractMode",
"PikaGradientBlendColorSpace",
"PikaGradientSegmentColor",
"PikaGradientSegmentType",
"PikaGradientType",
"PikaGridStyle",
"PikaHistogramChannel",
"PikaHueRange",
"PikaIconType",
"PikaImageBaseType",
"PikaImageType",
"PikaInkBlobType",
"PikaInterpolationType",
"PikaJoinStyle",
"PikaLayerColorSpace",
"PikaLayerCompositeMode",
"PikaLayerMode",
"PikaMaskApplyMode",
"PikaMergeType",
"PikaMessageHandlerType",
"PikaOffsetType",
"PikaOrientationType",
"PikaPDBErrorHandler",
"PikaPDBProcType",
"PikaPDBStatusType",
"PikaPaintApplicationMode",
"PikaPrecision",
"PikaProgressCommand",
"PikaRepeatMode",
"PikaRotationType",
"PikaRunMode",
"PikaSelectCriterion",
"PikaSizeType",
"PikaStackTraceMode",
"PikaStrokeMethod",
"PikaTextDirection",
"PikaTextHintStyle",
"PikaTextJustification",
"PikaTransferMode",
"PikaTransformDirection",
"PikaTransformResize",
"PikaVectorsStrokeType"
};
static gboolean enums_initialized = FALSE;
#if 0
/* keep around as documentation how to do compat enums */
GType pika_convert_dither_type_compat_get_type (void);
#endif
/**
* pika_enums_init:
*
* This function makes sure all the enum types are registered
* with the #GType system. This is intended for use by language
* bindings that need the symbols early, before pika_main is run.
* It's not necessary for plug-ins to call this directly, because
* the normal plug-in initialization code will handle it implicitly.
*
* Since: 2.4
**/
void
pika_enums_init (void)
{
const PikaGetTypeFunc *funcs = get_type_funcs;
#if 0
GQuark quark;
#endif
gint i;
if (enums_initialized)
return;
for (i = 0; i < G_N_ELEMENTS (get_type_funcs); i++, funcs++)
{
GType type = (*funcs) ();
g_type_class_ref (type);
}
#if 0
/* keep around as documentation how to do compat enums */
/* keep compat enum code in sync with app/app.c (app_libs_init) */
quark = g_quark_from_static_string ("pika-compat-enum");
g_type_set_qdata (PIKA_TYPE_CONVERT_DITHER_TYPE, quark,
(gpointer) pika_convert_dither_type_compat_get_type ());
#endif
pika_base_compat_enums_init ();
enums_initialized = TRUE;
}
/**
* pika_enums_get_type_names:
* @n_type_names: (out): return location for the number of names
*
* This function gives access to the list of enums registered by libpika.
* The returned array is static and must not be modified.
*
* Returns: (array length=n_type_names) (transfer none): an array with type names
*
* Since: 2.2
**/
const gchar **
pika_enums_get_type_names (gint *n_type_names)
{
g_return_val_if_fail (n_type_names != NULL, NULL);
*n_type_names = G_N_ELEMENTS (type_names);
return (const gchar **) type_names;
}

282
libpika/pikaenums.h Normal file
View File

@ -0,0 +1,282 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is autogenerated by enumcode.pl */
#ifndef __PIKA_ENUMS_H__
#define __PIKA_ENUMS_H__
G_BEGIN_DECLS
#define PIKA_TYPE_BRUSH_APPLICATION_MODE (pika_brush_application_mode_get_type ())
GType pika_brush_application_mode_get_type (void) G_GNUC_CONST;
/**
* PikaBrushApplicationMode:
* @PIKA_BRUSH_HARD: PIKA_BRUSH_HARD
* @PIKA_BRUSH_SOFT: PIKA_BRUSH_SOFT
*
* Extracted from app/paint/paint-enums.h
**/
typedef enum
{
PIKA_BRUSH_HARD,
PIKA_BRUSH_SOFT
} PikaBrushApplicationMode;
#define PIKA_TYPE_CONVERT_DITHER_TYPE (pika_convert_dither_type_get_type ())
GType pika_convert_dither_type_get_type (void) G_GNUC_CONST;
/**
* PikaConvertDitherType:
* @PIKA_CONVERT_DITHER_NONE: PIKA_CONVERT_DITHER_NONE
* @PIKA_CONVERT_DITHER_FS: PIKA_CONVERT_DITHER_FS
* @PIKA_CONVERT_DITHER_FS_LOWBLEED: PIKA_CONVERT_DITHER_FS_LOWBLEED
* @PIKA_CONVERT_DITHER_FIXED: PIKA_CONVERT_DITHER_FIXED
*
* Extracted from app/core/core-enums.h
**/
typedef enum
{
PIKA_CONVERT_DITHER_NONE,
PIKA_CONVERT_DITHER_FS,
PIKA_CONVERT_DITHER_FS_LOWBLEED,
PIKA_CONVERT_DITHER_FIXED
} PikaConvertDitherType;
#define PIKA_TYPE_HISTOGRAM_CHANNEL (pika_histogram_channel_get_type ())
GType pika_histogram_channel_get_type (void) G_GNUC_CONST;
/**
* PikaHistogramChannel:
* @PIKA_HISTOGRAM_VALUE: PIKA_HISTOGRAM_VALUE
* @PIKA_HISTOGRAM_RED: PIKA_HISTOGRAM_RED
* @PIKA_HISTOGRAM_GREEN: PIKA_HISTOGRAM_GREEN
* @PIKA_HISTOGRAM_BLUE: PIKA_HISTOGRAM_BLUE
* @PIKA_HISTOGRAM_ALPHA: PIKA_HISTOGRAM_ALPHA
* @PIKA_HISTOGRAM_LUMINANCE: PIKA_HISTOGRAM_LUMINANCE
*
* Extracted from app/core/core-enums.h
**/
typedef enum
{
PIKA_HISTOGRAM_VALUE,
PIKA_HISTOGRAM_RED,
PIKA_HISTOGRAM_GREEN,
PIKA_HISTOGRAM_BLUE,
PIKA_HISTOGRAM_ALPHA,
PIKA_HISTOGRAM_LUMINANCE
} PikaHistogramChannel;
#define PIKA_TYPE_LAYER_COLOR_SPACE (pika_layer_color_space_get_type ())
GType pika_layer_color_space_get_type (void) G_GNUC_CONST;
/**
* PikaLayerColorSpace:
* @PIKA_LAYER_COLOR_SPACE_AUTO: PIKA_LAYER_COLOR_SPACE_AUTO
* @PIKA_LAYER_COLOR_SPACE_RGB_LINEAR: PIKA_LAYER_COLOR_SPACE_RGB_LINEAR
* @PIKA_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: PIKA_LAYER_COLOR_SPACE_RGB_PERCEPTUAL
*
* Extracted from app/operations/operations-enums.h
**/
typedef enum
{
PIKA_LAYER_COLOR_SPACE_AUTO,
PIKA_LAYER_COLOR_SPACE_RGB_LINEAR,
PIKA_LAYER_COLOR_SPACE_RGB_PERCEPTUAL
} PikaLayerColorSpace;
#define PIKA_TYPE_LAYER_COMPOSITE_MODE (pika_layer_composite_mode_get_type ())
GType pika_layer_composite_mode_get_type (void) G_GNUC_CONST;
/**
* PikaLayerCompositeMode:
* @PIKA_LAYER_COMPOSITE_AUTO: PIKA_LAYER_COMPOSITE_AUTO
* @PIKA_LAYER_COMPOSITE_UNION: PIKA_LAYER_COMPOSITE_UNION
* @PIKA_LAYER_COMPOSITE_CLIP_TO_BACKDROP: PIKA_LAYER_COMPOSITE_CLIP_TO_BACKDROP
* @PIKA_LAYER_COMPOSITE_CLIP_TO_LAYER: PIKA_LAYER_COMPOSITE_CLIP_TO_LAYER
* @PIKA_LAYER_COMPOSITE_INTERSECTION: PIKA_LAYER_COMPOSITE_INTERSECTION
*
* Extracted from app/operations/operations-enums.h
**/
typedef enum
{
PIKA_LAYER_COMPOSITE_AUTO,
PIKA_LAYER_COMPOSITE_UNION,
PIKA_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
PIKA_LAYER_COMPOSITE_CLIP_TO_LAYER,
PIKA_LAYER_COMPOSITE_INTERSECTION
} PikaLayerCompositeMode;
#define PIKA_TYPE_LAYER_MODE (pika_layer_mode_get_type ())
GType pika_layer_mode_get_type (void) G_GNUC_CONST;
/**
* PikaLayerMode:
* @PIKA_LAYER_MODE_NORMAL_LEGACY: PIKA_LAYER_MODE_NORMAL_LEGACY
* @PIKA_LAYER_MODE_DISSOLVE: PIKA_LAYER_MODE_DISSOLVE
* @PIKA_LAYER_MODE_BEHIND_LEGACY: PIKA_LAYER_MODE_BEHIND_LEGACY
* @PIKA_LAYER_MODE_MULTIPLY_LEGACY: PIKA_LAYER_MODE_MULTIPLY_LEGACY
* @PIKA_LAYER_MODE_SCREEN_LEGACY: PIKA_LAYER_MODE_SCREEN_LEGACY
* @PIKA_LAYER_MODE_OVERLAY_LEGACY: PIKA_LAYER_MODE_OVERLAY_LEGACY
* @PIKA_LAYER_MODE_DIFFERENCE_LEGACY: PIKA_LAYER_MODE_DIFFERENCE_LEGACY
* @PIKA_LAYER_MODE_ADDITION_LEGACY: PIKA_LAYER_MODE_ADDITION_LEGACY
* @PIKA_LAYER_MODE_SUBTRACT_LEGACY: PIKA_LAYER_MODE_SUBTRACT_LEGACY
* @PIKA_LAYER_MODE_DARKEN_ONLY_LEGACY: PIKA_LAYER_MODE_DARKEN_ONLY_LEGACY
* @PIKA_LAYER_MODE_LIGHTEN_ONLY_LEGACY: PIKA_LAYER_MODE_LIGHTEN_ONLY_LEGACY
* @PIKA_LAYER_MODE_HSV_HUE_LEGACY: PIKA_LAYER_MODE_HSV_HUE_LEGACY
* @PIKA_LAYER_MODE_HSV_SATURATION_LEGACY: PIKA_LAYER_MODE_HSV_SATURATION_LEGACY
* @PIKA_LAYER_MODE_HSL_COLOR_LEGACY: PIKA_LAYER_MODE_HSL_COLOR_LEGACY
* @PIKA_LAYER_MODE_HSV_VALUE_LEGACY: PIKA_LAYER_MODE_HSV_VALUE_LEGACY
* @PIKA_LAYER_MODE_DIVIDE_LEGACY: PIKA_LAYER_MODE_DIVIDE_LEGACY
* @PIKA_LAYER_MODE_DODGE_LEGACY: PIKA_LAYER_MODE_DODGE_LEGACY
* @PIKA_LAYER_MODE_BURN_LEGACY: PIKA_LAYER_MODE_BURN_LEGACY
* @PIKA_LAYER_MODE_HARDLIGHT_LEGACY: PIKA_LAYER_MODE_HARDLIGHT_LEGACY
* @PIKA_LAYER_MODE_SOFTLIGHT_LEGACY: PIKA_LAYER_MODE_SOFTLIGHT_LEGACY
* @PIKA_LAYER_MODE_GRAIN_EXTRACT_LEGACY: PIKA_LAYER_MODE_GRAIN_EXTRACT_LEGACY
* @PIKA_LAYER_MODE_GRAIN_MERGE_LEGACY: PIKA_LAYER_MODE_GRAIN_MERGE_LEGACY
* @PIKA_LAYER_MODE_COLOR_ERASE_LEGACY: PIKA_LAYER_MODE_COLOR_ERASE_LEGACY
* @PIKA_LAYER_MODE_OVERLAY: PIKA_LAYER_MODE_OVERLAY
* @PIKA_LAYER_MODE_LCH_HUE: PIKA_LAYER_MODE_LCH_HUE
* @PIKA_LAYER_MODE_LCH_CHROMA: PIKA_LAYER_MODE_LCH_CHROMA
* @PIKA_LAYER_MODE_LCH_COLOR: PIKA_LAYER_MODE_LCH_COLOR
* @PIKA_LAYER_MODE_LCH_LIGHTNESS: PIKA_LAYER_MODE_LCH_LIGHTNESS
* @PIKA_LAYER_MODE_NORMAL: PIKA_LAYER_MODE_NORMAL
* @PIKA_LAYER_MODE_BEHIND: PIKA_LAYER_MODE_BEHIND
* @PIKA_LAYER_MODE_MULTIPLY: PIKA_LAYER_MODE_MULTIPLY
* @PIKA_LAYER_MODE_SCREEN: PIKA_LAYER_MODE_SCREEN
* @PIKA_LAYER_MODE_DIFFERENCE: PIKA_LAYER_MODE_DIFFERENCE
* @PIKA_LAYER_MODE_ADDITION: PIKA_LAYER_MODE_ADDITION
* @PIKA_LAYER_MODE_SUBTRACT: PIKA_LAYER_MODE_SUBTRACT
* @PIKA_LAYER_MODE_DARKEN_ONLY: PIKA_LAYER_MODE_DARKEN_ONLY
* @PIKA_LAYER_MODE_LIGHTEN_ONLY: PIKA_LAYER_MODE_LIGHTEN_ONLY
* @PIKA_LAYER_MODE_HSV_HUE: PIKA_LAYER_MODE_HSV_HUE
* @PIKA_LAYER_MODE_HSV_SATURATION: PIKA_LAYER_MODE_HSV_SATURATION
* @PIKA_LAYER_MODE_HSL_COLOR: PIKA_LAYER_MODE_HSL_COLOR
* @PIKA_LAYER_MODE_HSV_VALUE: PIKA_LAYER_MODE_HSV_VALUE
* @PIKA_LAYER_MODE_DIVIDE: PIKA_LAYER_MODE_DIVIDE
* @PIKA_LAYER_MODE_DODGE: PIKA_LAYER_MODE_DODGE
* @PIKA_LAYER_MODE_BURN: PIKA_LAYER_MODE_BURN
* @PIKA_LAYER_MODE_HARDLIGHT: PIKA_LAYER_MODE_HARDLIGHT
* @PIKA_LAYER_MODE_SOFTLIGHT: PIKA_LAYER_MODE_SOFTLIGHT
* @PIKA_LAYER_MODE_GRAIN_EXTRACT: PIKA_LAYER_MODE_GRAIN_EXTRACT
* @PIKA_LAYER_MODE_GRAIN_MERGE: PIKA_LAYER_MODE_GRAIN_MERGE
* @PIKA_LAYER_MODE_VIVID_LIGHT: PIKA_LAYER_MODE_VIVID_LIGHT
* @PIKA_LAYER_MODE_PIN_LIGHT: PIKA_LAYER_MODE_PIN_LIGHT
* @PIKA_LAYER_MODE_LINEAR_LIGHT: PIKA_LAYER_MODE_LINEAR_LIGHT
* @PIKA_LAYER_MODE_HARD_MIX: PIKA_LAYER_MODE_HARD_MIX
* @PIKA_LAYER_MODE_EXCLUSION: PIKA_LAYER_MODE_EXCLUSION
* @PIKA_LAYER_MODE_LINEAR_BURN: PIKA_LAYER_MODE_LINEAR_BURN
* @PIKA_LAYER_MODE_LUMA_DARKEN_ONLY: PIKA_LAYER_MODE_LUMA_DARKEN_ONLY
* @PIKA_LAYER_MODE_LUMA_LIGHTEN_ONLY: PIKA_LAYER_MODE_LUMA_LIGHTEN_ONLY
* @PIKA_LAYER_MODE_LUMINANCE: PIKA_LAYER_MODE_LUMINANCE
* @PIKA_LAYER_MODE_COLOR_ERASE: PIKA_LAYER_MODE_COLOR_ERASE
* @PIKA_LAYER_MODE_ERASE: PIKA_LAYER_MODE_ERASE
* @PIKA_LAYER_MODE_MERGE: PIKA_LAYER_MODE_MERGE
* @PIKA_LAYER_MODE_SPLIT: PIKA_LAYER_MODE_SPLIT
* @PIKA_LAYER_MODE_PASS_THROUGH: PIKA_LAYER_MODE_PASS_THROUGH
*
* Extracted from app/operations/operations-enums.h
**/
typedef enum
{
PIKA_LAYER_MODE_NORMAL_LEGACY,
PIKA_LAYER_MODE_DISSOLVE,
PIKA_LAYER_MODE_BEHIND_LEGACY,
PIKA_LAYER_MODE_MULTIPLY_LEGACY,
PIKA_LAYER_MODE_SCREEN_LEGACY,
PIKA_LAYER_MODE_OVERLAY_LEGACY,
PIKA_LAYER_MODE_DIFFERENCE_LEGACY,
PIKA_LAYER_MODE_ADDITION_LEGACY,
PIKA_LAYER_MODE_SUBTRACT_LEGACY,
PIKA_LAYER_MODE_DARKEN_ONLY_LEGACY,
PIKA_LAYER_MODE_LIGHTEN_ONLY_LEGACY,
PIKA_LAYER_MODE_HSV_HUE_LEGACY,
PIKA_LAYER_MODE_HSV_SATURATION_LEGACY,
PIKA_LAYER_MODE_HSL_COLOR_LEGACY,
PIKA_LAYER_MODE_HSV_VALUE_LEGACY,
PIKA_LAYER_MODE_DIVIDE_LEGACY,
PIKA_LAYER_MODE_DODGE_LEGACY,
PIKA_LAYER_MODE_BURN_LEGACY,
PIKA_LAYER_MODE_HARDLIGHT_LEGACY,
PIKA_LAYER_MODE_SOFTLIGHT_LEGACY,
PIKA_LAYER_MODE_GRAIN_EXTRACT_LEGACY,
PIKA_LAYER_MODE_GRAIN_MERGE_LEGACY,
PIKA_LAYER_MODE_COLOR_ERASE_LEGACY,
PIKA_LAYER_MODE_OVERLAY,
PIKA_LAYER_MODE_LCH_HUE,
PIKA_LAYER_MODE_LCH_CHROMA,
PIKA_LAYER_MODE_LCH_COLOR,
PIKA_LAYER_MODE_LCH_LIGHTNESS,
PIKA_LAYER_MODE_NORMAL,
PIKA_LAYER_MODE_BEHIND,
PIKA_LAYER_MODE_MULTIPLY,
PIKA_LAYER_MODE_SCREEN,
PIKA_LAYER_MODE_DIFFERENCE,
PIKA_LAYER_MODE_ADDITION,
PIKA_LAYER_MODE_SUBTRACT,
PIKA_LAYER_MODE_DARKEN_ONLY,
PIKA_LAYER_MODE_LIGHTEN_ONLY,
PIKA_LAYER_MODE_HSV_HUE,
PIKA_LAYER_MODE_HSV_SATURATION,
PIKA_LAYER_MODE_HSL_COLOR,
PIKA_LAYER_MODE_HSV_VALUE,
PIKA_LAYER_MODE_DIVIDE,
PIKA_LAYER_MODE_DODGE,
PIKA_LAYER_MODE_BURN,
PIKA_LAYER_MODE_HARDLIGHT,
PIKA_LAYER_MODE_SOFTLIGHT,
PIKA_LAYER_MODE_GRAIN_EXTRACT,
PIKA_LAYER_MODE_GRAIN_MERGE,
PIKA_LAYER_MODE_VIVID_LIGHT,
PIKA_LAYER_MODE_PIN_LIGHT,
PIKA_LAYER_MODE_LINEAR_LIGHT,
PIKA_LAYER_MODE_HARD_MIX,
PIKA_LAYER_MODE_EXCLUSION,
PIKA_LAYER_MODE_LINEAR_BURN,
PIKA_LAYER_MODE_LUMA_DARKEN_ONLY,
PIKA_LAYER_MODE_LUMA_LIGHTEN_ONLY,
PIKA_LAYER_MODE_LUMINANCE,
PIKA_LAYER_MODE_COLOR_ERASE,
PIKA_LAYER_MODE_ERASE,
PIKA_LAYER_MODE_MERGE,
PIKA_LAYER_MODE_SPLIT,
PIKA_LAYER_MODE_PASS_THROUGH
} PikaLayerMode;
void pika_enums_init (void);
const gchar ** pika_enums_get_type_names (gint *n_type_names);
G_END_DECLS
#endif /* __PIKA_ENUMS_H__ */

1231
libpika/pikaexport.c Normal file

File diff suppressed because it is too large Load Diff

94
libpika/pikaexport.h Normal file
View File

@ -0,0 +1,94 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
*
* pikaexport.h
* Copyright (C) 1999-2000 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_EXPORT_H__
#define __PIKA_EXPORT_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
/**
* PikaExportCapabilities:
* @PIKA_EXPORT_CAN_HANDLE_RGB: Handles RGB images
* @PIKA_EXPORT_CAN_HANDLE_GRAY: Handles grayscale images
* @PIKA_EXPORT_CAN_HANDLE_INDEXED: Handles indexed images
* @PIKA_EXPORT_CAN_HANDLE_BITMAP: Handles two-color indexed images
* @PIKA_EXPORT_CAN_HANDLE_ALPHA: Handles alpha channels
* @PIKA_EXPORT_CAN_HANDLE_LAYERS: Handles layers
* @PIKA_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION: Handles animation of layers
* @PIKA_EXPORT_CAN_HANDLE_LAYER_MASKS: Handles layer masks
* @PIKA_EXPORT_NEEDS_ALPHA: Needs alpha channels
* @PIKA_EXPORT_NEEDS_CROP: Needs to crop content to image bounds
*
* The types of images and layers an export procedure can handle
**/
typedef enum
{
PIKA_EXPORT_CAN_HANDLE_RGB = 1 << 0,
PIKA_EXPORT_CAN_HANDLE_GRAY = 1 << 1,
PIKA_EXPORT_CAN_HANDLE_INDEXED = 1 << 2,
PIKA_EXPORT_CAN_HANDLE_BITMAP = 1 << 3,
PIKA_EXPORT_CAN_HANDLE_ALPHA = 1 << 4,
PIKA_EXPORT_CAN_HANDLE_LAYERS = 1 << 5,
PIKA_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION = 1 << 6,
PIKA_EXPORT_CAN_HANDLE_LAYER_MASKS = 1 << 7,
PIKA_EXPORT_NEEDS_ALPHA = 1 << 8,
PIKA_EXPORT_NEEDS_CROP = 1 << 9
} PikaExportCapabilities;
/**
* PikaExportReturn:
* @PIKA_EXPORT_CANCEL: The export was cancelled
* @PIKA_EXPORT_IGNORE: The image is unmodified but export shall continue anyway
* @PIKA_EXPORT_EXPORT: The chosen transforms were applied to the image
*
* Possible return values of pika_export_image().
**/
typedef enum
{
PIKA_EXPORT_CANCEL,
PIKA_EXPORT_IGNORE,
PIKA_EXPORT_EXPORT
} PikaExportReturn;
GtkWidget * pika_export_dialog_new (const gchar *format_name,
const gchar *role,
const gchar *help_id);
GtkWidget * pika_export_dialog_get_content_area (GtkWidget *dialog);
PikaExportReturn pika_export_image (PikaImage **image,
gint *n_drawables,
PikaDrawable ***drawables,
const gchar *format_name,
PikaExportCapabilities capabilities);
G_END_DECLS
#endif /* __PIKA_EXPORT_H__ */

263
libpika/pikafile_pdb.c Normal file
View File

@ -0,0 +1,263 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafile_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikafile
* @title: pikafile
* @short_description: Image file operations (load, save, etc.)
*
* Image file operations (load, save, etc.)
**/
/**
* pika_file_load:
* @run_mode: The run mode.
* @file: The file to load.
*
* Loads an image file by invoking the right load handler.
*
* This procedure invokes the correct file load handler using magic if
* possible, and falling back on the file's extension and/or prefix if
* not.
*
* Returns: (transfer none): The output image.
**/
PikaImage *
pika_file_load (PikaRunMode run_mode,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaImage *image = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_RUN_MODE, run_mode,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-file-load",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
image = PIKA_VALUES_GET_IMAGE (return_vals, 1);
pika_value_array_unref (return_vals);
return image;
}
/**
* pika_file_load_layer:
* @run_mode: The run mode.
* @image: Destination image.
* @file: The file to load.
*
* Loads an image file as a layer for an existing image.
*
* This procedure behaves like the file-load procedure but opens the
* specified image as a layer for an existing image. The returned layer
* needs to be added to the existing image with
* pika_image_insert_layer().
*
* Returns: (transfer none): The layer created when loading the image file.
*
* Since: 2.4
**/
PikaLayer *
pika_file_load_layer (PikaRunMode run_mode,
PikaImage *image,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaLayer *layer = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_RUN_MODE, run_mode,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-file-load-layer",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
layer = PIKA_VALUES_GET_LAYER (return_vals, 1);
pika_value_array_unref (return_vals);
return layer;
}
/**
* pika_file_load_layers:
* @run_mode: The run mode.
* @image: Destination image.
* @file: The file to load.
* @num_layers: (out): The number of loaded layers.
*
* Loads an image file as layers for an existing image.
*
* This procedure behaves like the file-load procedure but opens the
* specified image as layers for an existing image. The returned layers
* needs to be added to the existing image with
* pika_image_insert_layer().
*
* Returns: (array length=num_layers) (element-type PikaLayer) (transfer container):
* The list of loaded layers.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
PikaLayer **
pika_file_load_layers (PikaRunMode run_mode,
PikaImage *image,
GFile *file,
gint *num_layers)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaLayer **layers = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_RUN_MODE, run_mode,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-file-load-layers",
args);
pika_value_array_unref (args);
*num_layers = 0;
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
{
*num_layers = PIKA_VALUES_GET_INT (return_vals, 1);
{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index (return_vals, 2)); if (a) layers = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
}
pika_value_array_unref (return_vals);
return layers;
}
/**
* pika_file_save:
* @run_mode: The run mode.
* @image: Input image.
* @num_drawables: The number of drawables to save.
* @drawables: (array length=num_drawables) (element-type PikaItem): Drawables to save.
* @file: The file to save the image in.
*
* Saves a file by extension.
*
* This procedure invokes the correct file save handler according to
* the file's extension and/or prefix.
*
* Returns: TRUE on success.
**/
gboolean
pika_file_save (PikaRunMode run_mode,
PikaImage *image,
gint num_drawables,
const PikaItem **drawables,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_RUN_MODE, run_mode,
PIKA_TYPE_IMAGE, image,
G_TYPE_INT, num_drawables,
PIKA_TYPE_OBJECT_ARRAY, NULL,
G_TYPE_FILE, file,
G_TYPE_NONE);
pika_value_set_object_array (pika_value_array_index (args, 3), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-file-save",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_file_save_thumbnail:
* @image: The image.
* @file: The file the thumbnail belongs to.
*
* Saves a thumbnail for the given image
*
* This procedure saves a thumbnail for the given image according to
* the Free Desktop Thumbnail Managing Standard. The thumbnail is saved
* so that it belongs to the given file. This means you have to save
* the image under this name first, otherwise this procedure will fail.
* This procedure may become useful if you want to explicitly save a
* thumbnail with a file.
*
* Returns: TRUE on success.
**/
gboolean
pika_file_save_thumbnail (PikaImage *image,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-file-save-thumbnail",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

55
libpika/pikafile_pdb.h Normal file
View File

@ -0,0 +1,55 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafile_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_FILE_PDB_H__
#define __PIKA_FILE_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
PikaImage* pika_file_load (PikaRunMode run_mode,
GFile *file);
PikaLayer* pika_file_load_layer (PikaRunMode run_mode,
PikaImage *image,
GFile *file);
PikaLayer** pika_file_load_layers (PikaRunMode run_mode,
PikaImage *image,
GFile *file,
gint *num_layers);
gboolean pika_file_save (PikaRunMode run_mode,
PikaImage *image,
gint num_drawables,
const PikaItem **drawables,
GFile *file);
gboolean pika_file_save_thumbnail (PikaImage *image,
GFile *file);
G_END_DECLS
#endif /* __PIKA_FILE_PDB_H__ */

401
libpika/pikafileprocedure.c Normal file
View File

@ -0,0 +1,401 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* pikafileprocedure.c
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
#include "pikafileprocedure.h"
struct _PikaFileProcedurePrivate
{
gchar *format_name;
gchar *mime_types;
gchar *extensions;
gchar *prefixes;
gchar *magics;
gint priority;
gboolean handles_remote;
};
static void pika_file_procedure_constructed (GObject *object);
static void pika_file_procedure_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PikaFileProcedure, pika_file_procedure,
PIKA_TYPE_PROCEDURE)
#define parent_class pika_file_procedure_parent_class
static void
pika_file_procedure_class_init (PikaFileProcedureClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = pika_file_procedure_constructed;
object_class->finalize = pika_file_procedure_finalize;
}
static void
pika_file_procedure_init (PikaFileProcedure *procedure)
{
procedure->priv = pika_file_procedure_get_instance_private (procedure);
}
static void
pika_file_procedure_constructed (GObject *object)
{
PikaProcedure *procedure = PIKA_PROCEDURE (object);
G_OBJECT_CLASS (parent_class)->constructed (object);
PIKA_PROC_ARG_ENUM (procedure, "run-mode",
"Run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_NONINTERACTIVE,
G_PARAM_READWRITE);
}
static void
pika_file_procedure_finalize (GObject *object)
{
PikaFileProcedure *procedure = PIKA_FILE_PROCEDURE (object);
g_clear_pointer (&procedure->priv->format_name, g_free);
g_clear_pointer (&procedure->priv->mime_types, g_free);
g_clear_pointer (&procedure->priv->extensions, g_free);
g_clear_pointer (&procedure->priv->prefixes, g_free);
g_clear_pointer (&procedure->priv->magics, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* public functions */
/**
* pika_file_procedure_set_format_name:
* @procedure: A file procedure.
* @format_name: A public-facing name for the format, e.g. "PNG".
*
* Associates a format name with a file handler procedure.
*
* This name can be used for any public-facing strings, such as
* graphical interface labels. An example usage would be
* %PikaSaveProcedureDialog title looking like "Export Image as %s".
*
* Note that since the format name is public-facing, it is recommended
* to localize it at runtime, for instance through gettext, like:
*
* ```c
* pika_file_procedure_set_format_name (procedure, _("JPEG"));
* ```
*
* Some language would indeed localize even some technical terms or
* acronyms, even if sometimes just to rewrite them with the local
* writing system.
*
* Since: 3.0
**/
void
pika_file_procedure_set_format_name (PikaFileProcedure *procedure,
const gchar *format_name)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
g_free (procedure->priv->format_name);
procedure->priv->format_name = g_strdup (format_name);
}
/**
* pika_file_procedure_get_format_name:
* @procedure: A file procedure object.
*
* Returns the procedure's format name, as set with
* [method@FileProcedure.set_format_name].
*
* Returns: The procedure's format name.
*
* Since: 3.0
**/
const gchar *
pika_file_procedure_get_format_name (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), NULL);
return procedure->priv->format_name;
}
/**
* pika_file_procedure_set_mime_types:
* @procedure: A file procedure object.
* @mime_types: A comma-separated list of MIME types, such as "image/jpeg".
*
* Associates MIME types with a file handler procedure.
*
* Registers MIME types for a file handler procedure. This allows PIKA
* to determine the MIME type of the file opened or saved using this
* procedure. It is recommended that only one MIME type is registered
* per file procedure; when registering more than one MIME type, PIKA
* will associate the first one with files opened or saved with this
* procedure.
*
* Since: 3.0
**/
void
pika_file_procedure_set_mime_types (PikaFileProcedure *procedure,
const gchar *mime_types)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
g_free (procedure->priv->mime_types);
procedure->priv->mime_types = g_strdup (mime_types);
}
/**
* pika_file_procedure_get_mime_types:
* @procedure: A file procedure.
*
* Returns the procedure's mime-type as set with
* [method@FileProcedure.set_mime_types].
*
* Returns: The procedure's registered mime-types.
*
* Since: 3.0
**/
const gchar *
pika_file_procedure_get_mime_types (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), NULL);
return procedure->priv->mime_types;
}
/**
* pika_file_procedure_set_extensions:
* @procedure: A file procedure.
* @extensions: A comma separated list of extensions this procedure can
* handle (i.e. "jpg,jpeg").
*
* Registers the given list of extensions as something this procedure can
* handle.
*
* Since: 3.0
**/
void
pika_file_procedure_set_extensions (PikaFileProcedure *procedure,
const gchar *extensions)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
g_free (procedure->priv->extensions);
procedure->priv->extensions = g_strdup (extensions);
}
/**
* pika_file_procedure_get_extensions:
* @procedure: A file procedure object.
*
* Returns the procedure's extensions as set with
* [method@FileProcedure.set_extensions].
*
* Returns: The procedure's registered extensions.
*
* Since: 3.0
**/
const gchar *
pika_file_procedure_get_extensions (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), NULL);
return procedure->priv->extensions;
}
/**
* pika_file_procedure_set_prefixes:
* @procedure: A file procedure object.
* @prefixes: A comma separated list of prefixes this procedure can
* handle (i.e. "http:,ftp:").
*
* It should almost never be necessary to register prefixes with file
* procedures, because most sorts of URIs should be handled by GIO.
*
* Since: 3.0
**/
void
pika_file_procedure_set_prefixes (PikaFileProcedure *procedure,
const gchar *prefixes)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
g_free (procedure->priv->prefixes);
procedure->priv->prefixes = g_strdup (prefixes);
}
/**
* pika_file_procedure_get_prefixes:
* @procedure: A file procedure object.
*
* Returns the procedure's prefixes as set with
* [method@FileProcedure.set_prefixes].
*
* Returns: The procedure's registered prefixes.
*
* Since: 3.0
**/
const gchar *
pika_file_procedure_get_prefixes (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), NULL);
return procedure->priv->prefixes;
}
/**
* pika_file_procedure_set_magics:
* @procedure: A file procedure object.
* @magics: A comma-separated list of magic file information (i.e. "0,string,GIF").
*
* Registers the list of magic file information this procedure can handle.
*
* Since: 3.0
**/
void
pika_file_procedure_set_magics (PikaFileProcedure *procedure,
const gchar *magics)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
g_free (procedure->priv->magics);
procedure->priv->magics = g_strdup (magics);
}
/**
* pika_file_procedure_get_magics:
* @procedure: A file procedure object.
*
* Returns the procedure's magics as set with [method@FileProcedure.set_magics].
*
* Returns: The procedure's registered magics.
*
* Since: 3.0
**/
const gchar *
pika_file_procedure_get_magics (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), NULL);
return procedure->priv->magics;
}
/**
* pika_file_procedure_set_priority:
* @procedure: A file procedure object.
* @priority: The procedure's priority.
*
* Sets the priority of a file handler procedure.
*
* When more than one procedure matches a given file, the procedure with the
* lowest priority is used; if more than one procedure has the lowest priority,
* it is unspecified which one of them is used. The default priority for file
* handler procedures is 0.
*
* Since: 3.0
**/
void
pika_file_procedure_set_priority (PikaFileProcedure *procedure,
gint priority)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
procedure->priv->priority = priority;
}
/**
* pika_file_procedure_get_priority:
* @procedure: A file procedure object.
*
* Returns the procedure's priority as set with
* [method@FileProcedure.set_priority].
*
* Returns: The procedure's registered priority.
*
* Since: 3.0
**/
gint
pika_file_procedure_get_priority (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), 0);
return procedure->priv->priority;
}
/**
* pika_file_procedure_set_handles_remote:
* @procedure: A #PikaFileProcedure.
* @handles_remote: The procedure's 'handles remote' flag.
*
* Registers a file procedure as capable of handling arbitrary remote
* URIs via GIO.
*
* When @handles_remote is set to %TRUE, the procedure will get a
* #GFile passed that can point to a remote file.
*
* When @handles_remote is set to %FALSE, the procedure will get a
* local [iface@Gio.File] passed and can use [method@Gio.File.get_path] to get
* to a filename that can be used with whatever non-GIO means of dealing with
* the file.
*
* Since: 3.0
**/
void
pika_file_procedure_set_handles_remote (PikaFileProcedure *procedure,
gint handles_remote)
{
g_return_if_fail (PIKA_IS_FILE_PROCEDURE (procedure));
procedure->priv->handles_remote = handles_remote;
}
/**
* pika_file_procedure_get_handles_remote:
* @procedure: A file procedure object.
*
* Returns the procedure's 'handles remote' flags as set with
* [method@FileProcedure.set_handles_remote].
*
* Returns: The procedure's 'handles remote' flag
*
* Since: 3.0
**/
gint
pika_file_procedure_get_handles_remote (PikaFileProcedure *procedure)
{
g_return_val_if_fail (PIKA_IS_FILE_PROCEDURE (procedure), 0);
return procedure->priv->handles_remote;
}

View File

@ -0,0 +1,96 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* pikafileprocedure.h
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_FILE_PROCEDURE_H__
#define __PIKA_FILE_PROCEDURE_H__
#include <libpika/pikaprocedure.h>
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define PIKA_TYPE_FILE_PROCEDURE (pika_file_procedure_get_type ())
#define PIKA_FILE_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_FILE_PROCEDURE, PikaFileProcedure))
#define PIKA_FILE_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_FILE_PROCEDURE, PikaFileProcedureClass))
#define PIKA_IS_FILE_PROCEDURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_FILE_PROCEDURE))
#define PIKA_IS_FILE_PROCEDURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_FILE_PROCEDURE))
#define PIKA_FILE_PROCEDURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_FILE_PROCEDURE, PikaFileProcedureClass))
typedef struct _PikaFileProcedure PikaFileProcedure;
typedef struct _PikaFileProcedureClass PikaFileProcedureClass;
typedef struct _PikaFileProcedurePrivate PikaFileProcedurePrivate;
struct _PikaFileProcedure
{
PikaProcedure parent_instance;
PikaFileProcedurePrivate *priv;
};
struct _PikaFileProcedureClass
{
PikaProcedureClass parent_class;
};
GType pika_file_procedure_get_type (void) G_GNUC_CONST;
void pika_file_procedure_set_format_name (PikaFileProcedure *procedure,
const gchar *format_name);
const gchar * pika_file_procedure_get_format_name (PikaFileProcedure *procedure);
void pika_file_procedure_set_mime_types (PikaFileProcedure *procedure,
const gchar *mime_types);
const gchar * pika_file_procedure_get_mime_types (PikaFileProcedure *procedure);
void pika_file_procedure_set_extensions (PikaFileProcedure *procedure,
const gchar *extensions);
const gchar * pika_file_procedure_get_extensions (PikaFileProcedure *procedure);
void pika_file_procedure_set_prefixes (PikaFileProcedure *procedure,
const gchar *prefixes);
const gchar * pika_file_procedure_get_prefixes (PikaFileProcedure *procedure);
void pika_file_procedure_set_magics (PikaFileProcedure *procedure,
const gchar *magics);
const gchar * pika_file_procedure_get_magics (PikaFileProcedure *procedure);
void pika_file_procedure_set_priority (PikaFileProcedure *procedure,
gint priority);
gint pika_file_procedure_get_priority (PikaFileProcedure *procedure);
void pika_file_procedure_set_handles_remote
(PikaFileProcedure *procedure,
gboolean handles_remote);
gboolean pika_file_procedure_get_handles_remote
(PikaFileProcedure *procedure);
G_END_DECLS
#endif /* __PIKA_FILE_PROCEDURE_H__ */

View File

@ -0,0 +1,185 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafloatingsel_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikafloatingsel
* @title: pikafloatingsel
* @short_description: Functions for removing or attaching floating selections.
*
* Functions for removing or attaching floating selections.
**/
/**
* pika_floating_sel_remove:
* @floating_sel: The floating selection.
*
* Remove the specified floating selection from its associated
* drawable.
*
* This procedure removes the floating selection completely, without
* any side effects. The associated drawable is then set to active.
*
* Returns: TRUE on success.
**/
gboolean
pika_floating_sel_remove (PikaLayer *floating_sel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_LAYER, floating_sel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-floating-sel-remove",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_floating_sel_anchor:
* @floating_sel: The floating selection.
*
* Anchor the specified floating selection to its associated drawable.
*
* This procedure anchors the floating selection to its associated
* drawable. This is similar to merging with a merge type of
* ClipToBottomLayer. The floating selection layer is no longer valid
* after this operation.
*
* Returns: TRUE on success.
**/
gboolean
pika_floating_sel_anchor (PikaLayer *floating_sel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_LAYER, floating_sel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-floating-sel-anchor",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_floating_sel_to_layer:
* @floating_sel: The floating selection.
*
* Transforms the specified floating selection into a layer.
*
* This procedure transforms the specified floating selection into a
* layer with the same offsets and extents. The composited image will
* look precisely the same, but the floating selection layer will no
* longer be clipped to the extents of the drawable it was attached to.
* The floating selection will become the active layer. This procedure
* will not work if the floating selection has a different base type
* from the underlying image. This might be the case if the floating
* selection is above an auxiliary channel or a layer mask.
*
* Returns: TRUE on success.
**/
gboolean
pika_floating_sel_to_layer (PikaLayer *floating_sel)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_LAYER, floating_sel,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-floating-sel-to-layer",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_floating_sel_attach:
* @layer: The layer (is attached as floating selection).
* @drawable: The drawable (where to attach the floating selection).
*
* Attach the specified layer as floating to the specified drawable.
*
* This procedure attaches the layer as floating selection to the
* drawable.
*
* Returns: TRUE on success.
**/
gboolean
pika_floating_sel_attach (PikaLayer *layer,
PikaDrawable *drawable)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_LAYER, layer,
PIKA_TYPE_DRAWABLE, drawable,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-floating-sel-attach",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,44 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafloatingsel_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_FLOATING_SEL_PDB_H__
#define __PIKA_FLOATING_SEL_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_floating_sel_remove (PikaLayer *floating_sel);
gboolean pika_floating_sel_anchor (PikaLayer *floating_sel);
gboolean pika_floating_sel_to_layer (PikaLayer *floating_sel);
gboolean pika_floating_sel_attach (PikaLayer *layer,
PikaDrawable *drawable);
G_END_DECLS
#endif /* __PIKA_FLOATING_SEL_PDB_H__ */

73
libpika/pikafont_pdb.c Normal file
View File

@ -0,0 +1,73 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafont_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikafont
* @title: pikafont
* @short_description: Installable object used by text tools.
*
* Installable object used by text tools.
**/
/**
* pika_font_get_by_name:
* @name: The name of the font.
*
* Returns the font with the given name.
*
* Returns the font with the given name.
*
* Returns: (transfer none): The font.
*
* Since: 3.0
**/
PikaFont *
pika_font_get_by_name (const gchar *name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaFont *font = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-font-get-by-name",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
font = PIKA_VALUES_GET_FONT (return_vals, 1);
pika_value_array_unref (return_vals);
return font;
}

40
libpika/pikafont_pdb.h Normal file
View File

@ -0,0 +1,40 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafont_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_FONT_PDB_H__
#define __PIKA_FONT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
PikaFont* pika_font_get_by_name (const gchar *name);
G_END_DECLS
#endif /* __PIKA_FONT_PDB_H__ */

106
libpika/pikafonts_pdb.c Normal file
View File

@ -0,0 +1,106 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafonts_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikafonts
* @title: pikafonts
* @short_description: Operations related to fonts.
*
* Operations related to fonts.
**/
/**
* pika_fonts_refresh:
*
* Refresh current fonts. This function always succeeds.
*
* This procedure retrieves all fonts currently in the user's font path
* and updates the font dialogs accordingly. Depending on the amount of
* fonts on the system, this can take considerable time.
*
* Returns: TRUE on success.
**/
gboolean
pika_fonts_refresh (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-fonts-refresh",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_fonts_get_list:
* @filter: An optional regular expression used to filter the list.
*
* Retrieve the list of loaded fonts.
*
* This procedure returns a list of the fonts that are currently
* available.
*
* Returns: (array zero-terminated=1) (transfer full): The list of font names.
* The returned value must be freed with g_strfreev().
**/
gchar **
pika_fonts_get_list (const gchar *filter)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **font_list = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, filter,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-fonts-get-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
font_list = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return font_list;
}

41
libpika/pikafonts_pdb.h Normal file
View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafonts_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_FONTS_PDB_H__
#define __PIKA_FONTS_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_fonts_refresh (void);
gchar** pika_fonts_get_list (const gchar *filter);
G_END_DECLS
#endif /* __PIKA_FONTS_PDB_H__ */

View File

@ -0,0 +1,154 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafontselect_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikafontselect
* @title: pikafontselect
* @short_description: Methods of a font chooser dialog.
*
* A font chooser dialog shows installed fonts.
* The dialog is non-modal with its owning dialog,
* which is usually a plugin procedure's dialog.
* When a user selects a font,
* the dialog calls back but the dialog remains open.
* The chosen font is only a choice for the owning widget
* and does not select the font for the context.
* The user can close but not cancel the dialog.
* The owning dialog can close the font chooser dialog
* when the user closes or cancels the owning dialog.
**/
/**
* pika_fonts_popup:
* @font_callback: The callback PDB proc to call when user chooses a font.
* @popup_title: Title of the font selection dialog.
* @initial_font_name: The name of the initial font choice.
*
* Invokes the Pika font selection dialog.
*
* Opens a dialog letting a user choose a font.
*
* Returns: TRUE on success.
**/
gboolean
pika_fonts_popup (const gchar *font_callback,
const gchar *popup_title,
const gchar *initial_font_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, font_callback,
G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_font_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-fonts-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_fonts_close_popup:
* @font_callback: The name of the callback registered in the PDB for this dialog.
*
* Close the font selection dialog.
*
* Closes an open font selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_fonts_close_popup (const gchar *font_callback)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, font_callback,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-fonts-close-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_fonts_set_popup:
* @font_callback: The name of the callback registered in the PDB for the dialog.
* @font_name: The name of the font to set as selected.
*
* Sets the current font in a font selection dialog.
*
* Sets the current font in a font selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_fonts_set_popup (const gchar *font_callback,
const gchar *font_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, font_callback,
G_TYPE_STRING, font_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-fonts-set-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikafontselect_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_FONT_SELECT_PDB_H__
#define __PIKA_FONT_SELECT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_fonts_popup (const gchar *font_callback,
const gchar *popup_title,
const gchar *initial_font_name);
gboolean pika_fonts_close_popup (const gchar *font_callback);
gboolean pika_fonts_set_popup (const gchar *font_callback,
const gchar *font_name);
G_END_DECLS
#endif /* __PIKA_FONT_SELECT_PDB_H__ */

View File

@ -0,0 +1,158 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikafontselectbutton.c
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pika.h"
#include "pikauitypes.h"
#include "pikafontselectbutton.h"
#include "pikauimarshal.h"
#include "libpika-intl.h"
/**
* SECTION: pikafontselectbutton
* @title: PikaFontSelectButton
* @short_description: A button which pops up a font selection dialog.
*
* A button which pops up a font selection dialog.
**/
struct _PikaFontSelectButton
{
PikaResourceSelectButton parent_instance;
GtkWidget *label;
};
static void pika_font_select_button_draw_interior (PikaResourceSelectButton *self);
static const GtkTargetEntry drag_target = { "application/x-pika-font-name", 0, 0 };
G_DEFINE_FINAL_TYPE (PikaFontSelectButton,
pika_font_select_button,
PIKA_TYPE_RESOURCE_SELECT_BUTTON)
static void
pika_font_select_button_class_init (PikaFontSelectButtonClass *klass)
{
PikaResourceSelectButtonClass *superclass = PIKA_RESOURCE_SELECT_BUTTON_CLASS (klass);
superclass->draw_interior = pika_font_select_button_draw_interior;
superclass->resource_type = PIKA_TYPE_FONT;
}
static void
pika_font_select_button_init (PikaFontSelectButton *self)
{
GtkWidget *button;
GtkWidget *hbox;
GtkWidget *image;
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (self), button);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_container_add (GTK_CONTAINER (button), hbox);
image = gtk_image_new_from_icon_name (PIKA_ICON_FONT,
GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
self->label = gtk_label_new ("unknown");
gtk_box_pack_start (GTK_BOX (hbox), self->label, TRUE, TRUE, 4);
gtk_widget_show_all (GTK_WIDGET (self));
pika_resource_select_button_set_drag_target (PIKA_RESOURCE_SELECT_BUTTON (self),
hbox,
&drag_target);
pika_resource_select_button_set_clickable (PIKA_RESOURCE_SELECT_BUTTON (self),
button);
}
static void
pika_font_select_button_draw_interior (PikaResourceSelectButton *self)
{
PikaFontSelectButton *font_select= PIKA_FONT_SELECT_BUTTON (self);
PikaResource *resource;
gchar *name = NULL;
resource = pika_resource_select_button_get_resource (self);
if (resource)
name = pika_resource_get_name (resource);
gtk_label_set_text (GTK_LABEL (font_select->label), name);
}
/**
* pika_font_select_button_new:
* @title: (nullable): Title of the dialog to use or %NULL to use the default title.
* @resource: (nullable): Initial font.
*
* Creates a new #GtkWidget that lets a user choose a font.
* You can put this widget in a plug-in dialog.
*
* When font is NULL, initial choice is from context.
*
* Returns: A #GtkWidget that you can use in your UI.
*
* Since: 2.4
*/
GtkWidget *
pika_font_select_button_new (const gchar *title,
PikaResource *resource)
{
GtkWidget *self;
g_return_val_if_fail (resource == NULL || PIKA_IS_FONT (resource), NULL);
if (resource == NULL)
resource = PIKA_RESOURCE (pika_context_get_font ());
if (title)
self = g_object_new (PIKA_TYPE_FONT_SELECT_BUTTON,
"title", title,
"resource", resource,
NULL);
else
self = g_object_new (PIKA_TYPE_FONT_SELECT_BUTTON,
"resource", resource,
NULL);
pika_font_select_button_draw_interior (PIKA_RESOURCE_SELECT_BUTTON (self));
return self;
}

View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikafontselectbutton.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_FONT_SELECT_BUTTON_H__
#define __PIKA_FONT_SELECT_BUTTON_H__
#include <libpika/pikaresourceselectbutton.h>
G_BEGIN_DECLS
#define PIKA_TYPE_FONT_SELECT_BUTTON (pika_font_select_button_get_type ())
G_DECLARE_FINAL_TYPE (PikaFontSelectButton,
pika_font_select_button,
PIKA, FONT_SELECT_BUTTON,
PikaResourceSelectButton)
GtkWidget * pika_font_select_button_new (const gchar *title,
PikaResource *resource);
G_END_DECLS
#endif /* __PIKA_FONT_SELECT_BUTTON_H__ */

1147
libpika/pikagpparams-body.c Normal file

File diff suppressed because it is too large Load Diff

41
libpika/pikagpparams.c Normal file
View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagpparams.c
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikabase/pikaprotocol.h"
#include "pika.h"
#include "pikagpparams.h"
/* include the implementation, they are shared between app/ and
* libpika/ but need different headers.
*/
#define LIBPIKA_COMPILATION
#include "pikagpparams-body.c"
#undef LIBPIKA_COMPILATION

47
libpika/pikagpparams.h Normal file
View File

@ -0,0 +1,47 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagpparams.h
* Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_GP_PARAMS_H__
#define __PIKA_GP_PARAMS_H__
G_BEGIN_DECLS
GParamSpec * _pika_gp_param_def_to_param_spec (const GPParamDef *param_def);
void _pika_param_spec_to_gp_param_def (GParamSpec *pspec,
GPParamDef *param_def);
PikaValueArray * _pika_gp_params_to_value_array (gpointer pika,
GParamSpec **pspecs,
gint n_pspecs,
const GPParam *params,
gint n_params,
gboolean return_values);
GPParam * _pika_value_array_to_gp_params (const PikaValueArray *args,
gboolean full_copy);
void _pika_gp_params_free (GPParam *params,
gint n_params,
gboolean full_copy);
G_END_DECLS
#endif /* __PIKA_GP_PARAMS_H__ */

1352
libpika/pikagradient_pdb.c Normal file

File diff suppressed because it is too large Load Diff

135
libpika/pikagradient_pdb.h Normal file
View File

@ -0,0 +1,135 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagradient_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_GRADIENT_PDB_H__
#define __PIKA_GRADIENT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
PikaGradient* pika_gradient_new (const gchar *name);
PikaGradient* pika_gradient_get_by_name (const gchar *name);
gint pika_gradient_get_number_of_segments (PikaGradient *gradient);
gboolean pika_gradient_get_uniform_samples (PikaGradient *gradient,
gint num_samples,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples);
gboolean pika_gradient_get_custom_samples (PikaGradient *gradient,
gint num_samples,
const gdouble *positions,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples);
gboolean pika_gradient_segment_get_left_color (PikaGradient *gradient,
gint segment,
PikaRGB *color,
gdouble *opacity);
gboolean pika_gradient_segment_set_left_color (PikaGradient *gradient,
gint segment,
const PikaRGB *color,
gdouble opacity);
gboolean pika_gradient_segment_get_right_color (PikaGradient *gradient,
gint segment,
PikaRGB *color,
gdouble *opacity);
gboolean pika_gradient_segment_set_right_color (PikaGradient *gradient,
gint segment,
const PikaRGB *color,
gdouble opacity);
gboolean pika_gradient_segment_get_left_pos (PikaGradient *gradient,
gint segment,
gdouble *pos);
gboolean pika_gradient_segment_set_left_pos (PikaGradient *gradient,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean pika_gradient_segment_get_middle_pos (PikaGradient *gradient,
gint segment,
gdouble *pos);
gboolean pika_gradient_segment_set_middle_pos (PikaGradient *gradient,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean pika_gradient_segment_get_right_pos (PikaGradient *gradient,
gint segment,
gdouble *pos);
gboolean pika_gradient_segment_set_right_pos (PikaGradient *gradient,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean pika_gradient_segment_get_blending_function (PikaGradient *gradient,
gint segment,
PikaGradientSegmentType *blend_func);
gboolean pika_gradient_segment_get_coloring_type (PikaGradient *gradient,
gint segment,
PikaGradientSegmentColor *coloring_type);
gboolean pika_gradient_segment_range_set_blending_function (PikaGradient *gradient,
gint start_segment,
gint end_segment,
PikaGradientSegmentType blending_function);
gboolean pika_gradient_segment_range_set_coloring_type (PikaGradient *gradient,
gint start_segment,
gint end_segment,
PikaGradientSegmentColor coloring_type);
gboolean pika_gradient_segment_range_flip (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gboolean pika_gradient_segment_range_replicate (PikaGradient *gradient,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean pika_gradient_segment_range_split_midpoint (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gboolean pika_gradient_segment_range_split_uniform (PikaGradient *gradient,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean pika_gradient_segment_range_delete (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gboolean pika_gradient_segment_range_redistribute_handles (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gboolean pika_gradient_segment_range_blend_colors (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gboolean pika_gradient_segment_range_blend_opacity (PikaGradient *gradient,
gint start_segment,
gint end_segment);
gdouble pika_gradient_segment_range_move (PikaGradient *gradient,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
G_END_DECLS
#endif /* __PIKA_GRADIENT_PDB_H__ */

107
libpika/pikagradients_pdb.c Normal file
View File

@ -0,0 +1,107 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagradients_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikagradients
* @title: pikagradients
* @short_description: Operations related to gradients.
*
* Operations related to gradients.
**/
/**
* pika_gradients_refresh:
*
* Refresh current gradients. This function always succeeds.
*
* This procedure retrieves all gradients currently in the user's
* gradient path and updates the gradient dialogs accordingly.
*
* Returns: TRUE on success.
**/
gboolean
pika_gradients_refresh (void)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-gradients-refresh",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_gradients_get_list:
* @filter: An optional regular expression used to filter the list.
*
* Retrieve the list of loaded gradients.
*
* This procedure returns a list of the gradients that are currently
* loaded. You can later use the pika_context_set_gradient() function
* to set the active gradient.
*
* Returns: (array zero-terminated=1) (transfer full):
* The list of gradient names.
* The returned value must be freed with g_strfreev().
**/
gchar **
pika_gradients_get_list (const gchar *filter)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gchar **gradient_list = NULL;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, filter,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-gradients-get-list",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
gradient_list = PIKA_VALUES_DUP_STRV (return_vals, 1);
pika_value_array_unref (return_vals);
return gradient_list;
}

View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagradients_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_GRADIENTS_PDB_H__
#define __PIKA_GRADIENTS_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_gradients_refresh (void);
gchar** pika_gradients_get_list (const gchar *filter);
G_END_DECLS
#endif /* __PIKA_GRADIENTS_PDB_H__ */

View File

@ -0,0 +1,146 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagradientselect_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikagradientselect
* @title: pikagradientselect
* @short_description: Methods of a gradient chooser dialog
*
* A dialog letting a user choose a gradient. Read more at
* pikafontselect.
**/
/**
* pika_gradients_popup:
* @gradient_callback: The callback PDB proc to call when user chooses a gradient.
* @popup_title: Title of the gradient selection dialog.
* @initial_gradient_name: The name of the initial gradient choice.
*
* Invokes the Pika gradients selection dialog.
*
* Opens a dialog letting a user choose a gradient.
*
* Returns: TRUE on success.
**/
gboolean
pika_gradients_popup (const gchar *gradient_callback,
const gchar *popup_title,
const gchar *initial_gradient_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, gradient_callback,
G_TYPE_STRING, popup_title,
G_TYPE_STRING, initial_gradient_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-gradients-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_gradients_close_popup:
* @gradient_callback: The name of the callback registered for this pop-up.
*
* Close the gradient selection dialog.
*
* Closes an open gradient selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_gradients_close_popup (const gchar *gradient_callback)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, gradient_callback,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-gradients-close-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_gradients_set_popup:
* @gradient_callback: The name of the callback registered for this pop-up.
* @gradient_name: The name of the gradient to set as selected.
*
* Sets the current gradient in a gradient selection dialog.
*
* Sets the current gradient in a gradient selection dialog.
*
* Returns: TRUE on success.
**/
gboolean
pika_gradients_set_popup (const gchar *gradient_callback,
const gchar *gradient_name)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, gradient_callback,
G_TYPE_STRING, gradient_name,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-gradients-set-popup",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,45 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikagradientselect_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_GRADIENT_SELECT_PDB_H__
#define __PIKA_GRADIENT_SELECT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_gradients_popup (const gchar *gradient_callback,
const gchar *popup_title,
const gchar *initial_gradient_name);
gboolean pika_gradients_close_popup (const gchar *gradient_callback);
gboolean pika_gradients_set_popup (const gchar *gradient_callback,
const gchar *gradient_name);
G_END_DECLS
#endif /* __PIKA_GRADIENT_SELECT_PDB_H__ */

View File

@ -0,0 +1,301 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikagradientselectbutton.c
* Copyright (C) 1998 Andy Thomas
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pika.h"
#include "pikauitypes.h"
#include "pikagradientselectbutton.h"
#include "pikauimarshal.h"
#include "libpika-intl.h"
/**
* SECTION: pikagradientselectbutton
* @title: PikaGradientSelectButton
* @short_description: A button which pops up a gradient select dialog.
*
* A button which pops up a gradient select dialog.
**/
struct _PikaGradientSelectButton
{
PikaResourceSelectButton parent_instance;
GtkWidget *preview;
};
/* local function prototypes */
static void pika_gradient_select_button_draw_interior (PikaResourceSelectButton *self);
static void pika_gradient_select_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
PikaGradientSelectButton *self);
static gboolean pika_gradient_select_preview_draw_handler (GtkWidget *preview,
cairo_t *cr,
PikaGradientSelectButton *self);
static const GtkTargetEntry drag_target = { "application/x-pika-gradient-name", 0 };
G_DEFINE_FINAL_TYPE (PikaGradientSelectButton,
pika_gradient_select_button,
PIKA_TYPE_RESOURCE_SELECT_BUTTON)
/* Initial dimensions of widget. */
#define CELL_HEIGHT 18
#define CELL_WIDTH 84
static void
pika_gradient_select_button_class_init (PikaGradientSelectButtonClass *klass)
{
PikaResourceSelectButtonClass *superclass = PIKA_RESOURCE_SELECT_BUTTON_CLASS (klass);
superclass->draw_interior = pika_gradient_select_button_draw_interior;
superclass->resource_type = PIKA_TYPE_GRADIENT;
}
static void
pika_gradient_select_button_init (PikaGradientSelectButton *self)
{
GtkWidget *button;
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (self), button);
self->preview = gtk_drawing_area_new ();
gtk_widget_set_size_request (self->preview, CELL_WIDTH, CELL_HEIGHT);
gtk_container_add (GTK_CONTAINER (button), self->preview);
g_signal_connect (self->preview, "size-allocate",
G_CALLBACK (pika_gradient_select_preview_size_allocate),
self);
g_signal_connect (self->preview, "draw",
G_CALLBACK (pika_gradient_select_preview_draw_handler),
self);
gtk_widget_show_all (GTK_WIDGET (self));
pika_resource_select_button_set_drag_target (PIKA_RESOURCE_SELECT_BUTTON (self),
self->preview,
&drag_target);
pika_resource_select_button_set_clickable (PIKA_RESOURCE_SELECT_BUTTON (self),
button);
}
static void
pika_gradient_select_button_draw_interior (PikaResourceSelectButton *self)
{
PikaGradientSelectButton *gradient_select = PIKA_GRADIENT_SELECT_BUTTON (self);
gtk_widget_queue_draw (gradient_select->preview);
}
/**
* pika_gradient_select_button_new:
* @title: (nullable): Title of the dialog to use or %NULL to use the default title.
* @gradient: (nullable): Initial gradient.
*
* Creates a new #GtkWidget that lets a user choose a gradient.
* You can use this widget in a table in a plug-in dialog.
*
* Returns: A #GtkWidget that you can use in your UI.
*
* Since: 2.4
*/
GtkWidget *
pika_gradient_select_button_new (const gchar *title,
PikaResource *gradient)
{
GtkWidget *self;
if (gradient == NULL)
gradient = PIKA_RESOURCE (pika_context_get_gradient ());
if (title)
self = g_object_new (PIKA_TYPE_GRADIENT_SELECT_BUTTON,
"title", title,
"resource", gradient,
NULL);
else
self = g_object_new (PIKA_TYPE_GRADIENT_SELECT_BUTTON,
"resource", gradient,
NULL);
pika_gradient_select_button_draw_interior (PIKA_RESOURCE_SELECT_BUTTON (self));
return self;
}
/* private functions */
/* Get array of samples from self's gradient.
* Return array and size at given handles.
* Return success.
*/
static gboolean
get_gradient_data (PikaGradientSelectButton *self,
gint allocation_width,
gint *sample_count,
gdouble **sample_array)
{
PikaGradient *gradient;
gboolean result;
gdouble *samples;
gint n_samples;
g_object_get (self, "resource", &gradient, NULL);
result = pika_gradient_get_uniform_samples (gradient,
allocation_width,
FALSE, /* not reversed. */
&n_samples,
&samples);
if (result)
{
/* Return array of samples to dereferenced handles. */
*sample_array = samples;
*sample_count = n_samples;
}
/* When result is true, caller must free the array. */
return result;
}
/* Called on widget resized. */
static void
pika_gradient_select_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
PikaGradientSelectButton *self)
{
/* Do nothing.
*
* In former code, we cached the gradient data in self, on allocate event.
* But allocate event always seems to be paired with a draw event,
* so there is no point in caching the gradient data.
* And caching gradient data is a premature optimization,
* without deep knowledge of Gtk and actual performance testing,
* you can't know caching helps performance.
*/
}
/* Draw array of samples.
* This understands mostly cairo, and little about gradient.
*/
static void
pika_gradient_select_preview_draw (cairo_t *cr,
gint src_width,
gint dest_width,
gdouble *src)
{
cairo_pattern_t *pattern;
cairo_surface_t *surface;
guchar *dest;
gint x;
pattern = pika_cairo_checkerboard_create (cr, PIKA_CHECK_SIZE_SM, NULL, NULL);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_paint (cr);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, src_width, 1);
for (x = 0, dest = cairo_image_surface_get_data (surface);
x < src_width;
x++, src += 4, dest += 4)
{
PikaRGB color;
guchar r, g, b, a;
pika_rgba_set (&color, src[0], src[1], src[2], src[3]);
pika_rgba_get_uchar (&color, &r, &g, &b, &a);
PIKA_CAIRO_ARGB32_SET_PIXEL (dest, r, g, b, a);
}
cairo_surface_mark_dirty (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT);
cairo_surface_destroy (surface);
cairo_scale (cr, (gdouble) dest_width / (gdouble) src_width, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_paint (cr);
}
/* Handles a draw signal.
* Draw self, i.e. interior of button.
*
* Always returns FALSE, but doesn't draw when fail to get gradient data.
*
* Is passed neither gradient nor attributes of gradient: get them now from self.
*/
static gboolean
pika_gradient_select_preview_draw_handler (GtkWidget *widget,
cairo_t *cr,
PikaGradientSelectButton *self)
{
GtkAllocation allocation;
/* Attributes of the source.*/
gdouble *src;
gint n_samples;
gint src_width;
gtk_widget_get_allocation (widget, &allocation);
if (!get_gradient_data (self, allocation.width, &n_samples, &src))
return FALSE;
/* Width in pixels of src, since BPP is 4. */
src_width = n_samples / 4;
pika_gradient_select_preview_draw (cr, src_width, allocation.width, src);
g_free (src);
return FALSE;
}

View File

@ -0,0 +1,46 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikagradientselectbutton.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_GRADIENT_SELECT_BUTTON_H__
#define __PIKA_GRADIENT_SELECT_BUTTON_H__
#include <libpika/pikaresourceselectbutton.h>
G_BEGIN_DECLS
#define PIKA_TYPE_GRADIENT_SELECT_BUTTON (pika_gradient_select_button_get_type ())
G_DECLARE_FINAL_TYPE (PikaGradientSelectButton,
pika_gradient_select_button,
PIKA,
GRADIENT_SELECT_BUTTON,
PikaResourceSelectButton)
GtkWidget * pika_gradient_select_button_new (const gchar *title,
PikaResource *gradient);
G_END_DECLS
#endif /* __PIKA_GRADIENT_SELECT_BUTTON_H__ */

78
libpika/pikahelp_pdb.c Normal file
View File

@ -0,0 +1,78 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikahelp_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikahelp
* @title: pikahelp
* @short_description: Loading help pages using pika_help.
*
* Loading help pages using pika_help.
**/
/**
* pika_help:
* @help_domain: The help domain in which help_id is registered.
* @help_id: The help page's ID.
*
* Load a help page.
*
* This procedure loads the specified help page into the helpbrowser or
* what ever is configured as help viewer. The help page is identified
* by its domain and ID: if help_domain is NULL, we use the help_domain
* which was registered using the pika_plugin_help_register()
* procedure. If help_domain is NULL and no help domain was registered,
* the help domain of the main PIKA installation is used.
*
* Returns: TRUE on success.
**/
gboolean
pika_help (const gchar *help_domain,
const gchar *help_id)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_STRING, help_domain,
G_TYPE_STRING, help_id,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-help",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

41
libpika/pikahelp_pdb.h Normal file
View File

@ -0,0 +1,41 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikahelp_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_HELP_PDB_H__
#define __PIKA_HELP_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_help (const gchar *help_domain,
const gchar *help_id);
G_END_DECLS
#endif /* __PIKA_HELP_PDB_H__ */

772
libpika/pikaimage.c Normal file
View File

@ -0,0 +1,772 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* pikaimage.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
#include "libpikabase/pikawire.h" /* FIXME kill this include */
#include "pikapixbuf.h"
#include "pikaplugin-private.h"
#include "pikaprocedure-private.h"
enum
{
PROP_0,
PROP_ID,
N_PROPS
};
struct _PikaImage
{
GObject parent_instance;
gint id;
};
static void pika_image_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_image_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (PikaImage, pika_image, G_TYPE_OBJECT)
#define parent_class pika_image_parent_class
static GParamSpec *props[N_PROPS] = { NULL, };
static void
pika_image_class_init (PikaImageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = pika_image_set_property;
object_class->get_property = pika_image_get_property;
props[PROP_ID] =
g_param_spec_int ("id",
"The image id",
"The image id for internal use",
0, G_MAXINT32, 0,
PIKA_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, N_PROPS, props);
}
static void
pika_image_init (PikaImage *image)
{
}
static void
pika_image_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaImage *image = PIKA_IMAGE (object);
switch (property_id)
{
case PROP_ID:
image->id = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_image_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaImage *image = PIKA_IMAGE (object);
switch (property_id)
{
case PROP_ID:
g_value_set_int (value, image->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* Public API */
/**
* pika_image_get_id:
* @image: The image.
*
* Returns: the image ID.
*
* Since: 3.0
**/
gint32
pika_image_get_id (PikaImage *image)
{
return image ? image->id : -1;
}
/**
* pika_image_get_by_id:
* @image_id: The image id.
*
* Returns: (nullable) (transfer none): a #PikaImage for @image_id or
* %NULL if @image_id does not represent a valid image.
* The object belongs to libpika and you must not modify
* or unref it.
*
* Since: 3.0
**/
PikaImage *
pika_image_get_by_id (gint32 image_id)
{
if (image_id > 0)
{
PikaPlugIn *plug_in = pika_get_plug_in ();
PikaProcedure *procedure = _pika_plug_in_get_procedure (plug_in);
return _pika_procedure_get_image (procedure, image_id);
}
return NULL;
}
/**
* pika_image_is_valid:
* @image: The image to check.
*
* Returns TRUE if the image is valid.
*
* This procedure checks if the given image is valid and refers to
* an existing image.
*
* Returns: Whether the image is valid.
*
* Since: 2.4
**/
gboolean
pika_image_is_valid (PikaImage *image)
{
return pika_image_id_is_valid (pika_image_get_id (image));
}
/**
* pika_list_images:
*
* Returns the list of images currently open.
*
* This procedure returns the list of images currently open in PIKA.
*
* Returns: (element-type PikaImage) (transfer container):
* The list of images currently open.
* The returned list must be freed with g_list_free(). Image
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_list_images (void)
{
PikaImage **images;
gint num_images;
GList *list = NULL;
gint i;
images = pika_get_images (&num_images);
for (i = 0; i < num_images; i++)
list = g_list_prepend (list, images[i]);
g_free (images);
return g_list_reverse (list);
}
/**
* pika_image_list_layers:
* @image: The image.
*
* Returns the list of layers contained in the specified image.
*
* This procedure returns the list of layers contained in the specified
* image. The order of layers is from topmost to bottommost.
*
* Returns: (element-type PikaLayer) (transfer container):
* The list of layers contained in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_layers (PikaImage *image)
{
PikaLayer **layers;
gint num_layers;
GList *list = NULL;
gint i;
layers = pika_image_get_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
list = g_list_prepend (list, layers[i]);
g_free (layers);
return g_list_reverse (list);
}
/**
* pika_image_list_selected_layers:
* @image: The image.
*
* Returns the list of layers selected in the specified image.
*
* This procedure returns the list of layers selected in the specified
* image.
*
* Returns: (element-type PikaLayer) (transfer container):
* The list of selected layers in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_selected_layers (PikaImage *image)
{
PikaLayer **layers;
gint num_layers;
GList *list = NULL;
gint i;
layers = pika_image_get_selected_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
list = g_list_prepend (list, layers[i]);
g_free (layers);
return g_list_reverse (list);
}
/**
* pika_image_take_selected_layers:
* @image: The image.
* @layers: (transfer container) (element-type PikaLayer): The list of layers to select.
*
* The layers are set as the selected layers in the image. Any previous
* selected layers or channels are unselected. An exception is a previously
* existing floating selection, in which case this procedure will return an
* execution error.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_take_selected_layers (PikaImage *image,
GList *layers)
{
PikaLayer **sel_layers;
GList *list;
gboolean success;
gint i;
sel_layers = g_new0 (PikaLayer *, g_list_length (layers));
for (list = layers, i = 0; list; list = list->next, i++)
sel_layers[i] = list->data;
success = pika_image_set_selected_layers (image, g_list_length (layers),
(const PikaLayer **) sel_layers);
g_list_free (layers);
g_free (sel_layers);
return success;
}
/**
* pika_image_list_selected_channels:
* @image: The image.
*
* Returns the list of channels selected in the specified image.
*
* This procedure returns the list of channels selected in the specified
* image.
*
* Returns: (element-type PikaChannel) (transfer container):
* The list of selected channels in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_selected_channels (PikaImage *image)
{
PikaChannel **channels;
gint num_channels;
GList *list = NULL;
gint i;
channels = pika_image_get_selected_channels (image, &num_channels);
for (i = 0; i < num_channels; i++)
list = g_list_prepend (list, channels[i]);
g_free (channels);
return g_list_reverse (list);
}
/**
* pika_image_take_selected_channels:
* @image: The image.
* @channels: (transfer container) (element-type PikaChannel): The list of channels to select.
*
* The channels are set as the selected channels in the image. Any previous
* selected layers or channels are unselected. An exception is a previously
* existing floating selection, in which case this procedure will return an
* execution error.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_take_selected_channels (PikaImage *image,
GList *channels)
{
PikaChannel **sel_channels;
GList *list;
gboolean success;
gint i;
sel_channels = g_new0 (PikaChannel *, g_list_length (channels));
for (list = channels, i = 0; list; list = list->next, i++)
sel_channels[i] = list->data;
success = pika_image_set_selected_channels (image, g_list_length (channels),
(const PikaChannel **) sel_channels);
g_list_free (channels);
return success;
}
/**
* pika_image_list_selected_vectors:
* @image: The image.
*
* Returns the list of paths selected in the specified image.
*
* This procedure returns the list of paths selected in the specified
* image.
*
* Returns: (element-type PikaVectors) (transfer container):
* The list of selected paths in the image.
* The returned list must be freed with g_list_free().
* Path elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_selected_vectors (PikaImage *image)
{
PikaVectors **vectors;
gint num_vectors;
GList *list = NULL;
gint i;
vectors = pika_image_get_selected_vectors (image, &num_vectors);
for (i = 0; i < num_vectors; i++)
list = g_list_prepend (list, vectors[i]);
g_free (vectors);
return g_list_reverse (list);
}
/**
* pika_image_take_selected_vectors:
* @image: The image.
* @vectors: (transfer container) (element-type PikaVectors): The list of paths to select.
*
* The paths are set as the selected paths in the image. Any previous
* selected paths are unselected.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_take_selected_vectors (PikaImage *image,
GList *vectors)
{
PikaVectors **sel_vectors;
GList *list;
gboolean success;
gint i;
sel_vectors = g_new0 (PikaVectors *, g_list_length (vectors));
for (list = vectors, i = 0; list; list = list->next, i++)
sel_vectors[i] = list->data;
success = pika_image_set_selected_vectors (image, g_list_length (vectors),
(const PikaVectors **) sel_vectors);
g_list_free (vectors);
return success;
}
/**
* pika_image_list_channels:
* @image: The image.
*
* Returns the list of channels contained in the specified image.
*
* This procedure returns the list of channels contained in the
* specified image. This does not include the selection mask, or layer
* masks. The order is from topmost to bottommost. Note that
* "channels" are custom channels and do not include the image's
* color components.
*
* Returns: (element-type PikaChannel) (transfer container):
* The list of channels contained in the image.
* The returned list must be freed with g_list_free(). Channel
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_channels (PikaImage *image)
{
PikaChannel **channels;
gint num_channels;
GList *list = NULL;
gint i;
channels = pika_image_get_channels (image, &num_channels);
for (i = 0; i < num_channels; i++)
list = g_list_prepend (list, channels[i]);
g_free (channels);
return g_list_reverse (list);
}
/**
* pika_image_list_vectors:
* @image: The image.
*
* Returns the list of vectors contained in the specified image.
*
* This procedure returns the list of vectors contained in the
* specified image.
*
* Returns: (element-type PikaVectors) (transfer container):
* The list of vectors contained in the image.
* The returned value must be freed with g_list_free(). Vectors
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_vectors (PikaImage *image)
{
PikaVectors **vectors;
gint num_vectors;
GList *list = NULL;
gint i;
vectors = pika_image_get_vectors (image, &num_vectors);
for (i = 0; i < num_vectors; i++)
list = g_list_prepend (list, vectors[i]);
g_free (vectors);
return g_list_reverse (list);
}
/**
* pika_image_list_selected_drawables:
* @image: The image.
*
* Returns the list of drawables selected in the specified image.
*
* This procedure returns the list of drawables selected in the specified
* image.
* These can be either a list of layers or a list of channels (a list mixing
* layers and channels is not possible), or it can be a layer mask (a list
* containing only a layer mask as single item), if a layer mask is in edit
* mode.
*
* Returns: (element-type PikaItem) (transfer container):
* The list of selected drawables in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libpika and must not be freed.
*
* Since: 3.0
**/
GList *
pika_image_list_selected_drawables (PikaImage *image)
{
PikaItem **drawables;
gint num_drawables;
GList *list = NULL;
gint i;
drawables = pika_image_get_selected_drawables (image, &num_drawables);
for (i = 0; i < num_drawables; i++)
list = g_list_prepend (list, drawables[i]);
g_free (drawables);
return g_list_reverse (list);
}
/**
* pika_image_get_colormap:
* @image: The image.
* @colormap_len: (out) (optional): The size (in bytes) of the returned colormap
* @num_colors: (out) (optional): Returns the number of colors in the colormap array.
*
* Returns the image's colormap
*
* This procedure returns an actual pointer to the image's colormap, as
* well as the number of colors contained in the colormap. If the image
* is not of base type INDEXED, this pointer will be NULL.
*
* Returns: (array length=colormap_len): The image's colormap.
*/
guchar *
pika_image_get_colormap (PikaImage *image,
gint *colormap_len,
gint *num_colors)
{
GBytes *bytes;
gsize num_bytes;
guchar *cmap;
bytes = _pika_image_get_colormap (image);
cmap = g_bytes_unref_to_data (bytes, &num_bytes);
if (colormap_len)
*colormap_len = num_bytes;
if (num_colors)
*num_colors = num_bytes / 3;
return cmap;
}
/**
* pika_image_set_colormap:
* @image: The image.
* @colormap: (array): The new colormap values.
* @num_colors: Number of colors in the colormap array.
*
* Sets the entries in the image's colormap.
*
* This procedure sets the entries in the specified image's colormap.
* The number of colors is specified by the "num_colors" parameter
* and corresponds to the number of INT8 triples that must be contained
* in the "cmap" array.
*
* Returns: TRUE on success.
*/
gboolean
pika_image_set_colormap (PikaImage *image,
const guchar *colormap,
gint num_colors)
{
GBytes *bytes;
gboolean ret;
bytes = g_bytes_new_static (colormap, num_colors * 3);
ret = _pika_image_set_colormap (image, bytes);
g_bytes_unref (bytes);
return ret;
}
/**
* pika_image_get_thumbnail_data:
* @image: The image.
* @width: (inout): The requested thumbnail width.
* @height: (inout): The requested thumbnail height.
* @bpp: (out): The previews bpp.
*
* Get a thumbnail of an image.
*
* This function gets data from which a thumbnail of an image preview
* can be created. Maximum x or y dimension is 1024 pixels. The pixels
* are returned in RGB[A] or GRAY[A] format. The bpp return value
* gives the number of bytes per pixel in the image.
*
* Returns: (array) (transfer full): the thumbnail data.
**/
guchar *
pika_image_get_thumbnail_data (PikaImage *image,
gint *width,
gint *height,
gint *bpp)
{
gint ret_width;
gint ret_height;
GBytes *image_bytes;
guchar *image_data;
gsize data_size;
_pika_image_thumbnail (image,
*width,
*height,
&ret_width,
&ret_height,
bpp,
&image_bytes);
image_data = g_bytes_unref_to_data (image_bytes, &data_size);
*width = ret_width;
*height = ret_height;
return image_data;
}
/**
* pika_image_get_thumbnail:
* @image: the #PikaImage
* @width: the requested thumbnail width (<= 1024 pixels)
* @height: the requested thumbnail height (<= 1024 pixels)
* @alpha: how to handle an alpha channel
*
* Retrieves a thumbnail pixbuf for @image.
* The thumbnail will be not larger than the requested size.
*
* Returns: (transfer full): a new #GdkPixbuf
*
* Since: 2.2
**/
GdkPixbuf *
pika_image_get_thumbnail (PikaImage *image,
gint width,
gint height,
PikaPixbufTransparency alpha)
{
gint thumb_width = width;
gint thumb_height = height;
gint thumb_bpp;
guchar *data;
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
data = pika_image_get_thumbnail_data (image,
&thumb_width,
&thumb_height,
&thumb_bpp);
if (data)
return _pika_pixbuf_from_data (data,
thumb_width, thumb_height, thumb_bpp,
alpha);
else
return NULL;
}
/**
* pika_image_get_metadata:
* @image: The image.
*
* Returns the image's metadata.
*
* Returns exif/iptc/xmp metadata from the image.
*
* Returns: (nullable) (transfer full): The exif/ptc/xmp metadata,
* or %NULL if there is none.
*
* Since: 2.10
**/
PikaMetadata *
pika_image_get_metadata (PikaImage *image)
{
PikaMetadata *metadata = NULL;
gchar *metadata_string;
metadata_string = _pika_image_get_metadata (image);
if (metadata_string)
{
metadata = pika_metadata_deserialize (metadata_string);
g_free (metadata_string);
}
return metadata;
}
/**
* pika_image_set_metadata:
* @image: The image.
* @metadata: The exif/ptc/xmp metadata.
*
* Set the image's metadata.
*
* Sets exif/iptc/xmp metadata on the image, or deletes it if
* @metadata is %NULL.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_set_metadata (PikaImage *image,
PikaMetadata *metadata)
{
gchar *metadata_string = NULL;
gboolean success;
if (metadata)
metadata_string = pika_metadata_serialize (metadata);
success = _pika_image_set_metadata (image, metadata_string);
if (metadata_string)
g_free (metadata_string);
return success;
}

84
libpika/pikaimage.h Normal file
View File

@ -0,0 +1,84 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* pikaimage.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_H__
#define __PIKA_IMAGE_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define PIKA_TYPE_IMAGE (pika_image_get_type ())
G_DECLARE_FINAL_TYPE (PikaImage, pika_image, PIKA, IMAGE, GObject)
gint32 pika_image_get_id (PikaImage *image);
PikaImage * pika_image_get_by_id (gint32 image_id);
gboolean pika_image_is_valid (PikaImage *image);
GList * pika_list_images (void);
GList * pika_image_list_layers (PikaImage *image);
GList * pika_image_list_channels (PikaImage *image);
GList * pika_image_list_vectors (PikaImage *image);
GList * pika_image_list_selected_layers (PikaImage *image);
gboolean pika_image_take_selected_layers (PikaImage *image,
GList *layers);
GList * pika_image_list_selected_channels (PikaImage *image);
gboolean pika_image_take_selected_channels (PikaImage *image,
GList *channels);
GList * pika_image_list_selected_vectors (PikaImage *image);
gboolean pika_image_take_selected_vectors (PikaImage *image,
GList *vectors);
GList * pika_image_list_selected_drawables(PikaImage *image);
guchar * pika_image_get_colormap (PikaImage *image,
gint *colormap_len,
gint *num_colors);
gboolean pika_image_set_colormap (PikaImage *image,
const guchar *colormap,
gint num_colors);
guchar * pika_image_get_thumbnail_data (PikaImage *image,
gint *width,
gint *height,
gint *bpp);
GdkPixbuf * pika_image_get_thumbnail (PikaImage *image,
gint width,
gint height,
PikaPixbufTransparency alpha);
PikaMetadata * pika_image_get_metadata (PikaImage *image);
gboolean pika_image_set_metadata (PikaImage *image,
PikaMetadata *metadata);
G_END_DECLS
#endif /* __PIKA_IMAGE_H__ */

3534
libpika/pikaimage_pdb.c Normal file

File diff suppressed because it is too large Load Diff

207
libpika/pikaimage_pdb.h Normal file
View File

@ -0,0 +1,207 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimage_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_PDB_H__
#define __PIKA_IMAGE_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_image_id_is_valid (gint image_id);
PikaImage** pika_get_images (gint *num_images);
PikaImage* pika_image_new (gint width,
gint height,
PikaImageBaseType type);
PikaImage* pika_image_new_with_precision (gint width,
gint height,
PikaImageBaseType type,
PikaPrecision precision);
PikaImage* pika_image_duplicate (PikaImage *image);
gboolean pika_image_delete (PikaImage *image);
PikaImageBaseType pika_image_get_base_type (PikaImage *image);
PikaPrecision pika_image_get_precision (PikaImage *image);
PikaLayerMode pika_image_get_default_new_layer_mode (PikaImage *image);
gint pika_image_get_width (PikaImage *image);
gint pika_image_get_height (PikaImage *image);
PikaLayer** pika_image_get_layers (PikaImage *image,
gint *num_layers);
PikaChannel** pika_image_get_channels (PikaImage *image,
gint *num_channels);
PikaVectors** pika_image_get_vectors (PikaImage *image,
gint *num_vectors);
gboolean pika_image_unset_active_channel (PikaImage *image);
PikaLayer* pika_image_get_floating_sel (PikaImage *image);
PikaDrawable* pika_image_floating_sel_attached_to (PikaImage *image);
gboolean pika_image_pick_color (PikaImage *image,
gint num_drawables,
const PikaItem **drawables,
gdouble x,
gdouble y,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
PikaRGB *color);
PikaLayer* pika_image_pick_correlate_layer (PikaImage *image,
gint x,
gint y);
gboolean pika_image_insert_layer (PikaImage *image,
PikaLayer *layer,
PikaLayer *parent,
gint position);
gboolean pika_image_remove_layer (PikaImage *image,
PikaLayer *layer);
gboolean pika_image_freeze_layers (PikaImage *image);
gboolean pika_image_thaw_layers (PikaImage *image);
gboolean pika_image_insert_channel (PikaImage *image,
PikaChannel *channel,
PikaChannel *parent,
gint position);
gboolean pika_image_remove_channel (PikaImage *image,
PikaChannel *channel);
gboolean pika_image_freeze_channels (PikaImage *image);
gboolean pika_image_thaw_channels (PikaImage *image);
gboolean pika_image_insert_vectors (PikaImage *image,
PikaVectors *vectors,
PikaVectors *parent,
gint position);
gboolean pika_image_remove_vectors (PikaImage *image,
PikaVectors *vectors);
gboolean pika_image_freeze_vectors (PikaImage *image);
gboolean pika_image_thaw_vectors (PikaImage *image);
gint pika_image_get_item_position (PikaImage *image,
PikaItem *item);
gboolean pika_image_raise_item (PikaImage *image,
PikaItem *item);
gboolean pika_image_lower_item (PikaImage *image,
PikaItem *item);
gboolean pika_image_raise_item_to_top (PikaImage *image,
PikaItem *item);
gboolean pika_image_lower_item_to_bottom (PikaImage *image,
PikaItem *item);
gboolean pika_image_reorder_item (PikaImage *image,
PikaItem *item,
PikaItem *parent,
gint position);
PikaLayer* pika_image_flatten (PikaImage *image);
PikaLayer* pika_image_merge_visible_layers (PikaImage *image,
PikaMergeType merge_type);
PikaLayer* pika_image_merge_down (PikaImage *image,
PikaLayer *merge_layer,
PikaMergeType merge_type);
PikaLayer* pika_image_merge_layer_group (PikaImage *image,
PikaLayer *layer_group);
G_GNUC_INTERNAL GBytes* _pika_image_get_colormap (PikaImage *image);
G_GNUC_INTERNAL gboolean _pika_image_set_colormap (PikaImage *image,
GBytes *colormap);
G_GNUC_INTERNAL gchar* _pika_image_get_metadata (PikaImage *image);
G_GNUC_INTERNAL gboolean _pika_image_set_metadata (PikaImage *image,
const gchar *metadata_string);
gboolean pika_image_clean_all (PikaImage *image);
gboolean pika_image_is_dirty (PikaImage *image);
G_GNUC_INTERNAL gboolean _pika_image_thumbnail (PikaImage *image,
gint width,
gint height,
gint *actual_width,
gint *actual_height,
gint *bpp,
GBytes **thumbnail_data);
PikaLayer** pika_image_get_selected_layers (PikaImage *image,
gint *num_layers);
gboolean pika_image_set_selected_layers (PikaImage *image,
gint num_layers,
const PikaLayer **layers);
PikaChannel** pika_image_get_selected_channels (PikaImage *image,
gint *num_channels);
gboolean pika_image_set_selected_channels (PikaImage *image,
gint num_channels,
const PikaChannel **channels);
PikaVectors** pika_image_get_selected_vectors (PikaImage *image,
gint *num_vectors);
gboolean pika_image_set_selected_vectors (PikaImage *image,
gint num_vectors,
const PikaVectors **vectors);
PikaItem** pika_image_get_selected_drawables (PikaImage *image,
gint *num_drawables);
PikaSelection* pika_image_get_selection (PikaImage *image);
gboolean pika_image_get_component_active (PikaImage *image,
PikaChannelType component);
gboolean pika_image_set_component_active (PikaImage *image,
PikaChannelType component,
gboolean active);
gboolean pika_image_get_component_visible (PikaImage *image,
PikaChannelType component);
gboolean pika_image_set_component_visible (PikaImage *image,
PikaChannelType component,
gboolean visible);
GFile* pika_image_get_file (PikaImage *image);
gboolean pika_image_set_file (PikaImage *image,
GFile *file);
GFile* pika_image_get_xcf_file (PikaImage *image);
GFile* pika_image_get_imported_file (PikaImage *image);
GFile* pika_image_get_exported_file (PikaImage *image);
gchar* pika_image_get_name (PikaImage *image);
gboolean pika_image_get_resolution (PikaImage *image,
gdouble *xresolution,
gdouble *yresolution);
gboolean pika_image_set_resolution (PikaImage *image,
gdouble xresolution,
gdouble yresolution);
PikaUnit pika_image_get_unit (PikaImage *image);
gboolean pika_image_set_unit (PikaImage *image,
PikaUnit unit);
guint pika_image_get_tattoo_state (PikaImage *image);
gboolean pika_image_set_tattoo_state (PikaImage *image,
guint tattoo_state);
PikaLayer* pika_image_get_layer_by_tattoo (PikaImage *image,
guint tattoo);
PikaChannel* pika_image_get_channel_by_tattoo (PikaImage *image,
guint tattoo);
PikaVectors* pika_image_get_vectors_by_tattoo (PikaImage *image,
guint tattoo);
PikaLayer* pika_image_get_layer_by_name (PikaImage *image,
const gchar *name);
PikaChannel* pika_image_get_channel_by_name (PikaImage *image,
const gchar *name);
PikaVectors* pika_image_get_vectors_by_name (PikaImage *image,
const gchar *name);
gboolean pika_image_attach_parasite (PikaImage *image,
const PikaParasite *parasite);
gboolean pika_image_detach_parasite (PikaImage *image,
const gchar *name);
PikaParasite* pika_image_get_parasite (PikaImage *image,
const gchar *name);
gchar** pika_image_get_parasite_list (PikaImage *image);
gboolean pika_image_policy_rotate (PikaImage *image,
gboolean interactive);
gboolean pika_image_policy_color_profile (PikaImage *image,
gboolean interactive);
G_END_DECLS
#endif /* __PIKA_IMAGE_PDB_H__ */

View File

@ -0,0 +1,252 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagecolorprofile.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "pika.h"
/**
* pika_image_get_color_profile:
* @image: The image.
*
* Returns the image's color profile
*
* This procedure returns the image's color profile, or NULL if the
* image has no color profile assigned.
*
* Returns: (transfer full): The image's color profile. The returned
* value must be freed with g_object_unref().
*
* Since: 2.10
**/
PikaColorProfile *
pika_image_get_color_profile (PikaImage *image)
{
GBytes *data;
data = _pika_image_get_color_profile (image);
if (data)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile;
}
return NULL;
}
/**
* pika_image_set_color_profile:
* @image: The image.
* @profile: (nullable): A #PikaColorProfile, or %NULL.
*
* Sets the image's color profile
*
* This procedure sets the image's color profile.
*
* Returns: %TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_set_color_profile (PikaImage *image,
PikaColorProfile *profile)
{
const guint8 *data = NULL;
GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || PIKA_IS_COLOR_PROFILE (profile),
FALSE);
if (profile)
{
gsize l;
data = pika_color_profile_get_icc_profile (profile, &l);
bytes = g_bytes_new_static (data, l);
}
ret = _pika_image_set_color_profile (image, bytes);
g_bytes_unref (bytes);
return ret;
}
/**
* pika_image_get_simulation_profile:
* @image: The image.
*
* Returns the image's simulation color profile
*
* This procedure returns the image's simulation color profile, or NULL if
* the image has no simulation color profile assigned.
*
* Returns: (transfer full): The image's simulation color profile. The
* returned value must be freed with g_object_unref().
*
* Since: 3.0
**/
PikaColorProfile *
pika_image_get_simulation_profile (PikaImage *image)
{
GBytes *data;
data = _pika_image_get_simulation_profile (image);
if (data)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile;
}
return NULL;
}
/**
* pika_image_set_simulation_profile:
* @image: The image.
* @profile: A #PikaColorProfile, or %NULL.
*
* Sets the image's simulation color profile
*
* This procedure sets the image's simulation color profile.
*
* Returns: %TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_set_simulation_profile (PikaImage *image,
PikaColorProfile *profile)
{
const guint8 *data = NULL;
GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || PIKA_IS_COLOR_PROFILE (profile),
FALSE);
if (profile)
{
gsize l;
data = pika_color_profile_get_icc_profile (profile, &l);
bytes = g_bytes_new_static (data, l);
}
ret = _pika_image_set_simulation_profile (image, bytes);
g_bytes_unref (bytes);
return ret;
}
/**
* pika_image_get_effective_color_profile:
* @image: The image.
*
* Returns the color profile that is used for the image.
*
* This procedure returns the color profile that is actually used for
* this image, which is the profile returned by
* pika_image_get_color_profile() if the image has a profile assigned,
* or the default RGB profile from preferences if no profile is
* assigned to the image. If there is no default RGB profile configured
* in preferences either, a generated default RGB profile is returned.
*
* Returns: (transfer full): The color profile. The returned value must
* be freed with g_object_unref().
*
* Since: 2.10
**/
PikaColorProfile *
pika_image_get_effective_color_profile (PikaImage *image)
{
GBytes *data;
data = _pika_image_get_effective_color_profile (image);
if (data)
{
PikaColorProfile *profile;
profile = pika_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile;
}
return NULL;
}
/**
* pika_image_convert_color_profile:
* @image: The image.
* @profile: The color profile to convert to.
* @intent: Rendering intent.
* @bpc: Black point compensation.
*
* Convert the image's layers to a color profile
*
* This procedure converts from the image's color profile (or the
* default RGB profile if none is set) to the given color profile. Only
* RGB color profiles are accepted.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_convert_color_profile (PikaImage *image,
PikaColorProfile *profile,
PikaColorRenderingIntent intent,
gboolean bpc)
{
const guint8 *data = NULL;
GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || PIKA_IS_COLOR_PROFILE (profile),
FALSE);
if (profile)
{
gsize l;
data = pika_color_profile_get_icc_profile (profile, &l);
bytes = g_bytes_new_static (data, l);
}
ret = _pika_image_convert_color_profile (image, bytes, intent, bpc);
g_bytes_unref (bytes);
return ret;
}

View File

@ -0,0 +1,51 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagecolorprofile.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_COLOR_PROFILE_H__
#define __PIKA_IMAGE_COLOR_PROFILE_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
PikaColorProfile * pika_image_get_color_profile (PikaImage *image);
gboolean pika_image_set_color_profile (PikaImage *image,
PikaColorProfile *profile);
PikaColorProfile * pika_image_get_simulation_profile (PikaImage *image);
gboolean pika_image_set_simulation_profile (PikaImage *image,
PikaColorProfile *profile);
PikaColorProfile * pika_image_get_effective_color_profile (PikaImage *image);
gboolean pika_image_convert_color_profile (PikaImage *image,
PikaColorProfile *profile,
PikaColorRenderingIntent intent,
gboolean bpc);
G_END_DECLS
#endif /* __PIKA_IMAGE_COLOR_PROFILE_H__ */

View File

@ -0,0 +1,562 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagecolorprofile_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikaimagecolorprofile
* @title: pikaimagecolorprofile
* @short_description: Operations on an image's color profile.
*
* Operations on an image's color profile.
**/
/**
* _pika_image_get_color_profile:
* @image: The image.
*
* Returns the image's color profile
*
* This procedure returns the image's color profile, or NULL if the
* image has no color profile assigned.
*
* Returns: (transfer full): The image's serialized color profile.
*
* Since: 2.10
**/
GBytes *
_pika_image_get_color_profile (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
GBytes *profile_data = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-get-color-profile",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
profile_data = PIKA_VALUES_DUP_BYTES (return_vals, 1);
pika_value_array_unref (return_vals);
return profile_data;
}
/**
* _pika_image_get_effective_color_profile:
* @image: The image.
*
* Returns the color profile that is used for the image
*
* This procedure returns the color profile that is actually used for
* this image, which is the profile returned by
* pika_image_get_color_profile() if the image has a profile assigned,
* or a generated default RGB or grayscale profile, according to the
* image's type.
*
* Returns: (transfer full): The image's serialized color profile.
*
* Since: 2.10
**/
GBytes *
_pika_image_get_effective_color_profile (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
GBytes *profile_data = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-get-effective-color-profile",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
profile_data = PIKA_VALUES_DUP_BYTES (return_vals, 1);
pika_value_array_unref (return_vals);
return profile_data;
}
/**
* _pika_image_set_color_profile:
* @image: The image.
* @color_profile: The new serialized color profile.
*
* Sets the image's color profile
*
* This procedure sets the image's color profile, or unsets it if NULL
* is passed as 'color_profile'. This procedure does no color
* conversion. However, it will change the pixel format of all layers
* to contain the babl space matching the profile. You must call this
* procedure before adding layers to the image.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
_pika_image_set_color_profile (PikaImage *image,
GBytes *color_profile)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_BYTES, color_profile,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-color-profile",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_set_color_profile_from_file:
* @image: The image.
* @file: The file containing the new color profile.
*
* Sets the image's color profile from an ICC file
*
* This procedure sets the image's color profile from a file containing
* an ICC profile, or unsets it if NULL is passed as 'file'. This
* procedure does no color conversion. However, it will change the
* pixel format of all layers to contain the babl space matching the
* profile. You must call this procedure before adding layers to the
* image.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_set_color_profile_from_file (PikaImage *image,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-color-profile-from-file",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* _pika_image_get_simulation_profile:
* @image: The image.
*
* Returns the image's simulation color profile
*
* This procedure returns the image's simulation color profile, or NULL
* if the image has no simulation color profile assigned.
*
* Returns: (transfer full): The image's serialized simulation color profile.
*
* Since: 3.0
**/
GBytes *
_pika_image_get_simulation_profile (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
GBytes *profile_data = NULL;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-get-simulation-profile",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
profile_data = PIKA_VALUES_DUP_BYTES (return_vals, 1);
pika_value_array_unref (return_vals);
return profile_data;
}
/**
* _pika_image_set_simulation_profile:
* @image: The image.
* @color_profile: The new serialized simulation color profile.
*
* Sets the image's simulation color profile
*
* This procedure sets the image's simulation color profile, or unsets
* it if NULL is passed as 'color_profile'. This procedure does no
* color conversion.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
_pika_image_set_simulation_profile (PikaImage *image,
GBytes *color_profile)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_BYTES, color_profile,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-simulation-profile",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_set_simulation_profile_from_file:
* @image: The image.
* @file: The file containing the new simulation color profile.
*
* Sets the image's simulation color profile from an ICC file
*
* This procedure sets the image's simulation color profile from a file
* containing an ICC profile, or unsets it if NULL is passed as 'file'.
* This procedure does no color conversion.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_set_simulation_profile_from_file (PikaImage *image,
GFile *file)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-simulation-profile-from-file",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_get_simulation_intent:
* @image: The image.
*
* Returns the image's simulation rendering intent
*
* This procedure returns the image's simulation rendering intent.
*
* Returns: The image's simulation rendering intent.
*
* Since: 3.0
**/
PikaColorRenderingIntent
pika_image_get_simulation_intent (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaColorRenderingIntent intent = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-get-simulation-intent",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
intent = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return intent;
}
/**
* pika_image_set_simulation_intent:
* @image: The image.
* @intent: A PikaColorRenderingIntent.
*
* Sets the image's simulation rendering intent
*
* This procedure sets the image's simulation rendering intent.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_set_simulation_intent (PikaImage *image,
PikaColorRenderingIntent intent)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_COLOR_RENDERING_INTENT, intent,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-simulation-intent",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_get_simulation_bpc:
* @image: The image.
*
* Returns whether the image has Black Point Compensation enabled for
* its simulation
*
* This procedure returns whether the image has Black Point
* Compensation enabled for its simulation
*
* Returns: The Black Point Compensation status.
*
* Since: 3.0
**/
gboolean
pika_image_get_simulation_bpc (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean bpc = FALSE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-get-simulation-bpc",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
bpc = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);
pika_value_array_unref (return_vals);
return bpc;
}
/**
* pika_image_set_simulation_bpc:
* @image: The image.
* @bpc: The Black Point Compensation status.
*
* Sets whether the image has Black Point Compensation enabled for its
* simulation
*
* This procedure whether the image has Black Point Compensation
* enabled for its simulation
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
pika_image_set_simulation_bpc (PikaImage *image,
gboolean bpc)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_BOOLEAN, bpc,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-set-simulation-bpc",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* _pika_image_convert_color_profile:
* @image: The image.
* @color_profile: The serialized color profile.
* @intent: Rendering intent.
* @bpc: Black point compensation.
*
* Convert the image's layers to a color profile
*
* This procedure converts from the image's color profile (or the
* default RGB or grayscale profile if none is set) to the given color
* profile. Only RGB and grayscale color profiles are accepted,
* according to the image's type.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
_pika_image_convert_color_profile (PikaImage *image,
GBytes *color_profile,
PikaColorRenderingIntent intent,
gboolean bpc)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_BYTES, color_profile,
PIKA_TYPE_COLOR_RENDERING_INTENT, intent,
G_TYPE_BOOLEAN, bpc,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-color-profile",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_convert_color_profile_from_file:
* @image: The image.
* @file: The file containing the new color profile.
* @intent: Rendering intent.
* @bpc: Black point compensation.
*
* Convert the image's layers to a color profile
*
* This procedure converts from the image's color profile (or the
* default RGB or grayscale profile if none is set) to an ICC profile
* specified by 'file'. Only RGB and grayscale color profiles are
* accepted, according to the image's type.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_convert_color_profile_from_file (PikaImage *image,
GFile *file,
PikaColorRenderingIntent intent,
gboolean bpc)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_FILE, file,
PIKA_TYPE_COLOR_RENDERING_INTENT, intent,
G_TYPE_BOOLEAN, bpc,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-color-profile-from-file",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,64 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagecolorprofile_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_COLOR_PROFILE_PDB_H__
#define __PIKA_IMAGE_COLOR_PROFILE_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL GBytes* _pika_image_get_color_profile (PikaImage *image);
G_GNUC_INTERNAL GBytes* _pika_image_get_effective_color_profile (PikaImage *image);
G_GNUC_INTERNAL gboolean _pika_image_set_color_profile (PikaImage *image,
GBytes *color_profile);
gboolean pika_image_set_color_profile_from_file (PikaImage *image,
GFile *file);
G_GNUC_INTERNAL GBytes* _pika_image_get_simulation_profile (PikaImage *image);
G_GNUC_INTERNAL gboolean _pika_image_set_simulation_profile (PikaImage *image,
GBytes *color_profile);
gboolean pika_image_set_simulation_profile_from_file (PikaImage *image,
GFile *file);
PikaColorRenderingIntent pika_image_get_simulation_intent (PikaImage *image);
gboolean pika_image_set_simulation_intent (PikaImage *image,
PikaColorRenderingIntent intent);
gboolean pika_image_get_simulation_bpc (PikaImage *image);
gboolean pika_image_set_simulation_bpc (PikaImage *image,
gboolean bpc);
G_GNUC_INTERNAL gboolean _pika_image_convert_color_profile (PikaImage *image,
GBytes *color_profile,
PikaColorRenderingIntent intent,
gboolean bpc);
gboolean pika_image_convert_color_profile_from_file (PikaImage *image,
GFile *file,
PikaColorRenderingIntent intent,
gboolean bpc);
G_END_DECLS
#endif /* __PIKA_IMAGE_COLOR_PROFILE_PDB_H__ */

294
libpika/pikaimagecombobox.c Normal file
View File

@ -0,0 +1,294 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikaimagecombobox.c
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "pika.h"
#include "pikauitypes.h"
#include "pikaimagecombobox.h"
#include "pikapixbuf.h"
/**
* SECTION: pikaimagecombobox
* @title: PikaImageComboBox
* @short_description: A widget providing a popup menu of images.
*
* A widget providing a popup menu of images.
**/
#define THUMBNAIL_SIZE 24
#define WIDTH_REQUEST 200
typedef struct _PikaImageComboBoxClass PikaImageComboBoxClass;
struct _PikaImageComboBox
{
PikaIntComboBox parent_instance;
PikaImageConstraintFunc constraint;
gpointer data;
GDestroyNotify data_destroy;
};
struct _PikaImageComboBoxClass
{
PikaIntComboBoxClass parent_class;
};
static void pika_image_combo_box_finalize (GObject *object);
static void pika_image_combo_box_populate (PikaImageComboBox *combo_box);
static void pika_image_combo_box_model_add (GtkListStore *store,
GList *images,
PikaImageConstraintFunc constraint,
gpointer data);
static void pika_image_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time);
static void pika_image_combo_box_changed (PikaImageComboBox *combo_box);
static const GtkTargetEntry target = { "application/x-pika-image-id", 0 };
G_DEFINE_TYPE (PikaImageComboBox, pika_image_combo_box,
PIKA_TYPE_INT_COMBO_BOX)
#define parent_class pika_image_combo_box_parent_class
static void
pika_image_combo_box_class_init (PikaImageComboBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = pika_image_combo_box_finalize;
widget_class->drag_data_received = pika_image_combo_box_drag_data_received;
}
static void
pika_image_combo_box_init (PikaImageComboBox *combo_box)
{
gtk_drag_dest_set (GTK_WIDGET (combo_box),
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
&target, 1,
GDK_ACTION_COPY);
}
static void
pika_image_combo_box_finalize (GObject *object)
{
PikaImageComboBox *combo = PIKA_IMAGE_COMBO_BOX (object);
if (combo->data_destroy)
combo->data_destroy (combo->data);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* pika_image_combo_box_new:
* @constraint: (nullable): A #PikaImageConstraintFunc or %NULL
* @data: (closure constraint): A pointer that is passed to @constraint
* @data_destroy: (destroy data): Destroy function for @data.
*
* Creates a new #PikaIntComboBox filled with all currently opened
* images. If a @constraint function is specified, it is called for
* each image and only if the function returns %TRUE, the image is
* added to the combobox.
*
* You should use pika_int_combo_box_connect() to initialize and
* connect the combo. Use pika_int_combo_box_set_active() to get the
* active image ID and pika_int_combo_box_get_active() to retrieve the
* ID of the selected image.
*
* Returns: a new #PikaIntComboBox.
*
* Since: 2.2
**/
GtkWidget *
pika_image_combo_box_new (PikaImageConstraintFunc constraint,
gpointer data,
GDestroyNotify data_destroy)
{
PikaImageComboBox *combo_box;
combo_box = g_object_new (PIKA_TYPE_IMAGE_COMBO_BOX,
"width-request", WIDTH_REQUEST,
"ellipsize", PANGO_ELLIPSIZE_MIDDLE,
NULL);
combo_box->constraint = constraint;
combo_box->data = data;
combo_box->data_destroy = data_destroy;
pika_image_combo_box_populate (combo_box);
g_signal_connect (combo_box, "changed",
G_CALLBACK (pika_image_combo_box_changed),
NULL);
return GTK_WIDGET (combo_box);
}
static void
pika_image_combo_box_populate (PikaImageComboBox *combo_box)
{
GtkTreeModel *model;
GtkTreeIter iter;
GList *images;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
images = pika_list_images ();
pika_image_combo_box_model_add (GTK_LIST_STORE (model), images,
combo_box->constraint,
combo_box->data);
g_list_free (images);
if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
}
static void
pika_image_combo_box_model_add (GtkListStore *store,
GList *images,
PikaImageConstraintFunc constraint,
gpointer data)
{
GtkTreeIter iter;
GList *list;
for (list = images; list; list = g_list_next (list))
{
PikaImage *image = list->data;
gint32 image_id = pika_image_get_id (image);
if (! constraint || constraint (image, data))
{
gchar *image_name = pika_image_get_name (image);
gchar *label;
GdkPixbuf *thumb;
label = g_strdup_printf ("%s-%d", image_name, image_id);
g_free (image_name);
thumb = pika_image_get_thumbnail (image,
THUMBNAIL_SIZE, THUMBNAIL_SIZE,
PIKA_PIXBUF_SMALL_CHECKS);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
PIKA_INT_STORE_VALUE, image_id,
PIKA_INT_STORE_LABEL, label,
PIKA_INT_STORE_PIXBUF, thumb,
-1);
if (thumb)
g_object_unref (thumb);
g_free (label);
}
}
}
static void
pika_image_combo_box_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time)
{
gint length = gtk_selection_data_get_length (selection);
gchar *str;
if (gtk_selection_data_get_format (selection) != 8 || length < 1)
{
g_warning ("%s: received invalid image ID data", G_STRFUNC);
return;
}
str = g_strndup ((const gchar *) gtk_selection_data_get_data (selection),
length);
if (g_utf8_validate (str, -1, NULL))
{
gint pid;
gint ID;
if (sscanf (str, "%i:%i", &pid, &ID) == 2 &&
pid == pika_getpid ())
{
pika_int_combo_box_set_active (PIKA_INT_COMBO_BOX (widget), ID);
}
}
g_free (str);
}
static void
pika_image_combo_box_changed (PikaImageComboBox *combo_box)
{
gint image_ID;
if (pika_int_combo_box_get_active (PIKA_INT_COMBO_BOX (combo_box),
&image_ID))
{
if (! pika_image_get_by_id (image_ID))
{
GtkTreeModel *model;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
g_signal_stop_emission_by_name (combo_box, "changed");
gtk_list_store_clear (GTK_LIST_STORE (model));
pika_image_combo_box_populate (combo_box);
}
}
}

View File

@ -0,0 +1,56 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikaimagecombobox.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__PIKA_UI_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pikaui.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_COMBO_BOX_H__
#define __PIKA_IMAGE_COMBO_BOX_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
/**
* PikaImageConstraintFunc:
* @image:
* @data: (closure):
*/
typedef gboolean (* PikaImageConstraintFunc) (PikaImage *image,
gpointer data);
#define PIKA_TYPE_IMAGE_COMBO_BOX (pika_image_combo_box_get_type ())
#define PIKA_IMAGE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_IMAGE_COMBO_BOX, PikaImageComboBox))
#define PIKA_IS_IMAGE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_IMAGE_COMBO_BOX)
GType pika_image_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * pika_image_combo_box_new (PikaImageConstraintFunc constraint,
gpointer data,
GDestroyNotify data_destroy);
G_END_DECLS
#endif /* __PIKA_IMAGE_COMBO_BOX_H__ */

View File

@ -0,0 +1,252 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimageconvert_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikaimageconvert
* @title: pikaimageconvert
* @short_description: Conversions between RGB, indexed, and grayscale modes.
*
* Conversions between RGB, indexed, and grayscale modes.
**/
/**
* pika_image_convert_rgb:
* @image: The image.
*
* Convert specified image to RGB color
*
* This procedure converts the specified image to RGB color. This
* process requires an image in Grayscale or Indexed color mode. No
* image content is lost in this process aside from the colormap for an
* indexed image.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_convert_rgb (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-rgb",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_convert_grayscale:
* @image: The image.
*
* Convert specified image to grayscale
*
* This procedure converts the specified image to grayscale. This
* process requires an image in RGB or Indexed color mode.
*
* Returns: TRUE on success.
**/
gboolean
pika_image_convert_grayscale (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-grayscale",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_convert_indexed:
* @image: The image.
* @dither_type: The dither type to use.
* @palette_type: The type of palette to use.
* @num_cols: The number of colors to quantize to, ignored unless (palette_type == PIKA_CONVERT_PALETTE_GENERATE).
* @alpha_dither: Dither transparency to fake partial opacity.
* @remove_unused: Remove unused or duplicate color entries from final palette, ignored if (palette_type == PIKA_CONVERT_PALETTE_GENERATE).
* @palette: The name of the custom palette to use, ignored unless (palette_type == PIKA_CONVERT_PALETTE_CUSTOM).
*
* Convert specified image to and Indexed image
*
* This procedure converts the specified image to 'indexed' color. This
* process requires an image in RGB or Grayscale mode. The
* 'palette_type' specifies what kind of palette to use, A type of '0'
* means to use an optimal palette of 'num_cols' generated from the
* colors in the image. A type of '1' means to re-use the previous
* palette (not currently implemented). A type of '2' means to use the
* so-called WWW-optimized palette. Type '3' means to use only black
* and white colors. A type of '4' means to use a palette from the pika
* palettes directories. The 'dither type' specifies what kind of
* dithering to use. '0' means no dithering, '1' means standard
* Floyd-Steinberg error diffusion, '2' means Floyd-Steinberg error
* diffusion with reduced bleeding, '3' means dithering based on pixel
* location ('Fixed' dithering).
*
* Returns: TRUE on success.
**/
gboolean
pika_image_convert_indexed (PikaImage *image,
PikaConvertDitherType dither_type,
PikaConvertPaletteType palette_type,
gint num_cols,
gboolean alpha_dither,
gboolean remove_unused,
const gchar *palette)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_CONVERT_DITHER_TYPE, dither_type,
PIKA_TYPE_CONVERT_PALETTE_TYPE, palette_type,
G_TYPE_INT, num_cols,
G_TYPE_BOOLEAN, alpha_dither,
G_TYPE_BOOLEAN, remove_unused,
G_TYPE_STRING, palette,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-indexed",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_convert_set_dither_matrix:
* @width: Width of the matrix (0 to reset to default matrix).
* @height: Height of the matrix (0 to reset to default matrix).
* @matrix: The matrix -- all values must be >= 1.
*
* Set dither matrix for conversion to indexed
*
* This procedure sets the dither matrix used when converting images to
* INDEXED mode with positional dithering.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_convert_set_dither_matrix (gint width,
gint height,
GBytes *matrix)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_BYTES, matrix,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-set-dither-matrix",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_convert_precision:
* @image: The image.
* @precision: The new precision.
*
* Convert the image to the specified precision
*
* This procedure converts the image to the specified precision. Note
* that indexed images cannot be converted and are always in
* PIKA_PRECISION_U8.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
pika_image_convert_precision (PikaImage *image,
PikaPrecision precision)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_PRECISION, precision,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-convert-precision",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

View File

@ -0,0 +1,53 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimageconvert_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__PIKA_H_INSIDE__) && !defined (PIKA_COMPILATION)
#error "Only <libpika/pika.h> can be included directly."
#endif
#ifndef __PIKA_IMAGE_CONVERT_PDB_H__
#define __PIKA_IMAGE_CONVERT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean pika_image_convert_rgb (PikaImage *image);
gboolean pika_image_convert_grayscale (PikaImage *image);
gboolean pika_image_convert_indexed (PikaImage *image,
PikaConvertDitherType dither_type,
PikaConvertPaletteType palette_type,
gint num_cols,
gboolean alpha_dither,
gboolean remove_unused,
const gchar *palette);
gboolean pika_image_convert_set_dither_matrix (gint width,
gint height,
GBytes *matrix);
gboolean pika_image_convert_precision (PikaImage *image,
PikaPrecision precision);
G_END_DECLS
#endif /* __PIKA_IMAGE_CONVERT_PDB_H__ */

450
libpika/pikaimagegrid_pdb.c Normal file
View File

@ -0,0 +1,450 @@
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* pikaimagegrid_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "pika.h"
/**
* SECTION: pikaimagegrid
* @title: pikaimagegrid
* @short_description: Functions manuipulating an image's grid.
*
* Functions manuipulating an image's grid.
**/
/**
* pika_image_grid_get_spacing:
* @image: The image.
* @xspacing: (out): The image's grid horizontal spacing.
* @yspacing: (out): The image's grid vertical spacing.
*
* Gets the spacing of an image's grid.
*
* This procedure retrieves the horizontal and vertical spacing of an
* image's grid. It takes the image as parameter.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_get_spacing (PikaImage *image,
gdouble *xspacing,
gdouble *yspacing)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-get-spacing",
args);
pika_value_array_unref (args);
*xspacing = 0.0;
*yspacing = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*xspacing = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
*yspacing = PIKA_VALUES_GET_DOUBLE (return_vals, 2);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_set_spacing:
* @image: The image.
* @xspacing: The image's grid horizontal spacing.
* @yspacing: The image's grid vertical spacing.
*
* Sets the spacing of an image's grid.
*
* This procedure sets the horizontal and vertical spacing of an
* image's grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_set_spacing (PikaImage *image,
gdouble xspacing,
gdouble yspacing)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_DOUBLE, xspacing,
G_TYPE_DOUBLE, yspacing,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-set-spacing",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_get_offset:
* @image: The image.
* @xoffset: (out): The image's grid horizontal offset.
* @yoffset: (out): The image's grid vertical offset.
*
* Gets the offset of an image's grid.
*
* This procedure retrieves the horizontal and vertical offset of an
* image's grid. It takes the image as parameter.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_get_offset (PikaImage *image,
gdouble *xoffset,
gdouble *yoffset)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-get-offset",
args);
pika_value_array_unref (args);
*xoffset = 0.0;
*yoffset = 0.0;
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
{
*xoffset = PIKA_VALUES_GET_DOUBLE (return_vals, 1);
*yoffset = PIKA_VALUES_GET_DOUBLE (return_vals, 2);
}
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_set_offset:
* @image: The image.
* @xoffset: The image's grid horizontal offset.
* @yoffset: The image's grid vertical offset.
*
* Sets the offset of an image's grid.
*
* This procedure sets the horizontal and vertical offset of an image's
* grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_set_offset (PikaImage *image,
gdouble xoffset,
gdouble yoffset)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_DOUBLE, xoffset,
G_TYPE_DOUBLE, yoffset,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-set-offset",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_get_foreground_color:
* @image: The image.
* @fgcolor: (out caller-allocates): The image's grid foreground color.
*
* Sets the foreground color of an image's grid.
*
* This procedure gets the foreground color of an image's grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_get_foreground_color (PikaImage *image,
PikaRGB *fgcolor)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-get-foreground-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
PIKA_VALUES_GET_RGB (return_vals, 1, &*fgcolor);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_set_foreground_color:
* @image: The image.
* @fgcolor: The new foreground color.
*
* Gets the foreground color of an image's grid.
*
* This procedure sets the foreground color of an image's grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_set_foreground_color (PikaImage *image,
const PikaRGB *fgcolor)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_RGB, fgcolor,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-set-foreground-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_get_background_color:
* @image: The image.
* @bgcolor: (out caller-allocates): The image's grid background color.
*
* Sets the background color of an image's grid.
*
* This procedure gets the background color of an image's grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_get_background_color (PikaImage *image,
PikaRGB *bgcolor)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-get-background-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
if (success)
PIKA_VALUES_GET_RGB (return_vals, 1, &*bgcolor);
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_set_background_color:
* @image: The image.
* @bgcolor: The new background color.
*
* Gets the background color of an image's grid.
*
* This procedure sets the background color of an image's grid.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_set_background_color (PikaImage *image,
const PikaRGB *bgcolor)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_RGB, bgcolor,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-set-background-color",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}
/**
* pika_image_grid_get_style:
* @image: The image.
*
* Gets the style of an image's grid.
*
* This procedure retrieves the style of an image's grid.
*
* Returns: The image's grid style.
*
* Since: 2.4
**/
PikaGridStyle
pika_image_grid_get_style (PikaImage *image)
{
PikaValueArray *args;
PikaValueArray *return_vals;
PikaGridStyle style = 0;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-get-style",
args);
pika_value_array_unref (args);
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
style = PIKA_VALUES_GET_ENUM (return_vals, 1);
pika_value_array_unref (return_vals);
return style;
}
/**
* pika_image_grid_set_style:
* @image: The image.
* @style: The image's grid style.
*
* Sets the style unit of an image's grid.
*
* This procedure sets the style of an image's grid. It takes the image
* and the new style as parameters.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
pika_image_grid_set_style (PikaImage *image,
PikaGridStyle style)
{
PikaValueArray *args;
PikaValueArray *return_vals;
gboolean success = TRUE;
args = pika_value_array_new_from_types (NULL,
PIKA_TYPE_IMAGE, image,
PIKA_TYPE_GRID_STYLE, style,
G_TYPE_NONE);
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
"pika-image-grid-set-style",
args);
pika_value_array_unref (args);
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
pika_value_array_unref (return_vals);
return success;
}

Some files were not shown because too many files have changed in this diff Show More