Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo: use Granite styles #703

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions demo/GraniteDemo.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ public class Granite.Demo : Gtk.Application {
}

public override void startup () {
Granite.init ();
base.startup ();

Granite.init ();

var gtk_settings = Gtk.Settings.get_default ();
gtk_settings.gtk_theme_name = "Granite";

var granite_settings = Granite.Settings.get_default ();
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK;

granite_settings.notify["prefers-color-scheme"].connect (() => {
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK;
});
}

public override void activate () {
Expand Down Expand Up @@ -96,9 +107,6 @@ public class Granite.Demo : Gtk.Application {
shrink_start_child = false
};

var granite_settings = Granite.Settings.get_default ();
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK;

window.child = paned;
window.set_default_size (900, 600);
window.set_size_request (750, 500);
Expand All @@ -107,10 +115,6 @@ public class Granite.Demo : Gtk.Application {

add_window (window);
window.show ();

granite_settings.notify["prefers-color-scheme"].connect (() => {
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK;
});
}

public static int main (string[] args) {
Expand Down
15 changes: 10 additions & 5 deletions demo/Views/CSSView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@ public class CSSView : Gtk.Box {
card.append (header4);

var richlist_label = new Granite.HeaderLabel ("Lists") {
secondary_text = "\"rich-list\" and \"frame\" style classes"
secondary_text = "\"rich-list\" and \"card\" style classes"
};

var rich_listbox = new Gtk.ListBox () {
show_separators = true
var separators_modelbutton = new Granite.SwitchModelButton ("Show Separators") {
active = true,
description = "SwitchModelButton works great here too!"
};

var rich_listbox = new Gtk.ListBox ();
rich_listbox.add_css_class (Granite.STYLE_CLASS_RICH_LIST);
rich_listbox.add_css_class (Granite.STYLE_CLASS_FRAME);
rich_listbox.add_css_class (Granite.STYLE_CLASS_CARD);
rich_listbox.append (new Gtk.Label ("Row 1"));
rich_listbox.append (new Gtk.Label ("Row 2"));
rich_listbox.append (new Gtk.Label ("Row 3"));
rich_listbox.append (separators_modelbutton);

separators_modelbutton.bind_property ("active", rich_listbox, "show-separators", SYNC_CREATE | DEFAULT);

var terminal_label = new Granite.HeaderLabel ("\"terminal\" style class");

Expand Down
1 change: 1 addition & 0 deletions lib/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Granite {
* Style class for numbered badges
*/
public const string STYLE_CLASS_BADGE = "badge";

/**
* Style class for adding a small shadow to a container such as for image thumbnails
*
Expand Down
4 changes: 2 additions & 2 deletions lib/Icons/icons.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<file alias="scalable/status/adw-tab-icon-missing-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/adw-tab-icon-missing-symbolic.svg</file>
<file alias="scalable/status/adw-tab-overflow-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/adw-tab-overflow-symbolic.svg</file>

<file alias="scalable/status/check-active-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/check-active-symbolic.svg</file>
<file alias="scalable/status/check-mixed-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/check-mixed-symbolic.svg</file>
<file alias="scalable/status/check-checked-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/check-checked.svg</file>
<file alias="scalable/status/check-indeterminated-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/check-indeterminate.svg</file>

<file alias="scalable/status/pager-checked-symbolic.svg" compressed="true" preprocess="xml-stripblanks">scalable/pager-checked-symbolic.svg</file>

Expand Down
31 changes: 0 additions & 31 deletions lib/Icons/scalable/check-active-symbolic.svg

This file was deleted.

30 changes: 30 additions & 0 deletions lib/Icons/scalable/check-checked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions lib/Icons/scalable/check-indeterminate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 0 additions & 36 deletions lib/Icons/scalable/check-mixed-symbolic.svg

This file was deleted.

1 change: 1 addition & 0 deletions lib/Styles/Granite/Index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '_card.scss';
@import '_sidebar.scss';
@import 'Dialog.scss';
@import 'Header.scss';
@import 'MessageDialog.scss';
Expand Down
2 changes: 1 addition & 1 deletion lib/Styles/Granite/OverlayBar.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overlaybar .osd {
padding: rem(6px) rem(12px);
padding: $button-spacing rem(12px);
text-shadow: 0 rem(1px) rem(2px) rgba($fg_color, 0.6);

spinner {
Expand Down
12 changes: 12 additions & 0 deletions lib/Styles/Granite/_sidebar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.sidebar {
background-color: bg_color(3);
box-shadow: highlight();
min-width: rem(200px);

// Clear nested sidebar
.sidebar {
background: transparent;
box-shadow: none;
min-width: 0;
}
}
21 changes: 21 additions & 0 deletions lib/Styles/Gtk/Arrow.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
arrow {
-gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
min-height: rem(16px);
min-width: rem(16px);

&.down {
-gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
}

&.left {
-gtk-icon-source: -gtk-icontheme("pan-start-symbolic");
}

&.right {
-gtk-icon-source: -gtk-icontheme("pan-end-symbolic");
}

&.up {
-gtk-icon-source: -gtk-icontheme("pan-up-symbolic");
}
}
40 changes: 40 additions & 0 deletions lib/Styles/Gtk/CheckRadio.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
check,
radio {
background-color: scale-color($toplevel-border-color, $alpha: -50%); // FIXME: abstract as trough color?
-gtk-icon-size: 1em;
min-height: 1em;
min-width: 1em;
padding: 1px;

&:checked {
background-color: $BLUEBERRY_500; // FIXME: use accent color
color: white;
-gtk-icon-source: -gtk-icontheme("check-checked-symbolic");
}

&:indeterminate {
color: rgba($fg-color, 0.5);
-gtk-icon-source: -gtk-icontheme("check-indeterminate-symbolic");
}
}

check {
border-radius: rem($window_radius / 3);

&:checked {
-gtk-icon-source: -gtk-icontheme("check-checked-symbolic");
}
}

radio {
border-radius: 50%;

&:checked {
-gtk-icon-source: -gtk-icontheme("pager-checked-symbolic");
}
}

radiobutton,
checkbutton {
border-spacing: 0.5em; // FIXME: abstract button spacing?
}
2 changes: 1 addition & 1 deletion lib/Styles/Gtk/HeaderBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ headerbar {
}

.csd & {
padding: rem(6px);
padding: $button-spacing;
}
}
3 changes: 3 additions & 0 deletions lib/Styles/Gtk/Index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@import 'Arrow.scss';
@import 'Button.scss';
@import 'CheckRadio.scss';
@import 'HeaderBar.scss';
@import 'Image.scss';
@import 'List.scss';
@import 'Popover.scss';
@import 'Scrollbar.scss';
@import 'ShortcutsWindow.scss';
Expand Down
40 changes: 40 additions & 0 deletions lib/Styles/Gtk/List.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
list {
&.rich-list > row {
padding: rem(6px);
min-height: rem(32px); //Try to force homogeneous row height
}

&.card,
&.boxed-list {
@extend .rounded;

> row {
// Rounded top
&:first-child {
&, &.expander row.header {
border-top-left-radius: rem($window_radius / 2);
border-top-right-radius: rem($window_radius / 2);
}
}

// Rounded bottom
&:last-child {
&,
&.expander:not(:checked),
&.expander:not(:checked) row.header,
&.expander:checked list.nested,
&.expander:checked list.nested > row:last-child {
border-bottom-left-radius: rem($window_radius / 2);
border-bottom-right-radius: rem($window_radius / 2);
border-bottom-width: 0;
}
}
}
}


&.separators > row + row {
border-top: 1px solid $border-color;
box-shadow: inset 0 1px 0 0 scale-color($highlight_color, $alpha: -93%);
}
}
Loading