Update upstream source from tag 'upstream/0.3.4'
Update to upstream version '0.3.4'
with Debian dir 4e8602aaac740e974fb847491c9fc8c9bba28f37
Sebastian Ramacher
4 years ago
0 | Copyright (c) 2010-2018 pwmt.org | |
0 | Copyright (c) 2010-2020 pwmt.org | |
1 | 1 | |
2 | 2 | This software is provided 'as-is', without any express or implied warranty. In |
3 | 3 | no event will the authors be held liable for any damages arising from the use of |
177 | 177 | } |
178 | 178 | |
179 | 179 | void* |
180 | girara_list_find(girara_list_t* list, girara_compare_function_t compare, const void* data) | |
180 | girara_list_find(const girara_list_t* list, girara_compare_function_t compare, const void* data) | |
181 | 181 | { |
182 | 182 | g_return_val_if_fail(list != NULL && compare != NULL, NULL); |
183 | 183 | if (list->start == NULL) { |
140 | 140 | * @param data data passed as the second argument to the compare function |
141 | 141 | * @return the element if found or NULL |
142 | 142 | */ |
143 | void* girara_list_find(girara_list_t* list, girara_compare_function_t compare, | |
143 | void* girara_list_find(const girara_list_t* list, girara_compare_function_t compare, | |
144 | 144 | const void* data) GIRARA_VISIBLE; |
145 | 145 | |
146 | 146 | /** |
1 | 1 | |
2 | 2 | #include <ctype.h> |
3 | 3 | #include <glib.h> |
4 | #include <glib/gstdio.h> | |
4 | 5 | #include <glib/gi18n-lib.h> |
5 | 6 | #include <limits.h> |
6 | 7 | #include <pwd.h> |
67 | 68 | } |
68 | 69 | |
69 | 70 | /* g_spawn_async expects char** */ |
70 | char* argv[] = { g_strdup("xdg-open"), g_strdup(uri), NULL }; | |
71 | static char xdg_open[] = "xdg-open"; | |
72 | char* argv[] = { xdg_open, g_strdup(uri), NULL }; | |
71 | 73 | |
72 | 74 | GError* error = NULL; |
73 | const bool res = g_spawn_async(working_directory, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, | |
75 | bool res = g_spawn_async(working_directory, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, | |
74 | 76 | NULL, NULL, &error); |
75 | 77 | if (error != NULL) { |
76 | girara_warning("Failed to execute command: %s", error->message); | |
78 | girara_warning("Failed to execute 'xdg-open %s': %s", uri, error->message); | |
77 | 79 | g_error_free(error); |
80 | error = NULL; | |
81 | } | |
82 | ||
83 | if (res == false) { | |
84 | /* fall back to `gio open` */ | |
85 | char* current_dir = working_directory != NULL ? g_get_current_dir() : NULL; | |
86 | if (working_directory != NULL) { | |
87 | g_chdir(working_directory); | |
88 | } | |
89 | ||
90 | res = g_app_info_launch_default_for_uri(uri, NULL, &error); | |
91 | if (error != NULL) { | |
92 | girara_warning("Failed to open '%s': %s", uri, error->message); | |
93 | g_error_free(error); | |
94 | } | |
95 | ||
96 | if (working_directory != NULL) { | |
97 | g_chdir(current_dir); | |
98 | g_free(current_dir); | |
99 | } | |
78 | 100 | } |
79 | 101 | |
80 | 102 | g_free(argv[1]); |
81 | g_free(argv[0]); | |
82 | 103 | |
83 | 104 | return res; |
84 | 105 | } |
39 | 39 | char* girara_get_xdg_path(girara_xdg_path_t path) GIRARA_VISIBLE; |
40 | 40 | |
41 | 41 | /** |
42 | * Opens a URI with xdg-open. | |
42 | * Opens a URI with xdg-open. If xdg-open is not available, it falls back to the equivalent of gio | |
43 | * open. | |
43 | 44 | * |
44 | 45 | * @param uri the URI to be opened. |
45 | 46 | * @return true on success, false otherwise |
47 | 48 | bool girara_xdg_open(const char* uri) GIRARA_VISIBLE; |
48 | 49 | |
49 | 50 | /** |
50 | * Opens a URI with xdg-open in a different working directory. | |
51 | * Opens a URI with xdg-open in a different working directory. If xdg-open is not available, it | |
52 | * falls back to the equivalent of gio open. | |
51 | 53 | * |
52 | 54 | * @param uri the URI to be opened. |
53 | 55 | * @param working_directory working directory |
0 | 0 | project('girara', 'c', |
1 | version: '0.3.3', | |
1 | version: '0.3.4', | |
2 | 2 | meson_version: '>=0.48', |
3 | 3 | default_options: 'c_std=c11', |
4 | 4 | ) |
159 | 159 | requires_private: pc_requires_private, |
160 | 160 | ) |
161 | 161 | |
162 | girara_dependency = declare_dependency(link_with: girara, include_directories: include_directories) | |
163 | ||
162 | 164 | subdir('doc') |
163 | 165 | subdir('tests') |