songrec 0.7.3

An open-source Shazam client for Linux, written in Rust.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
using Gtk 4.0;
using Adw 1;
using Gio 2.0;

Adw.ApplicationWindow main_window {
  accessible-role: application;

  content: Adw.NavigationView main_window_pages {
    Adw.NavigationPage main_page {
      child: Adw.ToolbarView {
        content: ScrolledWindow main_scrollview {
          child: Box layout_box {
            homogeneous: true;
            margin-bottom: 15;
            margin-end: 15;
            margin-start: 15;
            margin-top: 15;
            spacing: 15;

            [primary]
            Box left_column {
              orientation: vertical;
              spacing: 15;

              Adw.PreferencesGroup identify_section {
                title: _("Recognize songs");

                Adw.ActionRow recognize_file_row {
                  activatable: true;
                  activatable-widget: recognize_file_button;
                  selectable: false;
                  title: _("Recognize from file");

                  Button recognize_file_button {
                    action-name: "win.recognize-file";

                    child: Adw.ButtonContent {
                      icon-name: "folder-new-symbolic";
                      label: _("Pick a file...");
                    };
                  }
                }

                Adw.PreferencesRow spinner_row {
                  activatable: false;
                  margin-end: 7;
                  margin-start: 7;
                  margin-top: 7;
                  selectable: false;
                  visible: false;

                  Spinner {
                    margin-bottom: 7;
                    spinning: true;
                  }
                }

                Adw.SwitchRow microphone_switch {
                  activatable: true;
                  selectable: false;
                  title: _("Recognize from microphone");
                  visible: false;
                  notify::active => $microphone_option_switched();
                }

                Adw.SwitchRow loopback_switch {
                  activatable: true;
                  selectable: false;
                  title: _("Recognize from my speakers");
                  visible: false;
                  notify::active => $loopback_options_switched();
                }

                Label no_network_message {
                  attributes: "0 -1 weight medium, 0 -1 foreground #a4a400000000";
                  label: _("Shazam servers are not reachable, are you connected?");
                  margin-top: 5;
                  visible: false;
                }

                Label rate_limited_message {
                  attributes: "0 -1 weight bold, 0 -1 foreground #a4a400000000";
                  label: _("ERROR: Your IP has been rate-limited");
                  margin-top: 5;
                  visible: false;
                }
              }

              Adw.PreferencesGroup results_section {
                title: _("Recognition results");
                visible: false;

                Adw.PreferencesRow results_row {
                  activatable: false;
                  selectable: false;

                  Box {
                    margin-bottom: 7;
                    margin-end: 7;
                    margin-start: 7;
                    margin-top: 7;
                    orientation: vertical;
                    spacing: 7;

                    Label results_label {
                      attributes: "0 -1 weight bold";
                      ellipsize: end;
                      label: "Artist - Song name";
                      natural-wrap-mode: word;
                      selectable: true;
                    }

                    Image results_image {
                      pixel-size: 160;
                    }
                  }
                }

                Adw.ActionRow search_youtube_row {
                  activatable: true;
                  activatable-widget: search_youtube_button;
                  selectable: false;
                  title: _("Search on YouTube");

                  Button search_youtube_button {
                    action-name: "win.search-youtube";

                    child: Adw.ButtonContent {
                      icon-name: "search-symbolic";
                      label: _("Search...");
                    };
                  }
                }
              }
            }

            [secondary]
            Box right_column {
              orientation: vertical;
              spacing: 15;

              Adw.PreferencesGroup input_device_section {
                header-suffix: Button refresh_devices {
                  action-name: "win.refresh-devices";
                  icon-name: "view-refresh-symbolic";
                  tooltip-text: _("Refresh available devices");
                };

                title: _("Audio input");
                visible: false;

                Adw.ComboRow audio_inputs {
                  factory: BuilderListItemFactory audio_inputs_factory {
                    template ListItem {
                      child: Label {
                        xalign: 0;
                        ellipsize: end;
                        label: bind template.item as <$ListedDevice>.display_name;
                      };
                    }
                  };

                  model: Gio.ListStore audio_inputs_model {};

                  title: _("Device");
                  title-lines: 1;
                  notify::selected-item => $input_device_switched();
                }

                Adw.PreferencesRow volume_row {
                  activatable: false;
                  selectable: false;

                  Box {
                    margin-bottom: 15;
                    margin-end: 15;
                    margin-start: 15;
                    margin-top: 15;
                    spacing: 15;

                    Label volume_label {
                      label: _("Volume:");
                    }

                    ProgressBar volume_gauge {
                      hexpand: true;
                      valign: center;
                    }
                  }
                }
              }

              Adw.PreferencesGroup history_section {
                header-suffix: MenuButton history_params {
                  has-tooltip: true;
                  icon-name: "preferences-system";
                  menu-model: history_menu_model;
                  tooltip-text: _("History options...");
                };

                title: _("Recognition history");

                Adw.PreferencesRow history_row {
                  child: ScrolledWindow {
                    child: history_view;

                    ColumnView history_view {
                      accessible-role: list;

                      css-classes: [
                        "column_view",
                      ];

                      model: SingleSelection history_selection {
                        autoselect: false;
                        can-unselect: true;
                      };

                      show-column-separators: true;
                      show-row-separators: true;

                      ColumnViewColumn song_name_cell {
                        factory: SignalListItemFactory {
                          setup => $history_cell_setup_cb(song_name_cell);
                          bind => $history_cell_bind_cb(song_name_cell);
                        };

                        id: "song_name";
                        resizable: true;
                        title: _("Song name");
                      }

                      ColumnViewColumn album_cell {
                        factory: SignalListItemFactory {
                          bind => $history_cell_bind_cb(album_cell);
                          setup => $history_cell_setup_cb(album_cell);
                        };

                        id: "album";
                        resizable: true;
                        title: _("Album");
                      }

                      ColumnViewColumn recognition_date_cell {
                        expand: true;

                        factory: SignalListItemFactory {
                          bind => $history_cell_bind_cb(recognition_date_cell);
                          setup => $history_cell_setup_cb(recognition_date_cell);
                        };

                        id: "recognition_date";
                        resizable: true;
                        title: _("Recognition date");
                      }
                    }
                  };

                  height-request: 200;
                }

                Adw.PreferencesRow favorites_button {
                  accessible-role: button;
                  action-name: "navigation.push";
                  action-target: "'favorites_tag'";

                  child: Label {
                    attributes: "0 -1 weight medium";
                    label: _("View favorites");
                    margin-bottom: 10;
                    margin-top: 10;
                  };
                }
              }
            }
          };
        };

        [top]
        Adw.HeaderBar title_bar {
          [end]
          MenuButton menu_button {
            accessible-role: menu;
            has-tooltip: true;
            icon-name: "open-menu-symbolic";
            menu-model: main_menu_model;
            primary: true;
            tooltip-text: _("Application menu");
          }
        }
      };

      title: "SongRec";
    }

    Adw.NavigationPage favorites_page {
      child: Adw.ToolbarView {
        content: ScrolledWindow {
          child: favorites_view;

          ColumnView favorites_view {
            accessible-role: list;

            css-classes: [
              "column_view",
            ];

            model: SingleSelection favorites_selection {
              autoselect: false;
              can-unselect: true;
            };

            show-column-separators: true;
            show-row-separators: true;

            ColumnViewColumn favorites_song_name_cell {
              factory: SignalListItemFactory {
                bind => $history_cell_bind_cb(favorites_song_name_cell);
                setup => $history_cell_setup_cb(favorites_song_name_cell);
              };

              id: "song_name";
              resizable: true;
              title: _("Song name");
            }

            ColumnViewColumn favorites_album_cell {
              factory: SignalListItemFactory {
                bind => $history_cell_bind_cb(favorites_album_cell);
                setup => $history_cell_setup_cb(favorites_album_cell);
              };

              id: "album";
              resizable: true;
              title: _("Album");
            }

            ColumnViewColumn favorites_recognition_date_cell {
              expand: true;

              factory: SignalListItemFactory {
                bind => $history_cell_bind_cb(favorites_recognition_date_cell);
                setup => $history_cell_setup_cb(favorites_recognition_date_cell);
              };

              id: "recognition_date";
              resizable: true;
              title: _("Recognition date");
            }
          }
        };

        [top]
        Adw.HeaderBar favorites_titlebar {}

        [bottom]
        ActionBar favorites_actions {
          Button favorites_export_csv {
            action-name: "win.export-favorites-to-csv";

            Adw.ButtonContent {
              icon-name: "x-office-spreadsheet-symbolic";
              label: _("Export to CSV");
            }
          }
        }
      };

      tag: "favorites_tag";
      title: _("Favorites");
    }

    Adw.NavigationPage settings_page {
      child: Adw.ToolbarView {
        content: Adw.PreferencesPage {
          Adw.PreferencesGroup general_preferences {
            title: _("General preferences");

            Adw.SwitchRow notification_setting {
              action-name: "win.notification-setting";
              subtitle: _("Notify when a new song is recognized or network error is encountered");
              title: _("Show notifications");
            }

            Adw.SwitchRow no_dupes_setting {
              action-name: "win.no-dupes-setting";
              subtitle: _(
                "Bump a song to the top of the history list and remove the former entry when the same song is detected multiple times"
              );
              title: _("No duplicates in history");
            }

            Adw.SwitchRow systray_setting {
              action-name: "win.systray-setting";
              subtitle: _(
                "When closing the window, minimize to system tray using KSNI instead of closing the app. Please note that you may have to increase the \"request interval\" setting when leaving SongRec running in the background to reduce your changes of getting rate-limited."
              );
              title: _("Minimize to system tray");
              visible: false;
            }
          }

          Adw.PreferencesGroup network_preferences {
            title: _("Network preferences");

            Adw.SpinRow interval_setting {
              adjustment: Adjustment interval_value {
                lower: 1;
                page-increment: 1;
                page-size: 1;
                step-increment: 1;
                upper: 513;
                value: 8;
                value-changed => $interval_changed();
              };

              climb-rate: 1;
              numeric: true;
              snap-to-ticks: true;
              subtitle: _("By default 8, increase if you are rate-limited");
              title: _("Shazam interval between requests in seconds");
              update-policy: if_valid;
            }

            Adw.SwitchRow mpris_setting {
              action-name: "win.mpris-setting";
              has-tooltip: true;
              subtitle: _(
                "MPRIS will display information about recognized songs in places like the GNOME or KDE control panel"
              );
              title: _("Enable MPRIS");
              visible: false;
            }
          }

          Adw.PreferencesGroup search_preferences {
            title: _("Search preferences");

            Adw.EntryRow search_engine_name {
              title: _("Custom search engine action");
              changed => $search_engine_action_changed();
            }

            Adw.EntryRow search_engine_url {
              title: _("Custom search engine URL");
              changed => $search_engine_url_changed();
            }
          }
        };

        [top]
        Adw.HeaderBar {}
      };

      tag: "settings_tag";
      title: _("Settings");
    }
  };

  default-height: 570;
  default-width: 977;
  icon-name: "re.fossplant.songrec";
  startup-id: "re.fossplant.songrec";
  title: "SongRec";
  visible: true;

  Adw.Breakpoint main_page_breakpoint {
    condition ("max-width: 800px")

    setters {
      layout_box.orientation: vertical;
      layout_box.homogeneous: false;
    }
  }
}

menu main_menu_model {
  section menu_section {
    item {
      action: "win.notification-setting";
      label: _("Show notifications");
    }

    item {
      action: "navigation.push";
      label: _("_Preferences...");
      target: "settings_tag";
    }
  }

  section {
    item {
      action: "win.show-about";
      label: _("About...");
    }
  }
}

Adw.AboutDialog about_dialog {
  application-icon: "custom_icon";
  application-name: "SongRec";
  debug-info-filename: "songrec-debug-info.txt";
  developer-name: "Marin Moulinier - Fossplant.re";

  developers: [
    "Marin Moulinier https://moulinier.dev/",
    "Contributors https://github.com/marin-m/SongRec/graphs/contributors",
  ];

  issue-url: "https://github.com/marin-m/SongRec/issues/new/choose";
  license-type: gpl_3_0;
  support-url: "https://matrix.to/#/#songrec:matrix.org";
  translator-credits: "SongRec translators https://github.com/marin-m/SongRec/tree/main/translations";
  visible: false;
  website: "https://songrec.fossplant.re/";
  closed => $about_dialog_closed();
}

menu history_menu_model {
  item {
    action: "win.export-to-csv";
    label: _("Export to CSV");
  }

  item {
    action: "win.wipe-history";
    label: _("Delete history");
  }
}

FileDialog file_picker {
  title: _("Select a file to recognize");
}

PopoverMenu history_context_menu {
  menu-model: history_context_model;
}

menu history_context_model {
  section {
    item {
      action: "history-menu.copy-artist-track";
      icon: "edit-copy-symbolic";
      label: _("Copy artist and track");
    }

    item {
      action: "history-menu.copy-artist";
      icon: "edit-copy-symbolic";
      label: _("Copy artist");
    }

    item {
      action: "history-menu.copy-track-name";
      icon: "edit-copy-symbolic";
      label: _("Copy track name");
    }

    item {
      action: "history-menu.copy-album";
      icon: "edit-copy-symbolic";
      label: _("Copy album");
    }
  }

  section {
    item {
      action: "history-menu.search-on-youtube";
      icon: "search-symbolic";
      label: _("Search on YouTube");
    }
  }

  section {
    item {
      action: "history-menu.remove-from-history";
      icon: "edit-delete-symbolic";
      label: _("Delete from History");
    }

    item {
      action: "history-menu.add-to-favorites";
      icon: "favorite-new-symbolic";
      label: _("Add to Favorites");
    }
  }
}

menu history_context_model_faved {
  section {
    item {
      action: "history-menu.copy-artist-track";
      icon: "edit-copy-symbolic";
      label: _("Copy artist and track");
    }

    item {
      action: "history-menu.copy-artist";
      icon: "edit-copy-symbolic";
      label: _("Copy artist");
    }

    item {
      action: "history-menu.copy-track-name";
      icon: "edit-copy-symbolic";
      label: _("Copy track name");
    }

    item {
      action: "history-menu.copy-album";
      icon: "edit-copy-symbolic";
      label: _("Copy album");
    }
  }

  section {
    item {
      action: "history-menu.search-on-youtube";
      icon: "search-symbolic";
      label: _("Search on YouTube");
    }
  }

  section {
    item {
      action: "history-menu.remove-from-favorites";
      icon: "edit-delete-symbolic";
      label: _("Remove from Favorites");
    }
  }
}

ShortcutsWindow shortcuts_window {
  child: ShortcutsSection {
    title: "shortcuts";

    ShortcutsGroup {
      title: C_("General section in the Shortcuts window", "General");

      ShortcutsShortcut {
        accelerator: "<Ctrl>Q";
        action-name: "win.close";
        title: C_("In the shortcuts window", "Close the application");
      }

      ShortcutsShortcut {
        accelerator: "<Ctrl>O";
        action-name: "win.recognize-file";
        title: C_("In the shortcuts window", "Recognize from a file");
      }

      ShortcutsShortcut {
        accelerator: "<Primary>comma";
        action-name: "win.show-preferences";
        title: C_("In the shortcuts window", "Show preferences");
      }

      ShortcutsShortcut {
        accelerator: "<Primary>question";
        action-name: "win.display-shortcuts";
        title: C_("In the shortcuts window", "Display shortcuts");
      }

      ShortcutsShortcut {
        accelerator: "F10";
        action-name: "win.show-menu";
        title: C_("win.show-menu", "Show menu");
      }
    }
  };

  destroy-with-parent: true;
  focus-visible: false;
  hide-on-close: true;
  modal: true;
  transient-for: main_window;
}