30
30
#include "gimpdocked.h"
31
31
#include "gimpeditor.h"
32
32
#include "gimpdnd.h"
33
#include "gimpenumwidgets.h"
34
33
#include "gimpmenufactory.h"
35
34
#include "gimpuimanager.h"
36
35
#include "gimpwidgets-utils.h"
37
#include "gimp-intl.h"
39
40
#define DEFAULT_CONTENT_SPACING 2
40
41
#define DEFAULT_BUTTON_SPACING 2
48
49
PROP_MENU_IDENTIFIER,
54
static void gimp_editor_class_init (GimpEditorClass *klass);
55
static void gimp_editor_init (GimpEditor *editor);
56
static void gimp_editor_docked_iface_init (GimpDockedInterface *docked_iface);
57
static void gimp_editor_docked_iface_init (GimpDockedInterface *iface);
58
59
static GObject * gimp_editor_constructor (GType type,
70
71
static void gimp_editor_style_set (GtkWidget *widget,
71
72
GtkStyle *prev_style);
73
static GimpUIManager * gimp_editor_get_menu (GimpDocked *docked,
74
const gchar **ui_path,
75
gpointer *popup_data);
77
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
80
static GtkVBoxClass *parent_class = NULL;
84
gimp_editor_get_type (void)
86
static GType type = 0;
90
static const GTypeInfo info =
92
sizeof (GimpEditorClass),
94
NULL, /* base_finalize */
95
(GClassInitFunc) gimp_editor_class_init,
96
NULL, /* class_finalize */
97
NULL, /* class_data */
100
(GInstanceInitFunc) gimp_editor_init,
102
static const GInterfaceInfo docked_iface_info =
104
(GInterfaceInitFunc) gimp_editor_docked_iface_init,
105
NULL, /* iface_finalize */
106
NULL /* iface_data */
109
type = g_type_register_static (GTK_TYPE_VBOX,
113
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
74
static GimpUIManager * gimp_editor_get_menu (GimpDocked *docked,
75
const gchar **ui_path,
76
gpointer *popup_data);
77
static gboolean gimp_editor_has_button_bar (GimpDocked *docked);
78
static void gimp_editor_set_show_button_bar (GimpDocked *docked,
80
static gboolean gimp_editor_get_show_button_bar (GimpDocked *docked);
82
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
85
G_DEFINE_TYPE_WITH_CODE (GimpEditor, gimp_editor, GTK_TYPE_VBOX,
86
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
87
gimp_editor_docked_iface_init))
89
#define parent_class gimp_editor_parent_class
121
93
gimp_editor_class_init (GimpEditorClass *klass)
124
96
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
125
97
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
127
parent_class = g_type_class_peek_parent (klass);
129
99
object_class->constructor = gimp_editor_constructor;
130
100
object_class->set_property = gimp_editor_set_property;
131
101
object_class->get_property = gimp_editor_get_property;
138
108
g_param_spec_object ("menu-factory",
140
110
GIMP_TYPE_MENU_FACTORY,
111
GIMP_PARAM_READWRITE |
142
112
G_PARAM_CONSTRUCT_ONLY));
144
114
g_object_class_install_property (object_class, PROP_MENU_IDENTIFIER,
145
115
g_param_spec_string ("menu-identifier",
118
GIMP_PARAM_READWRITE |
149
119
G_PARAM_CONSTRUCT_ONLY));
151
121
g_object_class_install_property (object_class, PROP_UI_PATH,
152
122
g_param_spec_string ("ui-path",
125
GIMP_PARAM_READWRITE |
156
126
G_PARAM_CONSTRUCT_ONLY));
158
128
g_object_class_install_property (object_class, PROP_POPUP_DATA,
159
129
g_param_spec_pointer ("popup-data",
131
GIMP_PARAM_READWRITE |
162
132
G_PARAM_CONSTRUCT_ONLY));
134
g_object_class_install_property (object_class, PROP_SHOW_NAME,
135
g_param_spec_boolean ("show-name",
138
GIMP_PARAM_READWRITE));
140
g_object_class_install_property (object_class, PROP_NAME,
141
g_param_spec_string ("name",
144
GIMP_PARAM_WRITABLE |
164
147
gtk_widget_class_install_style_property (widget_class,
165
g_param_spec_int ("content_spacing",
148
g_param_spec_int ("content-spacing",
169
152
DEFAULT_CONTENT_SPACING,
153
GIMP_PARAM_READABLE));
172
155
gtk_widget_class_install_style_property (widget_class,
173
g_param_spec_int ("button_spacing",
156
g_param_spec_int ("button-spacing",
177
160
DEFAULT_BUTTON_SPACING,
161
GIMP_PARAM_READABLE));
180
163
gtk_widget_class_install_style_property (widget_class,
181
g_param_spec_enum ("button_icon_size",
164
g_param_spec_enum ("button-icon-size",
183
166
GTK_TYPE_ICON_SIZE,
184
167
DEFAULT_BUTTON_ICON_SIZE,
168
GIMP_PARAM_READABLE));
194
177
editor->ui_path = NULL;
195
178
editor->popup_data = editor;
196
179
editor->button_box = NULL;
180
editor->show_button_bar = TRUE;
182
editor->name_label = g_object_new (GTK_TYPE_LABEL,
185
"ellipsize", PANGO_ELLIPSIZE_END,
187
gimp_label_set_attributes (GTK_LABEL (editor->name_label),
188
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
190
gtk_box_pack_start (GTK_BOX (editor), editor->name_label, FALSE, FALSE, 0);
200
gimp_editor_docked_iface_init (GimpDockedInterface *docked_iface)
194
gimp_editor_docked_iface_init (GimpDockedInterface *iface)
202
docked_iface->get_menu = gimp_editor_get_menu;
196
iface->get_menu = gimp_editor_get_menu;
197
iface->has_button_bar = gimp_editor_has_button_bar;
198
iface->set_show_button_bar = gimp_editor_set_show_button_bar;
199
iface->get_show_button_bar = gimp_editor_get_show_button_bar;
251
248
case PROP_POPUP_DATA:
252
249
editor->popup_data = g_value_get_pointer (value);
252
g_object_set_property (G_OBJECT (editor->name_label), "visible", value);
255
gimp_editor_set_name (editor, g_value_get_string (value));
255
258
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
279
282
case PROP_POPUP_DATA:
280
283
g_value_set_pointer (value, editor->popup_data);
286
g_object_get_property (G_OBJECT (editor->name_label), "visible", value);
283
289
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
327
333
if (GTK_WIDGET_CLASS (parent_class)->style_set)
328
334
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
330
gtk_widget_style_get (widget, "content_spacing", &content_spacing, NULL);
336
gtk_widget_style_get (widget, "content-spacing", &content_spacing, NULL);
332
338
gtk_box_set_spacing (GTK_BOX (widget), content_spacing);
348
354
return editor->ui_manager;
359
gimp_editor_has_button_bar (GimpDocked *docked)
361
GimpEditor *editor = GIMP_EDITOR (docked);
363
return editor->button_box != NULL;
367
gimp_editor_set_show_button_bar (GimpDocked *docked,
370
GimpEditor *editor = GIMP_EDITOR (docked);
372
if (show != editor->show_button_bar)
374
editor->show_button_bar = show;
376
if (editor->button_box)
379
gtk_widget_show (editor->button_box);
381
gtk_widget_hide (editor->button_box);
387
gimp_editor_get_show_button_bar (GimpDocked *docked)
389
GimpEditor *editor = GIMP_EDITOR (docked);
391
return editor->show_button_bar;
352
395
gimp_editor_new (void)
356
editor = g_object_new (GIMP_TYPE_EDITOR, NULL);
358
return GTK_WIDGET (editor);
397
return g_object_new (GIMP_TYPE_EDITOR, NULL);
430
469
button_icon_size = gimp_editor_ensure_button_box (editor);
432
button = gimp_button_new ();
471
button = g_object_new (GIMP_TYPE_BUTTON,
433
474
gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
434
475
gtk_widget_show (button);
440
481
g_signal_connect (button, "clicked",
444
485
if (extended_callback)
445
g_signal_connect (button, "extended_clicked",
486
g_signal_connect (button, "extended-clicked",
449
490
image = gtk_image_new_from_stock (stock_id, button_icon_size);
450
491
gtk_container_add (GTK_CONTAINER (button), image);
577
619
button = gimp_button_new ();
580
gtk_action_connect_proxy (action, button);
581
gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
582
gtk_widget_show (button);
584
622
g_object_get (action,
585
623
"stock-id", &stock_id,
586
624
"tooltip", &tooltip,
589
help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
591
627
old_child = gtk_bin_get_child (GTK_BIN (button));
600
636
g_free (stock_id);
638
gtk_action_connect_proxy (action, button);
639
gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
640
gtk_widget_show (button);
602
642
va_start (args, action_name);
604
644
action_name = va_arg (args, const gchar *);
632
gchar *tmp = g_strconcat (tooltip, "\n",
672
gchar *tmp = g_strconcat (tooltip, "\n(",
633
673
gimp_get_mod_string (mod_mask),
634
" ", ext_tooltip, NULL);
674
") ", ext_tooltip, NULL);
636
676
g_free (ext_tooltip);
637
677
g_free (tooltip);
650
690
g_object_set_data_full (G_OBJECT (button), "extended-actions", extended,
651
691
(GDestroyNotify) gimp_editor_button_extended_actions_free);
653
g_signal_connect (button, "extended_clicked",
693
g_signal_connect (button, "extended-clicked",
654
694
G_CALLBACK (gimp_editor_button_extended_clicked),
698
help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
658
700
if (tooltip || help_id)
659
701
gimp_help_set_help_data (button, tooltip, help_id);
709
gimp_editor_set_show_name (GimpEditor *editor,
712
g_return_if_fail (GIMP_IS_EDITOR (editor));
714
g_object_set (editor, "show-name", show, NULL);
718
gimp_editor_set_name (GimpEditor *editor,
721
g_return_if_fail (GIMP_IS_EDITOR (editor));
723
gtk_label_set_text (GTK_LABEL (editor->name_label),
724
name ? name : _("(None)"));
667
728
gimp_editor_set_box_style (GimpEditor *editor,
676
737
g_return_if_fail (GTK_IS_BOX (box));
678
739
gtk_widget_style_get (GTK_WIDGET (editor),
679
"button_icon_size", &button_icon_size,
680
"button_spacing", &button_spacing,
740
"button-icon-size", &button_icon_size,
741
"button-spacing", &button_spacing,
683
744
gtk_box_set_spacing (box, button_spacing);
716
777
gint button_spacing;
718
779
gtk_widget_style_get (GTK_WIDGET (editor),
719
"button_icon_size", &button_icon_size,
720
"button_spacing", &button_spacing,
780
"button-icon-size", &button_icon_size,
781
"button-spacing", &button_spacing,
723
784
if (! editor->button_box)
725
786
editor->button_box = gtk_hbox_new (TRUE, button_spacing);
726
787
gtk_box_pack_end (GTK_BOX (editor), editor->button_box, FALSE, FALSE, 0);
727
788
gtk_box_reorder_child (GTK_BOX (editor), editor->button_box, 0);
728
gtk_widget_show (editor->button_box);
790
if (editor->show_button_bar)
791
gtk_widget_show (editor->button_box);
731
794
return button_icon_size;