~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpwidgets-constructors.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
20
20
 
21
21
#include <gtk/gtk.h>
22
22
 
23
 
#ifdef __GNUC__
24
 
#warning GIMP_DISABLE_DEPRECATED
25
 
#endif
26
 
#undef GIMP_DISABLE_DEPRECATED
27
 
 
 
23
#include "libgimpbase/gimpbase.h"
28
24
#include "libgimpwidgets/gimpwidgets.h"
29
25
 
30
26
#include "widgets-types.h"
34
30
#include "gimp-intl.h"
35
31
 
36
32
 
 
33
/*  local function prototypes  */
 
34
 
 
35
static gboolean   gimp_paint_mode_menu_separator_func (GtkTreeModel *model,
 
36
                                                       GtkTreeIter  *iter,
 
37
                                                       gpointer      data);
 
38
 
 
39
 
 
40
/*  public functions  */
 
41
 
 
42
static void
 
43
gimp_enum_store_insert_value_after (GimpEnumStore *store,
 
44
                                    gint           after,
 
45
                                    gint           insert_value)
 
46
{
 
47
  GtkTreeIter iter;
 
48
 
 
49
  g_return_if_fail (GIMP_IS_ENUM_STORE (store));
 
50
 
 
51
  if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
 
52
                                      after, &iter))
 
53
    {
 
54
      GEnumValue *enum_value;
 
55
 
 
56
      enum_value = g_enum_get_value (store->enum_class, insert_value);
 
57
 
 
58
      if (enum_value)
 
59
        {
 
60
          GtkTreeIter  value_iter;
 
61
          const gchar *desc;
 
62
 
 
63
          gtk_list_store_insert_after (GTK_LIST_STORE (store),
 
64
                                       &value_iter, &iter);
 
65
 
 
66
          desc = gimp_enum_value_get_desc (store->enum_class, enum_value);
 
67
 
 
68
          gtk_list_store_set (GTK_LIST_STORE (store), &value_iter,
 
69
                              GIMP_INT_STORE_VALUE, enum_value->value,
 
70
                              GIMP_INT_STORE_LABEL, desc,
 
71
                              -1);
 
72
        }
 
73
    }
 
74
}
 
75
 
 
76
static void
 
77
gimp_int_store_insert_separator_after (GimpIntStore *store,
 
78
                                       gint          after,
 
79
                                       gint          separator_value)
 
80
{
 
81
  GtkTreeIter iter;
 
82
 
 
83
  g_return_if_fail (GIMP_IS_INT_STORE (store));
 
84
 
 
85
  if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
 
86
                                      after, &iter))
 
87
    {
 
88
      GtkTreeIter sep_iter;
 
89
 
 
90
      gtk_list_store_insert_after (GTK_LIST_STORE (store),
 
91
                                   &sep_iter, &iter);
 
92
      gtk_list_store_set (GTK_LIST_STORE (store), &sep_iter,
 
93
                          GIMP_INT_STORE_VALUE, separator_value,
 
94
                          -1);
 
95
    }
 
96
}
 
97
 
37
98
GtkWidget *
38
 
gimp_paint_mode_menu_new (GCallback            callback,
39
 
                          gpointer             data,
40
 
                          gboolean             with_behind_mode,
41
 
                          GimpLayerModeEffects initial)
 
99
gimp_paint_mode_menu_new (gboolean with_behind_mode,
 
100
                          gboolean with_replace_modes)
42
101
{
43
 
  GtkWidget *menu;
 
102
  GtkListStore *store;
 
103
  GtkWidget    *combo;
 
104
 
 
105
  store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
 
106
                                           21,
 
107
                                           GIMP_NORMAL_MODE,
 
108
                                           GIMP_DISSOLVE_MODE,
 
109
 
 
110
                                           GIMP_MULTIPLY_MODE,
 
111
                                           GIMP_DIVIDE_MODE,
 
112
                                           GIMP_SCREEN_MODE,
 
113
                                           GIMP_OVERLAY_MODE,
 
114
 
 
115
                                           GIMP_DODGE_MODE,
 
116
                                           GIMP_BURN_MODE,
 
117
                                           GIMP_HARDLIGHT_MODE,
 
118
                                           GIMP_SOFTLIGHT_MODE,
 
119
                                           GIMP_GRAIN_EXTRACT_MODE,
 
120
                                           GIMP_GRAIN_MERGE_MODE,
 
121
 
 
122
                                           GIMP_DIFFERENCE_MODE,
 
123
                                           GIMP_ADDITION_MODE,
 
124
                                           GIMP_SUBTRACT_MODE,
 
125
                                           GIMP_DARKEN_ONLY_MODE,
 
126
                                           GIMP_LIGHTEN_ONLY_MODE,
 
127
 
 
128
                                           GIMP_HUE_MODE,
 
129
                                           GIMP_SATURATION_MODE,
 
130
                                           GIMP_COLOR_MODE,
 
131
                                           GIMP_VALUE_MODE);
 
132
 
 
133
  gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
 
134
                                         GIMP_DISSOLVE_MODE, -1);
 
135
  gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
 
136
                                         GIMP_OVERLAY_MODE, -1);
 
137
  gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
 
138
                                         GIMP_GRAIN_MERGE_MODE, -1);
 
139
  gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
 
140
                                         GIMP_LIGHTEN_ONLY_MODE, -1);
44
141
 
45
142
  if (with_behind_mode)
46
143
    {
47
 
      menu = gimp_int_option_menu_new
48
 
        (FALSE, callback, data, initial,
49
 
 
50
 
         _("Normal"),        GIMP_NORMAL_MODE,        NULL,
51
 
         _("Dissolve"),      GIMP_DISSOLVE_MODE,      NULL,
52
 
         _("Behind"),        GIMP_BEHIND_MODE,        NULL,
53
 
         _("Color erase"),   GIMP_COLOR_ERASE_MODE,   NULL,
54
 
         "---",              0,                       NULL,
55
 
         _("Multiply"),      GIMP_MULTIPLY_MODE,      NULL,
56
 
         _("Divide"),        GIMP_DIVIDE_MODE,        NULL,
57
 
         _("Screen"),        GIMP_SCREEN_MODE,        NULL,
58
 
         _("Overlay"),       GIMP_OVERLAY_MODE,       NULL,
59
 
         "---",              0,                       NULL,
60
 
         _("Dodge"),         GIMP_DODGE_MODE,         NULL,
61
 
         _("Burn"),          GIMP_BURN_MODE,          NULL,
62
 
         _("Hard light"),    GIMP_HARDLIGHT_MODE,     NULL,
63
 
         _("Soft light"),    GIMP_SOFTLIGHT_MODE,     NULL,
64
 
         _("Grain extract"), GIMP_GRAIN_EXTRACT_MODE, NULL,
65
 
         _("Grain merge"),   GIMP_GRAIN_MERGE_MODE,   NULL,
66
 
         "---",              0,                       NULL,
67
 
         _("Difference"),    GIMP_DIFFERENCE_MODE,    NULL,
68
 
         _("Addition"),      GIMP_ADDITION_MODE,      NULL,
69
 
         _("Subtract"),      GIMP_SUBTRACT_MODE,      NULL,
70
 
         _("Darken only"),   GIMP_DARKEN_ONLY_MODE,   NULL,
71
 
         _("Lighten only"),  GIMP_LIGHTEN_ONLY_MODE,  NULL,
72
 
         "---",              0,                       NULL,
73
 
         _("Hue"),           GIMP_HUE_MODE,           NULL,
74
 
         _("Saturation"),    GIMP_SATURATION_MODE,    NULL,
75
 
         _("Color"),         GIMP_COLOR_MODE,         NULL,
76
 
         _("Value"),         GIMP_VALUE_MODE,         NULL,
77
 
 
78
 
         NULL);
 
144
      gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
 
145
                                          GIMP_DISSOLVE_MODE,
 
146
                                          GIMP_BEHIND_MODE);
 
147
      gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
 
148
                                          GIMP_BEHIND_MODE,
 
149
                                          GIMP_COLOR_ERASE_MODE);
79
150
    }
80
 
  else
 
151
 
 
152
  if (with_replace_modes)
81
153
    {
82
 
      menu = gimp_int_option_menu_new
83
 
        (FALSE, callback, data, initial,
84
 
 
85
 
         _("Normal"),        GIMP_NORMAL_MODE,        NULL,
86
 
         _("Dissolve"),      GIMP_DISSOLVE_MODE,      NULL,
87
 
         "---",              0,                       NULL,
88
 
         _("Multiply"),      GIMP_MULTIPLY_MODE,      NULL,
89
 
         _("Divide"),        GIMP_DIVIDE_MODE,        NULL,
90
 
         _("Screen"),        GIMP_SCREEN_MODE,        NULL,
91
 
         _("Overlay"),       GIMP_OVERLAY_MODE,       NULL,
92
 
         "---",              0,                       NULL,
93
 
         _("Dodge"),         GIMP_DODGE_MODE,         NULL,
94
 
         _("Burn"),          GIMP_BURN_MODE,          NULL,
95
 
         _("Hard light"),    GIMP_HARDLIGHT_MODE,     NULL,
96
 
         _("Soft light"),    GIMP_SOFTLIGHT_MODE,     NULL,
97
 
         _("Grain extract"), GIMP_GRAIN_EXTRACT_MODE, NULL,
98
 
         _("Grain merge"),   GIMP_GRAIN_MERGE_MODE,   NULL,
99
 
         "---",              0,                       NULL,
100
 
         _("Difference"),    GIMP_DIFFERENCE_MODE,    NULL,
101
 
         _("Addition"),      GIMP_ADDITION_MODE,      NULL,
102
 
         _("Subtract"),      GIMP_SUBTRACT_MODE,      NULL,
103
 
         _("Darken only"),   GIMP_DARKEN_ONLY_MODE,   NULL,
104
 
         _("Lighten only"),  GIMP_LIGHTEN_ONLY_MODE,  NULL,
105
 
         "---",              0,                       NULL,
106
 
         _("Hue"),           GIMP_HUE_MODE,           NULL,
107
 
         _("Saturation"),    GIMP_SATURATION_MODE,    NULL,
108
 
         _("Color"),         GIMP_COLOR_MODE,         NULL,
109
 
         _("Value"),         GIMP_VALUE_MODE,         NULL,
110
 
 
111
 
         NULL);
 
154
      gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
 
155
                                          GIMP_NORMAL_MODE,
 
156
                                          GIMP_REPLACE_MODE);
 
157
      gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
 
158
                                          GIMP_COLOR_ERASE_MODE,
 
159
                                          GIMP_ERASE_MODE);
 
160
      gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
 
161
                                          GIMP_ERASE_MODE,
 
162
                                          GIMP_ANTI_ERASE_MODE);
112
163
    }
113
164
 
114
 
  return menu;
 
165
  combo = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store));
 
166
  g_object_unref (store);
 
167
 
 
168
  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
 
169
                                        gimp_paint_mode_menu_separator_func,
 
170
                                        GINT_TO_POINTER (-1),
 
171
                                        NULL);
 
172
 
 
173
  return combo;
115
174
}
116
175
 
117
 
void
118
 
gimp_paint_mode_menu_set_history (GtkOptionMenu        *menu,
119
 
                                  GimpLayerModeEffects  value)
 
176
 
 
177
/*  private functions  */
 
178
 
 
179
static gboolean
 
180
gimp_paint_mode_menu_separator_func (GtkTreeModel *model,
 
181
                                     GtkTreeIter  *iter,
 
182
                                     gpointer      data)
120
183
{
121
 
  gimp_int_option_menu_set_history (menu, value);
 
184
  gint value;
 
185
 
 
186
  gtk_tree_model_get (model, iter, GIMP_INT_STORE_VALUE, &value, -1);
 
187
 
 
188
  return value == GPOINTER_TO_INT (data);
122
189
}