xpt*_*xpt 1 linux fonts gtk emacs ubuntu
我不喜欢基于 GTK 的 emacs(截图 #1),但仍然更喜欢我从 Ubuntu PPA 获得的传统 emacs(截图 #2)。
根本的区别在于,传统的 emacs 看起来大多是基于文本的,除了菜单,它仍然是基于 GTK 的。这个菜单字体和大小是我想要改变的。
基本上,我需要做与参考 #1 相同的事情:“例外是主菜单栏中弹出 [下拉] 菜单中的字体大小。例如,如果我启动 Emacs 并左键单击主菜单栏中的“文件”,弹出文件功能(打开文件、打开目录等)菜单,但是这个菜单字体太小,看不清。 Faces 自定义组中的选项似乎会影响它。”
我从参考文献#1 了解到“菜单字体由 GTK 控制,在 emacs 之外”。然而,在参考 #2 之后,我得到了相同的结果。即,无论我如何从消息中给出的参考中调整 ~/.emacs.d/gtkrc,对 Emacs 菜单都没有影响。
然后我从参考文献 #3 中发现,我所做的是为 GTK+ 版本 2 调整 Emacs 特定的 GTK+ 资源,而我的 Emacs,来自 Ubuntu PPA 的 Emacs 24,正在使用 GTK+ 版本 3。
好的,现在我的问题来了,如何配置 GTK+ 3 Menu 的字体和大小?我到处搜索,但也许 GTK+ 3 配置是如此新(或令人费解)以至于没有人写博客/谈论它。
任何人都可以给我一个如何配置 GTK+ 3 菜单字体和大小的工作示例吗?
谢谢
参考 #1:http : //forums.gentoo.org/viewtopic-t-516665-view-next.html?sid=b8448a7a0c04d2f6d6c80cbd43bfd931
参考 #2:http : //lists.debian.org/debian-user/2013/05/msg00169.html
参考 #3:http : //www.gnu.org/software/emacs/manual/html_node/emacs/GTK-resources.html#GTK-resources
截图 #1:
截图#2:

小智 7
假设:在您的主目录中,您有一个 subdir .themes。在这个子目录中,假设您从/usr/share/themes,递归复制了一个主题,以供阅读和定制。让我们称这个主题,或者更确切地说它的目录,~/.themes/mytheme. (注意:密切注意并在必要时修改文件的内容~/.themes/mytheme/index.theme)。
在该目录中,~/.themes/mytheme您还有另一个子目录~/.themes/mytheme/gtk-3.0。里面有个文件叫gtk.css. 这个文件可以很大,也可以很小。在后一种情况下,它通常有许多“@import url”语句,从别处导入其他 CSS 文件(样式表),例如,像这样:
@import url("/home/WHOAMI/.config/gtk-3.0/apps/someother.css");
@import url("./another.css");
Run Code Online (Sandbox Code Playgroud)
(用你自己的账户名代替 WHOAMI)
您的 emacs 样式表(即将推出的示例)将被调用 -- 您猜对了 -- emacs.css,我们需要将其添加到gtk.css,就像其他导入一样。让我们说:
@import url("/home/WHOAMI/.themes/gtk-3.0/emacs.css");
Run Code Online (Sandbox Code Playgroud)
在将我的副本交给您之前,请注意以下几点:
Gtk3 样式:与您所期望的相反(我当然这样做了),主题中可能可用的特定于应用程序的样式表(如上述emacs.css以及 gtk-3.0 子目录或任何嵌套子目录中的其他应用程序),这些特定于应用程序的样式表不仅限于相应的应用程序!看起来,Gtk3 只是在同一个命名空间内愉快地解析所有样式表(我只是在这里弥补后一个术语,但似乎合适)。
这意味着,例如,当您在样式表中设置菜单样式并调用 CSS 选择器(例如“GtkMenu”)时,您实际上是在设置所有应用程序中 GtkMenu 的所有实例的样式。这可能是也可能不是你的想法,但在我的情况下,当我在一个我命名为 emacs.css 的样式表中工作时,我发现它非常适得其反并且非常烦人 - 即限制其适用于 emacs。所以请注意,后一种假设是无效的。
另一个注意事项(部分是 a 的结果):尽管 css 现在看起来很小,但对 emacs Gtk3 进行样式设置很困难(我承认我是一个相对的 css 新手,但仍然如此)。我认为 emacs + Gtk3 需要有一个稍微好一点的 CSS 配置文件,因为有一个元素只能由 ' #pane '识别有点太笼统了,而且你几乎不能主题滚动条的事实在我看来是一个错误。我已经使用 emacs 超过 20 年了,我喜欢用 Gtk3 设计最新的 emacs-24.3,就像我早先用 Gtk2 设计 emacsen 一样。拥有桌面主题的一致性在大多数方面都很好,但在这种特殊情况下不是:我在 emacs 中花了很多时间,它需要根据我的眼睛喜欢和习惯来塑造(所以请注意 emacs 开发人员!)
第三个注意事项:又是由 b) 产生的:这个样式表看起来很精致!我有一种感觉,删除一个选择器,整个事情就会分崩离析。
当您开始修改样式表时,不要从启动器启动应用程序。从终端命令行启动它,所以 Gtk3 可能给出的关于样式/解析错误的任何反馈都在你面前。而且,您绝对不能在任何地方打开同一应用程序的其他实例。如果这样做,Gtk 显然会缓存样式数据,而新实例将只使用缓存的数据,让您想知道为什么最终应该使其工作的编辑实际上是行不通的。因此,每次修改样式时:电源循环:退出 emacs,从 CLI 再次启动它。
所以,这里是,我的emacs.css:
/*
see:
http://developer.gnome.org/gtk3/3.4/GtkCssProvider.html
http://www.gnu.org/software/emacs/manual/html_node/emacs/GTK-resources.html
http://thegnomejournal.wordpress.com/2011/03/15/styling-gtk-with-css/
http://www.gtkforums.com/viewtopic.php?f=3&t=988&p=72088=GTK3+with+CSS#p72088
*/
/*----------------------------------------------------------------*/
/*
General notes:
- try to make selectors as long as possible, so as not to interfere
with the controls of other applications; this can be achieved only partly
(e.g., #pane is a very general selector)
-
TODO:
- checkmarks in menus are black instead of white
- the 'exit emacs' popup dialog somehow gets the wrong resize grip
*/
/*----------------------------------------------------------------*/
/* this works */
#xxxpane
{
background-color: alpha( @theme_selected_bg_color, 0.8 );
color: purple;
}
#xxxframe /* works, but touches other applications */
/* (and we don't need it) )*/
{
background-color: #708090;
border-radius: 3px;
font-size: 12pt;
color: red;
}
/*----------------------------------------------------------------*/
#pane #verticalScrollBar
{
/* the vertical scrollbar in emacs has a bug where it sometimes covers the fringe */
border: 2px solid #292929; /* works ! */
padding: 1px 10px; /* second value has enormous effect oddly in vertical dimension! */
margin: 1px 10px; /* second value has enormous effect oddly in vertical dimension! */
/*border-radius: 2px;*/ /* works */
/*
GtkScrollbar:
"fixed-slider-length" gboolean
"has-backward-stepper" gboolean
"has-forward-stepper" gboolean
"has-secondary-backward-stepper" gboolean
"has-secondary-forward-stepper" gboolean
"min-slider-length" gint
*/
/*-GtkScrollbar-fixed-slider-length: 1;*/
-GtkScrollbar-min-slider-length: 25;
-GtkScrollbar-has-backward-stepper: 0;
-GtkScrollbar-has-forward-stepper: 0;
/*
GtkRange:
"activate-slider" gboolean
"arrow-displacement-x" gint
"arrow-displacement-y" gint
"arrow-scaling" gfloat
"slider-width" gint
"stepper-position-details" gboolean
"stepper-size" gint
"stepper-spacing" gint
"trough-border" gint
"trough-side-details" gboolean
"trough-under-steppers" gboolean
*/
/*-GtkRange-activate-slider: 1;*/
-GtkRange-slider-width: 4; /* works */
-GtkRange-trough-border: 0; /* works */ /* with a large width it reveals a bug in emacs and/or gtk3 */
-GtkRange-trough-side-details: 0;
-GtkRange-trough-under-steppers: 0;
}
/*----------------------------------------------------------------*/
/* the toolbar is almost never visible */
#emacs-toolbar,
#emacs-toolbar *
{
background-color: #536B84;
color: white;
padding: 0px 6px;
border: 1px solid white;
}
/*----------------------------------------------------------------*/
/* objective: get menu pulldown menu's to have thin and rounded borders */
#pane #menubar GtkMenuShell
{
border: 1px solid #78BAD4; /* light blue */
border-radius: 5px;
}
/* also give the menus a slightly larger font */
#pane #menubar,
#pane #menubar GtkMenuShell,
#pane #menubar GtkMenuShell *
{
font-family: "Ubuntu Sans Mono";
font-size: 7px;
}
/*----------------------------------------------------------------*/
#pane #menubar /* works */
{
background-color: #536B84;
border: none;
padding: 0px 0px;
margin: 25px;
}
/* top menu item */
/* this works, but it needs a parent Emacs class specifier */
#pane #menubar > GtkLabel,
#pane #menubar > GtkMenuItem
{
padding: 2px 18px; /* works */
margin: 3px 0px; /* works */
color: aquamarine; /* works */
}
/*----------------------------------------------------------------*/
/* disabled ("greyed out") menu items */
/* note: #emacs-menuitem:insensitive only does one level deep; test on Edit > GoTo > ... */
#emacs-menuitem *:insensitive
{
color: #292929; /* works */
text-shadow: none; /* works */
}
#emacs-menuitem * :hover,
#xxxxemacs-menuitem * :active
{
background-color: transparent; /* FINALLY WORKS! */
color: white; /* works */
}
#emacs-menuitem *, /* works */
#emacs-menuitem > GtkLabel /* works */
{
background-color: #536B84;
color: white /* works (also for tear lines!) */
}
#emacs-menuitem /* with only this it ALMOST works beautifully; only the tear lines are still white */
{
background-color: #536B84;
color: #292929; /* works -- this affects only the separators */
border: 0px none;
/*padding: auto auto;*/
/*margin: 0px 0px 0px 0px;*/
/*margin: auto auto auto auto;*/
}
/*----------------------------------------------------------------*/
/* popup dialog */
#emacs-dialog
{
background-color: #536B84;
color: white;
border: 0px none;
}
/*----------------------------------------------------------------*/
Run Code Online (Sandbox Code Playgroud)
看起来像个懦夫?好吧,那里有很多小时的样式和反复试验(我讨厌 CSS,它不是一种真正的语言,没有可发现性)。
尝试一下,看看你在适应和定制它时会如何。如果您获得任何见解或提示或发现缺点或错误或其他主题可能性,请提供反馈。我确定它不完整且不完美(一方面,我无法将下拉菜单的底角变圆)。
祝你好运!