Skip to content

Commit

Permalink
navigationrail: set filled symbolic on active, add orientation prop
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce authored Jan 9, 2023
1 parent b2af81d commit 9438427
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/Widgets/NavigationRail.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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 @@ -50,6 +51,22 @@
}
}

private Gtk.Orientation _orientation;
/**
* The orientation of this switcher.
*
* @since 1.0
*/
public Gtk.Orientation orientation {
get { return this._orientation; }
set {
if (this._orientation == value) return;

this._orientation = value;
((Gtk.BoxLayout)this.get_layout_manager ()).orientation = value;
}
}

public NavigationRail () {
base ();
}
Expand All @@ -61,7 +78,6 @@
construct {
this.add_css_class ("navigation-rail");
this.valign = Gtk.Align.CENTER;
((Gtk.BoxLayout)this.get_layout_manager ()).orientation = Gtk.Orientation.VERTICAL;
}

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

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

var button_child_label = new Gtk.Label ("");
this._stack_pages.get_item (position).bind_property ("title", button_child_label, "label", SYNC_CREATE);
Expand Down Expand Up @@ -126,7 +141,10 @@
unowned int position = this._buttons.index (button);
if (button.active) {
this._stack_pages.select_item (position, true);
button_child_image.icon_name = this._stack_pages.get_item (position).icon_name + "-filled";
return;
} else {
button_child_image.icon_name = this._stack_pages.get_item (position).icon_name;
}

this._stack_pages.unselect_item (position);
Expand Down

0 comments on commit 9438427

Please sign in to comment.