Replaced description labels with TextViews.

This commit is contained in:
Jordan Petridis 2017-11-01 17:36:47 +02:00
parent 0e6b6b2cce
commit fc761a963d
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
5 changed files with 54 additions and 43 deletions

View File

@ -10,7 +10,7 @@
**Would be nice:**
- [ ] Possibly Convert description labels to textview.
- [x] Possibly Convert description labels to textview.
- [ ] Make Podcast cover fetchng and loading not block the execution of the program at startup.
- [ ] Re-design EpisodeWidget.
- [ ] Lazy evaluate episode loading based on the podcast_widget's view scrolling.

View File

@ -11,23 +11,26 @@
<property name="margin_bottom">5</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="delete_button">
<property name="name">delete_button</property>
<object class="GtkButton" id="play_button">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="stock">gtk-media-play</property>
<property name="use_fallback">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
@ -60,26 +63,23 @@
</packing>
</child>
<child>
<object class="GtkButton" id="play_button">
<object class="GtkButton" id="delete_button">
<property name="name">delete_button</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-media-play</property>
<property name="use_fallback">True</property>
<property name="stock">gtk-delete</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
@ -161,21 +161,18 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="min_content_height">60</property>
<property name="max_content_height">400</property>
<property name="min_content_height">100</property>
<property name="max_content_height">600</property>
<property name="propagate_natural_width">True</property>
<property name="propagate_natural_height">True</property>
<child>
<object class="GtkViewport">
<object class="GtkTextView" id="desc_text_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="desc_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</object>
</child>
<property name="can_focus">True</property>
<property name="margin_bottom">5</property>
<property name="editable">False</property>
<property name="wrap_mode">word-char</property>
<property name="cursor_visible">False</property>
</object>
</child>
</object>
@ -189,7 +186,7 @@
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>

View File

@ -136,23 +136,31 @@ Warn: This will delete downloaded content associated with this Podcast.</propert
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="description_label">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">30</property>
<property name="lines">5</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<property name="min_content_width">200</property>
<property name="max_content_width">200</property>
<property name="propagate_natural_width">True</property>
<property name="propagate_natural_height">True</property>
<child>
<object class="GtkTextView" id="desc_text_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="wrap_mode">word-char</property>
<property name="cursor_visible">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@ -160,21 +168,21 @@ Warn: This will delete downloaded content associated with this Podcast.</propert
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>

View File

@ -17,7 +17,7 @@ use std::path::Path;
use glib;
use gtk;
use gtk::prelude::*;
use gtk::ContainerExt;
use gtk::{ContainerExt, TextBufferExt};
// http://gtk-rs.org/tuto/closures
// FIXME: Atm this macro is copied into every module.
@ -57,11 +57,11 @@ fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::
let unplayed_button: gtk::Button = builder.get_object("mark_unplayed_button").unwrap();
let title_label: gtk::Label = builder.get_object("title_label").unwrap();
let desc_label: gtk::Label = builder.get_object("desc_label").unwrap();
// let desc_label: gtk::Label = builder.get_object("desc_label").unwrap();
let expander: gtk::Expander = builder.get_object("expand_desc").unwrap();
let desc_text_view: gtk::TextView = builder.get_object("desc_text_view").unwrap();
title_label.set_xalign(0.0);
desc_label.set_xalign(0.0);
if let Some(t) = episode.title() {
title_label.set_text(t);
@ -72,7 +72,9 @@ fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::
expander.connect_activate(move |_| {
let plain_text = strip_html_tags(&d).join(" ");
desc_label.set_text(plain_text.trim())
// TODO: handle unwrap
let buff = desc_text_view.get_buffer().unwrap();
buff.set_text(plain_text.trim());
});
}

View File

@ -38,7 +38,8 @@ pub fn podcast_widget(db: &Database, stack: &gtk::Stack, pd: &Podcast) -> gtk::B
let cover: gtk::Image = pd_widget_buidler.get_object("cover").unwrap();
let title_label: gtk::Label = pd_widget_buidler.get_object("title_label").unwrap();
let desc_label: gtk::Label = pd_widget_buidler.get_object("description_label").unwrap();
// let desc_label: gtk::Label = pd_widget_buidler.get_object("description_label").unwrap();
let desc_text_view: gtk::TextView = pd_widget_buidler.get_object("desc_text_view").unwrap();
let view: gtk::Viewport = pd_widget_buidler.get_object("view").unwrap();
let unsub_button: gtk::Button = pd_widget_buidler.get_object("unsub_button").unwrap();
let played_button: gtk::Button = pd_widget_buidler
@ -56,7 +57,10 @@ pub fn podcast_widget(db: &Database, stack: &gtk::Stack, pd: &Podcast) -> gtk::B
view.add(&l);
}
desc_label.set_text(pd.description());
{
let buff = desc_text_view.get_buffer().unwrap();
buff.set_text(pd.description());
}
let img = get_pixbuf_from_path(pd.image_uri(), pd.title());
if let Some(i) = img {