Commit e34358d8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent 73570b0d
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]
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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 } }
};
......@@ -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);
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
}
......@@ -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
......
......@@ -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);
}
}
......@@ -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 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_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 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 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);
}
static void
gimp_color_button_clicked (GtkButton *button)
/**
* 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)
{
GimpColorButton *color_button;
GtkWidget *dialog;
GimpRGB color;
GdkColor gdk_color;
guint16 alpha;
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));
color_button = GIMP_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);
}
}
}
}
gimp_color_button_get_color (color_button, &color);
static void
gimp_color_button_clicked (GtkButton *button)
{
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
gdk_color.red = TOUINT16 (color.r);
gdk_color.green = TOUINT16 (color.g);
gdk_color.blue = TOUINT16 (color.b);
alpha = TOUINT16 (color.a);
if (! color_button->dialog)
{