]> granicus.if.org Git - vim/commitdiff
patch 8.1.2034: dark them of GTK 3 not supported v8.1.2034
authorBram Moolenaar <Bram@vim.org>
Sun, 15 Sep 2019 11:17:00 +0000 (13:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 15 Sep 2019 11:17:00 +0000 (13:17 +0200)
Problem:    Dark them of GTK 3 not supported.
Solution:   Add the "d" flag in 'guioptions'. (Jonathan Conder, closes #4934)

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
src/version.c

index 9fa2bfb3ad07f1a0f0cfef72b91d956b332a785f..4890a986c3f0d18c7b3dac69d1fb127bcd66f370 100644 (file)
@@ -856,6 +856,8 @@ A jump table for the options with a short description can be found at |Q_op|.
                :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
@@ -3740,6 +3742,9 @@ A jump table for the options with a short description can be found at |Q_op|.
                                                                *'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.
index c4ccd2177c27d4e86b8f2b27f48569901f48e752..dc5accc7a12f372cc92e3ed741baea20f6157229 100644 (file)
 # define FEAT_MENU
 #endif
 
+/*
+ * GUI dark theme variant
+ */
+#if defined(FEAT_GUI_GTK) && defined(USE_GTK3)
+# define FEAT_GUI_DARKTHEME
+#endif
+
 /*
  * GUI tabline
  */
index d9e7e47a0f39e237f1600867ca8b64c740ad5e3f..860add2b43aece9af61c85931136519135654b9f 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -3425,6 +3425,10 @@ static int       prev_which_scrollbars[3];
     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,6 +3499,11 @@ gui_init_which_components(char_u *oldval UNUSED)
            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,6 +3537,14 @@ gui_init_which_components(char_u *oldval UNUSED)
        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. */
index 4940b87e2e3b476a681ee85750636f17d2299d42..1bf836fce14365b89a56136250f56f35c16b8dc6 100644 (file)
@@ -3130,6 +3130,19 @@ update_window_manager_hints(int force_width, int force_height)
     }
 }
 
+#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
 
 /*
index bb68d5afcd469e93ebcf4d7a67cd9d0f222e3042..1d85843d5100ee029b8506089ab8296d80322161 100644 (file)
 #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
 #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'
+#define GO_ALL         "!aAbcdefFghilmMprtTvk" // all possible flags for 'go'
 
 // flags for 'comments' option
 #define COM_NEST       'n'             // comments strings nest
index 708e68dd5e4c9744b8e87b8130ffd6aa48edd0da..3f2604480281a8bbbba247bca7b3f0ad4f13fe0b 100644 (file)
@@ -8,6 +8,7 @@ void gui_mch_stop_blink(int may_call_gui_update_cursor);
 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);
index f2d82e4a6d006ddfe2f37367d1060d713f75d120..0f2a962304416b8973aa41e41bf87b17e4badc9b 100644 (file)
@@ -643,6 +643,15 @@ func Test_set_guioptions()
       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
index 9eb5db7232a29c220941c3bf88091a42aba5b1c8..69c77d81d1c49771fa3ccc10a66f9299886a0e4f 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2034,
 /**/
     2033,
 /**/