Add GTK application implementation
This commit is contained in:
parent
d1bb505e0a
commit
b7c0307f6b
29 changed files with 2564 additions and 266 deletions
32
data/data.go
Normal file
32
data/data.go
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "embed"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed ui/window.ui
|
||||||
|
var WindowXML string
|
||||||
|
|
||||||
|
//go:embed ui/shortcuts-dialog.ui
|
||||||
|
var ShortcutsDialogXML string
|
||||||
|
|
||||||
|
//go:embed ui/connection-panel.ui
|
||||||
|
var ConnectionPanelXML string
|
||||||
|
|
||||||
|
//go:embed ui/server-panel.ui
|
||||||
|
var ServerPanelXML string
|
||||||
|
|
||||||
|
//go:embed ui/cover-panel.ui
|
||||||
|
var CoverPanelXML string
|
||||||
|
|
||||||
|
//go:embed ui/playlist-panel.ui
|
||||||
|
var PlaylistPanelXML string
|
||||||
|
|
||||||
|
//go:embed ui/album-headerbar.ui
|
||||||
|
var AlbumHeaderbarXML string
|
||||||
|
|
||||||
|
//go:embed ui/library-panel.ui
|
||||||
|
var LibraryPanelXML string
|
||||||
|
|
||||||
|
//go:embed gtk.css
|
||||||
|
var MainCSS string
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#content_stack {
|
#content_stack {
|
||||||
box-shadow:inset 4px 4px 10px rgba(0,0,0,0.3);
|
box-shadow:inset 4px 4px 10px rgba(0,0,0,0.3);
|
||||||
background-image:url('noise-texture.png');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#port_spinner {
|
#port_spinner {
|
||||||
|
|
@ -30,10 +29,6 @@
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.fullscreen #cover_box {
|
|
||||||
background: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
#cover_info_revealer {
|
#cover_info_revealer {
|
||||||
background-color:alpha(@theme_bg_color, 0.8);
|
background-color:alpha(@theme_bg_color, 0.8);
|
||||||
box-shadow:0 0 10px @theme_bg_color;
|
box-shadow:0 0 10px @theme_bg_color;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
application_id = 'xyz.suruatoel.mcg'
|
|
||||||
|
|
||||||
scalable_dir = join_paths('hicolor', 'scalable', 'apps')
|
|
||||||
install_data(
|
|
||||||
join_paths(scalable_dir, ('@0@.svg').format(application_id)),
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir)
|
|
||||||
)
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="4.8"/>
|
<requires lib="gtk+" version="4.8"/>
|
||||||
<requires lib="adw" version="1.2" />
|
<requires lib="adw" version="1.2" />
|
||||||
<template class="McgAlbumHeaderbar" parent="AdwBin">
|
<object id="McgAlbumHeaderbar" class="AdwBin">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHeaderBar">
|
<object class="GtkHeaderBar">
|
||||||
<child type="title">
|
<child type="title">
|
||||||
|
|
@ -25,9 +25,8 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object id="close_button" class="GtkButton">
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_close_clicked" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="icon-name">go-previous-symbolic</property>
|
<property name="icon-name">go-previous-symbolic</property>
|
||||||
|
|
@ -37,5 +36,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -9,79 +9,58 @@
|
||||||
<property name="step-increment">1</property>
|
<property name="step-increment">1</property>
|
||||||
<property name="page-increment">100</property>
|
<property name="page-increment">100</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkBox" id="toolbar">
|
<object id="McgConnectionPanel" class="AdwBin">
|
||||||
<property name="orientation">horizontal</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
</object>
|
|
||||||
<template class="McgConnectionPanel" parent="AdwBin">
|
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwStatusPage">
|
<object class="AdwStatusPage">
|
||||||
<property name="title">Connect to MPD</property>
|
<property name="title">Connect to MPD</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkListBox">
|
||||||
<property name="hexpand">false</property>
|
<property name="hexpand">false</property>
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="selection-mode">none</property>
|
||||||
|
<style>
|
||||||
|
<class name="boxed-list"/>
|
||||||
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox" id="zeroconf_list">
|
<object class="AdwEntryRow" id="host_row">
|
||||||
<property name="hexpand">true</property>
|
<property name="title" translatable="yes">Host</property>
|
||||||
<child type="placeholder">
|
<property name="show-apply-button">true</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<style>
|
||||||
|
<class name="header"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="label" translatable="yes">No service found</property>
|
<property name="label" translatable="yes">Port</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="hexpand">false</property>
|
||||||
|
<style>
|
||||||
|
<class name="subtitle"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="port_spinner">
|
||||||
|
<property name="name">port_spinner</property>
|
||||||
|
<property name="value">6600</property>
|
||||||
|
<property name="adjustment">server-port-adjustment</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox">
|
<object class="AdwPasswordEntryRow" id="password_row">
|
||||||
<property name="hexpand">true</property>
|
<property name="title" translatable="yes">Password</property>
|
||||||
<property name="selection-mode">none</property>
|
<property name="show-apply-button">true</property>
|
||||||
<style>
|
|
||||||
<class name="boxed-list"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="AdwEntryRow" id="host_row">
|
|
||||||
<property name="title" translatable="yes">Host</property>
|
|
||||||
<property name="show-apply-button">true</property>
|
|
||||||
<signal name="apply" handler="on_host_entry_apply"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<style>
|
|
||||||
<class name="header"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="label" translatable="yes">Port</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="hexpand">false</property>
|
|
||||||
<style>
|
|
||||||
<class name="subtitle"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="port_spinner">
|
|
||||||
<property name="name">port_spinner</property>
|
|
||||||
<property name="value">6600</property>
|
|
||||||
<property name="adjustment">server-port-adjustment</property>
|
|
||||||
<signal name="value-changed" handler="on_port_spinner_value_changed"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="AdwPasswordEntryRow" id="password_row">
|
|
||||||
<property name="title" translatable="yes">Password</property>
|
|
||||||
<property name="show-apply-button">true</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<template class="McgCoverPanel" parent="GtkOverlay">
|
<object id="McgCoverPanel" class="GtkOverlay">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkStack" id="cover_stack">
|
<object class="GtkStack" id="cover_stack">
|
||||||
<property name="visible-child">cover_default</property>
|
<property name="visible-child">cover_default</property>
|
||||||
|
|
@ -157,5 +157,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,11 @@
|
||||||
<property name="round-digits">0</property>
|
<property name="round-digits">0</property>
|
||||||
<property name="digits">0</property>
|
<property name="digits">0</property>
|
||||||
<property name="has-origin">False</property>
|
<property name="has-origin">False</property>
|
||||||
<signal name="value-changed" handler="on_grid_scale_changed" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="library-toolbar-update">
|
<object class="GtkButton" id="library-toolbar-update">
|
||||||
<property name="label" translatable="yes">update library</property>
|
<property name="label" translatable="yes">update library</property>
|
||||||
<signal name="clicked" handler="on_update_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -53,7 +51,6 @@
|
||||||
<property name="label" translatable="yes">sort by artist</property>
|
<property name="label" translatable="yes">sort by artist</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="group">sort_year</property>
|
<property name="group">sort_year</property>
|
||||||
<signal name="toggled" handler="on_sort_toggled" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -61,14 +58,12 @@
|
||||||
<property name="label" translatable="yes">sort by title</property>
|
<property name="label" translatable="yes">sort by title</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="group">sort_year</property>
|
<property name="group">sort_year</property>
|
||||||
<signal name="toggled" handler="on_sort_toggled" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="sort_year">
|
<object class="GtkCheckButton" id="sort_year">
|
||||||
<property name="label" translatable="yes">sort by year</property>
|
<property name="label" translatable="yes">sort by year</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<signal name="toggled" handler="on_sort_toggled" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -76,7 +71,6 @@
|
||||||
<property name="label" translatable="yes">sort by modification</property>
|
<property name="label" translatable="yes">sort by modification</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="group">sort_year</property>
|
<property name="group">sort_year</property>
|
||||||
<signal name="toggled" handler="on_sort_toggled" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -86,7 +80,6 @@
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="active">True</property>
|
<property name="active">True</property>
|
||||||
<signal name="toggled" handler="on_sort_order_toggled" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -108,9 +101,6 @@
|
||||||
<property name="icon-name">system-search-symbolic</property>
|
<property name="icon-name">system-search-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<!--
|
|
||||||
<accelerator key="f" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
|
||||||
-->
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -119,7 +109,6 @@
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Select multiple albums</property>
|
<property name="tooltip-text" translatable="yes">Select multiple albums</property>
|
||||||
<signal name="toggled" handler="on_select_toggled" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="icon-name">object-select-symbolic</property>
|
<property name="icon-name">object-select-symbolic</property>
|
||||||
|
|
@ -145,7 +134,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<template class="McgLibraryPanel" parent="AdwBin">
|
<object id="McgLibraryPanel" class="AdwBin">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkStack" id="library_stack">
|
<object class="GtkStack" id="library_stack">
|
||||||
<property name="transition-type">slide-left-right</property>
|
<property name="transition-type">slide-left-right</property>
|
||||||
|
|
@ -158,7 +147,6 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="filter_entry">
|
<object class="GtkSearchEntry" id="filter_entry">
|
||||||
<property name="placeholder-text" translatable="yes">search library</property>
|
<property name="placeholder-text" translatable="yes">search library</property>
|
||||||
<signal name="search-changed" handler="on_filter_entry_changed" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -206,49 +194,9 @@
|
||||||
<object class="GtkGridView" id="library_grid">
|
<object class="GtkGridView" id="library_grid">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="single_click_activate">true</property>
|
<property name="single_click_activate">true</property>
|
||||||
<signal name="activate" handler="on_library_grid_clicked"/>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="no-bg"/>
|
<class name="no-bg"/>
|
||||||
</style>
|
</style>
|
||||||
<property name="factory">
|
|
||||||
<object class="GtkBuilderListItemFactory">
|
|
||||||
<property name="bytes">
|
|
||||||
<![CDATA[
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<template class="GtkListItem">
|
|
||||||
<property name="activatable">true</property>
|
|
||||||
<property name="child">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="vexpand">true</property>
|
|
||||||
<property name="hexpand">true</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkPicture">
|
|
||||||
<property name="content-fit">contain</property>
|
|
||||||
<property name="can-shrink">false</property>
|
|
||||||
<property name="vexpand">true</property>
|
|
||||||
<property name="hexpand">true</property>
|
|
||||||
<binding name="tooltip-markup">
|
|
||||||
<lookup name="tooltip" type="GridItem">
|
|
||||||
<lookup name="item">GtkListItem</lookup>
|
|
||||||
</lookup>
|
|
||||||
</binding>
|
|
||||||
<binding name="paintable">
|
|
||||||
<lookup name="cover" type="GridItem">
|
|
||||||
<lookup name="item">GtkListItem</lookup>
|
|
||||||
</lookup>
|
|
||||||
</binding>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
||||||
]]>
|
|
||||||
</property>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -264,17 +212,15 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkActionBar" id="actionbar">
|
<object class="GtkActionBar" id="actionbar">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="selection_cancel_button">
|
||||||
<property name="label" translatable="yes">cancel</property>
|
<property name="label" translatable="yes">cancel</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_selection_cancel_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="selection_queue_button">
|
||||||
<property name="label" translatable="yes">queue</property>
|
<property name="label" translatable="yes">queue</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_selection_add_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -321,17 +267,15 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkActionBar" id="actionbar_standalone">
|
<object class="GtkActionBar" id="actionbar_standalone">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="standalone_play_button">
|
||||||
<property name="label" translatable="yes">play</property>
|
<property name="label" translatable="yes">play</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_standalone_play_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="standalone_queue_button">
|
||||||
<property name="label" translatable="yes">queue</property>
|
<property name="label" translatable="yes">queue</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_standalone_queue_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -340,5 +284,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Select multiple albums</property>
|
<property name="tooltip-text" translatable="yes">Select multiple albums</property>
|
||||||
<signal name="toggled" handler="on_select_toggled" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="icon-name">object-select-symbolic</property>
|
<property name="icon-name">object-select-symbolic</property>
|
||||||
|
|
@ -26,7 +25,6 @@
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Clear the playlist</property>
|
<property name="tooltip-text" translatable="yes">Clear the playlist</property>
|
||||||
<signal name="clicked" handler="on_clear_clicked" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
@ -37,7 +35,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<template class="McgPlaylistPanel" parent="AdwBin">
|
<object id="McgPlaylistPanel" class="AdwBin">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkStack" id="playlist_stack">
|
<object class="GtkStack" id="playlist_stack">
|
||||||
<property name="transition-type">slide-left-right</property>
|
<property name="transition-type">slide-left-right</property>
|
||||||
|
|
@ -51,45 +49,9 @@
|
||||||
<object class="GtkGridView" id="playlist_grid">
|
<object class="GtkGridView" id="playlist_grid">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="single-click-activate">true</property>
|
<property name="single-click-activate">true</property>
|
||||||
<signal name="activate" handler="on_playlist_grid_clicked"/>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="no-bg"/>
|
<class name="no-bg"/>
|
||||||
</style>
|
</style>
|
||||||
<property name="factory">
|
|
||||||
<object class="GtkBuilderListItemFactory">
|
|
||||||
<property name="bytes">
|
|
||||||
<![CDATA[
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<template class="GtkListItem">
|
|
||||||
<property name="activatable">true</property>
|
|
||||||
<property name="child">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkPicture">
|
|
||||||
<property name="content-fit">contain</property>
|
|
||||||
<property name="can-shrink">false</property>
|
|
||||||
<binding name="tooltip-markup">
|
|
||||||
<lookup name="tooltip" type="GridItem">
|
|
||||||
<lookup name="item">GtkListItem</lookup>
|
|
||||||
</lookup>
|
|
||||||
</binding>
|
|
||||||
<binding name="paintable">
|
|
||||||
<lookup name="cover" type="GridItem">
|
|
||||||
<lookup name="item">GtkListItem</lookup>
|
|
||||||
</lookup>
|
|
||||||
</binding>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
||||||
]]>
|
|
||||||
</property>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -103,17 +65,15 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkActionBar" id="actionbar">
|
<object class="GtkActionBar" id="actionbar">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="selection_cancel_button">
|
||||||
<property name="label" translatable="yes">cancel</property>
|
<property name="label" translatable="yes">cancel</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_selection_cancel_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="selection_remove_button">
|
||||||
<property name="label" translatable="yes">remove</property>
|
<property name="label" translatable="yes">remove</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_selection_remove_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -159,17 +119,15 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkActionBar" id="actionbar_standalone">
|
<object class="GtkActionBar" id="actionbar_standalone">
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="standalone_play_button">
|
||||||
<property name="label" translatable="yes">play</property>
|
<property name="label" translatable="yes">play</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_standalone_play_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="standalone_remove_button">
|
||||||
<property name="label" translatable="yes">remove</property>
|
<property name="label" translatable="yes">remove</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<signal name="clicked" handler="on_standalone_remove_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -178,5 +136,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<template class="McgServerPanel" parent="AdwBin">
|
<object id="McgServerPanel" class="AdwBin">
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwFlap" id="server_flap">
|
<object class="AdwFlap" id="server_flap">
|
||||||
<property name="flap-position">end</property>
|
<property name="flap-position">end</property>
|
||||||
|
|
@ -322,5 +322,5 @@
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="4.8"/>
|
<requires lib="gtk+" version="4.8"/>
|
||||||
<requires lib="adw" version="1.2" />
|
<requires lib="adw" version="1.2" />
|
||||||
<template class="McgShortcutsDialog" parent="GtkShortcutsWindow">
|
<object id="McgShortcutsDialog" class="GtkShortcutsWindow">
|
||||||
<property name="modal">1</property>
|
<property name="modal">1</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsSection">
|
<object class="GtkShortcutsSection">
|
||||||
|
|
@ -103,5 +103,5 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="4.8" />
|
<requires lib="gtk+" version="4.8" />
|
||||||
<requires lib="adw" version="1.2" />
|
<requires lib="adw" version="1.2" />
|
||||||
<template class="McgAppWindow" parent="AdwApplicationWindow">
|
<object id="McgAppWindow" class="AdwApplicationWindow">
|
||||||
|
<property name="title">CoverGrid</property>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwToolbarView" id="toolbar_view">
|
<object class="AdwToolbarView" id="toolbar_view">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
|
|
@ -17,13 +18,12 @@
|
||||||
</property>
|
</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSwitch" id="headerbar_button_connect">
|
<object class="GtkSwitch" id="headerbar_button_connect">
|
||||||
<signal name="state-set" handler="on_headerbar_connection_state_set" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="headerbar_button_playpause">
|
<object class="GtkToggleButton" id="headerbar_button_playpause">
|
||||||
|
<property name="sensitive">false</property>
|
||||||
<property name="tooltip-text" translatable="yes">Switch between play and pause</property>
|
<property name="tooltip-text" translatable="yes">Switch between play and pause</property>
|
||||||
<signal name="toggled" handler="on_headerbar_playpause_toggled" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkVolumeButton" id="headerbar_button_volume">
|
<object class="GtkVolumeButton" id="headerbar_button_volume">
|
||||||
<signal name="value-changed" handler="on_headerbar_volume_changed" swapped="no"/>
|
<property name="sensitive">false</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="GtkBox" id="content_box">
|
<object class="GtkBox">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwToastOverlay" id="info_toast">
|
<object class="AdwToastOverlay" id="info_toast">
|
||||||
|
|
@ -55,7 +55,6 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwViewStack" id="panel_stack">
|
<object class="AdwViewStack" id="panel_stack">
|
||||||
<property name="vexpand">true</property>
|
<property name="vexpand">true</property>
|
||||||
<signal name="notify::visible-child" handler="on_stack_switched" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -70,9 +69,13 @@
|
||||||
</binding>
|
</binding>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkDrawingArea" id="resize_helper">
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</template>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<gresources>
|
|
||||||
<gresource prefix="/xyz/suruatoel/mcg">
|
|
||||||
<file>gtk.css</file>
|
|
||||||
<file>noise-texture.png</file>
|
|
||||||
<file>ui/window.ui</file>
|
|
||||||
<file>ui/shortcuts-dialog.ui</file>
|
|
||||||
<file>ui/connection-panel.ui</file>
|
|
||||||
<file>ui/album-headerbar.ui</file>
|
|
||||||
<file>ui/server-panel.ui</file>
|
|
||||||
<file>ui/cover-panel.ui</file>
|
|
||||||
<file>ui/playlist-panel.ui</file>
|
|
||||||
<file>ui/library-panel.ui</file>
|
|
||||||
</gresource>
|
|
||||||
</gresources>
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<schemalist>
|
|
||||||
<enum id="xyz.suruatoel.mcg.SortOrder">
|
|
||||||
<value nick="artist" value="0" />
|
|
||||||
<value nick="title" value="1" />
|
|
||||||
<value nick="year" value="2" />
|
|
||||||
<value nick="modified" value="3" />
|
|
||||||
</enum>
|
|
||||||
<schema path="/xyz/suruatoel/mcg/" id="xyz.suruatoel.mcg" gettext-domain="mcg">
|
|
||||||
<key type="s" name="host">
|
|
||||||
<default>'localhost'</default>
|
|
||||||
<summary>MPD host</summary>
|
|
||||||
<description>MPD host to connect to</description>
|
|
||||||
</key>
|
|
||||||
<key type="i" name="port">
|
|
||||||
<default>6600</default>
|
|
||||||
<summary>MPD port</summary>
|
|
||||||
<description>MPD port to connect to</description>
|
|
||||||
</key>
|
|
||||||
<key type="b" name="connected">
|
|
||||||
<default>false</default>
|
|
||||||
<summary>Connection state</summary>
|
|
||||||
<description>State of last connection</description>
|
|
||||||
</key>
|
|
||||||
<key type="i" name="width">
|
|
||||||
<default>800</default>
|
|
||||||
<summary>Window width</summary>
|
|
||||||
<description>The window width in pixels.</description>
|
|
||||||
</key>
|
|
||||||
<key type="i" name="height">
|
|
||||||
<default>600</default>
|
|
||||||
<summary>Window height</summary>
|
|
||||||
<description>The window height in pixels.</description>
|
|
||||||
</key>
|
|
||||||
<key type="b" name="is-maximized">
|
|
||||||
<default>false</default>
|
|
||||||
<summary>Window maximized</summary>
|
|
||||||
<description>Whether or not the window is in maximized state.</description>
|
|
||||||
</key>
|
|
||||||
<key type="i" name="panel">
|
|
||||||
<range min="0" max="3"/>
|
|
||||||
<default>1</default>
|
|
||||||
<summary>Last selected panel</summary>
|
|
||||||
<description>The index of the last selected panel.</description>
|
|
||||||
</key>
|
|
||||||
<key type="i" name="item-size">
|
|
||||||
<range min="100" max="1000" />
|
|
||||||
<default>150</default>
|
|
||||||
<summary>Size of library items</summary>
|
|
||||||
<description>The size of items displayed in the library.</description>
|
|
||||||
</key>
|
|
||||||
<key enum="xyz.suruatoel.mcg.SortOrder" name="sort-order">
|
|
||||||
<default>'year'</default>
|
|
||||||
<summary>Sort criterium for library items</summary>
|
|
||||||
<description>The sort criterium of items displayed in the library.</description>
|
|
||||||
</key>
|
|
||||||
<key type="b" name="sort-type">
|
|
||||||
<default>true</default>
|
|
||||||
<summary>Sort type for library items</summary>
|
|
||||||
<description>The sort type of items displayed in the library.</description>
|
|
||||||
</key>
|
|
||||||
</schema>
|
|
||||||
</schemalist>
|
|
||||||
|
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 7 KiB |
7
go.mod
7
go.mod
|
|
@ -3,3 +3,10 @@ module suruatoel.xyz/mcg
|
||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
toolchain go1.26.0
|
toolchain go1.26.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/diamondburned/gotk4-adwaita/pkg v0.0.0-20260808200908-d4aecaa0ff32
|
||||||
|
github.com/diamondburned/gotk4/pkg v0.4.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require golang.org/x/sync v0.22.0 // indirect
|
||||||
|
|
|
||||||
6
go.sum
6
go.sum
|
|
@ -0,0 +1,6 @@
|
||||||
|
github.com/diamondburned/gotk4-adwaita/pkg v0.0.0-20260808200908-d4aecaa0ff32 h1:1EATAO7ZRrY7B7lt6djCzGnLPlKXPzuOuwPzDSF7jT0=
|
||||||
|
github.com/diamondburned/gotk4-adwaita/pkg v0.0.0-20260808200908-d4aecaa0ff32/go.mod h1:ZzYiyPe0TqsukfPHi0sK/WwKzm0wIJdSRylLnuvAZNw=
|
||||||
|
github.com/diamondburned/gotk4/pkg v0.4.1 h1:w4BwVUUBkKyNLz5HKHN2Oz3kZCTLHfpfKgB/su1p6uo=
|
||||||
|
github.com/diamondburned/gotk4/pkg v0.4.1/go.mod h1:BAEEDXtj5srQ1S2++5HX2K1s9c6CtuWSa60dAywrkRM=
|
||||||
|
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||||
|
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
42
internal/gui/albumheaderbar.go
Normal file
42
internal/gui/albumheaderbar.go
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||||
|
"suruatoel.xyz/mcg/data"
|
||||||
|
"suruatoel.xyz/mcg/internal/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
type albumHeaderbar struct {
|
||||||
|
*adw.Bin
|
||||||
|
titleLabel *gtk.Label
|
||||||
|
artistLabel *gtk.Label
|
||||||
|
closeButton *gtk.Button
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAlbumHeaderbar() *albumHeaderbar {
|
||||||
|
bar := albumHeaderbar{}
|
||||||
|
bar.loadWidgets()
|
||||||
|
|
||||||
|
return &bar
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *albumHeaderbar) loadWidgets() {
|
||||||
|
builder := gtk.NewBuilderFromString(data.AlbumHeaderbarXML)
|
||||||
|
|
||||||
|
b.Bin = builder.GetObject("McgAlbumHeaderbar").Cast().(*adw.Bin)
|
||||||
|
b.titleLabel = builder.GetObject("standalone_title").Cast().(*gtk.Label)
|
||||||
|
b.artistLabel = builder.GetObject("standalone_artist").Cast().(*gtk.Label)
|
||||||
|
b.closeButton = builder.GetObject("close_button").Cast().(*gtk.Button)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *albumHeaderbar) SetAlbum(album *common.Album) {
|
||||||
|
b.titleLabel.SetText(album.Title())
|
||||||
|
b.artistLabel.SetText(strings.Join(album.Artists(), ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *albumHeaderbar) ConnectClose(callback func()) {
|
||||||
|
b.closeButton.ConnectClicked(callback)
|
||||||
|
}
|
||||||
151
internal/gui/application.go
Normal file
151
internal/gui/application.go
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gio/v2"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/glib/v2"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||||
|
"suruatoel.xyz/mcg/data"
|
||||||
|
"suruatoel.xyz/mcg/internal/client"
|
||||||
|
"suruatoel.xyz/mcg/internal/i18n"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Application struct {
|
||||||
|
*gtk.Application
|
||||||
|
window *mainWindow
|
||||||
|
aboutDialog *adw.AboutDialog
|
||||||
|
config Configuration
|
||||||
|
configErr error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApplication() *Application {
|
||||||
|
app := Application{
|
||||||
|
Application: gtk.NewApplication("xyz.suruatoel.mcg", gio.ApplicationFlagsNone),
|
||||||
|
}
|
||||||
|
app.ConnectStartup(app.onStartup)
|
||||||
|
app.ConnectActivate(app.onActivate)
|
||||||
|
app.ConnectShutdown(app.onShutdown)
|
||||||
|
|
||||||
|
return &app
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) onStartup() {
|
||||||
|
a.setDefaultSettings()
|
||||||
|
a.loadCSS()
|
||||||
|
a.registerShortcuts()
|
||||||
|
a.registerActions()
|
||||||
|
a.loadConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) loadConfig() {
|
||||||
|
a.config = Configuration{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 6600,
|
||||||
|
Panel: "library",
|
||||||
|
SortField: "year",
|
||||||
|
SortDesc: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
a.configErr = readConfig(&a.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) setDefaultSettings() {
|
||||||
|
styleManager := adw.StyleManagerGetDefault()
|
||||||
|
styleManager.SetColorScheme(adw.ColorSchemePreferDark)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) loadCSS() {
|
||||||
|
styleProvider := gtk.NewCSSProvider()
|
||||||
|
styleProvider.LoadFromString(data.MainCSS)
|
||||||
|
|
||||||
|
gtk.StyleContextAddProviderForDisplay(
|
||||||
|
gdk.DisplayGetDefault(),
|
||||||
|
styleProvider,
|
||||||
|
gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) registerShortcuts() {
|
||||||
|
a.SetAccelsForAction("window.close", []string{"<primary>q"})
|
||||||
|
a.SetAccelsForAction("win.show-help-overlay", []string{"<primary>k"})
|
||||||
|
a.SetAccelsForAction("app.info", []string{"<primary>i"})
|
||||||
|
a.SetAccelsForAction("win.connect", []string{"<primary>c"})
|
||||||
|
a.SetAccelsForAction("win.play", []string{"<primary>p"})
|
||||||
|
a.SetAccelsForAction("win.clear-playlist", []string{"<primary>r"})
|
||||||
|
a.SetAccelsForAction("win.toggle-fullscreen", []string{"F11"})
|
||||||
|
a.SetAccelsForAction("win.search-library", []string{"<primary>f"})
|
||||||
|
a.SetAccelsForAction("win.panel(\"server\")", []string{"<primary>KP_1"})
|
||||||
|
a.SetAccelsForAction("win.panel(\"cover\")", []string{"<primary>KP_2"})
|
||||||
|
a.SetAccelsForAction("win.panel(\"playlist\")", []string{"<primary>KP_3"})
|
||||||
|
a.SetAccelsForAction("win.panel(\"library\")", []string{"<primary>KP_4"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) registerActions() {
|
||||||
|
infoAction := gio.NewSimpleAction("info", nil)
|
||||||
|
infoAction.ConnectActivate(func(_ *glib.Variant) {
|
||||||
|
a.showAboutDialog()
|
||||||
|
})
|
||||||
|
a.AddAction(infoAction)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) showAboutDialog() {
|
||||||
|
if a.aboutDialog == nil {
|
||||||
|
a.aboutDialog = a.newAboutDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
a.aboutDialog.Present(a.window)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) newAboutDialog() *adw.AboutDialog {
|
||||||
|
dialog := adw.NewAboutDialog()
|
||||||
|
dialog.SetApplicationName("CoverGrid")
|
||||||
|
dialog.SetApplicationIcon("xyz.suruatoel.mcg")
|
||||||
|
dialog.SetVersion(a.Version())
|
||||||
|
dialog.SetComments(i18n.T("CoverGrid is a client for the Music Player Daemon, focusing on albums instead of single tracks."))
|
||||||
|
dialog.SetWebsite("https://www.suruatoel.xyz/codes/mcg")
|
||||||
|
dialog.SetLicenseType(gtk.LicenseGPL30)
|
||||||
|
dialog.SetIssueURL("https://git.suruatoel.xyz/coderkun/mcg")
|
||||||
|
|
||||||
|
return dialog
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) onActivate() {
|
||||||
|
if a.window == nil {
|
||||||
|
a.window = newMainWindow(a.Application, a.config)
|
||||||
|
if a.configErr != nil && !os.IsNotExist(a.configErr) {
|
||||||
|
a.window.SetConfigError(a.configErr)
|
||||||
|
}
|
||||||
|
a.window.ConnectCloseRequest(a.onCloseRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
a.window.Present()
|
||||||
|
if a.config.IsConnected {
|
||||||
|
client.Instance().Connect(a.config.Host, int(a.config.Port), a.config.Password)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) onCloseRequest() bool {
|
||||||
|
a.window.UpdateConfig(&a.config)
|
||||||
|
a.config.IsConnected = client.Instance().IsConnected()
|
||||||
|
|
||||||
|
a.saveConfig()
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) saveConfig() {
|
||||||
|
err := writeConfig(&a.config)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("failed to save configuration file:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Application) onShutdown() {
|
||||||
|
if client.Instance().IsConnected() {
|
||||||
|
client.Instance().Disconnect()
|
||||||
|
}
|
||||||
|
}
|
||||||
78
internal/gui/config.go
Normal file
78
internal/gui/config.go
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Configuration struct {
|
||||||
|
Host string `json:"host"`
|
||||||
|
Port uint64 `json:"port"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
IsConnected bool `json:"connected"`
|
||||||
|
Panel string `json:"panel"`
|
||||||
|
SortField string `json:"sortField"`
|
||||||
|
SortDesc bool `json:"sortDesc"`
|
||||||
|
ItemSize int `json:"itemSize"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func readConfig(config *Configuration) error {
|
||||||
|
filename, filenameErr := getConfigFile()
|
||||||
|
if filenameErr != nil {
|
||||||
|
return filenameErr
|
||||||
|
}
|
||||||
|
|
||||||
|
file, fileErr := os.Open(filename)
|
||||||
|
if fileErr != nil {
|
||||||
|
return fileErr
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
return json.NewDecoder(file).Decode(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeConfig(config *Configuration) error {
|
||||||
|
filename, filenameErr := getConfigFile()
|
||||||
|
if filenameErr != nil {
|
||||||
|
return filenameErr
|
||||||
|
}
|
||||||
|
|
||||||
|
file, fileErr := os.Create(filename)
|
||||||
|
if fileErr != nil {
|
||||||
|
return fileErr
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(file)
|
||||||
|
encoder.SetIndent("", "\t")
|
||||||
|
|
||||||
|
return encoder.Encode(&config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getConfigFile() (string, error) {
|
||||||
|
configDir, configDirErr := getConfigDir()
|
||||||
|
if configDirErr != nil {
|
||||||
|
return "", configDirErr
|
||||||
|
}
|
||||||
|
|
||||||
|
createErr := ensureConfigDirExists(configDir)
|
||||||
|
if createErr != nil {
|
||||||
|
return "", createErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return filepath.Join(configDir, "config.json"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureConfigDirExists(folder string) error {
|
||||||
|
return os.MkdirAll(folder, 0o750)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getConfigDir() (string, error) {
|
||||||
|
configDir, configDirErr := os.UserConfigDir()
|
||||||
|
if configDirErr != nil {
|
||||||
|
return "", configDirErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return filepath.Join(configDir, "mcg"), nil
|
||||||
|
}
|
||||||
58
internal/gui/connectionpanel.go
Normal file
58
internal/gui/connectionpanel.go
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
|
||||||
|
"github.com/diamondburned/gotk4/pkg/gtk/v4"
|
||||||
|
"suruatoel.xyz/mcg/data"
|
||||||
|
)
|
||||||
|
|
||||||
|
type connectionPanel struct {
|
||||||
|
*adw.Bin
|
||||||
|
|
||||||
|
hostEntry *adw.EntryRow
|
||||||
|
portSpinner *gtk.SpinButton
|
||||||
|
passwordEntry *adw.PasswordEntryRow
|
||||||
|
}
|
||||||
|
|
||||||
|
func newConnectionPanel(config Configuration) *connectionPanel {
|
||||||
|
panel := connectionPanel{}
|
||||||
|
panel.loadWidgets()
|
||||||
|
panel.loadDefaultValues(config)
|
||||||
|
panel.connectSignals()
|
||||||
|
|
||||||
|
return &panel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) loadWidgets() {
|
||||||
|
builder := gtk.NewBuilderFromString(data.ConnectionPanelXML)
|
||||||
|
|
||||||
|
p.Bin = builder.GetObject("McgConnectionPanel").Cast().(*adw.Bin)
|
||||||
|
p.hostEntry = builder.GetObject("host_row").Cast().(*adw.EntryRow)
|
||||||
|
p.portSpinner = builder.GetObject("port_spinner").Cast().(*gtk.SpinButton)
|
||||||
|
p.passwordEntry = builder.GetObject("password_row").Cast().(*adw.PasswordEntryRow)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) connectSignals() {
|
||||||
|
p.hostEntry.ConnectApply(p.callback)
|
||||||
|
p.portSpinner.ConnectValueChanged(p.callback)
|
||||||
|
p.passwordEntry.ConnectApply(p.callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) loadDefaultValues(config Configuration) {
|
||||||
|
p.hostEntry.SetText(config.Host)
|
||||||
|
p.portSpinner.SetValue(float64(config.Port))
|
||||||
|
p.passwordEntry.SetText(config.Password)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) UpdateConfig(config *Configuration) {
|
||||||
|
config.Host = p.hostEntry.Text()
|
||||||
|
config.Port = uint64(p.portSpinner.Value())
|
||||||
|
config.Password = p.passwordEntry.Text()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) callback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *connectionPanel) ConnectionDetails() (string, int, string) {
|
||||||
|
return p.hostEntry.Text(), p.portSpinner.ValueAsInt(), p.passwordEntry.Text()
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue