Skip to content

Commit

Permalink
Populate the flowbox for #20
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed Feb 9, 2020
1 parent c9ad02c commit 9dc9622
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- TODO
- [ ] tex support sucks, remove it entirely
- [ ] faire une stack (?????|style) pour ce pauvre dialogue d'export
- [ ] casser prefs_and_export en 2 mais intelligemment
- [ ] help labels and links for pandoc too! et toutes les pages en fait
- [ ] CSS for admonitions (and other default plugins ?)
Expand Down
2 changes: 1 addition & 1 deletion markdown_preview/prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<object class="GtkStack" id="stack">
<property name="margin">10</property>
<property name="visible">True</property>
<property name="transition-type">crossfade</property>
<property name="transition-type">slide-up-down</property>

<child>
<object class="GtkBox" id="general_box">
Expand Down
57 changes: 55 additions & 2 deletions markdown_preview/prefs_and_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@
'custom': _("Custom command line")
}

REVEALJS_TRANSITIONS = {
'none': _("None"),
'fade': _("Fade"),
'slide': _("Slide"),
'convex': _("Cube (convex)"),
'concave': _("Cube (concave)"),
'zoom': _("Zoom")
}

REVEALJS_THEMES = {
'beige': _("Beige"),
'black': _("Black"),
'blood': _("Blood"),
'league': _("League"),
'moon': _("Moon"),
'night': _("Night"),
'serif': _("Serif"),
'simple': _("Simple"),
'sky': _("Sky"),
'solarized': _("Solarized"),
'white': _("White")
}

################################################################################

class MdRevealjsSettings():
Expand All @@ -105,10 +128,37 @@ def __init__(self, settings, parent_widget):
self.full_widget = builder.get_object('revealjs_box')

self.transitions_flowbox = builder.get_object('transitions_flowbox')
self.fill_flowbox(self.transitions_flowbox, 'revealjs-transitions', \
REVEALJS_TRANSITIONS)
self.theme_flowbox = builder.get_object('theme_flowbox')
self.fill_flowbox(self.theme_flowbox, 'revealjs-theme', REVEALJS_THEMES)

self.slide_num_switch = builder.get_object('slide_number_switch')
# TODO

def fill_flowbox(self, flowbox, setting_key, labels_dict):
self._radio_are_active = False
w0 = None
for id0 in labels_dict:
w0 = self.build_radio_btn(labels_dict[id0], id0, setting_key, w0)
flowbox.add(w0)
self._radio_are_active = True

def build_radio_btn(self, label, btn_id, key, group):
btn = Gtk.RadioButton(label=label, visible=True, group=group)
active_id = self._settings.get_string(key)
btn.set_active(btn_id == active_id)
btn.connect('toggled', self.on_radio_btn_changed, key, btn_id)
return btn

def on_radio_btn_changed(self, radiobtn, key, btn_id):
if not self._radio_are_active:
return
if key == 'revealjs-theme':
pass
elif key == 'revealjs-transitions':
pass

############################################################################
################################################################################

Expand Down Expand Up @@ -158,7 +208,7 @@ def _on_choose_css(self, *args):
if response == Gtk.ResponseType.ACCEPT:
self.css_uri = file_chooser.get_uri()
self._update_file_chooser_btn_label()
self.parent_widget.update_css(self.switch_css.get_active(), self.css_uri)
self.parent_widget.update_css(self.is_active(), self.css_uri)
file_chooser.destroy()

def _update_file_chooser_btn_label(self):
Expand All @@ -169,6 +219,9 @@ def _update_file_chooser_btn_label(self):
label = '…' + label[-45:]
self.style_label.set_label(label)

def is_active(self):
return self.switch_css.get_active()

############################################################################
################################################################################

Expand Down Expand Up @@ -417,7 +470,7 @@ def export_p3md(self):
start, end = doc.get_bounds()
unsaved_text = doc.get_text(start, end, True)
content = markdown.markdown(unsaved_text, extensions=md_extensions)
if self.css_manager.switch_css.get_active():
if self.css_manager.is_active():
pre_string = '<html><head><meta charset="utf-8" />' + \
'<link rel="stylesheet" href="' + self.css_manager.css_uri + \
'" /></head><body>'
Expand Down
40 changes: 29 additions & 11 deletions org.gnome.gedit.plugins.markdown_preview.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,37 @@
</key>
<key type="b" name="auto-reload">
<default>true</default>
<summary></summary>
<summary>Automatically reload the preview</summary>
<description></description>
</key>

<key type="b" name="use-style">
<default>false</default>
<summary>Use a stylesheet</summary>
<description></description>
</key>
<key type="s" name="style">
<default>''</default>
<summary>Stylesheet URI</summary>
<description></description>
</key>

<key type="s" name="revealjs-theme">
<default>'black'</default>
<summary>Name of the revealjs theme</summary>
<description>Values can be </description>
</key>
<key type="s" name="revealjs-transitions">
<default>'none'</default>
<summary>Type of transitions</summary>
<description>Values can be </description>
</key>
<key type="b" name="revealjs-slide-num">
<default>true</default>
<summary>Display slide numbers</summary>
<description></description>
</key>

<key type="s" name="backend">
<default>'pandoc'</default>
<summary>Favorite backend for the preview</summary>
Expand All @@ -37,16 +65,6 @@
<summary>Custom rendering command</summary>
<description></description>
</key>
<key type="b" name="use-style">
<default>false</default>
<summary>Use a stylesheet</summary>
<description></description>
</key>
<key type="s" name="style">
<default>""</default>
<summary>Stylesheet URI</summary>
<description></description>
</key>
<key type="as" name="extensions">
<default>['extra', 'sane_lists', 'toc']</default>
<summary>Enabled extensions</summary>
Expand Down

0 comments on commit 9dc9622

Please sign in to comment.