diff options
author | Benjamin Otte <otte@redhat.com> | 2016-02-17 02:43:18 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-02-17 04:36:18 +0100 |
commit | 37e3ccb2f67729ecdef6605455e6bf2b8b0279d7 (patch) | |
tree | dbcd6950a393cf775517b9d4b299f7fa90336afb | |
parent | 3e5be58991ce62e3c31f3a2a5bafc59abb3820a2 (diff) | |
download | gtk+-37e3ccb2f67729ecdef6605455e6bf2b8b0279d7.tar.gz |
win32: Split out fallback code into separate file
(1) Actual Windows users don't care about it
(2) It's easier to get rid of
-rw-r--r-- | gtk/Makefile.am | 2 | ||||
-rw-r--r-- | gtk/gtkwin32draw.c | 70 | ||||
-rw-r--r-- | gtk/gtkwin32drawprivate.h | 64 | ||||
-rw-r--r-- | gtk/gtkwin32theme.c | 46 |
4 files changed, 139 insertions, 43 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 566ec95e40..08062464db 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -564,6 +564,7 @@ gtk_private_h_sources = \ gtktreeprivate.h \ gtkwidgetprivate.h \ gtkwidgetpathprivate.h \ + gtkwin32drawprivate.h \ gtkwin32themeprivate.h \ gtkwindowprivate.h \ gtktreemenu.h \ @@ -926,6 +927,7 @@ gtk_base_c_sources = \ gtkwidgetpath.c \ gtkwindow.c \ gtkwindowgroup.c \ + gtkwin32draw.c \ gtkwin32theme.c \ gdkpixbufutils.c diff --git a/gtk/gtkwin32draw.c b/gtk/gtkwin32draw.c new file mode 100644 index 0000000000..d80d274b7f --- /dev/null +++ b/gtk/gtkwin32draw.c @@ -0,0 +1,70 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2016 Benjamin Otte <otte@gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include "gtkwin32drawprivate.h" + +struct { + const char *name; + GdkRGBA rgba; +} win32_default_colors[] = { +#define RGB(r, g, b) { (r)/255.0, (g)/255.0, (b)/255., 1.0 } + { "scrollbar", RGB(212, 208, 200) }, + { "background", RGB(58, 110, 165) }, + { "activecaption", RGB(10, 36, 106) }, + { "inactivecaption", RGB(128, 128, 128) }, + { "menu", RGB(212, 208, 200) }, + { "window", RGB(255, 255, 255) }, + { "windowframe", RGB(0, 0, 0) }, + { "menutext", RGB(0, 0, 0) }, + { "windowtext", RGB(0, 0, 0) }, + { "captiontext", RGB(255, 255, 255) }, + { "activeborder", RGB(212, 208, 200) }, + { "inactiveborder", RGB(212, 208, 200) }, + { "appworkspace", RGB(128, 128, 128) }, + { "highlight", RGB(10, 36, 106) }, + { "highlighttext", RGB(255, 255, 255) }, + { "btnface", RGB(212, 208, 200) }, + { "btnshadow", RGB(128, 128, 128) }, + { "graytext", RGB(128, 128, 128) }, + { "btntext", RGB(0, 0, 0) }, + { "inactivecaptiontext", RGB(212, 208, 200) }, + { "btnhighlight", RGB(255, 255, 255) }, + { "3ddkshadow", RGB(64, 64, 64) }, + { "3dlight", RGB(212, 208, 200) }, + { "infotext", RGB(0, 0, 0) }, + { "infobk", RGB(255, 255, 225) }, + { "alternatebtnface", RGB(181, 181, 181) }, + { "hotlight", RGB(0, 0, 200) }, + { "gradientactivecaption", RGB(166, 202, 240) }, + { "gradientinactivecaption", RGB(192, 192, 192) }, + { "menuhilight", RGB(10, 36, 106) }, + { "menubar", RGB(212, 208, 200) } +#undef RGB +}; + +void +gtk_win32_get_sys_color (gint id, + GdkRGBA *color) +{ + if (id < G_N_ELEMENTS (win32_default_colors)) + *color = win32_default_colors[id].rgba; + else + gdk_rgba_parse (color, "black"); +} + diff --git a/gtk/gtkwin32drawprivate.h b/gtk/gtkwin32drawprivate.h new file mode 100644 index 0000000000..fc57cb73d6 --- /dev/null +++ b/gtk/gtkwin32drawprivate.h @@ -0,0 +1,64 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2016 Benjamin Otte <otte@gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __GTK_WIN32_DRAW_H__ +#define __GTK_WIN32_DRAW_H__ + +#include <gdk/gdk.h> + +G_BEGIN_DECLS + +enum { + GTK_WIN32_SYS_COLOR_SCROLLBAR, + GTK_WIN32_SYS_COLOR_BACKGROUND, + GTK_WIN32_SYS_COLOR_ACTIVECAPTION, + GTK_WIN32_SYS_COLOR_INACTIVECAPTION, + GTK_WIN32_SYS_COLOR_MENU, + GTK_WIN32_SYS_COLOR_WINDOW, + GTK_WIN32_SYS_COLOR_WINDOWFRAME, + GTK_WIN32_SYS_COLOR_MENUTEXT, + GTK_WIN32_SYS_COLOR_WINDOWTEXT, + GTK_WIN32_SYS_COLOR_CAPTIONTEXT, + GTK_WIN32_SYS_COLOR_ACTIVEBORDER, + GTK_WIN32_SYS_COLOR_INACTIVEBORDER, + GTK_WIN32_SYS_COLOR_APPWORKSPACE, + GTK_WIN32_SYS_COLOR_HIGHLIGHT, + GTK_WIN32_SYS_COLOR_HIGHLIGHTTEXT, + GTK_WIN32_SYS_COLOR_BTNFACE, + GTK_WIN32_SYS_COLOR_BTNSHADOW, + GTK_WIN32_SYS_COLOR_GRAYTEXT, + GTK_WIN32_SYS_COLOR_BTNTEXT, + GTK_WIN32_SYS_COLOR_INACTIVECAPTIONTEXT, + GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT, + GTK_WIN32_SYS_COLOR_3DDKSHADOW, + GTK_WIN32_SYS_COLOR_3DLIGHT, + GTK_WIN32_SYS_COLOR_INFOTEXT, + GTK_WIN32_SYS_COLOR_INFOBK, + GTK_WIN32_SYS_COLOR_ALTERNATEBTNFACE, + GTK_WIN32_SYS_COLOR_HOTLIGHT, + GTK_WIN32_SYS_COLOR_GRADIENTACTIVECAPTION, + GTK_WIN32_SYS_COLOR_GRADIENTINACTIVECAPTION, + GTK_WIN32_SYS_COLOR_MENUHILIGHT, + GTK_WIN32_SYS_COLOR_MENUBAR +}; + +void gtk_win32_get_sys_color (gint id, + GdkRGBA *color); + +G_END_DECLS + +#endif /* __GTK_WIN32_DRAW_H__ */ diff --git a/gtk/gtkwin32theme.c b/gtk/gtkwin32theme.c index f933ac2dfc..8288f5d94d 100644 --- a/gtk/gtkwin32theme.c +++ b/gtk/gtkwin32theme.c @@ -23,6 +23,8 @@ #include "gtkwin32themeprivate.h" +#include "gtkwin32drawprivate.h" + #ifdef G_OS_WIN32 #include <windows.h> @@ -455,45 +457,6 @@ gtk_win32_theme_get_size (GtkWin32Theme *theme, #endif } -struct { - const char *name; - GdkRGBA rgba; -} win32_default_colors[] = { -#define RGB(r, g, b) { (r)/255.0, (g)/255.0, (b)/255., 1.0 } - { "scrollbar", RGB(212, 208, 200) }, - { "background", RGB(58, 110, 165) }, - { "activecaption", RGB(10, 36, 106) }, - { "inactivecaption", RGB(128, 128, 128) }, - { "menu", RGB(212, 208, 200) }, - { "window", RGB(255, 255, 255) }, - { "windowframe", RGB(0, 0, 0) }, - { "menutext", RGB(0, 0, 0) }, - { "windowtext", RGB(0, 0, 0) }, - { "captiontext", RGB(255, 255, 255) }, - { "activeborder", RGB(212, 208, 200) }, - { "inactiveborder", RGB(212, 208, 200) }, - { "appworkspace", RGB(128, 128, 128) }, - { "highlight", RGB(10, 36, 106) }, - { "highlighttext", RGB(255, 255, 255) }, - { "btnface", RGB(212, 208, 200) }, - { "btnshadow", RGB(128, 128, 128) }, - { "graytext", RGB(128, 128, 128) }, - { "btntext", RGB(0, 0, 0) }, - { "inactivecaptiontext", RGB(212, 208, 200) }, - { "btnhighlight", RGB(255, 255, 255) }, - { "3ddkshadow", RGB(64, 64, 64) }, - { "3dlight", RGB(212, 208, 200) }, - { "infotext", RGB(0, 0, 0) }, - { "infobk", RGB(255, 255, 225) }, - { "alternatebtnface", RGB(181, 181, 181) }, - { "hotlight", RGB(0, 0, 200) }, - { "gradientactivecaption", RGB(166, 202, 240) }, - { "gradientinactivecaption", RGB(192, 192, 192) }, - { "menuhilight", RGB(10, 36, 106) }, - { "menubar", RGB(212, 208, 200) } -#undef RGB -}; - void gtk_win32_theme_get_color (GtkWin32Theme *theme, gint id, @@ -518,10 +481,7 @@ gtk_win32_theme_get_color (GtkWin32Theme *theme, color->green = GetGValue (dcolor) / 255.0; color->blue = GetBValue (dcolor) / 255.0; #else - if (id < G_N_ELEMENTS (win32_default_colors)) - *color = win32_default_colors[id].rgba; - else - gdk_rgba_parse (color, "black"); + gtk_win32_get_sys_color (id, color); #endif } |