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 | |
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')
-rw-r--r-- | gtk/src/settings.c | 8 | ||||
-rw-r--r-- | gtk/src/videohandler.c | 5 | ||||
-rw-r--r-- | gtk/src/x264handler.c | 40 | ||||
-rw-r--r-- | gtk/src/x264handler.h | 1 |
4 files changed, 49 insertions, 5 deletions
diff --git a/gtk/src/settings.c b/gtk/src/settings.c index 91d95e761..26a622a61 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -561,9 +561,15 @@ ghb_update_widget(GtkWidget *widget, const GhbValue *value) } else if (type == GTK_TYPE_TEXT_VIEW) { + static int text_view_busy = 0; GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(widget)); - gtk_text_buffer_set_text (buffer, str, -1); + if (!text_view_busy) + { + text_view_busy = 1; + gtk_text_buffer_set_text (buffer, str, -1); + text_view_busy = 0; + } } else if (type == GTK_TYPE_LABEL) { diff --git a/gtk/src/videohandler.c b/gtk/src/videohandler.c index 8a5e16591..94845442d 100644 --- a/gtk/src/videohandler.c +++ b/gtk/src/videohandler.c @@ -20,6 +20,7 @@ #include "presets.h" #include "preview.h" #include "hb-backend.h" +#include "x264handler.h" int ghb_get_video_encoder(GhbValue *settings) { @@ -165,9 +166,9 @@ ghb_video_setting_changed(GtkWidget *widget, signal_user_data_t *ud) new_opts = hb_x264_param_unparse( preset, tunes, opts, profile, level, w, h); if (new_opts) - ghb_ui_update(ud, "x264Option", ghb_string_value(new_opts)); + ghb_update_x264Option(ud, new_opts); else - ghb_ui_update(ud, "x264Option", ghb_string_value("")); + ghb_update_x264Option(ud, ""); GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); 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); +} diff --git a/gtk/src/x264handler.h b/gtk/src/x264handler.h index c510b425d..b827e568c 100644 --- a/gtk/src/x264handler.h +++ b/gtk/src/x264handler.h @@ -31,5 +31,6 @@ void ghb_x264_init(signal_user_data_t *ud); void ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options); gint ghb_lookup_badapt(const gchar *options); void ghb_show_hide_advanced_video( signal_user_data_t *ud ); +void ghb_update_x264Option(signal_user_data_t *ud, const char *opt); #endif // _X264HANDLER_H_ |