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

« back to all changes in this revision

Viewing changes to app/widgets/gimpwidgets-utils.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
 * gimpwidgets-utils.c
23
23
 
24
24
#include <errno.h>
25
25
#include <fcntl.h>
26
 
#include <stdio.h>
27
26
#include <string.h>
28
 
#include <sys/stat.h>
29
27
#include <sys/types.h>
 
28
 
30
29
#ifdef HAVE_UNISTD_H
31
30
#include <unistd.h>
32
31
#endif
33
32
 
 
33
#include <glib/gstdio.h>
 
34
 
34
35
#include <glib.h>
35
36
 
36
37
#ifdef G_OS_WIN32
39
40
 
40
41
#include <gtk/gtk.h>
41
42
 
 
43
#ifdef GDK_WINDOWING_WIN32
 
44
#include <gdk/gdkwin32.h>
 
45
#endif
 
46
 
 
47
#ifdef GDK_WINDOWING_X11
 
48
#include <gdk/gdkx.h>
 
49
#endif
 
50
 
42
51
#include "libgimpbase/gimpbase.h"
 
52
#include "libgimpmath/gimpmath.h"
43
53
#include "libgimpcolor/gimpcolor.h"
44
54
#include "libgimpwidgets/gimpwidgets.h"
45
55
 
69
79
 **/
70
80
void
71
81
gimp_menu_position (GtkMenu *menu,
72
 
                    gint    *x,
73
 
                    gint    *y)
 
82
                    gint    *x,
 
83
                    gint    *y)
74
84
{
75
85
  GtkWidget      *widget;
76
86
  GdkScreen      *screen;
164
174
 
165
175
  gtk_menu_set_screen (menu, screen);
166
176
 
167
 
  *x += button->allocation.x;
 
177
  if (GTK_WIDGET_NO_WINDOW (button))
 
178
    *x += button->allocation.x;
168
179
 
169
180
  switch (position)
170
181
    {
185
196
      break;
186
197
    }
187
198
 
188
 
  *y += button->allocation.y + button->allocation.height / 2;
 
199
  if (GTK_WIDGET_NO_WINDOW (button))
 
200
    *y += button->allocation.y;
 
201
 
 
202
  *y += button->allocation.height / 2;
189
203
 
190
204
  if (*y + menu_requisition.height > rect.y + rect.height)
191
205
    *y -= menu_requisition.height;
 
206
 
192
207
  if (*y < rect.y)
193
208
    *y = rect.y;
194
209
}
196
211
void
197
212
gimp_table_attach_stock (GtkTable    *table,
198
213
                         gint         row,
199
 
                         const gchar *label_text,
200
 
                         gdouble      yalign,
 
214
                         const gchar *stock_id,
201
215
                         GtkWidget   *widget,
202
 
                         gint         colspan,
203
 
                         const gchar *stock_id)
 
216
                         gint         colspan,
 
217
                         gboolean     left_align)
204
218
{
205
219
  GtkWidget *image;
206
 
  GtkWidget *label;
207
220
 
208
221
  g_return_if_fail (GTK_IS_TABLE (table));
209
 
  g_return_if_fail (label_text != NULL);
210
 
 
211
 
  label = gtk_label_new_with_mnemonic (label_text);
212
 
 
213
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, yalign);
214
 
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
215
 
  gtk_table_attach (table, label, 0, 1, row, row + 1,
216
 
                    GTK_FILL, GTK_FILL, 0, 0);
217
 
  gtk_widget_show (label);
218
 
 
219
 
  if (widget)
 
222
  g_return_if_fail (stock_id != NULL);
 
223
  g_return_if_fail (GTK_IS_WIDGET (widget));
 
224
 
 
225
  image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
 
226
  gtk_misc_set_alignment (GTK_MISC (image), 1.0, 0.5);
 
227
  gtk_table_attach (table, image, 0, 1, row, row + 1,
 
228
                    GTK_FILL, GTK_FILL, 0, 0);
 
229
  gtk_widget_show (image);
 
230
 
 
231
  if (left_align)
220
232
    {
221
 
      g_return_if_fail (GTK_IS_WIDGET (widget));
 
233
      GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
222
234
 
223
 
      gtk_table_attach (table, widget, 1, 1 + colspan, row, row + 1,
224
 
                        GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
235
      gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
225
236
      gtk_widget_show (widget);
226
237
 
227
 
      gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
228
 
    }
229
 
 
230
 
  image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
231
 
 
232
 
  if (image)
233
 
    {
234
 
      gtk_misc_set_alignment (GTK_MISC (image), 0.0, 0.5);
235
 
      gtk_table_attach (table, image, 1 + colspan, 2 + colspan, row, row + 1,
236
 
                        GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
237
 
      gtk_widget_show (image);
238
 
    }
 
238
      widget = hbox;
 
239
    }
 
240
 
 
241
  gtk_table_attach (table, widget, 1, 1 + colspan, row, row + 1,
 
242
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
243
  gtk_widget_show (widget);
239
244
}
240
245
 
241
246
void
331
336
  gint          max_width;
332
337
  gint          max_height;
333
338
  GtkIconSize   icon_size = GTK_ICON_SIZE_MENU;
334
 
  GdkScreen    *screen;
335
339
  GtkSettings  *settings;
336
340
 
337
341
  g_return_val_if_fail (GTK_IS_WIDGET (widget), icon_size);
344
348
  if (! icon_set)
345
349
    return GTK_ICON_SIZE_INVALID;
346
350
 
347
 
  screen = gtk_widget_get_screen (widget);
348
 
  settings = gtk_settings_get_for_screen (screen);
 
351
  settings = gtk_widget_get_settings (widget);
349
352
 
350
353
  if (! gtk_icon_size_lookup_for_settings (settings, max_size,
351
354
                                           &max_width, &max_height))
384
387
  return icon_size;
385
388
}
386
389
 
387
 
 
388
 
/*  The format string which is used to display modifier names
389
 
 *  <Shift>, <Ctrl> and <Alt>
390
 
 */
391
 
#define GIMP_MOD_NAME_FORMAT_STRING N_("<%s>")
392
 
 
393
390
const gchar *
394
391
gimp_get_mod_name_shift (void)
395
392
{
400
397
      GtkAccelLabelClass *accel_label_class;
401
398
 
402
399
      accel_label_class = g_type_class_ref (GTK_TYPE_ACCEL_LABEL);
403
 
      mod_name_shift = g_strdup_printf (gettext (GIMP_MOD_NAME_FORMAT_STRING),
404
 
                                        accel_label_class->mod_name_shift);
 
400
      mod_name_shift = g_strdup (accel_label_class->mod_name_shift);
405
401
      g_type_class_unref (accel_label_class);
406
402
    }
407
403
 
418
414
      GtkAccelLabelClass *accel_label_class;
419
415
 
420
416
      accel_label_class = g_type_class_ref (GTK_TYPE_ACCEL_LABEL);
421
 
      mod_name_control = g_strdup_printf (gettext (GIMP_MOD_NAME_FORMAT_STRING),
422
 
                                          accel_label_class->mod_name_control);
 
417
      mod_name_control = g_strdup (accel_label_class->mod_name_control);
423
418
      g_type_class_unref (accel_label_class);
424
419
    }
425
420
 
436
431
      GtkAccelLabelClass *accel_label_class;
437
432
 
438
433
      accel_label_class = g_type_class_ref (GTK_TYPE_ACCEL_LABEL);
439
 
      mod_name_alt = g_strdup_printf (gettext (GIMP_MOD_NAME_FORMAT_STRING),
440
 
                                      accel_label_class->mod_name_alt);
 
434
      mod_name_alt = g_strdup (accel_label_class->mod_name_alt);
441
435
      g_type_class_unref (accel_label_class);
442
436
    }
443
437
 
531
525
      *p = ' ';
532
526
}
533
527
 
 
528
 
 
529
/* pretty much straight copy of _gtk_accel_label_class_get_accelerator_label */
534
530
gchar *
535
531
gimp_get_accel_string (guint           key,
536
532
                       GdkModifierType modifiers)
554
550
      switch (ch)
555
551
        {
556
552
        case ' ':
557
 
          g_string_append (gstring, "Space");
 
553
          /* do not translate the part before the | */
 
554
          g_string_append (gstring, Q_("keyboard label|Space"));
558
555
          break;
559
556
        case '\\':
560
 
          g_string_append (gstring, "Backslash");
 
557
          /* do not translate the part before the | */
 
558
          g_string_append (gstring, Q_("keyboard label|Backslash"));
561
559
          break;
562
560
        default:
563
561
          g_string_append_unichar (gstring, g_unichar_toupper (ch));
581
579
  return g_string_free (gstring, FALSE);
582
580
}
583
581
 
 
582
#define BUF_SIZE 100
 
583
/**
 
584
 * gimp_suggest_modifiers:
 
585
 * @message: initial text for the message
 
586
 * @modifiers: bit mask of modifiers that should be suggested
 
587
 * @shift_format: optional format string for the Shift modifier
 
588
 * @control_format: optional format string for the Ctrl modifier
 
589
 * @alt_format: optional format string for the Alt modifier
 
590
 *
 
591
 * Utility function to build a message suggesting to use some
 
592
 * modifiers for performing different actions (only Shift, Ctrl and
 
593
 * Alt are currently supported).  If some of these modifiers are
 
594
 * already active, they will not be suggested.  The optional format
 
595
 * strings #shift_format, #control_format and #alt_format may be used
 
596
 * to describe what the modifier will do.  They must contain a single
 
597
 * '%%s' which will be replaced by the name of the modifier.  They
 
598
 * can also be %NULL if the modifier name should be left alone.
 
599
 *
 
600
 * Return value: a newly allocated string containing the message.
 
601
 **/
 
602
gchar *
 
603
gimp_suggest_modifiers (const gchar     *message,
 
604
                        GdkModifierType  modifiers,
 
605
                        const gchar     *shift_format,
 
606
                        const gchar     *control_format,
 
607
                        const gchar     *alt_format)
 
608
{
 
609
  gchar     msg_buf[3][BUF_SIZE];
 
610
  gint      num_msgs = 0;
 
611
  gboolean  try      = FALSE;
 
612
 
 
613
  if (modifiers & GDK_SHIFT_MASK)
 
614
    {
 
615
      if (shift_format && *shift_format)
 
616
        {
 
617
          g_snprintf (msg_buf[num_msgs], BUF_SIZE, shift_format,
 
618
                      gimp_get_mod_name_shift ());
 
619
        }
 
620
      else
 
621
        {
 
622
          g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_shift (), BUF_SIZE);
 
623
          try = TRUE;
 
624
        }
 
625
 
 
626
      num_msgs++;
 
627
    }
 
628
 
 
629
  if (modifiers & GDK_CONTROL_MASK)
 
630
    {
 
631
      if (control_format && *control_format)
 
632
        {
 
633
          g_snprintf (msg_buf[num_msgs], BUF_SIZE, control_format,
 
634
                      gimp_get_mod_name_control ());
 
635
        }
 
636
      else
 
637
        {
 
638
          g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_control (), BUF_SIZE);
 
639
          try = TRUE;
 
640
        }
 
641
 
 
642
      num_msgs++;
 
643
    }
 
644
 
 
645
  if (modifiers & GDK_MOD1_MASK)
 
646
    {
 
647
      if (alt_format && *alt_format)
 
648
        {
 
649
          g_snprintf (msg_buf[num_msgs], BUF_SIZE, alt_format,
 
650
                      gimp_get_mod_name_alt ());
 
651
        }
 
652
      else
 
653
        {
 
654
          g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_alt (), BUF_SIZE);
 
655
          try = TRUE;
 
656
        }
 
657
 
 
658
      num_msgs++;
 
659
    }
 
660
 
 
661
  /* This convoluted way to build the message using multiple format strings
 
662
   * tries to make the messages easier to translate to other languages.
 
663
   */
 
664
 
 
665
  switch (num_msgs)
 
666
    {
 
667
    case 1:
 
668
      return g_strdup_printf (try ? _("%s (try %s)") : _("%s (%s)"),
 
669
                              message, msg_buf[0]);
 
670
 
 
671
    case 2:
 
672
      return g_strdup_printf (_("%s (try %s, %s)"),
 
673
                              message, msg_buf[0], msg_buf[1]);
 
674
 
 
675
    case 3:
 
676
      return g_strdup_printf (_("%s (try %s, %s, %s)"),
 
677
                              message, msg_buf[0], msg_buf[1], msg_buf[2]);
 
678
    }
 
679
 
 
680
  return g_strdup (message);
 
681
}
 
682
#undef BUF_SIZE
584
683
 
585
684
/**
586
685
 * gimp_get_screen_resolution:
634
733
      y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
635
734
    {
636
735
      g_warning ("GDK returned bogus values for the screen resolution, "
637
 
                 "using 75 dpi instead.");
 
736
                 "using 96 dpi instead.");
638
737
 
639
 
      x = 75.0;
640
 
      y = 75.0;
 
738
      x = 96.0;
 
739
      y = 96.0;
641
740
    }
642
741
 
643
742
  /*  round the value to full integers to give more pleasant results  */
717
816
    }
718
817
}
719
818
 
 
819
/**
 
820
 * gimp_window_get_native:
 
821
 * @window: a #GtkWindow
 
822
 *
 
823
 * This function is used to pass a window handle to plug-ins so that
 
824
 * they can set their dialog windows transient to the parent window.
 
825
 *
 
826
 * Return value: a native window handle of the window's #GdkWindow or 0
 
827
 *               if the window isn't realized yet
 
828
 */
 
829
GdkNativeWindow
 
830
gimp_window_get_native (GtkWindow *window)
 
831
{
 
832
  g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
 
833
 
 
834
#ifdef GDK_NATIVE_WINDOW_POINTER
 
835
#ifdef __GNUC__
 
836
#warning gimp_window_get_native() unimplementable for the target windowing system
 
837
#endif
 
838
  return (GdkNativeWindow)0;
 
839
#endif
 
840
 
 
841
#ifdef GDK_WINDOWING_WIN32
 
842
  if (window && GTK_WIDGET_REALIZED (window))
 
843
    return (GdkNativeWindow)GDK_WINDOW_HWND (GTK_WIDGET (window)->window);
 
844
#endif
 
845
 
 
846
#ifdef GDK_WINDOWING_X11
 
847
  if (window && GTK_WIDGET_REALIZED (window))
 
848
    return GDK_WINDOW_XID (GTK_WIDGET (window)->window);
 
849
#endif
 
850
 
 
851
  return (GdkNativeWindow)0;
 
852
}
 
853
 
 
854
static void
 
855
gimp_window_transient_realized (GtkWidget *window,
 
856
                                GdkWindow *parent)
 
857
{
 
858
  if (GTK_WIDGET_REALIZED (window))
 
859
    gdk_window_set_transient_for (window->window, parent);
 
860
}
 
861
 
 
862
/* similar to what we have in libgimp/gimpui.c */
720
863
void
721
 
gimp_dialog_set_sensitive (GtkDialog *dialog,
722
 
                           gboolean   sensitive)
 
864
gimp_window_set_transient_for (GtkWindow *window,
 
865
                               guint32    parent_ID)
723
866
{
724
 
  GList *children;
725
 
  GList *list;
726
 
 
727
 
  g_return_if_fail (GTK_IS_DIALOG (dialog));
728
 
 
729
 
  children = gtk_container_get_children (GTK_CONTAINER (dialog->vbox));
730
 
 
731
 
  for (list = children; list; list = g_list_next (list))
732
 
    {
733
 
      /*  skip the last item (the action area) */
734
 
      if (! g_list_next (list))
735
 
        break;
736
 
 
737
 
      gtk_widget_set_sensitive (list->data, sensitive);
738
 
    }
739
 
 
740
 
  g_list_free (children);
741
 
 
742
 
  if (sensitive)
743
 
    gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_CANCEL, sensitive);
744
 
 
745
 
  gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
 
867
  /* Cross-process transient-for is broken in gdk/win32 <= 2.10.6. It
 
868
   * causes hangs, at least when used as by the gimp and script-fu
 
869
   * processes. In some newer GTK+ version it will be fixed to be a
 
870
   * no-op. If it eventually is fixed to actually work, change this to
 
871
   * a run-time check of GTK+ version. Remember to change also the
 
872
   * function with the same name in libgimp/gimpui.c
 
873
   */
 
874
#ifndef GDK_WINDOWING_WIN32
 
875
  GdkWindow *parent;
 
876
 
 
877
  parent = gdk_window_foreign_new_for_display (gdk_display_get_default (),
 
878
                                               parent_ID);
 
879
 
 
880
  if (! parent)
 
881
    return;
 
882
 
 
883
  if (GTK_WIDGET_REALIZED (window))
 
884
    gdk_window_set_transient_for (GTK_WIDGET (window)->window, parent);
 
885
 
 
886
  g_signal_connect_object (window, "realize",
 
887
                           G_CALLBACK (gimp_window_transient_realized),
 
888
                           parent, 0);
 
889
 
 
890
  g_object_unref (parent);
 
891
#endif
746
892
}
747
893
 
748
894
gboolean
759
905
  g_return_val_if_fail (filename != NULL, FALSE);
760
906
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
761
907
 
762
 
  file = fopen (filename, "r");
 
908
  file = g_fopen (filename, "r");
763
909
 
764
910
  if (! file)
765
911
    {
794
940
 
795
941
  if (remaining)
796
942
    g_message (_("Invalid UTF-8 data in file '%s'."),
797
 
               gimp_filename_to_utf8 (filename));
 
943
               gimp_filename_to_utf8 (filename));
798
944
 
799
945
  return TRUE;
800
946
}
808
954
  GtkTextIter  start_iter;
809
955
  GtkTextIter  end_iter;
810
956
  gint         fd;
811
 
  gchar       *text_contents;
 
957
  gchar       *text_contents;
812
958
 
813
959
  g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
814
960
  g_return_val_if_fail (filename != NULL, FALSE);
815
961
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
816
962
 
817
 
  fd = open (filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
 
963
  fd = g_open (filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
818
964
 
819
965
  if (fd == -1)
820
966
    {
829
975
    gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
830
976
 
831
977
  text_contents = gtk_text_buffer_get_text (buffer,
832
 
                                            &start_iter, &end_iter, TRUE);
 
978
                                            &start_iter, &end_iter, TRUE);
833
979
 
834
980
  if (text_contents)
835
981
    {
872
1018
    gtk_widget_hide (widget);
873
1019
}
874
1020
 
 
1021
static gboolean
 
1022
gimp_widget_accel_find_func (GtkAccelKey *key,
 
1023
                             GClosure    *closure,
 
1024
                             gpointer     data)
 
1025
{
 
1026
  return (GClosure *) data == closure;
 
1027
}
 
1028
 
 
1029
static void
 
1030
gimp_widget_accel_changed (GtkAccelGroup   *accel_group,
 
1031
                           guint            unused1,
 
1032
                           GdkModifierType  unused2,
 
1033
                           GClosure        *accel_closure,
 
1034
                           GtkWidget       *widget)
 
1035
{
 
1036
  GClosure *widget_closure;
 
1037
 
 
1038
  widget_closure = g_object_get_data (G_OBJECT (widget), "gimp-accel-closure");
 
1039
 
 
1040
  if (accel_closure == widget_closure)
 
1041
    {
 
1042
      GtkAction   *action;
 
1043
      GtkAccelKey *accel_key;
 
1044
      gchar       *orig_tooltip;
 
1045
      gchar       *tooltip;
 
1046
      const gchar *help_id;
 
1047
 
 
1048
      action = g_object_get_data (G_OBJECT (widget), "gimp-accel-action");
 
1049
 
 
1050
      g_object_get (action, "tooltip", &orig_tooltip, NULL);
 
1051
      help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
 
1052
 
 
1053
      accel_key = gtk_accel_group_find (accel_group,
 
1054
                                        gimp_widget_accel_find_func,
 
1055
                                        accel_closure);
 
1056
 
 
1057
      if (accel_key            &&
 
1058
          accel_key->accel_key &&
 
1059
          accel_key->accel_flags & GTK_ACCEL_VISIBLE)
 
1060
        {
 
1061
          gchar *tmp = gimp_get_accel_string (accel_key->accel_key,
 
1062
                                              accel_key->accel_mods);
 
1063
 
 
1064
          tooltip = g_strconcat (orig_tooltip, "     ", tmp, NULL);
 
1065
 
 
1066
          g_free (tmp);
 
1067
        }
 
1068
      else
 
1069
        {
 
1070
          tooltip = g_strdup (orig_tooltip);
 
1071
        }
 
1072
 
 
1073
      gimp_help_set_help_data (widget, tooltip, help_id);
 
1074
 
 
1075
      g_free (tooltip);
 
1076
      g_free (orig_tooltip);
 
1077
    }
 
1078
}
 
1079
 
 
1080
void
 
1081
gimp_widget_set_accel_help (GtkWidget *widget,
 
1082
                            GtkAction *action)
 
1083
{
 
1084
  GClosure *accel_closure = NULL;
 
1085
 
 
1086
  accel_closure = gtk_action_get_accel_closure (action);
 
1087
 
 
1088
  if (accel_closure)
 
1089
    {
 
1090
      GtkAccelGroup *accel_group;
 
1091
 
 
1092
      g_object_set_data (G_OBJECT (widget), "gimp-accel-closure",
 
1093
                         accel_closure);
 
1094
      g_object_set_data (G_OBJECT (widget), "gimp-accel-action",
 
1095
                         action);
 
1096
 
 
1097
      accel_group = gtk_accel_group_from_accel_closure (accel_closure);
 
1098
 
 
1099
      g_signal_connect_object (accel_group, "accel-changed",
 
1100
                               G_CALLBACK (gimp_widget_accel_changed),
 
1101
                               widget, 0);
 
1102
 
 
1103
      gimp_widget_accel_changed (accel_group,
 
1104
                                 0, 0,
 
1105
                                 accel_closure,
 
1106
                                 widget);
 
1107
    }
 
1108
  else
 
1109
    {
 
1110
      gchar *tooltip;
 
1111
      gchar *help_id;
 
1112
 
 
1113
      g_object_get (action, "tooltip", &tooltip, NULL);
 
1114
      help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
 
1115
 
 
1116
      gimp_help_set_help_data (widget, tooltip, help_id);
 
1117
 
 
1118
      g_free (tooltip);
 
1119
    }
 
1120
}
 
1121
 
 
1122
const gchar *
 
1123
gimp_get_message_stock_id (GimpMessageSeverity severity)
 
1124
{
 
1125
  switch (severity)
 
1126
    {
 
1127
    case GIMP_MESSAGE_INFO:
 
1128
      return GIMP_STOCK_INFO;
 
1129
 
 
1130
    case GIMP_MESSAGE_WARNING:
 
1131
      return GIMP_STOCK_WARNING;
 
1132
 
 
1133
    case GIMP_MESSAGE_ERROR:
 
1134
      return GIMP_STOCK_ERROR;
 
1135
    }
 
1136
 
 
1137
  g_return_val_if_reached (GIMP_STOCK_WARNING);
 
1138
}