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

« back to all changes in this revision

Viewing changes to app/tools/gimptextoptions.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 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
21
21
#include <gtk/gtk.h>
22
22
 
23
23
#include "libgimpbase/gimpbase.h"
24
 
#include "libgimpcolor/gimpcolor.h"
 
24
#include "libgimpconfig/gimpconfig.h"
25
25
#include "libgimpwidgets/gimpwidgets.h"
26
26
 
27
27
#include "tools-types.h"
28
28
 
29
 
#include "config/gimpconfig.h"
30
 
#include "config/gimpconfig-params.h"
31
29
#include "config/gimpconfig-utils.h"
32
30
 
33
 
#include "core/gimp.h"
34
 
#include "core/gimptoolinfo.h"
 
31
#include "core/gimpviewable.h"
35
32
 
36
33
#include "text/gimptext.h"
37
34
 
62
59
  PROP_BASE_DIR,
63
60
  PROP_JUSTIFICATION,
64
61
  PROP_INDENTATION,
65
 
  PROP_LINE_SPACING
 
62
  PROP_LINE_SPACING,
 
63
  PROP_LETTER_SPACING,
 
64
 
 
65
  PROP_FONT_VIEW_TYPE,
 
66
  PROP_FONT_VIEW_SIZE
66
67
};
67
68
 
68
69
 
69
 
static void  gimp_text_options_class_init (GimpTextOptionsClass *options_class);
70
 
static void  gimp_text_options_init       (GimpTextOptions      *options);
71
 
 
72
70
static void  gimp_text_options_set_property       (GObject      *object,
73
71
                                                   guint         property_id,
74
72
                                                   const GValue *value,
92
90
                                                   GimpContext  *context);
93
91
 
94
92
 
95
 
static GimpToolOptionsClass *parent_class = NULL;
96
 
 
97
 
 
98
 
GType
99
 
gimp_text_options_get_type (void)
100
 
{
101
 
  static GType type = 0;
102
 
 
103
 
  if (! type)
104
 
    {
105
 
      static const GTypeInfo info =
106
 
      {
107
 
        sizeof (GimpTextOptionsClass),
108
 
        (GBaseInitFunc) NULL,
109
 
        (GBaseFinalizeFunc) NULL,
110
 
        (GClassInitFunc) gimp_text_options_class_init,
111
 
        NULL,           /* class_finalize */
112
 
        NULL,           /* class_data     */
113
 
        sizeof (GimpTextOptions),
114
 
        0,              /* n_preallocs    */
115
 
        (GInstanceInitFunc) gimp_text_options_init
116
 
      };
117
 
 
118
 
      type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
119
 
                                     "GimpTextOptions",
120
 
                                     &info, 0);
121
 
    }
122
 
 
123
 
  return type;
124
 
}
 
93
G_DEFINE_TYPE (GimpTextOptions, gimp_text_options, GIMP_TYPE_TOOL_OPTIONS)
 
94
 
125
95
 
126
96
static void
127
97
gimp_text_options_class_init (GimpTextOptionsClass *klass)
128
98
{
129
99
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
130
100
 
131
 
  parent_class = g_type_class_peek_parent (klass);
132
 
 
133
101
  object_class->set_property = gimp_text_options_set_property;
134
102
  object_class->get_property = gimp_text_options_get_property;
135
103
 
136
104
  GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_UNIT,
137
105
                                 "font-size-unit", NULL,
138
106
                                 TRUE, FALSE, GIMP_UNIT_PIXEL,
139
 
                                 0);
 
107
                                 GIMP_PARAM_STATIC_STRINGS);
140
108
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FONT_SIZE,
141
109
                                   "font-size", NULL,
142
110
                                   0.0, 8192.0, 18.0,
143
 
                                   0);
 
111
                                   GIMP_PARAM_STATIC_STRINGS);
144
112
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HINTING,
145
113
                                    "hinting",
146
114
                                    N_("Hinting alters the font outline to "
147
115
                                       "produce a crisp bitmap at small "
148
116
                                       "sizes"),
149
117
                                    TRUE,
150
 
                                    0);
 
118
                                    GIMP_PARAM_STATIC_STRINGS);
151
119
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTOHINT,
152
120
                                    "autohint",
153
121
                                    N_("If available, hints from the font are "
154
122
                                       "used but you may prefer to always use "
155
123
                                       "the automatic hinter"),
156
124
                                    FALSE,
157
 
                                    0);
 
125
                                    GIMP_PARAM_STATIC_STRINGS);
158
126
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
159
127
                                    "antialias", NULL,
160
128
                                    TRUE,
161
 
                                    0);
 
129
                                    GIMP_PARAM_STATIC_STRINGS);
162
130
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_LANGUAGE,
163
131
                                   "language", NULL,
164
132
                                   (const gchar *) gtk_get_default_language (),
165
 
                                   0);
 
133
                                   GIMP_PARAM_STATIC_STRINGS);
166
134
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BASE_DIR,
167
135
                                "base-direction", NULL,
168
136
                                 GIMP_TYPE_TEXT_DIRECTION,
169
137
                                 GIMP_TEXT_DIRECTION_LTR,
170
 
                                 0);
 
138
                                 GIMP_PARAM_STATIC_STRINGS);
171
139
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_JUSTIFICATION,
172
140
                                "justify", NULL,
173
141
                                 GIMP_TYPE_TEXT_JUSTIFICATION,
174
142
                                 GIMP_TEXT_JUSTIFY_LEFT,
175
 
                                 0);
 
143
                                 GIMP_PARAM_STATIC_STRINGS);
176
144
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_INDENTATION,
177
145
                                   "indent",
178
146
                                   N_("Indentation of the first line"),
179
147
                                   -8192.0, 8192.0, 0.0,
180
 
                                   GIMP_PARAM_DEFAULTS);
 
148
                                   GIMP_PARAM_STATIC_STRINGS |
 
149
                                   GIMP_CONFIG_PARAM_DEFAULTS);
181
150
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LINE_SPACING,
182
151
                                   "line-spacing",
183
 
                                   N_("Modify line spacing"),
184
 
                                   -8192.0, 8192.0, 0.0,
185
 
                                   GIMP_PARAM_DEFAULTS);
 
152
                                   N_("Adjust line spacing"),
 
153
                                   -8192.0, 8192.0, 0.0,
 
154
                                   GIMP_PARAM_STATIC_STRINGS |
 
155
                                   GIMP_CONFIG_PARAM_DEFAULTS);
 
156
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LETTER_SPACING,
 
157
                                   "letter-spacing",
 
158
                                   N_("Adjust letter spacing"),
 
159
                                   -8192.0, 8192.0, 0.0,
 
160
                                   GIMP_PARAM_STATIC_STRINGS |
 
161
                                   GIMP_CONFIG_PARAM_DEFAULTS);
 
162
 
 
163
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FONT_VIEW_TYPE,
 
164
                                 "font-view-type", NULL,
 
165
                                 GIMP_TYPE_VIEW_TYPE,
 
166
                                 GIMP_VIEW_TYPE_LIST,
 
167
                                 GIMP_PARAM_STATIC_STRINGS);
 
168
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_FONT_VIEW_SIZE,
 
169
                                "font-view-size", NULL,
 
170
                                GIMP_VIEW_SIZE_TINY,
 
171
                                GIMP_VIEWABLE_MAX_BUTTON_SIZE,
 
172
                                GIMP_VIEW_SIZE_SMALL,
 
173
                                GIMP_PARAM_STATIC_STRINGS);
186
174
}
187
175
 
188
176
static void
189
177
gimp_text_options_init (GimpTextOptions *options)
190
178
{
191
 
  options->size_entry = NULL;
 
179
  options->size_entry           = NULL;
 
180
  options->to_vectors_button    = NULL;
 
181
  options->along_vectors_button = NULL;
192
182
}
193
183
 
194
184
static void
231
221
    case PROP_LINE_SPACING:
232
222
      g_value_set_double (value, options->line_spacing);
233
223
      break;
 
224
    case PROP_LETTER_SPACING:
 
225
      g_value_set_double (value, options->letter_spacing);
 
226
      break;
 
227
 
 
228
    case PROP_FONT_VIEW_TYPE:
 
229
      g_value_set_enum (value, options->font_view_type);
 
230
      break;
 
231
    case PROP_FONT_VIEW_SIZE:
 
232
      g_value_set_int (value, options->font_view_size);
 
233
      break;
 
234
 
234
235
    default:
235
236
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
236
237
      break;
278
279
    case PROP_LINE_SPACING:
279
280
      options->line_spacing = g_value_get_double (value);
280
281
      break;
 
282
    case PROP_LETTER_SPACING:
 
283
      options->letter_spacing = g_value_get_double (value);
 
284
      break;
 
285
 
 
286
    case PROP_FONT_VIEW_TYPE:
 
287
      options->font_view_type = g_value_get_enum (value);
 
288
      break;
 
289
    case PROP_FONT_VIEW_SIZE:
 
290
      options->font_view_size = g_value_get_int (value);
 
291
      break;
 
292
 
281
293
    default:
282
294
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
283
295
      break;
365
377
 
366
378
  gimp_context_get_foreground (context, &color);
367
379
 
368
 
  gimp_config_sync (GIMP_CONFIG (options), GIMP_CONFIG (text), 0);
 
380
  gimp_config_sync (G_OBJECT (options), G_OBJECT (text), 0);
369
381
 
370
382
  g_object_set (text,
371
383
                "color", &color,
392
404
GtkWidget *
393
405
gimp_text_options_gui (GimpToolOptions *tool_options)
394
406
{
395
 
  GObject           *config  = G_OBJECT (tool_options);
396
 
  GimpTextOptions   *options = GIMP_TEXT_OPTIONS (tool_options);
397
 
  GtkWidget         *vbox;
398
 
  GtkWidget         *table;
399
 
  GtkWidget         *hbox;
400
 
  GtkWidget         *button;
401
 
  GtkWidget         *auto_button;
402
 
  GtkWidget         *entry;
403
 
  GtkWidget         *box;
404
 
  GtkWidget         *spinbutton;
405
 
  gint               row = 0;
406
 
 
407
 
  vbox = gimp_tool_options_gui (tool_options);
408
 
 
409
 
  g_object_set_data (G_OBJECT (tool_options), "tool-options-vbox", vbox);
410
 
 
411
 
  table = gtk_table_new (9, 3, FALSE);
 
407
  GObject         *config  = G_OBJECT (tool_options);
 
408
  GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options);
 
409
  GtkWidget       *vbox    = gimp_tool_options_gui (tool_options);
 
410
  GtkWidget       *table;
 
411
  GtkWidget       *hbox;
 
412
  GtkWidget       *button;
 
413
  GtkWidget       *auto_button;
 
414
  GtkWidget       *entry;
 
415
  GtkWidget       *box;
 
416
  GtkWidget       *spinbutton;
 
417
  gint             row = 0;
 
418
 
 
419
  table = gtk_table_new (10, 3, FALSE);
412
420
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
413
421
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
414
422
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
415
423
  gtk_widget_show (table);
416
424
 
417
 
  hbox = gimp_font_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
 
425
  hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
 
426
                                 "font-view-type", "font-view-size");
418
427
  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
419
428
                             _("Font:"), 0.0, 0.5,
420
429
                             hbox, 2, FALSE);
426
435
                             _("Size:"), 0.0, 0.5,
427
436
                             entry, 2, FALSE);
428
437
 
429
 
  options->size_entry = GIMP_SIZE_ENTRY (entry);
 
438
  options->size_entry = entry;
430
439
 
431
440
  button = gimp_prop_check_button_new (config, "hinting", _("Hinting"));
432
441
  gtk_table_attach (GTK_TABLE (table), button, 0, 3, row, row + 1,
465
474
 
466
475
  spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1);
467
476
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
468
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
469
 
                             _("Indent:"), 0.0, 0.5,
470
 
                             spinbutton, 1, FALSE);
 
477
  gimp_table_attach_stock (GTK_TABLE (table), row++,
 
478
                           GTK_STOCK_INDENT, spinbutton, 1, TRUE);
471
479
 
472
480
  spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1);
473
481
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
474
482
  gimp_table_attach_stock (GTK_TABLE (table), row++,
475
 
                           _("Line\nspacing:"), 0.0,
476
 
                           spinbutton, 1, GIMP_STOCK_LINE_SPACING);
477
 
 
478
 
  button = gtk_button_new_with_label (_("Create path from text"));
479
 
  gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
480
 
  gtk_widget_set_sensitive (button, FALSE);
481
 
  gtk_widget_show (button);
482
 
 
483
 
  g_object_set_data (G_OBJECT (tool_options),
484
 
                     "gimp-text-to-vectors", button);
 
483
                           GIMP_STOCK_LINE_SPACING, spinbutton, 1, TRUE);
 
484
 
 
485
  spinbutton = gimp_prop_spin_button_new (config,
 
486
                                          "letter-spacing", 1.0, 10.0, 1);
 
487
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
 
488
  gimp_table_attach_stock (GTK_TABLE (table), row++,
 
489
                           GIMP_STOCK_LETTER_SPACING, spinbutton, 1, TRUE);
 
490
 
 
491
  button = gtk_button_new_with_label (_("Create Path from Text"));
 
492
  gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
493
  gtk_widget_set_sensitive (button, FALSE);
 
494
  gtk_widget_show (button);
 
495
 
 
496
  options->to_vectors_button = button;
 
497
 
 
498
  button = gtk_button_new_with_label (_("Text along Path"));
 
499
  gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
500
  gtk_widget_set_sensitive (button, FALSE);
 
501
  gtk_widget_show (button);
 
502
 
 
503
  options->along_vectors_button = button;
485
504
 
486
505
  return vbox;
487
506
}
488
507
 
489
508
static void
490
 
gimp_text_options_dir_changed (GimpTextEditor  *editor,
491
 
                               GimpTextOptions *options)
 
509
gimp_text_options_editor_dir_changed (GimpTextEditor  *editor,
 
510
                                      GimpTextOptions *options)
492
511
{
493
512
  g_object_set (options,
494
513
                "base-direction", editor->base_dir,
496
515
}
497
516
 
498
517
static void
499
 
gimp_text_options_notify_dir (GimpTextOptions *options,
500
 
                              GParamSpec      *pspec,
501
 
                              GimpTextEditor  *editor)
 
518
gimp_text_options_editor_notify_dir (GimpTextOptions *options,
 
519
                                     GParamSpec      *pspec,
 
520
                                     GimpTextEditor  *editor)
502
521
{
503
522
  GimpTextDirection  dir;
504
523
 
509
528
  gimp_text_editor_set_direction (editor, dir);
510
529
}
511
530
 
 
531
static void
 
532
gimp_text_options_editor_notify_font (GimpTextOptions *options,
 
533
                                      GParamSpec      *pspec,
 
534
                                      GimpTextEditor  *editor)
 
535
{
 
536
  const gchar *font_name;
 
537
 
 
538
  font_name = gimp_context_get_font_name (GIMP_CONTEXT (options));
 
539
 
 
540
  gimp_text_editor_set_font_name (editor, font_name);
 
541
}
 
542
 
512
543
GtkWidget *
513
 
gimp_text_options_editor_new (GimpTextOptions *options,
 
544
gimp_text_options_editor_new (GtkWindow       *parent,
 
545
                              GimpTextOptions *options,
514
546
                              GimpMenuFactory *menu_factory,
515
547
                              const gchar     *title)
516
548
{
517
 
  GtkWidget *editor;
 
549
  GtkWidget   *editor;
 
550
  const gchar *font_name;
518
551
 
519
552
  g_return_val_if_fail (GIMP_IS_TEXT_OPTIONS (options), NULL);
520
553
  g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
521
554
  g_return_val_if_fail (title != NULL, NULL);
522
555
 
523
 
  editor = gimp_text_editor_new (title, menu_factory);
 
556
  editor = gimp_text_editor_new (title, parent, menu_factory);
 
557
 
 
558
  font_name = gimp_context_get_font_name (GIMP_CONTEXT (options));
524
559
 
525
560
  gimp_text_editor_set_direction (GIMP_TEXT_EDITOR (editor),
526
561
                                  options->base_dir);
 
562
  gimp_text_editor_set_font_name (GIMP_TEXT_EDITOR (editor),
 
563
                                  font_name);
527
564
 
528
 
  g_signal_connect_object (editor, "dir_changed",
529
 
                           G_CALLBACK (gimp_text_options_dir_changed),
 
565
  g_signal_connect_object (editor, "dir-changed",
 
566
                           G_CALLBACK (gimp_text_options_editor_dir_changed),
530
567
                           options, 0);
531
568
  g_signal_connect_object (options, "notify::base-direction",
532
 
                           G_CALLBACK (gimp_text_options_notify_dir),
 
569
                           G_CALLBACK (gimp_text_options_editor_notify_dir),
 
570
                           editor, 0);
 
571
  g_signal_connect_object (options, "notify::font",
 
572
                           G_CALLBACK (gimp_text_options_editor_notify_font),
533
573
                           editor, 0);
534
574
 
535
575
  return editor;