Commit ed3a7283 authored by Christopher Davis's avatar Christopher Davis 🌱

Added markdown popover

parent 42a41b08
......@@ -21,5 +21,6 @@
<file preprocess="xml-stripblanks">ui/room_config.ui</file>
<file preprocess="xml-stripblanks">ui/room_menu.ui</file>
<file preprocess="xml-stripblanks">ui/user_menu.ui</file>
<file preprocess="xml-stripblanks">ui/markdown_popover.ui</file>
</gresource>
</gresources>
......@@ -304,15 +304,15 @@
</packing>
</child>
<child>
<object class="GtkToggleButton" id="markdown_button">
<object class="GtkMenuButton" id="markdown_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<object class="GtkImage" id="md_img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">format-indent-more-symbolic</property>
<property name="icon_name">format-justify-left-symbolic</property>
</object>
</child>
</object>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopover" id="markdown_popover">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Markdown</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="markdown_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="tutorial_text_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">40</property>
<property name="label" translatable="yes">&gt; quote</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">**bold**</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">40</property>
<property name="label" translatable="yes">`code`</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">*italic*</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
......@@ -2911,13 +2911,32 @@ impl App {
}
fn connect_markdown(&self) {
let toggle_button: gtk::ToggleButton = self.ui.builder
let md_popover_btn: gtk::MenuButton = self.ui.builder
.get_object("markdown_button")
.expect("Couldn't find markdown_button in ui file.");
let popover: gtk::Popover = self.ui.builder
.get_object("markdown_popover")
.expect("Couldn't find markdown_popover in ui file.");
let markdown_switch: gtk::Switch = self.ui.builder
.get_object("markdown_switch")
.expect("Couldn't find markdown_switch in ui file.");
let md_img = self.ui.builder
.get_object::<gtk::Image>("md_img")
.expect("Couldn't find md_img in ui file.");
md_popover_btn.set_popover(Some(&popover));
let op = self.op.clone();
toggle_button.clone().connect_clicked(move |_| {
op.lock().unwrap().md_enabled = toggle_button.get_active();
markdown_switch.clone().connect_property_active_notify(move |_| {
op.lock().unwrap().md_enabled = markdown_switch.get_active();
if !markdown_switch.get_active() {
md_img.set_from_icon_name("format-justify-left-symbolic",1);
} else {
md_img.set_from_icon_name("format-indent-more-symbolic",1);
}
});
}
......
......@@ -26,6 +26,8 @@ impl UI {
.expect("Can't load ui file: room_menu.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/members.ui")
.expect("Can't load ui file: members.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/markdown_popover.ui")
.expect("Can't load ui file: markdown_popover.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/main_window.ui")
.expect("Can't load ui file: main_window.ui");
......
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