<commit_before>'''
@author: cgueret
'''
from gi.repository import GLib, Gtk

class Controller(object):
	def __init__(self, view, model):
		'''
		Constructor
		'''
		# Keep a pointer to the view and the model
		self._model = model
		self._view = view

		# Local variables
		self._selected_entity_name = None
		
		# Get a pointer to some objects from the interface
		contact_list_obj = self._view.get_object('contacts_list')
		button_newprop = self._view.get_object('button_newprop')
		
		# Connect the signals
		contact_list_obj.connect("cursor-changed", self._contact_selected_cb)
		button_newprop.connect("clicked", self._new_prop_clicked_cb)
		self._view.get_object('button_keep').connect("clicked", self._keep_clicked_cb)
		
		# Add a timeout to update contacts and force first call
		self._previous_contact_list = None
		self._update_contacts_cb(contact_list_obj)
		GLib.timeout_add_seconds(2, self._update_contacts_cb, contact_list_obj)

		# Hack to clean the grid
		self._grid_objs = []
		
	def _contact_selected_cb(self, obj):
		'''
		Called when a contact is selected
		'''
		# Get the identifier of the entity the user selected

		# If this fails, probably contacts have changed,
		# so we update the list of contacts and exit
		try:
			selected_row = obj.get_selection().get_selected_rows()[1][0][0]
			identifier = obj.get_model()[selected_row][0]
		except:
			self._update_contacts_cb(self, obj)
			return
		
		# Get the entity description from the model
		self._selected_entity_name = identifier
		
		# Refresh the display of the description<commit_msg>Bugfix<commit_after>'''
@author: cgueret
'''
from gi.repository import GLib, Gtk

class Controller(object):
	def __init__(self, view, model):
		'''
		Constructor
		'''
		# Keep a pointer to the view and the model
		self._model = model
		self._view = view

		# Local variables
		self._selected_entity_name = None
		
		# Get a pointer to some objects from the interface
		contact_list_obj = self._view.get_object('contacts_list')
		button_newprop = self._view.get_object('button_newprop')
		
		# Connect the signals
		contact_list_obj.connect("cursor-changed", self._contact_selected_cb)
		button_newprop.connect("clicked", self._new_prop_clicked_cb)
		self._view.get_object('button_keep').connect("clicked", self._keep_clicked_cb)
		
		# Add a timeout to update contacts and force first call
		self._previous_contact_list = None
		self._update_contacts_cb(contact_list_obj)
		GLib.timeout_add_seconds(2, self._update_contacts_cb, contact_list_obj)

		# Hack to clean the grid
		self._grid_objs = []
		
	def _contact_selected_cb(self, obj):
		'''
		Called when a contact is selected
		'''
		# Get the identifier of the entity the user selected

		# If this fails, probably contacts have changed,
		# so we update the list of contacts and exit
		try:
			selected_row = obj.get_selection().get_selected_rows()[1][0][0]
			identifier = obj.get_model()[selected_row][0]
		except:
			self._update_contacts_cb(obj)
			return
		
		# Get the entity description from the model
		self._selected_entity_name = identifier
		
		# Refresh the display of the description
{'fraction_non_alphanumeric': 0.09073420968259058, 'fraction_numerical': 0.0032061558191728116, 'mean_word_length': 4.435540069686411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '450170', 'n_tokens_mistral': 1085, 'n_tokens_neox': 961, 'n_words': 266}