mirror of https://github.com/GNOME/gimp.git
added Black and White to popup menu. Take widget->allocation into account
2001-11-16 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpcolorbutton.[ch]: added Black and White to popup menu. Take widget->allocation into account when calculation popup position since GtkButton is a NO_WINDOW widget now.
This commit is contained in:
parent
edcccae523
commit
a1439a3cca
|
@ -1,3 +1,9 @@
|
||||||
|
2001-11-16 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpcolorbutton.[ch]: added Black and White to popup
|
||||||
|
menu. Take widget->allocation into account when calculation popup
|
||||||
|
position since GtkButton is a NO_WINDOW widget now.
|
||||||
|
|
||||||
2001-11-16 Sven Neumann <sven@gimp.org>
|
2001-11-16 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/gimpimage.c: s/G_GNUC_PRETTY_FUNC/G_GNUC_PRETTY_FUNCTION/
|
* app/core/gimpimage.c: s/G_GNUC_PRETTY_FUNC/G_GNUC_PRETTY_FUNCTION/
|
||||||
|
|
|
@ -36,6 +36,14 @@
|
||||||
#include "libgimp/libgimp-intl.h"
|
#include "libgimp/libgimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GIMP_COLOR_BUTTON_COLOR_FG,
|
||||||
|
GIMP_COLOR_BUTTON_COLOR_BG,
|
||||||
|
GIMP_COLOR_BUTTON_COLOR_BLACK,
|
||||||
|
GIMP_COLOR_BUTTON_COLOR_WHITE,
|
||||||
|
} GimpColorButtonColor;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COLOR_CHANGED,
|
COLOR_CHANGED,
|
||||||
|
@ -56,13 +64,9 @@ static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
||||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static void gimp_color_button_use_fg (gpointer callback_data,
|
static void gimp_color_button_use_color (gpointer callback_data,
|
||||||
guint callback_action,
|
guint callback_action,
|
||||||
GtkWidget *widget);
|
GtkWidget *widget);
|
||||||
static void gimp_color_button_use_bg (gpointer callback_data,
|
|
||||||
guint callback_action,
|
|
||||||
GtkWidget *widget);
|
|
||||||
|
|
||||||
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
static gint gimp_color_button_menu_popup (GtkWidget *widget,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
@ -75,8 +79,15 @@ static void gimp_color_button_color_changed (GtkObject *object,
|
||||||
|
|
||||||
static GtkItemFactoryEntry menu_items[] =
|
static GtkItemFactoryEntry menu_items[] =
|
||||||
{
|
{
|
||||||
{ N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL },
|
{ N_("/Foreground Color"), NULL,
|
||||||
{ N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL }
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_FG, NULL },
|
||||||
|
{ N_("/Background Color"), NULL,
|
||||||
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_BG, NULL },
|
||||||
|
{ "/---", NULL, NULL, 0, "<Separator>"},
|
||||||
|
{ N_("/Black"), NULL,
|
||||||
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_BLACK, NULL },
|
||||||
|
{ N_("/White"), NULL,
|
||||||
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_WHITE, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
@ -321,7 +332,7 @@ gimp_color_button_menu_popup (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpColorButton *gcb;
|
GimpColorButton *gcb;
|
||||||
GdkEventButton *bevent;
|
GdkEventButton *bevent;
|
||||||
gint x;
|
gint x;
|
||||||
gint y;
|
gint y;
|
||||||
|
|
||||||
|
@ -338,6 +349,9 @@ gimp_color_button_menu_popup (GtkWidget *widget,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
|
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
|
||||||
|
x += widget->allocation.x;
|
||||||
|
y += widget->allocation.y;
|
||||||
|
|
||||||
gtk_item_factory_popup (gcb->item_factory,
|
gtk_item_factory_popup (gcb->item_factory,
|
||||||
x + bevent->x, y + bevent->y,
|
x + bevent->x, y + bevent->y,
|
||||||
bevent->button, bevent->time);
|
bevent->button, bevent->time);
|
||||||
|
@ -423,30 +437,33 @@ gimp_color_button_dialog_cancel (GtkWidget *widget,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_button_use_fg (gpointer callback_data,
|
gimp_color_button_use_color (gpointer callback_data,
|
||||||
guint callback_action,
|
guint callback_action,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
GimpColorButtonColor type;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
type = (GimpColorButtonColor) callback_action;
|
||||||
|
|
||||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||||
gimp_palette_get_foreground (&color);
|
|
||||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
switch (type)
|
||||||
gimp_color_button_use_bg (gpointer callback_data,
|
{
|
||||||
guint callback_action,
|
case GIMP_COLOR_BUTTON_COLOR_FG:
|
||||||
GtkWidget *widget)
|
gimp_palette_get_foreground (&color);
|
||||||
{
|
break;
|
||||||
GimpRGB color;
|
case GIMP_COLOR_BUTTON_COLOR_BG:
|
||||||
|
gimp_palette_get_background (&color);
|
||||||
|
break;
|
||||||
|
case GIMP_COLOR_BUTTON_COLOR_BLACK:
|
||||||
|
gimp_rgb_set (&color, 0.0, 0.0, 0.0);
|
||||||
|
break;
|
||||||
|
case GIMP_COLOR_BUTTON_COLOR_WHITE:
|
||||||
|
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
|
||||||
|
|
||||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
|
||||||
gimp_palette_get_background (&color);
|
|
||||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void gimp_color_button_get_color (GimpColorButton *gcb,
|
||||||
GimpRGB *color);
|
GimpRGB *color);
|
||||||
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
gboolean gimp_color_button_has_alpha (GimpColorButton *gcb);
|
||||||
void gimp_color_button_set_type (GimpColorButton *gcb,
|
void gimp_color_button_set_type (GimpColorButton *gcb,
|
||||||
GimpColorAreaType alpha);
|
GimpColorAreaType type);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue