forked from AuroraMiddleware/gtk
Merge branch 'win32-theme2'
This commit is contained in:
commit
4bfa35417b
@ -465,6 +465,7 @@ gtk_private_h_sources = \
|
||||
gtktreedatalist.h \
|
||||
gtktreeprivate.h \
|
||||
gtkwidgetprivate.h \
|
||||
gtkwin32themeprivate.h \
|
||||
gtkwindowprivate.h \
|
||||
gtktreemenu.h \
|
||||
$(gtk_clipboard_dnd_h_sources) \
|
||||
@ -724,6 +725,7 @@ gtk_base_c_sources = \
|
||||
gtkwidget.c \
|
||||
gtkwidgetpath.c \
|
||||
gtkwindow.c \
|
||||
gtkwin32theme.c \
|
||||
$(gtk_clipboard_dnd_c_sources) \
|
||||
$(gtk_appchooser_impl_c_sources)
|
||||
|
||||
@ -829,7 +831,8 @@ gtk_built_public_sources = \
|
||||
# built headers that don't get installed
|
||||
gtk_built_private_headers = \
|
||||
gtkmarshalers.h \
|
||||
gtkbuiltincache.h
|
||||
gtkbuiltincache.h \
|
||||
gtkwin32css.h
|
||||
|
||||
gtk_built_sources = \
|
||||
gtktypebuiltins.c \
|
||||
@ -841,6 +844,7 @@ gtk_built_sources = \
|
||||
stamp_files = \
|
||||
stamp-gtkmarshalers.h \
|
||||
stamp-gtktypebuiltins.h \
|
||||
stamp-gtkwin32css.h \
|
||||
stamp-icons
|
||||
|
||||
# non-header sources (headers should be specified in the above variables)
|
||||
@ -852,6 +856,7 @@ gtk_extra_sources = \
|
||||
gen-paper-names.c \
|
||||
gtkstatusicon-quartz.c \
|
||||
gtk.symbols \
|
||||
gtk-win32.css \
|
||||
gtkversion.h.in \
|
||||
gtkmarshalers.list \
|
||||
fallback-c89.c
|
||||
@ -897,6 +902,14 @@ gtkmarshalers.c: @REBUILD@ gtkmarshalers.list
|
||||
&& cp xgen-gmlc gtkmarshalers.c \
|
||||
&& rm -f xgen-gmlc
|
||||
|
||||
gtkwin32css.h: stamp-gtkwin32css.h
|
||||
@true
|
||||
stamp-gtkwin32css.h: @REBUILD@ gtk-win32.css
|
||||
$(AWK) 'BEGIN { print "static const char *gtk_win32_default_css = " } { print " \"" $$0 "\\n\""} END { print ";" }' < $(srcdir)/gtk-win32.css >> xgen-gmlh\
|
||||
&& (cmp -s xgen-gmlh gtkwin32css.h || cp xgen-gmlh gtkwin32css.h) \
|
||||
&& rm -f xgen-gmlh \
|
||||
&& echo timestamp > $(@F)
|
||||
|
||||
gtktypebuiltins.h: stamp-gtktypebuiltins.h
|
||||
@true
|
||||
stamp-gtktypebuiltins.h: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtktypebuiltins.h.template
|
||||
|
608
gtk/gtk-win32.css
Normal file
608
gtk/gtk-win32.css
Normal file
@ -0,0 +1,608 @@
|
||||
@define-color bg_color -gtk-win32-color(button, 15);
|
||||
|
||||
/* Buttons */
|
||||
|
||||
.button {
|
||||
background-image: -gtk-win32-theme-part(button, 1 1);
|
||||
border-width: 0;
|
||||
-GtkWidget-focus-line-width: 1;
|
||||
-GtkWidget-focus-padding: 3;
|
||||
-GtkButton-interior-focuse: true;
|
||||
}
|
||||
|
||||
.button:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 1 4);
|
||||
}
|
||||
|
||||
.button:focused {
|
||||
background-image: -gtk-win32-theme-part(button, 1 5);
|
||||
}
|
||||
|
||||
.button:prelight, .button:prelight:focused {
|
||||
background-image: -gtk-win32-theme-part(button, 1 2);
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.button:active, .button:active:focused, .button:active:focused:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 1 3);
|
||||
}
|
||||
|
||||
/* Check buttons */
|
||||
|
||||
.check {
|
||||
background-image: -gtk-win32-theme-part(button, 3 1);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.check:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 3 4);
|
||||
}
|
||||
|
||||
.check:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 3 2);
|
||||
}
|
||||
|
||||
.check:active {
|
||||
background-image: -gtk-win32-theme-part(button, 3 5);
|
||||
}
|
||||
|
||||
.check:active:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 1 8);
|
||||
}
|
||||
|
||||
.check:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 3 6);
|
||||
}
|
||||
|
||||
.check:inconsistent {
|
||||
background-image: -gtk-win32-theme-part(button, 3 9);
|
||||
}
|
||||
|
||||
.check:inconsistent:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 3 12);
|
||||
}
|
||||
|
||||
.check:inconsistent:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 3 10);
|
||||
}
|
||||
|
||||
/* Radio buttons */
|
||||
|
||||
.radio {
|
||||
background-image: -gtk-win32-theme-part(button, 2 1);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.radio:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 2 4);
|
||||
}
|
||||
|
||||
.radio:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 2 2);
|
||||
}
|
||||
|
||||
.radio:active {
|
||||
background-image: -gtk-win32-theme-part(button, 2 5);
|
||||
}
|
||||
|
||||
.radio:active:insensitive {
|
||||
background-image: -gtk-win32-theme-part(button, 1 8);
|
||||
}
|
||||
|
||||
.radio:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 2 6);
|
||||
}
|
||||
|
||||
|
||||
.radio:inconsistent {
|
||||
background-image: -gtk-win32-theme-part(button, 2 1, mix 2 5);
|
||||
}
|
||||
|
||||
.radio:inconsistent:prelight {
|
||||
background-image: -gtk-win32-theme-part(button, 2 4 , mix 2 6);
|
||||
}
|
||||
|
||||
/* Scrollbars */
|
||||
|
||||
/* TODO: Win32 has different concept for upper and lower trough, we
|
||||
don't use this atm */
|
||||
|
||||
.scrollbar {
|
||||
-GtkRange-trough-border: 0;
|
||||
-GtkRange-arrow-scaling: 0.0;
|
||||
-GtkRange-slider-width: -gtk-win32-size(scrollbar, 3);
|
||||
}
|
||||
|
||||
.scrollbar.vertical {
|
||||
-GtkRange-slider-width: -gtk-win32-size(scrollbar, 2);
|
||||
}
|
||||
|
||||
.scrollbar.button.bottom {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 5);
|
||||
}
|
||||
|
||||
.scrollbar.button.bottom:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 6);
|
||||
}
|
||||
|
||||
.scrollbar.button.bottom:active,
|
||||
.scrollbar.button.bottom:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 7);
|
||||
}
|
||||
|
||||
.scrollbar.button.bottom:insensitive {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 8);
|
||||
}
|
||||
|
||||
.scrollbar.button.top {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 1);
|
||||
}
|
||||
|
||||
.scrollbar.button.top:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 2);
|
||||
}
|
||||
|
||||
.scrollbar.button.top:active,
|
||||
.scrollbar.button.top:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 3);
|
||||
}
|
||||
|
||||
.scrollbar.button.top:insensitive {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 4);
|
||||
}
|
||||
|
||||
.scrollbar.button.left {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 9);
|
||||
}
|
||||
|
||||
.scrollbar.button.left:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 10);
|
||||
}
|
||||
|
||||
.scrollbar.button.left:active,
|
||||
.scrollbar.button.left:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 11);
|
||||
}
|
||||
|
||||
.scrollbar.button.left:insensitive {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 12);
|
||||
}
|
||||
|
||||
.scrollbar.button.right {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 13);
|
||||
}
|
||||
|
||||
.scrollbar.button.right:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 14);
|
||||
}
|
||||
|
||||
.scrollbar.button.right:active,
|
||||
.scrollbar.button.right:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 15);
|
||||
}
|
||||
|
||||
.scrollbar.button.right:insensitive {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 1 16);
|
||||
}
|
||||
|
||||
.scrollbar.trough {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 4 1);
|
||||
}
|
||||
|
||||
.scrollbar.trough.vertical {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 6 1);
|
||||
}
|
||||
|
||||
.scrollbar.slider {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 2 1, 8 1);
|
||||
}
|
||||
|
||||
.scrollbar.slider:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 2 2, 8 2);
|
||||
}
|
||||
|
||||
.scrollbar.slider.vertical {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 3 1, 9 1);
|
||||
}
|
||||
|
||||
.scrollbar.slider.vertical:prelight {
|
||||
background-image: -gtk-win32-theme-part(scrollbar, 3 2, 9 2);
|
||||
}
|
||||
|
||||
/* Entry */
|
||||
|
||||
/* TODO: For entries with set_has_frame FALSE we should use 'edit, 3 1', not
|
||||
sure how to select for this though */
|
||||
.entry {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(edit, 1 1);
|
||||
}
|
||||
.entry:insensitive {
|
||||
background-image: -gtk-win32-theme-part(edit, 1 4);
|
||||
}
|
||||
.entry:prelight {
|
||||
background-image: -gtk-win32-theme-part(edit, 1 4);
|
||||
}
|
||||
|
||||
/* Spinbuttons */
|
||||
|
||||
.spinbutton.button,
|
||||
.spinbutton.button:focused {
|
||||
border-width: 1 1 0 0;
|
||||
border-style: none;
|
||||
background-image: -gtk-win32-theme-part(spin, 1 1);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button:prelight,
|
||||
.spinbutton.button:prelight:focused {
|
||||
background-image: -gtk-win32-theme-part(spin, 1 2);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button:active,
|
||||
.spinbutton.button:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(spin, 1 3);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button:insensitive {
|
||||
background-image: -gtk-win32-theme-part(spin, 1 4);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button.bottom,
|
||||
.spinbutton.button.bottom:focused {
|
||||
border-width: 0 1 1 0;
|
||||
background-image: -gtk-win32-theme-part(spin, 2 1);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button.bottom:prelight,
|
||||
.spinbutton.button.bottom:prelight:focused {
|
||||
background-image: -gtk-win32-theme-part(spin, 2 2);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button.bottom:active,
|
||||
.spinbutton.button.bottom:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(spin, 2 3);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.spinbutton.button.bottom:insensitive {
|
||||
background-image: -gtk-win32-theme-part(spin, 2 4);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Ranges */
|
||||
|
||||
/* TODO: The trough is not quite right, it covers everything,
|
||||
but in win32 the slider 'sticks out' on the sides of the
|
||||
trough */
|
||||
|
||||
.scale {
|
||||
-GtkScale-value-spacing: 0;
|
||||
-GtkScale-slider-length: 9;
|
||||
-GtkRange-slider-width: 20;
|
||||
-GtkRange-trough-border: 0;
|
||||
}
|
||||
|
||||
.scale.trough {
|
||||
border-style: none;
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(trackbar, 1 1);
|
||||
}
|
||||
|
||||
.scale.slider {
|
||||
border-width: 0;
|
||||
color: rgba(0,0,0,0);
|
||||
background-image: -gtk-win32-theme-part(trackbar, 3 1);
|
||||
}
|
||||
|
||||
.scale.slider:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 3 2);
|
||||
}
|
||||
|
||||
.scale.slider:active,
|
||||
.scale.slider:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 3 3);
|
||||
}
|
||||
|
||||
.scale.slider:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 3 4);
|
||||
}
|
||||
|
||||
.scale.slider:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 3 5);
|
||||
}
|
||||
|
||||
.scale.slider.vertical {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 6 1);
|
||||
}
|
||||
|
||||
.scale.slider.vertical:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 6 2);
|
||||
}
|
||||
|
||||
.scale.slider.vertical:active,
|
||||
.scale.slider.vertical:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 6 3);
|
||||
}
|
||||
|
||||
.scale.slider.vertical:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 6 4);
|
||||
}
|
||||
|
||||
.scale.slider.vertical:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 6 5);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 4 1);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 4 2);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below:active,
|
||||
.scale.slider.scale-has-marks-below:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 4 3);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 4 4);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 4 5);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below.vertical {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 8 1);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below.vertical:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 8 2);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below.vertical:active,
|
||||
.scale.slider.scale-has-marks-below.vertical:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 8 3);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below.vertical:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 8 4);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-below.vertical:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 8 5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.scale.slider.scale-has-marks-above {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 5 1);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 5 2);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above:active,
|
||||
.scale.slider.scale-has-marks-above:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 5 3);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 5 4);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 5 5);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above.vertical {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 7 1);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above.vertical:prelight {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 7 2);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above.vertical:active,
|
||||
.scale.slider.scale-has-marks-above.vertical:prelight:active {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 7 3);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above.vertical:focus {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 7 4);
|
||||
}
|
||||
|
||||
.scale.slider.scale-has-marks-above.vertical:insensitive {
|
||||
background-image: -gtk-win32-theme-part(trackbar, 7 5);
|
||||
}
|
||||
|
||||
/* Progress bars */
|
||||
|
||||
GtkProgressBar {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
GtkProgressBar.trough {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(progress, 1 1);
|
||||
}
|
||||
|
||||
GtkProgressBar.progressbar,
|
||||
GtkEntry.progressbar {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(progress, 5 1);
|
||||
}
|
||||
|
||||
GtkProgressBar.progressbar.pulse,
|
||||
GtkEntry.progressbar.pulse {
|
||||
background-image: -gtk-win32-theme-part(progress, 8 1);
|
||||
}
|
||||
|
||||
GtkProgressBar.trough.vertical {
|
||||
background-image: -gtk-win32-theme-part(progress, 2 1);
|
||||
}
|
||||
|
||||
.progressbar.vertical {
|
||||
background-image: -gtk-win32-theme-part(progress, 6 1);
|
||||
}
|
||||
|
||||
.progressbar.pulse.vertical {
|
||||
background-image: -gtk-win32-theme-part(progress, 10 1);
|
||||
}
|
||||
|
||||
/* Menus */
|
||||
|
||||
.menubar {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(menu, 7 1);
|
||||
}
|
||||
|
||||
.menubar .menuitem {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(menu, 8 1);
|
||||
}
|
||||
|
||||
.menubar .menuitem:prelight {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(menu, 8 3);
|
||||
}
|
||||
|
||||
.menuitem:prelight {
|
||||
background-image: -gtk-win32-theme-part(menu, 14 2);
|
||||
|
||||
}
|
||||
|
||||
.menuitem.radio,
|
||||
.menuitem.radio:prelight {
|
||||
background-image: none;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.radio:active,
|
||||
.menuitem.radio:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(menu, 11 3);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.radio:inconsistent,
|
||||
.menuitem.radio:inconsistent:prelight {
|
||||
background-image: -gtk-win32-theme-part(menu, 11 3, mix 0 0);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.radio:insensitive,
|
||||
.menuitem.radio:insensitive:prelight{
|
||||
background-image: -gtk-win32-theme-part(menu, 11 4);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
|
||||
.menuitem.check,
|
||||
.menuitem.check:prelight {
|
||||
background-image: none;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.check:active,
|
||||
.menuitem.check:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(menu, 11 1);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.check:inconsistent,
|
||||
.menuitem.check:inconsistent:prelight {
|
||||
background-image: -gtk-win32-theme-part(menu, 11 1, mix 0 0);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.menuitem.check:insensitive,
|
||||
.menuitem.check:insensitive:prelight{
|
||||
background-image: -gtk-win32-theme-part(menu, 11 2);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
/* Combobox */
|
||||
|
||||
|
||||
GtkComboBox.combobox-entry .button {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(combobox, 1 1);
|
||||
color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
GtkComboBox.combobox-entry .button:prelight,
|
||||
GtkComboBox.combobox-entry .button:focused,
|
||||
GtkComboBox.combobox-entry .button:prelight:focused {
|
||||
background-image: -gtk-win32-theme-part(combobox, 1 2);
|
||||
}
|
||||
GtkComboBox.combobox-entry .button:active,
|
||||
GtkComboBox.combobox-entry .button:active:focused,
|
||||
GtkComboBox.combobox-entry .button:active:prelight,
|
||||
GtkComboBox.combobox-entry .button:active:focused:prelight {
|
||||
background-image: -gtk-win32-theme-part(combobox, 1 3);
|
||||
}
|
||||
GtkComboBox.combobox-entry .button:insensitive {
|
||||
background-image: -gtk-win32-theme-part(combobox, 1 4);
|
||||
}
|
||||
|
||||
/* Notebook */
|
||||
|
||||
.notebook {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(tab, 9 1);
|
||||
-GtkNotebook-tab-overlap: 0;
|
||||
-GtkNotebook-tab-curvature: 20;
|
||||
}
|
||||
|
||||
.notebook tab {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(tab, 1 1);
|
||||
}
|
||||
|
||||
.notebook tab:active {
|
||||
background-image: -gtk-win32-theme-part(tab, 1 3);
|
||||
}
|
||||
|
||||
.notebook {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Toolbar */
|
||||
|
||||
.toolbar {
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(rebar, 6 1);
|
||||
}
|
||||
|
||||
.toolbar .button,
|
||||
.toolbar .button:focused {
|
||||
background-image: -gtk-win32-theme-part(toolbar, 1 1);
|
||||
}
|
||||
|
||||
.toolbar .button:prelight,
|
||||
.toolbar .button:prelight:focused {
|
||||
background-image: -gtk-win32-theme-part(toolbar, 1 2);
|
||||
}
|
||||
|
||||
.toolbar .button:active {
|
||||
background-image: -gtk-win32-theme-part(toolbar, 1 3);
|
||||
}
|
||||
|
||||
.toolbar .button:active:prelight {
|
||||
background-image: -gtk-win32-theme-part(toolbar, 1 6);
|
||||
}
|
||||
|
||||
.toolbar .button:insensitive {
|
||||
background-image: -gtk-win32-theme-part(toolbar, 1 4);
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkborderimageprivate.h"
|
||||
#include "gtkstylepropertiesprivate.h"
|
||||
|
||||
/* this is in case round() is not provided by the compiler,
|
||||
* such as in the case of C89 compilers, like MSVC
|
||||
@ -54,7 +55,8 @@ enum {
|
||||
|
||||
struct _GtkBorderImage {
|
||||
cairo_pattern_t *source;
|
||||
GtkGradient *source_gradient;
|
||||
gpointer source_boxed;
|
||||
GType boxed_type;
|
||||
|
||||
GtkBorder slice;
|
||||
GtkBorder *width;
|
||||
@ -90,18 +92,21 @@ _gtk_border_image_new (cairo_pattern_t *pattern,
|
||||
}
|
||||
|
||||
GtkBorderImage *
|
||||
_gtk_border_image_new_for_gradient (GtkGradient *gradient,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat)
|
||||
_gtk_border_image_new_for_boxed (GType boxed_type,
|
||||
gpointer boxed,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat)
|
||||
{
|
||||
GtkBorderImage *image;
|
||||
|
||||
image = g_slice_new0 (GtkBorderImage);
|
||||
|
||||
image->ref_count = 1;
|
||||
|
||||
if (gradient != NULL)
|
||||
image->source_gradient = gtk_gradient_ref (gradient);
|
||||
if (boxed != NULL)
|
||||
image->source_boxed = g_boxed_copy (boxed_type, boxed);
|
||||
image->boxed_type = boxed_type;
|
||||
|
||||
if (slice != NULL)
|
||||
image->slice = *slice;
|
||||
@ -137,8 +142,8 @@ _gtk_border_image_unref (GtkBorderImage *image)
|
||||
if (image->source != NULL)
|
||||
cairo_pattern_destroy (image->source);
|
||||
|
||||
if (image->source_gradient != NULL)
|
||||
gtk_gradient_unref (image->source_gradient);
|
||||
if (image->source_boxed != NULL)
|
||||
g_boxed_free (image->boxed_type, image->source_boxed);
|
||||
|
||||
if (image->width != NULL)
|
||||
gtk_border_free (image->width);
|
||||
@ -157,8 +162,8 @@ _gtk_border_image_unpack (const GValue *value,
|
||||
parameter[0].name = "border-image-source";
|
||||
|
||||
if ((image != NULL) &&
|
||||
(image->source_gradient != NULL))
|
||||
g_value_init (¶meter[0].value, GTK_TYPE_GRADIENT);
|
||||
(image->source_boxed != NULL))
|
||||
g_value_init (¶meter[0].value, image->boxed_type);
|
||||
else
|
||||
g_value_init (¶meter[0].value, CAIRO_GOBJECT_TYPE_PATTERN);
|
||||
|
||||
@ -173,8 +178,8 @@ _gtk_border_image_unpack (const GValue *value,
|
||||
|
||||
if (image != NULL)
|
||||
{
|
||||
if (image->source_gradient != NULL)
|
||||
g_value_set_boxed (¶meter[0].value, image->source_gradient);
|
||||
if (image->source_boxed != NULL)
|
||||
g_value_set_boxed (¶meter[0].value, image->source_boxed);
|
||||
else
|
||||
g_value_set_boxed (¶meter[0].value, image->source);
|
||||
|
||||
@ -190,19 +195,20 @@ _gtk_border_image_unpack (const GValue *value,
|
||||
void
|
||||
_gtk_border_image_pack (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
GtkBorderImage *image;
|
||||
cairo_pattern_t *source;
|
||||
GtkBorder *slice, *width;
|
||||
GtkCssBorderImageRepeat *repeat;
|
||||
|
||||
gtk_style_properties_get (props, state,
|
||||
"border-image-source", &source,
|
||||
"border-image-slice", &slice,
|
||||
"border-image-repeat", &repeat,
|
||||
"border-image-width", &width,
|
||||
NULL);
|
||||
_gtk_style_properties_get (props, state, context,
|
||||
"border-image-source", &source,
|
||||
"border-image-slice", &slice,
|
||||
"border-image-repeat", &repeat,
|
||||
"border-image-width", &width,
|
||||
NULL);
|
||||
|
||||
if (source == NULL)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gtkstyleproperties.h"
|
||||
#include "gtkthemingengine.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -42,7 +43,8 @@ GtkBorderImage * _gtk_border_image_new (cairo_pattern_t *sour
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat);
|
||||
GtkBorderImage * _gtk_border_image_new_for_gradient (GtkGradient *gradient,
|
||||
GtkBorderImage * _gtk_border_image_new_for_boxed (GType boxed_type,
|
||||
gpointer boxed,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat);
|
||||
@ -62,7 +64,8 @@ GParameter * _gtk_border_image_unpack (const GValue *valu
|
||||
guint *n_params);
|
||||
void _gtk_border_image_pack (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state);
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
@ -575,7 +576,8 @@ typedef enum {
|
||||
COLOR_DARKER,
|
||||
COLOR_SHADE,
|
||||
COLOR_ALPHA,
|
||||
COLOR_MIX
|
||||
COLOR_MIX,
|
||||
COLOR_WIN32
|
||||
} ColorType;
|
||||
|
||||
static GtkSymbolicColor *
|
||||
@ -644,6 +646,12 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
|
||||
|
||||
symbolic = gtk_symbolic_color_new_literal (&rgba);
|
||||
}
|
||||
else if (color == COLOR_WIN32)
|
||||
{
|
||||
symbolic = _gtk_win32_theme_color_parse (parser);
|
||||
if (symbolic == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
child1 = _gtk_css_parser_read_symbolic_color (parser);
|
||||
@ -769,7 +777,8 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
|
||||
{
|
||||
GtkSymbolicColor *symbolic;
|
||||
guint color;
|
||||
const char *names[] = {"rgba", "rgb", "lighter", "darker", "shade", "alpha", "mix" };
|
||||
const char *names[] = {"rgba", "rgb", "lighter", "darker", "shade", "alpha", "mix",
|
||||
GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME};
|
||||
char *name;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), NULL);
|
||||
|
@ -3083,6 +3083,8 @@ _gtk_css_provider_get_theme_dir (void)
|
||||
return path;
|
||||
}
|
||||
|
||||
#include "gtkwin32css.h"
|
||||
|
||||
/**
|
||||
* gtk_css_provider_get_named:
|
||||
* @name: A theme name
|
||||
@ -3103,7 +3105,18 @@ gtk_css_provider_get_named (const gchar *name,
|
||||
gchar *key;
|
||||
|
||||
if (G_UNLIKELY (!themes))
|
||||
themes = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
{
|
||||
themes = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
if (!gtk_css_provider_load_from_data (provider, gtk_win32_default_css, -1, NULL))
|
||||
{
|
||||
g_warning ("Failed to load the internal win32 default CSS.");
|
||||
g_object_unref (provider);
|
||||
}
|
||||
else
|
||||
g_hash_table_insert (themes, "gtk-win32", provider);
|
||||
}
|
||||
|
||||
if (variant == NULL)
|
||||
key = (gchar *)name;
|
||||
|
@ -3522,6 +3522,8 @@ gtk_entry_draw_progress (GtkWidget *widget,
|
||||
GtkStyleContext *context,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (widget);
|
||||
GtkEntryPrivate *private = entry->priv;
|
||||
gint x, y, width, height;
|
||||
|
||||
get_progress_area (widget, &x, &y, &width, &height);
|
||||
@ -3531,6 +3533,8 @@ gtk_entry_draw_progress (GtkWidget *widget,
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
|
||||
if (private->progress_pulse_mode)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
|
||||
|
||||
gtk_render_activity (context, cr,
|
||||
x, y, width, height);
|
||||
|
@ -760,6 +760,7 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
|
||||
|
||||
gtk_render_activity (context, cr, area.x, area.y, area.width, area.height);
|
||||
|
||||
|
@ -1922,6 +1922,23 @@ draw_stepper (GtkRange *range,
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
|
||||
gtk_style_context_set_state (context, state);
|
||||
|
||||
switch (arrow_type)
|
||||
{
|
||||
case GTK_ARROW_RIGHT:
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
|
||||
break;
|
||||
case GTK_ARROW_DOWN:
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
break;
|
||||
case GTK_ARROW_LEFT:
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
|
||||
break;
|
||||
case GTK_ARROW_UP:
|
||||
default:
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_render_background (context, cr,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
|
@ -401,7 +401,11 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
g_param_spec_string ("gtk-theme-name",
|
||||
P_("Theme Name"),
|
||||
P_("Name of theme to load"),
|
||||
#ifdef G_OS_WIN32
|
||||
"gtk-win32",
|
||||
#else
|
||||
"Raleigh",
|
||||
#endif
|
||||
GTK_PARAM_READWRITE),
|
||||
NULL);
|
||||
g_assert (result == PROP_THEME_NAME);
|
||||
|
@ -998,6 +998,10 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
|
||||
if (arrow_type == GTK_ARROW_UP)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
|
||||
else
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
|
||||
priv = spin_button->priv;
|
||||
widget = GTK_WIDGET (spin_button);
|
||||
|
@ -1367,6 +1367,24 @@ gtk_style_context_get_property (GtkStyleContext *context,
|
||||
gtk_style_properties_get_property (data->store, property, state, value);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_get_valist (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *property_context,
|
||||
va_list args)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
StyleData *data;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
priv = context->priv;
|
||||
g_return_if_fail (priv->widget_path != NULL);
|
||||
|
||||
data = style_data_lookup (context);
|
||||
_gtk_style_properties_get_valist (data->store, state, property_context, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_get_valist:
|
||||
* @context: a #GtkStyleContext
|
||||
|
@ -669,6 +669,15 @@ struct _GtkStyleContextClass
|
||||
*/
|
||||
#define GTK_STYLE_REGION_TAB "tab"
|
||||
|
||||
/**
|
||||
* GTK_STYLE_CLASS_PULSE:
|
||||
*
|
||||
* A CSS class to use when rendering a pulse in an indeterminate progress bar.
|
||||
*
|
||||
* This is used by #GtkProgressBar and #GtkEntry.
|
||||
*/
|
||||
#define GTK_STYLE_CLASS_PULSE "pulse"
|
||||
|
||||
|
||||
GType gtk_style_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
@ -24,7 +24,17 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkStylePropertyContext GtkStylePropertyContext;
|
||||
struct _GtkStylePropertyContext
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
void _gtk_style_context_get_valist (GtkStyleContext *context,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *property_context,
|
||||
va_list args);
|
||||
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
|
||||
GType widget_type,
|
||||
GtkStateFlags state,
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkstyleproperties
|
||||
* @Short_description: Store for style property information
|
||||
@ -465,9 +467,10 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
|
||||
}
|
||||
else if (style_prop->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
|
||||
{
|
||||
/* Allow GtkGradient as a substitute */
|
||||
/* Allow GtkGradient and theme part as a substitute */
|
||||
g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
|
||||
value_type == GTK_TYPE_GRADIENT);
|
||||
value_type == GTK_TYPE_GRADIENT ||
|
||||
value_type == GTK_TYPE_WIN32_THEME_PART);
|
||||
}
|
||||
else if (style_prop->pspec->value_type == G_TYPE_INT)
|
||||
{
|
||||
@ -635,44 +638,50 @@ gtk_style_properties_set (GtkStyleProperties *props,
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/* NB: Will return NULL for shorthands */
|
||||
const GValue *
|
||||
_gtk_style_properties_peek_property (GtkStyleProperties *props,
|
||||
const gchar *prop_name,
|
||||
GtkStateFlags state,
|
||||
const GtkStyleProperty **property)
|
||||
gboolean
|
||||
_gtk_style_properties_get_property (GtkStyleProperties *props,
|
||||
const gchar *property,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *value)
|
||||
{
|
||||
GtkStylePropertiesPrivate *priv;
|
||||
const GtkStyleProperty *node;
|
||||
PropertyData *prop;
|
||||
GValue *val;
|
||||
GValue *val = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL);
|
||||
g_return_val_if_fail (prop_name != NULL, NULL);
|
||||
|
||||
node = _gtk_style_property_lookup (prop_name);
|
||||
if (property)
|
||||
*property = node;
|
||||
g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
|
||||
g_return_val_if_fail (property != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
node = _gtk_style_property_lookup (property);
|
||||
if (!node)
|
||||
{
|
||||
g_warning ("Style property \"%s\" is not registered", prop_name);
|
||||
return NULL;
|
||||
g_warning ("Style property \"%s\" is not registered", property);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv = props->priv;
|
||||
prop = g_hash_table_lookup (priv->properties, node);
|
||||
|
||||
if (!prop)
|
||||
return NULL;
|
||||
val = NULL;
|
||||
|
||||
val = property_data_match_state (prop, state);
|
||||
if (val == NULL)
|
||||
return NULL;
|
||||
|
||||
_gtk_style_property_resolve (node, props, state, val);
|
||||
if (prop)
|
||||
{
|
||||
/* NB: Will return NULL for shorthands */
|
||||
val = property_data_match_state (prop, state);
|
||||
}
|
||||
|
||||
return val;
|
||||
g_value_init (value, node->pspec->value_type);
|
||||
|
||||
if (val)
|
||||
_gtk_style_property_resolve (node, props, state, context, val, value);
|
||||
else if (_gtk_style_property_is_shorthand (node))
|
||||
_gtk_style_property_pack (node, props, state, context, value);
|
||||
else
|
||||
_gtk_style_property_default_value (node, props, state, value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -695,28 +704,53 @@ gtk_style_properties_get_property (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GValue *value)
|
||||
{
|
||||
const GtkStyleProperty *node;
|
||||
const GValue *val;
|
||||
GtkStylePropertyContext context = { 100, 100};
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
|
||||
g_return_val_if_fail (property != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
val = _gtk_style_properties_peek_property (props, property, state, &node);
|
||||
return _gtk_style_properties_get_property (props,
|
||||
property,
|
||||
state, &context, value);
|
||||
}
|
||||
|
||||
if (!node)
|
||||
return FALSE;
|
||||
void
|
||||
_gtk_style_properties_get_valist (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
va_list args)
|
||||
{
|
||||
const gchar *property_name;
|
||||
|
||||
g_value_init (value, node->pspec->value_type);
|
||||
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
|
||||
|
||||
if (val)
|
||||
g_value_copy (val, value);
|
||||
else if (_gtk_style_property_is_shorthand (node))
|
||||
_gtk_style_property_pack (node, props, state, value);
|
||||
else
|
||||
_gtk_style_property_default_value (node, props, state, value);
|
||||
property_name = va_arg (args, const gchar *);
|
||||
|
||||
return TRUE;
|
||||
while (property_name)
|
||||
{
|
||||
gchar *error = NULL;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
if (!_gtk_style_properties_get_property (props,
|
||||
property_name,
|
||||
state,
|
||||
context,
|
||||
&value))
|
||||
break;
|
||||
|
||||
G_VALUE_LCOPY (&value, args, 0, &error);
|
||||
g_value_unset (&value);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Could not get style property \"%s\": %s", property_name, error);
|
||||
g_free (error);
|
||||
break;
|
||||
}
|
||||
|
||||
property_name = va_arg (args, const gchar *);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -734,54 +768,24 @@ gtk_style_properties_get_valist (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
va_list args)
|
||||
{
|
||||
const gchar *property_name;
|
||||
GtkStylePropertyContext context = { 100, 100};
|
||||
|
||||
return _gtk_style_properties_get_valist (props, state, &context, args);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_properties_get (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
|
||||
|
||||
property_name = va_arg (args, const gchar *);
|
||||
|
||||
while (property_name)
|
||||
{
|
||||
const GtkStyleProperty *node;
|
||||
gchar *error = NULL;
|
||||
const GValue *val;
|
||||
|
||||
val = _gtk_style_properties_peek_property (props, property_name, state, &node);
|
||||
if (!node)
|
||||
break;
|
||||
|
||||
if (val)
|
||||
{
|
||||
G_VALUE_LCOPY (val, args, 0, &error);
|
||||
}
|
||||
else if (_gtk_style_property_is_shorthand (node))
|
||||
{
|
||||
GValue packed = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&packed, node->pspec->value_type);
|
||||
_gtk_style_property_pack (node, props, state, &packed);
|
||||
G_VALUE_LCOPY (&packed, args, 0, &error);
|
||||
g_value_unset (&packed);
|
||||
}
|
||||
else
|
||||
{
|
||||
GValue default_value = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&default_value, node->pspec->value_type);
|
||||
_gtk_style_property_default_value (node, props, state, &default_value);
|
||||
G_VALUE_LCOPY (&default_value, args, 0, &error);
|
||||
g_value_unset (&default_value);
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Could not get style property \"%s\": %s", property_name, error);
|
||||
g_free (error);
|
||||
break;
|
||||
}
|
||||
|
||||
property_name = va_arg (args, const gchar *);
|
||||
}
|
||||
va_start (args, context);
|
||||
_gtk_style_properties_get_valist (props, state, context, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,13 +22,25 @@
|
||||
|
||||
#include "gtkstyleproperties.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props,
|
||||
const gchar *prop_name,
|
||||
GtkStateFlags state,
|
||||
const GtkStyleProperty **property);
|
||||
void _gtk_style_properties_get (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
...);
|
||||
void _gtk_style_properties_get_valist (GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
va_list args);
|
||||
|
||||
const GValue * _gtk_style_properties_resolve_property (GtkStyleProperties *props,
|
||||
const gchar *prop_name,
|
||||
GtkStateFlags state,
|
||||
const GtkStyleProperty **property,
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *value);
|
||||
|
||||
void _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
|
||||
const GtkStyleProperty *property,
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "gtkshadowprivate.h"
|
||||
#include "gtkthemingengine.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
/* this is in case round() is not provided by the compiler,
|
||||
* such as in the case of C89 compilers, like MSVC
|
||||
@ -384,6 +385,17 @@ int_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (_gtk_css_parser_begins_with (parser, '-'))
|
||||
{
|
||||
int res = _gtk_win32_theme_int_parse (parser, base, &i);
|
||||
if (res >= 0)
|
||||
{
|
||||
g_value_set_int (value, i);
|
||||
return res > 0;
|
||||
}
|
||||
/* < 0 => continue */
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &i))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
@ -588,11 +600,26 @@ border_value_parse (GtkCssParser *parser,
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (numbers); i++)
|
||||
{
|
||||
if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
|
||||
break;
|
||||
if (_gtk_css_parser_begins_with (parser, '-'))
|
||||
{
|
||||
/* These are strictly speaking signed, but we want to be able to use them
|
||||
for unsigned types too, as the actual ranges of values make this safe */
|
||||
int res = _gtk_win32_theme_int_parse (parser, base, (int *)&numbers[i]);
|
||||
|
||||
/* XXX: shouldn't allow spaces here? */
|
||||
_gtk_css_parser_try (parser, "px", TRUE);
|
||||
if (res == 0) /* Parse error, report */
|
||||
return FALSE;
|
||||
|
||||
if (res < 0) /* Nothing known to expand */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
|
||||
break;
|
||||
|
||||
/* XXX: shouldn't allow spaces here? */
|
||||
_gtk_css_parser_try (parser, "px", TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
@ -908,6 +935,11 @@ pattern_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
if (_gtk_css_parser_begins_with (parser, '-'))
|
||||
{
|
||||
int res;
|
||||
res = _gtk_win32_theme_part_parse (parser, base, value);
|
||||
if (res >= 0)
|
||||
return res > 0;
|
||||
/* < 0 => continue */
|
||||
g_value_unset (value);
|
||||
g_value_init (value, GTK_TYPE_GRADIENT);
|
||||
return gradient_value_parse (parser, base, value);
|
||||
@ -1250,7 +1282,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
GValue temp = G_VALUE_INIT;
|
||||
cairo_pattern_t *pattern = NULL;
|
||||
GtkGradient *gradient = NULL;
|
||||
gconstpointer *boxed = NULL;
|
||||
GType boxed_type;
|
||||
GtkBorder slice, *width = NULL, *parsed_slice;
|
||||
GtkCssBorderImageRepeat repeat, *parsed_repeat;
|
||||
gboolean retval = FALSE;
|
||||
@ -1261,8 +1294,9 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
if (!pattern_value_parse (parser, base, &temp))
|
||||
return FALSE;
|
||||
|
||||
if (G_VALUE_TYPE (&temp) == GTK_TYPE_GRADIENT)
|
||||
gradient = g_value_dup_boxed (&temp);
|
||||
boxed_type = G_VALUE_TYPE (&temp);
|
||||
if (boxed_type != CAIRO_GOBJECT_TYPE_PATTERN)
|
||||
boxed = g_value_dup_boxed (&temp);
|
||||
else
|
||||
pattern = g_value_dup_boxed (&temp);
|
||||
|
||||
@ -1297,8 +1331,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
|
||||
g_value_unset (&temp);
|
||||
|
||||
if (gradient != NULL)
|
||||
image = _gtk_border_image_new_for_gradient (gradient, &slice, width, &repeat);
|
||||
if (boxed != NULL)
|
||||
image = _gtk_border_image_new_for_boxed (boxed_type, boxed, &slice, width, &repeat);
|
||||
else if (pattern != NULL)
|
||||
image = _gtk_border_image_new (pattern, &slice, width, &repeat);
|
||||
|
||||
@ -1312,8 +1346,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
if (pattern != NULL)
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
if (gradient != NULL)
|
||||
gtk_gradient_unref (gradient);
|
||||
if (boxed != NULL)
|
||||
g_boxed_free (boxed_type, boxed);
|
||||
|
||||
if (width != NULL)
|
||||
gtk_border_free (width);
|
||||
@ -1853,7 +1887,8 @@ unpack_border_width (const GValue *value,
|
||||
static void
|
||||
pack_border_width (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
pack_border (value, props, state,
|
||||
"border-top-width", "border-left-width",
|
||||
@ -1872,7 +1907,8 @@ unpack_padding (const GValue *value,
|
||||
static void
|
||||
pack_padding (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
pack_border (value, props, state,
|
||||
"padding-top", "padding-left",
|
||||
@ -1891,7 +1927,8 @@ unpack_margin (const GValue *value,
|
||||
static void
|
||||
pack_margin (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
pack_border (value, props, state,
|
||||
"margin-top", "margin-left",
|
||||
@ -1933,7 +1970,8 @@ unpack_border_radius (const GValue *value,
|
||||
static void
|
||||
pack_border_radius (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
GtkCssBorderCornerRadius *top_left;
|
||||
|
||||
@ -2033,7 +2071,8 @@ unpack_font_description (const GValue *value,
|
||||
static void
|
||||
pack_font_description (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
PangoFontDescription *description;
|
||||
char **families;
|
||||
@ -2111,7 +2150,8 @@ unpack_border_color (const GValue *value,
|
||||
static void
|
||||
pack_border_color (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state)
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
/* NB: We are a color property, so we have to resolve to a color here.
|
||||
* So we just resolve to a color. We pick one and stick to it.
|
||||
@ -2466,6 +2506,27 @@ resolve_color_rgb (GtkStyleProperties *props,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
resolve_win32_theme_part (GtkStyleProperties *props,
|
||||
GValue *value,
|
||||
GValue *value_out,
|
||||
GtkStylePropertyContext *context)
|
||||
{
|
||||
GtkWin32ThemePart *part;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
part = g_value_get_boxed (value);
|
||||
if (part == NULL)
|
||||
return FALSE;
|
||||
|
||||
pattern = _gtk_win32_theme_part_render (part, context->width, context->height);
|
||||
|
||||
g_value_take_boxed (value_out, pattern);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
resolve_gradient (GtkStyleProperties *props,
|
||||
GValue *value)
|
||||
@ -2510,19 +2571,21 @@ void
|
||||
_gtk_style_property_resolve (const GtkStyleProperty *property,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GValue *val)
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *val,
|
||||
GValue *val_out)
|
||||
{
|
||||
if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR)
|
||||
{
|
||||
if (property->pspec->value_type == GDK_TYPE_RGBA)
|
||||
{
|
||||
if (resolve_color (props, val))
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
else if (property->pspec->value_type == GDK_TYPE_COLOR)
|
||||
{
|
||||
if (resolve_color_rgb (props, val))
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_value_unset (val);
|
||||
@ -2550,6 +2613,15 @@ _gtk_style_property_resolve (const GtkStyleProperty *property,
|
||||
if (!resolve_shadow (props, val))
|
||||
_gtk_style_property_default_value (property, props, state, val);
|
||||
}
|
||||
else if (G_VALUE_TYPE (val) == GTK_TYPE_WIN32_THEME_PART)
|
||||
{
|
||||
if (resolve_win32_theme_part (props, val, val_out, context))
|
||||
return; /* Don't copy val, this sets val_out */
|
||||
_gtk_style_property_default_value (property, props, state, val);
|
||||
}
|
||||
|
||||
out:
|
||||
g_value_copy (val, val_out);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -2577,6 +2649,7 @@ void
|
||||
_gtk_style_property_pack (const GtkStyleProperty *property,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *value)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
@ -2584,7 +2657,7 @@ _gtk_style_property_pack (const GtkStyleProperty *property,
|
||||
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
|
||||
g_return_if_fail (G_IS_VALUE (value));
|
||||
|
||||
property->pack_func (value, props, state);
|
||||
property->pack_func (value, props, state, context);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define __GTK_STYLEPROPERTY_PRIVATE_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -33,7 +34,8 @@ typedef GParameter * (* GtkStyleUnpackFunc) (const GValue
|
||||
guint *n_params);
|
||||
typedef void (* GtkStylePackFunc) (GValue *value,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state);
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context);
|
||||
typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
GValue *value);
|
||||
@ -82,7 +84,9 @@ void _gtk_style_property_default_value (const GtkStyleProper
|
||||
void _gtk_style_property_resolve (const GtkStyleProperty *property,
|
||||
GtkStyleProperties *properties,
|
||||
GtkStateFlags state,
|
||||
GValue *value);
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *orig_value,
|
||||
GValue *out_value);
|
||||
|
||||
gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property);
|
||||
GParameter * _gtk_style_property_unpack (const GtkStyleProperty *property,
|
||||
@ -91,6 +95,7 @@ GParameter * _gtk_style_property_unpack (const GtkStyleProper
|
||||
void _gtk_style_property_pack (const GtkStyleProperty *property,
|
||||
GtkStyleProperties *props,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *context,
|
||||
GValue *value);
|
||||
|
||||
gboolean _gtk_style_property_parse_value (const GtkStyleProperty *property,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtkstyleproperties.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtksymboliccolor
|
||||
@ -50,7 +51,8 @@ typedef enum {
|
||||
COLOR_TYPE_NAME,
|
||||
COLOR_TYPE_SHADE,
|
||||
COLOR_TYPE_ALPHA,
|
||||
COLOR_TYPE_MIX
|
||||
COLOR_TYPE_MIX,
|
||||
COLOR_TYPE_WIN32
|
||||
} ColorType;
|
||||
|
||||
struct _GtkSymbolicColor
|
||||
@ -75,6 +77,12 @@ struct _GtkSymbolicColor
|
||||
GtkSymbolicColor *color2;
|
||||
gdouble factor;
|
||||
} mix;
|
||||
|
||||
struct
|
||||
{
|
||||
gchar *theme_class;
|
||||
gint id;
|
||||
} win32;
|
||||
};
|
||||
};
|
||||
|
||||
@ -226,6 +234,35 @@ gtk_symbolic_color_new_mix (GtkSymbolicColor *color1,
|
||||
return symbolic_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_symbolic_color_new_mix: (constructor)
|
||||
* @theme_class: The theme class to pull color from
|
||||
* @id: The color id
|
||||
*
|
||||
* Creates a symbolic color based on the current win32
|
||||
* theme.
|
||||
*
|
||||
* Returns: A newly created #GtkSymbolicColor
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
GtkSymbolicColor *
|
||||
gtk_symbolic_color_new_win32 (const gchar *theme_class,
|
||||
gint id)
|
||||
{
|
||||
GtkSymbolicColor *symbolic_color;
|
||||
|
||||
g_return_val_if_fail (theme_class != NULL, NULL);
|
||||
|
||||
symbolic_color = g_slice_new0 (GtkSymbolicColor);
|
||||
symbolic_color->type = COLOR_TYPE_WIN32;
|
||||
symbolic_color->win32.theme_class = g_strdup (theme_class);
|
||||
symbolic_color->win32.id = id;
|
||||
symbolic_color->ref_count = 1;
|
||||
|
||||
return symbolic_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_symbolic_color_ref:
|
||||
* @color: a #GtkSymbolicColor
|
||||
@ -279,6 +316,9 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color)
|
||||
gtk_symbolic_color_unref (color->mix.color1);
|
||||
gtk_symbolic_color_unref (color->mix.color2);
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
g_free (color->win32.theme_class);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -556,6 +596,12 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
return _gtk_win32_theme_color_resolve (color->win32.theme_class,
|
||||
color->win32.id,
|
||||
resolved_color);
|
||||
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@ -623,6 +669,12 @@ gtk_symbolic_color_to_string (GtkSymbolicColor *color)
|
||||
g_free (color_string2);
|
||||
}
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
{
|
||||
s = g_strdup_printf (GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME"(%s, %d)",
|
||||
color->win32.theme_class, color->win32.id);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color,
|
||||
GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1,
|
||||
GtkSymbolicColor *color2,
|
||||
gdouble factor);
|
||||
GtkSymbolicColor * gtk_symbolic_color_new_win32 (const gchar *theme_class,
|
||||
gint id);
|
||||
|
||||
GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color);
|
||||
void gtk_symbolic_color_unref (GtkSymbolicColor *color);
|
||||
|
@ -183,6 +183,14 @@ static void gtk_theming_engine_render_icon (GtkThemingEngine *engine,
|
||||
GdkPixbuf *pixbuf,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static void render_background_internal (GtkThemingEngine *engine,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction,
|
||||
cairo_pattern_t *optional_background);
|
||||
|
||||
G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
|
||||
|
||||
@ -450,6 +458,25 @@ gtk_theming_engine_get_valist (GtkThemingEngine *engine,
|
||||
gtk_style_context_get_valist (priv->context, state, args);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_theming_engine_get (GtkThemingEngine *engine,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *property_context,
|
||||
...)
|
||||
{
|
||||
GtkThemingEnginePrivate *priv;
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
||||
|
||||
priv = engine->priv;
|
||||
|
||||
va_start (args, property_context);
|
||||
_gtk_style_context_get_valist (priv->context, state, property_context, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_theming_engine_get:
|
||||
* @engine: a #GtkThemingEngine
|
||||
@ -1066,6 +1093,8 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine,
|
||||
GtkBorderStyle border_style;
|
||||
GtkBorder border;
|
||||
gint border_width;
|
||||
GtkStylePropertyContext context;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
flags = gtk_theming_engine_get_state (engine);
|
||||
cairo_save (cr);
|
||||
@ -1074,9 +1103,22 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine,
|
||||
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
||||
gtk_theming_engine_get_border (engine, flags, &border);
|
||||
|
||||
gtk_theming_engine_get (engine, flags,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
context.width = width;
|
||||
context.height = height;
|
||||
|
||||
_gtk_theming_engine_get (engine, flags, &context,
|
||||
"background-image", &pattern,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
|
||||
if (pattern != NULL)
|
||||
{
|
||||
render_background_internal (engine, cr, x, y, width, height,
|
||||
gtk_theming_engine_get_junction_sides (engine), pattern);
|
||||
cairo_restore (cr);
|
||||
cairo_pattern_destroy (pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
border_width = MIN (MIN (border.top, border.bottom),
|
||||
MIN (border.left, border.right));
|
||||
@ -1186,6 +1228,8 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine,
|
||||
gint exterior_size, interior_size, pad, thickness, border_width;
|
||||
GtkBorderStyle border_style;
|
||||
GtkBorder border;
|
||||
GtkStylePropertyContext context;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
flags = gtk_theming_engine_get_state (engine);
|
||||
|
||||
@ -1195,9 +1239,22 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine,
|
||||
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
||||
gtk_theming_engine_get_border (engine, flags, &border);
|
||||
|
||||
gtk_theming_engine_get (engine, flags,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
context.width = width;
|
||||
context.height = height;
|
||||
|
||||
_gtk_theming_engine_get (engine, flags, &context,
|
||||
"background-image", &pattern,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
|
||||
if (pattern != NULL)
|
||||
{
|
||||
render_background_internal (engine, cr, x, y, width, height,
|
||||
gtk_theming_engine_get_junction_sides (engine), pattern);
|
||||
cairo_restore (cr);
|
||||
cairo_pattern_destroy (pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
exterior_size = MIN (width, height);
|
||||
border_width = MIN (MIN (border.top, border.bottom),
|
||||
@ -1370,6 +1427,9 @@ color_shade (const GdkRGBA *color,
|
||||
gtk_symbolic_color_unref (shade);
|
||||
}
|
||||
|
||||
/* optional_background is the background-image, in case it was
|
||||
already availible we avoid getting it (and thus possibly
|
||||
rendering it) twice */
|
||||
static void
|
||||
render_background_internal (GtkThemingEngine *engine,
|
||||
cairo_t *cr,
|
||||
@ -1377,7 +1437,8 @@ render_background_internal (GtkThemingEngine *engine,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction)
|
||||
GtkJunctionSides junction,
|
||||
cairo_pattern_t *optional_background)
|
||||
{
|
||||
GdkRGBA bg_color;
|
||||
cairo_pattern_t *pattern;
|
||||
@ -1388,16 +1449,26 @@ render_background_internal (GtkThemingEngine *engine,
|
||||
GtkRoundedBox border_box;
|
||||
GtkShadow *box_shadow;
|
||||
GtkBorder border;
|
||||
GtkStylePropertyContext context;
|
||||
|
||||
flags = gtk_theming_engine_get_state (engine);
|
||||
|
||||
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
||||
|
||||
gtk_theming_engine_get (engine, flags,
|
||||
"background-image", &pattern,
|
||||
"background-repeat", &repeat,
|
||||
"box-shadow", &box_shadow,
|
||||
NULL);
|
||||
context.width = width;
|
||||
context.height = height;
|
||||
|
||||
if (optional_background)
|
||||
pattern = cairo_pattern_reference (optional_background);
|
||||
else
|
||||
_gtk_theming_engine_get (engine, flags, &context,
|
||||
"background-image", &pattern,
|
||||
NULL);
|
||||
|
||||
_gtk_theming_engine_get (engine, flags, &context,
|
||||
"background-repeat", &repeat,
|
||||
"box-shadow", &box_shadow,
|
||||
NULL);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_translate (cr, x, y);
|
||||
@ -1427,9 +1498,9 @@ render_background_internal (GtkThemingEngine *engine,
|
||||
other_flags = flags | GTK_STATE_FLAG_PRELIGHT;
|
||||
|
||||
gtk_theming_engine_get_background_color (engine, other_flags, &other_bg);
|
||||
gtk_theming_engine_get (engine, other_flags,
|
||||
"background-image", &other_pattern,
|
||||
NULL);
|
||||
_gtk_theming_engine_get (engine, other_flags, &context,
|
||||
"background-image", &other_pattern,
|
||||
NULL);
|
||||
|
||||
if (pattern && other_pattern)
|
||||
{
|
||||
@ -1665,7 +1736,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine,
|
||||
|
||||
render_background_internal (engine, cr,
|
||||
x, y, width, height,
|
||||
junction);
|
||||
junction, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1851,15 +1922,19 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine,
|
||||
GtkJunctionSides junction;
|
||||
GtkBorderImage *border_image;
|
||||
GtkBorder border;
|
||||
GtkStylePropertyContext context;
|
||||
|
||||
flags = gtk_theming_engine_get_state (engine);
|
||||
junction = gtk_theming_engine_get_junction_sides (engine);
|
||||
gtk_theming_engine_get_border (engine, flags, &border);
|
||||
|
||||
gtk_theming_engine_get (engine, flags,
|
||||
"border-image", &border_image,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
context.width = width;
|
||||
context.height = height;
|
||||
|
||||
_gtk_theming_engine_get (engine, flags, &context,
|
||||
"border-image", &border_image,
|
||||
"border-style", &border_style,
|
||||
NULL);
|
||||
|
||||
if (border_image != NULL)
|
||||
{
|
||||
@ -2369,11 +2444,11 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine,
|
||||
gap_side == GTK_POS_BOTTOM)
|
||||
render_background_internal (engine, cr,
|
||||
0, 0, width, height,
|
||||
GTK_JUNCTION_BOTTOM);
|
||||
GTK_JUNCTION_BOTTOM, NULL);
|
||||
else
|
||||
render_background_internal (engine, cr,
|
||||
0, 0, height, width,
|
||||
GTK_JUNCTION_BOTTOM);
|
||||
GTK_JUNCTION_BOTTOM, NULL);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_save (cr);
|
||||
@ -2439,7 +2514,7 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
|
||||
color_shade (&bg_color, 0.7, &darker);
|
||||
color_shade (&bg_color, 1.3, &lighter);
|
||||
|
||||
render_background_internal (engine, cr, x, y, width, height, sides);
|
||||
render_background_internal (engine, cr, x, y, width, height, sides, NULL);
|
||||
|
||||
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
|
||||
{
|
||||
|
@ -21,6 +21,13 @@
|
||||
#define __GTK_THEMING_ENGINE_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
void _gtk_theming_engine_get (GtkThemingEngine *engine,
|
||||
GtkStateFlags state,
|
||||
GtkStylePropertyContext *property_context,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
|
||||
void _gtk_theming_engine_paint_spinner (cairo_t *cr,
|
||||
gdouble radius,
|
||||
|
593
gtk/gtkwin32theme.c
Normal file
593
gtk/gtkwin32theme.c
Normal file
@ -0,0 +1,593 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* Authors: Carlos Garnacho <carlosg@gnome.org>
|
||||
* Cosimo Cecchi <cosimoc@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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <cairo-win32.h>
|
||||
|
||||
typedef HANDLE HTHEME;
|
||||
|
||||
#define UXTHEME_DLL "uxtheme.dll"
|
||||
|
||||
static HINSTANCE uxtheme_dll = NULL;
|
||||
static gboolean use_xp_theme = FALSE;
|
||||
|
||||
typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc) (HTHEME hTheme, int iFontID, OUT LOGFONTW *plf);
|
||||
typedef int (FAR PASCAL *GetThemeSysSizeFunc) (HTHEME hTheme, int iSizeId);
|
||||
typedef COLORREF (FAR PASCAL *GetThemeSysColorFunc) (HTHEME hTheme,
|
||||
int iColorID);
|
||||
typedef HTHEME (FAR PASCAL *OpenThemeDataFunc) (HWND hwnd,
|
||||
LPCWSTR pszClassList);
|
||||
typedef HRESULT (FAR PASCAL *CloseThemeDataFunc) (HTHEME theme);
|
||||
typedef HRESULT (FAR PASCAL *DrawThemeBackgroundFunc) (HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
|
||||
const RECT *pRect, const RECT *pClipRect);
|
||||
typedef HRESULT (FAR PASCAL *EnableThemeDialogTextureFunc) (HWND hwnd,
|
||||
DWORD dwFlags);
|
||||
typedef BOOL (FAR PASCAL *IsThemeActiveFunc) (VOID);
|
||||
typedef BOOL (FAR PASCAL *IsAppThemedFunc) (VOID);
|
||||
typedef BOOL (FAR PASCAL *IsThemeBackgroundPartiallyTransparentFunc) (HTHEME hTheme,
|
||||
int iPartId,
|
||||
int iStateId);
|
||||
typedef HRESULT (FAR PASCAL *DrawThemeParentBackgroundFunc) (HWND hwnd,
|
||||
HDC hdc,
|
||||
RECT *prc);
|
||||
typedef HRESULT (FAR PASCAL *GetThemePartSizeFunc) (HTHEME hTheme,
|
||||
HDC hdc,
|
||||
int iPartId,
|
||||
int iStateId,
|
||||
RECT *prc,
|
||||
int eSize,
|
||||
SIZE *psz);
|
||||
|
||||
static GetThemeSysFontFunc get_theme_sys_font = NULL;
|
||||
static GetThemeSysColorFunc get_theme_sys_color = NULL;
|
||||
static GetThemeSysSizeFunc get_theme_sys_metric = NULL;
|
||||
static OpenThemeDataFunc open_theme_data = NULL;
|
||||
static CloseThemeDataFunc close_theme_data = NULL;
|
||||
static DrawThemeBackgroundFunc draw_theme_background = NULL;
|
||||
static EnableThemeDialogTextureFunc enable_theme_dialog_texture = NULL;
|
||||
static IsThemeActiveFunc is_theme_active = NULL;
|
||||
static IsAppThemedFunc is_app_themed = NULL;
|
||||
static IsThemeBackgroundPartiallyTransparentFunc is_theme_partially_transparent = NULL;
|
||||
static DrawThemeParentBackgroundFunc draw_theme_parent_background = NULL;
|
||||
static GetThemePartSizeFunc get_theme_part_size = NULL;
|
||||
|
||||
static GHashTable *hthemes_by_class = NULL;
|
||||
|
||||
static void
|
||||
_gtk_win32_theme_init (void)
|
||||
{
|
||||
char *buf;
|
||||
char dummy;
|
||||
int n, k;
|
||||
|
||||
if (uxtheme_dll)
|
||||
return;
|
||||
|
||||
n = GetSystemDirectory (&dummy, 0);
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
buf = g_malloc (n + 1 + strlen (UXTHEME_DLL));
|
||||
k = GetSystemDirectory (buf, n);
|
||||
if (k == 0 || k > n)
|
||||
{
|
||||
g_free (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!G_IS_DIR_SEPARATOR (buf[strlen (buf) -1]))
|
||||
strcat (buf, G_DIR_SEPARATOR_S);
|
||||
strcat (buf, UXTHEME_DLL);
|
||||
|
||||
uxtheme_dll = LoadLibrary (buf);
|
||||
g_free (buf);
|
||||
|
||||
if (!uxtheme_dll)
|
||||
return;
|
||||
|
||||
is_app_themed = (IsAppThemedFunc) GetProcAddress (uxtheme_dll, "IsAppThemed");
|
||||
if (is_app_themed)
|
||||
{
|
||||
is_theme_active = (IsThemeActiveFunc) GetProcAddress (uxtheme_dll, "IsThemeActive");
|
||||
open_theme_data = (OpenThemeDataFunc) GetProcAddress (uxtheme_dll, "OpenThemeData");
|
||||
close_theme_data = (CloseThemeDataFunc) GetProcAddress (uxtheme_dll, "CloseThemeData");
|
||||
draw_theme_background = (DrawThemeBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeBackground");
|
||||
enable_theme_dialog_texture = (EnableThemeDialogTextureFunc) GetProcAddress (uxtheme_dll, "EnableThemeDialogTexture");
|
||||
get_theme_sys_font = (GetThemeSysFontFunc) GetProcAddress (uxtheme_dll, "GetThemeSysFont");
|
||||
get_theme_sys_color = (GetThemeSysColorFunc) GetProcAddress (uxtheme_dll, "GetThemeSysColor");
|
||||
get_theme_sys_metric = (GetThemeSysSizeFunc) GetProcAddress (uxtheme_dll, "GetThemeSysSize");
|
||||
is_theme_partially_transparent = (IsThemeBackgroundPartiallyTransparentFunc) GetProcAddress (uxtheme_dll, "IsThemeBackgroundPartiallyTransparent");
|
||||
draw_theme_parent_background = (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground");
|
||||
get_theme_part_size = (GetThemePartSizeFunc) GetProcAddress (uxtheme_dll, "GetThemePartSize");
|
||||
}
|
||||
|
||||
if (is_app_themed && is_theme_active)
|
||||
{
|
||||
use_xp_theme = (is_app_themed () && is_theme_active ());
|
||||
}
|
||||
else
|
||||
{
|
||||
use_xp_theme = FALSE;
|
||||
}
|
||||
|
||||
hthemes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
static HTHEME
|
||||
lookup_htheme_by_classname (const char *class)
|
||||
{
|
||||
HTHEME theme;
|
||||
guint16 *wclass;
|
||||
char *lower;
|
||||
|
||||
lower = g_ascii_strdown (class, -1);
|
||||
|
||||
theme = (HTHEME) g_hash_table_lookup (hthemes_by_class, lower);
|
||||
if (theme)
|
||||
{
|
||||
g_free (lower);
|
||||
return theme;
|
||||
}
|
||||
|
||||
wclass = g_utf8_to_utf16 (lower, -1, NULL, NULL, NULL);
|
||||
theme = open_theme_data (NULL, wclass);
|
||||
g_free (wclass);
|
||||
|
||||
if (theme == NULL)
|
||||
{
|
||||
g_free (lower);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Takes ownership of lower: */
|
||||
g_hash_table_insert (hthemes_by_class, lower, theme);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
typedef void * HTHEME;
|
||||
|
||||
static void
|
||||
_gtk_win32_theme_init (void)
|
||||
{
|
||||
}
|
||||
|
||||
static HTHEME
|
||||
lookup_htheme_by_classname (const char *class)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
G_DEFINE_BOXED_TYPE_WITH_CODE (GtkWin32ThemePart, _gtk_win32_theme_part,
|
||||
_gtk_win32_theme_part_ref, _gtk_win32_theme_part_unref,
|
||||
_gtk_win32_theme_init() )
|
||||
|
||||
typedef enum {
|
||||
RENDER_OVER,
|
||||
RENDER_MIX
|
||||
} ThemePartRenderOps;
|
||||
|
||||
struct _GtkWin32ThemePart {
|
||||
HTHEME theme;
|
||||
int part;
|
||||
int state;
|
||||
int part2;
|
||||
int state2;
|
||||
ThemePartRenderOps op;
|
||||
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
GtkWin32ThemePart *
|
||||
_gtk_win32_theme_part_new (const char *class,
|
||||
int xp_part, int state,
|
||||
int xp_part2, int state2,
|
||||
ThemePartRenderOps op)
|
||||
{
|
||||
GtkWin32ThemePart *part;
|
||||
|
||||
part = g_slice_new0 (GtkWin32ThemePart);
|
||||
part->ref_count = 1;
|
||||
|
||||
part->theme = lookup_htheme_by_classname (class);
|
||||
part->part = xp_part;
|
||||
part->state = state;
|
||||
part->part2 = xp_part2;
|
||||
part->state2 = state2;
|
||||
part->op = op;
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
GtkWin32ThemePart *
|
||||
_gtk_win32_theme_part_ref (GtkWin32ThemePart *part)
|
||||
{
|
||||
g_return_val_if_fail (part != NULL, NULL);
|
||||
|
||||
part->ref_count++;
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_win32_theme_part_unref (GtkWin32ThemePart *part)
|
||||
{
|
||||
g_return_if_fail (part != NULL);
|
||||
|
||||
part->ref_count--;
|
||||
|
||||
if (part->ref_count == 0)
|
||||
{
|
||||
g_slice_free (GtkWin32ThemePart, part);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_gtk_win32_theme_part_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
GValue *value)
|
||||
{
|
||||
char *class;
|
||||
int xp_part, state, xp_part2, state2;
|
||||
ThemePartRenderOps op;
|
||||
GtkWin32ThemePart *theme_part;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "-gtk-win32-theme-part", TRUE))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_value_unset (value);
|
||||
g_value_init (value, GTK_TYPE_WIN32_THEME_PART);
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after '-gtk-win32-theme-part'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
class = _gtk_css_parser_try_name (parser, TRUE);
|
||||
if (class == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected name as first argument to '-gtk-win32-theme-part'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ','");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &xp_part))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &state))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
op = RENDER_OVER;
|
||||
xp_part2 = -1;
|
||||
state2 = -1;
|
||||
if ( _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
|
||||
if ( _gtk_css_parser_try (parser, "over", TRUE))
|
||||
{
|
||||
op = RENDER_OVER;
|
||||
}
|
||||
else if ( _gtk_css_parser_try (parser, "mix", TRUE))
|
||||
{
|
||||
op = RENDER_MIX;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &xp_part2))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &state2))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
theme_part = _gtk_win32_theme_part_new (class,
|
||||
xp_part, state,
|
||||
xp_part2, state2,
|
||||
op);
|
||||
g_free (class);
|
||||
|
||||
g_value_take_boxed (value, theme_part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
cairo_surface_t *
|
||||
_gtk_win32_theme_part_create_surface (GtkWin32ThemePart *part,
|
||||
int xp_part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
HDC hdc;
|
||||
RECT rect;
|
||||
HRESULT res;
|
||||
|
||||
surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, width, height);
|
||||
hdc = cairo_win32_surface_get_dc (surface);
|
||||
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
|
||||
res = draw_theme_background (part->theme, hdc, xp_part, state, &rect, &rect);
|
||||
return surface;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
cairo_pattern_t *
|
||||
_gtk_win32_theme_part_render (GtkWin32ThemePart *part,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
cairo_surface_t *surface, *surface2, *image;
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_t *cr;
|
||||
cairo_matrix_t matrix;
|
||||
cairo_user_data_key_t key;
|
||||
|
||||
surface = _gtk_win32_theme_part_create_surface (part, part->part, part->state,
|
||||
width, height);
|
||||
|
||||
if (part->state2 >= 0)
|
||||
{
|
||||
surface2 = _gtk_win32_theme_part_create_surface (part, part->part2, part->state2,
|
||||
width, height);
|
||||
|
||||
|
||||
if (part->op == RENDER_MIX)
|
||||
{
|
||||
cr = cairo_create (surface);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (surface2);
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_paint_with_alpha (cr, 0.5);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
else /* OVER */
|
||||
{
|
||||
cr = cairo_create (surface);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (surface2);
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
cairo_surface_destroy (surface2);
|
||||
}
|
||||
|
||||
/* We need to return an image surface, as that is what the code expects in order
|
||||
to get the size */
|
||||
image = cairo_win32_surface_get_image (surface);
|
||||
pattern = cairo_pattern_create_for_surface (cairo_surface_reference (image));
|
||||
|
||||
cairo_matrix_init_scale (&matrix,
|
||||
width,
|
||||
height);
|
||||
cairo_pattern_set_matrix (pattern, &matrix);
|
||||
|
||||
/* We can't immediately destroy the surface, because that would free the data
|
||||
the image surface refers too. Instead we destroy it with the pattern. */
|
||||
cairo_pattern_set_user_data (pattern,
|
||||
&key,
|
||||
surface, (cairo_destroy_func_t) cairo_surface_destroy);
|
||||
|
||||
return pattern;
|
||||
#else
|
||||
GdkRGBA color;
|
||||
|
||||
gdk_rgba_parse (&color, "pink");
|
||||
|
||||
return cairo_pattern_create_rgb (color.red, color.green, color.blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_gtk_win32_theme_int_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
int *value)
|
||||
{
|
||||
char *class;
|
||||
int arg;
|
||||
|
||||
if (_gtk_css_parser_try (parser,
|
||||
"-gtk-win32-size",
|
||||
TRUE))
|
||||
{
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after '-gtk-win32-size'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
class = _gtk_css_parser_try_name (parser, TRUE);
|
||||
if (class == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected name as first argument to '-gtk-win32-size'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ','");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &arg))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (use_xp_theme && get_theme_sys_metric != NULL)
|
||||
{
|
||||
HTHEME theme = lookup_htheme_by_classname (class);
|
||||
|
||||
/* If theme is NULL it will just return the GetSystemMetrics value */
|
||||
*value = get_theme_sys_metric (theme, arg);
|
||||
}
|
||||
else
|
||||
*value = GetSystemMetrics (arg);
|
||||
#else
|
||||
*value = 1;
|
||||
#endif
|
||||
|
||||
g_free (class);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
GtkSymbolicColor *
|
||||
_gtk_win32_theme_color_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkSymbolicColor *color;
|
||||
char *class;
|
||||
int id;
|
||||
|
||||
class = _gtk_css_parser_try_name (parser, TRUE);
|
||||
if (class == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected name as first argument to '-gtk-win32-color'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ','");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &id))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color = gtk_symbolic_color_new_win32 (class, id);
|
||||
g_free (class);
|
||||
return color;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_win32_theme_color_resolve (const char *theme_class,
|
||||
gint id,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
DWORD dcolor;
|
||||
|
||||
if (use_xp_theme && get_theme_sys_color != NULL)
|
||||
{
|
||||
HTHEME theme = lookup_htheme_by_classname (theme_class);
|
||||
|
||||
/* if theme is NULL, it will just return the GetSystemColor()
|
||||
value */
|
||||
dcolor = get_theme_sys_color (theme, id);
|
||||
}
|
||||
else
|
||||
dcolor = GetSysColor (id);
|
||||
|
||||
color->alpha = 1.0;
|
||||
color->red = GetRValue (dcolor) / 255.0;
|
||||
color->green = GetGValue (dcolor) / 255.0;
|
||||
color->blue = GetBValue (dcolor) / 255.0;
|
||||
#else
|
||||
gdk_rgba_parse (color, "pink");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
55
gtk/gtkwin32themeprivate.h
Normal file
55
gtk/gtkwin32themeprivate.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_WIN32_THEME_PART_H__
|
||||
#define __GTK_WIN32_THEME_PART_H__
|
||||
|
||||
#include "gtkcssparserprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME "-gtk-win32-color"
|
||||
|
||||
typedef struct _GtkWin32ThemePart GtkWin32ThemePart;
|
||||
|
||||
#define GTK_TYPE_WIN32_THEME_PART (_gtk_win32_theme_part_get_type ())
|
||||
|
||||
GType _gtk_win32_theme_part_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWin32ThemePart *_gtk_win32_theme_part_ref (GtkWin32ThemePart *part);
|
||||
void _gtk_win32_theme_part_unref (GtkWin32ThemePart *part);
|
||||
int _gtk_win32_theme_part_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
GValue *value);
|
||||
cairo_pattern_t *_gtk_win32_theme_part_render (GtkWin32ThemePart *part,
|
||||
int width,
|
||||
int height);
|
||||
int _gtk_win32_theme_int_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
int *value);
|
||||
GtkSymbolicColor *_gtk_win32_theme_color_parse (GtkCssParser *parser);
|
||||
gboolean _gtk_win32_theme_color_resolve (const char *theme_class,
|
||||
gint id,
|
||||
GdkRGBA *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_WIN32_THEME_PART_H__ */
|
Loading…
Reference in New Issue
Block a user