2003-02-26 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI if the get_preview() functions return NULL. Default to GTK_STOCK_DIALOG_QUESTION. * app/core/gimptoolinfo.[ch]: set the tool's stock_id. Removed the cached GdkPixbuf. Don't implement any preview function so the GUI uses the stock_id. * app/tools/tool_manager.c: removed GdkPixbuf creation, removed the #warning about the buggy way we created the pixbuf. * app/gui/dialogs-constructors.c * app/gui/image-menu.c * app/tools/gimpcroptool.c * app/tools/gimphistogramtool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptoolbox.c: use viewable->stock_id instead of tool_info->stock_id. * app/core/gimpbrush.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimpundo.c: simplified get_preview() implementations: - never scale previews up, only down. - don't render white or checks backgrounds but simply return TempBufs with alpha and let the preview system do its job. - don't add padding but simply return previews smaller than requested. * app/display/gimpdisplayshell-render.[ch]: added "render_blend_white", a 2d lookup table for blending on white, just as the check lookup tables. Added "render_white_buf". * app/widgets/gimppreview.[ch]: changed a lot: - don't render the preview's border into the buffer. - added "GdkGC *border_gc" and draw the preview's border in expose() using gdk_draw_rectangle(). - added "GdkPixbuf *no_preview_pixbuf" and create it in gimp_preview_real_render() if gimp_viewable_get_preview() returned NULL. - factored the actual preview rendering out to gimp_preview_render_to_buffer(). Added configurable background rendering for the preview itself and it's padding area (the area the preview is larger than the buffer returned by gimp_viewable_get_preview()). - changed gimp_preview_render_and_flush() to gimp_preview_render_preview() and added "inside_bg" and "outside_bg" parameters. - use the new render buffers for blending on white. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpgradientpreview.c * app/widgets/gimpimagepreview.c * app/widgets/gimppalettepreview.c * app/widgets/gimppatternpreview.c: don't create large white TempBufs to center the previews in but simply set the TempBuf's offsets to get them centered. Simplified & cleaned up many preview render functions. Pass the correct GimpPreviewBG modes to gimp_preview_render_preview(). * app/widgets/gimpcellrendererviewable.[ch]: new GtkCellRenderer class derived from GtkCellRendererPixbuf which knows how to use gimp_viewable_get_preview_size() and renders the viewable's stock item if no preview can be created. * app/widgets/gimpcontainertreeview.c: added a GtkTreeCellDataFunc which creates the preview pixbuf if needed so we don't create it unconditionally upon item insertion. Fixed preview size assertion to use GIMP_PREVIEW_MAX_SIZE, not "64". Block "selection_changed" while reordering the selected item. * app/widgets/gimpcontainerview.c: cosmetic. * app/widgets/gimpimagefilepreview.[ch] * app/widgets/gimptoolinfopreview.[ch] * app/widgets/gimpundopreview.[ch]: removed because the default implementation is good enough. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimppreview-utils.c: changed accordingly. * app/gui/dialogs-constructors.[ch] * app/gui/dialogs-menu.c * app/gui/dialogs.c * app/gui/image-menu.c * app/gui/toolbox-menu.c: register grid and tree view variants of the document history. Unrelated: * app/gui/gui.c (gui_exit_finish_callback): disconnect from signals earlier. * app/gui/user-install-dialog.c: create the "tool-options" subdir of the user's ~/.gimp-1.3 directory.
310 lines
11 KiB
C
310 lines
11 KiB
C
/* 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 <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "gui-types.h"
|
|
|
|
#include "widgets/gimpcontainerview.h"
|
|
#include "widgets/gimpcontainerview-utils.h"
|
|
#include "widgets/gimpdialogfactory.h"
|
|
#include "widgets/gimpdockbook.h"
|
|
#include "widgets/gimpimagedock.h"
|
|
#include "widgets/gimpitemfactory.h"
|
|
|
|
#include "dialogs-commands.h"
|
|
#include "dialogs-menu.h"
|
|
#include "menus.h"
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
#define ADD_TAB(path,id,type,stock_id) \
|
|
{ { (path), "foo", dialogs_add_tab_cmd_callback, 0, (type), (stock_id) }, \
|
|
(id), NULL, NULL }
|
|
#define PREVIEW_SIZE(path,size) \
|
|
{ { (path), NULL, dialogs_preview_size_cmd_callback, \
|
|
(size), "/Preview Size/Tiny" }, NULL, NULL, NULL }
|
|
|
|
|
|
GimpItemFactoryEntry dialogs_menu_entries[] =
|
|
{
|
|
{ { N_("/Select Tab"), NULL, NULL, 0 },
|
|
NULL, NULL, NULL },
|
|
|
|
ADD_TAB (N_("/Add Tab/Tool Options..."), "gimp-tool-options",
|
|
"<StockItem>", GIMP_STOCK_TOOL_OPTIONS),
|
|
|
|
MENU_SEPARATOR ("/Add Tab/---"),
|
|
|
|
ADD_TAB (N_("/Add Tab/Layers..."), "gimp-layer-list", NULL, NULL),
|
|
ADD_TAB (N_("/Add Tab/Channels..."), "gimp-channel-list", NULL, NULL),
|
|
ADD_TAB (N_("/Add Tab/Paths..."), "gimp-vectors-list", NULL, NULL),
|
|
ADD_TAB (N_("/Add Tab/Indexed Palette..."), "gimp-indexed-palette",
|
|
"<StockItem>", GTK_STOCK_SELECT_COLOR),
|
|
ADD_TAB (N_("/Add Tab/Selection Editor..."), "gimp-selection-editor",
|
|
"<StockItem>", GIMP_STOCK_TOOL_RECT_SELECT),
|
|
ADD_TAB (N_("/Add Tab/Navigation..."), "gimp-navigation-view",
|
|
"<StockItem>", GIMP_STOCK_NAVIGATION),
|
|
ADD_TAB (N_("/Add Tab/Undo History..."), "gimp-undo-history",
|
|
"<StockItem>", GTK_STOCK_UNDO),
|
|
|
|
MENU_SEPARATOR ("/Add Tab/---"),
|
|
|
|
ADD_TAB (N_("/Add Tab/Colors..."), "gimp-color-editor",
|
|
"<StockItem>", GTK_STOCK_SELECT_COLOR),
|
|
ADD_TAB (N_("/Add Tab/Brushes..."), "gimp-brush-grid",
|
|
"<StockItem>", GIMP_STOCK_TOOL_PAINTBRUSH),
|
|
ADD_TAB (N_("/Add Tab/Patterns..."), "gimp-pattern-grid",
|
|
"<StockItem>", GIMP_STOCK_TOOL_BUCKET_FILL),
|
|
ADD_TAB (N_("/Add Tab/Gradients..."), "gimp-gradient-list",
|
|
"<StockItem>", GIMP_STOCK_TOOL_BLEND),
|
|
ADD_TAB (N_("/Add Tab/Palettes..."), "gimp-palette-list",
|
|
"<StockItem>", GTK_STOCK_SELECT_COLOR),
|
|
ADD_TAB (N_("/Add Tab/Buffers..."), "gimp-buffer-list",
|
|
"<StockItem>", GTK_STOCK_PASTE),
|
|
|
|
MENU_SEPARATOR ("/Add Tab/---"),
|
|
|
|
ADD_TAB (N_("/Add Tab/Images..."), "gimp-image-list", NULL, NULL),
|
|
ADD_TAB (N_("/Add Tab/Document History..."), "gimp-document-list",
|
|
"<StockItem>", GTK_STOCK_OPEN),
|
|
ADD_TAB (N_("/Add Tab/Error Console..."), "gimp-error-console",
|
|
"<StockItem>", GIMP_STOCK_WARNING),
|
|
|
|
MENU_SEPARATOR ("/Add Tab/---"),
|
|
|
|
ADD_TAB (N_("/Add Tab/Tools..."), "gimp-tool-list", NULL, NULL),
|
|
ADD_TAB (N_("/Add Tab/Old Paths..."), "gimp-path-list", NULL, NULL),
|
|
|
|
{ { N_("/Remove Tab"), NULL,
|
|
dialogs_remove_tab_cmd_callback, 0,
|
|
"<StockItem>", GTK_STOCK_REMOVE },
|
|
NULL, NULL, NULL },
|
|
|
|
MENU_SEPARATOR ("/view-type-separator"),
|
|
|
|
MENU_BRANCH ("/Preview Size"),
|
|
|
|
{ { N_("/Preview Size/Tiny"), NULL,
|
|
dialogs_preview_size_cmd_callback,
|
|
GIMP_PREVIEW_SIZE_TINY, "<RadioItem>" },
|
|
NULL, NULL, NULL },
|
|
|
|
PREVIEW_SIZE (N_("/Preview Size/Extra Small"), GIMP_PREVIEW_SIZE_EXTRA_SMALL),
|
|
PREVIEW_SIZE (N_("/Preview Size/Small"), GIMP_PREVIEW_SIZE_SMALL),
|
|
PREVIEW_SIZE (N_("/Preview Size/Medium"), GIMP_PREVIEW_SIZE_MEDIUM),
|
|
PREVIEW_SIZE (N_("/Preview Size/Large"), GIMP_PREVIEW_SIZE_LARGE),
|
|
PREVIEW_SIZE (N_("/Preview Size/Extra Large"), GIMP_PREVIEW_SIZE_EXTRA_LARGE),
|
|
PREVIEW_SIZE (N_("/Preview Size/Huge"), GIMP_PREVIEW_SIZE_HUGE),
|
|
PREVIEW_SIZE (N_("/Preview Size/Enormous"), GIMP_PREVIEW_SIZE_ENORMOUS),
|
|
PREVIEW_SIZE (N_("/Preview Size/Gigantic"), GIMP_PREVIEW_SIZE_GIGANTIC),
|
|
|
|
{ { N_("/View as List"), NULL,
|
|
dialogs_toggle_view_cmd_callback, GIMP_VIEW_TYPE_LIST, "<RadioItem>" },
|
|
NULL, NULL, NULL },
|
|
{ { N_("/View as Grid"), NULL,
|
|
dialogs_toggle_view_cmd_callback, GIMP_VIEW_TYPE_GRID, "/View as List" },
|
|
NULL, NULL, NULL },
|
|
{ { N_("/View as Tree"), NULL,
|
|
dialogs_toggle_view_cmd_callback, GIMP_VIEW_TYPE_TREE, "/View as List" },
|
|
NULL, NULL, NULL },
|
|
|
|
MENU_SEPARATOR ("/image-menu-separator"),
|
|
|
|
{ { N_("/Show Image Menu"), NULL,
|
|
dialogs_toggle_image_menu_cmd_callback, 0, "<ToggleItem>" },
|
|
NULL, NULL, NULL },
|
|
{ { N_("/Auto Follow Active Image"), NULL,
|
|
dialogs_toggle_auto_cmd_callback, 0, "<ToggleItem>" },
|
|
NULL, NULL, NULL }
|
|
};
|
|
|
|
#undef ADD_TAB
|
|
#undef PREVIEW_SIZE
|
|
|
|
gint n_dialogs_menu_entries = G_N_ELEMENTS (dialogs_menu_entries);
|
|
|
|
|
|
void
|
|
dialogs_menu_update (GtkItemFactory *factory,
|
|
gpointer data)
|
|
{
|
|
GimpDockbook *dockbook;
|
|
|
|
dockbook = GIMP_DOCKBOOK (data);
|
|
|
|
if (dockbook)
|
|
{
|
|
GimpDockable *dockable;
|
|
gint page_num;
|
|
GimpDialogFactoryEntry *entry;
|
|
GimpContainerView *view;
|
|
GimpViewType view_type = -1;
|
|
gboolean list_view_available = FALSE;
|
|
gboolean grid_view_available = FALSE;
|
|
gboolean tree_view_available = FALSE;
|
|
GimpPreviewSize preview_size = GIMP_PREVIEW_SIZE_NONE;
|
|
|
|
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
|
|
|
|
dockable = (GimpDockable *)
|
|
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
|
|
|
|
entry = g_object_get_data (G_OBJECT (dockable),
|
|
"gimp-dialog-factory-entry");
|
|
|
|
if (entry)
|
|
{
|
|
gchar *identifier;
|
|
gchar *substring = NULL;
|
|
|
|
identifier = g_strdup (entry->identifier);
|
|
|
|
if ((substring = strstr (identifier, "grid")))
|
|
view_type = GIMP_VIEW_TYPE_GRID;
|
|
else if ((substring = strstr (identifier, "list")))
|
|
view_type = GIMP_VIEW_TYPE_LIST;
|
|
else if ((substring = strstr (identifier, "tree")))
|
|
view_type = GIMP_VIEW_TYPE_TREE;
|
|
|
|
if (substring)
|
|
{
|
|
memcpy (substring, "list", 4);
|
|
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
|
|
identifier))
|
|
list_view_available = TRUE;
|
|
|
|
memcpy (substring, "grid", 4);
|
|
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
|
|
identifier))
|
|
grid_view_available = TRUE;
|
|
|
|
memcpy (substring, "tree", 4);
|
|
if (gimp_dialog_factory_find_entry (dockbook->dock->dialog_factory,
|
|
identifier))
|
|
tree_view_available = TRUE;
|
|
}
|
|
|
|
g_free (identifier);
|
|
}
|
|
|
|
view = gimp_container_view_get_by_dockable (dockable);
|
|
|
|
if (view)
|
|
preview_size = view->preview_size;
|
|
|
|
#define SET_ACTIVE(path,active) \
|
|
gimp_item_factory_set_active (factory, (path), (active))
|
|
#define SET_VISIBLE(path,active) \
|
|
gimp_item_factory_set_visible (factory, (path), (active))
|
|
#define SET_SENSITIVE(path,sensitive) \
|
|
gimp_item_factory_set_sensitive (factory, (path), (sensitive))
|
|
|
|
SET_VISIBLE ("/view-type-separator",
|
|
preview_size != GIMP_PREVIEW_SIZE_NONE || view_type != -1);
|
|
|
|
SET_VISIBLE ("/Preview Size", preview_size != GIMP_PREVIEW_SIZE_NONE);
|
|
|
|
if (preview_size != GIMP_PREVIEW_SIZE_NONE)
|
|
{
|
|
if (preview_size >= GIMP_PREVIEW_SIZE_GIGANTIC)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Gigantic", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_ENORMOUS)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Enormous", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_HUGE)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Huge", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_LARGE)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Extra Large", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_LARGE)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Large", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_MEDIUM)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Medium", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_SMALL)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Small", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_EXTRA_SMALL)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Extra Small", TRUE);
|
|
}
|
|
else if (preview_size >= GIMP_PREVIEW_SIZE_TINY)
|
|
{
|
|
SET_ACTIVE ("/Preview Size/Tiny", TRUE);
|
|
}
|
|
}
|
|
|
|
SET_VISIBLE ("/View as Grid", view_type != -1);
|
|
SET_VISIBLE ("/View as List", view_type != -1);
|
|
SET_VISIBLE ("/View as Tree", view_type != -1);
|
|
|
|
if (view_type != -1)
|
|
{
|
|
if (view_type == GIMP_VIEW_TYPE_LIST)
|
|
SET_ACTIVE ("/View as List", TRUE);
|
|
else if (view_type == GIMP_VIEW_TYPE_GRID)
|
|
SET_ACTIVE ("/View as Grid", TRUE);
|
|
else
|
|
SET_ACTIVE ("/View as Tree", TRUE);
|
|
|
|
SET_SENSITIVE ("/View as Grid", grid_view_available);
|
|
SET_SENSITIVE ("/View as List", list_view_available);
|
|
SET_SENSITIVE ("/View as Tree", tree_view_available);
|
|
}
|
|
|
|
if (GIMP_IS_IMAGE_DOCK (dockbook->dock))
|
|
{
|
|
SET_VISIBLE ("/image-menu-separator", TRUE);
|
|
SET_VISIBLE ("/Show Image Menu", TRUE);
|
|
SET_VISIBLE ("/Auto Follow Active Image", TRUE);
|
|
|
|
SET_ACTIVE ("/Show Image Menu",
|
|
GIMP_IMAGE_DOCK (dockbook->dock)->show_image_menu);
|
|
SET_ACTIVE ("/Auto Follow Active Image",
|
|
GIMP_IMAGE_DOCK (dockbook->dock)->auto_follow_active);
|
|
}
|
|
else
|
|
{
|
|
SET_VISIBLE ("/image-menu-separator", FALSE);
|
|
SET_VISIBLE ("/Show Image Menu", FALSE);
|
|
SET_VISIBLE ("/Auto Follow Active Image", FALSE);
|
|
}
|
|
|
|
#undef SET_ACTIVE
|
|
#undef SET_VISIBLE
|
|
#undef SET_SENSITIVE
|
|
}
|
|
}
|