-
-
Notifications
You must be signed in to change notification settings - Fork 90
library: add Carousel entry #326
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
93574e4
library: add carousel entry
ce6bccb
make carousel functional
halfmexican c0096b8
add main.vala
halfmexican 4212593
fix horizontal orientation
halfmexican e9905eb
fix alignment on prefsrow
halfmexican 089246a
main.vala: fix formatting
halfmexican 59b21d4
Apply suggestions from code review
halfmexican 655f288
main.blp: fix spacing
halfmexican 790b75c
remove quotes
halfmexican File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| using Gtk 4.0; | ||
| using Adw 1; | ||
|
|
||
| Box root_box { | ||
| orientation: vertical; | ||
| valign: center; | ||
| halign: center; | ||
| spacing: 12; | ||
|
|
||
| Adw.Carousel carousel { | ||
| halign: center; | ||
| valign: center; | ||
| allow-long-swipes: true; | ||
| allow-scroll-wheel: true; | ||
| spacing: 12; | ||
|
|
||
| Adw.StatusPage { | ||
| title: _("Carousel"); | ||
| description: _("Swipe or Scroll to Navigate"); | ||
| icon-name: "carousel-symbolic"; | ||
|
|
||
| LinkButton { | ||
| label: "API Reference"; | ||
| uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.Carousel.html"; | ||
| margin-top: 12; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Adw.Clamp { | ||
| maximum-size: 700; | ||
| halign: center; | ||
| valign: center; | ||
|
|
||
| Adw.PreferencesGroup { | ||
| styles ["boxed-list"] | ||
|
|
||
| Adw.ComboRow orientation_row { | ||
| title: _("Carousel Orientation"); | ||
| model: StringList { | ||
| strings [_("Horizontal"), _("Vertical")] | ||
| }; | ||
| } | ||
|
|
||
| Adw.ComboRow indicator_row { | ||
| title: _("Page Indicators"); | ||
| model: StringList { | ||
| strings [_("Dots"), _("Lines")] | ||
| }; | ||
| } | ||
|
|
||
| Adw.ActionRow { | ||
| title: _("Scroll Wheel"); | ||
| activatable-widget: sw_switch; | ||
|
|
||
| Gtk.Switch sw_switch { | ||
| valign: center; | ||
| } | ||
| } | ||
|
|
||
| Adw.ActionRow { | ||
| title: _("Long Swipes"); | ||
| activatable-widget: ls_switch; | ||
|
|
||
| Gtk.Switch ls_switch { | ||
| valign: center; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Adw.StatusPage { | ||
| title: _("Last Page"); | ||
| description: _("You've reached the end of the carousel."); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import Gtk from "gi://Gtk"; | ||
| import Adw from "gi://Adw"; | ||
|
|
||
| const root_box = workbench.builder.get_object("root_box"); | ||
| const carousel = workbench.builder.get_object("carousel"); | ||
| const ls_switch = workbench.builder.get_object("ls_switch"); | ||
| const sw_switch = workbench.builder.get_object("sw_switch"); | ||
| const indicator_row = workbench.builder.get_object("indicator_row"); | ||
| const orientation_row = workbench.builder.get_object("orientation_row"); | ||
| let indicators; | ||
|
|
||
| carousel.connect("page-changed", () => { | ||
| console.log("Page Changed"); | ||
| }); | ||
|
|
||
| // Scroll Wheel Switch | ||
| sw_switch.active = carousel.allow_scroll_wheel; | ||
|
|
||
| sw_switch.connect("notify::active", () => { | ||
| carousel.allow_scroll_wheel = sw_switch.active; | ||
| }); | ||
|
|
||
| // Long Swipe Switch | ||
| ls_switch.active = carousel.allow_long_swipes; | ||
|
|
||
| ls_switch.connect("notify::active", () => { | ||
| carousel.allow_long_swipes = ls_switch.active; | ||
| }); | ||
|
|
||
| if (indicator_row.get_selected() === 0) { | ||
| indicators = new Adw.CarouselIndicatorDots({ carousel: carousel }); | ||
| } else { | ||
| indicators = new Adw.CarouselIndicatorLines({ carousel: carousel }); | ||
| } | ||
|
|
||
| indicators.orientation = carousel.orientation; | ||
| root_box.append(indicators); | ||
|
|
||
| indicator_row.connect("notify::selected-item", () => { | ||
| root_box.remove(indicators); | ||
|
|
||
| if (indicator_row.get_selected() === 0) { | ||
| indicators = new Adw.CarouselIndicatorDots({ carousel: carousel }); | ||
| } else { | ||
| indicators = new Adw.CarouselIndicatorLines({ carousel: carousel }); | ||
| } | ||
|
|
||
| indicators.orientation = carousel.orientation; | ||
| root_box.append(indicators); | ||
| }); | ||
|
|
||
| orientation_row.connect("notify::selected-item", () => { | ||
| if (orientation_row.get_selected() === 0) { | ||
| root_box.orientation = Gtk.Orientation.VERTICAL; | ||
| carousel.orientation = Gtk.Orientation.HORIZONTAL; | ||
| indicators.orientation = Gtk.Orientation.HORIZONTAL; | ||
| } else { | ||
| root_box.orientation = Gtk.Orientation.HORIZONTAL; | ||
| carousel.orientation = Gtk.Orientation.VERTICAL; | ||
| indicators.orientation = Gtk.Orientation.VERTICAL; | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "Carousel", | ||
| "category": "user_interface", | ||
| "description": "A paginated scrolling widget", | ||
| "panels": ["code", "ui", "preview"], | ||
| "autorun": false | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 | ||
|
|
||
| public void main() { | ||
| var root_box = workbench.builder.get_object("root_box") as Gtk.Box; | ||
| var carousel = workbench.builder.get_object("carousel") as Adw.Carousel; | ||
| var ls_switch = workbench.builder.get_object("ls_switch") as Gtk.Switch; | ||
| var sw_switch = workbench.builder.get_object("sw_switch") as Gtk.Switch; | ||
| var indicator_row = workbench.builder.get_object("indicator_row") as Adw.ComboRow; | ||
| var orientation_row = workbench.builder.get_object("orientation_row") as Adw.ComboRow; | ||
| Adw.CarouselIndicatorDots? dots = null; | ||
| Adw.CarouselIndicatorLines? lines = null; | ||
|
|
||
| carousel.page_changed.connect(() => { | ||
| debug("Page Changed"); | ||
| }); | ||
|
|
||
| // Scroll Wheel Switch | ||
| sw_switch.active = carousel.allow_scroll_wheel; | ||
| sw_switch.notify["active"].connect(() => { | ||
| carousel.allow_scroll_wheel = sw_switch.active; | ||
| }); | ||
|
|
||
| // Long Swipe Switch | ||
| ls_switch.active = carousel.allow_long_swipes; | ||
| ls_switch.notify["active"].connect(() => { | ||
| carousel.allow_long_swipes = ls_switch.active; | ||
| }); | ||
|
|
||
| if (indicator_row.get_selected() == 0) { | ||
| dots = new Adw.CarouselIndicatorDots() { carousel = carousel }; | ||
| dots.orientation = carousel.orientation; | ||
| root_box.append(dots); | ||
| } else { | ||
| lines = new Adw.CarouselIndicatorLines() { carousel = carousel }; | ||
| lines.orientation = carousel.orientation; | ||
| root_box.append(lines); | ||
| } | ||
|
|
||
| indicator_row.notify["selected-item"].connect(() => { | ||
| if (indicator_row.get_selected() == 0) { | ||
| root_box.remove(lines); | ||
| dots = new Adw.CarouselIndicatorDots() { carousel = carousel }; | ||
| dots.orientation = carousel.orientation; | ||
| root_box.append(dots); | ||
| } else { | ||
| root_box.remove(dots); | ||
| lines = new Adw.CarouselIndicatorLines() { carousel = carousel }; | ||
| lines.orientation = carousel.orientation; | ||
| root_box.append(lines); | ||
| } | ||
| }); | ||
|
|
||
| orientation_row.notify["selected-item"].connect(() => { | ||
| if (orientation_row.get_selected() == 0) { | ||
| root_box.orientation = Gtk.Orientation.VERTICAL; | ||
| carousel.orientation = Gtk.Orientation.HORIZONTAL; | ||
| dots.orientation = Gtk.Orientation.HORIZONTAL; | ||
| lines.orientation = Gtk.Orientation.HORIZONTAL; | ||
| } else { | ||
| root_box.orientation = Gtk.Orientation.HORIZONTAL; | ||
| carousel.orientation = Gtk.Orientation.VERTICAL; | ||
| dots.orientation = Gtk.Orientation.VERTICAL; | ||
| lines.orientation = Gtk.Orientation.VERTICAL; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.