Commit de108498 authored by Ell's avatar Ell

libgimpbase, libgimp, app: pass icon theme dir to plug-ins through config

Pass the current icon theme directory to plug-ins through the
config message, and add a gimp_icon_theme_dir() libgimp function
for retrieving it.  Note that we already have a similar
gimp_icon_get_theme_dir() PDB function, which we keep around, since
it can be used to dynamically query for the current icon dir,
unlike the former, and since it returns a dynamically-allocated
string, while the rest of the config-related functions return
statically allocated strings.

Use the new function, instead of gimp_get_icon_theme_dir(), in
gimp_ui_init().  This allows gimp_ui_init() to run without making
any PDB calls.  Consequently, this allows us to start plug-ins that
call gimp_ui_init() without entering the main loop in the main app.
We're going to add a plug-in that displays an interactive dialog
while the main app is blocking waiting for an operation to
complete, and we need to be able to start the plug-in without
entering the main loop, to avoid the possibility of arbitrary code
being executed during the wait.

Bump the protocol version.
parent 82b97938
......@@ -175,6 +175,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
gint display_ID;
GObject *screen;
gint monitor;
GFile *icon_theme_dir;
if (! gimp_plug_in_open (plug_in, GIMP_PLUG_IN_CALL_RUN, FALSE))
{
......@@ -195,6 +196,8 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
display_ID = display ? gimp_get_display_ID (manager->gimp, display) : -1;
icon_theme_dir = gimp_get_icon_theme_dir (manager->gimp);
config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = GIMP_PLUG_IN_TILE_WIDTH;
config.tile_height = GIMP_PLUG_IN_TILE_HEIGHT;
......@@ -220,6 +223,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
&screen, &monitor);
config.monitor_number = monitor;
config.timestamp = gimp_get_user_time (manager->gimp);
config.icon_theme_dir = icon_theme_dir ?
g_file_get_path (icon_theme_dir) :
NULL;
proc_run.name = GIMP_PROCEDURE (procedure)->original_name;
proc_run.nparams = gimp_value_array_length (args);
......@@ -236,6 +242,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
name);
g_free (config.display_name);
g_free (config.icon_theme_dir);
g_free (proc_run.params);
g_object_unref (plug_in);
......@@ -248,6 +255,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
}
g_free (config.display_name);
g_free (config.icon_theme_dir);
g_free (proc_run.params);
/* If this is an extension,
......
......@@ -158,6 +158,10 @@
<title>Index of new symbols in GIMP 2.10</title>
<xi:include href="xml/api-index-2.10.xml"><xi:fallback /></xi:include>
</index>
<index role="2.10.4" id="api-index-2-10-4">
<title>Index of new symbols in GIMP 2.10.4</title>
<xi:include href="xml/api-index-2.10.4.xml"><xi:fallback /></xi:include>
</index>
<index role="deprecated" id="api-index-deprecated">
<title>Index of deprecated symbols</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
......
......@@ -45,6 +45,7 @@ gimp_wm_class
gimp_display_name
gimp_monitor_number
gimp_user_time
gimp_icon_theme_dir
gimp_get_progname
gimp_extension_enable
gimp_extension_ack
......
......@@ -228,6 +228,7 @@ static gchar *_wm_class = NULL;
static gchar *_display_name = NULL;
static gint _monitor_number = 0;
static guint32 _timestamp = 0;
static gchar *_icon_theme_dir = NULL;
static const gchar *progname = NULL;
static gchar write_buffer[WRITE_BUFFER_SIZE];
......@@ -1615,6 +1616,23 @@ gimp_user_time (void)
return _timestamp;
}
/**
* gimp_get_icon_theme_dir:
*
* Returns the directory of the current icon theme.
*
* This is a constant value given at plug-in configuration time.
*
* Return value: the icon theme directory
*
* Since: 2.10.4
**/
const gchar *
gimp_icon_theme_dir (void)
{
return _icon_theme_dir;
}
/**
* gimp_get_progname:
*
......@@ -2293,6 +2311,7 @@ gimp_config (GPConfig *config)
_display_name = g_strdup (config->display_name);
_monitor_number = config->monitor_number;
_timestamp = config->timestamp;
_icon_theme_dir = g_strdup (config->icon_theme_dir);
if (config->app_name)
g_set_application_name (config->app_name);
......
......@@ -416,6 +416,7 @@ EXPORTS
gimp_histogram
gimp_histogram_channel_get_type
gimp_hue_saturation
gimp_icon_theme_dir
gimp_image_add_channel
gimp_image_add_hguide
gimp_image_add_layer
......
......@@ -340,6 +340,7 @@ const gchar * gimp_wm_class (void) G_GNUC_CONST;
const gchar * gimp_display_name (void) G_GNUC_CONST;
gint gimp_monitor_number (void) G_GNUC_CONST;
guint32 gimp_user_time (void) G_GNUC_CONST;
const gchar * gimp_icon_theme_dir (void) G_GNUC_CONST;
const gchar * gimp_get_progname (void) G_GNUC_CONST;
......
......@@ -164,9 +164,12 @@ gimp_ui_init (const gchar *prog_name,
screen = gdk_screen_get_default ();
gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen));
file = g_file_new_for_path (gimp_get_icon_theme_dir ());
gimp_icons_set_icon_theme (file);
g_object_unref (file);
if (gimp_icon_theme_dir ())
{
file = g_file_new_for_path (gimp_icon_theme_dir ());
gimp_icons_set_icon_theme (file);
g_object_unref (file);
}
gimp_widgets_init (gimp_ui_help_func,
gimp_context_get_foreground,
......
......@@ -545,6 +545,14 @@ _gp_config_read (GIOChannel *channel,
&config->timestamp, 1, user_data))
goto cleanup;
if (config->version < 0x0017)
goto end;
if (! _gimp_wire_read_string (channel,
&config->icon_theme_dir, 1, user_data))
goto cleanup;
end:
msg->data = config;
return;
......@@ -552,6 +560,7 @@ _gp_config_read (GIOChannel *channel,
g_free (config->app_name);
g_free (config->wm_class);
g_free (config->display_name);
g_free (config->icon_theme_dir);
g_slice_free (GPConfig, config);
}
......@@ -640,6 +649,13 @@ _gp_config_write (GIOChannel *channel,
(const guint32 *) &config->timestamp, 1,
user_data))
return;
if (config->version < 0x0017)
return;
if (! _gimp_wire_write_string (channel,
&config->icon_theme_dir, 1, user_data))
return;
}
static void
......
......@@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Increment every time the protocol changes
*/
#define GIMP_PROTOCOL_VERSION 0x0016
#define GIMP_PROTOCOL_VERSION 0x0017
enum
......@@ -82,6 +82,9 @@ struct _GPConfig
gchar *display_name;
gint32 monitor_number;
guint32 timestamp;
/* since protocol version 0x0017: */
gchar *icon_theme_dir;
};
struct _GPTileReq
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment