Skip to content

Instantly share code, notes, and snippets.

@feliwir
Created April 7, 2023 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feliwir/fb04c5544f3114118a49e1c34fd3e202 to your computer and use it in GitHub Desktop.
Save feliwir/fb04c5544f3114118a49e1c34fd3e202 to your computer and use it in GitHub Desktop.
/* window.rs
*
* Copyright 2023 stephan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
use adw::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib};
use crate::YahooFinanceModel;
mod imp {
use super::*;
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(resource = "/org/byteforge/stocks/window.ui")]
pub struct StocksWindow {
// Template widgets
#[template_child]
pub yahoo_model: TemplateChild<YahooFinanceModel>,
}
#[glib::object_subclass]
impl ObjectSubclass for StocksWindow {
const NAME: &'static str = "StocksWindow";
type Type = super::StocksWindow;
type ParentType = adw::ApplicationWindow;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
klass.bind_template_callbacks();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl ObjectImpl for StocksWindow {}
impl WidgetImpl for StocksWindow {}
impl WindowImpl for StocksWindow {}
impl ApplicationWindowImpl for StocksWindow {}
impl AdwApplicationWindowImpl for StocksWindow {}
}
glib::wrapper! {
pub struct StocksWindow(ObjectSubclass<imp::StocksWindow>)
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap;
}
impl StocksWindow {
pub fn new<P: glib::IsA<gtk::Application>>(application: &P) -> Self {
glib::Object::builder()
.property("application", application)
.build()
}
}
#[gtk::template_callbacks]
impl StocksWindow {
#[template_callback]
fn handle_row_activated(&self, listbox: &gtk::ListBox, row: &gtk::ListBoxRow) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment