@@ -85,7 +85,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
8585 }
8686
8787 update_orientation ();
88- update_offset ();
88+ // update_offset ();
8989 }
9090 }
9191 }
@@ -215,6 +215,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
215215 set {
216216 if (this . length == 0 ) {
217217 _position = 0 ;
218+ tonearm. progress =
218219 prog. progress = 0 ;
219220 } else {
220221 #if SCROBBLING
@@ -223,6 +224,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
223224 }
224225 #endif
225226 _position = value ;
227+ tonearm. progress =
226228 prog. progress = (double )value / (double )this . length;
227229 }
228230 }
@@ -234,6 +236,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
234236 set {
235237 _length = value ;
236238
239+ tonearm. progress =
237240 prog. progress = value == 0 ? 0 : (double )this . position / (double )value ;
238241 #if SCROBBLING
239242 if (value > 0 ) {
@@ -271,17 +274,6 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
271274 }
272275
273276 private void update_orientation () {
274- switch (this . orientation) {
275- case Gtk . Orientation . VERTICAL:
276- this . default_width = 0 ;
277- this . default_height = this . cover_size == Size . SMALL ? 300 : 400 ;
278- break ;
279- default:
280- this . default_width = 534 ;
281- this . default_height = 0 ;
282- break ;
283- }
284-
285277 art_pic. orientation =
286278 main_box. orientation =
287279 prog. orientation = this . orientation;
@@ -310,31 +302,59 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
310302 if (value != art_pic. style ) {
311303 art_pic. style = value ;
312304 art_pic. turntable_playing = this . playing;
313- update_offset ();
305+ // update_offset ();
314306 }
315307 }
316308 }
317309
318- private void update_offset () {
319- switch (this . cover_style) {
320- case Widgets . Cover . Style . SHADOW:
321- prog. offset = art_pic. size - (int32 ) (Widgets . Cover . FADE_WIDTH / 2 );
322- break ;
323- default:
324- prog. offset = 0 ;
325- break ;
326- }
327- }
310+ // private void update_offset () {
311+ // switch (this.cover_style) {
312+ // case Widgets.Cover.Style.SHADOW:
313+ // prog.offset = art_pic.size - (int32) (Widgets.Cover.FADE_WIDTH / 2);
314+ // break;
315+ // default:
316+ // prog.offset = 0;
317+ // break;
318+ // }
319+ // }
328320
329321 private void update_extracted_colors () {
330322 prog. extracted_colors = art_pic. extracted_colors;
331323 }
332324
325+ private inline void setup_window_size () {
326+ this . default_width = settings. get_int (" window-w" );
327+ this . default_height = settings. get_int (" window-h" );
328+ this . maximized = settings. get_boolean (" window-maximized" );
329+
330+ this . notify[" default-width" ]. connect (on_window_size_changed);
331+ this . notify[" default-height" ]. connect (on_window_size_changed);
332+ this . notify[" maximized" ]. connect (on_window_size_changed);
333+ }
334+
335+ uint window_settings_timeout = 0 ;
336+ private void on_window_size_changed () {
337+ // non_art_box.visible = settings.orientation_horizontal ? this.default_width > 452 : this.default_height > 423;
338+ if (window_settings_timeout > 0 ) GLib . Source . remove (window_settings_timeout);
339+ window_settings_timeout = GLib . Timeout . add (2 * 1000 , update_window_size_settings, Priority . LOW );
340+ }
341+
342+ private bool update_window_size_settings () {
343+ settings. set_int (" window-h" , this . default_height);
344+ settings. set_int (" window-w" , this . default_width);
345+ settings. set_boolean (" window-maximized" , this . maximized);
346+
347+ window_settings_timeout = 0 ;
348+ return GLib . Source . REMOVE ;
349+ }
350+
333351 Mpris . Entry ? player = null ;
334352 Widgets . Marquee artist_label;
335353 Widgets . Marquee title_label;
336354 Widgets . Marquee album_label;
337355 Widgets . Cover art_pic;
356+ Widgets . Tonearm tonearm;
357+ Gtk . Box non_art_box;
338358 Widgets . ProgressBin prog;
339359 Gtk . Box main_box;
340360 Gtk . Button button_play;
@@ -344,31 +364,37 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
344364 construct {
345365 this . uuid = GLib . Uuid . string_random ();
346366 this . icon_name = Build . DOMAIN ;
347- this . resizable = false ;
348367 this . title = Build . NAME ;
349368
350- this . default_width = 0 ;
351- this . default_height = 0 ;
369+ setup_window_size ();
352370 this . height_request = - 1 ;
353371 this . width_request = - 1 ;
354372
355- main_box = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 0 );
373+ main_box = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 0 ) {
374+ valign = CENTER ,
375+ halign = CENTER
376+ };
356377 art_pic = new Widgets .Cover () {
357378 valign = Gtk . Align . START ,
358379 halign = Gtk . Align . START
359380 };
360381 art_pic. notify[" extracted-colors" ]. connect (update_extracted_colors);
361382 controls_overlay = new Widgets .ControlsOverlay (art_pic);
362- main_box. append (controls_overlay);
363383
364- var box2 = new Gtk .Box (Gtk . Orientation . VERTICAL , 0 ) {
384+ tonearm = new Widgets .Tonearm () {
385+ halign = CENTER ,
386+ child = controls_overlay
387+ };
388+ main_box. append (tonearm);
389+
390+ non_art_box = new Gtk .Box (Gtk . Orientation . VERTICAL , 0 ) {
365391 hexpand = true ,
366392 margin_top = 16 ,
367393 margin_bottom = 16 ,
368394 margin_end = 16 ,
369395 margin_start = 16
370396 };
371- main_box. append (box2 );
397+ main_box. append (non_art_box );
372398
373399
374400 title_label = new Widgets .Marquee () {
@@ -382,9 +408,9 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
382408 xalign = 0.0f
383409 };
384410
385- box2 . append (title_label);
386- box2 . append (artist_label);
387- box2 . append (album_label);
411+ non_art_box . append (title_label);
412+ non_art_box . append (artist_label);
413+ non_art_box . append (album_label);
388414
389415 prog = new Widgets .ProgressBin () {
390416 content = main_box
@@ -396,7 +422,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
396422 halign = Gtk . Align . CENTER ,
397423 valign = Gtk . Align . CENTER ,
398424 };
399- box2 . append (box3);
425+ non_art_box . append (box3);
400426
401427 button_prev = new Gtk .Button .from_icon_name (is_rtl ? " skip-forward-large-symbolic" : " skip-backward-large-symbolic" ) {
402428 css_classes = {" circular" },
@@ -520,8 +546,18 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
520546 account_manager.accounts_changed.connect (update_scrobble_status );
521547 #endif
522548
523- box2 .state_flags_changed.connect (on_state_flags_changed );
549+ non_art_box .state_flags_changed.connect (on_state_flags_changed );
524550 art_pic.map.connect (on_mapped );
551+
552+ Gtk . GestureClick click_gesture = new Gtk .GestureClick () {
553+ button = Gdk . BUTTON_PRIMARY
554+ };
555+ click_gesture.pressed.connect (on_click );
556+ prog.add_controller (click_gesture );
557+ }
558+
559+ private void on_click () {
560+ if (controls_overlay. hide_overlay ()) this . focus_widget = null ;
525561 }
526562
527563 private void play_next () {
@@ -537,7 +573,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
537573 }
538574
539575 private void on_mapped () {
540- update_offset ();
576+ // update_offset ();
541577 art_pic. turntable_playing = this . playing;
542578 }
543579
@@ -639,7 +675,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
639675 }
640676
641677 private void update_component_tonearm_from_settings () {
642- this . prog . tonearm_enabled = settings. component_tonearm;
678+ this . tonearm . enabled = settings. component_tonearm;
643679 component_tonearm_action. set_state (settings. component_tonearm);
644680 }
645681
@@ -663,10 +699,19 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
663699
664700 #if SCROBBLING
665701 private void open_scrobbling_setup () {
666- (new Views .ScrobblerSetup ()). present (this );
702+ this . resizable = false ;
703+
704+ var dlg = new Views .ScrobblerSetup ();
705+ dlg. present (this );
706+ dlg. closed. connect (make_resizable);
667707 }
668708 #endif
669709
710+ // hack to force present dialogs as windows
711+ public void make_resizable () {
712+ this . resizable = true ;
713+ }
714+
670715 GLib . Binding [] player_bindings = {};
671716 private void update_player (Mpris .Entry ? new_player ) {
672717 debug (" [%s ] Player Changed" , uuid);
0 commit comments