[gimp/gtk3-port: 291/362] Bug 794132 - Make the plug-in protocol version part of the plug-in command line



commit 3561e23a44a4a7dc7e510cf1b63b033e375735f9
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 2 16:35:06 2018 +0200

    Bug 794132 - Make the plug-in protocol version part of the plug-in command line
    
    Also clean GPConfig struct from deprecated members and bump the
    plug-in protocol version number.

 app/plug-in/gimpplugin.c             |    7 ++++-
 app/plug-in/gimppluginmanager-call.c |    3 --
 libgimp/gimp.c                       |   46 +++++++++++++++++-----------------
 libgimp/gimp.h                       |    2 -
 libgimpbase/gimpprotocol.c           |   20 --------------
 libgimpbase/gimpprotocol.h           |   13 +---------
 6 files changed, 30 insertions(+), 61 deletions(-)
---
diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c
index 8869bc4..5394b88 100644
--- a/app/plug-in/gimpplugin.c
+++ b/app/plug-in/gimpplugin.c
@@ -218,9 +218,10 @@ gimp_plug_in_open (GimpPlugIn         *plug_in,
   gint          my_read[2];
   gint          my_write[2];
   gchar       **envp;
-  const gchar  *args[9];
+  const gchar  *args[10];
   gchar       **argv;
   gint          argc;
+  gchar         protocol_version[8];
   gchar        *interp, *interp_arg;
   gchar        *his_read_fd, *his_write_fd;
   const gchar  *mode;
@@ -327,8 +328,12 @@ gimp_plug_in_open (GimpPlugIn         *plug_in,
   if (interp_arg)
     args[argc++] = interp_arg;
 
+  g_snprintf (protocol_version, sizeof (protocol_version),
+              "%d", GIMP_PROTOCOL_VERSION);
+
   args[argc++] = progname;
   args[argc++] = "-gimp";
+  args[argc++] = protocol_version;
   args[argc++] = his_read_fd;
   args[argc++] = his_write_fd;
   args[argc++] = mode;
diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c
index a5a419f..4489601 100644
--- a/app/plug-in/gimppluginmanager-call.c
+++ b/app/plug-in/gimppluginmanager-call.c
@@ -194,7 +194,6 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
 
       display_ID = display ? gimp_get_display_ID (manager->gimp, display) : -1;
 
-      config.version          = GIMP_PROTOCOL_VERSION;
       config.tile_width       = GIMP_PLUG_IN_TILE_WIDTH;
       config.tile_height      = GIMP_PLUG_IN_TILE_HEIGHT;
       config.shm_ID           = (manager->shm ?
@@ -208,9 +207,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
       config.export_exif      = core_config->export_metadata_exif;
       config.export_xmp       = core_config->export_metadata_xmp;
       config.export_iptc      = core_config->export_metadata_iptc;
-      config.install_cmap     = FALSE;
       config.show_tooltips    = gui_config->show_tooltips;
-      config.min_colors       = 144;
       config.gdisp_ID         = display_ID;
       config.app_name         = (gchar *) g_get_application_name ();
       config.wm_class         = (gchar *) gimp_get_program_class (manager->gimp);
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 722d8d5..0e4865d 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -214,7 +214,6 @@ static gint           _tile_height       = -1;
 static gint           _shm_ID            = -1;
 static guchar        *_shm_addr          = NULL;
 static const gdouble  _gamma_val         = 2.2;
-static gboolean       _install_cmap      = FALSE;
 static gboolean       _show_tool_tips    = TRUE;
 static gboolean       _show_help_button  = TRUE;
 static gboolean       _export_exif       = FALSE;
@@ -222,7 +221,6 @@ static gboolean       _export_xmp        = FALSE;
 static gboolean       _export_iptc       = FALSE;
 static GimpCheckSize  _check_size        = GIMP_CHECK_SIZE_MEDIUM_CHECKS;
 static GimpCheckType  _check_type        = GIMP_CHECK_TYPE_GRAY_CHECKS;
-static gint           _min_colors        = 144;
 static gint           _gdisp_ID          = -1;
 static gchar         *_wm_class          = NULL;
 static gchar         *_display_name      = NULL;
@@ -279,6 +277,7 @@ gimp_main (const GimpPlugInInfo *info,
   {
     ARG_PROGNAME,
     ARG_GIMP,
+    ARG_PROTOCOL_VERSION,
     ARG_READ_FD,
     ARG_WRITE_FD,
     ARG_MODE,
@@ -290,6 +289,7 @@ gimp_main (const GimpPlugInInfo *info,
   gchar       *basename;
   const gchar *env_string;
   gchar       *debug_string;
+  gint         protocol_version;
 
 #ifdef G_OS_WIN32
   gint i, j, k;
@@ -455,6 +455,27 @@ gimp_main (const GimpPlugInInfo *info,
 
   g_set_prgname (basename);
 
+  protocol_version = atoi (argv[ARG_PROTOCOL_VERSION]);
+
+  if (protocol_version < GIMP_PROTOCOL_VERSION)
+    {
+      gimp_message (g_strdup_printf ("Could not execute plug-in \"%s\"\n(%s)\n"
+                                     "because GIMP is using an older version of the "
+                                     "plug-in protocol.",
+                                     gimp_filename_to_utf8 (g_get_prgname ()),
+                                     gimp_filename_to_utf8 (progname)));
+      return 1;
+    }
+  else if (protocol_version > GIMP_PROTOCOL_VERSION)
+    {
+      gimp_message (g_strdup_printf ("Could not execute plug-in \"%s\"\n(%s)\n"
+                                     "because it uses an obsolete version of the "
+                                     "plug-in protocol.",
+                                     gimp_filename_to_utf8 (g_get_prgname ()),
+                                     gimp_filename_to_utf8 (progname)));
+      return 1;
+    }
+
   env_string = g_getenv ("GIMP_PLUGIN_DEBUG");
 
   if (env_string)
@@ -2126,37 +2147,16 @@ gimp_loop (void)
 static void
 gimp_config (GPConfig *config)
 {
-  if (config->version < GIMP_PROTOCOL_VERSION)
-    {
-      g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
-                 "because GIMP is using an older version of the "
-                 "plug-in protocol.",
-                 gimp_filename_to_utf8 (g_get_prgname ()),
-                 gimp_filename_to_utf8 (progname));
-      gimp_quit ();
-    }
-  else if (config->version > GIMP_PROTOCOL_VERSION)
-    {
-      g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
-                 "because it uses an obsolete version of the "
-                 "plug-in protocol.",
-                 gimp_filename_to_utf8 (g_get_prgname ()),
-                 gimp_filename_to_utf8 (progname));
-      gimp_quit ();
-    }
-
   _tile_width       = config->tile_width;
   _tile_height      = config->tile_height;
   _shm_ID           = config->shm_ID;
   _check_size       = config->check_size;
   _check_type       = config->check_type;
-  _install_cmap     = config->install_cmap     ? TRUE : FALSE;
   _show_tool_tips   = config->show_tooltips    ? TRUE : FALSE;
   _show_help_button = config->show_help_button ? TRUE : FALSE;
   _export_exif      = config->export_exif      ? TRUE : FALSE;
   _export_xmp       = config->export_xmp       ? TRUE : FALSE;
   _export_iptc      = config->export_iptc      ? TRUE : FALSE;
-  _min_colors       = config->min_colors;
   _gdisp_ID         = config->gdisp_ID;
   _wm_class         = g_strdup (config->wm_class);
   _display_name     = g_strdup (config->display_name);
diff --git a/libgimp/gimp.h b/libgimp/gimp.h
index 78c39ff..8de7ea3 100644
--- a/libgimp/gimp.h
+++ b/libgimp/gimp.h
@@ -129,7 +129,6 @@ union _GimpParamData
   gchar           **d_stringarray;
   GimpRGB          *d_colorarray;
   GimpRGB           d_color;
-  GimpParamRegion   d_region; /* deprecated */
   gint32            d_display;
   gint32            d_image;
   gint32            d_item;
@@ -139,7 +138,6 @@ union _GimpParamData
   gint32            d_drawable;
   gint32            d_selection;
   gint32            d_boundary;
-  gint32            d_path; /* deprecated */
   gint32            d_vectors;
   gint32            d_unit;
   GimpParasite      d_parasite;
diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c
index 0cf1d7a..a4f4514 100644
--- a/libgimpbase/gimpprotocol.c
+++ b/libgimpbase/gimpprotocol.c
@@ -474,9 +474,6 @@ _gp_config_read (GIOChannel      *channel,
   GPConfig *config = g_slice_new0 (GPConfig);
 
   if (! _gimp_wire_read_int32 (channel,
-                               &config->version, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_int32 (channel,
                                &config->tile_width, 1, user_data))
     goto cleanup;
   if (! _gimp_wire_read_int32 (channel,
@@ -516,15 +513,9 @@ _gp_config_read (GIOChannel      *channel,
                               user_data))
     goto cleanup;
   if (! _gimp_wire_read_int8 (channel,
-                              (guint8 *) &config->install_cmap, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_int8 (channel,
                               (guint8 *) &config->show_tooltips, 1, user_data))
     goto cleanup;
   if (! _gimp_wire_read_int32 (channel,
-                               (guint32 *) &config->min_colors, 1, user_data))
-    goto cleanup;
-  if (! _gimp_wire_read_int32 (channel,
                                (guint32 *) &config->gdisp_ID, 1, user_data))
     goto cleanup;
 
@@ -563,9 +554,6 @@ _gp_config_write (GIOChannel      *channel,
   GPConfig *config = msg->data;
 
   if (! _gimp_wire_write_int32 (channel,
-                                &config->version, 1, user_data))
-    return;
-  if (! _gimp_wire_write_int32 (channel,
                                 &config->tile_width, 1, user_data))
     return;
   if (! _gimp_wire_write_int32 (channel,
@@ -608,18 +596,10 @@ _gp_config_write (GIOChannel      *channel,
                                user_data))
     return;
   if (! _gimp_wire_write_int8 (channel,
-                               (const guint8 *) &config->install_cmap, 1,
-                               user_data))
-    return;
-  if (! _gimp_wire_write_int8 (channel,
                                (const guint8 *) &config->show_tooltips, 1,
                                user_data))
     return;
   if (! _gimp_wire_write_int32 (channel,
-                                (const guint32 *) &config->min_colors, 1,
-                                user_data))
-    return;
-  if (! _gimp_wire_write_int32 (channel,
                                 (const guint32 *) &config->gdisp_ID, 1,
                                 user_data))
     return;
diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h
index bcb9d1d..63e1a21 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  0x0016
+#define GIMP_PROTOCOL_VERSION  0x0017
 
 
 enum
@@ -61,7 +61,6 @@ typedef struct _GPProcUninstall GPProcUninstall;
 
 struct _GPConfig
 {
-  guint32  version;
   guint32  tile_width;
   guint32  tile_height;
   gint32   shm_ID;
@@ -73,9 +72,7 @@ struct _GPConfig
   gint8    export_exif;
   gint8    export_xmp;
   gint8    export_iptc;
-  gint8    install_cmap;
   gint8    show_tooltips;
-  gint32   min_colors;
   gint32   gdisp_ID;
   gchar   *app_name;
   gchar   *wm_class;
@@ -121,13 +118,6 @@ struct _GPParam
     gchar       **d_stringarray;
     GimpRGB      *d_colorarray;
     GimpRGB       d_color;
-    struct
-    {
-      gint32 x;
-      gint32 y;
-      gint32 width;
-      gint32 height;
-    } d_region; /* deprecated */
     gint32        d_display;
     gint32        d_image;
     gint32        d_item;
@@ -136,7 +126,6 @@ struct _GPParam
     gint32        d_drawable;
     gint32        d_selection;
     gint32        d_boundary;
-    gint32        d_path; /* deprecated */
     gint32        d_vectors;
     gint32        d_status;
     GimpParasite  d_parasite;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]