Skip to content

Commit 2927230

Browse files
authored
core: add g_icon property to icon widget (#2)
1 parent 8da6a21 commit 2927230

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/src/widget/icon.vala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Icon : Gtk.Image {
1010

1111
public new Gdk.Pixbuf pixbuf { get; set; }
1212
public string icon { get; set; default = ""; }
13+
public GLib.Icon g_icon {get; set;}
1314

1415
private async void display_icon() {
1516
switch(type) {
@@ -45,6 +46,11 @@ public class Icon : Gtk.Image {
4546
set_from_surface(cs);
4647
}
4748
break;
49+
case IconType.GICON:
50+
pixel_size = (int)size;
51+
gicon = g_icon;
52+
break;
53+
4854
}
4955
}
5056

@@ -71,6 +77,11 @@ public class Icon : Gtk.Image {
7177
display_icon.begin();
7278
});
7379

80+
notify["g-icon"].connect(() => {
81+
type = IconType.GICON;
82+
display_icon.begin();
83+
});
84+
7485
size_allocate.connect(() => {
7586
size = get_style_context()
7687
.get_property("font-size", Gtk.StateFlags.NORMAL).get_double();
@@ -91,5 +102,6 @@ private enum IconType {
91102
NAMED,
92103
FILE,
93104
PIXBUF,
105+
GICON,
94106
}
95107
}

0 commit comments

Comments
 (0)