Skip to content

Commit

Permalink
feat: use Adw.ButtonRow instead of pill buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Rirusha committed Aug 11, 2024
1 parent 53778fe commit b07742a
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 59 deletions.
2 changes: 1 addition & 1 deletion data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ frame {
background-color: rgba(0, 0, 0, 0);
}

.plus-background {
.plus-button {
color: white;
background-image: linear-gradient(90deg,#ff5c4d,#eb469f 30%,#8341ef 75%,#3f68f9);
}
Expand Down
40 changes: 15 additions & 25 deletions data/ui/account-info-dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ template $CassetteAccountInfoDialog: Adw.Dialog {
margin-bottom: 12;
margin-start: 12;
margin-end: 12;
maximum-size: 450;
maximum-size: 360;

Box {
spacing: 24;
spacing: 12;
orientation: vertical;

Adw.Avatar avatar {}
Expand All @@ -39,45 +39,35 @@ template $CassetteAccountInfoDialog: Adw.Dialog {
wrap: true;
}

Box {
orientation: vertical;
halign: center;
spacing: 8;
ListBox {
styles [
"boxed-list-separate"
]

Button user_button {
styles [
"pill"
]
margin-top: 12;
selection-mode: none;

Adw.ButtonRow user_button {
action-name: "app.open-account";
label: _("Open in browser");
hexpand: true;
can-shrink: true;
title: _("Open in browser");
}

Button plus_button {
Adw.ButtonRow plus_button {
styles [
"pill",
"plus-background"
"plus-button"
]

action-name: "app.open-plus";
label: _("Plus");
hexpand: true;
can-shrink: true;
title: _("Plus");
}

Button logout_button {
Adw.ButtonRow logout_button {
styles [
"pill",
"destructive-action"
]

margin-top: 24;
action-name: "app.log-out";
label: _("Log out");
hexpand: true;
can-shrink: true;
title: _("Log out");
}
}
}
Expand Down
85 changes: 52 additions & 33 deletions data/ui/no-plus-dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,56 @@ using Gtk 4.0;
using Adw 1;

template $CassetteNoPlusDialog: Adw.Dialog {
width-request: 360;
content-width: 360;

Adw.ToolbarView {
top-bar-style: flat;

[top]
Adw.HeaderBar {}

content: Adw.StatusPage {
margin-top: 24;
margin-bottom: 12;
margin-start: 12;
margin-end: 12;
icon-name: "dialog-warning-symbolic";
title: _("No Plus Subscription");
description: _("To avoid problems with Yandex, the online functions of the application are not available without a Yandex.Plus subscription. Thanks for understanding.");

Button logout_button {
styles [
"pill",
"destructive-action"
]

visible: bind template.log-out-button-visible;
margin-top: 24;
action-name: "app.log-out";
label: _("Log out");
hexpand: true;
can-shrink: true;
}
};
}
width-request: 360;
content-width: 360;

Adw.ToolbarView {
top-bar-style: flat;

[top]
Adw.HeaderBar {}

content: Box {
orientation: vertical;

Adw.StatusPage {
vexpand: true;
icon-name: "dialog-warning-symbolic";
title: _("No Plus Subscription");
description: _("To avoid problems with Yandex, the online functions of the application are not available without a Yandex.Plus subscription. Thanks for understanding.");
}

ListBox {
styles [
"boxed-list-separate"
]

margin-top: 12;
margin-bottom: 12;
margin-start: 12;
margin-end: 12;
selection-mode: none;

Adw.ButtonRow get_plus_button {
styles [
"plus-button",
]

action-name: "app.get-plus";
title: _("Get Plus");
hexpand: true;
}

Adw.ButtonRow logout_button {
styles [
"destructive-action"
]

action-name: "app.log-out";
title: _("Log out");
hexpand: true;
}
}
};
}
}
10 changes: 10 additions & 0 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace Cassette {
{ "parse-url", on_parse_url_action },
{ "open-account", on_open_account_action },
{ "open-plus", on_open_plus_action },
{ "get-plus", on_get_plus_action },
{ "mute", on_mute_action },
};

Expand Down Expand Up @@ -454,6 +455,15 @@ namespace Cassette {
}
}

void on_get_plus_action () {
try {
Process.spawn_command_line_async ("xdg-open https://plus.yandex.ru/getplus");

} catch (SpawnError e) {
Logger.warning (_("Error while opening uri: %s").printf (e.message));
}
}

void on_mute_action () {
player.mute = !player.mute;
}
Expand Down

0 comments on commit b07742a

Please sign in to comment.