diff options
author | jstebbins <[email protected]> | 2015-03-25 21:32:07 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-03-25 21:32:07 +0000 |
commit | 9a096f1644decc529b00e5bbd288668cf6ed36b5 (patch) | |
tree | ff1c74aa5a3dcf98e1fff74998028e7c76ee7758 /gtk/src/x264handler.c | |
parent | 4ee00c554b11d543fb1ad1d27dcd0369e4a280b3 (diff) |
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
Diffstat (limited to 'gtk/src/x264handler.c')
-rw-r--r-- | gtk/src/x264handler.c | 40 |
1 files changed, 38 insertions, 2 deletions
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); +} |