feat: add message bubble
Build / Flatpak (x86_64) (push) Failing after 8m45s
Details
Build / Flatpak (x86_64) (push) Failing after 8m45s
Details
This commit is contained in:
parent
dbfe5b4eb9
commit
31689a1d72
|
@ -2,6 +2,7 @@
|
|||
<gresources>
|
||||
<gresource prefix="/io/github/Bavarder/Bavarder">
|
||||
<file preprocess="xml-stripblanks">ui/window.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/message_bubble.ui</file>
|
||||
<file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/help-overlay.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/preferences.ui</file>
|
||||
<file>style.css</file>
|
||||
|
|
|
@ -2,6 +2,7 @@ blueprints = custom_target('blueprints',
|
|||
input: files(
|
||||
'help-overlay.blp',
|
||||
'preferences.blp',
|
||||
'message_bubble.blp',
|
||||
'window.blp',
|
||||
),
|
||||
output: '.',
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $MessageBubble: Gtk.Box {
|
||||
orientation: vertical;
|
||||
|
||||
Label sender_label {
|
||||
styles ["caption-heading"]
|
||||
|
||||
ellipsize: end;
|
||||
xalign: 0;
|
||||
}
|
||||
|
||||
Adw.Bin message_reply_bin {}
|
||||
|
||||
Adw.Bin prefix_bin {}
|
||||
|
||||
Label message_label {
|
||||
}
|
||||
}
|
|
@ -30,4 +30,5 @@ bavarder_sources = [
|
|||
PY_INSTALLDIR.install_sources(bavarder_sources, subdir: moduledir)
|
||||
|
||||
subdir('providers')
|
||||
subdir('views')
|
||||
subdir('views')
|
||||
subdir('widgets')
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
widgets_dir = join_paths(moduledir, 'widgets')
|
||||
|
||||
widgets_sources = [
|
||||
'__init__.py',
|
||||
'message_bubble.py',
|
||||
]
|
||||
|
||||
PY_INSTALLDIR.install_sources(widgets_sources, subdir: widgets_dir)
|
|
@ -0,0 +1,59 @@
|
|||
from gi.repository import Adw, Gtk, Gio
|
||||
|
||||
from bavarder.constants import app_id, build_type
|
||||
|
||||
MAX_WIDTH = 400
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/Bavarder/Bavarder/ui/message_bubble.ui")
|
||||
class MessageBubble(Gtk.Box):
|
||||
__gtype_name__ = "MessageBubble"
|
||||
|
||||
sender_label = Gtk.Template.Child()
|
||||
message_reply_bin = Gtk.Template.Child()
|
||||
prefix_bin = Gtk.Template.Child()
|
||||
message_label = Gtk.Template.Child()
|
||||
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.app = Gtk.Application.get_default()
|
||||
|
||||
|
||||
# def measure(self, orientation, , for_size):
|
||||
# # Limit the widget width
|
||||
# if orientation == Gtk.Orientation.HORIZONTAL:
|
||||
# minimum, natural, minimum_baseline, natural_baseline = \
|
||||
# self.overlay.measure(orientation, for_size)
|
||||
|
||||
# return (
|
||||
# minimum.min(MAX_WIDTH),
|
||||
# natural.min(MAX_WIDTH),
|
||||
# minimum_baseline,
|
||||
# natural_baseline,
|
||||
# )
|
||||
# else:
|
||||
# adjusted_for_size = for_size.min(MAX_WIDTH);
|
||||
# self.overlay.measure(orientation, adjusted_for_size)
|
||||
#
|
||||
#
|
||||
|
||||
# def size_allocate(self, width, height, baseline):
|
||||
# self.overlay.allocate(width, height, baseline, None)
|
||||
#
|
||||
|
||||
# def request_mode(self):
|
||||
# return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
|
||||
|
||||
def set_label(self, label):
|
||||
if label.is_empty():
|
||||
self.message_label.set_label("")
|
||||
self..message_label.set_visible(false)
|
||||
|
||||
self.remove_css_class("with-label")
|
||||
else:
|
||||
self.message_label.set_label(label)
|
||||
self.message_label.set_visible(true)
|
||||
|
||||
self.add_css_class("with-label")
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
from gi.repository import Adw
|
||||
from gi.repository import Gtk, Gio
|
||||
|
||||
from bavarder.widgets.message_bubble import MessageBubble
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/Bavarder/Bavarder/ui/window.ui")
|
||||
class BavarderWindow(Adw.ApplicationWindow):
|
||||
|
@ -64,4 +65,4 @@ class BavarderWindow(Adw.ApplicationWindow):
|
|||
)
|
||||
self.settings.bind(
|
||||
"is-fullscreen", self, "fullscreened", Gio.SettingsBindFlags.DEFAULT
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue