libpurple/purplepath.c

Thu, 25 Aug 2022 23:25:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 23:25:12 -0500
branch
gtk4
changeset 41598
2b34cd990c16
parent 41264
46a289816176
child 41680
fcd5838ffd18
permissions
-rw-r--r--

Replace the style-updated signal with GtkIconTheme:changed

Testing Done:
Ran and make sure the `GWarning` went away.

Reviewed at https://reviews.imfreedom.org/r/1653/

41237
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <libpurple/purplepath.h>
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
41264
46a289816176 We need to include our win32dep.h file for the path api
Gary Kramlich <grim@reaperworld.com>
parents: 41237
diff changeset
21 #ifdef _WIN32
46a289816176 We need to include our win32dep.h file for the path api
Gary Kramlich <grim@reaperworld.com>
parents: 41237
diff changeset
22 # include "win32/win32dep.h"
46a289816176 We need to include our win32dep.h file for the path api
Gary Kramlich <grim@reaperworld.com>
parents: 41237
diff changeset
23 #endif
46a289816176 We need to include our win32dep.h file for the path api
Gary Kramlich <grim@reaperworld.com>
parents: 41237
diff changeset
24
41237
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * Globals
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 static gchar *custom_user_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 static gchar *user_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 static gchar *cache_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 static gchar *config_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 static gchar *data_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 /******************************************************************************
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 * Helpers
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 *****************************************************************************/
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 static const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 purple_xdg_dir(gchar **xdg_dir, const gchar *xdg_base_dir,
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 const gchar *xdg_type)
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 if (!*xdg_dir) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 if (!custom_user_dir) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 *xdg_dir = g_build_filename(xdg_base_dir, "purple", NULL);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 } else {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 *xdg_dir = g_build_filename(custom_user_dir, xdg_type, NULL);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 return *xdg_dir;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 /******************************************************************************
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 * Public API
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 *****************************************************************************/
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 purple_home_dir(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 #ifndef _WIN32
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 return g_get_home_dir();
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 #else
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 return wpurple_home_dir();
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 #endif
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 /* Returns the argument passed to -c IFF it was present, or ~/.purple. */
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 purple_user_dir(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 if(custom_user_dir != NULL) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 return custom_user_dir;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 } else if(!user_dir) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 user_dir = g_build_filename(purple_home_dir(), ".purple", NULL);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 return user_dir;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 purple_cache_dir(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 return purple_xdg_dir(&cache_dir, g_get_user_cache_dir(), "cache");
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 purple_config_dir(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 return purple_xdg_dir(&config_dir, g_get_user_config_dir(), "config");
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 const gchar *
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 purple_data_dir(void) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 return purple_xdg_dir(&data_dir, g_get_user_data_dir(), "data");
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 void
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 purple_util_set_user_dir(const gchar *dir) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 g_free(custom_user_dir);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 if(dir != NULL && *dir) {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 custom_user_dir = g_strdup(dir);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 } else {
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 custom_user_dir = NULL;
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 }
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_clear_pointer(&user_dir, g_free);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 g_clear_pointer(&cache_dir, g_free);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 g_clear_pointer(&config_dir, g_free);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 g_clear_pointer(&data_dir, g_free);
5098e0dd3a09 Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }

mercurial