Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
2f4bae19
by Daniel Brötzmann at 2021-02-03T10:38:28+01:00
3 changed files:
Changes:
| 1 |
+<?xml version="1.0" encoding="UTF-8"?>
|
|
| 2 |
+<!-- Generated with glade 3.38.2 -->
|
|
| 3 |
+<interface>
|
|
| 4 |
+ <requires lib="gtk+" version="3.24"/>
|
|
| 5 |
+ <object class="GtkOverlay" id="overlay">
|
|
| 6 |
+ <property name="visible">True</property>
|
|
| 7 |
+ <property name="can-focus">False</property>
|
|
| 8 |
+ <child>
|
|
| 9 |
+ <object class="GtkBox">
|
|
| 10 |
+ <property name="visible">True</property>
|
|
| 11 |
+ <property name="can-focus">False</property>
|
|
| 12 |
+ <child>
|
|
| 13 |
+ <object class="GtkBox" id="account_identifier">
|
|
| 14 |
+ <property name="width-request">6</property>
|
|
| 15 |
+ <property name="can-focus">False</property>
|
|
| 16 |
+ <property name="no-show-all">True</property>
|
|
| 17 |
+ <property name="margin-end">6</property>
|
|
| 18 |
+ <property name="orientation">vertical</property>
|
|
| 19 |
+ <child>
|
|
| 20 |
+ <placeholder/>
|
|
| 21 |
+ </child>
|
|
| 22 |
+ <style>
|
|
| 23 |
+ <class name="account-identifier-bar"/>
|
|
| 24 |
+ </style>
|
|
| 25 |
+ </object>
|
|
| 26 |
+ <packing>
|
|
| 27 |
+ <property name="expand">False</property>
|
|
| 28 |
+ <property name="fill">True</property>
|
|
| 29 |
+ <property name="position">0</property>
|
|
| 30 |
+ </packing>
|
|
| 31 |
+ </child>
|
|
| 32 |
+ <child>
|
|
| 33 |
+ <object class="GtkImage" id="avatar_image">
|
|
| 34 |
+ <property name="visible">True</property>
|
|
| 35 |
+ <property name="can-focus">False</property>
|
|
| 36 |
+ <property name="margin-end">12</property>
|
|
| 37 |
+ </object>
|
|
| 38 |
+ <packing>
|
|
| 39 |
+ <property name="expand">False</property>
|
|
| 40 |
+ <property name="fill">True</property>
|
|
| 41 |
+ <property name="position">1</property>
|
|
| 42 |
+ </packing>
|
|
| 43 |
+ </child>
|
|
| 44 |
+ <child>
|
|
| 45 |
+ <object class="GtkBox">
|
|
| 46 |
+ <property name="visible">True</property>
|
|
| 47 |
+ <property name="can-focus">False</property>
|
|
| 48 |
+ <property name="orientation">vertical</property>
|
|
| 49 |
+ <child>
|
|
| 50 |
+ <object class="GtkBox">
|
|
| 51 |
+ <property name="visible">True</property>
|
|
| 52 |
+ <property name="can-focus">False</property>
|
|
| 53 |
+ <property name="spacing">6</property>
|
|
| 54 |
+ <child>
|
|
| 55 |
+ <object class="GtkLabel" id="name_label">
|
|
| 56 |
+ <property name="visible">True</property>
|
|
| 57 |
+ <property name="can-focus">False</property>
|
|
| 58 |
+ <property name="halign">start</property>
|
|
| 59 |
+ <property name="ellipsize">end</property>
|
|
| 60 |
+ <property name="single-line-mode">True</property>
|
|
| 61 |
+ <property name="xalign">0</property>
|
|
| 62 |
+ </object>
|
|
| 63 |
+ <packing>
|
|
| 64 |
+ <property name="expand">False</property>
|
|
| 65 |
+ <property name="fill">True</property>
|
|
| 66 |
+ <property name="position">0</property>
|
|
| 67 |
+ </packing>
|
|
| 68 |
+ </child>
|
|
| 69 |
+ <child>
|
|
| 70 |
+ <object class="GtkLabel" id="timestamp_label">
|
|
| 71 |
+ <property name="visible">True</property>
|
|
| 72 |
+ <property name="can-focus">False</property>
|
|
| 73 |
+ <property name="valign">end</property>
|
|
| 74 |
+ <style>
|
|
| 75 |
+ <class name="small-label"/>
|
|
| 76 |
+ <class name="dim-label"/>
|
|
| 77 |
+ </style>
|
|
| 78 |
+ </object>
|
|
| 79 |
+ <packing>
|
|
| 80 |
+ <property name="expand">False</property>
|
|
| 81 |
+ <property name="fill">True</property>
|
|
| 82 |
+ <property name="pack-type">end</property>
|
|
| 83 |
+ <property name="position">1</property>
|
|
| 84 |
+ </packing>
|
|
| 85 |
+ </child>
|
|
| 86 |
+ <child>
|
|
| 87 |
+ <object class="GtkLabel" id="unread_label">
|
|
| 88 |
+ <property name="can-focus">False</property>
|
|
| 89 |
+ <property name="no-show-all">True</property>
|
|
| 90 |
+ <style>
|
|
| 91 |
+ <class name="unread-counter"/>
|
|
| 92 |
+ </style>
|
|
| 93 |
+ </object>
|
|
| 94 |
+ <packing>
|
|
| 95 |
+ <property name="expand">False</property>
|
|
| 96 |
+ <property name="fill">True</property>
|
|
| 97 |
+ <property name="pack-type">end</property>
|
|
| 98 |
+ <property name="position">2</property>
|
|
| 99 |
+ </packing>
|
|
| 100 |
+ </child>
|
|
| 101 |
+ </object>
|
|
| 102 |
+ <packing>
|
|
| 103 |
+ <property name="expand">False</property>
|
|
| 104 |
+ <property name="fill">True</property>
|
|
| 105 |
+ <property name="position">0</property>
|
|
| 106 |
+ </packing>
|
|
| 107 |
+ </child>
|
|
| 108 |
+ <child>
|
|
| 109 |
+ <object class="GtkBox">
|
|
| 110 |
+ <property name="visible">True</property>
|
|
| 111 |
+ <property name="can-focus">False</property>
|
|
| 112 |
+ <property name="spacing">3</property>
|
|
| 113 |
+ <child>
|
|
| 114 |
+ <object class="GtkLabel" id="nick_label">
|
|
| 115 |
+ <property name="visible">True</property>
|
|
| 116 |
+ <property name="can-focus">False</property>
|
|
| 117 |
+ <property name="halign">start</property>
|
|
| 118 |
+ <property name="single-line-mode">True</property>
|
|
| 119 |
+ <property name="xalign">0</property>
|
|
| 120 |
+ <style>
|
|
| 121 |
+ <class name="small-label"/>
|
|
| 122 |
+ <class name="dim-label"/>
|
|
| 123 |
+ </style>
|
|
| 124 |
+ </object>
|
|
| 125 |
+ <packing>
|
|
| 126 |
+ <property name="expand">False</property>
|
|
| 127 |
+ <property name="fill">True</property>
|
|
| 128 |
+ <property name="position">0</property>
|
|
| 129 |
+ </packing>
|
|
| 130 |
+ </child>
|
|
| 131 |
+ <child>
|
|
| 132 |
+ <object class="GtkLabel" id="message_label">
|
|
| 133 |
+ <property name="visible">True</property>
|
|
| 134 |
+ <property name="can-focus">False</property>
|
|
| 135 |
+ <property name="halign">start</property>
|
|
| 136 |
+ <property name="ellipsize">end</property>
|
|
| 137 |
+ <property name="single-line-mode">True</property>
|
|
| 138 |
+ <property name="xalign">0</property>
|
|
| 139 |
+ <style>
|
|
| 140 |
+ <class name="small-label"/>
|
|
| 141 |
+ </style>
|
|
| 142 |
+ </object>
|
|
| 143 |
+ <packing>
|
|
| 144 |
+ <property name="expand">False</property>
|
|
| 145 |
+ <property name="fill">True</property>
|
|
| 146 |
+ <property name="position">1</property>
|
|
| 147 |
+ </packing>
|
|
| 148 |
+ </child>
|
|
| 149 |
+ </object>
|
|
| 150 |
+ <packing>
|
|
| 151 |
+ <property name="expand">False</property>
|
|
| 152 |
+ <property name="fill">True</property>
|
|
| 153 |
+ <property name="position">1</property>
|
|
| 154 |
+ </packing>
|
|
| 155 |
+ </child>
|
|
| 156 |
+ </object>
|
|
| 157 |
+ <packing>
|
|
| 158 |
+ <property name="expand">True</property>
|
|
| 159 |
+ <property name="fill">True</property>
|
|
| 160 |
+ <property name="position">2</property>
|
|
| 161 |
+ </packing>
|
|
| 162 |
+ </child>
|
|
| 163 |
+ </object>
|
|
| 164 |
+ <packing>
|
|
| 165 |
+ <property name="index">-1</property>
|
|
| 166 |
+ </packing>
|
|
| 167 |
+ </child>
|
|
| 168 |
+ <child type="overlay">
|
|
| 169 |
+ <object class="GtkRevealer" id="revealer">
|
|
| 170 |
+ <property name="can-focus">False</property>
|
|
| 171 |
+ <property name="halign">end</property>
|
|
| 172 |
+ <property name="transition-type">crossfade</property>
|
|
| 173 |
+ <property name="transition-duration">100</property>
|
|
| 174 |
+ <child>
|
|
| 175 |
+ <object class="GtkButton" id="close_button">
|
|
| 176 |
+ <property name="visible">True</property>
|
|
| 177 |
+ <property name="can-focus">True</property>
|
|
| 178 |
+ <property name="receives-default">True</property>
|
|
| 179 |
+ <property name="tooltip-text" translatable="yes">Close</property>
|
|
| 180 |
+ <property name="valign">center</property>
|
|
| 181 |
+ <child>
|
|
| 182 |
+ <object class="GtkImage">
|
|
| 183 |
+ <property name="visible">True</property>
|
|
| 184 |
+ <property name="can-focus">False</property>
|
|
| 185 |
+ <property name="icon-name">window-close-symbolic</property>
|
|
| 186 |
+ </object>
|
|
| 187 |
+ </child>
|
|
| 188 |
+ <style>
|
|
| 189 |
+ <class name="revealer-close-button"/>
|
|
| 190 |
+ <class name="flat"/>
|
|
| 191 |
+ </style>
|
|
| 192 |
+ </object>
|
|
| 193 |
+ </child>
|
|
| 194 |
+ </object>
|
|
| 195 |
+ </child>
|
|
| 196 |
+ </object>
|
|
| 197 |
+</interface>
|
| ... | ... | @@ -126,8 +126,8 @@ |
| 126 | 126 |
.chatlist-row {
|
| 127 | 127 |
transition: none;
|
| 128 | 128 |
padding: 0px;
|
| 129 |
- margin-left: 6px;
|
|
| 130 |
- margin-right: 6px;
|
|
| 129 |
+ margin-left: 12px;
|
|
| 130 |
+ margin-right: 12px;
|
|
| 131 | 131 |
margin-bottom: 3px;
|
| 132 | 132 |
border-radius: 6px;
|
| 133 | 133 |
}
|
| ... | ... | @@ -142,7 +142,7 @@ |
| 142 | 142 |
background-color: shade(@theme_base_color, 0.9);
|
| 143 | 143 |
outline: none;
|
| 144 | 144 |
}
|
| 145 |
-.chatlist-row:selected label {
|
|
| 145 |
+.chatlist-row:selected label:not(.unread-counter){
|
|
| 146 | 146 |
color: @theme_text_color;
|
| 147 | 147 |
}
|
| 148 | 148 |
.chatlist-row:selected button {
|
| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 |
|
| 3 | 3 |
from gi.repository import GLib
|
| 4 | 4 |
from gi.repository import Gtk
|
| 5 |
-from gi.repository import Pango
|
|
| 6 | 5 |
|
| 7 | 6 |
from gajim.common import app
|
| 8 | 7 |
from gajim.common.const import AvatarSize
|
| ... | ... | @@ -12,6 +11,8 @@ |
| 12 | 11 |
from gajim.common.helpers import get_group_chat_nick
|
| 13 | 12 |
from gajim.common.helpers import get_uf_relative_time
|
| 14 | 13 |
|
| 14 |
+from gajim.gui.util import get_builder
|
|
| 15 |
+ |
|
| 15 | 16 |
log = logging.getLogger('gajim.gtk.chatlist')
|
| 16 | 17 |
|
| 17 | 18 |
|
| ... | ... | @@ -110,17 +111,16 @@ def __init__(self, workspace_id, account, jid, type_): |
| 110 | 111 |
|
| 111 | 112 |
self.get_style_context().add_class('chatlist-row')
|
| 112 | 113 |
|
| 114 |
+ self._ui = get_builder('chat_list_row.ui')
|
|
| 115 |
+ self.add(self._ui.overlay)
|
|
| 116 |
+ |
|
| 113 | 117 |
self.connect('state-flags-changed', self._on_state_flags_changed)
|
| 118 |
+ self._ui.close_button.connect('clicked', self._on_close_button_clicked)
|
|
| 114 | 119 |
|
| 115 |
- account_bar = Gtk.Box()
|
|
| 116 |
- account_bar.set_size_request(6, -1)
|
|
| 117 |
- account_bar.set_no_show_all(True)
|
|
| 118 | 120 |
account_class = app.css_config.get_dynamic_class(account)
|
| 119 |
- account_bar.get_style_context().add_class(account_class)
|
|
| 120 |
- account_bar.get_style_context().add_class(
|
|
| 121 |
- 'account-identifier-bar')
|
|
| 121 |
+ self._ui.account_identifier.get_style_context().add_class(account_class)
|
|
| 122 | 122 |
if len(app.get_enabled_accounts_with_labels()) > 1:
|
| 123 |
- account_bar.show()
|
|
| 123 |
+ self._ui.account_identifier.show()
|
|
| 124 | 124 |
|
| 125 | 125 |
contact = app.contacts.get_contact(account, jid)
|
| 126 | 126 |
|
| ... | ... | @@ -147,116 +147,56 @@ def __init__(self, workspace_id, account, jid, type_): |
| 147 | 147 |
scale)
|
| 148 | 148 |
name = jid
|
| 149 | 149 |
|
| 150 |
- avatar_image = Gtk.Image.new_from_surface(avatar)
|
|
| 151 |
- chat_name_label = Gtk.Label()
|
|
| 152 |
- chat_name_label.set_halign(Gtk.Align.START)
|
|
| 153 |
- chat_name_label.set_xalign(0)
|
|
| 154 |
- chat_name_label.set_ellipsize(Pango.EllipsizeMode.END)
|
|
| 155 |
- chat_name_label.set_text(name)
|
|
| 156 |
- |
|
| 157 |
- self._last_message_label = Gtk.Label()
|
|
| 158 |
- self._last_message_label.set_halign(Gtk.Align.START)
|
|
| 159 |
- self._last_message_label.set_xalign(0)
|
|
| 160 |
- self._last_message_label.set_ellipsize(Pango.EllipsizeMode.END)
|
|
| 161 |
- self._last_message_label.get_style_context().add_class('small-label')
|
|
| 162 |
- |
|
| 163 |
- self._timestamp_label = Gtk.Label()
|
|
| 164 |
- self._timestamp_label.set_halign(Gtk.Align.END)
|
|
| 165 |
- self._timestamp_label.set_valign(Gtk.Align.END)
|
|
| 166 |
- self._timestamp_label.get_style_context().add_class('small-label')
|
|
| 167 |
- self._timestamp_label.get_style_context().add_class('dim-label')
|
|
| 150 |
+ self._ui.avatar_image.set_from_surface(avatar)
|
|
| 151 |
+ self._ui.name_label.set_text(name)
|
|
| 168 | 152 |
|
| 169 | 153 |
# Get last chat message from archive
|
| 170 | 154 |
line = app.storage.archive.get_last_conversation_line(account, jid)
|
| 171 |
- last_message_box = Gtk.Box(spacing=3)
|
|
| 172 | 155 |
if line is not None and line.message is not None:
|
| 173 | 156 |
one_line = ' '.join(line.message.splitlines())
|
| 174 |
- |
|
| 175 |
- self._last_message_label.set_text(one_line)
|
|
| 176 |
- self._nick_label = Gtk.Label()
|
|
| 177 |
- self._nick_label.set_halign(Gtk.Align.START)
|
|
| 178 |
- self._nick_label.get_style_context().add_class('small-label')
|
|
| 179 |
- self._nick_label.get_style_context().add_class('dim-label')
|
|
| 157 |
+ self._ui.message_label.set_text(one_line)
|
|
| 180 | 158 |
if line.kind in (KindConstant.CHAT_MSG_SENT,
|
| 181 | 159 |
KindConstant.SINGLE_MSG_SENT):
|
| 182 |
- self._nick_label.set_text(_('Me:'))
|
|
| 183 |
- last_message_box.add(self._nick_label)
|
|
| 160 |
+ self._ui.nick_label.set_text(_('Me:'))
|
|
| 161 |
+ self._ui.nick_label.show()
|
|
| 162 |
+ |
|
| 184 | 163 |
if line.kind == KindConstant.GC_MSG:
|
| 185 | 164 |
our_nick = get_group_chat_nick(account, jid)
|
| 186 | 165 |
if line.contact_name == our_nick:
|
| 187 |
- self._nick_label.set_text(_('Me:'))
|
|
| 166 |
+ self._ui.nick_label.set_text(_('Me:'))
|
|
| 188 | 167 |
else:
|
| 189 |
- self._nick_label.set_text(_('%(muc_nick)s: ') % {
|
|
| 168 |
+ self._ui.nick_label.set_text(_('%(muc_nick)s: ') % {
|
|
| 190 | 169 |
'muc_nick': line.contact_name})
|
| 191 |
- last_message_box.add(self._nick_label)
|
|
| 170 |
+ self._ui.nick_label.show()
|
|
| 192 | 171 |
|
| 193 |
- # TODO: file transfers have to be displayed differently
|
|
| 172 |
+ # TODO: file transfers have to be displayed differently
|
|
| 194 | 173 |
|
| 195 | 174 |
self._timestamp = line.time
|
| 196 | 175 |
uf_timestamp = get_uf_relative_time(line.time)
|
| 197 |
- self._timestamp_label.set_text(uf_timestamp)
|
|
| 198 |
- |
|
| 199 |
- last_message_box.add(self._last_message_label)
|
|
| 200 |
- |
|
| 201 |
- self._unread_label = Gtk.Label()
|
|
| 202 |
- self._unread_label.set_no_show_all(True)
|
|
| 203 |
- self._unread_label.set_halign(Gtk.Align.END)
|
|
| 204 |
- self._unread_label.get_style_context().add_class('unread-counter')
|
|
| 205 |
- |
|
| 206 |
- close_button = Gtk.Button.new_from_icon_name(
|
|
| 207 |
- 'window-close-symbolic', Gtk.IconSize.BUTTON)
|
|
| 208 |
- close_button.set_valign(Gtk.Align.CENTER)
|
|
| 209 |
- close_button.set_tooltip_text(_('Close'))
|
|
| 210 |
- close_button.get_style_context().add_class('revealer-close-button')
|
|
| 211 |
- close_button.get_style_context().add_class('flat')
|
|
| 212 |
- close_button.connect('clicked', self._on_close_button_clicked)
|
|
| 213 |
- self._revealer = Gtk.Revealer()
|
|
| 214 |
- self._revealer.set_transition_type(
|
|
| 215 |
- Gtk.RevealerTransitionType.CROSSFADE)
|
|
| 216 |
- self._revealer.set_halign(Gtk.Align.END)
|
|
| 217 |
- self._revealer.add(close_button)
|
|
| 218 |
- |
|
| 219 |
- meta_box = Gtk.Box(spacing=6)
|
|
| 220 |
- meta_box.pack_start(chat_name_label, False, True, 0)
|
|
| 221 |
- meta_box.pack_end(self._unread_label, False, True, 0)
|
|
| 222 |
- meta_box.pack_end(self._timestamp_label, False, True, 0)
|
|
| 223 |
- |
|
| 224 |
- text_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
|
| 225 |
- text_box.add(meta_box)
|
|
| 226 |
- text_box.add(last_message_box)
|
|
| 227 |
- |
|
| 228 |
- main_box = Gtk.Box(spacing=12)
|
|
| 229 |
- main_box.pack_start(account_bar, False, True, 0)
|
|
| 230 |
- main_box.pack_start(avatar_image, False, True, 0)
|
|
| 231 |
- main_box.pack_start(text_box, True, True, 0)
|
|
| 232 |
- |
|
| 233 |
- overlay = Gtk.Overlay()
|
|
| 234 |
- overlay.add(main_box)
|
|
| 235 |
- overlay.add_overlay(self._revealer)
|
|
| 236 |
- |
|
| 237 |
- self.add(overlay)
|
|
| 176 |
+ self._ui.timestamp_label.set_text(uf_timestamp)
|
|
| 177 |
+ |
|
| 238 | 178 |
self.show_all()
|
| 239 | 179 |
|
| 240 | 180 |
def _on_state_flags_changed(self, _listboxrow, *args):
|
| 241 | 181 |
state = self.get_state_flags()
|
| 242 | 182 |
if (state & Gtk.StateFlags.PRELIGHT) != 0:
|
| 243 |
- self._revealer.set_reveal_child(True)
|
|
| 183 |
+ self._ui.revealer.set_reveal_child(True)
|
|
| 244 | 184 |
else:
|
| 245 |
- self._revealer.set_reveal_child(False)
|
|
| 185 |
+ self._ui.revealer.set_reveal_child(False)
|
|
| 246 | 186 |
|
| 247 | 187 |
def _on_close_button_clicked(self, _button):
|
| 248 | 188 |
app.window.remove_chat(self.workspace_id, self.account, self.jid)
|
| 249 | 189 |
|
| 250 | 190 |
def update_time(self):
|
| 251 | 191 |
if self._timestamp is not None:
|
| 252 |
- uf_timestamp = get_uf_relative_time(self._timestamp)
|
|
| 253 |
- self._timestamp_label.set_text(uf_timestamp)
|
|
| 192 |
+ self._ui.timestamp_label.set_text(
|
|
| 193 |
+ get_uf_relative_time(self._timestamp))
|
|
| 254 | 194 |
|
| 255 | 195 |
def add_unread(self):
|
| 256 | 196 |
self._unread_count += 1
|
| 257 |
- self._unread_label.set_text(str(self._unread_count))
|
|
| 258 |
- self._unread_label.show()
|
|
| 197 |
+ self._ui.unread_label.set_text(str(self._unread_count))
|
|
| 198 |
+ self._ui.unread_label.show()
|
|
| 259 | 199 |
|
| 260 | 200 |
def set_last_message_text(self, nickname, text):
|
| 261 |
- self._last_message_label.set_text(text)
|
|
| 262 |
- self._nick_label.set_text(nickname)
|
|
| 201 |
+ self._ui.message_label.set_text(text)
|
|
| 202 |
+ self._ui.nick_label.set_text(nickname)
|