forked from Mirrors/apostrophe
parent
7ed0ba1097
commit
2723459cc2
|
@ -59,7 +59,7 @@ except:
|
|||
APT_ENABLED = False
|
||||
|
||||
#from uberwriter_lib import Window
|
||||
from uberwriter_lib import AppWindow
|
||||
from uberwriter_lib.AppWindow import Window
|
||||
from uberwriter_lib import helpers
|
||||
from .AboutUberwriterDialog import AboutUberwriterDialog
|
||||
from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
|
||||
|
@ -71,12 +71,10 @@ from .UberwriterAdvancedExportDialog import UberwriterAdvancedExportDialog
|
|||
CONFIG_PATH = os.path.expanduser("~/.config/uberwriter/")
|
||||
|
||||
# See texteditor_lib.Window.py for more details about how this class works
|
||||
class UberwriterWindow(AppWindow.Application):
|
||||
class UberwriterWindow(Window):
|
||||
|
||||
#__gtype_name__ = "UberwriterWindow"
|
||||
|
||||
print("hahah")
|
||||
|
||||
__gsignals__ = {
|
||||
'save-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
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
### END LICENSE
|
||||
|
||||
import sys
|
||||
import optparse
|
||||
|
||||
import locale
|
||||
|
@ -24,6 +24,7 @@ locale.textdomain('uberwriter')
|
|||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
|
||||
from . import UberwriterWindow
|
||||
from uberwriter_lib import AppWindow
|
||||
|
||||
from uberwriter_lib import set_up_logging, get_version
|
||||
|
||||
|
@ -50,13 +51,15 @@ def main():
|
|||
(options, args) = parse_options()
|
||||
|
||||
# Run the application.
|
||||
if args:
|
||||
for arg in args:
|
||||
window = UberwriterWindow.UberwriterWindow()
|
||||
window.load_file(arg)
|
||||
else:
|
||||
window = UberwriterWindow.UberwriterWindow()
|
||||
if options.experimental_features:
|
||||
window.use_experimental_features(True)
|
||||
window.run()
|
||||
# ~ if args:
|
||||
# ~ for arg in args:
|
||||
# ~ window = UberwriterWindow.UberwriterWindow()
|
||||
# ~ window.load_file(arg)
|
||||
# ~ else:
|
||||
# ~ window = UberwriterWindow.UberwriterWindow()
|
||||
# ~ if options.experimental_features:
|
||||
# ~ window.use_experimental_features(True)
|
||||
app = AppWindow.Application()
|
||||
app.run(sys.argv)
|
||||
|
||||
#Gtk.main()
|
||||
|
|
|
@ -5,8 +5,9 @@ gi.require_version('Gtk', '3.0')
|
|||
from gi.repository import GLib, Gio, Gtk
|
||||
|
||||
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):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -29,18 +30,13 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
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(builder)
|
||||
|
||||
self.finish_initializing(self.builder)
|
||||
|
||||
return self
|
||||
|
||||
|
||||
def on_maximize_toggle(self, action, value):
|
||||
action.set_state(value)
|
||||
|
@ -48,6 +44,38 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
self.maximize()
|
||||
else:
|
||||
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):
|
||||
|
||||
|
@ -74,12 +102,14 @@ class Application(Gtk.Application):
|
|||
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 = Window(application=self, title="UberWriter")
|
||||
self.window = UberwriterWindow.UberwriterWindow()
|
||||
|
||||
self.window.present()
|
||||
|
||||
|
@ -101,6 +131,6 @@ class Application(Gtk.Application):
|
|||
def on_quit(self, action, param):
|
||||
self.quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = Application()
|
||||
app.run(sys.argv)
|
||||
# ~ if __name__ == "__main__":
|
||||
# ~ app = Application()
|
||||
# ~ app.run(sys.argv)
|
||||
|
|
Loading…
Reference in New Issue