Codebase list sugar-pippy-activity / 394c393
Avoid close confirmation alert for unchanged example tabs James Cameron 4 years ago
2 changed file(s) with 22 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
410410 page = self.get_nth_page(index)
411411
412412 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:
416416 self.__tab_close(index)
417417 self.emit('tab-closed', index)
418418 return
419419
420420 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
421430 alert = ConfirmationAlert()
422431 alert.props.title = _('Erase')
423432 alert.props.msg = _('Do you want to permanently erase \"%s\"?') \
10361036 _iter = self.model.insert_before(self.example_iter, None)
10371037 self.model.set_value(_iter, 0, entry)
10381038 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
10391049
10401050 def _get_pippy_object_id(self):
10411051 ''' We need the object_id of this pippy instance to save in the .py