int *list_elt_to_hack_number; /* table for sorting the hack list */
int *hack_number_to_list_elt; /* the inverse table */
Bool *hacks_available_p; /* whether hacks are on $PATH */
+ int total_available; /* how many are on $PATH */
int list_count; /* how many items are in the list: this may be
less than p->screenhacks_count, if some are
suppressed. */
strcpy (buf, "Unknown error!");
warning_dialog (s->toplevel_widget, buf, False, 100);
}
- if (err) free (err);
}
else
{
p->load_url_command,
p->help_url, p->help_url, p->help_url, p->help_url);
strcat (help_command, " ) &");
- system (help_command);
+ if (system (help_command) < 0)
+ fprintf (stderr, "%s: fork error\n", blurb());
free (help_command);
}
flush_dialog_changes_and_save (s);
xscreensaver_command (GDK_DISPLAY(), XA_EXIT, 0, False, NULL);
sleep (1);
- system ("xscreensaver -nosplash &");
+ if (system ("xscreensaver -nosplash &") < 0)
+ fprintf (stderr, "%s: fork error\n", blurb());
await_xscreensaver (s);
}
cmd,
name2, name2, name2, name2);
strcat (cmd2, " ) &");
- system (cmd2);
+ if (system (cmd2) < 0)
+ fprintf (stderr, "%s: fork error\n", blurb());
free (cmd2);
}
else
#ifdef HAVE_GTK2
model = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
STFU g_assert (model);
- gtk_tree_model_iter_nth_child (model, &iter, NULL, list_elt);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
- gtk_tree_selection_select_iter (selection, &iter);
+ if (gtk_tree_model_iter_nth_child (model, &iter, NULL, list_elt))
+ {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
#else /* !HAVE_GTK2 */
gtk_list_select_item (GTK_LIST (list), list_elt);
#endif /* !HAVE_GTK2 */
calloc (sizeof(int), p->screenhacks_count + 1);
s->hacks_available_p = (Bool *)
calloc (sizeof(Bool), p->screenhacks_count + 1);
+ s->total_available = 0;
/* Check which hacks actually exist on $PATH
*/
for (i = 0; i < p->screenhacks_count; i++)
{
screenhack *hack = p->screenhacks[i];
- s->hacks_available_p[i] = on_path_p (hack->command);
+ int on = on_path_p (hack->command) ? 1 : 0;
+ s->hacks_available_p[i] = on;
+ s->total_available += on;
}
/* Initialize list->hack table to unsorted mapping, omitting nonexistent
Bool available_p = (hack_number >= 0
? s->hacks_available_p [hack_number]
: True);
+ Bool nothing_p = (s->total_available < 5);
+
#ifdef HAVE_GTK2
GtkWidget *notebook = name_to_widget (s, "preview_notebook");
gtk_notebook_set_page (GTK_NOTEBOOK (notebook),
(s->running_preview_error_p
- ? (available_p ? 1 : 2)
+ ? (available_p ? 1 :
+ nothing_p ? 3 : 2)
: 0));
#else /* !HAVE_GTK2 */
if (s->running_preview_error_p)
close (out); /* don't need this one */
*buf = 0;
- fgets (buf, sizeof(buf)-1, f);
+ if (!fgets (buf, sizeof(buf)-1, f))
+ *buf = 0;
fclose (f);
/* Wait for the child to die. */