1 // preferences.c
2 // LiVES (lives-exe)
3 // (c) G. Finch 2004 - 2019 <salsaman+lives@gmail.com>
4 // released under the GNU GPL 3 or later
5 // see file ../COPYING or www.gnu.org for licensing details
6 // functions dealing with getting/setting user preferences
7 // TODO - use atom type system for prefs
8 
9 #include <dlfcn.h>
10 
11 #include "main.h"
12 #include "paramwindow.h"
13 #include "callbacks.h"
14 #include "resample.h"
15 #include "plugins.h"
16 #include "rte_window.h"
17 #include "interface.h"
18 #include "startup.h"
19 #include "effects-weed.h"
20 
21 #ifdef ENABLE_OSC
22 #include "omc-learn.h"
23 #endif
24 
25 static LiVESWidget *saved_closebutton;
26 static LiVESWidget *saved_applybutton;
27 static LiVESWidget *saved_revertbutton;
28 static  boolean mt_needs_idlefunc;
29 
30 static int nmons;
31 
32 static uint32_t prefs_current_page;
33 
34 static void select_pref_list_row(uint32_t selected_idx, _prefsw *prefsw);
35 
36 #define ACTIVE(widget, signal) lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->widget), LIVES_WIDGET_ ##signal## \
37 							 _SIGNAL, LIVES_GUI_CALLBACK(apply_button_set_enabled), NULL)
38 
39 
40 /** @brief callback to set to make a togglebutton or check_menu_item directly control a boolean pref
41     widget is either a togge_button (sets temporary) or a check_menuitem (sets permanent)
42     pref must have a corresponding entry in pref_factory_bool()
43 
44     See also: on_boolean_toggled()
45 */
toggle_sets_pref(LiVESWidget * widget,livespointer prefidx)46 void toggle_sets_pref(LiVESWidget *widget, livespointer prefidx) {
47   if (LIVES_IS_TOGGLE_BUTTON(widget))
48     pref_factory_bool((const char *)prefidx,
49                       lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(widget)), FALSE);
50   else if (LIVES_IS_CHECK_MENU_ITEM(widget))
51     pref_factory_bool((const char *)prefidx,
52                       lives_check_menu_item_get_active(LIVES_CHECK_MENU_ITEM(widget)), TRUE);
53 }
54 
55 
56 #ifdef ENABLE_OSC
on_osc_enable_toggled(LiVESToggleButton * t1,livespointer t2)57 static void on_osc_enable_toggled(LiVESToggleButton *t1, livespointer t2) {
58   if (prefs->osc_udp_started) return;
59   lives_widget_set_sensitive(prefsw->spinbutton_osc_udp, lives_toggle_button_get_active(t1) ||
60                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(t2)));
61 }
62 #endif
63 
64 
get_pref_inner(const char * filename,const char * key,char * val,int maxlen,LiVESList * cache)65 static LiVESResponseType get_pref_inner(const char *filename, const char *key, char *val, int maxlen,
66                                         LiVESList *cache) {
67   char *com;
68   memset(val, 0, maxlen);
69   if (!filename) {
70     if (cache) {
71       char *prefval = get_val_from_cached_list(key, maxlen, cache);
72       if (prefval) {
73         lives_snprintf(val, maxlen, "%s", prefval);
74         lives_free(prefval);
75         return LIVES_RESPONSE_YES;
76       }
77       return LIVES_RESPONSE_NO;
78     }
79     com = lives_strdup_printf("%s get_pref \"%s\" -", prefs->backend_sync, key);
80   } else {
81     com = lives_strdup_printf("%s get_clip_value \"%s\" - - \"%s\"", prefs->backend_sync, key,
82                               filename);
83   }
84 
85   lives_popen(com, TRUE, val, maxlen);
86 
87   lives_free(com);
88   return LIVES_RESPONSE_NONE;
89 }
90 
91 
get_string_pref(const char * key,char * val,int maxlen)92 LIVES_GLOBAL_INLINE LiVESResponseType get_string_pref(const char *key, char *val, int maxlen) {
93   /// get from prefs
94   return get_pref_inner(NULL, key, val, maxlen, mainw->prefs_cache);
95 }
96 
97 
get_string_prefd(const char * key,char * val,int maxlen,const char * def)98 LIVES_GLOBAL_INLINE LiVESResponseType get_string_prefd(const char *key, char *val, int maxlen, const char *def) {
99   /// get from prefs
100   int ret = get_pref_inner(NULL, key, val, maxlen, mainw->prefs_cache);
101   if (ret == LIVES_RESPONSE_NO) lives_snprintf(val, maxlen, "%s", def);
102   return ret;
103 }
104 
105 
get_pref_from_file(const char * filename,const char * key,char * val,int maxlen)106 LIVES_GLOBAL_INLINE LiVESResponseType get_pref_from_file(const char *filename, const char *key, char *val, int maxlen) {
107   /// get from non-prefs
108   return get_pref_inner(filename, key, val, maxlen, mainw->gen_cache);
109 }
110 
111 
get_utf8_pref(const char * key,char * val,int maxlen)112 LiVESResponseType get_utf8_pref(const char *key, char *val, int maxlen) {
113   // get a pref in locale encoding, then convert it to utf8
114   char *tmp;
115   int retval = get_string_pref(key, val, maxlen);
116   tmp = lives_filename_to_utf8(val, -1, NULL, NULL, NULL);
117   lives_snprintf(val, maxlen, "%s", tmp);
118   lives_free(tmp);
119   return retval;
120 }
121 
122 
get_list_pref(const char * key)123 LiVESList *get_list_pref(const char *key) {
124   // get a list of values from a preference
125   char **array;
126   char buf[65536];
127   int nvals, i;
128 
129   LiVESList *retlist = NULL;
130 
131   if (get_string_pref(key, buf, 65535) == LIVES_RESPONSE_NO) return NULL;
132   if (!(*buf)) return NULL;
133 
134   nvals = get_token_count(buf, '\n');
135   array = lives_strsplit(buf, "\n", nvals);
136   for (i = 0; i < nvals; i++) {
137     retlist = lives_list_append(retlist, lives_strdup(array[i]));
138   }
139 
140   lives_strfreev(array);
141 
142   return retlist;
143 }
144 
145 
get_boolean_pref(const char * key)146 LIVES_GLOBAL_INLINE boolean get_boolean_pref(const char *key) {
147   char buffer[16];
148   get_string_pref(key, buffer, 16);
149   if (!strcmp(buffer, "true")) return TRUE;
150   return FALSE;
151 }
152 
153 
get_boolean_prefd(const char * key,boolean defval)154 LIVES_GLOBAL_INLINE boolean get_boolean_prefd(const char *key, boolean defval) {
155   char buffer[16];
156   get_string_pref(key, buffer, 16);
157   if (!(*buffer)) return defval;
158   if (!strcmp(buffer, "true")) return TRUE;
159   return FALSE;
160 }
161 
162 
get_int_pref(const char * key)163 LIVES_GLOBAL_INLINE int get_int_pref(const char *key) {
164   char buffer[64];
165   get_string_pref(key, buffer, 64);
166   if (!(*buffer)) return 0;
167   return atoi(buffer);
168 }
169 
170 
get_int_prefd(const char * key,int defval)171 LIVES_GLOBAL_INLINE int get_int_prefd(const char *key, int defval) {
172   char buffer[64];
173   get_string_pref(key, buffer, 64);
174   if (!(*buffer)) return defval;
175   return atoi(buffer);
176 }
177 
178 
get_int64_prefd(const char * key,int64_t defval)179 LIVES_GLOBAL_INLINE int64_t get_int64_prefd(const char *key, int64_t defval) {
180   char buffer[64];
181   get_string_pref(key, buffer, 64);
182   if (!(*buffer)) return defval;
183   return atol(buffer);
184 }
185 
186 
get_double_pref(const char * key)187 LIVES_GLOBAL_INLINE double get_double_pref(const char *key) {
188   char buffer[64];
189   get_string_pref(key, buffer, 64);
190   if (!(*buffer)) return 0.;
191   return strtod(buffer, NULL);
192 }
193 
194 
get_double_prefd(const char * key,double defval)195 LIVES_GLOBAL_INLINE double get_double_prefd(const char *key, double defval) {
196   char buffer[64];
197   get_string_pref(key, buffer, 64);
198   if (!(*buffer)) return defval;
199   return strtod(buffer, NULL);
200 }
201 
202 
has_pref(const char * key)203 LIVES_GLOBAL_INLINE boolean has_pref(const char *key) {
204   char buffer[64];
205   get_string_pref(key, buffer, 64);
206   if (!(*buffer)) return FALSE;
207   return TRUE;
208 }
209 
210 
get_colour_pref(const char * key,lives_colRGBA64_t * lcol)211 boolean get_colour_pref(const char *key, lives_colRGBA64_t *lcol) {
212   /// this is for leading colours from prefs; for loading from themes
213   // use get_theme_colour_pref
214   char buffer[64];
215   char **array;
216   int ntoks;
217 
218   if (get_string_pref(key, buffer, 64) == LIVES_RESPONSE_NO) return FALSE;
219   if (!(*buffer)) return FALSE;
220   if ((ntoks = get_token_count(buffer, ' ')) < 3) return FALSE;
221 
222   array = lives_strsplit(buffer, " ", 4);
223   lcol->red = atoi(array[0]);
224   lcol->green = atoi(array[1]);
225   lcol->blue = atoi(array[2]);
226   if (ntoks == 4) lcol->alpha = atoi(array[3]);
227   else lcol->alpha = 65535;
228   lives_strfreev(array);
229 
230   return TRUE;
231 }
232 
233 
get_theme_colour_pref(const char * key,lives_colRGBA64_t * lcol)234 boolean get_theme_colour_pref(const char *key, lives_colRGBA64_t *lcol) {
235   /// load from mainw->gen_cache
236   char *tmp;
237   char **array;
238   int ntoks;
239 
240   tmp = get_val_from_cached_list(key, 64, mainw->gen_cache);
241   if (!tmp) return FALSE;
242 
243   if ((ntoks = get_token_count(tmp, ' ')) < 3) {
244     lives_free(tmp);
245     return FALSE;
246   }
247   array = lives_strsplit(tmp, " ", 4);
248   lcol->red = atoi(array[0]);
249   lcol->green = atoi(array[1]);
250   lcol->blue = atoi(array[2]);
251   if (ntoks == 4) lcol->alpha = atoi(array[3]);
252   else lcol->alpha = 65535;
253   lives_strfreev(array);
254   lives_free(tmp);
255   return TRUE;
256 }
257 
258 
run_prefs_command(const char * com)259 static int run_prefs_command(const char *com) {
260   int ret = 0;
261   do {
262     ret = lives_system(com, TRUE) >> 8;
263     if (mainw && mainw->is_ready) {
264       if (ret == 4) {
265         // error writing to temp config file
266         char *newrcfile = ensure_extension(prefs->configfile, LIVES_FILE_EXT_NEW);
267         ret = do_write_failed_error_s_with_retry(newrcfile, NULL);
268         lives_free(newrcfile);
269       } else if (ret == 3) {
270         // error writing to config file
271         ret = do_write_failed_error_s_with_retry(prefs->configfile, NULL);
272       } else if (ret != 0) {
273         // error reading from config file
274         ret = do_read_failed_error_s_with_retry(prefs->configfile, NULL);
275       }
276     } else ret = 0;
277   } while (ret == LIVES_RESPONSE_RETRY);
278   return ret;
279 }
280 
281 
delete_pref(const char * key)282 int delete_pref(const char *key) {
283   char *com = lives_strdup_printf("%s delete_pref \"%s\"", prefs->backend_sync, key);
284   int ret = run_prefs_command(com);
285   lives_free(com);
286   return ret;
287 }
288 
289 
set_string_pref(const char * key,const char * value)290 int set_string_pref(const char *key, const char *value) {
291   char *com = lives_strdup_printf("%s set_pref \"%s\" \"%s\"", prefs->backend_sync, key, value);
292   int ret = run_prefs_command(com);
293   lives_free(com);
294   return ret;
295 }
296 
297 
set_string_pref_priority(const char * key,const char * value)298 int set_string_pref_priority(const char *key, const char *value) {
299   char *com = lives_strdup_printf("%s set_pref_priority \"%s\" \"%s\"", prefs->backend_sync, key, value);
300   int ret = run_prefs_command(com);
301   lives_free(com);
302   return ret;
303 }
304 
305 
set_utf8_pref(const char * key,const char * value)306 int set_utf8_pref(const char *key, const char *value) {
307   // convert to locale encoding
308   char *tmp = U82F(value);
309   char *com = lives_strdup_printf("%s set_pref \"%s\" \"%s\"", prefs->backend_sync, key, tmp);
310   int ret = run_prefs_command(com);
311   lives_free(com);
312   lives_free(tmp);
313   return ret;
314 }
315 
316 
set_theme_pref(const char * themefile,const char * key,const char * value)317 void set_theme_pref(const char *themefile, const char *key, const char *value) {
318   char *com = lives_strdup_printf("%s set_clip_value \"%s\" \"%s\" \"%s\"", prefs->backend_sync, themefile, key, value);
319   int ret = 0;
320   do {
321     if (lives_system(com, TRUE)) {
322       ret = do_write_failed_error_s_with_retry(themefile, NULL);
323     }
324   } while (ret == LIVES_RESPONSE_RETRY);
325   lives_free(com);
326 }
327 
328 
set_int_pref(const char * key,int value)329 int set_int_pref(const char *key, int value) {
330   char *com = lives_strdup_printf("%s set_pref \"%s\" %d", prefs->backend_sync, key, value);
331   int ret = run_prefs_command(com);
332   lives_free(com);
333   return ret;
334 }
335 
336 
set_int64_pref(const char * key,int64_t value)337 int set_int64_pref(const char *key, int64_t value) {
338   // not used
339   char *com = lives_strdup_printf("%s set_pref \"%s\" %"PRId64, prefs->backend_sync, key, value);
340   int ret = run_prefs_command(com);
341   lives_free(com);
342   return ret;
343 }
344 
345 
set_double_pref(const char * key,double value)346 int set_double_pref(const char *key, double value) {
347   char *com = lives_strdup_printf("%s set_pref \"%s\" %.3f", prefs->backend_sync, key, value);
348   int ret = run_prefs_command(com);
349   lives_free(com);
350   return ret;
351 }
352 
353 
set_boolean_pref(const char * key,boolean value)354 int set_boolean_pref(const char *key, boolean value) {
355   char *com;
356   int ret;
357   if (value) {
358     com = lives_strdup_printf("%s set_pref \"%s\" true", prefs->backend_sync, key);
359   } else {
360     com = lives_strdup_printf("%s set_pref \"%s\" false", prefs->backend_sync, key);
361   }
362   ret = run_prefs_command(com);
363   lives_free(com);
364   return ret;
365 }
366 
367 
set_list_pref(const char * key,LiVESList * values)368 int set_list_pref(const char *key, LiVESList *values) {
369   // set pref from a list of values
370   LiVESList *xlist = values;
371   char *string = NULL, *tmp;
372   int ret;
373 
374   while (xlist) {
375     if (string == NULL) string = lives_strdup((char *)xlist->data);
376     else {
377       tmp = lives_strdup_printf("%s\n%s", string, (char *)xlist->data);
378       lives_free(string);
379       string = tmp;
380     }
381     xlist = xlist->next;
382   }
383 
384   if (string == NULL) string = lives_strdup("");
385 
386   ret = set_string_pref(key, string);
387 
388   lives_free(string);
389   return ret;
390 }
391 
392 
set_theme_colour_pref(const char * themefile,const char * key,lives_colRGBA64_t * lcol)393 void set_theme_colour_pref(const char *themefile, const char *key, lives_colRGBA64_t *lcol) {
394   char *myval = lives_strdup_printf("%d %d %d", lcol->red, lcol->green, lcol->blue);
395   char *com = lives_strdup_printf("%s set_clip_value \"%s\" \"%s\" \"%s\"", prefs->backend_sync, themefile, key, myval);
396   lives_system(com, FALSE);
397   lives_free(com);
398   lives_free(myval);
399 }
400 
401 
set_colour_pref(const char * key,lives_colRGBA64_t * lcol)402 int set_colour_pref(const char *key, lives_colRGBA64_t *lcol) {
403   char *myval = lives_strdup_printf("%d %d %d %d", lcol->red, lcol->green, lcol->blue, lcol->alpha);
404   char *com = lives_strdup_printf("%s set_pref \"%s\" \"%s\"", prefs->backend_sync, key, myval);
405   int ret = run_prefs_command(com);
406   lives_free(com);
407   lives_free(myval);
408   return ret;
409 }
410 
411 
set_palette_prefs(boolean save)412 void set_palette_prefs(boolean save) {
413   lives_colRGBA64_t lcol;
414 
415   lcol.red = palette->style;
416   lcol.green = lcol.blue = lcol.alpha = 0;
417 
418   if (save) {
419     if (set_colour_pref(THEME_DETAIL_STYLE, &lcol)) return;
420 
421     if (set_string_pref(THEME_DETAIL_SEPWIN_IMAGE, mainw->sepimg_path)) return;
422     if (set_string_pref(THEME_DETAIL_FRAMEBLANK_IMAGE, mainw->frameblank_path)) return;
423   }
424 
425   widget_color_to_lives_rgba(&lcol, &palette->normal_fore);
426   if (save)
427     if (set_colour_pref(THEME_DETAIL_NORMAL_FORE, &lcol)) return;
428 
429   widget_color_to_lives_rgba(&lcol, &palette->normal_back);
430   if (save)
431     if (set_colour_pref(THEME_DETAIL_NORMAL_BACK, &lcol)) return;
432 
433   widget_color_to_lives_rgba(&lcol, &palette->menu_and_bars_fore);
434   if (save)
435     if (set_colour_pref(THEME_DETAIL_ALT_FORE, &lcol)) return;
436 
437   widget_color_to_lives_rgba(&lcol, &palette->menu_and_bars);
438   if (save)
439     if (set_colour_pref(THEME_DETAIL_ALT_BACK, &lcol)) return;
440 
441   widget_color_to_lives_rgba(&lcol, &palette->info_text);
442   if (save)
443     if (set_colour_pref(THEME_DETAIL_INFO_TEXT, &lcol)) return;
444 
445   widget_color_to_lives_rgba(&lcol, &palette->info_base);
446   if (save)
447     if (set_colour_pref(THEME_DETAIL_INFO_BASE, &lcol)) return;
448 
449   widget_color_to_lives_rgba(&lcol, &palette->mt_timecode_fg);
450   if (save)
451     if (set_colour_pref(THEME_DETAIL_MT_TCFG, &lcol)) return;
452 
453   widget_color_to_lives_rgba(&lcol, &palette->mt_timecode_bg);
454   if (save)
455     if (set_colour_pref(THEME_DETAIL_MT_TCBG, &lcol)) return;
456 
457   if (save) {
458     if (set_colour_pref(THEME_DETAIL_AUDCOL, &palette->audcol)) return;
459     if (set_colour_pref(THEME_DETAIL_VIDCOL, &palette->vidcol)) return;
460     if (set_colour_pref(THEME_DETAIL_FXCOL, &palette->fxcol)) return;
461 
462     if (set_colour_pref(THEME_DETAIL_MT_TLREG, &palette->mt_timeline_reg)) return;
463     if (set_colour_pref(THEME_DETAIL_MT_MARK, &palette->mt_mark)) return;
464     if (set_colour_pref(THEME_DETAIL_MT_EVBOX, &palette->mt_evbox)) return;
465 
466     if (set_colour_pref(THEME_DETAIL_FRAME_SURROUND, &palette->frame_surround)) return;
467 
468     if (set_colour_pref(THEME_DETAIL_CE_SEL, &palette->ce_sel)) return;
469     if (set_colour_pref(THEME_DETAIL_CE_UNSEL, &palette->ce_unsel)) return;
470 
471     if (set_string_pref(THEME_DETAIL_SEPWIN_IMAGE, mainw->sepimg_path)) return;
472     if (set_string_pref(THEME_DETAIL_FRAMEBLANK_IMAGE, mainw->frameblank_path)) return;
473   }
474 }
475 
set_vpp(boolean set_in_prefs)476 void set_vpp(boolean set_in_prefs) {
477   // Video Playback Plugin
478 
479   if (*future_prefs->vpp_name) {
480     if (!lives_utf8_strcasecmp(future_prefs->vpp_name, mainw->string_constants[LIVES_STRING_CONSTANT_NONE])) {
481       if (mainw->vpp) {
482         if (mainw->ext_playback) vid_playback_plugin_exit();
483         close_vid_playback_plugin(mainw->vpp);
484         mainw->vpp = NULL;
485         if (set_in_prefs) set_string_pref(PREF_VID_PLAYBACK_PLUGIN, "none");
486       }
487     } else {
488       _vid_playback_plugin *vpp;
489       if ((vpp = open_vid_playback_plugin(future_prefs->vpp_name, TRUE))) {
490         mainw->vpp = vpp;
491         if (set_in_prefs) {
492           set_string_pref(PREF_VID_PLAYBACK_PLUGIN, mainw->vpp->name);
493           if (!mainw->ext_playback)
494             do_error_dialog(_("\n\nVideo playback plugins are only activated in\nfull screen, separate window (fs) mode\n"));
495         }
496       }
497     }
498     if (set_in_prefs) mainw->write_vpp_file = TRUE;
499   }
500 
501   if (future_prefs->vpp_argv && mainw->vpp) {
502     mainw->vpp->fwidth = future_prefs->vpp_fwidth;
503     mainw->vpp->fheight = future_prefs->vpp_fheight;
504     mainw->vpp->palette = future_prefs->vpp_palette;
505     mainw->vpp->fixed_fpsd = future_prefs->vpp_fixed_fpsd;
506     mainw->vpp->fixed_fps_numer = future_prefs->vpp_fixed_fps_numer;
507     mainw->vpp->fixed_fps_denom = future_prefs->vpp_fixed_fps_denom;
508     if (mainw->vpp->fixed_fpsd > 0.) {
509       if (mainw->fixed_fpsd != -1. || !((*mainw->vpp->set_fps)(mainw->vpp->fixed_fpsd))) {
510         do_vpp_fps_error();
511         mainw->vpp->fixed_fpsd = -1.;
512         mainw->vpp->fixed_fps_numer = 0;
513       }
514     }
515     if (!(*mainw->vpp->set_palette)(mainw->vpp->palette)) {
516       do_vpp_palette_error();
517     }
518     mainw->vpp->YUV_clamping = future_prefs->vpp_YUV_clamping;
519 
520     if (mainw->vpp->set_yuv_palette_clamping)(*mainw->vpp->set_yuv_palette_clamping)(mainw->vpp->YUV_clamping);
521 
522     mainw->vpp->extra_argc = future_prefs->vpp_argc;
523     mainw->vpp->extra_argv = future_prefs->vpp_argv;
524     if (set_in_prefs) mainw->write_vpp_file = TRUE;
525   }
526 
527   memset(future_prefs->vpp_name, 0, 64);
528   future_prefs->vpp_argv = NULL;
529 }
530 
531 
set_workdir_label_text(LiVESLabel * label,const char * dir)532 static void set_workdir_label_text(LiVESLabel *label, const char *dir) {
533   char *free_ds;
534   char *tmp, *txt;
535 
536   if (!is_writeable_dir(dir)) {
537     tmp = (_("(Free space = UNKNOWN)"));
538   } else {
539     free_ds = lives_format_storage_space_string(get_ds_free(dir));
540     tmp = lives_strdup_printf(_("(Free space = %s)"), free_ds);
541     lives_free(free_ds);
542   }
543 
544   txt = lives_strdup_printf(_("The work directory is LiVES working directory where opened clips "
545                               "and sets are stored.\n"
546                               "It should be in a partition with plenty of free disk space.\n\n%s"),
547                             tmp);
548   lives_free(tmp);
549   lives_layout_label_set_text(label, txt);
550   lives_free(txt);
551 }
552 
553 
pref_factory_string(const char * prefidx,const char * newval,boolean permanent)554 boolean pref_factory_string(const char *prefidx, const char *newval, boolean permanent) {
555   if (prefsw) prefsw->ignore_apply = TRUE;
556 
557   if (!lives_strcmp(prefidx, PREF_AUDIO_PLAYER)) {
558     const char *audio_player = newval;
559 
560     if (!(lives_strcmp(audio_player, AUDIO_PLAYER_NONE)) && prefs->audio_player != AUD_PLAYER_NONE) {
561       // switch to none
562       switch_aud_to_none(permanent);
563 #if 0
564       if (mainw->ping_pong && prefs->audio_opts & AUDIO_OPTS_FOLLOW_FPS) mainw->nullaudio_loop = AUDIO_LOOP_PINGPONG;
565       else mainw->nullaudio_loop = AUDIO_LOOP_FORWARD;
566 #endif
567       update_all_host_info(); // let fx plugins know about the change
568       goto success1;
569     } else if (!(lives_strcmp(audio_player, AUDIO_PLAYER_SOX)) && prefs->audio_player != AUD_PLAYER_SOX) {
570       // switch to sox
571       if (switch_aud_to_sox(permanent)) goto success1;
572       // revert text
573       if (prefsw) {
574         lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->orig_audp_name);
575         lives_widget_process_updates(prefsw->prefs_dialog);
576       }
577       goto fail1;
578     }
579 
580 #ifdef ENABLE_JACK
581     if (!(lives_strcmp(audio_player, AUDIO_PLAYER_JACK)) && prefs->audio_player != AUD_PLAYER_JACK) {
582       // switch to jack
583       if (!capable->has_jackd) {
584         do_error_dialogf(_("\nUnable to switch audio players to %s\n%s must be installed first.\nSee %s\n"),
585                          AUDIO_PLAYER_JACK,
586                          EXEC_JACKD,
587                          JACK_URL);
588         goto fail1;
589       } else {
590         if (prefs->audio_player == AUD_PLAYER_JACK && lives_strcmp(audio_player, AUDIO_PLAYER_JACK)) {
591           do_error_dialogf(_("\nSwitching audio players requires restart (%s must not be running)\n"), EXEC_JACKD);
592           // revert text
593           if (prefsw) {
594             lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->orig_audp_name);
595             lives_widget_process_updates(prefsw->prefs_dialog);
596           }
597           goto fail1;
598         }
599       }
600       if (!switch_aud_to_jack(permanent)) {
601         // failed
602         do_jack_noopen_warn();
603         // revert text
604         if (prefsw) {
605           lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->orig_audp_name);
606           lives_widget_process_updates(prefsw->prefs_dialog);
607         }
608         goto fail1;
609       } else {
610         // success
611         if (mainw->loop_cont) {
612           if (mainw->ping_pong && prefs->audio_opts & AUDIO_OPTS_FOLLOW_FPS) mainw->jackd->loop = AUDIO_LOOP_PINGPONG;
613           else mainw->jackd->loop = AUDIO_LOOP_FORWARD;
614         }
615         update_all_host_info(); // let fx plugins know about the change
616         goto success1;
617       }
618       goto fail1;
619     }
620 #endif
621 
622 #ifdef HAVE_PULSE_AUDIO
623     if ((!lives_strcmp(audio_player, AUDIO_PLAYER_PULSE) || !lives_strcmp(audio_player, AUDIO_PLAYER_PULSE_AUDIO)) &&
624         prefs->audio_player != AUD_PLAYER_PULSE) {
625       // switch to pulseaudio
626       if (!capable->has_pulse_audio) {
627         do_error_dialogf(_("\nUnable to switch audio players to %s\n%s must be installed first.\nSee %s\n"),
628                          AUDIO_PLAYER_PULSE_AUDIO,
629                          AUDIO_PLAYER_PULSE_AUDIO,
630                          PULSE_AUDIO_URL);
631         // revert text
632         if (prefsw) {
633           lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->orig_audp_name);
634           lives_widget_process_updates(prefsw->prefs_dialog);
635         }
636         goto fail1;
637       } else {
638         if (!switch_aud_to_pulse(permanent)) {
639           // revert text
640           if (prefsw) {
641             lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->orig_audp_name);
642             lives_widget_process_updates(prefsw->prefs_dialog);
643           }
644           goto fail1;
645         } else {
646           // success
647           if (mainw->loop_cont) {
648             if (mainw->ping_pong && prefs->audio_opts & AUDIO_OPTS_FOLLOW_FPS) mainw->pulsed->loop = AUDIO_LOOP_PINGPONG;
649             else mainw->pulsed->loop = AUDIO_LOOP_FORWARD;
650           }
651           update_all_host_info(); // let fx plugins know about the change
652           goto success1;
653         }
654       }
655     }
656 #endif
657     goto fail1;
658   }
659 
660 #ifdef HAVE_PULSE_AUDIO
661   if (!lives_strcmp(prefidx, PREF_PASTARTOPTS)) {
662     if (lives_strcmp(newval, prefs->pa_start_opts)) {
663       lives_snprintf(prefs->pa_start_opts, 255, "%s", newval);
664       if (permanent) set_string_pref(PREF_PASTARTOPTS, newval);
665       goto success1;
666     }
667     goto fail1;
668   }
669 #endif
670 
671   if (!lives_strcmp(prefidx, PREF_OMC_JS_FNAME)) {
672     if (lives_strcmp(newval, prefs->omc_js_fname)) {
673       lives_snprintf(prefs->omc_js_fname, PATH_MAX, "%s", newval);
674       if (permanent) set_utf8_pref(PREF_OMC_JS_FNAME, newval);
675       goto success1;
676     }
677     goto fail1;
678   }
679 
680   if (!lives_strcmp(prefidx, PREF_OMC_MIDI_FNAME)) {
681     if (lives_strcmp(newval, prefs->omc_midi_fname)) {
682       lives_snprintf(prefs->omc_midi_fname, PATH_MAX, "%s", newval);
683       if (permanent) set_utf8_pref(PREF_OMC_MIDI_FNAME, newval);
684       goto success1;
685     }
686     goto fail1;
687   }
688 
689   if (!lives_strcmp(prefidx, PREF_MIDI_RCV_CHANNEL)) {
690     if (strlen(newval) > 2) {
691       if (prefs->midi_rcv_channel != -1) {
692         prefs->midi_rcv_channel = -1;
693         if (permanent) set_int_pref(PREF_MIDI_RCV_CHANNEL, prefs->midi_rcv_channel);
694         goto success1;
695       }
696     } else if (prefs->midi_rcv_channel != atoi(newval)) {
697       prefs->midi_rcv_channel = atoi(newval);
698       if (permanent) set_int_pref(PREF_MIDI_RCV_CHANNEL, prefs->midi_rcv_channel);
699       goto success1;
700     }
701     goto fail1;
702   }
703 
704 fail1:
705   if (prefsw) prefsw->ignore_apply = FALSE;
706   return FALSE;
707 
708 success1:
709   if (prefsw) {
710     lives_widget_process_updates(prefsw->prefs_dialog);
711     prefsw->ignore_apply = FALSE;
712   }
713   return TRUE;
714 }
715 
716 
pref_factory_bool(const char * prefidx,boolean newval,boolean permanent)717 boolean pref_factory_bool(const char *prefidx, boolean newval, boolean permanent) {
718   // this is called from lbindings.c which in turn is called from liblives.cpp
719 
720   // can also be called from other places
721 
722   if (prefsw) prefsw->ignore_apply = TRUE;
723 
724   if (!lives_strcmp(prefidx, PREF_RRCRASH)) {
725     if (prefs->rr_crash == newval) goto fail2;
726     prefs->rr_crash = newval;
727     goto success2;
728   }
729 
730   if (!lives_strcmp(prefidx, PREF_RRSUPER)) {
731     if (prefs->rr_super == newval) goto fail2;
732     prefs->rr_super = newval;
733     goto success2;
734   }
735 
736   if (!lives_strcmp(prefidx, PREF_RRPRESMOOTH)) {
737     if (prefs->rr_pre_smooth == newval) goto fail2;
738     prefs->rr_pre_smooth = newval;
739     goto success2;
740   }
741 
742   if (!lives_strcmp(prefidx, PREF_RRQSMOOTH)) {
743     if (prefs->rr_qsmooth == newval) goto fail2;
744     prefs->rr_qsmooth = newval;
745     goto success2;
746   }
747 
748   if (!lives_strcmp(prefidx, PREF_RRAMICRO)) {
749     if (prefs->rr_amicro == newval) goto fail2;
750     prefs->rr_amicro = newval;
751     goto success2;
752   }
753 
754   if (!lives_strcmp(prefidx, PREF_RRRAMICRO)) {
755     if (prefs->rr_ramicro == newval) goto fail2;
756     prefs->rr_ramicro = newval;
757     goto success2;
758   }
759 
760   if (!lives_strcmp(prefidx, PREF_SHOW_QUOTA)) {
761     if (prefs->show_disk_quota == newval) goto fail2;
762     prefs->show_disk_quota = newval;
763     /// allow dialog checkbutton to set permanent pref
764     permanent = TRUE;
765     goto success2;
766   }
767 
768   if (!lives_strcmp(prefidx, PREF_MSG_START)) {
769     if (prefs->show_msgs_on_startup == newval) goto fail2;
770     prefs->show_msgs_on_startup = newval;
771     /// allow dialog checkbutton to set permanent pref
772     permanent = TRUE;
773     goto success2;
774   }
775 
776   if (!lives_strcmp(prefidx, PREF_AUTOCLEAN_TRASH)) {
777     if (prefs->autoclean == newval) goto fail2;
778     prefs->autoclean = newval;
779     goto success2;
780   }
781 
782   if (!lives_strcmp(prefidx, PREF_MT_SHOW_CTX)) {
783     if (prefs->mt_show_ctx == newval) goto fail2;
784     prefs->mt_show_ctx = newval;
785     goto success2;
786   }
787 
788   if (!lives_strcmp(prefidx, PREF_PREF_TRASH)) {
789     if (prefs->pref_trash == newval) goto fail2;
790     prefs->pref_trash = newval;
791     goto success2;
792   }
793 
794   if (!lives_strcmp(prefidx, PREF_SHOW_BUTTON_ICONS)) {
795     if (prefs->show_button_images == newval) goto fail2;
796     prefs->show_button_images = widget_opts.show_button_images = newval;
797     lives_widget_queue_draw(LIVES_MAIN_WINDOW_WIDGET);
798     if (prefsw) lives_widget_queue_draw(prefsw->prefs_dialog);
799     goto success2;
800   }
801 
802   if (!lives_strcmp(prefidx, PREF_EXTRA_COLOURS)) {
803     if (prefs->extra_colours == newval) goto fail2;
804     prefs->extra_colours = newval;
805     lives_widget_queue_draw(LIVES_MAIN_WINDOW_WIDGET);
806     if (prefsw) lives_widget_queue_draw(prefsw->prefs_dialog);
807     goto success2;
808   }
809 
810   // show recent
811   if (!lives_strcmp(prefidx, PREF_SHOW_RECENT_FILES)) {
812     if (prefs->show_recent == newval) goto fail2;
813     prefs->show_recent = newval;
814     if (newval) {
815       lives_widget_show(mainw->recent_menu);
816       if (mainw->multitrack) lives_widget_show(mainw->multitrack->recent_menu);
817     } else {
818       lives_widget_hide(mainw->recent_menu);
819       if (mainw->multitrack) lives_widget_hide(mainw->multitrack->recent_menu);
820     }
821     if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->recent_check), newval);
822   }
823 
824   if (!lives_strcmp(prefidx, PREF_MSG_PBDIS)) {
825     if (prefs->msgs_pbdis == newval) goto fail2;
826     prefs->msgs_pbdis = newval;
827     if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->msgs_pbdis), newval);
828     goto success2;
829   }
830 
831   if (!lives_strcmp(prefidx, PREF_USE_SCREEN_GAMMA)) {
832     if (prefs->use_screen_gamma == newval) goto fail2;
833     prefs->use_screen_gamma = newval;
834     if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_screengamma), newval);
835     goto success2;
836   }
837 
838   if (!lives_strcmp(prefidx, PREF_LETTERBOX)) {
839     if (prefs->letterbox == newval) goto fail2;
840     prefs->letterbox = newval;
841     if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_lb), newval);
842     if (mainw->multitrack) {
843       lives_signal_handler_block(mainw->letter, mainw->lb_func);
844       lives_check_menu_item_set_active(LIVES_CHECK_MENU_ITEM(mainw->letter), newval);
845       lives_signal_handler_unblock(mainw->letter, mainw->lb_func);
846     }
847     goto success2;
848   }
849 
850   if (!lives_strcmp(prefidx, PREF_LETTERBOXMT)) {
851     prefs->letterbox_mt = newval;
852     if (permanent) {
853       if (prefs->letterbox_mt == newval) goto fail2;
854       future_prefs->letterbox_mt = newval;
855       if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_lbmt), newval);
856     }
857     if (mainw->multitrack && mainw->multitrack->event_list)
858       mt_show_current_frame(mainw->multitrack, FALSE);
859     goto success2;
860   }
861 
862   if (!lives_strcmp(prefidx, PREF_PBQ_ADAPTIVE)) {
863     if (prefs->pbq_adaptive == newval) goto fail2;
864     prefs->pbq_adaptive = newval;
865     if (prefsw) lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->pbq_adaptive), newval);
866     goto success2;
867   }
868 
869   if (!lives_strcmp(prefidx, PREF_VJMODE)) {
870     if (future_prefs->vj_mode == newval) goto fail2;
871     if (mainw && mainw->vj_mode)
872       lives_check_menu_item_set_active(LIVES_CHECK_MENU_ITEM(mainw->vj_mode), newval);
873     future_prefs->vj_mode = newval;
874     goto success2;
875   }
876 
877   if (!lives_strcmp(prefidx, PREF_SHOW_DEVOPTS)) {
878     if (prefs->show_dev_opts == newval) goto fail2;
879     if (mainw && mainw->show_devopts !=  NULL)
880       lives_check_menu_item_set_active(LIVES_CHECK_MENU_ITEM(mainw->show_devopts), newval);
881     prefs->show_dev_opts = newval;
882     goto success2;
883   }
884 
885   if (!lives_strcmp(prefidx, PREF_REC_EXT_AUDIO)) {
886     boolean success = FALSE;
887     boolean rec_ext_audio = newval;
888     if (rec_ext_audio && prefs->audio_src == AUDIO_SRC_INT) {
889       prefs->audio_src = AUDIO_SRC_EXT;
890       if (permanent) {
891         set_int_pref(PREF_AUDIO_SRC, AUDIO_SRC_EXT);
892         future_prefs->audio_src = prefs->audio_src;
893       }
894       success = TRUE;
895     } else if (!rec_ext_audio && prefs->audio_src == AUDIO_SRC_EXT) {
896       prefs->audio_src = AUDIO_SRC_INT;
897       if (permanent) {
898         set_int_pref(PREF_AUDIO_SRC, AUDIO_SRC_INT);
899         future_prefs->audio_src = prefs->audio_src;
900       }
901       success = TRUE;
902     }
903     if (success) {
904       if (prefsw && permanent) {
905         if (prefs->audio_src == AUDIO_SRC_EXT)
906           lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rextaudio), TRUE);
907         else
908           lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rintaudio), TRUE);
909       }
910       lives_toggle_tool_button_set_active(LIVES_TOGGLE_TOOL_BUTTON(mainw->ext_audio_checkbutton),
911                                           prefs->audio_src == AUDIO_SRC_EXT);
912 
913       lives_toggle_tool_button_set_active(LIVES_TOGGLE_TOOL_BUTTON(mainw->int_audio_checkbutton),
914                                           prefs->audio_src == AUDIO_SRC_INT);
915       goto success2;
916     }
917     goto fail2;
918   }
919 
920   if (!lives_strcmp(prefidx, PREF_MT_EXIT_RENDER)) {
921     if (prefs->mt_exit_render == newval) goto fail2;
922     prefs->mt_exit_render = newval;
923     if (prefsw)
924       lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_mt_exit_render), prefs->mt_exit_render);
925     goto success2;
926   }
927 
928   if (!lives_strcmp(prefidx, PREF_PUSH_AUDIO_TO_GENS)) {
929     if (prefs->push_audio_to_gens == newval) goto fail2;
930     prefs->push_audio_to_gens = newval;
931     if (prefsw)
932       lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->pa_gens), prefs->push_audio_to_gens);
933     goto success2;
934   }
935 
936 #ifdef HAVE_PULSE_AUDIO
937   if (!lives_strcmp(prefidx, PREF_PARESTART)) {
938     if (prefs->pa_restart == newval) goto fail2;
939     prefs->pa_restart = newval;
940     if (prefsw)
941       lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_parestart), prefs->pa_restart);
942     goto success2;
943   }
944 #endif
945 
946   if (!lives_strcmp(prefidx, PREF_SHOW_ASRC)) {
947     if (prefs->show_asrc == newval) goto fail2;
948     prefs->show_asrc = newval;
949     if (prefsw)
950       lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_show_asrc), prefs->show_asrc);
951     if (!newval) {
952       lives_widget_hide(mainw->int_audio_checkbutton);
953       lives_widget_hide(mainw->ext_audio_checkbutton);
954       lives_widget_hide(mainw->l1_tb);
955       lives_widget_hide(mainw->l2_tb);
956       lives_widget_hide(mainw->l3_tb);
957     } else {
958       lives_widget_show(mainw->int_audio_checkbutton);
959       lives_widget_show(mainw->ext_audio_checkbutton);
960       lives_widget_show(mainw->l1_tb);
961       lives_widget_show(mainw->l2_tb);
962       lives_widget_show(mainw->l3_tb);
963     }
964     goto success2;
965   }
966 
967   if (!lives_strcmp(prefidx, PREF_SHOW_TOOLTIPS)) {
968     if (prefs->show_tooltips == newval) goto fail2;
969     else {
970       if (newval) prefs->show_tooltips = newval;
971       if (prefsw) {
972         if (prefsw->checkbutton_show_ttips)
973           lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_show_ttips), newval);
974         set_tooltips_state(prefsw->prefs_dialog, newval);
975       }
976       set_tooltips_state(mainw->top_vbox, newval);
977       if (mainw->multitrack) set_tooltips_state(mainw->multitrack->top_vbox, newval);
978       if (fx_dialog[0] && LIVES_IS_WIDGET(fx_dialog[0]->dialog)) set_tooltips_state(fx_dialog[0]->dialog, newval);
979       if (fx_dialog[1] && LIVES_IS_WIDGET(fx_dialog[1]->dialog)) set_tooltips_state(fx_dialog[1]->dialog, newval);
980       if (rte_window) set_tooltips_state(rte_window, newval);
981     }
982     // turn off after, or we cannot nullify the ttips
983     if (!newval) prefs->show_tooltips = newval;
984     goto success2;
985   }
986 
987   if (!lives_strcmp(prefidx, PREF_HFBWNP)) {
988     if (prefs->hfbwnp == newval) goto fail2;
989     prefs->hfbwnp = newval;
990     if (prefsw)
991       lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_hfbwnp), prefs->hfbwnp);
992     if (newval) {
993       if (!LIVES_IS_PLAYING) {
994         lives_widget_hide(mainw->framebar);
995       }
996     } else {
997       if (!LIVES_IS_PLAYING || (LIVES_IS_PLAYING && !prefs->hide_framebar &&
998                                 (!mainw->fs || (mainw->ext_playback && mainw->vpp &&
999                                     !(mainw->vpp->capabilities & VPP_LOCAL_DISPLAY) &&
1000                                     !(mainw->vpp->capabilities & VPP_CAN_RESIZE))))) {
1001         lives_widget_show(mainw->framebar);
1002       }
1003     }
1004     goto success2;
1005   }
1006 
1007   if (!lives_strcmp(prefidx, PREF_AR_CLIPSET)) {
1008     if (prefs->ar_clipset == newval) goto fail2;
1009     prefs->ar_clipset = newval;
1010     goto success2;
1011   }
1012 
1013   if (!lives_strcmp(prefidx, PREF_AR_LAYOUT)) {
1014     if (prefs->ar_layout == newval) goto fail2;
1015     prefs->ar_layout = newval;
1016     goto success2;
1017   }
1018 
1019 fail2:
1020   if (prefsw) prefsw->ignore_apply = FALSE;
1021   return FALSE;
1022 
1023 success2:
1024   if (prefsw) {
1025     lives_widget_process_updates(prefsw->prefs_dialog);
1026     prefsw->ignore_apply = FALSE;
1027   }
1028   if (permanent) set_boolean_pref(prefidx, newval);
1029   return TRUE;
1030 }
1031 
1032 
pref_factory_color_button(lives_colRGBA64_t * pcol,LiVESColorButton * cbutton)1033 boolean pref_factory_color_button(lives_colRGBA64_t *pcol, LiVESColorButton *cbutton) {
1034   LiVESWidgetColor col;
1035   lives_colRGBA64_t lcol;
1036 
1037   if (prefsw) prefsw->ignore_apply = TRUE;
1038 
1039   if (!lives_rgba_equal(widget_color_to_lives_rgba(&lcol, lives_color_button_get_color(cbutton, &col)), pcol)) {
1040     lives_rgba_copy(pcol, &lcol);
1041     if (prefsw) {
1042       lives_widget_process_updates(prefsw->prefs_dialog);
1043       prefsw->ignore_apply = FALSE;
1044     }
1045     return TRUE;
1046   }
1047 
1048   if (prefsw) prefsw->ignore_apply = FALSE;
1049   return FALSE;
1050 }
1051 
1052 
pref_factory_int(const char * prefidx,int newval,boolean permanent)1053 boolean pref_factory_int(const char *prefidx, int newval, boolean permanent) {
1054   if (prefsw) prefsw->ignore_apply = TRUE;
1055 
1056   if (!lives_strcmp(prefidx, PREF_MT_AUTO_BACK)) {
1057     if (newval == prefs->mt_auto_back) goto fail3;
1058     if (mainw->multitrack) {
1059       if (newval <= 0 && prefs->mt_auto_back > 0) {
1060         if (mainw->multitrack->idlefunc > 0) {
1061           lives_source_remove(mainw->multitrack->idlefunc);
1062           mainw->multitrack->idlefunc = 0;
1063         }
1064         if (newval == 0) {
1065           prefs->mt_auto_back = newval;
1066           mt_auto_backup(mainw->multitrack);
1067         }
1068       }
1069       if (newval > 0 && prefs->mt_auto_back <= 0 && mainw->multitrack->idlefunc > 0) {
1070         mainw->multitrack->idlefunc = mt_idle_add(mainw->multitrack);
1071       }
1072     }
1073     prefs->mt_auto_back = newval;
1074     goto success3;
1075   }
1076 
1077   if (!lives_strcmp(prefidx, PREF_MAX_MSGS)) {
1078     if (newval == prefs->max_messages) goto fail3;
1079     if (newval < mainw->n_messages && newval >= 0) {
1080       free_n_msgs(mainw->n_messages - newval);
1081       if (prefs->show_msg_area)
1082         msg_area_scroll(LIVES_ADJUSTMENT(mainw->msg_adj), mainw->msg_area);
1083     }
1084     prefs->max_messages = newval;
1085     goto success3;
1086   }
1087 
1088   if (!lives_strcmp(prefidx, PREF_SEPWIN_TYPE)) {
1089     if (prefs->sepwin_type == newval) goto fail3;
1090     prefs->sepwin_type = newval;
1091     if (newval == SEPWIN_TYPE_STICKY) {
1092       if (mainw->sep_win) {
1093         if (!LIVES_IS_PLAYING) {
1094           make_play_window();
1095         }
1096       } else {
1097         if (mainw->play_window) {
1098           play_window_set_title();
1099         }
1100       }
1101     } else {
1102       if (mainw->sep_win) {
1103         if (!LIVES_IS_PLAYING) {
1104           kill_play_window();
1105         } else {
1106           play_window_set_title();
1107         }
1108       }
1109     }
1110 
1111     if (permanent) future_prefs->sepwin_type = prefs->sepwin_type;
1112     goto success3;
1113   }
1114 
1115   if (!lives_strcmp(prefidx, PREF_RRQMODE)) {
1116     if (newval != prefs->rr_qmode) {
1117       prefs->rr_qmode = newval;
1118       goto success3;
1119     }
1120     goto fail3;
1121   }
1122 
1123   if (!lives_strcmp(prefidx, PREF_RRFSTATE)) {
1124     if (newval != prefs->rr_fstate) {
1125       prefs->rr_fstate = newval;
1126       goto success3;
1127     }
1128     goto fail3;
1129   }
1130 
1131   if (!lives_strcmp(prefidx, PREF_MIDI_CHECK_RATE)) {
1132     if (newval != prefs->midi_check_rate) {
1133       prefs->midi_check_rate = newval;
1134       goto success3;
1135     }
1136     goto fail3;
1137   }
1138 
1139   if (!lives_strcmp(prefidx, PREF_MIDI_RPT)) {
1140     if (newval != prefs->midi_rpt) {
1141       prefs->midi_rpt = newval;
1142       goto success3;
1143     }
1144     goto fail3;
1145   }
1146 
1147 
1148 fail3:
1149   if (prefsw) prefsw->ignore_apply = FALSE;
1150   return FALSE;
1151 
1152 success3:
1153   if (prefsw) {
1154     lives_widget_process_updates(prefsw->prefs_dialog);
1155     prefsw->ignore_apply = FALSE;
1156   }
1157   if (permanent) set_int_pref(prefidx, newval);
1158   return TRUE;
1159 }
1160 
pref_factory_string_choice(const char * prefidx,LiVESList * list,const char * strval,boolean permanent)1161 boolean pref_factory_string_choice(const char *prefidx, LiVESList *list, const char *strval, boolean permanent) {
1162   int idx = lives_list_strcmp_index(list, (livesconstpointer)strval, TRUE);
1163   if (prefsw) prefsw->ignore_apply = TRUE;
1164 
1165   if (!lives_strcmp(prefidx, PREF_MSG_TEXTSIZE)) {
1166     if (idx == prefs->msg_textsize) goto fail4;
1167     prefs->msg_textsize = idx;
1168     if (permanent) future_prefs->msg_textsize = prefs->msg_textsize;
1169     if (prefs->show_msg_area) {
1170       if (mainw->multitrack)
1171         msg_area_scroll(LIVES_ADJUSTMENT(mainw->multitrack->msg_adj), mainw->multitrack->msg_area);
1172       else
1173         msg_area_scroll(LIVES_ADJUSTMENT(mainw->msg_adj), mainw->msg_area);
1174     }
1175     goto success4;
1176   }
1177 
1178 fail4:
1179   if (prefsw) prefsw->ignore_apply = FALSE;
1180   return FALSE;
1181 
1182 success4:
1183   if (prefsw) {
1184     lives_widget_process_updates(prefsw->prefs_dialog);
1185     prefsw->ignore_apply = FALSE;
1186   }
1187   if (permanent) set_int_pref(prefidx, idx);
1188   return TRUE;
1189 }
1190 
1191 
pref_factory_float(const char * prefidx,float newval,boolean permanent)1192 boolean pref_factory_float(const char *prefidx, float newval, boolean permanent) {
1193   if (prefsw) prefsw->ignore_apply = TRUE;
1194 
1195   if (!lives_strcmp(prefidx, PREF_MASTER_VOLUME)) {
1196     char *ttip;
1197     if ((LIVES_IS_PLAYING && future_prefs->volume == newval)
1198         || (!LIVES_IS_PLAYING && prefs->volume == (double)newval)) goto fail5;
1199     future_prefs->volume = newval;
1200     ttip = lives_strdup_printf(_("Audio volume (%.2f)"), newval);
1201     lives_widget_set_tooltip_text(mainw->vol_toolitem, _(ttip));
1202     lives_free(ttip);
1203     if (!LIVES_IS_PLAYING) {
1204       prefs->volume = newval;
1205     } else permanent = FALSE;
1206     if (LIVES_IS_RANGE(mainw->volume_scale)) {
1207       lives_range_set_value(LIVES_RANGE(mainw->volume_scale), newval);
1208     } else {
1209       lives_scale_button_set_value(LIVES_SCALE_BUTTON(mainw->volume_scale), newval);
1210     }
1211     goto success5;
1212   }
1213 
1214   if (!lives_strcmp(prefidx, PREF_AHOLD_THRESHOLD)) {
1215     if (prefs->ahold_threshold == newval) goto fail5;
1216     prefs->ahold_threshold = newval;
1217     goto success5;
1218   }
1219 
1220   if (!lives_strcmp(prefidx, PREF_SCREEN_GAMMA)) {
1221     if (prefs->screen_gamma == newval) goto fail5;
1222     prefs->screen_gamma = newval;
1223     goto success5;
1224   }
1225 
1226 fail5:
1227   if (prefsw) prefsw->ignore_apply = FALSE;
1228   return FALSE;
1229 
1230 success5:
1231   if (prefsw) {
1232     lives_widget_process_updates(prefsw->prefs_dialog);
1233     prefsw->ignore_apply = FALSE;
1234   }
1235   if (permanent) set_double_pref(prefidx, newval);
1236   return TRUE;
1237 }
1238 
1239 
pref_factory_bitmapped(const char * prefidx,int bitfield,boolean newval,boolean permanent)1240 boolean pref_factory_bitmapped(const char *prefidx, int bitfield, boolean newval, boolean permanent) {
1241   if (prefsw) prefsw->ignore_apply = TRUE;
1242 
1243   if (!lives_strcmp(prefidx, PREF_AUDIO_OPTS)) {
1244     if (newval && !(prefs->audio_opts & bitfield)) prefs->audio_opts &= bitfield;
1245     else if (!newval && (prefs->audio_opts & bitfield)) prefs->audio_opts ^= bitfield;
1246     else goto fail6;
1247 
1248     if (permanent) set_int_pref(PREF_AUDIO_OPTS, prefs->audio_opts);
1249 
1250     if (prefsw) {
1251       if (bitfield == AUDIO_OPTS_FOLLOW_FPS) {
1252         lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_afollow),
1253                                        (prefs->audio_opts & AUDIO_OPTS_FOLLOW_FPS) ? TRUE : FALSE);
1254       }
1255       if (bitfield == AUDIO_OPTS_FOLLOW_CLIPS) {
1256         lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_aclips),
1257                                        (prefs->audio_opts & AUDIO_OPTS_FOLLOW_CLIPS) ? TRUE : FALSE);
1258       }
1259     }
1260     goto success6;
1261   }
1262 
1263   if (!lives_strcmp(prefidx, PREF_OMC_DEV_OPTS)) {
1264     if (newval && !(prefs->omc_dev_opts & bitfield)) prefs->omc_dev_opts &= bitfield;
1265     else if (!newval && (prefs->omc_dev_opts & bitfield)) prefs->omc_dev_opts ^= bitfield;
1266     else goto fail6;
1267 
1268     if (permanent) set_int_pref(PREF_OMC_DEV_OPTS, prefs->omc_dev_opts);
1269 
1270     if (bitfield == OMC_DEV_JS) {
1271       if (newval) js_open();
1272       else js_close();
1273     } else if (bitfield == OMC_DEV_MIDI) {
1274       if (!newval) midi_close();
1275     }
1276 #ifdef ALSA_MIDI
1277     else if (bitfield == OMC_DEV_FORCE_RAW_MIDI) {
1278       prefs->use_alsa_midi = !newval;
1279     } else if (bitfield == OMC_DEV_MIDI_DUMMY) {
1280       prefs->alsa_midi_dummy = newval;
1281     }
1282 #endif
1283     goto success6;
1284   }
1285 
1286 fail6:
1287   if (prefsw) prefsw->ignore_apply = FALSE;
1288   return FALSE;
1289 
1290 success6:
1291   if (prefsw) {
1292     lives_widget_process_updates(prefsw->prefs_dialog);
1293     prefsw->ignore_apply = FALSE;
1294   }
1295   return TRUE;
1296 }
1297 
1298 
pref_factory_int64(const char * prefidx,int64_t newval,boolean permanent)1299 boolean pref_factory_int64(const char *prefidx, int64_t newval, boolean permanent) {
1300   if (prefsw) prefsw->ignore_apply = TRUE;
1301 
1302   if (!lives_strcmp(prefidx, PREF_DISK_QUOTA)) {
1303     if (newval != prefs->disk_quota) {
1304       future_prefs->disk_quota = prefs->disk_quota = newval;
1305       goto success7;
1306     }
1307     goto fail7;
1308   }
1309 
1310 fail7:
1311   if (prefsw) prefsw->ignore_apply = FALSE;
1312   return FALSE;
1313 
1314 success7:
1315   if (prefsw) {
1316     lives_widget_process_updates(prefsw->prefs_dialog);
1317     prefsw->ignore_apply = FALSE;
1318   }
1319   if (permanent) set_int64_pref(prefidx, newval);
1320   return TRUE;
1321 }
1322 
1323 
apply_prefs(boolean skip_warn)1324 boolean apply_prefs(boolean skip_warn) {
1325   // set current prefs from prefs dialog
1326   char prefworkdir[PATH_MAX]; /// locale encoding
1327 
1328   const char *video_open_command = lives_entry_get_text(LIVES_ENTRY(prefsw->video_open_entry));
1329   /* const char *audio_play_command = lives_entry_get_text(LIVES_ENTRY(prefsw->audio_command_entry)); */
1330   const char *def_vid_load_dir = lives_entry_get_text(LIVES_ENTRY(prefsw->vid_load_dir_entry));
1331   const char *def_vid_save_dir = lives_entry_get_text(LIVES_ENTRY(prefsw->vid_save_dir_entry));
1332   const char *def_audio_dir = lives_entry_get_text(LIVES_ENTRY(prefsw->audio_dir_entry));
1333   const char *def_image_dir = lives_entry_get_text(LIVES_ENTRY(prefsw->image_dir_entry));
1334   const char *def_proj_dir = lives_entry_get_text(LIVES_ENTRY(prefsw->proj_dir_entry));
1335   const char *wp_path = lives_entry_get_text(LIVES_ENTRY(prefsw->wpp_entry));
1336   const char *frei0r_path = lives_entry_get_text(LIVES_ENTRY(prefsw->frei0r_entry));
1337 #ifdef HAVE_LIBVISUAL
1338   const char *libvis_path = lives_entry_get_text(LIVES_ENTRY(prefsw->libvis_entry));
1339 #endif
1340   const char *ladspa_path = lives_entry_get_text(LIVES_ENTRY(prefsw->ladspa_entry));
1341 
1342   const char *sepimg_path = lives_entry_get_text(LIVES_ENTRY(prefsw->sepimg_entry));
1343   const char *frameblank_path = lives_entry_get_text(LIVES_ENTRY(prefsw->frameblank_entry));
1344 
1345   char workdir[PATH_MAX]; /// locale encoding
1346   const char *theme = lives_combo_get_active_text(LIVES_COMBO(prefsw->theme_combo));
1347   const char *audp = lives_combo_get_active_text(LIVES_COMBO(prefsw->audp_combo));
1348   const char *audio_codec = NULL;
1349   const char *pb_quality = lives_combo_get_active_text(LIVES_COMBO(prefsw->pbq_combo));
1350 
1351   LiVESWidgetColor colf, colb, colf2, colb2, coli, colt, coltcfg, coltcbg;
1352 
1353   boolean pbq_adap = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->pbq_adaptive));
1354   int pbq = PB_QUALITY_MED;
1355   int idx;
1356 
1357   boolean needs_restart = FALSE;
1358 
1359   double default_fps = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_def_fps));
1360   double ext_aud_thresh = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_ext_aud_thresh)) / 100.;
1361   boolean load_rfx = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_load_rfx));
1362   boolean apply_gamma = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_apply_gamma));
1363   boolean antialias = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_antialias));
1364   boolean fx_threads = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_threads));
1365 
1366   boolean lbox = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_lb));
1367   boolean lboxmt = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_lbmt));
1368   boolean scgamma = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_screengamma));
1369   double gamma = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_gamma));
1370 
1371   int nfx_threads = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_nfx_threads));
1372 
1373   boolean stop_screensaver = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->stop_screensaver_check));
1374   boolean open_maximised = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->open_maximised_check));
1375   boolean fs_maximised = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->fs_max_check));
1376   boolean show_recent = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->recent_check));
1377   boolean stream_audio_out = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_stream_audio));
1378   boolean rec_after_pb = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_rec_after_pb));
1379 
1380   int max_msgs = (uint64_t)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->nmessages_spin));
1381   const char *msgtextsize = lives_combo_get_active_text(LIVES_COMBO(prefsw->msg_textsize_combo));
1382   boolean msgs_unlimited = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->msgs_unlimited));
1383   boolean msgs_pbdis = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->msgs_pbdis));
1384 
1385   uint64_t ds_warn_level = (uint64_t)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_warn_ds)) * 1000000;
1386   uint64_t ds_crit_level = (uint64_t)lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_crit_ds)) * 1000000;
1387 
1388   boolean warn_fps = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_fps));
1389   boolean warn_save_set = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_save_set));
1390   boolean warn_fsize = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_fsize));
1391   boolean warn_mplayer = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_mplayer));
1392   boolean warn_rendered_fx = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_rendered_fx));
1393   boolean warn_encoders = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_encoders));
1394   boolean warn_duplicate_set = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_dup_set));
1395   boolean warn_layout_missing_clips = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_clips));
1396   boolean warn_layout_close = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_close));
1397   boolean warn_layout_delete = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_delete));
1398   boolean warn_layout_shift = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_shift));
1399   boolean warn_layout_alter = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_alter));
1400   boolean warn_discard_layout = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_discard_layout));
1401   boolean warn_after_dvgrab =
1402 #ifdef HAVE_LDVGRAB
1403     lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_after_dvgrab));
1404 #else
1405     !(prefs->warning_mask & WARN_MASK_AFTER_DVGRAB);
1406 #endif
1407   boolean warn_mt_achans = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_mt_achans));
1408   boolean warn_mt_no_jack = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_mt_no_jack));
1409   boolean warn_yuv4m_open =
1410 #ifdef HAVE_YUV4MPEG
1411     lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_yuv4m_open));
1412 #else
1413     !(prefs->warning_mask & WARN_MASK_OPEN_YUV4M);
1414 #endif
1415 
1416   boolean warn_layout_adel = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_adel));
1417   boolean warn_layout_ashift = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_ashift));
1418   boolean warn_layout_aalt = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_aalt));
1419   boolean warn_layout_popup = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_popup));
1420   boolean warn_mt_backup_space
1421     = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_mt_backup_space));
1422   boolean warn_after_crash = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_after_crash));
1423   boolean warn_no_pulse = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_no_pulse));
1424   boolean warn_layout_wipe = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_wipe));
1425   boolean warn_layout_gamma = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_gamma));
1426   boolean warn_layout_lb = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_layout_lb));
1427   boolean warn_vjmode_enter = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_warn_vjmode_enter));
1428 
1429   boolean midisynch = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->check_midi));
1430   boolean instant_open = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_instant_open));
1431   boolean auto_deint = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_auto_deint));
1432   boolean auto_trim = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_auto_trim));
1433   boolean auto_nobord = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_nobord));
1434   boolean concat_images = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_concat_images));
1435   boolean ins_speed = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->ins_speed));
1436   boolean show_player_stats = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_show_stats));
1437   boolean ext_jpeg = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->jpeg));
1438   boolean show_tool = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->show_tool));
1439   boolean mouse_scroll = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->mouse_scroll));
1440   boolean ce_maxspect = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_ce_maxspect));
1441   boolean show_button_icons = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_button_icons));
1442   boolean extra_colours = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_extra_colours));
1443   boolean show_asrc = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_show_asrc));
1444   boolean show_ttips = prefsw->checkbutton_show_ttips == NULL ? FALSE : lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(
1445                          prefsw->checkbutton_show_ttips));
1446   boolean hfbwnp = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_hfbwnp));
1447 
1448   int fsize_to_warn = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_warn_fsize));
1449   int dl_bwidth = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_bwidth));
1450   int ocp = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_ocp));
1451 
1452   boolean rec_frames = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rframes));
1453   boolean rec_fps = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rfps));
1454   boolean rec_effects = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->reffects));
1455   boolean rec_clips = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rclips));
1456   boolean rec_audio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->raudio));
1457   boolean pa_gens = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->pa_gens));
1458   boolean rec_ext_audio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rextaudio));
1459 #ifdef RT_AUDIO
1460   boolean rec_desk_audio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rdesk_audio));
1461 #endif
1462 
1463   boolean mt_enter_prompt = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->mt_enter_prompt));
1464   boolean render_prompt = !lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_render_prompt));
1465 
1466   int mt_def_width = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_def_width));
1467   int mt_def_height = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_def_height));
1468   int mt_def_fps = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_def_fps));
1469   int mt_def_arate = atoi(lives_entry_get_text(LIVES_ENTRY(resaudw->entry_arate)));
1470   int mt_def_achans = atoi(lives_entry_get_text(LIVES_ENTRY(resaudw->entry_achans)));
1471   int mt_def_asamps = atoi(lives_entry_get_text(LIVES_ENTRY(resaudw->entry_asamps)));
1472   int mt_def_signed_endian = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(resaudw->rb_unsigned)) *
1473                              AFORM_UNSIGNED + lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(resaudw->rb_bigend))
1474                              * AFORM_BIG_ENDIAN;
1475   int mt_undo_buf = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_undo_buf));
1476 
1477   boolean mt_exit_render = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_mt_exit_render));
1478   boolean mt_enable_audio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(resaudw->aud_checkbutton));
1479   boolean mt_pertrack_audio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->pertrack_checkbutton));
1480   boolean mt_backaudio = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->backaudio_checkbutton));
1481 
1482   boolean mt_autoback_always = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->mt_autoback_always));
1483   boolean mt_autoback_never = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->mt_autoback_never));
1484 
1485   int mt_autoback_time = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_ab_time));
1486   int max_disp_vtracks = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_max_disp_vtracks));
1487   int gui_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_gmoni));
1488   int play_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_pmoni));
1489 
1490   boolean ce_thumbs = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->ce_thumbs));
1491 
1492   boolean forcesmon = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->forcesmon));
1493   boolean startup_ce = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rb_startup_ce));
1494 
1495   boolean show_msgstart = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->cb_show_msgstart));
1496   boolean show_quota = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->cb_show_quota));
1497   boolean autoclean = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->cb_autoclean));
1498 
1499 #ifdef ENABLE_JACK_TRANSPORT
1500   boolean jack_tstart = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_start_tjack));
1501   boolean jack_master = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_master));
1502   boolean jack_client = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_client));
1503   boolean jack_tb_start = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_start));
1504   boolean jack_mtb_start = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_mtb_start));
1505   boolean jack_tb_client = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_client));
1506 #else
1507 #ifdef ENABLE_JACK
1508   boolean jack_tstart = FALSE;
1509   boolean jack_master = FALSE;
1510   boolean jack_client = FALSE;
1511   boolean jack_tb_start = FALSE, jack_mtb_start = FALSE;
1512   boolean jack_tb_client = FALSE;
1513 #endif
1514 #endif
1515 
1516 #ifdef ENABLE_JACK
1517   boolean jack_astart = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_start_ajack));
1518   boolean jack_pwp = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_pwp));
1519   boolean jack_read_autocon = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_read_autocon));
1520   uint32_t jack_opts = (JACK_OPTS_TRANSPORT_CLIENT * jack_client + JACK_OPTS_TRANSPORT_MASTER * jack_master +
1521                         JACK_OPTS_START_TSERVER * jack_tstart + JACK_OPTS_START_ASERVER * jack_astart +
1522                         JACK_OPTS_NOPLAY_WHEN_PAUSED * !jack_pwp + JACK_OPTS_TIMEBASE_START * jack_tb_start +
1523                         JACK_OPTS_TIMEBASE_LSTART * jack_mtb_start +
1524                         JACK_OPTS_TIMEBASE_CLIENT * jack_tb_client + JACK_OPTS_NO_READ_AUTOCON * !jack_read_autocon);
1525 #endif
1526 
1527 #ifdef RT_AUDIO
1528   boolean audio_follow_fps = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_afollow));
1529   boolean audio_follow_clips = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_aclips));
1530   uint32_t audio_opts = (AUDIO_OPTS_FOLLOW_FPS * audio_follow_fps + AUDIO_OPTS_FOLLOW_CLIPS * audio_follow_clips);
1531 #endif
1532 
1533 #ifdef ENABLE_OSC
1534   uint32_t osc_udp_port = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_osc_udp));
1535   boolean osc_start = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->enable_OSC_start));
1536   boolean osc_enable = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->enable_OSC));
1537 #endif
1538 
1539   int rte_keys_virtual = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_rte_keys));
1540 
1541 #ifdef ENABLE_OSC
1542 #ifdef OMC_JS_IMPL
1543   boolean omc_js_enable = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_omc_js));
1544   const char *omc_js_fname = lives_entry_get_text(LIVES_ENTRY(prefsw->omc_js_entry));
1545 #endif
1546 
1547 #ifdef OMC_MIDI_IMPL
1548   boolean omc_midi_enable = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_omc_midi));
1549   const char *omc_midi_fname = lives_entry_get_text(LIVES_ENTRY(prefsw->omc_midi_entry));
1550   int midicr = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_midicr));
1551   int midirpt = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_midirpt));
1552   const char *midichan = lives_combo_get_active_text(LIVES_COMBO(prefsw->midichan_combo));
1553 
1554 #ifdef ALSA_MIDI
1555   boolean use_alsa_midi = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->alsa_midi));
1556   boolean alsa_midi_dummy = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->alsa_midi_dummy));
1557 #endif
1558 
1559 #endif
1560 #endif
1561 
1562   boolean pstyle2 = palette->style & STYLE_2;
1563   boolean pstyle3 = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->theme_style3));
1564   boolean pstyle4 = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->theme_style4));
1565 
1566   int rec_gb = lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(prefsw->spinbutton_rec_gb));
1567 
1568   char audio_player[256];
1569   int listlen = lives_list_length(prefs->acodec_list);
1570   int rec_opts = rec_frames * REC_FRAMES + rec_fps * REC_FPS + rec_effects * REC_EFFECTS + rec_clips * REC_CLIPS + rec_audio *
1571                  REC_AUDIO
1572                  + rec_after_pb * REC_AFTER_PB;
1573   uint64_t warn_mask;
1574 
1575   unsigned char *new_undo_buf;
1576   LiVESList *ulist;
1577 
1578 #ifdef ENABLE_OSC
1579   boolean set_omc_dev_opts = FALSE;
1580 #ifdef OMC_MIDI_IMPL
1581   boolean needs_midi_restart = FALSE;
1582 #endif
1583 #endif
1584 
1585   char *tmp;
1586   char *cdplay_device = lives_filename_from_utf8((char *)lives_entry_get_text(LIVES_ENTRY(prefsw->cdplay_entry)),
1587                         -1, NULL, NULL, NULL);
1588 
1589   lives_snprintf(prefworkdir, PATH_MAX, "%s", prefs->workdir);
1590   ensure_isdir(prefworkdir);
1591 
1592   // TODO: move all into pref_factory_* functions
1593   mainw->no_context_update = TRUE;
1594 
1595   if (prefsw->theme_style2)
1596     pstyle2 = lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->theme_style2));
1597 
1598   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_fore), &colf);
1599   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_back), &colb);
1600   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_mabf), &colf2);
1601   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_mab), &colb2);
1602   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_infob), &coli);
1603   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_infot), &colt);
1604 
1605   if (strcasecmp(future_prefs->theme, LIVES_THEME_NONE)) {
1606     if (!lives_widget_color_equal(&colf, &palette->normal_fore) ||
1607         !lives_widget_color_equal(&colb, &palette->normal_back) ||
1608         !lives_widget_color_equal(&colf2, &palette->menu_and_bars_fore) ||
1609         !lives_widget_color_equal(&colb2, &palette->menu_and_bars) ||
1610         !lives_widget_color_equal(&colt, &palette->info_text) ||
1611         !lives_widget_color_equal(&coli, &palette->info_base) ||
1612         ((pstyle2 * STYLE_2) != (palette->style & STYLE_2)) ||
1613         ((pstyle3 * STYLE_3) != (palette->style & STYLE_3)) ||
1614         ((pstyle4 * STYLE_4) != (palette->style & STYLE_4))
1615        ) {
1616 
1617       lives_widget_color_copy(&palette->normal_fore, &colf);
1618       lives_widget_color_copy(&palette->normal_back, &colb);
1619       lives_widget_color_copy(&palette->menu_and_bars_fore, &colf2);
1620       lives_widget_color_copy(&palette->menu_and_bars, &colb2);
1621       lives_widget_color_copy(&palette->info_base, &coli);
1622       lives_widget_color_copy(&palette->info_text, &colt);
1623 
1624       palette->style = STYLE_1 | (pstyle2 * STYLE_2) | (pstyle3 * STYLE_3) | (pstyle4 * STYLE_4);
1625       mainw->prefs_changed |= PREFS_COLOURS_CHANGED;
1626     }
1627   }
1628 
1629   if (pref_factory_color_button(&palette->ce_sel, LIVES_COLOR_BUTTON(prefsw->cbutton_cesel)))
1630     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1631   if (pref_factory_color_button(&palette->ce_unsel, LIVES_COLOR_BUTTON(prefsw->cbutton_ceunsel)))
1632     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1633   if (pref_factory_color_button(&palette->frame_surround, LIVES_COLOR_BUTTON(prefsw->cbutton_fsur)))
1634     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1635   if (pref_factory_color_button(&palette->mt_mark, LIVES_COLOR_BUTTON(prefsw->cbutton_mtmark)))
1636     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1637   if (pref_factory_color_button(&palette->mt_evbox, LIVES_COLOR_BUTTON(prefsw->cbutton_evbox)))
1638     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1639   if (pref_factory_color_button(&palette->mt_timeline_reg, LIVES_COLOR_BUTTON(prefsw->cbutton_tlreg)))
1640     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1641   if (pref_factory_color_button(&palette->vidcol, LIVES_COLOR_BUTTON(prefsw->cbutton_vidcol)))
1642     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1643   if (pref_factory_color_button(&palette->audcol, LIVES_COLOR_BUTTON(prefsw->cbutton_audcol)))
1644     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1645   if (pref_factory_color_button(&palette->fxcol, LIVES_COLOR_BUTTON(prefsw->cbutton_fxcol)))
1646     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1647 
1648   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_tcfg), &coltcfg);
1649   if (!lives_widget_color_equal(&coltcfg, &palette->mt_timecode_fg)) {
1650     lives_widget_color_copy(&palette->mt_timecode_fg, &coltcfg);
1651     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1652   }
1653 
1654   lives_color_button_get_color(LIVES_COLOR_BUTTON(prefsw->cbutton_tcbg), &coltcbg);
1655   if (!lives_widget_color_equal(&coltcbg, &palette->mt_timecode_bg)) {
1656     lives_widget_color_copy(&palette->mt_timecode_bg, &coltcbg);
1657     mainw->prefs_changed |= PREFS_XCOLOURS_CHANGED;
1658   }
1659 
1660   if (capable->has_encoder_plugins) {
1661     audio_codec = lives_combo_get_active_text(LIVES_COMBO(prefsw->acodec_combo));
1662 
1663     for (idx = 0; idx < listlen && lives_strcmp((char *)lives_list_nth_data(prefs->acodec_list, idx), audio_codec); idx++);
1664 
1665     if (idx == listlen) future_prefs->encoder.audio_codec = 0;
1666     else future_prefs->encoder.audio_codec = prefs->acodec_list_to_format[idx];
1667   } else future_prefs->encoder.audio_codec = 0;
1668 
1669   lives_snprintf(workdir, PATH_MAX, "%s",
1670                  (tmp = lives_filename_from_utf8((char *)lives_entry_get_text(LIVES_ENTRY(prefsw->workdir_entry)),
1671                         -1, NULL, NULL, NULL)));
1672   lives_free(tmp);
1673 
1674   if (!audp ||
1675       !strncmp(audp, mainw->string_constants[LIVES_STRING_CONSTANT_NONE],
1676                strlen(mainw->string_constants[LIVES_STRING_CONSTANT_NONE]))) lives_snprintf(audio_player, 256, AUDIO_PLAYER_NONE);
1677   else if (!strncmp(audp, AUDIO_PLAYER_JACK, strlen(AUDIO_PLAYER_JACK))) lives_snprintf(audio_player, 256, AUDIO_PLAYER_JACK);
1678   else if (!strncmp(audp, AUDIO_PLAYER_SOX, strlen(AUDIO_PLAYER_SOX))) lives_snprintf(audio_player, 256, AUDIO_PLAYER_SOX);
1679   else if (!strncmp(audp, AUDIO_PLAYER_PULSE_AUDIO, strlen(AUDIO_PLAYER_PULSE_AUDIO))) lives_snprintf(audio_player, 256,
1680         AUDIO_PLAYER_PULSE);
1681 
1682   if (!((prefs->audio_player == AUD_PLAYER_JACK && capable->has_jackd) || (prefs->audio_player == AUD_PLAYER_PULSE &&
1683         capable->has_pulse_audio))) {
1684     if (prefs->audio_src == AUDIO_SRC_EXT) future_prefs->audio_src = prefs->audio_src = AUDIO_SRC_INT;
1685   }
1686 
1687   if (rec_opts != prefs->rec_opts) {
1688     prefs->rec_opts = rec_opts;
1689     set_int_pref(PREF_RECORD_OPTS, prefs->rec_opts);
1690   }
1691 
1692   if (!mainw->multitrack) {
1693     pref_factory_bool(PREF_REC_EXT_AUDIO, rec_ext_audio, TRUE);
1694   } else {
1695     future_prefs->audio_src = rec_ext_audio ? AUDIO_SRC_EXT : AUDIO_SRC_INT;
1696   }
1697 
1698   warn_mask = !warn_fps * WARN_MASK_FPS + !warn_save_set * WARN_MASK_SAVE_SET
1699               + !warn_fsize * WARN_MASK_FSIZE + !warn_mplayer *
1700               WARN_MASK_NO_MPLAYER + !warn_rendered_fx * WARN_MASK_RENDERED_FX + !warn_encoders *
1701               WARN_MASK_NO_ENCODERS + !warn_layout_missing_clips * WARN_MASK_LAYOUT_MISSING_CLIPS + !warn_duplicate_set *
1702               WARN_MASK_DUPLICATE_SET + !warn_layout_close * WARN_MASK_LAYOUT_CLOSE_FILE + !warn_layout_delete *
1703               WARN_MASK_LAYOUT_DELETE_FRAMES + !warn_layout_shift * WARN_MASK_LAYOUT_SHIFT_FRAMES + !warn_layout_alter *
1704               WARN_MASK_LAYOUT_ALTER_FRAMES + !warn_discard_layout * WARN_MASK_EXIT_MT + !warn_after_dvgrab *
1705               WARN_MASK_AFTER_DVGRAB + !warn_mt_achans * WARN_MASK_MT_ACHANS + !warn_mt_no_jack *
1706               WARN_MASK_MT_NO_JACK + !warn_layout_adel * WARN_MASK_LAYOUT_DELETE_AUDIO + !warn_layout_ashift *
1707               WARN_MASK_LAYOUT_SHIFT_AUDIO + !warn_layout_aalt * WARN_MASK_LAYOUT_ALTER_AUDIO + !warn_layout_popup *
1708               WARN_MASK_LAYOUT_POPUP + !warn_yuv4m_open * WARN_MASK_OPEN_YUV4M + !warn_mt_backup_space *
1709               WARN_MASK_MT_BACKUP_SPACE + !warn_after_crash * WARN_MASK_CLEAN_AFTER_CRASH
1710               + !warn_no_pulse * WARN_MASK_NO_PULSE_CONNECT
1711               + !warn_layout_wipe * WARN_MASK_LAYOUT_WIPE + !warn_layout_gamma * WARN_MASK_LAYOUT_GAMMA + !warn_layout_lb *
1712               WARN_MASK_LAYOUT_LB + !warn_vjmode_enter *
1713               WARN_MASK_VJMODE_ENTER;
1714 
1715   if (warn_mask != prefs->warning_mask) {
1716     prefs->warning_mask = warn_mask;
1717     set_int64_pref(PREF_LIVES_WARNING_MASK, prefs->warning_mask);
1718   }
1719 
1720   if (msgs_unlimited) {
1721     pref_factory_int(PREF_MAX_MSGS, -max_msgs, TRUE);
1722   } else {
1723     pref_factory_int(PREF_MAX_MSGS, max_msgs, TRUE);
1724   }
1725 
1726   pref_factory_bool(PREF_MSG_PBDIS, msgs_pbdis, TRUE);
1727   pref_factory_bool(PREF_MSG_START, show_msgstart, TRUE);
1728   pref_factory_bool(PREF_SHOW_QUOTA, show_quota, TRUE);
1729   pref_factory_bool(PREF_AUTOCLEAN_TRASH, autoclean, TRUE);
1730   pref_factory_bool(PREF_LETTERBOX, lbox, TRUE);
1731   pref_factory_bool(PREF_LETTERBOXMT, lboxmt, TRUE);
1732   pref_factory_bool(PREF_USE_SCREEN_GAMMA, scgamma, TRUE);
1733   pref_factory_float(PREF_SCREEN_GAMMA, gamma, TRUE);
1734 
1735   ulist = get_textsizes_list();
1736   pref_factory_string_choice(PREF_MSG_TEXTSIZE, ulist, msgtextsize, TRUE);
1737   lives_list_free_all(&ulist);
1738 
1739   if (fsize_to_warn != prefs->warn_file_size) {
1740     prefs->warn_file_size = fsize_to_warn;
1741     set_int_pref(PREF_WARN_FILE_SIZE, fsize_to_warn);
1742   }
1743 
1744   if (dl_bwidth != prefs->dl_bandwidth) {
1745     prefs->dl_bandwidth = dl_bwidth;
1746     set_int_pref(PREF_DL_BANDWIDTH_K, dl_bwidth);
1747   }
1748 
1749   if (ocp != prefs->ocp) {
1750     prefs->ocp = ocp;
1751     set_int_pref(PREF_OPEN_COMPRESSION_PERCENT, ocp);
1752   }
1753 
1754   if (show_tool != prefs->show_tool) {
1755     prefs->show_tool = show_tool;
1756     set_boolean_pref(PREF_SHOW_TOOLBAR, show_tool);
1757   }
1758 
1759   if (mouse_scroll != prefs->mouse_scroll_clips) {
1760     prefs->mouse_scroll_clips = mouse_scroll;
1761     set_boolean_pref(PREF_MOUSE_SCROLL_CLIPS, mouse_scroll);
1762   }
1763 
1764   pref_factory_bool(PREF_RRCRASH, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_crash)), TRUE);
1765   pref_factory_bool(PREF_RRSUPER, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_super)), TRUE);
1766   pref_factory_bool(PREF_RRPRESMOOTH, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_pre_smooth)), TRUE);
1767   pref_factory_bool(PREF_RRQSMOOTH, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_qsmooth)), TRUE);
1768   pref_factory_bool(PREF_RRAMICRO, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_amicro)), TRUE);
1769   pref_factory_bool(PREF_RRRAMICRO, lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->rr_ramicro)), TRUE);
1770 
1771   pref_factory_int(PREF_RRQMODE, lives_combo_get_active_index(LIVES_COMBO(prefsw->rr_combo)), TRUE);
1772   pref_factory_int(PREF_RRFSTATE, lives_combo_get_active_index(LIVES_COMBO(prefsw->rr_scombo)), TRUE);
1773 
1774   pref_factory_bool(PREF_PUSH_AUDIO_TO_GENS, pa_gens, TRUE);
1775 
1776   pref_factory_bool(PREF_SHOW_BUTTON_ICONS, show_button_icons, TRUE);
1777 
1778   pref_factory_bool(PREF_EXTRA_COLOURS, extra_colours, TRUE);
1779 
1780 #ifdef HAVE_PULSE_AUDIO
1781   pref_factory_bool(PREF_PARESTART,
1782                     lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_parestart)),
1783                     TRUE);
1784   if (prefs->pa_restart)
1785     pref_factory_string(PREF_PASTARTOPTS, lives_entry_get_text(LIVES_ENTRY(prefsw->audio_command_entry)), TRUE);
1786 #endif
1787 
1788   if (show_asrc != prefs->show_asrc) {
1789     pref_factory_bool(PREF_SHOW_ASRC, show_asrc, TRUE);
1790   }
1791 
1792 #if GTK_CHECK_VERSION(2, 12, 0)
1793   if (show_ttips != prefs->show_tooltips) {
1794     pref_factory_bool(PREF_SHOW_TOOLTIPS, show_ttips, TRUE);
1795   }
1796 #endif
1797 
1798   if (hfbwnp != prefs->hfbwnp) {
1799     pref_factory_bool(PREF_HFBWNP, hfbwnp, TRUE);
1800   }
1801 
1802   if (ce_maxspect != prefs->ce_maxspect) {
1803     prefs->ce_maxspect = ce_maxspect;
1804     set_boolean_pref(PREF_CE_MAXSPECT, ce_maxspect);
1805     if (mainw->multitrack == NULL) {
1806       if (mainw->current_file > -1) {
1807         int current_file = mainw->current_file;
1808         switch_to_file((mainw->current_file = 0), current_file);
1809       }
1810     }
1811   }
1812 
1813   if (lives_strcmp(wp_path, prefs->weed_plugin_path)) {
1814     set_string_pref(PREF_WEED_PLUGIN_PATH, wp_path);
1815     lives_snprintf(prefs->weed_plugin_path, PATH_MAX, "%s", wp_path);
1816     lives_setenv("WEED_PLUGIN_PATH", wp_path);
1817   }
1818 
1819 #ifdef HAVE_FREI0R
1820   if (lives_strcmp(frei0r_path, prefs->frei0r_path)) {
1821     set_string_pref(PREF_FREI0R_PATH, frei0r_path);
1822     lives_snprintf(prefs->frei0r_path, PATH_MAX, "%s", frei0r_path);
1823     lives_setenv("FREI0R_PATH", frei0r_path);
1824   }
1825 #endif
1826 
1827 #ifdef HAVE_LIBVISUAL
1828   if (lives_strcmp(libvis_path, prefs->libvis_path)) {
1829     set_string_pref(PREF_LIBVISUAL_PATH, libvis_path);
1830     lives_snprintf(prefs->libvis_path, PATH_MAX, "%s", libvis_path);
1831     lives_setenv("VISDUAL_PLUGIN_PATH", libvis_path);
1832   }
1833 #endif
1834 
1835 #ifdef HAVE_LADSPA
1836   if (lives_strcmp(ladspa_path, prefs->ladspa_path)) {
1837     set_string_pref(PREF_LADSPA_PATH, ladspa_path);
1838     lives_snprintf(prefs->ladspa_path, PATH_MAX, "%s", ladspa_path);
1839     lives_setenv("LADSPA_PATH", ladspa_path);
1840   }
1841 #endif
1842 
1843   if (lives_strcmp(sepimg_path, mainw->sepimg_path)) {
1844     lives_snprintf(mainw->sepimg_path, PATH_MAX, "%s", sepimg_path);
1845     mainw->prefs_changed |= PREFS_IMAGES_CHANGED;
1846   }
1847 
1848   if (lives_strcmp(frameblank_path, mainw->frameblank_path)) {
1849     lives_snprintf(mainw->frameblank_path, PATH_MAX, "%s", frameblank_path);
1850     mainw->prefs_changed |= PREFS_IMAGES_CHANGED;
1851   }
1852 
1853   ensure_isdir(workdir);
1854 
1855   // disabled_decoders
1856   if (string_lists_differ(prefs->disabled_decoders, future_prefs->disabled_decoders)) {
1857     lives_list_free_all(&prefs->disabled_decoders);
1858     prefs->disabled_decoders = lives_list_copy_strings(future_prefs->disabled_decoders);
1859     if (prefs->disabled_decoders) set_list_pref(PREF_DISABLED_DECODERS, prefs->disabled_decoders);
1860     else delete_pref(PREF_DISABLED_DECODERS);
1861   }
1862 
1863   // stop xscreensaver
1864   if (prefs->stop_screensaver != stop_screensaver) {
1865     prefs->stop_screensaver = stop_screensaver;
1866     set_boolean_pref(PREF_STOP_SCREENSAVER, prefs->stop_screensaver);
1867   }
1868 
1869   // antialias
1870   if (prefs->antialias != antialias) {
1871     prefs->antialias = antialias;
1872     set_boolean_pref(PREF_ANTIALIAS, antialias);
1873   }
1874 
1875   // load rfx
1876   if (prefs->load_rfx_builtin != load_rfx) {
1877     prefs->load_rfx_builtin = load_rfx;
1878     set_boolean_pref(PREF_LOAD_RFX_BUILTIN, load_rfx);
1879   }
1880 
1881   // apply gamma correction
1882   if (prefs->apply_gamma != apply_gamma) {
1883     prefs->apply_gamma = apply_gamma;
1884     set_boolean_pref(PREF_APPLY_GAMMA, apply_gamma);
1885     needs_restart = TRUE;
1886   }
1887 
1888   // fx_threads
1889   if (!fx_threads) nfx_threads = 1;
1890   if (prefs->nfx_threads != nfx_threads) {
1891     future_prefs->nfx_threads = nfx_threads;
1892     set_int_pref(PREF_NFX_THREADS, nfx_threads);
1893   }
1894 
1895   // open maximised
1896   if (prefs->open_maximised != open_maximised) {
1897     prefs->open_maximised = open_maximised;
1898     set_boolean_pref(PREF_OPEN_MAXIMISED, open_maximised);
1899   }
1900 
1901   // filesel maximised
1902   if (prefs->fileselmax != fs_maximised) {
1903     prefs->fileselmax = fs_maximised;
1904     set_boolean_pref(PREF_FILESEL_MAXIMISED, fs_maximised);
1905   }
1906 
1907   // monitors
1908 
1909   if (forcesmon != prefs->force_single_monitor) {
1910     prefs->force_single_monitor = forcesmon;
1911     set_boolean_pref(PREF_FORCE_SINGLE_MONITOR, forcesmon);
1912     get_monitors(FALSE);
1913     if (capable->nmonitors == 0) resize_widgets_for_monitor(TRUE);
1914   }
1915 
1916   if (capable->nmonitors > 1) {
1917     if (gui_monitor != prefs->gui_monitor || play_monitor != prefs->play_monitor) {
1918       char *str = lives_strdup_printf("%d,%d", gui_monitor, play_monitor);
1919       set_string_pref(PREF_MONITORS, str);
1920       prefs->gui_monitor = gui_monitor;
1921       prefs->play_monitor = play_monitor;
1922       widget_opts.monitor = prefs->gui_monitor > 0 ? prefs->gui_monitor - 1 : capable->primary_monitor;
1923       resize_widgets_for_monitor(TRUE);
1924     }
1925   }
1926 
1927   if (ce_thumbs != prefs->ce_thumb_mode) {
1928     prefs->ce_thumb_mode = ce_thumbs;
1929     set_boolean_pref(PREF_CE_THUMB_MODE, ce_thumbs);
1930   }
1931 
1932   // fps stats
1933   if (prefs->show_player_stats != show_player_stats) {
1934     prefs->show_player_stats = show_player_stats;
1935     set_boolean_pref(PREF_SHOW_PLAYER_STATS, show_player_stats);
1936   }
1937 
1938   if (prefs->stream_audio_out != stream_audio_out) {
1939     prefs->stream_audio_out = stream_audio_out;
1940     set_boolean_pref(PREF_STREAM_AUDIO_OUT, stream_audio_out);
1941   }
1942 
1943   pref_factory_bool(PREF_SHOW_RECENT_FILES, show_recent, TRUE);
1944 
1945   // midi synch
1946   if (prefs->midisynch != midisynch) {
1947     prefs->midisynch = midisynch;
1948     set_boolean_pref(PREF_MIDISYNCH, midisynch);
1949   }
1950 
1951   // jpeg/png
1952   if (strcmp(prefs->image_ext, LIVES_FILE_EXT_JPG) && ext_jpeg) {
1953     set_string_pref(PREF_DEFAULT_IMAGE_TYPE, LIVES_IMAGE_TYPE_JPEG);
1954     lives_snprintf(prefs->image_ext, 16, LIVES_FILE_EXT_JPG);
1955     lives_snprintf(prefs->image_type, 16, "%s", LIVES_IMAGE_TYPE_JPEG);
1956   } else if (!strcmp(prefs->image_ext, LIVES_FILE_EXT_JPG) && !ext_jpeg) {
1957     set_string_pref(PREF_DEFAULT_IMAGE_TYPE, LIVES_IMAGE_TYPE_PNG);
1958     lives_snprintf(prefs->image_ext, 16, LIVES_FILE_EXT_PNG);
1959     lives_snprintf(prefs->image_type, 16, "%s", LIVES_IMAGE_TYPE_PNG);
1960   }
1961 
1962   // instant open
1963   if (prefs->instant_open != instant_open) {
1964     set_boolean_pref(PREF_INSTANT_OPEN, (prefs->instant_open = instant_open));
1965   }
1966 
1967   // auto deinterlace
1968   if (prefs->auto_deint != auto_deint) {
1969     set_boolean_pref(PREF_AUTO_DEINTERLACE, (prefs->auto_deint = auto_deint));
1970   }
1971 
1972   // auto deinterlace
1973   if (prefs->auto_trim_audio != auto_trim) {
1974     set_boolean_pref(PREF_AUTO_TRIM_PAD_AUDIO, (prefs->auto_trim_audio = auto_trim));
1975   }
1976 
1977   // auto border cut
1978   if (prefs->auto_nobord != auto_nobord) {
1979     set_boolean_pref(PREF_AUTO_CUT_BORDERS, (prefs->auto_nobord = auto_nobord));
1980   }
1981 
1982   // concat images
1983   if (prefs->concat_images != concat_images) {
1984     set_boolean_pref(PREF_CONCAT_IMAGES, (prefs->concat_images = concat_images));
1985   }
1986 
1987   // encoder
1988   if (strcmp(prefs->encoder.name, future_prefs->encoder.name)) {
1989     lives_snprintf(prefs->encoder.name, 64, "%s", future_prefs->encoder.name);
1990     set_string_pref(PREF_ENCODER, prefs->encoder.name);
1991     lives_snprintf(prefs->encoder.of_restrict, 1024, "%s", future_prefs->encoder.of_restrict);
1992     prefs->encoder.of_allowed_acodecs = future_prefs->encoder.of_allowed_acodecs;
1993   }
1994 
1995   // output format
1996   if (strcmp(prefs->encoder.of_name, future_prefs->encoder.of_name)) {
1997     lives_snprintf(prefs->encoder.of_name, 64, "%s", future_prefs->encoder.of_name);
1998     lives_snprintf(prefs->encoder.of_restrict, 1024, "%s", future_prefs->encoder.of_restrict);
1999     lives_snprintf(prefs->encoder.of_desc, 128, "%s", future_prefs->encoder.of_desc);
2000     prefs->encoder.of_allowed_acodecs = future_prefs->encoder.of_allowed_acodecs;
2001     set_string_pref(PREF_OUTPUT_TYPE, prefs->encoder.of_name);
2002   }
2003 
2004   if (prefs->encoder.audio_codec != future_prefs->encoder.audio_codec) {
2005     prefs->encoder.audio_codec = future_prefs->encoder.audio_codec;
2006     if (prefs->encoder.audio_codec < AUDIO_CODEC_UNKNOWN) {
2007       set_int_pref(PREF_ENCODER_ACODEC, prefs->encoder.audio_codec);
2008     }
2009   }
2010 
2011   // pb quality
2012   if (!strcmp(pb_quality, (char *)lives_list_nth_data(prefsw->pbq_list, 0))) pbq = PB_QUALITY_LOW;
2013   if (!strcmp(pb_quality, (char *)lives_list_nth_data(prefsw->pbq_list, 1))) pbq = PB_QUALITY_MED;
2014   if (!strcmp(pb_quality, (char *)lives_list_nth_data(prefsw->pbq_list, 2))) pbq = PB_QUALITY_HIGH;
2015 
2016   if (pbq != prefs->pb_quality) {
2017     future_prefs->pb_quality = prefs->pb_quality = pbq;
2018     set_int_pref(PREF_PB_QUALITY, pbq);
2019   }
2020 
2021   pref_factory_bool(PREF_PBQ_ADAPTIVE, pbq_adap, TRUE);
2022 
2023   // video open command
2024   if (lives_strcmp(prefs->video_open_command, video_open_command)) {
2025     lives_snprintf(prefs->video_open_command, PATH_MAX * 2, "%s", video_open_command);
2026     set_string_pref(PREF_VIDEO_OPEN_COMMAND, prefs->video_open_command);
2027   }
2028 
2029   //playback plugin
2030   set_vpp(TRUE);
2031 
2032   /* // audio play command */
2033   /* if (strcmp(prefs->audio_play_command, audio_play_command)) { */
2034   /*   lives_snprintf(prefs->audio_play_command, PATH_MAX * 2, "%s", audio_play_command); */
2035   /*   set_string_pref(PREF_AUDIO_PLAY_COMMAND, prefs->audio_play_command); */
2036   /* } */
2037 
2038   // cd play device
2039   if (lives_strcmp(prefs->cdplay_device, cdplay_device)) {
2040     lives_snprintf(prefs->cdplay_device, PATH_MAX, "%s", cdplay_device);
2041     set_string_pref(PREF_CDPLAY_DEVICE, prefs->cdplay_device);
2042   }
2043 
2044   lives_free(cdplay_device);
2045 
2046   // default video load directory
2047   if (lives_strcmp(prefs->def_vid_load_dir, def_vid_load_dir)) {
2048     lives_snprintf(prefs->def_vid_load_dir, PATH_MAX, "%s/", def_vid_load_dir);
2049     get_dirname(prefs->def_vid_load_dir);
2050     set_utf8_pref(PREF_VID_LOAD_DIR, prefs->def_vid_load_dir);
2051     lives_snprintf(mainw->vid_load_dir, PATH_MAX, "%s", prefs->def_vid_load_dir);
2052   }
2053 
2054   // default video save directory
2055   if (lives_strcmp(prefs->def_vid_save_dir, def_vid_save_dir)) {
2056     lives_snprintf(prefs->def_vid_save_dir, PATH_MAX, "%s/", def_vid_save_dir);
2057     get_dirname(prefs->def_vid_save_dir);
2058     set_utf8_pref(PREF_VID_SAVE_DIR, prefs->def_vid_save_dir);
2059     lives_snprintf(mainw->vid_save_dir, PATH_MAX, "%s", prefs->def_vid_save_dir);
2060   }
2061 
2062   // default audio directory
2063   if (lives_strcmp(prefs->def_audio_dir, def_audio_dir)) {
2064     lives_snprintf(prefs->def_audio_dir, PATH_MAX, "%s/", def_audio_dir);
2065     get_dirname(prefs->def_audio_dir);
2066     set_utf8_pref(PREF_AUDIO_DIR, prefs->def_audio_dir);
2067     lives_snprintf(mainw->audio_dir, PATH_MAX, "%s", prefs->def_audio_dir);
2068   }
2069 
2070   // default image directory
2071   if (lives_strcmp(prefs->def_image_dir, def_image_dir)) {
2072     lives_snprintf(prefs->def_image_dir, PATH_MAX, "%s/", def_image_dir);
2073     get_dirname(prefs->def_image_dir);
2074     set_utf8_pref(PREF_IMAGE_DIR, prefs->def_image_dir);
2075     lives_snprintf(mainw->image_dir, PATH_MAX, "%s", prefs->def_image_dir);
2076   }
2077 
2078   // default project directory - for backup and restore
2079   if (lives_strcmp(prefs->def_proj_dir, def_proj_dir)) {
2080     lives_snprintf(prefs->def_proj_dir, PATH_MAX, "%s/", def_proj_dir);
2081     get_dirname(prefs->def_proj_dir);
2082     set_utf8_pref(PREF_PROJ_DIR, prefs->def_proj_dir);
2083     lives_snprintf(mainw->proj_load_dir, PATH_MAX, "%s", prefs->def_proj_dir);
2084     lives_snprintf(mainw->proj_save_dir, PATH_MAX, "%s", prefs->def_proj_dir);
2085   }
2086 
2087   // the theme
2088   if (lives_utf8_strcmp(future_prefs->theme, theme) && !(!strcasecmp(future_prefs->theme, LIVES_THEME_NONE) &&
2089       !lives_utf8_strcmp(theme, mainw->string_constants[LIVES_STRING_CONSTANT_NONE]))) {
2090     mainw->prefs_changed |= PREFS_THEME_CHANGED;
2091     if (lives_utf8_strcmp(theme, mainw->string_constants[LIVES_STRING_CONSTANT_NONE])) {
2092       lives_snprintf(prefs->theme, 64, "%s", theme);
2093       lives_snprintf(future_prefs->theme, 64, "%s", theme);
2094       set_string_pref(PREF_GUI_THEME, future_prefs->theme);
2095       widget_opts.apply_theme = 1;
2096       set_palette_colours(TRUE);
2097       if (mainw->multitrack) {
2098         if (mainw->multitrack->frame_pixbuf == mainw->imframe) mainw->multitrack->frame_pixbuf = NULL;
2099       }
2100       load_theme_images();
2101       mainw->prefs_changed |= PREFS_COLOURS_CHANGED | PREFS_IMAGES_CHANGED;
2102     } else {
2103       lives_snprintf(future_prefs->theme, 64, LIVES_THEME_NONE);
2104       set_string_pref(PREF_GUI_THEME, future_prefs->theme);
2105       delete_pref(THEME_DETAIL_STYLE);
2106       delete_pref(THEME_DETAIL_SEPWIN_IMAGE);
2107       delete_pref(THEME_DETAIL_FRAMEBLANK_IMAGE);
2108       delete_pref(THEME_DETAIL_NORMAL_FORE);
2109       delete_pref(THEME_DETAIL_NORMAL_BACK);
2110       delete_pref(THEME_DETAIL_ALT_FORE);
2111       delete_pref(THEME_DETAIL_ALT_BACK);
2112       delete_pref(THEME_DETAIL_INFO_TEXT);
2113       delete_pref(THEME_DETAIL_INFO_BASE);
2114     }
2115   }
2116 
2117   // default fps
2118   if (prefs->default_fps != default_fps) {
2119     prefs->default_fps = default_fps;
2120     set_double_pref(PREF_DEFAULT_FPS, prefs->default_fps);
2121   }
2122 
2123   // ahold
2124   pref_factory_float(PREF_AHOLD_THRESHOLD, ext_aud_thresh, TRUE);
2125 
2126   // virtual rte keys
2127   if (prefs->rte_keys_virtual != rte_keys_virtual) {
2128     // if we are showing the rte window, we must destroy and recreate it
2129     refresh_rte_window();
2130 
2131     prefs->rte_keys_virtual = rte_keys_virtual;
2132     set_int_pref(PREF_RTE_KEYS_VIRTUAL, prefs->rte_keys_virtual);
2133   }
2134 
2135   if (prefs->rec_stop_gb != rec_gb) {
2136     // disk free level at which we must stop recording
2137     prefs->rec_stop_gb = rec_gb;
2138     set_int_pref(PREF_REC_STOP_GB, prefs->rec_stop_gb);
2139   }
2140 
2141   if (ins_speed == prefs->ins_resample) {
2142     prefs->ins_resample = !ins_speed;
2143     set_boolean_pref(PREF_INSERT_RESAMPLE, prefs->ins_resample);
2144   }
2145 
2146   if (ds_warn_level != prefs->ds_warn_level) {
2147     prefs->ds_warn_level = ds_warn_level;
2148     mainw->next_ds_warn_level = prefs->ds_warn_level;
2149     set_int64_pref(PREF_DS_WARN_LEVEL, ds_warn_level);
2150   }
2151 
2152   if (ds_crit_level != prefs->ds_crit_level) {
2153     prefs->ds_crit_level = ds_crit_level;
2154     set_int64_pref(PREF_DS_CRIT_LEVEL, ds_crit_level);
2155   }
2156 
2157 #ifdef ENABLE_OSC
2158   if (osc_enable) {
2159     if (prefs->osc_udp_started && osc_udp_port != prefs->osc_udp_port) {
2160       // port number changed
2161       lives_osc_end();
2162       prefs->osc_udp_started = FALSE;
2163     }
2164     prefs->osc_udp_port = osc_udp_port;
2165     // try to start on new port number
2166     if (!prefs->osc_udp_started) prefs->osc_udp_started = lives_osc_init(prefs->osc_udp_port);
2167   } else {
2168     if (prefs->osc_udp_started) {
2169       lives_osc_end();
2170       prefs->osc_udp_started = FALSE;
2171     }
2172   }
2173   if (osc_start) {
2174     if (!future_prefs->osc_start) {
2175       set_boolean_pref(PREF_OSC_START, TRUE);
2176       future_prefs->osc_start = TRUE;
2177     }
2178   } else {
2179     if (future_prefs->osc_start) {
2180       set_boolean_pref(PREF_OSC_START, FALSE);
2181       future_prefs->osc_start = FALSE;
2182     }
2183   }
2184   if (prefs->osc_udp_port != osc_udp_port) {
2185     prefs->osc_udp_port = osc_udp_port;
2186     set_int_pref(PREF_OSC_PORT, osc_udp_port);
2187   }
2188 #endif
2189 
2190 #ifdef RT_AUDIO
2191   if (prefs->audio_opts != audio_opts) {
2192     prefs->audio_opts = audio_opts;
2193     set_int_pref(PREF_AUDIO_OPTS, audio_opts);
2194   }
2195 
2196   if (rec_desk_audio != prefs->rec_desktop_audio) {
2197     prefs->rec_desktop_audio = rec_desk_audio;
2198     set_boolean_pref(PREF_REC_DESKTOP_AUDIO, rec_desk_audio);
2199   }
2200 #endif
2201 
2202   pref_factory_string(PREF_AUDIO_PLAYER, audio_player, TRUE);
2203 
2204 #ifdef ENABLE_JACK
2205   if (prefs->jack_opts != jack_opts) {
2206     set_int_pref(PREF_JACK_OPTS, jack_opts);
2207     future_prefs->jack_opts = prefs->jack_opts = jack_opts;
2208   }
2209 #endif
2210 
2211 #ifdef ENABLE_OSC
2212 #ifdef OMC_JS_IMPL
2213   pref_factory_string(PREF_OMC_JS_FNAME, omc_js_fname, TRUE);
2214   if (pref_factory_bitmapped(PREF_OMC_DEV_OPTS, OMC_DEV_JS, omc_js_enable, FALSE))
2215     set_omc_dev_opts = TRUE;
2216 #endif
2217 
2218 #ifdef OMC_MIDI_IMPL
2219   pref_factory_string(PREF_MIDI_RCV_CHANNEL, midichan, TRUE);
2220   pref_factory_string(PREF_OMC_MIDI_FNAME, omc_midi_fname, TRUE);
2221 
2222   pref_factory_int(PREF_MIDI_CHECK_RATE, midicr, TRUE);
2223   pref_factory_int(PREF_MIDI_RPT, midirpt, TRUE);
2224 
2225   if (omc_midi_enable && !(prefs->omc_dev_opts & OMC_DEV_MIDI)) needs_midi_restart = TRUE;
2226   if (pref_factory_bitmapped(PREF_OMC_DEV_OPTS, OMC_DEV_MIDI, omc_midi_enable, FALSE))
2227     set_omc_dev_opts = TRUE;
2228 
2229 #ifdef ALSA_MIDI
2230   if (pref_factory_bitmapped(PREF_OMC_DEV_OPTS, OMC_DEV_FORCE_RAW_MIDI, !use_alsa_midi, FALSE))
2231     set_omc_dev_opts = TRUE;
2232 
2233   if (use_alsa_midi == ((prefs->omc_dev_opts & OMC_DEV_FORCE_RAW_MIDI) / OMC_DEV_FORCE_RAW_MIDI)) {
2234     if (!needs_midi_restart) {
2235       needs_midi_restart = (mainw->ext_cntl[EXT_CNTL_MIDI]);
2236     }
2237   }
2238 
2239   if (pref_factory_bitmapped(PREF_OMC_DEV_OPTS, OMC_DEV_MIDI_DUMMY, alsa_midi_dummy, FALSE)) {
2240     set_omc_dev_opts = TRUE;
2241     if (!needs_midi_restart) {
2242       needs_midi_restart = (mainw->ext_cntl[EXT_CNTL_MIDI]);
2243     }
2244   }
2245 #endif
2246 
2247   if (needs_midi_restart) {
2248     midi_close();
2249     midi_open();
2250   }
2251 
2252 #endif
2253   if (set_omc_dev_opts) set_int_pref(PREF_OMC_DEV_OPTS, prefs->omc_dev_opts);
2254 #endif
2255 
2256   if (mt_enter_prompt != prefs->mt_enter_prompt) {
2257     prefs->mt_enter_prompt = mt_enter_prompt;
2258     set_boolean_pref(PREF_MT_ENTER_PROMPT, mt_enter_prompt);
2259   }
2260 
2261   pref_factory_bool(PREF_MT_EXIT_RENDER, mt_exit_render, TRUE);
2262 
2263   if (render_prompt != prefs->render_prompt) {
2264     prefs->render_prompt = render_prompt;
2265     set_boolean_pref(PREF_RENDER_PROMPT, render_prompt);
2266   }
2267 
2268   if (mt_pertrack_audio != prefs->mt_pertrack_audio) {
2269     prefs->mt_pertrack_audio = mt_pertrack_audio;
2270     set_boolean_pref(PREF_MT_PERTRACK_AUDIO, mt_pertrack_audio);
2271   }
2272 
2273   if (mt_backaudio != prefs->mt_backaudio) {
2274     prefs->mt_backaudio = mt_backaudio;
2275     set_int_pref(PREF_MT_BACKAUDIO, mt_backaudio);
2276   }
2277 
2278   if (mt_def_width != prefs->mt_def_width) {
2279     prefs->mt_def_width = mt_def_width;
2280     set_int_pref(PREF_MT_DEF_WIDTH, mt_def_width);
2281   }
2282   if (mt_def_height != prefs->mt_def_height) {
2283     prefs->mt_def_height = mt_def_height;
2284     set_int_pref(PREF_MT_DEF_HEIGHT, mt_def_height);
2285   }
2286   if (mt_def_fps != prefs->mt_def_fps) {
2287     prefs->mt_def_fps = mt_def_fps;
2288     set_double_pref(PREF_MT_DEF_FPS, mt_def_fps);
2289   }
2290   if (!mt_enable_audio) mt_def_achans = 0;
2291   if (mt_def_achans != prefs->mt_def_achans) {
2292     prefs->mt_def_achans = mt_def_achans;
2293     set_int_pref(PREF_MT_DEF_ACHANS, mt_def_achans);
2294   }
2295   if (mt_def_asamps != prefs->mt_def_asamps) {
2296     prefs->mt_def_asamps = mt_def_asamps;
2297     set_int_pref(PREF_MT_DEF_ASAMPS, mt_def_asamps);
2298   }
2299   if (mt_def_arate != prefs->mt_def_arate) {
2300     prefs->mt_def_arate = mt_def_arate;
2301     set_int_pref(PREF_MT_DEF_ARATE, mt_def_arate);
2302   }
2303   if (mt_def_signed_endian != prefs->mt_def_signed_endian) {
2304     prefs->mt_def_signed_endian = mt_def_signed_endian;
2305     set_int_pref(PREF_MT_DEF_SIGNED_ENDIAN, mt_def_signed_endian);
2306   }
2307 
2308   if (mt_undo_buf != prefs->mt_undo_buf) {
2309     if ((new_undo_buf = (unsigned char *)lives_malloc(mt_undo_buf * 1024 * 1024)) == NULL) {
2310       do_mt_set_mem_error(mainw->multitrack != NULL);
2311     } else {
2312       if (mainw->multitrack) {
2313         if (mainw->multitrack->undo_mem) {
2314           if (mt_undo_buf < prefs->mt_undo_buf) {
2315             ssize_t space_needed = mainw->multitrack->undo_buffer_used - (size_t)(mt_undo_buf * 1024 * 1024);
2316             if (space_needed > 0) make_backup_space(mainw->multitrack, space_needed);
2317             lives_memcpy(new_undo_buf, mainw->multitrack->undo_mem, mt_undo_buf * 1024 * 1024);
2318           } else lives_memcpy(new_undo_buf, mainw->multitrack->undo_mem, prefs->mt_undo_buf * 1024 * 1024);
2319           ulist = mainw->multitrack->undos;
2320           while (ulist) {
2321             ulist->data = new_undo_buf + ((unsigned char *)ulist->data - mainw->multitrack->undo_mem);
2322             ulist = ulist->next;
2323           }
2324           lives_free(mainw->multitrack->undo_mem);
2325           mainw->multitrack->undo_mem = new_undo_buf;
2326         } else {
2327           mainw->multitrack->undo_mem = (unsigned char *)lives_malloc(mt_undo_buf * 1024 * 1024);
2328           if (mainw->multitrack->undo_mem == NULL) {
2329             do_mt_set_mem_error(TRUE);
2330           } else {
2331             mainw->multitrack->undo_buffer_used = 0;
2332             mainw->multitrack->undos = NULL;
2333             mainw->multitrack->undo_offset = 0;
2334           }
2335         }
2336       }
2337       prefs->mt_undo_buf = mt_undo_buf;
2338       set_int_pref(PREF_MT_UNDO_BUF, mt_undo_buf);
2339     }
2340   }
2341 
2342   if (mt_autoback_always) mt_autoback_time = 0;
2343   else if (mt_autoback_never) mt_autoback_time = -1;
2344 
2345   pref_factory_int(PREF_MT_AUTO_BACK, mt_autoback_time, TRUE);
2346 
2347   if (max_disp_vtracks != prefs->max_disp_vtracks) {
2348     prefs->max_disp_vtracks = max_disp_vtracks;
2349     set_int_pref(PREF_MAX_DISP_VTRACKS, max_disp_vtracks);
2350     if (mainw->multitrack) scroll_tracks(mainw->multitrack, mainw->multitrack->top_track, FALSE);
2351   }
2352 
2353   if (startup_ce && future_prefs->startup_interface != STARTUP_CE) {
2354     future_prefs->startup_interface = STARTUP_CE;
2355     set_int_pref(PREF_STARTUP_INTERFACE, STARTUP_CE);
2356     if ((mainw->multitrack && mainw->multitrack->event_list) || mainw->stored_event_list)
2357       write_backup_layout_numbering(mainw->multitrack);
2358   } else if (!startup_ce && future_prefs->startup_interface != STARTUP_MT) {
2359     future_prefs->startup_interface = STARTUP_MT;
2360     set_int_pref(PREF_STARTUP_INTERFACE, STARTUP_MT);
2361     if ((mainw->multitrack && mainw->multitrack->event_list) || mainw->stored_event_list)
2362       write_backup_layout_numbering(mainw->multitrack);
2363   }
2364 
2365   mainw->no_context_update = FALSE;
2366 
2367   if (lives_strcmp(prefworkdir, workdir)) {
2368     char *xworkdir = lives_strdup(workdir);
2369     if (check_workdir_valid(&xworkdir, LIVES_DIALOG(prefsw->prefs_dialog), FALSE) == LIVES_RESPONSE_OK) {
2370       char *msg = workdir_ch_warning();
2371 
2372       if (do_warning_dialog(msg)) {
2373         lives_snprintf(workdir, PATH_MAX, "%s", xworkdir);
2374         set_workdir_label_text(LIVES_LABEL(prefsw->workdir_label), xworkdir);
2375         lives_free(xworkdir);
2376 
2377         lives_widget_queue_draw(prefsw->workdir_label);
2378         lives_widget_context_update(); // update prefs window before showing confirmation box
2379         lives_snprintf(future_prefs->workdir, PATH_MAX, "%s", workdir);
2380         mainw->prefs_changed = PREFS_WORKDIR_CHANGED;
2381         needs_restart = TRUE;
2382       } else {
2383         future_prefs->workdir[0] = '\0';
2384         mainw->prefs_changed |= PREFS_NEEDS_REVERT;
2385       }
2386       lives_free(msg);
2387     }
2388   }
2389 
2390   return needs_restart;
2391 }
2392 
2393 
save_future_prefs(void)2394 void save_future_prefs(void) {
2395   // save future prefs on exit, if they have changed
2396 
2397   // show_recent is a special case, future prefs has our original value
2398   if (!prefs->show_recent && future_prefs->show_recent) {
2399     for (register int i = 1; i < + N_RECENT_FILES; i++)  {
2400       char *prefname = lives_strdup_printf("%s%d", PREF_RECENT, i);
2401       set_string_pref(prefname, "");
2402       lives_free(prefname);
2403     }
2404   }
2405 
2406   if (prefs->pref_trash != future_prefs->pref_trash) {
2407     set_boolean_pref(PREF_PREF_TRASH, prefs->pref_trash);
2408   }
2409 
2410   if ((*future_prefs->workdir)) {
2411     set_string_pref_priority(PREF_WORKING_DIR, future_prefs->workdir);
2412     set_string_pref(PREF_WORKING_DIR_OLD, future_prefs->workdir);
2413   }
2414 }
2415 
2416 
rdet_acodec_changed(LiVESCombo * acodec_combo,livespointer user_data)2417 void rdet_acodec_changed(LiVESCombo *acodec_combo, livespointer user_data) {
2418   int listlen = lives_list_length(prefs->acodec_list);
2419   int idx;
2420   const char *audio_codec = lives_combo_get_active_text(acodec_combo);
2421   if (!strcmp(audio_codec, mainw->string_constants[LIVES_STRING_CONSTANT_ANY])) return;
2422 
2423   for (idx = 0; idx < listlen && strcmp((char *)lives_list_nth_data(prefs->acodec_list, idx), audio_codec); idx++);
2424 
2425   if (idx == listlen) future_prefs->encoder.audio_codec = 0;
2426   else future_prefs->encoder.audio_codec = prefs->acodec_list_to_format[idx];
2427 
2428   if (prefs->encoder.audio_codec != future_prefs->encoder.audio_codec) {
2429     prefs->encoder.audio_codec = future_prefs->encoder.audio_codec;
2430     if (prefs->encoder.audio_codec < AUDIO_CODEC_UNKNOWN) {
2431       set_int_pref(PREF_ENCODER_ACODEC, prefs->encoder.audio_codec);
2432     }
2433   }
2434 }
2435 
2436 
set_acodec_list_from_allowed(_prefsw * prefsw,render_details * rdet)2437 void set_acodec_list_from_allowed(_prefsw *prefsw, render_details *rdet) {
2438   // could be done better, but no time...
2439   // get settings for current format
2440 
2441   int count = 0, idx;
2442   boolean is_allowed = FALSE;
2443 
2444   if (prefs->acodec_list) {
2445     lives_list_free(prefs->acodec_list);
2446     prefs->acodec_list = NULL;
2447   }
2448 
2449   if (future_prefs->encoder.of_allowed_acodecs == 0) {
2450     prefs->acodec_list = lives_list_append(prefs->acodec_list, lives_strdup(mainw->string_constants[LIVES_STRING_CONSTANT_NONE]));
2451     future_prefs->encoder.audio_codec = prefs->acodec_list_to_format[0] = AUDIO_CODEC_NONE;
2452 
2453     if (prefsw) {
2454       lives_combo_populate(LIVES_COMBO(prefsw->acodec_combo), prefs->acodec_list);
2455       lives_combo_set_active_index(LIVES_COMBO(prefsw->acodec_combo), 0);
2456     }
2457     if (rdet) {
2458       lives_combo_populate(LIVES_COMBO(rdet->acodec_combo), prefs->acodec_list);
2459       lives_combo_set_active_index(LIVES_COMBO(rdet->acodec_combo), 0);
2460     }
2461     return;
2462   }
2463   for (idx = 0; strlen(anames[idx]); idx++) {
2464     if (future_prefs->encoder.of_allowed_acodecs & (1 << idx)) {
2465       if (idx == AUDIO_CODEC_PCM) prefs->acodec_list = lives_list_append(prefs->acodec_list,
2466             (_("PCM (highest quality; largest files)")));
2467       else prefs->acodec_list = lives_list_append(prefs->acodec_list, lives_strdup(anames[idx]));
2468       prefs->acodec_list_to_format[count++] = idx;
2469       if (future_prefs->encoder.audio_codec == idx) is_allowed = TRUE;
2470     }
2471   }
2472 
2473   if (prefsw) {
2474     lives_combo_populate(LIVES_COMBO(prefsw->acodec_combo), prefs->acodec_list);
2475   }
2476   if (rdet) {
2477     lives_combo_populate(LIVES_COMBO(rdet->acodec_combo), prefs->acodec_list);
2478   }
2479   if (!is_allowed) {
2480     future_prefs->encoder.audio_codec = prefs->acodec_list_to_format[0];
2481   }
2482 
2483   for (idx = 0; idx < lives_list_length(prefs->acodec_list); idx++) {
2484     if (prefs->acodec_list_to_format[idx] == future_prefs->encoder.audio_codec) {
2485       if (prefsw) {
2486         lives_combo_set_active_index(LIVES_COMBO(prefsw->acodec_combo), idx);
2487       }
2488       if (rdet) {
2489         lives_combo_set_active_index(LIVES_COMBO(rdet->acodec_combo), idx);
2490       }
2491       break;
2492     }
2493   }
2494 }
2495 
2496 
after_vpp_changed(LiVESWidget * vpp_combo,livespointer advbutton)2497 void after_vpp_changed(LiVESWidget *vpp_combo, livespointer advbutton) {
2498   const char *newvpp = lives_combo_get_active_text(LIVES_COMBO(vpp_combo));
2499   _vid_playback_plugin *tmpvpp;
2500 
2501   if (!lives_utf8_strcasecmp(newvpp, mainw->string_constants[LIVES_STRING_CONSTANT_NONE])) {
2502     lives_widget_set_sensitive(LIVES_WIDGET(advbutton), FALSE);
2503   } else {
2504     lives_widget_set_sensitive(LIVES_WIDGET(advbutton), TRUE);
2505 
2506     // will call set_astream_settings
2507     if ((tmpvpp = open_vid_playback_plugin(newvpp, FALSE)) == NULL) {
2508       lives_combo_set_active_string(LIVES_COMBO(vpp_combo), mainw->vpp->name);
2509       return;
2510     }
2511     close_vid_playback_plugin(tmpvpp);
2512   }
2513   lives_snprintf(future_prefs->vpp_name, 64, "%s", newvpp);
2514 
2515   if (future_prefs->vpp_argv) {
2516     register int i;
2517     for (i = 0; future_prefs->vpp_argv[i]; lives_free(future_prefs->vpp_argv[i++]));
2518     lives_free(future_prefs->vpp_argv);
2519     future_prefs->vpp_argv = NULL;
2520   }
2521   future_prefs->vpp_argc = 0;
2522 
2523   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_stream_audio), FALSE);
2524   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_rec_after_pb), FALSE);
2525 }
2526 
2527 
on_forcesmon_toggled(LiVESToggleButton * tbutton,livespointer user_data)2528 static void on_forcesmon_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2529   int gui_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_gmoni));
2530   int play_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_pmoni));
2531   lives_widget_set_sensitive(prefsw->spinbutton_gmoni, !lives_toggle_button_get_active(tbutton));
2532   lives_widget_set_sensitive(prefsw->spinbutton_pmoni, !lives_toggle_button_get_active(tbutton));
2533   lives_widget_set_sensitive(prefsw->ce_thumbs, !lives_toggle_button_get_active(tbutton) &&
2534                              play_monitor != gui_monitor &&
2535                              play_monitor != 0 && capable->nmonitors > 1);
2536 }
2537 
2538 
pmoni_gmoni_changed(LiVESWidget * sbut,livespointer user_data)2539 static void pmoni_gmoni_changed(LiVESWidget *sbut, livespointer user_data) {
2540   _prefsw *prefsw = (_prefsw *)user_data;
2541   int gui_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_gmoni));
2542   int play_monitor = lives_spin_button_get_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_pmoni));
2543   lives_widget_set_sensitive(prefsw->ce_thumbs, play_monitor != gui_monitor &&
2544                              play_monitor != 0 && !lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->forcesmon)) &&
2545                              capable->nmonitors > 1);
2546 }
2547 
2548 
on_mtbackevery_toggled(LiVESToggleButton * tbutton,livespointer user_data)2549 static void on_mtbackevery_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2550   _prefsw *xprefsw;
2551 
2552   if (user_data) xprefsw = (_prefsw *)user_data;
2553   else xprefsw = prefsw;
2554 
2555   lives_widget_set_sensitive(xprefsw->spinbutton_mt_ab_time, lives_toggle_button_get_active(tbutton));
2556 
2557 }
2558 
2559 
2560 #ifdef ENABLE_JACK_TRANSPORT
after_jack_client_toggled(LiVESToggleButton * tbutton,livespointer user_data)2561 static void after_jack_client_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2562   if (!lives_toggle_button_get_active(tbutton)) {
2563     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_start), FALSE);
2564     lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_start, FALSE);
2565   } else {
2566     lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_start, TRUE);
2567     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_start),
2568                                    (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_START) ? TRUE : FALSE);
2569   }
2570 }
2571 
2572 
after_jack_tb_start_toggled(LiVESToggleButton * tbutton,livespointer user_data)2573 static void after_jack_tb_start_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2574   if (!lives_toggle_button_get_active(tbutton)) {
2575     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_client), FALSE);
2576     lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_client, FALSE);
2577     future_prefs->jack_opts |= JACK_OPTS_TIMEBASE_START;
2578   } else {
2579     lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_client, TRUE);
2580     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_client),
2581                                    (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_CLIENT) ? TRUE : FALSE);
2582     future_prefs->jack_opts &= ~JACK_OPTS_TIMEBASE_START;
2583   }
2584 }
2585 
after_jack_master_toggled(LiVESToggleButton * tbutton,livespointer user_data)2586 static void after_jack_master_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2587   if (!lives_toggle_button_get_active(tbutton)) {
2588     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_mtb_start), FALSE);
2589     lives_widget_set_sensitive(prefsw->checkbutton_jack_mtb_start, FALSE);
2590   } else {
2591     lives_widget_set_sensitive(prefsw->checkbutton_jack_mtb_start, TRUE);
2592     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_mtb_start),
2593                                    (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_LSTART) ? TRUE : FALSE);
2594   }
2595 }
2596 #endif
2597 
2598 
2599 #ifdef ENABLE_OSC
2600 #ifdef OMC_MIDI_IMPL
2601 #ifdef ALSA_MIDI
on_alsa_midi_toggled(LiVESToggleButton * tbutton,livespointer user_data)2602 static void on_alsa_midi_toggled(LiVESToggleButton *tbutton, livespointer user_data) {
2603   _prefsw *xprefsw;
2604 
2605   if (user_data) xprefsw = (_prefsw *)user_data;
2606   else xprefsw = prefsw;
2607 
2608   lives_widget_set_sensitive(xprefsw->button_midid, !lives_toggle_button_get_active(tbutton));
2609   lives_widget_set_sensitive(xprefsw->alsa_midi_dummy, lives_toggle_button_get_active(tbutton));
2610   lives_widget_set_sensitive(xprefsw->omc_midi_entry, !lives_toggle_button_get_active(tbutton));
2611   lives_widget_set_sensitive(xprefsw->spinbutton_midicr, !lives_toggle_button_get_active(tbutton));
2612   lives_widget_set_sensitive(xprefsw->spinbutton_midirpt, !lives_toggle_button_get_active(tbutton));
2613 }
2614 #endif
2615 #endif
2616 #endif
2617 
2618 
on_audp_entry_changed(LiVESWidget * audp_combo,livespointer ptr)2619 static void on_audp_entry_changed(LiVESWidget *audp_combo, livespointer ptr) {
2620   const char *audp = lives_combo_get_active_text(LIVES_COMBO(audp_combo));
2621 
2622   if (!(*audp) || !strcmp(audp, prefsw->audp_name)) return;
2623   if (LIVES_IS_PLAYING) {
2624     do_aud_during_play_error();
2625     lives_signal_handler_block(audp_combo, prefsw->audp_entry_func);
2626 
2627     lives_combo_set_active_string(LIVES_COMBO(audp_combo), prefsw->audp_name);
2628 
2629     //lives_widget_queue_draw(audp_entry);
2630     lives_signal_handler_unblock(audp_combo, prefsw->audp_entry_func);
2631     return;
2632   }
2633 
2634 #ifdef RT_AUDIO
2635   if (!strcmp(audp, AUDIO_PLAYER_JACK) || !strcmp(audp, AUDIO_PLAYER_PULSE_AUDIO)) {
2636     lives_widget_set_sensitive(prefsw->checkbutton_aclips, TRUE);
2637     lives_widget_set_sensitive(prefsw->checkbutton_afollow, TRUE);
2638     lives_widget_set_sensitive(prefsw->raudio, TRUE);
2639     lives_widget_set_sensitive(prefsw->pa_gens, TRUE);
2640     lives_widget_set_sensitive(prefsw->rextaudio, TRUE);
2641   } else {
2642     lives_widget_set_sensitive(prefsw->checkbutton_aclips, FALSE);
2643     lives_widget_set_sensitive(prefsw->checkbutton_afollow, FALSE);
2644     lives_widget_set_sensitive(prefsw->raudio, FALSE);
2645     lives_widget_set_sensitive(prefsw->pa_gens, FALSE);
2646     lives_widget_set_sensitive(prefsw->rextaudio, FALSE);
2647     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rextaudio), FALSE);
2648   }
2649 #ifdef ENABLE_JACK
2650   if (!strcmp(audp, AUDIO_PLAYER_JACK)) {
2651     lives_widget_set_sensitive(prefsw->checkbutton_jack_pwp, TRUE);
2652     lives_widget_set_sensitive(prefsw->checkbutton_jack_read_autocon, TRUE);
2653     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_start_ajack), TRUE);
2654     lives_widget_show(prefsw->jack_int_label);
2655   } else {
2656     lives_widget_set_sensitive(prefsw->checkbutton_jack_pwp, FALSE);
2657     lives_widget_set_sensitive(prefsw->checkbutton_jack_read_autocon, FALSE);
2658     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_start_ajack), FALSE);
2659     lives_widget_hide(prefsw->jack_int_label);
2660   }
2661 #endif
2662 #ifdef HAVE_PULSE_AUDIO
2663   if (!strcmp(audp, AUDIO_PLAYER_PULSE_AUDIO)) {
2664     lives_widget_set_sensitive(prefsw->checkbutton_parestart, TRUE);
2665     lives_widget_set_sensitive(prefsw->audio_command_entry,
2666                                lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_parestart)));
2667 
2668   } else {
2669     lives_widget_set_sensitive(prefsw->checkbutton_parestart, FALSE);
2670     lives_widget_set_sensitive(prefsw->audio_command_entry, FALSE);
2671   }
2672 #endif
2673 #endif
2674   lives_free(prefsw->audp_name);
2675 
2676   prefsw->audp_name = lives_strdup(lives_combo_get_active_text(LIVES_COMBO(audp_combo)));
2677   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_stream_audio), FALSE);
2678   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_rec_after_pb), FALSE);
2679 }
2680 
2681 
stream_audio_toggled(LiVESToggleButton * togglebutton,livespointer user_data)2682 static void stream_audio_toggled(LiVESToggleButton *togglebutton, livespointer user_data) {
2683   // if audio streaming is enabled, check requisites
2684 
2685   if (lives_toggle_button_get_active(togglebutton)) {
2686     // init vpp, get audio codec, check requisites
2687     _vid_playback_plugin *tmpvpp;
2688     uint32_t orig_acodec = AUDIO_CODEC_NONE;
2689 
2690     if (*future_prefs->vpp_name) {
2691       if ((tmpvpp = open_vid_playback_plugin(future_prefs->vpp_name, FALSE)) == NULL) return;
2692     } else {
2693       tmpvpp = mainw->vpp;
2694       orig_acodec = mainw->vpp->audio_codec;
2695       get_best_audio(mainw->vpp); // check again because audio player may differ
2696     }
2697 
2698     if (tmpvpp->audio_codec != AUDIO_CODEC_NONE) {
2699       // make audiostream plugin name
2700       size_t rlen;
2701 
2702       char buf[1024];
2703       char *com;
2704 
2705       char *astreamer = lives_build_filename(prefs->lib_dir, PLUGIN_EXEC_DIR, PLUGIN_AUDIO_STREAM, AUDIO_STREAMER_NAME, NULL);
2706 
2707       com = lives_strdup_printf("\"%s\" check %d", astreamer, tmpvpp->audio_codec);
2708       lives_free(astreamer);
2709 
2710       rlen = lives_popen(com, TRUE, buf, 1024);
2711       lives_free(com);
2712       if (rlen > 0) {
2713         lives_toggle_button_set_active(togglebutton, FALSE);
2714       }
2715     }
2716 
2717     if (tmpvpp) {
2718       if (tmpvpp != mainw->vpp) {
2719         // close the temp current vpp
2720         close_vid_playback_plugin(tmpvpp);
2721       } else {
2722         // restore current codec
2723         mainw->vpp->audio_codec = orig_acodec;
2724 	// *INDENT-OFF*
2725       }}}
2726   // *INDENT-ON*
2727 }
2728 
2729 
prefsw_set_astream_settings(_vid_playback_plugin * vpp,_prefsw * prefsw)2730 void prefsw_set_astream_settings(_vid_playback_plugin * vpp, _prefsw * prefsw) {
2731   if (vpp && (vpp->audio_codec != AUDIO_CODEC_NONE || vpp->init_audio)) {
2732     lives_widget_set_sensitive(prefsw->checkbutton_stream_audio, TRUE);
2733     //lives_toggle_button_set_active (LIVES_TOGGLE_BUTTON (prefsw->checkbutton_stream_audio),future_prefs->stream_audio_out);
2734   } else {
2735     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_stream_audio), FALSE);
2736     lives_widget_set_sensitive(prefsw->checkbutton_stream_audio, FALSE);
2737   }
2738 }
2739 
2740 
prefsw_set_rec_after_settings(_vid_playback_plugin * vpp,_prefsw * prefsw)2741 void prefsw_set_rec_after_settings(_vid_playback_plugin * vpp, _prefsw * prefsw) {
2742   if (vpp && (vpp->capabilities & VPP_CAN_RETURN)) {
2743     /// TODO !!!
2744     //lives_widget_set_sensitive(prefsw->checkbutton_rec_after_pb, TRUE);
2745     //lives_toggle_button_set_active (LIVES_TOGGLE_BUTTON (prefsw->checkbutton_stream_audio),future_prefs->stream_audio_out);
2746   } else {
2747     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_rec_after_pb), FALSE);
2748     lives_widget_set_sensitive(prefsw->checkbutton_rec_after_pb, FALSE);
2749   }
2750 }
2751 
2752 
2753 /*
2754   Initialize preferences dialog list
2755 */
pref_init_list(LiVESWidget * list)2756 static void pref_init_list(LiVESWidget * list) {
2757   LiVESCellRenderer *renderer, *pixbufRenderer;
2758   LiVESTreeViewColumn *column1, *column2;
2759   LiVESListStore *store;
2760 
2761   renderer = lives_cell_renderer_text_new();
2762   pixbufRenderer = lives_cell_renderer_pixbuf_new();
2763 
2764   column1 = lives_tree_view_column_new_with_attributes("List Icons", pixbufRenderer, LIVES_TREE_VIEW_COLUMN_PIXBUF, LIST_ICON,
2765             NULL);
2766   column2 = lives_tree_view_column_new_with_attributes("List Items", renderer, LIVES_TREE_VIEW_COLUMN_TEXT, LIST_ITEM, NULL);
2767   lives_tree_view_append_column(LIVES_TREE_VIEW(list), column1);
2768   lives_tree_view_append_column(LIVES_TREE_VIEW(list), column2);
2769   lives_tree_view_column_set_sizing(column2, LIVES_TREE_VIEW_COLUMN_FIXED);
2770   lives_tree_view_column_set_fixed_width(column2, 150. * widget_opts.scale);
2771 
2772   store = lives_list_store_new(N_COLUMNS, LIVES_COL_TYPE_PIXBUF, LIVES_COL_TYPE_STRING, LIVES_COL_TYPE_UINT);
2773 
2774   lives_tree_view_set_model(LIVES_TREE_VIEW(list), LIVES_TREE_MODEL(store));
2775 }
2776 
2777 
2778 /*
2779   Adds entry to preferences dialog list
2780 */
prefs_add_to_list(LiVESWidget * list,LiVESPixbuf * pix,const char * str,uint32_t idx)2781 static void prefs_add_to_list(LiVESWidget * list, LiVESPixbuf * pix, const char *str, uint32_t idx) {
2782   LiVESListStore *store;
2783   LiVESTreeIter iter;
2784 
2785   char *tmp = lives_strdup_printf("\n  %s\n", str);
2786 
2787   store = LIVES_LIST_STORE(lives_tree_view_get_model(LIVES_TREE_VIEW(list)));
2788 
2789   lives_list_store_insert(store, &iter, idx);
2790   lives_list_store_set(store, &iter, LIST_ICON, pix, LIST_ITEM, tmp, LIST_NUM, idx, -1);
2791   lives_free(tmp);
2792 }
2793 
2794 
2795 /*
2796   Callback function called when preferences list row changed
2797 */
on_prefs_page_changed(LiVESTreeSelection * widget,_prefsw * prefsw)2798 void on_prefs_page_changed(LiVESTreeSelection * widget, _prefsw * prefsw) {
2799   LiVESTreeIter iter;
2800   LiVESTreeModel *model;
2801   char *name, *tmp;
2802 
2803   for (int i = 0; i < 2; i++) {
2804     // for some reason gtk+ needs us to do this twice..
2805     if (lives_tree_selection_get_selected(widget, &model, &iter)) {
2806 
2807       // Hide currently shown widget
2808       if (prefsw->right_shown) {
2809         lives_widget_hide(prefsw->right_shown);
2810       }
2811 
2812       switch (prefs_current_page) {
2813       case LIST_ENTRY_MULTITRACK:
2814         lives_widget_show_all(prefsw->scrollw_right_multitrack);
2815         prefsw->right_shown = prefsw->scrollw_right_multitrack;
2816         break;
2817       case LIST_ENTRY_DECODING:
2818         lives_widget_show_all(prefsw->scrollw_right_decoding);
2819         prefsw->right_shown = prefsw->scrollw_right_decoding;
2820         break;
2821       case LIST_ENTRY_PLAYBACK:
2822         lives_widget_show_all(prefsw->scrollw_right_playback);
2823         prefsw->right_shown = prefsw->scrollw_right_playback;
2824         break;
2825       case LIST_ENTRY_RECORDING:
2826         lives_widget_show_all(prefsw->scrollw_right_recording);
2827         prefsw->right_shown = prefsw->scrollw_right_recording;
2828         break;
2829       case LIST_ENTRY_ENCODING:
2830         lives_widget_show_all(prefsw->scrollw_right_encoding);
2831         prefsw->right_shown = prefsw->scrollw_right_encoding;
2832         break;
2833       case LIST_ENTRY_EFFECTS:
2834         lives_widget_show_all(prefsw->scrollw_right_effects);
2835         prefsw->right_shown = prefsw->scrollw_right_effects;
2836         break;
2837       case LIST_ENTRY_DIRECTORIES:
2838         lives_widget_show_all(prefsw->scrollw_right_directories);
2839         prefsw->right_shown = prefsw->scrollw_right_directories;
2840         break;
2841       case LIST_ENTRY_WARNINGS:
2842         lives_widget_show_all(prefsw->scrollw_right_warnings);
2843         prefsw->right_shown = prefsw->scrollw_right_warnings;
2844         break;
2845       case LIST_ENTRY_MISC:
2846         lives_widget_show_all(prefsw->scrollw_right_misc);
2847         prefsw->right_shown = prefsw->scrollw_right_misc;
2848         if (!check_for_executable(&capable->has_cdda2wav, EXEC_CDDA2WAV)
2849             && !check_for_executable(&capable->has_icedax, EXEC_ICEDAX)) {
2850           lives_widget_hide(prefsw->cdda_hbox);
2851         }
2852         break;
2853       case LIST_ENTRY_THEMES:
2854         lives_widget_show_all(prefsw->scrollw_right_themes);
2855         prefsw->right_shown = prefsw->scrollw_right_themes;
2856         break;
2857       case LIST_ENTRY_NET:
2858         lives_widget_show_all(prefsw->scrollw_right_net);
2859         prefsw->right_shown = prefsw->scrollw_right_net;
2860         break;
2861       case LIST_ENTRY_JACK:
2862         lives_widget_show_all(prefsw->scrollw_right_jack);
2863 
2864 #ifdef ENABLE_JACK
2865         if (prefs->audio_player == AUD_PLAYER_JACK) {
2866           lives_widget_show(prefsw->jack_int_label);
2867         }
2868 #endif
2869 
2870         prefsw->right_shown = prefsw->scrollw_right_jack;
2871         break;
2872       case LIST_ENTRY_MIDI:
2873         lives_widget_show_all(prefsw->scrollw_right_midi);
2874         prefsw->right_shown = prefsw->scrollw_right_midi;
2875 #ifdef OMC_MIDI_IMPL
2876 #ifndef ALSA_MIDI
2877         lives_widget_hide(prefsw->midi_hbox);
2878 #endif
2879 #endif
2880         break;
2881       case LIST_ENTRY_GUI:
2882       default:
2883         lives_widget_show_all(prefsw->scrollw_right_gui);
2884         prefsw->right_shown = prefsw->scrollw_right_gui;
2885         if (nmons > 1) {
2886           lives_widget_set_no_show_all(prefsw->forcesmon_hbox, FALSE);
2887           lives_widget_show(prefsw->forcesmon_hbox);
2888 #if !LIVES_HAS_GRID_WIDGET
2889           lives_widget_set_no_show_all(prefsw->ce_thumbs, FALSE);
2890           lives_widget_show(prefsw->ce_thumbs);
2891 #endif
2892         }
2893         prefs_current_page = LIST_ENTRY_GUI;
2894       }
2895       lives_tree_model_get(model, &iter, LIST_NUM, &prefs_current_page, LIST_ITEM, &name, -1);
2896       tmp = lives_strdup_printf("<big><b>%s</b></big>", name);
2897       widget_opts.use_markup = TRUE;
2898       lives_label_set_text(LIVES_LABEL(prefsw->tlabel), tmp);
2899       widget_opts.use_markup = FALSE;
2900       lives_free(tmp);
2901     }
2902   }
2903 
2904   lives_widget_queue_draw(prefsw->prefs_dialog);
2905 }
2906 
2907 
2908 /*
2909   Function makes apply button sensitive
2910 */
apply_button_set_enabled(LiVESWidget * widget,livespointer func_data)2911 void apply_button_set_enabled(LiVESWidget * widget, livespointer func_data) {
2912   if (prefsw->ignore_apply) return;
2913   lives_button_grab_default_special(prefsw->applybutton); // need to do this first or the button doesnt get its colour
2914   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->applybutton), TRUE);
2915   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->revertbutton), TRUE);
2916   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->closebutton), FALSE);
2917 }
2918 
2919 
spinbutton_ds_value_changed(LiVESSpinButton * warn_ds,livespointer is_critp)2920 static void spinbutton_ds_value_changed(LiVESSpinButton * warn_ds, livespointer is_critp) {
2921   boolean is_crit = LIVES_POINTER_TO_INT(is_critp);
2922   char *tmp = NULL, *tmp2;
2923   double myval = lives_spin_button_get_value(warn_ds);
2924   uint64_t umyval = (uint64_t)myval * MILLIONS(1);
2925   if (is_crit)
2926     lives_spin_button_set_range(LIVES_SPIN_BUTTON(prefsw->spinbutton_warn_ds), myval, DS_WARN_CRIT_MAX);
2927   if (myval == 0.) tmp2 = lives_strdup(mainw->string_constants[LIVES_STRING_CONSTANT_DISABLED]);
2928   else {
2929     tmp = lives_format_storage_space_string(umyval);
2930     tmp2 = lives_strdup_printf("(%s)", tmp);
2931   }
2932   if (is_crit)
2933     lives_label_set_text(LIVES_LABEL(prefsw->dsc_label), tmp2);
2934   else
2935     lives_label_set_text(LIVES_LABEL(prefsw->dsl_label), tmp2);
2936   if (tmp)lives_free(tmp);
2937   lives_free(tmp2);
2938 }
2939 
2940 
theme_widgets_set_sensitive(LiVESCombo * combo,livespointer xprefsw)2941 static void theme_widgets_set_sensitive(LiVESCombo * combo, livespointer xprefsw) {
2942   _prefsw *prefsw = (_prefsw *)xprefsw;
2943   const char *theme = lives_combo_get_active_text(combo);
2944   boolean theme_set = TRUE;
2945   if (!lives_utf8_strcmp(theme, mainw->string_constants[LIVES_STRING_CONSTANT_NONE])) theme_set = FALSE;
2946   lives_widget_set_sensitive(prefsw->cbutton_fxcol, theme_set);
2947   lives_widget_set_sensitive(prefsw->cbutton_audcol, theme_set);
2948   lives_widget_set_sensitive(prefsw->cbutton_vidcol, theme_set);
2949   lives_widget_set_sensitive(prefsw->cbutton_evbox, theme_set);
2950   lives_widget_set_sensitive(prefsw->cbutton_ceunsel, theme_set);
2951   lives_widget_set_sensitive(prefsw->cbutton_cesel, theme_set);
2952   lives_widget_set_sensitive(prefsw->fb_filebutton, theme_set);
2953   lives_widget_set_sensitive(prefsw->sepimg_entry, theme_set);
2954   lives_widget_set_sensitive(prefsw->se_filebutton, theme_set);
2955   lives_widget_set_sensitive(prefsw->frameblank_entry, theme_set);
2956   lives_widget_set_sensitive(prefsw->theme_style4, theme_set);
2957   if (prefsw->theme_style2) {
2958     lives_widget_set_sensitive(prefsw->theme_style2, theme_set);
2959   }
2960   lives_widget_set_sensitive(prefsw->theme_style3, theme_set);
2961   lives_widget_set_sensitive(prefsw->cbutton_back, theme_set);
2962   lives_widget_set_sensitive(prefsw->cbutton_fore, theme_set);
2963   lives_widget_set_sensitive(prefsw->cbutton_mab, theme_set);
2964   lives_widget_set_sensitive(prefsw->cbutton_mabf, theme_set);
2965   lives_widget_set_sensitive(prefsw->cbutton_infot, theme_set);
2966   lives_widget_set_sensitive(prefsw->cbutton_infob, theme_set);
2967   lives_widget_set_sensitive(prefsw->cbutton_infot, theme_set);
2968   lives_widget_set_sensitive(prefsw->cbutton_mtmark, theme_set);
2969   lives_widget_set_sensitive(prefsw->cbutton_tlreg, theme_set);
2970   lives_widget_set_sensitive(prefsw->cbutton_tcfg, theme_set);
2971   lives_widget_set_sensitive(prefsw->cbutton_tcbg, theme_set);
2972   lives_widget_set_sensitive(prefsw->cbutton_fsur, theme_set);
2973 }
2974 
2975 
check_txtsize(LiVESWidget * combo)2976 static boolean check_txtsize(LiVESWidget * combo) {
2977   LiVESList *list = get_textsizes_list();
2978   const char *msgtextsize = lives_combo_get_active_text(LIVES_COMBO(combo));
2979   int idx = lives_list_strcmp_index(list, (livesconstpointer)msgtextsize, TRUE);
2980   lives_list_free_all(&list);
2981 
2982   if (idx > mainw->max_textsize) {
2983     show_warn_image(combo, _("Text size may be too large for the screen size"));
2984     return TRUE;
2985   }
2986   hide_warn_image(combo);
2987   return FALSE;
2988 }
2989 
2990 
2991 /*
2992   Function creates preferences dialog
2993 */
create_prefs_dialog(LiVESWidget * saved_dialog)2994 _prefsw *create_prefs_dialog(LiVESWidget * saved_dialog) {
2995   LiVESWidget *dialog_vbox_main;
2996   LiVESWidget *dialog_table;
2997   LiVESWidget *list_scroll;
2998 
2999   LiVESPixbuf *pixbuf_multitrack;
3000   LiVESPixbuf *pixbuf_gui;
3001   LiVESPixbuf *pixbuf_decoding;
3002   LiVESPixbuf *pixbuf_playback;
3003   LiVESPixbuf *pixbuf_recording;
3004   LiVESPixbuf *pixbuf_encoding;
3005   LiVESPixbuf *pixbuf_effects;
3006   LiVESPixbuf *pixbuf_directories;
3007   LiVESPixbuf *pixbuf_warnings;
3008   LiVESPixbuf *pixbuf_misc;
3009   LiVESPixbuf *pixbuf_themes;
3010   LiVESPixbuf *pixbuf_net;
3011   LiVESPixbuf *pixbuf_jack;
3012   LiVESPixbuf *pixbuf_midi;
3013 
3014   LiVESWidget *ins_resample;
3015   LiVESWidget *hbox;
3016 
3017   LiVESWidget *layout;
3018 
3019   LiVESWidget *hbox1;
3020   LiVESWidget *vbox;
3021 
3022   LiVESWidget *dirbutton;
3023 
3024   LiVESWidget *pp_combo;
3025   LiVESWidget *png;
3026   LiVESWidget *frame;
3027   LiVESWidget *mt_enter_defs;
3028 
3029   LiVESWidget *advbutton;
3030 
3031   LiVESWidget *sp_red, *sp_green, *sp_blue;
3032 
3033 #ifdef ENABLE_OSC
3034 #ifdef OMC_MIDI_IMPL
3035   LiVESWidget *raw_midi_button;
3036 #endif
3037 #endif
3038 
3039   LiVESWidget *label;
3040 
3041   // radio button groups
3042   //LiVESSList *rb_group = NULL;
3043   LiVESSList *jpeg_png = NULL;
3044   LiVESSList *mt_enter_prompt = NULL;
3045   LiVESSList *rb_group2 = NULL;
3046 
3047 #ifdef ENABLE_OSC
3048 #ifdef OMC_MIDI_IMPL
3049   LiVESSList *alsa_midi_group = NULL;
3050   LiVESList *mchanlist = NULL;
3051 #endif
3052 #endif
3053 
3054   LiVESSList *autoback_group = NULL;
3055   LiVESSList *st_interface_group = NULL;
3056 
3057   LiVESSList *asrc_group = NULL;
3058 
3059   // drop down lists
3060   LiVESList *themes = NULL;
3061   LiVESList *ofmt = NULL;
3062   LiVESList *ofmt_all = NULL;
3063   LiVESList *audp = NULL;
3064   LiVESList *encoders = NULL;
3065   LiVESList *vid_playback_plugins = NULL;
3066   LiVESList *textsizes_list;
3067   LiVESList *rmodelist = NULL;
3068   LiVESList *radjlist = NULL;
3069 
3070   lives_colRGBA64_t rgba;
3071 
3072   char **array, **filt;
3073   char *tmp, *tmp2, *tmp3;
3074   char *theme;
3075 
3076 #ifdef ENABLE_OSC
3077 #ifdef OMC_MIDI_IMPL
3078   char *midichan;
3079 #endif
3080 #endif
3081 
3082   boolean pfsm;
3083   boolean has_ap_rec = FALSE;
3084 
3085   int woph;
3086 
3087   register int i;
3088 
3089   // Allocate memory for the preferences structure
3090   _prefsw *prefsw = (_prefsw *)(lives_malloc(sizeof(_prefsw)));
3091   prefsw->right_shown = NULL;
3092   mainw->prefs_need_restart = FALSE;
3093 
3094   prefsw->accel_group = LIVES_ACCEL_GROUP(lives_accel_group_new());
3095 
3096   woph = widget_opts.packing_height;
3097 
3098   if (!saved_dialog) {
3099     // Create new modal dialog window and set some attributes
3100     prefsw->prefs_dialog = lives_standard_dialog_new(_("Preferences"), FALSE, PREFWIN_WIDTH, PREFWIN_HEIGHT);
3101     lives_window_add_accel_group(LIVES_WINDOW(prefsw->prefs_dialog), prefsw->accel_group);
3102     lives_window_set_default_size(LIVES_WINDOW(prefsw->prefs_dialog), PREFWIN_WIDTH, PREFWIN_HEIGHT);
3103   } else prefsw->prefs_dialog = saved_dialog;
3104 
3105   prefsw->ignore_apply = FALSE;
3106   //prefs->cb_is_switch = TRUE; // TODO: intercept TOGGLED handler
3107 
3108   // Get dialog's vbox and show it
3109   dialog_vbox_main = lives_dialog_get_content_area(LIVES_DIALOG(prefsw->prefs_dialog));
3110   lives_widget_show(dialog_vbox_main);
3111 
3112   // Create dialog horizontal panels
3113   prefsw->dialog_hpaned = lives_hpaned_new();
3114   lives_widget_show(prefsw->dialog_hpaned);
3115 
3116   // Create dialog table for the right panel controls placement
3117   dialog_table = lives_vbox_new(FALSE, 0);
3118 
3119   hbox = lives_hbox_new(FALSE, 0);
3120   lives_box_pack_start(LIVES_BOX(dialog_table), hbox, FALSE, FALSE, widget_opts.packing_height);
3121   widget_opts.justify = LIVES_JUSTIFY_CENTER;
3122   prefsw->tlabel = lives_standard_label_new(NULL);
3123   lives_widget_apply_theme2(prefsw->tlabel, LIVES_WIDGET_STATE_NORMAL, TRUE);
3124   widget_opts.justify = LIVES_JUSTIFY_DEFAULT;
3125   lives_box_pack_start(LIVES_BOX(hbox), prefsw->tlabel, TRUE, TRUE, 0);
3126 
3127 #if GTK_CHECK_VERSION(3, 16, 0)
3128   if (mainw->pretty_colours) {
3129     char *colref2 = gdk_rgba_to_string(&palette->menu_and_bars);
3130     char *colref = gdk_rgba_to_string(&palette->normal_back);
3131     char *tmp = lives_strdup_printf("linear-gradient(%s, %s)", colref2, colref);
3132     set_css_value_direct(prefsw->tlabel, LIVES_WIDGET_STATE_NORMAL, "",
3133                          "background-image", tmp);
3134     lives_free(colref); lives_free(colref2);
3135     lives_free(tmp);
3136     set_css_value_direct(LIVES_WIDGET(prefsw->tlabel), LIVES_WIDGET_STATE_NORMAL, "", "border-top-left-radius", "20px");
3137     set_css_value_direct(LIVES_WIDGET(prefsw->tlabel), LIVES_WIDGET_STATE_NORMAL, "", "border-top-right-radius", "20px");
3138   }
3139 #endif
3140 
3141   lives_widget_show_all(dialog_table);
3142   lives_widget_set_no_show_all(dialog_table, TRUE);
3143 
3144   // Create preferences list with invisible headers
3145   prefsw->prefs_list = lives_tree_view_new();
3146 
3147   if (palette->style & STYLE_1) {
3148     lives_widget_apply_theme(prefsw->prefs_list, LIVES_WIDGET_STATE_SELECTED);
3149   }
3150 
3151   lives_tree_view_set_headers_visible(LIVES_TREE_VIEW(prefsw->prefs_list), FALSE);
3152 
3153   // Place panels into main vbox
3154   lives_box_pack_start(LIVES_BOX(dialog_vbox_main), prefsw->dialog_hpaned, TRUE, TRUE, 0);
3155 
3156   // Place list on the left panel
3157   pref_init_list(prefsw->prefs_list);
3158 
3159   list_scroll =
3160     lives_scrolled_window_new(lives_tree_view_get_hadjustment(LIVES_TREE_VIEW(prefsw->prefs_list)),
3161                               NULL);
3162   lives_scrolled_window_set_policy(LIVES_SCROLLED_WINDOW(list_scroll), LIVES_POLICY_AUTOMATIC,
3163                                    LIVES_POLICY_AUTOMATIC);
3164   lives_container_add(LIVES_CONTAINER(list_scroll), prefsw->prefs_list);
3165 
3166   if (palette->style & STYLE_1) {
3167     lives_widget_apply_theme3(prefsw->prefs_list, LIVES_WIDGET_STATE_NORMAL);
3168   }
3169 
3170   if (palette->style & STYLE_1) {
3171     lives_widget_apply_theme(dialog_table, LIVES_WIDGET_STATE_NORMAL);
3172     lives_widget_apply_theme(prefsw->dialog_hpaned, LIVES_WIDGET_STATE_NORMAL);
3173   }
3174 
3175   lives_paned_pack(1, LIVES_PANED(prefsw->dialog_hpaned), list_scroll, TRUE, FALSE);
3176   // Place table on the right panel
3177 
3178   lives_paned_pack(2, LIVES_PANED(prefsw->dialog_hpaned), dialog_table, TRUE, FALSE);
3179 
3180 #if GTK_CHECK_VERSION(3, 0, 0)
3181   lives_paned_set_position(LIVES_PANED(prefsw->dialog_hpaned), PREFS_PANED_POS);
3182 #else
3183   lives_paned_set_position(LIVES_PANED(prefsw->dialog_hpaned), PREFS_PANED_POS / 2);
3184 #endif
3185   // -------------------,
3186   // gui controls       |
3187   // -------------------'
3188   prefsw->vbox_right_gui = lives_vbox_new(FALSE, 0);
3189 
3190   prefsw->scrollw_right_gui = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_gui);
3191   prefsw->right_shown = prefsw->vbox_right_gui;
3192 
3193   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_gui));
3194   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3195 
3196   prefsw->fs_max_check =
3197     lives_standard_check_button_new(_("Open file selection maximised"), prefs->fileselmax, LIVES_BOX(hbox), NULL);
3198 
3199   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3200 
3201   prefsw->recent_check =
3202     lives_standard_check_button_new(_("Show recent files in the File menu"), prefs->show_recent, LIVES_BOX(hbox), NULL);
3203 
3204   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3205 
3206   prefsw->stop_screensaver_check =
3207     lives_standard_check_button_new(_("Stop screensaver on playback    "), prefs->stop_screensaver, LIVES_BOX(hbox), NULL);
3208 
3209   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3210 
3211   prefsw->open_maximised_check = lives_standard_check_button_new(_("Open main window maximised"), prefs->open_maximised,
3212                                  LIVES_BOX(hbox), NULL);
3213 
3214   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3215 
3216   prefsw->show_tool =
3217     lives_standard_check_button_new(_("Show toolbar when background is blanked"), prefs->show_tool, LIVES_BOX(hbox), NULL);
3218 
3219   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3220 
3221   prefsw->mouse_scroll =
3222     lives_standard_check_button_new(_("Allow mouse wheel to switch clips"), prefs->mouse_scroll_clips, LIVES_BOX(hbox), NULL);
3223 
3224   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3225 
3226   prefsw->checkbutton_ce_maxspect =
3227     lives_standard_check_button_new(_("Shrink previews to fit in interface"), prefs->ce_maxspect, LIVES_BOX(hbox),
3228                                     (tmp = H_("Setting is assumed automatically if letterbox playback is enabled")));
3229   lives_free(tmp);
3230 
3231   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3232 
3233   prefsw->checkbutton_hfbwnp =
3234     lives_standard_check_button_new(_("Hide framebar when not playing"), prefs->hfbwnp, LIVES_BOX(hbox), NULL);
3235 
3236   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3237 
3238 #if GTK_CHECK_VERSION(2, 12, 0)
3239   prefsw->checkbutton_show_ttips =
3240     lives_standard_check_button_new(_("Show tooltips"), prefs->show_tooltips, LIVES_BOX(hbox), NULL);
3241 #else
3242   prefsw->checkbutton_show_ttips = NULL;
3243 #endif
3244 
3245   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3246 
3247   prefsw->checkbutton_show_asrc =
3248     lives_standard_check_button_new(_("Show audio source in toolbar"), prefs->show_asrc, LIVES_BOX(hbox), NULL);
3249 
3250   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_gui));
3251 
3252   hbox = lives_hbox_new(FALSE, 0);
3253   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_gui), hbox, FALSE, FALSE, widget_opts.packing_height);
3254   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_gui));
3255 
3256   label = lives_standard_label_new(_("Startup mode:"));
3257   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, TRUE, 0);
3258 
3259   add_fill_to_box(LIVES_BOX(hbox));
3260 
3261   prefsw->rb_startup_ce = lives_standard_radio_button_new(_("_Clip editor"), &st_interface_group, LIVES_BOX(hbox), NULL);
3262 
3263   add_fill_to_box(LIVES_BOX(hbox));
3264 
3265   prefsw->rb_startup_mt = lives_standard_radio_button_new(_("_Multitrack mode"), &st_interface_group, LIVES_BOX(hbox), NULL);
3266 
3267   if (prefs->vj_mode)
3268     show_warn_image(prefsw->rb_startup_mt, _("Disabled in VJ mode"));
3269 
3270   if (future_prefs->startup_interface == STARTUP_MT) {
3271     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rb_startup_mt), TRUE);
3272   } else {
3273     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rb_startup_ce), TRUE);
3274   }
3275 
3276   add_fill_to_box(LIVES_BOX(hbox));
3277 
3278   //
3279   // multihead support (inside Gui part)
3280   //
3281 
3282   pfsm = prefs->force_single_monitor;
3283   prefs->force_single_monitor = FALSE;
3284   get_monitors(FALSE);
3285   nmons = capable->nmonitors;
3286 
3287   label = lives_standard_label_new(_("Multi-head support"));
3288   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_gui), label, FALSE, FALSE, widget_opts.packing_height);
3289 
3290   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_gui));
3291   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3292 
3293   prefsw->spinbutton_gmoni = lives_standard_spin_button_new(_("Monitor number for LiVES interface"), prefs->gui_monitor, 1, nmons,
3294                              1., 1., 0, LIVES_BOX(hbox), NULL);
3295 
3296   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3297 
3298   prefsw->spinbutton_pmoni =
3299     lives_standard_spin_button_new(_("Monitor number for playback"),
3300                                    prefs->play_monitor, 0,
3301                                    nmons == 1 ? 0 : nmons, 1., 1., 0, LIVES_BOX(hbox),
3302                                    (tmp = lives_strdup(H_("A setting of 0 means use all available "
3303                                           "monitors (only works with some playback "
3304                                           "plugins)."))));
3305   lives_free(tmp);
3306   prefs->force_single_monitor = pfsm;
3307 
3308   add_fill_to_box(LIVES_BOX(hbox));
3309 
3310   prefsw->forcesmon_hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3311 
3312   prefsw->forcesmon = lives_standard_check_button_new((tmp = (_("Force single monitor"))),
3313                       prefs->force_single_monitor, LIVES_BOX(prefsw->forcesmon_hbox),
3314                       (tmp2 = (_("Ignore all except the first monitor."))));
3315   lives_free(tmp);
3316   lives_free(tmp2);
3317 
3318   lives_widget_set_no_show_all(prefsw->forcesmon, TRUE);
3319 
3320   if (nmons <= 1) {
3321     lives_widget_set_sensitive(prefsw->spinbutton_gmoni, FALSE);
3322     lives_widget_set_sensitive(prefsw->spinbutton_pmoni, FALSE);
3323   }
3324 
3325   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->forcesmon), LIVES_WIDGET_TOGGLED_SIGNAL,
3326                             LIVES_GUI_CALLBACK(on_forcesmon_toggled), NULL);
3327 
3328   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3329 
3330   prefsw->ce_thumbs = lives_standard_check_button_new(_("Show clip thumbnails during playback"), prefs->ce_thumb_mode,
3331                       LIVES_BOX(hbox), NULL);
3332   lives_widget_set_no_show_all(prefsw->ce_thumbs, TRUE);
3333 
3334   lives_widget_set_sensitive(prefsw->ce_thumbs, prefs->play_monitor != prefs->gui_monitor &&
3335                              prefs->play_monitor != 0 && !prefs->force_single_monitor &&
3336                              capable->nmonitors > 1);
3337 
3338   pmoni_gmoni_changed(NULL, (livespointer)prefsw);
3339 
3340   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_gui));
3341 
3342   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_gui));
3343   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3344 
3345   prefsw->nmessages_spin = lives_standard_spin_button_new(_("Number of _Info Messages to Buffer"),
3346                            ABS(prefs->max_messages), 0., 100000., 1., 1., 0,
3347                            LIVES_BOX(hbox), NULL);
3348   ACTIVE(nmessages_spin, VALUE_CHANGED);
3349 
3350   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3351   prefsw->msgs_unlimited = lives_standard_check_button_new(_("_Unlimited"),
3352                            prefs->max_messages < 0, LIVES_BOX(hbox), NULL);
3353 
3354   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->msgs_unlimited), prefsw->nmessages_spin, TRUE);
3355   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->nmessages_spin), LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
3356                             LIVES_GUI_CALLBACK(widget_inact_toggle), prefsw->msgs_unlimited);
3357   ACTIVE(msgs_unlimited, TOGGLED);
3358 
3359   textsizes_list = get_textsizes_list();
3360 
3361   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3362   prefsw->msg_textsize_combo = lives_standard_combo_new(_("Message Area _Font Size"), textsizes_list,
3363                                LIVES_BOX(hbox), NULL);
3364 
3365   lives_combo_set_active_index(LIVES_COMBO(prefsw->msg_textsize_combo), prefs->msg_textsize);
3366 
3367   check_txtsize(prefsw->msg_textsize_combo);
3368   lives_signal_connect_after(LIVES_WIDGET_OBJECT(prefsw->msg_textsize_combo), LIVES_WIDGET_CHANGED_SIGNAL,
3369                              LIVES_GUI_CALLBACK(check_txtsize), NULL);
3370 
3371   lives_list_free_all(&textsizes_list);
3372 
3373   ACTIVE(msg_textsize_combo, CHANGED);
3374 
3375   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3376   prefsw->msgs_pbdis = lives_standard_check_button_new(_("_Disable message output during playback"),
3377                        prefs->msgs_pbdis, LIVES_BOX(hbox), NULL);
3378   ACTIVE(msgs_pbdis, TOGGLED);
3379 
3380   pixbuf_gui = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_GUI, LIVES_ICON_SIZE_CUSTOM, -1, -1);
3381 
3382   prefs_add_to_list(prefsw->prefs_list, pixbuf_gui, _("GUI"), LIST_ENTRY_GUI);
3383   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_gui);
3384 
3385   // -----------------------,
3386   // multitrack controls    |
3387   // -----------------------'
3388 
3389   prefsw->vbox_right_multitrack = lives_vbox_new(FALSE, 0);
3390   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_multitrack), widget_opts.border_width * 2);
3391 
3392   prefsw->scrollw_right_multitrack = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_multitrack);
3393 
3394   hbox = lives_hbox_new(FALSE, 0);
3395   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_multitrack), hbox, FALSE, FALSE, widget_opts.packing_height);
3396 
3397   label = lives_standard_label_new(_("When entering Multitrack mode:"));
3398   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
3399 
3400   add_fill_to_box(LIVES_BOX(hbox));
3401 
3402   hbox = lives_hbox_new(FALSE, 0);
3403   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_multitrack), hbox, FALSE, FALSE, widget_opts.packing_height);
3404 
3405   prefsw->mt_enter_prompt = lives_standard_radio_button_new(_("_Prompt me for width, height, fps and audio settings"),
3406                             &mt_enter_prompt, LIVES_BOX(hbox), NULL);
3407 
3408   mt_enter_defs = lives_standard_radio_button_new(_("_Always use the following values:"),
3409                   &mt_enter_prompt, LIVES_BOX(hbox), NULL);
3410 
3411   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(mt_enter_defs), !prefs->mt_enter_prompt);
3412 
3413   hbox = lives_hbox_new(FALSE, 0);
3414   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_multitrack), hbox, FALSE, FALSE, 0);
3415 
3416   prefsw->checkbutton_render_prompt = lives_standard_check_button_new(_("Use these same _values for rendering a new clip"),
3417                                       !prefs->render_prompt, LIVES_BOX(hbox), NULL);
3418 
3419   frame = add_video_options(&prefsw->spinbutton_mt_def_width, mainw->multitrack == NULL ? prefs->mt_def_width : cfile->hsize,
3420                             &prefsw->spinbutton_mt_def_height,
3421                             mainw->multitrack == NULL ? prefs->mt_def_height : cfile->vsize, &prefsw->spinbutton_mt_def_fps,
3422                             mainw->multitrack == NULL ? prefs->mt_def_fps : cfile->fps, NULL, 0, FALSE, NULL);
3423 
3424   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_multitrack), frame, FALSE, FALSE, widget_opts.packing_height);
3425 
3426   hbox = add_audio_options(&prefsw->backaudio_checkbutton, &prefsw->pertrack_checkbutton);
3427 
3428   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->backaudio_checkbutton), prefs->mt_backaudio > 0);
3429   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->pertrack_checkbutton), prefs->mt_pertrack_audio);
3430 
3431   // must be done after creating check buttons
3432   resaudw = create_resaudw(4, NULL, prefsw->vbox_right_multitrack);
3433 
3434   // must be done after resaudw
3435   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_multitrack), hbox, FALSE, FALSE, widget_opts.packing_height);
3436 
3437   lives_widget_set_sensitive(prefsw->backaudio_checkbutton,
3438                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(resaudw->aud_checkbutton)));
3439 
3440   lives_widget_set_sensitive(prefsw->pertrack_checkbutton,
3441                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(resaudw->aud_checkbutton)));
3442 
3443   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_multitrack));
3444 
3445   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_multitrack));
3446   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3447 
3448   prefsw->spinbutton_mt_undo_buf = lives_standard_spin_button_new(_("_Undo buffer size (MB)"),
3449                                    prefs->mt_undo_buf, 0., ONE_MILLION, 1., 1., 0,
3450                                    LIVES_BOX(hbox), NULL);
3451 
3452   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3453   prefsw->checkbutton_mt_exit_render = lives_standard_check_button_new(_("_Exit multitrack mode after rendering"),
3454                                        prefs->mt_exit_render, LIVES_BOX(hbox), NULL);
3455 
3456   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3457   label = lives_standard_label_new(_("Auto backup layouts:"));
3458   lives_box_pack_end(LIVES_BOX(hbox), label, FALSE, TRUE, widget_opts.packing_width * 2);
3459 
3460   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3461   int wopw = widget_opts.packing_width;
3462   widget_opts.packing_width >>= 1;
3463   prefsw->mt_autoback_every = lives_standard_radio_button_new(_("_Every"), &autoback_group, LIVES_BOX(hbox), NULL);
3464 
3465   widget_opts.swap_label = TRUE;
3466   prefsw->spinbutton_mt_ab_time = lives_standard_spin_button_new(_("seconds"), 120., 10., 1800., 1., 10., 0, LIVES_BOX(hbox),
3467                                   NULL);
3468   widget_opts.swap_label = FALSE;
3469   widget_opts.packing_width = wopw;
3470 
3471   lives_layout_add_fill(LIVES_LAYOUT(layout), TRUE);
3472   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3473   prefsw->mt_autoback_always = lives_standard_radio_button_new(_("After every _change"),
3474                                &autoback_group, LIVES_BOX(hbox), NULL);
3475 
3476   lives_layout_add_fill(LIVES_LAYOUT(layout), TRUE);
3477   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3478   prefsw->mt_autoback_never = lives_standard_radio_button_new(_("_Never"), &autoback_group, LIVES_BOX(hbox), NULL);
3479 
3480   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->mt_autoback_every), LIVES_WIDGET_TOGGLED_SIGNAL,
3481                             LIVES_GUI_CALLBACK(on_mtbackevery_toggled), prefsw);
3482 
3483   if (prefs->mt_auto_back == 0) {
3484     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->mt_autoback_always), TRUE);
3485   } else if (prefs->mt_auto_back == -1) {
3486     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->mt_autoback_never), TRUE);
3487   } else {
3488     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->mt_autoback_every), TRUE);
3489     lives_spin_button_set_value(LIVES_SPIN_BUTTON(prefsw->spinbutton_mt_ab_time), prefs->mt_auto_back);
3490   }
3491 
3492   lives_layout_add_fill(LIVES_LAYOUT(layout), FALSE);
3493 
3494   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3495   prefsw->spinbutton_max_disp_vtracks = lives_standard_spin_button_new(_("Maximum number of visible tracks"),
3496                                         prefs->max_disp_vtracks, 5., 15.,
3497                                         1., 1., 0, LIVES_BOX(hbox), NULL);
3498 
3499   pixbuf_multitrack = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_MULTITRACK, LIVES_ICON_SIZE_CUSTOM, -1, -1);
3500 
3501   prefs_add_to_list(prefsw->prefs_list, pixbuf_multitrack, _("Multitrack/Render"), LIST_ENTRY_MULTITRACK);
3502   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_multitrack);
3503 
3504   // ---------------,
3505   // decoding       |
3506   // ---------------'
3507 
3508   prefsw->vbox_right_decoding = lives_vbox_new(FALSE, 0);
3509   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_decoding), widget_opts.border_width * 2);
3510 
3511   prefsw->scrollw_right_decoding = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_decoding);
3512 
3513   hbox = lives_hbox_new(FALSE, 0);
3514   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3515 
3516   prefsw->checkbutton_instant_open =
3517     lives_standard_check_button_new((tmp = (_("Use instant opening when possible"))),
3518                                     prefs->instant_open, LIVES_BOX(hbox),
3519                                     (tmp2 = (H_("Enable instant opening of some file types using decoder plugins"))));
3520 
3521   lives_free(tmp);
3522   lives_free(tmp2);
3523 
3524   // advanced instant opening
3525   advbutton = lives_standard_button_new_from_stock_full(LIVES_STOCK_PREFERENCES, _("_Advanced"),
3526               DEF_BUTTON_WIDTH, DEF_BUTTON_HEIGHT, LIVES_BOX(hbox), TRUE, NULL);
3527 
3528   lives_signal_sync_connect(LIVES_GUI_OBJECT(advbutton), LIVES_WIDGET_CLICKED_SIGNAL,
3529                             LIVES_GUI_CALLBACK(on_decplug_advanced_clicked), NULL);
3530 
3531   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_instant_open), advbutton, FALSE);
3532 
3533   hbox = lives_hbox_new(FALSE, 0);
3534   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3535 
3536   prefsw->video_open_entry = lives_standard_entry_new(_("Video open command (fallback)"),
3537                              prefs->video_open_command, -1, PATH_MAX * 2,
3538                              LIVES_BOX(hbox), NULL);
3539 
3540   hbox = lives_hbox_new(FALSE, 0);
3541   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3542 
3543   label = lives_standard_label_new_with_tooltips(_("Fallback image format"), LIVES_BOX(hbox),
3544           _("The image format to be used when opening clips\n"
3545             "for which there is no instant decoder candidate."));
3546 
3547   add_fill_to_box(LIVES_BOX(hbox));
3548 
3549   prefsw->jpeg = lives_standard_radio_button_new(_("_jpeg"), &jpeg_png, LIVES_BOX(hbox), NULL);
3550 
3551   add_fill_to_box(LIVES_BOX(hbox));
3552 
3553   png = lives_standard_radio_button_new(_("_png"), &jpeg_png, LIVES_BOX(hbox), NULL);
3554   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(png), !strcmp(prefs->image_ext, LIVES_FILE_EXT_PNG));
3555 
3556   hbox = lives_hbox_new(FALSE, 0);
3557   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height * 2);
3558 
3559   label = lives_standard_label_new(_("(Check Help/Troubleshoot to see which image formats are supported)"));
3560   lives_box_pack_start(LIVES_BOX(hbox), label, TRUE, TRUE, widget_opts.packing_width);
3561 
3562   if (prefs->ocp == -1) prefs->ocp = get_int_pref(PREF_OPEN_COMPRESSION_PERCENT);
3563 
3564   hbox = lives_hbox_new(FALSE, 0);
3565   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3566 
3567   label = lives_standard_label_new(_("Image compression"));
3568   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
3569 
3570   widget_opts.swap_label = TRUE;
3571   widget_opts.expand = LIVES_EXPAND_DEFAULT_HEIGHT;
3572   prefsw->spinbutton_ocp =
3573     lives_standard_spin_button_new(("  %  "), prefs->ocp, 0., 60., 1., 5., 0, LIVES_BOX(hbox),
3574                                    (tmp = H_("A higher value will require less disk space\n"
3575                                           "but may slow down the application.\n"
3576                                           "For jpeg, a higher value may lead to\n"
3577                                           "loss of image quality\n"
3578                                           "The default value of 15 is recommended")));
3579   lives_free(tmp);
3580   widget_opts.swap_label = FALSE;
3581   widget_opts.expand = LIVES_EXPAND_DEFAULT;
3582 
3583   add_fill_to_box(LIVES_BOX(hbox));
3584   add_fill_to_box(LIVES_BOX(hbox));
3585 
3586   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_decoding));
3587 
3588   hbox = lives_hbox_new(FALSE, 0);
3589   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3590 
3591   prefsw->checkbutton_auto_deint = lives_standard_check_button_new((tmp = lives_strdup(
3592                                      _("Enable automatic deinterlacing when possible"))),
3593                                    prefs->auto_deint, LIVES_BOX(hbox),
3594                                    (tmp2 = (_("Automatically deinterlace frames when a plugin suggests it"))));
3595   lives_free(tmp);
3596   lives_free(tmp2);
3597 
3598   hbox = lives_hbox_new(FALSE, 0);
3599   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3600 
3601   prefsw->checkbutton_auto_trim = lives_standard_check_button_new((tmp = lives_strdup(
3602                                     _("Automatic trimming / padding of audio when possible"))),
3603                                   prefs->auto_trim_audio, LIVES_BOX(hbox),
3604                                   (tmp2 = (_("Automatically trim or pad audio when a plugin suggests it"))));
3605   lives_free(tmp);
3606   lives_free(tmp2);
3607 
3608 
3609   hbox = lives_hbox_new(FALSE, 0);
3610   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3611 
3612   prefsw->checkbutton_nobord = lives_standard_check_button_new((tmp = (_("Ignore blank borders when possible"))),
3613                                prefs->auto_nobord, LIVES_BOX(hbox),
3614                                (tmp2 = (_("Clip any blank borders from frames where possible"))));
3615   lives_free(tmp);
3616   lives_free(tmp2);
3617 
3618 
3619   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_decoding));
3620 
3621   hbox = lives_hbox_new(FALSE, 0);
3622   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_decoding), hbox, FALSE, FALSE, widget_opts.packing_height);
3623 
3624   prefsw->checkbutton_concat_images = lives_standard_check_button_new(
3625                                         _("When opening multiple files, concatenate images into one clip"),
3626                                         prefs->concat_images, LIVES_BOX(hbox), NULL);
3627 
3628   pixbuf_decoding = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_DECODING, LIVES_ICON_SIZE_CUSTOM, -1, -1);
3629 
3630   prefs_add_to_list(prefsw->prefs_list, pixbuf_decoding, _("Decoding"), LIST_ENTRY_DECODING);
3631 
3632   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_decoding);
3633 
3634   // ---------------,
3635   // playback       |
3636   // ---------------'
3637 
3638   prefsw->vbox_right_playback = lives_vbox_new(FALSE, 0);
3639 
3640   prefsw->scrollw_right_playback = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_playback);
3641 
3642   frame = lives_standard_frame_new(_("VIDEO"), 0., FALSE);
3643 
3644   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_playback), frame, FALSE, FALSE, 0);
3645 
3646   vbox = lives_vbox_new(FALSE, 0);
3647   lives_container_add(LIVES_CONTAINER(frame), vbox);
3648   lives_container_set_border_width(LIVES_CONTAINER(vbox), widget_opts.border_width);
3649 
3650   layout = lives_layout_new(LIVES_BOX(vbox));
3651   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3652 
3653   prefsw->pbq_adaptive =
3654     lives_standard_check_button_new(
3655       (tmp = lives_strdup_printf(_("_Enable adaptive quality (%s)"),
3656                                  mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED])),
3657       prefs->pbq_adaptive, LIVES_BOX(hbox),
3658       (tmp2 = (H_("If enabled, quality will be automatically adjusted during playback\n"
3659                   "in order to maintain a smooth frame rate"))));
3660   lives_free(tmp);
3661   lives_free(tmp2);
3662 
3663   prefsw->pbq_list = NULL;
3664   // TRANSLATORS: video quality, max len 50
3665   prefsw->pbq_list = lives_list_append(prefsw->pbq_list, (_("Low - can improve performance on slower machines")));
3666   // TRANSLATORS: video quality, max len 50
3667   prefsw->pbq_list = lives_list_append(prefsw->pbq_list, (_("Normal - recommended for most users")));
3668   // TRANSLATORS: video quality, max len 50
3669   prefsw->pbq_list = lives_list_append(prefsw->pbq_list, (_("High - can improve quality on very fast machines")));
3670 
3671   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3672 
3673   //widget_opts.expand = LIVES_EXPAND_EXTRA;
3674   prefsw->pbq_combo = lives_standard_combo_new((tmp = (_("Preview _quality"))), prefsw->pbq_list, LIVES_BOX(hbox),
3675                       (tmp2 = (_("The preview quality for video playback - affects resizing"))));
3676   //widget_opts.expand = LIVES_EXPAND_DEFAULT;
3677 
3678   lives_free(tmp);
3679   lives_free(tmp2);
3680 
3681   switch (future_prefs->pb_quality) {
3682   case PB_QUALITY_HIGH:
3683     lives_combo_set_active_index(LIVES_COMBO(prefsw->pbq_combo), 2);
3684     break;
3685   case PB_QUALITY_MED:
3686     lives_combo_set_active_index(LIVES_COMBO(prefsw->pbq_combo), 1);
3687   }
3688 
3689   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3690 
3691   prefsw->checkbutton_show_stats = lives_standard_check_button_new(_("_Show FPS statistics"),
3692                                    prefs->show_player_stats,
3693                                    LIVES_BOX(hbox), NULL);
3694 
3695   add_hsep_to_box(LIVES_BOX(vbox));
3696 
3697   layout = lives_layout_new(LIVES_BOX(vbox));
3698 
3699   lives_layout_add_label(LIVES_LAYOUT(layout), _("Use letterboxing by default:"), TRUE);
3700 
3701   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3702   prefsw->checkbutton_lb = lives_standard_check_button_new(_("In Clip Edit Mode"),
3703                            prefs->letterbox, LIVES_BOX(hbox), NULL);
3704 
3705   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3706   prefsw->checkbutton_lbmt = lives_standard_check_button_new(_("In Multitrack Mode"),
3707                              future_prefs->letterbox_mt, LIVES_BOX(hbox),
3708                              (tmp = H_("This setting only affects newly created layouts.\nTo change the current layout, use menu option\n'Tools' / 'Change Width, Height and Audio Values'\nin the multitrack window")));
3709   lives_free(tmp);
3710 
3711   lives_layout_add_row(LIVES_LAYOUT(layout));
3712   lives_layout_add_label(LIVES_LAYOUT(layout), _("Monitor gamma setting:"), TRUE);
3713 
3714   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3715   prefsw->checkbutton_screengamma = lives_standard_check_button_new(_("Apply screen gamma"),
3716                                     prefs->use_screen_gamma, LIVES_BOX(hbox), NULL);
3717 
3718   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3719   prefsw->spinbutton_gamma = lives_standard_spin_button_new(_("Screen gamma value"),
3720                              prefs->screen_gamma, 1.2, 3.0, .01, .1, 2,
3721                              LIVES_BOX(hbox), NULL);
3722 
3723   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_screengamma), prefsw->spinbutton_gamma, FALSE);
3724 
3725   add_hsep_to_box(LIVES_BOX(vbox));
3726 
3727   layout = lives_layout_new(LIVES_BOX(vbox));
3728   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3729 
3730   vid_playback_plugins = get_plugin_list(PLUGIN_VID_PLAYBACK, TRUE, NULL, "-" DLL_NAME);
3731   vid_playback_plugins = lives_list_prepend(vid_playback_plugins,
3732                          lives_strdup(mainw->string_constants[LIVES_STRING_CONSTANT_NONE]));
3733 
3734   pp_combo = lives_standard_combo_new(_("_Plugin"), vid_playback_plugins, LIVES_BOX(hbox), NULL);
3735 
3736   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3737   advbutton = lives_standard_button_new_from_stock_full(LIVES_STOCK_PREFERENCES, _("_Advanced"),
3738               DEF_BUTTON_WIDTH, DEF_BUTTON_HEIGHT, LIVES_BOX(hbox), TRUE, NULL);
3739 
3740   lives_signal_connect(LIVES_GUI_OBJECT(advbutton), LIVES_WIDGET_CLICKED_SIGNAL,
3741                        LIVES_GUI_CALLBACK(on_vpp_advanced_clicked),
3742                        LIVES_INT_TO_POINTER(LIVES_INTENTION_PLAY));
3743 
3744   if (mainw->vpp) {
3745     lives_combo_set_active_string(LIVES_COMBO(pp_combo), mainw->vpp->name);
3746   } else {
3747     lives_combo_set_active_index(LIVES_COMBO(pp_combo), 0);
3748     lives_widget_set_sensitive(advbutton, FALSE);
3749   }
3750   lives_list_free_all(&vid_playback_plugins);
3751 
3752   lives_signal_sync_connect_after(LIVES_WIDGET_OBJECT(pp_combo), LIVES_WIDGET_CHANGED_SIGNAL,
3753                                   LIVES_GUI_CALLBACK(after_vpp_changed), (livespointer) advbutton);
3754 
3755   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3756 
3757   prefsw->checkbutton_stream_audio =
3758     lives_standard_check_button_new((tmp = (_("Stream audio"))), prefs->stream_audio_out, LIVES_BOX(hbox),
3759                                     (tmp2 = _("Stream audio to playback plugin")));
3760   lives_free(tmp); lives_free(tmp2);
3761 
3762   prefsw_set_astream_settings(mainw->vpp, prefsw);
3763 
3764   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->checkbutton_stream_audio), LIVES_WIDGET_TOGGLED_SIGNAL,
3765                             LIVES_GUI_CALLBACK(stream_audio_toggled), NULL);
3766 
3767   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3768 
3769   prefsw->checkbutton_rec_after_pb =
3770     lives_standard_check_button_new((tmp = (_("Record player output"))),
3771                                     (prefs->rec_opts & REC_AFTER_PB), LIVES_BOX(hbox),
3772                                     (tmp2 = lives_strdup
3773                                         (_("Record output from player instead of input to player"))));
3774   lives_free(tmp); lives_free(tmp2);
3775 
3776   /// TODO !!!
3777   lives_widget_set_sensitive(prefsw->checkbutton_rec_after_pb, FALSE);
3778 
3779   prefsw_set_rec_after_settings(mainw->vpp, prefsw);
3780 
3781   //-
3782 
3783   frame = lives_standard_frame_new(_("AUDIO"), 0., FALSE);
3784 
3785   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_playback), frame, FALSE, FALSE, widget_opts.packing_height);
3786 
3787   vbox = lives_vbox_new(FALSE, 0);
3788   lives_container_add(LIVES_CONTAINER(frame), vbox);
3789 
3790   audp = lives_list_append(audp, lives_strdup_printf("%s", mainw->string_constants[LIVES_STRING_CONSTANT_NONE]));
3791 
3792 #ifdef HAVE_PULSE_AUDIO
3793   audp = lives_list_append(audp, lives_strdup_printf("%s (%s)", AUDIO_PLAYER_PULSE_AUDIO,
3794                            mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]));
3795   has_ap_rec = TRUE;
3796 #endif
3797 
3798 #ifdef ENABLE_JACK
3799   if (!has_ap_rec) audp = lives_list_append(audp, lives_strdup_printf("%s (%s)", AUDIO_PLAYER_JACK,
3800                             mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]));
3801   else audp = lives_list_append(audp, lives_strdup_printf(AUDIO_PLAYER_JACK));
3802   has_ap_rec = TRUE;
3803 #endif
3804 
3805   if (capable->has_sox_play) {
3806     if (has_ap_rec) audp = lives_list_append(audp, lives_strdup(AUDIO_PLAYER_SOX));
3807     else audp = lives_list_append(audp, lives_strdup_printf("%s (%s)", AUDIO_PLAYER_SOX,
3808                                     mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]));
3809   }
3810 
3811   layout = lives_layout_new(LIVES_BOX(vbox));
3812   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3813 
3814   prefsw->audp_combo = lives_standard_combo_new(_("_Player"), audp, LIVES_BOX(hbox), NULL);
3815 
3816   has_ap_rec = FALSE;
3817 
3818   lives_layout_add_row(LIVES_LAYOUT(layout));
3819 
3820   prefsw->jack_int_label =
3821     lives_layout_add_label(LIVES_LAYOUT(layout), _("(See also the Jack Integration tab for jack startup options)"), TRUE);
3822   lives_widget_set_no_show_all(prefsw->jack_int_label, TRUE);
3823 
3824   prefsw->audp_name = NULL;
3825 
3826   if (prefs->audio_player == AUD_PLAYER_NONE) {
3827     prefsw->audp_name = lives_strdup_printf("%s", mainw->string_constants[LIVES_STRING_CONSTANT_NONE]);
3828   }
3829 
3830 #ifdef HAVE_PULSE_AUDIO
3831   if (prefs->audio_player == AUD_PLAYER_PULSE) {
3832     prefsw->audp_name = lives_strdup_printf("%s (%s)", AUDIO_PLAYER_PULSE_AUDIO,
3833                                             mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]);
3834   }
3835   has_ap_rec = TRUE;
3836 #endif
3837 
3838 #ifdef ENABLE_JACK
3839   if (prefs->audio_player == AUD_PLAYER_JACK) {
3840     if (!has_ap_rec)
3841       prefsw->audp_name = lives_strdup_printf("%s (%s)", AUDIO_PLAYER_JACK,
3842                                               mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]);
3843     else prefsw->audp_name = lives_strdup_printf(AUDIO_PLAYER_JACK);
3844   }
3845   has_ap_rec = TRUE;
3846 #endif
3847 
3848   if (prefs->audio_player == AUD_PLAYER_SOX) {
3849     if (!has_ap_rec) prefsw->audp_name = lives_strdup_printf("%s (%s)", AUDIO_PLAYER_SOX,
3850                                            mainw->string_constants[LIVES_STRING_CONSTANT_RECOMMENDED]);
3851     else prefsw->audp_name = lives_strdup_printf(AUDIO_PLAYER_SOX);
3852   }
3853 
3854   if (prefsw->audp_name)
3855     lives_combo_set_active_string(LIVES_COMBO(prefsw->audp_combo), prefsw->audp_name);
3856   prefsw->orig_audp_name = lives_strdup(prefsw->audp_name);
3857 
3858   //---
3859 
3860 #ifdef HAVE_PULSE_AUDIO
3861   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3862 
3863   prefsw->checkbutton_parestart = lives_standard_check_button_new((tmp = (_("Restart pulseaudio on LiVES startup"))),
3864                                   prefs->pa_restart, LIVES_BOX(hbox),
3865                                   (tmp2 = (_("Recommended, but may interfere with other running "
3866                                           "audio applications"))));
3867   lives_free(tmp);
3868   lives_free(tmp2);
3869   ACTIVE(checkbutton_parestart, TOGGLED);
3870 
3871   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3872   tmp = lives_strdup_printf(_("Pulseaudio restart command: %s -k"), EXEC_PULSEAUDIO);
3873   prefsw->audio_command_entry = lives_standard_entry_new(tmp, prefs->pa_start_opts, SHORT_ENTRY_WIDTH, PATH_MAX * 2,
3874                                 LIVES_BOX(hbox), NULL);
3875   ACTIVE(audio_command_entry, CHANGED);
3876   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_parestart), prefsw->audio_command_entry, FALSE);
3877 #endif
3878 
3879   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3880 
3881   prefsw->checkbutton_afollow = lives_standard_check_button_new(_("Audio follows video _rate/direction"),
3882                                 (prefs->audio_opts & AUDIO_OPTS_FOLLOW_FPS) ? TRUE : FALSE, LIVES_BOX(hbox), NULL);
3883 
3884   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3885 
3886   prefsw->checkbutton_aclips = lives_standard_check_button_new(_("Audio follows _clip switches"),
3887                                (prefs->audio_opts & AUDIO_OPTS_FOLLOW_CLIPS) ? TRUE : FALSE, LIVES_BOX(hbox), NULL);
3888 
3889   add_hsep_to_box(LIVES_BOX(vbox));
3890 
3891   hbox = lives_hbox_new(FALSE, 0);
3892   lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0);
3893   label = lives_standard_label_new(_("Audio Source (clip editor only):"));
3894   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
3895   add_fill_to_box(LIVES_BOX(hbox));
3896   add_fill_to_box(LIVES_BOX(vbox));
3897 
3898   prefsw->rintaudio = lives_standard_radio_button_new(_("_Internal"), &asrc_group, LIVES_BOX(hbox), NULL);
3899 
3900   add_fill_to_box(LIVES_BOX(hbox));
3901 
3902   prefsw->rextaudio = lives_standard_radio_button_new(_("_External [monitor]"),
3903                       &asrc_group, LIVES_BOX(hbox), NULL);
3904 
3905   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->rextaudio), future_prefs->audio_src == AUDIO_SRC_EXT);
3906   add_fill_to_box(LIVES_BOX(hbox));
3907 
3908   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rextaudio), prefsw->checkbutton_aclips, TRUE);
3909   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rextaudio), prefsw->checkbutton_afollow, TRUE);
3910 
3911   if (mainw->playing_file > 0 && mainw->record) {
3912     lives_widget_set_sensitive(prefsw->rextaudio, FALSE);
3913   }
3914 
3915   if (!is_realtime_aplayer(prefs->audio_player)) {
3916     lives_widget_set_sensitive(prefsw->rextaudio, FALSE);
3917   }
3918 
3919   pixbuf_playback = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_PLAYBACK, LIVES_ICON_SIZE_CUSTOM, -1, -1);
3920 
3921   prefs_add_to_list(prefsw->prefs_list, pixbuf_playback, _("Playback"), LIST_ENTRY_PLAYBACK);
3922   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_playback);
3923 
3924   lives_widget_hide(prefsw->jack_int_label);
3925 
3926 #ifdef ENABLE_JACK
3927   if (prefs->audio_player == AUD_PLAYER_JACK) {
3928     lives_widget_show(prefsw->jack_int_label);
3929   }
3930 #endif
3931 
3932   // ---------------,
3933   // recording      |
3934   // ---------------'
3935 
3936   prefsw->vbox_right_recording = lives_vbox_new(FALSE, 0);
3937   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_recording), widget_opts.border_width * 2);
3938 
3939   prefsw->scrollw_right_recording = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_recording);
3940 
3941   hbox = lives_hbox_new(FALSE, 0);
3942   prefsw->rdesk_audio = lives_standard_check_button_new(
3943                           _("Record audio when capturing an e_xternal window\n (requires jack or pulseaudio)"),
3944                           prefs->rec_desktop_audio, LIVES_BOX(hbox), NULL);
3945 
3946 #ifndef RT_AUDIO
3947   lives_widget_set_sensitive(prefsw->rdesk_audio, FALSE);
3948 #endif
3949 
3950   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_recording), hbox, FALSE, FALSE, widget_opts.packing_height);
3951 
3952   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_recording));
3953 
3954   hbox = lives_hbox_new(FALSE, 0);
3955   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_recording), hbox, FALSE, FALSE, widget_opts.packing_height);
3956 
3957   label = lives_standard_label_new(_("What to record when 'r' is pressed"));
3958 
3959   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
3960 
3961   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_recording));
3962   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3963   prefsw->rframes = lives_standard_check_button_new(_("_Frame changes"), (prefs->rec_opts & REC_FRAMES), LIVES_BOX(hbox), NULL);
3964 
3965   if (prefs->rec_opts & REC_FPS || prefs->rec_opts & REC_CLIPS) {
3966     lives_widget_set_sensitive(prefsw->rframes, FALSE); // we must record these if recording fps changes or clip switches
3967   }
3968   if (mainw->playing_file > 0 && mainw->record) {
3969     lives_widget_set_sensitive(prefsw->rframes, FALSE);
3970   }
3971 
3972   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3973   prefsw->rfps = lives_standard_check_button_new(_("F_PS changes"), (prefs->rec_opts & REC_FPS), LIVES_BOX(hbox), NULL);
3974 
3975   if (prefs->rec_opts & REC_CLIPS) {
3976     lives_widget_set_sensitive(prefsw->rfps, FALSE); // we must record these if recording clip switches
3977   }
3978 
3979   if (mainw->playing_file > 0 && mainw->record) {
3980     lives_widget_set_sensitive(prefsw->rfps, FALSE);
3981   }
3982 
3983   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3984   prefsw->reffects = lives_standard_check_button_new(_("_Real time effects"), (prefs->rec_opts & REC_EFFECTS),
3985                      LIVES_BOX(hbox), NULL);
3986 
3987   if (mainw->playing_file > 0 && mainw->record) {
3988     lives_widget_set_sensitive(prefsw->reffects, FALSE);
3989   }
3990 
3991   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
3992   prefsw->rclips = lives_standard_check_button_new(_("_Clip switches"), (prefs->rec_opts & REC_CLIPS), LIVES_BOX(hbox), NULL);
3993 
3994   if (mainw->playing_file > 0 && mainw->record) {
3995     lives_widget_set_sensitive(prefsw->rclips, FALSE);
3996   }
3997 
3998   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
3999   prefsw->raudio = lives_standard_check_button_new(_("_Audio (requires jack or pulseaudio player)"),
4000                    (prefs->rec_opts & REC_AUDIO), LIVES_BOX(hbox), NULL);
4001 
4002   if (mainw->playing_file > 0 && mainw->record) {
4003     lives_widget_set_sensitive(prefsw->raudio, FALSE);
4004   }
4005 
4006   if (!is_realtime_aplayer(prefs->audio_player)) {
4007     lives_widget_set_sensitive(prefsw->raudio, FALSE);
4008   }
4009 
4010   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_recording));
4011 
4012   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_recording));
4013 
4014   lives_layout_add_label(LIVES_LAYOUT(layout), _("Pause recording if:"), TRUE);
4015 
4016   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4017 
4018   lives_standard_check_button_new(_("Free disk space falls below"), TRUE, LIVES_BOX(hbox), NULL);
4019 
4020   widget_opts.swap_label = TRUE;
4021 
4022   // TRANSLATORS: gigabytes
4023   prefsw->spinbutton_rec_gb = lives_standard_spin_button_new(_("GB"), prefs->rec_stop_gb, 0., 1024., 1., 10., 0,
4024                               LIVES_BOX(hbox), NULL);
4025   widget_opts.swap_label = FALSE;
4026 
4027   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4028   lives_standard_check_button_new(_("More than"), TRUE, LIVES_BOX(hbox), NULL);
4029 
4030   //hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4031   widget_opts.swap_label = TRUE;
4032   // xgettext:no-c-format
4033   lives_standard_spin_button_new(_("% of quota is used"), 90., 0., 100., 1., 5., 0,
4034                                  LIVES_BOX(hbox), NULL);
4035   widget_opts.swap_label = FALSE;
4036 
4037   //lives_layout_add_fill(LIVES_LAYOUT(layout), TRUE);
4038 
4039   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4040   lives_standard_check_button_new(_("Disk space warning level is passed"), TRUE, LIVES_BOX(hbox), NULL);
4041 
4042   lives_layout_add_label(LIVES_LAYOUT(layout), _("Recording is always paused if the disk space critical level is reached"),
4043                          FALSE);
4044 
4045   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_recording));
4046 
4047   hbox = lives_hbox_new(FALSE, 0);
4048   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_recording), hbox, FALSE, FALSE,
4049                        widget_opts.packing_height);
4050 
4051   label = lives_standard_label_new(_("External Audio Source"));
4052   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
4053 
4054   hbox = lives_hbox_new(FALSE, 0);
4055   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_recording), hbox, FALSE, FALSE, widget_opts.packing_height);
4056   prefsw->spinbutton_ext_aud_thresh = lives_standard_spin_button_new(
4057                                         _("Delay recording playback start until external audio volume reaches "),
4058                                         prefs->ahold_threshold * 100., 0., 100., 1., 10., 0,
4059                                         LIVES_BOX(hbox), NULL);
4060 
4061   label = lives_standard_label_new("%");
4062   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
4063   add_fill_to_box(LIVES_BOX(hbox));
4064 
4065   // Rendering options
4066 
4067   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_recording));
4068 
4069   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_recording));
4070   lives_layout_add_label(LIVES_LAYOUT(layout), _("Rendering Options (post Recording)"), FALSE);
4071 
4072   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4073   prefsw->rr_crash = lives_standard_check_button_new(_("Enable Crash Recovery for recordings"), prefs->rr_crash,
4074                      LIVES_BOX(hbox),
4075                      (tmp = H_("If LiVES crashes or ctrl-c is pressed during "
4076                                "recording or when rendering a recording,"
4077                                "the recorded material will be retained and reloaded "
4078                                "the next time LiVES is restarted.\n\n")));
4079   ACTIVE(rr_crash, TOGGLED);
4080 
4081   if (!prefs->crash_recovery)
4082     show_warn_image(prefsw->rr_crash, _("Crash recovery also needs to be enabled for this feature to function."));
4083 
4084   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4085 
4086   widget_opts.use_markup = TRUE;
4087   prefsw->rr_super = lives_standard_check_button_new(_("Enable <b><u>SuperFluid</u></b> rendering:"),
4088                      prefs->rr_super, LIVES_BOX(hbox),
4089                      H_("Enables various pre-processing stages so that the resulting rendering\n"
4090                         "appears smoother and with fewer audio glitches"));
4091   widget_opts.use_markup = FALSE;
4092 
4093   ACTIVE(rr_super, TOGGLED);
4094 
4095   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4096   rmodelist = lives_list_append(rmodelist, _("Prioritize Audio rate"));
4097   rmodelist = lives_list_append(rmodelist, _("Prioritize Frame rate"));
4098   prefsw->rr_combo = lives_standard_combo_new(_("Render mode:"), rmodelist, LIVES_BOX(hbox),
4099                      H_("In 'Prioritize Audio rate' mode, frame timings will be adjusted slightly "
4100                         "to maintain the correct audio rate\n"
4101                         "In 'Constant Frame Rate' mode, the audio rate will be adjusted slightly "
4102                         "so that frames are shown at the exact recorded time\n"));
4103   lives_list_free_all(&rmodelist);
4104   lives_combo_set_active_index(LIVES_COMBO(prefsw->rr_combo), prefs->rr_qmode);
4105   ACTIVE(rr_combo, CHANGED);
4106 
4107   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4108 
4109   prefsw->rr_pre_smooth = lives_standard_check_button_new(_("Enable pre-quantisation frame smoothing"), prefs->rr_pre_smooth,
4110                           LIVES_BOX(hbox), NULL);
4111   lives_widget_set_margin_left(widget_opts.last_container, widget_opts.packing_width * 4);
4112   ACTIVE(rr_pre_smooth, TOGGLED);
4113 
4114   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4115   prefsw->rr_qsmooth = lives_standard_check_button_new(_("Enable frame smoothing during quantisation"), prefs->rr_qsmooth,
4116                        LIVES_BOX(hbox), NULL);
4117   lives_widget_set_margin_left(widget_opts.last_container, widget_opts.packing_width * 4);
4118   ACTIVE(rr_qsmooth, TOGGLED);
4119 
4120   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4121 
4122   radjlist = lives_list_append(radjlist, _("Apply effects state at original time"));
4123   radjlist = lives_list_append(radjlist, _("Apply effects state at adjusted time"));
4124   prefsw->rr_scombo = lives_standard_combo_new(_("When re-aligning frames"), radjlist, LIVES_BOX(hbox), NULL);
4125   lives_list_free_all(&radjlist);
4126   lives_combo_set_active_index(LIVES_COMBO(prefsw->rr_scombo), prefs->rr_fstate);
4127   ACTIVE(rr_scombo, CHANGED);
4128 
4129   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4130   prefsw->rr_amicro = lives_standard_check_button_new(_("Enable audio micro-adjustments during quantisation"), prefs->rr_amicro,
4131                       LIVES_BOX(hbox), NULL);
4132   lives_widget_set_margin_left(widget_opts.last_container, widget_opts.packing_width * 4);
4133   ACTIVE(rr_amicro, TOGGLED);
4134 
4135   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4136   prefsw->rr_ramicro = lives_standard_check_button_new(_("Ignore tiny audio jumps during rendering"), prefs->rr_ramicro,
4137                        LIVES_BOX(hbox), NULL);
4138   lives_widget_set_margin_left(widget_opts.last_container, widget_opts.packing_width * 4);
4139   ACTIVE(rr_ramicro, TOGGLED);
4140 
4141   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_combo, FALSE);
4142   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_scombo, FALSE);
4143   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_combo, FALSE);
4144   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_pre_smooth, FALSE);
4145   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_qsmooth, FALSE);
4146   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_amicro, FALSE);
4147   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->rr_super), prefsw->rr_ramicro, FALSE);
4148 
4149   pixbuf_recording = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_RECORD, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4150 
4151   prefs_add_to_list(prefsw->prefs_list, pixbuf_recording, _("Recording"), LIST_ENTRY_RECORDING);
4152   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_recording);
4153 
4154   // ---------------,
4155   // encoding       |
4156   // ---------------'
4157 
4158   prefsw->vbox_right_encoding = lives_vbox_new(FALSE, 0);
4159 
4160   prefsw->scrollw_right_encoding = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_encoding);
4161 
4162   widget_opts.packing_height <<= 2;
4163   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_encoding));
4164 
4165   lives_layout_add_label(LIVES_LAYOUT(layout),
4166                          _("You can also change these values when encoding a clip"), FALSE);
4167 
4168   if (capable->has_encoder_plugins) {
4169     // scan for encoder plugins
4170     encoders = get_plugin_list(PLUGIN_ENCODERS, TRUE, NULL, NULL);
4171   }
4172 
4173   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4174 
4175   prefsw->encoder_combo = lives_standard_combo_new(_("Encoder"), encoders,
4176                           LIVES_BOX(hbox), NULL);
4177 
4178   lives_layout_add_fill(LIVES_LAYOUT(layout), TRUE);
4179 
4180   if (encoders) {
4181     lives_combo_set_active_string(LIVES_COMBO(prefsw->encoder_combo), prefs->encoder.name);
4182     lives_list_free_all(&encoders);
4183   }
4184 
4185   if (capable->has_encoder_plugins) {
4186     // reqest formats from the encoder plugin
4187     if ((ofmt_all = plugin_request_by_line(PLUGIN_ENCODERS, prefs->encoder.name, "get_formats"))) {
4188       for (i = 0; i < lives_list_length(ofmt_all); i++) {
4189         if (get_token_count((char *)lives_list_nth_data(ofmt_all, i), '|') > 2) {
4190           array = lives_strsplit((char *)lives_list_nth_data(ofmt_all, i), "|", -1);
4191           if (!strcmp(array[0], prefs->encoder.of_name)) {
4192             prefs->encoder.of_allowed_acodecs = atoi(array[2]);
4193             lives_snprintf(prefs->encoder.of_restrict, 1024, "%s", array[3]);
4194           }
4195           ofmt = lives_list_append(ofmt, lives_strdup(array[1]));
4196           lives_strfreev(array);
4197         }
4198       }
4199       lives_memcpy(&future_prefs->encoder, &prefs->encoder, sizeof(_encoder));
4200     } else {
4201       do_plugin_encoder_error(prefs->encoder.name);
4202       future_prefs->encoder.of_allowed_acodecs = 0;
4203     }
4204 
4205     hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4206     prefsw->ofmt_combo = lives_standard_combo_new(_("Output format"), ofmt, LIVES_BOX(hbox), NULL);
4207 
4208     if (ofmt) {
4209       lives_combo_set_active_string(LIVES_COMBO(prefsw->ofmt_combo), prefs->encoder.of_desc);
4210       lives_list_free_all(&ofmt);
4211     }
4212 
4213     lives_list_free_all(&ofmt_all);
4214 
4215     hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4216     prefsw->acodec_combo = lives_standard_combo_new(_("Audio codec"), NULL, LIVES_BOX(hbox), NULL);
4217     prefs->acodec_list = NULL;
4218 
4219     set_acodec_list_from_allowed(prefsw, rdet);
4220 
4221   } else prefsw->acodec_combo = NULL;
4222   widget_opts.packing_height >>= 2;
4223 
4224   pixbuf_encoding = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_ENCODING, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4225 
4226   prefs_add_to_list(prefsw->prefs_list, pixbuf_encoding, _("Encoding"), LIST_ENTRY_ENCODING);
4227   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_encoding);
4228 
4229   // ---------------,
4230   // effects        |
4231   // ---------------'
4232 
4233   prefsw->vbox_right_effects = lives_vbox_new(FALSE, 0);
4234 
4235   prefsw->scrollw_right_effects = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_effects);
4236 
4237   hbox = lives_hbox_new(FALSE, 0);
4238   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE, widget_opts.packing_height);
4239 
4240   prefsw->checkbutton_load_rfx = lives_standard_check_button_new(_("Load rendered effects on startup"), prefs->load_rfx_builtin,
4241                                  LIVES_BOX(hbox), NULL);
4242 
4243   if (prefs->vj_mode)
4244     show_warn_image(prefsw->checkbutton_load_rfx, _("Disabled in VJ mode"));
4245 
4246   prefsw->checkbutton_antialias = lives_standard_check_button_new(_("Use _antialiasing when resizing"), prefs->antialias,
4247                                   LIVES_BOX(hbox), NULL);
4248 
4249   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_effects));
4250 
4251   hbox = lives_hbox_new(FALSE, 0);
4252   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE,
4253                        widget_opts.packing_height);
4254 
4255   prefsw->checkbutton_apply_gamma =
4256     lives_standard_check_button_new(_("Automatic gamma correction (requires restart)"),
4257                                     prefs->apply_gamma, LIVES_BOX(hbox),
4258                                     (tmp = (_("Also affects the monitor gamma !! (for now...)"))));
4259   lives_free(tmp);
4260 
4261   hbox = lives_hbox_new(FALSE, 0);
4262   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE, widget_opts.packing_height);
4263 
4264   prefsw->spinbutton_rte_keys = lives_standard_spin_button_new
4265                                 ((tmp = (_("Number of _real time effect keys"))), prefs->rte_keys_virtual, FX_KEYS_PHYSICAL,
4266                                  FX_KEYS_MAX_VIRTUAL, 1., 1., 0, LIVES_BOX(hbox),
4267                                  (tmp2 = lives_strdup(
4268                                      _("The number of \"virtual\" real time effect keys. "
4269                                        "They can be controlled through the real time effects window, or via network (OSC)."))));
4270   lives_free(tmp); lives_free(tmp2);
4271 
4272   hbox = lives_hbox_new(FALSE, 0);
4273   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE, widget_opts.packing_height);
4274 
4275   prefsw->checkbutton_threads = lives_standard_check_button_new(_("Use _threads where possible when applying effects"),
4276                                 future_prefs->nfx_threads > 1, LIVES_BOX(hbox), NULL);
4277 
4278   add_fill_to_box(LIVES_BOX(hbox));
4279 
4280   prefsw->spinbutton_nfx_threads = lives_standard_spin_button_new(_("Number of _threads"), future_prefs->nfx_threads, 2., 65536.,
4281                                    1., 1., 0, LIVES_BOX(hbox), NULL);
4282 
4283   toggle_sets_sensitive(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_threads), prefsw->spinbutton_nfx_threads, FALSE);
4284 
4285   add_fill_to_box(LIVES_BOX(hbox));
4286   add_fill_to_box(LIVES_BOX(hbox));
4287 
4288   if (future_prefs->nfx_threads == 1) lives_widget_set_sensitive(prefsw->spinbutton_nfx_threads, FALSE);
4289 
4290   hbox = lives_hbox_new(FALSE, 0);
4291   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE, widget_opts.packing_height);
4292 
4293   prefsw->pa_gens = lives_standard_check_button_new(_("Push audio to video generators that support it"),
4294                     prefs->push_audio_to_gens, LIVES_BOX(hbox), NULL);
4295 
4296   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_effects));
4297 
4298   hbox = lives_hbox_new(FALSE, 0);
4299   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_effects), hbox, FALSE, FALSE,
4300                        widget_opts.packing_height);
4301 
4302   label = lives_standard_label_new(_("Restart is required if any of the following paths are changed:"));
4303 
4304   lives_box_pack_start(LIVES_BOX(hbox), label, TRUE, TRUE, 0);
4305 
4306   add_fill_to_box(LIVES_BOX(hbox));
4307 
4308   widget_opts.packing_height *= 2;
4309 
4310   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_effects));
4311 
4312   lives_layout_add_label(LIVES_LAYOUT(layout), _("Changing these values will only take effect after a restart of LiVES:"), FALSE);
4313 
4314   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4315   prefsw->wpp_entry = lives_standard_direntry_new(_("Weed plugin path"), prefs->weed_plugin_path,
4316                       LONG_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox), NULL);
4317 
4318   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4319   prefsw->frei0r_entry = lives_standard_direntry_new(_("Frei0r plugin path"), prefs->frei0r_path,
4320                          LONG_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox),
4321                          (tmp = H_("(Frei0r directories should be separated by ':',\n"
4322                                    "ordered from lowest to highest priority)")));
4323   lives_free(tmp);
4324 
4325 #ifndef HAVE_FREI0R
4326   lives_widget_set_sensitive(prefsw->frei0r_entry, FALSE);
4327   show_warn_image(prefsw->frei0r_entry, _("LiVES was compiled without frei0r support"));
4328 #endif
4329 
4330   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4331   prefsw->ladspa_entry = lives_standard_direntry_new(_("LADSPA plugin path"), prefs->ladspa_path, LONG_ENTRY_WIDTH, PATH_MAX,
4332                          LIVES_BOX(hbox), NULL);
4333 #ifndef HAVE_LADSPA
4334   lives_widget_set_sensitive(prefsw->ladspa_entry, FALSE);
4335   show_warn_image(prefsw->ladspa_entry, _("LiVES was compiled without LADSPA support"));
4336 #endif
4337 
4338   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4339   prefsw->libvis_entry = lives_standard_direntry_new(_("libvisual plugin path"), prefs->libvis_path, LONG_ENTRY_WIDTH, PATH_MAX,
4340                          LIVES_BOX(hbox), NULL);
4341 
4342   widget_opts.packing_height = woph;
4343 
4344 #ifndef HAVE_LIBVISUAL
4345   lives_widget_set_sensitive(prefsw->libvis_entry, FALSE);
4346   show_warn_image(prefsw->libvis_entry, _("LiVES was compiled without libvisual support"));
4347 #endif
4348 
4349   pixbuf_effects = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_EFFECTS, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4350 
4351   prefs_add_to_list(prefsw->prefs_list, pixbuf_effects, _("Effects"), LIST_ENTRY_EFFECTS);
4352   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_effects);
4353 
4354   // -------------------,
4355   // Directories        |
4356   // -------------------'
4357 
4358   prefsw->table_right_directories = lives_table_new(10, 3, FALSE);
4359 
4360   lives_container_set_border_width(LIVES_CONTAINER(prefsw->table_right_directories), widget_opts.border_width * 2);
4361   lives_table_set_col_spacings(LIVES_TABLE(prefsw->table_right_directories), widget_opts.packing_width * 2);
4362   lives_table_set_row_spacings(LIVES_TABLE(prefsw->table_right_directories), widget_opts.packing_height * 4);
4363 
4364   prefsw->scrollw_right_directories = lives_standard_scrolled_window_new(0, 0, prefsw->table_right_directories);
4365 
4366   widget_opts.justify = LIVES_JUSTIFY_END;
4367   label = lives_standard_label_new(_("Video load directory (default)"));
4368   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 4, 5,
4369                      (LiVESAttachOptions)(LIVES_FILL),
4370                      (LiVESAttachOptions)(0), 0, 0);
4371 
4372   label = lives_standard_label_new(_("Video save directory (default)"));
4373   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 5, 6,
4374                      (LiVESAttachOptions)(LIVES_FILL),
4375                      (LiVESAttachOptions)(0), 0, 0);
4376 
4377   label = lives_standard_label_new(_("Audio load directory (default)"));
4378   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 6, 7,
4379                      (LiVESAttachOptions)(LIVES_FILL),
4380                      (LiVESAttachOptions)(0), 0, 0);
4381 
4382   label = lives_standard_label_new(_("Image directory (default)"));
4383   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 7, 8,
4384                      (LiVESAttachOptions)(LIVES_FILL),
4385                      (LiVESAttachOptions)(0), 0, 0);
4386 
4387   label = lives_standard_label_new(_("Backup/Restore directory (default)"));
4388   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 8, 9,
4389                      (LiVESAttachOptions)(LIVES_FILL),
4390                      (LiVESAttachOptions)(0), 0, 0);
4391 
4392   widget_opts.use_markup = TRUE;
4393   label = lives_standard_label_new(_("<b>Work directory</b>"));
4394   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), label, 0, 1, 3, 4,
4395                      (LiVESAttachOptions)(LIVES_FILL),
4396                      (LiVESAttachOptions)(0), 0, 0);
4397   widget_opts.use_markup = FALSE;
4398   widget_opts.justify = LIVES_JUSTIFY_DEFAULT;
4399 
4400   // workdir warning label
4401   layout = lives_layout_new(NULL);
4402 
4403   prefsw->workdir_label = lives_layout_add_label(LIVES_LAYOUT(layout), NULL, FALSE);
4404   set_workdir_label_text(LIVES_LABEL(prefsw->workdir_label), prefs->workdir);
4405 
4406   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), layout, 0, 3, 0, 2,
4407                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4408                      (LiVESAttachOptions)(0), 0, 0);
4409 
4410   hbox = lives_hbox_new(FALSE, 0);
4411 
4412   widget_opts.expand = LIVES_EXPAND_EXTRA_WIDTH | LIVES_EXPAND_DEFAULT_HEIGHT;
4413   widget_opts.packing_width = 0;
4414   prefsw->workdir_entry =
4415     lives_standard_entry_new(NULL, *future_prefs->workdir
4416                              ? future_prefs->workdir : prefs->workdir,
4417                              -1, PATH_MAX, LIVES_BOX(hbox),
4418                              (tmp2 = _("The default directory for saving encoded clips to")));
4419   lives_free(tmp2);
4420 
4421   widget_opts.expand = LIVES_EXPAND_DEFAULT;
4422   widget_opts.packing_width = wopw;
4423 
4424   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), hbox, 1, 2, 3, 4,
4425                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4426                      (LiVESAttachOptions)(0), 0, 0);
4427 
4428   lives_entry_set_editable(LIVES_ENTRY(prefsw->workdir_entry), FALSE);
4429   ACTIVE(workdir_entry, CHANGED);
4430 
4431   prefsw->vid_load_dir_entry = lives_standard_entry_new(NULL, prefs->def_vid_load_dir, -1, PATH_MAX,
4432                                NULL,  _("The default directory for loading video clips from"));
4433   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), prefsw->vid_load_dir_entry, 1, 2, 4, 5,
4434                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4435                      (LiVESAttachOptions)(0), 0, 0);
4436 
4437   lives_entry_set_editable(LIVES_ENTRY(prefsw->vid_load_dir_entry), FALSE);
4438   ACTIVE(vid_load_dir_entry, CHANGED);
4439 
4440   prefsw->vid_save_dir_entry = lives_standard_entry_new(NULL, prefs->def_vid_save_dir, -1, PATH_MAX,
4441                                NULL, _("The default directory for saving encoded clips to"));
4442   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), prefsw->vid_save_dir_entry, 1, 2, 5, 6,
4443                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4444                      (LiVESAttachOptions)(0), 0, 0);
4445 
4446   lives_entry_set_editable(LIVES_ENTRY(prefsw->vid_save_dir_entry), FALSE);
4447   ACTIVE(vid_save_dir_entry, CHANGED);
4448 
4449   prefsw->audio_dir_entry = lives_standard_entry_new(NULL, prefs->def_audio_dir, -1, PATH_MAX,
4450                             NULL, _("The default directory for loading and saving audio"));
4451   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), prefsw->audio_dir_entry, 1, 2, 6, 7,
4452                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4453                      (LiVESAttachOptions)(0), 0, 0);
4454 
4455   lives_entry_set_editable(LIVES_ENTRY(prefsw->audio_dir_entry), FALSE);
4456   ACTIVE(audio_dir_entry, CHANGED);
4457 
4458   prefsw->image_dir_entry = lives_standard_entry_new(NULL, prefs->def_image_dir, -1, PATH_MAX,
4459                             NULL, _("The default directory for saving frameshots to"));
4460   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), prefsw->image_dir_entry, 1, 2, 7, 8,
4461                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4462                      (LiVESAttachOptions)(0), 0, 0);
4463 
4464   lives_entry_set_editable(LIVES_ENTRY(prefsw->image_dir_entry), FALSE);
4465   ACTIVE(image_dir_entry, CHANGED);
4466 
4467   prefsw->proj_dir_entry = lives_standard_entry_new(NULL, prefs->def_proj_dir, -1, PATH_MAX,
4468                            NULL, _("The default directory for backing up/restoring single clips"));
4469   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), prefsw->proj_dir_entry, 1, 2, 8, 9,
4470                      (LiVESAttachOptions)(LIVES_EXPAND | LIVES_FILL),
4471                      (LiVESAttachOptions)(0), 0, 0);
4472 
4473   lives_entry_set_editable(LIVES_ENTRY(prefsw->proj_dir_entry), FALSE);
4474   ACTIVE(image_dir_entry, CHANGED);
4475 
4476   /// dirbuttons
4477 
4478   /* dirbutton = lives_standard_file_button_new(TRUE, */
4479   /* 					     g_filename_from_utf8(*future_prefs->workdir */
4480   /* 								      ? future_prefs->workdir : prefs->workdir, */
4481   /* 								 -1, NULL, NULL, NULL)); */
4482 
4483   dirbutton = lives_standard_file_button_new(TRUE, *future_prefs->workdir
4484               ? future_prefs->workdir : prefs->workdir);
4485 
4486   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 3, 4,
4487                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4488 
4489   lives_widget_object_set_data(LIVES_WIDGET_OBJECT(dirbutton), FILESEL_TYPE_KEY,
4490                                (livespointer)LIVES_DIR_SELECTION_WORKDIR);
4491 
4492   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4493                             prefsw->workdir_entry);
4494 
4495   if (mainw->has_session_workdir) {
4496     show_warn_image(prefsw->workdir_entry, _("Value cannot be changed when workdir\nis set via commandline option"));
4497     lives_widget_set_sensitive(dirbutton, FALSE);
4498   } else if (prefs->vj_mode) {
4499     show_warn_image(prefsw->workdir_entry, _("Changes disabled in VJ mode"));
4500     lives_widget_set_sensitive(dirbutton, FALSE);
4501   }
4502 
4503   dirbutton = lives_standard_file_button_new(TRUE, NULL);
4504 
4505   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 4, 5,
4506                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4507 
4508   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4509                             prefsw->vid_load_dir_entry);
4510 
4511   dirbutton = lives_standard_file_button_new(TRUE, NULL);
4512 
4513   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 5, 6,
4514                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4515 
4516   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4517                             prefsw->vid_save_dir_entry);
4518 
4519   dirbutton = lives_standard_file_button_new(TRUE, NULL);
4520 
4521   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 6, 7,
4522                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4523 
4524   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4525                             prefsw->audio_dir_entry);
4526 
4527   dirbutton = lives_standard_file_button_new(TRUE, NULL);
4528 
4529   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 7, 8,
4530                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4531 
4532   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4533                             prefsw->image_dir_entry);
4534 
4535   dirbutton = lives_standard_file_button_new(TRUE, NULL);
4536 
4537   lives_table_attach(LIVES_TABLE(prefsw->table_right_directories), dirbutton, 2, 3, 8, 9,
4538                      (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4539 
4540   lives_signal_sync_connect(dirbutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
4541                             prefsw->proj_dir_entry);
4542 
4543   pixbuf_directories = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_DIRECTORY, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4544 
4545   prefs_add_to_list(prefsw->prefs_list, pixbuf_directories, _("Directories"), LIST_ENTRY_DIRECTORIES);
4546   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_directories);
4547 
4548   // ---------------,
4549   // Warnings       |
4550   // ---------------'
4551 
4552   prefsw->vbox_right_warnings = lives_vbox_new(FALSE, widget_opts.packing_height >> 2);
4553   prefsw->scrollw_right_warnings =
4554     lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_warnings);
4555 
4556   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_warnings));
4557   lives_layout_add_label(LIVES_LAYOUT(layout), _("Low Disk Space Warnings (set to zero to disable)"), FALSE);
4558 
4559   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4560 
4561   prefsw->spinbutton_warn_ds =
4562     lives_standard_spin_button_new((tmp = (_("Disk space warning level"))),
4563                                    prefs->ds_warn_level / MILLIONS(1), prefs->ds_crit_level / MILLIONS(1), DS_WARN_CRIT_MAX,
4564                                    1., 50., 1,
4565                                    LIVES_BOX(hbox), (tmp2 = (H_("LiVES will start showing warnings if usable disk space\n"
4566                                        "falls below this level"))));
4567   lives_free(tmp); lives_free(tmp2);
4568 
4569   if (prefs->vj_mode)
4570     show_warn_image(prefsw->spinbutton_warn_ds, _("Reduced checking in VJ mode"));
4571 
4572   lives_layout_add_label(LIVES_LAYOUT(layout), _("MB"), TRUE);
4573 
4574   tmp = lives_format_storage_space_string(prefs->ds_warn_level);
4575   tmp2 = lives_strdup_printf("(%s)", tmp);
4576   prefsw->dsl_label = lives_layout_add_label(LIVES_LAYOUT(layout), tmp2, TRUE);
4577   lives_free(tmp); lives_free(tmp2);
4578 
4579   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4580 
4581   prefsw->spinbutton_crit_ds =
4582     lives_standard_spin_button_new((tmp = (_("Disk space critical level"))),
4583                                    prefs->ds_crit_level / MILLIONS(1), 0, MILLIONS(1), 1., 10., 1,
4584                                    LIVES_BOX(hbox), (tmp2 = (H_("LiVES will abort if usable disk space\n"
4585                                        "falls below this level"))));
4586   lives_free(tmp); lives_free(tmp2);
4587 
4588   if (prefs->vj_mode)
4589     show_warn_image(prefsw->spinbutton_crit_ds, _("Reduced checking in VJ mode"));
4590 
4591   lives_layout_add_label(LIVES_LAYOUT(layout), _("MB"), TRUE);
4592 
4593   tmp = lives_format_storage_space_string(prefs->ds_crit_level);
4594   tmp2 = lives_strdup_printf("(%s)", tmp);
4595   prefsw->dsc_label = lives_layout_add_label(LIVES_LAYOUT(layout), tmp2, TRUE);
4596   lives_free(tmp); lives_free(tmp2);
4597 
4598   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_warnings));
4599 
4600   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_warnings));
4601   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4602 
4603   //hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4604   prefsw->checkbutton_warn_fps = lives_standard_check_button_new(
4605                                    _("Warn on Insert / Merge if _frame rate of clipboard does "
4606                                      "not match frame rate of selection"),
4607                                    !(prefs->warning_mask & WARN_MASK_FPS), LIVES_BOX(hbox), NULL);
4608 
4609 
4610   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4611   prefsw->checkbutton_warn_fsize = lives_standard_check_button_new(
4612                                      _("Warn on Open if Instant Opening is not available, and the file _size exceeds "),
4613                                      !(prefs->warning_mask & WARN_MASK_FSIZE), LIVES_BOX(hbox), NULL);
4614 
4615   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4616   prefsw->spinbutton_warn_fsize = lives_standard_spin_button_new(NULL,
4617                                   prefs->warn_file_size, 1., 2048., 1., 10., 0,
4618                                   LIVES_BOX(hbox), NULL);
4619 
4620   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4621   label = lives_standard_label_new(_(" MB"));
4622   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width >> 1);
4623 
4624   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4625   prefsw->checkbutton_warn_save_set = lives_standard_check_button_new(_("Show a warning before saving a se_t"),
4626                                       !(prefs->warning_mask & WARN_MASK_SAVE_SET), LIVES_BOX(hbox), NULL);
4627 
4628   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4629   prefsw->checkbutton_warn_mplayer = lives_standard_check_button_new
4630                                      (_("Show a warning if _mplayer/mplayer2, sox, composite or convert is not "
4631                                         "found when LiVES is started."),
4632                                       !(prefs->warning_mask & WARN_MASK_NO_MPLAYER), LIVES_BOX(hbox), NULL);
4633 
4634   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4635   prefsw->checkbutton_warn_rendered_fx = lives_standard_check_button_new
4636                                          (_("Show a warning if no _rendered effects are found at startup."),
4637                                           !(prefs->warning_mask & WARN_MASK_RENDERED_FX), LIVES_BOX(hbox), NULL);
4638 
4639   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4640   prefsw->checkbutton_warn_encoders = lives_standard_check_button_new
4641                                       (_("Show a warning if no _encoder plugins are found at startup."),
4642                                        !(prefs->warning_mask & WARN_MASK_NO_ENCODERS), LIVES_BOX(hbox), NULL);
4643 
4644   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4645   prefsw->checkbutton_warn_dup_set = lives_standard_check_button_new
4646                                      (_("Show a warning if a _duplicate set name is entered."),
4647                                       !(prefs->warning_mask & WARN_MASK_DUPLICATE_SET), LIVES_BOX(hbox), NULL);
4648 
4649   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4650   prefsw->checkbutton_warn_layout_clips = lives_standard_check_button_new
4651                                           (_("When a set is loaded, warn if clips are missing from _layouts."),
4652                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_MISSING_CLIPS), LIVES_BOX(hbox), NULL);
4653 
4654   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4655   prefsw->checkbutton_warn_layout_close = lives_standard_check_button_new
4656                                           (_("Warn if a clip used in a layout is about to be closed."),
4657                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_CLOSE_FILE), LIVES_BOX(hbox), NULL);
4658 
4659   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4660   prefsw->checkbutton_warn_layout_delete = lives_standard_check_button_new
4661       (_("Warn if frames used in a layout are about to be deleted."),
4662        !(prefs->warning_mask & WARN_MASK_LAYOUT_DELETE_FRAMES), LIVES_BOX(hbox), NULL);
4663 
4664   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4665   prefsw->checkbutton_warn_layout_shift = lives_standard_check_button_new
4666                                           (_("Warn if frames used in a layout are about to be shifted."),
4667                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_SHIFT_FRAMES), LIVES_BOX(hbox), NULL);
4668 
4669   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4670   prefsw->checkbutton_warn_layout_alter = lives_standard_check_button_new
4671                                           (_("Warn if frames used in a layout are about to be altered."),
4672                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_ALTER_FRAMES), LIVES_BOX(hbox), NULL);
4673 
4674   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4675   prefsw->checkbutton_warn_layout_adel = lives_standard_check_button_new
4676                                          (_("Warn if audio used in a layout is about to be deleted."),
4677                                           !(prefs->warning_mask & WARN_MASK_LAYOUT_DELETE_AUDIO), LIVES_BOX(hbox), NULL);
4678 
4679   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4680   prefsw->checkbutton_warn_layout_ashift = lives_standard_check_button_new
4681       (_("Warn if audio used in a layout is about to be shifted."),
4682        !(prefs->warning_mask & WARN_MASK_LAYOUT_SHIFT_AUDIO), LIVES_BOX(hbox), NULL);
4683 
4684   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4685   prefsw->checkbutton_warn_layout_aalt = lives_standard_check_button_new
4686                                          (_("Warn if audio used in a layout is about to be altered."),
4687                                           !(prefs->warning_mask & WARN_MASK_LAYOUT_ALTER_AUDIO), LIVES_BOX(hbox), NULL);
4688 
4689   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4690   prefsw->checkbutton_warn_layout_popup = lives_standard_check_button_new
4691                                           (_("Popup layout errors after clip changes."),
4692                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_POPUP), LIVES_BOX(hbox), NULL);
4693 
4694   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4695   prefsw->checkbutton_warn_discard_layout = lives_standard_check_button_new
4696       (_("Warn if the layout has not been saved when leaving multitrack mode."),
4697        !(prefs->warning_mask & WARN_MASK_EXIT_MT), LIVES_BOX(hbox), NULL);
4698 
4699   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4700   prefsw->checkbutton_warn_mt_achans = lives_standard_check_button_new
4701                                        (_("Warn if multitrack has no audio channels, and a layout with audio is loaded."),
4702                                         !(prefs->warning_mask & WARN_MASK_MT_ACHANS), LIVES_BOX(hbox), NULL);
4703 
4704   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4705   prefsw->checkbutton_warn_mt_no_jack = lives_standard_check_button_new
4706                                         (_("Warn if multitrack has audio channels, and your audio player is not \"jack\" or \"pulseaudio\"."),
4707                                          !(prefs->warning_mask & WARN_MASK_MT_NO_JACK), LIVES_BOX(hbox), NULL);
4708 
4709 #ifdef HAVE_LDVGRAB
4710   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4711   prefsw->checkbutton_warn_after_dvgrab = lives_standard_check_button_new
4712                                           (_("Show info message after importing from firewire device."),
4713                                               !(prefs->warning_mask & WARN_MASK_AFTER_DVGRAB), LIVES_BOX(hbox), NULL);
4714 
4715 #else
4716   prefsw->checkbutton_warn_after_dvgrab = NULL;
4717 #endif
4718 
4719 #ifdef HAVE_YUV4MPEG
4720   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4721   prefsw->checkbutton_warn_yuv4m_open = lives_standard_check_button_new
4722                                         (_("Show a warning before opening a yuv4mpeg stream (advanced)."),
4723                                          !(prefs->warning_mask & WARN_MASK_OPEN_YUV4M), LIVES_BOX(hbox), NULL);
4724 #else
4725   prefsw->checkbutton_warn_yuv4m_open = NULL;
4726 #endif
4727 
4728   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4729   prefsw->checkbutton_warn_mt_backup_space = lives_standard_check_button_new
4730       (_("Show a warning when multitrack is low on backup space."),
4731        !(prefs->warning_mask & WARN_MASK_MT_BACKUP_SPACE), LIVES_BOX(hbox), NULL);
4732 
4733   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4734   prefsw->checkbutton_warn_after_crash = lives_standard_check_button_new
4735                                          (_("Show a warning advising cleaning of disk space after a crash."),
4736                                           !(prefs->warning_mask & WARN_MASK_CLEAN_AFTER_CRASH), LIVES_BOX(hbox), NULL);
4737 
4738   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4739   prefsw->checkbutton_warn_no_pulse = lives_standard_check_button_new
4740                                       (_("Show a warning if unable to connect to pulseaudio player."),
4741                                        !(prefs->warning_mask & WARN_MASK_NO_PULSE_CONNECT), LIVES_BOX(hbox), NULL);
4742 
4743   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4744   prefsw->checkbutton_warn_layout_wipe = lives_standard_check_button_new
4745                                          (_("Show a warning before wiping a layout which has unsaved changes."),
4746                                           !(prefs->warning_mask & WARN_MASK_LAYOUT_WIPE), LIVES_BOX(hbox), NULL);
4747 
4748   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4749   prefsw->checkbutton_warn_layout_gamma = lives_standard_check_button_new
4750                                           (_("Show a warning if a loaded layout has incompatible gamma settings."),
4751                                               !(prefs->warning_mask & WARN_MASK_LAYOUT_GAMMA), LIVES_BOX(hbox), NULL);
4752 
4753   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4754   prefsw->checkbutton_warn_layout_lb = lives_standard_check_button_new
4755                                        (_("Show a warning if a loaded layout has incompatible letterbox settings."),
4756                                         !(prefs->warning_mask & WARN_MASK_LAYOUT_LB), LIVES_BOX(hbox), NULL);
4757 
4758   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4759   prefsw->checkbutton_warn_vjmode_enter = lives_standard_check_button_new
4760                                           (_("Show a warning when the menu option Restart in VJ Mode becomes activated."),
4761                                               !(prefs->warning_mask & WARN_MASK_VJMODE_ENTER), LIVES_BOX(hbox), NULL);
4762 
4763   pixbuf_warnings = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_WARNING, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4764 
4765   prefs_add_to_list(prefsw->prefs_list, pixbuf_warnings, _("Warnings"), LIST_ENTRY_WARNINGS);
4766   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_warnings);
4767 
4768   // -----------,
4769   // Misc       |
4770   // -----------'
4771 
4772   prefsw->vbox_right_misc = lives_vbox_new(FALSE, widget_opts.packing_height * 4);
4773   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_misc), widget_opts.border_width * 2);
4774 
4775   prefsw->scrollw_right_misc = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_misc);
4776 
4777   hbox = lives_hbox_new(FALSE, 0);
4778   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), hbox, FALSE, FALSE, widget_opts.packing_height);
4779 
4780   label = lives_standard_label_new(_("When inserting/merging frames:"));
4781 
4782   lives_box_pack_start(LIVES_BOX(hbox), label, FALSE, FALSE, widget_opts.packing_width);
4783   add_fill_to_box(LIVES_BOX(hbox));
4784 
4785   prefsw->ins_speed = lives_standard_radio_button_new(_("_Speed Up/Slow Down Insertion"), &rb_group2, LIVES_BOX(hbox), NULL);
4786 
4787   ins_resample = lives_standard_radio_button_new(_("_Resample Insertion"), &rb_group2, LIVES_BOX(hbox), NULL);
4788 
4789   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(ins_resample), prefs->ins_resample);
4790 
4791   prefsw->cdda_hbox = lives_hbox_new(FALSE, 0);
4792   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), prefsw->cdda_hbox, FALSE, FALSE, widget_opts.packing_height);
4793 
4794   prefsw->cdplay_entry = lives_standard_fileentry_new((tmp = (_("CD device"))),
4795                          (tmp2 = lives_filename_to_utf8(prefs->cdplay_device, -1, NULL, NULL, NULL)),
4796                          LIVES_DEVICE_DIR, MEDIUM_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(prefsw->cdda_hbox),
4797                          (tmp3 = (_("LiVES can load audio tracks from this CD"))));
4798   lives_free(tmp); lives_free(tmp2); lives_free(tmp3);
4799 
4800   hbox = lives_hbox_new(FALSE, 0);
4801   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), hbox, FALSE, FALSE, widget_opts.packing_height);
4802 
4803   prefsw->spinbutton_def_fps = lives_standard_spin_button_new((tmp = (_("Default FPS"))),
4804                                prefs->default_fps, 1., FPS_MAX, 1., 1., 3,
4805                                LIVES_BOX(hbox), (tmp2 = (_("Frames per second to use when none is specified"))));
4806   lives_free(tmp); lives_free(tmp2);
4807 
4808   pixbuf_misc = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_MISC, LIVES_ICON_SIZE_CUSTOM, -1, -1);
4809 
4810   prefs_add_to_list(prefsw->prefs_list, pixbuf_misc, _("Misc"), LIST_ENTRY_MISC);
4811   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_misc);
4812 
4813   if (!check_for_executable(&capable->has_cdda2wav, EXEC_CDDA2WAV)
4814       && !check_for_executable(&capable->has_icedax, EXEC_ICEDAX)) {
4815     lives_widget_hide(prefsw->cdda_hbox);
4816   }
4817 
4818   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_misc));
4819 
4820   hbox = lives_hbox_new(FALSE, 0);
4821   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), hbox, FALSE, FALSE,
4822                        widget_opts.packing_height);
4823 
4824   prefsw->cb_show_quota = lives_standard_check_button_new
4825                           (_("Pop up disk quota settings window on startup"), prefs->show_disk_quota, LIVES_BOX(hbox), NULL);
4826   ACTIVE(cb_show_quota, TOGGLED);
4827   if (mainw->has_session_workdir)
4828     show_warn_image(prefsw->cb_show_quota, _("Quota checking is disabled when workdir is set\n"
4829                     "via the commandline option"));
4830   else if (prefs->vj_mode)
4831     show_warn_image(prefsw->cb_show_quota, _("Disabled in VJ mode"));
4832 
4833   hbox = lives_hbox_new(FALSE, 0);
4834   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), hbox, FALSE, FALSE,
4835                        widget_opts.packing_height);
4836 
4837   prefsw->cb_show_msgstart = lives_standard_check_button_new
4838                              (_("Pop up messages window on startup"), prefs->show_msgs_on_startup, LIVES_BOX(hbox), NULL);
4839   ACTIVE(cb_show_msgstart, TOGGLED);
4840   if (prefs->vj_mode)
4841     show_warn_image(prefsw->cb_show_msgstart, _("Disabled in VJ mode"));
4842 
4843   hbox = lives_hbox_new(FALSE, 0);
4844   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_misc), hbox, FALSE, FALSE,
4845                        widget_opts.packing_height);
4846 
4847   prefsw->cb_autoclean = lives_standard_check_button_new
4848                          (_("_Remove temporary backup files on startup and shutdown"),
4849                           prefs->autoclean, LIVES_BOX(hbox), H_("Save disk space by "
4850                               "allowing LiVES to remove\ntemporary preview and backup files"));
4851   ACTIVE(cb_autoclean, TOGGLED);
4852 
4853   if (prefs->vj_mode)
4854     show_warn_image(prefsw->rb_startup_mt, _("Disabled in VJ mode"));
4855 
4856   // -----------,
4857   // Themes     |
4858   // -----------'
4859 
4860   prefsw->vbox_right_themes = lives_vbox_new(FALSE, 0);
4861   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_themes), widget_opts.border_width * 2);
4862 
4863   prefsw->scrollw_right_themes = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_themes);
4864 
4865   hbox = lives_hbox_new(FALSE, 0);
4866   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_themes), hbox, TRUE, FALSE, widget_opts.packing_height);
4867 
4868   // scan for themes
4869   themes = get_plugin_list(PLUGIN_THEMES_CUSTOM, TRUE, NULL, NULL);
4870   themes = lives_list_concat(themes, get_plugin_list(PLUGIN_THEMES, TRUE, NULL, NULL));
4871   themes = lives_list_prepend(themes, lives_strdup(mainw->string_constants[LIVES_STRING_CONSTANT_NONE]));
4872 
4873   prefsw->theme_combo = lives_standard_combo_new(_("New theme:           "), themes, LIVES_BOX(hbox), NULL);
4874 
4875   if (strcasecmp(future_prefs->theme, LIVES_THEME_NONE)) {
4876     theme = lives_strdup(future_prefs->theme);
4877   } else theme = lives_strdup(mainw->string_constants[LIVES_STRING_CONSTANT_NONE]);
4878 
4879   lives_list_free_all(&themes);
4880 
4881   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_themes));
4882 
4883   layout = lives_layout_new(LIVES_BOX(prefsw->vbox_right_themes));
4884   lives_layout_add_label(LIVES_LAYOUT(layout), _("Eye Candy"), FALSE);
4885 
4886   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4887 
4888   prefsw->checkbutton_button_icons =
4889     lives_standard_check_button_new(_("Show icons in buttons"), widget_opts.show_button_images,
4890                                     LIVES_BOX(hbox), NULL);
4891 
4892   widget_opts.expand = LIVES_EXPAND_DEFAULT_HEIGHT | LIVES_EXPAND_EXTRA_WIDTH;
4893   lives_layout_add_fill(LIVES_LAYOUT(layout), TRUE);
4894   widget_opts.expand = LIVES_EXPAND_DEFAULT;
4895 
4896   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4897 
4898   prefsw->checkbutton_extra_colours =
4899     lives_standard_check_button_new(_("Invent interface colours"),
4900                                     prefs->extra_colours, LIVES_BOX(hbox),
4901                                     (tmp = H_("Make the interface more interesting "
4902                                         "by adding harmonious colours")));
4903   lives_free(tmp);
4904 
4905   frame = lives_standard_frame_new(_("Main Theme Details"), 0., FALSE);
4906 
4907   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_themes), frame, TRUE, TRUE, widget_opts.packing_height);
4908 
4909   vbox = lives_vbox_new(FALSE, 0);
4910   lives_container_add(LIVES_CONTAINER(frame), vbox);
4911   lives_container_set_border_width(LIVES_CONTAINER(vbox), widget_opts.border_width);
4912 
4913   layout = lives_layout_new(LIVES_BOX(vbox));
4914   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4915 
4916   widget_color_to_lives_rgba(&rgba, &palette->normal_fore);
4917   prefsw->cbutton_fore = lives_standard_color_button_new(LIVES_BOX(hbox), _("_Foreground Color"), FALSE, &rgba, &sp_red,
4918                          &sp_green, &sp_blue, NULL);
4919   ACTIVE(cbutton_fore, COLOR_SET);
4920 
4921   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4922   widget_color_to_lives_rgba(&rgba, &palette->normal_back);
4923   prefsw->cbutton_back = lives_standard_color_button_new(LIVES_BOX(hbox), _("_Background Color"), FALSE, &rgba, &sp_red,
4924                          &sp_green, &sp_blue, NULL);
4925   ACTIVE(cbutton_back, COLOR_SET);
4926 
4927   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4928   widget_color_to_lives_rgba(&rgba, &palette->menu_and_bars_fore);
4929   prefsw->cbutton_mabf = lives_standard_color_button_new(LIVES_BOX(hbox), _("_Alt Foreground Color"), FALSE, &rgba, &sp_red,
4930                          &sp_green, &sp_blue, NULL);
4931   ACTIVE(cbutton_mabf, COLOR_SET);
4932 
4933   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4934   widget_color_to_lives_rgba(&rgba, &palette->menu_and_bars);
4935   prefsw->cbutton_mab = lives_standard_color_button_new(LIVES_BOX(hbox), _("_Alt Background Color"), FALSE, &rgba, &sp_red,
4936                         &sp_green, &sp_blue, NULL);
4937   ACTIVE(cbutton_mab, COLOR_SET);
4938 
4939   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4940   widget_color_to_lives_rgba(&rgba, &palette->info_text);
4941   prefsw->cbutton_infot = lives_standard_color_button_new(LIVES_BOX(hbox), _("Info _Text Color"), FALSE, &rgba, &sp_red,
4942                           &sp_green, &sp_blue, NULL);
4943   ACTIVE(cbutton_infot, COLOR_SET);
4944 
4945   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
4946   widget_color_to_lives_rgba(&rgba, &palette->info_base);
4947   prefsw->cbutton_infob = lives_standard_color_button_new(LIVES_BOX(hbox), _("Info _Base Color"), FALSE, &rgba, &sp_red,
4948                           &sp_green, &sp_blue, NULL);
4949   ACTIVE(cbutton_infob, COLOR_SET);
4950 
4951   hbox = lives_hbox_new(FALSE, 0);
4952   lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0);
4953   prefsw->theme_style3 = lives_standard_check_button_new((tmp = (_("Theme is _light"))), (palette->style & STYLE_3),
4954                          LIVES_BOX(hbox),
4955                          (tmp2 = (_("Affects some contrast details of the timeline"))));
4956   lives_free(tmp); lives_free(tmp2);
4957 
4958   hbox = lives_hbox_new(FALSE, 0);
4959   lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0);
4960 
4961   prefsw->theme_style2 = NULL;
4962 #if GTK_CHECK_VERSION(3, 0, 0)
4963   prefsw->theme_style2 = lives_standard_check_button_new(_("Color the start/end frame spinbuttons (requires restart)"),
4964                          (palette->style & STYLE_2), LIVES_BOX(hbox), NULL);
4965 #endif
4966 
4967   hbox = lives_hbox_new(FALSE, 0);
4968   lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0);
4969 
4970   prefsw->theme_style4 = lives_standard_check_button_new(_("Highlight horizontal separators in multitrack"),
4971                          (palette->style & STYLE_4), LIVES_BOX(hbox), NULL);
4972   layout = lives_layout_new(LIVES_BOX(vbox));
4973 
4974   filt = (char **)lives_malloc(3 * sizeof(char *));
4975   filt[0] = LIVES_FILE_EXT_JPG;
4976   filt[1] = LIVES_FILE_EXT_PNG;
4977   filt[2] = NULL;
4978 
4979   lives_layout_add_label(LIVES_LAYOUT(layout), _("Frame blank image"), TRUE);
4980 
4981   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4982   prefsw->frameblank_entry = lives_standard_fileentry_new(" ", mainw->frameblank_path,
4983                              prefs->def_image_dir, MEDIUM_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox),
4984                              (tmp2 = (_("The frame image which is shown when there is no clip loaded."))));
4985   lives_free(tmp2);
4986 
4987   prefsw->fb_filebutton = lives_label_get_mnemonic_widget(LIVES_LABEL(widget_opts.last_label));
4988 
4989   lives_widget_object_set_data(LIVES_WIDGET_OBJECT(prefsw->fb_filebutton), FILTER_KEY, filt);
4990   lives_widget_object_set_data(LIVES_WIDGET_OBJECT(prefsw->fb_filebutton), FILESEL_TYPE_KEY,
4991                                LIVES_INT_TO_POINTER(LIVES_FILE_SELECTION_IMAGE_ONLY));
4992 
4993   lives_layout_add_row(LIVES_LAYOUT(layout));
4994   lives_layout_add_label(LIVES_LAYOUT(layout), _("Separator image"), TRUE);
4995 
4996   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
4997   prefsw->sepimg_entry = lives_standard_fileentry_new(" ", mainw->sepimg_path,
4998                          prefs->def_image_dir, MEDIUM_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox),
4999                          (tmp2 = (_("The image shown in the center of the interface."))));
5000   lives_free(tmp2);
5001 
5002   prefsw->se_filebutton = lives_label_get_mnemonic_widget(LIVES_LABEL(widget_opts.last_label));
5003   lives_signal_sync_connect(prefsw->se_filebutton, LIVES_WIDGET_CLICKED_SIGNAL, LIVES_GUI_CALLBACK(on_filesel_button_clicked),
5004                             prefsw->sepimg_entry);
5005 
5006   lives_widget_object_set_data(LIVES_WIDGET_OBJECT(prefsw->se_filebutton), FILTER_KEY, filt);
5007   lives_widget_object_set_data(LIVES_WIDGET_OBJECT(prefsw->se_filebutton), FILESEL_TYPE_KEY,
5008                                LIVES_INT_TO_POINTER(LIVES_FILE_SELECTION_IMAGE_ONLY));
5009 
5010   lives_free(filt);
5011 
5012   frame = lives_standard_frame_new(_("Extended Theme Details"), 0., FALSE);
5013 
5014   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_themes), frame, TRUE, TRUE, widget_opts.packing_height);
5015 
5016   vbox = lives_vbox_new(FALSE, 0);
5017   lives_container_add(LIVES_CONTAINER(frame), vbox);
5018   lives_container_set_border_width(LIVES_CONTAINER(vbox), widget_opts.border_width);
5019 
5020   layout = lives_layout_new(LIVES_BOX(vbox));
5021   hbox = lives_layout_hbox_new(LIVES_LAYOUT(layout));
5022   prefsw->cbutton_cesel = lives_standard_color_button_new(LIVES_BOX(hbox),
5023                           (tmp = (_("Selected frames/audio (clip editor)"))),
5024                           FALSE, &palette->ce_sel, &sp_red, &sp_green, &sp_blue, NULL);
5025   ACTIVE(cbutton_cesel, COLOR_SET);
5026 
5027   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5028   prefsw->cbutton_ceunsel = lives_standard_color_button_new(LIVES_BOX(hbox),
5029                             (tmp = (_("Unselected frames/audio (clip editor)"))),
5030                             FALSE, &palette->ce_unsel, &sp_red, &sp_green, &sp_blue, NULL);
5031   ACTIVE(cbutton_ceunsel, COLOR_SET);
5032 
5033   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5034   prefsw->cbutton_evbox = lives_standard_color_button_new(LIVES_BOX(hbox),
5035                           (tmp = (_("Track background (multitrack)"))),
5036                           FALSE, &palette->mt_evbox, &sp_red, &sp_green, &sp_blue, NULL);
5037   ACTIVE(cbutton_evbox, COLOR_SET);
5038 
5039   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5040   prefsw->cbutton_vidcol = lives_standard_color_button_new(LIVES_BOX(hbox), (tmp = (_("Video block (multitrack)"))),
5041                            FALSE, &palette->vidcol, &sp_red, &sp_green, &sp_blue, NULL);
5042   ACTIVE(cbutton_vidcol, COLOR_SET);
5043 
5044   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5045   prefsw->cbutton_audcol = lives_standard_color_button_new(LIVES_BOX(hbox), (tmp = (_("Audio block (multitrack)"))),
5046                            FALSE, &palette->audcol, &sp_red, &sp_green, &sp_blue, NULL);
5047   ACTIVE(cbutton_audcol, COLOR_SET);
5048 
5049   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5050   prefsw->cbutton_fxcol = lives_standard_color_button_new(LIVES_BOX(hbox), (tmp = (_("Effects block (multitrack)"))),
5051                           FALSE, &palette->fxcol, &sp_red, &sp_green, &sp_blue, NULL);
5052   ACTIVE(cbutton_fxcol, COLOR_SET);
5053 
5054   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5055   prefsw->cbutton_mtmark = lives_standard_color_button_new(LIVES_BOX(hbox), (tmp = (_("Timeline mark (multitrack)"))),
5056                            FALSE, &palette->mt_mark, &sp_red, &sp_green, &sp_blue, NULL);
5057   ACTIVE(cbutton_mtmark, COLOR_SET);
5058 
5059   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5060   prefsw->cbutton_tlreg = lives_standard_color_button_new(LIVES_BOX(hbox),
5061                           (tmp = (_("Timeline selection (multitrack)"))),
5062                           FALSE, &palette->mt_timeline_reg, &sp_red, &sp_green, &sp_blue, NULL);
5063   ACTIVE(cbutton_tlreg, COLOR_SET);
5064 
5065   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5066   widget_color_to_lives_rgba(&rgba, &palette->mt_timecode_bg);
5067   prefsw->cbutton_tcbg = lives_standard_color_button_new(LIVES_BOX(hbox),
5068                          (tmp = (_("Timecode background (multitrack)"))),
5069                          FALSE, &rgba, &sp_red, &sp_green, &sp_blue, NULL);
5070   ACTIVE(cbutton_tcbg, COLOR_SET);
5071 
5072   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5073   widget_color_to_lives_rgba(&rgba, &palette->mt_timecode_fg);
5074   prefsw->cbutton_tcfg = lives_standard_color_button_new(LIVES_BOX(hbox),
5075                          (tmp = (_("Timecode foreground (multitrack)"))),
5076                          FALSE, &rgba, &sp_red, &sp_green, &sp_blue, NULL);
5077   ACTIVE(cbutton_tcfg, COLOR_SET);
5078 
5079   hbox = lives_layout_row_new(LIVES_LAYOUT(layout));
5080   prefsw->cbutton_fsur = lives_standard_color_button_new(LIVES_BOX(hbox), (tmp = (_("Frame surround"))),
5081                          FALSE, &palette->frame_surround, &sp_red, &sp_green, &sp_blue, NULL);
5082   lives_free(tmp);
5083   ACTIVE(cbutton_fsur, COLOR_SET);
5084 
5085   // change in value of theme combo should set other widgets sensitive / insensitive
5086   lives_signal_sync_connect_after(LIVES_GUI_OBJECT(prefsw->theme_combo), LIVES_WIDGET_CHANGED_SIGNAL,
5087                                   LIVES_GUI_CALLBACK(theme_widgets_set_sensitive), (livespointer)prefsw);
5088   lives_combo_set_active_string(LIVES_COMBO(prefsw->theme_combo), theme);
5089   lives_free(theme);
5090 
5091   pixbuf_themes = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_THEMES, LIVES_ICON_SIZE_CUSTOM, -1, -1);
5092 
5093   prefs_add_to_list(prefsw->prefs_list, pixbuf_themes, _("Themes/Colors"), LIST_ENTRY_THEMES);
5094   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_themes);
5095 
5096   // --------------------------,
5097   // streaming/networking      |
5098   // --------------------------'
5099 
5100   prefsw->vbox_right_net = lives_vbox_new(FALSE, widget_opts.packing_height * 4);
5101   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_net), widget_opts.border_width * 2);
5102 
5103   prefsw->scrollw_right_net = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_net);
5104 
5105   hbox = lives_hbox_new(FALSE, 0);
5106   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_net), hbox, FALSE, FALSE, widget_opts.packing_height);
5107 
5108   prefsw->spinbutton_bwidth = lives_standard_spin_button_new(_("Download bandwidth (Kb/s)"),
5109                               prefs->dl_bandwidth, 0, 100000000., 1, 10, 0, LIVES_BOX(hbox), NULL);
5110 
5111   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_net));
5112 
5113 #ifndef ENABLE_OSC
5114   label = lives_standard_label_new(_("LiVES must be compiled without \"configure --disable-OSC\" to use OMC"));
5115   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_net), label, FALSE, FALSE, widget_opts.packing_height);
5116 #endif
5117 
5118   hbox1 = lives_hbox_new(FALSE, 0);
5119   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_net), hbox1, FALSE, FALSE, widget_opts.packing_height);
5120 
5121   hbox = lives_hbox_new(FALSE, 0);
5122   lives_box_pack_start(LIVES_BOX(hbox1), hbox, FALSE, FALSE, 0);
5123 
5124   prefsw->enable_OSC = lives_standard_check_button_new(_("OMC remote control enabled"), FALSE, LIVES_BOX(hbox), NULL);
5125 
5126 #ifndef ENABLE_OSC
5127   lives_widget_set_sensitive(prefsw->enable_OSC, FALSE);
5128 #endif
5129 
5130   prefsw->spinbutton_osc_udp = lives_standard_spin_button_new(_("UDP port"),
5131                                prefs->osc_udp_port, 1., 65535., 1., 10., 0, LIVES_BOX(hbox), NULL);
5132 
5133   hbox = lives_hbox_new(FALSE, 0);
5134   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_net), hbox, FALSE, FALSE, widget_opts.packing_height);
5135 
5136   prefsw->enable_OSC_start = lives_standard_check_button_new(_("Start OMC on startup"), future_prefs->osc_start,
5137                              LIVES_BOX(hbox), NULL);
5138 
5139 #ifndef ENABLE_OSC
5140   lives_widget_set_sensitive(prefsw->spinbutton_osc_udp, FALSE);
5141   lives_widget_set_sensitive(prefsw->enable_OSC_start, FALSE);
5142   lives_widget_set_sensitive(label, FALSE);
5143 #else
5144   if (prefs->osc_udp_started) {
5145     lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(prefsw->enable_OSC), TRUE);
5146     lives_widget_set_sensitive(prefsw->spinbutton_osc_udp, FALSE);
5147     lives_widget_set_sensitive(prefsw->enable_OSC, FALSE);
5148   }
5149 #endif
5150 
5151   pixbuf_net = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_NET, LIVES_ICON_SIZE_CUSTOM, -1, -1);
5152 
5153   prefs_add_to_list(prefsw->prefs_list, pixbuf_net, _("Streaming/Networking"), LIST_ENTRY_NET);
5154   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_net);
5155 
5156   // ----------,
5157   // jack      |
5158   // ----------'
5159 
5160   prefsw->vbox_right_jack = lives_vbox_new(FALSE, 0);
5161   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_jack), widget_opts.border_width * 2);
5162 
5163   prefsw->scrollw_right_jack = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_jack);
5164 
5165   label = lives_standard_label_new(_("Jack transport"));
5166   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5167 
5168 #ifndef ENABLE_JACK_TRANSPORT
5169   label = lives_standard_label_new(
5170             _("LiVES must be compiled with jack/transport.h and jack/jack.h present to use jack transport"));
5171   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5172 #else
5173   hbox = lives_hbox_new(FALSE, 0);
5174   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5175 
5176   prefsw->jack_tserver_entry = lives_standard_entry_new(_("Jack _transport config file"), prefs->jack_tserver, -1, PATH_MAX,
5177                                LIVES_BOX(hbox), NULL);
5178 
5179   lives_widget_set_sensitive(prefsw->jack_tserver_entry, FALSE); // unused for now
5180 
5181   prefsw->checkbutton_start_tjack = lives_standard_check_button_new(_("Start _server on LiVES startup"),
5182                                     (future_prefs->jack_opts & JACK_OPTS_START_TSERVER) ? TRUE : FALSE,
5183                                     LIVES_BOX(hbox), NULL);
5184 
5185   hbox = lives_hbox_new(FALSE, 0);
5186   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5187 
5188   prefsw->checkbutton_jack_master = lives_standard_check_button_new(_("Jack transport _master (start and stop)"),
5189                                     (future_prefs->jack_opts & JACK_OPTS_TRANSPORT_MASTER) ? TRUE : FALSE,
5190                                     LIVES_BOX(hbox), NULL);
5191 
5192   lives_signal_sync_connect_after(LIVES_GUI_OBJECT(prefsw->checkbutton_jack_master), LIVES_WIDGET_TOGGLED_SIGNAL,
5193                                   LIVES_GUI_CALLBACK(after_jack_master_toggled), NULL);
5194 
5195   prefsw->checkbutton_jack_mtb_start = lives_standard_check_button_new(_("LiVES can set start position"),
5196                                        (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_LSTART) ?
5197                                        (lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_master)))
5198                                        : FALSE, LIVES_BOX(hbox), NULL);
5199 
5200   lives_widget_set_sensitive(prefsw->checkbutton_jack_mtb_start,
5201                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_master)));
5202 
5203   hbox = lives_hbox_new(FALSE, 0);
5204   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5205 
5206   prefsw->checkbutton_jack_client = lives_standard_check_button_new(_("Jack transport _client (start and stop)"),
5207                                     (future_prefs->jack_opts & JACK_OPTS_TRANSPORT_CLIENT) ? TRUE : FALSE,
5208                                     LIVES_BOX(hbox), NULL);
5209 
5210   lives_signal_sync_connect_after(LIVES_GUI_OBJECT(prefsw->checkbutton_jack_client), LIVES_WIDGET_TOGGLED_SIGNAL,
5211                                   LIVES_GUI_CALLBACK(after_jack_client_toggled), NULL);
5212 
5213   prefsw->checkbutton_jack_tb_start = lives_standard_check_button_new(_("Jack transport can set start position"),
5214                                       (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_START) ?
5215                                       (lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_client)))
5216                                       : FALSE, LIVES_BOX(hbox), NULL);
5217 
5218   lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_start,
5219                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_client)));
5220 
5221   lives_signal_sync_connect_after(LIVES_GUI_OBJECT(prefsw->checkbutton_jack_tb_start), LIVES_WIDGET_TOGGLED_SIGNAL,
5222                                   LIVES_GUI_CALLBACK(after_jack_tb_start_toggled), NULL);
5223 
5224   hbox = lives_hbox_new(FALSE, 0);
5225   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5226 
5227   //add_fill_to_box(LIVES_BOX(hbox));
5228 
5229   prefsw->checkbutton_jack_tb_client = lives_standard_check_button_new(_("Jack transport timebase slave"),
5230                                        (future_prefs->jack_opts & JACK_OPTS_TIMEBASE_CLIENT) ?
5231                                        (lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_start)))
5232                                        : FALSE, LIVES_BOX(hbox),
5233                                        (tmp = H_("If playback is triggered by jack transport,\n"
5234                                            "then LiVES will attempt to sync with transport"
5235                                            "\nuntil playback finishes.")));
5236   lives_free(tmp);
5237 
5238   lives_widget_set_sensitive(prefsw->checkbutton_jack_tb_client,
5239                              lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(prefsw->checkbutton_jack_tb_start)));
5240 
5241   label = lives_standard_label_new(_("(See also Playback -> Audio follows video rate/direction)\n\n\n\n"));
5242   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5243 
5244 #endif
5245 
5246   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_jack));
5247 
5248   label = lives_standard_label_new(_("Jack audio"));
5249   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5250 
5251 #ifndef ENABLE_JACK
5252   label = lives_standard_label_new(_("LiVES must be compiled with jack/jack.h present to use jack audio"));
5253   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5254 #else
5255   label = lives_standard_label_new(_("You MUST set the audio player to \"jack\" in the Playback tab to use jack audio"));
5256   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), label, FALSE, FALSE, widget_opts.packing_height);
5257 
5258   hbox = lives_hbox_new(FALSE, 0);
5259   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5260 
5261   prefsw->jack_aserver_entry = lives_standard_entry_new(_("Jack _audio server config file"), prefs->jack_aserver, -1,
5262                                PATH_MAX, LIVES_BOX(hbox), NULL);
5263 
5264   lives_widget_set_sensitive(prefsw->jack_aserver_entry, FALSE);
5265 
5266   prefsw->checkbutton_start_ajack = lives_standard_check_button_new(_("Start _server on LiVES startup"),
5267                                     (future_prefs->jack_opts & JACK_OPTS_START_ASERVER) ? TRUE : FALSE,
5268                                     LIVES_BOX(hbox), NULL);
5269 
5270   hbox = lives_hbox_new(FALSE, 0);
5271   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5272 
5273   prefsw->checkbutton_jack_pwp = lives_standard_check_button_new(_("Play audio even when transport is _paused"),
5274                                  (future_prefs->jack_opts & JACK_OPTS_NOPLAY_WHEN_PAUSED) ? FALSE : TRUE,
5275                                  LIVES_BOX(hbox), NULL);
5276 
5277   lives_widget_set_sensitive(prefsw->checkbutton_jack_pwp, prefs->audio_player == AUD_PLAYER_JACK);
5278 
5279   hbox = lives_hbox_new(FALSE, 0);
5280   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_jack), hbox, FALSE, FALSE, widget_opts.packing_height);
5281 
5282   prefsw->checkbutton_jack_read_autocon = lives_standard_check_button_new
5283                                           (_("Automatically connect to System Out ports when 'playing' External Audio"),
5284                                               (future_prefs->jack_opts & JACK_OPTS_NO_READ_AUTOCON) ? FALSE : TRUE,
5285                                               LIVES_BOX(hbox), NULL);
5286 
5287   lives_widget_set_sensitive(prefsw->checkbutton_jack_read_autocon, prefs->audio_player == AUD_PLAYER_JACK);
5288 
5289 #endif
5290 
5291   pixbuf_jack = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_JACK, LIVES_ICON_SIZE_CUSTOM, -1, -1);
5292 
5293   prefs_add_to_list(prefsw->prefs_list, pixbuf_jack, _("Jack Integration"), LIST_ENTRY_JACK);
5294   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_jack);
5295 
5296   // ----------------------,
5297   // MIDI/js learner       |
5298   // ----------------------'
5299 
5300   prefsw->vbox_right_midi = lives_vbox_new(FALSE, 0);
5301 
5302   prefsw->scrollw_right_midi = lives_standard_scrolled_window_new(0, 0, prefsw->vbox_right_midi);
5303 
5304   lives_container_set_border_width(LIVES_CONTAINER(prefsw->vbox_right_midi), widget_opts.border_width * 2);
5305 
5306   label = lives_standard_label_new(_("Events to respond to:"));
5307   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), label, FALSE, FALSE, widget_opts.packing_height);
5308 
5309 #ifdef ENABLE_OSC
5310 #ifdef OMC_JS_IMPL
5311 
5312   hbox = lives_hbox_new(FALSE, 0);
5313   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5314 
5315   prefsw->checkbutton_omc_js = lives_standard_check_button_new(_("_Joystick events"), (prefs->omc_dev_opts & OMC_DEV_JS),
5316                                LIVES_BOX(hbox), NULL);
5317 
5318   label = lives_standard_label_new(_("Leave blank to use defaults"));
5319   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), label, FALSE, FALSE, widget_opts.packing_height);
5320 
5321   hbox = lives_hbox_new(FALSE, 0);
5322   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5323 
5324   prefsw->omc_js_entry = lives_standard_fileentry_new((tmp = (_("_Joystick device")))
5325                          , prefs->omc_js_fname, LIVES_DEVICE_DIR, LONG_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox),
5326                          (tmp2 = (H_("The joystick device, e.g. /dev/input/js0\n"
5327                                      "Leave blank to use defaults"))));
5328   lives_free(tmp); lives_free(tmp2);
5329 
5330 #ifdef OMC_MIDI_IMPL
5331   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_midi));
5332 #endif
5333 
5334 #endif
5335 
5336 #ifdef OMC_MIDI_IMPL
5337   hbox = lives_hbox_new(FALSE, 0);
5338   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5339 
5340   prefsw->checkbutton_omc_midi = lives_standard_check_button_new(_("_MIDI events"), (prefs->omc_dev_opts & OMC_DEV_MIDI),
5341                                  LIVES_BOX(hbox), NULL);
5342 
5343   add_fill_to_box(LIVES_BOX(hbox));
5344 
5345   if (!(mainw->midi_channel_lock &&
5346         prefs->midi_rcv_channel > -1)) mchanlist = lives_list_append(mchanlist, (_("All channels")));
5347   for (i = 0; i < 16; i++) {
5348     midichan = lives_strdup_printf("%d", i);
5349     mchanlist = lives_list_append(mchanlist, midichan);
5350   }
5351 
5352   midichan = lives_strdup_printf("%d", prefs->midi_rcv_channel);
5353 
5354   prefsw->midichan_combo = lives_standard_combo_new(_("MIDI receive _channel"), mchanlist, LIVES_BOX(hbox), NULL);
5355 
5356   lives_list_free_all(&mchanlist);
5357 
5358   if (prefs->midi_rcv_channel > -1) {
5359     lives_combo_set_active_string(LIVES_COMBO(prefsw->midichan_combo), midichan);
5360   }
5361 
5362   lives_free(midichan);
5363 
5364   if (mainw->midi_channel_lock && prefs->midi_rcv_channel == -1) lives_widget_set_sensitive(prefsw->midichan_combo, FALSE);
5365 
5366   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_midi));
5367 
5368   prefsw->midi_hbox = lives_hbox_new(FALSE, 0);
5369   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), prefsw->midi_hbox, FALSE, FALSE, widget_opts.packing_height);
5370 
5371 #ifdef ALSA_MIDI
5372   prefsw->alsa_midi = lives_standard_radio_button_new((tmp = (_("Use _ALSA MIDI (recommended)"))), &alsa_midi_group,
5373                       LIVES_BOX(prefsw->midi_hbox),
5374                       (tmp2 = (_("Create an ALSA MIDI port which other MIDI devices can be connected to"))));
5375 
5376   lives_free(tmp); lives_free(tmp2);
5377 
5378   prefsw->alsa_midi_dummy = lives_standard_check_button_new((tmp = (_("Create dummy MIDI output"))),
5379                             prefs->alsa_midi_dummy, LIVES_BOX(prefsw->midi_hbox),
5380                             (tmp2 = (_("Create a dummy ALSA MIDI output port."))));
5381 
5382   lives_free(tmp); lives_free(tmp2);
5383 
5384   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_midi));
5385 #endif
5386 
5387   hbox = lives_hbox_new(FALSE, 0);
5388 
5389   raw_midi_button = lives_standard_radio_button_new((tmp = (_("Use _raw MIDI"))), &alsa_midi_group,
5390                     LIVES_BOX(hbox), (tmp2 = (_("Read directly from the MIDI device"))));
5391 
5392   lives_free(tmp); lives_free(tmp2);
5393 
5394 #ifdef ALSA_MIDI
5395   lives_toggle_button_set_active(LIVES_TOGGLE_BUTTON(raw_midi_button), !prefs->use_alsa_midi);
5396 #endif
5397 
5398   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5399 
5400   hbox = lives_hbox_new(FALSE, 0);
5401   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5402   prefsw->omc_midi_entry = lives_standard_fileentry_new((tmp = (_("_MIDI device"))), prefs->omc_midi_fname,
5403                            LIVES_DEVICE_DIR, LONG_ENTRY_WIDTH, PATH_MAX, LIVES_BOX(hbox),
5404                            (tmp2 = (_("The MIDI device, e.g. /dev/input/midi0"))));
5405 
5406   lives_free(tmp); lives_free(tmp2);
5407 
5408   prefsw->button_midid = lives_label_get_mnemonic_widget(LIVES_LABEL(widget_opts.last_label));
5409 
5410   label = lives_standard_label_new(_("Advanced"));
5411   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), label, FALSE, FALSE, widget_opts.packing_height);
5412 
5413   hbox = lives_hbox_new(FALSE, 0);
5414   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5415 
5416   prefsw->spinbutton_midicr = lives_standard_spin_button_new((tmp = (_("MIDI check _rate"))),
5417                               prefs->midi_check_rate, 1., 2000., 1., 10., 0, LIVES_BOX(hbox),
5418                               (tmp2 = lives_strdup(
5419                                         _("Number of MIDI checks per keyboard tick. Increasing this may improve "
5420                                           "MIDI responsiveness, "
5421                                           "but may slow down playback."))));
5422 
5423   lives_free(tmp); lives_free(tmp2);
5424 
5425   add_fill_to_box(LIVES_BOX(hbox));
5426 
5427   prefsw->spinbutton_midirpt = lives_standard_spin_button_new((tmp = (_("MIDI repeat"))),
5428                                prefs->midi_rpt, 1., 10000., 10., 100., 0, LIVES_BOX(hbox),
5429                                (tmp2 = (_("Number of non-reads allowed between succesive reads."))));
5430 
5431   lives_free(tmp); lives_free(tmp2);
5432 
5433   label = lives_standard_label_new(_("(Warning: setting this value too high can slow down playback.)"));
5434 
5435   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), label, FALSE, FALSE, widget_opts.packing_height);
5436 
5437 #ifdef ALSA_MIDI
5438   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->alsa_midi), LIVES_WIDGET_TOGGLED_SIGNAL,
5439                             LIVES_GUI_CALLBACK(on_alsa_midi_toggled), NULL);
5440 
5441   on_alsa_midi_toggled(LIVES_TOGGLE_BUTTON(prefsw->alsa_midi), prefsw);
5442 #endif
5443 
5444   add_hsep_to_box(LIVES_BOX(prefsw->vbox_right_midi));
5445 
5446 #endif
5447 #endif
5448 
5449   hbox = lives_hbox_new(FALSE, 0);
5450   lives_box_pack_start(LIVES_BOX(prefsw->vbox_right_midi), hbox, FALSE, FALSE, widget_opts.packing_height);
5451 
5452   prefsw->check_midi = lives_standard_check_button_new
5453                        ((tmp = lives_strdup_printf(_("Midi program synch (requires the files %s and %s)"), EXEC_MIDISTART, EXEC_MIDISTOP)),
5454                         prefs->midisynch, LIVES_BOX(hbox), NULL);
5455   lives_free(tmp);
5456 
5457   lives_widget_set_sensitive(prefsw->check_midi, capable->has_midistartstop);
5458 
5459   pixbuf_midi = lives_pixbuf_new_from_stock_at_size(LIVES_LIVES_STOCK_PREF_MIDI, LIVES_ICON_SIZE_CUSTOM, -1, -1);
5460 
5461   prefs_add_to_list(prefsw->prefs_list, pixbuf_midi, _("MIDI/Joystick learner"), LIST_ENTRY_MIDI);
5462   lives_container_add(LIVES_CONTAINER(dialog_table), prefsw->scrollw_right_midi);
5463 
5464   prefsw->selection = lives_tree_view_get_selection(LIVES_TREE_VIEW(prefsw->prefs_list));
5465   lives_tree_selection_set_mode(prefsw->selection, LIVES_SELECTION_SINGLE);
5466 
5467   lives_signal_sync_connect(prefsw->selection, LIVES_WIDGET_CHANGED_SIGNAL, LIVES_GUI_CALLBACK(on_prefs_page_changed),
5468                             (livespointer)prefsw);
5469 
5470   if (!saved_dialog) {
5471     widget_opts.expand |= LIVES_EXPAND_EXTRA_WIDTH;
5472     // Preferences 'Revert' button
5473     prefsw->revertbutton = lives_dialog_add_button_from_stock(LIVES_DIALOG(prefsw->prefs_dialog),
5474                            LIVES_STOCK_REVERT_TO_SAVED, NULL, LIVES_RESPONSE_CANCEL);
5475     lives_widget_show_all(prefsw->revertbutton);
5476 
5477     // Preferences 'Apply' button
5478     prefsw->applybutton = lives_dialog_add_button_from_stock(LIVES_DIALOG(prefsw->prefs_dialog), LIVES_STOCK_APPLY, NULL,
5479                           LIVES_RESPONSE_ACCEPT);
5480     lives_widget_show_all(prefsw->applybutton);
5481 
5482     // Preferences 'Close' button
5483     prefsw->closebutton = lives_dialog_add_button_from_stock(LIVES_DIALOG(prefsw->prefs_dialog), LIVES_STOCK_CLOSE, NULL,
5484                           LIVES_RESPONSE_OK);
5485     lives_widget_show_all(prefsw->closebutton);
5486     widget_opts.expand = LIVES_EXPAND_DEFAULT;
5487   } else {
5488     prefsw->revertbutton = saved_revertbutton;
5489     prefsw->applybutton = saved_applybutton;
5490     prefsw->closebutton = saved_closebutton;
5491     lives_widget_set_sensitive(prefsw->closebutton, TRUE);
5492   }
5493   lives_button_grab_default_special(prefsw->closebutton);
5494 
5495   prefs->cb_is_switch = FALSE;
5496 
5497   lives_widget_add_accelerator(prefsw->closebutton, LIVES_WIDGET_CLICKED_SIGNAL, prefsw->accel_group,
5498                                LIVES_KEY_Escape, (LiVESXModifierType)0, (LiVESAccelFlags)0);
5499 
5500   // Set 'Revert' button as inactive since there are no changes yet
5501   lives_widget_set_sensitive(prefsw->revertbutton, FALSE);
5502   // Set 'Apply' button as inactive since there are no changes yet
5503   lives_widget_set_sensitive(prefsw->applybutton, FALSE);
5504 
5505   // Connect signals for 'Apply' button activity handling
5506   if (prefsw->theme_style2)
5507     ACTIVE(theme_style2, TOGGLED);
5508 
5509   ACTIVE(theme_style3, TOGGLED);
5510   ACTIVE(theme_style4, TOGGLED);
5511 
5512   ACTIVE(wpp_entry, CHANGED);
5513   ACTIVE(frei0r_entry, CHANGED);
5514   ACTIVE(libvis_entry, CHANGED);
5515   ACTIVE(ladspa_entry, CHANGED);
5516 
5517   ACTIVE(fs_max_check, TOGGLED);
5518   ACTIVE(recent_check, TOGGLED);
5519   ACTIVE(stop_screensaver_check, TOGGLED);
5520   ACTIVE(open_maximised_check, TOGGLED);
5521   ACTIVE(show_tool, TOGGLED);
5522   ACTIVE(mouse_scroll, TOGGLED);
5523   ACTIVE(checkbutton_ce_maxspect, TOGGLED);
5524   ACTIVE(ce_thumbs, TOGGLED);
5525   ACTIVE(checkbutton_button_icons, TOGGLED);
5526   ACTIVE(checkbutton_extra_colours, TOGGLED);
5527   ACTIVE(checkbutton_hfbwnp, TOGGLED);
5528   ACTIVE(checkbutton_show_asrc, TOGGLED);
5529   ACTIVE(checkbutton_show_ttips, TOGGLED);
5530   ACTIVE(rb_startup_mt, TOGGLED);
5531   ACTIVE(rb_startup_ce, TOGGLED);
5532 
5533   ACTIVE(spinbutton_warn_ds, VALUE_CHANGED);
5534   ACTIVE(spinbutton_crit_ds, VALUE_CHANGED);
5535 
5536   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->spinbutton_warn_ds), LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
5537                             LIVES_GUI_CALLBACK(spinbutton_ds_value_changed), LIVES_INT_TO_POINTER(FALSE));
5538   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->spinbutton_crit_ds), LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
5539                             LIVES_GUI_CALLBACK(spinbutton_ds_value_changed), LIVES_INT_TO_POINTER(TRUE));
5540 
5541   ACTIVE(spinbutton_gmoni, VALUE_CHANGED);
5542   ACTIVE(spinbutton_pmoni, VALUE_CHANGED);
5543 
5544   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->spinbutton_gmoni), LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
5545                             LIVES_GUI_CALLBACK(pmoni_gmoni_changed), NULL);
5546   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->spinbutton_pmoni), LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
5547                             LIVES_GUI_CALLBACK(pmoni_gmoni_changed), NULL);
5548 
5549   ACTIVE(forcesmon, TOGGLED);
5550   ACTIVE(checkbutton_stream_audio, TOGGLED);
5551   ACTIVE(checkbutton_rec_after_pb, TOGGLED);
5552   ACTIVE(spinbutton_warn_ds, VALUE_CHANGED);
5553   ACTIVE(spinbutton_crit_ds, VALUE_CHANGED);
5554 
5555   lives_signal_sync_connect(LIVES_GUI_OBJECT(mt_enter_defs), LIVES_WIDGET_TOGGLED_SIGNAL,
5556                             LIVES_GUI_CALLBACK(apply_button_set_enabled), NULL);
5557 
5558   ACTIVE(mt_enter_prompt, TOGGLED);
5559   ACTIVE(checkbutton_render_prompt, TOGGLED);
5560 
5561   ACTIVE(spinbutton_mt_def_width, VALUE_CHANGED);
5562   ACTIVE(spinbutton_mt_def_height, VALUE_CHANGED);
5563   ACTIVE(spinbutton_mt_def_fps, VALUE_CHANGED);
5564 
5565   ACTIVE(backaudio_checkbutton, TOGGLED);
5566   ACTIVE(pertrack_checkbutton, TOGGLED);
5567 
5568   ACTIVE(spinbutton_mt_undo_buf, VALUE_CHANGED);
5569 
5570   ACTIVE(checkbutton_mt_exit_render, TOGGLED);
5571 
5572   ACTIVE(spinbutton_mt_ab_time, VALUE_CHANGED);
5573   ACTIVE(spinbutton_max_disp_vtracks, VALUE_CHANGED);
5574 
5575   ACTIVE(mt_autoback_always, TOGGLED);
5576   ACTIVE(mt_autoback_never, TOGGLED);
5577   ACTIVE(mt_autoback_every, TOGGLED);
5578 
5579   ACTIVE(video_open_entry, CHANGED);
5580   ACTIVE(frameblank_entry, CHANGED);
5581   ACTIVE(sepimg_entry, CHANGED);
5582 
5583   ACTIVE(spinbutton_ocp, VALUE_CHANGED);
5584   ACTIVE(jpeg, TOGGLED);
5585 
5586   ACTIVE(checkbutton_instant_open, TOGGLED);
5587   ACTIVE(checkbutton_auto_deint, TOGGLED);
5588   ACTIVE(checkbutton_concat_images, TOGGLED);
5589   ACTIVE(checkbutton_lb, TOGGLED);
5590   ACTIVE(checkbutton_lbmt, TOGGLED);
5591   ACTIVE(checkbutton_screengamma, TOGGLED);
5592   ACTIVE(spinbutton_gamma, VALUE_CHANGED);
5593   ACTIVE(pbq_adaptive, TOGGLED);
5594 
5595   ACTIVE(pbq_combo, CHANGED);
5596   lives_signal_sync_connect(LIVES_GUI_OBJECT(pp_combo), LIVES_WIDGET_CHANGED_SIGNAL,
5597                             LIVES_GUI_CALLBACK(apply_button_set_enabled), NULL);
5598   ACTIVE(audp_combo, CHANGED);
5599 
5600   ACTIVE(checkbutton_show_stats, TOGGLED);
5601 
5602   ACTIVE(checkbutton_afollow, TOGGLED);
5603   ACTIVE(checkbutton_aclips, TOGGLED);
5604 
5605   ACTIVE(rdesk_audio, TOGGLED);
5606 
5607   ACTIVE(rframes, TOGGLED);
5608   ACTIVE(rfps, TOGGLED);
5609   ACTIVE(reffects, TOGGLED);
5610   ACTIVE(rclips, TOGGLED);
5611   ACTIVE(raudio, TOGGLED);
5612   ACTIVE(rextaudio, TOGGLED);
5613 
5614   ACTIVE(pa_gens, TOGGLED);
5615 
5616   ACTIVE(spinbutton_ext_aud_thresh, VALUE_CHANGED);
5617   ACTIVE(spinbutton_rec_gb, VALUE_CHANGED);
5618 
5619   ACTIVE(encoder_combo, CHANGED);
5620 
5621   if (capable->has_encoder_plugins) {
5622     ACTIVE(ofmt_combo, CHANGED);
5623     ACTIVE(acodec_combo, CHANGED);
5624   }
5625 
5626   ACTIVE(checkbutton_antialias, TOGGLED);
5627   ACTIVE(checkbutton_load_rfx, TOGGLED);
5628   ACTIVE(checkbutton_apply_gamma, TOGGLED);
5629 
5630   ACTIVE(spinbutton_rte_keys, VALUE_CHANGED);
5631   ACTIVE(spinbutton_nfx_threads, VALUE_CHANGED);
5632 
5633   ACTIVE(checkbutton_threads, TOGGLED);
5634 
5635   ACTIVE(checkbutton_warn_fps, TOGGLED);
5636   ACTIVE(checkbutton_warn_fsize, TOGGLED);
5637   ACTIVE(checkbutton_warn_save_set, TOGGLED);
5638   ACTIVE(checkbutton_warn_mplayer, TOGGLED);
5639   ACTIVE(checkbutton_warn_rendered_fx, TOGGLED);
5640   ACTIVE(checkbutton_warn_encoders, TOGGLED);
5641   ACTIVE(checkbutton_warn_dup_set, TOGGLED);
5642   ACTIVE(checkbutton_warn_layout_clips, TOGGLED);
5643   ACTIVE(checkbutton_warn_layout_close, TOGGLED);
5644   ACTIVE(checkbutton_warn_layout_delete, TOGGLED);
5645   ACTIVE(checkbutton_warn_layout_shift, TOGGLED);
5646   ACTIVE(checkbutton_warn_layout_alter, TOGGLED);
5647   ACTIVE(checkbutton_warn_layout_adel, TOGGLED);
5648   ACTIVE(checkbutton_warn_layout_ashift, TOGGLED);
5649   ACTIVE(checkbutton_warn_layout_aalt, TOGGLED);
5650   ACTIVE(checkbutton_warn_layout_popup, TOGGLED);
5651   ACTIVE(checkbutton_warn_discard_layout, TOGGLED);
5652   ACTIVE(checkbutton_warn_mt_achans, TOGGLED);
5653   ACTIVE(checkbutton_warn_mt_no_jack, TOGGLED);
5654 
5655   ACTIVE(spinbutton_warn_fsize, VALUE_CHANGED);
5656 
5657 #ifdef HAVE_LDVGRAB
5658   ACTIVE(checkbutton_warn_after_dvgrab, TOGGLED);
5659 #endif
5660 #ifdef HAVE_YUV4MPEG
5661   ACTIVE(checkbutton_warn_yuv4m_open, TOGGLED);
5662 #endif
5663   ACTIVE(checkbutton_warn_layout_gamma, TOGGLED);
5664   ACTIVE(checkbutton_warn_layout_lb, TOGGLED);
5665   ACTIVE(checkbutton_warn_layout_wipe, TOGGLED);
5666   ACTIVE(checkbutton_warn_no_pulse, TOGGLED);
5667   ACTIVE(checkbutton_warn_after_crash, TOGGLED);
5668   ACTIVE(checkbutton_warn_mt_backup_space, TOGGLED);
5669   ACTIVE(checkbutton_warn_vjmode_enter, TOGGLED);
5670 
5671   ACTIVE(check_midi, TOGGLED);
5672   ACTIVE(midichan_combo, CHANGED);
5673 
5674   ACTIVE(ins_speed, TOGGLED);
5675 
5676   ACTIVE(cdplay_entry, CHANGED);
5677 
5678   ACTIVE(spinbutton_def_fps, VALUE_CHANGED);
5679 
5680   ACTIVE(theme_combo, CHANGED);
5681 
5682   ACTIVE(spinbutton_bwidth, VALUE_CHANGED);
5683 #ifdef ENABLE_OSC
5684   ACTIVE(spinbutton_osc_udp, VALUE_CHANGED);
5685   ACTIVE(enable_OSC_start, TOGGLED);
5686   ACTIVE(enable_OSC, TOGGLED);
5687 #endif
5688 
5689 #ifdef ENABLE_JACK_TRANSPORT
5690   ACTIVE(jack_tserver_entry, CHANGED);
5691   ACTIVE(checkbutton_start_tjack, TOGGLED);
5692   ACTIVE(checkbutton_jack_master, TOGGLED);
5693   ACTIVE(checkbutton_jack_client, TOGGLED);
5694   ACTIVE(checkbutton_jack_tb_start, TOGGLED);
5695   ACTIVE(checkbutton_jack_mtb_start, TOGGLED);
5696   ACTIVE(checkbutton_jack_tb_client, TOGGLED);
5697 #endif
5698 
5699 #ifdef ENABLE_JACK
5700   ACTIVE(jack_aserver_entry, CHANGED);
5701   ACTIVE(checkbutton_start_ajack, TOGGLED);
5702   ACTIVE(checkbutton_jack_pwp, TOGGLED);
5703   ACTIVE(checkbutton_jack_read_autocon, TOGGLED);
5704 #endif
5705 
5706 #ifdef ENABLE_OSC
5707 #ifdef OMC_JS_IMPL
5708   ACTIVE(checkbutton_omc_js, TOGGLED);
5709   ACTIVE(omc_js_entry, CHANGED);
5710 #endif
5711 #ifdef OMC_MIDI_IMPL
5712   ACTIVE(checkbutton_omc_midi, TOGGLED);
5713 #ifdef ALSA_MIDI
5714   ACTIVE(alsa_midi, TOGGLED);
5715   ACTIVE(alsa_midi_dummy, TOGGLED);
5716 #endif
5717   ACTIVE(omc_midi_entry, CHANGED);
5718   ACTIVE(spinbutton_midicr, VALUE_CHANGED);
5719   ACTIVE(spinbutton_midirpt, VALUE_CHANGED);
5720 #endif
5721 #endif
5722 
5723   if (capable->has_encoder_plugins) {
5724     prefsw->encoder_name_fn = lives_signal_sync_connect(LIVES_GUI_OBJECT(LIVES_COMBO(prefsw->encoder_combo)),
5725                               LIVES_WIDGET_CHANGED_SIGNAL, LIVES_GUI_CALLBACK(on_encoder_entry_changed), NULL);
5726 
5727     prefsw->encoder_ofmt_fn = lives_signal_sync_connect(LIVES_GUI_OBJECT(LIVES_COMBO(prefsw->ofmt_combo)),
5728                               LIVES_WIDGET_CHANGED_SIGNAL, LIVES_GUI_CALLBACK(on_encoder_ofmt_changed), NULL);
5729   }
5730 
5731   prefsw->audp_entry_func = lives_signal_sync_connect(LIVES_GUI_OBJECT(LIVES_COMBO(prefsw->audp_combo)),
5732                             LIVES_WIDGET_CHANGED_SIGNAL, LIVES_GUI_CALLBACK(on_audp_entry_changed), NULL);
5733 
5734 #ifdef ENABLE_OSC
5735   lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->enable_OSC), LIVES_WIDGET_TOGGLED_SIGNAL,
5736                             LIVES_GUI_CALLBACK(on_osc_enable_toggled),
5737                             (livespointer)prefsw->enable_OSC_start);
5738 #endif
5739   if (saved_dialog == NULL) {
5740     lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->revertbutton), LIVES_WIDGET_CLICKED_SIGNAL,
5741                               LIVES_GUI_CALLBACK(on_prefs_revert_clicked), NULL);
5742 
5743     lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->prefs_dialog), LIVES_WIDGET_DELETE_EVENT,
5744                               LIVES_GUI_CALLBACK(on_prefs_close_clicked), NULL);
5745 
5746     lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->applybutton), LIVES_WIDGET_CLICKED_SIGNAL,
5747                               LIVES_GUI_CALLBACK(on_prefs_apply_clicked), NULL);
5748   }
5749 
5750   prefsw->close_func = lives_signal_sync_connect(LIVES_GUI_OBJECT(prefsw->closebutton), LIVES_WIDGET_CLICKED_SIGNAL,
5751                        LIVES_GUI_CALLBACK(on_prefs_close_clicked), prefsw);
5752 
5753   lives_list_free_all(&audp);
5754 
5755   if (prefs_current_page == -1) {
5756     if (!mainw->multitrack)
5757       select_pref_list_row(LIST_ENTRY_GUI, prefsw);
5758     else
5759       select_pref_list_row(LIST_ENTRY_MULTITRACK, prefsw);
5760   } else select_pref_list_row(prefs_current_page, prefsw);
5761 
5762   lives_widget_show_all(prefsw->prefs_dialog);
5763 
5764   main_thread_execute((lives_funcptr_t)on_prefs_page_changed, -1, NULL, "vv", prefsw->selection, prefsw);
5765   //on_prefs_page_changed(prefsw->selection, prefsw);
5766 
5767   lives_widget_queue_draw(prefsw->prefs_list);
5768   return prefsw;
5769 }
5770 
5771 
on_preferences_activate(LiVESMenuItem * menuitem,livespointer user_data)5772 void on_preferences_activate(LiVESMenuItem * menuitem, livespointer user_data) {
5773   LiVESWidget *saved_dialog = (LiVESWidget *)user_data;
5774   mt_needs_idlefunc = FALSE;
5775 
5776   if (mainw->multitrack) {
5777     if (mainw->multitrack->idlefunc > 0) {
5778       lives_source_remove(mainw->multitrack->idlefunc);
5779       mainw->multitrack->idlefunc = 0;
5780       mt_needs_idlefunc = TRUE;
5781     }
5782     mt_desensitise(mainw->multitrack);
5783   }
5784 
5785   if (menuitem) prefs_current_page = -1;
5786 
5787   if (prefsw && prefsw->prefs_dialog) {
5788     lives_window_present(LIVES_WINDOW(prefsw->prefs_dialog));
5789     lives_xwindow_raise(lives_widget_get_xwindow(prefsw->prefs_dialog));
5790     return;
5791   }
5792 
5793   future_prefs->disabled_decoders = lives_list_copy_strings(prefs->disabled_decoders);
5794   lives_set_cursor_style(LIVES_CURSOR_BUSY, NULL);
5795   lives_widget_context_update();
5796 
5797   prefsw = create_prefs_dialog(saved_dialog);
5798   lives_widget_show(prefsw->prefs_dialog);
5799   lives_window_set_position(LIVES_WINDOW(prefsw->prefs_dialog), LIVES_WIN_POS_CENTER_ALWAYS);
5800   lives_widget_queue_draw(prefsw->prefs_dialog);
5801   lives_set_cursor_style(LIVES_CURSOR_NORMAL, NULL);
5802   lives_set_cursor_style(LIVES_CURSOR_NORMAL, prefsw->prefs_dialog);
5803 }
5804 
5805 
5806 /*!
5807   Closes preferences dialog window
5808 */
on_prefs_close_clicked(LiVESButton * button,livespointer user_data)5809 void on_prefs_close_clicked(LiVESButton * button, livespointer user_data) {
5810   lives_list_free_all(&prefs->acodec_list);
5811   lives_list_free_all(&prefsw->pbq_list);
5812   lives_tree_view_set_model(LIVES_TREE_VIEW(prefsw->prefs_list), NULL);
5813   lives_free(prefsw->audp_name);
5814   lives_free(prefsw->orig_audp_name);
5815   lives_freep((void **)&resaudw);
5816   lives_list_free_all(&future_prefs->disabled_decoders);
5817 
5818   lives_general_button_clicked(button, user_data);
5819 
5820   prefsw = NULL;
5821 
5822   if (mainw->prefs_need_restart) {
5823     do_shutdown_msg();
5824     on_quit_activate(NULL, NULL);
5825   }
5826   if (mainw->multitrack) {
5827     mt_sensitise(mainw->multitrack);
5828     if (mt_needs_idlefunc) {
5829       mainw->multitrack->idlefunc = mt_idle_add(mainw->multitrack);
5830     }
5831   }
5832 }
5833 
5834 
pref_change_images(void)5835 void pref_change_images(void) {
5836   if (prefs->show_gui) {
5837     if (mainw->current_file == -1) {
5838       load_start_image(0);
5839       load_end_image(0);
5840       if (mainw->preview_box) load_preview_image(FALSE);
5841     }
5842     lives_widget_queue_draw(LIVES_MAIN_WINDOW_WIDGET);
5843     if (mainw->multitrack && mainw->multitrack->sep_image) {
5844       lives_image_set_from_pixbuf(LIVES_IMAGE(mainw->multitrack->sep_image), mainw->imsep);
5845       mt_show_current_frame(mainw->multitrack, FALSE);
5846       lives_widget_queue_draw(LIVES_MAIN_WINDOW_WIDGET);
5847     }
5848   }
5849 }
5850 
5851 
pref_change_xcolours(void)5852 void pref_change_xcolours(void) {
5853   // minor colours changed
5854   if (prefs->show_gui) {
5855     if (mainw->multitrack) {
5856       resize_timeline(mainw->multitrack);
5857       set_mt_colours(mainw->multitrack);
5858     } else {
5859       update_play_times();
5860       lives_widget_queue_draw(LIVES_MAIN_WINDOW_WIDGET);
5861     }
5862   }
5863 }
5864 
5865 
pref_change_colours(void)5866 void pref_change_colours(void) {
5867   if (mainw->preview_box) {
5868     set_preview_box_colours();
5869   }
5870 
5871   if (prefs->show_gui) {
5872     set_colours(&palette->normal_fore, &palette->normal_back, &palette->menu_and_bars_fore, &palette->menu_and_bars, \
5873                 &palette->info_base, &palette->info_text);
5874 
5875     if (mainw->multitrack) {
5876       set_mt_colours(mainw->multitrack);
5877       scroll_tracks(mainw->multitrack, mainw->multitrack->top_track, FALSE);
5878       track_select(mainw->multitrack);
5879       mt_clip_select(mainw->multitrack, FALSE);
5880     } else update_play_times();
5881   }
5882 }
5883 
5884 
on_prefs_apply_clicked(LiVESButton * button,livespointer user_data)5885 void on_prefs_apply_clicked(LiVESButton * button, livespointer user_data) {
5886   boolean needs_restart = FALSE;
5887 
5888   lives_set_cursor_style(LIVES_CURSOR_BUSY, prefsw->prefs_dialog);
5889 
5890   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->applybutton), FALSE);
5891   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->revertbutton), FALSE);
5892   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->closebutton), FALSE);
5893 
5894   // Apply preferences
5895   needs_restart = apply_prefs(FALSE);
5896 
5897   if (!mainw->prefs_need_restart) {
5898     mainw->prefs_need_restart = needs_restart;
5899   }
5900 
5901   if (needs_restart) {
5902     //do_info_dialog(_("For the directory change to take effect LiVES will restart when preferences dialog closes."));
5903     do_info_dialog(_("LiVES will restart when preferences dialog closes."));
5904   }
5905 
5906   if (mainw->prefs_changed & PREFS_THEME_CHANGED) {
5907     if (!lives_strcmp(future_prefs->theme, LIVES_THEME_NONE)) {
5908       lives_widget_set_sensitive(mainw->export_theme, FALSE);
5909       do_info_dialog(_("Disabling the theme will not take effect until the next time you start LiVES."));
5910     } else do_info_dialog(_("Theme changes will only take full effect after restarting LiVES."));
5911   } else
5912     lives_widget_set_sensitive(mainw->export_theme, TRUE);
5913 
5914   if (mainw->prefs_changed & PREFS_JACK_CHANGED) {
5915     do_info_dialog(_("Jack options will not take effect until the next time you start LiVES."));
5916   }
5917 
5918   if (!(mainw->prefs_changed & PREFS_THEME_CHANGED) &&
5919       ((mainw->prefs_changed & PREFS_IMAGES_CHANGED) ||
5920        (mainw->prefs_changed & PREFS_XCOLOURS_CHANGED) ||
5921        (mainw->prefs_changed & PREFS_COLOURS_CHANGED))) {
5922     // set details in prefs
5923     set_palette_prefs(TRUE);
5924     if (mainw->prefs_changed & PREFS_IMAGES_CHANGED) {
5925       load_theme_images();
5926     }
5927   }
5928 
5929   if (mainw->prefs_changed & PREFS_IMAGES_CHANGED) {
5930     pref_change_images();
5931   }
5932 
5933   if (mainw->prefs_changed & PREFS_XCOLOURS_CHANGED) {
5934     pref_change_xcolours();
5935   }
5936 
5937   if (mainw->prefs_changed & PREFS_COLOURS_CHANGED) {
5938     // major coulours changed
5939     // force reshow of window
5940     pref_change_colours();
5941     on_prefs_revert_clicked(button, NULL);
5942   } else if (mainw->prefs_changed & PREFS_NEEDS_REVERT) {
5943     on_prefs_revert_clicked(button, NULL);
5944   }
5945 
5946   lives_set_cursor_style(LIVES_CURSOR_NORMAL, NULL);
5947   lives_set_cursor_style(LIVES_CURSOR_NORMAL, prefsw->prefs_dialog);
5948 
5949   lives_button_grab_default_special(prefsw->closebutton);
5950   lives_widget_set_sensitive(LIVES_WIDGET(prefsw->closebutton), TRUE);
5951 
5952   mainw->prefs_changed = 0;
5953 }
5954 
5955 
5956 /*
5957   Function is used to select particular row in preferences selection list
5958   selection is performed according to provided index which is one of LIST_ENTRY_* constants
5959 */
select_pref_list_row(uint32_t selected_idx,_prefsw * prefsw)5960 static void select_pref_list_row(uint32_t selected_idx, _prefsw * prefsw) {
5961   LiVESTreeIter iter;
5962   LiVESTreeModel *model;
5963   boolean valid;
5964   uint32_t idx;
5965 
5966   model = lives_tree_view_get_model(LIVES_TREE_VIEW(prefsw->prefs_list));
5967   valid = lives_tree_model_get_iter_first(model, &iter);
5968   while (valid) {
5969     lives_tree_model_get(model, &iter, LIST_NUM, &idx, -1);
5970     //
5971     if (idx == selected_idx) {
5972       lives_tree_selection_select_iter(prefsw->selection, &iter);
5973       break;
5974     }
5975     //
5976     valid = lives_tree_model_iter_next(model, &iter);
5977   }
5978 }
5979 
5980 
on_prefs_revert_clicked(LiVESButton * button,livespointer user_data)5981 void on_prefs_revert_clicked(LiVESButton * button, livespointer user_data) {
5982   LiVESWidget *saved_dialog;
5983   register int i;
5984 
5985   lives_set_cursor_style(LIVES_CURSOR_BUSY, NULL);
5986   lives_widget_process_updates(prefsw->prefs_dialog);
5987 
5988   if (future_prefs->vpp_argv) {
5989     for (i = 0; future_prefs->vpp_argv[i]; lives_free(future_prefs->vpp_argv[i++]));
5990 
5991     lives_free(future_prefs->vpp_argv);
5992 
5993     future_prefs->vpp_argv = NULL;
5994   }
5995   memset(future_prefs->vpp_name, 0, 64);
5996 
5997   lives_list_free_all(&prefs->acodec_list);
5998   lives_list_free_all(&prefsw->pbq_list);
5999   lives_tree_view_set_model(LIVES_TREE_VIEW(prefsw->prefs_list), NULL);
6000 
6001   lives_free(prefsw->audp_name);
6002   lives_free(prefsw->orig_audp_name);
6003 
6004   lives_list_free_all(&future_prefs->disabled_decoders);
6005 
6006   saved_dialog = prefsw->prefs_dialog;
6007   saved_revertbutton = prefsw->revertbutton;
6008   saved_applybutton = prefsw->applybutton;
6009   saved_closebutton = prefsw->closebutton;
6010   lives_signal_handler_disconnect(prefsw->closebutton, prefsw->close_func);
6011   lives_widget_remove_accelerator(prefsw->closebutton, prefsw->accel_group, LIVES_KEY_Escape, (LiVESXModifierType)0);
6012 
6013   lives_widget_destroy(prefsw->dialog_hpaned);
6014   lives_freep((void **)&prefsw);
6015 
6016   future_prefs->jack_opts = prefs->jack_opts;
6017 
6018   on_preferences_activate(NULL, saved_dialog);
6019 
6020   lives_set_cursor_style(LIVES_CURSOR_NORMAL, NULL);
6021 }
6022 
6023 
text_to_lives_perm(const char * text)6024 static int text_to_lives_perm(const char *text) {
6025   if (!text || !*text) return LIVES_PERM_INVALID;
6026   if (!strcmp(text, "DOWNLOADLOCAL")) return LIVES_PERM_DOWNLOAD_LOCAL;
6027   if (!strcmp(text, "COPYLOCAL")) return LIVES_PERM_COPY_LOCAL;
6028   return LIVES_PERM_INVALID;
6029 }
6030 
lives_ask_permission(char ** argv,int argc,int offs)6031 boolean lives_ask_permission(char **argv, int argc, int offs) {
6032   const char *sudocom = NULL;
6033   char *msg;
6034   boolean ret;
6035   int what = atoi(argv[offs]);
6036   if (what == LIVES_PERM_INVALID && *argv[offs]) {
6037     what = text_to_lives_perm(argv[offs]);
6038   }
6039 
6040   switch (what) {
6041   case LIVES_PERM_OSC_PORTS:
6042     return ask_permission_dialog(what);
6043   case LIVES_PERM_DOWNLOAD_LOCAL:
6044   case LIVES_PERM_COPY_LOCAL:
6045     if (argc >= 5 && strstr(argv[4], "_TRY_SUDO_")) sudocom = (const char *)argv[2];
6046     ret = ask_permission_dialog_complex(what, argv, argc, ++offs, sudocom);
6047     return ret;
6048   default:
6049     msg = lives_strdup_printf("Unknown permission (%d) requested", what);
6050     LIVES_WARN(msg);
6051     lives_free(msg);
6052   }
6053   return FALSE;
6054 }
6055 
6056