mirror of
				https://gitlab.gnome.org/julianschacher/top-bar-organizer.git
				synced 2025-10-27 15:19:09 +00:00 
			
		
		
		
	Update: Make the preferences window content scrollable
Previously it could happen that the preferences window got larger than the height of the screen (e.g. when having a bunch of items and a low vertical screen resolution). Fix this, by making the preferences window content scrollable. Also introduce a nice default window size.
This commit is contained in:
		
							parent
							
								
									8bda3ea0ab
								
							
						
					
					
						commit
						a4ea0c630a
					
				| @ -18,81 +18,85 @@ | ||||
|   along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
| --> | ||||
| <interface> | ||||
|     <template class="PrefsWidget" parent="GtkBox"> | ||||
|         <property name="orientation">vertical</property> | ||||
|         <property name="spacing">24</property> | ||||
|         <property name="margin-top">36</property> | ||||
|         <property name="margin-bottom">36</property> | ||||
|         <property name="margin-start">36</property> | ||||
|         <property name="margin-end">36</property> | ||||
|         <child> | ||||
|             <object class="GtkLabel"> | ||||
|                 <property name="label">Simply use drag and drop to order the items any way you want.</property> | ||||
|                 <property name="halign">start</property> | ||||
|                 <style> | ||||
|                     <class name="dim-label"/> | ||||
|                 </style> | ||||
|             </object> | ||||
|         </child> | ||||
|     <template class="PrefsWidget" parent="GtkScrolledWindow"> | ||||
|         <child> | ||||
|             <object class="GtkBox"> | ||||
|                 <property name="orientation">vertical</property> | ||||
|                 <property name="spacing">24</property> | ||||
|                 <property name="margin-top">36</property> | ||||
|                 <property name="margin-bottom">36</property> | ||||
|                 <property name="margin-start">36</property> | ||||
|                 <property name="margin-end">36</property> | ||||
|                 <child> | ||||
|                     <object class="GtkLabel"> | ||||
|                         <property name="label">Left Top Bar Box</property> | ||||
|                         <property name="label">Simply use drag and drop to order the items any way you want.</property> | ||||
|                         <property name="halign">start</property> | ||||
|                         <property name="margin-bottom">12</property> | ||||
|                         <attributes> | ||||
|                             <attribute name="weight" value="bold"/> | ||||
|                         </attributes> | ||||
|                         <style> | ||||
|                             <class name="dim-label"/> | ||||
|                         </style> | ||||
|                     </object> | ||||
|                 </child> | ||||
|                 <child> | ||||
|                     <object class="GtkListBox" id="left-box-order"> | ||||
|                         <property name="selection-mode">none</property> | ||||
|                         <property name="show-separators">True</property> | ||||
|                     </object> | ||||
|                 </child> | ||||
|             </object> | ||||
|         </child> | ||||
|         <child> | ||||
|             <object class="GtkBox"> | ||||
|                 <property name="orientation">vertical</property> | ||||
|                 <child> | ||||
|                     <object class="GtkLabel"> | ||||
|                         <property name="label">Center Top Bar Box</property> | ||||
|                         <property name="halign">start</property> | ||||
|                         <property name="margin-bottom">12</property> | ||||
|                         <attributes> | ||||
|                             <attribute name="weight" value="bold"/> | ||||
|                         </attributes> | ||||
|                     <object class="GtkBox"> | ||||
|                         <property name="orientation">vertical</property> | ||||
|                         <child> | ||||
|                             <object class="GtkLabel"> | ||||
|                                 <property name="label">Left Top Bar Box</property> | ||||
|                                 <property name="halign">start</property> | ||||
|                                 <property name="margin-bottom">12</property> | ||||
|                                 <attributes> | ||||
|                                     <attribute name="weight" value="bold"/> | ||||
|                                 </attributes> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                         <child> | ||||
|                             <object class="GtkListBox" id="left-box-order"> | ||||
|                                 <property name="selection-mode">none</property> | ||||
|                                 <property name="show-separators">True</property> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                     </object> | ||||
|                 </child> | ||||
|                 <child> | ||||
|                     <object class="GtkListBox" id="center-box-order"> | ||||
|                         <property name="selection-mode">none</property> | ||||
|                         <property name="show-separators">True</property> | ||||
|                     </object> | ||||
|                 </child> | ||||
|             </object> | ||||
|         </child> | ||||
|         <child> | ||||
|             <object class="GtkBox"> | ||||
|                 <property name="orientation">vertical</property> | ||||
|                 <child> | ||||
|                     <object class="GtkLabel"> | ||||
|                         <property name="label">Right Top Bar Box</property> | ||||
|                         <property name="halign">start</property> | ||||
|                         <property name="margin-bottom">12</property> | ||||
|                         <attributes> | ||||
|                             <attribute name="weight" value="bold"/> | ||||
|                         </attributes> | ||||
|                     <object class="GtkBox"> | ||||
|                         <property name="orientation">vertical</property> | ||||
|                         <child> | ||||
|                             <object class="GtkLabel"> | ||||
|                                 <property name="label">Center Top Bar Box</property> | ||||
|                                 <property name="halign">start</property> | ||||
|                                 <property name="margin-bottom">12</property> | ||||
|                                 <attributes> | ||||
|                                     <attribute name="weight" value="bold"/> | ||||
|                                 </attributes> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                         <child> | ||||
|                             <object class="GtkListBox" id="center-box-order"> | ||||
|                                 <property name="selection-mode">none</property> | ||||
|                                 <property name="show-separators">True</property> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                     </object> | ||||
|                 </child> | ||||
|                 <child> | ||||
|                     <object class="GtkListBox" id="right-box-order"> | ||||
|                         <property name="selection-mode">none</property> | ||||
|                         <property name="show-separators">True</property> | ||||
|                     <object class="GtkBox"> | ||||
|                         <property name="orientation">vertical</property> | ||||
|                         <child> | ||||
|                             <object class="GtkLabel"> | ||||
|                                 <property name="label">Right Top Bar Box</property> | ||||
|                                 <property name="halign">start</property> | ||||
|                                 <property name="margin-bottom">12</property> | ||||
|                                 <attributes> | ||||
|                                     <attribute name="weight" value="bold"/> | ||||
|                                 </attributes> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                         <child> | ||||
|                             <object class="GtkListBox" id="right-box-order"> | ||||
|                                 <property name="selection-mode">none</property> | ||||
|                                 <property name="show-separators">True</property> | ||||
|                             </object> | ||||
|                         </child> | ||||
|                     </object> | ||||
|                 </child> | ||||
|             </object> | ||||
|  | ||||
							
								
								
									
										23
									
								
								src/prefs.js
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/prefs.js
									
									
									
									
									
								
							| @ -36,12 +36,33 @@ var PrefsWidget = GObject.registerClass({ | ||||
|         "center-box-order", | ||||
|         "right-box-order" | ||||
|     ] | ||||
| }, class PrefsWidget extends Gtk.Box { | ||||
| }, class PrefsWidget extends Gtk.ScrolledWindow { | ||||
|     _init(params = {}) { | ||||
|         super._init(params); | ||||
| 
 | ||||
|         this._settings = ExtensionUtils.getSettings(); | ||||
| 
 | ||||
|         // Never show a horizontal scrollbar.
 | ||||
|         // Achieved by setting the hscrollbar_policy to 2, while setting the
 | ||||
|         // vscrollbar_policy to 1 (the default value).
 | ||||
|         this.set_policy(2, 1); | ||||
| 
 | ||||
|         // Set the default size of the preferences window to a sensible value on
 | ||||
|         // realize.
 | ||||
|         this.connect("realize", () => { | ||||
|             // Get the window.
 | ||||
|             const window = this.get_root(); | ||||
| 
 | ||||
|             // Use 500 and 750 for the default size.
 | ||||
|             // Those are the same values the Just Perfection Gnome Shell
 | ||||
|             // extension uses.
 | ||||
|             // It seems like those values only get used the first time the
 | ||||
|             // preferences window gets opened in a session. On all consecutive
 | ||||
|             // opens, the window is a bit larger than those values.
 | ||||
|             window.default_width = 500; | ||||
|             window.default_height = 750; | ||||
|         }); | ||||
| 
 | ||||
|         // Initialize the given `gtkListBox`.
 | ||||
|         const initializeGtkListBox = (boxOrder, gtkListBox) => { | ||||
|             // Add the items of the given configured box order as
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user