Skip to content

Commit

Permalink
fixing bs
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Jan 9, 2023
1 parent 166809e commit 4f177de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions demo/data/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ template DemoMainWindow : He.ApplicationWindow {
Stack view_stack {
StackPage {
title: "Mono View";
icon-name: "list-add-symbolic";
icon-name: "clock-symbolic";

child: He.EmptyPage {
title: "Empty Page";
Expand All @@ -331,7 +331,7 @@ template DemoMainWindow : He.ApplicationWindow {
}
StackPage {
title: "Dual View";
icon-name: "list-add-symbolic";
icon-name: "timer-symbolic";

child: He.ViewDual {
[left]
Expand Down Expand Up @@ -381,7 +381,7 @@ template DemoMainWindow : He.ApplicationWindow {
}
StackPage {
title: "Aux View";
icon-name: "list-add-symbolic";
icon-name: "stopwatch-symbolic";

child: He.ViewAux {
show-aux: true;
Expand Down
24 changes: 17 additions & 7 deletions lib/Widgets/NavigationRail.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
public class He.NavigationRail : He.Bin {
private Gtk.SelectionModel _stack_pages;
private List<Gtk.ToggleButton> _buttons;
private Gtk.Image button_child_image;

private Gtk.Stack _stack;
/**
Expand Down Expand Up @@ -78,6 +77,7 @@
construct {
this.add_css_class ("navigation-rail");
this.valign = Gtk.Align.CENTER;
this.orientation = Gtk.Orientation.VERTICAL;
}

private void on_stack_pages_changed (uint position, uint removed, uint added) {
Expand All @@ -100,7 +100,8 @@
};
button.add_css_class ("navigation-rail-button");

button_child_image = new Gtk.Image ();
var button_child_image = new Gtk.Image ();
this._stack_pages.get_item (position).bind_property ("icon_name", button_child_image, "icon_name", SYNC_CREATE);

var button_child_label = new Gtk.Label ("");
this._stack_pages.get_item (position).bind_property ("title", button_child_label, "label", SYNC_CREATE);
Expand All @@ -117,6 +118,14 @@
button.set_group ((Gtk.ToggleButton) this._buttons.nth_data (0));
}

if (button.active) {
if (((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name.contains ("-symbolic")) {
((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name = ((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name.replace ("-symbolic","-filled-symbolic");
} else {
((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name = ((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name + "-filled-symbolic";
}
}

this._buttons.insert_before (button_link, button);

position++;
Expand All @@ -141,14 +150,15 @@
unowned int position = this._buttons.index (button);
if (button.active) {
this._stack_pages.select_item (position, true);
if (button_child_image.icon_name.contains ("-symbolic")) {
button_child_image.icon_name = this._stack_pages.get_item (position).icon_name.replace ("-symbolic","-filled-symbolic");
if (((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name.contains ("-symbolic")) {
((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name = ((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name.replace ("-symbolic","-filled-symbolic");
} else {
button_child_image.icon_name = this._stack_pages.get_item (position).icon_name + "-filled-symbolic";
((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name = ((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name + "-filled-symbolic";
}
return;
} else {
button_child_image.icon_name = this._stack_pages.get_item (position).icon_name;
}
if (!(button.active)) {
((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name = ((Gtk.StackPage)this._stack_pages.get_item (position)).icon_name.replace ("-filled","");
return;
}

Expand Down

0 comments on commit 4f177de

Please sign in to comment.