X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=4a6f3cf169a57630372dfc9b39f1a87727341b56;hp=7d1ca042db190f04a2fa74c380a88431cd27349d;hb=0d6b320def9180cf907ceaed56b23a972a11b757;hpb=3f438031d610c7e15fd33876a879b97e290e05fb diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index 7d1ca042..4a6f3cf1 100644 --- a/driver/demo-Gtk.c +++ b/driver/demo-Gtk.c @@ -190,6 +190,7 @@ typedef struct { 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. */ @@ -645,7 +646,6 @@ run_hack (state *s, int list_elt, Bool report_errors_p) strcpy (buf, "Unknown error!"); warning_dialog (s->toplevel_widget, buf, False, 100); } - if (err) free (err); } else { @@ -845,7 +845,8 @@ doc_menu_cb (GtkMenuItem *menuitem, gpointer user_data) 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); } @@ -889,7 +890,8 @@ restart_menu_cb (GtkWidget *widget, gpointer user_data) 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); } @@ -1051,7 +1053,8 @@ manual_cb (GtkButton *button, gpointer user_data) cmd, name2, name2, name2, name2); strcat (cmd2, " ) &"); - system (cmd2); + if (system (cmd2) < 0) + fprintf (stderr, "%s: fork error\n", blurb()); free (cmd2); } else @@ -1080,9 +1083,11 @@ force_list_select_item (state *s, GtkWidget *list, int list_elt, Bool scroll_p) #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 */ @@ -3315,13 +3320,16 @@ initialize_sort_map (state *s) 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 @@ -3473,11 +3481,14 @@ clear_preview_window (state *s) 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) @@ -3718,7 +3729,8 @@ get_best_gl_visual (state *s) 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. */