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

« back to all changes in this revision

Viewing changes to app/widgets/gimpactiongroup.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
 * gimpactiongroup.c
50
50
};
51
51
 
52
52
 
53
 
static void   gimp_action_group_init           (GimpActionGroup       *group);
54
 
static void   gimp_action_group_class_init     (GimpActionGroupClass  *klass);
55
 
 
56
53
static GObject * gimp_action_group_constructor (GType                  type,
57
54
                                                guint                  n_params,
58
55
                                                GObjectConstructParam *params);
68
65
                                                GParamSpec            *pspec);
69
66
 
70
67
 
71
 
static GtkActionGroupClass *parent_class = NULL;
72
 
 
73
 
 
74
 
GType
75
 
gimp_action_group_get_type (void)
76
 
{
77
 
  static GType type = 0;
78
 
 
79
 
  if (!type)
80
 
    {
81
 
      static const GTypeInfo type_info =
82
 
      {
83
 
        sizeof (GimpActionGroupClass),
84
 
        NULL,           /* base_init */
85
 
        NULL,           /* base_finalize */
86
 
        (GClassInitFunc) gimp_action_group_class_init,
87
 
        NULL,           /* class_finalize */
88
 
        NULL,           /* class_data */
89
 
        sizeof (GimpActionGroup),
90
 
        0, /* n_preallocs */
91
 
        (GInstanceInitFunc) gimp_action_group_init,
92
 
      };
93
 
 
94
 
      type = g_type_register_static (GTK_TYPE_ACTION_GROUP,
95
 
                                     "GimpActionGroup",
96
 
                                     &type_info, 0);
97
 
    }
98
 
 
99
 
  return type;
100
 
}
 
68
G_DEFINE_TYPE (GimpActionGroup, gimp_action_group, GTK_TYPE_ACTION_GROUP)
 
69
 
 
70
#define parent_class gimp_action_group_parent_class
 
71
 
101
72
 
102
73
static void
103
74
gimp_action_group_class_init (GimpActionGroupClass *klass)
104
75
{
105
76
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
106
77
 
107
 
  parent_class = g_type_class_peek_parent (klass);
108
 
 
109
78
  object_class->constructor  = gimp_action_group_constructor;
110
79
  object_class->dispose      = gimp_action_group_dispose;
111
80
  object_class->finalize     = gimp_action_group_finalize;
116
85
                                   g_param_spec_object ("gimp",
117
86
                                                        NULL, NULL,
118
87
                                                        GIMP_TYPE_GIMP,
119
 
                                                        G_PARAM_READWRITE |
 
88
                                                        GIMP_PARAM_READWRITE |
120
89
                                                        G_PARAM_CONSTRUCT_ONLY));
121
90
 
122
91
  g_object_class_install_property (object_class, PROP_LABEL,
123
92
                                   g_param_spec_string ("label",
124
93
                                                        NULL, NULL,
125
94
                                                        NULL,
126
 
                                                        G_PARAM_READWRITE |
 
95
                                                        GIMP_PARAM_READWRITE |
127
96
                                                        G_PARAM_CONSTRUCT_ONLY));
128
97
 
129
98
  g_object_class_install_property (object_class, PROP_STOCK_ID,
130
99
                                   g_param_spec_string ("stock-id",
131
100
                                                        NULL, NULL,
132
101
                                                        NULL,
133
 
                                                        G_PARAM_READWRITE |
 
102
                                                        GIMP_PARAM_READWRITE |
134
103
                                                        G_PARAM_CONSTRUCT_ONLY));
135
104
 
136
105
  g_object_class_install_property (object_class, PROP_MNEMONICS,
137
106
                                   g_param_spec_boolean ("mnemonics",
138
107
                                                         NULL, NULL,
139
108
                                                         TRUE,
140
 
                                                         G_PARAM_READWRITE |
 
109
                                                         GIMP_PARAM_READWRITE |
141
110
                                                         G_PARAM_CONSTRUCT_ONLY));
142
111
 
143
112
  klass->groups = g_hash_table_new_full (g_str_hash, g_str_equal,
364
333
}
365
334
 
366
335
void
367
 
gimp_action_group_add_actions (GimpActionGroup *group,
368
 
                               GimpActionEntry *entries,
369
 
                               guint            n_entries)
 
336
gimp_action_group_add_actions (GimpActionGroup       *group,
 
337
                               const GimpActionEntry *entries,
 
338
                               guint                  n_entries)
370
339
{
371
340
  gint i;
372
341
 
378
347
      gchar       *label;
379
348
      const gchar *tooltip;
380
349
 
381
 
      label   = gettext (entries[i].label);
 
350
      label   = (gchar *) g_strip_context (entries[i].label,
 
351
                                           gettext (entries[i].label));
382
352
      tooltip = gettext (entries[i].tooltip);
383
353
 
384
354
      if (! group->mnemonics)
409
379
}
410
380
 
411
381
void
412
 
gimp_action_group_add_toggle_actions (GimpActionGroup       *group,
413
 
                                      GimpToggleActionEntry *entries,
414
 
                                      guint                  n_entries)
 
382
gimp_action_group_add_toggle_actions (GimpActionGroup             *group,
 
383
                                      const GimpToggleActionEntry *entries,
 
384
                                      guint                        n_entries)
415
385
{
416
386
  gint i;
417
387
 
423
393
      gchar           *label;
424
394
      const gchar     *tooltip;
425
395
 
426
 
      label   = gettext (entries[i].label);
 
396
      label   = (gchar *) g_strip_context (entries[i].label,
 
397
                                           gettext (entries[i].label));
427
398
      tooltip = gettext (entries[i].tooltip);
428
399
 
429
400
      if (! group->mnemonics)
430
401
        label = gimp_strip_uline (label);
431
402
 
432
403
      action = gtk_toggle_action_new (entries[i].name, label, tooltip,
433
 
                                      entries[i].stock_id);
 
404
                                      entries[i].stock_id);
434
405
 
435
406
      if (! group->mnemonics)
436
407
        g_free (label);
455
426
    }
456
427
}
457
428
 
458
 
void
459
 
gimp_action_group_add_radio_actions (GimpActionGroup      *group,
460
 
                                     GimpRadioActionEntry *entries,
461
 
                                     guint                 n_entries,
462
 
                                     gint                  value,
463
 
                                     GCallback             callback)
 
429
GSList *
 
430
gimp_action_group_add_radio_actions (GimpActionGroup            *group,
 
431
                                     const GimpRadioActionEntry *entries,
 
432
                                     guint                       n_entries,
 
433
                                     GSList                     *radio_group,
 
434
                                     gint                        value,
 
435
                                     GCallback                   callback)
464
436
{
465
437
  GtkRadioAction *first_action = NULL;
466
 
  GSList         *radio_group  = NULL;
467
438
  gint            i;
468
439
 
469
 
  g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
 
440
  g_return_val_if_fail (GIMP_IS_ACTION_GROUP (group), NULL);
470
441
 
471
442
  for (i = 0; i < n_entries; i++)
472
443
    {
474
445
      gchar          *label;
475
446
      const gchar    *tooltip;
476
447
 
477
 
      label   = gettext (entries[i].label);
 
448
      label   = (gchar *) g_strip_context (entries[i].label,
 
449
                                           gettext (entries[i].label));
478
450
      tooltip = gettext (entries[i].tooltip);
479
451
 
480
452
      if (! group->mnemonics)
481
453
        label = gimp_strip_uline (label);
482
454
 
483
455
      action = gtk_radio_action_new (entries[i].name, label, tooltip,
484
 
                                     entries[i].stock_id,
485
 
                                     entries[i].value);
 
456
                                     entries[i].stock_id,
 
457
                                     entries[i].value);
486
458
 
487
459
      if (! group->mnemonics)
488
460
        g_free (label);
489
461
 
490
462
      if (i == 0)
491
 
        first_action = action;
 
463
        first_action = action;
492
464
 
493
465
      gtk_radio_action_set_group (action, radio_group);
494
466
      radio_group = gtk_radio_action_get_group (action);
495
467
 
496
468
      if (value == entries[i].value)
497
 
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 
469
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
498
470
 
499
471
      gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
500
472
                                              GTK_ACTION (action),
512
484
    g_signal_connect (first_action, "changed",
513
485
                      callback,
514
486
                      group->user_data);
 
487
 
 
488
  return radio_group;
515
489
}
516
490
 
517
491
void
518
 
gimp_action_group_add_enum_actions (GimpActionGroup     *group,
519
 
                                    GimpEnumActionEntry *entries,
520
 
                                    guint                n_entries,
521
 
                                    GCallback            callback)
 
492
gimp_action_group_add_enum_actions (GimpActionGroup           *group,
 
493
                                    const GimpEnumActionEntry *entries,
 
494
                                    guint                      n_entries,
 
495
                                    GCallback                  callback)
522
496
{
523
497
  gint i;
524
498
 
530
504
      gchar          *label;
531
505
      const gchar    *tooltip;
532
506
 
533
 
      label   = gettext (entries[i].label);
 
507
      label   = (gchar *) g_strip_context (entries[i].label,
 
508
                                           gettext (entries[i].label));
534
509
      tooltip = gettext (entries[i].tooltip);
535
510
 
536
511
      if (! group->mnemonics)
537
512
        label = gimp_strip_uline (label);
538
513
 
539
514
      action = gimp_enum_action_new (entries[i].name, label, tooltip,
540
 
                                     entries[i].stock_id,
541
 
                                     entries[i].value,
 
515
                                     entries[i].stock_id,
 
516
                                     entries[i].value,
542
517
                                     entries[i].value_variable);
543
518
 
544
519
      if (! group->mnemonics)
563
538
}
564
539
 
565
540
void
566
 
gimp_action_group_add_string_actions (GimpActionGroup       *group,
567
 
                                      GimpStringActionEntry *entries,
568
 
                                      guint                  n_entries,
569
 
                                      GCallback              callback)
 
541
gimp_action_group_add_string_actions (GimpActionGroup             *group,
 
542
                                      const GimpStringActionEntry *entries,
 
543
                                      guint                        n_entries,
 
544
                                      GCallback                    callback)
570
545
{
571
546
  gint i;
572
547
 
578
553
      gchar            *label;
579
554
      const gchar      *tooltip;
580
555
 
581
 
      label   = gettext (entries[i].label);
 
556
      label   = (gchar *) g_strip_context (entries[i].label,
 
557
                                           gettext (entries[i].label));
582
558
      tooltip = gettext (entries[i].tooltip);
583
559
 
584
560
      if (! group->mnemonics)
610
586
}
611
587
 
612
588
void
613
 
gimp_action_group_add_plug_in_actions (GimpActionGroup       *group,
614
 
                                       GimpPlugInActionEntry *entries,
615
 
                                       guint                  n_entries,
616
 
                                       GCallback              callback)
 
589
gimp_action_group_add_plug_in_actions (GimpActionGroup             *group,
 
590
                                       const GimpPlugInActionEntry *entries,
 
591
                                       guint                        n_entries,
 
592
                                       GCallback                    callback)
617
593
{
618
594
  gint i;
619
595
 
633
609
                                        label,
634
610
                                        entries[i].tooltip,
635
611
                                        entries[i].stock_id,
636
 
                                        entries[i].proc_def);
 
612
                                        entries[i].procedure);
637
613
 
638
614
      if (! group->mnemonics)
639
615
        g_free (label);
676
652
      return;
677
653
    }
678
654
 
679
 
  g_object_set (action, "visible", visible ? TRUE : FALSE, NULL);
 
655
  gtk_action_set_visible (action, visible);
680
656
}
681
657
 
682
658
void
699
675
      return;
700
676
    }
701
677
 
702
 
  g_object_set (action, "sensitive", sensitive ? TRUE : FALSE, NULL);
 
678
  gtk_action_set_sensitive (action, sensitive);
703
679
}
704
680
 
705
681
void
850
826
}
851
827
 
852
828
void
853
 
gimp_action_group_set_action_important (GimpActionGroup *group,
854
 
                                        const gchar     *action_name,
855
 
                                        gboolean         is_important)
 
829
gimp_action_group_set_action_hide_empty (GimpActionGroup *group,
 
830
                                         const gchar     *action_name,
 
831
                                         gboolean         hide_empty)
856
832
{
857
833
  GtkAction *action;
858
834
 
863
839
 
864
840
  if (! action)
865
841
    {
866
 
      g_warning ("%s: Unable to set \"is-important\" of action "
 
842
      g_warning ("%s: Unable to set \"hide-if-empty\" of action "
867
843
                 "which doesn't exist: %s",
868
844
                 G_STRFUNC, action_name);
869
845
      return;
870
846
    }
871
847
 
872
 
  g_object_set (action, "is-important", is_important ? TRUE : FALSE, NULL);
 
848
  g_object_set (action, "hide-if-empty", hide_empty ? TRUE : FALSE, NULL);
873
849
}