From d156028c8acffc2c02f489b203dc94b898e7766c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 8 Aug 2019 09:57:56 +0200 Subject: [PATCH] libgimp*, app: add the help-id to the wire protocol Pass the help-id specified by the procedure to the core, and use it in the core if set instead of always using the procedure's name (which was probably good enough for all eternity, but it's still more consistent this way). --- app/plug-in/gimpplugin-message.c | 2 ++ app/plug-in/gimppluginprocedure.c | 31 +++++++++++++++++++++++++------ app/plug-in/gimppluginprocedure.h | 4 ++++ libgimp/gimplegacy.c | 1 + libgimp/gimpprocedure-private.c | 1 + libgimpbase/gimpprotocol.c | 8 ++++++++ libgimpbase/gimpprotocol.h | 3 ++- 7 files changed, 43 insertions(+), 7 deletions(-) diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 786706a78c..05e69d33a8 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -749,6 +749,7 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in, VALIDATE (canonical) && VALIDATE_OR_NULL (proc_install->blurb) && VALIDATE_OR_NULL (proc_install->help) && + VALIDATE_OR_NULL (proc_install->help_id) && VALIDATE_OR_NULL (proc_install->authors) && VALIDATE_OR_NULL (proc_install->copyright) && VALIDATE_OR_NULL (proc_install->date)) @@ -864,6 +865,7 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in, proc->menu_label = g_strdup (proc_install->menu_label); gimp_plug_in_procedure_set_image_types (proc, proc_install->image_types); + gimp_plug_in_procedure_set_help_id (proc, proc_install->help_id); for (i = 0; i < proc_install->nparams; i++) { diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c index dab746b8c1..e432b23f01 100644 --- a/app/plug-in/gimppluginprocedure.c +++ b/app/plug-in/gimppluginprocedure.c @@ -157,6 +157,7 @@ gimp_plug_in_procedure_finalize (GObject *object) g_free (proc->label); g_free (proc->help_id); + g_free (proc->help_id_with_domain); g_free (proc->icon_data); g_free (proc->image_types); @@ -300,18 +301,24 @@ gimp_plug_in_procedure_get_help_id (GimpProcedure *procedure) { GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure); const gchar *domain; + const gchar *help_id; - if (proc->help_id) - return proc->help_id; + if (proc->help_id_with_domain) + return proc->help_id_with_domain; domain = gimp_plug_in_procedure_get_help_domain (proc); - if (domain) - proc->help_id = g_strconcat (domain, "?", gimp_object_get_name (proc), NULL); + if (proc->help_id) + help_id = proc->help_id; else - proc->help_id = g_strdup (gimp_object_get_name (proc)); + help_id = gimp_object_get_name (procedure); - return proc->help_id; + if (domain) + proc->help_id_with_domain = g_strconcat (domain, "?", help_id, NULL); + else + proc->help_id_with_domain = g_strdup (help_id); + + return proc->help_id_with_domain; } static gboolean @@ -575,6 +582,18 @@ gimp_plug_in_procedure_set_help_domain (GimpPlugInProcedure *proc, proc->help_domain = help_domain ? g_quark_from_string (help_domain) : 0; } +void +gimp_plug_in_procedure_set_help_id (GimpPlugInProcedure *proc, + const gchar *help_id) +{ + g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc)); + + g_clear_pointer (&proc->help_id_with_domain, g_free); + + g_free (proc->help_id); + proc->help_id = g_strdup (help_id); +} + const gchar * gimp_plug_in_procedure_get_help_domain (GimpPlugInProcedure *proc) { diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h index 3b815a1f8f..115eecdbff 100644 --- a/app/plug-in/gimppluginprocedure.h +++ b/app/plug-in/gimppluginprocedure.h @@ -46,6 +46,7 @@ struct _GimpPlugInProcedure GList *menu_paths; gchar *label; gchar *help_id; + gchar *help_id_with_domain; GimpIconType icon_type; gint icon_data_length; guint8 *icon_data; @@ -103,6 +104,9 @@ void gimp_plug_in_procedure_set_help_domain (GimpPlugInProcedure *pro const gchar *help_domain); const gchar * gimp_plug_in_procedure_get_help_domain (GimpPlugInProcedure *proc); +void gimp_plug_in_procedure_set_help_id (GimpPlugInProcedure *proc, + const gchar *help_id); + gboolean gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc, const gchar *menu_path, GError **error); diff --git a/libgimp/gimplegacy.c b/libgimp/gimplegacy.c index 744339836a..c865b943cd 100644 --- a/libgimp/gimplegacy.c +++ b/libgimp/gimplegacy.c @@ -210,6 +210,7 @@ gimp_install_procedure (const gchar *name, proc_install.name = (gchar *) name; proc_install.blurb = (gchar *) blurb; proc_install.help = (gchar *) help; + proc_install.help_id = (gchar *) name; proc_install.authors = (gchar *) author; proc_install.copyright = (gchar *) copyright; proc_install.date = (gchar *) date; diff --git a/libgimp/gimpprocedure-private.c b/libgimp/gimpprocedure-private.c index c7955e426e..1dede20319 100644 --- a/libgimp/gimpprocedure-private.c +++ b/libgimp/gimpprocedure-private.c @@ -57,6 +57,7 @@ _gimp_procedure_register (GimpProcedure *procedure) proc_install.name = (gchar *) gimp_procedure_get_name (procedure); proc_install.blurb = (gchar *) gimp_procedure_get_blurb (procedure); proc_install.help = (gchar *) gimp_procedure_get_help (procedure); + proc_install.help_id = (gchar *) gimp_procedure_get_help_id (procedure); proc_install.authors = (gchar *) gimp_procedure_get_authors (procedure); proc_install.copyright = (gchar *) gimp_procedure_get_copyright (procedure); proc_install.date = (gchar *) gimp_procedure_get_date (procedure); diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c index 90c6842b4a..12518d54af 100644 --- a/libgimpbase/gimpprotocol.c +++ b/libgimpbase/gimpprotocol.c @@ -1202,6 +1202,9 @@ _gp_proc_install_read (GIOChannel *channel, if (! _gimp_wire_read_string (channel, &proc_install->help, 1, user_data)) goto cleanup; + if (! _gimp_wire_read_string (channel, + &proc_install->help_id, 1, user_data)) + goto cleanup; if (! _gimp_wire_read_string (channel, &proc_install->authors, 1, user_data)) goto cleanup; @@ -1255,6 +1258,7 @@ _gp_proc_install_read (GIOChannel *channel, g_free (proc_install->name); g_free (proc_install->blurb); g_free (proc_install->help); + g_free (proc_install->help_id); g_free (proc_install->authors); g_free (proc_install->copyright); g_free (proc_install->date); @@ -1443,6 +1447,9 @@ _gp_proc_install_write (GIOChannel *channel, if (! _gimp_wire_write_string (channel, &proc_install->help, 1, user_data)) return; + if (! _gimp_wire_write_string (channel, + &proc_install->help_id, 1, user_data)) + return; if (! _gimp_wire_write_string (channel, &proc_install->authors, 1, user_data)) return; @@ -1498,6 +1505,7 @@ _gp_proc_install_destroy (GimpWireMessage *msg) g_free (proc_install->name); g_free (proc_install->blurb); g_free (proc_install->help); + g_free (proc_install->help_id); g_free (proc_install->authors); g_free (proc_install->copyright); g_free (proc_install->date); diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h index 5b7177babc..732f9c1b31 100644 --- a/libgimpbase/gimpprotocol.h +++ b/libgimpbase/gimpprotocol.h @@ -26,7 +26,7 @@ G_BEGIN_DECLS /* Increment every time the protocol changes */ -#define GIMP_PROTOCOL_VERSION 0x0106 +#define GIMP_PROTOCOL_VERSION 0x0107 enum @@ -268,6 +268,7 @@ struct _GPProcInstall gchar *name; gchar *blurb; gchar *help; + gchar *help_id; gchar *authors; gchar *copyright; gchar *date;