Skip to content

Commit

Permalink
Merge pull request #41 from redian23/master
Browse files Browse the repository at this point in the history
Add green theme
  • Loading branch information
Alain authored Sep 14, 2019
2 parents 70f5248 + 8f506b4 commit 0e61b23
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 65 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ You'll need the following dependencies:
* libtagc0-dev
* libsqlite3-dev
* libgranite-dev (>=0.5)
* libunity-dev
* meson
* valac >= 0.40.3

Expand Down
7 changes: 4 additions & 3 deletions data/com.github.alainm23.byte.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<enum id="com.github.alainm23.byte.repeat-mode">
<value nick="off" value="0" />
<value nick="all" value="1" />
<value nick="one" value="2" />
<value nick="one" value="2" />
</enum>

<enum id="com.github.alainm23.byte.tracks-sort-mode">
Expand Down Expand Up @@ -33,6 +33,7 @@
<value nick="Byte" value="1" />
<value nick="Black" value="2" />
<value nick="Blueberry" value="3" />
<value nick="Turquoise" value="4" />
</enum>

<schema path="/com/github/alainm23/byte/" id="com.github.alainm23.byte" gettext-domain="com.github.alainm23.byte">
Expand All @@ -41,7 +42,7 @@
<summary>Theme</summary>
<description>Theme</description>
</key>

<key name="library-location" type="s">
<default>""</default>
<summary>Default library location.</summary>
Expand Down Expand Up @@ -137,7 +138,7 @@
<summary>Show notifications.</summary>
<description>Show notifications.</description>
</key>

<key name="auto-download-covers" type="b">
<default>false</default>
<summary>Auto download covers</summary>
Expand Down
104 changes: 59 additions & 45 deletions src/Dialogs/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class Dialogs.Settings : Gtk.Dialog {

var settings_01_label = new Gtk.Label (_("Dark mode"));
//settings_01_label.get_style_context ().add_class ("h3");

var settings_01_switch = new Gtk.Switch ();
settings_01_switch.get_style_context ().add_class ("active-switch");
settings_01_switch.valign = Gtk.Align.CENTER;
var gtk_settings = Gtk.Settings.get_default ();

var gtk_settings = Gtk.Settings.get_default ();
settings_01_switch.bind_property ("active", gtk_settings, "gtk_application_prefer_dark_theme");
Byte.settings.bind ("dark-mode", settings_01_switch, "active", GLib.SettingsBindFlags.DEFAULT);

Expand All @@ -71,7 +71,7 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_02_icon.valign = Gtk.Align.CENTER;

var settings_02_label = new Gtk.Label (_("Notifications"));

var settings_02_switch = new Gtk.Switch ();
settings_02_switch.get_style_context ().add_class ("active-switch");
settings_02_switch.valign = Gtk.Align.CENTER;
Expand All @@ -95,12 +95,12 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_03_icon.valign = Gtk.Align.CENTER;

var settings_03_label = new Gtk.Label (_("Play in background if closed"));

var settings_03_switch = new Gtk.Switch ();
settings_03_switch.get_style_context ().add_class ("active-switch");
settings_03_switch.valign = Gtk.Align.CENTER;
settings_03_switch.active = Byte.settings.get_boolean ("play-in-background");

var settings_03_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
settings_03_box.hexpand = true;
settings_03_box.margin = 6;
Expand All @@ -119,7 +119,7 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_09_icon.valign = Gtk.Align.CENTER;

var settings_09_label = new Gtk.Label (_("Theme"));

var theme_01 = new Gtk.RadioButton (null);
theme_01.valign = Gtk.Align.START;
theme_01.halign = Gtk.Align.START;
Expand All @@ -138,23 +138,32 @@ public class Dialogs.Settings : Gtk.Dialog {
theme_03.tooltip_text = _("Blueberry");
apply_styles ("03", "#3689e6", theme_03);

var theme_04 = new Gtk.RadioButton.from_widget (theme_01);
theme_04.valign = Gtk.Align.START;
theme_04.halign = Gtk.Align.START;
theme_04.tooltip_text = _("Turquoise");
apply_styles ("04", "#36E683", theme_04);

var theme_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
theme_box.pack_start (theme_01, false, false, 6);
theme_box.pack_start (theme_02, false, false, 6);
theme_box.pack_start (theme_03, false, false, 6);
theme_box.pack_start (theme_04, false, false, 6);

int theme = Byte.settings.get_enum ("theme");

if (theme == 1) {
// I think switch most better here (redian23)
switch (Byte.settings.get_enum ("theme")) {
case 1 :
theme_01.active = true;
} else if (theme == 2) {
break;
case 2 :
theme_02.active = true;
} else {
break;
case 3 :
theme_03.active = true;
}

if (Byte.settings.get_boolean ("dark-mode")) {
theme_box.sensitive = false;
break;
case 4 :
theme_04.active = true;
break;
}

var settings_09_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
Expand Down Expand Up @@ -196,10 +205,10 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_04_icon.valign = Gtk.Align.CENTER;

var settings_04_label = new Gtk.Label (_("Music folder location"));

var library_filechooser = new Gtk.FileChooserButton (_("Select Music Folder…"), Gtk.FileChooserAction.SELECT_FOLDER);
library_filechooser.valign = Gtk.Align.CENTER;

File library_path = File.new_for_uri (Byte.settings.get_string ("library-location"));
library_filechooser.set_current_folder (library_path.get_path ());

Expand All @@ -211,7 +220,7 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_04_box.pack_end (library_filechooser, false, false, 0);

/*
Sync init
Sync init
*/

var settings_05_icon = new Gtk.Image ();
Expand All @@ -221,12 +230,12 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_05_icon.valign = Gtk.Align.CENTER;

var settings_05_label = new Gtk.Label (_("Sync library on start up"));

var settings_05_switch = new Gtk.Switch ();
settings_05_switch.get_style_context ().add_class ("active-switch");
settings_05_switch.valign = Gtk.Align.CENTER;
settings_05_switch.active = Byte.settings.get_boolean ("sync-files");

var settings_05_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
settings_05_box.hexpand = true;
settings_05_box.margin = 6;
Expand All @@ -237,20 +246,20 @@ public class Dialogs.Settings : Gtk.Dialog {
/*
Auto download cover
*/

var settings_06_icon = new Gtk.Image ();
settings_06_icon.gicon = new ThemedIcon ("folder-download-symbolic");
settings_06_icon.pixel_size = 16;
settings_06_icon.get_style_context ().add_class ("settings-icon");
settings_06_icon.valign = Gtk.Align.CENTER;

var settings_06_label = new Gtk.Label (_("Automatically download covers"));

var settings_06_switch = new Gtk.Switch ();
settings_06_switch.get_style_context ().add_class ("active-switch");
settings_06_switch.valign = Gtk.Align.CENTER;
settings_06_switch.active = Byte.settings.get_boolean ("auto-download-covers");

var settings_06_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
settings_06_box.hexpand = true;
settings_06_box.margin = 6;
Expand All @@ -269,12 +278,12 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_07_icon.valign = Gtk.Align.CENTER;

var settings_07_label = new Gtk.Label (_("Save changes into ID3-Tag"));

var settings_07_switch = new Gtk.Switch ();
settings_07_switch.get_style_context ().add_class ("active-switch");
settings_07_switch.valign = Gtk.Align.CENTER;
settings_07_switch.active = Byte.settings.get_boolean ("save-id3-tags");

var settings_07_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
settings_07_box.hexpand = true;
settings_07_box.margin = 6;
Expand Down Expand Up @@ -307,10 +316,10 @@ public class Dialogs.Settings : Gtk.Dialog {
settings_08_icon.valign = Gtk.Align.CENTER;

var settings_08_label = new Gtk.Label (_("Reset all library"));

var settings_08_button = new Gtk.Button.with_label (_("Reset"));
settings_08_button.valign = Gtk.Align.CENTER;

var settings_08_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
settings_08_box.hexpand = true;
settings_08_box.margin = 6;
Expand Down Expand Up @@ -345,11 +354,11 @@ public class Dialogs.Settings : Gtk.Dialog {
//add_button (_("Close"), Gtk.ResponseType.CLOSE);
/*
response.connect ((response_id) => {
destroy ();
destroy ();
});
*/

settings_01_switch.notify["active"].connect (() => {
settings_01_switch.notify["active"].connect (() => {
theme_box.sensitive = !settings_01_switch.active;

var provider = new Gtk.CssProvider ();
Expand Down Expand Up @@ -407,7 +416,7 @@ public class Dialogs.Settings : Gtk.Dialog {
var set_button = new Gtk.Button.with_label (_("Set Music Folder"));
set_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
message_dialog.add_action_widget (set_button, Gtk.ResponseType.ACCEPT);

message_dialog.show_all ();

if (message_dialog.run () == Gtk.ResponseType.ACCEPT) {
Expand All @@ -419,23 +428,23 @@ public class Dialogs.Settings : Gtk.Dialog {
});

settings_08_button.clicked.connect (() => {
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Reset your library?"),
_("Are you sure you want to reset all your library?"),
"dialog-warning",
Gtk.ButtonsType.CANCEL
);
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Reset your library?"),
_("Are you sure you want to reset all your library?"),
"dialog-warning",
Gtk.ButtonsType.CANCEL
);

var remove_button = new Gtk.Button.with_label (_("Reset"));
remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
message_dialog.add_action_widget (remove_button, Gtk.ResponseType.ACCEPT);
var remove_button = new Gtk.Button.with_label (_("Reset"));
remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
message_dialog.add_action_widget (remove_button, Gtk.ResponseType.ACCEPT);

message_dialog.show_all ();
message_dialog.show_all ();

if (message_dialog.run () == Gtk.ResponseType.ACCEPT) {
Byte.database.reset_all_library ();
destroy ();
}
if (message_dialog.run () == Gtk.ResponseType.ACCEPT) {
Byte.database.reset_all_library ();
destroy ();
}

message_dialog.destroy ();
});
Expand All @@ -454,6 +463,11 @@ public class Dialogs.Settings : Gtk.Dialog {
Byte.settings.set_enum ("theme", 3);
Byte.utils.apply_theme (3);
});

theme_04.toggled.connect (() => {
Byte.settings.set_enum ("theme", 4);
Byte.utils.apply_theme (4);
});
}

private void apply_styles (string id, string color, Gtk.RadioButton radio) {
Expand Down
Loading

0 comments on commit 0e61b23

Please sign in to comment.