Fed*_*eli 5 gtkinspector gtk4 gnome-text-editor
Ubuntu 22.10 / 23.04 / 23.10 中的“新”文本编辑器(我不是在谈论旧gedit
工具)在编辑区域(就在第一行上方)具有较大的上边距,如下所示:
今天,我遇到了GTK Inspector ,可以通过按+ + (大写)从文本编辑器激活它。导航到对象\xe2\x86\x92属性并将上边距的值从 12 更改为 2 后,此上边距大小将减小为更有意义的设置:CtrlShiftIi
但是,此设置更改不是永久性的;关闭并重新启动后,gnome-text-editor
此大小将恢复为旧值 (12)。
有没有办法让改变永久化?我想,~/.config/gtk-4.0/gtk.css
需要进行一些修改;然而GTK Inspector并没有帮助我解决这个问题。
AFAIK,这是 GTK Widget“属性”
\n仅在以下情况下才可以在运行时包中更改它:
\n否则,没有其他方法可以更改源代码本身,因为应用程序不使用 GTK 构建器,它基于编译的编程语言。GUI 以二进制格式嵌入到可执行文件或其共享库中。
\nGTK Widget“属性”与 CSS 样式不同。我确实检查过:padding-top
它们margin-top
不一样,只是增加了更多空间。即使在层次结构中向下也没有效果,我怀疑它被运行时程序更新/覆盖。
不管怎样,这是我首先尝试调试和跟踪的,可能是我错过了一些东西:
\n.editor.GtkSourceView.monospace.sourceview.view {\n border-style: solid;\n border-top-width: 3px;\n border-top-color: rgb(0,255,0);\n border-left-width: 2px;\n border-left-color: rgb(0,255,255);\n background-color: rgb(255,0,0);\n margin-top: 100px;\n padding-top: 50px;\n}\n\n.editor.GtkSourceView.monospace.sourceview.view > text {\n border-style: solid;\n border-top-width: 5px;\n border-top-color: rgb(255,255,0);\n border-left-width: 3px;\n border-left-color: rgb(0,255,255);\n\n /* not effective ??? */\n background-color: rgb(0,0,200);\n margin-top: 10px;\n padding-top: 100px;\n margin: 50px;\n padding: 30px;\n} \n
Run Code Online (Sandbox Code Playgroud)\nGTK 检查器 CSS 在 gnome 文本编辑器上进行调整试验的屏幕截图
\n\n\nRun Code Online (Sandbox Code Playgroud)\n.editor.GtkSourceView.monospace.sourceview.view {\n margin-top: -12px;\n}\n
注意:如果您想知道“ editor GtkSourceView monospace sourceview view
CSS 选择器”来自哪里,请检查:GTK Inspector > 对象 > 使用选取工具 > CSS 节点 > 样式类。
如果您选择修改源代码,我希望您能找到以下内容:
\nhttps://gitlab.gnome.org/GNOME/gnome-text-editor/-/blob/main/src/editor-page.ui#L30
\n...\n<object class="GtkScrolledWindow" id="scroller">\n <property name="hexpand">true</property>\n <property name="vexpand">true</property>\n <child>\n <object class="EditorSourceView" id="view">\n <style>\n <class name="editor"/>\n </style>\n <signal name="notify::font-scale" handler="font_scale_changed_cb" swapped="true"/>\n <property name="auto-indent">true</property>\n <property name="top-margin">12</property>\n...\n
Run Code Online (Sandbox Code Playgroud)\n好吧,这只是一个捷径/黑客。我不会在源代码开放且免费的“自由软件”世界中推荐它。
\n安装 bless 或任何其他十六进制编辑器。
\n制作可执行文件的副本
\n## Check for file path\nwhich gnome-text-editor\n\n/usr/bin/gnome-text-editor\n\n## Confirm not just a proxy/wrapper script\nfile /usr/bin/gnome-text-editor\n\n/usr/bin/gnome-text-editor: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b2b5986d56418c22adb1e35431cb650c259bba7c, for GNU/Linux 3.2.0, stripped\n\n## Copy and make a backup\ncp /usr/bin/gnome-text-editor ./Desktop/gnome-text-editor.mod\ncp /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor.backup\n
Run Code Online (Sandbox Code Playgroud)\n打开./Desktop/gnome-text-editor.mod
用bless
。搜索“上边距”。你可能会发现4个与“editor”对象中的匹配的就是我们的目标。我在 Ubuntu 23.10 中的偏移量约为 405506(十进制)。将值“12”更改为所需值,但保留两位数(零为“00”)
测试一下然后复制回来
\n./Desktop/gnome-text-editor.mod\nsudo cp ./Desktop/gnome-text-editor.mod ./Desktop/gnome-text-editor\n
Run Code Online (Sandbox Code Playgroud)\n结果 gnome-text-editor 的屏幕截图,上边距设置为 0px
\n这可能会被任何未来的更新覆盖。如果您想通过在 APT 或 DPKG 中锁定其软件包更新来防止这种情况,由您决定。
\n