Commit 166d396c authored by Christopher Davis's avatar Christopher Davis 🌱 Committed by Daniel Garcia Moreno

Added format button

parent b0695894
...@@ -302,6 +302,25 @@ ...@@ -302,6 +302,25 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkToggleButton" id="markdown_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">format-indent-more-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkEntry" id="msg_entry"> <object class="GtkEntry" id="msg_entry">
<property name="can_focus">True</property> <property name="can_focus">True</property>
...@@ -311,7 +330,7 @@ ...@@ -311,7 +330,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
......
...@@ -115,6 +115,7 @@ pub struct AppOp { ...@@ -115,6 +115,7 @@ pub struct AppOp {
pub loading_more: bool, pub loading_more: bool,
pub invitation_roomid: Option<String>, pub invitation_roomid: Option<String>,
pub md_enabled: bool,
invite_list: Vec<Member>, invite_list: Vec<Member>,
search_type: SearchType, search_type: SearchType,
} }
...@@ -213,6 +214,7 @@ impl AppOp { ...@@ -213,6 +214,7 @@ impl AppOp {
logged_in: false, logged_in: false,
loading_more: false, loading_more: false,
md_enabled: false,
invitation_roomid: None, invitation_roomid: None,
invite_list: vec![], invite_list: vec![],
search_type: SearchType::Invite, search_type: SearchType::Invite,
...@@ -1376,7 +1378,7 @@ impl AppOp { ...@@ -1376,7 +1378,7 @@ impl AppOp {
// Riot does not properly show emotes with Markdown; // Riot does not properly show emotes with Markdown;
// Emotes with markdown have a newline after the username // Emotes with markdown have a newline after the username
if m.mtype != "m.emote" { if m.mtype != "m.emote" && self.md_enabled {
let md_parsed_msg = markdown_to_html(&msg, &ComrakOptions::default()); let md_parsed_msg = markdown_to_html(&msg, &ComrakOptions::default());
if md_parsed_msg != String::from("<p>") + &msg + &String::from("</p>\n") { if md_parsed_msg != String::from("<p>") + &msg + &String::from("</p>\n") {
...@@ -2455,6 +2457,7 @@ impl App { ...@@ -2455,6 +2457,7 @@ impl App {
self.connect_send(); self.connect_send();
self.connect_attach(); self.connect_attach();
self.connect_markdown();
self.connect_autocomplete(); self.connect_autocomplete();
self.connect_directory(); self.connect_directory();
...@@ -2910,6 +2913,17 @@ impl App { ...@@ -2910,6 +2913,17 @@ impl App {
}); });
} }
fn connect_markdown(&self) {
let toggle_button: gtk::ToggleButton = self.ui.builder
.get_object("markdown_button")
.expect("Couldn't find markdown_button in ui file.");
let op = self.op.clone();
toggle_button.clone().connect_clicked(move |_| {
op.lock().unwrap().md_enabled = toggle_button.get_active();
});
}
fn connect_login_view(&self) { fn connect_login_view(&self) {
let advbtn: gtk::Button = self.ui.builder let advbtn: gtk::Button = self.ui.builder
.get_object("login_advanced_button") .get_object("login_advanced_button")
......
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