Skip to content
Browse files

no need to restart gedit anymore to activate new user settings

  • Loading branch information...
1 parent 7687b9c commit d6baffaa88a68c00348f496124407a3ee80a792b @fmarcia committed
Showing with 21 additions and 28 deletions.
  1. +19 −9 zencoding/__init__.py
  2. +2 −19 zencoding/zen_settings.py
View
28 zencoding/__init__.py
@@ -110,16 +110,8 @@ def __init__(self, window):
self.window.set_data("ZenCodingPluginInfo", windowdata)
# zen coding
+ self.modified = None
self.editor = ZenEditor(self.window)
- error = self.editor.get_user_settings_error()
- if error:
- md = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
- gtk.BUTTONS_CLOSE, "There is an error in user settings:")
- message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
- md.set_title("Zen Coding error")
- md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset']))
- md.run()
- md.destroy()
def deactivate(self):
@@ -144,6 +136,24 @@ def update_ui(self):
# the content changed
self.editor.set_context(view)
+
+ # user settings
+ modified = os.path.getmtime(os.path.join(os.path.dirname(__file__), 'my_zen_settings.py'))
+ if modified != self.modified:
+ try:
+ import my_zen_settings
+ reload(my_zen_settings)
+ except Exception as error:
+ md = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
+ gtk.BUTTONS_CLOSE, "An error occured in user settings:")
+ message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
+ md.set_title("Zen Coding error")
+ md.format_secondary_text(message.format(error.msg, error.lineno, error.offset))
+ md.run()
+ md.destroy()
+ else:
+ globals()['zen_core'].zen_settings = globals()['stparser'].get_settings(my_zen_settings.my_zen_settings)
+ self.modified = modified
# Menu handlers
View
21 zencoding/zen_settings.py
@@ -44,7 +44,8 @@
"r:a": "right:auto;",
"b": "bottom:|;",
"b:a": "bottom:auto;",
- "brad": "-webkit-border-radius: ${1:radius};\n-moz-border-radius: $1;\n-ms-border-radius: $1;\nborder-radius: $1;$0",
+ "brad": "-webkit-border-radius: ${1:radius};\n-moz-border-radius: $1;\n-ms-border-radius: $1;\nborder-radius: $1;",
+ "bsha": "-webkit-box-shadow: ${1:hoff} ${2:voff} ${3:blur} ${4:rgba(0,0,0,0.5)};\n-moz-box-shadow: $1 $2 $3 $4;\n-ms-box-shadow: $1 $2 $3 $4;\nbox-shadow: $1 $2 $3 $4;",
"l": "left:|;",
"l:a": "left:auto;",
"z": "z-index:|;",
@@ -738,21 +739,3 @@
}
}
-# merge standard settings with user settings
-try:
- from my_zen_settings import my_zen_settings
-except Exception as error:
- zen_settings['variables']['user_settings_error'] = {
- 'msg': error.msg,
- 'lineno': error.lineno,
- 'offset': error.offset,
- 'text': error.text.replace(r'"', r'\"')
- }
-else:
- for lang in zen_settings:
- if lang in my_zen_settings:
- if 'snippets' in zen_settings[lang] and 'snippets' in my_zen_settings[lang]:
- zen_settings[lang]['snippets'].update(my_zen_settings[lang]['snippets'])
- if 'abbreviations' in zen_settings[lang] and 'abbreviations' in my_zen_settings[lang]:
- zen_settings[lang]['abbreviations'].update(my_zen_settings[lang]['abbreviations'])
-

0 comments on commit d6baffa

Please sign in to comment.
Something went wrong with that request. Please try again.