dialogs-commands.c 5.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* 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"

21 22
#include <string.h>

23 24
#include <gtk/gtk.h>

25 26
#include "libgimpwidgets/gimpwidgets.h"

Michael Natterer's avatar
Michael Natterer committed
27
#include "actions-types.h"
28

29 30
#include "core/gimp.h"

31
#include "widgets/gimpdialogfactory.h"
32
#include "widgets/gimpdockable.h"
33
#include "widgets/gimpdockbook.h"
Michael Natterer's avatar
Michael Natterer committed
34
#include "widgets/gimpimagedock.h"
35

36
#include "dialogs/dialogs.h"
37

38 39
#include "actions.h"
#include "dialogs-commands.h"
40 41


42 43
/*  local function prototypes  */

44
static void   dialogs_create_dock (GdkScreen   *screen,
45
                                   gboolean     show_image_menu,
46
                                   const gchar *tabs[],
47 48 49 50 51
                                   gint         n_tabs);


/*  public functions  */

52
void
53
dialogs_show_toolbox_cmd_callback (GtkAction *action,
54
                                   gpointer   data)
55 56 57 58
{
  dialogs_show_toolbox ();
}

59
void
60 61 62
dialogs_create_toplevel_cmd_callback (GtkAction   *action,
                                      const gchar *value,
				      gpointer     data)
63
{
64 65
  GtkWidget *widget;
  return_if_no_widget (widget, data);
Michael Natterer's avatar
Michael Natterer committed
66

67 68 69
  if (value)
    gimp_dialog_factory_dialog_new (global_dialog_factory,
                                    gtk_widget_get_screen (widget),
70
                                    value, -1, TRUE);
71 72
}

73
void
74 75 76
dialogs_create_dockable_cmd_callback (GtkAction   *action,
                                      const gchar *value,
				      gpointer     data)
77
{
78 79
  GtkWidget *widget;
  return_if_no_widget (widget, data);
80

81 82 83 84
  if (value)
    gimp_dialog_factory_dialog_raise (global_dock_factory,
                                      gtk_widget_get_screen (widget),
                                      value, -1);
85 86
}

87
void
88
dialogs_create_lc_cmd_callback (GtkAction *action,
89
                                gpointer   data)
90
{
91
  GtkWidget *widget;
92
  static const gchar *tabs[] =
93
  {
94 95 96
    "gimp-layer-list",
    "gimp-channel-list",
    "gimp-vectors-list",
97
    "gimp-undo-history"
98
  };
99

100 101
  return_if_no_widget (widget, data);

102
  dialogs_create_dock (gtk_widget_get_screen (widget), TRUE,
103
                       tabs, G_N_ELEMENTS (tabs));
104
}
105

106
void
107
dialogs_create_data_cmd_callback (GtkAction *action,
108
                                  gpointer   data)
109
{
110
  GtkWidget *widget;
111 112 113 114 115 116 117 118
  static const gchar *tabs[] =
  {
    "gimp-brush-grid",
    "gimp-pattern-grid",
    "gimp-gradient-list",
    "gimp-palette-list",
    "gimp-font-list"
  };
119

120 121
  return_if_no_widget (widget, data);

122
  dialogs_create_dock (gtk_widget_get_screen (widget), FALSE,
123
                       tabs, G_N_ELEMENTS (tabs));
124
}
125

126
void
127
dialogs_create_stuff_cmd_callback (GtkAction *action,
128
                                   gpointer   data)
129
{
130
  GtkWidget *widget;
131
  static const gchar *tabs[] =
132
  {
133 134
    "gimp-buffer-list",
    "gimp-image-list",
135 136
    "gimp-document-list",
    "gimp-template-list"
137
  };
138

139 140
  return_if_no_widget (widget, data);

141
  dialogs_create_dock (gtk_widget_get_screen (widget), FALSE,
142
                       tabs, G_N_ELEMENTS (tabs));
143
}
144

145 146 147 148 149 150 151
void
dialogs_show_toolbox (void)
{
  if (! global_toolbox_factory->open_dialogs)
    {
      GtkWidget *toolbox;

152 153
      toolbox = gimp_dialog_factory_dock_new (global_toolbox_factory,
                                              gdk_screen_get_default ());
154 155 156 157 158

      gtk_widget_show (toolbox);
    }
  else
    {
159
      gimp_dialog_factories_toggle (global_toolbox_factory, TRUE);
160 161
    }
}
162 163 164 165 166


/*  private functions  */

static void
167
dialogs_create_dock (GdkScreen   *screen,
168
                     gboolean     show_image_menu,
169
                     const gchar *tabs[],
170 171 172 173 174 175 176
                     gint         n_tabs)
{
  GtkWidget *dock;
  GtkWidget *dockbook;
  GtkWidget *dockable;
  gint       i;

177
  dock = gimp_dialog_factory_dock_new (global_dock_factory, screen);
178

179 180
  gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (dock), show_image_menu);

181 182 183 184 185 186 187
  dockbook = gimp_dockbook_new (global_dock_factory->menu_factory);

  gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), 0);

  for (i = 0; i < n_tabs; i++)
    {
      dockable = gimp_dialog_factory_dialog_new (global_dock_factory,
188
                                                 screen,
189
                                                 tabs[i], -1, TRUE);
190 191 192 193 194 195 196

      if (dockable && ! GIMP_DOCKABLE (dockable)->dockbook)
        gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dockable), -1, -1);
    }

  gtk_widget_show (dock);
}