added new API gimp_color_button_[get|set]_update() which configures the

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

	* libgimpwidgets/gimpcolorbutton.[ch]: added new API
	gimp_color_button_[get|set]_update() which configures the button
	to emit "color_changed" continuously while the color in the color
	selection dialog is being changed. Fixes bug #90091.

	Renamed GimpColorButton struct member
	"GtkItemFactory *item_factory" to a /*< private >*/ member named
	"gpointer popup_menu". This is ugly but fixes bug #125115,

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell.c
	* app/widgets/gimpcolorpanel.c: changed accordingly.

	* libgimpwidgets/gimpcolorbutton.c: use a GimpColorSelection
	with a handmade GimpDialog instead of GtkColorSelectionDialog.

	Enabled module loading for plug-ins so the color selection
	can show the color selectors which are implemented in modules:

	* libgimpwidgets/gimpwidgets-private.[ch]: added
	GimpEnsureModlesFunc which can be called by modules users.

	* app/gui/gui.c (gui_libs_init): pass NULL as
	GimpEnsureModulesFunc since the core loads the modules itself.

	* libgimp/gimpui.c (gimp_ui_init): pass new private function
	gimp_ensure_modules() which will load the modules upon first
	invocation.

	* libgimp/Makefile.am: link libgimpui against libgimpmodule.

	* libgimpwidgets/gimpcolorselection.c: call
	_gimp_ensure_modules_func() if it is non-NULL so color selector
	modules are available for plug-ins.

	* tools/pdbgen/pdb/gimprc.pdb: added new PDB wrapper
	gimp_get_module_load_inhibit().

	* app/pdb/gimprc_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpgimprc_pdb.[ch]: regenerated.
This commit is contained in:
Michael Natterer 2003-11-11 17:55:45 +00:00 committed by Michael Natterer
parent 73570b0d35
commit e34358d8c3
19 changed files with 523 additions and 188 deletions

View File

@ -1,3 +1,47 @@
2003-11-11 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcolorbutton.[ch]: added new API
gimp_color_button_[get|set]_update() which configures the button
to emit "color_changed" continuously while the color in the color
selection dialog is being changed. Fixes bug #90091.
Renamed GimpColorButton struct member
"GtkItemFactory *item_factory" to a /*< private >*/ member named
"gpointer popup_menu". This is ugly but fixes bug #125115,
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell.c
* app/widgets/gimpcolorpanel.c: changed accordingly.
* libgimpwidgets/gimpcolorbutton.c: use a GimpColorSelection
with a handmade GimpDialog instead of GtkColorSelectionDialog.
Enabled module loading for plug-ins so the color selection
can show the color selectors which are implemented in modules:
* libgimpwidgets/gimpwidgets-private.[ch]: added
GimpEnsureModlesFunc which can be called by modules users.
* app/gui/gui.c (gui_libs_init): pass NULL as
GimpEnsureModulesFunc since the core loads the modules itself.
* libgimp/gimpui.c (gimp_ui_init): pass new private function
gimp_ensure_modules() which will load the modules upon first
invocation.
* libgimp/Makefile.am: link libgimpui against libgimpmodule.
* libgimpwidgets/gimpcolorselection.c: call
_gimp_ensure_modules_func() if it is non-NULL so color selector
modules are available for plug-ins.
* tools/pdbgen/pdb/gimprc.pdb: added new PDB wrapper
gimp_get_module_load_inhibit().
* app/pdb/gimprc_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpgimprc_pdb.[ch]: regenerated.
2003-11-11 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpstock.[ch]

View File

@ -1373,17 +1373,19 @@ gimp_display_shell_color_button_press (GtkWidget *widget,
if (bevent->button == 3)
{
GimpColorButton *color_button;
GtkItemFactory *item_factory;
guchar r, g, b;
GimpRGB color;
color_button = GIMP_COLOR_BUTTON (widget);
item_factory = GTK_ITEM_FACTORY (color_button->popup_menu);
r = shell->canvas->style->bg[GTK_STATE_NORMAL].red >> 8;
g = shell->canvas->style->bg[GTK_STATE_NORMAL].green >> 8;
b = shell->canvas->style->bg[GTK_STATE_NORMAL].blue >> 8;
gimp_rgba_set_uchar (&color, r, g, b, 255);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/From Theme", &color, FALSE);
gimp_rgba_set_uchar (&color,
@ -1391,7 +1393,7 @@ gimp_display_shell_color_button_press (GtkWidget *widget,
render_blend_light_check[1],
render_blend_light_check[2],
255);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/Light Check Color", &color, FALSE);
gimp_rgba_set_uchar (&color,
@ -1399,7 +1401,7 @@ gimp_display_shell_color_button_press (GtkWidget *widget,
render_blend_dark_check[1],
render_blend_dark_check[2],
255);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/Dark Check Color", &color, FALSE);
}

View File

@ -819,9 +819,13 @@ gimp_display_shell_new (GimpDisplay *gdisp,
GIMP_STOCK_RESET }
};
gtk_item_factory_create_items (GIMP_COLOR_BUTTON (shell->padding_button)->item_factory,
G_N_ELEMENTS (menu_items),
menu_items,
GtkItemFactory *item_factory;
item_factory =
GTK_ITEM_FACTORY (GIMP_COLOR_BUTTON (shell->padding_button)->popup_menu);
gtk_item_factory_create_items (item_factory,
G_N_ELEMENTS (menu_items), menu_items,
shell);
}

View File

@ -819,9 +819,13 @@ gimp_display_shell_new (GimpDisplay *gdisp,
GIMP_STOCK_RESET }
};
gtk_item_factory_create_items (GIMP_COLOR_BUTTON (shell->padding_button)->item_factory,
G_N_ELEMENTS (menu_items),
menu_items,
GtkItemFactory *item_factory;
item_factory =
GTK_ITEM_FACTORY (GIMP_COLOR_BUTTON (shell->padding_button)->popup_menu);
gtk_item_factory_create_items (item_factory,
G_N_ELEMENTS (menu_items), menu_items,
shell);
}

View File

@ -143,7 +143,8 @@ gui_libs_init (gint *argc,
gimp_widgets_init (&vtable,
gui_help_func,
gui_get_foreground_func,
gui_get_background_func);
gui_get_background_func,
NULL);
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);

View File

@ -35,11 +35,14 @@
#include "core/gimp.h"
#include "core/gimptemplate.h"
#include "libgimpmodule/gimpmodule.h"
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;
static ProcRecord get_module_load_inhibit_proc;
void
register_gimprc_procs (Gimp *gimp)
@ -49,6 +52,7 @@ register_gimprc_procs (Gimp *gimp)
procedural_db_register (gimp, &get_default_comment_proc);
procedural_db_register (gimp, &get_monitor_resolution_proc);
procedural_db_register (gimp, &get_theme_dir_proc);
procedural_db_register (gimp, &get_module_load_inhibit_proc);
}
static Argument *
@ -314,3 +318,47 @@ static ProcRecord get_theme_dir_proc =
get_theme_dir_outargs,
{ { get_theme_dir_invoker } }
};
static Argument *
get_module_load_inhibit_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *load_inhibit;
load_inhibit = g_strdup (gimp_module_db_get_load_inhibit (gimp->module_db));
success = TRUE;
return_args = procedural_db_return_args (&get_module_load_inhibit_proc, success);
if (success)
return_args[1].value.pdb_pointer = load_inhibit;
return return_args;
}
static ProcArg get_module_load_inhibit_outargs[] =
{
{
GIMP_PDB_STRING,
"load_inhibit",
"The list of modules"
}
};
static ProcRecord get_module_load_inhibit_proc =
{
"gimp_get_module_load_inhibit",
"Get the list of modules which should not be loaded.",
"Returns a copy of the list of modules which should not be loaded.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
0,
NULL,
1,
get_module_load_inhibit_outargs,
{ { get_module_load_inhibit_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);
/* 350 procedures registered total */
/* 351 procedures registered total */
void
internal_procs_init (Gimp *gimp,
@ -87,7 +87,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Channel"), 0.04);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.086);
(* status_callback) (NULL, _("Color"), 0.085);
register_color_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.123);
@ -96,76 +96,76 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Display procedures"), 0.131);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.143);
(* status_callback) (NULL, _("Drawable procedures"), 0.142);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.209);
(* status_callback) (NULL, _("Edit procedures"), 0.208);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.226);
(* status_callback) (NULL, _("File Operations"), 0.225);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.249);
(* status_callback) (NULL, _("Floating selections"), 0.248);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.266);
(* status_callback) (NULL, _("Font UI"), 0.265);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.274);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.28);
(* status_callback) (NULL, _("Gimprc procedures"), 0.279);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.294);
(* status_callback) (NULL, _("Gradient UI"), 0.296);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.303);
(* status_callback) (NULL, _("Gradients"), 0.305);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.323);
(* status_callback) (NULL, _("Guide procedures"), 0.325);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.34);
(* status_callback) (NULL, _("Help procedures"), 0.342);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.343);
(* status_callback) (NULL, _("Image"), 0.345);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.526);
(* status_callback) (NULL, _("Layer"), 0.527);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.62);
(* status_callback) (NULL, _("Message procedures"), 0.621);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.629);
(* status_callback) (NULL, _("Miscellaneous"), 0.63);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.634);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.635);
register_misc_tools_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.643);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.644);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.686);
(* status_callback) (NULL, _("Palette"), 0.687);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.703);
(* status_callback) (NULL, _("Palette UI"), 0.704);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.711);
(* status_callback) (NULL, _("Palettes"), 0.712);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.726);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.76);
(* status_callback) (NULL, _("Paths"), 0.761);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.803);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.811);
(* status_callback) (NULL, _("Patterns"), 0.812);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.826);
@ -180,7 +180,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Selection Tool procedures"), 0.917);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.931);
(* status_callback) (NULL, _("Text procedures"), 0.932);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.943);

View File

@ -153,18 +153,20 @@ gimp_color_panel_button_press (GtkWidget *widget,
{
GimpColorButton *color_button;
GimpColorPanel *color_panel;
GtkItemFactory *item_factory;
GimpRGB black, white;
color_button = GIMP_COLOR_BUTTON (widget);
color_panel = GIMP_COLOR_PANEL (widget);
item_factory = GTK_ITEM_FACTORY (color_button->popup_menu);
gimp_item_factory_set_visible (color_button->item_factory,
gimp_item_factory_set_visible (item_factory,
"/Foreground Color",
color_panel->context != NULL);
gimp_item_factory_set_visible (color_button->item_factory,
gimp_item_factory_set_visible (item_factory,
"/Background Color",
color_panel->context != NULL);
gimp_item_factory_set_visible (color_button->item_factory,
gimp_item_factory_set_visible (item_factory,
"/fg-bg-separator",
color_panel->context != NULL);
@ -175,18 +177,18 @@ gimp_color_panel_button_press (GtkWidget *widget,
gimp_context_get_foreground (color_panel->context, &fg);
gimp_context_get_background (color_panel->context, &bg);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/Foreground Color", &fg, FALSE);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/Background Color", &bg, FALSE);
}
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_rgba_set (&white, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/Black", &black, FALSE);
gimp_item_factory_set_color (color_button->item_factory,
gimp_item_factory_set_color (item_factory,
"/White", &white, FALSE);
}

View File

@ -2,6 +2,7 @@
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la
libgimpmodule = $(top_builddir)/libgimpmodule/libgimpmodule-$(LT_RELEASE).la
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la
libgimp = ./libgimp-$(LT_RELEASE).la
@ -254,7 +255,7 @@ libgimpui_1_3_la_LDFLAGS = \
$(libgimpui_export_symbols)
libgimpui_1_3_la_LIBADD = $(libgimp) $(libgimpwidgets) $(libgimpcolor) \
$(libgimpbase) $(GTK_LIBS)
$(libgimpbase) $(libgimpmodule) $(GTK_LIBS)
libgimpui_1_3_la_DEPENDENCIES = $(gimpui_def) $(libgimp)

View File

@ -369,7 +369,7 @@ confirm_save_dialog (const gchar *message,
gtk_widget_show (dialog);
switch (gtk_dialog_run (GTK_DIALOG (dialog)))
switch (gimp_dialog_run (GTK_DIALOG (dialog)))
{
case GTK_RESPONSE_OK:
retval = GIMP_EXPORT_EXPORT;
@ -523,7 +523,7 @@ export_dialog (GSList *actions,
gtk_widget_show (dialog);
switch (gtk_dialog_run (GTK_DIALOG (dialog)))
switch (gimp_dialog_run (GTK_DIALOG (dialog)))
{
case GTK_RESPONSE_OK:
retval = GIMP_EXPORT_EXPORT;

View File

@ -196,3 +196,31 @@ gimp_get_theme_dir (void)
return theme_dir;
}
/**
* gimp_get_module_load_inhibit:
*
* Get the list of modules which should not be loaded.
*
* Returns a copy of the list of modules which should not be loaded.
*
* Returns: The list of modules.
*/
gchar *
gimp_get_module_load_inhibit (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *load_inhibit = NULL;
return_vals = gimp_run_procedure ("gimp_get_module_load_inhibit",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
load_inhibit = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return load_inhibit;
}

View File

@ -29,13 +29,14 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gchar* gimp_gimprc_query (const gchar *token);
gboolean gimp_gimprc_set (const gchar *token,
const gchar *value);
gchar* gimp_get_default_comment (void);
gboolean gimp_get_monitor_resolution (gdouble *xres,
gdouble *yres);
gchar* gimp_get_theme_dir (void);
gchar* gimp_gimprc_query (const gchar *token);
gboolean gimp_gimprc_set (const gchar *token,
const gchar *value);
gchar* gimp_get_default_comment (void);
gboolean gimp_get_monitor_resolution (gdouble *xres,
gdouble *yres);
gchar* gimp_get_theme_dir (void);
gchar* gimp_get_module_load_inhibit (void);
G_END_DECLS

View File

@ -21,6 +21,10 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpmodule/gimpmodule.h"
#include "gimp.h"
#include "gimpui.h"
@ -30,8 +34,9 @@
/* local function prototypes */
static void gimp_ui_help_func (const gchar *help_id,
gpointer help_data);
static void gimp_ui_help_func (const gchar *help_id,
gpointer help_data);
static void gimp_ensure_modules (void);
/* public functions */
@ -143,7 +148,8 @@ gimp_ui_init (const gchar *prog_name,
gimp_widgets_init (&vtable,
gimp_ui_help_func,
gimp_palette_get_foreground,
gimp_palette_get_background);
gimp_palette_get_background,
gimp_ensure_modules);
if (! gimp_show_tool_tips ())
gimp_help_disable_tooltips ();
@ -160,3 +166,25 @@ gimp_ui_help_func (const gchar *help_id,
{
gimp_help (gimp_get_progname (), help_id);
}
static void
gimp_ensure_modules (void)
{
static GimpModuleDB *module_db = NULL;
if (! module_db)
{
gchar *load_inhibit;
gchar *module_path;
load_inhibit = gimp_get_module_load_inhibit ();
module_path = gimp_gimprc_query ("module-path");
module_db = gimp_module_db_new (FALSE);
gimp_module_db_set_load_inhibit (module_db, load_inhibit);
gimp_module_db_load (module_db, module_path);
g_free (load_inhibit);
g_free (module_path);
}
}

View File

@ -30,11 +30,19 @@
#include "gimpcolorarea.h"
#include "gimpcolorbutton.h"
#include "gimpcolornotebook.h"
#include "gimpcolorselection.h"
#include "gimpdialog.h"
#include "gimphelpui.h"
#include "gimpstock.h"
#include "gimpwidgets-private.h"
#include "libgimp/libgimp-intl.h"
#define COLOR_SELECTION_KEY "gimp-color-selection"
#define RESPONSE_RESET 1
#define TODOUBLE(i) (i / 65535.0)
#define TOUINT16(d) ((guint16) (d * 65535 + 0.5))
@ -54,29 +62,30 @@ enum
};
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
static void gimp_color_button_init (GimpColorButton *button);
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
static void gimp_color_button_init (GimpColorButton *button);
static gboolean gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType prev_state);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_use_color (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static void gimp_color_button_color_changed (GtkObject *object,
gpointer data);
static gboolean gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType prev_state);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_dialog_response (GtkWidget *dialog,
gint response_id,
GimpColorButton *button);
static void gimp_color_button_use_color (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static void gimp_color_button_area_changed (GtkWidget *color_area,
GimpColorButton *button);
static void gimp_color_button_selection_changed (GtkWidget *selection,
GimpColorButton *button);
static void gimp_color_button_help_func (const gchar *help_id,
gpointer help_data);
static GtkItemFactoryEntry menu_items[] =
@ -118,8 +127,8 @@ gimp_color_button_get_type (void)
};
button_type = g_type_register_static (GIMP_TYPE_BUTTON,
"GimpColorButton",
&button_info, 0);
"GimpColorButton",
&button_info, 0);
}
return button_type;
@ -162,24 +171,25 @@ gimp_color_button_init (GimpColorButton *button)
{
GimpRGB color;
button->title = NULL;
button->dialog = NULL;
button->continuous_update = FALSE;
button->title = NULL;
button->dialog = NULL;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
g_signal_connect (button->color_area, "color_changed",
G_CALLBACK (gimp_color_button_color_changed),
G_CALLBACK (gimp_color_button_area_changed),
button);
gtk_container_add (GTK_CONTAINER (button), button->color_area);
gtk_widget_show (button->color_area);
/* right-click opens a popup */
button->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (button->item_factory,
button->popup_menu = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (button->popup_menu,
gimp_color_button_menu_translate,
NULL, NULL);
gtk_item_factory_create_items (button->item_factory,
gtk_item_factory_create_items (button->popup_menu,
G_N_ELEMENTS (menu_items), menu_items, button);
}
@ -227,10 +237,10 @@ gimp_color_button_button_press (GtkWidget *widget,
x += widget->allocation.x;
y += widget->allocation.y;
gtk_menu_set_screen (GTK_MENU (button->item_factory->widget),
gtk_menu_set_screen (GTK_MENU (GTK_ITEM_FACTORY (button->popup_menu)->widget),
gtk_widget_get_screen (widget));
gtk_item_factory_popup (button->item_factory,
gtk_item_factory_popup (button->popup_menu,
x + bevent->x, y + bevent->y,
bevent->button, bevent->time);
}
@ -362,95 +372,155 @@ gimp_color_button_set_type (GimpColorButton *button,
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
}
/**
* gimp_color_button_get_update:
* @button: A #GimpColorButton widget.
*
* Returns the color button's @continuous_update property.
*
* Return value: the @continuous_update property.
**/
gboolean
gimp_color_button_get_update (GimpColorButton *button)
{
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), FALSE);
return button->continuous_update;
}
/**
* gimp_color_button_set_update:
* @button: A #GimpColorButton widget.
* @continuous: The new setting of the @continuous_update property.
*
* When set to #TRUE, the @button will emit the "color_changed"
* continuously while the color is changed in the color selection
* dialog.
**/
void
gimp_color_button_set_update (GimpColorButton *button,
gboolean continuous)
{
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
if (continuous != button->continuous_update)
{
button->continuous_update = continuous ? TRUE : FALSE;
if (button->dialog)
{
GimpColorSelection *selection;
GimpRGB color;
selection = g_object_get_data (G_OBJECT (button->dialog),
COLOR_SELECTION_KEY);
if (button->continuous_update)
{
gimp_color_selection_get_color (selection, &color);
gimp_color_button_set_color (button, &color);
}
else
{
gimp_color_selection_get_old_color (selection, &color);
gimp_color_button_set_color (button, &color);
}
}
}
}
static void
gimp_color_button_clicked (GtkButton *button)
{
GimpColorButton *color_button;
GtkWidget *dialog;
GimpRGB color;
GdkColor gdk_color;
guint16 alpha;
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
color_button = GIMP_COLOR_BUTTON (button);
gimp_color_button_get_color (color_button, &color);
gdk_color.red = TOUINT16 (color.r);
gdk_color.green = TOUINT16 (color.g);
gdk_color.blue = TOUINT16 (color.b);
alpha = TOUINT16 (color.a);
dialog = color_button->dialog;
if (!dialog)
if (! color_button->dialog)
{
dialog = gtk_color_selection_dialog_new (color_button->title);
GtkWidget *dialog;
GtkWidget *selection;
GimpRGB color;
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), gimp_color_button_has_alpha (color_button));
gimp_color_button_get_color (color_button, &color);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (dialog)->help_button);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 2);
dialog = color_button->dialog =
gimp_dialog_new (color_button->title, COLOR_SELECTION_KEY,
GTK_WIDGET (button), 0,
gimp_color_button_help_func, NULL,
GIMP_STOCK_RESET, RESPONSE_RESET,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (gimp_color_button_dialog_response),
color_button);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&color_button->dialog);
g_signal_connect (GTK_COLOR_SELECTION_DIALOG (dialog)->ok_button,
"clicked",
G_CALLBACK (gimp_color_button_dialog_ok),
color_button);
g_signal_connect (GTK_COLOR_SELECTION_DIALOG (dialog)->cancel_button,
"clicked",
G_CALLBACK (gimp_color_button_dialog_cancel),
color_button);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
color_button->dialog = dialog;
selection = gimp_color_selection_new ();
gtk_container_set_border_width (GTK_CONTAINER (selection), 6);
gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (selection),
gimp_color_button_has_alpha (color_button));
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (selection), &color);
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (selection),
&color);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), selection);
gtk_widget_show (selection);
g_signal_connect (selection, "color_changed",
G_CALLBACK (gimp_color_button_selection_changed),
button);
g_object_set_data (G_OBJECT (color_button->dialog), COLOR_SELECTION_KEY,
selection);
}
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), &gdk_color);
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), alpha);
gtk_widget_show (dialog);
gtk_window_present (GTK_WINDOW (color_button->dialog));
}
static void
gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data)
gimp_color_button_dialog_response (GtkWidget *dialog,
gint response_id,
GimpColorButton *button)
{
GimpColorButton *button;
GimpRGB color;
GdkColor gdk_color;
guint16 alpha;
GtkWidget *selection;
GimpRGB color;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
selection = g_object_get_data (G_OBJECT (dialog), COLOR_SELECTION_KEY);
button = GIMP_COLOR_BUTTON (data);
switch (response_id)
{
case RESPONSE_RESET:
gimp_color_selection_reset (GIMP_COLOR_SELECTION (selection));
break;
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
alpha = gtk_color_selection_get_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel));
case GTK_RESPONSE_OK:
if (! button->continuous_update)
{
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection),
&color);
gimp_color_button_set_color (button, &color);
}
color.r = TODOUBLE (gdk_color.red);
color.g = TODOUBLE (gdk_color.green);
color.b = TODOUBLE (gdk_color.blue);
color.a = TODOUBLE (alpha);
gtk_widget_hide (dialog);
break;
gimp_color_button_set_color (button, &color);
default:
if (button->continuous_update)
{
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (selection),
&color);
gimp_color_button_set_color (button, &color);
}
gtk_widget_hide (button->dialog);
gtk_widget_hide (dialog);
break;
}
}
static void
gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data)
{
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
gtk_widget_hide (GIMP_COLOR_BUTTON (data)->dialog);
}
static void
gimp_color_button_use_color (gpointer callback_data,
guint callback_action,
@ -468,16 +538,23 @@ gimp_color_button_use_color (gpointer callback_data,
case GIMP_COLOR_BUTTON_COLOR_FG:
if (_gimp_get_foreground_func)
_gimp_get_foreground_func (&color);
else
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
break;
case GIMP_COLOR_BUTTON_COLOR_BG:
if (_gimp_get_background_func)
_gimp_get_background_func (&color);
else
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
break;
case GIMP_COLOR_BUTTON_COLOR_BLACK:
gimp_rgb_set (&color, 0.0, 0.0, 0.0);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
break;
case GIMP_COLOR_BUTTON_COLOR_WHITE:
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
break;
}
@ -485,34 +562,76 @@ gimp_color_button_use_color (gpointer callback_data,
}
static void
gimp_color_button_color_changed (GtkObject *object,
gpointer data)
gimp_color_button_area_changed (GtkWidget *color_area,
GimpColorButton *button)
{
GimpColorButton *button = GIMP_COLOR_BUTTON (data);
if (button->dialog)
{
GimpRGB color;
GdkColor gdk_color;
guint16 alpha;
GimpColorSelection *selection;
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
selection = g_object_get_data (G_OBJECT (button->dialog),
COLOR_SELECTION_KEY);
gdk_color.red = TOUINT16 (color.r);
gdk_color.green = TOUINT16 (color.g);
gdk_color.blue = TOUINT16 (color.b);
alpha = TOUINT16 (color.a);
gimp_color_button_get_color (button, &color);
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), alpha);
g_signal_handlers_block_by_func (selection,
gimp_color_button_selection_changed,
button);
gimp_color_selection_set_color (selection, &color);
g_signal_handlers_unblock_by_func (selection,
gimp_color_button_selection_changed,
button);
}
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);
}
static void
gimp_color_button_selection_changed (GtkWidget *selection,
GimpColorButton *button)
{
if (button->continuous_update)
{
GimpRGB color;
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection), &color);
g_signal_handlers_block_by_func (button->color_area,
gimp_color_button_area_changed,
button);
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), &color);
g_signal_handlers_unblock_by_func (button->color_area,
gimp_color_button_area_changed,
button);
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);
}
}
static gchar *
gimp_color_button_menu_translate (const gchar *path,
gpointer func_data)
{
return (gettext (path));
}
static void
gimp_color_button_help_func (const gchar *help_id,
gpointer help_data)
{
GimpColorSelection *selection;
GimpColorNotebook *notebook;
selection = g_object_get_data (G_OBJECT (help_data), COLOR_SELECTION_KEY);
notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
help_id = GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->help_page;
gimp_standard_help_func (help_id, NULL);
}

View File

@ -1,4 +1,4 @@
/* LIBGIMP - The GIMP Library
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcolorbutton.h
@ -8,10 +8,10 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
@ -49,10 +49,13 @@ struct _GimpColorButton
GimpButton parent_instance;
gchar *title;
gboolean continuous_update;
GtkWidget *color_area;
GtkWidget *dialog;
GtkItemFactory *item_factory;
/*< private >*/
gpointer popup_menu;
};
struct _GimpColorButtonClass
@ -75,10 +78,15 @@ void gimp_color_button_set_color (GimpColorButton *button,
const GimpRGB *color);
void gimp_color_button_get_color (GimpColorButton *button,
GimpRGB *color);
gboolean gimp_color_button_has_alpha (GimpColorButton *button);
void gimp_color_button_set_type (GimpColorButton *button,
GimpColorAreaType type);
gboolean gimp_color_button_get_update (GimpColorButton *button);
void gimp_color_button_set_update (GimpColorButton *button,
gboolean continuous);
G_END_DECLS

View File

@ -30,10 +30,13 @@
#include "gimpcolorarea.h"
#include "gimpcolornotebook.h"
#include "gimpcolorscales.h"
#include "gimpcolorselect.h"
#include "gimpcolorselection.h"
#include "gimphelpui.h"
#include "gimpstock.h"
#include "gimpwidgets.h"
#include "gimpwidgets-private.h"
#include "gimpwidgetsmarshal.h"
#include "libgimp/libgimp-intl.h"
@ -155,10 +158,20 @@ gimp_color_selection_init (GimpColorSelection *selection)
TRUE, TRUE, 0);
gtk_widget_show (selection->left_vbox);
if (_gimp_ensure_modules_func)
{
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
_gimp_ensure_modules_func ();
}
selection->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
&selection->rgb,
&selection->hsv,
selection->channel);
if (_gimp_ensure_modules_func)
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
gimp_color_selector_set_toggles_visible
(GIMP_COLOR_SELECTOR (selection->notebook), FALSE);
gtk_box_pack_start (GTK_BOX (selection->left_vbox), selection->notebook,

View File

@ -35,17 +35,19 @@
#include "themes/Default/images/gimp-wilber-pixbufs.h"
GimpWidgetsVTable _gimp_eek = { NULL, };
GimpHelpFunc _gimp_standard_help_func = NULL;
GimpGetColorFunc _gimp_get_foreground_func = NULL;
GimpGetColorFunc _gimp_get_background_func = NULL;
GimpWidgetsVTable _gimp_eek = { NULL, };
GimpHelpFunc _gimp_standard_help_func = NULL;
GimpGetColorFunc _gimp_get_foreground_func = NULL;
GimpGetColorFunc _gimp_get_background_func = NULL;
GimpEnsureModulesFunc _gimp_ensure_modules_func = NULL;
void
gimp_widgets_init (GimpWidgetsVTable *vtable,
GimpHelpFunc standard_help_func,
GimpGetColorFunc get_foreground_func,
GimpGetColorFunc get_background_func)
gimp_widgets_init (GimpWidgetsVTable *vtable,
GimpHelpFunc standard_help_func,
GimpGetColorFunc get_foreground_func,
GimpGetColorFunc get_background_func,
GimpEnsureModulesFunc ensure_modules_func)
{
static gboolean gimp_widgets_initialized = FALSE;
@ -71,6 +73,7 @@ gimp_widgets_init (GimpWidgetsVTable *vtable,
_gimp_standard_help_func = standard_help_func;
_gimp_get_foreground_func = get_foreground_func;
_gimp_get_background_func = get_background_func;
_gimp_ensure_modules_func = ensure_modules_func;
gimp_stock_init ();

View File

@ -24,7 +24,8 @@
#define __GIMP_WIDGETS_PRIVATE_H__
typedef gboolean (* GimpGetColorFunc) (GimpRGB *color);
typedef gboolean (* GimpGetColorFunc) (GimpRGB *color);
typedef void (* GimpEnsureModulesFunc) (void);
typedef struct _GimpWidgetsVTable GimpWidgetsVTable;
@ -48,19 +49,21 @@ struct _GimpWidgetsVTable
};
extern GimpWidgetsVTable _gimp_eek;
extern GimpHelpFunc _gimp_standard_help_func;
extern GimpGetColorFunc _gimp_get_foreground_func;
extern GimpGetColorFunc _gimp_get_background_func;
extern GimpWidgetsVTable _gimp_eek;
extern GimpHelpFunc _gimp_standard_help_func;
extern GimpGetColorFunc _gimp_get_foreground_func;
extern GimpGetColorFunc _gimp_get_background_func;
extern GimpEnsureModulesFunc _gimp_ensure_modules_func;
G_BEGIN_DECLS
void gimp_widgets_init (GimpWidgetsVTable *vtable,
GimpHelpFunc standard_help_func,
GimpGetColorFunc get_foreground_func,
GimpGetColorFunc get_background_func);
void gimp_widgets_init (GimpWidgetsVTable *vtable,
GimpHelpFunc standard_help_func,
GimpGetColorFunc get_foreground_func,
GimpGetColorFunc get_background_func,
GimpEnsureModulesFunc ensure_modules_func);
G_END_DECLS

View File

@ -182,10 +182,36 @@ CODE
);
}
sub get_module_load_inhibit {
$blurb = 'Get the list of modules which should not be loaded.';
$help = 'Returns a copy of the list of modules which should not be loaded.';
&std_pdb_misc;
@inargs = ( );
@outargs = (
{ name => 'load_inhibit', type => 'string',
desc => 'The list of modules' }
);
%invoke = (
headers => [ qw("libgimpmodule/gimpmodule.h") ],
code => <<'CODE'
{
load_inhibit = g_strdup (gimp_module_db_get_load_inhibit (gimp->module_db));
success = TRUE;
}
CODE
);
}
@headers = qw("core/gimp.h");
@procs = qw(gimprc_query gimprc_set
get_default_comment get_monitor_resolution get_theme_dir);
get_default_comment get_monitor_resolution get_theme_dir
get_module_load_inhibit);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gimprc procedures';