home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpui.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-19  |  2.8 KB  |  85 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19.  
  20. #include "gimp.h"
  21. #include "gimpui.h"
  22.  
  23. /**
  24.  * gimp_ui_init:
  25.  * @prog_name: The name of the plug-in which will be passed as argv[0] to
  26.  *             gtk_init(). It's a convention to use the name of the
  27.  *             executable and _not_ the PDB procedure name or something.
  28.  * @preview: #TRUE if the plug-in has some kind of preview in it's UI.
  29.  *           Note that passing #TRUE is recommended also if one of the
  30.  *           used GIMP Library widgets contains a preview (like the image
  31.  *           menu returned by gimp_image_menu_new()).
  32.  *
  33.  * This function initializes GTK+ with gtk_init(), instructs GDK not to
  34.  * use X shared memory if The GIMP was invoked with the --no-xshm command
  35.  * line option and initializes GDK's image rendering subsystem (GdkRGB) to
  36.  * follow the GIMP main program's colormap allocation/installation policy.
  37.  *
  38.  * The GIMP's colormap policy can be determinded by the user with the
  39.  * gimprc variables @min_colors and @install_cmap.
  40.  **/
  41. void
  42. gimp_ui_init (const gchar *prog_name,
  43.           gboolean     preview)
  44. {
  45.   gint    argc;
  46.   gchar **argv;
  47.   gchar  *user_gtkrc;
  48.  
  49.   static gboolean initialized = FALSE;
  50.  
  51.   g_return_if_fail (prog_name != NULL);
  52.  
  53.   if (initialized)
  54.     return;
  55.  
  56.   argc    = 1;
  57.   argv    = g_new (gchar *, 1);
  58.   argv[0] = g_strdup (prog_name);
  59.  
  60.   gtk_init (&argc, &argv);
  61.   gtk_rc_parse (gimp_gtkrc ());
  62.  
  63.   user_gtkrc = gimp_personal_rc_file ("gtkrc");
  64.   gtk_rc_parse (user_gtkrc);
  65.   g_free (user_gtkrc);
  66.  
  67.   /*  It's only safe to switch Gdk SHM usage off  */
  68.   if (! gimp_use_xshm ())
  69.     gdk_set_use_xshm (FALSE);
  70.  
  71.   gdk_rgb_set_min_colors (gimp_min_colors ());
  72.   gdk_rgb_set_install (gimp_install_cmap ());
  73.  
  74.   gtk_widget_set_default_visual (gdk_rgb_get_visual ());
  75.   gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
  76.  
  77.   /*  Set the gamma after installing the colormap because
  78.    *  gtk_preview_set_gamma() initializes GdkRGB if not already done
  79.    */
  80.   if (preview)
  81.     gtk_preview_set_gamma (gimp_gamma ());
  82.  
  83.   initialized = TRUE;
  84. }
  85.