From 3fb934b2a421f6f2afacdd1ef0c97ebc4227343f Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 18 May 2004 21:19:43 +0000 Subject: [PATCH] Allow plug-ins to register menu icons. Fixes bug #120500. 2004-05-18 Michael Natterer 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. --- ChangeLog | 61 ++++++++++ app/actions/dialogs-actions.c | 2 +- app/actions/file-actions.c | 10 +- app/actions/file-dialog-actions.c | 6 +- app/actions/plug-in-actions.c | 2 +- app/config/gimpconfigwriter.c | 48 ++++++++ app/config/gimpconfigwriter.h | 5 + app/config/gimpscanner.c | 18 +++ app/config/gimpscanner.h | 3 + app/core/core-enums.c | 20 ++++ app/core/core-enums.h | 12 ++ app/menus/file-dialog-menu.c | 10 +- app/menus/file-dialog-menu.h | 3 +- app/menus/file-open-menu.c | 4 +- app/menus/file-save-menu.c | 4 +- app/pdb/gimppluginprocedure.c | 71 +++++++++++- app/pdb/gimppluginprocedure.h | 20 +++- app/pdb/internal_procs.c | 52 ++++----- app/pdb/plug_in_cmds.c | 115 +++++++++++++++++++ app/plug-in/gimppluginprocedure.c | 71 +++++++++++- app/plug-in/gimppluginprocedure.h | 20 +++- app/plug-in/plug-in-proc-def.c | 71 +++++++++++- app/plug-in/plug-in-proc-def.h | 20 +++- app/plug-in/plug-in-proc.c | 71 +++++++++++- app/plug-in/plug-in-proc.h | 20 +++- app/plug-in/plug-in-rc.c | 135 +++++++++++++++++++++++ app/widgets/gimppluginaction.c | 91 +++++++++++---- app/xcf/xcf.c | 50 +++++---- libgimp/gimpenums.h | 7 ++ libgimp/gimpplugin_pdb.c | 40 +++++++ libgimp/gimpplugin_pdb.h | 20 ++-- libgimpconfig/gimpconfigwriter.c | 48 ++++++++ libgimpconfig/gimpconfigwriter.h | 5 + libgimpconfig/gimpscanner.c | 18 +++ libgimpconfig/gimpscanner.h | 3 + plug-ins/common/plugin-browser.c | 4 + plug-ins/common/plugindetails.c | 4 + plug-ins/common/screenshot.c | 122 ++++++++++++++++++++ plug-ins/common/uniteditor.c | 4 + plug-ins/dbbrowser/plugin-browser.c | 4 + plug-ins/print/print.c | 4 + plug-ins/pygimp/gimpenums.py | 5 + plug-ins/script-fu/script-fu-constants.c | 4 + tools/pdbgen/enums.pl | 10 ++ tools/pdbgen/pdb/plug_in.pdb | 79 ++++++++++++- 45 files changed, 1272 insertions(+), 124 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d1d21ca7e..6e64a647e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,64 @@ +2004-05-18 Michael Natterer + + 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-18 Maurits Rijk * plug-ins/common/sel_gauss.c: HIGified, fixed indendation, speed diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c index 80bbb1d912..fcb39df1fb 100644 --- a/app/actions/dialogs-actions.c +++ b/app/actions/dialogs-actions.c @@ -181,7 +181,7 @@ static GimpStringActionEntry dialogs_toplevel_actions[] = "gimp-preferences-dialog", GIMP_HELP_PREFS_DIALOG }, - { "dialogs-module-manager", NULL, + { "dialogs-module-manager", GTK_STOCK_EXECUTE, N_("_Module Manager"), NULL, NULL, "gimp-module-manager-dialog", GIMP_HELP_MODULE_DIALOG }, diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c index 8de2b6435d..a03f149aa2 100644 --- a/app/actions/file-actions.c +++ b/app/actions/file-actions.c @@ -56,9 +56,13 @@ static void file_actions_last_opened_reorder (GimpContainer *container, static GimpActionEntry file_actions[] = { - { "file-menu", NULL, N_("_File") }, - { "file-open-recent-menu", NULL, N_("Open _Recent") }, - { "file-acquire-menu", NULL, N_("_Acquire") }, + { "file-menu", NULL, N_("_File") }, + + { "file-open-recent-menu", GTK_STOCK_OPEN, + N_("Open _Recent"), "", NULL }, + + { "file-acquire-menu", NULL, + N_("_Acquire"), NULL, NULL }, { "file-new", GTK_STOCK_NEW, N_("_New..."), "N", NULL, diff --git a/app/actions/file-dialog-actions.c b/app/actions/file-dialog-actions.c index 5073925457..07b79cc8f7 100644 --- a/app/actions/file-dialog-actions.c +++ b/app/actions/file-dialog-actions.c @@ -48,7 +48,6 @@ file_dialog_actions_setup (GimpActionGroup *group, for (list = file_procs; list; list = g_slist_next (list)) { PlugInProcDef *file_proc = list->data; - const gchar *stock_id = NULL; gchar *help_id; GimpPlugInActionEntry entry; gchar *label; @@ -61,8 +60,7 @@ file_dialog_actions_setup (GimpActionGroup *group, if (is_xcf) { - stock_id = GIMP_STOCK_WILBER; - help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF); + help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF); } else { @@ -84,7 +82,7 @@ file_dialog_actions_setup (GimpActionGroup *group, label = strrchr (file_proc->menu_paths->data, '/') + 1; entry.name = file_proc->db_info.name; - entry.stock_id = stock_id; + entry.stock_id = plug_in_proc_def_get_stock_id (file_proc); entry.label = label; entry.accelerator = NULL; entry.tooltip = NULL; diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c index 484be6fb65..83ab636669 100644 --- a/app/actions/plug-in-actions.c +++ b/app/actions/plug-in-actions.c @@ -283,7 +283,7 @@ plug_in_actions_add_proc (GimpActionGroup *group, } entry.name = proc_def->db_info.name; - entry.stock_id = NULL; + entry.stock_id = plug_in_proc_def_get_stock_id (proc_def); entry.label = label_translated; entry.accelerator = NULL; entry.tooltip = NULL; diff --git a/app/config/gimpconfigwriter.c b/app/config/gimpconfigwriter.c index c62492d26a..0cbb45ec3a 100644 --- a/app/config/gimpconfigwriter.c +++ b/app/config/gimpconfigwriter.c @@ -319,6 +319,54 @@ gimp_config_writer_string (GimpConfigWriter *writer, gimp_config_string_append_escaped (writer->buffer, string); } +/** + * gimp_config_writer_identifier: + * @writer: a #GimpConfigWriter + * @string: a NUL-terminated string + * + * Writes an identifier to @writer. The @string is *not* quoted and special + * characters are *not* escaped. + **/ +void +gimp_config_writer_identifier (GimpConfigWriter *writer, + const gchar *identifier) +{ + g_return_if_fail (writer != NULL); + g_return_if_fail (identifier != NULL); + + if (writer->error) + return; + + g_string_append_printf (writer->buffer, " %s", identifier); +} + +void +gimp_config_writer_data (GimpConfigWriter *writer, + gint length, + const guint8 *data) +{ + gint i; + + g_return_if_fail (writer != NULL); + g_return_if_fail (length > 0); + g_return_if_fail (data != NULL); + + if (writer->error) + return; + + g_string_append (writer->buffer, " \""); + + for (i = 0; i < length; i++) + { + if (g_ascii_isalpha (data[i])) + g_string_append_c (writer->buffer, data[i]); + else + g_string_append_printf (writer->buffer, "\\%o", data[i]); + } + + g_string_append (writer->buffer, "\""); +} + /** * gimp_config_writer_revert: * @writer: a #GimpConfigWriter diff --git a/app/config/gimpconfigwriter.h b/app/config/gimpconfigwriter.h index bc12ba740c..b4f0535877 100644 --- a/app/config/gimpconfigwriter.h +++ b/app/config/gimpconfigwriter.h @@ -41,8 +41,13 @@ void gimp_config_writer_print (GimpConfigWriter *writer, void gimp_config_writer_printf (GimpConfigWriter *writer, const gchar *format, ...); +void gimp_config_writer_identifier (GimpConfigWriter *writer, + const gchar *identifier); void gimp_config_writer_string (GimpConfigWriter *writer, const gchar *string); +void gimp_config_writer_data (GimpConfigWriter *writer, + gint length, + const guint8 *data); void gimp_config_writer_comment (GimpConfigWriter *writer, const gchar *comment); void gimp_config_writer_linefeed (GimpConfigWriter *writer); diff --git a/app/config/gimpscanner.c b/app/config/gimpscanner.c index 247f9c17e4..dcf295375a 100644 --- a/app/config/gimpscanner.c +++ b/app/config/gimpscanner.c @@ -248,6 +248,24 @@ gimp_scanner_parse_string_no_validate (GScanner *scanner, return TRUE; } +gboolean +gimp_scanner_parse_data (GScanner *scanner, + gint length, + guint8 **dest) +{ + if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING) + return FALSE; + + g_scanner_get_next_token (scanner); + + if (scanner->value.v_string) + *dest = g_memdup (scanner->value.v_string, length); + else + *dest = NULL; + + return TRUE; +} + gboolean gimp_scanner_parse_int (GScanner *scanner, gint *dest) diff --git a/app/config/gimpscanner.h b/app/config/gimpscanner.h index 498d53a674..bb783b219d 100644 --- a/app/config/gimpscanner.h +++ b/app/config/gimpscanner.h @@ -39,6 +39,9 @@ gboolean gimp_scanner_parse_string (GScanner *scanner, gchar **dest); gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner, gchar **dest); +gboolean gimp_scanner_parse_data (GScanner *scanner, + gint length, + guint8 **dest); gboolean gimp_scanner_parse_int (GScanner *scanner, gint *dest); gboolean gimp_scanner_parse_float (GScanner *scanner, diff --git a/app/core/core-enums.c b/app/core/core-enums.c index 382964b1ca..b0dba307b4 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -343,6 +343,26 @@ gimp_dash_preset_get_type (void) } +static const GEnumValue gimp_icon_type_enum_values[] = +{ + { GIMP_ICON_TYPE_STOCK_ID, N_("Stock ID"), "stock-id" }, + { GIMP_ICON_TYPE_INLINE_PIXBUF, N_("Inline Pixbuf"), "inline-pixbuf" }, + { GIMP_ICON_TYPE_IMAGE_FILE, N_("Image File"), "image-file" }, + { 0, NULL, NULL } +}; + +GType +gimp_icon_type_get_type (void) +{ + static GType enum_type = 0; + + if (!enum_type) + enum_type = g_enum_register_static ("GimpIconType", gimp_icon_type_enum_values); + + return enum_type; +} + + static const GEnumValue gimp_image_base_type_enum_values[] = { { GIMP_RGB, N_("RGB Color"), "rgb" }, diff --git a/app/core/core-enums.h b/app/core/core-enums.h index e0813dc04c..8c6621d240 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -251,6 +251,18 @@ typedef enum /*< pdb-skip >*/ } GimpDashPreset; +#define GIMP_TYPE_ICON_TYPE (gimp_icon_type_get_type ()) + +GType gimp_icon_type_get_type (void) G_GNUC_CONST; + +typedef enum +{ + GIMP_ICON_TYPE_STOCK_ID, /*< desc="Stock ID" >*/ + GIMP_ICON_TYPE_INLINE_PIXBUF, /*< desc="Inline Pixbuf" >*/ + GIMP_ICON_TYPE_IMAGE_FILE /*< desc="Image File" >*/ +} GimpIconType; + + #define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ()) GType gimp_image_base_type_get_type (void) G_GNUC_CONST; diff --git a/app/menus/file-dialog-menu.c b/app/menus/file-dialog-menu.c index 437e829d27..4eec5e9a4c 100644 --- a/app/menus/file-dialog-menu.c +++ b/app/menus/file-dialog-menu.c @@ -34,8 +34,7 @@ void file_dialog_menu_setup (GimpUIManager *manager, const gchar *ui_path, - GSList *file_procs, - const gchar *xcf_proc_name) + GSList *file_procs) { GSList *list; guint merge_id; @@ -46,12 +45,15 @@ file_dialog_menu_setup (GimpUIManager *manager, { PlugInProcDef *file_proc = list->data; gchar *path; + gchar *p; if (! file_proc->menu_paths) continue; - if (! strcmp (file_proc->db_info.name, xcf_proc_name)) - path = g_strdup_printf ("%s/%s", ui_path, "Internal"); + p = strchr (file_proc->menu_paths->data, '/'); + + if (p) + path = g_strdup_printf ("%s%s", ui_path, p); else path = g_strdup (ui_path); diff --git a/app/menus/file-dialog-menu.h b/app/menus/file-dialog-menu.h index 084abffca3..bdd63bbf79 100644 --- a/app/menus/file-dialog-menu.h +++ b/app/menus/file-dialog-menu.h @@ -22,8 +22,7 @@ void file_dialog_menu_setup (GimpUIManager *manager, const gchar *ui_path, - GSList *file_procs, - const gchar *xcf_proc_name); + GSList *file_procs); #endif /* __FILE_DIALOG_MENU_H__ */ diff --git a/app/menus/file-open-menu.c b/app/menus/file-open-menu.c index 4819061915..3185119ad1 100644 --- a/app/menus/file-open-menu.c +++ b/app/menus/file-open-menu.c @@ -34,7 +34,5 @@ void file_open_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - file_dialog_menu_setup (manager, ui_path, - manager->gimp->load_procs, - "gimp_xcf_load"); + file_dialog_menu_setup (manager, ui_path, manager->gimp->load_procs); } diff --git a/app/menus/file-save-menu.c b/app/menus/file-save-menu.c index 3aa28a2b2d..8d3b099122 100644 --- a/app/menus/file-save-menu.c +++ b/app/menus/file-save-menu.c @@ -34,7 +34,5 @@ void file_save_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - file_dialog_menu_setup (manager, ui_path, - manager->gimp->save_procs, - "gimp_xcf_save"); + file_dialog_menu_setup (manager, ui_path, manager->gimp->save_procs); } diff --git a/app/pdb/gimppluginprocedure.c b/app/pdb/gimppluginprocedure.c index f176a1b920..3332450d46 100644 --- a/app/pdb/gimppluginprocedure.c +++ b/app/pdb/gimppluginprocedure.c @@ -21,6 +21,7 @@ #include #include +#include #include "libgimpbase/gimpbase.h" @@ -38,7 +39,11 @@ PlugInProcDef * plug_in_proc_def_new (void) { - return g_new0 (PlugInProcDef, 1); + PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1); + + proc_def->icon_data_length = -1; + + return proc_def; } void @@ -76,11 +81,22 @@ plug_in_proc_def_free (PlugInProcDef *proc_def) g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL); g_list_free (proc_def->menu_paths); + g_free (proc_def->icon_data); + g_free (proc_def->image_types); + g_free (proc_def->extensions); g_free (proc_def->prefixes); g_free (proc_def->magics); g_free (proc_def->mime_type); - g_free (proc_def->image_types); + + g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->extensions_list); + + g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->prefixes_list); + + g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->magics_list); g_free (proc_def); } @@ -149,6 +165,57 @@ plug_in_proc_def_get_label (const PlugInProcDef *proc_def, return label; } +const gchar * +plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) +{ + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + return proc_def->icon_data; + + default: + return NULL; + } +} + +GdkPixbuf * +plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def) +{ + GdkPixbuf *pixbuf = NULL; + GError *error = NULL; + + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_INLINE_PIXBUF: + pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length, + proc_def->icon_data, TRUE, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + case GIMP_ICON_TYPE_IMAGE_FILE: + pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + default: + break; + } + + return pixbuf; +} + gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain) diff --git a/app/pdb/gimppluginprocedure.h b/app/pdb/gimppluginprocedure.h index ba92b7145b..1e321f739b 100644 --- a/app/pdb/gimppluginprocedure.h +++ b/app/pdb/gimppluginprocedure.h @@ -21,26 +21,34 @@ #include /* time_t */ +#include + #include "pdb/procedural_db.h" /* ProcRecord */ struct _PlugInProcDef { + /* common members */ gchar *prog; gchar *menu_label; GList *menu_paths; + GimpIconType icon_type; + gint icon_data_length; + gchar *icon_data; + gchar *image_types; + PlugInImageType image_types_val; + time_t mtime; + gboolean installed_during_init; + ProcRecord db_info; + + /* file proc specific members */ gchar *extensions; gchar *prefixes; gchar *magics; gchar *mime_type; - gchar *image_types; - PlugInImageType image_types_val; - ProcRecord db_info; GSList *extensions_list; GSList *prefixes_list; GSList *magics_list; - time_t mtime; - gboolean installed_during_init; }; @@ -51,6 +59,8 @@ const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def) const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def, const gchar *locale_domain); +const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def); +GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index 2bb5aa73f1..d6ef62ca70 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -68,7 +68,7 @@ void register_transform_tools_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 349 procedures registered total */ +/* 350 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -92,82 +92,82 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Convert"), 0.103); register_convert_procs (gimp); - (* status_callback) (NULL, _("Display procedures"), 0.112); + (* status_callback) (NULL, _("Display procedures"), 0.111); register_display_procs (gimp); (* status_callback) (NULL, _("Drawable procedures"), 0.123); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.215); + (* status_callback) (NULL, _("Edit procedures"), 0.214); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.238); + (* status_callback) (NULL, _("File Operations"), 0.237); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.264); + (* status_callback) (NULL, _("Floating selections"), 0.263); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Font UI"), 0.281); + (* status_callback) (NULL, _("Font UI"), 0.28); register_font_select_procs (gimp); (* status_callback) (NULL, _("Fonts"), 0.289); register_fonts_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.295); + (* status_callback) (NULL, _("Gimprc procedures"), 0.294); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.312); + (* status_callback) (NULL, _("Gradient UI"), 0.311); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.321); + (* status_callback) (NULL, _("Gradients"), 0.32); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.341); + (* status_callback) (NULL, _("Guide procedures"), 0.34); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.358); + (* status_callback) (NULL, _("Help procedures"), 0.357); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.361); + (* status_callback) (NULL, _("Image"), 0.36); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.536); + (* status_callback) (NULL, _("Layer"), 0.534); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.61); + (* status_callback) (NULL, _("Message procedures"), 0.609); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.619); + (* status_callback) (NULL, _("Miscellaneous"), 0.617); register_misc_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.625); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.623); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.668); + (* status_callback) (NULL, _("Palette"), 0.666); register_palette_procs (gimp); - (* status_callback) (NULL, _("Palette UI"), 0.685); + (* status_callback) (NULL, _("Palette UI"), 0.683); register_palette_select_procs (gimp); - (* status_callback) (NULL, _("Palettes"), 0.693); + (* status_callback) (NULL, _("Palettes"), 0.691); register_palettes_procs (gimp); - (* status_callback) (NULL, _("Parasite procedures"), 0.708); + (* status_callback) (NULL, _("Parasite procedures"), 0.706); register_parasite_procs (gimp); - (* status_callback) (NULL, _("Paths"), 0.742); + (* status_callback) (NULL, _("Paths"), 0.74); register_paths_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.785); + (* status_callback) (NULL, _("Pattern UI"), 0.783); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.794); + (* status_callback) (NULL, _("Patterns"), 0.791); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.808); + (* status_callback) (NULL, _("Plug-in"), 0.806); register_plug_in_procs (gimp); - (* status_callback) (NULL, _("Procedural database"), 0.825); + (* status_callback) (NULL, _("Procedural database"), 0.826); register_procedural_db_procs (gimp); (* status_callback) (NULL, _("Image mask"), 0.851); @@ -179,7 +179,7 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Text procedures"), 0.917); register_text_tool_procs (gimp); - (* status_callback) (NULL, _("Transform Tool procedures"), 0.928); + (* status_callback) (NULL, _("Transform Tool procedures"), 0.929); register_transform_tools_procs (gimp); (* status_callback) (NULL, _("Undo"), 0.946); diff --git a/app/pdb/plug_in_cmds.c b/app/pdb/plug_in_cmds.c index 776f0d9f5c..e11f7e54ca 100644 --- a/app/pdb/plug_in_cmds.c +++ b/app/pdb/plug_in_cmds.c @@ -53,6 +53,7 @@ static ProcRecord plugins_query_proc; static ProcRecord plugin_domain_register_proc; static ProcRecord plugin_help_register_proc; static ProcRecord plugin_menu_register_proc; +static ProcRecord plugin_icon_register_proc; void register_plug_in_procs (Gimp *gimp) @@ -63,6 +64,7 @@ register_plug_in_procs (Gimp *gimp) procedural_db_register (gimp, &plugin_domain_register_proc); procedural_db_register (gimp, &plugin_help_register_proc); procedural_db_register (gimp, &plugin_menu_register_proc); + procedural_db_register (gimp, &plugin_icon_register_proc); } static int @@ -625,3 +627,116 @@ static ProcRecord plugin_menu_register_proc = NULL, { { plugin_menu_register_invoker } } }; + +static Argument * +plugin_icon_register_invoker (Gimp *gimp, + GimpContext *context, + Argument *args) +{ + gboolean success = TRUE; + gchar *procedure_name; + gint32 icon_type; + gint32 icon_data_length; + guint8 *icon_data; + + procedure_name = (gchar *) args[0].value.pdb_pointer; + if (procedure_name == NULL || !g_utf8_validate (procedure_name, -1, NULL)) + success = FALSE; + + icon_type = args[1].value.pdb_int; + if (icon_type < GIMP_ICON_TYPE_STOCK_ID || icon_type > GIMP_ICON_TYPE_IMAGE_FILE) + success = FALSE; + + icon_data_length = args[2].value.pdb_int; + + icon_data = (guint8 *) args[3].value.pdb_pointer; + + if (success) + { + if (gimp->current_plug_in && gimp->current_plug_in->query) + { + GSList *list; + + for (list = gimp->current_plug_in->plug_in_def->proc_defs; + list; + list = g_slist_next (list)) + { + PlugInProcDef *proc_def = list->data; + + if (! strcmp (procedure_name, proc_def->db_info.name)) + { + if (proc_def->icon_data) + { + g_free (proc_def->icon_data); + proc_def->icon_data_length = -1; + proc_def->icon_data = NULL; + } + + proc_def->icon_type = icon_type; + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + case GIMP_ICON_TYPE_IMAGE_FILE: + proc_def->icon_data_length = -1; + proc_def->icon_data = g_strdup (icon_data); + break; + + case GIMP_ICON_TYPE_INLINE_PIXBUF: + proc_def->icon_data_length = icon_data_length; + proc_def->icon_data = g_memdup (icon_data, + icon_data_length); + break; + } + + break; + } + } + + if (! list) + success = FALSE; + } + } + + return procedural_db_return_args (&plugin_icon_register_proc, success); +} + +static ProcArg plugin_icon_register_inargs[] = +{ + { + GIMP_PDB_STRING, + "procedure_name", + "The procedure for which to install the icon" + }, + { + GIMP_PDB_INT32, + "icon_type", + "The type of the icon" + }, + { + GIMP_PDB_INT32, + "icon_data_length", + "The length of 'icon_data'" + }, + { + GIMP_PDB_INT8ARRAY, + "icon_data", + "The procedure's icon. The format depends on the 'icon_type' parameter" + } +}; + +static ProcRecord plugin_icon_register_proc = +{ + "gimp_plugin_icon_register", + "Register an icon for a plug-in procedure.", + "This procedure installs an icon for the given procedure.", + "Michael Natterer ", + "Michael Natterer ", + "2004", + GIMP_INTERNAL, + 4, + plugin_icon_register_inargs, + 0, + NULL, + { { plugin_icon_register_invoker } } +}; diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c index f176a1b920..3332450d46 100644 --- a/app/plug-in/gimppluginprocedure.c +++ b/app/plug-in/gimppluginprocedure.c @@ -21,6 +21,7 @@ #include #include +#include #include "libgimpbase/gimpbase.h" @@ -38,7 +39,11 @@ PlugInProcDef * plug_in_proc_def_new (void) { - return g_new0 (PlugInProcDef, 1); + PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1); + + proc_def->icon_data_length = -1; + + return proc_def; } void @@ -76,11 +81,22 @@ plug_in_proc_def_free (PlugInProcDef *proc_def) g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL); g_list_free (proc_def->menu_paths); + g_free (proc_def->icon_data); + g_free (proc_def->image_types); + g_free (proc_def->extensions); g_free (proc_def->prefixes); g_free (proc_def->magics); g_free (proc_def->mime_type); - g_free (proc_def->image_types); + + g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->extensions_list); + + g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->prefixes_list); + + g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->magics_list); g_free (proc_def); } @@ -149,6 +165,57 @@ plug_in_proc_def_get_label (const PlugInProcDef *proc_def, return label; } +const gchar * +plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) +{ + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + return proc_def->icon_data; + + default: + return NULL; + } +} + +GdkPixbuf * +plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def) +{ + GdkPixbuf *pixbuf = NULL; + GError *error = NULL; + + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_INLINE_PIXBUF: + pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length, + proc_def->icon_data, TRUE, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + case GIMP_ICON_TYPE_IMAGE_FILE: + pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + default: + break; + } + + return pixbuf; +} + gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain) diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h index ba92b7145b..1e321f739b 100644 --- a/app/plug-in/gimppluginprocedure.h +++ b/app/plug-in/gimppluginprocedure.h @@ -21,26 +21,34 @@ #include /* time_t */ +#include + #include "pdb/procedural_db.h" /* ProcRecord */ struct _PlugInProcDef { + /* common members */ gchar *prog; gchar *menu_label; GList *menu_paths; + GimpIconType icon_type; + gint icon_data_length; + gchar *icon_data; + gchar *image_types; + PlugInImageType image_types_val; + time_t mtime; + gboolean installed_during_init; + ProcRecord db_info; + + /* file proc specific members */ gchar *extensions; gchar *prefixes; gchar *magics; gchar *mime_type; - gchar *image_types; - PlugInImageType image_types_val; - ProcRecord db_info; GSList *extensions_list; GSList *prefixes_list; GSList *magics_list; - time_t mtime; - gboolean installed_during_init; }; @@ -51,6 +59,8 @@ const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def) const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def, const gchar *locale_domain); +const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def); +GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); diff --git a/app/plug-in/plug-in-proc-def.c b/app/plug-in/plug-in-proc-def.c index f176a1b920..3332450d46 100644 --- a/app/plug-in/plug-in-proc-def.c +++ b/app/plug-in/plug-in-proc-def.c @@ -21,6 +21,7 @@ #include #include +#include #include "libgimpbase/gimpbase.h" @@ -38,7 +39,11 @@ PlugInProcDef * plug_in_proc_def_new (void) { - return g_new0 (PlugInProcDef, 1); + PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1); + + proc_def->icon_data_length = -1; + + return proc_def; } void @@ -76,11 +81,22 @@ plug_in_proc_def_free (PlugInProcDef *proc_def) g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL); g_list_free (proc_def->menu_paths); + g_free (proc_def->icon_data); + g_free (proc_def->image_types); + g_free (proc_def->extensions); g_free (proc_def->prefixes); g_free (proc_def->magics); g_free (proc_def->mime_type); - g_free (proc_def->image_types); + + g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->extensions_list); + + g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->prefixes_list); + + g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->magics_list); g_free (proc_def); } @@ -149,6 +165,57 @@ plug_in_proc_def_get_label (const PlugInProcDef *proc_def, return label; } +const gchar * +plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) +{ + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + return proc_def->icon_data; + + default: + return NULL; + } +} + +GdkPixbuf * +plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def) +{ + GdkPixbuf *pixbuf = NULL; + GError *error = NULL; + + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_INLINE_PIXBUF: + pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length, + proc_def->icon_data, TRUE, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + case GIMP_ICON_TYPE_IMAGE_FILE: + pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + default: + break; + } + + return pixbuf; +} + gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain) diff --git a/app/plug-in/plug-in-proc-def.h b/app/plug-in/plug-in-proc-def.h index ba92b7145b..1e321f739b 100644 --- a/app/plug-in/plug-in-proc-def.h +++ b/app/plug-in/plug-in-proc-def.h @@ -21,26 +21,34 @@ #include /* time_t */ +#include + #include "pdb/procedural_db.h" /* ProcRecord */ struct _PlugInProcDef { + /* common members */ gchar *prog; gchar *menu_label; GList *menu_paths; + GimpIconType icon_type; + gint icon_data_length; + gchar *icon_data; + gchar *image_types; + PlugInImageType image_types_val; + time_t mtime; + gboolean installed_during_init; + ProcRecord db_info; + + /* file proc specific members */ gchar *extensions; gchar *prefixes; gchar *magics; gchar *mime_type; - gchar *image_types; - PlugInImageType image_types_val; - ProcRecord db_info; GSList *extensions_list; GSList *prefixes_list; GSList *magics_list; - time_t mtime; - gboolean installed_during_init; }; @@ -51,6 +59,8 @@ const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def) const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def, const gchar *locale_domain); +const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def); +GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); diff --git a/app/plug-in/plug-in-proc.c b/app/plug-in/plug-in-proc.c index f176a1b920..3332450d46 100644 --- a/app/plug-in/plug-in-proc.c +++ b/app/plug-in/plug-in-proc.c @@ -21,6 +21,7 @@ #include #include +#include #include "libgimpbase/gimpbase.h" @@ -38,7 +39,11 @@ PlugInProcDef * plug_in_proc_def_new (void) { - return g_new0 (PlugInProcDef, 1); + PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1); + + proc_def->icon_data_length = -1; + + return proc_def; } void @@ -76,11 +81,22 @@ plug_in_proc_def_free (PlugInProcDef *proc_def) g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL); g_list_free (proc_def->menu_paths); + g_free (proc_def->icon_data); + g_free (proc_def->image_types); + g_free (proc_def->extensions); g_free (proc_def->prefixes); g_free (proc_def->magics); g_free (proc_def->mime_type); - g_free (proc_def->image_types); + + g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->extensions_list); + + g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->prefixes_list); + + g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL); + g_slist_free (proc_def->magics_list); g_free (proc_def); } @@ -149,6 +165,57 @@ plug_in_proc_def_get_label (const PlugInProcDef *proc_def, return label; } +const gchar * +plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) +{ + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + return proc_def->icon_data; + + default: + return NULL; + } +} + +GdkPixbuf * +plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def) +{ + GdkPixbuf *pixbuf = NULL; + GError *error = NULL; + + g_return_val_if_fail (proc_def != NULL, NULL); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_INLINE_PIXBUF: + pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length, + proc_def->icon_data, TRUE, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + case GIMP_ICON_TYPE_IMAGE_FILE: + pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error); + if (! pixbuf) + { + g_printerr (error->message); + g_clear_error (&error); + } + break; + + default: + break; + } + + return pixbuf; +} + gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain) diff --git a/app/plug-in/plug-in-proc.h b/app/plug-in/plug-in-proc.h index ba92b7145b..1e321f739b 100644 --- a/app/plug-in/plug-in-proc.h +++ b/app/plug-in/plug-in-proc.h @@ -21,26 +21,34 @@ #include /* time_t */ +#include + #include "pdb/procedural_db.h" /* ProcRecord */ struct _PlugInProcDef { + /* common members */ gchar *prog; gchar *menu_label; GList *menu_paths; + GimpIconType icon_type; + gint icon_data_length; + gchar *icon_data; + gchar *image_types; + PlugInImageType image_types_val; + time_t mtime; + gboolean installed_during_init; + ProcRecord db_info; + + /* file proc specific members */ gchar *extensions; gchar *prefixes; gchar *magics; gchar *mime_type; - gchar *image_types; - PlugInImageType image_types_val; - ProcRecord db_info; GSList *extensions_list; GSList *prefixes_list; GSList *magics_list; - time_t mtime; - gboolean installed_during_init; }; @@ -51,6 +59,8 @@ const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def) const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def, const gchar *locale_domain); +const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def); +GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c index b702a7b6a3..d247d62c10 100644 --- a/app/plug-in/plug-in-rc.c +++ b/app/plug-in/plug-in-rc.c @@ -53,6 +53,8 @@ static GTokenType plug_in_proc_def_deserialize (GScanner *scanner, PlugInProcDef *proc_def); static GTokenType plug_in_menu_path_deserialize (GScanner *scanner, PlugInProcDef *proc_def); +static GTokenType plug_in_icon_deserialize (GScanner *scanner, + PlugInProcDef *proc_def); static GTokenType plug_in_proc_arg_deserialize (GScanner *scanner, ProcArg *arg); static GTokenType plug_in_mime_type_deserialize (GScanner *scanner, @@ -75,6 +77,7 @@ enum HAS_INIT, PROC_ARG, MENU_PATH, + ICON, MIME_TYPE }; @@ -85,6 +88,7 @@ plug_in_rc_parse (Gimp *gimp, GError **error) { GScanner *scanner; + GEnumClass *enum_class; GTokenType token; gboolean retval = FALSE; gint version = GIMP_PROTOCOL_VERSION; @@ -98,6 +102,8 @@ plug_in_rc_parse (Gimp *gimp, if (! scanner) return FALSE; + enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE); + g_scanner_scope_add_symbol (scanner, 0, "protocol-version", GINT_TO_POINTER (PROTOCOL_VERSION)); @@ -115,6 +121,8 @@ plug_in_rc_parse (Gimp *gimp, "proc-arg", GINT_TO_POINTER (PROC_ARG)); g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF, "menu-path", GINT_TO_POINTER (MENU_PATH)); + g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF, + "icon", GINT_TO_POINTER (ICON)); g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF, "mime-type", GINT_TO_POINTER (MIME_TYPE)); @@ -176,6 +184,8 @@ plug_in_rc_parse (Gimp *gimp, retval = TRUE; } + g_type_class_unref (enum_class); + gimp_scanner_destroy (scanner); return retval; @@ -304,6 +314,10 @@ plug_in_proc_def_deserialize (GScanner *scanner, return token; } + token = plug_in_icon_deserialize (scanner, proc_def); + if (token != G_TOKEN_LEFT_PAREN) + return token; + if (! gimp_scanner_parse_string (scanner, &proc_def->extensions)) return G_TOKEN_STRING; if (! gimp_scanner_parse_string (scanner, &proc_def->prefixes)) @@ -381,6 +395,98 @@ plug_in_menu_path_deserialize (GScanner *scanner, return G_TOKEN_LEFT_PAREN; } +static GTokenType +plug_in_icon_deserialize (GScanner *scanner, + PlugInProcDef *proc_def) +{ + GEnumClass *enum_class; + GEnumValue *enum_value; + GimpIconType icon_type; + gint icon_data_length; + gchar *icon_data; + + if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN)) + return G_TOKEN_LEFT_PAREN; + + if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) || + GPOINTER_TO_INT (scanner->value.v_symbol) != ICON) + return G_TOKEN_SYMBOL; + + enum_class = g_type_class_peek (GIMP_TYPE_ICON_TYPE); + + switch (g_scanner_peek_next_token (scanner)) + { + case G_TOKEN_IDENTIFIER: + g_scanner_get_next_token (scanner); + + enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class), + scanner->value.v_identifier); + if (!enum_value) + enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class), + scanner->value.v_identifier); + + if (!enum_value) + { + g_scanner_error (scanner, + _("invalid value '%s' for icon type"), + scanner->value.v_identifier); + return G_TOKEN_NONE; + } + break; + + case G_TOKEN_INT: + g_scanner_get_next_token (scanner); + + enum_value = g_enum_get_value (enum_class, + (gint) scanner->value.v_int64); + + if (!enum_value) + { + g_scanner_error (scanner, + _("invalid value '%ld' for icon type"), + (glong) scanner->value.v_int64); + return G_TOKEN_NONE; + } + break; + + default: + return G_TOKEN_IDENTIFIER; + } + + icon_type = enum_value->value; + + if (! gimp_scanner_parse_int (scanner, &icon_data_length)) + return G_TOKEN_INT; + + switch (icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + case GIMP_ICON_TYPE_IMAGE_FILE: + icon_data_length = -1; + + if (! gimp_scanner_parse_string_no_validate (scanner, &icon_data)) + return G_TOKEN_STRING; + break; + + case GIMP_ICON_TYPE_INLINE_PIXBUF: + if (icon_data_length < 0) + return G_TOKEN_STRING; + + if (! gimp_scanner_parse_data (scanner, icon_data_length, &icon_data)) + return G_TOKEN_STRING; + break; + } + + proc_def->icon_type = icon_type; + proc_def->icon_data_length = icon_data_length; + proc_def->icon_data = icon_data; + + if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN)) + return G_TOKEN_RIGHT_PAREN; + + return G_TOKEN_LEFT_PAREN; +} + static GTokenType plug_in_mime_type_deserialize (GScanner *scanner, PlugInProcDef *proc_def) @@ -501,6 +607,7 @@ plug_in_rc_write (GSList *plug_in_defs, GError **error) { GimpConfigWriter *writer; + GEnumClass *enum_class; PlugInDef *plug_in_def; PlugInProcDef *proc_def; GSList *list; @@ -518,6 +625,8 @@ plug_in_rc_write (GSList *plug_in_defs, if (!writer) return FALSE; + enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE); + gimp_config_writer_open (writer, "protocol-version"); gimp_config_writer_printf (writer, "%d", GIMP_PROTOCOL_VERSION); gimp_config_writer_close (writer); @@ -535,6 +644,8 @@ plug_in_rc_write (GSList *plug_in_defs, for (list2 = plug_in_def->proc_defs; list2; list2 = list2->next) { + GEnumValue *enum_value; + proc_def = list2->data; if (proc_def->installed_during_init) @@ -566,6 +677,28 @@ plug_in_rc_write (GSList *plug_in_defs, gimp_config_writer_string (writer, list3->data); gimp_config_writer_close (writer); } + + gimp_config_writer_open (writer, "icon"); + enum_value = g_enum_get_value (enum_class, proc_def->icon_type); + gimp_config_writer_identifier (writer, enum_value->value_nick); + gimp_config_writer_printf (writer, "%d", + proc_def->icon_data_length); + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + case GIMP_ICON_TYPE_IMAGE_FILE: + gimp_config_writer_string (writer, proc_def->icon_data); + break; + + case GIMP_ICON_TYPE_INLINE_PIXBUF: + gimp_config_writer_data (writer, proc_def->icon_data_length, + proc_def->icon_data); + break; + } + + gimp_config_writer_close (writer); + gimp_config_writer_linefeed (writer); gimp_config_writer_string (writer, proc_def->extensions); @@ -655,5 +788,7 @@ plug_in_rc_write (GSList *plug_in_defs, } } + g_type_class_unref (enum_class); + return gimp_config_writer_finish (writer, "end of plug-ins", error); } diff --git a/app/widgets/gimppluginaction.c b/app/widgets/gimppluginaction.c index eb8d77db21..3d369100c5 100644 --- a/app/widgets/gimppluginaction.c +++ b/app/widgets/gimppluginaction.c @@ -27,6 +27,8 @@ #include "core/gimpmarshal.h" +#include "plug-in/plug-in-proc.h" + #include "gimppluginaction.h" @@ -43,19 +45,21 @@ enum }; -static void gimp_plug_in_action_init (GimpPlugInAction *action); -static void gimp_plug_in_action_class_init (GimpPlugInActionClass *klass); +static void gimp_plug_in_action_init (GimpPlugInAction *action); +static void gimp_plug_in_action_class_init (GimpPlugInActionClass *klass); -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); +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); -static void gimp_plug_in_action_activate (GtkAction *action); +static void gimp_plug_in_action_activate (GtkAction *action); +static void gimp_plug_in_action_connect_proxy (GtkAction *action, + GtkWidget *proxy); static GtkActionClass *parent_class = NULL; @@ -101,7 +105,8 @@ gimp_plug_in_action_class_init (GimpPlugInActionClass *klass) object_class->set_property = gimp_plug_in_action_set_property; object_class->get_property = gimp_plug_in_action_get_property; - action_class->activate = gimp_plug_in_action_activate; + action_class->activate = gimp_plug_in_action_activate; + action_class->connect_proxy = gimp_plug_in_action_connect_proxy; g_object_class_install_property (object_class, PROP_PROC_DEF, g_param_spec_pointer ("proc-def", @@ -163,6 +168,60 @@ gimp_plug_in_action_set_property (GObject *object, } } +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); +} + +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->proc_def) + { + GdkPixbuf *pixbuf; + + pixbuf = plug_in_proc_def_get_pixbuf (plug_in_action->proc_def); + + if (pixbuf) + { + GdkScreen *screen = gtk_widget_get_screen (proxy); + GtkSettings *settings = gtk_settings_get_for_screen (screen); + 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 * gimp_plug_in_action_new (const gchar *name, const gchar *label, @@ -179,14 +238,6 @@ gimp_plug_in_action_new (const gchar *name, NULL); } -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); -} - void gimp_plug_in_action_selected (GimpPlugInAction *action) { diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index 6ddd2e4d15..e012179120 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -68,14 +68,14 @@ static ProcArg xcf_load_args[] = "The name of the file to load, in the on-disk character set and encoding" }, { GIMP_PDB_STRING, "raw_filename", - "The basename of the file, in UTF-8" }, + "The basename of the file, in UTF-8" } }; static ProcArg xcf_load_return_vals[] = { { GIMP_PDB_IMAGE, "image", - "Output image" }, + "Output image" } }; static PlugInProcDef xcf_plug_in_load_proc = @@ -83,16 +83,19 @@ static PlugInProcDef xcf_plug_in_load_proc = "gimp_xcf_load", N_("GIMP XCF image"), NULL, - "xcf", - "", - "0,string,gimp\\040xcf\\040", - "image/x-xcf", + GIMP_ICON_TYPE_STOCK_ID, + -1, + "gimp-wilber", NULL, /* ignored for load */ 0, /* ignored for load */ + 0, + FALSE, { "gimp_xcf_load", "loads file saved in the .xcf file format", - "The xcf file format has been designed specifically for loading and saving tiled and layered images in the GIMP. This procedure will load the specified file.", + "The xcf file format has been designed specifically for loading and " + "saving tiled and layered images in the GIMP. This procedure will load " + "the specified file.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", @@ -103,10 +106,13 @@ static PlugInProcDef xcf_plug_in_load_proc = xcf_load_return_vals, { { xcf_load_invoker } }, }, + "xcf", + "", + "0,string,gimp\\040xcf\\040", + "image/x-xcf", NULL, /* fill me in at runtime */ NULL, /* fill me in at runtime */ - NULL, /* fill me in at runtime */ - 0 + NULL /* fill me in at runtime */ }; static ProcArg xcf_save_args[] = @@ -125,7 +131,7 @@ static ProcArg xcf_save_args[] = "The name of the file to save the image in, in the on-disk character set and encoding" }, { GIMP_PDB_STRING, "raw_filename", - "The basename of the file, in UTF-8" }, + "The basename of the file, in UTF-8" } }; static PlugInProcDef xcf_plug_in_save_proc = @@ -133,16 +139,19 @@ static PlugInProcDef xcf_plug_in_save_proc = "gimp_xcf_save", N_("GIMP XCF image"), NULL, - "xcf", - "", - NULL, - "image/x-xcf", + GIMP_ICON_TYPE_STOCK_ID, + -1, + "gimp-wilber", "RGB*, GRAY*, INDEXED*", 0, /* fill me in at runtime */ + 0, + FALSE, { "gimp_xcf_save", "saves file in the .xcf file format", - "The xcf file format has been designed specifically for loading and saving tiled and layered images in the GIMP. This procedure will save the specified image in the xcf file format.", + "The xcf file format has been designed specifically for loading and " + "saving tiled and layered images in the GIMP. This procedure will save " + "the specified image in the xcf file format.", "Spencer Kimball & Peter Mattis", "Spencer Kimball & Peter Mattis", "1995-1996", @@ -153,10 +162,13 @@ static PlugInProcDef xcf_plug_in_save_proc = NULL, { { xcf_save_invoker } }, }, + "xcf", + "", + NULL, + "image/x-xcf", NULL, /* fill me in at runtime */ NULL, /* fill me in at runtime */ - NULL, /* fill me in at runtime */ - 0 + NULL /* fill me in at runtime */ }; @@ -183,8 +195,8 @@ xcf_init (Gimp *gimp) procedural_db_register (gimp, &xcf_plug_in_save_proc.db_info); procedural_db_register (gimp, &xcf_plug_in_load_proc.db_info); - xcf_plug_in_save_proc.menu_paths = g_list_append (NULL, ""); - xcf_plug_in_load_proc.menu_paths = g_list_append (NULL, ""); + xcf_plug_in_save_proc.menu_paths = g_list_append (NULL, "/Internal"); + xcf_plug_in_load_proc.menu_paths = g_list_append (NULL, "/Internal"); xcf_plug_in_save_proc.image_types_val = plug_ins_image_types_parse (xcf_plug_in_save_proc.image_types); diff --git a/libgimp/gimpenums.h b/libgimp/gimpenums.h index 056eca1376..e6493a9a4b 100644 --- a/libgimp/gimpenums.h +++ b/libgimp/gimpenums.h @@ -159,6 +159,13 @@ typedef enum GIMP_MAGENTA_HUES } GimpHueRange; +typedef enum +{ + GIMP_ICON_TYPE_STOCK_ID, + GIMP_ICON_TYPE_INLINE_PIXBUF, + GIMP_ICON_TYPE_IMAGE_FILE +} GimpIconType; + typedef enum { GIMP_RGB, diff --git a/libgimp/gimpplugin_pdb.c b/libgimp/gimpplugin_pdb.c index 8d28366a49..64c949c12f 100644 --- a/libgimp/gimpplugin_pdb.c +++ b/libgimp/gimpplugin_pdb.c @@ -194,3 +194,43 @@ gimp_plugin_menu_register (const gchar *procedure_name, return success; } + +/** + * gimp_plugin_icon_register: + * @procedure_name: The procedure for which to install the icon. + * @icon_type: The type of the icon. + * @icon_data_length: The length of 'icon_data'. + * @icon_data: The procedure's icon. The format depends on the 'icon_type' parameter. + * + * Register an icon for a plug-in procedure. + * + * This procedure installs an icon for the given procedure. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_plugin_icon_register (const gchar *procedure_name, + GimpIconType icon_type, + gint icon_data_length, + const guint8 *icon_data) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_plugin_icon_register", + &nreturn_vals, + GIMP_PDB_STRING, procedure_name, + GIMP_PDB_INT32, icon_type, + GIMP_PDB_INT32, icon_data_length, + GIMP_PDB_INT8ARRAY, icon_data, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} diff --git a/libgimp/gimpplugin_pdb.h b/libgimp/gimpplugin_pdb.h index 18e1ac6faa..a3ccbc0f31 100644 --- a/libgimp/gimpplugin_pdb.h +++ b/libgimp/gimpplugin_pdb.h @@ -29,14 +29,18 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_progress_init (const gchar *message); -gboolean gimp_progress_update (gdouble percentage); -gboolean gimp_plugin_domain_register (const gchar *domain_name, - const gchar *domain_path); -gboolean gimp_plugin_help_register (const gchar *domain_name, - const gchar *domain_uri); -gboolean gimp_plugin_menu_register (const gchar *procedure_name, - const gchar *menu_path); +gboolean gimp_progress_init (const gchar *message); +gboolean gimp_progress_update (gdouble percentage); +gboolean gimp_plugin_domain_register (const gchar *domain_name, + const gchar *domain_path); +gboolean gimp_plugin_help_register (const gchar *domain_name, + const gchar *domain_uri); +gboolean gimp_plugin_menu_register (const gchar *procedure_name, + const gchar *menu_path); +gboolean gimp_plugin_icon_register (const gchar *procedure_name, + GimpIconType icon_type, + gint icon_data_length, + const guint8 *icon_data); G_END_DECLS diff --git a/libgimpconfig/gimpconfigwriter.c b/libgimpconfig/gimpconfigwriter.c index c62492d26a..0cbb45ec3a 100644 --- a/libgimpconfig/gimpconfigwriter.c +++ b/libgimpconfig/gimpconfigwriter.c @@ -319,6 +319,54 @@ gimp_config_writer_string (GimpConfigWriter *writer, gimp_config_string_append_escaped (writer->buffer, string); } +/** + * gimp_config_writer_identifier: + * @writer: a #GimpConfigWriter + * @string: a NUL-terminated string + * + * Writes an identifier to @writer. The @string is *not* quoted and special + * characters are *not* escaped. + **/ +void +gimp_config_writer_identifier (GimpConfigWriter *writer, + const gchar *identifier) +{ + g_return_if_fail (writer != NULL); + g_return_if_fail (identifier != NULL); + + if (writer->error) + return; + + g_string_append_printf (writer->buffer, " %s", identifier); +} + +void +gimp_config_writer_data (GimpConfigWriter *writer, + gint length, + const guint8 *data) +{ + gint i; + + g_return_if_fail (writer != NULL); + g_return_if_fail (length > 0); + g_return_if_fail (data != NULL); + + if (writer->error) + return; + + g_string_append (writer->buffer, " \""); + + for (i = 0; i < length; i++) + { + if (g_ascii_isalpha (data[i])) + g_string_append_c (writer->buffer, data[i]); + else + g_string_append_printf (writer->buffer, "\\%o", data[i]); + } + + g_string_append (writer->buffer, "\""); +} + /** * gimp_config_writer_revert: * @writer: a #GimpConfigWriter diff --git a/libgimpconfig/gimpconfigwriter.h b/libgimpconfig/gimpconfigwriter.h index bc12ba740c..b4f0535877 100644 --- a/libgimpconfig/gimpconfigwriter.h +++ b/libgimpconfig/gimpconfigwriter.h @@ -41,8 +41,13 @@ void gimp_config_writer_print (GimpConfigWriter *writer, void gimp_config_writer_printf (GimpConfigWriter *writer, const gchar *format, ...); +void gimp_config_writer_identifier (GimpConfigWriter *writer, + const gchar *identifier); void gimp_config_writer_string (GimpConfigWriter *writer, const gchar *string); +void gimp_config_writer_data (GimpConfigWriter *writer, + gint length, + const guint8 *data); void gimp_config_writer_comment (GimpConfigWriter *writer, const gchar *comment); void gimp_config_writer_linefeed (GimpConfigWriter *writer); diff --git a/libgimpconfig/gimpscanner.c b/libgimpconfig/gimpscanner.c index 247f9c17e4..dcf295375a 100644 --- a/libgimpconfig/gimpscanner.c +++ b/libgimpconfig/gimpscanner.c @@ -248,6 +248,24 @@ gimp_scanner_parse_string_no_validate (GScanner *scanner, return TRUE; } +gboolean +gimp_scanner_parse_data (GScanner *scanner, + gint length, + guint8 **dest) +{ + if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING) + return FALSE; + + g_scanner_get_next_token (scanner); + + if (scanner->value.v_string) + *dest = g_memdup (scanner->value.v_string, length); + else + *dest = NULL; + + return TRUE; +} + gboolean gimp_scanner_parse_int (GScanner *scanner, gint *dest) diff --git a/libgimpconfig/gimpscanner.h b/libgimpconfig/gimpscanner.h index 498d53a674..bb783b219d 100644 --- a/libgimpconfig/gimpscanner.h +++ b/libgimpconfig/gimpscanner.h @@ -39,6 +39,9 @@ gboolean gimp_scanner_parse_string (GScanner *scanner, gchar **dest); gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner, gchar **dest); +gboolean gimp_scanner_parse_data (GScanner *scanner, + gint length, + guint8 **dest); gboolean gimp_scanner_parse_int (GScanner *scanner, gint *dest); gboolean gimp_scanner_parse_float (GScanner *scanner, diff --git a/plug-ins/common/plugin-browser.c b/plug-ins/common/plugin-browser.c index c1e7f4401e..ca40906d86 100644 --- a/plug-ins/common/plugin-browser.c +++ b/plug-ins/common/plugin-browser.c @@ -158,6 +158,10 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); + gimp_plugin_icon_register ("plug_in_plug_in_details", + GIMP_ICON_TYPE_STOCK_ID, + strlen (GIMP_STOCK_PLUGIN) + 1, + GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/common/plugindetails.c b/plug-ins/common/plugindetails.c index c1e7f4401e..ca40906d86 100644 --- a/plug-ins/common/plugindetails.c +++ b/plug-ins/common/plugindetails.c @@ -158,6 +158,10 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); + gimp_plugin_icon_register ("plug_in_plug_in_details", + GIMP_ICON_TYPE_STOCK_ID, + strlen (GIMP_STOCK_PLUGIN) + 1, + GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/common/screenshot.c b/plug-ins/common/screenshot.c index eefce3121f..a00f3fba5c 100644 --- a/plug-ins/common/screenshot.c +++ b/plug-ins/common/screenshot.c @@ -43,6 +43,124 @@ #include "libgimp/stdplugins-intl.h" +/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */ + +#ifdef __SUNPRO_C +#pragma align 4 (screenshot_icon) +#endif +#ifdef __GNUC__ +static const guint8 screenshot_icon[] __attribute__ ((__aligned__ (4))) = +#else +static const guint8 screenshot_icon[] = +#endif +{ + "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2735) */ + "\0\0\12\307" + /* pixdata_type (0x2010002) */ + "\2\1\0\2" + /* rowstride (128) */ + "\0\0\0\200" + /* width (32) */ + "\0\0\0\40" + /* height (32) */ + "\0\0\0\40" + /* pixel_data: */ + "\326\0\0\0\0\1eee\13\230\0\0\0\0\1\15\15\15z\207\0\0\0\377\1\14\14\14" + "W\227\0\0\0\0\11\0\0\0\377\306\306\306\354\364\364\364\377\372\372\372" + "\377\375\375\375\377\372\372\372\377\357\357\357\377\257\257\257\310" + "\0\0\0\377\226\0\0\0\0\12]]]\14\0\0\0\377\304\304\304\377\354\354\354" + "\377\367\367\367\377\372\372\372\377\366\366\366\377\352\352\352\377" + "\257\257\257\354\0\0\0\377\226\0\0\0\0\4QQQ+\0\0\0\377}}}\374\177\177" + "\177\366\204\200\200\200\366\2xxx\377\0\0\0\377\226\0\0\0\0\4\35\35\35" + "[\0\0\0\377333\343AAA\206\202PPPL\5KKKYBBB\211555\377\0\0\0\377'''\30" + "\225\0\0\0\0\4\6\6\6\226\0\0\0\377\35\35\35\324GGGc\203QQQU\4""777p\35" + "\35\35\377\0\0\0\377\6\6\6K\224\0\0\0\0\5\0\0\0\33\7\7\7\317\0\0\0\377" + "ZZZ\377eee\377\203fff\377\4ddd\377EEE\377\0\0\0\377\0\0\0\201\215\0\0" + "\0\0\6\0\0\0\4\0\0\0\20\0\0\0\30\2\2\1""4\0\0\0B\0\0\0S\202\0\0\0\377" + "\3''&\264ZYY\365uuu\377\205\217\217\217\377\3sss\377HHH\357\17\17\17" + "\330\202\0\0\0\377\3\0\0\0\233\37\37\37B\0\0\0\16\205\0\0\0\0\2\0\0\0" + "\14\0\0\0u\206\0\0\0\377\6XXX\354LLL\354OOO\345ppp\343\233\233\233\377" + "\252\252\252\377\205\265\265\265\377\10\262\262\262\377\221\221\221\377" + "PPP\372LLL\361===\353\36\36\36\343\37\37\37\330\0\0\0""0\203\0\0\0\0" + "\1\0\0\0\217\203\0\0\0\377\15kjh\377dca\377gec\377jig\377srp\377\243" + "\243\243\377eee\377\345\345\345\377\340\340\340\377|||\377\255\255\255" + "\377\213\213\213\377\212\212\212\377\204\204\204\204\377\10\206\206\206" + "\377\232\232\232\377xxx\377ooo\377|||\377sss\377HHH\367\27\27\27\243" + "\203\0\0\0\0\35\0\0\0\377cb^\377oom\377|{y\377a`^\377YYY\377222\377U" + "TS\377vur\377\217\217\217\377ZZZ\377\346\346\346\377\336\336\336\377" + "\203\203\203\377\242\242\242\377\213\213\213\377\220\217\217\377\201" + "\200\200\377zzx\377mlk\377rqp\377vvu\377\204\204\204\377\213\213\213" + "\377lll\377xxx\377\177\177\177\377ppp\377\0\0\0\377\203\0\0\0\0\35\0" + "\0\0\377\261\257\254\377\206\205\202\377\201\200|\377onk\377onl\377N" + "ML\377\200\200~\377feb\377@@@\377bbb\377RRR\377fff\377\262\262\262\377" + "\221\221\221\377\221\220\216\377rrp\377vwu\377iji\377QSR\377XYX\377c" + "eb\377_`]\377\202\202\201\377rrr\377iii\377bbb\377nnn\377\0\0\0\377\203" + "\0\0\0\0\23\0\0\0\377\210\207\201\377\265\264\262\377\262\262\260\377" + "\302\301\277\377\307\307\306\377\267\267\266\377`_]\377\"\"\40\377JJ" + "J\377sss\377iii\377www\377\264\263\263\377\200\200\177\377hkh\377[_]" + "\377_bb\377]aa\377\202RVV\377\5JNK\377>B=\377QSO\377hig\377jjj\377\202" + "\177\177\177\377\1\0\0\0\377\203\0\0\0\0\35\0\0\0\377\202\200w\377\177" + "}t\377tqh\377ljb\377a^W\377WUO\377\77=9\377$#\40\377LLL\377uuu\377pp" + "p\377\236\236\236\377\222\223\222\377\\__\377bfe\377JNP\377BHI\377CH" + "J\377BGJ\377>CE\3776::\377/3.\377/2,\377:=8\377jih\377}}}\377\200\200" + "\200\377\0\0\0\377\203\0\0\0\0\35\0\0\0\377\202\177w\377\200}u\377tq" + "h\377mjc\377a_X\377WUO\377@\77;\377.,*\377KKK\377mmm\377yyy\377\224\223" + "\222\377aee\377X]]\377\77DD\377VYW\377\\_^\377MQS\377GLM\377TXZ\377Q" + "TV\377;@A\377,/*\377**#\377SRO\377zzz\377\177\177\177\377\0\0\0\377\203" + "\0\0\0\0\12\0\0\0\377\201~u\377\177|t\377sph\377mjb\377a_X\377WUO\377" + "@>9\377/.+\377KKK\377\202ttt\377\21{}}\377QVW\377DHG\377`bb\377599\377" + "\20\21\21\377\6\6\6\377\11\11\11\377\25\27\27\377DFG\377SVW\3777<>\377" + "+,(\377860\377poo\377zzz\377\0\0\0\377\203\0\0\0\0\23\0\0\0\377\200}" + "u\377\177|t\377spg\377ljb\377a_X\377WTN\377@>9\377/.+\377KKK\377ttt\377" + "bdd\377rvw\377\77DD\377\\_^\3778;9\377444\377FFF\377111\377\202\37\37" + "\37\377\10\35\36\36\3778<<\377DIL\377154\377*)\"\377nmk\377\200\200\200" + "\377\0\0\0\377\203\0\0\0\0>\0\0\0\377\177}u\377~{s\377sph\377ljb\377" + "`^W\377UTM\377@=9\377..*\377III\377nnn\377_`a\377@FG\377HLL\377LPQ\377" + ",-+\377\251\251\251\377\200\200\200\377\242\242\242\377OOO\377\77\77" + "\77\377111\377)++\377HMP\377BIK\377\34\34\27\377NMK\377qqq\377\0\0\0" + "\377\0\0\0\2\0\0\0\1\0\0\0\0\0\0\0\377\177}t\377~{s\377rog\377lia\377" + "`^W\377USM\377\77=8\377..*\377III\377lll\377ghh\3779>\77\377SWV\377F" + "JG\377$$#\377lll\377\242\242\242\377\363\363\363\377\221\221\221\377" + "ddd\377DDD\377111\377GLO\377HNQ\377\35\35\32\377QPN\377lll\377\0\0\0" + "\377\0\0\0\6\202\0\0\0\3\36\0\0\0\377\177|t\377}zs\377rog\377kha\377" + "`]W\377USM\377>=8\377.-*\377HHH\377rrr\377dee\3777;<\377LRS\377:>:\377" + "\10\10\7\377CCC\377yyy\377\233\233\233\377\242\242\242\377{{{\377TTT" + "\377<<<\377INQ\377HMQ\377$%#\377mmk\377ttt\377\0\0\0\377\0\0\0\21\202" + "\0\0\0\10""3\0\0\0\377~{s\377}zr\377qog\377kha\377_]V\377TRL\377><8\377" + ".-*\377JJJ\377uuu\377iij\3777;<\3779AC\377387\377\21\22\20\377\37\37" + "\37\377\77\77\77\377ddd\377{{{\377ppp\377\223\223\223\377@AA\377CJM\377" + "\77FI\377-/.\377ssr\377ppp\377\0\0\0\377\0\0\0\31\0\0\0\14\0\0\0\16\0" + "\0\0\377~{t\377}zr\377qnf\377jh`\377^\\V\377SQL\377><7\377.-*\377HHH" + "\377www\377non\377/12\3776>>\377;CF\377%)&\377\33\34\33\377111\377DD" + "D\377\202TTT\377\23FFG\377MOR\377;BG\377058\377DEE\377uuu\377NNN\374" + "\21\21\21\302\0\0\0\34\0\0\0\15\0\0\0\17\0\0\0\264NLJ\377{xq\377ome\377" + "jg`\377`]V\377TQL\377973\377\204\0\0\0\377\14\22\23\23\3774:;\377;CG" + "\377>DC\377*.-\377'((\377111\377;;;\377<>>\377FJM\377FLO\377=BG\377\203" + "\0\0\0\377\7\10\10\10\273\1\1\1l\0\0\0\26\0\0\0\11\0\0\0\12\0\0\0m\0" + "\0\0\256\206\0\0\0\377\40\3\3\2\301\0\0\0\236\0\0\0n\0\0\0t\1\1\1\204" + "\17\20\21\354\0\0\0\377Z]^\377RVW\377B\377\77EH\377HLO\377[" + "]_\377UY[\377\0\0\0\377\14\15\16\266\0\0\0_\0\0\0I\0\0\0-\0\0\0\32\0" + "\0\0\13\0\0\0\4\0\0\0\5\0\0\0\14\0\0\0#\0\0\0;\0\0\0P\0\0\0\\\3\3\3f" + "\11\10\10[\4\4\4N\202\0\0\0B\24\0\0\0E\0\0\0O\0\0\0[\4\5\5\212\20\22" + "\24\321\0\0\0\377INR\377BIM\377BHL\377Z^`\377KOR\377NRU\377\0\0\0\377" + "\17\20\21\265\5\5\6c\0\0\0@\0\0\0-\0\0\0\31\0\0\0\15\0\0\0\4\202\0\0" + "\0\1\4\0\0\0\3\0\0\0\6\0\0\0\11\0\0\0\13\202\0\0\0\15\13\0\0\0\17\0\0" + "\0\22\0\0\0\24\0\0\0\26\0\0\0\32\0\0\0&\0\0\0""0\0\0\0<\1\1\2M\11\12" + "\13\232\34\37!\320\204\0\0\0\377\10\16\17\17\300\14\14\14w\0\0\0<\0\0" + "\0.\0\0\0\35\0\0\0\21\0\0\0\7\0\0\0\3\204\0\0\0\0\6\0\0\0\1\0\0\0\2\0" + "\0\0\1\0\0\0\2\0\0\0\1\0\0\0\2\202\0\0\0\3\23\0\0\0\5\0\0\0\6\0\0\0\17" + "\0\0\0\26\0\0\0\37\0\0\0#\0\0\0-\4\4\5@\3\3\3[\0\0\0p\2\3\3d\7\10\10" + "O\7\10\10""7\0\0\0&\0\0\0\35\0\0\0\24\0\0\0\12\0\0\0\5\0\0\0\1\217\0" + "\0\0\0\6\0\0\0\3\0\0\0\5\0\0\0\11\0\0\0\14\0\0\0\20\0\0\0\23\202\0\0" + "\0\25\7\0\0\0\23\0\0\0\21\0\0\0\15\0\0\0\13\0\0\0\7\0\0\0\4\0\0\0\2\222" + "\0\0\0\0\5\0\0\0\1\0\0\0\2\0\0\0\4\0\0\0\5\0\0\0\7\202\0\0\0\10\5\0\0" + "\0\6\0\0\0\5\0\0\0\3\0\0\0\2\0\0\0\1\207\0\0\0\0" +}; + + /* Defines */ #define PLUG_IN_NAME "plug_in_screenshot" #define HELP_ID "plug-in-screenshot" @@ -145,6 +263,10 @@ query (void) gimp_plugin_menu_register (PLUG_IN_NAME, N_("/File/Acquire")); /* gimp_plugin_menu_register (PLUG_IN_NAME, N_("/File/Acquire")); */ + + gimp_plugin_icon_register (PLUG_IN_NAME, + GIMP_ICON_TYPE_INLINE_PIXBUF, + sizeof (screenshot_icon) - 1, screenshot_icon); } static void diff --git a/plug-ins/common/uniteditor.c b/plug-ins/common/uniteditor.c index 9ead198f36..fc23b4fec4 100644 --- a/plug-ins/common/uniteditor.c +++ b/plug-ins/common/uniteditor.c @@ -122,6 +122,10 @@ query (void) gimp_plugin_menu_register ("plug_in_unit_editor", N_("/Xtns/Extensions")); + gimp_plugin_icon_register ("plug_in_unit_editor", + GIMP_ICON_TYPE_STOCK_ID, + strlen (GIMP_STOCK_TOOL_MEASURE) + 1, + GIMP_STOCK_TOOL_MEASURE); } static void diff --git a/plug-ins/dbbrowser/plugin-browser.c b/plug-ins/dbbrowser/plugin-browser.c index c1e7f4401e..ca40906d86 100644 --- a/plug-ins/dbbrowser/plugin-browser.c +++ b/plug-ins/dbbrowser/plugin-browser.c @@ -158,6 +158,10 @@ query (void) gimp_plugin_menu_register ("plug_in_plug_in_details", N_("/Xtns/Extensions")); + gimp_plugin_icon_register ("plug_in_plug_in_details", + GIMP_ICON_TYPE_STOCK_ID, + strlen (GIMP_STOCK_PLUGIN) + 1, + GIMP_STOCK_PLUGIN); } static void diff --git a/plug-ins/print/print.c b/plug-ins/print/print.c index 933fc371ac..d86dff0434 100644 --- a/plug-ins/print/print.c +++ b/plug-ins/print/print.c @@ -169,6 +169,10 @@ query (void) gimp_plugin_menu_register ("file_print_gimp", N_("/File/Send")); + gimp_plugin_icon_register ("file_print_gimp", + GIMP_ICON_TYPE_STOCK_ID, + strlen (GTK_STOCK_PRINT) + 1, + GTK_STOCK_PRINT); } diff --git a/plug-ins/pygimp/gimpenums.py b/plug-ins/pygimp/gimpenums.py index df1fff8d0d..4285440cd8 100644 --- a/plug-ins/pygimp/gimpenums.py +++ b/plug-ins/pygimp/gimpenums.py @@ -136,6 +136,11 @@ CYAN_HUES = 4 BLUE_HUES = 5 MAGENTA_HUES = 6 +# GimpIconType +ICON_TYPE_STOCK_ID = 0 +ICON_TYPE_INLINE_PIXBUF = 1 +ICON_TYPE_IMAGE_FILE = 2 + # GimpImageBaseType RGB = 0 GRAY = 1 diff --git a/plug-ins/script-fu/script-fu-constants.c b/plug-ins/script-fu/script-fu-constants.c index 6eac8aa652..ce1f9972b5 100644 --- a/plug-ins/script-fu/script-fu-constants.c +++ b/plug-ins/script-fu/script-fu-constants.c @@ -110,6 +110,10 @@ init_generated_constants (void) setvar (cintern ("BLUE-HUES"), flocons (5), NIL); setvar (cintern ("MAGENTA-HUES"), flocons (6), NIL); + setvar (cintern ("ICON-TYPE-STOCK-ID"), flocons (0), NIL); + setvar (cintern ("ICON-TYPE-INLINE-PIXBUF"), flocons (1), NIL); + setvar (cintern ("ICON-TYPE-IMAGE-FILE"), flocons (2), NIL); + setvar (cintern ("RGB"), flocons (0), NIL); setvar (cintern ("GRAY"), flocons (1), NIL); setvar (cintern ("INDEXED"), flocons (2), NIL); diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl index 445403cd7c..dec0dd14de 100644 --- a/tools/pdbgen/enums.pl +++ b/tools/pdbgen/enums.pl @@ -289,6 +289,16 @@ package Gimp::CodeGen::enums; GIMP_GRADIENT_SPIRAL_CLOCKWISE => '9', GIMP_GRADIENT_SPIRAL_ANTICLOCKWISE => '10' } }, + GimpIconType => + { contig => 1, + header => 'core/core-enums.h', + symbols => [ qw(GIMP_ICON_TYPE_STOCK_ID + GIMP_ICON_TYPE_INLINE_PIXBUF + GIMP_ICON_TYPE_IMAGE_FILE) ], + mapping => { GIMP_ICON_TYPE_STOCK_ID => '0', + GIMP_ICON_TYPE_INLINE_PIXBUF => '1', + GIMP_ICON_TYPE_IMAGE_FILE => '2' } + }, GimpImageBaseType => { contig => 1, header => 'core/core-enums.h', diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb index 18d0fb3eea..924d95043a 100644 --- a/tools/pdbgen/pdb/plug_in.pdb +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -389,6 +389,80 @@ CODE ); } +sub plugin_icon_register { + $blurb = "Register an icon for a plug-in procedure."; + + $help = <'; + $date = '2004'; + $since = '2.2'; + + @inargs = ( + { name => 'procedure_name', type => 'string', + desc => 'The procedure for which to install the icon' }, + { name => 'icon_type', type => 'enum GimpIconType', + desc => 'The type of the icon' }, + { name => 'icon_data_length', type => 'int32', + desc => 'The length of \'icon_data\'' }, + { name => 'icon_data', type => 'int8array', + desc => 'The procedure\'s icon. The format depends on the \'icon_type\' parameter' } + ); + + %invoke = ( + success => 'TRUE', + code => <<'CODE', +{ + if (gimp->current_plug_in && gimp->current_plug_in->query) + { + GSList *list; + + for (list = gimp->current_plug_in->plug_in_def->proc_defs; + list; + list = g_slist_next (list)) + { + PlugInProcDef *proc_def = list->data; + + if (! strcmp (procedure_name, proc_def->db_info.name)) + { + if (proc_def->icon_data) + { + g_free (proc_def->icon_data); + proc_def->icon_data_length = -1; + proc_def->icon_data = NULL; + } + + proc_def->icon_type = icon_type; + + switch (proc_def->icon_type) + { + case GIMP_ICON_TYPE_STOCK_ID: + case GIMP_ICON_TYPE_IMAGE_FILE: + proc_def->icon_data_length = -1; + proc_def->icon_data = g_strdup (icon_data); + break; + + case GIMP_ICON_TYPE_INLINE_PIXBUF: + proc_def->icon_data_length = icon_data_length; + proc_def->icon_data = g_memdup (icon_data, + icon_data_length); + break; + } + + break; + } + } + + if (! list) + success = FALSE; + } +} +CODE + ); +} + $extra{app}->{code} = <<'CODE'; static int @@ -406,8 +480,9 @@ CODE "plug-in/plug-in-proc.h" "plug-in/plug-in-progress.h"); @procs = qw(progress_init progress_update plugins_query - plugin_domain_register plugin_help_register plugin_menu_register); -%exports = (app => [@procs], lib => [@procs[0,1,3,4,5]]); + plugin_domain_register plugin_help_register + plugin_menu_register plugin_icon_register); +%exports = (app => [@procs], lib => [@procs[0,1,3,4,5,6]]); $desc = 'Plug-in';