Fixing save/save as dialog
This commit is contained in:
parent
fa1e17f4e5
commit
7f3ea8c146
@ -70,7 +70,6 @@ class ControllerData:
|
||||
self.src_buffer = GtkSource.Buffer(max_undo_levels = 0)
|
||||
self.src_preview = self.builder.get_object('src_preview')
|
||||
|
||||
|
||||
self.scheme_manager = GtkSource.StyleSchemeManager()
|
||||
self.language_manager = GtkSource.LanguageManager()
|
||||
self.all_styles_dict = collections.OrderedDict()
|
||||
|
@ -41,34 +41,35 @@ class DialogSignalsMixin():
|
||||
self.load_scheme(path)
|
||||
|
||||
def on_save_clicked(self, param):
|
||||
if not self.origSchemeFile:
|
||||
filename = run_save_as_dialog(self.window, self.entryId.get_text() + '.xml')
|
||||
if not self.orig_scheme_file:
|
||||
filename = self.run_save_as_dialog(self.window, self.id_entry.get_text() + '.xml')
|
||||
|
||||
if filename and not '.' in os.path.basename(filename):
|
||||
filename = f"{filename}.xml"
|
||||
|
||||
if filename:
|
||||
self.write_scheme(filename, self.entryId.get_text())
|
||||
self.origSchemeFile = filename
|
||||
self.write_scheme(filename, self.id_entry.get_text())
|
||||
self.orig_scheme_file = filename
|
||||
else:
|
||||
self.write_scheme(self.origSchemeFile, self.entryId.get_text())
|
||||
self.write_scheme(self.orig_scheme_file, self.id_entry.get_text())
|
||||
|
||||
def on_save_as_clicked(self, param):
|
||||
filename = run_save_as_dialog(self.window, self.entryId.get_text() + '.xml')
|
||||
filename = self.run_save_as_dialog(self.window, self.id_entry.get_text() + '.xml')
|
||||
if filename and not '.' in os.path.basename(filename):
|
||||
filename = f"{filename}.xml"
|
||||
|
||||
if filename:
|
||||
self.write_scheme(filename, self.entryId.get_text())
|
||||
self.origSchemeFile = filename
|
||||
self.write_scheme(filename, self.id_entry.get_text())
|
||||
self.orig_scheme_file = filename
|
||||
|
||||
|
||||
def message_dialog(
|
||||
self,
|
||||
dialog_type,
|
||||
short_msg,
|
||||
long_msg = None,
|
||||
parent = None,
|
||||
buttons = Gtk.ButtonsType.OK,
|
||||
parent = None,
|
||||
buttons = Gtk.ButtonsType.OK,
|
||||
additional_buttons = None
|
||||
):
|
||||
dialog = Gtk.MessageDialog(parent = parent, flags = Gtk.DialogFlags.MODAL, type = dialog_type, buttons = buttons)
|
||||
@ -97,7 +98,7 @@ class DialogSignalsMixin():
|
||||
|
||||
return response
|
||||
|
||||
def run_save_as_dialog(parent, current_name):
|
||||
def run_save_as_dialog(self, parent, current_name):
|
||||
file_chooser = Gtk.FileChooserDialog('Save As', parent, Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
||||
|
||||
file_filter = Gtk.FileFilter()
|
||||
@ -136,4 +137,4 @@ class DialogSignalsMixin():
|
||||
if result == Gtk.ResponseType.YES: break
|
||||
|
||||
file_chooser.destroy()
|
||||
return path
|
||||
return path
|
||||
|
@ -52,14 +52,14 @@ class SourceviewSignalsMixin:
|
||||
this_scheme = self.scheme_manager.get_scheme(scheme_id_or_file)
|
||||
if not this_scheme: return False
|
||||
|
||||
self.currentScheme = this_scheme
|
||||
self.current_scheme = this_scheme
|
||||
|
||||
self.name_entry.set_text( this_scheme.get_name() )
|
||||
self.authr_entry.set_text( ', '.join( this_scheme.get_authors() ) )
|
||||
self.desc_entry.set_text( this_scheme.get_description() )
|
||||
self.id_entry.set_text( this_scheme.get_id() )
|
||||
|
||||
scheme_file = self.currentScheme.get_filename()
|
||||
scheme_file = self.current_scheme.get_filename()
|
||||
with open(scheme_file, 'r') as f:
|
||||
xml_tree = ET.parse(f)
|
||||
|
||||
@ -67,12 +67,12 @@ class SourceviewSignalsMixin:
|
||||
self.all_styles_dict.clear()
|
||||
|
||||
for style_elem in style_elems:
|
||||
this_style = self.currentScheme.get_style(style_elem.attrib['name'])
|
||||
this_style = self.current_scheme.get_style(style_elem.attrib['name'])
|
||||
styleProps = StyleProperties()
|
||||
styleProps.from_gtk_source_style(this_style)
|
||||
self.all_styles_dict[style_elem.attrib['name']] = styleProps;
|
||||
|
||||
self.src_buffer.set_style_scheme(self.currentScheme);
|
||||
self.src_buffer.set_style_scheme(self.current_scheme);
|
||||
|
||||
# set up temp file so the sample view can be updated
|
||||
self.temp_scheme_id = f"{this_scheme.get_id()}_temp"
|
||||
@ -104,4 +104,4 @@ class SourceviewSignalsMixin:
|
||||
except:
|
||||
return False
|
||||
|
||||
return True
|
||||
return True
|
@ -96,7 +96,7 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user