Patch 8.1.2034

9 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 15, 2019, 7:17:51 AM9/15/19
to vim...@googlegroups.com

Patch 8.1.2034
Problem: Dark theme of GTK 3 not supported.
Solution: Add the "d" flag in 'guioptions'. (Jonathan Conder, closes #4934)
Files: runtime/doc/options.txt, src/feature.h, src/gui.c,
src/gui_gtk_x11.c, src/option.h, src/proto/gui_gtk_x11.pro,
src/testdir/test_gui.vim


*** ../vim-8.1.2033/runtime/doc/options.txt 2019-09-14 21:00:01.379100893 +0200
--- runtime/doc/options.txt 2019-09-15 13:13:52.745023920 +0200
***************
*** 856,861 ****
--- 856,863 ----
:set background&
< Vim will guess the value. In the GUI this should work correctly,
in other cases Vim might not be able to guess the right value.
+ If the GUI supports a dark them, you can use the "d" flag in
+ 'guioptions', see 'go-d'.

When the |t_RB| option is set, Vim will use it to request the background
color from the terminal. If the returned RGB value is dark/light and
***************
*** 3738,3743 ****
--- 3742,3750 ----
*'go-c'*
'c' Use console dialogs instead of popup dialogs for simple
choices.
+ *'go-d'*
+ 'd' Use dark theme variant if available. Currently only works for
+ GTK+ GUI.
*'go-e'*
'e' Add tab pages when indicated with 'showtabline'.
'guitablabel' can be used to change the text in the labels.
*** ../vim-8.1.2033/src/feature.h 2019-09-04 15:54:23.916359692 +0200
--- src/feature.h 2019-09-15 13:08:06.054407481 +0200
***************
*** 647,652 ****
--- 647,659 ----
#endif

/*
+ * GUI dark theme variant
+ */
+ #if defined(FEAT_GUI_GTK) && defined(USE_GTK3)
+ # define FEAT_GUI_DARKTHEME
+ #endif
+
+ /*
* GUI tabline
*/
#if defined(FEAT_NORMAL) \
*** ../vim-8.1.2033/src/gui.c 2019-08-21 14:36:29.387376100 +0200
--- src/gui.c 2019-09-15 13:08:06.058407465 +0200
***************
*** 3425,3430 ****
--- 3425,3434 ----
void
gui_init_which_components(char_u *oldval UNUSED)
{
+ #ifdef FEAT_GUI_DARKTHEME
+ static int prev_dark_theme = -1;
+ int using_dark_theme = FALSE;
+ #endif
#ifdef FEAT_MENU
static int prev_menu_is_active = -1;
#endif
***************
*** 3495,3500 ****
--- 3499,3509 ----
case GO_BOT:
gui.which_scrollbars[SBAR_BOTTOM] = TRUE;
break;
+ #ifdef FEAT_GUI_DARKTHEME
+ case GO_DARKTHEME:
+ using_dark_theme = TRUE;
+ break;
+ #endif
#ifdef FEAT_MENU
case GO_MENUS:
gui.menu_is_active = TRUE;
***************
*** 3528,3533 ****
--- 3537,3550 ----
need_set_size = 0;
fix_size = FALSE;

+ #ifdef FEAT_GUI_DARKTHEME
+ if (using_dark_theme != prev_dark_theme)
+ {
+ gui_mch_set_dark_theme(using_dark_theme);
+ prev_dark_theme = using_dark_theme;
+ }
+ #endif
+
#ifdef FEAT_GUI_TABLINE
/* Update the GUI tab line, it may appear or disappear. This may
* cause the non-GUI tab line to disappear or appear. */
*** ../vim-8.1.2033/src/gui_gtk_x11.c 2019-07-28 15:21:50.813275855 +0200
--- src/gui_gtk_x11.c 2019-09-15 13:08:06.058407465 +0200
***************
*** 3130,3135 ****
--- 3130,3148 ----
}
}

+ #if defined(FEAT_GUI_DARKTHEME) || defined(PROTO)
+ void
+ gui_mch_set_dark_theme(int dark)
+ {
+ # if GTK_CHECK_VERSION(3,0,0)
+ GtkSettings *gtk_settings;
+
+ gtk_settings = gtk_settings_get_for_screen(gdk_screen_get_default());
+ g_object_set(gtk_settings, "gtk-application-prefer-dark-theme", (gboolean)dark, NULL);
+ # endif
+ }
+ #endif /* FEAT_GUI_DARKTHEME */
+
#ifdef FEAT_TOOLBAR

/*
*** ../vim-8.1.2033/src/option.h 2019-09-14 21:00:01.383100879 +0200
--- src/option.h 2019-09-15 13:08:06.058407465 +0200
***************
*** 213,218 ****
--- 213,219 ----
#define GO_ASELML 'A' // autoselect modeless selection
#define GO_BOT 'b' // use bottom scrollbar
#define GO_CONDIALOG 'c' // use console dialog
+ #define GO_DARKTHEME 'd' // use dark theme variant
#define GO_TABLINE 'e' // may show tabline
#define GO_FORG 'f' // start GUI in foreground
#define GO_GREY 'g' // use grey menu items
***************
*** 231,237 ****
#define GO_FOOTER 'F' // add footer
#define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size
! #define GO_ALL "!aAbcefFghilmMprtTvk" // all possible flags for 'go'

// flags for 'comments' option
#define COM_NEST 'n' // comments strings nest
--- 232,238 ----
#define GO_FOOTER 'F' // add footer
#define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size
! #define GO_ALL "!aAbcdefFghilmMprtTvk" // all possible flags for 'go'

// flags for 'comments' option
#define COM_NEST 'n' // comments strings nest
*** ../vim-8.1.2033/src/proto/gui_gtk_x11.pro 2019-06-14 21:36:51.014437500 +0200
--- src/proto/gui_gtk_x11.pro 2019-09-15 13:08:06.058407465 +0200
***************
*** 8,13 ****
--- 8,14 ----
void gui_mch_start_blink(void);
int gui_mch_early_init_check(int give_message);
int gui_mch_init_check(void);
+ void gui_mch_set_dark_theme(int dark);
void gui_mch_show_tabline(int showit);
int gui_mch_showing_tabline(void);
void gui_mch_update_tabline(void);
*** ../vim-8.1.2033/src/testdir/test_gui.vim 2019-09-08 18:58:39.557952948 +0200
--- src/testdir/test_gui.vim 2019-09-15 13:08:06.058407465 +0200
***************
*** 643,648 ****
--- 643,657 ----
call assert_equal('aegi', &guioptions)
endif

+ if has('gui_gtk3')
+ set guioptions+=d
+ exec 'sleep' . duration
+ call assert_equal('aegid', &guioptions)
+ set guioptions-=d
+ exec 'sleep' . duration
+ call assert_equal('aegi', &guioptions)
+ endif
+
" Restore GUI ornaments to the default state.
set guioptions+=m
exec 'sleep' . duration
*** ../vim-8.1.2033/src/version.c 2019-09-14 22:33:44.152114604 +0200
--- src/version.c 2019-09-15 13:09:44.006009454 +0200
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 2034,
/**/

--
hundred-and-one symptoms of being an internet addict:
263. You have more e-mail addresses than shorts.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages