Skip to content

Commit

Permalink
Schema install update
Browse files Browse the repository at this point in the history
Signed-off-by: technosf <[email protected]>
  • Loading branch information
technosf committed Oct 26, 2024
1 parent 2d8ce00 commit 8d72482
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 221 deletions.
1 change: 0 additions & 1 deletion com.github.louis77.tuner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ finish-args:
- "--share=ipc"
- "--socket=fallback-x11"
- "--socket=wayland"
- "--talk-name=org.gtk.vfs"
- "--talk-name=org.gtk.vfs.*"
- "--share=network"
- "--metadata=X-DConf=migrate-path=/com/github/louis77/tuner/"
Expand Down
23 changes: 6 additions & 17 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ icon_sizes = ['16', '24', '32', '48', '64', '128']
foreach i : icon_sizes
install_data (
join_paths ('icons', i, meson.project_name () + '.svg'),
install_dir: join_paths (get_option ('datadir'), 'icons/hicolor', i + 'x' + i, 'apps'),
install_dir: join_paths (get_option ('datadir'), 'icons','hicolor', i + 'x' + i, 'apps'),
install_tag: 'icons'
)
install_data (
join_paths ('icons', i, meson.project_name () + '.svg'),
install_dir: join_paths (get_option ('datadir'), 'icons/hicolor', i + 'x' + i + '@2', 'apps'),
install_dir: join_paths (get_option ('datadir'), 'icons','hicolor', i + 'x' + i + '@2', 'apps'),
install_tag: 'icons'
)
endforeach

meson.add_install_script('gtk-update-icon-cache', join_paths('datadir', 'icons/hicolor'), install_tag: 'icons')

message('Installed icons\n')

Expand Down Expand Up @@ -70,23 +69,13 @@ message('Installed appdata\n')
#
message('Installing schema...')

#gsettings_schema_build_dir = join_paths(meson.current_build_dir(), 'schemas')
schemas_dir = join_paths (get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')

#message('to ' + gsettings_schema_build_dir)
#gnome.compile_schemas(gsettings_schema_build_dir)
settings_schemas = [ meson.project_name() + '.gschema.xml' ]

gsettings_schema_dir = join_paths(get_option ('datadir'), 'glib-2.0', 'schemas')
gschema = files(meson.project_name () +'.gschema.xml')
install_data(settings_schemas, install_dir: schemas_dir)

message('to ' + gsettings_schema_dir)

install_data(
gschema,
install_dir: gsettings_schema_dir,
install_tag: 'schemas'
)

meson.add_install_script('glib-compile-schemas', gsettings_schema_dir, install_tag: 'schemas')
meson.add_install_script('glib-compile-schemas', schemas_dir, install_tag: 'schemas')


message('Installed schema\n')
4 changes: 3 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
project (
'com.github.louis77.tuner',
'vala', 'c',
version: '1.5.5'
version: '1.5.5',
meson_version: '>= 0.60.0',
)

message('Starting build for project: ' + meson.project_name())
Expand Down Expand Up @@ -69,6 +70,7 @@ executable (
)

subdir ('data')

subdir ('po')

message('Build for project: ' + meson.project_name() + ' finished.\n')
2 changes: 2 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public class Tuner.Application : Gtk.Application {
GLib.Intl.textdomain (GETTEXT_PACKAGE);

settings = new GLib.Settings (this.application_id);
warning(@"Settings path: $(settings.path)");

player = new PlayerController ();

cache_dir = Path.build_filename (Environment.get_user_cache_dir (), application_id);
Expand Down
136 changes: 34 additions & 102 deletions src/Widgets/PreferencesPopover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]>
*/

/**
* @class PreferencesPopover
* @brief A popover widget for displaying and managing application preferences.
*
* This class extends Gtk.Popover and provides a user interface for various
* application settings such as theme selection, autoplay, and tracking options.
*/
public class Tuner.PreferencesPopover : Gtk.Popover {

/**
* @brief Constructs the PreferencesPopover widget.
*
* This method sets up the layout and adds various preference options
* to the popover menu.
*/
construct {
var about_menuitem = new Gtk.ModelButton ();
about_menuitem.text = _("About");
about_menuitem.action_name = Window.ACTION_PREFIX + Window.ACTION_ABOUT;

var disable_tracking_item = new Gtk.ModelButton ();
disable_tracking_item.text = _("Do not track");
disable_tracking_item.action_name = Window.ACTION_PREFIX + Window.ACTION_DISABLE_TRACKING;
disable_tracking_item.tooltip_text = _("If enabled, we will not send usage info to radio-browser.org");

var theme_combo = new Gtk.ComboBoxText ();
theme_combo.append("system", _("Use System"));
theme_combo.append("light", _("Light mode"));
theme_combo.append("dark", _("Dark mode"));
theme_combo.halign = Gtk.Align.CENTER;
theme_combo.active_id = Application.instance.settings.get_string("theme-mode");

theme_combo.changed.connect ((elem) => {
warning(@"Theme changed: $(elem.active_id)");
Application.instance.settings.set_string("theme-mode", elem.active_id);
});

var theme_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
theme_box.pack_end (theme_combo, true, true, 5);
theme_box.pack_end (new Gtk.Label(_("Theme")), false, false, 12);

var autoplay_item = new Gtk.ModelButton ();
autoplay_item.text = _("Auto-play last station");
autoplay_item.action_name = Window.ACTION_PREFIX + Window.ACTION_ENABLE_AUTOPLAY;
autoplay_item.tooltip_text = _("If enabled, when Tuner starts it will automatically start to play the last played station");

var menu_grid = new Gtk.Grid ();
menu_grid.margin_bottom = 10;
Expand All @@ -27,101 +43,17 @@ public class Tuner.PreferencesPopover : Gtk.Popover {
menu_grid.margin_end = 5;
menu_grid.row_spacing = 3;
menu_grid.orientation = Gtk.Orientation.VERTICAL;
menu_grid.attach (prefer_dark_theme(), 0, 0);
menu_grid.attach (theme_box, 0, 0);
menu_grid.attach (new Gtk.SeparatorMenuItem (), 0, 1, 3, 1);
menu_grid.attach (autoplay_item(), 0, 2, 3, 1);
menu_grid.attach (disable_tracking_item(), 0, 3, 3, 1);
menu_grid.attach (autoplay_item, 0, 2, 3, 1);
menu_grid.attach (disable_tracking_item, 0, 3, 3, 1);
menu_grid.attach (new Gtk.SeparatorMenuItem (), 0, 4, 3, 1);
menu_grid.attach (about_menuitem(), 0, 5, 3, 1);
menu_grid.attach (about_menuitem, 0, 5, 3, 1);
menu_grid.show_all ();

this.add (menu_grid);
}


/**
* @brief Creates and returns a Gtk.ModelButton for the "About" menu item.
*
* @return Gtk.ModelButton The configured "About" menu item.
*/
private static Gtk.ModelButton about_menuitem ()
{
var about_menuitem = new Gtk.ModelButton ();
about_menuitem.text = _("About");
about_menuitem.action_name = Window.ACTION_PREFIX + Window.ACTION_ABOUT;
return about_menuitem;
}

/**
* @brief Creates and returns a Gtk.ModelButton for the "Do not track" option.
*
* @return Gtk.ModelButton The configured "Do not track" menu item.
*/
private static Gtk.ModelButton disable_tracking_item ()
{
var disable_tracking_item = new Gtk.ModelButton ();
disable_tracking_item.text = _("Do not track");
disable_tracking_item.action_name = Window.ACTION_PREFIX + Window.ACTION_DISABLE_TRACKING;
disable_tracking_item.tooltip_text = _("If enabled, we will not send usage info to radio-browser.org");

return disable_tracking_item;
}

/**
* @brief Creates and returns a Gtk.ModelButton for the "Auto-play last station" option.
*
* @return Gtk.ModelButton The configured "Auto-play last station" menu item.
*/
private static Gtk.ModelButton autoplay_item ()
{
var autoplay_item = new Gtk.ModelButton ();
autoplay_item.text = _("Auto-play last station");
autoplay_item.action_name = Window.ACTION_PREFIX + Window.ACTION_ENABLE_AUTOPLAY;
autoplay_item.tooltip_text = _("If enabled, when Tuner starts it will automatically start to play the last played station");
return autoplay_item;
}

/**
* @brief Creates and returns a Gtk.ModelButton for the "Prefer dark theme" option.
*
* @return Gtk.ModelButton The configured "Prefer dark theme" menu item.
*/
private static Gtk.ModelButton prefer_dark_theme ()
{
var prefer_dark_theme = new Gtk.ModelButton ();
prefer_dark_theme.text = _("Prefer dark theme");
prefer_dark_theme.action_name = Window.ACTION_PREFIX + Window.ACTION_PREFER_DARK_MODE;
prefer_dark_theme.tooltip_text = _("If enabled, when Tuner starts it will use the dark theme");
return prefer_dark_theme;
}

/**
* @brief Creates and returns a Gtk.Box containing the theme selection combo box.
*
* This method sets up a combo box for selecting the application theme
* (System, Light, or Dark) and handles theme change events.
*
* @return Gtk.Box A box containing the theme selection combo box and label.
*/
// private static Gtk.Box theme_box ()
// {
// var theme_combo = new Gtk.ComboBoxText ();
// theme_combo.halign = Gtk.Align.CENTER;

// theme_combo.append(Application.Theme.SYSTEM.to_string(), _("Use System"));
// theme_combo.append(Application.Theme.LIGHT.to_string(), _("Light mode"));
// theme_combo.append(Application.Theme.DARK.to_string(), _("Dark mode"));
// theme_combo.active_id = Application.instance.theme.to_string();

// theme_combo.changed.connect ((elem) => {
// warning(@"Theme changed: $(elem.active_id)");
// Application.instance.theme = Application.theme_from_string(elem.active_id);
// });

// var theme_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
// theme_box.pack_end (theme_combo, true, true, 5);
// theme_box.pack_end (new Gtk.Label(_("Theme")), false, false, 12);
// return theme_box;
// }

}
}
2 changes: 1 addition & 1 deletion src/Widgets/Theme.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Theme : Gtk.Widget
return _instance.once (() => { return new Theme (); });
}

public bool is_theme_dark()
public bool delet_is_theme_dark()
{
var settings = Gtk.Settings.get_default();
var theme = Environment.get_variable("GTK_THEME");
Expand Down
Loading

0 comments on commit 8d72482

Please sign in to comment.