Commit ae06cd2d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

libgimpwidgets/gimpbutton.c libgimpwidgets/gimpcolorarea.c

2001-11-28  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpbutton.c
	* libgimpwidgets/gimpcolorarea.c
	* libgimpwidgets/gimpcolorbutton.c
	* libgimpwidgets/gimpoffsetarea.c: fixed button_press event handling,
	removed double g_return_if_fail()s, misc. cleanup.

	* app/display/gimpdisplayshell.c: removed the SET_COLOR() stuff
	here...

	* app/gui/menus.c: ...and added it here so it actually works.

	* app/widgets/gimpcolorpanel.c: add color previews to the
	item_factory.

	* app/widgets/gimpdockbook.c: use the item_factory functions now
	that they are in widgets/.

	* app/widgets/gimpitemfactory.[ch]: nothing, we just want to keep
	the RCS hirtory.
parent 79337647
2001-11-28 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpbutton.c
* libgimpwidgets/gimpcolorarea.c
* libgimpwidgets/gimpcolorbutton.c
* libgimpwidgets/gimpoffsetarea.c: fixed button_press event handling,
removed double g_return_if_fail()s, misc. cleanup.
* app/display/gimpdisplayshell.c: removed the SET_COLOR() stuff
here...
* app/gui/menus.c: ...and added it here so it actually works.
* app/widgets/gimpcolorpanel.c: add color previews to the
item_factory.
* app/widgets/gimpdockbook.c: use the item_factory functions now
that they are in widgets/.
* app/widgets/gimpitemfactory.[ch]: nothing, we just want to keep
the RCS hirtory.
2001-11-27 Daniel Egger <degger@fhm.edu>
* app/paint-funcs/paint-funcs-generic.h
......
......@@ -962,8 +962,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_ACTIVE(menu,condition) \
gimp_menu_item_set_active ("<Image>/" menu, (condition) != 0)
#define SET_COLOR(menu,color) \
gimp_menu_item_set_color ("<Image>/" menu, (color), FALSE)
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Image>/" menu, (condition) != 0)
......@@ -1000,9 +998,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Edit/Fill with FG Color", lp);
SET_SENSITIVE ("Edit/Fill with BG Color", lp);
SET_SENSITIVE ("Edit/Stroke", lp);
SET_COLOR ("Edit/Fill with FG Color", &fg);
SET_COLOR ("Edit/Fill with BG Color", &bg);
}
SET_SENSITIVE ("Select", gdisp && lp);
......@@ -1088,7 +1083,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_ACTIVE
#undef SET_COLOR
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);
......
......@@ -962,8 +962,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_ACTIVE(menu,condition) \
gimp_menu_item_set_active ("<Image>/" menu, (condition) != 0)
#define SET_COLOR(menu,color) \
gimp_menu_item_set_color ("<Image>/" menu, (color), FALSE)
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Image>/" menu, (condition) != 0)
......@@ -1000,9 +998,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Edit/Fill with FG Color", lp);
SET_SENSITIVE ("Edit/Fill with BG Color", lp);
SET_SENSITIVE ("Edit/Stroke", lp);
SET_COLOR ("Edit/Fill with FG Color", &fg);
SET_COLOR ("Edit/Fill with BG Color", &bg);
}
SET_SENSITIVE ("Select", gdisp && lp);
......@@ -1088,7 +1083,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_ACTIVE
#undef SET_COLOR
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);
......
......@@ -30,6 +30,7 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
......@@ -79,19 +80,21 @@ static void menus_tools_create (GimpToolInfo *tool_info)
static void menus_last_opened_update_labels (GimpContainer *container,
GimpImagefile *unused,
Gimp *gimp);
static void menus_color_changed (GimpContext *context,
const GimpRGB *unused,
Gimp *gimp);
#ifdef ENABLE_DEBUG_ENTRY
static void menus_debug_recurse_menu (GtkWidget *menu,
gint depth,
gchar *path);
static void menus_debug_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
static void menus_debug_recurse_menu (GtkWidget *menu,
gint depth,
gchar *path);
static void menus_debug_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
#endif /* ENABLE_DEBUG_ENTRY */
#define SEPARATOR(path) \
{ { (path), NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
#define BRANCH(path) \
{ { (path), NULL, NULL, 0, "<Branch>" }, NULL, NULL, NULL }
......@@ -280,14 +283,12 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Mem Profile"), NULL,
mem_profile_cmd_callback, 0 },
NULL,
NULL, NULL },
NULL, NULL, NULL }
#ifdef ENABLE_DEBUG_ENTRY
{ { "/Help/Dump Items (Debug)", NULL,
menus_debug_cmd_callback, 0 },
NULL,
NULL, NULL }
, { { "/Help/Dump Items (Debug)", NULL,
menus_debug_cmd_callback, 0 },
NULL, NULL, NULL }
#endif
};
......@@ -297,8 +298,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
static GimpItemFactoryEntry image_entries[] =
{
{ { "/tearoff1", NULL, gimp_item_factory_tearoff_callback, 0, "<Tearoff>" },
NULL,
NULL, NULL },
NULL, NULL, NULL },
/* <Image>/File */
......@@ -1989,6 +1989,17 @@ menus_init (Gimp *gimp)
gimp);
menus_last_opened_update_labels (gimp->documents, NULL, gimp);
g_signal_connect (G_OBJECT (gimp_get_user_context (gimp)),
"foreground_changed",
G_CALLBACK (menus_color_changed),
gimp);
g_signal_connect (G_OBJECT (gimp_get_user_context (gimp)),
"background_changed",
G_CALLBACK (menus_color_changed),
gimp);
menus_color_changed (gimp_get_user_context (gimp), NULL, gimp);
}
void
......@@ -2418,6 +2429,21 @@ menus_last_opened_update_labels (GimpContainer *container,
}
}
static void
menus_color_changed (GimpContext *context,
const GimpRGB *unused,
Gimp *gimp)
{
GimpRGB fg;
GimpRGB bg;
gimp_context_get_foreground (context, &fg);
gimp_context_get_background (context, &bg);
gimp_menu_item_set_color ("<Image>/Edit/Fill with FG Color", &fg, FALSE);
gimp_menu_item_set_color ("<Image>/Edit/Fill with BG Color", &bg, FALSE);
}
#ifdef ENABLE_DEBUG_ENTRY
......
......@@ -30,6 +30,7 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
......@@ -79,19 +80,21 @@ static void menus_tools_create (GimpToolInfo *tool_info)
static void menus_last_opened_update_labels (GimpContainer *container,
GimpImagefile *unused,
Gimp *gimp);
static void menus_color_changed (GimpContext *context,
const GimpRGB *unused,
Gimp *gimp);
#ifdef ENABLE_DEBUG_ENTRY
static void menus_debug_recurse_menu (GtkWidget *menu,
gint depth,
gchar *path);
static void menus_debug_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
static void menus_debug_recurse_menu (GtkWidget *menu,
gint depth,
gchar *path);
static void menus_debug_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
#endif /* ENABLE_DEBUG_ENTRY */
#define SEPARATOR(path) \
{ { (path), NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
#define BRANCH(path) \
{ { (path), NULL, NULL, 0, "<Branch>" }, NULL, NULL, NULL }
......@@ -280,14 +283,12 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Mem Profile"), NULL,
mem_profile_cmd_callback, 0 },
NULL,
NULL, NULL },
NULL, NULL, NULL }
#ifdef ENABLE_DEBUG_ENTRY
{ { "/Help/Dump Items (Debug)", NULL,
menus_debug_cmd_callback, 0 },
NULL,
NULL, NULL }
, { { "/Help/Dump Items (Debug)", NULL,
menus_debug_cmd_callback, 0 },
NULL, NULL, NULL }
#endif
};
......@@ -297,8 +298,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
static GimpItemFactoryEntry image_entries[] =
{
{ { "/tearoff1", NULL, gimp_item_factory_tearoff_callback, 0, "<Tearoff>" },
NULL,
NULL, NULL },
NULL, NULL, NULL },
/* <Image>/File */
......@@ -1989,6 +1989,17 @@ menus_init (Gimp *gimp)
gimp);
menus_last_opened_update_labels (gimp->documents, NULL, gimp);
g_signal_connect (G_OBJECT (gimp_get_user_context (gimp)),
"foreground_changed",
G_CALLBACK (menus_color_changed),
gimp);
g_signal_connect (G_OBJECT (gimp_get_user_context (gimp)),
"background_changed",
G_CALLBACK (menus_color_changed),
gimp);
menus_color_changed (gimp_get_user_context (gimp), NULL, gimp);
}
void
......@@ -2418,6 +2429,21 @@ menus_last_opened_update_labels (GimpContainer *container,
}
}
static void
menus_color_changed (GimpContext *context,
const GimpRGB *unused,
Gimp *gimp)
{
GimpRGB fg;
GimpRGB bg;
gimp_context_get_foreground (context, &fg);
gimp_context_get_background (context, &bg);
gimp_menu_item_set_color ("<Image>/Edit/Fill with FG Color", &fg, FALSE);
gimp_menu_item_set_color ("<Image>/Edit/Fill with BG Color", &bg, FALSE);
}
#ifdef ENABLE_DEBUG_ENTRY
......
......@@ -22,12 +22,20 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "gui/gui-types.h"
#include "gui/color-notebook.h"
#include "gimpcolorpanel.h"
#include "gimpitemfactory.h"
#include "app_procs.h"
struct _GimpColorPanel
......@@ -40,17 +48,20 @@ struct _GimpColorPanel
/* local function prototypes */
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
static void gimp_color_panel_init (GimpColorPanel *panel);
static void gimp_color_panel_destroy (GtkObject *object);
static void gimp_color_panel_color_changed (GimpColorButton *button);
static void gimp_color_panel_clicked (GtkButton *button);
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
static void gimp_color_panel_init (GimpColorPanel *panel);
static void gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void gimp_color_panel_destroy (GtkObject *object);
static gboolean gimp_color_panel_button_press (GtkWidget *widget,
GdkEventButton *bevent);
static void gimp_color_panel_color_changed (GimpColorButton *button);
static void gimp_color_panel_clicked (GtkButton *button);
static void gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static GimpColorButtonClass *parent_class = NULL;
......@@ -88,16 +99,19 @@ static void
gimp_color_panel_class_init (GimpColorPanelClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
GimpColorButtonClass *color_button_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
color_button_class = GIMP_COLOR_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_color_panel_destroy;
widget_class->button_press_event = gimp_color_panel_button_press;
button_class->clicked = gimp_color_panel_clicked;
color_button_class->color_changed = gimp_color_panel_color_changed;
}
......@@ -125,8 +139,39 @@ gimp_color_panel_destroy (GtkObject *object)
panel->color_notebook = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static gboolean
gimp_color_panel_button_press (GtkWidget *widget,
GdkEventButton *bevent)
{
if (bevent->button == 3)
{
GimpColorButton *color_button;
GimpRGB fg, bg, black, white;
color_button = GIMP_COLOR_BUTTON (widget);
gimp_context_get_foreground (gimp_get_user_context (the_gimp), &fg);
gimp_context_get_background (gimp_get_user_context (the_gimp), &bg);
gimp_rgba_set (&black, 0.0, 0.0, 0.0, 1.0);
gimp_rgba_set (&white, 1.0, 1.0, 1.0, 1.0);
gimp_item_factory_set_color (color_button->item_factory,
"/Foreground Color", &fg, FALSE);
gimp_item_factory_set_color (color_button->item_factory,
"/Background Color", &bg, FALSE);
gimp_item_factory_set_color (color_button->item_factory,
"/Black", &black, FALSE);
gimp_item_factory_set_color (color_button->item_factory,
"/White", &white, FALSE);
}
if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
return FALSE;
}
GtkWidget *
......
......@@ -34,6 +34,7 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpimagedock.h"
#include "gimpitemfactory.h"
/* EEK, see below */
#include "gimpcontainerview.h"
......@@ -449,13 +450,8 @@ gimp_dockbook_tab_button_press (GtkWidget *widget,
{
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
GtkWidget *list_widget;
GtkWidget *grid_widget;
GtkWidget *size_widget;
GtkWidget *toggle_widget;
GtkWidget *auto_widget;
gboolean is_grid = FALSE;
gint preview_size = 16;
GimpPreviewSize preview_size = GIMP_PREVIEW_SIZE_NONE;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
......@@ -473,81 +469,61 @@ gimp_dockbook_tab_button_press (GtkWidget *widget,
preview_size = view->preview_size;
}
list_widget = gtk_item_factory_get_widget (ifactory, "/View as List");
grid_widget = gtk_item_factory_get_widget (ifactory, "/View as Grid");
toggle_widget = gtk_item_factory_get_widget (ifactory,
"/Show Image Menu");
auto_widget = gtk_item_factory_get_widget (ifactory,
"/Auto Follow Active Image");
#define SET_ACTIVE(path,active) \
gimp_item_factory_set_active (ifactory, (path), (active))
/* yes, this is insane */
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Gigantic");
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
}
if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Enormous");
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Huge");
SET_ACTIVE ("/Preview Size/Huge", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Extra Large");
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Large");
SET_ACTIVE ("/Preview Size/Large", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Medium");
SET_ACTIVE ("/Preview Size/Medium", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Small");
SET_ACTIVE ("/Preview Size/Small", TRUE);
}
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Extra Small");
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
}
else
{
size_widget = gtk_item_factory_get_widget (ifactory,
"/Preview Size/Tiny");
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
}
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (size_widget),
TRUE);
if (is_grid)
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (grid_widget),
TRUE);
SET_ACTIVE ("/View as Grid", TRUE);
}
else
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (list_widget),
TRUE);
SET_ACTIVE ("/View as List", TRUE);
}
gtk_check_menu_item_set_active
(GTK_CHECK_MENU_ITEM (toggle_widget),
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Show Image Menu",
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
SET_ACTIVE ("/Auto Follow Active Image",
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
gtk_check_menu_item_set_active
(GTK_CHECK_MENU_ITEM (auto_widget),
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
#undef SET_ACTIVE
}
/* do evil things */
......
This diff is collapsed.
......@@ -16,13 +16,88 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __MENUS_H__
#define __MENUS_H__
#ifndef __GIMP_ITEM_FACTORY_H__
#define __GIMP_ITEM_FACTORY_H__
G_BEGIN_DECLS
void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
#endif /* __MENUS_H__ */
struct _GimpItemFactoryEntry
{
GtkItemFactoryEntry entry;
const gchar *quark_string;
const gchar *help_page;
const gchar *description;
};
GtkItemFactory * gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff);
void gimp_item_factory_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type,
gboolean create_tearoff,
gboolean static_entry);
void gimp_item_factory_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type,
gboolean create_tearoff,
gboolean static_entries);
void gimp_item_factory_set_active (GtkItemFactory *factory,
gchar *path,
gboolean state);
void gimp_item_factory_set_color (GtkItemFactory *factory,
gchar *path,
const GimpRGB *color,
gboolean set_label);
void gimp_item_factory_set_label (GtkItemFactory *factory,
gchar *path,
const gchar *label);
void gimp_item_factory_set_sensitive (GtkItemFactory *factory,
gchar *path,
gboolean sensitive);
void gimp_item_factory_set_visible (GtkItemFactory *factory,
gchar *path,
gboolean visible);
void gimp_item_factory_tearoff_callback (GtkWidget *widget,
gpointer data,
guint action);
void gimp_menu_item_create (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void gimp_menu_item_destroy (gchar *path);
void gimp_menu_item_set_active (gchar *path,
gboolean state);
void gimp_menu_item_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label);
void gimp_menu_item_set_label (gchar *path,
const gchar *label);
void gimp_menu_item_set_sensitive (gchar *path,
gboolean sensitive);
void gimp_menu_item_set_visible (gchar *path,
gboolean visible);
G_END_DECLS
#endif /* __GIMP_ITEM_FACTORY_H__ */
......@@ -166,7 +166,7 @@ gimp_button_button_press (GtkWidget *widget,
if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
return TRUE;
return FALSE;
}