Separate main

This commit is contained in:
Mauricio Baeza 2020-12-20 22:00:38 -06:00
parent 04aa7eea7c
commit f410bf3d19
7 changed files with 4894 additions and 3748 deletions

View File

@ -111,7 +111,7 @@ MENU_MAIN = {
MENUS = ( MENUS = (
{ {
'title': {'en': 'Insert BarCode', 'es': 'Insertar Código'}, 'title': {'en': 'Insert BarCode', 'es': 'Insertar Código'},
'argument': 'ask', 'argument': 'used_dialog',
'context': 'calc,writer,impress,draw', 'context': 'calc,writer,impress,draw',
'icon': 'barcode', 'icon': 'barcode',
'toolbar': False, 'toolbar': False,

Binary file not shown.

View File

@ -20,7 +20,7 @@
<value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.presentation.PresentationDocument,com.sun.star.drawing.DrawingDocument</value> <value>com.sun.star.sheet.SpreadsheetDocument,com.sun.star.text.TextDocument,com.sun.star.presentation.PresentationDocument,com.sun.star.drawing.DrawingDocument</value>
</prop> </prop>
<prop oor:name="URL" oor:type="xs:string"> <prop oor:name="URL" oor:type="xs:string">
<value>service:net.elmau.zaz.BarCode?ask</value> <value>service:net.elmau.zaz.BarCode?used_dialog</value>
</prop> </prop>
<prop oor:name="Target" oor:type="xs:string"> <prop oor:name="Target" oor:type="xs:string">
<value>_self</value> <value>_self</value>

View File

@ -5,28 +5,28 @@
<node oor:name="com.sun.star.sheet.SpreadsheetDocument"> <node oor:name="com.sun.star.sheet.SpreadsheetDocument">
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse"> <node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
<prop oor:name="Command"> <prop oor:name="Command">
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value> <value xml:lang="en-US">service:net.elmau.zaz.BarCode?used_dialog</value>
</prop> </prop>
</node> </node>
</node> </node>
<node oor:name="com.sun.star.text.TextDocument"> <node oor:name="com.sun.star.text.TextDocument">
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse"> <node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
<prop oor:name="Command"> <prop oor:name="Command">
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value> <value xml:lang="en-US">service:net.elmau.zaz.BarCode?used_dialog</value>
</prop> </prop>
</node> </node>
</node> </node>
<node oor:name="com.sun.star.presentation.PresentationDocument"> <node oor:name="com.sun.star.presentation.PresentationDocument">
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse"> <node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
<prop oor:name="Command"> <prop oor:name="Command">
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value> <value xml:lang="en-US">service:net.elmau.zaz.BarCode?used_dialog</value>
</prop> </prop>
</node> </node>
</node> </node>
<node oor:name="com.sun.star.drawing.DrawingDocument"> <node oor:name="com.sun.star.drawing.DrawingDocument">
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse"> <node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
<prop oor:name="Command"> <prop oor:name="Command">
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value> <value xml:lang="en-US">service:net.elmau.zaz.BarCode?used_dialog</value>
</prop> </prop>
</node> </node>
</node> </node>

View File

@ -2,6 +2,9 @@ import gettext
import uno import uno
import unohelper import unohelper
from com.sun.star.task import XJobExecutor, XJob from com.sun.star.task import XJobExecutor, XJob
import main
import easymacro as app import easymacro as app
import qrcode import qrcode
@ -15,8 +18,6 @@ TITLE = 'ZAZ BarCode'
QR = 'qrcode' QR = 'qrcode'
_ = app.install_locales(__file__)
class Controllers(object): class Controllers(object):
@ -72,13 +73,15 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
return self._path return self._path
def trigger(self, args): def trigger(self, args):
self._type = args main.ID_EXTENSION = ID_EXTENSION
if args == 'ask' and not self._get_values(): main.run(args, __file__)
return # ~ self._type = args
# ~ if args == 'ask' and not self._get_values():
# ~ return
doc = app.get_document() # ~ doc = app.get_document()
getattr(self, '_insert_in_{}'.format(doc.type))(doc) # ~ getattr(self, '_insert_in_{}'.format(doc.type))(doc)
app.kill(self._path) # ~ app.kill(self._path)
return return
def _create_code(self, path=''): def _create_code(self, path=''):

File diff suppressed because it is too large Load Diff

31
source/pythonpath/main.py Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import easymacro as app
ID_EXTENSION = ''
_ = None
def _use_dialog():
print('dialog')
return
def _insert_code(type_code):
print(type_code)
return
@app.catch_exception
def run(args, path_locales):
global _
_ = app.install_locales(path_locales)
if args == 'used_dialog':
_use_dialog()
else:
_insert_code(args)
return