Commit 25e79aec authored by Enrico Lumetti's avatar Enrico Lumetti

Make ux more robust by disabling dangerous actions

e.g. removing annotations while drawing multiple ink annotations can
lead to crashes
parent 9b0d56d4
......@@ -73,6 +73,7 @@ typedef struct {
GtkWidget *darea;
GtkWidget *annot_view;
GtkWidget *timer_label;
GtkWidget *single_ink_path_check;
GtkWidget *remove_button;
GtkWidget *type_selector;
GtkWidget *main_box;
......@@ -389,12 +390,16 @@ pgd_annots_start_toggle_annot (GtkWidget *button, PgdAnnotsDemo *demo)
{
case MODE_NORMAL: {
gtk_button_set_label(GTK_BUTTON(button), "Done");
gtk_widget_hide(demo->timer_label);
gtk_widget_show(demo->single_ink_path_check);
pgd_annots_start_add_annot(button, demo);
}
break;
case MODE_ADD: {
gtk_button_set_label(GTK_BUTTON(button), "Add");
gtk_widget_show(demo->timer_label);
gtk_widget_hide(demo->single_ink_path_check);
pgd_annots_done(demo);
}
break;
......@@ -543,6 +548,17 @@ pgd_annot_view_set_annot_free_text (GtkWidget *table,
g_free (text);
}
static void
pgd_single_ink_annot_changed(GtkToggleButton *button, PgdAnnotsDemo *demo)
{
if (demo->mode != MODE_NORMAL) {
// don't change path saving mechanism while drawing
return;
}
demo->single_path_per_annot = gtk_toggle_button_get_active(button);
}
static void
pgd_annots_file_attachment_save_dialog_response (GtkFileChooser *file_chooser,
gint response,
......@@ -837,7 +853,10 @@ pgd_annots_selection_changed (GtkTreeSelection *treeselection,
pgd_annot_view_set_annot (demo, annot);
g_object_unref (annot);
// we don't want the remove button to be enabled while drawing
if (demo->mode == MODE_NORMAL) {
gtk_widget_set_sensitive (demo->remove_button, TRUE);
}
} else {
pgd_annot_view_set_annot (demo, NULL);
gtk_widget_set_sensitive (demo->remove_button, FALSE);
......@@ -1018,6 +1037,9 @@ pgd_annots_add_annot (PgdAnnotsDemo *demo)
g_assert_not_reached ();
}
gtk_widget_set_sensitive(demo->remove_button, FALSE);
gtk_widget_set_sensitive(demo->single_ink_path_check, FALSE);
demo->active_annot = annot;
poppler_annot_set_color (annot, &color);
......@@ -1047,7 +1069,13 @@ pgd_annots_done (PgdAnnotsDemo *demo)
demo->current_ink_path = NULL;
demo->ink_annot_paths = NULL;
gtk_widget_set_sensitive(demo->remove_button, TRUE);
gtk_widget_set_sensitive(demo->single_ink_path_check, TRUE);
gtk_widget_hide (demo->single_ink_path_check);
gtk_label_set_text (GTK_LABEL (demo->timer_label), NULL);
gtk_widget_show (demo->timer_label);
}
static void
......@@ -1437,6 +1465,13 @@ pgd_annots_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
gtk_widget_show (demo->timer_label);
demo->single_ink_path_check = gtk_check_button_new_with_label ("Use one path per ink annotation");
gtk_widget_set_halign(demo->single_ink_path_check, GTK_ALIGN_END);
g_signal_connect (demo->single_ink_path_check, "toggled",
G_CALLBACK (pgd_single_ink_annot_changed),
(gpointer) demo);
gtk_box_pack_start( GTK_BOX (vbox), demo->single_ink_path_check, FALSE, TRUE, 0);
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
demo->annot_view = pgd_annot_view_new ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment