static void openOK(GtkObject *object, gpointer data) { GtkFileSelection *fileselection = GTK_FILE_SELECTION(data); GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app")); Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); gchar *fileName = g_strdup(gtk_file_selection_get_filename(fileselection)); pf_flow *newPara; gtk_widget_destroy(GTK_WIDGET(fileselection)); newPara = pf_factory(fileName, font, guiSupport); if (newPara != NULL) { gchar *title = prettyTitle(fileName); GtkWidget *area = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(app), "area")); if (context->paragraph != NULL) { pf_close(context->paragraph); } context->paragraph = newPara; gtk_window_set_title(GTK_WINDOW(app), title); gtk_widget_hide(area); pf_breakLines(context->paragraph, context->width, context->height); gtk_widget_show_all(area); g_free(title); } g_free(fileName); }
GtkWidget *newSample(const gchar *fileName) { Context *context = NEW_ARRAY(Context, 1); gchar *title; GtkWidget *app; GtkWidget *area; GtkStyle *style; int i; context->width = 600; context->height = 400; context->paragraph = pf_factory(fileName, font, guiSupport); title = prettyTitle(fileName); app = gnome_app_new("gnomeLayout", title); gtk_object_set_data(GTK_OBJECT(app), "context", context); gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); gtk_signal_connect(GTK_OBJECT(app), "delete_event", GTK_SIGNAL_FUNC(eventDelete), NULL); area = gtk_drawing_area_new(); gtk_object_set_data(GTK_OBJECT(app), "area", area); style = gtk_style_copy(gtk_widget_get_style(area)); for (i = 0; i < 5; i += 1) { style->fg[i] = style->white; } gtk_widget_set_style(area, style); gnome_app_set_contents(GNOME_APP(app), area); gtk_signal_connect(GTK_OBJECT(area), "expose_event", GTK_SIGNAL_FUNC(eventExpose), context); gtk_signal_connect(GTK_OBJECT(area), "configure_event", GTK_SIGNAL_FUNC(eventConfigure), context); appList = g_slist_prepend(appList, app); g_free(title); return app; }
QString MetaBundle::prettyTitle() const { QString s = m_artist; //NOTE this gets regressed often, please be careful! // whatever you do, handle the stream case, streams have no artist but have an excellent title //FIXME doesn't work for resume playback if( !s.isEmpty() ) s += i18n(" - "); s += m_title; if( s.isEmpty() ) s = prettyTitle( m_url.fileName() ); return s; }
QString MetaBundle::veryNiceTitle() const { QString s; //NOTE I'm not sure, but the notes and FIXME's in the prettyTitle function should be fixed now. // If not then they do apply to this function also! if( !m_title.isEmpty() ) { if( !m_artist.isEmpty() ) s = i18n( "%1 by %2" ).arg( m_title ).arg( m_artist ); else s = m_title; } else { s = prettyTitle( m_url.fileName() ); } return s; }
void MetaBundle::init( const KFileMetaInfo& info ) { if( info.isValid() && !info.isEmpty() ) { m_artist = info.item( "Artist" ).string(); m_album = info.item( "Album" ).string(); m_year = info.item( "Year" ).string(); m_comment = info.item( "Comment" ).string(); m_genre = info.item( "Genre" ).string(); m_track = info.item( "Track" ).string(); m_bitrate = info.item( "Bitrate" ).value().toInt(); m_length = info.item( "Length" ).value().toInt(); m_sampleRate = info.item( "Sample Rate" ).value().toInt(); // For title, check if it is valid. If not, use prettyTitle. // @see bug:83650 const KFileMetaInfoItem item = info.item( "Title" ); m_title = item.isValid() ? item.string() : prettyTitle( m_url.fileName() ); // because whoever designed KMetaInfoItem is a donkey #define makeSane( x ) if( x == "---" ) x = null; QString null; makeSane( m_artist ); makeSane( m_album ); makeSane( m_year ); makeSane( m_comment ); makeSane( m_genre ); makeSane( m_track ); makeSane( m_title ); #undef makeSane m_isValidMedia = true; } else { m_bitrate = m_length = m_sampleRate = Undetermined; m_isValidMedia = false; } }