Commit 9adf5791 authored by Mohammed Sadiq's avatar Mohammed Sadiq
Browse files

Add ChattyMaChatInfo for matrix chats

parent 44713162
......@@ -36,6 +36,8 @@ src/chatty-utils.h
src/chatty-window.c
src/chatty-window.h
src/dialogs/chatty-info-dialog.c
src/dialogs/chatty-ma-chat-info.c
src/dialogs/chatty-ma-chat-info.h
src/dialogs/chatty-info-dialog.h
src/dialogs/chatty-pp-chat-info.c
src/dialogs/chatty-pp-chat-info.h
......@@ -60,6 +62,7 @@ src/ui/chatty-contact-row.ui
src/ui/chatty-dialog-join-muc.ui
src/ui/chatty-dialog-new-chat.ui
src/ui/chatty-info-dialog.ui
src/ui/chatty-ma-chat-info.ui
src/ui/chatty-pp-chat-info.ui
src/ui/chatty-fp-row.ui
src/ui/chatty-list-row.ui
......
......@@ -7,6 +7,7 @@
<file preprocess="xml-stripblanks">ui/chatty-contact-row.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-image-item.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-message-row.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-ma-chat-info.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-pp-chat-info.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-info-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/chatty-ma-account-details.ui</file>
......
/* -*- mode: c; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* chatty-ma-chat-info.c
*
* Copyright 2021 Purism SPC
*
* 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/>.
*
* Author(s):
* Mohammed Sadiq <sadiq@sadiqpk.org>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "chatty-ma-chat-info"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib/gi18n.h>
#include "chatty-avatar.h"
#include "chatty-list-row.h"
#include "chatty-fp-row.h"
#include "matrix/chatty-ma-chat.h"
#include "chatty-ma-chat-info.h"
#include "chatty-log.h"
struct _ChattyMaChatInfo
{
HdyPreferencesPage parent_instance;
ChattyChat *chat;
GtkWidget *avatar_button;
GtkWidget *avatar;
GtkWidget *name_label;
GtkWidget *matrix_id_label;
GtkWidget *avatar_chooser_dialog;
};
G_DEFINE_TYPE (ChattyMaChatInfo, chatty_ma_chat_info, HDY_TYPE_PREFERENCES_PAGE)
static void
chatty_ma_chat_info_finalize (GObject *object)
{
ChattyMaChatInfo *self = (ChattyMaChatInfo *)object;
g_clear_object (&self->chat);
G_OBJECT_CLASS (chatty_ma_chat_info_parent_class)->finalize (object);
}
static void
chatty_ma_chat_info_class_init (ChattyMaChatInfoClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = chatty_ma_chat_info_finalize;
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/Chatty/"
"ui/chatty-ma-chat-info.ui");
gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, avatar_button);
gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, avatar);
gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, name_label);
gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, matrix_id_label);
gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, avatar_chooser_dialog);
}
static void
chatty_ma_chat_info_init (ChattyMaChatInfo *self)
{
GtkWidget *clamp, *window;
gtk_widget_init_template (GTK_WIDGET (self));
clamp = gtk_widget_get_ancestor (self->avatar, HDY_TYPE_CLAMP);
if (clamp) {
hdy_clamp_set_maximum_size (HDY_CLAMP (clamp), 360);
hdy_clamp_set_tightening_threshold (HDY_CLAMP (clamp), 320);
}
window = gtk_widget_get_ancestor (self->avatar, GTK_TYPE_DIALOG);
if (window)
gtk_window_set_transient_for (GTK_WINDOW (self->avatar_chooser_dialog),
GTK_WINDOW (window));
}
GtkWidget *
chatty_ma_chat_info_new (void)
{
return g_object_new (CHATTY_TYPE_MA_CHAT_INFO, NULL);
}
ChattyChat *
chatty_ma_chat_info_get_item (ChattyMaChatInfo *self)
{
g_return_val_if_fail (CHATTY_IS_MA_CHAT_INFO (self), NULL);
return self->chat;
}
void
chatty_ma_chat_info_set_item (ChattyMaChatInfo *self,
ChattyChat *chat)
{
g_return_if_fail (CHATTY_IS_MA_CHAT_INFO (self));
g_return_if_fail (!chat || CHATTY_IS_CHAT (chat));
if (!g_set_object (&self->chat, chat) || !chat)
return;
gtk_label_set_text (GTK_LABEL (self->matrix_id_label),
chatty_chat_get_chat_name (self->chat));
gtk_label_set_text (GTK_LABEL (self->name_label),
chatty_item_get_name (CHATTY_ITEM (self->chat)));
}
/* -*- mode: c; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* chatty-ma-chat-info.h
*
* Copyright 2021 Purism SPC
*
* 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/>.
*
* Author(s):
* Mohammed Sadiq <sadiq@sadiqpk.org>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include "chatty-chat.h"
G_BEGIN_DECLS
#define CHATTY_TYPE_MA_CHAT_INFO (chatty_ma_chat_info_get_type ())
G_DECLARE_FINAL_TYPE (ChattyMaChatInfo, chatty_ma_chat_info, CHATTY, MA_CHAT_INFO, HdyPreferencesPage)
GtkWidget *chatty_ma_chat_info_new (void);
ChattyChat *chatty_ma_chat_info_get_item (ChattyMaChatInfo *self);
void chatty_ma_chat_info_set_item (ChattyMaChatInfo *self,
ChattyChat *chat);
G_END_DECLS
......@@ -14,6 +14,7 @@ libsrc = [
'contrib/gtkslicelistmodel.c',
'dialogs/chatty-ma-account-details.c',
'dialogs/chatty-pp-account-details.c',
'dialogs/chatty-ma-chat-info.c',
'dialogs/chatty-pp-chat-info.c',
'matrix/matrix-api.c',
'matrix/matrix-enc.c',
......@@ -61,6 +62,7 @@ ui_files = files (
'ui/chatty-message-row.ui',
# FIXME
# 'ui/chatty-pp-account-details.ui',
# 'ui/chatty-ma-chat-info.ui',
# 'ui/chatty-pp-user-info.ui',
'ui/chatty-settings-dialog.ui',
'ui/chatty-window.ui',
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ChattyMaChatInfo" parent="HdyPreferencesPage">
<property name="visible">1</property>
<child>
<object class="HdyPreferencesGroup">
<property name="visible">1</property>
<child>
<object class="GtkButton" id="avatar_button">
<property name="visible" bind-source="avatar" bind-property="visible"
bind-flags="sync-create"/>
<property name="hexpand">1</property>
<property name="halign">center</property>
<property name="can-focus">0</property>
<property name="sensitive">0</property>
<property name="focus-on-click">0</property>
<property name="receives_default">0</property>
<property name="margin-bottom">24</property>
<child>
<object class="ChattyAvatar" id="avatar">
<property name="visible">1</property>
<property name="size">96</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="HdyPreferencesGroup">
<property name="visible">1</property>
<child>
<object class="GtkGrid">
<property name="visible">1</property>
<property name="hexpand">1</property>
<property name="valign">start</property>
<property name="margin-bottom">24</property>
<property name="row-spacing">6</property>
<property name="column-spacing">6</property>
<property name="orientation">vertical</property>
<!-- User Alias -->
<child>
<object class="GtkLabel">
<property name="visible" bind-source="name_label" bind-property="visible"
bind-flags="sync-create"/>
<property name="xalign">1</property>
<property name="label" translatable="no">Chat</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="name_label">
<property name="visible">1</property>
<property name="expand">1</property>
<property name="halign">start</property>
<property name="ellipsize">end</property>
<property name="justify">left</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<!-- User ID -->
<child>
<object class="GtkLabel">
<property name="visible" bind-source="matrix_id_label" bind-property="visible"
bind-flags="sync-create"/>
<property name="xalign">1</property>
<property name="label" translatable="yes">Matrix ID</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="matrix_id_label">
<property name="visible">1</property>
<property name="expand">1</property>
<property name="halign">start</property>
<property name="ellipsize">end</property>
<property name="justify">left</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkFileChooserDialog" id="avatar_chooser_dialog">
<property name="modal">1</property>
<property name="filter">image_filter</property>
<property name="title" translatable="yes">Set Avatar</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete"/>
<child type="action">
<object class="GtkButton" id="avatar_cancel_button">
<property name="visible">1</property>
<property name="label" translatable="yes">Cancel</property>
</object>
</child>
<child type="action">
<object class="GtkButton" id="avatar_apply_button">
<property name="visible">1</property>
<property name="can-default">1</property>
<property name="label" translatable="yes">Open</property>
</object>
</child>
<action-widgets>
<action-widget response="cancel">avatar_cancel_button</action-widget>
<action-widget response="apply" default="true">avatar_apply_button</action-widget>
</action-widgets>
</object>
<object class="GtkFileFilter" id="image_filter">
<mime-types>
<mime-type>image/*</mime-type>
</mime-types>
</object>
<object class="GtkTextBuffer" id="topic_buffer"/>
</interface>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment