comparison src/audacious/ui_fileinfopopup.c @ 2355:f03beaca8e81 trunk

[svn] - ui_fileinfopopup.c uses gtk code, no more glade in it
author giacomo
date Wed, 17 Jan 2007 08:13:07 -0800
parents 911743d27aba
children 139d2358f617
comparison
equal deleted inserted replaced
2354:fea1b8594cd8 2355:f03beaca8e81
23 #endif 23 #endif
24 24
25 #include <glib.h> 25 #include <glib.h>
26 #include <glib/gi18n.h> 26 #include <glib/gi18n.h>
27 #include <gtk/gtk.h> 27 #include <gtk/gtk.h>
28 #include <glade/glade.h>
29 #include <string.h> 28 #include <string.h>
30 29
31 #include "glade.h"
32 #include "titlestring.h" 30 #include "titlestring.h"
33 #include "ui_fileinfopopup.h" 31 #include "ui_fileinfopopup.h"
34 #include "main.h" 32 #include "main.h"
35 #include "ui_main.h" 33 #include "ui_main.h"
36 34
37 35
38 static void 36 static void
39 filepopup_entry_set_text(GtkWidget *filepopup_win, const char *entry, const char *text) 37 filepopup_entry_set_text(GtkWidget *filepopup_win, const char *entry_name, const char *text)
40 { 38 {
41 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); 39 GtkWidget *widget = g_object_get_data(G_OBJECT(filepopup_win), entry_name);
42 GtkWidget *widget = glade_xml_get_widget(xml, entry); 40
43 41 if (widget == NULL)
44 if (xml == NULL || widget == NULL) 42 return;
45 return; 43
46 44 gtk_label_set_text( GTK_LABEL(widget) , text );
47 gtk_label_set_text(GTK_LABEL(widget), text);
48 } 45 }
49 46
50 static void 47 static void
51 filepopup_entry_set_image(GtkWidget *filepopup_win, const char *entry, const char *text) 48 filepopup_entry_set_image(GtkWidget *filepopup_win, const char *entry_name, const char *text)
52 { 49 {
53 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); 50 GtkWidget *widget = g_object_get_data(G_OBJECT(filepopup_win), entry_name);
54 GtkWidget *widget = glade_xml_get_widget(xml, entry);
55 GdkPixbuf *pixbuf; 51 GdkPixbuf *pixbuf;
56 int width, height; 52 int width, height;
57 double aspect; 53 double aspect;
58 GdkPixbuf *pixbuf2; 54 GdkPixbuf *pixbuf2;
59 55
60 if (xml == NULL || widget == NULL) 56 if (widget == NULL)
61 return; 57 return;
62 58
63 pixbuf = gdk_pixbuf_new_from_file(text, NULL); 59 pixbuf = gdk_pixbuf_new_from_file(text, NULL);
64 60
65 if (pixbuf == NULL) 61 if (pixbuf == NULL)
88 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); 84 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf));
89 g_object_unref(G_OBJECT(pixbuf)); 85 g_object_unref(G_OBJECT(pixbuf));
90 } 86 }
91 87
92 static void 88 static void
93 filepopup_entry_set_text_free(GtkWidget *filepopup_win, const char *entry, char *text) 89 filepopup_entry_set_text_free(GtkWidget *filepopup_win, const char *entry_name, char *text)
94 { 90 {
95 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); 91 GtkWidget *widget = g_object_get_data(G_OBJECT(filepopup_win), entry_name);
96 GtkWidget *widget = glade_xml_get_widget(xml, entry); 92
97 93 if (widget == NULL)
98 if (xml == NULL || widget == NULL)
99 return; 94 return;
100 95
101 gtk_label_set_text(GTK_LABEL(widget), text); 96 gtk_label_set_text(GTK_LABEL(widget), text);
102 97
103 g_free(text); 98 g_free(text);
266 261
267 262
268 GtkWidget * 263 GtkWidget *
269 audacious_fileinfopopup_create(void) 264 audacious_fileinfopopup_create(void)
270 { 265 {
271 const gchar *glade_file = DATA_DIR "/glade/fileinfo_popup.glade"; 266 GtkWidget *filepopup_win;
272 GladeXML *xml; 267 GtkWidget *filepopup_hbox;
273 GtkWidget *widget; 268 GtkWidget *filepopup_data_image;
274 GtkWidget *filepopup_win; 269 GtkWidget *filepopup_data_table;
275 270 GtkWidget *filepopup_data_info_header[7];
276 xml = glade_xml_new_or_die(_("Track Information Popup"), glade_file, NULL, NULL); 271 GtkWidget *filepopup_data_info_label[7];
277 272 gchar *markup;
278 glade_xml_signal_autoconnect(xml); 273
279 274 filepopup_win = gtk_window_new( GTK_WINDOW_POPUP );
280 filepopup_win = glade_xml_get_widget(xml, "win_pl_popup"); 275 gtk_window_set_decorated( GTK_WINDOW(filepopup_win), FALSE );
281 g_object_set_data(G_OBJECT(filepopup_win), "glade-xml", xml); 276 gtk_container_set_border_width( GTK_CONTAINER(filepopup_win) , 6 );
282 gtk_window_set_transient_for(GTK_WINDOW(filepopup_win), GTK_WINDOW(mainwin)); 277 gtk_window_set_transient_for( GTK_WINDOW(filepopup_win) , GTK_WINDOW(mainwin) );
283 278
284 widget = glade_xml_get_widget(xml, "image_artwork"); 279 filepopup_hbox = gtk_hbox_new( FALSE , 0 );
285 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); 280 gtk_container_add( GTK_CONTAINER(filepopup_win) , filepopup_hbox );
286 g_object_set_data( G_OBJECT(filepopup_win) , "last_artwork" , NULL ); 281
287 282 filepopup_data_image = gtk_image_new();
288 return filepopup_win; 283 gtk_misc_set_alignment( GTK_MISC(filepopup_data_image) , 0.5 , 0 );
284 gtk_image_set_from_file( GTK_IMAGE(filepopup_data_image) , DATA_DIR "/images/audio.png" );
285 g_object_set_data( G_OBJECT(filepopup_win) , "image_artwork" , filepopup_data_image );
286 g_object_set_data( G_OBJECT(filepopup_win) , "last_artwork" , NULL );
287 gtk_box_pack_start( GTK_BOX(filepopup_hbox) , filepopup_data_image , FALSE , FALSE , 0 );
288
289 gtk_box_pack_start( GTK_BOX(filepopup_hbox) , gtk_vseparator_new() , FALSE , FALSE , 6 );
290
291 filepopup_data_table = gtk_table_new( 7 , 2 , FALSE );
292 gtk_table_set_row_spacings( GTK_TABLE(filepopup_data_table) , 6 );
293 gtk_table_set_col_spacings( GTK_TABLE(filepopup_data_table) , 6 );
294 gtk_box_pack_start( GTK_BOX(filepopup_hbox) , filepopup_data_table , TRUE , TRUE , 0 );
295
296 /* title */
297 filepopup_data_info_header[0] = gtk_label_new("");
298 filepopup_data_info_label[0] = gtk_label_new("");
299 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[0]) , 0 , 0.5 );
300 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[0]) , 0 , 0.5 );
301 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Title") );
302 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[0]) , markup );
303 g_free( markup );
304 g_object_set_data( G_OBJECT(filepopup_win) , "label_title" , filepopup_data_info_label[0] );
305 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[0] ,
306 0 , 1 , 0 , 1 , GTK_FILL , 0 , 0 , 0 );
307 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[0] ,
308 1 , 2 , 0 , 1 , GTK_FILL , 0 , 0 , 0 );
309
310 /* artist */
311 filepopup_data_info_header[1] = gtk_label_new("");
312 filepopup_data_info_label[1] = gtk_label_new("");
313 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[1]) , 0 , 0.5 );
314 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[1]) , 0 , 0.5 );
315 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Artist") );
316 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[1]) , markup );
317 g_free( markup );
318 g_object_set_data( G_OBJECT(filepopup_win) , "label_artist" , filepopup_data_info_label[1] );
319 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[1] ,
320 0 , 1 , 1 , 2 , GTK_FILL , 0 , 0 , 0 );
321 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[1] ,
322 1 , 2 , 1 , 2 , GTK_FILL , 0 , 0 , 0 );
323
324 /* album */
325 filepopup_data_info_header[2] = gtk_label_new("");
326 filepopup_data_info_label[2] = gtk_label_new("");
327 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[2]) , 0 , 0.5 );
328 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[2]) , 0 , 0.5 );
329 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Album") );
330 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[2]) , markup );
331 g_free( markup );
332 g_object_set_data( G_OBJECT(filepopup_win) , "label_album" , filepopup_data_info_label[2] );
333 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[2] ,
334 0 , 1 , 2 , 3 , GTK_FILL , 0 , 0 , 0 );
335 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[2] ,
336 1 , 2 , 2 , 3 , GTK_FILL , 0 , 0 , 0 );
337
338 /* genre */
339 filepopup_data_info_header[3] = gtk_label_new("");
340 filepopup_data_info_label[3] = gtk_label_new("");
341 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[3]) , 0 , 0.5 );
342 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[3]) , 0 , 0.5 );
343 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Genre") );
344 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[3]) , markup );
345 g_free( markup );
346 g_object_set_data( G_OBJECT(filepopup_win) , "label_genre" , filepopup_data_info_label[3] );
347 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[3] ,
348 0 , 1 , 3 , 4 , GTK_FILL , 0 , 0 , 0 );
349 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[3] ,
350 1 , 2 , 3 , 4 , GTK_FILL , 0 , 0 , 0 );
351
352 /* year */
353 filepopup_data_info_header[4] = gtk_label_new("");
354 filepopup_data_info_label[4] = gtk_label_new("");
355 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[4]) , 0 , 0.5 );
356 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[4]) , 0 , 0.5 );
357 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Year") );
358 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[4]) , markup );
359 g_free( markup );
360 g_object_set_data( G_OBJECT(filepopup_win) , "label_year" , filepopup_data_info_label[4] );
361 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[4] ,
362 0 , 1 , 4 , 5 , GTK_FILL , 0 , 0 , 0 );
363 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[4] ,
364 1 , 2 , 4 , 5 , GTK_FILL , 0 , 0 , 0 );
365
366 /* Track Number */
367 filepopup_data_info_header[5] = gtk_label_new("");
368 filepopup_data_info_label[5] = gtk_label_new("");
369 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[5]) , 0 , 0.5 );
370 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[5]) , 0 , 0.5 );
371 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Track Number") );
372 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[5]) , markup );
373 g_free( markup );
374 g_object_set_data( G_OBJECT(filepopup_win) , "label_tracknum" , filepopup_data_info_label[5] );
375 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[5] ,
376 0 , 1 , 5 , 6 , GTK_FILL , 0 , 0 , 0 );
377 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[5] ,
378 1 , 2 , 5 , 6 , GTK_FILL , 0 , 0 , 0 );
379
380 /* Track Length */
381 filepopup_data_info_header[6] = gtk_label_new("");
382 filepopup_data_info_label[6] = gtk_label_new("");
383 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_header[6]) , 0 , 0.5 );
384 gtk_misc_set_alignment( GTK_MISC(filepopup_data_info_label[6]) , 0 , 0.5 );
385 markup = g_markup_printf_escaped( "<span style=\"italic\">%s</span>" , _("Track Length") );
386 gtk_label_set_markup( GTK_LABEL(filepopup_data_info_header[6]) , markup );
387 g_free( markup );
388 g_object_set_data( G_OBJECT(filepopup_win) , "label_tracklen" , filepopup_data_info_label[6] );
389 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_header[6] ,
390 0 , 1 , 6 , 7 , GTK_FILL , 0 , 0 , 0 );
391 gtk_table_attach( GTK_TABLE(filepopup_data_table) , filepopup_data_info_label[6] ,
392 1 , 2 , 6 , 7 , GTK_FILL , 0 , 0 , 0 );
393
394 /* this will realize all widgets contained in filepopup_hbox */
395 gtk_widget_show_all(filepopup_hbox);
396
397 return filepopup_win;
289 } 398 }
290 399
291 void 400 void
292 audacious_fileinfopopup_destroy(GtkWidget *filepopup_win) 401 audacious_fileinfopopup_destroy(GtkWidget *filepopup_win)
293 { 402 {
294 gchar *last_artwork = g_object_get_data( G_OBJECT(filepopup_win) , "last_artwork" ); 403 gchar *last_artwork = g_object_get_data( G_OBJECT(filepopup_win) , "last_artwork" );
295 if ( last_artwork != NULL ) g_free(last_artwork); 404 if ( last_artwork != NULL ) g_free(last_artwork);
296 g_object_unref( g_object_get_data(G_OBJECT(filepopup_win), "glade-xml") ); 405 gtk_widget_destroy( filepopup_win );
297 gtk_widget_destroy( filepopup_win ); 406 return;
298 return;
299 } 407 }
300 408
301 void 409 void
302 audacious_fileinfopopup_show_from_tuple(GtkWidget *filepopup_win, TitleInput *tuple) 410 audacious_fileinfopopup_show_from_tuple(GtkWidget *filepopup_win, TitleInput *tuple)
303 { 411 {