app/widgets/Makefile.am new toolbox area which shows the active image.

2004-05-31  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/gimptoolbox-image-area.[ch]: new toolbox area which
	shows the active image.

	* app/config/gimpguiconfig.[ch]
	* app/config/gimprc-blurbs.h: added config options to control the
	visibility of the toolbox' color, indicator and image areas.

	* app/widgets/gimptoolbox.[ch]: added the image area and honor the
	new config options. Put the various areas into their own wrap box.

	* app/widgets/gimptoolbox-dnd.c: changed accordingly.

	* app/widgets/gimphelp-ids.h: added a help ID for the image area.

	* app/widgets/gimptoolbox-indicator-area.c: made the previews
	a bit larger, cleanup.

	* app/gui/preferences-dialog.c: added a "Toolbox" page as GUI for
	the new config options.

	* themes/Default/images/preferences/Makefile.am
	* themes/Default/images/preferences/toolbox.png: a (wrong) icon
	for the "Toolbox" prefs page. Needs to be replaced.
This commit is contained in:
Michael Natterer 2004-05-31 20:30:52 +00:00 committed by Michael Natterer
parent 4c03f0156c
commit dbc49d9a11
16 changed files with 532 additions and 161 deletions

View File

@ -1,3 +1,30 @@
2004-05-31 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/gimptoolbox-image-area.[ch]: new toolbox area which
shows the active image.
* app/config/gimpguiconfig.[ch]
* app/config/gimprc-blurbs.h: added config options to control the
visibility of the toolbox' color, indicator and image areas.
* app/widgets/gimptoolbox.[ch]: added the image area and honor the
new config options. Put the various areas into their own wrap box.
* app/widgets/gimptoolbox-dnd.c: changed accordingly.
* app/widgets/gimphelp-ids.h: added a help ID for the image area.
* app/widgets/gimptoolbox-indicator-area.c: made the previews
a bit larger, cleanup.
* app/gui/preferences-dialog.c: added a "Toolbox" page as GUI for
the new config options.
* themes/Default/images/preferences/Makefile.am
* themes/Default/images/preferences/toolbox.png: a (wrong) icon
for the "Toolbox" prefs page. Needs to be replaced.
2004-05-31 Sven Neumann <sven@gimp.org>
* app/widgets/Makefile.am

View File

@ -79,6 +79,9 @@ enum
PROP_RESTORE_ACCELS,
PROP_LAST_OPENED_SIZE,
PROP_MAX_NEW_IMAGE_SIZE,
PROP_TOOLBOX_COLOR_AREA,
PROP_TOOLBOX_FOO_AREA,
PROP_TOOLBOX_IMAGE_AREA,
PROP_THEME_PATH,
PROP_THEME,
PROP_USE_HELP,
@ -206,6 +209,21 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
MAX_NEW_IMAGE_SIZE_BLURB,
0, GIMP_MAX_MEMSIZE, 1 << 26,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_COLOR_AREA,
"toolbox-color-area",
TOOLBOX_COLOR_AREA_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_FOO_AREA,
"toolbox-foo-area",
TOOLBOX_FOO_AREA_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_IMAGE_AREA,
"toolbox-image-area",
TOOLBOX_IMAGE_AREA_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
"theme-path", THEME_PATH_BLURB,
GIMP_PARAM_PATH_DIR_LIST,
@ -321,6 +339,15 @@ gimp_gui_config_set_property (GObject *object,
case PROP_MAX_NEW_IMAGE_SIZE:
gui_config->max_new_image_size = g_value_get_uint64 (value);
break;
case PROP_TOOLBOX_COLOR_AREA:
gui_config->toolbox_color_area = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_FOO_AREA:
gui_config->toolbox_foo_area = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_IMAGE_AREA:
gui_config->toolbox_image_area = g_value_get_boolean (value);
break;
case PROP_THEME_PATH:
g_free (gui_config->theme_path);
gui_config->theme_path = g_value_dup_string (value);
@ -417,6 +444,15 @@ gimp_gui_config_get_property (GObject *object,
case PROP_MAX_NEW_IMAGE_SIZE:
g_value_set_uint64 (value, gui_config->max_new_image_size);
break;
case PROP_TOOLBOX_COLOR_AREA:
g_value_set_boolean (value, gui_config->toolbox_color_area);
break;
case PROP_TOOLBOX_FOO_AREA:
g_value_set_boolean (value, gui_config->toolbox_foo_area);
break;
case PROP_TOOLBOX_IMAGE_AREA:
g_value_set_boolean (value, gui_config->toolbox_image_area);
break;
case PROP_THEME_PATH:
g_value_set_string (value, gui_config->theme_path);
break;

View File

@ -57,6 +57,9 @@ struct _GimpGuiConfig
gboolean restore_accels;
gint last_opened_size;
guint64 max_new_image_size;
gboolean toolbox_color_area;
gboolean toolbox_foo_area;
gboolean toolbox_image_area;
gchar *theme_path;
gchar *theme;
gboolean use_help;

View File

@ -351,6 +351,10 @@ N_("The tile cache is used to make sure the GIMP doesn't thrash " \
"the GIMP to use more memory. Conversely, a smaller cache size " \
"causes the GIMP to use more swap space and less memory.")
#define TOOLBOX_COLOR_AREA_BLURB NULL
#define TOOLBOX_FOO_AREA_BLURB NULL
#define TOOLBOX_IMAGE_AREA_BLURB NULL
#define TOOLBOX_WINDOW_HINT_BLURB \
N_("The window type hint that is set on the toolbox. This may affect " \
"how your window manager decorates and handles the toolbox window.")

View File

@ -1375,6 +1375,38 @@ prefs_dialog_new (Gimp *gimp,
size_group = NULL;
/*************************/
/* Interface / Toolbox */
/*************************/
vbox = prefs_notebook_append_page (gimp,
GTK_NOTEBOOK (notebook),
_("Toolbox"),
"toolbox.png",
GTK_TREE_STORE (tree),
_("Toolbox"),
GIMP_HELP_PREFS_TOOLBOX,
&top_iter,
&child_iter,
page_index++);
/* Appearance */
vbox2 = prefs_frame_new (_("Appearance"),
GTK_CONTAINER (vbox), FALSE);
prefs_check_button_add_with_icon (object, "toolbox-color-area",
_("Show Foreground & Background _Color"),
GIMP_STOCK_DEFAULT_COLORS,
GTK_BOX (vbox2));
prefs_check_button_add_with_icon (object, "toolbox-foo-area",
_("Show Active _Brush, Pattern & Gradient"),
GIMP_STOCK_BRUSH,
GTK_BOX (vbox2));
prefs_check_button_add_with_icon (object, "toolbox-image-area",
_("Show Active _Image"),
GIMP_STOCK_IMAGE,
GTK_BOX (vbox2));
/*******************************/
/* Interface / Input Devices */
/*******************************/

View File

@ -1375,6 +1375,38 @@ prefs_dialog_new (Gimp *gimp,
size_group = NULL;
/*************************/
/* Interface / Toolbox */
/*************************/
vbox = prefs_notebook_append_page (gimp,
GTK_NOTEBOOK (notebook),
_("Toolbox"),
"toolbox.png",
GTK_TREE_STORE (tree),
_("Toolbox"),
GIMP_HELP_PREFS_TOOLBOX,
&top_iter,
&child_iter,
page_index++);
/* Appearance */
vbox2 = prefs_frame_new (_("Appearance"),
GTK_CONTAINER (vbox), FALSE);
prefs_check_button_add_with_icon (object, "toolbox-color-area",
_("Show Foreground & Background _Color"),
GIMP_STOCK_DEFAULT_COLORS,
GTK_BOX (vbox2));
prefs_check_button_add_with_icon (object, "toolbox-foo-area",
_("Show Active _Brush, Pattern & Gradient"),
GIMP_STOCK_BRUSH,
GTK_BOX (vbox2));
prefs_check_button_add_with_icon (object, "toolbox-image-area",
_("Show Active _Image"),
GIMP_STOCK_IMAGE,
GTK_BOX (vbox2));
/*******************************/
/* Interface / Input Devices */
/*******************************/

View File

@ -200,6 +200,8 @@ libappwidgets_a_sources = \
gimptoolbox-color-area.h \
gimptoolbox-dnd.c \
gimptoolbox-dnd.h \
gimptoolbox-image-area.c \
gimptoolbox-image-area.h \
gimptoolbox-indicator-area.c \
gimptoolbox-indicator-area.h \
gimptooldialog.c \

View File

@ -359,6 +359,7 @@
#define GIMP_HELP_PREFS_INTERFACE "gimp-prefs-interface"
#define GIMP_HELP_PREFS_HELP "gimp-prefs-help"
#define GIMP_HELP_PREFS_TOOL_OPTIONS "gimp-prefs-tool-options"
#define GIMP_HELP_PREFS_TOOLBOX "gimp-prefs-toolbox"
#define GIMP_HELP_PREFS_INPUT_DEVICES "gimp-prefs-input-devices"
#define GIMP_HELP_PREFS_IMAGE_WINDOW "gimp-prefs-image-window"
#define GIMP_HELP_PREFS_IMAGE_WINDOW_APPEARANCE "gimp-prefs-image-window-appearance"

View File

@ -65,21 +65,21 @@ gimp_toolbox_dnd_init (GimpToolbox *toolbox)
gimp_dnd_file_dest_add (GTK_WIDGET (toolbox), gimp_dnd_open_files, NULL);
gimp_dnd_file_dest_add (toolbox->wbox, gimp_dnd_open_files, NULL);
gimp_dnd_file_dest_add (toolbox->tool_wbox, gimp_dnd_open_files, NULL);
gimp_dnd_viewable_dest_add (toolbox->wbox, GIMP_TYPE_LAYER,
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_LAYER,
gimp_toolbox_drop_drawable,
dock->context);
gimp_dnd_viewable_dest_add (toolbox->wbox, GIMP_TYPE_LAYER_MASK,
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_LAYER_MASK,
gimp_toolbox_drop_drawable,
dock->context);
gimp_dnd_viewable_dest_add (toolbox->wbox, GIMP_TYPE_CHANNEL,
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_CHANNEL,
gimp_toolbox_drop_drawable,
dock->context);
gimp_dnd_viewable_dest_add (toolbox->wbox, GIMP_TYPE_TOOL_INFO,
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_TOOL_INFO,
gimp_toolbox_drop_tool,
dock->context);
gimp_dnd_viewable_dest_add (toolbox->wbox, GIMP_TYPE_BUFFER,
gimp_dnd_viewable_dest_add (toolbox->tool_wbox, GIMP_TYPE_BUFFER,
gimp_toolbox_drop_buffer,
dock->context);
}

View File

@ -0,0 +1,108 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "gimpdialogfactory.h"
#include "gimpdnd.h"
#include "gimppreview.h"
#include "gimptoolbox.h"
#include "gimptoolbox-image-area.h"
#include "gimp-intl.h"
#define CELL_WIDTH 48
#define CELL_HEIGHT 48
static void
image_preview_clicked (GtkWidget *widget,
GdkModifierType state,
GimpToolbox *toolbox)
{
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
gtk_widget_get_screen (widget),
"gimp-image-list|gimp-image-grid", -1);
}
static void
image_preview_drop_image (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context = GIMP_CONTEXT (data);
gimp_context_set_image (context, GIMP_IMAGE (viewable));
}
/* public functions */
GtkWidget *
gimp_toolbox_image_area_create (GimpToolbox *toolbox,
gint width,
gint height)
{
GimpContext *context;
GtkWidget *image_preview;
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
context = GIMP_DOCK (toolbox)->context;
image_preview =
gimp_preview_new_full_by_types (GIMP_TYPE_PREVIEW, GIMP_TYPE_IMAGE,
width, height, 0,
FALSE, TRUE, TRUE);
gimp_preview_set_viewable (GIMP_PREVIEW (image_preview),
(GimpViewable *) gimp_context_get_image (context));
gtk_widget_show (image_preview);
gimp_help_set_help_data (image_preview,
_("The active image.\n"
"Click to open the Image Dialog."), NULL);
g_signal_connect_object (context, "image_changed",
G_CALLBACK (gimp_preview_set_viewable),
image_preview,
G_CONNECT_SWAPPED);
g_signal_connect (image_preview, "clicked",
G_CALLBACK (image_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (image_preview,
GIMP_TYPE_IMAGE,
image_preview_drop_image,
context);
return image_preview;
}

View File

@ -0,0 +1,28 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_TOOLBOX_IMAGE_AREA_H__
#define __GIMP_TOOLBOX_IMAGE_AREA_H__
GtkWidget * gimp_toolbox_image_area_create (GimpToolbox *toolbox,
gint width,
gint height);
#endif /* __GIMP_TOOLBOX_IMAGE_AREA_H__ */

View File

@ -41,10 +41,10 @@
#include "gimp-intl.h"
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
#define CELL_SIZE 26 /* The size of the previews */
#define GRAD_CELL_WIDTH 54 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 14 /* The height of the gradient preview */
#define CELL_SPACING 2 /* How much between brush and pattern cells */
static void
@ -62,9 +62,7 @@ brush_preview_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
GimpContext *context = GIMP_CONTEXT (data);
gimp_context_set_brush (context, GIMP_BRUSH (viewable));
}
@ -84,9 +82,7 @@ pattern_preview_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
GimpContext *context = GIMP_CONTEXT (data);
gimp_context_set_pattern (context, GIMP_PATTERN (viewable));
}
@ -106,9 +102,7 @@ gradient_preview_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
GimpContext *context = GIMP_CONTEXT (data);
gimp_context_set_gradient (context, GIMP_GRADIENT (viewable));
}
@ -130,8 +124,8 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
context = GIMP_DOCK (toolbox)->context;
indicator_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_PADDING);
gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_PADDING);
gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_SPACING);
gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_SPACING);
/* brush preview */
@ -142,21 +136,21 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
gimp_preview_set_viewable (GIMP_PREVIEW (brush_preview),
GIMP_VIEWABLE (gimp_context_get_brush (context)));
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_preview,
0, 1, 0, 1);
0, 1, 0, 1);
gtk_widget_show (brush_preview);
gimp_help_set_help_data (brush_preview,
_("The active brush.\n"
"Click to open the Brush Dialog."), NULL);
_("The active brush.\n"
"Click to open the Brush Dialog."), NULL);
g_signal_connect_object (context, "brush_changed",
G_CALLBACK (gimp_preview_set_viewable),
brush_preview,
G_CONNECT_SWAPPED);
G_CALLBACK (gimp_preview_set_viewable),
brush_preview,
G_CONNECT_SWAPPED);
g_signal_connect (brush_preview, "clicked",
G_CALLBACK (brush_preview_clicked),
toolbox);
G_CALLBACK (brush_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (brush_preview,
GIMP_TYPE_BRUSH,
@ -173,21 +167,21 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
GIMP_VIEWABLE (gimp_context_get_pattern (context)));
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_preview,
1, 2, 0, 1);
1, 2, 0, 1);
gtk_widget_show (pattern_preview);
gimp_help_set_help_data (pattern_preview,
_("The active pattern.\n"
"Click to open the Pattern Dialog."), NULL);
_("The active pattern.\n"
"Click to open the Pattern Dialog."), NULL);
g_signal_connect_object (context, "pattern_changed",
G_CALLBACK (gimp_preview_set_viewable),
pattern_preview,
G_CONNECT_SWAPPED);
G_CALLBACK (gimp_preview_set_viewable),
pattern_preview,
G_CONNECT_SWAPPED);
g_signal_connect (pattern_preview, "clicked",
G_CALLBACK (pattern_preview_clicked),
toolbox);
G_CALLBACK (pattern_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (pattern_preview,
GIMP_TYPE_PATTERN,
@ -204,21 +198,21 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
GIMP_VIEWABLE (gimp_context_get_gradient (context)));
gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_preview,
0, 2, 1, 2);
0, 2, 1, 2);
gtk_widget_show (gradient_preview);
gimp_help_set_help_data (gradient_preview,
_("The active gradient.\n"
"Click to open the Gradient Dialog."), NULL);
_("The active gradient.\n"
"Click to open the Gradient Dialog."), NULL);
g_signal_connect_object (context, "gradient_changed",
G_CALLBACK (gimp_preview_set_viewable),
gradient_preview,
G_CONNECT_SWAPPED);
G_CALLBACK (gimp_preview_set_viewable),
gradient_preview,
G_CONNECT_SWAPPED);
g_signal_connect (gradient_preview, "clicked",
G_CALLBACK (gradient_preview_clicked),
toolbox);
G_CALLBACK (gradient_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (gradient_preview,
GIMP_TYPE_GRADIENT,

View File

@ -40,6 +40,7 @@
#include "gimptoolbox.h"
#include "gimptoolbox-color-area.h"
#include "gimptoolbox-dnd.h"
#include "gimptoolbox-image-area.h"
#include "gimptoolbox-indicator-area.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
@ -57,53 +58,58 @@
/* local function prototypes */
static void gimp_toolbox_class_init (GimpToolboxClass *klass);
static void gimp_toolbox_init (GimpToolbox *toolbox);
static void gimp_toolbox_class_init (GimpToolboxClass *klass);
static void gimp_toolbox_init (GimpToolbox *toolbox);
static GObject * gimp_toolbox_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static GObject * gimp_toolbox_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static gboolean gimp_toolbox_delete_event (GtkWidget *widget,
GdkEventAny *event);
static void gimp_toolbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_toolbox_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gimp_toolbox_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_set_geometry (GimpToolbox *toolbox);
static gboolean gimp_toolbox_delete_event (GtkWidget *widget,
GdkEventAny *event);
static void gimp_toolbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_toolbox_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gimp_toolbox_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_set_geometry (GimpToolbox *toolbox);
static void toolbox_create_tools (GimpToolbox *toolbox,
GimpContext *context);
static void toolbox_create_color_area (GimpToolbox *toolbox,
GimpContext *context);
static void toolbox_create_indicator_area (GimpToolbox *toolbox,
GimpContext *context);
static void toolbox_create_tools (GimpToolbox *toolbox,
GimpContext *context);
static GtkWidget * toolbox_create_color_area (GimpToolbox *toolbox,
GimpContext *context);
static GtkWidget * toolbox_create_foo_area (GimpToolbox *toolbox,
GimpContext *context);
static GtkWidget * toolbox_create_image_area (GimpToolbox *toolbox,
GimpContext *context);
static void toolbox_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void toolbox_area_notify (GimpGuiConfig *config,
GParamSpec *pspec,
GtkWidget *area);
static void toolbox_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void toolbox_tool_reorder (GimpContainer *container,
GimpToolInfo *tool_info,
gint index,
GtkWidget *wrap_box);
static void toolbox_tool_visible_notify (GimpToolInfo *tool_info,
GParamSpec *pspec,
GtkWidget *button);
static void toolbox_tool_reorder (GimpContainer *container,
GimpToolInfo *tool_info,
gint index,
GtkWidget *wrap_box);
static void toolbox_tool_visible_notify (GimpToolInfo *tool_info,
GParamSpec *pspec,
GtkWidget *button);
static void toolbox_tool_button_toggled (GtkWidget *widget,
GimpToolInfo *tool_info);
static gboolean toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpToolbox *toolbox);
static void toolbox_tool_button_toggled (GtkWidget *widget,
GimpToolInfo *tool_info);
static gboolean toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpToolbox *toolbox);
static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp);
static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp);
/* local variables */
@ -221,14 +227,23 @@ gimp_toolbox_constructor (GType type,
gtk_window_add_accel_group (GTK_WINDOW (toolbox),
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (manager)));
toolbox->wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (toolbox->wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (toolbox->wbox),
toolbox->tool_wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (toolbox->tool_wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (toolbox->tool_wbox),
GTK_JUSTIFY_LEFT);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (toolbox->wbox), 5.0 / 6.0);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (toolbox->tool_wbox), 5.0 / 6.0);
gtk_box_pack_start (GTK_BOX (vbox), toolbox->wbox, FALSE, FALSE, 0);
gtk_widget_show (toolbox->wbox);
gtk_box_pack_start (GTK_BOX (vbox), toolbox->tool_wbox, FALSE, FALSE, 0);
gtk_widget_show (toolbox->tool_wbox);
toolbox->area_wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (toolbox->area_wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (toolbox->area_wbox),
GTK_JUSTIFY_LEFT);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (toolbox->area_wbox), 5.0 / 6.0);
gtk_box_pack_start (GTK_BOX (vbox), toolbox->area_wbox, FALSE, FALSE, 0);
gtk_widget_show (toolbox->area_wbox);
/* We need to know when the current device changes, so we can update
* the correct tool - to do this we connect to motion events.
@ -256,12 +271,41 @@ gimp_toolbox_constructor (GType type,
}
toolbox_create_tools (toolbox, context);
toolbox_create_color_area (toolbox, context);
toolbox_create_indicator_area (toolbox, context);
g_signal_connect_object (context, "tool_changed",
toolbox->color_area = toolbox_create_color_area (toolbox, context);
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (toolbox->area_wbox),
toolbox->color_area,
TRUE, TRUE, FALSE, TRUE, TRUE);
if (config->toolbox_color_area)
gtk_widget_show (toolbox->color_area);
g_signal_connect_object (config, "notify::toolbox-color-area",
G_CALLBACK (toolbox_area_notify),
toolbox->color_area, 0);
toolbox->foo_area = toolbox_create_foo_area (toolbox, context);
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->area_wbox), toolbox->foo_area,
TRUE, TRUE, FALSE, TRUE);
if (config->toolbox_foo_area)
gtk_widget_show (toolbox->foo_area);
g_signal_connect_object (config, "notify::toolbox-foo-area",
G_CALLBACK (toolbox_area_notify),
toolbox->foo_area, 0);
toolbox->image_area = toolbox_create_image_area (toolbox, context);
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->area_wbox), toolbox->image_area,
TRUE, TRUE, FALSE, TRUE);
if (config->toolbox_image_area)
gtk_widget_show (toolbox->image_area);
g_signal_connect_object (config, "notify::toolbox-image-area",
G_CALLBACK (toolbox_area_notify),
toolbox->image_area, 0);
g_signal_connect_object (context, "tool-changed",
G_CALLBACK (toolbox_tool_changed),
toolbox->wbox,
toolbox->tool_wbox,
0);
gimp_toolbox_dnd_init (GIMP_TOOLBOX (toolbox));
@ -284,9 +328,11 @@ static void
gimp_toolbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
Gimp *gimp;
GimpToolInfo *tool_info;
GtkWidget *tool_button;
GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
Gimp *gimp;
GimpGuiConfig *config;
GimpToolInfo *tool_info;
GtkWidget *tool_button;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
@ -296,6 +342,8 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
gimp = GIMP_DOCK (widget)->context->gimp;
config = GIMP_GUI_CONFIG (gimp->config);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-rect-select-tool");
@ -303,20 +351,13 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
if (tool_button)
{
GimpToolbox *toolbox;
GtkRequisition button_requisition;
GtkRequisition color_requisition;
GtkRequisition indicator_requisition;
GList *list;
gint n_tools;
gint tool_rows;
gint tool_columns;
toolbox = GIMP_TOOLBOX (widget);
gtk_widget_size_request (tool_button, &button_requisition);
gtk_widget_size_request (toolbox->color_area, &color_requisition);
gtk_widget_size_request (toolbox->indicator_area, &indicator_requisition);
gtk_widget_size_request (tool_button, &button_requisition);
for (list = GIMP_LIST (gimp->tool_info_list)->list, n_tools = 0;
list;
@ -340,25 +381,55 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
toolbox->tool_rows = tool_rows;
toolbox->tool_columns = tool_columns;
if ((tool_columns * button_requisition.width) >=
(color_requisition.width + indicator_requisition.width))
{
gtk_widget_set_size_request (toolbox->wbox, -1,
tool_rows *
button_requisition.height +
MAX (color_requisition.height,
indicator_requisition.height));
}
else
{
gtk_widget_set_size_request (toolbox->wbox, -1,
tool_rows *
button_requisition.height +
color_requisition.height +
indicator_requisition.height);
}
gtk_widget_set_size_request (toolbox->tool_wbox, -1,
tool_rows * button_requisition.height);
}
}
{
GtkRequisition color_requisition;
GtkRequisition foo_requisition;
GtkRequisition image_requisition;
gint width;
gint height;
gint n_areas;
gint area_rows;
gint area_columns;
gtk_widget_get_child_requisition (toolbox->color_area,
&color_requisition);
gtk_widget_get_child_requisition (toolbox->foo_area,
&foo_requisition);
gtk_widget_get_child_requisition (toolbox->image_area,
&image_requisition);
width = MAX (color_requisition.width,
MAX (foo_requisition.width,
image_requisition.width));
height = MAX (color_requisition.height,
MAX (foo_requisition.height,
image_requisition.height));
n_areas = (config->toolbox_color_area +
config->toolbox_foo_area +
config->toolbox_image_area);
area_columns = MAX (1, (allocation->width / width));
area_rows = n_areas / area_columns;
if (n_areas % area_columns)
area_rows++;
if (toolbox->area_rows != area_rows ||
toolbox->area_columns != area_columns)
{
toolbox->area_rows = area_rows;
toolbox->area_columns = area_columns;
gtk_widget_set_size_request (toolbox->area_wbox, -1,
area_rows * height);
}
}
}
static void
@ -446,28 +517,16 @@ gimp_toolbox_set_geometry (GimpToolbox *toolbox)
GtkWidget *main_vbox;
GtkRequisition menubar_requisition;
GtkRequisition button_requisition;
GtkRequisition color_requisition;
GtkRequisition indicator_requisition;
gint border_width;
gint spacing;
gint separator_height;
GdkGeometry geometry;
main_vbox = GIMP_DOCK (toolbox)->main_vbox;
gtk_widget_size_request (toolbox->menu_bar, &menubar_requisition);
gtk_widget_size_request (tool_button, &button_requisition);
gtk_widget_size_request (toolbox->color_area, &color_requisition);
gtk_widget_size_request (toolbox->indicator_area, &indicator_requisition);
gtk_widget_size_request (toolbox->menu_bar, &menubar_requisition);
gtk_widget_size_request (tool_button, &button_requisition);
border_width = gtk_container_get_border_width (GTK_CONTAINER (main_vbox));
spacing = gtk_box_get_spacing (GTK_BOX (main_vbox));
gtk_widget_style_get (GTK_WIDGET (toolbox),
"separator_height", &separator_height,
NULL);
geometry.min_width = (2 * border_width +
2 * button_requisition.width);
geometry.min_height = -1;
@ -647,7 +706,7 @@ toolbox_create_tools (GimpToolbox *toolbox,
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), button,
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->tool_wbox), button,
FALSE, FALSE, FALSE, FALSE);
if (tool_info->visible)
@ -754,10 +813,10 @@ toolbox_create_tools (GimpToolbox *toolbox,
g_signal_connect_object (context->gimp->tool_info_list, "reorder",
G_CALLBACK (toolbox_tool_reorder),
toolbox->wbox, 0);
toolbox->tool_wbox, 0);
}
static void
static GtkWidget *
toolbox_create_color_area (GimpToolbox *toolbox,
GimpContext *context)
{
@ -767,57 +826,97 @@ toolbox_create_color_area (GimpToolbox *toolbox,
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (toolbox->wbox), frame,
TRUE, TRUE, FALSE, TRUE, TRUE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
gimp_help_set_help_data (alignment, NULL, GIMP_HELP_TOOLBOX_COLOR_AREA);
col_area = gimp_toolbox_color_area_create (toolbox, 54, 42);
gtk_container_add (GTK_CONTAINER (alignment), col_area);
gtk_widget_show (col_area);
gimp_help_set_help_data
(col_area, _("Foreground & background colors. The black and white squares "
"reset colors. The arrows swap colors. Double click to open "
"the color selection dialog."), NULL);
gtk_widget_show (col_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
toolbox->color_area = frame;
return frame;
}
static void
toolbox_create_indicator_area (GimpToolbox *toolbox,
GimpContext *context)
static GtkWidget *
toolbox_create_foo_area (GimpToolbox *toolbox,
GimpContext *context)
{
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *ind_area;
GtkWidget *foo_area;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), frame,
TRUE, TRUE, FALSE, TRUE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
gimp_help_set_help_data (alignment, NULL, GIMP_HELP_TOOLBOX_INDICATOR_AREA);
ind_area = gimp_toolbox_indicator_area_create (toolbox);
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
foo_area = gimp_toolbox_indicator_area_create (toolbox);
gtk_container_add (GTK_CONTAINER (alignment), foo_area);
gtk_widget_show (foo_area);
gtk_widget_show (ind_area);
return frame;
}
static GtkWidget *
toolbox_create_image_area (GimpToolbox *toolbox,
GimpContext *context)
{
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *image_area;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show (alignment);
gtk_widget_show (frame);
toolbox->indicator_area = frame;
gimp_help_set_help_data (alignment, NULL, GIMP_HELP_TOOLBOX_INDICATOR_AREA);
image_area = gimp_toolbox_image_area_create (toolbox, 52, 42);
gtk_container_add (GTK_CONTAINER (alignment), image_area);
gtk_widget_show (image_area);
return frame;
}
static void
toolbox_area_notify (GimpGuiConfig *config,
GParamSpec *pspec,
GtkWidget *area)
{
GtkRequisition foo;
gboolean visible;
if (config->toolbox_color_area ||
config->toolbox_foo_area ||
config->toolbox_image_area)
{
gtk_widget_show (area->parent);
}
else
{
gtk_widget_hide (area->parent);
}
g_object_get (config, pspec->name, &visible, NULL);
g_object_set (area, "visible", visible, NULL);
}
static void

View File

@ -38,12 +38,16 @@ struct _GimpToolbox
GimpDock parent_instance;
GtkWidget *menu_bar;
GtkWidget *wbox;
GtkWidget *tool_wbox;
GtkWidget *area_wbox;
GtkWidget *color_area;
GtkWidget *indicator_area;
GtkWidget *foo_area;
GtkWidget *image_area;
gint tool_rows;
gint tool_columns;
gint area_rows;
gint area_columns;
};
struct _GimpToolboxClass

View File

@ -27,6 +27,7 @@ PREFS_IMAGES = \
monitor.png \
new-image.png \
session.png \
toolbox.png \
tool-options.png \
window-management.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB