1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #include "config.h"
19 
20 #include <gegl.h>
21 #include <gtk/gtk.h>
22 
23 #include "libgimpbase/gimpbase.h"
24 #include "libgimpcolor/gimpcolor.h"
25 #include "libgimpwidgets/gimpwidgets.h"
26 
27 #include "widgets-types.h"
28 
29 #include "gimpwidgets-constructors.h"
30 
31 #include "gimp-intl.h"
32 
33 
34 /*  public functions  */
35 
36 GtkWidget *
gimp_icon_button_new(const gchar * icon_name,const gchar * label)37 gimp_icon_button_new (const gchar *icon_name,
38                       const gchar *label)
39 {
40   GtkWidget *button;
41   GtkWidget *image;
42 
43   button = gtk_button_new ();
44 
45   if (label)
46     {
47       GtkWidget *hbox;
48       GtkWidget *lab;
49 
50       hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
51       gtk_container_add (GTK_CONTAINER (button), hbox);
52       gtk_widget_show (hbox);
53 
54       image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
55       gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
56       gtk_widget_show (image);
57 
58       lab = gtk_label_new_with_mnemonic (label);
59       gtk_label_set_mnemonic_widget (GTK_LABEL (lab), button);
60       gtk_box_pack_start (GTK_BOX (hbox), lab, TRUE, TRUE, 0);
61       gtk_widget_show (lab);
62     }
63   else
64     {
65       image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
66       gtk_container_add (GTK_CONTAINER (button), image);
67       gtk_widget_show (image);
68     }
69 
70   return button;
71 }
72 
73 GtkWidget *
gimp_color_profile_label_new(GimpColorProfile * profile)74 gimp_color_profile_label_new (GimpColorProfile *profile)
75 {
76   GtkWidget   *expander;
77   GtkWidget   *view;
78   const gchar *label;
79 
80   g_return_val_if_fail (profile == NULL ||
81                         GIMP_IS_COLOR_PROFILE (profile), NULL);
82 
83   if (profile)
84     label = gimp_color_profile_get_label (profile);
85   else
86     label = C_("profile", "None");
87 
88   expander = gtk_expander_new (label);
89 
90   view = gimp_color_profile_view_new ();
91 
92   if (profile)
93     gimp_color_profile_view_set_profile (GIMP_COLOR_PROFILE_VIEW (view),
94                                          profile);
95   else
96     gimp_color_profile_view_set_error (GIMP_COLOR_PROFILE_VIEW (view),
97                                        C_("profile", "None"));
98 
99   gtk_container_add (GTK_CONTAINER (expander), view);
100   gtk_widget_show (view);
101 
102   return expander;
103 }
104