feat: implement barebone features for Sidebar widget

merge-requests/8/head
Nefo Fortressia 2021-10-28 17:11:14 +07:00
parent 0a13750970
commit ffdc612e7e
4 changed files with 112 additions and 0 deletions

View File

@ -3,4 +3,5 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
pub mod app;
pub mod sidebar;
pub mod window;

View File

@ -0,0 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::CompositeTemplate;
#[derive(Default, CompositeTemplate)]
#[template(file = "./sidebar.ui")]
pub struct EchidnaSidebar {}
#[glib::object_subclass]
impl ObjectSubclass for EchidnaSidebar {
const NAME: &'static str = "EchidnaSidebar";
type Type = super::EchidnaSidebar;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl ObjectImpl for EchidnaSidebar {}
impl WidgetImpl for EchidnaSidebar {}
impl BoxImpl for EchidnaSidebar {}

View File

@ -0,0 +1,13 @@
pub mod imp;
glib::wrapper! {
pub struct EchidnaSidebar(ObjectSubclass<imp::EchidnaSidebar>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
impl EchidnaSidebar {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create 'EchidnaSidebar' component.")
}
}

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="4.5.0" />
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<template class="EchidnaSidebar">
<child>
<object class="GtkStackSidebar">
<property name="stack">
<object class="GtkStack">
<child>
<object class="GtkStackPage">
<!-- Explorer Tab -->
<property name="name">explorer</property>
<property name="title">Explorer</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="model">liststore1</property>
<child></child>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<signal name="changed" handler="on_treeview_selection_changed" />
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Search Tab -->
<property name="name">search</property>
<property name="title">Search</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLabel">
<property name="label">Search</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Extensions Tab -->
<property name="name">extensions</property>
<property name="title">Extensions</property>
<property name="child"></property>
</object>
</child>
</object>
</property>
</object>
</child>
</template>
</interface>