gimpflipoptions.c 4.66 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
 */

#include "config.h"

20
#include <gegl.h>
21 22
#include <gtk/gtk.h>

23
#include "libgimpconfig/gimpconfig.h"
24 25 26 27 28 29 30
#include "libgimpwidgets/gimpwidgets.h"

#include "tools-types.h"

#include "widgets/gimpwidgets-utils.h"

#include "gimpflipoptions.h"
31
#include "gimptooloptions-gui.h"
32

33
#include "gimp-intl.h"
34 35


36 37 38 39 40 41 42
enum
{
  PROP_0,
  PROP_FLIP_TYPE
};


43 44 45 46 47 48 49 50
static void   gimp_flip_options_set_property (GObject      *object,
                                              guint         property_id,
                                              const GValue *value,
                                              GParamSpec   *pspec);
static void   gimp_flip_options_get_property (GObject      *object,
                                              guint         property_id,
                                              GValue       *value,
                                              GParamSpec   *pspec);
51

52

53
G_DEFINE_TYPE (GimpFlipOptions, gimp_flip_options,
54
               GIMP_TYPE_TRANSFORM_OPTIONS)
55

56

57
static void
58 59
gimp_flip_options_class_init (GimpFlipOptionsClass *klass)
{
60
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
61 62 63 64 65

  object_class->set_property = gimp_flip_options_set_property;
  object_class->get_property = gimp_flip_options_get_property;

  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FLIP_TYPE,
66 67
                                 "flip-type",
                                 N_("Direction of flipping"),
68 69
                                 GIMP_TYPE_ORIENTATION_TYPE,
                                 GIMP_ORIENTATION_HORIZONTAL,
70
                                 GIMP_PARAM_STATIC_STRINGS);
71 72
}

73 74 75 76 77
static void
gimp_flip_options_init (GimpFlipOptions *options)
{
}

78 79 80 81 82
static void
gimp_flip_options_set_property (GObject      *object,
                                guint         property_id,
                                const GValue *value,
                                GParamSpec   *pspec)
83
{
84
  GimpFlipOptions *options = GIMP_FLIP_OPTIONS (object);
85

86 87 88 89 90 91 92 93 94 95
  switch (property_id)
    {
    case PROP_FLIP_TYPE:
      options->flip_type = g_value_get_enum (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
96

97 98 99 100 101 102
static void
gimp_flip_options_get_property (GObject    *object,
                                guint       property_id,
                                GValue     *value,
                                GParamSpec *pspec)
{
103
  GimpFlipOptions *options = GIMP_FLIP_OPTIONS (object);
104 105 106 107 108 109 110 111 112 113 114 115

  switch (property_id)
    {
    case PROP_FLIP_TYPE:
      g_value_set_enum (value, options->flip_type);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}

116
GtkWidget *
117 118
gimp_flip_options_gui (GimpToolOptions *tool_options)
{
119 120 121 122 123 124 125 126 127 128
  GObject         *config = G_OBJECT (tool_options);
  GtkWidget       *vbox   = gimp_tool_options_gui (tool_options);
  GtkWidget       *hbox;
  GtkWidget       *box;
  GtkWidget       *label;
  GtkWidget       *frame;
  gchar           *str;
  GdkModifierType  toggle_mask;

  toggle_mask = gimp_get_toggle_behavior_mask ();
129

Michael Natterer's avatar
Michael Natterer committed
130
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
131 132 133 134 135 136 137
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new (_("Affect:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

138
  box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0);
139 140 141
  gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
  gtk_widget_show (box);

142
  /*  tool toggle  */
143
  str = g_strdup_printf (_("Flip Type  (%s)"),
144
                         gimp_get_mod_string (toggle_mask));
145

146 147 148 149
  frame = gimp_prop_enum_radio_frame_new (config, "flip-type",
                                          str,
                                          GIMP_ORIENTATION_HORIZONTAL,
                                          GIMP_ORIENTATION_VERTICAL);
150 151 152 153
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  g_free (str);
154 155

  return vbox;
156
}