brushes-menu.c 2.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* 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 <gtk/gtk.h>

23 24
#include "libgimpwidgets/gimpwidgets.h"

25
#include "gui-types.h"
26 27

#include "core/gimpcontext.h"
28
#include "core/gimpdata.h"
29

30
#include "widgets/gimpcontainereditor.h"
31
#include "widgets/gimpcontainerview.h"
32
#include "widgets/gimpdatafactoryview.h"
33
#include "widgets/gimphelp-ids.h"
34
#include "widgets/gimpitemfactory.h"
35

36 37 38
#include "brushes-menu.h"
#include "data-commands.h"
#include "menus.h"
39

40
#include "gimp-intl.h"
41 42


43 44
GimpItemFactoryEntry brushes_menu_entries[] =
{
45 46 47 48 49 50 51 52
  { { N_("/_Edit Brush..."), NULL,
      data_edit_data_cmd_callback, 0,
      "<StockItem>", GIMP_STOCK_EDIT },
    NULL,
    GIMP_HELP_BRUSH_EDIT, NULL },

  MENU_SEPARATOR ("/---"),

53
  { { N_("/_New Brush"), "",
54 55 56
      data_new_data_cmd_callback, 0,
      "<StockItem>", GTK_STOCK_NEW },
    NULL,
57
    GIMP_HELP_BRUSH_NEW, NULL },
58
  { { N_("/D_uplicate Brush"), NULL,
59 60 61
      data_duplicate_data_cmd_callback, 0,
      "<StockItem>", GIMP_STOCK_DUPLICATE },
    NULL,
62
    GIMP_HELP_BRUSH_DUPLICATE, NULL },
63
  { { N_("/_Delete Brush..."), "",
64 65 66
      data_delete_data_cmd_callback, 0,
      "<StockItem>", GTK_STOCK_DELETE },
    NULL,
67
    GIMP_HELP_BRUSH_DELETE, NULL },
68 69 70

  MENU_SEPARATOR ("/---"),

71
  { { N_("/_Refresh Brushes"), "",
72 73 74
      data_refresh_data_cmd_callback, 0,
      "<StockItem>", GTK_STOCK_REFRESH },
    NULL,
75
    GIMP_HELP_BRUSH_REFRESH, NULL }
76 77 78 79
};

gint n_brushes_menu_entries = G_N_ELEMENTS (brushes_menu_entries);

80

81
void
82
brushes_menu_update (GtkItemFactory *factory,
83
                     gpointer        user_data)
84
{
85 86
  GimpContainerEditor *editor;
  GimpBrush           *brush;
87
  GimpData            *data = NULL;
88

89
  editor = GIMP_CONTAINER_EDITOR (user_data);
90 91 92

  brush = gimp_context_get_brush (editor->view->context);

93
  if (brush)
94
    data = GIMP_DATA (brush);
95

96
#define SET_SENSITIVE(menu,condition) \
97
        gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
98

99
  SET_SENSITIVE ("/Edit Brush...",
100
		 brush && GIMP_DATA_FACTORY_VIEW (editor)->data_edit_func);
101 102
  SET_SENSITIVE ("/Duplicate Brush",
		 brush && GIMP_DATA_GET_CLASS (data)->duplicate);
103
  SET_SENSITIVE ("/Delete Brush...",
104
		 brush && data->writeable && !data->internal);
105 106 107

#undef SET_SENSITIVE
}