2
This file is part of LoggerOuter.
4
LoggerOuter is free software: you can redistribute it and/or modify it under the
5
terms of the GNU Lesser General Public License as published by the Free Software
6
Foundation, either version 3 of the License, or (at your option) any later
9
LoggerOuter is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
License for more details.
14
You should have received a copy of the GNU Lessel General Public License
15
along with LoggerOuter. If not, see <https://www.gnu.org/licenses/>.
21
public static string strip_prelude_of_path (string str) {
23
if (str_starts_with (str, "file://")) {
24
print ("Icon is path!\n");
25
tmp_str = str.substring (7).escape (null);
26
print (@"$(tmp_str)\n");
33
public static string str_escape_enviorment_variables (string str ) {
38
// Fake old style gtk_main () from old GTK.
39
void fake_gtk_main () {
40
if ( Gtk.Window.get_toplevels () != null ){
41
while (((GLib.ListStore)Gtk.Window.get_toplevels ()).get_n_items () > 0) {
42
GLib.MainContext.default ().iteration (true);
47
void __dialog_response (int id) {
55
Gtk.MessageDialog dia;
58
// Easier presentation of dialog...
59
void prensent_dialog (string? format, ...) {
60
bool use_fake_main_loop = false;
61
Gtk.Window? parent = null;
62
if (!Gtk.is_initialized ()) {
64
use_fake_main_loop = true;
70
string message = format.vprintf (va_list ());
71
GLib.stderr.printf (message);
73
dia = new Gtk.AlertDialog (message, null);
74
dia.response.connect (__dialog_responce );
77
dia = new Gtk.MessageDialog (parent,
78
Gtk.DialogFlags.USE_HEADER_BAR,
79
Gtk.MessageType.ERROR,
80
Gtk.ButtonsType.CANCEL, message, null);
81
dia.response.connect (__dialog_response );
84
if (use_fake_main_loop) {
91
bool str_starts_with (string stack, string needle) {
92
if (stack.length < needle.length ) {
95
for (long i = 0; i < needle.length; i++) {
96
if (stack[i] != needle[i]) {
104
string resolve_path (string path) {
109
if (path[0] == '/') {
113
if (str_starts_with (path, "~/")) {
114
base_dir = GLib.Environment.get_home_dir ();
115
long index = path.index_of_char ('/');
117
out_path = base_dir + path.substring (index);
120
base_dir = GLib.Environment.get_current_dir () + "/";
121
// either "./" or nothing at start.
122
if (str_starts_with (path, "./")) {
124
long index = path.index_of_char ('/') + 1;
125
tmp_file = path.substring (index);
131
out_path= base_dir + tmp_file;