forked from Mirrors/apostrophe
parent
325f5bb211
commit
7ed0ba1097
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<menu id="app-menu">
|
||||||
|
<section>
|
||||||
|
<attribute name="label" translatable="yes">Change label</attribute>
|
||||||
|
<item>
|
||||||
|
<!--
|
||||||
|
<attribute name="action">win.change_label</attribute>
|
||||||
|
<attribute name="target">String 1</attribute>
|
||||||
|
-->
|
||||||
|
<attribute name="label" translatable="yes">String 1</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">String 2</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">String 3</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="action">win.maximize</attribute>
|
||||||
|
<attribute name="label" translatable="yes">Maximize</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="action">app.about</attribute>
|
||||||
|
<attribute name="label" translatable="yes">_About</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="action">app.quit</attribute>
|
||||||
|
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||||
|
<attribute name="accel"><Primary>q</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
|
</interface>
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
depends="gtk+" version="3.26">
|
depends="gtk+" version="3.26">
|
||||||
<glade-widget-classes>
|
<glade-widget-classes>
|
||||||
<glade-widget-class title="Uberwriter Window" name="UberwriterWindow"
|
<glade-widget-class title="Uberwriter Window" name="UberwriterWindow"
|
||||||
generic-name="UberwriterWindow" parent="GtkWindow"
|
generic-name="UberwriterWindow" parent="GtkApplicationWindow"
|
||||||
icon-name="widget-gtk-window"/>
|
icon-name="widget-gtk-window"/>
|
||||||
</glade-widget-classes>
|
</glade-widget-classes>
|
||||||
</glade-catalog>
|
</glade-catalog>
|
||||||
|
|
|
@ -58,7 +58,8 @@ try:
|
||||||
except:
|
except:
|
||||||
APT_ENABLED = False
|
APT_ENABLED = False
|
||||||
|
|
||||||
from uberwriter_lib import Window
|
#from uberwriter_lib import Window
|
||||||
|
from uberwriter_lib import AppWindow
|
||||||
from uberwriter_lib import helpers
|
from uberwriter_lib import helpers
|
||||||
from .AboutUberwriterDialog import AboutUberwriterDialog
|
from .AboutUberwriterDialog import AboutUberwriterDialog
|
||||||
from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
|
from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
|
||||||
|
@ -70,9 +71,11 @@ from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
|
||||||
CONFIG_PATH = os.path.expanduser("~/.config/uberwriter/")
|
CONFIG_PATH = os.path.expanduser("~/.config/uberwriter/")
|
||||||
|
|
||||||
# See texteditor_lib.Window.py for more details about how this class works
|
# See texteditor_lib.Window.py for more details about how this class works
|
||||||
class UberwriterWindow(Window):
|
class UberwriterWindow(AppWindow.Application):
|
||||||
|
|
||||||
__gtype_name__ = "UberwriterWindow"
|
#__gtype_name__ = "UberwriterWindow"
|
||||||
|
|
||||||
|
print("hahah")
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'save-file': (GObject.SIGNAL_ACTION, None, ()),
|
'save-file': (GObject.SIGNAL_ACTION, None, ()),
|
||||||
|
|
|
@ -58,5 +58,5 @@ def main():
|
||||||
window = UberwriterWindow.UberwriterWindow()
|
window = UberwriterWindow.UberwriterWindow()
|
||||||
if options.experimental_features:
|
if options.experimental_features:
|
||||||
window.use_experimental_features(True)
|
window.use_experimental_features(True)
|
||||||
window.show()
|
window.run()
|
||||||
Gtk.main()
|
#Gtk.main()
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import gi
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
from gi.repository import GLib, Gio, Gtk
|
||||||
|
|
||||||
|
from . helpers import get_builder, show_uri, get_help_uri
|
||||||
|
|
||||||
|
class UberwriterWindow(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# This will be in the windows group and have the "win" prefix
|
||||||
|
max_action = Gio.SimpleAction.new_stateful("maximize", None,
|
||||||
|
GLib.Variant.new_boolean(False))
|
||||||
|
max_action.connect("change-state", self.on_maximize_toggle)
|
||||||
|
self.add_action(max_action)
|
||||||
|
|
||||||
|
# Keep it in sync with the actual state
|
||||||
|
self.connect("notify::is-maximized",
|
||||||
|
lambda obj, pspec: max_action.set_state(
|
||||||
|
GLib.Variant.new_boolean(obj.props.is_maximized)))
|
||||||
|
|
||||||
|
self.default_width = 800
|
||||||
|
self.defaul_height = 500
|
||||||
|
self.set_icon_from_file("data/media/uberwriter.svg")
|
||||||
|
|
||||||
|
builder = get_builder('UberwriterWindow')
|
||||||
|
new_object = builder.get_object("grid1")
|
||||||
|
|
||||||
|
|
||||||
|
self.builder = builder
|
||||||
|
self.ui = builder.get_ui(self, True)
|
||||||
|
self.PreferencesDialog = None # class
|
||||||
|
self.preferences_dialog = None # instance
|
||||||
|
self.AboutDialog = None # class
|
||||||
|
|
||||||
|
self.contents = new_object
|
||||||
|
self.add(self.contents)
|
||||||
|
|
||||||
|
self.finish_initializing(self.builder)
|
||||||
|
|
||||||
|
|
||||||
|
def on_maximize_toggle(self, action, value):
|
||||||
|
action.set_state(value)
|
||||||
|
if value.get_boolean():
|
||||||
|
self.maximize()
|
||||||
|
else:
|
||||||
|
self.unmaximize()
|
||||||
|
|
||||||
|
class Application(Gtk.Application):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, application_id="de.wolfvollprecht.UberWriter",
|
||||||
|
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
|
||||||
|
**kwargs)
|
||||||
|
self.window = None
|
||||||
|
|
||||||
|
self.add_main_option("test", ord("t"), GLib.OptionFlags.NONE,
|
||||||
|
GLib.OptionArg.NONE, "Command line test", None)
|
||||||
|
|
||||||
|
def do_startup(self):
|
||||||
|
Gtk.Application.do_startup(self)
|
||||||
|
|
||||||
|
# ~ action = Gio.SimpleAction.new("about", None)
|
||||||
|
# ~ action.connect("activate", self.on_about)
|
||||||
|
# ~ self.add_action(action)
|
||||||
|
|
||||||
|
action = Gio.SimpleAction.new("quit", None)
|
||||||
|
action.connect("activate", self.on_quit)
|
||||||
|
self.add_action(action)
|
||||||
|
|
||||||
|
builder = get_builder('App_menu')
|
||||||
|
self.set_app_menu(builder.get_object("app-menu"))
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
# We only allow a single window and raise any existing ones
|
||||||
|
if not self.window:
|
||||||
|
# Windows are associated with the application
|
||||||
|
# when the last one is closed the application shuts down
|
||||||
|
self.window = UberwriterWindow(application=self, title="UberWriter")
|
||||||
|
|
||||||
|
self.window.present()
|
||||||
|
|
||||||
|
def do_command_line(self, command_line):
|
||||||
|
options = command_line.get_options_dict()
|
||||||
|
|
||||||
|
if options.contains("test"):
|
||||||
|
# This is printed on the main instance
|
||||||
|
print("Test argument recieved")
|
||||||
|
|
||||||
|
self.activate()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# ~ def on_about(self, action, param):
|
||||||
|
# ~ about_dialog = Gtk.AboutDialog(transient_for=self.window, modal=True)
|
||||||
|
# ~ about_dialog.present()
|
||||||
|
|
||||||
|
def on_quit(self, action, param):
|
||||||
|
self.quit()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = Application()
|
||||||
|
app.run(sys.argv)
|
|
@ -24,7 +24,7 @@ from . helpers import get_builder, show_uri, get_help_uri
|
||||||
|
|
||||||
# This class is meant to be subclassed by UberwriterWindow. It provides
|
# This class is meant to be subclassed by UberwriterWindow. It provides
|
||||||
# common functions and some boilerplate.
|
# common functions and some boilerplate.
|
||||||
class Window(Gtk.ApplicationWindow):
|
class Window(Gtk.Application):
|
||||||
__gtype_name__ = "Window"
|
__gtype_name__ = "Window"
|
||||||
|
|
||||||
# To construct a new instance of this method, the following notable
|
# To construct a new instance of this method, the following notable
|
||||||
|
@ -43,11 +43,19 @@ class Window(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
Returns a fully instantiated BaseUberwriterWindow object.
|
Returns a fully instantiated BaseUberwriterWindow object.
|
||||||
"""
|
"""
|
||||||
|
App = Gtk.Application()
|
||||||
|
window = Gtk.ApplicationWindow()
|
||||||
|
|
||||||
|
|
||||||
builder = get_builder('UberwriterWindow')
|
builder = get_builder('UberwriterWindow')
|
||||||
new_object = builder.get_object("uberwriter_window")
|
new_object = builder.get_object("grid1")
|
||||||
new_object.finish_initializing(builder)
|
window.add(new_object)
|
||||||
return new_object
|
App.window = window
|
||||||
|
App.window.present()
|
||||||
|
#window.finish_initializing(builder)
|
||||||
|
|
||||||
|
return App
|
||||||
|
|
||||||
def finish_initializing(self, builder):
|
def finish_initializing(self, builder):
|
||||||
"""Called while initializing this instance in __new__
|
"""Called while initializing this instance in __new__
|
||||||
|
|
||||||
|
@ -61,7 +69,7 @@ class Window(Gtk.ApplicationWindow):
|
||||||
self.PreferencesDialog = None # class
|
self.PreferencesDialog = None # class
|
||||||
self.preferences_dialog = None # instance
|
self.preferences_dialog = None # instance
|
||||||
self.AboutDialog = None # class
|
self.AboutDialog = None # class
|
||||||
|
|
||||||
# self.settings = Gio.Settings("net.launchpad.uberwriter")
|
# self.settings = Gio.Settings("net.launchpad.uberwriter")
|
||||||
# self.settings.connect('changed', self.on_preferences_changed)
|
# self.settings.connect('changed', self.on_preferences_changed)
|
||||||
|
|
||||||
|
@ -77,6 +85,8 @@ class Window(Gtk.ApplicationWindow):
|
||||||
self.indicator = indicator.new_application_indicator(self)
|
self.indicator = indicator.new_application_indicator(self)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_mnu_contents_activate(self, widget, data=None):
|
def on_mnu_contents_activate(self, widget, data=None):
|
||||||
show_uri(self, "ghelp:%s" % get_help_uri())
|
show_uri(self, "ghelp:%s" % get_help_uri())
|
||||||
|
|
Loading…
Reference in New Issue