From d76fdf9cb931d6d189938102a98a71030ea907ad Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 31 May 2012 19:07:16 +0200 Subject: allow transcript formatting without markup (like search-as-you type) * controlled via checkbox * if markup is disabled the entered text is only regular expressions * default text attributes are used according to some constants (in configure.ac, later they will be configurable via config file) * fixed return value of gtk_experiment_transcript_load_formats() * care about possible capture mismatches in regular expressions (capture braces are inserted automatically - the user is not allowed specify own captures) * display state of interactive format via icon (successful/error) --- src/default.ui | 100 +++++++++++++++++++++++++++++++++++++++--------- src/experiment-player.h | 4 +- src/format-selection.c | 39 +++++++++++++++++-- src/main.c | 2 + 4 files changed, 123 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/default.ui b/src/default.ui index ee9195e..d526dbd 100644 --- a/src/default.ui +++ b/src/default.ui @@ -13,7 +13,6 @@ True - vertical True @@ -265,7 +264,6 @@ audio-volume-medium True - vertical True @@ -356,41 +354,107 @@ audio-volume-medium - + True - True - - + - 2 - 3 + 1 + 2 GTK_FILL - + True - True - - + + + True + True + + gtk-apply + + + + 0 + + + + + True + + + False + 5 + 1 + + + + + Markup + True + True + False + True + + + + False + 2 + + - 1 - 2 2 3 GTK_FILL - + True - + + + True + True + + gtk-apply + + + + 0 + + + + + True + + + False + 5 + 1 + + + + + Markup + True + True + False + True + + + + False + 2 + + - 1 - 2 + 1 + 2 + 2 + 3 GTK_FILL diff --git a/src/experiment-player.h b/src/experiment-player.h index a7cda8a..018cabd 100644 --- a/src/experiment-player.h +++ b/src/experiment-player.h @@ -37,7 +37,9 @@ extern gchar *quickopen_directory; void format_selection_init(const gchar *dir); extern GtkWidget *transcript_wizard_combo, - *transcript_proband_combo; + *transcript_proband_combo, + *transcript_wizard_entry_check, + *transcript_proband_entry_check; #define BUILDER_INIT(BUILDER, VAR) do { \ VAR = GTK_WIDGET(gtk_builder_get_object(BUILDER, #VAR)); \ diff --git a/src/format-selection.c b/src/format-selection.c index 8a11ae1..2e14028 100644 --- a/src/format-selection.c +++ b/src/format-selection.c @@ -17,7 +17,9 @@ static void refresh_formats_store(GtkListStore *store); GtkWidget *transcript_wizard_combo, - *transcript_proband_combo; + *transcript_proband_combo, + *transcript_wizard_entry_check, + *transcript_proband_entry_check; static gchar *formats_directory; @@ -93,14 +95,45 @@ generic_transcript_combo_changed_cb(gpointer user_data, GtkComboBox *combo) #endif } + + void generic_transcript_entry_changed_cb(gpointer user_data, GtkEditable *editable) { GtkExperimentTranscript *trans = GTK_EXPERIMENT_TRANSCRIPT(user_data); const gchar *text = gtk_entry_get_text(GTK_ENTRY(editable)); - /** @todo enable/disable markup */ - gtk_experiment_transcript_set_interactive_format(trans, text, TRUE); + GtkToggleButton *toggle; + gboolean isMarkup; + + gboolean res; + + toggle = trans == GTK_EXPERIMENT_TRANSCRIPT(transcript_wizard_widget) + ? GTK_TOGGLE_BUTTON(transcript_wizard_entry_check) + : GTK_TOGGLE_BUTTON(transcript_proband_entry_check); + isMarkup = gtk_toggle_button_get_active(toggle); + + res = gtk_experiment_transcript_set_interactive_format(trans, text, + isMarkup); + + gtk_entry_set_icon_from_stock(GTK_ENTRY(editable), + GTK_ENTRY_ICON_PRIMARY, + res ? "gtk-dialog-error" : "gtk-apply"); + gtk_entry_set_icon_sensitive(GTK_ENTRY(editable), + GTK_ENTRY_ICON_PRIMARY, + text != NULL && *text); +} + +void +generic_transcript_entry_check_toggled_cb(gpointer user_data, + GtkToggleButton *widget __attribute__((unused))) +{ + gint position = 0; + + /* + * Hack to update the transcript's interactive format + */ + gtk_editable_insert_text(GTK_EDITABLE(user_data), "", 0, &position); } static void diff --git a/src/main.c b/src/main.c index 59bc828..00690ab 100644 --- a/src/main.c +++ b/src/main.c @@ -287,6 +287,8 @@ main(int argc, char *argv[]) BUILDER_INIT(builder, transcript_wizard_combo); BUILDER_INIT(builder, transcript_proband_combo); + BUILDER_INIT(builder, transcript_wizard_entry_check); + BUILDER_INIT(builder, transcript_proband_entry_check); BUILDER_INIT(builder, navigator_scrolledwindow); BUILDER_INIT(builder, navigator_widget); -- cgit v1.2.3