Bug Summary

File:capplet/cafe-notification-properties.c
Warning:line 86, column 2
Value stored to 'valid' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cafe-notification-properties.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src/capplet -fcoverage-compilation-dir=/rootdir/src/capplet -resource-dir /usr/lib/llvm-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I ../../src/daemon -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/cdk-pixbuf-2.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/harfbuzz -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glycin-2 -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D ENGINES_DIR="/usr/lib/cafe-notification-daemon/engines" -D NOTIFICATION_LOCALEDIR="/usr/share/locale" -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2026-08-28-085341-37675-1 -x c cafe-notification-properties.c
1/*
2 * Copyright (C) 2007 Jonh Wendell <wendell@bani.com.br>
3 * Copyright (C) 2011 Perberos <perberos@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#include "config.h"
22
23#include <glib/gi18n.h>
24#include <glib.h>
25#include <gmodule.h>
26#include <ctk/ctk.h>
27#include <cdk/cdk.h>
28#include <gio/gio.h>
29#include <string.h>
30#include <libnotify/notify.h>
31
32#include "stack.h"
33
34#define GSETTINGS_SCHEMA"org.cafe.NotificationDaemon" "org.cafe.NotificationDaemon"
35#define GSETTINGS_KEY_THEME"theme" "theme"
36#define GSETTINGS_KEY_POPUP_LOCATION"popup-location" "popup-location"
37#define GSETTINGS_KEY_MONITOR_NUMBER"monitor-number" "monitor-number"
38#define GSETTINGS_KEY_USE_ACTIVE_MONITOR"use-active-monitor" "use-active-monitor"
39#define GSETTINGS_KEY_DO_NOT_DISTURB"do-not-disturb" "do-not-disturb"
40
41typedef struct {
42 GSettings* gsettings;
43
44 CtkWidget* dialog;
45 CtkWidget* position_combo;
46 CtkWidget* monitor_combo;
47 CtkWidget* theme_combo;
48 CtkWidget* preview_button;
49 CtkWidget* active_checkbox;
50 CtkWidget* dnd_checkbox;
51 CtkWidget* monitor_label;
52
53 NotifyNotification* preview;
54} NotificationAppletDialog;
55
56enum {
57 NOTIFY_POSITION_LABEL,
58 NOTIFY_POSITION_NAME,
59 N_COLUMNS_POSITION
60};
61
62enum {
63 NOTIFY_MONITOR_NUMBER,
64 N_COLUMNS_MONITOR
65};
66
67enum {
68 NOTIFY_THEME_LABEL,
69 NOTIFY_THEME_NAME,
70 NOTIFY_THEME_FILENAME,
71 N_COLUMNS_THEME
72};
73
74static void notification_properties_position_notify (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)),
75 gchar *key,
76 NotificationAppletDialog *dialog)
77{
78 CtkTreeModel* model;
79 CtkTreeIter iter;
80 const char* location;
81 gboolean valid;
82
83 location = g_settings_get_string(dialog->gsettings, key);
84
85 model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
);
86 valid = ctk_tree_model_get_iter_first(model, &iter);
Value stored to 'valid' is never read
87
88 for (valid = ctk_tree_model_get_iter_first(model, &iter); valid; valid = ctk_tree_model_iter_next(model, &iter))
89 {
90 gchar* key;
91
92 ctk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1);
93
94 if (g_str_equal(key, location)(strcmp ((const char *) (key), (const char *) (location)) == 0
)
)
95 {
96 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
, &iter);
97 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
98 break;
99 }
100
101 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
102 }
103}
104
105static void notification_properties_monitor_changed (CtkComboBox *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
106 NotificationAppletDialog *dialog)
107{
108 gint monitor;
109 CtkTreeIter iter;
110
111 CtkTreeModel *model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
);
112
113 if (!ctk_combo_box_get_active_iter(CTK_COMBO_BOX(dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
, &iter))
114 {
115 return;
116 }
117
118 ctk_tree_model_get(model, &iter, NOTIFY_MONITOR_NUMBER, &monitor, -1);
119
120 g_settings_set_int(dialog->gsettings, GSETTINGS_KEY_MONITOR_NUMBER"monitor-number", monitor);
121}
122
123static void notification_properties_monitor_notify (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)),
124 gchar *key G_GNUC_UNUSED__attribute__ ((__unused__)),
125 NotificationAppletDialog *dialog)
126{
127 CtkTreeModel* model;
128 CtkTreeIter iter;
129 gint monitor_number;
130 gint monitor_number_at_iter;
131 gboolean valid;
132
133 model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
);
134
135 monitor_number = g_settings_get_int(dialog->gsettings, GSETTINGS_KEY_MONITOR_NUMBER"monitor-number");
136
137 for (valid = ctk_tree_model_get_iter_first(model, &iter); valid; valid = ctk_tree_model_iter_next(model, &iter))
138 {
139 ctk_tree_model_get(model, &iter, NOTIFY_MONITOR_NUMBER, &monitor_number_at_iter, -1);
140
141 if (monitor_number_at_iter == monitor_number)
142 {
143 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
, &iter);
144 break;
145 }
146 }
147}
148
149static void notification_properties_location_changed (CtkComboBox *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
150 NotificationAppletDialog *dialog)
151{
152 char* location;
153 CtkTreeIter iter;
154
155 CtkTreeModel* model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
);
156
157 if (!ctk_combo_box_get_active_iter(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
, &iter))
158 {
159 return;
160 }
161
162 ctk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &location, -1);
163
164 g_settings_set_string (dialog->gsettings, GSETTINGS_KEY_POPUP_LOCATION"popup-location", location);
165 g_free(location)(__builtin_object_size ((location), 0) != ((size_t) - 1)) ? g_free_sized
(location, __builtin_object_size ((location), 0)) : (g_free)
(location)
;
166}
167
168static void notification_properties_dialog_setup_positions(NotificationAppletDialog* dialog)
169{
170 char* location;
171 gboolean valid;
172 CtkTreeModel* model;
173 CtkTreeIter iter;
174
175 g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_POPUP_LOCATION, G_CALLBACK (notification_properties_position_notify), dialog)g_signal_connect_data ((dialog->gsettings), ("changed::" "popup-location"
), (((GCallback) (notification_properties_position_notify))),
(dialog), ((void*)0), (GConnectFlags) 0)
;
176 g_signal_connect(dialog->position_combo, "changed", G_CALLBACK(notification_properties_location_changed), dialog)g_signal_connect_data ((dialog->position_combo), ("changed"
), (((GCallback) (notification_properties_location_changed)))
, (dialog), ((void*)0), (GConnectFlags) 0)
;
177
178 model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
);
179 location = g_settings_get_string(dialog->gsettings, GSETTINGS_KEY_POPUP_LOCATION"popup-location");
180
181 for (valid = ctk_tree_model_get_iter_first(model, &iter); valid; valid = ctk_tree_model_iter_next(model, &iter))
182 {
183 gchar* key;
184
185 ctk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1);
186
187 if (g_str_equal(key, location)(strcmp ((const char *) (key), (const char *) (location)) == 0
)
)
188 {
189 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->position_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->position_combo)), ((ctk_combo_box_get_type ()
))))))
, &iter);
190 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
191 break;
192 }
193
194 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
195 }
196
197 g_free(location)(__builtin_object_size ((location), 0) != ((size_t) - 1)) ? g_free_sized
(location, __builtin_object_size ((location), 0)) : (g_free)
(location)
;
198}
199
200static void notification_properties_dialog_setup_monitors(NotificationAppletDialog* dialog)
201{
202 CtkListStore *store;
203 CdkDisplay *display;
204 CdkScreen *screen;
205 CtkTreeIter iter;
206 gint num_monitors;
207 gint cur_monitor_number;
208 gint cur_monitor_number_at_iter;
209 gboolean valid;
210
211 // Assumes the user has only one display.
212 // TODO: add support for multiple displays.
213 display = cdk_display_get_default();
214 g_assert(display != NULL)do { if (display != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 214, ((const
char*) (__func__)), "display != NULL"); } while (0)
;
215
216 // Assumes the user has only one screen.
217 // TODO: add support for mulitple screens.
218 screen = cdk_display_get_default_screen(display);
219 g_assert(screen != NULL)do { if (screen != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 219, ((const
char*) (__func__)), "screen != NULL"); } while (0)
;
220
221 num_monitors = cdk_display_get_n_monitors(display);
222 g_assert(num_monitors >= 1)do { if (num_monitors >= 1) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 222, ((const
char*) (__func__)), "num_monitors >= 1"); } while (0)
;
223
224 store = ctk_list_store_new(N_COLUMNS_MONITOR, G_TYPE_INT((GType) ((6) << (2))));
225
226 gint i;
227 for (i = 0; i < num_monitors; i++)
228 {
229 ctk_list_store_append(store, &iter);
230 ctk_list_store_set(store, &iter, NOTIFY_MONITOR_NUMBER, i, -1);
231 }
232
233 ctk_combo_box_set_model(CTK_COMBO_BOX (dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
, CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
);
234
235 g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_MONITOR_NUMBER, G_CALLBACK (notification_properties_monitor_notify), dialog)g_signal_connect_data ((dialog->gsettings), ("changed::" "monitor-number"
), (((GCallback) (notification_properties_monitor_notify))), (
dialog), ((void*)0), (GConnectFlags) 0)
;
236 cur_monitor_number = g_settings_get_int(dialog->gsettings, GSETTINGS_KEY_MONITOR_NUMBER"monitor-number");
237
238 for (valid = ctk_tree_model_get_iter_first(CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter); valid; valid = ctk_tree_model_iter_next(CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter))
239 {
240 ctk_tree_model_get(CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter, NOTIFY_MONITOR_NUMBER, &cur_monitor_number_at_iter, -1);
241
242 if (cur_monitor_number_at_iter == cur_monitor_number)
243 {
244 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->monitor_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->monitor_combo)), ((ctk_combo_box_get_type ())
)))))
, &iter);
245 break;
246 }
247 }
248
249 g_object_unref(store);
250
251 g_signal_connect(dialog->monitor_combo, "changed", G_CALLBACK(notification_properties_monitor_changed), dialog)g_signal_connect_data ((dialog->monitor_combo), ("changed"
), (((GCallback) (notification_properties_monitor_changed))),
(dialog), ((void*)0), (GConnectFlags) 0)
;
252}
253
254static void notification_properties_theme_notify (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)),
255 gchar *key,
256 NotificationAppletDialog *dialog)
257{
258 const char* theme = g_settings_get_string(dialog->gsettings, key);
259
260 CtkTreeModel* model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
);
261
262 CtkTreeIter iter;
263 gboolean valid;
264
265 for (valid = ctk_tree_model_get_iter_first(model, &iter); valid; valid = ctk_tree_model_iter_next(model, &iter))
266 {
267 gchar* theme_name;
268
269 ctk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme_name, -1);
270
271 if (g_str_equal(theme_name, theme)(strcmp ((const char *) (theme_name), (const char *) (theme))
== 0)
)
272 {
273 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
, &iter);
274 g_free(theme_name)(__builtin_object_size ((theme_name), 0) != ((size_t) - 1)) ?
g_free_sized (theme_name, __builtin_object_size ((theme_name
), 0)) : (g_free) (theme_name)
;
275 break;
276 }
277
278 g_free(theme_name)(__builtin_object_size ((theme_name), 0) != ((size_t) - 1)) ?
g_free_sized (theme_name, __builtin_object_size ((theme_name
), 0)) : (g_free) (theme_name)
;
279 }
280}
281
282static void notification_properties_theme_changed (CtkComboBox *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
283 NotificationAppletDialog *dialog)
284{
285 char* theme;
286 CtkTreeIter iter;
287
288 CtkTreeModel* model = ctk_combo_box_get_model(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
);
289
290 if (!ctk_combo_box_get_active_iter(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
, &iter))
291 {
292 return;
293 }
294
295 ctk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme, -1);
296 g_settings_set_string(dialog->gsettings, GSETTINGS_KEY_THEME"theme", theme);
297 g_free(theme)(__builtin_object_size ((theme), 0) != ((size_t) - 1)) ? g_free_sized
(theme, __builtin_object_size ((theme), 0)) : (g_free) (theme
)
;
298}
299
300static gchar* get_theme_name(const gchar* filename)
301{
302 /* TODO: Remove magic numbers. Strip "lib" and ".so" */
303 gchar* result = g_strdup(filename + 3)g_strdup_inline (filename + 3);
304 result[strlen(result) - strlen("." G_MODULE_SUFFIX"so")] = '\0';
305 return result;
306}
307
308static void notification_properties_dialog_setup_themes(NotificationAppletDialog* dialog)
309{
310 GDir* dir;
311 const gchar* filename;
312 char* theme;
313 gboolean valid;
314 CtkListStore* store;
315 CtkTreeIter iter;
316
317 store = ctk_list_store_new(N_COLUMNS_THEME, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))));
318
319 ctk_combo_box_set_model(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
, CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
);
320
321 g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_THEME, G_CALLBACK (notification_properties_theme_notify), dialog)g_signal_connect_data ((dialog->gsettings), ("changed::" "theme"
), (((GCallback) (notification_properties_theme_notify))), (dialog
), ((void*)0), (GConnectFlags) 0)
;
322 g_signal_connect(dialog->theme_combo, "changed", G_CALLBACK(notification_properties_theme_changed), dialog)g_signal_connect_data ((dialog->theme_combo), ("changed"),
(((GCallback) (notification_properties_theme_changed))), (dialog
), ((void*)0), (GConnectFlags) 0)
;
323
324 if ((dir = g_dir_open(ENGINES_DIR"/usr/lib/cafe-notification-daemon/engines", 0, NULL((void*)0))))
325 {
326 while ((filename = g_dir_read_name(dir)))
327 {
328 if (g_str_has_suffix(filename, "." G_MODULE_SUFFIX)(__builtin_constant_p ("." "so")? __extension__ ({ const char
* const __str = (filename); const char * const __suffix = ("."
"so"); gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (filename, "." "so"
) )
)
329 {
330 char* theme_name;
331 char* theme_label;
332
333 theme_name = get_theme_name(filename);
334
335 /* FIXME: other solution than hardcode? */
336 if (g_str_equal(theme_name, "coco")(strcmp ((const char *) (theme_name), (const char *) ("coco")
) == 0)
)
337 {
338 theme_label = g_strdup(_("Coco"))g_strdup_inline (gettext ("Coco"));
339 }
340 else if (g_str_equal(theme_name, "nodoka")(strcmp ((const char *) (theme_name), (const char *) ("nodoka"
)) == 0)
)
341 {
342 theme_label = g_strdup(_("Nodoka"))g_strdup_inline (gettext ("Nodoka"));
343 }
344 else if (g_str_equal(theme_name, "slider")(strcmp ((const char *) (theme_name), (const char *) ("slider"
)) == 0)
)
345 {
346 theme_label = g_strdup(_("Slider"))g_strdup_inline (gettext ("Slider"));
347 }
348 else if (g_str_equal(theme_name, "standard")(strcmp ((const char *) (theme_name), (const char *) ("standard"
)) == 0)
)
349 {
350 theme_label = g_strdup(_("Standard theme"))g_strdup_inline (gettext ("Standard theme"));
351 }
352 else
353 {
354 theme_label = g_strdup(theme_name)g_strdup_inline (theme_name);
355 }
356
357 ctk_list_store_append(store, &iter);
358 ctk_list_store_set(store, &iter, NOTIFY_THEME_LABEL, theme_label, NOTIFY_THEME_NAME, theme_name, NOTIFY_THEME_FILENAME, filename, -1);
359 g_free(theme_name)(__builtin_object_size ((theme_name), 0) != ((size_t) - 1)) ?
g_free_sized (theme_name, __builtin_object_size ((theme_name
), 0)) : (g_free) (theme_name)
;
360 g_free(theme_label)(__builtin_object_size ((theme_label), 0) != ((size_t) - 1)) ?
g_free_sized (theme_label, __builtin_object_size ((theme_label
), 0)) : (g_free) (theme_label)
;
361 }
362 }
363
364 g_dir_close(dir);
365 }
366 else
367 {
368 g_warning("Error opening themes dir");
369 }
370
371 theme = g_settings_get_string(dialog->gsettings, GSETTINGS_KEY_THEME"theme");
372
373 for (valid = ctk_tree_model_get_iter_first(CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter); valid; valid = ctk_tree_model_iter_next(CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter))
374 {
375 gchar* key;
376
377 ctk_tree_model_get(CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((ctk_tree_model_get_type ()))))))
, &iter, NOTIFY_THEME_NAME, &key, -1);
378
379 if (g_str_equal(key, theme)(strcmp ((const char *) (key), (const char *) (theme)) == 0))
380 {
381 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(dialog->theme_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->theme_combo)), ((ctk_combo_box_get_type ())))
)))
, &iter);
382 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
383 break;
384 }
385
386 g_free(key)(__builtin_object_size ((key), 0) != ((size_t) - 1)) ? g_free_sized
(key, __builtin_object_size ((key), 0)) : (g_free) (key)
;
387 }
388
389 g_free(theme)(__builtin_object_size ((theme), 0) != ((size_t) - 1)) ? g_free_sized
(theme, __builtin_object_size ((theme), 0)) : (g_free) (theme
)
;
390}
391
392static void notification_properties_checkbox_toggled(CtkWidget* widget, NotificationAppletDialog* dialog)
393{
394 gboolean is_active;
395
396 is_active = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON (widget)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toggle_button_get_type ()))))))
);
397
398 // This was called as a result of notification_properties_checkbox_notify being called.
399 // Stop here instead of doing redundant work.
400 if (is_active == g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR"use-active-monitor"))
401 {
402 return;
403 }
404
405 if (is_active)
406 {
407 g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR"use-active-monitor", TRUE(!(0)));
408 ctk_widget_set_sensitive(dialog->monitor_combo, FALSE(0));
409 ctk_widget_set_sensitive(dialog->monitor_label, FALSE(0));
410 }
411 else
412 {
413 g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR"use-active-monitor", FALSE(0));
414 ctk_widget_set_sensitive(dialog->monitor_combo, TRUE(!(0)));
415 ctk_widget_set_sensitive(dialog->monitor_label, TRUE(!(0)));
416 }
417}
418
419static void notification_properties_checkbox_notify(GSettings *settings, gchar *key, NotificationAppletDialog* dialog)
420{
421 gboolean is_set;
422
423 is_set = g_settings_get_boolean(settings, key);
424
425 // This was called as a result of notification_properties_checkbox_toggled being called.
426 // Stop here instead of doing redundant work.
427 if(is_set == ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON (dialog->active_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->active_checkbox)), ((ctk_toggle_button_get_type
()))))))
))
428 {
429 return;
430 }
431
432 if (is_set)
433 {
434 ctk_widget_set_sensitive(dialog->monitor_combo, FALSE(0));
435 ctk_widget_set_sensitive(dialog->monitor_label, FALSE(0));
436 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON (dialog->active_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->active_checkbox)), ((ctk_toggle_button_get_type
()))))))
, TRUE(!(0)));
437 }
438 else
439 {
440 ctk_widget_set_sensitive(dialog->monitor_combo, TRUE(!(0)));
441 ctk_widget_set_sensitive(dialog->monitor_label, TRUE(!(0)));
442 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON (dialog->active_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->active_checkbox)), ((ctk_toggle_button_get_type
()))))))
, FALSE(0));
443 }
444}
445
446static void notification_properties_dnd_toggled(CtkWidget* widget, NotificationAppletDialog* dialog)
447{
448 gboolean is_active;
449
450 is_active = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON (widget)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toggle_button_get_type ()))))))
);
451
452 // This was called as a result of notification_properties_dnd_notify being called.
453 // Stop here instead of doing redundant work.
454 if (is_active == g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB"do-not-disturb"))
455 {
456 return;
457 }
458
459 g_settings_set_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB"do-not-disturb", is_active);
460}
461
462static void notification_properties_dnd_notify(GSettings *settings, gchar *key, NotificationAppletDialog* dialog)
463{
464 gboolean is_set;
465
466 is_set = g_settings_get_boolean(settings, key);
467
468 // This was called as a result of notification_properties_dnd_toggled being called.
469 // Stop here instead of doing redundant work.
470 if(is_set == ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON (dialog->dnd_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->dnd_checkbox)), ((ctk_toggle_button_get_type (
)))))))
))
471 {
472 return;
473 }
474
475 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON (dialog->dnd_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->dnd_checkbox)), ((ctk_toggle_button_get_type (
)))))))
, is_set);
476}
477
478static void show_message(NotificationAppletDialog* dialog, const gchar* message)
479{
480 CtkWidget* d = ctk_message_dialog_new(CTK_WINDOW(dialog->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->dialog)), ((ctk_window_get_type ()))))))
, CTK_DIALOG_DESTROY_WITH_PARENT, CTK_MESSAGE_ERROR, CTK_BUTTONS_CLOSE, "%s", message);
481 ctk_dialog_run(CTK_DIALOG(d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((ctk_dialog_get_type ()))))))
);
482 ctk_widget_destroy(d);
483}
484
485static void notification_properties_dialog_preview_closed(NotifyNotification* preview, NotificationAppletDialog* dialog)
486{
487 if (preview == dialog->preview)
488 {
489 dialog->preview = NULL((void*)0);
490 }
491
492 g_object_unref(preview);
493}
494
495static void notification_properties_dialog_preview(NotificationAppletDialog* dialog)
496{
497 if (!notify_is_initted() && !notify_init("n-d"))
498 {
499 show_message(dialog, _("Error initializing libcafenotify")gettext ("Error initializing libcafenotify"));
500 return;
501 }
502
503 GError* error = NULL((void*)0);
504
505 if (dialog->preview)
506 {
507 notify_notification_close(dialog->preview, NULL((void*)0));
508 g_object_unref(dialog->preview);
509 dialog->preview = NULL((void*)0);
510 }
511
512 dialog->preview = notify_notification_new(_("Notification Test")gettext ("Notification Test"), _("Just a test")gettext ("Just a test"), "dialog-information");
513
514 if (!notify_notification_show(dialog->preview, &error))
515 {
516 char* message = g_strdup_printf(_("Error while displaying notification: %s")gettext ("Error while displaying notification: %s"), error->message);
517 show_message(dialog, message);
518 g_error_free(error);
519 g_free(message)(__builtin_object_size ((message), 0) != ((size_t) - 1)) ? g_free_sized
(message, __builtin_object_size ((message), 0)) : (g_free) (
message)
;
520 }
521
522 g_signal_connect(dialog->preview, "closed", G_CALLBACK(notification_properties_dialog_preview_closed), dialog)g_signal_connect_data ((dialog->preview), ("closed"), (((GCallback
) (notification_properties_dialog_preview_closed))), (dialog)
, ((void*)0), (GConnectFlags) 0)
;
523}
524
525static void notification_properties_dialog_response(CtkWidget* widget, int response, NotificationAppletDialog* dialog)
526{
527 switch (response)
528 {
529 case CTK_RESPONSE_ACCEPT:
530 notification_properties_dialog_preview(dialog);
531 break;
532
533 case CTK_RESPONSE_CLOSE:
534 default:
535 ctk_widget_destroy(widget);
536 break;
537 }
538}
539
540static void notification_properties_dialog_destroyed (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
541 NotificationAppletDialog *dialog)
542{
543 dialog->dialog = NULL((void*)0);
544
545 ctk_main_quit();
546}
547
548static gboolean notification_properties_dialog_init(NotificationAppletDialog* dialog)
549{
550 CtkBuilder* builder = ctk_builder_new();
551 GError* error = NULL((void*)0);
552
553 ctk_builder_add_from_resource (builder, "/org/cafe/notifications/properties/cafe-notification-properties.ui", &error);
554
555 if (error != NULL((void*)0))
556 {
557 g_warning(_("Could not load user interface: %s")gettext ("Could not load user interface: %s"), error->message);
558 g_error_free(error);
559 return FALSE(0);
560 }
561
562 dialog->dialog = CTK_WIDGET(ctk_builder_get_object(builder, "dialog"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "dialog"))), ((ctk_widget_get_type
()))))))
;
563 g_assert(dialog->dialog != NULL)do { if (dialog->dialog != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 563, ((const
char*) (__func__)), "dialog->dialog != NULL"); } while (0
)
;
564
565 dialog->position_combo = CTK_WIDGET(ctk_builder_get_object(builder, "position_combo"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "position_combo"))), ((ctk_widget_get_type
()))))))
;
566 g_assert(dialog->position_combo != NULL)do { if (dialog->position_combo != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 566, ((const
char*) (__func__)), "dialog->position_combo != NULL"); } while
(0)
;
567
568 dialog->monitor_combo = CTK_WIDGET(ctk_builder_get_object(builder, "monitor_combo"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "monitor_combo"))), ((ctk_widget_get_type
()))))))
;
569 g_assert(dialog->monitor_combo != NULL)do { if (dialog->monitor_combo != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 569, ((const
char*) (__func__)), "dialog->monitor_combo != NULL"); } while
(0)
;
570
571 dialog->theme_combo = CTK_WIDGET(ctk_builder_get_object(builder, "theme_combo"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "theme_combo"))), ((ctk_widget_get_type
()))))))
;
572 g_assert(dialog->theme_combo != NULL)do { if (dialog->theme_combo != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 572, ((const
char*) (__func__)), "dialog->theme_combo != NULL"); } while
(0)
;
573
574 dialog->active_checkbox = CTK_WIDGET(ctk_builder_get_object(builder, "use_active_check"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "use_active_check"))), (
(ctk_widget_get_type ()))))))
;
575 g_assert(dialog->active_checkbox != NULL)do { if (dialog->active_checkbox != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 575, ((const
char*) (__func__)), "dialog->active_checkbox != NULL"); }
while (0)
;
576
577 dialog->dnd_checkbox = CTK_WIDGET(ctk_builder_get_object(builder, "do_not_disturb_check"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "do_not_disturb_check"))
), ((ctk_widget_get_type ()))))))
;
578 g_assert(dialog->dnd_checkbox != NULL)do { if (dialog->dnd_checkbox != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 578, ((const
char*) (__func__)), "dialog->dnd_checkbox != NULL"); } while
(0)
;
579
580 dialog->monitor_label = CTK_WIDGET(ctk_builder_get_object(builder, "monitor_label"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(builder, "monitor_label"))), ((ctk_widget_get_type
()))))))
;
581 g_assert(dialog->monitor_label != NULL)do { if (dialog->monitor_label != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "cafe-notification-properties.c", 581, ((const
char*) (__func__)), "dialog->monitor_label != NULL"); } while
(0)
;
582
583 g_object_unref(builder);
584
585 dialog->gsettings = g_settings_new (GSETTINGS_SCHEMA"org.cafe.NotificationDaemon");
586
587 g_signal_connect(dialog->dialog, "response", G_CALLBACK(notification_properties_dialog_response), dialog)g_signal_connect_data ((dialog->dialog), ("response"), (((
GCallback) (notification_properties_dialog_response))), (dialog
), ((void*)0), (GConnectFlags) 0)
;
588 g_signal_connect(dialog->dialog, "destroy", G_CALLBACK(notification_properties_dialog_destroyed), dialog)g_signal_connect_data ((dialog->dialog), ("destroy"), (((GCallback
) (notification_properties_dialog_destroyed))), (dialog), ((void
*)0), (GConnectFlags) 0)
;
589
590 g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_USE_ACTIVE_MONITOR, G_CALLBACK (notification_properties_checkbox_notify), dialog)g_signal_connect_data ((dialog->gsettings), ("changed::" "use-active-monitor"
), (((GCallback) (notification_properties_checkbox_notify))),
(dialog), ((void*)0), (GConnectFlags) 0)
;
591 g_signal_connect(dialog->active_checkbox, "toggled", G_CALLBACK(notification_properties_checkbox_toggled), dialog)g_signal_connect_data ((dialog->active_checkbox), ("toggled"
), (((GCallback) (notification_properties_checkbox_toggled)))
, (dialog), ((void*)0), (GConnectFlags) 0)
;
592
593 g_signal_connect(dialog->gsettings, "changed::" GSETTINGS_KEY_DO_NOT_DISTURB, G_CALLBACK (notification_properties_dnd_notify), dialog)g_signal_connect_data ((dialog->gsettings), ("changed::" "do-not-disturb"
), (((GCallback) (notification_properties_dnd_notify))), (dialog
), ((void*)0), (GConnectFlags) 0)
;
594 g_signal_connect(dialog->dnd_checkbox, "toggled", G_CALLBACK(notification_properties_dnd_toggled), dialog)g_signal_connect_data ((dialog->dnd_checkbox), ("toggled")
, (((GCallback) (notification_properties_dnd_toggled))), (dialog
), ((void*)0), (GConnectFlags) 0)
;
595
596 notification_properties_dialog_setup_themes(dialog);
597 notification_properties_dialog_setup_positions(dialog);
598 notification_properties_dialog_setup_monitors(dialog);
599
600 if (g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR"use-active-monitor"))
601 {
602 ctk_widget_set_sensitive(dialog->monitor_combo, FALSE(0));
603 ctk_widget_set_sensitive(dialog->monitor_label, FALSE(0));
604 }
605 else
606 {
607 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON (dialog->active_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->active_checkbox)), ((ctk_toggle_button_get_type
()))))))
, FALSE(0));
608 ctk_widget_set_sensitive(dialog->monitor_combo, TRUE(!(0)));
609 ctk_widget_set_sensitive(dialog->monitor_label, TRUE(!(0)));
610 }
611
612 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON (dialog->dnd_checkbox)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog->dnd_checkbox)), ((ctk_toggle_button_get_type (
)))))))
, g_settings_get_boolean(dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB"do-not-disturb"));
613
614 ctk_widget_show_all(dialog->dialog);
615
616 dialog->preview = NULL((void*)0);
617
618 return TRUE(!(0));
619}
620
621static void notification_properties_dialog_finalize(NotificationAppletDialog* dialog)
622{
623 if (dialog->dialog != NULL((void*)0))
624 {
625 ctk_widget_destroy(dialog->dialog);
626 dialog->dialog = NULL((void*)0);
627 }
628
629 if (dialog->preview)
630 {
631 notify_notification_close(dialog->preview, NULL((void*)0));
632 dialog->preview = NULL((void*)0);
633 }
634}
635
636int main(int argc, char** argv)
637{
638 NotificationAppletDialog dialog = {NULL((void*)0), }; /* <- ? */
639
640 bindtextdomain(GETTEXT_PACKAGE"cafe-notification-daemon", NOTIFICATION_LOCALEDIR"/usr/share/locale");
641 bind_textdomain_codeset(GETTEXT_PACKAGE"cafe-notification-daemon", "UTF-8");
642 textdomain(GETTEXT_PACKAGE"cafe-notification-daemon");
643
644 ctk_init(&argc, &argv);
645
646 notify_init("cafe-notification-properties");
647
648 if (!notification_properties_dialog_init(&dialog))
649 {
650 notification_properties_dialog_finalize(&dialog);
651 return 1;
652 }
653
654 ctk_main();
655
656 notification_properties_dialog_finalize(&dialog);
657
658 return 0;
659}