-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
library: Ported View switcher to rust (#594)
* library: Ported ViewSwitcher to rust * library: Moved `title` * Updated refrences to `strong` * Updated `notification_count` to an integer value * Removed the unused reference * Works with weak refrences now as well * Sync JS * Changed indent to `2` to match other varients * Sync vala * Test says so * Revert "Changed indent to `2` to match other varients" This reverts commit 56887ff.
- Loading branch information
Showing
3 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
use crate::workbench; | ||
use adw::prelude::*; | ||
|
||
use glib::clone; | ||
use gtk::glib; | ||
|
||
pub fn main() { | ||
let notifications_page: adw::ViewStackPage = workbench::builder().object("page3").unwrap(); | ||
let notification_list: gtk::ListBox = workbench::builder().object("notification_list").unwrap(); | ||
|
||
let notification_count = 5; | ||
notifications_page.set_badge_number(notification_count); | ||
|
||
for _ in 0..notification_count { | ||
let notification_row = adw::ActionRow::builder() | ||
.title("Notification") | ||
.selectable(false) | ||
.build(); | ||
|
||
let button = gtk::Button::builder() | ||
.halign(gtk::Align::Center) | ||
.valign(gtk::Align::Center) | ||
.margin_top(10) | ||
.margin_bottom(10) | ||
.icon_name("check-plain-symbolic") | ||
.build(); | ||
|
||
button.connect_clicked(clone!( | ||
@weak notifications_page, @weak notification_list, @weak notification_row => move |_| { | ||
notifications_page.set_badge_number(notifications_page.badge_number() - 1); | ||
notification_list.remove(¬ification_row); | ||
|
||
if notifications_page.badge_number() == 0 { | ||
notifications_page.set_needs_attention(false); | ||
} | ||
} | ||
)); | ||
|
||
notification_row.add_suffix(&button); | ||
|
||
notification_list.append(¬ification_row); | ||
} | ||
} |
This file contains 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
This file contains 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