diff options
Diffstat (limited to 'src/utils.vala')
-rw-r--r-- | src/utils.vala | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/utils.vala b/src/utils.vala new file mode 100644 index 0000000..04837df --- /dev/null +++ b/src/utils.vala @@ -0,0 +1,46 @@ +namespace JadupcSupport +{ + namespace utils + { + internal string get_message_icon(Gtk.MessageType type) + { + switch (type) { + case ERROR: + return "dialog-error"; + case INFO: + return "dialog-information"; + case QUESTION: + return "dialog-question"; + case WARNING: + return "dialog-warning"; + default: + return "image-missing"; + } + } + +// This function takes a visible Gtk Widget and recursively realizes +// the childrens as Gtk whines on key event if even one +// ((great)grand)children widget is not realized... + internal void realize_all(Gtk.Container container) + { + if (!container.get_realized()) + container.realize(); + + container.foreach((widget) => { + if (widget is Gtk.Container) realize_all(widget as Gtk.Container); + else if (!widget.get_realized()) widget.realize(); + }); + } + + internal string strret(int ret, string[] retstrs = {}) + { + if (0 < ret <= 64 && !(ret == 11 || ret == 28 || 3 <= ret <= 8)) + return "%s".printf(strsignal(ret) ?? _("Unknown Signal - %d").printf(ret)); + else if (128 < ret < 256) + return "%s".printf(strsignal(ret - 128) ?? _("Unknown Signal - %d").printf(ret)); + else if (ret % 256 == 0) + return _("Process returned %d").printf(ret / 256); + return _("Exit status - %d (unknown)").printf(ret); + } + } +} |