From d517927260f6e57768960e50b0dc6df351522bec Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 8 Feb 2000 23:45:20 +0000 Subject: [PATCH] Use static GdkPixmaps in the image_window and for the tool icons. --Sven --- ChangeLog | 12 +++ app/devices.c | 13 +-- app/display/gimpdisplayshell-draw.c | 138 +++++++++++++--------------- app/display/gimpdisplayshell-draw.h | 3 - app/display/gimpdisplayshell.c | 138 +++++++++++++--------------- app/display/gimpdisplayshell.h | 3 - app/gimpdnd.c | 7 +- app/gui/device-status-dialog.c | 13 +-- app/gui/input-dialog.c | 13 +-- app/interface.c | 138 +++++++++++++--------------- app/interface.h | 3 - app/tools.c | 66 ++++++++++++- app/tools.h | 22 +++-- app/tools/tools.c | 66 ++++++++++++- app/tools/tools.h | 22 +++-- app/widgets/gimpdeviceinfo.c | 13 +-- app/widgets/gimpdevices.c | 13 +-- app/widgets/gimpdnd.c | 7 +- 18 files changed, 381 insertions(+), 309 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9be5cbbd3..0725aac350 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Feb 8 21:35:10 CET 2000 Sven Neumann + + * app/devices.c + * app/gimpdnd.c + * app/interface.c + * app/interface.h + * app/tools.c + * app/tools.h: create the pixmaps in the image_window and in the + toolbox static and reuse them everywhere. Added tool pixmaps to + the tool_options dialog as an extra goodie. Should help to + visualize that these are tools. + 2000-02-08 Michael Natterer * app/by_color_select.c: show our selection mode cursors (REPLACE, diff --git a/app/devices.c b/app/devices.c index bc6751e5b9..36a71e531b 100644 --- a/app/devices.c +++ b/app/devices.c @@ -735,7 +735,6 @@ void device_status_create (void) { DeviceInfo *device_info; - GdkPixmap *pixmap; GtkWidget *label; GList *list; gint i; @@ -815,9 +814,7 @@ device_status_create (void) deviceD->eventboxes[i] = gtk_event_box_new(); - pixmap = create_tool_pixmap (deviceD->table, RECT_SELECT); - deviceD->tools[i] = gtk_pixmap_new (pixmap, NULL); - gdk_pixmap_unref (pixmap); + deviceD->tools[i] = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); gtk_drag_source_set (deviceD->eventboxes[i], GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, @@ -984,7 +981,6 @@ device_status_update_current (void) void device_status_update (guint32 deviceid) { - GdkPixmap *pixmap; GdkDeviceInfo *gdk_info; DeviceInfo *device_info; guchar buffer[CELL_SIZE*3]; @@ -1022,10 +1018,9 @@ device_status_update (guint32 deviceid) { gtk_widget_show (deviceD->frames[i]); - pixmap = create_tool_pixmap (deviceD->table, - gimp_context_get_tool (device_info->context)); - gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), pixmap, NULL); - gdk_pixmap_unref (pixmap); + gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), + tool_get_pixmap (gimp_context_get_tool (device_info->context)), + NULL); gtk_widget_draw (deviceD->tools[i], NULL); gtk_widget_show (deviceD->tools[i]); diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index ed14a0cf17..fad2e48aa7 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -50,6 +50,7 @@ #include "libgimp/gimpintl.h" + /* local functions */ static void tools_select_update (GtkWidget *widget, gpointer data); @@ -312,29 +313,32 @@ create_color_area (GtkWidget *parent) gtk_widget_show (frame); } -GdkPixmap * -create_tool_pixmap (GtkWidget *parent, - ToolType type) +/* creates all icons */ +static void +create_tool_pixmaps (GtkWidget *parent) { - /* - * FIXME this really should be dones without using the #defined tool names - * but it should work this way for now - */ - if (type == SCALE || type == SHEAR || type == PERSPECTIVE) - type = ROTATE; + ToolType type; + gint i; - if (tool_info[(int) type].icon_data) - return create_pixmap (parent->window, NULL, - tool_info[(int) type].icon_data, - 22, 22); - else - return create_pixmap (parent->window, NULL, - dialog_bits, - 22, 22); + g_return_if_fail (parent != NULL); - g_return_val_if_fail (FALSE, NULL); + for (i = 0; i < num_tools; i++) + { + type = i; - return NULL; /* not reached */ + if (type == SCALE || type == SHEAR || type == PERSPECTIVE) + type = ROTATE; + + if (tool_info[type].icon_data) + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + tool_info[type].icon_data, + 22, 22); + + else + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + dialog_bits, + 22, 22); + } } static void @@ -350,6 +354,8 @@ create_tools (GtkWidget *parent) wbox = parent; gtk_widget_realize (gtk_widget_get_toplevel (wbox)); + + create_tool_pixmaps (wbox); group = NULL; @@ -371,7 +377,7 @@ create_tools (GtkWidget *parent) gtk_container_set_border_width (GTK_CONTAINER (alignment), 0); gtk_container_add (GTK_CONTAINER (button), alignment); - pixmap = create_pixmap_widget (wbox->window, tool_info[j].icon_data, 22, 22); + pixmap = gtk_pixmap_new (tool_get_pixmap ((ToolType)j), NULL); gtk_container_add (GTK_CONTAINER (alignment), pixmap); gtk_signal_connect (GTK_OBJECT (button), "toggled", @@ -499,23 +505,6 @@ create_pixmap (GdkWindow *parent, return pixmap; } -GtkWidget* -create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height) -{ - GtkWidget *widget; - GdkPixmap *pixmap; - GdkBitmap *mask; - - pixmap = create_pixmap (parent, &mask, data, width, height); - widget = gtk_pixmap_new (pixmap, mask); - gdk_pixmap_unref (pixmap); - gdk_bitmap_unref (mask); - - return (widget); -} void create_toolbox (void) @@ -623,6 +612,9 @@ toolbox_free (void) gtk_widget_destroy (toolbox_shell); for (i = 0; i < num_tools; i++) { + if (tool_info[i].icon_pixmap) + gdk_pixmap_unref (tool_info[i].icon_pixmap); + if (!tool_info[i].icon_data) gtk_object_sink (GTK_OBJECT (tool_info[i].tool_widget)); } @@ -645,6 +637,13 @@ create_display_shell (GDisplay* gdisp, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; + + static GdkPixmap *qmasksel_pixmap = NULL; + static GdkBitmap *qmasksel_mask = NULL; + static GdkPixmap *qmasknosel_pixmap = NULL; + static GdkBitmap *qmasknosel_mask = NULL; + static GdkPixmap *navbutton_pixmap = NULL; + static GdkBitmap *navbutton_mask = NULL; GtkWidget *vbox; GtkWidget *table; @@ -851,48 +850,37 @@ create_display_shell (GDisplay* gdisp, gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15); gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15); - /* Draw pixmaps - note: you must realize the parent prior to doing the + /* Create pixmaps - note: you must realize the parent prior to doing the rest! */ - { - GdkPixmap *pxmp; - GdkBitmap *mask; - GtkStyle *style; + if (!qmasksel_pixmap) + { + GtkStyle *style; + + gtk_widget_realize (gdisp->shell); + style = gtk_widget_get_style (gdisp->shell); + + qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasksel_xpm); + qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasknosel_xpm); + navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask, + &style->bg[GTK_STATE_NORMAL], + navbutton_xpm); + } - gtk_widget_realize (gdisp->shell); - style = gtk_widget_get_style (gdisp->shell); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasksel_xpm); + pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); + gtk_widget_show (pixmap); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); - gtk_widget_show (pixmap); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasknosel_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); + pixmap = gtk_pixmap_new (qmasknosel_pixmap, qmasknosel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); + gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); - gtk_widget_show (pixmap); - - /* nav button pixmap */ - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - navbutton_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (navhbox), pixmap); - gtk_widget_show (pixmap); - } + pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask); + gtk_container_add (GTK_CONTAINER (navhbox), pixmap); + gtk_widget_show (pixmap); gdisp->canvas = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height); diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index c6001c4dba..7fe1acd8d4 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -27,9 +27,6 @@ GtkWidget * create_pixmap_widget (GdkWindow *parent, gint width, gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); - void create_toolbox (void); void toolbox_free (void); diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index ed14a0cf17..fad2e48aa7 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -50,6 +50,7 @@ #include "libgimp/gimpintl.h" + /* local functions */ static void tools_select_update (GtkWidget *widget, gpointer data); @@ -312,29 +313,32 @@ create_color_area (GtkWidget *parent) gtk_widget_show (frame); } -GdkPixmap * -create_tool_pixmap (GtkWidget *parent, - ToolType type) +/* creates all icons */ +static void +create_tool_pixmaps (GtkWidget *parent) { - /* - * FIXME this really should be dones without using the #defined tool names - * but it should work this way for now - */ - if (type == SCALE || type == SHEAR || type == PERSPECTIVE) - type = ROTATE; + ToolType type; + gint i; - if (tool_info[(int) type].icon_data) - return create_pixmap (parent->window, NULL, - tool_info[(int) type].icon_data, - 22, 22); - else - return create_pixmap (parent->window, NULL, - dialog_bits, - 22, 22); + g_return_if_fail (parent != NULL); - g_return_val_if_fail (FALSE, NULL); + for (i = 0; i < num_tools; i++) + { + type = i; - return NULL; /* not reached */ + if (type == SCALE || type == SHEAR || type == PERSPECTIVE) + type = ROTATE; + + if (tool_info[type].icon_data) + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + tool_info[type].icon_data, + 22, 22); + + else + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + dialog_bits, + 22, 22); + } } static void @@ -350,6 +354,8 @@ create_tools (GtkWidget *parent) wbox = parent; gtk_widget_realize (gtk_widget_get_toplevel (wbox)); + + create_tool_pixmaps (wbox); group = NULL; @@ -371,7 +377,7 @@ create_tools (GtkWidget *parent) gtk_container_set_border_width (GTK_CONTAINER (alignment), 0); gtk_container_add (GTK_CONTAINER (button), alignment); - pixmap = create_pixmap_widget (wbox->window, tool_info[j].icon_data, 22, 22); + pixmap = gtk_pixmap_new (tool_get_pixmap ((ToolType)j), NULL); gtk_container_add (GTK_CONTAINER (alignment), pixmap); gtk_signal_connect (GTK_OBJECT (button), "toggled", @@ -499,23 +505,6 @@ create_pixmap (GdkWindow *parent, return pixmap; } -GtkWidget* -create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height) -{ - GtkWidget *widget; - GdkPixmap *pixmap; - GdkBitmap *mask; - - pixmap = create_pixmap (parent, &mask, data, width, height); - widget = gtk_pixmap_new (pixmap, mask); - gdk_pixmap_unref (pixmap); - gdk_bitmap_unref (mask); - - return (widget); -} void create_toolbox (void) @@ -623,6 +612,9 @@ toolbox_free (void) gtk_widget_destroy (toolbox_shell); for (i = 0; i < num_tools; i++) { + if (tool_info[i].icon_pixmap) + gdk_pixmap_unref (tool_info[i].icon_pixmap); + if (!tool_info[i].icon_data) gtk_object_sink (GTK_OBJECT (tool_info[i].tool_widget)); } @@ -645,6 +637,13 @@ create_display_shell (GDisplay* gdisp, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; + + static GdkPixmap *qmasksel_pixmap = NULL; + static GdkBitmap *qmasksel_mask = NULL; + static GdkPixmap *qmasknosel_pixmap = NULL; + static GdkBitmap *qmasknosel_mask = NULL; + static GdkPixmap *navbutton_pixmap = NULL; + static GdkBitmap *navbutton_mask = NULL; GtkWidget *vbox; GtkWidget *table; @@ -851,48 +850,37 @@ create_display_shell (GDisplay* gdisp, gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15); gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15); - /* Draw pixmaps - note: you must realize the parent prior to doing the + /* Create pixmaps - note: you must realize the parent prior to doing the rest! */ - { - GdkPixmap *pxmp; - GdkBitmap *mask; - GtkStyle *style; + if (!qmasksel_pixmap) + { + GtkStyle *style; + + gtk_widget_realize (gdisp->shell); + style = gtk_widget_get_style (gdisp->shell); + + qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasksel_xpm); + qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasknosel_xpm); + navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask, + &style->bg[GTK_STATE_NORMAL], + navbutton_xpm); + } - gtk_widget_realize (gdisp->shell); - style = gtk_widget_get_style (gdisp->shell); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasksel_xpm); + pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); + gtk_widget_show (pixmap); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); - gtk_widget_show (pixmap); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasknosel_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); + pixmap = gtk_pixmap_new (qmasknosel_pixmap, qmasknosel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); + gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); - gtk_widget_show (pixmap); - - /* nav button pixmap */ - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - navbutton_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (navhbox), pixmap); - gtk_widget_show (pixmap); - } + pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask); + gtk_container_add (GTK_CONTAINER (navhbox), pixmap); + gtk_widget_show (pixmap); gdisp->canvas = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height); diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index c6001c4dba..7fe1acd8d4 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -27,9 +27,6 @@ GtkWidget * create_pixmap_widget (GdkWindow *parent, gint width, gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); - void create_toolbox (void); void toolbox_free (void); diff --git a/app/gimpdnd.c b/app/gimpdnd.c index bdb28f4684..7906b8da6a 100644 --- a/app/gimpdnd.c +++ b/app/gimpdnd.c @@ -939,7 +939,6 @@ gimp_dnd_get_tool_icon (GtkWidget *widget, GtkSignalFunc get_tool_func, gpointer get_tool_data) { - GdkPixmap *tool_pixmap; GtkWidget *tool_icon; ToolType tool_type; @@ -949,11 +948,7 @@ gimp_dnd_get_tool_icon (GtkWidget *widget, if (((gint) tool_type < 0) || ((gint) tool_type >= num_tools)) return NULL; - tool_pixmap = create_tool_pixmap (widget, tool_type); - - tool_icon = gtk_pixmap_new (tool_pixmap, NULL); - - gdk_pixmap_unref (tool_pixmap); + tool_icon = gtk_pixmap_new (tool_get_pixmap (tool_type), NULL); return tool_icon; } diff --git a/app/gui/device-status-dialog.c b/app/gui/device-status-dialog.c index bc6751e5b9..36a71e531b 100644 --- a/app/gui/device-status-dialog.c +++ b/app/gui/device-status-dialog.c @@ -735,7 +735,6 @@ void device_status_create (void) { DeviceInfo *device_info; - GdkPixmap *pixmap; GtkWidget *label; GList *list; gint i; @@ -815,9 +814,7 @@ device_status_create (void) deviceD->eventboxes[i] = gtk_event_box_new(); - pixmap = create_tool_pixmap (deviceD->table, RECT_SELECT); - deviceD->tools[i] = gtk_pixmap_new (pixmap, NULL); - gdk_pixmap_unref (pixmap); + deviceD->tools[i] = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); gtk_drag_source_set (deviceD->eventboxes[i], GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, @@ -984,7 +981,6 @@ device_status_update_current (void) void device_status_update (guint32 deviceid) { - GdkPixmap *pixmap; GdkDeviceInfo *gdk_info; DeviceInfo *device_info; guchar buffer[CELL_SIZE*3]; @@ -1022,10 +1018,9 @@ device_status_update (guint32 deviceid) { gtk_widget_show (deviceD->frames[i]); - pixmap = create_tool_pixmap (deviceD->table, - gimp_context_get_tool (device_info->context)); - gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), pixmap, NULL); - gdk_pixmap_unref (pixmap); + gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), + tool_get_pixmap (gimp_context_get_tool (device_info->context)), + NULL); gtk_widget_draw (deviceD->tools[i], NULL); gtk_widget_show (deviceD->tools[i]); diff --git a/app/gui/input-dialog.c b/app/gui/input-dialog.c index bc6751e5b9..36a71e531b 100644 --- a/app/gui/input-dialog.c +++ b/app/gui/input-dialog.c @@ -735,7 +735,6 @@ void device_status_create (void) { DeviceInfo *device_info; - GdkPixmap *pixmap; GtkWidget *label; GList *list; gint i; @@ -815,9 +814,7 @@ device_status_create (void) deviceD->eventboxes[i] = gtk_event_box_new(); - pixmap = create_tool_pixmap (deviceD->table, RECT_SELECT); - deviceD->tools[i] = gtk_pixmap_new (pixmap, NULL); - gdk_pixmap_unref (pixmap); + deviceD->tools[i] = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); gtk_drag_source_set (deviceD->eventboxes[i], GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, @@ -984,7 +981,6 @@ device_status_update_current (void) void device_status_update (guint32 deviceid) { - GdkPixmap *pixmap; GdkDeviceInfo *gdk_info; DeviceInfo *device_info; guchar buffer[CELL_SIZE*3]; @@ -1022,10 +1018,9 @@ device_status_update (guint32 deviceid) { gtk_widget_show (deviceD->frames[i]); - pixmap = create_tool_pixmap (deviceD->table, - gimp_context_get_tool (device_info->context)); - gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), pixmap, NULL); - gdk_pixmap_unref (pixmap); + gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), + tool_get_pixmap (gimp_context_get_tool (device_info->context)), + NULL); gtk_widget_draw (deviceD->tools[i], NULL); gtk_widget_show (deviceD->tools[i]); diff --git a/app/interface.c b/app/interface.c index ed14a0cf17..fad2e48aa7 100644 --- a/app/interface.c +++ b/app/interface.c @@ -50,6 +50,7 @@ #include "libgimp/gimpintl.h" + /* local functions */ static void tools_select_update (GtkWidget *widget, gpointer data); @@ -312,29 +313,32 @@ create_color_area (GtkWidget *parent) gtk_widget_show (frame); } -GdkPixmap * -create_tool_pixmap (GtkWidget *parent, - ToolType type) +/* creates all icons */ +static void +create_tool_pixmaps (GtkWidget *parent) { - /* - * FIXME this really should be dones without using the #defined tool names - * but it should work this way for now - */ - if (type == SCALE || type == SHEAR || type == PERSPECTIVE) - type = ROTATE; + ToolType type; + gint i; - if (tool_info[(int) type].icon_data) - return create_pixmap (parent->window, NULL, - tool_info[(int) type].icon_data, - 22, 22); - else - return create_pixmap (parent->window, NULL, - dialog_bits, - 22, 22); + g_return_if_fail (parent != NULL); - g_return_val_if_fail (FALSE, NULL); + for (i = 0; i < num_tools; i++) + { + type = i; - return NULL; /* not reached */ + if (type == SCALE || type == SHEAR || type == PERSPECTIVE) + type = ROTATE; + + if (tool_info[type].icon_data) + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + tool_info[type].icon_data, + 22, 22); + + else + tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL, + dialog_bits, + 22, 22); + } } static void @@ -350,6 +354,8 @@ create_tools (GtkWidget *parent) wbox = parent; gtk_widget_realize (gtk_widget_get_toplevel (wbox)); + + create_tool_pixmaps (wbox); group = NULL; @@ -371,7 +377,7 @@ create_tools (GtkWidget *parent) gtk_container_set_border_width (GTK_CONTAINER (alignment), 0); gtk_container_add (GTK_CONTAINER (button), alignment); - pixmap = create_pixmap_widget (wbox->window, tool_info[j].icon_data, 22, 22); + pixmap = gtk_pixmap_new (tool_get_pixmap ((ToolType)j), NULL); gtk_container_add (GTK_CONTAINER (alignment), pixmap); gtk_signal_connect (GTK_OBJECT (button), "toggled", @@ -499,23 +505,6 @@ create_pixmap (GdkWindow *parent, return pixmap; } -GtkWidget* -create_pixmap_widget (GdkWindow *parent, - gchar **data, - gint width, - gint height) -{ - GtkWidget *widget; - GdkPixmap *pixmap; - GdkBitmap *mask; - - pixmap = create_pixmap (parent, &mask, data, width, height); - widget = gtk_pixmap_new (pixmap, mask); - gdk_pixmap_unref (pixmap); - gdk_bitmap_unref (mask); - - return (widget); -} void create_toolbox (void) @@ -623,6 +612,9 @@ toolbox_free (void) gtk_widget_destroy (toolbox_shell); for (i = 0; i < num_tools; i++) { + if (tool_info[i].icon_pixmap) + gdk_pixmap_unref (tool_info[i].icon_pixmap); + if (!tool_info[i].icon_data) gtk_object_sink (GTK_OBJECT (tool_info[i].tool_widget)); } @@ -645,6 +637,13 @@ create_display_shell (GDisplay* gdisp, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; + + static GdkPixmap *qmasksel_pixmap = NULL; + static GdkBitmap *qmasksel_mask = NULL; + static GdkPixmap *qmasknosel_pixmap = NULL; + static GdkBitmap *qmasknosel_mask = NULL; + static GdkPixmap *navbutton_pixmap = NULL; + static GdkBitmap *navbutton_mask = NULL; GtkWidget *vbox; GtkWidget *table; @@ -851,48 +850,37 @@ create_display_shell (GDisplay* gdisp, gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15); gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15); - /* Draw pixmaps - note: you must realize the parent prior to doing the + /* Create pixmaps - note: you must realize the parent prior to doing the rest! */ - { - GdkPixmap *pxmp; - GdkBitmap *mask; - GtkStyle *style; + if (!qmasksel_pixmap) + { + GtkStyle *style; + + gtk_widget_realize (gdisp->shell); + style = gtk_widget_get_style (gdisp->shell); + + qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasksel_xpm); + qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask, + &style->bg[GTK_STATE_NORMAL], + qmasknosel_xpm); + navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask, + &style->bg[GTK_STATE_NORMAL], + navbutton_xpm); + } - gtk_widget_realize (gdisp->shell); - style = gtk_widget_get_style (gdisp->shell); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasksel_xpm); + pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); + gtk_widget_show (pixmap); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap); - gtk_widget_show (pixmap); - - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - qmasknosel_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); + pixmap = gtk_pixmap_new (qmasknosel_pixmap, qmasknosel_mask); + gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); + gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap); - gtk_widget_show (pixmap); - - /* nav button pixmap */ - pxmp = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &mask, - &style->bg[GTK_STATE_NORMAL], - navbutton_xpm); - pixmap = gtk_pixmap_new (pxmp, mask); - gdk_pixmap_unref (pxmp); - gdk_bitmap_unref (mask); - - gtk_container_add (GTK_CONTAINER (navhbox), pixmap); - gtk_widget_show (pixmap); - } + pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask); + gtk_container_add (GTK_CONTAINER (navhbox), pixmap); + gtk_widget_show (pixmap); gdisp->canvas = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height); diff --git a/app/interface.h b/app/interface.h index c6001c4dba..7fe1acd8d4 100644 --- a/app/interface.h +++ b/app/interface.h @@ -27,9 +27,6 @@ GtkWidget * create_pixmap_widget (GdkWindow *parent, gint width, gint height); -GdkPixmap * create_tool_pixmap (GtkWidget *parent, - ToolType type); - void create_toolbox (void); void toolbox_free (void); diff --git a/app/tools.c b/app/tools.c index 8d39f0db61..7682c382e6 100644 --- a/app/tools.c +++ b/app/tools.c @@ -43,6 +43,7 @@ #include "fuzzy_select.h" #include "histogram_tool.h" #include "ink.h" +#include "interface.h" #include "iscissors.h" #include "levels.h" #include "magnify.h" @@ -74,6 +75,7 @@ Tool * active_tool = NULL; static GtkWidget * options_shell = NULL; static GtkWidget * options_vbox = NULL; static GtkWidget * options_label = NULL; +static GtkWidget * options_pixmap = NULL; static GtkWidget * options_reset_button = NULL; static gint global_tool_ID = 0; @@ -86,6 +88,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Rect Select"), "R", (char **) rect_bits, + NULL, N_("Select rectangular regions"), "tools/rect_select.html", RECT_SELECT, @@ -102,6 +105,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Ellipse Select"), "E", (char **) circ_bits, + NULL, N_("Select elliptical regions"), "tools/ellipse_select.html", ELLIPSE_SELECT, @@ -118,6 +122,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Free Select"), "F", (char **) free_bits, + NULL, N_("Select hand-drawn regions"), "tools/free_select.html", FREE_SELECT, @@ -134,6 +139,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Fuzzy Select"), "Z", (char **) fuzzy_bits, + NULL, N_("Select contiguous regions"), "tools/fuzzy_select.html", FUZZY_SELECT, @@ -150,6 +156,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Bezier Select"), "B", (char **) bezier_bits, + NULL, N_("Select regions using Bezier curves"), "tools/bezier_select.html", BEZIER_SELECT, @@ -166,6 +173,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Intelligent Scissors"), "I", (char **) iscissors_bits, + NULL, N_("Select shapes from image"), "tools/intelligent_scissors.html", ISCISSORS, @@ -182,6 +190,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Move"), "M", (char **) move_bits, + NULL, N_("Move layers & selections"), "tools/move.html", MOVE, @@ -198,6 +207,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Magnify"), "M", (char **) magnify_bits, + NULL, N_("Zoom in & out"), "tools/magnify.html", MAGNIFY, @@ -214,6 +224,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Crop & Resize"), "C", (char **) crop_bits, + NULL, N_("Crop or resize the image"), "tools/crop.html", CROP, @@ -230,6 +241,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Transform"), "T", (char **) scale_bits, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", ROTATE, @@ -246,6 +258,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", SCALE, @@ -262,6 +275,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", SHEAR, @@ -278,6 +292,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", PERSPECTIVE, @@ -294,6 +309,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Flip"), "F", (char **) flip_bits, + NULL, N_("Flip the layer or selection"), "tools/flip.html", FLIP, @@ -310,6 +326,7 @@ ToolInfo tool_info[] = N_("/Tools/Text"), "T", (char **) text_bits, + NULL, N_("Add text to the image"), "tools/text.html", TEXT, @@ -326,6 +343,7 @@ ToolInfo tool_info[] = N_("/Tools/Color Picker"), "O", (char **) colorpicker_bits, + NULL, N_("Pick colors from the image"), "tools/color_picker.html", COLOR_PICKER, @@ -342,6 +360,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Bucket Fill"), "B", (char **) fill_bits, + NULL, N_("Fill with a color or pattern"), "tools/bucket_fill.html", BUCKET_FILL, @@ -358,6 +377,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Blend"), "L", (char **) gradient_bits, + NULL, N_("Fill with a color gradient"), "tools/blend.html", BLEND, @@ -374,6 +394,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Pencil"), "P", (char **) pencil_bits, + NULL, N_("Draw sharp pencil strokes"), "tools/pencil.html", PENCIL, @@ -390,6 +411,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Paintbrush"), "P", (char **) paint_bits, + NULL, N_("Paint fuzzy brush strokes"), "tools/paintbrush.html", PAINTBRUSH, @@ -406,6 +428,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Eraser"), "E", (char **) erase_bits, + NULL, N_("Erase to background or transparency"), "tools/eraser.html", ERASER, @@ -422,6 +445,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Airbrush"), "A", (char **) airbrush_bits, + NULL, N_("Airbrush with variable pressure"), "tools/airbrush.html", AIRBRUSH, @@ -438,6 +462,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Clone"), "C", (char **) clone_bits, + NULL, N_("Paint using patterns or image regions"), "tools/clone.html", CLONE, @@ -454,6 +479,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Convolve"), "V", (char **) blur_bits, + NULL, N_("Blur or sharpen"), "tools/convolve.html", CONVOLVE, @@ -470,6 +496,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Ink"), "K", (char **) ink_bits, + NULL, N_("Draw in ink"), "tools/ink.html", INK, @@ -486,6 +513,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/DodgeBurn"), "D", (char **) dodge_bits, + NULL, N_("Dodge or Burn"), "tools/dodgeburn.html", DODGEBURN, @@ -502,6 +530,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Smudge"), "S", (char **) smudge_bits, + NULL, N_("Smudge"), "tools/smudge.html", SMUDGE, @@ -518,6 +547,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/XinputAirbrush"), "A", (char **) xinput_airbrush_bits, + NULL, N_("Natural Airbrush"), "tools/xinput_airbrush.html", XINPUT_AIRBRUSH, @@ -534,6 +564,7 @@ ToolInfo tool_info[] = N_("/Tools/Measure"), "", (char **) measure_bits, + NULL, N_("Measure distances and angles"), "tools/measure.html", MEASURE, @@ -550,6 +581,7 @@ ToolInfo tool_info[] = N_("/Tools/Path"), "", (char **) path_tool_bits, + NULL, N_("Manipulate paths"), "tools/path.html", PATH_TOOL, @@ -568,6 +600,7 @@ ToolInfo tool_info[] = N_("/Select/By Color..."), NULL, NULL, + NULL, N_("Select regions by color"), "tools/by_color_select.html", BY_COLOR_SELECT, @@ -584,6 +617,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Color Balance..."), NULL, NULL, + NULL, N_("Adjust color balance"), "tools/color_balance.html", COLOR_BALANCE, @@ -600,6 +634,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Brightness-Contrast..."), NULL, NULL, + NULL, N_("Adjust brightness and contrast"), "tools/brightness_contrast.html", BRIGHTNESS_CONTRAST, @@ -616,6 +651,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Hue-Saturation..."), NULL, NULL, + NULL, N_("Adjust hue and saturation"), "tools/hue_saturation.html", HUE_SATURATION, @@ -632,6 +668,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Posterize..."), NULL, NULL, + NULL, N_("Reduce image to a fixed numer of colors"), "tools/posterize.html", POSTERIZE, @@ -648,6 +685,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Threshold..."), NULL, NULL, + NULL, N_("Reduce image to two colors using a threshold"), "tools/threshold.html", THRESHOLD, @@ -664,6 +702,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Curves..."), NULL, NULL, + NULL, N_("Adjust color curves"), "tools/curves.html", CURVES, @@ -680,6 +719,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Levels..."), NULL, NULL, + NULL, N_("Adjust color levels"), "tools/levels.html", LEVELS, @@ -696,6 +736,7 @@ ToolInfo tool_info[] = N_("/Image/Histogram..."), NULL, NULL, + NULL, N_("View image histogram"), "tools/histogram.html", HISTOGRAM, @@ -785,6 +826,7 @@ tools_initialize (ToolType tool_type, /* don't set gdisp_ptr here! (see commands.c) */ } + void active_tool_control (ToolAction action, void *gdisp_ptr) @@ -970,6 +1012,9 @@ tools_register (ToolType tool_type, } gtk_label_set_text (GTK_LABEL (options_label), tool_options->title); + + gtk_pixmap_set (GTK_PIXMAP (options_pixmap), tool_get_pixmap (tool_type), NULL); + gtk_widget_queue_draw (options_pixmap); } /* Tool options function */ @@ -978,6 +1023,7 @@ void tool_options_dialog_new (void) { GtkWidget *frame; + GtkWidget *hbox; GtkWidget *vbox; /* The shell and main vbox */ @@ -1017,9 +1063,16 @@ tool_options_dialog_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); + hbox = gtk_hbox_new (FALSE, 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); + + options_pixmap = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); + gtk_box_pack_start (GTK_BOX (hbox), options_pixmap, FALSE, FALSE, 0); + gtk_widget_show (options_pixmap); + options_label = gtk_label_new (""); - gtk_misc_set_padding (GTK_MISC (options_label), 1, 0); - gtk_container_add (GTK_CONTAINER (frame), options_label); + gtk_box_pack_start (GTK_BOX (hbox), options_label, FALSE, FALSE, 1); gtk_widget_show (options_label); options_vbox = gtk_vbox_new (FALSE, 0); @@ -1071,6 +1124,9 @@ tool_options_show (ToolType tool_type) gtk_label_set_text (GTK_LABEL (options_label), tool_info[tool_type].tool_options->title); + gtk_pixmap_set (GTK_PIXMAP (options_pixmap), tool_get_pixmap (tool_type), NULL); + gtk_widget_queue_draw (options_pixmap); + if (tool_info[tool_type].tool_options->reset_func) gtk_widget_set_sensitive (options_reset_button, TRUE); else @@ -1163,3 +1219,9 @@ tool_active_PDB_string (void) return toolStr; } + +GdkPixmap * +tool_get_pixmap (ToolType type) +{ + return (tool_info[type].icon_pixmap); +} diff --git a/app/tools.h b/app/tools.h index 89cc079ffc..efc2650704 100644 --- a/app/tools.h +++ b/app/tools.h @@ -88,15 +88,16 @@ struct _ToolInfo { ToolOptions *tool_options; - gchar *tool_name; + gchar *tool_name; - gchar *menu_path; - gchar *menu_accel; + gchar *menu_path; + gchar *menu_accel; - gchar **icon_data; + gchar **icon_data; + GdkPixmap *icon_pixmap; - gchar *tool_desc; - gchar *private_tip; + gchar *tool_desc; + gchar *private_tip; ToolType tool_id; @@ -104,7 +105,7 @@ struct _ToolInfo ToolInfoFreeFunc free_func; ToolInfoInitFunc init_func; - GtkWidget *tool_widget; + GtkWidget *tool_widget; GimpContext *tool_context; }; @@ -135,4 +136,11 @@ void tool_options_dialog_free (void); gchar * tool_active_PDB_string (void); +/* don't unref this pixmap, it is static! */ +GdkPixmap * tool_get_pixmap (ToolType tool_type); + #endif /* __TOOLS_H__ */ + + + + diff --git a/app/tools/tools.c b/app/tools/tools.c index 8d39f0db61..7682c382e6 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -43,6 +43,7 @@ #include "fuzzy_select.h" #include "histogram_tool.h" #include "ink.h" +#include "interface.h" #include "iscissors.h" #include "levels.h" #include "magnify.h" @@ -74,6 +75,7 @@ Tool * active_tool = NULL; static GtkWidget * options_shell = NULL; static GtkWidget * options_vbox = NULL; static GtkWidget * options_label = NULL; +static GtkWidget * options_pixmap = NULL; static GtkWidget * options_reset_button = NULL; static gint global_tool_ID = 0; @@ -86,6 +88,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Rect Select"), "R", (char **) rect_bits, + NULL, N_("Select rectangular regions"), "tools/rect_select.html", RECT_SELECT, @@ -102,6 +105,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Ellipse Select"), "E", (char **) circ_bits, + NULL, N_("Select elliptical regions"), "tools/ellipse_select.html", ELLIPSE_SELECT, @@ -118,6 +122,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Free Select"), "F", (char **) free_bits, + NULL, N_("Select hand-drawn regions"), "tools/free_select.html", FREE_SELECT, @@ -134,6 +139,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Fuzzy Select"), "Z", (char **) fuzzy_bits, + NULL, N_("Select contiguous regions"), "tools/fuzzy_select.html", FUZZY_SELECT, @@ -150,6 +156,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Bezier Select"), "B", (char **) bezier_bits, + NULL, N_("Select regions using Bezier curves"), "tools/bezier_select.html", BEZIER_SELECT, @@ -166,6 +173,7 @@ ToolInfo tool_info[] = N_("/Tools/Select Tools/Intelligent Scissors"), "I", (char **) iscissors_bits, + NULL, N_("Select shapes from image"), "tools/intelligent_scissors.html", ISCISSORS, @@ -182,6 +190,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Move"), "M", (char **) move_bits, + NULL, N_("Move layers & selections"), "tools/move.html", MOVE, @@ -198,6 +207,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Magnify"), "M", (char **) magnify_bits, + NULL, N_("Zoom in & out"), "tools/magnify.html", MAGNIFY, @@ -214,6 +224,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Crop & Resize"), "C", (char **) crop_bits, + NULL, N_("Crop or resize the image"), "tools/crop.html", CROP, @@ -230,6 +241,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Transform"), "T", (char **) scale_bits, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", ROTATE, @@ -246,6 +258,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", SCALE, @@ -262,6 +275,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", SHEAR, @@ -278,6 +292,7 @@ ToolInfo tool_info[] = NULL, NULL, NULL, + NULL, N_("Rotation, scaling, shearing, perspective."), "tools/transform.html", PERSPECTIVE, @@ -294,6 +309,7 @@ ToolInfo tool_info[] = N_("/Tools/Transform Tools/Flip"), "F", (char **) flip_bits, + NULL, N_("Flip the layer or selection"), "tools/flip.html", FLIP, @@ -310,6 +326,7 @@ ToolInfo tool_info[] = N_("/Tools/Text"), "T", (char **) text_bits, + NULL, N_("Add text to the image"), "tools/text.html", TEXT, @@ -326,6 +343,7 @@ ToolInfo tool_info[] = N_("/Tools/Color Picker"), "O", (char **) colorpicker_bits, + NULL, N_("Pick colors from the image"), "tools/color_picker.html", COLOR_PICKER, @@ -342,6 +360,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Bucket Fill"), "B", (char **) fill_bits, + NULL, N_("Fill with a color or pattern"), "tools/bucket_fill.html", BUCKET_FILL, @@ -358,6 +377,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Blend"), "L", (char **) gradient_bits, + NULL, N_("Fill with a color gradient"), "tools/blend.html", BLEND, @@ -374,6 +394,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Pencil"), "P", (char **) pencil_bits, + NULL, N_("Draw sharp pencil strokes"), "tools/pencil.html", PENCIL, @@ -390,6 +411,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Paintbrush"), "P", (char **) paint_bits, + NULL, N_("Paint fuzzy brush strokes"), "tools/paintbrush.html", PAINTBRUSH, @@ -406,6 +428,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Eraser"), "E", (char **) erase_bits, + NULL, N_("Erase to background or transparency"), "tools/eraser.html", ERASER, @@ -422,6 +445,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Airbrush"), "A", (char **) airbrush_bits, + NULL, N_("Airbrush with variable pressure"), "tools/airbrush.html", AIRBRUSH, @@ -438,6 +462,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Clone"), "C", (char **) clone_bits, + NULL, N_("Paint using patterns or image regions"), "tools/clone.html", CLONE, @@ -454,6 +479,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Convolve"), "V", (char **) blur_bits, + NULL, N_("Blur or sharpen"), "tools/convolve.html", CONVOLVE, @@ -470,6 +496,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Ink"), "K", (char **) ink_bits, + NULL, N_("Draw in ink"), "tools/ink.html", INK, @@ -486,6 +513,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/DodgeBurn"), "D", (char **) dodge_bits, + NULL, N_("Dodge or Burn"), "tools/dodgeburn.html", DODGEBURN, @@ -502,6 +530,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/Smudge"), "S", (char **) smudge_bits, + NULL, N_("Smudge"), "tools/smudge.html", SMUDGE, @@ -518,6 +547,7 @@ ToolInfo tool_info[] = N_("/Tools/Paint Tools/XinputAirbrush"), "A", (char **) xinput_airbrush_bits, + NULL, N_("Natural Airbrush"), "tools/xinput_airbrush.html", XINPUT_AIRBRUSH, @@ -534,6 +564,7 @@ ToolInfo tool_info[] = N_("/Tools/Measure"), "", (char **) measure_bits, + NULL, N_("Measure distances and angles"), "tools/measure.html", MEASURE, @@ -550,6 +581,7 @@ ToolInfo tool_info[] = N_("/Tools/Path"), "", (char **) path_tool_bits, + NULL, N_("Manipulate paths"), "tools/path.html", PATH_TOOL, @@ -568,6 +600,7 @@ ToolInfo tool_info[] = N_("/Select/By Color..."), NULL, NULL, + NULL, N_("Select regions by color"), "tools/by_color_select.html", BY_COLOR_SELECT, @@ -584,6 +617,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Color Balance..."), NULL, NULL, + NULL, N_("Adjust color balance"), "tools/color_balance.html", COLOR_BALANCE, @@ -600,6 +634,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Brightness-Contrast..."), NULL, NULL, + NULL, N_("Adjust brightness and contrast"), "tools/brightness_contrast.html", BRIGHTNESS_CONTRAST, @@ -616,6 +651,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Hue-Saturation..."), NULL, NULL, + NULL, N_("Adjust hue and saturation"), "tools/hue_saturation.html", HUE_SATURATION, @@ -632,6 +668,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Posterize..."), NULL, NULL, + NULL, N_("Reduce image to a fixed numer of colors"), "tools/posterize.html", POSTERIZE, @@ -648,6 +685,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Threshold..."), NULL, NULL, + NULL, N_("Reduce image to two colors using a threshold"), "tools/threshold.html", THRESHOLD, @@ -664,6 +702,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Curves..."), NULL, NULL, + NULL, N_("Adjust color curves"), "tools/curves.html", CURVES, @@ -680,6 +719,7 @@ ToolInfo tool_info[] = N_("/Image/Colors/Levels..."), NULL, NULL, + NULL, N_("Adjust color levels"), "tools/levels.html", LEVELS, @@ -696,6 +736,7 @@ ToolInfo tool_info[] = N_("/Image/Histogram..."), NULL, NULL, + NULL, N_("View image histogram"), "tools/histogram.html", HISTOGRAM, @@ -785,6 +826,7 @@ tools_initialize (ToolType tool_type, /* don't set gdisp_ptr here! (see commands.c) */ } + void active_tool_control (ToolAction action, void *gdisp_ptr) @@ -970,6 +1012,9 @@ tools_register (ToolType tool_type, } gtk_label_set_text (GTK_LABEL (options_label), tool_options->title); + + gtk_pixmap_set (GTK_PIXMAP (options_pixmap), tool_get_pixmap (tool_type), NULL); + gtk_widget_queue_draw (options_pixmap); } /* Tool options function */ @@ -978,6 +1023,7 @@ void tool_options_dialog_new (void) { GtkWidget *frame; + GtkWidget *hbox; GtkWidget *vbox; /* The shell and main vbox */ @@ -1017,9 +1063,16 @@ tool_options_dialog_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); + hbox = gtk_hbox_new (FALSE, 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); + + options_pixmap = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); + gtk_box_pack_start (GTK_BOX (hbox), options_pixmap, FALSE, FALSE, 0); + gtk_widget_show (options_pixmap); + options_label = gtk_label_new (""); - gtk_misc_set_padding (GTK_MISC (options_label), 1, 0); - gtk_container_add (GTK_CONTAINER (frame), options_label); + gtk_box_pack_start (GTK_BOX (hbox), options_label, FALSE, FALSE, 1); gtk_widget_show (options_label); options_vbox = gtk_vbox_new (FALSE, 0); @@ -1071,6 +1124,9 @@ tool_options_show (ToolType tool_type) gtk_label_set_text (GTK_LABEL (options_label), tool_info[tool_type].tool_options->title); + gtk_pixmap_set (GTK_PIXMAP (options_pixmap), tool_get_pixmap (tool_type), NULL); + gtk_widget_queue_draw (options_pixmap); + if (tool_info[tool_type].tool_options->reset_func) gtk_widget_set_sensitive (options_reset_button, TRUE); else @@ -1163,3 +1219,9 @@ tool_active_PDB_string (void) return toolStr; } + +GdkPixmap * +tool_get_pixmap (ToolType type) +{ + return (tool_info[type].icon_pixmap); +} diff --git a/app/tools/tools.h b/app/tools/tools.h index 89cc079ffc..efc2650704 100644 --- a/app/tools/tools.h +++ b/app/tools/tools.h @@ -88,15 +88,16 @@ struct _ToolInfo { ToolOptions *tool_options; - gchar *tool_name; + gchar *tool_name; - gchar *menu_path; - gchar *menu_accel; + gchar *menu_path; + gchar *menu_accel; - gchar **icon_data; + gchar **icon_data; + GdkPixmap *icon_pixmap; - gchar *tool_desc; - gchar *private_tip; + gchar *tool_desc; + gchar *private_tip; ToolType tool_id; @@ -104,7 +105,7 @@ struct _ToolInfo ToolInfoFreeFunc free_func; ToolInfoInitFunc init_func; - GtkWidget *tool_widget; + GtkWidget *tool_widget; GimpContext *tool_context; }; @@ -135,4 +136,11 @@ void tool_options_dialog_free (void); gchar * tool_active_PDB_string (void); +/* don't unref this pixmap, it is static! */ +GdkPixmap * tool_get_pixmap (ToolType tool_type); + #endif /* __TOOLS_H__ */ + + + + diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c index bc6751e5b9..36a71e531b 100644 --- a/app/widgets/gimpdeviceinfo.c +++ b/app/widgets/gimpdeviceinfo.c @@ -735,7 +735,6 @@ void device_status_create (void) { DeviceInfo *device_info; - GdkPixmap *pixmap; GtkWidget *label; GList *list; gint i; @@ -815,9 +814,7 @@ device_status_create (void) deviceD->eventboxes[i] = gtk_event_box_new(); - pixmap = create_tool_pixmap (deviceD->table, RECT_SELECT); - deviceD->tools[i] = gtk_pixmap_new (pixmap, NULL); - gdk_pixmap_unref (pixmap); + deviceD->tools[i] = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); gtk_drag_source_set (deviceD->eventboxes[i], GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, @@ -984,7 +981,6 @@ device_status_update_current (void) void device_status_update (guint32 deviceid) { - GdkPixmap *pixmap; GdkDeviceInfo *gdk_info; DeviceInfo *device_info; guchar buffer[CELL_SIZE*3]; @@ -1022,10 +1018,9 @@ device_status_update (guint32 deviceid) { gtk_widget_show (deviceD->frames[i]); - pixmap = create_tool_pixmap (deviceD->table, - gimp_context_get_tool (device_info->context)); - gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), pixmap, NULL); - gdk_pixmap_unref (pixmap); + gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), + tool_get_pixmap (gimp_context_get_tool (device_info->context)), + NULL); gtk_widget_draw (deviceD->tools[i], NULL); gtk_widget_show (deviceD->tools[i]); diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c index bc6751e5b9..36a71e531b 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -735,7 +735,6 @@ void device_status_create (void) { DeviceInfo *device_info; - GdkPixmap *pixmap; GtkWidget *label; GList *list; gint i; @@ -815,9 +814,7 @@ device_status_create (void) deviceD->eventboxes[i] = gtk_event_box_new(); - pixmap = create_tool_pixmap (deviceD->table, RECT_SELECT); - deviceD->tools[i] = gtk_pixmap_new (pixmap, NULL); - gdk_pixmap_unref (pixmap); + deviceD->tools[i] = gtk_pixmap_new (tool_get_pixmap (RECT_SELECT), NULL); gtk_drag_source_set (deviceD->eventboxes[i], GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, @@ -984,7 +981,6 @@ device_status_update_current (void) void device_status_update (guint32 deviceid) { - GdkPixmap *pixmap; GdkDeviceInfo *gdk_info; DeviceInfo *device_info; guchar buffer[CELL_SIZE*3]; @@ -1022,10 +1018,9 @@ device_status_update (guint32 deviceid) { gtk_widget_show (deviceD->frames[i]); - pixmap = create_tool_pixmap (deviceD->table, - gimp_context_get_tool (device_info->context)); - gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), pixmap, NULL); - gdk_pixmap_unref (pixmap); + gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]), + tool_get_pixmap (gimp_context_get_tool (device_info->context)), + NULL); gtk_widget_draw (deviceD->tools[i], NULL); gtk_widget_show (deviceD->tools[i]); diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index bdb28f4684..7906b8da6a 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -939,7 +939,6 @@ gimp_dnd_get_tool_icon (GtkWidget *widget, GtkSignalFunc get_tool_func, gpointer get_tool_data) { - GdkPixmap *tool_pixmap; GtkWidget *tool_icon; ToolType tool_type; @@ -949,11 +948,7 @@ gimp_dnd_get_tool_icon (GtkWidget *widget, if (((gint) tool_type < 0) || ((gint) tool_type >= num_tools)) return NULL; - tool_pixmap = create_tool_pixmap (widget, tool_type); - - tool_icon = gtk_pixmap_new (tool_pixmap, NULL); - - gdk_pixmap_unref (tool_pixmap); + tool_icon = gtk_pixmap_new (tool_get_pixmap (tool_type), NULL); return tool_icon; }