repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
celery/django-celery
djcelery/loaders.py
DjangoLoader.read_configuration
def read_configuration(self): """Load configuration from Django settings.""" self.configured = True # Default backend needs to be the database backend for backward # compatibility. backend = (getattr(settings, 'CELERY_RESULT_BACKEND', None) or getattr(settings, 'CELERY_BACKEND', None)) if not backend: settings.CELERY_RESULT_BACKEND = 'database' return DictAttribute(settings)
python
def read_configuration(self): """Load configuration from Django settings.""" self.configured = True # Default backend needs to be the database backend for backward # compatibility. backend = (getattr(settings, 'CELERY_RESULT_BACKEND', None) or getattr(settings, 'CELERY_BACKEND', None)) if not backend: settings.CELERY_RESULT_BACKEND = 'database' return DictAttribute(settings)
[ "def", "read_configuration", "(", "self", ")", ":", "self", ".", "configured", "=", "True", "# Default backend needs to be the database backend for backward", "# compatibility.", "backend", "=", "(", "getattr", "(", "settings", ",", "'CELERY_RESULT_BACKEND'", ",", "None",...
Load configuration from Django settings.
[ "Load", "configuration", "from", "Django", "settings", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/loaders.py#L57-L66
train
217,700
celery/django-celery
djcelery/loaders.py
DjangoLoader.on_task_init
def on_task_init(self, task_id, task): """Called before every task.""" try: is_eager = task.request.is_eager except AttributeError: is_eager = False if not is_eager: self.close_database()
python
def on_task_init(self, task_id, task): """Called before every task.""" try: is_eager = task.request.is_eager except AttributeError: is_eager = False if not is_eager: self.close_database()
[ "def", "on_task_init", "(", "self", ",", "task_id", ",", "task", ")", ":", "try", ":", "is_eager", "=", "task", ".", "request", ".", "is_eager", "except", "AttributeError", ":", "is_eager", "=", "False", "if", "not", "is_eager", ":", "self", ".", "close_...
Called before every task.
[ "Called", "before", "every", "task", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/loaders.py#L110-L117
train
217,701
celery/django-celery
djcelery/humanize.py
naturaldate
def naturaldate(date, include_seconds=False): """Convert datetime into a human natural date string.""" if not date: return '' right_now = now() today = datetime(right_now.year, right_now.month, right_now.day, tzinfo=right_now.tzinfo) delta = right_now - date delta_midnight = today - date days = delta.days hours = delta.seconds // 3600 minutes = delta.seconds // 60 seconds = delta.seconds if days < 0: return _('just now') if days == 0: if hours == 0: if minutes > 0: return ungettext( _('{minutes} minute ago'), _('{minutes} minutes ago'), minutes ).format(minutes=minutes) else: if include_seconds and seconds: return ungettext( _('{seconds} second ago'), _('{seconds} seconds ago'), seconds ).format(seconds=seconds) return _('just now') else: return ungettext( _('{hours} hour ago'), _('{hours} hours ago'), hours ).format(hours=hours) if delta_midnight.days == 0: return _('yesterday at {time}').format(time=date.strftime('%H:%M')) count = 0 for chunk, pluralizefun in OLDER_CHUNKS: if days >= chunk: count = int(round((delta_midnight.days + 1) / chunk, 0)) fmt = pluralizefun(count) return fmt.format(num=count)
python
def naturaldate(date, include_seconds=False): """Convert datetime into a human natural date string.""" if not date: return '' right_now = now() today = datetime(right_now.year, right_now.month, right_now.day, tzinfo=right_now.tzinfo) delta = right_now - date delta_midnight = today - date days = delta.days hours = delta.seconds // 3600 minutes = delta.seconds // 60 seconds = delta.seconds if days < 0: return _('just now') if days == 0: if hours == 0: if minutes > 0: return ungettext( _('{minutes} minute ago'), _('{minutes} minutes ago'), minutes ).format(minutes=minutes) else: if include_seconds and seconds: return ungettext( _('{seconds} second ago'), _('{seconds} seconds ago'), seconds ).format(seconds=seconds) return _('just now') else: return ungettext( _('{hours} hour ago'), _('{hours} hours ago'), hours ).format(hours=hours) if delta_midnight.days == 0: return _('yesterday at {time}').format(time=date.strftime('%H:%M')) count = 0 for chunk, pluralizefun in OLDER_CHUNKS: if days >= chunk: count = int(round((delta_midnight.days + 1) / chunk, 0)) fmt = pluralizefun(count) return fmt.format(num=count)
[ "def", "naturaldate", "(", "date", ",", "include_seconds", "=", "False", ")", ":", "if", "not", "date", ":", "return", "''", "right_now", "=", "now", "(", ")", "today", "=", "datetime", "(", "right_now", ".", "year", ",", "right_now", ".", "month", ","...
Convert datetime into a human natural date string.
[ "Convert", "datetime", "into", "a", "human", "natural", "date", "string", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/humanize.py#L38-L85
train
217,702
celery/django-celery
djcelery/views.py
apply
def apply(request, task_name): """View applying a task. **Note:** Please use this with caution. Preferably you shouldn't make this publicly accessible without ensuring your code is safe! """ try: task = tasks[task_name] except KeyError: raise Http404('apply: no such task') return task_view(task)(request)
python
def apply(request, task_name): """View applying a task. **Note:** Please use this with caution. Preferably you shouldn't make this publicly accessible without ensuring your code is safe! """ try: task = tasks[task_name] except KeyError: raise Http404('apply: no such task') return task_view(task)(request)
[ "def", "apply", "(", "request", ",", "task_name", ")", ":", "try", ":", "task", "=", "tasks", "[", "task_name", "]", "except", "KeyError", ":", "raise", "Http404", "(", "'apply: no such task'", ")", "return", "task_view", "(", "task", ")", "(", "request", ...
View applying a task. **Note:** Please use this with caution. Preferably you shouldn't make this publicly accessible without ensuring your code is safe!
[ "View", "applying", "a", "task", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/views.py#L46-L57
train
217,703
celery/django-celery
djcelery/views.py
task_status
def task_status(request, task_id): """Returns task status and result in JSON format.""" result = AsyncResult(task_id) state, retval = result.state, result.result response_data = {'id': task_id, 'status': state, 'result': retval} if state in states.EXCEPTION_STATES: traceback = result.traceback response_data.update({'result': safe_repr(retval), 'exc': get_full_cls_name(retval.__class__), 'traceback': traceback}) return JsonResponse({'task': response_data})
python
def task_status(request, task_id): """Returns task status and result in JSON format.""" result = AsyncResult(task_id) state, retval = result.state, result.result response_data = {'id': task_id, 'status': state, 'result': retval} if state in states.EXCEPTION_STATES: traceback = result.traceback response_data.update({'result': safe_repr(retval), 'exc': get_full_cls_name(retval.__class__), 'traceback': traceback}) return JsonResponse({'task': response_data})
[ "def", "task_status", "(", "request", ",", "task_id", ")", ":", "result", "=", "AsyncResult", "(", "task_id", ")", "state", ",", "retval", "=", "result", ".", "state", ",", "result", ".", "result", "response_data", "=", "{", "'id'", ":", "task_id", ",", ...
Returns task status and result in JSON format.
[ "Returns", "task", "status", "and", "result", "in", "JSON", "format", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/views.py#L68-L78
train
217,704
celery/django-celery
djcelery/views.py
task_webhook
def task_webhook(fun): """Decorator turning a function into a task webhook. If an exception is raised within the function, the decorated function catches this and returns an error JSON response, otherwise it returns the result as a JSON response. Example: .. code-block:: python @task_webhook def add(request): x = int(request.GET['x']) y = int(request.GET['y']) return x + y def view(request): response = add(request) print(response.content) Gives:: "{'status': 'success', 'retval': 100}" """ @wraps(fun) def _inner(*args, **kwargs): try: retval = fun(*args, **kwargs) except Exception as exc: response = {'status': 'failure', 'reason': safe_repr(exc)} else: response = {'status': 'success', 'retval': retval} return JsonResponse(response) return _inner
python
def task_webhook(fun): """Decorator turning a function into a task webhook. If an exception is raised within the function, the decorated function catches this and returns an error JSON response, otherwise it returns the result as a JSON response. Example: .. code-block:: python @task_webhook def add(request): x = int(request.GET['x']) y = int(request.GET['y']) return x + y def view(request): response = add(request) print(response.content) Gives:: "{'status': 'success', 'retval': 100}" """ @wraps(fun) def _inner(*args, **kwargs): try: retval = fun(*args, **kwargs) except Exception as exc: response = {'status': 'failure', 'reason': safe_repr(exc)} else: response = {'status': 'success', 'retval': retval} return JsonResponse(response) return _inner
[ "def", "task_webhook", "(", "fun", ")", ":", "@", "wraps", "(", "fun", ")", "def", "_inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "retval", "=", "fun", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "Excep...
Decorator turning a function into a task webhook. If an exception is raised within the function, the decorated function catches this and returns an error JSON response, otherwise it returns the result as a JSON response. Example: .. code-block:: python @task_webhook def add(request): x = int(request.GET['x']) y = int(request.GET['y']) return x + y def view(request): response = add(request) print(response.content) Gives:: "{'status': 'success', 'retval': 100}"
[ "Decorator", "turning", "a", "function", "into", "a", "task", "webhook", "." ]
5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/views.py#L86-L125
train
217,705
Guake/guake
guake/menus.py
mk_tab_context_menu
def mk_tab_context_menu(callback_object): """Create the context menu for a notebook tab """ # Store the menu in a temp variable in terminal so that popup() is happy. See: # https://stackoverflow.com/questions/28465956/ callback_object.context_menu = Gtk.Menu() menu = callback_object.context_menu mi1 = Gtk.MenuItem(_("New Tab")) mi1.connect("activate", callback_object.on_new_tab) menu.add(mi1) mi2 = Gtk.MenuItem(_("Rename")) mi2.connect("activate", callback_object.on_rename) menu.add(mi2) mi3 = Gtk.MenuItem(_("Close")) mi3.connect("activate", callback_object.on_close) menu.add(mi3) menu.show_all() return menu
python
def mk_tab_context_menu(callback_object): """Create the context menu for a notebook tab """ # Store the menu in a temp variable in terminal so that popup() is happy. See: # https://stackoverflow.com/questions/28465956/ callback_object.context_menu = Gtk.Menu() menu = callback_object.context_menu mi1 = Gtk.MenuItem(_("New Tab")) mi1.connect("activate", callback_object.on_new_tab) menu.add(mi1) mi2 = Gtk.MenuItem(_("Rename")) mi2.connect("activate", callback_object.on_rename) menu.add(mi2) mi3 = Gtk.MenuItem(_("Close")) mi3.connect("activate", callback_object.on_close) menu.add(mi3) menu.show_all() return menu
[ "def", "mk_tab_context_menu", "(", "callback_object", ")", ":", "# Store the menu in a temp variable in terminal so that popup() is happy. See:", "# https://stackoverflow.com/questions/28465956/", "callback_object", ".", "context_menu", "=", "Gtk", ".", "Menu", "(", ")", "menu", ...
Create the context menu for a notebook tab
[ "Create", "the", "context", "menu", "for", "a", "notebook", "tab" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/menus.py#L13-L30
train
217,706
Guake/guake
guake/menus.py
mk_notebook_context_menu
def mk_notebook_context_menu(callback_object): """Create the context menu for the notebook """ callback_object.context_menu = Gtk.Menu() menu = callback_object.context_menu mi = Gtk.MenuItem(_("New Tab")) mi.connect("activate", callback_object.on_new_tab) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Save Tabs")) mi.connect("activate", callback_object.on_save_tabs) menu.add(mi) mi = Gtk.MenuItem(_("Restore Tabs")) mi.connect("activate", callback_object.on_restore_tabs_with_dialog) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.ImageMenuItem("gtk-preferences") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_preferences) menu.add(mi) mi = Gtk.ImageMenuItem("gtk-about") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_about) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Quit")) mi.connect("activate", callback_object.on_quit) menu.add(mi) menu.show_all() return menu
python
def mk_notebook_context_menu(callback_object): """Create the context menu for the notebook """ callback_object.context_menu = Gtk.Menu() menu = callback_object.context_menu mi = Gtk.MenuItem(_("New Tab")) mi.connect("activate", callback_object.on_new_tab) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Save Tabs")) mi.connect("activate", callback_object.on_save_tabs) menu.add(mi) mi = Gtk.MenuItem(_("Restore Tabs")) mi.connect("activate", callback_object.on_restore_tabs_with_dialog) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.ImageMenuItem("gtk-preferences") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_preferences) menu.add(mi) mi = Gtk.ImageMenuItem("gtk-about") mi.set_use_stock(True) mi.connect("activate", callback_object.on_show_about) menu.add(mi) menu.add(Gtk.SeparatorMenuItem()) mi = Gtk.MenuItem(_("Quit")) mi.connect("activate", callback_object.on_quit) menu.add(mi) menu.show_all() return menu
[ "def", "mk_notebook_context_menu", "(", "callback_object", ")", ":", "callback_object", ".", "context_menu", "=", "Gtk", ".", "Menu", "(", ")", "menu", "=", "callback_object", ".", "context_menu", "mi", "=", "Gtk", ".", "MenuItem", "(", "_", "(", "\"New Tab\""...
Create the context menu for the notebook
[ "Create", "the", "context", "menu", "for", "the", "notebook" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/menus.py#L33-L62
train
217,707
Guake/guake
guake/gsettings.py
GSettingHandler.ontop_toggled
def ontop_toggled(self, settings, key, user_data): """If the gconf var window_ontop be changed, this method will be called and will set the keep_above attribute in guake's main window. """ self.guake.window.set_keep_above(settings.get_boolean(key))
python
def ontop_toggled(self, settings, key, user_data): """If the gconf var window_ontop be changed, this method will be called and will set the keep_above attribute in guake's main window. """ self.guake.window.set_keep_above(settings.get_boolean(key))
[ "def", "ontop_toggled", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "self", ".", "guake", ".", "window", ".", "set_keep_above", "(", "settings", ".", "get_boolean", "(", "key", ")", ")" ]
If the gconf var window_ontop be changed, this method will be called and will set the keep_above attribute in guake's main window.
[ "If", "the", "gconf", "var", "window_ontop", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "set", "the", "keep_above", "attribute", "in", "guake", "s", "main", "window", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L103-L108
train
217,708
Guake/guake
guake/gsettings.py
GSettingHandler.alignment_changed
def alignment_changed(self, settings, key, user_data): """If the gconf var window_halignment be changed, this method will be called and will call the move function in guake. """ RectCalculator.set_final_window_rect(self.settings, self.guake.window) self.guake.set_tab_position() self.guake.force_move_if_shown()
python
def alignment_changed(self, settings, key, user_data): """If the gconf var window_halignment be changed, this method will be called and will call the move function in guake. """ RectCalculator.set_final_window_rect(self.settings, self.guake.window) self.guake.set_tab_position() self.guake.force_move_if_shown()
[ "def", "alignment_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "RectCalculator", ".", "set_final_window_rect", "(", "self", ".", "settings", ",", "self", ".", "guake", ".", "window", ")", "self", ".", "guake", ".", "set_t...
If the gconf var window_halignment be changed, this method will be called and will call the move function in guake.
[ "If", "the", "gconf", "var", "window_halignment", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "call", "the", "move", "function", "in", "guake", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L126-L132
train
217,709
Guake/guake
guake/gsettings.py
GSettingHandler.size_changed
def size_changed(self, settings, key, user_data): """If the gconf var window_height or window_width are changed, this method will be called and will call the resize function in guake. """ RectCalculator.set_final_window_rect(self.settings, self.guake.window)
python
def size_changed(self, settings, key, user_data): """If the gconf var window_height or window_width are changed, this method will be called and will call the resize function in guake. """ RectCalculator.set_final_window_rect(self.settings, self.guake.window)
[ "def", "size_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "RectCalculator", ".", "set_final_window_rect", "(", "self", ".", "settings", ",", "self", ".", "guake", ".", "window", ")" ]
If the gconf var window_height or window_width are changed, this method will be called and will call the resize function in guake.
[ "If", "the", "gconf", "var", "window_height", "or", "window_width", "are", "changed", "this", "method", "will", "be", "called", "and", "will", "call", "the", "resize", "function", "in", "guake", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L134-L139
train
217,710
Guake/guake
guake/gsettings.py
GSettingHandler.cursor_blink_mode_changed
def cursor_blink_mode_changed(self, settings, key, user_data): """Called when cursor blink mode settings has been changed """ for term in self.guake.notebook_manager.iter_terminals(): term.set_property("cursor-blink-mode", settings.get_int(key))
python
def cursor_blink_mode_changed(self, settings, key, user_data): """Called when cursor blink mode settings has been changed """ for term in self.guake.notebook_manager.iter_terminals(): term.set_property("cursor-blink-mode", settings.get_int(key))
[ "def", "cursor_blink_mode_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "term", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "term", ".", "set_property", "(", "\"cursor-bl...
Called when cursor blink mode settings has been changed
[ "Called", "when", "cursor", "blink", "mode", "settings", "has", "been", "changed" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L141-L145
train
217,711
Guake/guake
guake/gsettings.py
GSettingHandler.history_size_changed
def history_size_changed(self, settings, key, user_data): """If the gconf var history_size be changed, this method will be called and will set the scrollback_lines property of all terminals open. """ lines = settings.get_int(key) for i in self.guake.notebook_manager.iter_terminals(): i.set_scrollback_lines(lines)
python
def history_size_changed(self, settings, key, user_data): """If the gconf var history_size be changed, this method will be called and will set the scrollback_lines property of all terminals open. """ lines = settings.get_int(key) for i in self.guake.notebook_manager.iter_terminals(): i.set_scrollback_lines(lines)
[ "def", "history_size_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "lines", "=", "settings", ".", "get_int", "(", "key", ")", "for", "i", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", "...
If the gconf var history_size be changed, this method will be called and will set the scrollback_lines property of all terminals open.
[ "If", "the", "gconf", "var", "history_size", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "set", "the", "scrollback_lines", "property", "of", "all", "terminals", "open", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L171-L178
train
217,712
Guake/guake
guake/gsettings.py
GSettingHandler.keystroke_output
def keystroke_output(self, settings, key, user_data): """If the gconf var scroll_output be changed, this method will be called and will set the scroll_on_output in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_scroll_on_output(settings.get_boolean(key))
python
def keystroke_output(self, settings, key, user_data): """If the gconf var scroll_output be changed, this method will be called and will set the scroll_on_output in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_scroll_on_output(settings.get_boolean(key))
[ "def", "keystroke_output", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "i", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "i", ".", "set_scroll_on_output", "(", "settings", ".", ...
If the gconf var scroll_output be changed, this method will be called and will set the scroll_on_output in all terminals open.
[ "If", "the", "gconf", "var", "scroll_output", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "set", "the", "scroll_on_output", "in", "all", "terminals", "open", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L188-L194
train
217,713
Guake/guake
guake/gsettings.py
GSettingHandler.keystroke_toggled
def keystroke_toggled(self, settings, key, user_data): """If the gconf var scroll_keystroke be changed, this method will be called and will set the scroll_on_keystroke in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_scroll_on_keystroke(settings.get_boolean(key))
python
def keystroke_toggled(self, settings, key, user_data): """If the gconf var scroll_keystroke be changed, this method will be called and will set the scroll_on_keystroke in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_scroll_on_keystroke(settings.get_boolean(key))
[ "def", "keystroke_toggled", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "i", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "i", ".", "set_scroll_on_keystroke", "(", "settings", "...
If the gconf var scroll_keystroke be changed, this method will be called and will set the scroll_on_keystroke in all terminals open.
[ "If", "the", "gconf", "var", "scroll_keystroke", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "set", "the", "scroll_on_keystroke", "in", "all", "terminals", "open", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L196-L202
train
217,714
Guake/guake
guake/gsettings.py
GSettingHandler.allow_bold_toggled
def allow_bold_toggled(self, settings, key, user_data): """If the gconf var allow_bold is changed, this method will be called and will change the VTE terminal o. displaying characters in bold font. """ for term in self.guake.notebook_manager.iter_terminals(): term.set_allow_bold(settings.get_boolean(key))
python
def allow_bold_toggled(self, settings, key, user_data): """If the gconf var allow_bold is changed, this method will be called and will change the VTE terminal o. displaying characters in bold font. """ for term in self.guake.notebook_manager.iter_terminals(): term.set_allow_bold(settings.get_boolean(key))
[ "def", "allow_bold_toggled", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "term", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "term", ".", "set_allow_bold", "(", "settings", "."...
If the gconf var allow_bold is changed, this method will be called and will change the VTE terminal o. displaying characters in bold font.
[ "If", "the", "gconf", "var", "allow_bold", "is", "changed", "this", "method", "will", "be", "called", "and", "will", "change", "the", "VTE", "terminal", "o", ".", "displaying", "characters", "in", "bold", "font", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L226-L232
train
217,715
Guake/guake
guake/gsettings.py
GSettingHandler.bold_is_bright_toggled
def bold_is_bright_toggled(self, settings, key, user_data): """If the dconf var bold_is_bright is changed, this method will be called and will change the VTE terminal to toggle auto-brightened bold text. """ try: for term in self.guake.notebook_manager.iter_terminals(): term.set_bold_is_bright(settings.get_boolean(key)) except: # pylint: disable=bare-except log.error("set_bold_is_bright not supported by your version of VTE")
python
def bold_is_bright_toggled(self, settings, key, user_data): """If the dconf var bold_is_bright is changed, this method will be called and will change the VTE terminal to toggle auto-brightened bold text. """ try: for term in self.guake.notebook_manager.iter_terminals(): term.set_bold_is_bright(settings.get_boolean(key)) except: # pylint: disable=bare-except log.error("set_bold_is_bright not supported by your version of VTE")
[ "def", "bold_is_bright_toggled", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "try", ":", "for", "term", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "term", ".", "set_bold_is_bright", ...
If the dconf var bold_is_bright is changed, this method will be called and will change the VTE terminal to toggle auto-brightened bold text.
[ "If", "the", "dconf", "var", "bold_is_bright", "is", "changed", "this", "method", "will", "be", "called", "and", "will", "change", "the", "VTE", "terminal", "to", "toggle", "auto", "-", "brightened", "bold", "text", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L234-L242
train
217,716
Guake/guake
guake/gsettings.py
GSettingHandler.palette_font_and_background_color_toggled
def palette_font_and_background_color_toggled(self, settings, key, user_data): """If the gconf var use_palette_font_and_background_color be changed, this method will be called and will change the font color and the background color to the color defined in the palette. """ self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette')
python
def palette_font_and_background_color_toggled(self, settings, key, user_data): """If the gconf var use_palette_font_and_background_color be changed, this method will be called and will change the font color and the background color to the color defined in the palette. """ self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette')
[ "def", "palette_font_and_background_color_toggled", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "self", ".", "settings", ".", "styleFont", ".", "triggerOnChangedValue", "(", "self", ".", "settings", ".", "styleFont", ",", "'palette'", "...
If the gconf var use_palette_font_and_background_color be changed, this method will be called and will change the font color and the background color to the color defined in the palette.
[ "If", "the", "gconf", "var", "use_palette_font_and_background_color", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "change", "the", "font", "color", "and", "the", "background", "color", "to", "the", "color", "defined", "in", "the", ...
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L244-L249
train
217,717
Guake/guake
guake/gsettings.py
GSettingHandler.backspace_changed
def backspace_changed(self, settings, key, user_data): """If the gconf var compat_backspace be changed, this method will be called and will change the binding configuration in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_backspace_binding(self.getEraseBinding(settings.get_string(key)))
python
def backspace_changed(self, settings, key, user_data): """If the gconf var compat_backspace be changed, this method will be called and will change the binding configuration in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_backspace_binding(self.getEraseBinding(settings.get_string(key)))
[ "def", "backspace_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "i", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "i", ".", "set_backspace_binding", "(", "self", ".", ...
If the gconf var compat_backspace be changed, this method will be called and will change the binding configuration in all terminals open.
[ "If", "the", "gconf", "var", "compat_backspace", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "change", "the", "binding", "configuration", "in", "all", "terminals", "open", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L286-L292
train
217,718
Guake/guake
guake/gsettings.py
GSettingHandler.delete_changed
def delete_changed(self, settings, key, user_data): """If the gconf var compat_delete be changed, this method will be called and will change the binding configuration in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_delete_binding(self.getEraseBinding(settings.get_string(key)))
python
def delete_changed(self, settings, key, user_data): """If the gconf var compat_delete be changed, this method will be called and will change the binding configuration in all terminals open. """ for i in self.guake.notebook_manager.iter_terminals(): i.set_delete_binding(self.getEraseBinding(settings.get_string(key)))
[ "def", "delete_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "for", "i", "in", "self", ".", "guake", ".", "notebook_manager", ".", "iter_terminals", "(", ")", ":", "i", ".", "set_delete_binding", "(", "self", ".", "getEr...
If the gconf var compat_delete be changed, this method will be called and will change the binding configuration in all terminals open.
[ "If", "the", "gconf", "var", "compat_delete", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "change", "the", "binding", "configuration", "in", "all", "terminals", "open", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L294-L300
train
217,719
Guake/guake
guake/gsettings.py
GSettingHandler.max_tab_name_length_changed
def max_tab_name_length_changed(self, settings, key, user_data): """If the gconf var max_tab_name_length be changed, this method will be called and will set the tab name length limit. """ # avoid get window title before terminal is ready if self.guake.notebook_manager.get_current_notebook().get_current_terminal() is None: return # avoid get window title before terminal is ready if self.guake.notebook_manager.get_current_notebook().get_current_terminal( ).get_window_title() is None: return self.guake.recompute_tabs_titles()
python
def max_tab_name_length_changed(self, settings, key, user_data): """If the gconf var max_tab_name_length be changed, this method will be called and will set the tab name length limit. """ # avoid get window title before terminal is ready if self.guake.notebook_manager.get_current_notebook().get_current_terminal() is None: return # avoid get window title before terminal is ready if self.guake.notebook_manager.get_current_notebook().get_current_terminal( ).get_window_title() is None: return self.guake.recompute_tabs_titles()
[ "def", "max_tab_name_length_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "# avoid get window title before terminal is ready", "if", "self", ".", "guake", ".", "notebook_manager", ".", "get_current_notebook", "(", ")", ".", "get_curre...
If the gconf var max_tab_name_length be changed, this method will be called and will set the tab name length limit.
[ "If", "the", "gconf", "var", "max_tab_name_length", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "set", "the", "tab", "name", "length", "limit", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L302-L315
train
217,720
Guake/guake
guake/gsettings.py
GSettingHandler.abbreviate_tab_names_changed
def abbreviate_tab_names_changed(self, settings, key, user_data): """If the gconf var abbreviate_tab_names be changed, this method will be called and will update tab names. """ abbreviate_tab_names = settings.get_boolean('abbreviate-tab-names') self.guake.abbreviate = abbreviate_tab_names self.guake.recompute_tabs_titles()
python
def abbreviate_tab_names_changed(self, settings, key, user_data): """If the gconf var abbreviate_tab_names be changed, this method will be called and will update tab names. """ abbreviate_tab_names = settings.get_boolean('abbreviate-tab-names') self.guake.abbreviate = abbreviate_tab_names self.guake.recompute_tabs_titles()
[ "def", "abbreviate_tab_names_changed", "(", "self", ",", "settings", ",", "key", ",", "user_data", ")", ":", "abbreviate_tab_names", "=", "settings", ".", "get_boolean", "(", "'abbreviate-tab-names'", ")", "self", ".", "guake", ".", "abbreviate", "=", "abbreviate_...
If the gconf var abbreviate_tab_names be changed, this method will be called and will update tab names.
[ "If", "the", "gconf", "var", "abbreviate_tab_names", "be", "changed", "this", "method", "will", "be", "called", "and", "will", "update", "tab", "names", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/gsettings.py#L317-L323
train
217,721
Guake/guake
guake/keybindings.py
Keybindings.reload_accelerators
def reload_accelerators(self, *args): """Reassign an accel_group to guake main window and guake context menu and calls the load_accelerators method. """ if self.accel_group: self.guake.window.remove_accel_group(self.accel_group) self.accel_group = Gtk.AccelGroup() self.guake.window.add_accel_group(self.accel_group) self.load_accelerators()
python
def reload_accelerators(self, *args): """Reassign an accel_group to guake main window and guake context menu and calls the load_accelerators method. """ if self.accel_group: self.guake.window.remove_accel_group(self.accel_group) self.accel_group = Gtk.AccelGroup() self.guake.window.add_accel_group(self.accel_group) self.load_accelerators()
[ "def", "reload_accelerators", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "accel_group", ":", "self", ".", "guake", ".", "window", ".", "remove_accel_group", "(", "self", ".", "accel_group", ")", "self", ".", "accel_group", "=", "Gtk", "....
Reassign an accel_group to guake main window and guake context menu and calls the load_accelerators method.
[ "Reassign", "an", "accel_group", "to", "guake", "main", "window", "and", "guake", "context", "menu", "and", "calls", "the", "load_accelerators", "method", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/keybindings.py#L104-L112
train
217,722
Guake/guake
guake/globals.py
bindtextdomain
def bindtextdomain(app_name, locale_dir=None): """ Bind the domain represented by app_name to the locale directory locale_dir. It has the effect of loading translations, enabling applications for different languages. app_name: a domain to look for translations, typically the name of an application. locale_dir: a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo If omitted or None, then the current binding for app_name is used. """ import locale from locale import gettext as _ log.info("Local binding for app '%s', local dir: %s", app_name, locale_dir) locale.bindtextdomain(app_name, locale_dir) locale.textdomain(app_name)
python
def bindtextdomain(app_name, locale_dir=None): """ Bind the domain represented by app_name to the locale directory locale_dir. It has the effect of loading translations, enabling applications for different languages. app_name: a domain to look for translations, typically the name of an application. locale_dir: a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo If omitted or None, then the current binding for app_name is used. """ import locale from locale import gettext as _ log.info("Local binding for app '%s', local dir: %s", app_name, locale_dir) locale.bindtextdomain(app_name, locale_dir) locale.textdomain(app_name)
[ "def", "bindtextdomain", "(", "app_name", ",", "locale_dir", "=", "None", ")", ":", "import", "locale", "from", "locale", "import", "gettext", "as", "_", "log", ".", "info", "(", "\"Local binding for app '%s', local dir: %s\"", ",", "app_name", ",", "locale_dir", ...
Bind the domain represented by app_name to the locale directory locale_dir. It has the effect of loading translations, enabling applications for different languages. app_name: a domain to look for translations, typically the name of an application. locale_dir: a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo If omitted or None, then the current binding for app_name is used.
[ "Bind", "the", "domain", "represented", "by", "app_name", "to", "the", "locale", "directory", "locale_dir", ".", "It", "has", "the", "effect", "of", "loading", "translations", "enabling", "applications", "for", "different", "languages", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/globals.py#L38-L58
train
217,723
Guake/guake
guake/prefs.py
setup_standalone_signals
def setup_standalone_signals(instance): """Called when prefs dialog is running in standalone mode. It makes the delete event of dialog and click on close button finish the application. """ window = instance.get_widget('config-window') window.connect('delete-event', Gtk.main_quit) # We need to block the execution of the already associated # callback before connecting the new handler. button = instance.get_widget('button1') button.handler_block_by_func(instance.gtk_widget_destroy) button.connect('clicked', Gtk.main_quit) return instance
python
def setup_standalone_signals(instance): """Called when prefs dialog is running in standalone mode. It makes the delete event of dialog and click on close button finish the application. """ window = instance.get_widget('config-window') window.connect('delete-event', Gtk.main_quit) # We need to block the execution of the already associated # callback before connecting the new handler. button = instance.get_widget('button1') button.handler_block_by_func(instance.gtk_widget_destroy) button.connect('clicked', Gtk.main_quit) return instance
[ "def", "setup_standalone_signals", "(", "instance", ")", ":", "window", "=", "instance", ".", "get_widget", "(", "'config-window'", ")", "window", ".", "connect", "(", "'delete-event'", ",", "Gtk", ".", "main_quit", ")", "# We need to block the execution of the alread...
Called when prefs dialog is running in standalone mode. It makes the delete event of dialog and click on close button finish the application.
[ "Called", "when", "prefs", "dialog", "is", "running", "in", "standalone", "mode", ".", "It", "makes", "the", "delete", "event", "of", "dialog", "and", "click", "on", "close", "button", "finish", "the", "application", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1490-L1504
train
217,724
Guake/guake
guake/prefs.py
PrefsCallbacks.on_default_shell_changed
def on_default_shell_changed(self, combo): """Changes the activity of default_shell in dconf """ citer = combo.get_active_iter() if not citer: return shell = combo.get_model().get_value(citer, 0) # we unset the value (restore to default) when user chooses to use # user shell as guake shell interpreter. if shell == USER_SHELL_VALUE: self.settings.general.reset('default-shell') else: self.settings.general.set_string('default-shell', shell)
python
def on_default_shell_changed(self, combo): """Changes the activity of default_shell in dconf """ citer = combo.get_active_iter() if not citer: return shell = combo.get_model().get_value(citer, 0) # we unset the value (restore to default) when user chooses to use # user shell as guake shell interpreter. if shell == USER_SHELL_VALUE: self.settings.general.reset('default-shell') else: self.settings.general.set_string('default-shell', shell)
[ "def", "on_default_shell_changed", "(", "self", ",", "combo", ")", ":", "citer", "=", "combo", ".", "get_active_iter", "(", ")", "if", "not", "citer", ":", "return", "shell", "=", "combo", ".", "get_model", "(", ")", ".", "get_value", "(", "citer", ",", ...
Changes the activity of default_shell in dconf
[ "Changes", "the", "activity", "of", "default_shell", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L368-L380
train
217,725
Guake/guake
guake/prefs.py
PrefsCallbacks.on_gtk_theme_name_changed
def on_gtk_theme_name_changed(self, combo): """Set the `gtk_theme_name' property in dconf """ citer = combo.get_active_iter() if not citer: return theme_name = combo.get_model().get_value(citer, 0) self.settings.general.set_string('gtk-theme-name', theme_name) select_gtk_theme(self.settings)
python
def on_gtk_theme_name_changed(self, combo): """Set the `gtk_theme_name' property in dconf """ citer = combo.get_active_iter() if not citer: return theme_name = combo.get_model().get_value(citer, 0) self.settings.general.set_string('gtk-theme-name', theme_name) select_gtk_theme(self.settings)
[ "def", "on_gtk_theme_name_changed", "(", "self", ",", "combo", ")", ":", "citer", "=", "combo", ".", "get_active_iter", "(", ")", "if", "not", "citer", ":", "return", "theme_name", "=", "combo", ".", "get_model", "(", ")", ".", "get_value", "(", "citer", ...
Set the `gtk_theme_name' property in dconf
[ "Set", "the", "gtk_theme_name", "property", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L417-L425
train
217,726
Guake/guake
guake/prefs.py
PrefsCallbacks.on_gtk_prefer_dark_theme_toggled
def on_gtk_prefer_dark_theme_toggled(self, chk): """Set the `gtk_prefer_dark_theme' property in dconf """ self.settings.general.set_boolean('gtk-prefer-dark-theme', chk.get_active()) select_gtk_theme(self.settings)
python
def on_gtk_prefer_dark_theme_toggled(self, chk): """Set the `gtk_prefer_dark_theme' property in dconf """ self.settings.general.set_boolean('gtk-prefer-dark-theme', chk.get_active()) select_gtk_theme(self.settings)
[ "def", "on_gtk_prefer_dark_theme_toggled", "(", "self", ",", "chk", ")", ":", "self", ".", "settings", ".", "general", ".", "set_boolean", "(", "'gtk-prefer-dark-theme'", ",", "chk", ".", "get_active", "(", ")", ")", "select_gtk_theme", "(", "self", ".", "sett...
Set the `gtk_prefer_dark_theme' property in dconf
[ "Set", "the", "gtk_prefer_dark_theme", "property", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L427-L431
train
217,727
Guake/guake
guake/prefs.py
PrefsCallbacks.on_start_at_login_toggled
def on_start_at_login_toggled(self, chk): """Changes the activity of start_at_login in dconf """ self.settings.general.set_boolean('start-at-login', chk.get_active()) refresh_user_start(self.settings)
python
def on_start_at_login_toggled(self, chk): """Changes the activity of start_at_login in dconf """ self.settings.general.set_boolean('start-at-login', chk.get_active()) refresh_user_start(self.settings)
[ "def", "on_start_at_login_toggled", "(", "self", ",", "chk", ")", ":", "self", ".", "settings", ".", "general", ".", "set_boolean", "(", "'start-at-login'", ",", "chk", ".", "get_active", "(", ")", ")", "refresh_user_start", "(", "self", ".", "settings", ")"...
Changes the activity of start_at_login in dconf
[ "Changes", "the", "activity", "of", "start_at_login", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L480-L484
train
217,728
Guake/guake
guake/prefs.py
PrefsCallbacks.on_max_tab_name_length_changed
def on_max_tab_name_length_changed(self, spin): """Changes the value of max_tab_name_length in dconf """ val = int(spin.get_value()) self.settings.general.set_int('max-tab-name-length', val) self.prefDlg.update_vte_subwidgets_states()
python
def on_max_tab_name_length_changed(self, spin): """Changes the value of max_tab_name_length in dconf """ val = int(spin.get_value()) self.settings.general.set_int('max-tab-name-length', val) self.prefDlg.update_vte_subwidgets_states()
[ "def", "on_max_tab_name_length_changed", "(", "self", ",", "spin", ")", ":", "val", "=", "int", "(", "spin", ".", "get_value", "(", ")", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'max-tab-name-length'", ",", "val", ")", "self", ...
Changes the value of max_tab_name_length in dconf
[ "Changes", "the", "value", "of", "max_tab_name_length", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L501-L506
train
217,729
Guake/guake
guake/prefs.py
PrefsCallbacks.on_right_align_toggled
def on_right_align_toggled(self, chk): """set the horizontal alignment setting. """ v = chk.get_active() self.settings.general.set_int('window-halignment', 1 if v else 0)
python
def on_right_align_toggled(self, chk): """set the horizontal alignment setting. """ v = chk.get_active() self.settings.general.set_int('window-halignment', 1 if v else 0)
[ "def", "on_right_align_toggled", "(", "self", ",", "chk", ")", ":", "v", "=", "chk", ".", "get_active", "(", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-halignment'", ",", "1", "if", "v", "else", "0", ")" ]
set the horizontal alignment setting.
[ "set", "the", "horizontal", "alignment", "setting", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L514-L518
train
217,730
Guake/guake
guake/prefs.py
PrefsCallbacks.on_bottom_align_toggled
def on_bottom_align_toggled(self, chk): """set the vertical alignment setting. """ v = chk.get_active() self.settings.general.set_int('window-valignment', ALIGN_BOTTOM if v else ALIGN_TOP)
python
def on_bottom_align_toggled(self, chk): """set the vertical alignment setting. """ v = chk.get_active() self.settings.general.set_int('window-valignment', ALIGN_BOTTOM if v else ALIGN_TOP)
[ "def", "on_bottom_align_toggled", "(", "self", ",", "chk", ")", ":", "v", "=", "chk", ".", "get_active", "(", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-valignment'", ",", "ALIGN_BOTTOM", "if", "v", "else", "ALIGN_TOP", ")"...
set the vertical alignment setting.
[ "set", "the", "vertical", "alignment", "setting", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L520-L524
train
217,731
Guake/guake
guake/prefs.py
PrefsCallbacks.on_display_n_changed
def on_display_n_changed(self, combo): """Set the destination display in dconf. """ i = combo.get_active_iter() if not i: return model = combo.get_model() first_item_path = model.get_path(model.get_iter_first()) if model.get_path(i) == first_item_path: val_int = ALWAYS_ON_PRIMARY else: val = model.get_value(i, 0) val_int = int(val.split()[0]) # extracts 1 from '1' or from '1 (primary)' self.settings.general.set_int('display-n', val_int)
python
def on_display_n_changed(self, combo): """Set the destination display in dconf. """ i = combo.get_active_iter() if not i: return model = combo.get_model() first_item_path = model.get_path(model.get_iter_first()) if model.get_path(i) == first_item_path: val_int = ALWAYS_ON_PRIMARY else: val = model.get_value(i, 0) val_int = int(val.split()[0]) # extracts 1 from '1' or from '1 (primary)' self.settings.general.set_int('display-n', val_int)
[ "def", "on_display_n_changed", "(", "self", ",", "combo", ")", ":", "i", "=", "combo", ".", "get_active_iter", "(", ")", "if", "not", "i", ":", "return", "model", "=", "combo", ".", "get_model", "(", ")", "first_item_path", "=", "model", ".", "get_path",...
Set the destination display in dconf.
[ "Set", "the", "destination", "display", "in", "dconf", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L526-L542
train
217,732
Guake/guake
guake/prefs.py
PrefsCallbacks.on_window_height_value_changed
def on_window_height_value_changed(self, hscale): """Changes the value of window_height in dconf """ val = hscale.get_value() self.settings.general.set_int('window-height', int(val))
python
def on_window_height_value_changed(self, hscale): """Changes the value of window_height in dconf """ val = hscale.get_value() self.settings.general.set_int('window-height', int(val))
[ "def", "on_window_height_value_changed", "(", "self", ",", "hscale", ")", ":", "val", "=", "hscale", ".", "get_value", "(", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-height'", ",", "int", "(", "val", ")", ")" ]
Changes the value of window_height in dconf
[ "Changes", "the", "value", "of", "window_height", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L544-L548
train
217,733
Guake/guake
guake/prefs.py
PrefsCallbacks.on_window_width_value_changed
def on_window_width_value_changed(self, wscale): """Changes the value of window_width in dconf """ val = wscale.get_value() self.settings.general.set_int('window-width', int(val))
python
def on_window_width_value_changed(self, wscale): """Changes the value of window_width in dconf """ val = wscale.get_value() self.settings.general.set_int('window-width', int(val))
[ "def", "on_window_width_value_changed", "(", "self", ",", "wscale", ")", ":", "val", "=", "wscale", ".", "get_value", "(", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-width'", ",", "int", "(", "val", ")", ")" ]
Changes the value of window_width in dconf
[ "Changes", "the", "value", "of", "window_width", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L550-L554
train
217,734
Guake/guake
guake/prefs.py
PrefsCallbacks.on_window_halign_value_changed
def on_window_halign_value_changed(self, halign_button): """Changes the value of window_halignment in dconf """ which_align = { 'radiobutton_align_left': ALIGN_LEFT, 'radiobutton_align_right': ALIGN_RIGHT, 'radiobutton_align_center': ALIGN_CENTER } if halign_button.get_active(): self.settings.general.set_int( 'window-halignment', which_align[halign_button.get_name()] ) self.prefDlg.get_widget("window_horizontal_displacement").set_sensitive( which_align[halign_button.get_name()] != ALIGN_CENTER )
python
def on_window_halign_value_changed(self, halign_button): """Changes the value of window_halignment in dconf """ which_align = { 'radiobutton_align_left': ALIGN_LEFT, 'radiobutton_align_right': ALIGN_RIGHT, 'radiobutton_align_center': ALIGN_CENTER } if halign_button.get_active(): self.settings.general.set_int( 'window-halignment', which_align[halign_button.get_name()] ) self.prefDlg.get_widget("window_horizontal_displacement").set_sensitive( which_align[halign_button.get_name()] != ALIGN_CENTER )
[ "def", "on_window_halign_value_changed", "(", "self", ",", "halign_button", ")", ":", "which_align", "=", "{", "'radiobutton_align_left'", ":", "ALIGN_LEFT", ",", "'radiobutton_align_right'", ":", "ALIGN_RIGHT", ",", "'radiobutton_align_center'", ":", "ALIGN_CENTER", "}",...
Changes the value of window_halignment in dconf
[ "Changes", "the", "value", "of", "window_halignment", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L556-L570
train
217,735
Guake/guake
guake/prefs.py
PrefsCallbacks.on_history_size_value_changed
def on_history_size_value_changed(self, spin): """Changes the value of history_size in dconf """ val = int(spin.get_value()) self.settings.general.set_int('history-size', val) self._update_history_widgets()
python
def on_history_size_value_changed(self, spin): """Changes the value of history_size in dconf """ val = int(spin.get_value()) self.settings.general.set_int('history-size', val) self._update_history_widgets()
[ "def", "on_history_size_value_changed", "(", "self", ",", "spin", ")", ":", "val", "=", "int", "(", "spin", ".", "get_value", "(", ")", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'history-size'", ",", "val", ")", "self", ".", "...
Changes the value of history_size in dconf
[ "Changes", "the", "value", "of", "history_size", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L584-L589
train
217,736
Guake/guake
guake/prefs.py
PrefsCallbacks.on_transparency_value_changed
def on_transparency_value_changed(self, hscale): """Changes the value of background_transparency in dconf """ value = hscale.get_value() self.prefDlg.set_colors_from_settings() self.settings.styleBackground.set_int('transparency', MAX_TRANSPARENCY - int(value))
python
def on_transparency_value_changed(self, hscale): """Changes the value of background_transparency in dconf """ value = hscale.get_value() self.prefDlg.set_colors_from_settings() self.settings.styleBackground.set_int('transparency', MAX_TRANSPARENCY - int(value))
[ "def", "on_transparency_value_changed", "(", "self", ",", "hscale", ")", ":", "value", "=", "hscale", ".", "get_value", "(", ")", "self", ".", "prefDlg", ".", "set_colors_from_settings", "(", ")", "self", ".", "settings", ".", "styleBackground", ".", "set_int"...
Changes the value of background_transparency in dconf
[ "Changes", "the", "value", "of", "background_transparency", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L631-L636
train
217,737
Guake/guake
guake/prefs.py
PrefsCallbacks.on_backspace_binding_changed
def on_backspace_binding_changed(self, combo): """Changes the value of compat_backspace in dconf """ val = combo.get_active_text() self.settings.general.set_string('compat-backspace', ERASE_BINDINGS[val])
python
def on_backspace_binding_changed(self, combo): """Changes the value of compat_backspace in dconf """ val = combo.get_active_text() self.settings.general.set_string('compat-backspace', ERASE_BINDINGS[val])
[ "def", "on_backspace_binding_changed", "(", "self", ",", "combo", ")", ":", "val", "=", "combo", ".", "get_active_text", "(", ")", "self", ".", "settings", ".", "general", ".", "set_string", "(", "'compat-backspace'", ",", "ERASE_BINDINGS", "[", "val", "]", ...
Changes the value of compat_backspace in dconf
[ "Changes", "the", "value", "of", "compat_backspace", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L640-L644
train
217,738
Guake/guake
guake/prefs.py
PrefsCallbacks.on_window_vertical_displacement_value_changed
def on_window_vertical_displacement_value_changed(self, spin): """Changes the value of window-vertical-displacement """ self.settings.general.set_int('window-vertical-displacement', int(spin.get_value()))
python
def on_window_vertical_displacement_value_changed(self, spin): """Changes the value of window-vertical-displacement """ self.settings.general.set_int('window-vertical-displacement', int(spin.get_value()))
[ "def", "on_window_vertical_displacement_value_changed", "(", "self", ",", "spin", ")", ":", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-vertical-displacement'", ",", "int", "(", "spin", ".", "get_value", "(", ")", ")", ")" ]
Changes the value of window-vertical-displacement
[ "Changes", "the", "value", "of", "window", "-", "vertical", "-", "displacement" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L691-L694
train
217,739
Guake/guake
guake/prefs.py
PrefsCallbacks.on_window_horizontal_displacement_value_changed
def on_window_horizontal_displacement_value_changed(self, spin): """Changes the value of window-horizontal-displacement """ self.settings.general.set_int('window-horizontal-displacement', int(spin.get_value()))
python
def on_window_horizontal_displacement_value_changed(self, spin): """Changes the value of window-horizontal-displacement """ self.settings.general.set_int('window-horizontal-displacement', int(spin.get_value()))
[ "def", "on_window_horizontal_displacement_value_changed", "(", "self", ",", "spin", ")", ":", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-horizontal-displacement'", ",", "int", "(", "spin", ".", "get_value", "(", ")", ")", ")" ]
Changes the value of window-horizontal-displacement
[ "Changes", "the", "value", "of", "window", "-", "horizontal", "-", "displacement" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L696-L699
train
217,740
Guake/guake
guake/prefs.py
PrefsDialog.toggle_use_font_background_sensitivity
def toggle_use_font_background_sensitivity(self, chk): """If the user chooses to use the gnome default font configuration it means that he will not be able to use the font selector. """ self.get_widget('palette_16').set_sensitive(chk.get_active()) self.get_widget('palette_17').set_sensitive(chk.get_active())
python
def toggle_use_font_background_sensitivity(self, chk): """If the user chooses to use the gnome default font configuration it means that he will not be able to use the font selector. """ self.get_widget('palette_16').set_sensitive(chk.get_active()) self.get_widget('palette_17').set_sensitive(chk.get_active())
[ "def", "toggle_use_font_background_sensitivity", "(", "self", ",", "chk", ")", ":", "self", ".", "get_widget", "(", "'palette_16'", ")", ".", "set_sensitive", "(", "chk", ".", "get_active", "(", ")", ")", "self", ".", "get_widget", "(", "'palette_17'", ")", ...
If the user chooses to use the gnome default font configuration it means that he will not be able to use the font selector.
[ "If", "the", "user", "chooses", "to", "use", "the", "gnome", "default", "font", "configuration", "it", "means", "that", "he", "will", "not", "be", "able", "to", "use", "the", "font", "selector", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L866-L872
train
217,741
Guake/guake
guake/prefs.py
PrefsDialog.toggle_quick_open_command_line_sensitivity
def toggle_quick_open_command_line_sensitivity(self, chk): """When the user unchecks 'enable quick open', the command line should be disabled """ self.get_widget('quick_open_command_line').set_sensitive(chk.get_active()) self.get_widget('quick_open_in_current_terminal').set_sensitive(chk.get_active())
python
def toggle_quick_open_command_line_sensitivity(self, chk): """When the user unchecks 'enable quick open', the command line should be disabled """ self.get_widget('quick_open_command_line').set_sensitive(chk.get_active()) self.get_widget('quick_open_in_current_terminal').set_sensitive(chk.get_active())
[ "def", "toggle_quick_open_command_line_sensitivity", "(", "self", ",", "chk", ")", ":", "self", ".", "get_widget", "(", "'quick_open_command_line'", ")", ".", "set_sensitive", "(", "chk", ".", "get_active", "(", ")", ")", "self", ".", "get_widget", "(", "'quick_...
When the user unchecks 'enable quick open', the command line should be disabled
[ "When", "the", "user", "unchecks", "enable", "quick", "open", "the", "command", "line", "should", "be", "disabled" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L880-L884
train
217,742
Guake/guake
guake/prefs.py
PrefsDialog.on_cursor_shape_changed
def on_cursor_shape_changed(self, combo): """Changes the value of cursor_shape in dconf """ index = combo.get_active() self.settings.style.set_int('cursor-shape', index)
python
def on_cursor_shape_changed(self, combo): """Changes the value of cursor_shape in dconf """ index = combo.get_active() self.settings.style.set_int('cursor-shape', index)
[ "def", "on_cursor_shape_changed", "(", "self", ",", "combo", ")", ":", "index", "=", "combo", ".", "get_active", "(", ")", "self", ".", "settings", ".", "style", ".", "set_int", "(", "'cursor-shape'", ",", "index", ")" ]
Changes the value of cursor_shape in dconf
[ "Changes", "the", "value", "of", "cursor_shape", "in", "dconf" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L918-L922
train
217,743
Guake/guake
guake/prefs.py
PrefsDialog.set_palette_name
def set_palette_name(self, palette_name): """If the given palette matches an existing one, shows it in the combobox """ combo = self.get_widget('palette_name') found = False log.debug("wanting palette: %r", palette_name) for i in combo.get_model(): if i[0] == palette_name: combo.set_active_iter(i.iter) found = True break if not found: combo.set_active(self.custom_palette_index)
python
def set_palette_name(self, palette_name): """If the given palette matches an existing one, shows it in the combobox """ combo = self.get_widget('palette_name') found = False log.debug("wanting palette: %r", palette_name) for i in combo.get_model(): if i[0] == palette_name: combo.set_active_iter(i.iter) found = True break if not found: combo.set_active(self.custom_palette_index)
[ "def", "set_palette_name", "(", "self", ",", "palette_name", ")", ":", "combo", "=", "self", ".", "get_widget", "(", "'palette_name'", ")", "found", "=", "False", "log", ".", "debug", "(", "\"wanting palette: %r\"", ",", "palette_name", ")", "for", "i", "in"...
If the given palette matches an existing one, shows it in the combobox
[ "If", "the", "given", "palette", "matches", "an", "existing", "one", "shows", "it", "in", "the", "combobox" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L944-L957
train
217,744
Guake/guake
guake/prefs.py
PrefsDialog.set_palette_colors
def set_palette_colors(self, palette): """Updates the color buttons with the given palette """ palette = palette.split(':') for i, pal in enumerate(palette): x, color = Gdk.Color.parse(pal) self.get_widget('palette_%d' % i).set_color(color)
python
def set_palette_colors(self, palette): """Updates the color buttons with the given palette """ palette = palette.split(':') for i, pal in enumerate(palette): x, color = Gdk.Color.parse(pal) self.get_widget('palette_%d' % i).set_color(color)
[ "def", "set_palette_colors", "(", "self", ",", "palette", ")", ":", "palette", "=", "palette", ".", "split", "(", "':'", ")", "for", "i", ",", "pal", "in", "enumerate", "(", "palette", ")", ":", "x", ",", "color", "=", "Gdk", ".", "Color", ".", "pa...
Updates the color buttons with the given palette
[ "Updates", "the", "color", "buttons", "with", "the", "given", "palette" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1000-L1006
train
217,745
Guake/guake
guake/prefs.py
PrefsDialog._load_hooks_settings
def _load_hooks_settings(self): """load hooks settings""" log.debug("executing _load_hooks_settings") hook_show_widget = self.get_widget("hook_show") hook_show_setting = self.settings.hooks.get_string("show") if hook_show_widget is not None: if hook_show_setting is not None: hook_show_widget.set_text(hook_show_setting)
python
def _load_hooks_settings(self): """load hooks settings""" log.debug("executing _load_hooks_settings") hook_show_widget = self.get_widget("hook_show") hook_show_setting = self.settings.hooks.get_string("show") if hook_show_widget is not None: if hook_show_setting is not None: hook_show_widget.set_text(hook_show_setting)
[ "def", "_load_hooks_settings", "(", "self", ")", ":", "log", ".", "debug", "(", "\"executing _load_hooks_settings\"", ")", "hook_show_widget", "=", "self", ".", "get_widget", "(", "\"hook_show\"", ")", "hook_show_setting", "=", "self", ".", "settings", ".", "hooks...
load hooks settings
[ "load", "hooks", "settings" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1028-L1035
train
217,746
Guake/guake
guake/prefs.py
PrefsDialog._load_screen_settings
def _load_screen_settings(self): """Load screen settings""" # display number / use primary display combo = self.get_widget('display_n') dest_screen = self.settings.general.get_int('display-n') # If Guake is configured to use a screen that is not currently attached, # default to 'primary display' option. screen = self.get_widget('config-window').get_screen() n_screens = screen.get_n_monitors() if dest_screen > n_screens - 1: self.settings.general.set_boolean('mouse-display', False) dest_screen = screen.get_primary_monitor() self.settings.general.set_int('display-n', dest_screen) if dest_screen == ALWAYS_ON_PRIMARY: first_item = combo.get_model().get_iter_first() combo.set_active_iter(first_item) else: seen_first = False # first item "always on primary" is special for i in combo.get_model(): if seen_first: i_int = int(i[0].split()[0]) # extracts 1 from '1' or from '1 (primary)' if i_int == dest_screen: combo.set_active_iter(i.iter) else: seen_first = True
python
def _load_screen_settings(self): """Load screen settings""" # display number / use primary display combo = self.get_widget('display_n') dest_screen = self.settings.general.get_int('display-n') # If Guake is configured to use a screen that is not currently attached, # default to 'primary display' option. screen = self.get_widget('config-window').get_screen() n_screens = screen.get_n_monitors() if dest_screen > n_screens - 1: self.settings.general.set_boolean('mouse-display', False) dest_screen = screen.get_primary_monitor() self.settings.general.set_int('display-n', dest_screen) if dest_screen == ALWAYS_ON_PRIMARY: first_item = combo.get_model().get_iter_first() combo.set_active_iter(first_item) else: seen_first = False # first item "always on primary" is special for i in combo.get_model(): if seen_first: i_int = int(i[0].split()[0]) # extracts 1 from '1' or from '1 (primary)' if i_int == dest_screen: combo.set_active_iter(i.iter) else: seen_first = True
[ "def", "_load_screen_settings", "(", "self", ")", ":", "# display number / use primary display", "combo", "=", "self", ".", "get_widget", "(", "'display_n'", ")", "dest_screen", "=", "self", ".", "settings", ".", "general", ".", "get_int", "(", "'display-n'", ")",...
Load screen settings
[ "Load", "screen", "settings" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1046-L1071
train
217,747
Guake/guake
guake/prefs.py
PrefsDialog.populate_keys_tree
def populate_keys_tree(self): """Reads the HOTKEYS global variable and insert all data in the TreeStore used by the preferences window treeview. """ for group in HOTKEYS: parent = self.store.append(None, [None, group['label'], None, None]) for item in group['keys']: if item['key'] == "show-hide" or item['key'] == "show-focus": accel = self.settings.keybindingsGlobal.get_string(item['key']) else: accel = self.settings.keybindingsLocal.get_string(item['key']) gsettings_path = item['key'] keycode, mask = Gtk.accelerator_parse(accel) keylabel = Gtk.accelerator_get_label(keycode, mask) self.store.append(parent, [gsettings_path, item['label'], keylabel, accel]) self.get_widget('treeview-keys').expand_all()
python
def populate_keys_tree(self): """Reads the HOTKEYS global variable and insert all data in the TreeStore used by the preferences window treeview. """ for group in HOTKEYS: parent = self.store.append(None, [None, group['label'], None, None]) for item in group['keys']: if item['key'] == "show-hide" or item['key'] == "show-focus": accel = self.settings.keybindingsGlobal.get_string(item['key']) else: accel = self.settings.keybindingsLocal.get_string(item['key']) gsettings_path = item['key'] keycode, mask = Gtk.accelerator_parse(accel) keylabel = Gtk.accelerator_get_label(keycode, mask) self.store.append(parent, [gsettings_path, item['label'], keylabel, accel]) self.get_widget('treeview-keys').expand_all()
[ "def", "populate_keys_tree", "(", "self", ")", ":", "for", "group", "in", "HOTKEYS", ":", "parent", "=", "self", ".", "store", ".", "append", "(", "None", ",", "[", "None", ",", "group", "[", "'label'", "]", ",", "None", ",", "None", "]", ")", "for...
Reads the HOTKEYS global variable and insert all data in the TreeStore used by the preferences window treeview.
[ "Reads", "the", "HOTKEYS", "global", "variable", "and", "insert", "all", "data", "in", "the", "TreeStore", "used", "by", "the", "preferences", "window", "treeview", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1340-L1355
train
217,748
Guake/guake
guake/prefs.py
PrefsDialog.populate_display_n
def populate_display_n(self): """Get the number of displays and populate this drop-down box with them all. Prepend the "always on primary" option. """ cb = self.get_widget('display_n') screen = self.get_widget('config-window').get_screen() cb.append_text("always on primary") for m in range(0, int(screen.get_n_monitors())): if m == int(screen.get_primary_monitor()): # TODO l10n cb.append_text(str(m) + ' ' + '(primary)') else: cb.append_text(str(m))
python
def populate_display_n(self): """Get the number of displays and populate this drop-down box with them all. Prepend the "always on primary" option. """ cb = self.get_widget('display_n') screen = self.get_widget('config-window').get_screen() cb.append_text("always on primary") for m in range(0, int(screen.get_n_monitors())): if m == int(screen.get_primary_monitor()): # TODO l10n cb.append_text(str(m) + ' ' + '(primary)') else: cb.append_text(str(m))
[ "def", "populate_display_n", "(", "self", ")", ":", "cb", "=", "self", ".", "get_widget", "(", "'display_n'", ")", "screen", "=", "self", ".", "get_widget", "(", "'config-window'", ")", ".", "get_screen", "(", ")", "cb", ".", "append_text", "(", "\"always ...
Get the number of displays and populate this drop-down box with them all. Prepend the "always on primary" option.
[ "Get", "the", "number", "of", "displays", "and", "populate", "this", "drop", "-", "down", "box", "with", "them", "all", ".", "Prepend", "the", "always", "on", "primary", "option", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1357-L1371
train
217,749
Guake/guake
guake/prefs.py
PrefsDialog.on_accel_cleared
def on_accel_cleared(self, cellrendereraccel, path): """If the user tries to clear a keybinding with the backspace key this callback will be called and it just fill the model with an empty key and set the 'disabled' string in dconf path. """ dconf_path = self.store[path][HOTKET_MODEL_INDEX_DCONF] if dconf_path == "show-hide": # cannot disable 'show-hide' hotkey log.warn("Cannot disable 'show-hide' hotkey") self.settings.keybindingsGlobal.set_string(dconf_path, old_accel) else: self.store[path][HOTKET_MODEL_INDEX_HUMAN_ACCEL] = "" self.store[path][HOTKET_MODEL_INDEX_ACCEL] = "None" if dconf_path == "show-focus": self.settings.keybindingsGlobal.set_string(dconf_path, 'disabled') else: self.settings.keybindingsLocal.set_string(dconf_path, 'disabled')
python
def on_accel_cleared(self, cellrendereraccel, path): """If the user tries to clear a keybinding with the backspace key this callback will be called and it just fill the model with an empty key and set the 'disabled' string in dconf path. """ dconf_path = self.store[path][HOTKET_MODEL_INDEX_DCONF] if dconf_path == "show-hide": # cannot disable 'show-hide' hotkey log.warn("Cannot disable 'show-hide' hotkey") self.settings.keybindingsGlobal.set_string(dconf_path, old_accel) else: self.store[path][HOTKET_MODEL_INDEX_HUMAN_ACCEL] = "" self.store[path][HOTKET_MODEL_INDEX_ACCEL] = "None" if dconf_path == "show-focus": self.settings.keybindingsGlobal.set_string(dconf_path, 'disabled') else: self.settings.keybindingsLocal.set_string(dconf_path, 'disabled')
[ "def", "on_accel_cleared", "(", "self", ",", "cellrendereraccel", ",", "path", ")", ":", "dconf_path", "=", "self", ".", "store", "[", "path", "]", "[", "HOTKET_MODEL_INDEX_DCONF", "]", "if", "dconf_path", "==", "\"show-hide\"", ":", "# cannot disable 'show-hide' ...
If the user tries to clear a keybinding with the backspace key this callback will be called and it just fill the model with an empty key and set the 'disabled' string in dconf path.
[ "If", "the", "user", "tries", "to", "clear", "a", "keybinding", "with", "the", "backspace", "key", "this", "callback", "will", "be", "called", "and", "it", "just", "fill", "the", "model", "with", "an", "empty", "key", "and", "set", "the", "disabled", "st...
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1438-L1455
train
217,750
Guake/guake
guake/prefs.py
PrefsDialog.start_editing
def start_editing(self, treeview, event): """Make the treeview grab the focus and start editing the cell that the user has clicked to avoid confusion with two or three clicks before editing a keybinding. Thanks to gnome-keybinding-properties.c =) """ x, y = int(event.x), int(event.y) ret = treeview.get_path_at_pos(x, y) if not ret: return False path, column, cellx, celly = ret treeview.row_activated(path, Gtk.TreeViewColumn(None)) treeview.set_cursor(path) return False
python
def start_editing(self, treeview, event): """Make the treeview grab the focus and start editing the cell that the user has clicked to avoid confusion with two or three clicks before editing a keybinding. Thanks to gnome-keybinding-properties.c =) """ x, y = int(event.x), int(event.y) ret = treeview.get_path_at_pos(x, y) if not ret: return False path, column, cellx, celly = ret treeview.row_activated(path, Gtk.TreeViewColumn(None)) treeview.set_cursor(path) return False
[ "def", "start_editing", "(", "self", ",", "treeview", ",", "event", ")", ":", "x", ",", "y", "=", "int", "(", "event", ".", "x", ")", ",", "int", "(", "event", ".", "y", ")", "ret", "=", "treeview", ".", "get_path_at_pos", "(", "x", ",", "y", "...
Make the treeview grab the focus and start editing the cell that the user has clicked to avoid confusion with two or three clicks before editing a keybinding. Thanks to gnome-keybinding-properties.c =)
[ "Make", "the", "treeview", "grab", "the", "focus", "and", "start", "editing", "the", "cell", "that", "the", "user", "has", "clicked", "to", "avoid", "confusion", "with", "two", "or", "three", "clicks", "before", "editing", "a", "keybinding", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1457-L1474
train
217,751
Guake/guake
guake/utils.py
save_tabs_when_changed
def save_tabs_when_changed(func): """Decorator for save-tabs-when-changed """ def wrapper(*args, **kwargs): func(*args, **kwargs) log.debug("mom, I've been called: %s %s", func.__name__, func) # Find me the Guake! clsname = args[0].__class__.__name__ g = None if clsname == 'Guake': g = args[0] elif getattr(args[0], 'get_guake', None): g = args[0].get_guake() elif getattr(args[0], 'get_notebook', None): g = args[0].get_notebook().guake elif getattr(args[0], 'guake', None): g = args[0].guake elif getattr(args[0], 'notebook', None): g = args[0].notebook.guake # Tada! if g and g.settings.general.get_boolean('save-tabs-when-changed'): g.save_tabs() return wrapper
python
def save_tabs_when_changed(func): """Decorator for save-tabs-when-changed """ def wrapper(*args, **kwargs): func(*args, **kwargs) log.debug("mom, I've been called: %s %s", func.__name__, func) # Find me the Guake! clsname = args[0].__class__.__name__ g = None if clsname == 'Guake': g = args[0] elif getattr(args[0], 'get_guake', None): g = args[0].get_guake() elif getattr(args[0], 'get_notebook', None): g = args[0].get_notebook().guake elif getattr(args[0], 'guake', None): g = args[0].guake elif getattr(args[0], 'notebook', None): g = args[0].notebook.guake # Tada! if g and g.settings.general.get_boolean('save-tabs-when-changed'): g.save_tabs() return wrapper
[ "def", "save_tabs_when_changed", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "log", ".", "debug", "(", "\"mom, I've been called: %s %s\"", ",", "f...
Decorator for save-tabs-when-changed
[ "Decorator", "for", "save", "-", "tabs", "-", "when", "-", "changed" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/utils.py#L58-L84
train
217,752
Guake/guake
guake/utils.py
RectCalculator.get_final_window_monitor
def get_final_window_monitor(cls, settings, window): """Gets the final screen number for the main window of guake. """ screen = window.get_screen() # fetch settings use_mouse = settings.general.get_boolean('mouse-display') dest_screen = settings.general.get_int('display-n') if use_mouse: # TODO PORT get_pointer is deprecated # https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-pointer win, x, y, _ = screen.get_root_window().get_pointer() dest_screen = screen.get_monitor_at_point(x, y) # If Guake is configured to use a screen that is not currently attached, # default to 'primary display' option. n_screens = screen.get_n_monitors() if dest_screen > n_screens - 1: settings.general.set_boolean('mouse-display', False) settings.general.set_int('display-n', dest_screen) dest_screen = screen.get_primary_monitor() # Use primary display if configured if dest_screen == ALWAYS_ON_PRIMARY: dest_screen = screen.get_primary_monitor() return dest_screen
python
def get_final_window_monitor(cls, settings, window): """Gets the final screen number for the main window of guake. """ screen = window.get_screen() # fetch settings use_mouse = settings.general.get_boolean('mouse-display') dest_screen = settings.general.get_int('display-n') if use_mouse: # TODO PORT get_pointer is deprecated # https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-pointer win, x, y, _ = screen.get_root_window().get_pointer() dest_screen = screen.get_monitor_at_point(x, y) # If Guake is configured to use a screen that is not currently attached, # default to 'primary display' option. n_screens = screen.get_n_monitors() if dest_screen > n_screens - 1: settings.general.set_boolean('mouse-display', False) settings.general.set_int('display-n', dest_screen) dest_screen = screen.get_primary_monitor() # Use primary display if configured if dest_screen == ALWAYS_ON_PRIMARY: dest_screen = screen.get_primary_monitor() return dest_screen
[ "def", "get_final_window_monitor", "(", "cls", ",", "settings", ",", "window", ")", ":", "screen", "=", "window", ".", "get_screen", "(", ")", "# fetch settings", "use_mouse", "=", "settings", ".", "general", ".", "get_boolean", "(", "'mouse-display'", ")", "d...
Gets the final screen number for the main window of guake.
[ "Gets", "the", "final", "screen", "number", "for", "the", "main", "window", "of", "guake", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/utils.py#L312-L341
train
217,753
Guake/guake
guake/dialogs.py
PromptQuitDialog.quit
def quit(self): """Run the "are you sure" dialog for quitting Guake """ # Stop an open "close tab" dialog from obstructing a quit response = self.run() == Gtk.ResponseType.YES self.destroy() # Keep Guake focussed after dismissing tab-close prompt # if tab == -1: # self.window.present() return response
python
def quit(self): """Run the "are you sure" dialog for quitting Guake """ # Stop an open "close tab" dialog from obstructing a quit response = self.run() == Gtk.ResponseType.YES self.destroy() # Keep Guake focussed after dismissing tab-close prompt # if tab == -1: # self.window.present() return response
[ "def", "quit", "(", "self", ")", ":", "# Stop an open \"close tab\" dialog from obstructing a quit", "response", "=", "self", ".", "run", "(", ")", "==", "Gtk", ".", "ResponseType", ".", "YES", "self", ".", "destroy", "(", ")", "# Keep Guake focussed after dismissin...
Run the "are you sure" dialog for quitting Guake
[ "Run", "the", "are", "you", "sure", "dialog", "for", "quitting", "Guake" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/dialogs.py#L70-L79
train
217,754
Guake/guake
guake/boxes.py
TerminalBox.set_terminal
def set_terminal(self, terminal): """Packs the terminal widget. """ if self.terminal is not None: raise RuntimeError("TerminalBox: terminal already set") self.terminal = terminal self.terminal.connect("grab-focus", self.on_terminal_focus) self.terminal.connect("button-press-event", self.on_button_press, None) self.terminal.connect('child-exited', self.on_terminal_exited) self.pack_start(self.terminal, True, True, 0) self.terminal.show() self.add_scroll_bar()
python
def set_terminal(self, terminal): """Packs the terminal widget. """ if self.terminal is not None: raise RuntimeError("TerminalBox: terminal already set") self.terminal = terminal self.terminal.connect("grab-focus", self.on_terminal_focus) self.terminal.connect("button-press-event", self.on_button_press, None) self.terminal.connect('child-exited', self.on_terminal_exited) self.pack_start(self.terminal, True, True, 0) self.terminal.show() self.add_scroll_bar()
[ "def", "set_terminal", "(", "self", ",", "terminal", ")", ":", "if", "self", ".", "terminal", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"TerminalBox: terminal already set\"", ")", "self", ".", "terminal", "=", "terminal", "self", ".", "terminal...
Packs the terminal widget.
[ "Packs", "the", "terminal", "widget", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/boxes.py#L309-L321
train
217,755
Guake/guake
guake/boxes.py
TerminalBox.add_scroll_bar
def add_scroll_bar(self): """Packs the scrollbar. """ adj = self.terminal.get_vadjustment() scroll = Gtk.VScrollbar(adj) scroll.show() self.pack_start(scroll, False, False, 0)
python
def add_scroll_bar(self): """Packs the scrollbar. """ adj = self.terminal.get_vadjustment() scroll = Gtk.VScrollbar(adj) scroll.show() self.pack_start(scroll, False, False, 0)
[ "def", "add_scroll_bar", "(", "self", ")", ":", "adj", "=", "self", ".", "terminal", ".", "get_vadjustment", "(", ")", "scroll", "=", "Gtk", ".", "VScrollbar", "(", "adj", ")", "scroll", ".", "show", "(", ")", "self", ".", "pack_start", "(", "scroll", ...
Packs the scrollbar.
[ "Packs", "the", "scrollbar", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/boxes.py#L323-L329
train
217,756
Guake/guake
guake/guake_app.py
Guake.execute_command
def execute_command(self, command, tab=None): # TODO DBUS_ONLY """Execute the `command' in the `tab'. If tab is None, the command will be executed in the currently selected tab. Command should end with '\n', otherwise it will be appended to the string. """ # TODO CONTEXTMENU this has to be rewriten and only serves the # dbus interface, maybe this should be moved to dbusinterface.py if not self.get_notebook().has_page(): self.add_tab() if command[-1] != '\n': command += '\n' terminal = self.get_notebook().get_current_terminal() terminal.feed_child(command)
python
def execute_command(self, command, tab=None): # TODO DBUS_ONLY """Execute the `command' in the `tab'. If tab is None, the command will be executed in the currently selected tab. Command should end with '\n', otherwise it will be appended to the string. """ # TODO CONTEXTMENU this has to be rewriten and only serves the # dbus interface, maybe this should be moved to dbusinterface.py if not self.get_notebook().has_page(): self.add_tab() if command[-1] != '\n': command += '\n' terminal = self.get_notebook().get_current_terminal() terminal.feed_child(command)
[ "def", "execute_command", "(", "self", ",", "command", ",", "tab", "=", "None", ")", ":", "# TODO DBUS_ONLY", "# TODO CONTEXTMENU this has to be rewriten and only serves the", "# dbus interface, maybe this should be moved to dbusinterface.py", "if", "not", "self", ".", "get_not...
Execute the `command' in the `tab'. If tab is None, the command will be executed in the currently selected tab. Command should end with '\n', otherwise it will be appended to the string.
[ "Execute", "the", "command", "in", "the", "tab", ".", "If", "tab", "is", "None", "the", "command", "will", "be", "executed", "in", "the", "currently", "selected", "tab", ".", "Command", "should", "end", "with", "\\", "n", "otherwise", "it", "will", "be",...
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L386-L402
train
217,757
Guake/guake
guake/guake_app.py
Guake.execute_command_by_uuid
def execute_command_by_uuid(self, tab_uuid, command): # TODO DBUS_ONLY """Execute the `command' in the tab whose terminal has the `tab_uuid' uuid """ if command[-1] != '\n': command += '\n' try: tab_uuid = uuid.UUID(tab_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == tab_uuid ) except ValueError: pass else: terminals = self.get_notebook().get_terminals_for_page(page_index) for current_vte in terminals: current_vte.feed_child(command)
python
def execute_command_by_uuid(self, tab_uuid, command): # TODO DBUS_ONLY """Execute the `command' in the tab whose terminal has the `tab_uuid' uuid """ if command[-1] != '\n': command += '\n' try: tab_uuid = uuid.UUID(tab_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == tab_uuid ) except ValueError: pass else: terminals = self.get_notebook().get_terminals_for_page(page_index) for current_vte in terminals: current_vte.feed_child(command)
[ "def", "execute_command_by_uuid", "(", "self", ",", "tab_uuid", ",", "command", ")", ":", "# TODO DBUS_ONLY", "if", "command", "[", "-", "1", "]", "!=", "'\\n'", ":", "command", "+=", "'\\n'", "try", ":", "tab_uuid", "=", "uuid", ".", "UUID", "(", "tab_u...
Execute the `command' in the tab whose terminal has the `tab_uuid' uuid
[ "Execute", "the", "command", "in", "the", "tab", "whose", "terminal", "has", "the", "tab_uuid", "uuid" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L404-L421
train
217,758
Guake/guake
guake/guake_app.py
Guake.on_window_losefocus
def on_window_losefocus(self, window, event): """Hides terminal main window when it loses the focus and if the window_losefocus gconf variable is True. """ if not HidePrevention(self.window).may_hide(): return value = self.settings.general.get_boolean('window-losefocus') visible = window.get_property('visible') self.losefocus_time = get_server_time(self.window) if visible and value: log.info("Hiding on focus lose") self.hide()
python
def on_window_losefocus(self, window, event): """Hides terminal main window when it loses the focus and if the window_losefocus gconf variable is True. """ if not HidePrevention(self.window).may_hide(): return value = self.settings.general.get_boolean('window-losefocus') visible = window.get_property('visible') self.losefocus_time = get_server_time(self.window) if visible and value: log.info("Hiding on focus lose") self.hide()
[ "def", "on_window_losefocus", "(", "self", ",", "window", ",", "event", ")", ":", "if", "not", "HidePrevention", "(", "self", ".", "window", ")", ".", "may_hide", "(", ")", ":", "return", "value", "=", "self", ".", "settings", ".", "general", ".", "get...
Hides terminal main window when it loses the focus and if the window_losefocus gconf variable is True.
[ "Hides", "terminal", "main", "window", "when", "it", "loses", "the", "focus", "and", "if", "the", "window_losefocus", "gconf", "variable", "is", "True", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L423-L435
train
217,759
Guake/guake
guake/guake_app.py
Guake.show_menu
def show_menu(self, status_icon, button, activate_time): """Show the tray icon menu. """ menu = self.get_widget('tray-menu') menu.popup(None, None, None, Gtk.StatusIcon.position_menu, button, activate_time)
python
def show_menu(self, status_icon, button, activate_time): """Show the tray icon menu. """ menu = self.get_widget('tray-menu') menu.popup(None, None, None, Gtk.StatusIcon.position_menu, button, activate_time)
[ "def", "show_menu", "(", "self", ",", "status_icon", ",", "button", ",", "activate_time", ")", ":", "menu", "=", "self", ".", "get_widget", "(", "'tray-menu'", ")", "menu", ".", "popup", "(", "None", ",", "None", ",", "None", ",", "Gtk", ".", "StatusIc...
Show the tray icon menu.
[ "Show", "the", "tray", "icon", "menu", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L437-L441
train
217,760
Guake/guake
guake/guake_app.py
Guake.show_hide
def show_hide(self, *args): """Toggles the main window visibility """ log.debug("Show_hide called") if self.forceHide: self.forceHide = False return if not HidePrevention(self.window).may_hide(): return if not self.win_prepare(): return if not self.window.get_property('visible'): log.info("Showing the terminal") self.show() self.set_terminal_focus() return # Disable the focus_if_open feature # - if doesn't work seamlessly on all system # - self.window.window.get_state doesn't provides us the right information on all # systems, especially on MATE/XFCE # # if self.client.get_bool(KEY('/general/focus_if_open')): # restore_focus = False # if self.window.window: # state = int(self.window.window.get_state()) # if ((state & GDK_WINDOW_STATE_STICKY or # state & GDK_WINDOW_STATE_WITHDRAWN # )): # restore_focus = True # else: # restore_focus = True # if not self.hidden: # restore_focus = True # if restore_focus: # log.debug("DBG: Restoring the focus to the terminal") # self.hide() # self.show() # self.window.window.focus() # self.set_terminal_focus() # return log.info("Hiding the terminal") self.hide()
python
def show_hide(self, *args): """Toggles the main window visibility """ log.debug("Show_hide called") if self.forceHide: self.forceHide = False return if not HidePrevention(self.window).may_hide(): return if not self.win_prepare(): return if not self.window.get_property('visible'): log.info("Showing the terminal") self.show() self.set_terminal_focus() return # Disable the focus_if_open feature # - if doesn't work seamlessly on all system # - self.window.window.get_state doesn't provides us the right information on all # systems, especially on MATE/XFCE # # if self.client.get_bool(KEY('/general/focus_if_open')): # restore_focus = False # if self.window.window: # state = int(self.window.window.get_state()) # if ((state & GDK_WINDOW_STATE_STICKY or # state & GDK_WINDOW_STATE_WITHDRAWN # )): # restore_focus = True # else: # restore_focus = True # if not self.hidden: # restore_focus = True # if restore_focus: # log.debug("DBG: Restoring the focus to the terminal") # self.hide() # self.show() # self.window.window.focus() # self.set_terminal_focus() # return log.info("Hiding the terminal") self.hide()
[ "def", "show_hide", "(", "self", ",", "*", "args", ")", ":", "log", ".", "debug", "(", "\"Show_hide called\"", ")", "if", "self", ".", "forceHide", ":", "self", ".", "forceHide", "=", "False", "return", "if", "not", "HidePrevention", "(", "self", ".", ...
Toggles the main window visibility
[ "Toggles", "the", "main", "window", "visibility" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L472-L518
train
217,761
Guake/guake
guake/guake_app.py
Guake.show
def show(self): """Shows the main window and grabs the focus on it. """ self.hidden = False # setting window in all desktops window_rect = RectCalculator.set_final_window_rect(self.settings, self.window) self.window.stick() # add tab must be called before window.show to avoid a # blank screen before adding the tab. if not self.get_notebook().has_page(): self.add_tab() self.window.set_keep_below(False) self.window.show_all() # this is needed because self.window.show_all() results in showing every # thing which includes the scrollbar too self.settings.general.triggerOnChangedValue(self.settings.general, "use-scrollbar") # move the window even when in fullscreen-mode log.debug("Moving window to: %r", window_rect) self.window.move(window_rect.x, window_rect.y) # this works around an issue in fluxbox if not FullscreenManager(self.settings, self.window).is_fullscreen(): self.settings.general.triggerOnChangedValue(self.settings.general, 'window-height') time = get_server_time(self.window) # TODO PORT this # When minized, the window manager seems to refuse to resume # log.debug("self.window: %s. Dir=%s", type(self.window), dir(self.window)) # is_iconified = self.is_iconified() # if is_iconified: # log.debug("Is iconified. Ubuntu Trick => " # "removing skip_taskbar_hint and skip_pager_hint " # "so deiconify can work!") # self.get_widget('window-root').set_skip_taskbar_hint(False) # self.get_widget('window-root').set_skip_pager_hint(False) # self.get_widget('window-root').set_urgency_hint(False) # log.debug("get_skip_taskbar_hint: {}".format( # self.get_widget('window-root').get_skip_taskbar_hint())) # log.debug("get_skip_pager_hint: {}".format( # self.get_widget('window-root').get_skip_pager_hint())) # log.debug("get_urgency_hint: {}".format( # self.get_widget('window-root').get_urgency_hint())) # glib.timeout_add_seconds(1, lambda: self.timeout_restore(time)) # log.debug("order to present and deiconify") self.window.present() self.window.deiconify() self.window.show() self.window.get_window().focus(time) self.window.set_type_hint(Gdk.WindowTypeHint.DOCK) self.window.set_type_hint(Gdk.WindowTypeHint.NORMAL) # log.debug("Restoring skip_taskbar_hint and skip_pager_hint") # if is_iconified: # self.get_widget('window-root').set_skip_taskbar_hint(False) # self.get_widget('window-root').set_skip_pager_hint(False) # self.get_widget('window-root').set_urgency_hint(False) # This is here because vte color configuration works only after the # widget is shown. self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'color') self.settings.styleBackground.triggerOnChangedValue(self.settings.styleBackground, 'color') log.debug("Current window position: %r", self.window.get_position()) self.execute_hook('show')
python
def show(self): """Shows the main window and grabs the focus on it. """ self.hidden = False # setting window in all desktops window_rect = RectCalculator.set_final_window_rect(self.settings, self.window) self.window.stick() # add tab must be called before window.show to avoid a # blank screen before adding the tab. if not self.get_notebook().has_page(): self.add_tab() self.window.set_keep_below(False) self.window.show_all() # this is needed because self.window.show_all() results in showing every # thing which includes the scrollbar too self.settings.general.triggerOnChangedValue(self.settings.general, "use-scrollbar") # move the window even when in fullscreen-mode log.debug("Moving window to: %r", window_rect) self.window.move(window_rect.x, window_rect.y) # this works around an issue in fluxbox if not FullscreenManager(self.settings, self.window).is_fullscreen(): self.settings.general.triggerOnChangedValue(self.settings.general, 'window-height') time = get_server_time(self.window) # TODO PORT this # When minized, the window manager seems to refuse to resume # log.debug("self.window: %s. Dir=%s", type(self.window), dir(self.window)) # is_iconified = self.is_iconified() # if is_iconified: # log.debug("Is iconified. Ubuntu Trick => " # "removing skip_taskbar_hint and skip_pager_hint " # "so deiconify can work!") # self.get_widget('window-root').set_skip_taskbar_hint(False) # self.get_widget('window-root').set_skip_pager_hint(False) # self.get_widget('window-root').set_urgency_hint(False) # log.debug("get_skip_taskbar_hint: {}".format( # self.get_widget('window-root').get_skip_taskbar_hint())) # log.debug("get_skip_pager_hint: {}".format( # self.get_widget('window-root').get_skip_pager_hint())) # log.debug("get_urgency_hint: {}".format( # self.get_widget('window-root').get_urgency_hint())) # glib.timeout_add_seconds(1, lambda: self.timeout_restore(time)) # log.debug("order to present and deiconify") self.window.present() self.window.deiconify() self.window.show() self.window.get_window().focus(time) self.window.set_type_hint(Gdk.WindowTypeHint.DOCK) self.window.set_type_hint(Gdk.WindowTypeHint.NORMAL) # log.debug("Restoring skip_taskbar_hint and skip_pager_hint") # if is_iconified: # self.get_widget('window-root').set_skip_taskbar_hint(False) # self.get_widget('window-root').set_skip_pager_hint(False) # self.get_widget('window-root').set_urgency_hint(False) # This is here because vte color configuration works only after the # widget is shown. self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'color') self.settings.styleBackground.triggerOnChangedValue(self.settings.styleBackground, 'color') log.debug("Current window position: %r", self.window.get_position()) self.execute_hook('show')
[ "def", "show", "(", "self", ")", ":", "self", ".", "hidden", "=", "False", "# setting window in all desktops", "window_rect", "=", "RectCalculator", ".", "set_final_window_rect", "(", "self", ".", "settings", ",", "self", ".", "window", ")", "self", ".", "wind...
Shows the main window and grabs the focus on it.
[ "Shows", "the", "main", "window", "and", "grabs", "the", "focus", "on", "it", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L568-L641
train
217,762
Guake/guake
guake/guake_app.py
Guake.hide
def hide(self): """Hides the main window of the terminal and sets the visible flag to False. """ if not HidePrevention(self.window).may_hide(): return self.hidden = True self.get_widget('window-root').unstick() self.window.hide()
python
def hide(self): """Hides the main window of the terminal and sets the visible flag to False. """ if not HidePrevention(self.window).may_hide(): return self.hidden = True self.get_widget('window-root').unstick() self.window.hide()
[ "def", "hide", "(", "self", ")", ":", "if", "not", "HidePrevention", "(", "self", ".", "window", ")", ".", "may_hide", "(", ")", ":", "return", "self", ".", "hidden", "=", "True", "self", ".", "get_widget", "(", "'window-root'", ")", ".", "unstick", ...
Hides the main window of the terminal and sets the visible flag to False.
[ "Hides", "the", "main", "window", "of", "the", "terminal", "and", "sets", "the", "visible", "flag", "to", "False", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L660-L668
train
217,763
Guake/guake
guake/guake_app.py
Guake.load_config
def load_config(self): """"Just a proxy for all the configuration stuff. """ self.settings.general.triggerOnChangedValue(self.settings.general, 'use-trayicon') self.settings.general.triggerOnChangedValue(self.settings.general, 'prompt-on-quit') self.settings.general.triggerOnChangedValue(self.settings.general, 'prompt-on-close-tab') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-tabbar') self.settings.general.triggerOnChangedValue(self.settings.general, 'mouse-display') self.settings.general.triggerOnChangedValue(self.settings.general, 'display-n') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-ontop') if not FullscreenManager(self.settings, self.window).is_fullscreen(): self.settings.general.triggerOnChangedValue(self.settings.general, 'window-height') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-width') self.settings.general.triggerOnChangedValue(self.settings.general, 'use-scrollbar') self.settings.general.triggerOnChangedValue(self.settings.general, 'history-size') self.settings.general.triggerOnChangedValue(self.settings.general, 'infinite-history') self.settings.general.triggerOnChangedValue(self.settings.general, 'use-vte-titles') self.settings.general.triggerOnChangedValue(self.settings.general, 'set-window-title') self.settings.general.triggerOnChangedValue(self.settings.general, 'abbreviate-tab-names') self.settings.general.triggerOnChangedValue(self.settings.general, 'max-tab-name-length') self.settings.general.triggerOnChangedValue(self.settings.general, 'quick-open-enable') self.settings.general.triggerOnChangedValue( self.settings.general, 'quick-open-command-line' ) self.settings.style.triggerOnChangedValue(self.settings.style, 'cursor-shape') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'style') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette-name') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'allow-bold') self.settings.styleBackground.triggerOnChangedValue( self.settings.styleBackground, 'transparency' ) self.settings.general.triggerOnChangedValue(self.settings.general, 'use-default-font') self.settings.general.triggerOnChangedValue(self.settings.general, 'compat-backspace') self.settings.general.triggerOnChangedValue(self.settings.general, 'compat-delete')
python
def load_config(self): """"Just a proxy for all the configuration stuff. """ self.settings.general.triggerOnChangedValue(self.settings.general, 'use-trayicon') self.settings.general.triggerOnChangedValue(self.settings.general, 'prompt-on-quit') self.settings.general.triggerOnChangedValue(self.settings.general, 'prompt-on-close-tab') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-tabbar') self.settings.general.triggerOnChangedValue(self.settings.general, 'mouse-display') self.settings.general.triggerOnChangedValue(self.settings.general, 'display-n') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-ontop') if not FullscreenManager(self.settings, self.window).is_fullscreen(): self.settings.general.triggerOnChangedValue(self.settings.general, 'window-height') self.settings.general.triggerOnChangedValue(self.settings.general, 'window-width') self.settings.general.triggerOnChangedValue(self.settings.general, 'use-scrollbar') self.settings.general.triggerOnChangedValue(self.settings.general, 'history-size') self.settings.general.triggerOnChangedValue(self.settings.general, 'infinite-history') self.settings.general.triggerOnChangedValue(self.settings.general, 'use-vte-titles') self.settings.general.triggerOnChangedValue(self.settings.general, 'set-window-title') self.settings.general.triggerOnChangedValue(self.settings.general, 'abbreviate-tab-names') self.settings.general.triggerOnChangedValue(self.settings.general, 'max-tab-name-length') self.settings.general.triggerOnChangedValue(self.settings.general, 'quick-open-enable') self.settings.general.triggerOnChangedValue( self.settings.general, 'quick-open-command-line' ) self.settings.style.triggerOnChangedValue(self.settings.style, 'cursor-shape') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'style') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'palette-name') self.settings.styleFont.triggerOnChangedValue(self.settings.styleFont, 'allow-bold') self.settings.styleBackground.triggerOnChangedValue( self.settings.styleBackground, 'transparency' ) self.settings.general.triggerOnChangedValue(self.settings.general, 'use-default-font') self.settings.general.triggerOnChangedValue(self.settings.general, 'compat-backspace') self.settings.general.triggerOnChangedValue(self.settings.general, 'compat-delete')
[ "def", "load_config", "(", "self", ")", ":", "self", ".", "settings", ".", "general", ".", "triggerOnChangedValue", "(", "self", ".", "settings", ".", "general", ",", "'use-trayicon'", ")", "self", ".", "settings", ".", "general", ".", "triggerOnChangedValue",...
Just a proxy for all the configuration stuff.
[ "Just", "a", "proxy", "for", "all", "the", "configuration", "stuff", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L681-L716
train
217,764
Guake/guake
guake/guake_app.py
Guake.accel_quit
def accel_quit(self, *args): """Callback to prompt the user whether to quit Guake or not. """ procs = self.notebook_manager.get_running_fg_processes_count() tabs = self.notebook_manager.get_n_pages() notebooks = self.notebook_manager.get_n_notebooks() prompt_cfg = self.settings.general.get_boolean('prompt-on-quit') prompt_tab_cfg = self.settings.general.get_int('prompt-on-close-tab') # "Prompt on tab close" config overrides "prompt on quit" config if prompt_cfg or (prompt_tab_cfg == 1 and procs > 0) or (prompt_tab_cfg == 2): log.debug("Remaining procs=%r", procs) if PromptQuitDialog(self.window, procs, tabs, notebooks).quit(): log.info("Quitting Guake") Gtk.main_quit() else: log.info("Quitting Guake") Gtk.main_quit()
python
def accel_quit(self, *args): """Callback to prompt the user whether to quit Guake or not. """ procs = self.notebook_manager.get_running_fg_processes_count() tabs = self.notebook_manager.get_n_pages() notebooks = self.notebook_manager.get_n_notebooks() prompt_cfg = self.settings.general.get_boolean('prompt-on-quit') prompt_tab_cfg = self.settings.general.get_int('prompt-on-close-tab') # "Prompt on tab close" config overrides "prompt on quit" config if prompt_cfg or (prompt_tab_cfg == 1 and procs > 0) or (prompt_tab_cfg == 2): log.debug("Remaining procs=%r", procs) if PromptQuitDialog(self.window, procs, tabs, notebooks).quit(): log.info("Quitting Guake") Gtk.main_quit() else: log.info("Quitting Guake") Gtk.main_quit()
[ "def", "accel_quit", "(", "self", ",", "*", "args", ")", ":", "procs", "=", "self", ".", "notebook_manager", ".", "get_running_fg_processes_count", "(", ")", "tabs", "=", "self", ".", "notebook_manager", ".", "get_n_pages", "(", ")", "notebooks", "=", "self"...
Callback to prompt the user whether to quit Guake or not.
[ "Callback", "to", "prompt", "the", "user", "whether", "to", "quit", "Guake", "or", "not", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L739-L755
train
217,765
Guake/guake
guake/guake_app.py
Guake.accel_reset_terminal
def accel_reset_terminal(self, *args): # TODO KEYBINDINGS ONLY """Callback to reset and clean the terminal""" HidePrevention(self.window).prevent() current_term = self.get_notebook().get_current_terminal() current_term.reset(True, True) HidePrevention(self.window).allow() return True
python
def accel_reset_terminal(self, *args): # TODO KEYBINDINGS ONLY """Callback to reset and clean the terminal""" HidePrevention(self.window).prevent() current_term = self.get_notebook().get_current_terminal() current_term.reset(True, True) HidePrevention(self.window).allow() return True
[ "def", "accel_reset_terminal", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "HidePrevention", "(", "self", ".", "window", ")", ".", "prevent", "(", ")", "current_term", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_termin...
Callback to reset and clean the terminal
[ "Callback", "to", "reset", "and", "clean", "the", "terminal" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L757-L764
train
217,766
Guake/guake
guake/guake_app.py
Guake.accel_zoom_in
def accel_zoom_in(self, *args): """Callback to zoom in. """ for term in self.get_notebook().iter_terminals(): term.increase_font_size() return True
python
def accel_zoom_in(self, *args): """Callback to zoom in. """ for term in self.get_notebook().iter_terminals(): term.increase_font_size() return True
[ "def", "accel_zoom_in", "(", "self", ",", "*", "args", ")", ":", "for", "term", "in", "self", ".", "get_notebook", "(", ")", ".", "iter_terminals", "(", ")", ":", "term", ".", "increase_font_size", "(", ")", "return", "True" ]
Callback to zoom in.
[ "Callback", "to", "zoom", "in", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L766-L771
train
217,767
Guake/guake
guake/guake_app.py
Guake.accel_zoom_out
def accel_zoom_out(self, *args): """Callback to zoom out. """ for term in self.get_notebook().iter_terminals(): term.decrease_font_size() return True
python
def accel_zoom_out(self, *args): """Callback to zoom out. """ for term in self.get_notebook().iter_terminals(): term.decrease_font_size() return True
[ "def", "accel_zoom_out", "(", "self", ",", "*", "args", ")", ":", "for", "term", "in", "self", ".", "get_notebook", "(", ")", ".", "iter_terminals", "(", ")", ":", "term", ".", "decrease_font_size", "(", ")", "return", "True" ]
Callback to zoom out.
[ "Callback", "to", "zoom", "out", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L773-L778
train
217,768
Guake/guake
guake/guake_app.py
Guake.accel_increase_height
def accel_increase_height(self, *args): """Callback to increase height. """ height = self.settings.general.get_int('window-height') self.settings.general.set_int('window-height', min(height + 2, 100)) return True
python
def accel_increase_height(self, *args): """Callback to increase height. """ height = self.settings.general.get_int('window-height') self.settings.general.set_int('window-height', min(height + 2, 100)) return True
[ "def", "accel_increase_height", "(", "self", ",", "*", "args", ")", ":", "height", "=", "self", ".", "settings", ".", "general", ".", "get_int", "(", "'window-height'", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-height'", "...
Callback to increase height.
[ "Callback", "to", "increase", "height", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L780-L785
train
217,769
Guake/guake
guake/guake_app.py
Guake.accel_decrease_height
def accel_decrease_height(self, *args): """Callback to decrease height. """ height = self.settings.general.get_int('window-height') self.settings.general.set_int('window-height', max(height - 2, 0)) return True
python
def accel_decrease_height(self, *args): """Callback to decrease height. """ height = self.settings.general.get_int('window-height') self.settings.general.set_int('window-height', max(height - 2, 0)) return True
[ "def", "accel_decrease_height", "(", "self", ",", "*", "args", ")", ":", "height", "=", "self", ".", "settings", ".", "general", ".", "get_int", "(", "'window-height'", ")", "self", ".", "settings", ".", "general", ".", "set_int", "(", "'window-height'", "...
Callback to decrease height.
[ "Callback", "to", "decrease", "height", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L787-L792
train
217,770
Guake/guake
guake/guake_app.py
Guake.accel_increase_transparency
def accel_increase_transparency(self, *args): """Callback to increase transparency. """ transparency = self.settings.styleBackground.get_int('transparency') if int(transparency) - 2 > 0: self.settings.styleBackground.set_int('transparency', int(transparency) - 2) return True
python
def accel_increase_transparency(self, *args): """Callback to increase transparency. """ transparency = self.settings.styleBackground.get_int('transparency') if int(transparency) - 2 > 0: self.settings.styleBackground.set_int('transparency', int(transparency) - 2) return True
[ "def", "accel_increase_transparency", "(", "self", ",", "*", "args", ")", ":", "transparency", "=", "self", ".", "settings", ".", "styleBackground", ".", "get_int", "(", "'transparency'", ")", "if", "int", "(", "transparency", ")", "-", "2", ">", "0", ":",...
Callback to increase transparency.
[ "Callback", "to", "increase", "transparency", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L794-L800
train
217,771
Guake/guake
guake/guake_app.py
Guake.accel_decrease_transparency
def accel_decrease_transparency(self, *args): """Callback to decrease transparency. """ transparency = self.settings.styleBackground.get_int('transparency') if int(transparency) + 2 < MAX_TRANSPARENCY: self.settings.styleBackground.set_int('transparency', int(transparency) + 2) return True
python
def accel_decrease_transparency(self, *args): """Callback to decrease transparency. """ transparency = self.settings.styleBackground.get_int('transparency') if int(transparency) + 2 < MAX_TRANSPARENCY: self.settings.styleBackground.set_int('transparency', int(transparency) + 2) return True
[ "def", "accel_decrease_transparency", "(", "self", ",", "*", "args", ")", ":", "transparency", "=", "self", ".", "settings", ".", "styleBackground", ".", "get_int", "(", "'transparency'", ")", "if", "int", "(", "transparency", ")", "+", "2", "<", "MAX_TRANSP...
Callback to decrease transparency.
[ "Callback", "to", "decrease", "transparency", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L802-L808
train
217,772
Guake/guake
guake/guake_app.py
Guake.accel_toggle_transparency
def accel_toggle_transparency(self, *args): """Callback to toggle transparency. """ self.transparency_toggled = not self.transparency_toggled self.settings.styleBackground.triggerOnChangedValue( self.settings.styleBackground, 'transparency' ) return True
python
def accel_toggle_transparency(self, *args): """Callback to toggle transparency. """ self.transparency_toggled = not self.transparency_toggled self.settings.styleBackground.triggerOnChangedValue( self.settings.styleBackground, 'transparency' ) return True
[ "def", "accel_toggle_transparency", "(", "self", ",", "*", "args", ")", ":", "self", ".", "transparency_toggled", "=", "not", "self", ".", "transparency_toggled", "self", ".", "settings", ".", "styleBackground", ".", "triggerOnChangedValue", "(", "self", ".", "s...
Callback to toggle transparency.
[ "Callback", "to", "toggle", "transparency", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L810-L817
train
217,773
Guake/guake
guake/guake_app.py
Guake.accel_prev
def accel_prev(self, *args): """Callback to go to the previous tab. Called by the accel key. """ if self.get_notebook().get_current_page() == 0: self.get_notebook().set_current_page(self.get_notebook().get_n_pages() - 1) else: self.get_notebook().prev_page() return True
python
def accel_prev(self, *args): """Callback to go to the previous tab. Called by the accel key. """ if self.get_notebook().get_current_page() == 0: self.get_notebook().set_current_page(self.get_notebook().get_n_pages() - 1) else: self.get_notebook().prev_page() return True
[ "def", "accel_prev", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "==", "0", ":", "self", ".", "get_notebook", "(", ")", ".", "set_current_page", "(", "self", ".", "get_noteboo...
Callback to go to the previous tab. Called by the accel key.
[ "Callback", "to", "go", "to", "the", "previous", "tab", ".", "Called", "by", "the", "accel", "key", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L831-L838
train
217,774
Guake/guake
guake/guake_app.py
Guake.accel_next
def accel_next(self, *args): """Callback to go to the next tab. Called by the accel key. """ if self.get_notebook().get_current_page() + 1 == self.get_notebook().get_n_pages(): self.get_notebook().set_current_page(0) else: self.get_notebook().next_page() return True
python
def accel_next(self, *args): """Callback to go to the next tab. Called by the accel key. """ if self.get_notebook().get_current_page() + 1 == self.get_notebook().get_n_pages(): self.get_notebook().set_current_page(0) else: self.get_notebook().next_page() return True
[ "def", "accel_next", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "+", "1", "==", "self", ".", "get_notebook", "(", ")", ".", "get_n_pages", "(", ")", ":", "self", ".", "ge...
Callback to go to the next tab. Called by the accel key.
[ "Callback", "to", "go", "to", "the", "next", "tab", ".", "Called", "by", "the", "accel", "key", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L840-L847
train
217,775
Guake/guake
guake/guake_app.py
Guake.accel_move_tab_left
def accel_move_tab_left(self, *args): # TODO KEYBINDINGS ONLY """ Callback to move a tab to the left """ pos = self.get_notebook().get_current_page() if pos != 0: self.move_tab(pos, pos - 1) return True
python
def accel_move_tab_left(self, *args): # TODO KEYBINDINGS ONLY """ Callback to move a tab to the left """ pos = self.get_notebook().get_current_page() if pos != 0: self.move_tab(pos, pos - 1) return True
[ "def", "accel_move_tab_left", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "pos", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "if", "pos", "!=", "0", ":", "self", ".", "move_tab", "(", "pos", ",",...
Callback to move a tab to the left
[ "Callback", "to", "move", "a", "tab", "to", "the", "left" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L849-L855
train
217,776
Guake/guake
guake/guake_app.py
Guake.accel_move_tab_right
def accel_move_tab_right(self, *args): # TODO KEYBINDINGS ONLY """ Callback to move a tab to the right """ pos = self.get_notebook().get_current_page() if pos != self.get_notebook().get_n_pages() - 1: self.move_tab(pos, pos + 1) return True
python
def accel_move_tab_right(self, *args): # TODO KEYBINDINGS ONLY """ Callback to move a tab to the right """ pos = self.get_notebook().get_current_page() if pos != self.get_notebook().get_n_pages() - 1: self.move_tab(pos, pos + 1) return True
[ "def", "accel_move_tab_right", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "pos", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "if", "pos", "!=", "self", ".", "get_notebook", "(", ")", ".", "get_n_p...
Callback to move a tab to the right
[ "Callback", "to", "move", "a", "tab", "to", "the", "right" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L857-L863
train
217,777
Guake/guake
guake/guake_app.py
Guake.accel_rename_current_tab
def accel_rename_current_tab(self, *args): """Callback to show the rename tab dialog. Called by the accel key. """ page_num = self.get_notebook().get_current_page() page = self.get_notebook().get_nth_page(page_num) self.get_notebook().get_tab_label(page).on_rename(None) return True
python
def accel_rename_current_tab(self, *args): """Callback to show the rename tab dialog. Called by the accel key. """ page_num = self.get_notebook().get_current_page() page = self.get_notebook().get_nth_page(page_num) self.get_notebook().get_tab_label(page).on_rename(None) return True
[ "def", "accel_rename_current_tab", "(", "self", ",", "*", "args", ")", ":", "page_num", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "page", "=", "self", ".", "get_notebook", "(", ")", ".", "get_nth_page", "(", "page_num",...
Callback to show the rename tab dialog. Called by the accel key.
[ "Callback", "to", "show", "the", "rename", "tab", "dialog", ".", "Called", "by", "the", "accel", "key", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L886-L893
train
217,778
Guake/guake
guake/guake_app.py
Guake.accel_toggle_hide_on_lose_focus
def accel_toggle_hide_on_lose_focus(self, *args): """Callback toggle whether the window should hide when it loses focus. Called by the accel key. """ if self.settings.general.get_boolean('window-losefocus'): self.settings.general.set_boolean('window-losefocus', False) else: self.settings.general.set_boolean('window-losefocus', True) return True
python
def accel_toggle_hide_on_lose_focus(self, *args): """Callback toggle whether the window should hide when it loses focus. Called by the accel key. """ if self.settings.general.get_boolean('window-losefocus'): self.settings.general.set_boolean('window-losefocus', False) else: self.settings.general.set_boolean('window-losefocus', True) return True
[ "def", "accel_toggle_hide_on_lose_focus", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "settings", ".", "general", ".", "get_boolean", "(", "'window-losefocus'", ")", ":", "self", ".", "settings", ".", "general", ".", "set_boolean", "(", "'win...
Callback toggle whether the window should hide when it loses focus. Called by the accel key.
[ "Callback", "toggle", "whether", "the", "window", "should", "hide", "when", "it", "loses", "focus", ".", "Called", "by", "the", "accel", "key", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L911-L919
train
217,779
Guake/guake
guake/guake_app.py
Guake.recompute_tabs_titles
def recompute_tabs_titles(self): """Updates labels on all tabs. This is required when `self.abbreviate` changes """ use_vte_titles = self.settings.general.get_boolean("use-vte-titles") if not use_vte_titles: return # TODO NOTEBOOK this code only works if there is only one terminal in a # page, this need to be rewritten for terminal in self.get_notebook().iter_terminals(): page_num = self.get_notebook().page_num(terminal.get_parent()) self.get_notebook().rename_page(page_num, self.compute_tab_title(terminal), False)
python
def recompute_tabs_titles(self): """Updates labels on all tabs. This is required when `self.abbreviate` changes """ use_vte_titles = self.settings.general.get_boolean("use-vte-titles") if not use_vte_titles: return # TODO NOTEBOOK this code only works if there is only one terminal in a # page, this need to be rewritten for terminal in self.get_notebook().iter_terminals(): page_num = self.get_notebook().page_num(terminal.get_parent()) self.get_notebook().rename_page(page_num, self.compute_tab_title(terminal), False)
[ "def", "recompute_tabs_titles", "(", "self", ")", ":", "use_vte_titles", "=", "self", ".", "settings", ".", "general", ".", "get_boolean", "(", "\"use-vte-titles\"", ")", "if", "not", "use_vte_titles", ":", "return", "# TODO NOTEBOOK this code only works if there is onl...
Updates labels on all tabs. This is required when `self.abbreviate` changes
[ "Updates", "labels", "on", "all", "tabs", ".", "This", "is", "required", "when", "self", ".", "abbreviate", "changes" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L933-L945
train
217,780
Guake/guake
guake/guake_app.py
Guake.compute_tab_title
def compute_tab_title(self, vte): """Abbreviate and cut vte terminal title when necessary """ vte_title = vte.get_window_title() or _("Terminal") try: current_directory = vte.get_current_directory() if self.abbreviate and vte_title.endswith(current_directory): parts = current_directory.split('/') parts = [s[:1] for s in parts[:-1]] + [parts[-1]] vte_title = vte_title[:len(vte_title) - len(current_directory)] + '/'.join(parts) except OSError: pass return TabNameUtils.shorten(vte_title, self.settings)
python
def compute_tab_title(self, vte): """Abbreviate and cut vte terminal title when necessary """ vte_title = vte.get_window_title() or _("Terminal") try: current_directory = vte.get_current_directory() if self.abbreviate and vte_title.endswith(current_directory): parts = current_directory.split('/') parts = [s[:1] for s in parts[:-1]] + [parts[-1]] vte_title = vte_title[:len(vte_title) - len(current_directory)] + '/'.join(parts) except OSError: pass return TabNameUtils.shorten(vte_title, self.settings)
[ "def", "compute_tab_title", "(", "self", ",", "vte", ")", ":", "vte_title", "=", "vte", ".", "get_window_title", "(", ")", "or", "_", "(", "\"Terminal\"", ")", "try", ":", "current_directory", "=", "vte", ".", "get_current_directory", "(", ")", "if", "self...
Abbreviate and cut vte terminal title when necessary
[ "Abbreviate", "and", "cut", "vte", "terminal", "title", "when", "necessary" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L947-L959
train
217,781
Guake/guake
guake/guake_app.py
Guake.close_tab
def close_tab(self, *args): """Closes the current tab. """ prompt_cfg = self.settings.general.get_int('prompt-on-close-tab') self.get_notebook().delete_page_current(prompt=prompt_cfg)
python
def close_tab(self, *args): """Closes the current tab. """ prompt_cfg = self.settings.general.get_int('prompt-on-close-tab') self.get_notebook().delete_page_current(prompt=prompt_cfg)
[ "def", "close_tab", "(", "self", ",", "*", "args", ")", ":", "prompt_cfg", "=", "self", ".", "settings", ".", "general", ".", "get_int", "(", "'prompt-on-close-tab'", ")", "self", ".", "get_notebook", "(", ")", ".", "delete_page_current", "(", "prompt", "=...
Closes the current tab.
[ "Closes", "the", "current", "tab", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L997-L1001
train
217,782
Guake/guake
guake/guake_app.py
Guake.rename_tab_uuid
def rename_tab_uuid(self, term_uuid, new_text, user_set=True): """Rename an already added tab by its UUID """ term_uuid = uuid.UUID(term_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == term_uuid ) self.get_notebook().rename_page(page_index, new_text, user_set)
python
def rename_tab_uuid(self, term_uuid, new_text, user_set=True): """Rename an already added tab by its UUID """ term_uuid = uuid.UUID(term_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == term_uuid ) self.get_notebook().rename_page(page_index, new_text, user_set)
[ "def", "rename_tab_uuid", "(", "self", ",", "term_uuid", ",", "new_text", ",", "user_set", "=", "True", ")", ":", "term_uuid", "=", "uuid", ".", "UUID", "(", "term_uuid", ")", "page_index", ",", "=", "(", "index", "for", "index", ",", "t", "in", "enume...
Rename an already added tab by its UUID
[ "Rename", "an", "already", "added", "tab", "by", "its", "UUID" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L1003-L1011
train
217,783
Guake/guake
guake/guake_app.py
Guake.get_selected_uuidtab
def get_selected_uuidtab(self): # TODO DBUS ONLY """Returns the uuid of the current selected terminal """ page_num = self.get_notebook().get_current_page() terminals = self.get_notebook().get_terminals_for_page(page_num) return str(terminals[0].get_uuid())
python
def get_selected_uuidtab(self): # TODO DBUS ONLY """Returns the uuid of the current selected terminal """ page_num = self.get_notebook().get_current_page() terminals = self.get_notebook().get_terminals_for_page(page_num) return str(terminals[0].get_uuid())
[ "def", "get_selected_uuidtab", "(", "self", ")", ":", "# TODO DBUS ONLY", "page_num", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_page", "(", ")", "terminals", "=", "self", ".", "get_notebook", "(", ")", ".", "get_terminals_for_page", "(", "p...
Returns the uuid of the current selected terminal
[ "Returns", "the", "uuid", "of", "the", "current", "selected", "terminal" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L1093-L1099
train
217,784
Guake/guake
guake/guake_app.py
Guake.search_on_web
def search_on_web(self, *args): """Search for the selected text on the web """ # TODO KEYBINDINGS ONLY current_term = self.get_notebook().get_current_terminal() if current_term.get_has_selection(): current_term.copy_clipboard() guake_clipboard = Gtk.Clipboard.get_default(self.window.get_display()) search_query = guake_clipboard.wait_for_text() search_query = quote_plus(search_query) if search_query: # TODO search provider should be selectable (someone might # prefer bing.com, the internet is a strange place ¯\_(ツ)_/¯ ) search_url = "https://www.google.com/#q={!s}&safe=off".format(search_query, ) Gtk.show_uri(self.window.get_screen(), search_url, get_server_time(self.window)) return True
python
def search_on_web(self, *args): """Search for the selected text on the web """ # TODO KEYBINDINGS ONLY current_term = self.get_notebook().get_current_terminal() if current_term.get_has_selection(): current_term.copy_clipboard() guake_clipboard = Gtk.Clipboard.get_default(self.window.get_display()) search_query = guake_clipboard.wait_for_text() search_query = quote_plus(search_query) if search_query: # TODO search provider should be selectable (someone might # prefer bing.com, the internet is a strange place ¯\_(ツ)_/¯ ) search_url = "https://www.google.com/#q={!s}&safe=off".format(search_query, ) Gtk.show_uri(self.window.get_screen(), search_url, get_server_time(self.window)) return True
[ "def", "search_on_web", "(", "self", ",", "*", "args", ")", ":", "# TODO KEYBINDINGS ONLY", "current_term", "=", "self", ".", "get_notebook", "(", ")", ".", "get_current_terminal", "(", ")", "if", "current_term", ".", "get_has_selection", "(", ")", ":", "curre...
Search for the selected text on the web
[ "Search", "for", "the", "selected", "text", "on", "the", "web" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L1101-L1117
train
217,785
Guake/guake
guake/guake_app.py
Guake.execute_hook
def execute_hook(self, event_name): """Execute shell commands related to current event_name""" hook = self.settings.hooks.get_string('{!s}'.format(event_name)) if hook is not None and hook != "": hook = hook.split() try: subprocess.Popen(hook) except OSError as oserr: if oserr.errno == 8: log.error("Hook execution failed! Check shebang at first line of %s!", hook) log.debug(traceback.format_exc()) else: log.error(str(oserr)) except Exception as e: log.error("hook execution failed! %s", e) log.debug(traceback.format_exc()) else: log.debug("hook on event %s has been executed", event_name)
python
def execute_hook(self, event_name): """Execute shell commands related to current event_name""" hook = self.settings.hooks.get_string('{!s}'.format(event_name)) if hook is not None and hook != "": hook = hook.split() try: subprocess.Popen(hook) except OSError as oserr: if oserr.errno == 8: log.error("Hook execution failed! Check shebang at first line of %s!", hook) log.debug(traceback.format_exc()) else: log.error(str(oserr)) except Exception as e: log.error("hook execution failed! %s", e) log.debug(traceback.format_exc()) else: log.debug("hook on event %s has been executed", event_name)
[ "def", "execute_hook", "(", "self", ",", "event_name", ")", ":", "hook", "=", "self", ".", "settings", ".", "hooks", ".", "get_string", "(", "'{!s}'", ".", "format", "(", "event_name", ")", ")", "if", "hook", "is", "not", "None", "and", "hook", "!=", ...
Execute shell commands related to current event_name
[ "Execute", "shell", "commands", "related", "to", "current", "event_name" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L1125-L1142
train
217,786
Guake/guake
guake/theme.py
get_resource_dirs
def get_resource_dirs(resource): """Returns a list of all known resource dirs for a given resource. :param str resource: Name of the resource (e.g. "themes") :return: A list of resource dirs """ dirs = [ os.path.join(dir, resource) for dir in itertools.chain(GLib.get_system_data_dirs(), GUAKE_THEME_DIR, GLib.get_user_data_dir()) ] dirs += [os.path.join(os.path.expanduser("~"), ".{}".format(resource))] return [Path(dir) for dir in dirs if os.path.isdir(dir)]
python
def get_resource_dirs(resource): """Returns a list of all known resource dirs for a given resource. :param str resource: Name of the resource (e.g. "themes") :return: A list of resource dirs """ dirs = [ os.path.join(dir, resource) for dir in itertools.chain(GLib.get_system_data_dirs(), GUAKE_THEME_DIR, GLib.get_user_data_dir()) ] dirs += [os.path.join(os.path.expanduser("~"), ".{}".format(resource))] return [Path(dir) for dir in dirs if os.path.isdir(dir)]
[ "def", "get_resource_dirs", "(", "resource", ")", ":", "dirs", "=", "[", "os", ".", "path", ".", "join", "(", "dir", ",", "resource", ")", "for", "dir", "in", "itertools", ".", "chain", "(", "GLib", ".", "get_system_data_dirs", "(", ")", ",", "GUAKE_TH...
Returns a list of all known resource dirs for a given resource. :param str resource: Name of the resource (e.g. "themes") :return: A list of resource dirs
[ "Returns", "a", "list", "of", "all", "known", "resource", "dirs", "for", "a", "given", "resource", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/theme.py#L22-L36
train
217,787
Guake/guake
guake/terminal.py
GuakeTerminal.configure_terminal
def configure_terminal(self): """Sets all customized properties on the terminal """ client = self.guake.settings.general word_chars = client.get_string('word-chars') if word_chars: self.set_word_char_exceptions(word_chars) self.set_audible_bell(client.get_boolean('use-audible-bell')) self.set_sensitive(True) cursor_blink_mode = self.guake.settings.style.get_int('cursor-blink-mode') self.set_property('cursor-blink-mode', cursor_blink_mode) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 50): self.set_allow_hyperlink(True) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 56): try: self.set_bold_is_bright(self.guake.settings.styleFont.get_boolean('bold-is-bright')) except: # pylint: disable=bare-except log.error("set_bold_is_bright not supported by your version of VTE") # TODO PORT is this still the case with the newer vte version? # -- Ubuntu has a patch to libvte which disables mouse scrolling in apps # -- like vim and less by default. If this is the case, enable it back. if hasattr(self, "set_alternate_screen_scroll"): self.set_alternate_screen_scroll(True) self.set_can_default(True) self.set_can_focus(True)
python
def configure_terminal(self): """Sets all customized properties on the terminal """ client = self.guake.settings.general word_chars = client.get_string('word-chars') if word_chars: self.set_word_char_exceptions(word_chars) self.set_audible_bell(client.get_boolean('use-audible-bell')) self.set_sensitive(True) cursor_blink_mode = self.guake.settings.style.get_int('cursor-blink-mode') self.set_property('cursor-blink-mode', cursor_blink_mode) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 50): self.set_allow_hyperlink(True) if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 56): try: self.set_bold_is_bright(self.guake.settings.styleFont.get_boolean('bold-is-bright')) except: # pylint: disable=bare-except log.error("set_bold_is_bright not supported by your version of VTE") # TODO PORT is this still the case with the newer vte version? # -- Ubuntu has a patch to libvte which disables mouse scrolling in apps # -- like vim and less by default. If this is the case, enable it back. if hasattr(self, "set_alternate_screen_scroll"): self.set_alternate_screen_scroll(True) self.set_can_default(True) self.set_can_focus(True)
[ "def", "configure_terminal", "(", "self", ")", ":", "client", "=", "self", ".", "guake", ".", "settings", ".", "general", "word_chars", "=", "client", ".", "get_string", "(", "'word-chars'", ")", "if", "word_chars", ":", "self", ".", "set_word_char_exceptions"...
Sets all customized properties on the terminal
[ "Sets", "all", "customized", "properties", "on", "the", "terminal" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/terminal.py#L143-L172
train
217,788
Guake/guake
guake/terminal.py
GuakeTerminal.is_file_on_local_server
def is_file_on_local_server(self, text) -> Tuple[Optional[Path], Optional[int], Optional[int]]: """Test if the provided text matches a file on local server Supports: - absolute path - relative path (using current working directory) - file:line syntax - file:line:colum syntax Args: text (str): candidate for file search Returns - Tuple(None, None, None) if the provided text does not match anything - Tuple(file path, None, None) if only a file path is found - Tuple(file path, linenumber, None) if line number is found - Tuple(file path, linenumber, columnnumber) if line and column numbers are found """ lineno = None colno = None py_func = None # "<File>:<line>:<col>" m = re.compile(r"(.*)\:(\d+)\:(\d+)$").match(text) if m: text = m.group(1) lineno = m.group(2) colno = m.group(3) else: # "<File>:<line>" m = re.compile(r"(.*)\:(\d+)$").match(text) if m: text = m.group(1) lineno = m.group(2) else: # "<File>::<python_function>" m = re.compile(r"^(.*)\:\:([a-zA-Z0-9\_]+)$").match(text) if m: text = m.group(1) py_func = m.group(2).strip() def find_lineno(text, pt, lineno, py_func): # print("text={!r}, pt={!r}, lineno={!r}, py_func={!r}".format(text, # pt, lineno, py_func)) if lineno: return lineno if not py_func: return with pt.open() as f: for i, line in enumerate(f.readlines()): if line.startswith("def {}".format(py_func)): return i + 1 break pt = Path(text) log.debug("checking file existance: %r", pt) try: if pt.exists(): lineno = find_lineno(text, pt, lineno, py_func) log.info("File exists: %r, line=%r", pt.absolute().as_posix(), lineno) return (pt, lineno, colno) log.debug("No file found matching: %r", text) cwd = self.get_current_directory() pt = Path(cwd) / pt log.debug("checking file existance: %r", pt) if pt.exists(): lineno = find_lineno(text, pt, lineno, py_func) log.info("File exists: %r, line=%r", pt.absolute().as_posix(), lineno) return (pt, lineno, colno) log.debug("file does not exist: %s", str(pt)) except OSError: log.debug("not a file name: %r", text) return (None, None, None)
python
def is_file_on_local_server(self, text) -> Tuple[Optional[Path], Optional[int], Optional[int]]: """Test if the provided text matches a file on local server Supports: - absolute path - relative path (using current working directory) - file:line syntax - file:line:colum syntax Args: text (str): candidate for file search Returns - Tuple(None, None, None) if the provided text does not match anything - Tuple(file path, None, None) if only a file path is found - Tuple(file path, linenumber, None) if line number is found - Tuple(file path, linenumber, columnnumber) if line and column numbers are found """ lineno = None colno = None py_func = None # "<File>:<line>:<col>" m = re.compile(r"(.*)\:(\d+)\:(\d+)$").match(text) if m: text = m.group(1) lineno = m.group(2) colno = m.group(3) else: # "<File>:<line>" m = re.compile(r"(.*)\:(\d+)$").match(text) if m: text = m.group(1) lineno = m.group(2) else: # "<File>::<python_function>" m = re.compile(r"^(.*)\:\:([a-zA-Z0-9\_]+)$").match(text) if m: text = m.group(1) py_func = m.group(2).strip() def find_lineno(text, pt, lineno, py_func): # print("text={!r}, pt={!r}, lineno={!r}, py_func={!r}".format(text, # pt, lineno, py_func)) if lineno: return lineno if not py_func: return with pt.open() as f: for i, line in enumerate(f.readlines()): if line.startswith("def {}".format(py_func)): return i + 1 break pt = Path(text) log.debug("checking file existance: %r", pt) try: if pt.exists(): lineno = find_lineno(text, pt, lineno, py_func) log.info("File exists: %r, line=%r", pt.absolute().as_posix(), lineno) return (pt, lineno, colno) log.debug("No file found matching: %r", text) cwd = self.get_current_directory() pt = Path(cwd) / pt log.debug("checking file existance: %r", pt) if pt.exists(): lineno = find_lineno(text, pt, lineno, py_func) log.info("File exists: %r, line=%r", pt.absolute().as_posix(), lineno) return (pt, lineno, colno) log.debug("file does not exist: %s", str(pt)) except OSError: log.debug("not a file name: %r", text) return (None, None, None)
[ "def", "is_file_on_local_server", "(", "self", ",", "text", ")", "->", "Tuple", "[", "Optional", "[", "Path", "]", ",", "Optional", "[", "int", "]", ",", "Optional", "[", "int", "]", "]", ":", "lineno", "=", "None", "colno", "=", "None", "py_func", "...
Test if the provided text matches a file on local server Supports: - absolute path - relative path (using current working directory) - file:line syntax - file:line:colum syntax Args: text (str): candidate for file search Returns - Tuple(None, None, None) if the provided text does not match anything - Tuple(file path, None, None) if only a file path is found - Tuple(file path, linenumber, None) if line number is found - Tuple(file path, linenumber, columnnumber) if line and column numbers are found
[ "Test", "if", "the", "provided", "text", "matches", "a", "file", "on", "local", "server" ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/terminal.py#L226-L297
train
217,789
Guake/guake
guake/terminal.py
GuakeTerminal.button_press
def button_press(self, terminal, event): """Handles the button press event in the terminal widget. If any match string is caught, another application is open to handle the matched resource uri. """ self.matched_value = '' if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 46): matched_string = self.match_check_event(event) else: matched_string = self.match_check( int(event.x / self.get_char_width()), int(event.y / self.get_char_height()) ) self.found_link = None if event.button == 1 and (event.get_state() & Gdk.ModifierType.CONTROL_MASK): if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) > (0, 50): s = self.hyperlink_check_event(event) else: s = None if s is not None: self._on_ctrl_click_matcher((s, None)) elif self.get_has_selection(): self.quick_open() elif matched_string and matched_string[0]: self._on_ctrl_click_matcher(matched_string) elif event.button == 3 and matched_string: self.found_link = self.handleTerminalMatch(matched_string) self.matched_value = matched_string[0]
python
def button_press(self, terminal, event): """Handles the button press event in the terminal widget. If any match string is caught, another application is open to handle the matched resource uri. """ self.matched_value = '' if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 46): matched_string = self.match_check_event(event) else: matched_string = self.match_check( int(event.x / self.get_char_width()), int(event.y / self.get_char_height()) ) self.found_link = None if event.button == 1 and (event.get_state() & Gdk.ModifierType.CONTROL_MASK): if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) > (0, 50): s = self.hyperlink_check_event(event) else: s = None if s is not None: self._on_ctrl_click_matcher((s, None)) elif self.get_has_selection(): self.quick_open() elif matched_string and matched_string[0]: self._on_ctrl_click_matcher(matched_string) elif event.button == 3 and matched_string: self.found_link = self.handleTerminalMatch(matched_string) self.matched_value = matched_string[0]
[ "def", "button_press", "(", "self", ",", "terminal", ",", "event", ")", ":", "self", ".", "matched_value", "=", "''", "if", "(", "Vte", ".", "MAJOR_VERSION", ",", "Vte", ".", "MINOR_VERSION", ")", ">=", "(", "0", ",", "46", ")", ":", "matched_string", ...
Handles the button press event in the terminal widget. If any match string is caught, another application is open to handle the matched resource uri.
[ "Handles", "the", "button", "press", "event", "in", "the", "terminal", "widget", ".", "If", "any", "match", "string", "is", "caught", "another", "application", "is", "open", "to", "handle", "the", "matched", "resource", "uri", "." ]
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/terminal.py#L299-L327
train
217,790
Guake/guake
guake/terminal.py
GuakeTerminal.delete_shell
def delete_shell(self, pid): """This function will kill the shell on a tab, trying to send a sigterm and if it doesn't work, a sigkill. Between these two signals, we have a timeout of 3 seconds, so is recommended to call this in another thread. This doesn't change any thing in UI, so you can use python's start_new_thread. """ try: os.kill(pid, signal.SIGHUP) except OSError: pass num_tries = 30 while num_tries > 0: try: # Try to wait for the pid to be closed. If it does not # exist anymore, an OSError is raised and we can # safely ignore it. if os.waitpid(pid, os.WNOHANG)[0] != 0: break except OSError: break sleep(0.1) num_tries -= 1 if num_tries == 0: try: os.kill(pid, signal.SIGKILL) os.waitpid(pid, 0) except OSError: # if this part of code was reached, means that SIGTERM # did the work and SIGKILL wasnt needed. pass
python
def delete_shell(self, pid): """This function will kill the shell on a tab, trying to send a sigterm and if it doesn't work, a sigkill. Between these two signals, we have a timeout of 3 seconds, so is recommended to call this in another thread. This doesn't change any thing in UI, so you can use python's start_new_thread. """ try: os.kill(pid, signal.SIGHUP) except OSError: pass num_tries = 30 while num_tries > 0: try: # Try to wait for the pid to be closed. If it does not # exist anymore, an OSError is raised and we can # safely ignore it. if os.waitpid(pid, os.WNOHANG)[0] != 0: break except OSError: break sleep(0.1) num_tries -= 1 if num_tries == 0: try: os.kill(pid, signal.SIGKILL) os.waitpid(pid, 0) except OSError: # if this part of code was reached, means that SIGTERM # did the work and SIGKILL wasnt needed. pass
[ "def", "delete_shell", "(", "self", ",", "pid", ")", ":", "try", ":", "os", ".", "kill", "(", "pid", ",", "signal", ".", "SIGHUP", ")", "except", "OSError", ":", "pass", "num_tries", "=", "30", "while", "num_tries", ">", "0", ":", "try", ":", "# Tr...
This function will kill the shell on a tab, trying to send a sigterm and if it doesn't work, a sigkill. Between these two signals, we have a timeout of 3 seconds, so is recommended to call this in another thread. This doesn't change any thing in UI, so you can use python's start_new_thread.
[ "This", "function", "will", "kill", "the", "shell", "on", "a", "tab", "trying", "to", "send", "a", "sigterm", "and", "if", "it", "doesn", "t", "work", "a", "sigkill", ".", "Between", "these", "two", "signals", "we", "have", "a", "timeout", "of", "3", ...
4153ef38f9044cbed6494075fce80acd5809df2b
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/terminal.py#L463-L495
train
217,791
graphql-python/graphql-core
graphql/utils/is_valid_value.py
is_valid_value
def is_valid_value(value, type): # type: (Any, Any) -> List """Given a type and any value, return True if that value is valid.""" if isinstance(type, GraphQLNonNull): of_type = type.of_type if value is None: return [u'Expected "{}", found null.'.format(type)] return is_valid_value(value, of_type) if value is None: return _empty_list if isinstance(type, GraphQLList): item_type = type.of_type if not isinstance(value, string_types) and isinstance(value, Iterable): errors = [] for i, item in enumerate(value): item_errors = is_valid_value(item, item_type) for error in item_errors: errors.append(u"In element #{}: {}".format(i, error)) return errors else: return is_valid_value(value, item_type) if isinstance(type, GraphQLInputObjectType): if not isinstance(value, Mapping): return [u'Expected "{}", found not an object.'.format(type)] fields = type.fields errors = [] for provided_field in sorted(value.keys()): if provided_field not in fields: errors.append(u'In field "{}": Unknown field.'.format(provided_field)) for field_name, field in fields.items(): subfield_errors = is_valid_value(value.get(field_name), field.type) errors.extend( u'In field "{}": {}'.format(field_name, e) for e in subfield_errors ) return errors assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), "Must be input type" # Scalar/Enum input checks to ensure the type can parse the value to # a non-null value. parse_result = type.parse_value(value) if parse_result is None: return [u'Expected type "{}", found {}.'.format(type, json.dumps(value))] return _empty_list
python
def is_valid_value(value, type): # type: (Any, Any) -> List """Given a type and any value, return True if that value is valid.""" if isinstance(type, GraphQLNonNull): of_type = type.of_type if value is None: return [u'Expected "{}", found null.'.format(type)] return is_valid_value(value, of_type) if value is None: return _empty_list if isinstance(type, GraphQLList): item_type = type.of_type if not isinstance(value, string_types) and isinstance(value, Iterable): errors = [] for i, item in enumerate(value): item_errors = is_valid_value(item, item_type) for error in item_errors: errors.append(u"In element #{}: {}".format(i, error)) return errors else: return is_valid_value(value, item_type) if isinstance(type, GraphQLInputObjectType): if not isinstance(value, Mapping): return [u'Expected "{}", found not an object.'.format(type)] fields = type.fields errors = [] for provided_field in sorted(value.keys()): if provided_field not in fields: errors.append(u'In field "{}": Unknown field.'.format(provided_field)) for field_name, field in fields.items(): subfield_errors = is_valid_value(value.get(field_name), field.type) errors.extend( u'In field "{}": {}'.format(field_name, e) for e in subfield_errors ) return errors assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), "Must be input type" # Scalar/Enum input checks to ensure the type can parse the value to # a non-null value. parse_result = type.parse_value(value) if parse_result is None: return [u'Expected type "{}", found {}.'.format(type, json.dumps(value))] return _empty_list
[ "def", "is_valid_value", "(", "value", ",", "type", ")", ":", "# type: (Any, Any) -> List", "if", "isinstance", "(", "type", ",", "GraphQLNonNull", ")", ":", "of_type", "=", "type", ".", "of_type", "if", "value", "is", "None", ":", "return", "[", "u'Expected...
Given a type and any value, return True if that value is valid.
[ "Given", "a", "type", "and", "any", "value", "return", "True", "if", "that", "value", "is", "valid", "." ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/utils/is_valid_value.py#L28-L82
train
217,792
graphql-python/graphql-core
graphql/backend/cache.py
get_unique_schema_id
def get_unique_schema_id(schema): # type: (GraphQLSchema) -> str """Get a unique id given a GraphQLSchema""" assert isinstance(schema, GraphQLSchema), ( "Must receive a GraphQLSchema as schema. Received {}" ).format(repr(schema)) if schema not in _cached_schemas: _cached_schemas[schema] = sha1(str(schema).encode("utf-8")).hexdigest() return _cached_schemas[schema]
python
def get_unique_schema_id(schema): # type: (GraphQLSchema) -> str """Get a unique id given a GraphQLSchema""" assert isinstance(schema, GraphQLSchema), ( "Must receive a GraphQLSchema as schema. Received {}" ).format(repr(schema)) if schema not in _cached_schemas: _cached_schemas[schema] = sha1(str(schema).encode("utf-8")).hexdigest() return _cached_schemas[schema]
[ "def", "get_unique_schema_id", "(", "schema", ")", ":", "# type: (GraphQLSchema) -> str", "assert", "isinstance", "(", "schema", ",", "GraphQLSchema", ")", ",", "(", "\"Must receive a GraphQLSchema as schema. Received {}\"", ")", ".", "format", "(", "repr", "(", "schema...
Get a unique id given a GraphQLSchema
[ "Get", "a", "unique", "id", "given", "a", "GraphQLSchema" ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/backend/cache.py#L18-L27
train
217,793
graphql-python/graphql-core
graphql/backend/cache.py
get_unique_document_id
def get_unique_document_id(query_str): # type: (str) -> str """Get a unique id given a query_string""" assert isinstance(query_str, string_types), ( "Must receive a string as query_str. Received {}" ).format(repr(query_str)) if query_str not in _cached_queries: _cached_queries[query_str] = sha1(str(query_str).encode("utf-8")).hexdigest() return _cached_queries[query_str]
python
def get_unique_document_id(query_str): # type: (str) -> str """Get a unique id given a query_string""" assert isinstance(query_str, string_types), ( "Must receive a string as query_str. Received {}" ).format(repr(query_str)) if query_str not in _cached_queries: _cached_queries[query_str] = sha1(str(query_str).encode("utf-8")).hexdigest() return _cached_queries[query_str]
[ "def", "get_unique_document_id", "(", "query_str", ")", ":", "# type: (str) -> str", "assert", "isinstance", "(", "query_str", ",", "string_types", ")", ",", "(", "\"Must receive a string as query_str. Received {}\"", ")", ".", "format", "(", "repr", "(", "query_str", ...
Get a unique id given a query_string
[ "Get", "a", "unique", "id", "given", "a", "query_string" ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/backend/cache.py#L30-L39
train
217,794
graphql-python/graphql-core
graphql/backend/cache.py
GraphQLCachedBackend.get_key_for_schema_and_document_string
def get_key_for_schema_and_document_string(self, schema, request_string): # type: (GraphQLSchema, str) -> int """This method returns a unique key given a schema and a request_string""" if self.use_consistent_hash: schema_id = get_unique_schema_id(schema) document_id = get_unique_document_id(request_string) return hash((schema_id, document_id)) return hash((schema, request_string))
python
def get_key_for_schema_and_document_string(self, schema, request_string): # type: (GraphQLSchema, str) -> int """This method returns a unique key given a schema and a request_string""" if self.use_consistent_hash: schema_id = get_unique_schema_id(schema) document_id = get_unique_document_id(request_string) return hash((schema_id, document_id)) return hash((schema, request_string))
[ "def", "get_key_for_schema_and_document_string", "(", "self", ",", "schema", ",", "request_string", ")", ":", "# type: (GraphQLSchema, str) -> int", "if", "self", ".", "use_consistent_hash", ":", "schema_id", "=", "get_unique_schema_id", "(", "schema", ")", "document_id",...
This method returns a unique key given a schema and a request_string
[ "This", "method", "returns", "a", "unique", "key", "given", "a", "schema", "and", "a", "request_string" ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/backend/cache.py#L62-L69
train
217,795
graphql-python/graphql-core
graphql/validation/rules/fields_on_correct_type.py
get_suggested_type_names
def get_suggested_type_names(schema, output_type, field_name): """Go through all of the implementations of type, as well as the interfaces that they implement. If any of those types include the provided field, suggest them, sorted by how often the type is referenced, starting with Interfaces.""" if isinstance(output_type, (GraphQLInterfaceType, GraphQLUnionType)): suggested_object_types = [] interface_usage_count = OrderedDict() for possible_type in schema.get_possible_types(output_type): if not possible_type.fields.get(field_name): return # This object type defines this field. suggested_object_types.append(possible_type.name) for possible_interface in possible_type.interfaces: if not possible_interface.fields.get(field_name): continue # This interface type defines this field. interface_usage_count[possible_interface.name] = ( interface_usage_count.get(possible_interface.name, 0) + 1 ) # Suggest interface types based on how common they are. suggested_interface_types = sorted( list(interface_usage_count.keys()), key=lambda k: interface_usage_count[k], reverse=True, ) # Suggest both interface and object types. suggested_interface_types.extend(suggested_object_types) return suggested_interface_types # Otherwise, must be an Object type, which does not have possible fields. return []
python
def get_suggested_type_names(schema, output_type, field_name): """Go through all of the implementations of type, as well as the interfaces that they implement. If any of those types include the provided field, suggest them, sorted by how often the type is referenced, starting with Interfaces.""" if isinstance(output_type, (GraphQLInterfaceType, GraphQLUnionType)): suggested_object_types = [] interface_usage_count = OrderedDict() for possible_type in schema.get_possible_types(output_type): if not possible_type.fields.get(field_name): return # This object type defines this field. suggested_object_types.append(possible_type.name) for possible_interface in possible_type.interfaces: if not possible_interface.fields.get(field_name): continue # This interface type defines this field. interface_usage_count[possible_interface.name] = ( interface_usage_count.get(possible_interface.name, 0) + 1 ) # Suggest interface types based on how common they are. suggested_interface_types = sorted( list(interface_usage_count.keys()), key=lambda k: interface_usage_count[k], reverse=True, ) # Suggest both interface and object types. suggested_interface_types.extend(suggested_object_types) return suggested_interface_types # Otherwise, must be an Object type, which does not have possible fields. return []
[ "def", "get_suggested_type_names", "(", "schema", ",", "output_type", ",", "field_name", ")", ":", "if", "isinstance", "(", "output_type", ",", "(", "GraphQLInterfaceType", ",", "GraphQLUnionType", ")", ")", ":", "suggested_object_types", "=", "[", "]", "interface...
Go through all of the implementations of type, as well as the interfaces that they implement. If any of those types include the provided field, suggest them, sorted by how often the type is referenced, starting with Interfaces.
[ "Go", "through", "all", "of", "the", "implementations", "of", "type", "as", "well", "as", "the", "interfaces", "that", "they", "implement", ".", "If", "any", "of", "those", "types", "include", "the", "provided", "field", "suggest", "them", "sorted", "by", ...
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/validation/rules/fields_on_correct_type.py#L91-L128
train
217,796
graphql-python/graphql-core
graphql/validation/rules/fields_on_correct_type.py
get_suggested_field_names
def get_suggested_field_names(schema, graphql_type, field_name): """For the field name provided, determine if there are any similar field names that may be the result of a typo.""" if isinstance(graphql_type, (GraphQLInterfaceType, GraphQLObjectType)): possible_field_names = list(graphql_type.fields.keys()) return suggestion_list(field_name, possible_field_names) # Otherwise, must be a Union type, which does not define fields. return []
python
def get_suggested_field_names(schema, graphql_type, field_name): """For the field name provided, determine if there are any similar field names that may be the result of a typo.""" if isinstance(graphql_type, (GraphQLInterfaceType, GraphQLObjectType)): possible_field_names = list(graphql_type.fields.keys()) return suggestion_list(field_name, possible_field_names) # Otherwise, must be a Union type, which does not define fields. return []
[ "def", "get_suggested_field_names", "(", "schema", ",", "graphql_type", ",", "field_name", ")", ":", "if", "isinstance", "(", "graphql_type", ",", "(", "GraphQLInterfaceType", ",", "GraphQLObjectType", ")", ")", ":", "possible_field_names", "=", "list", "(", "grap...
For the field name provided, determine if there are any similar field names that may be the result of a typo.
[ "For", "the", "field", "name", "provided", "determine", "if", "there", "are", "any", "similar", "field", "names", "that", "may", "be", "the", "result", "of", "a", "typo", "." ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/validation/rules/fields_on_correct_type.py#L131-L141
train
217,797
graphql-python/graphql-core
graphql/backend/compiled.py
GraphQLCompiledDocument.from_code
def from_code( cls, schema, # type: GraphQLSchema code, # type: Union[str, Any] uptodate=None, # type: Optional[bool] extra_namespace=None, # type: Optional[Dict[str, Any]] ): # type: (...) -> GraphQLCompiledDocument """Creates a GraphQLDocument object from compiled code and the globals. This is used by the loaders and schema to create a document object. """ if isinstance(code, string_types): filename = "<document>" code = compile(code, filename, "exec") namespace = {"__file__": code.co_filename} exec(code, namespace) if extra_namespace: namespace.update(extra_namespace) rv = cls._from_namespace(schema, namespace) # rv._uptodate = uptodate return rv
python
def from_code( cls, schema, # type: GraphQLSchema code, # type: Union[str, Any] uptodate=None, # type: Optional[bool] extra_namespace=None, # type: Optional[Dict[str, Any]] ): # type: (...) -> GraphQLCompiledDocument """Creates a GraphQLDocument object from compiled code and the globals. This is used by the loaders and schema to create a document object. """ if isinstance(code, string_types): filename = "<document>" code = compile(code, filename, "exec") namespace = {"__file__": code.co_filename} exec(code, namespace) if extra_namespace: namespace.update(extra_namespace) rv = cls._from_namespace(schema, namespace) # rv._uptodate = uptodate return rv
[ "def", "from_code", "(", "cls", ",", "schema", ",", "# type: GraphQLSchema", "code", ",", "# type: Union[str, Any]", "uptodate", "=", "None", ",", "# type: Optional[bool]", "extra_namespace", "=", "None", ",", "# type: Optional[Dict[str, Any]]", ")", ":", "# type: (...)...
Creates a GraphQLDocument object from compiled code and the globals. This is used by the loaders and schema to create a document object.
[ "Creates", "a", "GraphQLDocument", "object", "from", "compiled", "code", "and", "the", "globals", ".", "This", "is", "used", "by", "the", "loaders", "and", "schema", "to", "create", "a", "document", "object", "." ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/backend/compiled.py#L12-L32
train
217,798
graphql-python/graphql-core
graphql/utils/suggestion_list.py
suggestion_list
def suggestion_list(inp, options): """ Given an invalid input string and a list of valid options, returns a filtered list of valid options sorted based on their similarity with the input. """ options_by_distance = OrderedDict() input_threshold = len(inp) / 2 for option in options: distance = lexical_distance(inp, option) threshold = max(input_threshold, len(option) / 2, 1) if distance <= threshold: options_by_distance[option] = distance return sorted( list(options_by_distance.keys()), key=lambda k: options_by_distance[k] )
python
def suggestion_list(inp, options): """ Given an invalid input string and a list of valid options, returns a filtered list of valid options sorted based on their similarity with the input. """ options_by_distance = OrderedDict() input_threshold = len(inp) / 2 for option in options: distance = lexical_distance(inp, option) threshold = max(input_threshold, len(option) / 2, 1) if distance <= threshold: options_by_distance[option] = distance return sorted( list(options_by_distance.keys()), key=lambda k: options_by_distance[k] )
[ "def", "suggestion_list", "(", "inp", ",", "options", ")", ":", "options_by_distance", "=", "OrderedDict", "(", ")", "input_threshold", "=", "len", "(", "inp", ")", "/", "2", "for", "option", "in", "options", ":", "distance", "=", "lexical_distance", "(", ...
Given an invalid input string and a list of valid options, returns a filtered list of valid options sorted based on their similarity with the input.
[ "Given", "an", "invalid", "input", "string", "and", "a", "list", "of", "valid", "options", "returns", "a", "filtered", "list", "of", "valid", "options", "sorted", "based", "on", "their", "similarity", "with", "the", "input", "." ]
d8e9d3abe7c209eb2f51cf001402783bfd480596
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/utils/suggestion_list.py#L4-L20
train
217,799