19
19
#include < stdio.h>
20
20
#include < unistd.h>
21
21
#include < limits.h>
22
+ #include < errno.h>
22
23
23
24
#include < FL/Fl.H>
24
25
#include < FL/Fl_Check_Browser.H>
41
42
#include < edelib/Ede.h>
42
43
43
44
EDELIB_NS_USING_AS (Window, AppWindow)
44
- EDELIB_NS_USING_LIST(15 , (String,
45
+ EDELIB_NS_USING_LIST(17 , (String,
45
46
DesktopFile,
46
47
IconLoader,
47
48
list,
48
49
dir_list,
49
50
system_config_dirs,
50
51
user_config_dir,
51
52
str_ends,
53
+ str_tolower,
52
54
run_async,
53
55
ask,
56
+ alert,
54
57
file_test,
55
58
window_center_on_screen,
56
59
FILE_TEST_IS_REGULAR,
@@ -135,8 +138,8 @@ static void unique_by_basename(StringList& lst) {
135
138
}
136
139
137
140
static void entry_list_run_clear (DialogEntryList& l, bool run) {
138
- DialogEntryListIter dit = l.begin (), dit_end = l.end ();
139
- for (; dit != dit_end ; ++dit) {
141
+ DialogEntryListIter dit = l.begin (), dite = l.end ();
142
+ for (; dit != dite ; ++dit) {
140
143
if (run)
141
144
AUTOSTART_RUN ((*dit)->exec .c_str ());
142
145
delete *dit;
@@ -188,8 +191,8 @@ static void run_autostart_dialog(DialogEntryList& l) {
188
191
txt->align (FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_WRAP);
189
192
cbrowser = new Fl_Check_Browser (10 , 75 , 350 , 185 );
190
193
191
- DialogEntryListIter it = l.begin (), it_end = l.end ();
192
- for (; it != it_end ; ++it) {
194
+ DialogEntryListIter it = l.begin (), ite = l.end ();
195
+ for (; it != ite ; ++it) {
193
196
if ((*it)->comment .empty ())
194
197
cbrowser->add ((*it)->name .c_str ());
195
198
else {
@@ -222,13 +225,13 @@ static void perform_autostart(bool safe) {
222
225
adir += AUTOSTART_DIRNAME;
223
226
224
227
StringList dfiles, sysdirs, tmp;
225
- StringListIter it, it_end , tmp_it, tmp_it_end ;
228
+ StringListIter it, ite , tmp_it, tmp_ite ;
226
229
227
230
dir_list (adir.c_str (), dfiles, true );
228
231
229
232
system_config_dirs (sysdirs);
230
233
if (!sysdirs.empty ()) {
231
- for (it = sysdirs.begin (), it_end = sysdirs.end (); it != it_end ; ++it) {
234
+ for (it = sysdirs.begin (), ite = sysdirs.end (); it != ite ; ++it) {
232
235
*it += AUTOSTART_DIRNAME;
233
236
234
237
/*
@@ -237,22 +240,18 @@ static void perform_autostart(bool safe) {
237
240
* probably via merge() member
238
241
*/
239
242
dir_list ((*it).c_str (), tmp, true );
240
- for (tmp_it = tmp.begin (), tmp_it_end = tmp.end (); tmp_it != tmp_it_end ; ++tmp_it)
243
+ for (tmp_it = tmp.begin (), tmp_ite = tmp.end (); tmp_it != tmp_ite ; ++tmp_it)
241
244
dfiles.push_back (*tmp_it);
242
245
}
243
246
}
244
247
245
- if (dfiles.empty ())
246
- return ;
248
+ if (dfiles.empty ()) return ;
247
249
248
250
/*
249
- * Remove duplicates where first one seen have priority to be keept.
250
- * This way is required by spec.
251
+ * Remove duplicates where first one seen have priority to be keept. This way is required by spec.
251
252
*
252
- * Also handle this case (noted in spec):
253
- * if $XDG_CONFIG_HOME/autostart/foo.desktop and $XDG_CONFIG_DIRS/autostart/foo.desktop
254
- * exists, but $XDG_CONFIG_HOME/autostart/foo.desktop have 'Hidden = true',
255
- * $XDG_CONFIG_DIRS/autostart/foo.autostart is ignored too.
253
+ * Also handle this case (noted in spec): * if $XDG_CONFIG_HOME/autostart/foo.desktop and $XDG_CONFIG_DIRS/autostart/foo.desktop
254
+ * exists, but $XDG_CONFIG_HOME/autostart/foo.desktop have 'Hidden = true', * $XDG_CONFIG_DIRS/autostart/foo.autostart is ignored too.
256
255
*
257
256
* Later is implied via unique_by_basename().
258
257
*/
@@ -263,7 +262,7 @@ static void perform_autostart(bool safe) {
263
262
DesktopFile df;
264
263
DialogEntryList entry_list;
265
264
266
- for (it = dfiles.begin (), it_end = dfiles.end (); it != it_end ; ++it) {
265
+ for (it = dfiles.begin (), ite = dfiles.end (); it != ite ; ++it) {
267
266
if ((*it).empty ())
268
267
continue ;
269
268
@@ -276,12 +275,23 @@ static void perform_autostart(bool safe) {
276
275
E_WARNING (E_STRLOC " : Can't load '%s'. Skipping...\n " , name);
277
276
continue ;
278
277
}
278
+
279
+ /* obey to OnlyShowIn rule */
280
+ if (df.only_show_in (buf, sizeof (buf))) {
281
+ str_tolower ((unsigned char *)buf);
282
+ if (strstr (buf, " ede" ) == NULL )
283
+ continue ;
284
+ }
285
+
286
+ /* obey to NotShowIn rule */
287
+ if (df.not_show_in (buf, sizeof (buf))) {
288
+ str_tolower ((unsigned char *)buf);
289
+ if (strstr (buf, " ede" ) != NULL )
290
+ continue ;
291
+ }
279
292
280
293
/* files marked as hidden must be skipped */
281
- if (df.hidden ())
282
- continue ;
283
-
284
- if (!df.exec (buf, sizeof (buf)))
294
+ if (df.hidden () || !df.exec (buf, sizeof (buf)))
285
295
continue ;
286
296
287
297
DialogEntry* en = new DialogEntry;
@@ -321,8 +331,11 @@ static void perform_autostart_scripts(const char* dir) {
321
331
" Would you like to start them?" ), dir))
322
332
{
323
333
/* spec said how we must chdir to the root of the medium */
324
- chdir (dir);
325
- AUTOSTART_RUN (path);
334
+ errno = 0 ;
335
+ if (chdir (dir) == 0 )
336
+ AUTOSTART_RUN (path);
337
+ else
338
+ alert (_ (" Unable to change folder: %s" ), strerror (errno));
326
339
}
327
340
328
341
/* we only match the one file */
0 commit comments