forked from Mirrors/apostrophe
externalize export popover
parent
5b1571293c
commit
b70416709c
|
@ -7,6 +7,7 @@
|
||||||
<file compressed="true" alias="icons/scalable/status/preview-layout-half-height-symbolic.svg">media/icons/preview-layout-half-height-symbolic.svg</file>
|
<file compressed="true" alias="icons/scalable/status/preview-layout-half-height-symbolic.svg">media/icons/preview-layout-half-height-symbolic.svg</file>
|
||||||
<file compressed="true">media/css/gtk/base.css</file>
|
<file compressed="true">media/css/gtk/base.css</file>
|
||||||
<file compressed="true" preprocess="xml-stripblanks">ui/Export.ui</file>
|
<file compressed="true" preprocess="xml-stripblanks">ui/Export.ui</file>
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks">ui/ExportPopover.ui</file>
|
||||||
<file compressed="true" preprocess="xml-stripblanks">ui/Menu.ui</file>
|
<file compressed="true" preprocess="xml-stripblanks">ui/Menu.ui</file>
|
||||||
<file compressed="true" preprocess="xml-stripblanks">ui/Preferences.ui</file>
|
<file compressed="true" preprocess="xml-stripblanks">ui/Preferences.ui</file>
|
||||||
<file compressed="true" preprocess="xml-stripblanks">ui/Recents.ui</file>
|
<file compressed="true" preprocess="xml-stripblanks">ui/Recents.ui</file>
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.22.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.20"/>
|
||||||
|
<object class="GtkPopover" id="export_menu">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin">12</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="action_name">app.save_as</property>
|
||||||
|
<property name="text" translatable="yes">Save as...</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparator">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="action_name">app.export</property>
|
||||||
|
<property name="action_target">"pdf"</property>
|
||||||
|
<property name="text" translatable="yes">Pdf</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="action_name">app.export</property>
|
||||||
|
<property name="action_target">"html"</property>
|
||||||
|
<property name="text" translatable="yes">Html</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="action_name">app.export</property>
|
||||||
|
<property name="action_target">"odt"</property>
|
||||||
|
<property name="text" translatable="yes">ODT</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="action_name">app.export</property>
|
||||||
|
<property name="action_target">"advanced"</property>
|
||||||
|
<property name="text" translatable="yes">Advanced</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
|
@ -46,97 +46,6 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="icon_name">view-restore-symbolic</property>
|
<property name="icon_name">view-restore-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkPopover" id="export_menu">
|
|
||||||
<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">12</property>
|
|
||||||
<property name="margin_right">12</property>
|
|
||||||
<property name="margin_top">12</property>
|
|
||||||
<property name="margin_bottom">12</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkModelButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="action_name">app.save_as</property>
|
|
||||||
<property name="text" translatable="yes">Save as...</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSeparator">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkModelButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="text" translatable="yes">Pdf</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkModelButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="text" translatable="yes">Html</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkModelButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="text" translatable="yes">ODT</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkModelButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="text" translatable="yes">Advanced</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkImage" id="new_icon">
|
<object class="GtkImage" id="new_icon">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -331,7 +240,6 @@
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Save as...</property>
|
<property name="tooltip_text" translatable="yes">Save as...</property>
|
||||||
<property name="popover">export_menu</property>
|
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Application(Gtk.Application):
|
||||||
action.connect("activate", self.on_save_as)
|
action.connect("activate", self.on_save_as)
|
||||||
self.add_action(action)
|
self.add_action(action)
|
||||||
|
|
||||||
action = Gio.SimpleAction.new("export", None)
|
action = Gio.SimpleAction.new("export", GLib.VariantType("s"))
|
||||||
action.connect("activate", self.on_export)
|
action.connect("activate", self.on_export)
|
||||||
self.add_action(action)
|
self.add_action(action)
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@ class Application(Gtk.Application):
|
||||||
def on_save_as(self, _action, _value):
|
def on_save_as(self, _action, _value):
|
||||||
self.window.save_document_as()
|
self.window.save_document_as()
|
||||||
|
|
||||||
def on_export(self, _action, _value):
|
def on_export(self, _action, value):
|
||||||
self.window.open_advanced_export()
|
self.window.open_advanced_export(value.get_string())
|
||||||
|
|
||||||
def on_copy_html(self, _action, _value):
|
def on_copy_html(self, _action, _value):
|
||||||
self.window.copy_html_to_clipboard()
|
self.window.copy_html_to_clipboard()
|
||||||
|
|
|
@ -39,6 +39,35 @@ class Export:
|
||||||
|
|
||||||
__gtype_name__ = "export_dialog"
|
__gtype_name__ = "export_dialog"
|
||||||
|
|
||||||
|
export_menu = {
|
||||||
|
"pdf":
|
||||||
|
{
|
||||||
|
"extension": "pdf",
|
||||||
|
"name": "PDF",
|
||||||
|
"mimetype": "application/pdf",
|
||||||
|
"dialog": regular_export_dialog()
|
||||||
|
},
|
||||||
|
"html":
|
||||||
|
{
|
||||||
|
"extension": "html",
|
||||||
|
"name": "HTML",
|
||||||
|
"mimetype": "text/html"
|
||||||
|
},
|
||||||
|
"odt":
|
||||||
|
{
|
||||||
|
"extension": "odt",
|
||||||
|
"name": "ODT",
|
||||||
|
"mimetype": "application/vnd.oasis.opendocument.text"
|
||||||
|
},
|
||||||
|
"advanced":
|
||||||
|
{
|
||||||
|
"extension": "",
|
||||||
|
"name": "",
|
||||||
|
"mimetype": "",
|
||||||
|
"dialog": advanced_export_dialog()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
formats = [
|
formats = [
|
||||||
{
|
{
|
||||||
"name": "LaTeX (pdf)",
|
"name": "LaTeX (pdf)",
|
||||||
|
@ -147,12 +176,30 @@ class Export:
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename, export_format):
|
||||||
"""Set up the about dialog"""
|
"""Set up the export dialog"""
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_resource(
|
self.builder.add_from_resource(
|
||||||
"/de/wolfvollprecht/UberWriter/ui/Export.ui")
|
"/de/wolfvollprecht/UberWriter/ui/Export.ui")
|
||||||
self.dialog = self.builder.get_object("Export")
|
#self.dialog = self.builder.get_object("Export")
|
||||||
|
|
||||||
|
self.dialog = Gtk.FileChooserNative.new(_("Export"),
|
||||||
|
None,
|
||||||
|
Gtk.FileChooserAction.SAVE,
|
||||||
|
_("Export to %s") %
|
||||||
|
self.export_menu[export_format]["extension"],
|
||||||
|
_("Cancel"))
|
||||||
|
print(self.export_menu[export_format]["mimetype"])
|
||||||
|
filter = Gtk.FileFilter.new()
|
||||||
|
filter.set_name(self.export_menu[export_format]["name"])
|
||||||
|
filter.add_mime_type(self.export_menu[export_format]["mimetype"])
|
||||||
|
self.dialog.add_filter(filter)
|
||||||
|
self.dialog.set_do_overwrite_confirmation(True)
|
||||||
|
self.dialog.set_current_name("%s.%s" % (filename, self.export_menu[export_format]["extension"]))
|
||||||
|
#filechooser.connect("response", self.__on_save_response)
|
||||||
|
#filechooser.run()
|
||||||
|
|
||||||
|
|
||||||
self.stack = self.builder.get_object("export_stack")
|
self.stack = self.builder.get_object("export_stack")
|
||||||
self.stack_switcher = self.builder.get_object("format_switcher")
|
self.stack_switcher = self.builder.get_object("format_switcher")
|
||||||
|
|
||||||
|
@ -196,6 +243,9 @@ class Export:
|
||||||
self.format_field.add_attribute(format_renderer, "text", 1)
|
self.format_field.add_attribute(format_renderer, "text", 1)
|
||||||
self.format_field.set_active(0)
|
self.format_field.set_active(0)
|
||||||
|
|
||||||
|
def regular_export_dialog():
|
||||||
|
|
||||||
|
|
||||||
def export(self, text=""):
|
def export(self, text=""):
|
||||||
"""Export the given text using the specified format.
|
"""Export the given text using the specified format.
|
||||||
For advanced export, this includes special flags for the enabled options.
|
For advanced export, this includes special flags for the enabled options.
|
||||||
|
@ -330,6 +380,7 @@ class Export:
|
||||||
else:
|
else:
|
||||||
export_btn.set_sensitive(True)
|
export_btn.set_sensitive(True)
|
||||||
|
|
||||||
|
|
||||||
def disabled_text():
|
def disabled_text():
|
||||||
"""Return the TexLive installation instructions
|
"""Return the TexLive installation instructions
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ class BaseHeaderbar:
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_resource(
|
self.builder.add_from_resource(
|
||||||
"/de/wolfvollprecht/UberWriter/ui/Headerbar.ui")
|
"/de/wolfvollprecht/UberWriter/ui/Headerbar.ui")
|
||||||
|
self.builder.add_from_resource(
|
||||||
|
"/de/wolfvollprecht/UberWriter/ui/ExportPopover.ui")
|
||||||
|
|
||||||
self.hb = self.builder.get_object(
|
self.hb = self.builder.get_object(
|
||||||
"Headerbar")
|
"Headerbar")
|
||||||
|
@ -63,8 +65,11 @@ class BaseHeaderbar:
|
||||||
self.menu_button = self.builder.get_object("menu_button")
|
self.menu_button = self.builder.get_object("menu_button")
|
||||||
self.recents_button = self.builder.get_object("recents_button")
|
self.recents_button = self.builder.get_object("recents_button")
|
||||||
self.export_button = self.builder.get_object("export_button")
|
self.export_button = self.builder.get_object("export_button")
|
||||||
|
export_popover = self.builder.get_object("export_menu")
|
||||||
self.preview_switch_button = self.builder.get_object("preview_switch_button")
|
self.preview_switch_button = self.builder.get_object("preview_switch_button")
|
||||||
|
|
||||||
|
self.export_button.set_popover(export_popover)
|
||||||
|
|
||||||
add_menus(self, app)
|
add_menus(self, app)
|
||||||
|
|
||||||
settings = Gtk.Settings.get_default()
|
settings = Gtk.Settings.get_default()
|
||||||
|
|
|
@ -544,11 +544,11 @@ class MainWindow(StyledWindow):
|
||||||
|
|
||||||
self.searchreplace.toggle_search(replace=replace)
|
self.searchreplace.toggle_search(replace=replace)
|
||||||
|
|
||||||
def open_advanced_export(self, _widget=None, _data=None):
|
def open_advanced_export(self, export_format):
|
||||||
"""open the export and advanced export dialog
|
"""open the export and advanced export dialog
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.export = Export(self.filename)
|
self.export = Export(self.filename, export_format)
|
||||||
self.export.dialog.set_transient_for(self)
|
self.export.dialog.set_transient_for(self)
|
||||||
|
|
||||||
response = self.export.dialog.run()
|
response = self.export.dialog.run()
|
||||||
|
|
Loading…
Reference in New Issue