~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/tools/gimprectangleoptions.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
43
42
  COLUMN_LEFT_NUMBER,
44
43
  COLUMN_RIGHT_NUMBER,
45
44
  COLUMN_TEXT,
46
 
  NUM_COLUMNS
 
45
  N_COLUMNS
47
46
};
48
47
 
49
48
 
101
100
    {
102
101
      g_object_interface_install_property (iface,
103
102
                                           g_param_spec_boolean ("auto-shrink",
104
 
                                                                 NULL, NULL,
 
103
                                                                 NULL,
 
104
                                                                 N_("Automatically shrink to the nearest "
 
105
                                                                    "rectangular shape in a layer"),
105
106
                                                                 FALSE,
106
107
                                                                 GIMP_CONFIG_PARAM_FLAGS |
107
108
                                                                 GIMP_PARAM_STATIC_STRINGS));
117
118
 
118
119
      g_object_interface_install_property (iface,
119
120
                                           g_param_spec_enum ("guide",
120
 
                                                              NULL, NULL,
121
 
                                                              GIMP_TYPE_RECTANGLE_GUIDE,
122
 
                                                              GIMP_RECTANGLE_GUIDE_NONE,
 
121
                                                              NULL,
 
122
                                                              N_("Composition guides such as rule of thirds"),
 
123
                                                              GIMP_TYPE_GUIDES_TYPE,
 
124
                                                              GIMP_GUIDES_NONE,
123
125
                                                              GIMP_CONFIG_PARAM_FLAGS |
124
126
                                                              GIMP_PARAM_STATIC_STRINGS));
125
127
 
126
128
      g_object_interface_install_property (iface,
127
129
                                           g_param_spec_double ("x",
128
 
                                                                NULL, NULL,
 
130
                                                                NULL,
 
131
                                                                N_("X coordinate of top left corner"),
129
132
                                                                -GIMP_MAX_IMAGE_SIZE,
130
133
                                                                GIMP_MAX_IMAGE_SIZE,
131
134
                                                                0.0,
134
137
 
135
138
      g_object_interface_install_property (iface,
136
139
                                           g_param_spec_double ("y",
137
 
                                                                NULL, NULL,
 
140
                                                                NULL,
 
141
                                                                N_("Y coordinate of top left corner"),
138
142
                                                                -GIMP_MAX_IMAGE_SIZE,
139
143
                                                                GIMP_MAX_IMAGE_SIZE,
140
144
                                                                0.0,
143
147
 
144
148
      g_object_interface_install_property (iface,
145
149
                                           g_param_spec_double ("width",
146
 
                                                                NULL, NULL,
 
150
                                                                NULL,
 
151
                                                                N_("Width of selection"),
147
152
                                                                0.0, GIMP_MAX_IMAGE_SIZE,
148
153
                                                                0.0,
149
154
                                                                GIMP_PARAM_READWRITE |
151
156
 
152
157
      g_object_interface_install_property (iface,
153
158
                                           g_param_spec_double ("height",
154
 
                                                                NULL, NULL,
 
159
                                                                NULL,
 
160
                                                                N_("Height of selection"),
155
161
                                                                0.0, GIMP_MAX_IMAGE_SIZE,
156
162
                                                                0.0,
157
163
                                                                GIMP_PARAM_READWRITE |
159
165
 
160
166
      g_object_interface_install_property (iface,
161
167
                                           gimp_param_spec_unit ("position-unit",
162
 
                                                                 NULL, NULL,
 
168
                                                                 NULL,
 
169
                                                                 N_("Unit of top left corner coordinate"),
163
170
                                                                 TRUE, TRUE,
164
171
                                                                 GIMP_UNIT_PIXEL,
165
172
                                                                 GIMP_PARAM_READWRITE |
167
174
 
168
175
      g_object_interface_install_property (iface,
169
176
                                           gimp_param_spec_unit ("size-unit",
170
 
                                                                 NULL, NULL,
 
177
                                                                 NULL,
 
178
                                                                 N_("Unit of selection size"),
171
179
                                                                 TRUE, TRUE,
172
180
                                                                 GIMP_UNIT_PIXEL,
173
181
                                                                 GIMP_PARAM_READWRITE |
175
183
 
176
184
      g_object_interface_install_property (iface,
177
185
                                           g_param_spec_boolean ("fixed-rule-active",
178
 
                                                                 NULL, NULL,
 
186
                                                                 NULL,
 
187
                                                                 N_("Enable lock of aspect ratio, "
 
188
                                                                    "width, height or size"),
179
189
                                                                 FALSE,
180
190
                                                                 GIMP_CONFIG_PARAM_FLAGS |
181
191
                                                                 GIMP_PARAM_STATIC_STRINGS));
182
192
 
183
193
      g_object_interface_install_property (iface,
184
194
                                           g_param_spec_enum ("fixed-rule",
185
 
                                                              NULL, NULL,
 
195
                                                              NULL,
 
196
                                                              N_("Choose what has to be locked"),
186
197
                                                              GIMP_TYPE_RECTANGLE_TOOL_FIXED_RULE,
187
198
                                                              GIMP_RECTANGLE_TOOL_FIXED_ASPECT,
188
199
                                                              GIMP_CONFIG_PARAM_FLAGS |
190
201
 
191
202
      g_object_interface_install_property (iface,
192
203
                                           g_param_spec_double ("desired-fixed-width",
193
 
                                                                NULL, NULL,
 
204
                                                                NULL,
 
205
                                                                N_("Custom fixed width"),
194
206
                                                                0.0, GIMP_MAX_IMAGE_SIZE,
195
207
                                                                100.0,
196
208
                                                                GIMP_CONFIG_PARAM_FLAGS |
198
210
 
199
211
      g_object_interface_install_property (iface,
200
212
                                           g_param_spec_double ("desired-fixed-height",
201
 
                                                                NULL, NULL,
 
213
                                                                NULL,
 
214
                                                                N_("Custom fixed height"),
202
215
                                                                0.0, GIMP_MAX_IMAGE_SIZE,
203
216
                                                                100.0,
204
217
                                                                GIMP_CONFIG_PARAM_FLAGS |
291
304
 
292
305
      g_object_interface_install_property (iface,
293
306
                                           gimp_param_spec_unit ("fixed-unit",
294
 
                                                                 NULL, NULL,
 
307
                                                                 NULL,
 
308
                                                                 N_("Unit of fixed width, height or size"),
295
309
                                                                 TRUE, TRUE,
296
310
                                                                 GIMP_UNIT_PIXEL,
297
311
                                                                 GIMP_PARAM_READWRITE |
299
313
 
300
314
      g_object_interface_install_property (iface,
301
315
                                           g_param_spec_boolean ("fixed-center",
302
 
                                                                 NULL, NULL,
 
316
                                                                 NULL,
 
317
                                                                 N_("Expand selection from center outwards"),
303
318
                                                                 FALSE,
304
319
                                                                 GIMP_CONFIG_PARAM_FLAGS |
305
320
                                                                 GIMP_PARAM_STATIC_STRINGS));
335
350
    {
336
351
      private = g_slice_new0 (GimpRectangleOptionsPrivate);
337
352
 
338
 
      private->aspect_history = gtk_list_store_new (NUM_COLUMNS,
 
353
      private->aspect_history = gtk_list_store_new (N_COLUMNS,
339
354
                                                    G_TYPE_DOUBLE,
340
355
                                                    G_TYPE_DOUBLE,
341
356
                                                    G_TYPE_STRING);
342
357
 
343
 
      private->size_history = gtk_list_store_new (NUM_COLUMNS,
 
358
      private->size_history = gtk_list_store_new (N_COLUMNS,
344
359
                                                  G_TYPE_DOUBLE,
345
360
                                                  G_TYPE_DOUBLE,
346
361
                                                  G_TYPE_STRING);
658
673
}
659
674
 
660
675
/**
 
676
 * gimp_rectangle_options_get_width_entry:
 
677
 * @rectangle_options:
 
678
 *
 
679
 * Returns: GtkEntry used to enter desired width of rectangle. For
 
680
 *          testing purposes.
 
681
 **/
 
682
GtkWidget *
 
683
gimp_rectangle_options_get_width_entry (GimpRectangleOptions *rectangle_options)
 
684
{
 
685
  GimpRectangleOptionsPrivate *private;
 
686
 
 
687
  private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (rectangle_options);
 
688
 
 
689
  return private->width_entry;
 
690
}
 
691
  
 
692
/**
661
693
 * gimp_rectangle_options_fixed_rule_changed:
662
694
 * @combo_box:
663
695
 * @private:
750
782
  frame = gimp_frame_new (NULL);
751
783
 
752
784
  /*  title  */
753
 
  hbox = gtk_hbox_new (FALSE, 4);
 
785
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
754
786
  gtk_frame_set_label_widget (GTK_FRAME (frame), hbox);
755
787
  gtk_widget_show (hbox);
756
788
 
758
790
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
759
791
  gtk_widget_show (label);
760
792
 
761
 
  menu = gimp_prop_unit_menu_new (config, unit_property_name, "%a");
 
793
  menu = gimp_prop_unit_combo_box_new (config, unit_property_name);
762
794
  gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
763
795
  gtk_widget_show (menu);
764
796
 
765
797
  /*  content  */
766
 
  hbox = gtk_hbox_new (FALSE, 4);
 
798
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
767
799
  gtk_container_add (GTK_CONTAINER (frame), hbox);
768
800
  gtk_widget_show (hbox);
769
801
 
822
854
 
823
855
    /* Setup frame title widgets */
824
856
 
825
 
    hbox = gtk_hbox_new (FALSE, 2);
 
857
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
826
858
    gtk_frame_set_label_widget (GTK_FRAME (frame), hbox);
827
859
    gtk_widget_show (hbox);
828
860
 
845
877
 
846
878
    /* Setup frame content */
847
879
 
848
 
    vbox2 = gtk_vbox_new (FALSE, 0);
 
880
    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
849
881
    gtk_container_add (GTK_CONTAINER (frame), vbox2);
850
882
    gtk_widget_show (vbox2);
851
883
 
852
884
    size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
853
885
 
854
886
    /* Fixed aspect entry/buttons */
855
 
    private->fixed_aspect_hbox = gtk_hbox_new (FALSE, 2);
 
887
    private->fixed_aspect_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
856
888
    gtk_box_pack_start (GTK_BOX (vbox2), private->fixed_aspect_hbox,
857
889
                        FALSE, FALSE, 0);
858
890
    gtk_size_group_add_widget (size_group, private->fixed_aspect_hbox);
859
891
    g_object_unref (size_group);
860
892
    /* don't show */
861
893
 
 
894
    g_object_add_weak_pointer (G_OBJECT (private->fixed_aspect_hbox),
 
895
                               (gpointer) &private->fixed_aspect_hbox);
 
896
 
862
897
    entry = gimp_prop_number_pair_entry_new (config,
863
898
                                             "aspect-numerator",
864
899
                                             "aspect-denominator",
866
901
                                             "default-aspect-denominator",
867
902
                                             "overridden-fixed-aspect",
868
903
                                             FALSE, TRUE,
869
 
                                             ":/",
 
904
                                             ":/" "xX*",
870
905
                                             TRUE,
871
906
                                             0.001, GIMP_MAX_IMAGE_SIZE);
872
907
    gtk_box_pack_start (GTK_BOX (private->fixed_aspect_hbox), entry,
891
926
                        private->aspect_button_box, FALSE, FALSE, 0);
892
927
    gtk_widget_show (private->aspect_button_box);
893
928
 
 
929
    g_object_add_weak_pointer (G_OBJECT (private->aspect_button_box),
 
930
                               (gpointer) &private->aspect_button_box);
 
931
 
894
932
    /* hide "square" */
895
933
    children =
896
934
      gtk_container_get_children (GTK_CONTAINER (private->aspect_button_box));
907
945
    gtk_size_group_add_widget (size_group, private->fixed_width_entry);
908
946
    /* don't show */
909
947
 
 
948
    g_object_add_weak_pointer (G_OBJECT (private->fixed_width_entry),
 
949
                               (gpointer) &private->fixed_width_entry);
 
950
 
910
951
    /* Fixed height entry */
911
952
    private->fixed_height_entry =
912
953
      gimp_prop_size_entry_new (config,
917
958
    gtk_size_group_add_widget (size_group, private->fixed_height_entry);
918
959
    /* don't show */
919
960
 
 
961
    g_object_add_weak_pointer (G_OBJECT (private->fixed_height_entry),
 
962
                               (gpointer) &private->fixed_height_entry);
 
963
 
920
964
    /* Fixed size entry */
921
 
    private->fixed_size_hbox = gtk_hbox_new (FALSE, 2);
 
965
    private->fixed_size_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
922
966
    gtk_box_pack_start (GTK_BOX (vbox2), private->fixed_size_hbox,
923
967
                        FALSE, FALSE, 0);
924
968
    gtk_size_group_add_widget (size_group, private->fixed_size_hbox);
925
969
    /* don't show */
926
970
 
 
971
    g_object_add_weak_pointer (G_OBJECT (private->fixed_size_hbox),
 
972
                               (gpointer) &private->fixed_size_hbox);
 
973
 
927
974
    entry = gimp_prop_number_pair_entry_new (config,
928
975
                                             "desired-fixed-size-width",
929
976
                                             "desired-fixed-size-height",
931
978
                                             "default-fixed-size-height",
932
979
                                             "overridden-fixed-size",
933
980
                                             TRUE, FALSE,
934
 
                                             "xX*",
 
981
                                             "xX*" ":/",
935
982
                                             FALSE,
936
983
                                             1, GIMP_MAX_IMAGE_SIZE);
937
984
    gtk_box_pack_start (GTK_BOX (private->fixed_size_hbox), entry,
983
1030
  gtk_widget_show (button);
984
1031
 
985
1032
  /*  Guide  */
986
 
  combo = gimp_prop_enum_combo_box_new (config, "guide", 0, 0);
 
1033
  combo = gimp_prop_enum_combo_box_new (config, "guide",
 
1034
                                        GIMP_GUIDES_NONE,
 
1035
                                        GIMP_GUIDES_DIAGONALS);
987
1036
  gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
988
1037
  gtk_widget_show (combo);
989
1038
 
994
1043
  gtk_widget_set_sensitive (private->auto_shrink_button, FALSE);
995
1044
  gtk_widget_show (private->auto_shrink_button);
996
1045
 
 
1046
  g_object_add_weak_pointer (G_OBJECT (private->auto_shrink_button),
 
1047
                             (gpointer) &private->auto_shrink_button);
 
1048
 
997
1049
  button = gimp_prop_check_button_new (config, "shrink-merged",
998
1050
                                       _("Shrink merged"));
999
1051
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1031
1083
                                               GtkWidget            *entry,
1032
1084
                                               GtkListStore         *history)
1033
1085
{
1034
 
  GimpRectangleOptionsPrivate *private;
1035
 
  GtkEntryCompletion          *completion;
1036
 
 
1037
 
  private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (rectangle_options);
 
1086
  GtkEntryCompletion *completion;
1038
1087
 
1039
1088
  completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION,
1040
1089
                             "model", history,