mirror of
				https://github.com/Zedfrigg/ironbar.git
				synced 2025-11-03 23:11:54 +01:00 
			
		
		
		
	fix(custom): crash when clicking non-popup button
This commit is contained in:
		
					parent
					
						
							
								22ab33d194
							
						
					
				
			
			
				commit
				
					
						901a86caa4
					
				
			
		
					 2 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -115,17 +115,24 @@ impl ModulePopup for Option<gtk::Box> {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
pub trait PopupButton {
 | 
			
		||||
    fn try_popup_id(&self) -> Option<usize>;
 | 
			
		||||
    fn popup_id(&self) -> usize;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl PopupButton for Button {
 | 
			
		||||
    /// Gets the popup ID associated with this button, if there is one.
 | 
			
		||||
    /// Will return `None` if this is not a popup button.
 | 
			
		||||
    fn try_popup_id(&self) -> Option<usize> {
 | 
			
		||||
        self.get_tag("popup-id").copied()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Gets the popup ID associated with this button.
 | 
			
		||||
    /// This should only be called on buttons which are known to be associated with popups.
 | 
			
		||||
    ///
 | 
			
		||||
    /// # Panics
 | 
			
		||||
    /// Will panic if an ID has not been set.
 | 
			
		||||
    fn popup_id(&self) -> usize {
 | 
			
		||||
        *self.get_tag("popup-id").expect("data to exist")
 | 
			
		||||
        self.try_popup_id().expect("id to exist")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue