forked from Mirrors/apostrophe
parent
7ed0ba1097
commit
2723459cc2
|
@ -59,7 +59,7 @@ 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.AppWindow import Window
|
||||||
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
|
||||||
|
@ -71,12 +71,10 @@ 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(AppWindow.Application):
|
class UberwriterWindow(Window):
|
||||||
|
|
||||||
#__gtype_name__ = "UberwriterWindow"
|
#__gtype_name__ = "UberwriterWindow"
|
||||||
|
|
||||||
print("hahah")
|
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'save-file': (GObject.SIGNAL_ACTION, None, ()),
|
'save-file': (GObject.SIGNAL_ACTION, None, ()),
|
||||||
'open-file': (GObject.SIGNAL_ACTION, None, ()),
|
'open-file': (GObject.SIGNAL_ACTION, None, ()),
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
### END LICENSE
|
### END LICENSE
|
||||||
|
import sys
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
import locale
|
import locale
|
||||||
|
@ -24,6 +24,7 @@ locale.textdomain('uberwriter')
|
||||||
from gi.repository import Gtk # pylint: disable=E0611
|
from gi.repository import Gtk # pylint: disable=E0611
|
||||||
|
|
||||||
from . import UberwriterWindow
|
from . import UberwriterWindow
|
||||||
|
from uberwriter_lib import AppWindow
|
||||||
|
|
||||||
from uberwriter_lib import set_up_logging, get_version
|
from uberwriter_lib import set_up_logging, get_version
|
||||||
|
|
||||||
|
@ -50,13 +51,15 @@ def main():
|
||||||
(options, args) = parse_options()
|
(options, args) = parse_options()
|
||||||
|
|
||||||
# Run the application.
|
# Run the application.
|
||||||
if args:
|
# ~ if args:
|
||||||
for arg in args:
|
# ~ for arg in args:
|
||||||
window = UberwriterWindow.UberwriterWindow()
|
# ~ window = UberwriterWindow.UberwriterWindow()
|
||||||
window.load_file(arg)
|
# ~ window.load_file(arg)
|
||||||
else:
|
# ~ else:
|
||||||
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.run()
|
app = AppWindow.Application()
|
||||||
|
app.run(sys.argv)
|
||||||
|
|
||||||
#Gtk.main()
|
#Gtk.main()
|
||||||
|
|
|
@ -5,8 +5,9 @@ gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import GLib, Gio, Gtk
|
from gi.repository import GLib, Gio, Gtk
|
||||||
|
|
||||||
from . helpers import get_builder, show_uri, get_help_uri
|
from . helpers import get_builder, show_uri, get_help_uri
|
||||||
|
from uberwriter import UberwriterWindow
|
||||||
|
|
||||||
class UberwriterWindow(Gtk.ApplicationWindow):
|
class Window(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -29,18 +30,13 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
||||||
builder = get_builder('UberwriterWindow')
|
builder = get_builder('UberwriterWindow')
|
||||||
new_object = builder.get_object("grid1")
|
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.contents = new_object
|
||||||
self.add(self.contents)
|
self.add(self.contents)
|
||||||
|
|
||||||
|
self.finish_initializing(builder)
|
||||||
|
|
||||||
self.finish_initializing(self.builder)
|
return self
|
||||||
|
|
||||||
|
|
||||||
def on_maximize_toggle(self, action, value):
|
def on_maximize_toggle(self, action, value):
|
||||||
action.set_state(value)
|
action.set_state(value)
|
||||||
|
@ -48,6 +44,38 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
||||||
self.maximize()
|
self.maximize()
|
||||||
else:
|
else:
|
||||||
self.unmaximize()
|
self.unmaximize()
|
||||||
|
|
||||||
|
def finish_initializing(self, builder):
|
||||||
|
"""Called while initializing this instance in __new__
|
||||||
|
|
||||||
|
finish_initializing should be called after parsing the UI definition
|
||||||
|
and creating a UberwriterWindow object with it in order to finish
|
||||||
|
initializing the start of the new UberwriterWindow instance.
|
||||||
|
"""
|
||||||
|
# Get a reference to the builder and set up the signals.
|
||||||
|
self.builder = builder
|
||||||
|
self.ui = builder.get_ui(self, True)
|
||||||
|
self.PreferencesDialog = None # class
|
||||||
|
self.preferences_dialog = None # instance
|
||||||
|
self.AboutDialog = None # class
|
||||||
|
|
||||||
|
|
||||||
|
# self.settings = Gio.Settings("net.launchpad.uberwriter")
|
||||||
|
# self.settings.connect('changed', self.on_preferences_changed)
|
||||||
|
|
||||||
|
# Optional application indicator support
|
||||||
|
# Run 'quickly add indicator' to get started.
|
||||||
|
# More information:
|
||||||
|
# http://owaislone.org/quickly-add-indicator/
|
||||||
|
# https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators
|
||||||
|
try:
|
||||||
|
from uberwriter import indicator
|
||||||
|
# self is passed so methods of this class can be called from indicator.py
|
||||||
|
# Comment this next line out to disable appindicator
|
||||||
|
self.indicator = indicator.new_application_indicator(self)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Application(Gtk.Application):
|
class Application(Gtk.Application):
|
||||||
|
|
||||||
|
@ -74,12 +102,14 @@ class Application(Gtk.Application):
|
||||||
builder = get_builder('App_menu')
|
builder = get_builder('App_menu')
|
||||||
self.set_app_menu(builder.get_object("app-menu"))
|
self.set_app_menu(builder.get_object("app-menu"))
|
||||||
|
|
||||||
|
|
||||||
def do_activate(self):
|
def do_activate(self):
|
||||||
# We only allow a single window and raise any existing ones
|
# We only allow a single window and raise any existing ones
|
||||||
if not self.window:
|
if not self.window:
|
||||||
# Windows are associated with the application
|
# Windows are associated with the application
|
||||||
# when the last one is closed the application shuts down
|
# when the last one is closed the application shuts down
|
||||||
self.window = UberwriterWindow(application=self, title="UberWriter")
|
# self.window = Window(application=self, title="UberWriter")
|
||||||
|
self.window = UberwriterWindow.UberwriterWindow()
|
||||||
|
|
||||||
self.window.present()
|
self.window.present()
|
||||||
|
|
||||||
|
@ -101,6 +131,6 @@ class Application(Gtk.Application):
|
||||||
def on_quit(self, action, param):
|
def on_quit(self, action, param):
|
||||||
self.quit()
|
self.quit()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
# ~ if __name__ == "__main__":
|
||||||
app = Application()
|
# ~ app = Application()
|
||||||
app.run(sys.argv)
|
# ~ app.run(sys.argv)
|
||||||
|
|
Loading…
Reference in New Issue