gimp/app/widgets/gimppluginaction.c

239 lines
7.2 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppluginaction.c
* Copyright (C) 2004 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpmarshal.h"
#include "plug-in/gimppluginprocedure.h"
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
#include "gimppluginaction.h"
enum
{
SELECTED,
LAST_SIGNAL
};
enum
{
PROP_0,
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
PROP_PROCEDURE
};
static void gimp_plug_in_action_finalize (GObject *object);
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
static void gimp_plug_in_action_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_plug_in_action_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
static void gimp_plug_in_action_activate (GtkAction *action);
static void gimp_plug_in_action_connect_proxy (GtkAction *action,
GtkWidget *proxy);
G_DEFINE_TYPE (GimpPlugInAction, gimp_plug_in_action, GIMP_TYPE_ACTION)
#define parent_class gimp_plug_in_action_parent_class
static guint action_signals[LAST_SIGNAL] = { 0 };
static void
gimp_plug_in_action_class_init (GimpPlugInActionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
object_class->finalize = gimp_plug_in_action_finalize;
object_class->set_property = gimp_plug_in_action_set_property;
object_class->get_property = gimp_plug_in_action_get_property;
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
action_class->activate = gimp_plug_in_action_activate;
action_class->connect_proxy = gimp_plug_in_action_connect_proxy;
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
g_object_class_install_property (object_class, PROP_PROCEDURE,
g_param_spec_object ("procedure",
NULL, NULL,
GIMP_TYPE_PLUG_IN_PROCEDURE,
GIMP_PARAM_READWRITE));
action_signals[SELECTED] =
g_signal_new ("selected",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPlugInActionClass, selected),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_PLUG_IN_PROCEDURE);
}
static void
gimp_plug_in_action_init (GimpPlugInAction *action)
{
action->procedure = NULL;
}
static void
gimp_plug_in_action_finalize (GObject *object)
{
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object);
if (action->procedure)
{
g_object_unref (action->procedure);
action->procedure = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_plug_in_action_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object);
switch (prop_id)
{
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
case PROP_PROCEDURE:
g_value_set_object (value, action->procedure);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gimp_plug_in_action_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object);
switch (prop_id)
{
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
case PROP_PROCEDURE:
if (action->procedure)
g_object_unref (action->procedure);
action->procedure = GIMP_PLUG_IN_PROCEDURE (g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
static void
gimp_plug_in_action_activate (GtkAction *action)
{
GimpPlugInAction *plug_in_action = GIMP_PLUG_IN_ACTION (action);
gimp_plug_in_action_selected (plug_in_action, plug_in_action->procedure);
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
}
static void
gimp_plug_in_action_connect_proxy (GtkAction *action,
GtkWidget *proxy)
{
GimpPlugInAction *plug_in_action = GIMP_PLUG_IN_ACTION (action);
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
if (GTK_IS_IMAGE_MENU_ITEM (proxy) && plug_in_action->procedure)
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
{
GdkPixbuf *pixbuf;
pixbuf = gimp_plug_in_procedure_get_pixbuf (plug_in_action->procedure);
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
if (pixbuf)
{
GtkSettings *settings = gtk_widget_get_settings (proxy);
Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer <mitch@gimp.org> Allow plug-ins to register menu icons. Fixes bug #120500. * app/core/core-enums.[ch]: added enum GimpIconType which can be one of { STOCK_ID, IMAGE_FILE, INLINE_PIXBUF }. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_data) * app/config/gimpscanner.[ch] (gimp_scanner_parse_data): new functions which write/parse raw binary data. Needed for storing inline pixbufs in pluginrc. * app/config/gimpconfigwriter.[ch] (gimp_config_writer_identifier): new function which writes out an unquoted and unescaped string. * app/plug-in/plug-in-proc.[ch] (struct PlugInProcDef): added new members "icon_type", "icon_data_length" and "icon_data". Reordered members so file_proc specific stuff is at the end. (plug_in_proc_def_get_stock_id) (plug_in_proc_def_get_pixbuf): new functions to access the procedure's icon. * app/plug-in/plug-in-rc.c: save/restore the registered icons. * app/actions/file-dialog-actions.c * app/actions/plug-in-actions.c: set the action's stock ID from the procedure's stock ID. * app/widgets/gimppluginaction.c (gimp_plug_in_action_connect_proxy): if the procedure provides a pixbuf, set it as icon for the menu item. * app/menus/file-dialog-menu.[ch] * app/menus/file-open-menu.c * app/menus/file-save-menu.c * app/xcf/xcf.c: changed accordingly. * tools/pdbgen/pdb/plug_in.pdb (plugin_icon_register): new PDB function which can be called during query(). * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/plug_in_cmds.c * libgimp/gimpenums.h * libgimp/gimpplugin_pdb.c * libgimp/gimpplugin_pdb.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c: regenerated. * plug-ins/common/plugindetails.c * plug-ins/common/uniteditor.c * plug-ins/print/print.c: register stock_id icons. * plug-ins/common/screenshot.c: register an inline_pixbuf icon for testing purposes (used emblem-camera.png from gnome-icon-theme). * app/actions/dialogs-actions.c * app/actions/file-actions.c: unrelated: added some more icons to menu items.
2004-05-19 05:19:43 +08:00
gint width;
gint height;
GtkWidget *image;
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
&width, &height);
if (width != gdk_pixbuf_get_width (pixbuf) ||
height != gdk_pixbuf_get_height (pixbuf))
{
GdkPixbuf *copy;
copy = gdk_pixbuf_scale_simple (pixbuf, width, height,
GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
pixbuf = copy;
}
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
g_object_unref (pixbuf);
}
}
}
/* public functions */
GimpPlugInAction *
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
gimp_plug_in_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *stock_id,
GimpPlugInProcedure *procedure)
{
return g_object_new (GIMP_TYPE_PLUG_IN_ACTION,
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
"name", name,
"label", label,
"tooltip", tooltip,
"stock-id", stock_id,
"procedure", procedure,
NULL);
}
void
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
gimp_plug_in_action_selected (GimpPlugInAction *action,
GimpPlugInProcedure *procedure)
{
g_return_if_fail (GIMP_IS_PLUG_IN_ACTION (action));
g_signal_emit (action, action_signals[SELECTED], 0, procedure);
}