mirror of
				https://github.com/johrpan/musicus.git
				synced 2025-10-26 11:47:25 +01:00 
			
		
		
		
	Show tracks in recording screen
This commit is contained in:
		
							parent
							
								
									54e743b876
								
							
						
					
					
						commit
						4bb92a3c27
					
				
					 3 changed files with 148 additions and 4 deletions
				
			
		|  | @ -1,8 +1,8 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!-- Generated with glade 3.38.1 --> | ||||
| <interface> | ||||
|   <requires lib="gtk+" version="3.24" /> | ||||
|   <requires lib="libhandy" version="1.0" /> | ||||
|   <requires lib="gtk+" version="3.24"/> | ||||
|   <requires lib="libhandy" version="1.0"/> | ||||
|   <object class="GtkBox" id="widget"> | ||||
|     <property name="visible">True</property> | ||||
|     <property name="can-focus">False</property> | ||||
|  | @ -53,7 +53,99 @@ | |||
|       </packing> | ||||
|     </child> | ||||
|     <child> | ||||
|       <placeholder /> | ||||
|       <object class="GtkStack" id="stack"> | ||||
|         <property name="visible">True</property> | ||||
|         <property name="can-focus">False</property> | ||||
|         <child> | ||||
|           <object class="GtkSpinner"> | ||||
|             <property name="visible">True</property> | ||||
|             <property name="can-focus">False</property> | ||||
|             <property name="active">True</property> | ||||
|           </object> | ||||
|           <packing> | ||||
|             <property name="name">loading</property> | ||||
|           </packing> | ||||
|         </child> | ||||
|         <child> | ||||
|           <object class="GtkScrolledWindow"> | ||||
|             <property name="visible">True</property> | ||||
|             <property name="can-focus">True</property> | ||||
|             <child> | ||||
|               <object class="GtkViewport"> | ||||
|                 <property name="visible">True</property> | ||||
|                 <property name="can-focus">False</property> | ||||
|                 <property name="shadow-type">none</property> | ||||
|                 <child> | ||||
|                   <object class="GtkBox"> | ||||
|                     <property name="visible">True</property> | ||||
|                     <property name="can-focus">False</property> | ||||
|                     <property name="border-width">18</property> | ||||
|                     <property name="orientation">vertical</property> | ||||
|                     <property name="spacing">18</property> | ||||
|                     <child> | ||||
|                       <object class="GtkBox"> | ||||
|                         <property name="visible">True</property> | ||||
|                         <property name="can-focus">False</property> | ||||
|                         <property name="orientation">vertical</property> | ||||
|                         <property name="spacing">12</property> | ||||
|                         <child> | ||||
|                           <object class="GtkLabel"> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="can-focus">False</property> | ||||
|                             <property name="halign">start</property> | ||||
|                             <property name="label" translatable="yes">Tracks</property> | ||||
|                             <attributes> | ||||
|                               <attribute name="size" value="12288"/> | ||||
|                             </attributes> | ||||
|                           </object> | ||||
|                           <packing> | ||||
|                             <property name="expand">False</property> | ||||
|                             <property name="fill">True</property> | ||||
|                             <property name="position">0</property> | ||||
|                           </packing> | ||||
|                         </child> | ||||
|                         <child> | ||||
|                           <object class="GtkFrame" id="frame"> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="can-focus">False</property> | ||||
|                             <property name="label-xalign">0</property> | ||||
|                             <property name="shadow-type">in</property> | ||||
|                             <child> | ||||
|                               <placeholder/> | ||||
|                             </child> | ||||
|                           </object> | ||||
|                           <packing> | ||||
|                             <property name="expand">False</property> | ||||
|                             <property name="fill">True</property> | ||||
|                             <property name="position">1</property> | ||||
|                           </packing> | ||||
|                         </child> | ||||
|                       </object> | ||||
|                       <packing> | ||||
|                         <property name="expand">False</property> | ||||
|                         <property name="fill">True</property> | ||||
|                         <property name="position">1</property> | ||||
|                       </packing> | ||||
|                     </child> | ||||
|                   </object> | ||||
|                 </child> | ||||
|               </object> | ||||
|             </child> | ||||
|           </object> | ||||
|           <packing> | ||||
|             <property name="name">content</property> | ||||
|             <property name="position">1</property> | ||||
|           </packing> | ||||
|         </child> | ||||
|         <child> | ||||
|           <placeholder/> | ||||
|         </child> | ||||
|       </object> | ||||
|       <packing> | ||||
|         <property name="expand">True</property> | ||||
|         <property name="fill">True</property> | ||||
|         <property name="position">1</property> | ||||
|       </packing> | ||||
|     </child> | ||||
|   </object> | ||||
| </interface> | ||||
|  |  | |||
|  | @ -192,7 +192,9 @@ impl From<Track> for TrackDescription { | |||
|     fn from(track: Track) -> Self { | ||||
|         let mut work_parts = Vec::<usize>::new(); | ||||
|         for part in track.work_parts.split(",") { | ||||
|             work_parts.push(part.parse().unwrap()); | ||||
|             if !part.is_empty() { | ||||
|                 work_parts.push(part.parse().unwrap()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         TrackDescription { | ||||
|  |  | |||
|  | @ -9,7 +9,9 @@ use std::cell::RefCell; | |||
| use std::rc::Rc; | ||||
| 
 | ||||
| pub struct RecordingScreen { | ||||
|     backend: Rc<Backend>, | ||||
|     widget: gtk::Box, | ||||
|     stack: gtk::Stack, | ||||
|     navigator: RefCell<Option<Rc<Navigator>>>, | ||||
| } | ||||
| 
 | ||||
|  | @ -22,6 +24,8 @@ impl RecordingScreen { | |||
|         get_widget!(builder, libhandy::HeaderBar, header); | ||||
|         get_widget!(builder, gtk::Button, back_button); | ||||
|         get_widget!(builder, gtk::MenuButton, menu_button); | ||||
|         get_widget!(builder, gtk::Stack, stack); | ||||
|         get_widget!(builder, gtk::Frame, frame); | ||||
| 
 | ||||
|         header.set_title(Some(&recording.work.get_title())); | ||||
|         header.set_subtitle(Some(&recording.get_performers())); | ||||
|  | @ -44,8 +48,45 @@ impl RecordingScreen { | |||
| 
 | ||||
|         menu_button.set_menu_model(Some(&menu)); | ||||
| 
 | ||||
|         let recording = Rc::new(recording); | ||||
|         let list = List::new( | ||||
|             clone!(@strong recording => move |track: &TrackDescription| { | ||||
|                 let mut title_parts = Vec::<String>::new(); | ||||
|                 for part in &track.work_parts { | ||||
|                     title_parts.push(recording.work.parts[*part].title.clone()); | ||||
|                 } | ||||
| 
 | ||||
|                 let title = if title_parts.is_empty() { | ||||
|                     String::from("Unknown") | ||||
|                 } else { | ||||
|                     title_parts.join(", ") | ||||
|                 }; | ||||
| 
 | ||||
|                 let title_label = gtk::Label::new(Some(&title)); | ||||
|                 title_label.set_ellipsize(pango::EllipsizeMode::End); | ||||
|                 title_label.set_halign(gtk::Align::Start); | ||||
| 
 | ||||
|                 let file_name_label = gtk::Label::new(Some(&track.file_name)); | ||||
|                 file_name_label.set_ellipsize(pango::EllipsizeMode::End); | ||||
|                 file_name_label.set_opacity(0.5); | ||||
|                 file_name_label.set_halign(gtk::Align::Start); | ||||
| 
 | ||||
|                 let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0); | ||||
|                 vbox.add(&title_label); | ||||
|                 vbox.add(&file_name_label); | ||||
| 
 | ||||
|                 vbox.upcast() | ||||
|             }), | ||||
|             |_| true, | ||||
|             "No tracks found.", | ||||
|         ); | ||||
| 
 | ||||
|         frame.add(&list.widget); | ||||
| 
 | ||||
|         let result = Rc::new(Self { | ||||
|             backend, | ||||
|             widget, | ||||
|             stack, | ||||
|             navigator: RefCell::new(None), | ||||
|         }); | ||||
| 
 | ||||
|  | @ -56,6 +97,15 @@ impl RecordingScreen { | |||
|             } | ||||
|         })); | ||||
| 
 | ||||
|         let context = glib::MainContext::default(); | ||||
|         let clone = result.clone(); | ||||
|         let id = recording.id; | ||||
|         context.spawn_local(async move { | ||||
|             let tracks = clone.backend.get_tracks(id).await.unwrap(); | ||||
|             list.show_items(tracks); | ||||
|             clone.stack.set_visible_child_name("content"); | ||||
|         }); | ||||
| 
 | ||||
|         result | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Elias Projahn
						Elias Projahn