Skip to content

Commit

Permalink
chat-info-members: Move MemberRow inside chat_info_window module
Browse files Browse the repository at this point in the history
  • Loading branch information
yuraiz committed Jan 8, 2023
1 parent 339ea84 commit e1be8c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion data/resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<file compressed="true" preprocess="xml-stripblanks">ui/add-account-row.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/avatar-with-selection.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/components-avatar.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/components-chat-member-row.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/components-message-entry.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-chat-action-bar.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-chat-history.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-chat-info-member-row.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-chat-info-window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-event-row.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/content-message-document.ui</file>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ComponentsChatMemberRow" parent="GtkBox">
<template class="ContentChatInfoMemberRow" parent="GtkBox">
<property name="spacing">12</property>
<child>
<object class="ComponentsAvatar" id="avatar">
Expand Down
2 changes: 0 additions & 2 deletions src/session/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
mod avatar;
mod chat_member_row;
mod message_entry;
mod snow;

pub(crate) use self::avatar::Avatar;
pub(crate) use self::chat_member_row::ChatMemberRow;
pub(crate) use self::message_entry::MessageEntry;
pub(crate) use self::snow::Snow;
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate};

use super::Avatar;
use crate::session::components::Avatar;
use crate::{expressions, strings};
use tdlib::enums::{UserStatus, UserType};

mod imp {
use super::*;
#[derive(Debug, Default, CompositeTemplate)]
#[template(resource = "/com/github/melix99/telegrand/ui/components-chat-member-row.ui")]
pub(crate) struct ChatMemberRow {
#[template(resource = "/com/github/melix99/telegrand/ui/content-chat-info-member-row.ui")]
pub(crate) struct MemberRow {
#[template_child]
pub(super) avatar: TemplateChild<Avatar>,
#[template_child]
Expand All @@ -24,9 +24,9 @@ mod imp {
}

#[glib::object_subclass]
impl ObjectSubclass for ChatMemberRow {
const NAME: &'static str = "ComponentsChatMemberRow";
type Type = super::ChatMemberRow;
impl ObjectSubclass for MemberRow {
const NAME: &'static str = "ContentChatInfoMemberRow";
type Type = super::MemberRow;
type ParentType = gtk::Box;

fn class_init(klass: &mut Self::Class) {
Expand All @@ -39,19 +39,19 @@ mod imp {
}
}

impl ObjectImpl for ChatMemberRow {}
impl ObjectImpl for MemberRow {}

impl WidgetImpl for ChatMemberRow {}
impl WidgetImpl for MemberRow {}

impl BoxImpl for ChatMemberRow {}
impl BoxImpl for MemberRow {}
}

glib::wrapper! {
pub(crate) struct ChatMemberRow(ObjectSubclass<imp::ChatMemberRow>)
pub(crate) struct MemberRow(ObjectSubclass<imp::MemberRow>)
@extends gtk::Widget;
}

impl ChatMemberRow {
impl MemberRow {
pub fn new() -> Self {
glib::Object::new(&[])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mod member_row;

use self::member_row::MemberRow;

use adw::prelude::*;
use gettextrs::gettext;
use glib::{clone, closure};
Expand All @@ -12,7 +16,6 @@ use tdlib::types::{
};

use crate::i18n::ngettext_f;
use crate::session::components::ChatMemberRow;
use crate::tdlib::{BasicGroup, BoxedUserStatus, Chat, ChatMember, ChatType, Supergroup, User};
use crate::utils::spawn;
use crate::{expressions, strings};
Expand Down Expand Up @@ -395,13 +398,13 @@ impl ChatInfoWindow {
let factory = gtk::SignalListItemFactory::new();

factory.connect_setup(move |_, list_item| {
list_item.set_property("child", ChatMemberRow::new());
list_item.set_property("child", MemberRow::new());
});

factory.connect_bind(move |_, list_item| {
let list_item: &gtk::ListItem = list_item.downcast_ref().unwrap();

let user_row: ChatMemberRow = list_item.child().unwrap().downcast().unwrap();
let user_row: MemberRow = list_item.child().unwrap().downcast().unwrap();
let member: ChatMember = list_item.item().unwrap().downcast().unwrap();

user_row.bind_member(member);
Expand Down

0 comments on commit e1be8c4

Please sign in to comment.