Merge pull request #19

ina
This commit is contained in:
tranfelix 2023-10-16 15:55:35 +02:00 committed by GitHub
commit 84e6f3748e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 323 additions and 251 deletions

View file

@ -1,4 +1,5 @@
mod window;
mod wifi;
use gtk::prelude::*;
use gtk::{Application, gio};
@ -10,20 +11,16 @@ fn main() {
gio::resources_register_include!("src.templates.gresource")
.expect("Failed to register resources.");
// Create a new application
let app = Application::builder()
.application_id(APP_ID)
.build();
// Connect to "activate" signal of `app`
app.connect_activate(build_ui);
// Run the application
app.connect_activate(buildUI);
app.run();
}
fn build_ui(app: &Application) {
// Create new window and present it
#[allow(non_snake_case)]
fn buildUI(app: &Application) {
let window = Window::new(app);
window.present();
}

View file

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.17.0 -->
<interface>
<requires lib="gtk" version="4.12"/>
<requires lib="gtk" version="4.8"/>
<requires lib="libadwaita" version="1.4"/>
<template class="resetUI" parent="AdwApplicationWindow">
<child>
@ -15,197 +15,28 @@
<property name="title">ReSet</property>
</object>
</property>
<child>
<object class="GtkLabel" id="test"/>
</child>
</object>
</child>
<child>
<object class="AdwNavigationSplitView">
<property name="content">
<object class="AdwNavigationPage">
<property name="child">
<object class="GtkFlowBox" id="resetMainWindow">
<child>
<object class="GtkBox" id="resetWifi_2">
<property name="orientation">vertical</property>
<child>
<object class="AdwClampScrollable">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="justify">right</property>
<property name="label">Available networks</property>
</object>
</child>
<child>
<object class="GtkListBox" id="resetWifiList">
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength_2">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel_2">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton_2">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength_3">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel_3">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton_3">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength_4">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel_4">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton_4">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength_5">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel_5">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton_5">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength_6">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel_6">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton_6">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="halign">start</property>
<property name="label">Advanced</property>
<property name="valign">start</property>
</object>
</child>
</object>
</child>
</object>
</property>
<property name="margin-bottom">20</property>
<property name="margin-end">20</property>
<property name="margin-start">20</property>
<property name="margin-top">20</property>
<child>
<object class="GtkFlowBox" id="resetMain">
<property name="column-spacing">25</property>
<property name="homogeneous">True</property>
<property name="row-spacing">25</property>
<property name="selection-mode">none</property>
<property name="valign">start</property>
</object>
</child>
</object>
</property>
<property name="sidebar">
@ -218,14 +49,14 @@
<property name="orientation">vertical</property>
<property name="width-request">150</property>
<child>
<object class="GtkSearchEntry">
<object class="GtkSearchEntry" id="resetSearchEntry">
<property name="margin-end">5</property>
<property name="margin-start">5</property>
<property name="placeholder-text">Search</property>
</object>
</child>
<child>
<object class="GtkListBox">
<object class="GtkListBox" id="resetSidebarList">
<property name="css-name">resetList</property>
<property name="width-request">150</property>
<child>
@ -393,6 +224,7 @@
</property>
</object>
</property>
<property name="vexpand">True</property>
</object>
</child>
</object>

View file

@ -2,11 +2,12 @@
<!DOCTYPE cambalache-project SYSTEM "cambalache-project.dtd">
<cambalache-project version="0.13.1" target_tk="gtk-4.0">
<ui>
(3,None,None,"resetMainWindow",None,None,None,None,None,None,None),
(4,None,None,"resetWiFi",None,None,None,None,None,None,None)
(3,1,None,"resetMainWindow",None,None,None,None,None,None,None),
(4,7,None,"resetWiFi",None,None,None,None,None,None,None),
(5,1,None,"resetWifiEntry",None,None,None,None,None,None,None)
</ui>
<object>
(3,1,"AdwApplicationWindow",None,None,None,None,None,-1,None),
(3,1,"AdwApplicationWindow","resetUI",None,None,None,None,-1,None),
(3,2,"GtkBox",None,1,None,None,None,-1,None),
(3,3,"AdwHeaderBar",None,2,None,None,None,None,None),
(3,5,"AdwWindowTitle",None,3,None,None,None,-1,None),
@ -15,8 +16,8 @@
(3,8,"AdwNavigationPage",None,6,None,None,None,-1,None),
(3,73,"GtkViewport",None,7,None,None,None,-1,None),
(3,74,"GtkBox",None,73,None,None,None,None,None),
(3,75,"GtkSearchEntry",None,74,None,None,None,None,None),
(3,76,"GtkListBox",None,74,None,None,None,1,None),
(3,75,"GtkSearchEntry","resetSearchEntry",74,None,None,None,None,None),
(3,76,"GtkListBox","resetSidebarList",74,None,None,None,1,None),
(3,79,"GtkListBoxRow","resetWifi",76,None,None,None,1,None),
(3,81,"GtkListBoxRow","resetBluetooth",76,None,None,None,2,None),
(3,83,"GtkListBoxRow","resetVPN",76,None,None,None,3,None),
@ -45,19 +46,26 @@
(3,111,"GtkBox",None,85,None,None,None,None,None),
(3,112,"GtkImage",None,111,None,None,None,None,None),
(3,113,"GtkLabel",None,111,None,None,None,1,None),
(3,114,"GtkFlowBox","resetMainWindow",8,None,None,None,-1,None),
(4,1,"GtkListBoxRow","resetWifiEntry",None,None,None,None,None,None),
(4,2,"GtkBox",None,1,None,None,None,None,None),
(4,3,"GtkImage","resetWifiStrength",2,None,None,None,None,None),
(4,4,"GtkLabel","resetWifiLabel",2,None,None,None,1,None),
(4,5,"GtkButton","resetWifiButton",2,None,None,None,2,None),
(3,115,"GtkLabel","test",3,None,None,None,-1,None),
(3,116,"GtkFlowBox","resetMain",8,None,None,None,-1,None),
(4,7,"GtkBox","resetWifi",None,None,None,None,None,None),
(4,8,"AdwClampScrollable",None,7,None,None,None,None,None),
(4,9,"GtkBox",None,8,None,None,None,None,None),
(4,10,"GtkLabel",None,9,None,None,None,None,None),
(4,11,"GtkListBox","resetWifiList",9,None,None,None,1,None),
(4,42,"GtkButton",None,7,None,None,None,1,None),
(4,43,"AdwToast",None,None,None,None,None,-1,None)
(4,44,"resetWifiEntry",None,11,None,None,None,1,None),
(4,45,"resetWifiEntry",None,11,None,None,None,1,None),
(4,46,"resetWifiEntry",None,11,None,None,None,2,None),
(4,47,"resetWifiEntry",None,11,None,None,None,3,None),
(4,48,"resetWifiEntry",None,11,None,None,None,4,None),
(4,49,"resetWifiEntry",None,11,None,None,None,5,None),
(4,50,"resetWifiEntry",None,11,None,None,None,6,None),
(5,1,"GtkListBoxRow","resetWifiEntry",None,None,None,None,None,None),
(5,2,"GtkBox",None,1,None,None,None,None,None),
(5,3,"GtkImage","resetWifiStrength",2,None,None,None,None,None),
(5,4,"GtkLabel","resetWifiLabel",2,None,None,None,1,None),
(5,5,"GtkButton","resetWifiButton",2,None,None,None,2,None)
</object>
<object_property>
(3,2,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None),
@ -66,8 +74,8 @@
(3,5,"AdwWindowTitle","title","ReSet",None,None,None,None,None,None,None,None,None),
(3,6,"AdwNavigationSplitView","content",None,None,None,None,None,8,None,None,None,None),
(3,6,"AdwNavigationSplitView","sidebar",None,None,None,None,None,7,None,None,None,None),
(3,6,"GtkWidget","vexpand","True",None,None,None,None,None,None,None,None,None),
(3,7,"AdwNavigationPage","child",None,None,None,None,None,73,None,None,None,None),
(3,8,"AdwNavigationPage","child",None,None,None,None,None,114,None,None,None,None),
(3,8,"GtkWidget","margin-bottom","20",None,None,None,None,None,None,None,None,None),
(3,8,"GtkWidget","margin-end","20",None,None,None,None,None,None,None,None,None),
(3,8,"GtkWidget","margin-start","20",None,None,None,None,None,None,None,None,None),
@ -122,23 +130,37 @@
(3,112,"GtkImage","icon-name","audio-headset-symbolic",None,None,None,None,None,None,None,None,None),
(3,112,"GtkWidget","margin-end","10",None,None,None,None,None,None,None,None,None),
(3,113,"GtkLabel","label","Audio",None,None,None,None,None,None,None,None,None),
(4,3,"GtkImage","icon-name","network-wireless-symbolic",None,None,None,None,None,None,None,None,None),
(4,3,"GtkWidget","margin-end","15",None,None,None,None,None,None,None,None,None),
(4,4,"GtkLabel","label","LoremIpsumInternet",None,None,None,None,None,None,None,None,None),
(4,4,"GtkLabel","xalign","0.0",None,None,None,None,None,None,None,None,None),
(4,4,"GtkWidget","hexpand","True",None,None,None,None,None,None,None,None,None),
(4,5,"GtkButton","icon-name","emblem-system-symbolic",None,None,None,None,None,None,None,None,None),
(4,5,"GtkWidget","halign","start",None,None,None,None,None,None,None,None,None),
(4,5,"GtkWidget","valign","center",None,None,None,None,None,None,None,None,None),
(3,116,"GtkFlowBox","column-spacing","25",None,None,None,None,None,None,None,None,None),
(3,116,"GtkFlowBox","homogeneous","True",None,None,None,None,None,None,None,None,None),
(3,116,"GtkFlowBox","row-spacing","25",None,None,None,None,None,None,None,None,None),
(3,116,"GtkFlowBox","selection-mode","none",None,None,None,None,None,None,None,None,None),
(3,116,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(4,7,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None),
(4,7,"GtkWidget","halign","start",None,None,None,None,None,None,None,None,None),
(4,7,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(4,8,"AdwClampScrollable","maximum-size","0",None,None,None,None,None,None,None,None,None),
(4,8,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None),
(4,9,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None),
(4,9,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(4,10,"GtkLabel","justify","right",None,None,None,None,None,None,None,None,None),
(4,10,"GtkLabel","label","Available networks",None,None,None,None,None,None,None,None,None),
(4,10,"GtkWidget","halign","start",None,None,None,None,None,None,None,None,None),
(4,11,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(4,42,"GtkButton","label","Advanced",None,None,None,None,None,None,None,None,None),
(4,42,"GtkWidget","halign","start",None,None,None,None,None,None,None,None,None),
(4,42,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None)
(4,42,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
(5,3,"GtkImage","icon-name","network-wireless-symbolic",None,None,None,None,None,None,None,None,None),
(5,3,"GtkWidget","margin-end","15",None,None,None,None,None,None,None,None,None),
(5,4,"GtkLabel","ellipsize","end",None,None,None,None,None,None,None,None,None),
(5,4,"GtkLabel","label","LoremIpsumInternet",None,None,None,None,None,None,None,None,None),
(5,4,"GtkLabel","single-line-mode","True",None,None,None,None,None,None,None,None,None),
(5,4,"GtkLabel","xalign","0.0",None,None,None,None,None,None,None,None,None),
(5,4,"GtkWidget","hexpand","True",None,None,None,None,None,None,None,None,None),
(5,4,"GtkWidget","margin-end","10",None,None,None,None,None,None,None,None,None),
(5,4,"GtkWidget","width-request","200",None,None,None,None,None,None,None,None,None),
(5,5,"GtkButton","icon-name","emblem-system-symbolic",None,None,None,None,None,None,None,None,None),
(5,5,"GtkWidget","halign","start",None,None,None,None,None,None,None,None,None),
(5,5,"GtkWidget","valign","center",None,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(3,76,"GtkWidget",2,2,None,1,None,None,None,None),

View file

@ -1,40 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.17.0 -->
<interface>
<object class="GtkListBoxRow" id="resetWifiEntry">
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel">
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkBox" id="resetWifi">
<requires lib="gtk" version="4.12"/>
<requires lib="libadwaita" version="1.4"/>
<template class="resetWifi" parent="GtkBox">
<property name="halign">start</property>
<property name="orientation">vertical</property>
<property name="valign">start</property>
<child>
<object class="AdwClampScrollable">
<property name="maximum-size">0</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">start</property>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
@ -43,7 +23,30 @@
</object>
</child>
<child>
<object class="GtkListBox" id="resetWifiList"/>
<object class="GtkListBox" id="resetWifiList">
<property name="valign">start</property>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
<child>
<object class="resetWifiEntry"/>
</child>
</object>
</child>
</object>
</child>
@ -56,6 +59,5 @@
<property name="valign">start</property>
</object>
</child>
</object>
<object class="AdwToast"/>
</template>
</interface>

View file

@ -0,0 +1,35 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.17.0 -->
<interface>
<requires lib="gtk" version="4.12"/>
<template class="resetWifiEntry" parent="GtkListBoxRow">
<child>
<object class="GtkBox">
<child>
<object class="GtkImage" id="resetWifiStrength">
<property name="icon-name">network-wireless-symbolic</property>
<property name="margin-end">15</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resetWifiLabel">
<property name="ellipsize">end</property>
<property name="hexpand">True</property>
<property name="label">LoremIpsumInternet</property>
<property name="margin-end">10</property>
<property name="single-line-mode">True</property>
<property name="width-request">200</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkButton" id="resetWifiButton">
<property name="halign">start</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/xetibo/reset/">
<file compressed="true" preprocess="xml-stripblanks">resetWifiEntry.ui</file>
<file compressed="true" preprocess="xml-stripblanks">resetWiFi.ui</file>
<file compressed="true" preprocess="xml-stripblanks">resetMainWindow.ui</file>
<!-- <file compressed="true" preprocess="xml-stripblanks">resetWiFi.ui</file>-->
</gresource>
</gresources>

33
src/wifi/mod.rs Normal file
View file

@ -0,0 +1,33 @@
#![allow(non_snake_case)]
mod wifiBox;
mod wifiEntry;
use adw::glib::Object;
use gtk::{glib};
use gtk::prelude::WidgetExt;
use gtk::subclass::prelude::*;
glib::wrapper! {
pub struct WifiBox(ObjectSubclass<wifiBox::WifiBox>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
glib::wrapper! {
pub struct WifiEntry(ObjectSubclass<wifiEntry::WifiEntry>)
@extends gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
}
impl WifiBox {
pub fn new() -> Self {
Object::builder().build()
}
}
impl WifiEntry {
fn onClick(&self) {
self.imp().resetWifiButton.set_tooltip_text(Option::from("asd"));
}
}

43
src/wifi/wifiBox.rs Normal file
View file

@ -0,0 +1,43 @@
use gtk::{CompositeTemplate, glib, ListBox};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::wifi::WifiEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/xetibo/reset/resetWiFi.ui")]
pub struct WifiBox {
#[template_child]
pub resetWifiList: TemplateChild<ListBox>,
}
#[glib::object_subclass]
impl ObjectSubclass for WifiBox {
const NAME: &'static str = "resetWifi";
type Type = super::WifiBox;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
WifiEntry::ensure_type();
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl ObjectImpl for WifiBox {
fn constructed(&self) {
self.parent_constructed();
}
}
impl BoxImpl for WifiBox {}
impl WidgetImpl for WifiBox {}
impl WindowImpl for WifiBox {}
impl ApplicationWindowImpl for WifiBox {}

39
src/wifi/wifiEntry.rs Normal file
View file

@ -0,0 +1,39 @@
use gtk::{Button, CompositeTemplate, glib};
use gtk::subclass::prelude::*;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/xetibo/reset/resetWifiEntry.ui")]
pub struct WifiEntry {
#[template_child]
pub resetWifiButton: TemplateChild<Button>,
}
#[glib::object_subclass]
impl ObjectSubclass for WifiEntry {
const NAME: &'static str = "resetWifiEntry";
type Type = super::WifiEntry;
type ParentType = gtk::ListBoxRow;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl ObjectImpl for WifiEntry {
fn constructed(&self) {
self.parent_constructed();
}
}
impl ListBoxRowImpl for WifiEntry {}
impl WidgetImpl for WifiEntry {}
impl WindowImpl for WifiEntry {}
impl ApplicationWindowImpl for WifiEntry {}

View file

@ -1,12 +1,22 @@
use adw::glib::StaticTypeExt;
use adw::subclass::prelude::AdwApplicationWindowImpl;
use glib::subclass::InitializingObject;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate};
use gtk::{glib, CompositeTemplate, SearchEntry, Label, ListBox, FlowBox};
use crate::wifi::WifiBox;
#[allow(non_snake_case)]
#[derive(CompositeTemplate, Default)]
#[template(resource = "/org/xetibo/reset/resetMainWindow.ui")]
pub struct Window {
// todo i guess
#[template_child]
pub resetSearchEntry: TemplateChild<SearchEntry>,
#[template_child]
pub resetSidebarList: TemplateChild<ListBox>,
#[template_child]
pub resetMain: TemplateChild<FlowBox>,
#[template_child]
pub test: TemplateChild<Label>,
}
#[glib::object_subclass]
@ -16,6 +26,7 @@ impl ObjectSubclass for Window {
type ParentType = adw::ApplicationWindow;
fn class_init(klass: &mut Self::Class) {
WifiBox::ensure_type();
klass.bind_template();
}
@ -24,7 +35,24 @@ impl ObjectSubclass for Window {
}
}
impl ObjectImpl for Window {}
impl ObjectImpl for Window {
fn constructed(&self) {
self.parent_constructed();
let object = self.obj();
object.setupCallback();
let wifibox = WifiBox::new();
let wifibox2 = WifiBox::new();
let wifibox3 = WifiBox::new();
let wifibox4 = WifiBox::new();
self.resetMain.insert(&wifibox, -1);
self.resetMain.insert(&wifibox2, -1);
self.resetMain.insert(&wifibox3, -1);
self.resetMain.insert(&wifibox4, -1);
}
}
impl WidgetImpl for Window {}

View file

@ -1,7 +1,10 @@
mod imp;
use adw::glib::clone;
use adw::subclass::prelude::ObjectSubclassIsExt;
use glib::Object;
use gtk::{gio, glib, Application};
use gtk::prelude::*;
glib::wrapper! {
pub struct Window(ObjectSubclass<imp::Window>)
@ -10,11 +13,48 @@ glib::wrapper! {
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
}
#[allow(non_snake_case)]
impl Window {
pub fn new(app: &Application) -> Self {
// Create new window
Object::builder()
.property("application", app)
.build()
Object::builder().property("application", app).build()
}
fn setupCallback(&self) {
self.imp()
.resetSearchEntry
.connect_search_changed(clone!(@ weak self as window => move |_| {
window.setText();
window.filterList();
}));
}
fn setText(&self) {
let buffer = self.imp()
.resetSearchEntry
.text()
.to_string();
self.imp()
.test
.set_text(&buffer);
}
fn filterList(&self) {
let text = self.imp()
.resetSearchEntry
.text()
.to_string();
self.imp().resetSidebarList.set_filter_func(move |x| {
if text == "" {
return true;
}
if let Some(child) = x.child() {
let result = child.downcast::<gtk::Box>().unwrap();
let label = result.last_child().unwrap().downcast::<gtk::Label>().unwrap();
if label.text().to_lowercase().contains(&text.to_lowercase()) {
return true;
}
}
return false;
});
}
}