Skip to content

Commit

Permalink
Merge branch 'gedit-47'
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferyto committed Jun 7, 2024
2 parents 401e055 + c1bfc24 commit 054a1e2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [v0.4.1-dev][Unreleased] - Unreleased
* Fixed error when loaded in gedit 47

## [v0.4.0] - 2023-11-02
* Changed minimum gedit version required to 3.12
Expand Down
10 changes: 8 additions & 2 deletions controlyourtabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,17 @@ def on_multi_notebook_tab_removed(self, multi, notebook, tab, tab_models):

self.untrack_tab(tab, tab_models[notebook])

def on_window_active_tab_changed(self, window, tab, tab_models):
def on_window_active_tab_changed(self, window, tab, tab_models=None):
# tab parameter removed in gedit 47
if not tab_models:
tab_models = tab
tab = window.get_active_tab()

if log.query(log.INFO):
Gedit.debug_plugin_message(log.format("%s, %s", window, tab))

self.active_tab_changed(tab, tab_models[tab.get_parent()])
if tab:
self.active_tab_changed(tab, tab_models[tab.get_parent()])

def on_window_key_press_event(self, window, event, tab_models):
if log.query(log.INFO):
Expand Down
27 changes: 18 additions & 9 deletions controlyourtabs/tabinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,24 @@


# based on switch statement in _gedit_tab_get_icon() in gedit-tab.c
TAB_STATE_TO_NAMED_ICON = {
Gedit.TabState.STATE_PRINTING: 'printer-printing-symbolic',
Gedit.TabState.STATE_SHOWING_PRINT_PREVIEW: 'printer-symbolic',
Gedit.TabState.STATE_LOADING_ERROR: 'dialog-error-symbolic',
Gedit.TabState.STATE_REVERTING_ERROR: 'dialog-error-symbolic',
Gedit.TabState.STATE_SAVING_ERROR: 'dialog-error-symbolic',
Gedit.TabState.STATE_GENERIC_ERROR: 'dialog-error-symbolic',
Gedit.TabState.STATE_EXTERNALLY_MODIFIED_NOTIFICATION: 'dialog-warning-symbolic'
}
TAB_STATE_TO_NAMED_ICON = {}
try:
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.PRINTING] = 'printer-printing-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.SHOWING_PRINT_PREVIEW] = 'printer-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.LOADING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.REVERTING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.SAVING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.GENERIC_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.EXTERNALLY_MODIFIED_NOTIFICATION] = 'dialog-warning-symbolic'
except AttributeError:
# constant names before gedit 47
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_PRINTING] = 'printer-printing-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_SHOWING_PRINT_PREVIEW] = 'printer-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_LOADING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_REVERTING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_SAVING_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_GENERIC_ERROR] = 'dialog-error-symbolic'
TAB_STATE_TO_NAMED_ICON[Gedit.TabState.STATE_EXTERNALLY_MODIFIED_NOTIFICATION] = 'dialog-warning-symbolic'

try:
# Gedit.TabState.STATE_PRINT_PREVIEWING removed in gedit 3.36
Expand Down

0 comments on commit 054a1e2

Please sign in to comment.