Cleanup previous PR

This commit is contained in:
Kovid Goyal 2023-03-19 10:37:37 +05:30
parent 14dcf38e51
commit fda2646dd3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
10 changed files with 33 additions and 12 deletions

View File

@ -68,6 +68,8 @@ Detailed list of changes
- macOS: Fix the maximized window not taking up full space when the title bar is hidden or when :opt:`resize_in_steps` is configured (:iss:`6021`)
- Linux: A new option :opt:`linux_bell_theme` to control which sound theme is used for the bell sound (:pull:`4858`)
- ssh kitten: Change the syntax of glob patterns slightly to match common usage
elsewhere. Now the syntax is the same a "extendedglob" in most shells.

View File

@ -162,6 +162,7 @@ free_canberra_event_fields(CanberraEvent *e) {
free(e->which_sound); e->which_sound = NULL;
free(e->event_id); e->event_id = NULL;
free(e->media_role); e->media_role = NULL;
free(e->theme_name); e->theme_name = NULL;
}
static void
@ -245,7 +246,7 @@ play_desktop_sound(PyObject *self UNUSED, PyObject *args) {
const char *which, *event_id = "test sound";
const char *theme_name = "freedesktop";
int is_path = 0;
if (!PyArg_ParseTuple(args, "s|sp", &which, &event_id, &is_path, &theme_name)) return NULL;
if (!PyArg_ParseTuple(args, "s|sps", &which, &event_id, &is_path, &theme_name)) return NULL;
play_canberra_sound(which, event_id, is_path, "event", theme_name);
Py_RETURN_NONE;
}

View File

@ -1387,8 +1387,8 @@ ring_audio_bell(void) {
#ifdef __APPLE__
cocoa_system_beep(OPT(bell_path));
#else
if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true, "event", OPT(linux_bell_theme_name));
else play_canberra_sound("bell", "kitty bell", false, "event", OPT(linux_bell_theme_name));
if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true, "event", OPT(bell_theme));
else play_canberra_sound("bell", "kitty bell", false, "event", OPT(bell_theme));
#endif
}

View File

@ -858,8 +858,8 @@ MP3 or WAV on macOS (NSSound)
'''
)
opt('linux_bell_theme_name', '__custom',
long_text='If audio bell is enabled on Linux, sets the XDG Sound Theme kitty will use to play the bell sound.'
opt('linux_bell_theme', '__custom', ctype='!bell_theme',
long_text='The XDG Sound Theme kitty will use to play the bell sound.'
' Defaults to the custom theme name used by GNOME and Budgie, falling back to the default freedesktop theme if it does not exist.'
' This option may be removed if Linux ever provides desktop-agnostic support for setting system sound themes.'
)

View File

@ -1024,8 +1024,8 @@ class Parser:
def kitty_mod(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['kitty_mod'] = to_modifiers(val)
def linux_bell_theme_name(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['linux_bell_theme_name'] = str(val)
def linux_bell_theme(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['linux_bell_theme'] = str(val)
def linux_display_server(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
val = val.lower()

View File

@ -473,6 +473,19 @@ convert_from_opts_bell_path(PyObject *py_opts, Options *opts) {
Py_DECREF(ret);
}
static void
convert_from_python_linux_bell_theme(PyObject *val, Options *opts) {
bell_theme(val, opts);
}
static void
convert_from_opts_linux_bell_theme(PyObject *py_opts, Options *opts) {
PyObject *ret = PyObject_GetAttrString(py_opts, "linux_bell_theme");
if (ret == NULL) return;
convert_from_python_linux_bell_theme(ret, opts);
Py_DECREF(ret);
}
static void
convert_from_python_active_border_color(PyObject *val, Options *opts) {
opts->active_border_color = active_border_color(val);
@ -1119,6 +1132,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
if (PyErr_Occurred()) return false;
convert_from_opts_bell_path(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_linux_bell_theme(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_active_border_color(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_inactive_border_color(py_opts, opts);

View File

@ -104,6 +104,10 @@ background_image(PyObject *src, Options *opts) { STR_SETTER(background_image); }
static void
bell_path(PyObject *src, Options *opts) { STR_SETTER(bell_path); }
static void
bell_theme(PyObject *src, Options *opts) { STR_SETTER(bell_theme); }
static void
window_logo_path(PyObject *src, Options *opts) { STR_SETTER(default_window_logo); }

View File

@ -376,7 +376,7 @@ option_names = ( # {{{
'italic_font',
'kitten_alias',
'kitty_mod',
'linux_bell_theme_name',
'linux_bell_theme',
'linux_display_server',
'listen_on',
'macos_colorspace',
@ -535,7 +535,7 @@ class Options:
input_delay: int = 3
italic_font: str = 'auto'
kitty_mod: int = 5
linux_bell_theme_name: str = '__custom'
linux_bell_theme: str = '__custom'
linux_display_server: choices_for_linux_display_server = 'auto'
listen_on: str = 'none'
macos_colorspace: choices_for_macos_colorspace = 'srgb'

View File

@ -1405,7 +1405,7 @@ finalize(void) {
if (detached_windows.windows) free(detached_windows.windows);
detached_windows.capacity = 0;
#define F(x) free(OPT(x)); OPT(x) = NULL;
F(background_image); F(bell_path); F(default_window_logo);
F(background_image); F(bell_path); F(bell_theme); F(default_window_logo);
#undef F
// we leak the texture here since it is not guaranteed
// that freeing the texture will work during shutdown and

View File

@ -29,7 +29,6 @@ typedef struct {
double wheel_scroll_multiplier, touch_scroll_multiplier;
int wheel_scroll_min_lines;
bool enable_audio_bell;
const char *linux_bell_theme_name;
CursorShape cursor_shape;
float cursor_beam_thickness;
float cursor_underline_thickness;
@ -47,7 +46,7 @@ typedef struct {
unsigned int macos_option_as_alt;
float macos_thicken_font;
WindowTitleIn macos_show_window_title_in;
char *bell_path;
char *bell_path, *bell_theme;
float background_opacity, dim_opacity;
float text_contrast, text_gamma_adjustment;
bool text_old_gamma;