comparison src/aosd/aosd_ui.c @ 569:d401f87f89f7 trunk

[svn] - added Audacious OSD, yet-another-written-from-scratch plugin to display OSD, based on Ghosd library; currently untied from configure, to compile it you have to run make in its directory; will be added to configure after some testing
author giacomo
date Mon, 29 Jan 2007 06:40:04 -0800
parents
children 26519231a4f4
comparison
equal deleted inserted replaced
568:8c64b5abdcda 569:d401f87f89f7
1 /*
2 *
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21 #include "aosd_ui.h"
22 #include "aosd_style.h"
23 #include "aosd_cfg.h"
24 #include "aosd_osd.h"
25 #include <glib.h>
26 #include <glib/gi18n.h>
27 #include <gdk/gdk.h>
28 #include <gtk/gtk.h>
29
30
31 extern aosd_cfg_t * global_config;
32
33
34 /*************************************************************/
35 /* small callback system used by the configuration interface */
36 typedef void (*aosd_ui_cb_func_t)( GtkWidget * , aosd_cfg_t * );
37
38 typedef struct
39 {
40 aosd_ui_cb_func_t func;
41 GtkWidget * widget;
42 }
43 aosd_ui_cb_t;
44
45 static void
46 aosd_callback_list_add ( GList ** list , GtkWidget * widget , aosd_ui_cb_func_t func )
47 {
48 aosd_ui_cb_t *cb = g_malloc(sizeof(aosd_ui_cb_t));
49 cb->widget = widget;
50 cb->func = func;
51 *list = g_list_append( *list , cb );
52 return;
53 }
54
55 static void
56 aosd_callback_list_run ( GList * list , aosd_cfg_t * cfg )
57 {
58 while ( list != NULL )
59 {
60 aosd_ui_cb_t *cb = (aosd_ui_cb_t*)list->data;
61 cb->func( cb->widget , cfg );
62 list = g_list_next( list );
63 }
64 return;
65 }
66
67 static void
68 aosd_callback_list_free ( GList * list )
69 {
70 GList *list_top = list;
71 while ( list != NULL )
72 {
73 g_free( (aosd_ui_cb_t*)list->data );
74 list = g_list_next( list );
75 }
76 g_list_free( list_top );
77 return;
78 }
79 /*************************************************************/
80
81
82
83 static gboolean
84 aosd_cb_configure_position_expose ( GtkWidget * darea ,
85 GdkEventExpose * event ,
86 gpointer coord_gp )
87 {
88 gint coord = GPOINTER_TO_INT(coord_gp);
89 gdk_draw_rectangle( GDK_DRAWABLE(darea->window) ,
90 darea->style->black_gc , TRUE ,
91 (coord % 3) * 10 , (coord / 3) * 16 , 20 , 8 );
92 return FALSE;
93 }
94
95
96 static void
97 aosd_cb_configure_position_placement_commit ( GtkWidget * table , aosd_cfg_t * cfg )
98 {
99 GList *placbt_list = gtk_container_get_children( GTK_CONTAINER(table) );
100 GList *list_iter = placbt_list;
101
102 while ( list_iter != NULL )
103 {
104 GtkWidget *placbt = list_iter->data;
105 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(placbt) ) == TRUE )
106 {
107 cfg->osd->position.placement = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(placbt),"value"));
108 break;
109 }
110 list_iter = g_list_next( list_iter );
111 }
112
113 g_list_free( placbt_list );
114 return;
115 }
116
117
118 static void
119 aosd_cb_configure_position_offset_commit ( GtkWidget * table , aosd_cfg_t * cfg )
120 {
121 cfg->osd->position.offset_x = gtk_spin_button_get_value_as_int(
122 GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(table),"offx")) );
123 cfg->osd->position.offset_y = gtk_spin_button_get_value_as_int(
124 GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(table),"offy")) );
125 return;
126 }
127
128
129 static GtkWidget *
130 aosd_ui_configure_position ( aosd_cfg_t * cfg , GList ** cb_list )
131 {
132 GtkWidget *pos_vbox;
133 GtkWidget *pos_placement_frame, *pos_placement_hbox, *pos_placement_table;
134 GtkWidget *pos_placement_bt[9], *pos_placement_bt_darea[9];
135 GtkWidget *pos_offset_table, *pos_offset_x_label, *pos_offset_x_spinbt;
136 GtkWidget *pos_offset_y_label, *pos_offset_y_spinbt;
137 gint i = 0;
138
139 pos_vbox = gtk_vbox_new( FALSE , 0 );
140 gtk_container_set_border_width( GTK_CONTAINER(pos_vbox) , 6 );
141
142 pos_placement_frame = gtk_frame_new( _("Placement") );
143 pos_placement_hbox = gtk_hbox_new( FALSE , 0 );
144 gtk_container_set_border_width( GTK_CONTAINER(pos_placement_hbox) , 6 );
145 gtk_container_add( GTK_CONTAINER(pos_placement_frame) , pos_placement_hbox );
146 gtk_box_pack_start( GTK_BOX(pos_vbox) , pos_placement_frame , FALSE , FALSE , 0 );
147
148 pos_placement_table = gtk_table_new( 3 , 3 , TRUE );
149 for ( i = 0 ; i < 9 ; i++ )
150 {
151 if ( i == 0 )
152 pos_placement_bt[i] = gtk_radio_button_new( NULL );
153 else
154 pos_placement_bt[i] = gtk_radio_button_new_from_widget( GTK_RADIO_BUTTON(pos_placement_bt[0]) );
155 gtk_toggle_button_set_mode( GTK_TOGGLE_BUTTON(pos_placement_bt[i]) , FALSE );
156 pos_placement_bt_darea[i] = gtk_drawing_area_new();
157 gtk_widget_set_size_request( pos_placement_bt_darea[i] , 40 , 40 );
158 gtk_container_add( GTK_CONTAINER(pos_placement_bt[i]) , pos_placement_bt_darea[i] );
159 g_signal_connect( G_OBJECT(pos_placement_bt_darea[i]) , "expose-event" ,
160 G_CALLBACK(aosd_cb_configure_position_expose) , GINT_TO_POINTER(i) );
161 gtk_table_attach( GTK_TABLE(pos_placement_table) , pos_placement_bt[i] ,
162 (i % 3) , (i % 3) + 1 , (i / 3) , (i / 3) + 1 ,
163 GTK_FILL , GTK_FILL , 0 , 0 );
164 g_object_set_data( G_OBJECT(pos_placement_bt[i]) , "value" , GINT_TO_POINTER(i+1) );
165 if ( cfg->osd->position.placement == (i+1) )
166 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(pos_placement_bt[i]) , TRUE );
167 }
168 gtk_box_pack_start( GTK_BOX(pos_placement_hbox) , pos_placement_table , FALSE , FALSE , 0 );
169 aosd_callback_list_add( cb_list , pos_placement_table , aosd_cb_configure_position_placement_commit );
170
171 gtk_box_pack_start( GTK_BOX(pos_placement_hbox) , gtk_vseparator_new() , FALSE , FALSE , 6 );
172
173 pos_offset_table = gtk_table_new( 2 , 2 , FALSE );
174 gtk_table_set_row_spacings( GTK_TABLE(pos_offset_table) , 4 );
175 gtk_table_set_col_spacings( GTK_TABLE(pos_offset_table) , 4 );
176 pos_offset_x_label = gtk_label_new( _( "Relative X offset:" ) );
177 gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_x_label ,
178 0 , 1 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
179 pos_offset_x_spinbt = gtk_spin_button_new_with_range( -9999 , 9999 , 1 );
180 gtk_spin_button_set_value( GTK_SPIN_BUTTON(pos_offset_x_spinbt) , cfg->osd->position.offset_x );
181 gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_x_spinbt ,
182 1 , 2 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
183 g_object_set_data( G_OBJECT(pos_offset_table) , "offx" , pos_offset_x_spinbt );
184 pos_offset_y_label = gtk_label_new( _( "Relative Y offset:" ) );
185 gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_y_label ,
186 0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL , 0 , 0 );
187 pos_offset_y_spinbt = gtk_spin_button_new_with_range( -9999 , 9999 , 1 );
188 gtk_spin_button_set_value( GTK_SPIN_BUTTON(pos_offset_y_spinbt) , cfg->osd->position.offset_y );
189 gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_y_spinbt ,
190 1 , 2 , 1 , 2 , GTK_FILL , GTK_FILL , 0 , 0 );
191 g_object_set_data( G_OBJECT(pos_offset_table) , "offy" , pos_offset_y_spinbt );
192 gtk_box_pack_start( GTK_BOX(pos_placement_hbox) , pos_offset_table , FALSE , FALSE , 0 );
193 aosd_callback_list_add( cb_list , pos_offset_table , aosd_cb_configure_position_offset_commit );
194
195 return pos_vbox;
196 }
197
198
199 static GtkWidget *
200 aosd_ui_configure_animation_timing ( gchar * label_string )
201 {
202 GtkWidget *hbox, *desc_label, *spinbt;
203 hbox = gtk_hbox_new( FALSE , 4 );
204 desc_label = gtk_label_new( label_string );
205 spinbt = gtk_spin_button_new_with_range( 0 , 99999 , 1 );
206 gtk_box_pack_start( GTK_BOX(hbox) , desc_label , FALSE , FALSE , 0 );
207 gtk_box_pack_start( GTK_BOX(hbox) , spinbt , FALSE , FALSE , 0 );
208 g_object_set_data( G_OBJECT(hbox) , "spinbt" , spinbt );
209 return hbox;
210 }
211
212
213 static void
214 aosd_cb_configure_animation_timing_commit ( GtkWidget * timing_hbox , aosd_cfg_t * cfg )
215 {
216 cfg->osd->animation.timing_display = gtk_spin_button_get_value_as_int(
217 GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(timing_hbox),"display")) );
218 cfg->osd->animation.timing_fadein = gtk_spin_button_get_value_as_int(
219 GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(timing_hbox),"fadein")) );
220 cfg->osd->animation.timing_fadeout = gtk_spin_button_get_value_as_int(
221 GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(timing_hbox),"fadeout")) );
222 return;
223 }
224
225
226 static GtkWidget *
227 aosd_ui_configure_animation ( aosd_cfg_t * cfg , GList ** cb_list )
228 {
229 GtkWidget *ani_vbox;
230 GtkWidget *ani_timing_frame, *ani_timing_hbox;
231 GtkWidget *ani_timing_fadein_widget, *ani_timing_fadeout_widget, *ani_timing_stay_widget;
232 GtkSizeGroup *sizegroup;
233
234 ani_vbox = gtk_vbox_new( FALSE , 0 );
235 gtk_container_set_border_width( GTK_CONTAINER(ani_vbox) , 6 );
236
237 ani_timing_hbox = gtk_hbox_new( FALSE , 0 );
238 ani_timing_frame = gtk_frame_new( _("Timing (ms)") );
239 gtk_container_set_border_width( GTK_CONTAINER(ani_timing_hbox) , 6 );
240 gtk_container_add( GTK_CONTAINER(ani_timing_frame) , ani_timing_hbox );
241 gtk_box_pack_start( GTK_BOX(ani_vbox) , ani_timing_frame , FALSE , FALSE , 0 );
242
243 ani_timing_stay_widget = aosd_ui_configure_animation_timing( _("Display:") );
244 gtk_spin_button_set_value( GTK_SPIN_BUTTON(g_object_get_data(
245 G_OBJECT(ani_timing_stay_widget),"spinbt")) , cfg->osd->animation.timing_display );
246 gtk_box_pack_start( GTK_BOX(ani_timing_hbox) , ani_timing_stay_widget , TRUE , TRUE , 0 );
247 gtk_box_pack_start( GTK_BOX(ani_timing_hbox) , gtk_vseparator_new() , FALSE , FALSE , 4 );
248 ani_timing_fadein_widget = aosd_ui_configure_animation_timing( _("Fade in:") );
249 gtk_spin_button_set_value( GTK_SPIN_BUTTON(g_object_get_data(
250 G_OBJECT(ani_timing_fadein_widget),"spinbt")) , cfg->osd->animation.timing_fadein );
251 gtk_box_pack_start( GTK_BOX(ani_timing_hbox) , ani_timing_fadein_widget , TRUE , TRUE , 0 );
252 gtk_box_pack_start( GTK_BOX(ani_timing_hbox) , gtk_vseparator_new() , FALSE , FALSE , 4 );
253 ani_timing_fadeout_widget = aosd_ui_configure_animation_timing( _("Fade out:") );
254 gtk_spin_button_set_value( GTK_SPIN_BUTTON(g_object_get_data(
255 G_OBJECT(ani_timing_fadeout_widget),"spinbt")) , cfg->osd->animation.timing_fadeout );
256 gtk_box_pack_start( GTK_BOX(ani_timing_hbox) , ani_timing_fadeout_widget , TRUE , TRUE , 0 );
257 g_object_set_data( G_OBJECT(ani_timing_hbox) , "display" ,
258 g_object_get_data(G_OBJECT(ani_timing_stay_widget),"spinbt") );
259 g_object_set_data( G_OBJECT(ani_timing_hbox) , "fadein" ,
260 g_object_get_data(G_OBJECT(ani_timing_fadein_widget),"spinbt") );
261 g_object_set_data( G_OBJECT(ani_timing_hbox) , "fadeout" ,
262 g_object_get_data(G_OBJECT(ani_timing_fadeout_widget),"spinbt") );
263 sizegroup = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );
264 gtk_size_group_add_widget( sizegroup , ani_timing_stay_widget );
265 gtk_size_group_add_widget( sizegroup , ani_timing_fadein_widget );
266 gtk_size_group_add_widget( sizegroup , ani_timing_fadeout_widget );
267 aosd_callback_list_add( cb_list , ani_timing_hbox , aosd_cb_configure_animation_timing_commit );
268
269 return ani_vbox;
270 }
271
272
273 static void
274 aosd_cb_configure_text_font_shadow_toggle ( GtkToggleButton * shadow_togglebt ,
275 gpointer shadow_colorbt )
276 {
277 if ( gtk_toggle_button_get_active( shadow_togglebt ) == TRUE )
278 gtk_widget_set_sensitive( GTK_WIDGET(shadow_colorbt) , TRUE );
279 else
280 gtk_widget_set_sensitive( GTK_WIDGET(shadow_colorbt) , FALSE );
281 return;
282 }
283
284
285 static void
286 aosd_cb_configure_text_font_commit ( GtkWidget * fontbt , aosd_cfg_t * cfg )
287 {
288 gint fontnum = GPOINTER_TO_INT(g_object_get_data( G_OBJECT(fontbt) , "fontnum" ));
289 GdkColor color, shadow_color;
290 cfg->osd->text.fonts_name[fontnum] = g_strdup( gtk_font_button_get_font_name(GTK_FONT_BUTTON(fontbt)) );
291 gtk_color_button_get_color(
292 GTK_COLOR_BUTTON(g_object_get_data(G_OBJECT(fontbt),"color")) , &color );
293 cfg->osd->text.fonts_color[fontnum].red = color.red;
294 cfg->osd->text.fonts_color[fontnum].green = color.green;
295 cfg->osd->text.fonts_color[fontnum].blue = color.blue;
296 cfg->osd->text.fonts_color[fontnum].alpha = gtk_color_button_get_alpha(
297 GTK_COLOR_BUTTON(g_object_get_data(G_OBJECT(fontbt),"color")) );
298 cfg->osd->text.fonts_draw_shadow[fontnum] = gtk_toggle_button_get_active(
299 GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(fontbt),"use_shadow")) );
300 gtk_color_button_get_color(
301 GTK_COLOR_BUTTON(g_object_get_data(G_OBJECT(fontbt),"shadow_color")) , &shadow_color );
302 cfg->osd->text.fonts_shadow_color[fontnum].red = shadow_color.red;
303 cfg->osd->text.fonts_shadow_color[fontnum].green = shadow_color.green;
304 cfg->osd->text.fonts_shadow_color[fontnum].blue = shadow_color.blue;
305 cfg->osd->text.fonts_shadow_color[fontnum].alpha = gtk_color_button_get_alpha(
306 GTK_COLOR_BUTTON(g_object_get_data(G_OBJECT(fontbt),"shadow_color")) );
307 return;
308 }
309
310
311 static GtkWidget *
312 aosd_ui_configure_text ( aosd_cfg_t * cfg , GList ** cb_list )
313 {
314 GtkWidget *tex_vbox;
315 GtkWidget *tex_font_table, *tex_font_frame;
316 GtkWidget *tex_font_label[3], *tex_font_fontbt[3];
317 GtkWidget *tex_font_colorbt[3], *tex_font_shadow_togglebt[3];
318 GtkWidget *tex_font_shadow_colorbt[3];
319 GtkWidget *other_vbox;
320 gint i = 0;
321
322 tex_vbox = gtk_vbox_new( FALSE , 4 );
323 gtk_container_set_border_width( GTK_CONTAINER(tex_vbox) , 6 );
324
325 tex_font_frame = gtk_frame_new( _("Fonts") );
326 tex_font_table = gtk_table_new( 3 , 5 , FALSE );
327 gtk_container_set_border_width( GTK_CONTAINER(tex_font_table) , 6 );
328 gtk_table_set_row_spacings( GTK_TABLE(tex_font_table) , 4 );
329 gtk_table_set_col_spacings( GTK_TABLE(tex_font_table) , 4 );
330 for ( i = 0 ; i < AOSD_TEXT_FONTS_NUM ; i++ )
331 {
332 GdkColor gcolor = { 0 , 0 , 0 , 0 };
333 gchar *label_str = g_strdup_printf( "Font %i:" , i+1 );
334 tex_font_label[i] = gtk_label_new( label_str );
335 g_free( label_str );
336 tex_font_fontbt[i] = gtk_font_button_new();
337 gtk_font_button_set_show_style( GTK_FONT_BUTTON(tex_font_fontbt[i]) , TRUE );
338 gtk_font_button_set_show_size( GTK_FONT_BUTTON(tex_font_fontbt[i]) , TRUE );
339 gtk_font_button_set_use_font( GTK_FONT_BUTTON(tex_font_fontbt[i]) , FALSE );
340 gtk_font_button_set_use_size( GTK_FONT_BUTTON(tex_font_fontbt[i]) , FALSE );
341 gtk_font_button_set_font_name( GTK_FONT_BUTTON(tex_font_fontbt[i]) , cfg->osd->text.fonts_name[i] );
342 tex_font_colorbt[i] = gtk_color_button_new();
343 gcolor.red = cfg->osd->text.fonts_color[i].red;
344 gcolor.green = cfg->osd->text.fonts_color[i].green;
345 gcolor.blue = cfg->osd->text.fonts_color[i].blue;
346 gtk_color_button_set_use_alpha( GTK_COLOR_BUTTON(tex_font_colorbt[i]) , TRUE );
347 gtk_color_button_set_color( GTK_COLOR_BUTTON(tex_font_colorbt[i]) , &gcolor );
348 gtk_color_button_set_alpha( GTK_COLOR_BUTTON(tex_font_colorbt[i]) ,
349 cfg->osd->text.fonts_color[i].alpha );
350 tex_font_shadow_togglebt[i] = gtk_toggle_button_new_with_label( _("Shadow") );
351 gtk_toggle_button_set_mode( GTK_TOGGLE_BUTTON(tex_font_shadow_togglebt[i]) , FALSE );
352 tex_font_shadow_colorbt[i] = gtk_color_button_new();
353 gtk_color_button_set_use_alpha( GTK_COLOR_BUTTON(tex_font_shadow_colorbt[i]) , TRUE );
354 gcolor.red = cfg->osd->text.fonts_shadow_color[i].red;
355 gcolor.green = cfg->osd->text.fonts_shadow_color[i].green;
356 gcolor.blue = cfg->osd->text.fonts_shadow_color[i].blue;
357 gtk_color_button_set_color( GTK_COLOR_BUTTON(tex_font_shadow_colorbt[i]) , &gcolor );
358 gtk_color_button_set_alpha( GTK_COLOR_BUTTON(tex_font_shadow_colorbt[i]) ,
359 cfg->osd->text.fonts_shadow_color[i].alpha );
360 gtk_widget_set_sensitive( tex_font_shadow_colorbt[i] , FALSE );
361 g_signal_connect( G_OBJECT(tex_font_shadow_togglebt[i]) , "toggled" ,
362 G_CALLBACK(aosd_cb_configure_text_font_shadow_toggle) ,
363 tex_font_shadow_colorbt[i] );
364 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(tex_font_shadow_togglebt[i]) ,
365 cfg->osd->text.fonts_draw_shadow[i] );
366 gtk_table_attach( GTK_TABLE(tex_font_table) , tex_font_label[i] ,
367 0 , 1 , i , i + 1 , GTK_FILL , GTK_FILL , 0 , 0 );
368 gtk_table_attach( GTK_TABLE(tex_font_table) , tex_font_fontbt[i] ,
369 1 , 2 , i , i + 1 , GTK_FILL | GTK_EXPAND , GTK_FILL , 0 , 0 );
370 gtk_table_attach( GTK_TABLE(tex_font_table) , tex_font_colorbt[i] ,
371 2 , 3 , i , i + 1 , GTK_FILL , GTK_FILL , 0 , 0 );
372 gtk_table_attach( GTK_TABLE(tex_font_table) , tex_font_shadow_togglebt[i] ,
373 3 , 4 , i , i + 1 , GTK_FILL , GTK_FILL , 0 , 0 );
374 gtk_table_attach( GTK_TABLE(tex_font_table) , tex_font_shadow_colorbt[i] ,
375 4 , 5 , i , i + 1 , GTK_FILL , GTK_FILL , 0 , 0 );
376 g_object_set_data( G_OBJECT(tex_font_fontbt[i]) , "fontnum" , GINT_TO_POINTER(i) );
377 g_object_set_data( G_OBJECT(tex_font_fontbt[i]) , "color" , tex_font_colorbt[i] );
378 g_object_set_data( G_OBJECT(tex_font_fontbt[i]) , "use_shadow" , tex_font_shadow_togglebt[i] );
379 g_object_set_data( G_OBJECT(tex_font_fontbt[i]) , "shadow_color" , tex_font_shadow_colorbt[i] );
380 aosd_callback_list_add( cb_list , tex_font_fontbt[i] , aosd_cb_configure_text_font_commit );
381 }
382 gtk_container_add( GTK_CONTAINER(tex_font_frame) , tex_font_table );
383 gtk_box_pack_start( GTK_BOX(tex_vbox) , tex_font_frame , FALSE , FALSE , 0 );
384
385 return tex_vbox;
386 }
387
388
389 static void
390 aosd_ui_configure_decoration_browse ( GtkButton * button , gpointer entry )
391 {
392 GtkWidget *dialog;
393 GtkWidget *parent_win = gtk_widget_get_toplevel( GTK_WIDGET(button) );
394 dialog = gtk_file_chooser_dialog_new ( _("Select Skin File") ,
395 ( GTK_WIDGET_TOPLEVEL(parent_win) ? GTK_WINDOW(parent_win) : NULL ) ,
396 GTK_FILE_CHOOSER_ACTION_OPEN ,
397 GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
398 GTK_STOCK_OPEN , GTK_RESPONSE_ACCEPT , NULL );
399 if ( gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT )
400 {
401 gchar *filename;
402 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
403 gtk_entry_set_text( GTK_ENTRY(entry) , filename );
404 g_free( filename );
405 }
406 gtk_widget_destroy( dialog );
407 return;
408 }
409
410
411 static void
412 aosd_cb_configure_decoration_style_commit ( GtkWidget * lv , aosd_cfg_t * cfg )
413 {
414 GtkTreeSelection *sel = gtk_tree_view_get_selection( GTK_TREE_VIEW(lv) );
415 GtkTreeModel *model;
416 GtkTreeIter iter;
417
418 if ( gtk_tree_selection_get_selected( sel , &model , &iter ) == TRUE )
419 {
420 gint deco_code = 0;
421 gtk_tree_model_get( model , &iter , 1 , &deco_code , -1 );
422 cfg->osd->decoration.code = deco_code;
423 }
424 return;
425 }
426
427
428 static void
429 aosd_cb_configure_decoration_color_commit ( GtkWidget * colorbt , aosd_cfg_t * cfg )
430 {
431 GdkColor gcolor;
432 aosd_color_t color;
433 gint colnum = GPOINTER_TO_INT( g_object_get_data( G_OBJECT(colorbt) , "colnum" ) );
434 gtk_color_button_get_color( GTK_COLOR_BUTTON(colorbt) , &gcolor );
435 color.red = gcolor.red;
436 color.green = gcolor.green;
437 color.blue = gcolor.blue;
438 color.alpha = gtk_color_button_get_alpha( GTK_COLOR_BUTTON(colorbt) );
439 g_array_insert_val( cfg->osd->decoration.colors , colnum , color );
440 return;
441 }
442
443
444 static void
445 aosd_cb_configure_decoration_skinfile_commit ( GtkWidget * entry , aosd_cfg_t * cfg )
446 {
447 cfg->osd->decoration.skin_file = g_strdup( gtk_entry_get_text(GTK_ENTRY(entry)) );
448 return;
449 }
450
451
452 static GtkWidget *
453 aosd_ui_configure_decoration ( aosd_cfg_t * cfg , GList ** cb_list )
454 {
455 GtkWidget *dec_hbox;
456 GtkWidget *dec_rstyle_lv, *dec_rstyle_lv_frame, *dec_rstyle_lv_sw;
457 GtkListStore *dec_rstyle_store;
458 GtkCellRenderer *dec_rstyle_lv_rndr_text;
459 GtkTreeViewColumn *dec_rstyle_lv_col_desc;
460 GtkTreeSelection *dec_rstyle_lv_sel;
461 GtkTreeIter iter, iter_sel;
462 GtkWidget *dec_rstyle_hbox;
463 GtkWidget *dec_rstyleopts_frame, *dec_rstyleopts_table;
464 GtkWidget *dec_rstylecustom_frame, *dec_rstylecustom_table;
465 GtkWidget *dec_rstylecustom_label, *dec_rstylecustom_entry, *dec_rstylecustom_browse_bt;
466 gint *deco_code_array, deco_code_array_size;
467 gint colors_max_num = 0, i = 0;
468
469 dec_hbox = gtk_hbox_new( FALSE , 4 );
470 gtk_container_set_border_width( GTK_CONTAINER(dec_hbox) , 6 );
471
472 /* decoration style model
473 ---------------------------------------------
474 G_TYPE_STRING -> decoration description
475 G_TYPE_INT -> decoration code
476 G_TYPE_INT -> number of user-definable colors
477 ---------------------------------------------
478 */
479 dec_rstyle_store = gtk_list_store_new( 3 , G_TYPE_STRING , G_TYPE_INT , G_TYPE_INT );
480 aosd_deco_style_get_codes_array ( &deco_code_array , &deco_code_array_size );
481 for ( i = 0 ; i < deco_code_array_size ; i++ )
482 {
483 gint colors_num = aosd_deco_style_get_numcol( deco_code_array[i] );
484 if ( colors_num > colors_max_num )
485 colors_max_num = colors_num;
486 gtk_list_store_append( dec_rstyle_store , &iter );
487 gtk_list_store_set( dec_rstyle_store , &iter ,
488 0 , aosd_deco_style_get_desc( deco_code_array[i] ) ,
489 1 , deco_code_array[i] , 2 , colors_num , -1 );
490 if ( deco_code_array[i] == cfg->osd->decoration.code )
491 iter_sel = iter;
492 }
493
494 dec_rstyle_lv_frame = gtk_frame_new( NULL );
495 dec_rstyle_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(dec_rstyle_store) );
496 g_object_unref( dec_rstyle_store );
497 dec_rstyle_lv_sel = gtk_tree_view_get_selection( GTK_TREE_VIEW(dec_rstyle_lv) );
498 gtk_tree_selection_set_mode( dec_rstyle_lv_sel , GTK_SELECTION_BROWSE );
499
500 dec_rstyle_lv_rndr_text = gtk_cell_renderer_text_new();
501 dec_rstyle_lv_col_desc = gtk_tree_view_column_new_with_attributes(
502 _("Render Style") , dec_rstyle_lv_rndr_text , "text" , 0 , NULL );
503 gtk_tree_view_append_column( GTK_TREE_VIEW(dec_rstyle_lv), dec_rstyle_lv_col_desc );
504 dec_rstyle_lv_sw = gtk_scrolled_window_new( NULL , NULL );
505 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(dec_rstyle_lv_sw) ,
506 GTK_POLICY_NEVER , GTK_POLICY_ALWAYS );
507 gtk_container_add( GTK_CONTAINER(dec_rstyle_lv_sw) , dec_rstyle_lv );
508 gtk_container_add( GTK_CONTAINER(dec_rstyle_lv_frame) , dec_rstyle_lv_sw );
509
510 gtk_tree_selection_select_iter( dec_rstyle_lv_sel , &iter_sel );
511 gtk_box_pack_start( GTK_BOX(dec_hbox) , dec_rstyle_lv_frame , FALSE , FALSE , 0 );
512 aosd_callback_list_add( cb_list , dec_rstyle_lv , aosd_cb_configure_decoration_style_commit );
513
514 dec_rstyle_hbox = gtk_vbox_new( FALSE , 4 );
515 gtk_box_pack_start( GTK_BOX(dec_hbox) , dec_rstyle_hbox , TRUE , TRUE , 0 );
516
517 /* in colors_max_num now there's the maximum number of colors used by decoration styles */
518 dec_rstyleopts_frame = gtk_frame_new( _("Colors") );
519 dec_rstyleopts_table = gtk_table_new( (colors_max_num / 3) + 1 , 3 , TRUE );
520 gtk_container_set_border_width( GTK_CONTAINER(dec_rstyleopts_table) , 6 );
521 gtk_table_set_row_spacings( GTK_TABLE(dec_rstyleopts_table) , 4 );
522 gtk_table_set_col_spacings( GTK_TABLE(dec_rstyleopts_table) , 8 );
523 gtk_container_add( GTK_CONTAINER(dec_rstyleopts_frame) , dec_rstyleopts_table );
524 for ( i = 0 ; i < colors_max_num ; i++ )
525 {
526 GtkWidget *colorbt, *hbox, *label;
527 aosd_color_t color = g_array_index( cfg->osd->decoration.colors , aosd_color_t , i );
528 GdkColor gcolor = { 0 , 0 , 0 , 0 };
529 gchar *label_str = NULL;
530 hbox = gtk_hbox_new( FALSE , 4 );
531 label_str = g_strdup_printf( "Color %i:" , i+1 );
532 label = gtk_label_new( label_str );
533 g_free( label_str );
534 colorbt = gtk_color_button_new();
535 gtk_color_button_set_use_alpha( GTK_COLOR_BUTTON(colorbt) , TRUE );
536 gcolor.red = color.red; gcolor.green = color.green; gcolor.blue = color.blue;
537 gtk_color_button_set_color( GTK_COLOR_BUTTON(colorbt) , &gcolor );
538 gtk_color_button_set_alpha( GTK_COLOR_BUTTON(colorbt) , color.alpha );
539 gtk_box_pack_start( GTK_BOX(hbox) , label , FALSE , FALSE , 0 );
540 gtk_box_pack_start( GTK_BOX(hbox) , colorbt , FALSE , FALSE , 0 );
541 gtk_table_attach( GTK_TABLE(dec_rstyleopts_table) , hbox ,
542 (i % 3) , (i % 3) + 1 , (i / 3) , (i / 3) + 1 ,
543 GTK_FILL , GTK_FILL , 0 , 0 );
544 g_object_set_data( G_OBJECT(colorbt) , "colnum" , GINT_TO_POINTER(i) );
545 aosd_callback_list_add( cb_list , colorbt , aosd_cb_configure_decoration_color_commit );
546 }
547 gtk_box_pack_start( GTK_BOX(dec_rstyle_hbox) , dec_rstyleopts_frame , FALSE , FALSE , 0 );
548
549 #if 0
550 /* custom skin entry TODO still working on this */
551 dec_rstylecustom_frame = gtk_frame_new( _("Custom Skin") );
552 dec_rstylecustom_table = gtk_table_new( 1 , 3 , FALSE );
553 gtk_container_set_border_width( GTK_CONTAINER(dec_rstylecustom_table) , 6 );
554 gtk_table_set_row_spacings( GTK_TABLE(dec_rstylecustom_table) , 4 );
555 gtk_table_set_col_spacings( GTK_TABLE(dec_rstylecustom_table) , 4 );
556 gtk_container_add( GTK_CONTAINER(dec_rstylecustom_frame) , dec_rstylecustom_table );
557 dec_rstylecustom_label = gtk_label_new( _("Skin file:") );
558 dec_rstylecustom_entry = gtk_entry_new();
559 gtk_entry_set_text( GTK_ENTRY(dec_rstylecustom_entry) , cfg->osd->decoration.skin_file );
560 dec_rstylecustom_browse_bt = gtk_button_new_with_label( _("Browse") );
561 g_signal_connect( G_OBJECT(dec_rstylecustom_browse_bt) , "clicked" ,
562 G_CALLBACK(aosd_ui_configure_decoration_browse) , dec_rstylecustom_entry );
563 gtk_table_attach( GTK_TABLE(dec_rstylecustom_table) , dec_rstylecustom_label ,
564 0 , 1 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
565 gtk_table_attach( GTK_TABLE(dec_rstylecustom_table) , dec_rstylecustom_entry ,
566 1 , 2 , 0 , 1 , GTK_FILL | GTK_EXPAND , GTK_FILL , 0 , 0 );
567 gtk_table_attach( GTK_TABLE(dec_rstylecustom_table) , dec_rstylecustom_browse_bt ,
568 2 , 3 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
569 aosd_callback_list_add( cb_list , dec_rstylecustom_entry , aosd_cb_configure_decoration_skinfile_commit );
570
571 gtk_box_pack_start( GTK_BOX(dec_rstyle_hbox) , dec_rstylecustom_frame , FALSE , FALSE , 0 );
572 #endif
573
574 return dec_hbox;
575 }
576
577
578 static GtkWidget *
579 aosd_ui_configure_trigger ( aosd_cfg_t * cfg , GList ** cb_list )
580 {
581 GtkWidget *tri_hbox;
582 GtkWidget *tri_event_lv, *tri_event_lv_frame, *tri_event_lv_sw;
583 GtkListStore *tri_event_store;
584 GtkCellRenderer *tri_event_lv_rndr_text;
585 GtkTreeViewColumn *tri_event_lv_col_desc;
586 GtkTreeSelection *tri_event_lv_sel;
587 GtkTreeIter iter;
588 GtkWidget *tri_event_label;
589
590 tri_hbox = gtk_hbox_new( FALSE , 4 );
591 gtk_container_set_border_width( GTK_CONTAINER(tri_hbox) , 6 );
592
593 /* TODO this part will probably be changed in future! */
594
595 /* event model
596 ---------------------------------------------
597 G_TYPE_STRING -> decoration description
598 ---------------------------------------------
599 */
600 tri_event_store = gtk_list_store_new( 1 , G_TYPE_STRING );
601 gtk_list_store_append( tri_event_store , &iter );
602 gtk_list_store_set( tri_event_store , &iter , 0 , _("Song Change") , -1 );
603
604 tri_event_lv_frame = gtk_frame_new( NULL );
605 tri_event_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(tri_event_store) );
606 g_object_unref( tri_event_store );
607 tri_event_lv_sel = gtk_tree_view_get_selection( GTK_TREE_VIEW(tri_event_lv) );
608 gtk_tree_selection_set_mode( tri_event_lv_sel , GTK_SELECTION_BROWSE );
609
610 tri_event_lv_rndr_text = gtk_cell_renderer_text_new();
611 tri_event_lv_col_desc = gtk_tree_view_column_new_with_attributes(
612 _("Event") , tri_event_lv_rndr_text , "text" , 0 , NULL );
613 gtk_tree_view_append_column( GTK_TREE_VIEW(tri_event_lv), tri_event_lv_col_desc );
614 tri_event_lv_sw = gtk_scrolled_window_new( NULL , NULL );
615 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(tri_event_lv_sw) ,
616 GTK_POLICY_NEVER , GTK_POLICY_ALWAYS );
617 gtk_container_add( GTK_CONTAINER(tri_event_lv_sw) , tri_event_lv );
618 gtk_container_add( GTK_CONTAINER(tri_event_lv_frame) , tri_event_lv_sw );
619 gtk_tree_selection_select_iter( tri_event_lv_sel , &iter );
620
621 gtk_box_pack_start( GTK_BOX(tri_hbox) , tri_event_lv_frame , FALSE , FALSE , 0 );
622
623 tri_event_label = gtk_label_new( _("Song Change is currently the only event that triggers "
624 "the OSD. Other events will be added in next Audacious OSD versions.") );
625 gtk_label_set_line_wrap( GTK_LABEL(tri_event_label) , TRUE );
626 gtk_misc_set_alignment( GTK_MISC(tri_event_label) , 0.5 , 0.0 );
627 gtk_box_pack_start( GTK_BOX(tri_hbox) , tri_event_label , FALSE , FALSE , 0 );
628
629 return tri_hbox;
630 }
631
632
633 static void
634 aosd_cb_configure_test ( gpointer cfg_win )
635 {
636 gchar *markup_message = NULL;
637 aosd_cfg_t *cfg = aosd_cfg_new();
638 GList *cb_list = g_object_get_data( G_OBJECT(cfg_win) , "cblist" );
639 aosd_callback_list_run( cb_list , cfg );
640 cfg->set = TRUE;
641 #ifdef DEBUG
642 aosd_cfg_debug( cfg );
643 #endif
644 markup_message = g_markup_printf_escaped(
645 "<span font_desc='%s'>Audacious OSD</span>" , cfg->osd->text.fonts_name[0] );
646 aosd_display( markup_message , cfg->osd , TRUE );
647 g_free( markup_message );
648 aosd_cfg_delete( cfg );
649 return;
650 }
651
652
653 static void
654 aosd_cb_configure_cancel ( gpointer cfg_win )
655 {
656 GList *cb_list = g_object_get_data( G_OBJECT(cfg_win) , "cblist" );
657 aosd_callback_list_free( cb_list );
658 aosd_shutdown(); /* stop any displayed osd */
659 gtk_widget_destroy( GTK_WIDGET(cfg_win) );
660 return;
661 }
662
663
664 static void
665 aosd_cb_configure_ok ( gpointer cfg_win )
666 {
667 gchar *markup_message = NULL;
668 aosd_cfg_t *cfg = aosd_cfg_new();
669 GList *cb_list = g_object_get_data( G_OBJECT(cfg_win) , "cblist" );
670 aosd_callback_list_run( cb_list , cfg );
671 cfg->set = TRUE;
672 aosd_shutdown(); /* stop any displayed osd */
673 if ( global_config != NULL )
674 {
675 /* plugin is active */
676 aosd_cfg_delete( global_config ); /* delete old global_config */
677 global_config = cfg; /* put the new one */
678 aosd_cfg_save( cfg ); /* save the new configuration on config file */
679 }
680 else
681 {
682 /* plugin is not active */
683 aosd_cfg_save( cfg ); /* save the new configuration on config file */
684 }
685 aosd_callback_list_free( cb_list );
686 gtk_widget_destroy( GTK_WIDGET(cfg_win) );
687 return;
688 }
689
690
691 void
692 aosd_ui_configure ( aosd_cfg_t * cfg )
693 {
694 static GtkWidget *cfg_win = NULL;
695 GtkWidget *cfg_vbox;
696 GtkWidget *cfg_nb;
697 GtkWidget *cfg_bbar_hbbox;
698 GtkWidget *cfg_bbar_bt_ok, *cfg_bbar_bt_test, *cfg_bbar_bt_cancel;
699 GtkWidget *cfg_position_widget;
700 GtkWidget *cfg_animation_widget;
701 GtkWidget *cfg_text_widget;
702 GtkWidget *cfg_decoration_widget;
703 GtkWidget *cfg_trigger_widget;
704 GdkGeometry cfg_win_hints;
705 GList *cb_list = NULL; /* list of custom callbacks */
706
707 if ( cfg_win != NULL )
708 {
709 gtk_window_present( GTK_WINDOW(cfg_win) );
710 return;
711 }
712
713 cfg_win = gtk_window_new( GTK_WINDOW_TOPLEVEL );
714 gtk_window_set_type_hint( GTK_WINDOW(cfg_win), GDK_WINDOW_TYPE_HINT_DIALOG );
715 gtk_window_set_title( GTK_WINDOW(cfg_win) , _("Audacious OSD - configuration") );
716 gtk_container_set_border_width( GTK_CONTAINER(cfg_win), 10 );
717 g_signal_connect( G_OBJECT(cfg_win) , "destroy" ,
718 G_CALLBACK(gtk_widget_destroyed) , &cfg_win );
719 cfg_win_hints.min_width = -1;
720 cfg_win_hints.min_height = 350;
721 gtk_window_set_geometry_hints( GTK_WINDOW(cfg_win) , GTK_WIDGET(cfg_win) ,
722 &cfg_win_hints , GDK_HINT_MIN_SIZE );
723
724 cfg_vbox = gtk_vbox_new( 0 , FALSE );
725 gtk_container_add( GTK_CONTAINER(cfg_win) , cfg_vbox );
726
727 cfg_nb = gtk_notebook_new();
728 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(cfg_nb) , GTK_POS_TOP );
729 gtk_box_pack_start( GTK_BOX(cfg_vbox) , cfg_nb , TRUE , TRUE , 0 );
730
731 gtk_box_pack_start( GTK_BOX(cfg_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 );
732
733 cfg_bbar_hbbox = gtk_hbutton_box_new();
734 gtk_button_box_set_layout( GTK_BUTTON_BOX(cfg_bbar_hbbox) , GTK_BUTTONBOX_START );
735 gtk_box_pack_start( GTK_BOX(cfg_vbox) , cfg_bbar_hbbox , FALSE , FALSE , 0 );
736 cfg_bbar_bt_test = gtk_button_new_with_label( _("Test") );
737 gtk_button_set_image( GTK_BUTTON(cfg_bbar_bt_test) ,
738 gtk_image_new_from_stock( GTK_STOCK_MEDIA_PLAY , GTK_ICON_SIZE_BUTTON ) );
739 gtk_container_add( GTK_CONTAINER(cfg_bbar_hbbox) , cfg_bbar_bt_test );
740 gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(cfg_bbar_hbbox) , cfg_bbar_bt_test , FALSE );
741 cfg_bbar_bt_cancel = gtk_button_new_from_stock( GTK_STOCK_CANCEL );
742 gtk_container_add( GTK_CONTAINER(cfg_bbar_hbbox) , cfg_bbar_bt_cancel );
743 gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(cfg_bbar_hbbox) , cfg_bbar_bt_cancel , TRUE );
744 cfg_bbar_bt_ok = gtk_button_new_from_stock( GTK_STOCK_OK );
745 gtk_container_add( GTK_CONTAINER(cfg_bbar_hbbox) , cfg_bbar_bt_ok );
746 gtk_button_box_set_child_secondary( GTK_BUTTON_BOX(cfg_bbar_hbbox) , cfg_bbar_bt_ok , TRUE );
747
748 /* add POSITION page */
749 cfg_position_widget = aosd_ui_configure_position( cfg , &cb_list );
750 gtk_notebook_append_page( GTK_NOTEBOOK(cfg_nb) ,
751 cfg_position_widget , gtk_label_new( _("Position") ) );
752
753 /* add ANIMATION page */
754 cfg_animation_widget = aosd_ui_configure_animation( cfg , &cb_list );
755 gtk_notebook_append_page( GTK_NOTEBOOK(cfg_nb) ,
756 cfg_animation_widget , gtk_label_new( _("Animation") ) );
757
758 /* add TEXT page */
759 cfg_text_widget = aosd_ui_configure_text( cfg , &cb_list );
760 gtk_notebook_append_page( GTK_NOTEBOOK(cfg_nb) ,
761 cfg_text_widget , gtk_label_new( _("Text") ) );
762
763 /* add DECORATION page */
764 cfg_decoration_widget = aosd_ui_configure_decoration( cfg , &cb_list );
765 gtk_notebook_append_page( GTK_NOTEBOOK(cfg_nb) ,
766 cfg_decoration_widget , gtk_label_new( _("Decoration") ) );
767
768 /* add TRIGGER page */
769 cfg_trigger_widget = aosd_ui_configure_trigger( cfg , &cb_list );
770 gtk_notebook_append_page( GTK_NOTEBOOK(cfg_nb) ,
771 cfg_trigger_widget , gtk_label_new( _("Trigger") ) );
772
773 g_object_set_data( G_OBJECT(cfg_win) , "cblist" , cb_list );
774
775 g_signal_connect_swapped( G_OBJECT(cfg_bbar_bt_test) , "clicked" ,
776 G_CALLBACK(aosd_cb_configure_test) , cfg_win );
777 g_signal_connect_swapped( G_OBJECT(cfg_bbar_bt_cancel) , "clicked" ,
778 G_CALLBACK(aosd_cb_configure_cancel) , cfg_win );
779 g_signal_connect_swapped( G_OBJECT(cfg_bbar_bt_ok) , "clicked" ,
780 G_CALLBACK(aosd_cb_configure_ok) , cfg_win );
781
782 gtk_widget_show_all( cfg_win );
783 }
784
785
786 /* about box */
787 void
788 aosd_ui_about ( void )
789 {
790 static GtkWidget *about_win = NULL;
791 GtkWidget *about_vbox;
792 GtkWidget *logoandinfo_vbox;
793 GtkWidget *info_tv, *info_tv_sw, *info_tv_frame;
794 GtkWidget *bbar_bbox, *bbar_bt_ok;
795 GtkTextBuffer *info_tb;
796 GdkGeometry abount_win_hints;
797
798 if ( about_win != NULL )
799 {
800 gtk_window_present( GTK_WINDOW(about_win) );
801 return;
802 }
803
804 about_win = gtk_window_new( GTK_WINDOW_TOPLEVEL );
805 gtk_window_set_type_hint( GTK_WINDOW(about_win), GDK_WINDOW_TYPE_HINT_DIALOG );
806 gtk_window_set_position( GTK_WINDOW(about_win), GTK_WIN_POS_CENTER );
807 gtk_window_set_title( GTK_WINDOW(about_win), _("Audacious OSD - about") );
808 abount_win_hints.min_width = 420;
809 abount_win_hints.min_height = 240;
810 gtk_window_set_geometry_hints( GTK_WINDOW(about_win) , GTK_WIDGET(about_win) ,
811 &abount_win_hints , GDK_HINT_MIN_SIZE );
812 /* gtk_window_set_resizable( GTK_WINDOW(about_win) , FALSE ); */
813 gtk_container_set_border_width( GTK_CONTAINER(about_win) , 10 );
814 g_signal_connect( G_OBJECT(about_win) , "destroy" , G_CALLBACK(gtk_widget_destroyed) , &about_win );
815
816 about_vbox = gtk_vbox_new( FALSE , 0 );
817 gtk_container_add( GTK_CONTAINER(about_win) , about_vbox );
818
819 logoandinfo_vbox = gtk_vbox_new( TRUE , 2 );
820
821 /* TODO make a logo or make someone do it! :)
822 logo_pixbuf = gdk_pixbuf_new_from_xpm_data( (const gchar **)evdev_plug_logo_xpm );
823 logo_image = gtk_image_new_from_pixbuf( logo_pixbuf );
824 g_object_unref( logo_pixbuf );
825
826 logo_frame = gtk_frame_new( NULL );
827 gtk_container_add( GTK_CONTAINER(logo_frame) , logo_image );
828 gtk_box_pack_start( GTK_BOX(logoandinfo_vbox) , logo_frame , TRUE , TRUE , 0 ); */
829
830 info_tv = gtk_text_view_new();
831 info_tb = gtk_text_view_get_buffer( GTK_TEXT_VIEW(info_tv) );
832 gtk_text_view_set_editable( GTK_TEXT_VIEW(info_tv) , FALSE );
833 gtk_text_view_set_cursor_visible( GTK_TEXT_VIEW(info_tv) , FALSE );
834 gtk_text_view_set_justification( GTK_TEXT_VIEW(info_tv) , GTK_JUSTIFY_LEFT );
835 gtk_text_view_set_left_margin( GTK_TEXT_VIEW(info_tv) , 10 );
836
837 gtk_text_buffer_set_text( info_tb ,
838 _("\nAudacious OSD " AOSD_VERSION_PLUGIN
839 "\nhttp://www.develia.org/projects.php?p=aosd\n"
840 "written by Giacomo Lozito\n"
841 "< james@develia.org >\n\n"
842 "On-Screen-Display is based on Ghosd library\n"
843 "written by Evan Martin\n"
844 "http://neugierig.org/software/ghosd/\n\n") , -1 );
845
846 info_tv_sw = gtk_scrolled_window_new( NULL , NULL );
847 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(info_tv_sw) ,
848 GTK_POLICY_NEVER , GTK_POLICY_ALWAYS );
849 gtk_container_add( GTK_CONTAINER(info_tv_sw) , info_tv );
850 info_tv_frame = gtk_frame_new( NULL );
851 gtk_container_add( GTK_CONTAINER(info_tv_frame) , info_tv_sw );
852 gtk_box_pack_start( GTK_BOX(logoandinfo_vbox) , info_tv_frame , TRUE , TRUE , 0 );
853
854 gtk_box_pack_start( GTK_BOX(about_vbox) , logoandinfo_vbox , TRUE , TRUE , 0 );
855
856 /* horizontal separator and buttons */
857 gtk_box_pack_start( GTK_BOX(about_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 );
858 bbar_bbox = gtk_hbutton_box_new();
859 gtk_button_box_set_layout( GTK_BUTTON_BOX(bbar_bbox) , GTK_BUTTONBOX_END );
860 bbar_bt_ok = gtk_button_new_from_stock( GTK_STOCK_OK );
861 g_signal_connect_swapped( G_OBJECT(bbar_bt_ok) , "clicked" ,
862 G_CALLBACK(gtk_widget_destroy) , about_win );
863 gtk_container_add( GTK_CONTAINER(bbar_bbox) , bbar_bt_ok );
864 gtk_box_pack_start( GTK_BOX(about_vbox) , bbar_bbox , FALSE , FALSE , 0 );
865
866 gtk_widget_show_all( about_win );
867 }