1 /*****************************************************************
2  * gmerlin - a general purpose multimedia framework and applications
3  *
4  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5  * gmerlin-general@lists.sourceforge.net
6  * http://gmerlin.sourceforge.net
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  * *****************************************************************/
21 
22 #include <gtk/gtk.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 
26 #include <config.h>
27 
28 #include <gmerlin/pluginregistry.h>
29 #include <gmerlin/utils.h>
30 #include <gmerlin/cfg_dialog.h>
31 
32 #include <gui_gtk/plugin.h>
33 #include <gui_gtk/gtkutils.h>
34 
35 struct bg_gtk_plugin_widget_single_s
36   {
37   GtkWidget * label;
38   GtkWidget * combo;
39   GtkWidget * config_button;
40   GtkWidget * info_button;
41   GtkWidget * audio_button;
42   GtkWidget * video_button;
43 
44   bg_plugin_registry_t * reg;
45   const bg_plugin_info_t * info;
46 
47   bg_plugin_handle_t * handle;
48 
49   bg_cfg_section_t * section;
50   bg_cfg_section_t * audio_section;
51   bg_cfg_section_t * video_section;
52   bg_cfg_section_t * subtitle_text_section;
53   bg_cfg_section_t * subtitle_overlay_section;
54 
55   int section_priv;
56   int audio_section_priv;
57   int video_section_priv;
58   int subtitle_text_section_priv;
59   int subtitle_overlay_section_priv;
60 
61   int32_t type_mask;
62   int32_t flag_mask;
63   void (*set_plugin)(const bg_plugin_info_t *, void*);
64   void * set_plugin_data;
65 
66   bg_set_parameter_func_t set_parameter;
67   bg_get_parameter_func_t get_parameter;
68   void * set_parameter_data;
69   };
70 
set_parameter(void * data,const char * name,const bg_parameter_value_t * v)71 static void set_parameter(void * data, const char * name,
72                           const bg_parameter_value_t * v)
73   {
74   bg_gtk_plugin_widget_single_t * widget;
75   widget = (bg_gtk_plugin_widget_single_t *)data;
76 
77   if(widget->handle && widget->handle->plugin->set_parameter)
78     {
79     bg_plugin_lock(widget->handle);
80     widget->handle->plugin->set_parameter(widget->handle->priv, name, v);
81     bg_plugin_unlock(widget->handle);
82     }
83   if(widget->set_parameter)
84     {
85     widget->set_parameter(widget->set_parameter_data, name, v);
86     }
87 
88   }
89 
get_parameter(void * data,const char * name,bg_parameter_value_t * v)90 static int get_parameter(void * data, const char * name,
91                          bg_parameter_value_t * v)
92   {
93   int ret = 0;
94   bg_gtk_plugin_widget_single_t * widget;
95   widget = (bg_gtk_plugin_widget_single_t *)data;
96 
97   if(widget->handle && widget->handle->plugin->get_parameter)
98     {
99     bg_plugin_lock(widget->handle);
100     ret = widget->handle->plugin->get_parameter(widget->handle->priv, name, v);
101     bg_plugin_unlock(widget->handle);
102     }
103   return ret;
104   }
105 
button_callback(GtkWidget * w,gpointer data)106 static void button_callback(GtkWidget * w, gpointer data)
107   {
108   const bg_parameter_info_t * parameters;
109   bg_gtk_plugin_widget_single_t * widget;
110 
111   bg_dialog_t * dialog;
112 
113   widget = (bg_gtk_plugin_widget_single_t *)data;
114 
115   if(w == widget->info_button)
116     {
117     bg_gtk_plugin_info_show(widget->info, widget->info_button);
118     }
119   else if(w == widget->config_button)
120     {
121     if(widget->handle)
122       parameters = widget->handle->plugin->get_parameters(widget->handle->priv);
123     else
124       parameters = widget->info->parameters;
125 
126     if(widget->handle && widget->handle->plugin->get_parameter)
127       bg_cfg_section_get(widget->section, parameters,
128                          widget->handle->plugin->get_parameter,
129                          widget->handle->priv);
130 
131     dialog = bg_dialog_create(widget->section,
132                               set_parameter,
133                               get_parameter,
134                               (void*)widget,
135                               parameters,
136                               TRD(widget->info->long_name, widget->info->gettext_domain));
137     bg_dialog_show(dialog, widget->config_button);
138     bg_dialog_destroy(dialog);
139     }
140 
141   else if(w == widget->audio_button)
142     {
143     dialog = bg_dialog_create(widget->audio_section,
144                               NULL, NULL, NULL,
145                               widget->info->audio_parameters,
146                               TRD(widget->info->long_name, widget->info->gettext_domain));
147     bg_dialog_show(dialog, widget->audio_button);
148     bg_dialog_destroy(dialog);
149     }
150 
151   else if(w == widget->video_button)
152     {
153     dialog = bg_dialog_create(widget->video_section,
154                               NULL, NULL, NULL,
155                               widget->info->video_parameters,
156                               TRD(widget->info->long_name, widget->info->gettext_domain));
157     bg_dialog_show(dialog, widget->video_button);
158     bg_dialog_destroy(dialog);
159     }
160 
161   }
162 
create_pixmap_button(bg_gtk_plugin_widget_single_t * w,const char * filename,const char * tooltip)163 static GtkWidget * create_pixmap_button(bg_gtk_plugin_widget_single_t * w,
164                                         const char * filename,
165                                         const char * tooltip)
166   {
167   GtkWidget * button;
168   GtkWidget * image;
169   char * path;
170   path = bg_search_file_read("icons", filename);
171   if(path)
172     {
173     image = gtk_image_new_from_file(path);
174     free(path);
175     }
176   else
177     image = gtk_image_new();
178 
179   gtk_widget_show(image);
180   button = gtk_button_new();
181   gtk_container_add(GTK_CONTAINER(button), image);
182 
183   bg_gtk_tooltips_set_tip(button, tooltip, PACKAGE);
184 
185   g_signal_connect(G_OBJECT(button), "clicked",
186                    G_CALLBACK(button_callback), (gpointer)w);
187 
188   gtk_widget_show(button);
189   return button;
190   }
191 
update_sensitive(bg_gtk_plugin_widget_single_t * widget)192 static void update_sensitive(bg_gtk_plugin_widget_single_t * widget)
193   {
194   if(!widget->info)
195     return;
196 
197   if(widget->info->parameters)
198     gtk_widget_set_sensitive(widget->config_button, 1);
199   else
200     gtk_widget_set_sensitive(widget->config_button, 0);
201 
202   if(widget->info->type & (BG_PLUGIN_ENCODER_AUDIO|
203                            BG_PLUGIN_ENCODER_VIDEO|
204                            BG_PLUGIN_ENCODER))
205     {
206     if(widget->audio_button)
207       {
208       if(widget->info->audio_parameters)
209         gtk_widget_set_sensitive(widget->audio_button, 1);
210       else
211         gtk_widget_set_sensitive(widget->audio_button, 0);
212       }
213 
214     if(widget->video_button)
215       {
216       if(widget->info->video_parameters)
217         gtk_widget_set_sensitive(widget->video_button, 1);
218       else
219         gtk_widget_set_sensitive(widget->video_button, 0);
220       }
221     }
222 
223   }
224 
change_callback(GtkWidget * w,gpointer data)225 static void change_callback(GtkWidget * w, gpointer data)
226   {
227 
228   bg_gtk_plugin_widget_single_t * widget;
229 
230   widget = (bg_gtk_plugin_widget_single_t *)data;
231 
232   widget->info =
233     bg_plugin_find_by_index(widget->reg,
234                             gtk_combo_box_get_active(GTK_COMBO_BOX(widget->combo)),
235                             widget->type_mask, widget->flag_mask);
236 
237   if(widget->handle)
238     {
239     bg_plugin_unref(widget->handle);
240     widget->handle = NULL;
241     }
242   update_sensitive(widget);
243 
244   if(widget->section_priv)
245     {
246     bg_cfg_section_destroy(widget->section);
247     widget->section_priv = 0;
248     }
249 
250   widget->section = bg_plugin_registry_get_section(widget->reg,
251                                                    widget->info->name);
252 
253   if(widget->info->type & (BG_PLUGIN_ENCODER_AUDIO|
254                            BG_PLUGIN_ENCODER_VIDEO|
255                            BG_PLUGIN_ENCODER_SUBTITLE_TEXT|
256                            BG_PLUGIN_ENCODER_SUBTITLE_OVERLAY|
257                            BG_PLUGIN_ENCODER))
258     {
259     if(widget->audio_section_priv)
260       {
261       bg_cfg_section_destroy(widget->audio_section);
262       widget->audio_section_priv = 0;
263       }
264 
265     if(widget->info->audio_parameters)
266       widget->audio_section =
267         bg_cfg_section_find_subsection(widget->section, "$audio");
268     else
269       widget->audio_section = NULL;
270 
271     if(widget->video_section_priv)
272       {
273       bg_cfg_section_destroy(widget->video_section);
274       widget->video_section_priv = 0;
275       }
276 
277     if(widget->info->video_parameters)
278       widget->video_section =
279         bg_cfg_section_find_subsection(widget->section, "$video");
280     else
281       widget->video_section = NULL;
282 
283     if(widget->subtitle_text_section_priv)
284       {
285       bg_cfg_section_destroy(widget->subtitle_text_section);
286       widget->subtitle_text_section_priv = 0;
287       }
288 
289     if(widget->info->subtitle_text_parameters)
290       widget->subtitle_text_section =
291         bg_cfg_section_find_subsection(widget->section, "$subtitle_text");
292     else
293       widget->subtitle_text_section = NULL;
294 
295     if(widget->subtitle_overlay_section_priv)
296       {
297       bg_cfg_section_destroy(widget->subtitle_overlay_section);
298       widget->subtitle_overlay_section_priv = 0;
299       }
300 
301     if(widget->info->subtitle_overlay_parameters)
302       widget->subtitle_overlay_section =
303         bg_cfg_section_find_subsection(widget->section, "$subtitle_overlay");
304     else
305       widget->subtitle_overlay_section = NULL;
306 
307     }
308 
309   if(widget->set_plugin)
310     widget->set_plugin(widget->info, widget->set_plugin_data);
311 
312   }
313 
314 void
bg_gtk_plugin_widget_single_set_change_callback(bg_gtk_plugin_widget_single_t * w,void (* set_plugin)(const bg_plugin_info_t * plugin,void * data),void * set_plugin_data)315 bg_gtk_plugin_widget_single_set_change_callback(bg_gtk_plugin_widget_single_t * w,
316                                                 void (*set_plugin)(const bg_plugin_info_t * plugin,
317                                                                    void * data),
318                                                 void * set_plugin_data)
319   {
320   w->set_plugin = set_plugin;
321   w->set_plugin_data = set_plugin_data;
322 
323   }
324 
325 void
bg_gtk_plugin_widget_single_set_parameter_callback(bg_gtk_plugin_widget_single_t * w,bg_set_parameter_func_t func,void * priv)326 bg_gtk_plugin_widget_single_set_parameter_callback(bg_gtk_plugin_widget_single_t * w,
327                                                    bg_set_parameter_func_t func,
328                                                    void * priv)
329   {
330   w->set_parameter = func;
331   w->set_parameter_data = priv;
332   }
333 
334 
335 
336 bg_gtk_plugin_widget_single_t *
bg_gtk_plugin_widget_single_create(char * label,bg_plugin_registry_t * reg,uint32_t type_mask,uint32_t flag_mask)337 bg_gtk_plugin_widget_single_create(char * label,
338                                    bg_plugin_registry_t * reg,
339                                    uint32_t type_mask,
340                                    uint32_t flag_mask)
341   {
342   int default_index;
343 
344   int num_plugins, i;
345   bg_gtk_plugin_widget_single_t * ret;
346   const bg_plugin_info_t * info;
347   const bg_plugin_info_t * default_info;
348 
349   ret = calloc(1, sizeof(*ret));
350 
351 
352   ret->reg = reg;
353   ret->type_mask = type_mask;
354   ret->flag_mask = flag_mask;
355 
356   /* Make label */
357 
358   ret->label = gtk_label_new(label);
359   gtk_misc_set_alignment(GTK_MISC(ret->label), 0.0, 0.5);
360   gtk_widget_show(ret->label);
361 
362   /* Make buttons */
363 
364   /* Config */
365 
366   ret->config_button = create_pixmap_button(ret, "config_16.png",
367                                             TRS("Plugin options"));
368 
369   /* Info */
370 
371   ret->info_button = create_pixmap_button(ret, "info_16.png",
372                                           TRS("Plugin info"));
373 
374   /* Audio */
375 
376   if(type_mask & (BG_PLUGIN_ENCODER_AUDIO | BG_PLUGIN_ENCODER))
377     {
378     ret->audio_button = create_pixmap_button(ret, "audio_16.png",
379                                             TRS("Audio options"));
380     }
381 
382   /* Video */
383 
384   if(type_mask & (BG_PLUGIN_ENCODER_VIDEO | BG_PLUGIN_ENCODER))
385     {
386     ret->video_button = create_pixmap_button(ret, "video_16.png",
387                                             TRS("Video options"));
388     }
389 
390   /* Create combo */
391 
392   num_plugins = bg_plugin_registry_get_num_plugins(reg,
393                                                    type_mask,
394                                                    flag_mask);
395 
396   default_info = bg_plugin_registry_get_default(reg, type_mask, flag_mask);
397 
398 
399   /* Make combo */
400   default_index = -1;
401   ret->combo = bg_gtk_combo_box_new_text();
402   g_signal_connect(G_OBJECT(ret->combo),
403                    "changed", G_CALLBACK(change_callback),
404                    (gpointer)ret);
405   for(i = 0; i < num_plugins; i++)
406     {
407     info = bg_plugin_find_by_index(reg, i, type_mask, flag_mask);
408     bg_gtk_combo_box_append_text(ret->combo, info->long_name);
409 
410     if(info == default_info)
411       default_index = i;
412     }
413   if(default_index >= 0)
414     gtk_combo_box_set_active(GTK_COMBO_BOX(ret->combo), default_index);
415 
416   /* Show */
417 
418   gtk_widget_show(ret->combo);
419 
420 
421 
422   return ret;
423   }
424 
bg_gtk_plugin_widget_single_destroy(bg_gtk_plugin_widget_single_t * w)425 void bg_gtk_plugin_widget_single_destroy(bg_gtk_plugin_widget_single_t * w)
426   {
427   if(w->handle)
428     bg_plugin_unref(w->handle);
429 
430   if(w->section_priv)
431     bg_cfg_section_destroy(w->section);
432 
433   if(w->audio_section_priv)
434     bg_cfg_section_destroy(w->audio_section);
435 
436   if(w->video_section_priv)
437     bg_cfg_section_destroy(w->video_section);
438 
439   if(w->subtitle_text_section_priv)
440     bg_cfg_section_destroy(w->subtitle_text_section);
441 
442   if(w->subtitle_overlay_section_priv)
443     bg_cfg_section_destroy(w->subtitle_overlay_section);
444 
445   free(w);
446   }
447 
bg_gtk_plugin_widget_single_attach(bg_gtk_plugin_widget_single_t * w,GtkWidget * table,int * row,int * num_columns)448 void bg_gtk_plugin_widget_single_attach(bg_gtk_plugin_widget_single_t * w,
449                                         GtkWidget * table,
450                                         int * row, int * num_columns)
451   {
452   int columns_needed = 4;
453   int col;
454 
455   if(w->audio_button)
456     columns_needed++;
457   if(w->video_button)
458     columns_needed++;
459   if(*num_columns < columns_needed)
460     *num_columns = columns_needed;
461 
462   gtk_table_resize(GTK_TABLE(table), *row+1, *num_columns);
463 
464   gtk_table_attach(GTK_TABLE(table), w->label,
465                    0, 1, *row, *row+1, GTK_FILL, GTK_SHRINK, 0, 0);
466 
467   gtk_table_attach(GTK_TABLE(table),
468                    w->combo,
469                    1, 2, *row, *row+1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
470 
471   gtk_table_attach(GTK_TABLE(table),
472                    w->info_button,
473                    2, 3, *row, *row+1, GTK_FILL, GTK_SHRINK, 0, 0);
474 
475   gtk_table_attach(GTK_TABLE(table),
476                    w->config_button,
477                    3, 4, *row, *row+1, GTK_FILL, GTK_SHRINK, 0, 0);
478 
479   col = 4;
480   if(w->audio_button)
481     {
482     gtk_table_attach(GTK_TABLE(table),
483                      w->audio_button,
484                      col, col+1, *row, *row+1, GTK_FILL, GTK_SHRINK, 0, 0);
485     col++;
486     }
487   if(w->video_button)
488     {
489     gtk_table_attach(GTK_TABLE(table),
490                      w->video_button,
491                      col, col+1, *row, *row+1, GTK_FILL, GTK_SHRINK, 0, 0);
492     }
493 
494   (*row)++;
495   }
496 
bg_gtk_plugin_widget_single_set_sensitive(bg_gtk_plugin_widget_single_t * w,int sensitive)497 void bg_gtk_plugin_widget_single_set_sensitive(bg_gtk_plugin_widget_single_t * w,
498                                                int sensitive)
499   {
500   gtk_widget_set_sensitive(w->combo, sensitive);
501   gtk_widget_set_sensitive(w->info_button, sensitive);
502   gtk_widget_set_sensitive(w->config_button, sensitive);
503   if(w->audio_button)
504     gtk_widget_set_sensitive(w->audio_button, sensitive);
505   if(w->video_button)
506     gtk_widget_set_sensitive(w->video_button, sensitive);
507 
508   if(sensitive)
509     update_sensitive(w);
510 
511   }
512 
513 const bg_plugin_info_t *
bg_gtk_plugin_widget_single_get_plugin(bg_gtk_plugin_widget_single_t * w)514 bg_gtk_plugin_widget_single_get_plugin(bg_gtk_plugin_widget_single_t * w)
515   {
516   return w->info;
517   }
518 
bg_gtk_plugin_widget_single_set_plugin(bg_gtk_plugin_widget_single_t * w,const bg_plugin_info_t * info)519 void bg_gtk_plugin_widget_single_set_plugin(bg_gtk_plugin_widget_single_t * w,
520                                             const bg_plugin_info_t * info)
521   {
522   int index;
523   int num_plugins;
524   int i;
525   const bg_plugin_info_t * test_info;
526   index = -1;
527 
528   num_plugins = bg_plugin_registry_get_num_plugins(w->reg,
529                                                    w->type_mask,
530                                                    w->flag_mask);
531 
532   for(i = 0; i < num_plugins; i++)
533     {
534     test_info = bg_plugin_find_by_index(w->reg, i, w->type_mask, w->flag_mask);
535 
536     if(info == test_info)
537       {
538       index = i;
539       break;
540       }
541     }
542   if(index >= 0)
543     gtk_combo_box_set_active(GTK_COMBO_BOX(w->combo), index);
544   }
545 
546 bg_plugin_handle_t *
bg_gtk_plugin_widget_single_load_plugin(bg_gtk_plugin_widget_single_t * w)547 bg_gtk_plugin_widget_single_load_plugin(bg_gtk_plugin_widget_single_t * w)
548   {
549   if(w->handle)
550     bg_plugin_unref(w->handle);
551   w->handle = bg_plugin_load(w->reg, w->info);
552   return w->handle;
553   }
554 
555 bg_cfg_section_t *
bg_gtk_plugin_widget_single_get_section(bg_gtk_plugin_widget_single_t * w)556 bg_gtk_plugin_widget_single_get_section(bg_gtk_plugin_widget_single_t * w)
557   {
558   return w->section;
559   }
560 
561 bg_cfg_section_t *
bg_gtk_plugin_widget_single_get_audio_section(bg_gtk_plugin_widget_single_t * w)562 bg_gtk_plugin_widget_single_get_audio_section(bg_gtk_plugin_widget_single_t * w)
563   {
564   return w->audio_section;
565   }
566 
567 bg_cfg_section_t *
bg_gtk_plugin_widget_single_get_video_section(bg_gtk_plugin_widget_single_t * w)568 bg_gtk_plugin_widget_single_get_video_section(bg_gtk_plugin_widget_single_t * w)
569   {
570   return w->video_section;
571 
572   }
573 
574 bg_cfg_section_t *
bg_gtk_plugin_widget_single_get_subtitle_text_section(bg_gtk_plugin_widget_single_t * w)575 bg_gtk_plugin_widget_single_get_subtitle_text_section(bg_gtk_plugin_widget_single_t * w)
576   {
577   return w->subtitle_text_section;
578 
579   }
580 
581 bg_cfg_section_t *
bg_gtk_plugin_widget_single_get_subtitle_overlay_section(bg_gtk_plugin_widget_single_t * w)582 bg_gtk_plugin_widget_single_get_subtitle_overlay_section(bg_gtk_plugin_widget_single_t * w)
583   {
584   return w->subtitle_overlay_section;
585 
586   }
587 
588 
589 void
bg_gtk_plugin_widget_single_set_section(bg_gtk_plugin_widget_single_t * w,bg_cfg_section_t * s,int copy)590 bg_gtk_plugin_widget_single_set_section(bg_gtk_plugin_widget_single_t * w,
591                                         bg_cfg_section_t * s, int copy)
592   {
593   if(w->section_priv)
594     bg_cfg_section_destroy(w->section);
595 
596   if(copy)
597     {
598     if(s)
599       {
600       w->section_priv = 1;
601       w->section = bg_cfg_section_copy(s);
602       }
603     else
604       w->section_priv = 0;
605     }
606   else
607     {
608     w->section = s;
609     w->section_priv = 0;
610     }
611 
612   }
613 
614 void
bg_gtk_plugin_widget_single_set_audio_section(bg_gtk_plugin_widget_single_t * w,bg_cfg_section_t * s,int copy)615 bg_gtk_plugin_widget_single_set_audio_section(bg_gtk_plugin_widget_single_t * w,
616                                               bg_cfg_section_t * s, int copy)
617   {
618   if(w->audio_section_priv)
619     bg_cfg_section_destroy(w->audio_section);
620 
621   if(copy)
622     {
623     if(s)
624       {
625       w->audio_section_priv = 1;
626       w->audio_section = bg_cfg_section_copy(s);
627       }
628     else
629       w->audio_section_priv = 0;
630     }
631   else
632     {
633     w->audio_section = s;
634     w->audio_section_priv = 0;
635     }
636 
637   }
638 
639 void
bg_gtk_plugin_widget_single_set_video_section(bg_gtk_plugin_widget_single_t * w,bg_cfg_section_t * s,int copy)640 bg_gtk_plugin_widget_single_set_video_section(bg_gtk_plugin_widget_single_t * w,
641                                               bg_cfg_section_t * s, int copy)
642   {
643   if(w->video_section_priv)
644     bg_cfg_section_destroy(w->video_section);
645 
646   if(copy)
647     {
648     if(s)
649       {
650       w->video_section_priv = 1;
651       w->video_section = bg_cfg_section_copy(s);
652       }
653     else
654       w->video_section_priv = 0;
655     }
656   else
657     {
658     w->video_section = s;
659     w->video_section_priv = 0;
660     }
661   }
662 
663 void
bg_gtk_plugin_widget_single_set_subtitle_text_section(bg_gtk_plugin_widget_single_t * w,bg_cfg_section_t * s,int copy)664 bg_gtk_plugin_widget_single_set_subtitle_text_section(bg_gtk_plugin_widget_single_t * w,
665                                                       bg_cfg_section_t * s, int copy)
666   {
667   if(w->subtitle_text_section_priv)
668     bg_cfg_section_destroy(w->subtitle_text_section);
669 
670   if(copy)
671     {
672     if(s)
673       {
674       w->subtitle_text_section_priv = 1;
675       w->subtitle_text_section = bg_cfg_section_copy(s);
676       }
677     else
678       w->subtitle_text_section_priv = 0;
679     }
680   else
681     {
682     w->subtitle_text_section = s;
683     w->subtitle_text_section_priv = 0;
684     }
685   }
686 
687 void
bg_gtk_plugin_widget_single_set_subtitle_overlay_section(bg_gtk_plugin_widget_single_t * w,bg_cfg_section_t * s,int copy)688 bg_gtk_plugin_widget_single_set_subtitle_overlay_section(bg_gtk_plugin_widget_single_t * w,
689                                                          bg_cfg_section_t * s, int copy)
690   {
691   if(w->subtitle_overlay_section_priv)
692     bg_cfg_section_destroy(w->subtitle_overlay_section);
693 
694   if(copy)
695     {
696 
697     if(s)
698       {
699       w->subtitle_overlay_section_priv = 1;
700       w->subtitle_overlay_section = bg_cfg_section_copy(s);
701       }
702     else
703       w->subtitle_overlay_section_priv = 0;
704     }
705   else
706     {
707     w->subtitle_overlay_section = s;
708     w->subtitle_overlay_section_priv = 0;
709     }
710   }
711 
712 void
bg_gtk_plugin_widget_single_show_buttons(bg_gtk_plugin_widget_single_t * w,int show)713 bg_gtk_plugin_widget_single_show_buttons(bg_gtk_plugin_widget_single_t * w,
714                                          int show)
715   {
716   if(show)
717     {
718     gtk_widget_show(w->config_button);
719     gtk_widget_show(w->info_button);
720 
721     if(w->audio_button)
722       gtk_widget_show(w->audio_button);
723 
724     if(w->video_button)
725       gtk_widget_show(w->video_button);
726     }
727   else
728     {
729     gtk_widget_hide(w->config_button);
730     gtk_widget_hide(w->info_button);
731 
732     if(w->audio_button)
733       gtk_widget_hide(w->audio_button);
734 
735     if(w->video_button)
736       gtk_widget_hide(w->video_button);
737     }
738 
739   }
740