vectors-options-dialog.c 4.46 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

#include "config.h"

#include <string.h>

22
#include <gegl.h>
23 24 25 26 27 28
#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "dialogs-types.h"

29
#include "core/gimpcontext.h"
30 31 32 33 34 35 36 37 38 39 40
#include "core/gimpimage.h"

#include "vectors/gimpvectors.h"

#include "widgets/gimpviewabledialog.h"

#include "vectors-options-dialog.h"

#include "gimp-intl.h"


41 42
static void  vectors_options_dialog_free (VectorsOptionsDialog *dialog);

43 44

VectorsOptionsDialog *
45
vectors_options_dialog_new (GimpImage   *image,
46
                            GimpVectors *vectors,
47
                            GimpContext *context,
48 49 50
                            GtkWidget   *parent,
                            const gchar *title,
                            const gchar *role,
51
                            const gchar *icon_name,
52
                            const gchar *desc,
53 54
                            const gchar *help_id,
                            const gchar *vectors_name)
55 56 57 58 59 60 61
{
  VectorsOptionsDialog *options;
  GimpViewable         *viewable;
  GtkWidget            *hbox;
  GtkWidget            *vbox;
  GtkWidget            *table;

62
  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
63
  g_return_val_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors), NULL);
64
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
65 66 67
  g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
  g_return_val_if_fail (title != NULL, NULL);
  g_return_val_if_fail (role != NULL, NULL);
68
  g_return_val_if_fail (icon_name != NULL, NULL);
69 70 71
  g_return_val_if_fail (desc != NULL, NULL);
  g_return_val_if_fail (help_id != NULL, NULL);

72
  options = g_slice_new0 (VectorsOptionsDialog);
73

74
  options->image  = image;
75 76 77 78 79
  options->vectors = vectors;

  if (vectors)
    viewable = GIMP_VIEWABLE (vectors);
  else
80
    viewable = GIMP_VIEWABLE (image);
81 82

  options->dialog =
83
    gimp_viewable_dialog_new (viewable, context,
84
                              title, role, icon_name, desc,
85 86 87 88 89 90 91 92 93
                              parent,
                              gimp_standard_help_func,
                              help_id,

                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                              GTK_STOCK_OK,     GTK_RESPONSE_OK,

                              NULL);

94
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (options->dialog),
95 96 97
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);
98

99
  g_object_weak_ref (G_OBJECT (options->dialog),
100
                     (GWeakNotify) vectors_options_dialog_free, options);
101

Michael Natterer's avatar
Michael Natterer committed
102
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
103
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
104 105
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (options->dialog))),
                      hbox, TRUE, TRUE, 0);
106 107
  gtk_widget_show (hbox);

Michael Natterer's avatar
Michael Natterer committed
108
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
109 110 111 112 113 114 115 116 117 118 119 120 121
  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  table = gtk_table_new (1, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
  gtk_widget_show (table);

  options->name_entry = gtk_entry_new ();
  gtk_widget_set_size_request (options->name_entry, 150, -1);
  gtk_entry_set_activates_default (GTK_ENTRY (options->name_entry), TRUE);
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
122
                             _("Path name:"), 0.0, 0.5,
123 124 125 126 127 128
                             options->name_entry, 1, FALSE);

  gtk_entry_set_text (GTK_ENTRY (options->name_entry), vectors_name);

  return options;
}
129 130 131 132 133 134

static void
vectors_options_dialog_free (VectorsOptionsDialog *dialog)
{
  g_slice_free (VectorsOptionsDialog, dialog);
}