From 9a096f1644decc529b00e5bbd288668cf6ed36b5 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Wed, 25 Mar 2015 21:32:07 +0000 Subject: LinGui: work around yet another gtk+-3 bug GtkTextView gets confused if you try to set it's contents again while in a callback for a change to the TextView. So prevent such behavior by the app. Requires updating the x264Option TextView in the background (idle loop) rather than immediately. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7013 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/x264handler.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'gtk/src/x264handler.c') diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c index 46eb8c1cf..649a3a78f 100644 --- a/gtk/src/x264handler.c +++ b/gtk/src/x264handler.c @@ -150,7 +150,7 @@ x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) gchar *sopts; sopts = sanitize_x264opts(ud, options); - ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); + ghb_update_x264Option(ud, sopts); ghb_x264_parse_options(ud, sopts); GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); @@ -795,7 +795,7 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget) if (len > 0) result[len - 1] = 0; gchar *sopts; sopts = sanitize_x264opts(ud, result); - ghb_ui_update(ud, "x264Option", ghb_string_value(sopts)); + ghb_update_x264Option(ud, sopts); ghb_x264_parse_options(ud, sopts); g_free(sopts); g_free(result); @@ -1060,3 +1060,39 @@ ghb_x264_init(signal_user_data_t *ud) { ud->x264_priv = ghb_settings_new(); } + +gboolean +ghb_background_refresh_x264Option(signal_user_data_t *ud) +{ + const char *opt; + opt = ghb_settings_get_const_string(ud->settings, "x264Option"); + + GtkWidget *widget; + GtkTextBuffer *buffer; + GtkTextIter start, end; + gchar *str; + + widget = GHB_WIDGET(ud->builder, "x264Option"); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); + gtk_text_buffer_get_bounds(buffer, &start, &end); + str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); + + // If the value has changed, then update it + if (opt != NULL) + { + if (str == NULL || strcmp(str, opt)) + { + ud->dont_clear_presets = 1; + ghb_ui_update(ud, "x264Option", ghb_string_value(opt)); + ud->dont_clear_presets = 0; + } + } + free(str); + return FALSE; +} + +void ghb_update_x264Option(signal_user_data_t *ud, const char *opt) +{ + ghb_settings_set_string(ud->settings, "x264Option", opt); + g_idle_add((GSourceFunc)ghb_background_refresh_x264Option, ud); +} -- cgit v1.2.3