Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Frontend-GNOME] Calculate best topic heigth in TopicScrolledWindow.S…

…izeRequested instead of GroupChatView.ApplyConfig() (closes: #470)
  • Loading branch information...
commit 61283473974d7ef4a4427b80bb9d398b9380a482 1 parent 0873d5a
@meebey authored
Showing with 15 additions and 9 deletions.
  1. +15 −9 src/Frontend-GNOME/Views/Chats/GroupChatView.cs
View
24 src/Frontend-GNOME/Views/Chats/GroupChatView.cs
@@ -188,6 +188,21 @@ public GroupChatView(GroupChatModel groupChat) : base(groupChat)
_TopicScrolledWindow.ShowAll();
_TopicScrolledWindow.Visible = false;
_TopicScrolledWindow.NoShowAll = true;
+ _TopicScrolledWindow.SizeRequested += delegate(object o, Gtk.SizeRequestedArgs args) {
+ // predict and set useful topic heigth
+ Pango.Layout layout = _TopicTextView.CreatePangoLayout("Test Topic");
+ int lineWidth, lineHeigth;
+ layout.GetPixelSize(out lineWidth, out lineHeigth);
+ var lineSpacing = _TopicTextView.PixelsAboveLines +
+ _TopicTextView.PixelsBelowLines;
+ var text = Topic != null ? Topic.ToString() : String.Empty;
+ // hardcoded to 2 lines for now
+ var newLines = text.Length > 0 ? 2 : 0;
+ var bestSize = new Gtk.Requisition() {
+ Height = ((lineHeigth + lineSpacing) * newLines) + 2
+ };
+ args.Requisition = bestSize;
+ };
Add(_OutputHPaned);
@@ -457,15 +472,6 @@ public override void ApplyConfig(UserConfig config)
// topic
_TopicTextView.ApplyConfig(config);
- // predict and set useful topic heigth
- Pango.Layout layout = _TopicTextView.CreatePangoLayout("Test Topic");
- int lineWidth, lineHeigth;
- layout.GetPixelSize(out lineWidth, out lineHeigth);
- // use 2 lines + a bit extra as the topic heigth
- int bestHeigth = (lineHeigth * 2) + 5;
- _TopicTextView.HeightRequest = bestHeigth;
- _TopicScrolledWindow.HeightRequest = bestHeigth;
-
string topic_pos = (string) config["Interface/Notebook/Channel/TopicPosition"];
if (_TopicScrolledWindow.IsAncestor(_OutputVBox)) {
_OutputVBox.Remove(_TopicScrolledWindow);
Please sign in to comment.
Something went wrong with that request. Please try again.