comparison src/amidi-plug/i_fileinfo.c @ 1275:b839faa693e2

updated amidi-plug to handle URIs in fileinfo and all-over in code
author Giacomo Lozito <james@develia.org>
date Sun, 15 Jul 2007 23:41:06 +0200
parents 3da1b8942b8b
children
comparison
equal deleted inserted replaced
1274:bcf6dc9564f4 1275:b839faa693e2
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 108
109 void i_fileinfo_gui( gchar * filename ) 109 void i_fileinfo_gui( gchar * filename_uri )
110 { 110 {
111 static GtkWidget *fileinfowin = NULL; 111 static GtkWidget *fileinfowin = NULL;
112 GtkWidget *fileinfowin_vbox, *fileinfowin_columns_hbox; 112 GtkWidget *fileinfowin_vbox, *fileinfowin_columns_hbox;
113 GtkWidget *midiinfoboxes_vbox, *miditextboxes_vbox, *miditextboxes_paned; 113 GtkWidget *midiinfoboxes_vbox, *miditextboxes_vbox, *miditextboxes_paned;
114 GtkWidget *title_hbox, *title_icon_image, *title_name_f_label, *title_name_v_entry; 114 GtkWidget *title_hbox, *title_icon_image, *title_name_f_label, *title_name_v_entry;
119 GtkWidget *footer_hbbox, *footer_bclose; 119 GtkWidget *footer_hbbox, *footer_bclose;
120 GdkPixbuf *title_icon_pixbuf; 120 GdkPixbuf *title_icon_pixbuf;
121 PangoAttrList *pangoattrlist; 121 PangoAttrList *pangoattrlist;
122 PangoAttribute *pangoattr; 122 PangoAttribute *pangoattr;
123 GString *value_gstring; 123 GString *value_gstring;
124 gchar *title , *filename_utf8; 124 gchar *title , *filename, *filename_utf8;
125 gint bpm = 0, wavg_bpm = 0; 125 gint bpm = 0, wavg_bpm = 0;
126 midifile_t *mf; 126 midifile_t *mf;
127 127
128 if ( fileinfowin ) 128 if ( fileinfowin )
129 return; 129 return;
130 130
131 mf = g_malloc(sizeof(midifile_t)); 131 mf = g_malloc(sizeof(midifile_t));
132 132
133 /****************** midifile parser ******************/ 133 /****************** midifile parser ******************/
134 if ( !i_midi_parse_from_filename( filename , mf ) ) 134 if ( !i_midi_parse_from_filename( filename_uri , mf ) )
135 return; 135 return;
136 /* midifile is filled with information at this point, 136 /* midifile is filled with information at this point,
137 bpm information is needed too */ 137 bpm information is needed too */
138 i_midi_get_bpm( mf , &bpm , &wavg_bpm ); 138 i_midi_get_bpm( mf , &bpm , &wavg_bpm );
139 /*****************************************************/ 139 /*****************************************************/
331 gtk_container_add( GTK_CONTAINER(footer_hbbox) , footer_bclose ); 331 gtk_container_add( GTK_CONTAINER(footer_hbbox) , footer_bclose );
332 gtk_box_pack_start( GTK_BOX(fileinfowin_vbox) , footer_hbbox , FALSE , FALSE , 0 ); 332 gtk_box_pack_start( GTK_BOX(fileinfowin_vbox) , footer_hbbox , FALSE , FALSE , 0 );
333 333
334 334
335 /* utf8-ize filename and set window title */ 335 /* utf8-ize filename and set window title */
336 filename = g_filename_from_uri( filename_uri , NULL , NULL );
337 if ( !filename )
338 filename = g_strdup( filename_uri );
336 filename_utf8 = g_strdup(g_filename_to_utf8( filename , -1 , NULL , NULL , NULL )); 339 filename_utf8 = g_strdup(g_filename_to_utf8( filename , -1 , NULL , NULL , NULL ));
337 if ( !filename_utf8 ) 340 if ( !filename_utf8 )
338 { 341 {
339 /* utf8 fallback */ 342 /* utf8 fallback */
340 gchar *chr , *convert_str = g_strdup( filename ); 343 gchar *chr , *convert_str = g_strdup( filename );
351 g_free(title); 354 g_free(title);
352 /* set the text for the filename header too */ 355 /* set the text for the filename header too */
353 gtk_entry_set_text( GTK_ENTRY(title_name_v_entry) , filename_utf8 ); 356 gtk_entry_set_text( GTK_ENTRY(title_name_v_entry) , filename_utf8 );
354 gtk_editable_set_position( GTK_EDITABLE(title_name_v_entry) , -1 ); 357 gtk_editable_set_position( GTK_EDITABLE(title_name_v_entry) , -1 );
355 g_free(filename_utf8); 358 g_free(filename_utf8);
359 g_free(filename);
356 360
357 gtk_widget_grab_focus( GTK_WIDGET(footer_bclose) ); 361 gtk_widget_grab_focus( GTK_WIDGET(footer_bclose) );
358 gtk_widget_show_all( fileinfowin ); 362 gtk_widget_show_all( fileinfowin );
359 } 363 }