我设法让滚动条比平常小一点。但是,我无法将父窗口小部件缩放到正确的大小。下图显示了我的意思,并显示了〜/ .gtkrc-2.0的内容......
我错过了什么?
这是一个可复制的〜/ .gtkrc-2.0片段:
style "neverness" {
GtkScrollbar::activate-slider = 1
GtkScrollbar::trough-border = 0
GtkScrollbar::slider-width = 9
GtkScrollbar::min-slider-length = 36
GtkScrollbar::has-forward-stepper = 1
GtkScrollbar::has-backward-stepper = 1
}
class "GtkScrollbar" style "neverness"
class "GtkHScrollbar" style "neverness"
class "GtkVScrollbar" style "neverness"
Vim版本:
; vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 21 2013 17:41:49)
Included patches: 1-831
Compiled by yann@nightwatch.neverness.org
Big version with GTK2 GUI. Features included (+) or not (-):
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
+clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra +toolbar
+cmdline_compl +insert_expand -perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall -profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui -lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind +X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape -sniff +xsmp_interact
+eval +mouse_dec +startuptime +xterm_clipboard
+ex_extra +mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop
+farsi +mouse_netterm +syntax
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/home/yann/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/local/include -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib64/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
答案 0 :(得分:2)
这不是由GTK +引起的;它是由vim引起的。
参见vim73 / src / gui.c:gui_init_check():
gui.scrollbar_width = gui.scrollbar_height = SB_DEFAULT_WIDTH;
该值来自gui.h:
#define SB_DEFAULT_WIDTH 16
稍后,gui_position_components()执行此操作:
gui.right_sbar_x = text_area_x + text_area_width;
gui_update_scrollbars()这样做:
gui_mch_set_scrollbar_pos(&wp->w_scrollbars[SBAR_RIGHT],
gui.right_sbar_x, y,
gui.scrollbar_width, h);
以
完成gtk_form_move_resize(GTK_FORM(gui.formwin), sb->id, x, y, w, h);
GtkForm是一个在vim中实现的自定义小部件;见gui_gtk_f.c:
void
gtk_form_move_resize(GtkForm *form, GtkWidget *widget,
gint x, gint y, gint w, gint h)
{
widget->requisition.width = w;
widget->requisition.height = h;
gtk_form_move(form, widget, x, y);
}
稍后,gtk_form_position_child()中的代码只是抓取widget->请求并将其用于子项的分配。
GtkVScrollbar看到它被分配的水平空间超过了它所需的水平空间(即SB_DEFAULT_WIDTH = 16),并以其分配为中心。这是您在滚动条周围看到的额外空间。
Vim不应该调整小部件的内部 - >请求字段。相反,它应该在某处(可能在GtkFormChild结构中)存储所需的值并使用它们。除此之外,它应该能够使用GTK +自己的大小请求来获得滚动条的请求宽度。