Codebase list girara / 11ab874
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
6 changed file(s) with 35 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
0 Copyright (c) 2010-2018 pwmt.org
0 Copyright (c) 2010-2020 pwmt.org
11
22 This software is provided 'as-is', without any express or implied warranty. In
33 no event will the authors be held liable for any damages arising from the use of
177177 }
178178
179179 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)
181181 {
182182 g_return_val_if_fail(list != NULL && compare != NULL, NULL);
183183 if (list->start == NULL) {
140140 * @param data data passed as the second argument to the compare function
141141 * @return the element if found or NULL
142142 */
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,
144144 const void* data) GIRARA_VISIBLE;
145145
146146 /**
11
22 #include <ctype.h>
33 #include <glib.h>
4 #include <glib/gstdio.h>
45 #include <glib/gi18n-lib.h>
56 #include <limits.h>
67 #include <pwd.h>
6768 }
6869
6970 /* 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 };
7173
7274 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,
7476 NULL, NULL, &error);
7577 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);
7779 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 }
78100 }
79101
80102 g_free(argv[1]);
81 g_free(argv[0]);
82103
83104 return res;
84105 }
3939 char* girara_get_xdg_path(girara_xdg_path_t path) GIRARA_VISIBLE;
4040
4141 /**
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.
4344 *
4445 * @param uri the URI to be opened.
4546 * @return true on success, false otherwise
4748 bool girara_xdg_open(const char* uri) GIRARA_VISIBLE;
4849
4950 /**
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.
5153 *
5254 * @param uri the URI to be opened.
5355 * @param working_directory working directory
00 project('girara', 'c',
1 version: '0.3.3',
1 version: '0.3.4',
22 meson_version: '>=0.48',
33 default_options: 'c_std=c11',
44 )
159159 requires_private: pc_requires_private,
160160 )
161161
162 girara_dependency = declare_dependency(link_with: girara, include_directories: include_directories)
163
162164 subdir('doc')
163165 subdir('tests')