@@ -49,6 +49,7 @@ with GNAT.Strings; use GNAT.Strings;
49
49
50
50
with Glib.Convert ; use Glib.Convert;
51
51
with Glib.Error ; use Glib.Error;
52
+ with Glib.G_Icon ; use Glib.G_Icon;
52
53
with Glib.Menu ; use Glib.Menu;
53
54
with Glib.Object ; use Glib.Object;
54
55
with Glib.Properties ; use Glib.Properties;
@@ -677,6 +678,11 @@ package body Gtkada.MDI is
677
678
678
679
end Close_Button ;
679
680
681
+ function Get_Icon
682
+ (Child : not null access MDI_Child_Record'Class)
683
+ return Gtk_Image;
684
+ -- Retrieve icon. Can return null.
685
+
680
686
package body Close_Button is separate ;
681
687
682
688
-- -------------------
@@ -1244,7 +1250,7 @@ package body Gtkada.MDI is
1244
1250
D.Icon.Set_From_Icon_Name
1245
1251
(C.Icon_Name.all , Size => Icon_Size_Menu);
1246
1252
elsif C.Title_Icon /= null then
1247
- Scaled := C.Title_Icon.Get; -- still owned by Title_Icon
1253
+ Scaled := Get_Icon (C);
1248
1254
Set_Child_Visible (D.Icon, Scaled /= null );
1249
1255
if Scaled /= null then
1250
1256
Scaled := Scale_Simple (Scaled, 32 , 32 );
@@ -3173,6 +3179,35 @@ package body Gtkada.MDI is
3173
3179
return Child.Title_Icon.Get;
3174
3180
end Get_Icon ;
3175
3181
3182
+ -- ------------
3183
+ -- Get_Icon --
3184
+ -- ------------
3185
+
3186
+ function Get_Icon
3187
+ (Child : not null access MDI_Child_Record'Class)
3188
+ return Gtk_Image
3189
+ is
3190
+ Result : Gtk_Image;
3191
+
3192
+ Pixbuf : Gdk_Pixbuf;
3193
+ G_Icon : Glib.G_Icon.G_Icon;
3194
+ Size : Gtk.Enums.Gtk_Icon_Size;
3195
+
3196
+ begin
3197
+ Pixbuf := Child.Title_Icon.Get; -- still owned by the image
3198
+ if Pixbuf /= null then
3199
+ Gtk_New (Result, Pixbuf);
3200
+
3201
+ else
3202
+ Child.Title_Icon.Get (G_Icon, Size);
3203
+ if G_Icon /= Null_G_Icon then
3204
+ Result := Gtk_Image_New_From_Gicon (G_Icon, Size);
3205
+ end if ;
3206
+ end if ;
3207
+
3208
+ return Result;
3209
+ end Get_Icon ;
3210
+
3176
3211
-- -----------------
3177
3212
-- Get_Icon_Name --
3178
3213
-- -----------------
@@ -5531,11 +5566,10 @@ package body Gtkada.MDI is
5531
5566
Child : MDI_Child;
5532
5567
It : Gtk_Radio_Menu_Item;
5533
5568
Box : Gtk_Box;
5534
- Pixbuf : Gdk_Pixbuf;
5535
- Pixmap : Gtk_Image;
5536
5569
Label : Gtk_Accel_Label;
5537
5570
Children, L : Widget_List.Glist;
5538
5571
W : Gtk_Widget;
5572
+ Icon : Gtk_Image;
5539
5573
begin
5540
5574
-- Remove all items
5541
5575
@@ -5569,10 +5603,9 @@ package body Gtkada.MDI is
5569
5603
Gtk_New_Hbox (Box, Homogeneous => False, Spacing => 5 );
5570
5604
It.Add (Box);
5571
5605
5572
- Pixbuf := Child.Title_Icon.Get; -- still owned by the image
5573
- if Pixbuf /= null then
5574
- Gtk_New (Pixmap, Pixbuf);
5575
- Box.Pack_Start (Pixmap, Expand => False);
5606
+ Icon := Get_Icon (Child);
5607
+ if Icon /= null then
5608
+ Box.Pack_Start (Icon, Expand => False);
5576
5609
end if ;
5577
5610
5578
5611
Gtk_New (Label, Child.Short_Title.all );
0 commit comments