1 Star 0 Fork 3

丈青山/gnome-console

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-Enable-Ctrl-PgUp-PgDn-to-switch-tabs-if-there-are-mu.patch 2.67 KB
一键复制 编辑 原始数据 按行查看 历史
丈青山 提交于 2022-04-15 17:15 . Initial Packaging
From 41f0321b2ee83e1bd670177e5960c4d5dcbb281f Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@mit.edu>
Date: Mon, 28 Mar 2022 23:16:26 -0700
Subject: [PATCH] Enable Ctrl+PgUp/PgDn to switch tabs if there are multiple
tabs
Users expect Ctrl+PgUp/PgDn to switch tabs, but some terminal
applications want to be able to use these keys themselves. Make the
same compromise that gnome-terminal does, and let these keys switch
tabs _if_ there are multiple tabs in the current window to switch
between.
Fixes https://gitlab.gnome.org/GNOME/console/-/issues/118.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
src/kgx-pages.c | 19 +++++++++++++++++++
src/kgx-pages.h | 1 +
src/kgx-window.c | 9 +++++----
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/kgx-pages.c b/src/kgx-pages.c
index 0b7c37a..4084efd 100644
--- a/src/kgx-pages.c
+++ b/src/kgx-pages.c
@@ -819,6 +819,25 @@ kgx_pages_current_status (KgxPages *self)
}
+/**
+ * kgx_pages_count:
+ * @self: the #KgxPages
+ *
+ * Returns: number of #KgxTab s in @self
+ */
+int
+kgx_pages_count (KgxPages *self)
+{
+ KgxPagesPrivate *priv;
+
+ g_return_val_if_fail (KGX_IS_PAGES (self), KGX_NONE);
+
+ priv = kgx_pages_get_instance_private (self);
+
+ return hdy_tab_view_get_n_pages (HDY_TAB_VIEW (priv->view));
+}
+
+
/**
* kgx_pages_get_children:
* @self: the #KgxPages
diff --git a/src/kgx-pages.h b/src/kgx-pages.h
index 9fbaae6..9a03c77 100644
--- a/src/kgx-pages.h
+++ b/src/kgx-pages.h
@@ -45,6 +45,7 @@ void kgx_pages_add_page (KgxPages *self,
KgxTab *page);
void kgx_pages_remove_page (KgxPages *self,
KgxTab *page);
+int kgx_pages_count (KgxPages *self);
GPtrArray *kgx_pages_get_children (KgxPages *self);
void kgx_pages_focus_page (KgxPages *self,
KgxTab *page);
diff --git a/src/kgx-window.c b/src/kgx-window.c
index acddf60..3bc1d0c 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -260,10 +260,11 @@ key_press_event (GtkWidget *widget,
*
* See https://gitlab.gnome.org/GNOME/libhandy/-/issues/422
*/
- if ((keyval == GDK_KEY_Page_Up ||
- keyval == GDK_KEY_KP_Page_Up ||
- keyval == GDK_KEY_Page_Down ||
- keyval == GDK_KEY_KP_Page_Down ||
+ if ((((keyval == GDK_KEY_Page_Up ||
+ keyval == GDK_KEY_KP_Page_Up ||
+ keyval == GDK_KEY_Page_Down ||
+ keyval == GDK_KEY_KP_Page_Down) &&
+ kgx_pages_count (KGX_PAGES (self->pages)) <= 1) ||
keyval == GDK_KEY_Home ||
keyval == GDK_KEY_KP_Home ||
keyval == GDK_KEY_End ||
--
2.35.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhang__3125/gnome-console.git
git@gitee.com:zhang__3125/gnome-console.git
zhang__3125
gnome-console
gnome-console
master

搜索帮助