Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove refresh_all in Windows on settings change. Fixes Issue #15 #16

Merged
merged 4 commits into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions set_window_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,30 @@ def plugin_loaded():
global _READY_
_READY_ = True

# Update all window titles on setting change.
settings = sublime.load_settings("set_window_title.sublime-settings")
setting_keys = [
"unregistered",
"template",
"has_project_true",
"has_project_false",
"is_dirty_true",
"is_dirty_false",
"path_display",
"untitled",
]
for k in setting_keys:
settings.add_on_change(k, refresh_all)

if PLATFORM == "linux":
# Set the title when the plugin is loaded.
# Only enabled on Linux because for some reason it freezes ST on Windows.
# TODO: Find how to enable a similar behavior on Windows.
# Update all window titles on setting change.
settings = sublime.load_settings("set_window_title.sublime-settings")
setting_keys = [
"unregistered",
"template",
"has_project_true",
"has_project_false",
"is_dirty_true",
"is_dirty_false",
"path_display",
"untitled",
]
for k in setting_keys:
settings.add_on_change(k, refresh_all)

# Update all window titles on plugin loaded for Linux.
refresh_all()

# Reported to freeze ST on Windows for some reason to update top or all window titles on loading. TODO: Find how to update window title on plugin loaded for Windows wthout freezing.
# Reference - https://github.com/gwenzek/SublimeSetWindowTitle/pull/16
#elif PLATFORM == "windows":
#SetWindowTitle().run(sublime.active_window().active_view())


def refresh_all():
title_setter = SetWindowTitle()
Expand Down Expand Up @@ -143,7 +146,8 @@ def rename_window_linux(self, window, official_title, new_title, debug=False):
def rename_window_windows(self, new_title):
# PX_WINDOW_CLASS is the ClassName of SublimeText, can be seen via a tool such as Nirsoft WinLister
hwndSublime = ctypes.windll.user32.FindWindowA(b'PX_WINDOW_CLASS', None)
ctypes.windll.user32.SetWindowTextW(hwndSublime, new_title)
if(hwndSublime):
ctypes.windll.user32.SetWindowTextW(hwndSublime, new_title)

def get_project(window):
"""Returns the project name for the given window.
Expand Down