Avoid close confirmation alert for unchanged example tabs
James Cameron
4 years ago
410 | 410 |
page = self.get_nth_page(index)
|
411 | 411 |
|
412 | 412 |
text_buffer = page.get_children()[0].get_buffer()
|
413 | |
char_count = text_buffer.get_char_count()
|
414 | |
|
415 | |
if char_count == 0:
|
|
413 |
empty = text_buffer.get_char_count() == 0
|
|
414 |
|
|
415 |
if empty:
|
416 | 416 |
self.__tab_close(index)
|
417 | 417 |
self.emit('tab-closed', index)
|
418 | 418 |
return
|
419 | 419 |
|
420 | 420 |
tablabel = self.get_tab_label(page)
|
|
421 |
path = tablabel.get_path()
|
|
422 |
example = self.activity.is_example(path)
|
|
423 |
pristine = not text_buffer.get_modified()
|
|
424 |
|
|
425 |
if example and pristine:
|
|
426 |
self.__tab_close(index)
|
|
427 |
self.emit('tab-closed', index)
|
|
428 |
return
|
|
429 |
|
421 | 430 |
alert = ConfirmationAlert()
|
422 | 431 |
alert.props.title = _('Erase')
|
423 | 432 |
alert.props.msg = _('Do you want to permanently erase \"%s\"?') \
|
1036 | 1036 |
_iter = self.model.insert_before(self.example_iter, None)
|
1037 | 1037 |
self.model.set_value(_iter, 0, entry)
|
1038 | 1038 |
self.model.set_value(_iter, 1, entry['name'])
|
|
1039 |
|
|
1040 |
def is_example(self, path):
|
|
1041 |
if path is None:
|
|
1042 |
return False
|
|
1043 |
|
|
1044 |
for name in self.paths:
|
|
1045 |
if path.startswith(name[1]):
|
|
1046 |
return True
|
|
1047 |
|
|
1048 |
return False
|
1039 | 1049 |
|
1040 | 1050 |
def _get_pippy_object_id(self):
|
1041 | 1051 |
''' We need the object_id of this pippy instance to save in the .py
|