mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-19 06:14:03 +00:00
Started making the toolbox configurable. Addresses bug #105764. Not
2004-05-10 Michael Natterer <mitch@gimp.org> Started making the toolbox configurable. Addresses bug #105764. Not finished yet. * app/core/gimptoolinfo.[ch]: renamed "in_toolbox" to "visible" and made it a GObject property. * app/tools/gimp-tools.[ch]: added new function gimp_tools_get_default_order() which returns a GList of tool identifiers. * app/actions/tools-actions.c * app/actions/tools-commands.[ch]: added actions & callbacks for toggling the "visible" boolean and for resetting all tools. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimptoolview.[ch]: new widget which allows to toggle a tool's visibility and to reorder the tools. * app/widgets/gimptoolbox.[ch]: removed member "GtkWidget *trash" and pack all tool buttons into the same wrap box. Connect to "reoder" of the tool container and to "notify::visible" of all tool infos and update the toolbox accordingly. * app/gui/dialogs-constructors.c: create a GimpToolView for the tools list/grid. * app/menus/menus.c: register a <Tools> menu for the dialog above. * menus/Makefile.am * menus/tools-menu.xml: added the menu.
This commit is contained in:
parent
2870718d45
commit
da0de0873f
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
|||
2004-05-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Started making the toolbox configurable.
|
||||
Addresses bug #105764. Not finished yet.
|
||||
|
||||
* app/core/gimptoolinfo.[ch]: renamed "in_toolbox" to "visible"
|
||||
and made it a GObject property.
|
||||
|
||||
* app/tools/gimp-tools.[ch]: added new function
|
||||
gimp_tools_get_default_order() which returns a GList of tool
|
||||
identifiers.
|
||||
|
||||
* app/actions/tools-actions.c
|
||||
* app/actions/tools-commands.[ch]: added actions & callbacks for
|
||||
toggling the "visible" boolean and for resetting all tools.
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimptoolview.[ch]: new widget which allows to
|
||||
toggle a tool's visibility and to reorder the tools.
|
||||
|
||||
* app/widgets/gimptoolbox.[ch]: removed member "GtkWidget *trash"
|
||||
and pack all tool buttons into the same wrap box. Connect to
|
||||
"reoder" of the tool container and to "notify::visible" of all
|
||||
tool infos and update the toolbox accordingly.
|
||||
|
||||
* app/gui/dialogs-constructors.c: create a GimpToolView for the
|
||||
tools list/grid.
|
||||
|
||||
* app/menus/menus.c: register a <Tools> menu for the dialog above.
|
||||
|
||||
* menus/Makefile.am
|
||||
* menus/tools-menu.xml: added the menu.
|
||||
|
||||
2004-05-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpuimanager.c: re-added help for menu items. Still
|
||||
|
|
|
@ -27,10 +27,13 @@
|
|||
#include "actions-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpcontainereditor.h"
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "actions/tools-actions.h"
|
||||
|
@ -41,6 +44,9 @@
|
|||
|
||||
static GimpActionEntry tools_actions[] =
|
||||
{
|
||||
{ "tools-popup", GIMP_STOCK_TOOLS, N_("Tools Menu"), NULL, NULL, NULL,
|
||||
GIMP_HELP_TOOLS_DIALOG },
|
||||
|
||||
{ "tools-menu", NULL, N_("_Tools") },
|
||||
{ "tools-select-menu", NULL, N_("_Selection Tools") },
|
||||
{ "tools-paint-menu", NULL, N_("_Paint Tools") },
|
||||
|
@ -55,7 +61,21 @@ static GimpActionEntry tools_actions[] =
|
|||
{ "tools-swap-colors", GIMP_STOCK_SWAP_COLORS,
|
||||
N_("S_wap Colors"), "X", NULL,
|
||||
G_CALLBACK (tools_swap_colors_cmd_callback),
|
||||
GIMP_HELP_TOOLBOX_SWAP_COLORS }
|
||||
GIMP_HELP_TOOLBOX_SWAP_COLORS },
|
||||
|
||||
{ "tools-reset", GIMP_STOCK_RESET,
|
||||
N_("_Reset Order & Visibility"), NULL, NULL,
|
||||
G_CALLBACK (tools_reset_cmd_callback),
|
||||
NULL }
|
||||
};
|
||||
|
||||
static GimpToggleActionEntry tools_toggle_actions[] =
|
||||
{
|
||||
{ "tools-visibility", NULL,
|
||||
N_("Show in Toolbox"), NULL, NULL,
|
||||
G_CALLBACK (tools_toggle_visibility_cmd_callback),
|
||||
TRUE,
|
||||
NULL /* FIXME */ }
|
||||
};
|
||||
|
||||
static GimpStringActionEntry tools_alternative_actions[] =
|
||||
|
@ -82,6 +102,10 @@ tools_actions_setup (GimpActionGroup *group)
|
|||
tools_actions,
|
||||
G_N_ELEMENTS (tools_actions));
|
||||
|
||||
gimp_action_group_add_toggle_actions (group,
|
||||
tools_toggle_actions,
|
||||
G_N_ELEMENTS (tools_toggle_actions));
|
||||
|
||||
gimp_action_group_add_string_actions (group,
|
||||
tools_alternative_actions,
|
||||
G_N_ELEMENTS (tools_alternative_actions),
|
||||
|
@ -138,4 +162,16 @@ void
|
|||
tools_actions_update (GimpActionGroup *group,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolInfo *tool_info = NULL;
|
||||
|
||||
if (GIMP_IS_CONTAINER_EDITOR (data))
|
||||
tool_info =
|
||||
gimp_context_get_tool (GIMP_CONTAINER_EDITOR (data)->view->context);
|
||||
|
||||
#define SET_ACTIVE(action,condition) \
|
||||
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
||||
|
||||
SET_ACTIVE ("tools-visibility", tool_info && tool_info->visible);
|
||||
|
||||
#undef SET_ACTIVE
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpcontainereditor.h"
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimptoolview.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "tools/gimptool.h"
|
||||
|
@ -94,3 +98,32 @@ tools_select_cmd_callback (GtkAction *action,
|
|||
if (gdisp)
|
||||
tool_manager_initialize_active (gimp, gdisp);
|
||||
}
|
||||
|
||||
void
|
||||
tools_toggle_visibility_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
if (GIMP_IS_CONTAINER_EDITOR (data))
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
gboolean active;
|
||||
|
||||
tool_info =
|
||||
gimp_context_get_tool (GIMP_CONTAINER_EDITOR (data)->view->context);
|
||||
|
||||
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||
|
||||
if (active != tool_info->visible)
|
||||
g_object_set (tool_info, "visible", active, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tools_reset_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolView *view = GIMP_TOOL_VIEW (data);
|
||||
|
||||
if (GTK_WIDGET_SENSITIVE (view->reset_button))
|
||||
gtk_button_clicked (GTK_BUTTON (view->reset_button));
|
||||
}
|
||||
|
|
|
@ -20,13 +20,18 @@
|
|||
#define __TOOLS_COMMANDS_H__
|
||||
|
||||
|
||||
void tools_default_colors_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tools_swap_colors_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tools_select_cmd_callback (GtkAction *action,
|
||||
const gchar *value,
|
||||
gpointer data);
|
||||
void tools_default_colors_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tools_swap_colors_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tools_select_cmd_callback (GtkAction *action,
|
||||
const gchar *value,
|
||||
gpointer data);
|
||||
|
||||
void tools_toggle_visibility_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tools_reset_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __TOOLS_COMMANDS_H__ */
|
||||
|
|
|
@ -35,10 +35,25 @@
|
|||
#include "gimptooloptions.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VISIBLE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_tool_info_class_init (GimpToolInfoClass *klass);
|
||||
static void gimp_tool_info_init (GimpToolInfo *tool_info);
|
||||
|
||||
static void gimp_tool_info_finalize (GObject *object);
|
||||
static void gimp_tool_info_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_tool_info_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static gchar * gimp_tool_info_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -83,8 +98,16 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass)
|
|||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_tool_info_finalize;
|
||||
object_class->get_property = gimp_tool_info_get_property;
|
||||
object_class->set_property = gimp_tool_info_set_property;
|
||||
|
||||
viewable_class->get_description = gimp_tool_info_get_description;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_VISIBLE,
|
||||
g_param_spec_boolean ("visible",
|
||||
NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -105,7 +128,7 @@ gimp_tool_info_init (GimpToolInfo *tool_info)
|
|||
tool_info->help_domain = NULL;
|
||||
tool_info->help_id = NULL;
|
||||
|
||||
tool_info->in_toolbox = TRUE;
|
||||
tool_info->visible = TRUE;
|
||||
tool_info->tool_options = NULL;
|
||||
tool_info->paint_info = NULL;
|
||||
}
|
||||
|
@ -163,6 +186,44 @@ gimp_tool_info_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_info_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpToolInfo *tool_info = GIMP_TOOL_INFO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, tool_info->visible);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_info_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpToolInfo *tool_info = GIMP_TOOL_INFO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_VISIBLE:
|
||||
tool_info->visible = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_tool_info_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip)
|
||||
|
|
|
@ -52,7 +52,7 @@ struct _GimpToolInfo
|
|||
gchar *help_domain;
|
||||
gchar *help_id;
|
||||
|
||||
gboolean in_toolbox;
|
||||
gboolean visible;
|
||||
GimpToolOptions *tool_options;
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "widgets/gimptemplateview.h"
|
||||
#include "widgets/gimptoolbox.h"
|
||||
#include "widgets/gimptooloptionseditor.h"
|
||||
#include "widgets/gimptoolview.h"
|
||||
#include "widgets/gimpundoeditor.h"
|
||||
#include "widgets/gimpvectorstreeview.h"
|
||||
|
||||
|
@ -370,10 +371,11 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory,
|
|||
{
|
||||
GtkWidget *view;
|
||||
|
||||
view = gimp_container_tree_view_new (context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 0,
|
||||
FALSE);
|
||||
view = gimp_tool_view_new (GIMP_VIEW_TYPE_LIST,
|
||||
context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 0,
|
||||
factory->menu_factory);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
_("Tools"), NULL,
|
||||
|
@ -579,10 +581,11 @@ dialogs_tool_grid_view_new (GimpDialogFactory *factory,
|
|||
{
|
||||
GtkWidget *view;
|
||||
|
||||
view = gimp_container_grid_view_new (context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 1,
|
||||
FALSE);
|
||||
view = gimp_tool_view_new (GIMP_VIEW_TYPE_GRID,
|
||||
context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 1,
|
||||
factory->menu_factory);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
_("Tools"), NULL,
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "widgets/gimptemplateview.h"
|
||||
#include "widgets/gimptoolbox.h"
|
||||
#include "widgets/gimptooloptionseditor.h"
|
||||
#include "widgets/gimptoolview.h"
|
||||
#include "widgets/gimpundoeditor.h"
|
||||
#include "widgets/gimpvectorstreeview.h"
|
||||
|
||||
|
@ -370,10 +371,11 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory,
|
|||
{
|
||||
GtkWidget *view;
|
||||
|
||||
view = gimp_container_tree_view_new (context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 0,
|
||||
FALSE);
|
||||
view = gimp_tool_view_new (GIMP_VIEW_TYPE_LIST,
|
||||
context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 0,
|
||||
factory->menu_factory);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
_("Tools"), NULL,
|
||||
|
@ -579,10 +581,11 @@ dialogs_tool_grid_view_new (GimpDialogFactory *factory,
|
|||
{
|
||||
GtkWidget *view;
|
||||
|
||||
view = gimp_container_grid_view_new (context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 1,
|
||||
FALSE);
|
||||
view = gimp_tool_view_new (GIMP_VIEW_TYPE_GRID,
|
||||
context->gimp->tool_info_list,
|
||||
context,
|
||||
preview_size, 1,
|
||||
factory->menu_factory);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
_("Tools"), NULL,
|
||||
|
|
|
@ -232,6 +232,13 @@ menus_init (Gimp *gimp)
|
|||
"images-menu.xml", NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Tools>",
|
||||
"tools",
|
||||
NULL,
|
||||
"/tools-popup",
|
||||
"tools-menu.xml", NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<GradientEditor>",
|
||||
"gradient-editor",
|
||||
NULL,
|
||||
|
|
|
@ -157,7 +157,9 @@ gimp_tools_init (Gimp *gimp)
|
|||
gimp_rect_select_tool_register
|
||||
};
|
||||
|
||||
gint i;
|
||||
GList *default_order = NULL;
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
|
@ -171,13 +173,37 @@ gimp_tools_init (Gimp *gimp)
|
|||
}
|
||||
|
||||
gimp_container_thaw (gimp->tool_info_list);
|
||||
|
||||
for (list = GIMP_LIST (gimp->tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
const gchar *identifier = gimp_object_get_name (list->data);
|
||||
|
||||
|
||||
default_order = g_list_prepend (default_order, g_strdup (identifier));
|
||||
}
|
||||
|
||||
default_order = g_list_reverse (default_order);
|
||||
|
||||
g_object_set_data (G_OBJECT (gimp), "gimp-tools-default-order", default_order);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tools_exit (Gimp *gimp)
|
||||
{
|
||||
GList *default_order;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
default_order = g_object_get_data (G_OBJECT (gimp),
|
||||
"gimp-tools-default-order");
|
||||
|
||||
g_list_foreach (default_order, (GFunc) g_free, NULL);
|
||||
g_list_free (default_order);
|
||||
|
||||
g_object_set_data (G_OBJECT (gimp), "gimp-tools-default-order", NULL);
|
||||
|
||||
tool_manager_exit (gimp);
|
||||
}
|
||||
|
||||
|
@ -285,6 +311,15 @@ gimp_tools_save (Gimp *gimp)
|
|||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_tools_get_default_order (Gimp *gimp)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
return g_object_get_data (G_OBJECT (gimp),
|
||||
"gimp-tools-default-order");
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -367,7 +402,7 @@ gimp_tools_register (GType tool_type,
|
|||
stock_id);
|
||||
|
||||
if (g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL))
|
||||
tool_info->in_toolbox = FALSE;
|
||||
g_object_set (tool_info, "visible", FALSE, NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
|
||||
options_gui_func);
|
||||
|
|
|
@ -26,5 +26,7 @@ void gimp_tools_exit (Gimp *gimp);
|
|||
void gimp_tools_restore (Gimp *gimp);
|
||||
void gimp_tools_save (Gimp *gimp);
|
||||
|
||||
GList *gimp_tools_get_default_order (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __GIMP_TOOLS_H__ */
|
||||
|
|
|
@ -202,6 +202,8 @@ libappwidgets_a_sources = \
|
|||
gimptooldialog.h \
|
||||
gimptooloptionseditor.c \
|
||||
gimptooloptionseditor.h \
|
||||
gimptoolview.c \
|
||||
gimptoolview.h \
|
||||
gimpuimanager.c \
|
||||
gimpuimanager.h \
|
||||
gimpundoeditor.c \
|
||||
|
|
|
@ -83,6 +83,14 @@ 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_button_toggled (GtkWidget *widget,
|
||||
GimpToolInfo *tool_info);
|
||||
static gboolean toolbox_tool_button_press (GtkWidget *widget,
|
||||
|
@ -195,12 +203,6 @@ gimp_toolbox_init (GimpToolbox *toolbox)
|
|||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), toolbox->wbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (toolbox->wbox);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -256,7 +258,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
|
|||
{
|
||||
tool_info = (GimpToolInfo *) list->data;
|
||||
|
||||
if (tool_info->in_toolbox)
|
||||
if (tool_info->visible)
|
||||
n_tools++;
|
||||
}
|
||||
|
||||
|
@ -298,8 +300,6 @@ gimp_toolbox_style_set (GtkWidget *widget,
|
|||
GtkStyle *previous_style)
|
||||
{
|
||||
Gimp *gimp;
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *tool_button;
|
||||
GtkIconSize tool_icon_size;
|
||||
GtkReliefStyle relief;
|
||||
GList *list;
|
||||
|
@ -321,10 +321,8 @@ gimp_toolbox_style_set (GtkWidget *widget,
|
|||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
tool_info = GIMP_TOOL_INFO (list->data);
|
||||
|
||||
if (! tool_info->in_toolbox)
|
||||
continue;
|
||||
GimpToolInfo *tool_info = list->data;
|
||||
GtkWidget *tool_button;
|
||||
|
||||
tool_button = g_object_get_data (G_OBJECT (tool_info),
|
||||
TOOL_BUTTON_DATA_KEY);
|
||||
|
@ -632,21 +630,20 @@ 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);
|
||||
|
||||
if (tool_info->in_toolbox)
|
||||
{
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
gtk_widget_show (button);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (toolbox->wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_container_add (GTK_CONTAINER (toolbox->trash), button);
|
||||
}
|
||||
if (tool_info->visible)
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect_object (tool_info, "notify::visible",
|
||||
G_CALLBACK (toolbox_tool_visible_notify),
|
||||
button, 0);
|
||||
|
||||
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);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY, button);
|
||||
g_object_set_data (G_OBJECT (button), TOOL_INFO_DATA_KEY, tool_info);
|
||||
|
@ -706,6 +703,10 @@ toolbox_create_tools (GimpToolbox *toolbox,
|
|||
gimp_help_set_help_data (button, tool_info->help, tool_info->help_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
g_signal_connect_object (context->gimp->tool_info_list, "reorder",
|
||||
G_CALLBACK (toolbox_tool_reorder),
|
||||
toolbox->wbox, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -797,6 +798,32 @@ toolbox_tool_changed (GimpContext *context,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_reorder (GimpContainer *container,
|
||||
GimpToolInfo *tool_info,
|
||||
gint index,
|
||||
GtkWidget *wrap_box)
|
||||
{
|
||||
if (tool_info)
|
||||
{
|
||||
GtkWidget *button = g_object_get_data (G_OBJECT (tool_info),
|
||||
TOOL_BUTTON_DATA_KEY);
|
||||
|
||||
gtk_wrap_box_reorder_child (GTK_WRAP_BOX (wrap_box), button, index);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_visible_notify (GimpToolInfo *tool_info,
|
||||
GParamSpec *pspec,
|
||||
GtkWidget *button)
|
||||
{
|
||||
if (tool_info->visible)
|
||||
gtk_widget_show (button);
|
||||
else
|
||||
gtk_widget_hide (button);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
GimpToolInfo *tool_info)
|
||||
|
|
|
@ -39,7 +39,6 @@ struct _GimpToolbox
|
|||
|
||||
GtkWidget *menu_bar;
|
||||
GtkWidget *wbox;
|
||||
GtkWidget *trash;
|
||||
GtkWidget *color_area;
|
||||
GtkWidget *indicator_area;
|
||||
|
||||
|
|
190
app/widgets/gimptoolview.c
Normal file
190
app/widgets/gimptoolview.c
Normal file
|
@ -0,0 +1,190 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimptoolview.c
|
||||
* Copyright (C) 2001-2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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 <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "tools/tools-types.h"
|
||||
|
||||
#include "tools/gimp-tools.h"
|
||||
#include "tools/gimpimagemaptool.h"
|
||||
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimptoolview.h"
|
||||
#include "gimphelp-ids.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_tool_view_class_init (GimpToolViewClass *klass);
|
||||
static void gimp_tool_view_init (GimpToolView *view);
|
||||
|
||||
static void gimp_tool_view_reset_clicked (GtkWidget *widget,
|
||||
GimpToolView *view);
|
||||
static void gimp_tool_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_tool_view_activate_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
static GimpContainerEditorClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_tool_view_get_type (void)
|
||||
{
|
||||
static GType view_type = 0;
|
||||
|
||||
if (! view_type)
|
||||
{
|
||||
static const GTypeInfo view_info =
|
||||
{
|
||||
sizeof (GimpToolViewClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_tool_view_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpToolView),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_tool_view_init,
|
||||
};
|
||||
|
||||
view_type = g_type_register_static (GIMP_TYPE_CONTAINER_EDITOR,
|
||||
"GimpToolView",
|
||||
&view_info, 0);
|
||||
}
|
||||
|
||||
return view_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_view_class_init (GimpToolViewClass *klass)
|
||||
{
|
||||
GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
editor_class->select_item = gimp_tool_view_select_item;
|
||||
editor_class->activate_item = gimp_tool_view_activate_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_view_init (GimpToolView *view)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_tool_view_new (GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint preview_border_width,
|
||||
GimpMenuFactory *menu_factory)
|
||||
{
|
||||
GimpToolView *tool_view;
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
tool_view = g_object_new (GIMP_TYPE_TOOL_VIEW, NULL);
|
||||
|
||||
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (tool_view),
|
||||
view_type,
|
||||
container,context,
|
||||
preview_size, preview_border_width,
|
||||
TRUE, /* reorderable */
|
||||
menu_factory, "<Tools>",
|
||||
"/tools-popup"))
|
||||
{
|
||||
g_object_unref (tool_view);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
editor = GIMP_CONTAINER_EDITOR (tool_view);
|
||||
|
||||
tool_view->reset_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor->view),
|
||||
GIMP_STOCK_RESET,
|
||||
_("Reset tool order and visibility"),
|
||||
NULL,
|
||||
G_CALLBACK (gimp_tool_view_reset_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
|
||||
return GTK_WIDGET (tool_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_view_reset_clicked (GtkWidget *widget,
|
||||
GimpToolView *view)
|
||||
{
|
||||
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
|
||||
GimpContainer *tool_infos;
|
||||
GList *list;
|
||||
gint i = 0;
|
||||
|
||||
tool_infos = editor->view->context->gimp->tool_info_list;
|
||||
|
||||
for (list = gimp_tools_get_default_order (editor->view->context->gimp);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpObject *object = gimp_container_get_child_by_name (tool_infos,
|
||||
list->data);
|
||||
|
||||
if (object)
|
||||
{
|
||||
gimp_container_reorder (tool_infos, object, i);
|
||||
|
||||
g_object_set (object, "visible",
|
||||
! g_type_is_a (GIMP_TOOL_INFO (object)->tool_type,
|
||||
GIMP_TYPE_IMAGE_MAP_TOOL),
|
||||
NULL);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item)
|
||||
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_view_activate_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item)
|
||||
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->activate_item (editor, viewable);
|
||||
}
|
62
app/widgets/gimptoolview.h
Normal file
62
app/widgets/gimptoolview.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimptoolview.h
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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_TOOL_VIEW_H__
|
||||
#define __GIMP_TOOL_VIEW_H__
|
||||
|
||||
|
||||
#include "gimpcontainereditor.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TOOL_VIEW (gimp_tool_view_get_type ())
|
||||
#define GIMP_TOOL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_VIEW, GimpToolView))
|
||||
#define GIMP_TOOL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_VIEW, GimpToolViewClass))
|
||||
#define GIMP_IS_TOOL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_VIEW))
|
||||
#define GIMP_IS_TOOL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_VIEW))
|
||||
#define GIMP_TOOL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_VIEW, GimpToolViewClass))
|
||||
|
||||
|
||||
typedef struct _GimpToolViewClass GimpToolViewClass;
|
||||
|
||||
struct _GimpToolView
|
||||
{
|
||||
GimpContainerEditor parent_instance;
|
||||
|
||||
GtkWidget *reset_button;
|
||||
};
|
||||
|
||||
struct _GimpToolViewClass
|
||||
{
|
||||
GimpContainerEditorClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_tool_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_tool_view_new (GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
GimpContext *context,
|
||||
gint preview_size,
|
||||
gint preview_border_width,
|
||||
GimpMenuFactory *menu_factory);
|
||||
|
||||
|
||||
#endif /* __GIMP_TOOL_VIEW_H__ */
|
|
@ -104,6 +104,7 @@ typedef struct _GimpDocumentView GimpDocumentView;
|
|||
typedef struct _GimpFontView GimpFontView;
|
||||
typedef struct _GimpImageView GimpImageView;
|
||||
typedef struct _GimpTemplateView GimpTemplateView;
|
||||
typedef struct _GimpToolView GimpToolView;
|
||||
typedef struct _GimpDataFactoryView GimpDataFactoryView;
|
||||
typedef struct _GimpBrushFactoryView GimpBrushFactoryView;
|
||||
typedef struct _GimpPatternFactoryView GimpPatternFactoryView;
|
||||
|
|
|
@ -30,6 +30,7 @@ menudata_DATA = \
|
|||
qmask-menu.xml \
|
||||
templates-menu.xml \
|
||||
tool-options-menu.xml \
|
||||
tools-menu.xml \
|
||||
vectors-menu.xml
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
|
10
menus/tools-menu.xml
Normal file
10
menus/tools-menu.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
|
||||
|
||||
<ui>
|
||||
<popup action="tools-popup">
|
||||
<menuitem action="tools-visibility" />
|
||||
<separator />
|
||||
<menuitem action="tools-reset" />
|
||||
</popup>
|
||||
</ui>
|
Loading…
Reference in a new issue