Made plug-ins honor the current GIMP theme:

2003-11-10  Michael Natterer  <mitch@gimp.org>

	Made plug-ins honor the current GIMP theme:

	* app/core/gimp.[ch]: added GimpGetThemeDirFunc to the GUI vtable.

	* app/gui/gui-vtable.c: implement it here.

	* tools/pdbgen/pdb/gimprc.pdb: added new PDB function
	gimp_get_theme_dir().

	* libgimp/gimpui.c: use the new function and fall back to
	gimp_gtkrc() if it returns NULL.

	* app/pdb/gimprc_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpgimprc_pdb.[ch]: regenerated.

	* app/gui/themes.c: unrelated cleanup.
This commit is contained in:
Michael Natterer 2003-11-10 12:36:22 +00:00 committed by Michael Natterer
parent 429313f598
commit cd218fef29
11 changed files with 186 additions and 32 deletions

View File

@ -1,3 +1,23 @@
2003-11-10 Michael Natterer <mitch@gimp.org>
Made plug-ins honor the current GIMP theme:
* app/core/gimp.[ch]: added GimpGetThemeDirFunc to the GUI vtable.
* app/gui/gui-vtable.c: implement it here.
* tools/pdbgen/pdb/gimprc.pdb: added new PDB function
gimp_get_theme_dir().
* libgimp/gimpui.c: use the new function and fall back to
gimp_gtkrc() if it returns NULL.
* app/pdb/gimprc_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpgimprc_pdb.[ch]: regenerated.
* app/gui/themes.c: unrelated cleanup.
2003-11-10 Michael Natterer <mitch@gimp.org>
* app/gui/tools-commands.c (tools_select_cmd_callback): don't

View File

@ -1164,6 +1164,17 @@ gimp_get_display_name (Gimp *gimp,
return NULL;
}
const gchar *
gimp_get_theme_dir (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->gui_get_theme_dir_func)
return gimp->gui_get_theme_dir_func (gimp);
return NULL;
}
GimpImage *
gimp_create_image (Gimp *gimp,
gint width,

View File

@ -61,6 +61,7 @@ typedef const gchar * (* GimpGetProgramClassFunc) (Gimp *gimp);
typedef gchar * (* GimpGetDisplayNameFunc) (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
typedef const gchar * (* GimpGetThemeDirFunc) (Gimp *);
#define GIMP_TYPE_GIMP (gimp_get_type ())
@ -106,6 +107,7 @@ struct _Gimp
GimpPDBDialogsCheckFunc gui_pdb_dialogs_check_func;
GimpGetProgramClassFunc gui_get_program_class_func;
GimpGetDisplayNameFunc gui_get_display_name_func;
GimpGetThemeDirFunc gui_get_theme_dir_func;
gint busy;
guint busy_idle_id;
@ -267,6 +269,7 @@ const gchar * gimp_get_program_class (Gimp *gimp);
gchar * gimp_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
const gchar * gimp_get_theme_dir (Gimp *gimp);
GimpImage * gimp_create_image (Gimp *gimp,
gint width,

View File

@ -88,6 +88,7 @@ static const gchar * gui_get_program_class (Gimp *gimp);
static gchar * gui_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
static const gchar * gui_get_theme_dir (Gimp *gimp);
/* public functions */
@ -113,6 +114,7 @@ gui_vtable_init (Gimp *gimp)
gimp->gui_pdb_dialogs_check_func = gui_pdb_dialogs_check;
gimp->gui_get_program_class_func = gui_get_program_class;
gimp->gui_get_display_name_func = gui_get_display_name;
gimp->gui_get_theme_dir_func = gui_get_theme_dir;
}
@ -310,3 +312,9 @@ gui_get_display_name (Gimp *gimp,
return NULL;
}
static const gchar *
gui_get_theme_dir (Gimp *gimp)
{
return themes_get_theme_dir (gimp);
}

View File

@ -86,7 +86,6 @@ themes_init (Gimp *gimp)
else
{
/* get the hardcoded default theme gtkrc */
gtkrc = g_strdup (gimp_gtkrc ());
}
@ -94,7 +93,6 @@ themes_init (Gimp *gimp)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
/* parse the user gtkrc */
@ -105,7 +103,6 @@ themes_init (Gimp *gimp)
g_print (_("Parsing '%s'\n"), gtkrc);
gtk_rc_parse (gtkrc);
g_free (gtkrc);
}

View File

@ -39,6 +39,7 @@ static ProcRecord gimprc_query_proc;
static ProcRecord gimprc_set_proc;
static ProcRecord get_default_comment_proc;
static ProcRecord get_monitor_resolution_proc;
static ProcRecord get_theme_dir_proc;
void
register_gimprc_procs (Gimp *gimp)
@ -47,6 +48,7 @@ register_gimprc_procs (Gimp *gimp)
procedural_db_register (gimp, &gimprc_set_proc);
procedural_db_register (gimp, &get_default_comment_proc);
procedural_db_register (gimp, &get_monitor_resolution_proc);
procedural_db_register (gimp, &get_theme_dir_proc);
}
static Argument *
@ -268,3 +270,47 @@ static ProcRecord get_monitor_resolution_proc =
get_monitor_resolution_outargs,
{ { get_monitor_resolution_invoker } }
};
static Argument *
get_theme_dir_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *theme_dir;
theme_dir = g_strdup (gimp_get_theme_dir (gimp));
success = TRUE;
return_args = procedural_db_return_args (&get_theme_dir_proc, success);
if (success)
return_args[1].value.pdb_pointer = theme_dir;
return return_args;
}
static ProcArg get_theme_dir_outargs[] =
{
{
GIMP_PDB_STRING,
"theme_dir",
"The GUI theme dir"
}
};
static ProcRecord get_theme_dir_proc =
{
"gimp_get_theme_dir",
"Get the directory of the current GUI theme.",
"Returns a copy of the current GUI theme dir.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
0,
NULL,
1,
get_theme_dir_outargs,
{ { get_theme_dir_invoker } }
};

View File

@ -69,7 +69,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,
@ -93,7 +93,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Convert"), 0.123);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.132);
(* status_callback) (NULL, _("Display procedures"), 0.131);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.143);
@ -111,70 +111,70 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Font UI"), 0.266);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.275);
(* status_callback) (NULL, _("Fonts"), 0.274);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.281);
(* status_callback) (NULL, _("Gimprc procedures"), 0.28);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.292);
(* status_callback) (NULL, _("Gradient UI"), 0.294);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.301);
(* status_callback) (NULL, _("Gradients"), 0.303);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.321);
(* status_callback) (NULL, _("Guide procedures"), 0.323);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.338);
(* status_callback) (NULL, _("Help procedures"), 0.34);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.341);
(* status_callback) (NULL, _("Image"), 0.343);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.524);
(* status_callback) (NULL, _("Layer"), 0.526);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.619);
(* status_callback) (NULL, _("Message procedures"), 0.62);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.628);
(* status_callback) (NULL, _("Miscellaneous"), 0.629);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.633);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.634);
register_misc_tools_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.642);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.643);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.685);
(* status_callback) (NULL, _("Palette"), 0.686);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.702);
(* status_callback) (NULL, _("Palette UI"), 0.703);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.711);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.725);
(* status_callback) (NULL, _("Parasite procedures"), 0.726);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.759);
(* status_callback) (NULL, _("Paths"), 0.76);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.802);
(* status_callback) (NULL, _("Pattern UI"), 0.803);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.811);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.825);
(* status_callback) (NULL, _("Plug-in"), 0.826);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.842);
(* status_callback) (NULL, _("Procedural database"), 0.843);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.865);
(* status_callback) (NULL, _("Image mask"), 0.866);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.917);

View File

@ -168,3 +168,31 @@ gimp_get_monitor_resolution (gdouble *xres,
return success;
}
/**
* gimp_get_theme_dir:
*
* Get the directory of the current GUI theme.
*
* Returns a copy of the current GUI theme dir.
*
* Returns: The GUI theme dir.
*/
gchar *
gimp_get_theme_dir (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *theme_dir = NULL;
return_vals = gimp_run_procedure ("gimp_get_theme_dir",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
theme_dir = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return theme_dir;
}

View File

@ -35,6 +35,7 @@ gboolean gimp_gimprc_set (const gchar *token,
gchar* gimp_get_default_comment (void);
gboolean gimp_get_monitor_resolution (gdouble *xres,
gdouble *yres);
gchar* gimp_get_theme_dir (void);
G_END_DECLS

View File

@ -64,7 +64,8 @@ gimp_ui_init (const gchar *prog_name,
const gchar *display_name;
gint argc;
gchar **argv;
gchar *user_gtkrc;
gchar *theme_dir;
gchar *gtkrc;
GdkScreen *screen;
g_return_if_fail (prog_name != NULL);
@ -95,11 +96,26 @@ gimp_ui_init (const gchar *prog_name,
argv[2] = g_strdup_printf ("--class=%s", gimp_wm_class ());
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
user_gtkrc = gimp_personal_rc_file ("gtkrc");
gtk_rc_parse (user_gtkrc);
g_free (user_gtkrc);
theme_dir = gimp_get_theme_dir ();
if (theme_dir)
{
gtkrc = g_build_filename (theme_dir, "gtkrc", NULL);
g_free (theme_dir);
}
else
{
/* get the hardcoded default theme gtkrc */
gtkrc = g_strdup (gimp_gtkrc ());
}
gtk_rc_parse (gtkrc);
g_free (gtkrc);
gtkrc = gimp_personal_rc_file ("gtkrc");
gtk_rc_parse (gtkrc);
g_free (gtkrc);
gdk_rgb_set_min_colors (gimp_min_colors ());
gdk_rgb_set_install (gimp_install_cmap ());

View File

@ -144,7 +144,7 @@ sub get_default_comment {
@outargs = (
{ name => 'comment', type => 'string',
desc => 'Default Image Comment' },
desc => 'Default Image Comment' }
);
%invoke = (
@ -158,10 +158,34 @@ CODE
);
}
sub get_theme_dir {
$blurb = 'Get the directory of the current GUI theme.';
$help = 'Returns a copy of the current GUI theme dir.';
&std_pdb_misc;
@inargs = ( );
@outargs = (
{ name => 'theme_dir', type => 'string',
desc => 'The GUI theme dir' }
);
%invoke = (
code => <<'CODE'
{
theme_dir = g_strdup (gimp_get_theme_dir (gimp));
success = TRUE;
}
CODE
);
}
@headers = qw("core/gimp.h");
@procs = qw(gimprc_query gimprc_set
get_default_comment get_monitor_resolution);
get_default_comment get_monitor_resolution get_theme_dir);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gimprc procedures';