From b73bbe1da5d1aeb7faba7e694257f11c27bfc36e Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Thu, 4 Jul 2013 15:53:17 +0000 Subject: [PATCH] Win-installer: embedding the Windows GTK theme --- Makefile.win32 | 5 +++- data/gtkrc | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/main.ml | 6 +++++ src/ocamlBuffer.ml | 5 ++-- 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 data/gtkrc diff --git a/Makefile.win32 b/Makefile.win32 index 9cbc6e2..96d1f84 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -10,6 +10,7 @@ else endif WINLIBS=/cygdrive/c/usr/bin +GTK_MODULES=/cygdrive/c/usr/lib/gtk-2.0/2.10.0/ utils/mkwinapp$(EXEEXT): utils/mkwinapp.ml ocamlfind ocamlopt -package unix -linkpkg -o $@ $^ @@ -28,7 +29,7 @@ clean: rm -rf inst rm -f ocaml-top$(EXEEXT) ocaml-top.msi -RESOURCES = data/ocaml.lang data/def.lang data/cobalt.xml data/language2.rng data/toplevel_init.ml data/logo.png data/logo.ico +RESOURCES = data/ocaml.lang data/def.lang data/cobalt.xml data/language2.rng data/toplevel_init.ml data/logo.png data/logo.ico data/gtkrc ICONS = $(wildcard data/icons/*.png) .PHONY: inst/ocaml-top inst/ocaml-top: ocaml-top$(EXEEXT) $(RESOURCES) $(ICONS) @@ -39,6 +40,8 @@ inst/ocaml-top: ocaml-top$(EXEEXT) $(RESOURCES) $(ICONS) cp $(ICONS) inst/ocaml-top/data/icons cp $$(PATH=$(WINLIBS):$$PATH ldd ocaml-top.exe | awk '/usr\/bin/ { print $$3 }') \ inst/ocaml-top + mkdir -p inst/ocaml-top/data/engines + cp $(GTK_MODULES)/engines/libwimp.dll inst/ocaml-top/data/engines ocaml-top.zip: inst/ocaml-top cd inst && zip -r ../ocaml-top.zip ocaml-top diff --git a/data/gtkrc b/data/gtkrc new file mode 100644 index 0000000..162265f --- /dev/null +++ b/data/gtkrc @@ -0,0 +1,66 @@ +gtk-icon-sizes = "gtk-menu=13,13:gtk-small-toolbar=16,16:gtk-large-toolbar=24,24:gtk-dnd=32,32" +gtk-toolbar-icon-size = small-toolbar + +# disable images in buttons. i've only seen ugly delphi apps use this feature. +gtk-button-images = 0 + +# enable/disable images in menus. most "stock" microsoft apps don't use these, except sparingly. +# the office apps use them heavily, though. +gtk-menu-images = 1 + +# use the win32 button ordering instead of the GNOME HIG one, where applicable +gtk-alternative-button-order = 1 + +# use the win32 sort indicators direction, as in Explorer +gtk-alternative-sort-arrows = 1 + +# Windows users don't expect the PC Speaker beeping at them when they backspace in an empty textview and stuff like that +gtk-error-bell = 0 + +style "msw-default" +{ + GtkWidget::interior-focus = 1 + GtkOptionMenu::indicator-size = { 9, 5 } + GtkOptionMenu::indicator-spacing = { 7, 5, 2, 2 } + GtkSpinButton::shadow-type = in + + # Owen and I disagree that these should be themable + #GtkUIManager::add-tearoffs = 0 + #GtkComboBox::add-tearoffs = 0 + + GtkComboBox::appears-as-list = 1 + GtkComboBox::focus-on-click = 0 + + GOComboBox::add_tearoffs = 0 + + GtkTreeView::allow-rules = 0 + GtkTreeView::expander-size = 12 + + GtkExpander::expander-size = 12 + + GtkScrolledWindow::scrollbar_spacing = 1 + + GtkSeparatorMenuItem::horizontal-padding = 2 + + engine "wimp" + { + } +} +class "*" style "msw-default" + +binding "ms-windows-tree-view" +{ + bind "Right" { "expand-collapse-cursor-row" (1,1,0) } + bind "Left" { "expand-collapse-cursor-row" (1,0,0) } +} + +class "GtkTreeView" binding "ms-windows-tree-view" + +style "msw-combobox-thickness" = "msw-default" +{ + xthickness = 0 + ythickness = 0 +} + +widget_class "*TreeView*ComboBox*" style "msw-combobox-thickness" +widget_class "*ComboBox*GtkFrame*" style "msw-combobox-thickness" diff --git a/src/main.ml b/src/main.ml index bb931fc..6425637 100644 --- a/src/main.ml +++ b/src/main.ml @@ -230,6 +230,12 @@ let _ = output_string ch s) "ok" ; + let _reloc_gtk_conf_on_windows = + if Sys.os_type <> "Unix" then + let gtkrc = Filename.concat !Cfg.datadir "gtkrc" in + (try Glib.setenv "GTK_PATH" !Cfg.datadir true with Not_found -> ()); + if Sys.file_exists gtkrc then GtkMain.Rc.parse gtkrc + in let main_window = Gui.main_window () in let create () = diff --git a/src/ocamlBuffer.ml b/src/ocamlBuffer.ml index 499be9d..ec4b8f2 100644 --- a/src/ocamlBuffer.ml +++ b/src/ocamlBuffer.ml @@ -15,16 +15,15 @@ open Tools.Ops module GSourceView_params = struct - let syntax_mgr = GSourceView2.source_language_manager ~default:true - let style_mgr = GSourceView2.source_style_scheme_manager ~default:true - let syntax () = + let syntax_mgr = GSourceView2.source_language_manager ~default:true in syntax_mgr#set_search_path [!Cfg.datadir]; let syn = syntax_mgr#language "ocp-edit-ocaml" in if syn = None then Tools.debug "WARNING: ocaml language def not found"; syn let style () = + let style_mgr = GSourceView2.source_style_scheme_manager ~default:true in style_mgr#set_search_path [!Cfg.datadir]; let sty = style_mgr#style_scheme "cobalt" in if sty = None then Tools.debug "WARNING: style def not found";