Set window icon on linux
This commit is contained in:
parent
ed77692a87
commit
df5c225b5a
@ -75,7 +75,9 @@ mouse_button_pressed = defaultdict(lambda: False)
|
|||||||
mouse_cursor_pos = [0, 0]
|
mouse_cursor_pos = [0, 0]
|
||||||
viewport_size = ViewportSize()
|
viewport_size = ViewportSize()
|
||||||
cell_size = ViewportSize()
|
cell_size = ViewportSize()
|
||||||
terminfo_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'terminfo')
|
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
terminfo_dir = os.path.join(base_dir, 'terminfo')
|
||||||
|
logo_data_file = os.path.join(base_dir, 'logo', 'kitty.rgba')
|
||||||
main_thread = threading.current_thread()
|
main_thread = threading.current_thread()
|
||||||
shell_path = pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh'
|
shell_path = pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh'
|
||||||
|
|
||||||
|
|||||||
10
kitty/glfw.c
10
kitty/glfw.c
@ -285,6 +285,15 @@ set_clipboard_string(Window *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
set_window_icon(Window *self, PyObject *args) {
|
||||||
|
GLFWimage logo;
|
||||||
|
Py_ssize_t sz;
|
||||||
|
if(!PyArg_ParseTuple(args, "s#ii", &(logo.pixels), &sz, &(logo.width), &(logo.height))) return NULL;
|
||||||
|
glfwSetWindowIcon(self->window, 1, &logo);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
_set_title(Window *self, PyObject *args) {
|
_set_title(Window *self, PyObject *args) {
|
||||||
@ -327,6 +336,7 @@ static PyMethodDef methods[] = {
|
|||||||
MND(set_clipboard_string, METH_VARARGS),
|
MND(set_clipboard_string, METH_VARARGS),
|
||||||
MND(make_context_current, METH_NOARGS),
|
MND(make_context_current, METH_NOARGS),
|
||||||
{"set_title", (PyCFunction)_set_title, METH_VARARGS, ""},
|
{"set_title", (PyCFunction)_set_title, METH_VARARGS, ""},
|
||||||
|
{"set_icon", (PyCFunction)set_window_icon, METH_VARARGS, ""},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from gettext import gettext as _
|
|||||||
|
|
||||||
|
|
||||||
from .config import load_config, load_cached_values, cached_values, save_cached_values
|
from .config import load_config, load_cached_values, cached_values, save_cached_values
|
||||||
from .constants import appname, str_version, config_dir, viewport_size, isosx
|
from .constants import appname, str_version, config_dir, viewport_size, isosx, logo_data_file
|
||||||
from .layout import all_layouts
|
from .layout import all_layouts
|
||||||
from .boss import Boss
|
from .boss import Boss
|
||||||
from .shaders import GL_VERSION
|
from .shaders import GL_VERSION
|
||||||
@ -104,6 +104,9 @@ def run_app(opts, args):
|
|||||||
viewport_size.width, viewport_size.height, args.cls)
|
viewport_size.width, viewport_size.height, args.cls)
|
||||||
window.set_title(appname)
|
window.set_title(appname)
|
||||||
window.make_context_current()
|
window.make_context_current()
|
||||||
|
if not isosx:
|
||||||
|
with open(logo_data_file, 'rb') as f:
|
||||||
|
window.set_icon(f.read(), 256, 256)
|
||||||
viewport_size.width, viewport_size.height = window.get_framebuffer_size()
|
viewport_size.width, viewport_size.height = window.get_framebuffer_size()
|
||||||
glewInit()
|
glewInit()
|
||||||
boss = Boss(window, opts, args)
|
boss = Boss(window, opts, args)
|
||||||
|
|||||||
BIN
logo/kitty.rgba
Normal file
BIN
logo/kitty.rgba
Normal file
Binary file not shown.
@ -17,6 +17,7 @@ def render(output, sz=256):
|
|||||||
|
|
||||||
|
|
||||||
render('kitty.png')
|
render('kitty.png')
|
||||||
|
subprocess.check_call(['convert', 'kitty.png', 'kitty.rgba'])
|
||||||
iconset = 'kitty.iconset'
|
iconset = 'kitty.iconset'
|
||||||
if os.path.exists(iconset):
|
if os.path.exists(iconset):
|
||||||
shutil.rmtree(iconset)
|
shutil.rmtree(iconset)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -219,10 +219,12 @@ def package(args): # {{{
|
|||||||
if os.path.exists(libdir):
|
if os.path.exists(libdir):
|
||||||
shutil.rmtree(libdir)
|
shutil.rmtree(libdir)
|
||||||
os.makedirs(os.path.join(libdir, 'terminfo/x'))
|
os.makedirs(os.path.join(libdir, 'terminfo/x'))
|
||||||
|
os.makedirs(os.path.join(libdir, 'logo'))
|
||||||
safe_makedirs(terminfo_dir)
|
safe_makedirs(terminfo_dir)
|
||||||
shutil.copy2('__main__.py', libdir)
|
shutil.copy2('__main__.py', libdir)
|
||||||
shutil.copy2('terminfo/x/xterm-kitty', terminfo_dir)
|
shutil.copy2('terminfo/x/xterm-kitty', terminfo_dir)
|
||||||
shutil.copy2('terminfo/x/xterm-kitty', os.path.join(libdir, 'terminfo/x'))
|
shutil.copy2('terminfo/x/xterm-kitty', os.path.join(libdir, 'terminfo/x'))
|
||||||
|
shutil.copy2('logo/kitty.rgba', os.path.join(libdir, 'logo'))
|
||||||
|
|
||||||
def src_ignore(parent, entries):
|
def src_ignore(parent, entries):
|
||||||
return [x for x in entries if '.' in x and x.rpartition('.')[2] not in ('py', 'so', 'conf')]
|
return [x for x in entries if '.' in x and x.rpartition('.')[2] not in ('py', 'so', 'conf')]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user