2001-01-22 11:30:42 +08:00
|
|
|
/* 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"
|
|
|
|
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2001-01-22 11:30:42 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "widgets-types.h"
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimplist.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gimpdevices.h"
|
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimpitemfactory.h"
|
|
|
|
#include "gimptoolbox.h"
|
|
|
|
#include "gimptoolbox-color-area.h"
|
2003-06-06 23:14:47 +08:00
|
|
|
#include "gimptoolbox-dnd.h"
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gimptoolbox-indicator-area.h"
|
2003-07-02 17:54:48 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gtkhwrapbox.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-01-22 11:30:42 +08:00
|
|
|
|
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
#define DEFAULT_TOOL_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
2002-10-16 03:07:06 +08:00
|
|
|
#define DEFAULT_BUTTON_RELIEF GTK_RELIEF_NONE
|
2002-03-19 03:34:06 +08:00
|
|
|
|
|
|
|
|
2001-12-12 09:16:39 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
static void gimp_toolbox_class_init (GimpToolboxClass *klass);
|
|
|
|
static void gimp_toolbox_init (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);
|
2002-10-25 21:21:54 +08:00
|
|
|
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);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
static void toolbox_create_tools (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context);
|
2002-03-15 01:07:02 +08:00
|
|
|
static void toolbox_create_color_area (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context);
|
2002-03-15 01:07:02 +08:00
|
|
|
static void toolbox_create_indicator_area (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context);
|
|
|
|
|
|
|
|
static void toolbox_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void toolbox_tool_button_toggled (GtkWidget *widget,
|
2002-10-25 21:21:54 +08:00
|
|
|
GimpToolInfo *tool_info);
|
2001-12-12 09:16:39 +08:00
|
|
|
static gboolean toolbox_tool_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
2002-03-15 01:07:02 +08:00
|
|
|
GimpToolbox *toolbox);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
static gboolean toolbox_check_device (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
2002-10-25 21:21:54 +08:00
|
|
|
Gimp *gimp);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2001-01-22 11:30:42 +08:00
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
static GimpDockClass *parent_class = NULL;
|
|
|
|
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
GType
|
|
|
|
gimp_toolbox_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
if (! type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo type_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpToolboxClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) gimp_toolbox_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpToolbox),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_toolbox_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
type = g_type_register_static (GIMP_TYPE_DOCK,
|
|
|
|
"GimpToolbox",
|
|
|
|
&type_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_class_init (GimpToolboxClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
2002-10-25 21:21:54 +08:00
|
|
|
GimpDockClass *dock_class;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
2002-10-25 21:21:54 +08:00
|
|
|
dock_class = GIMP_DOCK_CLASS (klass);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
widget_class->delete_event = gimp_toolbox_delete_event;
|
|
|
|
widget_class->size_allocate = gimp_toolbox_size_allocate;
|
|
|
|
widget_class->style_set = gimp_toolbox_style_set;
|
2002-03-19 03:34:06 +08:00
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
dock_class->book_added = gimp_toolbox_book_added;
|
|
|
|
dock_class->book_removed = gimp_toolbox_book_removed;
|
|
|
|
|
2002-10-16 03:07:06 +08:00
|
|
|
gtk_widget_class_install_style_property
|
|
|
|
(widget_class,
|
|
|
|
g_param_spec_enum ("tool_icon_size",
|
|
|
|
NULL, NULL,
|
|
|
|
GTK_TYPE_ICON_SIZE,
|
|
|
|
DEFAULT_TOOL_ICON_SIZE,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
gtk_widget_class_install_style_property
|
|
|
|
(widget_class,
|
|
|
|
g_param_spec_enum ("button_relief",
|
|
|
|
NULL, NULL,
|
|
|
|
GTK_TYPE_RELIEF_STYLE,
|
|
|
|
DEFAULT_BUTTON_RELIEF,
|
|
|
|
G_PARAM_READABLE));
|
2002-03-15 01:07:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_init (GimpToolbox *toolbox)
|
2001-01-22 11:30:42 +08:00
|
|
|
{
|
2002-01-26 02:34:33 +08:00
|
|
|
GimpItemFactory *toolbox_factory;
|
|
|
|
GtkWidget *main_vbox;
|
2002-03-15 01:07:02 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
|
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (toolbox), "toolbox", "Gimp");
|
|
|
|
gtk_window_set_title (GTK_WINDOW (toolbox), _("The GIMP"));
|
2003-03-14 02:22:20 +08:00
|
|
|
|
2003-06-11 20:05:00 +08:00
|
|
|
/* Docks are utility windows by default, but the toolbox doesn't fit
|
2003-03-14 02:22:20 +08:00
|
|
|
* into this category. 'Normal' is not correct as well but there
|
|
|
|
* doesn't seem to be a better match :-(
|
|
|
|
*/
|
|
|
|
gtk_window_set_type_hint (GTK_WINDOW (toolbox), GDK_WINDOW_TYPE_HINT_NORMAL);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
main_vbox = GIMP_DOCK (toolbox)->main_vbox;
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (main_vbox), vbox, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
toolbox_factory = gimp_item_factory_from_path ("<Toolbox>");
|
|
|
|
|
|
|
|
toolbox->menu_bar = GTK_ITEM_FACTORY (toolbox_factory)->widget;
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toolbox->menu_bar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toolbox->menu_bar);
|
|
|
|
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (toolbox),
|
|
|
|
GTK_ITEM_FACTORY (toolbox_factory)->accel_group);
|
|
|
|
|
|
|
|
/* Connect the "F1" help key */
|
|
|
|
gimp_help_connect (GTK_WIDGET (toolbox),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"toolbox/toolbox.html");
|
|
|
|
|
|
|
|
toolbox->wbox = gtk_hwrap_box_new (FALSE);
|
|
|
|
gtk_wrap_box_set_justify (GTK_WRAP_BOX (toolbox->wbox), GTK_JUSTIFY_TOP);
|
2003-06-06 22:58:20 +08:00
|
|
|
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (toolbox->wbox),
|
|
|
|
GTK_JUSTIFY_LEFT);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toolbox->wbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toolbox->wbox);
|
2003-06-11 20:05:00 +08:00
|
|
|
|
|
|
|
/* A container that keeps references on the buttons that are not
|
|
|
|
* added to the toolbox. Just to make sure they are freed on exit.
|
|
|
|
*/
|
|
|
|
toolbox->trash = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), toolbox->trash);
|
2002-03-15 01:07:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_toolbox_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
2002-12-05 23:49:59 +08:00
|
|
|
gimp_exit (GIMP_DOCK (widget)->context->gimp, FALSE);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkWidget *tool_button;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
|
|
|
|
|
|
|
if (! GIMP_DOCK (widget)->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp = GIMP_DOCK (widget)->context->gimp;
|
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gimp->tool_info_list,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-rect-select-tool");
|
2002-03-15 01:07:02 +08:00
|
|
|
tool_button = g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
|
|
|
|
|
|
|
if (tool_button)
|
|
|
|
{
|
|
|
|
GimpToolbox *toolbox;
|
|
|
|
GtkRequisition button_requisition;
|
|
|
|
GtkRequisition color_requisition;
|
|
|
|
GtkRequisition indicator_requisition;
|
2003-06-06 22:58:20 +08:00
|
|
|
GList *list;
|
2002-03-15 01:07:02 +08:00
|
|
|
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);
|
|
|
|
|
2003-06-06 22:58:20 +08:00
|
|
|
for (list = GIMP_LIST (gimp->tool_info_list)->list, n_tools = 0;
|
|
|
|
list;
|
|
|
|
list = list->next)
|
|
|
|
{
|
|
|
|
tool_info = (GimpToolInfo *) list->data;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
2003-06-06 22:58:20 +08:00
|
|
|
if (tool_info->in_toolbox)
|
|
|
|
n_tools++;
|
|
|
|
}
|
2002-03-15 01:07:02 +08:00
|
|
|
|
2003-06-06 22:58:20 +08:00
|
|
|
tool_columns = MAX (1, (allocation->width / button_requisition.width));
|
|
|
|
tool_rows = n_tools / tool_columns;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
if (n_tools % tool_columns)
|
|
|
|
tool_rows++;
|
|
|
|
|
|
|
|
if (toolbox->tool_rows != tool_rows ||
|
|
|
|
toolbox->tool_columns != tool_columns)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
static void
|
|
|
|
gimp_toolbox_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *previous_style)
|
|
|
|
{
|
2002-10-16 03:07:06 +08:00
|
|
|
Gimp *gimp;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkWidget *tool_button;
|
|
|
|
GtkIconSize tool_icon_size;
|
|
|
|
GtkReliefStyle relief;
|
|
|
|
GList *list;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->style_set)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
|
|
|
|
|
|
|
|
if (! GIMP_DOCK (widget)->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp = GIMP_DOCK (widget)->context->gimp;
|
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
gtk_widget_style_get (widget,
|
|
|
|
"tool_icon_size", &tool_icon_size,
|
2002-10-16 03:07:06 +08:00
|
|
|
"button_relief", &relief,
|
2002-03-19 03:34:06 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
for (list = GIMP_LIST (gimp->tool_info_list)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
tool_info = GIMP_TOOL_INFO (list->data);
|
|
|
|
|
2003-06-06 22:58:20 +08:00
|
|
|
if (! tool_info->in_toolbox)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tool_button = g_object_get_data (G_OBJECT (tool_info),
|
|
|
|
"toolbox-button");
|
2002-03-19 03:34:06 +08:00
|
|
|
|
|
|
|
if (tool_button)
|
|
|
|
{
|
|
|
|
GtkImage *image;
|
|
|
|
gchar *stock_id;
|
|
|
|
|
|
|
|
image = GTK_IMAGE (GTK_BIN (tool_button)->child);
|
|
|
|
|
|
|
|
gtk_image_get_stock (image, &stock_id, NULL);
|
|
|
|
gtk_image_set_from_stock (image, stock_id, tool_icon_size);
|
2002-10-16 03:07:06 +08:00
|
|
|
|
2002-10-17 22:31:24 +08:00
|
|
|
gtk_button_set_relief (GTK_BUTTON (tool_button), relief);
|
2002-03-19 03:34:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
gimp_toolbox_set_geometry (GIMP_TOOLBOX (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_book_added (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook)
|
|
|
|
{
|
|
|
|
if (g_list_length (dock->dockbooks) == 1)
|
|
|
|
gimp_toolbox_set_geometry (GIMP_TOOLBOX (dock));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_book_removed (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook)
|
|
|
|
{
|
|
|
|
if (dock->dockbooks == NULL &&
|
|
|
|
! (GTK_OBJECT_FLAGS (dock) & GTK_IN_DESTRUCTION))
|
|
|
|
gimp_toolbox_set_geometry (GIMP_TOOLBOX (dock));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_set_geometry (GimpToolbox *toolbox)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkWidget *tool_button;
|
|
|
|
|
|
|
|
gimp = GIMP_DOCK (toolbox)->context->gimp;
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gimp->tool_info_list,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-rect-select-tool");
|
2002-03-15 01:07:02 +08:00
|
|
|
tool_button = g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
|
|
|
|
|
|
|
if (tool_button)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
main_vbox = GIMP_DOCK (toolbox)->main_vbox;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (main_vbox));
|
|
|
|
|
|
|
|
spacing = gtk_box_get_spacing (GTK_BOX (main_vbox));
|
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (toolbox),
|
2002-03-15 01:07:02 +08:00
|
|
|
"separator_height", &separator_height,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
geometry.min_width = (2 * border_width +
|
|
|
|
2 * button_requisition.width);
|
|
|
|
geometry.min_height = (2 * border_width +
|
|
|
|
spacing +
|
|
|
|
separator_height +
|
|
|
|
button_requisition.height +
|
|
|
|
menubar_requisition.height +
|
|
|
|
MAX (color_requisition.height,
|
|
|
|
indicator_requisition.height));
|
|
|
|
geometry.width_inc = button_requisition.width;
|
2002-10-25 21:21:54 +08:00
|
|
|
geometry.height_inc = (GIMP_DOCK (toolbox)->dockbooks ?
|
|
|
|
1 : button_requisition.height);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
gtk_window_set_geometry_hints (GTK_WINDOW (toolbox),
|
2002-03-15 01:07:02 +08:00
|
|
|
NULL,
|
|
|
|
&geometry,
|
2003-01-15 06:06:06 +08:00
|
|
|
GDK_HINT_MIN_SIZE |
|
|
|
|
GDK_HINT_RESIZE_INC |
|
|
|
|
GDK_HINT_USER_POS);
|
2002-03-15 01:07:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_toolbox_new (GimpDialogFactory *dialog_factory,
|
|
|
|
Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolbox *toolbox;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
2001-10-25 21:30:01 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
context = gimp_get_user_context (gimp);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox = g_object_new (GIMP_TYPE_TOOLBOX, NULL);
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-10-25 21:21:54 +08:00
|
|
|
gimp_dock_construct (GIMP_DOCK (toolbox), dialog_factory, context);
|
2001-05-01 21:16:59 +08:00
|
|
|
|
2001-01-22 11:30:42 +08:00
|
|
|
/* We need to know when the current device changes, so we can update
|
|
|
|
* the correct tool - to do this we connect to motion events.
|
|
|
|
* We can't just use EXTENSION_EVENTS_CURSOR though, since that
|
|
|
|
* would get us extension events for the mouse pointer, and our
|
|
|
|
* device would change to that and not change back. So we check
|
|
|
|
* manually that all devices have a cursor, before establishing the check.
|
|
|
|
*/
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
for (list = gdk_devices_list (); list; list = g_list_next (list))
|
2001-01-22 11:30:42 +08:00
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
if (! ((GdkDevice *) (list->data))->has_cursor)
|
2001-01-22 11:30:42 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-24 10:42:09 +08:00
|
|
|
if (! list) /* all devices have cursor */
|
2001-01-22 11:30:42 +08:00
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (toolbox, "motion_notify_event",
|
2001-07-25 10:22:05 +08:00
|
|
|
G_CALLBACK (toolbox_check_device),
|
2001-12-02 05:02:34 +08:00
|
|
|
gimp);
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-03-26 02:28:50 +08:00
|
|
|
gtk_widget_add_events (GTK_WIDGET (toolbox), GDK_POINTER_MOTION_MASK);
|
2002-03-15 01:07:02 +08:00
|
|
|
gtk_widget_set_extension_events (GTK_WIDGET (toolbox),
|
|
|
|
GDK_EXTENSION_EVENTS_CURSOR);
|
2001-01-22 11:30:42 +08:00
|
|
|
}
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox_create_tools (toolbox, context);
|
|
|
|
toolbox_create_color_area (toolbox, context);
|
|
|
|
toolbox_create_indicator_area (toolbox, context);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_object (context, "tool_changed",
|
2001-07-25 10:22:05 +08:00
|
|
|
G_CALLBACK (toolbox_tool_changed),
|
2003-01-06 06:07:10 +08:00
|
|
|
toolbox->wbox,
|
2001-07-25 10:22:05 +08:00
|
|
|
0);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2003-06-06 23:14:47 +08:00
|
|
|
gimp_toolbox_dnd_init (GIMP_TOOLBOX (toolbox));
|
2001-01-22 11:30:42 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
gimp_toolbox_style_set (GTK_WIDGET (toolbox), GTK_WIDGET (toolbox)->style);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
return GTK_WIDGET (toolbox);
|
2001-01-22 11:30:42 +08:00
|
|
|
}
|
|
|
|
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2002-04-22 22:13:06 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_toolbox_button_accel_find_func (GtkAccelKey *key,
|
|
|
|
GClosure *closure,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
return (GClosure *) data == closure;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_button_accel_changed (GtkAccelGroup *accel_group,
|
|
|
|
guint unused1,
|
|
|
|
GdkModifierType unused2,
|
|
|
|
GClosure *accel_closure,
|
|
|
|
GtkWidget *tool_button)
|
|
|
|
{
|
|
|
|
GClosure *button_closure;
|
|
|
|
|
|
|
|
button_closure = g_object_get_data (G_OBJECT (tool_button),
|
|
|
|
"toolbox-accel-closure");
|
|
|
|
|
|
|
|
if (accel_closure == button_closure)
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkAccelKey *accel_key;
|
|
|
|
gchar *tooltip;
|
|
|
|
|
|
|
|
tool_info = g_object_get_data (G_OBJECT (tool_button), "tool-info");
|
|
|
|
|
|
|
|
accel_key = gtk_accel_group_find (accel_group,
|
|
|
|
gimp_toolbox_button_accel_find_func,
|
|
|
|
accel_closure);
|
|
|
|
|
|
|
|
if (accel_key &&
|
|
|
|
accel_key->accel_key &&
|
|
|
|
accel_key->accel_flags & GTK_ACCEL_VISIBLE)
|
|
|
|
{
|
|
|
|
/* mostly taken from gtk-2-0/gtk/gtkaccellabel.c:1.46
|
|
|
|
*/
|
|
|
|
GtkAccelLabelClass *accel_label_class;
|
|
|
|
GString *gstring;
|
|
|
|
gboolean seen_mod = FALSE;
|
|
|
|
gunichar ch;
|
|
|
|
|
|
|
|
accel_label_class = g_type_class_peek (GTK_TYPE_ACCEL_LABEL);
|
|
|
|
|
|
|
|
gstring = g_string_new (tool_info->help);
|
|
|
|
g_string_append (gstring, " ");
|
|
|
|
|
|
|
|
if (accel_key->accel_mods & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
g_string_append (gstring, accel_label_class->mod_name_shift);
|
|
|
|
seen_mod = TRUE;
|
|
|
|
}
|
|
|
|
if (accel_key->accel_mods & GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
if (seen_mod)
|
|
|
|
g_string_append (gstring, accel_label_class->mod_separator);
|
|
|
|
g_string_append (gstring, accel_label_class->mod_name_control);
|
|
|
|
seen_mod = TRUE;
|
|
|
|
}
|
|
|
|
if (accel_key->accel_mods & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
if (seen_mod)
|
|
|
|
g_string_append (gstring, accel_label_class->mod_separator);
|
|
|
|
g_string_append (gstring, accel_label_class->mod_name_alt);
|
|
|
|
seen_mod = TRUE;
|
|
|
|
}
|
|
|
|
if (seen_mod)
|
|
|
|
g_string_append (gstring, accel_label_class->mod_separator);
|
|
|
|
|
|
|
|
ch = gdk_keyval_to_unicode (accel_key->accel_key);
|
|
|
|
if (ch && (g_unichar_isgraph (ch) || ch == ' ') &&
|
|
|
|
(ch < 0x80 || accel_label_class->latin1_to_char))
|
|
|
|
{
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case ' ':
|
|
|
|
g_string_append (gstring, "Space");
|
|
|
|
break;
|
|
|
|
case '\\':
|
|
|
|
g_string_append (gstring, "Backslash");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_string_append_unichar (gstring, g_unichar_toupper (ch));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *tmp;
|
|
|
|
|
|
|
|
tmp = gtk_accelerator_name (accel_key->accel_key, 0);
|
|
|
|
if (tmp[0] != 0 && tmp[1] == 0)
|
|
|
|
tmp[0] = g_ascii_toupper (tmp[0]);
|
|
|
|
g_string_append (gstring, tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
tooltip = g_string_free (gstring, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tooltip = g_strdup (tool_info->help);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_help_set_help_data (tool_button,
|
|
|
|
tooltip,
|
|
|
|
tool_info->help_data);
|
2002-08-22 22:48:28 +08:00
|
|
|
|
|
|
|
g_free (tooltip);
|
2002-04-22 22:13:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-12 09:16:39 +08:00
|
|
|
static void
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox_create_tools (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context)
|
|
|
|
{
|
2002-04-22 22:13:06 +08:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
GimpToolInfo *active_tool;
|
|
|
|
GList *list;
|
|
|
|
GSList *group = NULL;
|
|
|
|
|
|
|
|
item_factory = gimp_item_factory_from_path ("<Image>");
|
2002-03-11 02:31:42 +08:00
|
|
|
|
|
|
|
active_tool = gimp_context_get_tool (context);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *image;
|
2003-02-27 02:08:26 +08:00
|
|
|
const gchar *stock_id;
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *) list->data;
|
|
|
|
|
|
|
|
button = gtk_radio_button_new (group);
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
2001-12-12 09:16:39 +08:00
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
2003-06-06 22:58:20 +08:00
|
|
|
|
|
|
|
if (tool_info->in_toolbox)
|
|
|
|
{
|
|
|
|
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), button,
|
|
|
|
FALSE, FALSE, FALSE, FALSE);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
|
|
|
|
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
}
|
2003-06-11 20:05:00 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_container_add (GTK_CONTAINER (toolbox->trash), button);
|
|
|
|
}
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (tool_info), "toolbox-button", button);
|
2002-04-22 22:13:06 +08:00
|
|
|
g_object_set_data (G_OBJECT (button), "tool-info", tool_info);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
if (tool_info == active_tool)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "toggled",
|
2001-12-12 09:16:39 +08:00
|
|
|
G_CALLBACK (toolbox_tool_button_toggled),
|
|
|
|
tool_info);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "button_press_event",
|
2001-12-12 09:16:39 +08:00
|
|
|
G_CALLBACK (toolbox_tool_button_press),
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
if (item_factory)
|
|
|
|
{
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
gchar *menu_path;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
menu_path = gimp_menu_path_strip_uline (tool_info->menu_path);
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
menu_item =
|
|
|
|
gtk_item_factory_get_widget (GTK_ITEM_FACTORY (item_factory),
|
|
|
|
menu_path);
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
g_free (menu_path);
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
if (menu_item)
|
|
|
|
{
|
|
|
|
GList *accel_closures;
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
accel_closures = gtk_widget_list_accel_closures (menu_item);
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
if (g_list_length (accel_closures) != 1)
|
|
|
|
{
|
|
|
|
g_warning (G_STRLOC ": FIXME: g_list_length (accel_closures) != 1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GClosure *accel_closure;
|
|
|
|
GtkAccelGroup *accel_group;
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
accel_closure = (GClosure *) accel_closures->data;
|
2002-04-22 22:13:06 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
g_object_set_data (G_OBJECT (button), "toolbox-accel-closure",
|
|
|
|
accel_closure);
|
|
|
|
|
|
|
|
accel_group = gtk_accel_group_from_accel_closure (accel_closure);
|
|
|
|
|
|
|
|
g_signal_connect (accel_group, "accel_changed",
|
|
|
|
G_CALLBACK (gimp_toolbox_button_accel_changed),
|
|
|
|
button);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2003-07-02 17:54:48 +08:00
|
|
|
gimp_toolbox_button_accel_changed (accel_group,
|
|
|
|
0, 0,
|
|
|
|
accel_closure,
|
|
|
|
button);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (accel_closures);
|
|
|
|
}
|
|
|
|
}
|
2001-12-12 09:16:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox_create_color_area (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *alignment;
|
|
|
|
GtkWidget *col_area;
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
2002-03-15 01:07:02 +08:00
|
|
|
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (toolbox->wbox), frame,
|
|
|
|
TRUE, TRUE, FALSE, TRUE, TRUE);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (alignment, NULL, "#color_area");
|
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
col_area = gimp_toolbox_color_area_create (toolbox, 54, 42);
|
|
|
|
|
2001-12-12 09:16:39 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), col_area);
|
|
|
|
gimp_help_set_help_data
|
2002-06-08 20:15:11 +08:00
|
|
|
(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);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
gtk_widget_show (col_area);
|
|
|
|
gtk_widget_show (alignment);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox->color_area = frame;
|
2001-12-12 09:16:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox_create_indicator_area (GimpToolbox *toolbox,
|
2001-12-12 09:16:39 +08:00
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *alignment;
|
|
|
|
GtkWidget *ind_area;
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
2002-03-15 01:07:02 +08:00
|
|
|
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), frame,
|
|
|
|
TRUE, TRUE, FALSE, TRUE);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
ind_area = gimp_toolbox_indicator_area_create (toolbox);
|
2001-12-12 09:16:39 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
|
|
|
|
|
|
|
gtk_widget_show (ind_area);
|
|
|
|
gtk_widget_show (alignment);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
toolbox->indicator_area = frame;
|
2001-12-12 09:16:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
toolbox_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
GtkWidget *toolbox_button;
|
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
toolbox_button = g_object_get_data (G_OBJECT (tool_info),
|
|
|
|
"toolbox-button");
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
|
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func (toolbox_button,
|
2001-12-12 09:16:39 +08:00
|
|
|
toolbox_tool_button_toggled,
|
|
|
|
tool_info);
|
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbox_button),
|
|
|
|
TRUE);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func (toolbox_button,
|
2001-12-12 09:16:39 +08:00
|
|
|
toolbox_tool_button_toggled,
|
|
|
|
tool_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-22 11:30:42 +08:00
|
|
|
static void
|
2002-10-25 21:21:54 +08:00
|
|
|
toolbox_tool_button_toggled (GtkWidget *widget,
|
|
|
|
GimpToolInfo *tool_info)
|
2001-12-12 09:16:39 +08:00
|
|
|
{
|
2002-10-25 21:21:54 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
2001-12-12 09:16:39 +08:00
|
|
|
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
toolbox_tool_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
2002-03-15 01:07:02 +08:00
|
|
|
GimpToolbox *toolbox)
|
2001-12-12 09:16:39 +08:00
|
|
|
{
|
|
|
|
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
|
|
|
{
|
2002-03-15 01:07:02 +08:00
|
|
|
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-tool-options",
|
2002-03-10 23:05:58 +08:00
|
|
|
-1);
|
2001-12-12 09:16:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
toolbox_check_device (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
2002-10-25 21:21:54 +08:00
|
|
|
Gimp *gimp)
|
2001-12-12 09:16:39 +08:00
|
|
|
{
|
2002-10-25 21:21:54 +08:00
|
|
|
gimp_devices_check_change (gimp, event);
|
2001-12-12 09:16:39 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|