From 66122b369e06d517fb5e8a9a7dd3002f3fc660ac Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 2 Dec 2010 14:52:22 +0000 Subject: [PATCH 001/634] gtk: Centre the text under the icon in GtkIconView No point in setting the alignment to centre if we don't center it within the cell itself. --- gtk/gtkiconview.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 8a3defdb80..17ce6af25b 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -5618,7 +5618,7 @@ update_text_cell (GtkIconView *icon_view) g_object_set (info->cell, "alignment", PANGO_ALIGN_CENTER, "wrap-mode", PANGO_WRAP_WORD_CHAR, - "xalign", 0.0, + "xalign", 0.5, "yalign", 0.0, NULL); else @@ -5626,7 +5626,7 @@ update_text_cell (GtkIconView *icon_view) "alignment", PANGO_ALIGN_LEFT, "wrap-mode", PANGO_WRAP_WORD_CHAR, "xalign", 0.0, - "yalign", 0.0, + "yalign", 0.5, NULL); } } From c5d1b36e8713ed081a112e18662d6376a0b27189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?= Date: Thu, 2 Dec 2010 19:28:12 +0100 Subject: [PATCH 002/634] Updated Spanish translation --- po/es.po | 417 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 222 insertions(+), 195 deletions(-) diff --git a/po/es.po b/po/es.po index 8b5ba0437d..1934a51173 100644 --- a/po/es.po +++ b/po/es.po @@ -16,8 +16,8 @@ msgstr "" "Project-Id-Version: gtk+.master\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gtk" "%2b&component=general\n" -"POT-Creation-Date: 2010-10-22 15:08+0000\n" -"PO-Revision-Date: 2010-10-23 14:18+0200\n" +"POT-Creation-Date: 2010-11-29 20:28+0000\n" +"PO-Revision-Date: 2010-12-02 19:10+0100\n" "Last-Translator: Jorge González \n" "Language-Team: Español \n" "MIME-Version: 1.0\n" @@ -27,58 +27,58 @@ msgstr "" "X-Generator: KBabel 1.11.4\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: ../gdk/gdk.c:104 +#: ../gdk/gdk.c:115 #, c-format msgid "Error parsing option --gdk-debug" msgstr "Error al analizar la opción --gdk-debug" -#: ../gdk/gdk.c:124 +#: ../gdk/gdk.c:135 #, c-format msgid "Error parsing option --gdk-no-debug" msgstr "Error al analizar la opción --gdk-no-debug" #. Description of --class=CLASS in --help output -#: ../gdk/gdk.c:152 +#: ../gdk/gdk.c:163 msgid "Program class as used by the window manager" msgstr "Clase del programa tal como la usa el gestor de ventanas" #. Placeholder in --class=CLASS in --help output -#: ../gdk/gdk.c:153 +#: ../gdk/gdk.c:164 msgid "CLASS" msgstr "CLASE" #. Description of --name=NAME in --help output -#: ../gdk/gdk.c:155 +#: ../gdk/gdk.c:166 msgid "Program name as used by the window manager" msgstr "Nombre del programa tal como lo usa el gestor de ventanas" #. Placeholder in --name=NAME in --help output -#: ../gdk/gdk.c:156 +#: ../gdk/gdk.c:167 msgid "NAME" msgstr "NOMBRE" #. Description of --display=DISPLAY in --help output -#: ../gdk/gdk.c:158 +#: ../gdk/gdk.c:169 msgid "X display to use" msgstr "Visor [display] X que usar" #. Placeholder in --display=DISPLAY in --help output -#: ../gdk/gdk.c:159 +#: ../gdk/gdk.c:170 msgid "DISPLAY" msgstr "VISOR" #. Description of --screen=SCREEN in --help output -#: ../gdk/gdk.c:161 +#: ../gdk/gdk.c:172 msgid "X screen to use" msgstr "Pantalla [screen] X que usar" #. Placeholder in --screen=SCREEN in --help output -#: ../gdk/gdk.c:162 +#: ../gdk/gdk.c:173 msgid "SCREEN" msgstr "PANTALLA" #. Description of --gdk-debug=FLAGS in --help output -#: ../gdk/gdk.c:165 +#: ../gdk/gdk.c:176 msgid "GDK debugging flags to set" msgstr "Opciones de depuración GTK+ que establecer" @@ -86,12 +86,12 @@ msgstr "Opciones de depuración GTK+ que establecer" #. Placeholder in --gdk-no-debug=FLAGS in --help output #. Placeholder in --gtk-debug=FLAGS in --help output #. Placeholder in --gtk-no-debug=FLAGS in --help output -#: ../gdk/gdk.c:166 ../gdk/gdk.c:169 ../gtk/gtkmain.c:534 ../gtk/gtkmain.c:537 +#: ../gdk/gdk.c:177 ../gdk/gdk.c:180 ../gtk/gtkmain.c:525 ../gtk/gtkmain.c:528 msgid "FLAGS" msgstr "OPCIONES" #. Description of --gdk-no-debug=FLAGS in --help output -#: ../gdk/gdk.c:168 +#: ../gdk/gdk.c:179 msgid "GDK debugging flags to unset" msgstr "Opciones de depuración GTK+ que quitar" @@ -310,17 +310,17 @@ msgstr "Tamaño de la paleta en modo 8 bits" msgid "COLORS" msgstr "COLORES" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:312 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:305 #, c-format msgid "Starting %s" msgstr "Iniciando %s" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:316 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:318 #, c-format msgid "Opening %s" msgstr "Abriendo %s" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:321 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:323 #, c-format msgid "Opening %d Item" msgid_plural "Opening %d Items" @@ -341,7 +341,7 @@ msgid "This program comes with ABSOLUTELY NO WARRANTY; for details, visit %s" msgstr "" "Este programa viene SIN NINGUNA GARANTÍA; para obtener más detalles visite %s" -#: ../gtk/gtkaboutdialog.c:339 ../gtk/gtkaboutdialog.c:2232 +#: ../gtk/gtkaboutdialog.c:339 ../gtk/gtkaboutdialog.c:2233 msgid "License" msgstr "Licencia" @@ -350,41 +350,41 @@ msgid "The license of the program" msgstr "La licencia del programa" #. Add the credits button -#: ../gtk/gtkaboutdialog.c:621 +#: ../gtk/gtkaboutdialog.c:622 msgid "C_redits" msgstr "C_réditos" #. Add the license button -#: ../gtk/gtkaboutdialog.c:635 +#: ../gtk/gtkaboutdialog.c:636 msgid "_License" msgstr "_Licencia" -#: ../gtk/gtkaboutdialog.c:839 +#: ../gtk/gtkaboutdialog.c:840 msgid "Could not show link" msgstr "No se pudo mostrar el enlace" -#: ../gtk/gtkaboutdialog.c:932 +#: ../gtk/gtkaboutdialog.c:933 #, c-format msgid "About %s" msgstr "Acerca de %s" -#: ../gtk/gtkaboutdialog.c:2150 +#: ../gtk/gtkaboutdialog.c:2151 msgid "Credits" msgstr "Créditos" -#: ../gtk/gtkaboutdialog.c:2182 +#: ../gtk/gtkaboutdialog.c:2183 msgid "Written by" msgstr "Escrito por" -#: ../gtk/gtkaboutdialog.c:2185 +#: ../gtk/gtkaboutdialog.c:2186 msgid "Documented by" msgstr "Documentado por" -#: ../gtk/gtkaboutdialog.c:2197 +#: ../gtk/gtkaboutdialog.c:2198 msgid "Translated by" msgstr "Traducido por" -#: ../gtk/gtkaboutdialog.c:2201 +#: ../gtk/gtkaboutdialog.c:2202 msgid "Artwork by" msgstr "Arte por" @@ -489,7 +489,7 @@ msgstr "Etiqueta no soportada: «%s»" #. * text direction of RTL and specify "calendar:YM", then the year #. * will appear to the right of the month. #. -#: ../gtk/gtkcalendar.c:883 +#: ../gtk/gtkcalendar.c:878 msgid "calendar:MY" msgstr "calendar:MY" @@ -497,7 +497,7 @@ msgstr "calendar:MY" #. * first day of the week to calendar:week_start:1 if you want Monday #. * to be the first day of the week, and so on. #. -#: ../gtk/gtkcalendar.c:921 +#: ../gtk/gtkcalendar.c:916 msgid "calendar:week_start:0" msgstr "calendar:week_start:1" @@ -506,7 +506,7 @@ msgstr "calendar:week_start:1" #. * #. * If you don't understand this, leave it as "2000" #. -#: ../gtk/gtkcalendar.c:2006 +#: ../gtk/gtkcalendar.c:1848 msgctxt "year measurement template" msgid "2000" msgstr "2000" @@ -521,7 +521,7 @@ msgstr "2000" #. * digits. That needs support from your system and locale definition #. * too. #. -#: ../gtk/gtkcalendar.c:2037 ../gtk/gtkcalendar.c:2719 +#: ../gtk/gtkcalendar.c:1879 ../gtk/gtkcalendar.c:2564 #, c-format msgctxt "calendar:day:digits" msgid "%d" @@ -537,7 +537,7 @@ msgstr "%d" #. * digits. That needs support from your system and locale definition #. * too. #. -#: ../gtk/gtkcalendar.c:2069 ../gtk/gtkcalendar.c:2579 +#: ../gtk/gtkcalendar.c:1911 ../gtk/gtkcalendar.c:2432 #, c-format msgctxt "calendar:week:digits" msgid "%d" @@ -553,7 +553,7 @@ msgstr "%Id" #. * #. * "%Y" is appropriate for most locales. #. -#: ../gtk/gtkcalendar.c:2361 +#: ../gtk/gtkcalendar.c:2197 msgctxt "calendar year format" msgid "%Y" msgstr "%Y" @@ -589,15 +589,15 @@ msgctxt "progress bar label" msgid "%d %%" msgstr "%d %%" -#: ../gtk/gtkcolorbutton.c:176 ../gtk/gtkcolorbutton.c:445 +#: ../gtk/gtkcolorbutton.c:188 ../gtk/gtkcolorbutton.c:473 msgid "Pick a Color" msgstr "Escoja un color" -#: ../gtk/gtkcolorbutton.c:336 +#: ../gtk/gtkcolorbutton.c:363 msgid "Received invalid color data\n" msgstr "Se recibió un dato de color no válido\n" -#: ../gtk/gtkcolorsel.c:379 +#: ../gtk/gtkcolorsel.c:416 msgid "" "Select the color you want from the outer ring. Select the darkness or " "lightness of that color using the inner triangle." @@ -605,7 +605,7 @@ msgstr "" "Seleccionar el color que desea desde el anillo exterior. Seleccionar la " "oscuridad o luminosidad de ese color usando el triángulo interior." -#: ../gtk/gtkcolorsel.c:403 +#: ../gtk/gtkcolorsel.c:440 msgid "" "Click the eyedropper, then click a color anywhere on your screen to select " "that color." @@ -613,67 +613,67 @@ msgstr "" "Pulse en el gotero, luego pulse sobre cualquier color que haya en su " "pantalla para seleccionar ese color." -#: ../gtk/gtkcolorsel.c:412 +#: ../gtk/gtkcolorsel.c:449 msgid "_Hue:" msgstr "_Matiz:" -#: ../gtk/gtkcolorsel.c:413 +#: ../gtk/gtkcolorsel.c:450 msgid "Position on the color wheel." msgstr "Posición en la rueda de colores." -#: ../gtk/gtkcolorsel.c:415 +#: ../gtk/gtkcolorsel.c:452 msgid "_Saturation:" msgstr "_Saturación:" -#: ../gtk/gtkcolorsel.c:416 +#: ../gtk/gtkcolorsel.c:453 msgid "Intensity of the color." msgstr "Intensidad del color." -#: ../gtk/gtkcolorsel.c:417 +#: ../gtk/gtkcolorsel.c:454 msgid "_Value:" msgstr "_Valor:" -#: ../gtk/gtkcolorsel.c:418 +#: ../gtk/gtkcolorsel.c:455 msgid "Brightness of the color." msgstr "Brillo del color." -#: ../gtk/gtkcolorsel.c:419 +#: ../gtk/gtkcolorsel.c:456 msgid "_Red:" msgstr "_Rojo:" -#: ../gtk/gtkcolorsel.c:420 +#: ../gtk/gtkcolorsel.c:457 msgid "Amount of red light in the color." msgstr "Cantidad de luz roja en el color." -#: ../gtk/gtkcolorsel.c:421 +#: ../gtk/gtkcolorsel.c:458 msgid "_Green:" msgstr "_Verde:" -#: ../gtk/gtkcolorsel.c:422 +#: ../gtk/gtkcolorsel.c:459 msgid "Amount of green light in the color." msgstr "Cantidad de luz verde en el color." -#: ../gtk/gtkcolorsel.c:423 +#: ../gtk/gtkcolorsel.c:460 msgid "_Blue:" msgstr "_Azul:" -#: ../gtk/gtkcolorsel.c:424 +#: ../gtk/gtkcolorsel.c:461 msgid "Amount of blue light in the color." msgstr "Cantidad de luz azul en el color." -#: ../gtk/gtkcolorsel.c:427 +#: ../gtk/gtkcolorsel.c:464 msgid "Op_acity:" msgstr "_Opacidad:" -#: ../gtk/gtkcolorsel.c:434 ../gtk/gtkcolorsel.c:444 +#: ../gtk/gtkcolorsel.c:471 ../gtk/gtkcolorsel.c:481 msgid "Transparency of the color." msgstr "Transparencia del color." -#: ../gtk/gtkcolorsel.c:451 +#: ../gtk/gtkcolorsel.c:488 msgid "Color _name:" msgstr "_Nombre del color:" -#: ../gtk/gtkcolorsel.c:465 +#: ../gtk/gtkcolorsel.c:502 msgid "" "You can enter an HTML-style hexadecimal color value, or simply a color name " "such as 'orange' in this entry." @@ -681,15 +681,15 @@ msgstr "" "Puede introducir en esta entrada un valor de color en estilo HTML " "hexadecimal, o simplemente un nombre de color como «orange»." -#: ../gtk/gtkcolorsel.c:495 +#: ../gtk/gtkcolorsel.c:532 msgid "_Palette:" msgstr "_Paleta:" -#: ../gtk/gtkcolorsel.c:524 +#: ../gtk/gtkcolorsel.c:561 msgid "Color Wheel" msgstr "Rueda de color" -#: ../gtk/gtkcolorsel.c:983 +#: ../gtk/gtkcolorsel.c:1031 msgid "" "The previously-selected color, for comparison to the color you're selecting " "now. You can drag this color to a palette entry, or select this color as " @@ -700,7 +700,7 @@ msgstr "" "seleccionar este color como actual arrastrándolo al otro color a lo largo de " "la muestra." -#: ../gtk/gtkcolorsel.c:986 +#: ../gtk/gtkcolorsel.c:1034 msgid "" "The color you've chosen. You can drag this color to a palette entry to save " "it for use in the future." @@ -708,7 +708,7 @@ msgstr "" "El color elegido. Puede arrastrar este color a una entrada de la paleta para " "guardarlo para usarlo en el futuro." -#: ../gtk/gtkcolorsel.c:991 +#: ../gtk/gtkcolorsel.c:1039 msgid "" "The previously-selected color, for comparison to the color you're selecting " "now." @@ -716,15 +716,15 @@ msgstr "" "El color anteriormente seleccionado, para compararlo con el color que está " "seleccionando ahora" -#: ../gtk/gtkcolorsel.c:994 +#: ../gtk/gtkcolorsel.c:1042 msgid "The color you've chosen." msgstr "El color que ha elegido." -#: ../gtk/gtkcolorsel.c:1394 +#: ../gtk/gtkcolorsel.c:1442 msgid "_Save color here" msgstr "_Guardar color aquí" -#: ../gtk/gtkcolorsel.c:1599 +#: ../gtk/gtkcolorsel.c:1647 msgid "" "Click this palette entry to make it the current color. To change this entry, " "drag a color swatch here or right-click it and select \"Save color here.\"" @@ -801,23 +801,23 @@ msgstr "_Derecho:" msgid "Paper Margins" msgstr "Márgenes del papel" -#: ../gtk/gtkentry.c:8565 ../gtk/gtktextview.c:8183 +#: ../gtk/gtkentry.c:8794 ../gtk/gtktextview.c:8229 msgid "Input _Methods" msgstr "_Métodos de entrada" -#: ../gtk/gtkentry.c:8579 ../gtk/gtktextview.c:8197 +#: ../gtk/gtkentry.c:8808 ../gtk/gtktextview.c:8243 msgid "_Insert Unicode Control Character" msgstr "_Insertar un carácter de control Unicode" -#: ../gtk/gtkentry.c:9979 +#: ../gtk/gtkentry.c:10208 msgid "Caps Lock and Num Lock are on" msgstr "Bloq Mayús y Bloq Num están activados" -#: ../gtk/gtkentry.c:9981 +#: ../gtk/gtkentry.c:10210 msgid "Num Lock is on" msgstr "Bloq Num está activado" -#: ../gtk/gtkentry.c:9983 +#: ../gtk/gtkentry.c:10212 msgid "Caps Lock is on" msgstr "Bloq Mayús está activado" @@ -837,7 +837,7 @@ msgstr "Escritorio" msgid "(None)" msgstr "(Ninguno)" -#: ../gtk/gtkfilechooserbutton.c:1997 +#: ../gtk/gtkfilechooserbutton.c:2001 msgid "Other..." msgstr "Otra…" @@ -898,194 +898,194 @@ msgstr "%1$s en %2$s" msgid "Search" msgstr "Buscar" -#: ../gtk/gtkfilechooserdefault.c:1776 ../gtk/gtkfilechooserdefault.c:9382 +#: ../gtk/gtkfilechooserdefault.c:1776 ../gtk/gtkfilechooserdefault.c:9417 msgid "Recently Used" msgstr "Usados recientemente" -#: ../gtk/gtkfilechooserdefault.c:2430 +#: ../gtk/gtkfilechooserdefault.c:2437 msgid "Select which types of files are shown" msgstr "Seleccionar qué tipos de archivos se muestran" -#: ../gtk/gtkfilechooserdefault.c:2789 +#: ../gtk/gtkfilechooserdefault.c:2796 #, c-format msgid "Add the folder '%s' to the bookmarks" msgstr "Añadir la carpeta «%s» a los marcadores" -#: ../gtk/gtkfilechooserdefault.c:2833 +#: ../gtk/gtkfilechooserdefault.c:2840 #, c-format msgid "Add the current folder to the bookmarks" msgstr "Añadir la carpeta actual a los marcadores" -#: ../gtk/gtkfilechooserdefault.c:2835 +#: ../gtk/gtkfilechooserdefault.c:2842 #, c-format msgid "Add the selected folders to the bookmarks" msgstr "Añadir las carpetas seleccionadas a los marcadores" -#: ../gtk/gtkfilechooserdefault.c:2873 +#: ../gtk/gtkfilechooserdefault.c:2880 #, c-format msgid "Remove the bookmark '%s'" msgstr "Quitar el marcador «%s»" -#: ../gtk/gtkfilechooserdefault.c:2875 +#: ../gtk/gtkfilechooserdefault.c:2882 #, c-format msgid "Bookmark '%s' cannot be removed" msgstr "No se puede quitar el marcador «%s»" -#: ../gtk/gtkfilechooserdefault.c:2882 ../gtk/gtkfilechooserdefault.c:3746 +#: ../gtk/gtkfilechooserdefault.c:2889 ../gtk/gtkfilechooserdefault.c:3750 msgid "Remove the selected bookmark" msgstr "Quitar el marcador seleccionado" -#: ../gtk/gtkfilechooserdefault.c:3442 +#: ../gtk/gtkfilechooserdefault.c:3445 msgid "Remove" msgstr "Quitar" -#: ../gtk/gtkfilechooserdefault.c:3451 +#: ../gtk/gtkfilechooserdefault.c:3454 msgid "Rename..." msgstr "Renombrar…" #. Accessible object name for the file chooser's shortcuts pane -#: ../gtk/gtkfilechooserdefault.c:3614 +#: ../gtk/gtkfilechooserdefault.c:3617 msgid "Places" msgstr "Lugares" #. Column header for the file chooser's shortcuts pane -#: ../gtk/gtkfilechooserdefault.c:3671 +#: ../gtk/gtkfilechooserdefault.c:3674 msgid "_Places" msgstr "_Lugares" -#: ../gtk/gtkfilechooserdefault.c:3727 +#: ../gtk/gtkfilechooserdefault.c:3731 msgid "_Add" msgstr "_Añadir" -#: ../gtk/gtkfilechooserdefault.c:3734 +#: ../gtk/gtkfilechooserdefault.c:3738 msgid "Add the selected folder to the Bookmarks" msgstr "Añade la carpeta seleccionada a los marcadores" -#: ../gtk/gtkfilechooserdefault.c:3739 +#: ../gtk/gtkfilechooserdefault.c:3743 msgid "_Remove" msgstr "_Quitar" -#: ../gtk/gtkfilechooserdefault.c:3881 +#: ../gtk/gtkfilechooserdefault.c:3885 msgid "Could not select file" msgstr "No se pudo seleccionar el archivo" -#: ../gtk/gtkfilechooserdefault.c:4056 +#: ../gtk/gtkfilechooserdefault.c:4060 msgid "_Add to Bookmarks" msgstr "_Añadir a los marcadores" -#: ../gtk/gtkfilechooserdefault.c:4069 +#: ../gtk/gtkfilechooserdefault.c:4073 msgid "Show _Hidden Files" msgstr "Mostrar archivos _ocultos" -#: ../gtk/gtkfilechooserdefault.c:4076 +#: ../gtk/gtkfilechooserdefault.c:4080 msgid "Show _Size Column" msgstr "Mostrar columna de _tamaño" -#: ../gtk/gtkfilechooserdefault.c:4302 +#: ../gtk/gtkfilechooserdefault.c:4306 msgid "Files" msgstr "Archivos" -#: ../gtk/gtkfilechooserdefault.c:4353 +#: ../gtk/gtkfilechooserdefault.c:4357 msgid "Name" msgstr "Nombre" -#: ../gtk/gtkfilechooserdefault.c:4376 +#: ../gtk/gtkfilechooserdefault.c:4380 msgid "Size" msgstr "Tamaño" -#: ../gtk/gtkfilechooserdefault.c:4390 +#: ../gtk/gtkfilechooserdefault.c:4394 msgid "Modified" msgstr "Modificado" #. Label -#: ../gtk/gtkfilechooserdefault.c:4645 ../gtk/gtkprinteroptionwidget.c:793 +#: ../gtk/gtkfilechooserdefault.c:4649 ../gtk/gtkprinteroptionwidget.c:793 msgid "_Name:" msgstr "_Nombre:" -#: ../gtk/gtkfilechooserdefault.c:4688 +#: ../gtk/gtkfilechooserdefault.c:4692 msgid "_Browse for other folders" msgstr "_Buscar otras carpetas" -#: ../gtk/gtkfilechooserdefault.c:4958 +#: ../gtk/gtkfilechooserdefault.c:4962 msgid "Type a file name" msgstr "Teclee un nombre de archivo" # C en conflicto con Cancelar #. Create Folder -#: ../gtk/gtkfilechooserdefault.c:5001 +#: ../gtk/gtkfilechooserdefault.c:5005 msgid "Create Fo_lder" msgstr "Crear car_peta" -#: ../gtk/gtkfilechooserdefault.c:5011 +#: ../gtk/gtkfilechooserdefault.c:5015 msgid "_Location:" msgstr "_Lugar:" # El acelerador c entra en conflicto con cancelar -#: ../gtk/gtkfilechooserdefault.c:5215 +#: ../gtk/gtkfilechooserdefault.c:5219 msgid "Save in _folder:" msgstr "_Guardar en la carpeta:" -#: ../gtk/gtkfilechooserdefault.c:5217 +#: ../gtk/gtkfilechooserdefault.c:5221 msgid "Create in _folder:" msgstr "Crear en la _carpeta:" -#: ../gtk/gtkfilechooserdefault.c:6286 +#: ../gtk/gtkfilechooserdefault.c:6290 #, c-format msgid "Could not read the contents of %s" msgstr "No se pudo leer el contenido de %s" -#: ../gtk/gtkfilechooserdefault.c:6290 +#: ../gtk/gtkfilechooserdefault.c:6294 msgid "Could not read the contents of the folder" msgstr "No se pudo leer el contenido del la carpeta" -#: ../gtk/gtkfilechooserdefault.c:6383 ../gtk/gtkfilechooserdefault.c:6451 -#: ../gtk/gtkfilechooserdefault.c:6596 +#: ../gtk/gtkfilechooserdefault.c:6387 ../gtk/gtkfilechooserdefault.c:6455 +#: ../gtk/gtkfilechooserdefault.c:6600 msgid "Unknown" msgstr "Desconocido" -#: ../gtk/gtkfilechooserdefault.c:6398 +#: ../gtk/gtkfilechooserdefault.c:6402 msgid "%H:%M" msgstr "%H:%M" -#: ../gtk/gtkfilechooserdefault.c:6400 +#: ../gtk/gtkfilechooserdefault.c:6404 msgid "Yesterday at %H:%M" msgstr "Ayer a las %H:%M" -#: ../gtk/gtkfilechooserdefault.c:7066 +#: ../gtk/gtkfilechooserdefault.c:7070 msgid "Cannot change to folder because it is not local" msgstr "No se pudo cambiar a la carpeta porque no es local" -#: ../gtk/gtkfilechooserdefault.c:7663 ../gtk/gtkfilechooserdefault.c:7684 +#: ../gtk/gtkfilechooserdefault.c:7667 ../gtk/gtkfilechooserdefault.c:7688 #, c-format msgid "Shortcut %s already exists" msgstr "La combinación %s ya existe" -#: ../gtk/gtkfilechooserdefault.c:7774 +#: ../gtk/gtkfilechooserdefault.c:7778 #, c-format msgid "Shortcut %s does not exist" msgstr "La combinación %s no existe" -#: ../gtk/gtkfilechooserdefault.c:8035 ../gtk/gtkprintunixdialog.c:480 +#: ../gtk/gtkfilechooserdefault.c:8039 ../gtk/gtkprintunixdialog.c:480 #, c-format msgid "A file named \"%s\" already exists. Do you want to replace it?" msgstr "Ya existe un archivo llamado «%s». ¿Quiere reemplazarlo?" -#: ../gtk/gtkfilechooserdefault.c:8038 ../gtk/gtkprintunixdialog.c:484 +#: ../gtk/gtkfilechooserdefault.c:8042 ../gtk/gtkprintunixdialog.c:484 #, c-format msgid "" "The file already exists in \"%s\". Replacing it will overwrite its contents." msgstr "" "El archivo ya existe en «%s». Si lo reemplaza sobreescribirá su contenido." -#: ../gtk/gtkfilechooserdefault.c:8043 ../gtk/gtkprintunixdialog.c:491 +#: ../gtk/gtkfilechooserdefault.c:8047 ../gtk/gtkprintunixdialog.c:491 msgid "_Replace" msgstr "_Reemplazar" -#: ../gtk/gtkfilechooserdefault.c:8751 +#: ../gtk/gtkfilechooserdefault.c:8755 msgid "Could not start the search process" msgstr "No se ha podido iniciar el proceso de búsqueda" -#: ../gtk/gtkfilechooserdefault.c:8752 +#: ../gtk/gtkfilechooserdefault.c:8756 msgid "" "The program was not able to create a connection to the indexer daemon. " "Please make sure it is running." @@ -1093,36 +1093,36 @@ msgstr "" "El programa no fue capaz de crear una conexión con el demonio indexador. Por " "favor asegúrese de que se está ejecutando." -#: ../gtk/gtkfilechooserdefault.c:8766 +#: ../gtk/gtkfilechooserdefault.c:8770 msgid "Could not send the search request" msgstr "No se ha podido enviar la petición de búsqueda" -#: ../gtk/gtkfilechooserdefault.c:8954 +#: ../gtk/gtkfilechooserdefault.c:8989 msgid "Search:" msgstr "Buscar:" -#: ../gtk/gtkfilechooserdefault.c:9559 +#: ../gtk/gtkfilechooserdefault.c:9594 #, c-format msgid "Could not mount %s" msgstr "No se pudo montar %s" #. Translators: this is shown in the feedback for Tab-completion in a file #. * chooser's text entry, when the user enters an invalid path. -#: ../gtk/gtkfilechooserentry.c:702 ../gtk/gtkfilechooserentry.c:1169 +#: ../gtk/gtkfilechooserentry.c:702 ../gtk/gtkfilechooserentry.c:1172 msgid "Invalid path" msgstr "Ruta no válida" #. translators: this text is shown when there are no completions #. * for something the user typed in a file chooser entry #. -#: ../gtk/gtkfilechooserentry.c:1101 +#: ../gtk/gtkfilechooserentry.c:1104 msgid "No match" msgstr "No hay coincidencias" #. translators: this text is shown when there is exactly one completion #. * for something the user typed in a file chooser entry #. -#: ../gtk/gtkfilechooserentry.c:1112 +#: ../gtk/gtkfilechooserentry.c:1115 msgid "Sole completion" msgstr "Completado único" @@ -1130,13 +1130,13 @@ msgstr "Completado único" #. * entry is a complete filename, but could be continued to find #. * a longer match #. -#: ../gtk/gtkfilechooserentry.c:1128 +#: ../gtk/gtkfilechooserentry.c:1131 msgid "Complete, but not unique" msgstr "Completado, pero no único" #. Translators: this text is shown while the system is searching #. * for possible completions for filenames in a file chooser entry. -#: ../gtk/gtkfilechooserentry.c:1160 +#: ../gtk/gtkfilechooserentry.c:1163 msgid "Completing..." msgstr "Completando…" @@ -1144,7 +1144,7 @@ msgstr "Completando…" #. Translators: this is shown in the feedback for Tab-completion in a #. * file chooser's text entry when the user enters something like #. * "sftp://blahblah" in an app that only supports local filenames. -#: ../gtk/gtkfilechooserentry.c:1182 ../gtk/gtkfilechooserentry.c:1207 +#: ../gtk/gtkfilechooserentry.c:1185 ../gtk/gtkfilechooserentry.c:1210 msgid "Only local files may be selected" msgstr "Sólo se pueden seleccionar archivos locales" @@ -1152,14 +1152,14 @@ msgstr "Sólo se pueden seleccionar archivos locales" #. Translators: this is shown in the feedback for Tab-completion in a #. * file chooser's text entry when the user hasn't entered the first '/' #. * after a hostname and yet hits Tab (such as "sftp://blahblah[Tab]") -#: ../gtk/gtkfilechooserentry.c:1191 +#: ../gtk/gtkfilechooserentry.c:1194 msgid "Incomplete hostname; end it with '/'" msgstr "Nombre de equipo incompleto; termínelo con «/»" #. Translators: this is shown in the feedback for Tab-completion in a file #. * chooser's text entry when the user enters a path that does not exist #. * and then hits Tab -#: ../gtk/gtkfilechooserentry.c:1202 +#: ../gtk/gtkfilechooserentry.c:1205 msgid "Path does not exist" msgstr "La ruta no existe" @@ -1206,11 +1206,11 @@ msgid "Si_ze:" msgstr "_Tamaño:" #. create the text entry widget -#: ../gtk/gtkfontsel.c:559 +#: ../gtk/gtkfontsel.c:558 msgid "_Preview:" msgstr "_Vista previa:" -#: ../gtk/gtkfontsel.c:1659 +#: ../gtk/gtkfontsel.c:1658 msgid "Font Selection" msgstr "Selección de tipografías" @@ -1222,7 +1222,7 @@ msgstr "Selección de tipografías" msgid "Error loading icon: %s" msgstr "Ocurrió un error al cargar el icono: %s" -#: ../gtk/gtkicontheme.c:1354 +#: ../gtk/gtkicontheme.c:1355 #, c-format msgid "" "Could not find the icon '%s'. The '%s' theme\n" @@ -1235,12 +1235,12 @@ msgstr "" "Puede obtener una copia desde:\n" "\t%s" -#: ../gtk/gtkicontheme.c:1535 +#: ../gtk/gtkicontheme.c:1536 #, c-format msgid "Icon '%s' not present in theme" msgstr "El icono «%s» no está presente en el tema" -#: ../gtk/gtkicontheme.c:3048 +#: ../gtk/gtkicontheme.c:3057 msgid "Failed to load icon" msgstr "No se pudo cargar el icono" @@ -1266,12 +1266,12 @@ msgid "System (%s)" msgstr "Sistema (%s)" #. Open Link -#: ../gtk/gtklabel.c:6196 +#: ../gtk/gtklabel.c:6214 msgid "_Open Link" msgstr "_Abrir enlace" #. Copy Link Address -#: ../gtk/gtklabel.c:6208 +#: ../gtk/gtklabel.c:6226 msgid "Copy _Link Address" msgstr "Copiar la dirección del _enlace" @@ -1284,27 +1284,27 @@ msgid "Invalid URI" msgstr "URI inválida" #. Description of --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:527 +#: ../gtk/gtkmain.c:518 msgid "Load additional GTK+ modules" msgstr "Cargar módulos adicionales GTK+" #. Placeholder in --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:528 +#: ../gtk/gtkmain.c:519 msgid "MODULES" msgstr "MÓDULOS" #. Description of --g-fatal-warnings in --help output -#: ../gtk/gtkmain.c:530 +#: ../gtk/gtkmain.c:521 msgid "Make all warnings fatal" msgstr "Hacer todas las advertencias fatales" #. Description of --gtk-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:533 +#: ../gtk/gtkmain.c:524 msgid "GTK+ debugging flags to set" msgstr "Opciones de depuración GTK+ a poner" #. Description of --gtk-no-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:536 +#: ../gtk/gtkmain.c:527 msgid "GTK+ debugging flags to unset" msgstr "Opciones de depuración GTK+ a quitar" @@ -1313,20 +1313,20 @@ msgstr "Opciones de depuración GTK+ a quitar" #. * Do *not* translate it to "predefinito:LTR", if it #. * it isn't default:LTR or default:RTL it will not work #. -#: ../gtk/gtkmain.c:799 +#: ../gtk/gtkmain.c:790 msgid "default:LTR" msgstr "default:LTR" -#: ../gtk/gtkmain.c:864 +#: ../gtk/gtkmain.c:855 #, c-format msgid "Cannot open display: %s" msgstr "No se puede abrir el visor: %s" -#: ../gtk/gtkmain.c:923 +#: ../gtk/gtkmain.c:914 msgid "GTK+ Options" msgstr "Opciones GTK+" -#: ../gtk/gtkmain.c:923 +#: ../gtk/gtkmain.c:914 msgid "Show GTK+ Options" msgstr "Mostrar opciones GTK+" @@ -1411,12 +1411,12 @@ msgstr "Shell Z" msgid "Cannot end process with PID %d: %s" msgstr "No se puede finalizar el proceso con PID %d: %s" -#: ../gtk/gtknotebook.c:4724 ../gtk/gtknotebook.c:7287 +#: ../gtk/gtknotebook.c:4756 ../gtk/gtknotebook.c:7319 #, c-format msgid "Page %u" msgstr "Página %u" -#: ../gtk/gtkpagesetup.c:596 ../gtk/gtkpapersize.c:838 +#: ../gtk/gtkpagesetup.c:648 ../gtk/gtkpapersize.c:838 #: ../gtk/gtkpapersize.c:880 msgid "Not a valid page setup file" msgstr "No es un archivo válido de configuración de página" @@ -1464,15 +1464,15 @@ msgstr "_Orientación:" msgid "Page Setup" msgstr "Configuración de página" -#: ../gtk/gtkpathbar.c:154 +#: ../gtk/gtkpathbar.c:158 msgid "Up Path" msgstr "Ruta superior" -#: ../gtk/gtkpathbar.c:156 +#: ../gtk/gtkpathbar.c:160 msgid "Down Path" msgstr "Ruta inferior" -#: ../gtk/gtkpathbar.c:1490 +#: ../gtk/gtkpathbar.c:1523 msgid "File System Root" msgstr "Sistema de archivos raíz" @@ -2055,15 +2055,15 @@ msgctxt "recent menu label" msgid "%d. %s" msgstr "%d. %s" -#: ../gtk/gtkrecentmanager.c:986 ../gtk/gtkrecentmanager.c:999 -#: ../gtk/gtkrecentmanager.c:1137 ../gtk/gtkrecentmanager.c:1147 -#: ../gtk/gtkrecentmanager.c:1200 ../gtk/gtkrecentmanager.c:1209 -#: ../gtk/gtkrecentmanager.c:1224 +#: ../gtk/gtkrecentmanager.c:1000 ../gtk/gtkrecentmanager.c:1013 +#: ../gtk/gtkrecentmanager.c:1150 ../gtk/gtkrecentmanager.c:1160 +#: ../gtk/gtkrecentmanager.c:1213 ../gtk/gtkrecentmanager.c:1222 +#: ../gtk/gtkrecentmanager.c:1237 #, c-format msgid "Unable to find an item with URI '%s'" msgstr "No se ha podido encontrar un elemento con el URI «%s»" -#: ../gtk/gtkrecentmanager.c:2394 +#: ../gtk/gtkrecentmanager.c:2437 #, c-format msgid "No registered application with name '%s' for item with URI '%s' found" msgstr "" @@ -2585,6 +2585,33 @@ msgctxt "Stock label" msgid "Zoom _Out" msgstr "_Reducir" +#. Translators: if the "on" state label requires more than three +#. * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for +#. * the state +#. +#: ../gtk/gtkswitch.c:297 ../gtk/gtkswitch.c:340 ../gtk/gtkswitch.c:532 +msgctxt "switch" +msgid "ON" +msgstr "ENCENDIDO" + +#. Translators: if the "off" state label requires more than three +#. * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state +#. +#: ../gtk/gtkswitch.c:305 ../gtk/gtkswitch.c:341 ../gtk/gtkswitch.c:553 +msgctxt "switch" +msgid "OFF" +msgstr "APAGADO" + +#: ../gtk/gtkswitch.c:938 +#| msgid "inch" +msgctxt "light switch widget" +msgid "Switch" +msgstr "Interruptor" + +#: ../gtk/gtkswitch.c:939 +msgid "Switches between on and off states" +msgstr "Cambia entre los estados encendido y apagado" + #: ../gtk/gtktextbufferrichtext.c:650 #, c-format msgid "Unknown error when trying to deserialize %s" @@ -2595,108 +2622,108 @@ msgstr "Error desconocido al intentar deserializar %s" msgid "No deserialize function found for format %s" msgstr "No se encontró función de deserialización para el formato %s" -#: ../gtk/gtktextbufferserialize.c:795 ../gtk/gtktextbufferserialize.c:821 +#: ../gtk/gtktextbufferserialize.c:803 ../gtk/gtktextbufferserialize.c:829 #, c-format msgid "Both \"id\" and \"name\" were found on the <%s> element" msgstr "Se encontraron tanto «id» como «name» en el elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:805 ../gtk/gtktextbufferserialize.c:831 +#: ../gtk/gtktextbufferserialize.c:813 ../gtk/gtktextbufferserialize.c:839 #, c-format msgid "The attribute \"%s\" was found twice on the <%s> element" msgstr "Se encontró el atributo «%s» dos veces en el elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:845 +#: ../gtk/gtktextbufferserialize.c:855 #, c-format msgid "<%s> element has invalid ID \"%s\"" msgstr "El elemento <%s> tiene el ID inválido «%s»" -#: ../gtk/gtktextbufferserialize.c:855 +#: ../gtk/gtktextbufferserialize.c:865 #, c-format msgid "<%s> element has neither a \"name\" nor an \"id\" attribute" msgstr "El elemento <%s> no tiene ni un elemento «name» ni un elemento «id»" -#: ../gtk/gtktextbufferserialize.c:942 +#: ../gtk/gtktextbufferserialize.c:952 #, c-format msgid "Attribute \"%s\" repeated twice on the same <%s> element" msgstr "El atributo «%s» se repite dos veces en el mismo elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:960 ../gtk/gtktextbufferserialize.c:985 +#: ../gtk/gtktextbufferserialize.c:970 ../gtk/gtktextbufferserialize.c:995 #, c-format msgid "Attribute \"%s\" is invalid on <%s> element in this context" msgstr "El atributo «%s» es inválido en el elemento <%s> en este contexto" -#: ../gtk/gtktextbufferserialize.c:1024 +#: ../gtk/gtktextbufferserialize.c:1034 #, c-format msgid "Tag \"%s\" has not been defined." msgstr "La etiqueta «%s» no ha sido definida." -#: ../gtk/gtktextbufferserialize.c:1036 +#: ../gtk/gtktextbufferserialize.c:1046 msgid "Anonymous tag found and tags can not be created." msgstr "Se encontró una etiqueta anónima y las etiquetas no se pueden crear." -#: ../gtk/gtktextbufferserialize.c:1047 +#: ../gtk/gtktextbufferserialize.c:1057 #, c-format msgid "Tag \"%s\" does not exist in buffer and tags can not be created." msgstr "" "La etiqueta «%s» no existe en el búfer y las etiquetas no se pueden crear." -#: ../gtk/gtktextbufferserialize.c:1146 ../gtk/gtktextbufferserialize.c:1221 -#: ../gtk/gtktextbufferserialize.c:1324 ../gtk/gtktextbufferserialize.c:1398 +#: ../gtk/gtktextbufferserialize.c:1156 ../gtk/gtktextbufferserialize.c:1231 +#: ../gtk/gtktextbufferserialize.c:1336 ../gtk/gtktextbufferserialize.c:1410 #, c-format msgid "Element <%s> is not allowed below <%s>" msgstr "El elemento <%s» no se permite debajo de <%s>" -#: ../gtk/gtktextbufferserialize.c:1177 +#: ../gtk/gtktextbufferserialize.c:1187 #, c-format msgid "\"%s\" is not a valid attribute type" msgstr "«%s» no es un tipo de atributo válido" -#: ../gtk/gtktextbufferserialize.c:1185 +#: ../gtk/gtktextbufferserialize.c:1195 #, c-format msgid "\"%s\" is not a valid attribute name" msgstr "«%s» no es un nombre de atributo válido" -#: ../gtk/gtktextbufferserialize.c:1195 +#: ../gtk/gtktextbufferserialize.c:1205 #, c-format msgid "" "\"%s\" could not be converted to a value of type \"%s\" for attribute \"%s\"" msgstr "«%s» no se pudo convertir a un valor de tipo «%s»para el atributo «%s»" -#: ../gtk/gtktextbufferserialize.c:1204 +#: ../gtk/gtktextbufferserialize.c:1214 #, c-format msgid "\"%s\" is not a valid value for attribute \"%s\"" msgstr "«%s» no es un valor válido para el atributo «%s»" -#: ../gtk/gtktextbufferserialize.c:1289 +#: ../gtk/gtktextbufferserialize.c:1299 #, c-format msgid "Tag \"%s\" already defined" msgstr "La etiqueta «%s» ya está definida" -#: ../gtk/gtktextbufferserialize.c:1300 +#: ../gtk/gtktextbufferserialize.c:1312 #, c-format msgid "Tag \"%s\" has invalid priority \"%s\"" msgstr "La etiqueta «%s» tiene prioridad «%s» inválida" -#: ../gtk/gtktextbufferserialize.c:1353 +#: ../gtk/gtktextbufferserialize.c:1365 #, c-format msgid "Outermost element in text must be not <%s>" msgstr "" "El elemento más externo en el texto debe ser no <%s>" -#: ../gtk/gtktextbufferserialize.c:1362 ../gtk/gtktextbufferserialize.c:1378 +#: ../gtk/gtktextbufferserialize.c:1374 ../gtk/gtktextbufferserialize.c:1390 #, c-format msgid "A <%s> element has already been specified" msgstr "Ya se ha especificado un elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:1384 +#: ../gtk/gtktextbufferserialize.c:1396 msgid "A element can't occur before a element" msgstr "Un elemento no puede estar antes de un elemento " -#: ../gtk/gtktextbufferserialize.c:1784 +#: ../gtk/gtktextbufferserialize.c:1796 msgid "Serialized data is malformed" msgstr "Los datos serializados están mal formados" -#: ../gtk/gtktextbufferserialize.c:1862 +#: ../gtk/gtktextbufferserialize.c:1874 msgid "" "Serialized data is malformed. First section isn't GTKTEXTBUFFERCONTENTS-0001" msgstr "" @@ -3656,81 +3683,81 @@ msgstr "No se ha podido escribir el índice de la carpeta\n" msgid "Failed to rewrite header\n" msgstr "No se ha podido reescribir la cabecera\n" -#: ../gtk/updateiconcache.c:1463 +#: ../gtk/updateiconcache.c:1488 #, c-format msgid "Failed to open file %s : %s\n" msgstr "No se ha podido abrir el archivo «%s»: %s\n" -#: ../gtk/updateiconcache.c:1471 +#: ../gtk/updateiconcache.c:1496 ../gtk/updateiconcache.c:1526 #, c-format msgid "Failed to write cache file: %s\n" msgstr "No se ha podido escribir el archivo de caché: %s\n" -#: ../gtk/updateiconcache.c:1507 +#: ../gtk/updateiconcache.c:1537 #, c-format msgid "The generated cache was invalid.\n" msgstr "La caché generada no es válida.\n" -#: ../gtk/updateiconcache.c:1521 +#: ../gtk/updateiconcache.c:1551 #, c-format msgid "Could not rename %s to %s: %s, removing %s then.\n" msgstr "No se pudo renombrar %s a %s: %s, eliminando %s entonces.\n" -#: ../gtk/updateiconcache.c:1535 +#: ../gtk/updateiconcache.c:1565 #, c-format msgid "Could not rename %s to %s: %s\n" msgstr "No se pudo renombrar %s a %s: %s\n" -#: ../gtk/updateiconcache.c:1545 +#: ../gtk/updateiconcache.c:1575 #, c-format msgid "Could not rename %s back to %s: %s.\n" msgstr "No se pudo renombrar %s de nuevo a %s: %s.\n" -#: ../gtk/updateiconcache.c:1572 +#: ../gtk/updateiconcache.c:1602 #, c-format msgid "Cache file created successfully.\n" msgstr "Archivo de caché creado con éxito.\n" -#: ../gtk/updateiconcache.c:1611 +#: ../gtk/updateiconcache.c:1641 msgid "Overwrite an existing cache, even if up to date" msgstr "Sobreescribir un caché existente, incluso si está actualizado" -#: ../gtk/updateiconcache.c:1612 +#: ../gtk/updateiconcache.c:1642 msgid "Don't check for the existence of index.theme" msgstr "No comprobar la existencia de index.theme" -#: ../gtk/updateiconcache.c:1613 +#: ../gtk/updateiconcache.c:1643 msgid "Don't include image data in the cache" msgstr "No incluir los datos de la imagen en el caché" -#: ../gtk/updateiconcache.c:1614 +#: ../gtk/updateiconcache.c:1644 msgid "Output a C header file" msgstr "Sacar un archivo de cabecera C" -#: ../gtk/updateiconcache.c:1615 +#: ../gtk/updateiconcache.c:1645 msgid "Turn off verbose output" msgstr "Desactivar la salida prolija" -#: ../gtk/updateiconcache.c:1616 +#: ../gtk/updateiconcache.c:1646 msgid "Validate existing icon cache" msgstr "Validar la caché de iconos existente" -#: ../gtk/updateiconcache.c:1683 +#: ../gtk/updateiconcache.c:1713 #, c-format msgid "File not found: %s\n" msgstr "Archivo no encontrado: %s\n" -#: ../gtk/updateiconcache.c:1689 +#: ../gtk/updateiconcache.c:1719 #, c-format msgid "Not a valid icon cache: %s\n" msgstr "No es una caché de iconos válida: %s\n" -#: ../gtk/updateiconcache.c:1702 +#: ../gtk/updateiconcache.c:1732 #, c-format msgid "No theme index file.\n" msgstr "No existe el archivo índice del tema.\n" -#: ../gtk/updateiconcache.c:1706 +#: ../gtk/updateiconcache.c:1736 #, c-format msgid "" "No theme index file in '%s'.\n" @@ -4148,32 +4175,32 @@ msgstr "Personalizado %sx%s" msgid "output.%s" msgstr "salida.%s" -#: ../modules/printbackends/file/gtkprintbackendfile.c:493 +#: ../modules/printbackends/file/gtkprintbackendfile.c:501 msgid "Print to File" msgstr "Imprimir a un archivo" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "PDF" msgstr "PDF" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "Postscript" msgstr "Postscript" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "SVG" msgstr "SVG" -#: ../modules/printbackends/file/gtkprintbackendfile.c:582 +#: ../modules/printbackends/file/gtkprintbackendfile.c:590 #: ../modules/printbackends/test/gtkprintbackendtest.c:503 msgid "Pages per _sheet:" msgstr "Páginas por _hoja:" -#: ../modules/printbackends/file/gtkprintbackendfile.c:641 +#: ../modules/printbackends/file/gtkprintbackendfile.c:649 msgid "File" msgstr "Archivo" -#: ../modules/printbackends/file/gtkprintbackendfile.c:651 +#: ../modules/printbackends/file/gtkprintbackendfile.c:659 msgid "_Output format" msgstr "Formato de _salida" From 86390c99dd885dd729e3634ab7aa78646cc4e230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gonz=C3=A1lez?= Date: Thu, 2 Dec 2010 19:28:16 +0100 Subject: [PATCH 003/634] Updated Spanish translation --- po-properties/es.po | 2395 ++++++++++++++++++++++--------------------- 1 file changed, 1205 insertions(+), 1190 deletions(-) diff --git a/po-properties/es.po b/po-properties/es.po index 70db01e403..be287b4698 100644 --- a/po-properties/es.po +++ b/po-properties/es.po @@ -17,8 +17,8 @@ msgstr "" "Project-Id-Version: gtk+-properties.master\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gtk" "%2b&component=general\n" -"POT-Creation-Date: 2010-10-25 09:20+0000\n" -"PO-Revision-Date: 2010-10-25 16:25+0200\n" +"POT-Creation-Date: 2010-11-30 05:33+0000\n" +"PO-Revision-Date: 2010-12-02 19:09+0100\n" "Last-Translator: Jorge González \n" "Language-Team: Español \n" "MIME-Version: 1.0\n" @@ -28,64 +28,64 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: KBabel 1.11.4\n" -#: ../gdk/gdkdevice.c:99 +#: ../gdk/gdkdevice.c:113 msgid "Device Display" msgstr "Pantalla del dispositivo" -#: ../gdk/gdkdevice.c:100 +#: ../gdk/gdkdevice.c:114 msgid "Display which the device belongs to" msgstr "Pantalla a la que pertenece el dispositivo" -#: ../gdk/gdkdevice.c:114 +#: ../gdk/gdkdevice.c:128 msgid "Device manager" msgstr "Gestor de dispositivos" -#: ../gdk/gdkdevice.c:115 +#: ../gdk/gdkdevice.c:129 msgid "Device manager which the device belongs to" msgstr "Gestor de dispositivos al que pertenece el dispositivo" -#: ../gdk/gdkdevice.c:129 ../gdk/gdkdevice.c:130 +#: ../gdk/gdkdevice.c:143 ../gdk/gdkdevice.c:144 msgid "Device name" msgstr "Nombre del dispositivo" -#: ../gdk/gdkdevice.c:144 +#: ../gdk/gdkdevice.c:158 msgid "Device type" msgstr "Tipo de dispositivo" -#: ../gdk/gdkdevice.c:145 +#: ../gdk/gdkdevice.c:159 msgid "Device role in the device manager" msgstr "Rol del dispositivo en el gestor de dispositivos" -#: ../gdk/gdkdevice.c:161 +#: ../gdk/gdkdevice.c:175 msgid "Associated device" msgstr "Dispositivo asociado" -#: ../gdk/gdkdevice.c:162 +#: ../gdk/gdkdevice.c:176 msgid "Associated pointer or keyboard with this device" msgstr "Dispositivo apuntador o teclado asociado con este dispositivo" -#: ../gdk/gdkdevice.c:175 +#: ../gdk/gdkdevice.c:189 msgid "Input source" msgstr "Fuente de entrada" -#: ../gdk/gdkdevice.c:176 +#: ../gdk/gdkdevice.c:190 msgid "Source type for the device" msgstr "Tipo de la fuente de entrada para el dispositivo" -#: ../gdk/gdkdevice.c:191 ../gdk/gdkdevice.c:192 +#: ../gdk/gdkdevice.c:205 ../gdk/gdkdevice.c:206 msgid "Input mode for the device" msgstr "Modo de entrada para el dispositivo" -#: ../gdk/gdkdevice.c:207 +#: ../gdk/gdkdevice.c:221 msgid "Whether the device has a cursor" msgstr "Indica si el dispositivo tiene un cursor" -#: ../gdk/gdkdevice.c:208 +#: ../gdk/gdkdevice.c:222 msgid "Whether there is a visible cursor following device motion" msgstr "" "Indica si existe un cursor disponible siguiendo el movimiento del dispositivo" -#: ../gdk/gdkdevice.c:222 ../gdk/gdkdevice.c:223 +#: ../gdk/gdkdevice.c:236 ../gdk/gdkdevice.c:237 msgid "Number of axes in the device" msgstr "Número de ejes en el dispositivo" @@ -97,27 +97,27 @@ msgstr "Pantalla" msgid "Display for the device manager" msgstr "Pantalla para el gestor de dispositivos" -#: ../gdk/gdkdisplaymanager.c:101 +#: ../gdk/gdkdisplaymanager.c:106 msgid "Default Display" msgstr "Visor predeterminado" -#: ../gdk/gdkdisplaymanager.c:102 +#: ../gdk/gdkdisplaymanager.c:107 msgid "The default display for GDK" msgstr "El visor predeterminado para GDK" -#: ../gdk/gdkscreen.c:74 +#: ../gdk/gdkscreen.c:90 msgid "Font options" msgstr "Opciones de la tipografía" -#: ../gdk/gdkscreen.c:75 +#: ../gdk/gdkscreen.c:91 msgid "The default font options for the screen" msgstr "Las opciones predeterminadas de la tipografía para la pantalla" -#: ../gdk/gdkscreen.c:82 +#: ../gdk/gdkscreen.c:98 msgid "Font resolution" msgstr "Resolución de la tipografía" -#: ../gdk/gdkscreen.c:83 +#: ../gdk/gdkscreen.c:99 msgid "The resolution for fonts on the screen" msgstr "La resolución para las tipografías en la pantalla" @@ -294,9 +294,9 @@ msgstr "Nombre" msgid "A unique name for the action." msgstr "Un nombre único para la acción." -#: ../gtk/gtkaction.c:241 ../gtk/gtkbutton.c:238 ../gtk/gtkexpander.c:209 -#: ../gtk/gtkframe.c:130 ../gtk/gtklabel.c:549 ../gtk/gtkmenuitem.c:331 -#: ../gtk/gtktoolbutton.c:202 ../gtk/gtktoolitemgroup.c:1571 +#: ../gtk/gtkaction.c:241 ../gtk/gtkbutton.c:226 ../gtk/gtkexpander.c:209 +#: ../gtk/gtkframe.c:130 ../gtk/gtklabel.c:567 ../gtk/gtkmenuitem.c:331 +#: ../gtk/gtktoolbutton.c:202 ../gtk/gtktoolitemgroup.c:1588 msgid "Label" msgstr "Etiqueta" @@ -338,26 +338,26 @@ msgid "GIcon" msgstr "GIcon" #: ../gtk/gtkaction.c:305 ../gtk/gtkcellrendererpixbuf.c:215 -#: ../gtk/gtkimage.c:320 ../gtk/gtkstatusicon.c:253 +#: ../gtk/gtkimage.c:326 ../gtk/gtkstatusicon.c:253 msgid "The GIcon being displayed" msgstr "El icono mostrado" #: ../gtk/gtkaction.c:325 ../gtk/gtkcellrendererpixbuf.c:180 -#: ../gtk/gtkimage.c:302 ../gtk/gtkprinter.c:174 ../gtk/gtkstatusicon.c:236 -#: ../gtk/gtkwindow.c:732 +#: ../gtk/gtkimage.c:308 ../gtk/gtkprinter.c:174 ../gtk/gtkstatusicon.c:236 +#: ../gtk/gtkwindow.c:733 msgid "Icon Name" msgstr "Nombre del icono" #: ../gtk/gtkaction.c:326 ../gtk/gtkcellrendererpixbuf.c:181 -#: ../gtk/gtkimage.c:303 ../gtk/gtkstatusicon.c:237 +#: ../gtk/gtkimage.c:309 ../gtk/gtkstatusicon.c:237 msgid "The name of the icon from the icon theme" msgstr "El nombre del icono del tema de iconos" -#: ../gtk/gtkaction.c:333 ../gtk/gtktoolitem.c:186 +#: ../gtk/gtkaction.c:333 ../gtk/gtktoolitem.c:195 msgid "Visible when horizontal" msgstr "Visible si es horizontal" -#: ../gtk/gtkaction.c:334 ../gtk/gtktoolitem.c:187 +#: ../gtk/gtkaction.c:334 ../gtk/gtktoolitem.c:196 msgid "" "Whether the toolbar item is visible when the toolbar is in a horizontal " "orientation." @@ -377,11 +377,11 @@ msgstr "" "Cuando sea TRUE, se representan elementos de proximidad para esta acción en " "el menú de rebosamiento de la barra de herramientas." -#: ../gtk/gtkaction.c:357 ../gtk/gtktoolitem.c:193 +#: ../gtk/gtkaction.c:357 ../gtk/gtktoolitem.c:202 msgid "Visible when vertical" msgstr "Visible si es vertical" -#: ../gtk/gtkaction.c:358 ../gtk/gtktoolitem.c:194 +#: ../gtk/gtkaction.c:358 ../gtk/gtktoolitem.c:203 msgid "" "Whether the toolbar item is visible when the toolbar is in a vertical " "orientation." @@ -389,7 +389,7 @@ msgstr "" "Indica si el elemento de la barra de herramientas es visible cuando la barra " "esté en orientación vertical." -#: ../gtk/gtkaction.c:365 ../gtk/gtktoolitem.c:200 +#: ../gtk/gtkaction.c:365 ../gtk/gtktoolitem.c:209 msgid "Is important" msgstr "Es importante" @@ -413,7 +413,7 @@ msgstr "" "acción se ocultan." #: ../gtk/gtkaction.c:381 ../gtk/gtkactiongroup.c:235 -#: ../gtk/gtkcellrenderer.c:243 ../gtk/gtkwidget.c:975 +#: ../gtk/gtkcellrenderer.c:282 ../gtk/gtkwidget.c:916 msgid "Sensitive" msgstr "Sensible" @@ -423,7 +423,7 @@ msgstr "Indica si la acción está activada." #: ../gtk/gtkaction.c:388 ../gtk/gtkactiongroup.c:242 #: ../gtk/gtkstatusicon.c:287 ../gtk/gtktreeviewcolumn.c:213 -#: ../gtk/gtkwidget.c:968 +#: ../gtk/gtkwidget.c:909 msgid "Visible" msgstr "Visible" @@ -443,11 +443,11 @@ msgstr "" "El GtkActionGroup con el que esta GtkAction está asociada, o NULL (para uso " "interno)." -#: ../gtk/gtkaction.c:414 ../gtk/gtkimagemenuitem.c:172 +#: ../gtk/gtkaction.c:414 ../gtk/gtkimagemenuitem.c:182 msgid "Always show image" msgstr "Siempre mostrar la imagen" -#: ../gtk/gtkaction.c:415 ../gtk/gtkimagemenuitem.c:173 +#: ../gtk/gtkaction.c:415 ../gtk/gtkimagemenuitem.c:183 msgid "Whether the image will always be shown" msgstr "Indica si la imagen se mostrará siempre" @@ -483,7 +483,7 @@ msgstr "" "relacionadas" #: ../gtk/gtkadjustment.c:114 ../gtk/gtkcellrendererprogress.c:126 -#: ../gtk/gtkscalebutton.c:220 ../gtk/gtkspinbutton.c:289 +#: ../gtk/gtkscalebutton.c:220 ../gtk/gtkspinbutton.c:291 msgid "Value" msgstr "Valor" @@ -535,7 +535,7 @@ msgstr "El tamaño de página del ajuste" msgid "Horizontal alignment" msgstr "Alineación horizontal" -#: ../gtk/gtkalignment.c:128 ../gtk/gtkbutton.c:289 +#: ../gtk/gtkalignment.c:128 ../gtk/gtkbutton.c:277 msgid "" "Horizontal position of child in available space. 0.0 is left aligned, 1.0 is " "right aligned" @@ -547,7 +547,7 @@ msgstr "" msgid "Vertical alignment" msgstr "Alineación vertical" -#: ../gtk/gtkalignment.c:138 ../gtk/gtkbutton.c:308 +#: ../gtk/gtkalignment.c:138 ../gtk/gtkbutton.c:296 msgid "" "Vertical position of child in available space. 0.0 is top aligned, 1.0 is " "bottom aligned" @@ -627,7 +627,7 @@ msgstr "Sombra de la flecha" msgid "Appearance of the shadow surrounding the arrow" msgstr "Apariencia de la sombra que rodea la flecha" -#: ../gtk/gtkarrow.c:127 ../gtk/gtkmenu.c:730 ../gtk/gtkmenuitem.c:394 +#: ../gtk/gtkarrow.c:127 ../gtk/gtkmenu.c:731 ../gtk/gtkmenuitem.c:394 msgid "Arrow Scaling" msgstr "Escalado de flechas" @@ -635,7 +635,7 @@ msgstr "Escalado de flechas" msgid "Amount of space used up by arrow" msgstr "Cantidad de espacio ocupado por flecha" -#: ../gtk/gtkaspectframe.c:109 ../gtk/gtkwidget.c:1171 +#: ../gtk/gtkaspectframe.c:109 ../gtk/gtkwidget.c:1112 msgid "Horizontal Alignment" msgstr "Alineación horizontal" @@ -643,7 +643,7 @@ msgstr "Alineación horizontal" msgid "X alignment of the child" msgstr "Alineación X del hijo" -#: ../gtk/gtkaspectframe.c:116 ../gtk/gtkwidget.c:1187 +#: ../gtk/gtkaspectframe.c:116 ../gtk/gtkwidget.c:1128 msgid "Vertical Alignment" msgstr "Alineación vertical" @@ -667,100 +667,100 @@ msgstr "Obedecer al hijo" msgid "Force aspect ratio to match that of the frame's child" msgstr "Forzar la proporción para que coincida con el hijo del marco" -#: ../gtk/gtkassistant.c:310 +#: ../gtk/gtkassistant.c:327 msgid "Header Padding" msgstr "Separación de la cabecera" -#: ../gtk/gtkassistant.c:311 +#: ../gtk/gtkassistant.c:328 msgid "Number of pixels around the header." msgstr "Número de píxeles alrededor de la cabecera." -#: ../gtk/gtkassistant.c:318 +#: ../gtk/gtkassistant.c:335 msgid "Content Padding" msgstr "Separación del contenido" -#: ../gtk/gtkassistant.c:319 +#: ../gtk/gtkassistant.c:336 msgid "Number of pixels around the content pages." msgstr "Número de píxeles alrededor de las páginas de contenidos." -#: ../gtk/gtkassistant.c:335 +#: ../gtk/gtkassistant.c:352 msgid "Page type" msgstr "Tipo de página" -#: ../gtk/gtkassistant.c:336 +#: ../gtk/gtkassistant.c:353 msgid "The type of the assistant page" msgstr "El tipo de página del asistente" -#: ../gtk/gtkassistant.c:353 +#: ../gtk/gtkassistant.c:370 msgid "Page title" msgstr "Título de página" -#: ../gtk/gtkassistant.c:354 +#: ../gtk/gtkassistant.c:371 msgid "The title of the assistant page" msgstr "El título de la página del asistente" -#: ../gtk/gtkassistant.c:370 +#: ../gtk/gtkassistant.c:387 msgid "Header image" msgstr "Imagen de la cabecera" -#: ../gtk/gtkassistant.c:371 +#: ../gtk/gtkassistant.c:388 msgid "Header image for the assistant page" msgstr "Imagen de la cabecera para la página del asistente" -#: ../gtk/gtkassistant.c:387 +#: ../gtk/gtkassistant.c:404 msgid "Sidebar image" msgstr "Imagen de barra lateral" -#: ../gtk/gtkassistant.c:388 +#: ../gtk/gtkassistant.c:405 msgid "Sidebar image for the assistant page" msgstr "Imagen de barra lateral para la página del asistente" -#: ../gtk/gtkassistant.c:403 +#: ../gtk/gtkassistant.c:420 msgid "Page complete" msgstr "Página completa" -#: ../gtk/gtkassistant.c:404 +#: ../gtk/gtkassistant.c:421 msgid "Whether all required fields on the page have been filled out" msgstr "Indica si todos los campos requeridos en la página se han rellenado" -#: ../gtk/gtkbbox.c:135 +#: ../gtk/gtkbbox.c:152 msgid "Minimum child width" msgstr "Anchura mínima del hijo" -#: ../gtk/gtkbbox.c:136 +#: ../gtk/gtkbbox.c:153 msgid "Minimum width of buttons inside the box" msgstr "Anchura mínima de los botones dentro de la caja" -#: ../gtk/gtkbbox.c:144 +#: ../gtk/gtkbbox.c:161 msgid "Minimum child height" msgstr "Altura mínima del hijo" -#: ../gtk/gtkbbox.c:145 +#: ../gtk/gtkbbox.c:162 msgid "Minimum height of buttons inside the box" msgstr "Altura mínima de los botones dentro de la caja" -#: ../gtk/gtkbbox.c:153 +#: ../gtk/gtkbbox.c:170 msgid "Child internal width padding" msgstr "Anchura interna de relleno del hijo" -#: ../gtk/gtkbbox.c:154 +#: ../gtk/gtkbbox.c:171 msgid "Amount to increase child's size on either side" msgstr "Cantidad en la que se incrementa el tamaño del hijo por cada lado" -#: ../gtk/gtkbbox.c:162 +#: ../gtk/gtkbbox.c:179 msgid "Child internal height padding" msgstr "Altura interna de relleno del hijo" -#: ../gtk/gtkbbox.c:163 +#: ../gtk/gtkbbox.c:180 msgid "Amount to increase child's size on the top and bottom" msgstr "" "Cantidad en la que se incrementa el tamaño del hijo por arriba y por abajo" -#: ../gtk/gtkbbox.c:171 +#: ../gtk/gtkbbox.c:188 msgid "Layout style" msgstr "Estilo de la distribución" -#: ../gtk/gtkbbox.c:172 +#: ../gtk/gtkbbox.c:189 msgid "" "How to lay out the buttons in the box. Possible values are: spread, edge, " "start and end" @@ -768,11 +768,11 @@ msgstr "" "Como disponer los botones en la caja. Los valores posibles son: esparcidos, " "esquinas, inicio y final" -#: ../gtk/gtkbbox.c:180 +#: ../gtk/gtkbbox.c:197 msgid "Secondary" msgstr "Secundario" -#: ../gtk/gtkbbox.c:181 +#: ../gtk/gtkbbox.c:198 msgid "" "If TRUE, the child appears in a secondary group of children, suitable for, e." "g., help buttons" @@ -780,34 +780,34 @@ msgstr "" "Si es TRUE, el hijo aparece en un grupo secundario de hijos, apropiado para, " "por ejemplo, botones de ayuda" -#: ../gtk/gtkbox.c:237 ../gtk/gtkexpander.c:233 ../gtk/gtkiconview.c:684 +#: ../gtk/gtkbox.c:241 ../gtk/gtkexpander.c:233 ../gtk/gtkiconview.c:696 #: ../gtk/gtktreeviewcolumn.c:238 msgid "Spacing" msgstr "Espaciado" -#: ../gtk/gtkbox.c:238 +#: ../gtk/gtkbox.c:242 msgid "The amount of space between children" msgstr "La cantidad de espacio entre hijos" -#: ../gtk/gtkbox.c:247 ../gtk/gtktable.c:188 ../gtk/gtktoolbar.c:547 -#: ../gtk/gtktoolitemgroup.c:1624 +#: ../gtk/gtkbox.c:251 ../gtk/gtktable.c:193 ../gtk/gtktoolbar.c:553 +#: ../gtk/gtktoolitemgroup.c:1641 msgid "Homogeneous" msgstr "Homogéneo" -#: ../gtk/gtkbox.c:248 +#: ../gtk/gtkbox.c:252 msgid "Whether the children should all be the same size" msgstr "Indica si todos los hijos deben ser del mismo tamaño" -#: ../gtk/gtkbox.c:264 ../gtk/gtktoolbar.c:539 ../gtk/gtktoolitemgroup.c:1631 -#: ../gtk/gtktoolpalette.c:1038 ../gtk/gtktreeviewcolumn.c:294 +#: ../gtk/gtkbox.c:268 ../gtk/gtktoolbar.c:545 ../gtk/gtktoolitemgroup.c:1648 +#: ../gtk/gtktoolpalette.c:1092 ../gtk/gtktreeviewcolumn.c:294 msgid "Expand" msgstr "Expandir" -#: ../gtk/gtkbox.c:265 +#: ../gtk/gtkbox.c:269 msgid "Whether the child should receive extra space when the parent grows" msgstr "Indica si el hijo debe recibir espacio extra cuando el padre crece" -#: ../gtk/gtkbox.c:281 ../gtk/gtktoolitemgroup.c:1638 +#: ../gtk/gtkbox.c:281 ../gtk/gtktoolitemgroup.c:1655 msgid "Fill" msgstr "Relleno" @@ -831,7 +831,7 @@ msgstr "Espacio extra para colocar entre el hijo y sus vecinos, en píxeles" msgid "Pack type" msgstr "Tipo de empaquetado" -#: ../gtk/gtkbox.c:297 ../gtk/gtknotebook.c:786 +#: ../gtk/gtkbox.c:297 ../gtk/gtknotebook.c:793 msgid "" "A GtkPackType indicating whether the child is packed with reference to the " "start or end of the parent" @@ -839,12 +839,12 @@ msgstr "" "Un GtkPackType que indica si el hijo está empaquetado con referencia al " "inicio o el final del padre" -#: ../gtk/gtkbox.c:303 ../gtk/gtknotebook.c:757 ../gtk/gtkpaned.c:271 -#: ../gtk/gtkruler.c:158 ../gtk/gtktoolitemgroup.c:1652 +#: ../gtk/gtkbox.c:303 ../gtk/gtknotebook.c:764 ../gtk/gtkpaned.c:327 +#: ../gtk/gtktoolitemgroup.c:1669 msgid "Position" msgstr "Posición" -#: ../gtk/gtkbox.c:304 ../gtk/gtknotebook.c:758 +#: ../gtk/gtkbox.c:304 ../gtk/gtknotebook.c:765 msgid "The index of the child in the parent" msgstr "El índice del hijo en el padre" @@ -856,7 +856,7 @@ msgstr "Dominio de traducción" msgid "The translation domain used by gettext" msgstr "El dominio de traducción que usa gettext" -#: ../gtk/gtkbutton.c:239 +#: ../gtk/gtkbutton.c:227 msgid "" "Text of the label widget inside the button, if the button contains a label " "widget" @@ -864,12 +864,12 @@ msgstr "" "Texto del etiqueta del widget dentro del botón, si el botón contiene una " "etiqueta del widget" -#: ../gtk/gtkbutton.c:246 ../gtk/gtkexpander.c:217 ../gtk/gtklabel.c:570 +#: ../gtk/gtkbutton.c:234 ../gtk/gtkexpander.c:217 ../gtk/gtklabel.c:588 #: ../gtk/gtkmenuitem.c:346 ../gtk/gtktoolbutton.c:209 msgid "Use underline" msgstr "Utilizar subrayado" -#: ../gtk/gtkbutton.c:247 ../gtk/gtkexpander.c:218 ../gtk/gtklabel.c:571 +#: ../gtk/gtkbutton.c:235 ../gtk/gtkexpander.c:218 ../gtk/gtklabel.c:589 #: ../gtk/gtkmenuitem.c:347 msgid "" "If set, an underline in the text indicates the next character should be used " @@ -878,71 +878,71 @@ msgstr "" "Si se establece, un subrayado en el texto indica que el siguiente carácter " "se utiliza como el nemotécnico de la teclas aceleradora" -#: ../gtk/gtkbutton.c:254 ../gtk/gtkimagemenuitem.c:153 +#: ../gtk/gtkbutton.c:242 ../gtk/gtkimagemenuitem.c:163 msgid "Use stock" msgstr "Usar inventario" -#: ../gtk/gtkbutton.c:255 +#: ../gtk/gtkbutton.c:243 msgid "" "If set, the label is used to pick a stock item instead of being displayed" msgstr "" "Si se selecciona, la etiqueta se utiliza para tomar un elemento del " "inventario en vez de para mostrarse" -#: ../gtk/gtkbutton.c:262 ../gtk/gtkcombobox.c:861 +#: ../gtk/gtkbutton.c:250 ../gtk/gtkcombobox.c:865 #: ../gtk/gtkfilechooserbutton.c:383 msgid "Focus on click" msgstr "Enfocar al pulsar" -#: ../gtk/gtkbutton.c:263 ../gtk/gtkfilechooserbutton.c:384 +#: ../gtk/gtkbutton.c:251 ../gtk/gtkfilechooserbutton.c:384 msgid "Whether the button grabs focus when it is clicked with the mouse" msgstr "Indica si el botón obtiene el foco al ser pulsado con el ratón" -#: ../gtk/gtkbutton.c:270 +#: ../gtk/gtkbutton.c:258 msgid "Border relief" msgstr "Relieve del borde" -#: ../gtk/gtkbutton.c:271 +#: ../gtk/gtkbutton.c:259 msgid "The border relief style" msgstr "Estilo del relieve del borde" -#: ../gtk/gtkbutton.c:288 +#: ../gtk/gtkbutton.c:276 msgid "Horizontal alignment for child" msgstr "Alineación horizontal para el hijo" -#: ../gtk/gtkbutton.c:307 +#: ../gtk/gtkbutton.c:295 msgid "Vertical alignment for child" msgstr "Alineación vertical para el hijo" -#: ../gtk/gtkbutton.c:324 ../gtk/gtkimagemenuitem.c:138 +#: ../gtk/gtkbutton.c:312 ../gtk/gtkimagemenuitem.c:148 msgid "Image widget" msgstr "Widget de imagen" -#: ../gtk/gtkbutton.c:325 +#: ../gtk/gtkbutton.c:313 msgid "Child widget to appear next to the button text" msgstr "Widget hijo que aparece al lado del texto del botón" -#: ../gtk/gtkbutton.c:339 +#: ../gtk/gtkbutton.c:327 msgid "Image position" msgstr "Posición de la imagen" -#: ../gtk/gtkbutton.c:340 +#: ../gtk/gtkbutton.c:328 msgid "The position of the image relative to the text" msgstr "Posición de la imagen relativa al texto" -#: ../gtk/gtkbutton.c:460 +#: ../gtk/gtkbutton.c:448 msgid "Default Spacing" msgstr "Espaciado predeterminado" -#: ../gtk/gtkbutton.c:461 +#: ../gtk/gtkbutton.c:449 msgid "Extra space to add for GTK_CAN_DEFAULT buttons" msgstr "Espacio adicional que añadir para los botones CAN_DEFAULT" -#: ../gtk/gtkbutton.c:475 +#: ../gtk/gtkbutton.c:463 msgid "Default Outside Spacing" msgstr "Espaciado exterior predeterminado" -#: ../gtk/gtkbutton.c:476 +#: ../gtk/gtkbutton.c:464 msgid "" "Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside " "the border" @@ -950,31 +950,31 @@ msgstr "" "Espacio adicional que añadir para los botones CAN_DEFAULT que se dibuja " "siempre fuera del borde" -#: ../gtk/gtkbutton.c:481 +#: ../gtk/gtkbutton.c:469 msgid "Child X Displacement" msgstr "Desplazamiento X del hijo" -#: ../gtk/gtkbutton.c:482 +#: ../gtk/gtkbutton.c:470 msgid "" "How far in the x direction to move the child when the button is depressed" msgstr "" "Cuánta distancia en la dirección x se mueve el hijo cuando se suelta el botón" -#: ../gtk/gtkbutton.c:489 +#: ../gtk/gtkbutton.c:477 msgid "Child Y Displacement" msgstr "Desplazamiento Y del hijo" -#: ../gtk/gtkbutton.c:490 +#: ../gtk/gtkbutton.c:478 msgid "" "How far in the y direction to move the child when the button is depressed" msgstr "" "Cuánta distancia en la dirección y se mueve el hijo cuando se suelta el botón" -#: ../gtk/gtkbutton.c:506 +#: ../gtk/gtkbutton.c:494 msgid "Displace focus" msgstr "Desplazar el foco" -#: ../gtk/gtkbutton.c:507 +#: ../gtk/gtkbutton.c:495 msgid "" "Whether the child_displacement_x/_y properties should also affect the focus " "rectangle" @@ -982,43 +982,43 @@ msgstr "" "Indica si las propiedades child_displacement_x/_y deben afectar también al " "rectángulo del foco" -#: ../gtk/gtkbutton.c:520 ../gtk/gtkentry.c:695 ../gtk/gtkentry.c:1740 +#: ../gtk/gtkbutton.c:508 ../gtk/gtkentry.c:786 ../gtk/gtkentry.c:1831 msgid "Inner Border" msgstr "Borde interior" -#: ../gtk/gtkbutton.c:521 +#: ../gtk/gtkbutton.c:509 msgid "Border between button edges and child." msgstr "Borde entre los bordes del botón y el hijo." -#: ../gtk/gtkbutton.c:534 +#: ../gtk/gtkbutton.c:522 msgid "Image spacing" msgstr "Espaciado de imagen" -#: ../gtk/gtkbutton.c:535 +#: ../gtk/gtkbutton.c:523 msgid "Spacing in pixels between the image and label" msgstr "Espaciado en píxeles entre la imagen y la etiqueta" -#: ../gtk/gtkcalendar.c:470 +#: ../gtk/gtkcalendar.c:475 msgid "Year" msgstr "Año" -#: ../gtk/gtkcalendar.c:471 +#: ../gtk/gtkcalendar.c:476 msgid "The selected year" msgstr "El año seleccionado" -#: ../gtk/gtkcalendar.c:484 +#: ../gtk/gtkcalendar.c:489 msgid "Month" msgstr "Mes" -#: ../gtk/gtkcalendar.c:485 +#: ../gtk/gtkcalendar.c:490 msgid "The selected month (as a number between 0 and 11)" msgstr "El mes seleccionado (como un número entre 0 y 11)" -#: ../gtk/gtkcalendar.c:499 +#: ../gtk/gtkcalendar.c:504 msgid "Day" msgstr "Día" -#: ../gtk/gtkcalendar.c:500 +#: ../gtk/gtkcalendar.c:505 msgid "" "The selected day (as a number between 1 and 31, or 0 to unselect the " "currently selected day)" @@ -1026,83 +1026,83 @@ msgstr "" "El día seleccionado (como un número entre 1 y 31, o 0 para deseleccionar el " "día actualmente seleccionado)" -#: ../gtk/gtkcalendar.c:514 +#: ../gtk/gtkcalendar.c:519 msgid "Show Heading" msgstr "Mostrar cabecera" -#: ../gtk/gtkcalendar.c:515 +#: ../gtk/gtkcalendar.c:520 msgid "If TRUE, a heading is displayed" msgstr "Si es TRUE, se muestra una cabecera" -#: ../gtk/gtkcalendar.c:529 +#: ../gtk/gtkcalendar.c:534 msgid "Show Day Names" msgstr "Mostrar nombres de los días" -#: ../gtk/gtkcalendar.c:530 +#: ../gtk/gtkcalendar.c:535 msgid "If TRUE, day names are displayed" msgstr "Si es TRUE, se muestran los nombres de los días" -#: ../gtk/gtkcalendar.c:543 +#: ../gtk/gtkcalendar.c:548 msgid "No Month Change" msgstr "Sin cambio de mes" -#: ../gtk/gtkcalendar.c:544 +#: ../gtk/gtkcalendar.c:549 msgid "If TRUE, the selected month cannot be changed" msgstr "Si es TRUE, el mes seleccionado no puede cambiarse" -#: ../gtk/gtkcalendar.c:558 +#: ../gtk/gtkcalendar.c:563 msgid "Show Week Numbers" msgstr "Mostrar números de las semanas" -#: ../gtk/gtkcalendar.c:559 +#: ../gtk/gtkcalendar.c:564 msgid "If TRUE, week numbers are displayed" msgstr "Si es TRUE, se muestran los números de las semanas" -#: ../gtk/gtkcalendar.c:574 +#: ../gtk/gtkcalendar.c:579 msgid "Details Width" msgstr "Detalles de la anchura" -#: ../gtk/gtkcalendar.c:575 +#: ../gtk/gtkcalendar.c:580 msgid "Details width in characters" msgstr "Detalla la anchura en los caracteres" -#: ../gtk/gtkcalendar.c:590 +#: ../gtk/gtkcalendar.c:595 msgid "Details Height" msgstr "Detalles de la altura" -#: ../gtk/gtkcalendar.c:591 +#: ../gtk/gtkcalendar.c:596 msgid "Details height in rows" msgstr "Detalla la altura en las filas" -#: ../gtk/gtkcalendar.c:607 +#: ../gtk/gtkcalendar.c:612 msgid "Show Details" msgstr "Mostrar detalles" -#: ../gtk/gtkcalendar.c:608 +#: ../gtk/gtkcalendar.c:613 msgid "If TRUE, details are shown" msgstr "Si es TRUE, se muestran los detalles" -#: ../gtk/gtkcalendar.c:620 +#: ../gtk/gtkcalendar.c:625 msgid "Inner border" msgstr "Borde interior" -#: ../gtk/gtkcalendar.c:621 +#: ../gtk/gtkcalendar.c:626 msgid "Inner border space" msgstr "Espacio del borde interior" -#: ../gtk/gtkcalendar.c:632 +#: ../gtk/gtkcalendar.c:637 msgid "Vertical separation" msgstr "Separación vertical" -#: ../gtk/gtkcalendar.c:633 +#: ../gtk/gtkcalendar.c:638 msgid "Space between day headers and main area" msgstr "Espacio entre las cabeceras del día y el área principal" -#: ../gtk/gtkcalendar.c:644 +#: ../gtk/gtkcalendar.c:649 msgid "Horizontal separation" msgstr "Separación horizontal" -#: ../gtk/gtkcalendar.c:645 +#: ../gtk/gtkcalendar.c:650 msgid "Space between week headers and main area" msgstr "Espacio entre las cabeceras de la semana y el área principal" @@ -1146,129 +1146,127 @@ msgstr "Modo del acelerador" msgid "The type of accelerators" msgstr "El tipo de aceleradores" -#: ../gtk/gtkcellrenderer.c:227 +#: ../gtk/gtkcellrenderer.c:266 msgid "mode" msgstr "modo" -#: ../gtk/gtkcellrenderer.c:228 +#: ../gtk/gtkcellrenderer.c:267 msgid "Editable mode of the CellRenderer" msgstr "Modo editable del CellRenderer" -#: ../gtk/gtkcellrenderer.c:236 +#: ../gtk/gtkcellrenderer.c:275 msgid "visible" msgstr "visible" -#: ../gtk/gtkcellrenderer.c:237 +#: ../gtk/gtkcellrenderer.c:276 msgid "Display the cell" msgstr "Mostrar la celda" -#: ../gtk/gtkcellrenderer.c:244 +#: ../gtk/gtkcellrenderer.c:283 msgid "Display the cell sensitive" msgstr "Mostrar la celda sensible" -#: ../gtk/gtkcellrenderer.c:251 +#: ../gtk/gtkcellrenderer.c:290 msgid "xalign" msgstr "xalign" -#: ../gtk/gtkcellrenderer.c:252 +#: ../gtk/gtkcellrenderer.c:291 msgid "The x-align" msgstr "La alineación x" -#: ../gtk/gtkcellrenderer.c:261 +#: ../gtk/gtkcellrenderer.c:300 msgid "yalign" msgstr "yalign" -#: ../gtk/gtkcellrenderer.c:262 +#: ../gtk/gtkcellrenderer.c:301 msgid "The y-align" msgstr "La alineación y" -#: ../gtk/gtkcellrenderer.c:271 +#: ../gtk/gtkcellrenderer.c:310 msgid "xpad" msgstr "xpad" -#: ../gtk/gtkcellrenderer.c:272 +#: ../gtk/gtkcellrenderer.c:311 msgid "The xpad" msgstr "La separación x" -#: ../gtk/gtkcellrenderer.c:281 +#: ../gtk/gtkcellrenderer.c:320 msgid "ypad" msgstr "ypad" -#: ../gtk/gtkcellrenderer.c:282 +#: ../gtk/gtkcellrenderer.c:321 msgid "The ypad" msgstr "La separación y" -#: ../gtk/gtkcellrenderer.c:291 +#: ../gtk/gtkcellrenderer.c:330 msgid "width" msgstr "anchura" -#: ../gtk/gtkcellrenderer.c:292 +#: ../gtk/gtkcellrenderer.c:331 msgid "The fixed width" msgstr "La anchura fija" -#: ../gtk/gtkcellrenderer.c:301 +#: ../gtk/gtkcellrenderer.c:340 msgid "height" msgstr "altura" -#: ../gtk/gtkcellrenderer.c:302 +#: ../gtk/gtkcellrenderer.c:341 msgid "The fixed height" msgstr "La altura fija" -#: ../gtk/gtkcellrenderer.c:311 +#: ../gtk/gtkcellrenderer.c:350 msgid "Is Expander" msgstr "Es expansor" -#: ../gtk/gtkcellrenderer.c:312 +#: ../gtk/gtkcellrenderer.c:351 msgid "Row has children" msgstr "La fila tiene hijos" -#: ../gtk/gtkcellrenderer.c:320 +#: ../gtk/gtkcellrenderer.c:359 msgid "Is Expanded" msgstr "Está expandido" -#: ../gtk/gtkcellrenderer.c:321 +#: ../gtk/gtkcellrenderer.c:360 msgid "Row is an expander row, and is expanded" msgstr "La fila es una fila de expansor, y está expandida" -#: ../gtk/gtkcellrenderer.c:328 +#: ../gtk/gtkcellrenderer.c:367 msgid "Cell background color name" msgstr "Nombre del color de fondo de la celda" -#: ../gtk/gtkcellrenderer.c:329 +#: ../gtk/gtkcellrenderer.c:368 msgid "Cell background color as a string" msgstr "Color de fondo de la celda como una cadena" -#: ../gtk/gtkcellrenderer.c:336 +#: ../gtk/gtkcellrenderer.c:375 msgid "Cell background color" msgstr "Color de fondo de la celda" -#: ../gtk/gtkcellrenderer.c:337 +#: ../gtk/gtkcellrenderer.c:376 msgid "Cell background color as a GdkColor" msgstr "Color de fondo de la celda como GdkColor" -#: ../gtk/gtkcellrenderer.c:350 -#| msgid "Cell background color" +#: ../gtk/gtkcellrenderer.c:389 msgid "Cell background RGBA color" msgstr "Color de fondo RGBA de la celda" -#: ../gtk/gtkcellrenderer.c:351 -#| msgid "Cell background color as a GdkColor" +#: ../gtk/gtkcellrenderer.c:390 msgid "Cell background color as a GdkRGBA" msgstr "Color de fondo de la celda como GdkRGBA" -#: ../gtk/gtkcellrenderer.c:358 +#: ../gtk/gtkcellrenderer.c:397 msgid "Editing" msgstr "Editando" -#: ../gtk/gtkcellrenderer.c:359 +#: ../gtk/gtkcellrenderer.c:398 msgid "Whether the cell renderer is currently in editing mode" msgstr "Indica si la renderización de la celda está en modo de edición" -#: ../gtk/gtkcellrenderer.c:367 +#: ../gtk/gtkcellrenderer.c:406 msgid "Cell background set" msgstr "Establece el fondo de la celda" -#: ../gtk/gtkcellrenderer.c:368 +#: ../gtk/gtkcellrenderer.c:407 msgid "Whether this tag affects the cell background color" msgstr "Indica si esta etiqueta afecta el color de fondo de la celda" @@ -1289,7 +1287,7 @@ msgid "A column in the data source model to get the strings from" msgstr "" "Una columna en el modelo de origen de datos del que se obtienen las cadenas" -#: ../gtk/gtkcellrenderercombo.c:150 ../gtk/gtkcombobox.c:928 +#: ../gtk/gtkcellrenderercombo.c:150 ../gtk/gtkcombobox.c:932 msgid "Has Entry" msgstr "Tiene entrada" @@ -1322,7 +1320,7 @@ msgstr "Pixbuf del expansor cerrado" msgid "Pixbuf for closed expander" msgstr "El pixbuf para el expansor cerrado" -#: ../gtk/gtkcellrendererpixbuf.c:144 ../gtk/gtkimage.c:244 +#: ../gtk/gtkcellrendererpixbuf.c:144 ../gtk/gtkimage.c:250 #: ../gtk/gtkstatusicon.c:228 msgid "Stock ID" msgstr "ID del inventario" @@ -1356,8 +1354,8 @@ msgstr "Seguir estado" msgid "Whether the rendered pixbuf should be colorized according to the state" msgstr "Indica si el pixbuf renderizado debe colorearse de acuerdo al estado" -#: ../gtk/gtkcellrendererpixbuf.c:214 ../gtk/gtkimage.c:319 -#: ../gtk/gtkwindow.c:709 +#: ../gtk/gtkcellrendererpixbuf.c:214 ../gtk/gtkimage.c:325 +#: ../gtk/gtkwindow.c:710 msgid "Icon" msgstr "Icono" @@ -1365,10 +1363,10 @@ msgstr "Icono" msgid "Value of the progress bar" msgstr "Valor de la barra de progreso" -#: ../gtk/gtkcellrendererprogress.c:144 ../gtk/gtkcellrenderertext.c:233 -#: ../gtk/gtkentry.c:738 ../gtk/gtkentrybuffer.c:352 -#: ../gtk/gtkmessagedialog.c:226 ../gtk/gtkprogressbar.c:145 -#: ../gtk/gtktextbuffer.c:210 +#: ../gtk/gtkcellrendererprogress.c:144 ../gtk/gtkcellrenderertext.c:247 +#: ../gtk/gtkentry.c:829 ../gtk/gtkentrybuffer.c:352 +#: ../gtk/gtkmessagedialog.c:226 ../gtk/gtkprogressbar.c:177 +#: ../gtk/gtktextbuffer.c:209 msgid "Text" msgstr "Texto" @@ -1408,21 +1406,21 @@ msgstr "Alineación y del texto" msgid "The vertical text alignment, from 0 (top) to 1 (bottom)." msgstr "La alineación vertical del texto, desde 0 (superior) a 1 (inferior)." -#: ../gtk/gtkcellrendererprogress.c:214 ../gtk/gtkprogressbar.c:121 -#: ../gtk/gtkrange.c:433 +#: ../gtk/gtkcellrendererprogress.c:214 ../gtk/gtkprogressbar.c:153 +#: ../gtk/gtkrange.c:440 msgid "Inverted" msgstr "Invertido" -#: ../gtk/gtkcellrendererprogress.c:215 ../gtk/gtkprogressbar.c:122 +#: ../gtk/gtkcellrendererprogress.c:215 ../gtk/gtkprogressbar.c:154 msgid "Invert the direction in which the progress bar grows" msgstr "Invertir la dirección en la que aumentan las barras de progreso" -#: ../gtk/gtkcellrendererspin.c:91 ../gtk/gtkrange.c:425 -#: ../gtk/gtkscalebutton.c:239 ../gtk/gtkspinbutton.c:228 +#: ../gtk/gtkcellrendererspin.c:91 ../gtk/gtkrange.c:432 +#: ../gtk/gtkscalebutton.c:239 ../gtk/gtkspinbutton.c:230 msgid "Adjustment" msgstr "Ajuste" -#: ../gtk/gtkcellrendererspin.c:92 ../gtk/gtkspinbutton.c:229 +#: ../gtk/gtkcellrendererspin.c:92 ../gtk/gtkspinbutton.c:231 msgid "The adjustment that holds the value of the spin button" msgstr "El ajuste que mantiene el valor del botón incrementable" @@ -1430,22 +1428,23 @@ msgstr "El ajuste que mantiene el valor del botón incrementable" msgid "Climb rate" msgstr "Tasa de subida" -#: ../gtk/gtkcellrendererspin.c:108 ../gtk/gtkspinbutton.c:237 +#: ../gtk/gtkcellrendererspin.c:108 ../gtk/gtkspinbutton.c:239 msgid "The acceleration rate when you hold down a button" msgstr "La tasa de aceleración cuando mantiene apretado un botón" -#: ../gtk/gtkcellrendererspin.c:121 ../gtk/gtkscale.c:244 -#: ../gtk/gtkspinbutton.c:246 +#: ../gtk/gtkcellrendererspin.c:121 ../gtk/gtkscale.c:249 +#: ../gtk/gtkspinbutton.c:248 msgid "Digits" msgstr "Dígitos" -#: ../gtk/gtkcellrendererspin.c:122 ../gtk/gtkspinbutton.c:247 +#: ../gtk/gtkcellrendererspin.c:122 ../gtk/gtkspinbutton.c:249 msgid "The number of decimal places to display" msgstr "El número de lugares decimales que mostrar" #: ../gtk/gtkcellrendererspinner.c:119 ../gtk/gtkcheckmenuitem.c:105 -#: ../gtk/gtkmenu.c:520 ../gtk/gtkspinner.c:131 ../gtk/gtktoggleaction.c:133 -#: ../gtk/gtktogglebutton.c:115 ../gtk/gtktoggletoolbutton.c:112 +#: ../gtk/gtkmenu.c:521 ../gtk/gtkspinner.c:131 ../gtk/gtkswitch.c:739 +#: ../gtk/gtktoggleaction.c:133 ../gtk/gtktogglebutton.c:125 +#: ../gtk/gtktoggletoolbutton.c:112 msgid "Active" msgstr "Activo" @@ -1464,197 +1463,193 @@ msgstr "" "El valor de GTKIconSize que especifica el tamaño del marcador incrementable " "renderizado" -#: ../gtk/gtkcellrenderertext.c:234 +#: ../gtk/gtkcellrenderertext.c:248 msgid "Text to render" msgstr "Texto a renderizar" -#: ../gtk/gtkcellrenderertext.c:241 +#: ../gtk/gtkcellrenderertext.c:255 msgid "Markup" msgstr "Marcado" -#: ../gtk/gtkcellrenderertext.c:242 +#: ../gtk/gtkcellrenderertext.c:256 msgid "Marked up text to render" msgstr "Texto resaltado a renderizar" -#: ../gtk/gtkcellrenderertext.c:249 ../gtk/gtklabel.c:556 +#: ../gtk/gtkcellrenderertext.c:263 ../gtk/gtklabel.c:574 msgid "Attributes" msgstr "Atributos" -#: ../gtk/gtkcellrenderertext.c:250 +#: ../gtk/gtkcellrenderertext.c:264 msgid "A list of style attributes to apply to the text of the renderer" msgstr "" "Un lista de atributos de estilos para aplicar al texto del renderizador" -#: ../gtk/gtkcellrenderertext.c:257 +#: ../gtk/gtkcellrenderertext.c:271 msgid "Single Paragraph Mode" msgstr "Modo de parágrafo simple" -#: ../gtk/gtkcellrenderertext.c:258 +#: ../gtk/gtkcellrenderertext.c:272 msgid "Whether to keep all text in a single paragraph" msgstr "Indica si se debe mantener todo el texto en un sólo parágrafo" -#: ../gtk/gtkcellrenderertext.c:266 ../gtk/gtkcellview.c:179 +#: ../gtk/gtkcellrenderertext.c:280 ../gtk/gtkcellview.c:192 #: ../gtk/gtktexttag.c:178 msgid "Background color name" msgstr "Nombre del color de fondo" -#: ../gtk/gtkcellrenderertext.c:267 ../gtk/gtkcellview.c:180 +#: ../gtk/gtkcellrenderertext.c:281 ../gtk/gtkcellview.c:193 #: ../gtk/gtktexttag.c:179 msgid "Background color as a string" msgstr "Color de fondo como una cadena" -#: ../gtk/gtkcellrenderertext.c:274 ../gtk/gtkcellview.c:186 +#: ../gtk/gtkcellrenderertext.c:288 ../gtk/gtkcellview.c:199 #: ../gtk/gtktexttag.c:186 msgid "Background color" msgstr "Color de fondo" -#: ../gtk/gtkcellrenderertext.c:275 ../gtk/gtkcellview.c:187 +#: ../gtk/gtkcellrenderertext.c:289 ../gtk/gtkcellview.c:200 msgid "Background color as a GdkColor" msgstr "Color de fondo como GdkColor" -#: ../gtk/gtkcellrenderertext.c:289 -#| msgid "Background color name" +#: ../gtk/gtkcellrenderertext.c:303 msgid "Background color as RGBA" msgstr "Nombre del color de fondo como RGBA" -#: ../gtk/gtkcellrenderertext.c:290 ../gtk/gtkcellview.c:201 -#| msgid "Background color as a GdkColor" +#: ../gtk/gtkcellrenderertext.c:304 ../gtk/gtkcellview.c:214 msgid "Background color as a GdkRGBA" msgstr "Color de fondo como GdkRGBA" -#: ../gtk/gtkcellrenderertext.c:296 ../gtk/gtktexttag.c:202 +#: ../gtk/gtkcellrenderertext.c:310 ../gtk/gtktexttag.c:202 msgid "Foreground color name" msgstr "Nombre del color de primer plano" -#: ../gtk/gtkcellrenderertext.c:297 ../gtk/gtktexttag.c:203 +#: ../gtk/gtkcellrenderertext.c:311 ../gtk/gtktexttag.c:203 msgid "Foreground color as a string" msgstr "Color de primer plano como una cadena" -#: ../gtk/gtkcellrenderertext.c:304 ../gtk/gtktexttag.c:210 +#: ../gtk/gtkcellrenderertext.c:318 ../gtk/gtktexttag.c:210 #: ../gtk/gtktrayicon-x11.c:133 msgid "Foreground color" msgstr "Color de primer plano" -#: ../gtk/gtkcellrenderertext.c:305 +#: ../gtk/gtkcellrenderertext.c:319 msgid "Foreground color as a GdkColor" msgstr "Color de primer plano como GdkColor" -#: ../gtk/gtkcellrenderertext.c:319 -#| msgid "Foreground color name" +#: ../gtk/gtkcellrenderertext.c:333 msgid "Foreground color as RGBA" msgstr "Color de primer plano como RGBA" -#: ../gtk/gtkcellrenderertext.c:320 -#| msgid "Foreground color as a GdkColor" +#: ../gtk/gtkcellrenderertext.c:334 msgid "Foreground color as a GdkRGBA" msgstr "Color de primer plano como GdkRGBA" -#: ../gtk/gtkcellrenderertext.c:328 ../gtk/gtkentry.c:662 -#: ../gtk/gtktexttag.c:227 ../gtk/gtktextview.c:660 +#: ../gtk/gtkcellrenderertext.c:342 ../gtk/gtkentry.c:753 +#: ../gtk/gtktexttag.c:227 ../gtk/gtktextview.c:686 msgid "Editable" msgstr "Editable" -#: ../gtk/gtkcellrenderertext.c:329 ../gtk/gtktexttag.c:228 -#: ../gtk/gtktextview.c:661 +#: ../gtk/gtkcellrenderertext.c:343 ../gtk/gtktexttag.c:228 +#: ../gtk/gtktextview.c:687 msgid "Whether the text can be modified by the user" msgstr "Indica si el texto puede modificarse por el usuario" -#: ../gtk/gtkcellrenderertext.c:336 ../gtk/gtkcellrenderertext.c:344 +#: ../gtk/gtkcellrenderertext.c:350 ../gtk/gtkcellrenderertext.c:358 #: ../gtk/gtktexttag.c:243 ../gtk/gtktexttag.c:251 msgid "Font" msgstr "Tipografía" -#: ../gtk/gtkcellrenderertext.c:337 ../gtk/gtktexttag.c:244 +#: ../gtk/gtkcellrenderertext.c:351 ../gtk/gtktexttag.c:244 msgid "Font description as a string, e.g. \"Sans Italic 12\"" msgstr "" "Descripción de la tipografía como una cadena, ejemplo: «Sans Italic 12»" -#: ../gtk/gtkcellrenderertext.c:345 ../gtk/gtktexttag.c:252 +#: ../gtk/gtkcellrenderertext.c:359 ../gtk/gtktexttag.c:252 msgid "Font description as a PangoFontDescription struct" msgstr "Descripción de la tipografía como una estructura PangoFontDescription" -#: ../gtk/gtkcellrenderertext.c:353 ../gtk/gtktexttag.c:259 +#: ../gtk/gtkcellrenderertext.c:367 ../gtk/gtktexttag.c:259 msgid "Font family" msgstr "Familia tipográfica" -#: ../gtk/gtkcellrenderertext.c:354 ../gtk/gtktexttag.c:260 +#: ../gtk/gtkcellrenderertext.c:368 ../gtk/gtktexttag.c:260 msgid "Name of the font family, e.g. Sans, Helvetica, Times, Monospace" msgstr "" "Nombre de la familia tipográfica, ej. Sans, Helvética, Times, Monospace" -#: ../gtk/gtkcellrenderertext.c:361 ../gtk/gtkcellrenderertext.c:362 +#: ../gtk/gtkcellrenderertext.c:375 ../gtk/gtkcellrenderertext.c:376 #: ../gtk/gtktexttag.c:267 msgid "Font style" msgstr "Estilo de la tipografía" -#: ../gtk/gtkcellrenderertext.c:370 ../gtk/gtkcellrenderertext.c:371 +#: ../gtk/gtkcellrenderertext.c:384 ../gtk/gtkcellrenderertext.c:385 #: ../gtk/gtktexttag.c:276 msgid "Font variant" msgstr "Variante de la tipografía" -#: ../gtk/gtkcellrenderertext.c:379 ../gtk/gtkcellrenderertext.c:380 +#: ../gtk/gtkcellrenderertext.c:393 ../gtk/gtkcellrenderertext.c:394 #: ../gtk/gtktexttag.c:285 msgid "Font weight" msgstr "Anchura de la tipografía" -#: ../gtk/gtkcellrenderertext.c:389 ../gtk/gtkcellrenderertext.c:390 +#: ../gtk/gtkcellrenderertext.c:403 ../gtk/gtkcellrenderertext.c:404 #: ../gtk/gtktexttag.c:296 msgid "Font stretch" msgstr "Estiramiento de la tipografía" -#: ../gtk/gtkcellrenderertext.c:398 ../gtk/gtkcellrenderertext.c:399 +#: ../gtk/gtkcellrenderertext.c:412 ../gtk/gtkcellrenderertext.c:413 #: ../gtk/gtktexttag.c:305 msgid "Font size" msgstr "Tamaño de la tipografía" -#: ../gtk/gtkcellrenderertext.c:408 ../gtk/gtktexttag.c:325 +#: ../gtk/gtkcellrenderertext.c:422 ../gtk/gtktexttag.c:325 msgid "Font points" msgstr "Puntos de la tipografía" -#: ../gtk/gtkcellrenderertext.c:409 ../gtk/gtktexttag.c:326 +#: ../gtk/gtkcellrenderertext.c:423 ../gtk/gtktexttag.c:326 msgid "Font size in points" msgstr "Tamaño de la tipografía en puntos" -#: ../gtk/gtkcellrenderertext.c:418 ../gtk/gtktexttag.c:315 +#: ../gtk/gtkcellrenderertext.c:432 ../gtk/gtktexttag.c:315 msgid "Font scale" msgstr "Escala de la tipografía" -#: ../gtk/gtkcellrenderertext.c:419 +#: ../gtk/gtkcellrenderertext.c:433 msgid "Font scaling factor" msgstr "Factor de escalado de la tipografía" -#: ../gtk/gtkcellrenderertext.c:428 ../gtk/gtktexttag.c:394 +#: ../gtk/gtkcellrenderertext.c:442 ../gtk/gtktexttag.c:394 msgid "Rise" msgstr "Elevar" -#: ../gtk/gtkcellrenderertext.c:429 +#: ../gtk/gtkcellrenderertext.c:443 msgid "" "Offset of text above the baseline (below the baseline if rise is negative)" msgstr "" "Desplazamiento del texto sobre la línea base (por debajo de la línea base la " "elevación es negativa)" -#: ../gtk/gtkcellrenderertext.c:440 ../gtk/gtktexttag.c:434 +#: ../gtk/gtkcellrenderertext.c:454 ../gtk/gtktexttag.c:434 msgid "Strikethrough" msgstr "Tachar" -#: ../gtk/gtkcellrenderertext.c:441 ../gtk/gtktexttag.c:435 +#: ../gtk/gtkcellrenderertext.c:455 ../gtk/gtktexttag.c:435 msgid "Whether to strike through the text" msgstr "Indica si se tacha el texto" -#: ../gtk/gtkcellrenderertext.c:448 ../gtk/gtktexttag.c:442 +#: ../gtk/gtkcellrenderertext.c:462 ../gtk/gtktexttag.c:442 msgid "Underline" msgstr "Subrayado" -#: ../gtk/gtkcellrenderertext.c:449 ../gtk/gtktexttag.c:443 +#: ../gtk/gtkcellrenderertext.c:463 ../gtk/gtktexttag.c:443 msgid "Style of underline for this text" msgstr "Estilo de subrayado de este texto" -#: ../gtk/gtkcellrenderertext.c:457 ../gtk/gtktexttag.c:354 +#: ../gtk/gtkcellrenderertext.c:471 ../gtk/gtktexttag.c:354 msgid "Language" msgstr "Idioma" -#: ../gtk/gtkcellrenderertext.c:458 +#: ../gtk/gtkcellrenderertext.c:472 msgid "" "The language this text is in, as an ISO code. Pango can use this as a hint " "when rendering the text. If you don't understand this parameter, you " @@ -1664,12 +1659,12 @@ msgstr "" "como una ayuda cuando está renderizando el texto. Si no comprende este " "parámetro probablemente no lo necesite" -#: ../gtk/gtkcellrenderertext.c:478 ../gtk/gtklabel.c:681 -#: ../gtk/gtkprogressbar.c:175 +#: ../gtk/gtkcellrenderertext.c:492 ../gtk/gtklabel.c:699 +#: ../gtk/gtkprogressbar.c:207 msgid "Ellipsize" msgstr "Elipsis" -#: ../gtk/gtkcellrenderertext.c:479 +#: ../gtk/gtkcellrenderertext.c:493 msgid "" "The preferred place to ellipsize the string, if the cell renderer does not " "have enough room to display the entire string" @@ -1677,28 +1672,28 @@ msgstr "" "El lugar preferido para la elipsis de la cadena, si el renderizador de la " "celda no tiene espacio suficiente para mostrar la cadena completa" -#: ../gtk/gtkcellrenderertext.c:498 ../gtk/gtkfilechooserbutton.c:411 -#: ../gtk/gtklabel.c:702 +#: ../gtk/gtkcellrenderertext.c:512 ../gtk/gtkfilechooserbutton.c:411 +#: ../gtk/gtklabel.c:720 msgid "Width In Characters" msgstr "Anchura en caracteres" -#: ../gtk/gtkcellrenderertext.c:499 ../gtk/gtklabel.c:703 +#: ../gtk/gtkcellrenderertext.c:513 ../gtk/gtklabel.c:721 msgid "The desired width of the label, in characters" msgstr "La anchura deseada de la etiqueta, en caracteres" -#: ../gtk/gtkcellrenderertext.c:523 ../gtk/gtklabel.c:763 +#: ../gtk/gtkcellrenderertext.c:537 ../gtk/gtklabel.c:781 msgid "Maximum Width In Characters" msgstr "Anchura máxima en caracteres" -#: ../gtk/gtkcellrenderertext.c:524 +#: ../gtk/gtkcellrenderertext.c:538 msgid "The maximum width of the cell, in characters" msgstr "La anchura máxima de la celda, en caracteres" -#: ../gtk/gtkcellrenderertext.c:542 ../gtk/gtktexttag.c:451 +#: ../gtk/gtkcellrenderertext.c:556 ../gtk/gtktexttag.c:451 msgid "Wrap mode" msgstr "Modo de ajuste" -#: ../gtk/gtkcellrenderertext.c:543 +#: ../gtk/gtkcellrenderertext.c:557 msgid "" "How to break the string into multiple lines, if the cell renderer does not " "have enough room to display the entire string" @@ -1706,150 +1701,150 @@ msgstr "" "Cómo romper la cadena en líneas múltiples, si el renderizador de la celda no " "tiene suficiente espacio para mostrar la cadena completa" -#: ../gtk/gtkcellrenderertext.c:562 ../gtk/gtkcombobox.c:750 +#: ../gtk/gtkcellrenderertext.c:576 ../gtk/gtkcombobox.c:754 msgid "Wrap width" msgstr "Ajustar anchura" -#: ../gtk/gtkcellrenderertext.c:563 +#: ../gtk/gtkcellrenderertext.c:577 msgid "The width at which the text is wrapped" msgstr "La anchura a la que el texto se ajusta" -#: ../gtk/gtkcellrenderertext.c:583 ../gtk/gtktreeviewcolumn.c:319 +#: ../gtk/gtkcellrenderertext.c:597 ../gtk/gtktreeviewcolumn.c:319 msgid "Alignment" msgstr "Alineación" -#: ../gtk/gtkcellrenderertext.c:584 +#: ../gtk/gtkcellrenderertext.c:598 msgid "How to align the lines" msgstr "Cómo alinear las líneas" -#: ../gtk/gtkcellrenderertext.c:596 ../gtk/gtkcellview.c:223 +#: ../gtk/gtkcellrenderertext.c:610 ../gtk/gtkcellview.c:236 #: ../gtk/gtktexttag.c:540 msgid "Background set" msgstr "Establece el fondo" -#: ../gtk/gtkcellrenderertext.c:597 ../gtk/gtkcellview.c:224 +#: ../gtk/gtkcellrenderertext.c:611 ../gtk/gtkcellview.c:237 #: ../gtk/gtktexttag.c:541 msgid "Whether this tag affects the background color" msgstr "Indica si esta etiqueta afecta el color de fondo" -#: ../gtk/gtkcellrenderertext.c:600 ../gtk/gtktexttag.c:548 +#: ../gtk/gtkcellrenderertext.c:614 ../gtk/gtktexttag.c:548 msgid "Foreground set" msgstr "Establece el primer plano" -#: ../gtk/gtkcellrenderertext.c:601 ../gtk/gtktexttag.c:549 +#: ../gtk/gtkcellrenderertext.c:615 ../gtk/gtktexttag.c:549 msgid "Whether this tag affects the foreground color" msgstr "Indica si esta etiqueta afecta al color de frente" -#: ../gtk/gtkcellrenderertext.c:604 ../gtk/gtktexttag.c:552 +#: ../gtk/gtkcellrenderertext.c:618 ../gtk/gtktexttag.c:552 msgid "Editability set" msgstr "Establece la editabilidad" -#: ../gtk/gtkcellrenderertext.c:605 ../gtk/gtktexttag.c:553 +#: ../gtk/gtkcellrenderertext.c:619 ../gtk/gtktexttag.c:553 msgid "Whether this tag affects text editability" msgstr "Indica si esta etiqueta afecta la editabilidad del texto" -#: ../gtk/gtkcellrenderertext.c:608 ../gtk/gtktexttag.c:556 +#: ../gtk/gtkcellrenderertext.c:622 ../gtk/gtktexttag.c:556 msgid "Font family set" msgstr "Establece familia tipográfica" -#: ../gtk/gtkcellrenderertext.c:609 ../gtk/gtktexttag.c:557 +#: ../gtk/gtkcellrenderertext.c:623 ../gtk/gtktexttag.c:557 msgid "Whether this tag affects the font family" msgstr "Indica si esta etiqueta afecta a la familia de la tipografía" -#: ../gtk/gtkcellrenderertext.c:612 ../gtk/gtktexttag.c:560 +#: ../gtk/gtkcellrenderertext.c:626 ../gtk/gtktexttag.c:560 msgid "Font style set" msgstr "Establece el estilo de la tipografía" -#: ../gtk/gtkcellrenderertext.c:613 ../gtk/gtktexttag.c:561 +#: ../gtk/gtkcellrenderertext.c:627 ../gtk/gtktexttag.c:561 msgid "Whether this tag affects the font style" msgstr "Indica si esta etiqueta afecta el estilo de la tipografía" -#: ../gtk/gtkcellrenderertext.c:616 ../gtk/gtktexttag.c:564 +#: ../gtk/gtkcellrenderertext.c:630 ../gtk/gtktexttag.c:564 msgid "Font variant set" msgstr "Establece la variante de la tipografía" -#: ../gtk/gtkcellrenderertext.c:617 ../gtk/gtktexttag.c:565 +#: ../gtk/gtkcellrenderertext.c:631 ../gtk/gtktexttag.c:565 msgid "Whether this tag affects the font variant" msgstr "Indica si esta etiqueta afecta la variante de la tipografía" -#: ../gtk/gtkcellrenderertext.c:620 ../gtk/gtktexttag.c:568 +#: ../gtk/gtkcellrenderertext.c:634 ../gtk/gtktexttag.c:568 msgid "Font weight set" msgstr "Establece el peso de la tipografía" -#: ../gtk/gtkcellrenderertext.c:621 ../gtk/gtktexttag.c:569 +#: ../gtk/gtkcellrenderertext.c:635 ../gtk/gtktexttag.c:569 msgid "Whether this tag affects the font weight" msgstr "Indica si esta etiqueta afecta el peso de la tipografía" -#: ../gtk/gtkcellrenderertext.c:624 ../gtk/gtktexttag.c:572 +#: ../gtk/gtkcellrenderertext.c:638 ../gtk/gtktexttag.c:572 msgid "Font stretch set" msgstr "Establece el ancho de la tipografía" -#: ../gtk/gtkcellrenderertext.c:625 ../gtk/gtktexttag.c:573 +#: ../gtk/gtkcellrenderertext.c:639 ../gtk/gtktexttag.c:573 msgid "Whether this tag affects the font stretch" msgstr "Indica si esta etiqueta afecta el estiramiento de la tipografía" -#: ../gtk/gtkcellrenderertext.c:628 ../gtk/gtktexttag.c:576 +#: ../gtk/gtkcellrenderertext.c:642 ../gtk/gtktexttag.c:576 msgid "Font size set" msgstr "Establece el tamaño de tipografía" -#: ../gtk/gtkcellrenderertext.c:629 ../gtk/gtktexttag.c:577 +#: ../gtk/gtkcellrenderertext.c:643 ../gtk/gtktexttag.c:577 msgid "Whether this tag affects the font size" msgstr "Indica si esta etiqueta afecta el tamaño de la tipografía" -#: ../gtk/gtkcellrenderertext.c:632 ../gtk/gtktexttag.c:580 +#: ../gtk/gtkcellrenderertext.c:646 ../gtk/gtktexttag.c:580 msgid "Font scale set" msgstr "Establece la escala de la tipografía" -#: ../gtk/gtkcellrenderertext.c:633 ../gtk/gtktexttag.c:581 +#: ../gtk/gtkcellrenderertext.c:647 ../gtk/gtktexttag.c:581 msgid "Whether this tag scales the font size by a factor" msgstr "" "Indica si esta etiqueta escala el tamaño de la tipografía por un factor" -#: ../gtk/gtkcellrenderertext.c:636 ../gtk/gtktexttag.c:600 +#: ../gtk/gtkcellrenderertext.c:650 ../gtk/gtktexttag.c:600 msgid "Rise set" msgstr "Establece el elevamiento" -#: ../gtk/gtkcellrenderertext.c:637 ../gtk/gtktexttag.c:601 +#: ../gtk/gtkcellrenderertext.c:651 ../gtk/gtktexttag.c:601 msgid "Whether this tag affects the rise" msgstr "Indica si esta etiqueta afecta la elevación" -#: ../gtk/gtkcellrenderertext.c:640 ../gtk/gtktexttag.c:616 +#: ../gtk/gtkcellrenderertext.c:654 ../gtk/gtktexttag.c:616 msgid "Strikethrough set" msgstr "Establece el tachado" -#: ../gtk/gtkcellrenderertext.c:641 ../gtk/gtktexttag.c:617 +#: ../gtk/gtkcellrenderertext.c:655 ../gtk/gtktexttag.c:617 msgid "Whether this tag affects strikethrough" msgstr "Indica si esta etiqueta afecta el tachado" -#: ../gtk/gtkcellrenderertext.c:644 ../gtk/gtktexttag.c:624 +#: ../gtk/gtkcellrenderertext.c:658 ../gtk/gtktexttag.c:624 msgid "Underline set" msgstr "Establece el subrayado" -#: ../gtk/gtkcellrenderertext.c:645 ../gtk/gtktexttag.c:625 +#: ../gtk/gtkcellrenderertext.c:659 ../gtk/gtktexttag.c:625 msgid "Whether this tag affects underlining" msgstr "Indica si esta etiqueta afecta el subrayado" -#: ../gtk/gtkcellrenderertext.c:648 ../gtk/gtktexttag.c:588 +#: ../gtk/gtkcellrenderertext.c:662 ../gtk/gtktexttag.c:588 msgid "Language set" msgstr "Establece el idioma" -#: ../gtk/gtkcellrenderertext.c:649 ../gtk/gtktexttag.c:589 +#: ../gtk/gtkcellrenderertext.c:663 ../gtk/gtktexttag.c:589 msgid "Whether this tag affects the language the text is rendered as" msgstr "Indica si esta etiqueta afecta al idioma en que se renderiza el texto" -#: ../gtk/gtkcellrenderertext.c:652 +#: ../gtk/gtkcellrenderertext.c:666 msgid "Ellipsize set" msgstr "Establece la elipsis" -#: ../gtk/gtkcellrenderertext.c:653 +#: ../gtk/gtkcellrenderertext.c:667 msgid "Whether this tag affects the ellipsize mode" msgstr "Indica si esta etiqueta afecta el modo de elipsis" -#: ../gtk/gtkcellrenderertext.c:656 +#: ../gtk/gtkcellrenderertext.c:670 msgid "Align set" msgstr "Establece alineación" -#: ../gtk/gtkcellrenderertext.c:657 +#: ../gtk/gtkcellrenderertext.c:671 msgid "Whether this tag affects the alignment mode" msgstr "Indica si esta etiqueta afecta el modo de alineamiento" @@ -1889,33 +1884,32 @@ msgstr "Dibujar el botón de activación como un botón de radio" msgid "Indicator size" msgstr "Tamaño del indicador" -#: ../gtk/gtkcellrenderertoggle.c:161 ../gtk/gtkcheckbutton.c:72 +#: ../gtk/gtkcellrenderertoggle.c:161 ../gtk/gtkcheckbutton.c:78 #: ../gtk/gtkcheckmenuitem.c:129 msgid "Size of check or radio indicator" msgstr "Tamaño del indicador de radio o de la casilla" -#: ../gtk/gtkcellview.c:200 -#| msgid "Background color" +#: ../gtk/gtkcellview.c:213 msgid "Background RGBA color" msgstr "Color de fondo RGBA" -#: ../gtk/gtkcellview.c:215 +#: ../gtk/gtkcellview.c:228 msgid "CellView model" msgstr "Modelo CellView" -#: ../gtk/gtkcellview.c:216 +#: ../gtk/gtkcellview.c:229 msgid "The model for cell view" msgstr "El modelo para la vista de celda" -#: ../gtk/gtkcheckbutton.c:71 ../gtk/gtkcheckmenuitem.c:128 +#: ../gtk/gtkcheckbutton.c:77 ../gtk/gtkcheckmenuitem.c:128 msgid "Indicator Size" msgstr "Tamaño del indicador" -#: ../gtk/gtkcheckbutton.c:79 ../gtk/gtkexpander.c:267 +#: ../gtk/gtkcheckbutton.c:85 ../gtk/gtkexpander.c:267 msgid "Indicator Spacing" msgstr "Espacio del indicador" -#: ../gtk/gtkcheckbutton.c:80 +#: ../gtk/gtkcheckbutton.c:86 msgid "Spacing around check or radio indicator" msgstr "Espacio que rodea el indicador de radio o casilla" @@ -1923,7 +1917,7 @@ msgstr "Espacio que rodea el indicador de radio o casilla" msgid "Whether the menu item is checked" msgstr "Indica si el elemento de menú está marcado" -#: ../gtk/gtkcheckmenuitem.c:113 ../gtk/gtktogglebutton.c:123 +#: ../gtk/gtkcheckmenuitem.c:113 ../gtk/gtktogglebutton.c:133 msgid "Inconsistent" msgstr "Inconsistente" @@ -1941,86 +1935,82 @@ msgstr "" "Indica si la apariencia del elemento de menú es como un elemento de menú de " "radio" -#: ../gtk/gtkcolorbutton.c:158 +#: ../gtk/gtkcolorbutton.c:171 msgid "Use alpha" msgstr "Usar alfa" -#: ../gtk/gtkcolorbutton.c:159 +#: ../gtk/gtkcolorbutton.c:172 msgid "Whether to give the color an alpha value" msgstr "Indica si se debe dar un valor alfa al color" # components/music/nautilus-music-view.c:198 -#: ../gtk/gtkcolorbutton.c:173 ../gtk/gtkfilechooserbutton.c:397 +#: ../gtk/gtkcolorbutton.c:186 ../gtk/gtkfilechooserbutton.c:397 #: ../gtk/gtkfontbutton.c:140 ../gtk/gtkprintjob.c:115 #: ../gtk/gtkstatusicon.c:415 ../gtk/gtktreeviewcolumn.c:286 msgid "Title" msgstr "Título" -#: ../gtk/gtkcolorbutton.c:174 +#: ../gtk/gtkcolorbutton.c:187 msgid "The title of the color selection dialog" msgstr "El título del diálogo de selección del color" -#: ../gtk/gtkcolorbutton.c:188 ../gtk/gtkcolorsel.c:325 +#: ../gtk/gtkcolorbutton.c:201 ../gtk/gtkcolorsel.c:339 msgid "Current Color" msgstr "Color actual" -#: ../gtk/gtkcolorbutton.c:189 +#: ../gtk/gtkcolorbutton.c:202 msgid "The selected color" msgstr "El color seleccionado" -#: ../gtk/gtkcolorbutton.c:203 ../gtk/gtkcolorsel.c:332 +#: ../gtk/gtkcolorbutton.c:216 ../gtk/gtkcolorsel.c:346 msgid "Current Alpha" msgstr "Alfa actual" -#: ../gtk/gtkcolorbutton.c:204 +#: ../gtk/gtkcolorbutton.c:217 msgid "The selected opacity value (0 fully transparent, 65535 fully opaque)" msgstr "" "El valor de opacidad actual (0 es completamente transparente, 65535 es " "completamente opaco)" -#: ../gtk/gtkcolorbutton.c:218 -#| msgid "Current Color" +#: ../gtk/gtkcolorbutton.c:231 msgid "Current RGBA Color" msgstr "Color RGBA actual" -#: ../gtk/gtkcolorbutton.c:219 -#| msgid "The selected color" +#: ../gtk/gtkcolorbutton.c:232 msgid "The selected RGBA color" msgstr "El color RGBA seleccionado" -#: ../gtk/gtkcolorsel.c:311 +#: ../gtk/gtkcolorsel.c:325 msgid "Has Opacity Control" msgstr "Tiene control de opacidad" -#: ../gtk/gtkcolorsel.c:312 +#: ../gtk/gtkcolorsel.c:326 msgid "Whether the color selector should allow setting opacity" msgstr "Indica si el selector de color permite seleccionar la opacidad" -#: ../gtk/gtkcolorsel.c:318 +#: ../gtk/gtkcolorsel.c:332 msgid "Has palette" msgstr "Tiene paleta" -#: ../gtk/gtkcolorsel.c:319 +#: ../gtk/gtkcolorsel.c:333 msgid "Whether a palette should be used" msgstr "Indica si se debe usar una paleta" -#: ../gtk/gtkcolorsel.c:326 +#: ../gtk/gtkcolorsel.c:340 msgid "The current color" msgstr "El color actual" -#: ../gtk/gtkcolorsel.c:333 +#: ../gtk/gtkcolorsel.c:347 msgid "The current opacity value (0 fully transparent, 65535 fully opaque)" msgstr "" "El valor de opacidad actual (0 es completamente transparente, 65535 es " "completamente opaco)" -#: ../gtk/gtkcolorsel.c:347 -#| msgid "Current Alpha" +#: ../gtk/gtkcolorsel.c:361 msgid "Current RGBA" msgstr "RGBA actual" -#: ../gtk/gtkcolorsel.c:348 -#| msgid "The current color" +#: ../gtk/gtkcolorsel.c:362 msgid "The current RGBA color" msgstr "El color RGBA actual" @@ -2056,98 +2046,98 @@ msgstr "Botón Ayuda" msgid "The help button of the dialog." msgstr "El botón Ayuda del diálogo." -#: ../gtk/gtkcombobox.c:733 +#: ../gtk/gtkcombobox.c:737 msgid "ComboBox model" msgstr "Modelo de ComboBox" -#: ../gtk/gtkcombobox.c:734 +#: ../gtk/gtkcombobox.c:738 msgid "The model for the combo box" msgstr "El modelo para el ComboBox" -#: ../gtk/gtkcombobox.c:751 +#: ../gtk/gtkcombobox.c:755 msgid "Wrap width for laying out the items in a grid" msgstr "Ajusta la anchura para distribuir los elementos en una rejilla" -#: ../gtk/gtkcombobox.c:773 +#: ../gtk/gtkcombobox.c:777 msgid "Row span column" msgstr "Fila expande columna" -#: ../gtk/gtkcombobox.c:774 +#: ../gtk/gtkcombobox.c:778 msgid "TreeModel column containing the row span values" msgstr "Columna TreeModel que contiene los valores de expansión de la fila" -#: ../gtk/gtkcombobox.c:795 +#: ../gtk/gtkcombobox.c:799 msgid "Column span column" msgstr "Columna expande columna" -#: ../gtk/gtkcombobox.c:796 +#: ../gtk/gtkcombobox.c:800 msgid "TreeModel column containing the column span values" msgstr "Columna TreeModel que contiene los valores de expansión de columna" -#: ../gtk/gtkcombobox.c:817 +#: ../gtk/gtkcombobox.c:821 msgid "Active item" msgstr "Elemento activo" -#: ../gtk/gtkcombobox.c:818 +#: ../gtk/gtkcombobox.c:822 msgid "The item which is currently active" msgstr "El elemento que está activo actualmente" -#: ../gtk/gtkcombobox.c:837 ../gtk/gtkuimanager.c:224 +#: ../gtk/gtkcombobox.c:841 ../gtk/gtkuimanager.c:224 msgid "Add tearoffs to menus" msgstr "Añadir tiradores a los menús" -#: ../gtk/gtkcombobox.c:838 +#: ../gtk/gtkcombobox.c:842 msgid "Whether dropdowns should have a tearoff menu item" msgstr "Indica si los desplegables deben tener un tirador en el menú" -#: ../gtk/gtkcombobox.c:853 ../gtk/gtkentry.c:687 +#: ../gtk/gtkcombobox.c:857 ../gtk/gtkentry.c:778 msgid "Has Frame" msgstr "Tiene marco" -#: ../gtk/gtkcombobox.c:854 +#: ../gtk/gtkcombobox.c:858 msgid "Whether the combo box draws a frame around the child" msgstr "Indica si el ComboBox dibuja un marco alrededor del hijo" -#: ../gtk/gtkcombobox.c:862 +#: ../gtk/gtkcombobox.c:866 msgid "Whether the combo box grabs focus when it is clicked with the mouse" msgstr "Indica si el ComboBox obtiene el foco cuando se pulsa con el ratón" -#: ../gtk/gtkcombobox.c:877 ../gtk/gtkmenu.c:575 +#: ../gtk/gtkcombobox.c:881 ../gtk/gtkmenu.c:576 msgid "Tearoff Title" msgstr "Título del tirador" -#: ../gtk/gtkcombobox.c:878 +#: ../gtk/gtkcombobox.c:882 msgid "" "A title that may be displayed by the window manager when the popup is torn-" "off" msgstr "" "Un título que podría mostrar el gestor de ventanas al desprender el emergente" -#: ../gtk/gtkcombobox.c:895 +#: ../gtk/gtkcombobox.c:899 msgid "Popup shown" msgstr "Emergente mostrado" -#: ../gtk/gtkcombobox.c:896 +#: ../gtk/gtkcombobox.c:900 msgid "Whether the combo's dropdown is shown" msgstr "Indica si se muestra el desplegable del combo" -#: ../gtk/gtkcombobox.c:912 +#: ../gtk/gtkcombobox.c:916 msgid "Button Sensitivity" msgstr "Sensibilidad del botón" -#: ../gtk/gtkcombobox.c:913 +#: ../gtk/gtkcombobox.c:917 msgid "Whether the dropdown button is sensitive when the model is empty" msgstr "Indica si el botón desplegable es sensible cunado el modelo está vacío" -#: ../gtk/gtkcombobox.c:929 +#: ../gtk/gtkcombobox.c:933 msgid "Whether combo box has an entry" msgstr "Indica si el ComboBox tiene una entrada" -#: ../gtk/gtkcombobox.c:944 +#: ../gtk/gtkcombobox.c:948 msgid "Entry Text Column" msgstr "Columna de entrada de texto" -#: ../gtk/gtkcombobox.c:945 +#: ../gtk/gtkcombobox.c:949 msgid "" "The column in the combo box's model to associate with strings from the entry " "if the combo was created with #GtkComboBox:has-entry = %TRUE" @@ -2155,11 +2145,37 @@ msgstr "" "La columna en el modelo ce caja combinada para asociar con cadenas de la " "entrada si la caja combinada se creó con #GtkComboBox:has-entry = %TRUE" -#: ../gtk/gtkcombobox.c:962 +#: ../gtk/gtkcombobox.c:966 +#| msgid "Columns" +msgid "ID Column" +msgstr "ID de la columna" + +#: ../gtk/gtkcombobox.c:967 +#| msgid "" +#| "The column in the combo box's model to associate with strings from the " +#| "entry if the combo was created with #GtkComboBox:has-entry = %TRUE" +msgid "" +"The column in the combo box's model that provides string IDs for the values " +"in the model" +msgstr "" +"La columna en el modelo ce caja combinada que proporciona los ID de cadenas " +"para los valores en el modelo" + +#: ../gtk/gtkcombobox.c:982 +#| msgid "Active" +msgid "Active id" +msgstr "ID activo" + +#: ../gtk/gtkcombobox.c:983 +#| msgid "The name of the icon from the icon theme" +msgid "The value of the id column for the active row" +msgstr "El valor del ID de la columna para la fila activa" + +#: ../gtk/gtkcombobox.c:998 msgid "Popup Fixed Width" msgstr "Anchura fija del emergente" -#: ../gtk/gtkcombobox.c:963 +#: ../gtk/gtkcombobox.c:999 msgid "" "Whether the popup's width should be a fixed width matching the allocated " "width of the combo box" @@ -2167,29 +2183,29 @@ msgstr "" "Indica si la anchura del emergente debería ser fija coincidiendo con la " "anchura reservada para la caja combinada" -#: ../gtk/gtkcombobox.c:971 +#: ../gtk/gtkcombobox.c:1007 msgid "Appears as list" msgstr "Aparece como una lista" -#: ../gtk/gtkcombobox.c:972 +#: ../gtk/gtkcombobox.c:1008 msgid "Whether dropdowns should look like lists rather than menus" msgstr "Indica si los desplegables se parecen a listas en lugar de menús" -#: ../gtk/gtkcombobox.c:988 +#: ../gtk/gtkcombobox.c:1024 msgid "Arrow Size" msgstr "Tamaño de la flecha" -#: ../gtk/gtkcombobox.c:989 +#: ../gtk/gtkcombobox.c:1025 msgid "The minimum size of the arrow in the combo box" msgstr "El tamaño mínimo de la flecha en la caja combo" -#: ../gtk/gtkcombobox.c:1004 ../gtk/gtkentry.c:787 ../gtk/gtkhandlebox.c:182 -#: ../gtk/gtkmenubar.c:189 ../gtk/gtkstatusbar.c:178 ../gtk/gtktoolbar.c:597 -#: ../gtk/gtkviewport.c:148 +#: ../gtk/gtkcombobox.c:1040 ../gtk/gtkentry.c:878 ../gtk/gtkhandlebox.c:188 +#: ../gtk/gtkmenubar.c:196 ../gtk/gtkstatusbar.c:180 ../gtk/gtktoolbar.c:603 +#: ../gtk/gtkviewport.c:154 msgid "Shadow type" msgstr "Tipo de sombra" -#: ../gtk/gtkcombobox.c:1005 +#: ../gtk/gtkcombobox.c:1041 msgid "Which kind of shadow to draw around the combo box" msgstr "Qué clase de sombra dibujar alrededor de la caja combo" @@ -2251,49 +2267,49 @@ msgstr "" "Anchura del borde alrededor del área del botón en la parte inferior del " "diálogo" -#: ../gtk/gtkentry.c:634 +#: ../gtk/gtkentry.c:725 msgid "Text Buffer" msgstr "Búfer de texto" -#: ../gtk/gtkentry.c:635 +#: ../gtk/gtkentry.c:726 msgid "Text buffer object which actually stores entry text" msgstr "Objeto de búfer de texto que realmente almacena la entrada de texto" -#: ../gtk/gtkentry.c:642 ../gtk/gtklabel.c:644 +#: ../gtk/gtkentry.c:733 ../gtk/gtklabel.c:662 msgid "Cursor Position" msgstr "Posición del cursor" -#: ../gtk/gtkentry.c:643 ../gtk/gtklabel.c:645 +#: ../gtk/gtkentry.c:734 ../gtk/gtklabel.c:663 msgid "The current position of the insertion cursor in chars" msgstr "La posición actual del cursor de inserción en caracteres" -#: ../gtk/gtkentry.c:652 ../gtk/gtklabel.c:654 +#: ../gtk/gtkentry.c:743 ../gtk/gtklabel.c:672 msgid "Selection Bound" msgstr "Límite de selección" -#: ../gtk/gtkentry.c:653 ../gtk/gtklabel.c:655 +#: ../gtk/gtkentry.c:744 ../gtk/gtklabel.c:673 msgid "" "The position of the opposite end of the selection from the cursor in chars" msgstr "" "La posición en caracteres del extremo opuesto de la selección desde el cursor" -#: ../gtk/gtkentry.c:663 +#: ../gtk/gtkentry.c:754 msgid "Whether the entry contents can be edited" msgstr "Indica si los contenidos de la entrada pueden editarse" -#: ../gtk/gtkentry.c:670 ../gtk/gtkentrybuffer.c:382 +#: ../gtk/gtkentry.c:761 ../gtk/gtkentrybuffer.c:382 msgid "Maximum length" msgstr "Longitud máxima" -#: ../gtk/gtkentry.c:671 ../gtk/gtkentrybuffer.c:383 +#: ../gtk/gtkentry.c:762 ../gtk/gtkentrybuffer.c:383 msgid "Maximum number of characters for this entry. Zero if no maximum" msgstr "Número máximo de caracteres para esta entrada. Cero si no hay máximo" -#: ../gtk/gtkentry.c:679 +#: ../gtk/gtkentry.c:770 msgid "Visibility" msgstr "Visibilidad" -#: ../gtk/gtkentry.c:680 +#: ../gtk/gtkentry.c:771 msgid "" "FALSE displays the \"invisible char\" instead of the actual text (password " "mode)" @@ -2301,32 +2317,32 @@ msgstr "" "FALSE muestra el «carácter invisible» en lugar del texto actual (modo " "contraseña)" -#: ../gtk/gtkentry.c:688 +#: ../gtk/gtkentry.c:779 msgid "FALSE removes outside bevel from entry" msgstr "FALSE quita el bisel exterior de la entrada" -#: ../gtk/gtkentry.c:696 +#: ../gtk/gtkentry.c:787 msgid "" "Border between text and frame. Overrides the inner-border style property" msgstr "" "Borde entre el texto y el marco. Toma precedencia sobre la propiedad de " "estilo del borde interno" -#: ../gtk/gtkentry.c:703 ../gtk/gtkentry.c:1269 +#: ../gtk/gtkentry.c:794 ../gtk/gtkentry.c:1360 msgid "Invisible character" msgstr "Carácter invisible" -#: ../gtk/gtkentry.c:704 ../gtk/gtkentry.c:1270 +#: ../gtk/gtkentry.c:795 ../gtk/gtkentry.c:1361 msgid "The character to use when masking entry contents (in \"password mode\")" msgstr "" "El carácter que se usará cuando se enmascaren los contenidos de la entrada " "(en «modo contraseña»)" -#: ../gtk/gtkentry.c:711 +#: ../gtk/gtkentry.c:802 msgid "Activates default" msgstr "Activar predeterminado" -#: ../gtk/gtkentry.c:712 +#: ../gtk/gtkentry.c:803 msgid "" "Whether to activate the default widget (such as the default button in a " "dialog) when Enter is pressed" @@ -2334,33 +2350,33 @@ msgstr "" "Indica si se debe activar el widget predeterminado (como el botón " "predeterminado en un diálogo) cuando se pulse INTRO" -#: ../gtk/gtkentry.c:718 +#: ../gtk/gtkentry.c:809 msgid "Width in chars" msgstr "Anchura en caracteres" -#: ../gtk/gtkentry.c:719 +#: ../gtk/gtkentry.c:810 msgid "Number of characters to leave space for in the entry" msgstr "Número de caracteres para dejar de espacio en la entrada" -#: ../gtk/gtkentry.c:728 +#: ../gtk/gtkentry.c:819 msgid "Scroll offset" msgstr "Desplazamiento del scroll" -#: ../gtk/gtkentry.c:729 +#: ../gtk/gtkentry.c:820 msgid "Number of pixels of the entry scrolled off the screen to the left" msgstr "" "Número de píxeles de la entrada desplazados en scroll fuera de la pantalla " "hacia la izquierda" -#: ../gtk/gtkentry.c:739 +#: ../gtk/gtkentry.c:830 msgid "The contents of the entry" msgstr "El contenido de la entrada" -#: ../gtk/gtkentry.c:754 ../gtk/gtkmisc.c:81 +#: ../gtk/gtkentry.c:845 ../gtk/gtkmisc.c:81 msgid "X align" msgstr "X alineación" -#: ../gtk/gtkentry.c:755 ../gtk/gtkmisc.c:82 +#: ../gtk/gtkentry.c:846 ../gtk/gtkmisc.c:82 msgid "" "The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL " "layouts." @@ -2368,68 +2384,68 @@ msgstr "" "La alineación horizontal, desde 0 (izquierda) hasta 1 (derecha). Al revés " "para distribuciones D-->I." -#: ../gtk/gtkentry.c:771 +#: ../gtk/gtkentry.c:862 msgid "Truncate multiline" msgstr "Truncar multilínea" -#: ../gtk/gtkentry.c:772 +#: ../gtk/gtkentry.c:863 msgid "Whether to truncate multiline pastes to one line." msgstr "Indica si se truncan las pegadas multilíneas a una línea." -#: ../gtk/gtkentry.c:788 +#: ../gtk/gtkentry.c:879 msgid "Which kind of shadow to draw around the entry when has-frame is set" msgstr "" "Qué clase de sombra dibujar alrededor de la entrada cuando has-frame está " "activado" -#: ../gtk/gtkentry.c:803 ../gtk/gtktextview.c:740 +#: ../gtk/gtkentry.c:894 ../gtk/gtktextview.c:766 msgid "Overwrite mode" msgstr "Modo de sobreescritura" -#: ../gtk/gtkentry.c:804 +#: ../gtk/gtkentry.c:895 msgid "Whether new text overwrites existing text" msgstr "Indica si el texto introducido sobreescribe el existente" -#: ../gtk/gtkentry.c:818 ../gtk/gtkentrybuffer.c:367 +#: ../gtk/gtkentry.c:909 ../gtk/gtkentrybuffer.c:367 msgid "Text length" msgstr "Longitud del texto" -#: ../gtk/gtkentry.c:819 +#: ../gtk/gtkentry.c:910 msgid "Length of the text currently in the entry" msgstr "Longitud del texto actualmente en la entrada" -#: ../gtk/gtkentry.c:834 +#: ../gtk/gtkentry.c:925 msgid "Invisible character set" msgstr "Conjunto de caracteres invisibles" -#: ../gtk/gtkentry.c:835 +#: ../gtk/gtkentry.c:926 msgid "Whether the invisible character has been set" msgstr "" "Indica si se ha establecido la invisibilidad del conjunto de caracteres" -#: ../gtk/gtkentry.c:853 +#: ../gtk/gtkentry.c:944 msgid "Caps Lock warning" msgstr "Advertencia de bloqueo de mayúsculas" -#: ../gtk/gtkentry.c:854 +#: ../gtk/gtkentry.c:945 msgid "Whether password entries will show a warning when Caps Lock is on" msgstr "" "Indica si en las entradas de contraseñas se muestra una advertencia cuando " "el bloqueo de mayúsculas está activo" -#: ../gtk/gtkentry.c:868 +#: ../gtk/gtkentry.c:959 msgid "Progress Fraction" msgstr "Fracción de progreso" -#: ../gtk/gtkentry.c:869 +#: ../gtk/gtkentry.c:960 msgid "The current fraction of the task that's been completed" msgstr "La fracción actual completada de la tarea" -#: ../gtk/gtkentry.c:886 +#: ../gtk/gtkentry.c:977 msgid "Progress Pulse Step" msgstr "Progreso del paso del pulso" -#: ../gtk/gtkentry.c:887 +#: ../gtk/gtkentry.c:978 msgid "" "The fraction of total entry width to move the progress bouncing block for " "each call to gtk_entry_progress_pulse()" @@ -2437,169 +2453,169 @@ msgstr "" "La fracción del ancho total de la entrada para mover el bloque de rebote de " "progreso para cada llamada a gtk_entry_progress_pulse()" -#: ../gtk/gtkentry.c:903 +#: ../gtk/gtkentry.c:994 msgid "Primary pixbuf" msgstr "Pixbuf primario" -#: ../gtk/gtkentry.c:904 +#: ../gtk/gtkentry.c:995 msgid "Primary pixbuf for the entry" msgstr "El pixbuf primario para la entrada" -#: ../gtk/gtkentry.c:918 +#: ../gtk/gtkentry.c:1009 msgid "Secondary pixbuf" msgstr "Pixbuf secundario" -#: ../gtk/gtkentry.c:919 +#: ../gtk/gtkentry.c:1010 msgid "Secondary pixbuf for the entry" msgstr "El pixbuf secundario para la entrada" -#: ../gtk/gtkentry.c:933 +#: ../gtk/gtkentry.c:1024 msgid "Primary stock ID" msgstr "ID de almacenamiento primario" -#: ../gtk/gtkentry.c:934 +#: ../gtk/gtkentry.c:1025 msgid "Stock ID for primary icon" msgstr "ID de almacenamiento para el icono primario" -#: ../gtk/gtkentry.c:948 +#: ../gtk/gtkentry.c:1039 msgid "Secondary stock ID" msgstr "ID de almacenamiento secundario" -#: ../gtk/gtkentry.c:949 +#: ../gtk/gtkentry.c:1040 msgid "Stock ID for secondary icon" msgstr "ID de almacenamiento para el icono secundario" -#: ../gtk/gtkentry.c:963 +#: ../gtk/gtkentry.c:1054 msgid "Primary icon name" msgstr "Nombre del icono primario" -#: ../gtk/gtkentry.c:964 +#: ../gtk/gtkentry.c:1055 msgid "Icon name for primary icon" msgstr "Nombre del icono para el icono primario" -#: ../gtk/gtkentry.c:978 +#: ../gtk/gtkentry.c:1069 msgid "Secondary icon name" msgstr "Nombre del icono secundario" -#: ../gtk/gtkentry.c:979 +#: ../gtk/gtkentry.c:1070 msgid "Icon name for secondary icon" msgstr "Nombre del icono para el icono secundario" -#: ../gtk/gtkentry.c:993 +#: ../gtk/gtkentry.c:1084 msgid "Primary GIcon" msgstr "GIcon primario" -#: ../gtk/gtkentry.c:994 +#: ../gtk/gtkentry.c:1085 msgid "GIcon for primary icon" msgstr "GIcon para el icono primario" -#: ../gtk/gtkentry.c:1008 +#: ../gtk/gtkentry.c:1099 msgid "Secondary GIcon" msgstr "GIcon secundario" -#: ../gtk/gtkentry.c:1009 +#: ../gtk/gtkentry.c:1100 msgid "GIcon for secondary icon" msgstr "GIcon para el icono secundario" -#: ../gtk/gtkentry.c:1023 +#: ../gtk/gtkentry.c:1114 msgid "Primary storage type" msgstr "Tipo de almacenamiento primario" -#: ../gtk/gtkentry.c:1024 +#: ../gtk/gtkentry.c:1115 msgid "The representation being used for primary icon" msgstr "La representación empleada para el icono primario" -#: ../gtk/gtkentry.c:1039 +#: ../gtk/gtkentry.c:1130 msgid "Secondary storage type" msgstr "Tipo de almacenamiento secundario" -#: ../gtk/gtkentry.c:1040 +#: ../gtk/gtkentry.c:1131 msgid "The representation being used for secondary icon" msgstr "La representación empleada para el icono secundario" -#: ../gtk/gtkentry.c:1061 +#: ../gtk/gtkentry.c:1152 msgid "Primary icon activatable" msgstr "Icono primario activable" -#: ../gtk/gtkentry.c:1062 +#: ../gtk/gtkentry.c:1153 msgid "Whether the primary icon is activatable" msgstr "Indica si el icono primario es activable" -#: ../gtk/gtkentry.c:1082 +#: ../gtk/gtkentry.c:1173 msgid "Secondary icon activatable" msgstr "Icono secundario activable" -#: ../gtk/gtkentry.c:1083 +#: ../gtk/gtkentry.c:1174 msgid "Whether the secondary icon is activatable" msgstr "Indica si el icono secundario es activable" -#: ../gtk/gtkentry.c:1105 +#: ../gtk/gtkentry.c:1196 msgid "Primary icon sensitive" msgstr "Sensibilidad del icono primario" -#: ../gtk/gtkentry.c:1106 +#: ../gtk/gtkentry.c:1197 msgid "Whether the primary icon is sensitive" msgstr "Indica si el icono primario es sensible" -#: ../gtk/gtkentry.c:1127 +#: ../gtk/gtkentry.c:1218 msgid "Secondary icon sensitive" msgstr "Sensibilidad del icono secundario" -#: ../gtk/gtkentry.c:1128 +#: ../gtk/gtkentry.c:1219 msgid "Whether the secondary icon is sensitive" msgstr "Indica si el icono secundario es sensible" -#: ../gtk/gtkentry.c:1144 +#: ../gtk/gtkentry.c:1235 msgid "Primary icon tooltip text" msgstr "Texto del consejo del icono primario" -#: ../gtk/gtkentry.c:1145 ../gtk/gtkentry.c:1181 +#: ../gtk/gtkentry.c:1236 ../gtk/gtkentry.c:1272 msgid "The contents of the tooltip on the primary icon" msgstr "El contenido del consejo para el icono primario" -#: ../gtk/gtkentry.c:1161 +#: ../gtk/gtkentry.c:1252 msgid "Secondary icon tooltip text" msgstr "Texto del consejo del icono secundario" -#: ../gtk/gtkentry.c:1162 ../gtk/gtkentry.c:1200 +#: ../gtk/gtkentry.c:1253 ../gtk/gtkentry.c:1291 msgid "The contents of the tooltip on the secondary icon" msgstr "El contenido del consejo para el icono secundario" -#: ../gtk/gtkentry.c:1180 +#: ../gtk/gtkentry.c:1271 msgid "Primary icon tooltip markup" msgstr "Marcado del consejo del icono primario" -#: ../gtk/gtkentry.c:1199 +#: ../gtk/gtkentry.c:1290 msgid "Secondary icon tooltip markup" msgstr "Marcado del consejo del icono secundario" -#: ../gtk/gtkentry.c:1219 ../gtk/gtktextview.c:768 +#: ../gtk/gtkentry.c:1310 ../gtk/gtktextview.c:794 msgid "IM module" msgstr "Módulo ME" -#: ../gtk/gtkentry.c:1220 ../gtk/gtktextview.c:769 +#: ../gtk/gtkentry.c:1311 ../gtk/gtktextview.c:795 msgid "Which IM module should be used" msgstr "Qué módulo de ME se debe usar" -#: ../gtk/gtkentry.c:1234 +#: ../gtk/gtkentry.c:1325 msgid "Icon Prelight" msgstr "Iluminación de icono" -#: ../gtk/gtkentry.c:1235 +#: ../gtk/gtkentry.c:1326 msgid "Whether activatable icons should prelight when hovered" msgstr "" "Indica si los iconos activables deben iluminarse al pasar el ratón sobre " "ellos" -#: ../gtk/gtkentry.c:1248 +#: ../gtk/gtkentry.c:1339 msgid "Progress Border" msgstr "Borde del progreso" -#: ../gtk/gtkentry.c:1249 +#: ../gtk/gtkentry.c:1340 msgid "Border around the progress bar" msgstr "Borde alrededor de la barra de progreso" -#: ../gtk/gtkentry.c:1741 +#: ../gtk/gtkentry.c:1832 msgid "Border between text and frame." msgstr "Borde entre el texto y el marco." @@ -2627,7 +2643,7 @@ msgstr "Longitud mínima de clave" msgid "Minimum length of the search key in order to look up matches" msgstr "Longitud mínima de la clave de búsqueda para buscar coincidencias" -#: ../gtk/gtkentrycompletion.c:304 ../gtk/gtkiconview.c:605 +#: ../gtk/gtkentrycompletion.c:304 ../gtk/gtkiconview.c:617 msgid "Text column" msgstr "Columna de texto" @@ -2712,11 +2728,11 @@ msgstr "Indica si el expansor ha sido abierto para revelar el widget hijo" msgid "Text of the expander's label" msgstr "Texto de la etiqueta del expansor" -#: ../gtk/gtkexpander.c:225 ../gtk/gtklabel.c:563 +#: ../gtk/gtkexpander.c:225 ../gtk/gtklabel.c:581 msgid "Use markup" msgstr "Usar marcado" -#: ../gtk/gtkexpander.c:226 ../gtk/gtklabel.c:564 +#: ../gtk/gtkexpander.c:226 ../gtk/gtklabel.c:582 msgid "The text of the label includes XML markup. See pango_parse_markup()" msgstr "El texto de la etiqueta incluye marcado XML. Vea pango_parse_markup()" @@ -2725,7 +2741,7 @@ msgid "Space to put between the label and the child" msgstr "Espacio para colocar entre la etiqueta y el hijo" #: ../gtk/gtkexpander.c:243 ../gtk/gtkframe.c:165 ../gtk/gtktoolbutton.c:216 -#: ../gtk/gtktoolitemgroup.c:1578 +#: ../gtk/gtktoolitemgroup.c:1595 msgid "Label widget" msgstr "Widget etiqueta" @@ -2743,13 +2759,13 @@ msgstr "" "Indica si el widget de etiqueta debería llenar todo el espacio horizontal " "disponible" -#: ../gtk/gtkexpander.c:258 ../gtk/gtktoolitemgroup.c:1606 -#: ../gtk/gtktreeview.c:766 +#: ../gtk/gtkexpander.c:258 ../gtk/gtktoolitemgroup.c:1623 +#: ../gtk/gtktreeview.c:863 msgid "Expander Size" msgstr "Tamaño del expansor" -#: ../gtk/gtkexpander.c:259 ../gtk/gtktoolitemgroup.c:1607 -#: ../gtk/gtktreeview.c:767 +#: ../gtk/gtkexpander.c:259 ../gtk/gtktoolitemgroup.c:1624 +#: ../gtk/gtktreeview.c:864 msgid "Size of the expander arrow" msgstr "Tamaño de la flecha del expansor" @@ -2876,19 +2892,19 @@ msgstr "" "Indica si un selector de archivos en modo distinto a abrir ofrece al usuario " "la posibilidad de crear carpetas nuevas." -#: ../gtk/gtkfixed.c:98 ../gtk/gtklayout.c:603 +#: ../gtk/gtkfixed.c:103 ../gtk/gtklayout.c:633 msgid "X position" msgstr "Posición X" -#: ../gtk/gtkfixed.c:99 ../gtk/gtklayout.c:604 +#: ../gtk/gtkfixed.c:104 ../gtk/gtklayout.c:634 msgid "X position of child widget" msgstr "Posición X del widget hijo" -#: ../gtk/gtkfixed.c:108 ../gtk/gtklayout.c:613 +#: ../gtk/gtkfixed.c:111 ../gtk/gtklayout.c:643 msgid "Y position" msgstr "Posición Y" -#: ../gtk/gtkfixed.c:109 ../gtk/gtklayout.c:614 +#: ../gtk/gtkfixed.c:112 ../gtk/gtklayout.c:644 msgid "Y position of child widget" msgstr "Posición Y del widget hijo" @@ -2986,23 +3002,23 @@ msgstr "Apariencia del borde del marco" msgid "A widget to display in place of the usual frame label" msgstr "Un widget a mostrar en lugar de la usual etiqueta del marco" -#: ../gtk/gtkhandlebox.c:183 +#: ../gtk/gtkhandlebox.c:189 msgid "Appearance of the shadow that surrounds the container" msgstr "Apariencia de la sombra que rodea al contenedor" -#: ../gtk/gtkhandlebox.c:191 +#: ../gtk/gtkhandlebox.c:197 msgid "Handle position" msgstr "Posición del tirador" -#: ../gtk/gtkhandlebox.c:192 +#: ../gtk/gtkhandlebox.c:198 msgid "Position of the handle relative to the child widget" msgstr "Posición del tirador relativa al widget hijo" -#: ../gtk/gtkhandlebox.c:200 +#: ../gtk/gtkhandlebox.c:206 msgid "Snap edge" msgstr "Ajustar al borde" -#: ../gtk/gtkhandlebox.c:201 +#: ../gtk/gtkhandlebox.c:207 msgid "" "Side of the handlebox that's lined up with the docking point to dock the " "handlebox" @@ -3010,11 +3026,11 @@ msgstr "" "Lado de la caja manipuladora que está alineada con el punto de anclaje para " "anclar la caja manejadora" -#: ../gtk/gtkhandlebox.c:209 +#: ../gtk/gtkhandlebox.c:215 msgid "Snap edge set" msgstr "Ajuste al borde establecido" -#: ../gtk/gtkhandlebox.c:210 +#: ../gtk/gtkhandlebox.c:216 msgid "" "Whether to use the value from the snap_edge property or a value derived from " "handle_position" @@ -3022,11 +3038,11 @@ msgstr "" "Indica si se debe usar el valor desde la propiedad snap_edge o un valor " "derivado de handle_position" -#: ../gtk/gtkhandlebox.c:217 +#: ../gtk/gtkhandlebox.c:223 msgid "Child Detached" msgstr "Hijo desacoplado" -#: ../gtk/gtkhandlebox.c:218 +#: ../gtk/gtkhandlebox.c:224 msgid "" "A boolean value indicating whether the handlebox's child is attached or " "detached." @@ -3034,217 +3050,217 @@ msgstr "" "Una variable booleana indicando si el hijo del manejador de la caja está " "acoplado o desacoplado." -#: ../gtk/gtkiconview.c:568 +#: ../gtk/gtkiconview.c:580 msgid "Selection mode" msgstr "Modo de selección" -#: ../gtk/gtkiconview.c:569 +#: ../gtk/gtkiconview.c:581 msgid "The selection mode" msgstr "El modo de selección" -#: ../gtk/gtkiconview.c:587 +#: ../gtk/gtkiconview.c:599 msgid "Pixbuf column" msgstr "Columna de pixbuf" -#: ../gtk/gtkiconview.c:588 +#: ../gtk/gtkiconview.c:600 msgid "Model column used to retrieve the icon pixbuf from" msgstr "Columna modelo usada para obtener el pixbuf del icono" -#: ../gtk/gtkiconview.c:606 +#: ../gtk/gtkiconview.c:618 msgid "Model column used to retrieve the text from" msgstr "Columna modelo usada para obtener el texto" -#: ../gtk/gtkiconview.c:625 +#: ../gtk/gtkiconview.c:637 msgid "Markup column" msgstr "Columna de marcado" -#: ../gtk/gtkiconview.c:626 +#: ../gtk/gtkiconview.c:638 msgid "Model column used to retrieve the text if using Pango markup" msgstr "Columna modelo usada para obtener el texto si se usa marcado Pango" -#: ../gtk/gtkiconview.c:633 +#: ../gtk/gtkiconview.c:645 msgid "Icon View Model" msgstr "Modelo de vista de icono" -#: ../gtk/gtkiconview.c:634 +#: ../gtk/gtkiconview.c:646 msgid "The model for the icon view" msgstr "El modelo para la vista de icono" -#: ../gtk/gtkiconview.c:650 +#: ../gtk/gtkiconview.c:662 msgid "Number of columns" msgstr "Número de columnas" -#: ../gtk/gtkiconview.c:651 +#: ../gtk/gtkiconview.c:663 msgid "Number of columns to display" msgstr "El número de columnas que se mostrarán" -#: ../gtk/gtkiconview.c:668 +#: ../gtk/gtkiconview.c:680 msgid "Width for each item" msgstr "Anchura de cada elemento" -#: ../gtk/gtkiconview.c:669 +#: ../gtk/gtkiconview.c:681 msgid "The width used for each item" msgstr "La anchura usada por cada elemento" -#: ../gtk/gtkiconview.c:685 +#: ../gtk/gtkiconview.c:697 msgid "Space which is inserted between cells of an item" msgstr "Espacio que se introduce entre las celdas de un elemento" -#: ../gtk/gtkiconview.c:700 +#: ../gtk/gtkiconview.c:712 msgid "Row Spacing" msgstr "Espaciado entre filas" -#: ../gtk/gtkiconview.c:701 +#: ../gtk/gtkiconview.c:713 msgid "Space which is inserted between grid rows" msgstr "Espacio que se introduce entre las filas de la rejilla" -#: ../gtk/gtkiconview.c:716 +#: ../gtk/gtkiconview.c:728 msgid "Column Spacing" msgstr "Espaciado entre columnas" -#: ../gtk/gtkiconview.c:717 +#: ../gtk/gtkiconview.c:729 msgid "Space which is inserted between grid columns" msgstr "Espacio que se inserta entre las columnas de la rejilla" -#: ../gtk/gtkiconview.c:732 +#: ../gtk/gtkiconview.c:744 msgid "Margin" msgstr "Margen" -#: ../gtk/gtkiconview.c:733 +#: ../gtk/gtkiconview.c:745 msgid "Space which is inserted at the edges of the icon view" msgstr "Espacio que se introduce entre los bordes de la vista de icono" -#: ../gtk/gtkiconview.c:748 +#: ../gtk/gtkiconview.c:760 msgid "Item Orientation" msgstr "Orientación del elemento" -#: ../gtk/gtkiconview.c:749 +#: ../gtk/gtkiconview.c:761 msgid "" "How the text and icon of each item are positioned relative to each other" msgstr "" "Cómo se sitúan el texto y el icono para cada elemento relativo a los demás" -#: ../gtk/gtkiconview.c:765 ../gtk/gtktreeview.c:601 +#: ../gtk/gtkiconview.c:777 ../gtk/gtktreeview.c:698 #: ../gtk/gtktreeviewcolumn.c:329 msgid "Reorderable" msgstr "Reordenable" -#: ../gtk/gtkiconview.c:766 ../gtk/gtktreeview.c:602 +#: ../gtk/gtkiconview.c:778 ../gtk/gtktreeview.c:699 msgid "View is reorderable" msgstr "La vista es reordenable" -#: ../gtk/gtkiconview.c:773 ../gtk/gtktreeview.c:752 +#: ../gtk/gtkiconview.c:785 ../gtk/gtktreeview.c:849 msgid "Tooltip Column" msgstr "Columna de consejo" -#: ../gtk/gtkiconview.c:774 +#: ../gtk/gtkiconview.c:786 msgid "The column in the model containing the tooltip texts for the items" msgstr "" "La columna del modelo que contiene los textos de consejo para los elementos" -#: ../gtk/gtkiconview.c:791 +#: ../gtk/gtkiconview.c:803 msgid "Item Padding" msgstr "Separación del elemento" -#: ../gtk/gtkiconview.c:792 +#: ../gtk/gtkiconview.c:804 msgid "Padding around icon view items" msgstr "Separación alrededor de la vista de iconos" -#: ../gtk/gtkiconview.c:803 +#: ../gtk/gtkiconview.c:817 msgid "Selection Box Color" msgstr "Color de la caja de selección" -#: ../gtk/gtkiconview.c:804 +#: ../gtk/gtkiconview.c:818 msgid "Color of the selection box" msgstr "Color de la caja de selección" -#: ../gtk/gtkiconview.c:810 +#: ../gtk/gtkiconview.c:824 msgid "Selection Box Alpha" msgstr "Alfa de la caja de selección" -#: ../gtk/gtkiconview.c:811 +#: ../gtk/gtkiconview.c:825 msgid "Opacity of the selection box" msgstr "Opacidad de la caja de selección" -#: ../gtk/gtkimage.c:227 ../gtk/gtkstatusicon.c:212 +#: ../gtk/gtkimage.c:233 ../gtk/gtkstatusicon.c:212 msgid "Pixbuf" msgstr "Pixbuf" -#: ../gtk/gtkimage.c:228 ../gtk/gtkstatusicon.c:213 +#: ../gtk/gtkimage.c:234 ../gtk/gtkstatusicon.c:213 msgid "A GdkPixbuf to display" msgstr "Un GdkPixbuf para mostrar" -#: ../gtk/gtkimage.c:235 ../gtk/gtkrecentmanager.c:294 +#: ../gtk/gtkimage.c:241 ../gtk/gtkrecentmanager.c:294 #: ../gtk/gtkstatusicon.c:220 msgid "Filename" msgstr "Nombre de archivo" -#: ../gtk/gtkimage.c:236 ../gtk/gtkstatusicon.c:221 +#: ../gtk/gtkimage.c:242 ../gtk/gtkstatusicon.c:221 msgid "Filename to load and display" msgstr "Nombre del archivo a cargar y mostrar" -#: ../gtk/gtkimage.c:245 ../gtk/gtkstatusicon.c:229 +#: ../gtk/gtkimage.c:251 ../gtk/gtkstatusicon.c:229 msgid "Stock ID for a stock image to display" msgstr "ID de inventario para una imagen de inventario que mostrar" -#: ../gtk/gtkimage.c:252 +#: ../gtk/gtkimage.c:258 msgid "Icon set" msgstr "Conjunto de iconos" -#: ../gtk/gtkimage.c:253 +#: ../gtk/gtkimage.c:259 msgid "Icon set to display" msgstr "Conjunto de iconos para mostrar" -#: ../gtk/gtkimage.c:260 ../gtk/gtkscalebutton.c:230 ../gtk/gtktoolbar.c:514 -#: ../gtk/gtktoolpalette.c:976 +#: ../gtk/gtkimage.c:266 ../gtk/gtkscalebutton.c:230 ../gtk/gtktoolbar.c:520 +#: ../gtk/gtktoolpalette.c:1030 msgid "Icon size" msgstr "Tamaño del icono" -#: ../gtk/gtkimage.c:261 +#: ../gtk/gtkimage.c:267 msgid "Symbolic size to use for stock icon, icon set or named icon" msgstr "" "Tamaño simbólico que usar para el icono de inventario, conjunto de iconos o " "icono nombrado" -#: ../gtk/gtkimage.c:277 +#: ../gtk/gtkimage.c:283 msgid "Pixel size" msgstr "Tamaño del píxel" -#: ../gtk/gtkimage.c:278 +#: ../gtk/gtkimage.c:284 msgid "Pixel size to use for named icon" msgstr "Tamaño de píxel que usar para el icono nombrado" -#: ../gtk/gtkimage.c:286 +#: ../gtk/gtkimage.c:292 msgid "Animation" msgstr "Animación" -#: ../gtk/gtkimage.c:287 +#: ../gtk/gtkimage.c:293 msgid "GdkPixbufAnimation to display" msgstr "GdkPixbufAnimation para mostrar" -#: ../gtk/gtkimage.c:327 ../gtk/gtkstatusicon.c:260 +#: ../gtk/gtkimage.c:333 ../gtk/gtkstatusicon.c:260 msgid "Storage type" msgstr "Tipo de almacenamiento" -#: ../gtk/gtkimage.c:328 ../gtk/gtkstatusicon.c:261 +#: ../gtk/gtkimage.c:334 ../gtk/gtkstatusicon.c:261 msgid "The representation being used for image data" msgstr "La representación empleada para los datos de la imagen" -#: ../gtk/gtkimagemenuitem.c:139 +#: ../gtk/gtkimagemenuitem.c:149 msgid "Child widget to appear next to the menu text" msgstr "Widget hijo que aparecerá al lado del texto del menú" -#: ../gtk/gtkimagemenuitem.c:154 +#: ../gtk/gtkimagemenuitem.c:164 msgid "Whether to use the label text to create a stock menu item" msgstr "" "Indica si se debe usar el texto de la etiqueta para crear un elemento del " "menú de stock" -#: ../gtk/gtkimagemenuitem.c:187 ../gtk/gtkmenu.c:535 +#: ../gtk/gtkimagemenuitem.c:197 ../gtk/gtkmenu.c:536 msgid "Accel Group" msgstr "Grupo de aceleración" -#: ../gtk/gtkimagemenuitem.c:188 +#: ../gtk/gtkimagemenuitem.c:198 msgid "The Accel Group to use for stock accelerator keys" msgstr "" "El grupo de aceleración que usar para los aceleradores de teclado de stock" @@ -3270,27 +3286,27 @@ msgid "Width of border around the action area" msgstr "Anchura del borde alrededor del área de acción" #: ../gtk/gtkinvisible.c:90 ../gtk/gtkmountoperation.c:175 -#: ../gtk/gtkstatusicon.c:279 ../gtk/gtkwindow.c:740 +#: ../gtk/gtkstatusicon.c:279 ../gtk/gtkwindow.c:741 msgid "Screen" msgstr "Pantalla" -#: ../gtk/gtkinvisible.c:91 ../gtk/gtkwindow.c:741 +#: ../gtk/gtkinvisible.c:91 ../gtk/gtkwindow.c:742 msgid "The screen where this window will be displayed" msgstr "La pantalla donde se mostrará esta ventana" -#: ../gtk/gtklabel.c:550 +#: ../gtk/gtklabel.c:568 msgid "The text of the label" msgstr "El texto de la etiqueta" -#: ../gtk/gtklabel.c:557 +#: ../gtk/gtklabel.c:575 msgid "A list of style attributes to apply to the text of the label" msgstr "Un lista de atributos de estilos para aplicar al texto de la etiqueta" -#: ../gtk/gtklabel.c:578 ../gtk/gtktexttag.c:335 ../gtk/gtktextview.c:677 +#: ../gtk/gtklabel.c:596 ../gtk/gtktexttag.c:335 ../gtk/gtktextview.c:703 msgid "Justification" msgstr "Justificación" -#: ../gtk/gtklabel.c:579 +#: ../gtk/gtklabel.c:597 msgid "" "The alignment of the lines in the text of the label relative to each other. " "This does NOT affect the alignment of the label within its allocation. See " @@ -3300,11 +3316,11 @@ msgstr "" "Esto NO afecta la alineación de la etiqueta dentro de su ubicación. Ver " "GtkMisc::xalign para ello" -#: ../gtk/gtklabel.c:587 +#: ../gtk/gtklabel.c:605 msgid "Pattern" msgstr "Patrón" -#: ../gtk/gtklabel.c:588 +#: ../gtk/gtklabel.c:606 msgid "" "A string with _ characters in positions correspond to characters in the text " "to underline" @@ -3312,50 +3328,50 @@ msgstr "" "Un cadena con caracteres _ en posiciones correspondientes a caracteres en el " "texto a subrayar" -#: ../gtk/gtklabel.c:595 +#: ../gtk/gtklabel.c:613 msgid "Line wrap" msgstr "Ajuste de línea" -#: ../gtk/gtklabel.c:596 +#: ../gtk/gtklabel.c:614 msgid "If set, wrap lines if the text becomes too wide" msgstr "" "Si esta definido, ajustar las líneas si el texto se vuelve demasiado ancho" -#: ../gtk/gtklabel.c:611 +#: ../gtk/gtklabel.c:629 msgid "Line wrap mode" msgstr "Modo de ajuste de línea" -#: ../gtk/gtklabel.c:612 +#: ../gtk/gtklabel.c:630 msgid "If wrap is set, controls how linewrapping is done" msgstr "Si se establece el ajuste, controla cómo se hace el ajuste de línea" -#: ../gtk/gtklabel.c:619 +#: ../gtk/gtklabel.c:637 msgid "Selectable" msgstr "Seleccionable" -#: ../gtk/gtklabel.c:620 +#: ../gtk/gtklabel.c:638 msgid "Whether the label text can be selected with the mouse" msgstr "Indica si el texto de la etiqueta puede ser seleccionado con el ratón" -#: ../gtk/gtklabel.c:626 +#: ../gtk/gtklabel.c:644 msgid "Mnemonic key" msgstr "Tecla nemónica" -#: ../gtk/gtklabel.c:627 +#: ../gtk/gtklabel.c:645 msgid "The mnemonic accelerator key for this label" msgstr "La tecla nemotécnica del acelerador para esta etiqueta" -#: ../gtk/gtklabel.c:635 +#: ../gtk/gtklabel.c:653 msgid "Mnemonic widget" msgstr "Widget nemónico" -#: ../gtk/gtklabel.c:636 +#: ../gtk/gtklabel.c:654 msgid "The widget to be activated when the label's mnemonic key is pressed" msgstr "" "El widget que se activará cuando se presione la tecla mnemotécnica de la " "etiqueta" -#: ../gtk/gtklabel.c:682 +#: ../gtk/gtklabel.c:700 msgid "" "The preferred place to ellipsize the string, if the label does not have " "enough room to display the entire string" @@ -3363,47 +3379,47 @@ msgstr "" "El lugar preferido para la elipsis de la cadena, si la etiqueta no tiene " "suficiente espacio para mostrar la cadena completa" -#: ../gtk/gtklabel.c:723 +#: ../gtk/gtklabel.c:741 msgid "Single Line Mode" msgstr "Modo de línea única" -#: ../gtk/gtklabel.c:724 +#: ../gtk/gtklabel.c:742 msgid "Whether the label is in single line mode" msgstr "Indica si la etiqueta está en modo de línea única" -#: ../gtk/gtklabel.c:741 +#: ../gtk/gtklabel.c:759 msgid "Angle" msgstr "Ángulo" -#: ../gtk/gtklabel.c:742 +#: ../gtk/gtklabel.c:760 msgid "Angle at which the label is rotated" msgstr "Ángulo al cual la etiqueta se rota" -#: ../gtk/gtklabel.c:764 +#: ../gtk/gtklabel.c:782 msgid "The desired maximum width of the label, in characters" msgstr "La anchura máxima deseada de la etiqueta, en caracteres" -#: ../gtk/gtklabel.c:782 +#: ../gtk/gtklabel.c:800 msgid "Track visited links" msgstr "Seguir los enlaces visitados" -#: ../gtk/gtklabel.c:783 +#: ../gtk/gtklabel.c:801 msgid "Whether visited links should be tracked" msgstr "Indica si deben seguir los enlaces visitados" -#: ../gtk/gtklayout.c:627 ../gtk/gtktreeviewcolumn.c:229 +#: ../gtk/gtklayout.c:659 ../gtk/gtktreeviewcolumn.c:229 msgid "Width" msgstr "Anchura" -#: ../gtk/gtklayout.c:628 +#: ../gtk/gtklayout.c:660 msgid "The width of the layout" msgstr "La anchura de la distribución" -#: ../gtk/gtklayout.c:636 +#: ../gtk/gtklayout.c:668 msgid "Height" msgstr "Altura" -#: ../gtk/gtklayout.c:637 +#: ../gtk/gtklayout.c:669 msgid "The height of the layout" msgstr "La altura de la distribución" @@ -3423,63 +3439,63 @@ msgstr "Visitado" msgid "Whether this link has been visited." msgstr "Indica si este enlace se ha visitado." -#: ../gtk/gtkmenubar.c:163 +#: ../gtk/gtkmenubar.c:170 msgid "Pack direction" msgstr "Dirección del empaquetado" -#: ../gtk/gtkmenubar.c:164 +#: ../gtk/gtkmenubar.c:171 msgid "The pack direction of the menubar" msgstr "La dirección del empaquetado de la barra de menú" -#: ../gtk/gtkmenubar.c:180 +#: ../gtk/gtkmenubar.c:187 msgid "Child Pack direction" msgstr "Dirección de empaquetado del hijo" -#: ../gtk/gtkmenubar.c:181 +#: ../gtk/gtkmenubar.c:188 msgid "The child pack direction of the menubar" msgstr "La dirección de empaquetado hijo de la barra de menú" -#: ../gtk/gtkmenubar.c:190 +#: ../gtk/gtkmenubar.c:197 msgid "Style of bevel around the menubar" msgstr "Estilo del bisel alrededor de la barra de menús" -#: ../gtk/gtkmenubar.c:197 ../gtk/gtktoolbar.c:564 +#: ../gtk/gtkmenubar.c:204 ../gtk/gtktoolbar.c:570 msgid "Internal padding" msgstr "Relleno interno" -#: ../gtk/gtkmenubar.c:198 +#: ../gtk/gtkmenubar.c:205 msgid "Amount of border space between the menubar shadow and the menu items" msgstr "" "Número de espacios del borde entre la sombra de la barra de menús y los " "elementos del menú" -#: ../gtk/gtkmenu.c:521 +#: ../gtk/gtkmenu.c:522 msgid "The currently selected menu item" msgstr "El elemento del menú actualmente seleccionado" -#: ../gtk/gtkmenu.c:536 +#: ../gtk/gtkmenu.c:537 msgid "The accel group holding accelerators for the menu" msgstr "El grupo de aceleración que contiene los aceleradores para el menú" -#: ../gtk/gtkmenu.c:550 ../gtk/gtkmenuitem.c:316 +#: ../gtk/gtkmenu.c:551 ../gtk/gtkmenuitem.c:316 msgid "Accel Path" msgstr "Ruta del acelerador" -#: ../gtk/gtkmenu.c:551 +#: ../gtk/gtkmenu.c:552 msgid "An accel path used to conveniently construct accel paths of child items" msgstr "" "Una ruta de acelerador usada para construir convenientemente rutas de " "aceleración de elementos hijo" -#: ../gtk/gtkmenu.c:567 +#: ../gtk/gtkmenu.c:568 msgid "Attach Widget" msgstr "Acoplar widget" -#: ../gtk/gtkmenu.c:568 +#: ../gtk/gtkmenu.c:569 msgid "The widget the menu is attached to" msgstr "El menú al que está acoplado el widget" -#: ../gtk/gtkmenu.c:576 +#: ../gtk/gtkmenu.c:577 msgid "" "A title that may be displayed by the window manager when this menu is torn-" "off" @@ -3487,54 +3503,54 @@ msgstr "" "Un título que podría mostrarse por el administrador de ventanas cuando este " "menú se desprenda" -#: ../gtk/gtkmenu.c:590 +#: ../gtk/gtkmenu.c:591 msgid "Tearoff State" msgstr "Estado de desprendimiento" -#: ../gtk/gtkmenu.c:591 +#: ../gtk/gtkmenu.c:592 msgid "A boolean that indicates whether the menu is torn-off" msgstr "Un booleano que indica si el menú ha sido desprendido" -#: ../gtk/gtkmenu.c:605 +#: ../gtk/gtkmenu.c:606 msgid "Monitor" msgstr "Monitor" -#: ../gtk/gtkmenu.c:606 +#: ../gtk/gtkmenu.c:607 msgid "The monitor the menu will be popped up on" msgstr "El monitor en el que se mostrará el menú" -#: ../gtk/gtkmenu.c:612 +#: ../gtk/gtkmenu.c:613 msgid "Vertical Padding" msgstr "Separación vertical" -#: ../gtk/gtkmenu.c:613 +#: ../gtk/gtkmenu.c:614 msgid "Extra space at the top and bottom of the menu" msgstr "El espacio adicional en la parte superior e inferior del menú" -#: ../gtk/gtkmenu.c:635 +#: ../gtk/gtkmenu.c:636 msgid "Reserve Toggle Size" msgstr "Reservar tamaño para conmutar" -#: ../gtk/gtkmenu.c:636 +#: ../gtk/gtkmenu.c:637 msgid "" "A boolean that indicates whether the menu reserves space for toggles and " "icons" msgstr "" "Un booleano que indica si el menú reserva espacio para conmutadores e iconos" -#: ../gtk/gtkmenu.c:642 +#: ../gtk/gtkmenu.c:643 msgid "Horizontal Padding" msgstr "Separación horizontal" -#: ../gtk/gtkmenu.c:643 +#: ../gtk/gtkmenu.c:644 msgid "Extra space at the left and right edges of the menu" msgstr "El espacio adicional en los bordes derecho e izquierdo del menú" -#: ../gtk/gtkmenu.c:651 +#: ../gtk/gtkmenu.c:652 msgid "Vertical Offset" msgstr "Desplazamiento vertical" -#: ../gtk/gtkmenu.c:652 +#: ../gtk/gtkmenu.c:653 msgid "" "When the menu is a submenu, position it this number of pixels offset " "vertically" @@ -3542,11 +3558,11 @@ msgstr "" "Cuando el menú es un submenú, colocarlo este número de píxeles de " "desplazamiento vertical" -#: ../gtk/gtkmenu.c:660 +#: ../gtk/gtkmenu.c:661 msgid "Horizontal Offset" msgstr "Desplazamiento horizontal" -#: ../gtk/gtkmenu.c:661 +#: ../gtk/gtkmenu.c:662 msgid "" "When the menu is a submenu, position it this number of pixels offset " "horizontally" @@ -3554,55 +3570,55 @@ msgstr "" "Cuando el menú es un submenú, colocarlo este número de píxeles de " "desplazamiento horizontal" -#: ../gtk/gtkmenu.c:669 +#: ../gtk/gtkmenu.c:670 msgid "Double Arrows" msgstr "Dobles flechas" -#: ../gtk/gtkmenu.c:670 +#: ../gtk/gtkmenu.c:671 msgid "When scrolling, always show both arrows." msgstr "Al desplazar, siempre mostrar ambas flechas." -#: ../gtk/gtkmenu.c:683 +#: ../gtk/gtkmenu.c:684 msgid "Arrow Placement" msgstr "Colocación de flecha" -#: ../gtk/gtkmenu.c:684 +#: ../gtk/gtkmenu.c:685 msgid "Indicates where scroll arrows should be placed" msgstr "Indica si las flechas de desplazamiento se deben colocar" -#: ../gtk/gtkmenu.c:692 +#: ../gtk/gtkmenu.c:693 msgid "Left Attach" msgstr "Acoplar a la izquierda" -#: ../gtk/gtkmenu.c:693 ../gtk/gtktable.c:197 +#: ../gtk/gtkmenu.c:694 ../gtk/gtktable.c:202 msgid "The column number to attach the left side of the child to" msgstr "El número de columnas que acoplar al lado izquierdo del hijo" -#: ../gtk/gtkmenu.c:700 +#: ../gtk/gtkmenu.c:701 msgid "Right Attach" msgstr "Acoplar a la derecha" -#: ../gtk/gtkmenu.c:701 +#: ../gtk/gtkmenu.c:702 msgid "The column number to attach the right side of the child to" msgstr "El número de columnas que acoplar al lado derecho del hijo" -#: ../gtk/gtkmenu.c:708 +#: ../gtk/gtkmenu.c:709 msgid "Top Attach" msgstr "Acoplamiento superior" -#: ../gtk/gtkmenu.c:709 +#: ../gtk/gtkmenu.c:710 msgid "The row number to attach the top of the child to" msgstr "El número de filas que acoplar por encima del hijo" -#: ../gtk/gtkmenu.c:716 +#: ../gtk/gtkmenu.c:717 msgid "Bottom Attach" msgstr "Acoplamiento inferior" -#: ../gtk/gtkmenu.c:717 ../gtk/gtktable.c:218 +#: ../gtk/gtkmenu.c:718 ../gtk/gtktable.c:223 msgid "The row number to attach the bottom of the child to" msgstr "El número de filas que acoplar por debajo del hijo" -#: ../gtk/gtkmenu.c:731 +#: ../gtk/gtkmenu.c:732 msgid "Arbitrary constant to scale down the size of the scroll arrow" msgstr "" "Constante arbitraria para reducir el escalado del tamaño de la flecha de " @@ -3649,11 +3665,11 @@ msgstr "Anchura en caracteres" msgid "The minimum desired width of the menu item in characters" msgstr "La anchura mínima deseada del elemento del menú en caracteres" -#: ../gtk/gtkmenushell.c:379 +#: ../gtk/gtkmenushell.c:381 msgid "Take Focus" msgstr "Toma el foco" -#: ../gtk/gtkmenushell.c:380 +#: ../gtk/gtkmenushell.c:382 msgid "A boolean that determines whether the menu grabs the keyboard focus" msgstr "Un booleano que indica si el menú obtiene el foco del teclado" @@ -3777,52 +3793,52 @@ msgstr "Estamos mostrando un diálogo" msgid "The screen where this window will be displayed." msgstr "La pantalla donde se mostrará esta ventana." -#: ../gtk/gtknotebook.c:682 +#: ../gtk/gtknotebook.c:689 msgid "Page" msgstr "Página" -#: ../gtk/gtknotebook.c:683 +#: ../gtk/gtknotebook.c:690 msgid "The index of the current page" msgstr "El índice de la página actual" -#: ../gtk/gtknotebook.c:691 +#: ../gtk/gtknotebook.c:698 msgid "Tab Position" msgstr "Posición del tabulador" -#: ../gtk/gtknotebook.c:692 +#: ../gtk/gtknotebook.c:699 msgid "Which side of the notebook holds the tabs" msgstr "Qué lado del cuaderno contiene las solapas" -#: ../gtk/gtknotebook.c:699 +#: ../gtk/gtknotebook.c:706 msgid "Show Tabs" msgstr "Mostrar solapas" -#: ../gtk/gtknotebook.c:700 +#: ../gtk/gtknotebook.c:707 msgid "Whether tabs should be shown" msgstr "Indica si se deben mostrar las solapas" -#: ../gtk/gtknotebook.c:706 +#: ../gtk/gtknotebook.c:713 msgid "Show Border" msgstr "Mostrar borde" -#: ../gtk/gtknotebook.c:707 +#: ../gtk/gtknotebook.c:714 msgid "Whether the border should be shown" msgstr "Indica si se debe mostrar el borde" -#: ../gtk/gtknotebook.c:713 +#: ../gtk/gtknotebook.c:720 msgid "Scrollable" msgstr "Desplazable" -#: ../gtk/gtknotebook.c:714 +#: ../gtk/gtknotebook.c:721 msgid "If TRUE, scroll arrows are added if there are too many tabs to fit" msgstr "" "Si es TRUE, añadir flechas de desplazamiento si no caben todas las solapas" -#: ../gtk/gtknotebook.c:720 +#: ../gtk/gtknotebook.c:727 msgid "Enable Popup" msgstr "Activar emergente" -#: ../gtk/gtknotebook.c:721 +#: ../gtk/gtknotebook.c:728 msgid "" "If TRUE, pressing the right mouse button on the notebook pops up a menu that " "you can use to go to a page" @@ -3830,125 +3846,125 @@ msgstr "" "Si es TRUE, presionando el botón derecho del ratón en el cuaderno emerge un " "menú que puede usar para ir a una página" -#: ../gtk/gtknotebook.c:735 +#: ../gtk/gtknotebook.c:742 msgid "Group Name" msgstr "Nombre del grupo" -#: ../gtk/gtknotebook.c:736 +#: ../gtk/gtknotebook.c:743 msgid "Group name for tab drag and drop" msgstr "Nombre del grupo para el arrastre y suelte de solapas" -#: ../gtk/gtknotebook.c:743 +#: ../gtk/gtknotebook.c:750 msgid "Tab label" msgstr "Etiqueta de la solapa" -#: ../gtk/gtknotebook.c:744 +#: ../gtk/gtknotebook.c:751 msgid "The string displayed on the child's tab label" msgstr "La cadena mostrada en la etiqueta de la solapa hija" -#: ../gtk/gtknotebook.c:750 +#: ../gtk/gtknotebook.c:757 msgid "Menu label" msgstr "Etiqueta de menú" -#: ../gtk/gtknotebook.c:751 +#: ../gtk/gtknotebook.c:758 msgid "The string displayed in the child's menu entry" msgstr "La cadena mostrada en la entrada de menú hija" -#: ../gtk/gtknotebook.c:764 +#: ../gtk/gtknotebook.c:771 msgid "Tab expand" msgstr "Expansión de la solapa" -#: ../gtk/gtknotebook.c:765 +#: ../gtk/gtknotebook.c:772 msgid "Whether to expand the child's tab" msgstr "Indica si se deben expandir la solapas del hijo" -#: ../gtk/gtknotebook.c:771 +#: ../gtk/gtknotebook.c:778 msgid "Tab fill" msgstr "Relleno de la solapa" -#: ../gtk/gtknotebook.c:772 +#: ../gtk/gtknotebook.c:779 msgid "Whether the child's tab should fill the allocated area" msgstr "Indica si se debe rellenar el área asignada de las solapas hijas " -#: ../gtk/gtknotebook.c:785 +#: ../gtk/gtknotebook.c:792 msgid "Tab pack type" msgstr "Tipo de empaquetado de la solapa" -#: ../gtk/gtknotebook.c:792 +#: ../gtk/gtknotebook.c:799 msgid "Tab reorderable" msgstr "Solapa reordenable" -#: ../gtk/gtknotebook.c:793 +#: ../gtk/gtknotebook.c:800 msgid "Whether the tab is reorderable by user action" msgstr "Indica si la solapa se puede reordenar por una acción del usuario" -#: ../gtk/gtknotebook.c:799 +#: ../gtk/gtknotebook.c:806 msgid "Tab detachable" msgstr "Solapa desprendible" -#: ../gtk/gtknotebook.c:800 +#: ../gtk/gtknotebook.c:807 msgid "Whether the tab is detachable" msgstr "Indica si la solapa es desprendible" -#: ../gtk/gtknotebook.c:815 ../gtk/gtkscrollbar.c:105 +#: ../gtk/gtknotebook.c:822 ../gtk/gtkscrollbar.c:105 msgid "Secondary backward stepper" msgstr "Flecha de retroceso secundaria" -#: ../gtk/gtknotebook.c:816 +#: ../gtk/gtknotebook.c:823 msgid "" "Display a second backward arrow button on the opposite end of the tab area" msgstr "" "Muestra una segunda flecha de retroceso en el extremo opuesto del área de " "solapas" -#: ../gtk/gtknotebook.c:831 ../gtk/gtkscrollbar.c:112 +#: ../gtk/gtknotebook.c:838 ../gtk/gtkscrollbar.c:112 msgid "Secondary forward stepper" msgstr "Flecha de adelanto secundaria" -#: ../gtk/gtknotebook.c:832 +#: ../gtk/gtknotebook.c:839 msgid "" "Display a second forward arrow button on the opposite end of the tab area" msgstr "" "Mostrar una segunda flecha de avance en el extremo opuesto del área de " "solapas" -#: ../gtk/gtknotebook.c:846 ../gtk/gtkscrollbar.c:91 +#: ../gtk/gtknotebook.c:853 ../gtk/gtkscrollbar.c:91 msgid "Backward stepper" msgstr "Flecha de retroceso" -#: ../gtk/gtknotebook.c:847 ../gtk/gtkscrollbar.c:92 +#: ../gtk/gtknotebook.c:854 ../gtk/gtkscrollbar.c:92 msgid "Display the standard backward arrow button" msgstr "Mostrar el botón estándar de flecha de retroceso" -#: ../gtk/gtknotebook.c:861 ../gtk/gtkscrollbar.c:98 +#: ../gtk/gtknotebook.c:868 ../gtk/gtkscrollbar.c:98 msgid "Forward stepper" msgstr "Flecha de avance" -#: ../gtk/gtknotebook.c:862 ../gtk/gtkscrollbar.c:99 +#: ../gtk/gtknotebook.c:869 ../gtk/gtkscrollbar.c:99 msgid "Display the standard forward arrow button" msgstr "Mostrar el botón estándar de flecha de avance" -#: ../gtk/gtknotebook.c:876 +#: ../gtk/gtknotebook.c:883 msgid "Tab overlap" msgstr "Solapamiento de la solapa" -#: ../gtk/gtknotebook.c:877 +#: ../gtk/gtknotebook.c:884 msgid "Size of tab overlap area" msgstr "Tamaño del área de solapamiento de la solapa" -#: ../gtk/gtknotebook.c:892 +#: ../gtk/gtknotebook.c:899 msgid "Tab curvature" msgstr "Curvatura de la solapa" -#: ../gtk/gtknotebook.c:893 +#: ../gtk/gtknotebook.c:900 msgid "Size of tab curvature" msgstr "Tamaño de la curvatura de la solapa" -#: ../gtk/gtknotebook.c:909 +#: ../gtk/gtknotebook.c:916 msgid "Arrow spacing" msgstr "Espaciado de las flechas" -#: ../gtk/gtknotebook.c:910 +#: ../gtk/gtknotebook.c:917 msgid "Scroll arrow spacing" msgstr "Espaciado del desplazamiento de las flechas" @@ -3961,58 +3977,58 @@ msgstr "Orientación" msgid "The orientation of the orientable" msgstr "La orientación del orientable" -#: ../gtk/gtkpaned.c:272 +#: ../gtk/gtkpaned.c:328 msgid "" "Position of paned separator in pixels (0 means all the way to the left/top)" msgstr "" "Posición del separador cada hoja de la ventana en píxeles (0 significa todo " "el trayecto hacia la izquierda/arriba) " -#: ../gtk/gtkpaned.c:281 +#: ../gtk/gtkpaned.c:337 msgid "Position Set" msgstr "Posición establecida" -#: ../gtk/gtkpaned.c:282 +#: ../gtk/gtkpaned.c:338 msgid "TRUE if the Position property should be used" msgstr "TRUE si debe usarse la propiedad «Posición»" -#: ../gtk/gtkpaned.c:288 +#: ../gtk/gtkpaned.c:344 msgid "Handle Size" msgstr "Tamaño del tirador" -#: ../gtk/gtkpaned.c:289 +#: ../gtk/gtkpaned.c:345 msgid "Width of handle" msgstr "Anchura del tirador" -#: ../gtk/gtkpaned.c:305 +#: ../gtk/gtkpaned.c:361 msgid "Minimal Position" msgstr "Posición mínima" -#: ../gtk/gtkpaned.c:306 +#: ../gtk/gtkpaned.c:362 msgid "Smallest possible value for the \"position\" property" msgstr "El valor más pequeño posible para la propiedad \"position\"" -#: ../gtk/gtkpaned.c:323 +#: ../gtk/gtkpaned.c:379 msgid "Maximal Position" msgstr "Posición máxima" -#: ../gtk/gtkpaned.c:324 +#: ../gtk/gtkpaned.c:380 msgid "Largest possible value for the \"position\" property" msgstr "El valor más grande posible para la propiedad \"posicion\"" -#: ../gtk/gtkpaned.c:341 +#: ../gtk/gtkpaned.c:397 msgid "Resize" msgstr "Redimensionar" -#: ../gtk/gtkpaned.c:342 +#: ../gtk/gtkpaned.c:398 msgid "If TRUE, the child expands and shrinks along with the paned widget" msgstr "Si es TRUE, el hijo se expande y encoge junto con el widget dividido" -#: ../gtk/gtkpaned.c:357 +#: ../gtk/gtkpaned.c:413 msgid "Shrink" msgstr "Encoger" -#: ../gtk/gtkpaned.c:358 +#: ../gtk/gtkpaned.c:414 msgid "If TRUE, the child can be made smaller than its requisition" msgstr "Si es TRUE, el hijo puede hacerse más pequeño que sus requisitos" @@ -4339,36 +4355,36 @@ msgstr "" "TRUE si los combos de configuración de página están empotrados en " "GtkPrintUnixDialog" -#: ../gtk/gtkprogressbar.c:129 +#: ../gtk/gtkprogressbar.c:161 msgid "Fraction" msgstr "Fracción" -#: ../gtk/gtkprogressbar.c:130 +#: ../gtk/gtkprogressbar.c:162 msgid "The fraction of total work that has been completed" msgstr "La fracción del trabajo total que ha sido completado" -#: ../gtk/gtkprogressbar.c:137 +#: ../gtk/gtkprogressbar.c:169 msgid "Pulse Step" msgstr "Paso del pulso" -#: ../gtk/gtkprogressbar.c:138 +#: ../gtk/gtkprogressbar.c:170 msgid "The fraction of total progress to move the bouncing block when pulsed" msgstr "" "La fracción del progreso total para mover el bloque rebotador cuando se pulsa" -#: ../gtk/gtkprogressbar.c:146 +#: ../gtk/gtkprogressbar.c:178 msgid "Text to be displayed in the progress bar" msgstr "Texto que se mostrará en la barra de progreso" -#: ../gtk/gtkprogressbar.c:153 +#: ../gtk/gtkprogressbar.c:185 msgid "Show text" msgstr "Mostrar texto" -#: ../gtk/gtkprogressbar.c:154 +#: ../gtk/gtkprogressbar.c:186 msgid "Whether the progress is shown as text." msgstr "Indica si el progreso se muestra como texto." -#: ../gtk/gtkprogressbar.c:176 +#: ../gtk/gtkprogressbar.c:208 msgid "" "The preferred place to ellipsize the string, if the progress bar does not " "have enough room to display the entire string, if at all." @@ -4376,51 +4392,51 @@ msgstr "" "El lugar preferido para la elipsis de la cadena, si la barra de progreso no " "tiene suficiente espacio para mostrar la cadena completa." -#: ../gtk/gtkprogressbar.c:183 +#: ../gtk/gtkprogressbar.c:215 msgid "X spacing" msgstr "Espaciado X" -#: ../gtk/gtkprogressbar.c:184 +#: ../gtk/gtkprogressbar.c:216 msgid "Extra spacing applied to the width of a progress bar." msgstr "Espacio extra aplicado a la anchura de una barra de progreso." -#: ../gtk/gtkprogressbar.c:189 +#: ../gtk/gtkprogressbar.c:221 msgid "Y spacing" msgstr "Espaciado Y" -#: ../gtk/gtkprogressbar.c:190 +#: ../gtk/gtkprogressbar.c:222 msgid "Extra spacing applied to the height of a progress bar." msgstr "Espacio adicional aplicado a la altura >de una barra de progreso." -#: ../gtk/gtkprogressbar.c:203 +#: ../gtk/gtkprogressbar.c:235 msgid "Minimum horizontal bar width" msgstr "Anchura mínima de la barra horizontal" -#: ../gtk/gtkprogressbar.c:204 +#: ../gtk/gtkprogressbar.c:236 msgid "The minimum horizontal width of the progress bar" msgstr "La anchura mínima horizontal de la barra de progreso" -#: ../gtk/gtkprogressbar.c:216 +#: ../gtk/gtkprogressbar.c:248 msgid "Minimum horizontal bar height" msgstr "Altura mínima de la barra horizontal" -#: ../gtk/gtkprogressbar.c:217 +#: ../gtk/gtkprogressbar.c:249 msgid "Minimum horizontal height of the progress bar" msgstr "La altura mínima horizontal de la barra de progreso" -#: ../gtk/gtkprogressbar.c:229 +#: ../gtk/gtkprogressbar.c:261 msgid "Minimum vertical bar width" msgstr "Anchura mínima horizontal de la barra" -#: ../gtk/gtkprogressbar.c:230 +#: ../gtk/gtkprogressbar.c:262 msgid "The minimum vertical width of the progress bar" msgstr "La anchura mínima vertical de la barra de progreso" -#: ../gtk/gtkprogressbar.c:242 +#: ../gtk/gtkprogressbar.c:274 msgid "Minimum vertical bar height" msgstr "Altura mínima vertical de la barra" -#: ../gtk/gtkprogressbar.c:243 +#: ../gtk/gtkprogressbar.c:275 msgid "The minimum vertical height of the progress bar" msgstr "La altura mínima vertical de la barra de progreso" @@ -4436,7 +4452,7 @@ msgstr "" "El valor devuelto por gtk_radio_action_get_current_value() cuando esta " "acción es la acción actual de su grupo." -#: ../gtk/gtkradioaction.c:135 ../gtk/gtkradiobutton.c:160 +#: ../gtk/gtkradioaction.c:135 ../gtk/gtkradiobutton.c:163 #: ../gtk/gtkradiomenuitem.c:373 ../gtk/gtkradiotoolbutton.c:65 msgid "Group" msgstr "Grupo" @@ -4457,7 +4473,7 @@ msgstr "" "La propiedad del valor del miembro actualmente activo del grupo al que esta " "acción pertenece." -#: ../gtk/gtkradiobutton.c:161 +#: ../gtk/gtkradiobutton.c:164 msgid "The radio button whose group this widget belongs to." msgstr "El botón de radio a cuyo grupo pertenece este widget." @@ -4469,29 +4485,29 @@ msgstr "El elemento del menú de radio a cuyo grupo pertenece este widget." msgid "The radio tool button whose group this button belongs to." msgstr "La herramienta de botón de radio a cuyo grupo pertenece este widget." -#: ../gtk/gtkrange.c:416 +#: ../gtk/gtkrange.c:423 msgid "Update policy" msgstr "Política de actualización" -#: ../gtk/gtkrange.c:417 +#: ../gtk/gtkrange.c:424 msgid "How the range should be updated on the screen" msgstr "Cómo se debe actualizar el rango en la pantalla" -#: ../gtk/gtkrange.c:426 +#: ../gtk/gtkrange.c:433 msgid "The GtkAdjustment that contains the current value of this range object" msgstr "El GtkAdjustment que contiene el valor actual de este objeto de rango" -#: ../gtk/gtkrange.c:434 +#: ../gtk/gtkrange.c:441 msgid "Invert direction slider moves to increase range value" msgstr "" "Invierte la dirección en que se mueve el deslizador para incrementar el " "valor del rango" -#: ../gtk/gtkrange.c:441 +#: ../gtk/gtkrange.c:448 msgid "Lower stepper sensitivity" msgstr "Sensibilidad de la flecha inferior" -#: ../gtk/gtkrange.c:442 +#: ../gtk/gtkrange.c:449 msgid "" "The sensitivity policy for the stepper that points to the adjustment's lower " "side" @@ -4499,11 +4515,11 @@ msgstr "" "La directiva de sensibilidad del botón de desplazamiento que apunta al lado " "más bajo del ajuste" -#: ../gtk/gtkrange.c:450 +#: ../gtk/gtkrange.c:457 msgid "Upper stepper sensitivity" msgstr "Sensibilidad de la flecha superior" -#: ../gtk/gtkrange.c:451 +#: ../gtk/gtkrange.c:458 msgid "" "The sensitivity policy for the stepper that points to the adjustment's upper " "side" @@ -4511,91 +4527,91 @@ msgstr "" "La directiva de sensibilidad del botón de flecha que apunta al lado más alto " "del ajuste" -#: ../gtk/gtkrange.c:468 +#: ../gtk/gtkrange.c:475 msgid "Show Fill Level" msgstr "Mostrar nivel de relleno" -#: ../gtk/gtkrange.c:469 +#: ../gtk/gtkrange.c:476 msgid "Whether to display a fill level indicator graphics on trough." msgstr "" "Indica si se debe mostrar el indicador de nivel de llenado en los gráficos " "mientras se llena." -#: ../gtk/gtkrange.c:485 +#: ../gtk/gtkrange.c:492 msgid "Restrict to Fill Level" msgstr "Restringir al nivel de llenado" -#: ../gtk/gtkrange.c:486 +#: ../gtk/gtkrange.c:493 msgid "Whether to restrict the upper boundary to the fill level." msgstr "Indica si se debe restringir el borde superior al nivel de llenado." -#: ../gtk/gtkrange.c:501 +#: ../gtk/gtkrange.c:508 msgid "Fill Level" msgstr "Nivel de llenado" -#: ../gtk/gtkrange.c:502 +#: ../gtk/gtkrange.c:509 msgid "The fill level." msgstr "El nivel de llenado." -#: ../gtk/gtkrange.c:510 +#: ../gtk/gtkrange.c:517 ../gtk/gtkswitch.c:773 msgid "Slider Width" msgstr "Anchura del deslizador" -#: ../gtk/gtkrange.c:511 +#: ../gtk/gtkrange.c:518 msgid "Width of scrollbar or scale thumb" msgstr "Anchura de la barra de desplazamiento o escala de miniatura" -#: ../gtk/gtkrange.c:518 +#: ../gtk/gtkrange.c:525 msgid "Trough Border" msgstr "Borde del carril" -#: ../gtk/gtkrange.c:519 +#: ../gtk/gtkrange.c:526 msgid "Spacing between thumb/steppers and outer trough bevel" msgstr "" "Espaciado entre la marcador/flechas de desplazamiento y el bisel exterior " "del carril" -#: ../gtk/gtkrange.c:526 +#: ../gtk/gtkrange.c:533 msgid "Stepper Size" msgstr "Tamaño del botón de flecha de desplazamiento" -#: ../gtk/gtkrange.c:527 +#: ../gtk/gtkrange.c:534 msgid "Length of step buttons at ends" msgstr "Longitud de los botones de flecha en los extremos" -#: ../gtk/gtkrange.c:542 +#: ../gtk/gtkrange.c:549 msgid "Stepper Spacing" msgstr "Espaciado de los botones de flecha de desplazamiento" -#: ../gtk/gtkrange.c:543 +#: ../gtk/gtkrange.c:550 msgid "Spacing between step buttons and thumb" msgstr "Espaciado entre los botones de flecha de desplazamiento y el marcador" -#: ../gtk/gtkrange.c:550 +#: ../gtk/gtkrange.c:557 msgid "Arrow X Displacement" msgstr "Desplazamiento de la flecha X" -#: ../gtk/gtkrange.c:551 +#: ../gtk/gtkrange.c:558 msgid "" "How far in the x direction to move the arrow when the button is depressed" msgstr "" "Distancia en la dirección «X» para mover la flecha cuando se suelta el botón " -#: ../gtk/gtkrange.c:558 +#: ../gtk/gtkrange.c:565 msgid "Arrow Y Displacement" msgstr "Desplazamiento de la flecha Y" -#: ../gtk/gtkrange.c:559 +#: ../gtk/gtkrange.c:566 msgid "" "How far in the y direction to move the arrow when the button is depressed" msgstr "" "Distancia en la dirección «Y» para mover la flecha cuando se suelta el botón " -#: ../gtk/gtkrange.c:577 +#: ../gtk/gtkrange.c:584 msgid "Trough Under Steppers" msgstr "Carril bajo las flechas de deslizamiento" -#: ../gtk/gtkrange.c:578 +#: ../gtk/gtkrange.c:585 msgid "" "Whether to draw trough for full length of range or exclude the steppers and " "spacing" @@ -4603,11 +4619,11 @@ msgstr "" "Indica si se debe dibujar para la longitud completa del rango o excluir las " "flechas de desplazamiento y el espaciado" -#: ../gtk/gtkrange.c:591 +#: ../gtk/gtkrange.c:598 msgid "Arrow scaling" msgstr "Escalado de flechas" -#: ../gtk/gtkrange.c:592 +#: ../gtk/gtkrange.c:599 msgid "Arrow scaling with regard to scroll button size" msgstr "" "Escalado de flechas en consideración con el tamaño del botón de " @@ -4703,42 +4719,6 @@ msgstr "La ruta completa al archivo a usar para almacenar y leer la lista" msgid "The size of the recently used resources list" msgstr "El tamaño de la lista de recursos usados recientemente" -#: ../gtk/gtkruler.c:138 -msgid "Lower" -msgstr "Inferior" - -#: ../gtk/gtkruler.c:139 -msgid "Lower limit of ruler" -msgstr "Límite inferior de la regla" - -#: ../gtk/gtkruler.c:148 -msgid "Upper" -msgstr "Superior" - -#: ../gtk/gtkruler.c:149 -msgid "Upper limit of ruler" -msgstr "Límite superior de la regla" - -#: ../gtk/gtkruler.c:159 -msgid "Position of mark on the ruler" -msgstr "Posición de la etiqueta en la regla" - -#: ../gtk/gtkruler.c:168 -msgid "Max Size" -msgstr "Tamaño máximo" - -#: ../gtk/gtkruler.c:169 -msgid "Maximum size of the ruler" -msgstr "Tamaño máximo de la regla" - -#: ../gtk/gtkruler.c:184 -msgid "Metric" -msgstr "Métrica" - -#: ../gtk/gtkruler.c:185 -msgid "The metric used for the ruler" -msgstr "La métrica de la regla" - #: ../gtk/gtkscalebutton.c:221 msgid "The value of the scale" msgstr "El valor de la escala" @@ -4762,40 +4742,40 @@ msgstr "Iconos" msgid "List of icon names" msgstr "Lista de nombres de iconos" -#: ../gtk/gtkscale.c:245 +#: ../gtk/gtkscale.c:250 msgid "The number of decimal places that are displayed in the value" msgstr "El número de lugares decimales que se mostrarán en el valor" -#: ../gtk/gtkscale.c:254 +#: ../gtk/gtkscale.c:259 msgid "Draw Value" msgstr "Dibujar valor" -#: ../gtk/gtkscale.c:255 +#: ../gtk/gtkscale.c:260 msgid "Whether the current value is displayed as a string next to the slider" msgstr "" "Indica si el valor actual se muestra como una cadena contigua al deslizador" -#: ../gtk/gtkscale.c:262 +#: ../gtk/gtkscale.c:267 msgid "Value Position" msgstr "Posición del valor" -#: ../gtk/gtkscale.c:263 +#: ../gtk/gtkscale.c:268 msgid "The position in which the current value is displayed" msgstr "La posición en que se muestra el valor actual" -#: ../gtk/gtkscale.c:270 +#: ../gtk/gtkscale.c:275 msgid "Slider Length" msgstr "Longitud del deslizador" -#: ../gtk/gtkscale.c:271 +#: ../gtk/gtkscale.c:276 msgid "Length of scale's slider" msgstr "Longitud de la escala del deslizador" -#: ../gtk/gtkscale.c:279 +#: ../gtk/gtkscale.c:284 msgid "Value spacing" msgstr "Espaciado del valor" -#: ../gtk/gtkscale.c:280 +#: ../gtk/gtkscale.c:285 msgid "Space between value text and the slider/trough area" msgstr "Espacio entre el texto del valor y el área del deslizador/carril" @@ -4913,7 +4893,6 @@ msgstr "" "Número de píxeles entre las barras de desplazamiento y la ventana enrollada" #: ../gtk/gtkscrolledwindow.c:383 -#| msgid "Minimum Width" msgid "Minimum Content Width" msgstr "Anchura mínima del contenido" @@ -4923,7 +4902,6 @@ msgstr "" "La anchura mínima que la ventana desplazada reservará para su contenido" #: ../gtk/gtkscrolledwindow.c:390 -#| msgid "Minimum child height" msgid "Minimum Content Height" msgstr "Altura mínima del contenido" @@ -4932,19 +4910,19 @@ msgid "" "The minimum height that the scrolled window will allocate to its content" msgstr "La altura mínima que la ventana desplazada reservará para su contenido" -#: ../gtk/gtkseparatortoolitem.c:138 +#: ../gtk/gtkseparatortoolitem.c:143 msgid "Draw" msgstr "Dibujar" -#: ../gtk/gtkseparatortoolitem.c:139 +#: ../gtk/gtkseparatortoolitem.c:144 msgid "Whether the separator is drawn, or just blank" msgstr "Indica si el separador se dibuja, o sólo se deja en blanco" -#: ../gtk/gtksettings.c:241 +#: ../gtk/gtksettings.c:277 msgid "Double Click Time" msgstr "Tiempo del doble pulsación" -#: ../gtk/gtksettings.c:242 +#: ../gtk/gtksettings.c:278 msgid "" "Maximum time allowed between two clicks for them to be considered a double " "click (in milliseconds)" @@ -4952,11 +4930,11 @@ msgstr "" "Tiempo máximo permitido entre dos pulsaciones para ser considerados como una " "pulsación doble (en milisegundos)" -#: ../gtk/gtksettings.c:249 +#: ../gtk/gtksettings.c:285 msgid "Double Click Distance" msgstr "Distancia de la pulsación doble" -#: ../gtk/gtksettings.c:250 +#: ../gtk/gtksettings.c:286 msgid "" "Maximum distance allowed between two clicks for them to be considered a " "double click (in pixels)" @@ -4964,35 +4942,35 @@ msgstr "" "Distancia máxima permitida entre dos pulsaciones para ser considerados como " "una pulsación doble (en píxeles)" -#: ../gtk/gtksettings.c:266 +#: ../gtk/gtksettings.c:302 msgid "Cursor Blink" msgstr "Parpadeo del cursor" -#: ../gtk/gtksettings.c:267 +#: ../gtk/gtksettings.c:303 msgid "Whether the cursor should blink" msgstr "Indica si el cursor debe parpadear" -#: ../gtk/gtksettings.c:274 +#: ../gtk/gtksettings.c:310 msgid "Cursor Blink Time" msgstr "Tiempo de parpadeo del cursor" -#: ../gtk/gtksettings.c:275 +#: ../gtk/gtksettings.c:311 msgid "Length of the cursor blink cycle, in milliseconds" msgstr "Longitud del ciclo de parpadeo del cursor, en milisegundos" -#: ../gtk/gtksettings.c:294 +#: ../gtk/gtksettings.c:330 msgid "Cursor Blink Timeout" msgstr "Intervalo de parpadeo del cursor" -#: ../gtk/gtksettings.c:295 +#: ../gtk/gtksettings.c:331 msgid "Time after which the cursor stops blinking, in seconds" msgstr "Tiempo tras el que el cursor para de parpadear, en segundos" -#: ../gtk/gtksettings.c:302 +#: ../gtk/gtksettings.c:338 msgid "Split Cursor" msgstr "Dividir cursor" -#: ../gtk/gtksettings.c:303 +#: ../gtk/gtksettings.c:339 msgid "" "Whether two cursors should be displayed for mixed left-to-right and right-to-" "left text" @@ -5000,161 +4978,161 @@ msgstr "" "Indica si deben mostrarse dos cursores para el texto mezclado de izquierda-a-" "derecha y derecha-a-izquierda" -#: ../gtk/gtksettings.c:310 +#: ../gtk/gtksettings.c:346 msgid "Theme Name" msgstr "Nombre del tema" -#: ../gtk/gtksettings.c:311 +#: ../gtk/gtksettings.c:347 msgid "Name of theme RC file to load" msgstr "Nombre del archivo RC de tema que cargar" -#: ../gtk/gtksettings.c:319 +#: ../gtk/gtksettings.c:355 msgid "Icon Theme Name" msgstr "Nombre del tema de iconos" -#: ../gtk/gtksettings.c:320 +#: ../gtk/gtksettings.c:356 msgid "Name of icon theme to use" msgstr "Nombre del tema de iconos que utilizar" -#: ../gtk/gtksettings.c:328 +#: ../gtk/gtksettings.c:364 msgid "Fallback Icon Theme Name" msgstr "Nombre del tema de iconos de resguardo" -#: ../gtk/gtksettings.c:329 +#: ../gtk/gtksettings.c:365 msgid "Name of a icon theme to fall back to" msgstr "Nombre del tema de iconos que utilizar como resguardo" -#: ../gtk/gtksettings.c:337 +#: ../gtk/gtksettings.c:373 msgid "Key Theme Name" msgstr "Nombre del tema de teclas" -#: ../gtk/gtksettings.c:338 +#: ../gtk/gtksettings.c:374 msgid "Name of key theme RC file to load" msgstr "Nombre del archivo RC de tema de teclas que cargar" -#: ../gtk/gtksettings.c:346 +#: ../gtk/gtksettings.c:382 msgid "Menu bar accelerator" msgstr "Acelerador de la barra de menús" -#: ../gtk/gtksettings.c:347 +#: ../gtk/gtksettings.c:383 msgid "Keybinding to activate the menu bar" msgstr "Combinación de teclas para activar la barra de menús" -#: ../gtk/gtksettings.c:355 +#: ../gtk/gtksettings.c:391 msgid "Drag threshold" msgstr "Umbral del arrastre" -#: ../gtk/gtksettings.c:356 +#: ../gtk/gtksettings.c:392 msgid "Number of pixels the cursor can move before dragging" msgstr "" "Número de píxeles que el cursor puede mover antes de iniciar el arrastre" -#: ../gtk/gtksettings.c:364 +#: ../gtk/gtksettings.c:400 msgid "Font Name" msgstr "Nombre de la tipografía" -#: ../gtk/gtksettings.c:365 +#: ../gtk/gtksettings.c:401 msgid "Name of default font to use" msgstr "Nombre de la tipografía predeterminada a utilizar" -#: ../gtk/gtksettings.c:387 +#: ../gtk/gtksettings.c:423 msgid "Icon Sizes" msgstr "Tamaños de los iconos" -#: ../gtk/gtksettings.c:388 +#: ../gtk/gtksettings.c:424 msgid "List of icon sizes (gtk-menu=16,16:gtk-button=20,20..." msgstr "Lista de tamaños de los iconos (gtk-menu=16,16:gtk-button=20,20..." -#: ../gtk/gtksettings.c:396 +#: ../gtk/gtksettings.c:432 msgid "GTK Modules" msgstr "Módulos GTK" -#: ../gtk/gtksettings.c:397 +#: ../gtk/gtksettings.c:433 msgid "List of currently active GTK modules" msgstr "Lista de módulos GTK activos actualmente" -#: ../gtk/gtksettings.c:406 +#: ../gtk/gtksettings.c:442 msgid "Xft Antialias" msgstr "Suavizado Xft" -#: ../gtk/gtksettings.c:407 +#: ../gtk/gtksettings.c:443 msgid "Whether to antialias Xft fonts; 0=no, 1=yes, -1=default" msgstr "" "Indica si se deben suavizar los bordes de las tipografías Xft; 0=no,1=sí, " "-1=predeterminado" -#: ../gtk/gtksettings.c:416 +#: ../gtk/gtksettings.c:452 msgid "Xft Hinting" msgstr "Sugerencias Xft" -#: ../gtk/gtksettings.c:417 +#: ../gtk/gtksettings.c:453 msgid "Whether to hint Xft fonts; 0=no, 1=yes, -1=default" msgstr "" "Indica si se deben usar las sugerencias de las tipografías Xft; 0=no, 1 =sí, " "-1=predeterminado" -#: ../gtk/gtksettings.c:426 +#: ../gtk/gtksettings.c:462 msgid "Xft Hint Style" msgstr "Estilo de sugerencias Xft" -#: ../gtk/gtksettings.c:427 +#: ../gtk/gtksettings.c:463 msgid "" "What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull" msgstr "Qué grado de sugerencias usar: ninguno, ligero, medio o completo" -#: ../gtk/gtksettings.c:436 +#: ../gtk/gtksettings.c:472 msgid "Xft RGBA" msgstr "Xft RGBA" -#: ../gtk/gtksettings.c:437 +#: ../gtk/gtksettings.c:473 msgid "Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr" msgstr "Tipo de suavizado de subpíxel: ninguno, rgb, bgr, vrgb, vbgr" -#: ../gtk/gtksettings.c:446 +#: ../gtk/gtksettings.c:482 msgid "Xft DPI" msgstr "PPP Xft (DPI)" -#: ../gtk/gtksettings.c:447 +#: ../gtk/gtksettings.c:483 msgid "Resolution for Xft, in 1024 * dots/inch. -1 to use default value" msgstr "" "Resolución para Xft, en 1024 * puntos/pulgada. -1 para usar el valor " "predeterminado" -#: ../gtk/gtksettings.c:456 +#: ../gtk/gtksettings.c:492 msgid "Cursor theme name" msgstr "Nombre del tema del cursor" -#: ../gtk/gtksettings.c:457 +#: ../gtk/gtksettings.c:493 msgid "Name of the cursor theme to use, or NULL to use the default theme" msgstr "" "Nombre del tema de cursor que utilizar, o NULL para usar el tema " "predeterminado" -#: ../gtk/gtksettings.c:465 +#: ../gtk/gtksettings.c:501 msgid "Cursor theme size" msgstr "Tamaño del tema del cursor" -#: ../gtk/gtksettings.c:466 +#: ../gtk/gtksettings.c:502 msgid "Size to use for cursors, or 0 to use the default size" msgstr "" "Tamaño que se va a usar para los cursores, o 0 para usar el tamaño " "predeterminado" -#: ../gtk/gtksettings.c:476 +#: ../gtk/gtksettings.c:512 msgid "Alternative button order" msgstr "Orden de los botones alternativo" -#: ../gtk/gtksettings.c:477 +#: ../gtk/gtksettings.c:513 msgid "Whether buttons in dialogs should use the alternative button order" msgstr "" "Indica si los botones en los diálogos deben usar un orden de botones " "alternativo" -#: ../gtk/gtksettings.c:494 +#: ../gtk/gtksettings.c:530 msgid "Alternative sort indicator direction" msgstr "Dirección alternativa del indicador de ordenamiento" -#: ../gtk/gtksettings.c:495 +#: ../gtk/gtksettings.c:531 msgid "" "Whether the direction of the sort indicators in list and tree views is " "inverted compared to the default (where down means ascending)" @@ -5163,11 +5141,11 @@ msgstr "" "vista de árbol está invertida en comparación con la predeterminada (donde " "abajo significa ascendente)" -#: ../gtk/gtksettings.c:503 +#: ../gtk/gtksettings.c:539 msgid "Show the 'Input Methods' menu" msgstr "Mostrar el menú de métodos de entrada" -#: ../gtk/gtksettings.c:504 +#: ../gtk/gtksettings.c:540 msgid "" "Whether the context menus of entries and text views should offer to change " "the input method" @@ -5175,11 +5153,11 @@ msgstr "" "Indica si los menús de contexto y las vistas de texto deben ofrecer cambiar " "el método de entrada" -#: ../gtk/gtksettings.c:512 +#: ../gtk/gtksettings.c:548 msgid "Show the 'Insert Unicode Control Character' menu" msgstr "Mostrar el menú «Insertar carácter de control Unicode»" -#: ../gtk/gtksettings.c:513 +#: ../gtk/gtksettings.c:549 msgid "" "Whether the context menus of entries and text views should offer to insert " "control characters" @@ -5187,254 +5165,254 @@ msgstr "" "Indica si los menús de contexto de las estradas y las vistas de texto deben " "ofrecer insertar caracteres de control" -#: ../gtk/gtksettings.c:521 +#: ../gtk/gtksettings.c:557 msgid "Start timeout" msgstr "Tiempo de expiración de inicio" -#: ../gtk/gtksettings.c:522 +#: ../gtk/gtksettings.c:558 msgid "Starting value for timeouts, when button is pressed" msgstr "Valor de inicio para las expiraciones, cuando se pulsa el botón" -#: ../gtk/gtksettings.c:531 +#: ../gtk/gtksettings.c:567 msgid "Repeat timeout" msgstr "Expiración de repetición" -#: ../gtk/gtksettings.c:532 +#: ../gtk/gtksettings.c:568 msgid "Repeat value for timeouts, when button is pressed" msgstr "Valor de repetición para expiraciones, cuando el botón se pulsa" -#: ../gtk/gtksettings.c:541 +#: ../gtk/gtksettings.c:577 msgid "Expand timeout" msgstr "Expiración del expansor" -#: ../gtk/gtksettings.c:542 +#: ../gtk/gtksettings.c:578 msgid "Expand value for timeouts, when a widget is expanding a new region" msgstr "" "Valor de expansión para las expiraciones, cuando un widget está expandiendo " "una región nueva" -#: ../gtk/gtksettings.c:577 +#: ../gtk/gtksettings.c:613 msgid "Color scheme" msgstr "Esquema de color" -#: ../gtk/gtksettings.c:578 +#: ../gtk/gtksettings.c:614 msgid "A palette of named colors for use in themes" msgstr "Una paleta de colores con nombre para usar en los temas" -#: ../gtk/gtksettings.c:587 +#: ../gtk/gtksettings.c:623 msgid "Enable Animations" msgstr "Activar animaciones" -#: ../gtk/gtksettings.c:588 +#: ../gtk/gtksettings.c:624 msgid "Whether to enable toolkit-wide animations." msgstr "Indica si se activan las animaciones para todo el toolkit." -#: ../gtk/gtksettings.c:606 +#: ../gtk/gtksettings.c:642 msgid "Enable Touchscreen Mode" msgstr "Activar modo pantalla táctil" -#: ../gtk/gtksettings.c:607 +#: ../gtk/gtksettings.c:643 msgid "When TRUE, there are no motion notify events delivered on this screen" msgstr "" "Cuando esté a TRUE, no hay eventos de notificación de movimiento entregados " "en esta pantalla" -#: ../gtk/gtksettings.c:624 +#: ../gtk/gtksettings.c:660 msgid "Tooltip timeout" msgstr "Tiempo de expiración del consejo" -#: ../gtk/gtksettings.c:625 +#: ../gtk/gtksettings.c:661 msgid "Timeout before tooltip is shown" msgstr "Tiempo de expiración antes de que se muestre el consejo" -#: ../gtk/gtksettings.c:650 +#: ../gtk/gtksettings.c:686 msgid "Tooltip browse timeout" msgstr "Tiempo de los consejos de navegación" -#: ../gtk/gtksettings.c:651 +#: ../gtk/gtksettings.c:687 msgid "Timeout before tooltip is shown when browse mode is enabled" msgstr "" "Tiempo de expiración antes de que se muestre el consejo cuando el modo de " "navegación está activado" -#: ../gtk/gtksettings.c:672 +#: ../gtk/gtksettings.c:708 msgid "Tooltip browse mode timeout" msgstr "Tiempo de los consejos en modo navegación" -#: ../gtk/gtksettings.c:673 +#: ../gtk/gtksettings.c:709 msgid "Timeout after which browse mode is disabled" msgstr "" "Tiempo de expiración después del cual se desactiva el modo de navegación" -#: ../gtk/gtksettings.c:692 +#: ../gtk/gtksettings.c:728 msgid "Keynav Cursor Only" msgstr "Sólo cursor para navegar con teclas" -#: ../gtk/gtksettings.c:693 +#: ../gtk/gtksettings.c:729 msgid "When TRUE, there are only cursor keys available to navigate widgets" msgstr "" "Cuando sea TRUE, sólo hay teclas de cursos disponibles para navegar por los " "widgets" -#: ../gtk/gtksettings.c:710 +#: ../gtk/gtksettings.c:746 msgid "Keynav Wrap Around" msgstr "Saltar al navegar con el teclado" -#: ../gtk/gtksettings.c:711 +#: ../gtk/gtksettings.c:747 msgid "Whether to wrap around when keyboard-navigating widgets" msgstr "" "Indica si se ha de saltar alrededor cuando se navegue por los widgets con el " "teclado" -#: ../gtk/gtksettings.c:731 +#: ../gtk/gtksettings.c:767 msgid "Error Bell" msgstr "Campana de error" -#: ../gtk/gtksettings.c:732 +#: ../gtk/gtksettings.c:768 msgid "When TRUE, keyboard navigation and other errors will cause a beep" msgstr "" "Cuando sea TRUE, la navegación con el teclado y otros errores causarán un bip" -#: ../gtk/gtksettings.c:749 +#: ../gtk/gtksettings.c:785 msgid "Color Hash" msgstr "Hash del color" -#: ../gtk/gtksettings.c:750 +#: ../gtk/gtksettings.c:786 msgid "A hash table representation of the color scheme." msgstr "Una representación en tabla hash del esquema de color." -#: ../gtk/gtksettings.c:758 +#: ../gtk/gtksettings.c:794 msgid "Default file chooser backend" msgstr "Backend predeterminado del selector de archivos" -#: ../gtk/gtksettings.c:759 +#: ../gtk/gtksettings.c:795 msgid "Name of the GtkFileChooser backend to use by default" msgstr "Nombre del backend predeterminado del GtkFileChooser" -#: ../gtk/gtksettings.c:776 +#: ../gtk/gtksettings.c:812 msgid "Default print backend" msgstr "Backend predeterminado de impresión" -#: ../gtk/gtksettings.c:777 +#: ../gtk/gtksettings.c:813 msgid "List of the GtkPrintBackend backends to use by default" msgstr "Lista de backends GtkPrintBackend para usar por omisión" -#: ../gtk/gtksettings.c:800 +#: ../gtk/gtksettings.c:836 msgid "Default command to run when displaying a print preview" msgstr "" "Comando predeterminado que ejecutar al mostrar una vista previa de impresión" -#: ../gtk/gtksettings.c:801 +#: ../gtk/gtksettings.c:837 msgid "Command to run when displaying a print preview" msgstr "Comando que ejecutar al mostrar una vista previa de impresión" -#: ../gtk/gtksettings.c:817 +#: ../gtk/gtksettings.c:853 msgid "Enable Mnemonics" msgstr "Activar mnemónicos" -#: ../gtk/gtksettings.c:818 +#: ../gtk/gtksettings.c:854 msgid "Whether labels should have mnemonics" msgstr "Indica si las etiquetas deben tener mnemónicos" -#: ../gtk/gtksettings.c:834 +#: ../gtk/gtksettings.c:870 msgid "Enable Accelerators" msgstr "Activar aceleradores" -#: ../gtk/gtksettings.c:835 +#: ../gtk/gtksettings.c:871 msgid "Whether menu items should have accelerators" msgstr "Indica si los elementos del menú deben tener aceleradores" -#: ../gtk/gtksettings.c:852 +#: ../gtk/gtksettings.c:888 msgid "Recent Files Limit" msgstr "Límite de archivos recientes" -#: ../gtk/gtksettings.c:853 +#: ../gtk/gtksettings.c:889 msgid "Number of recently used files" msgstr "Número de archivos usados recientemente" -#: ../gtk/gtksettings.c:871 +#: ../gtk/gtksettings.c:907 msgid "Default IM module" msgstr "Módulo de método de entrada predeterminado" -#: ../gtk/gtksettings.c:872 +#: ../gtk/gtksettings.c:908 msgid "Which IM module should be used by default" msgstr "Qué módulo de método de entrada se debe usar de forma predeterminada" -#: ../gtk/gtksettings.c:890 +#: ../gtk/gtksettings.c:926 msgid "Recent Files Max Age" msgstr "Antigüedad máxima de los archivos recientes" -#: ../gtk/gtksettings.c:891 +#: ../gtk/gtksettings.c:927 msgid "Maximum age of recently used files, in days" msgstr "Máxima antigüedad para los archivos recientemente usados, en días" -#: ../gtk/gtksettings.c:900 +#: ../gtk/gtksettings.c:936 msgid "Fontconfig configuration timestamp" msgstr "Configuración de la marca de tiempo de fontconfig" -#: ../gtk/gtksettings.c:901 +#: ../gtk/gtksettings.c:937 msgid "Timestamp of current fontconfig configuration" msgstr "Marca de tiempo de la configuración actual de fontconfig" -#: ../gtk/gtksettings.c:923 +#: ../gtk/gtksettings.c:959 msgid "Sound Theme Name" msgstr "Nombre del tema de sonido" -#: ../gtk/gtksettings.c:924 +#: ../gtk/gtksettings.c:960 msgid "XDG sound theme name" msgstr "Nombre del tema de sonido XDG" #. Translators: this means sounds that are played as feedback to user input -#: ../gtk/gtksettings.c:946 +#: ../gtk/gtksettings.c:982 msgid "Audible Input Feedback" msgstr "Contexto de entrada audible" -#: ../gtk/gtksettings.c:947 +#: ../gtk/gtksettings.c:983 msgid "Whether to play event sounds as feedback to user input" msgstr "" "Indica si se deben reproducir eventos como respuesta a las entradas del " "usuario" -#: ../gtk/gtksettings.c:968 +#: ../gtk/gtksettings.c:1004 msgid "Enable Event Sounds" msgstr "Activar eventos de sonido" -#: ../gtk/gtksettings.c:969 +#: ../gtk/gtksettings.c:1005 msgid "Whether to play any event sounds at all" msgstr "Indica si se debe reproducir cualquier evento de sonido" -#: ../gtk/gtksettings.c:984 +#: ../gtk/gtksettings.c:1020 msgid "Enable Tooltips" msgstr "Activar consejos" -#: ../gtk/gtksettings.c:985 +#: ../gtk/gtksettings.c:1021 msgid "Whether tooltips should be shown on widgets" msgstr "Indica si se deben mostrar los consejos en los widgets" -#: ../gtk/gtksettings.c:998 +#: ../gtk/gtksettings.c:1034 msgid "Toolbar style" msgstr "Estilo de la barra de herramientas" -#: ../gtk/gtksettings.c:999 +#: ../gtk/gtksettings.c:1035 msgid "" "Whether default toolbars have text only, text and icons, icons only, etc." msgstr "" "Indica si las barras de herramientas predeterminadas tienen sólo texto, " "texto e iconos, sólo iconos, etc." -#: ../gtk/gtksettings.c:1013 +#: ../gtk/gtksettings.c:1049 msgid "Toolbar Icon Size" msgstr "Tamaño del icono de la barra de herramientas" -#: ../gtk/gtksettings.c:1014 +#: ../gtk/gtksettings.c:1050 msgid "The size of icons in default toolbars." msgstr "El tamaño de los iconos el las barras de herramientas." -#: ../gtk/gtksettings.c:1031 +#: ../gtk/gtksettings.c:1067 msgid "Auto Mnemonics" msgstr "Mnemónicos automáticos" -#: ../gtk/gtksettings.c:1032 +#: ../gtk/gtksettings.c:1068 msgid "" "Whether mnemonics should be automatically shown and hidden when the user " "presses the mnemonic activator." @@ -5442,63 +5420,63 @@ msgstr "" "Indica si se deben mostrar y ocultar automáticamente los mnemónicos cuando " "el usuario pulsa el activador de mnemónicos." -#: ../gtk/gtksettings.c:1057 +#: ../gtk/gtksettings.c:1093 msgid "Application prefers a dark theme" msgstr "La aplicación prefiere un tema oscuro" -#: ../gtk/gtksettings.c:1058 +#: ../gtk/gtksettings.c:1094 msgid "Whether the application prefers to have a dark theme." msgstr "Indica si la aplicación prefiere un tema oscuro." -#: ../gtk/gtksettings.c:1073 +#: ../gtk/gtksettings.c:1109 msgid "Show button images" msgstr "Mostrar imágenes en los botones" -#: ../gtk/gtksettings.c:1074 +#: ../gtk/gtksettings.c:1110 msgid "Whether images should be shown on buttons" msgstr "Indica si se deben mostrar las imágenes en los botones" -#: ../gtk/gtksettings.c:1082 ../gtk/gtksettings.c:1176 +#: ../gtk/gtksettings.c:1118 ../gtk/gtksettings.c:1212 msgid "Select on focus" msgstr "Seleccionar al enfocar" -#: ../gtk/gtksettings.c:1083 +#: ../gtk/gtksettings.c:1119 msgid "Whether to select the contents of an entry when it is focused" msgstr "" "Indica si se deben seleccionar los contenidos de una entrada cuando obtiene " "el foco" -#: ../gtk/gtksettings.c:1100 +#: ../gtk/gtksettings.c:1136 msgid "Password Hint Timeout" msgstr "Tiempo de expiración del hint de contraseña" -#: ../gtk/gtksettings.c:1101 +#: ../gtk/gtksettings.c:1137 msgid "How long to show the last input character in hidden entries" msgstr "" "Indica durante cuánto tiempo mostrar el último carácter en las entradas " "ocultas" -#: ../gtk/gtksettings.c:1110 +#: ../gtk/gtksettings.c:1146 msgid "Show menu images" msgstr "Mostrar imágenes del menú" -#: ../gtk/gtksettings.c:1111 +#: ../gtk/gtksettings.c:1147 msgid "Whether images should be shown in menus" msgstr "Indica si deben mostrarse o no las imágenes en los menús" -#: ../gtk/gtksettings.c:1119 +#: ../gtk/gtksettings.c:1155 msgid "Delay before drop down menus appear" msgstr "Retardo antes de que aparezcan los menús desplegables" -#: ../gtk/gtksettings.c:1120 +#: ../gtk/gtksettings.c:1156 msgid "Delay before the submenus of a menu bar appear" msgstr "Retardo antes de que aparezcan los submenús de una barra de menús" -#: ../gtk/gtksettings.c:1137 +#: ../gtk/gtksettings.c:1173 msgid "Scrolled Window Placement" msgstr "Colocación de la ventana donde se ha desplazado" -#: ../gtk/gtksettings.c:1138 +#: ../gtk/gtksettings.c:1174 msgid "" "Where the contents of scrolled windows are located with respect to the " "scrollbars, if not overridden by the scrolled window's own placement." @@ -5507,33 +5485,33 @@ msgstr "" "respecto a las barras de desplazamiento, si no toma precedencia por el " "propio emplazamiento de la ventana donde se hizo scroll." -#: ../gtk/gtksettings.c:1147 +#: ../gtk/gtksettings.c:1183 msgid "Can change accelerators" msgstr "Puede cambiar aceleradores" -#: ../gtk/gtksettings.c:1148 +#: ../gtk/gtksettings.c:1184 msgid "" "Whether menu accelerators can be changed by pressing a key over the menu item" msgstr "" "Indica si los aceleradores del menú pueden cambiarse pulsando una tecla " "sobre el elemento del menú" -#: ../gtk/gtksettings.c:1156 +#: ../gtk/gtksettings.c:1192 msgid "Delay before submenus appear" msgstr "Retraso antes de que aparezcan los submenús" -#: ../gtk/gtksettings.c:1157 +#: ../gtk/gtksettings.c:1193 msgid "" "Minimum time the pointer must stay over a menu item before the submenu appear" msgstr "" "Tiempo mínimo en que el puntero debe permanecer sobre un elemento de menú " "antes de que el submenú aparezca" -#: ../gtk/gtksettings.c:1166 +#: ../gtk/gtksettings.c:1202 msgid "Delay before hiding a submenu" msgstr "Retraso antes de ocultar un submenú" -#: ../gtk/gtksettings.c:1167 +#: ../gtk/gtksettings.c:1203 msgid "" "The time before hiding a submenu when the pointer is moving towards the " "submenu" @@ -5541,33 +5519,33 @@ msgstr "" "El tiempo antes de ocultar un submenú cuando el puntero se este moviendo " "hacia el submenú" -#: ../gtk/gtksettings.c:1177 +#: ../gtk/gtksettings.c:1213 msgid "Whether to select the contents of a selectable label when it is focused" msgstr "" "Indica si se debe seleccionar el contenido de una etiqueta seleccionable " "cuando obtiene el foco" -#: ../gtk/gtksettings.c:1185 +#: ../gtk/gtksettings.c:1221 msgid "Custom palette" msgstr "Paleta personalizada" -#: ../gtk/gtksettings.c:1186 +#: ../gtk/gtksettings.c:1222 msgid "Palette to use in the color selector" msgstr "Paleta que se usará en el selector de colores" -#: ../gtk/gtksettings.c:1194 +#: ../gtk/gtksettings.c:1230 msgid "IM Preedit style" msgstr "Estilo de preedición del ME" -#: ../gtk/gtksettings.c:1195 +#: ../gtk/gtksettings.c:1231 msgid "How to draw the input method preedit string" msgstr "Cómo dibujar la cadena del método de entrada de preedición" -#: ../gtk/gtksettings.c:1204 +#: ../gtk/gtksettings.c:1240 msgid "IM Status style" msgstr "Estilo del estado ME" -#: ../gtk/gtksettings.c:1205 +#: ../gtk/gtksettings.c:1241 msgid "How to draw the input method statusbar" msgstr "Cómo dibujar el método de entrada de la barra de estado" @@ -5594,15 +5572,15 @@ msgstr "" "Si es TRUE, los widgets no mapeados se ignoran al determinar el tamaño del " "grupo" -#: ../gtk/gtkspinbutton.c:236 +#: ../gtk/gtkspinbutton.c:238 msgid "Climb Rate" msgstr "Tasa de subida" -#: ../gtk/gtkspinbutton.c:256 +#: ../gtk/gtkspinbutton.c:258 msgid "Snap to Ticks" msgstr "Ajustarse a los ticks" -#: ../gtk/gtkspinbutton.c:257 +#: ../gtk/gtkspinbutton.c:259 msgid "" "Whether erroneous values are automatically changed to a spin button's " "nearest step increment" @@ -5610,39 +5588,39 @@ msgstr "" "Indica si los valores erróneos se cambian por el valor más cercano de un " "botón incrementable" -#: ../gtk/gtkspinbutton.c:264 +#: ../gtk/gtkspinbutton.c:266 msgid "Numeric" msgstr "Numérico" -#: ../gtk/gtkspinbutton.c:265 +#: ../gtk/gtkspinbutton.c:267 msgid "Whether non-numeric characters should be ignored" msgstr "Indica si se ignoran los caracteres no numéricos" -#: ../gtk/gtkspinbutton.c:272 +#: ../gtk/gtkspinbutton.c:274 msgid "Wrap" msgstr "Volver al inicio" -#: ../gtk/gtkspinbutton.c:273 +#: ../gtk/gtkspinbutton.c:275 msgid "Whether a spin button should wrap upon reaching its limits" msgstr "" "Indica si un botón giratorio debe volver al inicio al alcanzar sus límites" -#: ../gtk/gtkspinbutton.c:280 +#: ../gtk/gtkspinbutton.c:282 msgid "Update Policy" msgstr "Norma de actualización" -#: ../gtk/gtkspinbutton.c:281 +#: ../gtk/gtkspinbutton.c:283 msgid "" "Whether the spin button should update always, or only when the value is legal" msgstr "" "Indica si el botón incrementable se actualiza siempre, o sólo cuando el " "valor es legal" -#: ../gtk/gtkspinbutton.c:290 +#: ../gtk/gtkspinbutton.c:292 msgid "Reads the current value, or sets a new value" msgstr "Lee el valor actual, o establece un valor nuevo" -#: ../gtk/gtkspinbutton.c:299 +#: ../gtk/gtkspinbutton.c:301 msgid "Style of bevel around the spin button" msgstr "Estilo de bisel alrededor del botón giratorio" @@ -5675,7 +5653,7 @@ msgstr "" "El tiempo en milisegundos para que el marcador incrementable complete una " "vuelta completa" -#: ../gtk/gtkstatusbar.c:179 +#: ../gtk/gtkstatusbar.c:181 msgid "Style of bevel around the statusbar text" msgstr "Estilo del bisel alrededor del texto de la barra de estado" @@ -5699,7 +5677,7 @@ msgstr "Indica si el icono de estado está empotrado" msgid "The orientation of the tray" msgstr "La orientación de la bandeja" -#: ../gtk/gtkstatusicon.c:347 ../gtk/gtkwidget.c:1084 +#: ../gtk/gtkstatusicon.c:347 ../gtk/gtkwidget.c:1025 msgid "Has tooltip" msgstr "Tiene consejo" @@ -5707,15 +5685,15 @@ msgstr "Tiene consejo" msgid "Whether this tray icon has a tooltip" msgstr "Indica si el icono de la bandeja tiene un consejo" -#: ../gtk/gtkstatusicon.c:373 ../gtk/gtkwidget.c:1105 +#: ../gtk/gtkstatusicon.c:373 ../gtk/gtkwidget.c:1046 msgid "Tooltip Text" msgstr "Texto del consejo" -#: ../gtk/gtkstatusicon.c:374 ../gtk/gtkwidget.c:1106 ../gtk/gtkwidget.c:1127 +#: ../gtk/gtkstatusicon.c:374 ../gtk/gtkwidget.c:1047 ../gtk/gtkwidget.c:1068 msgid "The contents of the tooltip for this widget" msgstr "El contenido de los consejos para este widget" -#: ../gtk/gtkstatusicon.c:397 ../gtk/gtkwidget.c:1126 +#: ../gtk/gtkstatusicon.c:397 ../gtk/gtkwidget.c:1067 msgid "Tooltip markup" msgstr "Marcado de consejos" @@ -5727,89 +5705,99 @@ msgstr "El contenido de los consejos para este icono de la bandeja" msgid "The title of this tray icon" msgstr "El título de este icono de la bandeja" -#: ../gtk/gtktable.c:152 +#: ../gtk/gtkswitch.c:740 +#| msgid "Whether the widget is double buffered" +msgid "Whether the switch is on or off" +msgstr "Indica si el interruptor está encendido o apagado" + +#: ../gtk/gtkswitch.c:774 +#| msgid "The minimum value of the adjustment" +msgid "The minimum width of the handle" +msgstr "La anchura mínima del tirador" + +#: ../gtk/gtktable.c:157 msgid "Rows" msgstr "Filas" -#: ../gtk/gtktable.c:153 +#: ../gtk/gtktable.c:158 msgid "The number of rows in the table" msgstr "El número de filas en la tabla" -#: ../gtk/gtktable.c:161 +#: ../gtk/gtktable.c:166 msgid "Columns" msgstr "Columnas" -#: ../gtk/gtktable.c:162 +#: ../gtk/gtktable.c:167 msgid "The number of columns in the table" msgstr "El número de columnas en la tabla" -#: ../gtk/gtktable.c:170 +#: ../gtk/gtktable.c:175 msgid "Row spacing" msgstr "Espaciado entre filas" -#: ../gtk/gtktable.c:171 +#: ../gtk/gtktable.c:176 msgid "The amount of space between two consecutive rows" msgstr "La cantidad de espacio entre dos filas consecutivas" -#: ../gtk/gtktable.c:179 +#: ../gtk/gtktable.c:184 msgid "Column spacing" msgstr "Espaciado de la columna" -#: ../gtk/gtktable.c:180 +#: ../gtk/gtktable.c:185 msgid "The amount of space between two consecutive columns" msgstr "La cantidad de espacio entre dos columnas consecutivas" -#: ../gtk/gtktable.c:189 +#: ../gtk/gtktable.c:194 msgid "If TRUE, the table cells are all the same width/height" msgstr "" "Si es TRUE, las celdas de la tabla tienen todas de la misma anchura/altura" -#: ../gtk/gtktable.c:196 +#: ../gtk/gtktable.c:201 msgid "Left attachment" msgstr "Acoplado izquierdo" -#: ../gtk/gtktable.c:203 +#: ../gtk/gtktable.c:208 msgid "Right attachment" msgstr "Acoplado derecho" -#: ../gtk/gtktable.c:204 +#: ../gtk/gtktable.c:209 msgid "The column number to attach the right side of a child widget to" msgstr "" "El número de columnas que acoplar hacia el lado derecho de un widget hijo" -#: ../gtk/gtktable.c:210 +#: ../gtk/gtktable.c:215 msgid "Top attachment" msgstr "Acoplado superior" -#: ../gtk/gtktable.c:211 +#: ../gtk/gtktable.c:216 msgid "The row number to attach the top of a child widget to" msgstr "El número de fila que acoplar a la parte superior de un widget hijo" -#: ../gtk/gtktable.c:217 +#: ../gtk/gtktable.c:222 msgid "Bottom attachment" msgstr "Acoplado inferior" -#: ../gtk/gtktable.c:224 +#: ../gtk/gtktable.c:229 msgid "Horizontal options" msgstr "Opciones horizontales" -#: ../gtk/gtktable.c:225 +#: ../gtk/gtktable.c:230 msgid "Options specifying the horizontal behaviour of the child" msgstr "Opciones que indicar el comportamiento horizontal del hijo" -#: ../gtk/gtktable.c:231 +#: ../gtk/gtktable.c:236 msgid "Vertical options" msgstr "Opciones verticales" -#: ../gtk/gtktable.c:232 +#: ../gtk/gtktable.c:237 msgid "Options specifying the vertical behaviour of the child" msgstr "Opciones que especifican el comportamiento vertical del hijo" -#: ../gtk/gtktable.c:238 +#: ../gtk/gtktable.c:243 msgid "Horizontal padding" msgstr "Relleno horizontal" -#: ../gtk/gtktable.c:239 +#: ../gtk/gtktable.c:244 msgid "" "Extra space to put between the child and its left and right neighbors, in " "pixels" @@ -5817,11 +5805,11 @@ msgstr "" "Espacio extra que poner entre el hijo y sus vecinos izquierdos y derechos, " "en píxeles" -#: ../gtk/gtktable.c:245 +#: ../gtk/gtktable.c:250 msgid "Vertical padding" msgstr "Relleno vertical" -#: ../gtk/gtktable.c:246 +#: ../gtk/gtktable.c:251 msgid "" "Extra space to put between the child and its upper and lower neighbors, in " "pixels" @@ -5829,53 +5817,53 @@ msgstr "" "Espacio extra que poner entre el hijo y sus vecinos superiores e inferiores, " "en píxeles" -#: ../gtk/gtktextbuffer.c:192 +#: ../gtk/gtktextbuffer.c:191 msgid "Tag Table" msgstr "Tabla de etiquetas" -#: ../gtk/gtktextbuffer.c:193 +#: ../gtk/gtktextbuffer.c:192 msgid "Text Tag Table" msgstr "Tabla de etiquetas de texto" -#: ../gtk/gtktextbuffer.c:211 +#: ../gtk/gtktextbuffer.c:210 msgid "Current text of the buffer" msgstr "Texto actual del búfer" -#: ../gtk/gtktextbuffer.c:225 +#: ../gtk/gtktextbuffer.c:224 msgid "Has selection" msgstr "Tiene selección" -#: ../gtk/gtktextbuffer.c:226 +#: ../gtk/gtktextbuffer.c:225 msgid "Whether the buffer has some text currently selected" msgstr "Indica si el búfer tiene algo de texto actualmente seleccionado" -#: ../gtk/gtktextbuffer.c:242 +#: ../gtk/gtktextbuffer.c:241 msgid "Cursor position" msgstr "Posición del cursor" -#: ../gtk/gtktextbuffer.c:243 +#: ../gtk/gtktextbuffer.c:242 msgid "" "The position of the insert mark (as offset from the beginning of the buffer)" msgstr "" "La posición de la marca de inserción (como un desplazamiento desde el " "principio del búfer)" -#: ../gtk/gtktextbuffer.c:258 +#: ../gtk/gtktextbuffer.c:257 msgid "Copy target list" msgstr "Lista de destinos de la copia" -#: ../gtk/gtktextbuffer.c:259 +#: ../gtk/gtktextbuffer.c:258 msgid "" "The list of targets this buffer supports for clipboard copying and DND source" msgstr "" "La lista de destinos que soporta este búfer para copiar desde el " "portapapeles y el origen del DND" -#: ../gtk/gtktextbuffer.c:274 +#: ../gtk/gtktextbuffer.c:273 msgid "Paste target list" msgstr "Lista de destinos de pegado" -#: ../gtk/gtktextbuffer.c:275 +#: ../gtk/gtktextbuffer.c:274 msgid "" "The list of targets this buffer supports for clipboard pasting and DND " "destination" @@ -5975,7 +5963,7 @@ msgstr "" "tema, etc. por lo cual se recomienda. Pango define previamente algunas " "escalas tales como PANGO_SCALE_X_LARGE" -#: ../gtk/gtktexttag.c:336 ../gtk/gtktextview.c:678 +#: ../gtk/gtktexttag.c:336 ../gtk/gtktextview.c:704 msgid "Left, right, or center justification" msgstr "Justificación a la izquierda, derecha o centro" @@ -5992,7 +5980,7 @@ msgstr "" msgid "Left margin" msgstr "Margen izquierdo" -#: ../gtk/gtktexttag.c:363 ../gtk/gtktextview.c:687 +#: ../gtk/gtktexttag.c:363 ../gtk/gtktextview.c:713 msgid "Width of the left margin in pixels" msgstr "Anchura del margen izquierdo en píxeles" @@ -6000,15 +5988,15 @@ msgstr "Anchura del margen izquierdo en píxeles" msgid "Right margin" msgstr "Margen derecho" -#: ../gtk/gtktexttag.c:373 ../gtk/gtktextview.c:697 +#: ../gtk/gtktexttag.c:373 ../gtk/gtktextview.c:723 msgid "Width of the right margin in pixels" msgstr "Anchura del margen derecho en píxeles" -#: ../gtk/gtktexttag.c:383 ../gtk/gtktextview.c:706 +#: ../gtk/gtktexttag.c:383 ../gtk/gtktextview.c:732 msgid "Indent" msgstr "Sangrar" -#: ../gtk/gtktexttag.c:384 ../gtk/gtktextview.c:707 +#: ../gtk/gtktexttag.c:384 ../gtk/gtktextview.c:733 msgid "Amount to indent the paragraph, in pixels" msgstr "Número de píxeles para el sangrado del párrafo" @@ -6024,7 +6012,7 @@ msgstr "" msgid "Pixels above lines" msgstr "Píxeles encima de las líneas" -#: ../gtk/gtktexttag.c:405 ../gtk/gtktextview.c:631 +#: ../gtk/gtktexttag.c:405 ../gtk/gtktextview.c:657 msgid "Pixels of blank space above paragraphs" msgstr "Píxeles de espacio en blanco encima de los párrafos" @@ -6032,7 +6020,7 @@ msgstr "Píxeles de espacio en blanco encima de los párrafos" msgid "Pixels below lines" msgstr "Píxeles debajo de las líneas" -#: ../gtk/gtktexttag.c:415 ../gtk/gtktextview.c:641 +#: ../gtk/gtktexttag.c:415 ../gtk/gtktextview.c:667 msgid "Pixels of blank space below paragraphs" msgstr "Píxeles de espacio en blanco debajo de los párrafos" @@ -6040,22 +6028,22 @@ msgstr "Píxeles de espacio en blanco debajo de los párrafos" msgid "Pixels inside wrap" msgstr "Píxeles dentro del ajuste" -#: ../gtk/gtktexttag.c:425 ../gtk/gtktextview.c:651 +#: ../gtk/gtktexttag.c:425 ../gtk/gtktextview.c:677 msgid "Pixels of blank space between wrapped lines in a paragraph" msgstr "Píxeles de espacio en blanco entre las líneas ajustadas en un párrafo" -#: ../gtk/gtktexttag.c:452 ../gtk/gtktextview.c:669 +#: ../gtk/gtktexttag.c:452 ../gtk/gtktextview.c:695 msgid "" "Whether to wrap lines never, at word boundaries, or at character boundaries" msgstr "" "Indica si deben ajustarse las líneas, a los límites de las palabras, a los " "límites de los caracteres, o nunca" -#: ../gtk/gtktexttag.c:461 ../gtk/gtktextview.c:716 +#: ../gtk/gtktexttag.c:461 ../gtk/gtktextview.c:742 msgid "Tabs" msgstr "Solapas" -#: ../gtk/gtktexttag.c:462 ../gtk/gtktextview.c:717 +#: ../gtk/gtktexttag.c:462 ../gtk/gtktextview.c:743 msgid "Custom tabs for this text" msgstr "Pestañas personalizadas para este texto" @@ -6186,63 +6174,63 @@ msgstr "Fondo de parágrafo establecido" msgid "Whether this tag affects the paragraph background color" msgstr "Indica si esta etiqueta afecta el color de fondo del parágrafo" -#: ../gtk/gtktextview.c:630 +#: ../gtk/gtktextview.c:656 msgid "Pixels Above Lines" msgstr "Píxeles sobre las líneas" -#: ../gtk/gtktextview.c:640 +#: ../gtk/gtktextview.c:666 msgid "Pixels Below Lines" msgstr "Píxeles por debajo de las líneas" -#: ../gtk/gtktextview.c:650 +#: ../gtk/gtktextview.c:676 msgid "Pixels Inside Wrap" msgstr "Píxeles dentro del ajuste" -#: ../gtk/gtktextview.c:668 +#: ../gtk/gtktextview.c:694 msgid "Wrap Mode" msgstr "Modo de ajuste" -#: ../gtk/gtktextview.c:686 +#: ../gtk/gtktextview.c:712 msgid "Left Margin" msgstr "Margen izquierdo" -#: ../gtk/gtktextview.c:696 +#: ../gtk/gtktextview.c:722 msgid "Right Margin" msgstr "Margen derecho" -#: ../gtk/gtktextview.c:724 +#: ../gtk/gtktextview.c:750 msgid "Cursor Visible" msgstr "Cursor visible" -#: ../gtk/gtktextview.c:725 +#: ../gtk/gtktextview.c:751 msgid "If the insertion cursor is shown" msgstr "Si se muestra el cursor de inserción" -#: ../gtk/gtktextview.c:732 +#: ../gtk/gtktextview.c:758 msgid "Buffer" msgstr "Búfer" -#: ../gtk/gtktextview.c:733 +#: ../gtk/gtktextview.c:759 msgid "The buffer which is displayed" msgstr "El búfer que se está mostrando" -#: ../gtk/gtktextview.c:741 +#: ../gtk/gtktextview.c:767 msgid "Whether entered text overwrites existing contents" msgstr "Indica si el texto introducido sobreescribe el existente" -#: ../gtk/gtktextview.c:748 +#: ../gtk/gtktextview.c:774 msgid "Accepts tab" msgstr "Acepta tabuladores" -#: ../gtk/gtktextview.c:749 +#: ../gtk/gtktextview.c:775 msgid "Whether Tab will result in a tab character being entered" msgstr "Indica si Tab resultará en la introducción de un carácter tabulador" -#: ../gtk/gtktextview.c:782 +#: ../gtk/gtktextview.c:810 msgid "Error underline color" msgstr "Color de subrayado de errores" -#: ../gtk/gtktextview.c:783 +#: ../gtk/gtktextview.c:811 msgid "Color with which to draw error-indication underlines" msgstr "Color con el que dibujar el subrayado de indicación de errores" @@ -6260,101 +6248,101 @@ msgstr "" msgid "Whether the toggle action should be active" msgstr "Indica si la acción de conmutación debe estar activa" -#: ../gtk/gtktogglebutton.c:116 ../gtk/gtktoggletoolbutton.c:113 +#: ../gtk/gtktogglebutton.c:126 ../gtk/gtktoggletoolbutton.c:113 msgid "If the toggle button should be pressed in" msgstr "Si el botón de conmutación debe estar pulsado" -#: ../gtk/gtktogglebutton.c:124 +#: ../gtk/gtktogglebutton.c:134 msgid "If the toggle button is in an \"in between\" state" msgstr "Si el botón de conmutación está en un estado «intermedio»" -#: ../gtk/gtktogglebutton.c:131 +#: ../gtk/gtktogglebutton.c:141 msgid "Draw Indicator" msgstr "Indicador de dibujo" -#: ../gtk/gtktogglebutton.c:132 +#: ../gtk/gtktogglebutton.c:142 msgid "If the toggle part of the button is displayed" msgstr "Si se muestra la parte de conmutación del botón" -#: ../gtk/gtktoolbar.c:485 ../gtk/gtktoolpalette.c:1006 +#: ../gtk/gtktoolbar.c:491 ../gtk/gtktoolpalette.c:1060 msgid "Toolbar Style" msgstr "Estilo de la barra de herramientas" -#: ../gtk/gtktoolbar.c:486 +#: ../gtk/gtktoolbar.c:492 msgid "How to draw the toolbar" msgstr "Cómo dibujar la barra de herramientas" -#: ../gtk/gtktoolbar.c:493 +#: ../gtk/gtktoolbar.c:499 msgid "Show Arrow" msgstr "Mostrar flecha" -#: ../gtk/gtktoolbar.c:494 +#: ../gtk/gtktoolbar.c:500 msgid "If an arrow should be shown if the toolbar doesn't fit" msgstr "" "Indica si debe mostrarse una flecha si no cabe la barra de herramientas" -#: ../gtk/gtktoolbar.c:515 +#: ../gtk/gtktoolbar.c:521 msgid "Size of icons in this toolbar" msgstr "Tamaño de los iconos en esta barra de herramientas" -#: ../gtk/gtktoolbar.c:530 ../gtk/gtktoolpalette.c:992 +#: ../gtk/gtktoolbar.c:536 ../gtk/gtktoolpalette.c:1046 msgid "Icon size set" msgstr "Tamaño del icono establecido" -#: ../gtk/gtktoolbar.c:531 ../gtk/gtktoolpalette.c:993 +#: ../gtk/gtktoolbar.c:537 ../gtk/gtktoolpalette.c:1047 msgid "Whether the icon-size property has been set" msgstr "Indica si se ha establecido la propiedad de tamaño del icono" -#: ../gtk/gtktoolbar.c:540 +#: ../gtk/gtktoolbar.c:546 msgid "Whether the item should receive extra space when the toolbar grows" msgstr "" "Indica si el elemento debe recibir espacio extra cuando la barra crezca" -#: ../gtk/gtktoolbar.c:548 ../gtk/gtktoolitemgroup.c:1625 +#: ../gtk/gtktoolbar.c:554 ../gtk/gtktoolitemgroup.c:1642 msgid "Whether the item should be the same size as other homogeneous items" msgstr "" "Indica si el elemento debe ser del mismo tamaño que otros elementos " "homogéneos" -#: ../gtk/gtktoolbar.c:555 +#: ../gtk/gtktoolbar.c:561 msgid "Spacer size" msgstr "Tamaño del espaciador" -#: ../gtk/gtktoolbar.c:556 +#: ../gtk/gtktoolbar.c:562 msgid "Size of spacers" msgstr "Tamaño de los espaciadores" -#: ../gtk/gtktoolbar.c:565 +#: ../gtk/gtktoolbar.c:571 msgid "Amount of border space between the toolbar shadow and the buttons" msgstr "" "Número de espacio del borde entre la sombra de la barra de herramientas y " "los botones" -#: ../gtk/gtktoolbar.c:573 +#: ../gtk/gtktoolbar.c:579 msgid "Maximum child expand" msgstr "Expansión de hijos máxima" -#: ../gtk/gtktoolbar.c:574 +#: ../gtk/gtktoolbar.c:580 msgid "Maximum amount of space an expandable item will be given" msgstr "Cantidad máxima de espacio que se le dará a un elemento expandible" -#: ../gtk/gtktoolbar.c:582 +#: ../gtk/gtktoolbar.c:588 msgid "Space style" msgstr "Estilo del espacio" -#: ../gtk/gtktoolbar.c:583 +#: ../gtk/gtktoolbar.c:589 msgid "Whether spacers are vertical lines or just blank" msgstr "Indica si los espaciadores son líneas verticales o sólo blancos" -#: ../gtk/gtktoolbar.c:590 +#: ../gtk/gtktoolbar.c:596 msgid "Button relief" msgstr "Borde del botón" -#: ../gtk/gtktoolbar.c:591 +#: ../gtk/gtktoolbar.c:597 msgid "Type of bevel around toolbar buttons" msgstr "Tipo de bisel alrededor de los botones de la barra de herramientas" -#: ../gtk/gtktoolbar.c:598 +#: ../gtk/gtktoolbar.c:604 msgid "Style of bevel around the toolbar" msgstr "Estilo del bisel alrededor de la barra de herramientas" @@ -6407,7 +6395,7 @@ msgstr "Espaciado entre iconos" msgid "Spacing in pixels between the icon and label" msgstr "Espaciado en píxeles entre el icono y la etiqueta" -#: ../gtk/gtktoolitem.c:201 +#: ../gtk/gtktoolitem.c:210 msgid "" "Whether the toolbar item is considered important. When TRUE, toolbar buttons " "show text in GTK_TOOLBAR_BOTH_HORIZ mode" @@ -6416,85 +6404,85 @@ msgstr "" "Cuando está a TRUE, los botones de la barra de herramientas muestran texto " "en modo GTK_TOOLBAR_BOTH_HORIZ" -#: ../gtk/gtktoolitemgroup.c:1572 +#: ../gtk/gtktoolitemgroup.c:1589 msgid "The human-readable title of this item group" msgstr "El título leíble por humanos de este grupo de elementos" -#: ../gtk/gtktoolitemgroup.c:1579 +#: ../gtk/gtktoolitemgroup.c:1596 msgid "A widget to display in place of the usual label" msgstr "Un widget para mostrar en lugar de la usual etiqueta" -#: ../gtk/gtktoolitemgroup.c:1585 +#: ../gtk/gtktoolitemgroup.c:1602 msgid "Collapsed" msgstr "Contraído" -#: ../gtk/gtktoolitemgroup.c:1586 +#: ../gtk/gtktoolitemgroup.c:1603 msgid "Whether the group has been collapsed and items are hidden" msgstr "Indica si el grupo se ha colapsado y sus elementos están ocultos" -#: ../gtk/gtktoolitemgroup.c:1592 +#: ../gtk/gtktoolitemgroup.c:1609 msgid "ellipsize" msgstr "elipsis" -#: ../gtk/gtktoolitemgroup.c:1593 +#: ../gtk/gtktoolitemgroup.c:1610 msgid "Ellipsize for item group headers" msgstr "Elipsis para las cabeceras de grupo de los elementos" -#: ../gtk/gtktoolitemgroup.c:1599 +#: ../gtk/gtktoolitemgroup.c:1616 msgid "Header Relief" msgstr "Relieve de la cabecera" -#: ../gtk/gtktoolitemgroup.c:1600 +#: ../gtk/gtktoolitemgroup.c:1617 msgid "Relief of the group header button" msgstr "Relieve del botón de cabecera del grupo" -#: ../gtk/gtktoolitemgroup.c:1615 +#: ../gtk/gtktoolitemgroup.c:1632 msgid "Header Spacing" msgstr "Espaciado de la cabecera" -#: ../gtk/gtktoolitemgroup.c:1616 +#: ../gtk/gtktoolitemgroup.c:1633 msgid "Spacing between expander arrow and caption" msgstr "Espaciado entre la flecha del expansor y la descripción" -#: ../gtk/gtktoolitemgroup.c:1632 +#: ../gtk/gtktoolitemgroup.c:1649 msgid "Whether the item should receive extra space when the group grows" msgstr "Indica si el elemento debe recibir espacio extra cuando el grupo crece" -#: ../gtk/gtktoolitemgroup.c:1639 +#: ../gtk/gtktoolitemgroup.c:1656 msgid "Whether the item should fill the available space" msgstr "Indica si el elemento debería llenar todo el espacio disponible" -#: ../gtk/gtktoolitemgroup.c:1645 +#: ../gtk/gtktoolitemgroup.c:1662 msgid "New Row" msgstr "Fila nueva" -#: ../gtk/gtktoolitemgroup.c:1646 +#: ../gtk/gtktoolitemgroup.c:1663 msgid "Whether the item should start a new row" msgstr "Indica si el elemento debería iniciar una fila nueva" -#: ../gtk/gtktoolitemgroup.c:1653 +#: ../gtk/gtktoolitemgroup.c:1670 msgid "Position of the item within this group" msgstr "Posición del elemento en su grupo" -#: ../gtk/gtktoolpalette.c:977 +#: ../gtk/gtktoolpalette.c:1031 msgid "Size of icons in this tool palette" msgstr "Tamaño de los iconos en esta paleta de herramientas" -#: ../gtk/gtktoolpalette.c:1007 +#: ../gtk/gtktoolpalette.c:1061 msgid "Style of items in the tool palette" msgstr "Estilo de los elementos en la paleta de herramientas" -#: ../gtk/gtktoolpalette.c:1023 +#: ../gtk/gtktoolpalette.c:1077 msgid "Exclusive" msgstr "Exclusivo" -#: ../gtk/gtktoolpalette.c:1024 +#: ../gtk/gtktoolpalette.c:1078 msgid "Whether the item group should be the only expanded at a given time" msgstr "" "Indica si el elemento del grupo deben ser el único expandido en un " "determinado momento" -#: ../gtk/gtktoolpalette.c:1039 +#: ../gtk/gtktoolpalette.c:1093 msgid "" "Whether the item group should receive extra space when the palette grows" msgstr "" @@ -6541,222 +6529,222 @@ msgstr "Modelo TreeModelSort" msgid "The model for the TreeModelSort to sort" msgstr "El modelo para el TreeModelSort a ordenar" -#: ../gtk/gtktreeview.c:566 +#: ../gtk/gtktreeview.c:661 msgid "TreeView Model" msgstr "Modelo TreeView" -#: ../gtk/gtktreeview.c:567 +#: ../gtk/gtktreeview.c:662 msgid "The model for the tree view" msgstr "El modelo para la vista de árbol" -#: ../gtk/gtktreeview.c:577 +#: ../gtk/gtktreeview.c:674 msgid "Headers Visible" msgstr "Cabeceras visibles" -#: ../gtk/gtktreeview.c:578 +#: ../gtk/gtktreeview.c:675 msgid "Show the column header buttons" msgstr "Mostrar botones en los encabezados de columna" -#: ../gtk/gtktreeview.c:585 +#: ../gtk/gtktreeview.c:682 msgid "Headers Clickable" msgstr "Cabeceras pulsables" -#: ../gtk/gtktreeview.c:586 +#: ../gtk/gtktreeview.c:683 msgid "Column headers respond to click events" msgstr "Las cabeceras de las columnas responden a los eventos de pulsación" -#: ../gtk/gtktreeview.c:593 +#: ../gtk/gtktreeview.c:690 msgid "Expander Column" msgstr "Columna expansora" -#: ../gtk/gtktreeview.c:594 +#: ../gtk/gtktreeview.c:691 msgid "Set the column for the expander column" msgstr "Define la columna para la columna expansora" -#: ../gtk/gtktreeview.c:609 +#: ../gtk/gtktreeview.c:706 msgid "Rules Hint" msgstr "Consejo de las reglas" -#: ../gtk/gtktreeview.c:610 +#: ../gtk/gtktreeview.c:707 msgid "Set a hint to the theme engine to draw rows in alternating colors" msgstr "" "Define un consejo para el motor del tema para dibujar las filas con colores " "alternativos" -#: ../gtk/gtktreeview.c:617 +#: ../gtk/gtktreeview.c:714 msgid "Enable Search" msgstr "Habilitar búsqueda" -#: ../gtk/gtktreeview.c:618 +#: ../gtk/gtktreeview.c:715 msgid "View allows user to search through columns interactively" msgstr "" "La vista permite a los usuarios buscar en forma interactiva a través de las " "columnas" -#: ../gtk/gtktreeview.c:625 +#: ../gtk/gtktreeview.c:722 msgid "Search Column" msgstr "Columna de búsqueda" -#: ../gtk/gtktreeview.c:626 +#: ../gtk/gtktreeview.c:723 msgid "Model column to search through during interactive search" msgstr "" "Columna modelo para buscar a través de ella en una búsqueda interactiva" -#: ../gtk/gtktreeview.c:646 +#: ../gtk/gtktreeview.c:743 msgid "Fixed Height Mode" msgstr "Modo de altura fija" -#: ../gtk/gtktreeview.c:647 +#: ../gtk/gtktreeview.c:744 msgid "Speeds up GtkTreeView by assuming that all rows have the same height" msgstr "" "Acelera GtkTreeView asumiendo que todas las filas tienen la misma altura" -#: ../gtk/gtktreeview.c:667 +#: ../gtk/gtktreeview.c:764 msgid "Hover Selection" msgstr "Selección al pasar por encima" -#: ../gtk/gtktreeview.c:668 +#: ../gtk/gtktreeview.c:765 msgid "Whether the selection should follow the pointer" msgstr "Indica si la selección debe seguir al puntero" -#: ../gtk/gtktreeview.c:687 +#: ../gtk/gtktreeview.c:784 msgid "Hover Expand" msgstr "Expandir al poner el cursor encima" -#: ../gtk/gtktreeview.c:688 +#: ../gtk/gtktreeview.c:785 msgid "" "Whether rows should be expanded/collapsed when the pointer moves over them" msgstr "" "Indica si las filas deben expandirse/contraerse cuando el puntero se mueve " "sobre ellas" -#: ../gtk/gtktreeview.c:702 +#: ../gtk/gtktreeview.c:799 msgid "Show Expanders" msgstr "Mostrar expansores" -#: ../gtk/gtktreeview.c:703 +#: ../gtk/gtktreeview.c:800 msgid "View has expanders" msgstr "La vista tiene expansores" -#: ../gtk/gtktreeview.c:717 +#: ../gtk/gtktreeview.c:814 msgid "Level Indentation" msgstr "Nivel de sangrado" -#: ../gtk/gtktreeview.c:718 +#: ../gtk/gtktreeview.c:815 msgid "Extra indentation for each level" msgstr "Sangría extra para cada nivel" -#: ../gtk/gtktreeview.c:727 +#: ../gtk/gtktreeview.c:824 msgid "Rubber Banding" msgstr "Bandas de goma" -#: ../gtk/gtktreeview.c:728 +#: ../gtk/gtktreeview.c:825 msgid "" "Whether to enable selection of multiple items by dragging the mouse pointer" msgstr "" "Indica si se debe activar la selección de múltiples elementos arrastrándo el " "puntero del ratón" -#: ../gtk/gtktreeview.c:735 +#: ../gtk/gtktreeview.c:832 msgid "Enable Grid Lines" msgstr "Activar líneas de la rejilla" -#: ../gtk/gtktreeview.c:736 +#: ../gtk/gtktreeview.c:833 msgid "Whether grid lines should be drawn in the tree view" msgstr "Indica si debe haber un icono cerca del elemento" -#: ../gtk/gtktreeview.c:744 +#: ../gtk/gtktreeview.c:841 msgid "Enable Tree Lines" msgstr "Activar líneas del árbol" -#: ../gtk/gtktreeview.c:745 +#: ../gtk/gtktreeview.c:842 msgid "Whether tree lines should be drawn in the tree view" msgstr "Indica si deben dibujar las líneas en la vista del árbol" -#: ../gtk/gtktreeview.c:753 +#: ../gtk/gtktreeview.c:850 msgid "The column in the model containing the tooltip texts for the rows" msgstr "" "La columna del modelo que contiene los textos de consejo para las filas" -#: ../gtk/gtktreeview.c:775 +#: ../gtk/gtktreeview.c:872 msgid "Vertical Separator Width" msgstr "Anchura del separador vertical" -#: ../gtk/gtktreeview.c:776 +#: ../gtk/gtktreeview.c:873 msgid "Vertical space between cells. Must be an even number" msgstr "Espacio vertical entre celdas. Debe ser un número par" -#: ../gtk/gtktreeview.c:784 +#: ../gtk/gtktreeview.c:881 msgid "Horizontal Separator Width" msgstr "Anchura del separador horizontal" -#: ../gtk/gtktreeview.c:785 +#: ../gtk/gtktreeview.c:882 msgid "Horizontal space between cells. Must be an even number" msgstr "Espacio horizontal entre celdas. Debe ser un número par" -#: ../gtk/gtktreeview.c:793 +#: ../gtk/gtktreeview.c:890 msgid "Allow Rules" msgstr "Permitir reglas" -#: ../gtk/gtktreeview.c:794 +#: ../gtk/gtktreeview.c:891 msgid "Allow drawing of alternating color rows" msgstr "Permitir el dibujado de filas con colores alternativos" -#: ../gtk/gtktreeview.c:800 +#: ../gtk/gtktreeview.c:897 msgid "Indent Expanders" msgstr "Sangrar expansores" -#: ../gtk/gtktreeview.c:801 +#: ../gtk/gtktreeview.c:898 msgid "Make the expanders indented" msgstr "Crea los expansores sangrados" -#: ../gtk/gtktreeview.c:807 +#: ../gtk/gtktreeview.c:904 msgid "Even Row Color" msgstr "Color de la fila par" -#: ../gtk/gtktreeview.c:808 +#: ../gtk/gtktreeview.c:905 msgid "Color to use for even rows" msgstr "Color a usar para las filas pares" -#: ../gtk/gtktreeview.c:814 +#: ../gtk/gtktreeview.c:911 msgid "Odd Row Color" msgstr "Color de la fila impar" -#: ../gtk/gtktreeview.c:815 +#: ../gtk/gtktreeview.c:912 msgid "Color to use for odd rows" msgstr "Color a usar para las filas impares" -#: ../gtk/gtktreeview.c:821 +#: ../gtk/gtktreeview.c:918 msgid "Grid line width" msgstr "Anchura de la línea de la rejilla" -#: ../gtk/gtktreeview.c:822 +#: ../gtk/gtktreeview.c:919 msgid "Width, in pixels, of the tree view grid lines" msgstr "Anchura, en píxeles, de la línea indicadora del foco" -#: ../gtk/gtktreeview.c:828 +#: ../gtk/gtktreeview.c:925 msgid "Tree line width" msgstr "Anchura de la línea del árbol" -#: ../gtk/gtktreeview.c:829 +#: ../gtk/gtktreeview.c:926 msgid "Width, in pixels, of the tree view lines" msgstr "Anchura, en píxeles, de la línea indicadora del foco" -#: ../gtk/gtktreeview.c:835 +#: ../gtk/gtktreeview.c:932 msgid "Grid line pattern" msgstr "Patrón de la línea de la rejilla" -#: ../gtk/gtktreeview.c:836 +#: ../gtk/gtktreeview.c:933 msgid "Dash pattern used to draw the tree view grid lines" msgstr "" "Patrón de guiones utilizado para dibujar las líneas de rejilla de la vista " "de árbol" -#: ../gtk/gtktreeview.c:842 +#: ../gtk/gtktreeview.c:939 msgid "Tree line pattern" msgstr "Patrón de la línea del árbol" -#: ../gtk/gtktreeview.c:843 +#: ../gtk/gtktreeview.c:940 msgid "Dash pattern used to draw the tree view lines" msgstr "" "Patrón de guiones utilizado para dibujar las líneas de la vista de árbol" @@ -6765,7 +6753,7 @@ msgstr "" msgid "Whether to display the column" msgstr "Indica si se debe mostrar la columna" -#: ../gtk/gtktreeviewcolumn.c:221 ../gtk/gtkwindow.c:656 +#: ../gtk/gtktreeviewcolumn.c:221 ../gtk/gtkwindow.c:657 msgid "Resizable" msgstr "Redimensionable" @@ -6886,32 +6874,32 @@ msgstr "Definición del IU combinado" msgid "An XML string describing the merged UI" msgstr "Una cadena XML describiendo el IU combinado" -#: ../gtk/gtkviewport.c:149 +#: ../gtk/gtkviewport.c:155 msgid "Determines how the shadowed box around the viewport is drawn" msgstr "" "Determina como es dibujado el marco sombreado alrededor del puerto de visión" -#: ../gtk/gtkwidget.c:935 +#: ../gtk/gtkwidget.c:876 msgid "Widget name" msgstr "Nombre del widget" -#: ../gtk/gtkwidget.c:936 +#: ../gtk/gtkwidget.c:877 msgid "The name of the widget" msgstr "El nombre del widget" -#: ../gtk/gtkwidget.c:942 +#: ../gtk/gtkwidget.c:883 msgid "Parent widget" msgstr "Widget padre" -#: ../gtk/gtkwidget.c:943 +#: ../gtk/gtkwidget.c:884 msgid "The parent widget of this widget. Must be a Container widget" msgstr "El widget padre de este widget. Debe ser un widget contenedor" -#: ../gtk/gtkwidget.c:950 +#: ../gtk/gtkwidget.c:891 msgid "Width request" msgstr "Petición de anchura" -#: ../gtk/gtkwidget.c:951 +#: ../gtk/gtkwidget.c:892 msgid "" "Override for width request of the widget, or -1 if natural request should be " "used" @@ -6919,11 +6907,11 @@ msgstr "" "Sobreescribir el ancho solicitado del widget, o -1 si deber ser utilizado la " "solicitud natural" -#: ../gtk/gtkwidget.c:959 +#: ../gtk/gtkwidget.c:900 msgid "Height request" msgstr "Petición de altura" -#: ../gtk/gtkwidget.c:960 +#: ../gtk/gtkwidget.c:901 msgid "" "Override for height request of the widget, or -1 if natural request should " "be used" @@ -6931,84 +6919,84 @@ msgstr "" "Sobreescribir la altura solicitada del widget, o -1 si deber ser utilizada " "la solicitud natural" -#: ../gtk/gtkwidget.c:969 +#: ../gtk/gtkwidget.c:910 msgid "Whether the widget is visible" msgstr "Indica si el widget es visible" -#: ../gtk/gtkwidget.c:976 +#: ../gtk/gtkwidget.c:917 msgid "Whether the widget responds to input" msgstr "Indica si el widget responde al ingreso" -#: ../gtk/gtkwidget.c:982 +#: ../gtk/gtkwidget.c:923 msgid "Application paintable" msgstr "Pintable por la aplicación" -#: ../gtk/gtkwidget.c:983 +#: ../gtk/gtkwidget.c:924 msgid "Whether the application will paint directly on the widget" msgstr "Indica si la aplicación pintará directamente sobre el widget" -#: ../gtk/gtkwidget.c:989 +#: ../gtk/gtkwidget.c:930 msgid "Can focus" msgstr "Puede enfocar" -#: ../gtk/gtkwidget.c:990 +#: ../gtk/gtkwidget.c:931 msgid "Whether the widget can accept the input focus" msgstr "Indica si el widget puede aceptar el foco de entrada" -#: ../gtk/gtkwidget.c:996 +#: ../gtk/gtkwidget.c:937 msgid "Has focus" msgstr "Tiene foco" -#: ../gtk/gtkwidget.c:997 +#: ../gtk/gtkwidget.c:938 msgid "Whether the widget has the input focus" msgstr "Indica si el widget tiene el foco de entrada" -#: ../gtk/gtkwidget.c:1003 +#: ../gtk/gtkwidget.c:944 msgid "Is focus" msgstr "Tiene el foco" -#: ../gtk/gtkwidget.c:1004 +#: ../gtk/gtkwidget.c:945 msgid "Whether the widget is the focus widget within the toplevel" msgstr "Indica si el widget es el widget con foco dentro del nivel superior" -#: ../gtk/gtkwidget.c:1010 +#: ../gtk/gtkwidget.c:951 msgid "Can default" msgstr "Puede por omisión" -#: ../gtk/gtkwidget.c:1011 +#: ../gtk/gtkwidget.c:952 msgid "Whether the widget can be the default widget" msgstr "Indica si el widget puede ser el widget predeterminado" -#: ../gtk/gtkwidget.c:1017 +#: ../gtk/gtkwidget.c:958 msgid "Has default" msgstr "Tiene por omisión" -#: ../gtk/gtkwidget.c:1018 +#: ../gtk/gtkwidget.c:959 msgid "Whether the widget is the default widget" msgstr "Indica si el widget es el widget predeterminado" -#: ../gtk/gtkwidget.c:1024 +#: ../gtk/gtkwidget.c:965 msgid "Receives default" msgstr "Recibe por omisión" -#: ../gtk/gtkwidget.c:1025 +#: ../gtk/gtkwidget.c:966 msgid "If TRUE, the widget will receive the default action when it is focused" msgstr "" "Si es TRUE el widget recibirá la acción predeterminada cuando obtiene el foco" -#: ../gtk/gtkwidget.c:1031 +#: ../gtk/gtkwidget.c:972 msgid "Composite child" msgstr "Hijo compuesto" -#: ../gtk/gtkwidget.c:1032 +#: ../gtk/gtkwidget.c:973 msgid "Whether the widget is part of a composite widget" msgstr "Indica si el widget es parte de un widget compuesto" -#: ../gtk/gtkwidget.c:1038 +#: ../gtk/gtkwidget.c:979 msgid "Style" msgstr "Estilo" -#: ../gtk/gtkwidget.c:1039 +#: ../gtk/gtkwidget.c:980 msgid "" "The style of the widget, which contains information about how it will look " "(colors etc)" @@ -7016,186 +7004,186 @@ msgstr "" "El estilo del widget, que contiene información sobre la apariencia (colores, " "etc)" -#: ../gtk/gtkwidget.c:1045 +#: ../gtk/gtkwidget.c:986 msgid "Events" msgstr "Eventos" -#: ../gtk/gtkwidget.c:1046 +#: ../gtk/gtkwidget.c:987 msgid "The event mask that decides what kind of GdkEvents this widget gets" msgstr "" "La máscara de eventos que decide que tipo de GtkEvents recibe este widget" -#: ../gtk/gtkwidget.c:1053 +#: ../gtk/gtkwidget.c:994 msgid "Extension events" msgstr "Eventos de extensión" -#: ../gtk/gtkwidget.c:1054 +#: ../gtk/gtkwidget.c:995 msgid "The mask that decides what kind of extension events this widget gets" msgstr "" "La máscara que decide que clase de eventos de extensión conseguirá este " "widget" -#: ../gtk/gtkwidget.c:1061 +#: ../gtk/gtkwidget.c:1002 msgid "No show all" msgstr "No mostrar todo" -#: ../gtk/gtkwidget.c:1062 +#: ../gtk/gtkwidget.c:1003 msgid "Whether gtk_widget_show_all() should not affect this widget" msgstr "Indica que gtk_widget_show_all() no debe afectar a este widget" -#: ../gtk/gtkwidget.c:1085 +#: ../gtk/gtkwidget.c:1026 msgid "Whether this widget has a tooltip" msgstr "Indica si el widget tiene un consejo" -#: ../gtk/gtkwidget.c:1141 +#: ../gtk/gtkwidget.c:1082 msgid "Window" msgstr "Ventana" -#: ../gtk/gtkwidget.c:1142 +#: ../gtk/gtkwidget.c:1083 msgid "The widget's window if it is realized" msgstr "La ventana del widget si se realiza" -#: ../gtk/gtkwidget.c:1156 +#: ../gtk/gtkwidget.c:1097 msgid "Double Buffered" msgstr "Búfer doble" -#: ../gtk/gtkwidget.c:1157 +#: ../gtk/gtkwidget.c:1098 msgid "Whether the widget is double buffered" msgstr "Indica si el widget tiene búfer doble" -#: ../gtk/gtkwidget.c:1172 +#: ../gtk/gtkwidget.c:1113 msgid "How to position in extra horizontal space" msgstr "Cómo posicionar en el espacio horizontal adicional" -#: ../gtk/gtkwidget.c:1188 +#: ../gtk/gtkwidget.c:1129 msgid "How to position in extra vertical space" msgstr "Cómo posicionar en el espacio vertical adicional" -#: ../gtk/gtkwidget.c:1207 +#: ../gtk/gtkwidget.c:1148 msgid "Margin on Left" msgstr "Margen a la izquierda" -#: ../gtk/gtkwidget.c:1208 +#: ../gtk/gtkwidget.c:1149 msgid "Pixels of extra space on the left side" msgstr "Píxeles de espacio adicional en la parte izquierda" -#: ../gtk/gtkwidget.c:1228 +#: ../gtk/gtkwidget.c:1169 msgid "Margin on Right" msgstr "Margen a la derecha" -#: ../gtk/gtkwidget.c:1229 +#: ../gtk/gtkwidget.c:1170 msgid "Pixels of extra space on the right side" msgstr "Píxeles de espacio adicional en la parte derecha" -#: ../gtk/gtkwidget.c:1249 +#: ../gtk/gtkwidget.c:1190 msgid "Margin on Top" msgstr "Margen arriba" -#: ../gtk/gtkwidget.c:1250 +#: ../gtk/gtkwidget.c:1191 msgid "Pixels of extra space on the top side" msgstr "Píxeles de espacio adicional en la parte superior" -#: ../gtk/gtkwidget.c:1270 +#: ../gtk/gtkwidget.c:1211 msgid "Margin on Bottom" msgstr "Margen abajo" -#: ../gtk/gtkwidget.c:1271 +#: ../gtk/gtkwidget.c:1212 msgid "Pixels of extra space on the bottom side" msgstr "Píxeles de espacio adicional en la parte inferior" -#: ../gtk/gtkwidget.c:1288 +#: ../gtk/gtkwidget.c:1229 msgid "All Margins" msgstr "Todos los márgenes" -#: ../gtk/gtkwidget.c:1289 +#: ../gtk/gtkwidget.c:1230 msgid "Pixels of extra space on all four sides" msgstr "Píxeles de espacio adicionales en las cuatro partes" -#: ../gtk/gtkwidget.c:1322 +#: ../gtk/gtkwidget.c:1263 msgid "Horizontal Expand" msgstr "Expansión horizontal" -#: ../gtk/gtkwidget.c:1323 +#: ../gtk/gtkwidget.c:1264 msgid "Whether widget wants more horizontal space" msgstr "Indica si el widget quiere usar más espacio horizontal" -#: ../gtk/gtkwidget.c:1337 +#: ../gtk/gtkwidget.c:1278 msgid "Horizontal Expand Set" msgstr "Ajuste de expansión horizontal" -#: ../gtk/gtkwidget.c:1338 +#: ../gtk/gtkwidget.c:1279 msgid "Whether to use the hexpand property" msgstr "Indica si se debe usar la propiedad hexpand" -#: ../gtk/gtkwidget.c:1352 +#: ../gtk/gtkwidget.c:1293 msgid "Vertical Expand" msgstr "Expansión vertial" -#: ../gtk/gtkwidget.c:1353 +#: ../gtk/gtkwidget.c:1294 msgid "Whether widget wants more vertical space" msgstr "Indica si el widget quiere usar más espacio vertical" -#: ../gtk/gtkwidget.c:1367 +#: ../gtk/gtkwidget.c:1308 msgid "Vertical Expand Set" msgstr "Ajuste de expansión vertical" -#: ../gtk/gtkwidget.c:1368 +#: ../gtk/gtkwidget.c:1309 msgid "Whether to use the vexpand property" msgstr "Indica si se debe usar la propiedad vexpand" -#: ../gtk/gtkwidget.c:1382 +#: ../gtk/gtkwidget.c:1323 msgid "Expand Both" msgstr "Expandir en ambas" -#: ../gtk/gtkwidget.c:1383 +#: ../gtk/gtkwidget.c:1324 msgid "Whether widget wants to expand in both directions" msgstr "Indica si el widget quiere expandirse en ambas direcciones" -#: ../gtk/gtkwidget.c:3037 +#: ../gtk/gtkwidget.c:2963 msgid "Interior Focus" msgstr "Foco interior" -#: ../gtk/gtkwidget.c:3038 +#: ../gtk/gtkwidget.c:2964 msgid "Whether to draw the focus indicator inside widgets" msgstr "Indica si se ha de dibujar el indicador del foco dentro de los widgets" -#: ../gtk/gtkwidget.c:3044 +#: ../gtk/gtkwidget.c:2970 msgid "Focus linewidth" msgstr "Dar foco al ancho de línea" -#: ../gtk/gtkwidget.c:3045 +#: ../gtk/gtkwidget.c:2971 msgid "Width, in pixels, of the focus indicator line" msgstr "Anchura, en píxeles, de la línea indicadora del foco" -#: ../gtk/gtkwidget.c:3051 +#: ../gtk/gtkwidget.c:2977 msgid "Focus line dash pattern" msgstr "Dar foco a la línea con patrón punteado" -#: ../gtk/gtkwidget.c:3052 +#: ../gtk/gtkwidget.c:2978 msgid "Dash pattern used to draw the focus indicator" msgstr "Patrón punteado utilizado para dibujar el indicador de foco" -#: ../gtk/gtkwidget.c:3057 +#: ../gtk/gtkwidget.c:2983 msgid "Focus padding" msgstr "Relleno del foco" -#: ../gtk/gtkwidget.c:3058 +#: ../gtk/gtkwidget.c:2984 msgid "Width, in pixels, between focus indicator and the widget 'box'" msgstr "Anchura, en píxeles, entre el indicador de foco y la «caja» del widget" -#: ../gtk/gtkwidget.c:3063 +#: ../gtk/gtkwidget.c:2989 msgid "Cursor color" msgstr "Color del cursor" -#: ../gtk/gtkwidget.c:3064 +#: ../gtk/gtkwidget.c:2990 msgid "Color with which to draw insertion cursor" msgstr "Color con el cual dibujar el cursor de inserción" -#: ../gtk/gtkwidget.c:3069 +#: ../gtk/gtkwidget.c:2995 msgid "Secondary cursor color" msgstr "Color secundario del cursor" -#: ../gtk/gtkwidget.c:3070 +#: ../gtk/gtkwidget.c:2996 msgid "" "Color with which to draw the secondary insertion cursor when editing mixed " "right-to-left and left-to-right text" @@ -7203,43 +7191,43 @@ msgstr "" "Color con el cual dibujar el cursor de inserción secundario cuando se esta " "editando una mezcla de texto de derecha-a-izquierda y izquierda-a-derecha" -#: ../gtk/gtkwidget.c:3075 +#: ../gtk/gtkwidget.c:3001 msgid "Cursor line aspect ratio" msgstr "Proporción de la línea del cursor" -#: ../gtk/gtkwidget.c:3076 +#: ../gtk/gtkwidget.c:3002 msgid "Aspect ratio with which to draw insertion cursor" msgstr "La proporción con la cual dibujar el cursor de inserción" -#: ../gtk/gtkwidget.c:3082 +#: ../gtk/gtkwidget.c:3008 msgid "Window dragging" msgstr "Arrastre de ventana" -#: ../gtk/gtkwidget.c:3083 +#: ../gtk/gtkwidget.c:3009 msgid "Whether windows can be dragged by clicking on empty areas" msgstr "Indica si las ventanas se pueden arrastrar pulsando en áreas vacías" -#: ../gtk/gtkwidget.c:3096 +#: ../gtk/gtkwidget.c:3022 msgid "Unvisited Link Color" msgstr "Color del enlace no visitado" -#: ../gtk/gtkwidget.c:3097 +#: ../gtk/gtkwidget.c:3023 msgid "Color of unvisited links" msgstr "Color de los enlaces no visitados" -#: ../gtk/gtkwidget.c:3110 +#: ../gtk/gtkwidget.c:3036 msgid "Visited Link Color" msgstr "Color del enlace visitado" -#: ../gtk/gtkwidget.c:3111 +#: ../gtk/gtkwidget.c:3037 msgid "Color of visited links" msgstr "Color de los enlaces visitados" -#: ../gtk/gtkwidget.c:3125 +#: ../gtk/gtkwidget.c:3051 msgid "Wide Separators" msgstr "Separadores anchos" -#: ../gtk/gtkwidget.c:3126 +#: ../gtk/gtkwidget.c:3052 msgid "" "Whether separators have configurable width and should be drawn using a box " "instead of a line" @@ -7247,81 +7235,81 @@ msgstr "" "Indica si los separadores tienen anchura configurable y deben dibujarse " "usando una caja en lugar de una línea" -#: ../gtk/gtkwidget.c:3140 +#: ../gtk/gtkwidget.c:3066 msgid "Separator Width" msgstr "Anchura del separador" -#: ../gtk/gtkwidget.c:3141 +#: ../gtk/gtkwidget.c:3067 msgid "The width of separators if wide-separators is TRUE" msgstr "La anchura de los separadores si «wide-separators« es TRUE" -#: ../gtk/gtkwidget.c:3155 +#: ../gtk/gtkwidget.c:3081 msgid "Separator Height" msgstr "Altura del separador" -#: ../gtk/gtkwidget.c:3156 +#: ../gtk/gtkwidget.c:3082 msgid "The height of separators if \"wide-separators\" is TRUE" msgstr "La altura de los separadores si «wide-separators» es TRUE" -#: ../gtk/gtkwidget.c:3170 +#: ../gtk/gtkwidget.c:3096 msgid "Horizontal Scroll Arrow Length" msgstr "Longitud de la flecha de desplazamiento horizontal" -#: ../gtk/gtkwidget.c:3171 +#: ../gtk/gtkwidget.c:3097 msgid "The length of horizontal scroll arrows" msgstr "La longitud de las flechas de desplazamiento horizontal" -#: ../gtk/gtkwidget.c:3185 +#: ../gtk/gtkwidget.c:3111 msgid "Vertical Scroll Arrow Length" msgstr "Longitud de las flechas de desplazamiento vertical" -#: ../gtk/gtkwidget.c:3186 +#: ../gtk/gtkwidget.c:3112 msgid "The length of vertical scroll arrows" msgstr "La longitud de las flechas de desplazamiento vertical" -#: ../gtk/gtkwindow.c:614 +#: ../gtk/gtkwindow.c:615 msgid "Window Type" msgstr "Tipo de ventana" -#: ../gtk/gtkwindow.c:615 +#: ../gtk/gtkwindow.c:616 msgid "The type of the window" msgstr "El tipo de la ventana" -#: ../gtk/gtkwindow.c:623 +#: ../gtk/gtkwindow.c:624 msgid "Window Title" msgstr "Título de la ventana" -#: ../gtk/gtkwindow.c:624 +#: ../gtk/gtkwindow.c:625 msgid "The title of the window" msgstr "El título de la ventana" -#: ../gtk/gtkwindow.c:631 +#: ../gtk/gtkwindow.c:632 msgid "Window Role" msgstr "Rol de la ventana" -#: ../gtk/gtkwindow.c:632 +#: ../gtk/gtkwindow.c:633 msgid "Unique identifier for the window to be used when restoring a session" msgstr "" "Identificador único para la ventana para usarlo al restaurar una sesión" -#: ../gtk/gtkwindow.c:648 +#: ../gtk/gtkwindow.c:649 msgid "Startup ID" msgstr "ID de inicio" -#: ../gtk/gtkwindow.c:649 +#: ../gtk/gtkwindow.c:650 msgid "Unique startup identifier for the window used by startup-notification" msgstr "" "Identificador único de inicio para la ventana usado por startup-notification" -#: ../gtk/gtkwindow.c:657 +#: ../gtk/gtkwindow.c:658 msgid "If TRUE, users can resize the window" msgstr "Si es TRUE los usuario pueden redimensionar la ventana" -#: ../gtk/gtkwindow.c:664 +#: ../gtk/gtkwindow.c:665 msgid "Modal" msgstr "Modal" -#: ../gtk/gtkwindow.c:665 +#: ../gtk/gtkwindow.c:666 msgid "" "If TRUE, the window is modal (other windows are not usable while this one is " "up)" @@ -7329,80 +7317,80 @@ msgstr "" "Si es TRUE, esta ventana es modal (no se pueden utilizar otras ventanas " "mientras ésta este encima)" -#: ../gtk/gtkwindow.c:672 +#: ../gtk/gtkwindow.c:673 msgid "Window Position" msgstr "Posición de la ventana" -#: ../gtk/gtkwindow.c:673 +#: ../gtk/gtkwindow.c:674 msgid "The initial position of the window" msgstr "La posición inicial de la ventana" -#: ../gtk/gtkwindow.c:681 +#: ../gtk/gtkwindow.c:682 msgid "Default Width" msgstr "Anchura predeterminada" -#: ../gtk/gtkwindow.c:682 +#: ../gtk/gtkwindow.c:683 msgid "The default width of the window, used when initially showing the window" msgstr "" "El ancho predeterminado de la ventana, utilizado cuando se muestra " "inicialmente la ventana" -#: ../gtk/gtkwindow.c:691 +#: ../gtk/gtkwindow.c:692 msgid "Default Height" msgstr "Altura predeterminada" -#: ../gtk/gtkwindow.c:692 +#: ../gtk/gtkwindow.c:693 msgid "" "The default height of the window, used when initially showing the window" msgstr "" "La altura predeterminada de la ventana, utilizado cuando se muestra " "inicialmente la ventana" -#: ../gtk/gtkwindow.c:701 +#: ../gtk/gtkwindow.c:702 msgid "Destroy with Parent" msgstr "Destruir con el padre" -#: ../gtk/gtkwindow.c:702 +#: ../gtk/gtkwindow.c:703 msgid "If this window should be destroyed when the parent is destroyed" msgstr "Indica si esta ventana debe ser destruida cuando el padre se destruye" -#: ../gtk/gtkwindow.c:710 +#: ../gtk/gtkwindow.c:711 msgid "Icon for this window" msgstr "Icono para esta ventana" -#: ../gtk/gtkwindow.c:716 +#: ../gtk/gtkwindow.c:717 msgid "Mnemonics Visible" msgstr "Mnemónicos visibles" -#: ../gtk/gtkwindow.c:717 +#: ../gtk/gtkwindow.c:718 msgid "Whether mnemonics are currently visible in this window" msgstr "Indica si los mnemónicos son visibles actualmente en esta ventana" -#: ../gtk/gtkwindow.c:733 +#: ../gtk/gtkwindow.c:734 msgid "Name of the themed icon for this window" msgstr "Nombre del icono del tema para esta ventana" -#: ../gtk/gtkwindow.c:748 +#: ../gtk/gtkwindow.c:749 msgid "Is Active" msgstr "Está activo" -#: ../gtk/gtkwindow.c:749 +#: ../gtk/gtkwindow.c:750 msgid "Whether the toplevel is the current active window" msgstr "Indica si el nivel superior es la ventana activa actual" -#: ../gtk/gtkwindow.c:756 +#: ../gtk/gtkwindow.c:757 msgid "Focus in Toplevel" msgstr "Foco en el nivel superior" -#: ../gtk/gtkwindow.c:757 +#: ../gtk/gtkwindow.c:758 msgid "Whether the input focus is within this GtkWindow" msgstr "Indica si el foco de entrada esta dentro de este GtkWindow" -#: ../gtk/gtkwindow.c:764 +#: ../gtk/gtkwindow.c:765 msgid "Type hint" msgstr "Pista de tipo" -#: ../gtk/gtkwindow.c:765 +#: ../gtk/gtkwindow.c:766 msgid "" "Hint to help the desktop environment understand what kind of window this is " "and how to treat it." @@ -7410,118 +7398,145 @@ msgstr "" "Pista para ayudar al entorno de escritorio a entender qué clase de ventana " "es ésta y cómo tratar con ella." -#: ../gtk/gtkwindow.c:773 +#: ../gtk/gtkwindow.c:774 msgid "Skip taskbar" msgstr "Ignorar barra de tareas" -#: ../gtk/gtkwindow.c:774 +#: ../gtk/gtkwindow.c:775 msgid "TRUE if the window should not be in the task bar." msgstr "TRUE si la ventana no debe estar en la barra de tareas." -#: ../gtk/gtkwindow.c:781 +#: ../gtk/gtkwindow.c:782 msgid "Skip pager" msgstr "Ignorar paginador" -#: ../gtk/gtkwindow.c:782 +#: ../gtk/gtkwindow.c:783 msgid "TRUE if the window should not be in the pager." msgstr "TRUE si la ventana no debe estar en el paginador." -#: ../gtk/gtkwindow.c:789 +#: ../gtk/gtkwindow.c:790 msgid "Urgent" msgstr "Urgente" -#: ../gtk/gtkwindow.c:790 +#: ../gtk/gtkwindow.c:791 msgid "TRUE if the window should be brought to the user's attention." msgstr "TRUE si la ventana debe llamar la atención del usuario." -#: ../gtk/gtkwindow.c:804 +#: ../gtk/gtkwindow.c:805 msgid "Accept focus" msgstr "Aceptar foco" -#: ../gtk/gtkwindow.c:805 +#: ../gtk/gtkwindow.c:806 msgid "TRUE if the window should receive the input focus." msgstr "TRUE si la ventana no debe recibir el foco de entrada." -#: ../gtk/gtkwindow.c:819 +#: ../gtk/gtkwindow.c:820 msgid "Focus on map" msgstr "Foco en el mapa" -#: ../gtk/gtkwindow.c:820 +#: ../gtk/gtkwindow.c:821 msgid "TRUE if the window should receive the input focus when mapped." msgstr "TRUE si la ventana debe recibir el foco de entrada al ser mapeada." -#: ../gtk/gtkwindow.c:834 +#: ../gtk/gtkwindow.c:835 msgid "Decorated" msgstr "Decorado" -#: ../gtk/gtkwindow.c:835 +#: ../gtk/gtkwindow.c:836 msgid "Whether the window should be decorated by the window manager" msgstr "Indica si la ventana debe ser decorada por el gestor de ventanas" -#: ../gtk/gtkwindow.c:849 +#: ../gtk/gtkwindow.c:850 msgid "Deletable" msgstr "Borrable" -#: ../gtk/gtkwindow.c:850 +#: ../gtk/gtkwindow.c:851 msgid "Whether the window frame should have a close button" msgstr "Indica si el marco de la ventana debe tener un botón de cierre" -#: ../gtk/gtkwindow.c:869 +#: ../gtk/gtkwindow.c:870 msgid "Resize grip" msgstr "Redimensionar tirador" -#: ../gtk/gtkwindow.c:870 +#: ../gtk/gtkwindow.c:871 msgid "Specifies whether the window should have a resize grip" msgstr "Especifica si la ventana debe tener un tirador de redimensión" -#: ../gtk/gtkwindow.c:884 +#: ../gtk/gtkwindow.c:885 msgid "Resize grip is visible" msgstr "El tirador de redimensión es visible" -#: ../gtk/gtkwindow.c:885 +#: ../gtk/gtkwindow.c:886 msgid "Specifies whether the window's resize grip is visible." msgstr "Indica si el tirador de redimensión de la ventana es visible." -#: ../gtk/gtkwindow.c:901 +#: ../gtk/gtkwindow.c:902 msgid "Gravity" msgstr "Gravedad" -#: ../gtk/gtkwindow.c:902 +#: ../gtk/gtkwindow.c:903 msgid "The window gravity of the window" msgstr "La gravedad de la ventana" -#: ../gtk/gtkwindow.c:919 +#: ../gtk/gtkwindow.c:920 msgid "Transient for Window" msgstr "Transitorio para la ventana" -#: ../gtk/gtkwindow.c:920 +#: ../gtk/gtkwindow.c:921 msgid "The transient parent of the dialog" msgstr "El padre transitorio del diálogo" -#: ../gtk/gtkwindow.c:935 +#: ../gtk/gtkwindow.c:936 msgid "Opacity for Window" msgstr "Opacidad para la ventana" -#: ../gtk/gtkwindow.c:936 +#: ../gtk/gtkwindow.c:937 msgid "The opacity of the window, from 0 to 1" msgstr "La opacidad de la ventana, desde 0 hasta 1" -#: ../gtk/gtkwindow.c:946 ../gtk/gtkwindow.c:947 +#: ../gtk/gtkwindow.c:947 ../gtk/gtkwindow.c:948 msgid "Width of resize grip" msgstr "Anchura del tirador de redimensión" -#: ../gtk/gtkwindow.c:952 ../gtk/gtkwindow.c:953 +#: ../gtk/gtkwindow.c:953 ../gtk/gtkwindow.c:954 msgid "Height of resize grip" msgstr "Altura del tirador de redimensión" -#: ../gtk/gtkwindow.c:972 +#: ../gtk/gtkwindow.c:973 msgid "GtkApplication" msgstr "GtkApplication" -#: ../gtk/gtkwindow.c:973 +#: ../gtk/gtkwindow.c:974 msgid "The GtkApplication for the window" msgstr "El GtkApplication para la ventana" +#~ msgid "Lower" +#~ msgstr "Inferior" + +#~ msgid "Lower limit of ruler" +#~ msgstr "Límite inferior de la regla" + +#~ msgid "Upper" +#~ msgstr "Superior" + +#~ msgid "Upper limit of ruler" +#~ msgstr "Límite superior de la regla" + +#~ msgid "Position of mark on the ruler" +#~ msgstr "Posición de la etiqueta en la regla" + +#~ msgid "Max Size" +#~ msgstr "Tamaño máximo" + +#~ msgid "Maximum size of the ruler" +#~ msgstr "Tamaño máximo de la regla" + +#~ msgid "Metric" +#~ msgstr "Métrica" + +#~ msgid "The metric used for the ruler" +#~ msgstr "La métrica de la regla" + #~ msgid "Horizontal adjustment" #~ msgstr "Ajuste horizontal" From cf51750bf4b370a180b6273bd99781956165769d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 00:08:25 +0200 Subject: [PATCH 004/634] API: x11: gdk_drawable_get_xid => gdk_window_get_xid Also moves the function implementations to gtkwindow-x11.c. --- docs/reference/gdk/gdk3-sections.txt | 2 +- .../gtk/migrating-ClientSideWindows.sgml | 2 +- docs/tools/shooter.c | 2 +- gdk/gdk.symbols | 2 +- gdk/gdkwindow.c | 2 +- gdk/x11/gdkdrawable-x11.c | 46 ------------------- gdk/x11/gdkwindow-x11.c | 37 +++++++++++++++ gdk/x11/gdkx.h | 8 ++-- 8 files changed, 46 insertions(+), 55 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 40bcaaf67d..811266acd4 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -1007,7 +1007,7 @@ gdk_x11_display_error_trap_pop_ignored gdk_x11_display_set_cursor_theme gdk_x11_register_standard_event_type gdk_x11_drawable_get_xdisplay -gdk_x11_drawable_get_xid +gdk_x11_window_get_xid gdk_x11_get_default_root_xwindow gdk_x11_get_default_screen gdk_x11_get_default_xdisplay diff --git a/docs/reference/gtk/migrating-ClientSideWindows.sgml b/docs/reference/gtk/migrating-ClientSideWindows.sgml index 845e9561b2..54e0620f1b 100644 --- a/docs/reference/gtk/migrating-ClientSideWindows.sgml +++ b/docs/reference/gtk/migrating-ClientSideWindows.sgml @@ -13,7 +13,7 @@ longer correct to assume that each window has an associated XID. Code that makes this assumption can sometimes be fixed by calling gdk_window_ensure_native() on the windows in question. - Calling gdk_x11_drawable_get_xid() (or GDK_WINDOW_XID()) from the + Calling gdk_x11_window_get_xid() (or GDK_WINDOW_XID()) from the X11-specific API on a non-native window will explicitly call gdk_window_ensure_native(), so old code using this will continue to work. A small gotcha is that the GDK_WINDOW_XID() call is no longer a diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c index 873609d972..f9492f62e1 100644 --- a/docs/tools/shooter.c +++ b/docs/tools/shooter.c @@ -224,7 +224,7 @@ int main (int argc, char **argv) gtk_main_iteration (); } - id = gdk_x11_drawable_get_xid (GDK_DRAWABLE (window)); + id = gdk_x11_window_get_xid (window); screenshot = take_window_shot (id, info->include_decorations); filename = g_strdup_printf ("./%s.png", info->name); gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL); diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 557e7aebf0..2dbeaccb54 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -548,7 +548,6 @@ gdk_x11_display_set_cursor_theme gdk_x11_display_set_startup_notification_id gdk_x11_display_ungrab gdk_x11_drawable_get_xdisplay -gdk_x11_drawable_get_xid gdk_x11_get_default_root_xwindow gdk_x11_get_default_screen gdk_x11_get_default_xdisplay @@ -569,6 +568,7 @@ gdk_x11_screen_supports_net_wm_hint gdk_x11_ungrab_server gdk_x11_visual_get_xvisual gdk_x11_window_get_drawable_impl +gdk_x11_window_get_xid gdk_x11_window_move_to_current_desktop gdk_x11_window_set_user_time gdk_x11_xatom_to_atom diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index dca9df1fd3..01c5749e7a 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -9606,7 +9606,7 @@ gdk_window_print (GdkWindowObject *window, if (gdk_window_has_impl (window)) { #ifdef GDK_WINDOWING_X11 - g_print (" impl(0x%lx)", gdk_x11_drawable_get_xid (GDK_DRAWABLE (window))); + g_print (" impl(0x%lx)", gdk_x11_window_get_xid (window)); #endif } diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index a35a54b40e..9d00d02e80 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -134,52 +134,6 @@ gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable) return GDK_SCREEN_XDISPLAY (GDK_DRAWABLE_IMPL_X11 (get_impl_drawable (drawable))->screen); } -/** - * gdk_x11_drawable_get_xid: - * @drawable: a #GdkDrawable. - * - * Returns the X resource (window) belonging to a #GdkDrawable. - * - * Return value: the ID of @drawable's X resource. - **/ -XID -gdk_x11_drawable_get_xid (GdkDrawable *drawable) -{ - GdkDrawable *impl; - - if (GDK_IS_WINDOW (drawable)) - { - GdkWindow *window = (GdkWindow *)drawable; - - /* Try to ensure the window has a native window */ - if (!_gdk_window_has_impl (window)) - { - gdk_window_ensure_native (window); - - /* We sync here to ensure the window is created in the Xserver when - * this function returns. This is required because the returned XID - * for this window must be valid immediately, even with another - * connection to the Xserver */ - gdk_display_sync (gdk_window_get_display (window)); - } - - if (!GDK_WINDOW_IS_X11 (window)) - { - g_warning (G_STRLOC " drawable is not a native X11 window"); - return None; - } - - impl = ((GdkWindowObject *)drawable)->impl; - } - else - { - g_warning (G_STRLOC " drawable is not a window"); - return None; - } - - return ((GdkDrawableImplX11 *)impl)->xid; -} - GdkDrawable * gdk_x11_window_get_drawable_impl (GdkWindow *window) { diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index ec9071077e..ff32fabbfc 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -5584,3 +5584,40 @@ gdk_x11_get_server_time (GdkWindow *window) return xevent.xproperty.time; } + +/** + * gdk_x11_window_get_xid: + * @window: a native #GdkWindow. + * + * Returns the X resource (window) belonging to a #GdkWindow. + * + * Return value: the ID of @drawable's X resource. + **/ +XID +gdk_x11_window_get_xid (GdkWindow *window) +{ + GdkDrawable *impl; + + /* Try to ensure the window has a native window */ + if (!_gdk_window_has_impl (window)) + { + gdk_window_ensure_native (window); + + /* We sync here to ensure the window is created in the Xserver when + * this function returns. This is required because the returned XID + * for this window must be valid immediately, even with another + * connection to the Xserver */ + gdk_display_sync (gdk_window_get_display (window)); + } + + if (!GDK_WINDOW_IS_X11 (window)) + { + g_warning (G_STRLOC " drawable is not a native X11 window"); + return None; + } + + impl = ((GdkWindowObject *) window)->impl; + + return ((GdkDrawableImplX11 *)impl)->xid; +} + diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 7fc0227348..bde14d56cb 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -56,7 +56,7 @@ G_BEGIN_DECLS Display *gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable); -XID gdk_x11_drawable_get_xid (GdkDrawable *drawable); +Window gdk_x11_window_get_xid (GdkWindow *window); GdkDrawable *gdk_x11_window_get_drawable_impl (GdkWindow *window); Display *gdk_x11_cursor_get_xdisplay (GdkCursor *cursor); Cursor gdk_x11_cursor_get_xcursor (GdkCursor *cursor); @@ -186,16 +186,16 @@ gint gdk_x11_get_default_screen (void); * * Returns: the Xlib Window of @win. */ -#define GDK_WINDOW_XID(win) (gdk_x11_drawable_get_xid (win)) +#define GDK_WINDOW_XID(win) (gdk_x11_window_get_xid (win)) /** * GDK_WINDOW_XWINDOW: * * Another name for GDK_DRAWABLE_XID(). */ -#define GDK_WINDOW_XWINDOW(win) (gdk_x11_drawable_get_xid (win)) +#define GDK_WINDOW_XWINDOW(win) (gdk_x11_window_get_xid (win)) #define GDK_DRAWABLE_XDISPLAY(win) (gdk_x11_drawable_get_xdisplay (win)) -#define GDK_DRAWABLE_XID(win) (gdk_x11_drawable_get_xid (win)) +#define GDK_DRAWABLE_XID(win) (gdk_x11_window_get_xid (win)) #define GDK_SCREEN_XDISPLAY(screen) (gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen))) #define GDK_SCREEN_XSCREEN(screen) (gdk_x11_screen_get_xscreen (screen)) From deffc9e39f19363d8700bcd29c8dedfa8e75256b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 00:13:49 +0200 Subject: [PATCH 005/634] API: x11: Change GDK_WINDOW_XDISPLAY() macro Instead of lots of magic, we can go the usual way of requesting the XDisplay of the window's display. So we do that. --- gdk/x11/gdkx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index bde14d56cb..bc155ff65f 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -176,7 +176,7 @@ gint gdk_x11_get_default_screen (void); #define GDK_DISPLAY_XDISPLAY(display) (gdk_x11_display_get_xdisplay (display)) -#define GDK_WINDOW_XDISPLAY(win) (gdk_x11_drawable_get_xdisplay (gdk_x11_window_get_drawable_impl (win))) +#define GDK_WINDOW_XDISPLAY(win) (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (win))) /** * GDK_WINDOW_XID: From 3af4432c6f9771f132bddab4ca9bca56d3d1036a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 00:19:36 +0200 Subject: [PATCH 006/634] API: x11: Remove gdk_x11_window_get_drawable_impl() It's not used anymore --- docs/reference/gdk/gdk3-sections.txt | 1 - gdk/gdk.symbols | 1 - gdk/x11/gdkdrawable-x11.c | 6 ------ gdk/x11/gdkdrawable-x11.h | 1 - gdk/x11/gdkx.h | 1 - 5 files changed, 10 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 811266acd4..6ead743311 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -1028,7 +1028,6 @@ gdk_x11_get_xatom_name_for_display GDK_HAVE_WCHAR_H GDK_HAVE_WCTYPE_H -gdk_x11_window_get_drawable_impl
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 2dbeaccb54..5a9a41e3d2 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -567,7 +567,6 @@ gdk_x11_screen_lookup_visual gdk_x11_screen_supports_net_wm_hint gdk_x11_ungrab_server gdk_x11_visual_get_xvisual -gdk_x11_window_get_drawable_impl gdk_x11_window_get_xid gdk_x11_window_move_to_current_desktop gdk_x11_window_set_user_time diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 9d00d02e80..2447097812 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -134,12 +134,6 @@ gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable) return GDK_SCREEN_XDISPLAY (GDK_DRAWABLE_IMPL_X11 (get_impl_drawable (drawable))->screen); } -GdkDrawable * -gdk_x11_window_get_drawable_impl (GdkWindow *window) -{ - return ((GdkWindowObject *)window)->impl; -} - static void gdk_x11_cairo_surface_destroy (void *data) { diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h index e197766cba..284bba7eaf 100644 --- a/gdk/x11/gdkdrawable-x11.h +++ b/gdk/x11/gdkdrawable-x11.h @@ -68,7 +68,6 @@ GType _gdk_drawable_impl_x11_get_type (void); /* Note that the following take GdkDrawableImplX11, not the wrapper drawable */ void _gdk_x11_drawable_finish (GdkDrawable *drawable); void _gdk_x11_drawable_update_size (GdkDrawable *drawable); -GdkDrawable *gdk_x11_window_get_drawable_impl (GdkWindow *window); G_END_DECLS diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index bc155ff65f..1d5c850a5c 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -57,7 +57,6 @@ G_BEGIN_DECLS Display *gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable); Window gdk_x11_window_get_xid (GdkWindow *window); -GdkDrawable *gdk_x11_window_get_drawable_impl (GdkWindow *window); Display *gdk_x11_cursor_get_xdisplay (GdkCursor *cursor); Cursor gdk_x11_cursor_get_xcursor (GdkCursor *cursor); Display *gdk_x11_display_get_xdisplay (GdkDisplay *display); From 28ba4c21464d31486be4c51073ba1eda56f54dee Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 00:56:22 +0200 Subject: [PATCH 007/634] im-xim: Use window macros instead of drawable macros --- modules/input/gtkimcontextxim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c index c9de4207c6..035edc3a00 100644 --- a/modules/input/gtkimcontextxim.c +++ b/modules/input/gtkimcontextxim.c @@ -707,9 +707,9 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context, xevent.type = (event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease; xevent.serial = 0; /* hope it doesn't matter */ xevent.send_event = event->send_event; - xevent.display = GDK_DRAWABLE_XDISPLAY (event->window); - xevent.window = GDK_DRAWABLE_XID (event->window); - xevent.root = GDK_DRAWABLE_XID (root_window); + xevent.display = GDK_WINDOW_XDISPLAY (event->window); + xevent.window = GDK_WINDOW_XID (event->window); + xevent.root = GDK_WINDOW_XID (root_window); xevent.subwindow = xevent.window; xevent.time = event->time; xevent.x = xevent.x_root = 0; @@ -718,7 +718,7 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context, xevent.keycode = event->hardware_keycode; xevent.same_screen = True; - if (XFilterEvent ((XEvent *)&xevent, GDK_DRAWABLE_XID (context_xim->client_window))) + if (XFilterEvent ((XEvent *)&xevent, GDK_WINDOW_XID (context_xim->client_window))) return TRUE; if (event->state & @@ -1434,7 +1434,7 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim) xic = XCreateIC (context_xim->im_info->im, XNInputStyle, im_style, - XNClientWindow, GDK_DRAWABLE_XID (context_xim->client_window), + XNClientWindow, GDK_WINDOW_XID (context_xim->client_window), name1, list1, name2, list2, NULL); From 0841281b5554579ca6d6529ace20a8ab88b05e0b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:05:19 +0200 Subject: [PATCH 008/634] x11: Use window macros in test code --- gdk/x11/gdktestutils-x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/x11/gdktestutils-x11.c b/gdk/x11/gdktestutils-x11.c index d4d47fbad7..cfb38ebc53 100644 --- a/gdk/x11/gdktestutils-x11.c +++ b/gdk/x11/gdktestutils-x11.c @@ -41,7 +41,7 @@ void gdk_test_render_sync (GdkWindow *window) { - Display *display = gdk_x11_drawable_get_xdisplay (window); + Display *display = GDK_WINDOW_XDISPLAY (window); XImage *ximage; /* syncronize to X drawing queue, see: From 91679c384a10512ef6b02f5d9763687169e2da94 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:14:32 +0200 Subject: [PATCH 009/634] API: Remove gdk_x11_drawable_get_xdisplay() No need for the function. Macros exist to do the same thing. --- docs/reference/gdk/gdk3-sections.txt | 1 - gdk/gdk.symbols | 1 - gdk/x11/gdkdrawable-x11.c | 29 ---------------------------- gdk/x11/gdkx.h | 3 +-- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 6ead743311..596d7220eb 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -1006,7 +1006,6 @@ gdk_x11_display_error_trap_pop gdk_x11_display_error_trap_pop_ignored gdk_x11_display_set_cursor_theme gdk_x11_register_standard_event_type -gdk_x11_drawable_get_xdisplay gdk_x11_window_get_xid gdk_x11_get_default_root_xwindow gdk_x11_get_default_screen diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 5a9a41e3d2..abc2f592a2 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -547,7 +547,6 @@ gdk_x11_display_grab gdk_x11_display_set_cursor_theme gdk_x11_display_set_startup_notification_id gdk_x11_display_ungrab -gdk_x11_drawable_get_xdisplay gdk_x11_get_default_root_xwindow gdk_x11_get_default_screen gdk_x11_get_default_xdisplay diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 2447097812..f00706b660 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -105,35 +105,6 @@ _gdk_x11_drawable_update_size (GdkDrawable *drawable) * X11 specific implementations of generic functions * *****************************************************/ -static GdkDrawable * -get_impl_drawable (GdkDrawable *drawable) -{ - if (GDK_IS_WINDOW (drawable)) - return ((GdkWindowObject *)drawable)->impl; - else - { - g_warning (G_STRLOC " drawable is not a window"); - return NULL; - } -} - -/** - * gdk_x11_drawable_get_xdisplay: - * @drawable: a #GdkDrawable. - * - * Returns the display of a #GdkDrawable. - * - * Return value: an Xlib Display*. - **/ -Display * -gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable) -{ - if (GDK_IS_DRAWABLE_IMPL_X11 (drawable)) - return GDK_SCREEN_XDISPLAY (GDK_DRAWABLE_IMPL_X11 (drawable)->screen); - else - return GDK_SCREEN_XDISPLAY (GDK_DRAWABLE_IMPL_X11 (get_impl_drawable (drawable))->screen); -} - static void gdk_x11_cairo_surface_destroy (void *data) { diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 1d5c850a5c..885d5d4ff6 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -55,7 +55,6 @@ G_BEGIN_DECLS */ -Display *gdk_x11_drawable_get_xdisplay (GdkDrawable *drawable); Window gdk_x11_window_get_xid (GdkWindow *window); Display *gdk_x11_cursor_get_xdisplay (GdkCursor *cursor); Cursor gdk_x11_cursor_get_xcursor (GdkCursor *cursor); @@ -193,7 +192,7 @@ gint gdk_x11_get_default_screen (void); * Another name for GDK_DRAWABLE_XID(). */ #define GDK_WINDOW_XWINDOW(win) (gdk_x11_window_get_xid (win)) -#define GDK_DRAWABLE_XDISPLAY(win) (gdk_x11_drawable_get_xdisplay (win)) +#define GDK_DRAWABLE_XDISPLAY(win) (GDK_WINDOW_XDISPLAY (win)) #define GDK_DRAWABLE_XID(win) (gdk_x11_window_get_xid (win)) #define GDK_SCREEN_XDISPLAY(screen) (gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen))) #define GDK_SCREEN_XSCREEN(screen) (gdk_x11_screen_get_xscreen (screen)) From 3b8aea389da311b5b6d4675c61778a19394a9cb2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:22:45 +0200 Subject: [PATCH 010/634] x11: Use window macros instead of drawable macros GDK_WINDOW_XID() instead of GDK_DRAWABLE_XID() GDK_WINDOW_XDISPLAY() instead of GDK_DRAWABLE_XDISPLAY() --- gdk/x11/gdkdevice-core.c | 4 +- gdk/x11/gdkdisplay-x11.c | 4 +- gdk/x11/gdkdnd-x11.c | 118 ++++++++++++++++++------------------- gdk/x11/gdkselection-x11.c | 6 +- gdk/x11/gdktestutils-x11.c | 4 +- gdk/x11/gdkwindow-x11.c | 4 +- 6 files changed, 70 insertions(+), 70 deletions(-) diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c index a399713b55..a674aac654 100644 --- a/gdk/x11/gdkdevice-core.c +++ b/gdk/x11/gdkdevice-core.c @@ -133,8 +133,8 @@ gdk_device_core_get_history (GdkDevice *device, int i, j; impl_window = _gdk_window_get_impl_window (window); - xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (impl_window), + xcoords = XGetMotionEvents (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (impl_window), start, stop, &tmp_n_events); if (!xcoords) return FALSE; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 0ced13753b..2a2f8cb380 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -726,8 +726,8 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, Window child_window = 0; gdk_error_trap_push (); - if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), + if (XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), screen_x11->xroot_window, 0, 0, &tx, &ty, diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index e4d8cffc91..8927d5ef81 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -294,12 +294,12 @@ gdk_drag_context_find (GdkDisplay *display, context_dest_xid = context->dest_window ? (private->drop_xid ? private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window)) : + GDK_WINDOW_XID (context->dest_window)) : None; if ((!context->is_source == !is_source) && ((source_xid == None) || (context->source_window && - (GDK_DRAWABLE_XID (context->source_window) == source_xid))) && + (GDK_WINDOW_XID (context->source_window) == source_xid))) && ((dest_xid == None) || (context_dest_xid == dest_xid))) return context; @@ -1405,8 +1405,8 @@ motif_set_targets (GdkDragContext *context) info.selection_atom = private->motif_selection; - XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), - GDK_DRAWABLE_XID (context->source_window), + XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window), + GDK_WINDOW_XID (context->source_window), private->motif_selection, gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_INITIATOR_INFO"), 8, PropModeReplace, @@ -1475,13 +1475,13 @@ motif_send_enter (GdkDragContext *context, xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; - xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.window = GDK_WINDOW_XID (context->dest_window); MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER; MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order; MOTIF_XCLIENT_SHORT (&xev, 1) = 0; MOTIF_XCLIENT_LONG (&xev, 1) = time; - MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window); + MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XID (context->source_window); if (!private->motif_targets_set) motif_set_targets (context); @@ -1490,11 +1490,11 @@ motif_send_enter (GdkDragContext *context, MOTIF_XCLIENT_LONG (&xev, 4) = 0; if (!_gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->dest_window), + GDK_WINDOW_XID (context->dest_window), FALSE, 0, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); } static void @@ -1507,7 +1507,7 @@ motif_send_leave (GdkDragContext *context, xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; - xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.window = GDK_WINDOW_XID (context->dest_window); MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE; MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order; @@ -1518,11 +1518,11 @@ motif_send_leave (GdkDragContext *context, MOTIF_XCLIENT_LONG (&xev, 4) = 0; if (!_gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->dest_window), + GDK_WINDOW_XID (context->dest_window), FALSE, 0, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); } static gboolean @@ -1540,7 +1540,7 @@ motif_send_motion (GdkDragContext *context, xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; - xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.window = GDK_WINDOW_XID (context->dest_window); MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order; MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context); @@ -1568,11 +1568,11 @@ motif_send_motion (GdkDragContext *context, } if (!_gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->dest_window), + GDK_WINDOW_XID (context->dest_window), FALSE, 0, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); return retval; } @@ -1587,7 +1587,7 @@ motif_send_drop (GdkDragContext *context, guint32 time) xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; - xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.window = GDK_WINDOW_XID (context->dest_window); MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START; MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order; @@ -1598,14 +1598,14 @@ motif_send_drop (GdkDragContext *context, guint32 time) MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y; MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection; - MOTIF_XCLIENT_LONG (&xev, 4) = GDK_DRAWABLE_XID (context->source_window); + MOTIF_XCLIENT_LONG (&xev, 4) = GDK_WINDOW_XID (context->source_window); if (!_gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->dest_window), + GDK_WINDOW_XID (context->dest_window), FALSE, 0, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); } /* Target Side */ @@ -1924,7 +1924,7 @@ motif_drag_status (GdkEvent *event, if (!display) return GDK_FILTER_REMOVE; - context = gdk_drag_context_find (display, TRUE, GDK_DRAWABLE_XID (event->any.window), None); + context = gdk_drag_context_find (display, TRUE, GDK_WINDOW_XID (event->any.window), None); if (context) { @@ -2228,8 +2228,8 @@ xdnd_set_targets (GdkDragContext *context) i++; } - XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), - GDK_DRAWABLE_XID (context->source_window), + XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window), + GDK_WINDOW_XID (context->source_window), gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); @@ -2277,8 +2277,8 @@ xdnd_set_actions (GdkDragContext *context) } } - XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), - GDK_DRAWABLE_XID (context->source_window), + XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window), + GDK_WINDOW_XID (context->source_window), gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); @@ -2422,8 +2422,8 @@ xdnd_send_enter (GdkDragContext *context) xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window); + GDK_WINDOW_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window); xev.xclient.data.l[1] = (private->version << 24); /* version */ xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; @@ -2431,7 +2431,7 @@ xdnd_send_enter (GdkDragContext *context) GDK_NOTE(DND, g_message ("Sending enter source window %#lx XDND protocol version %d\n", - GDK_DRAWABLE_XID (context->source_window), private->version)); + GDK_WINDOW_XID (context->source_window), private->version)); if (g_list_length (context->targets) > 3) { if (!private->xdnd_targets_set) @@ -2457,7 +2457,7 @@ xdnd_send_enter (GdkDragContext *context) { GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); g_object_unref (context->dest_window); context->dest_window = NULL; } @@ -2476,8 +2476,8 @@ xdnd_send_leave (GdkDragContext *context) xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window); + GDK_WINDOW_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; @@ -2488,7 +2488,7 @@ xdnd_send_leave (GdkDragContext *context) { GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); g_object_unref (context->dest_window); context->dest_window = NULL; } @@ -2506,8 +2506,8 @@ xdnd_send_drop (GdkDragContext *context, guint32 time) xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window); + GDK_WINDOW_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = time; xev.xclient.data.l[3] = 0; @@ -2518,7 +2518,7 @@ xdnd_send_drop (GdkDragContext *context, guint32 time) { GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); g_object_unref (context->dest_window); context->dest_window = NULL; } @@ -2540,8 +2540,8 @@ xdnd_send_motion (GdkDragContext *context, xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : - GDK_DRAWABLE_XID (context->dest_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window); + GDK_WINDOW_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = (x_root << 16) | y_root; xev.xclient.data.l[3] = time; @@ -2552,7 +2552,7 @@ xdnd_send_motion (GdkDragContext *context, { GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->dest_window))); + GDK_WINDOW_XID (context->dest_window))); g_object_unref (context->dest_window); context->dest_window = NULL; } @@ -2654,7 +2654,7 @@ xdnd_read_actions (GdkDragContext *context) gdk_error_trap_push (); if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_DRAWABLE_XID (context->source_window), + GDK_WINDOW_XID (context->source_window), gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"), 0, 65536, False, XA_ATOM, &type, &format, &nitems, @@ -2702,8 +2702,8 @@ xdnd_read_actions (GdkDragContext *context) GdkDragContext *source_context; source_context = gdk_drag_context_find (display, TRUE, - GDK_DRAWABLE_XID (context->source_window), - GDK_DRAWABLE_XID (context->dest_window)); + GDK_WINDOW_XID (context->source_window), + GDK_WINDOW_XID (context->dest_window)); if (source_context) { @@ -2903,7 +2903,7 @@ xdnd_enter_filter (GdkXEvent *xev, if (get_types) { gdk_error_trap_push (); - XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window), + XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window), source_window, gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"), 0, 65536, @@ -2983,7 +2983,7 @@ xdnd_leave_filter (GdkXEvent *xev, if ((display_x11->current_dest_drag != NULL) && (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) && - (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window)) + (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window)) { event->dnd.type = GDK_DRAG_LEAVE; /* Pass ownership of context to the event */ @@ -3028,7 +3028,7 @@ xdnd_position_filter (GdkXEvent *xev, if ((display_x11->current_dest_drag != NULL) && (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) && - (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window)) + (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window)) { event->dnd.type = GDK_DRAG_MOTION; event->dnd.context = display_x11->current_dest_drag; @@ -3080,7 +3080,7 @@ xdnd_drop_filter (GdkXEvent *xev, if ((display_x11->current_dest_drag != NULL) && (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) && - (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window)) + (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window)) { GdkDragContextPrivateX11 *private; private = PRIVATE_DATA (display_x11->current_dest_drag); @@ -3386,7 +3386,7 @@ gdk_drag_find_window_for_screen (GdkDragContext *context, dest = get_client_window_at_coords (window_cache, drag_window && GDK_WINDOW_IS_X11 (drag_window) ? - GDK_DRAWABLE_XID (drag_window) : None, + GDK_WINDOW_XID (drag_window) : None, x_root, y_root); if (private->dest_xid != dest) @@ -3478,7 +3478,7 @@ gdk_drag_motion (GdkDragContext *context, GdkDisplay *display = GDK_WINDOW_DISPLAY (dest_window); xdnd_check_dest (display, - GDK_DRAWABLE_XID (dest_window), + GDK_WINDOW_XID (dest_window), &private->version); } } @@ -3498,8 +3498,8 @@ gdk_drag_motion (GdkDragContext *context, GdkDragContext *dest_context; dest_context = gdk_drag_context_find (display, FALSE, - GDK_DRAWABLE_XID (context->source_window), - GDK_DRAWABLE_XID (dest_window)); + GDK_WINDOW_XID (context->source_window), + GDK_WINDOW_XID (dest_window)); if (dest_context) { @@ -3733,7 +3733,7 @@ gdk_drag_status (GdkDragContext *context, xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; - xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); + xev.xclient.window = GDK_WINDOW_XID (context->source_window); if (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT) { @@ -3795,20 +3795,20 @@ gdk_drag_status (GdkDragContext *context, MOTIF_XCLIENT_LONG (&xev, 4) = 0; if (!_gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->source_window), + GDK_WINDOW_XID (context->source_window), FALSE, 0, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->source_window))); + GDK_WINDOW_XID (context->source_window))); } else if (context->protocol == GDK_DRAG_PROTO_XDND) { xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus"); xev.xclient.format = 32; - xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); + xev.xclient.window = GDK_WINDOW_XID (context->source_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->dest_window); xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; @@ -3818,7 +3818,7 @@ gdk_drag_status (GdkDragContext *context, FALSE, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->source_window))); + GDK_WINDOW_XID (context->source_window))); } private->old_action = action; @@ -3875,7 +3875,7 @@ gdk_drop_reply (GdkDragContext *context, MOTIF_XCLIENT_LONG (&xev, 4) = 0; _gdk_send_xevent (display, - GDK_DRAWABLE_XID (context->source_window), + GDK_WINDOW_XID (context->source_window), FALSE, 0, &xev); } } @@ -3905,9 +3905,9 @@ gdk_drop_finish (GdkDragContext *context, xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndFinished"); xev.xclient.format = 32; - xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); + xev.xclient.window = GDK_WINDOW_XID (context->source_window); - xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window); + xev.xclient.data.l[0] = GDK_WINDOW_XID (context->dest_window); if (success) { xev.xclient.data.l[1] = 1; @@ -3926,7 +3926,7 @@ gdk_drop_finish (GdkDragContext *context, FALSE, &xev)) GDK_NOTE (DND, g_message ("Send event to %lx failed", - GDK_DRAWABLE_XID (context->source_window))); + GDK_WINDOW_XID (context->source_window))); } } @@ -3970,7 +3970,7 @@ gdk_window_register_dnd (GdkWindow *window) info.num_drop_sites = 0; info.total_size = sizeof(info); - XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_DRAWABLE_XID (window), + XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), motif_drag_receiver_info_atom, motif_drag_receiver_info_atom, 8, PropModeReplace, @@ -3981,7 +3981,7 @@ gdk_window_register_dnd (GdkWindow *window) /* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */ XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_DRAWABLE_XID (window), + GDK_WINDOW_XID (window), gdk_x11_get_xatom_by_name_for_display (display, "XdndAware"), XA_ATOM, 32, PropModeReplace, (guchar *)&xdnd_version, 1); diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 41be49ed93..00390aa34f 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -88,7 +88,7 @@ _gdk_selection_filter_clear_event (XSelectionClearEvent *event) if (gdk_window_get_display (info->owner) == display && info->selection == gdk_x11_xatom_to_atom_for_display (display, event->selection)) { - if ((GDK_DRAWABLE_XID (info->owner) == event->window && + if ((GDK_WINDOW_XID (info->owner) == event->window && event->serial >= info->serial)) { owner_list = g_slist_remove (owner_list, info); @@ -296,8 +296,8 @@ gdk_selection_property_get (GdkWindow *requestor, protocol, in which case the client has to make sure they'll be notified of PropertyChange events _before_ the property is deleted. Otherwise there's no guarantee we'll win the race ... */ - if (XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), - GDK_DRAWABLE_XID (requestor), + if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor), + GDK_WINDOW_XID (requestor), gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property), 0, 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, &prop_format, diff --git a/gdk/x11/gdktestutils-x11.c b/gdk/x11/gdktestutils-x11.c index cfb38ebc53..8de93e428f 100644 --- a/gdk/x11/gdktestutils-x11.c +++ b/gdk/x11/gdktestutils-x11.c @@ -121,7 +121,7 @@ gdk_test_simulate_key (GdkWindow *window, y = y + priv->abs_y; xev.type = key_pressrelease == GDK_KEY_PRESS ? KeyPress : KeyRelease; - xev.display = GDK_DRAWABLE_XDISPLAY (window); + xev.display = GDK_WINDOW_XDISPLAY (window); xev.window = GDK_WINDOW_XID (window); xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen)); xev.subwindow = 0; @@ -228,7 +228,7 @@ gdk_test_simulate_button (GdkWindow *window, y = y + priv->abs_y; xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease; - xev.display = GDK_DRAWABLE_XDISPLAY (window); + xev.display = GDK_WINDOW_XDISPLAY (window); xev.window = GDK_WINDOW_XID (window); xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen)); xev.subwindow = 0; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index ff32fabbfc..ef5c1c8180 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -306,8 +306,8 @@ tmp_unset_bg (GdkWindow *window) impl->no_bg = TRUE; - XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window), - GDK_DRAWABLE_XID (window), None); + XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (window), None); } static void From 5139eecc752056b2cddc6dfdbeb7f1ffc03520f3 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:24:59 +0200 Subject: [PATCH 011/634] API: x11: Remove GDK_DRAWABLE_XID and GDK_DRAWABLE_XDISPLAY Window equivalents exist and drawables are on their way out. --- gdk/x11/gdkx.h | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 885d5d4ff6..9e736e158d 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -118,35 +118,8 @@ gint gdk_x11_get_default_screen (void); */ #define GDK_WINDOW_XDISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xdisplay) #define GDK_WINDOW_XID(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) +#define GDK_WINDOW_XWINDOW(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) -/** - * GDK_DRAWABLE_XDISPLAY: - * @win: a #GdkDrawable. - * - * Returns the display of a #GdkDrawable. - * - * Returns: an Xlib Display*. - */ -#define GDK_DRAWABLE_XDISPLAY(win) (GDK_WINDOW_XDISPLAY (win)) - -/** - * GDK_DRAWABLE_XID: - * @win: a #GdkDrawable. - * - * Returns the X resource (window or pixmap) belonging to a #GdkDrawable. - * - * Returns: the ID of @win's X resource. - */ -#define GDK_DRAWABLE_XID(win) (GDK_WINDOW_XID (win)) - -/** - * GDK_SCREEN_XDISPLAY: - * @screen: a #GdkScreen. - * - * Returns the display of a #GdkScreen. - * - * Returns: an Xlib Display*. - */ #define GDK_SCREEN_XDISPLAY(screen) (GDK_SCREEN_X11 (screen)->xdisplay) /** @@ -159,7 +132,6 @@ gint gdk_x11_get_default_screen (void); */ #define GDK_SCREEN_XSCREEN(screen) (GDK_SCREEN_X11 (screen)->xscreen) #define GDK_SCREEN_XNUMBER(screen) (GDK_SCREEN_X11 (screen)->screen_num) -#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID #else /* GDK_COMPILATION */ @@ -192,8 +164,6 @@ gint gdk_x11_get_default_screen (void); * Another name for GDK_DRAWABLE_XID(). */ #define GDK_WINDOW_XWINDOW(win) (gdk_x11_window_get_xid (win)) -#define GDK_DRAWABLE_XDISPLAY(win) (GDK_WINDOW_XDISPLAY (win)) -#define GDK_DRAWABLE_XID(win) (gdk_x11_window_get_xid (win)) #define GDK_SCREEN_XDISPLAY(screen) (gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen))) #define GDK_SCREEN_XSCREEN(screen) (gdk_x11_screen_get_xscreen (screen)) From dc7d8dae6722a1219b5fde4fc03fdcc051ec4e1c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:54:00 +0200 Subject: [PATCH 012/634] x11: Change GDK_WINDOW_SCREEN macro on't look at GdkDrawableImplX11->screen, but call gdk_window_get_screen() instead. --- gdk/x11/gdkgeometry-x11.c | 2 +- gdk/x11/gdkprivate-x11.h | 2 +- gdk/x11/gdkwindow-x11.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index a4b706273f..f7e967f50e 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -308,7 +308,7 @@ _gdk_x11_window_translate (GdkWindow *window, item->u.translate.dy = dy; gdk_window_queue (window, item); - XCopyArea (GDK_WINDOW_XDISPLAY (impl), + XCopyArea (GDK_WINDOW_XDISPLAY ((GdkWindow *) impl), GDK_DRAWABLE_IMPL_X11 (private->impl)->xid, GDK_DRAWABLE_IMPL_X11 (impl->impl)->xid, xgc, diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index bfcf1e38f8..f4135424e0 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -153,7 +153,7 @@ extern gboolean _gdk_synchronize; #define GDK_DRAWABLE_XROOTWIN(win) (GDK_WINDOW_XROOTWIN (win)) #define GDK_SCREEN_DISPLAY(screen) (GDK_SCREEN_X11 (screen)->display) #define GDK_SCREEN_XROOTWIN(screen) (GDK_SCREEN_X11 (screen)->xroot_window) -#define GDK_WINDOW_SCREEN(win) (GDK_DRAWABLE_IMPL_X11 (((GdkWindowObject *)win)->impl)->screen) +#define GDK_WINDOW_SCREEN(win) (gdk_window_get_screen (win)) #define GDK_WINDOW_DISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->display) #define GDK_WINDOW_XROOTWIN(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xroot_window) #define GDK_GC_DISPLAY(gc) (GDK_SCREEN_DISPLAY (GDK_GC_X11(gc)->screen)) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index ef5c1c8180..11c8837a90 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -194,7 +194,7 @@ gdk_window_impl_x11_finalize (GObject *object) if (!GDK_WINDOW_DESTROYED (wrapper)) { - GdkDisplay *display = GDK_WINDOW_DISPLAY (wrapper); + GdkDisplay *display = GDK_WINDOW_DISPLAY ((GdkWindow *) wrapper); _gdk_xid_table_remove (display, draw_impl->xid); if (window_impl->toplevel && window_impl->toplevel->focus_window) From cfa67127a1a5539e6a34171c7a3b7e125c146734 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 01:59:21 +0200 Subject: [PATCH 013/634] x11: Get display from window, not from impl-drawable's screen --- gdk/x11/gdkdrawable-x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index f00706b660..73dbcd306c 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -122,7 +122,7 @@ gdk_x11_create_cairo_surface (GdkDrawable *drawable, GdkVisual *visual; visual = gdk_window_get_visual (impl->wrapper); - return cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (impl->screen), + return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), impl->xid, GDK_VISUAL_XVISUAL (visual), width, height); From 5f127305993289440043caf06db1ba0aa98846cb Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 02:00:16 +0200 Subject: [PATCH 014/634] x11: Get display from window, not from impl-drawable's screen --- gdk/x11/gdkwindow-x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 11c8837a90..dc6ef6dcf2 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -5467,7 +5467,7 @@ _gdk_windowing_window_set_composited (GdkWindow *window, impl = GDK_WINDOW_IMPL_X11 (private->impl); - display = gdk_screen_get_display (GDK_DRAWABLE_IMPL_X11 (impl)->screen); + display = gdk_window_get_display (window); dpy = GDK_DISPLAY_XDISPLAY (display); xid = GDK_WINDOW_XWINDOW (private); From 094b0eeb98a7cadb354299e35e41ffd3aaec61e6 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 02:01:51 +0200 Subject: [PATCH 015/634] x11: Remove screen member from GdkDrawableImplX11 --- gdk/x11/gdkdrawable-x11.h | 1 - gdk/x11/gdkwindow-x11.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h index 284bba7eaf..e4996a8548 100644 --- a/gdk/x11/gdkdrawable-x11.h +++ b/gdk/x11/gdkdrawable-x11.h @@ -52,7 +52,6 @@ struct _GdkDrawableImplX11 GdkDrawable *wrapper; Window xid; - GdkScreen *screen; cairo_surface_t *cairo_surface; }; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index dc6ef6dcf2..c6304197a2 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -439,7 +439,6 @@ _gdk_windowing_window_init (GdkScreen * screen) draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); - draw_impl->screen = screen; draw_impl->xid = screen_x11->xroot_window; draw_impl->wrapper = GDK_DRAWABLE (private); @@ -686,7 +685,6 @@ _gdk_window_impl_new (GdkWindow *window, draw_impl = GDK_DRAWABLE_IMPL_X11 (impl); draw_impl->wrapper = GDK_DRAWABLE (window); - draw_impl->screen = screen; xdisplay = screen_x11->xdisplay; xattributes_mask = 0; @@ -898,12 +896,11 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, impl = GDK_WINDOW_IMPL_X11 (private->impl); draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); draw_impl->wrapper = GDK_DRAWABLE (window); - draw_impl->screen = screen; private->parent = gdk_xid_table_lookup_for_display (display, parent); if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN) - private->parent = (GdkWindowObject *) gdk_screen_get_root_window (draw_impl->screen); + private->parent = (GdkWindowObject *) gdk_screen_get_root_window (screen); private->parent->children = g_list_prepend (private->parent->children, window); From a3c5005eefaa145bec3223bfb12162afa7851f90 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 02:14:59 +0200 Subject: [PATCH 016/634] x11: Use GDK_WINDOW_XID() instead of writing it out --- gdk/x11/gdkgeometry-x11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index f7e967f50e..a9a10efa5e 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -309,8 +309,8 @@ _gdk_x11_window_translate (GdkWindow *window, gdk_window_queue (window, item); XCopyArea (GDK_WINDOW_XDISPLAY ((GdkWindow *) impl), - GDK_DRAWABLE_IMPL_X11 (private->impl)->xid, - GDK_DRAWABLE_IMPL_X11 (impl->impl)->xid, + GDK_WINDOW_XID (private), + GDK_WINDOW_XID (impl), xgc, extents.x - dx, extents.y - dy, extents.width, extents.height, From 1c7f58fdb62039bdc49f1fe1a85048979d89d9bf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 02:15:51 +0200 Subject: [PATCH 017/634] x11: Move xid member from GdkDrawableImplX11 to GdkWindowImplX11 --- gdk/x11/gdkdrawable-x11.c | 2 +- gdk/x11/gdkdrawable-x11.h | 2 -- gdk/x11/gdkwindow-x11.c | 25 ++++++++++++------------- gdk/x11/gdkwindow-x11.h | 2 ++ gdk/x11/gdkx.h | 4 ++-- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 73dbcd306c..15808f3bf4 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -123,7 +123,7 @@ gdk_x11_create_cairo_surface (GdkDrawable *drawable, visual = gdk_window_get_visual (impl->wrapper); return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), - impl->xid, + GDK_WINDOW_IMPL_X11 (impl)->xid, GDK_VISUAL_XVISUAL (visual), width, height); } diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h index e4996a8548..70a92d787e 100644 --- a/gdk/x11/gdkdrawable-x11.h +++ b/gdk/x11/gdkdrawable-x11.h @@ -51,8 +51,6 @@ struct _GdkDrawableImplX11 GdkDrawable *wrapper; - Window xid; - cairo_surface_t *cairo_surface; }; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index c6304197a2..5d7e6532d7 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -196,7 +196,7 @@ gdk_window_impl_x11_finalize (GObject *object) { GdkDisplay *display = GDK_WINDOW_DISPLAY ((GdkWindow *) wrapper); - _gdk_xid_table_remove (display, draw_impl->xid); + _gdk_xid_table_remove (display, window_impl->xid); if (window_impl->toplevel && window_impl->toplevel->focus_window) _gdk_xid_table_remove (display, window_impl->toplevel->focus_window); } @@ -439,7 +439,7 @@ _gdk_windowing_window_init (GdkScreen * screen) draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); - draw_impl->xid = screen_x11->xroot_window; + GDK_WINDOW_IMPL_X11 (draw_impl)->xid = screen_x11->xroot_window; draw_impl->wrapper = GDK_DRAWABLE (private); private->window_type = GDK_WINDOW_ROOT; @@ -665,7 +665,6 @@ _gdk_window_impl_new (GdkWindow *window, Window xparent; Visual *xvisual; Display *xdisplay; - Window xid; XSetWindowAttributes xattributes; long xattributes_mask; @@ -765,15 +764,15 @@ _gdk_window_impl_new (GdkWindow *window, private->height = 65535; } - xid = draw_impl->xid = XCreateWindow (xdisplay, xparent, - private->x + private->parent->abs_x, - private->y + private->parent->abs_y, - private->width, private->height, - 0, private->depth, class, xvisual, - xattributes_mask, &xattributes); + impl->xid = XCreateWindow (xdisplay, xparent, + private->x + private->parent->abs_x, + private->y + private->parent->abs_y, + private->width, private->height, + 0, private->depth, class, xvisual, + xattributes_mask, &xattributes); g_object_ref (window); - _gdk_xid_table_insert (screen_x11->display, &draw_impl->xid, window); + _gdk_xid_table_insert (screen_x11->display, &impl->xid, window); switch (GDK_WINDOW_TYPE (private)) { @@ -791,7 +790,7 @@ _gdk_window_impl_new (GdkWindow *window, class_hint = XAllocClassHint (); class_hint->res_name = attributes->wmclass_name; class_hint->res_class = attributes->wmclass_class; - XSetClassHint (xdisplay, xid, class_hint); + XSetClassHint (xdisplay, impl->xid, class_hint); XFree (class_hint); } @@ -904,7 +903,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, private->parent->children = g_list_prepend (private->parent->children, window); - draw_impl->xid = anid; + impl->xid = anid; private->x = attrs.x; private->y = attrs.y; @@ -5615,6 +5614,6 @@ gdk_x11_window_get_xid (GdkWindow *window) impl = ((GdkWindowObject *) window)->impl; - return ((GdkDrawableImplX11 *)impl)->xid; + return ((GdkWindowImplX11 *)impl)->xid; } diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index d9c617f928..57ba01a448 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -58,6 +58,8 @@ struct _GdkWindowImplX11 { GdkDrawableImplX11 parent_instance; + Window xid; + GdkToplevelX11 *toplevel; /* Toplevel-specific information */ GdkCursor *cursor; GHashTable *device_cursor; diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 9e736e158d..0a6178ee24 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -117,8 +117,8 @@ gint gdk_x11_get_default_screen (void); * Returns: an Xlib Display*. */ #define GDK_WINDOW_XDISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xdisplay) -#define GDK_WINDOW_XID(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) -#define GDK_WINDOW_XWINDOW(win) (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) +#define GDK_WINDOW_XID(win) (GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) +#define GDK_WINDOW_XWINDOW(win) (GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) #define GDK_SCREEN_XDISPLAY(screen) (GDK_SCREEN_X11 (screen)->xdisplay) From bb795066657c0585d3307dc57e0eddedb0295292 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 03:49:04 +0200 Subject: [PATCH 018/634] x11: Move cairo_surface and wrapper members to GdkWindowImplX11 struct --- gdk/x11/gdkdrawable-x11.c | 101 ------------------------------- gdk/x11/gdkdrawable-x11.h | 5 -- gdk/x11/gdkwindow-x11.c | 124 +++++++++++++++++++++++++++++++------- gdk/x11/gdkwindow-x11.h | 4 ++ 4 files changed, 105 insertions(+), 129 deletions(-) diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 15808f3bf4..4db0fd50b5 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -39,22 +39,11 @@ #include -static cairo_surface_t *gdk_x11_ref_cairo_surface (GdkDrawable *drawable); -static cairo_surface_t *gdk_x11_create_cairo_surface (GdkDrawable *drawable, - int width, - int height); - -static const cairo_user_data_key_t gdk_x11_cairo_key; - G_DEFINE_TYPE (GdkDrawableImplX11, _gdk_drawable_impl_x11, GDK_TYPE_DRAWABLE) static void _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass) { - GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); - - drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; - drawable_class->create_cairo_surface = gdk_x11_create_cairo_surface; } static void @@ -62,93 +51,3 @@ _gdk_drawable_impl_x11_init (GdkDrawableImplX11 *impl) { } -/** - * _gdk_x11_drawable_finish: - * @drawable: a #GdkDrawableImplX11. - * - * Performs necessary cleanup prior to destroying a window. - **/ -void -_gdk_x11_drawable_finish (GdkDrawable *drawable) -{ - GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); - - if (impl->cairo_surface) - { - cairo_surface_finish (impl->cairo_surface); - cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - NULL, NULL); - } -} - -/** - * _gdk_x11_drawable_update_size: - * @drawable: a #GdkDrawableImplX11. - * - * Updates the state of the drawable (in particular the drawable's - * cairo surface) when its size has changed. - **/ -void -_gdk_x11_drawable_update_size (GdkDrawable *drawable) -{ - GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); - - if (impl->cairo_surface) - { - cairo_xlib_surface_set_size (impl->cairo_surface, - gdk_window_get_width (impl->wrapper), - gdk_window_get_height (impl->wrapper)); - } -} - -/***************************************************** - * X11 specific implementations of generic functions * - *****************************************************/ - -static void -gdk_x11_cairo_surface_destroy (void *data) -{ - GdkDrawableImplX11 *impl = data; - - impl->cairo_surface = NULL; -} - -static cairo_surface_t * -gdk_x11_create_cairo_surface (GdkDrawable *drawable, - int width, - int height) -{ - GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); - GdkVisual *visual; - - visual = gdk_window_get_visual (impl->wrapper); - return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), - GDK_WINDOW_IMPL_X11 (impl)->xid, - GDK_VISUAL_XVISUAL (visual), - width, height); -} - -static cairo_surface_t * -gdk_x11_ref_cairo_surface (GdkDrawable *drawable) -{ - GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); - - if (GDK_IS_WINDOW_IMPL_X11 (drawable) && - GDK_WINDOW_DESTROYED (impl->wrapper)) - return NULL; - - if (!impl->cairo_surface) - { - impl->cairo_surface = gdk_x11_create_cairo_surface (drawable, - gdk_window_get_width (impl->wrapper), - gdk_window_get_height (impl->wrapper)); - - if (impl->cairo_surface) - cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - drawable, gdk_x11_cairo_surface_destroy); - } - else - cairo_surface_reference (impl->cairo_surface); - - return impl->cairo_surface; -} diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h index 70a92d787e..078e61177a 100644 --- a/gdk/x11/gdkdrawable-x11.h +++ b/gdk/x11/gdkdrawable-x11.h @@ -48,10 +48,6 @@ typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class; struct _GdkDrawableImplX11 { GdkDrawable parent_instance; - - GdkDrawable *wrapper; - - cairo_surface_t *cairo_surface; }; struct _GdkDrawableImplX11Class @@ -63,7 +59,6 @@ struct _GdkDrawableImplX11Class GType _gdk_drawable_impl_x11_get_type (void); /* Note that the following take GdkDrawableImplX11, not the wrapper drawable */ -void _gdk_x11_drawable_finish (GdkDrawable *drawable); void _gdk_x11_drawable_update_size (GdkDrawable *drawable); G_END_DECLS diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 5d7e6532d7..b7045139af 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -168,27 +168,103 @@ _gdk_x11_window_get_toplevel (GdkWindow *window) return impl->toplevel; } +static const cairo_user_data_key_t gdk_x11_cairo_key; + +/** + * _gdk_x11_drawable_update_size: + * @drawable: a #GdkDrawableImplX11. + * + * Updates the state of the drawable (in particular the drawable's + * cairo surface) when its size has changed. + **/ +void +_gdk_x11_drawable_update_size (GdkDrawable *drawable) +{ + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); + + if (impl->cairo_surface) + { + cairo_xlib_surface_set_size (impl->cairo_surface, + gdk_window_get_width (impl->wrapper), + gdk_window_get_height (impl->wrapper)); + } +} + +/***************************************************** + * X11 specific implementations of generic functions * + *****************************************************/ + +static void +gdk_x11_cairo_surface_destroy (void *data) +{ + GdkWindowImplX11 *impl = data; + + impl->cairo_surface = NULL; +} + +static cairo_surface_t * +gdk_x11_create_cairo_surface (GdkDrawable *drawable, + int width, + int height) +{ + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); + GdkVisual *visual; + + visual = gdk_window_get_visual (impl->wrapper); + return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper), + GDK_WINDOW_IMPL_X11 (impl)->xid, + GDK_VISUAL_XVISUAL (visual), + width, height); +} + +static cairo_surface_t * +gdk_x11_ref_cairo_surface (GdkDrawable *drawable) +{ + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); + + if (GDK_IS_WINDOW_IMPL_X11 (drawable) && + GDK_WINDOW_DESTROYED (impl->wrapper)) + return NULL; + + if (!impl->cairo_surface) + { + impl->cairo_surface = gdk_x11_create_cairo_surface (drawable, + gdk_window_get_width (impl->wrapper), + gdk_window_get_height (impl->wrapper)); + + if (impl->cairo_surface) + cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, + drawable, gdk_x11_cairo_surface_destroy); + } + else + cairo_surface_reference (impl->cairo_surface); + + return impl->cairo_surface; +} + static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); object_class->finalize = gdk_window_impl_x11_finalize; + + drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; + drawable_class->create_cairo_surface = gdk_x11_create_cairo_surface; } static void gdk_window_impl_x11_finalize (GObject *object) { GdkWindowObject *wrapper; - GdkDrawableImplX11 *draw_impl; - GdkWindowImplX11 *window_impl; + GdkWindowImplX11 *impl; g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object)); - draw_impl = GDK_DRAWABLE_IMPL_X11 (object); - window_impl = GDK_WINDOW_IMPL_X11 (object); + impl = GDK_WINDOW_IMPL_X11 (object); - wrapper = (GdkWindowObject*) draw_impl->wrapper; + wrapper = (GdkWindowObject*) impl->wrapper; _gdk_xgrab_check_destroy (GDK_WINDOW (wrapper)); @@ -196,17 +272,17 @@ gdk_window_impl_x11_finalize (GObject *object) { GdkDisplay *display = GDK_WINDOW_DISPLAY ((GdkWindow *) wrapper); - _gdk_xid_table_remove (display, window_impl->xid); - if (window_impl->toplevel && window_impl->toplevel->focus_window) - _gdk_xid_table_remove (display, window_impl->toplevel->focus_window); + _gdk_xid_table_remove (display, impl->xid); + if (impl->toplevel && impl->toplevel->focus_window) + _gdk_xid_table_remove (display, impl->toplevel->focus_window); } - g_free (window_impl->toplevel); + g_free (impl->toplevel); - if (window_impl->cursor) - gdk_cursor_unref (window_impl->cursor); + if (impl->cursor) + gdk_cursor_unref (impl->cursor); - g_hash_table_destroy (window_impl->device_cursor); + g_hash_table_destroy (impl->device_cursor); G_OBJECT_CLASS (gdk_window_impl_x11_parent_class)->finalize (object); } @@ -423,7 +499,7 @@ void _gdk_windowing_window_init (GdkScreen * screen) { GdkWindowObject *private; - GdkDrawableImplX11 *draw_impl; + GdkWindowImplX11 *impl; GdkScreenX11 *screen_x11; screen_x11 = GDK_SCREEN_X11 (screen); @@ -437,10 +513,10 @@ _gdk_windowing_window_init (GdkScreen * screen) private->impl_window = private; private->visual = gdk_screen_get_system_visual (screen); - draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (private->impl); - GDK_WINDOW_IMPL_X11 (draw_impl)->xid = screen_x11->xroot_window; - draw_impl->wrapper = GDK_DRAWABLE (private); + impl->xid = screen_x11->xroot_window; + impl->wrapper = GDK_DRAWABLE (private); private->window_type = GDK_WINDOW_ROOT; private->depth = DefaultDepthOfScreen (screen_x11->xscreen); @@ -658,7 +734,6 @@ _gdk_window_impl_new (GdkWindow *window, { GdkWindowObject *private; GdkWindowImplX11 *impl; - GdkDrawableImplX11 *draw_impl; GdkScreenX11 *screen_x11; GdkDisplayX11 *display_x11; @@ -681,8 +756,7 @@ _gdk_window_impl_new (GdkWindow *window, impl = g_object_new (_gdk_window_impl_get_type (), NULL); private->impl = (GdkDrawable *)impl; - draw_impl = GDK_DRAWABLE_IMPL_X11 (impl); - draw_impl->wrapper = GDK_DRAWABLE (window); + impl->wrapper = GDK_DRAWABLE (window); xdisplay = screen_x11->xdisplay; @@ -852,7 +926,6 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, GdkWindow *window; GdkWindowObject *private; GdkWindowImplX11 *impl; - GdkDrawableImplX11 *draw_impl; GdkDisplayX11 *display_x11; XWindowAttributes attrs; Window root, parent; @@ -893,8 +966,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, XVisualIDFromVisual (attrs.visual)); impl = GDK_WINDOW_IMPL_X11 (private->impl); - draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); - draw_impl->wrapper = GDK_DRAWABLE (window); + impl->wrapper = GDK_DRAWABLE (window); private->parent = gdk_xid_table_lookup_for_display (display, parent); @@ -1007,6 +1079,7 @@ _gdk_x11_window_destroy (GdkWindow *window, gboolean foreign_destroy) { GdkWindowObject *private = (GdkWindowObject *)window; + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); GdkToplevelX11 *toplevel; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1017,7 +1090,12 @@ _gdk_x11_window_destroy (GdkWindow *window, if (toplevel) gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel); - _gdk_x11_drawable_finish (private->impl); + if (impl->cairo_surface) + { + cairo_surface_finish (impl->cairo_surface); + cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, + NULL, NULL); + } if (!recursing && !foreign_destroy) { diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index 57ba01a448..f0292ecfcd 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -58,6 +58,8 @@ struct _GdkWindowImplX11 { GdkDrawableImplX11 parent_instance; + GdkDrawable *wrapper; + Window xid; GdkToplevelX11 *toplevel; /* Toplevel-specific information */ @@ -69,6 +71,8 @@ struct _GdkWindowImplX11 * unset during resizing and scaling */ guint override_redirect : 1; guint use_synchronized_configure : 1; + + cairo_surface_t *cairo_surface; #if defined (HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES) Damage damage; From 3e6a4af6d398eb95da5b2bafa307901051c47610 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 04:03:23 +0200 Subject: [PATCH 019/634] x11: _gdk_x11_drawable_update_size() => _gdk_x11_window_update_size() --- gdk/x11/gdkdisplay-x11.c | 4 ++-- gdk/x11/gdkdrawable-x11.h | 2 -- gdk/x11/gdkwindow-x11.c | 18 ++++++++---------- gdk/x11/gdkwindow-x11.h | 10 ++++++---- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 2a2f8cb380..cd8161b3f3 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -693,7 +693,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, window_private->height = xevent->xconfigure.height; _gdk_window_update_size (window); - _gdk_x11_drawable_update_size (window_private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window_private->impl)); _gdk_x11_screen_size_changed (screen, xevent); } @@ -749,7 +749,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, window_private->height = xevent->xconfigure.height; _gdk_window_update_size (window); - _gdk_x11_drawable_update_size (window_private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window_private->impl)); if (window_private->resize_count >= 1) { diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h index 078e61177a..03c621ef7d 100644 --- a/gdk/x11/gdkdrawable-x11.h +++ b/gdk/x11/gdkdrawable-x11.h @@ -58,8 +58,6 @@ struct _GdkDrawableImplX11Class GType _gdk_drawable_impl_x11_get_type (void); -/* Note that the following take GdkDrawableImplX11, not the wrapper drawable */ -void _gdk_x11_drawable_update_size (GdkDrawable *drawable); G_END_DECLS diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index b7045139af..7e3e810c90 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -171,17 +171,15 @@ _gdk_x11_window_get_toplevel (GdkWindow *window) static const cairo_user_data_key_t gdk_x11_cairo_key; /** - * _gdk_x11_drawable_update_size: - * @drawable: a #GdkDrawableImplX11. + * _gdk_x11_window_update_size: + * @impl: a #GdkWindowImplX11. * - * Updates the state of the drawable (in particular the drawable's + * Updates the state of the window (in particular the drawable's * cairo surface) when its size has changed. **/ void -_gdk_x11_drawable_update_size (GdkDrawable *drawable) +_gdk_x11_window_update_size (GdkWindowImplX11 *impl) { - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); - if (impl->cairo_surface) { cairo_xlib_surface_set_size (impl->cairo_surface, @@ -1565,7 +1563,7 @@ window_x11_resize (GdkWindow *window, { private->width = width; private->height = height; - _gdk_x11_drawable_update_size (private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); } else { @@ -1574,7 +1572,7 @@ window_x11_resize (GdkWindow *window, } } - _gdk_x11_drawable_update_size (private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); } static inline void @@ -1595,7 +1593,7 @@ window_x11_move_resize (GdkWindow *window, if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) { _gdk_window_move_resize_child (window, x, y, width, height); - _gdk_x11_drawable_update_size (private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); } else { @@ -1613,7 +1611,7 @@ window_x11_move_resize (GdkWindow *window, private->width = width; private->height = height; - _gdk_x11_drawable_update_size (private->impl); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); } else { diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index f0292ecfcd..77eb32b49c 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -158,10 +158,12 @@ void _gdk_x11_window_tmp_reset_bg (GdkWindow *window, void _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window); void _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window); -GdkCursor *_gdk_x11_window_get_cursor (GdkWindow *window); -void _gdk_x11_window_get_offsets (GdkWindow *window, - gint *x_offset, - gint *y_offset); +GdkCursor *_gdk_x11_window_get_cursor (GdkWindow *window); +void _gdk_x11_window_get_offsets (GdkWindow *window, + gint *x_offset, + gint *y_offset); + +void _gdk_x11_window_update_size (GdkWindowImplX11 *impl); G_END_DECLS From 88399c041c76fe30f83e06a426cf8f4961da86c5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 04:08:20 +0200 Subject: [PATCH 020/634] x11: Remove GdkDrawableImplX11 It's not use anymore, the whole functionality has been moved to GdkWindowImplX11. --- gdk/Makefile.am | 1 - gdk/x11/Makefile.am | 2 -- gdk/x11/gdkdrawable-x11.c | 53 -------------------------------- gdk/x11/gdkdrawable-x11.h | 64 --------------------------------------- gdk/x11/gdkwindow-x11.c | 2 +- gdk/x11/gdkwindow-x11.h | 6 ++-- 6 files changed, 4 insertions(+), 124 deletions(-) delete mode 100644 gdk/x11/gdkdrawable-x11.c delete mode 100644 gdk/x11/gdkdrawable-x11.h diff --git a/gdk/Makefile.am b/gdk/Makefile.am index 9a48fe8042..f4606b94cf 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -202,7 +202,6 @@ x11_introspection_files = \ x11/gdkdevice-xi.c \ x11/gdkdisplay-x11.c \ x11/gdkdnd-x11.c \ - x11/gdkdrawable-x11.c \ x11/gdkeventsource.c \ x11/gdkeventtranslator.c \ x11/gdkgeometry-x11.c \ diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am index 6344754597..b6a4751b32 100644 --- a/gdk/x11/Makefile.am +++ b/gdk/x11/Makefile.am @@ -30,8 +30,6 @@ libgdk_x11_la_SOURCES = \ gdkdisplay-x11.c \ gdkdisplay-x11.h \ gdkdnd-x11.c \ - gdkdrawable-x11.c \ - gdkdrawable-x11.h \ gdkeventsource.c \ gdkeventsource.h \ gdkeventtranslator.c \ diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c deleted file mode 100644 index 4db0fd50b5..0000000000 --- a/gdk/x11/gdkdrawable-x11.c +++ /dev/null @@ -1,53 +0,0 @@ -/* GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkdrawable-x11.h" - -#include "gdkx.h" -#include "gdkprivate-x11.h" -#include "gdkscreen-x11.h" -#include "gdkdisplay-x11.h" - -#include - -#include -#include - - -G_DEFINE_TYPE (GdkDrawableImplX11, _gdk_drawable_impl_x11, GDK_TYPE_DRAWABLE) - -static void -_gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass) -{ -} - -static void -_gdk_drawable_impl_x11_init (GdkDrawableImplX11 *impl) -{ -} - diff --git a/gdk/x11/gdkdrawable-x11.h b/gdk/x11/gdkdrawable-x11.h deleted file mode 100644 index 03c621ef7d..0000000000 --- a/gdk/x11/gdkdrawable-x11.h +++ /dev/null @@ -1,64 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GDK_DRAWABLE_X11_H__ -#define __GDK_DRAWABLE_X11_H__ - -#include -#include - -G_BEGIN_DECLS - -/* Drawable implementation for X11 - */ - -typedef struct _GdkDrawableImplX11 GdkDrawableImplX11; -typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class; - -#define GDK_TYPE_DRAWABLE_IMPL_X11 (_gdk_drawable_impl_x11_get_type ()) -#define GDK_DRAWABLE_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11)) -#define GDK_DRAWABLE_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11Class)) -#define GDK_IS_DRAWABLE_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE_IMPL_X11)) -#define GDK_IS_DRAWABLE_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE_IMPL_X11)) -#define GDK_DRAWABLE_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE_IMPL_X11, GdkDrawableImplX11Class)) - -struct _GdkDrawableImplX11 -{ - GdkDrawable parent_instance; -}; - -struct _GdkDrawableImplX11Class -{ - GdkDrawableClass parent_class; - -}; - -GType _gdk_drawable_impl_x11_get_type (void); - - -G_END_DECLS - -#endif /* __GDK_DRAWABLE_X11_H__ */ diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 7e3e810c90..1435fdf94b 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -130,7 +130,7 @@ static void gdk_window_impl_iface_init (GdkWindowImplIface *iface); G_DEFINE_TYPE_WITH_CODE (GdkWindowImplX11, gdk_window_impl_x11, - GDK_TYPE_DRAWABLE_IMPL_X11, + GDK_TYPE_DRAWABLE, G_IMPLEMENT_INTERFACE (GDK_TYPE_WINDOW_IMPL, gdk_window_impl_iface_init)); diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index 77eb32b49c..570a9572a3 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -27,7 +27,7 @@ #ifndef __GDK_WINDOW_X11_H__ #define __GDK_WINDOW_X11_H__ -#include +#include "gdk/x11/gdkprivate-x11.h" #ifdef HAVE_XDAMAGE #include @@ -56,7 +56,7 @@ typedef struct _GdkXPositionInfo GdkXPositionInfo; struct _GdkWindowImplX11 { - GdkDrawableImplX11 parent_instance; + GdkDrawable parent_instance; GdkDrawable *wrapper; @@ -81,7 +81,7 @@ struct _GdkWindowImplX11 struct _GdkWindowImplX11Class { - GdkDrawableImplX11Class parent_class; + GdkDrawableClass parent_class; }; struct _GdkToplevelX11 From d154344a439fd6e07d092cfc2cbdb132bb26c9e2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 04:30:24 +0200 Subject: [PATCH 021/634] win32: Remove some unused defines --- gdk/win32/gdkdrawable-win32.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index c6c8b61741..051569b138 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -34,20 +34,8 @@ #include #include -#include "gdkscreen.h" /* gdk_screen_get_default() */ #include "gdkprivate-win32.h" -#define ROP3_D 0x00AA0029 -#define ROP3_DSna 0x00220326 -#define ROP3_DSPDxax 0x00E20746 - -#define LINE_ATTRIBUTES (GDK_GC_LINE_WIDTH|GDK_GC_LINE_STYLE| \ - GDK_GC_CAP_STYLE|GDK_GC_JOIN_STYLE) - -#define MUST_RENDER_DASHES_MANUALLY(gcwin32) \ - (gcwin32->line_style == GDK_LINE_DOUBLE_DASH || \ - (gcwin32->line_style == GDK_LINE_ON_OFF_DASH && gcwin32->pen_dash_offset)) - static cairo_surface_t *gdk_win32_ref_cairo_surface (GdkDrawable *drawable); static cairo_surface_t *gdk_win32_create_cairo_surface (GdkDrawable *drawable, int width, From 65dde2f92f8d2fb78688966d2258848383270877 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 18:44:51 +0200 Subject: [PATCH 022/634] API: Remove gdk_cairo_reset_clip() You should not ever ever ever call cairo_reset_clip(). If you do, your code is broken and you deserve everything you get. And we should definitely not support this insanity. --- docs/reference/gdk/gdk3-sections.txt | 1 - .../gtk/migrating-ClientSideWindows.sgml | 12 ++------ gdk/gdkcairo.c | 28 ------------------- gdk/gdkcairo.h | 2 -- 4 files changed, 3 insertions(+), 40 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 596d7220eb..f277295c35 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -616,7 +616,6 @@ gdk_cairo_set_source_pixbuf gdk_cairo_set_source_window gdk_cairo_rectangle gdk_cairo_region -gdk_cairo_reset_clip gdk_cairo_region_create_from_surface
diff --git a/docs/reference/gtk/migrating-ClientSideWindows.sgml b/docs/reference/gtk/migrating-ClientSideWindows.sgml index 54e0620f1b..017249c3e9 100644 --- a/docs/reference/gtk/migrating-ClientSideWindows.sgml +++ b/docs/reference/gtk/migrating-ClientSideWindows.sgml @@ -46,15 +46,9 @@ Problems can also occur when using cairo for drawing. One thing that can - go wrong is clip handling. If you ever need to reset the clip region on - a cairo_t (i.e. use cairo_reset_clip()), you have to to use - gdk_cairo_reset_clip() instead. The reason for this is that the cairo_reset_clip() call will remove the initial clip region that limits your drawing to - the client-side window at hand, so you will end up drawing over stuff - outside the window. You also need to use gdk_cairo_reset_clip() if you - use a cairo_t that was not allocated in a double-buffered expose handler - and keep it in use after window hierarchy changes (resizing, moving, - stacking order changes). The easiest fix for this kind of problem is to - simply create a new cairo context for each expose event. + go wrong is clip handling. You may not use cairo_reset_clip() on a + cairo_t on a cairo context created via gdk_cairo_create() or passed to + the GtkWidget::draw signal. diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 197e2c41e9..a554241fff 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -78,34 +78,6 @@ gdk_cairo_create (GdkDrawable *drawable) return cr; } -/** - * gdk_cairo_reset_clip: - * @cr: a #cairo_t - * @drawable: a #GdkDrawable - * - * Resets the clip region for a Cairo context created by gdk_cairo_create(). - * - * This resets the clip region to the "empty" state for the given drawable. - * This is required for non-native windows since a direct call to - * cairo_reset_clip() would unset the clip region inherited from the - * drawable (i.e. the window clip region), and thus let you e.g. - * draw outside your window. - * - * This is rarely needed though, since most code just create a new cairo_t - * using gdk_cairo_create() each time they want to draw something. - * - * Since: 2.18 - **/ -void -gdk_cairo_reset_clip (cairo_t *cr, - GdkDrawable *drawable) -{ - cairo_reset_clip (cr); - - if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip) - GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr); -} - /** * gdk_cairo_get_clip_rectangle: * @cr: a cairo context diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h index b9b45e5f08..f594f8bec7 100644 --- a/gdk/gdkcairo.h +++ b/gdk/gdkcairo.h @@ -32,8 +32,6 @@ G_BEGIN_DECLS cairo_t *gdk_cairo_create (GdkDrawable *drawable); -void gdk_cairo_reset_clip (cairo_t *cr, - GdkDrawable *drawable); gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr, GdkRectangle *rect); From 97e6e9d212de2cfe543872513c6956bdee6dc6e7 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 19:12:27 +0200 Subject: [PATCH 023/634] API: Make gdk_cairo_create() take a GdkWindow This is not strictly an API change as GdkDrawable is typedeffed to GdkWindow, but it changes the header, so I'm marking it as such. gdk_cairo_create() can only be used with windows these days, so it makes sense to pass a window. With that, we can alseo remove the set_cairo_clip() vfunc from GdkDrawable and implement it inside gdkwindow.c. --- gdk/gdkcairo.c | 36 ---------------------------- gdk/gdkcairo.h | 2 +- gdk/gdkdrawable.h | 3 --- gdk/gdkwindow.c | 60 ++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index a554241fff..7fe0ccc770 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -42,42 +42,6 @@ */ -/** - * gdk_cairo_create: - * @drawable: a #GdkDrawable - * - * Creates a Cairo context for drawing to @drawable. - * - * - * Note that due to double-buffering, Cairo contexts created - * in a GTK+ expose event handler cannot be cached and reused - * between different expose events. - * - * - * Return value: A newly created Cairo context. Free with - * cairo_destroy() when you are done drawing. - * - * Since: 2.8 - **/ -cairo_t * -gdk_cairo_create (GdkDrawable *drawable) -{ - cairo_surface_t *surface; - cairo_t *cr; - - g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); - - surface = _gdk_drawable_ref_cairo_surface (drawable); - cr = cairo_create (surface); - - if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip) - GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr); - - cairo_surface_destroy (surface); - - return cr; -} - /** * gdk_cairo_get_clip_rectangle: * @cr: a cairo context diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h index f594f8bec7..67e08aa933 100644 --- a/gdk/gdkcairo.h +++ b/gdk/gdkcairo.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS -cairo_t *gdk_cairo_create (GdkDrawable *drawable); +cairo_t *gdk_cairo_create (GdkWindow *window); gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr, GdkRectangle *rect); diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index a32c18524f..24fa122851 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -67,9 +67,6 @@ struct _GdkDrawableClass cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable); - void (*set_cairo_clip) (GdkDrawable *drawable, - cairo_t *cr); - cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable, int width, int height); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 01c5749e7a..bb466439cd 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -224,8 +224,6 @@ static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable, int width, int height); static void gdk_window_drop_cairo_surface (GdkWindowObject *private); -static void gdk_window_set_cairo_clip (GdkDrawable *drawable, - cairo_t *cr); static cairo_region_t* gdk_window_get_clip_region (GdkDrawable *drawable); static cairo_region_t* gdk_window_get_visible_region (GdkDrawable *drawable); @@ -385,7 +383,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass) drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface; drawable_class->create_cairo_surface = gdk_window_create_cairo_surface; - drawable_class->set_cairo_clip = gdk_window_set_cairo_clip; drawable_class->get_clip_region = gdk_window_get_clip_region; drawable_class->get_visible_region = gdk_window_get_visible_region; @@ -2818,6 +2815,23 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) return TRUE; } +static cairo_t * +gdk_cairo_create_for_impl (GdkWindow *window) +{ + GdkWindowObject *priv; + cairo_surface_t *surface; + cairo_t *cr; + + priv = (GdkWindowObject*) window; + + surface = _gdk_drawable_ref_cairo_surface (priv->impl); + cr = cairo_create (surface); + + cairo_surface_destroy (surface); + + return cr; +} + /* Ensure that all content related to this (sub)window is pushed to the native region. If there is an active paint then that area is not pushed, in order to not show partially finished double buffers. */ @@ -2858,7 +2872,7 @@ gdk_window_flush_implicit_paint (GdkWindow *window) cairo_region_subtract (paint->region, region); /* Some regions are valid, push these to window now */ - cr = gdk_cairo_create (private->impl); + cr = gdk_cairo_create_for_impl (window); gdk_cairo_region (cr, region); cairo_clip (cr); cairo_set_source_surface (cr, paint->surface, 0, 0); @@ -2890,7 +2904,7 @@ gdk_window_end_implicit_paint (GdkWindow *window) cairo_t *cr; /* Some regions are valid, push these to window now */ - cr = gdk_cairo_create (private->impl); + cr = gdk_cairo_create_for_impl (window); gdk_cairo_region (cr, paint->region); cairo_clip (cr); cairo_set_source_surface (cr, paint->surface, 0, 0); @@ -3727,11 +3741,35 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable) return surface; } -static void -gdk_window_set_cairo_clip (GdkDrawable *drawable, - cairo_t *cr) +/** + * gdk_cairo_create: + * @drawable: a #GdkWindow + * + * Creates a Cairo context for drawing to @window. + * + * + * Note that calling cairo_reset_clip() on the resulting #cairo_t will + * produce undefined results, so avoid it at all costs. + * + * + * Return value: A newly created Cairo context. Free with + * cairo_destroy() when you are done drawing. + * + * Since: 2.8 + **/ +cairo_t * +gdk_cairo_create (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject*) drawable; + GdkWindowObject *private; + cairo_surface_t *surface; + cairo_t *cr; + + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + private = (GdkWindowObject*) window; + + surface = _gdk_drawable_ref_cairo_surface (window); + cr = cairo_create (surface); if (!private->paint_stack) { @@ -3765,6 +3803,10 @@ gdk_window_set_cairo_clip (GdkDrawable *drawable, cairo_clip (cr); } } + + cairo_surface_destroy (surface); + + return cr; } /* Code for dirty-region queueing From 6a3a89a6215f3c94e1ca250cad3676648c1ea896 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 19:31:03 +0200 Subject: [PATCH 024/634] API: gdk_drawable_get_clip_region() => gdk_window_get_clip_region() Also remove the vfunc from GdkDrawableClass. --- docs/reference/gdk/gdk3-sections.txt | 2 +- gdk/gdk.symbols | 2 +- gdk/gdkdraw.c | 22 ---------------------- gdk/gdkdrawable.h | 2 -- gdk/gdkwindow.c | 25 ++++++++++++++++++++----- gdk/gdkwindow.h | 2 ++ 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index f277295c35..e884a7722b 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -278,7 +278,6 @@ GDK_TYPE_RGBA Drawing Primitives drawing GdkDrawable -gdk_drawable_get_clip_region gdk_drawable_get_visible_region @@ -397,6 +396,7 @@ gdk_window_constrain_size gdk_window_beep +gdk_window_get_clip_region gdk_window_begin_paint_rect gdk_window_begin_paint_region gdk_window_end_paint diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index abc2f592a2..d6dacd0384 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -154,7 +154,6 @@ gdk_drag_get_selection gdk_drag_motion gdk_drag_protocol_get_type G_GNUC_CONST gdk_drag_status -gdk_drawable_get_clip_region gdk_drawable_get_type G_GNUC_CONST gdk_drawable_get_visible_region gdk_drop_finish @@ -414,6 +413,7 @@ gdk_window_geometry_changed gdk_window_get_accept_focus gdk_window_get_background_pattern gdk_window_get_children +gdk_window_get_clip_region gdk_window_get_composited gdk_window_get_cursor gdk_window_get_decorations diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index d31dfd9a66..df9762bf2d 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -50,28 +50,6 @@ gdk_drawable_init (GdkDrawable *drawable) { } -/** - * gdk_drawable_get_clip_region: - * @drawable: a #GdkDrawable - * - * Computes the region of a drawable that potentially can be written - * to by drawing primitives. This region will not take into account - * the clip region for the GC, and may also not take into account - * other factors such as if the window is obscured by other windows, - * but no area outside of this region will be affected by drawing - * primitives. - * - * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy() - * when you are done. - **/ -cairo_region_t * -gdk_drawable_get_clip_region (GdkDrawable *drawable) -{ - g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); - - return GDK_DRAWABLE_GET_CLASS (drawable)->get_clip_region (drawable); -} - /** * gdk_drawable_get_visible_region: * @drawable: a #GdkDrawable diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index 24fa122851..1c619a8908 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -62,7 +62,6 @@ struct _GdkDrawableClass { GObjectClass parent_class; - cairo_region_t* (*get_clip_region) (GdkDrawable *drawable); cairo_region_t* (*get_visible_region) (GdkDrawable *drawable); cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable); @@ -84,7 +83,6 @@ struct _GdkDrawableClass GType gdk_drawable_get_type (void) G_GNUC_CONST; -cairo_region_t *gdk_drawable_get_clip_region (GdkDrawable *drawable); cairo_region_t *gdk_drawable_get_visible_region (GdkDrawable *drawable); G_END_DECLS diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index bb466439cd..5523d07a62 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -225,7 +225,6 @@ static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable, int height); static void gdk_window_drop_cairo_surface (GdkWindowObject *private); -static cairo_region_t* gdk_window_get_clip_region (GdkDrawable *drawable); static cairo_region_t* gdk_window_get_visible_region (GdkDrawable *drawable); static void gdk_window_free_paint_stack (GdkWindow *window); @@ -383,7 +382,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass) drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface; drawable_class->create_cairo_surface = gdk_window_create_cairo_surface; - drawable_class->get_clip_region = gdk_window_get_clip_region; drawable_class->get_visible_region = gdk_window_get_visible_region; klass->create_surface = _gdk_offscreen_window_create_surface; @@ -3516,12 +3514,29 @@ gdk_window_flush_recursive (GdkWindowObject *window) gdk_window_flush_recursive_helper (window, window->impl); } -static cairo_region_t* -gdk_window_get_clip_region (GdkDrawable *drawable) +/** + * gdk_window_get_clip_region: + * @window: a #GdkWindow + * + * Computes the region of a window that potentially can be written + * to by drawing primitives. This region may not take into account + * other factors such as if the window is obscured by other windows, + * but no area outside of this region will be affected by drawing + * primitives. + * + * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy() + * when you are done. + **/ +cairo_region_t* +gdk_window_get_clip_region (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)drawable; + GdkWindowObject *private; cairo_region_t *result; + g_return_val_if_fail (GDK_WINDOW (window), NULL); + + private = (GdkWindowObject *) window; + result = cairo_region_copy (private->clip_region); if (private->paint_stack) diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 8a2fd4ba0e..f600c76ae0 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -680,6 +680,8 @@ void gdk_window_set_geometry_hints (GdkWindow *window, GdkWindowHints geom_mask); void gdk_set_sm_client_id (const gchar *sm_client_id); +cairo_region_t *gdk_window_get_clip_region (GdkWindow *window); + void gdk_window_begin_paint_rect (GdkWindow *window, const GdkRectangle *rectangle); void gdk_window_begin_paint_region (GdkWindow *window, From becaf660fc84238fc3ecf1a8df9932bc8da93d40 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 6 Oct 2010 23:42:45 +0200 Subject: [PATCH 025/634] API: gdk_drawable_get_visible_region => gdk_window_get_visible_region Also get rid of the GdkDrawable vfunc. --- gdk/gdkdraw.c | 20 -------------------- gdk/gdkdrawable.h | 4 ---- gdk/gdkwindow.c | 27 ++++++++++++++++++++------- gdk/gdkwindow.h | 2 ++ 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index df9762bf2d..77b2936ce6 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -50,26 +50,6 @@ gdk_drawable_init (GdkDrawable *drawable) { } -/** - * gdk_drawable_get_visible_region: - * @drawable: a #GdkDrawable - * - * Computes the region of a drawable that is potentially visible. - * This does not necessarily take into account if the window is - * obscured by other windows, but no area outside of this region - * is visible. - * - * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy() - * when you are done. - **/ -cairo_region_t * -gdk_drawable_get_visible_region (GdkDrawable *drawable) -{ - g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); - - return GDK_DRAWABLE_GET_CLASS (drawable)->get_visible_region (drawable); -} - /** * _gdk_drawable_ref_cairo_surface: * @drawable: a #GdkDrawable diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index 1c619a8908..b8799e343d 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -62,8 +62,6 @@ struct _GdkDrawableClass { GObjectClass parent_class; - cairo_region_t* (*get_visible_region) (GdkDrawable *drawable); - cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable); cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable, @@ -83,8 +81,6 @@ struct _GdkDrawableClass GType gdk_drawable_get_type (void) G_GNUC_CONST; -cairo_region_t *gdk_drawable_get_visible_region (GdkDrawable *drawable); - G_END_DECLS #endif /* __GDK_DRAWABLE_H__ */ diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 5523d07a62..e3d401368f 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -225,8 +225,6 @@ static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable, int height); static void gdk_window_drop_cairo_surface (GdkWindowObject *private); -static cairo_region_t* gdk_window_get_visible_region (GdkDrawable *drawable); - static void gdk_window_free_paint_stack (GdkWindow *window); static void gdk_window_init (GdkWindowObject *window); @@ -382,7 +380,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass) drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface; drawable_class->create_cairo_surface = gdk_window_create_cairo_surface; - drawable_class->get_visible_region = gdk_window_get_visible_region; klass->create_surface = _gdk_offscreen_window_create_surface; @@ -3560,10 +3557,26 @@ gdk_window_get_clip_region (GdkWindow *window) return result; } -static cairo_region_t* -gdk_window_get_visible_region (GdkDrawable *drawable) +/** + * gdk_window_get_visible_region: + * @window: a #GdkWindow + * + * Computes the region of the @window that is potentially visible. + * This does not necessarily take into account if the window is + * obscured by other windows, but no area outside of this region + * is visible. + * + * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy() + * when you are done. + **/ +cairo_region_t * +gdk_window_get_visible_region (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject*) drawable; + GdkWindowObject *private; + + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + private = (GdkWindowObject*) window; return cairo_region_copy (private->clip_region); } @@ -4511,7 +4524,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, private->window_type == GDK_WINDOW_ROOT) return; - visible_region = gdk_drawable_get_visible_region (window); + visible_region = gdk_window_get_visible_region (window); cairo_region_intersect (visible_region, region); tmp_list = private->children; diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index f600c76ae0..4e408ca86a 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -681,6 +681,8 @@ void gdk_window_set_geometry_hints (GdkWindow *window, void gdk_set_sm_client_id (const gchar *sm_client_id); cairo_region_t *gdk_window_get_clip_region (GdkWindow *window); +cairo_region_t *gdk_window_get_visible_region(GdkWindow *window); + void gdk_window_begin_paint_rect (GdkWindow *window, const GdkRectangle *rectangle); From fe6f76a5a2f33f9873b482c397b22a9ae5cda300 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 7 Oct 2010 00:17:33 +0200 Subject: [PATCH 026/634] x11: Make wrapper member a GdkDrawable This is in preparation for getting rid of GdkDrawable as a dependency of GdkWindow. --- gdk/x11/gdkwindow-x11.c | 6 +++--- gdk/x11/gdkwindow-x11.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 1435fdf94b..2589fa6c54 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -514,7 +514,7 @@ _gdk_windowing_window_init (GdkScreen * screen) impl = GDK_WINDOW_IMPL_X11 (private->impl); impl->xid = screen_x11->xroot_window; - impl->wrapper = GDK_DRAWABLE (private); + impl->wrapper = GDK_WINDOW (private); private->window_type = GDK_WINDOW_ROOT; private->depth = DefaultDepthOfScreen (screen_x11->xscreen); @@ -754,7 +754,7 @@ _gdk_window_impl_new (GdkWindow *window, impl = g_object_new (_gdk_window_impl_get_type (), NULL); private->impl = (GdkDrawable *)impl; - impl->wrapper = GDK_DRAWABLE (window); + impl->wrapper = GDK_WINDOW (window); xdisplay = screen_x11->xdisplay; @@ -964,7 +964,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, XVisualIDFromVisual (attrs.visual)); impl = GDK_WINDOW_IMPL_X11 (private->impl); - impl->wrapper = GDK_DRAWABLE (window); + impl->wrapper = window; private->parent = gdk_xid_table_lookup_for_display (display, parent); diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index 570a9572a3..04dc8aa0aa 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -58,7 +58,7 @@ struct _GdkWindowImplX11 { GdkDrawable parent_instance; - GdkDrawable *wrapper; + GdkWindow *wrapper; Window xid; From 18a6976e5a1e899b62280fbbeb6df9c2c9191bcc Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 7 Oct 2010 21:32:05 +0200 Subject: [PATCH 027/634] API: gdk: Don't track outstanding surfaces You are not allowed to track surfaces from GDK or draw outside of expose events. So we can remove ugly hacks needed previously. See https://bugzilla.gnome.org/show_bug.cgi?id=606009 for the introduction of this workaround. --- gdk/gdkinternals.h | 1 - gdk/gdkwindow.c | 12 +----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index c425447871..f25672fd58 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -267,7 +267,6 @@ struct _GdkWindowObject cairo_region_t *input_shape; cairo_surface_t *cairo_surface; - guint outstanding_surfaces; /* only set on impl window */ GList *devices_inside; GHashTable *device_events; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index e3d401368f..776a03bf10 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2784,9 +2784,6 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) private->implicit_paint != NULL) return FALSE; /* Don't stack implicit paints */ - if (private->outstanding_surfaces != 0) - return FALSE; /* May conflict with direct drawing to cairo surface */ - /* Never do implicit paints for foreign windows, they don't need * double buffer combination since they have no client side children, * and creating surfaces for them is risky since they could disappear @@ -3393,11 +3390,7 @@ move_region_on_impl (GdkWindowObject *impl_window, cairo_region_destroy (exposing); } - if (impl_window->outstanding_surfaces == 0) /* Enable flicker free handling of moves. */ - append_move_region (impl_window, region, dx, dy); - else - do_move_region_bits_on_impl (impl_window, - region, dx, dy); + append_move_region (impl_window, region, dx, dy); cairo_region_destroy (region); } @@ -3702,7 +3695,6 @@ gdk_window_cairo_surface_destroy (void *data) GdkWindowObject *private = (GdkWindowObject*) data; private->cairo_surface = NULL; - private->impl_window->outstanding_surfaces--; } static cairo_surface_t * @@ -3754,8 +3746,6 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable) if (private->cairo_surface) { - private->impl_window->outstanding_surfaces++; - cairo_surface_set_user_data (private->cairo_surface, &gdk_window_cairo_key, drawable, gdk_window_cairo_surface_destroy); } From e724054d19d617107cfc4d9be116b376bfee249d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:06:46 +0100 Subject: [PATCH 028/634] API: Remove GDK_WINDOW_XWINDOW() macro Use GDK_WINDOW_XID() instead. THis was done using sed, so there might be issues resulting to that. Feel free to fix. --- docs/reference/gdk/gdk3-sections.txt | 1 - gdk/x11/gdkcursor-x11.c | 2 +- gdk/x11/gdkdevice-core.c | 4 +-- gdk/x11/gdkdevice-xi.c | 4 +-- gdk/x11/gdkdevice-xi2.c | 8 +++--- gdk/x11/gdkdevicemanager-xi2.c | 2 +- gdk/x11/gdkdnd-x11.c | 16 +++++------ gdk/x11/gdkproperty-x11.c | 4 +-- gdk/x11/gdkwindow-x11.c | 18 ++++++------ gdk/x11/gdkx.h | 5 ++-- gtk/gtkplug-x11.c | 10 +++---- gtk/gtkselection.c | 2 +- gtk/gtksocket-x11.c | 42 ++++++++++++++-------------- gtk/gtktrayicon-x11.c | 4 +-- gtk/gtkxembed.c | 4 +-- modules/other/gail/gailwindow.c | 6 ++-- 16 files changed, 65 insertions(+), 67 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index e884a7722b..37ea219b00 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -975,7 +975,6 @@ GDK_SCREEN_XNUMBER GDK_SCREEN_XSCREEN GDK_CURSOR_XCURSOR GDK_CURSOR_XDISPLAY -GDK_WINDOW_XWINDOW gdkx_visual_get gdk_window_foreign_new gdk_window_foreign_new_for_display diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c index 60380672c2..6169cc1d89 100644 --- a/gdk/x11/gdkcursor-x11.c +++ b/gdk/x11/gdkcursor-x11.c @@ -1035,6 +1035,6 @@ gdk_display_get_maximal_cursor_size (GdkDisplay *display, screen = gdk_display_get_default_screen (display); window = gdk_screen_get_root_window (screen); XQueryBestCursor (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), 128, 128, width, height); } diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c index a674aac654..acb438641f 100644 --- a/gdk/x11/gdkdevice-core.c +++ b/gdk/x11/gdkdevice-core.c @@ -228,7 +228,7 @@ gdk_device_core_warp (GdkDevice *device, Window dest; xdisplay = GDK_DISPLAY_XDISPLAY (gdk_device_get_display (device)); - dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); + dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y); } @@ -497,6 +497,6 @@ gdk_device_core_select_window_events (GdkDevice *device, xmask |= StructureNotifyMask | PropertyChangeMask; XSelectInput (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), xmask); } diff --git a/gdk/x11/gdkdevice-xi.c b/gdk/x11/gdkdevice-xi.c index 8bebf075d3..8ffd8dfa06 100644 --- a/gdk/x11/gdkdevice-xi.c +++ b/gdk/x11/gdkdevice-xi.c @@ -443,7 +443,7 @@ gdk_device_xi_grab (GdkDevice *device, status = XGrabDevice (GDK_WINDOW_XDISPLAY (window), device_xi->xdevice, - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), owner_events, num_classes, event_classes, GrabModeAsync, GrabModeAsync, @@ -492,7 +492,7 @@ gdk_device_xi_select_window_events (GdkDevice *device, find_events (device, event_mask, event_classes, &num_classes); XSelectExtensionEvent (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), event_classes, num_classes); if (event_mask) diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c index 41142e2097..7c91cd3f82 100644 --- a/gdk/x11/gdkdevice-xi2.c +++ b/gdk/x11/gdkdevice-xi2.c @@ -258,13 +258,13 @@ gdk_device_xi2_set_window_cursor (GdkDevice *device, XIDefineCursor (GDK_WINDOW_XDISPLAY (window), priv->device_id, - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), cursor_private->xcursor); } else XIUndefineCursor (GDK_WINDOW_XDISPLAY (window), priv->device_id, - GDK_WINDOW_XWINDOW (window)); + GDK_WINDOW_XID (window)); } static void @@ -277,7 +277,7 @@ gdk_device_xi2_warp (GdkDevice *device, Window dest; priv = GDK_DEVICE_XI2 (device)->priv; - dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); + dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); XIWarpPointer (GDK_SCREEN_XDISPLAY (screen), priv->device_id, @@ -512,7 +512,7 @@ gdk_device_xi2_select_window_events (GdkDevice *device, evmask.mask = gdk_device_xi2_translate_event_mask (event_mask, &evmask.mask_len); XISelectEvents (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), &evmask, 1); g_free (evmask.mask); diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index f97717d522..25d7a841a6 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -369,7 +369,7 @@ gdk_device_manager_xi2_constructed (GObject *object) event_mask.mask = mask; _gdk_device_manager_xi2_select_events (GDK_DEVICE_MANAGER (object), - GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)), + GDK_WINDOW_XID (gdk_screen_get_root_window (screen)), &event_mask); } diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 8927d5ef81..0c94a6456b 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -547,7 +547,7 @@ gdk_window_cache_new (GdkScreen *screen) result->child_hash = g_hash_table_new (g_direct_hash, NULL); result->screen = screen; - XGetWindowAttributes (xdisplay, GDK_WINDOW_XWINDOW (root_window), &xwa); + XGetWindowAttributes (xdisplay, GDK_WINDOW_XID (root_window), &xwa); result->old_event_mask = xwa.your_event_mask; if (G_UNLIKELY (!GDK_DISPLAY_X11 (GDK_SCREEN_X11 (screen)->display)->trusted_client)) @@ -568,13 +568,13 @@ gdk_window_cache_new (GdkScreen *screen) return result; } - XSelectInput (xdisplay, GDK_WINDOW_XWINDOW (root_window), + XSelectInput (xdisplay, GDK_WINDOW_XID (root_window), result->old_event_mask | SubstructureNotifyMask); gdk_window_add_filter (root_window, gdk_window_cache_filter, result); gdk_window_add_filter (NULL, gdk_window_cache_shape_filter, result); if (!_gdk_x11_get_window_child_info (gdk_screen_get_display (screen), - GDK_WINDOW_XWINDOW (root_window), + GDK_WINDOW_XID (root_window), FALSE, NULL, &children, &nchildren)) return result; @@ -598,9 +598,9 @@ gdk_window_cache_new (GdkScreen *screen) */ if (gdk_screen_is_composited (screen)) { - cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XWINDOW (root_window)); + cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window)); gdk_window_cache_add (result, cow, 0, 0, gdk_screen_get_width (screen), gdk_screen_get_height (screen), TRUE); - XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XWINDOW (root_window)); + XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window)); } #endif @@ -613,7 +613,7 @@ gdk_window_cache_destroy (GdkWindowCache *cache) GdkWindow *root_window = gdk_screen_get_root_window (cache->screen); XSelectInput (GDK_WINDOW_XDISPLAY (root_window), - GDK_WINDOW_XWINDOW (root_window), + GDK_WINDOW_XID (root_window), cache->old_event_mask); gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache); gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache); @@ -774,7 +774,7 @@ get_client_window_at_coords (GdkWindowCache *cache, if (retval) return retval; else - return GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (cache->screen)); + return GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen)); } /************************************************************* @@ -2397,7 +2397,7 @@ xdnd_send_xevent (GdkDragContext *context, } } - xwindow = GDK_WINDOW_XWINDOW (window); + xwindow = GDK_WINDOW_XID (window); if (_gdk_x11_display_is_root_window (display, xwindow)) event_mask = ButtonPressMask; diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index b55cd42e5f..00132b29e1 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -703,7 +703,7 @@ gdk_property_get (GdkWindow *window, } res = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (window), xproperty, + GDK_WINDOW_XID (window), xproperty, offset, get_length, pdelete, xtype, &ret_prop_type, &ret_format, &ret_nitems, &ret_bytes_after, @@ -892,7 +892,7 @@ gdk_property_delete (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (window), + XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), gdk_x11_atom_to_xatom_for_display (GDK_WINDOW_DISPLAY (window), property)); } diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 2589fa6c54..e2cfcb8c02 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -878,7 +878,7 @@ _gdk_window_impl_new (GdkWindow *window, gdk_window_set_type_hint (window, attributes->type_hint); gdk_event_source_select_events ((GdkEventSource *) display_x11->event_source, - GDK_WINDOW_XWINDOW (window), event_mask, + GDK_WINDOW_XID (window), event_mask, StructureNotifyMask | PropertyChangeMask); } @@ -1826,7 +1826,7 @@ move_to_current_desktop (GdkWindow *window) xclient.type = ClientMessage; xclient.serial = 0; xclient.send_event = True; - xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.window = GDK_WINDOW_XID (window); xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"); xclient.format = 32; @@ -1877,7 +1877,7 @@ gdk_window_focus (GdkWindow *window, memset (&xclient, 0, sizeof (xclient)); xclient.type = ClientMessage; - xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.window = GDK_WINDOW_XID (window); xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_ACTIVE_WINDOW"); xclient.format = 32; @@ -3305,7 +3305,7 @@ _gdk_windowing_window_at_device_position (GdkDisplay *display, toplevels = gdk_screen_get_toplevel_windows (screen); for (list = toplevels; list != NULL; list = g_list_next (list)) { window = GDK_WINDOW (list->data); - xwindow = GDK_WINDOW_XWINDOW (window); + xwindow = GDK_WINDOW_XID (window); gdk_error_trap_push (); XQueryPointer (xdisplay, xwindow, &root, &child, &rootx, &rooty, &winx, &winy, &xmask); @@ -3407,7 +3407,7 @@ gdk_window_x11_set_events (GdkWindow *window, display_x11 = GDK_DISPLAY_X11 (gdk_window_get_display (window)); gdk_event_source_select_events ((GdkEventSource *) display_x11->event_source, - GDK_WINDOW_XWINDOW (window), event_mask, + GDK_WINDOW_XID (window), event_mask, xevent_mask); } } @@ -3986,7 +3986,7 @@ gdk_window_iconify (GdkWindow *window) if (GDK_WINDOW_IS_MAPPED (window)) { XIconifyWindow (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), gdk_screen_get_number (GDK_WINDOW_SCREEN (window))); } else @@ -4067,7 +4067,7 @@ gdk_window_stick (GdkWindow *window) /* Request desktop 0xFFFFFFFF */ memset (&xclient, 0, sizeof (xclient)); xclient.type = ClientMessage; - xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.window = GDK_WINDOW_XID (window); xclient.display = GDK_WINDOW_XDISPLAY (window); xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "_NET_WM_DESKTOP"); @@ -5541,7 +5541,7 @@ _gdk_windowing_window_set_composited (GdkWindow *window, display = gdk_window_get_display (window); dpy = GDK_DISPLAY_XDISPLAY (display); - xid = GDK_WINDOW_XWINDOW (private); + xid = GDK_WINDOW_XID (private); if (composited) { @@ -5642,7 +5642,7 @@ gdk_x11_get_server_time (GdkWindow *window) g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0); xdisplay = GDK_WINDOW_XDISPLAY (window); - xwindow = GDK_WINDOW_XWINDOW (window); + xwindow = GDK_WINDOW_XID (window); timestamp_prop_atom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "GDK_TIMESTAMP_PROP"); diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 0a6178ee24..911f93bf97 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -118,7 +118,6 @@ gint gdk_x11_get_default_screen (void); */ #define GDK_WINDOW_XDISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xdisplay) #define GDK_WINDOW_XID(win) (GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) -#define GDK_WINDOW_XWINDOW(win) (GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) #define GDK_SCREEN_XDISPLAY(screen) (GDK_SCREEN_X11 (screen)->xdisplay) @@ -159,11 +158,11 @@ gint gdk_x11_get_default_screen (void); #define GDK_WINDOW_XID(win) (gdk_x11_window_get_xid (win)) /** - * GDK_WINDOW_XWINDOW: + * GDK_WINDOW_XID: * * Another name for GDK_DRAWABLE_XID(). */ -#define GDK_WINDOW_XWINDOW(win) (gdk_x11_window_get_xid (win)) +#define GDK_WINDOW_XID(win) (gdk_x11_window_get_xid (win)) #define GDK_SCREEN_XDISPLAY(screen) (gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen))) #define GDK_SCREEN_XSCREEN(screen) (gdk_x11_screen_get_xscreen (screen)) diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c index ca3af73c27..df98e93e29 100644 --- a/gtk/gtkplug-x11.c +++ b/gtk/gtkplug-x11.c @@ -57,7 +57,7 @@ static void xembed_set_info (GdkWindow *window, GdkNativeWindow _gtk_plug_windowing_get_id (GtkPlug *plug) { - return GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (plug))); + return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (plug))); } void @@ -146,7 +146,7 @@ xembed_set_info (GdkWindow *window, buffer[1] = flags; XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), xembed_info_atom, xembed_info_atom, 32, PropModeReplace, (unsigned char *)buffer, 2); @@ -280,7 +280,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, * Probably need check in _gtk_plug_add_to_socket */ - if (xre->parent != GDK_WINDOW_XWINDOW (priv->socket_window)) + if (xre->parent != GDK_WINDOW_XID (priv->socket_window)) { GtkWidget *widget = GTK_WIDGET (plug); @@ -297,7 +297,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, * be invisible to the app. */ - if (xre->parent == GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen))) + if (xre->parent == GDK_WINDOW_XID (gdk_screen_get_root_window (screen))) { GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: calling gtk_plug_send_delete_event()")); _gtk_plug_send_delete_event (widget); @@ -309,7 +309,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, goto done; } - if (xre->parent != GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen))) + if (xre->parent != GDK_WINDOW_XID (gdk_screen_get_root_window (screen))) { /* Start of embedding protocol */ diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 70b3c055c8..4148f37b23 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -2567,7 +2567,7 @@ _gtk_selection_incr_event (GdkWindow *window, #ifdef DEBUG_SELECTION g_message ("INCR: put %d bytes (offset = %d) into window 0x%lx , property %ld", num_bytes, info->conversions[i].offset, - GDK_WINDOW_XWINDOW(info->requestor), event->atom); + GDK_WINDOW_XID(info->requestor), event->atom); #endif bytes_per_item = gtk_selection_bytes_per_item (info->conversions[i].data.format); diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c index b408fa6bcb..c5f2824f88 100644 --- a/gtk/gtksocket-x11.c +++ b/gtk/gtksocket-x11.c @@ -57,7 +57,7 @@ static gboolean xembed_get_info (GdkWindow *gdk_window, GdkNativeWindow _gtk_socket_windowing_get_id (GtkSocket *socket) { - return GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket))); + return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))); } void @@ -69,7 +69,7 @@ _gtk_socket_windowing_realize_window (GtkSocket *socket) window = gtk_widget_get_window (GTK_WIDGET (socket)); XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), &xattrs); /* Sooooo, it turns out that mozilla, as per the gtk2xt code selects @@ -81,7 +81,7 @@ _gtk_socket_windowing_realize_window (GtkSocket *socket) this for GtkSocket, so we unselect it here, fixing the crashes in firefox. */ XSelectInput (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), (xattrs.your_event_mask & ~ButtonPressMask) | SubstructureNotifyMask | SubstructureRedirectMask); } @@ -90,7 +90,7 @@ void _gtk_socket_windowing_end_embedding_toplevel (GtkSocket *socket) { gtk_window_remove_embedded_xid (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))), - GDK_WINDOW_XWINDOW (socket->plug_window)); + GDK_WINDOW_XID (socket->plug_window)); } void @@ -105,7 +105,7 @@ _gtk_socket_windowing_size_request (GtkSocket *socket) socket->request_height = 1; if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (socket->plug_window), - GDK_WINDOW_XWINDOW (socket->plug_window), + GDK_WINDOW_XID (socket->plug_window), &hints, &supplied)) { if (hints.flags & PMinSize) @@ -134,8 +134,8 @@ _gtk_socket_windowing_send_key_event (GtkSocket *socket, memset (&xkey, 0, sizeof (xkey)); xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease; - xkey.window = GDK_WINDOW_XWINDOW (socket->plug_window); - xkey.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); + xkey.window = GDK_WINDOW_XID (socket->plug_window); + xkey.root = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); xkey.subwindow = None; xkey.time = gdk_event->key.time; xkey.x = 0; @@ -148,7 +148,7 @@ _gtk_socket_windowing_send_key_event (GtkSocket *socket, gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window), - GDK_WINDOW_XWINDOW (socket->plug_window), + GDK_WINDOW_XID (socket->plug_window), False, (mask_key_presses ? KeyPressMask : NoEventMask), (XEvent *)&xkey); @@ -220,8 +220,8 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket) memset (&xconfigure, 0, sizeof (xconfigure)); xconfigure.type = ConfigureNotify; - xconfigure.event = GDK_WINDOW_XWINDOW (socket->plug_window); - xconfigure.window = GDK_WINDOW_XWINDOW (socket->plug_window); + xconfigure.event = GDK_WINDOW_XID (socket->plug_window); + xconfigure.window = GDK_WINDOW_XID (socket->plug_window); /* The ICCCM says that synthetic events should have root relative * coordinates. We still aren't really ICCCM compliant, since @@ -243,7 +243,7 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket) gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window), - GDK_WINDOW_XWINDOW (socket->plug_window), + GDK_WINDOW_XID (socket->plug_window), False, NoEventMask, (XEvent *)&xconfigure); gdk_error_trap_pop_ignored (); } @@ -252,7 +252,7 @@ void _gtk_socket_windowing_select_plug_window_input (GtkSocket *socket) { XSelectInput (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))), - GDK_WINDOW_XWINDOW (socket->plug_window), + GDK_WINDOW_XID (socket->plug_window), StructureNotifyMask | PropertyChangeMask); } @@ -283,13 +283,13 @@ _gtk_socket_windowing_embed_notify (GtkSocket *socket) gdk_error_trap_push (); XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (socket->plug_window), + GDK_WINDOW_XID (socket->plug_window), SetModeInsert, SaveSetRoot, SaveSetUnmap); gdk_error_trap_pop_ignored (); #endif _gtk_xembed_send_message (socket->plug_window, XEMBED_EMBEDDED_NOTIFY, 0, - GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket))), + GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))), socket->xembed_version); } @@ -309,7 +309,7 @@ xembed_get_info (GdkWindow *window, gdk_error_trap_push (); status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (window), + GDK_WINDOW_XID (window), xembed_info_atom, 0, 2, False, xembed_info_atom, &type, &format, @@ -508,7 +508,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, /* Note that we get destroy notifies both from SubstructureNotify on * our window and StructureNotify on socket->plug_window */ - if (socket->plug_window && (xdwe->window == GDK_WINDOW_XWINDOW (socket->plug_window))) + if (socket->plug_window && (xdwe->window == GDK_WINDOW_XID (socket->plug_window))) { gboolean result; @@ -554,7 +554,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, break; case PropertyNotify: if (socket->plug_window && - xevent->xproperty.window == GDK_WINDOW_XWINDOW (socket->plug_window)) + xevent->xproperty.window == GDK_WINDOW_XID (socket->plug_window)) { GdkDragProtocol protocol; @@ -615,7 +615,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received")); if (!socket->plug_window && - xre->parent == GDK_WINDOW_XWINDOW (window)) + xre->parent == GDK_WINDOW_XID (window)) { _gtk_socket_add_window (socket, xre->window, FALSE); @@ -629,8 +629,8 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, else { if (socket->plug_window && - xre->window == GDK_WINDOW_XWINDOW (socket->plug_window) && - xre->parent != GDK_WINDOW_XWINDOW (window)) + xre->window == GDK_WINDOW_XID (socket->plug_window) && + xre->parent != GDK_WINDOW_XID (window)) { gboolean result; @@ -650,7 +650,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, } case UnmapNotify: if (socket->plug_window && - xevent->xunmap.window == GDK_WINDOW_XWINDOW (socket->plug_window)) + xevent->xunmap.window == GDK_WINDOW_XID (socket->plug_window)) { GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Unmap notify")); diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 0d9b3afd17..150b634823 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -879,9 +879,9 @@ gtk_tray_icon_realize (GtkWidget *widget) GTK_NOTE (PLUGSOCKET, g_print ("GtkStatusIcon %p: realized, window: %lx, socket window: %lx\n", widget, - (gulong) GDK_WINDOW_XWINDOW (window), + (gulong) GDK_WINDOW_XID (window), gtk_plug_get_socket_window (GTK_PLUG (icon)) ? - (gulong) GDK_WINDOW_XWINDOW (gtk_plug_get_socket_window (GTK_PLUG (icon))) : 0UL)); + (gulong) GDK_WINDOW_XID (gtk_plug_get_socket_window (GTK_PLUG (icon))) : 0UL)); if (icon->priv->manager_window != None) gtk_tray_icon_send_dock_request (icon); diff --git a/gtk/gtkxembed.c b/gtk/gtkxembed.c index 7353e30cd3..5c900fc479 100644 --- a/gtk/gtkxembed.c +++ b/gtk/gtkxembed.c @@ -153,7 +153,7 @@ _gtk_xembed_send_message (GdkWindow *recipient, g_message ("Sending %s", _gtk_xembed_message_name (message))); memset (&xclient, 0, sizeof (xclient)); - xclient.window = GDK_WINDOW_XWINDOW (recipient); + xclient.window = GDK_WINDOW_XID (recipient); xclient.type = ClientMessage; xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"); xclient.format = 32; @@ -165,7 +165,7 @@ _gtk_xembed_send_message (GdkWindow *recipient, gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY(recipient), - GDK_WINDOW_XWINDOW (recipient), + GDK_WINDOW_XID (recipient), False, NoEventMask, (XEvent *)&xclient); gdk_error_trap_pop_ignored (); } diff --git a/modules/other/gail/gailwindow.c b/modules/other/gail/gailwindow.c index a99e43036d..75d9a1c1d5 100644 --- a/modules/other/gail/gailwindow.c +++ b/modules/other/gail/gailwindow.c @@ -723,7 +723,7 @@ get_stacked_windows (GailScreenInfo *info) gdk_error_trap_push (); ret_type = None; result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - GDK_WINDOW_XWINDOW (info->root_window), + GDK_WINDOW_XID (info->root_window), _net_client_list_stacking, 0, G_MAXLONG, False, XA_WINDOW, &ret_type, &format, &nitems, @@ -920,11 +920,11 @@ init_gail_screen (GdkScreen *screen, get_stacked_windows (&gail_screens [screen_n]); XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - GDK_WINDOW_XWINDOW (gail_screens [screen_n].root_window), + GDK_WINDOW_XID (gail_screens [screen_n].root_window), &attrs); XSelectInput (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - GDK_WINDOW_XWINDOW (gail_screens [screen_n].root_window), + GDK_WINDOW_XID (gail_screens [screen_n].root_window), attrs.your_event_mask | PropertyChangeMask); gail_screens [screen_n].screen_initialized = TRUE; From 072498ae87256b5ff2cbf6555128a9791b091245 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:23:31 +0100 Subject: [PATCH 029/634] gdk: Make _gdk_window_ref_cairo_surface() protected and use it ... instead of _gdk_drawable_ref_cairo_surface() where appropriate. Also, don't implement the drawable->create_cairo_surface vfunc anymore. This is in preparation for the split of GdkWindow from GdkDrawable. --- gdk/gdkcairo.c | 2 +- gdk/gdkinternals.h | 3 +++ gdk/gdkoffscreenwindow.c | 2 +- gdk/gdkpixbuf-drawable.c | 2 +- gdk/gdkwindow.c | 42 ++++++++++++++++++---------------------- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 7fe0ccc770..a82e97f75b 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -299,7 +299,7 @@ gdk_cairo_set_source_window (cairo_t *cr, g_return_if_fail (cr != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - surface = _gdk_drawable_ref_cairo_surface (GDK_DRAWABLE (window)); + surface = _gdk_window_ref_cairo_surface (window); cairo_set_source_surface (cr, surface, x, y); cairo_surface_destroy (surface); } diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index f25672fd58..445c255bfb 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -327,6 +327,9 @@ cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable, * Interfaces used by windowing code * *************************************/ +cairo_surface_t * + _gdk_window_ref_cairo_surface (GdkWindow *window); + void _gdk_window_impl_new (GdkWindow *window, GdkWindow *real_parent, GdkScreen *screen, diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index f7c071b16c..9f321eb4f2 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -160,7 +160,7 @@ _gdk_offscreen_window_create_surface (GdkWindow *offscreen, g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (private->impl), NULL); - similar = _gdk_drawable_ref_cairo_surface ((GdkWindow *)private->parent); + similar = _gdk_window_ref_cairo_surface ((GdkWindow *)private->parent); if (gdk_window_get_visual (offscreen) == gdk_screen_get_rgba_visual (gdk_window_get_screen (offscreen))) diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index 3869099e08..fd14b9e352 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -91,7 +91,7 @@ gdk_pixbuf_get_from_window (GdkWindow *src, g_return_val_if_fail (GDK_IS_WINDOW (src), NULL); g_return_val_if_fail (gdk_window_is_viewable (src), NULL); - surface = _gdk_drawable_ref_cairo_surface (src); + surface = _gdk_window_ref_cairo_surface (src); dest = gdk_pixbuf_get_from_surface (surface, src_x, src_y, width, height); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 776a03bf10..911fbc223c 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -219,10 +219,6 @@ typedef struct { /* Global info */ -static cairo_surface_t *gdk_window_ref_cairo_surface (GdkDrawable *drawable); -static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable, - int width, - int height); static void gdk_window_drop_cairo_surface (GdkWindowObject *private); static void gdk_window_free_paint_stack (GdkWindow *window); @@ -370,7 +366,6 @@ static void gdk_window_class_init (GdkWindowObjectClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -378,9 +373,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass) object_class->set_property = gdk_window_set_property; object_class->get_property = gdk_window_get_property; - drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface; - drawable_class->create_cairo_surface = gdk_window_create_cairo_surface; - klass->create_surface = _gdk_offscreen_window_create_surface; quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window"); @@ -2748,7 +2740,7 @@ gdk_window_get_content (GdkWindow *window) g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - surface = _gdk_drawable_ref_cairo_surface (window); + surface = _gdk_window_ref_cairo_surface (window); content = cairo_surface_get_content (surface); cairo_surface_destroy (surface); @@ -3647,7 +3639,7 @@ gdk_window_clear_backing_region_direct (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - paint.surface = _gdk_drawable_ref_cairo_surface (window); + paint.surface = _gdk_window_ref_cairo_surface (window); cr = setup_backing_rect (window, &paint, 0, 0); @@ -3698,14 +3690,14 @@ gdk_window_cairo_surface_destroy (void *data) } static cairo_surface_t * -gdk_window_create_cairo_surface (GdkDrawable *drawable, +gdk_window_create_cairo_surface (GdkWindow *window, int width, int height) { - GdkWindowObject *private = GDK_WINDOW_OBJECT(drawable); + GdkWindowObject *private = GDK_WINDOW_OBJECT (window); cairo_surface_t *surface, *subsurface; - surface =_gdk_drawable_ref_cairo_surface (private->impl); + surface = _gdk_drawable_ref_cairo_surface (private->impl); if (gdk_window_has_impl (private)) return surface; @@ -3719,12 +3711,16 @@ gdk_window_create_cairo_surface (GdkDrawable *drawable, } -static cairo_surface_t * -gdk_window_ref_cairo_surface (GdkDrawable *drawable) +cairo_surface_t * +_gdk_window_ref_cairo_surface (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject*) drawable; + GdkWindowObject *private; cairo_surface_t *surface; + g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); + + private = (GdkWindowObject*) window; + if (private->paint_stack) { GdkWindowPaint *paint = private->paint_stack->data; @@ -3736,18 +3732,18 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable) { /* This will be drawing directly to the window, so flush implicit paint */ - gdk_window_flush ((GdkWindow *)drawable); + gdk_window_flush (window); if (!private->cairo_surface) { - private->cairo_surface = _gdk_drawable_create_cairo_surface (drawable, - private->width, - private->height); + private->cairo_surface = gdk_window_create_cairo_surface (window, + private->width, + private->height); if (private->cairo_surface) { cairo_surface_set_user_data (private->cairo_surface, &gdk_window_cairo_key, - drawable, gdk_window_cairo_surface_destroy); + window, gdk_window_cairo_surface_destroy); } } else @@ -3786,7 +3782,7 @@ gdk_cairo_create (GdkWindow *window) private = (GdkWindowObject*) window; - surface = _gdk_drawable_ref_cairo_surface (window); + surface = _gdk_window_ref_cairo_surface (window); cr = cairo_create (surface); if (!private->paint_stack) @@ -10056,7 +10052,7 @@ gdk_window_create_similar_surface (GdkWindow * window, g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - window_surface = _gdk_drawable_ref_cairo_surface (window); + window_surface = _gdk_window_ref_cairo_surface (window); surface = cairo_surface_create_similar (window_surface, content, From 62622a94ae6f854b6bfe9a4d1c95acdf78508cd1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:27:46 +0100 Subject: [PATCH 030/634] gdk: Pass Drawable as argument We're not passing a GdKWindow here, but the implementation. --- gdk/gdkoffscreenwindow.c | 2 +- gdk/gdkwindowimpl.h | 2 +- gdk/quartz/gdkwindow-quartz.c | 2 +- gdk/win32/gdkwindow-win32.c | 2 +- gdk/x11/gdkwindow-x11.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index 9f321eb4f2..05fc540e33 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -643,7 +643,7 @@ gdk_offscreen_window_translate (GdkWindow *window, } static cairo_surface_t * -gdk_offscreen_window_resize_cairo_surface (GdkWindow *window, +gdk_offscreen_window_resize_cairo_surface (GdkDrawable *window, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index 1c9d81980b..ce7f663b6b 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -142,7 +142,7 @@ struct _GdkWindowImplIface gboolean recursing, gboolean foreign_destroy); - cairo_surface_t * (* resize_cairo_surface) (GdkWindow *window, + cairo_surface_t * (* resize_cairo_surface) (GdkDrawable *window, cairo_surface_t *surface, gint width, gint height); diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 11d140fd91..0f6745b430 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -1087,7 +1087,7 @@ _gdk_quartz_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_window_quartz_resize_cairo_surface (GdkWindow *window, +gdk_window_quartz_resize_cairo_surface (GdkDrawable *drawable, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 398be8dcb1..7a8cf149f8 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -745,7 +745,7 @@ _gdk_win32_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_win32_window_resize_cairo_surface (GdkWindow *window, +gdk_win32_window_resize_cairo_surface (GdkDrawable *drawable, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index e2cfcb8c02..07155d0d68 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1102,7 +1102,7 @@ _gdk_x11_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_window_x11_resize_cairo_surface (GdkWindow *window, +gdk_window_x11_resize_cairo_surface (GdkDrawable *window, cairo_surface_t *surface, gint width, gint height) From 63808f90a260a99745d7469ad62b553604b197a8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:47:05 +0100 Subject: [PATCH 031/634] gail: Avoid needless calls to GdkDrawable --- modules/other/gail/gailwindow.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/other/gail/gailwindow.c b/modules/other/gail/gailwindow.c index 75d9a1c1d5..73b1993783 100644 --- a/modules/other/gail/gailwindow.c +++ b/modules/other/gail/gailwindow.c @@ -827,8 +827,7 @@ filter_func (GdkXEvent *gdkxevent, if (window) { - screen_n = gdk_screen_get_number ( - gdk_window_get_screen (GDK_DRAWABLE (window))); + screen_n = gdk_screen_get_number (gdk_window_get_screen (window)); gail_screens [screen_n].update_stacked_windows = TRUE; if (!gail_screens [screen_n].update_handler) @@ -965,8 +964,7 @@ get_window_zorder (GdkWindow *window) gail_return_val_if_fail (GDK_IS_WINDOW (window), -1); - info = get_screen_info ( - gdk_window_get_screen (GDK_DRAWABLE (window))); + info = get_screen_info (gdk_window_get_screen (window)); gail_return_val_if_fail (info->stacked_windows != NULL, -1); From a7e6d6c4b4a50181c758db7e7fab650a51804986 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:47:56 +0100 Subject: [PATCH 032/634] gtk: Avoid GdkDrawable usage, including needless casts --- gtk/gtkimcontextsimple.c | 2 +- gtk/gtkimmodule.c | 4 ++-- gtk/gtkimmulticontext.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index d9c70e5b67..1270bb0563 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -692,7 +692,7 @@ check_hex (GtkIMContextSimple *context_simple, static void beep_window (GdkWindow *window) { - GdkScreen *screen = gdk_window_get_screen (GDK_DRAWABLE (window)); + GdkScreen *screen = gdk_window_get_screen (window); gboolean beep; g_object_get (gtk_settings_get_for_screen (screen), diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c index 788631d2ee..868cfe17c2 100644 --- a/gtk/gtkimmodule.c +++ b/gtk/gtkimmodule.c @@ -681,9 +681,9 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window) /* Check if the certain immodule is set in XSETTINGS. */ - if (GDK_IS_DRAWABLE (client_window)) + if (GDK_IS_WINDOW (client_window)) { - screen = gdk_window_get_screen (GDK_DRAWABLE (client_window)); + screen = gdk_window_get_screen (client_window); settings = gtk_settings_get_for_screen (screen); g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL); if (tmp) diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c index a8357babfe..f2454fcb4a 100644 --- a/gtk/gtkimmulticontext.c +++ b/gtk/gtkimmulticontext.c @@ -297,7 +297,7 @@ gtk_im_multicontext_set_client_window (GtkIMContext *context, if (window) { - screen = gdk_window_get_screen (GDK_DRAWABLE (window)); + screen = gdk_window_get_screen (window); settings = gtk_settings_get_for_screen (screen); connected = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings), From 81605623e222350daf36fcd0f86d4089972f6dfd Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:49:41 +0100 Subject: [PATCH 033/634] gdk: Use GdkDrawable for impl pointers ... instead of GdkWindow --- gdk/gdkwindow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 911fbc223c..fd9b541244 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -3472,7 +3472,7 @@ gdk_window_flush_if_exposing (GdkWindow *window) static void gdk_window_flush_recursive_helper (GdkWindowObject *window, - GdkWindow *impl) + GdkDrawable *impl) { GdkWindowObject *child; GList *l; @@ -6194,7 +6194,7 @@ move_native_children (GdkWindowObject *private) static gboolean collect_native_child_region_helper (GdkWindowObject *window, - GdkWindow *impl, + GdkDrawable *impl, cairo_region_t **region, int x_offset, int y_offset) From cf6ce6e671d050a1393fe9f30cfa2bbfc7041313 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:50:06 +0100 Subject: [PATCH 034/634] API: Decouple GdkWindow from GdkDrawable Make GdkWindow no longer typedeffed to GdkDrawable, but instead make it be its own (private) type. --- gdk/gdktypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index 417aec211d..f50d02f49a 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -146,7 +146,7 @@ typedef struct _GdkDrawable GdkDrawable; * * An opaque structure representing an onscreen drawable. */ -typedef struct _GdkDrawable GdkWindow; +typedef struct _GdkWindow GdkWindow; typedef struct _GdkDisplay GdkDisplay; typedef struct _GdkScreen GdkScreen; From 771fa78257d76a9cb973ea45e86a63f101e5d7c0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 17:56:34 +0100 Subject: [PATCH 035/634] textbuffer: Remove check for GdkDrawable This should only have been used for stipple patterns, and those are gone now. --- gtk/gtktextbufferserialize.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c index 16a36d3994..526e9518aa 100644 --- a/gtk/gtktextbufferserialize.c +++ b/gtk/gtktextbufferserialize.c @@ -70,10 +70,6 @@ serialize_value (GValue *value) return g_strdup_printf ("%x:%x:%x", color->red, color->green, color->blue); } - else if (g_type_is_a (value->g_type, GDK_TYPE_DRAWABLE)) - { - /* Don't do anything */ - } else { g_warning ("Type %s is not serializable\n", g_type_name (value->g_type)); From b1f6df80853ce3c79bd9c911ee3f5b2497bedf43 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 18:08:25 +0100 Subject: [PATCH 036/634] API: Remove gdkdrawable.h from public headers It continues to exist as a private header. --- gdk/gdk.h | 1 - gdk/gdkdrawable.h | 5 +---- gdk/gdktypes.h | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/gdk/gdk.h b/gdk/gdk.h index 9bc962201f..851185a8c0 100644 --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index b8799e343d..d790b023ca 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -24,10 +24,6 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ -#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION) -#error "Only can be included directly." -#endif - #ifndef __GDK_DRAWABLE_H__ #define __GDK_DRAWABLE_H__ @@ -38,6 +34,7 @@ G_BEGIN_DECLS +typedef struct _GdkDrawable GdkDrawable; typedef struct _GdkDrawableClass GdkDrawableClass; #define GDK_TYPE_DRAWABLE (gdk_drawable_get_type ()) diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index f50d02f49a..865a7f5226 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -139,8 +139,6 @@ typedef struct _GdkRGBA GdkRGBA; typedef struct _GdkCursor GdkCursor; typedef struct _GdkVisual GdkVisual; -typedef struct _GdkDrawable GdkDrawable; - /** * GdkWindow: * From b3bca70d5b4f9e6c9449c78859179d509d5e0903 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 18:24:24 +0100 Subject: [PATCH 037/634] gdk: Remove unused medialib code --- config.h.win32.in | 6 --- configure.ac | 22 --------- gdk/Makefile.am | 9 ---- gdk/gdkinternals.h | 3 -- gdk/gdkmedialib.c | 120 --------------------------------------------- gdk/gdkmedialib.h | 45 ----------------- 6 files changed, 205 deletions(-) delete mode 100644 gdk/gdkmedialib.c delete mode 100644 gdk/gdkmedialib.h diff --git a/config.h.win32.in b/config.h.win32.in index dec0d03092..23f0156685 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -276,12 +276,6 @@ /* Whether to load modules via .la files rather than directly */ /* #undef USE_LA_MODULES */ -/* Define to 1 if medialib is available and should be used */ -/* #undef USE_MEDIALIB */ - -/* Define to 1 if medialib 2.5 is available */ -/* #undef USE_MEDIALIB25 */ - /* Define to 1 if XXM is available and should be used */ #ifndef _MSC_VER # define USE_MMX 1 diff --git a/configure.ac b/configure.ac index d5ef2b7bb2..477aa7cda8 100644 --- a/configure.ac +++ b/configure.ac @@ -858,28 +858,6 @@ AC_CHECK_HEADER(sys/sysinfo.h, AC_DEFINE(HAVE_SYS_SYSINFO_H, 1, [Define to 1 if sys/sysinfo.h is available])) -AC_MSG_CHECKING(for mediaLib 2.3) -use_mlib25=no -# Check for a mediaLib 2.3 function since that is what the GTK+ mediaLib -# patch requires. -AC_CHECK_LIB(mlib, mlib_ImageSetStruct, use_mlib=yes, use_mlib=no) -if test $use_mlib = yes; then - AC_DEFINE(USE_MEDIALIB, 1, - [Define to 1 if medialib is available and should be used]) - MEDIA_LIB=-lmlib - - AC_MSG_CHECKING(for mediaLib 2.5) - # Check for a mediaLib 2.5 function since that is what is needed for - # gdk_rgb_convert integration. - AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib25=yes, use_mlib25=no) - if test $use_mlib25 = yes; then - AC_DEFINE(USE_MEDIALIB25, 1, - [Define to 1 if medialib 2.5 is available]) - fi -fi -AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes) -AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes) - dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes) diff --git a/gdk/Makefile.am b/gdk/Makefile.am index f4606b94cf..2b2ae6be27 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -21,7 +21,6 @@ EXTRA_DIST += \ gdkkeysyms-update.pl \ gdk.def \ gdkmarshalers.list \ - gdkmedialib.h \ gdkwindowimpl.h \ makeenums.pl \ makefile.msc \ @@ -55,13 +54,6 @@ LDADD = \ $(no_undefined) \ $(LIBTOOL_EXPORT_OPTIONS) -if USE_MEDIALIB -medialib_sources = \ - gdkmedialib.c -else -medialib_sources = -endif - # # setup source file variables # @@ -111,7 +103,6 @@ gdk_private_headers = \ gdkpoly-generic.h gdk_c_sources = \ - $(medialib_sources) \ gdk.c \ gdkapplaunchcontext.c \ gdkcairo.c \ diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 445c255bfb..e1150196c8 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -33,9 +33,6 @@ #include #include #include -#ifdef USE_MEDIALIB -#include -#endif G_BEGIN_DECLS diff --git a/gdk/gdkmedialib.c b/gdk/gdkmedialib.c deleted file mode 100644 index 597726824b..0000000000 --- a/gdk/gdkmedialib.c +++ /dev/null @@ -1,120 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 2001-2007 Sun Microsystems, Inc. All rights reserved. - * (Brian Cameron, Dmitriy Demin, James Cheng, Padraig O'Briain) - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2007. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkmedialib.h" - -#include -#include - -#ifdef HAVE_STRINGS_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#if defined(HAVE_SYS_SYSTEMINFO_H) -#include -#elif defined(HAVE_SYS_SYSINFO_H) -#include -#endif - -typedef char * (*ml_version) (void); - -static ml_version medialib_version = mlib_version; - -gboolean -_gdk_use_medialib (void) -{ - char *mlib_version_string; - char sys_info[257]; - long count; - - /* - * Sun mediaLib(tm) support. - * - * http://www.sun.com/processors/vis/mlib.html - * - */ - if (getenv ("GDK_DISABLE_MEDIALIB")) - return FALSE; - - /* - * The imaging functions we want to use were added in mediaLib version 2. - * So turn off mediaLib support if the user has an older version. - * mlib_version returns a string in this format: - * - * mediaLib:0210:20011101:v8plusa - * ^^^^^^^^ ^^^^ ^^^^^^^^ ^^^^^^^ - * libname vers build ISALIST identifier - * date (in this case sparcv8plus+vis) - * - * The first 2 digits of the version are the major version. The 3rd digit - * is the minor version, and the 4th digit is the micro version. So the - * above string corresponds to version 2.1.0.In the following test we only - * care about the major version. - */ - mlib_version_string = medialib_version (); - - count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257); - - if (count != -1) - { - if (strcmp (sys_info, "i386") == 0) - { - char *mlib_target_isa = &mlib_version_string[23]; - - /* - * For x86 processors mediaLib generic C implementation - * does not give any performance advantage so disable it. - */ - if (strncmp (mlib_target_isa, "sse", 3) != 0) - { - return FALSE; - } - - /* - * For x86 processors use of libumem conflicts with - * mediaLib, so avoid using it. - */ - if (dlsym (RTLD_PROBE, "umem_alloc") != NULL) - { - return FALSE; - } - } - } - else - { - /* Failed to get system architecture, disable mediaLib */ - return FALSE; - } - - return TRUE; -} diff --git a/gdk/gdkmedialib.h b/gdk/gdkmedialib.h deleted file mode 100644 index 1912e9d70d..0000000000 --- a/gdk/gdkmedialib.h +++ /dev/null @@ -1,45 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 2001-2007 Sun Microsystems, Inc. All rights reserved. - * (Brian Cameron, Dmitriy Demin, James Cheng, Padraig O'Briain) - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GDK_MEDIALIB_H__ -#define __GDK_MEDIALIB_H__ - -#ifdef USE_MEDIALIB -#include -#include - -#include - -G_BEGIN_DECLS - -gboolean _gdk_use_medialib (void); - -G_END_DECLS - -#endif /* USE_MEDIALIB */ -#endif /* __GDK_MEDIALIB_H__ */ - From 7acb64f983c2f182d86deb32813ee23ca8957e7b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 22 Nov 2010 20:42:00 +0100 Subject: [PATCH 038/634] gdk: Make GdkWindowImpl a class, not an interface It's a subclass of GdkDrawable and the baseclass for GdkWindowImplX11 etc now. --- gdk/gdkdisplay.c | 2 +- gdk/gdkoffscreenwindow.c | 56 +++++------ gdk/gdkwindow.c | 200 +++++++++++++++++++-------------------- gdk/gdkwindowimpl.c | 10 +- gdk/gdkwindowimpl.h | 21 ++-- gdk/x11/gdkwindow-x11.c | 84 ++++++++-------- gdk/x11/gdkwindow-x11.h | 5 +- 7 files changed, 187 insertions(+), 191 deletions(-) diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 564d4b5ca5..71ba823341 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -940,7 +940,7 @@ gdk_window_real_window_get_device_position (GdkDisplay *display, private = (GdkWindowObject *) window; - normal_child = GDK_WINDOW_IMPL_GET_IFACE (private->impl)->get_device_state (window, + normal_child = GDK_WINDOW_IMPL_GET_CLASS (private->impl)->get_device_state (window, device, &tmpx, &tmpy, &tmp_mask); diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index 05fc540e33..b139096a44 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -44,7 +44,7 @@ typedef struct _GdkOffscreenWindowClass GdkOffscreenWindowClass; struct _GdkOffscreenWindow { - GdkDrawable parent_instance; + GdkWindowImpl parent_instance; GdkWindow *wrapper; @@ -54,7 +54,7 @@ struct _GdkOffscreenWindow struct _GdkOffscreenWindowClass { - GdkDrawableClass parent_class; + GdkWindowImplClass parent_class; }; #define GDK_TYPE_OFFSCREEN_WINDOW (gdk_offscreen_window_get_type()) @@ -64,14 +64,9 @@ struct _GdkOffscreenWindowClass #define GDK_IS_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_OFFSCREEN_WINDOW)) #define GDK_OFFSCREEN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass)) -static void gdk_offscreen_window_impl_iface_init (GdkWindowImplIface *iface); static void gdk_offscreen_window_hide (GdkWindow *window); -G_DEFINE_TYPE_WITH_CODE (GdkOffscreenWindow, - gdk_offscreen_window, - GDK_TYPE_DRAWABLE, - G_IMPLEMENT_INTERFACE (GDK_TYPE_WINDOW_IMPL, - gdk_offscreen_window_impl_iface_init)); +G_DEFINE_TYPE (GdkOffscreenWindow, gdk_offscreen_window, GDK_TYPE_WINDOW_IMPL) static void @@ -727,35 +722,32 @@ gdk_offscreen_window_get_embedder (GdkWindow *window) static void gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass) { + GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gdk_offscreen_window_finalize; drawable_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface; -} -static void -gdk_offscreen_window_impl_iface_init (GdkWindowImplIface *iface) -{ - iface->show = gdk_offscreen_window_show; - iface->hide = gdk_offscreen_window_hide; - iface->withdraw = gdk_offscreen_window_withdraw; - iface->raise = gdk_offscreen_window_raise; - iface->lower = gdk_offscreen_window_lower; - iface->move_resize = gdk_offscreen_window_move_resize; - iface->set_background = gdk_offscreen_window_set_background; - iface->get_events = gdk_offscreen_window_get_events; - iface->set_events = gdk_offscreen_window_set_events; - iface->reparent = gdk_offscreen_window_reparent; - iface->get_geometry = gdk_offscreen_window_get_geometry; - iface->shape_combine_region = gdk_offscreen_window_shape_combine_region; - iface->input_shape_combine_region = gdk_offscreen_window_input_shape_combine_region; - iface->set_static_gravities = gdk_offscreen_window_set_static_gravities; - iface->queue_antiexpose = gdk_offscreen_window_queue_antiexpose; - iface->translate = gdk_offscreen_window_translate; - iface->get_root_coords = gdk_offscreen_window_get_root_coords; - iface->get_device_state = gdk_offscreen_window_get_device_state; - iface->destroy = gdk_offscreen_window_destroy; - iface->resize_cairo_surface = gdk_offscreen_window_resize_cairo_surface; + impl_class->show = gdk_offscreen_window_show; + impl_class->hide = gdk_offscreen_window_hide; + impl_class->withdraw = gdk_offscreen_window_withdraw; + impl_class->raise = gdk_offscreen_window_raise; + impl_class->lower = gdk_offscreen_window_lower; + impl_class->move_resize = gdk_offscreen_window_move_resize; + impl_class->set_background = gdk_offscreen_window_set_background; + impl_class->get_events = gdk_offscreen_window_get_events; + impl_class->set_events = gdk_offscreen_window_set_events; + impl_class->reparent = gdk_offscreen_window_reparent; + impl_class->get_geometry = gdk_offscreen_window_get_geometry; + impl_class->shape_combine_region = gdk_offscreen_window_shape_combine_region; + impl_class->input_shape_combine_region = gdk_offscreen_window_input_shape_combine_region; + impl_class->set_static_gravities = gdk_offscreen_window_set_static_gravities; + impl_class->queue_antiexpose = gdk_offscreen_window_queue_antiexpose; + impl_class->translate = gdk_offscreen_window_translate; + impl_class->get_root_coords = gdk_offscreen_window_get_root_coords; + impl_class->get_device_state = gdk_offscreen_window_get_device_state; + impl_class->destroy = gdk_offscreen_window_destroy; + impl_class->resize_cairo_surface = gdk_offscreen_window_resize_cairo_surface; } diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index fd9b541244..4760e454b4 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -830,18 +830,18 @@ static void apply_shape (GdkWindowObject *private, cairo_region_t *region) { - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; /* We trash whether we applied a shape so that we can avoid unsetting it many times, which could happen in e.g. apply_clip_as_shape as windows get resized */ - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); if (region) - impl_iface->shape_combine_region ((GdkWindow *)private, + impl_class->shape_combine_region ((GdkWindow *)private, region, 0, 0); else if (private->applied_shape) - impl_iface->shape_combine_region ((GdkWindow *)private, + impl_class->shape_combine_region ((GdkWindow *)private, NULL, 0, 0); private->applied_shape = region != NULL; @@ -1055,7 +1055,7 @@ recompute_visible_regions_internal (GdkWindowObject *private, if (private->cairo_surface && gdk_window_has_impl (private)) { - GdkWindowImplIface *iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + GdkWindowImplClass *iface = GDK_WINDOW_IMPL_GET_CLASS (private->impl); private->cairo_surface = iface->resize_cairo_surface (private->impl, private->cairo_surface, @@ -1245,17 +1245,17 @@ sync_native_window_stack_position (GdkWindow *window) { GdkWindowObject *above; GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GList listhead = {0}; private = (GdkWindowObject *) window; - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); above = find_native_sibling_above (private->parent, private); if (above) { listhead.data = window; - impl_iface->restack_under ((GdkWindow *)above, + impl_class->restack_under ((GdkWindow *)above, &listhead); } } @@ -1516,9 +1516,9 @@ reparent_to_impl (GdkWindowObject *private) GList *l; GdkWindowObject *child; gboolean show; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); /* Enumerate in reverse order so we get the right order for the native windows (first in childrens list is topmost, and reparent places on top) */ @@ -1530,7 +1530,7 @@ reparent_to_impl (GdkWindowObject *private) reparent_to_impl (child); else { - show = impl_iface->reparent ((GdkWindow *)child, + show = impl_class->reparent ((GdkWindow *)child, (GdkWindow *)private, child->x, child->y); if (show) @@ -1564,7 +1564,7 @@ gdk_window_reparent (GdkWindow *window, gboolean show, was_mapped, applied_clip_as_shape; gboolean do_reparent_to_impl; GdkEventMask old_native_event_mask; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent)); @@ -1593,7 +1593,7 @@ gdk_window_reparent (GdkWindow *window, To make sure we're ok, just wipe it. */ gdk_window_drop_cairo_surface (private); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); old_parent = private->parent; was_mapped = GDK_WINDOW_IS_MAPPED (window); @@ -1612,7 +1612,7 @@ gdk_window_reparent (GdkWindow *window, { old_native_event_mask = get_native_event_mask (private); /* Native window */ - show = impl_iface->reparent (window, new_parent, x, y); + show = impl_class->reparent (window, new_parent, x, y); } else { @@ -1680,7 +1680,7 @@ gdk_window_reparent (GdkWindow *window, GdkEventMask native_event_mask = get_native_event_mask (private); if (native_event_mask != old_native_event_mask) - impl_iface->set_events (window, native_event_mask); + impl_class->set_events (window, native_event_mask); } _gdk_window_update_viewable (window); @@ -1798,7 +1798,7 @@ gdk_window_ensure_native (GdkWindow *window) GdkScreen *screen; GdkWindowObject *above; GList listhead; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean disabled_extension_events; g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); @@ -1840,7 +1840,7 @@ gdk_window_ensure_native (GdkWindow *window) private->impl = old_impl; change_impl (private, private, new_impl); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); /* Native window creation will put the native window topmost in the * native parent, which may be wrong wrt the position of the previous @@ -1852,7 +1852,7 @@ gdk_window_ensure_native (GdkWindow *window) listhead.data = window; listhead.prev = NULL; listhead.next = NULL; - impl_iface->restack_under ((GdkWindow *)above, &listhead); + impl_class->restack_under ((GdkWindow *)above, &listhead); } recompute_visible_regions (private, FALSE, FALSE); @@ -1866,15 +1866,15 @@ gdk_window_ensure_native (GdkWindow *window) if (!private->input_only) { - impl_iface->set_background (window, private->background); + impl_class->set_background (window, private->background); } - impl_iface->input_shape_combine_region (window, + impl_class->input_shape_combine_region (window, private->input_shape, 0, 0); if (gdk_window_is_viewable (window)) - impl_iface->show (window, FALSE); + impl_class->show (window, FALSE); if (disabled_extension_events) reenable_extension_events (private); @@ -1949,7 +1949,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, { GdkWindowObject *private; GdkWindowObject *temp_private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GdkWindow *temp_window; GdkScreen *screen; GdkDisplay *display; @@ -2054,10 +2054,10 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, gdk_window_drop_cairo_surface (private); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); if (gdk_window_has_impl (private)) - impl_iface->destroy (window, recursing_native, + impl_class->destroy (window, recursing_native, foreign_destroy); else { @@ -3183,11 +3183,11 @@ do_move_region_bits_on_impl (GdkWindowObject *impl_window, cairo_region_t *dest_region, /* In impl window coords */ int dx, int dy) { - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (impl_window->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (impl_window->impl); - impl_iface->translate ((GdkWindow *) impl_window, dest_region, dx, dy); + impl_class->translate ((GdkWindow *) impl_window, dest_region, dx, dy); } static GdkWindowRegionMove * @@ -4074,7 +4074,7 @@ static void gdk_window_process_updates_internal (GdkWindow *window) { GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean save_region = FALSE; GdkRectangle clip_box; @@ -4191,8 +4191,8 @@ gdk_window_process_updates_internal (GdkWindow *window) * moves and queue antiexposure immediately. No need to do * any tricks */ gdk_window_flush_outstanding_moves (window); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - save_region = impl_iface->queue_antiexpose (window, update_area); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + save_region = impl_class->queue_antiexpose (window, update_area); } /* Render the invalid areas to the implicit paint, by sending exposes. @@ -4214,8 +4214,8 @@ gdk_window_process_updates_internal (GdkWindow *window) if (private->implicit_paint != NULL && !private->implicit_paint->flushed) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - save_region = impl_iface->queue_antiexpose (window, update_area); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + save_region = impl_class->queue_antiexpose (window, update_area); } gdk_window_end_implicit_paint (window); @@ -5240,7 +5240,7 @@ gdk_window_raise_internal (GdkWindow *window) GdkWindowObject *above; GList *native_children; GList *l, listhead; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; if (parent) { @@ -5248,7 +5248,7 @@ gdk_window_raise_internal (GdkWindow *window) parent->children = g_list_prepend (parent->children, window); } - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); /* Just do native raise for toplevels */ if (gdk_window_is_toplevel (private) || /* The restack_under codepath should work correctly even if the parent @@ -5258,7 +5258,7 @@ gdk_window_raise_internal (GdkWindow *window) when using native windows */ (gdk_window_has_impl (private) && gdk_window_has_impl (parent))) { - impl_iface->raise (window); + impl_class->raise (window); } else if (gdk_window_has_impl (private)) { @@ -5268,11 +5268,11 @@ gdk_window_raise_internal (GdkWindow *window) listhead.data = window; listhead.next = NULL; listhead.prev = NULL; - impl_iface->restack_under ((GdkWindow *)above, + impl_class->restack_under ((GdkWindow *)above, &listhead); } else - impl_iface->raise (window); + impl_class->raise (window); } else { @@ -5283,13 +5283,13 @@ gdk_window_raise_internal (GdkWindow *window) above = find_native_sibling_above (parent, private); if (above) - impl_iface->restack_under ((GdkWindow *)above, + impl_class->restack_under ((GdkWindow *)above, native_children); else { /* Right order, since native_children is bottom-topmost first */ for (l = native_children; l != NULL; l = l->next) - impl_iface->raise (l->data); + impl_class->raise (l->data); } g_list_free (native_children); @@ -5304,7 +5304,7 @@ set_viewable (GdkWindowObject *w, gboolean val) { GdkWindowObject *child; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GList *l; if (w->viewable == val) @@ -5355,11 +5355,11 @@ set_viewable (GdkWindowObject *w, * like this, so we just always show/hide directly. */ - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (w->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (w->impl); if (val) - impl_iface->show ((GdkWindow *)w, FALSE); + impl_class->show ((GdkWindow *)w, FALSE); else - impl_iface->hide ((GdkWindow *)w); + impl_class->hide ((GdkWindow *)w); return TRUE; } @@ -5390,7 +5390,7 @@ static void gdk_window_show_internal (GdkWindow *window, gboolean raise) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean was_mapped, was_viewable; gboolean did_show; @@ -5428,8 +5428,8 @@ gdk_window_show_internal (GdkWindow *window, gboolean raise) Also show if not done by gdk_window_update_viewable. */ if (gdk_window_has_impl (private) && (was_viewable || !did_show)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->show ((GdkWindow *)private, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->show ((GdkWindow *)private, !did_show ? was_mapped : TRUE); } @@ -5528,7 +5528,7 @@ gdk_window_lower_internal (GdkWindow *window) { GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *parent = private->parent; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GdkWindowObject *above; GList *native_children; GList *l, listhead; @@ -5539,7 +5539,7 @@ gdk_window_lower_internal (GdkWindow *window) parent->children = g_list_append (parent->children, window); } - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); /* Just do native lower for toplevels */ if (gdk_window_is_toplevel (private) || /* The restack_under codepath should work correctly even if the parent @@ -5549,7 +5549,7 @@ gdk_window_lower_internal (GdkWindow *window) when using native windows */ (gdk_window_has_impl (private) && gdk_window_has_impl (parent))) { - impl_iface->lower (window); + impl_class->lower (window); } else if (gdk_window_has_impl (private)) { @@ -5559,10 +5559,10 @@ gdk_window_lower_internal (GdkWindow *window) listhead.data = window; listhead.next = NULL; listhead.prev = NULL; - impl_iface->restack_under ((GdkWindow *)above, &listhead); + impl_class->restack_under ((GdkWindow *)above, &listhead); } else - impl_iface->raise (window); + impl_class->raise (window); } else { @@ -5573,13 +5573,13 @@ gdk_window_lower_internal (GdkWindow *window) above = find_native_sibling_above (parent, private); if (above) - impl_iface->restack_under ((GdkWindow *)above, + impl_class->restack_under ((GdkWindow *)above, native_children); else { /* Right order, since native_children is bottom-topmost first */ for (l = native_children; l != NULL; l = l->next) - impl_iface->raise (l->data); + impl_class->raise (l->data); } g_list_free (native_children); @@ -5673,7 +5673,7 @@ gdk_window_restack (GdkWindow *window, gboolean above) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GdkWindowObject *parent; GdkWindowObject *above_native; GList *sibling_link; @@ -5701,8 +5701,8 @@ gdk_window_restack (GdkWindow *window, if (gdk_window_is_toplevel (private)) { g_return_if_fail (gdk_window_is_toplevel (GDK_WINDOW_OBJECT (sibling))); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->restack_toplevel (window, sibling, above); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->restack_toplevel (window, sibling, above); return; } @@ -5724,7 +5724,7 @@ gdk_window_restack (GdkWindow *window, sibling_link->next, window); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); if (gdk_window_has_impl (private)) { above_native = find_native_sibling_above (parent, private); @@ -5733,10 +5733,10 @@ gdk_window_restack (GdkWindow *window, listhead.data = window; listhead.next = NULL; listhead.prev = NULL; - impl_iface->restack_under ((GdkWindow *)above_native, &listhead); + impl_class->restack_under ((GdkWindow *)above_native, &listhead); } else - impl_iface->raise (window); + impl_class->raise (window); } else { @@ -5746,13 +5746,13 @@ gdk_window_restack (GdkWindow *window, { above_native = find_native_sibling_above (parent, private); if (above_native) - impl_iface->restack_under ((GdkWindow *)above_native, + impl_class->restack_under ((GdkWindow *)above_native, native_children); else { /* Right order, since native_children is bottom-topmost first */ for (l = native_children; l != NULL; l = l->next) - impl_iface->raise (l->data); + impl_class->raise (l->data); } g_list_free (native_children); @@ -5800,7 +5800,7 @@ void gdk_window_hide (GdkWindow *window) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean was_mapped, did_hide; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -5854,8 +5854,8 @@ gdk_window_hide (GdkWindow *window) /* Hide foreign window as those are not handled by update_viewable. */ if (gdk_window_has_impl (private) && (!did_hide)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->hide (window); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->hide (window); } recompute_visible_regions (private, TRUE, FALSE); @@ -5891,7 +5891,7 @@ void gdk_window_withdraw (GdkWindow *window) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean was_mapped; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -5904,8 +5904,8 @@ gdk_window_withdraw (GdkWindow *window) if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->withdraw (window); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->withdraw (window); if (was_mapped) { @@ -5938,7 +5938,7 @@ gdk_window_set_events (GdkWindow *window, GdkEventMask event_mask) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -5965,8 +5965,8 @@ gdk_window_set_events (GdkWindow *window, if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->set_events (window, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->set_events (window, get_native_event_mask (private)); } @@ -6114,7 +6114,7 @@ gdk_window_move_resize_toplevel (GdkWindow *window, { GdkWindowObject *private; cairo_region_t *old_region, *new_region; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean expose; int old_x, old_y, old_abs_x, old_abs_y; int dx, dy; @@ -6137,8 +6137,8 @@ gdk_window_move_resize_toplevel (GdkWindow *window, old_region = cairo_region_copy (private->clip_region); } - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->move_resize (window, with_move, x, y, width, height); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->move_resize (window, with_move, x, y, width, height); dx = private->x - old_x; dy = private->y - old_y; @@ -6174,7 +6174,7 @@ move_native_children (GdkWindowObject *private) { GList *l; GdkWindowObject *child; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; for (l = private->children; l; l = l->next) { @@ -6182,8 +6182,8 @@ move_native_children (GdkWindowObject *private) if (child->impl != private->impl) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (child->impl); - impl_iface->move_resize ((GdkWindow *)child, TRUE, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (child->impl); + impl_class->move_resize ((GdkWindow *)child, TRUE, child->x, child->y, child->width, child->height); } @@ -6262,7 +6262,7 @@ gdk_window_move_resize_internal (GdkWindow *window, cairo_region_t *old_region, *new_region, *copy_area; cairo_region_t *old_native_child_region, *new_native_child_region; GdkWindowObject *impl_window; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; gboolean expose; int old_x, old_y, old_abs_x, old_abs_y; int dx, dy; @@ -6359,11 +6359,11 @@ gdk_window_move_resize_internal (GdkWindow *window, if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); /* Do the actual move after recomputing things, as this will have set the shape to the now correct one, thus avoiding copying regions that should not be copied. */ - impl_iface->move_resize (window, TRUE, + impl_class->move_resize (window, TRUE, private->x, private->y, private->width, private->height); } @@ -6793,8 +6793,8 @@ gdk_window_set_background_pattern (GdkWindow *window, if (gdk_window_has_impl (private) && !private->input_only) { - GdkWindowImplIface *impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->set_background (window, pattern); + GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->set_background (window, pattern); } } @@ -6833,7 +6833,7 @@ update_cursor_foreach (GdkDisplay *display, if (_gdk_native_windows || private->window_type == GDK_WINDOW_ROOT || private->window_type == GDK_WINDOW_FOREIGN) - GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_device_cursor (window, device, private->cursor); + GDK_WINDOW_IMPL_GET_CLASS (private->impl)->set_device_cursor (window, device, private->cursor); else if (_gdk_window_event_parent_of (window, pointer_info->window_under_pointer)) update_cursor (display, device); } @@ -7023,7 +7023,7 @@ gdk_window_get_geometry (GdkWindow *window, gint *depth) { GdkWindowObject *private, *parent; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; if (!window) { @@ -7041,8 +7041,8 @@ gdk_window_get_geometry (GdkWindow *window, { if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->get_geometry (window, x, y, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->get_geometry (window, x, y, width, height, depth); /* This reports the position wrt to the native parent, we need to convert @@ -7143,7 +7143,7 @@ gdk_window_get_origin (GdkWindow *window, gint *y) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; g_return_val_if_fail (GDK_IS_WINDOW (window), 0); @@ -7158,8 +7158,8 @@ gdk_window_get_origin (GdkWindow *window, private = (GdkWindowObject *) window; - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->get_root_coords (window, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->get_root_coords (window, private->abs_x, private->abs_y, x, y); @@ -7190,7 +7190,7 @@ gdk_window_get_root_coords (GdkWindow *window, gint *root_y) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -7205,8 +7205,8 @@ gdk_window_get_root_coords (GdkWindow *window, return; } - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->get_root_coords (window, + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->get_root_coords (window, x + private->abs_x, y + private->abs_y, root_x, root_y); @@ -7525,7 +7525,7 @@ gdk_window_input_shape_combine_region (GdkWindow *window, gint offset_y) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -7547,8 +7547,8 @@ gdk_window_input_shape_combine_region (GdkWindow *window, if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - impl_iface->input_shape_combine_region (window, private->input_shape, 0, 0); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class->input_shape_combine_region (window, private->input_shape, 0, 0); } /* Pointer may have e.g. moved outside window due to the input mask change */ @@ -7642,7 +7642,7 @@ gdk_window_set_static_gravities (GdkWindow *window, gboolean use_static) { GdkWindowObject *private; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); @@ -7650,8 +7650,8 @@ gdk_window_set_static_gravities (GdkWindow *window, if (gdk_window_has_impl (private)) { - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl); - return impl_iface->set_static_gravities (window, use_static); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + return impl_class->set_static_gravities (window, use_static); } return FALSE; @@ -8040,7 +8040,7 @@ update_cursor (GdkDisplay *display, { GdkWindowObject *cursor_window, *parent, *toplevel; GdkWindow *pointer_window; - GdkWindowImplIface *impl_iface; + GdkWindowImplClass *impl_class; GdkPointerWindowInfo *pointer_info; GdkDeviceGrabInfo *grab; GdkCursor *cursor; @@ -8080,8 +8080,8 @@ update_cursor (GdkDisplay *display, /* Set all cursors on toplevel, otherwise its tricky to keep track of * which native window has what cursor set. */ toplevel = (GdkWindowObject *) get_event_toplevel (pointer_window); - impl_iface = GDK_WINDOW_IMPL_GET_IFACE (toplevel->impl); - impl_iface->set_device_cursor ((GdkWindow *) toplevel, device, cursor); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (toplevel->impl); + impl_class->set_device_cursor ((GdkWindow *) toplevel, device, cursor); } static gboolean diff --git a/gdk/gdkwindowimpl.c b/gdk/gdkwindowimpl.c index 5658373b11..681aef8cdc 100644 --- a/gdk/gdkwindowimpl.c +++ b/gdk/gdkwindowimpl.c @@ -31,11 +31,15 @@ #include "gdkinternals.h" -typedef GdkWindowImplIface GdkWindowImplInterface; -G_DEFINE_INTERFACE (GdkWindowImpl, gdk_window_impl, G_TYPE_OBJECT); +G_DEFINE_TYPE (GdkWindowImpl, gdk_window_impl, GDK_TYPE_DRAWABLE); static void -gdk_window_impl_default_init (GdkWindowImplInterface *iface) +gdk_window_impl_class_init (GdkWindowImplClass *klass) +{ +} + +static void +gdk_window_impl_init (GdkWindowImpl *impl) { } diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index ce7f663b6b..3df0095956 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -32,16 +32,23 @@ G_BEGIN_DECLS #define GDK_TYPE_WINDOW_IMPL (gdk_window_impl_get_type ()) -#define GDK_WINDOW_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_WINDOW_IMPL, GdkWindowImpl)) -#define GDK_IS_WINDOW_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_WINDOW_IMPL)) -#define GDK_WINDOW_IMPL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_WINDOW_IMPL, GdkWindowImplIface)) +#define GDK_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL, GdkWindowImpl)) +#define GDK_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL, GdkWindowImplClass)) +#define GDK_IS_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL)) +#define GDK_IS_WINDOW_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL)) +#define GDK_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL, GdkWindowImplClass)) -typedef struct _GdkWindowImpl GdkWindowImpl; /* dummy */ -typedef struct _GdkWindowImplIface GdkWindowImplIface; +typedef struct _GdkWindowImpl GdkWindowImpl; +typedef struct _GdkWindowImplClass GdkWindowImplClass; -struct _GdkWindowImplIface +struct _GdkWindowImpl { - GTypeInterface g_iface; + GdkDrawable parent; +}; + +struct _GdkWindowImplClass +{ + GdkDrawableClass parent_class; void (* show) (GdkWindow *window, gboolean already_mapped); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 07155d0d68..1eec8b74bb 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -109,7 +109,6 @@ static void gdk_window_x11_set_background (GdkWindow *window, cairo_pattern_t *pattern); static void gdk_window_impl_x11_finalize (GObject *object); -static void gdk_window_impl_iface_init (GdkWindowImplIface *iface); #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ @@ -128,11 +127,7 @@ static void gdk_window_impl_iface_init (GdkWindowImplIface *iface); (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \ ) -G_DEFINE_TYPE_WITH_CODE (GdkWindowImplX11, - gdk_window_impl_x11, - GDK_TYPE_DRAWABLE, - G_IMPLEMENT_INTERFACE (GDK_TYPE_WINDOW_IMPL, - gdk_window_impl_iface_init)); +G_DEFINE_TYPE (GdkWindowImplX11, gdk_window_impl_x11, GDK_TYPE_WINDOW_IMPL) GType _gdk_window_impl_get_type (void) @@ -240,18 +235,6 @@ gdk_x11_ref_cairo_surface (GdkDrawable *drawable) return impl->cairo_surface; } -static void -gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); - - object_class->finalize = gdk_window_impl_x11_finalize; - - drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; - drawable_class->create_cairo_surface = gdk_x11_create_cairo_surface; -} - static void gdk_window_impl_x11_finalize (GObject *object) { @@ -5574,34 +5557,6 @@ _gdk_windowing_after_process_all_updates (void) { } -static void -gdk_window_impl_iface_init (GdkWindowImplIface *iface) -{ - iface->show = gdk_window_x11_show; - iface->hide = gdk_window_x11_hide; - iface->withdraw = gdk_window_x11_withdraw; - iface->set_events = gdk_window_x11_set_events; - iface->get_events = gdk_window_x11_get_events; - iface->raise = gdk_window_x11_raise; - iface->lower = gdk_window_x11_lower; - iface->restack_under = gdk_window_x11_restack_under; - iface->restack_toplevel = gdk_window_x11_restack_toplevel; - iface->move_resize = gdk_window_x11_move_resize; - iface->set_background = gdk_window_x11_set_background; - iface->reparent = gdk_window_x11_reparent; - iface->set_device_cursor = gdk_window_x11_set_device_cursor; - iface->get_geometry = gdk_window_x11_get_geometry; - iface->get_root_coords = gdk_window_x11_get_root_coords; - iface->get_device_state = gdk_window_x11_get_device_state; - iface->shape_combine_region = gdk_window_x11_shape_combine_region; - iface->input_shape_combine_region = gdk_window_x11_input_shape_combine_region; - iface->set_static_gravities = gdk_window_x11_set_static_gravities; - iface->queue_antiexpose = _gdk_x11_window_queue_antiexpose; - iface->translate = _gdk_x11_window_translate; - iface->destroy = _gdk_x11_window_destroy; - iface->resize_cairo_surface = gdk_window_x11_resize_cairo_surface; -} - static Bool timestamp_predicate (Display *display, XEvent *xevent, @@ -5693,3 +5648,40 @@ gdk_x11_window_get_xid (GdkWindow *window) return ((GdkWindowImplX11 *)impl)->xid; } +static void +gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); + + object_class->finalize = gdk_window_impl_x11_finalize; + + drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; + drawable_class->create_cairo_surface = gdk_x11_create_cairo_surface; + + impl_class->show = gdk_window_x11_show; + impl_class->hide = gdk_window_x11_hide; + impl_class->withdraw = gdk_window_x11_withdraw; + impl_class->set_events = gdk_window_x11_set_events; + impl_class->get_events = gdk_window_x11_get_events; + impl_class->raise = gdk_window_x11_raise; + impl_class->lower = gdk_window_x11_lower; + impl_class->restack_under = gdk_window_x11_restack_under; + impl_class->restack_toplevel = gdk_window_x11_restack_toplevel; + impl_class->move_resize = gdk_window_x11_move_resize; + impl_class->set_background = gdk_window_x11_set_background; + impl_class->reparent = gdk_window_x11_reparent; + impl_class->set_device_cursor = gdk_window_x11_set_device_cursor; + impl_class->get_geometry = gdk_window_x11_get_geometry; + impl_class->get_root_coords = gdk_window_x11_get_root_coords; + impl_class->get_device_state = gdk_window_x11_get_device_state; + impl_class->shape_combine_region = gdk_window_x11_shape_combine_region; + impl_class->input_shape_combine_region = gdk_window_x11_input_shape_combine_region; + impl_class->set_static_gravities = gdk_window_x11_set_static_gravities; + impl_class->queue_antiexpose = _gdk_x11_window_queue_antiexpose; + impl_class->translate = _gdk_x11_window_translate; + impl_class->destroy = _gdk_x11_window_destroy; + impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface; +} + diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index 04dc8aa0aa..fd63e8b462 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -28,6 +28,7 @@ #define __GDK_WINDOW_X11_H__ #include "gdk/x11/gdkprivate-x11.h" +#include "gdk/gdkwindowimpl.h" #ifdef HAVE_XDAMAGE #include @@ -56,7 +57,7 @@ typedef struct _GdkXPositionInfo GdkXPositionInfo; struct _GdkWindowImplX11 { - GdkDrawable parent_instance; + GdkWindowImpl parent_instance; GdkWindow *wrapper; @@ -81,7 +82,7 @@ struct _GdkWindowImplX11 struct _GdkWindowImplX11Class { - GdkDrawableClass parent_class; + GdkWindowImplClass parent_class; }; struct _GdkToplevelX11 From 1bb6f48bb374d700717c97d4f6893d7c00377264 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 00:55:39 +0100 Subject: [PATCH 039/634] gdk: Rename GdkWindowObject to GdkWindow ... and remove most of the casting that used to be necessary. --- gdk/gdkdevice.c | 10 +- gdk/gdkdisplay.c | 9 +- gdk/gdkevents.c | 6 +- gdk/gdkinternals.h | 21 +- gdk/gdkoffscreenwindow.c | 147 +-- gdk/gdkwindow.c | 1923 +++++++++++++------------------ gdk/x11/gdkdevice-core.c | 19 +- gdk/x11/gdkdevicemanager-core.c | 20 +- gdk/x11/gdkdisplay-x11.c | 60 +- gdk/x11/gdkeventsource.c | 5 +- gdk/x11/gdkgeometry-x11.c | 44 +- gdk/x11/gdkinput.c | 26 +- gdk/x11/gdkprivate-x11.h | 2 +- gdk/x11/gdktestutils-x11.c | 20 +- gdk/x11/gdkwindow-x11.c | 417 +++---- gdk/x11/gdkx.h | 2 +- 16 files changed, 1164 insertions(+), 1567 deletions(-) diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index afe8b94ce7..4e9b3d24e8 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -1067,7 +1067,7 @@ gdk_device_grab (GdkDevice *device, else native = gdk_window_get_toplevel (window); - while (((GdkWindowObject *) native)->window_type == GDK_WINDOW_OFFSCREEN) + while (native->window_type == GDK_WINDOW_OFFSCREEN) { native = gdk_offscreen_window_get_embedder (native); @@ -1231,7 +1231,6 @@ _gdk_device_translate_window_coord (GdkDevice *device, gdouble x_resolution, y_resolution; gdouble device_aspect; gint window_width, window_height; - GdkWindowObject *window_private; priv = device->priv; @@ -1274,7 +1273,6 @@ _gdk_device_translate_window_coord (GdkDevice *device, y_min = 0; } - window_private = (GdkWindowObject *) window; window_width = gdk_window_get_width (window); window_height = gdk_window_get_height (window); @@ -1342,7 +1340,6 @@ _gdk_device_translate_screen_coord (GdkDevice *device, GdkDevicePrivate *priv = device->priv; GdkAxisInfo axis_info; gdouble axis_width, scale, offset; - GdkWindowObject *window_private; if (priv->mode != GDK_MODE_SCREEN) return FALSE; @@ -1357,7 +1354,6 @@ _gdk_device_translate_screen_coord (GdkDevice *device, return FALSE; axis_width = axis_info.max_value - axis_info.min_value; - window_private = (GdkWindowObject *) window; if (axis_info.use == GDK_AXIS_X) { @@ -1366,7 +1362,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device, else scale = 1; - offset = - window_root_x - window_private->abs_x; + offset = - window_root_x - window->abs_x; } else { @@ -1375,7 +1371,7 @@ _gdk_device_translate_screen_coord (GdkDevice *device, else scale = 1; - offset = - window_root_y - window_private->abs_y; + offset = - window_root_y - window->abs_y; } if (axis_value) diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 71ba823341..d5c01fdc02 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -933,20 +933,17 @@ gdk_window_real_window_get_device_position (GdkDisplay *display, gint *y, GdkModifierType *mask) { - GdkWindowObject *private; gint tmpx, tmpy; GdkModifierType tmp_mask; gboolean normal_child; - private = (GdkWindowObject *) window; - - normal_child = GDK_WINDOW_IMPL_GET_CLASS (private->impl)->get_device_state (window, + normal_child = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_device_state (window, device, &tmpx, &tmpy, &tmp_mask); /* We got the coords on the impl, convert to the window */ - tmpx -= private->abs_x; - tmpy -= private->abs_y; + tmpx -= window->abs_x; + tmpy -= window->abs_y; if (x) *x = tmpx; diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index d60f3b16f9..b0b747ea82 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -1435,7 +1435,7 @@ gdk_synthesize_window_state (GdkWindow *window, temp_event.window_state.type = GDK_WINDOW_STATE; temp_event.window_state.send_event = FALSE; - old = ((GdkWindowObject*) temp_event.window_state.window)->state; + old = temp_event.window_state.window->state; temp_event.window_state.new_window_state = old; temp_event.window_state.new_window_state |= set_flags; @@ -1450,7 +1450,7 @@ gdk_synthesize_window_state (GdkWindow *window, * inconsistent state to the user. */ - ((GdkWindowObject*) window)->state = temp_event.window_state.new_window_state; + window->state = temp_event.window_state.new_window_state; if (temp_event.window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN) _gdk_window_update_viewable (window); @@ -1460,7 +1460,7 @@ gdk_synthesize_window_state (GdkWindow *window, * Non-toplevels do use the GDK_WINDOW_STATE_WITHDRAWN flag * internally so we needed to update window->state. */ - switch (((GdkWindowObject*) window)->window_type) + switch (window->window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: /* ? */ diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index e1150196c8..0fe151d4b9 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -175,25 +175,20 @@ typedef struct } GdkDeviceGrabInfo; typedef struct _GdkInputWindow GdkInputWindow; +typedef struct _GdkWindowPaint GdkWindowPaint; typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display, GdkDevice *device, GdkPointerWindowInfo *device_info, gpointer user_data); -/* Private version of GdkWindowObject. The initial part of this strucuture - is public for historical reasons. Don't change that part */ -typedef struct _GdkWindowPaint GdkWindowPaint; - -#define GDK_WINDOW_OBJECT(object) ((GdkWindowObject *) GDK_WINDOW (object)) - -struct _GdkWindowObject +struct _GdkWindow { GdkDrawable parent_instance; GdkDrawable *impl; /* window-system-specific delegate object */ - GdkWindowObject *parent; + GdkWindow *parent; GdkVisual *visual; gpointer user_data; @@ -235,10 +230,10 @@ struct _GdkWindowObject guint update_and_descendants_freeze_count; - /* The GdkWindowObject that has the impl, ref:ed if another window. + /* The GdkWindow that has the impl, ref:ed if another window. * This ref is required to keep the wrapper of the impl window alive * for as long as any GdkWindow references the impl. */ - GdkWindowObject *impl_window; + GdkWindow *impl_window; int abs_x, abs_y; /* Absolute offset in impl */ gint width, height; guint32 clip_tag; @@ -269,8 +264,8 @@ struct _GdkWindowObject GHashTable *device_events; }; -#define GDK_WINDOW_TYPE(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->window_type) -#define GDK_WINDOW_DESTROYED(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->destroyed) +#define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type) +#define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed) extern GdkEventFunc _gdk_event_func; /* Callback for events */ extern gpointer _gdk_event_data; @@ -406,7 +401,7 @@ gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display, gint depth); -#define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0) +#define GDK_WINDOW_IS_MAPPED(window) (((window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0) /* Called when gdk_window_destroy() is called on a foreign window diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index b139096a44..04770e57da 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -90,10 +90,9 @@ gdk_offscreen_window_destroy (GdkWindow *window, gboolean recursing, gboolean foreign_destroy) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (window); GdkOffscreenWindow *offscreen; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); gdk_offscreen_window_set_embedder (window, NULL); @@ -106,11 +105,11 @@ get_surface (GdkOffscreenWindow *offscreen) { if (! offscreen->surface) { - GdkWindowObject *private = (GdkWindowObject *) offscreen->wrapper; + GdkWindow *window = offscreen->wrapper; - g_signal_emit_by_name (private, "create-surface", - private->width, - private->height, + g_signal_emit_by_name (window, "create-surface", + window->width, + window->height, &offscreen->surface); } @@ -148,14 +147,13 @@ _gdk_offscreen_window_create_surface (GdkWindow *offscreen, gint width, gint height) { - GdkWindowObject *private = (GdkWindowObject *) offscreen; cairo_surface_t *similar; cairo_surface_t *surface; cairo_content_t content = CAIRO_CONTENT_COLOR; - g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (private->impl), NULL); + g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL); - similar = _gdk_window_ref_cairo_surface ((GdkWindow *)private->parent); + similar = _gdk_window_ref_cairo_surface (offscreen->parent); if (gdk_window_get_visual (offscreen) == gdk_screen_get_rgba_visual (gdk_window_get_screen (offscreen))) @@ -175,7 +173,6 @@ _gdk_offscreen_window_new (GdkWindow *window, GdkWindowAttr *attributes, gint attributes_mask) { - GdkWindowObject *private; GdkOffscreenWindow *offscreen; g_return_if_fail (attributes != NULL); @@ -183,13 +180,11 @@ _gdk_offscreen_window_new (GdkWindow *window, if (attributes->wclass != GDK_INPUT_OUTPUT) return; /* Can't support input only offscreens */ - private = (GdkWindowObject *)window; - - if (private->parent != NULL && GDK_WINDOW_DESTROYED (private->parent)) + if (window->parent != NULL && GDK_WINDOW_DESTROYED (window->parent)) return; - private->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL); - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + window->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); offscreen->wrapper = window; } @@ -199,15 +194,13 @@ gdk_offscreen_window_reparent (GdkWindow *window, gint x, gint y) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *new_parent_private = (GdkWindowObject *)new_parent; - GdkWindowObject *old_parent; + GdkWindow *old_parent; gboolean was_mapped; if (new_parent) { /* No input-output children of input-only windows */ - if (new_parent_private->input_only && !private->input_only) + if (new_parent->input_only && !window->input_only) return FALSE; /* Don't create loops in hierarchy */ @@ -219,20 +212,20 @@ gdk_offscreen_window_reparent (GdkWindow *window, gdk_window_hide (window); - if (private->parent) - private->parent->children = g_list_remove (private->parent->children, window); + if (window->parent) + window->parent->children = g_list_remove (window->parent->children, window); - old_parent = private->parent; - private->parent = new_parent_private; - private->x = x; - private->y = y; + old_parent = window->parent; + window->parent = new_parent; + window->x = x; + window->y = y; - if (new_parent_private) - private->parent->children = g_list_prepend (private->parent->children, window); + if (new_parent) + window->parent->children = g_list_prepend (window->parent->children, window); _gdk_synthesize_crossing_events_for_geometry_change (window); if (old_parent) - _gdk_synthesize_crossing_events_for_geometry_change (GDK_WINDOW (old_parent)); + _gdk_synthesize_crossing_events_for_geometry_change (old_parent); return was_mapped; } @@ -242,11 +235,7 @@ from_embedder (GdkWindow *window, double embedder_x, double embedder_y, double *offscreen_x, double *offscreen_y) { - GdkWindowObject *private; - - private = (GdkWindowObject *)window; - - g_signal_emit_by_name (private->impl_window, + g_signal_emit_by_name (window->impl_window, "from-embedder", embedder_x, embedder_y, offscreen_x, offscreen_y, @@ -258,11 +247,7 @@ to_embedder (GdkWindow *window, double offscreen_x, double offscreen_y, double *embedder_x, double *embedder_y) { - GdkWindowObject *private; - - private = (GdkWindowObject *)window; - - g_signal_emit_by_name (private->impl_window, + g_signal_emit_by_name (window->impl_window, "to-embedder", offscreen_x, offscreen_y, embedder_x, embedder_y, @@ -276,14 +261,13 @@ gdk_offscreen_window_get_root_coords (GdkWindow *window, gint *root_x, gint *root_y) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (window); GdkOffscreenWindow *offscreen; int tmpx, tmpy; tmpx = x; tmpy = y; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (offscreen->embedder) { double dx, dy; @@ -313,7 +297,6 @@ gdk_offscreen_window_get_device_state (GdkWindow *window, gint *y, GdkModifierType *mask) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (window); GdkOffscreenWindow *offscreen; int tmpx, tmpy; double dtmpx, dtmpy; @@ -323,7 +306,7 @@ gdk_offscreen_window_get_device_state (GdkWindow *window, tmpy = 0; tmpmask = 0; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (offscreen->embedder != NULL) { gdk_window_get_device_position (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask); @@ -356,15 +339,14 @@ gdk_offscreen_window_get_device_state (GdkWindow *window, cairo_surface_t * gdk_offscreen_window_get_surface (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkOffscreenWindow *offscreen; g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - if (!GDK_IS_OFFSCREEN_WINDOW (private->impl)) + if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) return NULL; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); return get_surface (offscreen); } @@ -391,33 +373,32 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window, gint height, gboolean send_expose_events) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkOffscreenWindow *offscreen; gint dx, dy, dw, dh; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (width < 1) width = 1; if (height < 1) height = 1; - if (private->destroyed) + if (window->destroyed) return; - dx = x - private->x; - dy = y - private->y; - dw = width - private->width; - dh = height - private->height; + dx = x - window->x; + dy = y - window->y; + dw = width - window->width; + dh = height - window->height; - private->x = x; - private->y = y; + window->x = x; + window->y = y; - if (private->width != width || - private->height != height) + if (window->width != width || + window->height != height) { - private->width = width; - private->height = height; + window->width = width; + window->height = height; if (offscreen->surface) { @@ -438,7 +419,7 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window, } } - if (GDK_WINDOW_IS_MAPPED (private)) + if (GDK_WINDOW_IS_MAPPED (window)) { // TODO: Only invalidate new area, i.e. for larger windows gdk_window_invalidate_rect (window, NULL, TRUE); @@ -454,22 +435,21 @@ gdk_offscreen_window_move_resize (GdkWindow *window, gint width, gint height) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkOffscreenWindow *offscreen; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (!with_move) { - x = private->x; - y = private->y; + x = window->x; + y = window->y; } if (width < 0) - width = private->width; + width = window->width; if (height < 0) - height = private->height; + height = window->height; gdk_offscreen_window_move_resize_internal (window, x, y, width, height, @@ -480,8 +460,7 @@ static void gdk_offscreen_window_show (GdkWindow *window, gboolean already_mapped) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkRectangle area = { 0, 0, private->width, private->height }; + GdkRectangle area = { 0, 0, window->width, window->height }; gdk_window_invalidate_rect (window, &area, FALSE); } @@ -490,14 +469,12 @@ gdk_offscreen_window_show (GdkWindow *window, static void gdk_offscreen_window_hide (GdkWindow *window) { - GdkWindowObject *private; GdkOffscreenWindow *offscreen; GdkDisplay *display; g_return_if_fail (window != NULL); - private = (GdkWindowObject*) window; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); /* May need to break grabs on children */ display = gdk_window_get_display (window); @@ -575,22 +552,18 @@ gdk_offscreen_window_get_geometry (GdkWindow *window, gint *height, gint *depth) { - GdkWindowObject *private = (GdkWindowObject *)window; - - g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); - if (!GDK_WINDOW_DESTROYED (window)) { if (x) - *x = private->x; + *x = window->x; if (y) - *y = private->y; + *y = window->y; if (width) - *width = private->width; + *width = window->width; if (height) - *height = private->height; + *height = window->height; if (depth) - *depth = private->depth; + *depth = window->depth; } } @@ -607,7 +580,7 @@ gdk_offscreen_window_translate (GdkWindow *window, gint dx, gint dy) { - GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (((GdkWindowObject *) window)->impl); + GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (offscreen->surface) { @@ -667,26 +640,25 @@ void gdk_offscreen_window_set_embedder (GdkWindow *window, GdkWindow *embedder) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkOffscreenWindow *offscreen; g_return_if_fail (GDK_IS_WINDOW (window)); - if (!GDK_IS_OFFSCREEN_WINDOW (private->impl)) + if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) return; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); if (embedder) { g_object_ref (embedder); - GDK_WINDOW_OBJECT (embedder)->num_offscreen_children++; + embedder->num_offscreen_children++; } if (offscreen->embedder) { g_object_unref (offscreen->embedder); - GDK_WINDOW_OBJECT (offscreen->embedder)->num_offscreen_children--; + offscreen->embedder->num_offscreen_children--; } offscreen->embedder = embedder; @@ -706,15 +678,14 @@ gdk_offscreen_window_set_embedder (GdkWindow *window, GdkWindow * gdk_offscreen_window_get_embedder (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkOffscreenWindow *offscreen; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - if (!GDK_IS_OFFSCREEN_WINDOW (private->impl)) + if (!GDK_IS_OFFSCREEN_WINDOW (window->impl)) return NULL; - offscreen = GDK_OFFSCREEN_WINDOW (private->impl); + offscreen = GDK_OFFSCREEN_WINDOW (window->impl); return offscreen->embedder; } diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 4760e454b4..4dd371aa1d 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -219,11 +219,11 @@ typedef struct { /* Global info */ -static void gdk_window_drop_cairo_surface (GdkWindowObject *private); +static void gdk_window_drop_cairo_surface (GdkWindow *private); static void gdk_window_free_paint_stack (GdkWindow *window); -static void gdk_window_init (GdkWindowObject *window); +static void gdk_window_init (GdkWindow *window); static void gdk_window_class_init (GdkWindowObjectClass *klass); static void gdk_window_finalize (GObject *object); @@ -239,19 +239,19 @@ static void gdk_window_get_property (GObject *object, static void gdk_window_clear_backing_region (GdkWindow *window, cairo_region_t *region); -static void recompute_visible_regions (GdkWindowObject *private, +static void recompute_visible_regions (GdkWindow *private, gboolean recalculate_siblings, gboolean recalculate_children); static void gdk_window_flush_outstanding_moves (GdkWindow *window); -static void gdk_window_flush_recursive (GdkWindowObject *window); -static void do_move_region_bits_on_impl (GdkWindowObject *private, +static void gdk_window_flush_recursive (GdkWindow *window); +static void do_move_region_bits_on_impl (GdkWindow *window, cairo_region_t *region, /* In impl window coords */ int dx, int dy); -static void gdk_window_invalidate_in_parent (GdkWindowObject *private); -static void move_native_children (GdkWindowObject *private); +static void gdk_window_invalidate_in_parent (GdkWindow *private); +static void move_native_children (GdkWindow *private); static void update_cursor (GdkDisplay *display, GdkDevice *device); -static void impl_window_add_update_area (GdkWindowObject *impl_window, +static void impl_window_add_update_area (GdkWindow *impl_window, cairo_region_t *region); static void gdk_window_region_move_free (GdkWindowRegionMove *move); static void gdk_window_invalidate_region_full (GdkWindow *window, @@ -287,7 +287,7 @@ gdk_window_object_get_type (void) "GdkWindow", sizeof (GdkWindowObjectClass), (GClassInitFunc) gdk_window_class_init, - sizeof (GdkWindowObject), + sizeof (GdkWindow), (GInstanceInitFunc) gdk_window_init, 0); @@ -319,7 +319,7 @@ _gdk_paintable_get_type (void) } static void -gdk_window_init (GdkWindowObject *window) +gdk_window_init (GdkWindow *window) { /* 0-initialization is good for all other fields. */ @@ -518,22 +518,17 @@ device_removed_cb (GdkDeviceManager *device_manager, GdkDevice *device, GdkWindow *window) { - GdkWindowObject *private; + window->devices_inside = g_list_remove (window->devices_inside, device); + g_hash_table_remove (window->device_cursor, device); - private = (GdkWindowObject *) window; - - private->devices_inside = g_list_remove (private->devices_inside, device); - g_hash_table_remove (private->device_cursor, device); - - if (private->device_events) - g_hash_table_remove (private->device_events, device); + if (window->device_events) + g_hash_table_remove (window->device_events, device); } static void gdk_window_finalize (GObject *object) { GdkWindow *window = GDK_WINDOW (object); - GdkWindowObject *obj = (GdkWindowObject *) object; GdkDeviceManager *device_manager; device_manager = gdk_display_get_device_manager (gdk_window_get_display (window)); @@ -553,37 +548,37 @@ gdk_window_finalize (GObject *object) _gdk_window_destroy (window, TRUE); } - gdk_window_drop_cairo_surface (obj); + gdk_window_drop_cairo_surface (window); - if (obj->impl) + if (window->impl) { - g_object_unref (obj->impl); - obj->impl = NULL; + g_object_unref (window->impl); + window->impl = NULL; } - if (obj->impl_window != obj) + if (window->impl_window != window) { - g_object_unref (obj->impl_window); - obj->impl_window = NULL; + g_object_unref (window->impl_window); + window->impl_window = NULL; } - if (obj->shape) - cairo_region_destroy (obj->shape); + if (window->shape) + cairo_region_destroy (window->shape); - if (obj->input_shape) - cairo_region_destroy (obj->input_shape); + if (window->input_shape) + cairo_region_destroy (window->input_shape); - if (obj->cursor) - gdk_cursor_unref (obj->cursor); + if (window->cursor) + gdk_cursor_unref (window->cursor); - if (obj->device_cursor) - g_hash_table_destroy (obj->device_cursor); + if (window->device_cursor) + g_hash_table_destroy (window->device_cursor); - if (obj->device_events) - g_hash_table_destroy (obj->device_events); + if (window->device_events) + g_hash_table_destroy (window->device_events); - if (obj->devices_inside) - g_list_free (obj->devices_inside); + if (window->devices_inside) + g_list_free (window->devices_inside); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -629,13 +624,13 @@ gdk_window_get_property (GObject *object, } static gboolean -gdk_window_is_offscreen (GdkWindowObject *window) +gdk_window_is_offscreen (GdkWindow *window) { return window->window_type == GDK_WINDOW_OFFSCREEN; } -static GdkWindowObject * -gdk_window_get_impl_window (GdkWindowObject *window) +static GdkWindow * +gdk_window_get_impl_window (GdkWindow *window) { return window->impl_window; } @@ -643,17 +638,17 @@ gdk_window_get_impl_window (GdkWindowObject *window) GdkWindow * _gdk_window_get_impl_window (GdkWindow *window) { - return (GdkWindow *)gdk_window_get_impl_window ((GdkWindowObject *)window); + return gdk_window_get_impl_window (window); } static gboolean -gdk_window_has_impl (GdkWindowObject *window) +gdk_window_has_impl (GdkWindow *window) { return window->impl_window == window; } static gboolean -gdk_window_is_toplevel (GdkWindowObject *window) +gdk_window_is_toplevel (GdkWindow *window) { return window->parent == NULL || @@ -663,22 +658,22 @@ gdk_window_is_toplevel (GdkWindowObject *window) gboolean _gdk_window_has_impl (GdkWindow *window) { - return gdk_window_has_impl ((GdkWindowObject *)window); + return gdk_window_has_impl (window); } static gboolean -gdk_window_has_no_impl (GdkWindowObject *window) +gdk_window_has_no_impl (GdkWindow *window) { return window->impl_window != window; } static void -remove_child_area (GdkWindowObject *private, - GdkWindowObject *until, +remove_child_area (GdkWindow *private, + GdkWindow *until, gboolean for_input, cairo_region_t *region) { - GdkWindowObject *child; + GdkWindow *child; cairo_region_t *child_region; GdkRectangle r; GList *l; @@ -754,40 +749,40 @@ remove_child_area (GdkWindowObject *private, } static GdkVisibilityState -effective_visibility (GdkWindowObject *private) +effective_visibility (GdkWindow *window) { GdkVisibilityState native; - if (!gdk_window_is_viewable ((GdkWindow *)private)) + if (!gdk_window_is_viewable (window)) return GDK_VISIBILITY_NOT_VIEWABLE; - native = private->impl_window->native_visibility; + native = window->impl_window->native_visibility; if (native == GDK_VISIBILITY_FULLY_OBSCURED || - private->visibility == GDK_VISIBILITY_FULLY_OBSCURED) + window->visibility == GDK_VISIBILITY_FULLY_OBSCURED) return GDK_VISIBILITY_FULLY_OBSCURED; else if (native == GDK_VISIBILITY_UNOBSCURED) - return private->visibility; + return window->visibility; else /* native PARTIAL, private partial or unobscured */ return GDK_VISIBILITY_PARTIAL; } static void -gdk_window_update_visibility (GdkWindowObject *private) +gdk_window_update_visibility (GdkWindow *window) { GdkVisibilityState new_visibility; GdkEvent *event; - new_visibility = effective_visibility (private); + new_visibility = effective_visibility (window); - if (new_visibility != private->effective_visibility) + if (new_visibility != window->effective_visibility) { - private->effective_visibility = new_visibility; + window->effective_visibility = new_visibility; if (new_visibility != GDK_VISIBILITY_NOT_VIEWABLE && - private->event_mask & GDK_VISIBILITY_NOTIFY) + window->event_mask & GDK_VISIBILITY_NOTIFY) { - event = _gdk_make_event ((GdkWindow *)private, GDK_VISIBILITY_NOTIFY, + event = _gdk_make_event (window, GDK_VISIBILITY_NOTIFY, NULL, FALSE); event->visibility.state = new_visibility; } @@ -795,14 +790,14 @@ gdk_window_update_visibility (GdkWindowObject *private) } static void -gdk_window_update_visibility_recursively (GdkWindowObject *private, - GdkWindowObject *only_for_impl) +gdk_window_update_visibility_recursively (GdkWindow *window, + GdkWindow *only_for_impl) { - GdkWindowObject *child; + GdkWindow *child; GList *l; - gdk_window_update_visibility (private); - for (l = private->children; l != NULL; l = l->next) + gdk_window_update_visibility (window); + for (l = window->children; l != NULL; l = l->next) { child = l->data; if ((only_for_impl == NULL) || @@ -812,22 +807,22 @@ gdk_window_update_visibility_recursively (GdkWindowObject *private, } static gboolean -should_apply_clip_as_shape (GdkWindowObject *private) +should_apply_clip_as_shape (GdkWindow *window) { return - gdk_window_has_impl (private) && + gdk_window_has_impl (window) && /* Not for offscreens */ - !gdk_window_is_offscreen (private) && + !gdk_window_is_offscreen (window) && /* or for toplevels */ - !gdk_window_is_toplevel (private) && + !gdk_window_is_toplevel (window) && /* or for foreign windows */ - private->window_type != GDK_WINDOW_FOREIGN && + window->window_type != GDK_WINDOW_FOREIGN && /* or for the root window */ - private->window_type != GDK_WINDOW_ROOT; + window->window_type != GDK_WINDOW_ROOT; } static void -apply_shape (GdkWindowObject *private, +apply_shape (GdkWindow *window, cairo_region_t *region) { GdkWindowImplClass *impl_class; @@ -836,15 +831,15 @@ apply_shape (GdkWindowObject *private, we can avoid unsetting it many times, which could happen in e.g. apply_clip_as_shape as windows get resized */ - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); if (region) - impl_class->shape_combine_region ((GdkWindow *)private, + impl_class->shape_combine_region (window, region, 0, 0); - else if (private->applied_shape) - impl_class->shape_combine_region ((GdkWindow *)private, + else if (window->applied_shape) + impl_class->shape_combine_region (window, NULL, 0, 0); - private->applied_shape = region != NULL; + window->applied_shape = region != NULL; } static gboolean @@ -865,33 +860,33 @@ region_rect_equal (const cairo_region_t *region, } static void -apply_clip_as_shape (GdkWindowObject *private) +apply_clip_as_shape (GdkWindow *window) { GdkRectangle r; r.x = r.y = 0; - r.width = private->width; - r.height = private->height; + r.width = window->width; + r.height = window->height; /* We only apply the clip region if would differ from the actual clip region implied by the size of the window. This is to avoid unneccessarily adding meaningless shapes to all native subwindows */ - if (!region_rect_equal (private->clip_region, &r)) - apply_shape (private, private->clip_region); + if (!region_rect_equal (window->clip_region, &r)) + apply_shape (window, window->clip_region); else - apply_shape (private, NULL); + apply_shape (window, NULL); } static void -recompute_visible_regions_internal (GdkWindowObject *private, - gboolean recalculate_clip, - gboolean recalculate_siblings, - gboolean recalculate_children) +recompute_visible_regions_internal (GdkWindow *private, + gboolean recalculate_clip, + gboolean recalculate_siblings, + gboolean recalculate_children) { GdkRectangle r; GList *l; - GdkWindowObject *child; + GdkWindow *child; cairo_region_t *new_clip, *old_clip_region_with_children; gboolean clip_region_changed; gboolean abs_pos_changed; @@ -1082,7 +1077,7 @@ recompute_visible_regions_internal (GdkWindowObject *private, * recompute_visible_regions), pass in TRUE for recalculate_children on the parent */ static void -recompute_visible_regions (GdkWindowObject *private, +recompute_visible_regions (GdkWindow *private, gboolean recalculate_siblings, gboolean recalculate_children) { @@ -1095,7 +1090,7 @@ recompute_visible_regions (GdkWindowObject *private, void _gdk_window_update_size (GdkWindow *window) { - recompute_visible_regions ((GdkWindowObject *)window, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); } /* Find the native window that would be just above "child" @@ -1104,11 +1099,11 @@ _gdk_window_update_size (GdkWindow *window) * window inside this native parent then NULL is returned. * If child is NULL, find lowest native window in parent. */ -static GdkWindowObject * -find_native_sibling_above_helper (GdkWindowObject *parent, - GdkWindowObject *child) +static GdkWindow * +find_native_sibling_above_helper (GdkWindow *parent, + GdkWindow *child) { - GdkWindowObject *w; + GdkWindow *w; GList *l; if (child) @@ -1137,11 +1132,11 @@ find_native_sibling_above_helper (GdkWindowObject *parent, } -static GdkWindowObject * -find_native_sibling_above (GdkWindowObject *parent, - GdkWindowObject *child) +static GdkWindow * +find_native_sibling_above (GdkWindow *parent, + GdkWindow *child) { - GdkWindowObject *w; + GdkWindow *w; w = find_native_sibling_above_helper (parent, child); if (w) @@ -1154,8 +1149,8 @@ find_native_sibling_above (GdkWindowObject *parent, } static GdkEventMask -get_native_device_event_mask (GdkWindowObject *private, - GdkDevice *device) +get_native_device_event_mask (GdkWindow *private, + GdkDevice *device) { GdkEventMask event_mask; @@ -1230,7 +1225,7 @@ get_native_grab_event_mask (GdkEventMask grab_mask) } static GdkEventMask -get_native_event_mask (GdkWindowObject *private) +get_native_event_mask (GdkWindow *private) { return get_native_device_event_mask (private, NULL); } @@ -1243,20 +1238,17 @@ get_native_event_mask (GdkWindowObject *private) static void sync_native_window_stack_position (GdkWindow *window) { - GdkWindowObject *above; - GdkWindowObject *private; + GdkWindow *above; GdkWindowImplClass *impl_class; GList listhead = {0}; - private = (GdkWindowObject *) window; - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); - above = find_native_sibling_above (private->parent, private); + above = find_native_sibling_above (window->parent, window); if (above) { listhead.data = window; - impl_class->restack_under ((GdkWindow *)above, - &listhead); + impl_class->restack_under (above, &listhead); } } @@ -1280,7 +1272,6 @@ gdk_window_new (GdkWindow *parent, gint attributes_mask) { GdkWindow *window; - GdkWindowObject *private; GdkScreen *screen; int x, y; gboolean native; @@ -1317,7 +1308,6 @@ gdk_window_new (GdkWindow *parent, } window = g_object_new (GDK_TYPE_WINDOW, NULL); - private = (GdkWindowObject *) window; /* Windows with a foreign parent are treated as if they are children * of the root window, except for actual creation. @@ -1326,10 +1316,10 @@ gdk_window_new (GdkWindow *parent, if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN) parent = gdk_screen_get_root_window (screen); - private->parent = (GdkWindowObject *)parent; + window->parent = parent; - private->accept_focus = TRUE; - private->focus_on_map = TRUE; + window->accept_focus = TRUE; + window->focus_on_map = TRUE; if (attributes_mask & GDK_WA_X) x = attributes->x; @@ -1341,17 +1331,17 @@ gdk_window_new (GdkWindow *parent, else y = 0; - private->x = x; - private->y = y; - private->width = (attributes->width > 1) ? (attributes->width) : (1); - private->height = (attributes->height > 1) ? (attributes->height) : (1); + window->x = x; + window->y = y; + window->width = (attributes->width > 1) ? (attributes->width) : (1); + window->height = (attributes->height > 1) ? (attributes->height) : (1); #ifdef GDK_WINDOWING_X11 /* Work around a bug where Xorg refuses to map toplevel InputOnly windows * from an untrusted client: http://bugs.freedesktop.org/show_bug.cgi?id=6988 */ if (attributes->wclass == GDK_INPUT_ONLY && - private->parent->window_type == GDK_WINDOW_ROOT && + window->parent->window_type == GDK_WINDOW_ROOT && !G_LIKELY (GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (parent))->trusted_client)) { g_warning ("Coercing GDK_INPUT_ONLY toplevel window to GDK_INPUT_OUTPUT to work around bug in Xorg server"); @@ -1366,15 +1356,15 @@ gdk_window_new (GdkWindow *parent, * before */ if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT) - private->window_type = GDK_WINDOW_TEMP; + window->window_type = GDK_WINDOW_TEMP; else - private->window_type = GDK_WINDOW_CHILD; + window->window_type = GDK_WINDOW_CHILD; } else - private->window_type = attributes->window_type; + window->window_type = attributes->window_type; /* Sanity checks */ - switch (private->window_type) + switch (window->window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: @@ -1386,57 +1376,57 @@ gdk_window_new (GdkWindow *parent, break; break; default: - g_warning (G_STRLOC "cannot make windows of type %d", private->window_type); + g_warning (G_STRLOC "cannot make windows of type %d", window->window_type); return NULL; } if (attributes_mask & GDK_WA_VISUAL) - private->visual = attributes->visual; + window->visual = attributes->visual; else - private->visual = gdk_screen_get_system_visual (screen); + window->visual = gdk_screen_get_system_visual (screen); - private->event_mask = attributes->event_mask; + window->event_mask = attributes->event_mask; if (attributes->wclass == GDK_INPUT_OUTPUT) { - private->input_only = FALSE; - private->depth = private->visual->depth; + window->input_only = FALSE; + window->depth = window->visual->depth; /* XXX: Cache this somehow? */ - private->background = cairo_pattern_create_rgb (0, 0, 0); + window->background = cairo_pattern_create_rgb (0, 0, 0); } else { - private->depth = 0; - private->input_only = TRUE; + window->depth = 0; + window->input_only = TRUE; } - if (private->parent) - private->parent->children = g_list_prepend (private->parent->children, window); + if (window->parent) + window->parent->children = g_list_prepend (window->parent->children, window); - private->device_cursor = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) gdk_cursor_unref); + window->device_cursor = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) gdk_cursor_unref); native = _gdk_native_windows; /* Default */ - if (private->parent->window_type == GDK_WINDOW_ROOT) + if (window->parent->window_type == GDK_WINDOW_ROOT) native = TRUE; /* Always use native windows for toplevels */ - else if (!private->input_only && + else if (!window->input_only && (attributes_mask & GDK_WA_VISUAL && - attributes->visual != gdk_window_get_visual (GDK_WINDOW (private->parent)))) + attributes->visual != gdk_window_get_visual (window->parent))) native = TRUE; /* InputOutput window with different visual than parent, needs native window */ - if (gdk_window_is_offscreen (private)) + if (gdk_window_is_offscreen (window)) { _gdk_offscreen_window_new (window, attributes, attributes_mask); - private->impl_window = private; + window->impl_window = window; } else if (native) { - event_mask = get_native_event_mask (private); + event_mask = get_native_event_mask (window); /* Create the impl */ _gdk_window_impl_new (window, real_parent, screen, event_mask, attributes, attributes_mask); - private->impl_window = private; + window->impl_window = window; /* This will put the native window topmost in the native parent, which may * be wrong wrt other native windows in the non-native hierarchy, so restack */ @@ -1445,11 +1435,11 @@ gdk_window_new (GdkWindow *parent, } else { - private->impl_window = g_object_ref (private->parent->impl_window); - private->impl = g_object_ref (private->impl_window->impl); + window->impl_window = g_object_ref (window->parent->impl_window); + window->impl = g_object_ref (window->impl_window->impl); } - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? (attributes->cursor) : @@ -1481,14 +1471,14 @@ is_parent_of (GdkWindow *parent, } static void -change_impl (GdkWindowObject *private, - GdkWindowObject *impl_window, +change_impl (GdkWindow *private, + GdkWindow *impl_window, GdkDrawable *new) { GList *l; - GdkWindowObject *child; + GdkWindow *child; GdkDrawable *old_impl; - GdkWindowObject *old_impl_window; + GdkWindow *old_impl_window; old_impl = private->impl; old_impl_window = private->impl_window; @@ -1511,10 +1501,10 @@ change_impl (GdkWindowObject *private, } static void -reparent_to_impl (GdkWindowObject *private) +reparent_to_impl (GdkWindow *private) { GList *l; - GdkWindowObject *child; + GdkWindow *child; gboolean show; GdkWindowImplClass *impl_class; @@ -1557,9 +1547,7 @@ gdk_window_reparent (GdkWindow *window, gint x, gint y) { - GdkWindowObject *private; - GdkWindowObject *new_parent_private; - GdkWindowObject *old_parent; + GdkWindow *old_parent; GdkScreen *screen; gboolean show, was_mapped, applied_clip_as_shape; gboolean do_reparent_to_impl; @@ -1578,11 +1566,8 @@ gdk_window_reparent (GdkWindow *window, if (!new_parent) new_parent = gdk_screen_get_root_window (screen); - private = (GdkWindowObject *) window; - new_parent_private = (GdkWindowObject *)new_parent; - /* No input-output children of input-only windows */ - if (new_parent_private->input_only && !private->input_only) + if (new_parent->input_only && !window->input_only) return; /* Don't create loops in hierarchy */ @@ -1591,42 +1576,42 @@ gdk_window_reparent (GdkWindow *window, /* This might be wrong in the new parent, e.g. for non-native surfaces. To make sure we're ok, just wipe it. */ - gdk_window_drop_cairo_surface (private); + gdk_window_drop_cairo_surface (window); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); - old_parent = private->parent; + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); + old_parent = window->parent; was_mapped = GDK_WINDOW_IS_MAPPED (window); show = FALSE; /* Reparenting to toplevel. Ensure we have a native window so this can work */ - if (new_parent_private->window_type == GDK_WINDOW_ROOT || - new_parent_private->window_type == GDK_WINDOW_FOREIGN) + if (new_parent->window_type == GDK_WINDOW_ROOT || + new_parent->window_type == GDK_WINDOW_FOREIGN) gdk_window_ensure_native (window); - applied_clip_as_shape = should_apply_clip_as_shape (private); + applied_clip_as_shape = should_apply_clip_as_shape (window); old_native_event_mask = 0; do_reparent_to_impl = FALSE; - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - old_native_event_mask = get_native_event_mask (private); + old_native_event_mask = get_native_event_mask (window); /* Native window */ show = impl_class->reparent (window, new_parent, x, y); } else { /* This shouldn't happen, as we created a native in this case, check anyway to see if that ever fails */ - g_assert (new_parent_private->window_type != GDK_WINDOW_ROOT && - new_parent_private->window_type != GDK_WINDOW_FOREIGN); + g_assert (new_parent->window_type != GDK_WINDOW_ROOT && + new_parent->window_type != GDK_WINDOW_FOREIGN); show = was_mapped; gdk_window_hide (window); do_reparent_to_impl = TRUE; - change_impl (private, - new_parent_private->impl_window, - new_parent_private->impl); + change_impl (window, + new_parent->impl_window, + new_parent->impl); } /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like @@ -1635,17 +1620,16 @@ gdk_window_reparent (GdkWindow *window, if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) { new_parent = gdk_screen_get_root_window (screen); - new_parent_private = (GdkWindowObject *)new_parent; } if (old_parent) old_parent->children = g_list_remove (old_parent->children, window); - private->parent = new_parent_private; - private->x = x; - private->y = y; + window->parent = new_parent; + window->x = x; + window->y = y; - new_parent_private->children = g_list_prepend (new_parent_private->children, window); + new_parent->children = g_list_prepend (new_parent->children, window); /* Switch the window type as appropriate */ @@ -1653,8 +1637,8 @@ gdk_window_reparent (GdkWindow *window, { case GDK_WINDOW_ROOT: case GDK_WINDOW_FOREIGN: - if (private->toplevel_window_type != -1) - GDK_WINDOW_TYPE (window) = private->toplevel_window_type; + if (window->toplevel_window_type != -1) + GDK_WINDOW_TYPE (window) = window->toplevel_window_type; else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL; break; @@ -1668,16 +1652,16 @@ gdk_window_reparent (GdkWindow *window, /* Save the original window type so we can restore it if the * window is reparented back to be a toplevel */ - private->toplevel_window_type = GDK_WINDOW_TYPE (window); + window->toplevel_window_type = GDK_WINDOW_TYPE (window); GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD; } } /* We might have changed window type for a native windows, so we need to change the event mask too. */ - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - GdkEventMask native_event_mask = get_native_event_mask (private); + GdkEventMask native_event_mask = get_native_event_mask (window); if (native_event_mask != old_native_event_mask) impl_class->set_events (window, native_event_mask); @@ -1685,25 +1669,25 @@ gdk_window_reparent (GdkWindow *window, _gdk_window_update_viewable (window); - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); if (old_parent && GDK_WINDOW_TYPE (old_parent) != GDK_WINDOW_ROOT) recompute_visible_regions (old_parent, FALSE, TRUE); /* We used to apply the clip as the shape, but no more. Reset this to the real shape */ - if (gdk_window_has_impl (private) && + if (gdk_window_has_impl (window) && applied_clip_as_shape && - !should_apply_clip_as_shape (private)) - apply_shape (private, private->shape); + !should_apply_clip_as_shape (window)) + apply_shape (window, window->shape); if (do_reparent_to_impl) - reparent_to_impl (private); + reparent_to_impl (window); else { /* The reparent will have put the native window topmost in the native parent, * which may be wrong wrt other native windows in the non-native hierarchy, * so restack */ - if (!gdk_window_has_impl (new_parent_private)) + if (!gdk_window_has_impl (new_parent)) sync_native_window_stack_position (window); } @@ -1714,9 +1698,9 @@ gdk_window_reparent (GdkWindow *window, } static gboolean -temporary_disable_extension_events (GdkWindowObject *window) +temporary_disable_extension_events (GdkWindow*window) { - GdkWindowObject *child; + GdkWindow*child; GList *l; gboolean res; @@ -1743,9 +1727,9 @@ temporary_disable_extension_events (GdkWindowObject *window) } static void -reenable_extension_events (GdkWindowObject *window) +reenable_extension_events (GdkWindow *window) { - GdkWindowObject *child; + GdkWindow *child; GList *l; int mask; @@ -1792,11 +1776,10 @@ reenable_extension_events (GdkWindowObject *window) gboolean gdk_window_ensure_native (GdkWindow *window) { - GdkWindowObject *private; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GdkDrawable *new_impl, *old_impl; GdkScreen *screen; - GdkWindowObject *above; + GdkWindow *above; GList listhead; GdkWindowImplClass *impl_class; gboolean disabled_extension_events; @@ -1807,14 +1790,12 @@ gdk_window_ensure_native (GdkWindow *window) GDK_WINDOW_DESTROYED (window)) return FALSE; - private = (GdkWindowObject *) window; - - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); if (gdk_window_is_offscreen (impl_window)) return FALSE; /* native in offscreens not supported */ - if (impl_window == private) + if (impl_window == window) /* Already has an impl, and its not offscreen . */ return TRUE; @@ -1824,29 +1805,29 @@ gdk_window_ensure_native (GdkWindow *window) descendants to handle the native input window moving */ disabled_extension_events = FALSE; if (impl_window->input_window) - disabled_extension_events = temporary_disable_extension_events (private); + disabled_extension_events = temporary_disable_extension_events (window); - gdk_window_drop_cairo_surface (private); + gdk_window_drop_cairo_surface (window); screen = gdk_window_get_screen (window); - old_impl = private->impl; - _gdk_window_impl_new (window, (GdkWindow *)private->parent, + old_impl = window->impl; + _gdk_window_impl_new (window, window->parent, screen, - get_native_event_mask (private), + get_native_event_mask (window), NULL, 0); - new_impl = private->impl; + new_impl = window->impl; - private->impl = old_impl; - change_impl (private, private, new_impl); + window->impl = old_impl; + change_impl (window, window, new_impl); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); /* Native window creation will put the native window topmost in the * native parent, which may be wrong wrt the position of the previous * non-native window wrt to the other non-native children, so correct this. */ - above = find_native_sibling_above (private->parent, private); + above = find_native_sibling_above (window->parent, window); if (above) { listhead.data = window; @@ -1855,29 +1836,29 @@ gdk_window_ensure_native (GdkWindow *window) impl_class->restack_under ((GdkWindow *)above, &listhead); } - recompute_visible_regions (private, FALSE, FALSE); + recompute_visible_regions (window, FALSE, FALSE); /* The shape may not have been set, as the clip region doesn't actually change, so do it here manually */ - if (should_apply_clip_as_shape (private)) - apply_clip_as_shape (private); + if (should_apply_clip_as_shape (window)) + apply_clip_as_shape (window); - reparent_to_impl (private); + reparent_to_impl (window); - if (!private->input_only) + if (!window->input_only) { - impl_class->set_background (window, private->background); + impl_class->set_background (window, window->background); } impl_class->input_shape_combine_region (window, - private->input_shape, + window->input_shape, 0, 0); if (gdk_window_is_viewable (window)) impl_class->show (window, FALSE); if (disabled_extension_events) - reenable_extension_events (private); + reenable_extension_events (window); return TRUE; } @@ -1885,17 +1866,15 @@ gdk_window_ensure_native (GdkWindow *window) static void window_remove_filters (GdkWindow *window) { - GdkWindowObject *obj = (GdkWindowObject*) window; - - if (obj->filters) + if (window->filters) { GList *tmp_list; - for (tmp_list = obj->filters; tmp_list; tmp_list = tmp_list->next) + for (tmp_list = window->filters; tmp_list; tmp_list = tmp_list->next) g_free (tmp_list->data); - g_list_free (obj->filters); - obj->filters = NULL; + g_list_free (window->filters); + window->filters = NULL; } } @@ -1947,8 +1926,6 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, gboolean recursing_native, gboolean foreign_destroy) { - GdkWindowObject *private; - GdkWindowObject *temp_private; GdkWindowImplClass *impl_class; GdkWindow *temp_window; GdkScreen *screen; @@ -1958,8 +1935,6 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject*) window; - if (GDK_WINDOW_DESTROYED (window)) return; @@ -1970,7 +1945,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, g_object_set_qdata (G_OBJECT (screen), quark_pointer_window, NULL); - switch (private->window_type) + switch (window->window_type) { case GDK_WINDOW_ROOT: if (!screen->closed) @@ -1984,7 +1959,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, case GDK_WINDOW_TEMP: case GDK_WINDOW_FOREIGN: case GDK_WINDOW_OFFSCREEN: - if (private->window_type == GDK_WINDOW_FOREIGN && !foreign_destroy) + if (window->window_type == GDK_WINDOW_FOREIGN && !foreign_destroy) { /* Logically, it probably makes more sense to send * a "destroy yourself" message to the foreign window @@ -1992,7 +1967,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, * reasons, we only send "destroy yourself" messages to * foreign windows in our hierarchy. */ - if (private->parent) + if (window->parent) _gdk_windowing_window_destroy_foreign (window); /* Also for historical reasons, we remove any filters @@ -2004,46 +1979,43 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, } else { - if (private->parent) + if (window->parent) { - GdkWindowObject *parent_private = (GdkWindowObject *)private->parent; - - if (parent_private->children) - parent_private->children = g_list_remove (parent_private->children, window); + if (window->parent->children) + window->parent->children = g_list_remove (window->parent->children, window); if (!recursing && GDK_WINDOW_IS_MAPPED (window)) { - recompute_visible_regions (private, TRUE, FALSE); - gdk_window_invalidate_in_parent (private); + recompute_visible_regions (window, TRUE, FALSE); + gdk_window_invalidate_in_parent (window); } } gdk_window_free_paint_stack (window); - if (private->background) + if (window->background) { - cairo_pattern_destroy (private->background); - private->background = NULL; + cairo_pattern_destroy (window->background); + window->background = NULL; } - if (private->window_type == GDK_WINDOW_FOREIGN) - g_assert (private->children == NULL); + if (window->window_type == GDK_WINDOW_FOREIGN) + g_assert (window->children == NULL); else { - children = tmp = private->children; - private->children = NULL; + children = tmp = window->children; + window->children = NULL; while (tmp) { temp_window = tmp->data; tmp = tmp->next; - temp_private = (GdkWindowObject*) temp_window; - if (temp_private) + if (temp_window) _gdk_window_destroy_hierarchy (temp_window, TRUE, - recursing_native || gdk_window_has_impl (private), + recursing_native || gdk_window_has_impl (window), foreign_destroy); } @@ -2052,11 +2024,11 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, _gdk_window_clear_update_area (window); - gdk_window_drop_cairo_surface (private); + gdk_window_drop_cairo_surface (window); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) impl_class->destroy (window, recursing_native, foreign_destroy); else @@ -2065,31 +2037,31 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, gdk_window_hide (window); } - private->state |= GDK_WINDOW_STATE_WITHDRAWN; - private->parent = NULL; - private->destroyed = TRUE; + window->state |= GDK_WINDOW_STATE_WITHDRAWN; + window->parent = NULL; + window->destroyed = TRUE; window_remove_filters (window); window_remove_from_pointer_info (window, display); - if (private->clip_region) + if (window->clip_region) { - cairo_region_destroy (private->clip_region); - private->clip_region = NULL; + cairo_region_destroy (window->clip_region); + window->clip_region = NULL; } - if (private->clip_region_with_children) + if (window->clip_region_with_children) { - cairo_region_destroy (private->clip_region_with_children); - private->clip_region_with_children = NULL; + cairo_region_destroy (window->clip_region_with_children); + window->clip_region_with_children = NULL; } - if (private->outstanding_moves) + if (window->outstanding_moves) { - g_list_foreach (private->outstanding_moves, (GFunc)gdk_window_region_move_free, NULL); - g_list_free (private->outstanding_moves); - private->outstanding_moves = NULL; + g_list_foreach (window->outstanding_moves, (GFunc)gdk_window_region_move_free, NULL); + g_list_free (window->outstanding_moves); + window->outstanding_moves = NULL; } } break; @@ -2153,7 +2125,7 @@ gdk_window_set_user_data (GdkWindow *window, { g_return_if_fail (GDK_IS_WINDOW (window)); - ((GdkWindowObject*)window)->user_data = user_data; + window->user_data = user_data; } /** @@ -2171,7 +2143,7 @@ gdk_window_get_user_data (GdkWindow *window, { g_return_if_fail (GDK_IS_WINDOW (window)); - *data = ((GdkWindowObject*)window)->user_data; + *data = window->user_data; } /** @@ -2203,13 +2175,9 @@ gdk_window_get_window_type (GdkWindow *window) GdkVisual* gdk_window_get_visual (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject *) window; - - return private->visual; + return window->visual; } /** @@ -2225,13 +2193,9 @@ gdk_window_get_visual (GdkWindow *window) GdkScreen* gdk_window_get_screen (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject *) window; - - return gdk_visual_get_screen (private->visual); + return gdk_visual_get_screen (window->visual); } /** @@ -2247,13 +2211,9 @@ gdk_window_get_screen (GdkWindow *window) GdkDisplay * gdk_window_get_display (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject *) window; - - return gdk_screen_get_display (gdk_visual_get_screen (private->visual)); + return gdk_screen_get_display (gdk_visual_get_screen (window->visual)); } /** * gdk_window_is_destroyed: @@ -2272,11 +2232,11 @@ gdk_window_is_destroyed (GdkWindow *window) } static void -to_embedder (GdkWindowObject *window, - gdouble offscreen_x, - gdouble offscreen_y, - gdouble *embedder_x, - gdouble *embedder_y) +to_embedder (GdkWindow *window, + gdouble offscreen_x, + gdouble offscreen_y, + gdouble *embedder_x, + gdouble *embedder_y) { g_signal_emit (window, signals[TO_EMBEDDER], 0, offscreen_x, offscreen_y, @@ -2284,11 +2244,11 @@ to_embedder (GdkWindowObject *window, } static void -from_embedder (GdkWindowObject *window, - gdouble embedder_x, - gdouble embedder_y, - gdouble *offscreen_x, - gdouble *offscreen_y) +from_embedder (GdkWindow *window, + gdouble embedder_x, + gdouble embedder_y, + gdouble *offscreen_x, + gdouble *offscreen_y) { g_signal_emit (window, signals[FROM_EMBEDDER], 0, embedder_x, embedder_y, @@ -2309,13 +2269,9 @@ from_embedder (GdkWindowObject *window, gboolean gdk_window_has_native (GdkWindow *window) { - GdkWindowObject *w; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - w = GDK_WINDOW_OBJECT (window); - - return w->parent == NULL || w->parent->impl != w->impl; + return window->parent == NULL || window->parent->impl != window->impl; } /** @@ -2338,16 +2294,12 @@ gdk_window_get_position (GdkWindow *window, gint *x, gint *y) { - GdkWindowObject *obj; - g_return_if_fail (GDK_IS_WINDOW (window)); - obj = (GdkWindowObject*) window; - if (x) - *x = obj->x; + *x = window->x; if (y) - *y = obj->y; + *y = window->y; } /** @@ -2373,7 +2325,7 @@ gdk_window_get_parent (GdkWindow *window) { g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - return (GdkWindow*) ((GdkWindowObject*) window)->parent; + return window->parent; } /** @@ -2393,16 +2345,12 @@ gdk_window_get_parent (GdkWindow *window) GdkWindow * gdk_window_get_effective_parent (GdkWindow *window) { - GdkWindowObject *obj; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - obj = (GdkWindowObject *)window; - - if (gdk_window_is_offscreen (obj)) + if (gdk_window_is_offscreen (window)) return gdk_offscreen_window_get_embedder (window); else - return (GdkWindow *) obj->parent; + return window->parent; } /** @@ -2425,20 +2373,16 @@ gdk_window_get_effective_parent (GdkWindow *window) GdkWindow * gdk_window_get_toplevel (GdkWindow *window) { - GdkWindowObject *obj; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - obj = (GdkWindowObject *)window; - - while (obj->window_type == GDK_WINDOW_CHILD) + while (window->window_type == GDK_WINDOW_CHILD) { - if (gdk_window_is_toplevel (obj)) + if (gdk_window_is_toplevel (window)) break; - obj = obj->parent; + window = window->parent; } - return GDK_WINDOW (obj); + return window; } /** @@ -2493,7 +2437,7 @@ gdk_window_get_children (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return NULL; - return g_list_copy (GDK_WINDOW_OBJECT (window)->children); + return g_list_copy (window->children); } /** @@ -2514,7 +2458,7 @@ gdk_window_peek_children (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return NULL; - return GDK_WINDOW_OBJECT (window)->children; + return window->children; } /** @@ -2537,14 +2481,12 @@ gdk_window_add_filter (GdkWindow *window, GdkFilterFunc function, gpointer data) { - GdkWindowObject *private; GList *tmp_list; GdkEventFilter *filter; g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); - private = (GdkWindowObject*) window; - if (private && GDK_WINDOW_DESTROYED (window)) + if (window && GDK_WINDOW_DESTROYED (window)) return; /* Filters are for the native events on the native window, so @@ -2552,8 +2494,8 @@ gdk_window_add_filter (GdkWindow *window, if (window) gdk_window_ensure_native (window); - if (private) - tmp_list = private->filters; + if (window) + tmp_list = window->filters; else tmp_list = _gdk_default_filters; @@ -2574,8 +2516,8 @@ gdk_window_add_filter (GdkWindow *window, filter->ref_count = 1; filter->flags = 0; - if (private) - private->filters = g_list_append (private->filters, filter); + if (window) + window->filters = g_list_append (window->filters, filter); else _gdk_default_filters = g_list_append (_gdk_default_filters, filter); } @@ -2594,16 +2536,13 @@ gdk_window_remove_filter (GdkWindow *window, GdkFilterFunc function, gpointer data) { - GdkWindowObject *private; GList *tmp_list, *node; GdkEventFilter *filter; g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); - private = (GdkWindowObject*) window; - - if (private) - tmp_list = private->filters; + if (window) + tmp_list = window->filters; else tmp_list = _gdk_default_filters; @@ -2620,8 +2559,8 @@ gdk_window_remove_filter (GdkWindow *window, if (filter->ref_count != 0) return; - if (private) - private->filters = g_list_remove_link (private->filters, node); + if (window) + window->filters = g_list_remove_link (window->filters, node); else _gdk_default_filters = g_list_remove_link (_gdk_default_filters, node); g_list_free_1 (node); @@ -2659,10 +2598,10 @@ gdk_screen_get_toplevel_windows (GdkScreen *screen) root_window = gdk_screen_get_root_window (screen); - tmp_list = ((GdkWindowObject *)root_window)->children; + tmp_list = root_window->children; while (tmp_list) { - GdkWindowObject *w = tmp_list->data; + GdkWindow *w = tmp_list->data; if (w->window_type != GDK_WINDOW_FOREIGN) new_list = g_list_prepend (new_list, w); @@ -2703,14 +2642,12 @@ gdk_window_is_visible (GdkWindow *window) gboolean gdk_window_is_viewable (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - if (private->destroyed) + if (window->destroyed) return FALSE; - return private->viewable; + return window->viewable; } /** @@ -2725,11 +2662,9 @@ gdk_window_is_viewable (GdkWindow *window) GdkWindowState gdk_window_get_state (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - return private->state; + return window->state; } static cairo_content_t @@ -2761,19 +2696,18 @@ gdk_window_get_content (GdkWindow *window) static gboolean gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowPaint *paint; - g_assert (gdk_window_has_impl (private)); + g_assert (gdk_window_has_impl (window)); if (_gdk_native_windows) return FALSE; /* No need for implicit paints since we can't merge draws anyway */ - if (GDK_IS_PAINTABLE (private->impl)) + if (GDK_IS_PAINTABLE (window->impl)) return FALSE; /* Implementation does double buffering */ - if (private->paint_stack != NULL || - private->implicit_paint != NULL) + if (window->paint_stack != NULL || + window->implicit_paint != NULL) return FALSE; /* Don't stack implicit paints */ /* Never do implicit paints for foreign windows, they don't need @@ -2781,7 +2715,7 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) * and creating surfaces for them is risky since they could disappear * at any time */ - if (private->window_type == GDK_WINDOW_FOREIGN) + if (window->window_type == GDK_WINDOW_FOREIGN) return FALSE; paint = g_new (GdkWindowPaint, 1); @@ -2794,7 +2728,7 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) MAX (rect->height, 1)); cairo_surface_set_device_offset (paint->surface, -rect->x, -rect->y); - private->implicit_paint = paint; + window->implicit_paint = paint; return TRUE; } @@ -2802,13 +2736,10 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) static cairo_t * gdk_cairo_create_for_impl (GdkWindow *window) { - GdkWindowObject *priv; cairo_surface_t *surface; cairo_t *cr; - priv = (GdkWindowObject*) window; - - surface = _gdk_drawable_ref_cairo_surface (priv->impl); + surface = _gdk_drawable_ref_cairo_surface (window->impl); cr = cairo_create (surface); cairo_surface_destroy (surface); @@ -2822,30 +2753,29 @@ gdk_cairo_create_for_impl (GdkWindow *window) static void gdk_window_flush_implicit_paint (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GdkWindowPaint *paint; cairo_region_t *region; GSList *list; - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); if (impl_window->implicit_paint == NULL) return; paint = impl_window->implicit_paint; paint->flushed = TRUE; - region = cairo_region_copy (private->clip_region_with_children); + region = cairo_region_copy (window->clip_region_with_children); /* Don't flush active double buffers, as that may show partially done * rendering */ - for (list = private->paint_stack; list != NULL; list = list->next) + for (list = window->paint_stack; list != NULL; list = list->next) { GdkWindowPaint *tmp_paint = list->data; cairo_region_subtract (region, tmp_paint->region); } - cairo_region_translate (region, -private->abs_x, -private->abs_y); + cairo_region_translate (region, -window->abs_x, -window->abs_y); cairo_region_intersect (region, paint->region); if (!GDK_WINDOW_DESTROYED (window) && !cairo_region_is_empty (region)) @@ -2872,16 +2802,15 @@ gdk_window_flush_implicit_paint (GdkWindow *window) static void gdk_window_end_implicit_paint (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowPaint *paint; - g_assert (gdk_window_has_impl (private)); + g_assert (gdk_window_has_impl (window)); - g_assert (private->implicit_paint != NULL); + g_assert (window->implicit_paint != NULL); - paint = private->implicit_paint; + paint = window->implicit_paint; - private->implicit_paint = NULL; + window->implicit_paint = NULL; if (!GDK_WINDOW_DESTROYED (window) && !cairo_region_is_empty (paint->region)) { @@ -2976,10 +2905,9 @@ gdk_window_begin_paint_region (GdkWindow *window, const cairo_region_t *region) { #ifdef USE_BACKING_STORE - GdkWindowObject *private = (GdkWindowObject *)window; GdkRectangle clip_box; GdkWindowPaint *paint, *implicit_paint; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GSList *list; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -2987,27 +2915,27 @@ gdk_window_begin_paint_region (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - if (GDK_IS_PAINTABLE (private->impl)) + if (GDK_IS_PAINTABLE (window->impl)) { - GdkPaintableIface *iface = GDK_PAINTABLE_GET_IFACE (private->impl); + GdkPaintableIface *iface = GDK_PAINTABLE_GET_IFACE (window->impl); if (iface->begin_paint_region) - iface->begin_paint_region ((GdkPaintable*)private->impl, window, region); + iface->begin_paint_region ((GdkPaintable*)window->impl, window, region); return; } - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); implicit_paint = impl_window->implicit_paint; paint = g_new (GdkWindowPaint, 1); paint->region = cairo_region_copy (region); paint->region_tag = new_region_tag (); - cairo_region_intersect (paint->region, private->clip_region_with_children); + cairo_region_intersect (paint->region, window->clip_region_with_children); cairo_region_get_extents (paint->region, &clip_box); - cairo_region_translate (paint->region, private->abs_x, private->abs_y); + cairo_region_translate (paint->region, window->abs_x, window->abs_y); /* Mark the region as valid on the implicit paint */ @@ -3015,14 +2943,14 @@ gdk_window_begin_paint_region (GdkWindow *window, cairo_region_union (implicit_paint->region, paint->region); /* Convert back to normal coords */ - cairo_region_translate (paint->region, -private->abs_x, -private->abs_y); + cairo_region_translate (paint->region, -window->abs_x, -window->abs_y); if (implicit_paint) { paint->uses_implicit = TRUE; paint->surface = cairo_surface_create_for_rectangle (implicit_paint->surface, - private->abs_x + clip_box.x, - private->abs_y + clip_box.y, + window->abs_x + clip_box.x, + window->abs_y + clip_box.y, MAX (clip_box.width, 1), MAX (clip_box.height, 1)); } @@ -3036,14 +2964,14 @@ gdk_window_begin_paint_region (GdkWindow *window, } cairo_surface_set_device_offset (paint->surface, -clip_box.x, -clip_box.y); - for (list = private->paint_stack; list != NULL; list = list->next) + for (list = window->paint_stack; list != NULL; list = list->next) { GdkWindowPaint *tmp_paint = list->data; cairo_region_subtract (tmp_paint->region, paint->region); } - private->paint_stack = g_slist_prepend (private->paint_stack, paint); + window->paint_stack = g_slist_prepend (window->paint_stack, paint); if (!cairo_region_is_empty (paint->region)) { @@ -3071,8 +2999,7 @@ void gdk_window_end_paint (GdkWindow *window) { #ifdef USE_BACKING_STORE - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *composited; + GdkWindow *composited; GdkWindowPaint *paint; GdkRectangle clip_box; cairo_region_t *full_clip; @@ -3082,25 +3009,25 @@ gdk_window_end_paint (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return; - if (GDK_IS_PAINTABLE (private->impl)) + if (GDK_IS_PAINTABLE (window->impl)) { - GdkPaintableIface *iface = GDK_PAINTABLE_GET_IFACE (private->impl); + GdkPaintableIface *iface = GDK_PAINTABLE_GET_IFACE (window->impl); if (iface->end_paint) - iface->end_paint ((GdkPaintable*)private->impl); + iface->end_paint ((GdkPaintable*)window->impl); return; } - if (private->paint_stack == NULL) + if (window->paint_stack == NULL) { g_warning (G_STRLOC": no preceding call to gdk_window_begin_paint_region(), see documentation"); return; } - paint = private->paint_stack->data; + paint = window->paint_stack->data; - private->paint_stack = g_slist_delete_link (private->paint_stack, - private->paint_stack); + window->paint_stack = g_slist_delete_link (window->paint_stack, + window->paint_stack); cairo_region_get_extents (paint->region, &clip_box); @@ -3110,7 +3037,7 @@ gdk_window_end_paint (GdkWindow *window) gdk_window_flush_outstanding_moves (window); - full_clip = cairo_region_copy (private->clip_region_with_children); + full_clip = cairo_region_copy (window->clip_region_with_children); cairo_region_intersect (full_clip, paint->region); cr = gdk_cairo_create (window); @@ -3132,7 +3059,7 @@ gdk_window_end_paint (GdkWindow *window) * stop if parent becomes NULL since then we'd have nowhere * to draw (ie: 'composited' will always be non-NULL here). */ - for (composited = private; + for (composited = window; composited->parent; composited = composited->parent) { @@ -3154,17 +3081,15 @@ gdk_window_end_paint (GdkWindow *window) static void gdk_window_free_paint_stack (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - - if (private->paint_stack) + if (window->paint_stack) { - GSList *tmp_list = private->paint_stack; + GSList *tmp_list = window->paint_stack; while (tmp_list) { GdkWindowPaint *paint = tmp_list->data; - if (tmp_list == private->paint_stack) + if (tmp_list == window->paint_stack) cairo_surface_destroy (paint->surface); cairo_region_destroy (paint->region); @@ -3173,13 +3098,13 @@ gdk_window_free_paint_stack (GdkWindow *window) tmp_list = tmp_list->next; } - g_slist_free (private->paint_stack); - private->paint_stack = NULL; + g_slist_free (window->paint_stack); + window->paint_stack = NULL; } } static void -do_move_region_bits_on_impl (GdkWindowObject *impl_window, +do_move_region_bits_on_impl (GdkWindow *impl_window, cairo_region_t *dest_region, /* In impl window coords */ int dx, int dy) { @@ -3187,7 +3112,7 @@ do_move_region_bits_on_impl (GdkWindowObject *impl_window, impl_class = GDK_WINDOW_IMPL_GET_CLASS (impl_window->impl); - impl_class->translate ((GdkWindow *) impl_window, dest_region, dx, dy); + impl_class->translate (impl_window, dest_region, dx, dy); } static GdkWindowRegionMove * @@ -3212,7 +3137,7 @@ gdk_window_region_move_free (GdkWindowRegionMove *move) } static void -append_move_region (GdkWindowObject *impl_window, +append_move_region (GdkWindow *impl_window, cairo_region_t *new_dest_region, int dx, int dy) { @@ -3327,7 +3252,7 @@ append_move_region (GdkWindowObject *impl_window, /* Moves bits and update area by dx/dy in impl window. Takes ownership of region to avoid copy (because we may change it) */ static void -move_region_on_impl (GdkWindowObject *impl_window, +move_region_on_impl (GdkWindow *impl_window, cairo_region_t *region, /* In impl window coords */ int dx, int dy) { @@ -3393,14 +3318,11 @@ move_region_on_impl (GdkWindowObject *impl_window, static void gdk_window_flush_outstanding_moves (GdkWindow *window) { - GdkWindowObject *private; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GList *l, *outstanding; GdkWindowRegionMove *move; - private = (GdkWindowObject *) window; - - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); outstanding = impl_window->outstanding_moves; impl_window->outstanding_moves = NULL; @@ -3457,11 +3379,9 @@ gdk_window_flush (GdkWindow *window) static void gdk_window_flush_if_exposing (GdkWindow *window) { - GdkWindowObject *private; - GdkWindowObject *impl_window; + GdkWindow *impl_window; - private = (GdkWindowObject *) window; - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); /* If we're in an implicit paint (i.e. in an expose handler, flush all the already finished exposes to get things to an uptodate state. */ @@ -3471,10 +3391,10 @@ gdk_window_flush_if_exposing (GdkWindow *window) static void -gdk_window_flush_recursive_helper (GdkWindowObject *window, +gdk_window_flush_recursive_helper (GdkWindow *window, GdkDrawable *impl) { - GdkWindowObject *child; + GdkWindow *child; GList *l; for (l = window->children; l != NULL; l = l->next) @@ -3490,9 +3410,9 @@ gdk_window_flush_recursive_helper (GdkWindowObject *window, } static void -gdk_window_flush_recursive (GdkWindowObject *window) +gdk_window_flush_recursive (GdkWindow *window) { - gdk_window_flush ((GdkWindow *)window); + gdk_window_flush (window); gdk_window_flush_recursive_helper (window, window->impl); } @@ -3512,19 +3432,16 @@ gdk_window_flush_recursive (GdkWindowObject *window) cairo_region_t* gdk_window_get_clip_region (GdkWindow *window) { - GdkWindowObject *private; cairo_region_t *result; g_return_val_if_fail (GDK_WINDOW (window), NULL); - private = (GdkWindowObject *) window; + result = cairo_region_copy (window->clip_region); - result = cairo_region_copy (private->clip_region); - - if (private->paint_stack) + if (window->paint_stack) { cairo_region_t *paint_region = cairo_region_create (); - GSList *tmp_list = private->paint_stack; + GSList *tmp_list = window->paint_stack; while (tmp_list) { @@ -3557,34 +3474,29 @@ gdk_window_get_clip_region (GdkWindow *window) cairo_region_t * gdk_window_get_visible_region (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject*) window; - - return cairo_region_copy (private->clip_region); + return cairo_region_copy (window->clip_region); } static cairo_t * setup_backing_rect (GdkWindow *window, GdkWindowPaint *paint, int x_offset_cairo, int y_offset_cairo) { - GdkWindowObject *private = (GdkWindowObject *) window; - GdkWindowObject *bg_private; + GdkWindow *bg_window; cairo_pattern_t *pattern = NULL; int x_offset = 0, y_offset = 0; cairo_t *cr; cr = cairo_create (paint->surface); - for (bg_private = private; bg_private; bg_private = bg_private->parent) + for (bg_window = window; bg_window; bg_window = bg_window->parent) { - pattern = gdk_window_get_background_pattern ((GdkWindow *) bg_private); + pattern = gdk_window_get_background_pattern (bg_window); if (pattern) break; - x_offset += bg_private->x; - y_offset += bg_private->y; + x_offset += bg_window->x; + y_offset += bg_window->y; } if (pattern) @@ -3603,8 +3515,7 @@ static void gdk_window_clear_backing_region (GdkWindow *window, cairo_region_t *region) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowPaint *paint = private->paint_stack->data; + GdkWindowPaint *paint = window->paint_stack->data; cairo_region_t *clip; GdkRectangle clipbox; cairo_t *cr; @@ -3630,7 +3541,6 @@ static void gdk_window_clear_backing_region_direct (GdkWindow *window, cairo_region_t *region) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowPaint paint; cairo_region_t *clip; GdkRectangle clipbox; @@ -3643,7 +3553,7 @@ gdk_window_clear_backing_region_direct (GdkWindow *window, cr = setup_backing_rect (window, &paint, 0, 0); - clip = cairo_region_copy (private->clip_region_with_children); + clip = cairo_region_copy (window->clip_region_with_children); cairo_region_intersect (clip, region); cairo_region_get_extents (clip, &clipbox); @@ -3661,32 +3571,30 @@ static void gdk_window_clear_region_internal (GdkWindow *window, cairo_region_t *region) { - GdkWindowObject *private = (GdkWindowObject *)window; - - if (private->paint_stack) + if (window->paint_stack) gdk_window_clear_backing_region (window, region); else gdk_window_clear_backing_region_direct (window, region); } static void -gdk_window_drop_cairo_surface (GdkWindowObject *private) +gdk_window_drop_cairo_surface (GdkWindow *window) { - if (private->cairo_surface) + if (window->cairo_surface) { - cairo_surface_finish (private->cairo_surface); - cairo_surface_set_user_data (private->cairo_surface, &gdk_window_cairo_key, + cairo_surface_finish (window->cairo_surface); + cairo_surface_set_user_data (window->cairo_surface, &gdk_window_cairo_key, NULL, NULL); - private->cairo_surface = NULL; + window->cairo_surface = NULL; } } static void gdk_window_cairo_surface_destroy (void *data) { - GdkWindowObject *private = (GdkWindowObject*) data; + GdkWindow *window = data; - private->cairo_surface = NULL; + window->cairo_surface = NULL; } static cairo_surface_t * @@ -3694,16 +3602,15 @@ gdk_window_create_cairo_surface (GdkWindow *window, int width, int height) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (window); cairo_surface_t *surface, *subsurface; - surface = _gdk_drawable_ref_cairo_surface (private->impl); - if (gdk_window_has_impl (private)) + surface = _gdk_drawable_ref_cairo_surface (window->impl); + if (gdk_window_has_impl (window)) return surface; subsurface = cairo_surface_create_for_rectangle (surface, - private->abs_x, - private->abs_y, + window->abs_x, + window->abs_y, width, height); cairo_surface_destroy (surface); @@ -3714,16 +3621,13 @@ gdk_window_create_cairo_surface (GdkWindow *window, cairo_surface_t * _gdk_window_ref_cairo_surface (GdkWindow *window) { - GdkWindowObject *private; cairo_surface_t *surface; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject*) window; - - if (private->paint_stack) + if (window->paint_stack) { - GdkWindowPaint *paint = private->paint_stack->data; + GdkWindowPaint *paint = window->paint_stack->data; surface = paint->surface; cairo_surface_reference (surface); @@ -3734,22 +3638,22 @@ _gdk_window_ref_cairo_surface (GdkWindow *window) /* This will be drawing directly to the window, so flush implicit paint */ gdk_window_flush (window); - if (!private->cairo_surface) + if (!window->cairo_surface) { - private->cairo_surface = gdk_window_create_cairo_surface (window, - private->width, - private->height); + window->cairo_surface = gdk_window_create_cairo_surface (window, + window->width, + window->height); - if (private->cairo_surface) + if (window->cairo_surface) { - cairo_surface_set_user_data (private->cairo_surface, &gdk_window_cairo_key, + cairo_surface_set_user_data (window->cairo_surface, &gdk_window_cairo_key, window, gdk_window_cairo_surface_destroy); } } else - cairo_surface_reference (private->cairo_surface); + cairo_surface_reference (window->cairo_surface); - surface = private->cairo_surface; + surface = window->cairo_surface; } return surface; @@ -3774,18 +3678,15 @@ _gdk_window_ref_cairo_surface (GdkWindow *window) cairo_t * gdk_cairo_create (GdkWindow *window) { - GdkWindowObject *private; cairo_surface_t *surface; cairo_t *cr; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject*) window; - surface = _gdk_window_ref_cairo_surface (window); cr = cairo_create (surface); - if (!private->paint_stack) + if (!window->paint_stack) { cairo_reset_clip (cr); @@ -3793,14 +3694,14 @@ gdk_cairo_create (GdkWindow *window) cairo_identity_matrix (cr); cairo_new_path (cr); - gdk_cairo_region (cr, private->clip_region_with_children); + gdk_cairo_region (cr, window->clip_region_with_children); cairo_restore (cr); cairo_clip (cr); } else { - GdkWindowPaint *paint = private->paint_stack->data; + GdkWindowPaint *paint = window->paint_stack->data; /* Only needs to clip to region if piggybacking on an implicit paint */ @@ -3835,7 +3736,7 @@ gdk_window_is_ancestor (GdkWindow *window, { while (window) { - GdkWindow *parent = (GdkWindow*) ((GdkWindowObject*) window)->parent; + GdkWindow *parent = window->parent; if (parent == ancestor) return TRUE; @@ -3855,7 +3756,7 @@ gdk_window_add_update_window (GdkWindow *window) for (tmp = update_windows; tmp; tmp = tmp->next) { - GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent; + GdkWindow *parent = window->parent; /* check if tmp is an ancestor of "window"; if it is, set a * flag indicating that all following windows are either @@ -3867,10 +3768,10 @@ gdk_window_add_update_window (GdkWindow *window) /* insert in reverse stacking order when adding around siblings, * so processing updates properly paints over lower stacked windows */ - if (parent == GDK_WINDOW_OBJECT (tmp->data)->parent) + if (parent == GDK_WINDOW (tmp->data)->parent) { gint index = g_list_index (parent->children, window); - for (; tmp && parent == GDK_WINDOW_OBJECT (tmp->data)->parent; tmp = tmp->next) + for (; tmp && parent == GDK_WINDOW (tmp->data)->parent; tmp = tmp->next) { gint sibling_index = g_list_index (parent->children, tmp->data); if (index > sibling_index) @@ -3936,9 +3837,9 @@ gdk_window_update_idle (gpointer data) static gboolean gdk_window_is_toplevel_frozen (GdkWindow *window) { - GdkWindowObject *toplevel; + GdkWindow *toplevel; - toplevel = (GdkWindowObject *)gdk_window_get_toplevel (window); + toplevel = gdk_window_get_toplevel (window); return toplevel->update_and_descendants_freeze_count > 0; } @@ -3947,7 +3848,7 @@ static void gdk_window_schedule_update (GdkWindow *window) { if (window && - (GDK_WINDOW_OBJECT (window)->update_freeze_count || + (window->update_freeze_count || gdk_window_is_toplevel_frozen (window))) return; @@ -3962,8 +3863,7 @@ void _gdk_window_process_updates_recurse (GdkWindow *window, cairo_region_t *expose_region) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *child; + GdkWindow *child; cairo_region_t *child_region; GdkRectangle r; GList *l, *children; @@ -3971,12 +3871,12 @@ _gdk_window_process_updates_recurse (GdkWindow *window, if (cairo_region_is_empty (expose_region)) return; - if (gdk_window_is_offscreen (private->impl_window) && - private == private->impl_window) - _gdk_window_add_damage ((GdkWindow *) private->impl_window, expose_region); + if (gdk_window_is_offscreen (window->impl_window) && + window == window->impl_window) + _gdk_window_add_damage ((GdkWindow *) window->impl_window, expose_region); /* Make this reentrancy safe for expose handlers freeing windows */ - children = g_list_copy (private->children); + children = g_list_copy (window->children); g_list_foreach (children, (GFunc)g_object_ref, NULL); /* Iterate over children, starting at topmost */ @@ -4006,7 +3906,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window, cairo_region_translate (child->shape, -child->x, -child->y); } - if (child->impl == private->impl) + if (child->impl == window->impl) { /* Client side child, expose */ cairo_region_intersect (child_region, expose_region); @@ -4026,9 +3926,9 @@ _gdk_window_process_updates_recurse (GdkWindow *window, g_list_free (children); if (!cairo_region_is_empty (expose_region) && - !private->destroyed) + !window->destroyed) { - if (private->event_mask & GDK_EXPOSURE_MASK) + if (window->event_mask & GDK_EXPOSURE_MASK) { GdkEvent event; @@ -4043,7 +3943,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window, g_object_unref (window); } - else if (private->window_type != GDK_WINDOW_FOREIGN) + else if (window->window_type != GDK_WINDOW_FOREIGN) { /* No exposure mask set, so nothing will be drawn, the * app relies on the background being what it specified @@ -4073,7 +3973,6 @@ _gdk_window_process_updates_recurse (GdkWindow *window, static void gdk_window_process_updates_internal (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowImplClass *impl_class; gboolean save_region = FALSE; GdkRectangle clip_box; @@ -4085,10 +3984,10 @@ gdk_window_process_updates_internal (GdkWindow *window) * window in the update queue that has an empty update_area. * just ignore it. */ - if (private->update_area) + if (window->update_area) { - cairo_region_t *update_area = private->update_area; - private->update_area = NULL; + cairo_region_t *update_area = window->update_area; + window->update_area = NULL; if (_gdk_event_func && gdk_window_is_viewable (window)) { @@ -4096,7 +3995,7 @@ gdk_window_process_updates_internal (GdkWindow *window) gboolean end_implicit; /* Clip to part visible in toplevel */ - cairo_region_intersect (update_area, private->clip_region); + cairo_region_intersect (update_area, window->clip_region); if (debug_updates) { @@ -4111,7 +4010,7 @@ gdk_window_process_updates_internal (GdkWindow *window) * be overdrawn by the expose anyway. So, in order to copy less data * we remove these areas from the outstanding moves. */ - if (private->outstanding_moves) + if (window->outstanding_moves) { GdkWindowRegionMove *move; cairo_region_t *remove; @@ -4120,7 +4019,7 @@ gdk_window_process_updates_internal (GdkWindow *window) remove = cairo_region_copy (update_area); /* We iterate backwards, starting from the state that would be if we had applied all the moves. */ - for (l = g_list_last (private->outstanding_moves); l != NULL; l = prev) + for (l = g_list_last (window->outstanding_moves); l != NULL; l = prev) { prev = l->prev; move = l->data; @@ -4137,8 +4036,8 @@ gdk_window_process_updates_internal (GdkWindow *window) if (cairo_region_is_empty (move->dest_region)) { gdk_window_region_move_free (move); - private->outstanding_moves = - g_list_delete_link (private->outstanding_moves, l); + window->outstanding_moves = + g_list_delete_link (window->outstanding_moves, l); } else /* move back */ cairo_region_translate (move->dest_region, move->dx, move->dy); @@ -4191,7 +4090,7 @@ gdk_window_process_updates_internal (GdkWindow *window) * moves and queue antiexposure immediately. No need to do * any tricks */ gdk_window_flush_outstanding_moves (window); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); save_region = impl_class->queue_antiexpose (window, update_area); } @@ -4211,10 +4110,10 @@ gdk_window_process_updates_internal (GdkWindow *window) * be to late to anti-expose now. Since this is merely an * optimization we just avoid doing it at all in that case. */ - if (private->implicit_paint != NULL && - !private->implicit_paint->flushed) + if (window->implicit_paint != NULL && + !window->implicit_paint->flushed) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); save_region = impl_class->queue_antiexpose (window, update_area); } @@ -4226,7 +4125,7 @@ gdk_window_process_updates_internal (GdkWindow *window) cairo_region_destroy (update_area); } - if (private->outstanding_moves) + if (window->outstanding_moves) { /* Flush any outstanding moves, may happen if we moved a window but got no actual invalid area */ @@ -4297,18 +4196,18 @@ gdk_window_process_all_updates (void) while (tmp_list) { - GdkWindowObject *private = (GdkWindowObject *)tmp_list->data; + GdkWindow *window = tmp_list->data; - if (!GDK_WINDOW_DESTROYED (tmp_list->data)) + if (!GDK_WINDOW_DESTROYED (window)) { - if (private->update_freeze_count || - gdk_window_is_toplevel_frozen (tmp_list->data)) - gdk_window_add_update_window ((GdkWindow *) private); + if (window->update_freeze_count || + gdk_window_is_toplevel_frozen (window)) + gdk_window_add_update_window (window); else - gdk_window_process_updates_internal (tmp_list->data); + gdk_window_process_updates_internal (window); } - g_object_unref (tmp_list->data); + g_object_unref (window); tmp_list = tmp_list->next; } @@ -4350,8 +4249,7 @@ void gdk_window_process_updates (GdkWindow *window, gboolean update_children) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -4361,7 +4259,7 @@ gdk_window_process_updates (GdkWindow *window, /* Make sure the window lives during the expose callouts */ g_object_ref (window); - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); if ((impl_window->update_area || impl_window->outstanding_moves) && !impl_window->update_freeze_count && @@ -4382,7 +4280,7 @@ gdk_window_process_updates (GdkWindow *window, */ GList *node, *children; - children = g_list_copy (private->children); + children = g_list_copy (window->children); g_list_foreach (children, (GFunc)g_object_ref, NULL); for (node = g_list_last (children); node; node = node->prev) @@ -4405,22 +4303,21 @@ gdk_window_invalidate_rect_full (GdkWindow *window, { GdkRectangle window_rect; cairo_region_t *region; - GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; - if (private->input_only || !private->viewable) + if (window->input_only || !window->viewable) return; if (!rect) { window_rect.x = 0; window_rect.y = 0; - window_rect.width = private->width; - window_rect.height = private->height; + window_rect.width = window->width; + window_rect.height = window->height; rect = &window_rect; } @@ -4464,16 +4361,16 @@ draw_ugly_color (GdkWindow *window, } static void -impl_window_add_update_area (GdkWindowObject *impl_window, +impl_window_add_update_area (GdkWindow *impl_window, cairo_region_t *region) { if (impl_window->update_area) cairo_region_union (impl_window->update_area, region); else { - gdk_window_add_update_window ((GdkWindow *)impl_window); + gdk_window_add_update_window (impl_window); impl_window->update_area = cairo_region_copy (region); - gdk_window_schedule_update ((GdkWindow *)impl_window); + gdk_window_schedule_update (impl_window); } } @@ -4494,8 +4391,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, GdkWindowChildFunc child_func, gpointer user_data) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; cairo_region_t *visible_region; GList *tmp_list; @@ -4504,19 +4400,19 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - if (private->input_only || - !private->viewable || + if (window->input_only || + !window->viewable || cairo_region_is_empty (region) || - private->window_type == GDK_WINDOW_ROOT) + window->window_type == GDK_WINDOW_ROOT) return; visible_region = gdk_window_get_visible_region (window); cairo_region_intersect (visible_region, region); - tmp_list = private->children; + tmp_list = window->children; while (tmp_list) { - GdkWindowObject *child = tmp_list->data; + GdkWindow *child = tmp_list->data; if (!child->input_only) { @@ -4555,7 +4451,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, tmp_list = tmp_list->next; } - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); if (!cairo_region_is_empty (visible_region) || /* Even if we're not exposing anything, make sure we process @@ -4567,13 +4463,13 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, draw_ugly_color (window, region); /* Convert to impl coords */ - cairo_region_translate (visible_region, private->abs_x, private->abs_y); + cairo_region_translate (visible_region, window->abs_x, window->abs_y); /* Only invalidate area if app requested expose events or if we need to clear the area (by request or to emulate background clearing for non-native windows or native windows with no support for window backgrounds */ - if (private->event_mask & GDK_EXPOSURE_MASK || + if (window->event_mask & GDK_EXPOSURE_MASK || clear_bg == CLEAR_BG_ALL || clear_bg == CLEAR_BG_WINCLEARED) impl_window_add_update_area (impl_window, visible_region); @@ -4697,7 +4593,6 @@ void _gdk_window_invalidate_for_expose (GdkWindow *window, cairo_region_t *region) { - GdkWindowObject *private = (GdkWindowObject *) window; GdkWindowRegionMove *move; cairo_region_t *move_region; GList *l; @@ -4708,7 +4603,7 @@ _gdk_window_invalidate_for_expose (GdkWindow *window, otherwise we would expose in the wrong place, as the outstanding moves will be copied before we draw the exposes. */ - for (l = private->outstanding_moves; l != NULL; l = l->next) + for (l = window->outstanding_moves; l != NULL; l = l->next) { move = l->data; @@ -4748,19 +4643,18 @@ _gdk_window_invalidate_for_expose (GdkWindow *window, cairo_region_t * gdk_window_get_update_area (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; cairo_region_t *tmp_region; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); if (impl_window->update_area) { - tmp_region = cairo_region_copy (private->clip_region_with_children); + tmp_region = cairo_region_copy (window->clip_region_with_children); /* Convert to impl coords */ - cairo_region_translate (tmp_region, private->abs_x, private->abs_y); + cairo_region_translate (tmp_region, window->abs_x, window->abs_y); cairo_region_intersect (tmp_region, impl_window->update_area); if (cairo_region_is_empty (tmp_region)) @@ -4782,7 +4676,7 @@ gdk_window_get_update_area (GdkWindow *window) } /* Convert from impl coords */ - cairo_region_translate (tmp_region, -private->abs_x, -private->abs_y); + cairo_region_translate (tmp_region, -window->abs_x, -window->abs_y); return tmp_region; } @@ -4801,16 +4695,14 @@ gdk_window_get_update_area (GdkWindow *window) void _gdk_window_clear_update_area (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - g_return_if_fail (GDK_IS_WINDOW (window)); - if (private->update_area) + if (window->update_area) { gdk_window_remove_update_window (window); - cairo_region_destroy (private->update_area); - private->update_area = NULL; + cairo_region_destroy (window->update_area); + window->update_area = NULL; } } @@ -4827,12 +4719,11 @@ _gdk_window_clear_update_area (GdkWindow *window) void gdk_window_freeze_updates (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; g_return_if_fail (GDK_IS_WINDOW (window)); - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); impl_window->update_freeze_count++; } @@ -4845,12 +4736,11 @@ gdk_window_freeze_updates (GdkWindow *window) void gdk_window_thaw_updates (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; g_return_if_fail (GDK_IS_WINDOW (window)); - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); g_return_if_fail (impl_window->update_freeze_count > 0); @@ -4876,12 +4766,10 @@ gdk_window_thaw_updates (GdkWindow *window) void gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - g_return_if_fail (GDK_IS_WINDOW (window)); - g_return_if_fail (private->window_type != GDK_WINDOW_CHILD); + g_return_if_fail (window->window_type != GDK_WINDOW_CHILD); - private->update_and_descendants_freeze_count++; + window->update_and_descendants_freeze_count++; } /** @@ -4897,13 +4785,11 @@ gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window) void gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - g_return_if_fail (GDK_IS_WINDOW (window)); - g_return_if_fail (private->window_type != GDK_WINDOW_CHILD); - g_return_if_fail (private->update_and_descendants_freeze_count > 0); + g_return_if_fail (window->window_type != GDK_WINDOW_CHILD); + g_return_if_fail (window->update_and_descendants_freeze_count > 0); - private->update_and_descendants_freeze_count--; + window->update_and_descendants_freeze_count--; gdk_window_schedule_update (window); } @@ -5214,13 +5100,13 @@ gdk_window_foreign_new (GdkNativeWindow anid) } static void -get_all_native_children (GdkWindowObject *private, +get_all_native_children (GdkWindow *window, GList **native) { - GdkWindowObject *child; + GdkWindow *child; GList *l; - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) { child = l->data; @@ -5235,9 +5121,8 @@ get_all_native_children (GdkWindowObject *private, static inline void gdk_window_raise_internal (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *parent = private->parent; - GdkWindowObject *above; + GdkWindow *parent = window->parent; + GdkWindow *above; GList *native_children; GList *l, listhead; GdkWindowImplClass *impl_class; @@ -5248,21 +5133,21 @@ gdk_window_raise_internal (GdkWindow *window) parent->children = g_list_prepend (parent->children, window); } - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); /* Just do native raise for toplevels */ - if (gdk_window_is_toplevel (private) || + if (gdk_window_is_toplevel (window) || /* The restack_under codepath should work correctly even if the parent is native, but it relies on the order of ->children to be correct, and some apps like SWT reorder the x windows without gdks knowledge, so we use raise directly in order to make these behave as before when using native windows */ - (gdk_window_has_impl (private) && gdk_window_has_impl (parent))) + (gdk_window_has_impl (window) && gdk_window_has_impl (parent))) { impl_class->raise (window); } - else if (gdk_window_has_impl (private)) + else if (gdk_window_has_impl (window)) { - above = find_native_sibling_above (parent, private); + above = find_native_sibling_above (parent, window); if (above) { listhead.data = window; @@ -5277,14 +5162,13 @@ gdk_window_raise_internal (GdkWindow *window) else { native_children = NULL; - get_all_native_children (private, &native_children); + get_all_native_children (window, &native_children); if (native_children != NULL) { - above = find_native_sibling_above (parent, private); + above = find_native_sibling_above (parent, window); if (above) - impl_class->restack_under ((GdkWindow *)above, - native_children); + impl_class->restack_under (above, native_children); else { /* Right order, since native_children is bottom-topmost first */ @@ -5300,10 +5184,10 @@ gdk_window_raise_internal (GdkWindow *window) /* Returns TRUE If the native window was mapped or unmapped */ static gboolean -set_viewable (GdkWindowObject *w, +set_viewable (GdkWindow *w, gboolean val) { - GdkWindowObject *child; + GdkWindow *child; GdkWindowImplClass *impl_class; GList *l; @@ -5371,43 +5255,40 @@ set_viewable (GdkWindowObject *w, gboolean _gdk_window_update_viewable (GdkWindow *window) { - GdkWindowObject *priv = (GdkWindowObject *)window; gboolean viewable; - if (priv->window_type == GDK_WINDOW_FOREIGN || - priv->window_type == GDK_WINDOW_ROOT) + if (window->window_type == GDK_WINDOW_FOREIGN || + window->window_type == GDK_WINDOW_ROOT) viewable = TRUE; - else if (gdk_window_is_toplevel (priv) || - priv->parent->viewable) - viewable = GDK_WINDOW_IS_MAPPED (priv); + else if (gdk_window_is_toplevel (window) || + window->parent->viewable) + viewable = GDK_WINDOW_IS_MAPPED (window); else viewable = FALSE; - return set_viewable (priv, viewable); + return set_viewable (window, viewable); } static void gdk_window_show_internal (GdkWindow *window, gboolean raise) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; gboolean was_mapped, was_viewable; gboolean did_show; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; was_mapped = GDK_WINDOW_IS_MAPPED (window); - was_viewable = private->viewable; + was_viewable = window->viewable; if (raise) /* Keep children in (reverse) stacking order */ gdk_window_raise_internal (window); - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { if (!was_mapped) gdk_synthesize_window_state (window, @@ -5416,7 +5297,7 @@ gdk_window_show_internal (GdkWindow *window, gboolean raise) } else { - private->state = 0; + window->state = 0; } did_show = _gdk_window_update_viewable (window); @@ -5426,28 +5307,27 @@ gdk_window_show_internal (GdkWindow *window, gboolean raise) for e.g. a foreign window. Dunno if this is strictly needed but its what happened pre-csw. Also show if not done by gdk_window_update_viewable. */ - if (gdk_window_has_impl (private) && (was_viewable || !did_show)) + if (gdk_window_has_impl (window) && (was_viewable || !did_show)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); - impl_class->show ((GdkWindow *)private, - !did_show ? was_mapped : TRUE); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); + impl_class->show (window, !did_show ? was_mapped : TRUE); } - if (!was_mapped && !gdk_window_has_impl (private)) + if (!was_mapped && !gdk_window_has_impl (window)) { - if (private->event_mask & GDK_STRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_MAP, NULL, FALSE); + if (window->event_mask & GDK_STRUCTURE_MASK) + _gdk_make_event (window, GDK_MAP, NULL, FALSE); - if (private->parent && private->parent->event_mask & GDK_SUBSTRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_MAP, NULL, FALSE); + if (window->parent && window->parent->event_mask & GDK_SUBSTRUCTURE_MASK) + _gdk_make_event (window, GDK_MAP, NULL, FALSE); } if (!was_mapped || raise) { - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); /* If any decendants became visible we need to send visibility notify */ - gdk_window_update_visibility_recursively (private, NULL); + gdk_window_update_visibility_recursively (window, NULL); if (gdk_window_is_viewable (window)) { @@ -5490,30 +5370,28 @@ gdk_window_show_unraised (GdkWindow *window) void gdk_window_raise (GdkWindow *window) { - GdkWindowObject *private; cairo_region_t *old_region, *new_region; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; gdk_window_flush_if_exposing (window); old_region = NULL; if (gdk_window_is_viewable (window) && - !private->input_only) - old_region = cairo_region_copy (private->clip_region); + !window->input_only) + old_region = cairo_region_copy (window->clip_region); /* Keep children in (reverse) stacking order */ gdk_window_raise_internal (window); - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); if (old_region) { - new_region = cairo_region_copy (private->clip_region); + new_region = cairo_region_copy (window->clip_region); cairo_region_subtract (new_region, old_region); gdk_window_invalidate_region_full (window, new_region, TRUE, CLEAR_BG_ALL); @@ -5526,10 +5404,9 @@ gdk_window_raise (GdkWindow *window) static void gdk_window_lower_internal (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowObject *parent = private->parent; + GdkWindow *parent = window->parent; GdkWindowImplClass *impl_class; - GdkWindowObject *above; + GdkWindow *above; GList *native_children; GList *l, listhead; @@ -5539,21 +5416,21 @@ gdk_window_lower_internal (GdkWindow *window) parent->children = g_list_append (parent->children, window); } - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); /* Just do native lower for toplevels */ - if (gdk_window_is_toplevel (private) || + if (gdk_window_is_toplevel (window) || /* The restack_under codepath should work correctly even if the parent is native, but it relies on the order of ->children to be correct, and some apps like SWT reorder the x windows without gdks knowledge, so we use lower directly in order to make these behave as before when using native windows */ - (gdk_window_has_impl (private) && gdk_window_has_impl (parent))) + (gdk_window_has_impl (window) && gdk_window_has_impl (parent))) { impl_class->lower (window); } - else if (gdk_window_has_impl (private)) + else if (gdk_window_has_impl (window)) { - above = find_native_sibling_above (parent, private); + above = find_native_sibling_above (parent, window); if (above) { listhead.data = window; @@ -5567,10 +5444,10 @@ gdk_window_lower_internal (GdkWindow *window) else { native_children = NULL; - get_all_native_children (private, &native_children); + get_all_native_children (window, &native_children); if (native_children != NULL) { - above = find_native_sibling_above (parent, private); + above = find_native_sibling_above (parent, window); if (above) impl_class->restack_under ((GdkWindow *)above, @@ -5589,7 +5466,7 @@ gdk_window_lower_internal (GdkWindow *window) } static void -gdk_window_invalidate_in_parent (GdkWindowObject *private) +gdk_window_invalidate_in_parent (GdkWindow *private) { GdkRectangle r, child; @@ -5607,7 +5484,7 @@ gdk_window_invalidate_in_parent (GdkWindowObject *private) child.height = private->height; gdk_rectangle_intersect (&r, &child, &r); - gdk_window_invalidate_rect_full (GDK_WINDOW (private->parent), &r, TRUE, CLEAR_BG_ALL); + gdk_window_invalidate_rect_full (private->parent, &r, TRUE, CLEAR_BG_ALL); } @@ -5629,12 +5506,9 @@ gdk_window_invalidate_in_parent (GdkWindowObject *private) void gdk_window_lower (GdkWindow *window) { - GdkWindowObject *private; - g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; gdk_window_flush_if_exposing (window); @@ -5642,10 +5516,10 @@ gdk_window_lower (GdkWindow *window) /* Keep children in (reverse) stacking order */ gdk_window_lower_internal (window); - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); _gdk_synthesize_crossing_events_for_geometry_change (window); - gdk_window_invalidate_in_parent (private); + gdk_window_invalidate_in_parent (window); } /** @@ -5672,10 +5546,9 @@ gdk_window_restack (GdkWindow *window, GdkWindow *sibling, gboolean above) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; - GdkWindowObject *parent; - GdkWindowObject *above_native; + GdkWindow *parent; + GdkWindow *above_native; GList *sibling_link; GList *native_children; GList *l, listhead; @@ -5683,8 +5556,7 @@ gdk_window_restack (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (sibling == NULL || GDK_IS_WINDOW (sibling)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; if (sibling == NULL) @@ -5698,15 +5570,15 @@ gdk_window_restack (GdkWindow *window, gdk_window_flush_if_exposing (window); - if (gdk_window_is_toplevel (private)) + if (gdk_window_is_toplevel (window)) { - g_return_if_fail (gdk_window_is_toplevel (GDK_WINDOW_OBJECT (sibling))); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + g_return_if_fail (gdk_window_is_toplevel (sibling)); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->restack_toplevel (window, sibling, above); return; } - parent = private->parent; + parent = window->parent; if (parent) { sibling_link = g_list_find (parent->children, sibling); @@ -5724,16 +5596,16 @@ gdk_window_restack (GdkWindow *window, sibling_link->next, window); - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); - if (gdk_window_has_impl (private)) + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); + if (gdk_window_has_impl (window)) { - above_native = find_native_sibling_above (parent, private); + above_native = find_native_sibling_above (parent, window); if (above_native) { listhead.data = window; listhead.next = NULL; listhead.prev = NULL; - impl_class->restack_under ((GdkWindow *)above_native, &listhead); + impl_class->restack_under (above_native, &listhead); } else impl_class->raise (window); @@ -5741,12 +5613,12 @@ gdk_window_restack (GdkWindow *window, else { native_children = NULL; - get_all_native_children (private, &native_children); + get_all_native_children (window, &native_children); if (native_children != NULL) { - above_native = find_native_sibling_above (parent, private); + above_native = find_native_sibling_above (parent, window); if (above_native) - impl_class->restack_under ((GdkWindow *)above_native, + impl_class->restack_under (above_native, native_children); else { @@ -5760,10 +5632,10 @@ gdk_window_restack (GdkWindow *window, } } - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); _gdk_synthesize_crossing_events_for_geometry_change (window); - gdk_window_invalidate_in_parent (private); + gdk_window_invalidate_in_parent (window); } @@ -5799,19 +5671,17 @@ gdk_window_show (GdkWindow *window) void gdk_window_hide (GdkWindow *window) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; gboolean was_mapped, did_hide; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; - was_mapped = GDK_WINDOW_IS_MAPPED (private); + was_mapped = GDK_WINDOW_IS_MAPPED (window); - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { if (GDK_WINDOW_IS_MAPPED (window)) @@ -5845,38 +5715,38 @@ gdk_window_hide (GdkWindow *window) gdk_device_ungrab (device, GDK_CURRENT_TIME); } - private->state = GDK_WINDOW_STATE_WITHDRAWN; + window->state = GDK_WINDOW_STATE_WITHDRAWN; g_list_free (devices); } did_hide = _gdk_window_update_viewable (window); /* Hide foreign window as those are not handled by update_viewable. */ - if (gdk_window_has_impl (private) && (!did_hide)) + if (gdk_window_has_impl (window) && (!did_hide)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->hide (window); } - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); /* all decendants became non-visible, we need to send visibility notify */ - gdk_window_update_visibility_recursively (private, NULL); + gdk_window_update_visibility_recursively (window, NULL); - if (was_mapped && !gdk_window_has_impl (private)) + if (was_mapped && !gdk_window_has_impl (window)) { - if (private->event_mask & GDK_STRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_UNMAP, NULL, FALSE); + if (window->event_mask & GDK_STRUCTURE_MASK) + _gdk_make_event (window, GDK_UNMAP, NULL, FALSE); - if (private->parent && private->parent->event_mask & GDK_SUBSTRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_UNMAP, NULL, FALSE); + if (window->parent && window->parent->event_mask & GDK_SUBSTRUCTURE_MASK) + _gdk_make_event (window, GDK_UNMAP, NULL, FALSE); - _gdk_synthesize_crossing_events_for_geometry_change (GDK_WINDOW (private->parent)); + _gdk_synthesize_crossing_events_for_geometry_change (window->parent); } /* Invalidate the rect */ if (was_mapped) - gdk_window_invalidate_in_parent (private); + gdk_window_invalidate_in_parent (window); } /** @@ -5890,35 +5760,33 @@ gdk_window_hide (GdkWindow *window) void gdk_window_withdraw (GdkWindow *window) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; gboolean was_mapped; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; - was_mapped = GDK_WINDOW_IS_MAPPED (private); + was_mapped = GDK_WINDOW_IS_MAPPED (window); - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->withdraw (window); if (was_mapped) { - if (private->event_mask & GDK_STRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_UNMAP, NULL, FALSE); + if (window->event_mask & GDK_STRUCTURE_MASK) + _gdk_make_event (window, GDK_UNMAP, NULL, FALSE); - if (private->parent && private->parent->event_mask & GDK_SUBSTRUCTURE_MASK) - _gdk_make_event (GDK_WINDOW (private), GDK_UNMAP, NULL, FALSE); + if (window->parent && window->parent->event_mask & GDK_SUBSTRUCTURE_MASK) + _gdk_make_event (window, GDK_UNMAP, NULL, FALSE); - _gdk_synthesize_crossing_events_for_geometry_change (GDK_WINDOW (private->parent)); + _gdk_synthesize_crossing_events_for_geometry_change (window->parent); } - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); } } @@ -5937,22 +5805,20 @@ void gdk_window_set_events (GdkWindow *window, GdkEventMask event_mask) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; /* If motion hint is disabled, enable motion events again */ display = gdk_window_get_display (window); - if ((private->event_mask & GDK_POINTER_MOTION_HINT_MASK) && + if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) && !(event_mask & GDK_POINTER_MOTION_HINT_MASK)) { - GList *devices = private->devices_inside; + GList *devices = window->devices_inside; while (devices) { @@ -5961,13 +5827,13 @@ gdk_window_set_events (GdkWindow *window, } } - private->event_mask = event_mask; + window->event_mask = event_mask; - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->set_events (window, - get_native_event_mask (private)); + get_native_event_mask (window)); } } @@ -5984,15 +5850,12 @@ gdk_window_set_events (GdkWindow *window, GdkEventMask gdk_window_get_events (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return 0; - return private->event_mask; + return window->event_mask; } /** @@ -6015,7 +5878,6 @@ gdk_window_set_device_events (GdkWindow *window, GdkEventMask event_mask) { GdkEventMask device_mask; - GdkWindowObject *private; GdkDisplay *display; GdkWindow *native; @@ -6025,26 +5887,24 @@ gdk_window_set_device_events (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; - private = (GdkWindowObject *) window; - /* If motion hint is disabled, enable motion events again */ display = gdk_window_get_display (window); - if ((private->event_mask & GDK_POINTER_MOTION_HINT_MASK) && + if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) && !(event_mask & GDK_POINTER_MOTION_HINT_MASK)) _gdk_display_enable_motion_hints (display, device); - if (G_UNLIKELY (!private->device_events)) - private->device_events = g_hash_table_new (NULL, NULL); + if (G_UNLIKELY (!window->device_events)) + window->device_events = g_hash_table_new (NULL, NULL); if (event_mask == 0) { /* FIXME: unsetting events on a master device - * would restore private->event_mask + * would restore window->event_mask */ - g_hash_table_remove (private->device_events, device); + g_hash_table_remove (window->device_events, device); } else - g_hash_table_insert (private->device_events, device, + g_hash_table_insert (window->device_events, device, GINT_TO_POINTER (event_mask)); if (_gdk_native_windows) @@ -6052,7 +5912,7 @@ gdk_window_set_device_events (GdkWindow *window, else native = gdk_window_get_toplevel (window); - while (gdk_window_is_offscreen ((GdkWindowObject *)native)) + while (gdk_window_is_offscreen (native)) { native = gdk_offscreen_window_get_embedder (native); @@ -6064,7 +5924,7 @@ gdk_window_set_device_events (GdkWindow *window, native = gdk_window_get_toplevel (native); } - device_mask = get_native_device_event_mask (private, device); + device_mask = get_native_device_event_mask (window, device); GDK_DEVICE_GET_CLASS (device)->select_window_events (device, native, device_mask); } @@ -6083,7 +5943,6 @@ GdkEventMask gdk_window_get_device_events (GdkWindow *window, GdkDevice *device) { - GdkWindowObject *private; GdkEventMask mask; g_return_val_if_fail (GDK_IS_WINDOW (window), 0); @@ -6092,14 +5951,12 @@ gdk_window_get_device_events (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return 0; - private = (GdkWindowObject *) window; - - if (!private->device_events) + if (!window->device_events) return 0; - mask = GPOINTER_TO_INT (g_hash_table_lookup (private->device_events, device)); + mask = GPOINTER_TO_INT (g_hash_table_lookup (window->device_events, device)); - /* FIXME: device could be controlled by private->event_mask */ + /* FIXME: device could be controlled by window->event_mask */ return mask; } @@ -6112,7 +5969,6 @@ gdk_window_move_resize_toplevel (GdkWindow *window, gint width, gint height) { - GdkWindowObject *private; cairo_region_t *old_region, *new_region; GdkWindowImplClass *impl_class; gboolean expose; @@ -6120,39 +5976,37 @@ gdk_window_move_resize_toplevel (GdkWindow *window, int dx, dy; gboolean is_resize; - private = (GdkWindowObject *) window; - expose = FALSE; old_region = NULL; - old_x = private->x; - old_y = private->y; + old_x = window->x; + old_y = window->y; is_resize = (width != -1) || (height != -1); if (gdk_window_is_viewable (window) && - !private->input_only) + !window->input_only) { expose = TRUE; - old_region = cairo_region_copy (private->clip_region); + old_region = cairo_region_copy (window->clip_region); } - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->move_resize (window, with_move, x, y, width, height); - dx = private->x - old_x; - dy = private->y - old_y; + dx = window->x - old_x; + dy = window->y - old_y; - old_abs_x = private->abs_x; - old_abs_y = private->abs_y; + old_abs_x = window->abs_x; + old_abs_y = window->abs_y; /* Avoid recomputing for pure toplevel moves, for performance reasons */ if (is_resize) - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); if (expose) { - new_region = cairo_region_copy (private->clip_region); + new_region = cairo_region_copy (window->clip_region); /* This is the newly exposed area (due to any resize), * X will expose it, but lets do that without the @@ -6170,10 +6024,10 @@ gdk_window_move_resize_toplevel (GdkWindow *window, static void -move_native_children (GdkWindowObject *private) +move_native_children (GdkWindow *private) { GList *l; - GdkWindowObject *child; + GdkWindow *child; GdkWindowImplClass *impl_class; for (l = private->children; l; l = l->next) @@ -6183,7 +6037,7 @@ move_native_children (GdkWindowObject *private) if (child->impl != private->impl) { impl_class = GDK_WINDOW_IMPL_GET_CLASS (child->impl); - impl_class->move_resize ((GdkWindow *)child, TRUE, + impl_class->move_resize (child, TRUE, child->x, child->y, child->width, child->height); } @@ -6193,13 +6047,13 @@ move_native_children (GdkWindowObject *private) } static gboolean -collect_native_child_region_helper (GdkWindowObject *window, +collect_native_child_region_helper (GdkWindow *window, GdkDrawable *impl, cairo_region_t **region, int x_offset, int y_offset) { - GdkWindowObject *child; + GdkWindow *child; cairo_region_t *tmp; GList *l; @@ -6234,7 +6088,7 @@ collect_native_child_region_helper (GdkWindowObject *window, } static cairo_region_t * -collect_native_child_region (GdkWindowObject *window, +collect_native_child_region (GdkWindow *window, gboolean include_this) { cairo_region_t *region; @@ -6258,10 +6112,9 @@ gdk_window_move_resize_internal (GdkWindow *window, gint width, gint height) { - GdkWindowObject *private; cairo_region_t *old_region, *new_region, *copy_area; cairo_region_t *old_native_child_region, *new_native_child_region; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GdkWindowImplClass *impl_class; gboolean expose; int old_x, old_y, old_abs_x, old_abs_y; @@ -6269,22 +6122,21 @@ gdk_window_move_resize_internal (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (private->destroyed) + if (window->destroyed) return; - if (gdk_window_is_toplevel (private)) + if (gdk_window_is_toplevel (window)) { gdk_window_move_resize_toplevel (window, with_move, x, y, width, height); return; } /* Bail early if no change */ - if (private->width == width && - private->height == height && + if (window->width == width && + window->height == height && (!with_move || - (private->x == x && - private->y == y))) + (window->x == x && + window->y == y))) return; gdk_window_flush_if_exposing (window); @@ -6294,26 +6146,26 @@ gdk_window_move_resize_internal (GdkWindow *window, expose = FALSE; old_region = NULL; - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); - old_x = private->x; - old_y = private->y; + old_x = window->x; + old_y = window->y; old_native_child_region = NULL; if (gdk_window_is_viewable (window) && - !private->input_only) + !window->input_only) { expose = TRUE; - old_region = cairo_region_copy (private->clip_region); + old_region = cairo_region_copy (window->clip_region); /* Adjust region to parent window coords */ - cairo_region_translate (old_region, private->x, private->y); + cairo_region_translate (old_region, window->x, window->y); - old_native_child_region = collect_native_child_region (private, TRUE); + old_native_child_region = collect_native_child_region (window, TRUE); if (old_native_child_region) { /* Adjust region to parent window coords */ - cairo_region_translate (old_native_child_region, private->x, private->y); + cairo_region_translate (old_native_child_region, window->x, window->y); /* Any native window move will immediately copy stuff to the destination, which may overwrite a * source or destination for a delayed GdkWindowRegionMove. So, we need @@ -6321,61 +6173,61 @@ gdk_window_move_resize_internal (GdkWindow *window, * of it. And we need to do this before setting the new clips as those will be * affecting this. */ - gdk_window_flush_recursive (private->parent); + gdk_window_flush_recursive (window->parent); } } /* Set the new position and size */ if (with_move) { - private->x = x; - private->y = y; + window->x = x; + window->y = y; } if (!(width < 0 && height < 0)) { if (width < 1) width = 1; - private->width = width; + window->width = width; if (height < 1) height = 1; - private->height = height; + window->height = height; } - dx = private->x - old_x; - dy = private->y - old_y; + dx = window->x - old_x; + dy = window->y - old_y; - old_abs_x = private->abs_x; - old_abs_y = private->abs_y; + old_abs_x = window->abs_x; + old_abs_y = window->abs_y; - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); new_native_child_region = NULL; if (old_native_child_region) { - new_native_child_region = collect_native_child_region (private, TRUE); + new_native_child_region = collect_native_child_region (window, TRUE); /* Adjust region to parent window coords */ - cairo_region_translate (new_native_child_region, private->x, private->y); + cairo_region_translate (new_native_child_region, window->x, window->y); } - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); /* Do the actual move after recomputing things, as this will have set the shape to the now correct one, thus avoiding copying regions that should not be copied. */ impl_class->move_resize (window, TRUE, - private->x, private->y, - private->width, private->height); + window->x, window->y, + window->width, window->height); } - else if (old_abs_x != private->abs_x || - old_abs_y != private->abs_y) - move_native_children (private); + else if (old_abs_x != window->abs_x || + old_abs_y != window->abs_y) + move_native_children (window); if (expose) { - new_region = cairo_region_copy (private->clip_region); + new_region = cairo_region_copy (window->clip_region); /* Adjust region to parent window coords */ - cairo_region_translate (new_region, private->x, private->y); + cairo_region_translate (new_region, window->x, window->y); /* copy_area: * Part of the data at the new location can be copied from the @@ -6414,10 +6266,10 @@ gdk_window_move_resize_internal (GdkWindow *window, cairo_region_subtract (new_region, copy_area); /* Convert old region to impl coords */ - cairo_region_translate (old_region, -dx + private->abs_x - private->x, -dy + private->abs_y - private->y); + cairo_region_translate (old_region, -dx + window->abs_x - window->x, -dy + window->abs_y - window->y); /* convert from parent coords to impl */ - cairo_region_translate (copy_area, private->abs_x - private->x, private->abs_y - private->y); + cairo_region_translate (copy_area, window->abs_x - window->x, window->abs_y - window->y); move_region_on_impl (impl_window, copy_area, dx, dy); /* takes ownership of copy_area */ @@ -6433,7 +6285,7 @@ gdk_window_move_resize_internal (GdkWindow *window, cairo_region_intersect (old_native_child_region, new_native_child_region); cairo_region_subtract (new_region, old_native_child_region); } - gdk_window_invalidate_region_full (GDK_WINDOW (private->parent), new_region, TRUE, CLEAR_BG_ALL); + gdk_window_invalidate_region_full (window->parent, new_region, TRUE, CLEAR_BG_ALL); cairo_region_destroy (old_region); cairo_region_destroy (new_region); @@ -6544,8 +6396,7 @@ gdk_window_scroll (GdkWindow *window, gint dx, gint dy) { - GdkWindowObject *private = (GdkWindowObject *) window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; cairo_region_t *copy_area, *noncopy_area; cairo_region_t *old_native_child_region, *new_native_child_region; GList *tmp_list; @@ -6555,12 +6406,12 @@ gdk_window_scroll (GdkWindow *window, if (dx == 0 && dy == 0) return; - if (private->destroyed) + if (window->destroyed) return; gdk_window_flush_if_exposing (window); - old_native_child_region = collect_native_child_region (private, FALSE); + old_native_child_region = collect_native_child_region (window, FALSE); if (old_native_child_region) { /* Any native window move will immediately copy stuff to the destination, which may overwrite a @@ -6569,39 +6420,38 @@ gdk_window_scroll (GdkWindow *window, * of it. And we need to do this before setting the new clips as those will be * affecting this. */ - gdk_window_flush_recursive (private); + gdk_window_flush_recursive (window); } /* First move all child windows, without causing invalidation */ - tmp_list = private->children; + tmp_list = window->children; while (tmp_list) { GdkWindow *child = GDK_WINDOW (tmp_list->data); - GdkWindowObject *child_obj = GDK_WINDOW_OBJECT (child); /* Just update the positions, the bits will move with the copy */ - child_obj->x += dx; - child_obj->y += dy; + child->x += dx; + child->y += dy; tmp_list = tmp_list->next; } - recompute_visible_regions (private, FALSE, TRUE); + recompute_visible_regions (window, FALSE, TRUE); new_native_child_region = NULL; if (old_native_child_region) - new_native_child_region = collect_native_child_region (private, FALSE); + new_native_child_region = collect_native_child_region (window, FALSE); - move_native_children (private); + move_native_children (window); /* Then copy the actual bits of the window w/ child windows */ - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); /* Calculate the area that can be gotten by copying the old area */ - copy_area = cairo_region_copy (private->clip_region); + copy_area = cairo_region_copy (window->clip_region); if (old_native_child_region) { /* Don't copy from inside native children, as this is copied by @@ -6614,14 +6464,14 @@ gdk_window_scroll (GdkWindow *window, cairo_region_subtract (copy_area, new_native_child_region); } cairo_region_translate (copy_area, dx, dy); - cairo_region_intersect (copy_area, private->clip_region); + cairo_region_intersect (copy_area, window->clip_region); /* And the rest need to be invalidated */ - noncopy_area = cairo_region_copy (private->clip_region); + noncopy_area = cairo_region_copy (window->clip_region); cairo_region_subtract (noncopy_area, copy_area); /* convert from window coords to impl */ - cairo_region_translate (copy_area, private->abs_x, private->abs_y); + cairo_region_translate (copy_area, window->abs_x, window->abs_y); move_region_on_impl (impl_window, copy_area, dx, dy); /* takes ownership of copy_area */ @@ -6667,8 +6517,7 @@ gdk_window_move_region (GdkWindow *window, gint dx, gint dy) { - GdkWindowObject *private = (GdkWindowObject *) window; - GdkWindowObject *impl_window; + GdkWindow *impl_window; cairo_region_t *nocopy_area; cairo_region_t *copy_area; @@ -6678,18 +6527,18 @@ gdk_window_move_region (GdkWindow *window, if (dx == 0 && dy == 0) return; - if (private->destroyed) + if (window->destroyed) return; - impl_window = gdk_window_get_impl_window (private); + impl_window = gdk_window_get_impl_window (window); /* compute source regions */ copy_area = cairo_region_copy (region); - cairo_region_intersect (copy_area, private->clip_region_with_children); + cairo_region_intersect (copy_area, window->clip_region_with_children); /* compute destination regions */ cairo_region_translate (copy_area, dx, dy); - cairo_region_intersect (copy_area, private->clip_region_with_children); + cairo_region_intersect (copy_area, window->clip_region_with_children); /* Invalidate parts of the region (source and dest) not covered by the copy */ @@ -6699,7 +6548,7 @@ gdk_window_move_region (GdkWindow *window, cairo_region_subtract (nocopy_area, copy_area); /* convert from window coords to impl */ - cairo_region_translate (copy_area, private->abs_x, private->abs_y); + cairo_region_translate (copy_area, window->abs_x, window->abs_y); move_region_on_impl (impl_window, copy_area, dx, dy); /* Takes ownership of copy_area */ gdk_window_invalidate_region_full (window, nocopy_area, FALSE, CLEAR_BG_ALL); @@ -6778,22 +6627,18 @@ void gdk_window_set_background_pattern (GdkWindow *window, cairo_pattern_t *pattern) { - GdkWindowObject *private; - g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (pattern) cairo_pattern_reference (pattern); - if (private->background) - cairo_pattern_destroy (private->background); - private->background = pattern; + if (window->background) + cairo_pattern_destroy (window->background); + window->background = pattern; - if (gdk_window_has_impl (private) && - !private->input_only) + if (gdk_window_has_impl (window) && + !window->input_only) { - GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->set_background (window, pattern); } } @@ -6814,11 +6659,9 @@ gdk_window_set_background_pattern (GdkWindow *window, cairo_pattern_t * gdk_window_get_background_pattern (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *) window; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - return private->background; + return window->background; } static void @@ -6828,12 +6671,11 @@ update_cursor_foreach (GdkDisplay *display, gpointer user_data) { GdkWindow *window = user_data; - GdkWindowObject *private = (GdkWindowObject *) window; if (_gdk_native_windows || - private->window_type == GDK_WINDOW_ROOT || - private->window_type == GDK_WINDOW_FOREIGN) - GDK_WINDOW_IMPL_GET_CLASS (private->impl)->set_device_cursor (window, device, private->cursor); + window->window_type == GDK_WINDOW_ROOT || + window->window_type == GDK_WINDOW_FOREIGN) + GDK_WINDOW_IMPL_GET_CLASS (window->impl)->set_device_cursor (window, device, window->cursor); else if (_gdk_window_event_parent_of (window, pointer_info->window_under_pointer)) update_cursor (display, device); } @@ -6856,13 +6698,9 @@ update_cursor_foreach (GdkDisplay *display, GdkCursor * gdk_window_get_cursor (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject *) window; - - return private->cursor; + return window->cursor; } /** @@ -6880,24 +6718,22 @@ void gdk_window_set_cursor (GdkWindow *window, GdkCursor *cursor) { - GdkWindowObject *private; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; display = gdk_window_get_display (window); - if (private->cursor) + if (window->cursor) { - gdk_cursor_unref (private->cursor); - private->cursor = NULL; + gdk_cursor_unref (window->cursor); + window->cursor = NULL; } if (!GDK_WINDOW_DESTROYED (window)) { if (cursor) - private->cursor = gdk_cursor_ref (cursor); + window->cursor = gdk_cursor_ref (cursor); _gdk_display_pointer_info_foreach (display, update_cursor_foreach, @@ -6927,14 +6763,10 @@ GdkCursor * gdk_window_get_device_cursor (GdkWindow *window, GdkDevice *device) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); g_return_val_if_fail (GDK_IS_DEVICE (device), NULL); - private = (GdkWindowObject *) window; - - return g_hash_table_lookup (private->device_cursor, device); + return g_hash_table_lookup (window->device_cursor, device); } /** @@ -6957,19 +6789,17 @@ gdk_window_set_device_cursor (GdkWindow *window, GdkDevice *device, GdkCursor *cursor) { - GdkWindowObject *private; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_DEVICE (device)); - private = (GdkWindowObject *) window; display = gdk_window_get_display (window); if (!cursor) - g_hash_table_remove (private->device_cursor, device); + g_hash_table_remove (window->device_cursor, device); else - g_hash_table_replace (private->device_cursor, device, gdk_cursor_ref (cursor)); + g_hash_table_replace (window->device_cursor, device, gdk_cursor_ref (cursor)); if (!GDK_WINDOW_DESTROYED (window)) { @@ -7022,7 +6852,7 @@ gdk_window_get_geometry (GdkWindow *window, gint *height, gint *depth) { - GdkWindowObject *private, *parent; + GdkWindow *parent; GdkWindowImplClass *impl_class; if (!window) @@ -7035,19 +6865,17 @@ gdk_window_get_geometry (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (!GDK_WINDOW_DESTROYED (window)) { - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->get_geometry (window, x, y, width, height, depth); /* This reports the position wrt to the native parent, we need to convert it to be relative to the client side parent */ - parent = private->parent; + parent = window->parent; if (parent && !gdk_window_has_impl (parent)) { if (x) @@ -7059,15 +6887,15 @@ gdk_window_get_geometry (GdkWindow *window, else { if (x) - *x = private->x; + *x = window->x; if (y) - *y = private->y; + *y = window->y; if (width) - *width = private->width; + *width = window->width; if (height) - *height = private->height; + *height = window->height; if (depth) - *depth = private->depth; + *depth = window->depth; } } } @@ -7089,13 +6917,9 @@ gdk_window_get_geometry (GdkWindow *window, int gdk_window_get_width (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowObject *) window; - - return private->width; + return window->width; } /** @@ -7115,13 +6939,9 @@ gdk_window_get_width (GdkWindow *window) int gdk_window_get_height (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowObject *) window; - - return private->height; + return window->height; } /** @@ -7142,7 +6962,6 @@ gdk_window_get_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; g_return_val_if_fail (GDK_IS_WINDOW (window), 0); @@ -7155,13 +6974,11 @@ gdk_window_get_origin (GdkWindow *window, *y = 0; return 0; } - - private = (GdkWindowObject *) window; - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->get_root_coords (window, - private->abs_x, - private->abs_y, + window->abs_x, + window->abs_y, x, y); return TRUE; @@ -7189,13 +7006,10 @@ gdk_window_get_root_coords (GdkWindow *window, gint *root_x, gint *root_y) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (GDK_WINDOW_DESTROYED (window)) { if (x) @@ -7205,10 +7019,10 @@ gdk_window_get_root_coords (GdkWindow *window, return; } - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); impl_class->get_root_coords (window, - x + private->abs_x, - y + private->abs_y, + x + window->abs_x, + y + window->abs_y, root_x, root_y); } @@ -7248,17 +7062,13 @@ gdk_window_coords_to_parent (GdkWindow *window, gdouble *parent_x, gdouble *parent_y) { - GdkWindowObject *obj; - g_return_if_fail (GDK_IS_WINDOW (window)); - obj = (GdkWindowObject *) window; - - if (gdk_window_is_offscreen (obj)) + if (gdk_window_is_offscreen (window)) { gdouble px, py; - to_embedder (obj, x, y, &px, &py); + to_embedder (window, x, y, &px, &py); if (parent_x) *parent_x = px; @@ -7269,10 +7079,10 @@ gdk_window_coords_to_parent (GdkWindow *window, else { if (parent_x) - *parent_x = x + obj->x; + *parent_x = x + window->x; if (parent_y) - *parent_y = y + obj->y; + *parent_y = y + window->y; } } @@ -7310,17 +7120,13 @@ gdk_window_coords_from_parent (GdkWindow *window, gdouble *x, gdouble *y) { - GdkWindowObject *obj; - g_return_if_fail (GDK_IS_WINDOW (window)); - obj = (GdkWindowObject *) window; - - if (gdk_window_is_offscreen (obj)) + if (gdk_window_is_offscreen (window)) { gdouble cx, cy; - from_embedder (obj, parent_x, parent_y, &cx, &cy); + from_embedder (window, parent_x, parent_y, &cx, &cy); if (x) *x = cx; @@ -7331,10 +7137,10 @@ gdk_window_coords_from_parent (GdkWindow *window, else { if (x) - *x = parent_x - obj->x; + *x = parent_x - window->x; if (y) - *y = parent_y - obj->y; + *y = parent_y - window->y; } } @@ -7366,42 +7172,39 @@ gdk_window_shape_combine_region (GdkWindow *window, gint offset_x, gint offset_y) { - GdkWindowObject *private; cairo_region_t *old_region, *new_region, *diff; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (GDK_WINDOW_DESTROYED (window)) return; - private->shaped = (shape_region != NULL); + window->shaped = (shape_region != NULL); - if (private->shape) - cairo_region_destroy (private->shape); + if (window->shape) + cairo_region_destroy (window->shape); old_region = NULL; if (GDK_WINDOW_IS_MAPPED (window)) - old_region = cairo_region_copy (private->clip_region); + old_region = cairo_region_copy (window->clip_region); if (shape_region) { - private->shape = cairo_region_copy (shape_region); - cairo_region_translate (private->shape, offset_x, offset_y); + window->shape = cairo_region_copy (shape_region); + cairo_region_translate (window->shape, offset_x, offset_y); } else - private->shape = NULL; + window->shape = NULL; - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); - if (gdk_window_has_impl (private) && - !should_apply_clip_as_shape (private)) - apply_shape (private, private->shape); + if (gdk_window_has_impl (window) && + !should_apply_clip_as_shape (window)) + apply_shape (window, window->shape); if (old_region) { - new_region = cairo_region_copy (private->clip_region); + new_region = cairo_region_copy (window->clip_region); /* New area in the window, needs invalidation */ diff = cairo_region_copy (new_region); @@ -7411,16 +7214,16 @@ gdk_window_shape_combine_region (GdkWindow *window, cairo_region_destroy (diff); - if (!gdk_window_is_toplevel (private)) + if (!gdk_window_is_toplevel (window)) { /* New area in the non-root parent window, needs invalidation */ diff = cairo_region_copy (old_region); cairo_region_subtract (diff, new_region); /* Adjust region to parent window coords */ - cairo_region_translate (diff, private->x, private->y); + cairo_region_translate (diff, window->x, window->y); - gdk_window_invalidate_region_full (GDK_WINDOW (private->parent), diff, TRUE, CLEAR_BG_ALL); + gdk_window_invalidate_region_full (window->parent, diff, TRUE, CLEAR_BG_ALL); cairo_region_destroy (diff); } @@ -7434,22 +7237,19 @@ static void do_child_shapes (GdkWindow *window, gboolean merge) { - GdkWindowObject *private; GdkRectangle r; cairo_region_t *region; - private = (GdkWindowObject *) window; - r.x = 0; r.y = 0; - r.width = private->width; - r.height = private->height; + r.width = window->width; + r.height = window->height; region = cairo_region_create_rectangle (&r); - remove_child_area (private, NULL, FALSE, region); + remove_child_area (window, NULL, FALSE, region); - if (merge && private->shape) - cairo_region_subtract (region, private->shape); + if (merge && window->shape) + cairo_region_subtract (region, window->shape); gdk_window_shape_combine_region (window, region, 0, 0); } @@ -7524,31 +7324,28 @@ gdk_window_input_shape_combine_region (GdkWindow *window, gint offset_x, gint offset_y) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *) window; - if (GDK_WINDOW_DESTROYED (window)) return; - if (private->input_shape) - cairo_region_destroy (private->input_shape); + if (window->input_shape) + cairo_region_destroy (window->input_shape); if (shape_region) { - private->input_shape = cairo_region_copy (shape_region); - cairo_region_translate (private->input_shape, offset_x, offset_y); + window->input_shape = cairo_region_copy (shape_region); + cairo_region_translate (window->input_shape, offset_x, offset_y); } else - private->input_shape = NULL; + window->input_shape = NULL; - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); - impl_class->input_shape_combine_region (window, private->input_shape, 0, 0); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); + impl_class->input_shape_combine_region (window, window->input_shape, 0, 0); } /* Pointer may have e.g. moved outside window due to the input mask change */ @@ -7559,24 +7356,21 @@ static void do_child_input_shapes (GdkWindow *window, gboolean merge) { - GdkWindowObject *private; GdkRectangle r; cairo_region_t *region; - private = (GdkWindowObject *) window; - r.x = 0; r.y = 0; - r.width = private->width; - r.height = private->height; + r.width = window->width; + r.height = window->height; region = cairo_region_create_rectangle (&r); - remove_child_area (private, NULL, TRUE, region); + remove_child_area (window, NULL, TRUE, region); - if (merge && private->shape) - cairo_region_subtract (region, private->shape); - if (merge && private->input_shape) - cairo_region_subtract (region, private->input_shape); + if (merge && window->shape) + cairo_region_subtract (region, window->shape); + if (merge && window->input_shape) + cairo_region_subtract (region, window->input_shape); gdk_window_input_shape_combine_region (window, region, 0, 0); } @@ -7641,16 +7435,13 @@ gboolean gdk_window_set_static_gravities (GdkWindow *window, gboolean use_static) { - GdkWindowObject *private; GdkWindowImplClass *impl_class; g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *) window; - - if (gdk_window_has_impl (private)) + if (gdk_window_has_impl (window)) { - impl_class = GDK_WINDOW_IMPL_GET_CLASS (private->impl); + impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); return impl_class->set_static_gravities (window, use_static); } @@ -7672,13 +7463,9 @@ gdk_window_set_static_gravities (GdkWindow *window, gboolean gdk_window_get_composited (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *)window; - - return private->composited; + return window->composited; } /** @@ -7716,14 +7503,13 @@ void gdk_window_set_composited (GdkWindow *window, gboolean composited) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); composited = composited != FALSE; - if (private->composited == composited) + if (window->composited == composited) return; if (composited) @@ -7740,12 +7526,12 @@ gdk_window_set_composited (GdkWindow *window, _gdk_windowing_window_set_composited (window, composited); - recompute_visible_regions (private, TRUE, FALSE); + recompute_visible_regions (window, TRUE, FALSE); if (GDK_WINDOW_IS_MAPPED (window)) - gdk_window_invalidate_in_parent (private); + gdk_window_invalidate_in_parent (window); - private->composited = composited; + window->composited = composited; } /** @@ -7762,13 +7548,9 @@ gdk_window_set_composited (GdkWindow *window, gboolean gdk_window_get_modal_hint (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject*) window; - - return private->modal_hint; + return window->modal_hint; } /** @@ -7785,13 +7567,9 @@ gdk_window_get_modal_hint (GdkWindow *window) gboolean gdk_window_get_accept_focus (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *)window; - - return private->accept_focus; + return window->accept_focus; } /** @@ -7809,13 +7587,9 @@ gdk_window_get_accept_focus (GdkWindow *window) gboolean gdk_window_get_focus_on_map (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *)window; - - return private->focus_on_map; + return window->focus_on_map; } /** @@ -7831,13 +7605,9 @@ gdk_window_get_focus_on_map (GdkWindow *window) gboolean gdk_window_is_input_only (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *)window; - - return private->input_only; + return window->input_only; } /** @@ -7853,24 +7623,18 @@ gdk_window_is_input_only (GdkWindow *window) gboolean gdk_window_is_shaped (GdkWindow *window) { - GdkWindowObject *private; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - private = (GdkWindowObject *)window; - - return private->shaped; + return window->shaped; } static void window_get_size_rectangle (GdkWindow *window, GdkRectangle *rect) { - GdkWindowObject *private = (GdkWindowObject *) window; - rect->x = rect->y = 0; - rect->width = private->width; - rect->height = private->height; + rect->width = window->width; + rect->height = window->height; } /* Calculates the real clipping region for a window, in window coordinates, @@ -7883,18 +7647,17 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window, gint *base_x_offset, gint *base_y_offset) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (window); GdkRectangle visible_rect; cairo_region_t *real_clip_region; gint x_offset, y_offset; - GdkWindowObject *parentwin, *lastwin; + GdkWindow *parentwin, *lastwin; if (base_x_offset) *base_x_offset = 0; if (base_y_offset) *base_y_offset = 0; - if (!private->viewable || private->input_only) + if (!window->viewable || window->input_only) return cairo_region_create (); window_get_size_rectangle (window, &visible_rect); @@ -7904,7 +7667,7 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window, x_offset = y_offset = 0; - lastwin = private; + lastwin = window; if (do_children) parentwin = lastwin; else @@ -7912,16 +7675,16 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window, /* Remove the areas of all overlapping windows above parentwin in the hiearachy */ for (; parentwin != NULL && - (parentwin == private || lastwin != (GdkWindowObject*) base_window); + (parentwin == window || lastwin != base_window); lastwin = parentwin, parentwin = lastwin->parent) { GList *cur; GdkRectangle real_clip_rect; - if (parentwin != private) + if (parentwin != window) { - x_offset += GDK_WINDOW_OBJECT (lastwin)->x; - y_offset += GDK_WINDOW_OBJECT (lastwin)->y; + x_offset += lastwin->x; + y_offset += lastwin->y; } /* children is ordered in reverse stack order */ @@ -7930,21 +7693,20 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window, cur = cur->next) { GdkWindow *child = cur->data; - GdkWindowObject *child_private = (GdkWindowObject *)child; - if (!GDK_WINDOW_IS_MAPPED (child) || child_private->input_only) + if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only) continue; /* Ignore offscreen children, as they don't draw in their parent and * don't take part in the clipping */ - if (gdk_window_is_offscreen (child_private)) + if (gdk_window_is_offscreen (child)) continue; window_get_size_rectangle (child, &visible_rect); /* Convert rect to "window" coords */ - visible_rect.x += child_private->x - x_offset; - visible_rect.y += child_private->y - y_offset; + visible_rect.x += child->x - x_offset; + visible_rect.y += child->y - y_offset; /* This shortcut is really necessary for performance when there are a lot of windows */ cairo_region_get_extents (real_clip_region, &real_clip_rect); @@ -7991,11 +7753,11 @@ _gdk_window_add_damage (GdkWindow *toplevel, /* Gets the toplevel for a window as used for events, i.e. including offscreen parents */ -static GdkWindowObject * -get_event_parent (GdkWindowObject *window) +static GdkWindow * +get_event_parent (GdkWindow *window) { if (gdk_window_is_offscreen (window)) - return (GdkWindowObject *)gdk_offscreen_window_get_embedder ((GdkWindow *)window); + return gdk_offscreen_window_get_embedder ((GdkWindow *)window); else return window->parent; } @@ -8004,16 +7766,15 @@ get_event_parent (GdkWindowObject *window) i.e. including offscreen parents going up to the native toplevel */ static GdkWindow * -get_event_toplevel (GdkWindow *w) +get_event_toplevel (GdkWindow *window) { - GdkWindowObject *private = GDK_WINDOW_OBJECT (w); - GdkWindowObject *parent; + GdkWindow *parent; - while ((parent = get_event_parent (private)) != NULL && + while ((parent = get_event_parent (window)) != NULL && (parent->window_type != GDK_WINDOW_ROOT)) - private = parent; + window = parent; - return GDK_WINDOW (private); + return window; } gboolean @@ -8028,7 +7789,7 @@ _gdk_window_event_parent_of (GdkWindow *parent, if (w == parent) return TRUE; - w = (GdkWindow *)get_event_parent ((GdkWindowObject *)w); + w = get_event_parent (w); } return FALSE; @@ -8038,7 +7799,7 @@ static void update_cursor (GdkDisplay *display, GdkDevice *device) { - GdkWindowObject *cursor_window, *parent, *toplevel; + GdkWindow *cursor_window, *parent, *toplevel; GdkWindow *pointer_window; GdkWindowImplClass *impl_class; GdkPointerWindowInfo *pointer_info; @@ -8057,12 +7818,12 @@ update_cursor (GdkDisplay *display, !_gdk_window_event_parent_of (grab->window, pointer_window)) { /* use the cursor from the grab window */ - cursor_window = (GdkWindowObject *) grab->window; + cursor_window = grab->window; } else { /* otherwise use the cursor from the pointer window */ - cursor_window = (GdkWindowObject *) pointer_window; + cursor_window = pointer_window; } /* Find the first window with the cursor actually set, as @@ -8079,15 +7840,15 @@ update_cursor (GdkDisplay *display, /* Set all cursors on toplevel, otherwise its tricky to keep track of * which native window has what cursor set. */ - toplevel = (GdkWindowObject *) get_event_toplevel (pointer_window); + toplevel = get_event_toplevel (pointer_window); impl_class = GDK_WINDOW_IMPL_GET_CLASS (toplevel->impl); - impl_class->set_device_cursor ((GdkWindow *) toplevel, device, cursor); + impl_class->set_device_cursor (toplevel, device, cursor); } static gboolean -point_in_window (GdkWindowObject *window, - gdouble x, - gdouble y) +point_in_window (GdkWindow *window, + gdouble x, + gdouble y) { return x >= 0 && x < window->width && @@ -8107,23 +7868,22 @@ convert_native_coords_to_toplevel (GdkWindow *window, gdouble *toplevel_x, gdouble *toplevel_y) { - GdkWindowObject *private = (GdkWindowObject *)window; gdouble x, y; x = child_x; y = child_y; - while (!gdk_window_is_toplevel (private)) + while (!gdk_window_is_toplevel (window)) { - x += private->x; - y += private->y; - private = private->parent; + x += window->x; + y += window->y; + window = window->parent; } *toplevel_x = x; *toplevel_y = y; - return (GdkWindow *)private; + return window; } static void @@ -8133,22 +7893,19 @@ convert_toplevel_coords_to_window (GdkWindow *window, gdouble *window_x, gdouble *window_y) { - GdkWindowObject *private; - GdkWindowObject *parent; + GdkWindow *parent; gdouble x, y; GList *children, *l; - private = GDK_WINDOW_OBJECT (window); - x = toplevel_x; y = toplevel_y; children = NULL; - while ((parent = get_event_parent (private)) != NULL && + while ((parent = get_event_parent (window)) != NULL && (parent->window_type != GDK_WINDOW_ROOT)) { - children = g_list_prepend (children, private); - private = parent; + children = g_list_prepend (children, window); + window = parent; } for (l = children; l != NULL; l = l->next) @@ -8160,12 +7917,12 @@ convert_toplevel_coords_to_window (GdkWindow *window, *window_y = y; } -static GdkWindowObject * -pick_embedded_child (GdkWindowObject *window, - gdouble x, - gdouble y) +static GdkWindow * +pick_embedded_child (GdkWindow *window, + gdouble x, + gdouble y) { - GdkWindowObject *res; + GdkWindow *res; res = NULL; g_signal_emit (window, @@ -8180,16 +7937,14 @@ _gdk_window_find_child_at (GdkWindow *window, int x, int y) { - GdkWindowObject *private, *sub; + GdkWindow *sub; double child_x, child_y; GList *l; - private = (GdkWindowObject *)window; - - if (point_in_window (private, x, y)) + if (point_in_window (window, x, y)) { /* Children is ordered in reverse stack order, i.e. first is topmost */ - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) { sub = l->data; @@ -8203,9 +7958,9 @@ _gdk_window_find_child_at (GdkWindow *window, return (GdkWindow *)sub; } - if (private->num_offscreen_children > 0) + if (window->num_offscreen_children > 0) { - sub = pick_embedded_child (private, + sub = pick_embedded_child (window, x, y); if (sub) return (GdkWindow *)sub; @@ -8216,26 +7971,24 @@ _gdk_window_find_child_at (GdkWindow *window, } GdkWindow * -_gdk_window_find_descendant_at (GdkWindow *toplevel, +_gdk_window_find_descendant_at (GdkWindow *window, gdouble x, gdouble y, gdouble *found_x, gdouble *found_y) { - GdkWindowObject *private, *sub; + GdkWindow *sub; gdouble child_x, child_y; GList *l; gboolean found; - private = (GdkWindowObject *)toplevel; - - if (point_in_window (private, x, y)) + if (point_in_window (window, x, y)) { do { found = FALSE; /* Children is ordered in reverse stack order, i.e. first is topmost */ - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) { sub = l->data; @@ -8249,20 +8002,20 @@ _gdk_window_find_descendant_at (GdkWindow *toplevel, { x = child_x; y = child_y; - private = sub; + window = sub; found = TRUE; break; } } if (!found && - private->num_offscreen_children > 0) + window->num_offscreen_children > 0) { - sub = pick_embedded_child (private, + sub = pick_embedded_child (window, x, y); if (sub) { found = TRUE; - private = sub; + window = sub; from_embedder (sub, x, y, &x, &y); } } @@ -8272,7 +8025,7 @@ _gdk_window_find_descendant_at (GdkWindow *toplevel, else { /* Not in window at all */ - private = NULL; + window = NULL; } if (found_x) @@ -8280,7 +8033,7 @@ _gdk_window_find_descendant_at (GdkWindow *toplevel, if (found_y) *found_y = y; - return (GdkWindow *)private; + return window; } /** @@ -8307,7 +8060,7 @@ gdk_window_beep (GdkWindow *window) toplevel = get_event_toplevel (window); display = gdk_window_get_display (window); - if (toplevel && !gdk_window_is_offscreen ((GdkWindowObject *)toplevel)) + if (toplevel && !gdk_window_is_offscreen (toplevel)) _gdk_windowing_window_beep (toplevel); else gdk_display_beep (display); @@ -8329,17 +8082,15 @@ void gdk_window_set_support_multidevice (GdkWindow *window, gboolean support_multidevice) { - GdkWindowObject *private = (GdkWindowObject *) window; - g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; - if (private->support_multidevice == support_multidevice) + if (window->support_multidevice == support_multidevice) return; - private->support_multidevice = support_multidevice; + window->support_multidevice = support_multidevice; /* FIXME: What to do if called when some pointers are inside the window ? */ } @@ -8358,14 +8109,12 @@ gdk_window_set_support_multidevice (GdkWindow *window, gboolean gdk_window_get_support_multidevice (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *) window; - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); if (GDK_WINDOW_DESTROYED (window)) return FALSE; - return private->support_multidevice; + return window->support_multidevice; } static const guint type_masks[] = { @@ -8448,11 +8197,11 @@ is_motion_type (GdkEventType type) type == GDK_LEAVE_NOTIFY; } -static GdkWindowObject * -find_common_ancestor (GdkWindowObject *win1, - GdkWindowObject *win2) +static GdkWindow * +find_common_ancestor (GdkWindow *win1, + GdkWindow *win2) { - GdkWindowObject *tmp; + GdkWindow *tmp; GList *path1 = NULL, *path2 = NULL; GList *list1, *list2; @@ -8475,7 +8224,7 @@ find_common_ancestor (GdkWindowObject *win1, tmp = NULL; while (list1 && list2 && (list1->data == list2->data)) { - tmp = (GdkWindowObject *)list1->data; + tmp = list1->data; list1 = g_list_next (list1); list2 = g_list_next (list2); } @@ -8591,8 +8340,8 @@ _gdk_make_event (GdkWindow *window, static void send_crossing_event (GdkDisplay *display, - GdkWindowObject *toplevel, - GdkWindowObject *window, + GdkWindow *toplevel, + GdkWindow *window, GdkEventType type, GdkCrossingMode mode, GdkNotifyType notify_type, @@ -8693,19 +8442,19 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, gulong serial, gboolean non_linear) { - GdkWindowObject *c; - GdkWindowObject *win, *last, *next; + GdkWindow *c; + GdkWindow *win, *last, *next; GList *path, *list; - GdkWindowObject *a; - GdkWindowObject *b; - GdkWindowObject *toplevel; + GdkWindow *a; + GdkWindow *b; + GdkWindow *toplevel; GdkNotifyType notify_type; /* TODO: Don't send events to toplevel, as we get those from the windowing system */ - a = (GdkWindowObject *)src; - b = (GdkWindowObject *)dest; - if (a == b) + a = src; + b = dest; + if (src == dest) return; /* No crossings generated between src and dest */ if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER) @@ -8726,7 +8475,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, if (a) /* There might not be a source (i.e. if no previous pointer_in_window) */ { - toplevel = (GdkWindowObject *)gdk_window_get_toplevel ((GdkWindow *)a); + toplevel = gdk_window_get_toplevel (a); /* Traverse up from a to (excluding) c sending leave events */ if (non_linear) @@ -8775,7 +8524,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, if (b) /* Might not be a dest, e.g. if we're moving out of the window */ { - toplevel = (GdkWindowObject *)gdk_window_get_toplevel ((GdkWindow *)b); + toplevel = gdk_window_get_toplevel ((GdkWindow *)b); /* Traverse down from c to b */ if (c != b) @@ -8796,10 +8545,10 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, list = path; while (list) { - win = (GdkWindowObject *)list->data; + win = list->data; list = g_list_next (list); if (list) - next = (GdkWindowObject *)list->data; + next = list->data; else next = b; @@ -8987,7 +8736,7 @@ gdk_pointer_grab (GdkWindow * window, native = window; else native = gdk_window_get_toplevel (window); - while (gdk_window_is_offscreen ((GdkWindowObject *)native)) + while (gdk_window_is_offscreen (native)) { native = gdk_offscreen_window_get_embedder (native); @@ -9092,7 +8841,7 @@ gdk_keyboard_grab (GdkWindow *window, else native = gdk_window_get_toplevel (window); - while (gdk_window_is_offscreen ((GdkWindowObject *)native)) + while (gdk_window_is_offscreen (native)) { native = gdk_offscreen_window_get_embedder (native); @@ -9168,15 +8917,13 @@ do_synthesize_crossing_event (gpointer data) { GdkDisplay *display; GdkWindow *changed_toplevel; - GdkWindowObject *changed_toplevel_priv; GHashTableIter iter; gpointer key, value; gulong serial; changed_toplevel = data; - changed_toplevel_priv = (GdkWindowObject *)changed_toplevel; - changed_toplevel_priv->synthesize_crossing_event_queued = FALSE; + changed_toplevel->synthesize_crossing_event_queued = FALSE; if (GDK_WINDOW_DESTROYED (changed_toplevel)) return FALSE; @@ -9226,7 +8973,6 @@ _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window) { GdkDisplay *display; GdkWindow *toplevel; - GdkWindowObject *toplevel_priv; if (_gdk_native_windows) return; /* We use the native crossing events if all native */ @@ -9234,11 +8980,10 @@ _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window) display = gdk_window_get_display (changed_window); toplevel = get_event_toplevel (changed_window); - toplevel_priv = (GdkWindowObject *) toplevel; - if (!toplevel_priv->synthesize_crossing_event_queued) + if (!toplevel->synthesize_crossing_event_queued) { - toplevel_priv->synthesize_crossing_event_queued = TRUE; + toplevel->synthesize_crossing_event_queued = TRUE; gdk_threads_add_idle_full (GDK_PRIORITY_EVENTS - 1, do_synthesize_crossing_event, @@ -9259,7 +9004,6 @@ get_event_window (GdkDisplay *display, { guint evmask; GdkWindow *grab_window; - GdkWindowObject *w; GdkDeviceGrabInfo *grab; grab = _gdk_display_has_device_grab (display, device, serial); @@ -9281,20 +9025,19 @@ get_event_window (GdkDisplay *display, return NULL; } - w = (GdkWindowObject *)pointer_window; - while (w != NULL) + while (pointer_window != NULL) { - evmask = w->event_mask; + evmask = pointer_window->event_mask; evmask = update_evmask_for_button_motion (evmask, mask); if (evmask & type_masks[type]) { if (evmask_out) *evmask_out = evmask; - return (GdkWindow *)w; + return pointer_window; } - w = get_event_parent (w); + pointer_window = get_event_parent (pointer_window); } if (grab != NULL && @@ -9379,8 +9122,8 @@ proxy_pointer_event (GdkDisplay *display, /* Send subwindow == NULL event */ send_crossing_event (display, - (GdkWindowObject *)toplevel_window, - (GdkWindowObject *)event_window, + toplevel_window, + event_window, source_event->type, source_event->crossing.mode, source_event->crossing.detail, @@ -9409,8 +9152,8 @@ proxy_pointer_event (GdkDisplay *display, /* Send subwindow == NULL event */ send_crossing_event (display, - (GdkWindowObject *)toplevel_window, - (GdkWindowObject *)event_window, + toplevel_window, + event_window, source_event->type, source_event->crossing.mode, source_event->crossing.detail, @@ -9526,14 +9269,14 @@ proxy_button_event (GdkEvent *source_event, GdkWindow *toplevel_window, *event_window; GdkWindow *event_win; GdkWindow *pointer_window; - GdkWindowObject *parent; + GdkWindow *parent; GdkEvent *event; guint state; guint32 time_; GdkEventType type; gdouble toplevel_x, toplevel_y; GdkDisplay *display; - GdkWindowObject *w; + GdkWindow *w; GdkDevice *device; type = source_event->any.type; @@ -9557,7 +9300,7 @@ proxy_button_event (GdkEvent *source_event, NULL, NULL); /* Find the event window, that gets the grab */ - w = (GdkWindowObject *)pointer_window; + w = pointer_window; while (w != NULL && (parent = get_event_parent (w)) != NULL && parent->window_type != GDK_WINDOW_ROOT) @@ -9639,7 +9382,7 @@ proxy_button_event (GdkEvent *source_event, #ifdef DEBUG_WINDOW_PRINTING static void -gdk_window_print (GdkWindowObject *window, +gdk_window_print (GdkWindow *window, int indent) { GdkRectangle r; @@ -9696,17 +9439,14 @@ gdk_window_print_tree (GdkWindow *window, int indent, gboolean include_input_only) { - GdkWindowObject *private; GList *l; - private = (GdkWindowObject *)window; - - if (private->input_only && !include_input_only) + if (window->input_only && !include_input_only) return; - gdk_window_print (private, indent); + gdk_window_print (window, indent); - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) gdk_window_print_tree (l->data, indent + 4, include_input_only); } @@ -9719,7 +9459,6 @@ _gdk_windowing_got_event (GdkDisplay *display, gulong serial) { GdkWindow *event_window; - GdkWindowObject *event_private; gdouble x, y; gboolean unlink_event; guint old_state, old_button; @@ -9756,7 +9495,6 @@ _gdk_windowing_got_event (GdkDisplay *display, return; pointer_info = _gdk_display_get_pointer_info (display, device); - event_private = GDK_WINDOW_OBJECT (event_window); #ifdef DEBUG_WINDOW_PRINTING if (event->type == GDK_KEY_PRESS && @@ -9809,18 +9547,18 @@ _gdk_windowing_got_event (GdkDisplay *display, if (event->type == GDK_VISIBILITY_NOTIFY) { - event_private->native_visibility = event->visibility.state; - gdk_window_update_visibility_recursively (event_private, - event_private); + event_window->native_visibility = event->visibility.state; + gdk_window_update_visibility_recursively (event_window, + event_window); return; } if (!(is_button_type (event->type) || is_motion_type (event->type)) || - event_private->window_type == GDK_WINDOW_ROOT) + event_window->window_type == GDK_WINDOW_ROOT) return; - is_toplevel = gdk_window_is_toplevel (event_private); + is_toplevel = gdk_window_is_toplevel (event_window); if ((event->type == GDK_ENTER_NOTIFY || event->type == GDK_LEAVE_NOTIFY) && @@ -9940,8 +9678,7 @@ get_extension_event_window (GdkDisplay *display, gulong serial) { guint evmask; - GdkWindow *grab_window; - GdkWindowObject *w; + GdkWindow *w, *grab_window; GdkDeviceGrabInfo *grab; /* FIXME: which device? */ @@ -9959,13 +9696,13 @@ get_extension_event_window (GdkDisplay *display, return NULL; } - w = (GdkWindowObject *)pointer_window; + w = pointer_window; while (w != NULL) { evmask = w->extension_events; if (evmask & type_masks[type]) - return (GdkWindow *)w; + return w; w = get_event_parent (w); } diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c index acb438641f..06182240e2 100644 --- a/gdk/x11/gdkdevice-core.c +++ b/gdk/x11/gdkdevice-core.c @@ -21,6 +21,7 @@ #include "gdkdevice-core.h" +#include "gdkinternals.h" #include "gdkwindow.h" #include "gdkprivate-x11.h" #include "gdkx.h" @@ -104,14 +105,12 @@ impl_coord_in_window (GdkWindow *window, int impl_x, int impl_y) { - GdkWindowObject *priv = (GdkWindowObject *) window; - - if (impl_x < priv->abs_x || - impl_x > priv->abs_x + priv->width) + if (impl_x < window->abs_x || + impl_x > window->abs_x + window->width) return FALSE; - if (impl_y < priv->abs_y || - impl_y > priv->abs_y + priv->height) + if (impl_y < window->abs_y || + impl_y > window->abs_y + window->height) return FALSE; return TRUE; @@ -125,7 +124,6 @@ gdk_device_core_get_history (GdkDevice *device, GdkTimeCoord ***events, gint *n_events) { - GdkWindowObject *priv; XTimeCoord *xcoords; GdkTimeCoord **coords; GdkWindow *impl_window; @@ -139,7 +137,6 @@ gdk_device_core_get_history (GdkDevice *device, if (!xcoords) return FALSE; - priv = (GdkWindowObject *) window; coords = _gdk_device_allocate_history (device, tmp_n_events); for (i = 0, j = 0; i < tmp_n_events; i++) @@ -147,8 +144,8 @@ gdk_device_core_get_history (GdkDevice *device, if (impl_coord_in_window (window, xcoords[i].x, xcoords[i].y)) { coords[j]->time = xcoords[i].time; - coords[j]->axes[0] = xcoords[i].x - priv->abs_x; - coords[j]->axes[1] = xcoords[i].y - priv->abs_y; + coords[j]->axes[0] = xcoords[i].x - window->abs_x; + coords[j]->axes[1] = xcoords[i].y - window->abs_y; j++; } } @@ -428,7 +425,7 @@ gdk_device_core_window_at_position (GdkDevice *device, if (get_toplevel && last != root && (window = gdk_window_lookup_for_display (display, last)) != NULL && - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) + window->window_type != GDK_WINDOW_FOREIGN) { xwindow = last; break; diff --git a/gdk/x11/gdkdevicemanager-core.c b/gdk/x11/gdkdevicemanager-core.c index e355eec6d7..5d592b6d99 100644 --- a/gdk/x11/gdkdevicemanager-core.c +++ b/gdk/x11/gdkdevicemanager-core.c @@ -415,7 +415,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, { GdkDeviceManagerCore *device_manager; GdkWindow *window; - GdkWindowObject *window_private; GdkWindowImplX11 *window_impl = NULL; gboolean return_val; GdkToplevelX11 *toplevel = NULL; @@ -425,7 +424,6 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, return_val = FALSE; window = get_event_window (translator, xevent); - window_private = (GdkWindowObject *) window; if (window) { @@ -433,14 +431,14 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, return FALSE; toplevel = _gdk_x11_window_get_toplevel (window); - window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl); + window_impl = GDK_WINDOW_IMPL_X11 (window->impl); g_object_ref (window); } event->any.window = window; event->any.send_event = xevent->xany.send_event ? TRUE : FALSE; - if (window_private && GDK_WINDOW_DESTROYED (window)) + if (window && GDK_WINDOW_DESTROYED (window)) { if (xevent->type != DestroyNotify) { @@ -472,7 +470,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, switch (xevent->type) { case KeyPress: - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -482,7 +480,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, break; case KeyRelease: - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -518,7 +516,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -590,7 +588,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.button)); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -628,7 +626,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, xevent->xmotion.x, xevent->xmotion.y, (xevent->xmotion.is_hint) ? "true" : "false")); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -661,7 +659,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, xevent->xcrossing.detail, xevent->xcrossing.subwindow)); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -705,7 +703,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, xevent->xcrossing.window, xevent->xcrossing.detail, xevent->xcrossing.subwindow)); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index cd8161b3f3..eaa2b5a7a4 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -31,6 +31,7 @@ #include "gdkdisplay.h" #include "gdkeventsource.h" #include "gdkeventtranslator.h" +#include "gdkinternals.h" #include "gdkscreen.h" #include "gdkscreen-x11.h" #include "gdkinternals.h" @@ -382,7 +383,6 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, XEvent *xevent) { GdkWindow *window; - GdkWindowObject *window_private; GdkWindowImplX11 *window_impl = NULL; GdkScreen *screen = NULL; GdkScreenX11 *screen_x11 = NULL; @@ -396,7 +396,6 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, * are reported same as structure events */ window = get_event_window (translator, xevent); - window_private = (GdkWindowObject *) window; if (window) { @@ -409,7 +408,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, screen = GDK_WINDOW_SCREEN (window); screen_x11 = GDK_SCREEN_X11 (screen); toplevel = _gdk_x11_window_get_toplevel (window); - window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl); + window_impl = GDK_WINDOW_IMPL_X11 (window->impl); xwindow = GDK_WINDOW_XID (window); g_object_ref (window); @@ -418,7 +417,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, event->any.window = window; event->any.send_event = xevent->xany.send_event ? TRUE : FALSE; - if (window_private && GDK_WINDOW_DESTROYED (window)) + if (window && GDK_WINDOW_DESTROYED (window)) { if (xevent->type != DestroyNotify) { @@ -480,7 +479,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, xevent->xexpose.width, xevent->xexpose.height, event->any.send_event ? " (send)" : "")); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -508,7 +507,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, g_message ("graphics expose:\tdrawable: %ld", xevent->xgraphicsexpose.drawable)); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -554,7 +553,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, } #endif /* G_ENABLE_DEBUG */ - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -605,7 +604,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, event->any.type = GDK_DESTROY; event->any.window = window; - return_val = window_private && !GDK_WINDOW_DESTROYED (window); + return_val = window && !GDK_WINDOW_DESTROYED (window); if (window && GDK_WINDOW_XID (window) != screen_x11->xroot_window) gdk_window_destroy_notify (window); @@ -649,7 +648,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, event->any.window = window; /* Unset iconified if it was set */ - if (window && (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED)) + if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED)) gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0); @@ -682,18 +681,18 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, xevent->xconfigure.override_redirect, !window ? " (discarding)" - : GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD + : window->window_type == GDK_WINDOW_CHILD ? " (discarding child)" : xevent->xconfigure.event != xevent->xconfigure.window ? " (discarding substructure)" : "")); if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT) { - window_private->width = xevent->xconfigure.width; - window_private->height = xevent->xconfigure.height; + window->width = xevent->xconfigure.width; + window->height = xevent->xconfigure.height; _gdk_window_update_size (window); - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window_private->impl)); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); _gdk_x11_screen_size_changed (screen, xevent); } @@ -743,19 +742,19 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, event->configure.x = xevent->xconfigure.x; event->configure.y = xevent->xconfigure.y; } - window_private->x = event->configure.x; - window_private->y = event->configure.y; - window_private->width = xevent->xconfigure.width; - window_private->height = xevent->xconfigure.height; + window->x = event->configure.x; + window->y = event->configure.y; + window->width = xevent->xconfigure.width; + window->height = xevent->xconfigure.height; _gdk_window_update_size (window); - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window_private->impl)); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); - if (window_private->resize_count >= 1) + if (window->resize_count >= 1) { - window_private->resize_count -= 1; + window->resize_count -= 1; - if (window_private->resize_count == 0) + if (window->resize_count == 0) _gdk_moveresize_configure_done (display, window); } } @@ -770,7 +769,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom), "\"")); - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; break; @@ -789,7 +788,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, gdk_check_wm_desktop_changed (window); } - if (window_private->event_mask & GDK_PROPERTY_CHANGE_MASK) + if (window->event_mask & GDK_PROPERTY_CHANGE_MASK) { event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; @@ -894,7 +893,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, break; case GDK_FILTER_CONTINUE: /* Send unknown ClientMessage's on to Gtk for it to use */ - if (window_private == NULL) + if (window == NULL) { return_val = FALSE; } @@ -956,7 +955,7 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, else #endif #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES) - if (display_x11->have_xdamage && window_private && window_private->composited && + if (display_x11->have_xdamage && window && window->composited && xevent->type == display_x11->xdamage_event_base + XDamageNotify && ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage) { @@ -964,8 +963,8 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, XserverRegion repair; GdkRectangle rect; - rect.x = window_private->x + damage_event->area.x; - rect.y = window_private->y + damage_event->area.y; + rect.x = window->x + damage_event->area.x; + rect.y = window->y + damage_event->area.y; rect.width = damage_event->area.width; rect.height = damage_event->area.height; @@ -976,8 +975,8 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, repair, None); XFixesDestroyRegion (display_x11->xdisplay, repair); - if (window_private->parent != NULL) - _gdk_window_process_expose (GDK_WINDOW (window_private->parent), + if (window->parent != NULL) + _gdk_window_process_expose (window->parent, damage_event->serial, &rect); return_val = TRUE; @@ -1066,12 +1065,11 @@ gdk_wm_protocols_filter (GdkXEvent *xev, else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS")) { GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window); - GdkWindowObject *private = (GdkWindowObject *)win; /* There is no way of knowing reliably whether we are viewable; * _gdk_x11_set_input_focus_safe() traps errors asynchronously. */ - if (toplevel && private->accept_focus) + if (toplevel && win->accept_focus) _gdk_x11_set_input_focus_safe (display, toplevel->focus_window, RevertToParent, xevent->xclient.data.l[1]); diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index 7a23b59b2c..5a597526c7 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -179,15 +179,14 @@ gdk_event_source_translate_event (GdkEventSource *event_source, if (filter_window) { /* Apply per-window filters */ - GdkWindowObject *filter_private = (GdkWindowObject *) filter_window; GdkFilterReturn result; event->any.window = g_object_ref (filter_window); - if (filter_private->filters) + if (filter_window->filters) { result = gdk_event_apply_filters (xevent, event, - &filter_private->filters); + &filter_window->filters); if (result == GDK_FILTER_REMOVE) { diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index a9a10efa5e..8ad8c24279 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -60,13 +60,9 @@ _gdk_window_move_resize_child (GdkWindow *window, gint width, gint height) { - GdkWindowObject *obj; - g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - obj = GDK_WINDOW_OBJECT (window); - if (width > 65535 || height > 65535) { @@ -78,10 +74,10 @@ _gdk_window_move_resize_child (GdkWindow *window, height = 65535; } - obj->x = x; - obj->y = y; - obj->width = width; - obj->height = height; + window->x = x; + window->y = y; + window->width = width; + window->height = height; /* We don't really care about origin overflow, because on overflow the window won't be visible anyway and thus it will be shaped @@ -91,8 +87,8 @@ _gdk_window_move_resize_child (GdkWindow *window, _gdk_x11_window_tmp_unset_bg (window, TRUE); XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - obj->x + obj->parent->abs_x, - obj->y + obj->parent->abs_y, + window->x + window->parent->abs_x, + window->y + window->parent->abs_y, width, height); _gdk_x11_window_tmp_reset_parent_bg (window); _gdk_x11_window_tmp_reset_bg (window, TRUE); @@ -227,15 +223,15 @@ gdk_window_queue (GdkWindow *window, } static GC -_get_scratch_gc (GdkWindowObject *window, cairo_region_t *clip_region) +_get_scratch_gc (GdkWindow *window, cairo_region_t *clip_region) { GdkScreenX11 *screen; XRectangle *rectangles; gint n_rects; gint depth; - screen = GDK_SCREEN_X11 (gdk_window_get_screen (GDK_WINDOW (window))); - depth = gdk_visual_get_depth (gdk_window_get_visual (GDK_WINDOW (window))) - 1; + screen = GDK_SCREEN_X11 (gdk_window_get_screen (window)); + depth = gdk_visual_get_depth (gdk_window_get_visual (window)) - 1; if (!screen->subwindow_gcs[depth]) { @@ -276,7 +272,7 @@ _gdk_x11_window_translate (GdkWindow *window, GdkWindowQueueItem *item; GC xgc; GdkRectangle extents; - GdkWindowObject *private, *impl; + GdkWindow *parent; int px, py; /* We need to get data from subwindows here, because we might have @@ -285,19 +281,19 @@ _gdk_x11_window_translate (GdkWindow *window, * from overlapping native window that are not children of this window, * so we copy from the toplevel with INCLUDE_INFERIORS. */ - private = impl = (GdkWindowObject *) window; + parent = window; px = py = 0; - while (private->parent != NULL && - private->parent->window_type != GDK_WINDOW_ROOT) + while (parent->parent != NULL && + parent->parent->window_type != GDK_WINDOW_ROOT) { - dx -= private->parent->abs_x + private->x; - dy -= private->parent->abs_y + private->y; - private = (GdkWindowObject *) _gdk_window_get_impl_window ((GdkWindow *) private->parent); + dx -= parent->parent->abs_x + parent->x; + dy -= parent->parent->abs_y + parent->y; + parent = _gdk_window_get_impl_window (parent->parent); } cairo_region_get_extents (area, &extents); - xgc = _get_scratch_gc (impl, area); + xgc = _get_scratch_gc (window, area); cairo_region_translate (area, -dx, -dy); /* Move to source region */ @@ -308,9 +304,9 @@ _gdk_x11_window_translate (GdkWindow *window, item->u.translate.dy = dy; gdk_window_queue (window, item); - XCopyArea (GDK_WINDOW_XDISPLAY ((GdkWindow *) impl), - GDK_WINDOW_XID (private), - GDK_WINDOW_XID (impl), + XCopyArea (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID (parent), + GDK_WINDOW_XID (window), xgc, extents.x - dx, extents.y - dy, extents.width, extents.height, diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index 559caaece4..bd41a428ea 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -66,7 +66,7 @@ _gdk_input_select_device_events (GdkWindow *impl_window, GdkDevice *device) { guint event_mask; - GdkWindowObject *w; + GdkWindow *w; GdkInputWindow *iw; GdkInputMode mode; gboolean has_cursor; @@ -74,7 +74,7 @@ _gdk_input_select_device_events (GdkWindow *impl_window, GList *l; event_mask = 0; - iw = ((GdkWindowObject *)impl_window)->input_window; + iw = impl_window->input_window; g_object_get (device, "type", &type, @@ -98,7 +98,7 @@ _gdk_input_select_device_events (GdkWindow *impl_window, if (event_mask) event_mask |= GDK_PROXIMITY_OUT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK; - gdk_window_set_device_events ((GdkWindow *) w, device, event_mask); + gdk_window_set_device_events (w, device, event_mask); } } } @@ -106,18 +106,16 @@ _gdk_input_select_device_events (GdkWindow *impl_window, static void unset_extension_events (GdkWindow *window) { - GdkWindowObject *window_private; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GdkDisplayX11 *display_x11; GdkInputWindow *iw; - window_private = (GdkWindowObject*) window; - impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window); + impl_window = _gdk_window_get_impl_window (window); iw = impl_window->input_window; display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window)); - if (window_private->extension_events != 0) + if (window->extension_events != 0) { g_assert (iw != NULL); g_assert (g_list_find (iw->windows, window) != NULL); @@ -131,7 +129,7 @@ unset_extension_events (GdkWindow *window) } } - window_private->extension_events = 0; + window->extension_events = 0; } /** @@ -150,8 +148,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkExtensionMode mode) { - GdkWindowObject *window_private; - GdkWindowObject *impl_window; + GdkWindow *impl_window; GdkInputWindow *iw; GdkDisplayX11 *display_x11; #ifndef XINPUT_NONE @@ -161,12 +158,11 @@ gdk_input_set_extension_events (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_WINDOW_IS_X11 (window)); - window_private = (GdkWindowObject*) window; display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window)); if (GDK_WINDOW_DESTROYED (window)) return; - impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window); + impl_window = _gdk_window_get_impl_window (window); if (mode == GDK_EXTENSION_EVENTS_ALL && mask != 0) mask |= GDK_ALL_DEVICES_MASK; @@ -190,9 +186,9 @@ gdk_input_set_extension_events (GdkWindow *window, impl_window->input_window = iw; } - if (window_private->extension_events == 0) + if (window->extension_events == 0) iw->windows = g_list_append (iw->windows, window); - window_private->extension_events = mask; + window->extension_events = mask; } else { diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index f4135424e0..f79c9632b7 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -157,6 +157,6 @@ extern gboolean _gdk_synchronize; #define GDK_WINDOW_DISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->display) #define GDK_WINDOW_XROOTWIN(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xroot_window) #define GDK_GC_DISPLAY(gc) (GDK_SCREEN_DISPLAY (GDK_GC_X11(gc)->screen)) -#define GDK_WINDOW_IS_X11(win) (GDK_IS_WINDOW_IMPL_X11 (((GdkWindowObject *)win)->impl)) +#define GDK_WINDOW_IS_X11(win) (GDK_IS_WINDOW_IMPL_X11 ((win)->impl)) #endif /* __GDK_PRIVATE_X11_H__ */ diff --git a/gdk/x11/gdktestutils-x11.c b/gdk/x11/gdktestutils-x11.c index 8de93e428f..960301b1e3 100644 --- a/gdk/x11/gdktestutils-x11.c +++ b/gdk/x11/gdktestutils-x11.c @@ -94,7 +94,6 @@ gdk_test_simulate_key (GdkWindow *window, { GdkScreen *screen; GdkKeymapKey *keys = NULL; - GdkWindowObject *priv; gboolean success; gint n_keys = 0; XKeyEvent xev = { @@ -108,17 +107,16 @@ gdk_test_simulate_key (GdkWindow *window, return FALSE; screen = gdk_window_get_screen (window); - priv = (GdkWindowObject *)window; if (x < 0 && y < 0) { - x = priv->width / 2; - y = priv->height / 2; + x = window->width / 2; + y = window->height / 2; } /* Convert to impl coordinates */ - x = x + priv->abs_x; - y = y + priv->abs_y; + x = x + window->abs_x; + y = y + window->abs_y; xev.type = key_pressrelease == GDK_KEY_PRESS ? KeyPress : KeyRelease; xev.display = GDK_WINDOW_XDISPLAY (window); @@ -206,7 +204,6 @@ gdk_test_simulate_button (GdkWindow *window, 1, /* send_event */ }; gboolean success; - GdkWindowObject *priv; g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE); g_return_val_if_fail (window != NULL, FALSE); @@ -215,17 +212,16 @@ gdk_test_simulate_button (GdkWindow *window, return FALSE; screen = gdk_window_get_screen (window); - priv = (GdkWindowObject *)window; if (x < 0 && y < 0) { - x = priv->width / 2; - y = priv->height / 2; + x = window->width / 2; + y = window->height / 2; } /* Convert to impl coordinates */ - x = x + priv->abs_x; - y = y + priv->abs_y; + x = x + window->abs_x; + y = y + window->abs_y; xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease; xev.display = GDK_WINDOW_XDISPLAY (window); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 1eec8b74bb..f24ca3e3d1 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -146,7 +146,6 @@ gdk_window_impl_x11_init (GdkWindowImplX11 *impl) GdkToplevelX11 * _gdk_x11_window_get_toplevel (GdkWindow *window) { - GdkWindowObject *private; GdkWindowImplX11 *impl; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); @@ -154,8 +153,7 @@ _gdk_x11_window_get_toplevel (GdkWindow *window) if (!WINDOW_IS_TOPLEVEL (window)) return NULL; - private = (GdkWindowObject *)window; - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); if (!impl->toplevel) impl->toplevel = g_new0 (GdkToplevelX11, 1); @@ -238,20 +236,20 @@ gdk_x11_ref_cairo_surface (GdkDrawable *drawable) static void gdk_window_impl_x11_finalize (GObject *object) { - GdkWindowObject *wrapper; + GdkWindow *wrapper; GdkWindowImplX11 *impl; g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object)); impl = GDK_WINDOW_IMPL_X11 (object); - wrapper = (GdkWindowObject*) impl->wrapper; + wrapper = impl->wrapper; - _gdk_xgrab_check_destroy (GDK_WINDOW (wrapper)); + _gdk_xgrab_check_destroy (wrapper); if (!GDK_WINDOW_DESTROYED (wrapper)) { - GdkDisplay *display = GDK_WINDOW_DISPLAY ((GdkWindow *) wrapper); + GdkDisplay *display = GDK_WINDOW_DISPLAY (wrapper); _gdk_xid_table_remove (display, impl->xid); if (impl->toplevel && impl->toplevel->focus_window) @@ -356,10 +354,8 @@ static void tmp_unset_bg (GdkWindow *window) { GdkWindowImplX11 *impl; - GdkWindowObject *obj; - obj = (GdkWindowObject *) window; - impl = GDK_WINDOW_IMPL_X11 (obj->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); impl->no_bg = TRUE; @@ -371,14 +367,12 @@ static void tmp_reset_bg (GdkWindow *window) { GdkWindowImplX11 *impl; - GdkWindowObject *obj; - obj = (GdkWindowObject *) window; - impl = GDK_WINDOW_IMPL_X11 (obj->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); impl->no_bg = FALSE; - gdk_window_x11_set_background (window, obj->background); + gdk_window_x11_set_background (window, window->background); } /* Unsetting and resetting window backgrounds. @@ -392,28 +386,24 @@ void _gdk_x11_window_tmp_unset_bg (GdkWindow *window, gboolean recurse) { - GdkWindowObject *private; - g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *)window; - - if (private->input_only || private->destroyed || - (private->window_type != GDK_WINDOW_ROOT && + if (window->input_only || window->destroyed || + (window->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window))) return; if (_gdk_window_has_impl (window) && GDK_WINDOW_IS_X11 (window) && - private->window_type != GDK_WINDOW_ROOT && - private->window_type != GDK_WINDOW_FOREIGN) + window->window_type != GDK_WINDOW_ROOT && + window->window_type != GDK_WINDOW_FOREIGN) tmp_unset_bg (window); if (recurse) { GList *l; - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) _gdk_x11_window_tmp_unset_bg (l->data, TRUE); } } @@ -421,13 +411,10 @@ _gdk_x11_window_tmp_unset_bg (GdkWindow *window, void _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window) { - GdkWindowObject *private; - private = (GdkWindowObject*) window; - - if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT) + if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT) return; - window = _gdk_window_get_impl_window ((GdkWindow *)private->parent); + window = _gdk_window_get_impl_window (window->parent); _gdk_x11_window_tmp_unset_bg (window, FALSE); } @@ -435,29 +422,25 @@ void _gdk_x11_window_tmp_reset_bg (GdkWindow *window, gboolean recurse) { - GdkWindowObject *private; - g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowObject *)window; - - if (private->input_only || private->destroyed || - (private->window_type != GDK_WINDOW_ROOT && + if (window->input_only || window->destroyed || + (window->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window))) return; if (_gdk_window_has_impl (window) && GDK_WINDOW_IS_X11 (window) && - private->window_type != GDK_WINDOW_ROOT && - private->window_type != GDK_WINDOW_FOREIGN) + window->window_type != GDK_WINDOW_ROOT && + window->window_type != GDK_WINDOW_FOREIGN) tmp_reset_bg (window); if (recurse) { GList *l; - for (l = private->children; l != NULL; l = l->next) + for (l = window->children; l != NULL; l = l->next) _gdk_x11_window_tmp_reset_bg (l->data, TRUE); } } @@ -465,13 +448,10 @@ _gdk_x11_window_tmp_reset_bg (GdkWindow *window, void _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window) { - GdkWindowObject *private; - private = (GdkWindowObject*) window; - - if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT) + if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT) return; - window = _gdk_window_get_impl_window ((GdkWindow *)private->parent); + window = _gdk_window_get_impl_window (window->parent); _gdk_x11_window_tmp_reset_bg (window, FALSE); } @@ -479,7 +459,7 @@ _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window) void _gdk_windowing_window_init (GdkScreen * screen) { - GdkWindowObject *private; + GdkWindow *window; GdkWindowImplX11 *impl; GdkScreenX11 *screen_x11; @@ -487,31 +467,30 @@ _gdk_windowing_window_init (GdkScreen * screen) g_assert (screen_x11->root_window == NULL); - screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL); + window = screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL); - private = (GdkWindowObject *) screen_x11->root_window; - private->impl = g_object_new (_gdk_window_impl_get_type (), NULL); - private->impl_window = private; - private->visual = gdk_screen_get_system_visual (screen); + window->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + window->impl_window = window; + window->visual = gdk_screen_get_system_visual (screen); - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); impl->xid = screen_x11->xroot_window; - impl->wrapper = GDK_WINDOW (private); + impl->wrapper = window; - private->window_type = GDK_WINDOW_ROOT; - private->depth = DefaultDepthOfScreen (screen_x11->xscreen); + window->window_type = GDK_WINDOW_ROOT; + window->depth = DefaultDepthOfScreen (screen_x11->xscreen); - private->x = 0; - private->y = 0; - private->abs_x = 0; - private->abs_y = 0; - private->width = WidthOfScreen (screen_x11->xscreen); - private->height = HeightOfScreen (screen_x11->xscreen); - private->viewable = TRUE; + window->x = 0; + window->y = 0; + window->abs_x = 0; + window->abs_y = 0; + window->width = WidthOfScreen (screen_x11->xscreen); + window->height = HeightOfScreen (screen_x11->xscreen); + window->viewable = TRUE; /* see init_randr_support() in gdkscreen-x11.c */ - private->event_mask = GDK_STRUCTURE_MASK; + window->event_mask = GDK_STRUCTURE_MASK; _gdk_window_update_size (screen_x11->root_window); @@ -607,8 +586,7 @@ ensure_sync_counter (GdkWindow *window) { GdkDisplay *display = GDK_WINDOW_DISPLAY (window); GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); if (toplevel && impl->use_synchronized_configure && toplevel->update_counter == None && @@ -640,7 +618,6 @@ static void setup_toplevel_window (GdkWindow *window, GdkWindow *parent) { - GdkWindowObject *obj = (GdkWindowObject *)window; GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); GdkDisplay *display = gdk_window_get_display (window); Display *xdisplay = GDK_WINDOW_XDISPLAY (window); @@ -652,7 +629,7 @@ setup_toplevel_window (GdkWindow *window, set_wm_protocols (window); - if (!obj->input_only) + if (!window->input_only) { /* The focus window is off the visible area, and serves to receive key * press events so they don't get sent to child windows. @@ -668,8 +645,8 @@ setup_toplevel_window (GdkWindow *window, * correct value??? */ size_hints.flags = PSize; - size_hints.width = obj->width; - size_hints.height = obj->height; + size_hints.width = window->width; + size_hints.height = window->height; XSetWMNormalHints (xdisplay, xid, &size_hints); @@ -697,7 +674,7 @@ setup_toplevel_window (GdkWindow *window, XA_WINDOW, 32, PropModeReplace, (guchar *) &toplevel->focus_window, 1); - if (!obj->focus_on_map) + if (!window->focus_on_map) gdk_x11_window_set_user_time (window, 0); else if (GDK_DISPLAY_X11 (screen_x11->display)->user_time != 0) gdk_x11_window_set_user_time (window, GDK_DISPLAY_X11 (screen_x11->display)->user_time); @@ -713,7 +690,6 @@ _gdk_window_impl_new (GdkWindow *window, GdkWindowAttr *attributes, gint attributes_mask) { - GdkWindowObject *private; GdkWindowImplX11 *impl; GdkScreenX11 *screen_x11; GdkDisplayX11 *display_x11; @@ -729,21 +705,19 @@ _gdk_window_impl_new (GdkWindow *window, unsigned int class; const char *title; - private = (GdkWindowObject *) window; - screen_x11 = GDK_SCREEN_X11 (screen); xparent = GDK_WINDOW_XID (real_parent); display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen)); impl = g_object_new (_gdk_window_impl_get_type (), NULL); - private->impl = (GdkDrawable *)impl; + window->impl = (GdkDrawable *)impl; impl->wrapper = GDK_WINDOW (window); xdisplay = screen_x11->xdisplay; xattributes_mask = 0; - xvisual = gdk_x11_visual_get_xvisual (private->visual); + xvisual = gdk_x11_visual_get_xvisual (window->visual); if (attributes_mask & GDK_WA_NOREDIR) { @@ -756,25 +730,25 @@ _gdk_window_impl_new (GdkWindow *window, impl->override_redirect = xattributes.override_redirect; - if (private->parent && private->parent->guffaw_gravity) + if (window->parent && window->parent->guffaw_gravity) { xattributes.win_gravity = StaticGravity; xattributes_mask |= CWWinGravity; } /* Sanity checks */ - switch (private->window_type) + switch (window->window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: - if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT) + if (GDK_WINDOW_TYPE (window->parent) != GDK_WINDOW_ROOT) { /* The common code warns for this case */ xparent = GDK_SCREEN_XROOTWIN (screen); } } - if (!private->input_only) + if (!window->input_only) { class = InputOutput; @@ -783,17 +757,17 @@ _gdk_window_impl_new (GdkWindow *window, xattributes.border_pixel = BlackPixel (xdisplay, screen_x11->screen_num); xattributes_mask |= CWBorderPixel | CWBackPixel; - if (private->guffaw_gravity) + if (window->guffaw_gravity) xattributes.bit_gravity = StaticGravity; else xattributes.bit_gravity = NorthWestGravity; xattributes_mask |= CWBitGravity; - xattributes.colormap = _gdk_visual_get_x11_colormap (private->visual); + xattributes.colormap = _gdk_visual_get_x11_colormap (window->visual); xattributes_mask |= CWColormap; - if (private->window_type == GDK_WINDOW_TEMP) + if (window->window_type == GDK_WINDOW_TEMP) { xattributes.save_under = True; xattributes.override_redirect = True; @@ -808,28 +782,28 @@ _gdk_window_impl_new (GdkWindow *window, class = InputOnly; } - if (private->width > 65535 || - private->height > 65535) + if (window->width > 65535 || + window->height > 65535) { g_warning ("Native Windows wider or taller than 65535 pixels are not supported"); - if (private->width > 65535) - private->width = 65535; - if (private->height > 65535) - private->height = 65535; + if (window->width > 65535) + window->width = 65535; + if (window->height > 65535) + window->height = 65535; } impl->xid = XCreateWindow (xdisplay, xparent, - private->x + private->parent->abs_x, - private->y + private->parent->abs_y, - private->width, private->height, - 0, private->depth, class, xvisual, + window->x + window->parent->abs_x, + window->y + window->parent->abs_y, + window->width, window->height, + 0, window->depth, class, xvisual, xattributes_mask, &xattributes); g_object_ref (window); _gdk_xid_table_insert (screen_x11->display, &impl->xid, window); - switch (GDK_WINDOW_TYPE (private)) + switch (GDK_WINDOW_TYPE (window)) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: @@ -849,7 +823,7 @@ _gdk_window_impl_new (GdkWindow *window, XFree (class_hint); } - setup_toplevel_window (window, (GdkWindow *)private->parent); + setup_toplevel_window (window, window->parent); break; case GDK_WINDOW_CHILD: @@ -905,7 +879,6 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, { GdkScreen *screen; GdkWindow *window; - GdkWindowObject *private; GdkWindowImplX11 *impl; GdkDisplayX11 *display_x11; XWindowAttributes attrs; @@ -940,40 +913,39 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, window = g_object_new (GDK_TYPE_WINDOW, NULL); - private = (GdkWindowObject *) window; - private->impl = g_object_new (_gdk_window_impl_get_type (), NULL); - private->impl_window = private; - private->visual = gdk_x11_screen_lookup_visual (screen, + window->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + window->impl_window = window; + window->visual = gdk_x11_screen_lookup_visual (screen, XVisualIDFromVisual (attrs.visual)); - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); impl->wrapper = window; - private->parent = gdk_xid_table_lookup_for_display (display, parent); + window->parent = gdk_xid_table_lookup_for_display (display, parent); - if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN) - private->parent = (GdkWindowObject *) gdk_screen_get_root_window (screen); + if (!window->parent || GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_FOREIGN) + window->parent = gdk_screen_get_root_window (screen); - private->parent->children = g_list_prepend (private->parent->children, window); + window->parent->children = g_list_prepend (window->parent->children, window); impl->xid = anid; - private->x = attrs.x; - private->y = attrs.y; - private->width = attrs.width; - private->height = attrs.height; - private->window_type = GDK_WINDOW_FOREIGN; - private->destroyed = FALSE; + window->x = attrs.x; + window->y = attrs.y; + window->width = attrs.width; + window->height = attrs.height; + window->window_type = GDK_WINDOW_FOREIGN; + window->destroyed = FALSE; - private->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); + window->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); if (attrs.map_state == IsUnmapped) - private->state = GDK_WINDOW_STATE_WITHDRAWN; + window->state = GDK_WINDOW_STATE_WITHDRAWN; else - private->state = 0; - private->viewable = TRUE; + window->state = 0; + window->viewable = TRUE; - private->depth = attrs.depth; + window->depth = attrs.depth; g_object_ref (window); _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window); @@ -1059,8 +1031,7 @@ _gdk_x11_window_destroy (GdkWindow *window, gboolean recursing, gboolean foreign_destroy) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); GdkToplevelX11 *toplevel; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1142,7 +1113,7 @@ gdk_window_destroy_notify (GdkWindow *window) { GdkWindowImplX11 *window_impl; - window_impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)window)->impl); + window_impl = GDK_WINDOW_IMPL_X11 ((window)->impl); if (!GDK_WINDOW_DESTROYED (window)) { @@ -1166,20 +1137,19 @@ update_wm_hints (GdkWindow *window, gboolean force) { GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window); - GdkWindowObject *private = (GdkWindowObject *)window; GdkDisplay *display = GDK_WINDOW_DISPLAY (window); XWMHints wm_hints; if (!force && !toplevel->is_leader && - private->state & GDK_WINDOW_STATE_WITHDRAWN) + window->state & GDK_WINDOW_STATE_WITHDRAWN) return; wm_hints.flags = StateHint | InputHint; - wm_hints.input = private->accept_focus ? True : False; + wm_hints.input = window->accept_focus ? True : False; wm_hints.initial_state = NormalState; - if (private->state & GDK_WINDOW_STATE_ICONIFIED) + if (window->state & GDK_WINDOW_STATE_ICONIFIED) { wm_hints.flags |= StateHint; wm_hints.initial_state = IconicState; @@ -1220,12 +1190,10 @@ set_initial_hints (GdkWindow *window) GdkDisplay *display = GDK_WINDOW_DISPLAY (window); Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); Window xwindow = GDK_WINDOW_XID (window); - GdkWindowObject *private; GdkToplevelX11 *toplevel; Atom atoms[9]; gint i; - private = (GdkWindowObject*) window; toplevel = _gdk_x11_window_get_toplevel (window); if (!toplevel) @@ -1240,7 +1208,7 @@ set_initial_hints (GdkWindow *window) i = 0; - if (private->state & GDK_WINDOW_STATE_MAXIMIZED) + if (window->state & GDK_WINDOW_STATE_MAXIMIZED) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT"); @@ -1251,21 +1219,21 @@ set_initial_hints (GdkWindow *window) toplevel->have_maxhorz = toplevel->have_maxvert = TRUE; } - if (private->state & GDK_WINDOW_STATE_ABOVE) + if (window->state & GDK_WINDOW_STATE_ABOVE) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_ABOVE"); ++i; } - if (private->state & GDK_WINDOW_STATE_BELOW) + if (window->state & GDK_WINDOW_STATE_BELOW) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_BELOW"); ++i; } - if (private->state & GDK_WINDOW_STATE_STICKY) + if (window->state & GDK_WINDOW_STATE_STICKY) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY"); @@ -1273,7 +1241,7 @@ set_initial_hints (GdkWindow *window) toplevel->have_sticky = TRUE; } - if (private->state & GDK_WINDOW_STATE_FULLSCREEN) + if (window->state & GDK_WINDOW_STATE_FULLSCREEN) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN"); @@ -1281,7 +1249,7 @@ set_initial_hints (GdkWindow *window) toplevel->have_fullscreen = TRUE; } - if (private->modal_hint) + if (window->modal_hint) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MODAL"); @@ -1317,7 +1285,7 @@ set_initial_hints (GdkWindow *window) gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE")); } - if (private->state & GDK_WINDOW_STATE_STICKY) + if (window->state & GDK_WINDOW_STATE_STICKY) { atoms[0] = 0xFFFFFFFF; XChangeProperty (xdisplay, @@ -1340,11 +1308,10 @@ set_initial_hints (GdkWindow *window) static void gdk_window_x11_show (GdkWindow *window, gboolean already_mapped) { - GdkWindowObject *private = (GdkWindowObject*) window; GdkDisplay *display; GdkDisplayX11 *display_x11; GdkToplevelX11 *toplevel; - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); Display *xdisplay = GDK_WINDOW_XDISPLAY (window); Window xwindow = GDK_WINDOW_XID (window); gboolean unset_bg; @@ -1364,8 +1331,8 @@ gdk_window_x11_show (GdkWindow *window, gboolean already_mapped) gdk_x11_window_set_user_time (window, display_x11->user_time); } - unset_bg = !private->input_only && - (private->window_type == GDK_WINDOW_CHILD || + unset_bg = !window->input_only && + (window->window_type == GDK_WINDOW_CHILD || impl->override_redirect) && gdk_window_is_viewable (window); @@ -1382,14 +1349,13 @@ static void pre_unmap (GdkWindow *window) { GdkWindow *start_window = NULL; - GdkWindowObject *private = (GdkWindowObject *)window; - if (private->input_only) + if (window->input_only) return; - if (private->window_type == GDK_WINDOW_CHILD) - start_window = _gdk_window_get_impl_window ((GdkWindow *)private->parent); - else if (private->window_type == GDK_WINDOW_TEMP) + if (window->window_type == GDK_WINDOW_CHILD) + start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent); + else if (window->window_type == GDK_WINDOW_TEMP) start_window = get_root (window); if (start_window) @@ -1400,28 +1366,27 @@ static void post_unmap (GdkWindow *window) { GdkWindow *start_window = NULL; - GdkWindowObject *private = (GdkWindowObject *)window; - if (private->input_only) + if (window->input_only) return; - if (private->window_type == GDK_WINDOW_CHILD) - start_window = _gdk_window_get_impl_window ((GdkWindow *)private->parent); - else if (private->window_type == GDK_WINDOW_TEMP) + if (window->window_type == GDK_WINDOW_CHILD) + start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent); + else if (window->window_type == GDK_WINDOW_TEMP) start_window = get_root (window); if (start_window) { _gdk_x11_window_tmp_reset_bg (start_window, TRUE); - if (private->window_type == GDK_WINDOW_CHILD && private->parent) + if (window->window_type == GDK_WINDOW_CHILD && window->parent) { GdkRectangle invalid_rect; gdk_window_get_position (window, &invalid_rect.x, &invalid_rect.y); invalid_rect.width = gdk_window_get_width (window); invalid_rect.height = gdk_window_get_height (window); - gdk_window_invalidate_rect ((GdkWindow *)private->parent, + gdk_window_invalidate_rect ((GdkWindow *)window->parent, &invalid_rect, TRUE); } } @@ -1430,10 +1395,6 @@ post_unmap (GdkWindow *window) static void gdk_window_x11_hide (GdkWindow *window) { - GdkWindowObject *private; - - private = (GdkWindowObject*) window; - /* We'll get the unmap notify eventually, and handle it then, * but checking here makes things more consistent if we are * just doing stuff ourself. @@ -1442,7 +1403,7 @@ gdk_window_x11_hide (GdkWindow *window) NextRequest (GDK_WINDOW_XDISPLAY (window))); /* You can't simply unmap toplevel windows. */ - switch (private->window_type) + switch (window->window_type) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: /* ? */ @@ -1466,10 +1427,7 @@ gdk_window_x11_hide (GdkWindow *window) static void gdk_window_x11_withdraw (GdkWindow *window) { - GdkWindowObject *private; - - private = (GdkWindowObject*) window; - if (!private->destroyed) + if (!window->destroyed) { if (GDK_WINDOW_IS_MAPPED (window)) gdk_synthesize_window_state (window, @@ -1492,14 +1450,13 @@ window_x11_move (GdkWindow *window, gint x, gint y) { - GdkWindowObject *private = (GdkWindowObject *) window; - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); - if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) { _gdk_window_move_resize_child (window, x, y, - private->width, private->height); + window->width, window->height); } else { @@ -1509,8 +1466,8 @@ window_x11_move (GdkWindow *window, if (impl->override_redirect) { - private->x = x; - private->y = y; + window->x = x; + window->y = y; } } } @@ -1520,23 +1477,21 @@ window_x11_resize (GdkWindow *window, gint width, gint height) { - GdkWindowObject *private = (GdkWindowObject *) window; - if (width < 1) width = 1; if (height < 1) height = 1; - if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) { _gdk_window_move_resize_child (window, - private->x, private->y, + window->x, window->y, width, height); } else { - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); XResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), @@ -1544,18 +1499,18 @@ window_x11_resize (GdkWindow *window, if (impl->override_redirect) { - private->width = width; - private->height = height; - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); + window->width = width; + window->height = height; + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); } else { - if (width != private->width || height != private->height) - private->resize_count += 1; + if (width != window->width || height != window->height) + window->resize_count += 1; } } - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); } static inline void @@ -1565,22 +1520,20 @@ window_x11_move_resize (GdkWindow *window, gint width, gint height) { - GdkWindowObject *private = (GdkWindowObject *) window;; - if (width < 1) width = 1; if (height < 1) height = 1; - if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD) + if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) { _gdk_window_move_resize_child (window, x, y, width, height); - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); } else { - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), @@ -1588,18 +1541,18 @@ window_x11_move_resize (GdkWindow *window, if (impl->override_redirect) { - private->x = x; - private->y = y; + window->x = x; + window->y = y; - private->width = width; - private->height = height; + window->width = width; + window->height = height; - _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (private->impl)); + _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl)); } else { - if (width != private->width || height != private->height) - private->resize_count += 1; + if (width != window->width || height != window->height) + window->resize_count += 1; } } } @@ -1629,27 +1582,23 @@ gdk_window_x11_reparent (GdkWindow *window, gint x, gint y) { - GdkWindowObject *window_private; - GdkWindowObject *parent_private; GdkWindowImplX11 *impl; - window_private = (GdkWindowObject*) window; - parent_private = (GdkWindowObject*) new_parent; - impl = GDK_WINDOW_IMPL_X11 (window_private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); _gdk_x11_window_tmp_unset_bg (window, TRUE); _gdk_x11_window_tmp_unset_parent_bg (window); XReparentWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), GDK_WINDOW_XID (new_parent), - parent_private->abs_x + x, parent_private->abs_y + y); + new_parent->abs_x + x, new_parent->abs_y + y); _gdk_x11_window_tmp_reset_parent_bg (window); _gdk_x11_window_tmp_reset_bg (window, TRUE); if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window)); - window_private->parent = parent_private; + window->parent = new_parent; /* Switch the window type as appropriate */ @@ -1664,8 +1613,8 @@ gdk_window_x11_reparent (GdkWindow *window, { /* This is also done in common code at a later stage, but we need it in setup_toplevel, so do it here too */ - if (window_private->toplevel_window_type != -1) - GDK_WINDOW_TYPE (window) = window_private->toplevel_window_type; + if (window->toplevel_window_type != -1) + GDK_WINDOW_TYPE (window) = window->toplevel_window_type; else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL; @@ -2090,15 +2039,11 @@ void gdk_window_set_modal_hint (GdkWindow *window, gboolean modal) { - GdkWindowObject *private; - if (GDK_WINDOW_DESTROYED (window) || !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) return; - private = (GdkWindowObject*) window; - - private->modal_hint = modal; + window->modal_hint = modal; if (GDK_WINDOW_IS_MAPPED (window)) gdk_wmspec_change_state (modal, window, @@ -2765,14 +2710,12 @@ gdk_window_x11_set_device_cursor (GdkWindow *window, GdkDevice *device, GdkCursor *cursor) { - GdkWindowObject *private; GdkWindowImplX11 *impl; g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_DEVICE (device)); - private = (GdkWindowObject *) window; - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); if (!cursor) g_hash_table_remove (impl->device_cursor, device); @@ -2790,13 +2733,11 @@ gdk_window_x11_set_device_cursor (GdkWindow *window, GdkCursor * _gdk_x11_window_get_cursor (GdkWindow *window) { - GdkWindowObject *private; GdkWindowImplX11 *impl; g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - private = (GdkWindowObject *)window; - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); return impl->cursor; } @@ -2904,7 +2845,6 @@ gdk_window_get_frame_extents (GdkWindow *window, GdkRectangle *rect) { GdkDisplay *display; - GdkWindowObject *private; GdkWindowImplX11 *impl; Window xwindow; Window xparent; @@ -2926,24 +2866,22 @@ gdk_window_get_frame_extents (GdkWindow *window, g_return_if_fail (rect != NULL); - private = (GdkWindowObject*) window; - rect->x = 0; rect->y = 0; rect->width = 1; rect->height = 1; - while (private->parent && ((GdkWindowObject*) private->parent)->parent) - private = (GdkWindowObject*) private->parent; + while (window->parent && (window->parent)->parent) + window = window->parent; /* Refine our fallback answer a bit using local information */ - rect->x = private->x; - rect->y = private->y; - rect->width = private->width; - rect->height = private->height; + rect->x = window->x; + rect->y = window->y; + rect->width = window->width; + rect->height = window->height; - impl = GDK_WINDOW_IMPL_X11 (private->impl); - if (GDK_WINDOW_DESTROYED (private) || impl->override_redirect) + impl = GDK_WINDOW_IMPL_X11 (window->impl); + if (GDK_WINDOW_DESTROYED (window) || impl->override_redirect) return; nvroots = 0; @@ -3370,7 +3308,7 @@ gdk_window_x11_get_events (GdkWindow *window) event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); /* if property change was filtered out before, keep it filtered out */ filtered = GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK; - GDK_WINDOW_OBJECT (window)->event_mask = event_mask & ((GDK_WINDOW_OBJECT (window)->event_mask & filtered) | ~filtered); + window->event_mask = event_mask & ((window->event_mask & filtered) | ~filtered); return event_mask; } @@ -3511,8 +3449,7 @@ gdk_window_set_override_redirect (GdkWindow *window, if (!GDK_WINDOW_DESTROYED (window) && WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) { - GdkWindowObject *private = (GdkWindowObject *)window; - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); attr.override_redirect = (override_redirect? True : False); XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), @@ -3541,15 +3478,11 @@ void gdk_window_set_accept_focus (GdkWindow *window, gboolean accept_focus) { - GdkWindowObject *private; - - private = (GdkWindowObject *)window; - accept_focus = accept_focus != FALSE; - if (private->accept_focus != accept_focus) + if (window->accept_focus != accept_focus) { - private->accept_focus = accept_focus; + window->accept_focus = accept_focus; if (!GDK_WINDOW_DESTROYED (window) && WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) @@ -3577,18 +3510,14 @@ void gdk_window_set_focus_on_map (GdkWindow *window, gboolean focus_on_map) { - GdkWindowObject *private; - - private = (GdkWindowObject *)window; - focus_on_map = focus_on_map != FALSE; - if (private->focus_on_map != focus_on_map) + if (window->focus_on_map != focus_on_map) { - private->focus_on_map = focus_on_map; + window->focus_on_map = focus_on_map; if ((!GDK_WINDOW_DESTROYED (window)) && - (!private->focus_on_map) && + (!window->focus_on_map) && WINDOW_IS_TOPLEVEL_OR_FOREIGN (window)) gdk_x11_window_set_user_time (window, 0); } @@ -4679,13 +4608,11 @@ gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on) { XSetWindowAttributes xattributes; - GdkWindowObject *private; guint xattributes_mask = 0; g_return_if_fail (GDK_IS_WINDOW (window)); - private = GDK_WINDOW_OBJECT (window); - if (private->input_only) + if (window->input_only) return; xattributes.bit_gravity = StaticGravity; @@ -4715,19 +4642,18 @@ static gboolean gdk_window_x11_set_static_gravities (GdkWindow *window, gboolean use_static) { - GdkWindowObject *private = (GdkWindowObject *)window; GList *tmp_list; - if (!use_static == !private->guffaw_gravity) + if (!use_static == !window->guffaw_gravity) return TRUE; - private->guffaw_gravity = use_static; + window->guffaw_gravity = use_static; if (!GDK_WINDOW_DESTROYED (window)) { gdk_window_set_static_bit_gravity (window, use_static); - tmp_list = private->children; + tmp_list = window->children; while (tmp_list) { gdk_window_set_static_win_gravity (tmp_list->data, use_static); @@ -5036,21 +4962,18 @@ gboolean _gdk_moveresize_handle_event (XEvent *event) { guint button_mask = 0; - GdkWindowObject *window_private; GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display); MoveResizeData *mv_resize = get_move_resize_data (display, FALSE); if (!mv_resize || !mv_resize->moveresize_window) return FALSE; - window_private = (GdkWindowObject *) mv_resize->moveresize_window; - button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1); switch (event->xany.type) { case MotionNotify: - if (window_private->resize_count > 0) + if (mv_resize->moveresize_window->resize_count > 0) { if (mv_resize->moveresize_pending_event) *mv_resize->moveresize_pending_event = *event; @@ -5370,13 +5293,12 @@ gdk_window_begin_move_drag (GdkWindow *window, void gdk_window_enable_synchronized_configure (GdkWindow *window) { - GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowImplX11 *impl; - if (!GDK_IS_WINDOW_IMPL_X11 (private->impl)) + if (!GDK_IS_WINDOW_IMPL_X11 (window->impl)) return; - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); if (!impl->use_synchronized_configure) { @@ -5412,7 +5334,7 @@ gdk_window_configure_finished (GdkWindow *window) if (!WINDOW_IS_TOPLEVEL (window)) return; - impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)window)->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); if (!impl->use_synchronized_configure) return; @@ -5514,17 +5436,16 @@ _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited) { #if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES) - GdkWindowObject *private = (GdkWindowObject *) window; GdkWindowImplX11 *impl; GdkDisplay *display; Display *dpy; Window xid; - impl = GDK_WINDOW_IMPL_X11 (private->impl); + impl = GDK_WINDOW_IMPL_X11 (window->impl); display = gdk_window_get_display (window); dpy = GDK_DISPLAY_XDISPLAY (display); - xid = GDK_WINDOW_XID (private); + xid = GDK_WINDOW_XID (window); if (composited) { @@ -5643,7 +5564,7 @@ gdk_x11_window_get_xid (GdkWindow *window) return None; } - impl = ((GdkWindowObject *) window)->impl; + impl = window->impl; return ((GdkWindowImplX11 *)impl)->xid; } diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 911f93bf97..829007527a 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -117,7 +117,7 @@ gint gdk_x11_get_default_screen (void); * Returns: an Xlib Display*. */ #define GDK_WINDOW_XDISPLAY(win) (GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (win))->xdisplay) -#define GDK_WINDOW_XID(win) (GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->xid) +#define GDK_WINDOW_XID(win) (GDK_WINDOW_IMPL_X11(GDK_WINDOW (win)->impl)->xid) #define GDK_SCREEN_XDISPLAY(screen) (GDK_SCREEN_X11 (screen)->xdisplay) From ac4609ecc9e2a63803a17000720a02c0b9322757 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 00:56:33 +0100 Subject: [PATCH 040/634] x11: Fix in_rectangle computation A point is not in a rectangle when it's at the x + width coordinate. --- gdk/x11/gdkdevice-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c index 06182240e2..008e339b01 100644 --- a/gdk/x11/gdkdevice-core.c +++ b/gdk/x11/gdkdevice-core.c @@ -106,11 +106,11 @@ impl_coord_in_window (GdkWindow *window, int impl_y) { if (impl_x < window->abs_x || - impl_x > window->abs_x + window->width) + impl_x >= window->abs_x + window->width) return FALSE; if (impl_y < window->abs_y || - impl_y > window->abs_y + window->height) + impl_y >= window->abs_y + window->height) return FALSE; return TRUE; From 370d272b13b44917ab6048fa00fd70b8bad9160a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:03:55 +0100 Subject: [PATCH 041/634] gdk: Remove _gdk_window_impl_get_type() function It was only used in the backends, and they can use the correct type directly. --- gdk/gdkinternals.h | 3 --- gdk/quartz/gdkwindow-quartz.c | 8 +------- gdk/win32/gdkwindow-win32.c | 12 +++--------- gdk/x11/gdkwindow-x11.c | 12 +++--------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 0fe151d4b9..e45352f8ba 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -437,9 +437,6 @@ struct _GdkPaintableIface GType _gdk_paintable_get_type (void) G_GNUC_CONST; -/* Implementation types */ -GType _gdk_window_impl_get_type (void) G_GNUC_CONST; - struct GdkAppLaunchContextPrivate { GdkDisplay *display; diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 0f6745b430..634b20eeac 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -473,12 +473,6 @@ _gdk_window_impl_quartz_get_type (void) return object_type; } -GType -_gdk_window_impl_get_type (void) -{ - return _gdk_window_impl_quartz_get_type (); -} - static const gchar * get_default_title (void) { @@ -834,7 +828,7 @@ _gdk_window_impl_new (GdkWindow *window, private = (GdkWindowObject *)window; - impl = g_object_new (_gdk_window_impl_get_type (), NULL); + impl = g_object_new (GDK_TYPE_WINDOW_IMPL_QUARTZ, NULL); private->impl = (GdkDrawable *)impl; draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (impl); draw_impl->wrapper = GDK_DRAWABLE (window); diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 7a8cf149f8..5cd3afb216 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -99,12 +99,6 @@ _gdk_window_impl_win32_get_type (void) return object_type; } -GType -_gdk_window_impl_get_type (void) -{ - return _gdk_window_impl_win32_get_type (); -} - static void gdk_window_impl_win32_init (GdkWindowImplWin32 *impl) { @@ -211,7 +205,7 @@ _gdk_windowing_window_init (GdkScreen *screen) _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL); private = (GdkWindowObject *)_gdk_root; - private->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + private->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL); private->impl_window = private; private->visual = gdk_screen_get_system_visual (screen); @@ -435,7 +429,7 @@ _gdk_window_impl_new (GdkWindow *window, hparent = GDK_WINDOW_HWND (real_parent); - impl = g_object_new (_gdk_window_impl_get_type (), NULL); + impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL); private->impl = (GdkDrawable *)impl; draw_impl = GDK_DRAWABLE_IMPL_WIN32 (impl); draw_impl->wrapper = GDK_DRAWABLE (window); @@ -641,7 +635,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, window = g_object_new (GDK_TYPE_WINDOW, NULL); private = (GdkWindowObject *)window; private->visual = gdk_screen_get_system_visual (_gdk_screen); - private->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + private->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL); impl = GDK_WINDOW_IMPL_WIN32 (private->impl); draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl); draw_impl->wrapper = GDK_DRAWABLE (window); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index f24ca3e3d1..3fd3eb9a09 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -129,12 +129,6 @@ static void gdk_window_impl_x11_finalize (GObject *object); G_DEFINE_TYPE (GdkWindowImplX11, gdk_window_impl_x11, GDK_TYPE_WINDOW_IMPL) -GType -_gdk_window_impl_get_type (void) -{ - return gdk_window_impl_x11_get_type (); -} - static void gdk_window_impl_x11_init (GdkWindowImplX11 *impl) { @@ -469,7 +463,7 @@ _gdk_windowing_window_init (GdkScreen * screen) window = screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL); - window->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); window->impl_window = window; window->visual = gdk_screen_get_system_visual (screen); @@ -709,7 +703,7 @@ _gdk_window_impl_new (GdkWindow *window, xparent = GDK_WINDOW_XID (real_parent); display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen)); - impl = g_object_new (_gdk_window_impl_get_type (), NULL); + impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); window->impl = (GdkDrawable *)impl; impl->wrapper = GDK_WINDOW (window); @@ -913,7 +907,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, window = g_object_new (GDK_TYPE_WINDOW, NULL); - window->impl = g_object_new (_gdk_window_impl_get_type (), NULL); + window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); window->impl_window = window; window->visual = gdk_x11_screen_lookup_visual (screen, XVisualIDFromVisual (attrs.visual)); From 1215f70e23aa0b21bec4c26acbab5374fd807f75 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:08:08 +0100 Subject: [PATCH 042/634] gdk: Remove GdkDrawable->create_cairo_surface vfunc It's unused. --- gdk/gdkdraw.c | 10 ---------- gdk/gdkdrawable.h | 4 ---- gdk/gdkinternals.h | 4 ---- gdk/x11/gdkwindow-x11.c | 1 - 4 files changed, 19 deletions(-) diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index 77b2936ce6..a46a1d882b 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -69,13 +69,3 @@ _gdk_drawable_ref_cairo_surface (GdkDrawable *drawable) return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable); } -/************************************************************************/ - -cairo_surface_t * -_gdk_drawable_create_cairo_surface (GdkDrawable *drawable, - int width, - int height) -{ - return GDK_DRAWABLE_GET_CLASS (drawable)->create_cairo_surface (drawable, - width, height); -} diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index d790b023ca..9e75d15806 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -61,10 +61,6 @@ struct _GdkDrawableClass cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable); - cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable, - int width, - int height); - /* Padding for future expansion */ void (*_gdk_reserved7) (void); void (*_gdk_reserved9) (void); diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index e45352f8ba..dd109d38f4 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -311,10 +311,6 @@ gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface, cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable); -cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable, - int width, - int height); - /************************************* * Interfaces used by windowing code * *************************************/ diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 3fd3eb9a09..82fa879552 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -5573,7 +5573,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) object_class->finalize = gdk_window_impl_x11_finalize; drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; - drawable_class->create_cairo_surface = gdk_x11_create_cairo_surface; impl_class->show = gdk_window_x11_show; impl_class->hide = gdk_window_x11_hide; From 9d2abf81d22208d1e6e202b9ff79183a98dffe7e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:09:22 +0100 Subject: [PATCH 043/634] x11: Remove outdated variable definition --- gdk/x11/gdkprivate-x11.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index f79c9632b7..163093f7cc 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -143,7 +143,6 @@ cairo_surface_t * _gdk_x11_window_create_bitmap_surface (GdkWindow *window, int width, int height); -extern GdkDrawableClass _gdk_x11_drawable_class; extern gboolean _gdk_use_xshm; extern const int _gdk_nenvent_masks; extern const int _gdk_event_mask_table[]; From 62d004cf8f0e431310c0ee551d203b1ba70d9dfe Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:32:19 +0100 Subject: [PATCH 044/634] gdk: Remove _gdk_drawable_ref_cairo_surface() Instead, call the vfunc directly from gdkWindow.c --- gdk/gdkdraw.c | 19 ------------------- gdk/gdkinternals.h | 2 -- gdk/gdkwindow.c | 10 ++++++++-- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index a46a1d882b..56a4215047 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -50,22 +50,3 @@ gdk_drawable_init (GdkDrawable *drawable) { } -/** - * _gdk_drawable_ref_cairo_surface: - * @drawable: a #GdkDrawable - * - * Obtains a #cairo_surface_t for the given drawable. If a - * #cairo_surface_t for the drawable already exists, it will be - * referenced, otherwise a new surface will be created. - * - * Return value: a newly referenced #cairo_surface_t that points - * to @drawable. Unref with cairo_surface_destroy() - **/ -cairo_surface_t * -_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable) -{ - g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL); - - return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable); -} - diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index dd109d38f4..721e733b85 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -309,8 +309,6 @@ GdkDeviceManager * _gdk_device_manager_new (GdkDisplay *display); gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface, GdkRectangle *extents); -cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable); - /************************************* * Interfaces used by windowing code * *************************************/ diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 4dd371aa1d..15c864fdcc 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2733,13 +2733,19 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) return TRUE; } +static cairo_surface_t * +gdk_window_ref_impl_surface (GdkWindow *window) +{ + return GDK_DRAWABLE_GET_CLASS (window->impl)->ref_cairo_surface (window->impl); +} + static cairo_t * gdk_cairo_create_for_impl (GdkWindow *window) { cairo_surface_t *surface; cairo_t *cr; - surface = _gdk_drawable_ref_cairo_surface (window->impl); + surface = gdk_window_ref_impl_surface (window); cr = cairo_create (surface); cairo_surface_destroy (surface); @@ -3604,7 +3610,7 @@ gdk_window_create_cairo_surface (GdkWindow *window, { cairo_surface_t *surface, *subsurface; - surface = _gdk_drawable_ref_cairo_surface (window->impl); + surface = gdk_window_ref_impl_surface (window); if (gdk_window_has_impl (window)) return surface; From d1700d6e3cf5d31b41abf78be5609cd886daf579 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:46:03 +0100 Subject: [PATCH 045/634] gdk: Move ref_cairo_surface from GdkDrawable to GdkWindowImpl Also make it take the actual GdkWindow, not the implementation, like all the other vfuncs do. --- gdk/gdkdrawable.h | 2 -- gdk/gdkoffscreenwindow.c | 8 +++----- gdk/gdkwindow.c | 2 +- gdk/gdkwindowimpl.h | 3 +++ gdk/x11/gdkwindow-x11.c | 22 +++++++++------------- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index 9e75d15806..c8d8146968 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -59,8 +59,6 @@ struct _GdkDrawableClass { GObjectClass parent_class; - cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable); - /* Padding for future expansion */ void (*_gdk_reserved7) (void); void (*_gdk_reserved9) (void); diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index 04770e57da..018af47023 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -135,9 +135,9 @@ is_parent_of (GdkWindow *parent, } static cairo_surface_t * -gdk_offscreen_window_ref_cairo_surface (GdkDrawable *drawable) +gdk_offscreen_window_ref_cairo_surface (GdkWindow *window) { - GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable); + GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl); return cairo_surface_reference (get_surface (offscreen)); } @@ -694,13 +694,11 @@ static void gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass) { GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); - GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gdk_offscreen_window_finalize; - drawable_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface; - + impl_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface; impl_class->show = gdk_offscreen_window_show; impl_class->hide = gdk_offscreen_window_hide; impl_class->withdraw = gdk_offscreen_window_withdraw; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 15c864fdcc..c746764756 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2736,7 +2736,7 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect) static cairo_surface_t * gdk_window_ref_impl_surface (GdkWindow *window) { - return GDK_DRAWABLE_GET_CLASS (window->impl)->ref_cairo_surface (window->impl); + return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->ref_cairo_surface (window); } static cairo_t * diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index 3df0095956..ece83a226e 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -50,6 +50,9 @@ struct _GdkWindowImplClass { GdkDrawableClass parent_class; + cairo_surface_t * + (* ref_cairo_surface) (GdkWindow *window); + void (* show) (GdkWindow *window, gboolean already_mapped); void (* hide) (GdkWindow *window); diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 82fa879552..d7eed9e75f 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -188,11 +188,10 @@ gdk_x11_cairo_surface_destroy (void *data) } static cairo_surface_t * -gdk_x11_create_cairo_surface (GdkDrawable *drawable, +gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl, int width, int height) { - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); GdkVisual *visual; visual = gdk_window_get_visual (impl->wrapper); @@ -203,23 +202,22 @@ gdk_x11_create_cairo_surface (GdkDrawable *drawable, } static cairo_surface_t * -gdk_x11_ref_cairo_surface (GdkDrawable *drawable) +gdk_x11_ref_cairo_surface (GdkWindow *window) { - GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable); + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); - if (GDK_IS_WINDOW_IMPL_X11 (drawable) && - GDK_WINDOW_DESTROYED (impl->wrapper)) + if (GDK_WINDOW_DESTROYED (window)) return NULL; if (!impl->cairo_surface) { - impl->cairo_surface = gdk_x11_create_cairo_surface (drawable, - gdk_window_get_width (impl->wrapper), - gdk_window_get_height (impl->wrapper)); + impl->cairo_surface = gdk_x11_create_cairo_surface (impl, + gdk_window_get_width (window), + gdk_window_get_height (window)); if (impl->cairo_surface) cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - drawable, gdk_x11_cairo_surface_destroy); + impl, gdk_x11_cairo_surface_destroy); } else cairo_surface_reference (impl->cairo_surface); @@ -5567,13 +5565,11 @@ static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass); object_class->finalize = gdk_window_impl_x11_finalize; - drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; - + impl_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; impl_class->show = gdk_window_x11_show; impl_class->hide = gdk_window_x11_hide; impl_class->withdraw = gdk_window_x11_withdraw; From 2408936bb54bc55f1a25d84d18306e0962c4b788 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:47:50 +0100 Subject: [PATCH 046/634] x11: Remove duplicate definition of GDK_WINDOW_XID Now, where did that come from? --- gdk/x11/gdkx.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 829007527a..bf1f0977fc 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -157,12 +157,6 @@ gint gdk_x11_get_default_screen (void); */ #define GDK_WINDOW_XID(win) (gdk_x11_window_get_xid (win)) -/** - * GDK_WINDOW_XID: - * - * Another name for GDK_DRAWABLE_XID(). - */ -#define GDK_WINDOW_XID(win) (gdk_x11_window_get_xid (win)) #define GDK_SCREEN_XDISPLAY(screen) (gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen))) #define GDK_SCREEN_XSCREEN(screen) (gdk_x11_screen_get_xscreen (screen)) From 1ad7c5f8c57d28ed9e2f4a77856c86d5426e9694 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:52:33 +0100 Subject: [PATCH 047/634] x11: Remove unused GDK_DRAWABLE_XROOTWIN macro --- gdk/x11/gdkprivate-x11.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 163093f7cc..ee5e1a76d9 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -149,7 +149,6 @@ extern const int _gdk_event_mask_table[]; extern GdkAtom _gdk_selection_property; extern gboolean _gdk_synchronize; -#define GDK_DRAWABLE_XROOTWIN(win) (GDK_WINDOW_XROOTWIN (win)) #define GDK_SCREEN_DISPLAY(screen) (GDK_SCREEN_X11 (screen)->display) #define GDK_SCREEN_XROOTWIN(screen) (GDK_SCREEN_X11 (screen)->xroot_window) #define GDK_WINDOW_SCREEN(win) (gdk_window_get_screen (win)) From e4c27b0a59f0c6821b6ae8c1cfd19080e459b505 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 01:54:37 +0100 Subject: [PATCH 048/634] API: GdkWindow no longer is a GdkDrawable Also, name the get_type function properly. --- gdk/gdkinternals.h | 2 +- gdk/gdkwindow.c | 4 ++-- gdk/gdkwindow.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 721e733b85..24b09562e7 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -184,7 +184,7 @@ typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display, struct _GdkWindow { - GdkDrawable parent_instance; + GObject parent_instance; GdkDrawable *impl; /* window-system-specific delegate object */ diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index c746764756..a03e52ec12 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -278,12 +278,12 @@ new_region_tag (void) } GType -gdk_window_object_get_type (void) +gdk_window_get_type (void) { static GType object_type = 0; if (!object_type) - object_type = g_type_register_static_simple (GDK_TYPE_DRAWABLE, + object_type = g_type_register_static_simple (G_TYPE_OBJECT, "GdkWindow", sizeof (GdkWindowObjectClass), (GClassInitFunc) gdk_window_class_init, diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 4e408ca86a..cf088b328d 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -478,7 +478,7 @@ struct _GdkPointerHooks typedef struct _GdkWindowObject GdkWindowObject; typedef struct _GdkWindowObjectClass GdkWindowObjectClass; -#define GDK_TYPE_WINDOW (gdk_window_object_get_type ()) +#define GDK_TYPE_WINDOW (gdk_window_get_type ()) #define GDK_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW, GdkWindow)) #define GDK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW, GdkWindowObjectClass)) #define GDK_IS_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW)) @@ -488,7 +488,7 @@ typedef struct _GdkWindowObjectClass GdkWindowObjectClass; struct _GdkWindowObjectClass { - GdkDrawableClass parent_class; + GObjectClass parent_class; GdkWindow * (* pick_embedded_child) (GdkWindow *window, gdouble x, @@ -522,7 +522,7 @@ struct _GdkWindowObjectClass /* Windows */ -GType gdk_window_object_get_type (void) G_GNUC_CONST; +GType gdk_window_get_type (void) G_GNUC_CONST; GdkWindow* gdk_window_new (GdkWindow *parent, GdkWindowAttr *attributes, gint attributes_mask); From 17a0a467a166c5d554f79247c7e7ac8fdb0ed68c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 23 Nov 2010 02:09:01 +0100 Subject: [PATCH 049/634] gdk: Pass the GdkWindow to resize_cairo_surface vfunc So it's in sync with all the other vfuncs. --- gdk/gdkoffscreenwindow.c | 2 +- gdk/gdkwindow.c | 2 +- gdk/gdkwindowimpl.h | 2 +- gdk/quartz/gdkwindow-quartz.c | 2 +- gdk/win32/gdkwindow-win32.c | 2 +- gdk/x11/gdkwindow-x11.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index 018af47023..9ade91bee1 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -611,7 +611,7 @@ gdk_offscreen_window_translate (GdkWindow *window, } static cairo_surface_t * -gdk_offscreen_window_resize_cairo_surface (GdkDrawable *window, +gdk_offscreen_window_resize_cairo_surface (GdkWindow *window, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index a03e52ec12..d7061023b4 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1052,7 +1052,7 @@ recompute_visible_regions_internal (GdkWindow *private, { GdkWindowImplClass *iface = GDK_WINDOW_IMPL_GET_CLASS (private->impl); - private->cairo_surface = iface->resize_cairo_surface (private->impl, + private->cairo_surface = iface->resize_cairo_surface (private, private->cairo_surface, private->width, private->height); diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index ece83a226e..17edbcaad4 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -152,7 +152,7 @@ struct _GdkWindowImplClass gboolean recursing, gboolean foreign_destroy); - cairo_surface_t * (* resize_cairo_surface) (GdkDrawable *window, + cairo_surface_t * (* resize_cairo_surface) (GdkWindow *window, cairo_surface_t *surface, gint width, gint height); diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 634b20eeac..4efe872fad 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -1081,7 +1081,7 @@ _gdk_quartz_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_window_quartz_resize_cairo_surface (GdkDrawable *drawable, +gdk_window_quartz_resize_cairo_surface (GdkWindow *window, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 5cd3afb216..8b73ac2edb 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -739,7 +739,7 @@ _gdk_win32_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_win32_window_resize_cairo_surface (GdkDrawable *drawable, +gdk_win32_window_resize_cairo_surface (GdkWindow *window, cairo_surface_t *surface, gint width, gint height) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index d7eed9e75f..79b1547e96 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1048,7 +1048,7 @@ _gdk_x11_window_destroy (GdkWindow *window, } static cairo_surface_t * -gdk_window_x11_resize_cairo_surface (GdkDrawable *window, +gdk_window_x11_resize_cairo_surface (GdkWindow *window, cairo_surface_t *surface, gint width, gint height) From 804c2c83504266ee4bda039bb816a3009922ec25 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 13:30:28 +0100 Subject: [PATCH 050/634] cellrenderer: Fix docs to say cairo_t instead of GdkDrawable --- gtk/gtkcellrenderer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index e05ec4ccc3..05e60689d1 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -27,18 +27,18 @@ /** * SECTION:gtkcellrenderer - * @Short_description: An object for rendering a single cell on a GdkDrawable + * @Short_description: An object for rendering a single cell * @Title: GtkCellRenderer * @See_also: #GtkCellRendererText, #GtkCellRendererPixbuf, #GtkCellRendererToggle * * The #GtkCellRenderer is a base class of a set of objects used for - * rendering a cell to a #GdkDrawable. These objects are used primarily by + * rendering a cell to a #cairo_t. These objects are used primarily by * the #GtkTreeView widget, though they aren't tied to them in any * specific way. It is worth noting that #GtkCellRenderer is not a * #GtkWidget and cannot be treated as such. * * The primary use of a #GtkCellRenderer is for drawing a certain graphical - * elements on a #GdkDrawable. Typically, one cell renderer is used to + * elements on a #cairo_t. Typically, one cell renderer is used to * draw many cells on the screen. To this extent, it isn't expected that a * CellRenderer keep any permanent state around. Instead, any state is set * just prior to use using #GObjects property system. Then, the From ba20a005702a956e9fe3f77b4224a894a5e9e9df Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 14:09:48 +0100 Subject: [PATCH 051/634] tests: Remove disabled testtext example --- tests/Makefile.am | 6 - tests/testtext.c | 3082 --------------------------------------------- 2 files changed, 3088 deletions(-) delete mode 100644 tests/testtext.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 4d63c11065..a690082b52 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -169,7 +169,6 @@ testsocket_DEPENDENCIES = $(DEPS) testsocket_child_DEPENDENCIES = $(DEPS) testspinbutton_DEPENDENCIES = $(TEST_DEPS) teststatusicon_DEPENDENCIES = $(TEST_DEPS) -#testtext_DEPENDENCIES = $(TEST_DEPS) testtreeedit_DEPENDENCIES = $(DEPS) testtreemodel_DEPENDENCIES = $(DEPS) testtreeview_DEPENDENCIES = $(DEPS) @@ -254,7 +253,6 @@ testtreeflow_LDADD = $(LDADDS) testtreecolumns_LDADD = $(LDADDS) testtreecolumnsizing_LDADD = $(LDADDS) testtreesort_LDADD = $(LDADDS) -#testtext_LDADD = $(LDADDS) treestoretest_LDADD = $(LDADDS) testxinerama_LDADD = $(LDADDS) testmerge_LDADD = $(LDADDS) @@ -301,10 +299,6 @@ testtreeview_SOURCES = \ prop-editor.c \ testtreeview.c -#testtext_SOURCES = \ -# prop-editor.c \ -# testtext.c - testtoolbar_SOURCES = \ testtoolbar.c \ prop-editor.c diff --git a/tests/testtext.c b/tests/testtext.c deleted file mode 100644 index 84159822ca..0000000000 --- a/tests/testtext.c +++ /dev/null @@ -1,3082 +0,0 @@ -/* testtext.c - * Copyright (C) 2000 Red Hat, Inc - * Author: Havoc Pennington - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include -#include -#include -#include - -#include -#include - -#include "prop-editor.h" - -typedef struct _Buffer Buffer; -typedef struct _View View; - -static gint untitled_serial = 1; - -GSList *active_window_stack = NULL; - -struct _Buffer -{ - gint refcount; - GtkTextBuffer *buffer; - char *filename; - gint untitled_serial; - GtkTextTag *invisible_tag; - GtkTextTag *not_editable_tag; - GtkTextTag *found_text_tag; - GtkTextTag *rise_tag; - GtkTextTag *large_tag; - GtkTextTag *indent_tag; - GtkTextTag *margin_tag; - GtkTextTag *custom_tabs_tag; - GSList *color_tags; - guint color_cycle_timeout; - gdouble start_hue; -}; - -struct _View -{ - GtkWidget *window; - GtkWidget *text_view; - GtkAccelGroup *accel_group; - GtkItemFactory *item_factory; - Buffer *buffer; -}; - -static void push_active_window (GtkWindow *window); -static void pop_active_window (void); -static GtkWindow *get_active_window (void); - -static Buffer * create_buffer (void); -static gboolean check_buffer_saved (Buffer *buffer); -static gboolean save_buffer (Buffer *buffer); -static gboolean save_as_buffer (Buffer *buffer); -static char * buffer_pretty_name (Buffer *buffer); -static void buffer_filename_set (Buffer *buffer); -static void buffer_search_forward (Buffer *buffer, - const char *str, - View *view); -static void buffer_search_backward (Buffer *buffer, - const char *str, - View *view); -static void buffer_set_colors (Buffer *buffer, - gboolean enabled); -static void buffer_cycle_colors (Buffer *buffer); - -static View *view_from_widget (GtkWidget *widget); - -static View *create_view (Buffer *buffer); -static void check_close_view (View *view); -static void close_view (View *view); -static void view_set_title (View *view); -static void view_init_menus (View *view); -static void view_add_example_widgets (View *view); - -GSList *buffers = NULL; -GSList *views = NULL; - -static void -push_active_window (GtkWindow *window) -{ - g_object_ref (window); - active_window_stack = g_slist_prepend (active_window_stack, window); -} - -static void -pop_active_window (void) -{ - g_object_unref (active_window_stack->data); - active_window_stack = g_slist_delete_link (active_window_stack, active_window_stack); -} - -static GtkWindow * -get_active_window (void) -{ - if (active_window_stack) - return active_window_stack->data; - else - return NULL; -} - -/* - * Filesel utility function - */ - -typedef gboolean (*FileselOKFunc) (const char *filename, gpointer data); - -static void -filesel_ok_cb (GtkWidget *button, GtkWidget *filesel) -{ - FileselOKFunc ok_func = (FileselOKFunc)g_object_get_data (G_OBJECT (filesel), "ok-func"); - gpointer data = g_object_get_data (G_OBJECT (filesel), "ok-data"); - gint *result = g_object_get_data (G_OBJECT (filesel), "ok-result"); - - gtk_widget_hide (filesel); - - if ((*ok_func) (gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)), data)) - { - gtk_widget_destroy (filesel); - *result = TRUE; - } - else - gtk_widget_show (filesel); -} - -gboolean -filesel_run (GtkWindow *parent, - const char *title, - const char *start_file, - FileselOKFunc func, - gpointer data) -{ - GtkWidget *filesel = gtk_file_selection_new (title); - gboolean result = FALSE; - - if (!parent) - parent = get_active_window (); - - if (parent) - gtk_window_set_transient_for (GTK_WINDOW (filesel), parent); - - if (start_file) - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), start_file); - - - g_object_set_data (G_OBJECT (filesel), "ok-func", func); - g_object_set_data (G_OBJECT (filesel), "ok-data", data); - g_object_set_data (G_OBJECT (filesel), "ok-result", &result); - - g_signal_connect (GTK_FILE_SELECTION (filesel)->ok_button, - "clicked", - G_CALLBACK (filesel_ok_cb), filesel); - g_signal_connect_swapped (GTK_FILE_SELECTION (filesel)->cancel_button, - "clicked", - G_CALLBACK (gtk_widget_destroy), filesel); - - g_signal_connect (filesel, "destroy", - G_CALLBACK (gtk_main_quit), NULL); - gtk_window_set_modal (GTK_WINDOW (filesel), TRUE); - - gtk_widget_show (filesel); - gtk_main (); - - return result; -} - -/* - * MsgBox utility functions - */ - -static void -msgbox_yes_cb (GtkWidget *widget, gboolean *result) -{ - *result = 0; - gtk_widget_destroy (gtk_widget_get_toplevel (widget)); -} - -static void -msgbox_no_cb (GtkWidget *widget, gboolean *result) -{ - *result = 1; - gtk_widget_destroy (gtk_widget_get_toplevel (widget)); -} - -static gboolean -msgbox_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data) -{ - if (event->keyval == GDK_Escape) - { - g_signal_stop_emission_by_name (widget, "key_press_event"); - gtk_widget_destroy (widget); - return TRUE; - } - - return FALSE; -} - -/* Don't copy this example, it's all crack-smoking - you can just use - * GtkMessageDialog now - */ -gint -msgbox_run (GtkWindow *parent, - const char *message, - const char *yes_button, - const char *no_button, - const char *cancel_button, - gint default_index) -{ - gboolean result = -1; - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *label; - GtkWidget *vbox; - GtkWidget *button_box; - GtkWidget *separator; - - g_return_val_if_fail (message != NULL, FALSE); - g_return_val_if_fail (default_index >= 0 && default_index <= 1, FALSE); - - if (!parent) - parent = get_active_window (); - - /* Create a dialog - */ - dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - if (parent) - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - - /* Quit our recursive main loop when the dialog is destroyed. - */ - g_signal_connect (dialog, "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - /* Catch Escape key presses and have them destroy the dialog - */ - g_signal_connect (dialog, "key_press_event", - G_CALLBACK (msgbox_key_press_cb), NULL); - - /* Fill in the contents of the widget - */ - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (dialog), vbox); - - label = gtk_label_new (message); - gtk_misc_set_padding (GTK_MISC (label), 12, 12); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0); - - button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_box), 8); - - - /* When Yes is clicked, call the msgbox_yes_cb - * This sets the result variable and destroys the dialog - */ - if (yes_button) - { - button = gtk_button_new_with_label (yes_button); - gtk_widget_set_can_default (button, TRUE); - gtk_container_add (GTK_CONTAINER (button_box), button); - - if (default_index == 0) - gtk_widget_grab_default (button); - - g_signal_connect (button, "clicked", - G_CALLBACK (msgbox_yes_cb), &result); - } - - /* When No is clicked, call the msgbox_no_cb - * This sets the result variable and destroys the dialog - */ - if (no_button) - { - button = gtk_button_new_with_label (no_button); - gtk_widget_set_can_default (button, TRUE); - gtk_container_add (GTK_CONTAINER (button_box), button); - - if (default_index == 0) - gtk_widget_grab_default (button); - - g_signal_connect (button, "clicked", - G_CALLBACK (msgbox_no_cb), &result); - } - - /* When Cancel is clicked, destroy the dialog - */ - if (cancel_button) - { - button = gtk_button_new_with_label (cancel_button); - gtk_widget_set_can_default (button, TRUE); - gtk_container_add (GTK_CONTAINER (button_box), button); - - if (default_index == 1) - gtk_widget_grab_default (button); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_object_destroy), dialog); - } - - gtk_widget_show_all (dialog); - - /* Run a recursive main loop until a button is clicked - * or the user destroys the dialog through the window mananger */ - gtk_main (); - - return result; -} - -#ifdef DO_BLINK -/* - * Example buffer filling code - */ -static gint -blink_timeout (gpointer data) -{ - GtkTextTag *tag; - static gboolean flip = FALSE; - - tag = GTK_TEXT_TAG (data); - - g_object_set (tag, - "foreground", flip ? "blue" : "purple", - NULL); - - flip = !flip; - - return TRUE; -} -#endif - -static gint -tag_event_handler (GtkTextTag *tag, GtkWidget *widget, GdkEvent *event, - const GtkTextIter *iter, gpointer user_data) -{ - gint char_index; - - char_index = gtk_text_iter_get_offset (iter); - - switch (event->type) - { - case GDK_MOTION_NOTIFY: - printf ("Motion event at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_BUTTON_PRESS: - printf ("Button press at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_2BUTTON_PRESS: - printf ("Double click at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_3BUTTON_PRESS: - printf ("Triple click at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_BUTTON_RELEASE: - printf ("Button release at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - printf ("Key event at char %d tag `%s'\n", - char_index, tag->name); - break; - - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - case GDK_PROPERTY_NOTIFY: - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: - case GDK_SELECTION_NOTIFY: - case GDK_PROXIMITY_IN: - case GDK_PROXIMITY_OUT: - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DRAG_STATUS: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - default: - break; - } - - return FALSE; -} - -static void -setup_tag (GtkTextTag *tag) -{ - g_signal_connect (tag, - "event", - G_CALLBACK (tag_event_handler), - NULL); -} - -static const char *book_closed_xpm[] = { -"16 16 6 1", -" c None s None", -". c black", -"X c red", -"o c yellow", -"O c #808080", -"# c white", -" ", -" .. ", -" ..XX. ", -" ..XXXXX. ", -" ..XXXXXXXX. ", -".ooXXXXXXXXX. ", -"..ooXXXXXXXXX. ", -".X.ooXXXXXXXXX. ", -".XX.ooXXXXXX.. ", -" .XX.ooXXX..#O ", -" .XX.oo..##OO. ", -" .XX..##OO.. ", -" .X.#OO.. ", -" ..O.. ", -" .. ", -" "}; - -void -fill_example_buffer (GtkTextBuffer *buffer) -{ - GtkTextIter iter, iter2; - GtkTextTag *tag; - GtkTextChildAnchor *anchor; - GdkColor color; - GdkColor color2; - GdkPixbuf *pixbuf; - int i; - char *str; - - /* FIXME this is broken if called twice on a buffer, since - * we try to create tags a second time. - */ - - tag = gtk_text_buffer_create_tag (buffer, "fg_blue", NULL); - -#ifdef DO_BLINK - g_timeout_add (1000, (GSourceFunc)blink_timeout, tag); -#endif - - setup_tag (tag); - - color.red = color.green = 0; - color.blue = 0xffff; - color2.red = 0xfff; - color2.blue = 0x0; - color2.green = 0; - g_object_set (tag, - "foreground_gdk", &color, - "background_gdk", &color2, - "size_points", 24.0, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "fg_red", NULL); - - setup_tag (tag); - - color.blue = color.green = 0; - color.red = 0xffff; - g_object_set (tag, - "rise", -4 * PANGO_SCALE, - "foreground_gdk", &color, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "bg_green", NULL); - - setup_tag (tag); - - color.blue = color.red = 0; - color.green = 0xffff; - g_object_set (tag, - "background_gdk", &color, - "size_points", 10.0, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "strikethrough", NULL); - - setup_tag (tag); - - g_object_set (tag, - "strikethrough", TRUE, - NULL); - - - tag = gtk_text_buffer_create_tag (buffer, "underline", NULL); - - setup_tag (tag); - - g_object_set (tag, - "underline", PANGO_UNDERLINE_SINGLE, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "underline_error", NULL); - - setup_tag (tag); - - g_object_set (tag, - "underline", PANGO_UNDERLINE_ERROR, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "centered", NULL); - - g_object_set (tag, - "justification", GTK_JUSTIFY_CENTER, - NULL); - - tag = gtk_text_buffer_create_tag (buffer, "rtl_quote", NULL); - - g_object_set (tag, - "wrap_mode", GTK_WRAP_WORD, - "direction", GTK_TEXT_DIR_RTL, - "indent", 30, - "left_margin", 20, - "right_margin", 20, - NULL); - - - tag = gtk_text_buffer_create_tag (buffer, "negative_indent", NULL); - - g_object_set (tag, - "indent", -25, - NULL); - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - - anchor = gtk_text_buffer_create_child_anchor (buffer, &iter); - - g_object_ref (anchor); - - g_object_set_data_full (G_OBJECT (buffer), "anchor", anchor, - (GDestroyNotify) g_object_unref); - - pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm); - - i = 0; - while (i < 100) - { - GtkTextMark * temp_mark; - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - - gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf); - - str = g_strdup_printf ("%d Hello World! blah blah blah blah blah blah blah blah blah blah blah blah\nwoo woo woo woo woo woo woo woo woo woo woo woo woo woo woo\n", - i); - - gtk_text_buffer_insert (buffer, &iter, str, -1); - - g_free (str); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 0, 5); - - gtk_text_buffer_insert (buffer, &iter, - "(Hello World!)\nfoo foo Hello this is some text we are using to text word wrap. It has punctuation! gee; blah - hmm, great.\nnew line with a significant quantity of text on it. This line really does contain some text. More text! More text! More text!\n" - /* This is UTF8 stuff, Emacs doesn't - really know how to display it */ - "German (Deutsch S\303\274d) Gr\303\274\303\237 Gott Greek (\316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254) \316\223\316\265\316\271\316\254 \317\203\316\261\317\202 Hebrew(\327\251\327\234\327\225\327\235) Hebrew punctuation(\xd6\xbf\327\251\xd6\xbb\xd6\xbc\xd6\xbb\xd6\xbf\327\234\xd6\xbc\327\225\xd6\xbc\xd6\xbb\xd6\xbb\xd6\xbf\327\235\xd6\xbc\xd6\xbb\xd6\xbf) Japanese (\346\227\245\346\234\254\350\252\236) Thai (\340\270\252\340\270\247\340\270\261\340\270\252\340\270\224\340\270\265\340\270\204\340\270\243\340\270\261\340\270\232) Thai wrong spelling (\340\270\204\340\270\263\340\270\225\340\271\210\340\270\255\340\271\204\340\270\233\340\270\231\340\270\267\340\271\210\340\270\252\340\270\260\340\270\201\340\270\224\340\270\234\340\270\264\340\270\224 \340\270\236\340\270\261\340\270\261\340\271\211\340\270\261\340\270\261\340\271\210\340\270\207\340\271\202\340\270\201\340\270\260)\n", -1); - - temp_mark = - gtk_text_buffer_create_mark (buffer, "tmp_mark", &iter, TRUE); - -#if 1 - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 0, 6); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 0, 13); - - gtk_text_buffer_apply_tag_by_name (buffer, "fg_blue", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 1, 10); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 1, 16); - - gtk_text_buffer_apply_tag_by_name (buffer, "underline", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 1, 4); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 1, 7); - - gtk_text_buffer_apply_tag_by_name (buffer, "underline_error", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 1, 14); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 1, 24); - - gtk_text_buffer_apply_tag_by_name (buffer, "strikethrough", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 0, 9); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 0, 16); - - gtk_text_buffer_apply_tag_by_name (buffer, "bg_green", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 4, 2); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 4, 10); - - gtk_text_buffer_apply_tag_by_name (buffer, "bg_green", &iter, &iter2); - - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 4, 8); - gtk_text_buffer_get_iter_at_line_offset (buffer, &iter2, 4, 15); - - gtk_text_buffer_apply_tag_by_name (buffer, "fg_red", &iter, &iter2); -#endif - - gtk_text_buffer_get_iter_at_mark (buffer, &iter, temp_mark); - gtk_text_buffer_insert (buffer, &iter, "Centered text!\n", -1); - - gtk_text_buffer_get_iter_at_mark (buffer, &iter2, temp_mark); - gtk_text_buffer_apply_tag_by_name (buffer, "centered", &iter2, &iter); - - gtk_text_buffer_move_mark (buffer, temp_mark, &iter); - gtk_text_buffer_insert (buffer, &iter, "Word wrapped, Right-to-left Quote\n", -1); - gtk_text_buffer_insert (buffer, &iter, "\331\210\331\202\330\257 \330\250\330\257\330\243 \330\253\331\204\330\247\330\253 \331\205\331\206 \330\243\331\203\330\253\330\261 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \330\252\331\202\330\257\331\205\330\247 \331\201\331\212 \330\264\330\250\331\203\330\251 \330\247\331\203\330\263\331\212\331\210\331\206 \330\250\330\261\330\247\331\205\330\254\331\207\330\247 \331\203\331\205\331\206\330\270\331\205\330\247\330\252 \331\204\330\247 \330\252\330\263\330\271\331\211 \331\204\331\204\330\261\330\250\330\255\330\214 \330\253\331\205 \330\252\330\255\331\210\331\204\330\252 \331\201\331\212 \330\247\331\204\330\263\331\206\331\210\330\247\330\252 \330\247\331\204\330\256\331\205\330\263 \330\247\331\204\331\205\330\247\330\266\331\212\330\251 \330\245\331\204\331\211 \331\205\330\244\330\263\330\263\330\247\330\252 \331\205\330\247\331\204\331\212\330\251 \331\205\331\206\330\270\331\205\330\251\330\214 \331\210\330\250\330\247\330\252\330\252 \330\254\330\262\330\241\330\247 \331\205\331\206 \330\247\331\204\331\206\330\270\330\247\331\205 \330\247\331\204\331\205\330\247\331\204\331\212 \331\201\331\212 \330\250\331\204\330\257\330\247\331\206\331\207\330\247\330\214 \331\210\331\204\331\203\331\206\331\207\330\247 \330\252\330\252\330\256\330\265\330\265 \331\201\331\212 \330\256\330\257\331\205\330\251 \331\202\330\267\330\247\330\271 \330\247\331\204\331\205\330\264\330\261\331\210\330\271\330\247\330\252 \330\247\331\204\330\265\330\272\331\212\330\261\330\251. \331\210\330\243\330\255\330\257 \330\243\331\203\330\253\330\261 \331\207\330\260\331\207 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \331\206\330\254\330\247\330\255\330\247 \331\207\331\210 \302\273\330\250\330\247\331\206\331\203\331\210\330\263\331\210\331\204\302\253 \331\201\331\212 \330\250\331\210\331\204\331\212\331\201\331\212\330\247.\n", -1); - gtk_text_buffer_get_iter_at_mark (buffer, &iter2, temp_mark); - gtk_text_buffer_apply_tag_by_name (buffer, "rtl_quote", &iter2, &iter); - - gtk_text_buffer_insert_with_tags (buffer, &iter, - "Paragraph with negative indentation. blah blah blah blah blah. The quick brown fox jumped over the lazy dog.\n", - -1, - gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table (buffer), - "negative_indent"), - NULL); - - ++i; - } - - g_object_unref (pixbuf); - - printf ("%d lines %d chars\n", - gtk_text_buffer_get_line_count (buffer), - gtk_text_buffer_get_char_count (buffer)); - - /* Move cursor to start */ - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - gtk_text_buffer_place_cursor (buffer, &iter); - - gtk_text_buffer_set_modified (buffer, FALSE); -} - -gboolean -fill_file_buffer (GtkTextBuffer *buffer, const char *filename) -{ - FILE* f; - gchar buf[2048]; - gint remaining = 0; - GtkTextIter iter, end; - - f = fopen (filename, "r"); - - if (f == NULL) - { - gchar *err = g_strdup_printf ("Cannot open file '%s': %s", - filename, g_strerror (errno)); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - g_free (err); - return FALSE; - } - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - while (!feof (f)) - { - gint count; - const char *leftover; - int to_read = 2047 - remaining; - - count = fread (buf + remaining, 1, to_read, f); - buf[count + remaining] = '\0'; - - g_utf8_validate (buf, count + remaining, &leftover); - - g_assert (g_utf8_validate (buf, leftover - buf, NULL)); - gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); - - remaining = (buf + remaining + count) - leftover; - g_memmove (buf, leftover, remaining); - - if (remaining > 6 || count < to_read) - break; - } - - if (remaining) - { - gchar *err = g_strdup_printf ("Invalid UTF-8 data encountered reading file '%s'", filename); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - g_free (err); - } - - /* We had a newline in the buffer to begin with. (The buffer always contains - * a newline, so we delete to the end of the buffer to clean up. - */ - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_delete (buffer, &iter, &end); - - gtk_text_buffer_set_modified (buffer, FALSE); - - return TRUE; -} - -static gint -delete_event_cb (GtkWidget *window, GdkEventAny *event, gpointer data) -{ - View *view = view_from_widget (window); - - push_active_window (GTK_WINDOW (window)); - check_close_view (view); - pop_active_window (); - - return TRUE; -} - -/* - * Menu callbacks - */ - -static View * -get_empty_view (View *view) -{ - if (!view->buffer->filename && - !gtk_text_buffer_get_modified (view->buffer->buffer)) - return view; - else - return create_view (create_buffer ()); -} - -static View * -view_from_widget (GtkWidget *widget) -{ - if (GTK_IS_MENU_ITEM (widget)) - { - GtkItemFactory *item_factory = gtk_item_factory_from_widget (widget); - return g_object_get_data (G_OBJECT (item_factory), "view"); - } - else - { - GtkWidget *app = gtk_widget_get_toplevel (widget); - return g_object_get_data (G_OBJECT (app), "view"); - } -} - -static void -do_new (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - create_view (create_buffer ()); -} - -static void -do_new_view (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - create_view (view->buffer); -} - -gboolean -open_ok_func (const char *filename, gpointer data) -{ - View *view = data; - View *new_view = get_empty_view (view); - - if (!fill_file_buffer (new_view->buffer->buffer, filename)) - { - if (new_view != view) - close_view (new_view); - return FALSE; - } - else - { - g_free (new_view->buffer->filename); - new_view->buffer->filename = g_strdup (filename); - buffer_filename_set (new_view->buffer); - - return TRUE; - } -} - -static void -do_open (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - push_active_window (GTK_WINDOW (view->window)); - filesel_run (NULL, "Open File", NULL, open_ok_func, view); - pop_active_window (); -} - -static void -do_save_as (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - push_active_window (GTK_WINDOW (view->window)); - save_as_buffer (view->buffer); - pop_active_window (); -} - -static void -do_save (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - push_active_window (GTK_WINDOW (view->window)); - if (!view->buffer->filename) - do_save_as (callback_data, callback_action, widget); - else - save_buffer (view->buffer); - pop_active_window (); -} - -static void -do_close (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - push_active_window (GTK_WINDOW (view->window)); - check_close_view (view); - pop_active_window (); -} - -static void -do_exit (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - GSList *tmp_list = buffers; - - push_active_window (GTK_WINDOW (view->window)); - while (tmp_list) - { - if (!check_buffer_saved (tmp_list->data)) - return; - - tmp_list = tmp_list->next; - } - - gtk_main_quit (); - pop_active_window (); -} - -static void -do_example (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - View *new_view; - - new_view = get_empty_view (view); - - fill_example_buffer (new_view->buffer->buffer); - - view_add_example_widgets (new_view); -} - - -static void -do_insert_and_scroll (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextBuffer *buffer; - GtkTextIter start, end; - GtkTextMark *mark; - - buffer = view->buffer->buffer; - - gtk_text_buffer_get_bounds (buffer, &start, &end); - mark = gtk_text_buffer_create_mark (buffer, NULL, &end, /* right grav */ FALSE); - - gtk_text_buffer_insert (buffer, &end, - "Hello this is multiple lines of text\n" - "Line 1\n" "Line 2\n" - "Line 3\n" "Line 4\n" - "Line 5\n", - -1); - - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view->text_view), mark, - 0, TRUE, 0.0, 1.0); - gtk_text_buffer_delete_mark (buffer, mark); -} - -static void -do_wrap_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view->text_view), callback_action); -} - -static void -do_direction_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - gtk_widget_set_direction (view->text_view, callback_action); - gtk_widget_queue_resize (view->text_view); -} - - -static void -do_spacing_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - if (callback_action) - { - gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (view->text_view), - 23); - gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (view->text_view), - 21); - gtk_text_view_set_pixels_inside_wrap (GTK_TEXT_VIEW (view->text_view), - 9); - } - else - { - gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (view->text_view), - 0); - gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (view->text_view), - 0); - gtk_text_view_set_pixels_inside_wrap (GTK_TEXT_VIEW (view->text_view), - 0); - } -} - -static void -do_editable_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - gtk_text_view_set_editable (GTK_TEXT_VIEW (view->text_view), callback_action); -} - -static void -change_cursor_color (GtkWidget *widget, - gboolean set) -{ - if (set) - { - GdkColor red = {0, 65535, 0, 0}; - gtk_widget_modify_cursor (widget, &red, &red); - } - else - gtk_widget_modify_cursor (widget, NULL, NULL); -} - -static void -do_cursor_visible_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - switch (callback_action) - { - case 0: - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view->text_view), FALSE); - break; - case 1: - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view->text_view), TRUE); - change_cursor_color (view->text_view, FALSE); - break; - case 2: - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view->text_view), TRUE); - change_cursor_color (view->text_view, TRUE); - break; - } -} - -static void -do_color_cycle_changed (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - buffer_set_colors (view->buffer, callback_action); -} - -static void -do_apply_editable (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->not_editable_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->not_editable_tag, - &start, &end); - } - } -} - -static void -do_apply_invisible (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->invisible_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->invisible_tag, - &start, &end); - } - } -} - -static void -do_apply_rise (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->rise_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->rise_tag, - &start, &end); - } - } -} - -static void -do_apply_large (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->large_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->large_tag, - &start, &end); - } - } -} - -static void -do_apply_indent (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->indent_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->indent_tag, - &start, &end); - } - } -} - -static void -do_apply_margin (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->margin_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->margin_tag, - &start, &end); - } - } -} - -static void -do_apply_tabs (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (callback_action) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - view->buffer->custom_tabs_tag, - &start, &end); - } - else - { - gtk_text_buffer_apply_tag (view->buffer->buffer, - view->buffer->custom_tabs_tag, - &start, &end); - } - } -} - -static void -do_apply_colors (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - Buffer *buffer = view->buffer; - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - if (!callback_action) - { - GSList *tmp; - - tmp = buffer->color_tags; - while (tmp != NULL) - { - gtk_text_buffer_remove_tag (view->buffer->buffer, - tmp->data, - &start, &end); - tmp = g_slist_next (tmp); - } - } - else - { - GSList *tmp; - - tmp = buffer->color_tags; - while (TRUE) - { - GtkTextIter next; - gboolean done = FALSE; - - next = start; - gtk_text_iter_forward_char (&next); - gtk_text_iter_forward_char (&next); - - if (gtk_text_iter_compare (&next, &end) >= 0) - { - next = end; - done = TRUE; - } - - gtk_text_buffer_apply_tag (view->buffer->buffer, - tmp->data, - &start, &next); - - start = next; - - if (done) - return; - - tmp = g_slist_next (tmp); - if (tmp == NULL) - tmp = buffer->color_tags; - } - } - } -} - -static void -do_remove_tags (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextIter start; - GtkTextIter end; - - if (gtk_text_buffer_get_selection_bounds (view->buffer->buffer, - &start, &end)) - { - gtk_text_buffer_remove_all_tags (view->buffer->buffer, - &start, &end); - } -} - -static void -do_properties (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - create_prop_editor (G_OBJECT (view->text_view), 0); -} - -static void -rich_text_store_populate (GtkListStore *store, - GtkTextBuffer *buffer, - gboolean deserialize) -{ - GdkAtom *formats; - gint n_formats; - gint i; - - gtk_list_store_clear (store); - - if (deserialize) - formats = gtk_text_buffer_get_deserialize_formats (buffer, &n_formats); - else - formats = gtk_text_buffer_get_serialize_formats (buffer, &n_formats); - - for (i = 0; i < n_formats; i++) - { - GtkTreeIter iter; - gchar *mime_type; - gboolean can_create_tags = FALSE; - - mime_type = gdk_atom_name (formats[i]); - - if (deserialize) - can_create_tags = - gtk_text_buffer_deserialize_get_can_create_tags (buffer, formats[i]); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, formats[i], - 1, mime_type, - 2, can_create_tags, - -1); - - g_free (mime_type); - } - - g_free (formats); -} - -static void -rich_text_paste_target_list_notify (GtkTextBuffer *buffer, - const GParamSpec *pspec, - GtkListStore *store) -{ - rich_text_store_populate (store, buffer, TRUE); -} - -static void -rich_text_copy_target_list_notify (GtkTextBuffer *buffer, - const GParamSpec *pspec, - GtkListStore *store) -{ - rich_text_store_populate (store, buffer, FALSE); -} - -static void -rich_text_can_create_tags_toggled (GtkCellRendererToggle *toggle, - const gchar *path, - GtkTreeModel *model) -{ - GtkTreeIter iter; - - if (gtk_tree_model_get_iter_from_string (model, &iter, path)) - { - GtkTextBuffer *buffer; - GdkAtom format; - gboolean can_create_tags; - - buffer = g_object_get_data (G_OBJECT (model), "buffer"); - - gtk_tree_model_get (model, &iter, - 0, &format, - 2, &can_create_tags, - -1); - - gtk_text_buffer_deserialize_set_can_create_tags (buffer, format, - !can_create_tags); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - 2, !can_create_tags, - -1); - } -} - -static void -rich_text_unregister_clicked (GtkWidget *button, - GtkTreeView *tv) -{ - GtkTreeSelection *sel = gtk_tree_view_get_selection (tv); - GtkTreeModel *model; - GtkTreeIter iter; - - if (gtk_tree_selection_get_selected (sel, &model, &iter)) - { - GtkTextBuffer *buffer; - gboolean deserialize; - GdkAtom format; - - buffer = g_object_get_data (G_OBJECT (model), "buffer"); - deserialize = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), - "deserialize")); - - gtk_tree_model_get (model, &iter, - 0, &format, - -1); - - if (deserialize) - gtk_text_buffer_unregister_deserialize_format (buffer, format); - else - gtk_text_buffer_unregister_serialize_format (buffer, format); - } -} - -static void -rich_text_register_clicked (GtkWidget *button, - GtkTreeView *tv) -{ - GtkWidget *dialog; - GtkWidget *label; - GtkWidget *entry; - - dialog = gtk_dialog_new_with_buttons ("Register new Tagset", - GTK_WINDOW (gtk_widget_get_toplevel (button)), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - label = gtk_label_new ("Enter tagset name or leave blank for " - "unrestricted internal format:"); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, - FALSE, FALSE, 0); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), entry, - FALSE, FALSE, 0); - - gtk_widget_show_all (dialog); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - GtkTreeModel *model = gtk_tree_view_get_model (tv); - GtkTextBuffer *buffer = g_object_get_data (G_OBJECT (model), "buffer"); - const gchar *tagset = gtk_entry_get_text (GTK_ENTRY (entry)); - gboolean deserialize; - - deserialize = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), - "deserialize")); - - if (tagset && ! strlen (tagset)) - tagset = NULL; - - if (deserialize) - gtk_text_buffer_register_deserialize_tagset (buffer, tagset); - else - gtk_text_buffer_register_serialize_tagset (buffer, tagset); - } - - gtk_widget_destroy (dialog); -} - -static void -do_rich_text (gpointer callback_data, - guint deserialize, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextBuffer *buffer; - GtkWidget *dialog; - GtkWidget *tv; - GtkWidget *sw; - GtkWidget *hbox; - GtkWidget *button; - GtkListStore *store; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view->text_view)); - - dialog = gtk_dialog_new_with_buttons (deserialize ? - "Rich Text Paste & Drop" : - "Rich Text Copy & Drag", - GTK_WINDOW (view->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, 0, - NULL); - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - - store = gtk_list_store_new (3, - G_TYPE_POINTER, - G_TYPE_STRING, - G_TYPE_BOOLEAN); - - g_object_set_data (G_OBJECT (store), "buffer", buffer); - g_object_set_data (G_OBJECT (store), "deserialize", - GUINT_TO_POINTER (deserialize)); - - tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - g_object_unref (store); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), - 0, "Rich Text Format", - gtk_cell_renderer_text_new (), - "text", 1, - NULL); - - if (deserialize) - { - GtkCellRenderer *renderer = gtk_cell_renderer_toggle_new (); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), - 1, "Can Create Tags", - renderer, - "active", 2, - NULL); - - g_signal_connect (renderer, "toggled", - G_CALLBACK (rich_text_can_create_tags_toggled), - store); - } - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_set_size_request (sw, 300, 100); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), sw); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), tv); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 6); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, - FALSE, FALSE, 0); - - button = gtk_button_new_with_label ("Unregister Selected Format"); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - - g_signal_connect (button, "clicked", - G_CALLBACK (rich_text_unregister_clicked), - tv); - - button = gtk_button_new_with_label ("Register New Tagset\n" - "for the Internal Format"); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - - g_signal_connect (button, "clicked", - G_CALLBACK (rich_text_register_clicked), - tv); - - if (deserialize) - g_signal_connect_object (buffer, "notify::paste-target-list", - G_CALLBACK (rich_text_paste_target_list_notify), - G_OBJECT (store), 0); - else - g_signal_connect_object (buffer, "notify::copy-target-list", - G_CALLBACK (rich_text_copy_target_list_notify), - G_OBJECT (store), 0); - - rich_text_store_populate (store, buffer, deserialize); - - gtk_widget_show_all (dialog); -} - -enum -{ - RESPONSE_FORWARD, - RESPONSE_BACKWARD -}; - -static void -dialog_response_callback (GtkWidget *dialog, gint response_id, gpointer data) -{ - GtkTextBuffer *buffer; - View *view = data; - GtkTextIter start, end; - gchar *search_string; - - if (response_id != RESPONSE_FORWARD && - response_id != RESPONSE_BACKWARD) - { - gtk_widget_destroy (dialog); - return; - } - - buffer = g_object_get_data (G_OBJECT (dialog), "buffer"); - - gtk_text_buffer_get_bounds (buffer, &start, &end); - - search_string = gtk_text_iter_get_text (&start, &end); - - g_print ("Searching for `%s'\n", search_string); - - if (response_id == RESPONSE_FORWARD) - buffer_search_forward (view->buffer, search_string, view); - else if (response_id == RESPONSE_BACKWARD) - buffer_search_backward (view->buffer, search_string, view); - - g_free (search_string); - - gtk_widget_destroy (dialog); -} - -static void -do_copy (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextBuffer *buffer; - - buffer = view->buffer->buffer; - - gtk_text_buffer_copy_clipboard (buffer, - gtk_clipboard_get (GDK_NONE)); -} - -static void -do_search (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkWidget *dialog; - GtkWidget *search_text; - GtkTextBuffer *buffer; - - dialog = gtk_dialog_new_with_buttons ("Search", - GTK_WINDOW (view->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - "Forward", RESPONSE_FORWARD, - "Backward", RESPONSE_BACKWARD, - GTK_STOCK_CANCEL, - GTK_RESPONSE_NONE, NULL); - - - buffer = gtk_text_buffer_new (NULL); - - search_text = gtk_text_view_new_with_buffer (buffer); - - g_object_unref (buffer); - - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox), - search_text, - TRUE, TRUE, 0); - - g_object_set_data (G_OBJECT (dialog), "buffer", buffer); - - g_signal_connect (dialog, - "response", - G_CALLBACK (dialog_response_callback), - view); - - gtk_widget_show (search_text); - - gtk_widget_grab_focus (search_text); - - gtk_widget_show_all (dialog); -} - -static void -do_select_all (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkTextBuffer *buffer; - GtkTextIter start, end; - - buffer = view->buffer->buffer; - - gtk_text_buffer_get_bounds (buffer, &start, &end); - gtk_text_buffer_select_range (buffer, &start, &end); -} - -typedef struct -{ - /* position is in coordinate system of text_view_move_child */ - int click_x; - int click_y; - int start_x; - int start_y; - int button; -} ChildMoveInfo; - -static gboolean -movable_child_callback (GtkWidget *child, - GdkEvent *event, - gpointer data) -{ - ChildMoveInfo *info; - GtkTextView *text_view; - - text_view = GTK_TEXT_VIEW (data); - - g_return_val_if_fail (GTK_IS_EVENT_BOX (child), FALSE); - g_return_val_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (text_view), FALSE); - - info = g_object_get_data (G_OBJECT (child), - "testtext-move-info"); - - if (info == NULL) - { - info = g_new (ChildMoveInfo, 1); - info->start_x = -1; - info->start_y = -1; - info->button = -1; - g_object_set_data_full (G_OBJECT (child), - "testtext-move-info", - info, - g_free); - } - - switch (event->type) - { - case GDK_BUTTON_PRESS: - if (info->button < 0) - { - if (gdk_pointer_grab (event->button.window, - FALSE, - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, - NULL, - event->button.time) != GDK_GRAB_SUCCESS) - return FALSE; - - info->button = event->button.button; - - info->start_x = child->allocation.x; - info->start_y = child->allocation.y; - info->click_x = child->allocation.x + event->button.x; - info->click_y = child->allocation.y + event->button.y; - } - break; - - case GDK_BUTTON_RELEASE: - if (info->button < 0) - return FALSE; - - if (info->button == event->button.button) - { - int x, y; - - gdk_pointer_ungrab (event->button.time); - info->button = -1; - - /* convert to window coords from event box coords */ - x = info->start_x + (event->button.x + child->allocation.x - info->click_x); - y = info->start_y + (event->button.y + child->allocation.y - info->click_y); - - gtk_text_view_move_child (text_view, - child, - x, y); - } - break; - - case GDK_MOTION_NOTIFY: - { - int x, y; - - if (info->button < 0) - return FALSE; - - gdk_window_get_pointer (child->window, &x, &y, NULL); /* ensure more events */ - - /* to window coords from event box coords */ - x += child->allocation.x; - y += child->allocation.y; - - x = info->start_x + (x - info->click_x); - y = info->start_y + (y - info->click_y); - - gtk_text_view_move_child (text_view, - child, - x, y); - } - break; - - default: - break; - } - - return FALSE; -} - -static void -add_movable_child (GtkTextView *text_view, - GtkTextWindowType window) -{ - GtkWidget *event_box; - GtkWidget *label; - GdkColor color; - - label = gtk_label_new ("Drag me around"); - - event_box = gtk_event_box_new (); - gtk_widget_add_events (event_box, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - - color.red = 0xffff; - color.green = color.blue = 0; - gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &color); - - gtk_container_add (GTK_CONTAINER (event_box), label); - - gtk_widget_show_all (event_box); - - g_signal_connect (event_box, "event", - G_CALLBACK (movable_child_callback), - text_view); - - gtk_text_view_add_child_in_window (text_view, - event_box, - window, - 0, 0); -} - -static void -do_add_children (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - - add_movable_child (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_WIDGET); - add_movable_child (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_LEFT); - add_movable_child (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_RIGHT); -} - -static void -do_add_focus_children (gpointer callback_data, - guint callback_action, - GtkWidget *widget) -{ - View *view = view_from_widget (widget); - GtkWidget *child; - GtkTextChildAnchor *anchor; - GtkTextIter iter; - GtkTextView *text_view; - - text_view = GTK_TEXT_VIEW (view->text_view); - - child = gtk_button_new_with_mnemonic ("Button _A in widget->window"); - - gtk_text_view_add_child_in_window (text_view, - child, - GTK_TEXT_WINDOW_WIDGET, - 200, 200); - - child = gtk_button_new_with_mnemonic ("Button _B in widget->window"); - - gtk_text_view_add_child_in_window (text_view, - child, - GTK_TEXT_WINDOW_WIDGET, - 350, 300); - - child = gtk_button_new_with_mnemonic ("Button _C in left window"); - - gtk_text_view_add_child_in_window (text_view, - child, - GTK_TEXT_WINDOW_LEFT, - 0, 0); - - child = gtk_button_new_with_mnemonic ("Button _D in right window"); - - gtk_text_view_add_child_in_window (text_view, - child, - GTK_TEXT_WINDOW_RIGHT, - 0, 0); - - gtk_text_buffer_get_start_iter (view->buffer->buffer, &iter); - - anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter); - - child = gtk_button_new_with_mnemonic ("Button _E in buffer"); - - gtk_text_view_add_child_at_anchor (text_view, child, anchor); - - anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter); - - child = gtk_button_new_with_mnemonic ("Button _F in buffer"); - - gtk_text_view_add_child_at_anchor (text_view, child, anchor); - - anchor = gtk_text_buffer_create_child_anchor (view->buffer->buffer, &iter); - - child = gtk_button_new_with_mnemonic ("Button _G in buffer"); - - gtk_text_view_add_child_at_anchor (text_view, child, anchor); - - /* show all the buttons */ - gtk_widget_show_all (view->text_view); -} - -static void -view_init_menus (View *view) -{ - GtkTextDirection direction = gtk_widget_get_direction (view->text_view); - GtkWrapMode wrap_mode = gtk_text_view_get_wrap_mode (GTK_TEXT_VIEW (view->text_view)); - GtkWidget *menu_item = NULL; - - switch (direction) - { - case GTK_TEXT_DIR_LTR: - menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Left-to-Right"); - break; - case GTK_TEXT_DIR_RTL: - menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Right-to-Left"); - break; - default: - break; - } - - if (menu_item) - gtk_menu_item_activate (GTK_MENU_ITEM (menu_item)); - - switch (wrap_mode) - { - case GTK_WRAP_NONE: - menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Off"); - break; - case GTK_WRAP_WORD: - menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Words"); - break; - case GTK_WRAP_CHAR: - menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Chars"); - break; - default: - break; - } - - if (menu_item) - gtk_menu_item_activate (GTK_MENU_ITEM (menu_item)); -} - -static GtkItemFactoryEntry menu_items[] = -{ - { "/_File", NULL, NULL, 0, "" }, - { "/File/_New", "N", do_new, 0, NULL }, - { "/File/New _View", NULL, do_new_view, 0, NULL }, - { "/File/_Open", "O", do_open, 0, NULL }, - { "/File/_Save", "S", do_save, 0, NULL }, - { "/File/Save _As...", NULL, do_save_as, 0, NULL }, - { "/File/sep1", NULL, NULL, 0, "" }, - { "/File/_Close", "W" , do_close, 0, NULL }, - { "/File/E_xit", "Q" , do_exit, 0, NULL }, - - { "/_Edit", NULL, 0, 0, "" }, - { "/Edit/Copy", NULL, do_copy, 0, NULL }, - { "/Edit/sep1", NULL, NULL, 0, "" }, - { "/Edit/Find...", NULL, do_search, 0, NULL }, - { "/Edit/Select All", "A", do_select_all, 0, NULL }, - - { "/_Settings", NULL, NULL, 0, "" }, - { "/Settings/Wrap _Off", NULL, do_wrap_changed, GTK_WRAP_NONE, "" }, - { "/Settings/Wrap _Words", NULL, do_wrap_changed, GTK_WRAP_WORD, "/Settings/Wrap Off" }, - { "/Settings/Wrap _Chars", NULL, do_wrap_changed, GTK_WRAP_CHAR, "/Settings/Wrap Off" }, - { "/Settings/sep1", NULL, NULL, 0, "" }, - { "/Settings/Editable", NULL, do_editable_changed, TRUE, "" }, - { "/Settings/Not editable", NULL, do_editable_changed, FALSE, "/Settings/Editable" }, - { "/Settings/sep1", NULL, NULL, 0, "" }, - - { "/Settings/Cursor normal", NULL, do_cursor_visible_changed, 1, "" }, - { "/Settings/Cursor not visible", NULL, do_cursor_visible_changed, 0, "/Settings/Cursor normal" }, - { "/Settings/Cursor colored", NULL, do_cursor_visible_changed, 2, "/Settings/Cursor normal" }, - { "/Settings/sep1", NULL, NULL, 0, "" }, - - { "/Settings/Left-to-Right", NULL, do_direction_changed, GTK_TEXT_DIR_LTR, "" }, - { "/Settings/Right-to-Left", NULL, do_direction_changed, GTK_TEXT_DIR_RTL, "/Settings/Left-to-Right" }, - - { "/Settings/sep1", NULL, NULL, 0, "" }, - { "/Settings/Sane spacing", NULL, do_spacing_changed, FALSE, "" }, - { "/Settings/Funky spacing", NULL, do_spacing_changed, TRUE, "/Settings/Sane spacing" }, - { "/Settings/sep1", NULL, NULL, 0, "" }, - { "/Settings/Don't cycle color tags", NULL, do_color_cycle_changed, FALSE, "" }, - { "/Settings/Cycle colors", NULL, do_color_cycle_changed, TRUE, "/Settings/Don't cycle color tags" }, - { "/_Attributes", NULL, NULL, 0, "" }, - { "/Attributes/Editable", NULL, do_apply_editable, TRUE, NULL }, - { "/Attributes/Not editable", NULL, do_apply_editable, FALSE, NULL }, - { "/Attributes/Invisible", NULL, do_apply_invisible, FALSE, NULL }, - { "/Attributes/Visible", NULL, do_apply_invisible, TRUE, NULL }, - { "/Attributes/Rise", NULL, do_apply_rise, FALSE, NULL }, - { "/Attributes/Large", NULL, do_apply_large, FALSE, NULL }, - { "/Attributes/Indent", NULL, do_apply_indent, FALSE, NULL }, - { "/Attributes/Margins", NULL, do_apply_margin, FALSE, NULL }, - { "/Attributes/Custom tabs", NULL, do_apply_tabs, FALSE, NULL }, - { "/Attributes/Default tabs", NULL, do_apply_tabs, TRUE, NULL }, - { "/Attributes/Color cycles", NULL, do_apply_colors, TRUE, NULL }, - { "/Attributes/No colors", NULL, do_apply_colors, FALSE, NULL }, - { "/Attributes/Remove all tags", NULL, do_remove_tags, 0, NULL }, - { "/Attributes/Properties", NULL, do_properties, 0, NULL }, - { "/Attributes/Rich Text copy & drag", NULL, do_rich_text, 0, NULL }, - { "/Attributes/Rich Text paste & drop", NULL, do_rich_text, 1, NULL }, - { "/_Test", NULL, NULL, 0, "" }, - { "/Test/_Example", NULL, do_example, 0, NULL }, - { "/Test/_Insert and scroll", NULL, do_insert_and_scroll, 0, NULL }, - { "/Test/_Add fixed children", NULL, do_add_children, 0, NULL }, - { "/Test/A_dd focusable children", NULL, do_add_focus_children, 0, NULL }, -}; - -static gboolean -save_buffer (Buffer *buffer) -{ - GtkTextIter start, end; - gchar *chars; - gboolean result = FALSE; - gboolean have_backup = FALSE; - gchar *bak_filename; - FILE *file; - - g_return_val_if_fail (buffer->filename != NULL, FALSE); - - bak_filename = g_strconcat (buffer->filename, "~", NULL); - - if (rename (buffer->filename, bak_filename) != 0) - { - if (errno != ENOENT) - { - gchar *err = g_strdup_printf ("Cannot back up '%s' to '%s': %s", - buffer->filename, bak_filename, g_strerror (errno)); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - g_free (err); - return FALSE; - } - } - else - have_backup = TRUE; - - file = fopen (buffer->filename, "w"); - if (!file) - { - gchar *err = g_strdup_printf ("Cannot back up '%s' to '%s': %s", - buffer->filename, bak_filename, g_strerror (errno)); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - } - else - { - gtk_text_buffer_get_iter_at_offset (buffer->buffer, &start, 0); - gtk_text_buffer_get_end_iter (buffer->buffer, &end); - - chars = gtk_text_buffer_get_slice (buffer->buffer, &start, &end, FALSE); - - if (fputs (chars, file) == EOF || - fclose (file) == EOF) - { - gchar *err = g_strdup_printf ("Error writing to '%s': %s", - buffer->filename, g_strerror (errno)); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - g_free (err); - } - else - { - /* Success - */ - result = TRUE; - gtk_text_buffer_set_modified (buffer->buffer, FALSE); - } - - g_free (chars); - } - - if (!result && have_backup) - { - if (rename (bak_filename, buffer->filename) != 0) - { - gchar *err = g_strdup_printf ("Error restoring backup file '%s' to '%s': %s\nBackup left as '%s'", - buffer->filename, bak_filename, g_strerror (errno), bak_filename); - msgbox_run (NULL, err, "OK", NULL, NULL, 0); - g_free (err); - } - } - - g_free (bak_filename); - - return result; -} - -static gboolean -save_as_ok_func (const char *filename, gpointer data) -{ - Buffer *buffer = data; - char *old_filename = buffer->filename; - - if (!buffer->filename || strcmp (filename, buffer->filename) != 0) - { - struct stat statbuf; - - if (stat (filename, &statbuf) == 0) - { - gchar *err = g_strdup_printf ("Ovewrite existing file '%s'?", filename); - gint result = msgbox_run (NULL, err, "Yes", "No", NULL, 1); - g_free (err); - - if (result != 0) - return FALSE; - } - } - - buffer->filename = g_strdup (filename); - - if (save_buffer (buffer)) - { - g_free (old_filename); - buffer_filename_set (buffer); - return TRUE; - } - else - { - g_free (buffer->filename); - buffer->filename = old_filename; - return FALSE; - } -} - -static gboolean -save_as_buffer (Buffer *buffer) -{ - return filesel_run (NULL, "Save File", NULL, save_as_ok_func, buffer); -} - -static gboolean -check_buffer_saved (Buffer *buffer) -{ - if (gtk_text_buffer_get_modified (buffer->buffer)) - { - char *pretty_name = buffer_pretty_name (buffer); - char *msg = g_strdup_printf ("Save changes to '%s'?", pretty_name); - gint result; - - g_free (pretty_name); - - result = msgbox_run (NULL, msg, "Yes", "No", "Cancel", 0); - g_free (msg); - - if (result == 0) - return save_as_buffer (buffer); - else if (result == 1) - return TRUE; - else - return FALSE; - } - else - return TRUE; -} - -#define N_COLORS 16 - -static Buffer * -create_buffer (void) -{ - Buffer *buffer; - PangoTabArray *tabs; - gint i; - - buffer = g_new (Buffer, 1); - - buffer->buffer = gtk_text_buffer_new (NULL); - - buffer->refcount = 1; - buffer->filename = NULL; - buffer->untitled_serial = -1; - - buffer->color_tags = NULL; - buffer->color_cycle_timeout = 0; - buffer->start_hue = 0.0; - - i = 0; - while (i < N_COLORS) - { - GtkTextTag *tag; - - tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, NULL); - - buffer->color_tags = g_slist_prepend (buffer->color_tags, tag); - - ++i; - } - -#if 1 - buffer->invisible_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "invisible", TRUE, NULL); -#endif - - buffer->not_editable_tag = - gtk_text_buffer_create_tag (buffer->buffer, NULL, - "editable", FALSE, - "foreground", "purple", NULL); - - buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "foreground", "red", NULL); - - buffer->rise_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "rise", 10 * PANGO_SCALE, NULL); - - buffer->large_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "scale", PANGO_SCALE_X_LARGE, NULL); - - buffer->indent_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "indent", 20, NULL); - - buffer->margin_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "left_margin", 20, "right_margin", 20, NULL); - - tabs = pango_tab_array_new_with_positions (4, - TRUE, - PANGO_TAB_LEFT, 10, - PANGO_TAB_LEFT, 30, - PANGO_TAB_LEFT, 60, - PANGO_TAB_LEFT, 120); - - buffer->custom_tabs_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL, - "tabs", tabs, - "foreground", "green", NULL); - - pango_tab_array_free (tabs); - - buffers = g_slist_prepend (buffers, buffer); - - return buffer; -} - -static char * -buffer_pretty_name (Buffer *buffer) -{ - if (buffer->filename) - { - char *p; - char *result = g_path_get_basename (buffer->filename); - p = strchr (result, '/'); - if (p) - *p = '\0'; - - return result; - } - else - { - if (buffer->untitled_serial == -1) - buffer->untitled_serial = untitled_serial++; - - if (buffer->untitled_serial == 1) - return g_strdup ("Untitled"); - else - return g_strdup_printf ("Untitled #%d", buffer->untitled_serial); - } -} - -static void -buffer_filename_set (Buffer *buffer) -{ - GSList *tmp_list = views; - - while (tmp_list) - { - View *view = tmp_list->data; - - if (view->buffer == buffer) - view_set_title (view); - - tmp_list = tmp_list->next; - } -} - -static void -buffer_search (Buffer *buffer, - const char *str, - View *view, - gboolean forward) -{ - GtkTextIter iter; - GtkTextIter start, end; - GtkWidget *dialog; - int i; - - /* remove tag from whole buffer */ - gtk_text_buffer_get_bounds (buffer->buffer, &start, &end); - gtk_text_buffer_remove_tag (buffer->buffer, buffer->found_text_tag, - &start, &end ); - - gtk_text_buffer_get_iter_at_mark (buffer->buffer, &iter, - gtk_text_buffer_get_mark (buffer->buffer, - "insert")); - - i = 0; - if (*str != '\0') - { - GtkTextIter match_start, match_end; - - if (forward) - { - while (gtk_text_iter_forward_search (&iter, str, - GTK_TEXT_SEARCH_VISIBLE_ONLY | - GTK_TEXT_SEARCH_TEXT_ONLY, - &match_start, &match_end, - NULL)) - { - ++i; - gtk_text_buffer_apply_tag (buffer->buffer, buffer->found_text_tag, - &match_start, &match_end); - - iter = match_end; - } - } - else - { - while (gtk_text_iter_backward_search (&iter, str, - GTK_TEXT_SEARCH_VISIBLE_ONLY | - GTK_TEXT_SEARCH_TEXT_ONLY, - &match_start, &match_end, - NULL)) - { - ++i; - gtk_text_buffer_apply_tag (buffer->buffer, buffer->found_text_tag, - &match_start, &match_end); - - iter = match_start; - } - } - } - - dialog = gtk_message_dialog_new (GTK_WINDOW (view->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%d strings found and marked in red", - i); - - g_signal_connect_swapped (dialog, - "response", - G_CALLBACK (gtk_widget_destroy), dialog); - - gtk_widget_show (dialog); -} - -static void -buffer_search_forward (Buffer *buffer, const char *str, - View *view) -{ - buffer_search (buffer, str, view, TRUE); -} - -static void -buffer_search_backward (Buffer *buffer, const char *str, - View *view) -{ - buffer_search (buffer, str, view, FALSE); -} - -static void -buffer_ref (Buffer *buffer) -{ - buffer->refcount++; -} - -static void -buffer_unref (Buffer *buffer) -{ - buffer->refcount--; - if (buffer->refcount == 0) - { - buffer_set_colors (buffer, FALSE); - buffers = g_slist_remove (buffers, buffer); - g_object_unref (buffer->buffer); - g_free (buffer->filename); - g_free (buffer); - } -} - -static void -hsv_to_rgb (gdouble *h, - gdouble *s, - gdouble *v) -{ - gdouble hue, saturation, value; - gdouble f, p, q, t; - - if (*s == 0.0) - { - *h = *v; - *s = *v; - *v = *v; /* heh */ - } - else - { - hue = *h * 6.0; - saturation = *s; - value = *v; - - if (hue >= 6.0) - hue = 0.0; - - f = hue - (int) hue; - p = value * (1.0 - saturation); - q = value * (1.0 - saturation * f); - t = value * (1.0 - saturation * (1.0 - f)); - - switch ((int) hue) - { - case 0: - *h = value; - *s = t; - *v = p; - break; - - case 1: - *h = q; - *s = value; - *v = p; - break; - - case 2: - *h = p; - *s = value; - *v = t; - break; - - case 3: - *h = p; - *s = q; - *v = value; - break; - - case 4: - *h = t; - *s = p; - *v = value; - break; - - case 5: - *h = value; - *s = p; - *v = q; - break; - - default: - g_assert_not_reached (); - } - } -} - -static void -hue_to_color (gdouble hue, - GdkColor *color) -{ - gdouble h, s, v; - - h = hue; - s = 1.0; - v = 1.0; - - g_return_if_fail (hue <= 1.0); - - hsv_to_rgb (&h, &s, &v); - - color->red = h * 65535; - color->green = s * 65535; - color->blue = v * 65535; -} - - -static gint -color_cycle_timeout (gpointer data) -{ - Buffer *buffer = data; - - buffer_cycle_colors (buffer); - - return TRUE; -} - -static void -buffer_set_colors (Buffer *buffer, - gboolean enabled) -{ - GSList *tmp; - gdouble hue = 0.0; - - if (enabled && buffer->color_cycle_timeout == 0) - buffer->color_cycle_timeout = gdk_threads_add_timeout (200, color_cycle_timeout, buffer); - else if (!enabled && buffer->color_cycle_timeout != 0) - { - g_source_remove (buffer->color_cycle_timeout); - buffer->color_cycle_timeout = 0; - } - - tmp = buffer->color_tags; - while (tmp != NULL) - { - if (enabled) - { - GdkColor color; - - hue_to_color (hue, &color); - - g_object_set (tmp->data, - "foreground_gdk", &color, - NULL); - } - else - g_object_set (tmp->data, - "foreground_set", FALSE, - NULL); - - hue += 1.0 / N_COLORS; - - tmp = g_slist_next (tmp); - } -} - -static void -buffer_cycle_colors (Buffer *buffer) -{ - GSList *tmp; - gdouble hue = buffer->start_hue; - - tmp = buffer->color_tags; - while (tmp != NULL) - { - GdkColor color; - - hue_to_color (hue, &color); - - g_object_set (tmp->data, - "foreground_gdk", &color, - NULL); - - hue += 1.0 / N_COLORS; - if (hue > 1.0) - hue = 0.0; - - tmp = g_slist_next (tmp); - } - - buffer->start_hue += 1.0 / N_COLORS; - if (buffer->start_hue > 1.0) - buffer->start_hue = 0.0; -} - -static void -close_view (View *view) -{ - views = g_slist_remove (views, view); - buffer_unref (view->buffer); - gtk_widget_destroy (view->window); - g_object_unref (view->item_factory); - - g_free (view); - - if (!views) - gtk_main_quit (); -} - -static void -check_close_view (View *view) -{ - if (view->buffer->refcount > 1 || - check_buffer_saved (view->buffer)) - close_view (view); -} - -static void -view_set_title (View *view) -{ - char *pretty_name = buffer_pretty_name (view->buffer); - char *title = g_strconcat ("testtext - ", pretty_name, NULL); - - gtk_window_set_title (GTK_WINDOW (view->window), title); - - g_free (pretty_name); - g_free (title); -} - -static void -cursor_set_callback (GtkTextBuffer *buffer, - const GtkTextIter *location, - GtkTextMark *mark, - gpointer user_data) -{ - GtkTextView *text_view; - - /* Redraw tab windows if the cursor moves - * on the mapped widget (windows may not exist before realization... - */ - - text_view = GTK_TEXT_VIEW (user_data); - - if (gtk_widget_get_mapped (GTK_WIDGET (text_view)) && - mark == gtk_text_buffer_get_insert (buffer)) - { - GdkWindow *tab_window; - - tab_window = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_TOP); - - gdk_window_invalidate_rect (tab_window, NULL, FALSE); - - tab_window = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_BOTTOM); - - gdk_window_invalidate_rect (tab_window, NULL, FALSE); - } -} - -static gint -tab_stops_expose (GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data) -{ - gint first_x; - gint last_x; - gint i; - GdkWindow *top_win; - GdkWindow *bottom_win; - GtkTextView *text_view; - GtkTextWindowType type; - GdkDrawable *target; - gint *positions = NULL; - gint size; - GtkTextAttributes *attrs; - GtkTextIter insert; - GtkTextBuffer *buffer; - gboolean in_pixels; - - text_view = GTK_TEXT_VIEW (widget); - - /* See if this expose is on the tab stop window */ - top_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_TOP); - - bottom_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_BOTTOM); - - if (event->window == top_win) - { - type = GTK_TEXT_WINDOW_TOP; - target = top_win; - } - else if (event->window == bottom_win) - { - type = GTK_TEXT_WINDOW_BOTTOM; - target = bottom_win; - } - else - return FALSE; - - first_x = event->area.x; - last_x = first_x + event->area.width; - - gtk_text_view_window_to_buffer_coords (text_view, - type, - first_x, - 0, - &first_x, - NULL); - - gtk_text_view_window_to_buffer_coords (text_view, - type, - last_x, - 0, - &last_x, - NULL); - - buffer = gtk_text_view_get_buffer (text_view); - - gtk_text_buffer_get_iter_at_mark (buffer, - &insert, - gtk_text_buffer_get_mark (buffer, - "insert")); - - attrs = gtk_text_attributes_new (); - - gtk_text_iter_get_attributes (&insert, attrs); - - if (attrs->tabs) - { - size = pango_tab_array_get_size (attrs->tabs); - - pango_tab_array_get_tabs (attrs->tabs, - NULL, - &positions); - - in_pixels = pango_tab_array_get_positions_in_pixels (attrs->tabs); - } - else - { - size = 0; - in_pixels = FALSE; - } - - gtk_text_attributes_unref (attrs); - - i = 0; - while (i < size) - { - gint pos; - - if (!in_pixels) - positions[i] = PANGO_PIXELS (positions[i]); - - gtk_text_view_buffer_to_window_coords (text_view, - type, - positions[i], - 0, - &pos, - NULL); - - gdk_draw_line (target, - widget->style->fg_gc [widget->state], - pos, 0, - pos, 15); - - ++i; - } - - g_free (positions); - - return TRUE; -} - -static void -get_lines (GtkTextView *text_view, - gint first_y, - gint last_y, - GArray *buffer_coords, - GArray *numbers, - gint *countp) -{ - GtkTextIter iter; - gint count; - gint size; - - g_array_set_size (buffer_coords, 0); - g_array_set_size (numbers, 0); - - /* Get iter at first y */ - gtk_text_view_get_line_at_y (text_view, &iter, first_y, NULL); - - /* For each iter, get its location and add it to the arrays. - * Stop when we pass last_y - */ - count = 0; - size = 0; - - while (!gtk_text_iter_is_end (&iter)) - { - gint y, height; - gint line_num; - - gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); - - g_array_append_val (buffer_coords, y); - line_num = gtk_text_iter_get_line (&iter); - g_array_append_val (numbers, line_num); - - ++count; - - if ((y + height) >= last_y) - break; - - gtk_text_iter_forward_line (&iter); - } - - *countp = count; -} - -static gint -line_numbers_expose (GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data) -{ - gint count; - GArray *numbers; - GArray *pixels; - gint first_y; - gint last_y; - gint i; - GdkWindow *left_win; - GdkWindow *right_win; - PangoLayout *layout; - GtkTextView *text_view; - GtkTextWindowType type; - GdkDrawable *target; - - text_view = GTK_TEXT_VIEW (widget); - - /* See if this expose is on the line numbers window */ - left_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_LEFT); - - right_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_RIGHT); - - if (event->window == left_win) - { - type = GTK_TEXT_WINDOW_LEFT; - target = left_win; - } - else if (event->window == right_win) - { - type = GTK_TEXT_WINDOW_RIGHT; - target = right_win; - } - else - return FALSE; - - first_y = event->area.y; - last_y = first_y + event->area.height; - - gtk_text_view_window_to_buffer_coords (text_view, - type, - 0, - first_y, - NULL, - &first_y); - - gtk_text_view_window_to_buffer_coords (text_view, - type, - 0, - last_y, - NULL, - &last_y); - - numbers = g_array_new (FALSE, FALSE, sizeof (gint)); - pixels = g_array_new (FALSE, FALSE, sizeof (gint)); - - get_lines (text_view, - first_y, - last_y, - pixels, - numbers, - &count); - - /* Draw fully internationalized numbers! */ - - layout = gtk_widget_create_pango_layout (widget, ""); - - i = 0; - while (i < count) - { - gint pos; - gchar *str; - - gtk_text_view_buffer_to_window_coords (text_view, - type, - 0, - g_array_index (pixels, gint, i), - NULL, - &pos); - - str = g_strdup_printf ("%d", g_array_index (numbers, gint, i)); - - pango_layout_set_text (layout, str, -1); - - gtk_paint_layout (widget->style, - target, - gtk_widget_get_state (widget), - FALSE, - NULL, - widget, - NULL, - 2, pos + 2, - layout); - - g_free (str); - - ++i; - } - - g_array_free (pixels, TRUE); - g_array_free (numbers, TRUE); - - g_object_unref (layout); - - /* don't stop emission, need to draw children */ - return FALSE; -} - -static void -selection_changed (GtkTextBuffer *buffer, - GParamSpec *pspec, - GtkWidget *copy_menu) -{ - gtk_widget_set_sensitive (copy_menu, gtk_text_buffer_get_has_selection (buffer)); -} - -static View * -create_view (Buffer *buffer) -{ - View *view; - GtkWidget *copy_menu; - GtkWidget *sw; - GtkWidget *vbox; - - view = g_new0 (View, 1); - views = g_slist_prepend (views, view); - - view->buffer = buffer; - buffer_ref (buffer); - - view->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_object_set_data (G_OBJECT (view->window), "view", view); - - g_signal_connect (view->window, "delete_event", - G_CALLBACK (delete_event_cb), NULL); - - view->accel_group = gtk_accel_group_new (); - view->item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "
", view->accel_group); - g_object_set_data (G_OBJECT (view->item_factory), "view", view); - - gtk_item_factory_create_items (view->item_factory, G_N_ELEMENTS (menu_items), menu_items, view); - - /* make the Copy menu item sensitivity update according to the selection */ - copy_menu = gtk_item_factory_get_item (view->item_factory, "
/Edit/Copy"); - gtk_widget_set_sensitive (copy_menu, gtk_text_buffer_get_has_selection (view->buffer->buffer)); - g_signal_connect (view->buffer->buffer, - "notify::has-selection", - G_CALLBACK (selection_changed), - copy_menu); - - gtk_window_add_accel_group (GTK_WINDOW (view->window), view->accel_group); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (view->window), vbox); - - gtk_box_pack_start (GTK_BOX (vbox), - gtk_item_factory_get_widget (view->item_factory, "
"), - FALSE, FALSE, 0); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - view->text_view = gtk_text_view_new_with_buffer (buffer->buffer); - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view->text_view), - GTK_WRAP_WORD); - - /* Make sure border width works, no real reason to do this other than testing */ - gtk_container_set_border_width (GTK_CONTAINER (view->text_view), - 10); - - /* Draw tab stops in the top and bottom windows. */ - - gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_TOP, - 15); - - gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_BOTTOM, - 15); - - g_signal_connect (view->text_view, - "expose_event", - G_CALLBACK (tab_stops_expose), - NULL); - - g_signal_connect (view->buffer->buffer, - "mark_set", - G_CALLBACK (cursor_set_callback), - view->text_view); - - /* Draw line numbers in the side windows; we should really be - * more scientific about what width we set them to. - */ - gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_RIGHT, - 30); - - gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (view->text_view), - GTK_TEXT_WINDOW_LEFT, - 30); - - g_signal_connect (view->text_view, - "expose_event", - G_CALLBACK (line_numbers_expose), - NULL); - - gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (sw), view->text_view); - - gtk_window_set_default_size (GTK_WINDOW (view->window), 500, 500); - - gtk_widget_grab_focus (view->text_view); - - view_set_title (view); - view_init_menus (view); - - view_add_example_widgets (view); - - gtk_widget_show_all (view->window); - return view; -} - -static void -view_add_example_widgets (View *view) -{ - GtkTextChildAnchor *anchor; - Buffer *buffer; - - buffer = view->buffer; - - anchor = g_object_get_data (G_OBJECT (buffer->buffer), - "anchor"); - - if (anchor && !gtk_text_child_anchor_get_deleted (anchor)) - { - GtkWidget *widget; - - widget = gtk_button_new_with_label ("Foo"); - - gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (view->text_view), - widget, - anchor); - - gtk_widget_show (widget); - } -} - -void -test_init (void) -{ - if (g_file_test ("../gdk-pixbuf/libpixbufloader-pnm.la", - G_FILE_TEST_EXISTS)) - { - g_setenv ("GDK_PIXBUF_MODULE_FILE", "../gdk-pixbuf/loaders.cache", TRUE); - g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE); - } -} - -int -main (int argc, char** argv) -{ - Buffer *buffer; - View *view; - int i; - - test_init (); - gtk_init (&argc, &argv); - - buffer = create_buffer (); - view = create_view (buffer); - buffer_unref (buffer); - - push_active_window (GTK_WINDOW (view->window)); - for (i=1; i < argc; i++) - { - char *filename; - - /* Quick and dirty canonicalization - better should be in GLib - */ - - if (!g_path_is_absolute (argv[i])) - { - char *cwd = g_get_current_dir (); - filename = g_strconcat (cwd, "/", argv[i], NULL); - g_free (cwd); - } - else - filename = argv[i]; - - open_ok_func (filename, view); - - if (filename != argv[i]) - g_free (filename); - } - pop_active_window (); - - gtk_main (); - - return 0; -} - - From d03c94907aa1e9d72a02ea36497d4d1e130620c8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 14:24:51 +0100 Subject: [PATCH 052/634] docs: Remove overrides for types that don't exist anymore --- docs/reference/gdk/gdk3-overrides.txt | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/docs/reference/gdk/gdk3-overrides.txt b/docs/reference/gdk/gdk3-overrides.txt index bcc85bba84..3ba60be322 100644 --- a/docs/reference/gdk/gdk3-overrides.txt +++ b/docs/reference/gdk/gdk3-overrides.txt @@ -1,27 +1,4 @@ -# GdkPixmap, GdkBitmap and GdkDrawable are the same as GdkWindow. - -GdkWindow -struct GdkPixmap -{ - gpointer user_data; -}; - - -GdkPixmap -struct GdkPixmap -{ - gpointer user_data; -}; - - -GdkDrawable -struct GdkDrawable -{ - gpointer user_data; -}; - - # GdkAtom is an opaque typedef GdkAtom From e3013a5cf52b5f918b823c935eed543743c4a9d8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 14:26:04 +0100 Subject: [PATCH 053/634] docs: Replace mentions of drawable with window in migration guide No need to let gtk3-aware people learn about wonderous gtk2 terms when they are migrating old code. ;) --- docs/reference/gtk/migrating-2to3.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index d150987e11..fc39ff1e24 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -134,7 +134,7 @@ them, are gone. This includes the gdk_draw family of functions like gdk_draw_rectangle() and gdk_draw_drawable(). As #GdkGC is roughly equivalent to #cairo_t and #GdkImage was used for - drawing images to GdkDrawables, which cairo supports automatically, + drawing images to GdkWindows, which cairo supports automatically, a transition is usually straightforward. @@ -143,7 +143,7 @@ was replaced. - Drawing a GdkPixbuf onto a GdkDrawable + Drawing a GdkPixbuf onto a GdkWindow Drawing a pixbuf onto a drawable used to be done like this: - Drawing a tiled GdkPixmap to a GdkDrawable + Drawing a tiled GdkPixmap to a GdkWindow Tiled pixmaps are often used for drawing backgrounds. Old code looked something like this: From 98838df2dbc9e337b71dcbe26efb341e8cfea8a1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 14:36:45 +0100 Subject: [PATCH 054/634] gdk: Make GdkWindow->impl a GdkWindowImpl --- gdk/gdkinternals.h | 3 ++- gdk/gdkwindow.c | 10 +++++----- gdk/x11/gdkwindow-x11.c | 8 ++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 24b09562e7..7da2d83821 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -32,6 +32,7 @@ #include #include #include +#include #include G_BEGIN_DECLS @@ -186,7 +187,7 @@ struct _GdkWindow { GObject parent_instance; - GdkDrawable *impl; /* window-system-specific delegate object */ + GdkWindowImpl *impl; /* window-system-specific delegate object */ GdkWindow *parent; GdkVisual *visual; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index d7061023b4..25dd678f8a 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1473,11 +1473,11 @@ is_parent_of (GdkWindow *parent, static void change_impl (GdkWindow *private, GdkWindow *impl_window, - GdkDrawable *new) + GdkWindowImpl *new) { GList *l; GdkWindow *child; - GdkDrawable *old_impl; + GdkWindowImpl *old_impl; GdkWindow *old_impl_window; old_impl = private->impl; @@ -1777,7 +1777,7 @@ gboolean gdk_window_ensure_native (GdkWindow *window) { GdkWindow *impl_window; - GdkDrawable *new_impl, *old_impl; + GdkWindowImpl *new_impl, *old_impl; GdkScreen *screen; GdkWindow *above; GList listhead; @@ -3398,7 +3398,7 @@ gdk_window_flush_if_exposing (GdkWindow *window) static void gdk_window_flush_recursive_helper (GdkWindow *window, - GdkDrawable *impl) + GdkWindowImpl *impl) { GdkWindow *child; GList *l; @@ -6054,7 +6054,7 @@ move_native_children (GdkWindow *private) static gboolean collect_native_child_region_helper (GdkWindow *window, - GdkDrawable *impl, + GdkWindowImpl *impl, cairo_region_t **region, int x_offset, int y_offset) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 79b1547e96..052b012d47 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -702,7 +702,7 @@ _gdk_window_impl_new (GdkWindow *window, display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen)); impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); - window->impl = (GdkDrawable *)impl; + window->impl = GDK_WINDOW_IMPL (impl); impl->wrapper = GDK_WINDOW (window); xdisplay = screen_x11->xdisplay; @@ -5536,8 +5536,6 @@ gdk_x11_get_server_time (GdkWindow *window) XID gdk_x11_window_get_xid (GdkWindow *window) { - GdkDrawable *impl; - /* Try to ensure the window has a native window */ if (!_gdk_window_has_impl (window)) { @@ -5556,9 +5554,7 @@ gdk_x11_window_get_xid (GdkWindow *window) return None; } - impl = window->impl; - - return ((GdkWindowImplX11 *)impl)->xid; + return GDK_WINDOW_IMPL_X11 (window->impl)->xid; } static void From 3494f87a10ec69521c2e3b4f5073d25385838297 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 14:46:49 +0100 Subject: [PATCH 055/634] API: Remove GdkNoExposeEvent It's not used by anyone and not supported by any backend but X11. --- docs/reference/gdk/gdk3-sections.txt | 1 - gdk/gdkevents.c | 2 -- gdk/gdkevents.h | 22 -------------------- gdk/gdkwindow.c | 1 - gdk/win32/gdkevents-win32.c | 1 - gdk/x11/gdkdisplay-x11.c | 10 ---------- gtk/gtkmain.c | 1 - gtk/gtkwidget.c | 30 ---------------------------- gtk/gtkwidget.h | 2 -- 9 files changed, 70 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 37ea219b00..c14b9669dc 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -861,7 +861,6 @@ GdkNativeWindow GdkEventDND GdkEventProximity GdkEventClient -GdkEventNoExpose GdkEventWindowState GdkEventSetting GdkEventOwnerChange diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index b0b747ea82..272fb32853 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -636,7 +636,6 @@ gdk_event_get_time (const GdkEvent *event) return event->dnd.time; case GDK_CLIENT_EVENT: case GDK_VISIBILITY_NOTIFY: - case GDK_NO_EXPOSE: case GDK_CONFIGURE: case GDK_FOCUS_CHANGE: case GDK_NOTHING: @@ -704,7 +703,6 @@ gdk_event_get_state (const GdkEvent *event, return TRUE; case GDK_VISIBILITY_NOTIFY: case GDK_CLIENT_EVENT: - case GDK_NO_EXPOSE: case GDK_CONFIGURE: case GDK_FOCUS_CHANGE: case GDK_SELECTION_CLEAR: diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index caecd97dad..fcefc6c1c8 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -77,7 +77,6 @@ G_BEGIN_DECLS typedef struct _GdkEventAny GdkEventAny; typedef struct _GdkEventExpose GdkEventExpose; -typedef struct _GdkEventNoExpose GdkEventNoExpose; typedef struct _GdkEventVisibility GdkEventVisibility; typedef struct _GdkEventMotion GdkEventMotion; typedef struct _GdkEventButton GdkEventButton; @@ -205,8 +204,6 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent, * @GDK_DROP_FINISHED: the drop operation initiated by the window has completed. * @GDK_CLIENT_EVENT: a message has been received from another application. * @GDK_VISIBILITY_NOTIFY: the window visibility status has changed. - * @GDK_NO_EXPOSE: indicates that the source region was completely available - * when parts of a drawable were copied. This is not very useful. * @GDK_SCROLL: the scroll wheel was turned * @GDK_WINDOW_STATE: the state of a window has changed. See #GdkWindowState * for the possible window states @@ -258,7 +255,6 @@ typedef enum GDK_DROP_FINISHED = 27, GDK_CLIENT_EVENT = 28, GDK_VISIBILITY_NOTIFY = 29, - GDK_NO_EXPOSE = 30, GDK_SCROLL = 31, GDK_WINDOW_STATE = 32, GDK_SETTING = 33, @@ -465,23 +461,6 @@ struct _GdkEventExpose gint count; /* If non-zero, how many more events follow. */ }; -/** - * GdkEventNoExpose: - * @type: the type of the event (%GDK_NO_EXPOSE). - * @window: the window which received the event. - * @send_event: %TRUE if the event was sent explicitly (e.g. using - * XSendEvent). - * - * Generated when the area of a #GdkDrawable being copied was completely - * available. - */ -struct _GdkEventNoExpose -{ - GdkEventType type; - GdkWindow *window; - gint8 send_event; -}; - /** * GdkEventVisibility: * @type: the type of the event (%GDK_VISIBILITY_NOTIFY). @@ -1064,7 +1043,6 @@ union _GdkEvent GdkEventType type; GdkEventAny any; GdkEventExpose expose; - GdkEventNoExpose no_expose; GdkEventVisibility visibility; GdkEventMotion motion; GdkEventButton button; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 25dd678f8a..20632c7fa5 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -8323,7 +8323,6 @@ _gdk_make_event (GdkWindow *window, case GDK_UNMAP: case GDK_CLIENT_EVENT: case GDK_VISIBILITY_NOTIFY: - case GDK_NO_EXPOSE: case GDK_DELETE: case GDK_DESTROY: case GDK_EXPOSE: diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index bea28a8b7e..31b1dae33c 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -756,7 +756,6 @@ _gdk_win32_print_event (const GdkEvent *event) CASE (GDK_DROP_FINISHED); CASE (GDK_CLIENT_EVENT); CASE (GDK_VISIBILITY_NOTIFY); - CASE (GDK_NO_EXPOSE); CASE (GDK_SCROLL); CASE (GDK_WINDOW_STATE); CASE (GDK_SETTING); diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index eaa2b5a7a4..bfcc358cce 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -523,16 +523,6 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator, } break; - case NoExpose: - GDK_NOTE (EVENTS, - g_message ("no expose:\t\tdrawable: %ld", - xevent->xnoexpose.drawable)); - - event->no_expose.type = GDK_NO_EXPOSE; - event->no_expose.window = window; - - break; - case VisibilityNotify: #ifdef G_ENABLE_DEBUG if (_gdk_debug_flags & GDK_DEBUG_EVENTS) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 1ba0ae767a..9af7503808 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1667,7 +1667,6 @@ gtk_main_do_event (GdkEvent *event) break; case GDK_PROPERTY_NOTIFY: - case GDK_NO_EXPOSE: case GDK_FOCUS_CHANGE: case GDK_CONFIGURE: case GDK_MAP: diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index aca9989d16..e7312a0980 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -422,7 +422,6 @@ enum { PROXIMITY_IN_EVENT, PROXIMITY_OUT_EVENT, CLIENT_EVENT, - NO_EXPOSE_EVENT, VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT, DAMAGE_EVENT, @@ -865,8 +864,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) /* Accessibility support */ klass->get_accessible = gtk_widget_real_get_accessible; - klass->no_expose_event = NULL; - klass->adjust_size_request = gtk_widget_real_adjust_size_request; klass->adjust_size_allocation = gtk_widget_real_adjust_size_allocation; @@ -2703,30 +2700,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - /** - * GtkWidget::no-expose-event: - * @widget: the object which received the signal - * @event: (type Gdk.EventNoExpose): the #GdkEventNoExpose which triggered - * this signal. - * - * The ::no-expose-event will be emitted when the @widget's window is - * drawn as a copy of another #GdkDrawable which was completely unobscured. - * If the source window was partially obscured #GdkEventExpose events will - * be generated for those areas. - * - * Returns: %TRUE to stop other handlers from being invoked for the event. - * %FALSE to propagate the event further. - */ - widget_signals[NO_EXPOSE_EVENT] = - g_signal_new (I_("no-expose-event"), - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkWidgetClass, no_expose_event), - _gtk_boolean_handled_accumulator, NULL, - _gtk_marshal_BOOLEAN__BOXED, - G_TYPE_BOOLEAN, 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - /** * GtkWidget::window-state-event: * @widget: the object which received the signal @@ -5817,9 +5790,6 @@ gtk_widget_event_internal (GtkWidget *widget, case GDK_PROXIMITY_OUT: signal_num = PROXIMITY_OUT_EVENT; break; - case GDK_NO_EXPOSE: - signal_num = NO_EXPOSE_EVENT; - break; case GDK_CLIENT_EVENT: signal_num = CLIENT_EVENT; break; diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 8a566df12b..034bcade1e 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -320,8 +320,6 @@ struct _GtkWidgetClass GdkEventVisibility *event); gboolean (* client_event) (GtkWidget *widget, GdkEventClient *event); - gboolean (* no_expose_event) (GtkWidget *widget, - GdkEventAny *event); gboolean (* window_state_event) (GtkWidget *widget, GdkEventWindowState *event); gboolean (* damage_event) (GtkWidget *widget, From 4bfa4e0d86b72bd1970be60f423dc80dd3296087 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 15:11:34 +0100 Subject: [PATCH 056/634] gdk: Make GdkWindowImpl inherit from GObject --- gdk/gdkwindowimpl.c | 2 +- gdk/gdkwindowimpl.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdk/gdkwindowimpl.c b/gdk/gdkwindowimpl.c index 681aef8cdc..57aed07552 100644 --- a/gdk/gdkwindowimpl.c +++ b/gdk/gdkwindowimpl.c @@ -31,7 +31,7 @@ #include "gdkinternals.h" -G_DEFINE_TYPE (GdkWindowImpl, gdk_window_impl, GDK_TYPE_DRAWABLE); +G_DEFINE_TYPE (GdkWindowImpl, gdk_window_impl, G_TYPE_OBJECT); static void diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index 17edbcaad4..6f246ffc88 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -43,12 +43,12 @@ typedef struct _GdkWindowImplClass GdkWindowImplClass; struct _GdkWindowImpl { - GdkDrawable parent; + GObject parent; }; struct _GdkWindowImplClass { - GdkDrawableClass parent_class; + GObjectClass parent_class; cairo_surface_t * (* ref_cairo_surface) (GdkWindow *window); From b9fc6a0c0387f42854409be8db826cf1d536079f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 15:31:24 +0100 Subject: [PATCH 057/634] gdk: Remove remaining includes of gdkdrawable.h --- gdk/gdkcairo.c | 1 - gdk/gdkwindow.c | 1 - gdk/gdkwindow.h | 1 - 3 files changed, 3 deletions(-) diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index a82e97f75b..7160207ebf 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -21,7 +21,6 @@ #include "gdkcairo.h" -#include "gdkdrawable.h" #include "gdkinternals.h" #include diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 20632c7fa5..ac46daa677 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -40,7 +40,6 @@ #include "gdkintl.h" #include "gdkscreen.h" #include "gdkdeviceprivate.h" -#include "gdkdrawable.h" #include "gdkmarshalers.h" #include "gdkscreen.h" #include "gdkwindowimpl.h" diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index cf088b328d..55726ffffc 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -31,7 +31,6 @@ #ifndef __GDK_WINDOW_H__ #define __GDK_WINDOW_H__ -#include #include #include From 218eea43785809ce43e894ed1bd94e18757f4efa Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 24 Nov 2010 15:32:41 +0100 Subject: [PATCH 058/634] gdk: Remove GdkDrawable It's unused. --- docs/reference/gdk/gdk-docs.sgml | 1 - docs/reference/gdk/gdk3-sections.txt | 18 ------- docs/reference/gdk/gdk3.types | 1 - gdk/Makefile.am | 2 - gdk/gdk.symbols | 2 - gdk/gdkdraw.c | 52 ------------------- gdk/gdkdrawable.h | 77 ---------------------------- 7 files changed, 153 deletions(-) delete mode 100644 gdk/gdkdraw.c delete mode 100644 gdk/gdkdrawable.h diff --git a/docs/reference/gdk/gdk-docs.sgml b/docs/reference/gdk/gdk-docs.sgml index a4f4d39123..c77b8be902 100644 --- a/docs/reference/gdk/gdk-docs.sgml +++ b/docs/reference/gdk/gdk-docs.sgml @@ -22,7 +22,6 @@ - diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index c14b9669dc..7785d0931d 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -274,24 +274,6 @@ gdk_rgba_to_string GDK_TYPE_RGBA -
-Drawing Primitives -drawing -GdkDrawable -gdk_drawable_get_visible_region - - -GDK_DRAWABLE -GDK_DRAWABLE_GET_CLASS -GDK_TYPE_DRAWABLE -GDK_IS_DRAWABLE -GDK_DRAWABLE_CLASS -GDK_IS_DRAWABLE_CLASS - - -GdkDrawableClass -
-
Visuals visuals diff --git a/docs/reference/gdk/gdk3.types b/docs/reference/gdk/gdk3.types index f5889831f9..fccac99ebe 100644 --- a/docs/reference/gdk/gdk3.types +++ b/docs/reference/gdk/gdk3.types @@ -3,7 +3,6 @@ gdk_display_get_type gdk_display_manager_get_type gdk_screen_get_type -gdk_drawable_get_type gdk_window_object_get_type gdk_keymap_get_type gdk_device_get_type diff --git a/gdk/Makefile.am b/gdk/Makefile.am index 2b2ae6be27..987379bc9c 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -71,7 +71,6 @@ gdk_public_h_sources = \ gdkdisplay.h \ gdkdisplaymanager.h \ gdkdnd.h \ - gdkdrawable.h \ gdkevents.h \ gdkinput.h \ gdkkeys.h \ @@ -113,7 +112,6 @@ gdk_c_sources = \ gdkdisplay.c \ gdkdisplaymanager.c \ gdkdnd.c \ - gdkdraw.c \ gdkevents.c \ gdkglobals.c \ gdkkeys.c \ diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index d6dacd0384..11501857fa 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -154,8 +154,6 @@ gdk_drag_get_selection gdk_drag_motion gdk_drag_protocol_get_type G_GNUC_CONST gdk_drag_status -gdk_drawable_get_type G_GNUC_CONST -gdk_drawable_get_visible_region gdk_drop_finish gdk_drop_reply gdk_enable_multidevice diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c deleted file mode 100644 index 56a4215047..0000000000 --- a/gdk/gdkdraw.c +++ /dev/null @@ -1,52 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkdrawable.h" - -#include "gdkcairo.h" -#include "gdkinternals.h" -#include "gdkwindow.h" -#include "gdkscreen.h" -#include "gdkpixbuf.h" - -#include -#include -#include - -G_DEFINE_ABSTRACT_TYPE (GdkDrawable, gdk_drawable, G_TYPE_OBJECT) - -static void -gdk_drawable_class_init (GdkDrawableClass *klass) -{ -} - -static void -gdk_drawable_init (GdkDrawable *drawable) -{ -} - diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h deleted file mode 100644 index c8d8146968..0000000000 --- a/gdk/gdkdrawable.h +++ /dev/null @@ -1,77 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GDK_DRAWABLE_H__ -#define __GDK_DRAWABLE_H__ - -#include -#include - -#include - -G_BEGIN_DECLS - -typedef struct _GdkDrawable GdkDrawable; -typedef struct _GdkDrawableClass GdkDrawableClass; - -#define GDK_TYPE_DRAWABLE (gdk_drawable_get_type ()) -#define GDK_DRAWABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE, GdkDrawable)) -#define GDK_DRAWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE, GdkDrawableClass)) -#define GDK_IS_DRAWABLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE)) -#define GDK_IS_DRAWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE)) -#define GDK_DRAWABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE, GdkDrawableClass)) - -/** - * GdkDrawable: - * - * An opaque structure representing an object that can be - * drawn onto. - */ -struct _GdkDrawable -{ - GObject parent_instance; -}; - -struct _GdkDrawableClass -{ - GObjectClass parent_class; - - /* Padding for future expansion */ - void (*_gdk_reserved7) (void); - void (*_gdk_reserved9) (void); - void (*_gdk_reserved10) (void); - void (*_gdk_reserved11) (void); - void (*_gdk_reserved12) (void); - void (*_gdk_reserved13) (void); - void (*_gdk_reserved14) (void); - void (*_gdk_reserved15) (void); -}; - -GType gdk_drawable_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __GDK_DRAWABLE_H__ */ From 1269f8424f935a34d38106527ffce3e2cc8e35d0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 25 Nov 2010 12:17:11 +0100 Subject: [PATCH 059/634] gdk: Make get_shape and get_input_shape vfuncs Trying to get rid of all the _gdk_windowing_something() functions that we expect backends to magically know about and instead put them in a proper interface (mostly GdkWindowImplClass). --- gdk/gdkinternals.h | 2 -- gdk/gdkwindow.c | 4 ++-- gdk/gdkwindowimpl.h | 2 ++ gdk/quartz/gdkwindow-quartz.c | 10 ++++++---- gdk/win32/gdkwindow-win32.c | 10 ++++++---- gdk/x11/gdkwindow-x11.c | 10 ++++++---- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 7da2d83821..830e5d7a03 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -356,8 +356,6 @@ gulong _gdk_windowing_window_get_next_serial (GdkDisplay *display); void _gdk_windowing_window_get_offsets (GdkWindow *window, gint *x_offset, gint *y_offset); -cairo_region_t *_gdk_windowing_window_get_shape (GdkWindow *window); -cairo_region_t *_gdk_windowing_window_get_input_shape(GdkWindow *window); void _gdk_windowing_window_beep (GdkWindow *window); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index ac46daa677..9e84e2a280 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -718,7 +718,7 @@ remove_child_area (GdkWindow *private, } else if (private->window_type == GDK_WINDOW_FOREIGN) { - shape = _gdk_windowing_window_get_shape ((GdkWindow *)child); + shape = GDK_WINDOW_IMPL_GET_CLASS (child)->get_shape (child); if (shape) { cairo_region_intersect (child_region, shape); @@ -732,7 +732,7 @@ remove_child_area (GdkWindow *private, cairo_region_intersect (child_region, child->input_shape); else if (private->window_type == GDK_WINDOW_FOREIGN) { - shape = _gdk_windowing_window_get_input_shape ((GdkWindow *)child); + shape = GDK_WINDOW_IMPL_GET_CLASS (child)->get_input_shape (child); if (shape) { cairo_region_intersect (child_region, shape); diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index 6f246ffc88..dfcf3b4dc7 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -104,6 +104,8 @@ struct _GdkWindowImplClass gint *y, GdkModifierType *mask); + cairo_region_t * (* get_shape) (GdkWindow *window); + cairo_region_t * (* get_input_shape) (GdkWindow *window); void (* shape_combine_region) (GdkWindow *window, const cairo_region_t *shape_region, gint offset_x, diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 4efe872fad..42117ac557 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -2954,15 +2954,15 @@ _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited) { } -cairo_region_t * -_gdk_windowing_window_get_shape (GdkWindow *window) +static cairo_region_t * +gdk_quartz_window_get_shape (GdkWindow *window) { /* FIXME: implement */ return NULL; } -cairo_region_t * -_gdk_windowing_window_get_input_shape (GdkWindow *window) +static cairo_region_t * +gdk_quartz_window_get_input_shape (GdkWindow *window) { /* FIXME: implement */ return NULL; @@ -2993,6 +2993,8 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface) iface->translate = _gdk_quartz_window_translate; iface->destroy = _gdk_quartz_window_destroy; iface->resize_cairo_surface = gdk_window_quartz_resize_cairo_surface; + iface->get_shape = gdk_quartz_window_get_shape; + iface->get_input_shape = gdk_quartz_window_get_input_shape; } diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 8b73ac2edb..ad291b24f4 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -3170,8 +3170,8 @@ _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited) { } -cairo_region_t * -_gdk_windowing_window_get_shape (GdkWindow *window) +static cairo_region_t * +gdk_win32_window_get_shape (GdkWindow *window) { HRGN hrgn = CreateRectRgn (0, 0, 0, 0); int type = GetWindowRgn (GDK_WINDOW_HWND (window), hrgn); @@ -3187,8 +3187,8 @@ _gdk_windowing_window_get_shape (GdkWindow *window) return NULL; } -cairo_region_t * -_gdk_windowing_window_get_input_shape (GdkWindow *window) +static cairo_region_t * +_gdk_win32_window_get_input_shape (GdkWindow *window) { /* CHECK: are these really supposed to be the same? */ return _gdk_windowing_window_get_shape (window); @@ -3306,6 +3306,8 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface) iface->translate = _gdk_win32_window_translate; iface->destroy = _gdk_win32_window_destroy; iface->resize_cairo_surface = gdk_win32_window_resize_cairo_surface; + iface->get_shape = gdk_win32_window_get_shape; + iface->get_input_shape = gdk_win32_window_get_input_shape; } gboolean diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 052b012d47..d3c4a8ec2a 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -4570,8 +4570,8 @@ _xwindow_get_shape (Display *xdisplay, } -cairo_region_t * -_gdk_windowing_window_get_shape (GdkWindow *window) +static cairo_region_t * +gdk_x11_window_get_shape (GdkWindow *window) { if (!GDK_WINDOW_DESTROYED (window) && gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))) @@ -4581,8 +4581,8 @@ _gdk_windowing_window_get_shape (GdkWindow *window) return NULL; } -cairo_region_t * -_gdk_windowing_window_get_input_shape (GdkWindow *window) +static cairo_region_t * +gdk_x11_window_get_input_shape (GdkWindow *window) { #if defined(ShapeInput) if (!GDK_WINDOW_DESTROYED (window) && @@ -5589,5 +5589,7 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) impl_class->translate = _gdk_x11_window_translate; impl_class->destroy = _gdk_x11_window_destroy; impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface; + impl_class->get_shape = gdk_x11_window_get_shape; + impl_class->get_input_shape = gdk_x11_window_get_input_shape; } From 4d1604c77de2b97c7759574fb3ca9a400be32403 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 25 Nov 2010 12:28:08 +0100 Subject: [PATCH 060/634] gdk: Move window beeps into GdkWindowImpl One less magic function. Also refactored it to make it easier to implement. It now returns TRUE if it beeped and FALSE if it failed to do so. A default implementation exists that just returns FALSE for all the backends that can't beep windows (read: everything but X11 with XKB - and why on earth do keyboard libs implement beeping?) --- gdk/gdkinternals.h | 1 - gdk/gdkwindow.c | 12 ++++++++---- gdk/gdkwindowimpl.c | 10 +++++++++- gdk/gdkwindowimpl.h | 3 +++ gdk/quartz/gdkwindow-quartz.c | 8 -------- gdk/win32/gdkwindow-win32.c | 6 ------ gdk/x11/gdkwindow-x11.c | 22 ++++++++++++---------- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 830e5d7a03..8aede53cce 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -356,7 +356,6 @@ gulong _gdk_windowing_window_get_next_serial (GdkDisplay *display); void _gdk_windowing_window_get_offsets (GdkWindow *window, gint *x_offset, gint *y_offset); -void _gdk_windowing_window_beep (GdkWindow *window); void _gdk_windowing_get_device_state (GdkDisplay *display, diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 9e84e2a280..36d13f611e 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -8065,10 +8065,14 @@ gdk_window_beep (GdkWindow *window) toplevel = get_event_toplevel (window); display = gdk_window_get_display (window); - if (toplevel && !gdk_window_is_offscreen (toplevel)) - _gdk_windowing_window_beep (toplevel); - else - gdk_display_beep (display); + if (toplevel) + { + if (GDK_WINDOW_IMPL_CLASS (toplevel)->beep (window)) + return; + } + + /* If windows fail to beep, we beep the display. */ + gdk_display_beep (display); } /** diff --git a/gdk/gdkwindowimpl.c b/gdk/gdkwindowimpl.c index 57aed07552..ef81fcffd0 100644 --- a/gdk/gdkwindowimpl.c +++ b/gdk/gdkwindowimpl.c @@ -33,10 +33,18 @@ G_DEFINE_TYPE (GdkWindowImpl, gdk_window_impl, G_TYPE_OBJECT); +static gboolean +gdk_window_impl_beep (GdkWindow *window) +{ + /* FALSE means windows can't beep, so the display will be + * made to beep instead. */ + return FALSE; +} static void -gdk_window_impl_class_init (GdkWindowImplClass *klass) +gdk_window_impl_class_init (GdkWindowImplClass *impl_class) { + impl_class->beep = gdk_window_impl_beep; } static void diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index dfcf3b4dc7..0332a31b71 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -158,6 +158,9 @@ struct _GdkWindowImplClass cairo_surface_t *surface, gint width, gint height); + + /* optional */ + gboolean (* beep) (GdkWindow *window); }; /* Interface Functions */ diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 42117ac557..40b9dbb854 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -2919,14 +2919,6 @@ gdk_window_destroy_notify (GdkWindow *window) check_grab_destroy (window); } -void -_gdk_windowing_window_beep (GdkWindow *window) -{ - g_return_if_fail (GDK_IS_WINDOW (window)); - - gdk_display_beep (_gdk_display); -} - void gdk_window_set_opacity (GdkWindow *window, gdouble opacity) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index ad291b24f4..bcbdca33a1 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -3121,12 +3121,6 @@ gdk_window_configure_finished (GdkWindow *window) g_return_if_fail (GDK_IS_WINDOW (window)); } -void -_gdk_windowing_window_beep (GdkWindow *window) -{ - gdk_display_beep (_gdk_display); -} - void gdk_window_set_opacity (GdkWindow *window, gdouble opacity) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index d3c4a8ec2a..725f77a61b 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -5350,24 +5350,25 @@ gdk_window_configure_finished (GdkWindow *window) #endif } -void -_gdk_windowing_window_beep (GdkWindow *window) +static gboolean +gdk_x11_window_beep (GdkWindow *window) { GdkDisplay *display; - g_return_if_fail (GDK_IS_WINDOW (window)); - display = GDK_WINDOW_DISPLAY (window); #ifdef HAVE_XKB if (GDK_DISPLAY_X11 (display)->use_xkb) - XkbBell (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XID (window), - 0, - None); - else + { + XkbBell (GDK_DISPLAY_XDISPLAY (display), + GDK_WINDOW_XID (window), + 0, + None); + return TRUE; + } #endif - gdk_display_beep (display); + + return FALSE; } /** @@ -5591,5 +5592,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface; impl_class->get_shape = gdk_x11_window_get_shape; impl_class->get_input_shape = gdk_x11_window_get_input_shape; + impl_class->beep = gdk_x11_window_beep; } From 585c4895776f2a51b14eff6f28b9a57e12d2ba29 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 25 Nov 2010 15:04:45 +0100 Subject: [PATCH 061/634] gdk: Remove GDK_PANGO_UNITS_OVERFLOWS() from internal headers It's unused. --- gdk/gdkprivate.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 8e70c98e0a..147d2d13ac 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -42,16 +42,6 @@ void gdk_synthesize_window_state (GdkWindow *window, GdkWindowState unset_flags, GdkWindowState set_flags); -/* Tests whether a pair of x,y may cause overflows when converted to Pango - * units (multiplied by PANGO_SCALE). We don't allow the entire range, leave - * some space for additions afterwards, to be safe... - */ -#define GDK_PANGO_UNITS_OVERFLOWS(x,y) (G_UNLIKELY ( \ - (y) >= PANGO_PIXELS (G_MAXINT-PANGO_SCALE)/2 || \ - (x) >= PANGO_PIXELS (G_MAXINT-PANGO_SCALE)/2 || \ - (y) <=-PANGO_PIXELS (G_MAXINT-PANGO_SCALE)/2 || \ - (x) <=-PANGO_PIXELS (G_MAXINT-PANGO_SCALE)/2)) - G_END_DECLS #endif /* __GDK_PRIVATE_H__ */ From f5be9388408470d2b435d410df73c755f1c53cb9 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 25 Nov 2010 15:33:01 +0100 Subject: [PATCH 062/634] gtk: Don't include private GDK headers Use the function that exists for this purpose instead. --- gtk/gtkmain.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 9af7503808..feb7ee2aa7 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -66,8 +66,6 @@ #include "gtkmenu.h" #include "gdk/gdkkeysyms.h" -#include "gdk/gdkprivate.h" /* for GDK_WINDOW_DESTROYED */ - #ifdef G_OS_WIN32 static HMODULE gtk_dll; @@ -2383,7 +2381,7 @@ gtk_get_event_widget (GdkEvent *event) widget = NULL; if (event && event->any.window && - (event->type == GDK_DESTROY || !GDK_WINDOW_DESTROYED (event->any.window))) + (event->type == GDK_DESTROY || !gdk_window_is_destroyed (event->any.window))) { gdk_window_get_user_data (event->any.window, &widget_ptr); widget = widget_ptr; From 8c6831ab5e2b1d17594cdd954cf2acd7a85de8cf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 25 Nov 2010 15:33:25 +0100 Subject: [PATCH 063/634] gdk: Remove useless macros from gdkprivate.h --- gdk/gdkprivate.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 147d2d13ac..6549b85ad0 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -31,11 +31,6 @@ G_BEGIN_DECLS -#ifndef GDK_COMPILATION -#define GDK_WINDOW_TYPE(d) (gdk_window_get_window_type (GDK_WINDOW (d))) -#define GDK_WINDOW_DESTROYED(d) (gdk_window_is_destroyed (GDK_WINDOW (d))) -#endif - void gdk_window_destroy_notify (GdkWindow *window); void gdk_synthesize_window_state (GdkWindow *window, From a6b407cf4aaa093d70adea2bad032358aa9362f3 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 29 Nov 2010 17:51:59 +0100 Subject: [PATCH 064/634] gtk: Fix typos in comment --- gtk/gtkmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index feb7ee2aa7..ceac861d71 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1656,7 +1656,7 @@ gtk_main_do_event (GdkEvent *event) { /* The app may paint with a previously allocated cairo_t, which will draw directly to the window. We can't catch cairo - drap operatoins to automatically flush the window, thus we + draw operations to automatically flush the window, thus we need to explicitly flush any outstanding moves or double buffering */ gdk_window_flush (event->any.window); From b3e8504111b3f1715e7bc5b7d7d3e017df64875a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 30 Nov 2010 22:55:44 +0100 Subject: [PATCH 065/634] x11: Don't include gdkprivate.h in gdkx.h It's private, mkay? And include it directly where we need it anyway. --- gdk/x11/gdkx.h | 3 ++- gtk/gtksocket-x11.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index bf1f0977fc..5db972c7f2 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -27,7 +27,8 @@ #ifndef __GDK_X_H__ #define __GDK_X_H__ -#include +#include + #include #include diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c index c5f2824f88..963d832b85 100644 --- a/gtk/gtksocket-x11.c +++ b/gtk/gtksocket-x11.c @@ -39,7 +39,8 @@ #include "gtkdnd.h" #include "gtkdebug.h" -#include "x11/gdkx.h" +#include "gdk/x11/gdkx.h" +#include "gdk/gdkprivate.h" #ifdef HAVE_XFIXES #include From f9a9567731efb314b9c9295d14879ebb57ab79f9 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 2 Dec 2010 10:59:37 +0100 Subject: [PATCH 066/634] gdk: Replace direct calls of _gdk_event_func with _gdk_event_emit() For now that function just calls the event func. --- gdk/gdkevents.c | 13 +++-- gdk/gdkinternals.h | 5 +- gdk/gdkwindow.c | 4 +- gdk/quartz/GdkQuartzWindow.c | 10 ++-- gdk/quartz/gdkeventloop-quartz.c | 3 +- gdk/win32/gdkevents-win32.c | 88 +++++++++++++++----------------- gdk/x11/gdkeventsource.c | 3 +- 7 files changed, 62 insertions(+), 64 deletions(-) diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 272fb32853..438beb8a1f 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -59,9 +59,16 @@ struct _GdkIOClosure /* Private variable declarations */ -GdkEventFunc _gdk_event_func = NULL; /* Callback for events */ -gpointer _gdk_event_data = NULL; -GDestroyNotify _gdk_event_notify = NULL; +static GdkEventFunc _gdk_event_func = NULL; /* Callback for events */ +static gpointer _gdk_event_data = NULL; +static GDestroyNotify _gdk_event_notify = NULL; + +void +_gdk_event_emit (GdkEvent *event) +{ + if (_gdk_event_func) + (*_gdk_event_func) (event, _gdk_event_data); +} /********************************************* * Functions for maintaining the event queue * diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 8aede53cce..a0063cdc97 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -268,10 +268,6 @@ struct _GdkWindow #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type) #define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed) -extern GdkEventFunc _gdk_event_func; /* Callback for events */ -extern gpointer _gdk_event_data; -extern GDestroyNotify _gdk_event_notify; - extern GSList *_gdk_displays; extern gchar *_gdk_display_name; extern gint _gdk_screen_number; @@ -281,6 +277,7 @@ extern gboolean _gdk_enable_multidevice; void _gdk_events_queue (GdkDisplay *display); GdkEvent* _gdk_event_unqueue (GdkDisplay *display); +void _gdk_event_emit (GdkEvent *event); GList* _gdk_event_queue_find_first (GdkDisplay *display); void _gdk_event_queue_remove_link (GdkDisplay *display, GList *node); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 36d13f611e..1be8be0581 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -3944,7 +3944,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window, event.expose.region = expose_region; cairo_region_get_extents (expose_region, &event.expose.area); - (*_gdk_event_func) (&event, _gdk_event_data); + _gdk_event_emit (&event); g_object_unref (window); } @@ -3994,7 +3994,7 @@ gdk_window_process_updates_internal (GdkWindow *window) cairo_region_t *update_area = window->update_area; window->update_area = NULL; - if (_gdk_event_func && gdk_window_is_viewable (window)) + if (gdk_window_is_viewable (window)) { cairo_region_t *expose_region; gboolean end_implicit; diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c index cbd54937e3..eb3cce8947 100644 --- a/gdk/quartz/GdkQuartzWindow.c +++ b/gdk/quartz/GdkQuartzWindow.c @@ -478,7 +478,7 @@ update_context_from_dragging_info (id sender) gdk_event_set_device (event, gdk_drag_context_get_device (current_context)); - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); @@ -508,7 +508,7 @@ update_context_from_dragging_info (id sender) gdk_event_set_device (event, gdk_drag_context_get_device (current_context)); - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); @@ -536,7 +536,7 @@ update_context_from_dragging_info (id sender) gdk_event_set_device (event, gdk_drag_context_get_device (current_context)); - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); @@ -563,7 +563,7 @@ update_context_from_dragging_info (id sender) gdk_event_set_device (event, gdk_drag_context_get_device (current_context)); - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); @@ -592,7 +592,7 @@ update_context_from_dragging_info (id sender) gdk_event_set_device (event, gdk_drag_context_get_device (_gdk_quartz_drag_source_context)); - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); diff --git a/gdk/quartz/gdkeventloop-quartz.c b/gdk/quartz/gdkeventloop-quartz.c index f11d4d88e7..71c15b8a95 100644 --- a/gdk/quartz/gdkeventloop-quartz.c +++ b/gdk/quartz/gdkeventloop-quartz.c @@ -670,8 +670,7 @@ gdk_event_dispatch (GSource *source, if (event) { - if (_gdk_event_func) - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); } diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 31b1dae33c..e29df5538f 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3018,54 +3018,51 @@ gdk_event_translate (MSG *msg, /* We need to render to clipboard immediately, don't call * append_event() */ - if (_gdk_event_func) - { - event = gdk_event_new (GDK_SELECTION_REQUEST); - event->selection.window = window; - event->selection.send_event = FALSE; - event->selection.selection = GDK_SELECTION_CLIPBOARD; - event->selection.target = target; - event->selection.property = _gdk_selection; - event->selection.requestor = msg->hwnd; - event->selection.time = msg->time; + event = gdk_event_new (GDK_SELECTION_REQUEST); + event->selection.window = window; + event->selection.send_event = FALSE; + event->selection.selection = GDK_SELECTION_CLIPBOARD; + event->selection.target = target; + event->selection.property = _gdk_selection; + event->selection.requestor = msg->hwnd; + event->selection.time = msg->time; - fixup_event (event); - GDK_NOTE (EVENTS, g_print (" (calling gdk_event_func)")); - GDK_NOTE (EVENTS, _gdk_win32_print_event (event)); - (*_gdk_event_func) (event, _gdk_event_data); - gdk_event_free (event); + fixup_event (event); + GDK_NOTE (EVENTS, g_print (" (calling _gdk_event_emit)")); + GDK_NOTE (EVENTS, _gdk_win32_print_event (event)); + _gdk_event_emit (event); + gdk_event_free (event); - /* Now the clipboard owner should have rendered */ - if (!_delayed_rendering_data) - { - GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)")); - } - else - { - if (msg->wParam == CF_DIB) - { - _delayed_rendering_data = - _gdk_win32_selection_convert_to_dib (_delayed_rendering_data, - target); - if (!_delayed_rendering_data) - { - g_warning ("Cannot convert to DIB from delayed rendered image"); - break; - } - } + /* Now the clipboard owner should have rendered */ + if (!_delayed_rendering_data) + { + GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)")); + } + else + { + if (msg->wParam == CF_DIB) + { + _delayed_rendering_data = + _gdk_win32_selection_convert_to_dib (_delayed_rendering_data, + target); + if (!_delayed_rendering_data) + { + g_warning ("Cannot convert to DIB from delayed rendered image"); + break; + } + } - /* The requestor is holding the clipboard, no - * OpenClipboard() is required/possible - */ - GDK_NOTE (DND, - g_print (" SetClipboardData(%s,%p)", - _gdk_win32_cf_to_string (msg->wParam), - _delayed_rendering_data)); + /* The requestor is holding the clipboard, no + * OpenClipboard() is required/possible + */ + GDK_NOTE (DND, + g_print (" SetClipboardData(%s,%p)", + _gdk_win32_cf_to_string (msg->wParam), + _delayed_rendering_data)); - API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data)); - _delayed_rendering_data = NULL; - } - } + API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data)); + _delayed_rendering_data = NULL; + } break; case WM_ACTIVATE: @@ -3222,8 +3219,7 @@ gdk_event_dispatch (GSource *source, if (event) { - if (_gdk_event_func) - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index 5a597526c7..5f0c3a79e6 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -318,8 +318,7 @@ gdk_event_source_dispatch (GSource *source, if (event) { - if (_gdk_event_func) - (*_gdk_event_func) (event, _gdk_event_data); + _gdk_event_emit (event); gdk_event_free (event); } From 0b6c184eaae9b5f78084d76b16b4d4286f2eaab7 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 2 Dec 2010 11:34:41 +0100 Subject: [PATCH 067/634] label: Clarify docs for gtk_label_get_layout() --- gtk/gtklabel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 39655b8518..63b9cd0464 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -5509,8 +5509,9 @@ gtk_label_get_selection_bounds (GtkLabel *label, * Gets the #PangoLayout used to display the label. * The layout is useful to e.g. convert text positions to * pixel positions, in combination with gtk_label_get_layout_offsets(). - * The returned layout is owned by the label so need not be - * freed by the caller. + * The returned layout is owned by the @label so need not be + * freed by the caller. The @label is free to recreate its layout at + * any time, so it should be considered read-only. * * Return value: (transfer none): the #PangoLayout for this label **/ From fdb242ac6ae660cddcde779b8a1fe656cbb12805 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 2 Dec 2010 12:06:49 +0100 Subject: [PATCH 068/634] gdk: Clean up Cairo code Remove a bunch of code that is not required. --- gdk/gdkwindow.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 1be8be0581..7b89ab7350 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -3693,15 +3693,7 @@ gdk_cairo_create (GdkWindow *window) if (!window->paint_stack) { - cairo_reset_clip (cr); - - cairo_save (cr); - cairo_identity_matrix (cr); - - cairo_new_path (cr); gdk_cairo_region (cr, window->clip_region_with_children); - - cairo_restore (cr); cairo_clip (cr); } else @@ -3710,16 +3702,9 @@ gdk_cairo_create (GdkWindow *window) /* Only needs to clip to region if piggybacking on an implicit paint */ - cairo_reset_clip (cr); if (paint->uses_implicit) { - cairo_save (cr); - cairo_identity_matrix (cr); - - cairo_new_path (cr); gdk_cairo_region (cr, paint->region); - cairo_restore (cr); - cairo_clip (cr); } } From f5c27476a5225b6c8b005531d7055b0bc534af49 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 2 Dec 2010 15:58:57 -0500 Subject: [PATCH 069/634] Don't require a display for the color test Its not really needed, and the build bot doesn't have X... --- gdk/tests/gdk-color.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gdk/tests/gdk-color.c b/gdk/tests/gdk-color.c index 008f425e28..3c3955a3cc 100644 --- a/gdk/tests/gdk-color.c +++ b/gdk/tests/gdk-color.c @@ -94,7 +94,6 @@ int main (int argc, char *argv[]) { g_test_init (&argc, &argv, NULL); - gdk_init (&argc, &argv); g_test_add_func ("/color/parse", test_color_parse); g_test_add_func ("/color/to-string", test_color_to_string); From b1beaa2dea249a80c04d38a6e375fd85f830ee70 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 2 Dec 2010 21:01:05 +0000 Subject: [PATCH 070/634] docs: Fix building with latest GDK changes --- docs/reference/gdk/gdk3-sections.txt | 2 +- docs/reference/gdk/gdk3.types | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 7785d0931d..32bf9cf636 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -506,7 +506,7 @@ GDK_TYPE_WM_DECORATION GDK_TYPE_WM_FUNCTION -gdk_window_object_get_type +gdk_window_get_type gdk_drawable_get_type GdkWindowObject GdkWindowObjectClass diff --git a/docs/reference/gdk/gdk3.types b/docs/reference/gdk/gdk3.types index fccac99ebe..bb8607d4f8 100644 --- a/docs/reference/gdk/gdk3.types +++ b/docs/reference/gdk/gdk3.types @@ -3,7 +3,7 @@ gdk_display_get_type gdk_display_manager_get_type gdk_screen_get_type -gdk_window_object_get_type +gdk_window_get_type gdk_keymap_get_type gdk_device_get_type gdk_device_manager_get_type From e4cbe47a11e99e1084d09b5638026f6001432221 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 2 Dec 2010 23:01:12 +0100 Subject: [PATCH 071/634] gtk: properly indent calls to gdk_threads_add_timeout() --- gtk/gtkrange.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 27e8a7424e..3345e88a32 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -2956,7 +2956,9 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment, gtk_widget_queue_draw (GTK_WIDGET (range)); /* setup a timer to ensure the range isn't lagging too much behind the scroll position */ if (!priv->repaint_id) - priv->repaint_id = gdk_threads_add_timeout_full (GDK_PRIORITY_EVENTS, 181, force_repaint, range, NULL); + priv->repaint_id = gdk_threads_add_timeout_full (GDK_PRIORITY_EVENTS, + 181, force_repaint, + range, NULL); } /* Note that we don't round off to priv->round_digits here. @@ -4076,8 +4078,8 @@ initial_timeout (gpointer data) g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL); priv->timer->timeout_id = gdk_threads_add_timeout (timeout * SCROLL_DELAY_FACTOR, - second_timeout, - range); + second_timeout, + range); /* remove self */ return FALSE; } @@ -4099,8 +4101,8 @@ gtk_range_add_step_timer (GtkRange *range, priv->timer = g_new (GtkRangeStepTimer, 1); priv->timer->timeout_id = gdk_threads_add_timeout (timeout, - initial_timeout, - range); + initial_timeout, + range); priv->timer->step = step; gtk_range_scroll (range, priv->timer->step); @@ -4143,8 +4145,8 @@ gtk_range_reset_update_timer (GtkRange *range) gtk_range_remove_update_timer (range); priv->update_timeout_id = gdk_threads_add_timeout (UPDATE_DELAY, - update_timeout, - range); + update_timeout, + range); } static void From 4ef86fc500119ce4ab71cdf942b58d58df9d96b1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 08:21:48 -0500 Subject: [PATCH 072/634] Add annotation to gdk_screen_get_monitor_geometry Pointed out by William Jon McCann. --- gdk/x11/gdkscreen-x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 90d35dc5d8..5927378839 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -450,7 +450,7 @@ gdk_x11_screen_get_monitor_output (GdkScreen *screen, * gdk_screen_get_monitor_geometry: * @screen: a #GdkScreen * @monitor_num: the monitor number, between 0 and gdk_screen_get_n_monitors (screen) - * @dest: a #GdkRectangle to be filled with the monitor geometry + * @dest: (out) (allow-none): a #GdkRectangle to be filled with the monitor geometry * * Retrieves the #GdkRectangle representing the size and position of * the individual monitor within the entire screen area. From 17e2c5391cdf70f956383d518f0c63a98c425ca1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 08:50:05 -0500 Subject: [PATCH 073/634] Fix up parameter mismatches in the docs And other minor gdk doc fixes. --- docs/reference/gdk/gdk3-sections.txt | 14 ++++++++++---- gdk/gdkcairo.c | 11 ++++++++++- gdk/gdkwindow.c | 2 +- gdk/x11/gdkkeys-x11.c | 5 ++--- gdk/x11/gdkx.h | 2 ++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 32bf9cf636..7b58029f18 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -257,6 +257,8 @@ gdk_color_to_string GDK_TYPE_COLOR + +gdk_color_get_type
@@ -272,6 +274,9 @@ gdk_rgba_to_string GDK_TYPE_RGBA + + +gdk_rgba_get_type
@@ -312,6 +317,7 @@ GDK_VISUAL_GET_CLASS GdkVisualClass +GdkVisualPrivate gdk_visual_get_type
@@ -382,6 +388,7 @@ gdk_window_get_clip_region gdk_window_begin_paint_rect gdk_window_begin_paint_region gdk_window_end_paint +gdk_window_get_visible_region gdk_window_invalidate_rect @@ -511,7 +518,7 @@ gdk_drawable_get_type GdkWindowObject GdkWindowObjectClass GdkWindowImpl -GdkWindowImplIface +GdkWindowImplClass GdkWindowRedirect gdk_window_impl_get_type gdk_window_freeze_toplevel_updates_libgtk_only @@ -714,6 +721,7 @@ gdk_device_get_device_type gdk_device_get_display gdk_device_get_has_cursor gdk_device_get_n_axes +gdk_device_get_n_keys gdk_device_grab @@ -946,11 +954,8 @@ gdk_drag_context_get_type X Window System Interaction x_interaction GDK_ROOT_WINDOW -GDK_WINDOW_XDISPLAY GDK_WINDOW_XID GDK_DISPLAY_XDISPLAY -GDK_DRAWABLE_XDISPLAY -GDK_DRAWABLE_XID GDK_SCREEN_XDISPLAY GDK_SCREEN_XNUMBER GDK_SCREEN_XSCREEN @@ -977,6 +982,7 @@ gdk_x11_cursor_get_xcursor gdk_x11_cursor_get_xdisplay gdk_x11_display_broadcast_startup_message gdk_x11_display_get_startup_notification_id +gdk_x11_display_set_startup_notification_id gdk_x11_display_get_xdisplay gdk_x11_display_grab gdk_x11_display_ungrab diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 7160207ebf..0d4b8bde09 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -84,7 +84,7 @@ gdk_cairo_get_clip_rectangle (cairo_t *cr, * gdk_cairo_set_source_color: * @cr: a #cairo_t * @color: a #GdkColor - * + * * Sets the specified #GdkColor as the source color of @cr. * * Since: 2.8 @@ -102,6 +102,15 @@ gdk_cairo_set_source_color (cairo_t *cr, color->blue / 65535.); } +/** + * gdk_cairo_set_source_rgba: + * @cr: a #cairo_t + * @rgba: a #GdkRGBA + * + * Sets the specified #GdkRGBA as the source color of @cr. + * + * Since: 3.0 + **/ void gdk_cairo_set_source_rgba (cairo_t *cr, const GdkRGBA *rgba) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 7b89ab7350..104ea41a7b 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -3666,7 +3666,7 @@ _gdk_window_ref_cairo_surface (GdkWindow *window) /** * gdk_cairo_create: - * @drawable: a #GdkWindow + * @window: a #GdkWindow * * Creates a Cairo context for drawing to @window. * diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 20bb6ee4ef..1de8400fb3 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -1609,14 +1609,13 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap, /* Key handling not part of the keymap */ /** * gdk_keyval_name: + * @keyval: a key value. * * Converts a key value into a symbolic name. - * The names are the same as those in the + * The names are the same as those in the * <gdk/gdkkeysyms.h> header file * but without the leading "GDK_KEY_". * - * @keyval: a key value. - * * Return value: (transfer none): a string containing the name of the key, or * %NULL if @keyval is not a valid key. The string should not be modified. **/ diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 5db972c7f2..51aae0dad1 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -106,6 +106,8 @@ gint gdk_x11_get_default_screen (void); * @display: a #GdkDisplay. * * Returns the display of a #GdkDisplay. + * + * Returns: an Xlib Display* */ #define GDK_DISPLAY_XDISPLAY(display) (GDK_DISPLAY_X11(display)->xdisplay) From 3d81af670dd3497c768731d17687ca305824eb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20=C5=BDnidar=C5=A1i=C4=8D?= Date: Fri, 3 Dec 2010 18:10:08 +0100 Subject: [PATCH 074/634] Updated Slovenian translation --- po/sl.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/sl.po b/po/sl.po index 061aed40ee..4a15b81251 100644 --- a/po/sl.po +++ b/po/sl.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: gtk+ master\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gtk%2b&component=general\n" "POT-Creation-Date: 2010-10-12 17:16+0000\n" -"PO-Revision-Date: 2010-11-29 09:32+0100\n" +"PO-Revision-Date: 2010-12-01 12:38+0100\n" "Last-Translator: Andrej Žnidaršič \n" "Language-Team: Slovenian GNOME Translation Team \n" "Language: \n" @@ -388,7 +388,7 @@ msgstr "Prevedli" #: ../gtk/gtkaboutdialog.c:2201 msgid "Artwork by" -msgstr "Grafična podobo oblikovali" +msgstr "Grafično podobo oblikovali" #. This is the text that should appear next to menu accelerators #. * that use the shift key. If the text on this key isn't typically From 5687d7f8808290138c2cbdf001d132cb9cf88751 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 13:04:42 -0500 Subject: [PATCH 075/634] Update gdk symbol list --- gdk/gdk.symbols | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 11501857fa..62871f0ac8 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -22,7 +22,6 @@ gdk_cairo_get_clip_rectangle gdk_cairo_rectangle gdk_cairo_region gdk_cairo_region_create_from_surface -gdk_cairo_reset_clip gdk_cairo_set_source_color gdk_cairo_set_source_pixbuf gdk_cairo_set_source_rgba @@ -438,9 +437,11 @@ gdk_window_get_screen gdk_window_get_state gdk_window_get_support_multidevice gdk_window_get_toplevel +gdk_window_get_type gdk_window_get_type_hint gdk_window_get_update_area gdk_window_get_user_data +gdk_window_get_visible_region gdk_window_get_visual gdk_window_get_width gdk_window_get_window_type From a996a309c767bd30175a1ed5a5f3777d0f54cddc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 13:05:23 -0500 Subject: [PATCH 076/634] One more forgotten symbol --- gdk/gdk.symbols | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 62871f0ac8..68df3da06f 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -437,7 +437,7 @@ gdk_window_get_screen gdk_window_get_state gdk_window_get_support_multidevice gdk_window_get_toplevel -gdk_window_get_type +gdk_window_get_type G_GNUC_CONST gdk_window_get_type_hint gdk_window_get_update_area gdk_window_get_user_data @@ -470,7 +470,6 @@ gdk_window_move gdk_window_move_region gdk_window_move_resize gdk_window_new -gdk_window_object_get_type G_GNUC_CONST gdk_window_peek_children gdk_window_process_all_updates gdk_window_process_updates From d916398dd2bc05bbdf50939b2583ea2e3a3cec97 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 3 Dec 2010 16:10:46 +0100 Subject: [PATCH 077/634] API: Rename GdkWindowClass to GdkWindowWindowClass We argued replacing GdkWindowClass with a input_only boolean, but this is not doable in an API-stable way, so I decided against it. --- docs/reference/gdk/gdk3-sections.txt | 2 +- gdk/gdkwindow.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 7b58029f18..e1c5bc5526 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -326,7 +326,7 @@ gdk_visual_get_type windows GdkWindow GdkWindowType -GdkWindowClass +GdkWindowWindowClass GdkWindowHints GdkGeometry GdkGravity diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 55726ffffc..b25b5f9ec7 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -42,7 +42,7 @@ typedef struct _GdkPointerHooks GdkPointerHooks; typedef struct _GdkWindowRedirect GdkWindowRedirect; /** - * GdkWindowClass: + * GdkWindowWindowClass: * @GDK_INPUT_OUTPUT: window for graphics and events * @GDK_INPUT_ONLY: window for events only * @@ -56,7 +56,7 @@ typedef enum { GDK_INPUT_OUTPUT, GDK_INPUT_ONLY -} GdkWindowClass; +} GdkWindowWindowClass; /** * GdkWindowType: @@ -345,7 +345,7 @@ struct _GdkWindowAttr gint x, y; gint width; gint height; - GdkWindowClass wclass; + GdkWindowWindowClass wclass; GdkVisual *visual; GdkWindowType window_type; GdkCursor *cursor; From 350fb1d55c7453ad6e2117b032a4fcaea81ac68f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 3 Dec 2010 16:14:31 +0100 Subject: [PATCH 078/634] API: gdk: Rename GdkWindowObjectClass to GdkWindowClass Be consistent in the naming of objects. --- docs/reference/gdk/gdk3-sections.txt | 2 +- gdk/gdkwindow.c | 14 +++++++------- gdk/gdkwindow.h | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index e1c5bc5526..0f50dc48e2 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -516,7 +516,7 @@ GDK_TYPE_WM_FUNCTION gdk_window_get_type gdk_drawable_get_type GdkWindowObject -GdkWindowObjectClass +GdkWindowClass GdkWindowImpl GdkWindowImplClass GdkWindowRedirect diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 104ea41a7b..630c3a1b66 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -223,7 +223,7 @@ static void gdk_window_drop_cairo_surface (GdkWindow *private); static void gdk_window_free_paint_stack (GdkWindow *window); static void gdk_window_init (GdkWindow *window); -static void gdk_window_class_init (GdkWindowObjectClass *klass); +static void gdk_window_class_init (GdkWindowClass *klass); static void gdk_window_finalize (GObject *object); static void gdk_window_set_property (GObject *object, @@ -284,7 +284,7 @@ gdk_window_get_type (void) if (!object_type) object_type = g_type_register_static_simple (G_TYPE_OBJECT, "GdkWindow", - sizeof (GdkWindowObjectClass), + sizeof (GdkWindowClass), (GClassInitFunc) gdk_window_class_init, sizeof (GdkWindow), (GInstanceInitFunc) gdk_window_init, @@ -362,7 +362,7 @@ create_surface_accumulator (GSignalInvocationHint *ihint, static GQuark quark_pointer_window = 0; static void -gdk_window_class_init (GdkWindowObjectClass *klass) +gdk_window_class_init (GdkWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -412,7 +412,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass) g_signal_new (g_intern_static_string ("pick-embedded-child"), G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowObjectClass, pick_embedded_child), + G_STRUCT_OFFSET (GdkWindowClass, pick_embedded_child), accumulate_get_window, NULL, _gdk_marshal_OBJECT__DOUBLE_DOUBLE, GDK_TYPE_WINDOW, @@ -439,7 +439,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass) g_signal_new (g_intern_static_string ("to-embedder"), G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowObjectClass, to_embedder), + G_STRUCT_OFFSET (GdkWindowClass, to_embedder), NULL, NULL, _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER, G_TYPE_NONE, @@ -468,7 +468,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass) g_signal_new (g_intern_static_string ("from-embedder"), G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowObjectClass, from_embedder), + G_STRUCT_OFFSET (GdkWindowClass, from_embedder), NULL, NULL, _gdk_marshal_VOID__DOUBLE_DOUBLE_POINTER_POINTER, G_TYPE_NONE, @@ -503,7 +503,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass) g_signal_new (g_intern_static_string ("create-surface"), G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkWindowObjectClass, create_surface), + G_STRUCT_OFFSET (GdkWindowClass, create_surface), create_surface_accumulator, NULL, _gdk_marshal_BOXED__INT_INT, CAIRO_GOBJECT_TYPE_SURFACE, diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index b25b5f9ec7..936e69af20 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -475,17 +475,17 @@ struct _GdkPointerHooks }; typedef struct _GdkWindowObject GdkWindowObject; -typedef struct _GdkWindowObjectClass GdkWindowObjectClass; +typedef struct _GdkWindowClass GdkWindowClass; #define GDK_TYPE_WINDOW (gdk_window_get_type ()) #define GDK_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW, GdkWindow)) -#define GDK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW, GdkWindowObjectClass)) +#define GDK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW, GdkWindowClass)) #define GDK_IS_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW)) #define GDK_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW)) -#define GDK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW, GdkWindowObjectClass)) +#define GDK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW, GdkWindowClass)) -struct _GdkWindowObjectClass +struct _GdkWindowClass { GObjectClass parent_class; From d998e7761c4972b26079eaeb14f10996576e5415 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 15:41:37 -0500 Subject: [PATCH 079/634] Update sections --- docs/reference/gdk/gdk3-sections.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 0f50dc48e2..f4b7e32999 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -514,7 +514,7 @@ GDK_TYPE_WM_FUNCTION gdk_window_get_type -gdk_drawable_get_type +gdk_window_window_class_get_type GdkWindowObject GdkWindowClass GdkWindowImpl From 12e5e24c3e647aa18c0de57d812f1c39a5dd514f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Dec 2010 23:50:58 -0500 Subject: [PATCH 080/634] Another attempt to fix the gdk symbol list --- gdk/gdk.symbols | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 68df3da06f..f884f6011f 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -386,7 +386,7 @@ gdk_window_begin_move_drag gdk_window_begin_paint_rect gdk_window_begin_paint_region gdk_window_begin_resize_drag -gdk_window_class_get_type G_GNUC_CONST +gdk_window_class_class_get_type G_GNUC_CONST gdk_window_configure_finished gdk_window_constrain_size gdk_window_coords_from_parent From 0d873a61e53201df57e5ba3990a152a94c043e43 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Sat, 4 Dec 2010 15:28:27 +0200 Subject: [PATCH 081/634] Updated Hebrew translation --- po-properties/he.po | 2252 ++++++++++++++++++++++--------------------- po/he.po | 410 ++++---- 2 files changed, 1354 insertions(+), 1308 deletions(-) diff --git a/po-properties/he.po b/po-properties/he.po index 10c6f6f94f..2bc6dc6ce6 100644 --- a/po-properties/he.po +++ b/po-properties/he.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: gtk+.HEAD.he\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-26 08:24+0200\n" -"PO-Revision-Date: 2010-10-26 08:31+0200\n" +"POT-Creation-Date: 2010-12-04 15:26+0200\n" +"PO-Revision-Date: 2010-12-04 15:27+0200\n" "Last-Translator: Yaron Shahrabani \n" "Language-Team: Hebrew \n" "MIME-Version: 1.0\n" @@ -16,63 +16,63 @@ msgstr "" "Language: he\n" "X-Generator: KBabel 1.0\n" -#: ../gdk/gdkdevice.c:99 +#: ../gdk/gdkdevice.c:113 msgid "Device Display" msgstr "Device Display" -#: ../gdk/gdkdevice.c:100 +#: ../gdk/gdkdevice.c:114 msgid "Display which the device belongs to" msgstr "Display which the device belongs to" -#: ../gdk/gdkdevice.c:114 +#: ../gdk/gdkdevice.c:128 msgid "Device manager" msgstr "Device manager" -#: ../gdk/gdkdevice.c:115 +#: ../gdk/gdkdevice.c:129 msgid "Device manager which the device belongs to" msgstr "Device manager which the device belongs to" -#: ../gdk/gdkdevice.c:129 ../gdk/gdkdevice.c:130 +#: ../gdk/gdkdevice.c:143 ../gdk/gdkdevice.c:144 msgid "Device name" msgstr "Device name" -#: ../gdk/gdkdevice.c:144 +#: ../gdk/gdkdevice.c:158 msgid "Device type" msgstr "Device type" -#: ../gdk/gdkdevice.c:145 +#: ../gdk/gdkdevice.c:159 msgid "Device role in the device manager" msgstr "Device role in the device manager" -#: ../gdk/gdkdevice.c:161 +#: ../gdk/gdkdevice.c:175 msgid "Associated device" msgstr "Associated device" -#: ../gdk/gdkdevice.c:162 +#: ../gdk/gdkdevice.c:176 msgid "Associated pointer or keyboard with this device" msgstr "Associated pointer or keyboard with this device" -#: ../gdk/gdkdevice.c:175 +#: ../gdk/gdkdevice.c:189 msgid "Input source" msgstr "Input source" -#: ../gdk/gdkdevice.c:176 +#: ../gdk/gdkdevice.c:190 msgid "Source type for the device" msgstr "Source type for the device" -#: ../gdk/gdkdevice.c:191 ../gdk/gdkdevice.c:192 +#: ../gdk/gdkdevice.c:205 ../gdk/gdkdevice.c:206 msgid "Input mode for the device" msgstr "Input mode for the device" -#: ../gdk/gdkdevice.c:207 +#: ../gdk/gdkdevice.c:221 msgid "Whether the device has a cursor" msgstr "Whether the device has a cursor" -#: ../gdk/gdkdevice.c:208 +#: ../gdk/gdkdevice.c:222 msgid "Whether there is a visible cursor following device motion" msgstr "Whether there is a visible cursor following device motion" -#: ../gdk/gdkdevice.c:222 ../gdk/gdkdevice.c:223 +#: ../gdk/gdkdevice.c:236 ../gdk/gdkdevice.c:237 msgid "Number of axes in the device" msgstr "Number of axes in the device" @@ -84,31 +84,31 @@ msgstr "Display" msgid "Display for the device manager" msgstr "Display for the device manager" -#: ../gdk/gdkdisplaymanager.c:101 +#: ../gdk/gdkdisplaymanager.c:106 msgid "Default Display" msgstr "Default Display" -#: ../gdk/gdkdisplaymanager.c:102 +#: ../gdk/gdkdisplaymanager.c:107 msgid "The default display for GDK" msgstr "The default display for GDK" -#: ../gdk/gdkscreen.c:74 +#: ../gdk/gdkscreen.c:90 msgid "Font options" msgstr "Font options" -#: ../gdk/gdkscreen.c:75 +#: ../gdk/gdkscreen.c:91 msgid "The default font options for the screen" msgstr "The default font options for the screen" -#: ../gdk/gdkscreen.c:82 +#: ../gdk/gdkscreen.c:98 msgid "Font resolution" msgstr "Font resolution" -#: ../gdk/gdkscreen.c:83 +#: ../gdk/gdkscreen.c:99 msgid "The resolution for fonts on the screen" msgstr "The resolution for fonts on the screen" -#: ../gdk/gdkwindow.c:410 ../gdk/gdkwindow.c:411 +#: ../gdk/gdkwindow.c:393 ../gdk/gdkwindow.c:394 msgid "Cursor" msgstr "Cursor" @@ -280,9 +280,9 @@ msgstr "Name" msgid "A unique name for the action." msgstr "A unique name for the action." -#: ../gtk/gtkaction.c:241 ../gtk/gtkbutton.c:238 ../gtk/gtkexpander.c:209 -#: ../gtk/gtkframe.c:130 ../gtk/gtklabel.c:549 ../gtk/gtkmenuitem.c:331 -#: ../gtk/gtktoolbutton.c:202 ../gtk/gtktoolitemgroup.c:1571 +#: ../gtk/gtkaction.c:241 ../gtk/gtkbutton.c:226 ../gtk/gtkexpander.c:209 +#: ../gtk/gtkframe.c:130 ../gtk/gtklabel.c:567 ../gtk/gtkmenuitem.c:331 +#: ../gtk/gtktoolbutton.c:202 ../gtk/gtktoolitemgroup.c:1588 msgid "Label" msgstr "Label" @@ -319,26 +319,26 @@ msgid "GIcon" msgstr "GIcon" #: ../gtk/gtkaction.c:305 ../gtk/gtkcellrendererpixbuf.c:215 -#: ../gtk/gtkimage.c:320 ../gtk/gtkstatusicon.c:253 +#: ../gtk/gtkimage.c:326 ../gtk/gtkstatusicon.c:253 msgid "The GIcon being displayed" msgstr "The GIcon being displayed" #: ../gtk/gtkaction.c:325 ../gtk/gtkcellrendererpixbuf.c:180 -#: ../gtk/gtkimage.c:302 ../gtk/gtkprinter.c:174 ../gtk/gtkstatusicon.c:236 +#: ../gtk/gtkimage.c:308 ../gtk/gtkprinter.c:174 ../gtk/gtkstatusicon.c:236 #: ../gtk/gtkwindow.c:733 msgid "Icon Name" msgstr "Icon Name" #: ../gtk/gtkaction.c:326 ../gtk/gtkcellrendererpixbuf.c:181 -#: ../gtk/gtkimage.c:303 ../gtk/gtkstatusicon.c:237 +#: ../gtk/gtkimage.c:309 ../gtk/gtkstatusicon.c:237 msgid "The name of the icon from the icon theme" msgstr "The name of the icon from the icon theme" -#: ../gtk/gtkaction.c:333 ../gtk/gtktoolitem.c:186 +#: ../gtk/gtkaction.c:333 ../gtk/gtktoolitem.c:195 msgid "Visible when horizontal" msgstr "Visible when horizontal" -#: ../gtk/gtkaction.c:334 ../gtk/gtktoolitem.c:187 +#: ../gtk/gtkaction.c:334 ../gtk/gtktoolitem.c:196 msgid "" "Whether the toolbar item is visible when the toolbar is in a horizontal " "orientation." @@ -358,11 +358,11 @@ msgstr "" "When TRUE, toolitem proxies for this action are represented in the toolbar " "overflow menu." -#: ../gtk/gtkaction.c:357 ../gtk/gtktoolitem.c:193 +#: ../gtk/gtkaction.c:357 ../gtk/gtktoolitem.c:202 msgid "Visible when vertical" msgstr "Visible when vertical" -#: ../gtk/gtkaction.c:358 ../gtk/gtktoolitem.c:194 +#: ../gtk/gtkaction.c:358 ../gtk/gtktoolitem.c:203 msgid "" "Whether the toolbar item is visible when the toolbar is in a vertical " "orientation." @@ -370,7 +370,7 @@ msgstr "" "Whether the toolbar item is visible when the toolbar is in a vertical " "orientation." -#: ../gtk/gtkaction.c:365 ../gtk/gtktoolitem.c:200 +#: ../gtk/gtkaction.c:365 ../gtk/gtktoolitem.c:209 msgid "Is important" msgstr "Is important" @@ -391,7 +391,7 @@ msgid "When TRUE, empty menu proxies for this action are hidden." msgstr "When TRUE, empty menu proxies for this action are hidden." #: ../gtk/gtkaction.c:381 ../gtk/gtkactiongroup.c:235 -#: ../gtk/gtkcellrenderer.c:243 ../gtk/gtkwidget.c:975 +#: ../gtk/gtkcellrenderer.c:282 ../gtk/gtkwidget.c:913 msgid "Sensitive" msgstr "Sensitive" @@ -401,7 +401,7 @@ msgstr "Whether the action is enabled." #: ../gtk/gtkaction.c:388 ../gtk/gtkactiongroup.c:242 #: ../gtk/gtkstatusicon.c:287 ../gtk/gtktreeviewcolumn.c:213 -#: ../gtk/gtkwidget.c:968 +#: ../gtk/gtkwidget.c:906 msgid "Visible" msgstr "Visible" @@ -421,11 +421,11 @@ msgstr "" "The GtkActionGroup this GtkAction is associated with, or NULL (for internal " "use)." -#: ../gtk/gtkaction.c:414 ../gtk/gtkimagemenuitem.c:172 +#: ../gtk/gtkaction.c:414 ../gtk/gtkimagemenuitem.c:182 msgid "Always show image" msgstr "Always show image" -#: ../gtk/gtkaction.c:415 ../gtk/gtkimagemenuitem.c:173 +#: ../gtk/gtkaction.c:415 ../gtk/gtkimagemenuitem.c:183 msgid "Whether the image will always be shown" msgstr "Whether the image will always be shown" @@ -458,7 +458,7 @@ msgid "Whether to use the related actions appearance properties" msgstr "Whether to use the related actions appearance properties" #: ../gtk/gtkadjustment.c:114 ../gtk/gtkcellrendererprogress.c:126 -#: ../gtk/gtkscalebutton.c:220 ../gtk/gtkspinbutton.c:289 +#: ../gtk/gtkscalebutton.c:220 ../gtk/gtkspinbutton.c:291 msgid "Value" msgstr "Value" @@ -510,7 +510,7 @@ msgstr "The page size of the adjustment" msgid "Horizontal alignment" msgstr "Horizontal alignment" -#: ../gtk/gtkalignment.c:128 ../gtk/gtkbutton.c:289 +#: ../gtk/gtkalignment.c:128 ../gtk/gtkbutton.c:277 msgid "" "Horizontal position of child in available space. 0.0 is left aligned, 1.0 is " "right aligned" @@ -522,7 +522,7 @@ msgstr "" msgid "Vertical alignment" msgstr "Vertical alignment" -#: ../gtk/gtkalignment.c:138 ../gtk/gtkbutton.c:308 +#: ../gtk/gtkalignment.c:138 ../gtk/gtkbutton.c:296 msgid "" "Vertical position of child in available space. 0.0 is top aligned, 1.0 is " "bottom aligned" @@ -602,7 +602,7 @@ msgstr "Arrow shadow" msgid "Appearance of the shadow surrounding the arrow" msgstr "Appearance of the shadow surrounding the arrow" -#: ../gtk/gtkarrow.c:127 ../gtk/gtkmenu.c:730 ../gtk/gtkmenuitem.c:394 +#: ../gtk/gtkarrow.c:127 ../gtk/gtkmenu.c:731 ../gtk/gtkmenuitem.c:394 msgid "Arrow Scaling" msgstr "Arrow Scaling" @@ -610,7 +610,7 @@ msgstr "Arrow Scaling" msgid "Amount of space used up by arrow" msgstr "Amount of space used up by arrow" -#: ../gtk/gtkaspectframe.c:109 ../gtk/gtkwidget.c:1171 +#: ../gtk/gtkaspectframe.c:109 ../gtk/gtkwidget.c:1109 msgid "Horizontal Alignment" msgstr "Horizontal Alignment" @@ -618,7 +618,7 @@ msgstr "Horizontal Alignment" msgid "X alignment of the child" msgstr "X alignment of the child" -#: ../gtk/gtkaspectframe.c:116 ../gtk/gtkwidget.c:1187 +#: ../gtk/gtkaspectframe.c:116 ../gtk/gtkwidget.c:1125 msgid "Vertical Alignment" msgstr "Vertical Alignment" @@ -642,99 +642,99 @@ msgstr "Obey child" msgid "Force aspect ratio to match that of the frame's child" msgstr "Force aspect ratio to match that of the frame's child" -#: ../gtk/gtkassistant.c:310 +#: ../gtk/gtkassistant.c:327 msgid "Header Padding" msgstr "Header Padding" -#: ../gtk/gtkassistant.c:311 +#: ../gtk/gtkassistant.c:328 msgid "Number of pixels around the header." msgstr "Number of pixels around the header." -#: ../gtk/gtkassistant.c:318 +#: ../gtk/gtkassistant.c:335 msgid "Content Padding" msgstr "Content Padding" -#: ../gtk/gtkassistant.c:319 +#: ../gtk/gtkassistant.c:336 msgid "Number of pixels around the content pages." msgstr "Number of pixels around the content pages." -#: ../gtk/gtkassistant.c:335 +#: ../gtk/gtkassistant.c:352 msgid "Page type" msgstr "Page type" -#: ../gtk/gtkassistant.c:336 +#: ../gtk/gtkassistant.c:353 msgid "The type of the assistant page" msgstr "The type of the assistant page" -#: ../gtk/gtkassistant.c:353 +#: ../gtk/gtkassistant.c:370 msgid "Page title" msgstr "Page title" -#: ../gtk/gtkassistant.c:354 +#: ../gtk/gtkassistant.c:371 msgid "The title of the assistant page" msgstr "The title of the assistant page" -#: ../gtk/gtkassistant.c:370 +#: ../gtk/gtkassistant.c:387 msgid "Header image" msgstr "Header image" -#: ../gtk/gtkassistant.c:371 +#: ../gtk/gtkassistant.c:388 msgid "Header image for the assistant page" msgstr "Header image for the assistant page" -#: ../gtk/gtkassistant.c:387 +#: ../gtk/gtkassistant.c:404 msgid "Sidebar image" msgstr "Sidebar image" -#: ../gtk/gtkassistant.c:388 +#: ../gtk/gtkassistant.c:405 msgid "Sidebar image for the assistant page" msgstr "Sidebar image for the assistant page" -#: ../gtk/gtkassistant.c:403 +#: ../gtk/gtkassistant.c:420 msgid "Page complete" msgstr "Page complete" -#: ../gtk/gtkassistant.c:404 +#: ../gtk/gtkassistant.c:421 msgid "Whether all required fields on the page have been filled out" msgstr "Whether all required fields on the page have been filled out" -#: ../gtk/gtkbbox.c:135 +#: ../gtk/gtkbbox.c:152 msgid "Minimum child width" msgstr "Minimum child width" -#: ../gtk/gtkbbox.c:136 +#: ../gtk/gtkbbox.c:153 msgid "Minimum width of buttons inside the box" msgstr "Minimum width of buttons inside the box" -#: ../gtk/gtkbbox.c:144 +#: ../gtk/gtkbbox.c:161 msgid "Minimum child height" msgstr "Minimum child height" -#: ../gtk/gtkbbox.c:145 +#: ../gtk/gtkbbox.c:162 msgid "Minimum height of buttons inside the box" msgstr "Minimum height of buttons inside the box" -#: ../gtk/gtkbbox.c:153 +#: ../gtk/gtkbbox.c:170 msgid "Child internal width padding" msgstr "Child internal width padding" -#: ../gtk/gtkbbox.c:154 +#: ../gtk/gtkbbox.c:171 msgid "Amount to increase child's size on either side" msgstr "Amount to increase child's size on either side" -#: ../gtk/gtkbbox.c:162 +#: ../gtk/gtkbbox.c:179 msgid "Child internal height padding" msgstr "Child internal height padding" -#: ../gtk/gtkbbox.c:163 +#: ../gtk/gtkbbox.c:180 msgid "Amount to increase child's size on the top and bottom" msgstr "Amount to increase child's size on the top and bottom" -#: ../gtk/gtkbbox.c:171 +#: ../gtk/gtkbbox.c:188 msgid "Layout style" msgstr "Layout style" -#: ../gtk/gtkbbox.c:172 +#: ../gtk/gtkbbox.c:189 msgid "" "How to lay out the buttons in the box. Possible values are: spread, edge, " "start and end" @@ -742,11 +742,11 @@ msgstr "" "How to lay out the buttons in the box. Possible values are: spread, edge, " "start and end" -#: ../gtk/gtkbbox.c:180 +#: ../gtk/gtkbbox.c:197 msgid "Secondary" msgstr "Secondary" -#: ../gtk/gtkbbox.c:181 +#: ../gtk/gtkbbox.c:198 msgid "" "If TRUE, the child appears in a secondary group of children, suitable for, e." "g., help buttons" @@ -754,34 +754,34 @@ msgstr "" "If TRUE, the child appears in a secondary group of children, suitable for, e." "g., help buttons" -#: ../gtk/gtkbox.c:237 ../gtk/gtkexpander.c:233 ../gtk/gtkiconview.c:691 +#: ../gtk/gtkbox.c:241 ../gtk/gtkexpander.c:233 ../gtk/gtkiconview.c:696 #: ../gtk/gtktreeviewcolumn.c:238 msgid "Spacing" msgstr "Spacing" -#: ../gtk/gtkbox.c:238 +#: ../gtk/gtkbox.c:242 msgid "The amount of space between children" msgstr "The amount of space between children" -#: ../gtk/gtkbox.c:247 ../gtk/gtktable.c:188 ../gtk/gtktoolbar.c:547 -#: ../gtk/gtktoolitemgroup.c:1624 +#: ../gtk/gtkbox.c:251 ../gtk/gtktable.c:193 ../gtk/gtktoolbar.c:553 +#: ../gtk/gtktoolitemgroup.c:1641 msgid "Homogeneous" msgstr "Homogeneous" -#: ../gtk/gtkbox.c:248 +#: ../gtk/gtkbox.c:252 msgid "Whether the children should all be the same size" msgstr "Whether the children should all be the same size" -#: ../gtk/gtkbox.c:264 ../gtk/gtktoolbar.c:539 ../gtk/gtktoolitemgroup.c:1631 -#: ../gtk/gtktoolpalette.c:1065 ../gtk/gtktreeviewcolumn.c:294 +#: ../gtk/gtkbox.c:268 ../gtk/gtktoolbar.c:545 ../gtk/gtktoolitemgroup.c:1648 +#: ../gtk/gtktoolpalette.c:1092 ../gtk/gtktreeviewcolumn.c:294 msgid "Expand" msgstr "Expand" -#: ../gtk/gtkbox.c:265 +#: ../gtk/gtkbox.c:269 msgid "Whether the child should receive extra space when the parent grows" msgstr "Whether the child should receive extra space when the parent grows" -#: ../gtk/gtkbox.c:281 ../gtk/gtktoolitemgroup.c:1638 +#: ../gtk/gtkbox.c:281 ../gtk/gtktoolitemgroup.c:1655 msgid "Fill" msgstr "Fill" @@ -805,7 +805,7 @@ msgstr "Extra space to put between the child and its neighbors, in pixels" msgid "Pack type" msgstr "Pack type" -#: ../gtk/gtkbox.c:297 ../gtk/gtknotebook.c:786 +#: ../gtk/gtkbox.c:297 ../gtk/gtknotebook.c:793 msgid "" "A GtkPackType indicating whether the child is packed with reference to the " "start or end of the parent" @@ -813,12 +813,12 @@ msgstr "" "A GtkPackType indicating whether the child is packed with reference to the " "start or end of the parent" -#: ../gtk/gtkbox.c:303 ../gtk/gtknotebook.c:757 ../gtk/gtkpaned.c:271 -#: ../gtk/gtkruler.c:158 ../gtk/gtktoolitemgroup.c:1652 +#: ../gtk/gtkbox.c:303 ../gtk/gtknotebook.c:764 ../gtk/gtkpaned.c:327 +#: ../gtk/gtktoolitemgroup.c:1669 msgid "Position" msgstr "Position" -#: ../gtk/gtkbox.c:304 ../gtk/gtknotebook.c:758 +#: ../gtk/gtkbox.c:304 ../gtk/gtknotebook.c:765 msgid "The index of the child in the parent" msgstr "The index of the child in the parent" @@ -830,7 +830,7 @@ msgstr "Translation Domain" msgid "The translation domain used by gettext" msgstr "The translation domain used by gettext" -#: ../gtk/gtkbutton.c:239 +#: ../gtk/gtkbutton.c:227 msgid "" "Text of the label widget inside the button, if the button contains a label " "widget" @@ -838,12 +838,12 @@ msgstr "" "Text of the label widget inside the button, if the button contains a label " "widget" -#: ../gtk/gtkbutton.c:246 ../gtk/gtkexpander.c:217 ../gtk/gtklabel.c:570 +#: ../gtk/gtkbutton.c:234 ../gtk/gtkexpander.c:217 ../gtk/gtklabel.c:588 #: ../gtk/gtkmenuitem.c:346 ../gtk/gtktoolbutton.c:209 msgid "Use underline" msgstr "Use underline" -#: ../gtk/gtkbutton.c:247 ../gtk/gtkexpander.c:218 ../gtk/gtklabel.c:571 +#: ../gtk/gtkbutton.c:235 ../gtk/gtkexpander.c:218 ../gtk/gtklabel.c:589 #: ../gtk/gtkmenuitem.c:347 msgid "" "If set, an underline in the text indicates the next character should be used " @@ -852,70 +852,70 @@ msgstr "" "If set, an underline in the text indicates the next character should be used " "for the mnemonic accelerator key" -#: ../gtk/gtkbutton.c:254 ../gtk/gtkimagemenuitem.c:153 +#: ../gtk/gtkbutton.c:242 ../gtk/gtkimagemenuitem.c:163 msgid "Use stock" msgstr "Use stock" -#: ../gtk/gtkbutton.c:255 +#: ../gtk/gtkbutton.c:243 msgid "" "If set, the label is used to pick a stock item instead of being displayed" msgstr "" "If set, the label is used to pick a stock item instead of being displayed" -#: ../gtk/gtkbutton.c:262 ../gtk/gtkcombobox.c:861 +#: ../gtk/gtkbutton.c:250 ../gtk/gtkcombobox.c:865 #: ../gtk/gtkfilechooserbutton.c:383 msgid "Focus on click" msgstr "Focus on click" -#: ../gtk/gtkbutton.c:263 ../gtk/gtkfilechooserbutton.c:384 +#: ../gtk/gtkbutton.c:251 ../gtk/gtkfilechooserbutton.c:384 msgid "Whether the button grabs focus when it is clicked with the mouse" msgstr "Whether the button grabs focus when it is clicked with the mouse" -#: ../gtk/gtkbutton.c:270 +#: ../gtk/gtkbutton.c:258 msgid "Border relief" msgstr "Border relief" -#: ../gtk/gtkbutton.c:271 +#: ../gtk/gtkbutton.c:259 msgid "The border relief style" msgstr "The border relief style" -#: ../gtk/gtkbutton.c:288 +#: ../gtk/gtkbutton.c:276 msgid "Horizontal alignment for child" msgstr "Horizontal alignment for child" -#: ../gtk/gtkbutton.c:307 +#: ../gtk/gtkbutton.c:295 msgid "Vertical alignment for child" msgstr "Vertical alignment for child" -#: ../gtk/gtkbutton.c:324 ../gtk/gtkimagemenuitem.c:138 +#: ../gtk/gtkbutton.c:312 ../gtk/gtkimagemenuitem.c:148 msgid "Image widget" msgstr "Image widget" -#: ../gtk/gtkbutton.c:325 +#: ../gtk/gtkbutton.c:313 msgid "Child widget to appear next to the button text" msgstr "Child widget to appear next to the button text" -#: ../gtk/gtkbutton.c:339 +#: ../gtk/gtkbutton.c:327 msgid "Image position" msgstr "Image position" -#: ../gtk/gtkbutton.c:340 +#: ../gtk/gtkbutton.c:328 msgid "The position of the image relative to the text" msgstr "The position of the image relative to the text" -#: ../gtk/gtkbutton.c:460 +#: ../gtk/gtkbutton.c:448 msgid "Default Spacing" msgstr "Default Spacing" -#: ../gtk/gtkbutton.c:461 +#: ../gtk/gtkbutton.c:449 msgid "Extra space to add for GTK_CAN_DEFAULT buttons" msgstr "Extra space to add for GTK_CAN_DEFAULT buttons" -#: ../gtk/gtkbutton.c:475 +#: ../gtk/gtkbutton.c:463 msgid "Default Outside Spacing" msgstr "Default Outside Spacing" -#: ../gtk/gtkbutton.c:476 +#: ../gtk/gtkbutton.c:464 msgid "" "Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside " "the border" @@ -923,31 +923,31 @@ msgstr "" "Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside " "the border" -#: ../gtk/gtkbutton.c:481 +#: ../gtk/gtkbutton.c:469 msgid "Child X Displacement" msgstr "Child X Displacement" -#: ../gtk/gtkbutton.c:482 +#: ../gtk/gtkbutton.c:470 msgid "" "How far in the x direction to move the child when the button is depressed" msgstr "" "How far in the x direction to move the child when the button is depressed" -#: ../gtk/gtkbutton.c:489 +#: ../gtk/gtkbutton.c:477 msgid "Child Y Displacement" msgstr "Child Y Displacement" -#: ../gtk/gtkbutton.c:490 +#: ../gtk/gtkbutton.c:478 msgid "" "How far in the y direction to move the child when the button is depressed" msgstr "" "How far in the y direction to move the child when the button is depressed" -#: ../gtk/gtkbutton.c:506 +#: ../gtk/gtkbutton.c:494 msgid "Displace focus" msgstr "Displace focus" -#: ../gtk/gtkbutton.c:507 +#: ../gtk/gtkbutton.c:495 msgid "" "Whether the child_displacement_x/_y properties should also affect the focus " "rectangle" @@ -955,43 +955,43 @@ msgstr "" "Whether the child_displacement_x/_y properties should also affect the focus " "rectangle" -#: ../gtk/gtkbutton.c:520 ../gtk/gtkentry.c:695 ../gtk/gtkentry.c:1740 +#: ../gtk/gtkbutton.c:508 ../gtk/gtkentry.c:786 ../gtk/gtkentry.c:1831 msgid "Inner Border" msgstr "Inner Border" -#: ../gtk/gtkbutton.c:521 +#: ../gtk/gtkbutton.c:509 msgid "Border between button edges and child." msgstr "Border between button edges and child." -#: ../gtk/gtkbutton.c:534 +#: ../gtk/gtkbutton.c:522 msgid "Image spacing" msgstr "Image spacing" -#: ../gtk/gtkbutton.c:535 +#: ../gtk/gtkbutton.c:523 msgid "Spacing in pixels between the image and label" msgstr "Spacing in pixels between the image and label" -#: ../gtk/gtkcalendar.c:470 +#: ../gtk/gtkcalendar.c:475 msgid "Year" msgstr "Year" -#: ../gtk/gtkcalendar.c:471 +#: ../gtk/gtkcalendar.c:476 msgid "The selected year" msgstr "The selected year" -#: ../gtk/gtkcalendar.c:484 +#: ../gtk/gtkcalendar.c:489 msgid "Month" msgstr "Month" -#: ../gtk/gtkcalendar.c:485 +#: ../gtk/gtkcalendar.c:490 msgid "The selected month (as a number between 0 and 11)" msgstr "The selected month (as a number between 0 and 11)" -#: ../gtk/gtkcalendar.c:499 +#: ../gtk/gtkcalendar.c:504 msgid "Day" msgstr "Day" -#: ../gtk/gtkcalendar.c:500 +#: ../gtk/gtkcalendar.c:505 msgid "" "The selected day (as a number between 1 and 31, or 0 to unselect the " "currently selected day)" @@ -999,83 +999,83 @@ msgstr "" "The selected day (as a number between 1 and 31, or 0 to unselect the " "currently selected day)" -#: ../gtk/gtkcalendar.c:514 +#: ../gtk/gtkcalendar.c:519 msgid "Show Heading" msgstr "Show Heading" -#: ../gtk/gtkcalendar.c:515 +#: ../gtk/gtkcalendar.c:520 msgid "If TRUE, a heading is displayed" msgstr "If TRUE, a heading is displayed" -#: ../gtk/gtkcalendar.c:529 +#: ../gtk/gtkcalendar.c:534 msgid "Show Day Names" msgstr "Show Day Names" -#: ../gtk/gtkcalendar.c:530 +#: ../gtk/gtkcalendar.c:535 msgid "If TRUE, day names are displayed" msgstr "If TRUE, day names are displayed" -#: ../gtk/gtkcalendar.c:543 +#: ../gtk/gtkcalendar.c:548 msgid "No Month Change" msgstr "No Month Change" -#: ../gtk/gtkcalendar.c:544 +#: ../gtk/gtkcalendar.c:549 msgid "If TRUE, the selected month cannot be changed" msgstr "If TRUE, the selected month cannot be changed" -#: ../gtk/gtkcalendar.c:558 +#: ../gtk/gtkcalendar.c:563 msgid "Show Week Numbers" msgstr "Show Week Numbers" -#: ../gtk/gtkcalendar.c:559 +#: ../gtk/gtkcalendar.c:564 msgid "If TRUE, week numbers are displayed" msgstr "If TRUE, week numbers are displayed" -#: ../gtk/gtkcalendar.c:574 +#: ../gtk/gtkcalendar.c:579 msgid "Details Width" msgstr "Details Width" -#: ../gtk/gtkcalendar.c:575 +#: ../gtk/gtkcalendar.c:580 msgid "Details width in characters" msgstr "Details width in characters" -#: ../gtk/gtkcalendar.c:590 +#: ../gtk/gtkcalendar.c:595 msgid "Details Height" msgstr "Details Height" -#: ../gtk/gtkcalendar.c:591 +#: ../gtk/gtkcalendar.c:596 msgid "Details height in rows" msgstr "Details height in rows" -#: ../gtk/gtkcalendar.c:607 +#: ../gtk/gtkcalendar.c:612 msgid "Show Details" msgstr "Show Details" -#: ../gtk/gtkcalendar.c:608 +#: ../gtk/gtkcalendar.c:613 msgid "If TRUE, details are shown" msgstr "If TRUE, details are shown" -#: ../gtk/gtkcalendar.c:620 +#: ../gtk/gtkcalendar.c:625 msgid "Inner border" msgstr "Inner border" -#: ../gtk/gtkcalendar.c:621 +#: ../gtk/gtkcalendar.c:626 msgid "Inner border space" msgstr "Inner border space" -#: ../gtk/gtkcalendar.c:632 +#: ../gtk/gtkcalendar.c:637 msgid "Vertical separation" msgstr "Vertical separation" -#: ../gtk/gtkcalendar.c:633 +#: ../gtk/gtkcalendar.c:638 msgid "Space between day headers and main area" msgstr "Space between day headers and main area" -#: ../gtk/gtkcalendar.c:644 +#: ../gtk/gtkcalendar.c:649 msgid "Horizontal separation" msgstr "Horizontal separation" -#: ../gtk/gtkcalendar.c:645 +#: ../gtk/gtkcalendar.c:650 msgid "Space between week headers and main area" msgstr "Space between week headers and main area" @@ -1119,127 +1119,127 @@ msgstr "Accelerator Mode" msgid "The type of accelerators" msgstr "The type of accelerators" -#: ../gtk/gtkcellrenderer.c:227 +#: ../gtk/gtkcellrenderer.c:266 msgid "mode" msgstr "mode" -#: ../gtk/gtkcellrenderer.c:228 +#: ../gtk/gtkcellrenderer.c:267 msgid "Editable mode of the CellRenderer" msgstr "Editable mode of the CellRenderer" -#: ../gtk/gtkcellrenderer.c:236 +#: ../gtk/gtkcellrenderer.c:275 msgid "visible" msgstr "visible" -#: ../gtk/gtkcellrenderer.c:237 +#: ../gtk/gtkcellrenderer.c:276 msgid "Display the cell" msgstr "Display the cell" -#: ../gtk/gtkcellrenderer.c:244 +#: ../gtk/gtkcellrenderer.c:283 msgid "Display the cell sensitive" msgstr "Display the cell sensitive" -#: ../gtk/gtkcellrenderer.c:251 +#: ../gtk/gtkcellrenderer.c:290 msgid "xalign" msgstr "xalign" -#: ../gtk/gtkcellrenderer.c:252 +#: ../gtk/gtkcellrenderer.c:291 msgid "The x-align" msgstr "The x-align" -#: ../gtk/gtkcellrenderer.c:261 +#: ../gtk/gtkcellrenderer.c:300 msgid "yalign" msgstr "yalign" -#: ../gtk/gtkcellrenderer.c:262 +#: ../gtk/gtkcellrenderer.c:301 msgid "The y-align" msgstr "The y-align" -#: ../gtk/gtkcellrenderer.c:271 +#: ../gtk/gtkcellrenderer.c:310 msgid "xpad" msgstr "xpad" -#: ../gtk/gtkcellrenderer.c:272 +#: ../gtk/gtkcellrenderer.c:311 msgid "The xpad" msgstr "The xpad" -#: ../gtk/gtkcellrenderer.c:281 +#: ../gtk/gtkcellrenderer.c:320 msgid "ypad" msgstr "ypad" -#: ../gtk/gtkcellrenderer.c:282 +#: ../gtk/gtkcellrenderer.c:321 msgid "The ypad" msgstr "The ypad" -#: ../gtk/gtkcellrenderer.c:291 +#: ../gtk/gtkcellrenderer.c:330 msgid "width" msgstr "width" -#: ../gtk/gtkcellrenderer.c:292 +#: ../gtk/gtkcellrenderer.c:331 msgid "The fixed width" msgstr "The fixed width" -#: ../gtk/gtkcellrenderer.c:301 +#: ../gtk/gtkcellrenderer.c:340 msgid "height" msgstr "height" -#: ../gtk/gtkcellrenderer.c:302 +#: ../gtk/gtkcellrenderer.c:341 msgid "The fixed height" msgstr "The fixed height" -#: ../gtk/gtkcellrenderer.c:311 +#: ../gtk/gtkcellrenderer.c:350 msgid "Is Expander" msgstr "Is Expander" -#: ../gtk/gtkcellrenderer.c:312 +#: ../gtk/gtkcellrenderer.c:351 msgid "Row has children" msgstr "Row has children" -#: ../gtk/gtkcellrenderer.c:320 +#: ../gtk/gtkcellrenderer.c:359 msgid "Is Expanded" msgstr "Is Expanded" -#: ../gtk/gtkcellrenderer.c:321 +#: ../gtk/gtkcellrenderer.c:360 msgid "Row is an expander row, and is expanded" msgstr "Row is an expander row, and is expanded" -#: ../gtk/gtkcellrenderer.c:328 +#: ../gtk/gtkcellrenderer.c:367 msgid "Cell background color name" msgstr "Cell background color name" -#: ../gtk/gtkcellrenderer.c:329 +#: ../gtk/gtkcellrenderer.c:368 msgid "Cell background color as a string" msgstr "Cell background color as a string" -#: ../gtk/gtkcellrenderer.c:336 +#: ../gtk/gtkcellrenderer.c:375 msgid "Cell background color" msgstr "Cell background color" -#: ../gtk/gtkcellrenderer.c:337 +#: ../gtk/gtkcellrenderer.c:376 msgid "Cell background color as a GdkColor" msgstr "Cell background color as a GdkColor" -#: ../gtk/gtkcellrenderer.c:350 +#: ../gtk/gtkcellrenderer.c:389 msgid "Cell background RGBA color" msgstr "Cell background RGBA color" -#: ../gtk/gtkcellrenderer.c:351 +#: ../gtk/gtkcellrenderer.c:390 msgid "Cell background color as a GdkRGBA" msgstr "Cell background color as a GdkRGBA" -#: ../gtk/gtkcellrenderer.c:358 +#: ../gtk/gtkcellrenderer.c:397 msgid "Editing" msgstr "Editing" -#: ../gtk/gtkcellrenderer.c:359 +#: ../gtk/gtkcellrenderer.c:398 msgid "Whether the cell renderer is currently in editing mode" msgstr "Whether the cell renderer is currently in editing mode" -#: ../gtk/gtkcellrenderer.c:367 +#: ../gtk/gtkcellrenderer.c:406 msgid "Cell background set" msgstr "Cell background set" -#: ../gtk/gtkcellrenderer.c:368 +#: ../gtk/gtkcellrenderer.c:407 msgid "Whether this tag affects the cell background color" msgstr "Whether this tag affects the cell background color" @@ -1259,7 +1259,7 @@ msgstr "Text Column" msgid "A column in the data source model to get the strings from" msgstr "A column in the data source model to get the strings from" -#: ../gtk/gtkcellrenderercombo.c:150 ../gtk/gtkcombobox.c:928 +#: ../gtk/gtkcellrenderercombo.c:150 ../gtk/gtkcombobox.c:932 msgid "Has Entry" msgstr "Has Entry" @@ -1291,7 +1291,7 @@ msgstr "Pixbuf Expander Closed" msgid "Pixbuf for closed expander" msgstr "Pixbuf for closed expander" -#: ../gtk/gtkcellrendererpixbuf.c:144 ../gtk/gtkimage.c:244 +#: ../gtk/gtkcellrendererpixbuf.c:144 ../gtk/gtkimage.c:250 #: ../gtk/gtkstatusicon.c:228 msgid "Stock ID" msgstr "Stock ID" @@ -1325,7 +1325,7 @@ msgstr "Follow State" msgid "Whether the rendered pixbuf should be colorized according to the state" msgstr "Whether the rendered pixbuf should be colorized according to the state" -#: ../gtk/gtkcellrendererpixbuf.c:214 ../gtk/gtkimage.c:319 +#: ../gtk/gtkcellrendererpixbuf.c:214 ../gtk/gtkimage.c:325 #: ../gtk/gtkwindow.c:710 msgid "Icon" msgstr "Icon" @@ -1334,10 +1334,10 @@ msgstr "Icon" msgid "Value of the progress bar" msgstr "Value of the progress bar" -#: ../gtk/gtkcellrendererprogress.c:144 ../gtk/gtkcellrenderertext.c:233 -#: ../gtk/gtkentry.c:738 ../gtk/gtkentrybuffer.c:352 -#: ../gtk/gtkmessagedialog.c:226 ../gtk/gtkprogressbar.c:145 -#: ../gtk/gtktextbuffer.c:210 +#: ../gtk/gtkcellrendererprogress.c:144 ../gtk/gtkcellrenderertext.c:247 +#: ../gtk/gtkentry.c:829 ../gtk/gtkentrybuffer.c:352 +#: ../gtk/gtkmessagedialog.c:226 ../gtk/gtkprogressbar.c:177 +#: ../gtk/gtktextbuffer.c:209 msgid "Text" msgstr "Text" @@ -1377,21 +1377,21 @@ msgstr "Text y alignment" msgid "The vertical text alignment, from 0 (top) to 1 (bottom)." msgstr "The vertical text alignment, from 0 (top) to 1 (bottom)." -#: ../gtk/gtkcellrendererprogress.c:214 ../gtk/gtkprogressbar.c:121 -#: ../gtk/gtkrange.c:433 +#: ../gtk/gtkcellrendererprogress.c:214 ../gtk/gtkprogressbar.c:153 +#: ../gtk/gtkrange.c:440 msgid "Inverted" msgstr "Inverted" -#: ../gtk/gtkcellrendererprogress.c:215 ../gtk/gtkprogressbar.c:122 +#: ../gtk/gtkcellrendererprogress.c:215 ../gtk/gtkprogressbar.c:154 msgid "Invert the direction in which the progress bar grows" msgstr "Invert the direction in which the progress bar grows" -#: ../gtk/gtkcellrendererspin.c:91 ../gtk/gtkrange.c:425 -#: ../gtk/gtkscalebutton.c:239 ../gtk/gtkspinbutton.c:228 +#: ../gtk/gtkcellrendererspin.c:91 ../gtk/gtkrange.c:432 +#: ../gtk/gtkscalebutton.c:239 ../gtk/gtkspinbutton.c:230 msgid "Adjustment" msgstr "Adjustment" -#: ../gtk/gtkcellrendererspin.c:92 ../gtk/gtkspinbutton.c:229 +#: ../gtk/gtkcellrendererspin.c:92 ../gtk/gtkspinbutton.c:231 msgid "The adjustment that holds the value of the spin button" msgstr "The adjustment that holds the value of the spin button" @@ -1399,22 +1399,23 @@ msgstr "The adjustment that holds the value of the spin button" msgid "Climb rate" msgstr "Climb rate" -#: ../gtk/gtkcellrendererspin.c:108 ../gtk/gtkspinbutton.c:237 +#: ../gtk/gtkcellrendererspin.c:108 ../gtk/gtkspinbutton.c:239 msgid "The acceleration rate when you hold down a button" msgstr "The acceleration rate when you hold down a button" -#: ../gtk/gtkcellrendererspin.c:121 ../gtk/gtkscale.c:244 -#: ../gtk/gtkspinbutton.c:246 +#: ../gtk/gtkcellrendererspin.c:121 ../gtk/gtkscale.c:254 +#: ../gtk/gtkspinbutton.c:248 msgid "Digits" msgstr "Digits" -#: ../gtk/gtkcellrendererspin.c:122 ../gtk/gtkspinbutton.c:247 +#: ../gtk/gtkcellrendererspin.c:122 ../gtk/gtkspinbutton.c:249 msgid "The number of decimal places to display" msgstr "The number of decimal places to display" #: ../gtk/gtkcellrendererspinner.c:119 ../gtk/gtkcheckmenuitem.c:105 -#: ../gtk/gtkmenu.c:520 ../gtk/gtkspinner.c:131 ../gtk/gtktoggleaction.c:133 -#: ../gtk/gtktogglebutton.c:122 ../gtk/gtktoggletoolbutton.c:112 +#: ../gtk/gtkmenu.c:521 ../gtk/gtkspinner.c:131 ../gtk/gtkswitch.c:738 +#: ../gtk/gtktoggleaction.c:133 ../gtk/gtktogglebutton.c:125 +#: ../gtk/gtktoggletoolbutton.c:112 msgid "Active" msgstr "Active" @@ -1430,189 +1431,189 @@ msgstr "Pulse of the spinner" msgid "The GtkIconSize value that specifies the size of the rendered spinner" msgstr "The GtkIconSize value that specifies the size of the rendered spinner" -#: ../gtk/gtkcellrenderertext.c:234 +#: ../gtk/gtkcellrenderertext.c:248 msgid "Text to render" msgstr "Text to render" -#: ../gtk/gtkcellrenderertext.c:241 +#: ../gtk/gtkcellrenderertext.c:255 msgid "Markup" msgstr "Markup" -#: ../gtk/gtkcellrenderertext.c:242 +#: ../gtk/gtkcellrenderertext.c:256 msgid "Marked up text to render" msgstr "Marked up text to render" -#: ../gtk/gtkcellrenderertext.c:249 ../gtk/gtklabel.c:556 +#: ../gtk/gtkcellrenderertext.c:263 ../gtk/gtklabel.c:574 msgid "Attributes" msgstr "Attributes" -#: ../gtk/gtkcellrenderertext.c:250 +#: ../gtk/gtkcellrenderertext.c:264 msgid "A list of style attributes to apply to the text of the renderer" msgstr "A list of style attributes to apply to the text of the renderer" -#: ../gtk/gtkcellrenderertext.c:257 +#: ../gtk/gtkcellrenderertext.c:271 msgid "Single Paragraph Mode" msgstr "Single Paragraph Mode" -#: ../gtk/gtkcellrenderertext.c:258 +#: ../gtk/gtkcellrenderertext.c:272 msgid "Whether to keep all text in a single paragraph" msgstr "Whether to keep all text in a single paragraph" -#: ../gtk/gtkcellrenderertext.c:266 ../gtk/gtkcellview.c:179 +#: ../gtk/gtkcellrenderertext.c:280 ../gtk/gtkcellview.c:192 #: ../gtk/gtktexttag.c:178 msgid "Background color name" msgstr "Background color name" -#: ../gtk/gtkcellrenderertext.c:267 ../gtk/gtkcellview.c:180 +#: ../gtk/gtkcellrenderertext.c:281 ../gtk/gtkcellview.c:193 #: ../gtk/gtktexttag.c:179 msgid "Background color as a string" msgstr "Background color as a string" -#: ../gtk/gtkcellrenderertext.c:274 ../gtk/gtkcellview.c:186 +#: ../gtk/gtkcellrenderertext.c:288 ../gtk/gtkcellview.c:199 #: ../gtk/gtktexttag.c:186 msgid "Background color" msgstr "Background color" -#: ../gtk/gtkcellrenderertext.c:275 ../gtk/gtkcellview.c:187 +#: ../gtk/gtkcellrenderertext.c:289 ../gtk/gtkcellview.c:200 msgid "Background color as a GdkColor" msgstr "Background color as a GdkColor" -#: ../gtk/gtkcellrenderertext.c:289 +#: ../gtk/gtkcellrenderertext.c:303 msgid "Background color as RGBA" msgstr "Background color as RGBA" -#: ../gtk/gtkcellrenderertext.c:290 ../gtk/gtkcellview.c:201 +#: ../gtk/gtkcellrenderertext.c:304 ../gtk/gtkcellview.c:214 msgid "Background color as a GdkRGBA" msgstr "Background color as a GdkRGBA" -#: ../gtk/gtkcellrenderertext.c:296 ../gtk/gtktexttag.c:202 +#: ../gtk/gtkcellrenderertext.c:310 ../gtk/gtktexttag.c:202 msgid "Foreground color name" msgstr "Foreground color name" -#: ../gtk/gtkcellrenderertext.c:297 ../gtk/gtktexttag.c:203 +#: ../gtk/gtkcellrenderertext.c:311 ../gtk/gtktexttag.c:203 msgid "Foreground color as a string" msgstr "Foreground color as a string" -#: ../gtk/gtkcellrenderertext.c:304 ../gtk/gtktexttag.c:210 +#: ../gtk/gtkcellrenderertext.c:318 ../gtk/gtktexttag.c:210 #: ../gtk/gtktrayicon-x11.c:133 msgid "Foreground color" msgstr "Foreground color" -#: ../gtk/gtkcellrenderertext.c:305 +#: ../gtk/gtkcellrenderertext.c:319 msgid "Foreground color as a GdkColor" msgstr "Foreground color as a GdkColor" -#: ../gtk/gtkcellrenderertext.c:319 +#: ../gtk/gtkcellrenderertext.c:333 msgid "Foreground color as RGBA" msgstr "Foreground color as RGBA" -#: ../gtk/gtkcellrenderertext.c:320 +#: ../gtk/gtkcellrenderertext.c:334 msgid "Foreground color as a GdkRGBA" msgstr "Foreground color as a GdkRGBA" -#: ../gtk/gtkcellrenderertext.c:328 ../gtk/gtkentry.c:662 -#: ../gtk/gtktexttag.c:227 ../gtk/gtktextview.c:667 +#: ../gtk/gtkcellrenderertext.c:342 ../gtk/gtkentry.c:753 +#: ../gtk/gtktexttag.c:227 ../gtk/gtktextview.c:686 msgid "Editable" msgstr "Editable" -#: ../gtk/gtkcellrenderertext.c:329 ../gtk/gtktexttag.c:228 -#: ../gtk/gtktextview.c:668 +#: ../gtk/gtkcellrenderertext.c:343 ../gtk/gtktexttag.c:228 +#: ../gtk/gtktextview.c:687 msgid "Whether the text can be modified by the user" msgstr "Whether the text can be modified by the user" -#: ../gtk/gtkcellrenderertext.c:336 ../gtk/gtkcellrenderertext.c:344 +#: ../gtk/gtkcellrenderertext.c:350 ../gtk/gtkcellrenderertext.c:358 #: ../gtk/gtktexttag.c:243 ../gtk/gtktexttag.c:251 msgid "Font" msgstr "Font" -#: ../gtk/gtkcellrenderertext.c:337 ../gtk/gtktexttag.c:244 +#: ../gtk/gtkcellrenderertext.c:351 ../gtk/gtktexttag.c:244 msgid "Font description as a string, e.g. \"Sans Italic 12\"" msgstr "Font description as a string, e.g. \"Sans Italic 12\"" -#: ../gtk/gtkcellrenderertext.c:345 ../gtk/gtktexttag.c:252 +#: ../gtk/gtkcellrenderertext.c:359 ../gtk/gtktexttag.c:252 msgid "Font description as a PangoFontDescription struct" msgstr "Font description as a PangoFontDescription struct" -#: ../gtk/gtkcellrenderertext.c:353 ../gtk/gtktexttag.c:259 +#: ../gtk/gtkcellrenderertext.c:367 ../gtk/gtktexttag.c:259 msgid "Font family" msgstr "Font family" -#: ../gtk/gtkcellrenderertext.c:354 ../gtk/gtktexttag.c:260 +#: ../gtk/gtkcellrenderertext.c:368 ../gtk/gtktexttag.c:260 msgid "Name of the font family, e.g. Sans, Helvetica, Times, Monospace" msgstr "Name of the font family, e.g. Sans, Helvetica, Times, Monospace" -#: ../gtk/gtkcellrenderertext.c:361 ../gtk/gtkcellrenderertext.c:362 +#: ../gtk/gtkcellrenderertext.c:375 ../gtk/gtkcellrenderertext.c:376 #: ../gtk/gtktexttag.c:267 msgid "Font style" msgstr "Font style" -#: ../gtk/gtkcellrenderertext.c:370 ../gtk/gtkcellrenderertext.c:371 +#: ../gtk/gtkcellrenderertext.c:384 ../gtk/gtkcellrenderertext.c:385 #: ../gtk/gtktexttag.c:276 msgid "Font variant" msgstr "Font variant" -#: ../gtk/gtkcellrenderertext.c:379 ../gtk/gtkcellrenderertext.c:380 +#: ../gtk/gtkcellrenderertext.c:393 ../gtk/gtkcellrenderertext.c:394 #: ../gtk/gtktexttag.c:285 msgid "Font weight" msgstr "Font weight" -#: ../gtk/gtkcellrenderertext.c:389 ../gtk/gtkcellrenderertext.c:390 +#: ../gtk/gtkcellrenderertext.c:403 ../gtk/gtkcellrenderertext.c:404 #: ../gtk/gtktexttag.c:296 msgid "Font stretch" msgstr "Font stretch" -#: ../gtk/gtkcellrenderertext.c:398 ../gtk/gtkcellrenderertext.c:399 +#: ../gtk/gtkcellrenderertext.c:412 ../gtk/gtkcellrenderertext.c:413 #: ../gtk/gtktexttag.c:305 msgid "Font size" msgstr "Font size" -#: ../gtk/gtkcellrenderertext.c:408 ../gtk/gtktexttag.c:325 +#: ../gtk/gtkcellrenderertext.c:422 ../gtk/gtktexttag.c:325 msgid "Font points" msgstr "Font points" -#: ../gtk/gtkcellrenderertext.c:409 ../gtk/gtktexttag.c:326 +#: ../gtk/gtkcellrenderertext.c:423 ../gtk/gtktexttag.c:326 msgid "Font size in points" msgstr "Font size in points" -#: ../gtk/gtkcellrenderertext.c:418 ../gtk/gtktexttag.c:315 +#: ../gtk/gtkcellrenderertext.c:432 ../gtk/gtktexttag.c:315 msgid "Font scale" msgstr "Font scale" -#: ../gtk/gtkcellrenderertext.c:419 +#: ../gtk/gtkcellrenderertext.c:433 msgid "Font scaling factor" msgstr "Font scaling factor" -#: ../gtk/gtkcellrenderertext.c:428 ../gtk/gtktexttag.c:394 +#: ../gtk/gtkcellrenderertext.c:442 ../gtk/gtktexttag.c:394 msgid "Rise" msgstr "Rise" -#: ../gtk/gtkcellrenderertext.c:429 +#: ../gtk/gtkcellrenderertext.c:443 msgid "" "Offset of text above the baseline (below the baseline if rise is negative)" msgstr "" "Offset of text above the baseline (below the baseline if rise is negative)" -#: ../gtk/gtkcellrenderertext.c:440 ../gtk/gtktexttag.c:434 +#: ../gtk/gtkcellrenderertext.c:454 ../gtk/gtktexttag.c:434 msgid "Strikethrough" msgstr "Strikethrough" -#: ../gtk/gtkcellrenderertext.c:441 ../gtk/gtktexttag.c:435 +#: ../gtk/gtkcellrenderertext.c:455 ../gtk/gtktexttag.c:435 msgid "Whether to strike through the text" msgstr "Whether to strike through the text" -#: ../gtk/gtkcellrenderertext.c:448 ../gtk/gtktexttag.c:442 +#: ../gtk/gtkcellrenderertext.c:462 ../gtk/gtktexttag.c:442 msgid "Underline" msgstr "Underline" -#: ../gtk/gtkcellrenderertext.c:449 ../gtk/gtktexttag.c:443 +#: ../gtk/gtkcellrenderertext.c:463 ../gtk/gtktexttag.c:443 msgid "Style of underline for this text" msgstr "Style of underline for this text" -#: ../gtk/gtkcellrenderertext.c:457 ../gtk/gtktexttag.c:354 +#: ../gtk/gtkcellrenderertext.c:471 ../gtk/gtktexttag.c:354 msgid "Language" msgstr "Language" -#: ../gtk/gtkcellrenderertext.c:458 +#: ../gtk/gtkcellrenderertext.c:472 msgid "" "The language this text is in, as an ISO code. Pango can use this as a hint " "when rendering the text. If you don't understand this parameter, you " @@ -1622,12 +1623,12 @@ msgstr "" "when rendering the text. If you don't understand this parameter, you " "probably don't need it" -#: ../gtk/gtkcellrenderertext.c:478 ../gtk/gtklabel.c:681 -#: ../gtk/gtkprogressbar.c:175 +#: ../gtk/gtkcellrenderertext.c:492 ../gtk/gtklabel.c:699 +#: ../gtk/gtkprogressbar.c:207 msgid "Ellipsize" msgstr "Ellipsize" -#: ../gtk/gtkcellrenderertext.c:479 +#: ../gtk/gtkcellrenderertext.c:493 msgid "" "The preferred place to ellipsize the string, if the cell renderer does not " "have enough room to display the entire string" @@ -1635,28 +1636,28 @@ msgstr "" "The preferred place to ellipsize the string, if the cell renderer does not " "have enough room to display the entire string" -#: ../gtk/gtkcellrenderertext.c:498 ../gtk/gtkfilechooserbutton.c:411 -#: ../gtk/gtklabel.c:702 +#: ../gtk/gtkcellrenderertext.c:512 ../gtk/gtkfilechooserbutton.c:411 +#: ../gtk/gtklabel.c:720 msgid "Width In Characters" msgstr "Width In Characters" -#: ../gtk/gtkcellrenderertext.c:499 ../gtk/gtklabel.c:703 +#: ../gtk/gtkcellrenderertext.c:513 ../gtk/gtklabel.c:721 msgid "The desired width of the label, in characters" msgstr "The desired width of the label, in characters" -#: ../gtk/gtkcellrenderertext.c:523 ../gtk/gtklabel.c:763 +#: ../gtk/gtkcellrenderertext.c:537 ../gtk/gtklabel.c:781 msgid "Maximum Width In Characters" msgstr "Maximum Width In Characters" -#: ../gtk/gtkcellrenderertext.c:524 +#: ../gtk/gtkcellrenderertext.c:538 msgid "The maximum width of the cell, in characters" msgstr "The maximum width of the cell, in characters" -#: ../gtk/gtkcellrenderertext.c:542 ../gtk/gtktexttag.c:451 +#: ../gtk/gtkcellrenderertext.c:556 ../gtk/gtktexttag.c:451 msgid "Wrap mode" msgstr "Wrap mode" -#: ../gtk/gtkcellrenderertext.c:543 +#: ../gtk/gtkcellrenderertext.c:557 msgid "" "How to break the string into multiple lines, if the cell renderer does not " "have enough room to display the entire string" @@ -1664,149 +1665,149 @@ msgstr "" "How to break the string into multiple lines, if the cell renderer does not " "have enough room to display the entire string" -#: ../gtk/gtkcellrenderertext.c:562 ../gtk/gtkcombobox.c:750 +#: ../gtk/gtkcellrenderertext.c:576 ../gtk/gtkcombobox.c:754 msgid "Wrap width" msgstr "Wrap width" -#: ../gtk/gtkcellrenderertext.c:563 +#: ../gtk/gtkcellrenderertext.c:577 msgid "The width at which the text is wrapped" msgstr "The width at which the text is wrapped" -#: ../gtk/gtkcellrenderertext.c:583 ../gtk/gtktreeviewcolumn.c:319 +#: ../gtk/gtkcellrenderertext.c:597 ../gtk/gtktreeviewcolumn.c:319 msgid "Alignment" msgstr "Alignment" -#: ../gtk/gtkcellrenderertext.c:584 +#: ../gtk/gtkcellrenderertext.c:598 msgid "How to align the lines" msgstr "How to draw the toolbar" -#: ../gtk/gtkcellrenderertext.c:596 ../gtk/gtkcellview.c:223 +#: ../gtk/gtkcellrenderertext.c:610 ../gtk/gtkcellview.c:236 #: ../gtk/gtktexttag.c:540 msgid "Background set" msgstr "Background set" -#: ../gtk/gtkcellrenderertext.c:597 ../gtk/gtkcellview.c:224 +#: ../gtk/gtkcellrenderertext.c:611 ../gtk/gtkcellview.c:237 #: ../gtk/gtktexttag.c:541 msgid "Whether this tag affects the background color" msgstr "Whether this tag affects the background color" -#: ../gtk/gtkcellrenderertext.c:600 ../gtk/gtktexttag.c:548 +#: ../gtk/gtkcellrenderertext.c:614 ../gtk/gtktexttag.c:548 msgid "Foreground set" msgstr "Foreground set" -#: ../gtk/gtkcellrenderertext.c:601 ../gtk/gtktexttag.c:549 +#: ../gtk/gtkcellrenderertext.c:615 ../gtk/gtktexttag.c:549 msgid "Whether this tag affects the foreground color" msgstr "Whether this tag affects the foreground color" -#: ../gtk/gtkcellrenderertext.c:604 ../gtk/gtktexttag.c:552 +#: ../gtk/gtkcellrenderertext.c:618 ../gtk/gtktexttag.c:552 msgid "Editability set" msgstr "Editability set" -#: ../gtk/gtkcellrenderertext.c:605 ../gtk/gtktexttag.c:553 +#: ../gtk/gtkcellrenderertext.c:619 ../gtk/gtktexttag.c:553 msgid "Whether this tag affects text editability" msgstr "Whether this tag affects text editability" -#: ../gtk/gtkcellrenderertext.c:608 ../gtk/gtktexttag.c:556 +#: ../gtk/gtkcellrenderertext.c:622 ../gtk/gtktexttag.c:556 msgid "Font family set" msgstr "Font family set" -#: ../gtk/gtkcellrenderertext.c:609 ../gtk/gtktexttag.c:557 +#: ../gtk/gtkcellrenderertext.c:623 ../gtk/gtktexttag.c:557 msgid "Whether this tag affects the font family" msgstr "Whether this tag affects the font family" -#: ../gtk/gtkcellrenderertext.c:612 ../gtk/gtktexttag.c:560 +#: ../gtk/gtkcellrenderertext.c:626 ../gtk/gtktexttag.c:560 msgid "Font style set" msgstr "Font style set" -#: ../gtk/gtkcellrenderertext.c:613 ../gtk/gtktexttag.c:561 +#: ../gtk/gtkcellrenderertext.c:627 ../gtk/gtktexttag.c:561 msgid "Whether this tag affects the font style" msgstr "Whether this tag affects the font style" -#: ../gtk/gtkcellrenderertext.c:616 ../gtk/gtktexttag.c:564 +#: ../gtk/gtkcellrenderertext.c:630 ../gtk/gtktexttag.c:564 msgid "Font variant set" msgstr "Font variant set" -#: ../gtk/gtkcellrenderertext.c:617 ../gtk/gtktexttag.c:565 +#: ../gtk/gtkcellrenderertext.c:631 ../gtk/gtktexttag.c:565 msgid "Whether this tag affects the font variant" msgstr "Whether this tag affects the font variant" -#: ../gtk/gtkcellrenderertext.c:620 ../gtk/gtktexttag.c:568 +#: ../gtk/gtkcellrenderertext.c:634 ../gtk/gtktexttag.c:568 msgid "Font weight set" msgstr "Font weight set" -#: ../gtk/gtkcellrenderertext.c:621 ../gtk/gtktexttag.c:569 +#: ../gtk/gtkcellrenderertext.c:635 ../gtk/gtktexttag.c:569 msgid "Whether this tag affects the font weight" msgstr "Whether this tag affects the font weight" -#: ../gtk/gtkcellrenderertext.c:624 ../gtk/gtktexttag.c:572 +#: ../gtk/gtkcellrenderertext.c:638 ../gtk/gtktexttag.c:572 msgid "Font stretch set" msgstr "Font stretch set" -#: ../gtk/gtkcellrenderertext.c:625 ../gtk/gtktexttag.c:573 +#: ../gtk/gtkcellrenderertext.c:639 ../gtk/gtktexttag.c:573 msgid "Whether this tag affects the font stretch" msgstr "Whether this tag affects the font stretch" -#: ../gtk/gtkcellrenderertext.c:628 ../gtk/gtktexttag.c:576 +#: ../gtk/gtkcellrenderertext.c:642 ../gtk/gtktexttag.c:576 msgid "Font size set" msgstr "Font size set" -#: ../gtk/gtkcellrenderertext.c:629 ../gtk/gtktexttag.c:577 +#: ../gtk/gtkcellrenderertext.c:643 ../gtk/gtktexttag.c:577 msgid "Whether this tag affects the font size" msgstr "Whether this tag affects the font size" -#: ../gtk/gtkcellrenderertext.c:632 ../gtk/gtktexttag.c:580 +#: ../gtk/gtkcellrenderertext.c:646 ../gtk/gtktexttag.c:580 msgid "Font scale set" msgstr "Font scale set" -#: ../gtk/gtkcellrenderertext.c:633 ../gtk/gtktexttag.c:581 +#: ../gtk/gtkcellrenderertext.c:647 ../gtk/gtktexttag.c:581 msgid "Whether this tag scales the font size by a factor" msgstr "Whether this tag scales the font size by a factor" -#: ../gtk/gtkcellrenderertext.c:636 ../gtk/gtktexttag.c:600 +#: ../gtk/gtkcellrenderertext.c:650 ../gtk/gtktexttag.c:600 msgid "Rise set" msgstr "Rise set" -#: ../gtk/gtkcellrenderertext.c:637 ../gtk/gtktexttag.c:601 +#: ../gtk/gtkcellrenderertext.c:651 ../gtk/gtktexttag.c:601 msgid "Whether this tag affects the rise" msgstr "Whether this tag affects the rise" -#: ../gtk/gtkcellrenderertext.c:640 ../gtk/gtktexttag.c:616 +#: ../gtk/gtkcellrenderertext.c:654 ../gtk/gtktexttag.c:616 msgid "Strikethrough set" msgstr "Strikethrough set" -#: ../gtk/gtkcellrenderertext.c:641 ../gtk/gtktexttag.c:617 +#: ../gtk/gtkcellrenderertext.c:655 ../gtk/gtktexttag.c:617 msgid "Whether this tag affects strikethrough" msgstr "Whether this tag affects strikethrough" -#: ../gtk/gtkcellrenderertext.c:644 ../gtk/gtktexttag.c:624 +#: ../gtk/gtkcellrenderertext.c:658 ../gtk/gtktexttag.c:624 msgid "Underline set" msgstr "Underline set" -#: ../gtk/gtkcellrenderertext.c:645 ../gtk/gtktexttag.c:625 +#: ../gtk/gtkcellrenderertext.c:659 ../gtk/gtktexttag.c:625 msgid "Whether this tag affects underlining" msgstr "Whether this tag affects underlining" -#: ../gtk/gtkcellrenderertext.c:648 ../gtk/gtktexttag.c:588 +#: ../gtk/gtkcellrenderertext.c:662 ../gtk/gtktexttag.c:588 msgid "Language set" msgstr "Language set" -#: ../gtk/gtkcellrenderertext.c:649 ../gtk/gtktexttag.c:589 +#: ../gtk/gtkcellrenderertext.c:663 ../gtk/gtktexttag.c:589 msgid "Whether this tag affects the language the text is rendered as" msgstr "Whether this tag affects the language the text is rendered as" -#: ../gtk/gtkcellrenderertext.c:652 +#: ../gtk/gtkcellrenderertext.c:666 msgid "Ellipsize set" msgstr "Ellipsize set" -#: ../gtk/gtkcellrenderertext.c:653 +#: ../gtk/gtkcellrenderertext.c:667 msgid "Whether this tag affects the ellipsize mode" msgstr "Whether this tag affects the ellipsize mode" -#: ../gtk/gtkcellrenderertext.c:656 +#: ../gtk/gtkcellrenderertext.c:670 msgid "Align set" msgstr "Align set" -#: ../gtk/gtkcellrenderertext.c:657 +#: ../gtk/gtkcellrenderertext.c:671 msgid "Whether this tag affects the alignment mode" msgstr "Whether this tag affects the alignment mode" @@ -1846,32 +1847,32 @@ msgstr "Draw the toggle button as a radio button" msgid "Indicator size" msgstr "Indicator size" -#: ../gtk/gtkcellrenderertoggle.c:161 ../gtk/gtkcheckbutton.c:72 +#: ../gtk/gtkcellrenderertoggle.c:161 ../gtk/gtkcheckbutton.c:78 #: ../gtk/gtkcheckmenuitem.c:129 msgid "Size of check or radio indicator" msgstr "Size of check or radio indicator" -#: ../gtk/gtkcellview.c:200 +#: ../gtk/gtkcellview.c:213 msgid "Background RGBA color" msgstr "Background RGBA color" -#: ../gtk/gtkcellview.c:215 +#: ../gtk/gtkcellview.c:228 msgid "CellView model" msgstr "CellView model" -#: ../gtk/gtkcellview.c:216 +#: ../gtk/gtkcellview.c:229 msgid "The model for cell view" msgstr "The model for cell view" -#: ../gtk/gtkcheckbutton.c:71 ../gtk/gtkcheckmenuitem.c:128 +#: ../gtk/gtkcheckbutton.c:77 ../gtk/gtkcheckmenuitem.c:128 msgid "Indicator Size" msgstr "Indicator Size" -#: ../gtk/gtkcheckbutton.c:79 ../gtk/gtkexpander.c:267 +#: ../gtk/gtkcheckbutton.c:85 ../gtk/gtkexpander.c:267 msgid "Indicator Spacing" msgstr "Indicator Spacing" -#: ../gtk/gtkcheckbutton.c:80 +#: ../gtk/gtkcheckbutton.c:86 msgid "Spacing around check or radio indicator" msgstr "Spacing around check or radio indicator" @@ -1879,7 +1880,7 @@ msgstr "Spacing around check or radio indicator" msgid "Whether the menu item is checked" msgstr "Whether the menu item is checked" -#: ../gtk/gtkcheckmenuitem.c:113 ../gtk/gtktogglebutton.c:130 +#: ../gtk/gtkcheckmenuitem.c:113 ../gtk/gtktogglebutton.c:133 msgid "Inconsistent" msgstr "Inconsistent" @@ -1895,77 +1896,77 @@ msgstr "Draw as radio menu item" msgid "Whether the menu item looks like a radio menu item" msgstr "Whether the menu item looks like a radio menu item" -#: ../gtk/gtkcolorbutton.c:158 +#: ../gtk/gtkcolorbutton.c:171 msgid "Use alpha" msgstr "Use alpha" -#: ../gtk/gtkcolorbutton.c:159 +#: ../gtk/gtkcolorbutton.c:172 msgid "Whether to give the color an alpha value" msgstr "Whether to give the color an alpha value" -#: ../gtk/gtkcolorbutton.c:173 ../gtk/gtkfilechooserbutton.c:397 +#: ../gtk/gtkcolorbutton.c:186 ../gtk/gtkfilechooserbutton.c:397 #: ../gtk/gtkfontbutton.c:140 ../gtk/gtkprintjob.c:115 #: ../gtk/gtkstatusicon.c:415 ../gtk/gtktreeviewcolumn.c:286 msgid "Title" msgstr "Title" -#: ../gtk/gtkcolorbutton.c:174 +#: ../gtk/gtkcolorbutton.c:187 msgid "The title of the color selection dialog" msgstr "The title of the color selection dialog" -#: ../gtk/gtkcolorbutton.c:188 ../gtk/gtkcolorsel.c:325 +#: ../gtk/gtkcolorbutton.c:201 ../gtk/gtkcolorsel.c:339 msgid "Current Color" msgstr "Current Color" -#: ../gtk/gtkcolorbutton.c:189 +#: ../gtk/gtkcolorbutton.c:202 msgid "The selected color" msgstr "The selected color" -#: ../gtk/gtkcolorbutton.c:203 ../gtk/gtkcolorsel.c:332 +#: ../gtk/gtkcolorbutton.c:216 ../gtk/gtkcolorsel.c:346 msgid "Current Alpha" msgstr "Current Alpha" -#: ../gtk/gtkcolorbutton.c:204 +#: ../gtk/gtkcolorbutton.c:217 msgid "The selected opacity value (0 fully transparent, 65535 fully opaque)" msgstr "The selected opacity value (0 fully transparent, 65535 fully opaque)" -#: ../gtk/gtkcolorbutton.c:218 +#: ../gtk/gtkcolorbutton.c:231 msgid "Current RGBA Color" msgstr "Current RGBA Color" -#: ../gtk/gtkcolorbutton.c:219 +#: ../gtk/gtkcolorbutton.c:232 msgid "The selected RGBA color" msgstr "The selected RGBA color" -#: ../gtk/gtkcolorsel.c:311 +#: ../gtk/gtkcolorsel.c:325 msgid "Has Opacity Control" msgstr "Has Opacity Control" -#: ../gtk/gtkcolorsel.c:312 +#: ../gtk/gtkcolorsel.c:326 msgid "Whether the color selector should allow setting opacity" msgstr "Whether the color selector should allow setting opacity" -#: ../gtk/gtkcolorsel.c:318 +#: ../gtk/gtkcolorsel.c:332 msgid "Has palette" msgstr "Has palette" -#: ../gtk/gtkcolorsel.c:319 +#: ../gtk/gtkcolorsel.c:333 msgid "Whether a palette should be used" msgstr "Whether a palette should be used" -#: ../gtk/gtkcolorsel.c:326 +#: ../gtk/gtkcolorsel.c:340 msgid "The current color" msgstr "The current color" -#: ../gtk/gtkcolorsel.c:333 +#: ../gtk/gtkcolorsel.c:347 msgid "The current opacity value (0 fully transparent, 65535 fully opaque)" msgstr "The current opacity value (0 fully transparent, 65535 fully opaque)" -#: ../gtk/gtkcolorsel.c:347 +#: ../gtk/gtkcolorsel.c:361 msgid "Current RGBA" msgstr "Current RGBA" -#: ../gtk/gtkcolorsel.c:348 +#: ../gtk/gtkcolorsel.c:362 msgid "The current RGBA color" msgstr "The current RGBA color" @@ -2001,67 +2002,67 @@ msgstr "Help Button" msgid "The help button of the dialog." msgstr "The help button of the dialog." -#: ../gtk/gtkcombobox.c:733 +#: ../gtk/gtkcombobox.c:737 msgid "ComboBox model" msgstr "ComboBox model" -#: ../gtk/gtkcombobox.c:734 +#: ../gtk/gtkcombobox.c:738 msgid "The model for the combo box" msgstr "The model for the combo box" -#: ../gtk/gtkcombobox.c:751 +#: ../gtk/gtkcombobox.c:755 msgid "Wrap width for laying out the items in a grid" msgstr "Wrap width for laying out the items in a grid" -#: ../gtk/gtkcombobox.c:773 +#: ../gtk/gtkcombobox.c:777 msgid "Row span column" msgstr "Row span column" -#: ../gtk/gtkcombobox.c:774 +#: ../gtk/gtkcombobox.c:778 msgid "TreeModel column containing the row span values" msgstr "TreeModel column containing the row span values" -#: ../gtk/gtkcombobox.c:795 +#: ../gtk/gtkcombobox.c:799 msgid "Column span column" msgstr "Column span column" -#: ../gtk/gtkcombobox.c:796 +#: ../gtk/gtkcombobox.c:800 msgid "TreeModel column containing the column span values" msgstr "TreeModel column containing the column span values" -#: ../gtk/gtkcombobox.c:817 +#: ../gtk/gtkcombobox.c:821 msgid "Active item" msgstr "Active item" -#: ../gtk/gtkcombobox.c:818 +#: ../gtk/gtkcombobox.c:822 msgid "The item which is currently active" msgstr "The item which is currently active" -#: ../gtk/gtkcombobox.c:837 ../gtk/gtkuimanager.c:224 +#: ../gtk/gtkcombobox.c:841 ../gtk/gtkuimanager.c:224 msgid "Add tearoffs to menus" msgstr "Add tearoffs to menus" -#: ../gtk/gtkcombobox.c:838 +#: ../gtk/gtkcombobox.c:842 msgid "Whether dropdowns should have a tearoff menu item" msgstr "Whether dropdowns should have a tearoff menu item" -#: ../gtk/gtkcombobox.c:853 ../gtk/gtkentry.c:687 +#: ../gtk/gtkcombobox.c:857 ../gtk/gtkentry.c:778 msgid "Has Frame" msgstr "Has Frame" -#: ../gtk/gtkcombobox.c:854 +#: ../gtk/gtkcombobox.c:858 msgid "Whether the combo box draws a frame around the child" msgstr "Whether the combo box draws a frame around the child" -#: ../gtk/gtkcombobox.c:862 +#: ../gtk/gtkcombobox.c:866 msgid "Whether the combo box grabs focus when it is clicked with the mouse" msgstr "Whether the combo box grabs focus when it is clicked with the mouse" -#: ../gtk/gtkcombobox.c:877 ../gtk/gtkmenu.c:575 +#: ../gtk/gtkcombobox.c:881 ../gtk/gtkmenu.c:576 msgid "Tearoff Title" msgstr "Tearoff Title" -#: ../gtk/gtkcombobox.c:878 +#: ../gtk/gtkcombobox.c:882 msgid "" "A title that may be displayed by the window manager when the popup is torn-" "off" @@ -2069,31 +2070,31 @@ msgstr "" "A title that may be displayed by the window manager when the popup is torn-" "off" -#: ../gtk/gtkcombobox.c:895 +#: ../gtk/gtkcombobox.c:899 msgid "Popup shown" msgstr "Popup shown" -#: ../gtk/gtkcombobox.c:896 +#: ../gtk/gtkcombobox.c:900 msgid "Whether the combo's dropdown is shown" msgstr "Whether the combo's dropdown is shown" -#: ../gtk/gtkcombobox.c:912 +#: ../gtk/gtkcombobox.c:916 msgid "Button Sensitivity" msgstr "Button Sensitivity" -#: ../gtk/gtkcombobox.c:913 +#: ../gtk/gtkcombobox.c:917 msgid "Whether the dropdown button is sensitive when the model is empty" msgstr "Whether the dropdown button is sensitive when the model is empty" -#: ../gtk/gtkcombobox.c:929 +#: ../gtk/gtkcombobox.c:933 msgid "Whether combo box has an entry" msgstr "Whether combo box has an entry" -#: ../gtk/gtkcombobox.c:944 +#: ../gtk/gtkcombobox.c:948 msgid "Entry Text Column" msgstr "Entry Text Column" -#: ../gtk/gtkcombobox.c:945 +#: ../gtk/gtkcombobox.c:949 msgid "" "The column in the combo box's model to associate with strings from the entry " "if the combo was created with #GtkComboBox:has-entry = %TRUE" @@ -2101,11 +2102,31 @@ msgstr "" "The column in the combo box's model to associate with strings from the entry " "if the combo was created with #GtkComboBox:has-entry = %TRUE" -#: ../gtk/gtkcombobox.c:962 +#: ../gtk/gtkcombobox.c:966 +msgid "ID Column" +msgstr "ID Column" + +#: ../gtk/gtkcombobox.c:967 +msgid "" +"The column in the combo box's model that provides string IDs for the values " +"in the model" +msgstr "" +"The column in the combo box's model that provides string IDs for the values " +"in the model" + +#: ../gtk/gtkcombobox.c:982 +msgid "Active id" +msgstr "Active id" + +#: ../gtk/gtkcombobox.c:983 +msgid "The value of the id column for the active row" +msgstr "The value of the id column for the active row" + +#: ../gtk/gtkcombobox.c:998 msgid "Popup Fixed Width" msgstr "Popup Fixed Width" -#: ../gtk/gtkcombobox.c:963 +#: ../gtk/gtkcombobox.c:999 msgid "" "Whether the popup's width should be a fixed width matching the allocated " "width of the combo box" @@ -2113,29 +2134,29 @@ msgstr "" "Whether the popup's width should be a fixed width matching the allocated " "width of the combo box" -#: ../gtk/gtkcombobox.c:971 +#: ../gtk/gtkcombobox.c:1007 msgid "Appears as list" msgstr "Appears as list" -#: ../gtk/gtkcombobox.c:972 +#: ../gtk/gtkcombobox.c:1008 msgid "Whether dropdowns should look like lists rather than menus" msgstr "Whether dropdowns should look like lists rather than menus" -#: ../gtk/gtkcombobox.c:988 +#: ../gtk/gtkcombobox.c:1024 msgid "Arrow Size" msgstr "Arrow Size" -#: ../gtk/gtkcombobox.c:989 +#: ../gtk/gtkcombobox.c:1025 msgid "The minimum size of the arrow in the combo box" msgstr "The minimum size of the arrow in the combo box" -#: ../gtk/gtkcombobox.c:1004 ../gtk/gtkentry.c:787 ../gtk/gtkhandlebox.c:182 -#: ../gtk/gtkmenubar.c:189 ../gtk/gtkstatusbar.c:178 ../gtk/gtktoolbar.c:597 -#: ../gtk/gtkviewport.c:155 +#: ../gtk/gtkcombobox.c:1040 ../gtk/gtkentry.c:878 ../gtk/gtkhandlebox.c:188 +#: ../gtk/gtkmenubar.c:196 ../gtk/gtkstatusbar.c:180 ../gtk/gtktoolbar.c:603 +#: ../gtk/gtkviewport.c:154 msgid "Shadow type" msgstr "Shadow type" -#: ../gtk/gtkcombobox.c:1005 +#: ../gtk/gtkcombobox.c:1041 msgid "Which kind of shadow to draw around the combo box" msgstr "Which kind of shadow to draw around the combo box" @@ -2195,49 +2216,49 @@ msgstr "Action area border" msgid "Width of border around the button area at the bottom of the dialog" msgstr "Width of border around the button area at the bottom of the dialog" -#: ../gtk/gtkentry.c:634 +#: ../gtk/gtkentry.c:725 msgid "Text Buffer" msgstr "Text Buffer" -#: ../gtk/gtkentry.c:635 +#: ../gtk/gtkentry.c:726 msgid "Text buffer object which actually stores entry text" msgstr "Text buffer object which actually stores entry text" -#: ../gtk/gtkentry.c:642 ../gtk/gtklabel.c:644 +#: ../gtk/gtkentry.c:733 ../gtk/gtklabel.c:662 msgid "Cursor Position" msgstr "Cursor Position" -#: ../gtk/gtkentry.c:643 ../gtk/gtklabel.c:645 +#: ../gtk/gtkentry.c:734 ../gtk/gtklabel.c:663 msgid "The current position of the insertion cursor in chars" msgstr "The current position of the insertion cursor in chars" -#: ../gtk/gtkentry.c:652 ../gtk/gtklabel.c:654 +#: ../gtk/gtkentry.c:743 ../gtk/gtklabel.c:672 msgid "Selection Bound" msgstr "Selection Bound" -#: ../gtk/gtkentry.c:653 ../gtk/gtklabel.c:655 +#: ../gtk/gtkentry.c:744 ../gtk/gtklabel.c:673 msgid "" "The position of the opposite end of the selection from the cursor in chars" msgstr "" "The position of the opposite end of the selection from the cursor in chars" -#: ../gtk/gtkentry.c:663 +#: ../gtk/gtkentry.c:754 msgid "Whether the entry contents can be edited" msgstr "Whether the entry contents can be edited" -#: ../gtk/gtkentry.c:670 ../gtk/gtkentrybuffer.c:382 +#: ../gtk/gtkentry.c:761 ../gtk/gtkentrybuffer.c:382 msgid "Maximum length" msgstr "Maximum length" -#: ../gtk/gtkentry.c:671 ../gtk/gtkentrybuffer.c:383 +#: ../gtk/gtkentry.c:762 ../gtk/gtkentrybuffer.c:383 msgid "Maximum number of characters for this entry. Zero if no maximum" msgstr "Maximum number of characters for this entry. Zero if no maximum" -#: ../gtk/gtkentry.c:679 +#: ../gtk/gtkentry.c:770 msgid "Visibility" msgstr "Visibility" -#: ../gtk/gtkentry.c:680 +#: ../gtk/gtkentry.c:771 msgid "" "FALSE displays the \"invisible char\" instead of the actual text (password " "mode)" @@ -2245,30 +2266,30 @@ msgstr "" "FALSE displays the \"invisible char\" instead of the actual text (password " "mode)" -#: ../gtk/gtkentry.c:688 +#: ../gtk/gtkentry.c:779 msgid "FALSE removes outside bevel from entry" msgstr "FALSE removes outside bevel from entry" -#: ../gtk/gtkentry.c:696 +#: ../gtk/gtkentry.c:787 msgid "" "Border between text and frame. Overrides the inner-border style property" msgstr "" "Border between text and frame. Overrides the inner-border style property" -#: ../gtk/gtkentry.c:703 ../gtk/gtkentry.c:1269 +#: ../gtk/gtkentry.c:794 ../gtk/gtkentry.c:1360 msgid "Invisible character" msgstr "Invisible character" -#: ../gtk/gtkentry.c:704 ../gtk/gtkentry.c:1270 +#: ../gtk/gtkentry.c:795 ../gtk/gtkentry.c:1361 msgid "The character to use when masking entry contents (in \"password mode\")" msgstr "" "The character to use when masking entry contents (in \"password mode\")" -#: ../gtk/gtkentry.c:711 +#: ../gtk/gtkentry.c:802 msgid "Activates default" msgstr "Activates default" -#: ../gtk/gtkentry.c:712 +#: ../gtk/gtkentry.c:803 msgid "" "Whether to activate the default widget (such as the default button in a " "dialog) when Enter is pressed" @@ -2276,31 +2297,31 @@ msgstr "" "Whether to activate the default widget (such as the default button in a " "dialog) when Enter is pressed" -#: ../gtk/gtkentry.c:718 +#: ../gtk/gtkentry.c:809 msgid "Width in chars" msgstr "Width in chars" -#: ../gtk/gtkentry.c:719 +#: ../gtk/gtkentry.c:810 msgid "Number of characters to leave space for in the entry" msgstr "Number of characters to leave space for in the entry" -#: ../gtk/gtkentry.c:728 +#: ../gtk/gtkentry.c:819 msgid "Scroll offset" msgstr "Scroll offset" -#: ../gtk/gtkentry.c:729 +#: ../gtk/gtkentry.c:820 msgid "Number of pixels of the entry scrolled off the screen to the left" msgstr "Number of pixels of the entry scrolled off the screen to the left" -#: ../gtk/gtkentry.c:739 +#: ../gtk/gtkentry.c:830 msgid "The contents of the entry" msgstr "The contents of the entry" -#: ../gtk/gtkentry.c:754 ../gtk/gtkmisc.c:81 +#: ../gtk/gtkentry.c:845 ../gtk/gtkmisc.c:81 msgid "X align" msgstr "X align" -#: ../gtk/gtkentry.c:755 ../gtk/gtkmisc.c:82 +#: ../gtk/gtkentry.c:846 ../gtk/gtkmisc.c:82 msgid "" "The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL " "layouts." @@ -2308,63 +2329,63 @@ msgstr "" "The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL " "layouts." -#: ../gtk/gtkentry.c:771 +#: ../gtk/gtkentry.c:862 msgid "Truncate multiline" msgstr "Truncate multiline" -#: ../gtk/gtkentry.c:772 +#: ../gtk/gtkentry.c:863 msgid "Whether to truncate multiline pastes to one line." msgstr "Whether to truncate multiline pastes to one line." -#: ../gtk/gtkentry.c:788 +#: ../gtk/gtkentry.c:879 msgid "Which kind of shadow to draw around the entry when has-frame is set" msgstr "Which kind of shadow to draw around the entry when has-frame is set" -#: ../gtk/gtkentry.c:803 ../gtk/gtktextview.c:747 +#: ../gtk/gtkentry.c:894 ../gtk/gtktextview.c:766 msgid "Overwrite mode" msgstr "Overwrite mode" -#: ../gtk/gtkentry.c:804 +#: ../gtk/gtkentry.c:895 msgid "Whether new text overwrites existing text" msgstr "Whether new text overwrites existing text" -#: ../gtk/gtkentry.c:818 ../gtk/gtkentrybuffer.c:367 +#: ../gtk/gtkentry.c:909 ../gtk/gtkentrybuffer.c:367 msgid "Text length" msgstr "Text length" -#: ../gtk/gtkentry.c:819 +#: ../gtk/gtkentry.c:910 msgid "Length of the text currently in the entry" msgstr "Length of the text currently in the entry" -#: ../gtk/gtkentry.c:834 +#: ../gtk/gtkentry.c:925 msgid "Invisible character set" msgstr "Invisible character set" -#: ../gtk/gtkentry.c:835 +#: ../gtk/gtkentry.c:926 msgid "Whether the invisible character has been set" msgstr "Whether the invisible character has been set" -#: ../gtk/gtkentry.c:853 +#: ../gtk/gtkentry.c:944 msgid "Caps Lock warning" msgstr "Caps Lock warning" -#: ../gtk/gtkentry.c:854 +#: ../gtk/gtkentry.c:945 msgid "Whether password entries will show a warning when Caps Lock is on" msgstr "Whether password entries will show a warning when Caps Lock is on" -#: ../gtk/gtkentry.c:868 +#: ../gtk/gtkentry.c:959 msgid "Progress Fraction" msgstr "Progress Fraction" -#: ../gtk/gtkentry.c:869 +#: ../gtk/gtkentry.c:960 msgid "The current fraction of the task that's been completed" msgstr "The current fraction of the task that's been completed" -#: ../gtk/gtkentry.c:886 +#: ../gtk/gtkentry.c:977 msgid "Progress Pulse Step" msgstr "Progress Pulse Step" -#: ../gtk/gtkentry.c:887 +#: ../gtk/gtkentry.c:978 msgid "" "The fraction of total entry width to move the progress bouncing block for " "each call to gtk_entry_progress_pulse()" @@ -2372,167 +2393,167 @@ msgstr "" "The fraction of total entry width to move the progress bouncing block for " "each call to gtk_entry_progress_pulse()" -#: ../gtk/gtkentry.c:903 +#: ../gtk/gtkentry.c:994 msgid "Primary pixbuf" msgstr "Primary pixbuf" -#: ../gtk/gtkentry.c:904 +#: ../gtk/gtkentry.c:995 msgid "Primary pixbuf for the entry" msgstr "Primary pixbuf for the entry" -#: ../gtk/gtkentry.c:918 +#: ../gtk/gtkentry.c:1009 msgid "Secondary pixbuf" msgstr "Secondary pixbuf" -#: ../gtk/gtkentry.c:919 +#: ../gtk/gtkentry.c:1010 msgid "Secondary pixbuf for the entry" msgstr "Secondary pixbuf for the entry" -#: ../gtk/gtkentry.c:933 +#: ../gtk/gtkentry.c:1024 msgid "Primary stock ID" msgstr "Primary stock ID" -#: ../gtk/gtkentry.c:934 +#: ../gtk/gtkentry.c:1025 msgid "Stock ID for primary icon" msgstr "Stock ID for primary icon" -#: ../gtk/gtkentry.c:948 +#: ../gtk/gtkentry.c:1039 msgid "Secondary stock ID" msgstr "Secondary stock ID" -#: ../gtk/gtkentry.c:949 +#: ../gtk/gtkentry.c:1040 msgid "Stock ID for secondary icon" msgstr "Stock ID for secondary icon" -#: ../gtk/gtkentry.c:963 +#: ../gtk/gtkentry.c:1054 msgid "Primary icon name" msgstr "Primary icon name" -#: ../gtk/gtkentry.c:964 +#: ../gtk/gtkentry.c:1055 msgid "Icon name for primary icon" msgstr "Icon name for primary icon" -#: ../gtk/gtkentry.c:978 +#: ../gtk/gtkentry.c:1069 msgid "Secondary icon name" msgstr "Secondary icon name" -#: ../gtk/gtkentry.c:979 +#: ../gtk/gtkentry.c:1070 msgid "Icon name for secondary icon" msgstr "Icon name for secondary icon" -#: ../gtk/gtkentry.c:993 +#: ../gtk/gtkentry.c:1084 msgid "Primary GIcon" msgstr "Primary GIcon" -#: ../gtk/gtkentry.c:994 +#: ../gtk/gtkentry.c:1085 msgid "GIcon for primary icon" msgstr "GIcon for primary icon" -#: ../gtk/gtkentry.c:1008 +#: ../gtk/gtkentry.c:1099 msgid "Secondary GIcon" msgstr "Secondary GIcon" -#: ../gtk/gtkentry.c:1009 +#: ../gtk/gtkentry.c:1100 msgid "GIcon for secondary icon" msgstr "GIcon for secondary icon" -#: ../gtk/gtkentry.c:1023 +#: ../gtk/gtkentry.c:1114 msgid "Primary storage type" msgstr "Primary storage type" -#: ../gtk/gtkentry.c:1024 +#: ../gtk/gtkentry.c:1115 msgid "The representation being used for primary icon" msgstr "The representation being used for primary icon" -#: ../gtk/gtkentry.c:1039 +#: ../gtk/gtkentry.c:1130 msgid "Secondary storage type" msgstr "Secondary storage type" -#: ../gtk/gtkentry.c:1040 +#: ../gtk/gtkentry.c:1131 msgid "The representation being used for secondary icon" msgstr "The representation being used for secondary icon" -#: ../gtk/gtkentry.c:1061 +#: ../gtk/gtkentry.c:1152 msgid "Primary icon activatable" msgstr "Primary icon activatable" -#: ../gtk/gtkentry.c:1062 +#: ../gtk/gtkentry.c:1153 msgid "Whether the primary icon is activatable" msgstr "Whether the primary icon is activatable" -#: ../gtk/gtkentry.c:1082 +#: ../gtk/gtkentry.c:1173 msgid "Secondary icon activatable" msgstr "Secondary icon activatable" -#: ../gtk/gtkentry.c:1083 +#: ../gtk/gtkentry.c:1174 msgid "Whether the secondary icon is activatable" msgstr "Whether the secondary icon is activatable" -#: ../gtk/gtkentry.c:1105 +#: ../gtk/gtkentry.c:1196 msgid "Primary icon sensitive" msgstr "Primary icon sensitive" -#: ../gtk/gtkentry.c:1106 +#: ../gtk/gtkentry.c:1197 msgid "Whether the primary icon is sensitive" msgstr "Whether the primary icon is sensitive" -#: ../gtk/gtkentry.c:1127 +#: ../gtk/gtkentry.c:1218 msgid "Secondary icon sensitive" msgstr "Secondary icon sensitive" -#: ../gtk/gtkentry.c:1128 +#: ../gtk/gtkentry.c:1219 msgid "Whether the secondary icon is sensitive" msgstr "Whether the secondary icon is sensitive" -#: ../gtk/gtkentry.c:1144 +#: ../gtk/gtkentry.c:1235 msgid "Primary icon tooltip text" msgstr "Primary icon tooltip text" -#: ../gtk/gtkentry.c:1145 ../gtk/gtkentry.c:1181 +#: ../gtk/gtkentry.c:1236 ../gtk/gtkentry.c:1272 msgid "The contents of the tooltip on the primary icon" msgstr "The contents of the tooltip on the primary icon" -#: ../gtk/gtkentry.c:1161 +#: ../gtk/gtkentry.c:1252 msgid "Secondary icon tooltip text" msgstr "Secondary icon tooltip text" -#: ../gtk/gtkentry.c:1162 ../gtk/gtkentry.c:1200 +#: ../gtk/gtkentry.c:1253 ../gtk/gtkentry.c:1291 msgid "The contents of the tooltip on the secondary icon" msgstr "The contents of the tooltip on the secondary icon" -#: ../gtk/gtkentry.c:1180 +#: ../gtk/gtkentry.c:1271 msgid "Primary icon tooltip markup" msgstr "Primary icon tooltip markup" -#: ../gtk/gtkentry.c:1199 +#: ../gtk/gtkentry.c:1290 msgid "Secondary icon tooltip markup" msgstr "Secondary icon tooltip markup" -#: ../gtk/gtkentry.c:1219 ../gtk/gtktextview.c:775 +#: ../gtk/gtkentry.c:1310 ../gtk/gtktextview.c:794 msgid "IM module" msgstr "IM module" -#: ../gtk/gtkentry.c:1220 ../gtk/gtktextview.c:776 +#: ../gtk/gtkentry.c:1311 ../gtk/gtktextview.c:795 msgid "Which IM module should be used" msgstr "Which IM module should be used" -#: ../gtk/gtkentry.c:1234 +#: ../gtk/gtkentry.c:1325 msgid "Icon Prelight" msgstr "Icon Prelight" -#: ../gtk/gtkentry.c:1235 +#: ../gtk/gtkentry.c:1326 msgid "Whether activatable icons should prelight when hovered" msgstr "Whether activatable icons should prelight when hovered" -#: ../gtk/gtkentry.c:1248 +#: ../gtk/gtkentry.c:1339 msgid "Progress Border" msgstr "Progress Border" -#: ../gtk/gtkentry.c:1249 +#: ../gtk/gtkentry.c:1340 msgid "Border around the progress bar" msgstr "Border around the progress bar" -#: ../gtk/gtkentry.c:1741 +#: ../gtk/gtkentry.c:1832 msgid "Border between text and frame." msgstr "Border between text and frame." @@ -2560,7 +2581,7 @@ msgstr "Minimum Key Length" msgid "Minimum length of the search key in order to look up matches" msgstr "Minimum length of the search key in order to look up matches" -#: ../gtk/gtkentrycompletion.c:304 ../gtk/gtkiconview.c:612 +#: ../gtk/gtkentrycompletion.c:304 ../gtk/gtkiconview.c:617 msgid "Text column" msgstr "Text column" @@ -2644,11 +2665,11 @@ msgstr "Whether the expander has been opened to reveal the child widget" msgid "Text of the expander's label" msgstr "Text of the expander's label" -#: ../gtk/gtkexpander.c:225 ../gtk/gtklabel.c:563 +#: ../gtk/gtkexpander.c:225 ../gtk/gtklabel.c:581 msgid "Use markup" msgstr "Use markup" -#: ../gtk/gtkexpander.c:226 ../gtk/gtklabel.c:564 +#: ../gtk/gtkexpander.c:226 ../gtk/gtklabel.c:582 msgid "The text of the label includes XML markup. See pango_parse_markup()" msgstr "The text of the label includes XML markup. See pango_parse_markup()" @@ -2657,7 +2678,7 @@ msgid "Space to put between the label and the child" msgstr "Space to put between the label and the child" #: ../gtk/gtkexpander.c:243 ../gtk/gtkframe.c:165 ../gtk/gtktoolbutton.c:216 -#: ../gtk/gtktoolitemgroup.c:1578 +#: ../gtk/gtktoolitemgroup.c:1595 msgid "Label widget" msgstr "Label widget" @@ -2673,13 +2694,13 @@ msgstr "Label fill" msgid "Whether the label widget should fill all available horizontal space" msgstr "Whether the label widget should fill all available horizontal space" -#: ../gtk/gtkexpander.c:258 ../gtk/gtktoolitemgroup.c:1606 -#: ../gtk/gtktreeview.c:770 +#: ../gtk/gtkexpander.c:258 ../gtk/gtktoolitemgroup.c:1623 +#: ../gtk/gtktreeview.c:863 msgid "Expander Size" msgstr "Expander Size" -#: ../gtk/gtkexpander.c:259 ../gtk/gtktoolitemgroup.c:1607 -#: ../gtk/gtktreeview.c:771 +#: ../gtk/gtkexpander.c:259 ../gtk/gtktoolitemgroup.c:1624 +#: ../gtk/gtktreeview.c:864 msgid "Size of the expander arrow" msgstr "Size of the expander arrow" @@ -2801,19 +2822,19 @@ msgstr "" "Whether a file chooser not in open mode will offer the user to create new " "folders." -#: ../gtk/gtkfixed.c:98 ../gtk/gtklayout.c:610 +#: ../gtk/gtkfixed.c:103 ../gtk/gtklayout.c:633 msgid "X position" msgstr "X position" -#: ../gtk/gtkfixed.c:99 ../gtk/gtklayout.c:611 +#: ../gtk/gtkfixed.c:104 ../gtk/gtklayout.c:634 msgid "X position of child widget" msgstr "X position of child widget" -#: ../gtk/gtkfixed.c:108 ../gtk/gtklayout.c:620 +#: ../gtk/gtkfixed.c:111 ../gtk/gtklayout.c:643 msgid "Y position" msgstr "Y position" -#: ../gtk/gtkfixed.c:109 ../gtk/gtklayout.c:621 +#: ../gtk/gtkfixed.c:112 ../gtk/gtklayout.c:644 msgid "Y position of child widget" msgstr "Y position of child widget" @@ -2909,23 +2930,23 @@ msgstr "Appearance of the frame border" msgid "A widget to display in place of the usual frame label" msgstr "A widget to display in place of the usual frame label" -#: ../gtk/gtkhandlebox.c:183 +#: ../gtk/gtkhandlebox.c:189 msgid "Appearance of the shadow that surrounds the container" msgstr "Appearance of the shadow that surrounds the container" -#: ../gtk/gtkhandlebox.c:191 +#: ../gtk/gtkhandlebox.c:197 msgid "Handle position" msgstr "Handle position" -#: ../gtk/gtkhandlebox.c:192 +#: ../gtk/gtkhandlebox.c:198 msgid "Position of the handle relative to the child widget" msgstr "Position of the handle relative to the child widget" -#: ../gtk/gtkhandlebox.c:200 +#: ../gtk/gtkhandlebox.c:206 msgid "Snap edge" msgstr "Snap edge" -#: ../gtk/gtkhandlebox.c:201 +#: ../gtk/gtkhandlebox.c:207 msgid "" "Side of the handlebox that's lined up with the docking point to dock the " "handlebox" @@ -2933,11 +2954,11 @@ msgstr "" "Side of the handlebox that's lined up with the docking point to dock the " "handlebox" -#: ../gtk/gtkhandlebox.c:209 +#: ../gtk/gtkhandlebox.c:215 msgid "Snap edge set" msgstr "Snap edge set" -#: ../gtk/gtkhandlebox.c:210 +#: ../gtk/gtkhandlebox.c:216 msgid "" "Whether to use the value from the snap_edge property or a value derived from " "handle_position" @@ -2945,11 +2966,11 @@ msgstr "" "Whether to use the value from the snap_edge property or a value derived from " "handle_position" -#: ../gtk/gtkhandlebox.c:217 +#: ../gtk/gtkhandlebox.c:223 msgid "Child Detached" msgstr "Child Detached" -#: ../gtk/gtkhandlebox.c:218 +#: ../gtk/gtkhandlebox.c:224 msgid "" "A boolean value indicating whether the handlebox's child is attached or " "detached." @@ -2957,212 +2978,212 @@ msgstr "" "A boolean value indicating whether the handlebox's child is attached or " "detached." -#: ../gtk/gtkiconview.c:575 +#: ../gtk/gtkiconview.c:580 msgid "Selection mode" msgstr "Selection mode" -#: ../gtk/gtkiconview.c:576 +#: ../gtk/gtkiconview.c:581 msgid "The selection mode" msgstr "The selection mode" -#: ../gtk/gtkiconview.c:594 +#: ../gtk/gtkiconview.c:599 msgid "Pixbuf column" msgstr "Pixbuf column" -#: ../gtk/gtkiconview.c:595 +#: ../gtk/gtkiconview.c:600 msgid "Model column used to retrieve the icon pixbuf from" msgstr "Model column used to retrieve the icon pixbuf from" -#: ../gtk/gtkiconview.c:613 +#: ../gtk/gtkiconview.c:618 msgid "Model column used to retrieve the text from" msgstr "Model column used to retrieve the text from" -#: ../gtk/gtkiconview.c:632 +#: ../gtk/gtkiconview.c:637 msgid "Markup column" msgstr "Markup column" -#: ../gtk/gtkiconview.c:633 +#: ../gtk/gtkiconview.c:638 msgid "Model column used to retrieve the text if using Pango markup" msgstr "Model column used to retrieve the text if using Pango markup" -#: ../gtk/gtkiconview.c:640 +#: ../gtk/gtkiconview.c:645 msgid "Icon View Model" msgstr "Icon View Model" -#: ../gtk/gtkiconview.c:641 +#: ../gtk/gtkiconview.c:646 msgid "The model for the icon view" msgstr "The model for the icon view" -#: ../gtk/gtkiconview.c:657 +#: ../gtk/gtkiconview.c:662 msgid "Number of columns" msgstr "Number of columns" -#: ../gtk/gtkiconview.c:658 +#: ../gtk/gtkiconview.c:663 msgid "Number of columns to display" msgstr "Number of columns to display" -#: ../gtk/gtkiconview.c:675 +#: ../gtk/gtkiconview.c:680 msgid "Width for each item" msgstr "Width for each item" -#: ../gtk/gtkiconview.c:676 +#: ../gtk/gtkiconview.c:681 msgid "The width used for each item" msgstr "The width used for each item" -#: ../gtk/gtkiconview.c:692 +#: ../gtk/gtkiconview.c:697 msgid "Space which is inserted between cells of an item" msgstr "Space which is inserted between cells of an item" -#: ../gtk/gtkiconview.c:707 +#: ../gtk/gtkiconview.c:712 msgid "Row Spacing" msgstr "Row Spacing" -#: ../gtk/gtkiconview.c:708 +#: ../gtk/gtkiconview.c:713 msgid "Space which is inserted between grid rows" msgstr "Space which is inserted between grid rows" -#: ../gtk/gtkiconview.c:723 +#: ../gtk/gtkiconview.c:728 msgid "Column Spacing" msgstr "Column Spacing" -#: ../gtk/gtkiconview.c:724 +#: ../gtk/gtkiconview.c:729 msgid "Space which is inserted between grid columns" msgstr "Space which is inserted between grid columns" -#: ../gtk/gtkiconview.c:739 +#: ../gtk/gtkiconview.c:744 msgid "Margin" msgstr "Margin" -#: ../gtk/gtkiconview.c:740 +#: ../gtk/gtkiconview.c:745 msgid "Space which is inserted at the edges of the icon view" msgstr "Space which is inserted at the edges of the icon view" -#: ../gtk/gtkiconview.c:755 +#: ../gtk/gtkiconview.c:760 msgid "Item Orientation" msgstr "Item Orientation" -#: ../gtk/gtkiconview.c:756 +#: ../gtk/gtkiconview.c:761 msgid "" "How the text and icon of each item are positioned relative to each other" msgstr "" "How the text and icon of each item are positioned relative to each other" -#: ../gtk/gtkiconview.c:772 ../gtk/gtktreeview.c:605 +#: ../gtk/gtkiconview.c:777 ../gtk/gtktreeview.c:698 #: ../gtk/gtktreeviewcolumn.c:329 msgid "Reorderable" msgstr "Reorderable" -#: ../gtk/gtkiconview.c:773 ../gtk/gtktreeview.c:606 +#: ../gtk/gtkiconview.c:778 ../gtk/gtktreeview.c:699 msgid "View is reorderable" msgstr "View is reorderable" -#: ../gtk/gtkiconview.c:780 ../gtk/gtktreeview.c:756 +#: ../gtk/gtkiconview.c:785 ../gtk/gtktreeview.c:849 msgid "Tooltip Column" msgstr "Tooltip Column" -#: ../gtk/gtkiconview.c:781 +#: ../gtk/gtkiconview.c:786 msgid "The column in the model containing the tooltip texts for the items" msgstr "The column in the model containing the tooltip texts for the items" -#: ../gtk/gtkiconview.c:798 +#: ../gtk/gtkiconview.c:803 msgid "Item Padding" msgstr "Item Padding" -#: ../gtk/gtkiconview.c:799 +#: ../gtk/gtkiconview.c:804 msgid "Padding around icon view items" msgstr "Padding around icon view items" -#: ../gtk/gtkiconview.c:812 +#: ../gtk/gtkiconview.c:817 msgid "Selection Box Color" msgstr "Selection Box Color" -#: ../gtk/gtkiconview.c:813 +#: ../gtk/gtkiconview.c:818 msgid "Color of the selection box" msgstr "Color of the selection box" -#: ../gtk/gtkiconview.c:819 +#: ../gtk/gtkiconview.c:824 msgid "Selection Box Alpha" msgstr "Selection Box Alpha" -#: ../gtk/gtkiconview.c:820 +#: ../gtk/gtkiconview.c:825 msgid "Opacity of the selection box" msgstr "Opacity of the selection box" -#: ../gtk/gtkimage.c:227 ../gtk/gtkstatusicon.c:212 +#: ../gtk/gtkimage.c:233 ../gtk/gtkstatusicon.c:212 msgid "Pixbuf" msgstr "Pixbuf" -#: ../gtk/gtkimage.c:228 ../gtk/gtkstatusicon.c:213 +#: ../gtk/gtkimage.c:234 ../gtk/gtkstatusicon.c:213 msgid "A GdkPixbuf to display" msgstr "A GdkPixbuf to display" -#: ../gtk/gtkimage.c:235 ../gtk/gtkrecentmanager.c:294 +#: ../gtk/gtkimage.c:241 ../gtk/gtkrecentmanager.c:294 #: ../gtk/gtkstatusicon.c:220 msgid "Filename" msgstr "Filename" -#: ../gtk/gtkimage.c:236 ../gtk/gtkstatusicon.c:221 +#: ../gtk/gtkimage.c:242 ../gtk/gtkstatusicon.c:221 msgid "Filename to load and display" msgstr "Filename to load and display" -#: ../gtk/gtkimage.c:245 ../gtk/gtkstatusicon.c:229 +#: ../gtk/gtkimage.c:251 ../gtk/gtkstatusicon.c:229 msgid "Stock ID for a stock image to display" msgstr "Stock ID for a stock image to display" -#: ../gtk/gtkimage.c:252 +#: ../gtk/gtkimage.c:258 msgid "Icon set" msgstr "Icon set" -#: ../gtk/gtkimage.c:253 +#: ../gtk/gtkimage.c:259 msgid "Icon set to display" msgstr "Icon set to display" -#: ../gtk/gtkimage.c:260 ../gtk/gtkscalebutton.c:230 ../gtk/gtktoolbar.c:514 -#: ../gtk/gtktoolpalette.c:1003 +#: ../gtk/gtkimage.c:266 ../gtk/gtkscalebutton.c:230 ../gtk/gtktoolbar.c:520 +#: ../gtk/gtktoolpalette.c:1030 msgid "Icon size" msgstr "Icon size" -#: ../gtk/gtkimage.c:261 +#: ../gtk/gtkimage.c:267 msgid "Symbolic size to use for stock icon, icon set or named icon" msgstr "Symbolic size to use for stock icon, icon set or named icon" -#: ../gtk/gtkimage.c:277 +#: ../gtk/gtkimage.c:283 msgid "Pixel size" msgstr "Pixel size" -#: ../gtk/gtkimage.c:278 +#: ../gtk/gtkimage.c:284 msgid "Pixel size to use for named icon" msgstr "Pixel size to use for named icon" -#: ../gtk/gtkimage.c:286 +#: ../gtk/gtkimage.c:292 msgid "Animation" msgstr "Animation" -#: ../gtk/gtkimage.c:287 +#: ../gtk/gtkimage.c:293 msgid "GdkPixbufAnimation to display" msgstr "GdkPixbufAnimation to display" -#: ../gtk/gtkimage.c:327 ../gtk/gtkstatusicon.c:260 +#: ../gtk/gtkimage.c:333 ../gtk/gtkstatusicon.c:260 msgid "Storage type" msgstr "Storage type" -#: ../gtk/gtkimage.c:328 ../gtk/gtkstatusicon.c:261 +#: ../gtk/gtkimage.c:334 ../gtk/gtkstatusicon.c:261 msgid "The representation being used for image data" msgstr "The representation being used for image data" -#: ../gtk/gtkimagemenuitem.c:139 +#: ../gtk/gtkimagemenuitem.c:149 msgid "Child widget to appear next to the menu text" msgstr "Child widget to appear next to the menu text" -#: ../gtk/gtkimagemenuitem.c:154 +#: ../gtk/gtkimagemenuitem.c:164 msgid "Whether to use the label text to create a stock menu item" msgstr "Whether to use the label text to create a stock menu item" -#: ../gtk/gtkimagemenuitem.c:187 ../gtk/gtkmenu.c:535 +#: ../gtk/gtkimagemenuitem.c:197 ../gtk/gtkmenu.c:536 msgid "Accel Group" msgstr "Accel Group" -#: ../gtk/gtkimagemenuitem.c:188 +#: ../gtk/gtkimagemenuitem.c:198 msgid "The Accel Group to use for stock accelerator keys" msgstr "The Accel Group to use for stock accelerator keys" @@ -3195,19 +3216,19 @@ msgstr "Screen" msgid "The screen where this window will be displayed" msgstr "The screen where this window will be displayed" -#: ../gtk/gtklabel.c:550 +#: ../gtk/gtklabel.c:568 msgid "The text of the label" msgstr "The text of the label" -#: ../gtk/gtklabel.c:557 +#: ../gtk/gtklabel.c:575 msgid "A list of style attributes to apply to the text of the label" msgstr "A list of style attributes to apply to the text of the label" -#: ../gtk/gtklabel.c:578 ../gtk/gtktexttag.c:335 ../gtk/gtktextview.c:684 +#: ../gtk/gtklabel.c:596 ../gtk/gtktexttag.c:335 ../gtk/gtktextview.c:703 msgid "Justification" msgstr "Justification" -#: ../gtk/gtklabel.c:579 +#: ../gtk/gtklabel.c:597 msgid "" "The alignment of the lines in the text of the label relative to each other. " "This does NOT affect the alignment of the label within its allocation. See " @@ -3217,11 +3238,11 @@ msgstr "" "This does NOT affect the alignment of the label within its allocation. See " "GtkMisc::xalign for that" -#: ../gtk/gtklabel.c:587 +#: ../gtk/gtklabel.c:605 msgid "Pattern" msgstr "Pattern" -#: ../gtk/gtklabel.c:588 +#: ../gtk/gtklabel.c:606 msgid "" "A string with _ characters in positions correspond to characters in the text " "to underline" @@ -3229,47 +3250,47 @@ msgstr "" "A string with _ characters in positions correspond to characters in the text " "to underline" -#: ../gtk/gtklabel.c:595 +#: ../gtk/gtklabel.c:613 msgid "Line wrap" msgstr "Line wrap" -#: ../gtk/gtklabel.c:596 +#: ../gtk/gtklabel.c:614 msgid "If set, wrap lines if the text becomes too wide" msgstr "If set, wrap lines if the text becomes too wide" -#: ../gtk/gtklabel.c:611 +#: ../gtk/gtklabel.c:629 msgid "Line wrap mode" msgstr "Line wrap mode" -#: ../gtk/gtklabel.c:612 +#: ../gtk/gtklabel.c:630 msgid "If wrap is set, controls how linewrapping is done" msgstr "If wrap is set, controls how linewrapping is done" -#: ../gtk/gtklabel.c:619 +#: ../gtk/gtklabel.c:637 msgid "Selectable" msgstr "Selectable" -#: ../gtk/gtklabel.c:620 +#: ../gtk/gtklabel.c:638 msgid "Whether the label text can be selected with the mouse" msgstr "Whether the label text can be selected with the mouse" -#: ../gtk/gtklabel.c:626 +#: ../gtk/gtklabel.c:644 msgid "Mnemonic key" msgstr "Mnemonic key" -#: ../gtk/gtklabel.c:627 +#: ../gtk/gtklabel.c:645 msgid "The mnemonic accelerator key for this label" msgstr "The mnemonic accelerator key for this label" -#: ../gtk/gtklabel.c:635 +#: ../gtk/gtklabel.c:653 msgid "Mnemonic widget" msgstr "Mnemonic widget" -#: ../gtk/gtklabel.c:636 +#: ../gtk/gtklabel.c:654 msgid "The widget to be activated when the label's mnemonic key is pressed" msgstr "The widget to be activated when the label's mnemonic key is pressed" -#: ../gtk/gtklabel.c:682 +#: ../gtk/gtklabel.c:700 msgid "" "The preferred place to ellipsize the string, if the label does not have " "enough room to display the entire string" @@ -3277,47 +3298,47 @@ msgstr "" "The preferred place to ellipsize the string, if the label does not have " "enough room to display the entire string" -#: ../gtk/gtklabel.c:723 +#: ../gtk/gtklabel.c:741 msgid "Single Line Mode" msgstr "Single Line Mode" -#: ../gtk/gtklabel.c:724 +#: ../gtk/gtklabel.c:742 msgid "Whether the label is in single line mode" msgstr "Whether the label is in single line mode" -#: ../gtk/gtklabel.c:741 +#: ../gtk/gtklabel.c:759 msgid "Angle" msgstr "Angle" -#: ../gtk/gtklabel.c:742 +#: ../gtk/gtklabel.c:760 msgid "Angle at which the label is rotated" msgstr "Angle at which the label is rotated" -#: ../gtk/gtklabel.c:764 +#: ../gtk/gtklabel.c:782 msgid "The desired maximum width of the label, in characters" msgstr "The desired maximum width of the label, in characters" -#: ../gtk/gtklabel.c:782 +#: ../gtk/gtklabel.c:800 msgid "Track visited links" msgstr "Track visited links" -#: ../gtk/gtklabel.c:783 +#: ../gtk/gtklabel.c:801 msgid "Whether visited links should be tracked" msgstr "Whether visited links should be tracked" -#: ../gtk/gtklayout.c:636 ../gtk/gtktreeviewcolumn.c:229 +#: ../gtk/gtklayout.c:659 ../gtk/gtktreeviewcolumn.c:229 msgid "Width" msgstr "Width" -#: ../gtk/gtklayout.c:637 +#: ../gtk/gtklayout.c:660 msgid "The width of the layout" msgstr "The width of the layout" -#: ../gtk/gtklayout.c:645 +#: ../gtk/gtklayout.c:668 msgid "Height" msgstr "Height" -#: ../gtk/gtklayout.c:646 +#: ../gtk/gtklayout.c:669 msgid "The height of the layout" msgstr "The height of the layout" @@ -3337,60 +3358,60 @@ msgstr "Visited" msgid "Whether this link has been visited." msgstr "Whether this link has been visited." -#: ../gtk/gtkmenubar.c:163 +#: ../gtk/gtkmenubar.c:170 msgid "Pack direction" msgstr "Pack direction" -#: ../gtk/gtkmenubar.c:164 +#: ../gtk/gtkmenubar.c:171 msgid "The pack direction of the menubar" msgstr "The pack direction of the menubar" -#: ../gtk/gtkmenubar.c:180 +#: ../gtk/gtkmenubar.c:187 msgid "Child Pack direction" msgstr "Child Pack direction" -#: ../gtk/gtkmenubar.c:181 +#: ../gtk/gtkmenubar.c:188 msgid "The child pack direction of the menubar" msgstr "The child pack direction of the menubar" -#: ../gtk/gtkmenubar.c:190 +#: ../gtk/gtkmenubar.c:197 msgid "Style of bevel around the menubar" msgstr "Style of bevel around the menubar" -#: ../gtk/gtkmenubar.c:197 ../gtk/gtktoolbar.c:564 +#: ../gtk/gtkmenubar.c:204 ../gtk/gtktoolbar.c:570 msgid "Internal padding" msgstr "Internal padding" -#: ../gtk/gtkmenubar.c:198 +#: ../gtk/gtkmenubar.c:205 msgid "Amount of border space between the menubar shadow and the menu items" msgstr "Amount of border space between the menubar shadow and the menu items" -#: ../gtk/gtkmenu.c:521 +#: ../gtk/gtkmenu.c:522 msgid "The currently selected menu item" msgstr "The currently selected menu item" -#: ../gtk/gtkmenu.c:536 +#: ../gtk/gtkmenu.c:537 msgid "The accel group holding accelerators for the menu" msgstr "The accel group holding accelerators for the menu" -#: ../gtk/gtkmenu.c:550 ../gtk/gtkmenuitem.c:316 +#: ../gtk/gtkmenu.c:551 ../gtk/gtkmenuitem.c:316 msgid "Accel Path" msgstr "Accel Path" -#: ../gtk/gtkmenu.c:551 +#: ../gtk/gtkmenu.c:552 msgid "An accel path used to conveniently construct accel paths of child items" msgstr "" "An accel path used to conveniently construct accel paths of child items" -#: ../gtk/gtkmenu.c:567 +#: ../gtk/gtkmenu.c:568 msgid "Attach Widget" msgstr "Attach Widget" -#: ../gtk/gtkmenu.c:568 +#: ../gtk/gtkmenu.c:569 msgid "The widget the menu is attached to" msgstr "The widget the menu is attached to" -#: ../gtk/gtkmenu.c:576 +#: ../gtk/gtkmenu.c:577 msgid "" "A title that may be displayed by the window manager when this menu is torn-" "off" @@ -3398,35 +3419,35 @@ msgstr "" "A title that may be displayed by the window manager when this menu is torn-" "off" -#: ../gtk/gtkmenu.c:590 +#: ../gtk/gtkmenu.c:591 msgid "Tearoff State" msgstr "Tearoff State" -#: ../gtk/gtkmenu.c:591 +#: ../gtk/gtkmenu.c:592 msgid "A boolean that indicates whether the menu is torn-off" msgstr "A boolean that indicates whether the menu is torn-off" -#: ../gtk/gtkmenu.c:605 +#: ../gtk/gtkmenu.c:606 msgid "Monitor" msgstr "Monitor" -#: ../gtk/gtkmenu.c:606 +#: ../gtk/gtkmenu.c:607 msgid "The monitor the menu will be popped up on" msgstr "The monitor the menu will be popped up on" -#: ../gtk/gtkmenu.c:612 +#: ../gtk/gtkmenu.c:613 msgid "Vertical Padding" msgstr "Vertical Padding" -#: ../gtk/gtkmenu.c:613 +#: ../gtk/gtkmenu.c:614 msgid "Extra space at the top and bottom of the menu" msgstr "Extra space at the top and bottom of the menu" -#: ../gtk/gtkmenu.c:635 +#: ../gtk/gtkmenu.c:636 msgid "Reserve Toggle Size" msgstr "Reserve Toggle Size" -#: ../gtk/gtkmenu.c:636 +#: ../gtk/gtkmenu.c:637 msgid "" "A boolean that indicates whether the menu reserves space for toggles and " "icons" @@ -3434,19 +3455,19 @@ msgstr "" "A boolean that indicates whether the menu reserves space for toggles and " "icons" -#: ../gtk/gtkmenu.c:642 +#: ../gtk/gtkmenu.c:643 msgid "Horizontal Padding" msgstr "Horizontal Padding" -#: ../gtk/gtkmenu.c:643 +#: ../gtk/gtkmenu.c:644 msgid "Extra space at the left and right edges of the menu" msgstr "Extra space at the left and right edges of the menu" -#: ../gtk/gtkmenu.c:651 +#: ../gtk/gtkmenu.c:652 msgid "Vertical Offset" msgstr "Vertical Offset" -#: ../gtk/gtkmenu.c:652 +#: ../gtk/gtkmenu.c:653 msgid "" "When the menu is a submenu, position it this number of pixels offset " "vertically" @@ -3454,11 +3475,11 @@ msgstr "" "When the menu is a submenu, position it this number of pixels offset " "vertically" -#: ../gtk/gtkmenu.c:660 +#: ../gtk/gtkmenu.c:661 msgid "Horizontal Offset" msgstr "Horizontal Offset" -#: ../gtk/gtkmenu.c:661 +#: ../gtk/gtkmenu.c:662 msgid "" "When the menu is a submenu, position it this number of pixels offset " "horizontally" @@ -3466,55 +3487,55 @@ msgstr "" "When the menu is a submenu, position it this number of pixels offset " "horizontally" -#: ../gtk/gtkmenu.c:669 +#: ../gtk/gtkmenu.c:670 msgid "Double Arrows" msgstr "Double Arrows" -#: ../gtk/gtkmenu.c:670 +#: ../gtk/gtkmenu.c:671 msgid "When scrolling, always show both arrows." msgstr "When scrolling, always show both arrows." -#: ../gtk/gtkmenu.c:683 +#: ../gtk/gtkmenu.c:684 msgid "Arrow Placement" msgstr "Arrow Placement" -#: ../gtk/gtkmenu.c:684 +#: ../gtk/gtkmenu.c:685 msgid "Indicates where scroll arrows should be placed" msgstr "Indicates where scroll arrows should be placed" -#: ../gtk/gtkmenu.c:692 +#: ../gtk/gtkmenu.c:693 msgid "Left Attach" msgstr "Left Attach" -#: ../gtk/gtkmenu.c:693 ../gtk/gtktable.c:197 +#: ../gtk/gtkmenu.c:694 ../gtk/gtktable.c:202 msgid "The column number to attach the left side of the child to" msgstr "The column number to attach the left side of the child to" -#: ../gtk/gtkmenu.c:700 +#: ../gtk/gtkmenu.c:701 msgid "Right Attach" msgstr "Right Attach" -#: ../gtk/gtkmenu.c:701 +#: ../gtk/gtkmenu.c:702 msgid "The column number to attach the right side of the child to" msgstr "The column number to attach the right side of the child to" -#: ../gtk/gtkmenu.c:708 +#: ../gtk/gtkmenu.c:709 msgid "Top Attach" msgstr "Top Attach" -#: ../gtk/gtkmenu.c:709 +#: ../gtk/gtkmenu.c:710 msgid "The row number to attach the top of the child to" msgstr "The row number to attach the top of the child to" -#: ../gtk/gtkmenu.c:716 +#: ../gtk/gtkmenu.c:717 msgid "Bottom Attach" msgstr "Bottom Attach" -#: ../gtk/gtkmenu.c:717 ../gtk/gtktable.c:218 +#: ../gtk/gtkmenu.c:718 ../gtk/gtktable.c:223 msgid "The row number to attach the bottom of the child to" msgstr "The row number to attach the bottom of the child to" -#: ../gtk/gtkmenu.c:731 +#: ../gtk/gtkmenu.c:732 msgid "Arbitrary constant to scale down the size of the scroll arrow" msgstr "Arbitrary constant to scale down the size of the scroll arrow" @@ -3557,11 +3578,11 @@ msgstr "Width in Characters" msgid "The minimum desired width of the menu item in characters" msgstr "The minimum desired width of the menu item in characters" -#: ../gtk/gtkmenushell.c:379 +#: ../gtk/gtkmenushell.c:381 msgid "Take Focus" msgstr "Take Focus" -#: ../gtk/gtkmenushell.c:380 +#: ../gtk/gtkmenushell.c:382 msgid "A boolean that determines whether the menu grabs the keyboard focus" msgstr "A boolean that determines whether the menu grabs the keyboard focus" @@ -3681,51 +3702,51 @@ msgstr "Are we showing a dialog" msgid "The screen where this window will be displayed." msgstr "The screen where this window will be displayed." -#: ../gtk/gtknotebook.c:682 +#: ../gtk/gtknotebook.c:689 msgid "Page" msgstr "Page" -#: ../gtk/gtknotebook.c:683 +#: ../gtk/gtknotebook.c:690 msgid "The index of the current page" msgstr "The index of the current page" -#: ../gtk/gtknotebook.c:691 +#: ../gtk/gtknotebook.c:698 msgid "Tab Position" msgstr "Tab Position" -#: ../gtk/gtknotebook.c:692 +#: ../gtk/gtknotebook.c:699 msgid "Which side of the notebook holds the tabs" msgstr "Which side of the notebook holds the tabs" -#: ../gtk/gtknotebook.c:699 +#: ../gtk/gtknotebook.c:706 msgid "Show Tabs" msgstr "Show Tabs" -#: ../gtk/gtknotebook.c:700 +#: ../gtk/gtknotebook.c:707 msgid "Whether tabs should be shown" msgstr "Whether tabs should be shown" -#: ../gtk/gtknotebook.c:706 +#: ../gtk/gtknotebook.c:713 msgid "Show Border" msgstr "Show Border" -#: ../gtk/gtknotebook.c:707 +#: ../gtk/gtknotebook.c:714 msgid "Whether the border should be shown" msgstr "Whether the border should be shown" -#: ../gtk/gtknotebook.c:713 +#: ../gtk/gtknotebook.c:720 msgid "Scrollable" msgstr "Scrollable" -#: ../gtk/gtknotebook.c:714 +#: ../gtk/gtknotebook.c:721 msgid "If TRUE, scroll arrows are added if there are too many tabs to fit" msgstr "If TRUE, scroll arrows are added if there are too many tabs to fit" -#: ../gtk/gtknotebook.c:720 +#: ../gtk/gtknotebook.c:727 msgid "Enable Popup" msgstr "Enable Popup" -#: ../gtk/gtknotebook.c:721 +#: ../gtk/gtknotebook.c:728 msgid "" "If TRUE, pressing the right mouse button on the notebook pops up a menu that " "you can use to go to a page" @@ -3733,123 +3754,123 @@ msgstr "" "If TRUE, pressing the right mouse button on the notebook pops up a menu that " "you can use to go to a page" -#: ../gtk/gtknotebook.c:735 +#: ../gtk/gtknotebook.c:742 msgid "Group Name" msgstr "Group Name" -#: ../gtk/gtknotebook.c:736 +#: ../gtk/gtknotebook.c:743 msgid "Group name for tab drag and drop" msgstr "Group name for tab drag and drop" -#: ../gtk/gtknotebook.c:743 +#: ../gtk/gtknotebook.c:750 msgid "Tab label" msgstr "Tab label" -#: ../gtk/gtknotebook.c:744 +#: ../gtk/gtknotebook.c:751 msgid "The string displayed on the child's tab label" msgstr "The string displayed on the child's tab label" -#: ../gtk/gtknotebook.c:750 +#: ../gtk/gtknotebook.c:757 msgid "Menu label" msgstr "Menu label" -#: ../gtk/gtknotebook.c:751 +#: ../gtk/gtknotebook.c:758 msgid "The string displayed in the child's menu entry" msgstr "The string displayed in the child's menu entry" -#: ../gtk/gtknotebook.c:764 +#: ../gtk/gtknotebook.c:771 msgid "Tab expand" msgstr "Tab expand" -#: ../gtk/gtknotebook.c:765 +#: ../gtk/gtknotebook.c:772 msgid "Whether to expand the child's tab" msgstr "Whether to expand the child's tab" -#: ../gtk/gtknotebook.c:771 +#: ../gtk/gtknotebook.c:778 msgid "Tab fill" msgstr "Tab fill" -#: ../gtk/gtknotebook.c:772 +#: ../gtk/gtknotebook.c:779 msgid "Whether the child's tab should fill the allocated area" msgstr "Whether the child's tab should fill the allocated area" -#: ../gtk/gtknotebook.c:785 +#: ../gtk/gtknotebook.c:792 msgid "Tab pack type" msgstr "Tab pack type" -#: ../gtk/gtknotebook.c:792 +#: ../gtk/gtknotebook.c:799 msgid "Tab reorderable" msgstr "Tab reorderable" -#: ../gtk/gtknotebook.c:793 +#: ../gtk/gtknotebook.c:800 msgid "Whether the tab is reorderable by user action" msgstr "Whether the tab is reorderable by user action" -#: ../gtk/gtknotebook.c:799 +#: ../gtk/gtknotebook.c:806 msgid "Tab detachable" msgstr "Tab detachable" -#: ../gtk/gtknotebook.c:800 +#: ../gtk/gtknotebook.c:807 msgid "Whether the tab is detachable" msgstr "Whether the tab is detachable" -#: ../gtk/gtknotebook.c:815 ../gtk/gtkscrollbar.c:105 +#: ../gtk/gtknotebook.c:822 ../gtk/gtkscrollbar.c:105 msgid "Secondary backward stepper" msgstr "Secondary backward stepper" -#: ../gtk/gtknotebook.c:816 +#: ../gtk/gtknotebook.c:823 msgid "" "Display a second backward arrow button on the opposite end of the tab area" msgstr "" "Display a second backward arrow button on the opposite end of the tab area" -#: ../gtk/gtknotebook.c:831 ../gtk/gtkscrollbar.c:112 +#: ../gtk/gtknotebook.c:838 ../gtk/gtkscrollbar.c:112 msgid "Secondary forward stepper" msgstr "Secondary forward stepper" -#: ../gtk/gtknotebook.c:832 +#: ../gtk/gtknotebook.c:839 msgid "" "Display a second forward arrow button on the opposite end of the tab area" msgstr "" "Display a second forward arrow button on the opposite end of the tab area" -#: ../gtk/gtknotebook.c:846 ../gtk/gtkscrollbar.c:91 +#: ../gtk/gtknotebook.c:853 ../gtk/gtkscrollbar.c:91 msgid "Backward stepper" msgstr "Backward stepper" -#: ../gtk/gtknotebook.c:847 ../gtk/gtkscrollbar.c:92 +#: ../gtk/gtknotebook.c:854 ../gtk/gtkscrollbar.c:92 msgid "Display the standard backward arrow button" msgstr "Display the standard backward arrow button" -#: ../gtk/gtknotebook.c:861 ../gtk/gtkscrollbar.c:98 +#: ../gtk/gtknotebook.c:868 ../gtk/gtkscrollbar.c:98 msgid "Forward stepper" msgstr "Forward stepper" -#: ../gtk/gtknotebook.c:862 ../gtk/gtkscrollbar.c:99 +#: ../gtk/gtknotebook.c:869 ../gtk/gtkscrollbar.c:99 msgid "Display the standard forward arrow button" msgstr "Display the standard forward arrow button" -#: ../gtk/gtknotebook.c:876 +#: ../gtk/gtknotebook.c:883 msgid "Tab overlap" msgstr "Tab overlap" -#: ../gtk/gtknotebook.c:877 +#: ../gtk/gtknotebook.c:884 msgid "Size of tab overlap area" msgstr "Size of tab overlap area" -#: ../gtk/gtknotebook.c:892 +#: ../gtk/gtknotebook.c:899 msgid "Tab curvature" msgstr "Tab curvature" -#: ../gtk/gtknotebook.c:893 +#: ../gtk/gtknotebook.c:900 msgid "Size of tab curvature" msgstr "Size of tab curvature" -#: ../gtk/gtknotebook.c:909 +#: ../gtk/gtknotebook.c:916 msgid "Arrow spacing" msgstr "Arrow spacing" -#: ../gtk/gtknotebook.c:910 +#: ../gtk/gtknotebook.c:917 msgid "Scroll arrow spacing" msgstr "Scroll arrow spacing" @@ -3862,57 +3883,57 @@ msgstr "Orientation" msgid "The orientation of the orientable" msgstr "The orientation of the orientable" -#: ../gtk/gtkpaned.c:272 +#: ../gtk/gtkpaned.c:328 msgid "" "Position of paned separator in pixels (0 means all the way to the left/top)" msgstr "" "Position of paned separator in pixels (0 means all the way to the left/top)" -#: ../gtk/gtkpaned.c:281 +#: ../gtk/gtkpaned.c:337 msgid "Position Set" msgstr "Position Set" -#: ../gtk/gtkpaned.c:282 +#: ../gtk/gtkpaned.c:338 msgid "TRUE if the Position property should be used" msgstr "TRUE if the Position property should be used" -#: ../gtk/gtkpaned.c:288 +#: ../gtk/gtkpaned.c:344 msgid "Handle Size" msgstr "Handle Size" -#: ../gtk/gtkpaned.c:289 +#: ../gtk/gtkpaned.c:345 msgid "Width of handle" msgstr "Width of handle" -#: ../gtk/gtkpaned.c:305 +#: ../gtk/gtkpaned.c:361 msgid "Minimal Position" msgstr "Minimal Position" -#: ../gtk/gtkpaned.c:306 +#: ../gtk/gtkpaned.c:362 msgid "Smallest possible value for the \"position\" property" msgstr "Smallest possible value for the \"position\" property" -#: ../gtk/gtkpaned.c:323 +#: ../gtk/gtkpaned.c:379 msgid "Maximal Position" msgstr "Maximal Position" -#: ../gtk/gtkpaned.c:324 +#: ../gtk/gtkpaned.c:380 msgid "Largest possible value for the \"position\" property" msgstr "Largest possible value for the \"position\" property" -#: ../gtk/gtkpaned.c:341 +#: ../gtk/gtkpaned.c:397 msgid "Resize" msgstr "Resize" -#: ../gtk/gtkpaned.c:342 +#: ../gtk/gtkpaned.c:398 msgid "If TRUE, the child expands and shrinks along with the paned widget" msgstr "If TRUE, the child expands and shrinks along with the paned widget" -#: ../gtk/gtkpaned.c:357 +#: ../gtk/gtkpaned.c:413 msgid "Shrink" msgstr "Shrink" -#: ../gtk/gtkpaned.c:358 +#: ../gtk/gtkpaned.c:414 msgid "If TRUE, the child can be made smaller than its requisition" msgstr "If TRUE, the child can be made smaller than its requisition" @@ -4233,35 +4254,35 @@ msgstr "Whether the application has a selection" msgid "TRUE if page setup combos are embedded in GtkPrintUnixDialog" msgstr "TRUE if page setup combos are embedded in GtkPrintUnixDialog" -#: ../gtk/gtkprogressbar.c:129 +#: ../gtk/gtkprogressbar.c:161 msgid "Fraction" msgstr "Fraction" -#: ../gtk/gtkprogressbar.c:130 +#: ../gtk/gtkprogressbar.c:162 msgid "The fraction of total work that has been completed" msgstr "The fraction of total work that has been completed" -#: ../gtk/gtkprogressbar.c:137 +#: ../gtk/gtkprogressbar.c:169 msgid "Pulse Step" msgstr "Pulse Step" -#: ../gtk/gtkprogressbar.c:138 +#: ../gtk/gtkprogressbar.c:170 msgid "The fraction of total progress to move the bouncing block when pulsed" msgstr "The fraction of total progress to move the bouncing block when pulsed" -#: ../gtk/gtkprogressbar.c:146 +#: ../gtk/gtkprogressbar.c:178 msgid "Text to be displayed in the progress bar" msgstr "Text to be displayed in the progress bar" -#: ../gtk/gtkprogressbar.c:153 +#: ../gtk/gtkprogressbar.c:185 msgid "Show text" msgstr "Show text" -#: ../gtk/gtkprogressbar.c:154 +#: ../gtk/gtkprogressbar.c:186 msgid "Whether the progress is shown as text." msgstr "Whether the progress is shown as text." -#: ../gtk/gtkprogressbar.c:176 +#: ../gtk/gtkprogressbar.c:208 msgid "" "The preferred place to ellipsize the string, if the progress bar does not " "have enough room to display the entire string, if at all." @@ -4269,51 +4290,51 @@ msgstr "" "The preferred place to ellipsize the string, if the progress bar does not " "have enough room to display the entire string, if at all." -#: ../gtk/gtkprogressbar.c:183 +#: ../gtk/gtkprogressbar.c:215 msgid "X spacing" msgstr "X spacing" -#: ../gtk/gtkprogressbar.c:184 +#: ../gtk/gtkprogressbar.c:216 msgid "Extra spacing applied to the width of a progress bar." msgstr "Extra spacing applied to the width of a progress bar." -#: ../gtk/gtkprogressbar.c:189 +#: ../gtk/gtkprogressbar.c:221 msgid "Y spacing" msgstr "Y spacing" -#: ../gtk/gtkprogressbar.c:190 +#: ../gtk/gtkprogressbar.c:222 msgid "Extra spacing applied to the height of a progress bar." msgstr "Extra spacing applied to the height of a progress bar." -#: ../gtk/gtkprogressbar.c:203 +#: ../gtk/gtkprogressbar.c:235 msgid "Minimum horizontal bar width" msgstr "Minimum horizontal bar width" -#: ../gtk/gtkprogressbar.c:204 +#: ../gtk/gtkprogressbar.c:236 msgid "The minimum horizontal width of the progress bar" msgstr "The minimum horizontal width of the progress bar" -#: ../gtk/gtkprogressbar.c:216 +#: ../gtk/gtkprogressbar.c:248 msgid "Minimum horizontal bar height" msgstr "Minimum horizontal bar height" -#: ../gtk/gtkprogressbar.c:217 +#: ../gtk/gtkprogressbar.c:249 msgid "Minimum horizontal height of the progress bar" msgstr "Minimum horizontal height of the progress bar" -#: ../gtk/gtkprogressbar.c:229 +#: ../gtk/gtkprogressbar.c:261 msgid "Minimum vertical bar width" msgstr "Minimum vertical bar width" -#: ../gtk/gtkprogressbar.c:230 +#: ../gtk/gtkprogressbar.c:262 msgid "The minimum vertical width of the progress bar" msgstr "The minimum vertical width of the progress bar" -#: ../gtk/gtkprogressbar.c:242 +#: ../gtk/gtkprogressbar.c:274 msgid "Minimum vertical bar height" msgstr "Minimum vertical bar height" -#: ../gtk/gtkprogressbar.c:243 +#: ../gtk/gtkprogressbar.c:275 msgid "The minimum vertical height of the progress bar" msgstr "The minimum vertical height of the progress bar" @@ -4329,7 +4350,7 @@ msgstr "" "The value returned by gtk_radio_action_get_current_value() when this action " "is the current action of its group." -#: ../gtk/gtkradioaction.c:135 ../gtk/gtkradiobutton.c:160 +#: ../gtk/gtkradioaction.c:135 ../gtk/gtkradiobutton.c:163 #: ../gtk/gtkradiomenuitem.c:373 ../gtk/gtkradiotoolbutton.c:65 msgid "Group" msgstr "Group" @@ -4350,7 +4371,7 @@ msgstr "" "The value property of the currently active member of the group to which this " "action belongs." -#: ../gtk/gtkradiobutton.c:161 +#: ../gtk/gtkradiobutton.c:164 msgid "The radio button whose group this widget belongs to." msgstr "The radio button whose group this widget belongs to." @@ -4362,27 +4383,27 @@ msgstr "The radio menu item whose group this widget belongs to." msgid "The radio tool button whose group this button belongs to." msgstr "The radio tool button whose group this button belongs to." -#: ../gtk/gtkrange.c:416 +#: ../gtk/gtkrange.c:423 msgid "Update policy" msgstr "Update policy" -#: ../gtk/gtkrange.c:417 +#: ../gtk/gtkrange.c:424 msgid "How the range should be updated on the screen" msgstr "How the range should be updated on the screen" -#: ../gtk/gtkrange.c:426 +#: ../gtk/gtkrange.c:433 msgid "The GtkAdjustment that contains the current value of this range object" msgstr "The GtkAdjustment that contains the current value of this range object" -#: ../gtk/gtkrange.c:434 +#: ../gtk/gtkrange.c:441 msgid "Invert direction slider moves to increase range value" msgstr "Invert direction slider moves to increase range value" -#: ../gtk/gtkrange.c:441 +#: ../gtk/gtkrange.c:448 msgid "Lower stepper sensitivity" msgstr "Lower stepper sensitivity" -#: ../gtk/gtkrange.c:442 +#: ../gtk/gtkrange.c:449 msgid "" "The sensitivity policy for the stepper that points to the adjustment's lower " "side" @@ -4390,11 +4411,11 @@ msgstr "" "The sensitivity policy for the stepper that points to the adjustment's lower " "side" -#: ../gtk/gtkrange.c:450 +#: ../gtk/gtkrange.c:457 msgid "Upper stepper sensitivity" msgstr "Upper stepper sensitivity" -#: ../gtk/gtkrange.c:451 +#: ../gtk/gtkrange.c:458 msgid "" "The sensitivity policy for the stepper that points to the adjustment's upper " "side" @@ -4402,87 +4423,87 @@ msgstr "" "The sensitivity policy for the stepper that points to the adjustment's upper " "side" -#: ../gtk/gtkrange.c:468 +#: ../gtk/gtkrange.c:475 msgid "Show Fill Level" msgstr "Show Fill Level" -#: ../gtk/gtkrange.c:469 +#: ../gtk/gtkrange.c:476 msgid "Whether to display a fill level indicator graphics on trough." msgstr "Whether to display a fill level indicator graphics on trough." -#: ../gtk/gtkrange.c:485 +#: ../gtk/gtkrange.c:492 msgid "Restrict to Fill Level" msgstr "Restrict to Fill Level" -#: ../gtk/gtkrange.c:486 +#: ../gtk/gtkrange.c:493 msgid "Whether to restrict the upper boundary to the fill level." msgstr "Whether to restrict the upper boundary to the fill level." -#: ../gtk/gtkrange.c:501 +#: ../gtk/gtkrange.c:508 msgid "Fill Level" msgstr "Fill Level" -#: ../gtk/gtkrange.c:502 +#: ../gtk/gtkrange.c:509 msgid "The fill level." msgstr "The fill level." -#: ../gtk/gtkrange.c:510 +#: ../gtk/gtkrange.c:517 ../gtk/gtkswitch.c:772 msgid "Slider Width" msgstr "Slider Width" -#: ../gtk/gtkrange.c:511 +#: ../gtk/gtkrange.c:518 msgid "Width of scrollbar or scale thumb" msgstr "Width of scrollbar or scale thumb" -#: ../gtk/gtkrange.c:518 +#: ../gtk/gtkrange.c:525 msgid "Trough Border" msgstr "Trough Border" -#: ../gtk/gtkrange.c:519 +#: ../gtk/gtkrange.c:526 msgid "Spacing between thumb/steppers and outer trough bevel" msgstr "Spacing between thumb/steppers and outer trough bevel" -#: ../gtk/gtkrange.c:526 +#: ../gtk/gtkrange.c:533 msgid "Stepper Size" msgstr "Stepper Size" -#: ../gtk/gtkrange.c:527 +#: ../gtk/gtkrange.c:534 msgid "Length of step buttons at ends" msgstr "Length of step buttons at ends" -#: ../gtk/gtkrange.c:542 +#: ../gtk/gtkrange.c:549 msgid "Stepper Spacing" msgstr "Stepper Spacing" -#: ../gtk/gtkrange.c:543 +#: ../gtk/gtkrange.c:550 msgid "Spacing between step buttons and thumb" msgstr "Spacing between step buttons and thumb" -#: ../gtk/gtkrange.c:550 +#: ../gtk/gtkrange.c:557 msgid "Arrow X Displacement" msgstr "Arrow X Displacement" -#: ../gtk/gtkrange.c:551 +#: ../gtk/gtkrange.c:558 msgid "" "How far in the x direction to move the arrow when the button is depressed" msgstr "" "How far in the x direction to move the arrow when the button is depressed" -#: ../gtk/gtkrange.c:558 +#: ../gtk/gtkrange.c:565 msgid "Arrow Y Displacement" msgstr "Arrow Y Displacement" -#: ../gtk/gtkrange.c:559 +#: ../gtk/gtkrange.c:566 msgid "" "How far in the y direction to move the arrow when the button is depressed" msgstr "" "How far in the y direction to move the arrow when the button is depressed" -#: ../gtk/gtkrange.c:577 +#: ../gtk/gtkrange.c:584 msgid "Trough Under Steppers" msgstr "Trough Under Steppers" -#: ../gtk/gtkrange.c:578 +#: ../gtk/gtkrange.c:585 msgid "" "Whether to draw trough for full length of range or exclude the steppers and " "spacing" @@ -4490,11 +4511,11 @@ msgstr "" "Whether to draw trough for full length of range or exclude the steppers and " "spacing" -#: ../gtk/gtkrange.c:591 +#: ../gtk/gtkrange.c:598 msgid "Arrow scaling" msgstr "Arrow scaling" -#: ../gtk/gtkrange.c:592 +#: ../gtk/gtkrange.c:599 msgid "Arrow scaling with regard to scroll button size" msgstr "Arrow scaling with regard to scroll button size" @@ -4587,42 +4608,6 @@ msgstr "The full path to the file to be used to store and read the list" msgid "The size of the recently used resources list" msgstr "The size of the recently used resources list" -#: ../gtk/gtkruler.c:138 -msgid "Lower" -msgstr "Lower" - -#: ../gtk/gtkruler.c:139 -msgid "Lower limit of ruler" -msgstr "Lower limit of ruler" - -#: ../gtk/gtkruler.c:148 -msgid "Upper" -msgstr "Upper" - -#: ../gtk/gtkruler.c:149 -msgid "Upper limit of ruler" -msgstr "Upper limit of ruler" - -#: ../gtk/gtkruler.c:159 -msgid "Position of mark on the ruler" -msgstr "Position of mark on the ruler" - -#: ../gtk/gtkruler.c:168 -msgid "Max Size" -msgstr "Max Size" - -#: ../gtk/gtkruler.c:169 -msgid "Maximum size of the ruler" -msgstr "Maximum size of the ruler" - -#: ../gtk/gtkruler.c:184 -msgid "Metric" -msgstr "Metric" - -#: ../gtk/gtkruler.c:185 -msgid "The metric used for the ruler" -msgstr "The metric used for the ruler" - #: ../gtk/gtkscalebutton.c:221 msgid "The value of the scale" msgstr "The value of the scale" @@ -4645,39 +4630,39 @@ msgstr "Icons" msgid "List of icon names" msgstr "List of icon names" -#: ../gtk/gtkscale.c:245 +#: ../gtk/gtkscale.c:255 msgid "The number of decimal places that are displayed in the value" msgstr "The number of decimal places that are displayed in the value" -#: ../gtk/gtkscale.c:254 +#: ../gtk/gtkscale.c:264 msgid "Draw Value" msgstr "Draw Value" -#: ../gtk/gtkscale.c:255 +#: ../gtk/gtkscale.c:265 msgid "Whether the current value is displayed as a string next to the slider" msgstr "Whether the current value is displayed as a string next to the slider" -#: ../gtk/gtkscale.c:262 +#: ../gtk/gtkscale.c:272 msgid "Value Position" msgstr "Value Position" -#: ../gtk/gtkscale.c:263 +#: ../gtk/gtkscale.c:273 msgid "The position in which the current value is displayed" msgstr "The position in which the current value is displayed" -#: ../gtk/gtkscale.c:270 +#: ../gtk/gtkscale.c:280 msgid "Slider Length" msgstr "Slider Length" -#: ../gtk/gtkscale.c:271 +#: ../gtk/gtkscale.c:281 msgid "Length of scale's slider" msgstr "Length of scale's slider" -#: ../gtk/gtkscale.c:279 +#: ../gtk/gtkscale.c:289 msgid "Value spacing" msgstr "Value spacing" -#: ../gtk/gtkscale.c:280 +#: ../gtk/gtkscale.c:290 msgid "Space between value text and the slider/trough area" msgstr "Space between value text and the slider/trough area" @@ -4808,19 +4793,19 @@ msgid "" msgstr "" "The minimum height that the scrolled window will allocate to its content" -#: ../gtk/gtkseparatortoolitem.c:138 +#: ../gtk/gtkseparatortoolitem.c:143 msgid "Draw" msgstr "Draw" -#: ../gtk/gtkseparatortoolitem.c:139 +#: ../gtk/gtkseparatortoolitem.c:144 msgid "Whether the separator is drawn, or just blank" msgstr "Whether the separator is drawn, or just blank" -#: ../gtk/gtksettings.c:241 +#: ../gtk/gtksettings.c:277 msgid "Double Click Time" msgstr "Double Click Time" -#: ../gtk/gtksettings.c:242 +#: ../gtk/gtksettings.c:278 msgid "" "Maximum time allowed between two clicks for them to be considered a double " "click (in milliseconds)" @@ -4828,11 +4813,11 @@ msgstr "" "Maximum time allowed between two clicks for them to be considered a double " "click (in milliseconds)" -#: ../gtk/gtksettings.c:249 +#: ../gtk/gtksettings.c:285 msgid "Double Click Distance" msgstr "Double Click Distance" -#: ../gtk/gtksettings.c:250 +#: ../gtk/gtksettings.c:286 msgid "" "Maximum distance allowed between two clicks for them to be considered a " "double click (in pixels)" @@ -4840,35 +4825,35 @@ msgstr "" "Maximum distance allowed between two clicks for them to be considered a " "double click (in pixels)" -#: ../gtk/gtksettings.c:266 +#: ../gtk/gtksettings.c:302 msgid "Cursor Blink" msgstr "Cursor Blink" -#: ../gtk/gtksettings.c:267 +#: ../gtk/gtksettings.c:303 msgid "Whether the cursor should blink" msgstr "Whether the cursor should blink" -#: ../gtk/gtksettings.c:274 +#: ../gtk/gtksettings.c:310 msgid "Cursor Blink Time" msgstr "Cursor Blink Time" -#: ../gtk/gtksettings.c:275 +#: ../gtk/gtksettings.c:311 msgid "Length of the cursor blink cycle, in milliseconds" msgstr "Length of the cursor blink cycle, in milliseconds" -#: ../gtk/gtksettings.c:294 +#: ../gtk/gtksettings.c:330 msgid "Cursor Blink Timeout" msgstr "Cursor Blink Timeout" -#: ../gtk/gtksettings.c:295 +#: ../gtk/gtksettings.c:331 msgid "Time after which the cursor stops blinking, in seconds" msgstr "Time after which the cursor stops blinking, in seconds" -#: ../gtk/gtksettings.c:302 +#: ../gtk/gtksettings.c:338 msgid "Split Cursor" msgstr "Split Cursor" -#: ../gtk/gtksettings.c:303 +#: ../gtk/gtksettings.c:339 msgid "" "Whether two cursors should be displayed for mixed left-to-right and right-to-" "left text" @@ -4876,149 +4861,149 @@ msgstr "" "Whether two cursors should be displayed for mixed left-to-right and right-to-" "left text" -#: ../gtk/gtksettings.c:310 +#: ../gtk/gtksettings.c:346 msgid "Theme Name" msgstr "Theme Name" -#: ../gtk/gtksettings.c:311 +#: ../gtk/gtksettings.c:347 msgid "Name of theme RC file to load" msgstr "Name of theme RC file to load" -#: ../gtk/gtksettings.c:319 +#: ../gtk/gtksettings.c:355 msgid "Icon Theme Name" msgstr "Icon Theme Name" -#: ../gtk/gtksettings.c:320 +#: ../gtk/gtksettings.c:356 msgid "Name of icon theme to use" msgstr "Name of icon theme to use" -#: ../gtk/gtksettings.c:328 +#: ../gtk/gtksettings.c:364 msgid "Fallback Icon Theme Name" msgstr "Fallback Icon Theme Name" -#: ../gtk/gtksettings.c:329 +#: ../gtk/gtksettings.c:365 msgid "Name of a icon theme to fall back to" msgstr "Name of a icon theme to fall back to" -#: ../gtk/gtksettings.c:337 +#: ../gtk/gtksettings.c:373 msgid "Key Theme Name" msgstr "Key Theme Name" -#: ../gtk/gtksettings.c:338 +#: ../gtk/gtksettings.c:374 msgid "Name of key theme RC file to load" msgstr "Name of key theme RC file to load" -#: ../gtk/gtksettings.c:346 +#: ../gtk/gtksettings.c:382 msgid "Menu bar accelerator" msgstr "Menu bar accelerator" -#: ../gtk/gtksettings.c:347 +#: ../gtk/gtksettings.c:383 msgid "Keybinding to activate the menu bar" msgstr "Keybinding to activate the menu bar" -#: ../gtk/gtksettings.c:355 +#: ../gtk/gtksettings.c:391 msgid "Drag threshold" msgstr "Drag threshold" -#: ../gtk/gtksettings.c:356 +#: ../gtk/gtksettings.c:392 msgid "Number of pixels the cursor can move before dragging" msgstr "Number of pixels the cursor can move before dragging" -#: ../gtk/gtksettings.c:364 +#: ../gtk/gtksettings.c:400 msgid "Font Name" msgstr "Font Name" -#: ../gtk/gtksettings.c:365 +#: ../gtk/gtksettings.c:401 msgid "Name of default font to use" msgstr "Name of default font to use" -#: ../gtk/gtksettings.c:387 +#: ../gtk/gtksettings.c:423 msgid "Icon Sizes" msgstr "Icon Sizes" -#: ../gtk/gtksettings.c:388 +#: ../gtk/gtksettings.c:424 msgid "List of icon sizes (gtk-menu=16,16:gtk-button=20,20..." msgstr "List of icon sizes (gtk-menu=16,16:gtk-button=20,20..." -#: ../gtk/gtksettings.c:396 +#: ../gtk/gtksettings.c:432 msgid "GTK Modules" msgstr "GTK Modules" -#: ../gtk/gtksettings.c:397 +#: ../gtk/gtksettings.c:433 msgid "List of currently active GTK modules" msgstr "List of currently active GTK modules" -#: ../gtk/gtksettings.c:406 +#: ../gtk/gtksettings.c:442 msgid "Xft Antialias" msgstr "Xft Antialias" -#: ../gtk/gtksettings.c:407 +#: ../gtk/gtksettings.c:443 msgid "Whether to antialias Xft fonts; 0=no, 1=yes, -1=default" msgstr "Whether to antialias Xft fonts; 0=no, 1=yes, -1=default" -#: ../gtk/gtksettings.c:416 +#: ../gtk/gtksettings.c:452 msgid "Xft Hinting" msgstr "Xft Hinting" -#: ../gtk/gtksettings.c:417 +#: ../gtk/gtksettings.c:453 msgid "Whether to hint Xft fonts; 0=no, 1=yes, -1=default" msgstr "Whether to hint Xft fonts; 0=no, 1=yes, -1=default" -#: ../gtk/gtksettings.c:426 +#: ../gtk/gtksettings.c:462 msgid "Xft Hint Style" msgstr "Xft Hint Style" -#: ../gtk/gtksettings.c:427 +#: ../gtk/gtksettings.c:463 msgid "" "What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull" msgstr "" "What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull" -#: ../gtk/gtksettings.c:436 +#: ../gtk/gtksettings.c:472 msgid "Xft RGBA" msgstr "Xft RGBA" -#: ../gtk/gtksettings.c:437 +#: ../gtk/gtksettings.c:473 msgid "Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr" msgstr "Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr" -#: ../gtk/gtksettings.c:446 +#: ../gtk/gtksettings.c:482 msgid "Xft DPI" msgstr "Xft DPI" -#: ../gtk/gtksettings.c:447 +#: ../gtk/gtksettings.c:483 msgid "Resolution for Xft, in 1024 * dots/inch. -1 to use default value" msgstr "Resolution for Xft, in 1024 * dots/inch. -1 to use default value" -#: ../gtk/gtksettings.c:456 +#: ../gtk/gtksettings.c:492 msgid "Cursor theme name" msgstr "Cursor theme name" -#: ../gtk/gtksettings.c:457 +#: ../gtk/gtksettings.c:493 msgid "Name of the cursor theme to use, or NULL to use the default theme" msgstr "Name of the cursor theme to use, or NULL to use the default theme" -#: ../gtk/gtksettings.c:465 +#: ../gtk/gtksettings.c:501 msgid "Cursor theme size" msgstr "Cursor theme size" -#: ../gtk/gtksettings.c:466 +#: ../gtk/gtksettings.c:502 msgid "Size to use for cursors, or 0 to use the default size" msgstr "Size to use for cursors, or 0 to use the default size" -#: ../gtk/gtksettings.c:476 +#: ../gtk/gtksettings.c:512 msgid "Alternative button order" msgstr "Alternative button order" -#: ../gtk/gtksettings.c:477 +#: ../gtk/gtksettings.c:513 msgid "Whether buttons in dialogs should use the alternative button order" msgstr "Whether buttons in dialogs should use the alternative button order" -#: ../gtk/gtksettings.c:494 +#: ../gtk/gtksettings.c:530 msgid "Alternative sort indicator direction" msgstr "Alternative sort indicator direction" -#: ../gtk/gtksettings.c:495 +#: ../gtk/gtksettings.c:531 msgid "" "Whether the direction of the sort indicators in list and tree views is " "inverted compared to the default (where down means ascending)" @@ -5026,11 +5011,11 @@ msgstr "" "Whether the direction of the sort indicators in list and tree views is " "inverted compared to the default (where down means ascending)" -#: ../gtk/gtksettings.c:503 +#: ../gtk/gtksettings.c:539 msgid "Show the 'Input Methods' menu" msgstr "Show the 'Input Methods' menu" -#: ../gtk/gtksettings.c:504 +#: ../gtk/gtksettings.c:540 msgid "" "Whether the context menus of entries and text views should offer to change " "the input method" @@ -5038,11 +5023,11 @@ msgstr "" "Whether the context menus of entries and text views should offer to change " "the input method" -#: ../gtk/gtksettings.c:512 +#: ../gtk/gtksettings.c:548 msgid "Show the 'Insert Unicode Control Character' menu" msgstr "Show the 'Insert Unicode Control Character' menu" -#: ../gtk/gtksettings.c:513 +#: ../gtk/gtksettings.c:549 msgid "" "Whether the context menus of entries and text views should offer to insert " "control characters" @@ -5050,238 +5035,238 @@ msgstr "" "Whether the context menus of entries and text views should offer to insert " "control characters" -#: ../gtk/gtksettings.c:521 +#: ../gtk/gtksettings.c:557 msgid "Start timeout" msgstr "Start timeout" -#: ../gtk/gtksettings.c:522 +#: ../gtk/gtksettings.c:558 msgid "Starting value for timeouts, when button is pressed" msgstr "Starting value for timeouts, when button is pressed" -#: ../gtk/gtksettings.c:531 +#: ../gtk/gtksettings.c:567 msgid "Repeat timeout" msgstr "Repeat timeout" -#: ../gtk/gtksettings.c:532 +#: ../gtk/gtksettings.c:568 msgid "Repeat value for timeouts, when button is pressed" msgstr "Repeat value for timeouts, when button is pressed" -#: ../gtk/gtksettings.c:541 +#: ../gtk/gtksettings.c:577 msgid "Expand timeout" msgstr "Expand timeout" -#: ../gtk/gtksettings.c:542 +#: ../gtk/gtksettings.c:578 msgid "Expand value for timeouts, when a widget is expanding a new region" msgstr "Expand value for timeouts, when a widget is expanding a new region" -#: ../gtk/gtksettings.c:577 +#: ../gtk/gtksettings.c:613 msgid "Color scheme" msgstr "Color scheme" -#: ../gtk/gtksettings.c:578 +#: ../gtk/gtksettings.c:614 msgid "A palette of named colors for use in themes" msgstr "A palette of named colors for use in themes" -#: ../gtk/gtksettings.c:587 +#: ../gtk/gtksettings.c:623 msgid "Enable Animations" msgstr "Enable Animations" -#: ../gtk/gtksettings.c:588 +#: ../gtk/gtksettings.c:624 msgid "Whether to enable toolkit-wide animations." msgstr "Whether to enable toolkit-wide animations." -#: ../gtk/gtksettings.c:606 +#: ../gtk/gtksettings.c:642 msgid "Enable Touchscreen Mode" msgstr "Enable Touchscreen Mode" -#: ../gtk/gtksettings.c:607 +#: ../gtk/gtksettings.c:643 msgid "When TRUE, there are no motion notify events delivered on this screen" msgstr "When TRUE, there are no motion notify events delivered on this screen" -#: ../gtk/gtksettings.c:624 +#: ../gtk/gtksettings.c:660 msgid "Tooltip timeout" msgstr "Tooltip timeout" -#: ../gtk/gtksettings.c:625 +#: ../gtk/gtksettings.c:661 msgid "Timeout before tooltip is shown" msgstr "Timeout before tooltip is shown" -#: ../gtk/gtksettings.c:650 +#: ../gtk/gtksettings.c:686 msgid "Tooltip browse timeout" msgstr "Tooltip browse timeout" -#: ../gtk/gtksettings.c:651 +#: ../gtk/gtksettings.c:687 msgid "Timeout before tooltip is shown when browse mode is enabled" msgstr "Timeout before tooltip is shown when browse mode is enabled" -#: ../gtk/gtksettings.c:672 +#: ../gtk/gtksettings.c:708 msgid "Tooltip browse mode timeout" msgstr "Tooltip browse mode timeout" -#: ../gtk/gtksettings.c:673 +#: ../gtk/gtksettings.c:709 msgid "Timeout after which browse mode is disabled" msgstr "Timeout after which browse mode is disabled" -#: ../gtk/gtksettings.c:692 +#: ../gtk/gtksettings.c:728 msgid "Keynav Cursor Only" msgstr "Keynav Cursor Only" -#: ../gtk/gtksettings.c:693 +#: ../gtk/gtksettings.c:729 msgid "When TRUE, there are only cursor keys available to navigate widgets" msgstr "When TRUE, there are only cursor keys available to navigate widgets" -#: ../gtk/gtksettings.c:710 +#: ../gtk/gtksettings.c:746 msgid "Keynav Wrap Around" msgstr "Keynav Wrap Around" -#: ../gtk/gtksettings.c:711 +#: ../gtk/gtksettings.c:747 msgid "Whether to wrap around when keyboard-navigating widgets" msgstr "Whether to wrap around when keyboard-navigating widgets" -#: ../gtk/gtksettings.c:731 +#: ../gtk/gtksettings.c:767 msgid "Error Bell" msgstr "Error Bell" -#: ../gtk/gtksettings.c:732 +#: ../gtk/gtksettings.c:768 msgid "When TRUE, keyboard navigation and other errors will cause a beep" msgstr "When TRUE, keyboard navigation and other errors will cause a beep" -#: ../gtk/gtksettings.c:749 +#: ../gtk/gtksettings.c:785 msgid "Color Hash" msgstr "Color Hash" -#: ../gtk/gtksettings.c:750 +#: ../gtk/gtksettings.c:786 msgid "A hash table representation of the color scheme." msgstr "A hash table representation of the color scheme." -#: ../gtk/gtksettings.c:758 +#: ../gtk/gtksettings.c:794 msgid "Default file chooser backend" msgstr "Default file chooser backend" -#: ../gtk/gtksettings.c:759 +#: ../gtk/gtksettings.c:795 msgid "Name of the GtkFileChooser backend to use by default" msgstr "Name of the GtkFileChooser backend to use by default" -#: ../gtk/gtksettings.c:776 +#: ../gtk/gtksettings.c:812 msgid "Default print backend" msgstr "Default print backend" -#: ../gtk/gtksettings.c:777 +#: ../gtk/gtksettings.c:813 msgid "List of the GtkPrintBackend backends to use by default" msgstr "List of the GtkPrintBackend backends to use by default" -#: ../gtk/gtksettings.c:800 +#: ../gtk/gtksettings.c:836 msgid "Default command to run when displaying a print preview" msgstr "Default command to run when displaying a print preview" -#: ../gtk/gtksettings.c:801 +#: ../gtk/gtksettings.c:837 msgid "Command to run when displaying a print preview" msgstr "Command to run when displaying a print preview" -#: ../gtk/gtksettings.c:817 +#: ../gtk/gtksettings.c:853 msgid "Enable Mnemonics" msgstr "Enable Mnemonics" -#: ../gtk/gtksettings.c:818 +#: ../gtk/gtksettings.c:854 msgid "Whether labels should have mnemonics" msgstr "Whether labels should have mnemonics" -#: ../gtk/gtksettings.c:834 +#: ../gtk/gtksettings.c:870 msgid "Enable Accelerators" msgstr "Enable Accelerators" -#: ../gtk/gtksettings.c:835 +#: ../gtk/gtksettings.c:871 msgid "Whether menu items should have accelerators" msgstr "Whether menu items should have accelerators" -#: ../gtk/gtksettings.c:852 +#: ../gtk/gtksettings.c:888 msgid "Recent Files Limit" msgstr "Recent Files Limit" -#: ../gtk/gtksettings.c:853 +#: ../gtk/gtksettings.c:889 msgid "Number of recently used files" msgstr "Number of recently used files" -#: ../gtk/gtksettings.c:871 +#: ../gtk/gtksettings.c:907 msgid "Default IM module" msgstr "Default IM module" -#: ../gtk/gtksettings.c:872 +#: ../gtk/gtksettings.c:908 msgid "Which IM module should be used by default" msgstr "Which IM module should be used by default" -#: ../gtk/gtksettings.c:890 +#: ../gtk/gtksettings.c:926 msgid "Recent Files Max Age" msgstr "Recent Files Max Age" -#: ../gtk/gtksettings.c:891 +#: ../gtk/gtksettings.c:927 msgid "Maximum age of recently used files, in days" msgstr "Maximum age of recently used files, in days" -#: ../gtk/gtksettings.c:900 +#: ../gtk/gtksettings.c:936 msgid "Fontconfig configuration timestamp" msgstr "Fontconfig configuration timestamp" -#: ../gtk/gtksettings.c:901 +#: ../gtk/gtksettings.c:937 msgid "Timestamp of current fontconfig configuration" msgstr "Timestamp of current fontconfig configuration" -#: ../gtk/gtksettings.c:923 +#: ../gtk/gtksettings.c:959 msgid "Sound Theme Name" msgstr "Sound Theme Name" -#: ../gtk/gtksettings.c:924 +#: ../gtk/gtksettings.c:960 msgid "XDG sound theme name" msgstr "XDG sound theme name" #. Translators: this means sounds that are played as feedback to user input -#: ../gtk/gtksettings.c:946 +#: ../gtk/gtksettings.c:982 msgid "Audible Input Feedback" msgstr "Audible Input Feedback" -#: ../gtk/gtksettings.c:947 +#: ../gtk/gtksettings.c:983 msgid "Whether to play event sounds as feedback to user input" msgstr "Whether to play event sounds as feedback to user input" -#: ../gtk/gtksettings.c:968 +#: ../gtk/gtksettings.c:1004 msgid "Enable Event Sounds" msgstr "Enable Event Sounds" -#: ../gtk/gtksettings.c:969 +#: ../gtk/gtksettings.c:1005 msgid "Whether to play any event sounds at all" msgstr "Whether to play any event sounds at all" -#: ../gtk/gtksettings.c:984 +#: ../gtk/gtksettings.c:1020 msgid "Enable Tooltips" msgstr "Enable Tooltips" -#: ../gtk/gtksettings.c:985 +#: ../gtk/gtksettings.c:1021 msgid "Whether tooltips should be shown on widgets" msgstr "Whether tooltips should be shown on widgets" -#: ../gtk/gtksettings.c:998 +#: ../gtk/gtksettings.c:1034 msgid "Toolbar style" msgstr "Toolbar style" -#: ../gtk/gtksettings.c:999 +#: ../gtk/gtksettings.c:1035 msgid "" "Whether default toolbars have text only, text and icons, icons only, etc." msgstr "" "Whether default toolbars have text only, text and icons, icons only, etc." -#: ../gtk/gtksettings.c:1013 +#: ../gtk/gtksettings.c:1049 msgid "Toolbar Icon Size" msgstr "Toolbar Icon Size" -#: ../gtk/gtksettings.c:1014 +#: ../gtk/gtksettings.c:1050 msgid "The size of icons in default toolbars." msgstr "The size of icons in default toolbars." -#: ../gtk/gtksettings.c:1031 +#: ../gtk/gtksettings.c:1067 msgid "Auto Mnemonics" msgstr "Auto Mnemonics" -#: ../gtk/gtksettings.c:1032 +#: ../gtk/gtksettings.c:1068 msgid "" "Whether mnemonics should be automatically shown and hidden when the user " "presses the mnemonic activator." @@ -5289,59 +5274,59 @@ msgstr "" "Whether mnemonics should be automatically shown and hidden when the user " "presses the mnemonic activator." -#: ../gtk/gtksettings.c:1057 +#: ../gtk/gtksettings.c:1093 msgid "Application prefers a dark theme" msgstr "Application prefers a dark theme" -#: ../gtk/gtksettings.c:1058 +#: ../gtk/gtksettings.c:1094 msgid "Whether the application prefers to have a dark theme." msgstr "Whether the application prefers to have a dark theme." -#: ../gtk/gtksettings.c:1073 +#: ../gtk/gtksettings.c:1109 msgid "Show button images" msgstr "Show button images" -#: ../gtk/gtksettings.c:1074 +#: ../gtk/gtksettings.c:1110 msgid "Whether images should be shown on buttons" msgstr "Whether images should be shown on buttons" -#: ../gtk/gtksettings.c:1082 ../gtk/gtksettings.c:1176 +#: ../gtk/gtksettings.c:1118 ../gtk/gtksettings.c:1212 msgid "Select on focus" msgstr "Select on focus" -#: ../gtk/gtksettings.c:1083 +#: ../gtk/gtksettings.c:1119 msgid "Whether to select the contents of an entry when it is focused" msgstr "Whether to select the contents of an entry when it is focused" -#: ../gtk/gtksettings.c:1100 +#: ../gtk/gtksettings.c:1136 msgid "Password Hint Timeout" msgstr "Password Hint Timeout" -#: ../gtk/gtksettings.c:1101 +#: ../gtk/gtksettings.c:1137 msgid "How long to show the last input character in hidden entries" msgstr "How long to show the last input character in hidden entries" -#: ../gtk/gtksettings.c:1110 +#: ../gtk/gtksettings.c:1146 msgid "Show menu images" msgstr "Show menu images" -#: ../gtk/gtksettings.c:1111 +#: ../gtk/gtksettings.c:1147 msgid "Whether images should be shown in menus" msgstr "Whether images should be shown in menus" -#: ../gtk/gtksettings.c:1119 +#: ../gtk/gtksettings.c:1155 msgid "Delay before drop down menus appear" msgstr "Delay before drop down menus appear" -#: ../gtk/gtksettings.c:1120 +#: ../gtk/gtksettings.c:1156 msgid "Delay before the submenus of a menu bar appear" msgstr "Delay before the submenus of a menu bar appear" -#: ../gtk/gtksettings.c:1137 +#: ../gtk/gtksettings.c:1173 msgid "Scrolled Window Placement" msgstr "Scrolled Window Placement" -#: ../gtk/gtksettings.c:1138 +#: ../gtk/gtksettings.c:1174 msgid "" "Where the contents of scrolled windows are located with respect to the " "scrollbars, if not overridden by the scrolled window's own placement." @@ -5349,31 +5334,31 @@ msgstr "" "Where the contents of scrolled windows are located with respect to the " "scrollbars, if not overridden by the scrolled window's own placement." -#: ../gtk/gtksettings.c:1147 +#: ../gtk/gtksettings.c:1183 msgid "Can change accelerators" msgstr "Can change accelerators" -#: ../gtk/gtksettings.c:1148 +#: ../gtk/gtksettings.c:1184 msgid "" "Whether menu accelerators can be changed by pressing a key over the menu item" msgstr "" "Whether menu accelerators can be changed by pressing a key over the menu item" -#: ../gtk/gtksettings.c:1156 +#: ../gtk/gtksettings.c:1192 msgid "Delay before submenus appear" msgstr "Delay before submenus appear" -#: ../gtk/gtksettings.c:1157 +#: ../gtk/gtksettings.c:1193 msgid "" "Minimum time the pointer must stay over a menu item before the submenu appear" msgstr "" "Minimum time the pointer must stay over a menu item before the submenu appear" -#: ../gtk/gtksettings.c:1166 +#: ../gtk/gtksettings.c:1202 msgid "Delay before hiding a submenu" msgstr "Delay before hiding a submenu" -#: ../gtk/gtksettings.c:1167 +#: ../gtk/gtksettings.c:1203 msgid "" "The time before hiding a submenu when the pointer is moving towards the " "submenu" @@ -5381,32 +5366,32 @@ msgstr "" "The time before hiding a submenu when the pointer is moving towards the " "submenu" -#: ../gtk/gtksettings.c:1177 +#: ../gtk/gtksettings.c:1213 msgid "Whether to select the contents of a selectable label when it is focused" msgstr "" "Whether to select the contents of a selectable label when it is focused" -#: ../gtk/gtksettings.c:1185 +#: ../gtk/gtksettings.c:1221 msgid "Custom palette" msgstr "Custom palette" -#: ../gtk/gtksettings.c:1186 +#: ../gtk/gtksettings.c:1222 msgid "Palette to use in the color selector" msgstr "Palette to use in the color selector" -#: ../gtk/gtksettings.c:1194 +#: ../gtk/gtksettings.c:1230 msgid "IM Preedit style" msgstr "IM Preedit style" -#: ../gtk/gtksettings.c:1195 +#: ../gtk/gtksettings.c:1231 msgid "How to draw the input method preedit string" msgstr "How to draw the input method preedit string" -#: ../gtk/gtksettings.c:1204 +#: ../gtk/gtksettings.c:1240 msgid "IM Status style" msgstr "IM Status style" -#: ../gtk/gtksettings.c:1205 +#: ../gtk/gtksettings.c:1241 msgid "How to draw the input method statusbar" msgstr "How to draw the input method statusbar" @@ -5432,15 +5417,15 @@ msgid "" msgstr "" "If TRUE, unmapped widgets are ignored when determining the size of the group" -#: ../gtk/gtkspinbutton.c:236 +#: ../gtk/gtkspinbutton.c:238 msgid "Climb Rate" msgstr "Climb Rate" -#: ../gtk/gtkspinbutton.c:256 +#: ../gtk/gtkspinbutton.c:258 msgid "Snap to Ticks" msgstr "Snap to Ticks" -#: ../gtk/gtkspinbutton.c:257 +#: ../gtk/gtkspinbutton.c:259 msgid "" "Whether erroneous values are automatically changed to a spin button's " "nearest step increment" @@ -5448,37 +5433,37 @@ msgstr "" "Whether erroneous values are automatically changed to a spin button's " "nearest step increment" -#: ../gtk/gtkspinbutton.c:264 +#: ../gtk/gtkspinbutton.c:266 msgid "Numeric" msgstr "Numeric" -#: ../gtk/gtkspinbutton.c:265 +#: ../gtk/gtkspinbutton.c:267 msgid "Whether non-numeric characters should be ignored" msgstr "Whether non-numeric characters should be ignored" -#: ../gtk/gtkspinbutton.c:272 +#: ../gtk/gtkspinbutton.c:274 msgid "Wrap" msgstr "Wrap" -#: ../gtk/gtkspinbutton.c:273 +#: ../gtk/gtkspinbutton.c:275 msgid "Whether a spin button should wrap upon reaching its limits" msgstr "Whether a spin button should wrap upon reaching its limits" -#: ../gtk/gtkspinbutton.c:280 +#: ../gtk/gtkspinbutton.c:282 msgid "Update Policy" msgstr "Update Policy" -#: ../gtk/gtkspinbutton.c:281 +#: ../gtk/gtkspinbutton.c:283 msgid "" "Whether the spin button should update always, or only when the value is legal" msgstr "" "Whether the spin button should update always, or only when the value is legal" -#: ../gtk/gtkspinbutton.c:290 +#: ../gtk/gtkspinbutton.c:292 msgid "Reads the current value, or sets a new value" msgstr "Reads the current value, or sets a new value" -#: ../gtk/gtkspinbutton.c:299 +#: ../gtk/gtkspinbutton.c:301 msgid "Style of bevel around the spin button" msgstr "Style of bevel around the spin button" @@ -5510,7 +5495,7 @@ msgid "" msgstr "" "The length of time in milliseconds for the spinner to complete a full loop" -#: ../gtk/gtkstatusbar.c:179 +#: ../gtk/gtkstatusbar.c:181 msgid "Style of bevel around the statusbar text" msgstr "Style of bevel around the statusbar text" @@ -5534,7 +5519,7 @@ msgstr "Whether the status icon is embedded" msgid "The orientation of the tray" msgstr "The orientation of the tray" -#: ../gtk/gtkstatusicon.c:347 ../gtk/gtkwidget.c:1084 +#: ../gtk/gtkstatusicon.c:347 ../gtk/gtkwidget.c:1022 msgid "Has tooltip" msgstr "Has tooltip" @@ -5542,15 +5527,15 @@ msgstr "Has tooltip" msgid "Whether this tray icon has a tooltip" msgstr "Whether this tray icon has a tooltip" -#: ../gtk/gtkstatusicon.c:373 ../gtk/gtkwidget.c:1105 +#: ../gtk/gtkstatusicon.c:373 ../gtk/gtkwidget.c:1043 msgid "Tooltip Text" msgstr "Tooltip Text" -#: ../gtk/gtkstatusicon.c:374 ../gtk/gtkwidget.c:1106 ../gtk/gtkwidget.c:1127 +#: ../gtk/gtkstatusicon.c:374 ../gtk/gtkwidget.c:1044 ../gtk/gtkwidget.c:1065 msgid "The contents of the tooltip for this widget" msgstr "The contents of the tooltip for this widget" -#: ../gtk/gtkstatusicon.c:397 ../gtk/gtkwidget.c:1126 +#: ../gtk/gtkstatusicon.c:397 ../gtk/gtkwidget.c:1064 msgid "Tooltip markup" msgstr "Tooltip markup" @@ -5562,87 +5547,95 @@ msgstr "The contents of the tooltip for this tray icon" msgid "The title of this tray icon" msgstr "The title of this tray icon" -#: ../gtk/gtktable.c:152 +#: ../gtk/gtkswitch.c:739 +msgid "Whether the switch is on or off" +msgstr "Whether the switch is on or off" + +#: ../gtk/gtkswitch.c:773 +msgid "The minimum width of the handle" +msgstr "The minimum width of the handle" + +#: ../gtk/gtktable.c:157 msgid "Rows" msgstr "Rows" -#: ../gtk/gtktable.c:153 +#: ../gtk/gtktable.c:158 msgid "The number of rows in the table" msgstr "The number of rows in the table" -#: ../gtk/gtktable.c:161 +#: ../gtk/gtktable.c:166 msgid "Columns" msgstr "Columns" -#: ../gtk/gtktable.c:162 +#: ../gtk/gtktable.c:167 msgid "The number of columns in the table" msgstr "The number of columns in the table" -#: ../gtk/gtktable.c:170 +#: ../gtk/gtktable.c:175 msgid "Row spacing" msgstr "Row spacing" -#: ../gtk/gtktable.c:171 +#: ../gtk/gtktable.c:176 msgid "The amount of space between two consecutive rows" msgstr "The amount of space between two consecutive rows" -#: ../gtk/gtktable.c:179 +#: ../gtk/gtktable.c:184 msgid "Column spacing" msgstr "Column spacing" -#: ../gtk/gtktable.c:180 +#: ../gtk/gtktable.c:185 msgid "The amount of space between two consecutive columns" msgstr "The amount of space between two consecutive columns" -#: ../gtk/gtktable.c:189 +#: ../gtk/gtktable.c:194 msgid "If TRUE, the table cells are all the same width/height" msgstr "If TRUE, the table cells are all the same width/height" -#: ../gtk/gtktable.c:196 +#: ../gtk/gtktable.c:201 msgid "Left attachment" msgstr "Left attachment" -#: ../gtk/gtktable.c:203 +#: ../gtk/gtktable.c:208 msgid "Right attachment" msgstr "Right attachment" -#: ../gtk/gtktable.c:204 +#: ../gtk/gtktable.c:209 msgid "The column number to attach the right side of a child widget to" msgstr "The column number to attach the right side of a child widget to" -#: ../gtk/gtktable.c:210 +#: ../gtk/gtktable.c:215 msgid "Top attachment" msgstr "Top attachment" -#: ../gtk/gtktable.c:211 +#: ../gtk/gtktable.c:216 msgid "The row number to attach the top of a child widget to" msgstr "The row number to attach the top of a child widget to" -#: ../gtk/gtktable.c:217 +#: ../gtk/gtktable.c:222 msgid "Bottom attachment" msgstr "Bottom attachment" -#: ../gtk/gtktable.c:224 +#: ../gtk/gtktable.c:229 msgid "Horizontal options" msgstr "Horizontal options" -#: ../gtk/gtktable.c:225 +#: ../gtk/gtktable.c:230 msgid "Options specifying the horizontal behaviour of the child" msgstr "Options specifying the horizontal behaviour of the child" -#: ../gtk/gtktable.c:231 +#: ../gtk/gtktable.c:236 msgid "Vertical options" msgstr "Vertical options" -#: ../gtk/gtktable.c:232 +#: ../gtk/gtktable.c:237 msgid "Options specifying the vertical behaviour of the child" msgstr "Options specifying the vertical behaviour of the child" -#: ../gtk/gtktable.c:238 +#: ../gtk/gtktable.c:243 msgid "Horizontal padding" msgstr "Horizontal padding" -#: ../gtk/gtktable.c:239 +#: ../gtk/gtktable.c:244 msgid "" "Extra space to put between the child and its left and right neighbors, in " "pixels" @@ -5650,11 +5643,11 @@ msgstr "" "Extra space to put between the child and its left and right neighbors, in " "pixels" -#: ../gtk/gtktable.c:245 +#: ../gtk/gtktable.c:250 msgid "Vertical padding" msgstr "Vertical padding" -#: ../gtk/gtktable.c:246 +#: ../gtk/gtktable.c:251 msgid "" "Extra space to put between the child and its upper and lower neighbors, in " "pixels" @@ -5662,51 +5655,51 @@ msgstr "" "Extra space to put between the child and its upper and lower neighbors, in " "pixels" -#: ../gtk/gtktextbuffer.c:192 +#: ../gtk/gtktextbuffer.c:191 msgid "Tag Table" msgstr "Tag Table" -#: ../gtk/gtktextbuffer.c:193 +#: ../gtk/gtktextbuffer.c:192 msgid "Text Tag Table" msgstr "Text Tag Table" -#: ../gtk/gtktextbuffer.c:211 +#: ../gtk/gtktextbuffer.c:210 msgid "Current text of the buffer" msgstr "Current text of the buffer" -#: ../gtk/gtktextbuffer.c:225 +#: ../gtk/gtktextbuffer.c:224 msgid "Has selection" msgstr "Has selection" -#: ../gtk/gtktextbuffer.c:226 +#: ../gtk/gtktextbuffer.c:225 msgid "Whether the buffer has some text currently selected" msgstr "Whether the buffer has some text currently selected" -#: ../gtk/gtktextbuffer.c:242 +#: ../gtk/gtktextbuffer.c:241 msgid "Cursor position" msgstr "Cursor position" -#: ../gtk/gtktextbuffer.c:243 +#: ../gtk/gtktextbuffer.c:242 msgid "" "The position of the insert mark (as offset from the beginning of the buffer)" msgstr "" "The position of the insert mark (as offset from the beginning of the buffer)" -#: ../gtk/gtktextbuffer.c:258 +#: ../gtk/gtktextbuffer.c:257 msgid "Copy target list" msgstr "Copy target list" -#: ../gtk/gtktextbuffer.c:259 +#: ../gtk/gtktextbuffer.c:258 msgid "" "The list of targets this buffer supports for clipboard copying and DND source" msgstr "" "The list of targets this buffer supports for clipboard copying and DND source" -#: ../gtk/gtktextbuffer.c:274 +#: ../gtk/gtktextbuffer.c:273 msgid "Paste target list" msgstr "Paste target list" -#: ../gtk/gtktextbuffer.c:275 +#: ../gtk/gtktextbuffer.c:274 msgid "" "The list of targets this buffer supports for clipboard pasting and DND " "destination" @@ -5796,7 +5789,7 @@ msgstr "" "adapts to theme changes etc. so is recommended. Pango predefines some scales " "such as PANGO_SCALE_X_LARGE" -#: ../gtk/gtktexttag.c:336 ../gtk/gtktextview.c:685 +#: ../gtk/gtktexttag.c:336 ../gtk/gtktextview.c:704 msgid "Left, right, or center justification" msgstr "Left, right, or center justification" @@ -5812,7 +5805,7 @@ msgstr "" msgid "Left margin" msgstr "Left margin" -#: ../gtk/gtktexttag.c:363 ../gtk/gtktextview.c:694 +#: ../gtk/gtktexttag.c:363 ../gtk/gtktextview.c:713 msgid "Width of the left margin in pixels" msgstr "Width of the left margin in pixels" @@ -5820,15 +5813,15 @@ msgstr "Width of the left margin in pixels" msgid "Right margin" msgstr "Right margin" -#: ../gtk/gtktexttag.c:373 ../gtk/gtktextview.c:704 +#: ../gtk/gtktexttag.c:373 ../gtk/gtktextview.c:723 msgid "Width of the right margin in pixels" msgstr "Width of the right margin in pixels" -#: ../gtk/gtktexttag.c:383 ../gtk/gtktextview.c:713 +#: ../gtk/gtktexttag.c:383 ../gtk/gtktextview.c:732 msgid "Indent" msgstr "Indent" -#: ../gtk/gtktexttag.c:384 ../gtk/gtktextview.c:714 +#: ../gtk/gtktexttag.c:384 ../gtk/gtktextview.c:733 msgid "Amount to indent the paragraph, in pixels" msgstr "Amount to indent the paragraph, in pixels" @@ -5844,7 +5837,7 @@ msgstr "" msgid "Pixels above lines" msgstr "Pixels above lines" -#: ../gtk/gtktexttag.c:405 ../gtk/gtktextview.c:638 +#: ../gtk/gtktexttag.c:405 ../gtk/gtktextview.c:657 msgid "Pixels of blank space above paragraphs" msgstr "Pixels of blank space above paragraphs" @@ -5852,7 +5845,7 @@ msgstr "Pixels of blank space above paragraphs" msgid "Pixels below lines" msgstr "Pixels below lines" -#: ../gtk/gtktexttag.c:415 ../gtk/gtktextview.c:648 +#: ../gtk/gtktexttag.c:415 ../gtk/gtktextview.c:667 msgid "Pixels of blank space below paragraphs" msgstr "Pixels of blank space below paragraphs" @@ -5860,21 +5853,21 @@ msgstr "Pixels of blank space below paragraphs" msgid "Pixels inside wrap" msgstr "Pixels inside wrap" -#: ../gtk/gtktexttag.c:425 ../gtk/gtktextview.c:658 +#: ../gtk/gtktexttag.c:425 ../gtk/gtktextview.c:677 msgid "Pixels of blank space between wrapped lines in a paragraph" msgstr "Pixels of blank space between wrapped lines in a paragraph" -#: ../gtk/gtktexttag.c:452 ../gtk/gtktextview.c:676 +#: ../gtk/gtktexttag.c:452 ../gtk/gtktextview.c:695 msgid "" "Whether to wrap lines never, at word boundaries, or at character boundaries" msgstr "" "Whether to wrap lines never, at word boundaries, or at character boundaries" -#: ../gtk/gtktexttag.c:461 ../gtk/gtktextview.c:723 +#: ../gtk/gtktexttag.c:461 ../gtk/gtktextview.c:742 msgid "Tabs" msgstr "Tabs" -#: ../gtk/gtktexttag.c:462 ../gtk/gtktextview.c:724 +#: ../gtk/gtktexttag.c:462 ../gtk/gtktextview.c:743 msgid "Custom tabs for this text" msgstr "Custom tabs for this text" @@ -6002,63 +5995,63 @@ msgstr "Paragraph background set" msgid "Whether this tag affects the paragraph background color" msgstr "Whether this tag affects the paragraph background color" -#: ../gtk/gtktextview.c:637 +#: ../gtk/gtktextview.c:656 msgid "Pixels Above Lines" msgstr "Pixels Above Lines" -#: ../gtk/gtktextview.c:647 +#: ../gtk/gtktextview.c:666 msgid "Pixels Below Lines" msgstr "Pixels Below Lines" -#: ../gtk/gtktextview.c:657 +#: ../gtk/gtktextview.c:676 msgid "Pixels Inside Wrap" msgstr "Pixels Inside Wrap" -#: ../gtk/gtktextview.c:675 +#: ../gtk/gtktextview.c:694 msgid "Wrap Mode" msgstr "Wrap Mode" -#: ../gtk/gtktextview.c:693 +#: ../gtk/gtktextview.c:712 msgid "Left Margin" msgstr "Left Margin" -#: ../gtk/gtktextview.c:703 +#: ../gtk/gtktextview.c:722 msgid "Right Margin" msgstr "Right Margin" -#: ../gtk/gtktextview.c:731 +#: ../gtk/gtktextview.c:750 msgid "Cursor Visible" msgstr "Cursor Visible" -#: ../gtk/gtktextview.c:732 +#: ../gtk/gtktextview.c:751 msgid "If the insertion cursor is shown" msgstr "If the insertion cursor is shown" -#: ../gtk/gtktextview.c:739 +#: ../gtk/gtktextview.c:758 msgid "Buffer" msgstr "Buffer" -#: ../gtk/gtktextview.c:740 +#: ../gtk/gtktextview.c:759 msgid "The buffer which is displayed" msgstr "The buffer which is displayed" -#: ../gtk/gtktextview.c:748 +#: ../gtk/gtktextview.c:767 msgid "Whether entered text overwrites existing contents" msgstr "Whether entered text overwrites existing contents" -#: ../gtk/gtktextview.c:755 +#: ../gtk/gtktextview.c:774 msgid "Accepts tab" msgstr "Accepts tab" -#: ../gtk/gtktextview.c:756 +#: ../gtk/gtktextview.c:775 msgid "Whether Tab will result in a tab character being entered" msgstr "Whether Tab will result in a tab character being entered" -#: ../gtk/gtktextview.c:791 +#: ../gtk/gtktextview.c:810 msgid "Error underline color" msgstr "Error underline color" -#: ../gtk/gtktextview.c:792 +#: ../gtk/gtktextview.c:811 msgid "Color with which to draw error-indication underlines" msgstr "Color with which to draw error-indication underlines" @@ -6074,95 +6067,95 @@ msgstr "Whether the proxies for this action look like radio action proxies" msgid "Whether the toggle action should be active" msgstr "Whether the toggle action should be active" -#: ../gtk/gtktogglebutton.c:123 ../gtk/gtktoggletoolbutton.c:113 +#: ../gtk/gtktogglebutton.c:126 ../gtk/gtktoggletoolbutton.c:113 msgid "If the toggle button should be pressed in" msgstr "If the toggle button should be pressed in" -#: ../gtk/gtktogglebutton.c:131 +#: ../gtk/gtktogglebutton.c:134 msgid "If the toggle button is in an \"in between\" state" msgstr "If the toggle button is in an \"in between\" state" -#: ../gtk/gtktogglebutton.c:138 +#: ../gtk/gtktogglebutton.c:141 msgid "Draw Indicator" msgstr "Draw Indicator" -#: ../gtk/gtktogglebutton.c:139 +#: ../gtk/gtktogglebutton.c:142 msgid "If the toggle part of the button is displayed" msgstr "If the toggle part of the button is displayed" -#: ../gtk/gtktoolbar.c:485 ../gtk/gtktoolpalette.c:1033 +#: ../gtk/gtktoolbar.c:491 ../gtk/gtktoolpalette.c:1060 msgid "Toolbar Style" msgstr "Toolbar Style" -#: ../gtk/gtktoolbar.c:486 +#: ../gtk/gtktoolbar.c:492 msgid "How to draw the toolbar" msgstr "How to draw the toolbar" -#: ../gtk/gtktoolbar.c:493 +#: ../gtk/gtktoolbar.c:499 msgid "Show Arrow" msgstr "Show Arrow" -#: ../gtk/gtktoolbar.c:494 +#: ../gtk/gtktoolbar.c:500 msgid "If an arrow should be shown if the toolbar doesn't fit" msgstr "If an arrow should be shown if the toolbar doesn't fit" -#: ../gtk/gtktoolbar.c:515 +#: ../gtk/gtktoolbar.c:521 msgid "Size of icons in this toolbar" msgstr "Size of icons in this toolbar" -#: ../gtk/gtktoolbar.c:530 ../gtk/gtktoolpalette.c:1019 +#: ../gtk/gtktoolbar.c:536 ../gtk/gtktoolpalette.c:1046 msgid "Icon size set" msgstr "Icon size set" -#: ../gtk/gtktoolbar.c:531 ../gtk/gtktoolpalette.c:1020 +#: ../gtk/gtktoolbar.c:537 ../gtk/gtktoolpalette.c:1047 msgid "Whether the icon-size property has been set" msgstr "Whether the icon-size property has been set" -#: ../gtk/gtktoolbar.c:540 +#: ../gtk/gtktoolbar.c:546 msgid "Whether the item should receive extra space when the toolbar grows" msgstr "Whether the item should receive extra space when the toolbar grows" -#: ../gtk/gtktoolbar.c:548 ../gtk/gtktoolitemgroup.c:1625 +#: ../gtk/gtktoolbar.c:554 ../gtk/gtktoolitemgroup.c:1642 msgid "Whether the item should be the same size as other homogeneous items" msgstr "Whether the item should be the same size as other homogeneous items" -#: ../gtk/gtktoolbar.c:555 +#: ../gtk/gtktoolbar.c:561 msgid "Spacer size" msgstr "Spacer size" -#: ../gtk/gtktoolbar.c:556 +#: ../gtk/gtktoolbar.c:562 msgid "Size of spacers" msgstr "Size of spacers" -#: ../gtk/gtktoolbar.c:565 +#: ../gtk/gtktoolbar.c:571 msgid "Amount of border space between the toolbar shadow and the buttons" msgstr "Amount of border space between the toolbar shadow and the buttons" -#: ../gtk/gtktoolbar.c:573 +#: ../gtk/gtktoolbar.c:579 msgid "Maximum child expand" msgstr "Maximum child expand" -#: ../gtk/gtktoolbar.c:574 +#: ../gtk/gtktoolbar.c:580 msgid "Maximum amount of space an expandable item will be given" msgstr "Maximum amount of space an expandable item will be given" -#: ../gtk/gtktoolbar.c:582 +#: ../gtk/gtktoolbar.c:588 msgid "Space style" msgstr "Space style" -#: ../gtk/gtktoolbar.c:583 +#: ../gtk/gtktoolbar.c:589 msgid "Whether spacers are vertical lines or just blank" msgstr "Whether spacers are vertical lines or just blank" -#: ../gtk/gtktoolbar.c:590 +#: ../gtk/gtktoolbar.c:596 msgid "Button relief" msgstr "Button relief" -#: ../gtk/gtktoolbar.c:591 +#: ../gtk/gtktoolbar.c:597 msgid "Type of bevel around toolbar buttons" msgstr "Type of bevel around toolbar buttons" -#: ../gtk/gtktoolbar.c:598 +#: ../gtk/gtktoolbar.c:604 msgid "Style of bevel around the toolbar" msgstr "Style of bevel around the toolbar" @@ -6214,7 +6207,7 @@ msgstr "Icon spacing" msgid "Spacing in pixels between the icon and label" msgstr "Spacing in pixels between the icon and label" -#: ../gtk/gtktoolitem.c:201 +#: ../gtk/gtktoolitem.c:210 msgid "" "Whether the toolbar item is considered important. When TRUE, toolbar buttons " "show text in GTK_TOOLBAR_BOTH_HORIZ mode" @@ -6222,83 +6215,83 @@ msgstr "" "Whether the toolbar item is considered important. When TRUE, toolbar buttons " "show text in GTK_TOOLBAR_BOTH_HORIZ mode" -#: ../gtk/gtktoolitemgroup.c:1572 +#: ../gtk/gtktoolitemgroup.c:1589 msgid "The human-readable title of this item group" msgstr "The human-readable title of this item group" -#: ../gtk/gtktoolitemgroup.c:1579 +#: ../gtk/gtktoolitemgroup.c:1596 msgid "A widget to display in place of the usual label" msgstr "A widget to display in place of the usual label" -#: ../gtk/gtktoolitemgroup.c:1585 +#: ../gtk/gtktoolitemgroup.c:1602 msgid "Collapsed" msgstr "Collapsed" -#: ../gtk/gtktoolitemgroup.c:1586 +#: ../gtk/gtktoolitemgroup.c:1603 msgid "Whether the group has been collapsed and items are hidden" msgstr "Whether the group has been collapsed and items are hidden" -#: ../gtk/gtktoolitemgroup.c:1592 +#: ../gtk/gtktoolitemgroup.c:1609 msgid "ellipsize" msgstr "ellipsize" -#: ../gtk/gtktoolitemgroup.c:1593 +#: ../gtk/gtktoolitemgroup.c:1610 msgid "Ellipsize for item group headers" msgstr "Ellipsize for item group headers" -#: ../gtk/gtktoolitemgroup.c:1599 +#: ../gtk/gtktoolitemgroup.c:1616 msgid "Header Relief" msgstr "Header Relief" -#: ../gtk/gtktoolitemgroup.c:1600 +#: ../gtk/gtktoolitemgroup.c:1617 msgid "Relief of the group header button" msgstr "Relief of the group header button" -#: ../gtk/gtktoolitemgroup.c:1615 +#: ../gtk/gtktoolitemgroup.c:1632 msgid "Header Spacing" msgstr "Header Spacing" -#: ../gtk/gtktoolitemgroup.c:1616 +#: ../gtk/gtktoolitemgroup.c:1633 msgid "Spacing between expander arrow and caption" msgstr "Spacing between expander arrow and caption" -#: ../gtk/gtktoolitemgroup.c:1632 +#: ../gtk/gtktoolitemgroup.c:1649 msgid "Whether the item should receive extra space when the group grows" msgstr "Whether the item should receive extra space when the group grows" -#: ../gtk/gtktoolitemgroup.c:1639 +#: ../gtk/gtktoolitemgroup.c:1656 msgid "Whether the item should fill the available space" msgstr "Whether the item should fill the available space" -#: ../gtk/gtktoolitemgroup.c:1645 +#: ../gtk/gtktoolitemgroup.c:1662 msgid "New Row" msgstr "New Row" -#: ../gtk/gtktoolitemgroup.c:1646 +#: ../gtk/gtktoolitemgroup.c:1663 msgid "Whether the item should start a new row" msgstr "Whether the item should start a new row" -#: ../gtk/gtktoolitemgroup.c:1653 +#: ../gtk/gtktoolitemgroup.c:1670 msgid "Position of the item within this group" msgstr "Position of the item within this group" -#: ../gtk/gtktoolpalette.c:1004 +#: ../gtk/gtktoolpalette.c:1031 msgid "Size of icons in this tool palette" msgstr "Size of icons in this tool palette" -#: ../gtk/gtktoolpalette.c:1034 +#: ../gtk/gtktoolpalette.c:1061 msgid "Style of items in the tool palette" msgstr "Style of items in the tool palette" -#: ../gtk/gtktoolpalette.c:1050 +#: ../gtk/gtktoolpalette.c:1077 msgid "Exclusive" msgstr "Exclusive" -#: ../gtk/gtktoolpalette.c:1051 +#: ../gtk/gtktoolpalette.c:1078 msgid "Whether the item group should be the only expanded at a given time" msgstr "Whether the item group should be the only expanded at a given time" -#: ../gtk/gtktoolpalette.c:1066 +#: ../gtk/gtktoolpalette.c:1093 msgid "" "Whether the item group should receive extra space when the palette grows" msgstr "" @@ -6344,211 +6337,211 @@ msgstr "TreeModelSort Model" msgid "The model for the TreeModelSort to sort" msgstr "The model for the TreeModelSort to sort" -#: ../gtk/gtktreeview.c:568 +#: ../gtk/gtktreeview.c:661 msgid "TreeView Model" msgstr "TreeView Model" -#: ../gtk/gtktreeview.c:569 +#: ../gtk/gtktreeview.c:662 msgid "The model for the tree view" msgstr "The model for the tree view" -#: ../gtk/gtktreeview.c:581 +#: ../gtk/gtktreeview.c:674 msgid "Headers Visible" msgstr "Headers Visible" -#: ../gtk/gtktreeview.c:582 +#: ../gtk/gtktreeview.c:675 msgid "Show the column header buttons" msgstr "Show the column header buttons" -#: ../gtk/gtktreeview.c:589 +#: ../gtk/gtktreeview.c:682 msgid "Headers Clickable" msgstr "Headers Clickable" -#: ../gtk/gtktreeview.c:590 +#: ../gtk/gtktreeview.c:683 msgid "Column headers respond to click events" msgstr "Column headers respond to click events" -#: ../gtk/gtktreeview.c:597 +#: ../gtk/gtktreeview.c:690 msgid "Expander Column" msgstr "Expander Column" -#: ../gtk/gtktreeview.c:598 +#: ../gtk/gtktreeview.c:691 msgid "Set the column for the expander column" msgstr "Set the column for the expander column" -#: ../gtk/gtktreeview.c:613 +#: ../gtk/gtktreeview.c:706 msgid "Rules Hint" msgstr "Rules Hint" -#: ../gtk/gtktreeview.c:614 +#: ../gtk/gtktreeview.c:707 msgid "Set a hint to the theme engine to draw rows in alternating colors" msgstr "Set a hint to the theme engine to draw rows in alternating colors" -#: ../gtk/gtktreeview.c:621 +#: ../gtk/gtktreeview.c:714 msgid "Enable Search" msgstr "Enable Search" -#: ../gtk/gtktreeview.c:622 +#: ../gtk/gtktreeview.c:715 msgid "View allows user to search through columns interactively" msgstr "View allows user to search through columns interactively" -#: ../gtk/gtktreeview.c:629 +#: ../gtk/gtktreeview.c:722 msgid "Search Column" msgstr "Search Column" -#: ../gtk/gtktreeview.c:630 +#: ../gtk/gtktreeview.c:723 msgid "Model column to search through during interactive search" msgstr "Model column to search through during interactive search" -#: ../gtk/gtktreeview.c:650 +#: ../gtk/gtktreeview.c:743 msgid "Fixed Height Mode" msgstr "Fixed Height Mode" -#: ../gtk/gtktreeview.c:651 +#: ../gtk/gtktreeview.c:744 msgid "Speeds up GtkTreeView by assuming that all rows have the same height" msgstr "Speeds up GtkTreeView by assuming that all rows have the same height" -#: ../gtk/gtktreeview.c:671 +#: ../gtk/gtktreeview.c:764 msgid "Hover Selection" msgstr "Hover Selection" -#: ../gtk/gtktreeview.c:672 +#: ../gtk/gtktreeview.c:765 msgid "Whether the selection should follow the pointer" msgstr "Whether the selection should follow the pointer" -#: ../gtk/gtktreeview.c:691 +#: ../gtk/gtktreeview.c:784 msgid "Hover Expand" msgstr "Hover Expand" -#: ../gtk/gtktreeview.c:692 +#: ../gtk/gtktreeview.c:785 msgid "" "Whether rows should be expanded/collapsed when the pointer moves over them" msgstr "" "Whether rows should be expanded/collapsed when the pointer moves over them" -#: ../gtk/gtktreeview.c:706 +#: ../gtk/gtktreeview.c:799 msgid "Show Expanders" msgstr "Show Expanders" -#: ../gtk/gtktreeview.c:707 +#: ../gtk/gtktreeview.c:800 msgid "View has expanders" msgstr "View has expanders" -#: ../gtk/gtktreeview.c:721 +#: ../gtk/gtktreeview.c:814 msgid "Level Indentation" msgstr "Level Indentation" -#: ../gtk/gtktreeview.c:722 +#: ../gtk/gtktreeview.c:815 msgid "Extra indentation for each level" msgstr "Extra indentation for each level" -#: ../gtk/gtktreeview.c:731 +#: ../gtk/gtktreeview.c:824 msgid "Rubber Banding" msgstr "Rubber Banding" -#: ../gtk/gtktreeview.c:732 +#: ../gtk/gtktreeview.c:825 msgid "" "Whether to enable selection of multiple items by dragging the mouse pointer" msgstr "" "Whether to enable selection of multiple items by dragging the mouse pointer" -#: ../gtk/gtktreeview.c:739 +#: ../gtk/gtktreeview.c:832 msgid "Enable Grid Lines" msgstr "Enable Grid Lines" -#: ../gtk/gtktreeview.c:740 +#: ../gtk/gtktreeview.c:833 msgid "Whether grid lines should be drawn in the tree view" msgstr "Whether grid lines should be drawn in the tree view" -#: ../gtk/gtktreeview.c:748 +#: ../gtk/gtktreeview.c:841 msgid "Enable Tree Lines" msgstr "Enable Tree Lines" -#: ../gtk/gtktreeview.c:749 +#: ../gtk/gtktreeview.c:842 msgid "Whether tree lines should be drawn in the tree view" msgstr "Whether tree lines should be drawn in the tree view" -#: ../gtk/gtktreeview.c:757 +#: ../gtk/gtktreeview.c:850 msgid "The column in the model containing the tooltip texts for the rows" msgstr "The column in the model containing the tooltip texts for the rows" -#: ../gtk/gtktreeview.c:779 +#: ../gtk/gtktreeview.c:872 msgid "Vertical Separator Width" msgstr "Vertical Separator Width" -#: ../gtk/gtktreeview.c:780 +#: ../gtk/gtktreeview.c:873 msgid "Vertical space between cells. Must be an even number" msgstr "Vertical space between cells. Must be an even number" -#: ../gtk/gtktreeview.c:788 +#: ../gtk/gtktreeview.c:881 msgid "Horizontal Separator Width" msgstr "Horizontal Separator Width" -#: ../gtk/gtktreeview.c:789 +#: ../gtk/gtktreeview.c:882 msgid "Horizontal space between cells. Must be an even number" msgstr "Horizontal space between cells. Must be an even number" -#: ../gtk/gtktreeview.c:797 +#: ../gtk/gtktreeview.c:890 msgid "Allow Rules" msgstr "Allow Rules" -#: ../gtk/gtktreeview.c:798 +#: ../gtk/gtktreeview.c:891 msgid "Allow drawing of alternating color rows" msgstr "Allow drawing of alternating color rows" -#: ../gtk/gtktreeview.c:804 +#: ../gtk/gtktreeview.c:897 msgid "Indent Expanders" msgstr "Indent Expanders" -#: ../gtk/gtktreeview.c:805 +#: ../gtk/gtktreeview.c:898 msgid "Make the expanders indented" msgstr "Make the expanders indented" -#: ../gtk/gtktreeview.c:811 +#: ../gtk/gtktreeview.c:904 msgid "Even Row Color" msgstr "Even Row Color" -#: ../gtk/gtktreeview.c:812 +#: ../gtk/gtktreeview.c:905 msgid "Color to use for even rows" msgstr "Color to use for even rows" -#: ../gtk/gtktreeview.c:818 +#: ../gtk/gtktreeview.c:911 msgid "Odd Row Color" msgstr "Odd Row Color" -#: ../gtk/gtktreeview.c:819 +#: ../gtk/gtktreeview.c:912 msgid "Color to use for odd rows" msgstr "Color to use for odd rows" -#: ../gtk/gtktreeview.c:825 +#: ../gtk/gtktreeview.c:918 msgid "Grid line width" msgstr "Grid line width" -#: ../gtk/gtktreeview.c:826 +#: ../gtk/gtktreeview.c:919 msgid "Width, in pixels, of the tree view grid lines" msgstr "Width, in pixels, of the tree view grid lines" -#: ../gtk/gtktreeview.c:832 +#: ../gtk/gtktreeview.c:925 msgid "Tree line width" msgstr "Tree line width" -#: ../gtk/gtktreeview.c:833 +#: ../gtk/gtktreeview.c:926 msgid "Width, in pixels, of the tree view lines" msgstr "Width, in pixels, of the tree view lines" -#: ../gtk/gtktreeview.c:839 +#: ../gtk/gtktreeview.c:932 msgid "Grid line pattern" msgstr "Grid line pattern" -#: ../gtk/gtktreeview.c:840 +#: ../gtk/gtktreeview.c:933 msgid "Dash pattern used to draw the tree view grid lines" msgstr "Dash pattern used to draw the tree view grid lines" -#: ../gtk/gtktreeview.c:846 +#: ../gtk/gtktreeview.c:939 msgid "Tree line pattern" msgstr "Tree line pattern" -#: ../gtk/gtktreeview.c:847 +#: ../gtk/gtktreeview.c:940 msgid "Dash pattern used to draw the tree view lines" msgstr "Dash pattern used to draw the tree view lines" @@ -6672,31 +6665,31 @@ msgstr "Merged UI definition" msgid "An XML string describing the merged UI" msgstr "An XML string describing the merged UI" -#: ../gtk/gtkviewport.c:156 +#: ../gtk/gtkviewport.c:155 msgid "Determines how the shadowed box around the viewport is drawn" msgstr "Determines how the shadowed box around the viewport is drawn" -#: ../gtk/gtkwidget.c:935 +#: ../gtk/gtkwidget.c:873 msgid "Widget name" msgstr "Widget name" -#: ../gtk/gtkwidget.c:936 +#: ../gtk/gtkwidget.c:874 msgid "The name of the widget" msgstr "The name of the widget" -#: ../gtk/gtkwidget.c:942 +#: ../gtk/gtkwidget.c:880 msgid "Parent widget" msgstr "Parent widget" -#: ../gtk/gtkwidget.c:943 +#: ../gtk/gtkwidget.c:881 msgid "The parent widget of this widget. Must be a Container widget" msgstr "The parent widget of this widget. Must be a Container widget" -#: ../gtk/gtkwidget.c:950 +#: ../gtk/gtkwidget.c:888 msgid "Width request" msgstr "Width request" -#: ../gtk/gtkwidget.c:951 +#: ../gtk/gtkwidget.c:889 msgid "" "Override for width request of the widget, or -1 if natural request should be " "used" @@ -6704,11 +6697,11 @@ msgstr "" "Override for width request of the widget, or -1 if natural request should be " "used" -#: ../gtk/gtkwidget.c:959 +#: ../gtk/gtkwidget.c:897 msgid "Height request" msgstr "Height request" -#: ../gtk/gtkwidget.c:960 +#: ../gtk/gtkwidget.c:898 msgid "" "Override for height request of the widget, or -1 if natural request should " "be used" @@ -6716,83 +6709,83 @@ msgstr "" "Override for height request of the widget, or -1 if natural request should " "be used" -#: ../gtk/gtkwidget.c:969 +#: ../gtk/gtkwidget.c:907 msgid "Whether the widget is visible" msgstr "Whether the widget is visible" -#: ../gtk/gtkwidget.c:976 +#: ../gtk/gtkwidget.c:914 msgid "Whether the widget responds to input" msgstr "Whether the widget responds to input" -#: ../gtk/gtkwidget.c:982 +#: ../gtk/gtkwidget.c:920 msgid "Application paintable" msgstr "Application paintable" -#: ../gtk/gtkwidget.c:983 +#: ../gtk/gtkwidget.c:921 msgid "Whether the application will paint directly on the widget" msgstr "Whether the application will paint directly on the widget" -#: ../gtk/gtkwidget.c:989 +#: ../gtk/gtkwidget.c:927 msgid "Can focus" msgstr "Can focus" -#: ../gtk/gtkwidget.c:990 +#: ../gtk/gtkwidget.c:928 msgid "Whether the widget can accept the input focus" msgstr "Whether the widget can accept the input focus" -#: ../gtk/gtkwidget.c:996 +#: ../gtk/gtkwidget.c:934 msgid "Has focus" msgstr "Has focus" -#: ../gtk/gtkwidget.c:997 +#: ../gtk/gtkwidget.c:935 msgid "Whether the widget has the input focus" msgstr "Whether the widget has the input focus" -#: ../gtk/gtkwidget.c:1003 +#: ../gtk/gtkwidget.c:941 msgid "Is focus" msgstr "Is focus" -#: ../gtk/gtkwidget.c:1004 +#: ../gtk/gtkwidget.c:942 msgid "Whether the widget is the focus widget within the toplevel" msgstr "Whether the widget is the focus widget within the toplevel" -#: ../gtk/gtkwidget.c:1010 +#: ../gtk/gtkwidget.c:948 msgid "Can default" msgstr "Can default" -#: ../gtk/gtkwidget.c:1011 +#: ../gtk/gtkwidget.c:949 msgid "Whether the widget can be the default widget" msgstr "Whether the widget can be the default widget" -#: ../gtk/gtkwidget.c:1017 +#: ../gtk/gtkwidget.c:955 msgid "Has default" msgstr "Has default" -#: ../gtk/gtkwidget.c:1018 +#: ../gtk/gtkwidget.c:956 msgid "Whether the widget is the default widget" msgstr "Whether the widget is the default widget" -#: ../gtk/gtkwidget.c:1024 +#: ../gtk/gtkwidget.c:962 msgid "Receives default" msgstr "Receives default" -#: ../gtk/gtkwidget.c:1025 +#: ../gtk/gtkwidget.c:963 msgid "If TRUE, the widget will receive the default action when it is focused" msgstr "If TRUE, the widget will receive the default action when it is focused" -#: ../gtk/gtkwidget.c:1031 +#: ../gtk/gtkwidget.c:969 msgid "Composite child" msgstr "Composite child" -#: ../gtk/gtkwidget.c:1032 +#: ../gtk/gtkwidget.c:970 msgid "Whether the widget is part of a composite widget" msgstr "Whether the widget is part of a composite widget" -#: ../gtk/gtkwidget.c:1038 +#: ../gtk/gtkwidget.c:976 msgid "Style" msgstr "Style" -#: ../gtk/gtkwidget.c:1039 +#: ../gtk/gtkwidget.c:977 msgid "" "The style of the widget, which contains information about how it will look " "(colors etc)" @@ -6800,183 +6793,183 @@ msgstr "" "The style of the widget, which contains information about how it will look " "(colors etc)" -#: ../gtk/gtkwidget.c:1045 +#: ../gtk/gtkwidget.c:983 msgid "Events" msgstr "Events" -#: ../gtk/gtkwidget.c:1046 +#: ../gtk/gtkwidget.c:984 msgid "The event mask that decides what kind of GdkEvents this widget gets" msgstr "The event mask that decides what kind of GdkEvents this widget gets" -#: ../gtk/gtkwidget.c:1053 +#: ../gtk/gtkwidget.c:991 msgid "Extension events" msgstr "Extension events" -#: ../gtk/gtkwidget.c:1054 +#: ../gtk/gtkwidget.c:992 msgid "The mask that decides what kind of extension events this widget gets" msgstr "The mask that decides what kind of extension events this widget gets" -#: ../gtk/gtkwidget.c:1061 +#: ../gtk/gtkwidget.c:999 msgid "No show all" msgstr "No show all" -#: ../gtk/gtkwidget.c:1062 +#: ../gtk/gtkwidget.c:1000 msgid "Whether gtk_widget_show_all() should not affect this widget" msgstr "Whether gtk_widget_show_all() should not affect this widget" -#: ../gtk/gtkwidget.c:1085 +#: ../gtk/gtkwidget.c:1023 msgid "Whether this widget has a tooltip" msgstr "Whether this widget has a tooltip" -#: ../gtk/gtkwidget.c:1141 +#: ../gtk/gtkwidget.c:1079 msgid "Window" msgstr "Window" -#: ../gtk/gtkwidget.c:1142 +#: ../gtk/gtkwidget.c:1080 msgid "The widget's window if it is realized" msgstr "The widget's window if it is realized" -#: ../gtk/gtkwidget.c:1156 +#: ../gtk/gtkwidget.c:1094 msgid "Double Buffered" msgstr "Double Buffered" -#: ../gtk/gtkwidget.c:1157 +#: ../gtk/gtkwidget.c:1095 msgid "Whether the widget is double buffered" msgstr "Whether the widget is double buffered" -#: ../gtk/gtkwidget.c:1172 +#: ../gtk/gtkwidget.c:1110 msgid "How to position in extra horizontal space" msgstr "How to position in extra horizontal space" -#: ../gtk/gtkwidget.c:1188 +#: ../gtk/gtkwidget.c:1126 msgid "How to position in extra vertical space" msgstr "How to position in extra vertical space" -#: ../gtk/gtkwidget.c:1207 +#: ../gtk/gtkwidget.c:1145 msgid "Margin on Left" msgstr "Margin on Left" -#: ../gtk/gtkwidget.c:1208 +#: ../gtk/gtkwidget.c:1146 msgid "Pixels of extra space on the left side" msgstr "Pixels of extra space on the left side" -#: ../gtk/gtkwidget.c:1228 +#: ../gtk/gtkwidget.c:1166 msgid "Margin on Right" msgstr "Margin on Right" -#: ../gtk/gtkwidget.c:1229 +#: ../gtk/gtkwidget.c:1167 msgid "Pixels of extra space on the right side" msgstr "Pixels of extra space on the right side" -#: ../gtk/gtkwidget.c:1249 +#: ../gtk/gtkwidget.c:1187 msgid "Margin on Top" msgstr "Margin on Top" -#: ../gtk/gtkwidget.c:1250 +#: ../gtk/gtkwidget.c:1188 msgid "Pixels of extra space on the top side" msgstr "Pixels of extra space on the top side" -#: ../gtk/gtkwidget.c:1270 +#: ../gtk/gtkwidget.c:1208 msgid "Margin on Bottom" msgstr "Margin on Bottom" -#: ../gtk/gtkwidget.c:1271 +#: ../gtk/gtkwidget.c:1209 msgid "Pixels of extra space on the bottom side" msgstr "Pixels of extra space on the bottom side" -#: ../gtk/gtkwidget.c:1288 +#: ../gtk/gtkwidget.c:1226 msgid "All Margins" msgstr "All Margins" -#: ../gtk/gtkwidget.c:1289 +#: ../gtk/gtkwidget.c:1227 msgid "Pixels of extra space on all four sides" msgstr "Pixels of extra space on all four sides" -#: ../gtk/gtkwidget.c:1322 +#: ../gtk/gtkwidget.c:1260 msgid "Horizontal Expand" msgstr "Horizontal Expand" -#: ../gtk/gtkwidget.c:1323 +#: ../gtk/gtkwidget.c:1261 msgid "Whether widget wants more horizontal space" msgstr "Whether widget wants more horizontal space" -#: ../gtk/gtkwidget.c:1337 +#: ../gtk/gtkwidget.c:1275 msgid "Horizontal Expand Set" msgstr "Horizontal Expand Set" -#: ../gtk/gtkwidget.c:1338 +#: ../gtk/gtkwidget.c:1276 msgid "Whether to use the hexpand property" msgstr "Whether to use the hexpand property" -#: ../gtk/gtkwidget.c:1352 +#: ../gtk/gtkwidget.c:1290 msgid "Vertical Expand" msgstr "Vertical Expand" -#: ../gtk/gtkwidget.c:1353 +#: ../gtk/gtkwidget.c:1291 msgid "Whether widget wants more vertical space" msgstr "Whether widget wants more vertical space" -#: ../gtk/gtkwidget.c:1367 +#: ../gtk/gtkwidget.c:1305 msgid "Vertical Expand Set" msgstr "Vertical Expand Set" -#: ../gtk/gtkwidget.c:1368 +#: ../gtk/gtkwidget.c:1306 msgid "Whether to use the vexpand property" msgstr "Whether to use the vexpand property" -#: ../gtk/gtkwidget.c:1382 +#: ../gtk/gtkwidget.c:1320 msgid "Expand Both" msgstr "Expand Both" -#: ../gtk/gtkwidget.c:1383 +#: ../gtk/gtkwidget.c:1321 msgid "Whether widget wants to expand in both directions" msgstr "Whether widget wants to expand in both directions" -#: ../gtk/gtkwidget.c:3037 +#: ../gtk/gtkwidget.c:2936 msgid "Interior Focus" msgstr "Interior Focus" -#: ../gtk/gtkwidget.c:3038 +#: ../gtk/gtkwidget.c:2937 msgid "Whether to draw the focus indicator inside widgets" msgstr "Whether to draw the focus indicator inside widgets" -#: ../gtk/gtkwidget.c:3044 +#: ../gtk/gtkwidget.c:2943 msgid "Focus linewidth" msgstr "Focus linewidth" -#: ../gtk/gtkwidget.c:3045 +#: ../gtk/gtkwidget.c:2944 msgid "Width, in pixels, of the focus indicator line" msgstr "Width, in pixels, of the focus indicator line" -#: ../gtk/gtkwidget.c:3051 +#: ../gtk/gtkwidget.c:2950 msgid "Focus line dash pattern" msgstr "Focus line dash pattern" -#: ../gtk/gtkwidget.c:3052 +#: ../gtk/gtkwidget.c:2951 msgid "Dash pattern used to draw the focus indicator" msgstr "Dash pattern used to draw the focus indicator" -#: ../gtk/gtkwidget.c:3057 +#: ../gtk/gtkwidget.c:2956 msgid "Focus padding" msgstr "Focus padding" -#: ../gtk/gtkwidget.c:3058 +#: ../gtk/gtkwidget.c:2957 msgid "Width, in pixels, between focus indicator and the widget 'box'" msgstr "Width, in pixels, between focus indicator and the widget 'box'" -#: ../gtk/gtkwidget.c:3063 +#: ../gtk/gtkwidget.c:2962 msgid "Cursor color" msgstr "Cursor color" -#: ../gtk/gtkwidget.c:3064 +#: ../gtk/gtkwidget.c:2963 msgid "Color with which to draw insertion cursor" msgstr "Color with which to draw insertion cursor" -#: ../gtk/gtkwidget.c:3069 +#: ../gtk/gtkwidget.c:2968 msgid "Secondary cursor color" msgstr "Secondary cursor color" -#: ../gtk/gtkwidget.c:3070 +#: ../gtk/gtkwidget.c:2969 msgid "" "Color with which to draw the secondary insertion cursor when editing mixed " "right-to-left and left-to-right text" @@ -6984,43 +6977,43 @@ msgstr "" "Color with which to draw the secondary insertion cursor when editing mixed " "right-to-left and left-to-right text" -#: ../gtk/gtkwidget.c:3075 +#: ../gtk/gtkwidget.c:2974 msgid "Cursor line aspect ratio" msgstr "Cursor line aspect ratio" -#: ../gtk/gtkwidget.c:3076 +#: ../gtk/gtkwidget.c:2975 msgid "Aspect ratio with which to draw insertion cursor" msgstr "Aspect ratio with which to draw insertion cursor" -#: ../gtk/gtkwidget.c:3082 +#: ../gtk/gtkwidget.c:2981 msgid "Window dragging" msgstr "Window dragging" -#: ../gtk/gtkwidget.c:3083 +#: ../gtk/gtkwidget.c:2982 msgid "Whether windows can be dragged by clicking on empty areas" msgstr "Whether windows can be dragged by clicking on empty areas" -#: ../gtk/gtkwidget.c:3096 +#: ../gtk/gtkwidget.c:2995 msgid "Unvisited Link Color" msgstr "Unvisited Link Color" -#: ../gtk/gtkwidget.c:3097 +#: ../gtk/gtkwidget.c:2996 msgid "Color of unvisited links" msgstr "Color of unvisited links" -#: ../gtk/gtkwidget.c:3110 +#: ../gtk/gtkwidget.c:3009 msgid "Visited Link Color" msgstr "Visited Link Color" -#: ../gtk/gtkwidget.c:3111 +#: ../gtk/gtkwidget.c:3010 msgid "Color of visited links" msgstr "Color of visited links" -#: ../gtk/gtkwidget.c:3125 +#: ../gtk/gtkwidget.c:3024 msgid "Wide Separators" msgstr "Wide Separators" -#: ../gtk/gtkwidget.c:3126 +#: ../gtk/gtkwidget.c:3025 msgid "" "Whether separators have configurable width and should be drawn using a box " "instead of a line" @@ -7028,35 +7021,35 @@ msgstr "" "Whether separators have configurable width and should be drawn using a box " "instead of a line" -#: ../gtk/gtkwidget.c:3140 +#: ../gtk/gtkwidget.c:3039 msgid "Separator Width" msgstr "Separator Width" -#: ../gtk/gtkwidget.c:3141 +#: ../gtk/gtkwidget.c:3040 msgid "The width of separators if wide-separators is TRUE" msgstr "The width of separators if wide-separators is TRUE" -#: ../gtk/gtkwidget.c:3155 +#: ../gtk/gtkwidget.c:3054 msgid "Separator Height" msgstr "Separator Height" -#: ../gtk/gtkwidget.c:3156 +#: ../gtk/gtkwidget.c:3055 msgid "The height of separators if \"wide-separators\" is TRUE" msgstr "The height of separators if \"wide-separators\" is TRUE" -#: ../gtk/gtkwidget.c:3170 +#: ../gtk/gtkwidget.c:3069 msgid "Horizontal Scroll Arrow Length" msgstr "Horizontal Scroll Arrow Length" -#: ../gtk/gtkwidget.c:3171 +#: ../gtk/gtkwidget.c:3070 msgid "The length of horizontal scroll arrows" msgstr "The length of horizontal scroll arrows" -#: ../gtk/gtkwidget.c:3185 +#: ../gtk/gtkwidget.c:3084 msgid "Vertical Scroll Arrow Length" msgstr "Vertical Scroll Arrow Length" -#: ../gtk/gtkwidget.c:3186 +#: ../gtk/gtkwidget.c:3085 msgid "The length of vertical scroll arrows" msgstr "The length of vertical scroll arrows" @@ -7299,6 +7292,33 @@ msgstr "GtkApplication" msgid "The GtkApplication for the window" msgstr "The GtkApplication for the window" +#~ msgid "Lower" +#~ msgstr "Lower" + +#~ msgid "Lower limit of ruler" +#~ msgstr "Lower limit of ruler" + +#~ msgid "Upper" +#~ msgstr "Upper" + +#~ msgid "Upper limit of ruler" +#~ msgstr "Upper limit of ruler" + +#~ msgid "Position of mark on the ruler" +#~ msgstr "Position of mark on the ruler" + +#~ msgid "Max Size" +#~ msgstr "Max Size" + +#~ msgid "Maximum size of the ruler" +#~ msgstr "Maximum size of the ruler" + +#~ msgid "Metric" +#~ msgstr "Metric" + +#~ msgid "The metric used for the ruler" +#~ msgstr "The metric used for the ruler" + #~ msgid "Horizontal adjustment" #~ msgstr "Horizontal adjustment" diff --git a/po/he.po b/po/he.po index d4a9fbe596..4f465b6de0 100644 --- a/po/he.po +++ b/po/he.po @@ -10,8 +10,8 @@ msgid "" msgstr "" "Project-Id-Version: gtk+.HEAD.he\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-10-23 02:38+0200\n" -"PO-Revision-Date: 2010-10-23 02:40+0200\n" +"POT-Creation-Date: 2010-12-04 15:16+0200\n" +"PO-Revision-Date: 2010-12-04 15:25+0200\n" "Last-Translator: Yaron Shahrabani \n" "Language-Team: Hebrew \n" "MIME-Version: 1.0\n" @@ -20,58 +20,58 @@ msgstr "" "Language: he\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: ../gdk/gdk.c:104 +#: ../gdk/gdk.c:115 #, c-format msgid "Error parsing option --gdk-debug" msgstr "Error parsing option --gdk-debug" -#: ../gdk/gdk.c:124 +#: ../gdk/gdk.c:135 #, c-format msgid "Error parsing option --gdk-no-debug" msgstr "Error parsing option --gdk-no-debug" #. Description of --class=CLASS in --help output -#: ../gdk/gdk.c:152 +#: ../gdk/gdk.c:163 msgid "Program class as used by the window manager" msgstr "Program class as used by the window manager" #. Placeholder in --class=CLASS in --help output -#: ../gdk/gdk.c:153 +#: ../gdk/gdk.c:164 msgid "CLASS" msgstr "CLASS" #. Description of --name=NAME in --help output -#: ../gdk/gdk.c:155 +#: ../gdk/gdk.c:166 msgid "Program name as used by the window manager" msgstr "Program name as used by the window manager" #. Placeholder in --name=NAME in --help output -#: ../gdk/gdk.c:156 +#: ../gdk/gdk.c:167 msgid "NAME" msgstr "NAME" #. Description of --display=DISPLAY in --help output -#: ../gdk/gdk.c:158 +#: ../gdk/gdk.c:169 msgid "X display to use" msgstr "X display to use" #. Placeholder in --display=DISPLAY in --help output -#: ../gdk/gdk.c:159 +#: ../gdk/gdk.c:170 msgid "DISPLAY" msgstr "DISPLAY" #. Description of --screen=SCREEN in --help output -#: ../gdk/gdk.c:161 +#: ../gdk/gdk.c:172 msgid "X screen to use" msgstr "X screen to use" #. Placeholder in --screen=SCREEN in --help output -#: ../gdk/gdk.c:162 +#: ../gdk/gdk.c:173 msgid "SCREEN" msgstr "SCREEN" #. Description of --gdk-debug=FLAGS in --help output -#: ../gdk/gdk.c:165 +#: ../gdk/gdk.c:176 msgid "GDK debugging flags to set" msgstr "GDK debugging flags to set" @@ -79,12 +79,12 @@ msgstr "GDK debugging flags to set" #. Placeholder in --gdk-no-debug=FLAGS in --help output #. Placeholder in --gtk-debug=FLAGS in --help output #. Placeholder in --gtk-no-debug=FLAGS in --help output -#: ../gdk/gdk.c:166 ../gdk/gdk.c:169 ../gtk/gtkmain.c:534 ../gtk/gtkmain.c:537 +#: ../gdk/gdk.c:177 ../gdk/gdk.c:180 ../gtk/gtkmain.c:523 ../gtk/gtkmain.c:526 msgid "FLAGS" msgstr "FLAGS" #. Description of --gdk-no-debug=FLAGS in --help output -#: ../gdk/gdk.c:168 +#: ../gdk/gdk.c:179 msgid "GDK debugging flags to unset" msgstr "GDK debugging flags to unset" @@ -305,17 +305,17 @@ msgstr "Size of the palette in 8 bit mode" msgid "COLORS" msgstr "COLORS" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:312 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:305 #, c-format msgid "Starting %s" msgstr "מתחיל את %s" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:316 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:318 #, c-format msgid "Opening %s" msgstr "פותח את %s" -#: ../gdk/x11/gdkapplaunchcontext-x11.c:321 +#: ../gdk/x11/gdkapplaunchcontext-x11.c:323 #, c-format msgid "Opening %d Item" msgid_plural "Opening %d Items" @@ -335,7 +335,7 @@ msgstr "Make X calls synchronous" msgid "This program comes with ABSOLUTELY NO WARRANTY; for details, visit %s" msgstr "תכנית זו מופצת ללא שום אחריות; לפרטים נא לבקר בכתובת %s" -#: ../gtk/gtkaboutdialog.c:339 ../gtk/gtkaboutdialog.c:2232 +#: ../gtk/gtkaboutdialog.c:339 ../gtk/gtkaboutdialog.c:2233 msgid "License" msgstr "רישיון" @@ -344,41 +344,41 @@ msgid "The license of the program" msgstr "רישיון השימוש בתוכנה" #. Add the credits button -#: ../gtk/gtkaboutdialog.c:621 +#: ../gtk/gtkaboutdialog.c:622 msgid "C_redits" msgstr "_תודות" #. Add the license button -#: ../gtk/gtkaboutdialog.c:635 +#: ../gtk/gtkaboutdialog.c:636 msgid "_License" msgstr "_רישיון" -#: ../gtk/gtkaboutdialog.c:839 +#: ../gtk/gtkaboutdialog.c:840 msgid "Could not show link" msgstr "לא ניתן להציג את הקישור" -#: ../gtk/gtkaboutdialog.c:932 +#: ../gtk/gtkaboutdialog.c:933 #, c-format msgid "About %s" msgstr "על אודות %s" -#: ../gtk/gtkaboutdialog.c:2150 +#: ../gtk/gtkaboutdialog.c:2151 msgid "Credits" msgstr "תודות" -#: ../gtk/gtkaboutdialog.c:2182 +#: ../gtk/gtkaboutdialog.c:2183 msgid "Written by" msgstr "נכתב על ידי" -#: ../gtk/gtkaboutdialog.c:2185 +#: ../gtk/gtkaboutdialog.c:2186 msgid "Documented by" msgstr "תועד על ידי" -#: ../gtk/gtkaboutdialog.c:2197 +#: ../gtk/gtkaboutdialog.c:2198 msgid "Translated by" msgstr "תורגם על ידי" -#: ../gtk/gtkaboutdialog.c:2201 +#: ../gtk/gtkaboutdialog.c:2202 msgid "Artwork by" msgstr "אומנות על ידי" @@ -482,7 +482,7 @@ msgstr "תגית בלתי מטופלת: '%s'" #. * text direction of RTL and specify "calendar:YM", then the year #. * will appear to the right of the month. #. -#: ../gtk/gtkcalendar.c:883 +#: ../gtk/gtkcalendar.c:878 msgid "calendar:MY" msgstr "calendar:YM" @@ -490,7 +490,7 @@ msgstr "calendar:YM" #. * first day of the week to calendar:week_start:1 if you want Monday #. * to be the first day of the week, and so on. #. -#: ../gtk/gtkcalendar.c:921 +#: ../gtk/gtkcalendar.c:916 msgid "calendar:week_start:0" msgstr "calendar:week_start:0" @@ -499,7 +499,7 @@ msgstr "calendar:week_start:0" #. * #. * If you don't understand this, leave it as "2000" #. -#: ../gtk/gtkcalendar.c:2006 +#: ../gtk/gtkcalendar.c:1848 msgctxt "year measurement template" msgid "2000" msgstr "2000" @@ -514,7 +514,7 @@ msgstr "2000" #. * digits. That needs support from your system and locale definition #. * too. #. -#: ../gtk/gtkcalendar.c:2037 ../gtk/gtkcalendar.c:2719 +#: ../gtk/gtkcalendar.c:1879 ../gtk/gtkcalendar.c:2564 #, c-format msgctxt "calendar:day:digits" msgid "%d" @@ -530,7 +530,7 @@ msgstr "%d" #. * digits. That needs support from your system and locale definition #. * too. #. -#: ../gtk/gtkcalendar.c:2069 ../gtk/gtkcalendar.c:2579 +#: ../gtk/gtkcalendar.c:1911 ../gtk/gtkcalendar.c:2432 #, c-format msgctxt "calendar:week:digits" msgid "%d" @@ -546,7 +546,7 @@ msgstr "%d" #. * #. * "%Y" is appropriate for most locales. #. -#: ../gtk/gtkcalendar.c:2361 +#: ../gtk/gtkcalendar.c:2197 msgctxt "calendar year format" msgid "%Y" msgstr "%Y" @@ -582,15 +582,15 @@ msgctxt "progress bar label" msgid "%d %%" msgstr "%d %%" -#: ../gtk/gtkcolorbutton.c:175 ../gtk/gtkcolorbutton.c:460 +#: ../gtk/gtkcolorbutton.c:188 ../gtk/gtkcolorbutton.c:473 msgid "Pick a Color" msgstr "בחירת צבע" -#: ../gtk/gtkcolorbutton.c:350 +#: ../gtk/gtkcolorbutton.c:363 msgid "Received invalid color data\n" msgstr "התקבלו נתוני צבע בלתי תקינים\n" -#: ../gtk/gtkcolorsel.c:395 +#: ../gtk/gtkcolorsel.c:416 msgid "" "Select the color you want from the outer ring. Select the darkness or " "lightness of that color using the inner triangle." @@ -598,73 +598,73 @@ msgstr "" "יש לבחור את הצבע הרצוי מהטבעת החיצונית. ניתן לבחור כמה כהה או בהיר יהיה צבע " "זה בעזרת המשולש הפנימי." -#: ../gtk/gtkcolorsel.c:419 +#: ../gtk/gtkcolorsel.c:440 msgid "" "Click the eyedropper, then click a color anywhere on your screen to select " "that color." msgstr "יש ללחוץ על הטפטפת ואז ללחוץ על צבע כלשהו במסך לבחירת אותו הצבע." -#: ../gtk/gtkcolorsel.c:428 +#: ../gtk/gtkcolorsel.c:449 msgid "_Hue:" msgstr "_גוון:" -#: ../gtk/gtkcolorsel.c:429 +#: ../gtk/gtkcolorsel.c:450 msgid "Position on the color wheel." msgstr "מיקום על גלגל הצבעים." -#: ../gtk/gtkcolorsel.c:431 +#: ../gtk/gtkcolorsel.c:452 msgid "_Saturation:" msgstr "_רוויה:" -#: ../gtk/gtkcolorsel.c:432 +#: ../gtk/gtkcolorsel.c:453 msgid "Intensity of the color." msgstr "חוזק הצבע." -#: ../gtk/gtkcolorsel.c:433 +#: ../gtk/gtkcolorsel.c:454 msgid "_Value:" msgstr "_ערך:" -#: ../gtk/gtkcolorsel.c:434 +#: ../gtk/gtkcolorsel.c:455 msgid "Brightness of the color." msgstr "בהירות הצבע." -#: ../gtk/gtkcolorsel.c:435 +#: ../gtk/gtkcolorsel.c:456 msgid "_Red:" msgstr "_אדום:" -#: ../gtk/gtkcolorsel.c:436 +#: ../gtk/gtkcolorsel.c:457 msgid "Amount of red light in the color." msgstr "כמות האור האדום בצבע." -#: ../gtk/gtkcolorsel.c:437 +#: ../gtk/gtkcolorsel.c:458 msgid "_Green:" msgstr "_ירוק:" -#: ../gtk/gtkcolorsel.c:438 +#: ../gtk/gtkcolorsel.c:459 msgid "Amount of green light in the color." msgstr "כמות האור הירוק בצבע." -#: ../gtk/gtkcolorsel.c:439 +#: ../gtk/gtkcolorsel.c:460 msgid "_Blue:" msgstr "_כחול:" -#: ../gtk/gtkcolorsel.c:440 +#: ../gtk/gtkcolorsel.c:461 msgid "Amount of blue light in the color." msgstr "כמות האור הכחול בצבע." -#: ../gtk/gtkcolorsel.c:443 +#: ../gtk/gtkcolorsel.c:464 msgid "Op_acity:" msgstr "_אטימות:" -#: ../gtk/gtkcolorsel.c:450 ../gtk/gtkcolorsel.c:460 +#: ../gtk/gtkcolorsel.c:471 ../gtk/gtkcolorsel.c:481 msgid "Transparency of the color." msgstr "אטימות הצבע." -#: ../gtk/gtkcolorsel.c:467 +#: ../gtk/gtkcolorsel.c:488 msgid "Color _name:" msgstr "_שם הצבע:" -#: ../gtk/gtkcolorsel.c:481 +#: ../gtk/gtkcolorsel.c:502 msgid "" "You can enter an HTML-style hexadecimal color value, or simply a color name " "such as 'orange' in this entry." @@ -672,15 +672,15 @@ msgstr "" "ניתן להזין ערך צבע הקסדצימלי בסגנון HTML, או פשוט לכתוב שם צבע באנגלית כמו " "'orange' ברשומה זו." -#: ../gtk/gtkcolorsel.c:511 +#: ../gtk/gtkcolorsel.c:532 msgid "_Palette:" msgstr "_פלטה:" -#: ../gtk/gtkcolorsel.c:540 +#: ../gtk/gtkcolorsel.c:561 msgid "Color Wheel" msgstr "גלגל הצבעים" -#: ../gtk/gtkcolorsel.c:1010 +#: ../gtk/gtkcolorsel.c:1031 msgid "" "The previously-selected color, for comparison to the color you're selecting " "now. You can drag this color to a palette entry, or select this color as " @@ -689,27 +689,27 @@ msgstr "" "הצבע הקודם שנבחר, להשוואה עם הצבע הנבחר כעת. ניתן לגרור צבע זה לרשומה בפלטה, " "או לבחור צבע זה כנוכחי על־ידי גרירתו לפיסת הצבע השנייה שלצידו." -#: ../gtk/gtkcolorsel.c:1013 +#: ../gtk/gtkcolorsel.c:1034 msgid "" "The color you've chosen. You can drag this color to a palette entry to save " "it for use in the future." msgstr "הצבע שנבחר. ניתן לגרור צבע זה לרשומת פלטה כדי לשמור אותו לשימוש בעתיד." -#: ../gtk/gtkcolorsel.c:1018 +#: ../gtk/gtkcolorsel.c:1039 msgid "" "The previously-selected color, for comparison to the color you're selecting " "now." msgstr "הצבע הקודם שנבחר, להשוואה עם הצבע שנבחר כעת." -#: ../gtk/gtkcolorsel.c:1021 +#: ../gtk/gtkcolorsel.c:1042 msgid "The color you've chosen." msgstr "הצבע שנבחר." -#: ../gtk/gtkcolorsel.c:1421 +#: ../gtk/gtkcolorsel.c:1442 msgid "_Save color here" msgstr "_שמירת הצבע כאן" -#: ../gtk/gtkcolorsel.c:1626 +#: ../gtk/gtkcolorsel.c:1647 msgid "" "Click this palette entry to make it the current color. To change this entry, " "drag a color swatch here or right-click it and select \"Save color here.\"" @@ -785,23 +785,23 @@ msgstr "_ימין:" msgid "Paper Margins" msgstr "שולי נייר" -#: ../gtk/gtkentry.c:8565 ../gtk/gtktextview.c:8158 +#: ../gtk/gtkentry.c:8794 ../gtk/gtktextview.c:8229 msgid "Input _Methods" msgstr "_שיטות קלט" -#: ../gtk/gtkentry.c:8579 ../gtk/gtktextview.c:8172 +#: ../gtk/gtkentry.c:8808 ../gtk/gtktextview.c:8243 msgid "_Insert Unicode Control Character" msgstr "_הזנת תו בקרה יוניקוד" -#: ../gtk/gtkentry.c:9979 +#: ../gtk/gtkentry.c:10208 msgid "Caps Lock and Num Lock are on" msgstr "ה־Caps Lock וה־Num Lock פעילים" -#: ../gtk/gtkentry.c:9981 +#: ../gtk/gtkentry.c:10210 msgid "Num Lock is on" msgstr "ה־Num Lock פעיל" -#: ../gtk/gtkentry.c:9983 +#: ../gtk/gtkentry.c:10212 msgid "Caps Lock is on" msgstr "ה־Caps Lock פעיל" @@ -820,7 +820,7 @@ msgstr "שולחן עבודה" msgid "(None)" msgstr "(ללא)" -#: ../gtk/gtkfilechooserbutton.c:1997 +#: ../gtk/gtkfilechooserbutton.c:2001 msgid "Other..." msgstr "אחר..." @@ -880,228 +880,228 @@ msgstr "‏%1$s ב־%2$s" msgid "Search" msgstr "חיפוש" -#: ../gtk/gtkfilechooserdefault.c:1776 ../gtk/gtkfilechooserdefault.c:9382 +#: ../gtk/gtkfilechooserdefault.c:1776 ../gtk/gtkfilechooserdefault.c:9417 msgid "Recently Used" msgstr "בשימוש לאחרונה" -#: ../gtk/gtkfilechooserdefault.c:2430 +#: ../gtk/gtkfilechooserdefault.c:2437 msgid "Select which types of files are shown" msgstr "בחירה בסוגי הקבצים שיוצגו" -#: ../gtk/gtkfilechooserdefault.c:2789 +#: ../gtk/gtkfilechooserdefault.c:2796 #, c-format msgid "Add the folder '%s' to the bookmarks" msgstr "הוסף את התיקייה '%s' לסימניות" -#: ../gtk/gtkfilechooserdefault.c:2833 +#: ../gtk/gtkfilechooserdefault.c:2840 #, c-format msgid "Add the current folder to the bookmarks" msgstr "הוסף את התיקייה הנוכחית לסימניות" -#: ../gtk/gtkfilechooserdefault.c:2835 +#: ../gtk/gtkfilechooserdefault.c:2842 #, c-format msgid "Add the selected folders to the bookmarks" msgstr "הוסף את התיקיות הנבחרות לסימניות" -#: ../gtk/gtkfilechooserdefault.c:2873 +#: ../gtk/gtkfilechooserdefault.c:2880 #, c-format msgid "Remove the bookmark '%s'" msgstr "הסרת הסימנייה '%s'" -#: ../gtk/gtkfilechooserdefault.c:2875 +#: ../gtk/gtkfilechooserdefault.c:2882 #, c-format msgid "Bookmark '%s' cannot be removed" msgstr "לא ניתן להסיר את הסימנייה '%s'" -#: ../gtk/gtkfilechooserdefault.c:2882 ../gtk/gtkfilechooserdefault.c:3746 +#: ../gtk/gtkfilechooserdefault.c:2889 ../gtk/gtkfilechooserdefault.c:3750 msgid "Remove the selected bookmark" msgstr "הסרת הסימנייה הנבחרת" -#: ../gtk/gtkfilechooserdefault.c:3442 +#: ../gtk/gtkfilechooserdefault.c:3445 msgid "Remove" msgstr "הסרה" -#: ../gtk/gtkfilechooserdefault.c:3451 +#: ../gtk/gtkfilechooserdefault.c:3454 msgid "Rename..." msgstr "שינוי שם..." #. Accessible object name for the file chooser's shortcuts pane -#: ../gtk/gtkfilechooserdefault.c:3614 +#: ../gtk/gtkfilechooserdefault.c:3617 msgid "Places" msgstr "מקומות" #. Column header for the file chooser's shortcuts pane -#: ../gtk/gtkfilechooserdefault.c:3671 +#: ../gtk/gtkfilechooserdefault.c:3674 msgid "_Places" msgstr "_מקומות" -#: ../gtk/gtkfilechooserdefault.c:3727 +#: ../gtk/gtkfilechooserdefault.c:3731 msgid "_Add" msgstr "_הוספה" -#: ../gtk/gtkfilechooserdefault.c:3734 +#: ../gtk/gtkfilechooserdefault.c:3738 msgid "Add the selected folder to the Bookmarks" msgstr "הוספת התיקייה הנבחרת לסימניות" -#: ../gtk/gtkfilechooserdefault.c:3739 +#: ../gtk/gtkfilechooserdefault.c:3743 msgid "_Remove" msgstr "_הסרה" -#: ../gtk/gtkfilechooserdefault.c:3881 +#: ../gtk/gtkfilechooserdefault.c:3885 msgid "Could not select file" msgstr "לא ניתן לבחור את הקובץ" -#: ../gtk/gtkfilechooserdefault.c:4056 +#: ../gtk/gtkfilechooserdefault.c:4060 msgid "_Add to Bookmarks" msgstr "_הוספה לסימניות" -#: ../gtk/gtkfilechooserdefault.c:4069 +#: ../gtk/gtkfilechooserdefault.c:4073 msgid "Show _Hidden Files" msgstr "הצגת קבצים _נסתרים" -#: ../gtk/gtkfilechooserdefault.c:4076 +#: ../gtk/gtkfilechooserdefault.c:4080 msgid "Show _Size Column" msgstr "הצגת _רוחב העמודה" # hebrew note: "תיקייה" is "folder", but there is no better word for # "directory" -#: ../gtk/gtkfilechooserdefault.c:4302 +#: ../gtk/gtkfilechooserdefault.c:4306 msgid "Files" msgstr "קבצים" -#: ../gtk/gtkfilechooserdefault.c:4353 +#: ../gtk/gtkfilechooserdefault.c:4357 msgid "Name" msgstr "שם" -#: ../gtk/gtkfilechooserdefault.c:4376 +#: ../gtk/gtkfilechooserdefault.c:4380 msgid "Size" msgstr "גודל" -#: ../gtk/gtkfilechooserdefault.c:4390 +#: ../gtk/gtkfilechooserdefault.c:4394 msgid "Modified" msgstr "שונה" #. Label -#: ../gtk/gtkfilechooserdefault.c:4645 ../gtk/gtkprinteroptionwidget.c:793 +#: ../gtk/gtkfilechooserdefault.c:4649 ../gtk/gtkprinteroptionwidget.c:793 msgid "_Name:" msgstr "_שם:" -#: ../gtk/gtkfilechooserdefault.c:4688 +#: ../gtk/gtkfilechooserdefault.c:4692 msgid "_Browse for other folders" msgstr "_דפדוף לתיקיות אחרות" -#: ../gtk/gtkfilechooserdefault.c:4958 +#: ../gtk/gtkfilechooserdefault.c:4962 msgid "Type a file name" msgstr "הזנת שם קובץ" #. Create Folder -#: ../gtk/gtkfilechooserdefault.c:5001 +#: ../gtk/gtkfilechooserdefault.c:5005 msgid "Create Fo_lder" msgstr "יצירת _תיקייה" -#: ../gtk/gtkfilechooserdefault.c:5011 +#: ../gtk/gtkfilechooserdefault.c:5015 msgid "_Location:" msgstr "_מיקום:" -#: ../gtk/gtkfilechooserdefault.c:5215 +#: ../gtk/gtkfilechooserdefault.c:5219 msgid "Save in _folder:" msgstr "שמירה ב_תיקייה:" -#: ../gtk/gtkfilechooserdefault.c:5217 +#: ../gtk/gtkfilechooserdefault.c:5221 msgid "Create in _folder:" msgstr "יצירה ב_תיקייה:" -#: ../gtk/gtkfilechooserdefault.c:6286 +#: ../gtk/gtkfilechooserdefault.c:6290 #, c-format msgid "Could not read the contents of %s" msgstr "לא ניתן לקרוא את התוכן של %s" -#: ../gtk/gtkfilechooserdefault.c:6290 +#: ../gtk/gtkfilechooserdefault.c:6294 msgid "Could not read the contents of the folder" msgstr "לא ניתן לקרוא את תכני התיקייה" -#: ../gtk/gtkfilechooserdefault.c:6383 ../gtk/gtkfilechooserdefault.c:6451 -#: ../gtk/gtkfilechooserdefault.c:6596 +#: ../gtk/gtkfilechooserdefault.c:6387 ../gtk/gtkfilechooserdefault.c:6455 +#: ../gtk/gtkfilechooserdefault.c:6600 msgid "Unknown" msgstr "לא ידוע" -#: ../gtk/gtkfilechooserdefault.c:6398 +#: ../gtk/gtkfilechooserdefault.c:6402 msgid "%H:%M" msgstr "%H:%M" -#: ../gtk/gtkfilechooserdefault.c:6400 +#: ../gtk/gtkfilechooserdefault.c:6404 msgid "Yesterday at %H:%M" msgstr "אתמול ב־%H:%M" -#: ../gtk/gtkfilechooserdefault.c:7066 +#: ../gtk/gtkfilechooserdefault.c:7070 msgid "Cannot change to folder because it is not local" msgstr "לא ניתן לשנות תיקייה כיוון שהיא איננה מקומית" -#: ../gtk/gtkfilechooserdefault.c:7663 ../gtk/gtkfilechooserdefault.c:7684 +#: ../gtk/gtkfilechooserdefault.c:7667 ../gtk/gtkfilechooserdefault.c:7688 #, c-format msgid "Shortcut %s already exists" msgstr "הקיצור %s כבר קיים" -#: ../gtk/gtkfilechooserdefault.c:7774 +#: ../gtk/gtkfilechooserdefault.c:7778 #, c-format msgid "Shortcut %s does not exist" msgstr "הקיצור %s אינו קיים" -#: ../gtk/gtkfilechooserdefault.c:8035 ../gtk/gtkprintunixdialog.c:480 +#: ../gtk/gtkfilechooserdefault.c:8039 ../gtk/gtkprintunixdialog.c:480 #, c-format msgid "A file named \"%s\" already exists. Do you want to replace it?" msgstr "קובץ בשם \"%s\" כבר קיים. האם ברצונך להחליפו?" -#: ../gtk/gtkfilechooserdefault.c:8038 ../gtk/gtkprintunixdialog.c:484 +#: ../gtk/gtkfilechooserdefault.c:8042 ../gtk/gtkprintunixdialog.c:484 #, c-format msgid "" "The file already exists in \"%s\". Replacing it will overwrite its contents." msgstr "הקובץ כבר קיים ב-\"%s\". החלפתו תגרום לאיבוד תוכנו." -#: ../gtk/gtkfilechooserdefault.c:8043 ../gtk/gtkprintunixdialog.c:491 +#: ../gtk/gtkfilechooserdefault.c:8047 ../gtk/gtkprintunixdialog.c:491 msgid "_Replace" msgstr "ה_חלפה" -#: ../gtk/gtkfilechooserdefault.c:8751 +#: ../gtk/gtkfilechooserdefault.c:8755 msgid "Could not start the search process" msgstr "לא ניתן להתחיל את תהליך החיפוש" -#: ../gtk/gtkfilechooserdefault.c:8752 +#: ../gtk/gtkfilechooserdefault.c:8756 msgid "" "The program was not able to create a connection to the indexer daemon. " "Please make sure it is running." msgstr "התנית לא הצליחה ליצור חיבור אל סוכן האינדקס. יש לוודא כי הוא פעיל." -#: ../gtk/gtkfilechooserdefault.c:8766 +#: ../gtk/gtkfilechooserdefault.c:8770 msgid "Could not send the search request" msgstr "לא ניתן לשלוח את בקשת החיפוש" -#: ../gtk/gtkfilechooserdefault.c:8954 +#: ../gtk/gtkfilechooserdefault.c:8989 msgid "Search:" msgstr "חיפוש:" -#: ../gtk/gtkfilechooserdefault.c:9559 +#: ../gtk/gtkfilechooserdefault.c:9594 #, c-format msgid "Could not mount %s" msgstr "לא ניתן לעגון את %s" #. Translators: this is shown in the feedback for Tab-completion in a file #. * chooser's text entry, when the user enters an invalid path. -#: ../gtk/gtkfilechooserentry.c:702 ../gtk/gtkfilechooserentry.c:1169 +#: ../gtk/gtkfilechooserentry.c:702 ../gtk/gtkfilechooserentry.c:1172 msgid "Invalid path" msgstr "נתיב לא תקין" #. translators: this text is shown when there are no completions #. * for something the user typed in a file chooser entry #. -#: ../gtk/gtkfilechooserentry.c:1101 +#: ../gtk/gtkfilechooserentry.c:1104 msgid "No match" msgstr "אין התאמה" #. translators: this text is shown when there is exactly one completion #. * for something the user typed in a file chooser entry #. -#: ../gtk/gtkfilechooserentry.c:1112 +#: ../gtk/gtkfilechooserentry.c:1115 msgid "Sole completion" msgstr "השלמה יחידה" @@ -1109,13 +1109,13 @@ msgstr "השלמה יחידה" #. * entry is a complete filename, but could be continued to find #. * a longer match #. -#: ../gtk/gtkfilechooserentry.c:1128 +#: ../gtk/gtkfilechooserentry.c:1131 msgid "Complete, but not unique" msgstr "שלם, אבל לא ייחודי" #. Translators: this text is shown while the system is searching #. * for possible completions for filenames in a file chooser entry. -#: ../gtk/gtkfilechooserentry.c:1160 +#: ../gtk/gtkfilechooserentry.c:1163 msgid "Completing..." msgstr "משלים..." @@ -1123,7 +1123,7 @@ msgstr "משלים..." #. Translators: this is shown in the feedback for Tab-completion in a #. * file chooser's text entry when the user enters something like #. * "sftp://blahblah" in an app that only supports local filenames. -#: ../gtk/gtkfilechooserentry.c:1182 ../gtk/gtkfilechooserentry.c:1207 +#: ../gtk/gtkfilechooserentry.c:1185 ../gtk/gtkfilechooserentry.c:1210 msgid "Only local files may be selected" msgstr "ניתן לבחור קבצים מקומיים בלבד" @@ -1131,14 +1131,14 @@ msgstr "ניתן לבחור קבצים מקומיים בלבד" #. Translators: this is shown in the feedback for Tab-completion in a #. * file chooser's text entry when the user hasn't entered the first '/' #. * after a hostname and yet hits Tab (such as "sftp://blahblah[Tab]") -#: ../gtk/gtkfilechooserentry.c:1191 +#: ../gtk/gtkfilechooserentry.c:1194 msgid "Incomplete hostname; end it with '/'" msgstr "שם המארח אינו מלא; יש לסיימו ב־'/'" #. Translators: this is shown in the feedback for Tab-completion in a file #. * chooser's text entry when the user enters a path that does not exist #. * and then hits Tab -#: ../gtk/gtkfilechooserentry.c:1202 +#: ../gtk/gtkfilechooserentry.c:1205 msgid "Path does not exist" msgstr "נתיב לא קיים" @@ -1185,11 +1185,11 @@ msgid "Si_ze:" msgstr "_גודל:" #. create the text entry widget -#: ../gtk/gtkfontsel.c:559 +#: ../gtk/gtkfontsel.c:558 msgid "_Preview:" msgstr "_תצוגה מקדימה:" -#: ../gtk/gtkfontsel.c:1659 +#: ../gtk/gtkfontsel.c:1658 msgid "Font Selection" msgstr "בחירת גופן" @@ -1201,7 +1201,7 @@ msgstr "בחירת גופן" msgid "Error loading icon: %s" msgstr "שגיאה בטעינת סמל: %s" -#: ../gtk/gtkicontheme.c:1354 +#: ../gtk/gtkicontheme.c:1355 #, c-format msgid "" "Could not find the icon '%s'. The '%s' theme\n" @@ -1214,12 +1214,12 @@ msgstr "" "אתה יכול לקבל עותק מ:\n" "\t%s" -#: ../gtk/gtkicontheme.c:1535 +#: ../gtk/gtkicontheme.c:1536 #, c-format msgid "Icon '%s' not present in theme" msgstr "הסמל '%s' לא קיים בערכת הנושא" -#: ../gtk/gtkicontheme.c:3048 +#: ../gtk/gtkicontheme.c:3057 msgid "Failed to load icon" msgstr "ארע כשל בטעינת סמל" @@ -1246,12 +1246,12 @@ msgid "System (%s)" msgstr "מערכת (%s)" #. Open Link -#: ../gtk/gtklabel.c:6196 +#: ../gtk/gtklabel.c:6215 msgid "_Open Link" msgstr "_פתיחת קישור" #. Copy Link Address -#: ../gtk/gtklabel.c:6208 +#: ../gtk/gtklabel.c:6227 msgid "Copy _Link Address" msgstr "העתקת כתובת ה_קישור" @@ -1264,27 +1264,27 @@ msgid "Invalid URI" msgstr "כתובת לא תקנית" #. Description of --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:527 +#: ../gtk/gtkmain.c:516 msgid "Load additional GTK+ modules" msgstr "Load additional GTK+ modules" #. Placeholder in --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:528 +#: ../gtk/gtkmain.c:517 msgid "MODULES" msgstr "MODULES" #. Description of --g-fatal-warnings in --help output -#: ../gtk/gtkmain.c:530 +#: ../gtk/gtkmain.c:519 msgid "Make all warnings fatal" msgstr "Make all warnings fatal" #. Description of --gtk-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:533 +#: ../gtk/gtkmain.c:522 msgid "GTK+ debugging flags to set" msgstr "GTK+ debugging flags to set" #. Description of --gtk-no-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:536 +#: ../gtk/gtkmain.c:525 msgid "GTK+ debugging flags to unset" msgstr "GTK+ debugging flags to unset" @@ -1293,20 +1293,20 @@ msgstr "GTK+ debugging flags to unset" #. * Do *not* translate it to "predefinito:LTR", if it #. * it isn't default:LTR or default:RTL it will not work #. -#: ../gtk/gtkmain.c:799 +#: ../gtk/gtkmain.c:788 msgid "default:LTR" msgstr "default:RTL" -#: ../gtk/gtkmain.c:864 +#: ../gtk/gtkmain.c:853 #, c-format msgid "Cannot open display: %s" msgstr "Cannot open display: %s" -#: ../gtk/gtkmain.c:923 +#: ../gtk/gtkmain.c:912 msgid "GTK+ Options" msgstr "GTK+ Options" -#: ../gtk/gtkmain.c:923 +#: ../gtk/gtkmain.c:912 msgid "Show GTK+ Options" msgstr "Show GTK+ Options" @@ -1390,12 +1390,12 @@ msgstr "מעטפת Z" msgid "Cannot end process with PID %d: %s" msgstr "לא ניתן לסיים את התהליך בעל המזהה %d: ‏%s" -#: ../gtk/gtknotebook.c:4724 ../gtk/gtknotebook.c:7287 +#: ../gtk/gtknotebook.c:4756 ../gtk/gtknotebook.c:7319 #, c-format msgid "Page %u" msgstr "עמוד %u" -#: ../gtk/gtkpagesetup.c:596 ../gtk/gtkpapersize.c:838 +#: ../gtk/gtkpagesetup.c:648 ../gtk/gtkpapersize.c:838 #: ../gtk/gtkpapersize.c:880 msgid "Not a valid page setup file" msgstr "קובץ הגדרות עמוד לא תקין" @@ -1443,17 +1443,17 @@ msgstr "_כיווניות:" msgid "Page Setup" msgstr "הגדרות עמוד" -#: ../gtk/gtkpathbar.c:154 +#: ../gtk/gtkpathbar.c:158 msgid "Up Path" msgstr "נתיב מעלה" -#: ../gtk/gtkpathbar.c:156 +#: ../gtk/gtkpathbar.c:160 msgid "Down Path" msgstr "נתיב מטה" # hebrew note: "תיקייה" is "folder", but there is no better word for # "directory" -#: ../gtk/gtkpathbar.c:1490 +#: ../gtk/gtkpathbar.c:1523 msgid "File System Root" msgstr "שורש מערכת הקבצים" @@ -2049,12 +2049,12 @@ msgstr "לא ניתן למצוא פריט עם כתובת '%s'" msgid "No registered application with name '%s' for item with URI '%s' found" msgstr "לא נמצא יישום הרשום בשם '%s' עבור הפריט בעל הכתובת '%s'" -#: ../gtk/gtkspinner.c:456 +#: ../gtk/gtkspinner.c:439 msgctxt "throbbing progress animation widget" msgid "Spinner" msgstr "הנפשת המתנה" -#: ../gtk/gtkspinner.c:457 +#: ../gtk/gtkspinner.c:440 msgid "Provides visual indication of progress" msgstr "אספקת חיווי חזותי של התהליך" @@ -2567,6 +2567,32 @@ msgctxt "Stock label" msgid "Zoom _Out" msgstr "הת_רחקות" +#. Translators: if the "on" state label requires more than three +#. * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for +#. * the state +#. +#: ../gtk/gtkswitch.c:296 ../gtk/gtkswitch.c:339 ../gtk/gtkswitch.c:531 +msgctxt "switch" +msgid "ON" +msgstr "❙" + +#. Translators: if the "off" state label requires more than three +#. * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state +#. +#: ../gtk/gtkswitch.c:304 ../gtk/gtkswitch.c:340 ../gtk/gtkswitch.c:552 +msgctxt "switch" +msgid "OFF" +msgstr "○" + +#: ../gtk/gtkswitch.c:943 +msgctxt "light switch widget" +msgid "Switch" +msgstr "החלפה" + +#: ../gtk/gtkswitch.c:944 +msgid "Switches between on and off states" +msgstr "החלפה בין המצבים פעיל ולא פעיל" + #: ../gtk/gtktextbufferrichtext.c:650 #, c-format msgid "Unknown error when trying to deserialize %s" @@ -2577,107 +2603,107 @@ msgstr "Unknown error when trying to deserialize %s" msgid "No deserialize function found for format %s" msgstr "No deserialize function found for format %s" -#: ../gtk/gtktextbufferserialize.c:795 ../gtk/gtktextbufferserialize.c:821 +#: ../gtk/gtktextbufferserialize.c:799 ../gtk/gtktextbufferserialize.c:825 #, c-format msgid "Both \"id\" and \"name\" were found on the <%s> element" msgstr "Both \"id\" and \"name\" were found on the <%s> element" -#: ../gtk/gtktextbufferserialize.c:805 ../gtk/gtktextbufferserialize.c:831 +#: ../gtk/gtktextbufferserialize.c:809 ../gtk/gtktextbufferserialize.c:835 #, c-format msgid "The attribute \"%s\" was found twice on the <%s> element" msgstr "The attribute \"%s\" was found twice on the <%s> element" -#: ../gtk/gtktextbufferserialize.c:845 +#: ../gtk/gtktextbufferserialize.c:851 #, c-format msgid "<%s> element has invalid ID \"%s\"" msgstr "<%s> element has invalid ID \"%s\"" -#: ../gtk/gtktextbufferserialize.c:855 +#: ../gtk/gtktextbufferserialize.c:861 #, c-format msgid "<%s> element has neither a \"name\" nor an \"id\" attribute" msgstr "<%s> element has neither a \"name\" nor an \"id\" attribute" -#: ../gtk/gtktextbufferserialize.c:942 +#: ../gtk/gtktextbufferserialize.c:948 #, c-format msgid "Attribute \"%s\" repeated twice on the same <%s> element" msgstr "Attribute \"%s\" repeated twice on the same <%s> element" -#: ../gtk/gtktextbufferserialize.c:960 ../gtk/gtktextbufferserialize.c:985 +#: ../gtk/gtktextbufferserialize.c:966 ../gtk/gtktextbufferserialize.c:991 #, c-format msgid "Attribute \"%s\" is invalid on <%s> element in this context" msgstr "Attribute \"%s\" is invalid on <%s> element in this context" -#: ../gtk/gtktextbufferserialize.c:1024 +#: ../gtk/gtktextbufferserialize.c:1030 #, c-format msgid "Tag \"%s\" has not been defined." msgstr "Tag \"%s\" has not been defined." -#: ../gtk/gtktextbufferserialize.c:1036 +#: ../gtk/gtktextbufferserialize.c:1042 msgid "Anonymous tag found and tags can not be created." msgstr "Anonymous tag found and tags can not be created." -#: ../gtk/gtktextbufferserialize.c:1047 +#: ../gtk/gtktextbufferserialize.c:1053 #, c-format msgid "Tag \"%s\" does not exist in buffer and tags can not be created." msgstr "Tag \"%s\" does not exist in buffer and tags can not be created." -#: ../gtk/gtktextbufferserialize.c:1146 ../gtk/gtktextbufferserialize.c:1221 -#: ../gtk/gtktextbufferserialize.c:1324 ../gtk/gtktextbufferserialize.c:1398 +#: ../gtk/gtktextbufferserialize.c:1152 ../gtk/gtktextbufferserialize.c:1227 +#: ../gtk/gtktextbufferserialize.c:1332 ../gtk/gtktextbufferserialize.c:1406 #, c-format msgid "Element <%s> is not allowed below <%s>" msgstr "Element <%s> is not allowed below <%s>" -#: ../gtk/gtktextbufferserialize.c:1177 +#: ../gtk/gtktextbufferserialize.c:1183 #, c-format msgid "\"%s\" is not a valid attribute type" msgstr "\"%s\" is not a valid attribute type" -#: ../gtk/gtktextbufferserialize.c:1185 +#: ../gtk/gtktextbufferserialize.c:1191 #, c-format msgid "\"%s\" is not a valid attribute name" msgstr "\"%s\" is not a valid attribute name" -#: ../gtk/gtktextbufferserialize.c:1195 +#: ../gtk/gtktextbufferserialize.c:1201 #, c-format msgid "" "\"%s\" could not be converted to a value of type \"%s\" for attribute \"%s\"" msgstr "" "\"%s\" could not be converted to a value of type \"%s\" for attribute \"%s\"" -#: ../gtk/gtktextbufferserialize.c:1204 +#: ../gtk/gtktextbufferserialize.c:1210 #, c-format msgid "\"%s\" is not a valid value for attribute \"%s\"" msgstr "\"%s\" is not a valid value for attribute \"%s\"" -#: ../gtk/gtktextbufferserialize.c:1289 +#: ../gtk/gtktextbufferserialize.c:1295 #, c-format msgid "Tag \"%s\" already defined" msgstr "Tag \"%s\" already defined" -#: ../gtk/gtktextbufferserialize.c:1300 +#: ../gtk/gtktextbufferserialize.c:1308 #, c-format msgid "Tag \"%s\" has invalid priority \"%s\"" msgstr "Tag \"%s\" has invalid priority \"%s\"" -#: ../gtk/gtktextbufferserialize.c:1353 +#: ../gtk/gtktextbufferserialize.c:1361 #, c-format msgid "Outermost element in text must be not <%s>" msgstr "Outermost element in text must be not <%s>" -#: ../gtk/gtktextbufferserialize.c:1362 ../gtk/gtktextbufferserialize.c:1378 +#: ../gtk/gtktextbufferserialize.c:1370 ../gtk/gtktextbufferserialize.c:1386 #, c-format msgid "A <%s> element has already been specified" msgstr "A <%s> element has already been specified" -#: ../gtk/gtktextbufferserialize.c:1384 +#: ../gtk/gtktextbufferserialize.c:1392 msgid "A element can't occur before a element" msgstr "A element can't occur before a element" -#: ../gtk/gtktextbufferserialize.c:1784 +#: ../gtk/gtktextbufferserialize.c:1792 msgid "Serialized data is malformed" msgstr "Serialized data is malformed" -#: ../gtk/gtktextbufferserialize.c:1862 +#: ../gtk/gtktextbufferserialize.c:1870 msgid "" "Serialized data is malformed. First section isn't GTKTEXTBUFFERCONTENTS-0001" msgstr "" @@ -3634,81 +3660,81 @@ msgstr "Failed to write folder index\n" msgid "Failed to rewrite header\n" msgstr "Failed to rewrite header\n" -#: ../gtk/updateiconcache.c:1463 +#: ../gtk/updateiconcache.c:1488 #, c-format msgid "Failed to open file %s : %s\n" msgstr "Failed to open file %s : %s\n" -#: ../gtk/updateiconcache.c:1471 +#: ../gtk/updateiconcache.c:1496 ../gtk/updateiconcache.c:1526 #, c-format msgid "Failed to write cache file: %s\n" msgstr "Failed to write cache file: %s\n" -#: ../gtk/updateiconcache.c:1507 +#: ../gtk/updateiconcache.c:1537 #, c-format msgid "The generated cache was invalid.\n" msgstr "The generated cache was invalid.\n" -#: ../gtk/updateiconcache.c:1521 +#: ../gtk/updateiconcache.c:1551 #, c-format msgid "Could not rename %s to %s: %s, removing %s then.\n" msgstr "Could not rename %s to %s: %s, removing %s then.\n" -#: ../gtk/updateiconcache.c:1535 +#: ../gtk/updateiconcache.c:1565 #, c-format msgid "Could not rename %s to %s: %s\n" msgstr "Could not rename %s to %s: %s\n" -#: ../gtk/updateiconcache.c:1545 +#: ../gtk/updateiconcache.c:1575 #, c-format msgid "Could not rename %s back to %s: %s.\n" msgstr "Could not rename %s back to %s: %s.\n" -#: ../gtk/updateiconcache.c:1572 +#: ../gtk/updateiconcache.c:1602 #, c-format msgid "Cache file created successfully.\n" msgstr "Cache file created successfully.\n" -#: ../gtk/updateiconcache.c:1611 +#: ../gtk/updateiconcache.c:1641 msgid "Overwrite an existing cache, even if up to date" msgstr "Overwrite an existing cache, even if up to date" -#: ../gtk/updateiconcache.c:1612 +#: ../gtk/updateiconcache.c:1642 msgid "Don't check for the existence of index.theme" msgstr "Don't check for the existence of index.theme" -#: ../gtk/updateiconcache.c:1613 +#: ../gtk/updateiconcache.c:1643 msgid "Don't include image data in the cache" msgstr "Don't include image data in the cache" -#: ../gtk/updateiconcache.c:1614 +#: ../gtk/updateiconcache.c:1644 msgid "Output a C header file" msgstr "Output a C header file" -#: ../gtk/updateiconcache.c:1615 +#: ../gtk/updateiconcache.c:1645 msgid "Turn off verbose output" msgstr "Turn off verbose output" -#: ../gtk/updateiconcache.c:1616 +#: ../gtk/updateiconcache.c:1646 msgid "Validate existing icon cache" msgstr "Validate existing icon cache" -#: ../gtk/updateiconcache.c:1683 +#: ../gtk/updateiconcache.c:1713 #, c-format msgid "File not found: %s\n" msgstr "File not found: %s\n" -#: ../gtk/updateiconcache.c:1689 +#: ../gtk/updateiconcache.c:1719 #, c-format msgid "Not a valid icon cache: %s\n" msgstr "Not a valid icon cache: %s\n" -#: ../gtk/updateiconcache.c:1702 +#: ../gtk/updateiconcache.c:1732 #, c-format msgid "No theme index file.\n" msgstr "No theme index file.\n" -#: ../gtk/updateiconcache.c:1706 +#: ../gtk/updateiconcache.c:1736 #, c-format msgid "" "No theme index file in '%s'.\n" @@ -4120,34 +4146,34 @@ msgstr "מותאם אישית %sx%s" msgid "output.%s" msgstr "פלט.%s" -#: ../modules/printbackends/file/gtkprintbackendfile.c:493 +#: ../modules/printbackends/file/gtkprintbackendfile.c:501 msgid "Print to File" msgstr "הדפסה לקובץ" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "PDF" msgstr "PDF" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "Postscript" msgstr "Postscript" -#: ../modules/printbackends/file/gtkprintbackendfile.c:570 +#: ../modules/printbackends/file/gtkprintbackendfile.c:578 msgid "SVG" msgstr "SVG" -#: ../modules/printbackends/file/gtkprintbackendfile.c:582 +#: ../modules/printbackends/file/gtkprintbackendfile.c:590 #: ../modules/printbackends/test/gtkprintbackendtest.c:503 msgid "Pages per _sheet:" msgstr "מספר העמודים ב_דף" # hebrew note: "תיקייה" is "folder", but there is no better word for # "directory" -#: ../modules/printbackends/file/gtkprintbackendfile.c:641 +#: ../modules/printbackends/file/gtkprintbackendfile.c:649 msgid "File" msgstr "קובץ" -#: ../modules/printbackends/file/gtkprintbackendfile.c:651 +#: ../modules/printbackends/file/gtkprintbackendfile.c:659 msgid "_Output format" msgstr "_תצורת הפלט" From 06288b5ae84182f9c6a1c29b245e0b4535a4a359 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 20:58:18 +0100 Subject: [PATCH 082/634] Add GTK_STATE_LAST to mark the end of GtkState enum. --- gtk/gtkenums.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index e7dd7f56c9..db53a4172f 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -367,7 +367,8 @@ typedef enum GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STATE_SELECTED, - GTK_STATE_INSENSITIVE + GTK_STATE_INSENSITIVE, + GTK_STATE_LAST } GtkStateType; /* Style for toolbars */ From f601abd25fcf8d9910542953dd19dc924cfae581 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 20:59:18 +0100 Subject: [PATCH 083/634] Add GtkStyleSet, a store of style properties. At the moment there's only basic API for adding, removing and clearing a property. There's also API to merge 2 GtkStyleSets. --- gtk/Makefile.am | 2 + gtk/gtk.h | 1 + gtk/gtkstyleset.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleset.h | 70 +++++++++++++ 4 files changed, 327 insertions(+) create mode 100644 gtk/gtkstyleset.c create mode 100644 gtk/gtkstyleset.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 6aa8e5890e..dc29a1e52b 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -291,6 +291,7 @@ gtk_public_h_sources = \ gtkstatusbar.h \ gtkstatusicon.h \ gtkstock.h \ + gtkstyleset.h \ gtkstyle.h \ gtkswitch.h \ gtktable.h \ @@ -587,6 +588,7 @@ gtk_base_c_sources = \ gtkstatusbar.c \ gtkstatusicon.c \ gtkstock.c \ + gtkstyleset.c \ gtkstyle.c \ gtkswitch.c \ gtktable.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index c6e096aa9f..711527577a 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -174,6 +174,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c new file mode 100644 index 0000000000..332d45bceb --- /dev/null +++ b/gtk/gtkstyleset.c @@ -0,0 +1,254 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtkstyleset.h" +#include "gtkprivate.h" +#include "gtkintl.h" + +#include "gtkalias.h" + +typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; +typedef struct PropertyData PropertyData; + +struct PropertyData +{ + GValue values[GTK_STATE_LAST]; +}; + +struct GtkStyleSetPrivate +{ + GHashTable *properties; +}; + +#define GTK_STYLE_SET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_SET, GtkStyleSetPrivate)) + +static void gtk_style_set_finalize (GObject *object); + + +G_DEFINE_TYPE (GtkStyleSet, gtk_style_set, G_TYPE_OBJECT) + +static void +gtk_style_set_class_init (GtkStyleSetClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gtk_style_set_finalize; + + g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); +} + +static PropertyData * +property_data_new (void) +{ + PropertyData *data; + + data = g_slice_new0 (PropertyData); + + return data; +} + +static void +property_data_free (PropertyData *data) +{ + gint i; + + for (i = 0; i <= GTK_STATE_INSENSITIVE; i++) + g_value_unset (&data->values[i]); + + g_slice_free (PropertyData, data); +} + +static void +gtk_style_set_init (GtkStyleSet *set) +{ + GtkStyleSetPrivate *priv; + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + + priv->properties = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) property_data_free); +} + +static void +gtk_style_set_finalize (GObject *object) +{ + GtkStyleSetPrivate *priv; + + priv = GTK_STYLE_SET_GET_PRIVATE (object); + g_hash_table_destroy (priv->properties); + + G_OBJECT_CLASS (gtk_style_set_parent_class)->finalize (object); +} + +GtkStyleSet * +gtk_style_set_new (void) +{ + return g_object_new (GTK_TYPE_STYLE_SET, NULL); +} + +void +gtk_style_set_set_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state, + const GValue *value) +{ + GtkStyleSetPrivate *priv; + PropertyData *prop; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (property != NULL); + g_return_if_fail (state < GTK_STATE_LAST); + g_return_if_fail (value != NULL); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + prop = g_hash_table_lookup (priv->properties, property); + + if (!prop) + { + prop = property_data_new (); + g_hash_table_insert (priv->properties, + g_strdup (property), + prop); + } + + if (G_VALUE_TYPE (&prop->values[state]) != G_TYPE_INVALID) + g_value_unset (&prop->values[state]); + + g_value_init (&prop->values[state], G_VALUE_TYPE (value)); + g_value_copy (value, &prop->values[state]); +} + +gboolean +gtk_style_set_get_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state, + GValue *value) +{ + GtkStyleSetPrivate *priv; + PropertyData *prop; + + g_return_val_if_fail (GTK_IS_STYLE_SET (set), FALSE); + g_return_val_if_fail (property != NULL, FALSE); + g_return_val_if_fail (state < GTK_STATE_LAST, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + prop = g_hash_table_lookup (priv->properties, property); + + if (!prop) + return FALSE; + + g_value_init (value, G_VALUE_TYPE (&prop->values[state])); + g_value_copy (&prop->values[state], value); + + return TRUE; +} + +void +gtk_style_set_unset_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state) +{ + GtkStyleSetPrivate *priv; + PropertyData *prop; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (property != NULL); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + prop = g_hash_table_lookup (priv->properties, property); + + if (!prop) + return; + + g_value_unset (&prop->values[state]); +} + +void +gtk_style_set_clear (GtkStyleSet *set) +{ + GtkStyleSetPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + g_hash_table_remove_all (priv->properties); +} + +void +gtk_style_set_merge (GtkStyleSet *set, + const GtkStyleSet *set_to_merge, + gboolean replace) +{ + GtkStyleSetPrivate *priv, *priv_to_merge; + GHashTableIter iter; + gpointer key, value; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_SET (set_to_merge)); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv_to_merge = GTK_STYLE_SET_GET_PRIVATE (set_to_merge); + + g_hash_table_iter_init (&iter, priv_to_merge->properties); + + while (g_hash_table_iter_next (&iter, &key, &value)) + { + const gchar *name_to_merge = key; + PropertyData *prop_to_merge = value; + PropertyData *prop = NULL; + GtkStateType i; + + for (i = GTK_STATE_NORMAL; i < GTK_STATE_LAST; i++) + { + if (G_VALUE_TYPE (&prop_to_merge->values[i]) == G_TYPE_INVALID) + continue; + + if (!prop) + prop = g_hash_table_lookup (priv->properties, name_to_merge); + + if (!prop) + { + prop = property_data_new (); + g_hash_table_insert (priv->properties, + g_strdup (name_to_merge), + prop); + } + + if (replace || + G_VALUE_TYPE (&prop->values[i]) == G_TYPE_INVALID) + { + if (G_VALUE_TYPE (&prop->values[i]) == G_TYPE_INVALID) + g_value_init (&prop->values[i], G_VALUE_TYPE (&prop_to_merge->values[i])); + + g_value_copy (&prop_to_merge->values[i], + &prop->values[i]); + } + } + } +} + + +#define __GTK_STYLE_SET_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h new file mode 100644 index 0000000000..48b3c3beaa --- /dev/null +++ b/gtk/gtkstyleset.h @@ -0,0 +1,70 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_STYLE_SET_H__ +#define __GTK_STYLE_SET_H__ + +#include +#include "gtkenums.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_STYLE_SET (gtk_style_set_get_type ()) +#define GTK_STYLE_SET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_SET, GtkStyleSet)) +#define GTK_STYLE_SET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_SET, GtkStyleSetClass)) +#define GTK_IS_STYLE_SET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_SET)) +#define GTK_IS_STYLE_SET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_SET)) +#define GTK_STYLE_SET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_SET, GtkStyleSetClass)) + +typedef struct GtkStyleSet GtkStyleSet; +typedef struct GtkStyleSetClass GtkStyleSetClass; + +struct GtkStyleSet +{ + GObject parent_object; +}; + +struct GtkStyleSetClass +{ + GObjectClass parent_class; +}; + +GType gtk_style_set_get_type (void) G_GNUC_CONST; + +GtkStyleSet * gtk_style_set_new (void); + +void gtk_style_set_set_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state, + const GValue *value); + +gboolean gtk_style_set_get_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state, + GValue *value); + +void gtk_style_set_unset_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state); + +void gtk_style_set_clear (GtkStyleSet *set); + +G_END_DECLS + +#endif /* __GTK_STYLE_PROPERTY_SET_H__ */ From 019fa73308b1e1703b257c20b5d05165e062e2ef Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 21:05:03 +0100 Subject: [PATCH 084/634] Add GtkStyleProvider, an interface to provide style details. The get_style() function isn't final yet, further parameters should be added to query details based on the widget hierarchy, name, etc. --- gtk/Makefile.am | 2 ++ gtk/gtk.h | 1 + gtk/gtkstyleprovider.c | 66 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleprovider.h | 58 +++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 gtk/gtkstyleprovider.c create mode 100644 gtk/gtkstyleprovider.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index dc29a1e52b..8b607f8d1c 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -291,6 +291,7 @@ gtk_public_h_sources = \ gtkstatusbar.h \ gtkstatusicon.h \ gtkstock.h \ + gtkstyleprovider.h \ gtkstyleset.h \ gtkstyle.h \ gtkswitch.h \ @@ -588,6 +589,7 @@ gtk_base_c_sources = \ gtkstatusbar.c \ gtkstatusicon.c \ gtkstock.c \ + gtkstyleprovider.c \ gtkstyleset.c \ gtkstyle.c \ gtkswitch.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 711527577a..15c411f22a 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -174,6 +174,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c new file mode 100644 index 0000000000..18cca7b817 --- /dev/null +++ b/gtk/gtkstyleprovider.c @@ -0,0 +1,66 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtkprivate.h" +#include "gtkstyleprovider.h" +#include "gtkintl.h" + +#include "gtkalias.h" + +static void gtk_style_provider_iface_init (gpointer g_iface); + +GType +gtk_style_provider_get_type (void) +{ + static GType style_provider_type = 0; + + if (!style_provider_type) + style_provider_type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("GtkStyleProvider"), + sizeof (GtkStyleProviderIface), + (GClassInitFunc) gtk_style_provider_iface_init, + 0, NULL, 0); + return style_provider_type; +} + +static void +gtk_style_provider_iface_init (gpointer g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); +} + +GtkStyleSet * +gtk_style_provider_get_style (GtkStyleProvider *provider) +{ + GtkStyleProviderIface *iface; + + g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL); + + iface = GTK_STYLE_PROVIDER_GET_IFACE (provider); + + if (!iface->get_style) + return NULL; + + return iface->get_style (provider); +} + +#define __GTK_STYLE_PROVIDER_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h new file mode 100644 index 0000000000..ec5ee99937 --- /dev/null +++ b/gtk/gtkstyleprovider.h @@ -0,0 +1,58 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_STYLE_PROVIDER_H__ +#define __GTK_STYLE_PROVIDER_H__ + +#include +#include "gtkstyleset.h" +#include "gtkenums.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_STYLE_PROVIDER (gtk_style_provider_get_type ()) +#define GTK_STYLE_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_PROVIDER, GtkStyleProvider)) +#define GTK_IS_STYLE_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_PROVIDER)) +#define GTK_STYLE_PROVIDER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GTK_TYPE_STYLE_PROVIDER, GtkStyleProviderIface)) + +typedef struct GtkStyleProviderIface GtkStyleProviderIface; +typedef struct GtkStyleProvider GtkStyleProvider; /* dummy typedef */ + +typedef enum { + GTK_SELECTOR_TYPE_PATH, + GTK_SELECTOR_TYPE_NAME, + GTK_SELECTOR_TYPE_CLASS_PATH, + GTK_SELECTOR_TYPE_CLASS_NAME +} GtkSelectorType; + +struct GtkStyleProviderIface +{ + GTypeInterface g_iface; + + GtkStyleSet * (* get_style) (GtkStyleProvider *provider); +}; + +GType gtk_style_provider_get_type (void) G_GNUC_CONST; + +GtkStyleSet *gtk_style_provider_get_style (GtkStyleProvider *provider); + + +G_END_DECLS + +#endif /* __GTK_STYLE_PROVIDER_H__ */ From f969470ad8c9c9bb706fcccdb88e693cb34bfbee Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 22:51:56 +0100 Subject: [PATCH 085/634] GtkStyleSet: Implement GtkStyleProvider. As simple as it can get. --- gtk/gtkstyleset.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 332d45bceb..e926234025 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -19,6 +19,7 @@ #include "config.h" +#include "gtkstyleprovider.h" #include "gtkstyleset.h" #include "gtkprivate.h" #include "gtkintl.h" @@ -40,10 +41,13 @@ struct GtkStyleSetPrivate #define GTK_STYLE_SET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_SET, GtkStyleSetPrivate)) -static void gtk_style_set_finalize (GObject *object); +static void gtk_style_set_provider_init (GtkStyleProviderIface *iface); +static void gtk_style_set_finalize (GObject *object); -G_DEFINE_TYPE (GtkStyleSet, gtk_style_set, G_TYPE_OBJECT) +G_DEFINE_TYPE_EXTENDED (GtkStyleSet, gtk_style_set, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, + gtk_style_set_provider_init)); static void gtk_style_set_class_init (GtkStyleSetClass *klass) @@ -71,7 +75,10 @@ property_data_free (PropertyData *data) gint i; for (i = 0; i <= GTK_STATE_INSENSITIVE; i++) - g_value_unset (&data->values[i]); + { + if (G_IS_VALUE (&data->values[i])) + g_value_unset (&data->values[i]); + } g_slice_free (PropertyData, data); } @@ -100,6 +107,20 @@ gtk_style_set_finalize (GObject *object) G_OBJECT_CLASS (gtk_style_set_parent_class)->finalize (object); } +GtkStyleSet * +gtk_style_set_get_style (GtkStyleProvider *provider) +{ + /* Return style set itself */ + return g_object_ref (provider); +} + +static void +gtk_style_set_provider_init (GtkStyleProviderIface *iface) +{ + iface->get_style = gtk_style_set_get_style; +} + + GtkStyleSet * gtk_style_set_new (void) { From 530ae15f96b465e62286a6b995f514b53fe4883b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 22:58:28 +0100 Subject: [PATCH 086/634] gtkstyleset.h: Add declaration for gtk_style_set_merge(). --- gtk/gtkstyleset.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 48b3c3beaa..2853d4c502 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -65,6 +65,10 @@ void gtk_style_set_unset_property (GtkStyleSet *set, void gtk_style_set_clear (GtkStyleSet *set); +void gtk_style_set_merge (GtkStyleSet *set, + const GtkStyleSet *set_to_merge, + gboolean replace); + G_END_DECLS #endif /* __GTK_STYLE_PROPERTY_SET_H__ */ From 2b425d89c80a47d0820b7b1b7aff26c37e5a61b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Mar 2010 23:00:30 +0100 Subject: [PATCH 087/634] Add GtkStyleContext. GtkStyleContext will conglomerate the information of several GtkStyleProviders for widgets and theme engines to query it. --- gtk/Makefile.am | 2 + gtk/gtk.h | 1 + gtk/gtkstylecontext.c | 225 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 59 +++++++++++ 4 files changed, 287 insertions(+) create mode 100644 gtk/gtkstylecontext.c create mode 100644 gtk/gtkstylecontext.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8b607f8d1c..94299bd4d0 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -291,6 +291,7 @@ gtk_public_h_sources = \ gtkstatusbar.h \ gtkstatusicon.h \ gtkstock.h \ + gtkstylecontext.h \ gtkstyleprovider.h \ gtkstyleset.h \ gtkstyle.h \ @@ -589,6 +590,7 @@ gtk_base_c_sources = \ gtkstatusbar.c \ gtkstatusicon.c \ gtkstock.c \ + gtkstylecontext.c \ gtkstyleprovider.c \ gtkstyleset.c \ gtkstyle.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 15c411f22a..1bc1c75f43 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -174,6 +174,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c new file mode 100644 index 0000000000..0a84cda563 --- /dev/null +++ b/gtk/gtkstylecontext.c @@ -0,0 +1,225 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 + +#include "gtkstylecontext.h" +#include "gtktypebuiltins.h" +#include "gtkintl.h" + +#include "gtkalias.h" + +typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; +typedef struct GtkStyleProviderData GtkStyleProviderData; + +struct GtkStyleProviderData +{ + GtkStyleProvider *provider; + guint priority; +}; + +struct GtkStyleContextPrivate +{ + GList *providers; + GtkStyleSet *store; +}; + +#define GTK_STYLE_CONTEXT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextPrivate)) + +static void gtk_style_context_finalize (GObject *object); + + +G_DEFINE_TYPE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT) + +static void +gtk_style_context_class_init (GtkStyleContextClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gtk_style_context_finalize; + + g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); +} + +static void +gtk_style_context_init (GtkStyleContext *style_context) +{ + GtkStyleContextPrivate *priv; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (style_context); + priv->store = gtk_style_set_new (); +} + +static GtkStyleProviderData * +style_provider_data_new (GtkStyleProvider *provider, + guint priority) +{ + GtkStyleProviderData *data; + + data = g_slice_new (GtkStyleProviderData); + data->provider = g_object_ref (provider); + data->priority = priority; + + return data; +} + +static void +style_provider_data_free (GtkStyleProviderData *data) +{ + g_object_unref (data->provider); + g_slice_free (GtkStyleProviderData, data); +} + +static void +gtk_style_context_finalize (GObject *object) +{ + GtkStyleContextPrivate *priv; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (object); + + g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); + g_list_free (priv->providers); + + G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); +} + +static void +rebuild_properties (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GList *list; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + list = priv->providers; + + gtk_style_set_clear (priv->store); + + while (list) + { + GtkStyleProviderData *data; + GtkStyleSet *provider_style; + + data = list->data; + list = list->next; + + provider_style = gtk_style_provider_get_style (data->provider); + gtk_style_set_merge (priv->store, provider_style, TRUE); + g_object_unref (provider_style); + } +} + +void +gtk_style_context_add_provider (GtkStyleContext *context, + GtkStyleProvider *provider, + guint priority) +{ + GtkStyleContextPrivate *priv; + GtkStyleProviderData *new_data; + gboolean added = FALSE; + GList *list; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + new_data = style_provider_data_new (provider, priority); + list = priv->providers; + + while (list) + { + GtkStyleProviderData *data; + + data = list->data; + + /* Provider was already attached to the style + * context, remove in order to add the new data + */ + if (data->provider == provider) + { + GList *link; + + link = list; + list = list->next; + + /* Remove and free link */ + priv->providers = g_list_remove_link (priv->providers, link); + style_provider_data_free (link->data); + g_list_free_1 (link); + + continue; + } + + if (!added && + data->priority > priority) + { + priv->providers = g_list_insert_before (priv->providers, list, new_data); + added = TRUE; + } + + list = list->next; + } + + if (!added) + priv->providers = g_list_append (priv->providers, new_data); + + rebuild_properties (context); +} + +void +gtk_style_context_remove_provider (GtkStyleContext *context, + GtkStyleProvider *provider) +{ + GtkStyleContextPrivate *priv; + gboolean removed = FALSE; + GList *list; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + list = priv->providers; + + while (list) + { + GtkStyleProviderData *data; + + data = list->data; + + if (data->provider == provider) + { + priv->providers = g_list_remove_link (priv->providers, list); + style_provider_data_free (list->data); + g_list_free_1 (list); + + removed = TRUE; + + break; + } + + list = list->next; + } + + if (removed) + rebuild_properties (context); +} + +#define __GTK_STYLE_CONTEXT_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h new file mode 100644 index 0000000000..1ded64e6ee --- /dev/null +++ b/gtk/gtkstylecontext.h @@ -0,0 +1,59 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_STYLE_CONTEXT_H__ +#define __GTK_STYLE_CONTEXT_H__ + +#include +#include "gtkstyleprovider.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_STYLE_CONTEXT (gtk_style_context_get_type ()) +#define GTK_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContext)) +#define GTK_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass)) +#define GTK_IS_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_CONTEXT)) +#define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT)) +#define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass)) + +typedef struct GtkStyleContext GtkStyleContext; +typedef struct GtkStyleContextClass GtkStyleContextClass; + +struct GtkStyleContext +{ + GObject parent_object; +}; + +struct GtkStyleContextClass +{ + GObjectClass parent_class; +}; + +GType gtk_style_context_get_type (void) G_GNUC_CONST; + +void gtk_style_context_add_provider (GtkStyleContext *context, + GtkStyleProvider *provider, + guint priority); + +void gtk_style_context_remove_provider (GtkStyleContext *context, + GtkStyleProvider *provider); + +G_END_DECLS + +#endif /* __GTK_STYLE_CONTEXT_H__ */ From 4c60de478307a06d7c45f81880791ee04b3ca09b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 5 Mar 2010 01:45:47 +0100 Subject: [PATCH 088/634] GtkStyleSet: Add style property registration funcs. Also some properties have been added as a default set. --- gtk/gtkstyleset.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleset.h | 16 +++++ 2 files changed, 174 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index e926234025..f84f1f2ffc 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -19,6 +19,8 @@ #include "config.h" +#include + #include "gtkstyleprovider.h" #include "gtkstyleset.h" #include "gtkprivate.h" @@ -28,6 +30,14 @@ typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; typedef struct PropertyData PropertyData; +typedef struct PropertyNode PropertyNode; + +struct PropertyNode +{ + GQuark property_quark; + GType property_type; + GValue default_value; +}; struct PropertyData { @@ -39,6 +49,8 @@ struct GtkStyleSetPrivate GHashTable *properties; }; +static GArray *properties = NULL; + #define GTK_STYLE_SET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_SET, GtkStyleSetPrivate)) static void gtk_style_set_provider_init (GtkStyleProviderIface *iface); @@ -53,9 +65,17 @@ static void gtk_style_set_class_init (GtkStyleSetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkColor black = { 0, 0, 0, 0 }; + GdkColor white = { 0, 65535, 65535, 65535 }; object_class->finalize = gtk_style_set_finalize; + /* Initialize default property set */ + gtk_style_set_register_property_color ("foreground-color", &white); + gtk_style_set_register_property_color ("background-color", &black); + gtk_style_set_register_property_color ("text-color", &white); + gtk_style_set_register_property_color ("base-color", &white); + g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } @@ -120,6 +140,144 @@ gtk_style_set_provider_init (GtkStyleProviderIface *iface) iface->get_style = gtk_style_set_get_style; } +static int +compare_property (gconstpointer p1, + gconstpointer p2) +{ + PropertyNode *key = (PropertyNode *) p1; + PropertyNode *node = (PropertyNode *) p2; + + return (int) key->property_quark - node->property_quark; +} + +static PropertyNode * +property_node_lookup (GQuark quark) +{ + PropertyNode key = { 0 }; + + if (!quark) + return NULL; + + if (!properties) + return NULL; + + key.property_quark = quark; + + return bsearch (&key, properties->data, properties->len, + sizeof (PropertyNode), compare_property); +} + +/* Property registration functions */ +void +gtk_style_set_register_property (const gchar *property_name, + GType type, + GValue *default_value) +{ + PropertyNode *node, new = { 0 }; + GQuark quark; + gint i; + + g_return_if_fail (property_name != NULL); + g_return_if_fail (default_value != NULL); + g_return_if_fail (type == G_VALUE_TYPE (default_value)); + + if (G_UNLIKELY (!properties)) + properties = g_array_new (FALSE, TRUE, sizeof (PropertyNode)); + + quark = g_quark_try_string (property_name); + + if ((node = property_node_lookup (quark)) != NULL) + { + g_warning ("Property \"%s\" was already registered with type %s", + property_name, g_type_name (node->property_type)); + return; + } + + quark = g_quark_from_string (property_name); + + new.property_quark = quark; + new.property_type = type; + + g_value_init (&new.default_value, type); + g_value_copy (default_value, &new.default_value); + + for (i = 0; i < properties->len; i++) + { + node = &g_array_index (properties, PropertyNode, i); + + if (node->property_quark > quark) + break; + } + + g_array_insert_val (properties, i, new); +} + +void +gtk_style_set_register_property_color (const gchar *property_name, + GdkColor *initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + g_return_if_fail (initial_value != NULL); + + g_value_init (&value, GDK_TYPE_COLOR); + g_value_set_boxed (&value, initial_value); + + gtk_style_set_register_property (property_name, GDK_TYPE_COLOR, &value); + + g_value_unset (&value); +} + +void +gtk_style_set_register_property_int (const gchar *property_name, + gint initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, initial_value); + + gtk_style_set_register_property (property_name, G_TYPE_INT, &value); + + g_value_unset (&value); +} + +void +gtk_style_set_register_property_uint (const gchar *property_name, + guint initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + + g_value_init (&value, G_TYPE_UINT); + g_value_set_uint (&value, initial_value); + + gtk_style_set_register_property (property_name, G_TYPE_UINT, &value); + + g_value_unset (&value); +} + +void +gtk_style_set_register_property_double (const gchar *property_name, + gdouble initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + + g_value_init (&value, G_TYPE_DOUBLE); + g_value_set_double (&value, initial_value); + + gtk_style_set_register_property (property_name, G_TYPE_DOUBLE, &value); + + g_value_unset (&value); +} + +/* GtkStyleSet methods */ GtkStyleSet * gtk_style_set_new (void) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 2853d4c502..01f6e1c139 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -21,6 +21,7 @@ #define __GTK_STYLE_SET_H__ #include +#include #include "gtkenums.h" G_BEGIN_DECLS @@ -47,6 +48,21 @@ struct GtkStyleSetClass GType gtk_style_set_get_type (void) G_GNUC_CONST; +/* Functions to register style properties */ +void gtk_style_set_register_property (const gchar *property_name, + GType type, + GValue *default_value); + +void gtk_style_set_register_property_color (const gchar *property_name, + GdkColor *default_value); +void gtk_style_set_register_property_int (const gchar *property_name, + gint default_value); +void gtk_style_set_register_property_uint (const gchar *property_name, + guint default_value); +void gtk_style_set_register_property_double (const gchar *property_name, + gdouble default_value); + + GtkStyleSet * gtk_style_set_new (void); void gtk_style_set_set_property (GtkStyleSet *set, From 2bf7483e743916bbb23c611a6a0bf46593e0a6a5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 5 Mar 2010 02:06:53 +0100 Subject: [PATCH 089/634] GtkStyleSet: Use property GQuark as store keys. --- gtk/gtkstyleset.c | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index f84f1f2ffc..cb444cd759 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -109,10 +109,7 @@ gtk_style_set_init (GtkStyleSet *set) GtkStyleSetPrivate *priv; priv = GTK_STYLE_SET_GET_PRIVATE (set); - - priv->properties = g_hash_table_new_full (g_str_hash, - g_str_equal, - (GDestroyNotify) g_free, + priv->properties = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) property_data_free); } @@ -292,6 +289,7 @@ gtk_style_set_set_property (GtkStyleSet *set, const GValue *value) { GtkStyleSetPrivate *priv; + PropertyNode *node; PropertyData *prop; g_return_if_fail (GTK_IS_STYLE_SET (set)); @@ -299,21 +297,33 @@ gtk_style_set_set_property (GtkStyleSet *set, g_return_if_fail (state < GTK_STATE_LAST); g_return_if_fail (value != NULL); + node = property_node_lookup (g_quark_try_string (property)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", property); + return; + } + + g_return_if_fail (node->property_type == G_VALUE_TYPE (value)); + priv = GTK_STYLE_SET_GET_PRIVATE (set); - prop = g_hash_table_lookup (priv->properties, property); + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); if (!prop) { prop = property_data_new (); g_hash_table_insert (priv->properties, - g_strdup (property), + GINT_TO_POINTER (node->property_quark), prop); } - if (G_VALUE_TYPE (&prop->values[state]) != G_TYPE_INVALID) - g_value_unset (&prop->values[state]); + if (G_IS_VALUE (&prop->values[state])) + g_value_reset (&prop->values[state]); + else + g_value_init (&prop->values[state], node->property_type); - g_value_init (&prop->values[state], G_VALUE_TYPE (value)); g_value_copy (value, &prop->values[state]); } @@ -324,6 +334,7 @@ gtk_style_set_get_property (GtkStyleSet *set, GValue *value) { GtkStyleSetPrivate *priv; + PropertyNode *node; PropertyData *prop; g_return_val_if_fail (GTK_IS_STYLE_SET (set), FALSE); @@ -331,8 +342,17 @@ gtk_style_set_get_property (GtkStyleSet *set, g_return_val_if_fail (state < GTK_STATE_LAST, FALSE); g_return_val_if_fail (value != NULL, FALSE); + node = property_node_lookup (g_quark_try_string (property)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", property); + return FALSE; + } + priv = GTK_STYLE_SET_GET_PRIVATE (set); - prop = g_hash_table_lookup (priv->properties, property); + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); if (!prop) return FALSE; @@ -349,14 +369,24 @@ gtk_style_set_unset_property (GtkStyleSet *set, GtkStateType state) { GtkStyleSetPrivate *priv; + PropertyNode *node; PropertyData *prop; g_return_if_fail (GTK_IS_STYLE_SET (set)); g_return_if_fail (property != NULL); g_return_if_fail (state < GTK_STATE_LAST); + node = property_node_lookup (g_quark_try_string (property)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", property); + return; + } + priv = GTK_STYLE_SET_GET_PRIVATE (set); - prop = g_hash_table_lookup (priv->properties, property); + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); if (!prop) return; @@ -394,7 +424,6 @@ gtk_style_set_merge (GtkStyleSet *set, while (g_hash_table_iter_next (&iter, &key, &value)) { - const gchar *name_to_merge = key; PropertyData *prop_to_merge = value; PropertyData *prop = NULL; GtkStateType i; @@ -405,14 +434,12 @@ gtk_style_set_merge (GtkStyleSet *set, continue; if (!prop) - prop = g_hash_table_lookup (priv->properties, name_to_merge); + prop = g_hash_table_lookup (priv->properties, key); if (!prop) { prop = property_data_new (); - g_hash_table_insert (priv->properties, - g_strdup (name_to_merge), - prop); + g_hash_table_insert (priv->properties, key, prop); } if (replace || From 9fdcbd7a8457a73f664795c35086f46b31fb42e2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 5 Mar 2010 03:02:59 +0100 Subject: [PATCH 090/634] GtkStyleSet: Add valist and varargs getters/setters. --- gtk/gtkstyleset.c | 137 +++++++++++++++++++++++++++++++++++++++++++++- gtk/gtkstyleset.h | 12 ++++ 2 files changed, 148 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index cb444cd759..4f49628b3c 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -20,6 +20,7 @@ #include "config.h" #include +#include #include "gtkstyleprovider.h" #include "gtkstyleset.h" @@ -327,6 +328,76 @@ gtk_style_set_set_property (GtkStyleSet *set, g_value_copy (value, &prop->values[state]); } + +void +gtk_style_set_set_valist (GtkStyleSet *set, + GtkStateType state, + va_list args) +{ + GtkStyleSetPrivate *priv; + const gchar *property_name; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + property_name = va_arg (args, const gchar *); + + while (property_name) + { + PropertyNode *node; + PropertyData *prop; + gchar *error = NULL; + + node = property_node_lookup (g_quark_try_string (property_name)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", property_name); + break; + } + + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); + + if (!prop) + { + prop = property_data_new (); + g_hash_table_insert (priv->properties, + GINT_TO_POINTER (node->property_quark), + prop); + } + + g_value_init (&prop->values[state], node->property_type); + G_VALUE_COLLECT (&prop->values[state], args, 0, &error); + + if (error) + { + g_warning ("Could not set style property \"%s\": %s", property_name, error); + g_value_unset (&prop->values[state]); + g_free (error); + break; + } + + property_name = va_arg (args, const gchar *); + } +} + +void +gtk_style_set_set (GtkStyleSet *set, + GtkStateType state, + ...) +{ + va_list args; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (state < GTK_STATE_LAST); + + va_start (args, state); + gtk_style_set_set_valist (set, state, args); + va_end (args); +} + gboolean gtk_style_set_get_property (GtkStyleSet *set, const gchar *property, @@ -363,6 +434,71 @@ gtk_style_set_get_property (GtkStyleSet *set, return TRUE; } +void +gtk_style_set_get_valist (GtkStyleSet *set, + GtkStateType state, + va_list args) +{ + GtkStyleSetPrivate *priv; + const gchar *property_name; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + property_name = va_arg (args, const gchar *); + + while (property_name) + { + PropertyNode *node; + PropertyData *prop; + gchar *error = NULL; + + node = property_node_lookup (g_quark_try_string (property_name)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", property_name); + break; + } + + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); + + if (!prop) + { + /* FIXME: Fill in default */ + break; + } + + G_VALUE_LCOPY (&prop->values[state], args, 0, &error); + + 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 *); + } +} + +void +gtk_style_set_get (GtkStyleSet *set, + GtkStateType state, + ...) +{ + va_list args; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (state < GTK_STATE_LAST); + + va_start (args, state); + gtk_style_set_get_valist (set, state, args); + va_end (args); +} + void gtk_style_set_unset_property (GtkStyleSet *set, const gchar *property, @@ -455,6 +591,5 @@ gtk_style_set_merge (GtkStyleSet *set, } } - #define __GTK_STYLE_SET_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 01f6e1c139..36edebbc61 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -69,11 +69,23 @@ void gtk_style_set_set_property (GtkStyleSet *set, const gchar *property, GtkStateType state, const GValue *value); +void gtk_style_set_set_valist (GtkStyleSet *set, + GtkStateType state, + va_list args); +void gtk_style_set_set (GtkStyleSet *set, + GtkStateType state, + ...) G_GNUC_NULL_TERMINATED; gboolean gtk_style_set_get_property (GtkStyleSet *set, const gchar *property, GtkStateType state, GValue *value); +void gtk_style_set_get_valist (GtkStyleSet *set, + GtkStateType state, + va_list args); +void gtk_style_set_get (GtkStyleSet *set, + GtkStateType state, + ...) G_GNUC_NULL_TERMINATED; void gtk_style_set_unset_property (GtkStyleSet *set, const gchar *property, From 2da033b18c67eaad1f1eac9de9d1d5e1b74eda89 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Mar 2010 19:52:18 +0100 Subject: [PATCH 091/634] GtkStyleSet: Return default value if value is not set. --- gtk/gtkstyleset.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 4f49628b3c..c2db1fc25b 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -425,11 +425,13 @@ gtk_style_set_get_property (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop) - return FALSE; + g_value_init (value, node->property_type); - g_value_init (value, G_VALUE_TYPE (&prop->values[state])); - g_value_copy (&prop->values[state], value); + if (!prop || + !G_IS_VALUE (&prop->values[state])) + g_value_copy (&node->default_value, value); + else + g_value_copy (&prop->values[state], value); return TRUE; } @@ -465,13 +467,11 @@ gtk_style_set_get_valist (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop) - { - /* FIXME: Fill in default */ - break; - } - - G_VALUE_LCOPY (&prop->values[state], args, 0, &error); + if (!prop || + !G_IS_VALUE (&prop->values[state])) + G_VALUE_LCOPY (&node->default_value, args, 0, &error); + else + G_VALUE_LCOPY (&prop->values[state], args, 0, &error); if (error) { From 1a3d964615d67ac61be35cad25c59bc0ac6b2422 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 7 Mar 2010 01:22:38 +0100 Subject: [PATCH 092/634] GtkStyleContext: Add methods to query composed style. --- gtk/gtkstylecontext.c | 49 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 11 ++++++++++ 2 files changed, 60 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 0a84cda563..b5c1f075d5 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -221,5 +221,54 @@ gtk_style_context_remove_provider (GtkStyleContext *context, rebuild_properties (context); } +void +gtk_style_context_get_property (GtkStyleContext *context, + const gchar *property, + GtkStateType state, + GValue *value) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (property != NULL); + g_return_if_fail (state < GTK_STATE_LAST); + g_return_if_fail (value != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + gtk_style_set_get_property (priv->store, property, state, value); +} + +void +gtk_style_context_get_valist (GtkStyleContext *context, + GtkStateType state, + va_list args) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + gtk_style_set_get_valist (priv->store, state, args); +} + +void +gtk_style_context_get (GtkStyleContext *context, + GtkStateType state, + ...) +{ + GtkStyleContextPrivate *priv; + va_list args; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + va_start (args, state); + gtk_style_context_get_valist (priv->store, state, args); + va_end (args); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 1ded64e6ee..37d4f15e4f 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -54,6 +54,17 @@ void gtk_style_context_add_provider (GtkStyleContext *context, void gtk_style_context_remove_provider (GtkStyleContext *context, GtkStyleProvider *provider); +void gtk_style_context_get_property (GtkStyleContext *context, + const gchar *property, + GtkStateType state, + GValue *value); +void gtk_style_context_get_valist (GtkStyleContext *context, + GtkStateType state, + va_list args); +void gtk_style_context_get (GtkStyleContext *context, + GtkStateType state, + ...) G_GNUC_NULL_TERMINATED; + G_END_DECLS #endif /* __GTK_STYLE_CONTEXT_H__ */ From 16484f845901137a7102833128fb02e10acbbde6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 7 Mar 2010 19:07:27 +0100 Subject: [PATCH 093/634] GtkStyleSet: Add method to register font properties. --- gtk/gtkstyleset.c | 22 ++++++++++++++++++++++ gtk/gtkstyleset.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index c2db1fc25b..6ac544294d 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -68,6 +68,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GdkColor black = { 0, 0, 0, 0 }; GdkColor white = { 0, 65535, 65535, 65535 }; + PangoFontDescription *font_desc; object_class->finalize = gtk_style_set_finalize; @@ -77,6 +78,10 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property_color ("text-color", &white); gtk_style_set_register_property_color ("base-color", &white); + font_desc = pango_font_description_from_string ("Sans 10"); + gtk_style_set_register_property_font ("font", font_desc); + pango_font_description_free (font_desc); + g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } @@ -227,6 +232,23 @@ gtk_style_set_register_property_color (const gchar *property_name, g_value_unset (&value); } +void +gtk_style_set_register_property_font (const gchar *property_name, + PangoFontDescription *initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + g_return_if_fail (initial_value != NULL); + + g_value_init (&value, PANGO_TYPE_FONT_DESCRIPTION); + g_value_set_boxed (&value, initial_value); + + gtk_style_set_register_property (property_name, PANGO_TYPE_FONT_DESCRIPTION, &value); + + g_value_unset (&value); +} + void gtk_style_set_register_property_int (const gchar *property_name, gint initial_value) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 36edebbc61..986fdb0dbd 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -55,6 +55,8 @@ void gtk_style_set_register_property (const gchar *property_name, void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *default_value); +void gtk_style_set_register_property_font (const gchar *property_name, + PangoFontDescription *initial_value); void gtk_style_set_register_property_int (const gchar *property_name, gint default_value); void gtk_style_set_register_property_uint (const gchar *property_name, From 28b7782d7801bded393094052b61fa62a20c4d2b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 7 Mar 2010 19:57:53 +0100 Subject: [PATCH 094/634] GtkStyleSet: Add method to register border property. --- gtk/gtkstyleset.c | 20 ++++++++++++++++++++ gtk/gtkstyleset.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 6ac544294d..c26eb3cdbd 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -69,6 +69,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) GdkColor black = { 0, 0, 0, 0 }; GdkColor white = { 0, 65535, 65535, 65535 }; PangoFontDescription *font_desc; + GtkBorder padding = { 0 }; object_class->finalize = gtk_style_set_finalize; @@ -82,6 +83,8 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property_font ("font", font_desc); pango_font_description_free (font_desc); + gtk_style_set_register_property_border ("padding", &padding); + g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } @@ -249,6 +252,23 @@ gtk_style_set_register_property_font (const gchar *property_name, g_value_unset (&value); } +void +gtk_style_set_register_property_border (const gchar *property_name, + GtkBorder *initial_value) +{ + GValue value = { 0 }; + + g_return_if_fail (property_name != NULL); + g_return_if_fail (initial_value != NULL); + + g_value_init (&value, GTK_TYPE_BORDER); + g_value_set_boxed (&value, initial_value); + + gtk_style_set_register_property (property_name, GTK_TYPE_BORDER, &value); + + g_value_unset (&value); +} + void gtk_style_set_register_property_int (const gchar *property_name, gint initial_value) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 986fdb0dbd..ff1b859a60 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -24,6 +24,9 @@ #include #include "gtkenums.h" +/* GtkBorder is defined there */ +#include "gtkstyle.h" + G_BEGIN_DECLS #define GTK_TYPE_STYLE_SET (gtk_style_set_get_type ()) @@ -57,6 +60,8 @@ void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *default_value); void gtk_style_set_register_property_font (const gchar *property_name, PangoFontDescription *initial_value); +void gtk_style_set_register_property_border (const gchar *property_name, + GtkBorder *initial_value); void gtk_style_set_register_property_int (const gchar *property_name, gint default_value); void gtk_style_set_register_property_uint (const gchar *property_name, From b82355c76ed3bb59e117b0ed7b32e394a61fa949 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 7 Mar 2010 19:58:35 +0100 Subject: [PATCH 095/634] GtkStyleContext: Fix typo. --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index b5c1f075d5..a37226a9bf 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -266,7 +266,7 @@ gtk_style_context_get (GtkStyleContext *context, priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); va_start (args, state); - gtk_style_context_get_valist (priv->store, state, args); + gtk_style_set_get_valist (priv->store, state, args); va_end (args); } From 8a7e035ac731dbf5e50e90221ba57ebe8edbd450 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 10 Mar 2010 00:28:18 +0100 Subject: [PATCH 096/634] GtkStateType: Add inconsistent and focused state. --- gtk/gtkenums.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index db53a4172f..d38e5e79d7 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -368,6 +368,8 @@ typedef enum GTK_STATE_PRELIGHT, GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE, + GTK_STATE_INCONSISTENT, + GTK_STATE_FOCUSED, GTK_STATE_LAST } GtkStateType; From 2e96770e0b3686380e94d3c82d428958f648c9ec Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 10 Mar 2010 00:52:57 +0100 Subject: [PATCH 097/634] Add GtkStateFlags. It basically represents GtkStateType as a flag set. --- gtk/gtkenums.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index d38e5e79d7..d613cb47f5 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -560,6 +560,17 @@ typedef enum GTK_SCROLL_NATURAL } GtkScrollablePolicy; +typedef enum +{ + GTK_STATE_FLAG_ACTIVE = 1 << 0, + GTK_STATE_FLAG_PRELIGHT = 1 << 1, + GTK_STATE_FLAG_SELECTED = 1 << 2, + GTK_STATE_FLAG_INSENSITIVE = 1 << 3, + GTK_STATE_FLAG_INCONSISTENT = 1 << 4, + GTK_STATE_FLAG_FOCUSED = 1 << 5 +} GtkStateFlags; + + G_END_DECLS From 3f93c714ae749c106cb037c76bc6e72176e0b6c6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 10 Mar 2010 00:55:48 +0100 Subject: [PATCH 098/634] GtkWidget: Add gtk_widget_get_style_context(). There will be one GtkStyleContext per widget, at the moment its lifetime is tied to the widget's, but it could be narrowed down to GTK_WIDGET_REALIZED. --- gtk/gtkwidget.c | 23 +++++++++++++++++++++++ gtk/gtkwidget.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e7312a0980..c28c31f5a9 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -58,6 +58,7 @@ #include "gtkbuildable.h" #include "gtkbuilderprivate.h" #include "gtksizerequest.h" +#include "gtkstylecontext.h" #include "gtkdebug.h" @@ -670,6 +671,7 @@ static GQuark quark_tooltip_markup = 0; static GQuark quark_has_tooltip = 0; static GQuark quark_tooltip_window = 0; static GQuark quark_visual = 0; +static GQuark quark_style_context = 0; GParamSpecPool *_gtk_widget_child_property_pool = NULL; GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL; @@ -783,6 +785,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip"); quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window"); quark_visual = g_quark_from_static_string ("gtk-widget-visual"); + quark_style_context = g_quark_from_static_string ("gtk-style-context"); style_property_spec_pool = g_param_spec_pool_new (FALSE); _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE); @@ -13161,3 +13164,23 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, { widget->priv->height_request_needed = height_request_needed; } + +GtkStyleContext * +gtk_widget_get_style_context (GtkWidget *widget) +{ + GtkStyleContext *context; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + + if (G_UNLIKELY (!context)) + { + context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); + g_object_set_qdata_full (widget, quark_style_context, context, + (GDestroyNotify) g_object_unref); + } + + return context; +} diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 034bcade1e..23afab27b7 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -36,6 +36,7 @@ #include #include #include +#include #include G_BEGIN_DECLS @@ -941,6 +942,9 @@ void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget, gboolean gtk_widget_in_destruction (GtkWidget *widget); +GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget); + + G_END_DECLS #endif /* __GTK_WIDGET_H__ */ From 835cc7049cc9f1f3730d04b05b334a3ca28b6576 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 10 Mar 2010 01:02:46 +0100 Subject: [PATCH 099/634] GtkStyleContext: Add getters and setter for state. --- gtk/gtkstylecontext.c | 55 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 7 ++++++ 2 files changed, 62 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index a37226a9bf..85727e3ecb 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -40,6 +40,7 @@ struct GtkStyleContextPrivate { GList *providers; GtkStyleSet *store; + GtkStateFlags state_flags; }; #define GTK_STYLE_CONTEXT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextPrivate)) @@ -270,5 +271,59 @@ gtk_style_context_get (GtkStyleContext *context, va_end (args); } +void +gtk_style_context_set_state (GtkStyleContext *context, + GtkStateFlags flags) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv->state_flags = flags; +} + +GtkStateFlags +gtk_style_context_get_state (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + return priv->state_flags; +} + +gboolean +gtk_style_context_is_state_set (GtkStyleContext *context, + GtkStateType state) +{ + GtkStyleContextPrivate *priv; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + switch (state) + { + case GTK_STATE_NORMAL: + return priv->state_flags == 0; + case GTK_STATE_ACTIVE: + return priv->state_flags & GTK_STATE_FLAG_ACTIVE; + case GTK_STATE_PRELIGHT: + return priv->state_flags & GTK_STATE_FLAG_PRELIGHT; + case GTK_STATE_SELECTED: + return priv->state_flags & GTK_STATE_FLAG_SELECTED; + case GTK_STATE_INSENSITIVE: + return priv->state_flags & GTK_STATE_FLAG_INSENSITIVE; + case GTK_STATE_INCONSISTENT: + return priv->state_flags & GTK_STATE_FLAG_INCONSISTENT; + case GTK_STATE_FOCUSED: + return priv->state_flags & GTK_STATE_FLAG_FOCUSED; + default: + return FALSE; + } +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 37d4f15e4f..edc6732975 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -65,6 +65,13 @@ void gtk_style_context_get (GtkStyleContext *context, GtkStateType state, ...) G_GNUC_NULL_TERMINATED; +void gtk_style_context_set_state (GtkStyleContext *context, + GtkStateFlags flags); +GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); + +gboolean gtk_style_context_is_state_set (GtkStyleContext *context, + GtkStateType state); + G_END_DECLS #endif /* __GTK_STYLE_CONTEXT_H__ */ From 61360dfddfaddaa68e96137e9f9e8881bd3669b3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Mar 2010 18:55:54 +0100 Subject: [PATCH 100/634] Add GtkWidgetPath. GtkWidgetPath represents a widget path. It will mainly used by theming engines to know detail about the widget hierarchy without actually accessing the widget. --- gtk/Makefile.am | 2 + gtk/gtk.h | 1 + gtk/gtkwidgetpath.c | 182 ++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkwidgetpath.h | 52 +++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 gtk/gtkwidgetpath.c create mode 100644 gtk/gtkwidgetpath.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 94299bd4d0..edbe7f58c4 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -338,6 +338,7 @@ gtk_public_h_sources = \ gtkvscrollbar.h \ gtkvseparator.h \ gtkwidget.h \ + gtkwidgetpath.h \ gtkwindow.h if OS_UNIX @@ -646,6 +647,7 @@ gtk_base_c_sources = \ gtkvscrollbar.c \ gtkvseparator.c \ gtkwidget.c \ + gtkwidgetpath.c \ gtkwindow-decorate.c \ gtkwindow.c \ $(gtk_clipboard_dnd_c_sources) \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 1bc1c75f43..374b1edfb9 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -221,6 +221,7 @@ #include #include #include +#include #include #undef __GTK_H_INSIDE__ diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c new file mode 100644 index 0000000000..2af624f557 --- /dev/null +++ b/gtk/gtkwidgetpath.c @@ -0,0 +1,182 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 + +#include "gtkwidget.h" +#include "gtkwidgetpath.h" + +typedef struct GtkPathElement GtkPathElement; + +struct GtkPathElement +{ + GType type; + gchar *name; +}; + +struct GtkWidgetPath +{ + GSList *elems; + GSList *last; /* Last element contains the described widget */ +}; + +GtkWidgetPath * +gtk_widget_path_new (void) +{ + GtkWidgetPath *path; + + path = g_slice_new0 (GtkWidgetPath); + + return path; +} + +static GtkPathElement * +path_element_new (GType type, + const gchar *name) +{ + GtkPathElement *elem; + + elem = g_slice_new (GtkPathElement); + elem->type = type; + elem->name = g_strdup (name); + + return elem; +} + +static void +path_element_free (GtkPathElement *elem) +{ + g_free (elem->name); + g_slice_free (GtkPathElement, elem); +} + +void +gtk_widget_path_prepend_widget_desc (GtkWidgetPath *path, + GType type, + const gchar *name) +{ + g_return_if_fail (path != NULL); + g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET)); + + if (!path->elems) + { + path->elems = g_slist_prepend (NULL, path_element_new (type, name)); + path->last = path->elems; + } + else + { + path->last->next = g_slist_alloc (); + path->last->next->data = path_element_new (type, name); + path->last = path->last->next; + } +} + +GtkWidgetPath * +gtk_widget_path_copy (GtkWidgetPath *path) +{ + GtkWidgetPath *new_path; + GSList *elems; + + new_path = gtk_widget_path_new (); + elems = path->elems; + + while (elems) + { + GtkPathElement *elem; + GSList *link; + + elem = elems->data; + link = g_slist_alloc (); + link->data = path_element_new (elem->type, elem->name); + + if (!new_path->elems) + new_path->last = new_path->elems = link; + else + { + new_path->last->next = link; + new_path->last = link; + } + + elems = elems->next; + } + + return new_path; +} + +void +gtk_widget_path_free (GtkWidgetPath *path) +{ + g_return_if_fail (path != NULL); + + g_slist_foreach (path->elems, (GFunc) path_element_free, NULL); + g_slist_free (path->elems); + + g_slice_free (GtkWidgetPath, path); +} + +gboolean +gtk_widget_path_has_parent (GtkWidgetPath *path, + GType type) +{ + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); + + GSList *elems = path->elems; + + while (elems) + { + GtkPathElement *elem; + + elem = elems->data; + + if (elem->type == type || + g_type_is_a (elem->type, type)) + return TRUE; + + elems = elems->next; + } + + return FALSE; +} + +void +gtk_widget_path_foreach (GtkWidgetPath *path, + GtkWidgetPathForeachFunc func, + gpointer user_data) +{ + GSList *elems; + + g_return_if_fail (path != NULL); + g_return_if_fail (func != NULL); + + elems = path->elems; + + while (elems) + { + GtkPathElement *elem; + + elem = elems->data; + elems = elems->next; + + if ((func) (elem->type, elem->name, user_data)) + return; + } +} diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h new file mode 100644 index 0000000000..664562cbc4 --- /dev/null +++ b/gtk/gtkwidgetpath.h @@ -0,0 +1,52 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_WIDGET_PATH_H__ +#define __GTK_WIDGET_PATH_H__ + +#include + +G_BEGIN_DECLS + +typedef struct GtkWidgetPath GtkWidgetPath; + +typedef gboolean (* GtkWidgetPathForeachFunc) (GType type, + const gchar *name, + gpointer user_data); + +GtkWidgetPath * gtk_widget_path_new (void); + +void gtk_widget_path_prepend_widget_desc (GtkWidgetPath *path, + GType type, + const gchar *name); + +GtkWidgetPath * gtk_widget_path_copy (GtkWidgetPath *path); +void gtk_widget_path_free (GtkWidgetPath *path); + +gboolean gtk_widget_path_has_parent (GtkWidgetPath *path, + GType type); + +void gtk_widget_path_foreach (GtkWidgetPath *path, + GtkWidgetPathForeachFunc func, + gpointer user_data); + + +G_END_DECLS + +#endif /* __GTK_WIDGET_PATH_H__ */ From 9794b6adf9f5885a54450e1dbb7bdf629d17ef2c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Mar 2010 19:02:33 +0100 Subject: [PATCH 101/634] GtkWidget: Add gtk_widget_get_path(). This function composes and returns a GtkWidgetPath representing the passed widget. --- gtk/gtkwidget.c | 24 +++++++++++++++++++++++- gtk/gtkwidget.h | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index c28c31f5a9..f6a1fe31ab 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13165,6 +13165,27 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, widget->priv->height_request_needed = height_request_needed; } +GtkWidgetPath * +gtk_widget_get_path (GtkWidget *widget) +{ + GtkWidgetPath *path; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL); + + path = gtk_widget_path_new (); + + while (widget) + { + gtk_widget_path_prepend_widget_desc (path, + G_OBJECT_TYPE (widget), + widget->name); + widget = widget->parent; + } + + return path; +} + GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget) { @@ -13178,7 +13199,8 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); - g_object_set_qdata_full (widget, quark_style_context, context, + g_object_set_qdata_full (G_OBJECT (widget), + quark_style_context, context, (GDestroyNotify) g_object_unref); } diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 23afab27b7..e522b2b9b8 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -37,6 +37,7 @@ #include #include #include +#include #include G_BEGIN_DECLS @@ -944,6 +945,8 @@ gboolean gtk_widget_in_destruction (GtkWidget *widget); GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget); +GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget); + G_END_DECLS From b7e6ae3983b53396b017cfb6dbf22b4a7ad4e149 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Mar 2010 11:15:42 +0100 Subject: [PATCH 102/634] GtkStyleContext: Add gtk_style_context_[gs]et_path() This relates a GtkStyleContext with a widget path, so all style querying would happen based on it. --- gtk/gtkstylecontext.c | 32 ++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 8 +++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 85727e3ecb..b19b02a20f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -40,6 +40,8 @@ struct GtkStyleContextPrivate { GList *providers; GtkStyleSet *store; + GtkWidgetPath *widget_path; + GtkStateFlags state_flags; }; @@ -325,5 +327,35 @@ gtk_style_context_is_state_set (GtkStyleContext *context, } } +void +gtk_style_context_set_path (GtkStyleContext *context, + GtkWidgetPath *path) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (path != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + if (priv->widget_path) + { + gtk_widget_path_free (priv->widget_path); + priv->widget_path = NULL; + } + + if (path) + priv->widget_path = gtk_widget_path_copy (path); +} + +G_CONST_RETURN GtkWidgetPath * +gtk_style_context_get_path (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + return priv->widget_path; +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index edc6732975..79f0f351e0 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -21,7 +21,8 @@ #define __GTK_STYLE_CONTEXT_H__ #include -#include "gtkstyleprovider.h" +#include +#include G_BEGIN_DECLS @@ -72,6 +73,11 @@ GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); gboolean gtk_style_context_is_state_set (GtkStyleContext *context, GtkStateType state); +void gtk_style_context_set_path (GtkStyleContext *context, + GtkWidgetPath *path); +G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context); + + G_END_DECLS #endif /* __GTK_STYLE_CONTEXT_H__ */ From 57be029b15769dea10a281db6c6590ed902b4bfb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Mar 2010 11:23:23 +0100 Subject: [PATCH 103/634] Add GtkThemingEngine. GtkThemingEngine will be the theming engines base class, with default implementations for all paint functions, and readonly access to the related GtkStyleContext data. --- gtk/Makefile.am | 2 + gtk/gtk.h | 1 + gtk/gtkthemingengine.c | 152 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 77 +++++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 gtk/gtkthemingengine.c create mode 100644 gtk/gtkthemingengine.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index edbe7f58c4..199dba1ebb 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -308,6 +308,7 @@ gtk_public_h_sources = \ gtktexttag.h \ gtktexttagtable.h \ gtktextview.h \ + gtkthemingengine.h \ gtktoggleaction.h \ gtktogglebutton.h \ gtktoggletoolbutton.h \ @@ -615,6 +616,7 @@ gtk_base_c_sources = \ gtktextutil.c \ gtktextview.c \ gtkthemes.c \ + gtkthemingengine.c \ gtktoggleaction.c \ gtktogglebutton.c \ gtktoggletoolbutton.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 374b1edfb9..163f8d4e91 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -189,6 +189,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c new file mode 100644 index 0000000000..b3209c8ad6 --- /dev/null +++ b/gtk/gtkthemingengine.c @@ -0,0 +1,152 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 + +#include +#include +#include + +#include "gtkalias.h" + +typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; + +struct GtkThemingEnginePrivate +{ + GtkStyleContext *context; +}; + +#define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate)) + +G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) + +static void +gtk_theming_engine_class_init (GtkThemingEngineClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); +} + +static void +gtk_theming_engine_init (GtkThemingEngine *engine) +{ + engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine); +} + +void +_gtk_theming_engine_set_context (GtkThemingEngine *engine, + GtkStyleContext *context) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = engine->priv; + priv->context = context; +} + +void +gtk_theming_engine_get_property (GtkThemingEngine *engine, + const gchar *property, + GtkStateType state, + GValue *value) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (property != NULL); + g_return_if_fail (state < GTK_STATE_LAST); + g_return_if_fail (value != NULL); + + priv = engine->priv; + gtk_style_context_get_property (priv->context, property, state, value); +} + +void +gtk_theming_engine_get_valist (GtkThemingEngine *engine, + GtkStateType state, + va_list args) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = engine->priv; + gtk_style_context_get_valist (priv->context, state, args); +} + +void +gtk_theming_engine_get (GtkThemingEngine *engine, + GtkStateType state, + ...) +{ + GtkThemingEnginePrivate *priv; + va_list args; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (state < GTK_STATE_LAST); + + priv = engine->priv; + + va_start (args, state); + gtk_style_context_get_valist (priv->context, state, args); + va_end (args); +} + +GtkStateFlags +gtk_theming_engine_get_state (GtkThemingEngine *engine) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); + + priv = engine->priv; + return gtk_style_context_get_state (priv->context); +} + +gboolean +gtk_theming_engine_is_state_set (GtkThemingEngine *engine, + GtkStateType state) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); + + priv = engine->priv; + return gtk_style_context_is_state_set (priv->context, state); +} + +G_CONST_RETURN GtkWidgetPath * +gtk_theming_engine_get_path (GtkThemingEngine *engine) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL); + + priv = engine->priv; + return gtk_style_context_get_path (priv->context); +} + +#define __GTK_THEMING_ENGINE_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h new file mode 100644 index 0000000000..5b7a3d7ae1 --- /dev/null +++ b/gtk/gtkthemingengine.h @@ -0,0 +1,77 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_THEMING_ENGINE_H__ +#define __GTK_THEMING_ENGINE_H__ + +#include +#include + +#include +#include +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_THEMING_ENGINE (gtk_theming_engine_get_type ()) +#define GTK_THEMING_ENGINE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEngine)) +#define GTK_THEMING_ENGINE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_THEMING_ENGINE, GtkThemingEngineClass)) +#define GTK_IS_THEMING_ENGINE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_ENGINE)) +#define GTK_IS_THEMING_ENGINE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_THEMING_ENGINE)) +#define GTK_THEMING_ENGINE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEngineClass)) + +typedef struct GtkThemingEngine GtkThemingEngine; +typedef struct GtkThemingEngineClass GtkThemingEngineClass; + +struct GtkThemingEngine +{ + GObject parent_object; + gpointer priv; +}; + +struct GtkThemingEngineClass +{ + GObjectClass parent_class; +}; + +GType gtk_theming_engine_get_type (void) G_GNUC_CONST; + +void _gtk_theming_engine_set_context (GtkThemingEngine *engine, + GtkStyleContext *context); + +void gtk_theming_engine_get_property (GtkThemingEngine *engine, + const gchar *property, + GtkStateType state, + GValue *value); +void gtk_theming_engine_get_valist (GtkThemingEngine *engine, + GtkStateType state, + va_list args); +void gtk_theming_engine_get (GtkThemingEngine *engine, + GtkStateType state, + ...) G_GNUC_NULL_TERMINATED; + +G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); + +GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); +gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, + GtkStateType state); + +G_END_DECLS + +#endif /* __GTK_THEMING_ENGINE_H__ */ From 0171c768710a4663163443b2e77bbdb3bf1feea5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Mar 2010 18:35:35 +0100 Subject: [PATCH 104/634] GtkThemingEngine: Add module loading capabilities. --- gtk/gtkthemingengine.c | 121 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 3 + 2 files changed, 124 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b3209c8ad6..d0939dbd2c 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -38,6 +38,29 @@ struct GtkThemingEnginePrivate G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) + +typedef struct GtkThemingModule GtkThemingModule; +typedef struct GtkThemingModuleClass GtkThemingModuleClass; + +struct GtkThemingModule +{ + GTypeModule parent_instance; + gchar *name; + + GtkThemingEngine * (*create_engine) (void); +}; + +struct GtkThemingModuleClass +{ + GTypeModuleClass parent_class; +}; + +#define GTK_TYPE_THEMING_MODULE (gtk_theming_module_get_type ()) +#define GTK_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_MODULE, GtkThemingModule)) +#define GTK_IS_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_MODULE)) + +G_DEFINE_TYPE (GtkThemingModule, gtk_theming_module, G_TYPE_TYPE_MODULE); + static void gtk_theming_engine_class_init (GtkThemingEngineClass *klass) { @@ -148,5 +171,103 @@ gtk_theming_engine_get_path (GtkThemingEngine *engine) return gtk_style_context_get_path (priv->context); } +/* GtkThemingModule */ + +static gboolean +gtk_theming_module_load (GTypeModule *type_module) +{ + GtkThemingModule *theming_module; + GModule *module; + gchar *name, *module_path; + + theming_module = GTK_THEMING_MODULE (type_module); + name = theming_module->name; + module_path = _gtk_find_module (name, "theming-engines"); + + if (!module_path) + { + g_warning (_("Unable to locate theme engine in module path: \"%s\","), name); + return FALSE; + } + + module = g_module_open (module_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); + g_free (module_path); + + if (!module) + { + g_warning ("%s", g_module_error ()); + return FALSE; + } + + if (!g_module_symbol (module, "create_engine", + (gpointer *) &theming_module->create_engine)) + { + g_warning ("%s", g_module_error()); + g_module_close (module); + + return FALSE; + } + + g_module_make_resident (module); + + return TRUE; +} + +static void +gtk_theming_module_class_init (GtkThemingModuleClass *klass) +{ + GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass); + + module_class->load = gtk_theming_module_load; +} + +static void +gtk_theming_module_init (GtkThemingModule *module) +{ +} + +G_CONST_RETURN GtkThemingEngine * +gtk_theming_engine_load (const gchar *name) +{ + static GHashTable *engines = NULL; + static GtkThemingEngine *default_engine; + GtkThemingEngine *engine = NULL; + + if (name) + { + if (!engines) + engines = g_hash_table_new (g_str_hash, g_str_equal); + + engine = g_hash_table_lookup (engines, name); + + if (!engine) + { + GtkThemingModule *module; + + module = g_object_new (GTK_TYPE_THEMING_MODULE, NULL); + g_type_module_set_name (G_TYPE_MODULE (module), name); + module->name = g_strdup (name); + + if (module && g_type_module_use (G_TYPE_MODULE (module))) + { + engine = (module->create_engine) (); + + if (engine) + g_hash_table_insert (engines, module->name, engine); + } + } + } + + if (!engine) + { + if (!default_engine) + default_engine = g_object_new (GTK_TYPE_THEMING_ENGINE, NULL); + + engine = default_engine; + } + + return engine; +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 5b7a3d7ae1..54547e87e5 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -72,6 +72,9 @@ GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, GtkStateType state); +G_CONST_RETURN GtkThemingEngine * gtk_theming_engine_load (const gchar *name); + + G_END_DECLS #endif /* __GTK_THEMING_ENGINE_H__ */ From bd3b97d82bb31171f6917382b0a4a0a44721821c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Mar 2010 20:08:06 +0100 Subject: [PATCH 105/634] GtkStyleContext: Relate to a GtkThemingEngine. --- gtk/gtkstylecontext.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index b19b02a20f..6dfdf50f26 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -23,6 +23,7 @@ #include "gtkstylecontext.h" #include "gtktypebuiltins.h" +#include "gtkthemingengine.h" #include "gtkintl.h" #include "gtkalias.h" @@ -43,6 +44,8 @@ struct GtkStyleContextPrivate GtkWidgetPath *widget_path; GtkStateFlags state_flags; + + GtkThemingEngine *theming_engine; }; #define GTK_STYLE_CONTEXT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextPrivate)) @@ -69,6 +72,7 @@ gtk_style_context_init (GtkStyleContext *style_context) priv = GTK_STYLE_CONTEXT_GET_PRIVATE (style_context); priv->store = gtk_style_set_new (); + priv->theming_engine = gtk_theming_engine_load (NULL); } static GtkStyleProviderData * From 9a76d1a332e7b460867b438492a5e2f9e616c8fd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 13:02:20 +0100 Subject: [PATCH 106/634] GtkStyleContext: Add style classes. Style classes are the replacement of detail strings. --- gtk/gtkstylecontext.c | 83 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 7 ++++ 2 files changed, 90 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 6dfdf50f26..59fc5c3f9b 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -44,6 +44,7 @@ struct GtkStyleContextPrivate GtkWidgetPath *widget_path; GtkStateFlags state_flags; + GList *style_classes; GtkThemingEngine *theming_engine; }; @@ -361,5 +362,87 @@ gtk_style_context_get_path (GtkStyleContext *context) return priv->widget_path; } +void +gtk_style_context_set_class (GtkStyleContext *context, + const gchar *class_name) +{ + GtkStyleContextPrivate *priv; + GQuark class_quark; + GList *link; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (class_name != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + class_quark = g_quark_from_string (class_name); + + link = priv->style_classes; + + while (link) + { + GQuark link_quark; + + link_quark = GUINT_TO_POINTER (link->data); + + if (link_quark == class_quark) + return; + else if (link_quark > class_quark) + { + priv->style_classes = g_list_insert_before (priv->style_classes, + link, GUINT_TO_POINTER (class_quark)); + return; + } + + link = link->next; + } + + priv->style_classes = g_list_append (priv->style_classes, + GUINT_TO_POINTER (class_quark)); +} + +void +gtk_style_context_unset_class (GtkStyleContext *context, + const gchar *class_name) +{ + GtkStyleContextPrivate *priv; + GQuark class_quark; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (class_name != NULL); + + class_quark = g_quark_try_string (class_name); + + if (!class_quark) + return; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv->style_classes = g_list_remove (priv->style_classes, + GUINT_TO_POINTER (class_quark)); +} + +gboolean +gtk_style_context_has_class (GtkStyleContext *context, + const gchar *class_name) +{ + GtkStyleContextPrivate *priv; + GQuark class_quark; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); + g_return_val_if_fail (class_name != NULL, FALSE); + + class_quark = g_quark_try_string (class_name); + + if (!class_quark) + return FALSE; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + if (g_list_find (priv->style_classes, + GUINT_TO_POINTER (class_quark))) + return TRUE; + + return FALSE; +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 79f0f351e0..3d594ee2a5 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -77,6 +77,13 @@ void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context); +void gtk_style_context_set_class (GtkStyleContext *context, + const gchar *class_name); +void gtk_style_context_unset_class (GtkStyleContext *context, + const gchar *class_name); +gboolean gtk_style_context_has_class (GtkStyleContext *context, + const gchar *class_name); + G_END_DECLS From 1d2aa614078a1bcc9e270aceb265cefc6fc1702d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 13:07:41 +0100 Subject: [PATCH 107/634] GtkStyleContext: Add child style classes. Child style classes are like style classes, but with additional positional information. This would be usually set by the parent container. --- gtk/gtkstylecontext.c | 139 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 17 ++++++ 2 files changed, 156 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 59fc5c3f9b..ddb34dc322 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -30,6 +30,13 @@ typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; +typedef struct GtkChildClass GtkChildClass; + +struct GtkChildClass +{ + GQuark class_quark; + GtkChildClassFlags flags; +}; struct GtkStyleProviderData { @@ -45,6 +52,7 @@ struct GtkStyleContextPrivate GtkStateFlags state_flags; GList *style_classes; + GList *child_style_classes; GtkThemingEngine *theming_engine; }; @@ -444,5 +452,136 @@ gtk_style_context_has_class (GtkStyleContext *context, return FALSE; } +static gint +child_style_class_compare (gconstpointer p1, + gconstpointer p2) +{ + const GtkChildClass *c1, *c2; + + c1 = p1; + c2 = p2; + + return (gint) c1->class_quark - c2->class_quark; +} + +void +gtk_style_context_set_child_class (GtkStyleContext *context, + const gchar *class_name, + GtkChildClassFlags flags) +{ + GtkStyleContextPrivate *priv; + GtkChildClass *child_class; + GQuark class_quark; + GList *link; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (class_name != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + class_quark = g_quark_from_string (class_name); + link = priv->style_classes; + + while (link) + { + GtkChildClass *link_class; + + link_class = link->data; + + if (link_class->class_quark == class_quark) + { + link_class->flags = flags; + return; + } + else if (link_class->class_quark > class_quark) + break; + + link = link->next; + } + + child_class = g_slice_new0 (GtkChildClass); + child_class->class_quark = class_quark; + child_class->flags = flags; + + if (link) + priv->style_classes = g_list_insert_before (priv->style_classes, + link, child_class); + else + priv->style_classes = g_list_append (priv->style_classes, child_class); +} + +void +gtk_style_context_unset_child_class (GtkStyleContext *context, + const gchar *class_name) +{ + GtkStyleContextPrivate *priv; + GtkChildClass child_class; + GQuark class_quark; + GList *link; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (class_name != NULL); + + class_quark = g_quark_try_string (class_name); + + if (!class_quark) + return; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + child_class.class_quark = class_quark; + + link = g_list_find_custom (priv->child_style_classes, + &child_class, child_style_class_compare); + + if (link) + { + priv->child_style_classes = g_list_remove_link (priv->child_style_classes, link); + g_slice_free (GtkChildClass, link->data); + g_list_free1 (link); + } +} + +gboolean +gtk_style_context_has_child_class (GtkStyleContext *context, + const gchar *class_name, + GtkChildClassFlags *flags_return) +{ + GtkStyleContextPrivate *priv; + GtkChildClass child_class; + GQuark class_quark; + GList *link; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); + g_return_val_if_fail (class_name != NULL, FALSE); + + if (flags_return) + *flags_return = 0; + + class_quark = g_quark_try_string (class_name); + + if (!class_quark) + return FALSE; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + child_class.class_quark = class_quark; + + link = g_list_find_custom (priv->child_style_classes, + &child_class, child_style_class_compare); + + if (link) + { + if (*flags_return) + { + GtkChildClass *found_class; + + found_class = link->data; + *flags_return = found_class->flags; + } + + return TRUE; + } + + return FALSE; +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 3d594ee2a5..cc8336ecd3 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -36,6 +36,15 @@ G_BEGIN_DECLS typedef struct GtkStyleContext GtkStyleContext; typedef struct GtkStyleContextClass GtkStyleContextClass; +typedef enum { + GTK_CHILD_CLASS_EVEN = 1 << 0, + GTK_CHILD_CLASS_ODD = 1 << 1, + GTK_CHILD_CLASS_FIRST = 1 << 2, + GTK_CHILD_CLASS_LAST = 1 << 3, + GTK_CHILD_CLASS_DEFAULT = 1 << 4, + GTK_CHILD_CLASS_SORTED = 1 << 5 +} GtkChildClassFlags; + struct GtkStyleContext { GObject parent_object; @@ -84,6 +93,14 @@ void gtk_style_context_unset_class (GtkStyleContext *context, gboolean gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name); +void gtk_style_context_set_child_class (GtkStyleContext *context, + const gchar *class_name, + GtkChildClassFlags flags); +void gtk_style_context_unset_child_class (GtkStyleContext *context, + const gchar *class_name); +gboolean gtk_style_context_has_child_class (GtkStyleContext *context, + const gchar *class_name, + GtkChildClassFlags *flags_return); G_END_DECLS From fe4a6cea734ec869578ecd0e641b568a1a8fca34 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 13:30:05 +0100 Subject: [PATCH 108/634] GtkWidget: Add widget path to style context. --- gtk/gtkwidget.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f6a1fe31ab..366f912244 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4146,6 +4146,7 @@ gtk_widget_realize (GtkWidget *widget) GtkWidgetPrivate *priv; GdkExtensionMode mode; cairo_region_t *region; + GtkStyleContext *context; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (widget->priv->anchored || @@ -4195,6 +4196,17 @@ gtk_widget_realize (GtkWidget *widget) gdk_window_set_support_multidevice (priv->window, TRUE); _gtk_widget_enable_device_events (widget); + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + if (context) + { + GtkWidgetPath *path; + + path = gtk_widget_get_path (widget); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); + } } } @@ -13204,5 +13216,14 @@ gtk_widget_get_style_context (GtkWidget *widget) (GDestroyNotify) g_object_unref); } + if (GTK_WIDGET_REALIZED (widget)) + { + GtkWidgetPath *path; + + path = gtk_widget_get_path (widget); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); + } + return context; } From bf7a9914ddcb9bb65c8099686edf1db75b767fcf Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 14:13:50 +0100 Subject: [PATCH 109/634] GtkThemingEngine: Add accessors to style classes. --- gtk/gtkthemingengine.c | 28 ++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index d0939dbd2c..a705f9fe41 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -171,6 +171,34 @@ gtk_theming_engine_get_path (GtkThemingEngine *engine) return gtk_style_context_get_path (priv->context); } +gboolean +gtk_theming_engine_has_class (GtkThemingEngine *engine, + const gchar *style_class) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); + + priv = engine->priv; + return gtk_style_context_has_class (priv->context, style_class); +} + +gboolean +gtk_theming_engine_has_child_class (GtkThemingEngine *engine, + const gchar *style_class, + GtkChildClassFlags *flags) +{ + GtkThemingEnginePrivate *priv; + + if (flags) + *flags = 0; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); + + priv = engine->priv; + return gtk_style_context_has_child_class (priv->context, style_class, flags); +} + /* GtkThemingModule */ static gboolean diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 54547e87e5..b17c6e1167 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -68,6 +68,12 @@ void gtk_theming_engine_get (GtkThemingEngine *engine, G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); +gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, + const gchar *style_class); +gboolean gtk_theming_engine_has_child_class (GtkThemingEngine *engine, + const gchar *style_class, + GtkChildClassFlags *flags); + GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, GtkStateType state); From acf4306bcdf8ac5476d95f087f44d13fd8950082 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 14:17:40 +0100 Subject: [PATCH 110/634] GtkThemingEngine: Add vmethod to render checkboxes. --- gtk/gtkthemingengine.c | 81 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 7 ++++ 2 files changed, 88 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a705f9fe41..82613ff6b4 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -36,6 +36,13 @@ struct GtkThemingEnginePrivate #define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate)) +static void gtk_theming_engine_render_check (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); + G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -66,6 +73,8 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + klass->render_check = gtk_theming_engine_render_check; + g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -297,5 +306,77 @@ gtk_theming_engine_load (const gchar *name) return engine; } +/* Paint method implementations */ +static void +gtk_theming_engine_render_check (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkColor *fg_color, *base_color, *text_color; + const GtkWidgetPath *path; + GtkStateFlags flags; + GtkStateType state; + + flags = gtk_theming_engine_get_state (engine); + path = gtk_theming_engine_get_path (engine); + cairo_save (cr); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + "base-color", &base_color, + "text-color", &text_color, + NULL); + + if (!gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) + { + cairo_set_line_width (cr, 1); + + cairo_rectangle (cr, + x + 0.5, y + 0.5, + width - 1, height - 1); + + gdk_cairo_set_source_color (cr, base_color); + cairo_fill_preserve (cr); + + if (gtk_widget_path_has_parent (path, GTK_TYPE_TREE_VIEW)) + gdk_cairo_set_source_color (cr, text_color); + else + gdk_cairo_set_source_color (cr, fg_color); + + cairo_stroke (cr); + } + + cairo_set_line_width (cr, 1.5); + gdk_cairo_set_source_color (cr, text_color); + + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) + { + cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); + cairo_line_to (cr, x + (width * 0.8), y + (height / 2)); + } + else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) + { + cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); + cairo_line_to (cr, x + (width * 0.4), y + (height * 0.8)); + cairo_line_to (cr, x + (width * 0.8), y + (height * 0.2)); + } + + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_color_free (fg_color); + gdk_color_free (base_color); + gdk_color_free (text_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index b17c6e1167..7bba3fb78e 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -48,6 +48,13 @@ struct GtkThemingEngine struct GtkThemingEngineClass { GObjectClass parent_class; + + void (* render_check) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 401625b8b35c574bfa8ee57c267fdc76a236fbb8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 14:26:11 +0100 Subject: [PATCH 111/634] GtkStyleContext: Add gtk_render_check(). --- gtk/gtkstylecontext.c | 24 ++++++++++++++++++++++++ gtk/gtkstylecontext.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index ddb34dc322..96b7f740d5 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -583,5 +583,29 @@ gtk_style_context_has_child_class (GtkStyleContext *context, return FALSE; } + +/* Paint methods */ +void +gtk_render_check (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_check (priv->theming_engine, cr, + x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index cc8336ecd3..fadd1fc03b 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -102,6 +102,14 @@ gboolean gtk_style_context_has_child_class (GtkStyleContext *context, const gchar *class_name, GtkChildClassFlags *flags_return); +/* Paint methods */ +void gtk_render_check (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); + G_END_DECLS #endif /* __GTK_STYLE_CONTEXT_H__ */ From 263f6de0e5704954e08dec3abb8d23b27bee9e1c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 17:37:34 +0100 Subject: [PATCH 112/634] GtkThemingEngine: Add vmethod to render radio buttons. --- gtk/gtkthemingengine.c | 83 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 +++ 2 files changed, 89 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 82613ff6b4..2962f52223 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -42,6 +42,12 @@ static void gtk_theming_engine_render_check (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_option (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -74,6 +80,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); klass->render_check = gtk_theming_engine_render_check; + klass->render_option = gtk_theming_engine_render_option; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -378,5 +385,81 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, gdk_color_free (text_color); } +static void +gtk_theming_engine_render_option (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags flags; + GdkColor *base_color, *fg_color, *text_color; + const GtkWidgetPath *path; + GtkStateType state; + gdouble radius; + + flags = gtk_theming_engine_get_state (engine); + path = gtk_theming_engine_get_path (engine); + radius = MIN (width, height) / 2 - 0.5; + + cairo_save (cr); + cairo_set_line_width (cr, 1); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + "base-color", &base_color, + "text-color", &text_color, + NULL); + + if (!gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) + { + cairo_arc (cr, + x + (width / 2), + y + (height / 2), + radius, + 0, 2 * G_PI); + + gdk_cairo_set_source_color (cr, base_color); + cairo_fill_preserve (cr); + + if (gtk_widget_path_has_parent (path, GTK_TYPE_TREE_VIEW)) + gdk_cairo_set_source_color (cr, text_color); + else + gdk_cairo_set_source_color (cr, fg_color); + + cairo_stroke (cr); + } + + if (gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) + gdk_cairo_set_source_color (cr, fg_color); + else + gdk_cairo_set_source_color (cr, text_color); + + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) + { + cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); + cairo_line_to (cr, x + (width * 0.8), y + (height / 2)); + cairo_stroke (cr); + } + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) + { + cairo_arc (cr, + x + (width / 2), + y + (height / 2), + radius / 2, + 0, 2 * G_PI); + + cairo_fill (cr); + } + + cairo_restore (cr); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 7bba3fb78e..f322e73b9b 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -55,6 +55,12 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_option) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 1c15b140a9050687074e4aed05b0fb831368565a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 20 Mar 2010 17:40:21 +0100 Subject: [PATCH 113/634] GtkStyleContext: Add gtk_render_option(). --- gtk/gtkstylecontext.c | 22 ++++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 96b7f740d5..50d3bb2859 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -607,5 +607,27 @@ gtk_render_check (GtkStyleContext *context, x, y, width, height); } +void +gtk_render_option (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_option (priv->theming_engine, cr, + x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index fadd1fc03b..8a14b1ed83 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -109,6 +109,12 @@ void gtk_render_check (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_option (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS From b7ca7d19ee4eeb67e24a4d4fd553a970f28f7f2f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 18:50:39 +0100 Subject: [PATCH 114/634] GtkThemingEngine: Add vmethod to render arrows. --- gtk/gtkthemingengine.c | 70 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++++ 2 files changed, 76 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 2962f52223..9e9443f573 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -48,6 +48,12 @@ static void gtk_theming_engine_render_option (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -81,6 +87,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_check = gtk_theming_engine_render_check; klass->render_option = gtk_theming_engine_render_option; + klass->render_arrow = gtk_theming_engine_render_arrow; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -461,5 +468,68 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_restore (cr); } +static void +add_path_arrow (cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size) +{ + cairo_save (cr); + + cairo_translate (cr, x + (size / 2), y + (size / 2)); + cairo_rotate (cr, angle); + + cairo_move_to (cr, 0, - (size / 4) + 0.5); + cairo_line_to (cr, - (size / 2), (size / 4) + 0.5); + cairo_line_to (cr, (size / 2), (size / 4) + 0.5); + cairo_close_path (cr); + + cairo_restore (cr); +} + +static void +gtk_theming_engine_render_arrow (GtkThemingEngine *engine, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *fg_color; + + cairo_save (cr); + + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + NULL); + + if (flags & GTK_STATE_FLAG_INSENSITIVE) + { + add_path_arrow (cr, angle, x + 1, y + 1, size); + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_fill (cr); + } + + add_path_arrow (cr, angle, x, y, size); + gdk_cairo_set_source_color (cr, fg_color); + cairo_fill (cr); + + cairo_restore (cr); + + gdk_color_free (fg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index f322e73b9b..960339f8bb 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -61,6 +61,12 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_arrow) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 01a8e068420d68cd62a9d81a33f83ce12017509f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 19:57:54 +0100 Subject: [PATCH 115/634] GtkStyleContext: Add gtk_render_arrow(). --- gtk/gtkstylecontext.c | 22 ++++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 50d3bb2859..43fb27a3ad 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -629,5 +629,27 @@ gtk_render_option (GtkStyleContext *context, x, y, width, height); } +void +gtk_render_arrow (GtkStyleContext *context, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_arrow (priv->theming_engine, cr, + angle, x, y, size); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 8a14b1ed83..806d25f754 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -115,6 +115,12 @@ void gtk_render_option (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_arrow (GtkStyleContext *context, + cairo_t *cr, + gdouble angle, + gdouble x, + gdouble y, + gdouble size); G_END_DECLS From 13812de971a8f382232f281284e11f82c77f0bf9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:06:44 +0100 Subject: [PATCH 116/634] GtkThemingEngine: Add vmethod to render backgrounds. --- gtk/gtkthemingengine.c | 173 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++ 2 files changed, 179 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 9e9443f573..ed9d29d6da 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -29,6 +29,13 @@ typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; +enum { + SIDE_LEFT = 1, + SIDE_BOTTOM = 1 << 1, + SIDE_RIGHT = 1 << 2, + SIDE_TOP = 1 << 3 +}; + struct GtkThemingEnginePrivate { GtkStyleContext *context; @@ -54,6 +61,12 @@ static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine, gdouble x, gdouble y, gdouble size); +static void gtk_theming_engine_render_background (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -88,6 +101,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_check = gtk_theming_engine_render_check; klass->render_option = gtk_theming_engine_render_option; klass->render_arrow = gtk_theming_engine_render_arrow; + klass->render_background = gtk_theming_engine_render_background; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -531,5 +545,164 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, gdk_color_free (fg_color); } +static void +add_path_rounded_rectangle (cairo_t *cr, + gdouble radius, + guint sides, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + gdouble r = 0; + + if (sides & SIDE_BOTTOM) + { + /* Bottom left corner */ + if (r == 0) + cairo_move_to (cr, x + 0.5, y + height - 0.5); + else + cairo_arc_negative (cr, + x + r + 0.5, + y + height - r - 0.5, + r, + 135 * (G_PI / 180), + 90 * (G_PI / 180)); + + /* Bottom side */ + cairo_line_to (cr, x + width - r - 0.5, y + height - 0.5); + + /* Bottom right corner */ + if (r > 0) + cairo_arc_negative (cr, + x + width - r - 0.5, + y + height - r - 0.5, + r, + 90 * (G_PI / 180), + 45 * (G_PI / 180)); + } + + if (sides & SIDE_RIGHT) + { + /* Bottom right corner */ + if (r == 0) + { + if ((sides & SIDE_BOTTOM) == 0) + cairo_move_to (cr, x + width - 0.5, y + height - 0.5); + } + else + cairo_arc_negative (cr, + x + width - r - 0.5, + y + height - r - 0.5, + r, + 45 * (G_PI / 180), 0); + + /* Right side */ + cairo_line_to (cr, x + width - 0.5, y + r); + + /* Top right corner */ + if (r > 0) + cairo_arc_negative (cr, + x + width - r - 0.5, + y + r + 0.5, + r, + 0, 315 * (G_PI / 180)); + } + + if (sides & SIDE_TOP) + { + /* Top right corner */ + if (r == 0) + { + if ((sides & SIDE_RIGHT) == 0) + cairo_move_to (cr, x + width - 1, y + 0.5); + } + else + cairo_arc_negative (cr, + x + width - r - 0.5, + y + r + 0.5, + r, + 315 * (G_PI / 180), + 270 * (G_PI / 180)); + + /* Top side */ + cairo_line_to (cr, x + 0.5 + r, y + 0.5); + + /* Top left corner */ + if (r > 0) + cairo_arc_negative (cr, + x + r + 0.5, + y + r + 0.5, + r, + 270 * (G_PI / 180), + 225 * (G_PI / 180)); + } + + if (sides & SIDE_LEFT) + { + /* Top left corner */ + if (r == 0) + { + if ((sides & SIDE_TOP) == 0) + cairo_move_to (cr, x + 0.5, y + 0.5); + } + else + cairo_arc_negative (cr, + x + + r + 0.5, + y + r + 0.5, + r, + 225 * (G_PI / 180), + 180 * (G_PI / 180)); + + /* Left side */ + cairo_line_to (cr, x + 0.5, y + height - r); + + if (r > 0) + cairo_arc_negative (cr, + x + r + 0.5, + y + height - r + 0.5, + r, + 180 * (G_PI / 180), + 135 * (G_PI / 180)); + } +} + +static void +gtk_theming_engine_render_background (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *bg_color; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, + x, y, width, height); + cairo_close_path (cr); + + gdk_cairo_set_source_color (cr, bg_color); + cairo_fill (cr); + + cairo_restore (cr); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 960339f8bb..a9dcff4ddf 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -49,6 +49,12 @@ struct GtkThemingEngineClass { GObjectClass parent_class; + void (* render_background) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); void (* render_check) (GtkThemingEngine *engine, cairo_t *cr, gdouble x, From 25488633ec3b4316847e481376bdaafd87274065 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:08:23 +0100 Subject: [PATCH 117/634] GtkStyleContext: Add gtk_render_background(). --- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 43fb27a3ad..6f44c6dbfc 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -651,5 +651,26 @@ gtk_render_arrow (GtkStyleContext *context, angle, x, y, size); } +void +gtk_render_background (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_background (priv->theming_engine, cr, x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 806d25f754..e68d6f9de5 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -121,6 +121,12 @@ void gtk_render_arrow (GtkStyleContext *context, gdouble x, gdouble y, gdouble size); +void gtk_render_background (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS From 48990bc71cf275a5edea2235161702e4ac181faa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:11:31 +0100 Subject: [PATCH 118/634] GtkThemingEngine: Add vmethod to render frames. --- gtk/gtkthemingengine.c | 96 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 +++ 2 files changed, 102 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index ed9d29d6da..2356440e99 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -67,6 +67,12 @@ static void gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_frame (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -102,6 +108,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_option = gtk_theming_engine_render_option; klass->render_arrow = gtk_theming_engine_render_arrow; klass->render_background = gtk_theming_engine_render_background; + klass->render_frame = gtk_theming_engine_render_frame; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -667,6 +674,16 @@ add_path_rounded_rectangle (cairo_t *cr, } } +static void +color_shade (const GdkColor *color, + gdouble factor, + GdkColor *color_return) +{ + color_return->red = CLAMP (color->red * factor, 0, 65535); + color_return->green = CLAMP (color->green * factor, 0, 65535); + color_return->blue = CLAMP (color->blue * factor, 0, 65535); +} + static void gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_t *cr, @@ -704,5 +721,84 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_restore (cr); } +static void +gtk_theming_engine_render_frame (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *bg_color; + GdkColor lighter, darker; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + cairo_set_line_width (cr, 1); + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + color_shade (bg_color, 0.7, &darker); + color_shade (bg_color, 1.3, &lighter); + + if (flags & GTK_STATE_FLAG_ACTIVE) + { + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT, + x, y, width, height); + + gdk_cairo_set_source_color (cr, &lighter); + cairo_stroke (cr); + + add_path_rounded_rectangle (cr, 0, + SIDE_TOP | SIDE_LEFT, + x + 1, y + 1, width - 2, height - 2); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); + + add_path_rounded_rectangle (cr, 0, + SIDE_TOP | SIDE_LEFT, + x, y, width, height); + gdk_cairo_set_source_color (cr, &darker); + cairo_stroke (cr); + } + else + { + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT, + x, y, width, height); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); + + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT, + x, y, width - 1, height - 1); + + gdk_cairo_set_source_color (cr, &darker); + cairo_stroke (cr); + + add_path_rounded_rectangle (cr, 0, + SIDE_TOP | SIDE_LEFT, + x, y, width, height); + + gdk_cairo_set_source_color (cr, &lighter); + cairo_stroke (cr); + } + + cairo_restore (cr); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index a9dcff4ddf..a2b167dca6 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -55,6 +55,12 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_frame) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); void (* render_check) (GtkThemingEngine *engine, cairo_t *cr, gdouble x, From b4c8eba4803edcd09c23fb76f862004fb4241a0e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:12:46 +0100 Subject: [PATCH 119/634] GtkStyleContext: Add gtk_render_frame(). --- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 6f44c6dbfc..9e97fda6a6 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -672,5 +672,26 @@ gtk_render_background (GtkStyleContext *context, engine_class->render_background (priv->theming_engine, cr, x, y, width, height); } +void +gtk_render_frame (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_frame (priv->theming_engine, cr, x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index e68d6f9de5..f432b4a458 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -127,6 +127,12 @@ void gtk_render_background (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_frame (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS From 19fdaabf4ca7226226f1df19ebc8a73b295b2cce Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:15:45 +0100 Subject: [PATCH 120/634] GtkThemingEngine: Add vmethod to render expanders. --- gtk/gtkthemingengine.c | 62 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++++ 2 files changed, 68 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 2356440e99..b9927ebc24 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -73,6 +73,12 @@ static void gtk_theming_engine_render_frame (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_expander (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -109,6 +115,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_arrow = gtk_theming_engine_render_arrow; klass->render_background = gtk_theming_engine_render_background; klass->render_frame = gtk_theming_engine_render_frame; + klass->render_expander = gtk_theming_engine_render_expander; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -800,5 +807,60 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, cairo_restore (cr); } +static void +gtk_theming_engine_render_expander (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStateFlags flags; + GdkColor *bg_color, *fg_color, *base_color; + GtkStateType state; + gdouble angle; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + "background-color", &bg_color, + "base-color", &base_color, + NULL); + + if (flags & GTK_STATE_FLAG_ACTIVE) + angle = G_PI; + else + angle = G_PI / 2; + + cairo_set_line_width (cr, 1); + add_path_arrow (cr, angle, x + 2, y + 2, + MIN (width - 1, height - 1) - 4); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + gdk_cairo_set_source_color (cr, fg_color); + else + gdk_cairo_set_source_color (cr, base_color); + + cairo_fill_preserve (cr); + + gdk_cairo_set_source_color (cr, fg_color); + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_color_free (base_color); + gdk_color_free (fg_color); + gdk_color_free (bg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index a2b167dca6..969d65b6bf 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -79,6 +79,12 @@ struct GtkThemingEngineClass gdouble x, gdouble y, gdouble size); + void (* render_expander) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 9c3b079c1cb49e1681f1c5b27c27ddb7f0e67217 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:16:44 +0100 Subject: [PATCH 121/634] GtkStyleContext: Add gtk_render_expander(). --- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 9e97fda6a6..bce74a7234 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -693,5 +693,26 @@ gtk_render_frame (GtkStyleContext *context, engine_class->render_frame (priv->theming_engine, cr, x, y, width, height); } +void +gtk_render_expander (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_expander (priv->theming_engine, cr, x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index f432b4a458..a54a431a01 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -133,6 +133,12 @@ void gtk_render_frame (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_expander (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS From 8439537e2f69fec3e1af4c96709c06ed21db06fe Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:18:38 +0100 Subject: [PATCH 122/634] GtkThemingEngine: Add vmethod to render focus indicator. --- gtk/gtkthemingengine.c | 51 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 +++++ 2 files changed, 57 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b9927ebc24..49dbe44dd6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -79,6 +79,12 @@ static void gtk_theming_engine_render_expander (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_focus (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -116,6 +122,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_background = gtk_theming_engine_render_background; klass->render_frame = gtk_theming_engine_render_frame; klass->render_expander = gtk_theming_engine_render_expander; + klass->render_focus = gtk_theming_engine_render_focus; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -862,5 +869,49 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, gdk_color_free (bg_color); } +static void +gtk_theming_engine_render_focus (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + const double dashes[] = { 0.5, 1.5 }; + GdkColor *base_color; + GtkStateFlags flags; + GtkStateType state; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "base-color", &base_color, + NULL); + + cairo_set_line_width (cr, 1.0); + cairo_set_dash (cr, dashes, 2, 0); + + cairo_rectangle (cr, + x + 0.5, + y + 0.5, + width - 1, + height - 1); + + gdk_cairo_set_source_color (cr, base_color); + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_color_free (base_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 969d65b6bf..61dc7f3d79 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -85,6 +85,12 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_focus) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 0486f5bbc023c9d0c684bb5f3330f244a10b89ff Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:19:53 +0100 Subject: [PATCH 123/634] GtkStyleContext: Add gtk_render_focus(). --- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index bce74a7234..3c5cb88db5 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -714,5 +714,26 @@ gtk_render_expander (GtkStyleContext *context, engine_class->render_expander (priv->theming_engine, cr, x, y, width, height); } +void +gtk_render_focus (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_focus (priv->theming_engine, cr, x, y, width, height); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a54a431a01..416a0e7f9d 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -139,6 +139,12 @@ void gtk_render_expander (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_focus (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS From 92994a0129af184d7b7b3be775dc3177b6f2084e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:21:55 +0100 Subject: [PATCH 124/634] GtkThemingEngine: Add vmethod to render layouts. --- gtk/gtkthemingengine.c | 40 ++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 49dbe44dd6..b56a86deaa 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -85,6 +85,11 @@ static void gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -123,6 +128,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_frame = gtk_theming_engine_render_frame; klass->render_expander = gtk_theming_engine_render_expander; klass->render_focus = gtk_theming_engine_render_focus; + klass->render_layout = gtk_theming_engine_render_layout; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -913,5 +919,39 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdk_color_free (base_color); } +static void +gtk_theming_engine_render_layout (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout) +{ + GdkColor *fg_color; + GtkStateFlags flags; + GtkStateType state; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "foreground-color", &fg_color, + NULL); + + cairo_move_to (cr, x, y); + gdk_cairo_set_source_color (cr, fg_color); + pango_cairo_show_layout (cr, layout); + + cairo_restore (cr); + + gdk_color_free (fg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 61dc7f3d79..6a79edc7ce 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -91,6 +91,11 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_layout) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From f80fbbd829fc4cb444709890b355d0efbb1ef682 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 20:22:44 +0100 Subject: [PATCH 125/634] GtkStyleContext: Add gtk_render_layout(). --- gtk/gtkstylecontext.c | 20 ++++++++++++++++++++ gtk/gtkstylecontext.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 3c5cb88db5..583a19bed1 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -735,5 +735,25 @@ gtk_render_focus (GtkStyleContext *context, engine_class->render_focus (priv->theming_engine, cr, x, y, width, height); } +void +gtk_render_layout (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_layout (priv->theming_engine, cr, x, y, layout); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 416a0e7f9d..0bf5e1cca8 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -145,6 +145,11 @@ void gtk_render_focus (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); +void gtk_render_layout (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + PangoLayout *layout); G_END_DECLS From b8f6617d991dc2507cdcfa5ef01f0b9f72243305 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:17:22 +0100 Subject: [PATCH 126/634] GtkThemingEngine: Add vmethod to render lines. --- gtk/gtkthemingengine.c | 121 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++ 2 files changed, 127 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b56a86deaa..9d175dba64 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -90,6 +90,12 @@ static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, gdouble x, gdouble y, PangoLayout *layout); +static void gtk_theming_engine_render_line (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -129,6 +135,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_expander = gtk_theming_engine_render_expander; klass->render_focus = gtk_theming_engine_render_focus; klass->render_layout = gtk_theming_engine_render_layout; + klass->render_line = gtk_theming_engine_render_line; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -919,6 +926,120 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdk_color_free (base_color); } +static void +add_path_line (cairo_t *cr, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) +{ + cairo_move_to (cr, x1 + 0.5, y1 + 0.5); + cairo_line_to (cr, x2 + 0.5, y2 + 0.5); +} + +static void +gtk_theming_engine_render_line (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + GdkColor *bg_color, darker, lighter; + GtkStateFlags flags; + GtkStateType state; + gint thickness, thickness_dark, thickness_light; + gint i; + + thickness = 2; + thickness_dark = thickness / 2; + thickness_light = thickness - thickness_dark; + + flags = gtk_theming_engine_get_state (engine); + cairo_save (cr); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + color_shade (bg_color, 0.7, &darker); + color_shade (bg_color, 1.3, &lighter); + + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); + cairo_set_line_width (cr, 1); + + if (y0 == y1) + { + /* Horizontal line */ + for (i = 0; i < thickness_dark; i++) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x0, y0, x1 - i - 1, y0); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x1 - i, y0, x1, y0 + 1); + cairo_stroke (cr); + y0++; + } + + for (i = 0; i < thickness_light; i++) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x0, y0, x0 + thickness_light - i, y0); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x0 + thickness_light - i, y0, x1, y0); + cairo_stroke (cr); + y0++; + } + } + else if (x0 == x1) + { + /* Vertical line */ + for (i = 0; i < thickness_dark; i++) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x0, y0, x0, y1 - i - 1); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x0, y1 - i, x0, y1); + cairo_stroke (cr); + x0++; + } + + for (i = 0; i < thickness_light; i++) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x0, y0, x0, y0 + thickness_light - i - 1); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x0, y0 + thickness_light - i, x0, y1); + cairo_stroke (cr); + x0++; + } + } + else + { + /* Arbitrary line */ + /* FIXME: implement thickness, etc */ + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x0, y0, x1, y1); + cairo_stroke (cr); + } + + cairo_restore (cr); +} + static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, cairo_t *cr, diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 6a79edc7ce..12270a165f 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -49,6 +49,12 @@ struct GtkThemingEngineClass { GObjectClass parent_class; + void (* render_line) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); void (* render_background) (GtkThemingEngine *engine, cairo_t *cr, gdouble x, From 86727adc4d09c69f954e56a1beb437179d168ee9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:18:24 +0100 Subject: [PATCH 127/634] GtkStyleContext: Add gtk_render_line(). --- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 583a19bed1..41fb1b8f86 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -755,5 +755,26 @@ gtk_render_layout (GtkStyleContext *context, engine_class->render_layout (priv->theming_engine, cr, x, y, layout); } +void +gtk_render_line (GtkStyleContext *context, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_line (priv->theming_engine, cr, x0, y0, x1, y1); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 0bf5e1cca8..6a62dae039 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -150,6 +150,12 @@ void gtk_render_layout (GtkStyleContext *context, gdouble x, gdouble y, PangoLayout *layout); +void gtk_render_line (GtkStyleContext *context, + cairo_t *cr, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); G_END_DECLS From 2ebdf80adcad73d4e784834c6908a7e40cc586c0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:20:21 +0100 Subject: [PATCH 128/634] GtkThemingEngine: Add vmethod to render sliders. --- gtk/gtkthemingengine.c | 37 +++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 7 +++++++ 2 files changed, 44 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 9d175dba64..f824dfe54a 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -96,6 +96,13 @@ static void gtk_theming_engine_render_line (GtkThemingEngine *engine, gdouble y0, gdouble x1, gdouble y1); +static void gtk_theming_engine_render_slider (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -136,6 +143,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_focus = gtk_theming_engine_render_focus; klass->render_layout = gtk_theming_engine_render_layout; klass->render_line = gtk_theming_engine_render_line; + klass->render_slider = gtk_theming_engine_render_slider; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -1074,5 +1082,34 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, gdk_color_free (fg_color); } +static void +gtk_theming_engine_render_slider (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + const GtkWidgetPath *path; + + path = gtk_theming_engine_get_path (engine); + + gtk_theming_engine_render_background (engine, cr, x, y, width, height); + gtk_theming_engine_render_frame (engine, cr, x, y, width, height); + + if (gtk_widget_path_has_parent (path, GTK_TYPE_SCALE)) + { + if (orientation == GTK_ORIENTATION_VERTICAL) + gtk_theming_engine_render_line (engine, cr, + x + 2, y + height / 2 - 1, + x + width - 4, y + height / 2 - 1); + else + gtk_theming_engine_render_line (engine, cr, + x + width / 2 - 1, y + 4, + x + width / 2 - 1, y + height - 4); + } +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 12270a165f..dd02bc5557 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -102,6 +102,13 @@ struct GtkThemingEngineClass gdouble x, gdouble y, PangoLayout *layout); + void (* render_slider) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 6a1b54f8bfc30bcc77d8bf5cb46bf4dec819dc8d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:21:34 +0100 Subject: [PATCH 129/634] GtkStyleContext: Add gtk_render_slider(). --- gtk/gtkstylecontext.c | 22 ++++++++++++++++++++++ gtk/gtkstylecontext.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 41fb1b8f86..cdf6c4b73b 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -776,5 +776,27 @@ gtk_render_line (GtkStyleContext *context, engine_class->render_line (priv->theming_engine, cr, x0, y0, x1, y1); } +void +gtk_render_slider (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 6a62dae039..710f689c4d 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -156,6 +156,13 @@ void gtk_render_line (GtkStyleContext *context, gdouble y0, gdouble x1, gdouble y1); +void gtk_render_slider (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); G_END_DECLS From af1edc3d8809f35092c25eedfdb81af7c7a45e2a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:23:13 +0100 Subject: [PATCH 130/634] GtkThemingEngine: Add vmethod to render frames with a gap. --- gtk/gtkthemingengine.c | 145 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 9 +++ 2 files changed, 154 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f824dfe54a..b95d6de6b6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -103,6 +103,15 @@ static void gtk_theming_engine_render_slider (GtkThemingEngine *engine, gdouble width, gdouble height, GtkOrientation orientation); +static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side, + gdouble xy0_gap, + gdouble xy1_gap); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -144,6 +153,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_layout = gtk_theming_engine_render_layout; klass->render_line = gtk_theming_engine_render_line; klass->render_slider = gtk_theming_engine_render_slider; + klass->render_frame_gap = gtk_theming_engine_render_frame_gap; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -709,6 +719,51 @@ add_path_rounded_rectangle (cairo_t *cr, } } +static void +add_path_gap_side (cairo_t *cr, + GtkPositionType gap_side, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + gdouble xy0_gap, + gdouble xy1_gap) +{ + if (gap_side == GTK_POS_TOP) + { + cairo_move_to (cr, x, y); + cairo_line_to (cr, x + xy0_gap, y); + + cairo_move_to (cr, x + xy1_gap, y); + cairo_line_to (cr, x + width, y); + } + else if (gap_side == GTK_POS_BOTTOM) + { + cairo_move_to (cr, x, y + height); + cairo_line_to (cr, x + xy0_gap, y + height); + + cairo_move_to (cr, x + xy1_gap, y + height); + cairo_line_to (cr, x + width, y + height); + } + else if (gap_side == GTK_POS_LEFT) + { + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + xy0_gap); + + cairo_move_to (cr, x, y + xy1_gap); + cairo_line_to (cr, x, y + height); + } + else + { + cairo_move_to (cr, x + width, y); + cairo_line_to (cr, x + width, y + xy0_gap); + + cairo_move_to (cr, x + width, y + xy1_gap); + cairo_line_to (cr, x + width, y + height); + } +} + static void color_shade (const GdkColor *color, gdouble factor, @@ -1111,5 +1166,95 @@ gtk_theming_engine_render_slider (GtkThemingEngine *engine, } } +static void +gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side, + gdouble xy0_gap, + gdouble xy1_gap) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *bg_color; + GdkColor lighter, darker; + guint sides; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + cairo_set_line_width (cr, 1); + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + color_shade (bg_color, 0.7, &darker); + color_shade (bg_color, 1.3, &lighter); + + if (gap_side == GTK_POS_RIGHT) + sides = SIDE_BOTTOM; + else if (gap_side == GTK_POS_BOTTOM) + sides = SIDE_RIGHT; + else + sides = SIDE_BOTTOM | SIDE_RIGHT; + + if (gap_side == GTK_POS_RIGHT || + gap_side == GTK_POS_BOTTOM) + add_path_gap_side (cr, gap_side, 0, + x, y, width, height, + xy0_gap, xy1_gap); + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width, height); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); + + if (gap_side == GTK_POS_RIGHT || + gap_side == GTK_POS_BOTTOM) + add_path_gap_side (cr, gap_side, 0, + x, y, width, height, + xy0_gap, xy1_gap); + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width - 1, height - 1); + + gdk_cairo_set_source_color (cr, &darker); + cairo_stroke (cr); + + if (gap_side == GTK_POS_LEFT) + sides = SIDE_TOP; + else if (gap_side == GTK_POS_TOP) + sides = SIDE_LEFT; + else + sides = SIDE_TOP | SIDE_LEFT; + + if (gap_side == GTK_POS_TOP || + gap_side == GTK_POS_LEFT) + add_path_gap_side (cr, gap_side, 0, + x, y, width, height, + xy0_gap, xy1_gap); + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width, height); + + gdk_cairo_set_source_color (cr, &lighter); + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_color_free (bg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index dd02bc5557..d085637eab 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -67,6 +67,15 @@ struct GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_frame_gap) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side, + gdouble xy0_gap, + gdouble xy1_gap); void (* render_check) (GtkThemingEngine *engine, cairo_t *cr, gdouble x, From 88492a50d6dbc6702ebbdbf9c888a21dbbc35f60 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:24:22 +0100 Subject: [PATCH 131/634] GtkStyleContext: Add gtk_render_frame_gap(). --- gtk/gtkstylecontext.c | 26 ++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cdf6c4b73b..5969f8dad3 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -798,5 +798,31 @@ gtk_render_slider (GtkStyleContext *context, engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation); } +void +gtk_render_frame_gap (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side, + gdouble xy0_gap, + gdouble xy1_gap) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_frame_gap (priv->theming_engine, cr, + x, y, width, height, gap_side, + xy0_gap, xy1_gap); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 710f689c4d..bea4dc72f6 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -163,6 +163,15 @@ void gtk_render_slider (GtkStyleContext *context, gdouble width, gdouble height, GtkOrientation orientation); +void gtk_render_frame_gap (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side, + gdouble xy0_gap, + gdouble xy1_gap); G_END_DECLS From aa1d492fe96dbe165fb5f105e57323bdc246f240 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:25:33 +0100 Subject: [PATCH 132/634] GtkThemingEngine: Add vmethod to render an extension. --- gtk/gtkthemingengine.c | 88 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 7 ++++ 2 files changed, 95 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b95d6de6b6..6a2bd38a0e 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -112,6 +112,13 @@ static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, GtkPositionType gap_side, gdouble xy0_gap, gdouble xy1_gap); +static void gtk_theming_engine_render_extension (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -154,6 +161,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_line = gtk_theming_engine_render_line; klass->render_slider = gtk_theming_engine_render_slider; klass->render_frame_gap = gtk_theming_engine_render_frame_gap; + klass->render_extension = gtk_theming_engine_render_extension; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -1256,5 +1264,85 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, gdk_color_free (bg_color); } +static void +gtk_theming_engine_render_extension (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *bg_color; + GdkColor lighter, darker; + guint sides; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_ACTIVE) + state = GTK_STATE_ACTIVE; + else if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + cairo_set_line_width (cr, 1); + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + color_shade (bg_color, 0.7, &darker); + color_shade (bg_color, 1.3, &lighter); + + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, + x, y, width, height); + cairo_close_path (cr); + + gdk_cairo_set_source_color (cr, bg_color); + cairo_fill (cr); + + if (gap_side == GTK_POS_RIGHT) + sides = SIDE_BOTTOM; + else if (gap_side == GTK_POS_BOTTOM) + sides = SIDE_RIGHT; + else + sides = SIDE_BOTTOM | SIDE_RIGHT; + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width, height); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width - 1, height - 1); + + gdk_cairo_set_source_color (cr, &darker); + cairo_stroke (cr); + + if (gap_side == GTK_POS_LEFT) + sides = SIDE_TOP; + else if (gap_side == GTK_POS_TOP) + sides = SIDE_LEFT; + else + sides = SIDE_TOP | SIDE_LEFT; + + add_path_rounded_rectangle (cr, 0, sides, + x, y, width, height); + + gdk_cairo_set_source_color (cr, &lighter); + cairo_stroke (cr); + + cairo_restore (cr); + + gdk_color_free (bg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index d085637eab..31e7635eca 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -76,6 +76,13 @@ struct GtkThemingEngineClass GtkPositionType gap_side, gdouble xy0_gap, gdouble xy1_gap); + void (* render_extension) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side); void (* render_check) (GtkThemingEngine *engine, cairo_t *cr, gdouble x, From 160821042cabbcce4f9e279c7c7cc2de7a759744 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:26:27 +0100 Subject: [PATCH 133/634] GtkStyleContext: Add gtk_render_extension(). --- gtk/gtkstylecontext.c | 22 ++++++++++++++++++++++ gtk/gtkstylecontext.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 5969f8dad3..c1fa38cdd8 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -824,5 +824,27 @@ gtk_render_frame_gap (GtkStyleContext *context, xy0_gap, xy1_gap); } +void +gtk_render_extension (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index bea4dc72f6..d0f380489c 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -172,6 +172,13 @@ void gtk_render_frame_gap (GtkStyleContext *context, GtkPositionType gap_side, gdouble xy0_gap, gdouble xy1_gap); +void gtk_render_extension (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkPositionType gap_side); G_END_DECLS From 9e5d9ff28d9ac3c546c9a3a625ad91d057a6f6ba Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:27:52 +0100 Subject: [PATCH 134/634] GtkThemingEngine: Add vmethod to render a handle area. --- gtk/gtkthemingengine.c | 83 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 7 ++++ 2 files changed, 90 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 6a2bd38a0e..3a019dc995 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -119,6 +119,13 @@ static void gtk_theming_engine_render_extension (GtkThemingEngine *engine, gdouble width, gdouble height, GtkPositionType gap_side); +static void gtk_theming_engine_render_handle (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -162,6 +169,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_slider = gtk_theming_engine_render_slider; klass->render_frame_gap = gtk_theming_engine_render_frame_gap; klass->render_extension = gtk_theming_engine_render_extension; + klass->render_handle = gtk_theming_engine_render_handle; g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -1344,5 +1352,80 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, gdk_color_free (bg_color); } +static void +paint_point (cairo_t *cr, + const GdkColor *lighter, + const GdkColor *darker, + gdouble x, + gdouble y) +{ + cairo_move_to (cr, x - 0.5, y + 1); + cairo_line_to (cr, x - 0.5, y - 0.5); + cairo_line_to (cr, x + 1, y - 0.5); + gdk_cairo_set_source_color (cr, lighter); + cairo_stroke (cr); + + cairo_move_to (cr, x + 1.5, y); + cairo_line_to (cr, x + 1.5, y + 1.5); + cairo_line_to (cr, x, y + 1.5); + gdk_cairo_set_source_color (cr, darker); + cairo_stroke (cr); +} + +static void +gtk_theming_engine_render_handle (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + GtkStateFlags flags; + GtkStateType state; + GdkColor *bg_color; + GdkColor lighter, darker; + gint xx, yy; + + cairo_save (cr); + flags = gtk_theming_engine_get_state (engine); + + if (flags & GTK_STATE_FLAG_ACTIVE) + state = GTK_STATE_ACTIVE; + else if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else + state = GTK_STATE_NORMAL; + + cairo_set_line_width (cr, 1); + + gtk_theming_engine_get (engine, state, + "background-color", &bg_color, + NULL); + color_shade (bg_color, 0.7, &darker); + color_shade (bg_color, 1.3, &lighter); + + add_path_rounded_rectangle (cr, 0, + SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, + x, y, width, height); + cairo_close_path (cr); + + gdk_cairo_set_source_color (cr, bg_color); + cairo_fill (cr); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5) + paint_point (cr, &lighter, &darker, xx, y + height / 2 - 1); + else + for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5) + paint_point (cr, &lighter, &darker, x + width / 2, yy); + + cairo_restore (cr); + + gdk_color_free (bg_color); +} + #define __GTK_THEMING_ENGINE_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 31e7635eca..6ff8214098 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -125,6 +125,13 @@ struct GtkThemingEngineClass gdouble width, gdouble height, GtkOrientation orientation); + void (* render_handle) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From f8c74ae54bb59e1dbf94718432e8227931a8f6c4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:28:44 +0100 Subject: [PATCH 135/634] GtkStyleContext: Add gtk_render_handle(). --- gtk/gtkstylecontext.c | 22 ++++++++++++++++++++++ gtk/gtkstylecontext.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c1fa38cdd8..9ec30d07fd 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -846,5 +846,27 @@ gtk_render_extension (GtkStyleContext *context, engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side); } +void +gtk_render_handle (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_handle (priv->theming_engine, cr, x, y, width, height, orientation); +} + #define __GTK_STYLE_CONTEXT_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index d0f380489c..2c2485b406 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -179,6 +179,13 @@ void gtk_render_extension (GtkStyleContext *context, gdouble width, gdouble height, GtkPositionType gap_side); +void gtk_render_handle (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkOrientation orientation); G_END_DECLS From f984c39e93738dc49ae5b7fcd82453c47ef47fca Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:29:55 +0100 Subject: [PATCH 136/634] GtkStyleContext: Fix typo. --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 9ec30d07fd..566538f0b7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -390,7 +390,7 @@ gtk_style_context_set_class (GtkStyleContext *context, { GQuark link_quark; - link_quark = GUINT_TO_POINTER (link->data); + link_quark = GPOINTER_TO_UINT (link->data); if (link_quark == class_quark) return; From bdadcb568cc6e798c056492a437974a3a008a359 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 27 Mar 2010 21:30:30 +0100 Subject: [PATCH 137/634] GtkStyleContext: Fix compiler warning. --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 566538f0b7..cb6bab6472 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -81,7 +81,7 @@ gtk_style_context_init (GtkStyleContext *style_context) priv = GTK_STYLE_CONTEXT_GET_PRIVATE (style_context); priv->store = gtk_style_set_new (); - priv->theming_engine = gtk_theming_engine_load (NULL); + priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL); } static GtkStyleProviderData * From fdcda4b356ea6d90482648dd45630de606f1411c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 19:46:57 +0200 Subject: [PATCH 138/634] GtkStyleContext: allow late set_path() calls. Now the properties will only be regenerated whenever there's a GtkWidgetPath to query about. --- gtk/gtkstylecontext.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cb6bab6472..9bf51e1369 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -196,7 +196,8 @@ gtk_style_context_add_provider (GtkStyleContext *context, if (!added) priv->providers = g_list_append (priv->providers, new_data); - rebuild_properties (context); + if (priv->widget_path) + rebuild_properties (context); } void @@ -233,7 +234,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context, list = list->next; } - if (removed) + if (removed && priv->widget_path) rebuild_properties (context); } @@ -358,7 +359,10 @@ gtk_style_context_set_path (GtkStyleContext *context, } if (path) - priv->widget_path = gtk_widget_path_copy (path); + { + priv->widget_path = gtk_widget_path_copy (path); + rebuild_properties (context); + } } G_CONST_RETURN GtkWidgetPath * From 7647deb4170480e1de3ea6c667440d6229dc7d2f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 19:52:58 +0200 Subject: [PATCH 139/634] GtkStyleSet: Make property registration take const GValues. --- gtk/gtkstyleset.c | 6 +++--- gtk/gtkstyleset.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index c26eb3cdbd..f91d3321ab 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -175,9 +175,9 @@ property_node_lookup (GQuark quark) /* Property registration functions */ void -gtk_style_set_register_property (const gchar *property_name, - GType type, - GValue *default_value) +gtk_style_set_register_property (const gchar *property_name, + GType type, + const GValue *default_value) { PropertyNode *node, new = { 0 }; GQuark quark; diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index ff1b859a60..642dd02c31 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -52,9 +52,9 @@ struct GtkStyleSetClass GType gtk_style_set_get_type (void) G_GNUC_CONST; /* Functions to register style properties */ -void gtk_style_set_register_property (const gchar *property_name, - GType type, - GValue *default_value); +void gtk_style_set_register_property (const gchar *property_name, + GType type, + const GValue *default_value); void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *default_value); From 9971f386b0b027c66ab86af6471a9fd694525f58 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 20:26:49 +0200 Subject: [PATCH 140/634] GtkStyleSet: Add method to lookup property default settings. --- gtk/gtkstyleset.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleset.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index f91d3321ab..19e1a97f65 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -218,6 +218,56 @@ gtk_style_set_register_property (const gchar *property_name, g_array_insert_val (properties, i, new); } +gboolean +gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GValue *default_value) +{ + PropertyNode *node; + GtkStyleSetClass *klass; + GQuark quark; + GType t; + gint i; + + g_return_val_if_fail (property_name != NULL, FALSE); + + klass = g_type_class_ref (GTK_TYPE_STYLE_SET); + quark = g_quark_try_string (property_name); + + if (quark == 0) + { + g_type_class_unref (klass); + return FALSE; + } + + for (i = 0; i < properties->len; i++) + { + node = &g_array_index (properties, PropertyNode, i); + + if (node->property_quark == quark) + { + if (type) + *type = node->property_type; + + if (default_value) + { + g_value_init (default_value, G_VALUE_TYPE (&node->default_value)); + g_value_copy (&node->default_value, default_value); + } + + g_type_class_unref (klass); + + return TRUE; + } + else if (node->property_quark > quark) + break; + } + + g_type_class_unref (klass); + + return FALSE; +} + void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *initial_value) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 642dd02c31..16fda3ea78 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -55,6 +55,9 @@ GType gtk_style_set_get_type (void) G_GNUC_CONST; void gtk_style_set_register_property (const gchar *property_name, GType type, const GValue *default_value); +gboolean gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GValue *default_value); void gtk_style_set_register_property_color (const gchar *property_name, GdkColor *default_value); From 7c5c4d86aefd6e39d7f23eaf4e107467300b9295 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 20:30:24 +0200 Subject: [PATCH 141/634] Add GtkWidgetPath parameter to gtk_style_provider_get_style(). --- gtk/gtkstylecontext.c | 11 ++++++++--- gtk/gtkstyleprovider.c | 5 +++-- gtk/gtkstyleprovider.h | 7 +++++-- gtk/gtkstyleset.c | 3 ++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 9bf51e1369..f8f6c08040 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -136,9 +136,14 @@ rebuild_properties (GtkStyleContext *context) data = list->data; list = list->next; - provider_style = gtk_style_provider_get_style (data->provider); - gtk_style_set_merge (priv->store, provider_style, TRUE); - g_object_unref (provider_style); + provider_style = gtk_style_provider_get_style (data->provider, + priv->widget_path); + + if (provider_style) + { + gtk_style_set_merge (priv->store, provider_style, TRUE); + g_object_unref (provider_style); + } } } diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 18cca7b817..606f4a130e 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -48,7 +48,8 @@ gtk_style_provider_iface_init (gpointer g_iface) } GtkStyleSet * -gtk_style_provider_get_style (GtkStyleProvider *provider) +gtk_style_provider_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) { GtkStyleProviderIface *iface; @@ -59,7 +60,7 @@ gtk_style_provider_get_style (GtkStyleProvider *provider) if (!iface->get_style) return NULL; - return iface->get_style (provider); + return iface->get_style (provider, path); } #define __GTK_STYLE_PROVIDER_C__ diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index ec5ee99937..6e12bb3c66 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -21,6 +21,7 @@ #define __GTK_STYLE_PROVIDER_H__ #include +#include "gtkwidgetpath.h" #include "gtkstyleset.h" #include "gtkenums.h" @@ -45,12 +46,14 @@ struct GtkStyleProviderIface { GTypeInterface g_iface; - GtkStyleSet * (* get_style) (GtkStyleProvider *provider); + GtkStyleSet * (* get_style) (GtkStyleProvider *provider, + GtkWidgetPath *path); }; GType gtk_style_provider_get_type (void) G_GNUC_CONST; -GtkStyleSet *gtk_style_provider_get_style (GtkStyleProvider *provider); +GtkStyleSet *gtk_style_provider_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path); G_END_DECLS diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 19e1a97f65..73e33be6c9 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -134,7 +134,8 @@ gtk_style_set_finalize (GObject *object) } GtkStyleSet * -gtk_style_set_get_style (GtkStyleProvider *provider) +gtk_style_set_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) { /* Return style set itself */ return g_object_ref (provider); From bccad0c65c63db5e516e1f9fd317a61e61b31b83 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 23:03:25 +0200 Subject: [PATCH 142/634] Added GtkCssProvider. GtkCssProvider is a GtkStyleProvider implementation which is able to read CSS-like input to style widgets. At the moment, only the basic parser features are available. --- gtk/Makefile.am | 2 + gtk/gtk.h | 1 + gtk/gtkcssprovider.c | 835 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkcssprovider.h | 61 ++++ 4 files changed, 899 insertions(+) create mode 100644 gtk/gtkcssprovider.c create mode 100644 gtk/gtkcssprovider.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 199dba1ebb..918e6329cc 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -193,6 +193,7 @@ gtk_public_h_sources = \ gtkcombobox.h \ gtkcomboboxtext.h \ gtkcontainer.h \ + gtkcssprovider.h \ gtkdebug.h \ gtkdialog.h \ gtkdnd.h \ @@ -480,6 +481,7 @@ gtk_base_c_sources = \ gtkcombobox.c \ gtkcomboboxtext.c \ gtkcontainer.c \ + gtkcssprovider.c \ gtkdialog.c \ gtkdrawingarea.c \ gtkeditable.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 163f8d4e91..02de38d9d1 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -77,6 +77,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c new file mode 100644 index 0000000000..eb10b2ea75 --- /dev/null +++ b/gtk/gtkcssprovider.c @@ -0,0 +1,835 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 +#include +#include +#include + +#include "gtkcssprovider.h" + +#include "gtkalias.h" + +typedef struct GtkCssProviderPrivate GtkCssProviderPrivate; +typedef struct SelectorElement SelectorElement; +typedef struct SelectorPath SelectorPath; +typedef struct SelectorStyleInfo SelectorStyleInfo; +typedef enum SelectorElementType SelectorElementType; +typedef enum ParserScope ParserScope; + +enum SelectorElementType { + SELECTOR_TYPE_NAME, + SELECTOR_NAME, + SELECTOR_GTYPE +}; + +struct SelectorElement +{ + SelectorElementType elem_type; + GtkStateType state; + + union + { + GQuark name; + GType type; + }; +}; + +struct SelectorPath +{ + GSList *elements; + guint ref_count; +}; + +struct SelectorStyleInfo +{ + SelectorPath *path; + GHashTable *style; +}; + +struct GtkCssProviderPrivate +{ + GScanner *scanner; + GPtrArray *selectors_info; + + /* Current parser state */ + GSList *state; + GSList *cur_selectors; + GHashTable *cur_properties; +}; + +enum ParserScope { + SCOPE_SELECTOR, + SCOPE_DECLARATION, + SCOPE_VALUE +}; + +#define GTK_CSS_PROVIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProviderPrivate)) + +static void gtk_css_provider_finalize (GObject *object); +static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); + +static void css_provider_apply_scope (GtkCssProvider *css_provider, + ParserScope scope); + +G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, + gtk_css_style_provider_iface_init)); + +static void +gtk_css_provider_class_init (GtkCssProviderClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gtk_css_provider_finalize; + + g_type_class_add_private (object_class, sizeof (GtkCssProviderPrivate)); +} + +static SelectorPath * +selector_path_new (void) +{ + SelectorPath *path; + + path = g_slice_new0 (SelectorPath); + path->ref_count = 1; + + return path; +} + +static SelectorPath * +selector_path_ref (SelectorPath *path) +{ + path->ref_count++; + return path; +} + +static void +selector_path_unref (SelectorPath *path) +{ + path->ref_count--; + + if (path->ref_count > 0) + return; + + while (path->elements) + { + g_slice_free (SelectorPath, path->elements->data); + path->elements = g_slist_delete_link (path->elements, path->elements); + } + + g_slice_free (SelectorPath, path); +} + +static void +selector_path_prepend_type (SelectorPath *path, + const gchar *type_name) +{ + SelectorElement *elem; + GType type; + + elem = g_slice_new (SelectorElement); + type = g_type_from_name (type_name); + + if (type == G_TYPE_INVALID) + { + elem->elem_type = SELECTOR_TYPE_NAME; + elem->name = g_quark_from_string (type_name); + } + else + { + elem->elem_type = SELECTOR_GTYPE; + elem->type = type; + } + + path->elements = g_slist_prepend (path->elements, elem); +} + +static SelectorStyleInfo * +selector_style_info_new (SelectorPath *path) +{ + SelectorStyleInfo *info; + + info = g_slice_new0 (SelectorStyleInfo); + info->path = selector_path_ref (path); + + return info; +} + +static void +selector_style_info_free (SelectorStyleInfo *info) +{ + if (info->style) + g_hash_table_unref (info->style); + + if (info->path) + selector_path_unref (info->path); +} + +static void +selector_style_info_set_style (SelectorStyleInfo *info, + GHashTable *style) +{ + if (info->style) + g_hash_table_unref (info->style); + + if (style) + info->style = g_hash_table_ref (style); + else + info->style = NULL; +} + +static void +gtk_css_provider_init (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + GScanner *scanner; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv->selectors_info = g_ptr_array_new_with_free_func ((GDestroyNotify) selector_style_info_free); + + scanner = g_scanner_new (NULL); + /* scanner->input_name = path; */ + + priv->scanner = scanner; + css_provider_apply_scope (css_provider, SCOPE_SELECTOR); +} + +typedef struct ComparePathData ComparePathData; + +struct ComparePathData +{ + guint64 score; + SelectorPath *path; + GSList *iter; +}; + +static gboolean +compare_path_foreach (GType type, + const gchar *name, + gpointer user_data) +{ + ComparePathData *data; + SelectorElement *elem; + + data = user_data; + elem = data->iter->data; + + if (elem->elem_type == SELECTOR_TYPE_NAME) + { + const gchar *type_name; + GType resolved_type; + + /* Resolve the type name */ + type_name = g_quark_to_string (elem->name); + resolved_type = g_type_from_name (type_name); + + if (resolved_type == G_TYPE_INVALID) + { + /* Type couldn't be resolved, so the selector + * clearly doesn't affect the given widget path + */ + data->score = 0; + return TRUE; + } + + elem->elem_type = SELECTOR_GTYPE; + elem->type = resolved_type; + } + + if (elem->elem_type == SELECTOR_GTYPE) + { + if (!g_type_is_a (type, elem->type)) + { + /* Selector definitely doesn't match */ + data->score = 0; + return TRUE; + } + else if (type == elem->type) + data->score |= 0xF; + else + { + GType parent = type; + guint8 score = 0xE; + + while ((parent = g_type_parent (parent)) != G_TYPE_INVALID) + { + if (parent == elem->type) + break; + + score--; + + if (score == 1) + { + g_warning ("Hierarchy is higher than expected."); + break; + } + } + + data->score |= score; + } + } + + data->iter = data->iter->next; + + if (data->iter) + { + data->score <<= 4; + return FALSE; + } + + return TRUE; +} + +static guint64 +compare_selector (GtkWidgetPath *path, + SelectorPath *selector) +{ + ComparePathData data; + + data.score = 0; + data.path = selector; + data.iter = selector->elements; + + gtk_widget_path_foreach (path, + compare_path_foreach, + &data); + + if (data.iter) + { + /* There is remaining data to compare, + * so don't take it as a match. + */ + data.score = 0; + } + + return data.score; +} + +typedef struct StylePriorityInfo StylePriorityInfo; + +struct StylePriorityInfo +{ + guint64 score; + GHashTable *style; +}; + +static GtkStyleSet * +gtk_style_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) +{ + GtkCssProviderPrivate *priv; + GtkStyleSet *set; + GArray *priority_info; + guint i, j; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (provider); + set = gtk_style_set_new (); + priority_info = g_array_new (FALSE, FALSE, sizeof (StylePriorityInfo)); + + for (i = 0; i < priv->selectors_info->len; i++) + { + SelectorStyleInfo *info; + StylePriorityInfo new; + gboolean added = FALSE; + guint64 score; + + info = g_ptr_array_index (priv->selectors_info, i); + score = compare_selector (path, info->path); + + if (score <= 0) + continue; + + new.score = score; + new.style = info->style; + + for (j = 0; j < priority_info->len; j++) + { + StylePriorityInfo *cur; + + cur = &g_array_index (priority_info, StylePriorityInfo, j); + + if (cur->score > new.score) + { + g_array_insert_val (priority_info, j, new); + added = TRUE; + break; + } + } + + if (!added) + g_array_append_val (priority_info, new); + } + + for (i = 0; i < priority_info->len; i++) + { + StylePriorityInfo *info; + GHashTableIter iter; + gpointer key, value; + + info = &g_array_index (priority_info, StylePriorityInfo, i); + g_hash_table_iter_init (&iter, info->style); + + while (g_hash_table_iter_next (&iter, &key, &value)) + gtk_style_set_set_property (set, key, GTK_STATE_NORMAL, value); + } + + g_array_free (priority_info, TRUE); + + return set; +} + +static void +gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface) +{ + iface->get_style = gtk_style_get_style; +} + +static void +gtk_css_provider_finalize (GObject *object) +{ + GtkCssProviderPrivate *priv; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (object); + g_scanner_destroy (priv->scanner); + + g_ptr_array_free (priv->selectors_info, TRUE); + + g_slist_foreach (priv->cur_selectors, (GFunc) selector_path_unref, NULL); + g_slist_free (priv->cur_selectors); + + g_hash_table_unref (priv->cur_properties); + + G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object); +} + +GtkCssProvider * +gtk_css_provider_new (void) +{ + return g_object_new (GTK_TYPE_CSS_PROVIDER, NULL); +} + +static void +property_value_free (GValue *value) +{ + if (G_IS_VALUE (value)) + g_value_unset (value); + + g_slice_free (GValue, value); +} + +static void +css_provider_apply_scope (GtkCssProvider *css_provider, + ParserScope scope) +{ + GtkCssProviderPrivate *priv; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + g_scanner_set_scope (priv->scanner, scope); + + if (scope == SCOPE_VALUE) + { + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z; + } + else + { + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; + } + + priv->scanner->config->scan_float = FALSE; +} + +static void +css_provider_push_scope (GtkCssProvider *css_provider, + ParserScope scope) +{ + GtkCssProviderPrivate *priv; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv->state = g_slist_prepend (priv->state, GUINT_TO_POINTER (scope)); + + css_provider_apply_scope (css_provider, scope); +} + +static ParserScope +css_provider_pop_scope (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + ParserScope scope = SCOPE_SELECTOR; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + if (!priv->state) + { + g_warning ("Push/pop calls to parser scope aren't paired"); + css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + return SCOPE_SELECTOR; + } + + priv->state = g_slist_delete_link (priv->state, priv->state); + + /* Fetch new scope */ + if (priv->state) + scope = GPOINTER_TO_INT (priv->state->data); + + css_provider_apply_scope (css_provider, scope); + + return scope; +} + +static void +css_provider_reset_parser (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + g_slist_free (priv->state); + priv->state = NULL; + + css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + + g_slist_foreach (priv->cur_selectors, (GFunc) selector_path_unref, NULL); + g_slist_free (priv->cur_selectors); + priv->cur_selectors = NULL; + + if (priv->cur_properties) + g_hash_table_unref (priv->cur_properties); + + priv->cur_properties = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) property_value_free); +} + +static void +css_provider_commit (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + GSList *l; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + l = priv->cur_selectors; + + while (l) + { + SelectorPath *path = l->data; + SelectorStyleInfo *info; + + info = selector_style_info_new (path); + selector_style_info_set_style (info, priv->cur_properties); + + g_ptr_array_add (priv->selectors_info, info); + l = l->next; + } +} + +static GTokenType +parse_selector (GScanner *scanner, + SelectorPath **selector_out) +{ + SelectorPath *path; + + *selector_out = NULL; + + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + path = selector_path_new (); + + if (g_ascii_isupper (scanner->value.v_identifier[0])) + { + while (scanner->token == G_TOKEN_IDENTIFIER && + g_ascii_isupper (scanner->value.v_identifier[0])) + { + selector_path_prepend_type (path, scanner->value.v_identifier); + g_scanner_get_next_token (scanner); + } + + if (scanner->token == '.') + { + /* style class scanning */ + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + { + selector_path_unref (path); + return G_TOKEN_IDENTIFIER; + } + + g_print ("Style class: %s\n", scanner->value.v_identifier); + g_scanner_get_next_token (scanner); + } + } + else + { + selector_path_unref (path); + return G_TOKEN_IDENTIFIER; + } + + *selector_out = path; + + return G_TOKEN_NONE; +} + +static gboolean +parse_value (GType type, + const gchar *value_str, + GValue *value) +{ + g_value_init (value, type); + + if (type == GDK_TYPE_COLOR) + { + GdkColor color; + + if (gdk_color_parse (value_str, &color) == FALSE) + return FALSE; + + g_value_set_boxed (value, &color); + return TRUE; + } + else if (type == PANGO_TYPE_FONT_DESCRIPTION) + { + PangoFontDescription *font_desc; + + font_desc = pango_font_description_from_string (value_str); + g_value_take_boxed (value, font_desc); + + return TRUE; + } + else if (type == G_TYPE_INT) + { + g_value_set_int (value, atoi (value_str)); + return TRUE; + } + else if (type == G_TYPE_DOUBLE) + { + g_value_set_double (value, g_ascii_strtod (value_str, NULL)); + return TRUE; + } + else + { + g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); + } + + return FALSE; +} + +static GTokenType +parse_rule (GtkCssProvider *css_provider, + GScanner *scanner) +{ + GtkCssProviderPrivate *priv; + GTokenType expected_token; + SelectorPath *selector; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + css_provider_push_scope (css_provider, SCOPE_SELECTOR); + expected_token = parse_selector (scanner, &selector); + + if (expected_token != G_TOKEN_NONE) + return expected_token; + + priv->cur_selectors = g_slist_prepend (priv->cur_selectors, selector); + + while (scanner->token == ',') + { + g_scanner_get_next_token (scanner); + + expected_token = parse_selector (scanner, &selector); + + if (expected_token != G_TOKEN_NONE) + return expected_token; + + priv->cur_selectors = g_slist_prepend (priv->cur_selectors, selector); + } + + css_provider_pop_scope (css_provider); + + if (scanner->token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + /* Declarations parsing */ + css_provider_push_scope (css_provider, SCOPE_DECLARATION); + g_scanner_get_next_token (scanner); + + while (scanner->token == G_TOKEN_IDENTIFIER) + { + const gchar *value_str = NULL; + GValue value = { 0 }; + GType prop_type; + gchar *prop; + + prop = g_strdup (scanner->value.v_identifier); + g_scanner_get_next_token (scanner); + + if (scanner->token != ':') + { + g_free (prop); + return ':'; + } + + css_provider_push_scope (css_provider, SCOPE_VALUE); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + { + g_free (prop); + return G_TOKEN_IDENTIFIER; + } + + value_str = g_strstrip (scanner->value.v_identifier); + + if (gtk_style_set_lookup_property (prop, &prop_type, NULL) && + parse_value (prop_type, value_str, &value)) + { + GValue *val; + + val = g_slice_new0 (GValue); + g_value_init (val, prop_type); + g_value_copy (&value, val); + + g_hash_table_insert (priv->cur_properties, prop, val); + } + else + g_free (prop); + + css_provider_pop_scope (css_provider); + g_scanner_get_next_token (scanner); + + if (scanner->token != ';') + return ';'; + + g_scanner_get_next_token (scanner); + } + + if (scanner->token != G_TOKEN_RIGHT_CURLY) + return G_TOKEN_RIGHT_CURLY; + + css_provider_pop_scope (css_provider); + + return G_TOKEN_NONE; +} + +static gboolean +parse_stylesheet (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + g_scanner_get_next_token (priv->scanner); + + while (!g_scanner_eof (priv->scanner)) + { + GTokenType expected_token; + + css_provider_reset_parser (css_provider); + expected_token = parse_rule (css_provider, priv->scanner); + + if (expected_token != G_TOKEN_NONE) + { + g_scanner_unexp_token (priv->scanner, expected_token, + NULL, NULL, NULL, + "Error parsing style resource", FALSE); + + while (!g_scanner_eof (priv->scanner) && + priv->scanner->token != G_TOKEN_RIGHT_CURLY) + g_scanner_get_next_token (priv->scanner); + } + else + css_provider_commit (css_provider); + + g_scanner_get_next_token (priv->scanner); + } + + return TRUE; +} + +gboolean +gtk_css_provider_load_from_data (GtkCssProvider *css_provider, + const gchar *data, + gssize length, + GError *error) +{ + GtkCssProviderPrivate *priv; + + g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); + g_return_val_if_fail (data != NULL, FALSE); + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + if (length < 0) + length = strlen (data); + + if (priv->selectors_info->len > 0) + g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); + + css_provider_reset_parser (css_provider); + g_scanner_input_text (priv->scanner, data, (guint) length); + + parse_stylesheet (css_provider); + + return TRUE; +} + +gboolean +gtk_css_provider_load_from_file (GtkCssProvider *css_provider, + GFile *file, + GError **error) +{ + GtkCssProviderPrivate *priv; + GError *internal_error = NULL; + gchar *data; + gsize length; + + g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + + if (!g_file_load_contents (file, NULL, + &data, &length, + NULL, &internal_error)) + { + g_propagate_error (error, internal_error); + return FALSE; + } + + if (priv->selectors_info->len > 0) + g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); + + css_provider_reset_parser (css_provider); + g_scanner_input_text (priv->scanner, data, (guint) length); + + parse_stylesheet (css_provider); + + g_free (data); + + return TRUE; +} + +#define __GTK_CSS_PROVIDER_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h new file mode 100644 index 0000000000..bf3d94ade2 --- /dev/null +++ b/gtk/gtkcssprovider.h @@ -0,0 +1,61 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_CSS_PROVIDER_H__ +#define __GTK_CSS_PROVIDER_H__ + +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_CSS_PROVIDER (gtk_css_provider_get_type ()) +#define GTK_CSS_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProvider)) +#define GTK_CSS_PROVIDER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_CSS_PROVIDER, GtkCssProviderClass)) +#define GTK_IS_CSS_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_CSS_PROVIDER)) +#define GTK_IS_CSS_PROVIDER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_CSS_PROVIDER)) +#define GTK_CSS_PROVIDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProviderClass)) + +typedef struct GtkCssProvider GtkCssProvider; +typedef struct GtkCssProviderClass GtkCssProviderClass; + +struct GtkCssProvider +{ + GObject parent_instance; +}; + +struct GtkCssProviderClass +{ + GObjectClass parent_class; +}; + +GType gtk_css_provider_get_type (void) G_GNUC_CONST; + +GtkCssProvider * gtk_css_provider_new (void); + +gboolean gtk_css_provider_load_from_data (GtkCssProvider *css_provider, + const gchar *data, + gssize length, + GError *error); +gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider, + GFile *file, + GError **error); + +G_END_DECLS + +#endif /* __GTK_CSS_PROVIDER_H__ */ From 82f485afd925c4b47acce987a55c7f7fb9e53e14 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 23:30:07 +0200 Subject: [PATCH 143/634] GtkStyleProvider: Add defines for most common priorities. --- gtk/gtkstyleprovider.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 6e12bb3c66..35a7e242d6 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -32,6 +32,11 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_PROVIDER)) #define GTK_STYLE_PROVIDER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GTK_TYPE_STYLE_PROVIDER, GtkStyleProviderIface)) +#define GTK_STYLE_PROVIDER_PRIORITY_FALLBACK 1 +#define GTK_STYLE_PROVIDER_PRIORITY_DEFAULT 200 +#define GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 400 +#define GTK_STYLE_PROVIDER_PRIORITY_USER 600 + typedef struct GtkStyleProviderIface GtkStyleProviderIface; typedef struct GtkStyleProvider GtkStyleProvider; /* dummy typedef */ From 7dada9949d32d8463458cbf4695aea2671180ea8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 11 Apr 2010 23:30:49 +0200 Subject: [PATCH 144/634] GtkWidget: Create GtkCssProvider for user modifications. ~/.gtk-X.0.css is checked, and added as a style resource if available. --- gtk/gtkwidget.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 366f912244..3d4d7cc6b7 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -59,6 +59,8 @@ #include "gtkbuilderprivate.h" #include "gtksizerequest.h" #include "gtkstylecontext.h" +#include "gtkcssprovider.h" +#include "gtkversion.h" #include "gtkdebug.h" @@ -13210,10 +13212,35 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { + static GtkCssProvider *css_provider = NULL; + context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); g_object_set_qdata_full (G_OBJECT (widget), quark_style_context, context, (GDestroyNotify) g_object_unref); + + /* Add provider for user file */ + if (G_UNLIKELY (!css_provider)) + { + GFile *home_dir, *css_file; + gchar *filename; + + css_provider = gtk_css_provider_new (); + home_dir = g_file_new_for_path (g_get_home_dir ()); + + filename = g_strdup_printf (".gtk-%d.0.css", GTK_MAJOR_VERSION); + css_file = g_file_get_child (home_dir, filename); + g_free (filename); + + if (g_file_query_exists (css_file, NULL)) + gtk_css_provider_load_from_file (css_provider, css_file, NULL); + + g_object_unref (home_dir); + g_object_unref (css_file); + } + + gtk_style_context_add_provider (context, css_provider, + GTK_STYLE_PROVIDER_PRIORITY_USER); } if (GTK_WIDGET_REALIZED (widget)) From 468f216b1cc12872c1c3af155bd0ba8a4965f780 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 14 Apr 2010 23:36:48 +0200 Subject: [PATCH 145/634] GtkCssProvider: Add state parsing. Now state is now defined as a pseudoclass in the CSS format, selectors like: GtkWidget:active { } GtkButton:insensitive { } GtkCalendar:prelight { } (also :hover is accepted) ... define the style for the given state. --- gtk/gtkcssprovider.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index eb10b2ea75..c401133f2d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -44,7 +44,6 @@ enum SelectorElementType { struct SelectorElement { SelectorElementType elem_type; - GtkStateType state; union { @@ -56,6 +55,7 @@ struct SelectorElement struct SelectorPath { GSList *elements; + GtkStateType state; guint ref_count; }; @@ -78,6 +78,7 @@ struct GtkCssProviderPrivate enum ParserScope { SCOPE_SELECTOR, + SCOPE_PSEUDO_CLASS, SCOPE_DECLARATION, SCOPE_VALUE }; @@ -110,6 +111,7 @@ selector_path_new (void) SelectorPath *path; path = g_slice_new0 (SelectorPath); + path->state = GTK_STATE_NORMAL; path->ref_count = 1; return path; @@ -209,6 +211,12 @@ gtk_css_provider_init (GtkCssProvider *css_provider) scanner = g_scanner_new (NULL); /* scanner->input_name = path; */ + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "active", GUINT_TO_POINTER (GTK_STATE_ACTIVE)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "prelight", GUINT_TO_POINTER (GTK_STATE_PRELIGHT)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "hover", GUINT_TO_POINTER (GTK_STATE_PRELIGHT)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "selected", GUINT_TO_POINTER (GTK_STATE_SELECTED)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "insensitive", GUINT_TO_POINTER (GTK_STATE_INSENSITIVE)); + priv->scanner = scanner; css_provider_apply_scope (css_provider, SCOPE_SELECTOR); } @@ -330,6 +338,7 @@ struct StylePriorityInfo { guint64 score; GHashTable *style; + GtkStateType state; }; static GtkStyleSet * @@ -360,6 +369,7 @@ gtk_style_get_style (GtkStyleProvider *provider, new.score = score; new.style = info->style; + new.state = info->path->state; for (j = 0; j < priority_info->len; j++) { @@ -389,7 +399,7 @@ gtk_style_get_style (GtkStyleProvider *provider, g_hash_table_iter_init (&iter, info->style); while (g_hash_table_iter_next (&iter, &key, &value)) - gtk_style_set_set_property (set, key, GTK_STATE_NORMAL, value); + gtk_style_set_set_property (set, key, info->state, value); } g_array_free (priority_info, TRUE); @@ -546,8 +556,9 @@ css_provider_commit (GtkCssProvider *css_provider) } static GTokenType -parse_selector (GScanner *scanner, - SelectorPath **selector_out) +parse_selector (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath **selector_out) { SelectorPath *path; @@ -588,6 +599,24 @@ parse_selector (GScanner *scanner, return G_TOKEN_IDENTIFIER; } + if (scanner->token == ':') + { + /* Pseudo-class scanning */ + css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_SYMBOL) + { + selector_path_unref (path); + return G_TOKEN_SYMBOL; + } + + path->state = GPOINTER_TO_INT (scanner->value.v_symbol); + + g_scanner_get_next_token (scanner); + css_provider_pop_scope (css_provider); + } + *selector_out = path; return G_TOKEN_NONE; @@ -648,7 +677,7 @@ parse_rule (GtkCssProvider *css_provider, priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); css_provider_push_scope (css_provider, SCOPE_SELECTOR); - expected_token = parse_selector (scanner, &selector); + expected_token = parse_selector (css_provider, scanner, &selector); if (expected_token != G_TOKEN_NONE) return expected_token; @@ -659,7 +688,7 @@ parse_rule (GtkCssProvider *css_provider, { g_scanner_get_next_token (scanner); - expected_token = parse_selector (scanner, &selector); + expected_token = parse_selector (css_provider, scanner, &selector); if (expected_token != G_TOKEN_NONE) return expected_token; From 4c8353bcbf9e95ca15552540bd609a6e96387395 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 16 Apr 2010 00:29:11 +0200 Subject: [PATCH 146/634] GtkCssProvider: Allow '*' selectors. These would match a single widget of any type. --- gtk/gtkcssprovider.c | 66 +++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index c401133f2d..ffb23b84f1 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -38,7 +38,8 @@ typedef enum ParserScope ParserScope; enum SelectorElementType { SELECTOR_TYPE_NAME, SELECTOR_NAME, - SELECTOR_GTYPE + SELECTOR_GTYPE, + SELECTOR_GLOB }; struct SelectorElement @@ -165,6 +166,17 @@ selector_path_prepend_type (SelectorPath *path, path->elements = g_slist_prepend (path->elements, elem); } +static void +selector_path_prepend_glob (SelectorPath *path) +{ + SelectorElement *elem; + + elem = g_slice_new (SelectorElement); + elem->elem_type = SELECTOR_GLOB; + + path->elements = g_slist_prepend (path->elements, elem); +} + static SelectorStyleInfo * selector_style_info_new (SelectorPath *path) { @@ -295,6 +307,11 @@ compare_path_foreach (GType type, data->score |= score; } } + else if (elem->elem_type == SELECTOR_GLOB) + { + /* Treat as lowest matching type */ + data->score++; + } data->iter = data->iter->next; @@ -460,11 +477,19 @@ css_provider_apply_scope (GtkCssProvider *css_provider, { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z; + priv->scanner->config->scan_identifier_1char = FALSE; + } + else if (scope == SCOPE_SELECTOR) + { + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*"; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; + priv->scanner->config->scan_identifier_1char = TRUE; } else { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; + priv->scanner->config->scan_identifier_1char = FALSE; } priv->scanner->config->scan_float = FALSE; @@ -556,9 +581,9 @@ css_provider_commit (GtkCssProvider *css_provider) } static GTokenType -parse_selector (GtkCssProvider *css_provider, - GScanner *scanner, - SelectorPath **selector_out) +parse_selector (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath **selector_out) { SelectorPath *path; @@ -569,34 +594,19 @@ parse_selector (GtkCssProvider *css_provider, path = selector_path_new (); - if (g_ascii_isupper (scanner->value.v_identifier[0])) + while (scanner->token == G_TOKEN_IDENTIFIER) { - while (scanner->token == G_TOKEN_IDENTIFIER && - g_ascii_isupper (scanner->value.v_identifier[0])) + if (g_ascii_isupper (scanner->value.v_identifier[0])) + selector_path_prepend_type (path, scanner->value.v_identifier); + else if (scanner->value.v_identifier[0] == '*') + selector_path_prepend_glob (path); + else { - selector_path_prepend_type (path, scanner->value.v_identifier); - g_scanner_get_next_token (scanner); + selector_path_unref (path); + return G_TOKEN_IDENTIFIER; } - if (scanner->token == '.') - { - /* style class scanning */ - g_scanner_get_next_token (scanner); - - if (scanner->token != G_TOKEN_IDENTIFIER) - { - selector_path_unref (path); - return G_TOKEN_IDENTIFIER; - } - - g_print ("Style class: %s\n", scanner->value.v_identifier); - g_scanner_get_next_token (scanner); - } - } - else - { - selector_path_unref (path); - return G_TOKEN_IDENTIFIER; + g_scanner_get_next_token (scanner); } if (scanner->token == ':') From abbeb89b7ca7e369ec47c548107843ed85ba34d4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 16 Apr 2010 01:44:50 +0200 Subject: [PATCH 147/634] GtkCssProvider: Allow empty selector. universal selector is implied, so things like this work: :active {} :insensitive{} --- gtk/gtkcssprovider.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index ffb23b84f1..71d58c71af 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -177,6 +177,12 @@ selector_path_prepend_glob (SelectorPath *path) path->elements = g_slist_prepend (path->elements, elem); } +static gint +selector_path_depth (SelectorPath *path) +{ + return g_slist_length (path->elements); +} + static SelectorStyleInfo * selector_style_info_new (SelectorPath *path) { @@ -589,7 +595,8 @@ parse_selector (GtkCssProvider *css_provider, *selector_out = NULL; - if (scanner->token != G_TOKEN_IDENTIFIER) + if (scanner->token != ':' && + scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; path = selector_path_new (); @@ -611,6 +618,10 @@ parse_selector (GtkCssProvider *css_provider, if (scanner->token == ':') { + /* Add glob selector if path is empty */ + if (selector_path_depth (path) == 0) + selector_path_prepend_glob (path); + /* Pseudo-class scanning */ css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); g_scanner_get_next_token (scanner); From d691e79cbf2f8df6b0c37b844d8f260b7a21085d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 16 Apr 2010 02:59:36 +0200 Subject: [PATCH 148/634] GtkCssProvider: Fix typo freeing SelectorElements. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 71d58c71af..5fdc882895 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -135,7 +135,7 @@ selector_path_unref (SelectorPath *path) while (path->elements) { - g_slice_free (SelectorPath, path->elements->data); + g_slice_free (SelectorElement, path->elements->data); path->elements = g_slist_delete_link (path->elements, path->elements); } From 8c03503d16331c83d28931b98ae7d4e48ea206f0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 16 Apr 2010 03:02:42 +0200 Subject: [PATCH 149/634] GtkCssProvider: Add support for child/descendant combinators. Now, selectors like: GtkWindow > GtkButton {} GtkNotebook > GtkLabel {} will represent a direct parent/child relation between both elements, while GtkWindow GtkButton {} GtkNotebook GtkLabel {} will allow intermediate children between these. --- gtk/gtkcssprovider.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 5fdc882895..8fbddc2431 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -33,6 +33,7 @@ typedef struct SelectorElement SelectorElement; typedef struct SelectorPath SelectorPath; typedef struct SelectorStyleInfo SelectorStyleInfo; typedef enum SelectorElementType SelectorElementType; +typedef enum CombinatorType CombinatorType; typedef enum ParserScope ParserScope; enum SelectorElementType { @@ -42,9 +43,15 @@ enum SelectorElementType { SELECTOR_GLOB }; +enum CombinatorType { + COMBINATOR_DESCENDANT, /* No direct relation needed */ + COMBINATOR_CHILD /* Direct child */ +}; + struct SelectorElement { SelectorElementType elem_type; + CombinatorType combinator; union { @@ -150,6 +157,7 @@ selector_path_prepend_type (SelectorPath *path, GType type; elem = g_slice_new (SelectorElement); + elem->combinator = COMBINATOR_DESCENDANT; type = g_type_from_name (type_name); if (type == G_TYPE_INVALID) @@ -173,10 +181,24 @@ selector_path_prepend_glob (SelectorPath *path) elem = g_slice_new (SelectorElement); elem->elem_type = SELECTOR_GLOB; + elem->combinator = COMBINATOR_DESCENDANT; path->elements = g_slist_prepend (path->elements, elem); } +static void +selector_path_prepend_combinator (SelectorPath *path, + CombinatorType combinator) +{ + SelectorElement *elem; + + g_assert (path->elements != NULL); + + /* It is actually stored in the last element */ + elem = path->elements->data; + elem->combinator = combinator; +} + static gint selector_path_depth (SelectorPath *path) { @@ -286,8 +308,16 @@ compare_path_foreach (GType type, if (!g_type_is_a (type, elem->type)) { /* Selector definitely doesn't match */ - data->score = 0; - return TRUE; + if (elem->combinator == COMBINATOR_CHILD) + { + data->score = 0; + return TRUE; + } + else + { + /* Keep checking descendants for a match */ + return FALSE; + } } else if (type == elem->type) data->score |= 0xF; @@ -614,6 +644,12 @@ parse_selector (GtkCssProvider *css_provider, } g_scanner_get_next_token (scanner); + + if (scanner->token == '>') + { + selector_path_prepend_combinator (path, COMBINATOR_CHILD); + g_scanner_get_next_token (scanner); + } } if (scanner->token == ':') From f60e3f3a8afd00963d3cc810899aad5cab39f7ea Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 00:32:21 +0200 Subject: [PATCH 150/634] Move GtkChildClassFlags to gtkenums.h. --- gtk/gtkenums.h | 9 +++++++++ gtk/gtkstylecontext.h | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index d613cb47f5..9356b8f08d 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -570,6 +570,15 @@ typedef enum GTK_STATE_FLAG_FOCUSED = 1 << 5 } GtkStateFlags; +typedef enum { + GTK_CHILD_CLASS_EVEN = 1 << 0, + GTK_CHILD_CLASS_ODD = 1 << 1, + GTK_CHILD_CLASS_FIRST = 1 << 2, + GTK_CHILD_CLASS_LAST = 1 << 3, + GTK_CHILD_CLASS_DEFAULT = 1 << 4, + GTK_CHILD_CLASS_SORTED = 1 << 5 +} GtkChildClassFlags; + G_END_DECLS diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 2c2485b406..a9ddd75e7a 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -36,15 +36,6 @@ G_BEGIN_DECLS typedef struct GtkStyleContext GtkStyleContext; typedef struct GtkStyleContextClass GtkStyleContextClass; -typedef enum { - GTK_CHILD_CLASS_EVEN = 1 << 0, - GTK_CHILD_CLASS_ODD = 1 << 1, - GTK_CHILD_CLASS_FIRST = 1 << 2, - GTK_CHILD_CLASS_LAST = 1 << 3, - GTK_CHILD_CLASS_DEFAULT = 1 << 4, - GTK_CHILD_CLASS_SORTED = 1 << 5 -} GtkChildClassFlags; - struct GtkStyleContext { GObject parent_object; From 71949e05c47fdce1f90e8515bf733b3a315fae5f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 01:27:46 +0200 Subject: [PATCH 151/634] Refurbish GtkWidgetPath API. The foreach() function is now gone, there's now API to get GTypes and names from the position in the path. --- gtk/gtkcssprovider.c | 117 ++++++++++++----------- gtk/gtkwidget.c | 4 +- gtk/gtkwidgetpath.c | 223 +++++++++++++++++++++++-------------------- gtk/gtkwidgetpath.h | 32 ++++--- 4 files changed, 202 insertions(+), 174 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 8fbddc2431..039f4a0f09 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -271,15 +271,12 @@ struct ComparePathData }; static gboolean -compare_path_foreach (GType type, - const gchar *name, - gpointer user_data) +compare_selector_element (GtkWidgetPath *path, + guint index, + SelectorElement *elem, + guint8 *score) { - ComparePathData *data; - SelectorElement *elem; - - data = user_data; - elem = data->iter->data; + *score = 0; if (elem->elem_type == SELECTOR_TYPE_NAME) { @@ -295,8 +292,7 @@ compare_path_foreach (GType type, /* Type couldn't be resolved, so the selector * clearly doesn't affect the given widget path */ - data->score = 0; - return TRUE; + return FALSE; } elem->elem_type = SELECTOR_GTYPE; @@ -305,84 +301,95 @@ compare_path_foreach (GType type, if (elem->elem_type == SELECTOR_GTYPE) { + GType type; + + type = gtk_widget_path_get_element_type (path, index); + if (!g_type_is_a (type, elem->type)) - { - /* Selector definitely doesn't match */ - if (elem->combinator == COMBINATOR_CHILD) - { - data->score = 0; - return TRUE; - } - else - { - /* Keep checking descendants for a match */ - return FALSE; - } - } - else if (type == elem->type) - data->score |= 0xF; + return FALSE; + + if (type == elem->type) + *score |= 0xF; else { GType parent = type; - guint8 score = 0xE; + + *score = 0xE; while ((parent = g_type_parent (parent)) != G_TYPE_INVALID) { if (parent == elem->type) break; - score--; + *score -= 1; - if (score == 1) + if (*score == 1) { g_warning ("Hierarchy is higher than expected."); break; } } - - data->score |= score; } + + return TRUE; } else if (elem->elem_type == SELECTOR_GLOB) { /* Treat as lowest matching type */ - data->score++; + *score = 1; + return TRUE; } - data->iter = data->iter->next; - - if (data->iter) - { - data->score <<= 4; - return FALSE; - } - - return TRUE; + return FALSE; } static guint64 compare_selector (GtkWidgetPath *path, SelectorPath *selector) { - ComparePathData data; + GSList *elements = selector->elements; + gboolean match = TRUE; + guint64 score = 0; + guint i = 0; - data.score = 0; - data.path = selector; - data.iter = selector->elements; - - gtk_widget_path_foreach (path, - compare_path_foreach, - &data); - - if (data.iter) + while (elements && match && + i < gtk_widget_path_length (path)) { - /* There is remaining data to compare, - * so don't take it as a match. - */ - data.score = 0; + SelectorElement *elem; + guint8 elem_score; + + elem = elements->data; + elements = elements->next; + + match = compare_selector_element (path, i, elem, &elem_score); + i++; + + if (!match && elem->combinator == COMBINATOR_DESCENDANT) + { + /* With descendant combinators there may + * be intermediate chidren in the hierarchy + */ + match = TRUE; + } + + if (match) + { + score <<= 4; + score |= elem_score; + } } - return data.score; + /* If there are pending selector + * elements to compare, it's not + * a match. + */ + if (elements) + match = FALSE; + + if (!match) + score = 0; + + return score; } typedef struct StylePriorityInfo StylePriorityInfo; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3d4d7cc6b7..e4e3e32b86 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13191,9 +13191,7 @@ gtk_widget_get_path (GtkWidget *widget) while (widget) { - gtk_widget_path_prepend_widget_desc (path, - G_OBJECT_TYPE (widget), - widget->name); + gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); widget = widget->parent; } diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 2af624f557..a6cfcccf32 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -34,8 +34,7 @@ struct GtkPathElement struct GtkWidgetPath { - GSList *elems; - GSList *last; /* Last element contains the described widget */ + GArray *elems; /* First element contains the described widget */ }; GtkWidgetPath * @@ -44,78 +43,31 @@ gtk_widget_path_new (void) GtkWidgetPath *path; path = g_slice_new0 (GtkWidgetPath); + path->elems = g_array_new (FALSE, TRUE, sizeof (GtkPathElement)); return path; } -static GtkPathElement * -path_element_new (GType type, - const gchar *name) -{ - GtkPathElement *elem; - - elem = g_slice_new (GtkPathElement); - elem->type = type; - elem->name = g_strdup (name); - - return elem; -} - -static void -path_element_free (GtkPathElement *elem) -{ - g_free (elem->name); - g_slice_free (GtkPathElement, elem); -} - -void -gtk_widget_path_prepend_widget_desc (GtkWidgetPath *path, - GType type, - const gchar *name) -{ - g_return_if_fail (path != NULL); - g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET)); - - if (!path->elems) - { - path->elems = g_slist_prepend (NULL, path_element_new (type, name)); - path->last = path->elems; - } - else - { - path->last->next = g_slist_alloc (); - path->last->next->data = path_element_new (type, name); - path->last = path->last->next; - } -} - GtkWidgetPath * -gtk_widget_path_copy (GtkWidgetPath *path) +gtk_widget_path_copy (const GtkWidgetPath *path) { GtkWidgetPath *new_path; - GSList *elems; + guint i; + + g_return_val_if_fail (path != NULL, NULL); new_path = gtk_widget_path_new (); - elems = path->elems; - while (elems) + for (i = 0; i < path->elems->len; i++) { - GtkPathElement *elem; - GSList *link; + GtkPathElement *elem, new = { 0 }; - elem = elems->data; - link = g_slist_alloc (); - link->data = path_element_new (elem->type, elem->name); + elem = &g_array_index (path->elems, GtkPathElement, i); - if (!new_path->elems) - new_path->last = new_path->elems = link; - else - { - new_path->last->next = link; - new_path->last = link; - } + new.type = elem->type; + new.name = g_strdup (elem->name); - elems = elems->next; + g_array_append_val (new_path->elems, new); } return new_path; @@ -124,59 +76,124 @@ gtk_widget_path_copy (GtkWidgetPath *path) void gtk_widget_path_free (GtkWidgetPath *path) { + guint i; + g_return_if_fail (path != NULL); - g_slist_foreach (path->elems, (GFunc) path_element_free, NULL); - g_slist_free (path->elems); - - g_slice_free (GtkWidgetPath, path); -} - -gboolean -gtk_widget_path_has_parent (GtkWidgetPath *path, - GType type) -{ - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); - - GSList *elems = path->elems; - - while (elems) + for (i = 0; i < path->elems->len; i++) { GtkPathElement *elem; - elem = elems->data; + elem = &g_array_index (path->elems, GtkPathElement, i); + g_free (elem->name); + } + + g_array_free (path->elems, TRUE); + g_slice_free (GtkWidgetPath, path); +} + +guint +gtk_widget_path_length (GtkWidgetPath *path) +{ + g_return_val_if_fail (path != NULL, 0); + + return path->elems->len; +} + +guint +gtk_widget_path_prepend_type (GtkWidgetPath *path, + GType type) +{ + GtkPathElement new = { 0 }; + + g_return_val_if_fail (path != NULL, 0); + g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), 0); + + new.type = type; + g_array_append_val (path->elems, new); + + return path->elems->len - 1; +} + +GType +gtk_widget_path_get_element_type (GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, G_TYPE_INVALID); + g_return_val_if_fail (pos < path->elems->len, G_TYPE_INVALID); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + return elem->type; +} + +void +gtk_widget_path_set_element_type (GtkWidgetPath *path, + guint pos, + GType type) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET)); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + elem->type = type; +} + +G_CONST_RETURN gchar * +gtk_widget_path_get_element_name (GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (pos < path->elems->len, NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + return elem->name; +} + +void +gtk_widget_path_set_element_name (GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (name != NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (elem->name) + g_free (elem->name); + + elem->name = g_strdup (name); +} + +gboolean +gtk_widget_path_has_parent (const GtkWidgetPath *path, + GType type) +{ + guint i; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); + + for (i = 1; i < path->elems->len; i++) + { + GtkPathElement *elem; + + elem = &g_array_index (path->elems, GtkPathElement, i); if (elem->type == type || g_type_is_a (elem->type, type)) return TRUE; - - elems = elems->next; } return FALSE; } - -void -gtk_widget_path_foreach (GtkWidgetPath *path, - GtkWidgetPathForeachFunc func, - gpointer user_data) -{ - GSList *elems; - - g_return_if_fail (path != NULL); - g_return_if_fail (func != NULL); - - elems = path->elems; - - while (elems) - { - GtkPathElement *elem; - - elem = elems->data; - elems = elems->next; - - if ((func) (elem->type, elem->name, user_data)) - return; - } -} diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 664562cbc4..3846988fd2 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -21,31 +21,37 @@ #define __GTK_WIDGET_PATH_H__ #include +#include "gtkenums.h" G_BEGIN_DECLS typedef struct GtkWidgetPath GtkWidgetPath; -typedef gboolean (* GtkWidgetPathForeachFunc) (GType type, - const gchar *name, - gpointer user_data); GtkWidgetPath * gtk_widget_path_new (void); -void gtk_widget_path_prepend_widget_desc (GtkWidgetPath *path, - GType type, - const gchar *name); +GtkWidgetPath * gtk_widget_path_copy (const GtkWidgetPath *path); +void gtk_widget_path_free (GtkWidgetPath *path); -GtkWidgetPath * gtk_widget_path_copy (GtkWidgetPath *path); -void gtk_widget_path_free (GtkWidgetPath *path); +guint gtk_widget_path_length (GtkWidgetPath *path); -gboolean gtk_widget_path_has_parent (GtkWidgetPath *path, - GType type); +guint gtk_widget_path_prepend_type (GtkWidgetPath *path, + GType type); -void gtk_widget_path_foreach (GtkWidgetPath *path, - GtkWidgetPathForeachFunc func, - gpointer user_data); +GType gtk_widget_path_get_element_type (GtkWidgetPath *path, + guint pos); +void gtk_widget_path_set_element_type (GtkWidgetPath *path, + guint pos, + GType type); +G_CONST_RETURN gchar * gtk_widget_path_get_element_name (GtkWidgetPath *path, + guint pos); +void gtk_widget_path_set_element_name (GtkWidgetPath *path, + guint pos, + const gchar *name); + +gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, + GType type); G_END_DECLS From 11c874619bdcf27204888831ac0d2de294874bb0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 01:35:54 +0200 Subject: [PATCH 152/634] GtkWidgetPath: Add API for named regions. --- gtk/gtkwidgetpath.c | 130 ++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkwidgetpath.h | 18 ++++++ 2 files changed, 148 insertions(+) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index a6cfcccf32..2573273616 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -30,6 +30,7 @@ struct GtkPathElement { GType type; gchar *name; + GHashTable *regions; }; struct GtkWidgetPath @@ -67,6 +68,23 @@ gtk_widget_path_copy (const GtkWidgetPath *path) new.type = elem->type; new.name = g_strdup (elem->name); + if (elem->regions) + { + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, elem->regions); + new.regions = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + NULL); + + while (g_hash_table_iter_next (&iter, &key, &value)) + g_hash_table_insert (new.regions, + g_strdup ((const gchar *) key), + value); + } + g_array_append_val (new_path->elems, new); } @@ -86,6 +104,9 @@ gtk_widget_path_free (GtkWidgetPath *path) elem = &g_array_index (path->elems, GtkPathElement, i); g_free (elem->name); + + if (elem->regions) + g_hash_table_destroy (elem->regions); } g_array_free (path->elems, TRUE); @@ -175,6 +196,115 @@ gtk_widget_path_set_element_name (GtkWidgetPath *path, elem->name = g_strdup (name); } +void +gtk_widget_path_iter_add_region (GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags flags) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (name != NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->regions) + elem->regions = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + NULL); + + g_hash_table_insert (elem->regions, + g_strdup (name), + GUINT_TO_POINTER (flags)); +} + +void +gtk_widget_path_iter_remove_region (GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (name != NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (elem->regions) + g_hash_table_remove (elem->regions, name); +} + +void +gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (elem->regions) + g_hash_table_remove_all (elem->regions); +} + +GSList * +gtk_widget_path_iter_list_regions (GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + GHashTableIter iter; + GSList *list = NULL; + gpointer key; + + g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (pos < path->elems->len, NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->regions) + return NULL; + + g_hash_table_iter_init (&iter, elem->regions); + + while (g_hash_table_iter_next (&iter, &key, NULL)) + list = g_slist_prepend (list, key); + + return list; +} + +gboolean +gtk_widget_path_iter_has_region (GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags *flags) +{ + GtkPathElement *elem; + gpointer value; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + g_return_val_if_fail (name != NULL, FALSE); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->regions) + return FALSE; + + if (!g_hash_table_lookup_extended (elem->regions, name, NULL, &value)) + return FALSE; + + if (flags) + *flags = GPOINTER_TO_UINT (value); + + return TRUE; +} + gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type) diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 3846988fd2..7020c826a3 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -50,6 +50,24 @@ void gtk_widget_path_set_element_name (GtkWidgetPath *path, guint pos, const gchar *name); +void gtk_widget_path_iter_add_region (GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags flags); +void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, + guint pos, + const gchar *name); +void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, + guint pos); + +GSList * gtk_widget_path_iter_list_regions (GtkWidgetPath *path, + guint pos); + +gboolean gtk_widget_path_iter_has_region (GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags *flags); + gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type); From 707d5ae99c3a3c811d8c87b70a680aaa5d6e6398 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 01:46:52 +0200 Subject: [PATCH 153/634] GtkCssProvider: Parse named regions. --- gtk/gtkcssprovider.c | 115 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 039f4a0f09..394c74e6ee 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -35,6 +35,7 @@ typedef struct SelectorStyleInfo SelectorStyleInfo; typedef enum SelectorElementType SelectorElementType; typedef enum CombinatorType CombinatorType; typedef enum ParserScope ParserScope; +typedef enum ParserSymbol ParserSymbol; enum SelectorElementType { SELECTOR_TYPE_NAME, @@ -87,10 +88,27 @@ struct GtkCssProviderPrivate enum ParserScope { SCOPE_SELECTOR, SCOPE_PSEUDO_CLASS, + SCOPE_NTH_CHILD, SCOPE_DECLARATION, SCOPE_VALUE }; +/* Extend GtkStateType, since these + * values are also used as symbols + */ +enum ParserSymbol { + /* Scope: pseudo-class */ + SYMBOL_NTH_CHILD = GTK_STATE_LAST, + SYMBOL_FIRST_CHILD, + SYMBOL_LAST_CHILD, + + /* Scope: nth-child */ + SYMBOL_NTH_CHILD_EVEN, + SYMBOL_NTH_CHILD_ODD, + SYMBOL_NTH_CHILD_FIRST, + SYMBOL_NTH_CHILD_LAST +}; + #define GTK_CSS_PROVIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProviderPrivate)) static void gtk_css_provider_finalize (GObject *object); @@ -257,6 +275,15 @@ gtk_css_provider_init (GtkCssProvider *css_provider) g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "selected", GUINT_TO_POINTER (GTK_STATE_SELECTED)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "insensitive", GUINT_TO_POINTER (GTK_STATE_INSENSITIVE)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "nth-child", GUINT_TO_POINTER (SYMBOL_NTH_CHILD)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "first-child", GUINT_TO_POINTER (SYMBOL_FIRST_CHILD)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "last-child", GUINT_TO_POINTER (SYMBOL_LAST_CHILD)); + + g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "even", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_EVEN)); + g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "odd", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_ODD)); + g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "first", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_FIRST)); + g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "last", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_LAST)); + priv->scanner = scanner; css_provider_apply_scope (css_provider, SCOPE_SELECTOR); } @@ -623,6 +650,73 @@ css_provider_commit (GtkCssProvider *css_provider) } } +static GTokenType +parse_nth_child (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath *selector, + GtkChildClassFlags *flags) +{ + ParserSymbol symbol; + + *flags = 0; + + css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_SYMBOL) + return G_TOKEN_SYMBOL; + + symbol = GPOINTER_TO_INT (scanner->value.v_symbol); + + if (symbol == SYMBOL_NTH_CHILD) + { + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_LEFT_PAREN) + return G_TOKEN_LEFT_PAREN; + + css_provider_push_scope (css_provider, SCOPE_NTH_CHILD); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_SYMBOL) + return G_TOKEN_SYMBOL; + + symbol = GPOINTER_TO_INT (scanner->value.v_symbol); + + switch (symbol) + { + case SYMBOL_NTH_CHILD_EVEN: + *flags = GTK_CHILD_CLASS_EVEN; + break; + case SYMBOL_NTH_CHILD_ODD: + *flags = GTK_CHILD_CLASS_ODD; + break; + case SYMBOL_NTH_CHILD_FIRST: + *flags = GTK_CHILD_CLASS_FIRST; + break; + case SYMBOL_NTH_CHILD_LAST: + *flags = GTK_CHILD_CLASS_LAST; + break; + default: + break; + } + + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_RIGHT_PAREN) + return G_TOKEN_RIGHT_PAREN; + + css_provider_pop_scope (css_provider); + } + else if (symbol == SYMBOL_FIRST_CHILD) + *flags = GTK_CHILD_CLASS_FIRST; + else if (symbol == SYMBOL_LAST_CHILD) + *flags = GTK_CHILD_CLASS_LAST; + + css_provider_pop_scope (css_provider); + return G_TOKEN_NONE; +} + static GTokenType parse_selector (GtkCssProvider *css_provider, GScanner *scanner, @@ -642,6 +736,23 @@ parse_selector (GtkCssProvider *css_provider, { if (g_ascii_isupper (scanner->value.v_identifier[0])) selector_path_prepend_type (path, scanner->value.v_identifier); + else if (g_ascii_islower (scanner->value.v_identifier[0])) + { + GtkChildClassFlags flags = 0; + + /* Parse nth-child type pseudo-class */ + if (g_scanner_peek_next_token (scanner) == ':') + { + GTokenType token; + g_scanner_get_next_token (scanner); + + if ((token = parse_nth_child (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) + { + selector_path_unref (path); + return token; + } + } + } else if (scanner->value.v_identifier[0] == '*') selector_path_prepend_glob (path); else @@ -723,9 +834,7 @@ parse_value (GType type, return TRUE; } else - { - g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); - } + g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); return FALSE; } From 07171d5f68378e8accbdd3ff3a16d879972685a5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 01:48:01 +0200 Subject: [PATCH 154/634] GtkCssProvider: Add named regions to selector path. --- gtk/gtkcssprovider.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 394c74e6ee..1c5ee9e70c 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -41,6 +41,7 @@ enum SelectorElementType { SELECTOR_TYPE_NAME, SELECTOR_NAME, SELECTOR_GTYPE, + SELECTOR_REGION, SELECTOR_GLOB }; @@ -58,6 +59,12 @@ struct SelectorElement { GQuark name; GType type; + + struct + { + GQuark name; + GtkChildClassFlags flags; + } region; }; }; @@ -204,6 +211,23 @@ selector_path_prepend_glob (SelectorPath *path) path->elements = g_slist_prepend (path->elements, elem); } +static void +selector_path_prepend_region (SelectorPath *path, + const gchar *name, + GtkChildClassFlags flags) +{ + SelectorElement *elem; + + elem = g_slice_new (SelectorElement); + elem->combinator = COMBINATOR_DESCENDANT; + elem->elem_type = SELECTOR_REGION; + + elem->region.name = g_quark_from_string (name); + elem->region.flags = flags; + + path->elements = g_slist_prepend (path->elements, elem); +} + static void selector_path_prepend_combinator (SelectorPath *path, CombinatorType combinator) @@ -739,6 +763,9 @@ parse_selector (GtkCssProvider *css_provider, else if (g_ascii_islower (scanner->value.v_identifier[0])) { GtkChildClassFlags flags = 0; + gchar *region_name; + + region_name = g_strdup (scanner->value.v_identifier); /* Parse nth-child type pseudo-class */ if (g_scanner_peek_next_token (scanner) == ':') @@ -752,6 +779,9 @@ parse_selector (GtkCssProvider *css_provider, return token; } } + + selector_path_prepend_region (path, region_name, flags); + g_free (region_name); } else if (scanner->value.v_identifier[0] == '*') selector_path_prepend_glob (path); From bc0af3208d55a3733e784a20bf00547da0bef274 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 21 Apr 2010 01:51:46 +0200 Subject: [PATCH 155/634] GtkCssProvider: free selector path on parse_rule(). --- gtk/gtkcssprovider.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 1c5ee9e70c..ed78aec8de 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -748,7 +748,8 @@ parse_selector (GtkCssProvider *css_provider, { SelectorPath *path; - *selector_out = NULL; + path = selector_path_new (); + *selector_out = path; if (scanner->token != ':' && scanner->token != G_TOKEN_IDENTIFIER) @@ -774,10 +775,7 @@ parse_selector (GtkCssProvider *css_provider, g_scanner_get_next_token (scanner); if ((token = parse_nth_child (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) - { - selector_path_unref (path); - return token; - } + return token; } selector_path_prepend_region (path, region_name, flags); @@ -786,10 +784,7 @@ parse_selector (GtkCssProvider *css_provider, else if (scanner->value.v_identifier[0] == '*') selector_path_prepend_glob (path); else - { - selector_path_unref (path); - return G_TOKEN_IDENTIFIER; - } + return G_TOKEN_IDENTIFIER; g_scanner_get_next_token (scanner); @@ -811,10 +806,7 @@ parse_selector (GtkCssProvider *css_provider, g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_SYMBOL) - { - selector_path_unref (path); - return G_TOKEN_SYMBOL; - } + return G_TOKEN_SYMBOL; path->state = GPOINTER_TO_INT (scanner->value.v_symbol); @@ -883,7 +875,10 @@ parse_rule (GtkCssProvider *css_provider, expected_token = parse_selector (css_provider, scanner, &selector); if (expected_token != G_TOKEN_NONE) - return expected_token; + { + selector_path_unref (selector); + return expected_token; + } priv->cur_selectors = g_slist_prepend (priv->cur_selectors, selector); @@ -894,7 +889,10 @@ parse_rule (GtkCssProvider *css_provider, expected_token = parse_selector (css_provider, scanner, &selector); if (expected_token != G_TOKEN_NONE) - return expected_token; + { + selector_path_unref (selector); + return expected_token; + } priv->cur_selectors = g_slist_prepend (priv->cur_selectors, selector); } From 0be4659c5d8f6428c41a5d5406a54cb2014f0311 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 01:23:27 +0200 Subject: [PATCH 156/634] GtkCssProvider: move to next selector element on match or child combinator. --- gtk/gtkcssprovider.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index ed78aec8de..9fd00e9b9e 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -410,7 +410,6 @@ compare_selector (GtkWidgetPath *path, guint8 elem_score; elem = elements->data; - elements = elements->next; match = compare_selector_element (path, i, elem, &elem_score); i++; @@ -422,6 +421,8 @@ compare_selector (GtkWidgetPath *path, */ match = TRUE; } + else + elements = elements->next; if (match) { From 977a9723588ba0ef5f2d74205aa8c8e3bf3f47c9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 01:28:24 +0200 Subject: [PATCH 157/634] GtkCssProvider: fix parsing of consecutive pseudo-classes. Now either of foo{}, foo:first-child{}, foo:nth-child(even):insensitive or foo:active{} will be correctly parsed. --- gtk/gtkcssprovider.c | 61 +++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 9fd00e9b9e..e903ec5f31 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -676,15 +676,13 @@ css_provider_commit (GtkCssProvider *css_provider) } static GTokenType -parse_nth_child (GtkCssProvider *css_provider, - GScanner *scanner, - SelectorPath *selector, - GtkChildClassFlags *flags) +parse_pseudo_class (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath *selector, + GtkChildClassFlags *flags) { ParserSymbol symbol; - *flags = 0; - css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); g_scanner_get_next_token (scanner); @@ -737,6 +735,13 @@ parse_nth_child (GtkCssProvider *css_provider, *flags = GTK_CHILD_CLASS_FIRST; else if (symbol == SYMBOL_LAST_CHILD) *flags = GTK_CHILD_CLASS_LAST; + else + { + GtkStateType state; + + state = GPOINTER_TO_INT (scanner->value.v_symbol); + selector->state = state; + } css_provider_pop_scope (css_provider); return G_TOKEN_NONE; @@ -769,13 +774,17 @@ parse_selector (GtkCssProvider *css_provider, region_name = g_strdup (scanner->value.v_identifier); - /* Parse nth-child type pseudo-class */ - if (g_scanner_peek_next_token (scanner) == ':') + /* Parse nth-child type pseudo-class, and + * possibly a state pseudo-class after it. + */ + while (path->state == GTK_STATE_NORMAL && + g_scanner_peek_next_token (scanner) == ':') { GTokenType token; + g_scanner_get_next_token (scanner); - if ((token = parse_nth_child (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) + if ((token = parse_pseudo_class (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) return token; } @@ -789,6 +798,10 @@ parse_selector (GtkCssProvider *css_provider, g_scanner_get_next_token (scanner); + /* State is the last element in the selector */ + if (path->state != GTK_STATE_NORMAL) + break; + if (scanner->token == '>') { selector_path_prepend_combinator (path, COMBINATOR_CHILD); @@ -796,23 +809,35 @@ parse_selector (GtkCssProvider *css_provider, } } - if (scanner->token == ':') + if (scanner->token == ':' && + path->state == GTK_STATE_NORMAL) { + GtkChildClassFlags flags = 0; + GTokenType token; + /* Add glob selector if path is empty */ if (selector_path_depth (path) == 0) selector_path_prepend_glob (path); - /* Pseudo-class scanning */ - css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); - g_scanner_get_next_token (scanner); + if ((token = parse_pseudo_class (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) + return token; - if (scanner->token != G_TOKEN_SYMBOL) - return G_TOKEN_SYMBOL; - - path->state = GPOINTER_TO_INT (scanner->value.v_symbol); + if (flags != 0) + { + /* This means either a standalone :nth-child + * selector, or on a invalid element type. + */ + return G_TOKEN_SYMBOL; + } g_scanner_get_next_token (scanner); - css_provider_pop_scope (css_provider); + } + else if (scanner->token == G_TOKEN_SYMBOL) + { + /* A new pseudo-class was starting, but the state was already + * parsed, so nothing is supposed to go after that. + */ + return G_TOKEN_LEFT_CURLY; } *selector_out = path; From 67c4f8d02ebcc4846316399cda9ed386a494f11d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 01:31:44 +0200 Subject: [PATCH 158/634] GtkCssProvider: Compare GtkWidgetPath regions with css. --- gtk/gtkcssprovider.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index e903ec5f31..93604885fd 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -384,6 +384,24 @@ compare_selector_element (GtkWidgetPath *path, return TRUE; } + else if (elem->elem_type == SELECTOR_REGION) + { + const gchar *region_name; + GtkChildClassFlags flags; + + /* FIXME: Need GQuark API here */ + region_name = g_quark_to_string (elem->region.name); + + if (!gtk_widget_path_iter_has_region (path, index, region_name, &flags)) + return FALSE; + + if (elem->region.flags != 0 && + (flags & elem->region.flags) == 0) + return FALSE; + + *score = 0xF; + return TRUE; + } else if (elem->elem_type == SELECTOR_GLOB) { /* Treat as lowest matching type */ From 104caa74f05a376a7dd65f4b7540c6986c7781f3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 02:31:57 +0200 Subject: [PATCH 159/634] GtkStyleContext: Add gtk_style_context_list_child_classes(). --- gtk/gtkstylecontext.c | 25 +++++++++++++++++++++++++ gtk/gtkstylecontext.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f8f6c08040..c4401cc155 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -473,6 +473,31 @@ child_style_class_compare (gconstpointer p1, return (gint) c1->class_quark - c2->class_quark; } +GList * +gtk_style_context_list_child_classes (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GList *classes = NULL; + GList *link; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + link = priv->child_style_classes; + + while (link) + { + GtkChildClass *link_class; + + link_class = link->data; + classes = g_list_prepend (classes, + g_quark_to_string (link_class->class_quark)); + link = link->next; + } + + return classes; +} + void gtk_style_context_set_child_class (GtkStyleContext *context, const gchar *class_name, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a9ddd75e7a..2ef9ee12c9 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -84,6 +84,8 @@ void gtk_style_context_unset_class (GtkStyleContext *context, gboolean gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name); +GList * gtk_style_context_list_child_classes (GtkStyleContext *context); + void gtk_style_context_set_child_class (GtkStyleContext *context, const gchar *class_name, GtkChildClassFlags flags); From cf27f6f1cfb7fb40ced5bb86e3cbbde58f0c6c2c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 02:33:01 +0200 Subject: [PATCH 160/634] GtkStyleContext: fix typos in code. The wrong list was being modified in gtk_style_context_set_child_class(), and gtk_style_context_has_child_class() was checking for *flags != 0, not flags != NULL. --- gtk/gtkstylecontext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c4401cc155..d0f95cf989 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -513,7 +513,7 @@ gtk_style_context_set_child_class (GtkStyleContext *context, priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); class_quark = g_quark_from_string (class_name); - link = priv->style_classes; + link = priv->child_style_classes; while (link) { @@ -537,10 +537,10 @@ gtk_style_context_set_child_class (GtkStyleContext *context, child_class->flags = flags; if (link) - priv->style_classes = g_list_insert_before (priv->style_classes, - link, child_class); + priv->child_style_classes = g_list_insert_before (priv->child_style_classes, + link, child_class); else - priv->style_classes = g_list_append (priv->style_classes, child_class); + priv->child_style_classes = g_list_append (priv->child_style_classes, child_class); } void @@ -603,7 +603,7 @@ gtk_style_context_has_child_class (GtkStyleContext *context, if (link) { - if (*flags_return) + if (flags_return) { GtkChildClass *found_class; From f5adc2a1c3bfd317f2288ba39925e7f7d6b50e38 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 02:36:47 +0200 Subject: [PATCH 161/634] Add region details in gtk_widget_get_path(). --- gtk/gtkwidget.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e4e3e32b86..8fcff94b67 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13182,17 +13182,53 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget) { + GtkStyleContext *context; GtkWidgetPath *path; + GtkWidget *parent; + GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL); - path = gtk_widget_path_new (); + parent = widget->priv->parent; - while (widget) + path = gtk_widget_path_new (); + gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); + regions = reg = NULL; + + if (widget->priv->name) + gtk_widget_path_iter_set_name (path, 0, widget->priv->name); + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + + if (context) + regions = reg = gtk_style_context_list_child_classes (context); + + while (reg) { - gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); - widget = widget->parent; + GtkChildClassFlags flags; + const gchar *region_name; + + region_name = reg->data; + reg = reg->next; + + gtk_style_context_has_child_class (context, region_name, &flags); + gtk_widget_path_iter_add_region (path, 0, region_name, flags); + } + + g_list_free (regions); + + while (parent) + { + guint position; + + position = gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (parent)); + + if (parent->priv->name) + gtk_widget_path_iter_set_name (path, position, parent->priv->name); + + parent = parent->priv->parent; } return path; From 17908880b568b8951a9841109ec603131841d4e1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 19:38:39 +0200 Subject: [PATCH 162/634] GtkStyle: Use new render methods underneath. This commit should probably be squashed in the future, when GtkStyleContext is on par with it, and GtkStyle is just a shallow object on top of GtkStyleContext and calling it in the default implementation methods, so all gtk_paint_* and gtk_draw_* would work. --- gtk/gtkstyle.c | 477 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 405 insertions(+), 72 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index a5566e2984..0dc5387c98 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -4528,16 +4528,15 @@ gtk_paint_hline (GtkStyle *style, gint x2, gint y) { + GtkStyleContext *context; + g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (cr != NULL); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL); + + context = gtk_widget_get_style_context (widget); cairo_save (cr); - - GTK_STYLE_GET_CLASS (style)->draw_hline (style, cr, state_type, - widget, detail, - x1, x2, y); - + gtk_render_line (context, cr, x1, y, x2, y); cairo_restore (cr); } @@ -4565,16 +4564,15 @@ gtk_paint_vline (GtkStyle *style, gint y2_, gint x) { + GtkStyleContext *context; + g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (cr != NULL); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL); + + context = gtk_widget_get_style_context (widget); cairo_save (cr); - - GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type, - widget, detail, - y1_, y2_, x); - + gtk_render_line (context, cr, x, y1_, x, y2_); cairo_restore (cr); } @@ -4606,18 +4604,34 @@ gtk_paint_shadow (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + if (width < 0 || height < 0) + { + gint w_width, w_height; + + gdk_drawable_get_size (GDK_DRAWABLE (window), &w_width, &w_height); + + if (width < 0) + width = w_width; + + if (height < 0) + height = w_height; + } + cairo_save (cr); - - GTK_STYLE_GET_CLASS (style)->draw_shadow (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height); - + gtk_render_frame (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); cairo_restore (cr); } @@ -4653,17 +4667,52 @@ gtk_paint_arrow (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + gdouble angle; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + if (arrow_type == GTK_ARROW_UP) + angle = 0; + else if (arrow_type == GTK_ARROW_RIGHT) + angle = G_PI / 2; + else if (arrow_type == GTK_ARROW_DOWN) + angle = G_PI; + else + angle = 3 * (G_PI / 2); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_arrow (style, cr, state_type, shadow_type, - widget, detail, - arrow_type, fill, x, y, width, height); + gtk_style_context_set_state (context, flags); + gtk_render_arrow (context, + cr, angle, + (gdouble) x, + (gdouble) y, + MIN ((gdouble) width, (gdouble) height)); cairo_restore (cr); } @@ -4738,16 +4787,37 @@ gtk_paint_box (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL); g_return_if_fail (cr != NULL); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); + cairo_save (cr); - - GTK_STYLE_GET_CLASS (style)->draw_box (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height); - + gtk_render_background (context, cr, x, y, width, height); + gtk_render_frame (context, cr, x, y, width, height); cairo_restore (cr); } @@ -4780,17 +4850,39 @@ gtk_paint_flat_box (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height); + gtk_style_context_set_state (context, flags); + gtk_render_background (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); cairo_restore (cr); } @@ -4823,15 +4915,40 @@ gtk_paint_check (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL); g_return_if_fail (cr != NULL); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + if (shadow_type == GTK_SHADOW_IN) + flags |= GTK_STATE_FLAG_ACTIVE; + else if (shadow_type == GTK_SHADOW_ETCHED_IN) + flags |= GTK_STATE_FLAG_INCONSISTENT; + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_check (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height); + gtk_style_context_set_state (context, flags); + gtk_render_check (context, + cr, x, y, + width, height); cairo_restore (cr); } @@ -4864,15 +4981,42 @@ gtk_paint_option (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL); g_return_if_fail (cr != NULL); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + if (shadow_type == GTK_SHADOW_IN) + flags |= GTK_STATE_FLAG_ACTIVE; + else if (shadow_type == GTK_SHADOW_ETCHED_IN) + flags |= GTK_STATE_FLAG_INCONSISTENT; + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_option (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height); + gtk_style_context_set_state (context, flags); + gtk_render_option (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); cairo_restore (cr); } @@ -4953,17 +5097,45 @@ gtk_paint_shadow_gap (GtkStyle *style, gint gap_x, gint gap_width) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height, gap_side, gap_x, gap_width); + gtk_style_context_set_state (context, flags); + gtk_render_frame_gap (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side, + (gdouble) gap_x, + (gdouble) gap_x + gap_width); cairo_restore (cr); } @@ -5002,17 +5174,51 @@ gtk_paint_box_gap (GtkStyle *style, gint gap_x, gint gap_width) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height, gap_side, gap_x, gap_width); + gtk_style_context_set_state (context, flags); + gtk_render_background (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); + + gtk_render_frame_gap (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side, + (gdouble) gap_x, + (gdouble) gap_x + gap_width); cairo_restore (cr); } @@ -5046,17 +5252,43 @@ gtk_paint_extension (GtkStyle *style, gint height, GtkPositionType gap_side) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_extension (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height, gap_side); + gtk_style_context_set_state (context, flags); + gtk_render_extension (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side); cairo_restore (cr); } @@ -5087,17 +5319,22 @@ gtk_paint_focus (GtkStyle *style, gint width, gint height) { + GtkStyleContext *context; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_focus (style, cr, state_type, - widget, detail, - x, y, width, height); + context = gtk_widget_get_style_context (widget); + + gtk_render_focus (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); cairo_restore (cr); } @@ -5132,17 +5369,38 @@ gtk_paint_slider (GtkStyle *style, gint height, GtkOrientation orientation) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_slider (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height, orientation); + gtk_style_context_set_state (context, flags); + gtk_render_slider (context, cr, x, y, width, height, orientation); cairo_restore (cr); } @@ -5176,17 +5434,40 @@ gtk_paint_handle (GtkStyle *style, gint height, GtkOrientation orientation) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_handle (style, cr, state_type, shadow_type, - widget, detail, - x, y, width, height, orientation); + gtk_style_context_set_state (context, flags); + gtk_render_handle (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + orientation); cairo_restore (cr); } @@ -5224,15 +5505,46 @@ gtk_paint_expander (GtkStyle *style, gint y, GtkExpanderStyle expander_style) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + gint size; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL); g_return_if_fail (cr != NULL); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + if (widget) + gtk_widget_style_get (widget, "expander-size", &size, NULL); + else + size = 10; + + if (expander_style == GTK_EXPANDER_EXPANDED) + flags |= GTK_STATE_FLAG_ACTIVE; + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_expander (style, cr, state_type, - widget, detail, - x, y, expander_style); + gtk_style_context_set_state (context, flags); + gtk_render_expander (context, cr, + (gdouble) x - (size / 2), + (gdouble) y - (size / 2), + (gdouble) size, + (gdouble) size); cairo_restore (cr); } @@ -5263,15 +5575,36 @@ gtk_paint_layout (GtkStyle *style, gint y, PangoLayout *layout) { + GtkStyleContext *context; + GtkStateFlags flags = 0; + g_return_if_fail (GTK_IS_STYLE (style)); - g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL); g_return_if_fail (cr != NULL); + context = gtk_widget_get_style_context (widget); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + cairo_save (cr); - GTK_STYLE_GET_CLASS (style)->draw_layout (style, cr, state_type, use_text, - widget, detail, - x, y, layout); + gtk_style_context_set_state (context, flags); + gtk_render_layout (context, cr, + (gdouble) x, + (gdouble) y, + layout); cairo_restore (cr); } From bd9bd1310bb3a55c499cc980926876720e2b61a2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 19:46:58 +0200 Subject: [PATCH 163/634] GtkStyleContext: Fix compiler warning. --- gtk/gtkstylecontext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index d0f95cf989..b12fda318c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -488,11 +488,13 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) while (link) { GtkChildClass *link_class; + const gchar *child_class; link_class = link->data; - classes = g_list_prepend (classes, - g_quark_to_string (link_class->class_quark)); link = link->next; + + child_class = g_quark_to_string (link_class->class_quark); + classes = g_list_prepend (classes, child_class); } return classes; From 66accc4184650c4bd5bc92d2703a4faf260f9900 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 19:55:19 +0200 Subject: [PATCH 164/634] GtkStyleSet: Add gtk_style_set_set_default(). This will set the default value to a given property for all possible states, such default value will only be used if the queried state doesn't have a value itself. --- gtk/gtkstyleset.c | 86 +++++++++++++++++++++++++++++++++++++---------- gtk/gtkstyleset.h | 3 ++ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 73e33be6c9..c2ca064fc5 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -42,6 +42,7 @@ struct PropertyNode struct PropertyData { + GValue default_value; GValue values[GTK_STATE_LAST]; }; @@ -227,7 +228,6 @@ gtk_style_set_lookup_property (const gchar *property_name, PropertyNode *node; GtkStyleSetClass *klass; GQuark quark; - GType t; gint i; g_return_val_if_fail (property_name != NULL, FALSE); @@ -376,20 +376,17 @@ gtk_style_set_new (void) return g_object_new (GTK_TYPE_STYLE_SET, NULL); } -void -gtk_style_set_set_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state, - const GValue *value) +static void +set_property_internal (GtkStyleSet *set, + const gchar *property, + gboolean is_default, + GtkStateType state, + const GValue *value) { GtkStyleSetPrivate *priv; PropertyNode *node; PropertyData *prop; - - g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (property != NULL); - g_return_if_fail (state < GTK_STATE_LAST); - g_return_if_fail (value != NULL); + GValue *val; node = property_node_lookup (g_quark_try_string (property)); @@ -413,14 +410,44 @@ gtk_style_set_set_property (GtkStyleSet *set, prop); } - if (G_IS_VALUE (&prop->values[state])) - g_value_reset (&prop->values[state]); + if (is_default) + val = &prop->default_value; else - g_value_init (&prop->values[state], node->property_type); + val = &prop->values[state]; - g_value_copy (value, &prop->values[state]); + if (G_IS_VALUE (val)) + g_value_reset (val); + else + g_value_init (val, node->property_type); + + g_value_copy (value, val); } +void +gtk_style_set_set_default (GtkStyleSet *set, + const gchar *property, + const GValue *value) +{ + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (property != NULL); + g_return_if_fail (value != NULL); + + set_property_internal (set, property, TRUE, GTK_STATE_NORMAL, value); +} + +void +gtk_style_set_set_property (GtkStyleSet *set, + const gchar *property, + GtkStateType state, + const GValue *value) +{ + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (property != NULL); + g_return_if_fail (state < GTK_STATE_LAST); + g_return_if_fail (value != NULL); + + set_property_internal (set, property, FALSE, state, value); +} void gtk_style_set_set_valist (GtkStyleSet *set, @@ -521,8 +548,11 @@ gtk_style_set_get_property (GtkStyleSet *set, g_value_init (value, node->property_type); if (!prop || - !G_IS_VALUE (&prop->values[state])) + (!G_IS_VALUE (&prop->values[state]) && + !G_IS_VALUE (&prop->default_value))) g_value_copy (&node->default_value, value); + else if (!G_IS_VALUE (&prop->values[state])) + g_value_copy (&prop->default_value, value); else g_value_copy (&prop->values[state], value); @@ -561,8 +591,11 @@ gtk_style_set_get_valist (GtkStyleSet *set, GINT_TO_POINTER (node->property_quark)); if (!prop || - !G_IS_VALUE (&prop->values[state])) + (!G_IS_VALUE (&prop->values[state]) && + !G_IS_VALUE (&prop->default_value))) G_VALUE_LCOPY (&node->default_value, args, 0, &error); + else if (!G_IS_VALUE (&prop->values[state])) + G_VALUE_LCOPY (&prop->default_value, args, 0, &error); else G_VALUE_LCOPY (&prop->values[state], args, 0, &error); @@ -681,6 +714,25 @@ gtk_style_set_merge (GtkStyleSet *set, &prop->values[i]); } } + + if (G_IS_VALUE (&prop_to_merge->default_value) && + (replace || !prop || !G_IS_VALUE (&prop->default_value))) + { + if (!prop) + prop = g_hash_table_lookup (priv->properties, key); + + if (!prop) + { + prop = property_data_new (); + g_hash_table_insert (priv->properties, key, prop); + } + + if (!G_IS_VALUE (&prop->default_value)) + g_value_init (&prop->default_value, G_VALUE_TYPE (&prop_to_merge->default_value)); + + g_value_copy (&prop_to_merge->default_value, + &prop->default_value); + } } } diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 16fda3ea78..750addc7ee 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -75,6 +75,9 @@ void gtk_style_set_register_property_double (const gchar *property_name, GtkStyleSet * gtk_style_set_new (void); +void gtk_style_set_set_default (GtkStyleSet *set, + const gchar *property, + const GValue *value); void gtk_style_set_set_property (GtkStyleSet *set, const gchar *property, GtkStateType state, From e899fdd973fb650b7e875af60ea6c589cfc9d00a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 19:58:07 +0200 Subject: [PATCH 165/634] GtkCssProvider: Set default value if no state pseudo-class is specified. --- gtk/gtkcssprovider.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 93604885fd..fbebb47688 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -444,6 +444,7 @@ compare_selector (GtkWidgetPath *path, if (match) { + /* Only 4 bits are actually used */ score <<= 4; score |= elem_score; } @@ -529,7 +530,12 @@ gtk_style_get_style (GtkStyleProvider *provider, g_hash_table_iter_init (&iter, info->style); while (g_hash_table_iter_next (&iter, &key, &value)) - gtk_style_set_set_property (set, key, info->state, value); + { + if (info->state == GTK_STATE_NORMAL) + gtk_style_set_set_default (set, key, value); + else + gtk_style_set_set_property (set, key, info->state, value); + } } g_array_free (priority_info, TRUE); From a323310c195d04269e14786f9c78c107b02fb2d8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 20:16:34 +0200 Subject: [PATCH 166/634] GtkNotebook: Set GtkChildClassFlags for tabs. --- gtk/gtknotebook.c | 52 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 5a765eaf6a..e7559ce49c 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -462,7 +462,9 @@ static void gtk_notebook_paint (GtkWidget *widget, cairo_t *cr); static void gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, - cairo_t *cr); + cairo_t *cr, + guint position, + gboolean is_last); static void gtk_notebook_draw_arrow (GtkNotebook *notebook, cairo_t *cr, GtkNotebookArrow arrow); @@ -2447,7 +2449,7 @@ gtk_notebook_draw (GtkWidget *widget, gtk_notebook_draw_tab (notebook, priv->cur_page, - cr); + cr, 0, FALSE); cairo_restore (cr); @@ -4895,8 +4897,8 @@ gtk_notebook_paint (GtkWidget *widget, gint x, y; guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gint gap_x = 0, gap_width = 0, step = STEP_PREV; - gboolean is_rtl; - gint tab_pos; + gboolean is_rtl, cur_page_end; + gint tab_pos, i, cur_page_pos; notebook = GTK_NOTEBOOK (widget); priv = notebook->priv; @@ -4987,6 +4989,8 @@ gtk_notebook_paint (GtkWidget *widget, showarrow = FALSE; children = gtk_notebook_search_page (notebook, NULL, step, TRUE); + i = 0; + while (children) { page = children->data; @@ -4996,8 +5000,18 @@ gtk_notebook_paint (GtkWidget *widget, continue; if (!gtk_widget_get_mapped (page->tab_label)) showarrow = TRUE; - else if (page != priv->cur_page) - gtk_notebook_draw_tab (notebook, page, cr); + else + { + if (page != priv->cur_page) + gtk_notebook_draw_tab (notebook, page, cr, i, children != NULL); + else + { + cur_page_pos = i; + cur_page_end = (children != NULL); + } + + i++; + } } if (showarrow && priv->scrollable) @@ -5013,18 +5027,22 @@ gtk_notebook_paint (GtkWidget *widget, } if (priv->operation != DRAG_OPERATION_REORDER) - gtk_notebook_draw_tab (notebook, priv->cur_page, cr); + gtk_notebook_draw_tab (notebook, priv->cur_page, cr, cur_page_pos, cur_page_end); } static void gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, - cairo_t *cr) + cairo_t *cr, + guint position, + gboolean is_last) { GtkNotebookPrivate *priv; GtkStateType state_type; GtkWidget *widget; - + GtkStyleContext *context; + GtkChildClassFlags flags = 0; + if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) || !gtk_widget_get_mapped (page->tab_label) || (page->allocation.width == 0) || (page->allocation.height == 0)) @@ -5038,6 +5056,20 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, else state_type = GTK_STATE_ACTIVE; + if (position % 2 == 0) + flags |= GTK_CHILD_CLASS_ODD; + else + flags |= GTK_CHILD_CLASS_EVEN; + + if (position == 0) + flags |= GTK_CHILD_CLASS_FIRST; + + if (is_last) + flags |= GTK_CHILD_CLASS_LAST; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_set_child_class (context, "tab", flags); + gtk_paint_extension (gtk_widget_get_style (widget), cr, state_type, GTK_SHADOW_OUT, widget, "tab", @@ -5063,6 +5095,8 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, allocation.width + 2 * focus_width, allocation.height + 2 * focus_width); } + + gtk_style_context_unset_child_class (context, "tab"); } static void From 80e01becbe38d6ba8d560d920577d19a43d40273 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 4 May 2010 21:01:35 +0200 Subject: [PATCH 167/634] Fix compilation. --- gtk/gtkwidget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8fcff94b67..2289ac2821 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13188,7 +13188,7 @@ gtk_widget_get_path (GtkWidget *widget) GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL); + g_return_val_if_fail (gtk_widget_get_realized (widget), NULL); parent = widget->priv->parent; @@ -13277,7 +13277,7 @@ gtk_widget_get_style_context (GtkWidget *widget) GTK_STYLE_PROVIDER_PRIORITY_USER); } - if (GTK_WIDGET_REALIZED (widget)) + if (gtk_widget_get_realized (widget)) { GtkWidgetPath *path; From 6906138e4549a8de05348fbbdb66c7be24afe44e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 13 Jun 2010 17:10:05 +0200 Subject: [PATCH 168/634] GtkStyleSet: Remove default value for registered properties. This should be handled at a higher level, a single default value for all states isn't that useful... --- gtk/gtkcssprovider.c | 2 +- gtk/gtkstyleset.c | 168 +++++++------------------------------------ gtk/gtkstyleset.h | 20 +----- 3 files changed, 30 insertions(+), 160 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index fbebb47688..f1e324ad6b 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -983,7 +983,7 @@ parse_rule (GtkCssProvider *css_provider, value_str = g_strstrip (scanner->value.v_identifier); - if (gtk_style_set_lookup_property (prop, &prop_type, NULL) && + if (gtk_style_set_lookup_property (prop, &prop_type) && parse_value (prop_type, value_str, &value)) { GValue *val; diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index c2ca064fc5..2bc91aae51 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -37,7 +37,6 @@ struct PropertyNode { GQuark property_quark; GType property_type; - GValue default_value; }; struct PropertyData @@ -67,24 +66,18 @@ static void gtk_style_set_class_init (GtkStyleSetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkColor black = { 0, 0, 0, 0 }; - GdkColor white = { 0, 65535, 65535, 65535 }; - PangoFontDescription *font_desc; - GtkBorder padding = { 0 }; object_class->finalize = gtk_style_set_finalize; /* Initialize default property set */ - gtk_style_set_register_property_color ("foreground-color", &white); - gtk_style_set_register_property_color ("background-color", &black); - gtk_style_set_register_property_color ("text-color", &white); - gtk_style_set_register_property_color ("base-color", &white); + gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR); + gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR); + gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR); + gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR); - font_desc = pango_font_description_from_string ("Sans 10"); - gtk_style_set_register_property_font ("font", font_desc); - pango_font_description_free (font_desc); + gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION); - gtk_style_set_register_property_border ("padding", &padding); + gtk_style_set_register_property ("padding", GTK_TYPE_BORDER); g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } @@ -178,16 +171,14 @@ property_node_lookup (GQuark quark) /* Property registration functions */ void gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value) + GType type) { PropertyNode *node, new = { 0 }; GQuark quark; gint i; g_return_if_fail (property_name != NULL); - g_return_if_fail (default_value != NULL); - g_return_if_fail (type == G_VALUE_TYPE (default_value)); + g_return_if_fail (type != 0); if (G_UNLIKELY (!properties)) properties = g_array_new (FALSE, TRUE, sizeof (PropertyNode)); @@ -206,9 +197,6 @@ gtk_style_set_register_property (const gchar *property_name, new.property_quark = quark; new.property_type = type; - g_value_init (&new.default_value, type); - g_value_copy (default_value, &new.default_value); - for (i = 0; i < properties->len; i++) { node = &g_array_index (properties, PropertyNode, i); @@ -222,11 +210,11 @@ gtk_style_set_register_property (const gchar *property_name, gboolean gtk_style_set_lookup_property (const gchar *property_name, - GType *type, - GValue *default_value) + GType *type) { PropertyNode *node; GtkStyleSetClass *klass; + gboolean found = FALSE; GQuark quark; gint i; @@ -250,15 +238,8 @@ gtk_style_set_lookup_property (const gchar *property_name, if (type) *type = node->property_type; - if (default_value) - { - g_value_init (default_value, G_VALUE_TYPE (&node->default_value)); - g_value_copy (&node->default_value, default_value); - } - - g_type_class_unref (klass); - - return TRUE; + found = TRUE; + break; } else if (node->property_quark > quark) break; @@ -266,106 +247,7 @@ gtk_style_set_lookup_property (const gchar *property_name, g_type_class_unref (klass); - return FALSE; -} - -void -gtk_style_set_register_property_color (const gchar *property_name, - GdkColor *initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - g_return_if_fail (initial_value != NULL); - - g_value_init (&value, GDK_TYPE_COLOR); - g_value_set_boxed (&value, initial_value); - - gtk_style_set_register_property (property_name, GDK_TYPE_COLOR, &value); - - g_value_unset (&value); -} - -void -gtk_style_set_register_property_font (const gchar *property_name, - PangoFontDescription *initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - g_return_if_fail (initial_value != NULL); - - g_value_init (&value, PANGO_TYPE_FONT_DESCRIPTION); - g_value_set_boxed (&value, initial_value); - - gtk_style_set_register_property (property_name, PANGO_TYPE_FONT_DESCRIPTION, &value); - - g_value_unset (&value); -} - -void -gtk_style_set_register_property_border (const gchar *property_name, - GtkBorder *initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - g_return_if_fail (initial_value != NULL); - - g_value_init (&value, GTK_TYPE_BORDER); - g_value_set_boxed (&value, initial_value); - - gtk_style_set_register_property (property_name, GTK_TYPE_BORDER, &value); - - g_value_unset (&value); -} - -void -gtk_style_set_register_property_int (const gchar *property_name, - gint initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - - g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, initial_value); - - gtk_style_set_register_property (property_name, G_TYPE_INT, &value); - - g_value_unset (&value); -} - -void -gtk_style_set_register_property_uint (const gchar *property_name, - guint initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, initial_value); - - gtk_style_set_register_property (property_name, G_TYPE_UINT, &value); - - g_value_unset (&value); -} - -void -gtk_style_set_register_property_double (const gchar *property_name, - gdouble initial_value) -{ - GValue value = { 0 }; - - g_return_if_fail (property_name != NULL); - - g_value_init (&value, G_TYPE_DOUBLE); - g_value_set_double (&value, initial_value); - - gtk_style_set_register_property (property_name, G_TYPE_DOUBLE, &value); - - g_value_unset (&value); + return found; } /* GtkStyleSet methods */ @@ -545,13 +427,12 @@ gtk_style_set_get_property (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); + if (!prop) + return FALSE; + g_value_init (value, node->property_type); - if (!prop || - (!G_IS_VALUE (&prop->values[state]) && - !G_IS_VALUE (&prop->default_value))) - g_value_copy (&node->default_value, value); - else if (!G_IS_VALUE (&prop->values[state])) + if (!G_IS_VALUE (&prop->values[state])) g_value_copy (&prop->default_value, value); else g_value_copy (&prop->values[state], value); @@ -590,10 +471,15 @@ gtk_style_set_get_valist (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop || - (!G_IS_VALUE (&prop->values[state]) && - !G_IS_VALUE (&prop->default_value))) - G_VALUE_LCOPY (&node->default_value, args, 0, &error); + if (!prop) + { + GValue *empty_value = { 0 }; + + g_warning ("No value for style property \"%s\"", property_name); + + g_value_init (&empty_value, node->property_type); + G_VALUE_LCOPY (&empty_value, args, 0, &error); + } else if (!G_IS_VALUE (&prop->values[state])) G_VALUE_LCOPY (&prop->default_value, args, 0, &error); else @@ -602,7 +488,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, if (error) { g_warning ("Could not get style property \"%s\": %s", property_name, error); - g_free (error); + g_free (error); break; } diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 750addc7ee..d14deb89d1 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -53,25 +53,9 @@ GType gtk_style_set_get_type (void) G_GNUC_CONST; /* Functions to register style properties */ void gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value); + GType type); gboolean gtk_style_set_lookup_property (const gchar *property_name, - GType *type, - GValue *default_value); - -void gtk_style_set_register_property_color (const gchar *property_name, - GdkColor *default_value); -void gtk_style_set_register_property_font (const gchar *property_name, - PangoFontDescription *initial_value); -void gtk_style_set_register_property_border (const gchar *property_name, - GtkBorder *initial_value); -void gtk_style_set_register_property_int (const gchar *property_name, - gint default_value); -void gtk_style_set_register_property_uint (const gchar *property_name, - guint default_value); -void gtk_style_set_register_property_double (const gchar *property_name, - gdouble default_value); - + GType *type); GtkStyleSet * gtk_style_set_new (void); From 327a9fc66a2d8bf1f4814d608f1a95fdd6855bff Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 13 Jun 2010 17:26:18 +0200 Subject: [PATCH 169/634] GtkWidget: Generate GtkWidgetPath on set_parent. There's no need to wait for realize() to have the right widget style. --- gtk/gtkwidget.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 2289ac2821..75ef3c9d39 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4198,17 +4198,6 @@ gtk_widget_realize (GtkWidget *widget) gdk_window_set_support_multidevice (priv->window, TRUE); _gtk_widget_enable_device_events (widget); - - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - if (context) - { - GtkWidgetPath *path; - - path = gtk_widget_get_path (widget); - gtk_style_context_set_path (context, path); - gtk_widget_path_free (path); - } } } @@ -7221,6 +7210,7 @@ gtk_widget_set_parent (GtkWidget *widget, { GtkWidgetPrivate *priv; GtkStateData data; + GtkStyleContext *context; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (parent)); @@ -7294,6 +7284,17 @@ gtk_widget_set_parent (GtkWidget *widget, { gtk_widget_queue_compute_expand (parent); } + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + if (context) + { + GtkWidgetPath *path; + + path = gtk_widget_get_path (widget); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); + } } /** @@ -13188,7 +13189,7 @@ gtk_widget_get_path (GtkWidget *widget) GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - g_return_val_if_fail (gtk_widget_get_realized (widget), NULL); + g_return_val_if_fail ((widget->parent || gtk_widget_is_toplevel (widget)), NULL); parent = widget->priv->parent; @@ -13277,7 +13278,8 @@ gtk_widget_get_style_context (GtkWidget *widget) GTK_STYLE_PROVIDER_PRIORITY_USER); } - if (gtk_widget_get_realized (widget)) + if (widget->parent || + gtk_widget_is_toplevel (widget)) { GtkWidgetPath *path; From 66d1cb805427935f2637bf0455e473ad3cfc1dab Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 13 Jun 2010 17:31:22 +0200 Subject: [PATCH 170/634] GtkStyleSet: Register GtkThemingEngine type. This has been also hooked up to the CSS provider, which parses the "engine" value to load the corresponding module. --- gtk/gtkcssprovider.c | 8 ++++++++ gtk/gtkstylecontext.c | 4 ++++ gtk/gtkstyleset.c | 2 ++ gtk/gtkthemingengine.c | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f1e324ad6b..e61ea736a8 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -905,6 +905,14 @@ parse_value (GType type, g_value_set_double (value, g_ascii_strtod (value_str, NULL)); return TRUE; } + else if (type == GTK_TYPE_THEMING_ENGINE) + { + GtkThemingEngine *engine; + + engine = gtk_theming_engine_load (value_str); + g_value_set_object (value, engine); + return TRUE; + } else g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index b12fda318c..848d8093e8 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -145,6 +145,10 @@ rebuild_properties (GtkStyleContext *context) g_object_unref (provider_style); } } + + gtk_style_set_get (priv->store, GTK_STATE_NORMAL, + "engine", &priv->theming_engine, + NULL); } void diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 2bc91aae51..5d8a856bc1 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -25,6 +25,7 @@ #include "gtkstyleprovider.h" #include "gtkstyleset.h" #include "gtkprivate.h" +#include "gtkthemingengine.h" #include "gtkintl.h" #include "gtkalias.h" @@ -78,6 +79,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION); gtk_style_set_register_property ("padding", GTK_TYPE_BORDER); + gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE); g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 3a019dc995..5d4c8ce7cc 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -393,7 +393,7 @@ gtk_theming_engine_load (const gchar *name) if (!engine) { - if (!default_engine) + if (G_UNLIKELY (!default_engine)) default_engine = g_object_new (GTK_TYPE_THEMING_ENGINE, NULL); engine = default_engine; From 814957021f5223b99ceb4b23a953c0eb09f30dcc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 13 Jun 2010 17:33:47 +0200 Subject: [PATCH 171/634] Fix compile warning. --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 848d8093e8..d760f7bc71 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -498,7 +498,7 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) link = link->next; child_class = g_quark_to_string (link_class->class_quark); - classes = g_list_prepend (classes, child_class); + classes = g_list_prepend (classes, (gchar *) child_class); } return classes; From aa5ec97cac8d005d58df9d0caf2103faba02628f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:42:48 +0200 Subject: [PATCH 172/634] GtkCssProvider: Make additions to parse_value() less error prone. --- gtk/gtkcssprovider.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index e61ea736a8..acc73c0f75 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -874,6 +874,8 @@ parse_value (GType type, const gchar *value_str, GValue *value) { + gboolean parsed = TRUE; + g_value_init (value, type); if (type == GDK_TYPE_COLOR) @@ -884,7 +886,6 @@ parse_value (GType type, return FALSE; g_value_set_boxed (value, &color); - return TRUE; } else if (type == PANGO_TYPE_FONT_DESCRIPTION) { @@ -892,31 +893,25 @@ parse_value (GType type, font_desc = pango_font_description_from_string (value_str); g_value_take_boxed (value, font_desc); - - return TRUE; } else if (type == G_TYPE_INT) - { - g_value_set_int (value, atoi (value_str)); - return TRUE; - } + g_value_set_int (value, atoi (value_str)); else if (type == G_TYPE_DOUBLE) - { - g_value_set_double (value, g_ascii_strtod (value_str, NULL)); - return TRUE; - } + g_value_set_double (value, g_ascii_strtod (value_str, NULL)); else if (type == GTK_TYPE_THEMING_ENGINE) { GtkThemingEngine *engine; engine = gtk_theming_engine_load (value_str); g_value_set_object (value, engine); - return TRUE; } else - g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); + { + g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); + parsed = FALSE; + } - return FALSE; + return parsed; } static GTokenType From ff05cc48499a6f3f446ea839987f73384e781d52 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:46:31 +0200 Subject: [PATCH 173/634] GtkCssProvider: Parse boolean values. --- gtk/gtkcssprovider.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index acc73c0f75..fef896c3e1 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -596,7 +596,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z; - priv->scanner->config->scan_identifier_1char = FALSE; + priv->scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) { @@ -894,6 +894,14 @@ parse_value (GType type, font_desc = pango_font_description_from_string (value_str); g_value_take_boxed (value, font_desc); } + else if (type == G_TYPE_BOOLEAN) + { + if (value_str[0] == '1' || + g_ascii_strcasecmp (value_str, "true") == 0) + g_value_set_boolean (value, TRUE); + else + g_value_set_boolean (value, FALSE); + } else if (type == G_TYPE_INT) g_value_set_int (value, atoi (value_str)); else if (type == G_TYPE_DOUBLE) From eec75f1f592dd043e50a4d0701543fe59d20d65e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:49:06 +0200 Subject: [PATCH 174/634] GtkCssProvider: Ensure each scope has its parser config. --- gtk/gtkcssprovider.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index fef896c3e1..e354675c61 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -604,12 +604,16 @@ css_provider_apply_scope (GtkCssProvider *css_provider, priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } - else + else if (scope == SCOPE_PSEUDO_CLASS || + scope == SCOPE_NTH_CHILD || + scope == SCOPE_DECLARATION) { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = FALSE; } + else + g_assert_not_reached (); priv->scanner->config->scan_float = FALSE; } From eaddc9f254649cd2607e428c023858da17fe5569 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:52:34 +0200 Subject: [PATCH 175/634] GtkCssProvider: refactor out selector matching. --- gtk/gtkcssprovider.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index e354675c61..dace8fe364 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -472,17 +472,15 @@ struct StylePriorityInfo GtkStateType state; }; -static GtkStyleSet * -gtk_style_get_style (GtkStyleProvider *provider, - GtkWidgetPath *path) +static GArray * +css_provider_get_selectors (GtkCssProvider *css_provider, + GtkWidgetPath *path) { GtkCssProviderPrivate *priv; - GtkStyleSet *set; GArray *priority_info; guint i, j; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (provider); - set = gtk_style_set_new (); + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); priority_info = g_array_new (FALSE, FALSE, sizeof (StylePriorityInfo)); for (i = 0; i < priv->selectors_info->len; i++) @@ -520,6 +518,23 @@ gtk_style_get_style (GtkStyleProvider *provider, g_array_append_val (priority_info, new); } + return priority_info; +} + +static GtkStyleSet * +gtk_css_provider_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) +{ + GtkCssProviderPrivate *priv; + GtkStyleSet *set; + GArray *priority_info; + guint i; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (provider); + set = gtk_style_set_new (); + + priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path); + for (i = 0; i < priority_info->len; i++) { StylePriorityInfo *info; From 6990a012999be09b277cb0048f9416d08fec3836 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:58:16 +0200 Subject: [PATCH 176/634] GtkStyleProvider: Add method to get widget style properties. --- gtk/gtkstyleprovider.c | 23 ++++++++++++++++++++++- gtk/gtkstyleprovider.h | 16 +++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 606f4a130e..e67d4471c2 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -44,7 +44,6 @@ gtk_style_provider_get_type (void) static void gtk_style_provider_iface_init (gpointer g_iface) { - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); } GtkStyleSet * @@ -63,5 +62,27 @@ gtk_style_provider_get_style (GtkStyleProvider *provider, return iface->get_style (provider, path); } +gboolean +gtk_style_provider_get_style_property (GtkStyleProvider *provider, + GtkWidgetPath *widget_path, + const gchar *property_name, + GValue *value) +{ + GtkStyleProviderIface *iface; + + g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE); + g_return_val_if_fail (widget_path != NULL, FALSE); + g_return_val_if_fail (property_name != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + iface = GTK_STYLE_PROVIDER_GET_IFACE (provider); + + if (!iface->get_style_property) + return FALSE; + + return iface->get_style_property (provider, widget_path, property_name, value); +} + + #define __GTK_STYLE_PROVIDER_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 35a7e242d6..5fc30ed42b 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -40,19 +40,17 @@ G_BEGIN_DECLS typedef struct GtkStyleProviderIface GtkStyleProviderIface; typedef struct GtkStyleProvider GtkStyleProvider; /* dummy typedef */ -typedef enum { - GTK_SELECTOR_TYPE_PATH, - GTK_SELECTOR_TYPE_NAME, - GTK_SELECTOR_TYPE_CLASS_PATH, - GTK_SELECTOR_TYPE_CLASS_NAME -} GtkSelectorType; - struct GtkStyleProviderIface { GTypeInterface g_iface; GtkStyleSet * (* get_style) (GtkStyleProvider *provider, GtkWidgetPath *path); + + gboolean (* get_style_property) (GtkStyleProvider *provider, + GtkWidgetPath *path, + const gchar *property_name, + GValue *value); }; GType gtk_style_provider_get_type (void) G_GNUC_CONST; @@ -60,6 +58,10 @@ GType gtk_style_provider_get_type (void) G_GNUC_CONST; GtkStyleSet *gtk_style_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path); +gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, + GtkWidgetPath *path, + const gchar *property_name, + GValue *value); G_END_DECLS From 37335fbb6f572813b9af9524902c9161abfcae4c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 16:59:14 +0200 Subject: [PATCH 177/634] GtkWidgetPath: Add methods to check topmost widget type. --- gtk/gtkwidgetpath.c | 29 +++++++++++++++++++++++++++++ gtk/gtkwidgetpath.h | 8 ++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 2573273616..c39b4c75d1 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -305,6 +305,35 @@ gtk_widget_path_iter_has_region (GtkWidgetPath *path, return TRUE; } +GType +gtk_widget_path_get_widget_type (const GtkWidgetPath *path) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, G_TYPE_INVALID); + + elem = &g_array_index (path->elems, GtkPathElement, 0); + return elem->type; +} + +gboolean +gtk_widget_path_is_type (const GtkWidgetPath *path, + GType type) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); + + elem = &g_array_index (path->elems, GtkPathElement, 0); + + if (elem->type == type || + g_type_is_a (elem->type, type)) + return TRUE; + + return FALSE; +} + gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type) diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 7020c826a3..9e2d0edf1e 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -68,8 +68,12 @@ gboolean gtk_widget_path_iter_has_region (GtkWidgetPath *path, const gchar *name, GtkChildClassFlags *flags); -gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, - GType type); +GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); + +gboolean gtk_widget_path_is_type (const GtkWidgetPath *path, + GType type); +gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, + GType type); G_END_DECLS From bf12227435e1cc8858a33148f820a8a29f895059 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 17:04:03 +0200 Subject: [PATCH 178/634] GtkCssProvider: Implement GtkStyleProvider->get_style_property Style properties in the resource files are something like: -GtkComboBox-appears-as-string -GtkEntry-icon-prelight Following the usual naming spec for extensions to CSS. --- gtk/gtkcssprovider.c | 93 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index dace8fe364..8280746e35 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -123,6 +123,8 @@ static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); static void css_provider_apply_scope (GtkCssProvider *css_provider, ParserScope scope); +static gboolean css_provider_parse_value (const gchar *value_str, + GValue *value); G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, @@ -546,6 +548,11 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, while (g_hash_table_iter_next (&iter, &key, &value)) { + gchar *prop = key; + + if (prop[0] == '-') + continue; + if (info->state == GTK_STATE_NORMAL) gtk_style_set_set_default (set, key, value); else @@ -558,10 +565,57 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, return set; } +static gboolean +gtk_css_provider_get_style_property (GtkStyleProvider *provider, + GtkWidgetPath *path, + const gchar *property_name, + GValue *value) +{ + GArray *priority_info; + gboolean found = FALSE; + gchar *prop_name; + GType path_type; + gint i; + + path_type = gtk_widget_path_get_widget_type (path); + + prop_name = g_strdup_printf ("-%s-%s", + g_type_name (path_type), + property_name); + + priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path); + + for (i = priority_info->len - 1; i >= 0; i--) + { + StylePriorityInfo *info; + GValue *val; + + info = &g_array_index (priority_info, StylePriorityInfo, i); + val = g_hash_table_lookup (info->style, prop_name); + + if (val) + { + const gchar *val_str; + + val_str = g_value_get_string (val); + found = TRUE; + + css_provider_parse_value (val_str, value); + break; + } + } + + g_array_free (priority_info, TRUE); + g_free (prop_name); + + return found; +} + static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface) { - iface->get_style = gtk_style_get_style; + iface->get_style = gtk_css_provider_get_style; + iface->get_style_property = gtk_css_provider_get_style_property; } static void @@ -623,7 +677,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, scope == SCOPE_NTH_CHILD || scope == SCOPE_DECLARATION) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "-" G_CSET_A_2_Z; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = FALSE; } @@ -889,13 +943,13 @@ parse_selector (GtkCssProvider *css_provider, } static gboolean -parse_value (GType type, - const gchar *value_str, - GValue *value) +css_provider_parse_value (const gchar *value_str, + GValue *value) { + GType type; gboolean parsed = TRUE; - g_value_init (value, type); + type = G_VALUE_TYPE (value); if (type == GDK_TYPE_COLOR) { @@ -989,7 +1043,6 @@ parse_rule (GtkCssProvider *css_provider, while (scanner->token == G_TOKEN_IDENTIFIER) { const gchar *value_str = NULL; - GValue value = { 0 }; GType prop_type; gchar *prop; @@ -1013,16 +1066,34 @@ parse_rule (GtkCssProvider *css_provider, value_str = g_strstrip (scanner->value.v_identifier); - if (gtk_style_set_lookup_property (prop, &prop_type) && - parse_value (prop_type, value_str, &value)) + if (prop[0] == '-' && + g_ascii_isupper (prop[1])) + { + GValue *val; + + val = g_slice_new0 (GValue); + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, value_str); + + g_hash_table_insert (priv->cur_properties, prop, val); + } + else if (gtk_style_set_lookup_property (prop, &prop_type)) { GValue *val; val = g_slice_new0 (GValue); g_value_init (val, prop_type); - g_value_copy (&value, val); - g_hash_table_insert (priv->cur_properties, prop, val); + if (css_provider_parse_value (value_str, val)) + g_hash_table_insert (priv->cur_properties, prop, val); + else + { + g_value_unset (val); + g_slice_free (GValue, val); + g_free (prop); + + return G_TOKEN_IDENTIFIER; + } } else g_free (prop); From 03370c6e0cd64154dc7288bd168b509250120d27 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 17:11:37 +0200 Subject: [PATCH 179/634] GtkStyleContext: Add methods to get style property values. --- gtk/gtkstylecontext.c | 181 +++++++++++++++++++++++++++++++++++++++++- gtk/gtkstylecontext.h | 9 +++ 2 files changed, 187 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index d760f7bc71..91ff093df4 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -20,17 +20,20 @@ #include "config.h" #include +#include #include "gtkstylecontext.h" #include "gtktypebuiltins.h" #include "gtkthemingengine.h" #include "gtkintl.h" +#include "gtkwidget.h" #include "gtkalias.h" typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; typedef struct GtkChildClass GtkChildClass; +typedef struct PropertyValue PropertyValue; struct GtkChildClass { @@ -44,12 +47,23 @@ struct GtkStyleProviderData guint priority; }; +struct PropertyValue +{ + GType widget_type; + GParamSpec *pspec; + GValue value; +}; + struct GtkStyleContextPrivate { GList *providers; + GList *providers_last; + GtkStyleSet *store; GtkWidgetPath *widget_path; + GArray *property_cache; + GtkStateFlags state_flags; GList *style_classes; GList *child_style_classes; @@ -104,6 +118,30 @@ style_provider_data_free (GtkStyleProviderData *data) g_slice_free (GtkStyleProviderData, data); } +static void +clear_property_cache (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + if (priv->property_cache) + { + guint i; + + for (i = 0; i < priv->property_cache->len; i++) + { + PropertyValue *node = &g_array_index (priv->property_cache, PropertyValue, i); + + g_param_spec_unref (node->pspec); + g_value_unset (&node->value); + } + + g_array_free (priv->property_cache, TRUE); + priv->property_cache = NULL; + } +} + static void gtk_style_context_finalize (GObject *object) { @@ -114,6 +152,8 @@ gtk_style_context_finalize (GObject *object) g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); g_list_free (priv->providers); + clear_property_cache (GTK_STYLE_CONTEXT (object)); + G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); } @@ -205,8 +245,13 @@ gtk_style_context_add_provider (GtkStyleContext *context, if (!added) priv->providers = g_list_append (priv->providers, new_data); + priv->providers_last = g_list_last (priv->providers); + if (priv->widget_path) - rebuild_properties (context); + { + rebuild_properties (context); + clear_property_cache (context); + } } void @@ -243,8 +288,16 @@ gtk_style_context_remove_provider (GtkStyleContext *context, list = list->next; } - if (removed && priv->widget_path) - rebuild_properties (context); + if (removed) + { + priv->providers_last = g_list_last (priv->providers); + + if (priv->widget_path) + { + rebuild_properties (context); + clear_property_cache (context); + } + } } void @@ -371,6 +424,7 @@ gtk_style_context_set_path (GtkStyleContext *context, { priv->widget_path = gtk_widget_path_copy (path); rebuild_properties (context); + clear_property_cache (context); } } @@ -623,6 +677,127 @@ gtk_style_context_has_child_class (GtkStyleContext *context, return FALSE; } +static gint +style_property_values_cmp (gconstpointer bsearch_node1, + gconstpointer bsearch_node2) +{ + const PropertyValue *val1 = bsearch_node1; + const PropertyValue *val2 = bsearch_node2; + + if (val1->widget_type == val2->widget_type) + return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1; + else + return val1->widget_type < val2->widget_type ? -1 : 1; +} + +const GValue * +_gtk_style_context_peek_style_property (GtkStyleContext *context, + GType widget_type, + GParamSpec *pspec) +{ + GtkStyleContextPrivate *priv; + PropertyValue *pcache, key = { 0 }; + GList *list; + guint i; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + key.widget_type = widget_type; + key.pspec = pspec; + + /* need value cache array */ + if (!priv->property_cache) + priv->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue)); + else + { + pcache = bsearch (&key, + priv->property_cache->data, priv->property_cache->len, + sizeof (PropertyValue), style_property_values_cmp); + if (pcache) + return &pcache->value; + } + + i = 0; + while (i < priv->property_cache->len && + style_property_values_cmp (&key, &g_array_index (priv->property_cache, PropertyValue, i)) >= 0) + i++; + + g_array_insert_val (priv->property_cache, i, key); + pcache = &g_array_index (priv->property_cache, PropertyValue, i); + + /* cache miss, initialize value type, then set contents */ + g_param_spec_ref (pcache->pspec); + g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + + if (priv->widget_path) + { + for (list = priv->providers_last; list; list = list->prev) + { + GtkStyleProviderData *data; + + data = list->data; + + if (gtk_style_provider_get_style_property (data->provider, priv->widget_path, + pspec->name, &pcache->value)) + return &pcache->value; + } + } + + /* not supplied by any provider, revert to default */ + g_param_value_set_default (pspec, &pcache->value); + + return &pcache->value; +} + +void +gtk_style_context_get_style_property (GtkStyleContext *context, + const gchar *property_name, + GValue *value) +{ + GtkStyleContextPrivate *priv; + GtkWidgetClass *widget_class; + GParamSpec *pspec; + const GValue *peek_value; + GType widget_type; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (property_name != NULL); + g_return_if_fail (value != NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + if (!priv->widget_path) + return; + + widget_type = gtk_widget_path_get_widget_type (priv->widget_path); + + widget_class = g_type_class_ref (widget_type); + pspec = gtk_widget_class_find_style_property (widget_class, property_name); + g_type_class_unref (widget_class); + + if (!pspec) + { + g_warning ("%s: widget class `%s' has no style property named `%s'", + G_STRLOC, + g_type_name (widget_type), + property_name); + return; + } + + peek_value = _gtk_style_context_peek_style_property (context, + widget_type, + pspec); + + if (G_VALUE_TYPE (value) == G_VALUE_TYPE (peek_value)) + g_value_copy (peek_value, value); + else if (g_value_type_transformable (G_VALUE_TYPE (peek_value), G_VALUE_TYPE (value))) + g_value_transform (peek_value, value); + else + g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'", + pspec->name, + G_VALUE_TYPE_NAME (peek_value), + G_VALUE_TYPE_NAME (value)); +} /* Paint methods */ void diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 2ef9ee12c9..a968f00c9a 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -95,6 +95,15 @@ gboolean gtk_style_context_has_child_class (GtkStyleContext *context, const gchar *class_name, GtkChildClassFlags *flags_return); +void gtk_style_context_get_style_property (GtkStyleContext *context, + const gchar *property_name, + GValue *value); + +/* Semi-private API */ +const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, + GType widget_type, + GParamSpec *pspec); + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, From 22bae20ce8d986a0439ec72b4476c7ea653acb2a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 17:16:21 +0200 Subject: [PATCH 180/634] GtkWidget: Hook up widget style property querying to style context. --- gtk/gtkwidget.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 75ef3c9d39..ed3a8fd182 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -10680,15 +10680,12 @@ gtk_widget_style_get_property (GtkWidget *widget, const gchar *property_name, GValue *value) { - GtkWidgetPrivate *priv; GParamSpec *pspec; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (property_name != NULL); g_return_if_fail (G_IS_VALUE (value)); - priv = widget->priv; - g_object_ref (widget); pspec = g_param_spec_pool_lookup (style_property_spec_pool, property_name, @@ -10701,12 +10698,13 @@ gtk_widget_style_get_property (GtkWidget *widget, property_name); else { + GtkStyleContext *context; const GValue *peek_value; - peek_value = _gtk_style_peek_property_value (priv->style, - G_OBJECT_TYPE (widget), - pspec, - (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser)); + context = gtk_widget_get_style_context (widget); + peek_value = _gtk_style_context_peek_style_property (context, + G_OBJECT_TYPE (widget), + pspec); /* auto-conversion of the caller's value type */ @@ -10739,14 +10737,13 @@ gtk_widget_style_get_valist (GtkWidget *widget, const gchar *first_property_name, va_list var_args) { - GtkWidgetPrivate *priv; + GtkStyleContext *context; const gchar *name; g_return_if_fail (GTK_IS_WIDGET (widget)); - priv = widget->priv; - g_object_ref (widget); + context = gtk_widget_get_style_context (widget); name = first_property_name; while (name) @@ -10769,10 +10766,10 @@ gtk_widget_style_get_valist (GtkWidget *widget, } /* style pspecs are always readable so we can spare that check here */ - peek_value = _gtk_style_peek_property_value (priv->style, - G_OBJECT_TYPE (widget), - pspec, - (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser)); + peek_value = _gtk_style_context_peek_style_property (context, + G_OBJECT_TYPE (widget), + pspec); + G_VALUE_LCOPY (peek_value, var_args, 0, &error); if (error) { From 6c91ba1cc263c40989bcb67a4e27154a3711d303 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Jun 2010 17:25:53 +0200 Subject: [PATCH 181/634] GtkWidget: Do not reset GtkStyleContext per get_style_context(). --- gtk/gtkwidget.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ed3a8fd182..3235f5c13b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13271,18 +13271,19 @@ gtk_widget_get_style_context (GtkWidget *widget) g_object_unref (css_file); } - gtk_style_context_add_provider (context, css_provider, + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); - } - if (widget->parent || - gtk_widget_is_toplevel (widget)) - { - GtkWidgetPath *path; + if (widget->parent || + gtk_widget_is_toplevel (widget)) + { + GtkWidgetPath *path; - path = gtk_widget_get_path (widget); - gtk_style_context_set_path (context, path); - gtk_widget_path_free (path); + path = gtk_widget_get_path (widget); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); + } } return context; From 1d4687675fc12bd4cf399cac8ab9c85d55e3c75c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 19 Jun 2010 16:04:30 +0200 Subject: [PATCH 182/634] GtkCssProvider: set scanner->input_name. --- gtk/gtkcssprovider.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 8280746e35..64883d0258 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -84,6 +84,8 @@ struct SelectorStyleInfo struct GtkCssProviderPrivate { GScanner *scanner; + const gchar *filename; + GPtrArray *selectors_info; /* Current parser state */ @@ -293,7 +295,6 @@ gtk_css_provider_init (GtkCssProvider *css_provider) priv->selectors_info = g_ptr_array_new_with_free_func ((GDestroyNotify) selector_style_info_free); scanner = g_scanner_new (NULL); - /* scanner->input_name = path; */ g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "active", GUINT_TO_POINTER (GTK_STATE_ACTIVE)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "prelight", GUINT_TO_POINTER (GTK_STATE_PRELIGHT)); @@ -624,7 +625,9 @@ gtk_css_provider_finalize (GObject *object) GtkCssProviderPrivate *priv; priv = GTK_CSS_PROVIDER_GET_PRIVATE (object); + g_scanner_destroy (priv->scanner); + g_free (priv->filename); g_ptr_array_free (priv->selectors_info, TRUE); @@ -1169,6 +1172,7 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); css_provider_reset_parser (css_provider); + priv->scanner->input_name = "-"; g_scanner_input_text (priv->scanner, data, (guint) length); parse_stylesheet (css_provider); @@ -1202,7 +1206,11 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, if (priv->selectors_info->len > 0) g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); + g_free (priv->filename); + priv->filename = g_file_get_path (file); + css_provider_reset_parser (css_provider); + priv->scanner->input_name = priv->filename; g_scanner_input_text (priv->scanner, data, (guint) length); parse_stylesheet (css_provider); From 2cd4ff421547e648a615396df6afc28ffa8e3b19 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 18:46:59 +0200 Subject: [PATCH 183/634] GtkCssProvider: Fix compile warning. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 64883d0258..d764edce25 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -84,7 +84,7 @@ struct SelectorStyleInfo struct GtkCssProviderPrivate { GScanner *scanner; - const gchar *filename; + gchar *filename; GPtrArray *selectors_info; From b50c88d1703547b46ec890e2a4bd8e432cfb256b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 18:49:15 +0200 Subject: [PATCH 184/634] GtkCssProvider: Plug memory leak. --- gtk/gtkcssprovider.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d764edce25..dc41a99b03 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -861,8 +861,6 @@ parse_selector (GtkCssProvider *css_provider, scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; - path = selector_path_new (); - while (scanner->token == G_TOKEN_IDENTIFIER) { if (g_ascii_isupper (scanner->value.v_identifier[0])) @@ -940,8 +938,6 @@ parse_selector (GtkCssProvider *css_provider, return G_TOKEN_LEFT_CURLY; } - *selector_out = path; - return G_TOKEN_NONE; } From d748ea983de123c065ede5bfb3118f54563416b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 19:24:19 +0200 Subject: [PATCH 185/634] GtkWidgetPath: Add to gtkalias. --- gtk/gtkwidgetpath.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index c39b4c75d1..2e78b7cdd5 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -356,3 +356,6 @@ gtk_widget_path_has_parent (const GtkWidgetPath *path, return FALSE; } + +#define __GTK_WIDGET_PATH_C__ +#include "gtkaliasdef.c" From 7094213df92e1ac72e294de58dad62124e7dd155 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 19:29:51 +0200 Subject: [PATCH 186/634] Add GtkSymbolicColor. This is a small boxed struct used to store symbolic colors so they can be resolved at a later point. --- gtk/Makefile.am | 2 + gtk/gtksymboliccolor.c | 153 +++++++++++++++++++++++++++++++++++++++++ gtk/gtksymboliccolor.h | 49 +++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 gtk/gtksymboliccolor.c create mode 100644 gtk/gtksymboliccolor.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 918e6329cc..0d4de0636f 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -297,6 +297,7 @@ gtk_public_h_sources = \ gtkstyleset.h \ gtkstyle.h \ gtkswitch.h \ + gtksymboliccolor.h \ gtktable.h \ gtktearoffmenuitem.h \ gtktestutils.h \ @@ -599,6 +600,7 @@ gtk_base_c_sources = \ gtkstyleset.c \ gtkstyle.c \ gtkswitch.c \ + gtksymboliccolor.c \ gtktable.c \ gtktearoffmenuitem.c \ gtktestutils.c \ diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c new file mode 100644 index 0000000000..7a8513d24e --- /dev/null +++ b/gtk/gtksymboliccolor.c @@ -0,0 +1,153 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtksymboliccolor.h" +#include "gtkstyleset.h" +#include "gtkintl.h" + +/* Symbolic colors */ +typedef enum { + COLOR_TYPE_LITERAL, + COLOR_TYPE_NAME, + COLOR_TYPE_SHADE, + COLOR_TYPE_MIX +} ColorType; + +struct GtkSymbolicColor +{ + ColorType type; + guint ref_count; + + union + { + GdkColor color; + gchar *name; + + struct + { + GtkSymbolicColor *color; + gdouble factor; + } shade; + + struct + { + GtkSymbolicColor *color1; + GtkSymbolicColor *color2; + gdouble factor; + } mix; + }; +}; + +GtkSymbolicColor * +gtk_symbolic_color_new_literal (GdkColor *color) +{ + GtkSymbolicColor *symbolic_color; + + g_return_val_if_fail (color != NULL, NULL); + + symbolic_color = g_slice_new0 (GtkSymbolicColor); + symbolic_color->type = COLOR_TYPE_LITERAL; + symbolic_color->color = *color; + + return symbolic_color; +} + +GtkSymbolicColor * +gtk_symbolic_color_new_name (const gchar *name) +{ + GtkSymbolicColor *symbolic_color; + + g_return_val_if_fail (name != NULL, NULL); + + symbolic_color = g_slice_new0 (GtkSymbolicColor); + symbolic_color->type = COLOR_TYPE_NAME; + symbolic_color->name = g_strdup (name); + + return symbolic_color; +} + +GtkSymbolicColor * +gtk_symbolic_color_new_shade (GtkSymbolicColor *color, + gdouble factor) +{ + GtkSymbolicColor *symbolic_color; + + g_return_val_if_fail (color != NULL, NULL); + + symbolic_color = g_slice_new0 (GtkSymbolicColor); + symbolic_color->type = COLOR_TYPE_SHADE; + symbolic_color->shade.color = gtk_symbolic_color_ref (color); + symbolic_color->shade.factor = CLAMP (factor, 0, 1); + + return symbolic_color; +} + +GtkSymbolicColor * +gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, + GtkSymbolicColor *color2, + gdouble factor) +{ + GtkSymbolicColor *symbolic_color; + + g_return_val_if_fail (color1 != NULL, NULL); + g_return_val_if_fail (color1 != NULL, NULL); + + symbolic_color = g_slice_new0 (GtkSymbolicColor); + symbolic_color->type = COLOR_TYPE_MIX; + symbolic_color->mix.color1 = gtk_symbolic_color_ref (color1); + symbolic_color->mix.color2 = gtk_symbolic_color_ref (color2); + symbolic_color->mix.factor = CLAMP (factor, 0, 1); + + return symbolic_color; +} + +GtkSymbolicColor * +gtk_symbolic_color_ref (GtkSymbolicColor *color) +{ + g_return_val_if_fail (color != NULL, NULL); + + color->ref_count++; + + return color; +} + +void +gtk_symbolic_color_unref (GtkSymbolicColor *color) +{ + g_return_if_fail (color != NULL); + + color->ref_count--; +} + +GType +gtk_symbolic_color_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (!type)) + type = g_boxed_type_register_static (I_("GtkSymbolicColor"), + (GBoxedCopyFunc) gtk_symbolic_color_ref, + (GBoxedFreeFunc) gtk_symbolic_color_unref); + + return type; +} + +#define __GTK_SYMBOLIC_COLOR_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h new file mode 100644 index 0000000000..e72cec128f --- /dev/null +++ b/gtk/gtksymboliccolor.h @@ -0,0 +1,49 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_SYMBOLIC_COLOR_H__ +#define __GTK_SYMBOLIC_COLOR_H__ + +#include +//#include "gtkstyleset.h" + +G_BEGIN_DECLS + +/* Dummy typedefs */ +typedef struct GtkSymbolicColor GtkSymbolicColor; +typedef struct GtkSymbolicColorMap GtkSymbolicColorMap; + +#define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ()) + +GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; + +GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkColor *color); +GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); +GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, + gdouble factor); +GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, + GtkSymbolicColor *color2, + gdouble factor); + +GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); +void gtk_symbolic_color_unref (GtkSymbolicColor *color); + +G_END_DECLS + +#endif /* __GTK_SYMBOLIC_COLOR_H__ */ From e2b8efcbecac6864148f1bc1d738ccf7e3c4feb3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 19:37:54 +0200 Subject: [PATCH 187/634] GtkStyleSet: Add API to map symbolic colors. --- gtk/gtkstyleset.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstyleset.h | 10 ++++--- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 5d8a856bc1..be07f6308f 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -48,6 +48,7 @@ struct PropertyData struct GtkStyleSetPrivate { + GHashTable *color_map; GHashTable *properties; }; @@ -126,6 +127,9 @@ gtk_style_set_finalize (GObject *object) priv = GTK_STYLE_SET_GET_PRIVATE (object); g_hash_table_destroy (priv->properties); + if (priv->color_map) + g_hash_table_destroy (priv->color_map); + G_OBJECT_CLASS (gtk_style_set_parent_class)->finalize (object); } @@ -260,6 +264,47 @@ gtk_style_set_new (void) return g_object_new (GTK_TYPE_STYLE_SET, NULL); } +void +gtk_style_set_map_color (GtkStyleSet *set, + const gchar *name, + GtkSymbolicColor *color) +{ + GtkStyleSetPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (name != NULL); + g_return_if_fail (color != NULL); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + + if (G_UNLIKELY (!priv->color_map)) + priv->color_map = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gtk_symbolic_color_unref); + + g_hash_table_replace (priv->color_map, + g_strdup (name), + gtk_symbolic_color_ref (color)); +} + +GtkSymbolicColor * +gtk_style_set_lookup_color (GtkStyleSet *set, + const gchar *name) +{ + GtkStyleSetPrivate *priv; + + g_return_val_if_fail (GTK_IS_STYLE_SET (set), NULL); + g_return_val_if_fail (name != NULL, NULL); + + priv = GTK_STYLE_SET_GET_PRIVATE (set); + + if (!priv->color_map) + return NULL; + + return g_hash_table_lookup (priv->color_map, name); +} + static void set_property_internal (GtkStyleSet *set, const gchar *property, @@ -570,6 +615,28 @@ gtk_style_set_merge (GtkStyleSet *set, priv = GTK_STYLE_SET_GET_PRIVATE (set); priv_to_merge = GTK_STYLE_SET_GET_PRIVATE (set_to_merge); + /* Merge symbolic color map */ + if (priv_to_merge->color_map) + { + g_hash_table_iter_init (&iter, priv_to_merge->color_map); + + while (g_hash_table_iter_next (&iter, &key, &value)) + { + const gchar *name; + GtkSymbolicColor *color; + + name = key; + color = value; + + if (!replace && + g_hash_table_lookup (priv->color_map, name)) + continue; + + gtk_style_set_map_color (set, name, color); + } + } + + /* Merge symbolic style properties */ g_hash_table_iter_init (&iter, priv_to_merge->properties); while (g_hash_table_iter_next (&iter, &key, &value)) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index d14deb89d1..88a11aee3b 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -23,9 +23,7 @@ #include #include #include "gtkenums.h" - -/* GtkBorder is defined there */ -#include "gtkstyle.h" +#include "gtksymboliccolor.h" G_BEGIN_DECLS @@ -59,6 +57,12 @@ gboolean gtk_style_set_lookup_property (const gchar *property_name, GtkStyleSet * gtk_style_set_new (void); +void gtk_style_set_map_color (GtkStyleSet *set, + const gchar *name, + GtkSymbolicColor *color); +GtkSymbolicColor * gtk_style_set_lookup_color (GtkStyleSet *set, + const gchar *name); + void gtk_style_set_set_default (GtkStyleSet *set, const gchar *property, const GValue *value); From b8fb2d1a367940aa8fb9b1b586350dbd66d4fa25 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 19:39:15 +0200 Subject: [PATCH 188/634] GtkSymbolicColor: Add method to resolve to a GdkColor. --- gtk/gtkstyleset.h | 4 +++ gtk/gtksymboliccolor.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 88a11aee3b..a716edf652 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -98,6 +98,10 @@ void gtk_style_set_merge (GtkStyleSet *set, const GtkStyleSet *set_to_merge, gboolean replace); +gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleSet *style_set, + GdkColor *resolved_color); + G_END_DECLS #endif /* __GTK_STYLE_PROPERTY_SET_H__ */ diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 7a8513d24e..bd33efaf6c 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -136,6 +136,73 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) color->ref_count--; } +gboolean +gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleSet *style_set, + GdkColor *resolved_color) +{ + g_return_val_if_fail (color != NULL, FALSE); + g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); + g_return_val_if_fail (resolved_color != NULL, FALSE); + + switch (color->type) + { + case COLOR_TYPE_LITERAL: + *resolved_color = color->color; + return TRUE; + case COLOR_TYPE_NAME: + { + GtkSymbolicColor *named_color; + + named_color = gtk_style_set_lookup_color (style_set, color->name); + + if (!named_color) + return FALSE; + + return gtk_symbolic_color_resolve (named_color, style_set, resolved_color); + } + + break; + case COLOR_TYPE_SHADE: + { + GdkColor shade; + + if (!gtk_symbolic_color_resolve (color->shade.color, style_set, &shade)) + return FALSE; + + resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 65535); + resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 65535); + resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 65535); + + return TRUE; + } + + break; + case COLOR_TYPE_MIX: + { + GdkColor color1, color2; + + if (!gtk_symbolic_color_resolve (color->mix.color1, style_set, &color1)) + return FALSE; + + if (!gtk_symbolic_color_resolve (color->mix.color2, style_set, &color2)) + return FALSE; + + resolved_color->red = CLAMP (color1.red + ((color2.red - color1.red) * color->mix.factor), 0, 65535); + resolved_color->green = CLAMP (color1.green + ((color2.green - color1.green) * color->mix.factor), 0, 65535); + resolved_color->blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 65535); + + return TRUE; + } + + break; + default: + g_assert_not_reached (); + } + + return FALSE; +} + GType gtk_symbolic_color_get_type (void) { From 4ed96df96a9e85a1ef4d9befd6e5da281f3f226f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 20:08:07 +0200 Subject: [PATCH 189/634] GtkStyleSet: Optionally take GtkSymbolicColors. gtk_style_set_set_property() now takes both GdkColor and GtkSymbolicColor GValues, All accessors still return GdkColors, so any symbolic color will be resolved and replaced in the styleset at that time. --- gtk/gtkstyleset.c | 77 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index be07f6308f..b76b497de7 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -315,8 +315,10 @@ set_property_internal (GtkStyleSet *set, GtkStyleSetPrivate *priv; PropertyNode *node; PropertyData *prop; + GType value_type; GValue *val; + value_type = G_VALUE_TYPE (value); node = property_node_lookup (g_quark_try_string (property)); if (!node) @@ -325,7 +327,13 @@ set_property_internal (GtkStyleSet *set, return; } - g_return_if_fail (node->property_type == G_VALUE_TYPE (value)); + if (node->property_type == GDK_TYPE_COLOR) + { + /* Allow GtkSymbolicColor as well */ + g_return_if_fail (value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); + } + else + g_return_if_fail (node->property_type == G_VALUE_TYPE (value)); priv = GTK_STYLE_SET_GET_PRIVATE (set); prop = g_hash_table_lookup (priv->properties, @@ -344,10 +352,15 @@ set_property_internal (GtkStyleSet *set, else val = &prop->values[state]; - if (G_IS_VALUE (val)) + if (G_VALUE_TYPE (val) == value_type) g_value_reset (val); else - g_value_init (val, node->property_type); + { + if (G_IS_VALUE (val)) + g_value_unset (val); + + g_value_init (val, value_type); + } g_value_copy (value, val); } @@ -447,6 +460,24 @@ gtk_style_set_set (GtkStyleSet *set, va_end (args); } +static gboolean +resolve_color (GtkStyleSet *set, + GValue *value) +{ + GdkColor color; + + /* Resolve symbolic color to GdkColor */ + if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), set, &color)) + return FALSE; + + /* Store it back, this is where GdkColor caching happens */ + g_value_unset (value); + g_value_init (value, GDK_TYPE_COLOR); + g_value_set_boxed (value, &color); + + return TRUE; +} + gboolean gtk_style_set_get_property (GtkStyleSet *set, const gchar *property, @@ -456,6 +487,7 @@ gtk_style_set_get_property (GtkStyleSet *set, GtkStyleSetPrivate *priv; PropertyNode *node; PropertyData *prop; + GValue *val; g_return_val_if_fail (GTK_IS_STYLE_SET (set), FALSE); g_return_val_if_fail (property != NULL, FALSE); @@ -479,10 +511,22 @@ gtk_style_set_get_property (GtkStyleSet *set, g_value_init (value, node->property_type); - if (!G_IS_VALUE (&prop->values[state])) - g_value_copy (&prop->default_value, value); + if (G_IS_VALUE (&prop->values[state])) + val = &prop->values[state]; else - g_value_copy (&prop->values[state], value); + val = &prop->default_value; + + g_return_val_if_fail (G_IS_VALUE (val), FALSE); + + if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) + { + g_return_val_if_fail (node->property_type == GDK_TYPE_COLOR, FALSE); + + if (!resolve_color (set, val)) + return FALSE; + } + + g_value_copy (val, value); return TRUE; } @@ -527,10 +571,25 @@ gtk_style_set_get_valist (GtkStyleSet *set, g_value_init (&empty_value, node->property_type); G_VALUE_LCOPY (&empty_value, args, 0, &error); } - else if (!G_IS_VALUE (&prop->values[state])) - G_VALUE_LCOPY (&prop->default_value, args, 0, &error); else - G_VALUE_LCOPY (&prop->values[state], args, 0, &error); + { + GValue *val; + + if (G_IS_VALUE (&prop->values[state])) + val = &prop->values[state]; + else + val = &prop->default_value; + + if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) + { + g_return_if_fail (node->property_type == GDK_TYPE_COLOR); + + if (!resolve_color (set, val)) + return; + } + + G_VALUE_LCOPY (val, args, 0, &error); + } if (error) { From 1de8f7551768868af8593a4214c3cf7cd58c9a4d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 20:27:15 +0200 Subject: [PATCH 190/634] GtkCssProvider: Parse color mappings. These are of the form: @color-a: #fff; @color-b: mix (@color-a, #000, 0.5) @color-c: shade (@color-b, 0.7) In the stylesheet, arbitrary nesting of these commands is handled. --- gtk/gtkcssprovider.c | 273 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 270 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index dc41a99b03..5d2d02b2dd 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -86,6 +86,8 @@ struct GtkCssProviderPrivate GScanner *scanner; gchar *filename; + GHashTable *symbolic_colors; + GPtrArray *selectors_info; /* Current parser state */ @@ -313,6 +315,10 @@ gtk_css_provider_init (GtkCssProvider *css_provider) priv->scanner = scanner; css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + + priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gtk_symbolic_color_unref); } typedef struct ComparePathData ComparePathData; @@ -524,6 +530,29 @@ css_provider_get_selectors (GtkCssProvider *css_provider, return priority_info; } +static void +css_provider_dump_symbolic_colors (GtkCssProvider *css_provider, + GtkStyleSet *set) +{ + GtkCssProviderPrivate *priv; + GHashTableIter iter; + gpointer key, value; + + priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + g_hash_table_iter_init (&iter, priv->symbolic_colors); + + while (g_hash_table_iter_next (&iter, &key, &value)) + { + const gchar *name; + GtkSymbolicColor *color; + + name = key; + color = value; + + gtk_style_set_map_color (set, name, color); + } +} + static GtkStyleSet * gtk_css_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) @@ -536,6 +565,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, priv = GTK_CSS_PROVIDER_GET_PRIVATE (provider); set = gtk_style_set_new (); + css_provider_dump_symbolic_colors ((GtkCssProvider *) provider, set); priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path); for (i = 0; i < priority_info->len; i++) @@ -635,6 +665,7 @@ gtk_css_provider_finalize (GObject *object) g_slist_free (priv->cur_selectors); g_hash_table_unref (priv->cur_properties); + g_hash_table_destroy (priv->symbolic_colors); G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object); } @@ -666,13 +697,13 @@ css_provider_apply_scope (GtkCssProvider *css_provider, if (scope == SCOPE_VALUE) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),." G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*"; + priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } @@ -941,6 +972,206 @@ parse_selector (GtkCssProvider *css_provider, return G_TOKEN_NONE; } +#define SKIP_SPACES(s) while (s[0] == ' ') s++; + +static GtkSymbolicColor * +symbolic_color_parse_str (const gchar *string, + gchar **end_ptr) +{ + GtkSymbolicColor *symbolic_color = NULL; + gchar *str; + + str = (gchar *) string; + + if (str[0] == '#') + { + GdkColor color; + gchar *color_str; + const gchar *end; + + end = str + 1; + + while (g_ascii_isxdigit (*end)) + end++; + + color_str = g_strndup (str, end - str); + *end_ptr = (gchar *) end; + + if (!gdk_color_parse (color_str, &color)) + { + g_free (color_str); + return NULL; + } + + symbolic_color = gtk_symbolic_color_new_literal (&color); + g_free (color_str); + } + else if (str[0] == '@') + { + const gchar *end; + gchar *name; + + str++; + end = str; + + while (*end == '-' || *end == '_' || + g_ascii_isalpha (*end)) + end++; + + name = g_strndup (str, end - str); + symbolic_color = gtk_symbolic_color_new_name (name); + g_free (name); + + *end_ptr = (gchar *) end; + } + else if (g_str_has_prefix (str, "shade")) + { + GtkSymbolicColor *param_color; + gdouble factor; + + str += strlen ("shade"); + + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + param_color = symbolic_color_parse_str (str, end_ptr); + + if (!param_color) + return NULL; + + str = *end_ptr; + SKIP_SPACES (str); + + if (str[0] != ',') + { + gtk_symbolic_color_unref (param_color); + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + factor = g_ascii_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + *end_ptr = (gchar *) str; + + if (str[0] != ')') + { + gtk_symbolic_color_unref (param_color); + return NULL; + } + + symbolic_color = gtk_symbolic_color_new_shade (param_color, factor); + (*end_ptr)++; + } + else if (g_str_has_prefix (str, "mix")) + { + GtkSymbolicColor *color1, *color2; + gdouble factor; + + str += strlen ("mix"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + color1 = symbolic_color_parse_str (str, end_ptr); + + if (!color1) + return NULL; + + str = *end_ptr; + SKIP_SPACES (str); + + if (str[0] != ',') + { + gtk_symbolic_color_unref (color1); + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + color2 = symbolic_color_parse_str (str, end_ptr); + + if (!color2 || *end_ptr[0] != ',') + { + gtk_symbolic_color_unref (color1); + return NULL; + } + + str = *end_ptr; + SKIP_SPACES (str); + + if (str[0] != ',') + { + gtk_symbolic_color_unref (color1); + gtk_symbolic_color_unref (color2); + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + factor = g_ascii_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + *end_ptr = (gchar *) str; + + if (str[0] != ')') + { + gtk_symbolic_color_unref (color1); + gtk_symbolic_color_unref (color2); + return NULL; + } + + symbolic_color = gtk_symbolic_color_new_mix (color1, color2, factor); + (*end_ptr)++; + } + + return symbolic_color; +} + +#undef SKIP_SPACES + +static GtkSymbolicColor * +symbolic_color_parse (const gchar *str) +{ + GtkSymbolicColor *color; + gchar *end; + + color = symbolic_color_parse_str (str, &end); + + if (*end != '\0') + { + g_warning ("Error parsing symbolic color \"%s\", stopped at char %ld : '%c'", + str, end - str, *end); + + if (color) + { + gtk_symbolic_color_unref (color); + color = NULL; + } + } + + return color; +} + static gboolean css_provider_parse_value (const gchar *value_str, GValue *value) @@ -1005,6 +1236,42 @@ parse_rule (GtkCssProvider *css_provider, priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); css_provider_push_scope (css_provider, SCOPE_SELECTOR); + + if (scanner->token == G_TOKEN_IDENTIFIER && + scanner->value.v_identifier[0] == '@') + { + GtkSymbolicColor *color; + gchar *color_name; + + /* Rule is a color mapping */ + color_name = g_strdup (&scanner->value.v_identifier[1]); + g_scanner_get_next_token (scanner); + + if (scanner->token != ':') + return ':'; + + css_provider_push_scope (css_provider, SCOPE_VALUE); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + color = symbolic_color_parse (scanner->value.v_identifier); + + if (!color) + return G_TOKEN_IDENTIFIER; + + g_hash_table_insert (priv->symbolic_colors, color_name, color); + + css_provider_pop_scope (css_provider); + g_scanner_get_next_token (scanner); + + if (scanner->token != ';') + return ';'; + + return G_TOKEN_NONE; + } + expected_token = parse_selector (css_provider, scanner, &selector); if (expected_token != G_TOKEN_NONE) From be5d4adf6b9636bc4f3d8ce1248fd937965a6bcc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Jun 2010 20:31:08 +0200 Subject: [PATCH 191/634] GtkCssProvider: Allow symbolic colors when parsing style rules. --- gtk/gtkcssprovider.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 5d2d02b2dd..b48b0b6e29 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1185,10 +1185,21 @@ css_provider_parse_value (const gchar *value_str, { GdkColor color; - if (gdk_color_parse (value_str, &color) == FALSE) - return FALSE; + if (gdk_color_parse (value_str, &color) == TRUE) + g_value_set_boxed (value, &color); + else + { + GtkSymbolicColor *symbolic_color; - g_value_set_boxed (value, &color); + symbolic_color = symbolic_color_parse (value_str); + + if (!symbolic_color) + return FALSE; + + g_value_unset (value); + g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR); + g_value_take_boxed (value, symbolic_color); + } } else if (type == PANGO_TYPE_FONT_DESCRIPTION) { From 318e0f28eea281907589f94f93241d5d3659beb0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 27 Jun 2010 19:35:08 +0200 Subject: [PATCH 192/634] GtkStyleProvider: Add gtk_style_provider_get_icon_factory(). With this, style providers have a way to override default icon theme. --- gtk/gtkstyleprovider.c | 16 ++++++++++++++++ gtk/gtkstyleprovider.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index e67d4471c2..4240176f24 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -83,6 +83,22 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider, return iface->get_style_property (provider, widget_path, property_name, value); } +GtkIconFactory * +gtk_style_provider_get_icon_factory (GtkStyleProvider *provider, + GtkWidgetPath *path) +{ + GtkStyleProviderIface *iface; + + g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL); + g_return_val_if_fail (path != NULL, NULL); + + iface = GTK_STYLE_PROVIDER_GET_IFACE (provider); + + if (!iface->get_icon_factory) + return NULL; + + return iface->get_icon_factory (provider, path); +} #define __GTK_STYLE_PROVIDER_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 5fc30ed42b..6c3a57561e 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -22,6 +22,7 @@ #include #include "gtkwidgetpath.h" +#include "gtkiconfactory.h" #include "gtkstyleset.h" #include "gtkenums.h" @@ -51,6 +52,9 @@ struct GtkStyleProviderIface GtkWidgetPath *path, const gchar *property_name, GValue *value); + + GtkIconFactory * (* get_icon_factory) (GtkStyleProvider *provider, + GtkWidgetPath *path); }; GType gtk_style_provider_get_type (void) G_GNUC_CONST; @@ -63,6 +67,9 @@ gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, const gchar *property_name, GValue *value); +GtkIconFactory * gtk_style_provider_get_icon_factory (GtkStyleProvider *provider, + GtkWidgetPath *path); + G_END_DECLS #endif /* __GTK_STYLE_PROVIDER_H__ */ From a256171d34a3000f899a8671b806dcfe529a5d26 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 27 Jun 2010 19:37:34 +0200 Subject: [PATCH 193/634] GtkStyleContext: Add gtk_style_context_lookup_icon_set(). --- gtk/gtkstylecontext.c | 61 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 4 +++ 2 files changed, 65 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 91ff093df4..4dd2bfea37 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -59,6 +59,8 @@ struct GtkStyleContextPrivate GList *providers; GList *providers_last; + GSList *icon_factories; + GtkStyleSet *store; GtkWidgetPath *widget_path; @@ -154,6 +156,9 @@ gtk_style_context_finalize (GObject *object) clear_property_cache (GTK_STYLE_CONTEXT (object)); + g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); + g_slist_free (priv->icon_factories); + G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); } @@ -191,6 +196,32 @@ rebuild_properties (GtkStyleContext *context) NULL); } +static void +rebuild_icon_factories (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GList *providers; + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); + g_slist_free (priv->icon_factories); + priv->icon_factories = NULL; + + for (providers = priv->providers_last; providers; providers = providers->prev) + { + GtkIconFactory *factory; + GtkStyleProviderData *data; + + data = providers->data; + factory = gtk_style_provider_get_icon_factory (data->provider, + priv->widget_path); + + if (factory) + priv->icon_factories = g_slist_prepend (priv->icon_factories, factory); + } +} + void gtk_style_context_add_provider (GtkStyleContext *context, GtkStyleProvider *provider, @@ -251,6 +282,7 @@ gtk_style_context_add_provider (GtkStyleContext *context, { rebuild_properties (context); clear_property_cache (context); + rebuild_icon_factories (context); } } @@ -296,6 +328,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context, { rebuild_properties (context); clear_property_cache (context); + rebuild_icon_factories (context); } } } @@ -425,6 +458,7 @@ gtk_style_context_set_path (GtkStyleContext *context, priv->widget_path = gtk_widget_path_copy (path); rebuild_properties (context); clear_property_cache (context); + rebuild_icon_factories (context); } } @@ -799,6 +833,33 @@ gtk_style_context_get_style_property (GtkStyleContext *context, G_VALUE_TYPE_NAME (value)); } +GtkIconSet * +gtk_style_context_lookup_icon_set (GtkStyleContext *context, + const gchar *stock_id) +{ + GtkStyleContextPrivate *priv; + GSList *list; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + g_return_val_if_fail (stock_id != NULL, NULL); + + priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + + for (list = priv->icon_factories; list; list = list->next) + { + GtkIconFactory *factory; + GtkIconSet *icon_set; + + factory = list->data; + icon_set = gtk_icon_factory_lookup (factory, stock_id); + + if (icon_set) + return icon_set; + } + + return gtk_icon_factory_lookup_default (stock_id); +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a968f00c9a..a8fae591e8 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -99,6 +99,10 @@ void gtk_style_context_get_style_property (GtkStyleContext *context, const gchar *property_name, GValue *value); +GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, + const gchar *stock_id); + + /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, From 51a8f642da27181a66477886fdfe0354c5dd3801 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 2 Jul 2010 20:54:20 +0200 Subject: [PATCH 194/634] Fix include. --- gtk/gtksymboliccolor.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index e72cec128f..8b3608bf21 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -20,8 +20,7 @@ #ifndef __GTK_SYMBOLIC_COLOR_H__ #define __GTK_SYMBOLIC_COLOR_H__ -#include -//#include "gtkstyleset.h" +#include G_BEGIN_DECLS From 875237187c4cad4e0cf2c408e8f5a27318540594 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 02:19:27 +0200 Subject: [PATCH 195/634] GtkCssProvider: Add priv pointer to object struct. --- gtk/gtkcssprovider.c | 41 +++++++++++++++++++++++------------------ gtk/gtkcssprovider.h | 1 + 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index b48b0b6e29..8989457bef 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -120,8 +120,6 @@ enum ParserSymbol { SYMBOL_NTH_CHILD_LAST }; -#define GTK_CSS_PROVIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProviderPrivate)) - static void gtk_css_provider_finalize (GObject *object); static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); @@ -293,7 +291,10 @@ gtk_css_provider_init (GtkCssProvider *css_provider) GtkCssProviderPrivate *priv; GScanner *scanner; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (css_provider, + GTK_TYPE_CSS_PROVIDER, + GtkCssProviderPrivate); + priv->selectors_info = g_ptr_array_new_with_free_func ((GDestroyNotify) selector_style_info_free); scanner = g_scanner_new (NULL); @@ -489,7 +490,7 @@ css_provider_get_selectors (GtkCssProvider *css_provider, GArray *priority_info; guint i, j; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; priority_info = g_array_new (FALSE, FALSE, sizeof (StylePriorityInfo)); for (i = 0; i < priv->selectors_info->len; i++) @@ -538,7 +539,7 @@ css_provider_dump_symbolic_colors (GtkCssProvider *css_provider, GHashTableIter iter; gpointer key, value; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; g_hash_table_iter_init (&iter, priv->symbolic_colors); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -557,16 +558,18 @@ static GtkStyleSet * gtk_css_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) { + GtkCssProvider *css_provider; GtkCssProviderPrivate *priv; GtkStyleSet *set; GArray *priority_info; guint i; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (provider); + css_provider = GTK_CSS_PROVIDER (provider); + priv = css_provider->priv; set = gtk_style_set_new (); - css_provider_dump_symbolic_colors ((GtkCssProvider *) provider, set); - priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path); + css_provider_dump_symbolic_colors (css_provider, set); + priority_info = css_provider_get_selectors (css_provider, path); for (i = 0; i < priority_info->len; i++) { @@ -652,9 +655,11 @@ gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface) static void gtk_css_provider_finalize (GObject *object) { + GtkCssProvider *css_provider; GtkCssProviderPrivate *priv; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (object); + css_provider = GTK_CSS_PROVIDER (object); + priv = css_provider->priv; g_scanner_destroy (priv->scanner); g_free (priv->filename); @@ -691,7 +696,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, { GtkCssProviderPrivate *priv; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; g_scanner_set_scope (priv->scanner, scope); @@ -727,7 +732,7 @@ css_provider_push_scope (GtkCssProvider *css_provider, { GtkCssProviderPrivate *priv; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; priv->state = g_slist_prepend (priv->state, GUINT_TO_POINTER (scope)); css_provider_apply_scope (css_provider, scope); @@ -739,7 +744,7 @@ css_provider_pop_scope (GtkCssProvider *css_provider) GtkCssProviderPrivate *priv; ParserScope scope = SCOPE_SELECTOR; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; if (!priv->state) { @@ -764,7 +769,7 @@ css_provider_reset_parser (GtkCssProvider *css_provider) { GtkCssProviderPrivate *priv; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; g_slist_free (priv->state); priv->state = NULL; @@ -790,7 +795,7 @@ css_provider_commit (GtkCssProvider *css_provider) GtkCssProviderPrivate *priv; GSList *l; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; l = priv->cur_selectors; while (l) @@ -1244,7 +1249,7 @@ parse_rule (GtkCssProvider *css_provider, GTokenType expected_token; SelectorPath *selector; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; css_provider_push_scope (css_provider, SCOPE_SELECTOR); @@ -1397,7 +1402,7 @@ parse_stylesheet (GtkCssProvider *css_provider) { GtkCssProviderPrivate *priv; - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; g_scanner_get_next_token (priv->scanner); while (!g_scanner_eof (priv->scanner)) @@ -1437,7 +1442,7 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); g_return_val_if_fail (data != NULL, FALSE); - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; if (length < 0) length = strlen (data); @@ -1467,7 +1472,7 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); - priv = GTK_CSS_PROVIDER_GET_PRIVATE (css_provider); + priv = css_provider->priv; if (!g_file_load_contents (file, NULL, &data, &length, diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h index bf3d94ade2..62f5a0e3d7 100644 --- a/gtk/gtkcssprovider.h +++ b/gtk/gtkcssprovider.h @@ -37,6 +37,7 @@ typedef struct GtkCssProviderClass GtkCssProviderClass; struct GtkCssProvider { GObject parent_instance; + gpointer priv; }; struct GtkCssProviderClass From 10f6c04f33dec9432df334de3845e5ad27e1c4b1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 02:19:54 +0200 Subject: [PATCH 196/634] GtkStyleSet: Add priv pointer to object struct. --- gtk/gtkstyleset.c | 31 +++++++++++++++++-------------- gtk/gtkstyleset.h | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index b76b497de7..f1e3f342ba 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -54,8 +54,6 @@ struct GtkStyleSetPrivate static GArray *properties = NULL; -#define GTK_STYLE_SET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_SET, GtkStyleSetPrivate)) - static void gtk_style_set_provider_init (GtkStyleProviderIface *iface); static void gtk_style_set_finalize (GObject *object); @@ -114,7 +112,10 @@ gtk_style_set_init (GtkStyleSet *set) { GtkStyleSetPrivate *priv; - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv = G_TYPE_INSTANCE_GET_PRIVATE (set, + GTK_TYPE_STYLE_SET, + GtkStyleSetPrivate); + priv->properties = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) property_data_free); } @@ -123,8 +124,10 @@ static void gtk_style_set_finalize (GObject *object) { GtkStyleSetPrivate *priv; + GtkStyleSet *set; - priv = GTK_STYLE_SET_GET_PRIVATE (object); + set = GTK_STYLE_SET (object); + priv = set->priv; g_hash_table_destroy (priv->properties); if (priv->color_map) @@ -275,7 +278,7 @@ gtk_style_set_map_color (GtkStyleSet *set, g_return_if_fail (name != NULL); g_return_if_fail (color != NULL); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; if (G_UNLIKELY (!priv->color_map)) priv->color_map = g_hash_table_new_full (g_str_hash, @@ -297,7 +300,7 @@ gtk_style_set_lookup_color (GtkStyleSet *set, g_return_val_if_fail (GTK_IS_STYLE_SET (set), NULL); g_return_val_if_fail (name != NULL, NULL); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; if (!priv->color_map) return NULL; @@ -335,7 +338,7 @@ set_property_internal (GtkStyleSet *set, else g_return_if_fail (node->property_type == G_VALUE_TYPE (value)); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -402,7 +405,7 @@ gtk_style_set_set_valist (GtkStyleSet *set, g_return_if_fail (GTK_IS_STYLE_SET (set)); g_return_if_fail (state < GTK_STATE_LAST); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; property_name = va_arg (args, const gchar *); while (property_name) @@ -502,7 +505,7 @@ gtk_style_set_get_property (GtkStyleSet *set, return FALSE; } - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -542,7 +545,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, g_return_if_fail (GTK_IS_STYLE_SET (set)); g_return_if_fail (state < GTK_STATE_LAST); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; property_name = va_arg (args, const gchar *); while (property_name) @@ -638,7 +641,7 @@ gtk_style_set_unset_property (GtkStyleSet *set, return; } - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -655,7 +658,7 @@ gtk_style_set_clear (GtkStyleSet *set) g_return_if_fail (GTK_IS_STYLE_SET (set)); - priv = GTK_STYLE_SET_GET_PRIVATE (set); + priv = set->priv; g_hash_table_remove_all (priv->properties); } @@ -671,8 +674,8 @@ gtk_style_set_merge (GtkStyleSet *set, g_return_if_fail (GTK_IS_STYLE_SET (set)); g_return_if_fail (GTK_IS_STYLE_SET (set_to_merge)); - priv = GTK_STYLE_SET_GET_PRIVATE (set); - priv_to_merge = GTK_STYLE_SET_GET_PRIVATE (set_to_merge); + priv = set->priv; + priv_to_merge = set_to_merge->priv; /* Merge symbolic color map */ if (priv_to_merge->color_map) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index a716edf652..24f6b99871 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -40,6 +40,7 @@ typedef struct GtkStyleSetClass GtkStyleSetClass; struct GtkStyleSet { GObject parent_object; + gpointer priv; }; struct GtkStyleSetClass From 41650933fdaac3cd37a8b0f8dc201a5792fea99e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 02:20:42 +0200 Subject: [PATCH 197/634] GtkStyleContext: Add priv pointer to object struct. --- gtk/gtkstylecontext.c | 83 ++++++++++++++++++++++--------------------- gtk/gtkstylecontext.h | 1 + 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 4dd2bfea37..57965e7f64 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -73,8 +73,6 @@ struct GtkStyleContextPrivate GtkThemingEngine *theming_engine; }; -#define GTK_STYLE_CONTEXT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextPrivate)) - static void gtk_style_context_finalize (GObject *object); @@ -95,7 +93,10 @@ gtk_style_context_init (GtkStyleContext *style_context) { GtkStyleContextPrivate *priv; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (style_context); + priv = style_context->priv = G_TYPE_INSTANCE_GET_PRIVATE (style_context, + GTK_TYPE_STYLE_CONTEXT, + GtkStyleContextPrivate); + priv->store = gtk_style_set_new (); priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL); } @@ -125,7 +126,7 @@ clear_property_cache (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; if (priv->property_cache) { @@ -148,8 +149,10 @@ static void gtk_style_context_finalize (GObject *object) { GtkStyleContextPrivate *priv; + GtkStyleContext *style_context; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (object); + style_context = GTK_STYLE_CONTEXT (object); + priv = style_context->priv; g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); g_list_free (priv->providers); @@ -168,7 +171,7 @@ rebuild_properties (GtkStyleContext *context) GtkStyleContextPrivate *priv; GList *list; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; list = priv->providers; gtk_style_set_clear (priv->store); @@ -202,7 +205,7 @@ rebuild_icon_factories (GtkStyleContext *context) GtkStyleContextPrivate *priv; GList *providers; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free (priv->icon_factories); @@ -235,7 +238,7 @@ gtk_style_context_add_provider (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; new_data = style_provider_data_new (provider, priority); list = priv->providers; @@ -297,7 +300,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; list = priv->providers; while (list) @@ -346,7 +349,7 @@ gtk_style_context_get_property (GtkStyleContext *context, g_return_if_fail (state < GTK_STATE_LAST); g_return_if_fail (value != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; gtk_style_set_get_property (priv->store, property, state, value); } @@ -360,7 +363,7 @@ gtk_style_context_get_valist (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (state < GTK_STATE_LAST); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; gtk_style_set_get_valist (priv->store, state, args); } @@ -375,7 +378,7 @@ gtk_style_context_get (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (state < GTK_STATE_LAST); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; va_start (args, state); gtk_style_set_get_valist (priv->store, state, args); @@ -390,7 +393,7 @@ gtk_style_context_set_state (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; priv->state_flags = flags; } @@ -401,7 +404,7 @@ gtk_style_context_get_state (GtkStyleContext *context) g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; return priv->state_flags; } @@ -413,7 +416,7 @@ gtk_style_context_is_state_set (GtkStyleContext *context, g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; switch (state) { @@ -445,7 +448,7 @@ gtk_style_context_set_path (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (path != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; if (priv->widget_path) { @@ -467,7 +470,7 @@ gtk_style_context_get_path (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; return priv->widget_path; } @@ -482,7 +485,7 @@ gtk_style_context_set_class (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; class_quark = g_quark_from_string (class_name); link = priv->style_classes; @@ -524,7 +527,7 @@ gtk_style_context_unset_class (GtkStyleContext *context, if (!class_quark) return; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; priv->style_classes = g_list_remove (priv->style_classes, GUINT_TO_POINTER (class_quark)); } @@ -544,7 +547,7 @@ gtk_style_context_has_class (GtkStyleContext *context, if (!class_quark) return FALSE; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; if (g_list_find (priv->style_classes, GUINT_TO_POINTER (class_quark))) @@ -574,7 +577,7 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; link = priv->child_style_classes; while (link) @@ -605,7 +608,7 @@ gtk_style_context_set_child_class (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; class_quark = g_quark_from_string (class_name); link = priv->child_style_classes; @@ -654,7 +657,7 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, if (!class_quark) return; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; child_class.class_quark = class_quark; link = g_list_find_custom (priv->child_style_classes, @@ -689,7 +692,7 @@ gtk_style_context_has_child_class (GtkStyleContext *context, if (!class_quark) return FALSE; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; child_class.class_quark = class_quark; link = g_list_find_custom (priv->child_style_classes, @@ -734,7 +737,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, GList *list; guint i; - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; key.widget_type = widget_type; key.pspec = pspec; @@ -798,7 +801,7 @@ gtk_style_context_get_style_property (GtkStyleContext *context, g_return_if_fail (property_name != NULL); g_return_if_fail (value != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; if (!priv->widget_path) return; @@ -843,7 +846,7 @@ gtk_style_context_lookup_icon_set (GtkStyleContext *context, g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); g_return_val_if_fail (stock_id != NULL, NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; for (list = priv->icon_factories; list; list = list->next) { @@ -875,7 +878,7 @@ gtk_render_check (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -897,7 +900,7 @@ gtk_render_option (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -919,7 +922,7 @@ gtk_render_arrow (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -941,7 +944,7 @@ gtk_render_background (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -962,7 +965,7 @@ gtk_render_frame (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -983,7 +986,7 @@ gtk_render_expander (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1004,7 +1007,7 @@ gtk_render_focus (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1024,7 +1027,7 @@ gtk_render_layout (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1045,7 +1048,7 @@ gtk_render_line (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1067,7 +1070,7 @@ gtk_render_slider (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1091,7 +1094,7 @@ gtk_render_frame_gap (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1115,7 +1118,7 @@ gtk_render_extension (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); @@ -1137,7 +1140,7 @@ gtk_render_handle (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (cr != NULL); - priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context); + priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); _gtk_theming_engine_set_context (priv->theming_engine, context); diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a8fae591e8..54f6a25659 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -39,6 +39,7 @@ typedef struct GtkStyleContextClass GtkStyleContextClass; struct GtkStyleContext { GObject parent_object; + gpointer priv; }; struct GtkStyleContextClass From 758c3e18cca979a976c5cde565629c6994585dbc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 13:17:35 +0200 Subject: [PATCH 198/634] GtkStyleContext: Add gtk_style_context_[gs]et_screen() --- gtk/gtkstylecontext.c | 99 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 4 ++ 2 files changed, 103 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 57965e7f64..7b13323c31 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -27,6 +27,7 @@ #include "gtkthemingengine.h" #include "gtkintl.h" #include "gtkwidget.h" +#include "gtkprivate.h" #include "gtkalias.h" @@ -56,6 +57,8 @@ struct PropertyValue struct GtkStyleContextPrivate { + GdkScreen *screen; + GList *providers; GList *providers_last; @@ -73,8 +76,22 @@ struct GtkStyleContextPrivate GtkThemingEngine *theming_engine; }; +enum { + PROP_0, + PROP_SCREEN +}; + static void gtk_style_context_finalize (GObject *object); +static void gtk_style_context_impl_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_style_context_impl_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + G_DEFINE_TYPE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT) @@ -84,6 +101,16 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gtk_style_context_finalize; + object_class->set_property = gtk_style_context_impl_set_property; + object_class->get_property = gtk_style_context_impl_get_property; + + g_object_class_install_property (object_class, + PROP_SCREEN, + g_param_spec_object ("screen", + P_("Screen"), + P_("The associated GdkScreen"), + GDK_TYPE_SCREEN, + GTK_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } @@ -165,6 +192,53 @@ gtk_style_context_finalize (GObject *object) G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); } +static void +gtk_style_context_impl_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkStyleContextPrivate *priv; + GtkStyleContext *style_context; + + style_context = GTK_STYLE_CONTEXT (object); + priv = style_context->priv; + + switch (prop_id) + { + case PROP_SCREEN: + gtk_style_context_set_screen (style_context, + g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_style_context_impl_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkStyleContextPrivate *priv; + GtkStyleContext *style_context; + + style_context = GTK_STYLE_CONTEXT (object); + priv = style_context->priv; + + switch (prop_id) + { + case PROP_SCREEN: + g_value_set_object (value, priv->screen); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void rebuild_properties (GtkStyleContext *context) { @@ -863,6 +937,31 @@ gtk_style_context_lookup_icon_set (GtkStyleContext *context, return gtk_icon_factory_lookup_default (stock_id); } +void +gtk_style_context_set_screen (GtkStyleContext *context, + GdkScreen *screen) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + priv->screen = screen; + + g_object_notify (G_OBJECT (context), "screen"); +} + +GdkScreen * +gtk_style_context_get_screen (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + + priv = context->priv; + return priv->screen; +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 54f6a25659..1fada4fb12 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -103,6 +103,10 @@ void gtk_style_context_get_style_property (GtkStyleContext *context, GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id); +void gtk_style_context_set_screen (GtkStyleContext *context, + GdkScreen *screen); +GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context); + /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, From 5db7197c278c97a9f1c69028cc53ba5a02899bad Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 13:20:45 +0200 Subject: [PATCH 199/634] GtkWidget: Set screen info in GtkStyleContext. --- gtk/gtkwidget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3235f5c13b..24cb380923 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7294,6 +7294,9 @@ gtk_widget_set_parent (GtkWidget *widget, path = gtk_widget_get_path (widget); gtk_style_context_set_path (context, path); gtk_widget_path_free (path); + + gtk_style_context_set_screen (context, + gtk_widget_get_screen (widget)); } } @@ -7895,6 +7898,8 @@ do_screen_change (GtkWidget *widget, { if (old_screen != new_screen) { + GtkStyleContext *context; + if (old_screen) { PangoContext *context = g_object_get_qdata (G_OBJECT (widget), quark_pango_context); @@ -7903,6 +7908,10 @@ do_screen_change (GtkWidget *widget, } _gtk_tooltip_hide (widget); + + context = gtk_widget_get_style_context (widget); + gtk_style_context_set_screen (context, new_screen); + g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen); } } @@ -13283,6 +13292,9 @@ gtk_widget_get_style_context (GtkWidget *widget) path = gtk_widget_get_path (widget); gtk_style_context_set_path (context, path); gtk_widget_path_free (path); + + gtk_style_context_set_screen (context, + gtk_widget_get_screen (widget)); } } From 4a465d279d0f2b5db2032b5456492d5114df9d87 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 13:21:56 +0200 Subject: [PATCH 200/634] GtkThemingEngine: Add gtk_theming_engine_get_screen(). --- gtk/gtkthemingengine.c | 11 +++++++++++ gtk/gtkthemingengine.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 5d4c8ce7cc..8e6f7a271d 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -402,6 +402,17 @@ gtk_theming_engine_load (const gchar *name) return engine; } +GdkScreen * +gtk_theming_engine_get_screen (GtkThemingEngine *engine) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL); + + priv = engine->priv; + return gtk_style_context_get_screen (priv->context); +} + /* Paint method implementations */ static void gtk_theming_engine_render_check (GtkThemingEngine *engine, diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 6ff8214098..9e337f818a 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -164,6 +164,8 @@ gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, G_CONST_RETURN GtkThemingEngine * gtk_theming_engine_load (const gchar *name); +GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine); + G_END_DECLS From 475f0fc2661e7455c3ad7ffb18e1a808a4efb3b2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 20:53:50 +0200 Subject: [PATCH 201/634] GtkStyleContext: Add gtk_style_context_save/restore(). This API will be used to have savepoints when adding and removing style classes information. --- gtk/gtkstylecontext.c | 316 +++++++++++++++++++++++++++++------------- gtk/gtkstylecontext.h | 3 + 2 files changed, 224 insertions(+), 95 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 7b13323c31..71f8c83a60 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -33,6 +33,7 @@ typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; +typedef struct GtkStyleRegion GtkStyleRegion; typedef struct GtkChildClass GtkChildClass; typedef struct PropertyValue PropertyValue; @@ -55,6 +56,12 @@ struct PropertyValue GValue value; }; +struct GtkStyleRegion +{ + GArray *style_classes; + GArray *child_style_classes; +}; + struct GtkStyleContextPrivate { GdkScreen *screen; @@ -70,8 +77,7 @@ struct GtkStyleContextPrivate GArray *property_cache; GtkStateFlags state_flags; - GList *style_classes; - GList *child_style_classes; + GSList *regions; GtkThemingEngine *theming_engine; }; @@ -115,10 +121,47 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } +static GtkStyleRegion * +style_region_new (void) +{ + GtkStyleRegion *region; + + region = g_slice_new0 (GtkStyleRegion); + region->style_classes = g_array_new (FALSE, FALSE, sizeof (GQuark)); + region->child_style_classes = g_array_new (FALSE, FALSE, sizeof (GtkChildClass)); + + return region; +} + +static void +style_region_free (GtkStyleRegion *region) +{ + g_array_free (region->style_classes, TRUE); + g_array_free (region->child_style_classes, TRUE); + g_slice_free (GtkStyleRegion, region); +} + +static GtkStyleRegion * +style_region_copy (const GtkStyleRegion *region) +{ + GtkStyleRegion *copy; + + copy = style_region_new (); + g_array_insert_vals (copy->style_classes, 0, + region->style_classes->data, + region->style_classes->len); + + g_array_insert_vals (copy->child_style_classes, 0, + region->child_style_classes->data, + region->child_style_classes->len); + return copy; +} + static void gtk_style_context_init (GtkStyleContext *style_context) { GtkStyleContextPrivate *priv; + GtkStyleRegion *region; priv = style_context->priv = G_TYPE_INSTANCE_GET_PRIVATE (style_context, GTK_TYPE_STYLE_CONTEXT, @@ -126,6 +169,10 @@ gtk_style_context_init (GtkStyleContext *style_context) priv->store = gtk_style_set_new (); priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL); + + /* Create default region */ + region = style_region_new (); + priv->regions = g_slist_prepend (priv->regions, region); } static GtkStyleProviderData * @@ -186,6 +233,9 @@ gtk_style_context_finalize (GObject *object) clear_property_cache (GTK_STYLE_CONTEXT (object)); + g_slist_foreach (priv->regions, (GFunc) style_region_free, NULL); + g_slist_free (priv->regions); + g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free (priv->icon_factories); @@ -548,13 +598,125 @@ gtk_style_context_get_path (GtkStyleContext *context) return priv->widget_path; } +void +gtk_style_context_save (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GtkStyleRegion *region; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + + g_assert (priv->regions != NULL); + + region = style_region_copy (priv->regions->data); + priv->regions = g_slist_prepend (priv->regions, region); +} + +void +gtk_style_context_restore (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GtkStyleRegion *region; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + + if (priv->regions) + { + region = priv->regions->data; + priv->regions = g_slist_remove (priv->regions, region); + style_region_free (region); + } + + if (!priv->regions) + { + g_warning ("Unpaired gtk_style_context_restore() call"); + + /* Create default region */ + region = style_region_new (); + priv->regions = g_slist_prepend (priv->regions, region); + } +} + +static gboolean +style_class_find (GArray *array, + GQuark class_quark, + guint *position) +{ + guint min, max, mid; + gboolean found = FALSE; + + min = 0; + max = array->len - 1; + mid = max - min / 2; + + do + { + GQuark item; + + mid = min + max / 2; + item = g_array_index (array, GQuark, mid); + + if (class_quark == item) + found = TRUE; + else if (class_quark > item) + min = mid + 1; + else + max = mid - 1; + } + while (!found && min < max); + + if (position) + *position = mid; + + return found; +} + +static gboolean +child_style_class_find (GArray *array, + GQuark class_quark, + guint *position) +{ + guint min, max, mid; + gboolean found = FALSE; + + min = 0; + max = array->len - 1; + mid = max - min / 2; + + do + { + GtkChildClass *child_class; + + mid = min + max / 2; + child_class = &g_array_index (array, GtkChildClass, mid); + + if (child_class->class_quark == class_quark) + found = TRUE; + else if (child_class->class_quark > class_quark) + min = mid + 1; + else + max = mid - 1; + } + while (!found && min < max); + + if (position) + *position = mid; + + return found; +} + void gtk_style_context_set_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; + GtkStyleRegion *region; GQuark class_quark; - GList *link; + guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); @@ -562,28 +724,11 @@ gtk_style_context_set_class (GtkStyleContext *context, priv = context->priv; class_quark = g_quark_from_string (class_name); - link = priv->style_classes; + g_assert (priv->regions != NULL); + region = priv->regions->data; - while (link) - { - GQuark link_quark; - - link_quark = GPOINTER_TO_UINT (link->data); - - if (link_quark == class_quark) - return; - else if (link_quark > class_quark) - { - priv->style_classes = g_list_insert_before (priv->style_classes, - link, GUINT_TO_POINTER (class_quark)); - return; - } - - link = link->next; - } - - priv->style_classes = g_list_append (priv->style_classes, - GUINT_TO_POINTER (class_quark)); + if (!style_class_find (region->style_classes, class_quark, &position)) + g_array_insert_val (region->style_classes, position, class_quark); } void @@ -591,7 +736,9 @@ gtk_style_context_unset_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; + GtkStyleRegion *region; GQuark class_quark; + guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); @@ -602,8 +749,12 @@ gtk_style_context_unset_class (GtkStyleContext *context, return; priv = context->priv; - priv->style_classes = g_list_remove (priv->style_classes, - GUINT_TO_POINTER (class_quark)); + + g_assert (priv->regions != NULL); + region = priv->regions->data; + + if (style_class_find (region->style_classes, class_quark, &position)) + g_array_remove_index (region->style_classes, position); } gboolean @@ -611,6 +762,7 @@ gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; + GtkStyleRegion *region; GQuark class_quark; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); @@ -623,47 +775,41 @@ gtk_style_context_has_class (GtkStyleContext *context, priv = context->priv; - if (g_list_find (priv->style_classes, - GUINT_TO_POINTER (class_quark))) + g_assert (priv->regions != NULL); + region = priv->regions->data; + + if (style_class_find (region->style_classes, class_quark, NULL)) return TRUE; return FALSE; } -static gint -child_style_class_compare (gconstpointer p1, - gconstpointer p2) -{ - const GtkChildClass *c1, *c2; - - c1 = p1; - c2 = p2; - - return (gint) c1->class_quark - c2->class_quark; -} - GList * gtk_style_context_list_child_classes (GtkStyleContext *context) { GtkStyleContextPrivate *priv; + GtkStyleRegion *region; GList *classes = NULL; - GList *link; + guint i; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); priv = context->priv; - link = priv->child_style_classes; - while (link) + g_assert (priv->regions != NULL); + region = priv->regions->data; + + for (i = 0; i < region->child_style_classes->len; i++) { - GtkChildClass *link_class; - const gchar *child_class; + GtkChildClass *child_class; + const gchar *class_name; - link_class = link->data; - link = link->next; + child_class = &g_array_index (region->child_style_classes, + GtkChildClass, + i); - child_class = g_quark_to_string (link_class->class_quark); - classes = g_list_prepend (classes, (gchar *) child_class); + class_name = g_quark_to_string (child_class->class_quark); + classes = g_list_prepend (classes, (gchar *) class_name); } return classes; @@ -675,43 +821,28 @@ gtk_style_context_set_child_class (GtkStyleContext *context, GtkChildClassFlags flags) { GtkStyleContextPrivate *priv; - GtkChildClass *child_class; + GtkStyleRegion *region; GQuark class_quark; - GList *link; + guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); priv = context->priv; class_quark = g_quark_from_string (class_name); - link = priv->child_style_classes; - while (link) + g_assert (priv->regions != NULL); + region = priv->regions->data; + + if (!child_style_class_find (region->child_style_classes, class_quark, &position)) { - GtkChildClass *link_class; + GtkChildClass child_class; - link_class = link->data; + child_class.class_quark = class_quark; + child_class.flags = flags; - if (link_class->class_quark == class_quark) - { - link_class->flags = flags; - return; - } - else if (link_class->class_quark > class_quark) - break; - - link = link->next; + g_array_insert_val (region->child_style_classes, position, child_class); } - - child_class = g_slice_new0 (GtkChildClass); - child_class->class_quark = class_quark; - child_class->flags = flags; - - if (link) - priv->child_style_classes = g_list_insert_before (priv->child_style_classes, - link, child_class); - else - priv->child_style_classes = g_list_append (priv->child_style_classes, child_class); } void @@ -719,9 +850,9 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; - GtkChildClass child_class; + GtkStyleRegion *region; GQuark class_quark; - GList *link; + guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (class_name != NULL); @@ -732,17 +863,12 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, return; priv = context->priv; - child_class.class_quark = class_quark; - link = g_list_find_custom (priv->child_style_classes, - &child_class, child_style_class_compare); + g_assert (priv->regions != NULL); + region = priv->regions->data; - if (link) - { - priv->child_style_classes = g_list_remove_link (priv->child_style_classes, link); - g_slice_free (GtkChildClass, link->data); - g_list_free1 (link); - } + if (child_style_class_find (region->child_style_classes, class_quark, &position)) + g_array_remove_index (region->child_style_classes, position); } gboolean @@ -751,9 +877,9 @@ gtk_style_context_has_child_class (GtkStyleContext *context, GtkChildClassFlags *flags_return) { GtkStyleContextPrivate *priv; - GtkChildClass child_class; + GtkStyleRegion *region; GQuark class_quark; - GList *link; + guint position; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); g_return_val_if_fail (class_name != NULL, FALSE); @@ -767,21 +893,21 @@ gtk_style_context_has_child_class (GtkStyleContext *context, return FALSE; priv = context->priv; - child_class.class_quark = class_quark; - link = g_list_find_custom (priv->child_style_classes, - &child_class, child_style_class_compare); + g_assert (priv->regions != NULL); + region = priv->regions->data; - if (link) + if (child_style_class_find (region->child_style_classes, class_quark, &position)) { if (flags_return) { - GtkChildClass *found_class; + GtkChildClass *child_class; - found_class = link->data; - *flags_return = found_class->flags; + child_class = &g_array_index (region->child_style_classes, + GtkChildClass, position); + + *flags_return = child_class->flags; } - return TRUE; } diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 1fada4fb12..f578b261bc 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -56,6 +56,9 @@ void gtk_style_context_add_provider (GtkStyleContext *context, void gtk_style_context_remove_provider (GtkStyleContext *context, GtkStyleProvider *provider); +void gtk_style_context_save (GtkStyleContext *context); +void gtk_style_context_restore (GtkStyleContext *context); + void gtk_style_context_get_property (GtkStyleContext *context, const gchar *property, GtkStateType state, From 038bcdcdb6bc916ad684c5b856396184b81b62da Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 3 Jul 2010 20:55:38 +0200 Subject: [PATCH 202/634] GtkThemingEngine: Use GdkPangoRenderer when painting layouts. --- gtk/gtkthemingengine.c | 154 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 151 insertions(+), 3 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 8e6f7a271d..6abed011ad 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1130,6 +1130,138 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, cairo_restore (cr); } +typedef struct _ByteRange ByteRange; + +struct _ByteRange +{ + guint start; + guint end; +}; + +static ByteRange* +range_new (guint start, + guint end) +{ + ByteRange *br = g_new (ByteRange, 1); + + br->start = start; + br->end = end; + + return br; +} + +static PangoLayout* +get_insensitive_layout (PangoLayout *layout) +{ + GSList *embossed_ranges = NULL; + GSList *shaded_ranges = NULL; + PangoLayoutIter *iter; + GSList *tmp_list = NULL; + PangoLayout *new_layout; + PangoAttrList *attrs; + + iter = pango_layout_get_iter (layout); + + do + { + PangoLayoutRun *run; + PangoAttribute *attr; + gboolean need_shade = FALSE; + ByteRange *br; + + run = pango_layout_iter_get_run_readonly (iter); + + if (run) + { + tmp_list = run->item->analysis.extra_attrs; + + while (tmp_list != NULL) + { + attr = tmp_list->data; + switch (attr->klass->type) + { + case PANGO_ATTR_FOREGROUND: + case PANGO_ATTR_BACKGROUND: + need_shade = TRUE; + break; + + default: + break; + } + + if (need_shade) + break; + + tmp_list = g_slist_next (tmp_list); + } + + br = range_new (run->item->offset, run->item->offset + run->item->length); + + if (need_shade) + shaded_ranges = g_slist_prepend (shaded_ranges, br); + else + embossed_ranges = g_slist_prepend (embossed_ranges, br); + } + } + while (pango_layout_iter_next_run (iter)); + + pango_layout_iter_free (iter); + + new_layout = pango_layout_copy (layout); + + attrs = pango_layout_get_attributes (new_layout); + + if (attrs == NULL) + { + /* Create attr list if there wasn't one */ + attrs = pango_attr_list_new (); + pango_layout_set_attributes (new_layout, attrs); + pango_attr_list_unref (attrs); + } + + tmp_list = embossed_ranges; + while (tmp_list != NULL) + { + PangoAttribute *attr; + ByteRange *br = tmp_list->data; + + attr = gdk_pango_attr_embossed_new (TRUE); + + attr->start_index = br->start; + attr->end_index = br->end; + + pango_attr_list_change (attrs, attr); + + g_free (br); + + tmp_list = g_slist_next (tmp_list); + } + + g_slist_free (embossed_ranges); + + tmp_list = shaded_ranges; + while (tmp_list != NULL) + { + PangoAttribute *attr; + ByteRange *br = tmp_list->data; + + attr = gdk_pango_attr_shade_new (0.7); + + attr->start_index = br->start; + attr->end_index = br->end; + + pango_attr_list_change (attrs, attr); + + g_free (br); + + tmp_list = g_slist_next (tmp_list); + } + + g_slist_free (shaded_ranges); + + return new_layout; +} + static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, cairo_t *cr, @@ -1140,10 +1272,13 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, GdkColor *fg_color; GtkStateFlags flags; GtkStateType state; + GdkScreen *screen; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); + /* FIXME: Set clipping */ + if (flags & GTK_STATE_FLAG_PRELIGHT) state = GTK_STATE_PRELIGHT; else if (flags & GTK_STATE_FLAG_INSENSITIVE) @@ -1155,9 +1290,22 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, "foreground-color", &fg_color, NULL); - cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, fg_color); - pango_cairo_show_layout (cr, layout); + screen = gtk_theming_engine_get_screen (engine); + + if (state == GTK_STATE_INSENSITIVE) + { + PangoLayout *insensitive_layout; + + insensitive_layout = get_insensitive_layout (layout); + gdk_pango_show_layout (screen, + cr, x, y, + insensitive_layout, + fg_color, NULL); + g_object_unref (insensitive_layout); + } + else + gdk_pango_show_layout (screen, cr, x, y, layout, + fg_color, NULL); cairo_restore (cr); From 27f5257d49a05d4e43c77c44bdbcf2684e46162f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 18 Jul 2010 18:40:48 +0200 Subject: [PATCH 203/634] GtkStyleContext: Don crash on empty class sets. --- gtk/gtkstylecontext.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 71f8c83a60..c1ec55dd7e 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -642,16 +642,21 @@ gtk_style_context_restore (GtkStyleContext *context) } static gboolean -style_class_find (GArray *array, - GQuark class_quark, - guint *position) +style_class_find (GArray *array, + GQuark class_quark, + guint *position) { guint min, max, mid; gboolean found = FALSE; + if (position) + *position = 0; + + if (!array || array->len == 0) + return FALSE; + min = 0; max = array->len - 1; - mid = max - min / 2; do { @@ -676,16 +681,21 @@ style_class_find (GArray *array, } static gboolean -child_style_class_find (GArray *array, - GQuark class_quark, - guint *position) +child_style_class_find (GArray *array, + GQuark class_quark, + guint *position) { guint min, max, mid; gboolean found = FALSE; + if (position) + *position = 0; + + if (!array || array->len == 0) + return FALSE; + min = 0; max = array->len - 1; - mid = max - min / 2; do { From 4e45e9099e6862fffb8051b4aeef147b5fb4301c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:42:18 +0200 Subject: [PATCH 204/634] GtkThemingEngine: Take checkbox rendering from GtkStyle. --- gtk/gtkthemingengine.c | 79 +++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 6abed011ad..88960ae3fc 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -426,6 +426,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, const GtkWidgetPath *path; GtkStateFlags flags; GtkStateType state; + gint exterior_size, interior_size, thickness, pad; flags = gtk_theming_engine_get_state (engine); path = gtk_theming_engine_get_path (engine); @@ -442,41 +443,85 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, "text-color", &text_color, NULL); - if (!gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) + exterior_size = MIN (width, height); + + if (exterior_size % 2 == 0) /* Ensure odd */ + exterior_size -= 1; + + /* FIXME: thickness */ + thickness = 1; + pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9); + interior_size = MAX (1, exterior_size - 2 * pad); + + if (interior_size < 7) { - cairo_set_line_width (cr, 1); + interior_size = 7; + pad = MAX (0, (exterior_size - interior_size) / 2); + } - cairo_rectangle (cr, - x + 0.5, y + 0.5, - width - 1, height - 1); + x -= (1 + exterior_size - (gint) width) / 2; + y -= (1 + exterior_size - (gint) height) / 2; + if (!gtk_theming_engine_has_class (engine, "menu")) + { + cairo_set_line_width (cr, 1.0); + + cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1); gdk_cairo_set_source_color (cr, base_color); cairo_fill_preserve (cr); - if (gtk_widget_path_has_parent (path, GTK_TYPE_TREE_VIEW)) - gdk_cairo_set_source_color (cr, text_color); + if (gtk_theming_engine_has_class (engine, "cell")) + gdk_cairo_set_source_color (cr, text_color); else - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_color (cr, fg_color); cairo_stroke (cr); } - cairo_set_line_width (cr, 1.5); - gdk_cairo_set_source_color (cr, text_color); + if (gtk_theming_engine_has_class (engine, "menu")) + gdk_cairo_set_source_color (cr, fg_color); + else + gdk_cairo_set_source_color (cr, text_color); if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) { - cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); - cairo_line_to (cr, x + (width * 0.8), y + (height / 2)); + int line_thickness = MAX (1, (3 + interior_size * 2) / 7); + + cairo_rectangle (cr, + x + pad, + y + pad + (1 + interior_size - line_thickness) / 2, + interior_size, + line_thickness); + cairo_fill (cr); } else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) { - cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); - cairo_line_to (cr, x + (width * 0.4), y + (height * 0.8)); - cairo_line_to (cr, x + (width * 0.8), y + (height * 0.2)); - } + cairo_translate (cr, + x + pad, y + pad); - cairo_stroke (cr); + cairo_scale (cr, interior_size / 7., interior_size / 7.); + + cairo_move_to (cr, 7.0, 0.0); + cairo_line_to (cr, 7.5, 1.0); + cairo_curve_to (cr, 5.3, 2.0, + 4.3, 4.0, + 3.5, 7.0); + cairo_curve_to (cr, 3.0, 5.7, + 1.3, 4.7, + 0.0, 4.7); + cairo_line_to (cr, 0.2, 3.5); + cairo_curve_to (cr, 1.1, 3.5, + 2.3, 4.3, + 3.0, 5.0); + cairo_curve_to (cr, 1.0, 3.9, + 2.4, 4.1, + 3.2, 4.9); + cairo_curve_to (cr, 3.5, 3.1, + 5.2, 2.0, + 7.0, 0.0); + + cairo_fill (cr); + } cairo_restore (cr); From 9261c2a9d79fc1b9eb24962acbe88ee33fe3104b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:45:35 +0200 Subject: [PATCH 205/634] GtkThemingEngine: Take option rendering from GtkStyle. --- gtk/gtkthemingengine.c | 79 +++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 88960ae3fc..48edaa2b2b 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -542,14 +542,16 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, GdkColor *base_color, *fg_color, *text_color; const GtkWidgetPath *path; GtkStateType state; + gint exterior_size, interior_size, pad, thickness; gdouble radius; + /* FIXME: set clipping */ + flags = gtk_theming_engine_get_state (engine); path = gtk_theming_engine_get_path (engine); radius = MIN (width, height) / 2 - 0.5; cairo_save (cr); - cairo_set_line_width (cr, 1); if (flags & GTK_STATE_FLAG_PRELIGHT) state = GTK_STATE_PRELIGHT; @@ -562,44 +564,81 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, "text-color", &text_color, NULL); - if (!gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) - { - cairo_arc (cr, - x + (width / 2), - y + (height / 2), - radius, - 0, 2 * G_PI); + exterior_size = MIN (width, height); + if (exterior_size % 2 == 0) /* Ensure odd */ + exterior_size -= 1; + + x -= (1 + exterior_size - width) / 2; + y -= (1 + exterior_size - height) / 2; + + if (!gtk_theming_engine_has_class (engine, "menu")) + { gdk_cairo_set_source_color (cr, base_color); + + cairo_arc (cr, + x + exterior_size / 2., + y + exterior_size / 2., + (exterior_size - 1) / 2., + 0, 2 * G_PI); + cairo_fill_preserve (cr); - if (gtk_widget_path_has_parent (path, GTK_TYPE_TREE_VIEW)) - gdk_cairo_set_source_color (cr, text_color); + if (gtk_theming_engine_has_class (engine, "cell")) + gdk_cairo_set_source_color (cr, text_color); else - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_color (cr, fg_color); + cairo_set_line_width (cr, 1.); cairo_stroke (cr); } - if (gtk_widget_path_has_parent (path, GTK_TYPE_MENU)) + if (gtk_theming_engine_has_class (engine, "menu")) gdk_cairo_set_source_color (cr, fg_color); else gdk_cairo_set_source_color (cr, text_color); + /* FIXME: thickness */ + thickness = 1; + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) { - cairo_move_to (cr, x + (width * 0.2), y + (height / 2)); - cairo_line_to (cr, x + (width * 0.8), y + (height / 2)); - cairo_stroke (cr); + gint line_thickness; + + pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9); + interior_size = MAX (1, exterior_size - 2 * pad); + + if (interior_size < 7) + { + interior_size = 7; + pad = MAX (0, (exterior_size - interior_size) / 2); + } + + line_thickness = MAX (1, (3 + interior_size * 2) / 7); + + cairo_rectangle (cr, + x + pad, + y + pad + (interior_size - line_thickness) / 2., + interior_size, + line_thickness); + cairo_fill (cr); } if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) { - cairo_arc (cr, - x + (width / 2), - y + (height / 2), - radius / 2, - 0, 2 * G_PI); + pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9); + interior_size = MAX (1, exterior_size - 2 * pad); + if (interior_size < 5) + { + interior_size = 7; + pad = MAX (0, (exterior_size - interior_size) / 2); + } + + cairo_arc (cr, + x + pad + interior_size / 2., + y + pad + interior_size / 2., + interior_size / 2., + 0, 2 * G_PI); cairo_fill (cr); } From 5cdb3f0e90ab03b59843beb425c323563724c6ed Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:47:37 +0200 Subject: [PATCH 206/634] GtkThemingEngine: Cairo-ify handle rendering from GtkStyle. --- gtk/gtkthemingengine.c | 69 +++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 48edaa2b2b..c6ec3b0774 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1596,23 +1596,34 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, } static void -paint_point (cairo_t *cr, - const GdkColor *lighter, - const GdkColor *darker, - gdouble x, - gdouble y) +render_dot (cairo_t *cr, + const GdkColor *lighter, + const GdkColor *darker, + gdouble x, + gdouble y, + gdouble size) { - cairo_move_to (cr, x - 0.5, y + 1); - cairo_line_to (cr, x - 0.5, y - 0.5); - cairo_line_to (cr, x + 1, y - 0.5); - gdk_cairo_set_source_color (cr, lighter); - cairo_stroke (cr); + size = CLAMP ((gint) size, 2, 3); - cairo_move_to (cr, x + 1.5, y); - cairo_line_to (cr, x + 1.5, y + 1.5); - cairo_line_to (cr, x, y + 1.5); - gdk_cairo_set_source_color (cr, darker); - cairo_stroke (cr); + if (size == 2) + { + gdk_cairo_set_source_color (cr, lighter); + cairo_rectangle (cr, x, y, 1, 1); + cairo_rectangle (cr, x + 1, y + 1, 1, 1); + cairo_fill (cr); + } + else if (size == 3) + { + gdk_cairo_set_source_color (cr, lighter); + cairo_rectangle (cr, x, y, 2, 1); + cairo_rectangle (cr, x, y, 1, 2); + cairo_fill (cr); + + gdk_cairo_set_source_color (cr, darker); + cairo_rectangle (cr, x + 1, y + 1, 2, 1); + cairo_rectangle (cr, x + 2, y, 1, 2); + cairo_fill (cr); + } } static void @@ -1650,20 +1661,28 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, - x, y, width, height); - cairo_close_path (cr); - gdk_cairo_set_source_color (cr, bg_color); + cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); - if (orientation == GTK_ORIENTATION_HORIZONTAL) - for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5) - paint_point (cr, &lighter, &darker, xx, y + height / 2 - 1); + if (gtk_theming_engine_has_class (engine, "paned")) + { + if (orientation == GTK_ORIENTATION_HORIZONTAL) + for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5) + render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3); + else + for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5) + render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3); + } else - for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5) - paint_point (cr, &lighter, &darker, x + width / 2, yy); + { + for (yy = y; yy < y + height; yy += 3) + for (xx = x; xx < x + width; xx += 6) + { + render_dot (cr, &lighter, &darker, xx, yy, 2); + render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2); + } + } cairo_restore (cr); From 75b059a3f26e8d6ffe3a40d05a0c945edb93611d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:51:17 +0200 Subject: [PATCH 207/634] GtkThemingEngine: Add cairo-ified rendering primitives. Functions to add paths for lines, rectangle sides, and the gap side in notebooks have been added. --- gtk/gtkthemingengine.c | 190 ++++++++++++----------------------------- 1 file changed, 56 insertions(+), 134 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index c6ec3b0774..a581029695 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -709,131 +709,66 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, } static void -add_path_rounded_rectangle (cairo_t *cr, - gdouble radius, - guint sides, - gdouble x, - gdouble y, - gdouble width, - gdouble height) +add_path_line (cairo_t *cr, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) { - gdouble r = 0; - - if (sides & SIDE_BOTTOM) + /* Adjust endpoints */ + if (y1 == y2) { - /* Bottom left corner */ - if (r == 0) - cairo_move_to (cr, x + 0.5, y + height - 0.5); - else - cairo_arc_negative (cr, - x + r + 0.5, - y + height - r - 0.5, - r, - 135 * (G_PI / 180), - 90 * (G_PI / 180)); + y1 += 0.5; + y2 += 0.5; + x2 += 1; + } + else if (x1 == x2) + { + x1 += 0.5; + x2 += 0.5; + y2 += 1; + } - /* Bottom side */ - cairo_line_to (cr, x + width - r - 0.5, y + height - 0.5); + cairo_move_to (cr, x1, y1); + cairo_line_to (cr, x2, y2); +} - /* Bottom right corner */ - if (r > 0) - cairo_arc_negative (cr, - x + width - r - 0.5, - y + height - r - 0.5, - r, - 90 * (G_PI / 180), - 45 * (G_PI / 180)); +static void +add_path_rectangle_sides (cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + guint sides) +{ + if (sides & SIDE_TOP) + { + cairo_move_to (cr, x, y + 0.5); + cairo_line_to (cr, x + width, y + 0.5); } if (sides & SIDE_RIGHT) { - /* Bottom right corner */ - if (r == 0) - { - if ((sides & SIDE_BOTTOM) == 0) - cairo_move_to (cr, x + width - 0.5, y + height - 0.5); - } - else - cairo_arc_negative (cr, - x + width - r - 0.5, - y + height - r - 0.5, - r, - 45 * (G_PI / 180), 0); - - /* Right side */ - cairo_line_to (cr, x + width - 0.5, y + r); - - /* Top right corner */ - if (r > 0) - cairo_arc_negative (cr, - x + width - r - 0.5, - y + r + 0.5, - r, - 0, 315 * (G_PI / 180)); + cairo_move_to (cr, x + width - 0.5, y); + cairo_line_to (cr, x + width - 0.5, y + height); } - if (sides & SIDE_TOP) + if (sides & SIDE_BOTTOM) { - /* Top right corner */ - if (r == 0) - { - if ((sides & SIDE_RIGHT) == 0) - cairo_move_to (cr, x + width - 1, y + 0.5); - } - else - cairo_arc_negative (cr, - x + width - r - 0.5, - y + r + 0.5, - r, - 315 * (G_PI / 180), - 270 * (G_PI / 180)); - - /* Top side */ - cairo_line_to (cr, x + 0.5 + r, y + 0.5); - - /* Top left corner */ - if (r > 0) - cairo_arc_negative (cr, - x + r + 0.5, - y + r + 0.5, - r, - 270 * (G_PI / 180), - 225 * (G_PI / 180)); + cairo_move_to (cr, x, y + height - 0.5); + cairo_line_to (cr, x + width, y + height - 0.5); } if (sides & SIDE_LEFT) { - /* Top left corner */ - if (r == 0) - { - if ((sides & SIDE_TOP) == 0) - cairo_move_to (cr, x + 0.5, y + 0.5); - } - else - cairo_arc_negative (cr, - x + + r + 0.5, - y + r + 0.5, - r, - 225 * (G_PI / 180), - 180 * (G_PI / 180)); - - /* Left side */ - cairo_line_to (cr, x + 0.5, y + height - r); - - if (r > 0) - cairo_arc_negative (cr, - x + r + 0.5, - y + height - r + 0.5, - r, - 180 * (G_PI / 180), - 135 * (G_PI / 180)); + cairo_move_to (cr, x + 0.5, y + height); + cairo_line_to (cr, x + 0.5, y); } } static void add_path_gap_side (cairo_t *cr, GtkPositionType gap_side, - gdouble radius, gdouble x, gdouble y, gdouble width, @@ -841,37 +776,24 @@ add_path_gap_side (cairo_t *cr, gdouble xy0_gap, gdouble xy1_gap) { - if (gap_side == GTK_POS_TOP) + switch (gap_side) { - cairo_move_to (cr, x, y); - cairo_line_to (cr, x + xy0_gap, y); - - cairo_move_to (cr, x + xy1_gap, y); - cairo_line_to (cr, x + width, y); - } - else if (gap_side == GTK_POS_BOTTOM) - { - cairo_move_to (cr, x, y + height); - cairo_line_to (cr, x + xy0_gap, y + height); - - cairo_move_to (cr, x + xy1_gap, y + height); - cairo_line_to (cr, x + width, y + height); - } - else if (gap_side == GTK_POS_LEFT) - { - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + xy0_gap); - - cairo_move_to (cr, x, y + xy1_gap); - cairo_line_to (cr, x, y + height); - } - else - { - cairo_move_to (cr, x + width, y); - cairo_line_to (cr, x + width, y + xy0_gap); - - cairo_move_to (cr, x + width, y + xy1_gap); - cairo_line_to (cr, x + width, y + height); + case GTK_POS_TOP: + add_path_line (cr, x, y, x + xy0_gap, y); + add_path_line (cr, x + xy1_gap, y, x + width, y); + break; + case GTK_POS_BOTTOM: + add_path_line (cr, x, y + height, x + xy0_gap, y + height); + add_path_line (cr, x + xy1_gap, y + height, x + width, y + height); + break; + case GTK_POS_LEFT: + add_path_line (cr, x, y, x, y + xy0_gap); + add_path_line (cr, x, y + xy1_gap, x, y + height); + break; + case GTK_POS_RIGHT: + add_path_line (cr, x + width, y, x + width, y + xy0_gap); + add_path_line (cr, x + width, y + xy1_gap, x + width, y + height); + break; } } From 1b556aa4d127d3b0ff1a47945b6a106e0ba15f61 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:54:31 +0200 Subject: [PATCH 208/634] GtkThemingEngine: Unify code to render lines. --- gtk/gtkthemingengine.c | 115 +++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 72 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a581029695..d1bca7e21a 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -19,6 +19,7 @@ #include "config.h" +#include #include #include @@ -1022,17 +1023,6 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdk_color_free (base_color); } -static void -add_path_line (cairo_t *cr, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2) -{ - cairo_move_to (cr, x1 + 0.5, y1 + 0.5); - cairo_line_to (cr, x2 + 0.5, y2 + 0.5); -} - static void gtk_theming_engine_render_line (GtkThemingEngine *engine, cairo_t *cr, @@ -1044,9 +1034,11 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, GdkColor *bg_color, darker, lighter; GtkStateFlags flags; GtkStateType state; - gint thickness, thickness_dark, thickness_light; - gint i; + gint i, thickness, thickness_dark, thickness_light, len; + cairo_matrix_t matrix; + gdouble angle; + /* FIXME: thickness */ thickness = 2; thickness_dark = thickness / 2; thickness_light = thickness - thickness_dark; @@ -1070,67 +1062,46 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); cairo_set_line_width (cr, 1); - if (y0 == y1) + angle = atan2 (x1 - x0, y1 - y0); + angle = (2 * G_PI) - angle; + angle += G_PI / 2; + + cairo_get_matrix (cr, &matrix); + cairo_matrix_translate (&matrix, x0, y0); + cairo_matrix_rotate (&matrix, angle); + cairo_set_matrix (cr, &matrix); + + x1 -= x0; + y1 -= y0; + + len = (gint) sqrt ((x1 * x1) + (y1 * y1)); + + y0 = -thickness_dark; + + for (i = 0; i < thickness_dark; i++) { - /* Horizontal line */ - for (i = 0; i < thickness_dark; i++) - { - gdk_cairo_set_source_color (cr, &darker); - add_path_line (cr, x0, y0, x1 - i - 1, y0); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_line (cr, x1 - i, y0, x1, y0 + 1); - cairo_stroke (cr); - y0++; - } - - for (i = 0; i < thickness_light; i++) - { - gdk_cairo_set_source_color (cr, &darker); - add_path_line (cr, x0, y0, x0 + thickness_light - i, y0); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_line (cr, x0 + thickness_light - i, y0, x1, y0); - cairo_stroke (cr); - y0++; - } - } - else if (x0 == x1) - { - /* Vertical line */ - for (i = 0; i < thickness_dark; i++) - { - gdk_cairo_set_source_color (cr, &darker); - add_path_line (cr, x0, y0, x0, y1 - i - 1); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_line (cr, x0, y1 - i, x0, y1); - cairo_stroke (cr); - x0++; - } - - for (i = 0; i < thickness_light; i++) - { - gdk_cairo_set_source_color (cr, &darker); - add_path_line (cr, x0, y0, x0, y0 + thickness_light - i - 1); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_line (cr, x0, y0 + thickness_light - i, x0, y1); - cairo_stroke (cr); - x0++; - } - } - else - { - /* Arbitrary line */ - /* FIXME: implement thickness, etc */ - gdk_cairo_set_source_color (cr, &darker); - add_path_line (cr, x0, y0, x1, y1); + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, len - i - 1.5, y0, len - 0.5, y0); cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, 0.5, y0, len - i - 1.5, y0); + cairo_stroke (cr); + + y0++; + } + + for (i = 0; i < thickness_light; i++) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, 0.5, y0, thickness_light - i + 0.5, y0); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, thickness_light - i + 0.5, y0, len - 0.5, y0); + cairo_stroke (cr); + + y0++; } cairo_restore (cr); From 4772b675634eb375549fc3b4eed14975915e9771 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:56:01 +0200 Subject: [PATCH 209/634] GtkThemingEngine: Make render_background use drawing primitives. --- gtk/gtkthemingengine.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index d1bca7e21a..57452613c6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -818,7 +818,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, { GtkStateFlags flags; GtkStateType state; - GdkColor *bg_color; + GdkColor *color; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -830,19 +830,31 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, else state = GTK_STATE_NORMAL; - gtk_theming_engine_get (engine, state, - "background-color", &bg_color, - NULL); + if (gtk_theming_engine_has_class (engine, "entry")) + gtk_theming_engine_get (engine, state, + "base-color", &color, + NULL); + else + gtk_theming_engine_get (engine, state, + "background-color", &color, + NULL); - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, - x, y, width, height); - cairo_close_path (cr); + gdk_cairo_set_source_color (cr, color); + cairo_rectangle (cr, x, y, width, height); - gdk_cairo_set_source_color (cr, bg_color); - cairo_fill (cr); + if (gtk_theming_engine_has_class (engine, "tooltip")) + { + cairo_fill_preserve (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_stroke (cr); + } + else + cairo_fill (cr); cairo_restore (cr); + + gdk_color_free (color); } static void From 7d2b51f147c67e94cd318ba9f64f80f2b889a17b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:57:25 +0200 Subject: [PATCH 210/634] GtkThemingEngine: Cairo-ify extension rendering from GtkStyle. --- gtk/gtkthemingengine.c | 121 ++++++++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 31 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 57452613c6..8e74a035ec 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1433,7 +1433,6 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, GtkStateType state; GdkColor *bg_color; GdkColor lighter, darker; - guint sides; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -1455,45 +1454,105 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT | SIDE_TOP | SIDE_LEFT, - x, y, width, height); - cairo_close_path (cr); + switch (gap_side) + { + case GTK_POS_TOP: + gdk_cairo_set_source_color (cr, bg_color); + cairo_rectangle (cr, x + 1, y, width - 2, height); + cairo_fill (cr); - gdk_cairo_set_source_color (cr, bg_color); - cairo_fill (cr); + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x, y, x, y + height - 2); + cairo_stroke (cr); - if (gap_side == GTK_POS_RIGHT) - sides = SIDE_BOTTOM; - else if (gap_side == GTK_POS_BOTTOM) - sides = SIDE_RIGHT; - else - sides = SIDE_BOTTOM | SIDE_RIGHT; + gdk_cairo_set_source_color (cr, bg_color); + add_path_line (cr, x + 1, y, x + 1, y + height - 2); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, sides, - x, y, width, height); + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x + 2, y + height - 2, x + width - 2, y + height - 2); + add_path_line (cr, x + width - 2, y, x + width - 2, y + height - 2); + cairo_stroke (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_stroke (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_line (cr, x + 1, y + height - 1, x + width - 2, y + height - 1); + add_path_line (cr, x + width - 1, y, x + width - 1, y + height - 2); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, sides, - x, y, width - 1, height - 1); + break; + case GTK_POS_BOTTOM: + gdk_cairo_set_source_color (cr, bg_color); + cairo_rectangle (cr, x + 1, y, width - 2, height); + cairo_fill (cr); - gdk_cairo_set_source_color (cr, &darker); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x + 1, y, x + width - 2, y); + add_path_line (cr, x, y + 1, x, y + height - 1); + cairo_stroke (cr); - if (gap_side == GTK_POS_LEFT) - sides = SIDE_TOP; - else if (gap_side == GTK_POS_TOP) - sides = SIDE_LEFT; - else - sides = SIDE_TOP | SIDE_LEFT; + gdk_cairo_set_source_color (cr, bg_color); + add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1); + add_path_line (cr, x + 1, y + 1, x + 1, y + height - 1); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, sides, - x, y, width, height); + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 1); + cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &lighter); - cairo_stroke (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_line (cr, x + width - 1, y + 1, x + width - 1, y + height - 1); + cairo_stroke (cr); + + break; + case GTK_POS_LEFT: + gdk_cairo_set_source_color (cr, bg_color); + cairo_rectangle (cr, x, y + 1, width, height - 2); + cairo_fill (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x, y, x + width - 2, y); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, bg_color); + add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x, y + height - 2, x + width - 2, y + height - 2); + add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 2); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_line (cr, x, y + height - 1, x + width - 2, y + height - 1); + add_path_line (cr, x + width - 1, y + 1, x + width - 1, y + height - 2); + cairo_stroke (cr); + + break; + case GTK_POS_RIGHT: + gdk_cairo_set_source_color (cr, bg_color); + cairo_rectangle (cr, x, y + 1, width, height - 2); + cairo_fill (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_line (cr, x + 1, y, x + width - 1, y); + add_path_line (cr, x, y + 1, x, y + height - 2); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, bg_color); + add_path_line (cr, x + 1, y + 1, x + width - 1, y + 1); + add_path_line (cr, x + 1, y + 1, x + 1, y + height - 2); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_line (cr, x + 2, y + height - 2, x + width - 1, y + height - 2); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_line (cr, x + 1, y + height - 1, x + width - 1, y + height - 1); + cairo_stroke (cr); + + break; + } cairo_restore (cr); From 8771f46dae70e2d45439f7ae9aa36d11d9b4edd2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:58:13 +0200 Subject: [PATCH 211/634] GtkThemingEngine: Cairo-ify frame_gap rendering from GtkStyle. --- gtk/gtkthemingengine.c | 53 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 8e74a035ec..b974b45620 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1372,29 +1372,30 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_BOTTOM | SIDE_RIGHT; - if (gap_side == GTK_POS_RIGHT || - gap_side == GTK_POS_BOTTOM) - add_path_gap_side (cr, gap_side, 0, - x, y, width, height, - xy0_gap, xy1_gap); - - add_path_rounded_rectangle (cr, 0, sides, - x, y, width, height); + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x + 1, y, width - 2, height, sides); + add_path_rectangle_sides (cr, x, y + 1, width, height - 2, sides); + cairo_stroke (cr); cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x, y, width, height, sides); cairo_stroke (cr); if (gap_side == GTK_POS_RIGHT || gap_side == GTK_POS_BOTTOM) - add_path_gap_side (cr, gap_side, 0, - x, y, width, height, - xy0_gap, xy1_gap); + { + gdk_cairo_set_source_color (cr, &darker); + add_path_gap_side (cr, gap_side, + x, y, width - 2, height - 2, + xy0_gap, xy1_gap); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, sides, - x, y, width - 1, height - 1); - - gdk_cairo_set_source_color (cr, &darker); - cairo_stroke (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_gap_side (cr, gap_side, + x, y, width - 1, height - 1, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } if (gap_side == GTK_POS_LEFT) sides = SIDE_TOP; @@ -1403,18 +1404,20 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_TOP | SIDE_LEFT; - if (gap_side == GTK_POS_TOP || - gap_side == GTK_POS_LEFT) - add_path_gap_side (cr, gap_side, 0, - x, y, width, height, - xy0_gap, xy1_gap); - - add_path_rounded_rectangle (cr, 0, sides, - x, y, width, height); - gdk_cairo_set_source_color (cr, &lighter); + + add_path_rectangle_sides (cr, x, y, width, height, sides); cairo_stroke (cr); + if (gap_side == GTK_POS_LEFT || + gap_side == GTK_POS_TOP) + { + add_path_gap_side (cr, gap_side, + x, y, width, height, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } + cairo_restore (cr); gdk_color_free (bg_color); From 44373ec551a25a110aa073b23f5aab2798882647 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 11:59:27 +0200 Subject: [PATCH 212/634] GtkThemingEngine: Cairo-ify frame rendering from GtkStyle. --- gtk/gtkthemingengine.c | 118 ++++++++++++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 30 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b974b45620..7457bc3ca3 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -867,8 +867,8 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, { GtkStateFlags flags; GtkStateType state; - GdkColor *bg_color; GdkColor lighter, darker; + GdkColor *bg_color; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -888,52 +888,110 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); - if (flags & GTK_STATE_FLAG_ACTIVE) + if (gtk_theming_engine_has_class (engine, "entry") || + gtk_theming_engine_has_class (engine, "scrolled-window")) { - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT, - x, y, width, height); + gdk_cairo_set_source_color (cr, bg_color); + add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 1, 1, 1); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); + } + else if (gtk_theming_engine_has_class (engine, "button") && + gtk_theming_engine_has_class (engine, "default")) + { + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_rectangle (cr, x + 0.5, x + 0.5, width - 1, height - 1); + cairo_stroke (cr); + } + else if (gtk_theming_engine_has_class (engine, "scrollbar") && + gtk_theming_engine_has_class (engine, "trough")) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); + } + else if (gtk_theming_engine_has_class (engine, "spinbutton")) + { + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, - SIDE_TOP | SIDE_LEFT, - x + 1, y + 1, width - 2, height - 2); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_stroke (cr); - - add_path_rounded_rectangle (cr, 0, - SIDE_TOP | SIDE_LEFT, - x, y, width, height); gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, bg_color); + add_path_rectangle_sides (cr, x, y, width - 1, height - 1, SIDE_BOTTOM); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, + SIDE_TOP | SIDE_LEFT | SIDE_RIGHT); cairo_stroke (cr); } else { - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT, - x, y, width, height); + if (flags & GTK_STATE_FLAG_ACTIVE) + { + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, - SIDE_BOTTOM | SIDE_RIGHT, - x, y, width - 1, height - 1); + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); + } + else + { + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width - 1, height - 1, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_TOP | SIDE_LEFT); + cairo_stroke (cr); - add_path_rounded_rectangle (cr, 0, - SIDE_TOP | SIDE_LEFT, - x, y, width, height); - - gdk_cairo_set_source_color (cr, &lighter); - cairo_stroke (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); + } } cairo_restore (cr); + + gdk_color_free (bg_color); } static void From 227c500dced238f6c04f2729ca5e9bd3b6a734e2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 19 Jul 2010 12:00:07 +0200 Subject: [PATCH 213/634] GtkThemingEngine: Improve slider rendering. --- gtk/gtkthemingengine.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 7457bc3ca3..5f34ce31c0 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1369,22 +1369,30 @@ gtk_theming_engine_render_slider (GtkThemingEngine *engine, GtkOrientation orientation) { const GtkWidgetPath *path; + gint thickness; path = gtk_theming_engine_get_path (engine); gtk_theming_engine_render_background (engine, cr, x, y, width, height); gtk_theming_engine_render_frame (engine, cr, x, y, width, height); - if (gtk_widget_path_has_parent (path, GTK_TYPE_SCALE)) + /* FIXME: thickness */ + thickness = 2; + + if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE)) { if (orientation == GTK_ORIENTATION_VERTICAL) gtk_theming_engine_render_line (engine, cr, - x + 2, y + height / 2 - 1, - x + width - 4, y + height / 2 - 1); + x + thickness, + y + (gint) height / 2, + x + width - thickness - 1, + y + (gint) height / 2); else gtk_theming_engine_render_line (engine, cr, - x + width / 2 - 1, y + 4, - x + width / 2 - 1, y + height - 4); + x + (gint) width / 2, + y + thickness, + x + (gint) width / 2, + y + height - thickness - 1); } } From 0813a2283e8b1ba3924d3b594c4259c5d7297c28 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 13:46:25 +0200 Subject: [PATCH 214/634] GtkCssProvider: Allow '_' in the middle of symbolic color names. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 8989457bef..5a4d82ae35 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -709,7 +709,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, else if (scope == SCOPE_SELECTOR) { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_PSEUDO_CLASS || From 7748b1d2deea3fa06942e4e6251bf4f88fa83876 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 13:50:17 +0200 Subject: [PATCH 215/634] GtkStyleContext: ensure class lookup return the correct insertion position if not found. --- gtk/gtkstylecontext.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c1ec55dd7e..b58612df15 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -646,7 +646,7 @@ style_class_find (GArray *array, GQuark class_quark, guint *position) { - guint min, max, mid; + gint min, max, mid; gboolean found = FALSE; if (position) @@ -668,11 +668,14 @@ style_class_find (GArray *array, if (class_quark == item) found = TRUE; else if (class_quark > item) - min = mid + 1; + min = mid = mid + 1; else - max = mid - 1; + max = mid = mid - 1; } - while (!found && min < max); + while (!found && min <= max); + + if (mid < 0) + mid = 0; if (position) *position = mid; @@ -685,7 +688,7 @@ child_style_class_find (GArray *array, GQuark class_quark, guint *position) { - guint min, max, mid; + gint min, max, mid; gboolean found = FALSE; if (position) @@ -707,11 +710,14 @@ child_style_class_find (GArray *array, if (child_class->class_quark == class_quark) found = TRUE; else if (child_class->class_quark > class_quark) - min = mid + 1; + min = mid = mid + 1; else - max = mid - 1; + max = mid = mid - 1; } - while (!found && min < max); + while (!found && min <= max); + + if (mid < 0) + mid = 0; if (position) *position = mid; From 5f2e8bc0d10bd89bc4b0a7f49e1557d68313c805 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 13:52:28 +0200 Subject: [PATCH 216/634] GtkStyleContext: Ensure style rebuilds after adding/removing classes. --- gtk/gtkstylecontext.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index b58612df15..63c28cae7a 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -639,6 +639,26 @@ gtk_style_context_restore (GtkStyleContext *context) region = style_region_new (); priv->regions = g_slist_prepend (priv->regions, region); } + + if (priv->widget_path) + { + GtkStyleRegion *region; + guint i; + + /* Update widget path regions */ + gtk_widget_path_iter_clear_regions (priv->widget_path, 0); + region = priv->regions->data; + + for (i = 0; i < region->child_style_classes->len; i++) + { + GtkChildClass *child_class; + + child_class = &g_array_index (region->child_style_classes, GtkChildClass, i); + gtk_widget_path_iter_add_region (priv->widget_path, 0, + g_quark_to_string (child_class->class_quark), + child_class->flags); + } + } } static gboolean @@ -858,6 +878,12 @@ gtk_style_context_set_child_class (GtkStyleContext *context, child_class.flags = flags; g_array_insert_val (region->child_style_classes, position, child_class); + + if (priv->widget_path) + { + gtk_widget_path_iter_add_region (priv->widget_path, 0, class_name, flags); + rebuild_properties (context); + } } } @@ -884,7 +910,15 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, region = priv->regions->data; if (child_style_class_find (region->child_style_classes, class_quark, &position)) - g_array_remove_index (region->child_style_classes, position); + { + g_array_remove_index (region->child_style_classes, position); + + if (priv->widget_path) + { + gtk_widget_path_iter_remove_region (priv->widget_path, 0, class_name); + rebuild_properties (context); + } + } } gboolean From c71248091218455c17939cfe0d82a6fe20d4158e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 13:58:16 +0200 Subject: [PATCH 217/634] GtkStyleContext: Add varargs functions for getting widget style properties. --- gtk/gtkstylecontext.c | 72 +++++++++++++++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 4 +++ 2 files changed, 76 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 63c28cae7a..f7297f71cb 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -21,6 +21,7 @@ #include #include +#include #include "gtkstylecontext.h" #include "gtktypebuiltins.h" @@ -1086,6 +1087,77 @@ gtk_style_context_get_style_property (GtkStyleContext *context, G_VALUE_TYPE_NAME (value)); } +void +gtk_style_context_get_style_valist (GtkStyleContext *context, + va_list args) +{ + GtkStyleContextPrivate *priv; + const gchar *prop_name; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + prop_name = va_arg (args, const gchar *); + priv = context->priv; + + if (!priv->widget_path) + return; + + while (prop_name) + { + GtkWidgetClass *widget_class; + GParamSpec *pspec; + const GValue *peek_value; + GType widget_type; + gchar *error; + + widget_type = gtk_widget_path_get_widget_type (priv->widget_path); + + widget_class = g_type_class_ref (widget_type); + pspec = gtk_widget_class_find_style_property (widget_class, prop_name); + g_type_class_unref (widget_class); + + if (!pspec) + { + g_warning ("%s: widget class `%s' has no style property named `%s'", + G_STRLOC, + g_type_name (widget_type), + prop_name); + continue; + } + + peek_value = _gtk_style_context_peek_style_property (context, + widget_type, + pspec); + + G_VALUE_LCOPY (peek_value, args, 0, &error); + + if (error) + { + g_warning ("can't retrieve style property `%s' of type `%s': %s", + pspec->name, + G_VALUE_TYPE_NAME (peek_value), + error); + g_free (error); + } + + prop_name = va_arg (args, const gchar *); + } +} + +void +gtk_style_context_get_style (GtkStyleContext *context, + ...) +{ + va_list args; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + va_start (args, context); + gtk_style_context_get_style_valist (context, args); + va_end (args); +} + + GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index f578b261bc..d1291a35f2 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -102,6 +102,10 @@ gboolean gtk_style_context_has_child_class (GtkStyleContext *context, void gtk_style_context_get_style_property (GtkStyleContext *context, const gchar *property_name, GValue *value); +void gtk_style_context_get_style_valist (GtkStyleContext *context, + va_list args); +void gtk_style_context_get_style (GtkStyleContext *context, + ...); GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id); From 0dc81b9a35c982444a47c4097211e2254d711511 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:26:41 +0200 Subject: [PATCH 218/634] GtkStyleSet: Allow setting default value when registering properties. This is now used for the "engine" keyword, where the default engine is used if none is specified. --- gtk/gtkstyleset.c | 58 +++++++++++++++++++++++++++++++++++------------ gtk/gtkstyleset.h | 3 ++- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index f1e3f342ba..15db395a00 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -38,6 +38,7 @@ struct PropertyNode { GQuark property_quark; GType property_type; + GValue default_value; }; struct PropertyData @@ -66,19 +67,24 @@ static void gtk_style_set_class_init (GtkStyleSetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + GValue val = { 0 }; object_class->finalize = gtk_style_set_finalize; /* Initialize default property set */ - gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR); - gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR); - gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR); - gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR); + gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR, NULL); + gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR, NULL); + gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR, NULL); + gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR, NULL); - gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION); + gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL); - gtk_style_set_register_property ("padding", GTK_TYPE_BORDER); - gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE); + gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL); + + g_value_init (&val, GTK_TYPE_THEMING_ENGINE); + g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); + gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val); + g_value_unset (&val); g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } @@ -180,7 +186,8 @@ property_node_lookup (GQuark quark) /* Property registration functions */ void gtk_style_set_register_property (const gchar *property_name, - GType type) + GType type, + const GValue *default_value) { PropertyNode *node, new = { 0 }; GQuark quark; @@ -206,6 +213,12 @@ gtk_style_set_register_property (const gchar *property_name, new.property_quark = quark; new.property_type = type; + if (default_value) + { + g_value_init (&new.default_value, G_VALUE_TYPE (default_value)); + g_value_copy (default_value, &new.default_value); + } + for (i = 0; i < properties->len; i++) { node = &g_array_index (properties, PropertyNode, i); @@ -516,8 +529,10 @@ gtk_style_set_get_property (GtkStyleSet *set, if (G_IS_VALUE (&prop->values[state])) val = &prop->values[state]; - else + else if (G_IS_VALUE (&prop->default_value)) val = &prop->default_value; + else + val = &node->default_value; g_return_val_if_fail (G_IS_VALUE (val), FALSE); @@ -565,7 +580,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop) + if (!prop && !G_IS_VALUE (&node->default_value)) { GValue *empty_value = { 0 }; @@ -578,10 +593,15 @@ gtk_style_set_get_valist (GtkStyleSet *set, { GValue *val; - if (G_IS_VALUE (&prop->values[state])) - val = &prop->values[state]; + if (prop) + { + if (G_IS_VALUE (&prop->values[state])) + val = &prop->values[state]; + else if (G_IS_VALUE (&prop->default_value)) + val = &prop->default_value; + } else - val = &prop->default_value; + val = &node->default_value; if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { @@ -724,8 +744,13 @@ gtk_style_set_merge (GtkStyleSet *set, if (replace || G_VALUE_TYPE (&prop->values[i]) == G_TYPE_INVALID) { - if (G_VALUE_TYPE (&prop->values[i]) == G_TYPE_INVALID) + if (!G_IS_VALUE (&prop->values[i])) g_value_init (&prop->values[i], G_VALUE_TYPE (&prop_to_merge->values[i])); + else if (G_VALUE_TYPE (&prop->values[i]) != G_VALUE_TYPE (&prop_to_merge->values[i])) + { + g_value_unset (&prop->values[i]); + g_value_init (&prop->values[i], G_VALUE_TYPE (&prop_to_merge->values[i])); + } g_value_copy (&prop_to_merge->values[i], &prop->values[i]); @@ -746,6 +771,11 @@ gtk_style_set_merge (GtkStyleSet *set, if (!G_IS_VALUE (&prop->default_value)) g_value_init (&prop->default_value, G_VALUE_TYPE (&prop_to_merge->default_value)); + else if (G_VALUE_TYPE (&prop->default_value) != G_VALUE_TYPE (&prop_to_merge->default_value)) + { + g_value_unset (&prop->default_value); + g_value_init (&prop->default_value, G_VALUE_TYPE (&prop_to_merge->default_value)); + } g_value_copy (&prop_to_merge->default_value, &prop->default_value); diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 24f6b99871..6b828345ac 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -52,7 +52,8 @@ GType gtk_style_set_get_type (void) G_GNUC_CONST; /* Functions to register style properties */ void gtk_style_set_register_property (const gchar *property_name, - GType type); + GType type, + const GValue *default_value); gboolean gtk_style_set_lookup_property (const gchar *property_name, GType *type); From c18ee462e376f271b23d23b2a5a1f683ad9ab619 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:33:20 +0200 Subject: [PATCH 219/634] GtkThemingEngine: Add methods to retrieve widget style properties. --- gtk/gtkthemingengine.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 9 +++++++++ 2 files changed, 51 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 5f34ce31c0..216b1f2293 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -243,6 +243,48 @@ gtk_theming_engine_get (GtkThemingEngine *engine, va_end (args); } +void +gtk_theming_engine_get_style_property (GtkThemingEngine *engine, + const gchar *property_name, + GValue *value) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (property_name != NULL); + + priv = engine->priv; + gtk_style_context_get_style_property (priv->context, property_name, value); +} + +void +gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, + va_list args) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_style_valist (priv->context, args); +} + +void +gtk_theming_engine_get_style (GtkThemingEngine *engine, + ...) +{ + GtkThemingEnginePrivate *priv; + va_list args; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + + va_start (args, engine); + gtk_style_context_get_style_valist (priv->context, args); + va_end (args); +} + GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine) { diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 9e337f818a..5703b2cc20 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -150,6 +150,15 @@ void gtk_theming_engine_get (GtkThemingEngine *engine, GtkStateType state, ...) G_GNUC_NULL_TERMINATED; +void gtk_theming_engine_get_style_property (GtkThemingEngine *engine, + const gchar *property_name, + GValue *value); +void gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, + va_list args); +void gtk_theming_engine_get_style (GtkThemingEngine *engine, + ...); + + G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, From 911431c0b21e5ab9a7d592d4112afc5767aacc59 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:45:13 +0200 Subject: [PATCH 220/634] GtkThemingEngine: Improve pixel alignment in arrows. --- gtk/gtkthemingengine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 216b1f2293..547f37321a 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -700,9 +700,9 @@ add_path_arrow (cairo_t *cr, cairo_translate (cr, x + (size / 2), y + (size / 2)); cairo_rotate (cr, angle); - cairo_move_to (cr, 0, - (size / 4) + 0.5); - cairo_line_to (cr, - (size / 2), (size / 4) + 0.5); - cairo_line_to (cr, (size / 2), (size / 4) + 0.5); + cairo_move_to (cr, 0, - (size / 4)); + cairo_line_to (cr, - (size / 2), (size / 4)); + cairo_line_to (cr, (size / 2), (size / 4)); cairo_close_path (cr); cairo_restore (cr); From 7482b636e6ec72c8a2f2601cd2e53fc4aa89b833 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:46:08 +0200 Subject: [PATCH 221/634] GtkThemingEngine: Improve background rendering. Now active and selected states are taken into account, and GtkSpinButton buttons are special cased. --- gtk/gtkthemingengine.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 547f37321a..972722e5ae 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -865,7 +865,11 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) + if (flags & GTK_STATE_FLAG_ACTIVE) + state = GTK_STATE_ACTIVE; + else if (flags & GTK_STATE_FLAG_SELECTED) + state = GTK_STATE_SELECTED; + else if (flags & GTK_STATE_FLAG_PRELIGHT) state = GTK_STATE_PRELIGHT; else if (flags & GTK_STATE_FLAG_INSENSITIVE) state = GTK_STATE_INSENSITIVE; @@ -882,7 +886,12 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, NULL); gdk_cairo_set_source_color (cr, color); - cairo_rectangle (cr, x, y, width, height); + + if (gtk_theming_engine_has_class (engine, "spinbutton") && + gtk_theming_engine_has_class (engine, "button")) + cairo_rectangle (cr, x + 2, y + 2, width - 4, height - 4); + else + cairo_rectangle (cr, x, y, width, height); if (gtk_theming_engine_has_class (engine, "tooltip")) { From d22f393be3d8c8b293b6296bb772083e3daadbc3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:48:31 +0200 Subject: [PATCH 222/634] GtkThemingEngine: Render frames and spinbutton boxes properly. --- gtk/gtkthemingengine.c | 44 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 972722e5ae..51d561d1b6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -940,7 +940,8 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, color_shade (bg_color, 1.3, &lighter); if (gtk_theming_engine_has_class (engine, "entry") || - gtk_theming_engine_has_class (engine, "scrolled-window")) + gtk_theming_engine_has_class (engine, "scrolled-window") || + gtk_theming_engine_has_class (engine, "viewport")) { gdk_cairo_set_source_color (cr, bg_color); add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, @@ -984,23 +985,36 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, } else if (gtk_theming_engine_has_class (engine, "spinbutton")) { - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); + if (gtk_theming_engine_has_class (engine, "button")) + { + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x + 1, y + 2, width - 3, height - 2, SIDE_TOP); + cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x + 1, y + 2, width - 3, height - 2, SIDE_BOTTOM); + cairo_stroke (cr); + } + else + { + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT); + cairo_stroke (cr); - gdk_cairo_set_source_color (cr, bg_color); - add_path_rectangle_sides (cr, x, y, width - 1, height - 1, SIDE_BOTTOM); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); + cairo_stroke (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, - SIDE_TOP | SIDE_LEFT | SIDE_RIGHT); - cairo_stroke (cr); + gdk_cairo_set_source_color (cr, bg_color); + add_path_rectangle_sides (cr, x, y, width - 1, height - 1, SIDE_BOTTOM); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_rectangle_sides (cr, x, y + 1, width - 1, height - 3, + SIDE_TOP | SIDE_LEFT | SIDE_RIGHT); + cairo_stroke (cr); + } } else { From eadaded37433e7cbba8148d96fd5f8cc49026136 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:49:45 +0200 Subject: [PATCH 223/634] GtkThemingEngine: Rip out expander rendering from old code. --- gtk/gtkthemingengine.c | 76 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 51d561d1b6..83dbcc3f60 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1070,7 +1070,15 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, GtkStateFlags flags; GdkColor *bg_color, *fg_color, *base_color; GtkStateType state; + double vertical_overshoot; + int diameter; + double radius; + double interp; /* interpolation factor for center position */ + double x_double_horz, y_double_horz; + double x_double_vert, y_double_vert; + double x_double, y_double; gdouble angle; + gint line_width; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -1088,14 +1096,68 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, "base-color", &base_color, NULL); - if (flags & GTK_STATE_FLAG_ACTIVE) - angle = G_PI; - else - angle = G_PI / 2; + line_width = 1; - cairo_set_line_width (cr, 1); - add_path_arrow (cr, angle, x + 2, y + 2, - MIN (width - 1, height - 1) - 4); + /* FIXME: LTR/RTL */ + if (flags & GTK_STATE_FLAG_ACTIVE) + { + angle = G_PI / 2; + interp = 1.0; + } + else + { + angle = 0; + interp = 0; + } + + /* Compute distance that the stroke extends beyonds the end + * of the triangle we draw. + */ + vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8)); + + /* For odd line widths, we end the vertical line of the triangle + * at a half pixel, so we round differently. + */ + if (line_width % 2 == 1) + vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5; + else + vertical_overshoot = ceil (vertical_overshoot); + + /* Adjust the size of the triangle we draw so that the entire stroke fits + */ + diameter = (gint) MAX (3, width - 2 * vertical_overshoot); + + /* If the line width is odd, we want the diameter to be even, + * and vice versa, so force the sum to be odd. This relationship + * makes the point of the triangle look right. + */ + diameter -= (1 - (diameter + line_width) % 2); + + radius = diameter / 2.; + + /* Adjust the center so that the stroke is properly aligned with + * the pixel grid. The center adjustment is different for the + * horizontal and vertical orientations. For intermediate positions + * we interpolate between the two. + */ + x_double_vert = floor ((x + width / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.; + y_double_vert = (y + height / 2) - 0.5; + + x_double_horz = (x + width / 2) - 0.5; + y_double_horz = floor ((y + height / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.; + + x_double = x_double_vert * (1 - interp) + x_double_horz * interp; + y_double = y_double_vert * (1 - interp) + y_double_horz * interp; + + cairo_translate (cr, x_double, y_double); + cairo_rotate (cr, angle); + + cairo_move_to (cr, - radius / 2., - radius); + cairo_line_to (cr, radius / 2., 0); + cairo_line_to (cr, - radius / 2., radius); + cairo_close_path (cr); + + cairo_set_line_width (cr, line_width); if (flags & GTK_STATE_FLAG_PRELIGHT) gdk_cairo_set_source_color (cr, fg_color); From 5510f24cc11c4fe1ce01b615000c6e4c51d20702 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:50:37 +0200 Subject: [PATCH 224/634] GtkThemingEngine: Rip out focus rendering from old code. --- gtk/gtkthemingengine.c | 56 +++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 83dbcc3f60..69d048e9ae 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1184,10 +1184,11 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdouble width, gdouble height) { - const double dashes[] = { 0.5, 1.5 }; - GdkColor *base_color; GtkStateFlags flags; GtkStateType state; + GdkColor *color; + gint line_width; + gint8 *dash_list; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -1200,24 +1201,57 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, state = GTK_STATE_NORMAL; gtk_theming_engine_get (engine, state, - "base-color", &base_color, + "foreground-color", &color, NULL); - cairo_set_line_width (cr, 1.0); - cairo_set_dash (cr, dashes, 2, 0); + gtk_theming_engine_get_style (engine, + "focus-line-width", &line_width, + "focus-line-pattern", (gchar *) &dash_list, + NULL); + + cairo_set_line_width (cr, (gdouble) line_width); + + if (dash_list[0]) + { + gint n_dashes = strlen ((const gchar *) dash_list); + gdouble *dashes = g_new (gdouble, n_dashes); + gdouble total_length = 0; + gdouble dash_offset; + gint i; + + for (i = 0; i < n_dashes; i++) + { + dashes[i] = dash_list[i]; + total_length += dash_list[i]; + } + + /* The dash offset here aligns the pattern to integer pixels + * by starting the dash at the right side of the left border + * Negative dash offsets in cairo don't work + * (https://bugs.freedesktop.org/show_bug.cgi?id=2729) + */ + dash_offset = - line_width / 2.; + + while (dash_offset < 0) + dash_offset += total_length; + + cairo_set_dash (cr, dashes, n_dashes, dash_offset); + g_free (dashes); + } cairo_rectangle (cr, - x + 0.5, - y + 0.5, - width - 1, - height - 1); + x + line_width / 2., + y + line_width / 2., + width - line_width, + height - line_width); - gdk_cairo_set_source_color (cr, base_color); + gdk_cairo_set_source_color (cr, color); cairo_stroke (cr); cairo_restore (cr); - gdk_color_free (base_color); + gdk_color_free (color); + g_free (dash_list); } static void From d858801ec38ea9c6ffd4c0d670a358212dc3fa5e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:51:23 +0200 Subject: [PATCH 225/634] GtkThemingEngine: Obey active/selected when rendering text. --- gtk/gtkthemingengine.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 69d048e9ae..65de2cbd12 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1487,7 +1487,11 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, /* FIXME: Set clipping */ - if (flags & GTK_STATE_FLAG_PRELIGHT) + if (flags & GTK_STATE_FLAG_ACTIVE) + state = GTK_STATE_ACTIVE; + else if (flags & GTK_STATE_FLAG_SELECTED) + state = GTK_STATE_SELECTED; + else if (flags & GTK_STATE_FLAG_PRELIGHT) state = GTK_STATE_PRELIGHT; else if (flags & GTK_STATE_FLAG_INSENSITIVE) state = GTK_STATE_INSENSITIVE; From 1e83e52b3d58b5bda9b43d0c2c98d94dcaa9f030 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 15:52:26 +0200 Subject: [PATCH 226/634] GtkThemingEngine: Add code to render GtkFrame frame with gap. --- gtk/gtkthemingengine.c | 146 ++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 40 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 65de2cbd12..8168dc985a 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1596,57 +1596,123 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); - if (gap_side == GTK_POS_RIGHT) - sides = SIDE_BOTTOM; - else if (gap_side == GTK_POS_BOTTOM) - sides = SIDE_RIGHT; - else - sides = SIDE_BOTTOM | SIDE_RIGHT; - - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x + 1, y, width - 2, height, sides); - add_path_rectangle_sides (cr, x, y + 1, width, height - 2, sides); - cairo_stroke (cr); - - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x, y, width, height, sides); - cairo_stroke (cr); - - if (gap_side == GTK_POS_RIGHT || - gap_side == GTK_POS_BOTTOM) + if (gtk_theming_engine_has_class (engine, "frame")) { + if (gap_side == GTK_POS_RIGHT) + sides = SIDE_BOTTOM; + else if (gap_side == GTK_POS_BOTTOM) + sides = SIDE_RIGHT; + else + sides = SIDE_BOTTOM | SIDE_RIGHT; + + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x , y, width , height, sides); + cairo_stroke (cr); + gdk_cairo_set_source_color (cr, &darker); - add_path_gap_side (cr, gap_side, - x, y, width - 2, height - 2, - xy0_gap, xy1_gap); + add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides); + cairo_stroke (cr); + + if (gap_side == GTK_POS_RIGHT || + gap_side == GTK_POS_BOTTOM) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_gap_side (cr, gap_side, + x + 1, y + 1, width - 4, height - 4, + xy0_gap, xy1_gap); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &lighter); + add_path_gap_side (cr, gap_side, + x, y, width, height, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } + + if (gap_side == GTK_POS_LEFT) + sides = SIDE_TOP; + else if (gap_side == GTK_POS_TOP) + sides = SIDE_LEFT; + else + sides = SIDE_TOP | SIDE_LEFT; + + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 3, sides); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides); + cairo_stroke (cr); + + if (gap_side == GTK_POS_LEFT || + gap_side == GTK_POS_TOP) + { + gdk_cairo_set_source_color (cr, &lighter); + add_path_gap_side (cr, gap_side, + x + 1, y + 1, width - 4, height - 4, + xy0_gap, xy1_gap); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &darker); + add_path_gap_side (cr, gap_side, + x, y, width - 2, height - 2, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } + } + else + { + if (gap_side == GTK_POS_RIGHT) + sides = SIDE_BOTTOM; + else if (gap_side == GTK_POS_BOTTOM) + sides = SIDE_RIGHT; + else + sides = SIDE_BOTTOM | SIDE_RIGHT; + + gdk_cairo_set_source_color (cr, &darker); + add_path_rectangle_sides (cr, x + 1, y, width - 2, height, sides); + add_path_rectangle_sides (cr, x, y + 1, width, height - 2, sides); cairo_stroke (cr); cairo_set_source_rgb (cr, 0, 0, 0); - add_path_gap_side (cr, gap_side, - x, y, width - 1, height - 1, - xy0_gap, xy1_gap); + add_path_rectangle_sides (cr, x, y, width, height, sides); cairo_stroke (cr); - } - if (gap_side == GTK_POS_LEFT) - sides = SIDE_TOP; - else if (gap_side == GTK_POS_TOP) - sides = SIDE_LEFT; - else - sides = SIDE_TOP | SIDE_LEFT; + if (gap_side == GTK_POS_RIGHT || + gap_side == GTK_POS_BOTTOM) + { + gdk_cairo_set_source_color (cr, &darker); + add_path_gap_side (cr, gap_side, + x, y, width - 2, height - 2, + xy0_gap, xy1_gap); + cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &lighter); + cairo_set_source_rgb (cr, 0, 0, 0); + add_path_gap_side (cr, gap_side, + x, y, width - 1, height - 1, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } - add_path_rectangle_sides (cr, x, y, width, height, sides); - cairo_stroke (cr); + if (gap_side == GTK_POS_LEFT) + sides = SIDE_TOP; + else if (gap_side == GTK_POS_TOP) + sides = SIDE_LEFT; + else + sides = SIDE_TOP | SIDE_LEFT; - if (gap_side == GTK_POS_LEFT || - gap_side == GTK_POS_TOP) - { - add_path_gap_side (cr, gap_side, - x, y, width, height, - xy0_gap, xy1_gap); + gdk_cairo_set_source_color (cr, &lighter); + add_path_rectangle_sides (cr, x, y, width, height, sides); cairo_stroke (cr); + + if (gap_side == GTK_POS_LEFT || + gap_side == GTK_POS_TOP) + { + add_path_gap_side (cr, gap_side, + x, y, width, height, + xy0_gap, xy1_gap); + cairo_stroke (cr); + } } cairo_restore (cr); From 09d6c4ea52b662edd867e825dff96fcace1604c2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:05:58 +0200 Subject: [PATCH 227/634] GtkStyle: Optionally construct above a GtkStyleContext. --- gtk/gtkstyle.c | 158 ++++++++++++++++++++++++++++++++++++++++++++----- gtk/gtkstyle.h | 4 ++ 2 files changed, 148 insertions(+), 14 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 0dc5387c98..d16f4f4a03 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -78,10 +78,22 @@ typedef struct _GtkStylePrivate GtkStylePrivate; struct _GtkStylePrivate { GSList *color_hashes; + GtkStyleContext *context; +}; + +enum { + PROP_0, + PROP_CONTEXT }; /* --- prototypes --- */ static void gtk_style_finalize (GObject *object); +static void gtk_style_constructed (GObject *object); +static void gtk_style_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + static void gtk_style_realize (GtkStyle *style, GdkVisual *visual); static void gtk_style_real_realize (GtkStyle *style); @@ -450,6 +462,8 @@ gtk_style_class_init (GtkStyleClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gtk_style_finalize; + object_class->set_property = gtk_style_set_property; + object_class->constructed = gtk_style_constructed; klass->clone = gtk_style_real_clone; klass->copy = gtk_style_real_copy; @@ -482,6 +496,14 @@ gtk_style_class_init (GtkStyleClass *klass) g_type_class_add_private (object_class, sizeof (GtkStylePrivate)); + g_object_class_install_property (object_class, + PROP_CONTEXT, + g_param_spec_object ("context", + P_("Style context"), + P_("GtkStyleContext to get style from"), + GTK_TYPE_STYLE_CONTEXT, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); + /** * GtkStyle::realize: * @style: the object which received the signal @@ -587,9 +609,110 @@ gtk_style_finalize (GObject *object) if (style->rc_style) g_object_unref (style->rc_style); + if (priv->context) + g_object_unref (priv->context); + G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object); } +static void +gtk_style_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkStylePrivate *priv; + + priv = GTK_STYLE_GET_PRIVATE (object); + + switch (prop_id) + { + case PROP_CONTEXT: + priv->context = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_color (GtkStyle *style, + GtkStyleContext *context, + GtkStateType state, + GtkRcFlags prop) +{ + GdkColor *color = NULL; + + switch (prop) + { + case GTK_RC_BG: + gtk_style_context_get (context, state, + "background-color", &color, + NULL); + if (color) + style->bg[state] = *color; + break; + case GTK_RC_FG: + gtk_style_context_get (context, state, + "foreground-color", &color, + NULL); + if (color) + style->fg[state] = *color; + break; + case GTK_RC_TEXT: + gtk_style_context_get (context, state, + "text-color", &color, + NULL); + if (color) + style->text[state] = *color; + break; + case GTK_RC_BASE: + gtk_style_context_get (context, state, + "base-color", &color, + NULL); + if (color) + style->base[state] = *color; + break; + } + + if (color) + gdk_color_free (color); +} + +static void +gtk_style_update_from_context (GtkStyle *style) +{ + GtkStylePrivate *priv; + GtkStateType state; + + priv = GTK_STYLE_GET_PRIVATE (style); + + for (state = GTK_STATE_NORMAL; state <= GTK_STATE_INSENSITIVE; state++) + { + set_color (style, priv->context, state, GTK_RC_BG); + set_color (style, priv->context, state, GTK_RC_FG); + set_color (style, priv->context, state, GTK_RC_BASE); + set_color (style, priv->context, state, GTK_RC_TEXT); + } + + /* FIXME: thickness */ +} + +static void +gtk_style_constructed (GObject *object) +{ + GtkStylePrivate *priv; + + priv = GTK_STYLE_GET_PRIVATE (object); + + if (priv->context) + { + gtk_style_update_from_context (GTK_STYLE (object)); + + /* FIXME: Listen to context changes */ + } +} /** * gtk_style_copy: @@ -648,6 +771,16 @@ gtk_style_new (void) return style; } +gboolean +gtk_style_has_context (GtkStyle *style) +{ + GtkStylePrivate *priv; + + priv = GTK_STYLE_GET_PRIVATE (style); + + return priv->context != NULL; +} + /** * gtk_style_attach: * @style: a #GtkStyle. @@ -793,23 +926,14 @@ GtkIconSet* gtk_style_lookup_icon_set (GtkStyle *style, const char *stock_id) { - GSList *iter; + GtkStylePrivate *priv; g_return_val_if_fail (GTK_IS_STYLE (style), NULL); g_return_val_if_fail (stock_id != NULL, NULL); - - iter = style->icon_factories; - while (iter != NULL) - { - GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data), - stock_id); - if (icon_set) - return icon_set; - - iter = g_slist_next (iter); - } - return gtk_icon_factory_lookup_default (stock_id); + priv = GTK_STYLE_GET_PRIVATE (style); + + return gtk_style_context_lookup_icon_set (priv->context, stock_id); } /** @@ -883,7 +1007,13 @@ gtk_style_set_background (GtkStyle *style, static GtkStyle * gtk_style_real_clone (GtkStyle *style) { - return g_object_new (G_OBJECT_TYPE (style), NULL); + GtkStylePrivate *priv; + + priv = GTK_STYLE_GET_PRIVATE (style); + + return g_object_new (G_OBJECT_TYPE (style), + "context", priv->context, + NULL); } static void diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 84a018ce1a..d57c4371a3 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -678,6 +678,10 @@ void gtk_draw_insertion_cursor (GtkWidget *widget, void _gtk_widget_get_cursor_color (GtkWidget *widget, GdkColor *color); +gboolean gtk_style_has_context (GtkStyle *style); + + + G_END_DECLS #endif /* __GTK_STYLE_H__ */ From 6c549fecd3006b435be9d25eae1f8cabbc66efa5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:11:40 +0200 Subject: [PATCH 228/634] GtkWidget: Construct style for partial widget hierarchies. Some unparented widgets like to ask style details, so now the style is constructed regardless of the parent being present or not, and then reconstructed if the parent changes. --- gtk/gtkwidget.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 24cb380923..8cca7a07dd 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13195,7 +13195,6 @@ gtk_widget_get_path (GtkWidget *widget) GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - g_return_val_if_fail ((widget->parent || gtk_widget_is_toplevel (widget)), NULL); parent = widget->priv->parent; @@ -13254,6 +13253,7 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { static GtkCssProvider *css_provider = NULL; + GtkWidgetPath *path; context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); g_object_set_qdata_full (G_OBJECT (widget), @@ -13284,18 +13284,13 @@ gtk_widget_get_style_context (GtkWidget *widget) GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); - if (widget->parent || - gtk_widget_is_toplevel (widget)) - { - GtkWidgetPath *path; - path = gtk_widget_get_path (widget); - gtk_style_context_set_path (context, path); - gtk_widget_path_free (path); + path = gtk_widget_get_path (widget); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); - gtk_style_context_set_screen (context, - gtk_widget_get_screen (widget)); - } + gtk_style_context_set_screen (context, + gtk_widget_get_screen (widget)); } return context; From 9255e20bf8872e3873bfeb2fd9d06d476513daff Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:14:17 +0200 Subject: [PATCH 229/634] GtkWidget: Create GtkStyle on top of GtkStyleContext. --- gtk/gtkwidget.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8cca7a07dd..5de120fc9b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7286,7 +7286,7 @@ gtk_widget_set_parent (GtkWidget *widget, } context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); + quark_style_context); if (context) { GtkWidgetPath *path; @@ -7420,8 +7420,22 @@ gtk_widget_ensure_style (GtkWidget *widget) { g_return_if_fail (GTK_IS_WIDGET (widget)); + if (!widget->priv->style || + !gtk_style_has_context (widget->priv->style)) + { + GtkStyle *style; + + style = g_object_new (GTK_TYPE_STYLE, + "context", gtk_widget_get_style_context (widget), + NULL); + + gtk_widget_set_style_internal (widget, style, TRUE); + } + +#if 0 if (!widget->priv->rc_style && !widget->priv->user_style) gtk_widget_reset_rc_style (widget); +#endif } /* Look up the RC style for this widget, unsetting any user style that From bd6751230a577356b51170b44a2466360161743f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:15:06 +0200 Subject: [PATCH 230/634] GtkStyle: Move gtk_render_* calls to default vmethod implementations. --- gtk/gtkstyle.c | 2678 ++++++++++++++---------------------------------- 1 file changed, 754 insertions(+), 1924 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index d16f4f4a03..9a9ccb55b7 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1730,7 +1730,114 @@ _cairo_draw_point (cairo_t *cr, } static void -gtk_default_draw_hline (GtkStyle *style, +transform_detail_string (const gchar *detail, + GtkStyleContext *context) +{ + if (!detail) + return; + + if (strcmp (detail, "arrow") == 0) + gtk_style_context_set_class (context, "arrow"); + else if (strcmp (detail, "button") == 0) + gtk_style_context_set_class (context, "button"); + else if (strcmp (detail, "buttondefault") == 0) + { + gtk_style_context_set_class (context, "button"); + gtk_style_context_set_class (context, "default"); + } + else if (strcmp (detail, "calendar") == 0) + gtk_style_context_set_class (context, "calendar"); + else if (strcmp (detail, "cellcheck") == 0) + { + gtk_style_context_set_class (context, "cell"); + gtk_style_context_set_class (context, "check"); + } + else if (strcmp (detail, "cellradio") == 0) + { + gtk_style_context_set_class (context, "cell"); + gtk_style_context_set_class (context, "radio"); + } + else if (strcmp (detail, "checkbutton") == 0) + gtk_style_context_set_class (context, "check"); + else if (strcmp (detail, "check") == 0) + { + gtk_style_context_set_class (context, "check"); + gtk_style_context_set_class (context, "menu"); + } + else if (strcmp (detail, "option") == 0) + { + gtk_style_context_set_class (context, "radio"); + gtk_style_context_set_class (context, "menu"); + } + else if (strcmp (detail, "entry") == 0 || + strcmp (detail, "entry_bg") == 0) + gtk_style_context_set_class (context, "entry"); + else if (strcmp (detail, "expander") == 0) + gtk_style_context_set_class (context, "expander"); + else if (strcmp (detail, "tooltip") == 0) + gtk_style_context_set_child_class (context, "tooltip", 0); + else if (strcmp (detail, "frame") == 0) + gtk_style_context_set_class (context, "frame"); + else if (strcmp (detail, "scrolled_window") == 0) + gtk_style_context_set_class (context, "scrolled-window"); + else if (strcmp (detail, "viewport") == 0 || + strcmp (detail, "viewportbin") == 0) + gtk_style_context_set_class (context, "viewport"); + else if (strcmp (detail, "trough") == 0) + { + gtk_style_context_set_class (context, "scrollbar"); + gtk_style_context_set_class (context, "trough"); + } + else if (strcmp (detail, "spinbutton") == 0) + gtk_style_context_set_class (context, "spinbutton"); + else if (strcmp (detail, "spinbutton_up") == 0 || + strcmp (detail, "spinbutton_down") == 0) + { + gtk_style_context_set_class (context, "spinbutton"); + gtk_style_context_set_class (context, "button"); + } + else if (g_str_has_prefix (detail, "cell_")) + { + GtkChildClassFlags row, col; + gboolean ruled = FALSE; + GStrv tokens; + guint i; + + tokens = g_strsplit (detail, "_", -1); + row = col = 0; + i = 0; + + while (tokens[i]) + { + if (strcmp (tokens[i], "even") == 0) + row |= GTK_CHILD_CLASS_EVEN; + else if (strcmp (tokens[i], "odd") == 0) + row |= GTK_CHILD_CLASS_ODD; + else if (strcmp (tokens[i], "start") == 0) + col |= GTK_CHILD_CLASS_FIRST; + else if (strcmp (tokens[i], "end") == 0) + col |= GTK_CHILD_CLASS_LAST; + else if (strcmp (tokens[i], "ruled") == 0) + ruled = TRUE; + else if (strcmp (tokens[i], "sorted") == 0) + col |= GTK_CHILD_CLASS_SORTED; + + i++; + } + + if (!ruled) + row &= ~(GTK_CHILD_CLASS_EVEN | GTK_CHILD_CLASS_ODD); + + gtk_style_context_set_class (context, "cell"); + gtk_style_context_set_child_class (context, "row", row); + gtk_style_context_set_child_class (context, "column", col); + + g_strfreev (tokens); + } +} + +static void +gtk_default_draw_hline (GtkStyle *style, cairo_t *cr, GtkStateType state_type, GtkWidget *widget, @@ -1739,36 +1846,30 @@ gtk_default_draw_hline (GtkStyle *style, gint x2, gint y) { - gint thickness_light; - gint thickness_dark; - gint i; - - thickness_light = style->ythickness / 2; - thickness_dark = style->ythickness - thickness_light; - - cairo_set_line_width (cr, 1.0); + GtkStyleContext *context; + GtkStylePrivate *priv; - if (detail && !strcmp (detail, "label")) - { - if (state_type == GTK_STATE_INSENSITIVE) - _cairo_draw_line (cr, &style->white, x1 + 1, y + 1, x2 + 1, y + 1); - _cairo_draw_line (cr, &style->fg[state_type], x1, y, x2, y); - } + if (widget) + context = gtk_widget_get_style_context (widget); else { - for (i = 0; i < thickness_dark; i++) - { - _cairo_draw_line (cr, &style->dark[state_type], x1, y + i, x2 - i - 1, y + i); - _cairo_draw_line (cr, &style->light[state_type], x2 - i, y + i, x2, y + i); - } - - y += thickness_dark; - for (i = 0; i < thickness_light; i++) - { - _cairo_draw_line (cr, &style->dark[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); - _cairo_draw_line (cr, &style->light[state_type], x1 + thickness_light - i, y + i, x2, y + i); - } + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + cairo_save (cr); + + gtk_render_line (context, cr, + x1, y, x2, y); + + cairo_restore (cr); + + gtk_style_context_restore (context); } @@ -1782,31 +1883,29 @@ gtk_default_draw_vline (GtkStyle *style, gint y2, gint x) { - gint thickness_light; - gint thickness_dark; - gint i; - - thickness_light = style->xthickness / 2; - thickness_dark = style->xthickness - thickness_light; + GtkStyleContext *context; + GtkStylePrivate *priv; - cairo_set_line_width (cr, 1.0); - - for (i = 0; i < thickness_dark; i++) - { - _cairo_draw_line (cr, &style->dark[state_type], - x + i, y1, x + i, y2 - i - 1); - _cairo_draw_line (cr, &style->light[state_type], - x + i, y2 - i, x + i, y2); - } - - x += thickness_dark; - for (i = 0; i < thickness_light; i++) + if (widget) + context = gtk_widget_get_style_context (widget); + else { - _cairo_draw_line (cr, &style->dark[state_type], - x + i, y1, x + i, y1 + thickness_light - i - 1); - _cairo_draw_line (cr, &style->light[state_type], - x + i, y1 + thickness_light - i, x + i, y2); + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + cairo_save (cr); + + gtk_render_line (context, cr, + x, y1, x, y2); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -1968,299 +2067,32 @@ gtk_default_draw_shadow (GtkStyle *style, gint width, gint height) { - GdkColor *gc1 = NULL; - GdkColor *gc2 = NULL; - gint thickness_light; - gint thickness_dark; - gint i; + GtkStyleContext *context; + GtkStylePrivate *priv; - cairo_set_line_width (cr, 1.0); - - if (shadow_type == GTK_SHADOW_IN) + if (widget) + context = gtk_widget_get_style_context (widget); + else { - if (detail && strcmp (detail, "buttondefault") == 0) - { - _cairo_draw_rectangle (cr, &style->black, FALSE, - x, y, width - 1, height - 1); - - return; - } - if (detail && strcmp (detail, "trough") == 0) - { - draw_thin_shadow (style, cr, state_type, - x, y, width, height); - - return; - } - if (GTK_IS_SPIN_BUTTON (widget) && - detail && strcmp (detail, "spinbutton") == 0) - { - draw_spinbutton_shadow (style, cr, state_type, - get_direction (widget), x, y, width, height); - - return; - } + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } - if (shadow_type == GTK_SHADOW_OUT && detail && strcmp (detail, "menu") == 0) - { - draw_menu_shadow (style, cr, state_type, x, y, width, height); - return; - } - - switch (shadow_type) - { - case GTK_SHADOW_NONE: - return; - case GTK_SHADOW_IN: - case GTK_SHADOW_ETCHED_IN: - gc1 = &style->light[state_type]; - gc2 = &style->dark[state_type]; - break; - case GTK_SHADOW_OUT: - case GTK_SHADOW_ETCHED_OUT: - gc1 = &style->dark[state_type]; - gc2 = &style->light[state_type]; - break; - } - - switch (shadow_type) - { - case GTK_SHADOW_NONE: - break; - - case GTK_SHADOW_IN: - /* Light around right and bottom edge */ + gtk_style_context_save (context); - if (style->ythickness > 0) - _cairo_draw_line (cr, gc1, - x, y + height - 1, x + width - 1, y + height - 1); - if (style->xthickness > 0) - _cairo_draw_line (cr, gc1, - x + width - 1, y, x + width - 1, y + height - 1); + if (detail) + transform_detail_string (detail, context); - if (style->ythickness > 1) - _cairo_draw_line (cr, &style->bg[state_type], - x + 1, y + height - 2, x + width - 2, y + height - 2); - if (style->xthickness > 1) - _cairo_draw_line (cr, &style->bg[state_type], - x + width - 2, y + 1, x + width - 2, y + height - 2); + cairo_save (cr); - /* Dark around left and top */ + gtk_render_frame (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); - if (style->ythickness > 1) - _cairo_draw_line (cr, &style->black, - x + 1, y + 1, x + width - 2, y + 1); - if (style->xthickness > 1) - _cairo_draw_line (cr, &style->black, - x + 1, y + 1, x + 1, y + height - 2); - - if (style->ythickness > 0) - _cairo_draw_line (cr, gc2, - x, y, x + width - 1, y); - if (style->xthickness > 0) - _cairo_draw_line (cr, gc2, - x, y, x, y + height - 1); - break; - - case GTK_SHADOW_OUT: - /* Dark around right and bottom edge */ - - if (style->ythickness > 0) - { - if (style->ythickness > 1) - { - _cairo_draw_line (cr, gc1, - x + 1, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &style->black, - x, y + height - 1, x + width - 1, y + height - 1); - } - else - { - _cairo_draw_line (cr, gc1, - x + 1, y + height - 1, x + width - 1, y + height - 1); - } - } - - if (style->xthickness > 0) - { - if (style->xthickness > 1) - { - _cairo_draw_line (cr, gc1, - x + width - 2, y + 1, x + width - 2, y + height - 2); - - _cairo_draw_line (cr, &style->black, - x + width - 1, y, x + width - 1, y + height - 1); - } - else - { - _cairo_draw_line (cr, gc1, - x + width - 1, y + 1, x + width - 1, y + height - 1); - } - } - - /* Light around top and left */ - - if (style->ythickness > 0) - _cairo_draw_line (cr, gc2, - x, y, x + width - 2, y); - if (style->xthickness > 0) - _cairo_draw_line (cr, gc2, - x, y, x, y + height - 2); - - if (style->ythickness > 1) - _cairo_draw_line (cr, &style->bg[state_type], - x + 1, y + 1, x + width - 3, y + 1); - if (style->xthickness > 1) - _cairo_draw_line (cr, &style->bg[state_type], - x + 1, y + 1, x + 1, y + height - 3); - break; - - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - if (style->xthickness > 0) - { - if (style->xthickness > 1) - { - thickness_light = 1; - thickness_dark = 1; - - for (i = 0; i < thickness_dark; i++) - { - _cairo_draw_line (cr, gc1, - x + width - i - 1, - y + i, - x + width - i - 1, - y + height - i - 1); - _cairo_draw_line (cr, gc2, - x + i, - y + i, - x + i, - y + height - i - 2); - } - - for (i = 0; i < thickness_light; i++) - { - _cairo_draw_line (cr, gc1, - x + thickness_dark + i, - y + thickness_dark + i, - x + thickness_dark + i, - y + height - thickness_dark - i - 1); - _cairo_draw_line (cr, gc2, - x + width - thickness_light - i - 1, - y + thickness_dark + i, - x + width - thickness_light - i - 1, - y + height - thickness_light - 1); - } - } - else - { - _cairo_draw_line (cr, - &style->dark[state_type], - x, y, x, y + height); - _cairo_draw_line (cr, - &style->dark[state_type], - x + width, y, x + width, y + height); - } - } - - if (style->ythickness > 0) - { - if (style->ythickness > 1) - { - thickness_light = 1; - thickness_dark = 1; - - for (i = 0; i < thickness_dark; i++) - { - _cairo_draw_line (cr, gc1, - x + i, - y + height - i - 1, - x + width - i - 1, - y + height - i - 1); - - _cairo_draw_line (cr, gc2, - x + i, - y + i, - x + width - i - 2, - y + i); - } - - for (i = 0; i < thickness_light; i++) - { - _cairo_draw_line (cr, gc1, - x + thickness_dark + i, - y + thickness_dark + i, - x + width - thickness_dark - i - 2, - y + thickness_dark + i); - - _cairo_draw_line (cr, gc2, - x + thickness_dark + i, - y + height - thickness_light - i - 1, - x + width - thickness_light - 1, - y + height - thickness_light - i - 1); - } - } - else - { - _cairo_draw_line (cr, - &style->dark[state_type], - x, y, x + width, y); - _cairo_draw_line (cr, - &style->dark[state_type], - x, y + height, x + width, y + height); - } - } - - break; - } - - if (shadow_type == GTK_SHADOW_IN && - GTK_IS_SPIN_BUTTON (widget) && - detail && strcmp (detail, "entry") == 0) - { - if (get_direction (widget) == GTK_TEXT_DIR_LTR) - { - _cairo_draw_line (cr, - &style->base[state_type], - x + width - 1, y + 2, - x + width - 1, y + height - 3); - _cairo_draw_line (cr, - &style->base[state_type], - x + width - 2, y + 2, - x + width - 2, y + height - 3); - /* draw point */ - _cairo_draw_point (cr, - &style->black, - x + width - 1, y + 1); - _cairo_draw_point (cr, - &style->bg[state_type], - x + width - 1, y + height - 2); - } - else - { - _cairo_draw_line (cr, - &style->base[state_type], - x, y + 2, - x, y + height - 3); - _cairo_draw_line (cr, - &style->base[state_type], - x + 1, y + 2, - x + 1, y + height - 3); - - _cairo_draw_point (cr, - &style->black, - x, y + 1); - - _cairo_draw_line (cr, - &style->bg[state_type], - x, y + height - 2, - x + 1, y + height - 2); - _cairo_draw_point (cr, - &style->light[state_type], - x, y + height - 1); - } - } + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -2389,16 +2221,76 @@ gtk_default_draw_arrow (GtkStyle *style, gint width, gint height) { - calculate_arrow_geometry (arrow_type, &x, &y, &width, &height); + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + gdouble angle, size; - if (detail && strcmp (detail, "menu_scroll_arrow_up") == 0) - y++; + if (widget) + context = gtk_widget_get_style_context (widget); + else + { + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } - if (state == GTK_STATE_INSENSITIVE) - draw_arrow (cr, &style->white, arrow_type, - x + 1, y + 1, width, height); - draw_arrow (cr, &style->fg[state], arrow_type, - x, y, width, height); + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (arrow_type) + { + case GTK_ARROW_UP: + angle = 0; + size = width; + break; + case GTK_ARROW_RIGHT: + angle = G_PI / 2; + size = height; + break; + case GTK_ARROW_DOWN: + angle = G_PI; + size = width; + break; + case GTK_ARROW_LEFT: + angle = 3 * (G_PI / 2); + size = height; + break; + default: + g_assert_not_reached (); + } + + switch (state) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_arrow (context, + cr, angle, + (gdouble) x, + (gdouble) y, + size); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -2563,94 +2455,50 @@ gtk_default_draw_box (GtkStyle *style, gint width, gint height) { - gboolean is_spinbutton_box = FALSE; - - if (GTK_IS_SPIN_BUTTON (widget) && detail) - { - if (strcmp (detail, "spinbutton_up") == 0) - { - y += 2; - width -= 3; - height -= 2; + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; - if (get_direction (widget) == GTK_TEXT_DIR_RTL) - x += 2; - else - x += 1; - - is_spinbutton_box = TRUE; - } - else if (strcmp (detail, "spinbutton_down") == 0) - { - width -= 3; - height -= 2; - - if (get_direction (widget) == GTK_TEXT_DIR_RTL) - x += 2; - else - x += 1; - - is_spinbutton_box = TRUE; - } - } - - if (background_is_solid (style, state_type)) - { - GdkColor *gc = &style->bg[state_type]; - - if (state_type == GTK_STATE_SELECTED && detail && strcmp (detail, "paned") == 0) - { - if (widget && !gtk_widget_has_focus (widget)) - gc = &style->base[GTK_STATE_ACTIVE]; - } - - _cairo_draw_rectangle (cr, gc, TRUE, - x, y, width, height); - } + if (widget) + context = gtk_widget_get_style_context (widget); else - gtk_style_apply_default_background (style, cr, gtk_widget_get_window (widget), - state_type, x, y, width, height); - - - if (is_spinbutton_box) { - GdkColor *upper; - GdkColor *lower; - - lower = &style->dark[state_type]; - if (shadow_type == GTK_SHADOW_OUT) - upper = &style->light[state_type]; - else - upper = &style->dark[state_type]; - - _cairo_draw_line (cr, upper, x, y, x + width - 1, y); - _cairo_draw_line (cr, lower, x, y + height - 1, x + width - 1, y + height - 1); - - return; + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } - gtk_paint_shadow (style, cr, state_type, shadow_type, widget, detail, - x, y, width, height); + gtk_style_context_save (context); - if (detail && strcmp (detail, "optionmenu") == 0) + if (detail) + transform_detail_string (detail, context); + + switch (state_type) { - GtkRequisition indicator_size; - GtkBorder indicator_spacing; - gint vline_x; - - option_menu_get_props (widget, &indicator_size, &indicator_spacing); - - if (get_direction (widget) == GTK_TEXT_DIR_RTL) - vline_x = x + indicator_size.width + indicator_spacing.left + indicator_spacing.right; - else - vline_x = x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness; - - gtk_paint_vline (style, cr, state_type, widget, - detail, - y + style->ythickness + 1, - y + height - style->ythickness - 3, - vline_x); + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; } + + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_background (context, cr, x, y, width, height); + gtk_render_frame (context, cr, x, y, width, height); + + cairo_restore (cr); + gtk_style_context_restore (context); } static GdkColor * @@ -2682,198 +2530,50 @@ gtk_default_draw_flat_box (GtkStyle *style, gint width, gint height) { - GdkColor *gc1; - GdkColor *freeme = NULL; - - cairo_set_line_width (cr, 1.0); + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + + if (widget) + context = gtk_widget_get_style_context (widget); + else + { + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); if (detail) + transform_detail_string (detail, context); + + switch (state_type) { - int trimmed_len = strlen (detail); - - if (g_str_has_prefix (detail, "cell_")) - { - if (g_str_has_suffix (detail, "_start")) - trimmed_len -= 6; - else if (g_str_has_suffix (detail, "_middle")) - trimmed_len -= 7; - else if (g_str_has_suffix (detail, "_end")) - trimmed_len -= 4; - } - - if (state_type == GTK_STATE_SELECTED) - { - if (!strcmp ("text", detail)) - gc1 = &style->bg[GTK_STATE_SELECTED]; - else if (!strncmp ("cell_even", detail, trimmed_len) || - !strncmp ("cell_odd", detail, trimmed_len) || - !strncmp ("cell_even_ruled", detail, trimmed_len) || - !strncmp ("cell_even_ruled_sorted", detail, trimmed_len)) - { - /* This has to be really broken; alex made me do it. -jrb */ - if (widget && gtk_widget_has_focus (widget)) - gc1 = &style->base[state_type]; - else - gc1 = &style->base[GTK_STATE_ACTIVE]; - } - else if (!strncmp ("cell_odd_ruled", detail, trimmed_len) || - !strncmp ("cell_odd_ruled_sorted", detail, trimmed_len)) - { - if (widget && gtk_widget_has_focus (widget)) - freeme = get_darkened (&style->base[state_type], 1); - else - freeme = get_darkened (&style->base[GTK_STATE_ACTIVE], 1); - gc1 = freeme; - } - else - { - gc1 = &style->bg[state_type]; - } - } - else - { - if (!strcmp ("viewportbin", detail)) - gc1 = &style->bg[GTK_STATE_NORMAL]; - else if (!strcmp ("entry_bg", detail)) - gc1 = &style->base[gtk_widget_get_state (widget)]; - - /* For trees: even rows are base color, odd rows are a shade of - * the base color, the sort column is a shade of the original color - * for that row. - */ - - else if (!strncmp ("cell_even", detail, trimmed_len) || - !strncmp ("cell_odd", detail, trimmed_len) || - !strncmp ("cell_even_ruled", detail, trimmed_len)) - { - GdkColor *color = NULL; - - gtk_widget_style_get (widget, - "even-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 0); - gc1 = freeme; - - gdk_color_free (color); - } - else - gc1 = &style->base[state_type]; - } - else if (!strncmp ("cell_odd_ruled", detail, trimmed_len)) - { - GdkColor *color = NULL; - - gtk_widget_style_get (widget, - "odd-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 0); - gc1 = freeme; - - gdk_color_free (color); - } - else - { - gtk_widget_style_get (widget, - "even-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 1); - gdk_color_free (color); - } - else - freeme = get_darkened (&style->base[state_type], 1); - gc1 = freeme; - } - } - else if (!strncmp ("cell_even_sorted", detail, trimmed_len) || - !strncmp ("cell_odd_sorted", detail, trimmed_len) || - !strncmp ("cell_even_ruled_sorted", detail, trimmed_len)) - { - GdkColor *color = NULL; - - if (!strncmp ("cell_odd_sorted", detail, trimmed_len)) - gtk_widget_style_get (widget, - "odd-row-color", &color, - NULL); - else - gtk_widget_style_get (widget, - "even-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 1); - gc1 = freeme; - - gdk_color_free (color); - } - else - { - freeme = get_darkened (&style->base[state_type], 1); - gc1 = freeme; - } - } - else if (!strncmp ("cell_odd_ruled_sorted", detail, trimmed_len)) - { - GdkColor *color = NULL; - - gtk_widget_style_get (widget, - "odd-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 1); - gc1 = freeme; - - gdk_color_free (color); - } - else - { - gtk_widget_style_get (widget, - "even-row-color", &color, - NULL); - - if (color) - { - freeme = get_darkened (color, 2); - gdk_color_free (color); - } - else - freeme = get_darkened (&style->base[state_type], 2); - gc1 = freeme; - } - } - else - gc1 = &style->bg[state_type]; - } + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; } - else - gc1 = &style->bg[state_type]; - - if (background_is_solid (style, state_type) || gc1 != &style->bg[state_type]) - { - _cairo_draw_rectangle (cr, gc1, TRUE, - x, y, width, height); - if (detail && !strcmp ("tooltip", detail)) - _cairo_draw_rectangle (cr, &style->black, FALSE, - x, y, width - 1, height - 1); - } - else - gtk_style_apply_default_background (style, cr, gtk_widget_get_window (widget), - state_type, x, y, width, height); + gtk_style_context_set_state (context, flags); - if (freeme) - gdk_color_free (freeme); + cairo_save (cr); + + gtk_render_background (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -2888,107 +2588,53 @@ gtk_default_draw_check (GtkStyle *style, gint width, gint height) { - enum { BUTTON, MENU, CELL } type = BUTTON; - int exterior_size; - int interior_size; - int pad; - + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + + if (widget) + context = gtk_widget_get_style_context (widget); + else + { + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + if (detail) + transform_detail_string (detail, context); + + switch (state_type) { - if (strcmp (detail, "cellcheck") == 0) - type = CELL; - else if (strcmp (detail, "check") == 0) - type = MENU; - } - - exterior_size = MIN (width, height); - if (exterior_size % 2 == 0) /* Ensure odd */ - exterior_size -= 1; - - pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9); - interior_size = MAX (1, exterior_size - 2 * pad); - - if (interior_size < 7) - { - interior_size = 7; - pad = MAX (0, (exterior_size - interior_size) / 2); - } - - x -= (1 + exterior_size - width) / 2; - y -= (1 + exterior_size - height) / 2; - - switch (type) - { - case BUTTON: - case CELL: - if (type == BUTTON) - gdk_cairo_set_source_color (cr, &style->fg[state_type]); - else - gdk_cairo_set_source_color (cr, &style->text[state_type]); - - cairo_set_line_width (cr, 1.0); - cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &style->base[state_type]); - cairo_rectangle (cr, x + 1, y + 1, exterior_size - 2, exterior_size - 2); - cairo_fill (cr); + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; break; - - case MENU: + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; break; - } - - switch (type) - { - case BUTTON: - case CELL: - gdk_cairo_set_source_color (cr, &style->text[state_type]); + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; break; - case MENU: - gdk_cairo_set_source_color (cr, &style->fg[state_type]); + default: break; } if (shadow_type == GTK_SHADOW_IN) - { - cairo_translate (cr, - x + pad, y + pad); - - cairo_scale (cr, interior_size / 7., interior_size / 7.); - - cairo_move_to (cr, 7.0, 0.0); - cairo_line_to (cr, 7.5, 1.0); - cairo_curve_to (cr, 5.3, 2.0, - 4.3, 4.0, - 3.5, 7.0); - cairo_curve_to (cr, 3.0, 5.7, - 1.3, 4.7, - 0.0, 4.7); - cairo_line_to (cr, 0.2, 3.5); - cairo_curve_to (cr, 1.1, 3.5, - 2.3, 4.3, - 3.0, 5.0); - cairo_curve_to (cr, 1.0, 3.9, - 2.4, 4.1, - 3.2, 4.9); - cairo_curve_to (cr, 3.5, 3.1, - 5.2, 2.0, - 7.0, 0.0); - - cairo_fill (cr); - } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ - { - int line_thickness = MAX (1, (3 + interior_size * 2) / 7); + flags |= GTK_STATE_FLAG_ACTIVE; + else if (shadow_type == GTK_SHADOW_ETCHED_IN) + flags |= GTK_STATE_FLAG_INCONSISTENT; - cairo_rectangle (cr, - x + pad, - y + pad + (1 + interior_size - line_thickness) / 2, - interior_size, - line_thickness); - cairo_fill (cr); - } + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_check (context, + cr, x, y, + width, height); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3003,102 +2649,54 @@ gtk_default_draw_option (GtkStyle *style, gint width, gint height) { - enum { BUTTON, MENU, CELL } type = BUTTON; - int exterior_size; - + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + + if (widget) + context = gtk_widget_get_style_context (widget); + else + { + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + if (detail) + transform_detail_string (detail, context); + + switch (state_type) { - if (strcmp (detail, "radio") == 0) - type = CELL; - else if (strcmp (detail, "option") == 0) - type = MENU; - } - - exterior_size = MIN (width, height); - if (exterior_size % 2 == 0) /* Ensure odd */ - exterior_size -= 1; - - x -= (1 + exterior_size - width) / 2; - y -= (1 + exterior_size - height) / 2; - - switch (type) - { - case BUTTON: - case CELL: - gdk_cairo_set_source_color (cr, &style->base[state_type]); - - cairo_arc (cr, - x + exterior_size / 2., - y + exterior_size / 2., - (exterior_size - 1) / 2., - 0, 2 * G_PI); - - cairo_fill_preserve (cr); - - if (type == BUTTON) - gdk_cairo_set_source_color (cr, &style->fg[state_type]); - else - gdk_cairo_set_source_color (cr, &style->text[state_type]); - - cairo_set_line_width (cr, 1.); - cairo_stroke (cr); + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; break; - - case MENU: + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; break; - } - - switch (type) - { - case BUTTON: - gdk_cairo_set_source_color (cr, &style->text[state_type]); + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; break; - case CELL: - break; - case MENU: - gdk_cairo_set_source_color (cr, &style->fg[state_type]); + default: break; } if (shadow_type == GTK_SHADOW_IN) - { - int pad = style->xthickness + MAX (1, 2 * (exterior_size - 2 * style->xthickness) / 9); - int interior_size = MAX (1, exterior_size - 2 * pad); + flags |= GTK_STATE_FLAG_ACTIVE; + else if (shadow_type == GTK_SHADOW_ETCHED_IN) + flags |= GTK_STATE_FLAG_INCONSISTENT; - if (interior_size < 5) - { - interior_size = 7; - pad = MAX (0, (exterior_size - interior_size) / 2); - } + gtk_style_context_set_state (context, flags); - cairo_arc (cr, - x + pad + interior_size / 2., - y + pad + interior_size / 2., - interior_size / 2., - 0, 2 * G_PI); - cairo_fill (cr); - } - else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ - { - int pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9); - int interior_size = MAX (1, exterior_size - 2 * pad); - int line_thickness; + cairo_save (cr); + gtk_render_option (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); - if (interior_size < 7) - { - interior_size = 7; - pad = MAX (0, (exterior_size - interior_size) / 2); - } - - line_thickness = MAX (1, (3 + interior_size * 2) / 7); - - cairo_rectangle (cr, - x + pad, - y + pad + (interior_size - line_thickness) / 2., - interior_size, - line_thickness); - cairo_fill (cr); - } + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3163,185 +2761,55 @@ gtk_default_draw_shadow_gap (GtkStyle *style, gint gap_x, gint gap_width) { - GdkColor *color1 = NULL; - GdkColor *color2 = NULL; - GdkColor *color3 = NULL; - GdkColor *color4 = NULL; - - switch (shadow_type) + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + + if (widget) + context = gtk_widget_get_style_context (widget); + else { - case GTK_SHADOW_NONE: + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; default: - return; - case GTK_SHADOW_IN: - color1 = &style->dark[state_type]; - color2 = &style->black; - color3 = &style->bg[state_type]; - color4 = &style->light[state_type]; - break; - case GTK_SHADOW_ETCHED_IN: - color1 = &style->dark[state_type]; - color2 = &style->light[state_type]; - color3 = &style->dark[state_type]; - color4 = &style->light[state_type]; - break; - case GTK_SHADOW_OUT: - color1 = &style->light[state_type]; - color2 = &style->bg[state_type]; - color3 = &style->dark[state_type]; - color4 = &style->black; - break; - case GTK_SHADOW_ETCHED_OUT: - color1 = &style->light[state_type]; - color2 = &style->dark[state_type]; - color3 = &style->light[state_type]; - color4 = &style->dark[state_type]; break; } - switch (shadow_type) - { - case GTK_SHADOW_NONE: - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - switch (gap_side) - { - case GTK_POS_TOP: - _cairo_draw_line (cr, color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, color2, - x + 1, y, x + 1, y + height - 2); - - _cairo_draw_line (cr, color3, - x + 1, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color3, - x + width - 2, y, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color4, - x, y + height - 1, x + width - 1, y + height - 1); - _cairo_draw_line (cr, color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, color1, - x, y, x + gap_x - 1, y); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + gap_x - 1, y + 1); - _cairo_draw_line (cr, color2, - x + gap_x, y, x + gap_x, y); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, color1, - x + gap_x + gap_width, y, x + width - 2, y); - _cairo_draw_line (cr, color2, - x + gap_x + gap_width, y + 1, x + width - 3, y + 1); - _cairo_draw_line (cr, color2, - x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y); - } - break; - case GTK_POS_BOTTOM: - _cairo_draw_line (cr, color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + width - 2, y + 1); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + 1, y + height - 1); - - _cairo_draw_line (cr, color3, - x + width - 2, y + 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, color4, - x, y + height - 1, x + gap_x - 1, y + height - 1); - _cairo_draw_line (cr, color3, - x + 1, y + height - 2, x + gap_x - 1, y + height - 2); - _cairo_draw_line (cr, color3, - x + gap_x, y + height - 1, x + gap_x, y + height - 1); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, color4, - x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, color3, - x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color3, - x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1); - } - break; - case GTK_POS_LEFT: - _cairo_draw_line (cr, color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, color2, - x, y + 1, x + width - 2, y + 1); - - _cairo_draw_line (cr, color3, - x, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color3, - x + width - 2, y + 1, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color4, - x, y + height - 1, x + width - 1, y + height - 1); - _cairo_draw_line (cr, color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, color1, - x, y, x, y + gap_x - 1); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + 1, y + gap_x - 1); - _cairo_draw_line (cr, color2, - x, y + gap_x, x, y + gap_x); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, color1, - x, y + gap_x + gap_width, x, y + height - 2); - _cairo_draw_line (cr, color2, - x + 1, y + gap_x + gap_width, x + 1, y + height - 2); - _cairo_draw_line (cr, color2, - x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1); - } - break; - case GTK_POS_RIGHT: - _cairo_draw_line (cr, color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + width - 1, y + 1); - _cairo_draw_line (cr, color2, - x + 1, y + 1, x + 1, y + height - 2); - - _cairo_draw_line (cr, color3, - x + 1, y + height - 2, x + width - 1, y + height - 2); - _cairo_draw_line (cr, color4, - x, y + height - 1, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, color4, - x + width - 1, y, x + width - 1, y + gap_x - 1); - _cairo_draw_line (cr, color3, - x + width - 2, y + 1, x + width - 2, y + gap_x - 1); - _cairo_draw_line (cr, color3, - x + width - 1, y + gap_x, x + width - 1, y + gap_x); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, color4, - x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2); - _cairo_draw_line (cr, color3, - x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2); - _cairo_draw_line (cr, color3, - x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1); - } - break; - } - } + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + gtk_render_frame_gap (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side, + (gdouble) gap_x, + (gdouble) gap_x + gap_width); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3359,189 +2827,61 @@ gtk_default_draw_box_gap (GtkStyle *style, gint gap_x, gint gap_width) { - GdkColor color1; - GdkColor color2; - GdkColor color3; - GdkColor color4; - - gtk_style_apply_default_background (style, cr, gtk_widget_get_window (widget), - state_type, x, y, width, height); + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; - switch (shadow_type) + if (widget) + context = gtk_widget_get_style_context (widget); + else { - case GTK_SHADOW_NONE: - return; - case GTK_SHADOW_IN: - color1 = style->dark[state_type]; - color2 = style->black; - color3 = style->bg[state_type]; - color4 = style->light[state_type]; + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; break; - case GTK_SHADOW_ETCHED_IN: - color1 = style->dark[state_type]; - color2 = style->light[state_type]; - color3 = style->dark[state_type]; - color4 = style->light[state_type]; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; break; - case GTK_SHADOW_OUT: - color1 = style->light[state_type]; - color2 = style->bg[state_type]; - color3 = style->dark[state_type]; - color4 = style->black; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; break; - case GTK_SHADOW_ETCHED_OUT: - color1 = style->light[state_type]; - color2 = style->dark[state_type]; - color3 = style->light[state_type]; - color4 = style->dark[state_type]; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: break; } - - cairo_set_line_width (cr, 1.0); - switch (shadow_type) - { - case GTK_SHADOW_NONE: - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - switch (gap_side) - { - case GTK_POS_TOP: - _cairo_draw_line (cr, &color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, &color2, - x + 1, y, x + 1, y + height - 2); - - _cairo_draw_line (cr, &color3, - x + 1, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 2, y, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color4, - x, y + height - 1, x + width - 1, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, &color1, - x, y, x + gap_x - 1, y); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + gap_x - 1, y + 1); - _cairo_draw_line (cr, &color2, - x + gap_x, y, x + gap_x, y); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, &color1, - x + gap_x + gap_width, y, x + width - 2, y); - _cairo_draw_line (cr, &color2, - x + gap_x + gap_width, y + 1, x + width - 2, y + 1); - _cairo_draw_line (cr, &color2, - x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y); - } - break; - case GTK_POS_BOTTOM: - _cairo_draw_line (cr, &color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, &color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + width - 2, y + 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + 1, y + height - 1); - - _cairo_draw_line (cr, &color3, - x + width - 2, y + 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, &color4, - x, y + height - 1, x + gap_x - 1, y + height - 1); - _cairo_draw_line (cr, &color3, - x + 1, y + height - 2, x + gap_x - 1, y + height - 2); - _cairo_draw_line (cr, &color3, - x + gap_x, y + height - 1, x + gap_x, y + height - 1); - } - if ((width - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, &color4, - x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, &color3, - x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1); - } - break; - case GTK_POS_LEFT: - _cairo_draw_line (cr, &color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, &color2, - x, y + 1, x + width - 2, y + 1); - - _cairo_draw_line (cr, &color3, - x, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 2, y + 1, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color4, - x, y + height - 1, x + width - 1, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, &color1, - x, y, x, y + gap_x - 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + 1, y + gap_x - 1); - _cairo_draw_line (cr, &color2, - x, y + gap_x, x, y + gap_x); - } - if ((height - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, &color1, - x, y + gap_x + gap_width, x, y + height - 2); - _cairo_draw_line (cr, &color2, - x + 1, y + gap_x + gap_width, x + 1, y + height - 2); - _cairo_draw_line (cr, &color2, - x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1); - } - break; - case GTK_POS_RIGHT: - _cairo_draw_line (cr, &color1, - x, y, x + width - 1, y); - _cairo_draw_line (cr, &color1, - x, y, x, y + height - 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + width - 1, y + 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + 1, y + height - 2); - - _cairo_draw_line (cr, &color3, - x + 1, y + height - 2, x + width - 1, y + height - 2); - _cairo_draw_line (cr, &color4, - x, y + height - 1, x + width - 1, y + height - 1); - if (gap_x > 0) - { - _cairo_draw_line (cr, &color4, - x + width - 1, y, x + width - 1, y + gap_x - 1); - _cairo_draw_line (cr, &color3, - x + width - 2, y + 1, x + width - 2, y + gap_x - 1); - _cairo_draw_line (cr, &color3, - x + width - 1, y + gap_x, x + width - 1, y + gap_x); - } - if ((height - (gap_x + gap_width)) > 0) - { - _cairo_draw_line (cr, &color4, - x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1); - } - break; - } - } + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + gtk_render_background (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); + + gtk_render_frame_gap (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side, + (gdouble) gap_x, + (gdouble) gap_x + gap_width); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3557,151 +2897,54 @@ gtk_default_draw_extension (GtkStyle *style, gint height, GtkPositionType gap_side) { - GdkWindow *window = gtk_widget_get_window (widget); - GdkColor color1; - GdkColor color2; - GdkColor color3; - GdkColor color4; - - switch (gap_side) + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + + if (widget) + context = gtk_widget_get_style_context (widget); + else { - case GTK_POS_TOP: - gtk_style_apply_default_background (style, cr, window, - state_type, - x + 1, - y, - width - 2, - height - 1); + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_ACTIVE; break; - case GTK_POS_BOTTOM: - gtk_style_apply_default_background (style, cr, window, - state_type, - x + 1, - y + 1, - width - 2, - height - 1); + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; break; - case GTK_POS_LEFT: - gtk_style_apply_default_background (style, cr, window, - state_type, - x, - y + 1, - width - 1, - height - 2); + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; break; - case GTK_POS_RIGHT: - gtk_style_apply_default_background (style, cr, window, - state_type, - x + 1, - y + 1, - width - 1, - height - 2); + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: break; } - switch (shadow_type) - { - case GTK_SHADOW_NONE: - return; - case GTK_SHADOW_IN: - color1 = style->dark[state_type]; - color2 = style->black; - color3 = style->bg[state_type]; - color4 = style->light[state_type]; - break; - case GTK_SHADOW_ETCHED_IN: - color1 = style->dark[state_type]; - color2 = style->light[state_type]; - color3 = style->dark[state_type]; - color4 = style->light[state_type]; - break; - case GTK_SHADOW_OUT: - color1 = style->light[state_type]; - color2 = style->bg[state_type]; - color3 = style->dark[state_type]; - color4 = style->black; - break; - case GTK_SHADOW_ETCHED_OUT: - color1 = style->light[state_type]; - color2 = style->dark[state_type]; - color3 = style->light[state_type]; - color4 = style->dark[state_type]; - break; - } + gtk_style_context_set_state (context, flags); - cairo_set_line_width (cr, 1.0); + cairo_save (cr); - switch (shadow_type) - { - case GTK_SHADOW_NONE: - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - switch (gap_side) - { - case GTK_POS_TOP: - _cairo_draw_line (cr, &color1, - x, y, x, y + height - 2); - _cairo_draw_line (cr, &color2, - x + 1, y, x + 1, y + height - 2); - - _cairo_draw_line (cr, &color3, - x + 2, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 2, y, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color4, - x + 1, y + height - 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y, x + width - 1, y + height - 2); - break; - case GTK_POS_BOTTOM: - _cairo_draw_line (cr, &color1, - x + 1, y, x + width - 2, y); - _cairo_draw_line (cr, &color1, - x, y + 1, x, y + height - 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + width - 2, y + 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + 1, y + height - 1); - - _cairo_draw_line (cr, &color3, - x + width - 2, y + 2, x + width - 2, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y + 1, x + width - 1, y + height - 1); - break; - case GTK_POS_LEFT: - _cairo_draw_line (cr, &color1, - x, y, x + width - 2, y); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + width - 2, y + 1); - - _cairo_draw_line (cr, &color3, - x, y + height - 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color3, - x + width - 2, y + 2, x + width - 2, y + height - 2); - _cairo_draw_line (cr, &color4, - x, y + height - 1, x + width - 2, y + height - 1); - _cairo_draw_line (cr, &color4, - x + width - 1, y + 1, x + width - 1, y + height - 2); - break; - case GTK_POS_RIGHT: - _cairo_draw_line (cr, &color1, - x + 1, y, x + width - 1, y); - _cairo_draw_line (cr, &color1, - x, y + 1, x, y + height - 2); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + width - 1, y + 1); - _cairo_draw_line (cr, &color2, - x + 1, y + 1, x + 1, y + height - 2); - - _cairo_draw_line (cr, &color3, - x + 2, y + height - 2, x + width - 1, y + height - 2); - _cairo_draw_line (cr, &color4, - x + 1, y + height - 1, x + width - 1, y + height - 1); - break; - } - } + gtk_render_extension (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + gap_side); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3715,74 +2958,32 @@ gtk_default_draw_focus (GtkStyle *style, gint width, gint height) { - gboolean free_dash_list = FALSE; - gint line_width = 1; - gint8 *dash_list = (gint8 *) "\1\1"; + GtkStyleContext *context; + GtkStylePrivate *priv; if (widget) - { - gtk_widget_style_get (widget, - "focus-line-width", &line_width, - "focus-line-pattern", (gchar *)&dash_list, - NULL); - - free_dash_list = TRUE; - } - - if (detail && !strcmp (detail, "add-mode")) - { - if (free_dash_list) - g_free (dash_list); - - dash_list = (gint8 *) "\4\4"; - free_dash_list = FALSE; - } - - if (detail && !strcmp (detail, "colorwheel_light")) - cairo_set_source_rgb (cr, 0., 0., 0.); - else if (detail && !strcmp (detail, "colorwheel_dark")) - cairo_set_source_rgb (cr, 1., 1., 1.); + context = gtk_widget_get_style_context (widget); else - gdk_cairo_set_source_color (cr, &style->fg[state_type]); - - cairo_set_line_width (cr, line_width); - - if (dash_list[0]) { - gint n_dashes = strlen ((const gchar *) dash_list); - gdouble *dashes = g_new (gdouble, n_dashes); - gdouble total_length = 0; - gdouble dash_offset; - gint i; - - for (i = 0; i < n_dashes; i++) - { - dashes[i] = dash_list[i]; - total_length += dash_list[i]; - } - - /* The dash offset here aligns the pattern to integer pixels - * by starting the dash at the right side of the left border - * Negative dash offsets in cairo don't work - * (https://bugs.freedesktop.org/show_bug.cgi?id=2729) - */ - dash_offset = - line_width / 2.; - while (dash_offset < 0) - dash_offset += total_length; - - cairo_set_dash (cr, dashes, n_dashes, dash_offset); - g_free (dashes); + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } - cairo_rectangle (cr, - x + line_width / 2., - y + line_width / 2., - width - line_width, - height - line_width); - cairo_stroke (cr); + gtk_style_context_save (context); - if (free_dash_list) - g_free (dash_list); + if (detail) + transform_detail_string (detail, context); + + cairo_save (cr); + + gtk_render_focus (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3798,22 +2999,49 @@ gtk_default_draw_slider (GtkStyle *style, gint height, GtkOrientation orientation) { - gtk_paint_box (style, cr, state_type, shadow_type, - widget, detail, x, y, width, height); + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; - if (detail && - (strcmp ("hscale", detail) == 0 || - strcmp ("vscale", detail) == 0)) + if (widget) + context = gtk_widget_get_style_context (widget); + else { - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_paint_vline (style, cr, state_type, widget, detail, - y + style->ythickness, - y + height - style->ythickness - 1, x + width / 2); - else - gtk_paint_hline (style, cr, state_type, widget, detail, - x + style->xthickness, - x + width - style->xthickness - 1, y + height / 2); + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (state_type) + { + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_slider (context, cr, x, y, width, height, orientation); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3855,58 +3083,51 @@ gtk_default_draw_handle (GtkStyle *style, gint height, GtkOrientation orientation) { - gint xx, yy; - gint xthick, ythick; - GdkColor light, dark; - - gtk_paint_box (style, cr, state_type, shadow_type, widget, - detail, x, y, width, height); - - if (detail && !strcmp (detail, "paned")) - { - /* we want to ignore the shadow border in paned widgets */ - xthick = 0; - ythick = 0; + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; - if (state_type == GTK_STATE_SELECTED && widget && !gtk_widget_has_focus (widget)) - _gtk_style_shade (&style->base[GTK_STATE_ACTIVE], &light, - LIGHTNESS_MULT); - else - light = style->light[state_type]; - - dark = style->black; - } + if (widget) + context = gtk_widget_get_style_context (widget); else { - xthick = style->xthickness; - ythick = style->ythickness; + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } - light = style->light[state_type]; - dark = style->dark[state_type]; - } - - cairo_rectangle(cr, x + xthick, y + ythick, - width - (xthick * 2), height - (ythick * 2)); - cairo_clip (cr); + gtk_style_context_save (context); - if (detail && !strcmp (detail, "paned")) + if (detail) + transform_detail_string (detail, context); + + switch (state_type) { - if (orientation == GTK_ORIENTATION_HORIZONTAL) - for (xx = x + width/2 - 15; xx <= x + width/2 + 15; xx += 5) - draw_dot (cr, &light, &dark, xx, y + height/2 - 1, 3); - else - for (yy = y + height/2 - 15; yy <= y + height/2 + 15; yy += 5) - draw_dot (cr, &light, &dark, x + width/2 - 1, yy, 3); - } - else - { - for (yy = y + ythick; yy < (y + height - ythick); yy += 3) - for (xx = x + xthick; xx < (x + width - xthick); xx += 6) - { - draw_dot (cr, &light, &dark, xx, yy, 2); - draw_dot (cr, &light, &dark, xx + 3, yy + 1, 2); - } + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; } + + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_handle (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height, + orientation); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -3919,117 +3140,59 @@ gtk_default_draw_expander (GtkStyle *style, gint y, GtkExpanderStyle expander_style) { -#define DEFAULT_EXPANDER_SIZE 12 + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + gint size; - gint expander_size; - gint line_width; - double vertical_overshoot; - int diameter; - double radius; - double interp; /* interpolation factor for center position */ - double x_double_horz, y_double_horz; - double x_double_vert, y_double_vert; - double x_double, y_double; - gint degrees = 0; - - if (widget && - gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget), - "expander-size")) - { - gtk_widget_style_get (widget, - "expander-size", &expander_size, - NULL); - } + if (widget) + context = gtk_widget_get_style_context (widget); else - expander_size = DEFAULT_EXPANDER_SIZE; - - line_width = MAX (1, expander_size/9); - - switch (expander_style) { - case GTK_EXPANDER_COLLAPSED: - degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 180 : 0; - interp = 0.0; + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } + + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; break; - case GTK_EXPANDER_SEMI_COLLAPSED: - degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 150 : 30; - interp = 0.25; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; break; - case GTK_EXPANDER_SEMI_EXPANDED: - degrees = (get_direction (widget) == GTK_TEXT_DIR_RTL) ? 120 : 60; - interp = 0.75; - break; - case GTK_EXPANDER_EXPANDED: - degrees = 90; - interp = 1.0; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; break; default: - g_assert_not_reached (); + break; } - /* Compute distance that the stroke extends beyonds the end - * of the triangle we draw. - */ - vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8)); - - /* For odd line widths, we end the vertical line of the triangle - * at a half pixel, so we round differently. - */ - if (line_width % 2 == 1) - vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5; + if (widget) + gtk_widget_style_get (widget, "expander-size", &size, NULL); else - vertical_overshoot = ceil (vertical_overshoot); + size = 12; - /* Adjust the size of the triangle we draw so that the entire stroke fits - */ - diameter = MAX (3, expander_size - 2 * vertical_overshoot); + if (expander_style == GTK_EXPANDER_EXPANDED) + flags |= GTK_STATE_FLAG_ACTIVE; - /* If the line width is odd, we want the diameter to be even, - * and vice versa, so force the sum to be odd. This relationship - * makes the point of the triangle look right. - */ - diameter -= (1 - (diameter + line_width) % 2); - - radius = diameter / 2.; + gtk_style_context_set_state (context, flags); - /* Adjust the center so that the stroke is properly aligned with - * the pixel grid. The center adjustment is different for the - * horizontal and vertical orientations. For intermediate positions - * we interpolate between the two. - */ - x_double_vert = floor (x - (radius + line_width) / 2.) + (radius + line_width) / 2.; - y_double_vert = y - 0.5; + cairo_save (cr); - x_double_horz = x - 0.5; - y_double_horz = floor (y - (radius + line_width) / 2.) + (radius + line_width) / 2.; + gtk_render_expander (context, cr, + (gdouble) x - (size / 2), + (gdouble) y - (size / 2), + (gdouble) size, + (gdouble) size); - x_double = x_double_vert * (1 - interp) + x_double_horz * interp; - y_double = y_double_vert * (1 - interp) + y_double_horz * interp; - - cairo_translate (cr, x_double, y_double); - cairo_rotate (cr, degrees * G_PI / 180); - - cairo_move_to (cr, - radius / 2., - radius); - cairo_line_to (cr, radius / 2., 0); - cairo_line_to (cr, - radius / 2., radius); - cairo_close_path (cr); - - cairo_set_line_width (cr, line_width); - - if (state_type == GTK_STATE_PRELIGHT) - gdk_cairo_set_source_color (cr, - &style->fg[GTK_STATE_PRELIGHT]); - else if (state_type == GTK_STATE_ACTIVE) - gdk_cairo_set_source_color (cr, - &style->light[GTK_STATE_ACTIVE]); - else - gdk_cairo_set_source_color (cr, - &style->base[GTK_STATE_NORMAL]); - - cairo_fill_preserve (cr); - - gdk_cairo_set_source_color (cr, &style->fg[state_type]); - cairo_stroke (cr); + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -4043,49 +3206,49 @@ gtk_default_draw_layout (GtkStyle *style, gint y, PangoLayout *layout) { - GdkColor *gc; - const PangoMatrix *matrix; + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; - matrix = pango_context_get_matrix (pango_layout_get_context (layout)); - if (matrix) - { - cairo_matrix_t cairo_matrix; - PangoMatrix tmp_matrix; - PangoRectangle rect; - - cairo_matrix_init (&cairo_matrix, - matrix->xx, matrix->yx, - matrix->xy, matrix->yy, - matrix->x0, matrix->y0); - - pango_layout_get_extents (layout, NULL, &rect); - pango_matrix_transform_rectangle (matrix, &rect); - pango_extents_to_pixels (&rect, NULL); - - tmp_matrix = *matrix; - cairo_matrix.x0 += x - rect.x; - cairo_matrix.y0 += y - rect.y; - - cairo_set_matrix (cr, &cairo_matrix); - } + if (widget) + context = gtk_widget_get_style_context (widget); else - cairo_translate (cr, x, y); - - cairo_new_path (cr); - - if (state_type == GTK_STATE_INSENSITIVE) { - gdk_cairo_set_source_color (cr, &style->white); - cairo_move_to (cr, 1, 1); - _gtk_pango_fill_layout (cr, layout); - cairo_new_path (cr); + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } - gc = use_text ? &style->text[state_type] : &style->fg[state_type]; + gtk_style_context_save (context); - gdk_cairo_set_source_color (cr, gc); + if (detail) + transform_detail_string (detail, context); - pango_cairo_show_layout (cr, layout); + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); + + cairo_save (cr); + + gtk_render_layout (context, cr, + (gdouble) x, + (gdouble) y, + layout); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void @@ -4658,15 +3821,16 @@ gtk_paint_hline (GtkStyle *style, gint x2, gint y) { - GtkStyleContext *context; - g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (cr != NULL); - - context = gtk_widget_get_style_context (widget); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL); cairo_save (cr); - gtk_render_line (context, cr, x1, y, x2, y); + + GTK_STYLE_GET_CLASS (style)->draw_hline (style, cr, state_type, + widget, detail, + x1, x2, y); + cairo_restore (cr); } @@ -4694,15 +3858,16 @@ gtk_paint_vline (GtkStyle *style, gint y2_, gint x) { - GtkStyleContext *context; - g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (cr != NULL); - - context = gtk_widget_get_style_context (widget); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL); cairo_save (cr); - gtk_render_line (context, cr, x, y1_, x, y2_); + + GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type, + widget, detail, + y1_, y2_, x); + cairo_restore (cr); } @@ -4734,34 +3899,18 @@ gtk_paint_shadow (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - if (width < 0 || height < 0) - { - gint w_width, w_height; - - gdk_drawable_get_size (GDK_DRAWABLE (window), &w_width, &w_height); - - if (width < 0) - width = w_width; - - if (height < 0) - height = w_height; - } - cairo_save (cr); - gtk_render_frame (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height); + + GTK_STYLE_GET_CLASS (style)->draw_shadow (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height); + cairo_restore (cr); } @@ -4797,52 +3946,17 @@ gtk_paint_arrow (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - gdouble angle; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - if (arrow_type == GTK_ARROW_UP) - angle = 0; - else if (arrow_type == GTK_ARROW_RIGHT) - angle = G_PI / 2; - else if (arrow_type == GTK_ARROW_DOWN) - angle = G_PI; - else - angle = 3 * (G_PI / 2); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_FLAG_ACTIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_arrow (context, - cr, angle, - (gdouble) x, - (gdouble) y, - MIN ((gdouble) width, (gdouble) height)); + GTK_STYLE_GET_CLASS (style)->draw_arrow (style, cr, state_type, shadow_type, + widget, detail, + arrow_type, fill, x, y, width, height); cairo_restore (cr); } @@ -4917,37 +4031,16 @@ gtk_paint_box (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL); g_return_if_fail (cr != NULL); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_FLAG_ACTIVE; - break; - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - - gtk_style_context_set_state (context, flags); - cairo_save (cr); - gtk_render_background (context, cr, x, y, width, height); - gtk_render_frame (context, cr, x, y, width, height); + + GTK_STYLE_GET_CLASS (style)->draw_box (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height); + cairo_restore (cr); } @@ -4980,39 +4073,17 @@ gtk_paint_flat_box (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_background (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height); + GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height); cairo_restore (cr); } @@ -5045,40 +4116,15 @@ gtk_paint_check (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL); g_return_if_fail (cr != NULL); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - - if (shadow_type == GTK_SHADOW_IN) - flags |= GTK_STATE_FLAG_ACTIVE; - else if (shadow_type == GTK_SHADOW_ETCHED_IN) - flags |= GTK_STATE_FLAG_INCONSISTENT; - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_check (context, - cr, x, y, - width, height); + GTK_STYLE_GET_CLASS (style)->draw_check (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height); cairo_restore (cr); } @@ -5111,42 +4157,15 @@ gtk_paint_option (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL); g_return_if_fail (cr != NULL); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - - if (shadow_type == GTK_SHADOW_IN) - flags |= GTK_STATE_FLAG_ACTIVE; - else if (shadow_type == GTK_SHADOW_ETCHED_IN) - flags |= GTK_STATE_FLAG_INCONSISTENT; - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_option (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height); + GTK_STYLE_GET_CLASS (style)->draw_option (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height); cairo_restore (cr); } @@ -5227,45 +4246,17 @@ gtk_paint_shadow_gap (GtkStyle *style, gint gap_x, gint gap_width) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; - break; - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_frame_gap (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height, - gap_side, - (gdouble) gap_x, - (gdouble) gap_x + gap_width); + GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height, gap_side, gap_x, gap_width); cairo_restore (cr); } @@ -5304,51 +4295,17 @@ gtk_paint_box_gap (GtkStyle *style, gint gap_x, gint gap_width) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; - break; - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_background (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height); - - gtk_render_frame_gap (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height, - gap_side, - (gdouble) gap_x, - (gdouble) gap_x + gap_width); + GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height, gap_side, gap_x, gap_width); cairo_restore (cr); } @@ -5382,43 +4339,17 @@ gtk_paint_extension (GtkStyle *style, gint height, GtkPositionType gap_side) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; - break; - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_extension (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height, - gap_side); + GTK_STYLE_GET_CLASS (style)->draw_extension (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height, gap_side); cairo_restore (cr); } @@ -5449,22 +4380,17 @@ gtk_paint_focus (GtkStyle *style, gint width, gint height) { - GtkStyleContext *context; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); cairo_save (cr); - context = gtk_widget_get_style_context (widget); - - gtk_render_focus (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height); + GTK_STYLE_GET_CLASS (style)->draw_focus (style, cr, state_type, + widget, detail, + x, y, width, height); cairo_restore (cr); } @@ -5499,38 +4425,17 @@ gtk_paint_slider (GtkStyle *style, gint height, GtkOrientation orientation) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_FLAG_ACTIVE; - break; - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_slider (context, cr, x, y, width, height, orientation); + GTK_STYLE_GET_CLASS (style)->draw_slider (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height, orientation); cairo_restore (cr); } @@ -5564,40 +4469,17 @@ gtk_paint_handle (GtkStyle *style, gint height, GtkOrientation orientation) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL); g_return_if_fail (cr != NULL); g_return_if_fail (width >= 0); g_return_if_fail (height >= 0); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_handle (context, cr, - (gdouble) x, - (gdouble) y, - (gdouble) width, - (gdouble) height, - orientation); + GTK_STYLE_GET_CLASS (style)->draw_handle (style, cr, state_type, shadow_type, + widget, detail, + x, y, width, height, orientation); cairo_restore (cr); } @@ -5635,46 +4517,15 @@ gtk_paint_expander (GtkStyle *style, gint y, GtkExpanderStyle expander_style) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - gint size; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL); g_return_if_fail (cr != NULL); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - - if (widget) - gtk_widget_style_get (widget, "expander-size", &size, NULL); - else - size = 10; - - if (expander_style == GTK_EXPANDER_EXPANDED) - flags |= GTK_STATE_FLAG_ACTIVE; - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_expander (context, cr, - (gdouble) x - (size / 2), - (gdouble) y - (size / 2), - (gdouble) size, - (gdouble) size); + GTK_STYLE_GET_CLASS (style)->draw_expander (style, cr, state_type, + widget, detail, + x, y, expander_style); cairo_restore (cr); } @@ -5705,36 +4556,15 @@ gtk_paint_layout (GtkStyle *style, gint y, PangoLayout *layout) { - GtkStyleContext *context; - GtkStateFlags flags = 0; - g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL); g_return_if_fail (cr != NULL); - context = gtk_widget_get_style_context (widget); - - switch (state_type) - { - case GTK_STATE_PRELIGHT: - flags |= GTK_STATE_FLAG_PRELIGHT; - break; - case GTK_STATE_SELECTED: - flags |= GTK_STATE_FLAG_SELECTED; - break; - case GTK_STATE_INSENSITIVE: - flags |= GTK_STATE_FLAG_INSENSITIVE; - break; - default: - break; - } - cairo_save (cr); - gtk_style_context_set_state (context, flags); - gtk_render_layout (context, cr, - (gdouble) x, - (gdouble) y, - layout); + GTK_STYLE_GET_CLASS (style)->draw_layout (style, cr, state_type, use_text, + widget, detail, + x, y, layout); cairo_restore (cr); } From 85398fc05fb0004bf1b855628402a736f4e9c1dd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:16:03 +0200 Subject: [PATCH 231/634] GtkCssProvider: Add gtk_css_provider_get_default(). This method returns a GtkCssProvider with the default style information loaded. --- gtk/gtkcssprovider.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkcssprovider.h | 3 ++ 2 files changed, 78 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 5a4d82ae35..eadefa0b63 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1499,5 +1499,80 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, return TRUE; } +GtkCssProvider * +gtk_css_provider_get_default (void) +{ + static GtkCssProvider *provider; + + if (G_UNLIKELY (!provider)) + { + const gchar *str = + "@fg_color: #000; \n" + "@bg_color: #dcdad5; \n" + "@text_color: #000; \n" + "@base_color: #fff; \n" + "@selected_bg_color: #4b6983; \n" + "@selected_fg_color: #fff; \n" + "@tooltip_bg_color: #eee1b3; \n" + "@tooltip_fg_color: #000; \n" + "\n" + "*, GtkTreeView GtkButton {\n" + " background-color: @bg_color;\n" + " foreground-color: @fg_color;\n" + " text-color: @text_color; \n" + " base-color: @base_color; \n" + "}\n" + "\n" + "*:active {\n" + " background-color: #c4c2bd;\n" + " foreground-color: #000000;\n" + " text-color: #c4c2bd; \n" + " base-color: #9c9a94; \n" + "}\n" + "\n" + "*:prelight {\n" + " background-color: #eeebe7;\n" + " foreground-color: #000000;\n" + " text-color: #eeebe7; \n" + " base-color: #ffffff; \n" + "}\n" + "\n" + "*:selected {\n" + " background-color: #4b6983;\n" + " foreground-color: #ffffff;\n" + " base-color: #4b6983;\n" + " text-color: #ffffff;\n" + "}\n" + "\n" + "*:insensitive {\n" + " background-color: #dcdad5;\n" + " foreground-color: #757575;\n" + "}\n" + "\n" + "GtkTreeView, GtkIconView {\n" + " background-color: #ffffff; \n" + "}\n" + "\n" + "row:nth-child(odd) { \n" + " background-color: shade(#ffffff, 0.93); \n" + "}\n" + "\n" + "tooltip {\n" + " background-color: @tooltip_bg_color; \n" + " foreground-color: @tooltip_fg_color; \n" + "}\n" + "\n" + "GtkToggleButton:prelight {\n" + " text-color: #000; \n" + "}\n" + "\n"; + + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, str, -1, NULL); + } + + return provider; +} + #define __GTK_CSS_PROVIDER_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h index 62f5a0e3d7..18364eaea8 100644 --- a/gtk/gtkcssprovider.h +++ b/gtk/gtkcssprovider.h @@ -57,6 +57,9 @@ gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider, GFile *file, GError **error); +GtkCssProvider * gtk_css_provider_get_default (void); + + G_END_DECLS #endif /* __GTK_CSS_PROVIDER_H__ */ From e15dc89f897d44c76665ea7b4415308096acfea4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 16:16:50 +0200 Subject: [PATCH 232/634] GtkWidget: Add the default CSS provider to all style contexts. --- gtk/gtkwidget.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5de120fc9b..8321dc9e05 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13267,6 +13267,7 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { static GtkCssProvider *css_provider = NULL; + GtkCssProvider *default_provider; GtkWidgetPath *path; context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); @@ -13298,6 +13299,10 @@ gtk_widget_get_style_context (GtkWidget *widget) GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); + default_provider = gtk_css_provider_get_default (); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (default_provider), + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); path = gtk_widget_get_path (widget); gtk_style_context_set_path (context, path); From dc216ffb001011c901d0cf08d5d67d0e87a6f43a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 17:18:53 +0200 Subject: [PATCH 233/634] GtkStyleContext: Add gtk_style_context_[gs]et_direction(). --- gtk/gtkstylecontext.c | 47 ++++++++++++++++++++++++++++++++++++++++++- gtk/gtkstylecontext.h | 4 ++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f7297f71cb..0e7cedb476 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -81,11 +81,14 @@ struct GtkStyleContextPrivate GSList *regions; GtkThemingEngine *theming_engine; + + GtkTextDirection direction; }; enum { PROP_0, - PROP_SCREEN + PROP_SCREEN, + PROP_DIRECTION }; static void gtk_style_context_finalize (GObject *object); @@ -118,6 +121,14 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) P_("The associated GdkScreen"), GDK_TYPE_SCREEN, GTK_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_DIRECTION, + g_param_spec_enum ("direction", + P_("Direction"), + P_("Text direction"), + GTK_TYPE_TEXT_DIRECTION, + GTK_TEXT_DIR_LTR, + GTK_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } @@ -171,6 +182,8 @@ gtk_style_context_init (GtkStyleContext *style_context) priv->store = gtk_style_set_new (); priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL); + priv->direction = GTK_TEXT_DIR_RTL; + /* Create default region */ region = style_region_new (); priv->regions = g_slist_prepend (priv->regions, region); @@ -261,6 +274,10 @@ gtk_style_context_impl_set_property (GObject *object, gtk_style_context_set_screen (style_context, g_value_get_object (value)); break; + case PROP_DIRECTION: + gtk_style_context_set_direction (style_context, + g_value_get_enum (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -284,6 +301,9 @@ gtk_style_context_impl_get_property (GObject *object, case PROP_SCREEN: g_value_set_object (value, priv->screen); break; + case PROP_DIRECTION: + g_value_set_enum (value, priv->direction); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1210,6 +1230,31 @@ gtk_style_context_get_screen (GtkStyleContext *context) return priv->screen; } +void +gtk_style_context_set_direction (GtkStyleContext *context, + GtkTextDirection direction) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + priv->direction = direction; + + g_object_notify (G_OBJECT (context), "direction"); +} + +GtkTextDirection +gtk_style_context_get_direction (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), GTK_TEXT_DIR_LTR); + + priv = context->priv; + return priv->direction; +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index d1291a35f2..c3a4516225 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -114,6 +114,10 @@ void gtk_style_context_set_screen (GtkStyleContext *context, GdkScreen *screen); GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context); +void gtk_style_context_set_direction (GtkStyleContext *context, + GtkTextDirection direction); +GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context); + /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, From 978d97ea6f3b539f5fa20d2944b27d32328f2393 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 2 Aug 2010 17:24:27 +0200 Subject: [PATCH 234/634] GtkWidget: Set style context direction. --- gtk/gtkwidget.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8321dc9e05..af4497b887 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -9578,7 +9578,17 @@ gtk_widget_set_direction (GtkWidget *widget, widget->priv->direction = dir; if (old_dir != gtk_widget_get_direction (widget)) - gtk_widget_emit_direction_changed (widget, old_dir); + { + GtkStyleContext *context; + + context = g_object_get_qdata (G_OBJECT (widget), quark_style_context); + + if (context) + gtk_style_context_set_direction (context, + gtk_widget_get_direction (widget)); + + gtk_widget_emit_direction_changed (widget, old_dir); + } } /** @@ -13270,7 +13280,11 @@ gtk_widget_get_style_context (GtkWidget *widget) GtkCssProvider *default_provider; GtkWidgetPath *path; - context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); + context = g_object_new (GTK_TYPE_STYLE_CONTEXT, + "direction", gtk_widget_get_direction (widget), + NULL); + + g_object_set_qdata_full (G_OBJECT (widget), quark_style_context, context, (GDestroyNotify) g_object_unref); From fcf12ff9b98ef2e39a02354d00cb688c41a7d6ae Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:26:53 +0200 Subject: [PATCH 235/634] GtkThemingEngine: Add gtk_theming_engine_get_direction(). --- gtk/gtkthemingengine.c | 11 +++++++++++ gtk/gtkthemingengine.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 8168dc985a..e873c88c82 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -347,6 +347,17 @@ gtk_theming_engine_has_child_class (GtkThemingEngine *engine, return gtk_style_context_has_child_class (priv->context, style_class, flags); } +GtkTextDirection +gtk_theming_engine_get_direction (GtkThemingEngine *engine) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), GTK_TEXT_DIR_LTR); + + priv = engine->priv; + return gtk_style_context_get_direction (priv->context); +} + /* GtkThemingModule */ static gboolean diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 5703b2cc20..f6ae571eb5 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -171,6 +171,8 @@ GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, GtkStateType state); +GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); + G_CONST_RETURN GtkThemingEngine * gtk_theming_engine_load (const gchar *name); GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine); From 78cc97f7b36a10a4ea7751ffd83dcbd913656975 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:27:32 +0200 Subject: [PATCH 236/634] GtkThemingEngine: fix typo in function declaration. --- gtk/gtkthemingengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index f6ae571eb5..b021d971d7 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -168,7 +168,7 @@ gboolean gtk_theming_engine_has_child_class (GtkThemingEngine *engine, GtkChildClassFlags *flags); GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); -gboolean gtk__theming_engine_is_state_set (GtkThemingEngine *engine, +gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, GtkStateType state); GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); From b4a24d64576d1cb4d0bfe9b0d4c6858b96d2a469 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:29:07 +0200 Subject: [PATCH 237/634] GtkStyleSet: Register the "border" property. --- gtk/gtkstyleset.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 15db395a00..f1b0b35709 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -80,6 +80,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL); gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL); + gtk_style_set_register_property ("border", G_TYPE_INT, NULL); g_value_init (&val, GTK_TYPE_THEMING_ENGINE); g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); From 143c4b3b60014891ff43ef00e781bd90b4b19b47 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:30:26 +0200 Subject: [PATCH 238/634] GtkStyleContext: Add gtk_style_context_lookup_color(). gtk_style_lookup_color() now uses this function internally. --- gtk/gtkstyle.c | 18 +++--------------- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 3 +++ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9a9ccb55b7..ef6fe3031e 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -958,7 +958,6 @@ gtk_style_lookup_color (GtkStyle *style, GdkColor *color) { GtkStylePrivate *priv; - GSList *iter; g_return_val_if_fail (GTK_IS_STYLE (style), FALSE); g_return_val_if_fail (color_name != NULL, FALSE); @@ -966,21 +965,10 @@ gtk_style_lookup_color (GtkStyle *style, priv = GTK_STYLE_GET_PRIVATE (style); - for (iter = priv->color_hashes; iter != NULL; iter = iter->next) - { - GHashTable *hash = iter->data; - GdkColor *mapping = g_hash_table_lookup (hash, color_name); + if (!priv->context) + return FALSE; - if (mapping) - { - color->red = mapping->red; - color->green = mapping->green; - color->blue = mapping->blue; - return TRUE; - } - } - - return FALSE; + return gtk_style_context_lookup_color (priv->context, color_name, color); } /** diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 0e7cedb476..591094b304 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1255,6 +1255,27 @@ gtk_style_context_get_direction (GtkStyleContext *context) return priv->direction; } +gboolean +gtk_style_context_lookup_color (GtkStyleContext *context, + const gchar *color_name, + GdkColor *color) +{ + GtkStyleContextPrivate *priv; + GtkSymbolicColor *sym_color; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); + g_return_val_if_fail (color_name != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); + + priv = context->priv; + sym_color = gtk_style_set_lookup_color (priv->store, color_name); + + if (!sym_color) + return FALSE; + + return gtk_symbolic_color_resolve (sym_color, priv->store, color); +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index c3a4516225..133f357397 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -118,6 +118,9 @@ void gtk_style_context_set_direction (GtkStyleContext *context, GtkTextDirection direction); GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context); +gboolean gtk_style_context_lookup_color (GtkStyleContext *context, + const gchar *color_name, + GdkColor *color); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, From d9b42ce50fd36020f29319707351e7fb61240b71 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:32:25 +0200 Subject: [PATCH 239/634] Add GtkJunctionSides flags. --- gtk/gtkenums.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 9356b8f08d..2bdaf7ae4f 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -579,6 +579,14 @@ typedef enum { GTK_CHILD_CLASS_SORTED = 1 << 5 } GtkChildClassFlags; +typedef enum { + GTK_JUNCTION_NONE = 0, + GTK_JUNCTION_TOP = 1 << 0, + GTK_JUNCTION_BOTTOM = 1 << 1, + GTK_JUNCTION_LEFT = 1 << 2, + GTK_JUNCTION_RIGHT = 1 << 3 +} GtkJunctionSides; + G_END_DECLS From 9108739c9b8ed9940eb0fcd259854df3486f29fc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:33:53 +0200 Subject: [PATCH 240/634] GtkStyleContext: Add gtk_style_context_[gs]et_junction_sides(). These functions will help widgets specify how does one element being painted relate to other contiguous elements. --- gtk/gtkstylecontext.c | 31 +++++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 591094b304..c896bc9bec 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -61,6 +61,7 @@ struct GtkStyleRegion { GArray *style_classes; GArray *child_style_classes; + GtkJunctionSides junction_sides; }; struct GtkStyleContextPrivate @@ -166,6 +167,9 @@ style_region_copy (const GtkStyleRegion *region) g_array_insert_vals (copy->child_style_classes, 0, region->child_style_classes->data, region->child_style_classes->len); + + copy->junction_sides = region->junction_sides; + return copy; } @@ -1255,6 +1259,33 @@ gtk_style_context_get_direction (GtkStyleContext *context) return priv->direction; } +void +gtk_style_context_set_junction_sides (GtkStyleContext *context, + GtkJunctionSides sides) +{ + GtkStyleContextPrivate *priv; + GtkStyleRegion *region; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + region = priv->regions->data; + region->junction_sides = sides; +} + +GtkJunctionSides +gtk_style_context_get_junction_sides (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GtkStyleRegion *region; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0); + + priv = context->priv; + region = priv->regions->data; + return region->junction_sides; +} + gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 133f357397..73a3e9fe94 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -118,6 +118,10 @@ void gtk_style_context_set_direction (GtkStyleContext *context, GtkTextDirection direction); GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context); +void gtk_style_context_set_junction_sides (GtkStyleContext *context, + GtkJunctionSides sides); +GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context); + gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, GdkColor *color); From 8c117b1638827fd34d51cb8f6deca31fa7caeedf Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:36:09 +0200 Subject: [PATCH 241/634] GtkThemingEngine: Add gtk_theming_engine_get_junction_sides(). --- gtk/gtkthemingengine.c | 11 +++++++++++ gtk/gtkthemingengine.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index e873c88c82..f162b311b3 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -358,6 +358,17 @@ gtk_theming_engine_get_direction (GtkThemingEngine *engine) return gtk_style_context_get_direction (priv->context); } +GtkJunctionSides +gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); + + priv = engine->priv; + return gtk_style_context_get_junction_sides (priv->context); +} + /* GtkThemingModule */ static gboolean diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index b021d971d7..1191d5a2f0 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -173,6 +173,8 @@ gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); +GtkJunctionSides gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine); + G_CONST_RETURN GtkThemingEngine * gtk_theming_engine_load (const gchar *name); GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine); From dd8da82d1e4f72d325b99b8a481fedf9f6cbc991 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:37:53 +0200 Subject: [PATCH 242/634] GtkStyle: set junction details in spinbutton buttons. --- gtk/gtkstyle.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index ef6fe3031e..2bcf1af5bf 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1778,11 +1778,17 @@ transform_detail_string (const gchar *detail, } else if (strcmp (detail, "spinbutton") == 0) gtk_style_context_set_class (context, "spinbutton"); - else if (strcmp (detail, "spinbutton_up") == 0 || - strcmp (detail, "spinbutton_down") == 0) + else if (strcmp (detail, "spinbutton_up") == 0) { gtk_style_context_set_class (context, "spinbutton"); gtk_style_context_set_class (context, "button"); + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); + } + else if (strcmp (detail, "spinbutton_down") == 0) + { + gtk_style_context_set_class (context, "spinbutton"); + gtk_style_context_set_class (context, "button"); + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); } else if (g_str_has_prefix (detail, "cell_")) { From b6226cb7b943be3ffc13cceca328f840b1c85def Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:38:23 +0200 Subject: [PATCH 243/634] GtkThemingEngine: Render correctly spinbutton buttons. --- gtk/gtkthemingengine.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f162b311b3..3d43b2f7ba 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1009,12 +1009,27 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, { if (gtk_theming_engine_has_class (engine, "button")) { + GtkJunctionSides sides; + + sides = gtk_theming_engine_get_junction_sides (engine); + + if (sides & GTK_JUNCTION_BOTTOM) + y += 2; + + width -= 3; + height -= 2; + + if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL) + x += 2; + else + x += 1; + gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x + 1, y + 2, width - 3, height - 2, SIDE_TOP); + add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); cairo_stroke (cr); gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x + 1, y + 2, width - 3, height - 2, SIDE_BOTTOM); + add_path_rectangle_sides (cr, x, y, width, height, SIDE_BOTTOM); cairo_stroke (cr); } else From 27bc581dca3bdabcbfe708dfbb0eec64db016b6f Mon Sep 17 00:00:00 2001 From: Sven Herzberg Date: Thu, 5 Aug 2010 16:21:12 +0200 Subject: [PATCH 244/634] GtkWidgetPath: properly use const * gtk/gtkwidgetpath.c, * gtk/gtkwidgetpath.h: use const where possible --- gtk/gtkwidgetpath.c | 22 +++++++++++----------- gtk/gtkwidgetpath.h | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 2e78b7cdd5..29b019ed36 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -114,7 +114,7 @@ gtk_widget_path_free (GtkWidgetPath *path) } guint -gtk_widget_path_length (GtkWidgetPath *path) +gtk_widget_path_length (const GtkWidgetPath *path) { g_return_val_if_fail (path != NULL, 0); @@ -137,8 +137,8 @@ gtk_widget_path_prepend_type (GtkWidgetPath *path, } GType -gtk_widget_path_get_element_type (GtkWidgetPath *path, - guint pos) +gtk_widget_path_get_element_type (const GtkWidgetPath *path, + guint pos) { GtkPathElement *elem; @@ -165,8 +165,8 @@ gtk_widget_path_set_element_type (GtkWidgetPath *path, } G_CONST_RETURN gchar * -gtk_widget_path_get_element_name (GtkWidgetPath *path, - guint pos) +gtk_widget_path_get_element_name (const GtkWidgetPath *path, + guint pos) { GtkPathElement *elem; @@ -254,8 +254,8 @@ gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, } GSList * -gtk_widget_path_iter_list_regions (GtkWidgetPath *path, - guint pos) +gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, + guint pos) { GtkPathElement *elem; GHashTableIter iter; @@ -279,10 +279,10 @@ gtk_widget_path_iter_list_regions (GtkWidgetPath *path, } gboolean -gtk_widget_path_iter_has_region (GtkWidgetPath *path, - guint pos, - const gchar *name, - GtkChildClassFlags *flags) +gtk_widget_path_iter_has_region (const GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags *flags) { GtkPathElement *elem; gpointer value; diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 9e2d0edf1e..78c33e0e14 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -33,22 +33,22 @@ GtkWidgetPath * gtk_widget_path_new (void); GtkWidgetPath * gtk_widget_path_copy (const GtkWidgetPath *path); void gtk_widget_path_free (GtkWidgetPath *path); -guint gtk_widget_path_length (GtkWidgetPath *path); +guint gtk_widget_path_length (const GtkWidgetPath *path); guint gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type); -GType gtk_widget_path_get_element_type (GtkWidgetPath *path, +GType gtk_widget_path_get_element_type (const GtkWidgetPath*path, guint pos); void gtk_widget_path_set_element_type (GtkWidgetPath *path, guint pos, GType type); -G_CONST_RETURN gchar * gtk_widget_path_get_element_name (GtkWidgetPath *path, - guint pos); -void gtk_widget_path_set_element_name (GtkWidgetPath *path, - guint pos, - const gchar *name); +G_CONST_RETURN gchar * gtk_widget_path_get_element_name (const GtkWidgetPath *path, + guint pos); +void gtk_widget_path_set_element_name (GtkWidgetPath *path, + guint pos, + const gchar *name); void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, @@ -60,13 +60,13 @@ void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, guint pos); -GSList * gtk_widget_path_iter_list_regions (GtkWidgetPath *path, - guint pos); +GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, + guint pos); -gboolean gtk_widget_path_iter_has_region (GtkWidgetPath *path, - guint pos, - const gchar *name, - GtkChildClassFlags *flags); +gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkChildClassFlags *flags); GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); From c001833ed172a4057a1e52f2630b20a791a646a1 Mon Sep 17 00:00:00 2001 From: Sven Herzberg Date: Thu, 5 Aug 2010 16:21:47 +0200 Subject: [PATCH 245/634] GtkCssProvider: don't ignore custom attributes * gtk/gtkcssprovider.c: don't ignore custom attribites (which can be added by theme engines) --- gtk/gtkcssprovider.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index eadefa0b63..67dc3f68ce 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -584,9 +584,6 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, { gchar *prop = key; - if (prop[0] == '-') - continue; - if (info->state == GTK_STATE_NORMAL) gtk_style_set_set_default (set, key, value); else @@ -1366,7 +1363,12 @@ parse_rule (GtkCssProvider *css_provider, val = g_slice_new0 (GValue); g_value_init (val, prop_type); - if (css_provider_parse_value (value_str, val)) + if (prop_type == G_TYPE_STRING) + { + g_value_set_string (val, value_str); + g_hash_table_insert (priv->cur_properties, prop, val); + } + else if (css_provider_parse_value (value_str, val)) g_hash_table_insert (priv->cur_properties, prop, val); else { From 9ebbc7b5c5eea7499cb60e89502f02b7cfb0b2ad Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 11:36:21 +0200 Subject: [PATCH 246/634] GtkCssProvider: Small optimization. --- gtk/gtkcssprovider.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 67dc3f68ce..8deae7e75c 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -429,10 +429,12 @@ compare_selector (GtkWidgetPath *path, GSList *elements = selector->elements; gboolean match = TRUE; guint64 score = 0; + guint len; guint i = 0; - while (elements && match && - i < gtk_widget_path_length (path)) + len = gtk_widget_path_length (path); + + while (elements && match && i < len) { SelectorElement *elem; guint8 elem_score; From 85dbc719215f4a1d9fcff8aeeabf26262144f6d6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 11:42:08 +0200 Subject: [PATCH 247/634] GtkCssProvider: Immediately bail out if GType couldn't be resolved. --- gtk/gtkcssprovider.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 8deae7e75c..692de7831a 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -444,14 +444,16 @@ compare_selector (GtkWidgetPath *path, match = compare_selector_element (path, i, elem, &elem_score); i++; - if (!match && elem->combinator == COMBINATOR_DESCENDANT) + if (!match && + elem->elem_type != SELECTOR_TYPE_NAME && + elem->combinator == COMBINATOR_DESCENDANT) { /* With descendant combinators there may * be intermediate chidren in the hierarchy */ match = TRUE; } - else + else if (match) elements = elements->next; if (match) From 52878c45b5303291be355232d2567f822b18529a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 11:43:18 +0200 Subject: [PATCH 248/634] GtkCssProvider: Don't jump too eagerly to the next element when comparing selectors. --- gtk/gtkcssprovider.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 692de7831a..7f83d1b304 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -442,7 +442,20 @@ compare_selector (GtkWidgetPath *path, elem = elements->data; match = compare_selector_element (path, i, elem, &elem_score); - i++; + + /* Only move on to the next index if there is no match + * with the current element (whether to continue or not + * handled right after in the combinator check), or a + * GType or glob has just been matched. + * + * Region and widget names do not trigger this because + * the next element in the selector path could also be + * related to the same index. + */ + if (!match || + (elem->elem_type == SELECTOR_GTYPE || + elem->elem_type == SELECTOR_GLOB)) + i++; if (!match && elem->elem_type != SELECTOR_TYPE_NAME && From 5f77ead9c6d818962a8296dd3cc1ed24e741b9b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 11:44:32 +0200 Subject: [PATCH 249/634] GtkCssProvider: Parse and compare widget names. --- gtk/gtkcssprovider.c | 49 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 7f83d1b304..f741504897 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -232,6 +232,21 @@ selector_path_prepend_region (SelectorPath *path, path->elements = g_slist_prepend (path->elements, elem); } +static void +selector_path_prepend_name (SelectorPath *path, + const gchar *name) +{ + SelectorElement *elem; + + elem = g_slice_new (SelectorElement); + elem->combinator = COMBINATOR_DESCENDANT; + elem->elem_type = SELECTOR_NAME; + + elem->name = g_quark_from_string (name); + + path->elements = g_slist_prepend (path->elements, elem); +} + static void selector_path_prepend_combinator (SelectorPath *path, CombinatorType combinator) @@ -418,6 +433,20 @@ compare_selector_element (GtkWidgetPath *path, *score = 1; return TRUE; } + else if (elem->elem_type == SELECTOR_NAME) + { + const gchar *name, *path_name; + + name = g_quark_to_string (elem->name); + path_name = gtk_widget_path_get_element_name (path, index); + + if (!path_name || + strcmp (path_name, name) != 0) + return FALSE; + + *score = 0xF; + return TRUE; + } return FALSE; } @@ -738,6 +767,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, g_assert_not_reached (); priv->scanner->config->scan_float = FALSE; + priv->scanner->config->cpair_comment_single = NULL; } static void @@ -908,12 +938,27 @@ parse_selector (GtkCssProvider *css_provider, *selector_out = path; if (scanner->token != ':' && + scanner->token != '#' && scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; - while (scanner->token == G_TOKEN_IDENTIFIER) + while (scanner->token == '#' || + scanner->token == G_TOKEN_IDENTIFIER) { - if (g_ascii_isupper (scanner->value.v_identifier[0])) + if (scanner->token == '#') + { + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + /* Add glob selector if path is empty */ + if (selector_path_depth (path) == 0) + selector_path_prepend_glob (path); + + selector_path_prepend_name (path, scanner->value.v_identifier); + } + else if (g_ascii_isupper (scanner->value.v_identifier[0])) selector_path_prepend_type (path, scanner->value.v_identifier); else if (g_ascii_islower (scanner->value.v_identifier[0])) { From d47d3d0200aed673d2a9bb1180fd9b9fdfa5087e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 11:46:01 +0200 Subject: [PATCH 250/634] GtkCssProvider: Set child combinators in default CSS. --- gtk/gtkcssprovider.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f741504897..7c00ffedf1 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1580,7 +1580,7 @@ gtk_css_provider_get_default (void) "@tooltip_bg_color: #eee1b3; \n" "@tooltip_fg_color: #000; \n" "\n" - "*, GtkTreeView GtkButton {\n" + "*, GtkTreeView > GtkButton {\n" " background-color: @bg_color;\n" " foreground-color: @fg_color;\n" " text-color: @text_color; \n" @@ -1617,7 +1617,7 @@ gtk_css_provider_get_default (void) " background-color: #ffffff; \n" "}\n" "\n" - "row:nth-child(odd) { \n" + "GtkTreeView > row:nth-child(odd) { \n" " background-color: shade(#ffffff, 0.93); \n" "}\n" "\n" From ad08330fae98a6d42a590d5320faf351e136f746 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 12:19:23 +0200 Subject: [PATCH 251/634] Compare region names as quarks in style matching. --- gtk/gtkcssprovider.c | 8 ++--- gtk/gtkwidgetpath.c | 77 ++++++++++++++++++++++++++++++-------------- gtk/gtkwidgetpath.h | 4 +++ 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 7c00ffedf1..f29ca64861 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -411,13 +411,11 @@ compare_selector_element (GtkWidgetPath *path, } else if (elem->elem_type == SELECTOR_REGION) { - const gchar *region_name; GtkChildClassFlags flags; - /* FIXME: Need GQuark API here */ - region_name = g_quark_to_string (elem->region.name); - - if (!gtk_widget_path_iter_has_region (path, index, region_name, &flags)) + if (!gtk_widget_path_iter_has_qregion (path, index, + elem->region.name, + &flags)) return FALSE; if (elem->region.flags != 0 && diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 29b019ed36..bbac2a7af4 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -74,15 +74,10 @@ gtk_widget_path_copy (const GtkWidgetPath *path) gpointer key, value; g_hash_table_iter_init (&iter, elem->regions); - new.regions = g_hash_table_new_full (g_str_hash, - g_str_equal, - (GDestroyNotify) g_free, - NULL); + new.regions = g_hash_table_new (NULL, NULL); while (g_hash_table_iter_next (&iter, &key, &value)) - g_hash_table_insert (new.regions, - g_strdup ((const gchar *) key), - value); + g_hash_table_insert (new.regions, key, value); } g_array_append_val (new_path->elems, new); @@ -203,21 +198,20 @@ gtk_widget_path_iter_add_region (GtkWidgetPath *path, GtkChildClassFlags flags) { GtkPathElement *elem; + GQuark qname; g_return_if_fail (path != NULL); g_return_if_fail (pos < path->elems->len); g_return_if_fail (name != NULL); elem = &g_array_index (path->elems, GtkPathElement, pos); + qname = g_quark_from_string (name); if (!elem->regions) - elem->regions = g_hash_table_new_full (g_str_hash, - g_str_equal, - (GDestroyNotify) g_free, - NULL); + elem->regions = g_hash_table_new (NULL, NULL); g_hash_table_insert (elem->regions, - g_strdup (name), + GUINT_TO_POINTER (qname), GUINT_TO_POINTER (flags)); } @@ -227,15 +221,21 @@ gtk_widget_path_iter_remove_region (GtkWidgetPath *path, const gchar *name) { GtkPathElement *elem; + GQuark qname; g_return_if_fail (path != NULL); g_return_if_fail (pos < path->elems->len); g_return_if_fail (name != NULL); + qname = g_quark_try_string (name); + + if (qname == 0) + return; + elem = &g_array_index (path->elems, GtkPathElement, pos); if (elem->regions) - g_hash_table_remove (elem->regions, name); + g_hash_table_remove (elem->regions, GUINT_TO_POINTER (qname)); } void @@ -273,36 +273,63 @@ gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, g_hash_table_iter_init (&iter, elem->regions); while (g_hash_table_iter_next (&iter, &key, NULL)) - list = g_slist_prepend (list, key); + { + GQuark qname; + + qname = GPOINTER_TO_UINT (key); + list = g_slist_prepend (list, (gchar *) g_quark_to_string (qname)); + } return list; } +gboolean +gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, + guint pos, + GQuark qname, + GtkChildClassFlags *flags) +{ + GtkPathElement *elem; + gpointer value; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + g_return_val_if_fail (qname != 0, FALSE); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->regions) + return FALSE; + + if (!g_hash_table_lookup_extended (elem->regions, + GUINT_TO_POINTER (qname), + NULL, &value)) + return FALSE; + + if (flags) + *flags = GPOINTER_TO_UINT (value); + + return TRUE; +} + gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, guint pos, const gchar *name, GtkChildClassFlags *flags) { - GtkPathElement *elem; - gpointer value; + GQuark qname; g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (pos < path->elems->len, FALSE); g_return_val_if_fail (name != NULL, FALSE); - elem = &g_array_index (path->elems, GtkPathElement, pos); + qname = g_quark_try_string (name); - if (!elem->regions) + if (qname == 0) return FALSE; - if (!g_hash_table_lookup_extended (elem->regions, name, NULL, &value)) - return FALSE; - - if (flags) - *flags = GPOINTER_TO_UINT (value); - - return TRUE; + return gtk_widget_path_iter_has_qregion (path, pos, qname, flags); } GType diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 78c33e0e14..b6515e191a 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -67,6 +67,10 @@ gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, guint pos, const gchar *name, GtkChildClassFlags *flags); +gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, + guint pos, + GQuark qname, + GtkChildClassFlags *flags); GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); From 09d8592b5bc722cdfe6164929ec2f02943b0379c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 12:50:37 +0200 Subject: [PATCH 252/634] GtkWidgetPath: Make API more consistent. --- gtk/gtkcssprovider.c | 4 ++-- gtk/gtkwidgetpath.c | 20 ++++++++++---------- gtk/gtkwidgetpath.h | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f29ca64861..323f397a9c 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -379,7 +379,7 @@ compare_selector_element (GtkWidgetPath *path, { GType type; - type = gtk_widget_path_get_element_type (path, index); + type = gtk_widget_path_iter_get_widget_type (path, index); if (!g_type_is_a (type, elem->type)) return FALSE; @@ -436,7 +436,7 @@ compare_selector_element (GtkWidgetPath *path, const gchar *name, *path_name; name = g_quark_to_string (elem->name); - path_name = gtk_widget_path_get_element_name (path, index); + path_name = gtk_widget_path_iter_get_name (path, index); if (!path_name || strcmp (path_name, name) != 0) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index bbac2a7af4..60dcfa2371 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -132,8 +132,8 @@ gtk_widget_path_prepend_type (GtkWidgetPath *path, } GType -gtk_widget_path_get_element_type (const GtkWidgetPath *path, - guint pos) +gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, + guint pos) { GtkPathElement *elem; @@ -145,9 +145,9 @@ gtk_widget_path_get_element_type (const GtkWidgetPath *path, } void -gtk_widget_path_set_element_type (GtkWidgetPath *path, - guint pos, - GType type) +gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, + guint pos, + GType type) { GtkPathElement *elem; @@ -160,8 +160,8 @@ gtk_widget_path_set_element_type (GtkWidgetPath *path, } G_CONST_RETURN gchar * -gtk_widget_path_get_element_name (const GtkWidgetPath *path, - guint pos) +gtk_widget_path_iter_get_name (const GtkWidgetPath *path, + guint pos) { GtkPathElement *elem; @@ -173,9 +173,9 @@ gtk_widget_path_get_element_name (const GtkWidgetPath *path, } void -gtk_widget_path_set_element_name (GtkWidgetPath *path, - guint pos, - const gchar *name) +gtk_widget_path_iter_set_name (GtkWidgetPath *path, + guint pos, + const gchar *name) { GtkPathElement *elem; diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index b6515e191a..d6e074edec 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -38,17 +38,17 @@ guint gtk_widget_path_length (const GtkWidgetPath *path); guint gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type); -GType gtk_widget_path_get_element_type (const GtkWidgetPath*path, - guint pos); -void gtk_widget_path_set_element_type (GtkWidgetPath *path, - guint pos, - GType type); +GType gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, + guint pos); +void gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, + guint pos, + GType type); -G_CONST_RETURN gchar * gtk_widget_path_get_element_name (const GtkWidgetPath *path, - guint pos); -void gtk_widget_path_set_element_name (GtkWidgetPath *path, - guint pos, - const gchar *name); +G_CONST_RETURN gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path, + guint pos); +void gtk_widget_path_iter_set_name (GtkWidgetPath *path, + guint pos, + const gchar *name); void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, From 56e4ffabea547d2ea9ffa90c5bc9e0aece40749c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 13:11:50 +0200 Subject: [PATCH 253/634] Compare widget names as GQuarks in style matching. --- gtk/gtkcssprovider.c | 8 +------- gtk/gtkwidgetpath.c | 45 +++++++++++++++++++++++++++++++++++++------- gtk/gtkwidgetpath.h | 16 +++++++++++----- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 323f397a9c..0f55a862fd 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -433,13 +433,7 @@ compare_selector_element (GtkWidgetPath *path, } else if (elem->elem_type == SELECTOR_NAME) { - const gchar *name, *path_name; - - name = g_quark_to_string (elem->name); - path_name = gtk_widget_path_iter_get_name (path, index); - - if (!path_name || - strcmp (path_name, name) != 0) + if (!gtk_widget_path_iter_has_qname (path, index, elem->name)) return FALSE; *score = 0xF; diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 60dcfa2371..db9f79b1be 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -29,7 +29,7 @@ typedef struct GtkPathElement GtkPathElement; struct GtkPathElement { GType type; - gchar *name; + GQuark name; GHashTable *regions; }; @@ -66,7 +66,7 @@ gtk_widget_path_copy (const GtkWidgetPath *path) elem = &g_array_index (path->elems, GtkPathElement, i); new.type = elem->type; - new.name = g_strdup (elem->name); + new.name = elem->name; if (elem->regions) { @@ -98,7 +98,6 @@ gtk_widget_path_free (GtkWidgetPath *path) GtkPathElement *elem; elem = &g_array_index (path->elems, GtkPathElement, i); - g_free (elem->name); if (elem->regions) g_hash_table_destroy (elem->regions); @@ -169,7 +168,7 @@ gtk_widget_path_iter_get_name (const GtkWidgetPath *path, g_return_val_if_fail (pos < path->elems->len, NULL); elem = &g_array_index (path->elems, GtkPathElement, pos); - return elem->name; + return g_quark_to_string (elem->name); } void @@ -185,10 +184,42 @@ gtk_widget_path_iter_set_name (GtkWidgetPath *path, elem = &g_array_index (path->elems, GtkPathElement, pos); - if (elem->name) - g_free (elem->name); + elem->name = g_quark_from_string (name); +} - elem->name = g_strdup (name); +gboolean +gtk_widget_path_iter_has_qname (const GtkWidgetPath *path, + guint pos, + GQuark qname) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (qname != 0, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + return (elem->name == qname); +} + +gboolean +gtk_widget_path_iter_has_name (const GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GQuark qname; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + + qname = g_quark_try_string (name); + + if (qname == 0) + return FALSE; + + return gtk_widget_path_iter_has_qname (path, pos, qname); } void diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index d6e074edec..e4c1de1579 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -44,11 +44,17 @@ void gtk_widget_path_iter_set_widget_type (GtkWidgetPath *p guint pos, GType type); -G_CONST_RETURN gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path, - guint pos); -void gtk_widget_path_iter_set_name (GtkWidgetPath *path, - guint pos, - const gchar *name); +G_CONST_RETURN gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path, + guint pos); +void gtk_widget_path_iter_set_name (GtkWidgetPath *path, + guint pos, + const gchar *name); +gboolean gtk_widget_path_iter_has_name (const GtkWidgetPath *path, + guint pos, + const gchar *name); +gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path, + guint pos, + GQuark qname); void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, From 99224c9eecdeb813206c15fd2a618e214765f4b9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 14:51:01 +0200 Subject: [PATCH 254/634] GtkCssProvider: Parse correctly widget types with a name. There's now a distinction between: GtkLabel#label-name: Label with name "label-name" GtkWindow #label-name: Window containing a widget named "label-name" --- gtk/gtkcssprovider.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 0f55a862fd..b0d41b4b60 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -744,7 +744,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, else if (scope == SCOPE_SELECTOR) { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_" G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_#" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_PSEUDO_CLASS || @@ -944,14 +944,36 @@ parse_selector (GtkCssProvider *css_provider, if (scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; - /* Add glob selector if path is empty */ - if (selector_path_depth (path) == 0) - selector_path_prepend_glob (path); - + selector_path_prepend_glob (path); + selector_path_prepend_combinator (path, COMBINATOR_CHILD); selector_path_prepend_name (path, scanner->value.v_identifier); } else if (g_ascii_isupper (scanner->value.v_identifier[0])) - selector_path_prepend_type (path, scanner->value.v_identifier); + { + gchar *pos; + + pos = strchr (scanner->value.v_identifier, '#'); + + if (pos) + { + gchar *type_name, *name; + + /* Widget type and name put together */ + name = pos + 1; + *pos = '\0'; + type_name = scanner->value.v_identifier; + + selector_path_prepend_type (path, type_name); + + /* This is only so there is a direct relationship + * between widget type and its name. + */ + selector_path_prepend_combinator (path, COMBINATOR_CHILD); + selector_path_prepend_name (path, name); + } + else + selector_path_prepend_type (path, scanner->value.v_identifier); + } else if (g_ascii_islower (scanner->value.v_identifier[0])) { GtkChildClassFlags flags = 0; From 355f0d69ab2c45ce7356361c6d957fd35acab854 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 17:49:15 +0200 Subject: [PATCH 255/634] GtkStyleSet: Allow custom parsers on registered properties. --- gtk/gtkcssprovider.c | 13 +++++++++++-- gtk/gtkstyleset.c | 35 ++++++++++++++++++++++------------- gtk/gtkstyleset.h | 16 +++++++++++----- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index b0d41b4b60..2cb90442db 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1398,7 +1398,9 @@ parse_rule (GtkCssProvider *css_provider, while (scanner->token == G_TOKEN_IDENTIFIER) { const gchar *value_str = NULL; + GtkStylePropertyParser parse_func = NULL; GType prop_type; + GError *error = NULL; gchar *prop; prop = g_strdup (scanner->value.v_identifier); @@ -1432,7 +1434,7 @@ parse_rule (GtkCssProvider *css_provider, g_hash_table_insert (priv->cur_properties, prop, val); } - else if (gtk_style_set_lookup_property (prop, &prop_type)) + else if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func)) { GValue *val; @@ -1444,10 +1446,17 @@ parse_rule (GtkCssProvider *css_provider, g_value_set_string (val, value_str); g_hash_table_insert (priv->cur_properties, prop, val); } - else if (css_provider_parse_value (value_str, val)) + else if ((parse_func && (parse_func) (value_str, val, &error)) || + (!parse_func && css_provider_parse_value (value_str, val))) g_hash_table_insert (priv->cur_properties, prop, val); else { + if (error) + { + g_warning ("Error parsing property value: %s\n", error->message); + g_error_free (error); + } + g_value_unset (val); g_slice_free (GValue, val); g_free (prop); diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index f1b0b35709..d2053db7ac 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -39,6 +39,7 @@ struct PropertyNode GQuark property_quark; GType property_type; GValue default_value; + GtkStylePropertyParser parse_func; }; struct PropertyData @@ -72,19 +73,19 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) object_class->finalize = gtk_style_set_finalize; /* Initialize default property set */ - gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR, NULL); - gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR, NULL); - gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR, NULL); - gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR, NULL); + gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR, NULL, NULL); + gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR, NULL, NULL); + gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR, NULL, NULL); + gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR, NULL, NULL); - gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL); + gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); - gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL); - gtk_style_set_register_property ("border", G_TYPE_INT, NULL); + gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); + gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); g_value_init (&val, GTK_TYPE_THEMING_ENGINE); g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); - gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val); + gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); g_value_unset (&val); g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); @@ -186,9 +187,10 @@ property_node_lookup (GQuark quark) /* Property registration functions */ void -gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value) +gtk_style_set_register_property (const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func) { PropertyNode *node, new = { 0 }; GQuark quark; @@ -220,6 +222,9 @@ gtk_style_set_register_property (const gchar *property_name, g_value_copy (default_value, &new.default_value); } + if (parse_func) + new.parse_func = parse_func; + for (i = 0; i < properties->len; i++) { node = &g_array_index (properties, PropertyNode, i); @@ -232,8 +237,9 @@ gtk_style_set_register_property (const gchar *property_name, } gboolean -gtk_style_set_lookup_property (const gchar *property_name, - GType *type) +gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GtkStylePropertyParser *parse_func) { PropertyNode *node; GtkStyleSetClass *klass; @@ -261,6 +267,9 @@ gtk_style_set_lookup_property (const gchar *property_name, if (type) *type = node->property_type; + if (parse_func) + *parse_func = node->parse_func; + found = TRUE; break; } diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 6b828345ac..cf46a2fab5 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -48,14 +48,20 @@ struct GtkStyleSetClass GObjectClass parent_class; }; +typedef gboolean (* GtkStylePropertyParser) (const gchar *string, + GValue *value, + GError **error); + GType gtk_style_set_get_type (void) G_GNUC_CONST; /* Functions to register style properties */ -void gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value); -gboolean gtk_style_set_lookup_property (const gchar *property_name, - GType *type); +void gtk_style_set_register_property (const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func); +gboolean gtk_style_set_lookup_property (const gchar *property_name, + GType *type, + GtkStylePropertyParser *parse_func); GtkStyleSet * gtk_style_set_new (void); From d9e3782391a7eebe76743b4bd335d2857ed52d02 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 17:50:52 +0200 Subject: [PATCH 256/634] GtkStyleSet: Fix compiler warning. --- gtk/gtkstyleset.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index d2053db7ac..e8b96cc1cc 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -601,7 +601,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, } else { - GValue *val; + GValue *val = NULL; if (prop) { @@ -610,7 +610,8 @@ gtk_style_set_get_valist (GtkStyleSet *set, else if (G_IS_VALUE (&prop->default_value)) val = &prop->default_value; } - else + + if (!val) val = &node->default_value; if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) From e04dfd4d6de0071f1029120868757ab178b4e18e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Aug 2010 17:51:19 +0200 Subject: [PATCH 257/634] GtkThemingEngine: Add gtk_theming_engine_register_property(). This function may be used for custom property registration from theming engines. The property names will have the -${engine-type-name}-${prop-name} format, the parser has been modified to allow properties with '-' as the first char. --- gtk/gtkcssprovider.c | 32 ++++++++++++++++++++------------ gtk/gtkthemingengine.c | 19 +++++++++++++++++++ gtk/gtkthemingengine.h | 6 ++++++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2cb90442db..ed9ad4539c 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -622,6 +622,14 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, { gchar *prop = key; + /* Properties starting with '-' may be both widget style properties + * or custom properties from the theming engine, so check whether + * the type is registered or not. + */ + if (prop[0] == '-' && + !gtk_style_set_lookup_property (prop, NULL, NULL)) + continue; + if (info->state == GTK_STATE_NORMAL) gtk_style_set_set_default (set, key, value); else @@ -1423,18 +1431,7 @@ parse_rule (GtkCssProvider *css_provider, value_str = g_strstrip (scanner->value.v_identifier); - if (prop[0] == '-' && - g_ascii_isupper (prop[1])) - { - GValue *val; - - val = g_slice_new0 (GValue); - g_value_init (val, G_TYPE_STRING); - g_value_set_string (val, value_str); - - g_hash_table_insert (priv->cur_properties, prop, val); - } - else if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func)) + if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func)) { GValue *val; @@ -1464,6 +1461,17 @@ parse_rule (GtkCssProvider *css_provider, return G_TOKEN_IDENTIFIER; } } + else if (prop[0] == '-' && + g_ascii_isupper (prop[1])) + { + GValue *val; + + val = g_slice_new0 (GValue); + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, value_str); + + g_hash_table_insert (priv->cur_properties, prop, val); + } else g_free (prop); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 3d43b2f7ba..fa65ab6458 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -194,6 +194,25 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, priv->context = context; } +void +gtk_theming_engine_register_property (GtkThemingEngine *engine, + const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func) +{ + gchar *name; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + g_return_if_fail (property_name != NULL); + g_return_if_fail (type != G_TYPE_INVALID); + g_return_if_fail (default_value != NULL && G_IS_VALUE (default_value)); + + name = g_strdup_printf ("-%s-%s", G_OBJECT_TYPE_NAME (engine), property_name); + gtk_style_set_register_property (name, type, default_value, parse_func); + g_free (name); +} + void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 1191d5a2f0..2e31a292bd 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -139,6 +139,12 @@ GType gtk_theming_engine_get_type (void) G_GNUC_CONST; void _gtk_theming_engine_set_context (GtkThemingEngine *engine, GtkStyleContext *context); +void gtk_theming_engine_register_property (GtkThemingEngine *engine, + const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func); + void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, GtkStateType state, From 198d75bea5065adb40db20db46d0fc581110d4db Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 5 Aug 2010 11:28:15 +0200 Subject: [PATCH 258/634] GtkStyleContext: Rename internal struct. GtkStyleRegion has been renamed to GtkStyleInfo, as it doesn't really have much to do with regions itself, the information it contains does. This struct is used in save/restore. --- gtk/gtkstylecontext.c | 169 +++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 85 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c896bc9bec..13b85974d1 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -34,7 +34,7 @@ typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; -typedef struct GtkStyleRegion GtkStyleRegion; +typedef struct GtkStyleInfo GtkStyleInfo; typedef struct GtkChildClass GtkChildClass; typedef struct PropertyValue PropertyValue; @@ -57,7 +57,7 @@ struct PropertyValue GValue value; }; -struct GtkStyleRegion +struct GtkStyleInfo { GArray *style_classes; GArray *child_style_classes; @@ -79,7 +79,7 @@ struct GtkStyleContextPrivate GArray *property_cache; GtkStateFlags state_flags; - GSList *regions; + GSList *info_stack; GtkThemingEngine *theming_engine; @@ -134,41 +134,41 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } -static GtkStyleRegion * -style_region_new (void) +static GtkStyleInfo * +style_info_new (void) { - GtkStyleRegion *region; + GtkStyleInfo *info; - region = g_slice_new0 (GtkStyleRegion); - region->style_classes = g_array_new (FALSE, FALSE, sizeof (GQuark)); - region->child_style_classes = g_array_new (FALSE, FALSE, sizeof (GtkChildClass)); + info = g_slice_new0 (GtkStyleInfo); + info->style_classes = g_array_new (FALSE, FALSE, sizeof (GQuark)); + info->child_style_classes = g_array_new (FALSE, FALSE, sizeof (GtkChildClass)); - return region; + return info; } static void -style_region_free (GtkStyleRegion *region) +style_info_free (GtkStyleInfo *info) { - g_array_free (region->style_classes, TRUE); - g_array_free (region->child_style_classes, TRUE); - g_slice_free (GtkStyleRegion, region); + g_array_free (info->style_classes, TRUE); + g_array_free (info->child_style_classes, TRUE); + g_slice_free (GtkStyleInfo, info); } -static GtkStyleRegion * -style_region_copy (const GtkStyleRegion *region) +static GtkStyleInfo * +style_info_copy (const GtkStyleInfo *info) { - GtkStyleRegion *copy; + GtkStyleInfo *copy; - copy = style_region_new (); + copy = style_info_new (); g_array_insert_vals (copy->style_classes, 0, - region->style_classes->data, - region->style_classes->len); + info->style_classes->data, + info->style_classes->len); g_array_insert_vals (copy->child_style_classes, 0, - region->child_style_classes->data, - region->child_style_classes->len); + info->child_style_classes->data, + info->child_style_classes->len); - copy->junction_sides = region->junction_sides; + copy->junction_sides = info->junction_sides; return copy; } @@ -177,7 +177,7 @@ static void gtk_style_context_init (GtkStyleContext *style_context) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; priv = style_context->priv = G_TYPE_INSTANCE_GET_PRIVATE (style_context, GTK_TYPE_STYLE_CONTEXT, @@ -188,9 +188,9 @@ gtk_style_context_init (GtkStyleContext *style_context) priv->direction = GTK_TEXT_DIR_RTL; - /* Create default region */ - region = style_region_new (); - priv->regions = g_slist_prepend (priv->regions, region); + /* Create default info store */ + info = style_info_new (); + priv->info_stack = g_slist_prepend (priv->info_stack, info); } static GtkStyleProviderData * @@ -251,8 +251,8 @@ gtk_style_context_finalize (GObject *object) clear_property_cache (GTK_STYLE_CONTEXT (object)); - g_slist_foreach (priv->regions, (GFunc) style_region_free, NULL); - g_slist_free (priv->regions); + g_slist_foreach (priv->info_stack, (GFunc) style_info_free, NULL); + g_slist_free (priv->info_stack); g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free (priv->icon_factories); @@ -627,58 +627,57 @@ void gtk_style_context_save (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); priv = context->priv; - g_assert (priv->regions != NULL); + g_assert (priv->info_stack != NULL); - region = style_region_copy (priv->regions->data); - priv->regions = g_slist_prepend (priv->regions, region); + info = style_info_copy (priv->info_stack->data); + priv->info_stack = g_slist_prepend (priv->info_stack, info); } void gtk_style_context_restore (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); priv = context->priv; - if (priv->regions) + if (priv->info_stack) { - region = priv->regions->data; - priv->regions = g_slist_remove (priv->regions, region); - style_region_free (region); + info = priv->info_stack->data; + priv->info_stack = g_slist_remove (priv->info_stack, info); + style_info_free (info); } - if (!priv->regions) + if (!priv->info_stack) { g_warning ("Unpaired gtk_style_context_restore() call"); /* Create default region */ - region = style_region_new (); - priv->regions = g_slist_prepend (priv->regions, region); + info = style_info_new (); + priv->info_stack = g_slist_prepend (priv->info_stack, info); } if (priv->widget_path) { - GtkStyleRegion *region; guint i; /* Update widget path regions */ gtk_widget_path_iter_clear_regions (priv->widget_path, 0); - region = priv->regions->data; + info = priv->info_stack->data; - for (i = 0; i < region->child_style_classes->len; i++) + for (i = 0; i < info->child_style_classes->len; i++) { GtkChildClass *child_class; - child_class = &g_array_index (region->child_style_classes, GtkChildClass, i); + child_class = &g_array_index (info->child_style_classes, GtkChildClass, i); gtk_widget_path_iter_add_region (priv->widget_path, 0, g_quark_to_string (child_class->class_quark), child_class->flags); @@ -775,7 +774,7 @@ gtk_style_context_set_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; guint position; @@ -785,11 +784,11 @@ gtk_style_context_set_class (GtkStyleContext *context, priv = context->priv; class_quark = g_quark_from_string (class_name); - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (!style_class_find (region->style_classes, class_quark, &position)) - g_array_insert_val (region->style_classes, position, class_quark); + if (!style_class_find (info->style_classes, class_quark, &position)) + g_array_insert_val (info->style_classes, position, class_quark); } void @@ -797,7 +796,7 @@ gtk_style_context_unset_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; guint position; @@ -811,11 +810,11 @@ gtk_style_context_unset_class (GtkStyleContext *context, priv = context->priv; - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (style_class_find (region->style_classes, class_quark, &position)) - g_array_remove_index (region->style_classes, position); + if (style_class_find (info->style_classes, class_quark, &position)) + g_array_remove_index (info->style_classes, position); } gboolean @@ -823,7 +822,7 @@ gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); @@ -836,10 +835,10 @@ gtk_style_context_has_class (GtkStyleContext *context, priv = context->priv; - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (style_class_find (region->style_classes, class_quark, NULL)) + if (style_class_find (info->style_classes, class_quark, NULL)) return TRUE; return FALSE; @@ -849,7 +848,7 @@ GList * gtk_style_context_list_child_classes (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GList *classes = NULL; guint i; @@ -857,15 +856,15 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) priv = context->priv; - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - for (i = 0; i < region->child_style_classes->len; i++) + for (i = 0; i < info->child_style_classes->len; i++) { GtkChildClass *child_class; const gchar *class_name; - child_class = &g_array_index (region->child_style_classes, + child_class = &g_array_index (info->child_style_classes, GtkChildClass, i); @@ -882,7 +881,7 @@ gtk_style_context_set_child_class (GtkStyleContext *context, GtkChildClassFlags flags) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; guint position; @@ -892,17 +891,17 @@ gtk_style_context_set_child_class (GtkStyleContext *context, priv = context->priv; class_quark = g_quark_from_string (class_name); - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (!child_style_class_find (region->child_style_classes, class_quark, &position)) + if (!child_style_class_find (info->child_style_classes, class_quark, &position)) { GtkChildClass child_class; child_class.class_quark = class_quark; child_class.flags = flags; - g_array_insert_val (region->child_style_classes, position, child_class); + g_array_insert_val (info->child_style_classes, position, child_class); if (priv->widget_path) { @@ -917,7 +916,7 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; guint position; @@ -931,12 +930,12 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, priv = context->priv; - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (child_style_class_find (region->child_style_classes, class_quark, &position)) + if (child_style_class_find (info->child_style_classes, class_quark, &position)) { - g_array_remove_index (region->child_style_classes, position); + g_array_remove_index (info->child_style_classes, position); if (priv->widget_path) { @@ -952,7 +951,7 @@ gtk_style_context_has_child_class (GtkStyleContext *context, GtkChildClassFlags *flags_return) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; GQuark class_quark; guint position; @@ -969,16 +968,16 @@ gtk_style_context_has_child_class (GtkStyleContext *context, priv = context->priv; - g_assert (priv->regions != NULL); - region = priv->regions->data; + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; - if (child_style_class_find (region->child_style_classes, class_quark, &position)) + if (child_style_class_find (info->child_style_classes, class_quark, &position)) { if (flags_return) { GtkChildClass *child_class; - child_class = &g_array_index (region->child_style_classes, + child_class = &g_array_index (info->child_style_classes, GtkChildClass, position); *flags_return = child_class->flags; @@ -1264,26 +1263,26 @@ gtk_style_context_set_junction_sides (GtkStyleContext *context, GtkJunctionSides sides) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); priv = context->priv; - region = priv->regions->data; - region->junction_sides = sides; + info = priv->info_stack->data; + info->junction_sides = sides; } GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GtkStyleRegion *region; + GtkStyleInfo *info; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0); priv = context->priv; - region = priv->regions->data; - return region->junction_sides; + info = priv->info_stack->data; + return info->junction_sides; } gboolean From a3637ec60d9281f1b903ae48786184d690b0f055 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 5 Aug 2010 11:08:51 +0200 Subject: [PATCH 259/634] s/child class/region/ everywhere. "Child class" is an invented term anyway, and it conceptually defines identifiable regions in widgets. --- gtk/gtkcssprovider.c | 34 +++++++-------- gtk/gtkenums.h | 14 +++---- gtk/gtknotebook.c | 16 +++---- gtk/gtkstyle.c | 20 ++++----- gtk/gtkstylecontext.c | 94 ++++++++++++++++++++---------------------- gtk/gtkstylecontext.h | 18 ++++---- gtk/gtkthemingengine.c | 8 ++-- gtk/gtkthemingengine.h | 10 ++--- gtk/gtkwidget.c | 6 +-- gtk/gtkwidgetpath.c | 12 +++--- gtk/gtkwidgetpath.h | 8 ++-- 11 files changed, 118 insertions(+), 122 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index ed9ad4539c..2ff92cb6cc 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -63,7 +63,7 @@ struct SelectorElement struct { GQuark name; - GtkChildClassFlags flags; + GtkRegionFlags flags; } region; }; }; @@ -216,9 +216,9 @@ selector_path_prepend_glob (SelectorPath *path) } static void -selector_path_prepend_region (SelectorPath *path, - const gchar *name, - GtkChildClassFlags flags) +selector_path_prepend_region (SelectorPath *path, + const gchar *name, + GtkRegionFlags flags) { SelectorElement *elem; @@ -411,7 +411,7 @@ compare_selector_element (GtkWidgetPath *path, } else if (elem->elem_type == SELECTOR_REGION) { - GtkChildClassFlags flags; + GtkRegionFlags flags; if (!gtk_widget_path_iter_has_qregion (path, index, elem->region.name, @@ -856,10 +856,10 @@ css_provider_commit (GtkCssProvider *css_provider) } static GTokenType -parse_pseudo_class (GtkCssProvider *css_provider, - GScanner *scanner, - SelectorPath *selector, - GtkChildClassFlags *flags) +parse_pseudo_class (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath *selector, + GtkRegionFlags *flags) { ParserSymbol symbol; @@ -889,16 +889,16 @@ parse_pseudo_class (GtkCssProvider *css_provider, switch (symbol) { case SYMBOL_NTH_CHILD_EVEN: - *flags = GTK_CHILD_CLASS_EVEN; + *flags = GTK_REGION_EVEN; break; case SYMBOL_NTH_CHILD_ODD: - *flags = GTK_CHILD_CLASS_ODD; + *flags = GTK_REGION_ODD; break; case SYMBOL_NTH_CHILD_FIRST: - *flags = GTK_CHILD_CLASS_FIRST; + *flags = GTK_REGION_FIRST; break; case SYMBOL_NTH_CHILD_LAST: - *flags = GTK_CHILD_CLASS_LAST; + *flags = GTK_REGION_LAST; break; default: break; @@ -912,9 +912,9 @@ parse_pseudo_class (GtkCssProvider *css_provider, css_provider_pop_scope (css_provider); } else if (symbol == SYMBOL_FIRST_CHILD) - *flags = GTK_CHILD_CLASS_FIRST; + *flags = GTK_REGION_FIRST; else if (symbol == SYMBOL_LAST_CHILD) - *flags = GTK_CHILD_CLASS_LAST; + *flags = GTK_REGION_LAST; else { GtkStateType state; @@ -984,7 +984,7 @@ parse_selector (GtkCssProvider *css_provider, } else if (g_ascii_islower (scanner->value.v_identifier[0])) { - GtkChildClassFlags flags = 0; + GtkRegionFlags flags = 0; gchar *region_name; region_name = g_strdup (scanner->value.v_identifier); @@ -1027,7 +1027,7 @@ parse_selector (GtkCssProvider *css_provider, if (scanner->token == ':' && path->state == GTK_STATE_NORMAL) { - GtkChildClassFlags flags = 0; + GtkRegionFlags flags = 0; GTokenType token; /* Add glob selector if path is empty */ diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 2bdaf7ae4f..a1fc4f49bf 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -571,13 +571,13 @@ typedef enum } GtkStateFlags; typedef enum { - GTK_CHILD_CLASS_EVEN = 1 << 0, - GTK_CHILD_CLASS_ODD = 1 << 1, - GTK_CHILD_CLASS_FIRST = 1 << 2, - GTK_CHILD_CLASS_LAST = 1 << 3, - GTK_CHILD_CLASS_DEFAULT = 1 << 4, - GTK_CHILD_CLASS_SORTED = 1 << 5 -} GtkChildClassFlags; + GTK_REGION_EVEN = 1 << 0, + GTK_REGION_ODD = 1 << 1, + GTK_REGION_FIRST = 1 << 2, + GTK_REGION_LAST = 1 << 3, + GTK_REGION_DEFAULT = 1 << 4, + GTK_REGION_SORTED = 1 << 5 +} GtkRegionFlags; typedef enum { GTK_JUNCTION_NONE = 0, diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index e7559ce49c..0ed23dc79b 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -5041,7 +5041,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, GtkStateType state_type; GtkWidget *widget; GtkStyleContext *context; - GtkChildClassFlags flags = 0; + GtkRegionFlags flags = 0; if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) || !gtk_widget_get_mapped (page->tab_label) || @@ -5056,19 +5056,19 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, else state_type = GTK_STATE_ACTIVE; - if (position % 2 == 0) - flags |= GTK_CHILD_CLASS_ODD; + if ((position + 1) % 2 == 0) + flags |= GTK_REGION_EVEN; else - flags |= GTK_CHILD_CLASS_EVEN; + flags |= GTK_REGION_ODD; if (position == 0) - flags |= GTK_CHILD_CLASS_FIRST; + flags |= GTK_REGION_FIRST; if (is_last) - flags |= GTK_CHILD_CLASS_LAST; + flags |= GTK_REGION_LAST; context = gtk_widget_get_style_context (widget); - gtk_style_context_set_child_class (context, "tab", flags); + gtk_style_context_set_region (context, "tab", flags); gtk_paint_extension (gtk_widget_get_style (widget), cr, state_type, GTK_SHADOW_OUT, @@ -5096,7 +5096,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, allocation.height + 2 * focus_width); } - gtk_style_context_unset_child_class (context, "tab"); + gtk_style_context_unset_region (context, "tab"); } static void diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 2bcf1af5bf..04923cb070 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1763,7 +1763,7 @@ transform_detail_string (const gchar *detail, else if (strcmp (detail, "expander") == 0) gtk_style_context_set_class (context, "expander"); else if (strcmp (detail, "tooltip") == 0) - gtk_style_context_set_child_class (context, "tooltip", 0); + gtk_style_context_set_class (context, "tooltip"); else if (strcmp (detail, "frame") == 0) gtk_style_context_set_class (context, "frame"); else if (strcmp (detail, "scrolled_window") == 0) @@ -1792,7 +1792,7 @@ transform_detail_string (const gchar *detail, } else if (g_str_has_prefix (detail, "cell_")) { - GtkChildClassFlags row, col; + GtkRegionFlags row, col; gboolean ruled = FALSE; GStrv tokens; guint i; @@ -1804,27 +1804,27 @@ transform_detail_string (const gchar *detail, while (tokens[i]) { if (strcmp (tokens[i], "even") == 0) - row |= GTK_CHILD_CLASS_EVEN; + row |= GTK_REGION_EVEN; else if (strcmp (tokens[i], "odd") == 0) - row |= GTK_CHILD_CLASS_ODD; + row |= GTK_REGION_ODD; else if (strcmp (tokens[i], "start") == 0) - col |= GTK_CHILD_CLASS_FIRST; + col |= GTK_REGION_FIRST; else if (strcmp (tokens[i], "end") == 0) - col |= GTK_CHILD_CLASS_LAST; + col |= GTK_REGION_LAST; else if (strcmp (tokens[i], "ruled") == 0) ruled = TRUE; else if (strcmp (tokens[i], "sorted") == 0) - col |= GTK_CHILD_CLASS_SORTED; + col |= GTK_REGION_SORTED; i++; } if (!ruled) - row &= ~(GTK_CHILD_CLASS_EVEN | GTK_CHILD_CLASS_ODD); + row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD); gtk_style_context_set_class (context, "cell"); - gtk_style_context_set_child_class (context, "row", row); - gtk_style_context_set_child_class (context, "column", col); + gtk_style_context_set_region (context, "row", row); + gtk_style_context_set_region (context, "column", col); g_strfreev (tokens); } diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 13b85974d1..cfe7a5e0f7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -35,13 +35,13 @@ typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; typedef struct GtkStyleInfo GtkStyleInfo; -typedef struct GtkChildClass GtkChildClass; +typedef struct GtkRegion GtkRegion; typedef struct PropertyValue PropertyValue; -struct GtkChildClass +struct GtkRegion { GQuark class_quark; - GtkChildClassFlags flags; + GtkRegionFlags flags; }; struct GtkStyleProviderData @@ -60,7 +60,7 @@ struct PropertyValue struct GtkStyleInfo { GArray *style_classes; - GArray *child_style_classes; + GArray *regions; GtkJunctionSides junction_sides; }; @@ -141,7 +141,7 @@ style_info_new (void) info = g_slice_new0 (GtkStyleInfo); info->style_classes = g_array_new (FALSE, FALSE, sizeof (GQuark)); - info->child_style_classes = g_array_new (FALSE, FALSE, sizeof (GtkChildClass)); + info->regions = g_array_new (FALSE, FALSE, sizeof (GtkRegion)); return info; } @@ -150,7 +150,7 @@ static void style_info_free (GtkStyleInfo *info) { g_array_free (info->style_classes, TRUE); - g_array_free (info->child_style_classes, TRUE); + g_array_free (info->regions, TRUE); g_slice_free (GtkStyleInfo, info); } @@ -164,9 +164,9 @@ style_info_copy (const GtkStyleInfo *info) info->style_classes->data, info->style_classes->len); - g_array_insert_vals (copy->child_style_classes, 0, - info->child_style_classes->data, - info->child_style_classes->len); + g_array_insert_vals (copy->regions, 0, + info->regions->data, + info->regions->len); copy->junction_sides = info->junction_sides; @@ -673,14 +673,14 @@ gtk_style_context_restore (GtkStyleContext *context) gtk_widget_path_iter_clear_regions (priv->widget_path, 0); info = priv->info_stack->data; - for (i = 0; i < info->child_style_classes->len; i++) + for (i = 0; i < info->regions->len; i++) { - GtkChildClass *child_class; + GtkRegion *region; - child_class = &g_array_index (info->child_style_classes, GtkChildClass, i); + region = &g_array_index (info->regions, GtkRegion, i); gtk_widget_path_iter_add_region (priv->widget_path, 0, - g_quark_to_string (child_class->class_quark), - child_class->flags); + g_quark_to_string (region->class_quark), + region->flags); } } } @@ -728,9 +728,9 @@ style_class_find (GArray *array, } static gboolean -child_style_class_find (GArray *array, - GQuark class_quark, - guint *position) +region_find (GArray *array, + GQuark class_quark, + guint *position) { gint min, max, mid; gboolean found = FALSE; @@ -746,14 +746,14 @@ child_style_class_find (GArray *array, do { - GtkChildClass *child_class; + GtkRegion *region; mid = min + max / 2; - child_class = &g_array_index (array, GtkChildClass, mid); + region = &g_array_index (array, GtkRegion, mid); - if (child_class->class_quark == class_quark) + if (region->class_quark == class_quark) found = TRUE; - else if (child_class->class_quark > class_quark) + else if (region->class_quark > class_quark) min = mid = mid + 1; else max = mid = mid - 1; @@ -845,7 +845,7 @@ gtk_style_context_has_class (GtkStyleContext *context, } GList * -gtk_style_context_list_child_classes (GtkStyleContext *context) +gtk_style_context_list_regions (GtkStyleContext *context) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; @@ -859,16 +859,14 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - for (i = 0; i < info->child_style_classes->len; i++) + for (i = 0; i < info->regions->len; i++) { - GtkChildClass *child_class; + GtkRegion *region; const gchar *class_name; - child_class = &g_array_index (info->child_style_classes, - GtkChildClass, - i); + region = &g_array_index (info->regions, GtkRegion, i); - class_name = g_quark_to_string (child_class->class_quark); + class_name = g_quark_to_string (region->class_quark); classes = g_list_prepend (classes, (gchar *) class_name); } @@ -876,9 +874,9 @@ gtk_style_context_list_child_classes (GtkStyleContext *context) } void -gtk_style_context_set_child_class (GtkStyleContext *context, - const gchar *class_name, - GtkChildClassFlags flags) +gtk_style_context_set_region (GtkStyleContext *context, + const gchar *class_name, + GtkRegionFlags flags) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; @@ -894,14 +892,14 @@ gtk_style_context_set_child_class (GtkStyleContext *context, g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (!child_style_class_find (info->child_style_classes, class_quark, &position)) + if (!region_find (info->regions, class_quark, &position)) { - GtkChildClass child_class; + GtkRegion region; - child_class.class_quark = class_quark; - child_class.flags = flags; + region.class_quark = class_quark; + region.flags = flags; - g_array_insert_val (info->child_style_classes, position, child_class); + g_array_insert_val (info->regions, position, region); if (priv->widget_path) { @@ -912,8 +910,8 @@ gtk_style_context_set_child_class (GtkStyleContext *context, } void -gtk_style_context_unset_child_class (GtkStyleContext *context, - const gchar *class_name) +gtk_style_context_unset_region (GtkStyleContext *context, + const gchar *class_name) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; @@ -933,9 +931,9 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (child_style_class_find (info->child_style_classes, class_quark, &position)) + if (region_find (info->regions, class_quark, &position)) { - g_array_remove_index (info->child_style_classes, position); + g_array_remove_index (info->regions, position); if (priv->widget_path) { @@ -946,9 +944,9 @@ gtk_style_context_unset_child_class (GtkStyleContext *context, } gboolean -gtk_style_context_has_child_class (GtkStyleContext *context, - const gchar *class_name, - GtkChildClassFlags *flags_return) +gtk_style_context_has_region (GtkStyleContext *context, + const gchar *class_name, + GtkRegionFlags *flags_return) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; @@ -971,16 +969,14 @@ gtk_style_context_has_child_class (GtkStyleContext *context, g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (child_style_class_find (info->child_style_classes, class_quark, &position)) + if (region_find (info->regions, class_quark, &position)) { if (flags_return) { - GtkChildClass *child_class; + GtkRegion *region; - child_class = &g_array_index (info->child_style_classes, - GtkChildClass, position); - - *flags_return = child_class->flags; + region = &g_array_index (info->regions, GtkRegion, position); + *flags_return = region->flags; } return TRUE; } diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 73a3e9fe94..bf0d87261a 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -88,16 +88,16 @@ void gtk_style_context_unset_class (GtkStyleContext *context, gboolean gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name); -GList * gtk_style_context_list_child_classes (GtkStyleContext *context); +GList * gtk_style_context_list_regions (GtkStyleContext *context); -void gtk_style_context_set_child_class (GtkStyleContext *context, - const gchar *class_name, - GtkChildClassFlags flags); -void gtk_style_context_unset_child_class (GtkStyleContext *context, - const gchar *class_name); -gboolean gtk_style_context_has_child_class (GtkStyleContext *context, - const gchar *class_name, - GtkChildClassFlags *flags_return); +void gtk_style_context_set_region (GtkStyleContext *context, + const gchar *region_name, + GtkRegionFlags flags); +void gtk_style_context_unset_region (GtkStyleContext *context, + const gchar *region_name); +gboolean gtk_style_context_has_region (GtkStyleContext *context, + const gchar *region_name, + GtkRegionFlags *flags_return); void gtk_style_context_get_style_property (GtkStyleContext *context, const gchar *property_name, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index fa65ab6458..f90946be84 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -351,9 +351,9 @@ gtk_theming_engine_has_class (GtkThemingEngine *engine, } gboolean -gtk_theming_engine_has_child_class (GtkThemingEngine *engine, - const gchar *style_class, - GtkChildClassFlags *flags) +gtk_theming_engine_has_region (GtkThemingEngine *engine, + const gchar *style_class, + GtkRegionFlags *flags) { GtkThemingEnginePrivate *priv; @@ -363,7 +363,7 @@ gtk_theming_engine_has_child_class (GtkThemingEngine *engine, g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); priv = engine->priv; - return gtk_style_context_has_child_class (priv->context, style_class, flags); + return gtk_style_context_has_region (priv->context, style_class, flags); } GtkTextDirection diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 2e31a292bd..96962067e2 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -167,11 +167,11 @@ void gtk_theming_engine_get_style (GtkThemingEngine *engine, G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); -gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, - const gchar *style_class); -gboolean gtk_theming_engine_has_child_class (GtkThemingEngine *engine, - const gchar *style_class, - GtkChildClassFlags *flags); +gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, + const gchar *style_class); +gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine, + const gchar *style_class, + GtkRegionFlags *flags); GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index af4497b887..e9c4937517 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13233,17 +13233,17 @@ gtk_widget_get_path (GtkWidget *widget) quark_style_context); if (context) - regions = reg = gtk_style_context_list_child_classes (context); + regions = reg = gtk_style_context_list_regions (context); while (reg) { - GtkChildClassFlags flags; + GtkRegionFlags flags; const gchar *region_name; region_name = reg->data; reg = reg->next; - gtk_style_context_has_child_class (context, region_name, &flags); + gtk_style_context_has_region (context, region_name, &flags); gtk_widget_path_iter_add_region (path, 0, region_name, flags); } diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index db9f79b1be..2788fa191a 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -223,10 +223,10 @@ gtk_widget_path_iter_has_name (const GtkWidgetPath *path, } void -gtk_widget_path_iter_add_region (GtkWidgetPath *path, - guint pos, - const gchar *name, - GtkChildClassFlags flags) +gtk_widget_path_iter_add_region (GtkWidgetPath *path, + guint pos, + const gchar *name, + GtkRegionFlags flags) { GtkPathElement *elem; GQuark qname; @@ -318,7 +318,7 @@ gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, guint pos, GQuark qname, - GtkChildClassFlags *flags) + GtkRegionFlags *flags) { GtkPathElement *elem; gpointer value; @@ -347,7 +347,7 @@ gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, guint pos, const gchar *name, - GtkChildClassFlags *flags) + GtkRegionFlags *flags) { GQuark qname; diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index e4c1de1579..7c5059e716 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -59,24 +59,24 @@ gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, const gchar *name, - GtkChildClassFlags flags); + GtkRegionFlags flags); void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, guint pos, const gchar *name); void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, guint pos); -GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, +GSList * gtk_widget_path_iter_list_regions (cosnt GtkWidgetPath *path, guint pos); gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, guint pos, const gchar *name, - GtkChildClassFlags *flags); + GtkRegionFlags *flags); gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, guint pos, GQuark qname, - GtkChildClassFlags *flags); + GtkRegionFlags *flags); GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); From 8a1b6e8224c8c36c96d37adfdf119989ae7ba1cb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 11:59:35 +0200 Subject: [PATCH 260/634] GtkWidgetPath: Add methods to include class info in paths. --- gtk/gtkwidgetpath.c | 180 ++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkwidgetpath.h | 19 ++++- 2 files changed, 198 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 2788fa191a..6fe08f558a 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -31,6 +31,7 @@ struct GtkPathElement GType type; GQuark name; GHashTable *regions; + GArray *classes; }; struct GtkWidgetPath @@ -222,6 +223,185 @@ gtk_widget_path_iter_has_name (const GtkWidgetPath *path, return gtk_widget_path_iter_has_qname (path, pos, qname); } +void +gtk_widget_path_iter_add_class (GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GtkPathElement *elem; + gboolean added = FALSE; + GQuark qname; + guint i; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (name != NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + qname = g_quark_from_string (name); + + if (!elem->classes) + elem->classes = g_array_new (FALSE, FALSE, sizeof (GQuark)); + + for (i = 0; i < elem->classes->len; i++) + { + GQuark quark; + + quark = g_array_index (elem->classes, GQuark, i); + + if (qname == quark) + { + /* Already there */ + added = TRUE; + break; + } + if (qname < quark) + { + g_array_insert_val (elem->classes, i, qname); + added = TRUE; + break; + } + } + + if (!added) + g_array_append_val (elem->classes, qname); +} + +void +gtk_widget_path_iter_remove_class (GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GtkPathElement *elem; + GQuark qname; + guint i; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + g_return_if_fail (name != NULL); + + qname = g_quark_try_string (name); + + if (qname == 0) + return; + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->classes) + return; + + for (i = 0; i < elem->classes->len; i++) + { + GQuark quark; + + quark = g_array_index (elem->classes, GQuark, i); + + if (quark > qname) + break; + else if (quark == qname) + { + g_array_remove_index (elem->classes, i); + break; + } + } +} + +void +gtk_widget_path_iter_clear_classes (GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + + g_return_if_fail (path != NULL); + g_return_if_fail (pos < path->elems->len); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->classes) + return; + + if (elem->classes->len > 0) + g_array_remove_range (elem->classes, 0, elem->classes->len); +} + +GSList * +gtk_widget_path_iter_list_classes (const GtkWidgetPath *path, + guint pos) +{ + GtkPathElement *elem; + GSList *list = NULL; + guint i; + + g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (pos < path->elems->len, NULL); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->classes) + return NULL; + + for (i = 0; i < elem->classes->len; i++) + { + GQuark quark; + + quark = g_array_index (elem->classes, GQuark, i); + list = g_slist_prepend (list, (gchar *) g_quark_to_string (quark)); + } + + return g_slist_reverse (list); +} + +gboolean +gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path, + guint pos, + GQuark qname) +{ + GtkPathElement *elem; + guint i; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + g_return_val_if_fail (qname != 0, FALSE); + + elem = &g_array_index (path->elems, GtkPathElement, pos); + + if (!elem->classes) + return FALSE; + + for (i = 0; i < elem->classes->len; i++) + { + GQuark quark; + + quark = g_array_index (elem->classes, GQuark, i); + + if (quark == qname) + return TRUE; + else if (quark > qname) + break; + } + + return FALSE; +} + +gboolean +gtk_widget_path_iter_has_class (const GtkWidgetPath *path, + guint pos, + const gchar *name) +{ + GQuark qname; + + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (pos < path->elems->len, FALSE); + g_return_val_if_fail (name != NULL, FALSE); + + qname = g_quark_try_string (name); + + if (qname == 0) + return FALSE; + + return gtk_widget_path_iter_has_qclass (path, pos, qname); +} + void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 7c5059e716..234f79b937 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -56,6 +56,23 @@ gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path guint pos, GQuark qname); +void gtk_widget_path_iter_add_class (GtkWidgetPath *path, + guint pos, + const gchar *name); +void gtk_widget_path_iter_remove_class (GtkWidgetPath *path, + guint pos, + const gchar *name); +void gtk_widget_path_iter_clear_classes (GtkWidgetPath *path, + guint pos); +GSList * gtk_widget_path_iter_list_classes (const GtkWidgetPath *path, + guint pos); +gboolean gtk_widget_path_iter_has_class (const GtkWidgetPath *path, + guint pos, + const gchar *name); +gboolean gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path, + guint pos, + GQuark qname); + void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, const gchar *name, @@ -66,7 +83,7 @@ void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, guint pos); -GSList * gtk_widget_path_iter_list_regions (cosnt GtkWidgetPath *path, +GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, guint pos); gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, From 2dabf20cfd1193baec6082ec90c5d723bb010ad4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 12:05:42 +0200 Subject: [PATCH 261/634] GtkStyleContext: Add gtk_style_context_list_classes(). --- gtk/gtkstylecontext.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cfe7a5e0f7..647d09078f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -844,6 +844,32 @@ gtk_style_context_has_class (GtkStyleContext *context, return FALSE; } +GList * +gtk_style_context_list_classes (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GtkStyleInfo *info; + GList *classes = NULL; + guint i; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + + priv = context->priv; + + g_assert (priv->info_stack != NULL); + info = priv->info_stack->data; + + for (i = 0; i < info->style_classes->len; i++) + { + GQuark quark; + + quark = g_array_index (info->style_classes, GQuark, i); + classes = g_list_prepend (classes, (gchar *) g_quark_to_string (quark)); + } + + return classes; +} + GList * gtk_style_context_list_regions (GtkStyleContext *context) { From 27c91622f63b31928066ed269a2df12b0c4975fb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 12:06:29 +0200 Subject: [PATCH 262/634] Set classes info in GtkWidgetPath. --- gtk/gtkstylecontext.c | 35 ++++++++++++++++++++++++++++++++--- gtk/gtkwidget.c | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 647d09078f..f944014ab2 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -669,9 +669,10 @@ gtk_style_context_restore (GtkStyleContext *context) { guint i; + info = priv->info_stack->data; + /* Update widget path regions */ gtk_widget_path_iter_clear_regions (priv->widget_path, 0); - info = priv->info_stack->data; for (i = 0; i < info->regions->len; i++) { @@ -682,6 +683,18 @@ gtk_style_context_restore (GtkStyleContext *context) g_quark_to_string (region->class_quark), region->flags); } + + /* Update widget path classes */ + gtk_widget_path_iter_clear_classes (priv->widget_path, 0); + + for (i = 0; i < info->style_classes->len; i++) + { + GQuark quark; + + quark = g_array_index (info->style_classes, GQuark, i); + gtk_widget_path_iter_add_class (priv->widget_path, 0, + g_quark_to_string (quark)); + } } } @@ -788,7 +801,15 @@ gtk_style_context_set_class (GtkStyleContext *context, info = priv->info_stack->data; if (!style_class_find (info->style_classes, class_quark, &position)) - g_array_insert_val (info->style_classes, position, class_quark); + { + g_array_insert_val (info->style_classes, position, class_quark); + + if (priv->widget_path) + { + gtk_widget_path_iter_add_class (priv->widget_path, 0, class_name); + rebuild_properties (context); + } + } } void @@ -814,7 +835,15 @@ gtk_style_context_unset_class (GtkStyleContext *context, info = priv->info_stack->data; if (style_class_find (info->style_classes, class_quark, &position)) - g_array_remove_index (info->style_classes, position); + { + g_array_remove_index (info->style_classes, position); + + if (priv->widget_path) + { + gtk_widget_path_iter_remove_class (priv->widget_path, 0, class_name); + rebuild_properties (context); + } + } } gboolean diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e9c4937517..6321348ea2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13216,7 +13216,6 @@ gtk_widget_get_path (GtkWidget *widget) GtkStyleContext *context; GtkWidgetPath *path; GtkWidget *parent; - GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); @@ -13224,7 +13223,6 @@ gtk_widget_get_path (GtkWidget *widget) path = gtk_widget_path_new (); gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); - regions = reg = NULL; if (widget->priv->name) gtk_widget_path_iter_set_name (path, 0, widget->priv->name); @@ -13233,22 +13231,40 @@ gtk_widget_get_path (GtkWidget *widget) quark_style_context); if (context) - regions = reg = gtk_style_context_list_regions (context); - - while (reg) { - GtkRegionFlags flags; - const gchar *region_name; + GList *list, *l; - region_name = reg->data; - reg = reg->next; + list = l = gtk_style_context_list_regions (context); - gtk_style_context_has_region (context, region_name, &flags); - gtk_widget_path_iter_add_region (path, 0, region_name, flags); + while (l) + { + GtkRegionFlags flags; + const gchar *region_name; + + region_name = l->data; + l = l->next; + + gtk_style_context_has_region (context, region_name, &flags); + gtk_widget_path_iter_add_region (path, 0, region_name, flags); + } + + g_list_free (list); + + list = l = gtk_style_context_list_classes (context); + + while (l) + { + const gchar *class_name; + + class_name = l->data; + l = l->next; + + gtk_widget_path_iter_add_class (path, 0, class_name); + } + + g_list_free (list); } - g_list_free (regions); - while (parent) { guint position; From 74697d91fe3d5e077fd12ee0c22a6d64585071fd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 12:08:48 +0200 Subject: [PATCH 263/634] GtkCssProvider: Parse and match class info. --- gtk/gtkcssprovider.c | 55 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2ff92cb6cc..06b98d7e0b 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -42,6 +42,7 @@ enum SelectorElementType { SELECTOR_NAME, SELECTOR_GTYPE, SELECTOR_REGION, + SELECTOR_CLASS, SELECTOR_GLOB }; @@ -247,6 +248,21 @@ selector_path_prepend_name (SelectorPath *path, path->elements = g_slist_prepend (path->elements, elem); } +static void +selector_path_prepend_class (SelectorPath *path, + const gchar *name) +{ + SelectorElement *elem; + + elem = g_slice_new (SelectorElement); + elem->combinator = COMBINATOR_DESCENDANT; + elem->elem_type = SELECTOR_CLASS; + + elem->name = g_quark_from_string (name); + + path->elements = g_slist_prepend (path->elements, elem); +} + static void selector_path_prepend_combinator (SelectorPath *path, CombinatorType combinator) @@ -439,6 +455,14 @@ compare_selector_element (GtkWidgetPath *path, *score = 0xF; return TRUE; } + else if (elem->elem_type == SELECTOR_CLASS) + { + if (!gtk_widget_path_iter_has_qclass (path, index, elem->name)) + return FALSE; + + *score = 0xF; + return TRUE; + } return FALSE; } @@ -939,14 +963,21 @@ parse_selector (GtkCssProvider *css_provider, if (scanner->token != ':' && scanner->token != '#' && + scanner->token != '.' && scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; while (scanner->token == '#' || + scanner->token == '.' || scanner->token == G_TOKEN_IDENTIFIER) { - if (scanner->token == '#') + if (scanner->token == '#' || + scanner->token == '.') { + gboolean is_class; + + is_class = (scanner->token == '.'); + g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_IDENTIFIER) @@ -954,19 +985,25 @@ parse_selector (GtkCssProvider *css_provider, selector_path_prepend_glob (path); selector_path_prepend_combinator (path, COMBINATOR_CHILD); - selector_path_prepend_name (path, scanner->value.v_identifier); + + if (is_class) + selector_path_prepend_class (path, scanner->value.v_identifier); + else + selector_path_prepend_name (path, scanner->value.v_identifier); } else if (g_ascii_isupper (scanner->value.v_identifier[0])) { gchar *pos; - pos = strchr (scanner->value.v_identifier, '#'); - - if (pos) + if ((pos = strchr (scanner->value.v_identifier, '#')) != NULL || + (pos = strchr (scanner->value.v_identifier, '.')) != NULL) { gchar *type_name, *name; + gboolean is_class; - /* Widget type and name put together */ + is_class = (*pos == '.'); + + /* Widget type and name/class put together */ name = pos + 1; *pos = '\0'; type_name = scanner->value.v_identifier; @@ -977,7 +1014,11 @@ parse_selector (GtkCssProvider *css_provider, * between widget type and its name. */ selector_path_prepend_combinator (path, COMBINATOR_CHILD); - selector_path_prepend_name (path, name); + + if (is_class) + selector_path_prepend_class (path, name); + else + selector_path_prepend_name (path, name); } else selector_path_prepend_type (path, scanner->value.v_identifier); From bccec3ef0c46d0426c7f7f4cfbe72a3142b1854a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 12:09:09 +0200 Subject: [PATCH 264/634] GtkCssProvider: Use class for tooltips. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 06b98d7e0b..85dcdbbcfe 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1693,7 +1693,7 @@ gtk_css_provider_get_default (void) " background-color: shade(#ffffff, 0.93); \n" "}\n" "\n" - "tooltip {\n" + ".tooltip {\n" " background-color: @tooltip_bg_color; \n" " foreground-color: @tooltip_fg_color; \n" "}\n" From 11ac0cb3e16c159ac0a920cadfe2015784f13ed2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 16 Aug 2010 18:40:03 +0200 Subject: [PATCH 265/634] GtkStyle: set the active flag depending on shadow_type in draw_box(). --- gtk/gtkstyle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 04923cb070..55a2fa7ab9 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -2484,6 +2484,9 @@ gtk_default_draw_box (GtkStyle *style, break; } + if (shadow_type == GTK_SHADOW_IN) + flags |= GTK_STATE_FLAG_ACTIVE; + gtk_style_context_set_state (context, flags); cairo_save (cr); @@ -3012,9 +3015,6 @@ gtk_default_draw_slider (GtkStyle *style, switch (state_type) { - case GTK_STATE_ACTIVE: - flags |= GTK_STATE_FLAG_ACTIVE; - break; case GTK_STATE_PRELIGHT: flags |= GTK_STATE_FLAG_PRELIGHT; break; From 2c7c4d9a513f8ddb80093cf7f2ed52095cc59b06 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 16 Aug 2010 19:08:11 +0200 Subject: [PATCH 266/634] GtkStyleContext: Return insertion position if not found when matching classes/regions --- gtk/gtkstylecontext.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f944014ab2..41b607f34f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -705,6 +705,7 @@ style_class_find (GArray *array, { gint min, max, mid; gboolean found = FALSE; + guint pos; if (position) *position = 0; @@ -719,23 +720,26 @@ style_class_find (GArray *array, { GQuark item; - mid = min + max / 2; + mid = (min + max) / 2; item = g_array_index (array, GQuark, mid); if (class_quark == item) - found = TRUE; + { + found = TRUE; + pos = mid; + } else if (class_quark > item) - min = mid = mid + 1; + min = pos = mid + 1; else - max = mid = mid - 1; + { + max = mid - 1; + pos = mid; + } } while (!found && min <= max); - if (mid < 0) - mid = 0; - if (position) - *position = mid; + *position = pos; return found; } @@ -747,6 +751,7 @@ region_find (GArray *array, { gint min, max, mid; gboolean found = FALSE; + guint pos; if (position) *position = 0; @@ -761,23 +766,26 @@ region_find (GArray *array, { GtkRegion *region; - mid = min + max / 2; + mid = (min + max) / 2; region = &g_array_index (array, GtkRegion, mid); if (region->class_quark == class_quark) - found = TRUE; + { + found = TRUE; + pos = mid; + } else if (region->class_quark > class_quark) - min = mid = mid + 1; + min = pos = mid + 1; else - max = mid = mid - 1; + { + max = mid - 1; + pos = mid; + } } while (!found && min <= max); - if (mid < 0) - mid = 0; - if (position) - *position = mid; + *position = pos; return found; } From 4781f94de258b9a3d6aa244626a30ffbbf529dfd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 16 Aug 2010 19:09:34 +0200 Subject: [PATCH 267/634] Move all theming stack to use GtkStateFlags. This support goes from the theming engines, which are able to retrieve style for different combined states to the CSS provider, where several state pseudo-classes may be specified, such as: GtkButton:active:prelight {} --- gtk/gtkcssprovider.c | 154 ++++++++++++------- gtk/gtkstylecontext.c | 11 +- gtk/gtkstylecontext.h | 6 +- gtk/gtkstyleset.c | 340 +++++++++++++++++++++++++---------------- gtk/gtkstyleset.h | 45 +++--- gtk/gtkthemingengine.c | 141 +++-------------- gtk/gtkthemingengine.h | 6 +- 7 files changed, 356 insertions(+), 347 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 85dcdbbcfe..0ca90fb0b5 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -72,7 +72,7 @@ struct SelectorElement struct SelectorPath { GSList *elements; - GtkStateType state; + GtkStateFlags state; guint ref_count; }; @@ -149,7 +149,6 @@ selector_path_new (void) SelectorPath *path; path = g_slice_new0 (SelectorPath); - path->state = GTK_STATE_NORMAL; path->ref_count = 1; return path; @@ -541,7 +540,7 @@ struct StylePriorityInfo { guint64 score; GHashTable *style; - GtkStateType state; + GtkStateFlags state; }; static GArray * @@ -654,10 +653,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, !gtk_style_set_lookup_property (prop, NULL, NULL)) continue; - if (info->state == GTK_STATE_NORMAL) - gtk_style_set_set_default (set, key, value); - else - gtk_style_set_set_property (set, key, info->state, value); + gtk_style_set_set_property (set, key, info->state, value); } } @@ -880,14 +876,12 @@ css_provider_commit (GtkCssProvider *css_provider) } static GTokenType -parse_pseudo_class (GtkCssProvider *css_provider, - GScanner *scanner, - SelectorPath *selector, - GtkRegionFlags *flags) +parse_nth_child (GtkCssProvider *css_provider, + GScanner *scanner, + GtkRegionFlags *flags) { ParserSymbol symbol; - css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_SYMBOL) @@ -941,13 +935,51 @@ parse_pseudo_class (GtkCssProvider *css_provider, *flags = GTK_REGION_LAST; else { - GtkStateType state; - - state = GPOINTER_TO_INT (scanner->value.v_symbol); - selector->state = state; + *flags = 0; + return G_TOKEN_SYMBOL; + } + + return G_TOKEN_NONE; +} + +static GTokenType +parse_pseudo_class (GtkCssProvider *css_provider, + GScanner *scanner, + SelectorPath *selector) +{ + GtkStateType state; + + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_SYMBOL) + return G_TOKEN_SYMBOL; + + state = GPOINTER_TO_INT (scanner->value.v_symbol); + + switch (state) + { + case GTK_STATE_ACTIVE: + selector->state |= GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + selector->state |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + selector->state |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + selector->state |= GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_INCONSISTENT: + selector->state |= GTK_STATE_FLAG_INCONSISTENT; + break; + case GTK_STATE_FOCUSED: + selector->state |= GTK_STATE_FLAG_FOCUSED; + break; + default: + return G_TOKEN_SYMBOL; } - css_provider_pop_scope (css_provider); return G_TOKEN_NONE; } @@ -1030,18 +1062,39 @@ parse_selector (GtkCssProvider *css_provider, region_name = g_strdup (scanner->value.v_identifier); - /* Parse nth-child type pseudo-class, and - * possibly a state pseudo-class after it. - */ - while (path->state == GTK_STATE_NORMAL && - g_scanner_peek_next_token (scanner) == ':') + if (g_scanner_peek_next_token (scanner) == ':') { - GTokenType token; + ParserSymbol symbol; g_scanner_get_next_token (scanner); + css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); - if ((token = parse_pseudo_class (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) - return token; + /* Check for the next token being nth-child, parse in that + * case, and fallback into common state parsing if not. + */ + if (g_scanner_peek_next_token (scanner) != G_TOKEN_SYMBOL) + return G_TOKEN_SYMBOL; + + symbol = GPOINTER_TO_INT (scanner->next_value.v_symbol); + + if (symbol == SYMBOL_FIRST_CHILD || + symbol == SYMBOL_LAST_CHILD || + symbol == SYMBOL_NTH_CHILD) + { + GTokenType token; + + if ((token = parse_nth_child (css_provider, scanner, &flags)) != G_TOKEN_NONE) + return token; + + css_provider_pop_scope (css_provider); + } + else + { + css_provider_pop_scope (css_provider); + selector_path_prepend_region (path, region_name, 0); + g_free (region_name); + break; + } } selector_path_prepend_region (path, region_name, flags); @@ -1054,10 +1107,6 @@ parse_selector (GtkCssProvider *css_provider, g_scanner_get_next_token (scanner); - /* State is the last element in the selector */ - if (path->state != GTK_STATE_NORMAL) - break; - if (scanner->token == '>') { selector_path_prepend_combinator (path, COMBINATOR_CHILD); @@ -1065,35 +1114,25 @@ parse_selector (GtkCssProvider *css_provider, } } - if (scanner->token == ':' && - path->state == GTK_STATE_NORMAL) + if (scanner->token == ':') { - GtkRegionFlags flags = 0; - GTokenType token; - /* Add glob selector if path is empty */ if (selector_path_depth (path) == 0) selector_path_prepend_glob (path); - if ((token = parse_pseudo_class (css_provider, scanner, path, &flags)) != G_TOKEN_NONE) - return token; + css_provider_push_scope (css_provider, SCOPE_PSEUDO_CLASS); - if (flags != 0) + while (scanner->token == ':') { - /* This means either a standalone :nth-child - * selector, or on a invalid element type. - */ - return G_TOKEN_SYMBOL; + GTokenType token; + + if ((token = parse_pseudo_class (css_provider, scanner, path)) != G_TOKEN_NONE) + return token; + + g_scanner_get_next_token (scanner); } - g_scanner_get_next_token (scanner); - } - else if (scanner->token == G_TOKEN_SYMBOL) - { - /* A new pseudo-class was starting, but the state was already - * parsed, so nothing is supposed to go after that. - */ - return G_TOKEN_LEFT_CURLY; + css_provider_pop_scope (css_provider); } return G_TOKEN_NONE; @@ -1652,20 +1691,14 @@ gtk_css_provider_get_default (void) "@tooltip_bg_color: #eee1b3; \n" "@tooltip_fg_color: #000; \n" "\n" - "*, GtkTreeView > GtkButton {\n" + "*,\n" + "GtkTreeView > GtkButton {\n" " background-color: @bg_color;\n" " foreground-color: @fg_color;\n" " text-color: @text_color; \n" " base-color: @base_color; \n" "}\n" "\n" - "*:active {\n" - " background-color: #c4c2bd;\n" - " foreground-color: #000000;\n" - " text-color: #c4c2bd; \n" - " base-color: #9c9a94; \n" - "}\n" - "\n" "*:prelight {\n" " background-color: #eeebe7;\n" " foreground-color: #000000;\n" @@ -1701,6 +1734,13 @@ gtk_css_provider_get_default (void) "GtkToggleButton:prelight {\n" " text-color: #000; \n" "}\n" + "\n" + ".button:active {\n" + " background-color: #c4c2bd;\n" + " foreground-color: #000000;\n" + " text-color: #c4c2bd; \n" + " base-color: #9c9a94; \n" + "}\n" "\n"; provider = gtk_css_provider_new (); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 41b607f34f..cd3b2c0276 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -343,7 +343,7 @@ rebuild_properties (GtkStyleContext *context) } } - gtk_style_set_get (priv->store, GTK_STATE_NORMAL, + gtk_style_set_get (priv->store, 0, "engine", &priv->theming_engine, NULL); } @@ -488,14 +488,13 @@ gtk_style_context_remove_provider (GtkStyleContext *context, void gtk_style_context_get_property (GtkStyleContext *context, const gchar *property, - GtkStateType state, + GtkStateFlags state, GValue *value) { GtkStyleContextPrivate *priv; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (property != NULL); - g_return_if_fail (state < GTK_STATE_LAST); g_return_if_fail (value != NULL); priv = context->priv; @@ -504,13 +503,12 @@ gtk_style_context_get_property (GtkStyleContext *context, void gtk_style_context_get_valist (GtkStyleContext *context, - GtkStateType state, + GtkStateFlags state, va_list args) { GtkStyleContextPrivate *priv; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - g_return_if_fail (state < GTK_STATE_LAST); priv = context->priv; gtk_style_set_get_valist (priv->store, state, args); @@ -518,14 +516,13 @@ gtk_style_context_get_valist (GtkStyleContext *context, void gtk_style_context_get (GtkStyleContext *context, - GtkStateType state, + GtkStateFlags state, ...) { GtkStyleContextPrivate *priv; va_list args; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - g_return_if_fail (state < GTK_STATE_LAST); priv = context->priv; diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index bf0d87261a..833ca71bee 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -61,13 +61,13 @@ void gtk_style_context_restore (GtkStyleContext *context); void gtk_style_context_get_property (GtkStyleContext *context, const gchar *property, - GtkStateType state, + GtkStateFlags state, GValue *value); void gtk_style_context_get_valist (GtkStyleContext *context, - GtkStateType state, + GtkStateFlags state, va_list args); void gtk_style_context_get (GtkStyleContext *context, - GtkStateType state, + GtkStateFlags state, ...) G_GNUC_NULL_TERMINATED; void gtk_style_context_set_state (GtkStyleContext *context, diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index e8b96cc1cc..7c42f1f7d0 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -33,6 +33,7 @@ typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; typedef struct PropertyData PropertyData; typedef struct PropertyNode PropertyNode; +typedef struct ValueData ValueData; struct PropertyNode { @@ -42,10 +43,15 @@ struct PropertyNode GtkStylePropertyParser parse_func; }; +struct ValueData +{ + GtkStateFlags state; + GValue value; +}; + struct PropertyData { - GValue default_value; - GValue values[GTK_STATE_LAST]; + GArray *values; }; struct GtkStyleSetPrivate @@ -97,6 +103,7 @@ property_data_new (void) PropertyData *data; data = g_slice_new0 (PropertyData); + data->values = g_array_new (FALSE, FALSE, sizeof (ValueData)); return data; } @@ -104,17 +111,138 @@ property_data_new (void) static void property_data_free (PropertyData *data) { - gint i; + guint i; - for (i = 0; i <= GTK_STATE_INSENSITIVE; i++) + for (i = 0; i < data->values->len; i++) { - if (G_IS_VALUE (&data->values[i])) - g_value_unset (&data->values[i]); + ValueData *value_data; + + value_data = &g_array_index (data->values, ValueData, i); + + if (G_IS_VALUE (&value_data->value)) + g_value_unset (&value_data->value); } g_slice_free (PropertyData, data); } +static gboolean +property_data_find_position (PropertyData *data, + GtkStateFlags state, + guint *pos) +{ + gint min, max, mid; + gboolean found = FALSE; + guint position; + + if (pos) + *pos = 0; + + if (data->values->len == 0) + return FALSE; + + /* Find position for the given state, or the position where + * it would be if not found, the array is ordered by the + * state flags. + */ + min = 0; + max = data->values->len - 1; + + do + { + ValueData *value_data; + + mid = (min + max) / 2; + value_data = &g_array_index (data->values, ValueData, mid); + + if (value_data->state == state) + { + found = TRUE; + position = mid; + } + else if (value_data->state < state) + position = min = mid + 1; + else + { + max = mid - 1; + position = mid; + } + } + while (!found && min <= max); + + if (pos) + *pos = position; + + return found; +} + +static GValue * +property_data_get_value (PropertyData *data, + GtkStateFlags state) +{ + ValueData *val_data; + guint pos; + + if (!property_data_find_position (data, state, &pos)) + { + ValueData new = { 0 }; + + //val_data = &g_array_index (data->values, ValueData, pos); + new.state = state; + g_array_insert_val (data->values, pos, new); + } + + val_data = &g_array_index (data->values, ValueData, pos); + + return &val_data->value; +} + +static GValue * +property_data_match_state (PropertyData *data, + GtkStateFlags state) +{ + guint pos; + gint i; + + if (property_data_find_position (data, state, &pos)) + { + ValueData *val_data; + + /* Exact match */ + val_data = &g_array_index (data->values, ValueData, pos); + return &val_data->value; + } + + if (pos >= data->values->len) + pos = data->values->len - 1; + + /* No exact match, go downwards the list to find + * the closest match to the given state flags, as + * a side effect, there is an implicit precedence + * of higher flags over the smaller ones. + */ + for (i = pos; i >= 0; i--) + { + ValueData *val_data; + + val_data = &g_array_index (data->values, ValueData, i); + + /* Check whether any of the requested + * flags are set, and no other flags are. + * + * Also, no flags acts as a wildcard, such + * value should be always in the first position + * in the array (if present) anyways. + */ + if (val_data->state == 0 || + ((val_data->state & state) != 0 && + (val_data->state & ~state) == 0)) + return &val_data->value; + } + + return NULL; +} + static void gtk_style_set_init (GtkStyleSet *set) { @@ -331,12 +459,11 @@ gtk_style_set_lookup_color (GtkStyleSet *set, return g_hash_table_lookup (priv->color_map, name); } -static void -set_property_internal (GtkStyleSet *set, - const gchar *property, - gboolean is_default, - GtkStateType state, - const GValue *value) +void +gtk_style_set_set_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state, + const GValue *value) { GtkStyleSetPrivate *priv; PropertyNode *node; @@ -344,6 +471,10 @@ set_property_internal (GtkStyleSet *set, GType value_type; GValue *val; + g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (property != NULL); + g_return_if_fail (value != NULL); + value_type = G_VALUE_TYPE (value); node = property_node_lookup (g_quark_try_string (property)); @@ -359,7 +490,7 @@ set_property_internal (GtkStyleSet *set, g_return_if_fail (value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); } else - g_return_if_fail (node->property_type == G_VALUE_TYPE (value)); + g_return_if_fail (node->property_type == value_type); priv = set->priv; prop = g_hash_table_lookup (priv->properties, @@ -373,10 +504,7 @@ set_property_internal (GtkStyleSet *set, prop); } - if (is_default) - val = &prop->default_value; - else - val = &prop->values[state]; + val = property_data_get_value (prop, state); if (G_VALUE_TYPE (val) == value_type) g_value_reset (val); @@ -392,41 +520,14 @@ set_property_internal (GtkStyleSet *set, } void -gtk_style_set_set_default (GtkStyleSet *set, - const gchar *property, - const GValue *value) -{ - g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (property != NULL); - g_return_if_fail (value != NULL); - - set_property_internal (set, property, TRUE, GTK_STATE_NORMAL, value); -} - -void -gtk_style_set_set_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state, - const GValue *value) -{ - g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (property != NULL); - g_return_if_fail (state < GTK_STATE_LAST); - g_return_if_fail (value != NULL); - - set_property_internal (set, property, FALSE, state, value); -} - -void -gtk_style_set_set_valist (GtkStyleSet *set, - GtkStateType state, - va_list args) +gtk_style_set_set_valist (GtkStyleSet *set, + GtkStateFlags state, + va_list args) { GtkStyleSetPrivate *priv; const gchar *property_name; g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (state < GTK_STATE_LAST); priv = set->priv; property_name = va_arg (args, const gchar *); @@ -436,6 +537,7 @@ gtk_style_set_set_valist (GtkStyleSet *set, PropertyNode *node; PropertyData *prop; gchar *error = NULL; + GValue *val; node = property_node_lookup (g_quark_try_string (property_name)); @@ -456,14 +558,19 @@ gtk_style_set_set_valist (GtkStyleSet *set, prop); } - g_value_init (&prop->values[state], node->property_type); - G_VALUE_COLLECT (&prop->values[state], args, 0, &error); + val = property_data_get_value (prop, state); + + if (G_IS_VALUE (val)) + g_value_unset (val); + + g_value_init (val, node->property_type); + G_VALUE_COLLECT (val, args, 0, &error); if (error) { g_warning ("Could not set style property \"%s\": %s", property_name, error); - g_value_unset (&prop->values[state]); - g_free (error); + g_value_unset (val); + g_free (error); break; } @@ -472,14 +579,13 @@ gtk_style_set_set_valist (GtkStyleSet *set, } void -gtk_style_set_set (GtkStyleSet *set, - GtkStateType state, +gtk_style_set_set (GtkStyleSet *set, + GtkStateFlags state, ...) { va_list args; g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (state < GTK_STATE_LAST); va_start (args, state); gtk_style_set_set_valist (set, state, args); @@ -505,10 +611,10 @@ resolve_color (GtkStyleSet *set, } gboolean -gtk_style_set_get_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state, - GValue *value) +gtk_style_set_get_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state, + GValue *value) { GtkStyleSetPrivate *priv; PropertyNode *node; @@ -517,7 +623,6 @@ gtk_style_set_get_property (GtkStyleSet *set, g_return_val_if_fail (GTK_IS_STYLE_SET (set), FALSE); g_return_val_if_fail (property != NULL, FALSE); - g_return_val_if_fail (state < GTK_STATE_LAST, FALSE); g_return_val_if_fail (value != NULL, FALSE); node = property_node_lookup (g_quark_try_string (property)); @@ -537,11 +642,9 @@ gtk_style_set_get_property (GtkStyleSet *set, g_value_init (value, node->property_type); - if (G_IS_VALUE (&prop->values[state])) - val = &prop->values[state]; - else if (G_IS_VALUE (&prop->default_value)) - val = &prop->default_value; - else + val = property_data_match_state (prop, state); + + if (!val && G_IS_VALUE (&node->default_value)) val = &node->default_value; g_return_val_if_fail (G_IS_VALUE (val), FALSE); @@ -560,15 +663,14 @@ gtk_style_set_get_property (GtkStyleSet *set, } void -gtk_style_set_get_valist (GtkStyleSet *set, - GtkStateType state, - va_list args) +gtk_style_set_get_valist (GtkStyleSet *set, + GtkStateFlags state, + va_list args) { GtkStyleSetPrivate *priv; const gchar *property_name; g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (state < GTK_STATE_LAST); priv = set->priv; property_name = va_arg (args, const gchar *); @@ -604,14 +706,9 @@ gtk_style_set_get_valist (GtkStyleSet *set, GValue *val = NULL; if (prop) - { - if (G_IS_VALUE (&prop->values[state])) - val = &prop->values[state]; - else if (G_IS_VALUE (&prop->default_value)) - val = &prop->default_value; - } + val = property_data_match_state (prop, state); - if (!val) + if (!val && G_IS_VALUE (&node->default_value)) val = &node->default_value; if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) @@ -637,14 +734,13 @@ gtk_style_set_get_valist (GtkStyleSet *set, } void -gtk_style_set_get (GtkStyleSet *set, - GtkStateType state, +gtk_style_set_get (GtkStyleSet *set, + GtkStateFlags state, ...) { va_list args; g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (state < GTK_STATE_LAST); va_start (args, state); gtk_style_set_get_valist (set, state, args); @@ -652,17 +748,17 @@ gtk_style_set_get (GtkStyleSet *set, } void -gtk_style_set_unset_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state) +gtk_style_set_unset_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state) { GtkStyleSetPrivate *priv; PropertyNode *node; PropertyData *prop; + guint pos; g_return_if_fail (GTK_IS_STYLE_SET (set)); g_return_if_fail (property != NULL); - g_return_if_fail (state < GTK_STATE_LAST); node = property_node_lookup (g_quark_try_string (property)); @@ -679,7 +775,17 @@ gtk_style_set_unset_property (GtkStyleSet *set, if (!prop) return; - g_value_unset (&prop->values[state]); + if (property_data_find_position (prop, state, &pos)) + { + ValueData *data; + + data = &g_array_index (prop->values, ValueData, pos); + + if (G_IS_VALUE (&data->value)) + g_value_unset (&data->value); + + g_array_remove_index (prop->values, pos); + } } void @@ -735,61 +841,37 @@ gtk_style_set_merge (GtkStyleSet *set, while (g_hash_table_iter_next (&iter, &key, &value)) { PropertyData *prop_to_merge = value; - PropertyData *prop = NULL; - GtkStateType i; + PropertyData *prop; + guint i; - for (i = GTK_STATE_NORMAL; i < GTK_STATE_LAST; i++) + prop = g_hash_table_lookup (priv->properties, key); + + if (!prop) { - if (G_VALUE_TYPE (&prop_to_merge->values[i]) == G_TYPE_INVALID) - continue; - - if (!prop) - prop = g_hash_table_lookup (priv->properties, key); - - if (!prop) - { - prop = property_data_new (); - g_hash_table_insert (priv->properties, key, prop); - } - - if (replace || - G_VALUE_TYPE (&prop->values[i]) == G_TYPE_INVALID) - { - if (!G_IS_VALUE (&prop->values[i])) - g_value_init (&prop->values[i], G_VALUE_TYPE (&prop_to_merge->values[i])); - else if (G_VALUE_TYPE (&prop->values[i]) != G_VALUE_TYPE (&prop_to_merge->values[i])) - { - g_value_unset (&prop->values[i]); - g_value_init (&prop->values[i], G_VALUE_TYPE (&prop_to_merge->values[i])); - } - - g_value_copy (&prop_to_merge->values[i], - &prop->values[i]); - } + prop = property_data_new (); + g_hash_table_insert (priv->properties, key, prop); } - if (G_IS_VALUE (&prop_to_merge->default_value) && - (replace || !prop || !G_IS_VALUE (&prop->default_value))) + for (i = 0; i < prop_to_merge->values->len; i++) { - if (!prop) - prop = g_hash_table_lookup (priv->properties, key); + ValueData *data; + GValue *value; - if (!prop) + data = &g_array_index (prop_to_merge->values, ValueData, i); + value = property_data_get_value (prop, data->state); + + if (replace || !G_IS_VALUE (value)) { - prop = property_data_new (); - g_hash_table_insert (priv->properties, key, prop); - } + if (!G_IS_VALUE (value)) + g_value_init (value, G_VALUE_TYPE (&data->value)); + else if (G_VALUE_TYPE (value) != G_VALUE_TYPE (&data->value)) + { + g_value_unset (value); + g_value_init (value, G_VALUE_TYPE (&data->value)); + } - if (!G_IS_VALUE (&prop->default_value)) - g_value_init (&prop->default_value, G_VALUE_TYPE (&prop_to_merge->default_value)); - else if (G_VALUE_TYPE (&prop->default_value) != G_VALUE_TYPE (&prop_to_merge->default_value)) - { - g_value_unset (&prop->default_value); - g_value_init (&prop->default_value, G_VALUE_TYPE (&prop_to_merge->default_value)); + g_value_copy (&data->value, value); } - - g_value_copy (&prop_to_merge->default_value, - &prop->default_value); } } } diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index cf46a2fab5..8b8750c588 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -71,34 +71,31 @@ void gtk_style_set_map_color (GtkStyleSet *set, GtkSymbolicColor * gtk_style_set_lookup_color (GtkStyleSet *set, const gchar *name); -void gtk_style_set_set_default (GtkStyleSet *set, - const gchar *property, - const GValue *value); -void gtk_style_set_set_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state, - const GValue *value); -void gtk_style_set_set_valist (GtkStyleSet *set, - GtkStateType state, - va_list args); -void gtk_style_set_set (GtkStyleSet *set, - GtkStateType state, +void gtk_style_set_set_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state, + const GValue *value); +void gtk_style_set_set_valist (GtkStyleSet *set, + GtkStateFlags state, + va_list args); +void gtk_style_set_set (GtkStyleSet *set, + GtkStateFlags state, ...) G_GNUC_NULL_TERMINATED; -gboolean gtk_style_set_get_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state, - GValue *value); -void gtk_style_set_get_valist (GtkStyleSet *set, - GtkStateType state, - va_list args); -void gtk_style_set_get (GtkStyleSet *set, - GtkStateType state, +gboolean gtk_style_set_get_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state, + GValue *value); +void gtk_style_set_get_valist (GtkStyleSet *set, + GtkStateFlags state, + va_list args); +void gtk_style_set_get (GtkStyleSet *set, + GtkStateFlags state, ...) G_GNUC_NULL_TERMINATED; -void gtk_style_set_unset_property (GtkStyleSet *set, - const gchar *property, - GtkStateType state); +void gtk_style_set_unset_property (GtkStyleSet *set, + const gchar *property, + GtkStateFlags state); void gtk_style_set_clear (GtkStyleSet *set); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f90946be84..a7a740b612 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -216,14 +216,13 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, - GtkStateType state, + GtkStateFlags state, GValue *value) { GtkThemingEnginePrivate *priv; g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); g_return_if_fail (property != NULL); - g_return_if_fail (state < GTK_STATE_LAST); g_return_if_fail (value != NULL); priv = engine->priv; @@ -232,13 +231,12 @@ gtk_theming_engine_get_property (GtkThemingEngine *engine, void gtk_theming_engine_get_valist (GtkThemingEngine *engine, - GtkStateType state, + GtkStateFlags state, va_list args) { GtkThemingEnginePrivate *priv; g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); - g_return_if_fail (state < GTK_STATE_LAST); priv = engine->priv; gtk_style_context_get_valist (priv->context, state, args); @@ -246,14 +244,13 @@ gtk_theming_engine_get_valist (GtkThemingEngine *engine, void gtk_theming_engine_get (GtkThemingEngine *engine, - GtkStateType state, + GtkStateFlags state, ...) { GtkThemingEnginePrivate *priv; va_list args; g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); - g_return_if_fail (state < GTK_STATE_LAST); priv = engine->priv; @@ -509,19 +506,13 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, GdkColor *fg_color, *base_color, *text_color; const GtkWidgetPath *path; GtkStateFlags flags; - GtkStateType state; gint exterior_size, interior_size, thickness, pad; flags = gtk_theming_engine_get_state (engine); path = gtk_theming_engine_get_path (engine); cairo_save (cr); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, "base-color", &base_color, "text-color", &text_color, @@ -625,7 +616,6 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, GtkStateFlags flags; GdkColor *base_color, *fg_color, *text_color; const GtkWidgetPath *path; - GtkStateType state; gint exterior_size, interior_size, pad, thickness; gdouble radius; @@ -637,12 +627,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_save (cr); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, "base-color", &base_color, "text-color", &text_color, @@ -758,21 +743,13 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, gdouble size) { GtkStateFlags flags; - GtkStateType state; GdkColor *fg_color; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, NULL); @@ -900,29 +877,17 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GtkStateType state; GdkColor *color; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_ACTIVE) - state = GTK_STATE_ACTIVE; - else if (flags & GTK_STATE_FLAG_SELECTED) - state = GTK_STATE_SELECTED; - else if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - if (gtk_theming_engine_has_class (engine, "entry")) - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "base-color", &color, NULL); else - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &color, NULL); @@ -958,23 +923,15 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GtkStateType state; GdkColor lighter, darker; GdkColor *bg_color; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - cairo_set_line_width (cr, 1); - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &bg_color, NULL); color_shade (bg_color, 0.7, &darker); @@ -1125,7 +1082,6 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, { GtkStateFlags flags; GdkColor *bg_color, *fg_color, *base_color; - GtkStateType state; double vertical_overshoot; int diameter; double radius; @@ -1139,14 +1095,7 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, "background-color", &bg_color, "base-color", &base_color, @@ -1241,7 +1190,6 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GtkStateType state; GdkColor *color; gint line_width; gint8 *dash_list; @@ -1249,14 +1197,7 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &color, NULL); @@ -1320,7 +1261,6 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, { GdkColor *bg_color, darker, lighter; GtkStateFlags flags; - GtkStateType state; gint i, thickness, thickness_dark, thickness_light, len; cairo_matrix_t matrix; gdouble angle; @@ -1333,14 +1273,7 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, flags = gtk_theming_engine_get_state (engine); cairo_save (cr); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &bg_color, NULL); color_shade (bg_color, 0.7, &darker); @@ -1535,7 +1468,6 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, { GdkColor *fg_color; GtkStateFlags flags; - GtkStateType state; GdkScreen *screen; cairo_save (cr); @@ -1543,24 +1475,13 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, /* FIXME: Set clipping */ - if (flags & GTK_STATE_FLAG_ACTIVE) - state = GTK_STATE_ACTIVE; - else if (flags & GTK_STATE_FLAG_SELECTED) - state = GTK_STATE_SELECTED; - else if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, NULL); screen = gtk_theming_engine_get_screen (engine); - if (state == GTK_STATE_INSENSITIVE) + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INSENSITIVE)) { PangoLayout *insensitive_layout; @@ -1629,7 +1550,6 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, gdouble xy1_gap) { GtkStateFlags flags; - GtkStateType state; GdkColor *bg_color; GdkColor lighter, darker; guint sides; @@ -1637,16 +1557,9 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - cairo_set_line_width (cr, 1); - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &bg_color, NULL); color_shade (bg_color, 0.7, &darker); @@ -1786,25 +1699,15 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, GtkPositionType gap_side) { GtkStateFlags flags; - GtkStateType state; GdkColor *bg_color; GdkColor lighter, darker; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_ACTIVE) - state = GTK_STATE_ACTIVE; - else if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - cairo_set_line_width (cr, 1); - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &bg_color, NULL); color_shade (bg_color, 0.7, &darker); @@ -1956,7 +1859,6 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, GtkOrientation orientation) { GtkStateFlags flags; - GtkStateType state; GdkColor *bg_color; GdkColor lighter, darker; gint xx, yy; @@ -1964,18 +1866,9 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - if (flags & GTK_STATE_FLAG_ACTIVE) - state = GTK_STATE_ACTIVE; - else if (flags & GTK_STATE_FLAG_PRELIGHT) - state = GTK_STATE_PRELIGHT; - else if (flags & GTK_STATE_FLAG_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - cairo_set_line_width (cr, 1); - gtk_theming_engine_get (engine, state, + gtk_theming_engine_get (engine, flags, "background-color", &bg_color, NULL); color_shade (bg_color, 0.7, &darker); diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 96962067e2..326fc63db4 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -147,13 +147,13 @@ void gtk_theming_engine_register_property (GtkThemingEngine *engine, void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, - GtkStateType state, + GtkStateFlags state, GValue *value); void gtk_theming_engine_get_valist (GtkThemingEngine *engine, - GtkStateType state, + GtkStateFlags state, va_list args); void gtk_theming_engine_get (GtkThemingEngine *engine, - GtkStateType state, + GtkStateFlags state, ...) G_GNUC_NULL_TERMINATED; void gtk_theming_engine_get_style_property (GtkThemingEngine *engine, From 2e2c07b695dfeeccd75b1bf5181bc45b2ba489ec Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 21:40:41 +0200 Subject: [PATCH 268/634] Add GtkTimeline as a private object. This will only be used internally by GtkStyleContext in order to animate state changes. When a proper animation framework is introduced in GTK+, it may be ditched. --- gtk/Makefile.am | 2 + gtk/gtktimeline.c | 738 ++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtktimeline.h | 117 ++++++++ 3 files changed, 857 insertions(+) create mode 100644 gtk/gtktimeline.c create mode 100644 gtk/gtktimeline.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 0d4de0636f..dd8a8b37ce 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -418,6 +418,7 @@ gtk_private_h_sources = \ gtktexttagprivate.h \ gtktexttypes.h \ gtktextutil.h \ + gtktimeline.h \ gtkthemes.h \ gtktoolpaletteprivate.h \ gtktreedatalist.h \ @@ -621,6 +622,7 @@ gtk_base_c_sources = \ gtktextview.c \ gtkthemes.c \ gtkthemingengine.c \ + gtktimeline.c \ gtktoggleaction.c \ gtktogglebutton.c \ gtktoggletoolbutton.c \ diff --git a/gtk/gtktimeline.c b/gtk/gtktimeline.c new file mode 100644 index 0000000000..b4c034d700 --- /dev/null +++ b/gtk/gtktimeline.c @@ -0,0 +1,738 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2007 Carlos Garnacho + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 +#include +#include +#include + +#define MSECS_PER_SEC 1000 +#define FRAME_INTERVAL(nframes) (MSECS_PER_SEC / nframes) +#define DEFAULT_FPS 30 + +typedef struct GtkTimelinePriv GtkTimelinePriv; + +struct GtkTimelinePriv +{ + guint duration; + guint fps; + guint source_id; + + GTimer *timer; + + gdouble progress; + gdouble last_progress; + + GdkScreen *screen; + + GtkTimelineProgressType progress_type; + + guint animations_enabled : 1; + guint loop : 1; + guint direction : 1; +}; + +enum { + PROP_0, + PROP_FPS, + PROP_DURATION, + PROP_LOOP, + PROP_DIRECTION, + PROP_SCREEN +}; + +enum { + STARTED, + PAUSED, + FINISHED, + FRAME, + LAST_SIGNAL +}; + +static guint signals [LAST_SIGNAL] = { 0, }; + + +static void gtk_timeline_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_timeline_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void gtk_timeline_finalize (GObject *object); + + +G_DEFINE_TYPE (GtkTimeline, gtk_timeline, G_TYPE_OBJECT) + + +static void +gtk_timeline_class_init (GtkTimelineClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = gtk_timeline_set_property; + object_class->get_property = gtk_timeline_get_property; + object_class->finalize = gtk_timeline_finalize; + + g_object_class_install_property (object_class, + PROP_FPS, + g_param_spec_uint ("fps", + "FPS", + "Frames per second for the timeline", + 1, G_MAXUINT, + DEFAULT_FPS, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_DURATION, + g_param_spec_uint ("duration", + "Animation Duration", + "Animation Duration", + 0, G_MAXUINT, + 0, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_LOOP, + g_param_spec_boolean ("loop", + "Loop", + "Whether the timeline loops or not", + FALSE, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_SCREEN, + g_param_spec_object ("screen", + "Screen", + "Screen to get the settings from", + GDK_TYPE_SCREEN, + G_PARAM_READWRITE)); + + signals[STARTED] = + g_signal_new ("started", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTimelineClass, started), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[PAUSED] = + g_signal_new ("paused", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTimelineClass, paused), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[FINISHED] = + g_signal_new ("finished", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTimelineClass, finished), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[FRAME] = + g_signal_new ("frame", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTimelineClass, frame), + NULL, NULL, + g_cclosure_marshal_VOID__DOUBLE, + G_TYPE_NONE, 1, + G_TYPE_DOUBLE); + + g_type_class_add_private (klass, sizeof (GtkTimelinePriv)); +} + +static void +gtk_timeline_init (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + priv = timeline->priv = G_TYPE_INSTANCE_GET_PRIVATE (timeline, + GTK_TYPE_TIMELINE, + GtkTimelinePriv); + + priv->fps = DEFAULT_FPS; + priv->duration = 0.0; + priv->direction = GTK_TIMELINE_DIRECTION_FORWARD; + priv->screen = gdk_screen_get_default (); + + priv->last_progress = 0; +} + +static void +gtk_timeline_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkTimeline *timeline; + GtkTimelinePriv *priv; + + timeline = GTK_TIMELINE (object); + priv = timeline->priv; + + switch (prop_id) + { + case PROP_FPS: + gtk_timeline_set_fps (timeline, g_value_get_uint (value)); + break; + case PROP_DURATION: + gtk_timeline_set_duration (timeline, g_value_get_uint (value)); + break; + case PROP_LOOP: + gtk_timeline_set_loop (timeline, g_value_get_boolean (value)); + break; + case PROP_DIRECTION: + gtk_timeline_set_direction (timeline, g_value_get_enum (value)); + break; + case PROP_SCREEN: + gtk_timeline_set_screen (timeline, + GDK_SCREEN (g_value_get_object (value))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtk_timeline_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkTimeline *timeline; + GtkTimelinePriv *priv; + + timeline = GTK_TIMELINE (object); + priv = timeline->priv; + + switch (prop_id) + { + case PROP_FPS: + g_value_set_uint (value, priv->fps); + break; + case PROP_DURATION: + g_value_set_uint (value, priv->duration); + break; + case PROP_LOOP: + g_value_set_boolean (value, priv->loop); + break; + case PROP_DIRECTION: + g_value_set_enum (value, priv->direction); + break; + case PROP_SCREEN: + g_value_set_object (value, priv->screen); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gtk_timeline_finalize (GObject *object) +{ + GtkTimelinePriv *priv; + GtkTimeline *timeline; + + timeline = (GtkTimeline *) object; + priv = timeline->priv; + + if (priv->source_id) + { + g_source_remove (priv->source_id); + priv->source_id = 0; + } + + if (priv->timer) + g_timer_destroy (priv->timer); + + G_OBJECT_CLASS (gtk_timeline_parent_class)->finalize (object); +} + +gdouble +calculate_progress (gdouble linear_progress, + GtkTimelineProgressType progress_type) +{ + gdouble progress; + + progress = linear_progress; + + switch (progress_type) + { + case GTK_TIMELINE_PROGRESS_LINEAR: + break; + case GTK_TIMELINE_PROGRESS_EASE_IN_OUT: + progress *= 2; + + if (progress < 1) + progress = pow (progress, 3) / 2; + else + progress = (pow (progress - 2, 3) + 2) / 2; + + break; + case GTK_TIMELINE_PROGRESS_EASE: + progress = (sinf ((progress - 0.5) * G_PI) + 1) / 2; + break; + case GTK_TIMELINE_PROGRESS_EASE_IN: + progress = pow (progress, 3); + break; + case GTK_TIMELINE_PROGRESS_EASE_OUT: + progress = pow (progress - 1, 3) + 1; + break; + default: + g_warning ("Timeline progress type not implemented"); + } + + return progress; +} + +static gboolean +gtk_timeline_run_frame (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + gdouble delta_progress, progress; + guint elapsed_time; + + priv = timeline->priv; + + elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000); + g_timer_start (priv->timer); + + if (priv->animations_enabled) + { + delta_progress = (gdouble) elapsed_time / priv->duration; + progress = priv->last_progress; + + if (priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD) + progress -= delta_progress; + else + progress += delta_progress; + + priv->last_progress = progress; + + progress = CLAMP (progress, 0., 1.); + } + else + progress = (priv->direction == GTK_TIMELINE_DIRECTION_FORWARD) ? 1.0 : 0.0; + + priv->progress = progress; + g_signal_emit (timeline, signals [FRAME], 0, + calculate_progress (progress, priv->progress_type)); + + if ((priv->direction == GTK_TIMELINE_DIRECTION_FORWARD && progress == 1.0) || + (priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD && progress == 0.0)) + { + if (!priv->loop) + { + if (priv->source_id) + { + g_source_remove (priv->source_id); + priv->source_id = 0; + } + g_timer_stop (priv->timer); + g_signal_emit (timeline, signals [FINISHED], 0); + return FALSE; + } + else + gtk_timeline_rewind (timeline); + } + + return TRUE; +} + +/** + * gtk_timeline_new: + * @duration: duration in milliseconds for the timeline + * + * Creates a new #GtkTimeline with the specified number of frames. + * + * Return Value: the newly created #GtkTimeline + **/ +GtkTimeline * +gtk_timeline_new (guint duration) +{ + return g_object_new (GTK_TYPE_TIMELINE, + "duration", duration, + NULL); +} + +GtkTimeline * +gtk_timeline_new_for_screen (guint duration, + GdkScreen *screen) +{ + return g_object_new (GTK_TYPE_TIMELINE, + "duration", duration, + "screen", screen, + NULL); +} + +/** + * gtk_timeline_start: + * @timeline: A #GtkTimeline + * + * Runs the timeline from the current frame. + **/ +void +gtk_timeline_start (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + GtkSettings *settings; + gboolean enable_animations = FALSE; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + + if (!priv->source_id) + { + if (priv->timer) + g_timer_continue (priv->timer); + else + priv->timer = g_timer_new (); + + /* sanity check */ + g_assert (priv->fps > 0); + + if (priv->screen) + { + settings = gtk_settings_get_for_screen (priv->screen); + g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL); + } + + priv->animations_enabled = (enable_animations == TRUE); + + g_signal_emit (timeline, signals [STARTED], 0); + + if (enable_animations) + priv->source_id = gdk_threads_add_timeout (FRAME_INTERVAL (priv->fps), + (GSourceFunc) gtk_timeline_run_frame, + timeline); + else + priv->source_id = gdk_threads_add_idle ((GSourceFunc) gtk_timeline_run_frame, + timeline); + } +} + +/** + * gtk_timeline_pause: + * @timeline: A #GtkTimeline + * + * Pauses the timeline. + **/ +void +gtk_timeline_pause (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + + if (priv->source_id) + { + g_timer_stop (priv->timer); + g_source_remove (priv->source_id); + priv->source_id = 0; + g_signal_emit (timeline, signals [PAUSED], 0); + } +} + +/** + * gtk_timeline_rewind: + * @timeline: A #GtkTimeline + * + * Rewinds the timeline. + **/ +void +gtk_timeline_rewind (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + + if (gtk_timeline_get_direction(timeline) != GTK_TIMELINE_DIRECTION_FORWARD) + priv->progress = priv->last_progress = 1.; + else + priv->progress = priv->last_progress = 0.; + + /* reset timer */ + if (priv->timer) + { + g_timer_start (priv->timer); + + if (!priv->source_id) + g_timer_stop (priv->timer); + } +} + +/** + * gtk_timeline_is_running: + * @timeline: A #GtkTimeline + * + * Returns whether the timeline is running or not. + * + * Return Value: %TRUE if the timeline is running + **/ +gboolean +gtk_timeline_is_running (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), FALSE); + + priv = timeline->priv; + + return (priv->source_id != 0); +} + +/** + * gtk_timeline_get_fps: + * @timeline: A #GtkTimeline + * + * Returns the number of frames per second. + * + * Return Value: frames per second + **/ +guint +gtk_timeline_get_fps (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 1); + + priv = timeline->priv; + return priv->fps; +} + +/** + * gtk_timeline_set_fps: + * @timeline: A #GtkTimeline + * @fps: frames per second + * + * Sets the number of frames per second that + * the timeline will play. + **/ +void +gtk_timeline_set_fps (GtkTimeline *timeline, + guint fps) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + g_return_if_fail (fps > 0); + + priv = timeline->priv; + + priv->fps = fps; + + if (gtk_timeline_is_running (timeline)) + { + g_source_remove (priv->source_id); + priv->source_id = gdk_threads_add_timeout (FRAME_INTERVAL (priv->fps), + (GSourceFunc) gtk_timeline_run_frame, + timeline); + } + + g_object_notify (G_OBJECT (timeline), "fps"); +} + +/** + * gtk_timeline_get_loop: + * @timeline: A #GtkTimeline + * + * Returns whether the timeline loops to the + * beginning when it has reached the end. + * + * Return Value: %TRUE if the timeline loops + **/ +gboolean +gtk_timeline_get_loop (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), FALSE); + + priv = timeline->priv; + return priv->loop; +} + +/** + * gtk_timeline_set_loop: + * @timeline: A #GtkTimeline + * @loop: %TRUE to make the timeline loop + * + * Sets whether the timeline loops to the beginning + * when it has reached the end. + **/ +void +gtk_timeline_set_loop (GtkTimeline *timeline, + gboolean loop) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + + if (loop != priv->loop) + { + priv->loop = loop; + g_object_notify (G_OBJECT (timeline), "loop"); + } +} + +void +gtk_timeline_set_duration (GtkTimeline *timeline, + guint duration) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + + if (duration != priv->duration) + { + priv->duration = duration; + g_object_notify (G_OBJECT (timeline), "duration"); + } +} + +guint +gtk_timeline_get_duration (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0); + + priv = timeline->priv; + + return priv->duration; +} + +/** + * gtk_timeline_set_direction: + * @timeline: A #GtkTimeline + * @direction: direction + * + * Sets the direction of the timeline. + **/ +void +gtk_timeline_set_direction (GtkTimeline *timeline, + GtkTimelineDirection direction) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + priv->direction = direction; +} + +/** + * gtk_timeline_get_direction: + * @timeline: A #GtkTimeline + * + * Returns the direction of the timeline. + * + * Return Value: direction + **/ +GtkTimelineDirection +gtk_timeline_get_direction (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), GTK_TIMELINE_DIRECTION_FORWARD); + + priv = timeline->priv; + return priv->direction; +} + +void +gtk_timeline_set_screen (GtkTimeline *timeline, + GdkScreen *screen) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + g_return_if_fail (GDK_IS_SCREEN (screen)); + + priv = timeline->priv; + + if (priv->screen) + g_object_unref (priv->screen); + + priv->screen = g_object_ref (screen); + + g_object_notify (G_OBJECT (timeline), "screen"); +} + +GdkScreen * +gtk_timeline_get_screen (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), NULL); + + priv = timeline->priv; + return priv->screen; +} + +gdouble +gtk_timeline_get_progress (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0.); + + priv = timeline->priv; + return calculate_progress (priv->progress, priv->progress_type); +} + +GtkTimelineProgressType +gtk_timeline_get_progress_type (GtkTimeline *timeline) +{ + GtkTimelinePriv *priv; + + g_return_val_if_fail (GTK_IS_TIMELINE (timeline), GTK_TIMELINE_PROGRESS_LINEAR); + + priv = timeline->priv; + return priv->progress_type; +} + +void +gtk_timeline_set_progress_type (GtkTimeline *timeline, + GtkTimelineProgressType progress_type) +{ + GtkTimelinePriv *priv; + + g_return_if_fail (GTK_IS_TIMELINE (timeline)); + + priv = timeline->priv; + priv->progress_type = progress_type; +} + +#define __GTK_TIMELINE_C__ +#include "gtkaliasdef.c" diff --git a/gtk/gtktimeline.h b/gtk/gtktimeline.h new file mode 100644 index 0000000000..d9a6ae5d2c --- /dev/null +++ b/gtk/gtktimeline.h @@ -0,0 +1,117 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2007 Carlos Garnacho + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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_TIMELINE_H__ +#define __GTK_TIMELINE_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_TIMELINE (gtk_timeline_get_type ()) +#define GTK_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TIMELINE, GtkTimeline)) +#define GTK_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TIMELINE, GtkTimelineClass)) +#define GTK_IS_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TIMELINE)) +#define GTK_IS_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TIMELINE)) +#define GTK_TIMELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TIMELINE, GtkTimelineClass)) + +typedef struct GtkTimeline GtkTimeline; +typedef struct GtkTimelineClass GtkTimelineClass; + +typedef enum { + GTK_TIMELINE_DIRECTION_FORWARD, + GTK_TIMELINE_DIRECTION_BACKWARD +} GtkTimelineDirection; + +typedef enum { + GTK_TIMELINE_PROGRESS_LINEAR, + GTK_TIMELINE_PROGRESS_EASE, + GTK_TIMELINE_PROGRESS_EASE_IN, + GTK_TIMELINE_PROGRESS_EASE_OUT, + GTK_TIMELINE_PROGRESS_EASE_IN_OUT +} GtkTimelineProgressType; + +struct GtkTimeline +{ + GObject parent_instance; + gpointer priv; +}; + +struct GtkTimelineClass +{ + GObjectClass parent_class; + + void (* started) (GtkTimeline *timeline); + void (* finished) (GtkTimeline *timeline); + void (* paused) (GtkTimeline *timeline); + + void (* frame) (GtkTimeline *timeline, + gdouble progress); + + void (* __gtk_reserved1) (void); + void (* __gtk_reserved2) (void); + void (* __gtk_reserved3) (void); + void (* __gtk_reserved4) (void); +}; + + +GType gtk_timeline_get_type (void) G_GNUC_CONST; + +GtkTimeline *gtk_timeline_new (guint duration); +GtkTimeline *gtk_timeline_new_for_screen (guint duration, + GdkScreen *screen); + +void gtk_timeline_start (GtkTimeline *timeline); +void gtk_timeline_pause (GtkTimeline *timeline); +void gtk_timeline_rewind (GtkTimeline *timeline); + +gboolean gtk_timeline_is_running (GtkTimeline *timeline); + +guint gtk_timeline_get_fps (GtkTimeline *timeline); +void gtk_timeline_set_fps (GtkTimeline *timeline, + guint fps); + +gboolean gtk_timeline_get_loop (GtkTimeline *timeline); +void gtk_timeline_set_loop (GtkTimeline *timeline, + gboolean loop); + +guint gtk_timeline_get_duration (GtkTimeline *timeline); +void gtk_timeline_set_duration (GtkTimeline *timeline, + guint duration); + +GdkScreen *gtk_timeline_get_screen (GtkTimeline *timeline); +void gtk_timeline_set_screen (GtkTimeline *timeline, + GdkScreen *screen); + +GtkTimelineDirection gtk_timeline_get_direction (GtkTimeline *timeline); +void gtk_timeline_set_direction (GtkTimeline *timeline, + GtkTimelineDirection direction); + +gdouble gtk_timeline_get_progress (GtkTimeline *timeline); + +GtkTimelineProgressType gtk_timeline_get_progress_type (GtkTimeline *timeline); +void gtk_timeline_set_progress_type (GtkTimeline *timeline, + GtkTimelineProgressType progress_type); + + +G_END_DECLS + +#endif /* __GTK_TIMELINE_H__ */ From ed840e73e43714650844b13e3de5944335866a63 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 21:45:30 +0200 Subject: [PATCH 269/634] Add GtkAnimationDescription as a private boxed object. This struct will be used to represent an animation in GtkStyleSet. It will only be used internally in GtkStyleContext in order to trigger animations, engines shouldn't need this. --- gtk/Makefile.am | 2 + gtk/gtkanimationdescription.c | 123 ++++++++++++++++++++++++++++++++++ gtk/gtkanimationdescription.h | 47 +++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 gtk/gtkanimationdescription.c create mode 100644 gtk/gtkanimationdescription.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index dd8a8b37ce..ff5ba8d876 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -378,6 +378,7 @@ gtk_private_h_sources = \ gtksearchenginesimple.h \ gtkdndcursors.h \ gtkentryprivate.h \ + gtkanimationdescription.h \ gtkbuilderprivate.h \ gtkcustompaperunixdialog.h\ gtkfilechooserdefault.h \ @@ -451,6 +452,7 @@ gtk_base_c_sources = \ gtkappchoosermodule.c \ gtkappchooseronline.c \ gtkapplication.c \ + gtkanimationdescription.c \ gtkarrow.c \ gtkaspectframe.c \ gtkassistant.c \ diff --git a/gtk/gtkanimationdescription.c b/gtk/gtkanimationdescription.c new file mode 100644 index 0000000000..a0cc3be533 --- /dev/null +++ b/gtk/gtkanimationdescription.c @@ -0,0 +1,123 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtkanimationdescription.h" +#include "gtkintl.h" + +struct GtkAnimationDescription +{ + GtkTimelineProgressType progress_type; + gdouble duration; + + guint ref_count; +}; + +GtkAnimationDescription * +gtk_animation_description_new (gdouble duration, + GtkTimelineProgressType progress_type) +{ + GtkAnimationDescription *desc; + + desc = g_slice_new (GtkAnimationDescription); + desc->duration = duration; + desc->progress_type = progress_type; + desc->ref_count = 1; + + return desc; +} + +gdouble +gtk_animation_description_get_duration (GtkAnimationDescription *desc) +{ + return desc->duration; +} + +GtkTimelineProgressType +gtk_animation_description_get_progress_type (GtkAnimationDescription *desc) +{ + return desc->progress_type; +} + +GtkAnimationDescription * +gtk_animation_description_ref (GtkAnimationDescription *desc) +{ + desc->ref_count++; + return desc; +} + +void +gtk_animation_description_unref (GtkAnimationDescription *desc) +{ + desc->ref_count--; + + if (desc->ref_count == 0) + g_slice_free (GtkAnimationDescription, desc); +} + +GtkAnimationDescription * +gtk_animation_description_from_string (const gchar *str) +{ + gchar timing_function[16] = { 0, }; + gchar duration_measurement[3] = { 0, }; + GtkTimelineProgressType progress_type; + guint duration = 0; + + if (sscanf (str, "%d%2s %15s", &duration, duration_measurement, timing_function) != 3) + return NULL; + + if (strcmp (duration_measurement, "s") == 0) + duration *= 1000; + else if (strcmp (duration_measurement, "ms") != 0) + { + g_warning ("Unknown duration measurement: %s\n", duration_measurement); + return NULL; + } + + if (strcmp (timing_function, "linear") == 0) + progress_type = GTK_TIMELINE_PROGRESS_LINEAR; + else if (strcmp (timing_function, "ease") == 0) + progress_type = GTK_TIMELINE_PROGRESS_EASE; + else if (strcmp (timing_function, "ease-in") == 0) + progress_type = GTK_TIMELINE_PROGRESS_EASE_IN; + else if (strcmp (timing_function, "ease-out") == 0) + progress_type = GTK_TIMELINE_PROGRESS_EASE_OUT; + else if (strcmp (timing_function, "ease-in-out") == 0) + progress_type = GTK_TIMELINE_PROGRESS_EASE_IN_OUT; + else + { + g_warning ("Unknown timing function: %s\n", timing_function); + return NULL; + } + + return gtk_animation_description_new ((gdouble) duration, progress_type); +} + +GType +gtk_animation_description_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (!type)) + type = g_boxed_type_register_static (I_("GtkAnimationDescription"), + (GBoxedCopyFunc) gtk_animation_description_ref, + (GBoxedFreeFunc) gtk_animation_description_unref); + + return type; +} diff --git a/gtk/gtkanimationdescription.h b/gtk/gtkanimationdescription.h new file mode 100644 index 0000000000..14537edbf1 --- /dev/null +++ b/gtk/gtkanimationdescription.h @@ -0,0 +1,47 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_ANIMATION_DESCRIPTION_H__ +#define __GTK_ANIMATION_DESCRIPTION_H__ + +#include "gtktimeline.h" + +G_BEGIN_DECLS + +/* Dummy typedefs */ +typedef struct GtkAnimationDescription GtkAnimationDescription; + +#define GTK_TYPE_ANIMATION_DESCRIPTION (gtk_animation_description_get_type ()) + +GType gtk_animation_description_get_type (void) G_GNUC_CONST; + +GtkAnimationDescription * gtk_animation_description_new (gdouble duration, + GtkTimelineProgressType progress_type); + +gdouble gtk_animation_description_get_duration (GtkAnimationDescription *desc); +GtkTimelineProgressType gtk_animation_description_get_progress_type (GtkAnimationDescription *desc); + +GtkAnimationDescription * gtk_animation_description_ref (GtkAnimationDescription *desc); +void gtk_animation_description_unref (GtkAnimationDescription *desc); + +GtkAnimationDescription * gtk_animation_description_from_string (const gchar *str); + +G_END_DECLS + +#endif /* __GTK_ANIMATION_DESC_H__ */ From 114f30b7726c17b1c3851fdd53c22dd2b3922e84 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 21:49:22 +0200 Subject: [PATCH 270/634] GtkStyleSet: Register the "transition" property. --- gtk/gtkstyleset.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 7c42f1f7d0..315846536e 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -26,6 +26,7 @@ #include "gtkstyleset.h" #include "gtkprivate.h" #include "gtkthemingengine.h" +#include "gtkanimationdescription.h" #include "gtkintl.h" #include "gtkalias.h" @@ -94,6 +95,11 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); g_value_unset (&val); + g_value_init (&val, GTK_TYPE_ANIMATION_DESCRIPTION); + g_value_take_boxed (&val, gtk_animation_description_new (0, GTK_TIMELINE_PROGRESS_LINEAR)); + gtk_style_set_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, &val, NULL); + g_value_unset (&val); + g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); } From 52baa7d51e09d32ea2fe10c46757d1125a2e5190 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 21:50:19 +0200 Subject: [PATCH 271/634] GtkCssProvider: Parse properties of type GtkAnimationDescription. --- gtk/gtkcssprovider.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 0ca90fb0b5..c9c5a17aed 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -24,6 +24,7 @@ #include #include +#include "gtkanimationdescription.h" #include "gtkcssprovider.h" #include "gtkalias.h" @@ -1393,6 +1394,17 @@ css_provider_parse_value (const gchar *value_str, engine = gtk_theming_engine_load (value_str); g_value_set_object (value, engine); } + else if (type == GTK_TYPE_ANIMATION_DESCRIPTION) + { + GtkAnimationDescription *desc; + + desc = gtk_animation_description_from_string (value_str); + + if (desc) + g_value_take_boxed (value, desc); + else + parsed = FALSE; + } else { g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); From bbd0c5a2a24f55d2a340fbeb4f1b8c79e58e3c47 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:00:04 +0200 Subject: [PATCH 272/634] GtkStyleContext: Declare gtk_style_context_list_classes() in header. --- gtk/gtkstylecontext.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 833ca71bee..eecb7b3b99 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -81,6 +81,8 @@ void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context); +GList * gtk_style_context_list_classes (GtkStyleContext *context); + void gtk_style_context_set_class (GtkStyleContext *context, const gchar *class_name); void gtk_style_context_unset_class (GtkStyleContext *context, From 61a0544b8be39cfdcac6d3fb831115dfb6bc2bf8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:35:42 +0200 Subject: [PATCH 273/634] GtkStyleContext: Add animation machinery. Animation regions are confined through gtk_style_context_[push|pop]_animatable_region, anything that's painted between these calls will be invalidated if an animation starts for any of the regions in the stack. gtk_style_context_notify_state_change() may be called from widgets to indicate a change for a given GtkStateType, in that case an animation will be started if there is an animation description for the widget/state. --- gtk/gtkstylecontext.c | 443 ++++++++++++++++++++++++++++++++++++++++- gtk/gtkstylecontext.h | 29 ++- gtk/gtkthemingengine.c | 2 +- 3 files changed, 461 insertions(+), 13 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cd3b2c0276..d34bc4103c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -29,6 +29,8 @@ #include "gtkintl.h" #include "gtkwidget.h" #include "gtkprivate.h" +#include "gtkanimationdescription.h" +#include "gtktimeline.h" #include "gtkalias.h" @@ -37,6 +39,7 @@ typedef struct GtkStyleProviderData GtkStyleProviderData; typedef struct GtkStyleInfo GtkStyleInfo; typedef struct GtkRegion GtkRegion; typedef struct PropertyValue PropertyValue; +typedef struct AnimationInfo AnimationInfo; struct GtkRegion { @@ -64,6 +67,19 @@ struct GtkStyleInfo GtkJunctionSides junction_sides; }; +struct AnimationInfo +{ + GtkTimeline *timeline; + + gpointer region_id; + GdkWindow *window; + GtkStateType state; + gboolean target_value; + + GdkRegion *invalidation_region; + GArray *rectangles; +}; + struct GtkStyleContextPrivate { GdkScreen *screen; @@ -81,6 +97,10 @@ struct GtkStyleContextPrivate GtkStateFlags state_flags; GSList *info_stack; + GSList *animation_regions; + GSList *animations; + gboolean animations_invalidated; + GtkThemingEngine *theming_engine; GtkTextDirection direction; @@ -554,11 +574,37 @@ gtk_style_context_get_state (GtkStyleContext *context) return priv->state_flags; } -gboolean -gtk_style_context_is_state_set (GtkStyleContext *context, - GtkStateType state) +static gboolean +context_has_animatable_region (GtkStyleContext *context, + gpointer region_id) { GtkStyleContextPrivate *priv; + GSList *r; + + /* NULL region_id means everything + * rendered through the style context + */ + if (!region_id) + return TRUE; + + priv = context->priv; + + for (r = priv->animation_regions; r; r = r->next) + { + if (r->data == region_id) + return TRUE; + } + + return FALSE; +} + +gboolean +gtk_style_context_is_state_set (GtkStyleContext *context, + GtkStateType state, + gdouble *progress) +{ + GtkStyleContextPrivate *priv; + gboolean state_set; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); @@ -567,22 +613,51 @@ gtk_style_context_is_state_set (GtkStyleContext *context, switch (state) { case GTK_STATE_NORMAL: - return priv->state_flags == 0; + state_set = (priv->state_flags == 0); + break; case GTK_STATE_ACTIVE: - return priv->state_flags & GTK_STATE_FLAG_ACTIVE; + state_set = (priv->state_flags & GTK_STATE_FLAG_ACTIVE); + break; case GTK_STATE_PRELIGHT: - return priv->state_flags & GTK_STATE_FLAG_PRELIGHT; + state_set = (priv->state_flags & GTK_STATE_FLAG_PRELIGHT); + break; case GTK_STATE_SELECTED: - return priv->state_flags & GTK_STATE_FLAG_SELECTED; + state_set = (priv->state_flags & GTK_STATE_FLAG_SELECTED); + break; case GTK_STATE_INSENSITIVE: - return priv->state_flags & GTK_STATE_FLAG_INSENSITIVE; + state_set = (priv->state_flags & GTK_STATE_FLAG_INSENSITIVE); + break; case GTK_STATE_INCONSISTENT: - return priv->state_flags & GTK_STATE_FLAG_INCONSISTENT; + state_set = (priv->state_flags & GTK_STATE_FLAG_INCONSISTENT); + break; case GTK_STATE_FOCUSED: - return priv->state_flags & GTK_STATE_FLAG_FOCUSED; + state_set = (priv->state_flags & GTK_STATE_FLAG_FOCUSED); + break; default: - return FALSE; + g_assert_not_reached (); } + + if (progress) + { + AnimationInfo *info; + GSList *l; + + *progress = (state_set) ? 1 : 0; + + for (l = priv->animations; l; l = l->next) + { + info = l->data; + + if (info->state == state && + context_has_animatable_region (context, info->region_id)) + { + *progress = gtk_timeline_get_progress (info->timeline); + break; + } + } + } + + return state_set; } void @@ -1362,6 +1437,350 @@ gtk_style_context_lookup_color (GtkStyleContext *context, return gtk_symbolic_color_resolve (sym_color, priv->store, color); } +static void +timeline_frame_cb (GtkTimeline *timeline, + gdouble progress, + gpointer user_data) +{ + AnimationInfo *info; + + info = user_data; + + if (info->invalidation_region && + !gdk_region_empty (info->invalidation_region)) + gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); +} + +static void +animation_info_free (AnimationInfo *info) +{ + g_object_unref (info->timeline); + g_object_unref (info->window); + + if (info->invalidation_region) + gdk_region_destroy (info->invalidation_region); + + g_array_free (info->rectangles, TRUE); + g_slice_free (AnimationInfo, info); +} + +static void +timeline_finished_cb (GtkTimeline *timeline, + gpointer user_data) +{ + GtkStyleContextPrivate *priv; + GtkStyleContext *context; + AnimationInfo *info; + GSList *l; + + context = user_data; + priv = context->priv; + + for (l = priv->animations; l; l = l->next) + { + info = l->data; + + if (info->timeline == timeline) + { + priv->animations = g_slist_delete_link (priv->animations, l); + + /* Invalidate one last time the area, so the final content is painted */ + if (info->invalidation_region && + !gdk_region_empty (info->invalidation_region)) + gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); + + animation_info_free (info); + break; + } + } +} + +static AnimationInfo * +animation_info_new (GtkStyleContext *context, + gdouble duration, + GtkTimelineProgressType progress_type, + GtkStateType state, + gboolean target_value, + GdkWindow *window) +{ + AnimationInfo *info; + + info = g_slice_new0 (AnimationInfo); + + info->rectangles = g_array_new (FALSE, FALSE, sizeof (GdkRectangle)); + info->timeline = gtk_timeline_new (duration); + info->window = g_object_ref (window); + info->state = state; + info->target_value = target_value; + + gtk_timeline_set_progress_type (info->timeline, progress_type); + + if (!target_value) + { + gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); + gtk_timeline_rewind (info->timeline); + } + + g_signal_connect (info->timeline, "frame", + G_CALLBACK (timeline_frame_cb), info); + g_signal_connect (info->timeline, "finished", + G_CALLBACK (timeline_finished_cb), context); + + gtk_timeline_start (info->timeline); + + return info; +} + +static AnimationInfo * +animation_info_lookup (GtkStyleContext *context, + gpointer region_id, + GtkStateType state) +{ + GtkStyleContextPrivate *priv; + GSList *l; + + priv = context->priv; + + for (l = priv->animations; l; l = l->next) + { + AnimationInfo *info; + + info = l->data; + + if (info->state == state && + info->region_id == region_id) + return info; + } + + return NULL; +} + +void +gtk_style_context_notify_state_change (GtkStyleContext *context, + GdkWindow *window, + gpointer region_id, + GtkStateType state, + gboolean state_value) +{ + GtkStyleContextPrivate *priv; + GtkAnimationDescription *desc; + AnimationInfo *info; + GtkStateFlags flags; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GDK_IS_WINDOW (window)); + g_return_if_fail (state < GTK_STATE_LAST); + + state_value = (state_value == TRUE); + priv = context->priv; + + switch (state) + { + case GTK_STATE_ACTIVE: + flags = GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags = GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags = GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags = GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_INCONSISTENT: + flags = GTK_STATE_FLAG_INCONSISTENT; + break; + case GTK_STATE_FOCUSED: + flags = GTK_STATE_FLAG_FOCUSED; + break; + case GTK_STATE_NORMAL: + default: + flags = 0; + break; + } + + /* Find out if there is any animation description for the given + * state, it will fallback to the normal state as well if necessary. + */ + gtk_style_set_get (priv->store, flags, + "transition", &desc, + NULL); + + if (!desc) + return; + + if (gtk_animation_description_get_duration (desc) == 0) + { + gtk_animation_description_unref (desc); + return; + } + + info = animation_info_lookup (context, region_id, state); + + if (info) + { + /* Reverse the animation if target values are the opposite */ + if (info->target_value != state_value) + { + if (gtk_timeline_get_direction (info->timeline) == GTK_TIMELINE_DIRECTION_FORWARD) + gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); + else + gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_FORWARD); + + info->target_value = state_value; + } + } + else + { + info = animation_info_new (context, + gtk_animation_description_get_duration (desc), + gtk_animation_description_get_progress_type (desc), + state, state_value, window); + + priv->animations = g_slist_prepend (priv->animations, info); + priv->animations_invalidated = TRUE; + } + + gtk_animation_description_unref (desc); +} + +void +gtk_style_context_push_animatable_region (GtkStyleContext *context, + gpointer region_id) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (region_id != NULL); + + priv = context->priv; + priv->animation_regions = g_slist_prepend (priv->animation_regions, region_id); +} + +void +gtk_style_context_pop_animatable_region (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + priv->animation_regions = g_slist_delete_link (priv->animation_regions, + priv->animation_regions); +} + +void +_gtk_style_context_invalidate_animation_areas (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GSList *l; + + priv = context->priv; + + for (l = priv->animations; l; l = l->next) + { + AnimationInfo *info; + + info = l->data; + + /* A NULL invalidation region means it has to be recreated on + * the next expose event, this happens usually after a widget + * allocation change, so the next expose after it will update + * the invalidation region. + */ + if (info->invalidation_region) + { + gdk_region_destroy (info->invalidation_region); + info->invalidation_region = NULL; + } + } + + priv->animations_invalidated = TRUE; +} + +void +_gtk_style_context_coalesce_animation_areas (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GSList *l; + + priv = context->priv; + + if (!priv->animations_invalidated) + return; + + for (l = priv->animations; l; l = l->next) + { + AnimationInfo *info; + guint i; + + info = l->data; + + if (info->invalidation_region) + continue; + + /* FIXME: If this happens there's not much + * point in keeping the animation running. + */ + if (info->rectangles->len == 0) + continue; + + info->invalidation_region = gdk_region_new (); + + for (i = 0; i rectangles->len; i++) + { + GdkRectangle *rect; + + rect = &g_array_index (info->rectangles, GdkRectangle, i); + gdk_region_union_with_rect (info->invalidation_region, rect); + } + + g_array_remove_range (info->rectangles, 0, info->rectangles->len); + } +} + +static void +store_animation_region (GtkStyleContext *context, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GSList *l; + + priv = context->priv; + + if (!priv->animations_invalidated) + return; + + for (l = priv->animations; l; l = l->next) + { + AnimationInfo *info; + + info = l->data; + + /* The animation doesn't need updatring + * the invalidation area, bail out. + */ + if (info->invalidation_region) + continue; + + if (context_has_animatable_region (context, info->region_id)) + { + GdkRectangle rect; + + rect.x = (gint) x; + rect.y = (gint) y; + rect.width = (gint) width; + rect.height = (gint) height; + + g_array_append_val (info->rectangles, rect); + } + } +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, @@ -1380,6 +1799,8 @@ gtk_render_check (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_check (priv->theming_engine, cr, x, y, width, height); diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index eecb7b3b99..020368c0a0 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -75,7 +75,8 @@ void gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); gboolean gtk_style_context_is_state_set (GtkStyleContext *context, - GtkStateType state); + GtkStateType state, + gdouble *progress); void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); @@ -128,10 +129,36 @@ gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, GdkColor *color); +void gtk_style_context_notify_state_change (GtkStyleContext *context, + GdkWindow *window, + gpointer region_id, + GtkStateType state, + gboolean state_value); +void gtk_style_context_push_animatable_region (GtkStyleContext *context, + gpointer region_id); +void gtk_style_context_pop_animatable_region (GtkStyleContext *context); + + /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, GParamSpec *pspec); +void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context); +void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context); + +/* Animation for state changes */ +void gtk_style_context_state_transition_start (GtkStyleContext *context, + gpointer identifier, + GtkWidget *widget, + GtkStateType state, + gboolean value, + GdkRectangle *rect); +void gtk_style_context_state_transition_update (GtkStyleContext *context, + gpointer identifier, + GdkRectangle *rect, + GtkStateType state); +void gtk_style_context_state_transition_stop (GtkStyleContext *context, + gpointer identifier); /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a7a740b612..b29c73db47 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -321,7 +321,7 @@ gtk_theming_engine_is_state_set (GtkThemingEngine *engine, g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); priv = engine->priv; - return gtk_style_context_is_state_set (priv->context, state); + return gtk_style_context_is_state_set (priv->context, state, NULL); } G_CONST_RETURN GtkWidgetPath * From 3c07e3d3dfbd8b7b6281198868dcd6f944b77f6e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:42:16 +0200 Subject: [PATCH 274/634] GtkWidget: Update GtkStyleContext animation regions on allocation change. --- gtk/gtkwidget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 6321348ea2..22f3bf2fee 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4660,6 +4660,14 @@ gtk_widget_size_allocate (GtkWidget *widget, cairo_region_destroy (invalidate); } } + + if (size_changed || position_changed) + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + _gtk_style_context_invalidate_animation_areas (context); + } } if ((size_changed || position_changed) && priv->parent && @@ -5632,6 +5640,7 @@ gtk_widget_send_expose (GtkWidget *widget, cairo_t *cr; int x, y; gboolean do_clip; + GtkStyleContext *context; g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE); g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE); @@ -5656,6 +5665,9 @@ gtk_widget_send_expose (GtkWidget *widget, gtk_cairo_set_event (cr, NULL); cairo_destroy (cr); + context = gtk_widget_get_style_context (widget); + _gtk_style_context_coalesce_animation_areas (context); + return result; } From 7519ed278b5f100d08fe95d88defb428da9af6a1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:45:22 +0200 Subject: [PATCH 275/634] GtkThemingEngine: Add progress arg to gtk_theming_engine_is_state_set() --- gtk/gtkthemingengine.c | 15 ++++++++------- gtk/gtkthemingengine.h | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b29c73db47..8797ff898e 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -314,14 +314,15 @@ gtk_theming_engine_get_state (GtkThemingEngine *engine) gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, - GtkStateType state) + GtkStateType state, + gdouble *progress) { GtkThemingEnginePrivate *priv; g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); priv = engine->priv; - return gtk_style_context_is_state_set (priv->context, state, NULL); + return gtk_style_context_is_state_set (priv->context, state, progress); } G_CONST_RETURN GtkWidgetPath * @@ -558,7 +559,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, else gdk_cairo_set_source_color (cr, text_color); - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT, NULL)) { int line_thickness = MAX (1, (3 + interior_size * 2) / 7); @@ -569,7 +570,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, line_thickness); cairo_fill (cr); } - else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) + else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, NULL)) { cairo_translate (cr, x + pad, y + pad); @@ -670,7 +671,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, /* FIXME: thickness */ thickness = 1; - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT)) + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT, NULL)) { gint line_thickness; @@ -692,7 +693,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, line_thickness); cairo_fill (cr); } - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE)) + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, NULL)) { pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9); interior_size = MAX (1, exterior_size - 2 * pad); @@ -1481,7 +1482,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, screen = gtk_theming_engine_get_screen (engine); - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INSENSITIVE)) + if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INSENSITIVE, NULL)) { PangoLayout *insensitive_layout; diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 326fc63db4..e315e0a01f 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -175,7 +175,8 @@ gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine, GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, - GtkStateType state); + GtkStateType state, + gdouble *progress); GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); From 9b949479b377f316d0c1d5102fdeab2218b51d97 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:47:02 +0200 Subject: [PATCH 276/634] GtkThemingEngine: Animate checkboxes activation. --- gtk/gtkthemingengine.c | 57 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 8797ff898e..cbf57bd1d5 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -570,33 +570,44 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, line_thickness); cairo_fill (cr); } - else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, NULL)) + else { - cairo_translate (cr, - x + pad, y + pad); + gdouble progress; + gboolean active; - cairo_scale (cr, interior_size / 7., interior_size / 7.); + active = gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, &progress); - cairo_move_to (cr, 7.0, 0.0); - cairo_line_to (cr, 7.5, 1.0); - cairo_curve_to (cr, 5.3, 2.0, - 4.3, 4.0, - 3.5, 7.0); - cairo_curve_to (cr, 3.0, 5.7, - 1.3, 4.7, - 0.0, 4.7); - cairo_line_to (cr, 0.2, 3.5); - cairo_curve_to (cr, 1.1, 3.5, - 2.3, 4.3, - 3.0, 5.0); - cairo_curve_to (cr, 1.0, 3.9, - 2.4, 4.1, - 3.2, 4.9); - cairo_curve_to (cr, 3.5, 3.1, - 5.2, 2.0, - 7.0, 0.0); + if (active || progress > 0) + { + cairo_translate (cr, + x + pad, y + pad); - cairo_fill (cr); + cairo_scale (cr, interior_size / 7., interior_size / 7.); + + cairo_rectangle (cr, 0, 0, 7 * progress, 7); + cairo_clip (cr); + + cairo_move_to (cr, 7.0, 0.0); + cairo_line_to (cr, 7.5, 1.0); + cairo_curve_to (cr, 5.3, 2.0, + 4.3, 4.0, + 3.5, 7.0); + cairo_curve_to (cr, 3.0, 5.7, + 1.3, 4.7, + 0.0, 4.7); + cairo_line_to (cr, 0.2, 3.5); + cairo_curve_to (cr, 1.1, 3.5, + 2.3, 4.3, + 3.0, 5.0); + cairo_curve_to (cr, 1.0, 3.9, + 2.4, 4.1, + 3.2, 4.9); + cairo_curve_to (cr, 3.5, 3.1, + 5.2, 2.0, + 7.0, 0.0); + + cairo_fill (cr); + } } cairo_restore (cr); From 91904f6778b40fd4cacf6efbdc7b6a25421ec0e0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 19 Aug 2010 22:47:44 +0200 Subject: [PATCH 277/634] GtkButton: Notify on active state when (un)depressed --- gtk/gtkbutton.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 71fb865f43..beece346c1 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -2246,6 +2246,18 @@ _gtk_button_set_depressed (GtkButton *button, if (depressed != priv->depressed) { + if (gtk_widget_get_realized (widget) && + gtk_widget_is_drawable (widget)) + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_notify_state_change (context, + gtk_widget_get_window (widget), + NULL, GTK_STATE_ACTIVE, + depressed); + } + priv->depressed = depressed; gtk_widget_queue_resize (widget); } From 0ce649e965560863d585393f70c7212a4f9cffbc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 20 Aug 2010 01:16:40 +0200 Subject: [PATCH 278/634] Plug a bunch of leaks. --- gtk/gtkstyle.c | 2 +- gtk/gtkstylecontext.c | 257 ++++++++++++++++++++++------------------- gtk/gtkstyleset.c | 1 + gtk/gtksymboliccolor.c | 25 ++++ gtk/gtkthemingengine.c | 6 + gtk/gtkwidget.c | 1 + gtk/gtkwidgetpath.c | 3 + 7 files changed, 175 insertions(+), 120 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 55a2fa7ab9..82d05dd2ce 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -696,7 +696,7 @@ gtk_style_update_from_context (GtkStyle *style) set_color (style, priv->context, state, GTK_RC_TEXT); } - /* FIXME: thickness */ + /* FIXME: thickness, font_desc */ } static void diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index d34bc4103c..f7f236d262 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -204,7 +204,7 @@ gtk_style_context_init (GtkStyleContext *style_context) GtkStyleContextPrivate); priv->store = gtk_style_set_new (); - priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL); + priv->theming_engine = g_object_ref ((gpointer) gtk_theming_engine_load (NULL)); priv->direction = GTK_TEXT_DIR_RTL; @@ -257,15 +257,139 @@ clear_property_cache (GtkStyleContext *context) } } +static void +animation_info_free (AnimationInfo *info) +{ + g_object_unref (info->timeline); + g_object_unref (info->window); + + if (info->invalidation_region) + gdk_region_destroy (info->invalidation_region); + + g_array_free (info->rectangles, TRUE); + g_slice_free (AnimationInfo, info); +} + +static void +timeline_frame_cb (GtkTimeline *timeline, + gdouble progress, + gpointer user_data) +{ + AnimationInfo *info; + + info = user_data; + + if (info->invalidation_region && + !gdk_region_empty (info->invalidation_region)) + gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); +} + +static void +timeline_finished_cb (GtkTimeline *timeline, + gpointer user_data) +{ + GtkStyleContextPrivate *priv; + GtkStyleContext *context; + AnimationInfo *info; + GSList *l; + + context = user_data; + priv = context->priv; + + for (l = priv->animations; l; l = l->next) + { + info = l->data; + + if (info->timeline == timeline) + { + priv->animations = g_slist_delete_link (priv->animations, l); + + /* Invalidate one last time the area, so the final content is painted */ + if (info->invalidation_region && + !gdk_region_empty (info->invalidation_region)) + gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); + + animation_info_free (info); + break; + } + } +} + +static AnimationInfo * +animation_info_new (GtkStyleContext *context, + gdouble duration, + GtkTimelineProgressType progress_type, + GtkStateType state, + gboolean target_value, + GdkWindow *window) +{ + AnimationInfo *info; + + info = g_slice_new0 (AnimationInfo); + + info->rectangles = g_array_new (FALSE, FALSE, sizeof (GdkRectangle)); + info->timeline = gtk_timeline_new (duration); + info->window = g_object_ref (window); + info->state = state; + info->target_value = target_value; + + gtk_timeline_set_progress_type (info->timeline, progress_type); + + if (!target_value) + { + gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); + gtk_timeline_rewind (info->timeline); + } + + g_signal_connect (info->timeline, "frame", + G_CALLBACK (timeline_frame_cb), info); + g_signal_connect (info->timeline, "finished", + G_CALLBACK (timeline_finished_cb), context); + + gtk_timeline_start (info->timeline); + + return info; +} + +static AnimationInfo * +animation_info_lookup (GtkStyleContext *context, + gpointer region_id, + GtkStateType state) +{ + GtkStyleContextPrivate *priv; + GSList *l; + + priv = context->priv; + + for (l = priv->animations; l; l = l->next) + { + AnimationInfo *info; + + info = l->data; + + if (info->state == state && + info->region_id == region_id) + return info; + } + + return NULL; +} + static void gtk_style_context_finalize (GObject *object) { GtkStyleContextPrivate *priv; GtkStyleContext *style_context; + GSList *l; style_context = GTK_STYLE_CONTEXT (object); priv = style_context->priv; + if (priv->widget_path) + gtk_widget_path_free (priv->widget_path); + + g_object_unref (priv->store); + g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); g_list_free (priv->providers); @@ -277,6 +401,16 @@ gtk_style_context_finalize (GObject *object) g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free (priv->icon_factories); + g_slist_free (priv->animation_regions); + + for (l = priv->animations; l; l = l->next) + animation_info_free ((AnimationInfo *) l->data); + + g_slist_free (priv->animations); + + if (priv->theming_engine) + g_object_unref (priv->theming_engine); + G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); } @@ -363,6 +497,9 @@ rebuild_properties (GtkStyleContext *context) } } + if (priv->theming_engine) + g_object_unref (priv->theming_engine); + gtk_style_set_get (priv->store, 0, "engine", &priv->theming_engine, NULL); @@ -1437,124 +1574,6 @@ gtk_style_context_lookup_color (GtkStyleContext *context, return gtk_symbolic_color_resolve (sym_color, priv->store, color); } -static void -timeline_frame_cb (GtkTimeline *timeline, - gdouble progress, - gpointer user_data) -{ - AnimationInfo *info; - - info = user_data; - - if (info->invalidation_region && - !gdk_region_empty (info->invalidation_region)) - gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); -} - -static void -animation_info_free (AnimationInfo *info) -{ - g_object_unref (info->timeline); - g_object_unref (info->window); - - if (info->invalidation_region) - gdk_region_destroy (info->invalidation_region); - - g_array_free (info->rectangles, TRUE); - g_slice_free (AnimationInfo, info); -} - -static void -timeline_finished_cb (GtkTimeline *timeline, - gpointer user_data) -{ - GtkStyleContextPrivate *priv; - GtkStyleContext *context; - AnimationInfo *info; - GSList *l; - - context = user_data; - priv = context->priv; - - for (l = priv->animations; l; l = l->next) - { - info = l->data; - - if (info->timeline == timeline) - { - priv->animations = g_slist_delete_link (priv->animations, l); - - /* Invalidate one last time the area, so the final content is painted */ - if (info->invalidation_region && - !gdk_region_empty (info->invalidation_region)) - gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); - - animation_info_free (info); - break; - } - } -} - -static AnimationInfo * -animation_info_new (GtkStyleContext *context, - gdouble duration, - GtkTimelineProgressType progress_type, - GtkStateType state, - gboolean target_value, - GdkWindow *window) -{ - AnimationInfo *info; - - info = g_slice_new0 (AnimationInfo); - - info->rectangles = g_array_new (FALSE, FALSE, sizeof (GdkRectangle)); - info->timeline = gtk_timeline_new (duration); - info->window = g_object_ref (window); - info->state = state; - info->target_value = target_value; - - gtk_timeline_set_progress_type (info->timeline, progress_type); - - if (!target_value) - { - gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); - gtk_timeline_rewind (info->timeline); - } - - g_signal_connect (info->timeline, "frame", - G_CALLBACK (timeline_frame_cb), info); - g_signal_connect (info->timeline, "finished", - G_CALLBACK (timeline_finished_cb), context); - - gtk_timeline_start (info->timeline); - - return info; -} - -static AnimationInfo * -animation_info_lookup (GtkStyleContext *context, - gpointer region_id, - GtkStateType state) -{ - GtkStyleContextPrivate *priv; - GSList *l; - - priv = context->priv; - - for (l = priv->animations; l; l = l->next) - { - AnimationInfo *info; - - info = l->data; - - if (info->state == state && - info->region_id == region_id) - return info; - } - - return NULL; -} - void gtk_style_context_notify_state_change (GtkStyleContext *context, GdkWindow *window, diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 315846536e..a9df3a1201 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -129,6 +129,7 @@ property_data_free (PropertyData *data) g_value_unset (&value_data->value); } + g_array_free (data->values, TRUE); g_slice_free (PropertyData, data); } diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index bd33efaf6c..569f3066f0 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -65,6 +65,7 @@ gtk_symbolic_color_new_literal (GdkColor *color) symbolic_color = g_slice_new0 (GtkSymbolicColor); symbolic_color->type = COLOR_TYPE_LITERAL; symbolic_color->color = *color; + symbolic_color->ref_count = 1; return symbolic_color; } @@ -79,6 +80,7 @@ gtk_symbolic_color_new_name (const gchar *name) symbolic_color = g_slice_new0 (GtkSymbolicColor); symbolic_color->type = COLOR_TYPE_NAME; symbolic_color->name = g_strdup (name); + symbolic_color->ref_count = 1; return symbolic_color; } @@ -95,6 +97,7 @@ gtk_symbolic_color_new_shade (GtkSymbolicColor *color, symbolic_color->type = COLOR_TYPE_SHADE; symbolic_color->shade.color = gtk_symbolic_color_ref (color); symbolic_color->shade.factor = CLAMP (factor, 0, 1); + symbolic_color->ref_count = 1; return symbolic_color; } @@ -114,6 +117,7 @@ gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, symbolic_color->mix.color1 = gtk_symbolic_color_ref (color1); symbolic_color->mix.color2 = gtk_symbolic_color_ref (color2); symbolic_color->mix.factor = CLAMP (factor, 0, 1); + symbolic_color->ref_count = 1; return symbolic_color; } @@ -134,6 +138,27 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) g_return_if_fail (color != NULL); color->ref_count--; + + if (color->ref_count == 0) + { + switch (color->type) + { + case COLOR_TYPE_NAME: + g_free (color->name); + break; + case COLOR_TYPE_SHADE: + gtk_symbolic_color_unref (color->shade.color); + break; + case COLOR_TYPE_MIX: + gtk_symbolic_color_unref (color->mix.color1); + gtk_symbolic_color_unref (color->mix.color2); + break; + default: + break; + } + + g_slice_free (GtkSymbolicColor, color); + } } gboolean diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index cbf57bd1d5..ef7a863cb5 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -724,6 +724,10 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, } cairo_restore (cr); + + gdk_color_free (fg_color); + gdk_color_free (base_color); + gdk_color_free (text_color); } static void @@ -1337,6 +1341,8 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, } cairo_restore (cr); + + gdk_color_free (bg_color); } typedef struct _ByteRange ByteRange; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 22f3bf2fee..cb053fad6b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7442,6 +7442,7 @@ gtk_widget_ensure_style (GtkWidget *widget) NULL); gtk_widget_set_style_internal (widget, style, TRUE); + g_object_unref (style); } #if 0 diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 6fe08f558a..0f5e420a41 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -102,6 +102,9 @@ gtk_widget_path_free (GtkWidgetPath *path) if (elem->regions) g_hash_table_destroy (elem->regions); + + if (elem->classes) + g_array_free (elem->classes, TRUE); } g_array_free (path->elems, TRUE); From 9dfba95f095667b425a8f676c48c5749ab6c4c18 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 20 Aug 2010 11:50:39 +0200 Subject: [PATCH 279/634] GtkCssProvider: Add gtk_css_provider_load_from_path() --- gtk/gtkcssprovider.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkcssprovider.h | 3 +++ 2 files changed, 63 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index c9c5a17aed..f9780c2420 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1686,6 +1686,45 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, return TRUE; } +gboolean +gtk_css_provider_load_from_path (GtkCssProvider *css_provider, + const gchar *path, + GError **error) +{ + GtkCssProviderPrivate *priv; + GError *internal_error = NULL; + gchar *data; + gsize length; + + g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); + g_return_val_if_fail (path != NULL, FALSE); + + priv = css_provider->priv; + + if (g_file_get_contents (path, &data, &length, + &internal_error)) + { + g_propagate_error (error, internal_error); + return FALSE; + } + + if (priv->selectors_info->len > 0) + g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); + + g_free (priv->filename); + priv->filename = g_strdup (path); + + css_provider_reset_parser (css_provider); + priv->scanner->input_name = priv->filename; + g_scanner_input_text (priv->scanner, data, (guint) length); + + parse_stylesheet (css_provider); + + g_free (data); + + return TRUE; +} + GtkCssProvider * gtk_css_provider_get_default (void) { @@ -1762,5 +1801,26 @@ gtk_css_provider_get_default (void) return provider; } +GtkCssProvider * +gtk_css_provider_get_named (const gchar *name) +{ + static GHashTable *themes = NULL; + GtkCssProvider *provider; + + if (G_UNLIKELY (!themes)) + themes = g_hash_table_new (g_str_hash, g_str_equal); + + provider = g_hash_table_lookup (themes, name); + + if (!provider) + { + + + g_hash_table_insert (themes, g_strdup (name), provider); + } + + return provider; +} + #define __GTK_CSS_PROVIDER_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h index 18364eaea8..2b8dd9dcfe 100644 --- a/gtk/gtkcssprovider.h +++ b/gtk/gtkcssprovider.h @@ -56,6 +56,9 @@ gboolean gtk_css_provider_load_from_data (GtkCssProvider *css_provider, gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider, GFile *file, GError **error); +gboolean gtk_css_provider_load_from_path (GtkCssProvider *css_provider, + const gchar *path, + GError **error); GtkCssProvider * gtk_css_provider_get_default (void); From c9d626523d103977eddf98f9e383bb2043c1371c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 20 Aug 2010 13:56:30 +0200 Subject: [PATCH 280/634] Remove gtkalias from style context code. --- gtk/gtkcssprovider.c | 5 ----- gtk/gtkstylecontext.c | 5 ----- gtk/gtkstyleprovider.c | 5 ----- gtk/gtkstyleset.c | 5 ----- gtk/gtksymboliccolor.c | 3 --- gtk/gtkthemingengine.c | 5 ----- gtk/gtktimeline.c | 3 --- gtk/gtkwidgetpath.c | 3 --- 8 files changed, 34 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f9780c2420..058c1d3450 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -27,8 +27,6 @@ #include "gtkanimationdescription.h" #include "gtkcssprovider.h" -#include "gtkalias.h" - typedef struct GtkCssProviderPrivate GtkCssProviderPrivate; typedef struct SelectorElement SelectorElement; typedef struct SelectorPath SelectorPath; @@ -1821,6 +1819,3 @@ gtk_css_provider_get_named (const gchar *name) return provider; } - -#define __GTK_CSS_PROVIDER_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f7f236d262..6c3fa2b46f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -32,8 +32,6 @@ #include "gtkanimationdescription.h" #include "gtktimeline.h" -#include "gtkalias.h" - typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; typedef struct GtkStyleInfo GtkStyleInfo; @@ -2085,6 +2083,3 @@ gtk_render_handle (GtkStyleContext *context, _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_handle (priv->theming_engine, cr, x, y, width, height, orientation); } - -#define __GTK_STYLE_CONTEXT_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 4240176f24..2c23a80edb 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -23,8 +23,6 @@ #include "gtkstyleprovider.h" #include "gtkintl.h" -#include "gtkalias.h" - static void gtk_style_provider_iface_init (gpointer g_iface); GType @@ -99,6 +97,3 @@ gtk_style_provider_get_icon_factory (GtkStyleProvider *provider, return iface->get_icon_factory (provider, path); } - -#define __GTK_STYLE_PROVIDER_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index a9df3a1201..5c634100e0 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -29,8 +29,6 @@ #include "gtkanimationdescription.h" #include "gtkintl.h" -#include "gtkalias.h" - typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; typedef struct PropertyData PropertyData; typedef struct PropertyNode PropertyNode; @@ -882,6 +880,3 @@ gtk_style_set_merge (GtkStyleSet *set, } } } - -#define __GTK_STYLE_SET_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 569f3066f0..9b9386b4cd 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -240,6 +240,3 @@ gtk_symbolic_color_get_type (void) return type; } - -#define __GTK_SYMBOLIC_COLOR_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index ef7a863cb5..10f4117557 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -26,8 +26,6 @@ #include #include -#include "gtkalias.h" - typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; enum { @@ -1919,6 +1917,3 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdk_color_free (bg_color); } - -#define __GTK_THEMING_ENGINE_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtktimeline.c b/gtk/gtktimeline.c index b4c034d700..348011c768 100644 --- a/gtk/gtktimeline.c +++ b/gtk/gtktimeline.c @@ -733,6 +733,3 @@ gtk_timeline_set_progress_type (GtkTimeline *timeline, priv = timeline->priv; priv->progress_type = progress_type; } - -#define __GTK_TIMELINE_C__ -#include "gtkaliasdef.c" diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 0f5e420a41..933a2dc0c7 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -597,6 +597,3 @@ gtk_widget_path_has_parent (const GtkWidgetPath *path, return FALSE; } - -#define __GTK_WIDGET_PATH_C__ -#include "gtkaliasdef.c" From f058359182a7ba7c07eec807c5bb0530aeaf541b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 20 Aug 2010 14:09:30 +0200 Subject: [PATCH 281/634] Replace GdkRegion and GdkRectangle with their cairo counterparts. --- gtk/gtkstylecontext.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 6c3fa2b46f..148dbd4594 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -74,7 +74,7 @@ struct AnimationInfo GtkStateType state; gboolean target_value; - GdkRegion *invalidation_region; + cairo_region_t *invalidation_region; GArray *rectangles; }; @@ -262,7 +262,7 @@ animation_info_free (AnimationInfo *info) g_object_unref (info->window); if (info->invalidation_region) - gdk_region_destroy (info->invalidation_region); + cairo_region_destroy (info->invalidation_region); g_array_free (info->rectangles, TRUE); g_slice_free (AnimationInfo, info); @@ -278,7 +278,7 @@ timeline_frame_cb (GtkTimeline *timeline, info = user_data; if (info->invalidation_region && - !gdk_region_empty (info->invalidation_region)) + !cairo_region_is_empty (info->invalidation_region)) gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); } @@ -304,7 +304,7 @@ timeline_finished_cb (GtkTimeline *timeline, /* Invalidate one last time the area, so the final content is painted */ if (info->invalidation_region && - !gdk_region_empty (info->invalidation_region)) + !cairo_region_is_empty (info->invalidation_region)) gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); animation_info_free (info); @@ -325,7 +325,7 @@ animation_info_new (GtkStyleContext *context, info = g_slice_new0 (AnimationInfo); - info->rectangles = g_array_new (FALSE, FALSE, sizeof (GdkRectangle)); + info->rectangles = g_array_new (FALSE, FALSE, sizeof (cairo_rectangle_int_t)); info->timeline = gtk_timeline_new (duration); info->window = g_object_ref (window); info->state = state; @@ -1708,7 +1708,7 @@ _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context) */ if (info->invalidation_region) { - gdk_region_destroy (info->invalidation_region); + cairo_region_destroy (info->invalidation_region); info->invalidation_region = NULL; } } @@ -1743,14 +1743,14 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context) if (info->rectangles->len == 0) continue; - info->invalidation_region = gdk_region_new (); + info->invalidation_region = cairo_region_create (); for (i = 0; i rectangles->len; i++) { - GdkRectangle *rect; + cairo_rectangle_int_t *rect; - rect = &g_array_index (info->rectangles, GdkRectangle, i); - gdk_region_union_with_rect (info->invalidation_region, rect); + rect = &g_array_index (info->rectangles, cairo_rectangle_int_t, i); + cairo_region_union_rectangle (info->invalidation_region, rect); } g_array_remove_range (info->rectangles, 0, info->rectangles->len); @@ -1786,7 +1786,7 @@ store_animation_region (GtkStyleContext *context, if (context_has_animatable_region (context, info->region_id)) { - GdkRectangle rect; + cairo_rectangle_int_t rect; rect.x = (gint) x; rect.y = (gint) y; From 78a98decaee9a5ee05f2abcc8481b84d0a72bc1a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 20 Aug 2010 14:58:54 +0200 Subject: [PATCH 282/634] Get rid of GdkPangoRenderer code in GtkThemingEngine. --- gtk/gtkthemingengine.c | 179 +++++++++-------------------------------- 1 file changed, 36 insertions(+), 143 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 10f4117557..b37a388564 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -26,6 +26,8 @@ #include #include +#include "gtkpango.h" + typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; enum { @@ -1343,138 +1345,6 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, gdk_color_free (bg_color); } -typedef struct _ByteRange ByteRange; - -struct _ByteRange -{ - guint start; - guint end; -}; - -static ByteRange* -range_new (guint start, - guint end) -{ - ByteRange *br = g_new (ByteRange, 1); - - br->start = start; - br->end = end; - - return br; -} - -static PangoLayout* -get_insensitive_layout (PangoLayout *layout) -{ - GSList *embossed_ranges = NULL; - GSList *shaded_ranges = NULL; - PangoLayoutIter *iter; - GSList *tmp_list = NULL; - PangoLayout *new_layout; - PangoAttrList *attrs; - - iter = pango_layout_get_iter (layout); - - do - { - PangoLayoutRun *run; - PangoAttribute *attr; - gboolean need_shade = FALSE; - ByteRange *br; - - run = pango_layout_iter_get_run_readonly (iter); - - if (run) - { - tmp_list = run->item->analysis.extra_attrs; - - while (tmp_list != NULL) - { - attr = tmp_list->data; - switch (attr->klass->type) - { - case PANGO_ATTR_FOREGROUND: - case PANGO_ATTR_BACKGROUND: - need_shade = TRUE; - break; - - default: - break; - } - - if (need_shade) - break; - - tmp_list = g_slist_next (tmp_list); - } - - br = range_new (run->item->offset, run->item->offset + run->item->length); - - if (need_shade) - shaded_ranges = g_slist_prepend (shaded_ranges, br); - else - embossed_ranges = g_slist_prepend (embossed_ranges, br); - } - } - while (pango_layout_iter_next_run (iter)); - - pango_layout_iter_free (iter); - - new_layout = pango_layout_copy (layout); - - attrs = pango_layout_get_attributes (new_layout); - - if (attrs == NULL) - { - /* Create attr list if there wasn't one */ - attrs = pango_attr_list_new (); - pango_layout_set_attributes (new_layout, attrs); - pango_attr_list_unref (attrs); - } - - tmp_list = embossed_ranges; - while (tmp_list != NULL) - { - PangoAttribute *attr; - ByteRange *br = tmp_list->data; - - attr = gdk_pango_attr_embossed_new (TRUE); - - attr->start_index = br->start; - attr->end_index = br->end; - - pango_attr_list_change (attrs, attr); - - g_free (br); - - tmp_list = g_slist_next (tmp_list); - } - - g_slist_free (embossed_ranges); - - tmp_list = shaded_ranges; - while (tmp_list != NULL) - { - PangoAttribute *attr; - ByteRange *br = tmp_list->data; - - attr = gdk_pango_attr_shade_new (0.7); - - attr->start_index = br->start; - attr->end_index = br->end; - - pango_attr_list_change (attrs, attr); - - g_free (br); - - tmp_list = g_slist_next (tmp_list); - } - - g_slist_free (shaded_ranges); - - return new_layout; -} - static void gtk_theming_engine_render_layout (GtkThemingEngine *engine, cairo_t *cr, @@ -1482,6 +1352,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, gdouble y, PangoLayout *layout) { + const PangoMatrix *matrix; GdkColor *fg_color; GtkStateFlags flags; GdkScreen *screen; @@ -1496,21 +1367,43 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, NULL); screen = gtk_theming_engine_get_screen (engine); + matrix = pango_context_get_matrix (pango_layout_get_context (layout)); + + if (matrix) + { + cairo_matrix_t cairo_matrix; + PangoMatrix tmp_matrix; + PangoRectangle rect; + + cairo_matrix_init (&cairo_matrix, + matrix->xx, matrix->yx, + matrix->xy, matrix->yy, + matrix->x0, matrix->y0); + + pango_layout_get_extents (layout, NULL, &rect); + pango_matrix_transform_rectangle (matrix, &rect); + pango_extents_to_pixels (&rect, NULL); + + tmp_matrix = *matrix; + cairo_matrix.x0 += x - rect.x; + cairo_matrix.y0 += y - rect.y; + + cairo_set_matrix (cr, &cairo_matrix); + } + else + cairo_translate (cr, x, y); if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INSENSITIVE, NULL)) { - PangoLayout *insensitive_layout; - - insensitive_layout = get_insensitive_layout (layout); - gdk_pango_show_layout (screen, - cr, x, y, - insensitive_layout, - fg_color, NULL); - g_object_unref (insensitive_layout); + cairo_save (cr); + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_move_to (cr, 1, 1); + _gtk_pango_fill_layout (cr, layout); + cairo_restore (cr); } - else - gdk_pango_show_layout (screen, cr, x, y, layout, - fg_color, NULL); + + gdk_cairo_set_source_color (cr, fg_color); + pango_cairo_show_layout (cr, layout); cairo_restore (cr); From 7e7347d1a072d553568b973985b3451e1d54b3c7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 23 Aug 2010 18:00:06 +0200 Subject: [PATCH 283/634] GtkNotebook: invert tab drawing order so region flags are set correctly. --- gtk/gtknotebook.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 0ed23dc79b..3ce43ee9ab 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -4967,7 +4967,7 @@ gtk_notebook_paint (GtkWidget *widget, gap_x = priv->cur_page->allocation.x - allocation.x - border_width; gap_width = priv->cur_page->allocation.width; - step = is_rtl ? STEP_NEXT : STEP_PREV; + step = is_rtl ? STEP_PREV : STEP_NEXT; break; case GTK_POS_LEFT: case GTK_POS_RIGHT: From 846f67d805316c8af0b8ce16a268b8a8868c3467 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 23 Aug 2010 18:00:31 +0200 Subject: [PATCH 284/634] GtkStyle: Allow GTK_ARROW_NONE. --- gtk/gtkstyle.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 82d05dd2ce..c4056702da 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -2220,6 +2220,9 @@ gtk_default_draw_arrow (GtkStyle *style, GtkStateFlags flags = 0; gdouble angle, size; + if (arrow_type == GTK_ARROW_NONE) + return; + if (widget) context = gtk_widget_get_style_context (widget); else From 585afafa39a3b2c6a40661f015e195d5b15a9c75 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 30 Aug 2010 22:34:31 +0200 Subject: [PATCH 285/634] Add basic parser for GtkBorder properties. Different units aren't supported, it takes 1 to 4 integers representing pixel distances. --- gtk/gtkcssprovider.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 058c1d3450..9b257ca43f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1403,6 +1403,43 @@ css_provider_parse_value (const gchar *value_str, else parsed = FALSE; } + else if (type == GTK_TYPE_BORDER) + { + guint first, second, third, fourth; + GtkBorder border; + + /* FIXME: no unit support */ + if (sscanf (value_str, "%d %d %d %d", + &first, &second, &third, &fourth) == 4) + { + border.top = first; + border.right = second; + border.bottom = third; + border.left = fourth; + } + else if (sscanf (value_str, "%d %d %d", + &first, &second, &third) == 3) + { + border.top = first; + border.left = border.right = second; + border.bottom = third; + } + else if (sscanf (value_str, "%d %d", &first, &second) == 2) + { + border.top = border.bottom = first; + border.left = border.right = second; + } + else if (sscanf (value_str, "%d", &first) == 1) + { + border.top = border.bottom = first; + border.left = border.right = first; + } + else + parsed = FALSE; + + if (parsed) + g_value_set_boxed (value, &border); + } else { g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); From 643abe312793ad45470e0a87fea792fa7b246eda Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 30 Aug 2010 22:35:30 +0200 Subject: [PATCH 286/634] GtkStyleSet: Register "margin" property. --- gtk/gtkstyleset.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 5c634100e0..101925a1cc 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -85,6 +85,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); + gtk_style_set_register_property ("margin", GTK_TYPE_BORDER, NULL, NULL); gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); From 58a51bca97ff8c366ef1f85353518b642c95fe8a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 30 Aug 2010 22:39:47 +0200 Subject: [PATCH 287/634] GtkStyle: Fill in x/ythickness and font_desc from the style context. --- gtk/gtkcssprovider.c | 1 + gtk/gtkstyle.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 9b257ca43f..941ff79018 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1783,6 +1783,7 @@ gtk_css_provider_get_default (void) " foreground-color: @fg_color;\n" " text-color: @text_color; \n" " base-color: @base_color; \n" + " padding: 2 2; \n" "}\n" "\n" "*:prelight {\n" diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index c4056702da..310da02ff4 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -685,6 +685,7 @@ gtk_style_update_from_context (GtkStyle *style) { GtkStylePrivate *priv; GtkStateType state; + GtkBorder *padding; priv = GTK_STYLE_GET_PRIVATE (style); @@ -696,7 +697,18 @@ gtk_style_update_from_context (GtkStyle *style) set_color (style, priv->context, state, GTK_RC_TEXT); } - /* FIXME: thickness, font_desc */ + if (style->font_desc) + pango_font_description_free (style->font_desc); + + gtk_style_context_get (priv->context, state, + "font", &style->font_desc, + "padding", &padding, + NULL); + + style->xthickness = padding->left; + style->ythickness = padding->top; + + gtk_border_free (padding); } static void From 621a95f515a97ff19f62db9d0aa561ee73276bd9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 30 Aug 2010 22:41:12 +0200 Subject: [PATCH 288/634] GtkSettings: implement GtkStyleProvider --- gtk/gtksettings.c | 76 +++++++++++++++++++++++++++++++++++++++++- gtk/gtkstyleprovider.h | 5 +-- gtk/gtkwidget.c | 6 ++++ 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 9b622254c2..ae9cf81983 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -179,6 +179,8 @@ enum { }; /* --- prototypes --- */ +static void gtk_settings_provider_iface_init (GtkStyleProviderIface *iface); + static void gtk_settings_finalize (GObject *object); static void gtk_settings_get_property (GObject *object, guint property_id, @@ -221,7 +223,9 @@ static GSList *object_list = NULL; static guint class_n_properties = 0; -G_DEFINE_TYPE (GtkSettings, gtk_settings, G_TYPE_OBJECT) +G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, + gtk_settings_provider_iface_init)); /* --- functions --- */ static void @@ -1246,6 +1250,76 @@ gtk_settings_class_init (GtkSettingsClass *class) g_assert (result == PROP_IM_STATUS_STYLE); } +static GtkStyleSet * +gtk_settings_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) +{ + PangoFontDescription *font_desc; + gchar *font_name, *color_scheme; + GtkSettings *settings; + GtkStyleSet *set; + gchar **colors; + guint i; + + settings = GTK_SETTINGS (provider); + set = gtk_style_set_new (); + + g_object_get (settings, + "gtk-font-name", &font_name, + "gtk-color-scheme", &color_scheme, + NULL); + + colors = g_strsplit_set (color_scheme, "\n;", -1); + + for (i = 0; colors[i]; i++) + { + gchar *name, *pos; + GdkColor col; + + if (!*colors[i]) + continue; + + name = colors[i]; + pos = strchr (colors[i], ':'); + + if (!pos) + continue; + + /* Set NUL after color name */ + *pos = '\0'; + pos++; + + /* Find start of color string */ + while (*pos == ' ') + pos++; + + if (!*pos || !gdk_color_parse (pos, &col)) + continue; + + gtk_style_set_map_color (set, name, + gtk_symbolic_color_new_literal (&col)); + } + + font_desc = pango_font_description_from_string (font_name); + + gtk_style_set_set (set, 0, + "font", font_desc, + NULL); + + pango_font_description_free (font_desc); + g_strfreev (colors); + g_free (color_scheme); + g_free (font_name); + + return set; +} + +static void +gtk_settings_provider_iface_init (GtkStyleProviderIface *iface) +{ + iface->get_style = gtk_settings_get_style; +} + static void gtk_settings_finalize (GObject *object) { diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 6c3a57561e..556b257405 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -35,8 +35,9 @@ G_BEGIN_DECLS #define GTK_STYLE_PROVIDER_PRIORITY_FALLBACK 1 #define GTK_STYLE_PROVIDER_PRIORITY_DEFAULT 200 -#define GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 400 -#define GTK_STYLE_PROVIDER_PRIORITY_USER 600 +#define GTK_STYLE_PROVIDER_PRIORITY_SETTINGS 400 +#define GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 600 +#define GTK_STYLE_PROVIDER_PRIORITY_USER 800 typedef struct GtkStyleProviderIface GtkStyleProviderIface; typedef struct GtkStyleProvider GtkStyleProvider; /* dummy typedef */ diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index cb053fad6b..8922eb9f7a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13308,6 +13308,7 @@ gtk_widget_get_style_context (GtkWidget *widget) static GtkCssProvider *css_provider = NULL; GtkCssProvider *default_provider; GtkWidgetPath *path; + GtkSettings *settings; context = g_object_new (GTK_TYPE_STYLE_CONTEXT, "direction", gtk_widget_get_direction (widget), @@ -13347,6 +13348,11 @@ gtk_widget_get_style_context (GtkWidget *widget) GTK_STYLE_PROVIDER (default_provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); + settings = gtk_widget_get_settings (widget); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (settings), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + path = gtk_widget_get_path (widget); gtk_style_context_set_path (context, path); gtk_widget_path_free (path); From 02a30118c6110bc7906602adf1c38622d520f7de Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 01:45:17 +0200 Subject: [PATCH 289/634] Add a boxed type for cairo_pattern_t. --- gdk/gdkcairo.c | 2 ++ gdk/gdkcairo.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 0d4b8bde09..60ac621943 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -25,6 +25,8 @@ #include +G_DEFINE_BOXED_TYPE (cairo_pattern_t, gdk_cairo_pattern, cairo_pattern_reference, cairo_pattern_destroy) + /** * SECTION:cairo_interaction * @Short_description: Functions to support using Cairo diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h index 67e08aa933..836c0be079 100644 --- a/gdk/gdkcairo.h +++ b/gdk/gdkcairo.h @@ -32,6 +32,9 @@ G_BEGIN_DECLS cairo_t *gdk_cairo_create (GdkWindow *window); +#define GDK_TYPE_CAIRO_PATTERN (gdk_cairo_pattern_get_type ()) + +GType gdk_cairo_pattern_get_type (void) G_GNUC_CONST; gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr, GdkRectangle *rect); From f12d7409cc1273781ec3b15a10e76fdba941ce11 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 01:48:24 +0200 Subject: [PATCH 290/634] Allow linefeeds in property values. --- gtk/gtkcssprovider.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 941ff79018..5e8ef5667b 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -765,7 +765,7 @@ css_provider_apply_scope (GtkCssProvider *css_provider, if (scope == SCOPE_VALUE) { priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),." G_CSET_A_2_Z; + priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\n" G_CSET_A_2_Z; priv->scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) @@ -1137,7 +1137,7 @@ parse_selector (GtkCssProvider *css_provider, return G_TOKEN_NONE; } -#define SKIP_SPACES(s) while (s[0] == ' ') s++; +#define SKIP_SPACES(s) while (s[0] == ' ' || s[0] == '\t' || s[0] == '\n') s++; static GtkSymbolicColor * symbolic_color_parse_str (const gchar *string, From c908e263ac8b76b3ad5819f41919a177df33525c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 01:49:59 +0200 Subject: [PATCH 291/634] GtkCssProvider: strip whitespaces in symbolic color values. --- gtk/gtkcssprovider.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 5e8ef5667b..c64ab88729 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1465,7 +1465,7 @@ parse_rule (GtkCssProvider *css_provider, scanner->value.v_identifier[0] == '@') { GtkSymbolicColor *color; - gchar *color_name; + gchar *color_name, *color_str; /* Rule is a color mapping */ color_name = g_strdup (&scanner->value.v_identifier[1]); @@ -1480,7 +1480,8 @@ parse_rule (GtkCssProvider *css_provider, if (scanner->token != G_TOKEN_IDENTIFIER) return G_TOKEN_IDENTIFIER; - color = symbolic_color_parse (scanner->value.v_identifier); + color_str = g_strstrip (scanner->value.v_identifier); + color = symbolic_color_parse (color_str); if (!color) return G_TOKEN_IDENTIFIER; From 74de1839a4ebf88a22e6e21bcf2ad8403ca5d31d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 01:58:48 +0200 Subject: [PATCH 292/634] GtkStyleSet: Set an empty default_value if none is provided. --- gtk/gtkstyleset.c | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 101925a1cc..755d66e1b0 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -355,6 +355,8 @@ gtk_style_set_register_property (const gchar *property_name, g_value_init (&new.default_value, G_VALUE_TYPE (default_value)); g_value_copy (default_value, &new.default_value); } + else + g_value_init (&new.default_value, type); if (parse_func) new.parse_func = parse_func; @@ -650,7 +652,7 @@ gtk_style_set_get_property (GtkStyleSet *set, val = property_data_match_state (prop, state); - if (!val && G_IS_VALUE (&node->default_value)) + if (!val) val = &node->default_value; g_return_val_if_fail (G_IS_VALUE (val), FALSE); @@ -686,6 +688,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, PropertyNode *node; PropertyData *prop; gchar *error = NULL; + GValue *val = NULL; node = property_node_lookup (g_quark_try_string (property_name)); @@ -698,36 +701,22 @@ gtk_style_set_get_valist (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop && !G_IS_VALUE (&node->default_value)) + if (prop) + val = property_data_match_state (prop, state); + + if (!val) + val = &node->default_value; + + if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - GValue *empty_value = { 0 }; + g_return_if_fail (node->property_type == GDK_TYPE_COLOR); - g_warning ("No value for style property \"%s\"", property_name); - - g_value_init (&empty_value, node->property_type); - G_VALUE_LCOPY (&empty_value, args, 0, &error); - } - else - { - GValue *val = NULL; - - if (prop) - val = property_data_match_state (prop, state); - - if (!val && G_IS_VALUE (&node->default_value)) + if (!resolve_color (set, val)) val = &node->default_value; - - if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) - { - g_return_if_fail (node->property_type == GDK_TYPE_COLOR); - - if (!resolve_color (set, val)) - return; - } - - G_VALUE_LCOPY (val, args, 0, &error); } + G_VALUE_LCOPY (val, args, 0, &error); + if (error) { g_warning ("Could not get style property \"%s\": %s", property_name, error); From 142a72637dc996be7f45462b8e2a5e379e54019b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 02:01:01 +0200 Subject: [PATCH 293/634] Add GtkGradient. This type defines a gradient between 2 symbolic colors, with any number of color stop between these. At the moment it has been put besides GtkSymbolicColor, although should be completely private, it will likely need extending in the future for radial gradients. At some point, it maybe should also be used for images, so painting both a gradient and an image is consistent. --- gtk/gtkstyleset.h | 3 + gtk/gtksymboliccolor.c | 132 +++++++++++++++++++++++++++++++++++++++++ gtk/gtksymboliccolor.h | 16 ++++- 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index 8b8750c588..f81881a596 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -106,6 +106,9 @@ void gtk_style_set_merge (GtkStyleSet *set, gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, GtkStyleSet *style_set, GdkColor *resolved_color); +gboolean gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleSet *style_set, + cairo_pattern_t **resolved_gradient); G_END_DECLS diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 9b9386b4cd..5710218102 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -22,6 +22,9 @@ #include "gtkstyleset.h" #include "gtkintl.h" +G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient, + gtk_gradient_ref, gtk_gradient_unref) + /* Symbolic colors */ typedef enum { COLOR_TYPE_LITERAL, @@ -55,6 +58,26 @@ struct GtkSymbolicColor }; }; +typedef struct ColorStop ColorStop; + +struct ColorStop +{ + gdouble offset; + GtkSymbolicColor *color; +}; + +struct GtkGradient +{ + gdouble x0; + gdouble y0; + gdouble x1; + gdouble y1; + + GArray *stops; + + guint ref_count; +}; + GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkColor *color) { @@ -240,3 +263,112 @@ gtk_symbolic_color_get_type (void) return type; } + +/* GtkGradient */ +GtkGradient * +gtk_gradient_new_linear (gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + GtkGradient *gradient; + + gradient = g_slice_new (GtkGradient); + gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); + + gradient->x0 = x0; + gradient->y0 = y0; + gradient->x1 = x1; + gradient->y1 = y1; + + gradient->ref_count = 1; + + return gradient; +} + +void +gtk_gradient_add_color_stop (GtkGradient *gradient, + gdouble offset, + GtkSymbolicColor *color) +{ + ColorStop stop; + + g_return_if_fail (gradient != NULL); + + stop.offset = offset; + stop.color = gtk_symbolic_color_ref (color); + + g_array_append_val (gradient->stops, stop); +} + +GtkGradient * +gtk_gradient_ref (GtkGradient *gradient) +{ + g_return_val_if_fail (gradient != NULL, NULL); + + gradient->ref_count++; + + return gradient; +} + +void +gtk_gradient_unref (GtkGradient *gradient) +{ + g_return_if_fail (gradient != NULL); + + gradient->ref_count--; + + if (gradient->ref_count == 0) + { + guint i; + + for (i = 0; i < gradient->stops->len; i++) + { + ColorStop *stop; + + stop = &g_array_index (gradient->stops, ColorStop, i); + gtk_symbolic_color_unref (stop->color); + } + + g_array_free (gradient->stops, TRUE); + g_slice_free (GtkGradient, gradient); + } +} + +gboolean +gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleSet *style_set, + cairo_pattern_t **resolved_gradient) +{ + cairo_pattern_t *pattern; + guint i; + + g_return_val_if_fail (gradient != NULL, FALSE); + g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); + g_return_val_if_fail (resolved_gradient != NULL, FALSE); + + pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0, + gradient->x1, gradient->y1); + + for (i = 0; i < gradient->stops->len; i++) + { + ColorStop *stop; + GdkColor color; + + stop = &g_array_index (gradient->stops, ColorStop, i); + + if (!gtk_symbolic_color_resolve (stop->color, style_set, &color)) + { + cairo_pattern_destroy (pattern); + return FALSE; + } + + cairo_pattern_add_color_stop_rgb (pattern, stop->offset, + color.red / 65535., + color.green / 65535., + color.blue / 65535.); + } + + *resolved_gradient = pattern; + return TRUE; +} diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index 8b3608bf21..aedd2aa28e 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -26,11 +26,13 @@ G_BEGIN_DECLS /* Dummy typedefs */ typedef struct GtkSymbolicColor GtkSymbolicColor; -typedef struct GtkSymbolicColorMap GtkSymbolicColorMap; +typedef struct GtkGradient GtkGradient; #define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ()) +#define GTK_TYPE_GRADIENT (gtk_gradient_get_type ()) GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; +GType gtk_gradient_get_type (void) G_GNUC_CONST; GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkColor *color); GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); @@ -43,6 +45,18 @@ GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); void gtk_symbolic_color_unref (GtkSymbolicColor *color); +GtkGradient * gtk_gradient_new_linear (gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); + +void gtk_gradient_add_color_stop (GtkGradient *gradient, + gdouble offset, + GtkSymbolicColor *color); + +GtkGradient * gtk_gradient_ref (GtkGradient *gradient); +void gtk_gradient_unref (GtkGradient *gradient); + G_END_DECLS #endif /* __GTK_SYMBOLIC_COLOR_H__ */ From 3fc5c87bcb4505a4d63e2163d1e2e1c6775cc0f1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 02:06:05 +0200 Subject: [PATCH 294/634] GtkCssProvider: Add a parser for gradients. --- gtk/gtkcssprovider.c | 246 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 244 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index c64ab88729..a4a1af7373 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1312,8 +1312,6 @@ symbolic_color_parse_str (const gchar *string, return symbolic_color; } -#undef SKIP_SPACES - static GtkSymbolicColor * symbolic_color_parse (const gchar *str) { @@ -1337,6 +1335,235 @@ symbolic_color_parse (const gchar *str) return color; } +static GtkGradient * +gradient_parse_str (const gchar *str, + gchar **end_ptr) +{ + GtkGradient *gradient = NULL; + + if (g_str_has_prefix (str, "-gtk-gradient")) + { + cairo_pattern_type_t type; + + str += strlen ("-gtk-gradient"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + + /* Parse gradient type */ + if (g_str_has_prefix (str, "linear")) + { + type = CAIRO_PATTERN_TYPE_LINEAR; + str += strlen ("linear"); + } + else if (g_str_has_prefix (str, "radial")) + { + type = CAIRO_PATTERN_TYPE_RADIAL; + str += strlen ("radial"); + } + else + { + *end_ptr = (gchar *) str; + return NULL; + } + + SKIP_SPACES (str); + + if (type == CAIRO_PATTERN_TYPE_LINEAR) + { + gdouble coords[4]; + gchar *end; + guint i; + + /* Parse start/stop position parameters */ + for (i = 0; i < 2; i++) + { + if (*str != ',') + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + + if (g_str_has_prefix (str, "left")) + { + coords[i * 2] = 0; + str += strlen ("left"); + } + else if (g_str_has_prefix (str, "right")) + { + coords[i * 2] = 1; + str += strlen ("right"); + } + else + { + coords[i * 2] = g_ascii_strtod (str, &end); + str = end; + } + + SKIP_SPACES (str); + + if (g_str_has_prefix (str, "top")) + { + coords[(i * 2) + 1] = 0; + str += strlen ("top"); + } + else if (g_str_has_prefix (str, "bottom")) + { + coords[(i * 2) + 1] = 1; + str += strlen ("bottom"); + } + else + { + coords[(i * 2) + 1] = g_ascii_strtod (str, &end); + str = end; + } + + SKIP_SPACES (str); + } + + gradient = gtk_gradient_new_linear (coords[0], coords[1], coords[2], coords[3]); + + while (*str == ',') + { + GtkSymbolicColor *color; + gdouble position; + + if (*str != ',') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + if (g_str_has_prefix (str, "from")) + { + position = 0; + str += strlen ("from"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + } + else if (g_str_has_prefix (str, "to")) + { + position = 1; + str += strlen ("to"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + } + else if (g_str_has_prefix (str, "color-stop")) + { + str += strlen ("color-stop"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + position = g_strtod (str, &end); + + str = end; + SKIP_SPACES (str); + + if (*str != ',') + { + *end_ptr = (gchar *) str; + return gradient; + } + } + else + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + color = symbolic_color_parse_str (str, &end); + + str = end; + SKIP_SPACES (str); + + if (*str != ')') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + if (color) + { + gtk_gradient_add_color_stop (gradient, position, color); + gtk_symbolic_color_unref (color); + } + } + + if (*str != ')') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + } + } + + *end_ptr = (gchar *) str; + + return gradient; +} + +static GtkGradient * +gradient_parse (const gchar *str) +{ + GtkGradient *gradient; + gchar *end; + + gradient = gradient_parse_str (str, &end); + + if (*end != '\0') + { + g_warning ("Error parsing pattern \"%s\", stopped at char %ld : '%c'", + str, end - str, *end); + + if (gradient) + { + gtk_gradient_unref (gradient); + gradient = NULL; + } + } + + return gradient; +} + static gboolean css_provider_parse_value (const gchar *value_str, GValue *value) @@ -1440,6 +1667,21 @@ css_provider_parse_value (const gchar *value_str, if (parsed) g_value_set_boxed (value, &border); } + else if (type == GDK_TYPE_CAIRO_PATTERN) + { + GtkGradient *gradient; + + gradient = gradient_parse (value_str); + + if (gradient) + { + g_value_unset (value); + g_value_init (value, GTK_TYPE_GRADIENT); + g_value_take_boxed (value, gradient); + } + else + parsed = FALSE; + } else { g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); From cf87923d1bc3ef1e5fad75b969b91c64f6f56840 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 02:11:12 +0200 Subject: [PATCH 295/634] GtkStyleSet: Handle GtkGradients as a replacement for cairo_pattern_t The former will handle GtkSymbolicColors, which will be resolved and cached at query time. --- gtk/gtkstyleset.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 755d66e1b0..a7851ad66e 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -497,6 +497,12 @@ gtk_style_set_set_property (GtkStyleSet *set, /* Allow GtkSymbolicColor as well */ g_return_if_fail (value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); } + else if (node->property_type == GDK_TYPE_CAIRO_PATTERN) + { + /* Allow GtkGradient as a substitute */ + g_return_if_fail (value_type == GDK_TYPE_CAIRO_PATTERN || + value_type == GTK_TYPE_GRADIENT); + } else g_return_if_fail (node->property_type == value_type); @@ -618,6 +624,23 @@ resolve_color (GtkStyleSet *set, return TRUE; } +static gboolean +resolve_gradient (GtkStyleSet *set, + GValue *value) +{ + cairo_pattern_t *gradient; + + if (!gtk_gradient_resolve (g_value_get_boxed (value), set, &gradient)) + return FALSE; + + /* Store it back, this is where cairo_pattern_t caching happens */ + g_value_unset (value); + g_value_init (value, GDK_TYPE_CAIRO_PATTERN); + g_value_take_boxed (value, gradient); + + return TRUE; +} + gboolean gtk_style_set_get_property (GtkStyleSet *set, const gchar *property, @@ -664,6 +687,13 @@ gtk_style_set_get_property (GtkStyleSet *set, if (!resolve_color (set, val)) return FALSE; } + else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) + { + g_return_val_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN, FALSE); + + if (!resolve_gradient (set, val)) + return FALSE; + } g_value_copy (val, value); @@ -714,6 +744,13 @@ gtk_style_set_get_valist (GtkStyleSet *set, if (!resolve_color (set, val)) val = &node->default_value; } + else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) + { + g_return_val_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN, FALSE); + + if (!resolve_gradient (set, val)) + val = &node->default_value; + } G_VALUE_LCOPY (val, args, 0, &error); From 2794e8d6ddb0b78f11c9abd91ba6880fbdd6f442 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 02:12:26 +0200 Subject: [PATCH 296/634] GtkStyleSet: Register a "background-image" property. Ironically, it currently just handles gradients, the name is to conform to current CSS gradient implementation trends. --- gtk/gtkstyleset.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index a7851ad66e..fb8486c475 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -89,6 +89,8 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); + gtk_style_set_register_property ("background-image", GDK_TYPE_CAIRO_PATTERN, NULL, NULL); + g_value_init (&val, GTK_TYPE_THEMING_ENGINE); g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); From 58b6e538c97afc7a21c430e8d8e6f4879a14b574 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 02:14:10 +0200 Subject: [PATCH 297/634] GtkThemingEngine: use background-image in render_background() --- gtk/gtkthemingengine.c | 52 +++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b37a388564..5a2285aad7 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -892,28 +892,47 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble width, gdouble height) { + GdkColor *bg_color, *base_color; + cairo_pattern_t *pattern; GtkStateFlags flags; - GdkColor *color; - cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - - if (gtk_theming_engine_has_class (engine, "entry")) - gtk_theming_engine_get (engine, flags, - "base-color", &color, - NULL); - else - gtk_theming_engine_get (engine, flags, - "background-color", &color, - NULL); - - gdk_cairo_set_source_color (cr, color); + cairo_save (cr); if (gtk_theming_engine_has_class (engine, "spinbutton") && gtk_theming_engine_has_class (engine, "button")) - cairo_rectangle (cr, x + 2, y + 2, width - 4, height - 4); + { + x += 2; + y += 2; + width -= 4; + height -= 4; + } + + gtk_theming_engine_get (engine, flags, + "background-image", &pattern, + "background-color", &bg_color, + "base-color", &base_color, + NULL); + + if (pattern) + { + cairo_translate (cr, x, y); + cairo_scale (cr, width, height); + + cairo_rectangle (cr, 0, 0, 1, 1); + cairo_set_source (cr, pattern); + + cairo_pattern_destroy (pattern); + } else - cairo_rectangle (cr, x, y, width, height); + { + if (gtk_theming_engine_has_class (engine, "entry")) + gdk_cairo_set_source_color (cr, base_color); + else + gdk_cairo_set_source_color (cr, bg_color); + + cairo_rectangle (cr, x, y, width, height); + } if (gtk_theming_engine_has_class (engine, "tooltip")) { @@ -927,7 +946,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (color); + gdk_color_free (base_color); + gdk_color_free (bg_color); } static void From 756bbf526f60e8007f21375a0c9bc97586afeb82 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:10:25 +0200 Subject: [PATCH 298/634] GtkStyleSet: Fix typo --- gtk/gtkstyleset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index fb8486c475..cd1c8dfb2a 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -748,7 +748,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { - g_return_val_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN, FALSE); + g_return_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN); if (!resolve_gradient (set, val)) val = &node->default_value; From 9f84e101bf150a85f82e15c56130b1f98b8fdbf0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:18:26 +0200 Subject: [PATCH 299/634] GtkStyleContext: Add gtk_style_context_invalidate(). This function will regenerate all styling information. --- gtk/gtkstylecontext.c | 47 ++++++++++++++++++++++++++++++++++++++++++- gtk/gtkstylecontext.h | 5 +++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 148dbd4594..c738e910e7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -97,7 +97,9 @@ struct GtkStyleContextPrivate GSList *animation_regions; GSList *animations; - gboolean animations_invalidated; + + guint animations_invalidated : 1; + guint invalidating_context : 1; GtkThemingEngine *theming_engine; @@ -110,6 +112,13 @@ enum { PROP_DIRECTION }; +enum { + CHANGED, + LAST_SIGNAL +}; + +guint signals[LAST_SIGNAL] = { 0 }; + static void gtk_style_context_finalize (GObject *object); static void gtk_style_context_impl_set_property (GObject *object, @@ -133,6 +142,15 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) object_class->set_property = gtk_style_context_impl_set_property; object_class->get_property = gtk_style_context_impl_get_property; + signals[CHANGED] = + g_signal_new (I_("changed"), + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GtkStyleContextClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + g_object_class_install_property (object_class, PROP_SCREEN, g_param_spec_object ("screen", @@ -1798,6 +1816,33 @@ store_animation_region (GtkStyleContext *context, } } +void +gtk_style_context_invalidate (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + + /* Avoid reentrancy */ + if (priv->invalidating_context) + return; + + if (!priv->widget_path) + return; + + priv->invalidating_context = TRUE; + + rebuild_properties (context); + clear_property_cache (context); + rebuild_icon_factories (context); + + g_signal_emit (context, signals[CHANGED], 0); + + priv->invalidating_context = FALSE; +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 020368c0a0..fba6028f50 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -45,6 +45,8 @@ struct GtkStyleContext struct GtkStyleContextClass { GObjectClass parent_class; + + void (* changed) (GtkStyleContext *context); }; GType gtk_style_context_get_type (void) G_GNUC_CONST; @@ -160,6 +162,9 @@ void gtk_style_context_state_transition_update (GtkStyleContext *context, void gtk_style_context_state_transition_stop (GtkStyleContext *context, gpointer identifier); +void gtk_style_context_invalidate (GtkStyleContext *context); + + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, From 77ccdfc94e721d8b1d27b2a718e1b376d38ecaa0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:10:50 +0200 Subject: [PATCH 300/634] GtkStyle: Protect against padding being NULL --- gtk/gtkstyle.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 310da02ff4..8f495a795d 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -705,10 +705,13 @@ gtk_style_update_from_context (GtkStyle *style) "padding", &padding, NULL); - style->xthickness = padding->left; - style->ythickness = padding->top; + if (padding) + { + style->xthickness = padding->left; + style->ythickness = padding->top; - gtk_border_free (padding); + gtk_border_free (padding); + } } static void From 3c390c9c8e2889f38b9a11d98b7e33b2b9e573ca Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:36:54 +0200 Subject: [PATCH 301/634] GtkWidget: Add the style-updated signal This signal is emitted whenever the widget's style changes. --- gtk/gtkwidget.c | 34 ++++++++++++++++++++++++++++++++++ gtk/gtkwidget.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8922eb9f7a..91c42a0715 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -445,6 +445,7 @@ enum { COMPOSITED_CHANGED, QUERY_TOOLTIP, DRAG_FAILED, + STYLE_UPDATED, LAST_SIGNAL }; @@ -531,6 +532,7 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget, gint y, gboolean keyboard_tip, GtkTooltip *tooltip); +static void gtk_widget_real_style_updated (GtkWidget *widget); static gboolean gtk_widget_real_show_help (GtkWidget *widget, GtkWidgetHelpType help_type); @@ -863,6 +865,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->can_activate_accel = gtk_widget_real_can_activate_accel; klass->grab_broken_event = NULL; klass->query_tooltip = gtk_widget_real_query_tooltip; + klass->style_updated = gtk_widget_real_style_updated; klass->show_help = gtk_widget_real_show_help; @@ -1499,6 +1502,15 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_TYPE_NONE, 1, GTK_TYPE_STYLE); + widget_signals[STYLE_UPDATED] = + g_signal_new (I_("style-updated"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GtkWidgetClass, style_updated), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + /** * GtkWidget::direction-changed: * @widget: the object on which the signal is emitted @@ -6219,6 +6231,17 @@ gtk_widget_real_query_tooltip (GtkWidget *widget, return FALSE; } +static void +gtk_widget_real_style_updated (GtkWidget *widget) +{ + GtkStyleContext *context; + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + if (context) + gtk_style_context_invalidate (context); +} + static gboolean gtk_widget_real_show_help (GtkWidget *widget, GtkWidgetHelpType help_type) @@ -13293,6 +13316,15 @@ gtk_widget_get_path (GtkWidget *widget) return path; } +static void +style_context_changed (GtkStyleContext *context, + gpointer user_data) +{ + GtkWidget *widget = user_data; + + g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0); +} + GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget) { @@ -13314,6 +13346,8 @@ gtk_widget_get_style_context (GtkWidget *widget) "direction", gtk_widget_get_direction (widget), NULL); + g_signal_connect (context, "changed", + G_CALLBACK (style_context_changed), widget); g_object_set_qdata_full (G_OBJECT (widget), quark_style_context, context, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index e522b2b9b8..c247f364cd 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -416,6 +416,8 @@ struct _GtkWidgetClass gint *allocated_pos, gint *allocated_size); + void (* style_updated) (GtkWidget *widget); + /*< private >*/ /* Padding for future expansion */ From f23970409448c8937491caaea1765b52d4b04c24 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:40:31 +0200 Subject: [PATCH 302/634] GtkWidget: Add gtk_widget_reset_style(). This function is analogous to gtk_widget_reset_rc_styles(), updates style recursively on a widget. --- gtk/gtkwidget.c | 22 +++++++++++++++++++--- gtk/gtkwidget.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 91c42a0715..3673fea878 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8125,17 +8125,33 @@ _gtk_widget_propagate_screen_changed (GtkWidget *widget, } static void -reset_rc_styles_recurse (GtkWidget *widget, gpointer data) +reset_style_recurse (GtkWidget *widget, gpointer data) { + GtkStyleContext *context; + +#if 0 if (widget->priv->rc_style) gtk_widget_reset_rc_style (widget); +#endif + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + if (context) + gtk_style_context_invalidate (context); if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), - reset_rc_styles_recurse, + reset_style_recurse, NULL); } +void +gtk_widget_reset_style (GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + reset_style_recurse (widget, NULL); +} /** * gtk_widget_reset_rc_styles: @@ -8152,7 +8168,7 @@ gtk_widget_reset_rc_styles (GtkWidget *widget) { g_return_if_fail (GTK_IS_WIDGET (widget)); - reset_rc_styles_recurse (widget, NULL); + reset_style_recurse (widget, NULL); } /** diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index c247f364cd..125d315b7a 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -803,6 +803,8 @@ gchar* gtk_widget_get_composite_name (GtkWidget *widget); /* Descend recursively and set rc-style on all widgets without user styles */ void gtk_widget_reset_rc_styles (GtkWidget *widget); +void gtk_widget_reset_style (GtkWidget *widget); + /* Push/pop pairs, to change default values upon a widget's creation. * This will override the values that got set by the * gtk_widget_set_default_* () functions. From 49ac732a184136b759b65eaaa56e5fef11df7e2b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:42:35 +0200 Subject: [PATCH 303/634] GtkStyleContext: Add gtk_style_context_[add|remove]_provider_for_screen() These functions allow per-screen style providers. also, the changed signal will be emitted whenever a style context changes. --- gtk/gtkstylecontext.c | 249 ++++++++++++++++++++++++++++++------------ gtk/gtkstylecontext.h | 6 + 2 files changed, 186 insertions(+), 69 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c738e910e7..106f78ae22 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -28,6 +28,7 @@ #include "gtkthemingengine.h" #include "gtkintl.h" #include "gtkwidget.h" +#include "gtkwindow.h" #include "gtkprivate.h" #include "gtkanimationdescription.h" #include "gtktimeline.h" @@ -119,6 +120,8 @@ enum { guint signals[LAST_SIGNAL] = { 0 }; +static GQuark provider_list_quark = 0; + static void gtk_style_context_finalize (GObject *object); static void gtk_style_context_impl_set_property (GObject *object, @@ -484,24 +487,55 @@ gtk_style_context_impl_get_property (GObject *object, } } +GList * +find_next_candidate (GList *local, + GList *global) +{ + if (local && global) + { + GtkStyleProviderData *local_data, *global_data; + + local_data = local->data; + global_data = global->data; + + if (local_data->priority >= global_data->priority) + return local; + else + return global; + } + else if (local) + return local; + else if (global) + return global; + + return NULL; +} + static void rebuild_properties (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GList *list; + GList *elem, *list, *global_list = NULL; priv = context->priv; list = priv->providers; + if (priv->screen) + global_list = g_object_get_qdata (G_OBJECT (priv->screen), provider_list_quark); + gtk_style_set_clear (priv->store); - while (list) + while ((elem = find_next_candidate (list, global_list)) != NULL) { GtkStyleProviderData *data; GtkStyleSet *provider_style; - data = list->data; - list = list->next; + data = elem->data; + + if (elem == list) + list = list->next; + else + global_list = global_list->next; provider_style = gtk_style_provider_get_style (data->provider, priv->widget_path); @@ -525,7 +559,7 @@ static void rebuild_icon_factories (GtkStyleContext *context) { GtkStyleContextPrivate *priv; - GList *providers; + GList *elem, *list, *global_list = NULL; priv = context->priv; @@ -533,12 +567,26 @@ rebuild_icon_factories (GtkStyleContext *context) g_slist_free (priv->icon_factories); priv->icon_factories = NULL; - for (providers = priv->providers_last; providers; providers = providers->prev) + list = priv->providers_last; + + if (priv->screen) + { + global_list = g_object_get_qdata (G_OBJECT (priv->screen), provider_list_quark); + global_list = g_list_last (global_list); + } + + while ((elem = find_next_candidate (list, global_list)) != NULL) { GtkIconFactory *factory; GtkStyleProviderData *data; - data = providers->data; + data = elem->data; + + if (elem == list) + list = list->prev; + else + global_list = global_list->prev; + factory = gtk_style_provider_get_icon_factory (data->provider, priv->widget_path); @@ -547,28 +595,22 @@ rebuild_icon_factories (GtkStyleContext *context) } } -void -gtk_style_context_add_provider (GtkStyleContext *context, - GtkStyleProvider *provider, - guint priority) +static void +style_provider_add (GList **list, + GtkStyleProvider *provider, + guint priority) { - GtkStyleContextPrivate *priv; GtkStyleProviderData *new_data; gboolean added = FALSE; - GList *list; + GList *l = *list; - g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); - - priv = context->priv; new_data = style_provider_data_new (provider, priority); - list = priv->providers; - while (list) + while (l) { GtkStyleProviderData *data; - data = list->data; + data = l->data; /* Provider was already attached to the style * context, remove in order to add the new data @@ -577,11 +619,11 @@ gtk_style_context_add_provider (GtkStyleContext *context, { GList *link; - link = list; - list = list->next; + link = l; + l = l->next; /* Remove and free link */ - priv->providers = g_list_remove_link (priv->providers, link); + *list = g_list_remove_link (*list, link); style_provider_data_free (link->data); g_list_free_1 (link); @@ -591,24 +633,59 @@ gtk_style_context_add_provider (GtkStyleContext *context, if (!added && data->priority > priority) { - priv->providers = g_list_insert_before (priv->providers, list, new_data); + *list = g_list_insert_before (*list, l, new_data); added = TRUE; } - list = list->next; + l = l->next; } if (!added) - priv->providers = g_list_append (priv->providers, new_data); + *list = g_list_append (*list, new_data); +} +static gboolean +style_provider_remove (GList **list, + GtkStyleProvider *provider) +{ + GList *l = *list; + + while (l) + { + GtkStyleProviderData *data; + + data = l->data; + + if (data->provider == provider) + { + *list = g_list_remove_link (*list, l); + style_provider_data_free (l->data); + g_list_free_1 (l); + + return TRUE; + } + + l = l->next; + } + + return FALSE; +} + +void +gtk_style_context_add_provider (GtkStyleContext *context, + GtkStyleProvider *provider, + guint priority) +{ + GtkStyleContextPrivate *priv; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); + + priv = context->priv; + style_provider_add (&priv->providers, provider, priority); priv->providers_last = g_list_last (priv->providers); - if (priv->widget_path) - { - rebuild_properties (context); - clear_property_cache (context); - rebuild_icon_factories (context); - } + gtk_style_context_invalidate (context); } void @@ -616,45 +693,81 @@ gtk_style_context_remove_provider (GtkStyleContext *context, GtkStyleProvider *provider) { GtkStyleContextPrivate *priv; - gboolean removed = FALSE; - GList *list; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); priv = context->priv; - list = priv->providers; - while (list) - { - GtkStyleProviderData *data; - - data = list->data; - - if (data->provider == provider) - { - priv->providers = g_list_remove_link (priv->providers, list); - style_provider_data_free (list->data); - g_list_free_1 (list); - - removed = TRUE; - - break; - } - - list = list->next; - } - - if (removed) + if (style_provider_remove (&priv->providers, provider)) { priv->providers_last = g_list_last (priv->providers); - if (priv->widget_path) - { - rebuild_properties (context); - clear_property_cache (context); - rebuild_icon_factories (context); - } + gtk_style_context_invalidate (context); + } +} + +static void +reset_toplevels (GdkScreen *screen) +{ + GList *list, *toplevels; + + toplevels = gtk_window_list_toplevels (); + g_list_foreach (toplevels, (GFunc)g_object_ref, NULL); + + for (list = toplevels; list; list = list->next) + { + if (gtk_widget_get_screen (list->data) == screen) + gtk_widget_reset_style (list->data); + + g_object_unref (list->data); + } + + g_list_free (toplevels); +} + +void +gtk_style_context_add_provider_for_screen (GdkScreen *screen, + GtkStyleProvider *provider, + guint priority) +{ + GList *providers, *list; + + g_return_if_fail (GDK_IS_SCREEN (screen)); + g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); + + if (G_UNLIKELY (!provider_list_quark)) + provider_list_quark = g_quark_from_static_string ("gtk-provider-list-quark"); + + list = providers = g_object_get_qdata (G_OBJECT (screen), provider_list_quark); + style_provider_add (&list, provider, priority); + + if (list != providers) + g_object_set_qdata (G_OBJECT (screen), provider_list_quark, list); + + reset_toplevels (screen); +} + +void +gtk_style_context_remove_provider_for_screen (GdkScreen *screen, + GtkStyleProvider *provider) +{ + GList *providers, *list; + + g_return_if_fail (GDK_IS_SCREEN (screen)); + g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); + + if (G_UNLIKELY (!provider_list_quark)) + return; + + list = providers = g_object_get_qdata (G_OBJECT (screen), provider_list_quark); + + if (style_provider_remove (&list, provider)) + { + if (list != providers) + g_object_set_qdata (G_OBJECT (screen), provider_list_quark, list); + + reset_toplevels (screen); } } @@ -833,9 +946,7 @@ gtk_style_context_set_path (GtkStyleContext *context, if (path) { priv->widget_path = gtk_widget_path_copy (path); - rebuild_properties (context); - clear_property_cache (context); - rebuild_icon_factories (context); + gtk_style_context_invalidate (context); } } @@ -1040,7 +1151,7 @@ gtk_style_context_set_class (GtkStyleContext *context, if (priv->widget_path) { gtk_widget_path_iter_add_class (priv->widget_path, 0, class_name); - rebuild_properties (context); + gtk_style_context_invalidate (context); } } } @@ -1074,7 +1185,7 @@ gtk_style_context_unset_class (GtkStyleContext *context, if (priv->widget_path) { gtk_widget_path_iter_remove_class (priv->widget_path, 0, class_name); - rebuild_properties (context); + gtk_style_context_invalidate (context); } } } @@ -1192,7 +1303,7 @@ gtk_style_context_set_region (GtkStyleContext *context, if (priv->widget_path) { gtk_widget_path_iter_add_region (priv->widget_path, 0, class_name, flags); - rebuild_properties (context); + gtk_style_context_invalidate (context); } } } @@ -1226,7 +1337,7 @@ gtk_style_context_unset_region (GtkStyleContext *context, if (priv->widget_path) { gtk_widget_path_iter_remove_region (priv->widget_path, 0, class_name); - rebuild_properties (context); + gtk_style_context_invalidate (context); } } } diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index fba6028f50..07cec5b71f 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -51,6 +51,12 @@ struct GtkStyleContextClass GType gtk_style_context_get_type (void) G_GNUC_CONST; +void gtk_style_context_add_provider_for_screen (GdkScreen *screen, + GtkStyleProvider *provider, + guint priority); +void gtk_style_context_remove_provider_for_screen (GdkScreen *screen, + GtkStyleProvider *provider); + void gtk_style_context_add_provider (GtkStyleContext *context, GtkStyleProvider *provider, guint priority); From 8dfa0e03eac790398e6e05ca99238731fc7a7dea Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:45:42 +0200 Subject: [PATCH 304/634] GtkWidget: Set style context's screen before the widget_path. This is so the style context has all necessary information before triggering a style change on setting the path. --- gtk/gtkwidget.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3673fea878..6bc665c17f 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13402,13 +13402,12 @@ gtk_widget_get_style_context (GtkWidget *widget) gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (settings), GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + gtk_style_context_set_screen (context, + gtk_widget_get_screen (widget)); path = gtk_widget_get_path (widget); gtk_style_context_set_path (context, path); gtk_widget_path_free (path); - - gtk_style_context_set_screen (context, - gtk_widget_get_screen (widget)); } return context; From 1e66155aec1964bc441a10e30a49b9441f2c8b3a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:47:31 +0200 Subject: [PATCH 305/634] GtkStyleContext: invalidate context when setting the screen --- gtk/gtkstylecontext.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 106f78ae22..522a3e2549 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1615,6 +1615,8 @@ gtk_style_context_set_screen (GtkStyleContext *context, priv->screen = screen; g_object_notify (G_OBJECT (context), "screen"); + + gtk_style_context_invalidate (context); } GdkScreen * From a07fe2c0e6d2dae404da866f741bd41fb833e52e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 11 Sep 2010 12:48:27 +0200 Subject: [PATCH 306/634] Add generic providers per-screen. The providers are added as soon as gtk GtkSettings object for the screen is created. --- gtk/gtksettings.c | 44 +++++++++++++++++++++++++++++++++++++++++++- gtk/gtkwidget.c | 36 ------------------------------------ 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index ae9cf81983..8e50804f74 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -30,6 +30,8 @@ #include "gtkwidget.h" #include "gtktypeutils.h" #include "gtkprivate.h" +#include "gtkcssprovider.h" +#include "gtkversion.h" #ifdef GDK_WINDOWING_X11 #include "x11/gdkx.h" @@ -1339,6 +1341,46 @@ gtk_settings_finalize (GObject *object) G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object); } +static void +settings_init_style (GtkSettings *settings) +{ + static GtkCssProvider *css_provider = NULL; + GtkCssProvider *default_provider; + + /* Add provider for user file */ + if (G_UNLIKELY (!css_provider)) + { + GFile *home_dir, *css_file; + gchar *filename; + + css_provider = gtk_css_provider_new (); + home_dir = g_file_new_for_path (g_get_home_dir ()); + + filename = g_strdup_printf (".gtk-%d.0.css", GTK_MAJOR_VERSION); + css_file = g_file_get_child (home_dir, filename); + g_free (filename); + + if (g_file_query_exists (css_file, NULL)) + gtk_css_provider_load_from_file (css_provider, css_file, NULL); + + g_object_unref (home_dir); + g_object_unref (css_file); + } + + gtk_style_context_add_provider_for_screen (settings->screen, + GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); + + default_provider = gtk_css_provider_get_default (); + gtk_style_context_add_provider_for_screen (settings->screen, + GTK_STYLE_PROVIDER (default_provider), + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); + + gtk_style_context_add_provider_for_screen (settings->screen, + GTK_STYLE_PROVIDER (settings), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); +} + /** * gtk_settings_get_for_screen: * @screen: a #GdkScreen. @@ -1364,7 +1406,7 @@ gtk_settings_get_for_screen (GdkScreen *screen) g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"), settings, g_object_unref); - gtk_rc_reparse_all_for_settings (settings, TRUE); + settings_init_style (settings); settings_update_double_click (settings); #ifdef GDK_WINDOWING_X11 settings_update_cursor_theme (settings); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 6bc665c17f..0694f5cd2d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13353,10 +13353,7 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { - static GtkCssProvider *css_provider = NULL; - GtkCssProvider *default_provider; GtkWidgetPath *path; - GtkSettings *settings; context = g_object_new (GTK_TYPE_STYLE_CONTEXT, "direction", gtk_widget_get_direction (widget), @@ -13369,39 +13366,6 @@ gtk_widget_get_style_context (GtkWidget *widget) quark_style_context, context, (GDestroyNotify) g_object_unref); - /* Add provider for user file */ - if (G_UNLIKELY (!css_provider)) - { - GFile *home_dir, *css_file; - gchar *filename; - - css_provider = gtk_css_provider_new (); - home_dir = g_file_new_for_path (g_get_home_dir ()); - - filename = g_strdup_printf (".gtk-%d.0.css", GTK_MAJOR_VERSION); - css_file = g_file_get_child (home_dir, filename); - g_free (filename); - - if (g_file_query_exists (css_file, NULL)) - gtk_css_provider_load_from_file (css_provider, css_file, NULL); - - g_object_unref (home_dir); - g_object_unref (css_file); - } - - gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (css_provider), - GTK_STYLE_PROVIDER_PRIORITY_USER); - - default_provider = gtk_css_provider_get_default (); - gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (default_provider), - GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); - - settings = gtk_widget_get_settings (widget); - gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (settings), - GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); gtk_style_context_set_screen (context, gtk_widget_get_screen (widget)); From 679ff63d5cf582a357fa1ad14752b9f53caf4d39 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 22 Sep 2010 23:39:15 +0200 Subject: [PATCH 307/634] GtkCssProvider: Add gtk_css_provider_get_named() This functions loads a CSS file from a installed theme. --- gtk/gtkcssprovider.c | 74 ++++++++++++++++++++++++++++++++++++++++++-- gtk/gtkcssprovider.h | 2 ++ 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index a4a1af7373..e118c1a781 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2080,8 +2080,25 @@ gtk_css_provider_get_default (void) return provider; } +static gchar * +css_provider_get_theme_dir (void) +{ + const gchar *var; + gchar *path; + + var = g_getenv ("GTK_DATA_PREFIX"); + + if (var) + path = g_build_filename (var, "share", "themes", NULL); + else + path = g_build_filename (GTK_DATA_PREFIX, "share", "themes", NULL); + + return path; +} + GtkCssProvider * -gtk_css_provider_get_named (const gchar *name) +gtk_css_provider_get_named (const gchar *name, + const gchar *variant) { static GHashTable *themes = NULL; GtkCssProvider *provider; @@ -2093,9 +2110,60 @@ gtk_css_provider_get_named (const gchar *name) if (!provider) { - + const gchar *home_dir; + gchar *subpath, *path = NULL; - g_hash_table_insert (themes, g_strdup (name), provider); + if (variant) + subpath = g_strdup_printf ("gtk-%d.0" G_DIR_SEPARATOR_S "gtk-%s.css", GTK_MAJOR_VERSION, variant); + else + subpath = g_strdup_printf ("gtk-%d.0" G_DIR_SEPARATOR_S "gtk.css", GTK_MAJOR_VERSION); + + /* First look in the users home directory + */ + home_dir = g_get_home_dir (); + if (home_dir) + { + path = g_build_filename (home_dir, ".themes", name, subpath, NULL); + + if (!g_file_test (path, G_FILE_TEST_EXISTS)) + { + g_free (path); + path = NULL; + } + } + + if (!path) + { + gchar *theme_dir = css_provider_get_theme_dir (); + path = g_build_filename (theme_dir, name, subpath, NULL); + g_free (theme_dir); + + if (!g_file_test (path, G_FILE_TEST_EXISTS)) + { + g_free (path); + path = NULL; + } + } + + if (path) + { + GtkCssProvider *provider; + GError *error = NULL; + + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_path (provider, path, &error); + + if (error) + { + g_warning ("Could not load named theme \"%s\": %s", name, error->message); + g_error_free (error); + + g_object_unref (provider); + provider = NULL; + } + else + g_hash_table_insert (themes, g_strdup (name), provider); + } } return provider; diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h index 2b8dd9dcfe..2c6d283342 100644 --- a/gtk/gtkcssprovider.h +++ b/gtk/gtkcssprovider.h @@ -62,6 +62,8 @@ gboolean gtk_css_provider_load_from_path (GtkCssProvider *css_provider, GtkCssProvider * gtk_css_provider_get_default (void); +GtkCssProvider * gtk_css_provider_get_named (const gchar *name, + const gchar *variant); G_END_DECLS From ac73a8f7a8346ce7fe6ca916c438c5263701e3da Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 22 Sep 2010 23:40:59 +0200 Subject: [PATCH 308/634] GtkStyleContext: Add gtk_style_context_reset_widgets() This function recalculates the style for all widgets on a screen. --- gtk/gtkstylecontext.c | 10 +++++----- gtk/gtkstylecontext.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 522a3e2549..cc234ee647 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -707,13 +707,13 @@ gtk_style_context_remove_provider (GtkStyleContext *context, } } -static void -reset_toplevels (GdkScreen *screen) +void +gtk_style_context_reset_widgets (GdkScreen *screen) { GList *list, *toplevels; toplevels = gtk_window_list_toplevels (); - g_list_foreach (toplevels, (GFunc)g_object_ref, NULL); + g_list_foreach (toplevels, (GFunc) g_object_ref, NULL); for (list = toplevels; list; list = list->next) { @@ -745,7 +745,7 @@ gtk_style_context_add_provider_for_screen (GdkScreen *screen, if (list != providers) g_object_set_qdata (G_OBJECT (screen), provider_list_quark, list); - reset_toplevels (screen); + gtk_style_context_reset_widgets (screen); } void @@ -767,7 +767,7 @@ gtk_style_context_remove_provider_for_screen (GdkScreen *screen, if (list != providers) g_object_set_qdata (G_OBJECT (screen), provider_list_quark, list); - reset_toplevels (screen); + gtk_style_context_reset_widgets (screen); } } diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 07cec5b71f..5064bf6f08 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -169,7 +169,7 @@ void gtk_style_context_state_transition_stop (GtkStyleContext *context, gpointer identifier); void gtk_style_context_invalidate (GtkStyleContext *context); - +void gtk_style_context_reset_widgets (GdkScreen *screen); /* Paint methods */ void gtk_render_check (GtkStyleContext *context, From cc68e62e24f65b2ac96da6527a2913b000895fd3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 22 Sep 2010 23:44:06 +0200 Subject: [PATCH 309/634] GtkSettings: Add a new provider for the theme CSS file. --- gtk/gtksettings.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 8e50804f74..3cde000bba 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -207,6 +207,7 @@ static void settings_update_font_options (GtkSettings *setting static gboolean settings_update_fontconfig (GtkSettings *settings); #endif static void settings_update_color_scheme (GtkSettings *settings); +static void settings_update_theme (GtkSettings *settings); static void merge_color_scheme (GtkSettings *settings, const GValue *value, @@ -1556,6 +1557,10 @@ gtk_settings_notify (GObject *object, break; case PROP_COLOR_SCHEME: settings_update_color_scheme (settings); + gtk_style_context_reset_widgets (settings->screen); + break; + case PROP_THEME_NAME: + settings_update_theme (settings); break; #ifdef GDK_WINDOWING_X11 case PROP_XFT_DPI: @@ -2594,6 +2599,49 @@ settings_update_color_scheme (GtkSettings *settings) } } +static void +settings_update_theme (GtkSettings *settings) +{ + static GQuark quark_theme_name = 0; + GtkCssProvider *provider, *new_provider = NULL; + gboolean prefer_dark_theme; + gchar *theme_name; + + if (G_UNLIKELY (!quark_theme_name)) + quark_theme_name = g_quark_from_static_string ("gtk-settings-theme-name"); + + provider = g_object_get_qdata (G_OBJECT (settings), quark_theme_name); + + g_object_get (settings, + "gtk-theme-name", &theme_name, + "gtk-application-prefer-dark-theme", &prefer_dark_theme, + NULL); + + if (theme_name && *theme_name) + { + gchar *variant = NULL; + + if (prefer_dark_theme) + variant = "dark"; + + new_provider = gtk_css_provider_get_named (theme_name, variant); + g_free (theme_name); + } + + if (new_provider != provider) + { + if (provider) + gtk_style_context_remove_provider_for_screen (settings->screen, provider); + + if (new_provider) + gtk_style_context_add_provider_for_screen (settings->screen, new_provider, + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS + 1); + + g_object_set_qdata_full (G_OBJECT (settings), quark_theme_name, + new_provider, (GDestroyNotify) g_object_unref); + } +} + static gboolean add_color_to_hash (gchar *name, GdkColor *color, From 089f375cdb7d04fcb8ca68896a03dd65e6fe7123 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 21:42:18 +0200 Subject: [PATCH 310/634] Add Gtk9Slice This is a private boxed object to contain information about a border image in order to render it in a size independent way. --- gtk/Makefile.am | 2 + gtk/gtk9slice.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtk9slice.h | 59 ++++++++ 3 files changed, 412 insertions(+) create mode 100644 gtk/gtk9slice.c create mode 100644 gtk/gtk9slice.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index ff5ba8d876..a4780a9f1a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -372,6 +372,7 @@ endif # GTK+ header files that don't get installed gtk_private_h_sources = \ + gtk9slice.h \ gtkbuttonprivate.h \ gtkquery.h \ gtksearchengine.h \ @@ -431,6 +432,7 @@ gtk_private_h_sources = \ # GTK+ C sources to build the library from gtk_base_c_sources = \ + gtk9slice.c \ gtkquery.c \ gtksearchengine.c \ gtksearchenginesimple.c \ diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c new file mode 100644 index 0000000000..9bfdafb914 --- /dev/null +++ b/gtk/gtk9slice.c @@ -0,0 +1,351 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtk9slice.h" + +enum { + BORDER_LEFT, + BORDER_MIDDLE, + BORDER_RIGHT, + BORDER_LAST, + BORDER_TOP = BORDER_LEFT, + BORDER_BOTTOM = BORDER_RIGHT +}; + +enum { + SIDE_TOP, + SIDE_RIGHT, + SIDE_BOTTOM, + SIDE_LEFT +}; + +struct Gtk9Slice +{ + cairo_surface_t *surfaces[BORDER_LAST][BORDER_LAST]; + GtkSliceSideModifier modifiers[4]; + gdouble distances[4]; + gint ref_count; +}; + +G_DEFINE_BOXED_TYPE (Gtk9Slice, gtk_9slice, + gtk_9slice_ref, gtk_9slice_unref) + + +Gtk9Slice * +gtk_9slice_new (GdkPixbuf *pixbuf, + gdouble distance_top, + gdouble distance_bottom, + gdouble distance_left, + gdouble distance_right, + GtkSliceSideModifier vertical_modifier, + GtkSliceSideModifier horizontal_modifier) +{ + Gtk9Slice *slice; + cairo_surface_t *surface; + gint width, height; + cairo_t *cr; + + g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); + + slice = g_slice_new0 (Gtk9Slice); + slice->ref_count = 1; + + slice->distances[SIDE_TOP] = distance_top; + slice->distances[SIDE_BOTTOM] = distance_bottom; + slice->distances[SIDE_LEFT] = distance_left; + slice->distances[SIDE_RIGHT] = distance_right; + + slice->modifiers[SIDE_TOP] = slice->modifiers[SIDE_BOTTOM] = horizontal_modifier; + slice->modifiers[SIDE_LEFT] = slice->modifiers[SIDE_RIGHT] = vertical_modifier; + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + + /* Get an image surface from the pixbuf */ + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cr = cairo_create (surface); + + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); + cairo_paint (cr); + + cairo_destroy (cr); + + /* Top /left corner */ + slice->surfaces[BORDER_LEFT][BORDER_TOP] = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, + distance_left, distance_top); + cairo_create (slice->surfaces[BORDER_LEFT][BORDER_TOP]); + + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + + cairo_destroy (cr); + + /* Top/right corner */ + slice->surfaces[BORDER_RIGHT][BORDER_TOP] = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, + distance_right, distance_top); + cairo_create (slice->surfaces[BORDER_RIGHT][BORDER_TOP]); + + cairo_set_source_surface (cr, surface, - width + distance_right, 0); + cairo_paint (cr); + + cairo_destroy (cr); + + /* Bottom/left corner */ + slice->surfaces[BORDER_LEFT][BORDER_BOTTOM] = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, + distance_left, distance_bottom); + cairo_create (slice->surfaces[BORDER_LEFT][BORDER_BOTTOM]); + + cairo_set_source_surface (cr, surface, 0, - height + distance_bottom); + cairo_paint (cr); + + cairo_destroy (cr); + + /* Bottom/right corner */ + slice->surfaces[BORDER_RIGHT][BORDER_BOTTOM] = cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA, + distance_right, distance_bottom); + cairo_create (slice->surfaces[BORDER_RIGHT][BORDER_BOTTOM]); + + cairo_set_source_surface (cr, surface, - width + distance_right, - height + distance_bottom); + cairo_paint (cr); + + cairo_destroy (cr); + + /* Top side */ + slice->surfaces[BORDER_MIDDLE][BORDER_TOP] = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + width - distance_left - distance_right, + distance_top); + cairo_create (slice->surfaces[BORDER_MIDDLE][BORDER_TOP]); + cairo_set_source_surface (cr, surface, - distance_left, 0); + cairo_paint (cr); + cairo_destroy (cr); + + /* Bottom side */ + slice->surfaces[BORDER_MIDDLE][BORDER_BOTTOM] = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + width - distance_left - distance_right, + distance_bottom); + cairo_create (slice->surfaces[BORDER_MIDDLE][BORDER_BOTTOM]); + cairo_set_source_surface (cr, surface, - distance_left, - height + distance_bottom); + cairo_paint (cr); + cairo_destroy (cr); + + /* Left side */ + slice->surfaces[BORDER_LEFT][BORDER_MIDDLE] = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + distance_left, + height - distance_top - distance_bottom); + cairo_create (slice->surfaces[BORDER_LEFT][BORDER_MIDDLE]); + cairo_set_source_surface (cr, surface, 0, - distance_top); + cairo_paint (cr); + cairo_destroy (cr); + + /* Right side */ + slice->surfaces[BORDER_RIGHT][BORDER_MIDDLE] = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + distance_right, + height - distance_top - distance_bottom); + cairo_create (slice->surfaces[BORDER_RIGHT][BORDER_MIDDLE]); + cairo_set_source_surface (cr, surface, - width + distance_right, - distance_top); + cairo_paint (cr); + cairo_destroy (cr); + + /* Center */ + slice->surfaces[BORDER_MIDDLE][BORDER_MIDDLE] = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + width - distance_left - distance_right, + height - distance_top - distance_bottom); + cairo_create (slice->surfaces[BORDER_MIDDLE][BORDER_MIDDLE]); + cairo_set_source_surface (cr, surface, - distance_left, - distance_top); + cairo_paint (cr); + cairo_destroy (cr); + + return slice; +} + +static void +render_border (cairo_t *cr, + cairo_surface_t *surface, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkSliceSideModifier modifier) +{ + cairo_pattern_t *pattern; + cairo_matrix_t matrix; + + cairo_save (cr); + + cairo_rectangle (cr, x, y, width, height); + cairo_clip (cr); + + pattern = cairo_pattern_create_for_surface (surface); + + cairo_matrix_init_translate (&matrix, - x, - y); + + if (modifier == GTK_SLICE_REPEAT) + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + else + { + gint w; + + w = cairo_image_surface_get_width (surface); + cairo_matrix_scale (&matrix, width / w, 0); + } + + cairo_pattern_set_matrix (pattern, &matrix); + cairo_set_source (cr, pattern); + + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); + + cairo_restore (cr); +} + +static void +render_corner (cairo_t *cr, + cairo_surface_t *surface, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + cairo_save (cr); + + cairo_rectangle (cr, x, y, width, height); + cairo_clip (cr); + + cairo_set_source_surface (cr, surface, x, y); + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); + + cairo_restore (cr); +} + +void +gtk_9slice_render (Gtk9Slice *slice, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + int img_width, img_height; + cairo_surface_t *surface; + + cairo_save (cr); + + /* Top side */ + surface = slice->surfaces[BORDER_MIDDLE][BORDER_TOP]; + img_height = cairo_image_surface_get_height (surface); + + render_border (cr, surface, + x + slice->distances[SIDE_LEFT], y, + (gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], + (gdouble) img_height, + slice->modifiers[SIDE_TOP]); + + /* Bottom side */ + surface = slice->surfaces[BORDER_MIDDLE][BORDER_BOTTOM]; + img_height = cairo_image_surface_get_height (surface); + + render_border (cr, surface, + x + slice->distances[SIDE_LEFT], y + height - img_height, + (gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], + (gdouble) img_height, + slice->modifiers[SIDE_BOTTOM]); + + /* Left side */ + surface = slice->surfaces[BORDER_LEFT][BORDER_MIDDLE]; + img_width = cairo_image_surface_get_width (surface); + + render_border (cr, surface, + x, y + slice->distances[SIDE_TOP], + (gdouble) img_width, + (gdouble) height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], + slice->modifiers[SIDE_LEFT]); + + /* Right side */ + surface = slice->surfaces[BORDER_RIGHT][BORDER_MIDDLE]; + img_width = cairo_image_surface_get_width (surface); + + render_border (cr, surface, + x + width - img_width, y + slice->distances[SIDE_TOP], + (gdouble) img_width, height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], + slice->modifiers[SIDE_RIGHT]); + + /* Top/Left corner */ + surface = slice->surfaces[BORDER_LEFT][BORDER_TOP]; + img_width = cairo_image_surface_get_width (surface); + img_height = cairo_image_surface_get_height (surface); + render_corner (cr, surface, x, y, (gdouble) img_width, (gdouble) img_height); + + /* Top/right corner */ + surface = slice->surfaces[BORDER_RIGHT][BORDER_TOP]; + img_width = cairo_image_surface_get_width (surface); + img_height = cairo_image_surface_get_height (surface); + render_corner (cr, surface, x + width - img_width, y, + (gdouble) img_width, (gdouble) img_height); + + /* Bottom/left corner */ + surface = slice->surfaces[BORDER_LEFT][BORDER_BOTTOM]; + img_width = cairo_image_surface_get_width (surface); + img_height = cairo_image_surface_get_height (surface); + render_corner (cr, surface, x, y + height - img_height, + (gdouble) img_width, (gdouble) img_height); + + /* Bottom/right corner */ + surface = slice->surfaces[BORDER_RIGHT][BORDER_BOTTOM]; + img_width = cairo_image_surface_get_width (surface); + img_height = cairo_image_surface_get_height (surface); + render_corner (cr, surface, x + width - img_width, y + height - img_height, + (gdouble) img_width, (gdouble) img_height); + + cairo_restore (cr); +} + +Gtk9Slice * +gtk_9slice_ref (Gtk9Slice *slice) +{ + g_return_val_if_fail (slice != NULL, NULL); + + slice->ref_count++; + return slice; +} + +void +gtk_9slice_unref (Gtk9Slice *slice) +{ + g_return_if_fail (slice != NULL); + + slice->ref_count--; + + if (slice->ref_count == 0) + { + gint i, j; + + for (i = 0; i < BORDER_LAST; i++) + for (j = 0; j < BORDER_LAST; j++) + cairo_surface_destroy (slice->surfaces[i][j]); + + g_slice_free (Gtk9Slice, slice); + } +} diff --git a/gtk/gtk9slice.h b/gtk/gtk9slice.h new file mode 100644 index 0000000000..28d998b4e3 --- /dev/null +++ b/gtk/gtk9slice.h @@ -0,0 +1,59 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_9SLICE_H__ +#define __GTK_9SLICE_H__ + +#include "gtktimeline.h" + +G_BEGIN_DECLS + +/* Dummy typedefs */ +typedef struct Gtk9Slice Gtk9Slice; + +#define GTK_TYPE_9SLICE (gtk_9slice_get_type ()) + +typedef enum { + GTK_SLICE_REPEAT, + GTK_SLICE_STRETCH +} GtkSliceSideModifier; + +GType gtk_9slice_get_type (void) G_GNUC_CONST; + +Gtk9Slice * gtk_9slice_new (GdkPixbuf *pixbuf, + gdouble distance_top, + gdouble distance_bottom, + gdouble distance_left, + gdouble distance_right, + GtkSliceSideModifier vertical_modifier, + GtkSliceSideModifier horizontal_modifier); + +Gtk9Slice * gtk_9slice_ref (Gtk9Slice *slice); +void gtk_9slice_unref (Gtk9Slice *slice); + +void gtk_9slice_render (Gtk9Slice *slice, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); + +G_END_DECLS + +#endif /* __GTK_9SLICE_H__ */ From f363e31a096a60c09f7f31c0a3646b39b548fe47 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 22:02:39 +0200 Subject: [PATCH 311/634] Register the border-image property It will contain a 9-sliced image, so it can be rendered as rectangles with any dimensions. --- gtk/gtkstyleset.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index cd1c8dfb2a..59ac9f5fa5 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -27,6 +27,7 @@ #include "gtkprivate.h" #include "gtkthemingengine.h" #include "gtkanimationdescription.h" +#include "gtk9slice.h" #include "gtkintl.h" typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; @@ -90,6 +91,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); gtk_style_set_register_property ("background-image", GDK_TYPE_CAIRO_PATTERN, NULL, NULL); + gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); g_value_init (&val, GTK_TYPE_THEMING_ENGINE); g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); From 7ee564c7cd02c2756dd54d46bfad3caf3e82c7ac Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 22:05:20 +0200 Subject: [PATCH 312/634] GtkCssProvider: Add a parser for 9slice typed properties. The value it parses is similar to the border-image CSS3 property, so strings like this will be accepted: border-image: url (foo.png) 4 3 4 3 repeat repeat; the image path is relative to the parsed CSS file dirname if no absolute path is provided. --- gtk/gtkcssprovider.c | 205 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 199 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index e118c1a781..de28e26553 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -23,8 +23,10 @@ #include #include #include +#include #include "gtkanimationdescription.h" +#include "gtk9slice.h" #include "gtkcssprovider.h" typedef struct GtkCssProviderPrivate GtkCssProviderPrivate; @@ -125,8 +127,9 @@ static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); static void css_provider_apply_scope (GtkCssProvider *css_provider, ParserScope scope); -static gboolean css_provider_parse_value (const gchar *value_str, - GValue *value); +static gboolean css_provider_parse_value (GtkCssProvider *css_provider, + const gchar *value_str, + GValue *value); G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, @@ -696,7 +699,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, val_str = g_value_get_string (val); found = TRUE; - css_provider_parse_value (val_str, value); + css_provider_parse_value (GTK_CSS_PROVIDER (provider), val_str, value); break; } } @@ -1564,9 +1567,188 @@ gradient_parse (const gchar *str) return gradient; } +static gchar * +url_parse_str (const gchar *str, + gchar **end_ptr) +{ + gchar *path, *chr; + + if (!g_str_has_prefix (str, "url")) + { + *end_ptr = (gchar *) str; + return NULL; + } + + str += strlen ("url"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return NULL; + } + + chr = strchr (str, ')'); + + if (!chr) + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + + path = g_strndup (str, chr - str); + g_strstrip (path); + + *end_ptr = chr + 1; + + return path; +} + +static Gtk9Slice * +slice_parse_str (GtkCssProvider *css_provider, + const gchar *str, + gchar **end_ptr) +{ + gdouble distance_top, distance_bottom; + gdouble distance_left, distance_right; + GtkSliceSideModifier mods[2]; + GError *error = NULL; + GdkPixbuf *pixbuf; + gchar *path; + gint i = 0; + + SKIP_SPACES (str); + + /* Parse image url */ + path = url_parse_str (str, end_ptr); + + if (!path) + return NULL; + + if (!g_path_is_absolute (path)) + { + GtkCssProviderPrivate *priv; + gchar *dirname, *full_path; + + priv = css_provider->priv; + + /* Use relative path to the current CSS file path, if any */ + dirname = g_path_get_dirname (priv->filename); + + full_path = g_build_filename (dirname, path, NULL); + g_free (path); + path = full_path; + } + + str = *end_ptr; + SKIP_SPACES (str); + + /* Parse top/left/bottom/right distances */ + distance_top = g_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + + distance_right = g_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + + distance_bottom = g_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + + distance_left = g_strtod (str, end_ptr); + + str = *end_ptr; + SKIP_SPACES (str); + + while (*str && i < 2) + { + if (g_str_has_prefix (str, "stretch")) + { + str += strlen ("stretch"); + mods[i] = GTK_SLICE_STRETCH; + } + else if (g_str_has_prefix (str, "repeat")) + { + str += strlen ("repeat"); + mods[i] = GTK_SLICE_REPEAT; + } + else + { + g_free (path); + *end_ptr = (gchar *) str; + return NULL; + } + + SKIP_SPACES (str); + i++; + } + + *end_ptr = (gchar *) str; + + if (*str != '\0') + { + g_free (path); + return NULL; + } + + if (i != 2) + { + /* Fill in second modifier, same as the first */ + mods[1] = mods[1]; + } + + pixbuf = gdk_pixbuf_new_from_file (path, &error); + g_free (path); + + if (error) + { + g_warning ("Pixbuf could not be loaded: %s\n", error->message); + g_error_free (error); + *end_ptr = (gchar *) str; + return NULL; + } + + return gtk_9slice_new (pixbuf, + distance_top, distance_bottom, + distance_left, distance_right, + mods[0], mods[1]); +} + +static Gtk9Slice * +slice_parse (GtkCssProvider *css_provider, + const gchar *str) +{ + Gtk9Slice *slice; + gchar *end; + + slice = slice_parse_str (css_provider, str, &end); + + if (*end != '\0') + { + g_warning ("Error parsing sliced image \"%s\", stopped at char %ld : '%c'", + str, end - str, *end); + + if (slice) + { + gtk_9slice_unref (slice); + slice = NULL; + } + } + + return slice; +} + static gboolean -css_provider_parse_value (const gchar *value_str, - GValue *value) +css_provider_parse_value (GtkCssProvider *css_provider, + const gchar *value_str, + GValue *value) { GType type; gboolean parsed = TRUE; @@ -1682,6 +1864,17 @@ css_provider_parse_value (const gchar *value_str, else parsed = FALSE; } + else if (type == GTK_TYPE_9SLICE) + { + Gtk9Slice *slice; + + slice = slice_parse (css_provider, value_str); + + if (slice) + g_value_take_boxed (value, slice); + else + parsed = FALSE; + } else { g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); @@ -1814,7 +2007,7 @@ parse_rule (GtkCssProvider *css_provider, g_hash_table_insert (priv->cur_properties, prop, val); } else if ((parse_func && (parse_func) (value_str, val, &error)) || - (!parse_func && css_provider_parse_value (value_str, val))) + (!parse_func && css_provider_parse_value (css_provider, value_str, val))) g_hash_table_insert (priv->cur_properties, prop, val); else { From 96e5a0214890580a19c4bffbb94a6004ee869527 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 22:08:49 +0200 Subject: [PATCH 313/634] GtkThemingEngine: Use border-image to render borders if an image is available. --- gtk/gtkthemingengine.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 5a2285aad7..a5241c3b50 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -26,6 +26,7 @@ #include #include +#include "gtk9slice.h" #include "gtkpango.h" typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; @@ -961,15 +962,26 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, GtkStateFlags flags; GdkColor lighter, darker; GdkColor *bg_color; + Gtk9Slice *slice; - cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - cairo_set_line_width (cr, 1); - gtk_theming_engine_get (engine, flags, + "border-image", &slice, "background-color", &bg_color, NULL); + + if (slice) + { + gtk_9slice_render (slice, cr, x, y, width, height); + gtk_9slice_unref (slice); + gdk_color_free (bg_color); + return; + } + + cairo_save (cr); + cairo_set_line_width (cr, 1); + color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); From 80cf01c2717961d3403470446b3d2c4c16b81322 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 22:09:37 +0200 Subject: [PATCH 314/634] GtkCssProvider: unset filename on load_from_data() --- gtk/gtkcssprovider.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index de28e26553..fc07bf37b4 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2112,6 +2112,9 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, priv->scanner->input_name = "-"; g_scanner_input_text (priv->scanner, data, (guint) length); + g_free (priv->filename); + priv->filename = NULL; + parse_stylesheet (css_provider); return TRUE; From 20051e02eb93baa819a217bc70574e1b49865033 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 22:10:20 +0200 Subject: [PATCH 315/634] GtkCssProvider: use mapped file to read CSS files. --- gtk/gtkcssprovider.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index fc07bf37b4..151902f54f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2167,7 +2167,8 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, { GtkCssProviderPrivate *priv; GError *internal_error = NULL; - gchar *data; + GMappedFile *mapped_file; + const gchar *data; gsize length; g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); @@ -2175,13 +2176,21 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, priv = css_provider->priv; - if (g_file_get_contents (path, &data, &length, - &internal_error)) + mapped_file = g_mapped_file_new (path, FALSE, &internal_error); + + if (internal_error) { g_propagate_error (error, internal_error); return FALSE; } + length = g_mapped_file_get_length (mapped_file); + data = g_mapped_file_get_contents (mapped_file); + + /* FIXME: Set error */ + if (!data) + return FALSE; + if (priv->selectors_info->len > 0) g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); @@ -2194,7 +2203,7 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, parse_stylesheet (css_provider); - g_free (data); + g_mapped_file_unref (mapped_file); return TRUE; } From fecc07908769c3538d4a35c3cd7b89248756a0d1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Oct 2010 10:53:09 +0200 Subject: [PATCH 316/634] GtkStyleContext: Invalidate whole window if no invalidation region is obtained. --- gtk/gtkstylecontext.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cc234ee647..194070ea32 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -301,6 +301,8 @@ timeline_frame_cb (GtkTimeline *timeline, if (info->invalidation_region && !cairo_region_is_empty (info->invalidation_region)) gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); + else + gdk_window_invalidate_rect (info->window, NULL, TRUE); } static void @@ -327,6 +329,8 @@ timeline_finished_cb (GtkTimeline *timeline, if (info->invalidation_region && !cairo_region_is_empty (info->invalidation_region)) gdk_window_invalidate_region (info->window, info->invalidation_region, TRUE); + else + gdk_window_invalidate_rect (info->window, NULL, TRUE); animation_info_free (info); break; From 7583f31609e923ebea8e0f8f94610cdd8517d7a3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Oct 2010 10:54:19 +0200 Subject: [PATCH 317/634] GtkStyleContext: Store animation region for a bunch of paint operations. --- gtk/gtkstylecontext.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 194070ea32..09236331f0 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2002,6 +2002,8 @@ gtk_render_option (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_option (priv->theming_engine, cr, x, y, width, height); @@ -2024,6 +2026,8 @@ gtk_render_arrow (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, size, size); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_arrow (priv->theming_engine, cr, angle, x, y, size); @@ -2046,6 +2050,8 @@ gtk_render_background (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_background (priv->theming_engine, cr, x, y, width, height); } @@ -2067,6 +2073,8 @@ gtk_render_frame (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_frame (priv->theming_engine, cr, x, y, width, height); } @@ -2088,6 +2096,8 @@ gtk_render_expander (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_expander (priv->theming_engine, cr, x, y, width, height); } @@ -2109,6 +2119,8 @@ gtk_render_focus (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_focus (priv->theming_engine, cr, x, y, width, height); } @@ -2172,6 +2184,8 @@ gtk_render_slider (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation); } @@ -2196,6 +2210,8 @@ gtk_render_frame_gap (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_frame_gap (priv->theming_engine, cr, x, y, width, height, gap_side, @@ -2220,6 +2236,8 @@ gtk_render_extension (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side); } @@ -2242,6 +2260,8 @@ gtk_render_handle (GtkStyleContext *context, priv = context->priv; engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + store_animation_region (context, x, y, width, height); + _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_handle (priv->theming_engine, cr, x, y, width, height, orientation); } From d8187b34bb7238d36f698951f8ad329e6ecdad3f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Oct 2010 10:54:49 +0200 Subject: [PATCH 318/634] GtkSymbolicColor: Use G_DEFINE_BOXED_TYPE --- gtk/gtksymboliccolor.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 5710218102..310e211342 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -22,6 +22,8 @@ #include "gtkstyleset.h" #include "gtkintl.h" +G_DEFINE_BOXED_TYPE (GtkSymbolicColor, gtk_symbolic_color, + gtk_symbolic_color_ref, gtk_symbolic_color_unref) G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient, gtk_gradient_ref, gtk_gradient_unref) @@ -251,19 +253,6 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, return FALSE; } -GType -gtk_symbolic_color_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (!type)) - type = g_boxed_type_register_static (I_("GtkSymbolicColor"), - (GBoxedCopyFunc) gtk_symbolic_color_ref, - (GBoxedFreeFunc) gtk_symbolic_color_unref); - - return type; -} - /* GtkGradient */ GtkGradient * gtk_gradient_new_linear (gdouble x0, From 908babd8ae6d02426c6c315a30da1783aea5a9d2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Oct 2010 10:55:40 +0200 Subject: [PATCH 319/634] GtkThemingEngine: Implement animations between gradients/colors. --- gtk/gtkthemingengine.c | 152 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a5241c3b50..a90f7513e3 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -896,6 +896,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, GdkColor *bg_color, *base_color; cairo_pattern_t *pattern; GtkStateFlags flags; + gboolean prelight; + gdouble progress; flags = gtk_theming_engine_get_state (engine); cairo_save (cr); @@ -915,6 +917,156 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, "base-color", &base_color, NULL); + prelight = gtk_theming_engine_is_state_set (engine, GTK_STATE_PRELIGHT, &progress); + + if (prelight || progress > 0 ) + { + cairo_pattern_t *other_pattern; + GtkStateFlags other_flags; + GdkColor *other_bg, *other_base; + cairo_pattern_t *new_pattern = NULL; + + if (prelight) + { + other_flags = flags & ~(GTK_STATE_FLAG_PRELIGHT); + progress = 1 - progress; + } + else + other_flags = flags | GTK_STATE_FLAG_PRELIGHT; + + gtk_theming_engine_get (engine, other_flags, + "background-image", &other_pattern, + "background-color", &other_bg, + "base-color", &other_base, + NULL); + + if (pattern && other_pattern) + { + gdouble offset0, red0, green0, blue0, alpha0; + gdouble offset1, red1, green1, blue1, alpha1; + gdouble x00, x01, y00, y01, x10, x11, y10, y11; + gint n0, n1; + guint i; + + cairo_pattern_get_linear_points (pattern, &x00, &y00, &x01, &y01); + cairo_pattern_get_linear_points (other_pattern, &x10, &y10, &x11, &y11); + + new_pattern = cairo_pattern_create_linear (x00 + (x10 - x00) * progress, + y00 + (y10 - y00) * progress, + x01 + (x11 - x01) * progress, + y01 + (y11 - y01) * progress); + cairo_pattern_set_filter (new_pattern, CAIRO_FILTER_FAST); + + cairo_pattern_get_color_stop_count (pattern, &n0); + cairo_pattern_get_color_stop_count (other_pattern, &n1); + i = 0; + + /* Blend both gradients into one */ + while (i < n0 && i < n1) + { + cairo_pattern_get_color_stop_rgba (pattern, i, + &offset0, + &red0, &green0, &blue0, + &alpha0); + cairo_pattern_get_color_stop_rgba (other_pattern, i, + &offset1, + &red1, &green1, &blue1, + &alpha1); + + cairo_pattern_add_color_stop_rgba (new_pattern, + offset0 + ((offset1 - offset0) * progress), + red0 + ((red1 - red0) * progress), + green0 + ((green1 - green0) * progress), + blue0 + ((blue1 - blue0) * progress), + alpha0 + ((alpha1 - alpha0) * progress)); + i++; + } + + /* FIXME: Handle remaining color stops in both source patterns */ + } + else if (pattern || other_pattern) + { + cairo_pattern_t *p; + GdkColor *c; + gdouble x0, y0, x1, y1; + gdouble red0, green0, blue0; + gdouble red1, green1, blue1; + gint n, i; + + /* Blend a pattern with a color */ + if (pattern) + { + p = pattern; + c = gtk_theming_engine_has_class (engine, "entry") ? other_base : other_bg; + progress = 1 - progress; + } + else + { + p = other_pattern; + c = gtk_theming_engine_has_class (engine, "entry") ? base_color : bg_color; + } + + cairo_pattern_get_linear_points (p, &x0, &y0, &x1, &y1); + new_pattern = cairo_pattern_create_linear (x0, y0, x1, y1); + cairo_pattern_get_color_stop_count (p, &n); + + red0 = c->red / 65535.; + green0 = c->green / 65535.; + blue0 = c->blue / 65535.; + + for (i = 0; i < n; i++) + { + gdouble offset, alpha; + + cairo_pattern_get_color_stop_rgba (p, i, + &offset, + &red1, &green1, &blue1, + &alpha); + cairo_pattern_add_color_stop_rgba (new_pattern, offset, + red0 + ((red1 - red0) * progress), + green0 + ((green1 - green0) * progress), + blue0 + ((blue1 - blue0) * progress), + alpha + ((1 - alpha) * progress)); + } + } + else + { + const GdkColor *color, *other_color; + + /* Merge just colors */ + if (gtk_theming_engine_has_class (engine, "entry")) + { + color = base_color; + other_color = other_base; + } + else + { + color = bg_color; + other_color = other_bg; + } + + new_pattern = cairo_pattern_create_rgb ((gdouble) (color->red + ((other_color->red - color->red) * progress)) / 65535., + (gdouble) (color->green + ((other_color->green - color->green) * progress)) / 65535., + (gdouble) (color->blue + ((other_color->blue - color->blue) * progress)) / 65535.); + } + + if (new_pattern) + { + /* Replace pattern to use */ + cairo_pattern_destroy (pattern); + pattern = new_pattern; + } + + if (other_pattern) + cairo_pattern_destroy (other_pattern); + + if (other_bg) + gdk_color_free (other_bg); + + if (other_base) + gdk_color_free (other_base); + } + if (pattern) { cairo_translate (cr, x, y); From 5b11d14a49c2d900f2fabf193742cee09f81bd52 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Oct 2010 10:56:52 +0200 Subject: [PATCH 320/634] GtkButton: Notify on prelight state change. --- gtk/gtkbutton.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index beece346c1..9b71c298f5 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1746,6 +1746,18 @@ gtk_button_enter_notify (GtkWidget *widget, { priv->in_button = TRUE; gtk_button_enter (button); + + if (gtk_widget_get_realized (widget) && + gtk_widget_is_drawable (widget)) + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_notify_state_change (context, + gtk_widget_get_window (widget), + NULL, GTK_STATE_PRELIGHT, + button->in_button); + } } return FALSE; @@ -1764,6 +1776,18 @@ gtk_button_leave_notify (GtkWidget *widget, { priv->in_button = FALSE; gtk_button_leave (button); + + if (gtk_widget_get_realized (widget) && + gtk_widget_is_drawable (widget)) + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_notify_state_change (context, + gtk_widget_get_window (widget), + NULL, GTK_STATE_PRELIGHT, + button->in_button); + } } return FALSE; From 5c8a8186715a54a3730727bc23e4cf0522bbcbcb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 6 Oct 2010 00:53:49 +0200 Subject: [PATCH 321/634] Fix typo in the Gtk9Slice parser. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 151902f54f..d5d552cff5 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1701,7 +1701,7 @@ slice_parse_str (GtkCssProvider *css_provider, if (i != 2) { /* Fill in second modifier, same as the first */ - mods[1] = mods[1]; + mods[1] = mods[0]; } pixbuf = gdk_pixbuf_new_from_file (path, &error); From 5c2cf1e934cfcdd5dccd277a9842b602fd6b674d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 6 Oct 2010 01:04:06 +0200 Subject: [PATCH 322/634] Plug some leaks. --- gtk/gtk9slice.c | 4 ++++ gtk/gtkcssprovider.c | 17 +++++++++++++---- gtk/gtksettings.c | 6 ++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c index 9bfdafb914..7cd6ad47ab 100644 --- a/gtk/gtk9slice.c +++ b/gtk/gtk9slice.c @@ -177,6 +177,8 @@ gtk_9slice_new (GdkPixbuf *pixbuf, cairo_paint (cr); cairo_destroy (cr); + cairo_surface_destroy (surface); + return slice; } @@ -217,6 +219,8 @@ render_border (cairo_t *cr, cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); + cairo_pattern_destroy (pattern); + cairo_restore (cr); } diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d5d552cff5..8236022e50 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1239,6 +1239,7 @@ symbolic_color_parse_str (const gchar *string, } symbolic_color = gtk_symbolic_color_new_shade (param_color, factor); + gtk_symbolic_color_unref (param_color); (*end_ptr)++; } else if (g_str_has_prefix (str, "mix")) @@ -1309,6 +1310,8 @@ symbolic_color_parse_str (const gchar *string, } symbolic_color = gtk_symbolic_color_new_mix (color1, color2, factor); + gtk_symbolic_color_unref (color1); + gtk_symbolic_color_unref (color2); (*end_ptr)++; } @@ -1617,6 +1620,7 @@ slice_parse_str (GtkCssProvider *css_provider, GtkSliceSideModifier mods[2]; GError *error = NULL; GdkPixbuf *pixbuf; + Gtk9Slice *slice; gchar *path; gint i = 0; @@ -1640,6 +1644,8 @@ slice_parse_str (GtkCssProvider *css_provider, full_path = g_build_filename (dirname, path, NULL); g_free (path); + g_free (dirname); + path = full_path; } @@ -1715,10 +1721,13 @@ slice_parse_str (GtkCssProvider *css_provider, return NULL; } - return gtk_9slice_new (pixbuf, - distance_top, distance_bottom, - distance_left, distance_right, - mods[0], mods[1]); + slice = gtk_9slice_new (pixbuf, + distance_top, distance_bottom, + distance_left, distance_right, + mods[0], mods[1]); + g_object_unref (pixbuf); + + return slice; } static Gtk9Slice * diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 3cde000bba..278890908c 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1276,6 +1276,7 @@ gtk_settings_get_style (GtkStyleProvider *provider, for (i = 0; colors[i]; i++) { + GtkSymbolicColor *color; gchar *name, *pos; GdkColor col; @@ -1299,8 +1300,9 @@ gtk_settings_get_style (GtkStyleProvider *provider, if (!*pos || !gdk_color_parse (pos, &col)) continue; - gtk_style_set_map_color (set, name, - gtk_symbolic_color_new_literal (&col)); + color = gtk_symbolic_color_new_literal (&col); + gtk_style_set_map_color (set, name, color); + gtk_symbolic_color_unref (color); } font_desc = pango_font_description_from_string (font_name); From a1a90396b7ba75f315173568906adc0686551fcf Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 8 Oct 2010 18:13:14 +0200 Subject: [PATCH 323/634] GtkThemingEngine: Do not return a const GtkThemingEngine on load() --- gtk/gtkthemingengine.c | 2 +- gtk/gtkthemingengine.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a90f7513e3..ee7e641d82 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -442,7 +442,7 @@ gtk_theming_module_init (GtkThemingModule *module) { } -G_CONST_RETURN GtkThemingEngine * +GtkThemingEngine * gtk_theming_engine_load (const gchar *name) { static GHashTable *engines = NULL; diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index e315e0a01f..8cbd75ad2d 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -182,7 +182,7 @@ GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); GtkJunctionSides gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine); -G_CONST_RETURN GtkThemingEngine * gtk_theming_engine_load (const gchar *name); +GtkThemingEngine * gtk_theming_engine_load (const gchar *name); GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine); From 1772b00e85d27d09d39f090e41a76f371e37d4d0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 8 Oct 2010 18:19:34 +0200 Subject: [PATCH 324/634] GtkCssProvider: Transform custom colors to a @define-color rule. Given there are other rules such as @import (which will be supported), keep a sane namespace here, so for (re)defining a color name, in the CSS file it will look like: @define-color color-name #fff; @define-color other-color mix (@color-name, #f00, 0.4); --- gtk/gtkcssprovider.c | 78 +++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 8236022e50..2dd42c0675 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1905,40 +1905,50 @@ parse_rule (GtkCssProvider *css_provider, css_provider_push_scope (css_provider, SCOPE_SELECTOR); + /* Handle directives */ if (scanner->token == G_TOKEN_IDENTIFIER && scanner->value.v_identifier[0] == '@') { - GtkSymbolicColor *color; - gchar *color_name, *color_str; + gchar *directive; - /* Rule is a color mapping */ - color_name = g_strdup (&scanner->value.v_identifier[1]); - g_scanner_get_next_token (scanner); + directive = &scanner->value.v_identifier[1]; - if (scanner->token != ':') - return ':'; + if (strcmp (directive, "define-color") == 0) + { + GtkSymbolicColor *color; + gchar *color_name, *color_str; - css_provider_push_scope (css_provider, SCOPE_VALUE); - g_scanner_get_next_token (scanner); + /* Directive is a color mapping */ + g_scanner_get_next_token (scanner); - if (scanner->token != G_TOKEN_IDENTIFIER) + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + color_name = g_strdup (scanner->value.v_identifier); + css_provider_push_scope (css_provider, SCOPE_VALUE); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + color_str = g_strstrip (scanner->value.v_identifier); + color = symbolic_color_parse (color_str); + + if (!color) + return G_TOKEN_IDENTIFIER; + + g_hash_table_insert (priv->symbolic_colors, color_name, color); + + css_provider_pop_scope (css_provider); + g_scanner_get_next_token (scanner); + + if (scanner->token != ';') + return ';'; + + return G_TOKEN_NONE; + } + else return G_TOKEN_IDENTIFIER; - - color_str = g_strstrip (scanner->value.v_identifier); - color = symbolic_color_parse (color_str); - - if (!color) - return G_TOKEN_IDENTIFIER; - - g_hash_table_insert (priv->symbolic_colors, color_name, color); - - css_provider_pop_scope (css_provider); - g_scanner_get_next_token (scanner); - - if (scanner->token != ';') - return ';'; - - return G_TOKEN_NONE; } expected_token = parse_selector (css_provider, scanner, &selector); @@ -2225,14 +2235,14 @@ gtk_css_provider_get_default (void) if (G_UNLIKELY (!provider)) { const gchar *str = - "@fg_color: #000; \n" - "@bg_color: #dcdad5; \n" - "@text_color: #000; \n" - "@base_color: #fff; \n" - "@selected_bg_color: #4b6983; \n" - "@selected_fg_color: #fff; \n" - "@tooltip_bg_color: #eee1b3; \n" - "@tooltip_fg_color: #000; \n" + "@define-color fg_color #000; \n" + "@define-color bg_color #dcdad5; \n" + "@define-color text_color #000; \n" + "@define-color base_color #fff; \n" + "@define-color selected_bg_color #4b6983; \n" + "@define-color selected_fg_color #fff; \n" + "@define-color tooltip_bg_color #eee1b3; \n" + "@define-color tooltip_fg_color #000; \n" "\n" "*,\n" "GtkTreeView > GtkButton {\n" From 8e96e4e41f2e18a07c049c53389436c8eaddb38a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 8 Oct 2010 18:27:22 +0200 Subject: [PATCH 325/634] GtkCssProvider: improve file paths parser. It will now return a full path, and check about the file being sane. --- gtk/gtkcssprovider.c | 72 ++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2dd42c0675..36ef3613ad 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1571,8 +1571,9 @@ gradient_parse (const gchar *str) } static gchar * -url_parse_str (const gchar *str, - gchar **end_ptr) +path_parse_str (GtkCssProvider *css_provider, + const gchar *str, + gchar **end_ptr) { gchar *path, *chr; @@ -1607,6 +1608,54 @@ url_parse_str (const gchar *str, *end_ptr = chr + 1; + /* Always return an absolute path */ + if (!g_path_is_absolute (path)) + { + GtkCssProviderPrivate *priv; + gchar *dirname, *full_path; + + priv = css_provider->priv; + + /* Use relative path to the current CSS file path, if any */ + dirname = g_path_get_dirname (priv->filename); + + full_path = g_build_filename (dirname, path, NULL); + g_free (path); + g_free (dirname); + + path = full_path; + } + + if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) + { + g_warning ("File doesn't exist: %s\n", path); + g_free (path); + path = NULL; + } + + return path; +} + +static gchar * +path_parse (GtkCssProvider *css_provider, + const gchar *str) +{ + gchar *path, *end; + + path = path_parse_str (css_provider, str, &end); + + if (*end != '\0') + { + g_warning ("Error parsing file path \"%s\", stopped at char %ld : '%c'", + str, end - str, *end); + + if (path) + { + g_free (path); + path = NULL; + } + } + return path; } @@ -1627,28 +1676,11 @@ slice_parse_str (GtkCssProvider *css_provider, SKIP_SPACES (str); /* Parse image url */ - path = url_parse_str (str, end_ptr); + path = path_parse_str (css_provider, str, end_ptr); if (!path) return NULL; - if (!g_path_is_absolute (path)) - { - GtkCssProviderPrivate *priv; - gchar *dirname, *full_path; - - priv = css_provider->priv; - - /* Use relative path to the current CSS file path, if any */ - dirname = g_path_get_dirname (priv->filename); - - full_path = g_build_filename (dirname, path, NULL); - g_free (path); - g_free (dirname); - - path = full_path; - } - str = *end_ptr; SKIP_SPACES (str); From 0ef48c0bde29bad9ee1cbd59a4544478d00a54a5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 8 Oct 2010 18:32:10 +0200 Subject: [PATCH 326/634] GtkCssProvider: no need for resetting the parser prior to parsing data This is done anyway on each iteration to parse_rule() in parse_stylesheet() --- gtk/gtkcssprovider.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 36ef3613ad..471a8b3ef1 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2159,7 +2159,6 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, if (priv->selectors_info->len > 0) g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); - css_provider_reset_parser (css_provider); priv->scanner->input_name = "-"; g_scanner_input_text (priv->scanner, data, (guint) length); @@ -2200,7 +2199,6 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, g_free (priv->filename); priv->filename = g_file_get_path (file); - css_provider_reset_parser (css_provider); priv->scanner->input_name = priv->filename; g_scanner_input_text (priv->scanner, data, (guint) length); @@ -2248,7 +2246,6 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, g_free (priv->filename); priv->filename = g_strdup (path); - css_provider_reset_parser (css_provider); priv->scanner->input_name = priv->filename; g_scanner_input_text (priv->scanner, data, (guint) length); From f9788eb173e59df9671551b2ac727f5a4729fc17 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 8 Oct 2010 18:36:46 +0200 Subject: [PATCH 327/634] GtkCssProvider: Add support for @import rules Now other CSS files can be referenced from the currently parsed file: @import url (other-file.css); @import url (/some/file.css); --- gtk/gtkcssprovider.c | 173 +++++++++++++++++++++++++++++++------------ 1 file changed, 127 insertions(+), 46 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 471a8b3ef1..598b1ffbee 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -125,11 +125,16 @@ enum ParserSymbol { static void gtk_css_provider_finalize (GObject *object); static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); -static void css_provider_apply_scope (GtkCssProvider *css_provider, - ParserScope scope); +static void scanner_apply_scope (GScanner *scanner, + ParserScope scope); static gboolean css_provider_parse_value (GtkCssProvider *css_provider, const gchar *value_str, GValue *value); +static gboolean gtk_css_provider_load_from_path_internal (GtkCssProvider *css_provider, + const gchar *path, + gboolean reset, + GError **error); + G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, @@ -317,18 +322,11 @@ selector_style_info_set_style (SelectorStyleInfo *info, info->style = NULL; } -static void -gtk_css_provider_init (GtkCssProvider *css_provider) +static GScanner * +create_scanner (void) { - GtkCssProviderPrivate *priv; GScanner *scanner; - priv = css_provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (css_provider, - GTK_TYPE_CSS_PROVIDER, - GtkCssProviderPrivate); - - priv->selectors_info = g_ptr_array_new_with_free_func ((GDestroyNotify) selector_style_info_free); - scanner = g_scanner_new (NULL); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "active", GUINT_TO_POINTER (GTK_STATE_ACTIVE)); @@ -346,8 +344,22 @@ gtk_css_provider_init (GtkCssProvider *css_provider) g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "first", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_FIRST)); g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "last", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_LAST)); - priv->scanner = scanner; - css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + scanner_apply_scope (scanner, SCOPE_SELECTOR); + + return scanner; +} + +static void +gtk_css_provider_init (GtkCssProvider *css_provider) +{ + GtkCssProviderPrivate *priv; + + priv = css_provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (css_provider, + GTK_TYPE_CSS_PROVIDER, + GtkCssProviderPrivate); + + priv->selectors_info = g_ptr_array_new_with_free_func ((GDestroyNotify) selector_style_info_free); + priv->scanner = create_scanner (); priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, @@ -756,40 +768,36 @@ property_value_free (GValue *value) } static void -css_provider_apply_scope (GtkCssProvider *css_provider, - ParserScope scope) +scanner_apply_scope (GScanner *scanner, + ParserScope scope) { - GtkCssProviderPrivate *priv; - - priv = css_provider->priv; - - g_scanner_set_scope (priv->scanner, scope); + g_scanner_set_scope (scanner, scope); if (scope == SCOPE_VALUE) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\n" G_CSET_A_2_Z; - priv->scanner->config->scan_identifier_1char = TRUE; + scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\n" G_CSET_A_2_Z; + scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_#" G_CSET_A_2_Z; - priv->scanner->config->scan_identifier_1char = TRUE; + scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_#" G_CSET_A_2_Z; + scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_PSEUDO_CLASS || scope == SCOPE_NTH_CHILD || scope == SCOPE_DECLARATION) { - priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "-" G_CSET_A_2_Z; - priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; - priv->scanner->config->scan_identifier_1char = FALSE; + scanner->config->cset_identifier_first = G_CSET_a_2_z "-" G_CSET_A_2_Z; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z; + scanner->config->scan_identifier_1char = FALSE; } else g_assert_not_reached (); - priv->scanner->config->scan_float = FALSE; - priv->scanner->config->cpair_comment_single = NULL; + scanner->config->scan_float = FALSE; + scanner->config->cpair_comment_single = NULL; } static void @@ -801,7 +809,7 @@ css_provider_push_scope (GtkCssProvider *css_provider, priv = css_provider->priv; priv->state = g_slist_prepend (priv->state, GUINT_TO_POINTER (scope)); - css_provider_apply_scope (css_provider, scope); + scanner_apply_scope (priv->scanner, scope); } static ParserScope @@ -815,7 +823,7 @@ css_provider_pop_scope (GtkCssProvider *css_provider) if (!priv->state) { g_warning ("Push/pop calls to parser scope aren't paired"); - css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + scanner_apply_scope (priv->scanner, SCOPE_SELECTOR); return SCOPE_SELECTOR; } @@ -825,7 +833,7 @@ css_provider_pop_scope (GtkCssProvider *css_provider) if (priv->state) scope = GPOINTER_TO_INT (priv->state->data); - css_provider_apply_scope (css_provider, scope); + scanner_apply_scope (priv->scanner, scope); return scope; } @@ -840,7 +848,7 @@ css_provider_reset_parser (GtkCssProvider *css_provider) g_slist_free (priv->state); priv->state = NULL; - css_provider_apply_scope (css_provider, SCOPE_SELECTOR); + scanner_apply_scope (priv->scanner, SCOPE_SELECTOR); g_slist_foreach (priv->cur_selectors, (GFunc) selector_path_unref, NULL); g_slist_free (priv->cur_selectors); @@ -1979,6 +1987,64 @@ parse_rule (GtkCssProvider *css_provider, return G_TOKEN_NONE; } + else if (strcmp (directive, "import") == 0) + { + GScanner *scanner_backup; + GSList *state_backup; + GError *error = NULL; + gboolean loaded; + gchar *path; + + css_provider_push_scope (css_provider, SCOPE_VALUE); + g_scanner_get_next_token (scanner); + + if (scanner->token != G_TOKEN_IDENTIFIER) + return G_TOKEN_IDENTIFIER; + + path = path_parse (css_provider, + g_strstrip (scanner->value.v_identifier)); + + if (!path) + return G_TOKEN_IDENTIFIER; + + css_provider_pop_scope (css_provider); + g_scanner_get_next_token (scanner); + + if (scanner->token != ';') + { + g_free (path); + return ';'; + } + + /* Snapshot current parser state and scanner in order to restore after importing */ + state_backup = priv->state; + scanner_backup = priv->scanner; + + priv->state = NULL; + priv->scanner = create_scanner (); + + /* FIXME: Avoid recursive importing */ + loaded = gtk_css_provider_load_from_path_internal (css_provider, path, + FALSE, &error); + + /* Restore previous state */ + css_provider_reset_parser (css_provider); + priv->state = state_backup; + g_scanner_destroy (priv->scanner); + priv->scanner = scanner_backup; + + g_free (path); + + if (!loaded) + { + g_warning ("Error loading imported file \"%s\": %s", + path, (error) ? error->message : ""); + g_error_free (error); + return G_TOKEN_IDENTIFIER; + } + else + return G_TOKEN_NONE; + } else return G_TOKEN_IDENTIFIER; } @@ -2209,10 +2275,11 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, return TRUE; } -gboolean -gtk_css_provider_load_from_path (GtkCssProvider *css_provider, - const gchar *path, - GError **error) +static gboolean +gtk_css_provider_load_from_path_internal (GtkCssProvider *css_provider, + const gchar *path, + gboolean reset, + GError **error) { GtkCssProviderPrivate *priv; GError *internal_error = NULL; @@ -2220,9 +2287,6 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, const gchar *data; gsize length; - g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - priv = css_provider->priv; mapped_file = g_mapped_file_new (path, FALSE, &internal_error); @@ -2240,11 +2304,14 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, if (!data) return FALSE; - if (priv->selectors_info->len > 0) - g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); + if (reset) + { + if (priv->selectors_info->len > 0) + g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); - g_free (priv->filename); - priv->filename = g_strdup (path); + g_free (priv->filename); + priv->filename = g_strdup (path); + } priv->scanner->input_name = priv->filename; g_scanner_input_text (priv->scanner, data, (guint) length); @@ -2256,6 +2323,20 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, return TRUE; } +gboolean +gtk_css_provider_load_from_path (GtkCssProvider *css_provider, + const gchar *path, + GError **error) +{ + GtkCssProviderPrivate *priv; + + g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); + g_return_val_if_fail (path != NULL, FALSE); + + return gtk_css_provider_load_from_path_internal (css_provider, path, + TRUE, error); +} + GtkCssProvider * gtk_css_provider_get_default (void) { From c575733edab533c7e36062e06a4a8a9e2382685b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 9 Oct 2010 15:19:52 +0200 Subject: [PATCH 328/634] GtkStyleContext: Fix animation framework to work with the new draw() semantics. Invalidation region coalescing now happens recursively as draw() runs, and the widget's x/y as now drawing coordinates are 0,0 based. --- gtk/gtkstylecontext.c | 9 ++++++++- gtk/gtkstylecontext.h | 4 +++- gtk/gtkwidget.c | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 09236331f0..69e7797d89 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1852,7 +1852,9 @@ _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context) } void -_gtk_style_context_coalesce_animation_areas (GtkStyleContext *context) +_gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, + gint rel_x, + gint rel_y) { GtkStyleContextPrivate *priv; GSList *l; @@ -1885,11 +1887,16 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context) cairo_rectangle_int_t *rect; rect = &g_array_index (info->rectangles, cairo_rectangle_int_t, i); + rect->x += rel_x; + rect->y += rel_y; + cairo_region_union_rectangle (info->invalidation_region, rect); } g_array_remove_range (info->rectangles, 0, info->rectangles->len); } + + priv->animations_invalidated = FALSE; } static void diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 5064bf6f08..3daf753059 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -152,7 +152,9 @@ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, GParamSpec *pspec); void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context); -void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context); +void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, + gint rel_x, + gint rel_y); /* Animation for state changes */ void gtk_style_context_state_transition_start (GtkStyleContext *context, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 0694f5cd2d..3dfbc6ce2d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4160,7 +4160,6 @@ gtk_widget_realize (GtkWidget *widget) GtkWidgetPrivate *priv; GdkExtensionMode mode; cairo_region_t *region; - GtkStyleContext *context; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (widget->priv->anchored || @@ -5413,6 +5412,8 @@ _gtk_widget_draw_internal (GtkWidget *widget, cairo_t *cr, gboolean clip_to_size) { + GtkStyleContext *context; + if (!gtk_widget_is_drawable (widget)) return; @@ -5433,6 +5434,11 @@ _gtk_widget_draw_internal (GtkWidget *widget, 0, cr, &result); } + + context = gtk_widget_get_style_context (widget); + _gtk_style_context_coalesce_animation_areas (context, + widget->priv->allocation.x, + widget->priv->allocation.y); } /** @@ -5652,7 +5658,6 @@ gtk_widget_send_expose (GtkWidget *widget, cairo_t *cr; int x, y; gboolean do_clip; - GtkStyleContext *context; g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE); g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE); @@ -5677,9 +5682,6 @@ gtk_widget_send_expose (GtkWidget *widget, gtk_cairo_set_event (cr, NULL); cairo_destroy (cr); - context = gtk_widget_get_style_context (widget); - _gtk_style_context_coalesce_animation_areas (context); - return result; } From 88b78953b68b01d9ac2f46b088322e4188fb9f38 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 11 Oct 2010 00:23:40 +0200 Subject: [PATCH 329/634] GtkContainer: Add method to get the GtkWidgetPath for a child. This is now used throughout in order to have the full path for a given widget, including intermediate named regions, the default implementation just returns the GtkContainer's path copy, no intermediate regions between. --- gtk/gtkcontainer.c | 22 +++++++++ gtk/gtkcontainer.h | 5 ++ gtk/gtkstylecontext.c | 21 +++++---- gtk/gtkwidget.c | 105 ++++++++++++++++-------------------------- gtk/gtkwidgetpath.c | 15 ++++++ gtk/gtkwidgetpath.h | 2 + 6 files changed, 95 insertions(+), 75 deletions(-) diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index a37e361d65..8c09ba2514 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -334,6 +334,9 @@ static void gtk_container_adjust_size_allocation (GtkWidget *widget, static gchar* gtk_container_child_default_composite_name (GtkContainer *container, GtkWidget *child); +static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container, + GtkWidget *child); + /* GtkBuildable */ static void gtk_container_buildable_init (GtkBuildableIface *iface); static void gtk_container_buildable_add_child (GtkBuildable *buildable, @@ -465,6 +468,7 @@ gtk_container_class_init (GtkContainerClass *class) class->set_focus_child = gtk_container_real_set_focus_child; class->child_type = NULL; class->composite_name = gtk_container_child_default_composite_name; + class->get_path_for_child = gtk_container_real_get_path_for_child; g_object_class_install_property (gobject_class, PROP_RESIZE_MODE, @@ -2207,6 +2211,13 @@ gtk_container_get_all_children (GtkContainer *container) return children; } +static GtkWidgetPath * +gtk_container_real_get_path_for_child (GtkContainer *container, + GtkWidget *child) +{ + return gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container))); +} + static gboolean gtk_container_focus (GtkWidget *widget, GtkDirectionType direction) @@ -3220,3 +3231,14 @@ _gtk_container_get_reallocate_redraws (GtkContainer *container) { return container->priv->reallocate_redraws; } + +GtkWidgetPath * +gtk_container_get_path_for_child (GtkContainer *container, + GtkWidget *child) +{ + g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL); + g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); + g_return_val_if_fail (container == (GtkContainer *) gtk_widget_get_parent (child), NULL); + + return GTK_CONTAINER_GET_CLASS (container)->get_path_for_child (container, child); +} diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index f469d89eba..94a8502c8f 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -88,6 +88,8 @@ struct _GtkContainerClass guint property_id, GValue *value, GParamSpec *pspec); + GtkWidgetPath * (*get_path_for_child) (GtkContainer *container, + GtkWidget *child); /* Padding for future expansion */ void (*_gtk_reserved1) (void); @@ -228,6 +230,9 @@ void _gtk_container_set_need_resize (GtkContainer *container, gboolean need_resize); gboolean _gtk_container_get_reallocate_redraws (GtkContainer *container); +GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container, + GtkWidget *child); + G_END_DECLS #endif /* __GTK_CONTAINER_H__ */ diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 69e7797d89..13d15f9179 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -524,11 +524,14 @@ rebuild_properties (GtkStyleContext *context) priv = context->priv; list = priv->providers; + gtk_style_set_clear (priv->store); + + if (!priv->widget_path) + return; + if (priv->screen) global_list = g_object_get_qdata (G_OBJECT (priv->screen), provider_list_quark); - gtk_style_set_clear (priv->store); - while ((elem = find_next_candidate (list, global_list)) != NULL) { GtkStyleProviderData *data; @@ -566,11 +569,13 @@ rebuild_icon_factories (GtkStyleContext *context) GList *elem, *list, *global_list = NULL; priv = context->priv; - g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free (priv->icon_factories); priv->icon_factories = NULL; + if (!priv->widget_path) + return; + list = priv->providers_last; if (priv->screen) @@ -948,10 +953,9 @@ gtk_style_context_set_path (GtkStyleContext *context, } if (path) - { - priv->widget_path = gtk_widget_path_copy (path); - gtk_style_context_invalidate (context); - } + priv->widget_path = gtk_widget_path_copy (path); + + gtk_style_context_invalidate (context); } G_CONST_RETURN GtkWidgetPath * @@ -1953,9 +1957,6 @@ gtk_style_context_invalidate (GtkStyleContext *context) if (priv->invalidating_context) return; - if (!priv->widget_path) - return; - priv->invalidating_context = TRUE; rebuild_properties (context); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3dfbc6ce2d..4da12a1639 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -374,6 +374,9 @@ struct _GtkWidgetPrivate /* The widget's parent. */ GtkWidget *parent; + + /* Widget's path for styling */ + GtkWidgetPath *path; }; enum { @@ -7229,6 +7232,18 @@ gtk_widget_is_sensitive (GtkWidget *widget) return widget->priv->sensitive && widget->priv->parent_sensitive; } +static void +_gtk_widget_update_path (GtkWidget *widget) +{ + if (widget->priv->path) + { + gtk_widget_path_free (widget->priv->path); + widget->priv->path = NULL; + } + + gtk_widget_get_path (widget); +} + /** * gtk_widget_set_parent: * @widget: a #GtkWidget @@ -7326,11 +7341,8 @@ gtk_widget_set_parent (GtkWidget *widget, quark_style_context); if (context) { - GtkWidgetPath *path; - - path = gtk_widget_get_path (widget); - gtk_style_context_set_path (context, path); - gtk_widget_path_free (path); + _gtk_widget_update_path (widget); + gtk_style_context_set_path (context, widget->priv->path); gtk_style_context_set_screen (context, gtk_widget_get_screen (widget)); @@ -8139,7 +8151,10 @@ reset_style_recurse (GtkWidget *widget, gpointer data) context = g_object_get_qdata (G_OBJECT (widget), quark_style_context); if (context) - gtk_style_context_invalidate (context); + { + _gtk_widget_update_path (widget); + gtk_style_context_set_path (context, widget->priv->path); + } if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), @@ -13267,71 +13282,34 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget) { - GtkStyleContext *context; - GtkWidgetPath *path; - GtkWidget *parent; - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - parent = widget->priv->parent; - - path = gtk_widget_path_new (); - gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); - - if (widget->priv->name) - gtk_widget_path_iter_set_name (path, 0, widget->priv->name); - - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - - if (context) + if (!widget->priv->path) { - GList *list, *l; + GtkWidget *parent; + guint pos; - list = l = gtk_style_context_list_regions (context); + parent = widget->priv->parent; - while (l) + if (parent) + widget->priv->path = gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget); + else { - GtkRegionFlags flags; - const gchar *region_name; - - region_name = l->data; - l = l->next; - - gtk_style_context_has_region (context, region_name, &flags); - gtk_widget_path_iter_add_region (path, 0, region_name, flags); + /* Widget is either toplevel or unparented, treat both + * as toplevels style wise, since there are situations + * where style properties might be retrieved on that + * situation. + */ + widget->priv->path = gtk_widget_path_new (); } - g_list_free (list); + pos = gtk_widget_path_append_type (widget->priv->path, G_OBJECT_TYPE (widget)); - list = l = gtk_style_context_list_classes (context); - - while (l) - { - const gchar *class_name; - - class_name = l->data; - l = l->next; - - gtk_widget_path_iter_add_class (path, 0, class_name); - } - - g_list_free (list); + if (widget->priv->name) + gtk_widget_path_iter_set_name (widget->priv->path, pos, widget->priv->name); } - while (parent) - { - guint position; - - position = gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (parent)); - - if (parent->priv->name) - gtk_widget_path_iter_set_name (path, position, parent->priv->name); - - parent = parent->priv->parent; - } - - return path; + return widget->priv->path; } static void @@ -13355,8 +13333,6 @@ gtk_widget_get_style_context (GtkWidget *widget) if (G_UNLIKELY (!context)) { - GtkWidgetPath *path; - context = g_object_new (GTK_TYPE_STYLE_CONTEXT, "direction", gtk_widget_get_direction (widget), NULL); @@ -13371,9 +13347,8 @@ gtk_widget_get_style_context (GtkWidget *widget) gtk_style_context_set_screen (context, gtk_widget_get_screen (widget)); - path = gtk_widget_get_path (widget); - gtk_style_context_set_path (context, path); - gtk_widget_path_free (path); + _gtk_widget_update_path (widget); + gtk_style_context_set_path (context, widget->priv->path); } return context; diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 933a2dc0c7..c6cfbb5c81 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -128,6 +128,21 @@ gtk_widget_path_prepend_type (GtkWidgetPath *path, g_return_val_if_fail (path != NULL, 0); g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), 0); + new.type = type; + g_array_prepend_val (path->elems, new); + + return 0; +} + +guint +gtk_widget_path_append_type (GtkWidgetPath *path, + GType type) +{ + GtkPathElement new = { 0 }; + + g_return_val_if_fail (path != NULL, 0); + g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), 0); + new.type = type; g_array_append_val (path->elems, new); diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 234f79b937..4e5c4769cb 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -35,6 +35,8 @@ void gtk_widget_path_free (GtkWidgetPath *path); guint gtk_widget_path_length (const GtkWidgetPath *path); +guint gtk_widget_path_append_type (GtkWidgetPath *path, + GType type); guint gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type); From 5bbab9872da0ea8ebb0c08a056d5cb1770a11bfb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 11 Oct 2010 17:58:31 +0200 Subject: [PATCH 330/634] GtkStyleContext: Cache style properties accross class/region changes. --- gtk/gtkstylecontext.c | 395 ++++++++++++++++++++++++++++-------------- 1 file changed, 262 insertions(+), 133 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 13d15f9179..ff58377274 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -39,6 +39,7 @@ typedef struct GtkStyleInfo GtkStyleInfo; typedef struct GtkRegion GtkRegion; typedef struct PropertyValue PropertyValue; typedef struct AnimationInfo AnimationInfo; +typedef struct StyleData StyleData; struct GtkRegion { @@ -66,6 +67,13 @@ struct GtkStyleInfo GtkJunctionSides junction_sides; }; +struct StyleData +{ + GtkStyleSet *store; + GSList *icon_factories; + GArray *property_cache; +}; + struct AnimationInfo { GtkTimeline *timeline; @@ -86,15 +94,12 @@ struct GtkStyleContextPrivate GList *providers; GList *providers_last; - GSList *icon_factories; - - GtkStyleSet *store; GtkWidgetPath *widget_path; - - GArray *property_cache; + GHashTable *style_data; + GSList *info_stack; + StyleData *current_data; GtkStateFlags state_flags; - GSList *info_stack; GSList *animation_regions; GSList *animations; @@ -212,6 +217,107 @@ style_info_copy (const GtkStyleInfo *info) return copy; } +static guint +style_info_hash (gconstpointer elem) +{ + const GtkStyleInfo *info; + guint i, hash = 0; + + info = elem; + + for (i = 0; i < info->style_classes->len; i++) + { + hash += g_array_index (info->style_classes, GQuark, i); + hash <<= 5; + } + + for (i = 0; i < info->regions->len; i++) + { + GtkRegion *region; + + region = &g_array_index (info->regions, GtkRegion, i); + hash += region->class_quark; + hash += region->flags; + hash <<= 5; + } + + return hash; +} + +static gboolean +style_info_equal (gconstpointer elem1, + gconstpointer elem2) +{ + const GtkStyleInfo *info1, *info2; + + info1 = elem1; + info2 = elem2; + + if (info1->junction_sides != info2->junction_sides) + return FALSE; + + if (info1->style_classes->len != info2->style_classes->len) + return FALSE; + + if (memcmp (info1->style_classes->data, + info2->style_classes->data, + info1->style_classes->len * sizeof (GQuark)) != 0) + return FALSE; + + if (info1->regions->len != info2->regions->len) + return FALSE; + + if (memcmp (info1->regions->data, + info2->regions->data, + info1->regions->len * sizeof (GtkRegion)) != 0) + return FALSE; + + return TRUE; +} + +static StyleData * +style_data_new (void) +{ + StyleData *data; + + data = g_slice_new0 (StyleData); + data->store = gtk_style_set_new (); + + return data; +} + +static void +clear_property_cache (StyleData *data) +{ + guint i; + + if (!data->property_cache) + return; + + for (i = 0; i < data->property_cache->len; i++) + { + PropertyValue *node = &g_array_index (data->property_cache, PropertyValue, i); + + g_param_spec_unref (node->pspec); + g_value_unset (&node->value); + } + + g_array_free (data->property_cache, TRUE); + data->property_cache = NULL; +} + +static void +style_data_free (StyleData *data) +{ + g_object_unref (data->store); + clear_property_cache (data); + + g_slist_foreach (data->icon_factories, (GFunc) g_object_unref, NULL); + g_slist_free (data->icon_factories); + + g_slice_free (StyleData, data); +} + static void gtk_style_context_init (GtkStyleContext *style_context) { @@ -222,7 +328,10 @@ gtk_style_context_init (GtkStyleContext *style_context) GTK_TYPE_STYLE_CONTEXT, GtkStyleContextPrivate); - priv->store = gtk_style_set_new (); + priv->style_data = g_hash_table_new_full (style_info_hash, + style_info_equal, + (GDestroyNotify) style_info_free, + (GDestroyNotify) style_data_free); priv->theming_engine = g_object_ref ((gpointer) gtk_theming_engine_load (NULL)); priv->direction = GTK_TEXT_DIR_RTL; @@ -252,30 +361,6 @@ style_provider_data_free (GtkStyleProviderData *data) g_slice_free (GtkStyleProviderData, data); } -static void -clear_property_cache (GtkStyleContext *context) -{ - GtkStyleContextPrivate *priv; - - priv = context->priv; - - if (priv->property_cache) - { - guint i; - - for (i = 0; i < priv->property_cache->len; i++) - { - PropertyValue *node = &g_array_index (priv->property_cache, PropertyValue, i); - - g_param_spec_unref (node->pspec); - g_value_unset (&node->value); - } - - g_array_free (priv->property_cache, TRUE); - priv->property_cache = NULL; - } -} - static void animation_info_free (AnimationInfo *info) { @@ -411,19 +496,14 @@ gtk_style_context_finalize (GObject *object) if (priv->widget_path) gtk_widget_path_free (priv->widget_path); - g_object_unref (priv->store); + g_hash_table_destroy (priv->style_data); g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); g_list_free (priv->providers); - clear_property_cache (GTK_STYLE_CONTEXT (object)); - g_slist_foreach (priv->info_stack, (GFunc) style_info_free, NULL); g_slist_free (priv->info_stack); - g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); - g_slist_free (priv->icon_factories); - g_slist_free (priv->animation_regions); for (l = priv->animations; l; l = l->next) @@ -516,7 +596,9 @@ find_next_candidate (GList *local, } static void -rebuild_properties (GtkStyleContext *context) +build_properties (GtkStyleContext *context, + StyleData *style_data, + GtkWidgetPath *path) { GtkStyleContextPrivate *priv; GList *elem, *list, *global_list = NULL; @@ -524,11 +606,6 @@ rebuild_properties (GtkStyleContext *context) priv = context->priv; list = priv->providers; - gtk_style_set_clear (priv->store); - - if (!priv->widget_path) - return; - if (priv->screen) global_list = g_object_get_qdata (G_OBJECT (priv->screen), provider_list_quark); @@ -544,38 +621,25 @@ rebuild_properties (GtkStyleContext *context) else global_list = global_list->next; - provider_style = gtk_style_provider_get_style (data->provider, - priv->widget_path); + provider_style = gtk_style_provider_get_style (data->provider, path); if (provider_style) { - gtk_style_set_merge (priv->store, provider_style, TRUE); + gtk_style_set_merge (style_data->store, provider_style, TRUE); g_object_unref (provider_style); } } - - if (priv->theming_engine) - g_object_unref (priv->theming_engine); - - gtk_style_set_get (priv->store, 0, - "engine", &priv->theming_engine, - NULL); } static void -rebuild_icon_factories (GtkStyleContext *context) +build_icon_factories (GtkStyleContext *context, + StyleData *style_data, + GtkWidgetPath *path) { GtkStyleContextPrivate *priv; GList *elem, *list, *global_list = NULL; priv = context->priv; - g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL); - g_slist_free (priv->icon_factories); - priv->icon_factories = NULL; - - if (!priv->widget_path) - return; - list = priv->providers_last; if (priv->screen) @@ -596,14 +660,95 @@ rebuild_icon_factories (GtkStyleContext *context) else global_list = global_list->prev; - factory = gtk_style_provider_get_icon_factory (data->provider, - priv->widget_path); + factory = gtk_style_provider_get_icon_factory (data->provider, path); if (factory) - priv->icon_factories = g_slist_prepend (priv->icon_factories, factory); + style_data->icon_factories = g_slist_prepend (style_data->icon_factories, factory); } } +GtkWidgetPath * +create_query_path (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + GtkWidgetPath *path; + GtkStyleInfo *info; + guint i, pos; + + priv = context->priv; + path = gtk_widget_path_copy (priv->widget_path); + pos = gtk_widget_path_length (path) - 1; + + info = priv->info_stack->data; + + /* Set widget regions */ + for (i = 0; i < info->regions->len; i++) + { + GtkRegion *region; + + region = &g_array_index (info->regions, GtkRegion, i); + gtk_widget_path_iter_add_region (path, pos, + g_quark_to_string (region->class_quark), + region->flags); + } + + /* Set widget classes */ + for (i = 0; i < info->style_classes->len; i++) + { + GQuark quark; + + quark = g_array_index (info->style_classes, GQuark, i); + gtk_widget_path_iter_add_class (path, pos, + g_quark_to_string (quark)); + } + + return path; +} + +StyleData * +style_data_lookup (GtkStyleContext *context) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + + priv = context->priv; + + /* Current data in use is cached, just return it */ + if (priv->current_data) + return priv->current_data; + + g_assert (priv->widget_path != NULL); + + data = g_hash_table_lookup (priv->style_data, priv->info_stack->data); + + if (!data) + { + GtkWidgetPath *path; + + data = style_data_new (); + path = create_query_path (context); + + build_properties (context, data, path); + build_icon_factories (context, data, path); + + g_hash_table_insert (priv->style_data, + style_info_copy (priv->info_stack->data), + data); + + gtk_widget_path_free (path); + } + + priv->current_data = data; + + if (priv->theming_engine) + g_object_unref (priv->theming_engine); + + gtk_style_set_get (data->store, 0, + "engine", &priv->theming_engine, + NULL); + return data; +} + static void style_provider_add (GList **list, GtkStyleProvider *provider, @@ -787,13 +932,18 @@ gtk_style_context_get_property (GtkStyleContext *context, GValue *value) { GtkStyleContextPrivate *priv; + StyleData *data; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (property != NULL); g_return_if_fail (value != NULL); priv = context->priv; - gtk_style_set_get_property (priv->store, property, state, value); + + g_return_if_fail (priv->widget_path != NULL); + + data = style_data_lookup (context); + gtk_style_set_get_property (data->store, property, state, value); } void @@ -802,11 +952,15 @@ gtk_style_context_get_valist (GtkStyleContext *context, va_list args) { GtkStyleContextPrivate *priv; + StyleData *data; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); priv = context->priv; - gtk_style_set_get_valist (priv->store, state, args); + g_return_if_fail (priv->widget_path != NULL); + + data = style_data_lookup (context); + gtk_style_set_get_valist (data->store, state, args); } void @@ -815,14 +969,18 @@ gtk_style_context_get (GtkStyleContext *context, ...) { GtkStyleContextPrivate *priv; + StyleData *data; va_list args; 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); va_start (args, state); - gtk_style_set_get_valist (priv->store, state, args); + gtk_style_set_get_valist (data->store, state, args); va_end (args); } @@ -1009,37 +1167,7 @@ gtk_style_context_restore (GtkStyleContext *context) priv->info_stack = g_slist_prepend (priv->info_stack, info); } - if (priv->widget_path) - { - guint i; - - info = priv->info_stack->data; - - /* Update widget path regions */ - gtk_widget_path_iter_clear_regions (priv->widget_path, 0); - - for (i = 0; i < info->regions->len; i++) - { - GtkRegion *region; - - region = &g_array_index (info->regions, GtkRegion, i); - gtk_widget_path_iter_add_region (priv->widget_path, 0, - g_quark_to_string (region->class_quark), - region->flags); - } - - /* Update widget path classes */ - gtk_widget_path_iter_clear_classes (priv->widget_path, 0); - - for (i = 0; i < info->style_classes->len; i++) - { - GQuark quark; - - quark = g_array_index (info->style_classes, GQuark, i); - gtk_widget_path_iter_add_class (priv->widget_path, 0, - g_quark_to_string (quark)); - } - } + priv->current_data = NULL; } static gboolean @@ -1156,11 +1284,8 @@ gtk_style_context_set_class (GtkStyleContext *context, { g_array_insert_val (info->style_classes, position, class_quark); - if (priv->widget_path) - { - gtk_widget_path_iter_add_class (priv->widget_path, 0, class_name); - gtk_style_context_invalidate (context); - } + /* Unset current data, as it likely changed due to the class change */ + priv->current_data = NULL; } } @@ -1190,11 +1315,8 @@ gtk_style_context_unset_class (GtkStyleContext *context, { g_array_remove_index (info->style_classes, position); - if (priv->widget_path) - { - gtk_widget_path_iter_remove_class (priv->widget_path, 0, class_name); - gtk_style_context_invalidate (context); - } + /* Unset current data, as it likely changed due to the class change */ + priv->current_data = NULL; } } @@ -1308,11 +1430,8 @@ gtk_style_context_set_region (GtkStyleContext *context, g_array_insert_val (info->regions, position, region); - if (priv->widget_path) - { - gtk_widget_path_iter_add_region (priv->widget_path, 0, class_name, flags); - gtk_style_context_invalidate (context); - } + /* Unset current data, as it likely changed due to the region change */ + priv->current_data = NULL; } } @@ -1342,11 +1461,8 @@ gtk_style_context_unset_region (GtkStyleContext *context, { g_array_remove_index (info->regions, position); - if (priv->widget_path) - { - gtk_widget_path_iter_remove_region (priv->widget_path, 0, class_name); - gtk_style_context_invalidate (context); - } + /* Unset current data, as it likely changed due to the region change */ + priv->current_data = NULL; } } @@ -1411,33 +1527,35 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, { GtkStyleContextPrivate *priv; PropertyValue *pcache, key = { 0 }; + StyleData *data; GList *list; guint i; priv = context->priv; + data = style_data_lookup (context); key.widget_type = widget_type; key.pspec = pspec; /* need value cache array */ - if (!priv->property_cache) - priv->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue)); + if (!data->property_cache) + data->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue)); else { pcache = bsearch (&key, - priv->property_cache->data, priv->property_cache->len, + data->property_cache->data, data->property_cache->len, sizeof (PropertyValue), style_property_values_cmp); if (pcache) return &pcache->value; } i = 0; - while (i < priv->property_cache->len && - style_property_values_cmp (&key, &g_array_index (priv->property_cache, PropertyValue, i)) >= 0) + while (i < data->property_cache->len && + style_property_values_cmp (&key, &g_array_index (data->property_cache, PropertyValue, i)) >= 0) i++; - g_array_insert_val (priv->property_cache, i, key); - pcache = &g_array_index (priv->property_cache, PropertyValue, i); + g_array_insert_val (data->property_cache, i, key); + pcache = &g_array_index (data->property_cache, PropertyValue, i); /* cache miss, initialize value type, then set contents */ g_param_spec_ref (pcache->pspec); @@ -1589,14 +1707,18 @@ gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id) { GtkStyleContextPrivate *priv; + StyleData *data; GSList *list; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); g_return_val_if_fail (stock_id != NULL, NULL); priv = context->priv; + g_return_val_if_fail (priv->widget_path != NULL, NULL); - for (list = priv->icon_factories; list; list = list->next) + data = style_data_lookup (context); + + for (list = data->icon_factories; list; list = list->next) { GtkIconFactory *factory; GtkIconSet *icon_set; @@ -1697,18 +1819,22 @@ gtk_style_context_lookup_color (GtkStyleContext *context, { GtkStyleContextPrivate *priv; GtkSymbolicColor *sym_color; + StyleData *data; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); g_return_val_if_fail (color_name != NULL, FALSE); g_return_val_if_fail (color != NULL, FALSE); priv = context->priv; - sym_color = gtk_style_set_lookup_color (priv->store, color_name); + g_return_val_if_fail (priv->widget_path != NULL, FALSE); + + data = style_data_lookup (context); + sym_color = gtk_style_set_lookup_color (data->store, color_name); if (!sym_color) return FALSE; - return gtk_symbolic_color_resolve (sym_color, priv->store, color); + return gtk_symbolic_color_resolve (sym_color, data->store, color); } void @@ -1722,13 +1848,16 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, GtkAnimationDescription *desc; AnimationInfo *info; GtkStateFlags flags; + StyleData *data; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (state < GTK_STATE_LAST); - state_value = (state_value == TRUE); priv = context->priv; + g_return_if_fail (priv->widget_path != NULL); + + state_value = (state_value == TRUE); switch (state) { @@ -1759,7 +1888,8 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, /* Find out if there is any animation description for the given * state, it will fallback to the normal state as well if necessary. */ - gtk_style_set_get (priv->store, flags, + data = style_data_lookup (context); + gtk_style_set_get (data->store, flags, "transition", &desc, NULL); @@ -1959,9 +2089,8 @@ gtk_style_context_invalidate (GtkStyleContext *context) priv->invalidating_context = TRUE; - rebuild_properties (context); - clear_property_cache (context); - rebuild_icon_factories (context); + g_hash_table_remove_all (priv->style_data); + priv->current_data = NULL; g_signal_emit (context, signals[CHANGED], 0); From a65d0d00c003452f65273c6acc6793f1d815fa51 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 11 Oct 2010 19:27:36 +0200 Subject: [PATCH 331/634] GtkWidget: Store GtkStyleContext in private struct. --- gtk/gtkwidget.c | 69 +++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4da12a1639..8ab15be5e2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -357,6 +357,7 @@ struct _GtkWidgetPrivate * the font to use for text. */ GtkStyle *style; + GtkStyleContext *context; /* The widget's allocated size. */ @@ -678,7 +679,6 @@ static GQuark quark_tooltip_markup = 0; static GQuark quark_has_tooltip = 0; static GQuark quark_tooltip_window = 0; static GQuark quark_visual = 0; -static GQuark quark_style_context = 0; GParamSpecPool *_gtk_widget_child_property_pool = NULL; GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL; @@ -792,7 +792,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip"); quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window"); quark_visual = g_quark_from_static_string ("gtk-widget-visual"); - quark_style_context = g_quark_from_static_string ("gtk-style-context"); style_property_spec_pool = g_param_spec_pool_new (FALSE); _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE); @@ -6239,12 +6238,8 @@ gtk_widget_real_query_tooltip (GtkWidget *widget, static void gtk_widget_real_style_updated (GtkWidget *widget) { - GtkStyleContext *context; - - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - if (context) - gtk_style_context_invalidate (context); + if (widget->priv->context) + gtk_style_context_invalidate (widget->priv->context); } static gboolean @@ -7262,7 +7257,6 @@ gtk_widget_set_parent (GtkWidget *widget, { GtkWidgetPrivate *priv; GtkStateData data; - GtkStyleContext *context; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (parent)); @@ -7337,14 +7331,12 @@ gtk_widget_set_parent (GtkWidget *widget, gtk_widget_queue_compute_expand (parent); } - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - if (context) + if (widget->priv->context) { _gtk_widget_update_path (widget); - gtk_style_context_set_path (context, widget->priv->path); + gtk_style_context_set_path (widget->priv->context, widget->priv->path); - gtk_style_context_set_screen (context, + gtk_style_context_set_screen (widget->priv->context, gtk_widget_get_screen (widget)); } } @@ -8141,19 +8133,16 @@ _gtk_widget_propagate_screen_changed (GtkWidget *widget, static void reset_style_recurse (GtkWidget *widget, gpointer data) { - GtkStyleContext *context; - #if 0 if (widget->priv->rc_style) gtk_widget_reset_rc_style (widget); #endif - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - if (context) + if (widget->priv->context) { _gtk_widget_update_path (widget); - gtk_style_context_set_path (context, widget->priv->path); + gtk_style_context_set_path (widget->priv->context, + widget->priv->path); } if (GTK_IS_CONTAINER (widget)) @@ -9648,12 +9637,8 @@ gtk_widget_set_direction (GtkWidget *widget, if (old_dir != gtk_widget_get_direction (widget)) { - GtkStyleContext *context; - - context = g_object_get_qdata (G_OBJECT (widget), quark_style_context); - - if (context) - gtk_style_context_set_direction (context, + if (widget->priv->context) + gtk_style_context_set_direction (widget->priv->context, gtk_widget_get_direction (widget)); gtk_widget_emit_direction_changed (widget, old_dir); @@ -9816,6 +9801,12 @@ gtk_widget_finalize (GObject *object) if (accessible) g_object_unref (accessible); + if (priv->path) + gtk_widget_path_free (priv->path); + + if (priv->context) + g_object_unref (priv->context); + if (g_object_is_floating (object)) g_warning ("A floating object was finalized. This means that someone\n" "called g_object_unref() on an object that had only a floating\n" @@ -13324,32 +13315,24 @@ style_context_changed (GtkStyleContext *context, GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget) { - GtkStyleContext *context; - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - context = g_object_get_qdata (G_OBJECT (widget), - quark_style_context); - - if (G_UNLIKELY (!context)) + if (G_UNLIKELY (!widget->priv->context)) { - context = g_object_new (GTK_TYPE_STYLE_CONTEXT, - "direction", gtk_widget_get_direction (widget), - NULL); + widget->priv->context = g_object_new (GTK_TYPE_STYLE_CONTEXT, + "direction", gtk_widget_get_direction (widget), + NULL); - g_signal_connect (context, "changed", + g_signal_connect (widget->priv->context, "changed", G_CALLBACK (style_context_changed), widget); - g_object_set_qdata_full (G_OBJECT (widget), - quark_style_context, context, - (GDestroyNotify) g_object_unref); - - gtk_style_context_set_screen (context, + gtk_style_context_set_screen (widget->priv->context, gtk_widget_get_screen (widget)); _gtk_widget_update_path (widget); - gtk_style_context_set_path (context, widget->priv->path); + gtk_style_context_set_path (widget->priv->context, + widget->priv->path); } - return context; + return widget->priv->context; } From 2e8b1cd358207442ea8bf914d9be12ead9510f65 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 12 Oct 2010 03:46:40 +0200 Subject: [PATCH 332/634] Gtk9Slice: Fix stretch case. --- gtk/gtk9slice.c | 61 ++++++++++++++++++++++++++++++++----------------- gtk/gtk9slice.h | 4 ++-- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c index 7cd6ad47ab..4b5a0184f6 100644 --- a/gtk/gtk9slice.c +++ b/gtk/gtk9slice.c @@ -54,8 +54,8 @@ gtk_9slice_new (GdkPixbuf *pixbuf, gdouble distance_bottom, gdouble distance_left, gdouble distance_right, - GtkSliceSideModifier vertical_modifier, - GtkSliceSideModifier horizontal_modifier) + GtkSliceSideModifier horizontal_modifier, + GtkSliceSideModifier vertical_modifier) { Gtk9Slice *slice; cairo_surface_t *surface; @@ -185,13 +185,13 @@ gtk_9slice_new (GdkPixbuf *pixbuf, static void render_border (cairo_t *cr, cairo_surface_t *surface, + guint side, gdouble x, gdouble y, gdouble width, gdouble height, GtkSliceSideModifier modifier) { - cairo_pattern_t *pattern; cairo_matrix_t matrix; cairo_save (cr); @@ -199,28 +199,47 @@ render_border (cairo_t *cr, cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); - pattern = cairo_pattern_create_for_surface (surface); - - cairo_matrix_init_translate (&matrix, - x, - y); - if (modifier == GTK_SLICE_REPEAT) - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + { + cairo_pattern_t *pattern; + + pattern = cairo_pattern_create_for_surface (surface); + + cairo_matrix_init_translate (&matrix, - x, - y); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + + cairo_pattern_set_matrix (pattern, &matrix); + cairo_set_source (cr, pattern); + cairo_pattern_destroy (pattern); + + cairo_rectangle (cr, x, y, width, height); + } else { - gint w; + gint d; - w = cairo_image_surface_get_width (surface); - cairo_matrix_scale (&matrix, width / w, 0); + if (side == SIDE_TOP || side == SIDE_BOTTOM) + { + d = cairo_image_surface_get_width (surface); + + cairo_translate (cr, x + (width / 2), y); + cairo_scale (cr, width / d, 1); + cairo_set_source_surface (cr, surface, - d / 2, 0); + cairo_rectangle (cr, - width / 2, 0, width, height); + } + else + { + d = cairo_image_surface_get_height (surface); + + cairo_translate (cr, x, y + (height / 2)); + cairo_scale (cr, 1, height / d); + cairo_set_source_surface (cr, surface, 0, - d / 2); + cairo_rectangle (cr, 0, - height / 2, width, height); + } } - cairo_pattern_set_matrix (pattern, &matrix); - cairo_set_source (cr, pattern); - - cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); - cairo_pattern_destroy (pattern); - cairo_restore (cr); } @@ -261,7 +280,7 @@ gtk_9slice_render (Gtk9Slice *slice, surface = slice->surfaces[BORDER_MIDDLE][BORDER_TOP]; img_height = cairo_image_surface_get_height (surface); - render_border (cr, surface, + render_border (cr, surface, SIDE_TOP, x + slice->distances[SIDE_LEFT], y, (gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], (gdouble) img_height, @@ -271,7 +290,7 @@ gtk_9slice_render (Gtk9Slice *slice, surface = slice->surfaces[BORDER_MIDDLE][BORDER_BOTTOM]; img_height = cairo_image_surface_get_height (surface); - render_border (cr, surface, + render_border (cr, surface, SIDE_BOTTOM, x + slice->distances[SIDE_LEFT], y + height - img_height, (gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], (gdouble) img_height, @@ -281,7 +300,7 @@ gtk_9slice_render (Gtk9Slice *slice, surface = slice->surfaces[BORDER_LEFT][BORDER_MIDDLE]; img_width = cairo_image_surface_get_width (surface); - render_border (cr, surface, + render_border (cr, surface, SIDE_LEFT, x, y + slice->distances[SIDE_TOP], (gdouble) img_width, (gdouble) height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], @@ -291,7 +310,7 @@ gtk_9slice_render (Gtk9Slice *slice, surface = slice->surfaces[BORDER_RIGHT][BORDER_MIDDLE]; img_width = cairo_image_surface_get_width (surface); - render_border (cr, surface, + render_border (cr, surface, SIDE_RIGHT, x + width - img_width, y + slice->distances[SIDE_TOP], (gdouble) img_width, height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], slice->modifiers[SIDE_RIGHT]); diff --git a/gtk/gtk9slice.h b/gtk/gtk9slice.h index 28d998b4e3..10e3df079d 100644 --- a/gtk/gtk9slice.h +++ b/gtk/gtk9slice.h @@ -41,8 +41,8 @@ Gtk9Slice * gtk_9slice_new (GdkPixbuf *pixbuf, gdouble distance_bottom, gdouble distance_left, gdouble distance_right, - GtkSliceSideModifier vertical_modifier, - GtkSliceSideModifier horizontal_modifier); + GtkSliceSideModifier horizontal_modifier, + GtkSliceSideModifier vertical_modifier); Gtk9Slice * gtk_9slice_ref (Gtk9Slice *slice); void gtk_9slice_unref (Gtk9Slice *slice); From 88a3c2daaeaa36c6474bd3ce745fb0b127875dac Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 12 Oct 2010 21:48:23 +0200 Subject: [PATCH 333/634] GtkGradient: Handle symbolic gradients. The css parser has been modified to parse correctly radial gradients: background-image: -gtk-gradient (radial, center center, 0, center center, 0.8, from (#000), to (#fff)); The theming engine has been modified to correctly animate these, as well as transitions between different pattern types. --- gtk/gtkcssprovider.c | 280 ++++++++++++++++++++++------------------- gtk/gtksymboliccolor.c | 39 +++++- gtk/gtksymboliccolor.h | 6 + gtk/gtkthemingengine.c | 146 ++++++++++++++------- 4 files changed, 294 insertions(+), 177 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 598b1ffbee..1150b08d63 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1354,6 +1354,9 @@ gradient_parse_str (const gchar *str, gchar **end_ptr) { GtkGradient *gradient = NULL; + gdouble coords[6]; + gchar *end; + guint i; if (g_str_has_prefix (str, "-gtk-gradient")) { @@ -1390,15 +1393,67 @@ gradient_parse_str (const gchar *str, SKIP_SPACES (str); - if (type == CAIRO_PATTERN_TYPE_LINEAR) + /* Parse start/stop position parameters */ + for (i = 0; i < 2; i++) { - gdouble coords[4]; - gchar *end; - guint i; - - /* Parse start/stop position parameters */ - for (i = 0; i < 2; i++) + if (*str != ',') { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + + if (strncmp (str, "left", 4) == 0) + { + coords[i * 3] = 0; + str += strlen ("left"); + } + else if (strncmp (str, "right", 5) == 0) + { + coords[i * 3] = 1; + str += strlen ("right"); + } + else if (strncmp (str, "center", 6) == 0) + { + coords[i * 3] = 0.5; + str += strlen ("center"); + } + else + { + coords[i * 3] = g_ascii_strtod (str, &end); + str = end; + } + + SKIP_SPACES (str); + + if (strncmp (str, "top", 3) == 0) + { + coords[(i * 3) + 1] = 0; + str += strlen ("top"); + } + else if (strncmp (str, "bottom", 6) == 0) + { + coords[(i * 3) + 1] = 1; + str += strlen ("bottom"); + } + else if (strncmp (str, "center", 6) == 0) + { + coords[(i * 3) + 1] = 0.5; + str += strlen ("center"); + } + else + { + coords[(i * 3) + 1] = g_ascii_strtod (str, &end); + str = end; + } + + SKIP_SPACES (str); + + if (type == CAIRO_PATTERN_TYPE_RADIAL) + { + /* Parse radius */ if (*str != ',') { *end_ptr = (gchar *) str; @@ -1408,137 +1463,95 @@ gradient_parse_str (const gchar *str, str++; SKIP_SPACES (str); - if (g_str_has_prefix (str, "left")) - { - coords[i * 2] = 0; - str += strlen ("left"); - } - else if (g_str_has_prefix (str, "right")) - { - coords[i * 2] = 1; - str += strlen ("right"); - } - else - { - coords[i * 2] = g_ascii_strtod (str, &end); - str = end; - } - - SKIP_SPACES (str); - - if (g_str_has_prefix (str, "top")) - { - coords[(i * 2) + 1] = 0; - str += strlen ("top"); - } - else if (g_str_has_prefix (str, "bottom")) - { - coords[(i * 2) + 1] = 1; - str += strlen ("bottom"); - } - else - { - coords[(i * 2) + 1] = g_ascii_strtod (str, &end); - str = end; - } + coords[(i * 3) + 2] = g_ascii_strtod (str, &end); + str = end; SKIP_SPACES (str); } + } - gradient = gtk_gradient_new_linear (coords[0], coords[1], coords[2], coords[3]); + if (type == CAIRO_PATTERN_TYPE_LINEAR) + gradient = gtk_gradient_new_linear (coords[0], coords[1], coords[3], coords[4]); + else + gradient = gtk_gradient_new_radial (coords[0], coords[1], coords[2], + coords[3], coords[4], coords[5]); - while (*str == ',') + while (*str == ',') + { + GtkSymbolicColor *color; + gdouble position; + + if (*str != ',') { - GtkSymbolicColor *color; - gdouble position; + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + if (g_str_has_prefix (str, "from")) + { + position = 0; + str += strlen ("from"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + } + else if (g_str_has_prefix (str, "to")) + { + position = 1; + str += strlen ("to"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + } + else if (g_str_has_prefix (str, "color-stop")) + { + str += strlen ("color-stop"); + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + position = g_strtod (str, &end); + + str = end; + SKIP_SPACES (str); if (*str != ',') { *end_ptr = (gchar *) str; return gradient; } - - str++; - SKIP_SPACES (str); - - if (g_str_has_prefix (str, "from")) - { - position = 0; - str += strlen ("from"); - SKIP_SPACES (str); - - if (*str != '(') - { - *end_ptr = (gchar *) str; - return gradient; - } - } - else if (g_str_has_prefix (str, "to")) - { - position = 1; - str += strlen ("to"); - SKIP_SPACES (str); - - if (*str != '(') - { - *end_ptr = (gchar *) str; - return gradient; - } - } - else if (g_str_has_prefix (str, "color-stop")) - { - str += strlen ("color-stop"); - SKIP_SPACES (str); - - if (*str != '(') - { - *end_ptr = (gchar *) str; - return gradient; - } - - str++; - SKIP_SPACES (str); - - position = g_strtod (str, &end); - - str = end; - SKIP_SPACES (str); - - if (*str != ',') - { - *end_ptr = (gchar *) str; - return gradient; - } - } - else - { - *end_ptr = (gchar *) str; - return gradient; - } - - str++; - SKIP_SPACES (str); - - color = symbolic_color_parse_str (str, &end); - - str = end; - SKIP_SPACES (str); - - if (*str != ')') - { - *end_ptr = (gchar *) str; - return gradient; - } - - str++; - SKIP_SPACES (str); - - if (color) - { - gtk_gradient_add_color_stop (gradient, position, color); - gtk_symbolic_color_unref (color); - } } + else + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; + SKIP_SPACES (str); + + color = symbolic_color_parse_str (str, &end); + + str = end; + SKIP_SPACES (str); if (*str != ')') { @@ -1547,7 +1560,22 @@ gradient_parse_str (const gchar *str, } str++; + SKIP_SPACES (str); + + if (color) + { + gtk_gradient_add_color_stop (gradient, position, color); + gtk_symbolic_color_unref (color); + } } + + if (*str != ')') + { + *end_ptr = (gchar *) str; + return gradient; + } + + str++; } *end_ptr = (gchar *) str; @@ -2328,8 +2356,6 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, const gchar *path, GError **error) { - GtkCssProviderPrivate *priv; - g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE); g_return_val_if_fail (path != NULL, FALSE); diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 310e211342..657ac82e3d 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -74,6 +74,8 @@ struct GtkGradient gdouble y0; gdouble x1; gdouble y1; + gdouble radius0; + gdouble radius1; GArray *stops; @@ -269,6 +271,33 @@ gtk_gradient_new_linear (gdouble x0, gradient->y0 = y0; gradient->x1 = x1; gradient->y1 = y1; + gradient->radius0 = 0; + gradient->radius1 = 0; + + gradient->ref_count = 1; + + return gradient; +} + +GtkGradient * +gtk_gradient_new_radial (gdouble x0, + gdouble y0, + gdouble radius0, + gdouble x1, + gdouble y1, + gdouble radius1) +{ + GtkGradient *gradient; + + gradient = g_slice_new (GtkGradient); + gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); + + gradient->x0 = x0; + gradient->y0 = y0; + gradient->x1 = x1; + gradient->y1 = y1; + gradient->radius0 = radius0; + gradient->radius1 = radius1; gradient->ref_count = 1; @@ -336,8 +365,14 @@ gtk_gradient_resolve (GtkGradient *gradient, g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); g_return_val_if_fail (resolved_gradient != NULL, FALSE); - pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0, - gradient->x1, gradient->y1); + if (gradient->radius0 == 0 && gradient->radius1 == 0) + pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0, + gradient->x1, gradient->y1); + else + pattern = cairo_pattern_create_radial (gradient->x0, gradient->y0, + gradient->radius0, + gradient->x1, gradient->y1, + gradient->radius1); for (i = 0; i < gradient->stops->len; i++) { diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index aedd2aa28e..de403a325f 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -49,6 +49,12 @@ GtkGradient * gtk_gradient_new_linear (gdouble x0, gdouble y0, gdouble x1, gdouble y1); +GtkGradient * gtk_gradient_new_radial (gdouble x0, + gdouble y0, + gdouble radius0, + gdouble x1, + gdouble y1, + gdouble radius1); void gtk_gradient_add_color_stop (GtkGradient *gradient, gdouble offset, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index ee7e641d82..95536ab09c 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -632,8 +632,6 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, gint exterior_size, interior_size, pad, thickness; gdouble radius; - /* FIXME: set clipping */ - flags = gtk_theming_engine_get_state (engine); path = gtk_theming_engine_get_path (engine); radius = MIN (width, height) / 2 - 0.5; @@ -897,7 +895,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_pattern_t *pattern; GtkStateFlags flags; gboolean prelight; - gdouble progress; + gdouble progress, alpha = 1; flags = gtk_theming_engine_get_state (engine); cairo_save (cr); @@ -919,6 +917,9 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, prelight = gtk_theming_engine_is_state_set (engine, GTK_STATE_PRELIGHT, &progress); + cairo_translate (cr, x, y); + cairo_scale (cr, width, height); + if (prelight || progress > 0 ) { cairo_pattern_t *other_pattern; @@ -942,53 +943,89 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, if (pattern && other_pattern) { - gdouble offset0, red0, green0, blue0, alpha0; - gdouble offset1, red1, green1, blue1, alpha1; - gdouble x00, x01, y00, y01, x10, x11, y10, y11; + cairo_pattern_type_t type, other_type; gint n0, n1; - guint i; - - cairo_pattern_get_linear_points (pattern, &x00, &y00, &x01, &y01); - cairo_pattern_get_linear_points (other_pattern, &x10, &y10, &x11, &y11); - - new_pattern = cairo_pattern_create_linear (x00 + (x10 - x00) * progress, - y00 + (y10 - y00) * progress, - x01 + (x11 - x01) * progress, - y01 + (y11 - y01) * progress); - cairo_pattern_set_filter (new_pattern, CAIRO_FILTER_FAST); cairo_pattern_get_color_stop_count (pattern, &n0); cairo_pattern_get_color_stop_count (other_pattern, &n1); - i = 0; + type = cairo_pattern_get_type (pattern); + other_type = cairo_pattern_get_type (other_pattern); - /* Blend both gradients into one */ - while (i < n0 && i < n1) + if (type == other_type && n0 == n1) { - cairo_pattern_get_color_stop_rgba (pattern, i, - &offset0, - &red0, &green0, &blue0, - &alpha0); - cairo_pattern_get_color_stop_rgba (other_pattern, i, - &offset1, - &red1, &green1, &blue1, - &alpha1); + gdouble offset0, red0, green0, blue0, alpha0; + gdouble offset1, red1, green1, blue1, alpha1; + gdouble x00, x01, y00, y01, x10, x11, y10, y11; + gdouble r00, r01, r10, r11; + guint i; - cairo_pattern_add_color_stop_rgba (new_pattern, - offset0 + ((offset1 - offset0) * progress), - red0 + ((red1 - red0) * progress), - green0 + ((green1 - green0) * progress), - blue0 + ((blue1 - blue0) * progress), - alpha0 + ((alpha1 - alpha0) * progress)); - i++; + if (type == CAIRO_PATTERN_TYPE_LINEAR) + { + cairo_pattern_get_linear_points (pattern, &x00, &y00, &x01, &y01); + cairo_pattern_get_linear_points (other_pattern, &x10, &y10, &x11, &y11); + + new_pattern = cairo_pattern_create_linear (x00 + (x10 - x00) * progress, + y00 + (y10 - y00) * progress, + x01 + (x11 - x01) * progress, + y01 + (y11 - y01) * progress); + } + else + { + cairo_pattern_get_radial_circles (pattern, &x00, &y00, &r00, &x01, &y01, &r01); + cairo_pattern_get_radial_circles (other_pattern, &x10, &y10, &r10, &x11, &y11, &r11); + + new_pattern = cairo_pattern_create_radial (x00 + (x10 - x00) * progress, + y00 + (y10 - y00) * progress, + r00 + (r10 - r00) * progress, + x01 + (x11 - x01) * progress, + y01 + (y11 - y01) * progress, + r01 + (r11 - r01) * progress); + } + + cairo_pattern_set_filter (new_pattern, CAIRO_FILTER_FAST); + i = 0; + + /* Blend both gradients into one */ + while (i < n0 && i < n1) + { + cairo_pattern_get_color_stop_rgba (pattern, i, + &offset0, + &red0, &green0, &blue0, + &alpha0); + cairo_pattern_get_color_stop_rgba (other_pattern, i, + &offset1, + &red1, &green1, &blue1, + &alpha1); + + cairo_pattern_add_color_stop_rgba (new_pattern, + offset0 + ((offset1 - offset0) * progress), + red0 + ((red1 - red0) * progress), + green0 + ((green1 - green0) * progress), + blue0 + ((blue1 - blue0) * progress), + alpha0 + ((alpha1 - alpha0) * progress)); + i++; + } } + else + { + /* Different pattern types, or different color + * stop counts, alpha blend both patterns. + */ + cairo_rectangle (cr, 0, 0, 1, 1); + cairo_set_source (cr, other_pattern); + cairo_fill (cr); - /* FIXME: Handle remaining color stops in both source patterns */ + /* Set alpha for posterior drawing + * of the target pattern + */ + alpha = 1 - progress; + } } else if (pattern || other_pattern) { cairo_pattern_t *p; GdkColor *c; - gdouble x0, y0, x1, y1; + gdouble x0, y0, x1, y1, r0, r1; gdouble red0, green0, blue0; gdouble red1, green1, blue1; gint n, i; @@ -1006,8 +1043,17 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, c = gtk_theming_engine_has_class (engine, "entry") ? base_color : bg_color; } - cairo_pattern_get_linear_points (p, &x0, &y0, &x1, &y1); - new_pattern = cairo_pattern_create_linear (x0, y0, x1, y1); + if (cairo_pattern_get_type (p) == CAIRO_PATTERN_TYPE_LINEAR) + { + cairo_pattern_get_linear_points (p, &x0, &y0, &x1, &y1); + new_pattern = cairo_pattern_create_linear (x0, y0, x1, y1); + } + else + { + cairo_pattern_get_radial_circles (p, &x0, &y0, &r0, &x1, &y1, &r1); + new_pattern = cairo_pattern_create_radial (x0, y0, r0, x1, y1, r1); + } + cairo_pattern_get_color_stop_count (p, &n); red0 = c->red / 65535.; @@ -1067,14 +1113,11 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdk_color_free (other_base); } + cairo_rectangle (cr, 0, 0, 1, 1); + if (pattern) { - cairo_translate (cr, x, y); - cairo_scale (cr, width, height); - - cairo_rectangle (cr, 0, 0, 1, 1); cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); } else @@ -1083,8 +1126,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdk_cairo_set_source_color (cr, base_color); else gdk_cairo_set_source_color (cr, bg_color); - - cairo_rectangle (cr, x, y, width, height); } if (gtk_theming_engine_has_class (engine, "tooltip")) @@ -1095,7 +1136,18 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_stroke (cr); } else - cairo_fill (cr); + { + if (alpha == 1) + cairo_fill (cr); + else + { + cairo_pattern_t *mask; + + mask = cairo_pattern_create_rgba (1, 1, 1, alpha); + cairo_mask (cr, mask); + cairo_pattern_destroy (mask); + } + } cairo_restore (cr); @@ -1544,8 +1596,6 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, cairo_save (cr); flags = gtk_theming_engine_get_state (engine); - /* FIXME: Set clipping */ - gtk_theming_engine_get (engine, flags, "foreground-color", &fg_color, NULL); From e8c103f652921530aa30ab9e829bbe485deb7d85 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Wed, 13 Oct 2010 16:33:38 +0200 Subject: [PATCH 334/634] Use cairo gobject support instead of a new boxed type. --- gdk/gdkcairo.c | 2 -- gdk/gdkcairo.h | 3 --- gtk/gtkcssprovider.c | 3 ++- gtk/gtkstyleset.c | 13 +++++++------ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index 60ac621943..0d4b8bde09 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -25,8 +25,6 @@ #include -G_DEFINE_BOXED_TYPE (cairo_pattern_t, gdk_cairo_pattern, cairo_pattern_reference, cairo_pattern_destroy) - /** * SECTION:cairo_interaction * @Short_description: Functions to support using Cairo diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h index 836c0be079..67e08aa933 100644 --- a/gdk/gdkcairo.h +++ b/gdk/gdkcairo.h @@ -32,9 +32,6 @@ G_BEGIN_DECLS cairo_t *gdk_cairo_create (GdkWindow *window); -#define GDK_TYPE_CAIRO_PATTERN (gdk_cairo_pattern_get_type ()) - -GType gdk_cairo_pattern_get_type (void) G_GNUC_CONST; gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr, GdkRectangle *rect); diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 1150b08d63..d4faf8873b 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gtkanimationdescription.h" #include "gtk9slice.h" @@ -1926,7 +1927,7 @@ css_provider_parse_value (GtkCssProvider *css_provider, if (parsed) g_value_set_boxed (value, &border); } - else if (type == GDK_TYPE_CAIRO_PATTERN) + else if (type == CAIRO_GOBJECT_TYPE_PATTERN) { GtkGradient *gradient; diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 59ac9f5fa5..2f71f718b4 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -21,6 +21,7 @@ #include #include +#include #include "gtkstyleprovider.h" #include "gtkstyleset.h" @@ -90,7 +91,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); - gtk_style_set_register_property ("background-image", GDK_TYPE_CAIRO_PATTERN, NULL, NULL); + gtk_style_set_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); g_value_init (&val, GTK_TYPE_THEMING_ENGINE); @@ -501,10 +502,10 @@ gtk_style_set_set_property (GtkStyleSet *set, /* Allow GtkSymbolicColor as well */ g_return_if_fail (value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); } - else if (node->property_type == GDK_TYPE_CAIRO_PATTERN) + else if (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN) { /* Allow GtkGradient as a substitute */ - g_return_if_fail (value_type == GDK_TYPE_CAIRO_PATTERN || + g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN || value_type == GTK_TYPE_GRADIENT); } else @@ -639,7 +640,7 @@ resolve_gradient (GtkStyleSet *set, /* Store it back, this is where cairo_pattern_t caching happens */ g_value_unset (value); - g_value_init (value, GDK_TYPE_CAIRO_PATTERN); + g_value_init (value, CAIRO_GOBJECT_TYPE_PATTERN); g_value_take_boxed (value, gradient); return TRUE; @@ -693,7 +694,7 @@ gtk_style_set_get_property (GtkStyleSet *set, } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { - g_return_val_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN, FALSE); + g_return_val_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); if (!resolve_gradient (set, val)) return FALSE; @@ -750,7 +751,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { - g_return_if_fail (node->property_type == GDK_TYPE_CAIRO_PATTERN); + g_return_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN); if (!resolve_gradient (set, val)) val = &node->default_value; From 59b0fa81332d7ab6d30813cb86a5706ee0a734d0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 13 Oct 2010 00:52:50 +0200 Subject: [PATCH 335/634] Remove GtkOrientation parameter from gtk_render_handle(). The case for paned can be guessed out from the height and width, for handlebox the orientation parameter doesn't make much sense, and this way it could also be used for resize grips. --- gtk/gtkstyle.c | 3 +-- gtk/gtkstylecontext.c | 5 ++--- gtk/gtkstylecontext.h | 9 +++++++-- gtk/gtkthemingengine.c | 8 +++----- gtk/gtkthemingengine.h | 3 +-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 8f495a795d..44c3ed9731 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -3135,8 +3135,7 @@ gtk_default_draw_handle (GtkStyle *style, (gdouble) x, (gdouble) y, (gdouble) width, - (gdouble) height, - orientation); + (gdouble) height); cairo_restore (cr); gtk_style_context_restore (context); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index ff58377274..04a39b53d2 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2385,8 +2385,7 @@ gtk_render_handle (GtkStyleContext *context, gdouble x, gdouble y, gdouble width, - gdouble height, - GtkOrientation orientation) + gdouble height) { GtkStyleContextPrivate *priv; GtkThemingEngineClass *engine_class; @@ -2400,5 +2399,5 @@ gtk_render_handle (GtkStyleContext *context, store_animation_region (context, x, y, width, height); _gtk_theming_engine_set_context (priv->theming_engine, context); - engine_class->render_handle (priv->theming_engine, cr, x, y, width, height, orientation); + engine_class->render_handle (priv->theming_engine, cr, x, y, width, height); } diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 3daf753059..9bab375a05 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -255,8 +255,13 @@ void gtk_render_handle (GtkStyleContext *context, gdouble x, gdouble y, gdouble width, - gdouble height, - GtkOrientation orientation); + gdouble height); +void gtk_render_progress (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_END_DECLS diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 95536ab09c..5096996e57 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -126,8 +126,7 @@ static void gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdouble x, gdouble y, gdouble width, - gdouble height, - GtkOrientation orientation); + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -1998,8 +1997,7 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdouble x, gdouble y, gdouble width, - gdouble height, - GtkOrientation orientation) + gdouble height) { GtkStateFlags flags; GdkColor *bg_color; @@ -2023,7 +2021,7 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, if (gtk_theming_engine_has_class (engine, "paned")) { - if (orientation == GTK_ORIENTATION_HORIZONTAL) + if (width > height) for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5) render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3); else diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 8cbd75ad2d..47a4234f4b 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -130,8 +130,7 @@ struct GtkThemingEngineClass gdouble x, gdouble y, gdouble width, - gdouble height, - GtkOrientation orientation); + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From a79626b7fb7d6609f0b7a650d50683b62a987a23 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 10:59:46 +0200 Subject: [PATCH 336/634] Add theming docs Both API and file format is documented, there's still missing a migration doc though. --- docs/reference/gtk/Makefile.am | 3 + docs/reference/gtk/gtk-docs.sgml | 9 + docs/reference/gtk/gtk3-sections.txt | 242 ++++++++++ docs/reference/gtk/gtk3.types | 4 + gtk/gtk.h | 1 + gtk/gtkanimationdescription.h | 2 +- gtk/gtkcontainer.c | 10 + gtk/gtkcssprovider.c | 414 +++++++++++++++++ gtk/gtkcssprovider.h | 8 +- gtk/gtkenums.h | 31 ++ gtk/gtkstylecontext.c | 672 ++++++++++++++++++++++++++- gtk/gtkstylecontext.h | 8 +- gtk/gtkstyleprovider.c | 52 ++- gtk/gtkstyleprovider.h | 12 +- gtk/gtkstyleset.c | 154 ++++++ gtk/gtkstyleset.h | 8 +- gtk/gtksymboliccolor.c | 164 ++++++- gtk/gtksymboliccolor.h | 4 +- gtk/gtkthemingengine.c | 211 ++++++++- gtk/gtkthemingengine.h | 28 +- gtk/gtkwidget.c | 19 + gtk/gtkwidgetpath.c | 383 ++++++++++++++- gtk/gtkwidgetpath.h | 2 +- 23 files changed, 2386 insertions(+), 55 deletions(-) diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index 1de3259a6d..c14a42725c 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -22,6 +22,8 @@ CFILE_GLOB=$(top_srcdir)/gtk/*.c # Header files to ignore when scanning IGNORE_HFILES= \ fnmatch.h \ + gtk9slice.h \ + gtkanimationdescription.h \ gtkdebug.h \ gtkbuilderprivate.h \ gtkdndcursors.h \ @@ -77,6 +79,7 @@ IGNORE_HFILES= \ gtktexttagprivate.h \ gtktexttypes.h \ gtktextutil.h \ + gtktimeline.h \ gtkthemes.h \ gtktrayicon.h \ gtktreedatalist.h \ diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index 5963787271..0daebefb01 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -51,6 +51,15 @@ + + Theming in GTK+ + + + + + + + GTK+ Widgets and Objects diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 2ec9ae874e..0406de2c19 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -881,6 +881,7 @@ gtk_container_set_resize_mode gtk_container_check_resize gtk_container_foreach gtk_container_get_children +gtk_container_get_path_for_child gtk_container_set_reallocate_redraws gtk_container_get_focus_child gtk_container_set_focus_child @@ -4950,6 +4951,11 @@ gtk_widget_get_mapped gtk_widget_get_requisition gtk_widget_device_is_shadowed + +gtk_widget_get_path +gtk_widget_get_style_context +gtk_widget_reset_style + gtk_requisition_new gtk_requisition_copy @@ -5246,6 +5252,242 @@ GTK_INTERFACE_AGE GTK_CHECK_VERSION +
+gtkwidgetpath +GtkWidgetPath +GtkWidgetPath +gtk_widget_path_append_type +gtk_widget_path_copy +gtk_widget_path_free +gtk_widget_path_get_widget_type +gtk_widget_path_has_parent +gtk_widget_path_is_type +gtk_widget_path_iter_add_class +gtk_widget_path_iter_add_region +gtk_widget_path_iter_clear_classes +gtk_widget_path_iter_clear_regions +gtk_widget_path_iter_get_name +gtk_widget_path_iter_get_widget_type +gtk_widget_path_iter_has_class +gtk_widget_path_iter_has_name +gtk_widget_path_iter_has_qclass +gtk_widget_path_iter_has_qname +gtk_widget_path_iter_has_qregion +gtk_widget_path_iter_has_region +gtk_widget_path_iter_list_classes +gtk_widget_path_iter_list_regions +gtk_widget_path_iter_remove_class +gtk_widget_path_iter_remove_region +gtk_widget_path_iter_set_name +gtk_widget_path_iter_set_widget_type +gtk_widget_path_length +gtk_widget_path_new +gtk_widget_path_prepend_type +
+ +
+gtkstyleprovider +GtkStyleProvider +GtkStyleProviderIface +GtkStyleProvider +GTK_STYLE_PROVIDER_PRIORITY_APPLICATION +GTK_STYLE_PROVIDER_PRIORITY_DEFAULT +GTK_STYLE_PROVIDER_PRIORITY_FALLBACK +GTK_STYLE_PROVIDER_PRIORITY_SETTINGS +GTK_STYLE_PROVIDER_PRIORITY_USER +gtk_style_provider_get_icon_factory +gtk_style_provider_get_style +gtk_style_provider_get_style_property + +GTK_TYPE_STYLE_PROVIDER +GTK_STYLE_PROVIDER +GTK_IS_STYLE_PROVIDER +GTK_STYLE_PROVIDER_GET_IFACE + +gtk_style_provider_get_type +
+ +
+gtksymboliccolor +GtkSymbolicColor +GtkSymbolicColor +GtkGradient +gtk_symbolic_color_new_literal +gtk_symbolic_color_new_mix +gtk_symbolic_color_new_name +gtk_symbolic_color_new_shade +gtk_symbolic_color_resolve +gtk_symbolic_color_ref +gtk_symbolic_color_unref +gtk_gradient_new_linear +gtk_gradient_new_radial +gtk_gradient_add_color_stop +gtk_gradient_resolve +gtk_gradient_ref +gtk_gradient_unref + +GTK_TYPE_GRADIENT +GTK_TYPE_SYMBOLIC_COLOR + +gtk_symbolic_color_get_type +gtk_gradient_get_type +
+ +
+gtkstyleset +GtkStyleSet +GtkStyleSet +gtk_style_set_clear +gtk_style_set_get +gtk_style_set_get_property +gtk_style_set_get_valist +gtk_style_set_lookup_color +gtk_style_set_lookup_property +gtk_style_set_map_color +gtk_style_set_merge +gtk_style_set_new +gtk_style_set_register_property +gtk_style_set_set +gtk_style_set_set_property +gtk_style_set_set_valist +gtk_style_set_unset_property + +GTK_TYPE_STYLE_SET +GTK_IS_STYLE_SET +GTK_IS_STYLE_SET_CLASS +GTK_STYLE_SET +GTK_STYLE_SET_CLASS +GTK_STYLE_SET_GET_CLASS + +gtk_style_set_get_type +
+ +
+gtkstylecontext +GtkStyleContext +GtkStyleContext +gtk_style_context_add_provider +gtk_style_context_add_provider_for_screen +gtk_style_context_get +gtk_style_context_get_direction +gtk_style_context_get_junction_sides +gtk_style_context_get_path +gtk_style_context_get_property +gtk_style_context_get_screen +gtk_style_context_get_state +gtk_style_context_get_style +gtk_style_context_get_style_property +gtk_style_context_get_style_valist +gtk_style_context_get_valist +gtk_style_context_has_class +gtk_style_context_has_region +gtk_style_context_invalidate +gtk_style_context_is_state_set +gtk_style_context_list_classes +gtk_style_context_list_regions +gtk_style_context_lookup_color +gtk_style_context_lookup_icon_set +gtk_style_context_notify_state_change +gtk_style_context_pop_animatable_region +gtk_style_context_push_animatable_region +gtk_style_context_remove_provider +gtk_style_context_remove_provider_for_screen +gtk_style_context_reset_widgets +gtk_style_context_restore +gtk_style_context_save +gtk_style_context_set_class +gtk_style_context_set_direction +gtk_style_context_set_junction_sides +gtk_style_context_set_path +gtk_style_context_set_region +gtk_style_context_set_screen +gtk_style_context_set_state +gtk_style_context_state_transition_start +gtk_style_context_state_transition_stop +gtk_style_context_state_transition_update +gtk_style_context_unset_class +gtk_style_context_unset_region + + +gtk_render_arrow +gtk_render_background +gtk_render_check +gtk_render_expander +gtk_render_extension +gtk_render_focus +gtk_render_frame +gtk_render_frame_gap +gtk_render_handle +gtk_render_layout +gtk_render_line +gtk_render_option +gtk_render_progress +gtk_render_slider + + +GTK_TYPE_STYLE_CONTEXT +GTK_STYLE_CONTEXT +GTK_STYLE_CONTEXT_CLASS +GTK_STYLE_CONTEXT_GET_CLASS +GTK_IS_STYLE_CONTEXT +GTK_IS_STYLE_CONTEXT_CLASS + +gtk_style_context_get_type +
+ +
+gtkcssprovider +GtkCssProvider +GtkCssProvider +gtk_css_provider_get_default +gtk_css_provider_get_named +gtk_css_provider_load_from_data +gtk_css_provider_load_from_file +gtk_css_provider_load_from_path +gtk_css_provider_new + +GTK_TYPE_CSS_PROVIDER +GTK_CSS_PROVIDER +GTK_CSS_PROVIDER_CLASS +GTK_CSS_PROVIDER_GET_CLASS +GTK_IS_CSS_PROVIDER +GTK_IS_CSS_PROVIDER_CLASS + +gtk_css_provider_get_type +
+ +
+gtkthemingengine +GtkThemingEngine +GtkThemingEngineClass +GtkThemingEngine +gtk_theming_engine_get +gtk_theming_engine_get_direction +gtk_theming_engine_get_junction_sides +gtk_theming_engine_get_path +gtk_theming_engine_get_property +gtk_theming_engine_get_screen +gtk_theming_engine_get_state +gtk_theming_engine_get_style +gtk_theming_engine_get_style_property +gtk_theming_engine_get_style_valist +gtk_theming_engine_get_valist +gtk_theming_engine_has_class +gtk_theming_engine_has_region +gtk_theming_engine_is_state_set +gtk_theming_engine_load +gtk_theming_engine_register_property + +GTK_THEMING_ENGINE +GTK_THEMING_ENGINE_CLASS +GTK_THEMING_ENGINE_GET_CLASS +GTK_IS_THEMING_ENGINE +GTK_IS_THEMING_ENGINE_CLASS + +GTK_TYPE_THEMING_ENGINE +gtk_theming_engine_get_type +
+
gtkstyle GtkStyle diff --git a/docs/reference/gtk/gtk3.types b/docs/reference/gtk/gtk3.types index 6b43eccf7f..c385a37c48 100644 --- a/docs/reference/gtk/gtk3.types +++ b/docs/reference/gtk/gtk3.types @@ -47,6 +47,7 @@ gtk_color_selection_get_type gtk_combo_box_get_type gtk_combo_box_text_get_type gtk_container_get_type +gtk_css_provider_get_type gtk_dialog_get_type gtk_drawing_area_get_type gtk_editable_get_type @@ -141,6 +142,8 @@ gtk_statusbar_get_type gtk_status_icon_get_type gtk_switch_get_type gtk_style_get_type +gtk_style_context_get_type +gtk_style_provider_get_type gtk_table_get_type gtk_tearoff_menu_item_get_type gtk_text_buffer_get_type @@ -150,6 +153,7 @@ gtk_text_mark_get_type gtk_text_tag_get_type gtk_text_tag_table_get_type gtk_text_view_get_type +gtk_theming_engine_get_type gtk_toggle_action_get_type gtk_toggle_button_get_type gtk_toggle_tool_button_get_type diff --git a/gtk/gtk.h b/gtk/gtk.h index 02de38d9d1..92b4c7d21d 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -180,6 +180,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkanimationdescription.h b/gtk/gtkanimationdescription.h index 14537edbf1..7770df2f02 100644 --- a/gtk/gtkanimationdescription.h +++ b/gtk/gtkanimationdescription.h @@ -44,4 +44,4 @@ GtkAnimationDescription * gtk_animation_description_from_string (const gchar *st G_END_DECLS -#endif /* __GTK_ANIMATION_DESC_H__ */ +#endif /* __GTK_ANIMATION_DESCRIPTION_H__ */ diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 8c09ba2514..1be4ab2926 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -3232,6 +3232,16 @@ _gtk_container_get_reallocate_redraws (GtkContainer *container) return container->priv->reallocate_redraws; } +/** + * gtk_container_get_path_for_child: + * @container: a #GtkContainer + * @child: a child of @container + * + * Returns a newly created widget path representing all the widget hierarchy + * from the toplevel down to @child (this one not being included). + * + * Returns: A newly created #GtkWidgetPath + **/ GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container, GtkWidget *child) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d4faf8873b..83f9cad5a3 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -30,6 +30,360 @@ #include "gtk9slice.h" #include "gtkcssprovider.h" +/** + * SECTION:gtkcssprovider + * @Short_description: CSS-like styling for widgets + * @Title: GtkCssProvider + * @See_also: #GtkStyleContext, #GtkStyleProvider + * + * #GtkCssProvider is an object implementing #GtkStyleProvider, it is able + * to parse CSS-like input in order to style widgets. + * + * + * Widget selectors + * + * Selectors work in a really similar way than in common CSS, widget object + * names act as HTML tags: + * + * + * Widgets in selectors + * + * /* Theme labels that are descendants of a window */ + * GtkWindow GtkLabel { + * background-color: #898989; + * } + * + * /* Theme notebooks, and anything that's within these */ + * GtkNotebook { + * background-color: #a939f0; + * } + * + * /* Theme combo boxes, and entries that + * are direct children of a notebook */ + * GtkComboBox, + * GtkNotebook > GtkEntry { + * background-color: #1209a2; + * } + * + * /* Theme any widget within a GtkBin */ + * GtkBin * { + * font-name: Sans 20; + * } + * + * + * + * Widget names may be matched in CSS as well: + * + * + * Widget names in selectors + * + * /* Theme a label named title-label */ + * GtkLabel#title-label { + * font-name: Sans 15; + * } + * + * /* Theme any widget named main-entry */ + * #main-entry { + * background-color: #f0a810; + * } + * + * + * + * Widgets may also define different classes, so these can be matched + * in CSS: + * + * + * Widget names in selectors + * + * /* Theme all widgets defining the class entry */ + * .entry { + * foreground-color: #39f1f9; + * } + * + * /* Theme spinbuttons' entry */ + * GtkSpinButton.entry { + * foreground-color: #900185; + * } + * + * + * + * Container widgets may define regions, these region names may be + * referenced in CSS, it's also possible to apply :nth-child + * pseudo-class information if the widget implementation provides + * such data. + * + * + * Region names in containers + * + * /* Theme any label within a notebook */ + * GtkNotebook GtkLabel { + * foreground-color: #f90192; + * } + * + * /* Theme labels within notebook tabs */ + * GtkNotebook tab:nth-child GtkLabel { + * foreground-color: #703910; + * } + * + * /* Theme labels in the any first notebook + * tab, both selectors are equivalent */ + * GtkNotebook tab:nth-child(first) GtkLabel, + * GtkNotebook tab:first-child GtkLabel { + * foreground-color: #89d012; + * } + * + * + * + * Widget states may be matched as pseudoclasses. + * Given the needed widget states differ from the + * offered pseudoclasses in CSS, some are unsupported, + * and some custom ones have been added. + * + * + * Styling specific widget states + * + * /* Theme active (pressed) buttons */ + * GtkButton:active { + * background-color: #0274d9; + * } + * + * /* Theme buttons with the mouse pointer on it */ + * GtkButton:hover, + * GtkButton:prelight { + * background-color: #3085a9; + * } + * + * /* Theme insensitive widgets, both are equivalent */ + * :insensitive, + * *:insensitive { + * background-color: #320a91; + * } + * + * /* Theme selection colors in entries */ + * GtkEntry:selected { + * background-color: #56f9a0; + * } + * + * /* Theme focused labels */ + * GtkLabel:focused { + * background-color: #b4940f; + * } + * + * /* Theme inconsistent checkbuttons */ + * GtkCheckButton:inconsistent { + * background-color: #20395a; + * } + * + * + * + * Widget state pseudoclasses may only apply to the + * last element in a selector. + * + * + * All the mentioned elements may be combined to create + * complex selectors that match specific widget paths. + * As in CSS, rules apply by specificity, so the selectors + * describing the best a widget path will take precedence + * over the others. + * + * + * + * @ rules + * + * GTK+'s CSS supports the @import rule, in order + * to load another CSS file in addition to the currently + * parsed one. + * + * + * Using the @import rule + * + * @import url (path/to/common.css) + * + * + * + * GTK+ also supports an additional @define-color + * rule, in order to define a color name which may be used + * instead of color numeric representations. + * + * + * Defining colors + * + * @define-color bg_color #f9a039; + * + * * { + * background-color: @bg_color; + * } + * + * + * + * + * Symbolic colors + * + * Besides being able to define color names, the CSS + * parser is also able to read different color modifiers, + * which can also be nested, providing a rich language + * to define colors starting from other colors. + * + * + * Using symbolic colors + * + * @define-color entry-color shade (@bg_color, 0.7); + * + * GtkEntry { + * background-color: @entry-color; + * } + * + * GtkEntry:focused { + * background-color: mix (@entry-color, + * shade (#fff, 0.5), + * 0.8); + * } + * + * + * + * + * Supported properties + * + * Properties are the part that differ the most to common CSS, + * not all properties are supported (some are planned to be + * supported eventually, some others are meaningless or don't + * map intuitively in a widget based environment). + * + * + * There is also a difference in shorthand properties, for + * example in common CSS it is fine to define a font through + * the different @font-family, @font-style, @font-size + * properties, meanwhile in GTK+'s CSS only the canonical + * @font property would be supported. + * + * + * The currently supported properties are: + * + * + * + * + * + * Property name + * Syntax + * Maps to + * Examples + * + * + * + * + * engine + * engine-name + * #GtkThemingEngine + * engine: clearlooks; + * + * + * background-color + * color + * #GdkColor + * + * + * background-color: #fff; + * foreground-color: @color-name; + * text-color: shade (@color-name, 0.5); + * base-color: mix (@color-name, #f0f, 0.8); + * + * + * + * foreground-color + * + * + * text-color + * + * + * base-color + * + * + * font + * family [style] [size] + * #PangoFontDescription + * font: Sans 15; + * + * + * margin + * + * + * width + * vertical-width horizontal-width + * top-width horizontal-width bottom-width + * top-width right-width bottom-width left-width + * + * + * #GtkBorder + * + * + * margin: 5; + * margin: 5 10; + * margin: 5 10 3; + * margin: 5 10 3 5; + * + * + * + * padding + * + * + * background-image + * + * + * -gtk-gradient (linear, + * starting-x-position starting-y-position, + * ending-x-position ending-y-position, + * [ [from|to] (color) | + * color-stop (percentage, color) ] ) + * + * -gtk-gradient (radial, + * starting-x-position starting-y-position, starting-radius, + * ending-x-position ending-y-position, ending-radius, + * [ [from|to] (color) | + * color-stop (percentage, color) ]* ) + * + * #cairo_pattern_t + * + * + * -gtk-gradient (linear, + * top left, top right, + * from (#fff), to (#000)); + * -gtk-gradient (linear, 0.0 0.5, 0.5 1.0, + * from (#fff), + * color-stop (0.5, #f00), + * to (#000)); + * -gtk-gradient (radial, + * center center, 0.2, + * center center, 0.8, + * color-stop (0.0, #fff), + * color-stop (1.0, #000)); + * + * + * + * border-image + * url([path]) top-distance right-distance bottom-distance left-distance horizontal-option vertical-option + * + * + * + * border-image: url (/path/to/image.png) 3 4 3 4 stretch; + * border-image: url (/path/to/image.png) 3 4 4 3 repeat stretch; + * + * + * + * transition + * duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] + * + * + * + * transition: 150ms ease-in-out; + * transition: 1s linear; + * + * + * + * + * + * + */ + typedef struct GtkCssProviderPrivate GtkCssProviderPrivate; typedef struct SelectorElement SelectorElement; typedef struct SelectorPath SelectorPath; @@ -753,6 +1107,13 @@ gtk_css_provider_finalize (GObject *object) G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object); } +/** + * gtk_css_provider_new: + * + * Returns a newly created #GtkCssProvider. + * + * Returns: A new #GtkCssProvider + **/ GtkCssProvider * gtk_css_provider_new (void) { @@ -2235,6 +2596,18 @@ parse_stylesheet (GtkCssProvider *css_provider) return TRUE; } +/** + * gtk_css_provider_load_from_data: + * @css_provider: a #GtkCssProvider + * @data: CSS data loaded in memory + * @length: the length of @data in bytes, or -1 for NUL terminated strings + * @error: (out) (allow-none): return location for a #GError, or %NULL + * + * Loads @data into @css_provider, making it clear any previously loaded + * information. + * + * Returns: %TRUE if the data could be loaded. + **/ gboolean gtk_css_provider_load_from_data (GtkCssProvider *css_provider, const gchar *data, @@ -2265,6 +2638,17 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, return TRUE; } +/** + * gtk_css_provider_load_from_file: + * @css_provider: a #GtkCssProvider + * @file: #GFile pointing to a file to load + * @error: (out) (allow-none): return location for a #GError, or %NULL + * + * Loads the data contained in @file into @css_provider, making it + * clear any previously loaded information. + * + * Returns: %TRUE if the data could be loaded. + **/ gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider, GFile *file, @@ -2352,6 +2736,17 @@ gtk_css_provider_load_from_path_internal (GtkCssProvider *css_provider, return TRUE; } +/** + * gtk_css_provider_load_from_path: + * @css_provider: a #GtkCssProvider + * @path: the path of a filename to load, in the GLib filename encoding + * @error: (out) (allow-none): return location for a #GError, or %NULL + * + * Loads the data contained in @path into @css_provider, making it clear + * any previously loaded information. + * + * Returns: %TRUE if the data could be loaded. + **/ gboolean gtk_css_provider_load_from_path (GtkCssProvider *css_provider, const gchar *path, @@ -2364,6 +2759,15 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider, TRUE, error); } +/** + * gtk_css_provider_get_default: + * + * Returns the provider containing the style settings used as a + * fallback for all widgets. + * + * Returns: (transfer none): The provider used for fallback styling. + * This memory is owned by GTK+, and you must not free it. + **/ GtkCssProvider * gtk_css_provider_get_default (void) { @@ -2457,6 +2861,16 @@ css_provider_get_theme_dir (void) return path; } +/** + * gtk_css_provider_get_named: + * @name: A theme name + * @variant: variant to load, for example, "dark", or %NULL for the default + * + * + * + * Returns: (transfer none): The provider used for fallback styling. + * This memory is owned by GTK+, and you must not free it. + **/ GtkCssProvider * gtk_css_provider_get_named (const gchar *name, const gchar *variant) diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h index 2c6d283342..ebfc36ddc8 100644 --- a/gtk/gtkcssprovider.h +++ b/gtk/gtkcssprovider.h @@ -31,16 +31,16 @@ G_BEGIN_DECLS #define GTK_IS_CSS_PROVIDER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_CSS_PROVIDER)) #define GTK_CSS_PROVIDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProviderClass)) -typedef struct GtkCssProvider GtkCssProvider; -typedef struct GtkCssProviderClass GtkCssProviderClass; +typedef struct _GtkCssProvider GtkCssProvider; +typedef struct _GtkCssProviderClass GtkCssProviderClass; -struct GtkCssProvider +struct _GtkCssProvider { GObject parent_instance; gpointer priv; }; -struct GtkCssProviderClass +struct _GtkCssProviderClass { GObjectClass parent_class; }; diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index a1fc4f49bf..85c8c561ae 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -560,6 +560,16 @@ typedef enum GTK_SCROLL_NATURAL } GtkScrollablePolicy; +/** + * GtkStateFlags: + * @GTK_STATE_FLAG_ACTIVE: Widget is active. + * @GTK_STATE_FLAG_PRELIGHT: Widget has a mouse pointer over it. + * @GTK_STATE_FLAG_SELECTED: Widget is selected. + * @GTK_STATE_FLAG_INCONSISTENT: Widget is inconsistent. + * @GTK_STATE_FLAG_FOCUSED: Widget has the keyboard focus. + * + * Describes a widget state. + */ typedef enum { GTK_STATE_FLAG_ACTIVE = 1 << 0, @@ -570,6 +580,17 @@ typedef enum GTK_STATE_FLAG_FOCUSED = 1 << 5 } GtkStateFlags; +/** + * GtkRegionFlags: + * @GTK_REGION_EVEN: Region has an even number within a set. + * @GTK_REGION_ODD: Region has an odd number within a set. + * @GTK_REGION_FIRST: Region is the first one within a set. + * @GTK_REGION_LAST: Region is the last one within a set. + * @GTK_REGION_DEFAULT: Region is the default option. + * @GTK_REGION_SORTED: Region is part of a sorted area. + * + * Describes a region within a widget. + */ typedef enum { GTK_REGION_EVEN = 1 << 0, GTK_REGION_ODD = 1 << 1, @@ -579,6 +600,16 @@ typedef enum { GTK_REGION_SORTED = 1 << 5 } GtkRegionFlags; +/** + * GtkJunctionSides: + * @GTK_JUNCTION_NONE: No junctions. + * @GTK_JUNCTION_TOP: Element connects on the top side. + * @GTK_JUNCTION_BOTTOM: Element connects on the bottom side. + * @GTK_JUNCTION_LEFT: Element connects on the left side. + * @GTK_JUNCTION_RIGHT: Element connects on the right side. + * + * Describes how a rendered element connects to adjacent elements. + */ typedef enum { GTK_JUNCTION_NONE = 0, GTK_JUNCTION_TOP = 1 << 0, diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 04a39b53d2..3a0407405c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -33,6 +33,163 @@ #include "gtkanimationdescription.h" #include "gtktimeline.h" +/** + * SECTION:gtkstylecontext + * @Short_description: rendering UI elements + * @Title: GtkStyleContext + * @See_also: + * + * #GtkStyleContext is an object that stores styling information affecting + * a widget defined by #GtkWidgetPath. + * + * In order to construct the final style information, #GtkStyleContext + * queries information to all attached #GtkStyleProviders, either + * to the context specifically through gtk_style_context_add_provider(), or + * to the screen through gtk_style_context_add_provider_for_screen(). The + * resulting style is a combination of all provider's information in priority + * order. + * + * For GTK+ widgets, any #GtkStyleContext returned by + * gtk_widget_get_style_context() will already have a #GtkWidgetPath, a + * #GdkScreen and RTL/LTR information set, the style context will be also + * updated automatically if any of these settings change on the widget. + * + * If you using are the theming layer standalone, you will need to set a + * widget path and a screen yourself to the created style context through + * gtk_style_context_set_path() and gtk_style_context_set_screen(), as well + * as updating the context yourself using gtk_style_context_invalidate() + * whenever any of the conditions change, such as a change in the + * #GtkSettings:gtk-theme-name property or a hierarchy change in the rendered + * widget. + * + * + * Transition animations + * + * #GtkStyleContext has built-in support for state change transitions. + * + * + * For simple widgets where state changes affect the whole widget area, + * calling gtk_style_context_notify_state_change() with a %NULL identifier + * would be sufficient. + * + * + * If a widget needs to declare several animatable regions (i.e. not + * affecting the whole widget area), its #GtkWidget::draw signal handler + * needs to wrap the render operations for the different regions around + * gtk_style_context_push_animatable_region() and + * gtk_style_context_pop_animatable_region(). These functions take an + * unique identifier within the style context, for simple widgets with + * little animatable regions, an enum may be used: + * + * + * Using an enum as animatable region identifier + * + * enum { + * REGION_ENTRY, + * REGION_BUTTON_UP, + * REGION_BUTTON_DOWN + * }; + * + * ... + * + * gboolean + * spin_button_draw (GtkWidget *widget, + * cairo_t *cr) + * { + * GtkStyleContext *context; + * + * context = gtk_widget_get_style_context (widget); + * + * gtk_style_context_push_animatable_region (context, + * GUINT_TO_POINTER (REGION_ENTRY)); + * + * gtk_render_background (cr, 0, 0, 100, 30); + * gtk_render_frame (cr, 0, 0, 100, 30); + * + * gtk_style_context_pop_animatable_region (context); + * + * ... + * } + * + * + * + * For complex widgets with an arbitrary number of animatable regions, it + * is up to the implementation to come up with a way to univocally identify + * an animatable region, pointers to internal structs would suffice. + * + * + * Using an arbitrary pointer as animatable region identifier + * + * void + * notebook_draw_tab (GtkWidget *widget, + * NotebookPage *page, + * cairo_t *cr) + * { + * gtk_style_context_push_animatable_region (context, page); + * gtk_render_extension (cr, page->x, page->y, page->width, page->height); + * gtk_style_context_pop_animatable_region (context); + * } + * + * + * + * The widget also needs to notify the style context about a state change + * for a given animatable region so the animation is triggered. + * + * + * Triggering a state change animation on a region + * + * gboolean + * notebook_motion_notify (GtkWidget *widget, + * GdkEventMotion *event) + * { + * GtkStyleContext *context; + * NotebookPage *page; + * + * context = gtk_widget_get_style_context (widget); + * page = find_page_under_pointer (widget, event); + * gtk_style_context_notify_state_change (context, + * gtk_widget_get_window (widget), + * page, + * GTK_STATE_PRELIGHT, + * TRUE); + * ... + * } + * + * + * + * gtk_style_context_notify_state_change() accepts %NULL region IDs as a + * special value, in this case, the whole widget area will be updated + * by the animation. + * + * + * + * + * Custom styling in UI libraries and applications + * + * If you are developing a library with custom #GtkWidgets that + * render differently than standard components, you may need to add a + * #GtkStyleProvider yourself with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK + * priority, either a #GtkCssProvider or a custom object implementing the + * #GtkStyleProvider interface. This way theming engines may still attempt + * to style your UI elements in a different way if needed so. + * + * + * If you are using custom styling on an applications, you probably want then + * to make your style information prevail to the theme's, so you must use + * a #GtkStyleProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + * priority, keep in mind that the user settings in $HOME/.gtk-3.0.css will + * still take precedence over your changes, as it uses the + * %GTK_STYLE_PROVIDER_PRIORITY_USER priority. + * + * + * If a custom theming engine is needed, you probably want to implement a + * #GtkStyleProvider yourself so it points to your #GtkThemingEngine + * implementation, as #GtkCssProvider uses gtk_theming_engine_load() + * which loads the theming engine module from the standard paths. + * + * + */ + typedef struct GtkStyleContextPrivate GtkStyleContextPrivate; typedef struct GtkStyleProviderData GtkStyleProviderData; typedef struct GtkStyleInfo GtkStyleInfo; @@ -571,7 +728,7 @@ gtk_style_context_impl_get_property (GObject *object, } } -GList * +static GList * find_next_candidate (GList *local, GList *global) { @@ -705,7 +862,7 @@ create_query_path (GtkStyleContext *context) return path; } -StyleData * +static StyleData * style_data_lookup (GtkStyleContext *context) { GtkStyleContextPrivate *priv; @@ -825,6 +982,20 @@ style_provider_remove (GList **list, return FALSE; } +/** + * gtk_style_context_add_provider: + * @context: a #GtkStyleContext + * @provider: a #GtkStyleProvider + * @priority: the priority of the style provider. The lower + * it is, the earlier it will be used in the style + * construction. Typically this will be in the range + * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and + * %GTK_STYLE_PROVIDER_PRIORITY_USER + * + * Adds a style provider to @context, to be used in style construction. + * + * Since: 3.0 + **/ void gtk_style_context_add_provider (GtkStyleContext *context, GtkStyleProvider *provider, @@ -842,6 +1013,15 @@ gtk_style_context_add_provider (GtkStyleContext *context, gtk_style_context_invalidate (context); } +/** + * gtk_style_context_remove_provider: + * @context: a #GtkStyleContext + * @provider: a #GtkStyleProvider + * + * Removes @provider from the style providers list in @context. + * + * Since: 3.0 + **/ void gtk_style_context_remove_provider (GtkStyleContext *context, GtkStyleProvider *provider) @@ -861,6 +1041,19 @@ gtk_style_context_remove_provider (GtkStyleContext *context, } } +/** + * gtk_style_context_reset_widgets: + * @screen: a #GdkScreen + * + * This function recomputes the styles for all widgets under a particular + * #GdkScreen. This is useful when some global parameter has changed that + * affects the appearance of all widgets, because when a widget gets a new + * style, it will both redraw and recompute any cached information about + * its appearance. As an example, it is used when the color scheme changes + * in the related #GtkSettings object. + * + * Since: 3.0 + **/ void gtk_style_context_reset_widgets (GdkScreen *screen) { @@ -880,6 +1073,22 @@ gtk_style_context_reset_widgets (GdkScreen *screen) g_list_free (toplevels); } +/** + * gtk_style_context_add_provider_for_screen: + * @screen: a #GdkScreen + * @provider: a #GtkStyleProvider + * @priority: the priority of the style provider. The lower + * it is, the earlier it will be used in the style + * construction. Typically this will be in the range + * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and + * %GTK_STYLE_PROVIDER_PRIORITY_USER + * + * Adds a global style provider to @screen, which will be used + * in style construction for all #GtkStyleContexts under + * @screen. + * + * Since: 3.0 + **/ void gtk_style_context_add_provider_for_screen (GdkScreen *screen, GtkStyleProvider *provider, @@ -902,6 +1111,15 @@ gtk_style_context_add_provider_for_screen (GdkScreen *screen, gtk_style_context_reset_widgets (screen); } +/** + * gtk_style_context_remove_provider_for_screen: + * @screen: a #GdkScreen + * @provider: a #GtkStyleProvider + * + * Removes @provider from the global style providers list in @screen. + * + * Since: 3.0 + **/ void gtk_style_context_remove_provider_for_screen (GdkScreen *screen, GtkStyleProvider *provider) @@ -925,6 +1143,18 @@ gtk_style_context_remove_provider_for_screen (GdkScreen *screen, } } +/** + * gtk_style_context_get_property: + * @context: a #GtkStyleContext + * @property: style property name + * @state: state to retrieve the property value for + * @value: (out) (transfer full): return location for the style property value. + * + * Gets a style property from @context for the given state. When done with @value, + * g_value_unset() needs to be called to free any allocated memory. + * + * Since: 3.0 + **/ void gtk_style_context_get_property (GtkStyleContext *context, const gchar *property, @@ -946,6 +1176,16 @@ gtk_style_context_get_property (GtkStyleContext *context, gtk_style_set_get_property (data->store, property, state, value); } +/** + * gtk_style_context_get_valist: + * @context: a #GtkStyleContext + * @state: state to retrieve the property values for + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several style property values from @context for a given state. + * + * Since: 3.0 + **/ void gtk_style_context_get_valist (GtkStyleContext *context, GtkStateFlags state, @@ -963,6 +1203,17 @@ gtk_style_context_get_valist (GtkStyleContext *context, gtk_style_set_get_valist (data->store, state, args); } +/** + * gtk_style_context_get: + * @context: a #GtkStyleContext + * @state: state to retrieve the property values for + * @...: property name /return value pairs, followed by %NULL + * + * Retrieves several style property values from @context for a + * given state. + * + * Since: 3.0 + **/ void gtk_style_context_get (GtkStyleContext *context, GtkStateFlags state, @@ -984,6 +1235,16 @@ gtk_style_context_get (GtkStyleContext *context, va_end (args); } +/** + * gtk_style_context_set_state: + * @context: a #GtkStyleContext + * @flags: state to represent + * + * Sets the style to be used when rendering with any + * of the "gtk_render_" prefixed functions. + * + * Since: 3.0 + **/ void gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags flags) @@ -996,6 +1257,16 @@ gtk_style_context_set_state (GtkStyleContext *context, priv->state_flags = flags; } +/** + * gtk_style_context_get_state: + * @context: a #GtkStyleContext + * + * returns the state used when rendering. + * + * Returns: the state flags + * + * Since: 3.0 + **/ GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context) { @@ -1093,6 +1364,19 @@ gtk_style_context_is_state_set (GtkStyleContext *context, return state_set; } +/** + * gtk_style_context_set_path: + * @context: a #GtkStyleContext + * @path: a #GtkWidgetPath + * + * Sets the #GtkWidgetPath used for style matching. As a + * consequence, the style will be regenerated to match + * the new given path. If you are using a #GtkStyleContext + * returned from gtk_widget_get_style_context(), you do + * not need to call this yourself. + * + * Since: 3.0 + **/ void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path) @@ -1116,6 +1400,16 @@ gtk_style_context_set_path (GtkStyleContext *context, gtk_style_context_invalidate (context); } +/** + * gtk_style_context_get_path: + * @context: a #GtkStyleContext + * + * Returns the widget path used for style matching. + * + * Returns: (transfer none): A #GtkWidgetPath + * + * Since: 3.0 + **/ G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context) { @@ -1125,6 +1419,18 @@ gtk_style_context_get_path (GtkStyleContext *context) return priv->widget_path; } +/** + * gtk_style_context_save: + * @context: a #GtkStyleContext + * + * Saves the @context state, so all modifications done through + * gtk_style_context_set_class(), gtk_style_context_unset_class(), + * gtk_style_context_set_region(), gtk_style_context_unset_region() + * or gtk_style_context_set_junction_sides() can be reverted in one + * go through gtk_style_context_restore(). + * + * Since: 3.0 + **/ void gtk_style_context_save (GtkStyleContext *context) { @@ -1141,6 +1447,15 @@ gtk_style_context_save (GtkStyleContext *context) priv->info_stack = g_slist_prepend (priv->info_stack, info); } +/** + * gtk_style_context_restore: + * @context: a #GtkStyleContext + * + * Restores @context state to a previous stage. See + * gtk_style_context_save(). + * + * Since: 3.0 + **/ void gtk_style_context_restore (GtkStyleContext *context) { @@ -1262,6 +1577,30 @@ region_find (GArray *array, return found; } +/** + * gtk_style_context_set_class: + * @context: a #GtkStyleContext + * @class_name: class name to use in styling + * + * Sets a class name to @context, so posterior calls to + * gtk_style_context_get() or any of the gtk_render_* + * functions will make use of this new class for styling. + * + * In the CSS file format, a #GtkEntry defining an "entry" + * class, would be matched by: + * + * + * GtkEntry.entry { ... } + * + * + * While any widget defining an "entry" class would be + * matched by: + * + * .entry { ... } + * + * + * Since: 3.0 + **/ void gtk_style_context_set_class (GtkStyleContext *context, const gchar *class_name) @@ -1289,6 +1628,15 @@ gtk_style_context_set_class (GtkStyleContext *context, } } +/** + * gtk_style_context_unset_class: + * @context: a #GtkStyleContext + * @class_name: class name to remove + * + * Removes @class_name from @context. + * + * Since: 3.0 + **/ void gtk_style_context_unset_class (GtkStyleContext *context, const gchar *class_name) @@ -1320,6 +1668,18 @@ gtk_style_context_unset_class (GtkStyleContext *context, } } +/** + * gtk_style_context_has_class: + * @context: a #GtkStyleContext + * @class_name: a class name + * + * Returns %TRUE if @context currently has defined the + * given class name + * + * Returns: %TRUE if @context has @class_name defined + * + * Since: 3.0 + **/ gboolean gtk_style_context_has_class (GtkStyleContext *context, const gchar *class_name) @@ -1347,6 +1707,19 @@ gtk_style_context_has_class (GtkStyleContext *context, return FALSE; } +/** + * gtk_style_context_list_classes: + * @context: a #GtkStyleContext + * + * Returns the list of classes currently defined in @context. + * + * Returns: (transfer container) (element-type utf8): a #GList of + * strings with the currently defined classes. The contents + * of the list are owned by GTK+, but you must free the list + * itself with g_list_free() when you are done with it. + * + * Since: 3.0 + **/ GList * gtk_style_context_list_classes (GtkStyleContext *context) { @@ -1373,6 +1746,20 @@ gtk_style_context_list_classes (GtkStyleContext *context) return classes; } +/** + * gtk_style_context_list_regions: + * @context: a #GtkStyleContext + * + * + * Returns the list of regions currently defined in @context. + * + * Returns: (transfer container) (element-type utf8): a #GList of + * strings with the currently defined regions. The contents + * of the list are owned by GTK+, but you must free the list + * itself with g_list_free() when you are done with it. + * + * Since: 3.0 + **/ GList * gtk_style_context_list_regions (GtkStyleContext *context) { @@ -1402,30 +1789,58 @@ gtk_style_context_list_regions (GtkStyleContext *context) return classes; } +/** + * gtk_style_context_set_region: + * @context: a #GtkStyleContext + * @region_name: region name to use in styling + * @flags: flags that apply to the region + * + * Sets a region to @context, so posterior calls to + * gtk_style_context_get() or any of the gtk_render_* + * functions will make use of this new region for styling. + * + * In the CSS file format, a #GtkTreeView defining a "row" + * region, would be matched by: + * + * + * GtkTreeView row { ... } + * + * + * pseudo-classes are used for matching @flags, so the two + * following rules: + * + * GtkTreeView row:nth-child (even) { ... } + * GtkTreeView row:nth-child (odd) { ... } + * + * + * would apply to even and odd rows, respectively. + * + * Since: 3.0 + **/ void gtk_style_context_set_region (GtkStyleContext *context, - const gchar *class_name, + const gchar *region_name, GtkRegionFlags flags) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; - GQuark class_quark; + GQuark region_quark; guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - g_return_if_fail (class_name != NULL); + g_return_if_fail (region_name != NULL); priv = context->priv; - class_quark = g_quark_from_string (class_name); + region_quark = g_quark_from_string (region_name); g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (!region_find (info->regions, class_quark, &position)) + if (!region_find (info->regions, region_quark, &position)) { GtkRegion region; - region.class_quark = class_quark; + region.class_quark = region_quark; region.flags = flags; g_array_insert_val (info->regions, position, region); @@ -1435,21 +1850,30 @@ gtk_style_context_set_region (GtkStyleContext *context, } } +/** + * gtk_style_context_unset_region: + * @context: a #GtkStyleContext + * @region_name: region name to unset + * + * Removes a region from @context + * + * Since: 3.0 + **/ void -gtk_style_context_unset_region (GtkStyleContext *context, - const gchar *class_name) +gtk_style_context_unset_region (GtkStyleContext *context, + const gchar *region_name) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; - GQuark class_quark; + GQuark region_quark; guint position; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - g_return_if_fail (class_name != NULL); + g_return_if_fail (region_name != NULL); - class_quark = g_quark_try_string (class_name); + region_quark = g_quark_try_string (region_name); - if (!class_quark) + if (!region_quark) return; priv = context->priv; @@ -1457,7 +1881,7 @@ gtk_style_context_unset_region (GtkStyleContext *context, g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (region_find (info->regions, class_quark, &position)) + if (region_find (info->regions, region_quark, &position)) { g_array_remove_index (info->regions, position); @@ -1466,25 +1890,38 @@ gtk_style_context_unset_region (GtkStyleContext *context, } } +/** + * gtk_style_context_has_region: + * @context: a #GtkStyleContext + * @region_name: a region name + * @flags_return: (out) (allow-none): return location for region flags + * + * Returns %TRUE if @context has the region defined. If @flags_return is + * not %NULL, it is set to the flags affecting the region. + * + * Returns: %TRUE if region is defined + * + * Since: 3.0 + **/ gboolean gtk_style_context_has_region (GtkStyleContext *context, - const gchar *class_name, + const gchar *region_name, GtkRegionFlags *flags_return) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; - GQuark class_quark; + GQuark region_quark; guint position; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); - g_return_val_if_fail (class_name != NULL, FALSE); + g_return_val_if_fail (region_name != NULL, FALSE); if (flags_return) *flags_return = 0; - class_quark = g_quark_try_string (class_name); + region_quark = g_quark_try_string (region_name); - if (!class_quark) + if (!region_quark) return FALSE; priv = context->priv; @@ -1492,7 +1929,7 @@ gtk_style_context_has_region (GtkStyleContext *context, g_assert (priv->info_stack != NULL); info = priv->info_stack->data; - if (region_find (info->regions, class_quark, &position)) + if (region_find (info->regions, region_quark, &position)) { if (flags_return) { @@ -1581,6 +2018,15 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, return &pcache->value; } +/** + * gtk_style_context_get_style_property: + * @context: a #GtkStyleContext + * @property_name: the name of the widget style property + * @value: (out) (transfer full): Return location for the property value, free with + * g_value_unset() after use. + * + * Gets the value for a widget style property. + **/ void gtk_style_context_get_style_property (GtkStyleContext *context, const gchar *property_name, @@ -1631,6 +2077,16 @@ gtk_style_context_get_style_property (GtkStyleContext *context, G_VALUE_TYPE_NAME (value)); } +/** + * gtk_style_context_get_style_valist: + * @context: a #GtkStyleContext + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several widget style properties from @context according to the + * current style. + * + * Since: 3.0 + **/ void gtk_style_context_get_style_valist (GtkStyleContext *context, va_list args) @@ -1688,6 +2144,16 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, } } +/** + * gtk_style_context_get_style: + * @context: a #GtkStyleContext + * @...: property name /return value pairs, followed by %NULL + * + * Retrieves several widget style properties from @context according to the + * current style. + * + * Since: 3.0 + **/ void gtk_style_context_get_style (GtkStyleContext *context, ...) @@ -1702,6 +2168,17 @@ gtk_style_context_get_style (GtkStyleContext *context, } +/** + * gtk_style_context_lookup_icon_set: + * @context: a #GtkStyleContext + * @stock_id: an icon name + * + * Looks up @stock_id in the icon factories associated to @context and + * the default icon factory, returning an icon set if found, otherwise + * %NULL. + * + * Returns: (transfer none): The looked up %GtkIconSet, or %NULL + **/ GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id) @@ -1733,6 +2210,18 @@ gtk_style_context_lookup_icon_set (GtkStyleContext *context, return gtk_icon_factory_lookup_default (stock_id); } +/** + * gtk_style_context_set_screen: + * @context: a #GtkStyleContext + * @screen: a #GdkScreen + * + * Sets the screen to which @context will be attached to, @screen + * is used in order to reconstruct style based on the global providers + * list. If you are using a #GtkStyleContext returned from + * gtk_widget_get_style_context(), you do not need to call this yourself. + * + * Since: 3.0 + **/ void gtk_style_context_set_screen (GtkStyleContext *context, GdkScreen *screen) @@ -1749,6 +2238,14 @@ gtk_style_context_set_screen (GtkStyleContext *context, gtk_style_context_invalidate (context); } +/** + * gtk_style_context_get_screen: + * @context: a #GtkStyleContext + * + * Returns the #GdkScreen to which @context is attached to. + * + * Returns: a #GdkScreen, or %NULL. + **/ GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context) { @@ -1760,6 +2257,17 @@ gtk_style_context_get_screen (GtkStyleContext *context) return priv->screen; } +/** + * gtk_style_context_set_direction: + * @context: a #GtkStyleContext + * @direction: the new direction. + * + * Sets the reading direction for rendering purposes. If you are + * using a #GtkStyleContext returned from gtk_widget_get_style_context(), + * you do not need to call this yourself. + * + * Since: 3.0 + **/ void gtk_style_context_set_direction (GtkStyleContext *context, GtkTextDirection direction) @@ -1774,6 +2282,16 @@ gtk_style_context_set_direction (GtkStyleContext *context, g_object_notify (G_OBJECT (context), "direction"); } +/** + * gtk_style_context_get_direction: + * @context: a #GtkStyleContext + * + * Returns the widget direction used for rendering. + * + * Returns: the widget direction + * + * Since: 3.0 + **/ GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context) { @@ -1785,6 +2303,17 @@ gtk_style_context_get_direction (GtkStyleContext *context) return priv->direction; } +/** + * gtk_style_context_set_junction_sides: + * @context: a #GtkStyleContext + * @sides: sides where rendered elements are visually connected to other elements. + * + * Sets the sides where rendered elements (mostly through gtk_render_frame()) will + * visually connect with other visual elements. This is merely a guideline that may + * be honored or not in theming engines. + * + * Since: 3.0 + **/ void gtk_style_context_set_junction_sides (GtkStyleContext *context, GtkJunctionSides sides) @@ -1799,6 +2328,16 @@ gtk_style_context_set_junction_sides (GtkStyleContext *context, info->junction_sides = sides; } +/** + * gtk_style_context_get_junction_sides: + * @context: a #GtkStyleContext + * + * Returns the sides where rendered elements connect visually with others. + * + * Returns: the junction sides + * + * Since: 3.0 + **/ GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context) { @@ -1812,6 +2351,16 @@ gtk_style_context_get_junction_sides (GtkStyleContext *context) return info->junction_sides; } +/** + * gtk_style_context_lookup_color: + * @context: a #GtkStyleContext + * @color_name: color name to lookup + * @color: (out): Return location for the looked up color + * + * Looks up and resolves a color name in the @context color map. + * + * Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise + **/ gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, @@ -1837,6 +2386,53 @@ gtk_style_context_lookup_color (GtkStyleContext *context, return gtk_symbolic_color_resolve (sym_color, data->store, color); } +/** + * gtk_style_context_notify_state_change: + * @context: a #GtkStyleContext + * @window: a #GdkWindow + * @region_id: (allow-none): animatable region to notify on, or %NULL. + * See gtk_style_context_push_animatable_region() + * @state: state to trigger transition for + * @state_value: target value of @state + * + * Notifies a state change on @context, so if the current style makes use + * of transition animations, one will be started so all rendered elements + * under @region_id are animated for state @state being set to value @state_value. + * + * The @window parameter is used in order to invalidate the rendered area + * as the animation runs, so make sure it is the same window that is being + * rendered on by the gtk_render_*() methods. + * + * If @region_id is %NULL, all rendered elements using @context will be + * affected by this state transition. + * + * As a practical example, a #GtkButton notifying a state transition on + * the prelight state: + * + * gtk_style_context_notify_state_change (context, + * gtk_widget_get_window (widget), + * NULL, GTK_STATE_PRELIGHT, + * button->in_button); + * + * + * Could be handled in the CSS file like this: + * + * GtkButton { + * background-color: #f00; + * } + * + * GtkButton:hover { + * background-color: #fff; + * transition: 200ms linear; + * } + * + * + * This combination would animate the button background from red to white + * if a pointer enters the button, and back to red if the pointer leaves + * the button. + * + * Since: 3.0 + **/ void gtk_style_context_notify_state_change (GtkStyleContext *context, GdkWindow *window, @@ -1931,6 +2527,22 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, gtk_animation_description_unref (desc); } +/** + * gtk_style_context_push_animatable_region: + * @context: a #GtkStyleContext + * @region_id: unique identifier for the animatable region + * + * Pushes an animatable region, so all further gtk_render_*() calls between + * this call and the following gtk_style_context_pop_animatable_region() will + * potentially show transition animations for if gtk_style_context_notify_state_change() + * is called for a given state, and the theme/style used contemplates the use of + * transition animations for state changes. + * + * The @region_id used must be unique in @context so the theming engine may + * univocally identify rendered elements subject to a state transition. + * + * Since: 3.0 + **/ void gtk_style_context_push_animatable_region (GtkStyleContext *context, gpointer region_id) @@ -1944,6 +2556,14 @@ gtk_style_context_push_animatable_region (GtkStyleContext *context, priv->animation_regions = g_slist_prepend (priv->animation_regions, region_id); } +/** + * gtk_style_context_pop_animatable_region: + * @context: a #GtkStyleContext + * + * Pops an animatable region from @context. See gtk_style_context_push_animatable_region(). + * + * Since: 3.0 + **/ void gtk_style_context_pop_animatable_region (GtkStyleContext *context) { @@ -2074,6 +2694,16 @@ store_animation_region (GtkStyleContext *context, } } +/** + * gtk_style_context_invalidate: + * @context: a #GtkStyleContext. + * + * Invalidates @context style information, so it will be reconstructed + * again. If you're using a #GtkStyleContext returned from + * gtk_widget_get_style_context(), you do not need to call this yourself. + * + * Since: 3.0 + **/ void gtk_style_context_invalidate (GtkStyleContext *context) { diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 9bab375a05..a9843f352e 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -33,16 +33,16 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT)) #define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass)) -typedef struct GtkStyleContext GtkStyleContext; -typedef struct GtkStyleContextClass GtkStyleContextClass; +typedef struct _GtkStyleContext GtkStyleContext; +typedef struct _GtkStyleContextClass GtkStyleContextClass; -struct GtkStyleContext +struct _GtkStyleContext { GObject parent_object; gpointer priv; }; -struct GtkStyleContextClass +struct _GtkStyleContextClass { GObjectClass parent_class; diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 2c23a80edb..2a9d2fc5e5 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -23,6 +23,16 @@ #include "gtkstyleprovider.h" #include "gtkintl.h" +/** + * SECTION:gtkstyleprovider + * @Short_description: Interface to provide style information to #GtkStyleContext + * @Title: GtkStyleProvider + * @See_also: #GtkStyleContext, #GtkCssProvider + * + * #GtkStyleProvider is an interface used to provide style information to a #GtkStyleContext, + * see gtk_style_context_add_provider() and gtk_style_context_add_provider_for_screen(). + */ + static void gtk_style_provider_iface_init (gpointer g_iface); GType @@ -44,6 +54,18 @@ gtk_style_provider_iface_init (gpointer g_iface) { } +/** + * gtk_style_provider_get_style: + * @provider: a #GtkStyleProvider + * @path: #GtkWidgetPath to query + * + * Returns the style settings affecting a widget defined by @path, or %NULL if + * @provider doesn't contemplate styling @path. + * + * Returns: a #GtkStyleSet containing the style settings affecting @path + * + * Since: 3.0 + **/ GtkStyleSet * gtk_style_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) @@ -60,16 +82,28 @@ gtk_style_provider_get_style (GtkStyleProvider *provider, return iface->get_style (provider, path); } +/** + * gtk_style_provider_get_style_property: + * @provider: a #GtkStyleProvider + * @path: #GtkWidgetPath to query + * @property_name: the property name + * @value: (out): return location for the property value + * + * Looks up a widget style property as defined by @provider for + * the widget represented by @widget_path. + * + * Returns: %TRUE if the property was found and has a value, %FALSE otherwise + **/ gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, - GtkWidgetPath *widget_path, + GtkWidgetPath *path, const gchar *property_name, GValue *value) { GtkStyleProviderIface *iface; g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE); - g_return_val_if_fail (widget_path != NULL, FALSE); + g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (property_name != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); @@ -78,9 +112,21 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider, if (!iface->get_style_property) return FALSE; - return iface->get_style_property (provider, widget_path, property_name, value); + return iface->get_style_property (provider, path, property_name, value); } +/** + * gtk_style_provider_get_icon_factory: + * @provider: a #GtkStyleProvider + * @path: #GtkWidgetPath to query + * + * Returns the #GtkIconFactory defined to be in use for @path, or %NULL if none + * is defined. + * + * Returns: The icon factory to use for @path, or %NULL + * + * Since: 3.0 + **/ GtkIconFactory * gtk_style_provider_get_icon_factory (GtkStyleProvider *provider, GtkWidgetPath *path) diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 556b257405..0f763a2b41 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -39,10 +39,16 @@ G_BEGIN_DECLS #define GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 600 #define GTK_STYLE_PROVIDER_PRIORITY_USER 800 -typedef struct GtkStyleProviderIface GtkStyleProviderIface; -typedef struct GtkStyleProvider GtkStyleProvider; /* dummy typedef */ +typedef struct _GtkStyleProviderIface GtkStyleProviderIface; +typedef struct _GtkStyleProvider GtkStyleProvider; /* dummy typedef */ -struct GtkStyleProviderIface +/** + * GtkStyleProviderIface + * @get_style: Gets a set of style information that applies to a widget path. + * @get_style_property: Gets the value of a widget style property that applies to a widget path. + * @get_icon_factory: Gets the icon factory that applies to a widget path. + */ +struct _GtkStyleProviderIface { GTypeInterface g_iface; diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 2f71f718b4..24641621ad 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -325,6 +325,21 @@ property_node_lookup (GQuark quark) } /* Property registration functions */ + +/** + * gtk_style_set_register_property: + * @property_name: property name to register + * @type: #GType the property will hold + * @default_value: default value for this property + * @parse_func: parsing function to use, or %NULL + * + * Registers a property so it can be used in the CSS file format. + * This function is the low-level equivalent of + * gtk_theming_engine_register_property(), if you are implementing + * a theming engine, you want to use that function instead. + * + * Since: 3.0 + **/ void gtk_style_set_register_property (const gchar *property_name, GType type, @@ -377,6 +392,20 @@ gtk_style_set_register_property (const gchar *property_name, g_array_insert_val (properties, i, new); } +/** + * gtk_style_set_lookup_property: + * @property_name: property name to look up + * @type: (out): return location for the looked up property type + * @parse_func: (out): return value for the parse function + * + * Returns %TRUE if a property has been registered, if @type or + * @parse_func are not %NULL, the property #GType and parsing function + * will be respectively returned. + * + * Returns: %TRUE if the property is registered, %FALSE otherwise + * + * Since: 3.0 + **/ gboolean gtk_style_set_lookup_property (const gchar *property_name, GType *type, @@ -425,12 +454,30 @@ gtk_style_set_lookup_property (const gchar *property_name, /* GtkStyleSet methods */ +/** + * gtk_style_set_new: + * + * Returns a newly created #GtkStyleSet + * + * Returns: a new #GtkStyleSet + **/ GtkStyleSet * gtk_style_set_new (void) { return g_object_new (GTK_TYPE_STYLE_SET, NULL); } +/** + * gtk_style_set_map_color: + * @set: a #GtkStyleSet + * @name: color name + * @color: #GtkSymbolicColor to map @name to + * + * Maps @color so it can be referenced by @name. See + * gtk_style_set_lookup_color() + * + * Since: 3.0 + **/ void gtk_style_set_map_color (GtkStyleSet *set, const gchar *name, @@ -455,6 +502,18 @@ gtk_style_set_map_color (GtkStyleSet *set, gtk_symbolic_color_ref (color)); } +/** + * gtk_style_set_lookup_color: + * @set: a #GtkStyleSet + * @name: color name to lookup + * + * Returns the symbolic color that is mapped + * to @name. + * + * Returns: The mapped color + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_style_set_lookup_color (GtkStyleSet *set, const gchar *name) @@ -472,6 +531,17 @@ gtk_style_set_lookup_color (GtkStyleSet *set, return g_hash_table_lookup (priv->color_map, name); } +/** + * gtk_style_set_set_property: + * @set: a #GtkStyleSet + * @property: styling property to set + * @state: state to set the value for + * @value: new value for the property + * + * Sets a styling property in @set. + * + * Since: 3.0 + **/ void gtk_style_set_set_property (GtkStyleSet *set, const gchar *property, @@ -538,6 +608,16 @@ gtk_style_set_set_property (GtkStyleSet *set, g_value_copy (value, val); } +/** + * gtk_style_set_set_valist: + * @set: a #GtkStyleSet + * @state: state to set the values for + * @args: va_list of property name/value pairs, followed by %NULL + * + * Sets several style properties on @set. + * + * Since: 3.0 + **/ void gtk_style_set_set_valist (GtkStyleSet *set, GtkStateFlags state, @@ -597,6 +677,16 @@ gtk_style_set_set_valist (GtkStyleSet *set, } } +/** + * gtk_style_set_set: + * @set: a #GtkStyleSet + * @state: state to set the values for + * @...: property name/value pairs, followed by %NULL + * + * Sets several style properties on @set. + * + * Since: 3.0 + **/ void gtk_style_set_set (GtkStyleSet *set, GtkStateFlags state, @@ -646,6 +736,20 @@ resolve_gradient (GtkStyleSet *set, return TRUE; } +/** + * gtk_style_set_get_property: + * @set: a #GtkStyleSet + * @property: style property name + * @state: state to retrieve the property value for + * @value: (out) (transfer full): return location for the style property value. + * + * Gets a style property from @set for the given state. When done with @value, + * g_value_unset() needs to be called to free any allocated memory. + * + * Returns: %TRUE if the property exists in @set, %FALSE otherwise + * + * Since: 3.0 + **/ gboolean gtk_style_set_get_property (GtkStyleSet *set, const gchar *property, @@ -705,6 +809,16 @@ gtk_style_set_get_property (GtkStyleSet *set, return TRUE; } +/** + * gtk_style_set_get_valist: + * @set: a #GtkStyleSet + * @state: state to retrieve the property values for + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several style property values from @set for a given state. + * + * Since: 3.0 + **/ void gtk_style_set_get_valist (GtkStyleSet *set, GtkStateFlags state, @@ -770,6 +884,17 @@ gtk_style_set_get_valist (GtkStyleSet *set, } } +/** + * gtk_style_set_get: + * @set: a #GtkStyleSet + * @state: state to retrieve the property values for + * @...: property name /return value pairs, followed by %NULL + * + * Retrieves several style property values from @set for a + * given state. + * + * Since: 3.0 + **/ void gtk_style_set_get (GtkStyleSet *set, GtkStateFlags state, @@ -784,6 +909,16 @@ gtk_style_set_get (GtkStyleSet *set, va_end (args); } +/** + * gtk_style_set_unset_property: + * @set: a #GtkStyleSet + * @property: property to unset + * @state: state to unset + * + * Unsets a style property in @set. + * + * Since: 3.0 + **/ void gtk_style_set_unset_property (GtkStyleSet *set, const gchar *property, @@ -825,6 +960,12 @@ gtk_style_set_unset_property (GtkStyleSet *set, } } +/** + * gtk_style_set_clear: + * @set: a #GtkStyleSet + * + * Clears all style information from @set. + **/ void gtk_style_set_clear (GtkStyleSet *set) { @@ -836,6 +977,19 @@ gtk_style_set_clear (GtkStyleSet *set) g_hash_table_remove_all (priv->properties); } +/** + * gtk_style_set_merge: + * @set: a #GtkStyleSet + * @set_to_merge: a second #GtkStyleSet + * @replace: whether to replace values or not + * + * Merges into @set all the style information contained + * in @set_to_merge. If @replace is %TRUE, the values + * will be overwritten, if it is %FALSE, the older values + * will prevail. + * + * Since: 3.0 + **/ void gtk_style_set_merge (GtkStyleSet *set, const GtkStyleSet *set_to_merge, diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index f81881a596..f19ce16041 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -34,16 +34,16 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_SET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_SET)) #define GTK_STYLE_SET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_SET, GtkStyleSetClass)) -typedef struct GtkStyleSet GtkStyleSet; -typedef struct GtkStyleSetClass GtkStyleSetClass; +typedef struct _GtkStyleSet GtkStyleSet; +typedef struct _GtkStyleSetClass GtkStyleSetClass; -struct GtkStyleSet +struct _GtkStyleSet { GObject parent_object; gpointer priv; }; -struct GtkStyleSetClass +struct _GtkStyleSetClass { GObjectClass parent_class; }; diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 657ac82e3d..e803c2e1e7 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -35,7 +35,7 @@ typedef enum { COLOR_TYPE_MIX } ColorType; -struct GtkSymbolicColor +struct _GtkSymbolicColor { ColorType type; guint ref_count; @@ -68,7 +68,7 @@ struct ColorStop GtkSymbolicColor *color; }; -struct GtkGradient +struct _GtkGradient { gdouble x0; gdouble y0; @@ -82,6 +82,16 @@ struct GtkGradient guint ref_count; }; +/** + * gtk_symbolic_color_new_literal: + * @color: a #GdkColor + * + * Creates a symbolic color pointing to a literal color. + * + * Returns: a newly created #GtkSymbolicColor + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkColor *color) { @@ -97,6 +107,18 @@ gtk_symbolic_color_new_literal (GdkColor *color) return symbolic_color; } +/** + * gtk_symbolic_color_new_name: + * @name: color name + * + * Creates a symbolic color pointing to an unresolved named + * color. See gtk_style_context_lookup_color() and + * gtk_style_set_lookup_color(). + * + * Returns: a newly created #GtkSymbolicColor + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name) { @@ -112,6 +134,20 @@ gtk_symbolic_color_new_name (const gchar *name) return symbolic_color; } +/** + * gtk_symbolic_color_new_shade: + * @color: another #GtkSymbolicColor + * @factor: shading factor to apply to @color + * + * Creates a symbolic color defined as a shade of + * another color. A factor > 1.0 would resolve to + * a brighter color, while < 1.0 would resolve to + * a darker color. + * + * Returns: A newly created #GtkSymbolicColor + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, gdouble factor) @@ -129,6 +165,20 @@ gtk_symbolic_color_new_shade (GtkSymbolicColor *color, return symbolic_color; } +/** + * gtk_symbolic_color_new_mix: + * @color1: color to mix + * @color2: another color to mix + * @factor: mix factor + * + * Creates a symbolic color defined as a mix of another + * two colors. a mix factor of 0 would resolve to @color1, + * while a factor of 1 would resolve to @color2. + * + * Returns: A newly created #GtkSymbolicColor + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, GtkSymbolicColor *color2, @@ -149,6 +199,16 @@ gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, return symbolic_color; } +/** + * gtk_symbolic_color_ref: + * @color: a #GtkSymbolicColor + * + * Increases the reference count of @color + * + * Returns: the same @color + * + * Since: 3.0 + **/ GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color) { @@ -159,6 +219,15 @@ gtk_symbolic_color_ref (GtkSymbolicColor *color) return color; } +/** + * gtk_symbolic_color_unref: + * @color: a #GtkSymbolicColor + * + * Decreases the reference count of @color, freeing its memory if the + * reference count reaches 0. + * + * Since: 3.0 + **/ void gtk_symbolic_color_unref (GtkSymbolicColor *color) { @@ -188,6 +257,21 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) } } +/** + * gtk_symbolic_color_resolve: + * @color: a #GtkSymbolicColor + * @style_set: #GtkStyleSet to use when resolving named colors + * @resolved_color: (out): return location for the resolved color + * + * If @color is resolvable, @resolved_color will be filled in + * with the resolved color, and %TRUE will be returned. Generally, + * if @color can't be resolved, it is due to it being defined on + * top of a named color that doesn't exist in @style_set. + * + * Returns: %TRUE if the color has been resolved + * + * Since: 3.0 + **/ gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, GtkStyleSet *style_set, @@ -256,6 +340,20 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, } /* GtkGradient */ +/** + * gtk_gradient_new_linear: + * @x0: X coordinate of the starting point + * @y0: Y coordinate of the starting point + * @x1: X coordinate of the end point + * @y1: Y coordinate of the end point + * + * Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient + * a number of stop colors must be added through gtk_gradient_add_color_stop(). + * + * Returns: A newly created #GtkGradient + * + * Since: 3.0 + **/ GtkGradient * gtk_gradient_new_linear (gdouble x0, gdouble y0, @@ -279,6 +377,23 @@ gtk_gradient_new_linear (gdouble x0, return gradient; } +/** + * gtk_gradient_new_radial: + * @x0: X coordinate of the start circle + * @y0: Y coordinate of the start circle + * @radius0: radius of the start circle + * @x1: X coordinate of the end circle + * @y1: Y coordinate of the end circle + * @radius1: radius of the end circle + * + * Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and + * (x1, y1, radius1). Before using the gradient a number of stop colors must be added + * through gtk_gradient_add_color_stop(). + * + * Returns: A newly created #GtkGradient + * + * Since: 3.0 + **/ GtkGradient * gtk_gradient_new_radial (gdouble x0, gdouble y0, @@ -304,6 +419,16 @@ gtk_gradient_new_radial (gdouble x0, return gradient; } +/** + * gtk_gradient_add_color_stop: + * @gradient: a #GtkGradient + * @offset: offset for the color stop + * @color: color to use + * + * Adds a stop color to @gradient. + * + * Since: 3.0 + **/ void gtk_gradient_add_color_stop (GtkGradient *gradient, gdouble offset, @@ -319,6 +444,16 @@ gtk_gradient_add_color_stop (GtkGradient *gradient, g_array_append_val (gradient->stops, stop); } +/** + * gtk_gradient_ref: + * @gradient: a #GtkGradient + * + * Increases the reference count of @gradient. + * + * Returns: The same @gradient + * + * Since: 3.0 + **/ GtkGradient * gtk_gradient_ref (GtkGradient *gradient) { @@ -329,6 +464,15 @@ gtk_gradient_ref (GtkGradient *gradient) return gradient; } +/** + * gtk_gradient_unref: + * @gradient: a #GtkGradient + * + * Decreases the reference count of @gradient, freeing its memory + * if the reference count reaches 0. + * + * Since: 3.0 + **/ void gtk_gradient_unref (GtkGradient *gradient) { @@ -353,6 +497,22 @@ gtk_gradient_unref (GtkGradient *gradient) } } +/** + * gtk_gradient_resolve: + * @gradient: a #GtkGradient + * @style_set: #GtkStyleSet to use when resolving named colors + * @resolved_gradient: (out): return location for the resolved pattern + * + * If @gradient is resolvable, @resolved_gradient will be filled in + * with the resolved gradient as a cairo_pattern_t, and %TRUE will + * be returned. Generally, if @gradient can't be resolved, it is + * due to it being defined on top of a named color that doesn't + * exist in @style_set. + * + * Returns: %TRUE if the gradient has been resolved + * + * Since: 3.0 + **/ gboolean gtk_gradient_resolve (GtkGradient *gradient, GtkStyleSet *style_set, diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index de403a325f..e326992a33 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -25,8 +25,8 @@ G_BEGIN_DECLS /* Dummy typedefs */ -typedef struct GtkSymbolicColor GtkSymbolicColor; -typedef struct GtkGradient GtkGradient; +typedef struct _GtkSymbolicColor GtkSymbolicColor; +typedef struct _GtkGradient GtkGradient; #define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ()) #define GTK_TYPE_GRADIENT (gtk_gradient_get_type ()) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 5096996e57..f72e6a6686 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -29,6 +29,23 @@ #include "gtk9slice.h" #include "gtkpango.h" +/** + * SECTION:gtkthemingengine + * @Short_description: Theming renderers + * @Title: GtkThemingEngine + * @See_also: #GtkStyleContext + * + * #GtkThemingEngine is the object used for rendering themed content + * in GTK+ widgets. Even though GTK+ has a default implementation, + * it can be overridden in CSS files by enforcing a #GtkThemingEngine + * object to be loaded as a module. + * + * In order to implement a theming engine, a #GtkThemingEngine subclass + * must be created, alongside the CSS file that will reference it, the + * theming engine would be created as an .so library, and installed in + * $(gtk-modules-dir)/theming-engines/. + */ + typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate; enum { @@ -194,6 +211,45 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, priv->context = context; } +/** + * gtk_theming_engine_register_property: + * @engine: a #GtkThemingEngine + * @property_name: property name to register + * @type: #GType the property will hold + * @default_value: default value for this property + * @parse_func: parsing function to use, or %NULL + * + * Registers a property so it can be used in the CSS file format, + * on the CSS file the property will look like + * "-${engine-object-name}-${@property_name}". being + * ${engine-object-name} the same than G_OBJECT_TYPE_NAME(engine) + * would return. + * + * For any type a @parse_func may be provided, being this function + * used for turning any property value (between ':' and ';') in + * CSS to the #GValue needed. For basic types there is already + * builtin parsing support, so %NULL may be provided for these + * cases. + * + * + * This function needs to be called only once during theming + * engine object initialization. + * + * + * + * In order to make use of the custom registered properties in + * the CSS file, make sure the engine is loaded first either in + * a previous rule or within the same one. + * + * * { + * engine: someengine; + * SomeEngine-custom-property: 2; + * } + * + * + * + * Since: 3.0 + **/ void gtk_theming_engine_register_property (GtkThemingEngine *engine, const gchar *property_name, @@ -213,6 +269,20 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, g_free (name); } +/** + * gtk_theming_engine_get_property: + * @engine: a #GtkThemingEngine + * @property: the property name + * @state: state to retrieve the value for + * @value: (out) (transfer full): return location for the property value, + * you must free this memory using g_value_unset() once you are + * done with it. + * + * Gets a property value as retrieved from the style settings that apply + * to the currently rendered element. + * + * Since: 3.0 + **/ void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, @@ -229,6 +299,17 @@ gtk_theming_engine_get_property (GtkThemingEngine *engine, gtk_style_context_get_property (priv->context, property, state, value); } +/** + * gtk_theming_engine_get_valist: + * @engine: a #GtkThemingEngine + * @state: state to retrieve values for + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several style property values that apply to the currently + * rendered element. + * + * Since: 3.0 + **/ void gtk_theming_engine_get_valist (GtkThemingEngine *engine, GtkStateFlags state, @@ -242,6 +323,17 @@ gtk_theming_engine_get_valist (GtkThemingEngine *engine, gtk_style_context_get_valist (priv->context, state, args); } +/** + * gtk_theming_engine_get: + * @engine: a #GtkThemingEngine + * @state: state to retrieve values for + * @...: property name /return value pairs, followed by %NULL + * + * Retrieves several style property values that apply to the currently + * rendered element. + * + * Since: 3.0 + **/ void gtk_theming_engine_get (GtkThemingEngine *engine, GtkStateFlags state, @@ -259,6 +351,17 @@ gtk_theming_engine_get (GtkThemingEngine *engine, va_end (args); } +/** + * gtk_theming_engine_get_style_property: + * @engine: a #GtkThemingEngine + * @property_name: the name of the widget style property + * @value: (out) (transfer full): Return location for the property value, free with + * g_value_unset() after use. + * + * Gets the value for a widget style property. + * + * Since: 3.0 + **/ void gtk_theming_engine_get_style_property (GtkThemingEngine *engine, const gchar *property_name, @@ -273,6 +376,16 @@ gtk_theming_engine_get_style_property (GtkThemingEngine *engine, gtk_style_context_get_style_property (priv->context, property_name, value); } +/** + * gtk_theming_engine_get_style_valist: + * @engine: a #GtkThemingEngine + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several widget style properties from @engine according to the + * currently rendered content's style. + * + * Since: 3.0 + **/ void gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, va_list args) @@ -285,6 +398,16 @@ gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, gtk_style_context_get_style_valist (priv->context, args); } +/** + * gtk_theming_engine_get_style: + * @engine: a #GtkThemingEngine + * @...: property name /return value pairs, followed by %NULL + * + * Retrieves several widget style properties from @engine according + * to the currently rendered content's style. + * + * Since: 3.0 + **/ void gtk_theming_engine_get_style (GtkThemingEngine *engine, ...) @@ -301,6 +424,16 @@ gtk_theming_engine_get_style (GtkThemingEngine *engine, va_end (args); } +/** + * gtk_theming_engine_get_state: + * @engine: a #GtkThemingEngine + * + * returns the state used when rendering. + * + * Returns: the state flags + * + * Since: 3.0 + **/ GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine) { @@ -325,6 +458,16 @@ gtk_theming_engine_is_state_set (GtkThemingEngine *engine, return gtk_style_context_is_state_set (priv->context, state, progress); } +/** + * gtk_theming_engine_get_path: + * @engine: a #GtkThemingEngine + * + * Returns the widget path used for style matching. + * + * Returns: (transfer none): A #GtkWidgetPath + * + * Since: 3.0 + **/ G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine) { @@ -336,6 +479,18 @@ gtk_theming_engine_get_path (GtkThemingEngine *engine) return gtk_style_context_get_path (priv->context); } +/** + * gtk_theming_engine_has_class: + * @engine: a #GtkThemingEngine + * @style_class: class name to look up + * + * Returns %TRUE if the currently rendered contents have + * defined the given class name. + * + * Returns: %TRUE if @engine has @class_name defined + * + * Since: 3.0 + **/ gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, const gchar *style_class) @@ -348,9 +503,23 @@ gtk_theming_engine_has_class (GtkThemingEngine *engine, return gtk_style_context_has_class (priv->context, style_class); } +/** + * gtk_theming_engine_has_region: + * @engine: a #GtkThemingEngine + * @style_region: a region name + * @flags: (out) (allow-none): return location for region flags + * + * Returns %TRUE if the currently rendered contents have the + * region defined. If @flags_return is not %NULL, it is set + * to the flags affecting the region. + * + * Returns: %TRUE if region is defined + * + * Since: 3.0 + **/ gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine, - const gchar *style_class, + const gchar *style_region, GtkRegionFlags *flags) { GtkThemingEnginePrivate *priv; @@ -361,9 +530,19 @@ gtk_theming_engine_has_region (GtkThemingEngine *engine, g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); priv = engine->priv; - return gtk_style_context_has_region (priv->context, style_class, flags); + return gtk_style_context_has_region (priv->context, style_region, flags); } +/** + * gtk_theming_engine_get_direction: + * @engine: a #GtkThemingEngine + * + * Returns the widget direction used for rendering. + * + * Returns: the widget direction + * + * Since: 3.0 + **/ GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine) { @@ -375,6 +554,16 @@ gtk_theming_engine_get_direction (GtkThemingEngine *engine) return gtk_style_context_get_direction (priv->context); } +/** + * gtk_theming_engine_get_junction_sides: + * @engine: a #GtkThemingEngine + * + * Returns the widget direction used for rendering. + * + * Returns: the widget direction + * + * Since: 3.0 + **/ GtkJunctionSides gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine) { @@ -441,6 +630,16 @@ gtk_theming_module_init (GtkThemingModule *module) { } +/** + * gtk_theming_engine_load: + * @name: Theme engine name to load + * + * Loads and initializes a theming engine module from the + * standard directories. + * + * Returns: (transfer none): A theming engine, or %NULL if + * the engine @name doesn't exist. + **/ GtkThemingEngine * gtk_theming_engine_load (const gchar *name) { @@ -484,6 +683,14 @@ gtk_theming_engine_load (const gchar *name) return engine; } +/** + * gtk_theming_engine_get_screen: + * @engine: a #GtkThemingEngine + * + * Returns the #GdkScreen to which @engine currently rendering to. + * + * Returns: a #GdkScreen, or %NULL. + **/ GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine) { diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 47a4234f4b..6ecf9c1009 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -36,16 +36,36 @@ G_BEGIN_DECLS #define GTK_IS_THEMING_ENGINE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_THEMING_ENGINE)) #define GTK_THEMING_ENGINE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEngineClass)) -typedef struct GtkThemingEngine GtkThemingEngine; -typedef struct GtkThemingEngineClass GtkThemingEngineClass; +typedef struct _GtkThemingEngine GtkThemingEngine; +typedef struct _GtkThemingEngineClass GtkThemingEngineClass; -struct GtkThemingEngine +struct _GtkThemingEngine { GObject parent_object; gpointer priv; }; -struct GtkThemingEngineClass +/** + * GtkThemingEngineClass + * @parent_class: The parent class. + * @render_line: Renders a line between two points. + * @render_background: Renders the background area of a widget region. + * @render_frame: Renders the frame around a widget area. + * @render_frame_gap: Renders the frame around a widget area with a gap in it. + * @render_extension: Renders a extension to a box, usually a notebook tab. + * @render_check: Renders a checkmark, as in #GtkCheckButton. + * @render_option: Renders an option, as in #GtkRadioButton. + * @render_arrow: Renders an arrow pointing to a certain direction. + * @render_expander: Renders an element what will expose/expand part of + * the UI, as in #GtkExpander. + * @render_focus: Renders the focus indicator. + * @render_layout: Renders a #PangoLayout + * @render_slider: Renders a slider control, as in #GtkScale. + * @render_handle: Renders a handle to drag UI elements, as in #GtkPaned. + * + * Base class for theming engines. + */ +struct _GtkThemingEngineClass { GObjectClass parent_class; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8ab15be5e2..d1765ec4c7 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13270,6 +13270,16 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, widget->priv->height_request_needed = height_request_needed; } +/** + * gtk_widget_get_path: + * @widget: a #GtkWidget + * + * Returns the #GtkWidgetPath representing @widget, if the widget + * is not connected to a toplevel widget, a partial path will be + * created. + * + * Returns: (transfer none): The #GtkWidgetPath representing @widget + **/ GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget) { @@ -13312,6 +13322,15 @@ style_context_changed (GtkStyleContext *context, g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0); } +/** + * gtk_widget_get_style_context: + * @widget: a #GtkWidget + * + * Returns the style context associated to @widget. + * + * Returns: (transfer none): a #GtkStyleContext. This memory is owned by @widget and + * must not be freed. + **/ GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget) { diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index c6cfbb5c81..578335b8e7 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -24,6 +24,62 @@ #include "gtkwidget.h" #include "gtkwidgetpath.h" +/** + * SECTION:gtkwidgetpath + * @Short_description: Widget path abstraction + * @Title: GtkWidgetPath + * @See_also: #GtkStyleContext + * + * #GtkWidgetPath is an struct that represents a widget hierarchy from + * the topmost widget, typically a toplevel, to any child. This widget + * path abstraction is used in #GtkStyleContext on behalf of the real + * widget in order to query style information. + * + * If you are using GTK+ widgets, there are many chances you don't + * need this API directly, as there is gtk_widget_get_path(), and the + * style context returned by gtk_widget_get_style_context() will be + * automatically updated on widget hierarchy changes. + * + * The widget path generation is generally simple: + * + * Defining a button within a window + * + * { + * GtkWidgetPath *path; + * + * path = gtk_widget_path_new (); + * gtk_widget_path_append_type (path, GTK_TYPE_WINDOW); + * gtk_widget_path_append_type (path, GTK_TYPE_BUTTON); + * } + * + * + * + * Although more complex information, such as widget names, or + * different classes (property that may be used by other widget + * types) and intermediate regions may be included: + * + * + * Defining the first tab widget in a notebook + * + * { + * GtkWidgetPath *path; + * guint pos; + * + * path = gtk_widget_path_new (); + * + * pos = gtk_widget_path_append_type (path, GTK_TYPE_NOTEBOOK); + * gtk_widget_path_iter_add_region (path, pos, "tab", GTK_REGION_EVEN | GTK_REGION_FIRST); + * + * pos = gtk_widget_path_append_type (path, GTK_TYPE_LABEL); + * gtk_widget_path_iter_set_name (path, pos, "first tab label"); + * } + * + * + * + * All this information will be used to match the style information + * that applies to the described widget. + **/ + typedef struct GtkPathElement GtkPathElement; struct GtkPathElement @@ -34,11 +90,20 @@ struct GtkPathElement GArray *classes; }; -struct GtkWidgetPath +struct _GtkWidgetPath { GArray *elems; /* First element contains the described widget */ }; +/** + * gtk_widget_path_new: + * + * Returns an empty widget path. + * + * Returns: (transfer full): A newly created, empty, #GtkWidgetPath + * + * Since: 3.0 + **/ GtkWidgetPath * gtk_widget_path_new (void) { @@ -50,6 +115,16 @@ gtk_widget_path_new (void) return path; } +/** + * gtk_widget_path_copy: + * @path: a #GtkWidgetPath + * + * Returns a copy of @path + * + * Returns: (transfer full): a copy of @path + * + * Since: 3.0 + **/ GtkWidgetPath * gtk_widget_path_copy (const GtkWidgetPath *path) { @@ -87,6 +162,14 @@ gtk_widget_path_copy (const GtkWidgetPath *path) return new_path; } +/** + * gtk_widget_path_free: + * @path: a #GtkWidgetPath + * + * Frees a #GtkWidgetPath. + * + * Since: 3.0 + **/ void gtk_widget_path_free (GtkWidgetPath *path) { @@ -111,6 +194,17 @@ gtk_widget_path_free (GtkWidgetPath *path) g_slice_free (GtkWidgetPath, path); } +/** + * gtk_widget_path_length: + * @path: a #GtkWidgetPath + * + * Returns the number of #GtkWidget #GTypes between the represented + * widget and its topmost container. + * + * Returns: the number of elements in the path + * + * Since: 3.0 + **/ guint gtk_widget_path_length (const GtkWidgetPath *path) { @@ -119,6 +213,17 @@ gtk_widget_path_length (const GtkWidgetPath *path) return path->elems->len; } +/** + * gtk_widget_path_prepend_type: + * @path: a #GtkWidgetPath + * @type: widget type to prepend + * + * Prepends a widget type to the widget hierachy represented by @path. + * + * Returns: the position where the element was inserted + * + * Since: 3.0 + **/ guint gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type) @@ -134,6 +239,17 @@ gtk_widget_path_prepend_type (GtkWidgetPath *path, return 0; } +/** + * gtk_widget_path_append_type: + * @path: a #GtkWidgetPath + * @type: widget type to append + * + * Appends a widget type to the widget hierachy represented by @path. + * + * Returns: the position where the element was inserted + * + * Since: 3.0 + **/ guint gtk_widget_path_append_type (GtkWidgetPath *path, GType type) @@ -149,6 +265,18 @@ gtk_widget_path_append_type (GtkWidgetPath *path, return path->elems->len - 1; } +/** + * gtk_widget_path_iter_get_widget_type: + * @path: a #GtkWidgetPath + * @pos: position to get the widget type for + * + * Returns the widget #GType that is at position @pos in the widget + * hierarchy defined in @path. + * + * Returns: a widget type + * + * Since: 3.0 + **/ GType gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, guint pos) @@ -162,6 +290,17 @@ gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, return elem->type; } +/** + * gtk_widget_path_iter_set_widget_type: + * @path: a #GtkWidgetPath + * @pos: position to modify + * @type: widget type to set + * + * Sets the widget type for a given position in the widget hierarchy + * defined by @path. @type must be a #GtkWidget derived #GType. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, guint pos, @@ -177,6 +316,17 @@ gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, elem->type = type; } +/** + * gtk_widget_path_iter_get_name: + * @path: a #GtkWidgetPath + * @pos: position to get the widget name for + * + * Returns the name corresponding to the widget found at + * the position @pos in the widget hierarchy defined by + * @path + * + * Returns: The widget name, or %NULL if none was set. + **/ G_CONST_RETURN gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path, guint pos) @@ -190,6 +340,17 @@ gtk_widget_path_iter_get_name (const GtkWidgetPath *path, return g_quark_to_string (elem->name); } +/** + * gtk_widget_path_iter_set_name: + * @path: a #GtkWidgetPath + * @pos: position to modify + * @name: widget name + * + * Sets the widget name for the widget found at position @pos + * in the widget hierarchy defined by @path. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_set_name (GtkWidgetPath *path, guint pos, @@ -206,6 +367,19 @@ gtk_widget_path_iter_set_name (GtkWidgetPath *path, elem->name = g_quark_from_string (name); } +/** + * gtk_widget_path_iter_has_qname: + * @path: a #GtkWidgetPath + * @pos: position to query + * @qname: widget name as a #GQuark + * + * See gtk_widget_path_iter_has_name(). This is a version + * that operates on #GQuarks. + * + * Returns: %TRUE if the widget at @pos has this name + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path, guint pos, @@ -222,6 +396,19 @@ gtk_widget_path_iter_has_qname (const GtkWidgetPath *path, return (elem->name == qname); } +/** + * gtk_widget_path_iter_has_name: + * @path: a #GtkWidgetPath + * @pos: position to query + * @name: a widget name + * + * Returns %TRUE if the widget at position @pos has the name @name, + * %FALSE otherwise. + * + * Returns: %TRUE if the widget at @pos has this name + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_name (const GtkWidgetPath *path, guint pos, @@ -241,6 +428,18 @@ gtk_widget_path_iter_has_name (const GtkWidgetPath *path, return gtk_widget_path_iter_has_qname (path, pos, qname); } +/** + * gtk_widget_path_iter_add_class: + * @path: a #GtkWidget + * @pos: position to modify + * @name: a class name + * + * Adds the class @name to the widget at position @pos in + * the hierarchy defined in @path. See + * gtk_style_context_set_class(). + * + * Since: 3.0 + **/ void gtk_widget_path_iter_add_class (GtkWidgetPath *path, guint pos, @@ -285,6 +484,17 @@ gtk_widget_path_iter_add_class (GtkWidgetPath *path, g_array_append_val (elem->classes, qname); } +/** + * gtk_widget_path_iter_remove_class: + * @path: a #GtkWidgetPath + * @pos: position to modify + * @name: class name + * + * Removes the class @name from the widget at position @pos in + * the hierarchy defined in @path. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_remove_class (GtkWidgetPath *path, guint pos, @@ -324,6 +534,16 @@ gtk_widget_path_iter_remove_class (GtkWidgetPath *path, } } +/** + * gtk_widget_path_iter_clear_classes: + * @path: a #GtkWidget + * @pos: position to modify + * + * Removes all classes from the widget at position @pos in the + * hierarchy defined in @path. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_clear_classes (GtkWidgetPath *path, guint pos) @@ -342,6 +562,21 @@ gtk_widget_path_iter_clear_classes (GtkWidgetPath *path, g_array_remove_range (elem->classes, 0, elem->classes->len); } +/** + * gtk_widget_path_iter_list_classes: + * @path: a #GtkWidgetPath + * @pos: position to query + * + * Returns a list with all the class names defined for the widget + * at position @pos in the hierarchy defined in @path. + * + * Returns: (transfer container) (type utf8): The list of classes, + * This is a list of strings, the #GSList contents are + * owned by GTK+, but you should use g_slist_free() to + * free the list itself. + * + * Since: 3.0 + **/ GSList * gtk_widget_path_iter_list_classes (const GtkWidgetPath *path, guint pos) @@ -369,6 +604,19 @@ gtk_widget_path_iter_list_classes (const GtkWidgetPath *path, return g_slist_reverse (list); } +/** + * gtk_widget_path_iter_has_qclass: + * @path: a #GtkWidgetPath + * @pos: position to query + * @qname: class name as a #GQuark + * + * See gtk_widget_path_iter_has_class(). This is a version that operates + * with GQuarks. + * + * Returns: %TRUE if the widget at @pos has the class defined. + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path, guint pos, @@ -401,6 +649,19 @@ gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path, return FALSE; } +/** + * gtk_widget_path_iter_has_class: + * @path: a #GtkWidgetPath + * @pos: position to query + * @name: class name + * + * Returns %TRUE if the widget at position @pos has the class @name + * defined, %FALSE otherwise. + * + * Returns: %TRUE if the class @name is defined for the widget at @pos + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_class (const GtkWidgetPath *path, guint pos, @@ -420,6 +681,19 @@ gtk_widget_path_iter_has_class (const GtkWidgetPath *path, return gtk_widget_path_iter_has_qclass (path, pos, qname); } +/** + * gtk_widget_path_iter_add_region: + * @path: a #GtkWidgetPath + * @pos: position to modify + * @name: region name + * @flags: flags affecting the region + * + * Adds the region @name to the widget at position @pos in + * the hierarchy defined in @path. See + * gtk_style_context_set_region(). + * + * Since: 3.0 + **/ void gtk_widget_path_iter_add_region (GtkWidgetPath *path, guint pos, @@ -444,6 +718,17 @@ gtk_widget_path_iter_add_region (GtkWidgetPath *path, GUINT_TO_POINTER (flags)); } +/** + * gtk_widget_path_iter_remove_region: + * @path: a #GtkWidgetPath + * @pos: position to modify + * @name: region name + * + * Removes the region @name from the widget at position @pos in + * the hierarchy defined in @path. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, guint pos, @@ -467,6 +752,16 @@ gtk_widget_path_iter_remove_region (GtkWidgetPath *path, g_hash_table_remove (elem->regions, GUINT_TO_POINTER (qname)); } +/** + * gtk_widget_path_iter_clear_regions: + * @path: a #GtkWidgetPath + * @pos: position to modify + * + * Removes all regions from the widget at position @pos in the + * hierarchy defined in @path. + * + * Since: 3.0 + **/ void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, guint pos) @@ -482,6 +777,21 @@ gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, g_hash_table_remove_all (elem->regions); } +/** + * gtk_widget_path_iter_list_regions: + * @path: a #GtkWidgetPath + * @pos: position to query + * + * Returns a list with all the region names defined for the widget + * at position @pos in the hierarchy defined in @path. + * + * Returns: (transfer container) (type utf8): The list of regions, + * This is a list of strings, the #GSList contents are + * owned by GTK+, but you should use g_slist_free() to + * free the list itself. + * + * Since: 3.0 + **/ GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, guint pos) @@ -512,6 +822,20 @@ gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, return list; } +/** + * gtk_widget_path_iter_has_qregion: + * @path: a #GtkWidgetPath + * @pos: position to query + * @qname: region name as a #GQuark + * @flags: (out): return location for the region flags + * + * See gtk_widget_path_iter_has_region(). This is a version that operates + * with GQuarks. + * + * Returns: %TRUE if the widget at @pos has the region defined. + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, guint pos, @@ -541,6 +865,20 @@ gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, return TRUE; } +/** + * gtk_widget_path_iter_has_region: + * @path: a #GtkWidgetPath + * @pos: position to query + * @name: region name + * @flags: (out): return location for the region flags + * + * Returns %TRUE if the widget at position @pos has the class @name + * defined, %FALSE otherwise. + * + * Returns: %TRUE if the class @name is defined for the widget at @pos + * + * Since: 3.0 + **/ gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, guint pos, @@ -561,6 +899,17 @@ gtk_widget_path_iter_has_region (const GtkWidgetPath *path, return gtk_widget_path_iter_has_qregion (path, pos, qname, flags); } +/** + * gtk_widget_path_get_widget_type: + * @path: a #GtkWidget + * + * Returns the topmost widget type, that is, the widget type this path + * is representing. + * + * Returns: The widget type + * + * Since: 3.0 + **/ GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path) { @@ -568,10 +917,23 @@ gtk_widget_path_get_widget_type (const GtkWidgetPath *path) g_return_val_if_fail (path != NULL, G_TYPE_INVALID); - elem = &g_array_index (path->elems, GtkPathElement, 0); + elem = &g_array_index (path->elems, GtkPathElement, + path->elems->len - 1); return elem->type; } +/** + * gtk_widget_path_is_type: + * @path: a #GtkWidgetPath + * @type: widget type to match + * + * Returns %TRUE if the widget type represented by this path + * is @type, or a subtype of it. + * + * Returns: %TRUE if the widget represented by @path is of type @type + * + * Since: 3.0 + **/ gboolean gtk_widget_path_is_type (const GtkWidgetPath *path, GType type) @@ -581,7 +943,8 @@ gtk_widget_path_is_type (const GtkWidgetPath *path, g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); - elem = &g_array_index (path->elems, GtkPathElement, 0); + elem = &g_array_index (path->elems, GtkPathElement, + path->elems->len - 1); if (elem->type == type || g_type_is_a (elem->type, type)) @@ -590,6 +953,18 @@ gtk_widget_path_is_type (const GtkWidgetPath *path, return FALSE; } +/** + * gtk_widget_path_has_parent: + * @path: a #GtkWidgetPath + * @type: widget type to check in parents + * + * Returns %TRUE if any of the parents of the widget represented + * in @path is of type @type, or any subtype of it. + * + * Returns: %TRUE if any parent is of type @type + * + * Since: 3.0 + **/ gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type) @@ -599,7 +974,7 @@ gtk_widget_path_has_parent (const GtkWidgetPath *path, g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); - for (i = 1; i < path->elems->len; i++) + for (i = 0; i < path->elems->len - 1; i++) { GtkPathElement *elem; diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 4e5c4769cb..f36ebcb830 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -25,7 +25,7 @@ G_BEGIN_DECLS -typedef struct GtkWidgetPath GtkWidgetPath; +typedef struct _GtkWidgetPath GtkWidgetPath; GtkWidgetPath * gtk_widget_path_new (void); From 96c16e246c5bdb5d5ad7ecbace254b94fb109ebe Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 11:29:18 +0200 Subject: [PATCH 337/634] GtkStyleContext: Actually store region ID when starting an animation. --- gtk/gtkstylecontext.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 3a0407405c..7fdce6db06 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -582,6 +582,7 @@ timeline_finished_cb (GtkTimeline *timeline, static AnimationInfo * animation_info_new (GtkStyleContext *context, + gpointer region_id, gdouble duration, GtkTimelineProgressType progress_type, GtkStateType state, @@ -597,6 +598,7 @@ animation_info_new (GtkStyleContext *context, info->window = g_object_ref (window); info->state = state; info->target_value = target_value; + info->region_id = region_id; gtk_timeline_set_progress_type (info->timeline, progress_type); @@ -2515,7 +2517,7 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, } else { - info = animation_info_new (context, + info = animation_info_new (context, region_id, gtk_animation_description_get_duration (desc), gtk_animation_description_get_progress_type (desc), state, state_value, window); From 68bfb94f6962ae9f98b0f73c2536c1f2501b9ea0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 12:09:23 +0200 Subject: [PATCH 338/634] Change semantics of the methods to check whether an animation is running. It actually messed up with the state being actually set, and having a transition animation running for it. Now this dichotomy is removed, and gtk_style_context_state_is_running() only checks whether an animation is running, leaving state checking to flags & GTK_STATE_FLAG_*. --- docs/reference/gtk/gtk3-sections.txt | 4 +- gtk/gtkstylecontext.c | 77 ++++++++++++---------------- gtk/gtkstylecontext.h | 25 ++------- gtk/gtkthemingengine.c | 54 +++++++++++++------ gtk/gtkthemingengine.h | 8 +-- 5 files changed, 81 insertions(+), 87 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 0406de2c19..ffc77f6194 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5382,7 +5382,7 @@ gtk_style_context_get_valist gtk_style_context_has_class gtk_style_context_has_region gtk_style_context_invalidate -gtk_style_context_is_state_set +gtk_style_context_state_is_running gtk_style_context_list_classes gtk_style_context_list_regions gtk_style_context_lookup_color @@ -5474,7 +5474,7 @@ gtk_theming_engine_get_style_valist gtk_theming_engine_get_valist gtk_theming_engine_has_class gtk_theming_engine_has_region -gtk_theming_engine_is_state_set +gtk_theming_engine_state_is_running gtk_theming_engine_load gtk_theming_engine_register_property diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 7fdce6db06..b571d86f7c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1304,66 +1304,53 @@ context_has_animatable_region (GtkStyleContext *context, return FALSE; } +/** + * gtk_style_context_state_is_running: + * @context: a #GtkStyleContext + * @state: a widget state + * @progress: (out): return location for the transition progress + * + * Returns %TRUE if there is a transition animation running for the + * current region (see gtk_style_context_push_animatable_region()). + * + * If @progress is not %NULL, the animation progress will be returned + * there, 0.0 means the state is closest to being %FALSE, while 1.0 means + * it's closest to being %TRUE. This means transition animations will + * run from 0 to 1 when @state is being set to %TRUE and from 1 to 0 when + * it's being set to %FALSE. + * + * Returns: %TRUE if there is a running transition animation for @state. + * + * Since: 3.0 + **/ gboolean -gtk_style_context_is_state_set (GtkStyleContext *context, - GtkStateType state, - gdouble *progress) +gtk_style_context_state_is_running (GtkStyleContext *context, + GtkStateType state, + gdouble *progress) { GtkStyleContextPrivate *priv; - gboolean state_set; + AnimationInfo *info; + GSList *l; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); priv = context->priv; - switch (state) + for (l = priv->animations; l; l = l->next) { - case GTK_STATE_NORMAL: - state_set = (priv->state_flags == 0); - break; - case GTK_STATE_ACTIVE: - state_set = (priv->state_flags & GTK_STATE_FLAG_ACTIVE); - break; - case GTK_STATE_PRELIGHT: - state_set = (priv->state_flags & GTK_STATE_FLAG_PRELIGHT); - break; - case GTK_STATE_SELECTED: - state_set = (priv->state_flags & GTK_STATE_FLAG_SELECTED); - break; - case GTK_STATE_INSENSITIVE: - state_set = (priv->state_flags & GTK_STATE_FLAG_INSENSITIVE); - break; - case GTK_STATE_INCONSISTENT: - state_set = (priv->state_flags & GTK_STATE_FLAG_INCONSISTENT); - break; - case GTK_STATE_FOCUSED: - state_set = (priv->state_flags & GTK_STATE_FLAG_FOCUSED); - break; - default: - g_assert_not_reached (); - } + info = l->data; - if (progress) - { - AnimationInfo *info; - GSList *l; - - *progress = (state_set) ? 1 : 0; - - for (l = priv->animations; l; l = l->next) + if (info->state == state && + context_has_animatable_region (context, info->region_id)) { - info = l->data; + if (progress) + *progress = gtk_timeline_get_progress (info->timeline); - if (info->state == state && - context_has_animatable_region (context, info->region_id)) - { - *progress = gtk_timeline_get_progress (info->timeline); - break; - } + return TRUE; } } - return state_set; + return FALSE; } /** diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a9843f352e..ad1a2ffeb0 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -82,9 +82,9 @@ void gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags flags); GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); -gboolean gtk_style_context_is_state_set (GtkStyleContext *context, - GtkStateType state, - gdouble *progress); +gboolean gtk_style_context_state_is_running (GtkStyleContext *context, + GtkStateType state, + gdouble *progress); void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); @@ -146,6 +146,8 @@ void gtk_style_context_push_animatable_region (GtkStyleContext *context, gpointer region_id); void gtk_style_context_pop_animatable_region (GtkStyleContext *context); +void gtk_style_context_invalidate (GtkStyleContext *context); +void gtk_style_context_reset_widgets (GdkScreen *screen); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, @@ -156,23 +158,6 @@ void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *c gint rel_x, gint rel_y); -/* Animation for state changes */ -void gtk_style_context_state_transition_start (GtkStyleContext *context, - gpointer identifier, - GtkWidget *widget, - GtkStateType state, - gboolean value, - GdkRectangle *rect); -void gtk_style_context_state_transition_update (GtkStyleContext *context, - gpointer identifier, - GdkRectangle *rect, - GtkStateType state); -void gtk_style_context_state_transition_stop (GtkStyleContext *context, - gpointer identifier); - -void gtk_style_context_invalidate (GtkStyleContext *context); -void gtk_style_context_reset_widgets (GdkScreen *screen); - /* Paint methods */ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f72e6a6686..0f035c0979 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -445,17 +445,36 @@ gtk_theming_engine_get_state (GtkThemingEngine *engine) return gtk_style_context_get_state (priv->context); } +/** + * gtk_theming_engine_state_is_running: + * @engine: a #GtkThemingEngine + * @state: a widget state + * @progress: (out): return location for the transition progress + * + * Returns %TRUE if there is a transition animation running for the + * current region (see gtk_style_context_push_animatable_region()). + * + * If @progress is not %NULL, the animation progress will be returned + * there, 0.0 means the state is closest to being %FALSE, while 1.0 means + * it's closest to being %TRUE. This means transition animations will + * run from 0 to 1 when @state is being set to %TRUE and from 1 to 0 when + * it's being set to %FALSE. + * + * Returns: %TRUE if there is a running transition animation for @state. + * + * Since: 3.0 + **/ gboolean -gtk_theming_engine_is_state_set (GtkThemingEngine *engine, - GtkStateType state, - gdouble *progress) +gtk_theming_engine_state_is_running (GtkThemingEngine *engine, + GtkStateType state, + gdouble *progress) { GtkThemingEnginePrivate *priv; - g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0); + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); priv = engine->priv; - return gtk_style_context_is_state_set (priv->context, state, progress); + return gtk_style_context_state_is_running (priv->context, state, progress); } /** @@ -766,7 +785,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, else gdk_cairo_set_source_color (cr, text_color); - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT, NULL)) + if (flags & GTK_STATE_FLAG_INCONSISTENT) { int line_thickness = MAX (1, (3 + interior_size * 2) / 7); @@ -780,12 +799,15 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, else { gdouble progress; - gboolean active; + gboolean running; - active = gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, &progress); + running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress); - if (active || progress > 0) + if ((flags & GTK_STATE_FLAG_ACTIVE) || running) { + if (!running) + progress = 1; + cairo_translate (cr, x + pad, y + pad); @@ -887,7 +909,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, /* FIXME: thickness */ thickness = 1; - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT, NULL)) + if (flags & GTK_STATE_FLAG_INCONSISTENT) { gint line_thickness; @@ -909,7 +931,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, line_thickness); cairo_fill (cr); } - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE, NULL)) + if (flags & GTK_STATE_FLAG_ACTIVE) { pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9); interior_size = MAX (1, exterior_size - 2 * pad); @@ -1100,7 +1122,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, GdkColor *bg_color, *base_color; cairo_pattern_t *pattern; GtkStateFlags flags; - gboolean prelight; + gboolean running; gdouble progress, alpha = 1; flags = gtk_theming_engine_get_state (engine); @@ -1121,19 +1143,19 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, "base-color", &base_color, NULL); - prelight = gtk_theming_engine_is_state_set (engine, GTK_STATE_PRELIGHT, &progress); + running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); cairo_translate (cr, x, y); cairo_scale (cr, width, height); - if (prelight || progress > 0 ) + if (running) { cairo_pattern_t *other_pattern; GtkStateFlags other_flags; GdkColor *other_bg, *other_base; cairo_pattern_t *new_pattern = NULL; - if (prelight) + if (flags & GTK_STATE_FLAG_PRELIGHT) { other_flags = flags & ~(GTK_STATE_FLAG_PRELIGHT); progress = 1 - progress; @@ -1833,7 +1855,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, else cairo_translate (cr, x, y); - if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INSENSITIVE, NULL)) + if (flags & GTK_STATE_FLAG_INSENSITIVE) { cairo_save (cr); cairo_set_source_rgb (cr, 1, 1, 1); diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 6ecf9c1009..9cbae78cf6 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -192,10 +192,10 @@ gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine, const gchar *style_class, GtkRegionFlags *flags); -GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); -gboolean gtk_theming_engine_is_state_set (GtkThemingEngine *engine, - GtkStateType state, - gdouble *progress); +GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); +gboolean gtk_theming_engine_state_is_running (GtkThemingEngine *engine, + GtkStateType state, + gdouble *progress); GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); From 4a9890e3ab133dd0ce9b727cecf014f1dd3d0866 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 12:59:19 +0200 Subject: [PATCH 339/634] GtkCssProvider: Parse missing widget states. --- gtk/gtkcssprovider.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 83f9cad5a3..1a1c4b2fb2 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -689,6 +689,8 @@ create_scanner (void) g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "hover", GUINT_TO_POINTER (GTK_STATE_PRELIGHT)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "selected", GUINT_TO_POINTER (GTK_STATE_SELECTED)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "insensitive", GUINT_TO_POINTER (GTK_STATE_INSENSITIVE)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "inconsistent", GUINT_TO_POINTER (GTK_STATE_INCONSISTENT)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "focused", GUINT_TO_POINTER (GTK_STATE_FOCUSED)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "nth-child", GUINT_TO_POINTER (SYMBOL_NTH_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "first-child", GUINT_TO_POINTER (SYMBOL_FIRST_CHILD)); From c2f47063c31321212790e692215790dac8b0f01a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 13:00:07 +0200 Subject: [PATCH 340/634] GtkCssProvider: Parse default/sorted region flags. --- gtk/gtkcssprovider.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 1a1c4b2fb2..e70ee14b7f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -469,6 +469,8 @@ enum ParserSymbol { SYMBOL_NTH_CHILD = GTK_STATE_LAST, SYMBOL_FIRST_CHILD, SYMBOL_LAST_CHILD, + SYMBOL_DEFAULT_CHILD, + SYMBOL_SORTED_CHILD, /* Scope: nth-child */ SYMBOL_NTH_CHILD_EVEN, @@ -695,6 +697,8 @@ create_scanner (void) g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "nth-child", GUINT_TO_POINTER (SYMBOL_NTH_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "first-child", GUINT_TO_POINTER (SYMBOL_FIRST_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "last-child", GUINT_TO_POINTER (SYMBOL_LAST_CHILD)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "default", GUINT_TO_POINTER (SYMBOL_DEFAULT_CHILD)); + g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "sorted", GUINT_TO_POINTER (SYMBOL_SORTED_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "even", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_EVEN)); g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "odd", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_ODD)); @@ -1307,6 +1311,10 @@ parse_nth_child (GtkCssProvider *css_provider, *flags = GTK_REGION_FIRST; else if (symbol == SYMBOL_LAST_CHILD) *flags = GTK_REGION_LAST; + else if (symbol == SYMBOL_DEFAULT_CHILD) + *flags = GTK_REGION_DEFAULT; + else if (symbol == SYMBOL_SORTED_CHILD) + *flags = GTK_REGION_SORTED; else { *flags = 0; @@ -1453,7 +1461,9 @@ parse_selector (GtkCssProvider *css_provider, if (symbol == SYMBOL_FIRST_CHILD || symbol == SYMBOL_LAST_CHILD || - symbol == SYMBOL_NTH_CHILD) + symbol == SYMBOL_NTH_CHILD || + symbol == SYMBOL_DEFAULT_CHILD || + symbol == SYMBOL_SORTED_CHILD) { GTokenType token; From d0f681e898d0ddb6a34776ea11c42be5cac63097 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Oct 2010 18:42:00 +0200 Subject: [PATCH 341/634] GtkStyleContext: Add gtk_style_context_new(). --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtkstylecontext.c | 23 ++++++++++++++++++ gtk/gtkstylecontext.h | 35 +++++++++++++++++++++------- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index ffc77f6194..d854ff5b50 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5366,6 +5366,7 @@ gtk_style_set_get_type gtkstylecontext GtkStyleContext GtkStyleContext +gtk_style_context_new gtk_style_context_add_provider gtk_style_context_add_provider_for_screen gtk_style_context_get diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index b571d86f7c..f0456a4d4c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -984,6 +984,29 @@ style_provider_remove (GList **list, return FALSE; } +/** + * gtk_style_context_new: + * + * Creates a standalone #GtkStyleContext, this style context + * won't be attached to any widget nor screen, so you may want + * to call gtk_style_context_set_path() and + * gtk_style_context_set_screen() yourself. + * + * + * This function is only useful when using the theming layer + * separated from GTK+, if you are using #GtkStyleContext to + * theme #GtkWidgets, use gtk_widget_get_style_context() + * in order to get a style context ready to theme the widget. + * + * + * Returns: A newly created #GtkStyleContext. + **/ +GtkStyleContext * +gtk_style_context_new (void) +{ + return g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL); +} + /** * gtk_style_context_add_provider: * @context: a #GtkStyleContext diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index ad1a2ffeb0..ce5fc0d06b 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -33,16 +33,16 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT)) #define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass)) -typedef struct _GtkStyleContext GtkStyleContext; -typedef struct _GtkStyleContextClass GtkStyleContextClass; +typedef struct GtkStyleContext GtkStyleContext; +typedef struct GtkStyleContextClass GtkStyleContextClass; -struct _GtkStyleContext +struct GtkStyleContext { GObject parent_object; gpointer priv; }; -struct _GtkStyleContextClass +struct GtkStyleContextClass { GObjectClass parent_class; @@ -51,6 +51,8 @@ struct _GtkStyleContextClass GType gtk_style_context_get_type (void) G_GNUC_CONST; +GtkStyleContext * gtk_style_context_new (void); + void gtk_style_context_add_provider_for_screen (GdkScreen *screen, GtkStyleProvider *provider, guint priority); @@ -82,9 +84,9 @@ void gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags flags); GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); -gboolean gtk_style_context_state_is_running (GtkStyleContext *context, - GtkStateType state, - gdouble *progress); +gboolean gtk_style_context_is_state_set (GtkStyleContext *context, + GtkStateType state, + gdouble *progress); void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); @@ -146,8 +148,6 @@ void gtk_style_context_push_animatable_region (GtkStyleContext *context, gpointer region_id); void gtk_style_context_pop_animatable_region (GtkStyleContext *context); -void gtk_style_context_invalidate (GtkStyleContext *context); -void gtk_style_context_reset_widgets (GdkScreen *screen); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, @@ -158,6 +158,23 @@ void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *c gint rel_x, gint rel_y); +/* Animation for state changes */ +void gtk_style_context_state_transition_start (GtkStyleContext *context, + gpointer identifier, + GtkWidget *widget, + GtkStateType state, + gboolean value, + GdkRectangle *rect); +void gtk_style_context_state_transition_update (GtkStyleContext *context, + gpointer identifier, + GdkRectangle *rect, + GtkStateType state); +void gtk_style_context_state_transition_stop (GtkStyleContext *context, + gpointer identifier); + +void gtk_style_context_invalidate (GtkStyleContext *context); +void gtk_style_context_reset_widgets (GdkScreen *screen); + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, From 35a41bd801bf121c2f0b7bc0287b7844daa3facb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 Oct 2010 13:26:27 +0200 Subject: [PATCH 342/634] Make loading of theming engines from modules work --- gtk/gtkthemingengine.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 0f035c0979..99518f8fb5 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -154,8 +154,11 @@ typedef struct GtkThemingModuleClass GtkThemingModuleClass; struct GtkThemingModule { GTypeModule parent_instance; + GModule *module; gchar *name; + void (*init) (GTypeModule *module); + void (*exit) (void); GtkThemingEngine * (*create_engine) (void); }; @@ -622,26 +625,50 @@ gtk_theming_module_load (GTypeModule *type_module) return FALSE; } - if (!g_module_symbol (module, "create_engine", + if (!g_module_symbol (module, "theme_init", + (gpointer *) &theming_module->init) || + !g_module_symbol (module, "theme_exit", + (gpointer *) &theming_module->exit) || + !g_module_symbol (module, "create_engine", (gpointer *) &theming_module->create_engine)) { - g_warning ("%s", g_module_error()); + g_warning ("%s", g_module_error ()); g_module_close (module); return FALSE; } - g_module_make_resident (module); + theming_module->module = module; + + theming_module->init (theming_module); return TRUE; } +static void +gtk_theming_module_unload (GTypeModule *type_module) +{ + GtkThemingModule *theming_module; + + theming_module = GTK_THEMING_MODULE (type_module); + + theming_module->exit (); + + g_module_close (theming_module->module); + + theming_module->module = NULL; + theming_module->init = NULL; + theming_module->exit = NULL; + theming_module->create_engine = NULL; +} + static void gtk_theming_module_class_init (GtkThemingModuleClass *klass) { GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass); module_class->load = gtk_theming_module_load; + module_class->unload = gtk_theming_module_unload; } static void From d03caa4683397825417412d83570cd2ebf144177 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 17:37:00 +0200 Subject: [PATCH 343/634] GtkCssProvider: Run through the widget path in the correct order. Comparing a selector with a widget path was being done backwards since the change to use GtkContainer::get_path_for_child(). --- gtk/gtkcssprovider.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index e70ee14b7f..001b062f31 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -848,12 +848,11 @@ compare_selector (GtkWidgetPath *path, GSList *elements = selector->elements; gboolean match = TRUE; guint64 score = 0; - guint len; - guint i = 0; + gint i; - len = gtk_widget_path_length (path); + i = gtk_widget_path_length (path) - 1; - while (elements && match && i < len) + while (elements && match && i >= 0) { SelectorElement *elem; guint8 elem_score; @@ -874,7 +873,7 @@ compare_selector (GtkWidgetPath *path, if (!match || (elem->elem_type == SELECTOR_GTYPE || elem->elem_type == SELECTOR_GLOB)) - i++; + i--; if (!match && elem->elem_type != SELECTOR_TYPE_NAME && From 0a0a1a20a7080171154ac8ae349c159967273415 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 18:04:39 +0200 Subject: [PATCH 344/634] GtkCssProvider: Make it able to parse enums. --- gtk/gtkcssprovider.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 001b062f31..045bd64bc4 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2314,6 +2314,17 @@ css_provider_parse_value (GtkCssProvider *css_provider, else parsed = FALSE; } + else if (G_TYPE_IS_ENUM (type)) + { + GEnumClass *class; + GEnumValue *enum_value; + + class = g_type_class_ref (type); + enum_value = g_enum_get_value_by_nick (class, value_str); + + g_value_set_enum (value, enum_value->value); + g_type_class_unref (class); + } else if (type == GTK_TYPE_9SLICE) { Gtk9Slice *slice; From 32b50f294814a97a453315839fe5109e278302b0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 18:05:15 +0200 Subject: [PATCH 345/634] GtkStyleContext: Update function declaration in header. --- gtk/gtkstylecontext.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index ce5fc0d06b..592d0e8c4a 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -84,9 +84,9 @@ void gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags flags); GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context); -gboolean gtk_style_context_is_state_set (GtkStyleContext *context, - GtkStateType state, - gdouble *progress); +gboolean gtk_style_context_state_is_running (GtkStyleContext *context, + GtkStateType state, + gdouble *progress); void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); From f7dd4238626bbbb453edc7170d661731e4948534 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 18:44:48 +0200 Subject: [PATCH 346/634] GtkStyleSet: Register the "border-radius" property --- gtk/gtkstyleset.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 24641621ad..9aa5519ec7 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -89,7 +89,9 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("margin", GTK_TYPE_BORDER, NULL, NULL); gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); - gtk_style_set_register_property ("border", G_TYPE_INT, NULL, NULL); + + gtk_style_set_register_property ("border-width", G_TYPE_INT, NULL, NULL); + gtk_style_set_register_property ("border-radius", G_TYPE_INT, NULL, NULL); gtk_style_set_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); From 161d5175e1532145d3f9c84cba4d1bdb0c2b7ee3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 18:47:28 +0200 Subject: [PATCH 347/634] GtkThemingEngine: Honor border-radius in render_background(). --- gtk/gtkthemingengine.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 99518f8fb5..f91f1c323a 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1138,6 +1138,29 @@ color_shade (const GdkColor *color, color_return->blue = CLAMP (color->blue * factor, 0, 65535); } +static void +_cairo_round_rectangle (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + radius = CLAMP (radius, 0, MIN (width / 2, height / 2)); + + if (radius == 0) + cairo_rectangle (cr, x, y, width, height); + else + { + cairo_new_sub_path (cr); + cairo_arc (cr, x + width - radius, y + radius, radius, - G_PI / 2, 0); + cairo_arc (cr, x + width - radius, y + height - radius, radius, 0, G_PI / 2); + cairo_arc (cr, x + radius, y + height - radius, radius, G_PI / 2, G_PI); + cairo_arc (cr, x + radius, y + radius, radius, G_PI, 3 * (G_PI / 2)); + cairo_close_path (cr); + } +} + static void gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_t *cr, @@ -1151,6 +1174,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, GtkStateFlags flags; gboolean running; gdouble progress, alpha = 1; + gint radius; flags = gtk_theming_engine_get_state (engine); cairo_save (cr); @@ -1168,10 +1192,14 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, "background-image", &pattern, "background-color", &bg_color, "base-color", &base_color, + "border-radius", &radius, NULL); running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); + _cairo_round_rectangle (cr, (gdouble) radius, x, y, width, height); + cairo_clip (cr); + cairo_translate (cr, x, y); cairo_scale (cr, width, height); @@ -1268,7 +1296,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, */ cairo_rectangle (cr, 0, 0, 1, 1); cairo_set_source (cr, other_pattern); - cairo_fill (cr); + cairo_fill_preserve (cr); /* Set alpha for posterior drawing * of the target pattern From c9a3da5025a40ce8b41a67f40666a9dddf4d49fa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 19:02:41 +0200 Subject: [PATCH 348/634] GtkStyleContext: s/set/add/ and s/unset/remove/ for classes/regions. Several classes and regions may be set to GtkStyleContext, so rename the functions to be more intuitive. --- docs/reference/gtk/gtk3-sections.txt | 16 ++++---- gtk/gtknotebook.c | 4 +- gtk/gtkstyle.c | 60 ++++++++++++++-------------- gtk/gtkstylecontext.c | 24 +++++------ gtk/gtkstylecontext.h | 28 ++++++------- gtk/gtkwidgetpath.c | 4 +- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index d854ff5b50..2da137cf31 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5380,12 +5380,8 @@ gtk_style_context_get_style gtk_style_context_get_style_property gtk_style_context_get_style_valist gtk_style_context_get_valist -gtk_style_context_has_class -gtk_style_context_has_region gtk_style_context_invalidate gtk_style_context_state_is_running -gtk_style_context_list_classes -gtk_style_context_list_regions gtk_style_context_lookup_color gtk_style_context_lookup_icon_set gtk_style_context_notify_state_change @@ -5396,18 +5392,22 @@ gtk_style_context_remove_provider_for_screen gtk_style_context_reset_widgets gtk_style_context_restore gtk_style_context_save -gtk_style_context_set_class gtk_style_context_set_direction gtk_style_context_set_junction_sides gtk_style_context_set_path -gtk_style_context_set_region +gtk_style_context_add_class +gtk_style_context_remove_class +gtk_style_context_has_class +gtk_style_context_list_classes +gtk_style_context_add_region +gtk_style_context_remove_region +gtk_style_context_has_region +gtk_style_context_list_regions gtk_style_context_set_screen gtk_style_context_set_state gtk_style_context_state_transition_start gtk_style_context_state_transition_stop gtk_style_context_state_transition_update -gtk_style_context_unset_class -gtk_style_context_unset_region gtk_render_arrow diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 3ce43ee9ab..708a8d0fff 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -5068,7 +5068,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, flags |= GTK_REGION_LAST; context = gtk_widget_get_style_context (widget); - gtk_style_context_set_region (context, "tab", flags); + gtk_style_context_add_region (context, "tab", flags); gtk_paint_extension (gtk_widget_get_style (widget), cr, state_type, GTK_SHADOW_OUT, @@ -5096,7 +5096,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, allocation.height + 2 * focus_width); } - gtk_style_context_unset_region (context, "tab"); + gtk_style_context_remove_region (context, "tab"); } static void diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 44c3ed9731..38390c072f 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1740,69 +1740,69 @@ transform_detail_string (const gchar *detail, return; if (strcmp (detail, "arrow") == 0) - gtk_style_context_set_class (context, "arrow"); + gtk_style_context_add_class (context, "arrow"); else if (strcmp (detail, "button") == 0) - gtk_style_context_set_class (context, "button"); + gtk_style_context_add_class (context, "button"); else if (strcmp (detail, "buttondefault") == 0) { - gtk_style_context_set_class (context, "button"); - gtk_style_context_set_class (context, "default"); + gtk_style_context_add_class (context, "button"); + gtk_style_context_add_class (context, "default"); } else if (strcmp (detail, "calendar") == 0) - gtk_style_context_set_class (context, "calendar"); + gtk_style_context_add_class (context, "calendar"); else if (strcmp (detail, "cellcheck") == 0) { - gtk_style_context_set_class (context, "cell"); - gtk_style_context_set_class (context, "check"); + gtk_style_context_add_class (context, "cell"); + gtk_style_context_add_class (context, "check"); } else if (strcmp (detail, "cellradio") == 0) { - gtk_style_context_set_class (context, "cell"); - gtk_style_context_set_class (context, "radio"); + gtk_style_context_add_class (context, "cell"); + gtk_style_context_add_class (context, "radio"); } else if (strcmp (detail, "checkbutton") == 0) - gtk_style_context_set_class (context, "check"); + gtk_style_context_add_class (context, "check"); else if (strcmp (detail, "check") == 0) { - gtk_style_context_set_class (context, "check"); - gtk_style_context_set_class (context, "menu"); + gtk_style_context_add_class (context, "check"); + gtk_style_context_add_class (context, "menu"); } else if (strcmp (detail, "option") == 0) { - gtk_style_context_set_class (context, "radio"); - gtk_style_context_set_class (context, "menu"); + gtk_style_context_add_class (context, "radio"); + gtk_style_context_add_class (context, "menu"); } else if (strcmp (detail, "entry") == 0 || strcmp (detail, "entry_bg") == 0) - gtk_style_context_set_class (context, "entry"); + gtk_style_context_add_class (context, "entry"); else if (strcmp (detail, "expander") == 0) - gtk_style_context_set_class (context, "expander"); + gtk_style_context_add_class (context, "expander"); else if (strcmp (detail, "tooltip") == 0) - gtk_style_context_set_class (context, "tooltip"); + gtk_style_context_add_class (context, "tooltip"); else if (strcmp (detail, "frame") == 0) - gtk_style_context_set_class (context, "frame"); + gtk_style_context_add_class (context, "frame"); else if (strcmp (detail, "scrolled_window") == 0) - gtk_style_context_set_class (context, "scrolled-window"); + gtk_style_context_add_class (context, "scrolled-window"); else if (strcmp (detail, "viewport") == 0 || strcmp (detail, "viewportbin") == 0) - gtk_style_context_set_class (context, "viewport"); + gtk_style_context_add_class (context, "viewport"); else if (strcmp (detail, "trough") == 0) { - gtk_style_context_set_class (context, "scrollbar"); - gtk_style_context_set_class (context, "trough"); + gtk_style_context_add_class (context, "scrollbar"); + gtk_style_context_add_class (context, "trough"); } else if (strcmp (detail, "spinbutton") == 0) - gtk_style_context_set_class (context, "spinbutton"); + gtk_style_context_add_class (context, "spinbutton"); else if (strcmp (detail, "spinbutton_up") == 0) { - gtk_style_context_set_class (context, "spinbutton"); - gtk_style_context_set_class (context, "button"); + gtk_style_context_add_class (context, "spinbutton"); + gtk_style_context_add_class (context, "button"); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); } else if (strcmp (detail, "spinbutton_down") == 0) { - gtk_style_context_set_class (context, "spinbutton"); - gtk_style_context_set_class (context, "button"); + gtk_style_context_add_class (context, "spinbutton"); + gtk_style_context_add_class (context, "button"); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); } else if (g_str_has_prefix (detail, "cell_")) @@ -1837,9 +1837,9 @@ transform_detail_string (const gchar *detail, if (!ruled) row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD); - gtk_style_context_set_class (context, "cell"); - gtk_style_context_set_region (context, "row", row); - gtk_style_context_set_region (context, "column", col); + gtk_style_context_add_class (context, "cell"); + gtk_style_context_add_region (context, "row", row); + gtk_style_context_add_region (context, "column", col); g_strfreev (tokens); } diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f0456a4d4c..284f8521a9 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1436,8 +1436,8 @@ gtk_style_context_get_path (GtkStyleContext *context) * @context: a #GtkStyleContext * * Saves the @context state, so all modifications done through - * gtk_style_context_set_class(), gtk_style_context_unset_class(), - * gtk_style_context_set_region(), gtk_style_context_unset_region() + * gtk_style_context_add_class(), gtk_style_context_remove_class(), + * gtk_style_context_add_region(), gtk_style_context_remove_region() * or gtk_style_context_set_junction_sides() can be reverted in one * go through gtk_style_context_restore(). * @@ -1590,7 +1590,7 @@ region_find (GArray *array, } /** - * gtk_style_context_set_class: + * gtk_style_context_add_class: * @context: a #GtkStyleContext * @class_name: class name to use in styling * @@ -1614,7 +1614,7 @@ region_find (GArray *array, * Since: 3.0 **/ void -gtk_style_context_set_class (GtkStyleContext *context, +gtk_style_context_add_class (GtkStyleContext *context, const gchar *class_name) { GtkStyleContextPrivate *priv; @@ -1641,7 +1641,7 @@ gtk_style_context_set_class (GtkStyleContext *context, } /** - * gtk_style_context_unset_class: + * gtk_style_context_remove_class: * @context: a #GtkStyleContext * @class_name: class name to remove * @@ -1650,8 +1650,8 @@ gtk_style_context_set_class (GtkStyleContext *context, * Since: 3.0 **/ void -gtk_style_context_unset_class (GtkStyleContext *context, - const gchar *class_name) +gtk_style_context_remove_class (GtkStyleContext *context, + const gchar *class_name) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; @@ -1802,7 +1802,7 @@ gtk_style_context_list_regions (GtkStyleContext *context) } /** - * gtk_style_context_set_region: + * gtk_style_context_add_region: * @context: a #GtkStyleContext * @region_name: region name to use in styling * @flags: flags that apply to the region @@ -1830,7 +1830,7 @@ gtk_style_context_list_regions (GtkStyleContext *context) * Since: 3.0 **/ void -gtk_style_context_set_region (GtkStyleContext *context, +gtk_style_context_add_region (GtkStyleContext *context, const gchar *region_name, GtkRegionFlags flags) { @@ -1863,7 +1863,7 @@ gtk_style_context_set_region (GtkStyleContext *context, } /** - * gtk_style_context_unset_region: + * gtk_style_context_remove_region: * @context: a #GtkStyleContext * @region_name: region name to unset * @@ -1872,8 +1872,8 @@ gtk_style_context_set_region (GtkStyleContext *context, * Since: 3.0 **/ void -gtk_style_context_unset_region (GtkStyleContext *context, - const gchar *region_name) +gtk_style_context_remove_region (GtkStyleContext *context, + const gchar *region_name) { GtkStyleContextPrivate *priv; GtkStyleInfo *info; diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 592d0e8c4a..a7c74b5489 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -94,23 +94,23 @@ G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *cont GList * gtk_style_context_list_classes (GtkStyleContext *context); -void gtk_style_context_set_class (GtkStyleContext *context, - const gchar *class_name); -void gtk_style_context_unset_class (GtkStyleContext *context, - const gchar *class_name); -gboolean gtk_style_context_has_class (GtkStyleContext *context, - const gchar *class_name); +void gtk_style_context_add_class (GtkStyleContext *context, + const gchar *class_name); +void gtk_style_context_remove_class (GtkStyleContext *context, + const gchar *class_name); +gboolean gtk_style_context_has_class (GtkStyleContext *context, + const gchar *class_name); GList * gtk_style_context_list_regions (GtkStyleContext *context); -void gtk_style_context_set_region (GtkStyleContext *context, - const gchar *region_name, - GtkRegionFlags flags); -void gtk_style_context_unset_region (GtkStyleContext *context, - const gchar *region_name); -gboolean gtk_style_context_has_region (GtkStyleContext *context, - const gchar *region_name, - GtkRegionFlags *flags_return); +void gtk_style_context_add_region (GtkStyleContext *context, + const gchar *region_name, + GtkRegionFlags flags); +void gtk_style_context_remove_region (GtkStyleContext *context, + const gchar *region_name); +gboolean gtk_style_context_has_region (GtkStyleContext *context, + const gchar *region_name, + GtkRegionFlags *flags_return); void gtk_style_context_get_style_property (GtkStyleContext *context, const gchar *property_name, diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 578335b8e7..4b4e186ca8 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -436,7 +436,7 @@ gtk_widget_path_iter_has_name (const GtkWidgetPath *path, * * Adds the class @name to the widget at position @pos in * the hierarchy defined in @path. See - * gtk_style_context_set_class(). + * gtk_style_context_add_class(). * * Since: 3.0 **/ @@ -690,7 +690,7 @@ gtk_widget_path_iter_has_class (const GtkWidgetPath *path, * * Adds the region @name to the widget at position @pos in * the hierarchy defined in @path. See - * gtk_style_context_set_region(). + * gtk_style_context_add_region(). * * Since: 3.0 **/ From 770f050d8c749d0f293356651f0a55385de84ee9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 19:33:39 +0200 Subject: [PATCH 349/634] GtkWidgetPath: turn into a boxed type. --- gtk/gtkwidgetpath.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 4b4e186ca8..dfd2afe824 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -30,7 +30,7 @@ * @Title: GtkWidgetPath * @See_also: #GtkStyleContext * - * #GtkWidgetPath is an struct that represents a widget hierarchy from + * #GtkWidgetPath is a boxed type that represents a widget hierarchy from * the topmost widget, typically a toplevel, to any child. This widget * path abstraction is used in #GtkStyleContext on behalf of the real * widget in order to query style information. @@ -80,6 +80,10 @@ * that applies to the described widget. **/ +G_DEFINE_BOXED_TYPE (GtkWidgetPath, gtk_widget_path, + gtk_widget_path_copy, gtk_widget_path_free) + + typedef struct GtkPathElement GtkPathElement; struct GtkPathElement From 8d4ffedbf1facd3a585161ff0b37431b2f3d8d06 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 20 Oct 2010 19:52:50 +0200 Subject: [PATCH 350/634] GtkStyleContext: '_' prefix the structs, gtk-doc prefers this. --- gtk/gtkstylecontext.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a7c74b5489..574beddf20 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -33,16 +33,16 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT)) #define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass)) -typedef struct GtkStyleContext GtkStyleContext; -typedef struct GtkStyleContextClass GtkStyleContextClass; +typedef struct _GtkStyleContext GtkStyleContext; +typedef struct _GtkStyleContextClass GtkStyleContextClass; -struct GtkStyleContext +struct _GtkStyleContext { GObject parent_object; gpointer priv; }; -struct GtkStyleContextClass +struct _GtkStyleContextClass { GObjectClass parent_class; From 3a455ed8f95324bdbf554935f7cff87518665c39 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 22 Oct 2010 10:38:21 +0200 Subject: [PATCH 351/634] GtkStyleSet: Register the border-style and border-color properties This is also implemented in the theming engine, although the default CSS should be using it in order to theme buttons, troughs, sliders and such. --- gtk/gtkenums.h | 6 + gtk/gtkstyleset.c | 3 + gtk/gtkthemingengine.c | 300 +++++++++++++++++++++-------------------- 3 files changed, 165 insertions(+), 144 deletions(-) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 85c8c561ae..99a52cf394 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -618,6 +618,12 @@ typedef enum { GTK_JUNCTION_RIGHT = 1 << 3 } GtkJunctionSides; +typedef enum { + GTK_BORDER_STYLE_NONE, + GTK_BORDER_STYLE_SOLID, + GTK_BORDER_STYLE_INSET, + GTK_BORDER_STYLE_OUTSET +} GtkBorderStyle; G_END_DECLS diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 9aa5519ec7..a53a75c314 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -23,6 +23,7 @@ #include #include +#include "gtktypebuiltins.h" #include "gtkstyleprovider.h" #include "gtkstyleset.h" #include "gtkprivate.h" @@ -92,6 +93,8 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("border-width", G_TYPE_INT, NULL, NULL); gtk_style_set_register_property ("border-radius", G_TYPE_INT, NULL, NULL); + gtk_style_set_register_property ("border-style", GTK_TYPE_BORDER_STYLE, NULL, NULL); + gtk_style_set_register_property ("border-color", GDK_TYPE_COLOR, NULL, NULL); gtk_style_set_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f91f1c323a..b7e101bbd0 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -52,7 +52,8 @@ enum { SIDE_LEFT = 1, SIDE_BOTTOM = 1 << 1, SIDE_RIGHT = 1 << 2, - SIDE_TOP = 1 << 3 + SIDE_TOP = 1 << 3, + SIDE_ALL = 0xF }; struct GtkThemingEnginePrivate @@ -1139,25 +1140,97 @@ color_shade (const GdkColor *color, } static void -_cairo_round_rectangle (cairo_t *cr, - gdouble radius, - gdouble x, - gdouble y, - gdouble width, - gdouble height) +_cairo_round_rectangle_sides (cairo_t *cr, + gdouble radius, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + guint sides, + GtkJunctionSides junction) { radius = CLAMP (radius, 0, MIN (width / 2, height / 2)); - if (radius == 0) - cairo_rectangle (cr, x, y, width, height); - else + if (sides & SIDE_RIGHT) { - cairo_new_sub_path (cr); - cairo_arc (cr, x + width - radius, y + radius, radius, - G_PI / 2, 0); - cairo_arc (cr, x + width - radius, y + height - radius, radius, 0, G_PI / 2); - cairo_arc (cr, x + radius, y + height - radius, radius, G_PI / 2, G_PI); - cairo_arc (cr, x + radius, y + radius, radius, G_PI, 3 * (G_PI / 2)); - cairo_close_path (cr); + if (radius == 0 || + (junction & GTK_JUNCTION_TOP) || + (junction & GTK_JUNCTION_RIGHT)) + cairo_move_to (cr, x + width, y); + else + { + cairo_new_sub_path (cr); + cairo_arc (cr, x + width - radius, y + radius, radius, - G_PI / 4, 0); + } + + if (radius == 0 || + (junction & GTK_JUNCTION_BOTTOM) || + (junction & GTK_JUNCTION_RIGHT)) + cairo_line_to (cr, x + width, y + height); + else + cairo_arc (cr, x + width - radius, y + height - radius, radius, 0, G_PI / 4); + } + + if (sides & SIDE_BOTTOM) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_RIGHT) && + ! (junction & GTK_JUNCTION_BOTTOM)) + { + if ((sides & SIDE_RIGHT) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + width - radius, y + height - radius, radius, G_PI / 4, G_PI / 2); + } + + if (radius == 0 || + (junction & GTK_JUNCTION_BOTTOM) || + (junction & GTK_JUNCTION_LEFT)) + cairo_line_to (cr, x, y + height); + else + cairo_arc (cr, x + radius, y + height - radius, radius, G_PI / 2, 3 * (G_PI / 4)); + } + else + cairo_move_to (cr, x, y + height); + + if (sides & SIDE_LEFT) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_LEFT) && + ! (junction & GTK_JUNCTION_BOTTOM)) + { + if ((sides & SIDE_BOTTOM) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + radius, y + height - radius, radius, 3 * (G_PI / 4), G_PI); + } + + if (radius == 0 || + (junction & GTK_JUNCTION_TOP) || + (junction & GTK_JUNCTION_LEFT)) + cairo_line_to (cr, x, y); + else + cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI + G_PI / 4); + } + + if (sides & SIDE_TOP) + { + if (radius != 0 && + ! (junction & GTK_JUNCTION_TOP) && + ! (junction & GTK_JUNCTION_LEFT)) + { + if ((sides & SIDE_TOP) == 0) + cairo_new_sub_path (cr); + + cairo_arc (cr, x + radius, y + radius, radius, 5 * (G_PI / 4), 3 * (G_PI / 2)); + } + + if (radius == 0 || + (junction & GTK_JUNCTION_TOP) || + (junction & GTK_JUNCTION_RIGHT)) + cairo_line_to (cr, x + width, y); + else + cairo_arc (cr, x + width - radius, y + radius, radius, 3 * (G_PI / 2), - G_PI / 4); } } @@ -1174,9 +1247,11 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, GtkStateFlags flags; gboolean running; gdouble progress, alpha = 1; + GtkJunctionSides junction; gint radius; flags = gtk_theming_engine_get_state (engine); + junction = gtk_theming_engine_get_junction_sides (engine); cairo_save (cr); if (gtk_theming_engine_has_class (engine, "spinbutton") && @@ -1197,7 +1272,9 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); - _cairo_round_rectangle (cr, (gdouble) radius, x, y, width, height); + _cairo_round_rectangle_sides (cr, (gdouble) radius, + x, y, width, height, + SIDE_ALL, junction); cairo_clip (cr); cairo_translate (cr, x, y); @@ -1448,163 +1525,98 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, { GtkStateFlags flags; GdkColor lighter, darker; - GdkColor *bg_color; + GdkColor *border_color; Gtk9Slice *slice; + GtkBorderStyle border_style; + gint border_width, radius; + GtkJunctionSides junction; flags = gtk_theming_engine_get_state (engine); + junction = gtk_theming_engine_get_junction_sides (engine); gtk_theming_engine_get (engine, flags, "border-image", &slice, - "background-color", &bg_color, + "border-color", &border_color, + "border-style", &border_style, + "border-width", &border_width, + "border-radius", &radius, NULL); if (slice) { gtk_9slice_render (slice, cr, x, y, width, height); gtk_9slice_unref (slice); - gdk_color_free (bg_color); - return; } - - cairo_save (cr); - cairo_set_line_width (cr, 1); - - color_shade (bg_color, 0.7, &darker); - color_shade (bg_color, 1.3, &lighter); - - if (gtk_theming_engine_has_class (engine, "entry") || - gtk_theming_engine_has_class (engine, "scrolled-window") || - gtk_theming_engine_has_class (engine, "viewport")) + else if (border_style != GTK_BORDER_STYLE_NONE) { - gdk_cairo_set_source_color (cr, bg_color); - add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); + cairo_save (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); + color_shade (border_color, 0.7, &darker); + color_shade (border_color, 1.3, &lighter); - cairo_set_source_rgb (cr, 1, 1, 1); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); - } - else if (gtk_theming_engine_has_class (engine, "button") && - gtk_theming_engine_has_class (engine, "default")) - { - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_rectangle (cr, x + 0.5, x + 0.5, width - 1, height - 1); - cairo_stroke (cr); - } - else if (gtk_theming_engine_has_class (engine, "scrollbar") && - gtk_theming_engine_has_class (engine, "trough")) - { - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - } - else if (gtk_theming_engine_has_class (engine, "spinbutton")) - { - if (gtk_theming_engine_has_class (engine, "button")) + switch (border_style) { - GtkJunctionSides sides; + case GTK_BORDER_STYLE_NONE: + break; + case GTK_BORDER_STYLE_SOLID: + cairo_set_line_width (cr, border_width); - sides = gtk_theming_engine_get_junction_sides (engine); + if (border_width > 1) + { + x += (gdouble) border_width / 2; + y += (gdouble) border_width / 2; + width -= border_width; + height -= border_width; + } - if (sides & GTK_JUNCTION_BOTTOM) - y += 2; + _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, + SIDE_ALL, junction); + gdk_cairo_set_source_color (cr, border_color); + cairo_stroke (cr); - width -= 3; - height -= 2; + break; + case GTK_BORDER_STYLE_INSET: + case GTK_BORDER_STYLE_OUTSET: + cairo_set_line_width (cr, border_width); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL) - x += 2; + if (border_width > 1) + { + gint d; + + d = border_width / 2; + x += d; + y += d; + width -= d * 2; + height -= d * 2; + } + + if (border_style == GTK_BORDER_STYLE_INSET) + gdk_cairo_set_source_color (cr, border_color); else - x += 1; + gdk_cairo_set_source_color (cr, &darker); - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); + _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, + SIDE_BOTTOM | SIDE_RIGHT, junction); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, SIDE_BOTTOM); + if (border_style == GTK_BORDER_STYLE_INSET) + gdk_cairo_set_source_color (cr, &darker); + else + gdk_cairo_set_source_color (cr, border_color); + + _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, + SIDE_TOP | SIDE_LEFT, junction); cairo_stroke (cr); + + break; } - else - { - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, bg_color); - add_path_rectangle_sides (cr, x, y, width - 1, height - 1, SIDE_BOTTOM); - cairo_stroke (cr); - - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x, y + 1, width - 1, height - 3, - SIDE_TOP | SIDE_LEFT | SIDE_RIGHT); - cairo_stroke (cr); - } - } - else - { - if (flags & GTK_STATE_FLAG_ACTIVE) - { - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); - } - else - { - gdk_cairo_set_source_color (cr, &darker); - add_path_rectangle_sides (cr, x, y, width - 1, height - 1, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - - gdk_cairo_set_source_color (cr, &lighter); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_TOP | SIDE_LEFT); - cairo_stroke (cr); - - cairo_set_source_rgb (cr, 0, 0, 0); - add_path_rectangle_sides (cr, x, y, width, height, - SIDE_BOTTOM | SIDE_RIGHT); - cairo_stroke (cr); - } + cairo_restore (cr); } - cairo_restore (cr); - - gdk_color_free (bg_color); + if (border_color) + gdk_color_free (border_color); } static void From 4e02218f52080421cf40b29c82555ec95f708b40 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 22 Oct 2010 12:41:19 +0200 Subject: [PATCH 352/634] Use GdkRGBA all around in GtkStyleContext. --- gtk/gtkcssprovider.c | 27 +++-- gtk/gtksettings.c | 4 +- gtk/gtkstyle.c | 37 ++++-- gtk/gtkstylecontext.c | 2 +- gtk/gtkstylecontext.h | 2 +- gtk/gtkstyleset.c | 26 ++--- gtk/gtkstyleset.h | 2 +- gtk/gtksymboliccolor.c | 39 +++---- gtk/gtksymboliccolor.h | 2 +- gtk/gtkthemingengine.c | 247 ++++++++++++++++++++--------------------- 10 files changed, 205 insertions(+), 183 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 045bd64bc4..0f051141fb 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -279,7 +279,7 @@ * * background-color * color - * #GdkColor + * #GdkRGBA * * * background-color: #fff; @@ -1532,21 +1532,30 @@ symbolic_color_parse_str (const gchar *string, str = (gchar *) string; - if (str[0] == '#') + if (str[0] == '#' || str[0] == 'r') { - GdkColor color; + GdkRGBA color; gchar *color_str; const gchar *end; end = str + 1; - while (g_ascii_isxdigit (*end)) - end++; + if (str[0] == '#') + while (g_ascii_isxdigit (*end)) + end++; + else + { + while (*end != ')' && *end != '\0') + end++; + + if (*end == ')') + end++; + } color_str = g_strndup (str, end - str); *end_ptr = (gchar *) end; - if (!gdk_color_parse (color_str, &color)) + if (!gdk_rgba_parse (&color, color_str)) { g_free (color_str); return NULL; @@ -2205,11 +2214,11 @@ css_provider_parse_value (GtkCssProvider *css_provider, type = G_VALUE_TYPE (value); - if (type == GDK_TYPE_COLOR) + if (type == GDK_TYPE_RGBA) { - GdkColor color; + GdkRGBA color; - if (gdk_color_parse (value_str, &color) == TRUE) + if (gdk_rgba_parse (&color, value_str) == TRUE) g_value_set_boxed (value, &color); else { diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 278890908c..d07ce4885b 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1278,7 +1278,7 @@ gtk_settings_get_style (GtkStyleProvider *provider, { GtkSymbolicColor *color; gchar *name, *pos; - GdkColor col; + GdkRGBA col; if (!*colors[i]) continue; @@ -1297,7 +1297,7 @@ gtk_settings_get_style (GtkStyleProvider *provider, while (*pos == ' ') pos++; - if (!*pos || !gdk_color_parse (pos, &col)) + if (!*pos || !gdk_rgba_parse (&col, pos)) continue; color = gtk_symbolic_color_new_literal (&col); diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 38390c072f..8ba9e975b2 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -642,7 +642,8 @@ set_color (GtkStyle *style, GtkStateType state, GtkRcFlags prop) { - GdkColor *color = NULL; + GdkRGBA *color = NULL; + GdkColor *dest = { 0 }; /* Shut up gcc */ switch (prop) { @@ -650,34 +651,36 @@ set_color (GtkStyle *style, gtk_style_context_get (context, state, "background-color", &color, NULL); - if (color) - style->bg[state] = *color; + dest = &style->bg[state]; break; case GTK_RC_FG: gtk_style_context_get (context, state, "foreground-color", &color, NULL); - if (color) - style->fg[state] = *color; + dest = &style->fg[state]; break; case GTK_RC_TEXT: gtk_style_context_get (context, state, "text-color", &color, NULL); - if (color) - style->text[state] = *color; + dest = &style->text[state]; break; case GTK_RC_BASE: gtk_style_context_get (context, state, "base-color", &color, NULL); - if (color) - style->base[state] = *color; + dest = &style->base[state]; break; } if (color) - gdk_color_free (color); + { + dest->pixel = 0; + dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535); + dest->green = CLAMP ((guint) (color->green * 65535), 0, 65535); + dest->blue = CLAMP ((guint) (color->blue * 65535), 0, 65535); + gdk_rgba_free (color); + } } static void @@ -973,6 +976,8 @@ gtk_style_lookup_color (GtkStyle *style, GdkColor *color) { GtkStylePrivate *priv; + gboolean result; + GdkRGBA rgba; g_return_val_if_fail (GTK_IS_STYLE (style), FALSE); g_return_val_if_fail (color_name != NULL, FALSE); @@ -983,7 +988,17 @@ gtk_style_lookup_color (GtkStyle *style, if (!priv->context) return FALSE; - return gtk_style_context_lookup_color (priv->context, color_name, color); + result = gtk_style_context_lookup_color (priv->context, color_name, &rgba); + + if (color) + { + color->red = (guint16) (rgba.red * 65535); + color->green = (guint16) (rgba.green * 65535); + color->blue = (guint16) (rgba.blue * 65535); + color->pixel = 0; + } + + return result; } /** diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 284f8521a9..602a83d126 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2376,7 +2376,7 @@ gtk_style_context_get_junction_sides (GtkStyleContext *context) gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, - GdkColor *color) + GdkRGBA *color) { GtkStyleContextPrivate *priv; GtkSymbolicColor *sym_color; diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 574beddf20..212de85558 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -137,7 +137,7 @@ GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext *context gboolean gtk_style_context_lookup_color (GtkStyleContext *context, const gchar *color_name, - GdkColor *color); + GdkRGBA *color); void gtk_style_context_notify_state_change (GtkStyleContext *context, GdkWindow *window, diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index a53a75c314..94a4136629 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -81,10 +81,10 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) object_class->finalize = gtk_style_set_finalize; /* Initialize default property set */ - gtk_style_set_register_property ("foreground-color", GDK_TYPE_COLOR, NULL, NULL); - gtk_style_set_register_property ("background-color", GDK_TYPE_COLOR, NULL, NULL); - gtk_style_set_register_property ("text-color", GDK_TYPE_COLOR, NULL, NULL); - gtk_style_set_register_property ("base-color", GDK_TYPE_COLOR, NULL, NULL); + gtk_style_set_register_property ("foreground-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_set_register_property ("background-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_set_register_property ("text-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_set_register_property ("base-color", GDK_TYPE_RGBA, NULL, NULL); gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); @@ -94,7 +94,7 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) gtk_style_set_register_property ("border-width", G_TYPE_INT, NULL, NULL); gtk_style_set_register_property ("border-radius", G_TYPE_INT, NULL, NULL); gtk_style_set_register_property ("border-style", GTK_TYPE_BORDER_STYLE, NULL, NULL); - gtk_style_set_register_property ("border-color", GDK_TYPE_COLOR, NULL, NULL); + gtk_style_set_register_property ("border-color", GDK_TYPE_RGBA, NULL, NULL); gtk_style_set_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); @@ -572,10 +572,10 @@ gtk_style_set_set_property (GtkStyleSet *set, return; } - if (node->property_type == GDK_TYPE_COLOR) + if (node->property_type == GDK_TYPE_RGBA) { /* Allow GtkSymbolicColor as well */ - g_return_if_fail (value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); + g_return_if_fail (value_type == GDK_TYPE_RGBA || value_type == GTK_TYPE_SYMBOLIC_COLOR); } else if (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN) { @@ -710,15 +710,15 @@ static gboolean resolve_color (GtkStyleSet *set, GValue *value) { - GdkColor color; + GdkRGBA color; - /* Resolve symbolic color to GdkColor */ + /* Resolve symbolic color to GdkRGBA */ if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), set, &color)) return FALSE; - /* Store it back, this is where GdkColor caching happens */ + /* Store it back, this is where GdkRGBA caching happens */ g_value_unset (value); - g_value_init (value, GDK_TYPE_COLOR); + g_value_init (value, GDK_TYPE_RGBA); g_value_set_boxed (value, &color); return TRUE; @@ -796,7 +796,7 @@ gtk_style_set_get_property (GtkStyleSet *set, if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - g_return_val_if_fail (node->property_type == GDK_TYPE_COLOR, FALSE); + g_return_val_if_fail (node->property_type == GDK_TYPE_RGBA, FALSE); if (!resolve_color (set, val)) return FALSE; @@ -863,7 +863,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - g_return_if_fail (node->property_type == GDK_TYPE_COLOR); + g_return_if_fail (node->property_type == GDK_TYPE_RGBA); if (!resolve_color (set, val)) val = &node->default_value; diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h index f19ce16041..60544ad583 100644 --- a/gtk/gtkstyleset.h +++ b/gtk/gtkstyleset.h @@ -105,7 +105,7 @@ void gtk_style_set_merge (GtkStyleSet *set, gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, GtkStyleSet *style_set, - GdkColor *resolved_color); + GdkRGBA *resolved_color); gboolean gtk_gradient_resolve (GtkGradient *gradient, GtkStyleSet *style_set, cairo_pattern_t **resolved_gradient); diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index e803c2e1e7..25af2c33ce 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -42,7 +42,7 @@ struct _GtkSymbolicColor union { - GdkColor color; + GdkRGBA color; gchar *name; struct @@ -84,7 +84,7 @@ struct _GtkGradient /** * gtk_symbolic_color_new_literal: - * @color: a #GdkColor + * @color: a #GdkRGBA * * Creates a symbolic color pointing to a literal color. * @@ -93,7 +93,7 @@ struct _GtkGradient * Since: 3.0 **/ GtkSymbolicColor * -gtk_symbolic_color_new_literal (GdkColor *color) +gtk_symbolic_color_new_literal (GdkRGBA *color) { GtkSymbolicColor *symbolic_color; @@ -273,9 +273,9 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) * Since: 3.0 **/ gboolean -gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GtkStyleSet *style_set, - GdkColor *resolved_color) +gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleSet *style_set, + GdkRGBA *resolved_color) { g_return_val_if_fail (color != NULL, FALSE); g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); @@ -301,14 +301,15 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, break; case COLOR_TYPE_SHADE: { - GdkColor shade; + GdkRGBA shade; if (!gtk_symbolic_color_resolve (color->shade.color, style_set, &shade)) return FALSE; - resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 65535); - resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 65535); - resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 65535); + resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 1); + resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 1); + resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 1); + resolved_color->alpha = CLAMP (shade.alpha * color->shade.factor, 0, 1); return TRUE; } @@ -316,7 +317,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, break; case COLOR_TYPE_MIX: { - GdkColor color1, color2; + GdkRGBA color1, color2; if (!gtk_symbolic_color_resolve (color->mix.color1, style_set, &color1)) return FALSE; @@ -324,9 +325,10 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, if (!gtk_symbolic_color_resolve (color->mix.color2, style_set, &color2)) return FALSE; - resolved_color->red = CLAMP (color1.red + ((color2.red - color1.red) * color->mix.factor), 0, 65535); - resolved_color->green = CLAMP (color1.green + ((color2.green - color1.green) * color->mix.factor), 0, 65535); - resolved_color->blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 65535); + resolved_color->red = CLAMP (color1.red + ((color2.red - color1.red) * color->mix.factor), 0, 1); + resolved_color->green = CLAMP (color1.green + ((color2.green - color1.green) * color->mix.factor), 0, 1); + resolved_color->blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 1); + resolved_color->alpha = CLAMP (color1.alpha + ((color2.alpha - color1.alpha) * color->mix.factor), 0, 1); return TRUE; } @@ -537,7 +539,7 @@ gtk_gradient_resolve (GtkGradient *gradient, for (i = 0; i < gradient->stops->len; i++) { ColorStop *stop; - GdkColor color; + GdkRGBA color; stop = &g_array_index (gradient->stops, ColorStop, i); @@ -547,10 +549,9 @@ gtk_gradient_resolve (GtkGradient *gradient, return FALSE; } - cairo_pattern_add_color_stop_rgb (pattern, stop->offset, - color.red / 65535., - color.green / 65535., - color.blue / 65535.); + cairo_pattern_add_color_stop_rgba (pattern, stop->offset, + color.red, color.green, + color.blue, color.alpha); } *resolved_gradient = pattern; diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index e326992a33..ce1d3c6fdc 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -34,7 +34,7 @@ typedef struct _GtkGradient GtkGradient; GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; GType gtk_gradient_get_type (void) G_GNUC_CONST; -GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkColor *color); +GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkRGBA *color); GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, gdouble factor); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b7e101bbd0..61433ad1e6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -758,7 +758,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, gdouble width, gdouble height) { - GdkColor *fg_color, *base_color, *text_color; + GdkRGBA *fg_color, *base_color, *text_color; const GtkWidgetPath *path; GtkStateFlags flags; gint exterior_size, interior_size, thickness, pad; @@ -797,21 +797,21 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1); - gdk_cairo_set_source_color (cr, base_color); + gdk_cairo_set_source_rgba (cr, base_color); cairo_fill_preserve (cr); if (gtk_theming_engine_has_class (engine, "cell")) - gdk_cairo_set_source_color (cr, text_color); + gdk_cairo_set_source_rgba (cr, text_color); else - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_stroke (cr); } if (gtk_theming_engine_has_class (engine, "menu")) - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); else - gdk_cairo_set_source_color (cr, text_color); + gdk_cairo_set_source_rgba (cr, text_color); if (flags & GTK_STATE_FLAG_INCONSISTENT) { @@ -869,9 +869,9 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (fg_color); - gdk_color_free (base_color); - gdk_color_free (text_color); + gdk_rgba_free (fg_color); + gdk_rgba_free (base_color); + gdk_rgba_free (text_color); } static void @@ -883,7 +883,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkColor *base_color, *fg_color, *text_color; + GdkRGBA *base_color, *fg_color, *text_color; const GtkWidgetPath *path; gint exterior_size, interior_size, pad, thickness; gdouble radius; @@ -910,7 +910,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, if (!gtk_theming_engine_has_class (engine, "menu")) { - gdk_cairo_set_source_color (cr, base_color); + gdk_cairo_set_source_rgba (cr, base_color); cairo_arc (cr, x + exterior_size / 2., @@ -921,18 +921,18 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_fill_preserve (cr); if (gtk_theming_engine_has_class (engine, "cell")) - gdk_cairo_set_source_color (cr, text_color); + gdk_cairo_set_source_rgba (cr, text_color); else - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_set_line_width (cr, 1.); cairo_stroke (cr); } if (gtk_theming_engine_has_class (engine, "menu")) - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); else - gdk_cairo_set_source_color (cr, text_color); + gdk_cairo_set_source_rgba (cr, text_color); /* FIXME: thickness */ thickness = 1; @@ -980,9 +980,9 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (fg_color); - gdk_color_free (base_color); - gdk_color_free (text_color); + gdk_rgba_free (fg_color); + gdk_rgba_free (base_color); + gdk_rgba_free (text_color); } static void @@ -1014,7 +1014,7 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, gdouble size) { GtkStateFlags flags; - GdkColor *fg_color; + GdkRGBA *fg_color; cairo_save (cr); @@ -1032,12 +1032,12 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, } add_path_arrow (cr, angle, x, y, size); - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_fill (cr); cairo_restore (cr); - gdk_color_free (fg_color); + gdk_rgba_free (fg_color); } static void @@ -1130,13 +1130,14 @@ add_path_gap_side (cairo_t *cr, } static void -color_shade (const GdkColor *color, - gdouble factor, - GdkColor *color_return) +color_shade (const GdkRGBA *color, + gdouble factor, + GdkRGBA *color_return) { - color_return->red = CLAMP (color->red * factor, 0, 65535); - color_return->green = CLAMP (color->green * factor, 0, 65535); - color_return->blue = CLAMP (color->blue * factor, 0, 65535); + color_return->red = CLAMP (color->red * factor, 0, 1); + color_return->green = CLAMP (color->green * factor, 0, 1); + color_return->blue = CLAMP (color->blue * factor, 0, 1); + color_return->alpha = CLAMP (color->alpha * factor, 0, 1); } static void @@ -1242,7 +1243,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble width, gdouble height) { - GdkColor *bg_color, *base_color; + GdkRGBA *bg_color, *base_color; cairo_pattern_t *pattern; GtkStateFlags flags; gboolean running; @@ -1284,7 +1285,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, { cairo_pattern_t *other_pattern; GtkStateFlags other_flags; - GdkColor *other_bg, *other_base; + GdkRGBA *other_bg, *other_base; cairo_pattern_t *new_pattern = NULL; if (flags & GTK_STATE_FLAG_PRELIGHT) @@ -1384,10 +1385,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, else if (pattern || other_pattern) { cairo_pattern_t *p; - GdkColor *c; + GdkRGBA *c; gdouble x0, y0, x1, y1, r0, r1; - gdouble red0, green0, blue0; - gdouble red1, green1, blue1; gint n, i; /* Blend a pattern with a color */ @@ -1416,28 +1415,25 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_pattern_get_color_stop_count (p, &n); - red0 = c->red / 65535.; - green0 = c->green / 65535.; - blue0 = c->blue / 65535.; - for (i = 0; i < n; i++) { - gdouble offset, alpha; + gdouble red1, green1, blue1, alpha1; + gdouble offset; cairo_pattern_get_color_stop_rgba (p, i, &offset, &red1, &green1, &blue1, - &alpha); + &alpha1); cairo_pattern_add_color_stop_rgba (new_pattern, offset, - red0 + ((red1 - red0) * progress), - green0 + ((green1 - green0) * progress), - blue0 + ((blue1 - blue0) * progress), - alpha + ((1 - alpha) * progress)); + c->red + ((red1 - c->red) * progress), + c->green + ((green1 - c->green) * progress), + c->blue + ((blue1 - c->blue) * progress), + c->alpha + ((alpha1 - c->alpha) * progress)); } } else { - const GdkColor *color, *other_color; + const GdkRGBA *color, *other_color; /* Merge just colors */ if (gtk_theming_engine_has_class (engine, "entry")) @@ -1451,9 +1447,10 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, other_color = other_bg; } - new_pattern = cairo_pattern_create_rgb ((gdouble) (color->red + ((other_color->red - color->red) * progress)) / 65535., - (gdouble) (color->green + ((other_color->green - color->green) * progress)) / 65535., - (gdouble) (color->blue + ((other_color->blue - color->blue) * progress)) / 65535.); + new_pattern = cairo_pattern_create_rgba (CLAMP (color->red + ((other_color->red - color->red) * progress), 0, 1), + CLAMP (color->green + ((other_color->green - color->green) * progress), 0, 1), + CLAMP (color->blue + ((other_color->blue - color->blue) * progress), 0, 1), + CLAMP (color->alpha + ((other_color->alpha - color->alpha) * progress), 0, 1)); } if (new_pattern) @@ -1467,10 +1464,10 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_pattern_destroy (other_pattern); if (other_bg) - gdk_color_free (other_bg); + gdk_rgba_free (other_bg); if (other_base) - gdk_color_free (other_base); + gdk_rgba_free (other_base); } cairo_rectangle (cr, 0, 0, 1, 1); @@ -1483,9 +1480,9 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, else { if (gtk_theming_engine_has_class (engine, "entry")) - gdk_cairo_set_source_color (cr, base_color); + gdk_cairo_set_source_rgba (cr, base_color); else - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); } if (gtk_theming_engine_has_class (engine, "tooltip")) @@ -1511,8 +1508,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (base_color); - gdk_color_free (bg_color); + gdk_rgba_free (base_color); + gdk_rgba_free (bg_color); } static void @@ -1524,8 +1521,8 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkColor lighter, darker; - GdkColor *border_color; + GdkRGBA lighter, darker; + GdkRGBA *border_color; Gtk9Slice *slice; GtkBorderStyle border_style; gint border_width, radius; @@ -1571,7 +1568,7 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_ALL, junction); - gdk_cairo_set_source_color (cr, border_color); + gdk_cairo_set_source_rgba (cr, border_color); cairo_stroke (cr); break; @@ -1592,18 +1589,18 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, } if (border_style == GTK_BORDER_STYLE_INSET) - gdk_cairo_set_source_color (cr, border_color); + gdk_cairo_set_source_rgba (cr, border_color); else - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_BOTTOM | SIDE_RIGHT, junction); cairo_stroke (cr); if (border_style == GTK_BORDER_STYLE_INSET) - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); else - gdk_cairo_set_source_color (cr, border_color); + gdk_cairo_set_source_rgba (cr, border_color); _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_TOP | SIDE_LEFT, junction); @@ -1616,7 +1613,7 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, } if (border_color) - gdk_color_free (border_color); + gdk_rgba_free (border_color); } static void @@ -1628,7 +1625,7 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkColor *bg_color, *fg_color, *base_color; + GdkRGBA *bg_color, *fg_color, *base_color; double vertical_overshoot; int diameter; double radius; @@ -1712,20 +1709,20 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, cairo_set_line_width (cr, line_width); if (flags & GTK_STATE_FLAG_PRELIGHT) - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); else - gdk_cairo_set_source_color (cr, base_color); + gdk_cairo_set_source_rgba (cr, base_color); cairo_fill_preserve (cr); - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_stroke (cr); cairo_restore (cr); - gdk_color_free (base_color); - gdk_color_free (fg_color); - gdk_color_free (bg_color); + gdk_rgba_free (base_color); + gdk_rgba_free (fg_color); + gdk_rgba_free (bg_color); } static void @@ -1737,7 +1734,7 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkColor *color; + GdkRGBA *color; gint line_width; gint8 *dash_list; @@ -1789,12 +1786,12 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, width - line_width, height - line_width); - gdk_cairo_set_source_color (cr, color); + gdk_cairo_set_source_rgba (cr, color); cairo_stroke (cr); cairo_restore (cr); - gdk_color_free (color); + gdk_rgba_free (color); g_free (dash_list); } @@ -1806,7 +1803,7 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, gdouble x1, gdouble y1) { - GdkColor *bg_color, darker, lighter; + GdkRGBA *bg_color, darker, lighter; GtkStateFlags flags; gint i, thickness, thickness_dark, thickness_light, len; cairo_matrix_t matrix; @@ -1847,11 +1844,11 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, for (i = 0; i < thickness_dark; i++) { - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, len - i - 1.5, y0, len - 0.5, y0); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, 0.5, y0, len - i - 1.5, y0); cairo_stroke (cr); @@ -1860,11 +1857,11 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, for (i = 0; i < thickness_light; i++) { - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, 0.5, y0, thickness_light - i + 0.5, y0); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, thickness_light - i + 0.5, y0, len - 0.5, y0); cairo_stroke (cr); @@ -1873,7 +1870,7 @@ gtk_theming_engine_render_line (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (bg_color); + gdk_rgba_free (bg_color); } static void @@ -1884,7 +1881,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, PangoLayout *layout) { const PangoMatrix *matrix; - GdkColor *fg_color; + GdkRGBA *fg_color; GtkStateFlags flags; GdkScreen *screen; @@ -1931,12 +1928,12 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, cairo_restore (cr); } - gdk_cairo_set_source_color (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); pango_cairo_show_layout (cr, layout); cairo_restore (cr); - gdk_color_free (fg_color); + gdk_rgba_free (fg_color); } static void @@ -1988,8 +1985,8 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, gdouble xy1_gap) { GtkStateFlags flags; - GdkColor *bg_color; - GdkColor lighter, darker; + GdkRGBA *bg_color; + GdkRGBA lighter, darker; guint sides; cairo_save (cr); @@ -2012,24 +2009,24 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_BOTTOM | SIDE_RIGHT; - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_rectangle_sides (cr, x , y, width , height, sides); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides); cairo_stroke (cr); if (gap_side == GTK_POS_RIGHT || gap_side == GTK_POS_BOTTOM) { - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_gap_side (cr, gap_side, x + 1, y + 1, width - 4, height - 4, xy0_gap, xy1_gap); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_gap_side (cr, gap_side, x, y, width, height, xy0_gap, xy1_gap); @@ -2043,24 +2040,24 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_TOP | SIDE_LEFT; - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 3, sides); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides); cairo_stroke (cr); if (gap_side == GTK_POS_LEFT || gap_side == GTK_POS_TOP) { - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_gap_side (cr, gap_side, x + 1, y + 1, width - 4, height - 4, xy0_gap, xy1_gap); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_gap_side (cr, gap_side, x, y, width - 2, height - 2, xy0_gap, xy1_gap); @@ -2076,7 +2073,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_BOTTOM | SIDE_RIGHT; - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_rectangle_sides (cr, x + 1, y, width - 2, height, sides); add_path_rectangle_sides (cr, x, y + 1, width, height - 2, sides); cairo_stroke (cr); @@ -2088,7 +2085,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, if (gap_side == GTK_POS_RIGHT || gap_side == GTK_POS_BOTTOM) { - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_gap_side (cr, gap_side, x, y, width - 2, height - 2, xy0_gap, xy1_gap); @@ -2108,7 +2105,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, else sides = SIDE_TOP | SIDE_LEFT; - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_rectangle_sides (cr, x, y, width, height, sides); cairo_stroke (cr); @@ -2124,7 +2121,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (bg_color); + gdk_rgba_free (bg_color); } static void @@ -2137,8 +2134,8 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, GtkPositionType gap_side) { GtkStateFlags flags; - GdkColor *bg_color; - GdkColor lighter, darker; + GdkRGBA *bg_color; + GdkRGBA lighter, darker; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -2154,19 +2151,19 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, switch (gap_side) { case GTK_POS_TOP: - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_rectangle (cr, x + 1, y, width - 2, height); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, x, y, x, y + height - 2); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); add_path_line (cr, x + 1, y, x + 1, y + height - 2); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, x + 2, y + height - 2, x + width - 2, y + height - 2); add_path_line (cr, x + width - 2, y, x + width - 2, y + height - 2); cairo_stroke (cr); @@ -2178,21 +2175,21 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, break; case GTK_POS_BOTTOM: - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba(cr, bg_color); cairo_rectangle (cr, x + 1, y, width - 2, height); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, x + 1, y, x + width - 2, y); add_path_line (cr, x, y + 1, x, y + height - 1); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1); add_path_line (cr, x + 1, y + 1, x + 1, y + height - 1); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 1); cairo_stroke (cr); @@ -2202,19 +2199,19 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, break; case GTK_POS_LEFT: - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_rectangle (cr, x, y + 1, width, height - 2); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, x, y, x + width - 2, y); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, x, y + height - 2, x + width - 2, y + height - 2); add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 2); cairo_stroke (cr); @@ -2226,21 +2223,21 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, break; case GTK_POS_RIGHT: - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_rectangle (cr, x, y + 1, width, height - 2); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &lighter); + gdk_cairo_set_source_rgba (cr, &lighter); add_path_line (cr, x + 1, y, x + width - 1, y); add_path_line (cr, x, y + 1, x, y + height - 2); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); add_path_line (cr, x + 1, y + 1, x + width - 1, y + 1); add_path_line (cr, x + 1, y + 1, x + 1, y + height - 2); cairo_stroke (cr); - gdk_cairo_set_source_color (cr, &darker); + gdk_cairo_set_source_rgba (cr, &darker); add_path_line (cr, x + 2, y + height - 2, x + width - 1, y + height - 2); cairo_stroke (cr); @@ -2253,34 +2250,34 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (bg_color); + gdk_rgba_free (bg_color); } static void -render_dot (cairo_t *cr, - const GdkColor *lighter, - const GdkColor *darker, - gdouble x, - gdouble y, - gdouble size) +render_dot (cairo_t *cr, + const GdkRGBA *lighter, + const GdkRGBA *darker, + gdouble x, + gdouble y, + gdouble size) { size = CLAMP ((gint) size, 2, 3); if (size == 2) { - gdk_cairo_set_source_color (cr, lighter); + gdk_cairo_set_source_rgba (cr, lighter); cairo_rectangle (cr, x, y, 1, 1); cairo_rectangle (cr, x + 1, y + 1, 1, 1); cairo_fill (cr); } else if (size == 3) { - gdk_cairo_set_source_color (cr, lighter); + gdk_cairo_set_source_rgba (cr, lighter); cairo_rectangle (cr, x, y, 2, 1); cairo_rectangle (cr, x, y, 1, 2); cairo_fill (cr); - gdk_cairo_set_source_color (cr, darker); + gdk_cairo_set_source_rgba (cr, darker); cairo_rectangle (cr, x + 1, y + 1, 2, 1); cairo_rectangle (cr, x + 2, y, 1, 2); cairo_fill (cr); @@ -2296,8 +2293,8 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkColor *bg_color; - GdkColor lighter, darker; + GdkRGBA *bg_color; + GdkRGBA lighter, darker; gint xx, yy; cairo_save (cr); @@ -2311,7 +2308,7 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, color_shade (bg_color, 0.7, &darker); color_shade (bg_color, 1.3, &lighter); - gdk_cairo_set_source_color (cr, bg_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); @@ -2336,5 +2333,5 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, cairo_restore (cr); - gdk_color_free (bg_color); + gdk_rgba_free (bg_color); } From 3bfc59b9bbee6ac57b8d9bba6d3c291ba2b6af95 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 22 Oct 2010 23:59:58 +0200 Subject: [PATCH 353/634] GtkStyle: Match "trough" and "slider" detail strings. This is so scrollbars can be themed throught the "trough" and "slider" classes. --- gtk/gtkstyle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 8ba9e975b2..c7ce8bbb2e 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1801,7 +1801,7 @@ transform_detail_string (const gchar *detail, else if (strcmp (detail, "viewport") == 0 || strcmp (detail, "viewportbin") == 0) gtk_style_context_add_class (context, "viewport"); - else if (strcmp (detail, "trough") == 0) + else if (strncmp (detail, "trough", 6) == 0) { gtk_style_context_add_class (context, "scrollbar"); gtk_style_context_add_class (context, "trough"); @@ -1820,6 +1820,8 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "button"); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); } + else if (strcmp (detail, "slider") == 0) + gtk_style_context_add_class (context, "slider"); else if (g_str_has_prefix (detail, "cell_")) { GtkRegionFlags row, col; From 490d59f045c2ba839cf1135f4b1fb71f2ead79e1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 18:24:14 +0200 Subject: [PATCH 354/634] Do not shade alpha values. --- gtk/gtksymboliccolor.c | 1 - gtk/gtkthemingengine.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 25af2c33ce..2fa3d18647 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -309,7 +309,6 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 1); resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 1); resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 1); - resolved_color->alpha = CLAMP (shade.alpha * color->shade.factor, 0, 1); return TRUE; } diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 61433ad1e6..6540c4cdb7 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1137,7 +1137,7 @@ color_shade (const GdkRGBA *color, color_return->red = CLAMP (color->red * factor, 0, 1); color_return->green = CLAMP (color->green * factor, 0, 1); color_return->blue = CLAMP (color->blue * factor, 0, 1); - color_return->alpha = CLAMP (color->alpha * factor, 0, 1); + color_return->alpha = color->alpha; } static void From 6bd086560127f450d3e258fdc22c1d38e33465b6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 18:25:18 +0200 Subject: [PATCH 355/634] GtkStyle: Handle scrollbar buttons. --- gtk/gtkstyle.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index c7ce8bbb2e..7e8906aad7 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1820,8 +1820,17 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "button"); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); } + else if ((detail[0] == 'h' || detail[0] == 'v') && + strncmp (&detail[1], "scrollbar_", 10) == 0) + { + gtk_style_context_add_class (context, "button"); + gtk_style_context_add_class (context, "scrollbar"); + } else if (strcmp (detail, "slider") == 0) - gtk_style_context_add_class (context, "slider"); + { + gtk_style_context_add_class (context, "slider"); + gtk_style_context_add_class (context, "scrollbar"); + } else if (g_str_has_prefix (detail, "cell_")) { GtkRegionFlags row, col; From 39ce35dd75eca0e0f0ed2866eab1529084429d7c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 18:32:15 +0200 Subject: [PATCH 356/634] GtkCssProvider: Improve default CSS. --- gtk/gtkcssprovider.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 0f051141fb..f763e3e80e 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2822,6 +2822,7 @@ gtk_css_provider_get_default (void) " foreground-color: @fg_color;\n" " text-color: @text_color; \n" " base-color: @base_color; \n" + " border-color: #898089;\n" " padding: 2 2; \n" "}\n" "\n" @@ -2861,11 +2862,34 @@ gtk_css_provider_get_default (void) " text-color: #000; \n" "}\n" "\n" + ".button,\n" + ".slider {\n" + " border-style: outset; \n" + " border-width: 2; \n" + "}\n" + "\n" ".button:active {\n" " background-color: #c4c2bd;\n" " foreground-color: #000000;\n" " text-color: #c4c2bd; \n" " base-color: #9c9a94; \n" + " border-style: inset; \n" + "}\n" + "\n" + ".trough {\n" + " border-style: inset;\n" + " border-width: 1;\n" + "}\n" + "\n" + ".entry {\n" + " border-style: inset;\n" + " border-width: 2;\n" + "}\n" + "\n" + ".viewport {\n" + " border-style: inset;\n" + " border-width: 2;\n" + " border-color: #9a909a;\n" "}\n" "\n"; From 975f133d63a89dc0a1d304ac825cf47383854a84 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 18:33:07 +0200 Subject: [PATCH 357/634] GtkThemingEngine: Improve rendering of inset/outset borders. --- gtk/gtkthemingengine.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 6540c4cdb7..b80592bb89 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1521,7 +1521,7 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkRGBA lighter, darker; + GdkRGBA lighter; GdkRGBA *border_color; Gtk9Slice *slice; GtkBorderStyle border_style; @@ -1544,12 +1544,12 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, gtk_9slice_render (slice, cr, x, y, width, height); gtk_9slice_unref (slice); } - else if (border_style != GTK_BORDER_STYLE_NONE) + else if (border_color && + border_style != GTK_BORDER_STYLE_NONE) { cairo_save (cr); - color_shade (border_color, 0.7, &darker); - color_shade (border_color, 1.3, &lighter); + color_shade (border_color, 1.8, &lighter); switch (border_style) { @@ -1579,28 +1579,30 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, if (border_width > 1) { - gint d; + gdouble d; - d = border_width / 2; + d = (gdouble) border_width / 2; x += d; y += d; - width -= d * 2; - height -= d * 2; + + d = (gdouble) (border_width - (gint) d) + 1; + width -= d; + height -= d; } if (border_style == GTK_BORDER_STYLE_INSET) - gdk_cairo_set_source_rgba (cr, border_color); + gdk_cairo_set_source_rgba (cr, &lighter); else - gdk_cairo_set_source_rgba (cr, &darker); + gdk_cairo_set_source_rgba (cr, border_color); _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_BOTTOM | SIDE_RIGHT, junction); cairo_stroke (cr); if (border_style == GTK_BORDER_STYLE_INSET) - gdk_cairo_set_source_rgba (cr, &darker); - else gdk_cairo_set_source_rgba (cr, border_color); + else + gdk_cairo_set_source_rgba (cr, &lighter); _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_TOP | SIDE_LEFT, junction); From 4ca3b5071e577ce68ff3ceab179d187e16298578 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 21:40:20 +0200 Subject: [PATCH 358/634] GtkSymbolicColor: Initialize alpha when resolving shades. --- gtk/gtksymboliccolor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 2fa3d18647..92d3eff9e3 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -309,6 +309,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 1); resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 1); resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 1); + resolved_color->alpha = shade.alpha; return TRUE; } From 7d441000f7bd2cda14382fa08dbe8f2a4f6085c5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 21:40:49 +0200 Subject: [PATCH 359/634] GtkCssProvider: Allow '\t' when parsing values. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f763e3e80e..88fa6d7a87 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1143,7 +1143,7 @@ scanner_apply_scope (GScanner *scanner, if (scope == SCOPE_VALUE) { scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; - scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\n" G_CSET_A_2_Z; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\t\n" G_CSET_A_2_Z; scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) From 087249db07f77a4ea445a8d187287e0388e3e003 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 22:24:57 +0200 Subject: [PATCH 360/634] GtkCssProvider: Update end string when misparsing symbolic colors. --- gtk/gtkcssprovider.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 88fa6d7a87..32d699f3f6 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1531,6 +1531,7 @@ symbolic_color_parse_str (const gchar *string, gchar *str; str = (gchar *) string; + *end_ptr = str; if (str[0] == '#' || str[0] == 'r') { From d565e15951a68bbb2ed055d964aa9ac54cf804d3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 23 Oct 2010 22:51:58 +0200 Subject: [PATCH 361/634] GtkStyle: translate active state in paint_flat_box(). --- gtk/gtkstyle.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 7e8906aad7..34f5d912bf 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -2599,6 +2599,9 @@ gtk_default_draw_flat_box (GtkStyle *style, case GTK_STATE_INSENSITIVE: flags |= GTK_STATE_FLAG_INSENSITIVE; break; + case GTK_STATE_ACTIVE: + flags |= GTK_STATE_FLAG_ACTIVE; + break; default: break; } From 43f7fb8354fd6a3c7a3d9d0bd245d6006fb74e3a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 24 Oct 2010 00:04:34 +0200 Subject: [PATCH 362/634] GtkThemingEngine: Clear the background for .background class --- gtk/gtkthemingengine.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b80592bb89..dba82ce522 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1278,6 +1278,13 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, SIDE_ALL, junction); cairo_clip (cr); + if (gtk_theming_engine_has_class (engine, "background")) + { + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); /* transparent */ + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_paint (cr); + } + cairo_translate (cr, x, y); cairo_scale (cr, width, height); From 6356f01b06045e31fdbbccf37be4dbd7a1d361e4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Oct 2010 10:24:15 +0200 Subject: [PATCH 363/634] =?UTF-8?q?GtkThemingEngine:=20render=200-radius?= =?UTF-8?q?=20frames=20with=203D-like=2045=C2=B0=20corner=20effect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gtk/gtkthemingengine.c | 59 +++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index dba82ce522..2ca90a1320 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1534,6 +1534,7 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, GtkBorderStyle border_style; gint border_width, radius; GtkJunctionSides junction; + gdouble d1, d2, m; flags = gtk_theming_engine_get_state (engine); junction = gtk_theming_engine_get_junction_sides (engine); @@ -1584,17 +1585,33 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, cairo_set_line_width (cr, border_width); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); + d1 = d2 = 0; + if (border_width > 1) { - gdouble d; + d1 = (gdouble) border_width / 2; + d2 = (gdouble) (border_width - (gint) d1) + 1; + } - d = (gdouble) border_width / 2; - x += d; - y += d; + cairo_save (cr); - d = (gdouble) (border_width - (gint) d) + 1; - width -= d; - height -= d; + m = MIN (width, height); + m /= 2; + + /* Only needed for square frames to have a 3D-like + * feeling, for rounded ones, the arc will ensure + * the stroke is painted to end at 45°. + */ + if (radius == 0) + { + cairo_move_to (cr, x, y + height); + cairo_line_to (cr, x + m, y + height - m); + cairo_line_to (cr, x + width - m, y + m); + cairo_line_to (cr, x + width, y); + cairo_line_to (cr, x + width, y + height); + cairo_close_path (cr); + + cairo_clip (cr); } if (border_style == GTK_BORDER_STYLE_INSET) @@ -1602,19 +1619,41 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, else gdk_cairo_set_source_rgba (cr, border_color); - _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, + _cairo_round_rectangle_sides (cr, (gdouble) radius, + x + d1, y + d1, + width - d2, height - d2, SIDE_BOTTOM | SIDE_RIGHT, junction); cairo_stroke (cr); - if (border_style == GTK_BORDER_STYLE_INSET) + cairo_restore (cr); + + cairo_save (cr); + + if (radius == 0) + { + cairo_move_to (cr, x, y + height); + cairo_line_to (cr, x + m, y + height - m); + cairo_line_to (cr, x + width - m, y + m); + cairo_line_to (cr, x + width, y); + cairo_line_to (cr, x, y); + cairo_close_path (cr); + + cairo_clip (cr); + } + + if (border_style == GTK_BORDER_STYLE_INSET) gdk_cairo_set_source_rgba (cr, border_color); else gdk_cairo_set_source_rgba (cr, &lighter); - _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, + _cairo_round_rectangle_sides (cr, (gdouble) radius, + x + d1, y + d1, + width - d2, height - d2, SIDE_TOP | SIDE_LEFT, junction); cairo_stroke (cr); + cairo_restore (cr); + break; } From 5310ad80704135150440bee501890655525421e8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Oct 2010 13:55:18 +0200 Subject: [PATCH 364/634] GtkStyle: Get to style GtkCellRendererText text. --- gtk/gtkstyle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 34f5d912bf..7c80afb8b5 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1831,7 +1831,7 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "slider"); gtk_style_context_add_class (context, "scrollbar"); } - else if (g_str_has_prefix (detail, "cell_")) + else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; gboolean ruled = FALSE; From 0bd81ef7109fd7110f22c3f102b0107218ccca71 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Oct 2010 13:55:56 +0200 Subject: [PATCH 365/634] GtkCssProvider: Make default style depend more on custom colors. --- gtk/gtkcssprovider.c | 47 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 32d699f3f6..a4c773256d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2823,35 +2823,39 @@ gtk_css_provider_get_default (void) " foreground-color: @fg_color;\n" " text-color: @text_color; \n" " base-color: @base_color; \n" - " border-color: #898089;\n" + " border-color: shade (@bg_color, 0.7);\n" " padding: 2 2; \n" "}\n" "\n" "*:prelight {\n" - " background-color: #eeebe7;\n" - " foreground-color: #000000;\n" - " text-color: #eeebe7; \n" - " base-color: #ffffff; \n" + " background-color: shade (@bg_color, 2.0);\n" + " foreground-color: shade (@fg_color, 1.3);\n" + " text-color: @selected_fg_color;\n" + " base-color: @selected_bg_color;\n" "}\n" "\n" "*:selected {\n" - " background-color: #4b6983;\n" - " foreground-color: #ffffff;\n" - " base-color: #4b6983;\n" - " text-color: #ffffff;\n" + " background-color: @selected_bg_color;\n" + " foreground-color: @selected_fg_color;\n" "}\n" "\n" "*:insensitive {\n" - " background-color: #dcdad5;\n" - " foreground-color: #757575;\n" + " background-color: shade (@bg_color, 0.7);\n" + " foreground-color: shade (@fg_color, 0.7);\n" "}\n" "\n" "GtkTreeView, GtkIconView {\n" - " background-color: #ffffff; \n" + " background-color: @base_color;\n" + " foreground-color: @text_color;\n" + "}\n" + "\n" + "GtkTreeView > row {\n" + " background-color: @base_color;\n" + " foreground-color: @text_color;\n" "}\n" "\n" "GtkTreeView > row:nth-child(odd) { \n" - " background-color: shade(#ffffff, 0.93); \n" + " background-color: shade (@base_color, 0.93); \n" "}\n" "\n" ".tooltip {\n" @@ -2859,10 +2863,6 @@ gtk_css_provider_get_default (void) " foreground-color: @tooltip_fg_color; \n" "}\n" "\n" - "GtkToggleButton:prelight {\n" - " text-color: #000; \n" - "}\n" - "\n" ".button,\n" ".slider {\n" " border-style: outset; \n" @@ -2870,13 +2870,17 @@ gtk_css_provider_get_default (void) "}\n" "\n" ".button:active {\n" - " background-color: #c4c2bd;\n" - " foreground-color: #000000;\n" - " text-color: #c4c2bd; \n" - " base-color: #9c9a94; \n" + " background-color: shade (@bg_color, 0.7);\n" " border-style: inset; \n" "}\n" "\n" + ".button:prelight,\n" + ".slider:prelight {\n" + " background-color: @selected_bg_color;\n" + " foreground-color: @selected_fg_color;\n" + " border-color: shade (@selected_bg_color, 0.7);\n" + "}\n" + "\n" ".trough {\n" " border-style: inset;\n" " border-width: 1;\n" @@ -2890,7 +2894,6 @@ gtk_css_provider_get_default (void) ".viewport {\n" " border-style: inset;\n" " border-width: 2;\n" - " border-color: #9a909a;\n" "}\n" "\n"; From ca44965f330bb96ee2c948869d75842191e50388 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Oct 2010 20:41:36 +0200 Subject: [PATCH 366/634] GtkSymbolicColor: Add gtk_symbolic_color_new_alpha() This function modifies the alpha channel of a color, multiplying it by a factor. --- gtk/gtksymboliccolor.c | 49 +++++++++++++++++++++++++++++++++++++++++- gtk/gtksymboliccolor.h | 2 ++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 92d3eff9e3..f45c8d2046 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -32,6 +32,7 @@ typedef enum { COLOR_TYPE_LITERAL, COLOR_TYPE_NAME, COLOR_TYPE_SHADE, + COLOR_TYPE_ALPHA, COLOR_TYPE_MIX } ColorType; @@ -49,7 +50,7 @@ struct _GtkSymbolicColor { GtkSymbolicColor *color; gdouble factor; - } shade; + } shade, alpha; struct { @@ -165,6 +166,37 @@ gtk_symbolic_color_new_shade (GtkSymbolicColor *color, return symbolic_color; } +/** + * gtk_symbolic_color_new_alpha: + * @color: another #GtkSymbolicColor + * @factor: factor to apply to @color alpha + * + * Creates a symbolic color by modifying the relative alpha + * value of @color. A factor < 1.0 would resolve to a more + * transparent color, while > 1.0 would resolve to a more + * opaque color. + * + * Returns: A newly created #GtkSymbolicColor + * + * Since: 3.0 + **/ +GtkSymbolicColor * +gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, + gdouble factor) +{ + GtkSymbolicColor *symbolic_color; + + g_return_val_if_fail (color != NULL, NULL); + + symbolic_color = g_slice_new0 (GtkSymbolicColor); + symbolic_color->type = COLOR_TYPE_ALPHA; + symbolic_color->alpha.color = gtk_symbolic_color_ref (color); + symbolic_color->alpha.factor = CLAMP (factor, 0, 1); + symbolic_color->ref_count = 1; + + return symbolic_color; +} + /** * gtk_symbolic_color_new_mix: * @color1: color to mix @@ -245,6 +277,9 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) case COLOR_TYPE_SHADE: gtk_symbolic_color_unref (color->shade.color); break; + case COLOR_TYPE_ALPHA: + gtk_symbolic_color_unref (color->alpha.color); + break; case COLOR_TYPE_MIX: gtk_symbolic_color_unref (color->mix.color1); gtk_symbolic_color_unref (color->mix.color2); @@ -315,6 +350,18 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, } break; + case COLOR_TYPE_ALPHA: + { + GdkRGBA alpha; + + if (!gtk_symbolic_color_resolve (color->alpha.color, style_set, &alpha)) + return FALSE; + + *resolved_color = alpha; + resolved_color->alpha = CLAMP (alpha.alpha * color->alpha.factor, 0, 1); + + return TRUE; + } case COLOR_TYPE_MIX: { GdkRGBA color1, color2; diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index ce1d3c6fdc..d52a9d32c5 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -38,6 +38,8 @@ GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkRGBA *color); GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, gdouble factor); +GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, + gdouble factor); GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, GtkSymbolicColor *color2, gdouble factor); From 51b742044a833e2561b90689e8203d7da7d74d1d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Oct 2010 20:44:15 +0200 Subject: [PATCH 367/634] GtkCssProvider: Parse alpha() symbolic colors. The "alpha" symbolic color modifies a passed color's alpha by a factor, the syntax would accept things like: background-color: alpha (@bg_color, 0.8); foreground-color: alpha (shade (@fg_color, 0.8), 0.5); --- gtk/gtkcssprovider.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index a4c773256d..d61a56417a 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1583,12 +1583,19 @@ symbolic_color_parse_str (const gchar *string, *end_ptr = (gchar *) end; } - else if (g_str_has_prefix (str, "shade")) + else if (g_str_has_prefix (str, "shade") || + g_str_has_prefix (str, "alpha")) { GtkSymbolicColor *param_color; + gboolean is_shade = FALSE; gdouble factor; - str += strlen ("shade"); + is_shade = g_str_has_prefix (str, "shade"); + + if (is_shade) + str += strlen ("shade"); + else + str += strlen ("alpha"); SKIP_SPACES (str); @@ -1629,7 +1636,11 @@ symbolic_color_parse_str (const gchar *string, return NULL; } - symbolic_color = gtk_symbolic_color_new_shade (param_color, factor); + if (is_shade) + symbolic_color = gtk_symbolic_color_new_shade (param_color, factor); + else + symbolic_color = gtk_symbolic_color_new_alpha (param_color, factor); + gtk_symbolic_color_unref (param_color); (*end_ptr)++; } From c88e3bfc0c3e89bc09d4b3604fe62e4a3d11b2a5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 26 Oct 2010 00:16:22 +0200 Subject: [PATCH 368/634] GtkStyleSet: Prevent from possible underflow. --- gtk/gtkstyleset.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 94a4136629..6009329bc5 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -309,7 +309,12 @@ compare_property (gconstpointer p1, PropertyNode *key = (PropertyNode *) p1; PropertyNode *node = (PropertyNode *) p2; - return (int) key->property_quark - node->property_quark; + if (key->property_quark > node->property_quark) + return 1; + else if (key->property_quark < node->property_quark) + return -1; + + return 0; } static PropertyNode * From 90de318ab3c29bd3e3854b3501f372e33c35ac51 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 26 Oct 2010 00:43:20 +0200 Subject: [PATCH 369/634] GtkThemingEngine: Add ::name construct only property This property is to be set by theming engines, the name set will be favored over the object type name when registering custom properties, making possible something like: -Clearlooks-border: blah; --- gtk/gtkthemingengine.c | 114 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 4 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 2ca90a1320..e69a1df9e8 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -26,6 +26,7 @@ #include #include +#include "gtkprivate.h" #include "gtk9slice.h" #include "gtkpango.h" @@ -56,13 +57,29 @@ enum { SIDE_ALL = 0xF }; +enum { + PROP_0, + PROP_NAME +}; + struct GtkThemingEnginePrivate { GtkStyleContext *context; + gchar *name; }; #define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate)) +static void gtk_theming_engine_finalize (GObject *object); +static void gtk_theming_engine_impl_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_theming_engine_impl_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + static void gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_t *cr, gdouble x, @@ -179,6 +196,10 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->finalize = gtk_theming_engine_finalize; + object_class->set_property = gtk_theming_engine_impl_set_property; + object_class->get_property = gtk_theming_engine_impl_get_property; + klass->render_check = gtk_theming_engine_render_check; klass->render_option = gtk_theming_engine_render_option; klass->render_arrow = gtk_theming_engine_render_arrow; @@ -193,6 +214,27 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_extension = gtk_theming_engine_render_extension; klass->render_handle = gtk_theming_engine_render_handle; + /** + * GtkThemingEngine:name: + * + * The theming engine name, this name will be used when registering + * custom properties, for a theming engine named "Clearlooks" registering + * a "glossy" custom property, it could be referenced in the CSS file as + * + * + * -Clearlooks-glossy: true; + * + * + * Since: 3.0 + */ + g_object_class_install_property (object_class, + PROP_NAME, + g_param_spec_string ("name", + P_("Name"), + P_("Theming engine name"), + NULL, + G_PARAM_CONSTRUCT_ONLY | GTK_PARAM_READWRITE)); + g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } @@ -202,6 +244,62 @@ gtk_theming_engine_init (GtkThemingEngine *engine) engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine); } +static void +gtk_theming_engine_finalize (GObject *object) +{ + GtkThemingEnginePrivate *priv; + + priv = GTK_THEMING_ENGINE (object)->priv; + g_free (priv->name); + + G_OBJECT_GET_CLASS (gtk_theming_engine_parent_class)->finalize (object); +} + +static void +gtk_theming_engine_impl_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkThemingEnginePrivate *priv; + + priv = GTK_THEMING_ENGINE (object)->priv; + + switch (prop_id) + { + case PROP_NAME: + if (priv->name) + g_free (priv->name); + + priv->name = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_theming_engine_impl_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkThemingEnginePrivate *priv; + + priv = GTK_THEMING_ENGINE (object)->priv; + + switch (prop_id) + { + case PROP_NAME: + g_value_set_string (value, priv->name); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + void _gtk_theming_engine_set_context (GtkThemingEngine *engine, GtkStyleContext *context) @@ -226,8 +324,8 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, * Registers a property so it can be used in the CSS file format, * on the CSS file the property will look like * "-${engine-object-name}-${@property_name}". being - * ${engine-object-name} the same than G_OBJECT_TYPE_NAME(engine) - * would return. + * ${engine-object-name} either the GtkThemingEngine:name property + * or G_OBJECT_TYPE_NAME(engine). * * For any type a @parse_func may be provided, being this function * used for turning any property value (between ':' and ';') in @@ -261,14 +359,22 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, const GValue *default_value, GtkStylePropertyParser parse_func) { - gchar *name; + GtkThemingEnginePrivate *priv; + gchar *engine_name, *name; g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); g_return_if_fail (property_name != NULL); g_return_if_fail (type != G_TYPE_INVALID); g_return_if_fail (default_value != NULL && G_IS_VALUE (default_value)); - name = g_strdup_printf ("-%s-%s", G_OBJECT_TYPE_NAME (engine), property_name); + priv = engine->priv; + + if (priv->name) + engine_name = priv->name; + else + engine_name = G_OBJECT_TYPE_NAME (engine); + + name = g_strdup_printf ("-%s-%s", engine_name, property_name); gtk_style_set_register_property (name, type, default_value, parse_func); g_free (name); } From a8a1d8cd01e7d4c7e710842f5a25073aa27372b7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 27 Oct 2010 23:23:14 +0200 Subject: [PATCH 370/634] GtkThemingEngine: Use ::name when registering style props. --- gtk/gtkthemingengine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index e69a1df9e8..9fa5f272a5 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -325,7 +325,7 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, * on the CSS file the property will look like * "-${engine-object-name}-${@property_name}". being * ${engine-object-name} either the GtkThemingEngine:name property - * or G_OBJECT_TYPE_NAME(engine). + * or G_OBJECT_TYPE_NAME(engine) if the property is unset. * * For any type a @parse_func may be provided, being this function * used for turning any property value (between ':' and ';') in @@ -360,7 +360,8 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, GtkStylePropertyParser parse_func) { GtkThemingEnginePrivate *priv; - gchar *engine_name, *name; + const gchar *engine_name; + gchar *name; g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); g_return_if_fail (property_name != NULL); From 7de2cf3286ad7687c50ef374555ff9d4f5e0a66b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 29 Oct 2010 05:30:36 +0200 Subject: [PATCH 371/634] GtkCssProvider: Fix parsing of concatenated classes. Now selectors such as: GtkWidget#name.class1.class2 #name.class1.class2 .class1.class2 are parsed correctly, being meaningful for a widget defining several classes. --- gtk/gtkcssprovider.c | 51 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d61a56417a..0c845b20cc 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1149,7 +1149,7 @@ scanner_apply_scope (GScanner *scanner, else if (scope == SCOPE_SELECTOR) { scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*@"; - scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_#" G_CSET_A_2_Z; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "-_#." G_CSET_A_2_Z; scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_PSEUDO_CLASS || @@ -1364,6 +1364,28 @@ parse_pseudo_class (GtkCssProvider *css_provider, return G_TOKEN_NONE; } +/* Parses a number of concatenated classes */ +static void +parse_classes (SelectorPath *path, + const gchar *str) +{ + gchar *pos; + + if ((pos = strchr (str, '.')) != NULL) + { + while (pos) + { + *pos = '\0'; + selector_path_prepend_class (path, str); + + str = pos + 1; + pos = strchr (str, '.'); + } + } + else + selector_path_prepend_class (path, str); +} + static GTokenType parse_selector (GtkCssProvider *css_provider, GScanner *scanner, @@ -1388,6 +1410,7 @@ parse_selector (GtkCssProvider *css_provider, scanner->token == '.') { gboolean is_class; + gchar *pos; is_class = (scanner->token == '.'); @@ -1400,9 +1423,18 @@ parse_selector (GtkCssProvider *css_provider, selector_path_prepend_combinator (path, COMBINATOR_CHILD); if (is_class) - selector_path_prepend_class (path, scanner->value.v_identifier); + parse_classes (path, scanner->value.v_identifier); else - selector_path_prepend_name (path, scanner->value.v_identifier); + { + if ((pos = strchr (scanner->value.v_identifier, '.')) != NULL) + *pos = '\0'; + + selector_path_prepend_name (path, scanner->value.v_identifier); + + /* Parse any remaining classes */ + if (pos) + parse_classes (path, pos + 1); + } } else if (g_ascii_isupper (scanner->value.v_identifier[0])) { @@ -1429,9 +1461,18 @@ parse_selector (GtkCssProvider *css_provider, selector_path_prepend_combinator (path, COMBINATOR_CHILD); if (is_class) - selector_path_prepend_class (path, name); + parse_classes (path, name); else - selector_path_prepend_name (path, name); + { + if ((pos = strchr (name, '.')) != NULL) + *pos = '\0'; + + selector_path_prepend_name (path, name); + + /* Parse any remaining classes */ + if (pos) + parse_classes (path, pos + 1); + } } else selector_path_prepend_type (path, scanner->value.v_identifier); From 8ea649e0a0c9e8e70883fcfc10f2141700600247 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 29 Oct 2010 05:33:38 +0200 Subject: [PATCH 372/634] Rely only on fg/bg colors. "foreground-color" has been renamed to just "color" as in regular CSS, and the "text-color" and "base-color" properties have been removed. The default CSS has been changed to have widgets cope with this change. --- gtk/gtkcssprovider.c | 68 ++++++++++++++++-------------- gtk/gtkstyle.c | 34 +++++++++++---- gtk/gtkstyleset.c | 4 +- gtk/gtkthemingengine.c | 95 ++++++++++++------------------------------ 4 files changed, 92 insertions(+), 109 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 0c845b20cc..68cec437df 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -97,12 +97,12 @@ * * /* Theme all widgets defining the class entry */ * .entry { - * foreground-color: #39f1f9; + * color: #39f1f9; * } * * /* Theme spinbuttons' entry */ * GtkSpinButton.entry { - * foreground-color: #900185; + * color: #900185; * } * * @@ -117,19 +117,19 @@ * * /* Theme any label within a notebook */ * GtkNotebook GtkLabel { - * foreground-color: #f90192; + * color: #f90192; * } * * /* Theme labels within notebook tabs */ * GtkNotebook tab:nth-child GtkLabel { - * foreground-color: #703910; + * color: #703910; * } * * /* Theme labels in the any first notebook * tab, both selectors are equivalent */ * GtkNotebook tab:nth-child(first) GtkLabel, * GtkNotebook tab:first-child GtkLabel { - * foreground-color: #89d012; + * color: #89d012; * } * * @@ -278,24 +278,18 @@ * * * background-color - * color - * #GdkRGBA - * + * color + * #GdkRGBA + * * * background-color: #fff; - * foreground-color: @color-name; - * text-color: shade (@color-name, 0.5); - * base-color: mix (@color-name, #f0f, 0.8); + * color: @color-name; + * background-color: shade (@color-name, 0.5); + * color: mix (@color-name, #f0f, 0.8); * * * - * foreground-color - * - * - * text-color - * - * - * base-color + * color * * * font @@ -2872,38 +2866,34 @@ gtk_css_provider_get_default (void) "*,\n" "GtkTreeView > GtkButton {\n" " background-color: @bg_color;\n" - " foreground-color: @fg_color;\n" - " text-color: @text_color; \n" - " base-color: @base_color; \n" + " color: @fg_color;\n" " border-color: shade (@bg_color, 0.7);\n" " padding: 2 2; \n" "}\n" "\n" "*:prelight {\n" " background-color: shade (@bg_color, 2.0);\n" - " foreground-color: shade (@fg_color, 1.3);\n" - " text-color: @selected_fg_color;\n" - " base-color: @selected_bg_color;\n" + " color: shade (@fg_color, 1.3);\n" "}\n" "\n" "*:selected {\n" " background-color: @selected_bg_color;\n" - " foreground-color: @selected_fg_color;\n" + " color: @selected_fg_color;\n" "}\n" "\n" "*:insensitive {\n" " background-color: shade (@bg_color, 0.7);\n" - " foreground-color: shade (@fg_color, 0.7);\n" + " color: shade (@fg_color, 0.7);\n" "}\n" "\n" - "GtkTreeView, GtkIconView {\n" + "GtkTreeView, GtkIconView, GtkTextView {\n" " background-color: @base_color;\n" - " foreground-color: @text_color;\n" + " color: @text_color;\n" "}\n" "\n" "GtkTreeView > row {\n" " background-color: @base_color;\n" - " foreground-color: @text_color;\n" + " color: @text_color;\n" "}\n" "\n" "GtkTreeView > row:nth-child(odd) { \n" @@ -2912,7 +2902,7 @@ gtk_css_provider_get_default (void) "\n" ".tooltip {\n" " background-color: @tooltip_bg_color; \n" - " foreground-color: @tooltip_fg_color; \n" + " color: @tooltip_fg_color; \n" "}\n" "\n" ".button,\n" @@ -2929,7 +2919,7 @@ gtk_css_provider_get_default (void) ".button:prelight,\n" ".slider:prelight {\n" " background-color: @selected_bg_color;\n" - " foreground-color: @selected_fg_color;\n" + " color: @selected_fg_color;\n" " border-color: shade (@selected_bg_color, 0.7);\n" "}\n" "\n" @@ -2941,6 +2931,22 @@ gtk_css_provider_get_default (void) ".entry {\n" " border-style: inset;\n" " border-width: 2;\n" + " background-color: @base_color;\n" + " color: @text_color;\n" + "}\n" + ".check, .radio {\n" + " background-color: @base_color;\n" + " color: @text_color;\n" + "}\n" + "\n" + ".menu.check,\n" + ".menu.radio {\n" + " color: @fg_color;\n" + "}\n" + "\n" + ".menu:hover {\n" + " background-color: @selected_bg_color;\n" + " border-style: none;\n" "}\n" "\n" ".viewport {\n" diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 7c80afb8b5..efb83836b8 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -655,19 +655,19 @@ set_color (GtkStyle *style, break; case GTK_RC_FG: gtk_style_context_get (context, state, - "foreground-color", &color, + "color", &color, NULL); dest = &style->fg[state]; break; case GTK_RC_TEXT: gtk_style_context_get (context, state, - "text-color", &color, + "color", &color, NULL); dest = &style->text[state]; break; case GTK_RC_BASE: gtk_style_context_get (context, state, - "base-color", &color, + "background-color", &color, NULL); dest = &style->base[state]; break; @@ -694,10 +694,28 @@ gtk_style_update_from_context (GtkStyle *style) for (state = GTK_STATE_NORMAL; state <= GTK_STATE_INSENSITIVE; state++) { - set_color (style, priv->context, state, GTK_RC_BG); - set_color (style, priv->context, state, GTK_RC_FG); - set_color (style, priv->context, state, GTK_RC_BASE); - set_color (style, priv->context, state, GTK_RC_TEXT); + if (gtk_style_context_has_class (priv->context, "entry")) + { + gtk_style_context_save (priv->context); + gtk_style_context_remove_class (priv->context, "entry"); + set_color (style, priv->context, state, GTK_RC_BG); + set_color (style, priv->context, state, GTK_RC_FG); + gtk_style_context_restore (priv->context); + + set_color (style, priv->context, state, GTK_RC_BASE); + set_color (style, priv->context, state, GTK_RC_TEXT); + } + else + { + gtk_style_context_save (priv->context); + gtk_style_context_add_class (priv->context, "entry"); + set_color (style, priv->context, state, GTK_RC_BASE); + set_color (style, priv->context, state, GTK_RC_TEXT); + gtk_style_context_restore (priv->context); + + set_color (style, priv->context, state, GTK_RC_BG); + set_color (style, priv->context, state, GTK_RC_FG); + } } if (style->font_desc) @@ -1831,6 +1849,8 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "slider"); gtk_style_context_add_class (context, "scrollbar"); } + else if (strcmp (detail, "menuitem") == 0) + gtk_style_context_add_class (context, "menu"); else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 6009329bc5..e856d29961 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -81,10 +81,8 @@ gtk_style_set_class_init (GtkStyleSetClass *klass) object_class->finalize = gtk_style_set_finalize; /* Initialize default property set */ - gtk_style_set_register_property ("foreground-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_set_register_property ("color", GDK_TYPE_RGBA, NULL, NULL); gtk_style_set_register_property ("background-color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_set_register_property ("text-color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_set_register_property ("base-color", GDK_TYPE_RGBA, NULL, NULL); gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 9fa5f272a5..5360ad0407 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -865,7 +865,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, gdouble width, gdouble height) { - GdkRGBA *fg_color, *base_color, *text_color; + GdkRGBA *fg_color, *bg_color; const GtkWidgetPath *path; GtkStateFlags flags; gint exterior_size, interior_size, thickness, pad; @@ -875,9 +875,8 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_save (cr); gtk_theming_engine_get (engine, flags, - "foreground-color", &fg_color, - "base-color", &base_color, - "text-color", &text_color, + "color", &fg_color, + "background-color", &bg_color, NULL); exterior_size = MIN (width, height); @@ -904,21 +903,15 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1); - gdk_cairo_set_source_rgba (cr, base_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_fill_preserve (cr); - if (gtk_theming_engine_has_class (engine, "cell")) - gdk_cairo_set_source_rgba (cr, text_color); - else - gdk_cairo_set_source_rgba (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_stroke (cr); } - if (gtk_theming_engine_has_class (engine, "menu")) - gdk_cairo_set_source_rgba (cr, fg_color); - else - gdk_cairo_set_source_rgba (cr, text_color); + gdk_cairo_set_source_rgba (cr, fg_color); if (flags & GTK_STATE_FLAG_INCONSISTENT) { @@ -977,8 +970,6 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, cairo_restore (cr); gdk_rgba_free (fg_color); - gdk_rgba_free (base_color); - gdk_rgba_free (text_color); } static void @@ -990,7 +981,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkRGBA *base_color, *fg_color, *text_color; + GdkRGBA *fg_color, *bg_color; const GtkWidgetPath *path; gint exterior_size, interior_size, pad, thickness; gdouble radius; @@ -1002,9 +993,8 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_save (cr); gtk_theming_engine_get (engine, flags, - "foreground-color", &fg_color, - "base-color", &base_color, - "text-color", &text_color, + "color", &fg_color, + "background-color", &bg_color, NULL); exterior_size = MIN (width, height); @@ -1017,7 +1007,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, if (!gtk_theming_engine_has_class (engine, "menu")) { - gdk_cairo_set_source_rgba (cr, base_color); + gdk_cairo_set_source_rgba (cr, bg_color); cairo_arc (cr, x + exterior_size / 2., @@ -1027,19 +1017,13 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_fill_preserve (cr); - if (gtk_theming_engine_has_class (engine, "cell")) - gdk_cairo_set_source_rgba (cr, text_color); - else - gdk_cairo_set_source_rgba (cr, fg_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_set_line_width (cr, 1.); cairo_stroke (cr); } - if (gtk_theming_engine_has_class (engine, "menu")) - gdk_cairo_set_source_rgba (cr, fg_color); - else - gdk_cairo_set_source_rgba (cr, text_color); + gdk_cairo_set_source_rgba (cr, fg_color); /* FIXME: thickness */ thickness = 1; @@ -1088,8 +1072,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_restore (cr); gdk_rgba_free (fg_color); - gdk_rgba_free (base_color); - gdk_rgba_free (text_color); + gdk_rgba_free (bg_color); } static void @@ -1128,7 +1111,7 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, flags = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, flags, - "foreground-color", &fg_color, + "color", &fg_color, NULL); if (flags & GTK_STATE_FLAG_INSENSITIVE) @@ -1350,7 +1333,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble width, gdouble height) { - GdkRGBA *bg_color, *base_color; + GdkRGBA *bg_color; cairo_pattern_t *pattern; GtkStateFlags flags; gboolean running; @@ -1374,7 +1357,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gtk_theming_engine_get (engine, flags, "background-image", &pattern, "background-color", &bg_color, - "base-color", &base_color, "border-radius", &radius, NULL); @@ -1399,7 +1381,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, { cairo_pattern_t *other_pattern; GtkStateFlags other_flags; - GdkRGBA *other_bg, *other_base; + GdkRGBA *other_bg; cairo_pattern_t *new_pattern = NULL; if (flags & GTK_STATE_FLAG_PRELIGHT) @@ -1413,7 +1395,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gtk_theming_engine_get (engine, other_flags, "background-image", &other_pattern, "background-color", &other_bg, - "base-color", &other_base, NULL); if (pattern && other_pattern) @@ -1499,7 +1480,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, else if (pattern || other_pattern) { cairo_pattern_t *p; - GdkRGBA *c; + const GdkRGBA *c; gdouble x0, y0, x1, y1, r0, r1; gint n, i; @@ -1507,13 +1488,13 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, if (pattern) { p = pattern; - c = gtk_theming_engine_has_class (engine, "entry") ? other_base : other_bg; + c = other_bg; progress = 1 - progress; } else { p = other_pattern; - c = gtk_theming_engine_has_class (engine, "entry") ? base_color : bg_color; + c = bg_color; } if (cairo_pattern_get_type (p) == CAIRO_PATTERN_TYPE_LINEAR) @@ -1550,16 +1531,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, const GdkRGBA *color, *other_color; /* Merge just colors */ - if (gtk_theming_engine_has_class (engine, "entry")) - { - color = base_color; - other_color = other_base; - } - else - { - color = bg_color; - other_color = other_bg; - } + color = bg_color; + other_color = other_bg; new_pattern = cairo_pattern_create_rgba (CLAMP (color->red + ((other_color->red - color->red) * progress), 0, 1), CLAMP (color->green + ((other_color->green - color->green) * progress), 0, 1), @@ -1579,9 +1552,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, if (other_bg) gdk_rgba_free (other_bg); - - if (other_base) - gdk_rgba_free (other_base); } cairo_rectangle (cr, 0, 0, 1, 1); @@ -1592,12 +1562,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_pattern_destroy (pattern); } else - { - if (gtk_theming_engine_has_class (engine, "entry")) - gdk_cairo_set_source_rgba (cr, base_color); - else - gdk_cairo_set_source_rgba (cr, bg_color); - } + gdk_cairo_set_source_rgba (cr, bg_color); if (gtk_theming_engine_has_class (engine, "tooltip")) { @@ -1622,7 +1587,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, cairo_restore (cr); - gdk_rgba_free (base_color); gdk_rgba_free (bg_color); } @@ -1780,7 +1744,7 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, gdouble height) { GtkStateFlags flags; - GdkRGBA *bg_color, *fg_color, *base_color; + GdkRGBA *bg_color, *fg_color; double vertical_overshoot; int diameter; double radius; @@ -1795,9 +1759,8 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, flags = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, flags, - "foreground-color", &fg_color, + "color", &fg_color, "background-color", &bg_color, - "base-color", &base_color, NULL); line_width = 1; @@ -1863,10 +1826,7 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, cairo_set_line_width (cr, line_width); - if (flags & GTK_STATE_FLAG_PRELIGHT) - gdk_cairo_set_source_rgba (cr, fg_color); - else - gdk_cairo_set_source_rgba (cr, base_color); + gdk_cairo_set_source_rgba (cr, fg_color); cairo_fill_preserve (cr); @@ -1875,7 +1835,6 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, cairo_restore (cr); - gdk_rgba_free (base_color); gdk_rgba_free (fg_color); gdk_rgba_free (bg_color); } @@ -1897,7 +1856,7 @@ gtk_theming_engine_render_focus (GtkThemingEngine *engine, flags = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, flags, - "foreground-color", &color, + "color", &color, NULL); gtk_theming_engine_get_style (engine, @@ -2044,7 +2003,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, flags = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, flags, - "foreground-color", &fg_color, + "color", &fg_color, NULL); screen = gtk_theming_engine_get_screen (engine); From 1bdd761c3fb9e9b5c33cbb78174b3ae5d391b83e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 29 Oct 2010 06:01:51 +0200 Subject: [PATCH 373/634] GtkWidget: Ensure name changes involve a style context update. --- gtk/gtkwidget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d1765ec4c7..f038d7aea4 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6666,6 +6666,18 @@ gtk_widget_set_name (GtkWidget *widget, g_free (priv->name); priv->name = new_name; + if (priv->path) + { + guint pos; + + pos = gtk_widget_path_length (priv->path) - 1; + gtk_widget_path_iter_set_name (priv->path, pos, + priv->name); + } + + if (priv->context) + gtk_style_context_set_path (priv->context, priv->path); + if (priv->rc_style) gtk_widget_reset_rc_style (widget); From 4acc20abc142356c581dc58328fff408aed7a6b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 29 Oct 2010 06:47:32 +0200 Subject: [PATCH 374/634] s/GtkStyleSet/GtkStyleProperties/ The former name had oddities such as gtk_style_set_set() and such, so the new name is nicer in that regard and not much longer. --- gtk/Makefile.am | 4 +- gtk/gtk.h | 2 +- gtk/gtkcssprovider.c | 22 +- gtk/gtksettings.c | 16 +- gtk/gtkstylecontext.c | 28 +- gtk/{gtkstyleset.c => gtkstyleproperties.c} | 336 ++++++++++---------- gtk/gtkstyleproperties.h | 115 +++++++ gtk/gtkstyleprovider.c | 4 +- gtk/gtkstyleprovider.h | 10 +- gtk/gtkstyleset.h | 115 ------- gtk/gtksymboliccolor.c | 42 +-- gtk/gtkthemingengine.c | 2 +- 12 files changed, 348 insertions(+), 348 deletions(-) rename gtk/{gtkstyleset.c => gtkstyleproperties.c} (69%) create mode 100644 gtk/gtkstyleproperties.h delete mode 100644 gtk/gtkstyleset.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index a4780a9f1a..14bde8ccfd 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -293,8 +293,8 @@ gtk_public_h_sources = \ gtkstatusicon.h \ gtkstock.h \ gtkstylecontext.h \ + gtkstyleproperties.h \ gtkstyleprovider.h \ - gtkstyleset.h \ gtkstyle.h \ gtkswitch.h \ gtksymboliccolor.h \ @@ -601,8 +601,8 @@ gtk_base_c_sources = \ gtkstatusicon.c \ gtkstock.c \ gtkstylecontext.c \ + gtkstyleproperties.c \ gtkstyleprovider.c \ - gtkstyleset.c \ gtkstyle.c \ gtkswitch.c \ gtksymboliccolor.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 92b4c7d21d..36d9a33f04 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -176,8 +176,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 68cec437df..eaf952c4f2 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -961,8 +961,8 @@ css_provider_get_selectors (GtkCssProvider *css_provider, } static void -css_provider_dump_symbolic_colors (GtkCssProvider *css_provider, - GtkStyleSet *set) +css_provider_dump_symbolic_colors (GtkCssProvider *css_provider, + GtkStyleProperties *props) { GtkCssProviderPrivate *priv; GHashTableIter iter; @@ -979,25 +979,25 @@ css_provider_dump_symbolic_colors (GtkCssProvider *css_provider, name = key; color = value; - gtk_style_set_map_color (set, name, color); + gtk_style_properties_map_color (props, name, color); } } -static GtkStyleSet * +static GtkStyleProperties * gtk_css_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) { GtkCssProvider *css_provider; GtkCssProviderPrivate *priv; - GtkStyleSet *set; + GtkStyleProperties *props; GArray *priority_info; guint i; css_provider = GTK_CSS_PROVIDER (provider); + props = gtk_style_properties_new (); priv = css_provider->priv; - set = gtk_style_set_new (); - css_provider_dump_symbolic_colors (css_provider, set); + css_provider_dump_symbolic_colors (css_provider, props); priority_info = css_provider_get_selectors (css_provider, path); for (i = 0; i < priority_info->len; i++) @@ -1018,16 +1018,16 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, * the type is registered or not. */ if (prop[0] == '-' && - !gtk_style_set_lookup_property (prop, NULL, NULL)) + !gtk_style_properties_lookup_property (prop, NULL, NULL)) continue; - gtk_style_set_set_property (set, key, info->state, value); + gtk_style_properties_set_property (props, key, info->state, value); } } g_array_free (priority_info, TRUE); - return set; + return props; } static gboolean @@ -2579,7 +2579,7 @@ parse_rule (GtkCssProvider *css_provider, value_str = g_strstrip (scanner->value.v_identifier); - if (gtk_style_set_lookup_property (prop, &prop_type, &parse_func)) + if (gtk_style_properties_lookup_property (prop, &prop_type, &parse_func)) { GValue *val; diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index d07ce4885b..cbfa7a7d85 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1253,19 +1253,19 @@ gtk_settings_class_init (GtkSettingsClass *class) g_assert (result == PROP_IM_STATUS_STYLE); } -static GtkStyleSet * +static GtkStyleProperties * gtk_settings_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) { PangoFontDescription *font_desc; gchar *font_name, *color_scheme; GtkSettings *settings; - GtkStyleSet *set; + GtkStyleProperties *props; gchar **colors; guint i; settings = GTK_SETTINGS (provider); - set = gtk_style_set_new (); + props = gtk_style_properties_new (); g_object_get (settings, "gtk-font-name", &font_name, @@ -1301,22 +1301,22 @@ gtk_settings_get_style (GtkStyleProvider *provider, continue; color = gtk_symbolic_color_new_literal (&col); - gtk_style_set_map_color (set, name, color); + gtk_style_properties_map_color (props, name, color); gtk_symbolic_color_unref (color); } font_desc = pango_font_description_from_string (font_name); - gtk_style_set_set (set, 0, - "font", font_desc, - NULL); + gtk_style_properties_set (props, 0, + "font", font_desc, + NULL); pango_font_description_free (font_desc); g_strfreev (colors); g_free (color_scheme); g_free (font_name); - return set; + return props; } static void diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 602a83d126..6479c75fe5 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -226,7 +226,7 @@ struct GtkStyleInfo struct StyleData { - GtkStyleSet *store; + GtkStyleProperties *store; GSList *icon_factories; GArray *property_cache; }; @@ -438,7 +438,7 @@ style_data_new (void) StyleData *data; data = g_slice_new0 (StyleData); - data->store = gtk_style_set_new (); + data->store = gtk_style_properties_new (); return data; } @@ -771,7 +771,7 @@ build_properties (GtkStyleContext *context, while ((elem = find_next_candidate (list, global_list)) != NULL) { GtkStyleProviderData *data; - GtkStyleSet *provider_style; + GtkStyleProperties *provider_style; data = elem->data; @@ -784,7 +784,7 @@ build_properties (GtkStyleContext *context, if (provider_style) { - gtk_style_set_merge (style_data->store, provider_style, TRUE); + gtk_style_properties_merge (style_data->store, provider_style, TRUE); g_object_unref (provider_style); } } @@ -902,9 +902,9 @@ style_data_lookup (GtkStyleContext *context) if (priv->theming_engine) g_object_unref (priv->theming_engine); - gtk_style_set_get (data->store, 0, - "engine", &priv->theming_engine, - NULL); + gtk_style_properties_get (data->store, 0, + "engine", &priv->theming_engine, + NULL); return data; } @@ -1198,7 +1198,7 @@ gtk_style_context_get_property (GtkStyleContext *context, g_return_if_fail (priv->widget_path != NULL); data = style_data_lookup (context); - gtk_style_set_get_property (data->store, property, state, value); + gtk_style_properties_get_property (data->store, property, state, value); } /** @@ -1225,7 +1225,7 @@ gtk_style_context_get_valist (GtkStyleContext *context, g_return_if_fail (priv->widget_path != NULL); data = style_data_lookup (context); - gtk_style_set_get_valist (data->store, state, args); + gtk_style_properties_get_valist (data->store, state, args); } /** @@ -1256,7 +1256,7 @@ gtk_style_context_get (GtkStyleContext *context, data = style_data_lookup (context); va_start (args, state); - gtk_style_set_get_valist (data->store, state, args); + gtk_style_properties_get_valist (data->store, state, args); va_end (args); } @@ -2390,7 +2390,7 @@ gtk_style_context_lookup_color (GtkStyleContext *context, g_return_val_if_fail (priv->widget_path != NULL, FALSE); data = style_data_lookup (context); - sym_color = gtk_style_set_lookup_color (data->store, color_name); + sym_color = gtk_style_properties_lookup_color (data->store, color_name); if (!sym_color) return FALSE; @@ -2497,9 +2497,9 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, * state, it will fallback to the normal state as well if necessary. */ data = style_data_lookup (context); - gtk_style_set_get (data->store, flags, - "transition", &desc, - NULL); + gtk_style_properties_get (data->store, flags, + "transition", &desc, + NULL); if (!desc) return; diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleproperties.c similarity index 69% rename from gtk/gtkstyleset.c rename to gtk/gtkstyleproperties.c index e856d29961..df8529bd67 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleproperties.c @@ -25,14 +25,14 @@ #include "gtktypebuiltins.h" #include "gtkstyleprovider.h" -#include "gtkstyleset.h" +#include "gtkstyleproperties.h" #include "gtkprivate.h" #include "gtkthemingengine.h" #include "gtkanimationdescription.h" #include "gtk9slice.h" #include "gtkintl.h" -typedef struct GtkStyleSetPrivate GtkStyleSetPrivate; +typedef struct GtkStylePropertiesPrivate GtkStylePropertiesPrivate; typedef struct PropertyData PropertyData; typedef struct PropertyNode PropertyNode; typedef struct ValueData ValueData; @@ -56,7 +56,7 @@ struct PropertyData GArray *values; }; -struct GtkStyleSetPrivate +struct GtkStylePropertiesPrivate { GHashTable *color_map; GHashTable *properties; @@ -64,50 +64,50 @@ struct GtkStyleSetPrivate static GArray *properties = NULL; -static void gtk_style_set_provider_init (GtkStyleProviderIface *iface); -static void gtk_style_set_finalize (GObject *object); +static void gtk_style_properties_provider_init (GtkStyleProviderIface *iface); +static void gtk_style_properties_finalize (GObject *object); -G_DEFINE_TYPE_EXTENDED (GtkStyleSet, gtk_style_set, G_TYPE_OBJECT, 0, +G_DEFINE_TYPE_EXTENDED (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, - gtk_style_set_provider_init)); + gtk_style_properties_provider_init)); static void -gtk_style_set_class_init (GtkStyleSetClass *klass) +gtk_style_properties_class_init (GtkStylePropertiesClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GValue val = { 0 }; - object_class->finalize = gtk_style_set_finalize; + object_class->finalize = gtk_style_properties_finalize; /* Initialize default property set */ - gtk_style_set_register_property ("color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_set_register_property ("background-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_properties_register_property ("color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_properties_register_property ("background-color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_set_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); + gtk_style_properties_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); - gtk_style_set_register_property ("margin", GTK_TYPE_BORDER, NULL, NULL); - gtk_style_set_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); + gtk_style_properties_register_property ("margin", GTK_TYPE_BORDER, NULL, NULL); + gtk_style_properties_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); - gtk_style_set_register_property ("border-width", G_TYPE_INT, NULL, NULL); - gtk_style_set_register_property ("border-radius", G_TYPE_INT, NULL, NULL); - gtk_style_set_register_property ("border-style", GTK_TYPE_BORDER_STYLE, NULL, NULL); - gtk_style_set_register_property ("border-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_properties_register_property ("border-width", G_TYPE_INT, NULL, NULL); + gtk_style_properties_register_property ("border-radius", G_TYPE_INT, NULL, NULL); + gtk_style_properties_register_property ("border-style", GTK_TYPE_BORDER_STYLE, NULL, NULL); + gtk_style_properties_register_property ("border-color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_set_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); - gtk_style_set_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); + gtk_style_properties_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); + gtk_style_properties_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); g_value_init (&val, GTK_TYPE_THEMING_ENGINE); g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); - gtk_style_set_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); + gtk_style_properties_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); g_value_unset (&val); g_value_init (&val, GTK_TYPE_ANIMATION_DESCRIPTION); g_value_take_boxed (&val, gtk_animation_description_new (0, GTK_TIMELINE_PROGRESS_LINEAR)); - gtk_style_set_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, &val, NULL); + gtk_style_properties_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, &val, NULL); g_value_unset (&val); - g_type_class_add_private (object_class, sizeof (GtkStyleSetPrivate)); + g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate)); } static PropertyData * @@ -258,46 +258,46 @@ property_data_match_state (PropertyData *data, } static void -gtk_style_set_init (GtkStyleSet *set) +gtk_style_properties_init (GtkStyleProperties *props) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; - priv = set->priv = G_TYPE_INSTANCE_GET_PRIVATE (set, - GTK_TYPE_STYLE_SET, - GtkStyleSetPrivate); + priv = props->priv = G_TYPE_INSTANCE_GET_PRIVATE (props, + GTK_TYPE_STYLE_PROPERTIES, + GtkStylePropertiesPrivate); priv->properties = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) property_data_free); } static void -gtk_style_set_finalize (GObject *object) +gtk_style_properties_finalize (GObject *object) { - GtkStyleSetPrivate *priv; - GtkStyleSet *set; + GtkStylePropertiesPrivate *priv; + GtkStyleProperties *props; - set = GTK_STYLE_SET (object); - priv = set->priv; + props = GTK_STYLE_PROPERTIES (object); + priv = props->priv; g_hash_table_destroy (priv->properties); if (priv->color_map) g_hash_table_destroy (priv->color_map); - G_OBJECT_CLASS (gtk_style_set_parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_style_properties_parent_class)->finalize (object); } -GtkStyleSet * -gtk_style_set_get_style (GtkStyleProvider *provider, - GtkWidgetPath *path) +GtkStyleProperties * +gtk_style_properties_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) { /* Return style set itself */ return g_object_ref (provider); } static void -gtk_style_set_provider_init (GtkStyleProviderIface *iface) +gtk_style_properties_provider_init (GtkStyleProviderIface *iface) { - iface->get_style = gtk_style_set_get_style; + iface->get_style = gtk_style_properties_get_style; } static int @@ -335,7 +335,7 @@ property_node_lookup (GQuark quark) /* Property registration functions */ /** - * gtk_style_set_register_property: + * gtk_style_properties_register_property: * @property_name: property name to register * @type: #GType the property will hold * @default_value: default value for this property @@ -349,10 +349,10 @@ property_node_lookup (GQuark quark) * Since: 3.0 **/ void -gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func) +gtk_style_properties_register_property (const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func) { PropertyNode *node, new = { 0 }; GQuark quark; @@ -401,7 +401,7 @@ gtk_style_set_register_property (const gchar *property_name, } /** - * gtk_style_set_lookup_property: + * gtk_style_properties_lookup_property: * @property_name: property name to look up * @type: (out): return location for the looked up property type * @parse_func: (out): return value for the parse function @@ -415,19 +415,19 @@ gtk_style_set_register_property (const gchar *property_name, * Since: 3.0 **/ gboolean -gtk_style_set_lookup_property (const gchar *property_name, - GType *type, - GtkStylePropertyParser *parse_func) +gtk_style_properties_lookup_property (const gchar *property_name, + GType *type, + GtkStylePropertyParser *parse_func) { PropertyNode *node; - GtkStyleSetClass *klass; + GtkStylePropertiesClass *klass; gboolean found = FALSE; GQuark quark; gint i; g_return_val_if_fail (property_name != NULL, FALSE); - klass = g_type_class_ref (GTK_TYPE_STYLE_SET); + klass = g_type_class_ref (GTK_TYPE_STYLE_PROPERTIES); quark = g_quark_try_string (property_name); if (quark == 0) @@ -460,44 +460,44 @@ gtk_style_set_lookup_property (const gchar *property_name, return found; } -/* GtkStyleSet methods */ +/* GtkStyleProperties methods */ /** - * gtk_style_set_new: + * gtk_style_properties_new: * - * Returns a newly created #GtkStyleSet + * Returns a newly created #GtkStyleProperties * - * Returns: a new #GtkStyleSet + * Returns: a new #GtkStyleProperties **/ -GtkStyleSet * -gtk_style_set_new (void) +GtkStyleProperties * +gtk_style_properties_new (void) { - return g_object_new (GTK_TYPE_STYLE_SET, NULL); + return g_object_new (GTK_TYPE_STYLE_PROPERTIES, NULL); } /** - * gtk_style_set_map_color: - * @set: a #GtkStyleSet + * gtk_style_properties_map_color: + * @props: a #GtkStyleProperties * @name: color name * @color: #GtkSymbolicColor to map @name to * * Maps @color so it can be referenced by @name. See - * gtk_style_set_lookup_color() + * gtk_style_properties_lookup_color() * * Since: 3.0 **/ void -gtk_style_set_map_color (GtkStyleSet *set, - const gchar *name, - GtkSymbolicColor *color) +gtk_style_properties_map_color (GtkStyleProperties *props, + const gchar *name, + GtkSymbolicColor *color) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); g_return_if_fail (name != NULL); g_return_if_fail (color != NULL); - priv = set->priv; + priv = props->priv; if (G_UNLIKELY (!priv->color_map)) priv->color_map = g_hash_table_new_full (g_str_hash, @@ -511,8 +511,8 @@ gtk_style_set_map_color (GtkStyleSet *set, } /** - * gtk_style_set_lookup_color: - * @set: a #GtkStyleSet + * gtk_style_properties_lookup_color: + * @props: a #GtkStyleProperties * @name: color name to lookup * * Returns the symbolic color that is mapped @@ -523,15 +523,15 @@ gtk_style_set_map_color (GtkStyleSet *set, * Since: 3.0 **/ GtkSymbolicColor * -gtk_style_set_lookup_color (GtkStyleSet *set, - const gchar *name) +gtk_style_properties_lookup_color (GtkStyleProperties *props, + const gchar *name) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; - g_return_val_if_fail (GTK_IS_STYLE_SET (set), NULL); + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL); g_return_val_if_fail (name != NULL, NULL); - priv = set->priv; + priv = props->priv; if (!priv->color_map) return NULL; @@ -540,29 +540,29 @@ gtk_style_set_lookup_color (GtkStyleSet *set, } /** - * gtk_style_set_set_property: - * @set: a #GtkStyleSet + * gtk_style_properties_set_property: + * @props: a #GtkStyleProperties * @property: styling property to set * @state: state to set the value for * @value: new value for the property * - * Sets a styling property in @set. + * Sets a styling property in @props. * * Since: 3.0 **/ void -gtk_style_set_set_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state, - const GValue *value) +gtk_style_properties_set_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state, + const GValue *value) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; PropertyNode *node; PropertyData *prop; GType value_type; GValue *val; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); g_return_if_fail (property != NULL); g_return_if_fail (value != NULL); @@ -589,7 +589,7 @@ gtk_style_set_set_property (GtkStyleSet *set, else g_return_if_fail (node->property_type == value_type); - priv = set->priv; + priv = props->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -617,26 +617,26 @@ gtk_style_set_set_property (GtkStyleSet *set, } /** - * gtk_style_set_set_valist: - * @set: a #GtkStyleSet + * gtk_style_properties_set_valist: + * @props: a #GtkStyleProperties * @state: state to set the values for * @args: va_list of property name/value pairs, followed by %NULL * - * Sets several style properties on @set. + * Sets several style properties on @props. * * Since: 3.0 **/ void -gtk_style_set_set_valist (GtkStyleSet *set, - GtkStateFlags state, - va_list args) +gtk_style_properties_set_valist (GtkStyleProperties *props, + GtkStateFlags state, + va_list args) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; const gchar *property_name; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); - priv = set->priv; + priv = props->priv; property_name = va_arg (args, const gchar *); while (property_name) @@ -686,37 +686,37 @@ gtk_style_set_set_valist (GtkStyleSet *set, } /** - * gtk_style_set_set: - * @set: a #GtkStyleSet + * gtk_style_properties_set: + * @props: a #GtkStyleProperties * @state: state to set the values for * @...: property name/value pairs, followed by %NULL * - * Sets several style properties on @set. + * Sets several style properties on @props. * * Since: 3.0 **/ void -gtk_style_set_set (GtkStyleSet *set, - GtkStateFlags state, - ...) +gtk_style_properties_set (GtkStyleProperties *props, + GtkStateFlags state, + ...) { va_list args; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); va_start (args, state); - gtk_style_set_set_valist (set, state, args); + gtk_style_properties_set_valist (props, state, args); va_end (args); } static gboolean -resolve_color (GtkStyleSet *set, - GValue *value) +resolve_color (GtkStyleProperties *props, + GValue *value) { GdkRGBA color; /* Resolve symbolic color to GdkRGBA */ - if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), set, &color)) + if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &color)) return FALSE; /* Store it back, this is where GdkRGBA caching happens */ @@ -728,12 +728,12 @@ resolve_color (GtkStyleSet *set, } static gboolean -resolve_gradient (GtkStyleSet *set, - GValue *value) +resolve_gradient (GtkStyleProperties *props, + GValue *value) { cairo_pattern_t *gradient; - if (!gtk_gradient_resolve (g_value_get_boxed (value), set, &gradient)) + if (!gtk_gradient_resolve (g_value_get_boxed (value), props, &gradient)) return FALSE; /* Store it back, this is where cairo_pattern_t caching happens */ @@ -745,31 +745,31 @@ resolve_gradient (GtkStyleSet *set, } /** - * gtk_style_set_get_property: - * @set: a #GtkStyleSet + * gtk_style_properties_get_property: + * @props: a #GtkStyleProperties * @property: style property name * @state: state to retrieve the property value for * @value: (out) (transfer full): return location for the style property value. * - * Gets a style property from @set for the given state. When done with @value, + * Gets a style property from @props for the given state. When done with @value, * g_value_unset() needs to be called to free any allocated memory. * - * Returns: %TRUE if the property exists in @set, %FALSE otherwise + * Returns: %TRUE if the property exists in @props, %FALSE otherwise * * Since: 3.0 **/ gboolean -gtk_style_set_get_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state, - GValue *value) +gtk_style_properties_get_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state, + GValue *value) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; PropertyNode *node; PropertyData *prop; GValue *val; - g_return_val_if_fail (GTK_IS_STYLE_SET (set), FALSE); + 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); @@ -781,7 +781,7 @@ gtk_style_set_get_property (GtkStyleSet *set, return FALSE; } - priv = set->priv; + priv = props->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -801,14 +801,14 @@ gtk_style_set_get_property (GtkStyleSet *set, { g_return_val_if_fail (node->property_type == GDK_TYPE_RGBA, FALSE); - if (!resolve_color (set, val)) + if (!resolve_color (props, val)) return FALSE; } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { g_return_val_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); - if (!resolve_gradient (set, val)) + if (!resolve_gradient (props, val)) return FALSE; } @@ -818,26 +818,26 @@ gtk_style_set_get_property (GtkStyleSet *set, } /** - * gtk_style_set_get_valist: - * @set: a #GtkStyleSet + * gtk_style_properties_get_valist: + * @props: a #GtkStyleProperties * @state: state to retrieve the property values for * @args: va_list of property name/return location pairs, followed by %NULL * - * Retrieves several style property values from @set for a given state. + * Retrieves several style property values from @props for a given state. * * Since: 3.0 **/ void -gtk_style_set_get_valist (GtkStyleSet *set, - GtkStateFlags state, - va_list args) +gtk_style_properties_get_valist (GtkStyleProperties *props, + GtkStateFlags state, + va_list args) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; const gchar *property_name; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); - priv = set->priv; + priv = props->priv; property_name = va_arg (args, const gchar *); while (property_name) @@ -868,14 +868,14 @@ gtk_style_set_get_valist (GtkStyleSet *set, { g_return_if_fail (node->property_type == GDK_TYPE_RGBA); - if (!resolve_color (set, val)) + if (!resolve_color (props, val)) val = &node->default_value; } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { g_return_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN); - if (!resolve_gradient (set, val)) + if (!resolve_gradient (props, val)) val = &node->default_value; } @@ -893,51 +893,51 @@ gtk_style_set_get_valist (GtkStyleSet *set, } /** - * gtk_style_set_get: - * @set: a #GtkStyleSet + * gtk_style_properties_get: + * @props: a #GtkStyleProperties * @state: state to retrieve the property values for * @...: property name /return value pairs, followed by %NULL * - * Retrieves several style property values from @set for a + * Retrieves several style property values from @props for a * given state. * * Since: 3.0 **/ void -gtk_style_set_get (GtkStyleSet *set, - GtkStateFlags state, - ...) +gtk_style_properties_get (GtkStyleProperties *props, + GtkStateFlags state, + ...) { va_list args; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); va_start (args, state); - gtk_style_set_get_valist (set, state, args); + gtk_style_properties_get_valist (props, state, args); va_end (args); } /** - * gtk_style_set_unset_property: - * @set: a #GtkStyleSet + * gtk_style_properties_unset_property: + * @props: a #GtkStyleProperties * @property: property to unset * @state: state to unset * - * Unsets a style property in @set. + * Unsets a style property in @props. * * Since: 3.0 **/ void -gtk_style_set_unset_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state) +gtk_style_properties_unset_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; PropertyNode *node; PropertyData *prop; guint pos; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); g_return_if_fail (property != NULL); node = property_node_lookup (g_quark_try_string (property)); @@ -948,7 +948,7 @@ gtk_style_set_unset_property (GtkStyleSet *set, return; } - priv = set->priv; + priv = props->priv; prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); @@ -969,49 +969,49 @@ gtk_style_set_unset_property (GtkStyleSet *set, } /** - * gtk_style_set_clear: - * @set: a #GtkStyleSet + * gtk_style_properties_clear: + * @props: a #GtkStyleProperties * - * Clears all style information from @set. + * Clears all style information from @props. **/ void -gtk_style_set_clear (GtkStyleSet *set) +gtk_style_properties_clear (GtkStyleProperties *props) { - GtkStyleSetPrivate *priv; + GtkStylePropertiesPrivate *priv; - g_return_if_fail (GTK_IS_STYLE_SET (set)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); - priv = set->priv; + priv = props->priv; g_hash_table_remove_all (priv->properties); } /** - * gtk_style_set_merge: - * @set: a #GtkStyleSet - * @set_to_merge: a second #GtkStyleSet + * gtk_style_properties_merge: + * @props: a #GtkStyleProperties + * @props_to_merge: a second #GtkStyleProperties * @replace: whether to replace values or not * - * Merges into @set all the style information contained - * in @set_to_merge. If @replace is %TRUE, the values + * Merges into @props all the style information contained + * in @props_to_merge. If @replace is %TRUE, the values * will be overwritten, if it is %FALSE, the older values * will prevail. * * Since: 3.0 **/ void -gtk_style_set_merge (GtkStyleSet *set, - const GtkStyleSet *set_to_merge, - gboolean replace) +gtk_style_properties_merge (GtkStyleProperties *props, + const GtkStyleProperties *props_to_merge, + gboolean replace) { - GtkStyleSetPrivate *priv, *priv_to_merge; + GtkStylePropertiesPrivate *priv, *priv_to_merge; GHashTableIter iter; gpointer key, value; - g_return_if_fail (GTK_IS_STYLE_SET (set)); - g_return_if_fail (GTK_IS_STYLE_SET (set_to_merge)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props_to_merge)); - priv = set->priv; - priv_to_merge = set_to_merge->priv; + priv = props->priv; + priv_to_merge = props_to_merge->priv; /* Merge symbolic color map */ if (priv_to_merge->color_map) @@ -1030,7 +1030,7 @@ gtk_style_set_merge (GtkStyleSet *set, g_hash_table_lookup (priv->color_map, name)) continue; - gtk_style_set_map_color (set, name, color); + gtk_style_properties_map_color (props, name, color); } } diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h new file mode 100644 index 0000000000..b12c223b1b --- /dev/null +++ b/gtk/gtkstyleproperties.h @@ -0,0 +1,115 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_STYLE_PROPERTIES_H__ +#define __GTK_STYLE_PROPERTIES_H__ + +#include +#include +#include "gtkenums.h" +#include "gtksymboliccolor.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_STYLE_PROPERTIES (gtk_style_properties_get_type ()) +#define GTK_STYLE_PROPERTIES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_PROPERTIES, GtkStyleProperties)) +#define GTK_STYLE_PROPERTIES_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_PROPERTIES, GtkStylePropertiesClass)) +#define GTK_IS_STYLE_PROPERTIES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_PROPERTIES)) +#define GTK_IS_STYLE_PROPERTIES_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_PROPERTIES)) +#define GTK_STYLE_PROPERTIES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_PROPERTIES, GtkStylePropertiesClass)) + +typedef struct _GtkStyleProperties GtkStyleProperties; +typedef struct _GtkStylePropertiesClass GtkStylePropertiesClass; + +struct _GtkStyleProperties +{ + GObject parent_object; + gpointer priv; +}; + +struct _GtkStylePropertiesClass +{ + GObjectClass parent_class; +}; + +typedef gboolean (* GtkStylePropertyParser) (const gchar *string, + GValue *value, + GError **error); + +GType gtk_style_properties_get_type (void) G_GNUC_CONST; + +/* Functions to register style properties */ +void gtk_style_properties_register_property (const gchar *property_name, + GType type, + const GValue *default_value, + GtkStylePropertyParser parse_func); +gboolean gtk_style_properties_lookup_property (const gchar *property_name, + GType *type, + GtkStylePropertyParser *parse_func); + +GtkStyleProperties * gtk_style_properties_new (void); + +void gtk_style_properties_map_color (GtkStyleProperties *props, + const gchar *name, + GtkSymbolicColor *color); +GtkSymbolicColor * gtk_style_properties_lookup_color (GtkStyleProperties *set, + const gchar *name); + +void gtk_style_properties_set_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state, + const GValue *value); +void gtk_style_properties_set_valist (GtkStyleProperties *props, + GtkStateFlags state, + va_list args); +void gtk_style_properties_set (GtkStyleProperties *props, + GtkStateFlags state, + ...) G_GNUC_NULL_TERMINATED; + +gboolean gtk_style_properties_get_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state, + GValue *value); +void gtk_style_properties_get_valist (GtkStyleProperties *props, + GtkStateFlags state, + va_list args); +void gtk_style_properties_get (GtkStyleProperties *props, + GtkStateFlags state, + ...) G_GNUC_NULL_TERMINATED; + +void gtk_style_properties_unset_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state); + +void gtk_style_properties_clear (GtkStyleProperties *props); + +void gtk_style_properties_merge (GtkStyleProperties *props, + const GtkStyleProperties *props_to_merge, + gboolean replace); + +gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleProperties *props, + GdkRGBA *resolved_color); +gboolean gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleProperties *props, + cairo_pattern_t **resolved_gradient); + +G_END_DECLS + +#endif /* __GTK_STYLE_PROPERTIES_H__ */ diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 2a9d2fc5e5..0f1312f34f 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -62,11 +62,11 @@ gtk_style_provider_iface_init (gpointer g_iface) * Returns the style settings affecting a widget defined by @path, or %NULL if * @provider doesn't contemplate styling @path. * - * Returns: a #GtkStyleSet containing the style settings affecting @path + * Returns: a #GtkStyleProperties containing the style settings affecting @path * * Since: 3.0 **/ -GtkStyleSet * +GtkStyleProperties * gtk_style_provider_get_style (GtkStyleProvider *provider, GtkWidgetPath *path) { diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 0f763a2b41..9e67a3286d 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -23,7 +23,7 @@ #include #include "gtkwidgetpath.h" #include "gtkiconfactory.h" -#include "gtkstyleset.h" +#include "gtkstyleproperties.h" #include "gtkenums.h" G_BEGIN_DECLS @@ -52,8 +52,8 @@ struct _GtkStyleProviderIface { GTypeInterface g_iface; - GtkStyleSet * (* get_style) (GtkStyleProvider *provider, - GtkWidgetPath *path); + GtkStyleProperties * (* get_style) (GtkStyleProvider *provider, + GtkWidgetPath *path); gboolean (* get_style_property) (GtkStyleProvider *provider, GtkWidgetPath *path, @@ -66,8 +66,8 @@ struct _GtkStyleProviderIface GType gtk_style_provider_get_type (void) G_GNUC_CONST; -GtkStyleSet *gtk_style_provider_get_style (GtkStyleProvider *provider, - GtkWidgetPath *path); +GtkStyleProperties *gtk_style_provider_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path); gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, GtkWidgetPath *path, diff --git a/gtk/gtkstyleset.h b/gtk/gtkstyleset.h deleted file mode 100644 index 60544ad583..0000000000 --- a/gtk/gtkstyleset.h +++ /dev/null @@ -1,115 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2010 Carlos Garnacho - * - * 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_STYLE_SET_H__ -#define __GTK_STYLE_SET_H__ - -#include -#include -#include "gtkenums.h" -#include "gtksymboliccolor.h" - -G_BEGIN_DECLS - -#define GTK_TYPE_STYLE_SET (gtk_style_set_get_type ()) -#define GTK_STYLE_SET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_SET, GtkStyleSet)) -#define GTK_STYLE_SET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_SET, GtkStyleSetClass)) -#define GTK_IS_STYLE_SET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_SET)) -#define GTK_IS_STYLE_SET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_SET)) -#define GTK_STYLE_SET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_SET, GtkStyleSetClass)) - -typedef struct _GtkStyleSet GtkStyleSet; -typedef struct _GtkStyleSetClass GtkStyleSetClass; - -struct _GtkStyleSet -{ - GObject parent_object; - gpointer priv; -}; - -struct _GtkStyleSetClass -{ - GObjectClass parent_class; -}; - -typedef gboolean (* GtkStylePropertyParser) (const gchar *string, - GValue *value, - GError **error); - -GType gtk_style_set_get_type (void) G_GNUC_CONST; - -/* Functions to register style properties */ -void gtk_style_set_register_property (const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func); -gboolean gtk_style_set_lookup_property (const gchar *property_name, - GType *type, - GtkStylePropertyParser *parse_func); - -GtkStyleSet * gtk_style_set_new (void); - -void gtk_style_set_map_color (GtkStyleSet *set, - const gchar *name, - GtkSymbolicColor *color); -GtkSymbolicColor * gtk_style_set_lookup_color (GtkStyleSet *set, - const gchar *name); - -void gtk_style_set_set_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state, - const GValue *value); -void gtk_style_set_set_valist (GtkStyleSet *set, - GtkStateFlags state, - va_list args); -void gtk_style_set_set (GtkStyleSet *set, - GtkStateFlags state, - ...) G_GNUC_NULL_TERMINATED; - -gboolean gtk_style_set_get_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state, - GValue *value); -void gtk_style_set_get_valist (GtkStyleSet *set, - GtkStateFlags state, - va_list args); -void gtk_style_set_get (GtkStyleSet *set, - GtkStateFlags state, - ...) G_GNUC_NULL_TERMINATED; - -void gtk_style_set_unset_property (GtkStyleSet *set, - const gchar *property, - GtkStateFlags state); - -void gtk_style_set_clear (GtkStyleSet *set); - -void gtk_style_set_merge (GtkStyleSet *set, - const GtkStyleSet *set_to_merge, - gboolean replace); - -gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GtkStyleSet *style_set, - GdkRGBA *resolved_color); -gboolean gtk_gradient_resolve (GtkGradient *gradient, - GtkStyleSet *style_set, - cairo_pattern_t **resolved_gradient); - -G_END_DECLS - -#endif /* __GTK_STYLE_PROPERTY_SET_H__ */ diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index f45c8d2046..c37313d198 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -19,7 +19,7 @@ #include "config.h" #include "gtksymboliccolor.h" -#include "gtkstyleset.h" +#include "gtkstyleproperties.h" #include "gtkintl.h" G_DEFINE_BOXED_TYPE (GtkSymbolicColor, gtk_symbolic_color, @@ -114,7 +114,7 @@ gtk_symbolic_color_new_literal (GdkRGBA *color) * * Creates a symbolic color pointing to an unresolved named * color. See gtk_style_context_lookup_color() and - * gtk_style_set_lookup_color(). + * gtk_style_properties_lookup_color(). * * Returns: a newly created #GtkSymbolicColor * @@ -295,25 +295,25 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) /** * gtk_symbolic_color_resolve: * @color: a #GtkSymbolicColor - * @style_set: #GtkStyleSet to use when resolving named colors + * @props: #GtkStyleProperties to use when resolving named colors * @resolved_color: (out): return location for the resolved color * * If @color is resolvable, @resolved_color will be filled in * with the resolved color, and %TRUE will be returned. Generally, * if @color can't be resolved, it is due to it being defined on - * top of a named color that doesn't exist in @style_set. + * top of a named color that doesn't exist in @props. * * Returns: %TRUE if the color has been resolved * * Since: 3.0 **/ gboolean -gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GtkStyleSet *style_set, - GdkRGBA *resolved_color) +gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleProperties *props, + GdkRGBA *resolved_color) { g_return_val_if_fail (color != NULL, FALSE); - g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); g_return_val_if_fail (resolved_color != NULL, FALSE); switch (color->type) @@ -325,12 +325,12 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GtkSymbolicColor *named_color; - named_color = gtk_style_set_lookup_color (style_set, color->name); + named_color = gtk_style_properties_lookup_color (props, color->name); if (!named_color) return FALSE; - return gtk_symbolic_color_resolve (named_color, style_set, resolved_color); + return gtk_symbolic_color_resolve (named_color, props, resolved_color); } break; @@ -338,7 +338,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GdkRGBA shade; - if (!gtk_symbolic_color_resolve (color->shade.color, style_set, &shade)) + if (!gtk_symbolic_color_resolve (color->shade.color, props, &shade)) return FALSE; resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 1); @@ -354,7 +354,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GdkRGBA alpha; - if (!gtk_symbolic_color_resolve (color->alpha.color, style_set, &alpha)) + if (!gtk_symbolic_color_resolve (color->alpha.color, props, &alpha)) return FALSE; *resolved_color = alpha; @@ -366,10 +366,10 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GdkRGBA color1, color2; - if (!gtk_symbolic_color_resolve (color->mix.color1, style_set, &color1)) + if (!gtk_symbolic_color_resolve (color->mix.color1, props, &color1)) return FALSE; - if (!gtk_symbolic_color_resolve (color->mix.color2, style_set, &color2)) + if (!gtk_symbolic_color_resolve (color->mix.color2, props, &color2)) return FALSE; resolved_color->red = CLAMP (color1.red + ((color2.red - color1.red) * color->mix.factor), 0, 1); @@ -549,29 +549,29 @@ gtk_gradient_unref (GtkGradient *gradient) /** * gtk_gradient_resolve: * @gradient: a #GtkGradient - * @style_set: #GtkStyleSet to use when resolving named colors + * @props: #GtkStyleProperties to use when resolving named colors * @resolved_gradient: (out): return location for the resolved pattern * * If @gradient is resolvable, @resolved_gradient will be filled in * with the resolved gradient as a cairo_pattern_t, and %TRUE will * be returned. Generally, if @gradient can't be resolved, it is * due to it being defined on top of a named color that doesn't - * exist in @style_set. + * exist in @props. * * Returns: %TRUE if the gradient has been resolved * * Since: 3.0 **/ gboolean -gtk_gradient_resolve (GtkGradient *gradient, - GtkStyleSet *style_set, - cairo_pattern_t **resolved_gradient) +gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleProperties *props, + cairo_pattern_t **resolved_gradient) { cairo_pattern_t *pattern; guint i; g_return_val_if_fail (gradient != NULL, FALSE); - g_return_val_if_fail (GTK_IS_STYLE_SET (style_set), FALSE); + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); g_return_val_if_fail (resolved_gradient != NULL, FALSE); if (gradient->radius0 == 0 && gradient->radius1 == 0) @@ -590,7 +590,7 @@ gtk_gradient_resolve (GtkGradient *gradient, stop = &g_array_index (gradient->stops, ColorStop, i); - if (!gtk_symbolic_color_resolve (stop->color, style_set, &color)) + if (!gtk_symbolic_color_resolve (stop->color, props, &color)) { cairo_pattern_destroy (pattern); return FALSE; diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 5360ad0407..ca3b3139f5 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -376,7 +376,7 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, engine_name = G_OBJECT_TYPE_NAME (engine); name = g_strdup_printf ("-%s-%s", engine_name, property_name); - gtk_style_set_register_property (name, type, default_value, parse_func); + gtk_style_properties_register_property (name, type, default_value, parse_func); g_free (name); } From 34b91a74e5d2cde582167d4fb34b7cec09cbc5fc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 30 Oct 2010 19:53:43 +0200 Subject: [PATCH 375/634] Document missing value in GtkStateFlags --- gtk/gtkenums.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 99a52cf394..44fa55b120 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -565,6 +565,7 @@ typedef enum * @GTK_STATE_FLAG_ACTIVE: Widget is active. * @GTK_STATE_FLAG_PRELIGHT: Widget has a mouse pointer over it. * @GTK_STATE_FLAG_SELECTED: Widget is selected. + * @GTK_STATE_FLAG_INSENSITIVE: Widget is insensitive. * @GTK_STATE_FLAG_INCONSISTENT: Widget is inconsistent. * @GTK_STATE_FLAG_FOCUSED: Widget has the keyboard focus. * From cd98204619f25db976fc2b8b99f2c08966aa3fbc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 30 Oct 2010 21:48:38 +0200 Subject: [PATCH 376/634] Implement widget states as a set of flags gtk_widget_(set|unset|get)_state_flags() has been added, using GtkStateFlags to represent the widget state. GtkStateType API has been implemented on top of the new one. --- docs/reference/gtk/gtk3-sections.txt | 3 + gtk/gtkmarshalers.list | 1 + gtk/gtkwidget.c | 338 ++++++++++++++++++++------- gtk/gtkwidget.h | 9 + 4 files changed, 271 insertions(+), 80 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 2da137cf31..d47480836b 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4933,6 +4933,9 @@ gtk_widget_is_sensitive gtk_widget_get_state gtk_widget_get_visible gtk_widget_set_visible +gtk_widget_set_state_flags +gtk_widget_unset_state_flags +gtk_widget_get_state_flags gtk_widget_has_default gtk_widget_has_focus gtk_widget_has_grab diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list index 22af46d610..10f0dfd689 100644 --- a/gtk/gtkmarshalers.list +++ b/gtk/gtkmarshalers.list @@ -69,6 +69,7 @@ VOID:ENUM,FLOAT,BOOLEAN VOID:ENUM,INT VOID:ENUM,INT,BOOLEAN VOID:ENUM,BOXED +VOID:FLAGS VOID:INT VOID:INT,BOOLEAN VOID:INT,INT diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f038d7aea4..a284f84839 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -290,15 +290,7 @@ struct _GtkWidgetPrivate * 5 widget states (defined in "gtkenums.h") * so 3 bits. */ - guint state : 3; - - /* The saved state of the widget. When a widget's state - * is changed to GTK_STATE_INSENSITIVE via - * "gtk_widget_set_state" or "gtk_widget_set_sensitive" - * the old state is kept around in this field. The state - * will be restored once the widget gets sensitive again. - */ - guint saved_state : 3; + guint state_flags : 6; guint direction : 2; @@ -389,6 +381,7 @@ enum { REALIZE, UNREALIZE, SIZE_ALLOCATE, + STATE_FLAGS_CHANGED, STATE_CHANGED, PARENT_SET, HIERARCHY_CHANGED, @@ -494,10 +487,16 @@ enum { typedef struct _GtkStateData GtkStateData; +enum { + STATE_CHANGE_REPLACE, + STATE_CHANGE_SET, + STATE_CHANGE_UNSET +}; + struct _GtkStateData { - GtkStateType state; - guint state_restoration : 1; + guint flags : 6; + guint operation : 2; guint parent_sensitive : 1; guint use_forall : 1; }; @@ -1432,6 +1431,8 @@ gtk_widget_class_init (GtkWidgetClass *klass) * * The ::state-changed signal is emitted when the widget state changes. * See gtk_widget_get_state(). + * + * Deprecated: 3.0. Use #GtkWidget::state-flags-changed instead. */ widget_signals[STATE_CHANGED] = g_signal_new (I_("state-changed"), @@ -1443,6 +1444,26 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_TYPE_NONE, 1, GTK_TYPE_STATE_TYPE); + /** + * GtkWidget::state-flags-changed: + * @widget: the object which received the signal. + * @flags: The previous state flags. + * + * The ::state-flags-changed signal is emitted when the widget state + * changes, see gtk_widget_get_state_flags(). + * + * Since: 3.0 + */ + widget_signals[STATE_FLAGS_CHANGED] = + g_signal_new (I_("state-flags-changed"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GtkWidgetClass, state_flags_changed), + NULL, NULL, + _gtk_marshal_VOID__FLAGS, + G_TYPE_NONE, 1, + GTK_TYPE_STATE_FLAGS); + /** * GtkWidget::parent-set: * @widget: the object on which the signal is emitted @@ -3465,8 +3486,6 @@ gtk_widget_init (GtkWidget *widget) priv = widget->priv; priv->child_visible = TRUE; - priv->state = GTK_STATE_NORMAL; - priv->saved_state = GTK_STATE_NORMAL; priv->name = NULL; priv->allocation.x = -1; priv->allocation.y = -1; @@ -6708,37 +6727,34 @@ gtk_widget_get_name (GtkWidget *widget) return G_OBJECT_TYPE_NAME (widget); } -/** - * gtk_widget_set_state: - * @widget: a #GtkWidget - * @state: new state for @widget - * - * This function is for use in widget implementations. Sets the state - * of a widget (insensitive, prelighted, etc.) Usually you should set - * the state using wrapper functions such as gtk_widget_set_sensitive(). - **/ -void -gtk_widget_set_state (GtkWidget *widget, - GtkStateType state) +static void +_gtk_widget_update_state_flags (GtkWidget *widget, + GtkStateFlags flags, + guint operation) { GtkWidgetPrivate *priv; - g_return_if_fail (GTK_IS_WIDGET (widget)); - priv = widget->priv; - if (state == gtk_widget_get_state (widget)) - return; + /* Handle insensitive first, since it is propagated + * differently throughout the widget hierarchy. + */ + if ((flags & GTK_STATE_FLAG_INSENSITIVE) != + (priv->state_flags & GTK_STATE_FLAG_INSENSITIVE)) + gtk_widget_set_sensitive (widget, + operation != STATE_CHANGE_UNSET); - if (state == GTK_STATE_INSENSITIVE) - gtk_widget_set_sensitive (widget, FALSE); - else + flags &= ~(GTK_STATE_FLAG_INSENSITIVE); + + if (flags != 0 || + operation == STATE_CHANGE_REPLACE) { GtkStateData data; - data.state = state; - data.state_restoration = FALSE; + data.flags = flags; + data.operation = operation; data.use_forall = FALSE; + if (priv->parent) data.parent_sensitive = (gtk_widget_is_sensitive (priv->parent) != FALSE); else @@ -6751,6 +6767,141 @@ gtk_widget_set_state (GtkWidget *widget, } } +/** + * gtk_widget_set_state_flags: + * @widget: a #GtkWidget + * @flags: State flags to turn on + * @clear: Whether to clear state before turning on @flags + * + * This function is for use in widget implementations. Turns on flag + * values in the current widget state (insensitive, prelighted, etc.). + * + * It is worth mentioning that any other state than %GTK_STATE_FLAG_INSENSITIVE, + * will be propagated down to all non-internal children if @widget is a + * #GtkContainer, while %GTK_STATE_FLAG_INSENSITIVE itself will be propagated + * down to all #GtkContainer children by different means than turning on the + * state flag down the hierarchy, both gtk_widget_get_state_flags() and + * gtk_widget_is_sensitive() will make use of these. + * + * Since: 3.0 + **/ +void +gtk_widget_set_state_flags (GtkWidget *widget, + GtkStateFlags flags, + gboolean clear) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + if ((!clear && (widget->priv->state_flags & flags) == flags) || + (clear && widget->priv->state_flags == flags)) + return; + + if (clear) + _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_REPLACE); + else + _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_SET); +} + +/** + * gtk_widget_unset_state_flags: + * @widget: a #GtkWidget + * @flags: State flags to turn off + * + * This function is for use in widget implementations. Turns off flag + * values for the current widget state (insensitive, prelighted, etc.). + * See gtk_widget_set_state_flags(). + * + * Since: 3.0 + **/ +void +gtk_widget_unset_state_flags (GtkWidget *widget, + GtkStateFlags flags) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + if ((widget->priv->state_flags & flags) == 0) + return; + + _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_UNSET); +} + +/** + * gtk_widget_get_state_flags: + * @widget: a #GtkWidget + * + * Returns the widget state as a flag set. It is worth mentioning + * that the effective %GTK_STATE_FLAG_INSENSITIVE state will be + * returned, that is, also based on parent insensitivity, even if + * @widget itself is sensitive. + * + * Returns: The state flags for widget + * + * Since: 3.0 + **/ +GtkStateFlags +gtk_widget_get_state_flags (GtkWidget *widget) +{ + GtkStateFlags flags; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); + + flags = widget->priv->state_flags; + + if (!gtk_widget_is_sensitive (widget)) + flags |= GTK_STATE_FLAG_INSENSITIVE; + + return flags; +} + +/** + * gtk_widget_set_state: + * @widget: a #GtkWidget + * @state: new state for @widget + * + * This function is for use in widget implementations. Sets the state + * of a widget (insensitive, prelighted, etc.) Usually you should set + * the state using wrapper functions such as gtk_widget_set_sensitive(). + * + * Deprecated: 3.0. Use gtk_widget_set_state_flags() instead. + **/ +void +gtk_widget_set_state (GtkWidget *widget, + GtkStateType state) +{ + GtkStateFlags flags; + + if (state == gtk_widget_get_state (widget)) + return; + + switch (state) + { + case GTK_STATE_ACTIVE: + flags = GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags = GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags = GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags = GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_INCONSISTENT: + flags = GTK_STATE_FLAG_INCONSISTENT; + break; + case GTK_STATE_FOCUSED: + flags = GTK_STATE_FLAG_FOCUSED; + break; + case GTK_STATE_NORMAL: + default: + flags = 0; + break; + } + + _gtk_widget_update_state_flags (widget, flags, STATE_CHANGE_REPLACE); +} + /** * gtk_widget_get_state: * @widget: a #GtkWidget @@ -6760,13 +6911,32 @@ gtk_widget_set_state (GtkWidget *widget, * Returns: the state of @widget. * * Since: 2.18 + * + * Deprecated: 3.0. Use gtk_widget_get_state_flags() instead. */ GtkStateType gtk_widget_get_state (GtkWidget *widget) { + GtkStateFlags flags; + g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_STATE_NORMAL); - return widget->priv->state; + flags = gtk_widget_get_state_flags (widget); + + if (flags & GTK_STATE_FLAG_INSENSITIVE) + return GTK_STATE_INSENSITIVE; + else if (flags & GTK_STATE_FLAG_INCONSISTENT) + return GTK_STATE_INCONSISTENT; + else if (flags & GTK_STATE_FLAG_ACTIVE) + return GTK_STATE_ACTIVE; + else if (flags & GTK_STATE_FLAG_SELECTED) + return GTK_STATE_SELECTED; + else if (flags & GTK_STATE_FLAG_FOCUSED) + return GTK_STATE_FOCUSED; + else if (flags & GTK_STATE_FLAG_PRELIGHT) + return GTK_STATE_PRELIGHT; + else + return GTK_STATE_NORMAL; } /** @@ -7173,17 +7343,19 @@ gtk_widget_set_sensitive (GtkWidget *widget, if (widget->priv->sensitive == sensitive) return; + data.flags = GTK_STATE_FLAG_INSENSITIVE; + if (sensitive) { widget->priv->sensitive = TRUE; - data.state = priv->saved_state; + data.operation = STATE_CHANGE_UNSET; } else { widget->priv->sensitive = FALSE; - data.state = gtk_widget_get_state (widget); + data.operation = STATE_CHANGE_SET; } - data.state_restoration = TRUE; + data.use_forall = TRUE; if (priv->parent) @@ -7192,6 +7364,7 @@ gtk_widget_set_sensitive (GtkWidget *widget, data.parent_sensitive = TRUE; gtk_widget_propagate_state (widget, &data); + if (gtk_widget_is_drawable (widget)) gtk_widget_queue_draw (widget); @@ -7267,6 +7440,7 @@ void gtk_widget_set_parent (GtkWidget *widget, GtkWidget *parent) { + GtkStateFlags parent_flags; GtkWidgetPrivate *priv; GtkStateData data; @@ -7293,14 +7467,17 @@ gtk_widget_set_parent (GtkWidget *widget, g_object_ref_sink (widget); priv->parent = parent; - if (gtk_widget_get_state (parent) != GTK_STATE_NORMAL) - data.state = gtk_widget_get_state (parent); - else - data.state = gtk_widget_get_state (widget); - data.state_restoration = FALSE; + parent_flags = gtk_widget_get_state_flags (parent); + + /* Merge both old state and current parent state, + * We don't want the insensitive flag to propagate + * to the new child though */ + data.flags = parent_flags & ~GTK_STATE_FLAG_INSENSITIVE; + data.flags |= priv->state_flags; + + data.operation = STATE_CHANGE_REPLACE; data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE); data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget); - gtk_widget_propagate_state (widget, &data); gtk_widget_reset_rc_styles (widget); @@ -7900,7 +8077,8 @@ gtk_widget_real_style_set (GtkWidget *widget, if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) - gtk_style_set_background (priv->style, priv->window, priv->state); + gtk_style_set_background (priv->style, priv->window, + gtk_widget_get_state (widget)); } static void @@ -10371,33 +10549,27 @@ gtk_widget_propagate_state (GtkWidget *widget, GtkStateData *data) { GtkWidgetPrivate *priv = widget->priv; - guint8 old_state = gtk_widget_get_state (widget); - guint8 old_saved_state = priv->saved_state; + GtkStateFlags old_flags = priv->state_flags; + GtkStateType old_state; - /* don't call this function with state==GTK_STATE_INSENSITIVE, - * parent_sensitive==TRUE on a sensitive widget - */ + old_state = gtk_widget_get_state (widget); + if (!priv->parent_sensitive) + old_flags |= GTK_STATE_FLAG_INSENSITIVE; priv->parent_sensitive = data->parent_sensitive; - if (gtk_widget_is_sensitive (widget)) + switch (data->operation) { - if (data->state_restoration) - priv->state = priv->saved_state; - else - priv->state = data->state; - } - else - { - if (!data->state_restoration) - { - if (data->state != GTK_STATE_INSENSITIVE) - priv->saved_state = data->state; - } - else if (gtk_widget_get_state (widget) != GTK_STATE_INSENSITIVE) - priv->saved_state = gtk_widget_get_state (widget); - priv->state = GTK_STATE_INSENSITIVE; + case STATE_CHANGE_REPLACE: + priv->state_flags = data->flags; + break; + case STATE_CHANGE_SET: + priv->state_flags |= data->flags; + break; + case STATE_CHANGE_UNSET: + priv->state_flags &= ~(data->flags); + break; } if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget)) @@ -10405,12 +10577,12 @@ gtk_widget_propagate_state (GtkWidget *widget, GtkWidget *window; window = gtk_widget_get_toplevel (widget); + if (window && gtk_widget_is_toplevel (window)) gtk_window_set_focus (GTK_WINDOW (window), NULL); } - if (old_state != gtk_widget_get_state (widget) || - old_saved_state != priv->saved_state) + if (old_flags != gtk_widget_get_state_flags (widget)) { g_object_ref (widget); @@ -10418,6 +10590,7 @@ gtk_widget_propagate_state (GtkWidget *widget, gtk_grab_remove (widget); g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state); + g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags); if (!priv->shadowed) { @@ -10444,7 +10617,7 @@ gtk_widget_propagate_state (GtkWidget *widget, if (!gtk_widget_is_sensitive (widget)) _gtk_widget_synthesize_crossing (widget, NULL, d->data, GDK_CROSSING_STATE_CHANGED); - else if (old_state == GTK_STATE_INSENSITIVE) + else if (old_flags & GTK_STATE_FLAG_INSENSITIVE) _gtk_widget_synthesize_crossing (NULL, widget, d->data, GDK_CROSSING_STATE_CHANGED); @@ -10456,17 +10629,22 @@ gtk_widget_propagate_state (GtkWidget *widget, } if (GTK_IS_CONTAINER (widget)) - { - data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE); - if (data->use_forall) - gtk_container_forall (GTK_CONTAINER (widget), - (GtkCallback) gtk_widget_propagate_state, - data); - else - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback) gtk_widget_propagate_state, - data); - } + { + data->parent_sensitive = gtk_widget_is_sensitive (widget); + + /* Do not propagate insensitive state further */ + data->flags &= ~(GTK_STATE_FLAG_INSENSITIVE); + + if (data->use_forall) + gtk_container_forall (GTK_CONTAINER (widget), + (GtkCallback) gtk_widget_propagate_state, + data); + else + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback) gtk_widget_propagate_state, + data); + } + g_object_unref (widget); } } diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 125d315b7a..9515d71310 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -225,6 +225,8 @@ struct _GtkWidgetClass GtkAllocation *allocation); void (* state_changed) (GtkWidget *widget, GtkStateType previous_state); + void (* state_flags_changed) (GtkWidget *widget, + GtkStateFlags previous_state_flags); void (* parent_set) (GtkWidget *widget, GtkWidget *previous_parent); void (* hierarchy_changed) (GtkWidget *widget, @@ -578,6 +580,13 @@ void gtk_widget_set_state (GtkWidget *widget, GtkStateType state); GtkStateType gtk_widget_get_state (GtkWidget *widget); +void gtk_widget_set_state_flags (GtkWidget *widget, + GtkStateFlags flags, + gboolean clear); +void gtk_widget_unset_state_flags (GtkWidget *widget, + GtkStateFlags flags); +GtkStateFlags gtk_widget_get_state_flags (GtkWidget *widget); + void gtk_widget_set_sensitive (GtkWidget *widget, gboolean sensitive); gboolean gtk_widget_get_sensitive (GtkWidget *widget); From 401b6553078d2479e7b9e9543332de36f71e5945 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:38:26 +0100 Subject: [PATCH 377/634] GtkButton: Set widget state as state flags. --- gtk/gtkbutton.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 9b71c298f5..84b5d0b578 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -2291,7 +2291,7 @@ static void gtk_button_update_state (GtkButton *button) { GtkButtonPrivate *priv = button->priv; - GtkStateType new_state; + GtkStateFlags new_state = 0; gboolean depressed; if (priv->activate_timeout) @@ -2299,13 +2299,14 @@ gtk_button_update_state (GtkButton *button) else depressed = priv->in_button && priv->button_down; - if (priv->in_button && (!priv->button_down || !depressed)) - new_state = GTK_STATE_PRELIGHT; - else - new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; + if (priv->in_button) + new_state |= GTK_STATE_FLAG_PRELIGHT; - _gtk_button_set_depressed (button, depressed); - gtk_widget_set_state (GTK_WIDGET (button), new_state); + if (priv->button_down || depressed) + new_state |= GTK_STATE_FLAG_ACTIVE; + + _gtk_button_set_depressed (button, depressed); + gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE); } static void From 0e25b19515143d6f72ee079cd896c6412db7d08e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:42:51 +0100 Subject: [PATCH 378/634] GtkComboBox: Set widget state as state flags. --- gtk/gtkcombobox.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index ebdd7f5e1d..c0d3548e86 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -284,9 +284,9 @@ static void gtk_combo_box_style_set (GtkWidget *widget, GtkStyle *previous); static void gtk_combo_box_button_toggled (GtkWidget *widget, gpointer data); -static void gtk_combo_box_button_state_changed (GtkWidget *widget, - GtkStateType previous, - gpointer data); +static void gtk_combo_box_button_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous, + gpointer data); static void gtk_combo_box_add (GtkContainer *container, GtkWidget *widget); static void gtk_combo_box_remove (GtkContainer *container, @@ -1322,9 +1322,9 @@ gtk_combo_box_state_changed (GtkWidget *widget, } static void -gtk_combo_box_button_state_changed (GtkWidget *widget, - GtkStateType previous, - gpointer data) +gtk_combo_box_button_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous, + gpointer data) { GtkComboBox *combo_box = GTK_COMBO_BOX (data); GtkComboBoxPrivate *priv = combo_box->priv; @@ -1332,14 +1332,9 @@ gtk_combo_box_button_state_changed (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { if (!priv->tree_view && priv->cell_view) - { - if ((gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) != - (gtk_widget_get_state (priv->cell_view) == GTK_STATE_INSENSITIVE)) - gtk_widget_set_sensitive (priv->cell_view, gtk_widget_get_sensitive (widget)); - - gtk_widget_set_state (priv->cell_view, - gtk_widget_get_state (widget)); - } + gtk_widget_set_state_flags (priv->cell_view, + gtk_widget_get_state_flags (widget), + TRUE); } gtk_widget_queue_draw (widget); @@ -3108,8 +3103,8 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box, g_signal_connect (priv->button, "button-press-event", G_CALLBACK (gtk_combo_box_menu_button_press), combo_box); - g_signal_connect (priv->button, "state-changed", - G_CALLBACK (gtk_combo_box_button_state_changed), + g_signal_connect (priv->button, "state-flags-changed", + G_CALLBACK (gtk_combo_box_button_state_flags_changed), combo_box); /* create our funky menu */ @@ -3274,7 +3269,7 @@ gtk_combo_box_menu_destroy (GtkComboBox *combo_box) g_signal_handlers_disconnect_matched (priv->button, G_SIGNAL_MATCH_DATA, 0, 0, NULL, - gtk_combo_box_button_state_changed, combo_box); + gtk_combo_box_button_state_flags_changed, combo_box); /* unparent will remove our latest ref */ gtk_widget_unparent (priv->button); From f7f5ac1b09de39ca5e856f86cb95fd61fe0a6662 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:43:20 +0100 Subject: [PATCH 379/634] GtkEntry: Set widget state as state flags. --- gtk/gtkentry.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index cd70918e1e..7483a6ca3d 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -6617,7 +6617,7 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, GtkIconInfo *info; GtkIconTheme *icon_theme; GtkSettings *settings; - GtkStateType state; + GtkStateFlags state; GtkWidget *widget; GdkScreen *screen; gint width, height; @@ -6633,8 +6633,8 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, case GTK_IMAGE_PIXBUF: break; case GTK_IMAGE_STOCK: - state = gtk_widget_get_state (widget); - gtk_widget_set_state (widget, GTK_STATE_NORMAL); + state = gtk_widget_get_state_flags (widget); + gtk_widget_set_state_flags (widget, 0, TRUE); icon_info->pixbuf = gtk_widget_render_icon (widget, icon_info->stock_id, GTK_ICON_SIZE_MENU, @@ -6644,7 +6644,7 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU, NULL); - gtk_widget_set_state (widget, state); + gtk_widget_set_state_flags (widget, state, TRUE); break; case GTK_IMAGE_ICON_NAME: @@ -6665,13 +6665,13 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, if (icon_info->pixbuf == NULL) { - state = gtk_widget_get_state (widget); - gtk_widget_set_state (widget, GTK_STATE_NORMAL); + state = gtk_widget_get_state_flags (widget); + gtk_widget_set_state_flags (widget, 0, TRUE); icon_info->pixbuf = gtk_widget_render_icon (widget, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU, NULL); - gtk_widget_set_state (widget, state); + gtk_widget_set_state_flags (widget, state, TRUE); } } break; @@ -6699,13 +6699,13 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, if (icon_info->pixbuf == NULL) { - state = gtk_widget_get_state (widget); - gtk_widget_set_state (widget, GTK_STATE_NORMAL); + state = gtk_widget_get_state_flags (widget); + gtk_widget_set_state_flags (widget, 0, TRUE); icon_info->pixbuf = gtk_widget_render_icon (widget, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU, NULL); - gtk_widget_set_state (widget, state); + gtk_widget_set_state_flags (widget, state, TRUE); } } break; From 399499225e9074df0ba325bee70c8ee3e3ec1827 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:43:37 +0100 Subject: [PATCH 380/634] GtkExpander: Set widget state as state flags. --- gtk/gtkexpander.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index 53eae8cfaa..236ff279f6 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -977,7 +977,9 @@ gtk_expander_enter_notify (GtkWidget *widget, expander->priv->prelight = TRUE; if (expander->priv->label_widget) - gtk_widget_set_state (expander->priv->label_widget, GTK_STATE_PRELIGHT); + gtk_widget_set_state_flags (expander->priv->label_widget, + GTK_STATE_FLAG_PRELIGHT, + FALSE); gtk_expander_redraw_expander (expander); } @@ -997,7 +999,8 @@ gtk_expander_leave_notify (GtkWidget *widget, expander->priv->prelight = FALSE; if (expander->priv->label_widget) - gtk_widget_set_state (expander->priv->label_widget, GTK_STATE_NORMAL); + gtk_widget_unset_state_flags (expander->priv->label_widget, + GTK_STATE_FLAG_PRELIGHT); gtk_expander_redraw_expander (expander); } @@ -1913,7 +1916,7 @@ gtk_expander_set_label_widget (GtkExpander *expander, if (priv->label_widget) { - gtk_widget_set_state (priv->label_widget, GTK_STATE_NORMAL); + gtk_widget_set_state_flags (priv->label_widget, 0, TRUE); gtk_widget_unparent (priv->label_widget); } @@ -1927,7 +1930,9 @@ gtk_expander_set_label_widget (GtkExpander *expander, gtk_widget_set_parent (label_widget, widget); if (priv->prelight) - gtk_widget_set_state (label_widget, GTK_STATE_PRELIGHT); + gtk_widget_set_state_flags (label_widget, + GTK_STATE_FLAG_PRELIGHT, + FALSE); } if (gtk_widget_get_visible (widget)) From 9ae2e29f44a82f785a34c5d704bb4b3babd0f2d3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:43:55 +0100 Subject: [PATCH 381/634] GtkMenu: Set widget state as state flags. --- gtk/gtkmenu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 13998ee1b9..83988ebaeb 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -1192,9 +1192,9 @@ gtk_menu_attach_to_widget (GtkMenu *menu, g_object_set_data_full (G_OBJECT (attach_widget), I_(ATTACHED_MENUS), list, (GDestroyNotify) g_list_free); - if (gtk_widget_get_state (GTK_WIDGET (menu)) != GTK_STATE_NORMAL) - gtk_widget_set_state (GTK_WIDGET (menu), GTK_STATE_NORMAL); - + if (gtk_widget_get_state_flags (GTK_WIDGET (menu)) != 0) + gtk_widget_set_state_flags (GTK_WIDGET (menu), 0, TRUE); + /* we don't need to set the style here, since * we are a toplevel widget. */ From 5f0f21aad301cd396470681b6ccfb58dd93abaab Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:44:09 +0100 Subject: [PATCH 382/634] GtkMenuItem: Set widget state as state flags. --- gtk/gtkmenuitem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index d0dd5e9032..7a94bed278 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -1626,7 +1626,8 @@ gtk_real_menu_item_select (GtkMenuItem *menu_item) _gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item), TRUE); } - gtk_widget_set_state (GTK_WIDGET (menu_item), GTK_STATE_PRELIGHT); + gtk_widget_set_state_flags (GTK_WIDGET (menu_item), + GTK_STATE_FLAG_PRELIGHT, FALSE); gtk_widget_queue_draw (GTK_WIDGET (menu_item)); } @@ -1636,7 +1637,8 @@ gtk_real_menu_item_deselect (GtkMenuItem *menu_item) if (menu_item->submenu) _gtk_menu_item_popdown_submenu (GTK_WIDGET (menu_item)); - gtk_widget_set_state (GTK_WIDGET (menu_item), GTK_STATE_NORMAL); + gtk_widget_unset_state_flags (GTK_WIDGET (menu_item), + GTK_STATE_FLAG_PRELIGHT); gtk_widget_queue_draw (GTK_WIDGET (menu_item)); } From 517eaa55e5277cb865ed6a7a3e304c0d85163153 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:44:26 +0100 Subject: [PATCH 383/634] GtkNotebook: Set widget state as state flags. --- gtk/gtknotebook.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 708a8d0fff..f5a4db5cc9 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -4651,7 +4651,7 @@ gtk_notebook_remove_tab_label (GtkNotebook *notebook, page->mnemonic_activate_signal); page->mnemonic_activate_signal = 0; - gtk_widget_set_state (page->tab_label, GTK_STATE_NORMAL); + gtk_widget_set_state_flags (page->tab_label, 0, TRUE); gtk_widget_unparent (page->tab_label); page->tab_label = NULL; } @@ -6205,9 +6205,9 @@ gtk_notebook_update_tab_states (GtkNotebook *notebook) if (page->tab_label) { if (page == priv->cur_page) - gtk_widget_set_state (page->tab_label, GTK_STATE_NORMAL); - else - gtk_widget_set_state (page->tab_label, GTK_STATE_ACTIVE); + gtk_widget_set_state_flags (page->tab_label, GTK_STATE_FLAG_ACTIVE, TRUE); + else + gtk_widget_set_state_flags (page->tab_label, 0, TRUE); } } } From 80d1ce9f676f7eacf66a46cf749c20b840287124 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:45:01 +0100 Subject: [PATCH 384/634] GtkRadioButton: Set widget state as state flags. --- gtk/gtkradiobutton.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index ff607cea56..33479503ab 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -217,7 +217,7 @@ gtk_radio_button_init (GtkRadioButton *radio_button) priv->group = g_slist_prepend (NULL, radio_button); _gtk_button_set_depressed (GTK_BUTTON (radio_button), TRUE); - gtk_widget_set_state (GTK_WIDGET (radio_button), GTK_STATE_ACTIVE); + gtk_widget_set_state_flags (GTK_WIDGET (radio_button), GTK_STATE_FLAG_ACTIVE, TRUE); } static void @@ -790,7 +790,7 @@ gtk_radio_button_clicked (GtkButton *button) GtkRadioButtonPrivate *priv = radio_button->priv; GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); GtkToggleButton *tmp_button; - GtkStateType new_state; + GtkStateFlags new_state = 0; GSList *tmp_list; gint toggled; gboolean depressed; @@ -818,14 +818,19 @@ gtk_radio_button_clicked (GtkButton *button) if (!tmp_button) { - new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE); + if (button->priv->in_button) + new_state |= GTK_STATE_FLAG_PRELIGHT; + + new_state |= GTK_STATE_FLAG_ACTIVE; } else { toggled = TRUE; _gtk_toggle_button_set_active (toggle_button, !gtk_toggle_button_get_active (toggle_button)); - new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL); + + if (button->priv->in_button) + new_state |= GTK_STATE_FLAG_PRELIGHT; } } else @@ -847,7 +852,10 @@ gtk_radio_button_clicked (GtkButton *button) } } - new_state = (button->priv->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE); + if (button->priv->in_button) + new_state |= GTK_STATE_FLAG_PRELIGHT; + + new_state |= GTK_STATE_FLAG_ACTIVE; } if (gtk_toggle_button_get_inconsistent (toggle_button)) @@ -857,8 +865,8 @@ gtk_radio_button_clicked (GtkButton *button) else depressed = gtk_toggle_button_get_active (toggle_button); - if (gtk_widget_get_state (GTK_WIDGET (button)) != new_state) - gtk_widget_set_state (GTK_WIDGET (button), new_state); + if (gtk_widget_get_state_flags (GTK_WIDGET (button)) != new_state) + gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE); if (toggled) { From 1c2f27fe11776e1e65e9a31ca9f847446d0cb103 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:45:19 +0100 Subject: [PATCH 385/634] GtkToggleButton: Set widget state as state flags. --- gtk/gtktogglebutton.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index a4979b3fa4..4fbaad5622 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -551,12 +551,15 @@ gtk_toggle_button_update_state (GtkButton *button) GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); GtkToggleButtonPrivate *priv = toggle_button->priv; gboolean depressed, touchscreen; - GtkStateType new_state; + GtkStateFlags new_state = 0; g_object_get (gtk_widget_get_settings (GTK_WIDGET (button)), "gtk-touchscreen-mode", &touchscreen, NULL); + if (priv->inconsistent) + new_state |= GTK_STATE_FLAG_INCONSISTENT; + if (priv->inconsistent) depressed = FALSE; else if (button->priv->in_button && button->priv->button_down) @@ -565,10 +568,10 @@ gtk_toggle_button_update_state (GtkButton *button) depressed = priv->active; if (!touchscreen && button->priv->in_button && (!button->priv->button_down || priv->draw_indicator)) - new_state = GTK_STATE_PRELIGHT; - else - new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; + new_state |= GTK_STATE_FLAG_PRELIGHT; + else if (depressed) + new_state |= GTK_STATE_FLAG_ACTIVE; - _gtk_button_set_depressed (button, depressed); - gtk_widget_set_state (GTK_WIDGET (toggle_button), new_state); + _gtk_button_set_depressed (button, depressed); + gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), new_state, TRUE); } From c0d08ff627d6182f813d2992db0064b451d31be6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 31 Oct 2010 14:45:41 +0100 Subject: [PATCH 386/634] GtkToolItemGroup: Set widget state as state flags. --- gtk/gtktoolitemgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c index 7983667ffc..abcc64014b 100644 --- a/gtk/gtktoolitemgroup.c +++ b/gtk/gtktoolitemgroup.c @@ -1752,7 +1752,7 @@ gtk_tool_item_group_set_label_widget (GtkToolItemGroup *group, if (priv->label_widget) { - gtk_widget_set_state (priv->label_widget, GTK_STATE_NORMAL); + gtk_widget_set_state_flags (priv->label_widget, 0, TRUE); gtk_container_remove (GTK_CONTAINER (alignment), priv->label_widget); } From 227294a6aa798691ec4f5ca4f84a9796657f24d1 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 1 Nov 2010 02:37:07 +0100 Subject: [PATCH 387/634] GtkWidget: Trigger state change transitions on state flags change. This makes state transitions automatic for non-complex widgets, complex widgets such as GtkTreeView still need to notify state updates themselves. --- gtk/gtkwidget.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index a284f84839..5f2299462a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -10549,7 +10549,7 @@ gtk_widget_propagate_state (GtkWidget *widget, GtkStateData *data) { GtkWidgetPrivate *priv = widget->priv; - GtkStateFlags old_flags = priv->state_flags; + GtkStateFlags new_flags, old_flags = priv->state_flags; GtkStateType old_state; old_state = gtk_widget_get_state (widget); @@ -10582,7 +10582,9 @@ gtk_widget_propagate_state (GtkWidget *widget, gtk_window_set_focus (GTK_WINDOW (window), NULL); } - if (old_flags != gtk_widget_get_state_flags (widget)) + new_flags = gtk_widget_get_state_flags (widget); + + if (old_flags != new_flags) { g_object_ref (widget); @@ -10645,6 +10647,59 @@ gtk_widget_propagate_state (GtkWidget *widget, data); } + /* Trigger state change transitions for the widget */ + if (priv->context && + gtk_widget_get_mapped (widget)) + { + gint diff, flag = 1; + GdkWindow *window; + + diff = old_flags ^ new_flags; + window = gtk_widget_get_window (widget); + + while (diff != 0) + { + if ((diff & flag) != 0) + { + GtkStateType state; + gboolean target; + + switch (flag) + { + case GTK_STATE_FLAG_ACTIVE: + state = GTK_STATE_ACTIVE; + break; + case GTK_STATE_FLAG_PRELIGHT: + state = GTK_STATE_PRELIGHT; + break; + case GTK_STATE_FLAG_SELECTED: + state = GTK_STATE_SELECTED; + break; + case GTK_STATE_FLAG_INSENSITIVE: + state = GTK_STATE_INSENSITIVE; + break; + case GTK_STATE_FLAG_INCONSISTENT: + state = GTK_STATE_INCONSISTENT; + break; + case GTK_STATE_FLAG_FOCUSED: + state = GTK_STATE_FOCUSED; + break; + default: + state = GTK_STATE_NORMAL; + break; + } + + target = ((new_flags & flag) != 0); + gtk_style_context_notify_state_change (priv->context, + window, NULL, + state, target); + diff &= ~flag; + } + + flag <<= 1; + } + } + g_object_unref (widget); } } From af1f8701dc70ffc7b1a62714ef9b886c1edf5ab3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 1 Nov 2010 02:42:08 +0100 Subject: [PATCH 388/634] GtkThemingEngine: draw resize grip through render_handle(). GtkJunctionSides is used instead of GdkWindowEdge, GtkStyle implementation has changed to use GtkStyleContext's. --- gtk/gtkstyle.c | 311 ++++++++--------------------------------- gtk/gtkthemingengine.c | 267 ++++++++++++++++++++++++++++++++++- 2 files changed, 321 insertions(+), 257 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index efb83836b8..5b0721e1f0 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -3323,284 +3323,83 @@ gtk_default_draw_resize_grip (GtkStyle *style, gint width, gint height) { - gint skip; + GtkStyleContext *context; + GtkStylePrivate *priv; + GtkStateFlags flags = 0; + GtkJunctionSides sides = 0; - cairo_rectangle (cr, x, y, width, height); - cairo_clip (cr); + if (widget) + context = gtk_widget_get_style_context (widget); + else + { + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; + } - cairo_set_line_width (cr, 1.0); + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + gtk_style_context_add_class (context, "grip"); + + switch (state_type) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags |= GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); - skip = -1; switch (edge) { case GDK_WINDOW_EDGE_NORTH_WEST: - /* make it square */ - if (width < height) - height = width; - else if (height < width) - width = height; - skip = 2; + sides = GTK_JUNCTION_TOP | GTK_JUNCTION_LEFT; break; case GDK_WINDOW_EDGE_NORTH: - if (width < height) - height = width; + sides = GTK_JUNCTION_TOP; break; case GDK_WINDOW_EDGE_NORTH_EAST: - /* make it square, aligning to top right */ - if (width < height) - height = width; - else if (height < width) - { - x += (width - height); - width = height; - } - skip = 3; + sides = GTK_JUNCTION_TOP | GTK_JUNCTION_RIGHT; break; case GDK_WINDOW_EDGE_WEST: - if (height < width) - width = height; + sides = GTK_JUNCTION_LEFT; break; case GDK_WINDOW_EDGE_EAST: - /* aligning to right */ - if (height < width) - { - x += (width - height); - width = height; - } + sides = GTK_JUNCTION_RIGHT; break; case GDK_WINDOW_EDGE_SOUTH_WEST: - /* make it square, aligning to bottom left */ - if (width < height) - { - y += (height - width); - height = width; - } - else if (height < width) - width = height; - skip = 1; + sides = GTK_JUNCTION_BOTTOM | GTK_JUNCTION_LEFT; break; case GDK_WINDOW_EDGE_SOUTH: - /* align to bottom */ - if (width < height) - { - y += (height - width); - height = width; - } + sides = GTK_JUNCTION_BOTTOM; break; case GDK_WINDOW_EDGE_SOUTH_EAST: - /* make it square, aligning to bottom right */ - if (width < height) - { - y += (height - width); - height = width; - } - else if (height < width) - { - x += (width - height); - width = height; - } - skip = 0; - break; - default: - g_assert_not_reached (); - } - - switch (edge) - { - case GDK_WINDOW_EDGE_WEST: - case GDK_WINDOW_EDGE_EAST: - { - gint xi; - - xi = x; - - while (xi < x + width) - { - _cairo_draw_line (cr, - &style->light[state_type], - xi, y, - xi, y + height); - - xi++; - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y, - xi, y + height); - - xi += 2; - } - } - break; - case GDK_WINDOW_EDGE_NORTH: - case GDK_WINDOW_EDGE_SOUTH: - { - gint yi; - - yi = y; - - while (yi < y + height) - { - _cairo_draw_line (cr, - &style->light[state_type], - x, yi, - x + width, yi); - - yi++; - _cairo_draw_line (cr, - &style->dark[state_type], - x, yi, - x + width, yi); - - yi+= 2; - } - } - break; - case GDK_WINDOW_EDGE_NORTH_WEST: - { - gint xi, yi; - - xi = x + width; - yi = y + height; - - while (xi > x + 3) - { - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y, - x, yi); - - --xi; - --yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y, - x, yi); - - --xi; - --yi; - - _cairo_draw_line (cr, - &style->light[state_type], - xi, y, - x, yi); - - xi -= 3; - yi -= 3; - - } - } - break; - case GDK_WINDOW_EDGE_NORTH_EAST: - { - gint xi, yi; - - xi = x; - yi = y + height; - - while (xi < (x + width - 3)) - { - _cairo_draw_line (cr, - &style->light[state_type], - xi, y, - x + width, yi); - - ++xi; - --yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y, - x + width, yi); - - ++xi; - --yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y, - x + width, yi); - - xi += 3; - yi -= 3; - } - } - break; - case GDK_WINDOW_EDGE_SOUTH_WEST: - { - gint xi, yi; - - xi = x + width; - yi = y; - - while (xi > x + 3) - { - _cairo_draw_line (cr, - &style->dark[state_type], - x, yi, - xi, y + height); - - --xi; - ++yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - x, yi, - xi, y + height); - - --xi; - ++yi; - - _cairo_draw_line (cr, - &style->light[state_type], - x, yi, - xi, y + height); - - xi -= 3; - yi += 3; - - } - } - break; - case GDK_WINDOW_EDGE_SOUTH_EAST: - { - gint xi, yi; - - xi = x; - yi = y; - - while (xi < (x + width - 3)) - { - _cairo_draw_line (cr, - &style->light[state_type], - xi, y + height, - x + width, yi); - - ++xi; - ++yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y + height, - x + width, yi); - - ++xi; - ++yi; - - _cairo_draw_line (cr, - &style->dark[state_type], - xi, y + height, - x + width, yi); - - xi += 3; - yi += 3; - } - } - break; - default: - g_assert_not_reached (); + sides = GTK_JUNCTION_BOTTOM | GTK_JUNCTION_RIGHT; break; } + + gtk_style_context_set_junction_sides (context, sides); + + cairo_save (cr); + + gtk_render_handle (context, cr, + (gdouble) x, + (gdouble) y, + (gdouble) width, + (gdouble) height); + + cairo_restore (cr); + gtk_style_context_restore (context); } static void diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index ca3b3139f5..d1741d2748 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -2426,7 +2426,272 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); - if (gtk_theming_engine_has_class (engine, "paned")) + if (gtk_theming_engine_has_class (engine, "grip")) + { + GtkJunctionSides sides; + gint skip = -1; + + cairo_save (cr); + + cairo_set_line_width (cr, 1.0); + sides = gtk_theming_engine_get_junction_sides (engine); + + /* reduce confusing values to a meaningful state */ + if (sides & (GTK_JUNCTION_LEFT | GTK_JUNCTION_RIGHT)) + sides &= ~(GTK_JUNCTION_LEFT); + + if (sides & (GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM)) + sides &= ~(GTK_JUNCTION_TOP); + + if (sides == 0) + sides = (GTK_JUNCTION_BOTTOM | GTK_JUNCTION_RIGHT); + + /* align drawing area to the connected side */ + if (sides == GTK_JUNCTION_LEFT) + { + if (height < width) + width = height; + } + else if (sides & (GTK_JUNCTION_LEFT | GTK_JUNCTION_TOP)) + { + if (width < height) + height = width; + else if (height < width) + width = height; + + skip = 2; + } + else if (sides & (GTK_JUNCTION_LEFT | GTK_JUNCTION_BOTTOM)) + { + /* make it square, aligning to bottom left */ + if (width < height) + { + y += (height - width); + height = width; + } + else if (height < width) + width = height; + + skip = 1; + } + if (sides == GTK_JUNCTION_RIGHT) + { + /* aligning to right */ + if (height < width) + { + x += (width - height); + width = height; + } + } + else if (sides & (GTK_JUNCTION_RIGHT | GTK_JUNCTION_TOP)) + { + if (width < height) + height = width; + else if (height < width) + { + x += (width - height); + width = height; + } + + skip = 3; + } + else if (sides & (GTK_JUNCTION_RIGHT | GTK_JUNCTION_BOTTOM)) + { + /* make it square, aligning to bottom right */ + if (width < height) + { + y += (height - width); + height = width; + } + else if (height < width) + { + x += (width - height); + width = height; + } + + skip = 0; + } + else if (sides == GTK_JUNCTION_TOP) + { + if (width < height) + height = width; + } + else if (sides == GTK_JUNCTION_BOTTOM) + { + /* align to bottom */ + if (width < height) + { + y += (height - width); + height = width; + } + } + else + g_assert_not_reached (); + + if (sides == GTK_JUNCTION_LEFT || + sides == GTK_JUNCTION_RIGHT) + { + gint xi; + + xi = x; + + while (xi < x + width) + { + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, x, y, x, y + height); + cairo_stroke (cr); + xi++; + + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, xi, y, xi, y + height); + cairo_stroke (cr); + xi += 2; + } + } + else if (sides == GTK_JUNCTION_TOP || + sides == GTK_JUNCTION_BOTTOM) + { + gint yi; + + yi = y; + + while (yi < y + height) + { + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, x, yi, x + width, yi); + cairo_stroke (cr); + yi++; + + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, x, yi, x + width, yi); + cairo_stroke (cr); + yi+= 2; + } + } + else if (sides == (GTK_JUNCTION_TOP | GTK_JUNCTION_LEFT)) + { + gint xi, yi; + + xi = x + width; + yi = y + height; + + while (xi > x + 3) + { + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, xi, y, x, yi); + cairo_stroke (cr); + + --xi; + --yi; + + add_path_line (cr, xi, y, x, yi); + cairo_stroke (cr); + + --xi; + --yi; + + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, xi, y, x, yi); + cairo_stroke (cr); + + xi -= 3; + yi -= 3; + } + } + else if (sides == (GTK_JUNCTION_TOP | GTK_JUNCTION_RIGHT)) + { + gint xi, yi; + + xi = x; + yi = y + height; + + while (xi < (x + width - 3)) + { + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, xi, y, x + width, yi); + cairo_stroke (cr); + + ++xi; + --yi; + + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, xi, y, x + width, yi); + cairo_stroke (cr); + + ++xi; + --yi; + + add_path_line (cr, xi, y, x + width, yi); + cairo_stroke (cr); + + xi += 3; + yi -= 3; + } + } + else if (sides == (GTK_JUNCTION_BOTTOM | GTK_JUNCTION_LEFT)) + { + gint xi, yi; + + xi = x + width; + yi = y; + + while (xi > x + 3) + { + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, x, yi, xi, y + height); + cairo_stroke (cr); + + --xi; + ++yi; + + add_path_line (cr, x, yi, xi, y + height); + cairo_stroke (cr); + + --xi; + ++yi; + + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, x, yi, xi, y + height); + cairo_stroke (cr); + + xi -= 3; + yi += 3; + } + } + else if (sides == (GTK_JUNCTION_BOTTOM | GTK_JUNCTION_RIGHT)) + { + gint xi, yi; + + xi = x; + yi = y; + + while (xi < (x + width - 3)) + { + gdk_cairo_set_source_rgba (cr, &lighter); + add_path_line (cr, xi, y + height, x + width, yi); + cairo_stroke (cr); + + ++xi; + ++yi; + + gdk_cairo_set_source_rgba (cr, &darker); + add_path_line (cr, xi, y + height, x + width, yi); + cairo_stroke (cr); + + ++xi; + ++yi; + + add_path_line (cr, xi, y + height, x + width, yi); + cairo_stroke (cr); + + xi += 3; + yi += 3; + } + } + + cairo_restore (cr); + } + else if (gtk_theming_engine_has_class (engine, "paned")) { if (width > height) for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5) From ebf5bd390f9c8fb13379afb12eaecea66262b020 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 1 Nov 2010 02:46:35 +0100 Subject: [PATCH 389/634] Add gtk_render_activity() This method will render progress bars and spinners, these should handle active and inconsistent states' animation progress in order to perform animations. --- gtk/gtkstylecontext.c | 23 +++++++++++ gtk/gtkstylecontext.h | 2 +- gtk/gtkthemingengine.c | 93 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 6 +++ 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 6479c75fe5..462d0df71c 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -3043,3 +3043,26 @@ gtk_render_handle (GtkStyleContext *context, _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_handle (priv->theming_engine, cr, x, y, width, height); } + +void +gtk_render_activity (GtkStyleContext *context, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + priv = context->priv; + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + store_animation_region (context, x, y, width, height); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + engine_class->render_activity (priv->theming_engine, cr, x, y, width, height); +} diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 212de85558..5a3730765d 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -258,7 +258,7 @@ void gtk_render_handle (GtkStyleContext *context, gdouble y, gdouble width, gdouble height); -void gtk_render_progress (GtkStyleContext *context, +void gtk_render_activity (GtkStyleContext *context, cairo_t *cr, gdouble x, gdouble y, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index d1741d2748..474bd0da06 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -162,6 +162,12 @@ static void gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static void gtk_theming_engine_render_activity (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -213,6 +219,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_frame_gap = gtk_theming_engine_render_frame_gap; klass->render_extension = gtk_theming_engine_render_extension; klass->render_handle = gtk_theming_engine_render_handle; + klass->render_activity = gtk_theming_engine_render_activity; /** * GtkThemingEngine:name: @@ -2714,3 +2721,89 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine, gdk_rgba_free (bg_color); } + +static void +gtk_theming_engine_render_activity (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + if (gtk_theming_engine_has_class (engine, "spinner")) + { + GtkStateFlags state; + guint num_steps, step; + GdkRGBA *color; + gdouble dx, dy; + gdouble progress; + gdouble radius; + gdouble half; + gint i; + + gtk_theming_engine_get_style (engine, + "num-steps", &num_steps, + NULL); + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get (engine, state, + "color", &color, + NULL); + if (num_steps == 0) + num_steps = 12; + + if (gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress)) + step = (guint) (progress * num_steps); + else + step = 0; + + cairo_save (cr); + + cairo_translate (cr, x, y); + + /* draw clip region */ + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + + dx = width / 2; + dy = height / 2; + radius = MIN (width / 2, height / 2); + half = num_steps / 2; + + for (i = 0; i < num_steps; i++) + { + gint inset = 0.7 * radius; + + /* transparency is a function of time and intial value */ + gdouble t = (gdouble) ((i + num_steps - step) + % num_steps) / num_steps; + + cairo_save (cr); + + cairo_set_source_rgba (cr, + color->red, + color->green, + color->blue, + color->alpha * t); + + cairo_set_line_width (cr, 2.0); + cairo_move_to (cr, + dx + (radius - inset) * cos (i * G_PI / half), + dy + (radius - inset) * sin (i * G_PI / half)); + cairo_line_to (cr, + dx + radius * cos (i * G_PI / half), + dy + radius * sin (i * G_PI / half)); + cairo_stroke (cr); + + cairo_restore (cr); + } + + cairo_restore (cr); + + gdk_rgba_free (color); + } + else + { + gtk_theming_engine_render_background (engine, cr, x, y, width, height); + gtk_theming_engine_render_frame (engine, cr, x, y, width, height); + } +} diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 9cbae78cf6..78842c6f16 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -151,6 +151,12 @@ struct _GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + void (* render_activity) (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 2efa2947be059e588adb9ae3c968e0a5edbf1978 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 1 Nov 2010 03:58:21 +0100 Subject: [PATCH 390/634] Document gtk_render_* functions. --- gtk/gtkstylecontext.c | 204 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 462d0df71c..8985877f52 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2740,6 +2740,22 @@ gtk_style_context_invalidate (GtkStyleContext *context) } /* Paint methods */ + +/** + * gtk_render_check: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders a checkmark (as in a #GtkCheckButton), the %GTK_STATE_FLAG_ACTIVE + * state will determine whether the check is on or off, and + * %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined. + * + * Since: 3.0 + **/ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, @@ -2764,6 +2780,21 @@ gtk_render_check (GtkStyleContext *context, x, y, width, height); } +/** + * gtk_render_option: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_ACTIVE + * state will determine whether the option is on or off, and + * %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined. + * + * Since: 3.0 + **/ void gtk_render_option (GtkStyleContext *context, cairo_t *cr, @@ -2788,6 +2819,19 @@ gtk_render_option (GtkStyleContext *context, x, y, width, height); } +/** + * gtk_render_arrow: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @angle: arrow angle from 0 to 2 * %G_PI, being 0 the arrow pointing to the north + * @x: Center X for the render area + * @y: Center Y for the render area + * @size: square side for render area + * + * Renders an arrow pointing to @angle. + * + * Since: 3.0 + **/ void gtk_render_arrow (GtkStyleContext *context, cairo_t *cr, @@ -2812,6 +2856,19 @@ gtk_render_arrow (GtkStyleContext *context, angle, x, y, size); } +/** + * gtk_render_background: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders the background of an element. + * + * Since: 3.0. + **/ void gtk_render_background (GtkStyleContext *context, cairo_t *cr, @@ -2835,6 +2892,19 @@ gtk_render_background (GtkStyleContext *context, engine_class->render_background (priv->theming_engine, cr, x, y, width, height); } +/** + * gtk_render_frame: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders a frame around the rectangle defined by @x, @y, @width, @height. + * + * Since: 3.0 + **/ void gtk_render_frame (GtkStyleContext *context, cairo_t *cr, @@ -2858,6 +2928,21 @@ gtk_render_frame (GtkStyleContext *context, engine_class->render_frame (priv->theming_engine, cr, x, y, width, height); } +/** + * gtk_render_expander: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders an expander (as used in #GtkTreeView and #GtkExpander) in the area + * defined by @x, @y, @width, @height. The state %GTK_STATE_FLAG_ACTIVE determines + * whether the expander is collapsed or expanded. + * + * Since: 3.0 + **/ void gtk_render_expander (GtkStyleContext *context, cairo_t *cr, @@ -2881,6 +2966,19 @@ gtk_render_expander (GtkStyleContext *context, engine_class->render_expander (priv->theming_engine, cr, x, y, width, height); } +/** + * gtk_render_focus: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders a focus indicator on the rectangle determined by @x, @y, @width, @height. + * + * Since: 3.0 + **/ void gtk_render_focus (GtkStyleContext *context, cairo_t *cr, @@ -2904,6 +3002,18 @@ gtk_render_focus (GtkStyleContext *context, engine_class->render_focus (priv->theming_engine, cr, x, y, width, height); } +/** + * gtk_render_layout: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin + * @y: Y origin + * @layout: the #PangoLayout to render + * + * Renders @layout on the coordinates @x, @y + * + * Since: 3.0 + **/ void gtk_render_layout (GtkStyleContext *context, cairo_t *cr, @@ -2924,6 +3034,19 @@ gtk_render_layout (GtkStyleContext *context, engine_class->render_layout (priv->theming_engine, cr, x, y, layout); } +/** + * gtk_render_line: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x0: X coordinate for the origin of the line + * @y0: Y coordinate for the origin of the line + * @x1: X coordinate for the end of the line + * @y1: Y coordinate for the end of the line + * + * Renders a line from (x0, y0) to (x1, y1). + * + * Since: 3.0 + **/ void gtk_render_line (GtkStyleContext *context, cairo_t *cr, @@ -2945,6 +3068,22 @@ gtk_render_line (GtkStyleContext *context, engine_class->render_line (priv->theming_engine, cr, x0, y0, x1, y1); } +/** + * gtk_render_slider: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * @orientation: orientation of the slider + * + * Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y, + * @width, @height. @orientation defines whether the slider is vertical + * or horizontal. + * + * Since: 3.0 + **/ void gtk_render_slider (GtkStyleContext *context, cairo_t *cr, @@ -2969,6 +3108,25 @@ gtk_render_slider (GtkStyleContext *context, engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation); } +/** + * gtk_render_frame_gap: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * @gap_side: side where the gap is + * @xy0_gap: initial coordinate (X or Y depending on @gap_side) for the gap + * @xy1_gap: end coordinate (X or Y depending on @gap_side) for the gap + * + * Renders a frame around the rectangle defined by (@x, @y, @width, @height), + * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates for + * %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for %GTK_POS_LEFT + * and %GTK_POS_RIGHT. + * + * Since: 3.0 + **/ void gtk_render_frame_gap (GtkStyleContext *context, cairo_t *cr, @@ -2997,6 +3155,22 @@ gtk_render_frame_gap (GtkStyleContext *context, xy0_gap, xy1_gap); } +/** + * gtk_render_extension: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * @gap_side: side where the gap is + * + * Renders a extension (as in a #GtkNotebook tab) in the rectangle + * defined by @x, @y, @width, @height. The side where the extension + * connects to is defined by @gap_side. + * + * Since: 3.0 + **/ void gtk_render_extension (GtkStyleContext *context, cairo_t *cr, @@ -3021,6 +3195,21 @@ gtk_render_extension (GtkStyleContext *context, engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side); } +/** + * gtk_render_handle: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders a handle (as in #GtkHandleBox, #GtkPaned and + * #GtkWindow's resize grip), in the rectangle + * determined by @x, @y, @width, @height. + * + * Since: 3.0 + **/ void gtk_render_handle (GtkStyleContext *context, cairo_t *cr, @@ -3044,6 +3233,21 @@ gtk_render_handle (GtkStyleContext *context, engine_class->render_handle (priv->theming_engine, cr, x, y, width, height); } +/** + * gtk_render_activity: + * @context: a #GtkStyleContext + * @cr: a #cairo_t + * @x: X origin of the rectangle + * @y: Y origin of the rectangle + * @width: rectangle width + * @height: rectangle height + * + * Renders an activity area (Such as in #GtkSpinner or the + * fill line in #GtkRange), the state %GTK_STATE_FLAG_ACTIVE + * determines whether there is activity going on. + * + * Since: 3.0 + **/ void gtk_render_activity (GtkStyleContext *context, cairo_t *cr, From af20ba6103d0eae66fc860d6a97af165f2ffd0f2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 11:35:42 +0100 Subject: [PATCH 391/634] GtkSymbolicColor: Take const GdkRGBA in new_literal(). --- gtk/gtksymboliccolor.c | 2 +- gtk/gtksymboliccolor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index c37313d198..1873d19750 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -94,7 +94,7 @@ struct _GtkGradient * Since: 3.0 **/ GtkSymbolicColor * -gtk_symbolic_color_new_literal (GdkRGBA *color) +gtk_symbolic_color_new_literal (const GdkRGBA *color) { GtkSymbolicColor *symbolic_color; diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index d52a9d32c5..fdcb915fe4 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -34,7 +34,7 @@ typedef struct _GtkGradient GtkGradient; GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; GType gtk_gradient_get_type (void) G_GNUC_CONST; -GtkSymbolicColor * gtk_symbolic_color_new_literal (GdkRGBA *color); +GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color); GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, gdouble factor); From fb8de847df03b91d3e6f0674021af1fa1ba543b4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 11:36:18 +0100 Subject: [PATCH 392/634] GtkStyleProperties: Merge font descriptions on merge() This is necessary so incomplete font descriptions are ensured to have family and size. --- gtk/gtkstyleproperties.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index df8529bd67..2c3a9558a0 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -1059,7 +1059,19 @@ gtk_style_properties_merge (GtkStyleProperties *props, data = &g_array_index (prop_to_merge->values, ValueData, i); value = property_data_get_value (prop, data->state); - if (replace || !G_IS_VALUE (value)) + if (G_VALUE_TYPE (&data->value) == PANGO_TYPE_FONT_DESCRIPTION && + G_IS_VALUE (value)) + { + PangoFontDescription *font_desc; + PangoFontDescription *font_desc_to_merge; + + /* Handle merging of font descriptions */ + font_desc = g_value_get_boxed (value); + font_desc_to_merge = g_value_get_boxed (&data->value); + + pango_font_description_merge (font_desc, font_desc_to_merge, replace); + } + else if (replace || !G_IS_VALUE (value)) { if (!G_IS_VALUE (value)) g_value_init (value, G_VALUE_TYPE (&data->value)); From 80e74d79bbaa6db10b25bf5d21a0b5c589ecae8c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 11:40:12 +0100 Subject: [PATCH 393/634] GtkStyleContext: Fix merging of local and global providers. --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 8985877f52..fe4084e79a 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -741,7 +741,7 @@ find_next_candidate (GList *local, local_data = local->data; global_data = global->data; - if (local_data->priority >= global_data->priority) + if (local_data->priority < global_data->priority) return local; else return global; From 071ccaf8a7e5777f5e6309bd40a4a6d75d660525 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 12:15:49 +0100 Subject: [PATCH 394/634] Theming documentation fixes 2 functions were not in -sections.txt, and GtkStyleSet was renamed to GtkStyleProperties. --- docs/reference/gtk/gtk3-sections.txt | 50 +++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index d47480836b..db3cfadefa 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5319,6 +5319,7 @@ gtk_symbolic_color_new_literal gtk_symbolic_color_new_mix gtk_symbolic_color_new_name gtk_symbolic_color_new_shade +gtk_symbolic_color_new_alpha gtk_symbolic_color_resolve gtk_symbolic_color_ref gtk_symbolic_color_unref @@ -5337,32 +5338,32 @@ gtk_gradient_get_type
-gtkstyleset -GtkStyleSet -GtkStyleSet -gtk_style_set_clear -gtk_style_set_get -gtk_style_set_get_property -gtk_style_set_get_valist -gtk_style_set_lookup_color -gtk_style_set_lookup_property -gtk_style_set_map_color -gtk_style_set_merge -gtk_style_set_new -gtk_style_set_register_property -gtk_style_set_set -gtk_style_set_set_property -gtk_style_set_set_valist -gtk_style_set_unset_property +gtkstyleproperties +GtkStyleProperties +GtkStyleProperties +gtk_style_properties_clear +gtk_style_properties_get +gtk_style_properties_get_property +gtk_style_properties_get_valist +gtk_style_properties_lookup_color +gtk_style_properties_lookup_property +gtk_style_properties_map_color +gtk_style_properties_merge +gtk_style_properties_new +gtk_style_properties_register_property +gtk_style_properties_set +gtk_style_properties_set_property +gtk_style_properties_set_valist +gtk_style_properties_unset_property -GTK_TYPE_STYLE_SET -GTK_IS_STYLE_SET -GTK_IS_STYLE_SET_CLASS -GTK_STYLE_SET -GTK_STYLE_SET_CLASS -GTK_STYLE_SET_GET_CLASS +GTK_TYPE_STYLE_PROPERTIES +GTK_IS_STYLE_PROPERTIES +GTK_IS_STYLE_PROPERTIES_CLASS +GTK_STYLE_PROPERTIES +GTK_STYLE_PROPERTIES_CLASS +GTK_STYLE_PROPERTIES_GET_CLASS -gtk_style_set_get_type +gtk_style_properties_get_type
@@ -5427,6 +5428,7 @@ gtk_render_line gtk_render_option gtk_render_progress gtk_render_slider +gtk_render_activity GTK_TYPE_STYLE_CONTEXT From 33e95ae65fd8fa7803de4915f3acddba262c80c5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 12:17:06 +0100 Subject: [PATCH 395/634] GtkStyleContext: Add the start of a default set of class names/regions. --- docs/reference/gtk/gtk3-sections.txt | 21 ++++ gtk/gtkstylecontext.h | 139 +++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index db3cfadefa..b87b13a972 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5369,6 +5369,27 @@ gtk_style_properties_get_type
gtkstylecontext GtkStyleContext + +GTK_STYLE_CLASS_BACKGROUND +GTK_STYLE_CLASS_BUTTON +GTK_STYLE_CLASS_CALENDAR +GTK_STYLE_CLASS_CELL +GTK_STYLE_CLASS_CHECK +GTK_STYLE_CLASS_DEFAULT +GTK_STYLE_CLASS_ENTRY +GTK_STYLE_CLASS_HEADER +GTK_STYLE_CLASS_MENU +GTK_STYLE_CLASS_RADIO +GTK_STYLE_CLASS_RUBBERBAND +GTK_STYLE_CLASS_SCROLLBAR +GTK_STYLE_CLASS_SLIDER +GTK_STYLE_CLASS_TOOLTIP +GTK_STYLE_CLASS_TROUGH +GTK_STYLE_REGION_COLUMN +GTK_STYLE_REGION_COLUMN_HEADER +GTK_STYLE_REGION_ROW +GTK_STYLE_REGION_TAB + GtkStyleContext gtk_style_context_new gtk_style_context_add_provider diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 5a3730765d..c57d914c9c 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -49,6 +49,145 @@ struct _GtkStyleContextClass void (* changed) (GtkStyleContext *context); }; +/* Predefined set of CSS classes */ + +/** + * GTK_STYLE_CLASS_CELL: + * + * A CSS class to match content rendered in cell views. + */ +#define GTK_STYLE_CLASS_CELL "cell" + +/** + * GTK_STYLE_CLASS_ENTRY: + * + * A CSS class to match text entries. + */ +#define GTK_STYLE_CLASS_ENTRY "entry" + +/** + * GTK_STYLE_CLASS_BUTTON: + * + * A CSS class to match buttons. + */ +#define GTK_STYLE_CLASS_BUTTON "button" + +/** + * GTK_STYLE_CLASS_CALENDAR: + * + * A CSS class to match calendars. + */ +#define GTK_STYLE_CLASS_CALENDAR "calendar" + +/** + * GTK_STYLE_CLASS_SLIDER: + * + * A CSS class to match sliders. + */ +#define GTK_STYLE_CLASS_SLIDER "slider" + +/** + * GTK_STYLE_CLASS_BACKGROUND: + * + * A CSS class to match the window background. + */ +#define GTK_STYLE_CLASS_BACKGROUND "background" + +/** + * GTK_STYLE_CLASS_RUBBERBAND: + * + * A CSS class to match the rubberband selection rectangle. + */ +#define GTK_STYLE_CLASS_RUBBERBAND "rubberband" + +/** + * GTK_STYLE_CLASS_TOOLTIP: + * + * A CSS class to match tooltip windows. + */ +#define GTK_STYLE_CLASS_TOOLTIP "tooltip" + +/** + * GTK_STYLE_CLASS_MENU: + * + * A CSS class to match popup menus. + */ +#define GTK_STYLE_CLASS_MENU "menu" + +/** + * GTK_STYLE_CLASS_RADIO: + * + * A CSS class to match radio buttons. + */ +#define GTK_STYLE_CLASS_RADIO "radio" + +/** + * GTK_STYLE_CLASS_CHECK: + * + * A CSS class to match check boxes. + */ +#define GTK_STYLE_CLASS_CHECK "check" + +/** + * GTK_STYLE_CLASS_DEFAULT: + * + * A CSS class to match the default widget. + */ +#define GTK_STYLE_CLASS_DEFAULT "default" + +/** + * GTK_STYLE_CLASS_TROUGH: + * + * A CSS class to match troughs, as in scrollbars and progressbars. + */ +#define GTK_STYLE_CLASS_TROUGH "trough" + +/** + * GTK_STYLE_CLASS_SCROLLBAR: + * + * A CSS class to match scrollbars. + */ +#define GTK_STYLE_CLASS_SCROLLBAR "scrollbar" + +/** + * GTK_STYLE_CLASS_HEADER: + * + * A CSS class to match a header element. + */ +#define GTK_STYLE_CLASS_HEADER "header" + + +/* Predefined set of widget regions */ + +/** + * GTK_STYLE_REGION_ROW: + * + * A widget region name to define a treeview row. + */ +#define GTK_STYLE_REGION_ROW "row" + +/** + * GTK_STYLE_REGION_COLUMN: + * + * A widget region name to define a treeview column. + */ +#define GTK_STYLE_REGION_COLUMN "column" + +/** + * GTK_STYLE_REGION_COLUMN_HEADER: + * + * A widget region name to define a treeview column header. + */ +#define GTK_STYLE_REGION_COLUMN_HEADER "column-header" + +/** + * GTK_STYLE_REGION_TAB: + * + * A widget region name to define a notebook tab. + */ +#define GTK_STYLE_REGION_TAB "tab" + + GType gtk_style_context_get_type (void) G_GNUC_CONST; GtkStyleContext * gtk_style_context_new (void); From 920637abef35f4d26a2991b12aac830eb26ec8c4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 12:18:48 +0100 Subject: [PATCH 396/634] GtkStyle: Listen to context changes. This way the GtkStyle is updated to the latest style info, actually emitting ::style-set must be performed after invalidating the style context. --- gtk/gtkstyle.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 5b0721e1f0..6c4530261b 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -79,6 +79,7 @@ typedef struct _GtkStylePrivate GtkStylePrivate; struct _GtkStylePrivate { GSList *color_hashes; GtkStyleContext *context; + gulong context_changed_id; }; enum { @@ -610,7 +611,12 @@ gtk_style_finalize (GObject *object) g_object_unref (style->rc_style); if (priv->context) - g_object_unref (priv->context); + { + if (priv->context_changed_id) + g_signal_handler_disconnect (priv->context, priv->context_changed_id); + + g_object_unref (priv->context); + } G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object); } @@ -735,6 +741,13 @@ gtk_style_update_from_context (GtkStyle *style) } } +static void +style_context_changed (GtkStyleContext *context, + gpointer user_data) +{ + gtk_style_update_from_context (GTK_STYLE (user_data)); +} + static void gtk_style_constructed (GObject *object) { @@ -746,7 +759,8 @@ gtk_style_constructed (GObject *object) { gtk_style_update_from_context (GTK_STYLE (object)); - /* FIXME: Listen to context changes */ + priv->context_changed_id = g_signal_connect (priv->context, "changed", + G_CALLBACK (style_context_changed), object); } } From f383e6b0a2ba681d81296c2f5196e6884f0f211d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 12:21:04 +0100 Subject: [PATCH 397/634] GtkWidget: Add new set of methods to override style information. gtk_widget_override_*() deprecates gtk_widget_modify_*(). There are only functions to modify fg/bg/font/symbolic color, If anything more fancy/complex is needed. There is the possibility of adding a GtkStyleProvider yourself. --- docs/reference/gtk/gtk3-sections.txt | 4 + gtk/gtk.symbols | 5 +- gtk/gtkwidget.c | 290 ++++++++++++++++++++++++--- gtk/gtkwidget.h | 18 +- 4 files changed, 284 insertions(+), 33 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index b87b13a972..e99c91d8fd 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4846,6 +4846,10 @@ gtk_widget_input_shape_combine_region gtk_widget_path gtk_widget_class_path gtk_widget_get_composite_name +gtk_widget_override_background_color +gtk_widget_override_color +gtk_widget_override_font +gtk_widget_override_symbolic_color gtk_widget_modify_style gtk_widget_get_modifier_style gtk_widget_modify_fg diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 7762a0e0a3..d7dc83e19d 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3272,9 +3272,12 @@ gtk_widget_modify_cursor gtk_widget_modify_fg gtk_widget_modify_font gtk_widget_modify_style -gtk_widget_modify_symbolic_color gtk_widget_modify_text gtk_widget_new +gtk_widget_override_background_color +gtk_widget_override_color +gtk_widget_override_font +gtk_widget_override_symbolic_color gtk_widget_path gtk_widget_pop_composite_child gtk_widget_push_composite_child diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5f2299462a..4111f72a8b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -678,6 +678,7 @@ static GQuark quark_tooltip_markup = 0; static GQuark quark_has_tooltip = 0; static GQuark quark_tooltip_window = 0; static GQuark quark_visual = 0; +static GQuark quark_modifier_style = 0; GParamSpecPool *_gtk_widget_child_property_pool = NULL; GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL; @@ -791,6 +792,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip"); quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window"); quark_visual = g_quark_from_static_string ("gtk-widget-visual"); + quark_modifier_style = g_quark_from_static_string ("gtk-widget-modifier-style"); style_property_spec_pool = g_param_spec_pool_new (FALSE); _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE); @@ -7830,30 +7832,208 @@ gtk_widget_modify_color_component (GtkWidget *widget, gtk_widget_modify_style (widget, rc_style); } +static GtkStyleProperties * +_gtk_widget_get_modifier_properties (GtkWidget *widget) +{ + GtkStyleProperties *properties; + + properties = g_object_get_qdata (G_OBJECT (widget), quark_modifier_style); + + if (G_UNLIKELY (!properties)) + { + GtkStyleContext *context; + + properties = gtk_style_properties_new (); + g_object_set_qdata_full (G_OBJECT (widget), + quark_modifier_style, + properties, + (GDestroyNotify) g_object_unref); + + context = gtk_widget_get_style_context (widget); + + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (properties), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + + return properties; +} + /** - * gtk_widget_modify_symbolic_color: + * gtk_widget_override_color: * @widget: a #GtkWidget - * @name: the name of the symbolic color to modify - * @color: (allow-none): the color to assign (does not need to be allocated), - * or %NULL to undo the effect of previous calls to - * of gtk_widget_modify_symbolic_color(). + * @state: the state for which to set the color + * @color: the color to assign, or %NULL to undo the effect + * of previous calls to gtk_widget_override_color() * - * Sets a symbolic color for a widget. - * All other style values are left untouched. See also - * gtk_widget_modify_style(). + * Sets the color to use for a widget. All other style values are left + * untouched. + * + * + * + * This API is mostly meant as a quick way for applications to change a + * widget appearance. If you are developing a widgets library and intend + * this change to be themeable, it is better done by setting meaningful + * CSS classes and regions in your widget/container implementation through + * gtk_style_context_add_class() and gtk_style_context_add_region(). + * + * + * This way, your widget library can install a #GtkCssProvider with the + * %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order to provide a + * default styling for those widgets that need so, and this theming may + * fully overridden by the user's theme. + * + * + * + * + * + * Note that for complex widgets this may bring in + * undesired results (such as uniform background color everywhere), + * in these cases it is better to fully style such widgets through a + * #GtkCssProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + * priority. + * + * * * Since: 3.0 **/ void -gtk_widget_modify_symbolic_color (GtkWidget *widget, - const gchar *name, - const GdkColor *color) +gtk_widget_override_color (GtkWidget *widget, + GtkStateFlags state, + const GdkRGBA *color) { - GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget); + GtkStyleProperties *properties; + GtkStyleContext *context; - _gtk_rc_style_set_symbolic_color (rc_style, name, color); + g_return_if_fail (GTK_IS_WIDGET (widget)); - gtk_widget_modify_style (widget, rc_style); + properties = _gtk_widget_get_modifier_properties (widget); + + gtk_style_properties_set (properties, state, + "color", color, + NULL); + + context = gtk_widget_get_style_context (widget); + gtk_style_context_invalidate (context); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); +} + +/** + * gtk_widget_override_background_color: + * @widget: a #GtkWidget + * @state: the state for which to set the background color + * @color: the color to assign, or %NULL to undo the effect + * of previous calls to gtk_widget_override_background_color() + * + * Sets the background color to use for a widget. All other style values + * are left untouched. See gtk_widget_override_color(). + * + * Since: 3.0 + **/ +void +gtk_widget_override_background_color (GtkWidget *widget, + GtkStateFlags state, + const GdkRGBA *color) +{ + GtkStyleProperties *properties; + GtkStyleContext *context; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + properties = _gtk_widget_get_modifier_properties (widget); + + gtk_style_properties_set (properties, state, + "background-color", color, + NULL); + + context = gtk_widget_get_style_context (widget); + gtk_style_context_invalidate (context); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); +} + +/** + * gtk_widget_override_font: + * @widget: a #GtkWidget + * @font_desc: the font descriptiong to use, or %NULL to undo + * the effect of previous calls to + * gtk_widget_override_font(). + * + * Sets the font to use for a widget. All other style values are + * left untouched. See gtk_widget_override_color(). + * + * Since: 3.0 + **/ +void +gtk_widget_override_font (GtkWidget *widget, + const PangoFontDescription *font_desc) +{ + GtkStyleProperties *properties; + GtkStyleContext *context; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + properties = _gtk_widget_get_modifier_properties (widget); + + gtk_style_properties_set (properties, 0, + "font", font_desc, + NULL); + + context = gtk_widget_get_style_context (widget); + gtk_style_context_invalidate (context); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); +} + +/** + * gtk_widget_override_symbolic_color: + * @widget: a #GtkWidget + * @name: the name of the symbolic color to modify + * @color: (allow-none): the color to assign (does not need to be allocated), + * or %NULL to undo the effect of previous calls to + * gtk_widget_override_symbolic_color(). + * + * Sets a symbolic color for a widget, All other style values are left + * untouched. See gtk_widget_override_color(). + * + * Since: 3.0 + **/ +void +gtk_widget_override_symbolic_color (GtkWidget *widget, + const gchar *name, + const GdkRGBA *color) +{ + GtkStyleProperties *properties; + GtkStyleContext *context; + GtkSymbolicColor *symbolic_color; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + properties = _gtk_widget_get_modifier_properties (widget); + symbolic_color = gtk_symbolic_color_new_literal (color); + + gtk_style_properties_map_color (properties, + name, symbolic_color); + + gtk_symbolic_color_unref (symbolic_color); + + context = gtk_widget_get_style_context (widget); + gtk_style_context_invalidate (context); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); } /** @@ -7873,10 +8053,42 @@ gtk_widget_modify_fg (GtkWidget *widget, GtkStateType state, const GdkColor *color) { + GtkStateFlags flags; + GdkRGBA rgba; + g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE); - gtk_widget_modify_color_component (widget, GTK_RC_FG, state, color); + switch (state) + { + case GTK_STATE_ACTIVE: + flags = GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags = GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags = GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags = GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_NORMAL: + default: + flags = 0; + } + + if (color) + { + rgba.red = color->red / 65535.; + rgba.green = color->green / 65535.; + rgba.blue = color->blue / 65535.; + rgba.alpha = 1; + + gtk_widget_override_color (widget, state, &rgba); + } + else + gtk_widget_override_color (widget, state, NULL); } /** @@ -7904,10 +8116,42 @@ gtk_widget_modify_bg (GtkWidget *widget, GtkStateType state, const GdkColor *color) { + GtkStateFlags flags; + GdkRGBA rgba; + g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE); - gtk_widget_modify_color_component (widget, GTK_RC_BG, state, color); + switch (state) + { + case GTK_STATE_ACTIVE: + flags = GTK_STATE_FLAG_ACTIVE; + break; + case GTK_STATE_PRELIGHT: + flags = GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_SELECTED: + flags = GTK_STATE_FLAG_SELECTED; + break; + case GTK_STATE_INSENSITIVE: + flags = GTK_STATE_FLAG_INSENSITIVE; + break; + case GTK_STATE_NORMAL: + default: + flags = 0; + } + + if (color) + { + rgba.red = color->red / 65535.; + rgba.green = color->green / 65535.; + rgba.blue = color->blue / 65535.; + rgba.alpha = 1; + + gtk_widget_override_background_color (widget, state, &rgba); + } + else + gtk_widget_override_background_color (widget, state, NULL); } /** @@ -8045,21 +8289,9 @@ void gtk_widget_modify_font (GtkWidget *widget, PangoFontDescription *font_desc) { - GtkRcStyle *rc_style; - g_return_if_fail (GTK_IS_WIDGET (widget)); - rc_style = gtk_widget_get_modifier_style (widget); - - if (rc_style->font_desc) - pango_font_description_free (rc_style->font_desc); - - if (font_desc) - rc_style->font_desc = pango_font_description_copy (font_desc); - else - rc_style->font_desc = NULL; - - gtk_widget_modify_style (widget, rc_style); + gtk_widget_override_font (widget, font_desc); } static void diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 9515d71310..eea8c7a0f4 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -758,6 +758,21 @@ gboolean gtk_widget_translate_coordinates (GtkWidget *src_widget, */ gboolean gtk_widget_hide_on_delete (GtkWidget *widget); +/* Functions to override widget styling */ +void gtk_widget_override_color (GtkWidget *widget, + GtkStateFlags state, + const GdkRGBA *color); +void gtk_widget_override_background_color (GtkWidget *widget, + GtkStateFlags state, + const GdkRGBA *color); + +void gtk_widget_override_font (GtkWidget *widget, + const PangoFontDescription *font_desc); + +void gtk_widget_override_symbolic_color (GtkWidget *widget, + const gchar *name, + const GdkRGBA *color); + /* Widget styles. */ void gtk_widget_style_attach (GtkWidget *widget); @@ -788,9 +803,6 @@ void gtk_widget_modify_cursor (GtkWidget *widget, const GdkColor *secondary); void gtk_widget_modify_font (GtkWidget *widget, PangoFontDescription *font_desc); -void gtk_widget_modify_symbolic_color (GtkWidget *widget, - const gchar *name, - const GdkColor *color); PangoContext *gtk_widget_create_pango_context (GtkWidget *widget); PangoContext *gtk_widget_get_pango_context (GtkWidget *widget); From f2c6c82ff0155729e4b6ed94e33d8dc1e3e93dcb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 19:27:18 +0100 Subject: [PATCH 398/634] GtkStatusIcon: update to use gtk_widget_override_symbolic_color(). --- gtk/gtkstatusicon.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c index 678cb8caab..f3bf6383b4 100644 --- a/gtk/gtkstatusicon.c +++ b/gtk/gtkstatusicon.c @@ -1701,8 +1701,16 @@ gtk_status_icon_color_changed (GtkTrayIcon *tray, if (name) { + GdkRGBA rgba; + g_object_get (priv->tray_icon, pspec->name, &color, NULL); - gtk_widget_modify_symbolic_color (priv->image, name, &color); + + rgba.red = color.red / 65535.; + rgba.green = color.green / 65535.; + rgba.blue = color.blue / 65535.; + rgba.alpha = 1; + + gtk_widget_override_symbolic_color (priv->image, name, &rgba); } } From 605fa03248e3ec9d31054a0d8eef268207312ea9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 21:10:06 +0100 Subject: [PATCH 399/634] Fix compile warning --- gtk/gtksettings.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index cbfa7a7d85..ea55a53ab4 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -2633,10 +2633,12 @@ settings_update_theme (GtkSettings *settings) if (new_provider != provider) { if (provider) - gtk_style_context_remove_provider_for_screen (settings->screen, provider); + gtk_style_context_remove_provider_for_screen (settings->screen, + GTK_STYLE_PROVIDER (provider)); if (new_provider) - gtk_style_context_add_provider_for_screen (settings->screen, new_provider, + gtk_style_context_add_provider_for_screen (settings->screen, + GTK_STYLE_PROVIDER (new_provider), GTK_STYLE_PROVIDER_PRIORITY_SETTINGS + 1); g_object_set_qdata_full (G_OBJECT (settings), quark_theme_name, From 06c88571914dda77fec9a152a2dde9a498d3fdf5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 21:12:57 +0100 Subject: [PATCH 400/634] GtkThemingEngine: Fix compile warning. --- gtk/gtkthemingengine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 474bd0da06..bd299f3202 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -755,7 +755,7 @@ gtk_theming_module_load (GTypeModule *type_module) theming_module->module = module; - theming_module->init (theming_module); + theming_module->init (G_TYPE_MODULE (theming_module)); return TRUE; } From a23863211b098d3db2b04f9dcf4a941645c506ae Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Nov 2010 21:14:08 +0100 Subject: [PATCH 401/634] GtkStyleContext: Add gtk_render_icon_pixbuf() This function is similar to gtk_style_render_icon(), which is now implemented on top of this one. --- gtk/gtkstyle.c | 125 ++++++++--------------------------------- gtk/gtkstylecontext.c | 33 +++++++++++ gtk/gtkstylecontext.h | 4 ++ gtk/gtkthemingengine.c | 92 ++++++++++++++++++++++++++++++ gtk/gtkthemingengine.h | 4 ++ 5 files changed, 156 insertions(+), 102 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 6c4530261b..9aba0fa6ea 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -327,6 +327,9 @@ static void hls_to_rgb (gdouble *h, static void style_unrealize_cursors (GtkStyle *style); +static void transform_detail_string (const gchar *detail, + GtkStyleContext *context); + /* * Data for default check and radio buttons */ @@ -1607,54 +1610,6 @@ out: cairo_restore (cr); } -static GdkPixbuf * -scale_or_ref (GdkPixbuf *src, - gint width, - gint height) -{ - if (width == gdk_pixbuf_get_width (src) && - height == gdk_pixbuf_get_height (src)) - { - return g_object_ref (src); - } - else - { - return gdk_pixbuf_scale_simple (src, - width, height, - GDK_INTERP_BILINEAR); - } -} - -static gboolean -lookup_icon_size (GtkStyle *style, - GtkWidget *widget, - GtkIconSize size, - gint *width, - gint *height) -{ - GdkScreen *screen; - GtkSettings *settings; - - if (widget && gtk_widget_has_screen (widget)) - { - screen = gtk_widget_get_screen (widget); - settings = gtk_settings_get_for_screen (screen); - } - else if (style && style->visual) - { - screen = gdk_visual_get_screen (style->visual); - settings = gtk_settings_get_for_screen (screen); - } - else - { - settings = gtk_settings_get_default (); - GTK_NOTE (MULTIHEAD, - g_warning ("Using the default screen for gtk_default_render_icon()")); - } - - return gtk_icon_size_lookup_for_settings (settings, size, width, height); -} - static GdkPixbuf * gtk_default_render_icon (GtkStyle *style, const GtkIconSource *source, @@ -1664,65 +1619,31 @@ gtk_default_render_icon (GtkStyle *style, GtkWidget *widget, const gchar *detail) { - gint width = 1; - gint height = 1; - GdkPixbuf *scaled; - GdkPixbuf *stated; - GdkPixbuf *base_pixbuf; + GtkStyleContext *context; + GtkStylePrivate *priv; + GdkPixbuf *pixbuf; - /* Oddly, style can be NULL in this function, because - * GtkIconSet can be used without a style and if so - * it uses this function. - */ - - base_pixbuf = gtk_icon_source_get_pixbuf (source); - - g_return_val_if_fail (base_pixbuf != NULL, NULL); - - if (size != (GtkIconSize) -1 && !lookup_icon_size(style, widget, size, &width, &height)) + if (widget) + context = gtk_widget_get_style_context (widget); + else { - g_warning (G_STRLOC ": invalid icon size '%d'", size); - return NULL; + priv = GTK_STYLE_GET_PRIVATE (style); + context = priv->context; } - /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise, - * leave it alone. - */ - if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source)) - scaled = scale_or_ref (base_pixbuf, width, height); - else - scaled = g_object_ref (base_pixbuf); + if (!context) + return NULL; - /* If the state was wildcarded, then generate a state. */ - if (gtk_icon_source_get_state_wildcarded (source)) - { - if (state == GTK_STATE_INSENSITIVE) - { - stated = gdk_pixbuf_copy (scaled); - - gdk_pixbuf_saturate_and_pixelate (scaled, stated, - 0.8, TRUE); - - g_object_unref (scaled); - } - else if (state == GTK_STATE_PRELIGHT) - { - stated = gdk_pixbuf_copy (scaled); - - gdk_pixbuf_saturate_and_pixelate (scaled, stated, - 1.2, FALSE); - - g_object_unref (scaled); - } - else - { - stated = scaled; - } - } - else - stated = scaled; - - return stated; + gtk_style_context_save (context); + + if (detail) + transform_detail_string (detail, context); + + pixbuf = gtk_render_icon_pixbuf (context, source, size); + + gtk_style_context_restore (context); + + return pixbuf; } static void diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index fe4084e79a..aaaf78209d 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -3270,3 +3270,36 @@ gtk_render_activity (GtkStyleContext *context, _gtk_theming_engine_set_context (priv->theming_engine, context); engine_class->render_activity (priv->theming_engine, cr, x, y, width, height); } + +/** + * gtk_render_icon_pixbuf: + * @context: a #GtkStyleContext + * @source: the #GtkIconSource specifying the icon to render + * @size: (type int): the size to render the icon at. A size of (GtkIconSize) -1 + * means render at the size of the source and don't scale. + * + * Renders the icon specified by @source at the given @size, returning the result + * in a pixbuf. + * + * Returns: (transfer full): a newly-created #GdkPixbuf containing the rendered icon + * + * Since: 3.0 + **/ +GdkPixbuf * +gtk_render_icon_pixbuf (GtkStyleContext *context, + const GtkIconSource *source, + GtkIconSize size) +{ + GtkStyleContextPrivate *priv; + GtkThemingEngineClass *engine_class; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + g_return_val_if_fail (size >= -1, NULL); + g_return_val_if_fail (source != NULL, NULL); + + priv = context->priv; + engine_class = GTK_THEMING_ENGINE_GET_CLASS (priv->theming_engine); + + _gtk_theming_engine_set_context (priv->theming_engine, context); + return engine_class->render_icon_pixbuf (priv->theming_engine, source, size); +} diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index c57d914c9c..30c08b8b2b 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -404,6 +404,10 @@ void gtk_render_activity (GtkStyleContext *context, gdouble width, gdouble height); +GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context, + const GtkIconSource *source, + GtkIconSize size); + G_END_DECLS #endif /* __GTK_STYLE_CONTEXT_H__ */ diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index bd299f3202..65a3a55600 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -168,6 +168,9 @@ static void gtk_theming_engine_render_activity (GtkThemingEngine *engine, gdouble y, gdouble width, gdouble height); +static GdkPixbuf * gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine, + const GtkIconSource *source, + GtkIconSize size); G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) @@ -220,6 +223,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) klass->render_extension = gtk_theming_engine_render_extension; klass->render_handle = gtk_theming_engine_render_handle; klass->render_activity = gtk_theming_engine_render_activity; + klass->render_icon_pixbuf = gtk_theming_engine_render_icon_pixbuf; /** * GtkThemingEngine:name: @@ -2807,3 +2811,91 @@ gtk_theming_engine_render_activity (GtkThemingEngine *engine, gtk_theming_engine_render_frame (engine, cr, x, y, width, height); } } + +static GdkPixbuf * +scale_or_ref (GdkPixbuf *src, + gint width, + gint height) +{ + if (width == gdk_pixbuf_get_width (src) && + height == gdk_pixbuf_get_height (src)) + return g_object_ref (src); + else + return gdk_pixbuf_scale_simple (src, + width, height, + GDK_INTERP_BILINEAR); +} + +static gboolean +lookup_icon_size (GtkThemingEngine *engine, + GtkIconSize size, + gint *width, + gint *height) +{ + GdkScreen *screen; + GtkSettings *settings; + + screen = gtk_theming_engine_get_screen (engine); + settings = gtk_settings_get_for_screen (screen); + + return gtk_icon_size_lookup_for_settings (settings, size, width, height); +} + +static GdkPixbuf * +gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine, + const GtkIconSource *source, + GtkIconSize size) +{ + GdkPixbuf *scaled; + GdkPixbuf *stated; + GdkPixbuf *base_pixbuf; + GtkStateFlags state; + gint width = 1; + gint height = 1; + + base_pixbuf = gtk_icon_source_get_pixbuf (source); + state = gtk_theming_engine_get_state (engine); + + g_return_val_if_fail (base_pixbuf != NULL, NULL); + + if (size != (GtkIconSize) -1 && + !lookup_icon_size (engine, size, &width, &height)) + { + g_warning (G_STRLOC ": invalid icon size '%d'", size); + return NULL; + } + + /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise, + * leave it alone. + */ + if (size != (GtkIconSize) -1 && + gtk_icon_source_get_size_wildcarded (source)) + scaled = scale_or_ref (base_pixbuf, width, height); + else + scaled = g_object_ref (base_pixbuf); + + /* If the state was wildcarded, then generate a state. */ + if (gtk_icon_source_get_state_wildcarded (source)) + { + if (state & GTK_STATE_FLAG_INSENSITIVE) + { + stated = gdk_pixbuf_copy (scaled); + gdk_pixbuf_saturate_and_pixelate (scaled, stated, + 0.8, TRUE); + g_object_unref (scaled); + } + else if (state & GTK_STATE_FLAG_PRELIGHT) + { + stated = gdk_pixbuf_copy (scaled); + gdk_pixbuf_saturate_and_pixelate (scaled, stated, + 1.2, FALSE); + g_object_unref (scaled); + } + else + stated = scaled; + } + else + stated = scaled; + + return stated; +} diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 78842c6f16..bc830b37f2 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -157,6 +157,10 @@ struct _GtkThemingEngineClass gdouble y, gdouble width, gdouble height); + + GdkPixbuf * (* render_icon_pixbuf) (GtkThemingEngine *engine, + const GtkIconSource *source, + GtkIconSize size); }; GType gtk_theming_engine_get_type (void) G_GNUC_CONST; From 3ea9568c20e1bf6344620169bcf45b59db5436fc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:33:52 +0100 Subject: [PATCH 402/634] GtkSymbolicColor: Do not clamp shade/mix/alpha factors. --- gtk/gtksymboliccolor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 1873d19750..35d944bc84 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -160,7 +160,7 @@ gtk_symbolic_color_new_shade (GtkSymbolicColor *color, symbolic_color = g_slice_new0 (GtkSymbolicColor); symbolic_color->type = COLOR_TYPE_SHADE; symbolic_color->shade.color = gtk_symbolic_color_ref (color); - symbolic_color->shade.factor = CLAMP (factor, 0, 1); + symbolic_color->shade.factor = factor; symbolic_color->ref_count = 1; return symbolic_color; @@ -191,7 +191,7 @@ gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, symbolic_color = g_slice_new0 (GtkSymbolicColor); symbolic_color->type = COLOR_TYPE_ALPHA; symbolic_color->alpha.color = gtk_symbolic_color_ref (color); - symbolic_color->alpha.factor = CLAMP (factor, 0, 1); + symbolic_color->alpha.factor = factor; symbolic_color->ref_count = 1; return symbolic_color; @@ -225,7 +225,7 @@ gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, symbolic_color->type = COLOR_TYPE_MIX; symbolic_color->mix.color1 = gtk_symbolic_color_ref (color1); symbolic_color->mix.color2 = gtk_symbolic_color_ref (color2); - symbolic_color->mix.factor = CLAMP (factor, 0, 1); + symbolic_color->mix.factor = factor; symbolic_color->ref_count = 1; return symbolic_color; From 525963d74d9f54ea502d5ff31ced5534de7cb6cf Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:35:20 +0100 Subject: [PATCH 403/634] GtkSymbolicColor: convert to/from hls when shading. This makes shading equal to GtkStyle's. --- gtk/gtksymboliccolor.c | 181 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 4 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index 35d944bc84..d2506dc4e5 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -292,6 +292,181 @@ gtk_symbolic_color_unref (GtkSymbolicColor *color) } } +static void +rgb_to_hls (gdouble *r, + gdouble *g, + gdouble *b) +{ + gdouble min; + gdouble max; + gdouble red; + gdouble green; + gdouble blue; + gdouble h, l, s; + gdouble delta; + + red = *r; + green = *g; + blue = *b; + + if (red > green) + { + if (red > blue) + max = red; + else + max = blue; + + if (green < blue) + min = green; + else + min = blue; + } + else + { + if (green > blue) + max = green; + else + max = blue; + + if (red < blue) + min = red; + else + min = blue; + } + + l = (max + min) / 2; + s = 0; + h = 0; + + if (max != min) + { + if (l <= 0.5) + s = (max - min) / (max + min); + else + s = (max - min) / (2 - max - min); + + delta = max -min; + if (red == max) + h = (green - blue) / delta; + else if (green == max) + h = 2 + (blue - red) / delta; + else if (blue == max) + h = 4 + (red - green) / delta; + + h *= 60; + if (h < 0.0) + h += 360; + } + + *r = h; + *g = l; + *b = s; +} + +static void +hls_to_rgb (gdouble *h, + gdouble *l, + gdouble *s) +{ + gdouble hue; + gdouble lightness; + gdouble saturation; + gdouble m1, m2; + gdouble r, g, b; + + lightness = *l; + saturation = *s; + + if (lightness <= 0.5) + m2 = lightness * (1 + saturation); + else + m2 = lightness + saturation - lightness * saturation; + m1 = 2 * lightness - m2; + + if (saturation == 0) + { + *h = lightness; + *l = lightness; + *s = lightness; + } + else + { + hue = *h + 120; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + r = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + r = m2; + else if (hue < 240) + r = m1 + (m2 - m1) * (240 - hue) / 60; + else + r = m1; + + hue = *h; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + g = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + g = m2; + else if (hue < 240) + g = m1 + (m2 - m1) * (240 - hue) / 60; + else + g = m1; + + hue = *h - 120; + while (hue > 360) + hue -= 360; + while (hue < 0) + hue += 360; + + if (hue < 60) + b = m1 + (m2 - m1) * hue / 60; + else if (hue < 180) + b = m2; + else if (hue < 240) + b = m1 + (m2 - m1) * (240 - hue) / 60; + else + b = m1; + + *h = r; + *l = g; + *s = b; + } +} + +static void +_shade_color (GdkRGBA *color, + gdouble factor) +{ + GdkRGBA temp; + + temp = *color; + rgb_to_hls (&temp.red, &temp.green, &temp.blue); + + temp.green *= factor; + if (temp.green > 1.0) + temp.green = 1.0; + else if (temp.green < 0.0) + temp.green = 0.0; + + temp.blue *= factor; + if (temp.blue > 1.0) + temp.blue = 1.0; + else if (temp.blue < 0.0) + temp.blue = 0.0; + + hls_to_rgb (&temp.red, &temp.green, &temp.blue); + *color = temp; +} + /** * gtk_symbolic_color_resolve: * @color: a #GtkSymbolicColor @@ -341,10 +516,8 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, if (!gtk_symbolic_color_resolve (color->shade.color, props, &shade)) return FALSE; - resolved_color->red = CLAMP (shade.red * color->shade.factor, 0, 1); - resolved_color->green = CLAMP (shade.green * color->shade.factor, 0, 1); - resolved_color->blue = CLAMP (shade.blue * color->shade.factor, 0, 1); - resolved_color->alpha = shade.alpha; + _shade_color (&shade, color->shade.factor); + *resolved_color = shade; return TRUE; } From 765f653df620c7e9a83c637c7e9d88e19c7b2ea8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:36:05 +0100 Subject: [PATCH 404/634] GtkSymbolicColor: Only require styleproperties when resolving named colors. It is not necessary for resolving colors based on literals, so be a bit less strict here. --- gtk/gtksymboliccolor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index d2506dc4e5..cb5a9191b0 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -488,7 +488,6 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, GdkRGBA *resolved_color) { g_return_val_if_fail (color != NULL, FALSE); - g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); g_return_val_if_fail (resolved_color != NULL, FALSE); switch (color->type) @@ -500,6 +499,8 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GtkSymbolicColor *named_color; + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); + named_color = gtk_style_properties_lookup_color (props, color->name); if (!named_color) From df95a74a2752f9ece372a2dc82fa8c945ce2bc38 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:37:46 +0100 Subject: [PATCH 405/634] GtkThemingEngine: Do not require a default value when registering properties NULL should work for 0 for int/double/enum/... types and NULL for pointer types, this should be sane enough to not require a default value. --- gtk/gtkthemingengine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 65a3a55600..968656fab1 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -377,7 +377,7 @@ gtk_theming_engine_register_property (GtkThemingEngine *engine, g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); g_return_if_fail (property_name != NULL); g_return_if_fail (type != G_TYPE_INVALID); - g_return_if_fail (default_value != NULL && G_IS_VALUE (default_value)); + g_return_if_fail (default_value == NULL || G_IS_VALUE (default_value)); priv = engine->priv; From 271145645cea0898eb461b36b631f9ee0c43887d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:38:52 +0100 Subject: [PATCH 406/634] GtkThemingEngine: Use GtkSymbolicColor for shades. --- gtk/gtkthemingengine.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 968656fab1..583e87e162 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1235,10 +1235,14 @@ color_shade (const GdkRGBA *color, gdouble factor, GdkRGBA *color_return) { - color_return->red = CLAMP (color->red * factor, 0, 1); - color_return->green = CLAMP (color->green * factor, 0, 1); - color_return->blue = CLAMP (color->blue * factor, 0, 1); - color_return->alpha = color->alpha; + GtkSymbolicColor *literal, *shade; + + literal = gtk_symbolic_color_new_literal (color); + shade = gtk_symbolic_color_new_shade (literal, factor); + gtk_symbolic_color_unref (literal); + + gtk_symbolic_color_resolve (shade, NULL, color_return); + gtk_symbolic_color_unref (shade); } static void From 912ad78cc5061de9e36064e291cf07424603bbf8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 6 Nov 2010 12:40:15 +0100 Subject: [PATCH 407/634] Remove GTK_REGION_DEFAULT GTK_STYLE_CLASS_DEFAULT is preferred to match a default area, as it doesn't make sense to have a per-region default. --- gtk/gtkcssprovider.c | 5 ----- gtk/gtkenums.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index eaf952c4f2..eaf850b944 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -463,7 +463,6 @@ enum ParserSymbol { SYMBOL_NTH_CHILD = GTK_STATE_LAST, SYMBOL_FIRST_CHILD, SYMBOL_LAST_CHILD, - SYMBOL_DEFAULT_CHILD, SYMBOL_SORTED_CHILD, /* Scope: nth-child */ @@ -691,7 +690,6 @@ create_scanner (void) g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "nth-child", GUINT_TO_POINTER (SYMBOL_NTH_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "first-child", GUINT_TO_POINTER (SYMBOL_FIRST_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "last-child", GUINT_TO_POINTER (SYMBOL_LAST_CHILD)); - g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "default", GUINT_TO_POINTER (SYMBOL_DEFAULT_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_PSEUDO_CLASS, "sorted", GUINT_TO_POINTER (SYMBOL_SORTED_CHILD)); g_scanner_scope_add_symbol (scanner, SCOPE_NTH_CHILD, "even", GUINT_TO_POINTER (SYMBOL_NTH_CHILD_EVEN)); @@ -1304,8 +1302,6 @@ parse_nth_child (GtkCssProvider *css_provider, *flags = GTK_REGION_FIRST; else if (symbol == SYMBOL_LAST_CHILD) *flags = GTK_REGION_LAST; - else if (symbol == SYMBOL_DEFAULT_CHILD) - *flags = GTK_REGION_DEFAULT; else if (symbol == SYMBOL_SORTED_CHILD) *flags = GTK_REGION_SORTED; else @@ -1496,7 +1492,6 @@ parse_selector (GtkCssProvider *css_provider, if (symbol == SYMBOL_FIRST_CHILD || symbol == SYMBOL_LAST_CHILD || symbol == SYMBOL_NTH_CHILD || - symbol == SYMBOL_DEFAULT_CHILD || symbol == SYMBOL_SORTED_CHILD) { GTokenType token; diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 44fa55b120..cc66e3904c 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -587,7 +587,6 @@ typedef enum * @GTK_REGION_ODD: Region has an odd number within a set. * @GTK_REGION_FIRST: Region is the first one within a set. * @GTK_REGION_LAST: Region is the last one within a set. - * @GTK_REGION_DEFAULT: Region is the default option. * @GTK_REGION_SORTED: Region is part of a sorted area. * * Describes a region within a widget. @@ -597,7 +596,6 @@ typedef enum { GTK_REGION_ODD = 1 << 1, GTK_REGION_FIRST = 1 << 2, GTK_REGION_LAST = 1 << 3, - GTK_REGION_DEFAULT = 1 << 4, GTK_REGION_SORTED = 1 << 5 } GtkRegionFlags; From 4c898a3c7eda36cdcc71a7280af9be3c2654b4cd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 01:30:02 +0100 Subject: [PATCH 408/634] GtkStyleContext: Define some more class names. --- gtk/gtkstylecontext.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 30c08b8b2b..c6150e2407 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -114,6 +114,20 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_MENU "menu" +/** + * GTK_STYLE_CLASS_MENUBAR: + * + * A CSS class to menubars. + */ +#define GTK_STYLE_CLASS_MENUBAR "menubar" + +/** + * GTK_STYLE_CLASS_MENUITEM: + * + * A CSS class to match menu items. + */ +#define GTK_STYLE_CLASS_MENUITEM "menuitem" + /** * GTK_STYLE_CLASS_RADIO: * @@ -156,6 +170,26 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_HEADER "header" +/** + * GTK_STYLE_CLASS_ACCELERATOR: + * + * A CSS class to match an accelerator. + */ +#define GTK_STYLE_CLASS_ACCELERATOR "accelerator" + +/** + * GTK_STYLE_CLASS_GRIP: + * + * A widget class defining a resize grip + */ +#define GTK_STYLE_CLASS_GRIP "grip" + +/** + * GTK_STYLE_CLASS_PROGRESSBAR: + * + * A widget class defining a resize grip + */ +#define GTK_STYLE_CLASS_PROGRESSBAR "progressbar" /* Predefined set of widget regions */ From 46b8cc86868c0acc2a1a11caee22abbad0866b55 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 01:52:25 +0100 Subject: [PATCH 409/634] GtkStyle: Transform menu accelerators string --- gtk/gtkstyle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9aba0fa6ea..3a44de64a4 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1786,6 +1786,8 @@ transform_detail_string (const gchar *detail, } else if (strcmp (detail, "menuitem") == 0) gtk_style_context_add_class (context, "menu"); + else if (strcmp (detail, "accellabel") == 0) + gtk_style_context_add_class (context, "accelerator"); else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; From 1ec47b20dbaa500bc3be9191e9bc124aefce9331 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 02:15:06 +0100 Subject: [PATCH 410/634] GtkStyle: Transform menubar detail string. --- gtk/gtkstyle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 3a44de64a4..b760fea440 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1788,6 +1788,8 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "menu"); else if (strcmp (detail, "accellabel") == 0) gtk_style_context_add_class (context, "accelerator"); + else if (strcmp (detail, "menubar") == 0) + gtk_style_context_add_class (context, "menubar"); else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; From d321713704bcbe400baea97305c9b4d598fbe57d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 02:30:39 +0100 Subject: [PATCH 411/634] GtkStyle: transform window background detail string. --- gtk/gtkstyle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index b760fea440..9acc49c82b 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1790,6 +1790,8 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "accelerator"); else if (strcmp (detail, "menubar") == 0) gtk_style_context_add_class (context, "menubar"); + else if (strcmp (detail, "base") == 0) + gtk_style_context_add_class (context, "background"); else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; From 8b267a58da7051c23c97074eb723b5de95723956 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 02:51:53 +0100 Subject: [PATCH 412/634] GtkCssProvider: Do not miss the last class name in concatenated classes. Selectors like .menu.check or .entry.progressbar were being misparsed and attributed to .menu and .entry. --- gtk/gtkcssprovider.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index eaf850b944..d97435b71f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1363,6 +1363,7 @@ parse_classes (SelectorPath *path, if ((pos = strchr (str, '.')) != NULL) { + /* Leave the last class to the call after the loop */ while (pos) { *pos = '\0'; @@ -1372,8 +1373,8 @@ parse_classes (SelectorPath *path, pos = strchr (str, '.'); } } - else - selector_path_prepend_class (path, str); + + selector_path_prepend_class (path, str); } static GTokenType From 405f2f306a903b67a81924fe0db959b5828010b3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 02:53:12 +0100 Subject: [PATCH 413/634] GtkStyleContext: restore widget state too in restore(). --- gtk/gtkstylecontext.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index aaaf78209d..ed2e68d827 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -222,6 +222,7 @@ struct GtkStyleInfo GArray *style_classes; GArray *regions; GtkJunctionSides junction_sides; + GtkStateFlags state_flags; }; struct StyleData @@ -256,8 +257,6 @@ struct GtkStyleContextPrivate GSList *info_stack; StyleData *current_data; - GtkStateFlags state_flags; - GSList *animation_regions; GSList *animations; @@ -1275,11 +1274,13 @@ gtk_style_context_set_state (GtkStyleContext *context, GtkStateFlags flags) { GtkStyleContextPrivate *priv; + GtkStyleInfo *info; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); priv = context->priv; - priv->state_flags = flags; + info = priv->info_stack->data; + info->state_flags = flags; } /** @@ -1296,11 +1297,14 @@ GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context) { GtkStyleContextPrivate *priv; + GtkStyleInfo *info; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0); priv = context->priv; - return priv->state_flags; + info = priv->info_stack->data; + + return info->state_flags; } static gboolean From 661a13fe4d67d69246eacf5733dc86db25074584 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 12:39:28 +0100 Subject: [PATCH 414/634] GtkStyleContext: Fix check for GtkIconSize in render_icon_pixbuf(). --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index ed2e68d827..cadd28e684 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -3298,7 +3298,7 @@ gtk_render_icon_pixbuf (GtkStyleContext *context, GtkThemingEngineClass *engine_class; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); - g_return_val_if_fail (size >= -1, NULL); + g_return_val_if_fail (size == -1 || size <= GTK_ICON_SIZE_DIALOG, NULL); g_return_val_if_fail (source != NULL, NULL); priv = context->priv; From d6ba3b7d89a1984c477b3ee79458b058109fceeb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 12:48:29 +0100 Subject: [PATCH 415/634] GtkThemingEngine: Get rid of obsolete code for tooltips. --- gtk/gtkthemingengine.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 583e87e162..46577670ef 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1579,25 +1579,15 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, else gdk_cairo_set_source_rgba (cr, bg_color); - if (gtk_theming_engine_has_class (engine, "tooltip")) - { - cairo_fill_preserve (cr); - - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_stroke (cr); - } + if (alpha == 1) + cairo_fill (cr); else { - if (alpha == 1) - cairo_fill (cr); - else - { - cairo_pattern_t *mask; + cairo_pattern_t *mask; - mask = cairo_pattern_create_rgba (1, 1, 1, alpha); - cairo_mask (cr, mask); - cairo_pattern_destroy (mask); - } + mask = cairo_pattern_create_rgba (1, 1, 1, alpha); + cairo_mask (cr, mask); + cairo_pattern_destroy (mask); } cairo_restore (cr); From 3d1403e6849dd6394fb54a61af9140541fd9e880 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 20:12:15 +0100 Subject: [PATCH 416/634] GtkThemingEngine: ensure that background isn't rendered past the frame boundaries. --- gtk/gtkthemingengine.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 46577670ef..42ef073f3b 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1354,7 +1354,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gboolean running; gdouble progress, alpha = 1; GtkJunctionSides junction; - gint radius; + gint radius, border_width; flags = gtk_theming_engine_get_state (engine); junction = gtk_theming_engine_get_junction_sides (engine); @@ -1372,11 +1372,24 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gtk_theming_engine_get (engine, flags, "background-image", &pattern, "background-color", &bg_color, + "border-width", &border_width, "border-radius", &radius, NULL); running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); + if (border_width > 0) + { + x += border_width; + y += border_width; + width -= 2 * border_width; + height -= 2 * border_width; + radius -= 2 * border_width; + + if (radius < 0) + radius = 0; + } + _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_ALL, junction); From f66275fa6ac98d01c90a3ba45d6b8593ad8bed99 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 20:15:19 +0100 Subject: [PATCH 417/634] GtkThemingEngine: Use square cap for solid frames. --- gtk/gtkthemingengine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 42ef073f3b..a2cd214bec 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1654,6 +1654,7 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, break; case GTK_BORDER_STYLE_SOLID: cairo_set_line_width (cr, border_width); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); if (border_width > 1) { From 0431239eadba0b0d1d09c66d14677d25169c8a6b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Nov 2010 20:17:17 +0100 Subject: [PATCH 418/634] GtkThemingEngine: ensure 1px wide frames aren't painted between pixels. --- gtk/gtkthemingengine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index a2cd214bec..c007274ccc 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1663,6 +1663,13 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, width -= border_width; height -= border_width; } + else if (border_width == 1) + { + x += 0.5; + y += 0.5; + width -= 1; + height -= 1; + } _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_ALL, junction); @@ -1675,13 +1682,16 @@ gtk_theming_engine_render_frame (GtkThemingEngine *engine, cairo_set_line_width (cr, border_width); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - d1 = d2 = 0; - if (border_width > 1) { d1 = (gdouble) border_width / 2; d2 = (gdouble) (border_width - (gint) d1) + 1; } + else + { + d1 = 0.5; + d2 = 1; + } cairo_save (cr); From 3848a58b1774318064c09b835165181df3ed5bc3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 18:26:39 +0100 Subject: [PATCH 419/634] GtkCssProvider: theme progressbars in default CSS. --- gtk/gtkcssprovider.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d97435b71f..2a818699a7 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2930,6 +2930,13 @@ gtk_css_provider_get_default (void) " background-color: @base_color;\n" " color: @text_color;\n" "}\n" + "\n" + ".progressbar,\n" + ".entry.progressbar {\n" + " background-color: @selected_bg_color;\n" + " border-color: shade (@selected_bg_color, 0.7);\n" + "}\n" + "\n" ".check, .radio {\n" " background-color: @base_color;\n" " color: @text_color;\n" From 99879d4a5f56fec155a90b3bbb7d613da191508e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 18:27:13 +0100 Subject: [PATCH 420/634] GtkStyle: translate a few more detail strings. --- gtk/gtkstyle.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9acc49c82b..3eca2014e9 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1792,6 +1792,14 @@ transform_detail_string (const gchar *detail, gtk_style_context_add_class (context, "menubar"); else if (strcmp (detail, "base") == 0) gtk_style_context_add_class (context, "background"); + else if (strcmp (detail, "bar") == 0) + gtk_style_context_add_class (context, "progressbar"); + else if (strcmp (detail, "toolbar") == 0) + gtk_style_context_add_class (context, "toolbar"); + else if (strcmp (detail, "handlebox_bin") == 0) + gtk_style_context_add_class (context, "dock"); + else if (strcmp (detail, "notebook") == 0) + gtk_style_context_add_class (context, "notebook"); else if (g_str_has_prefix (detail, "cell")) { GtkRegionFlags row, col; From 48f239c1f2bab93f9fce3c59df5018752cb96ef0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 18:27:36 +0100 Subject: [PATCH 421/634] Add CSS class defines for toolbars and docks. --- gtk/gtkstylecontext.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index c6150e2407..7b335da2cc 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -128,6 +128,13 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_MENUITEM "menuitem" +/** + * GTK_STYLE_CLASS_TOOLBAR: + * + * A CSS class to match toolbars. + */ +#define GTK_STYLE_CLASS_TOOLBAR "toolbar" + /** * GTK_STYLE_CLASS_RADIO: * @@ -184,6 +191,13 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_GRIP "grip" +/** + * GTK_STYLE_CLASS_DOCK: + * + * A widget class defining a dock area + */ +#define GTK_STYLE_CLASS_DOCK "dock" + /** * GTK_STYLE_CLASS_PROGRESSBAR: * From 1cfeeadc704f4644ebb0d95dddc1ee2004b269b3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 18:28:38 +0100 Subject: [PATCH 422/634] GtkWidget: Ensure the style context always has an screen. Things like font settings depend on the screen, and widgets like GtkTextView trigger queries on widgets without screen when the parent window is being destroyed. --- gtk/gtkwidget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4111f72a8b..1ceff2d775 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8388,7 +8388,7 @@ do_screen_change (GtkWidget *widget, _gtk_tooltip_hide (widget); context = gtk_widget_get_style_context (widget); - gtk_style_context_set_screen (context, new_screen); + gtk_style_context_set_screen (context, gtk_widget_get_screen (widget)); g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen); } From d9664021cc4917b93ac9a1aa0183e30226f61c7c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 18:31:39 +0100 Subject: [PATCH 423/634] GtkWidget: Update pango context from style context's font description. --- gtk/gtkwidget.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 1ceff2d775..75e01df78b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8667,12 +8667,22 @@ static void update_pango_context (GtkWidget *widget, PangoContext *context) { - GtkWidgetPrivate *priv = widget->priv; + PangoFontDescription *font_desc; + GtkStyleContext *style_context; - pango_context_set_font_description (context, priv->style->font_desc); + style_context = gtk_widget_get_style_context (widget); + + gtk_style_context_get (style_context, + gtk_widget_get_state_flags (widget), + "font", &font_desc, + NULL); + + pango_context_set_font_description (context, font_desc); pango_context_set_base_dir (context, gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL); + + pango_font_description_free (font_desc); } static void From 3f12fc2bd87209b366e806c01859279830b350de Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 21:24:41 +0100 Subject: [PATCH 424/634] GtkStyleContext: Add gtk_style_context_set_background(). This function replaces gtk_style_set_background(). --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtkstylecontext.c | 42 ++++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 3 ++ 3 files changed, 46 insertions(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index e99c91d8fd..6aad760848 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5419,6 +5419,7 @@ gtk_style_context_push_animatable_region gtk_style_context_remove_provider gtk_style_context_remove_provider_for_screen gtk_style_context_reset_widgets +gtk_style_context_set_background gtk_style_context_restore gtk_style_context_save gtk_style_context_set_direction diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cadd28e684..7554322848 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2743,6 +2743,48 @@ gtk_style_context_invalidate (GtkStyleContext *context) priv->invalidating_context = FALSE; } +/** + * gtk_style_context_set_background: + * @context: a #GtkStyleContext + * @window: a #GdkWindow + * + * Sets the background of @window to the background pattern or + * color specified in @context for its current state. + * + * Since: 3.0 + **/ +void +gtk_style_context_set_background (GtkStyleContext *context, + GdkWindow *window) +{ + GtkStateFlags state; + cairo_pattern_t *pattern; + GdkRGBA *color; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GDK_IS_WINDOW (window)); + + state = gtk_style_context_get_state (context); + gtk_style_context_get (context, state, + "background-image", &pattern, + NULL); + if (pattern) + { + gdk_window_set_background_pattern (window, pattern); + cairo_pattern_destroy (pattern); + return; + } + + gtk_style_context_get (context, state, + "background-color", &color, + NULL); + if (color) + { + gdk_window_set_background_rgba (window, color); + gdk_rgba_free (color); + } +} + /* Paint methods */ /** diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 7b335da2cc..cc83bad00b 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -362,6 +362,9 @@ void gtk_style_context_state_transition_stop (GtkStyleContext *context, void gtk_style_context_invalidate (GtkStyleContext *context); void gtk_style_context_reset_widgets (GdkScreen *screen); +void gtk_style_context_set_background (GtkStyleContext *context, + GdkWindow *window); + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, cairo_t *cr, From dc2df7d178867e9008e7f8c12878709f3a599a68 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 21:26:52 +0100 Subject: [PATCH 425/634] GtkWindow: Use GtkStyleContext for rendering. --- gtk/gtkwindow.c | 76 ++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 1f7134e646..b2b789ad58 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -345,8 +345,7 @@ static gint gtk_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event); static gint gtk_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event); -static void gtk_window_style_set (GtkWidget *widget, - GtkStyle *style); +static void gtk_window_style_updated (GtkWidget *widget); static gint gtk_window_client_event (GtkWidget *widget, GdkEventClient *event); static gboolean gtk_window_state_event (GtkWidget *widget, @@ -595,7 +594,7 @@ gtk_window_class_init (GtkWindowClass *klass) widget_class->window_state_event = gtk_window_state_event; widget_class->direction_changed = gtk_window_direction_changed; widget_class->state_changed = gtk_window_state_changed; - widget_class->style_set = gtk_window_style_set; + widget_class->style_updated = gtk_window_style_updated; container_class->check_resize = gtk_window_check_resize; @@ -4879,12 +4878,12 @@ gtk_window_realize (GtkWidget *widget) { GtkAllocation allocation; GtkWindow *window; - GtkStyle *style; GdkWindow *parent_window; GdkWindow *gdk_window; GdkWindowAttr attributes; gint attributes_mask; GtkWindowPrivate *priv; + GtkStyleContext *context; window = GTK_WINDOW (widget); priv = window->priv; @@ -5012,10 +5011,11 @@ gtk_window_realize (GtkWidget *widget) gdk_window_set_user_data (gdk_window, window); gtk_widget_style_attach (widget); - style = gtk_widget_get_style (widget); - gtk_style_set_background (style, gdk_window, GTK_STATE_NORMAL); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_set_background (context, gdk_window); if (priv->frame) - gtk_style_set_background (style, priv->frame, GTK_STATE_NORMAL); + gtk_style_context_set_background (context, priv->frame); if (priv->transient_parent && gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent))) @@ -5113,12 +5113,13 @@ gtk_window_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget); } -static GdkWindowEdge -get_grip_edge (GtkWidget *widget) +static GtkJunctionSides +get_grip_junction (GtkWidget *widget) { - return gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR - ? GDK_WINDOW_EDGE_SOUTH_EAST - : GDK_WINDOW_EDGE_SOUTH_WEST; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) + return GTK_JUNCTION_BOTTOM | GTK_JUNCTION_RIGHT; + else + return GTK_JUNCTION_BOTTOM | GTK_JUNCTION_LEFT; } static gboolean @@ -5231,7 +5232,7 @@ set_grip_shape (GtkWindow *window) cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0); cairo_paint (cr); cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0); - if (get_grip_edge (GTK_WIDGET (window)) == GDK_WINDOW_EDGE_SOUTH_EAST) + if (get_grip_junction (GTK_WIDGET (window)) & GTK_JUNCTION_RIGHT) { cairo_move_to (cr, width, 0.0); cairo_line_to (cr, width, height); @@ -5461,8 +5462,7 @@ gtk_window_state_changed (GtkWidget *widget, } static void -gtk_window_style_set (GtkWidget *widget, - GtkStyle *style) +gtk_window_style_updated (GtkWidget *widget) { GtkWindow *window = GTK_WINDOW (widget); GtkWindowPrivate *priv = window->priv; @@ -5681,7 +5681,6 @@ gtk_window_get_resize_grip_area (GtkWindow *window, { GtkWidget *widget = GTK_WIDGET (window); GtkAllocation allocation; - GtkStyle *style; gint grip_width; gint grip_height; @@ -5691,7 +5690,6 @@ gtk_window_get_resize_grip_area (GtkWindow *window, return FALSE; gtk_widget_get_allocation (widget, &allocation); - style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "resize-grip-width", &grip_width, @@ -7432,16 +7430,30 @@ gtk_window_draw (GtkWidget *widget, cairo_t *cr) { GtkWindowPrivate *priv = GTK_WINDOW (widget)->priv; + GtkStyleContext *context; gboolean ret = FALSE; + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + if (!gtk_widget_get_app_paintable (widget)) - gtk_paint_flat_box (gtk_widget_get_style (widget), - cr, - GTK_STATE_NORMAL, - GTK_SHADOW_NONE, widget, "base", - 0, 0, - gtk_widget_get_allocated_width (widget), - gtk_widget_get_allocated_height (widget)); + { + GtkStateFlags state; + + state = gtk_widget_get_state_flags (widget); + + if (gtk_window_has_toplevel_focus (GTK_WINDOW (widget))) + state |= GTK_STATE_FLAG_FOCUSED; + + gtk_style_context_set_state (context, state); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND); + gtk_render_background (context, cr, 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); + } + + gtk_style_context_restore (context); if (GTK_WIDGET_CLASS (gtk_window_parent_class)->draw) ret = GTK_WIDGET_CLASS (gtk_window_parent_class)->draw (widget, cr); @@ -7451,18 +7463,18 @@ gtk_window_draw (GtkWidget *widget, { GdkRectangle rect; + gtk_style_context_save (context); cairo_save (cr); + gtk_cairo_transform_to_window (cr, widget, priv->grip_window); gtk_window_get_resize_grip_area (GTK_WINDOW (widget), &rect); - gtk_paint_resize_grip (gtk_widget_get_style (widget), - cr, - gtk_widget_get_state (widget), - widget, - "statusbar", - get_grip_edge (widget), - 0, 0, - rect.width, rect.height); + + gtk_style_context_add_class (context, GTK_STYLE_CLASS_GRIP); + gtk_style_context_set_junction_sides (context, get_grip_junction (widget)); + gtk_render_handle (context, cr, 0, 0, rect.width, rect.height); + cairo_restore (cr); + gtk_style_context_restore (context); } return ret; From 4689b637397cb23dccaf227b1880e32b440b7078 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 21:33:10 +0100 Subject: [PATCH 426/634] GtkButton: Use GtkStyleContext for rendering. --- gtk/gtkbutton.c | 94 ++++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 84b5d0b578..4390424dcb 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -113,7 +113,7 @@ static void gtk_button_realize (GtkWidget * widget); static void gtk_button_unrealize (GtkWidget * widget); static void gtk_button_map (GtkWidget * widget); static void gtk_button_unmap (GtkWidget * widget); -static void gtk_button_style_set (GtkWidget * widget, GtkStyle * prev_style); +static void gtk_button_style_updated (GtkWidget * widget); static void gtk_button_size_allocate (GtkWidget * widget, GtkAllocation * allocation); static gint gtk_button_draw (GtkWidget * widget, cairo_t *cr); @@ -197,7 +197,7 @@ gtk_button_class_init (GtkButtonClass *klass) widget_class->unrealize = gtk_button_unrealize; widget_class->map = gtk_button_map; widget_class->unmap = gtk_button_unmap; - widget_class->style_set = gtk_button_style_set; + widget_class->style_updated = gtk_button_style_updated; widget_class->size_allocate = gtk_button_size_allocate; widget_class->draw = gtk_button_draw; widget_class->button_press_event = gtk_button_button_press; @@ -533,6 +533,7 @@ static void gtk_button_init (GtkButton *button) { GtkButtonPrivate *priv; + GtkStyleContext *context; button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, GTK_TYPE_BUTTON, @@ -561,6 +562,9 @@ gtk_button_init (GtkButton *button) priv->image_is_stock = TRUE; priv->image_position = GTK_POS_LEFT; priv->use_action_appearance = TRUE; + + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); } static void @@ -1375,8 +1379,7 @@ gtk_button_update_image_spacing (GtkButton *button) } static void -gtk_button_style_set (GtkWidget *widget, - GtkStyle *prev_style) +gtk_button_style_updated (GtkWidget *widget) { gtk_button_update_image_spacing (GTK_BUTTON (widget)); } @@ -1441,18 +1444,25 @@ gtk_button_size_allocate (GtkWidget *widget, GtkButton *button = GTK_BUTTON (widget); GtkButtonPrivate *priv = button->priv; GtkAllocation child_allocation; - GtkStyle *style; + GtkStyleContext *context; + GtkStateFlags state; GtkWidget *child; gint xthickness, ythickness; GtkBorder default_border; GtkBorder inner_border; - gint focus_width; + gint focus_width, border_width; gint focus_pad; - style = gtk_widget_get_style (widget); - xthickness = style->xthickness; - ythickness = style->ythickness; + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + + gtk_style_context_get (context, state, + "border-width", &border_width, + NULL); + + xthickness = border_width; + ythickness = border_width; gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL); gtk_widget_style_get (GTK_WIDGET (widget), @@ -1543,7 +1553,8 @@ _gtk_button_paint (GtkButton *button, gint focus_pad; GtkAllocation allocation; GdkWindow *window; - GtkStyle *style; + GtkStyleContext *context; + GtkStateFlags state; widget = GTK_WIDGET (button); @@ -1554,7 +1565,7 @@ _gtk_button_paint (GtkButton *button, NULL); gtk_widget_get_allocation (widget, &allocation); - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); window = gtk_widget_get_window (widget); x = 0; @@ -1563,15 +1574,12 @@ _gtk_button_paint (GtkButton *button, if (gtk_widget_has_default (widget) && priv->relief == GTK_RELIEF_NORMAL) { - gtk_paint_box (style, cr, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - widget, "buttondefault", - x, y, width, height); - x += default_border.left; y += default_border.top; width -= default_border.left + default_border.right; height -= default_border.top + default_border.bottom; + + gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT); } else if (gtk_widget_get_can_default (widget)) { @@ -1589,31 +1597,41 @@ _gtk_button_paint (GtkButton *button, height -= 2 * (focus_width + focus_pad); } + state = gtk_widget_get_state_flags (widget); + gtk_style_context_set_state (context, state); + if (priv->relief != GTK_RELIEF_NONE || priv->depressed || - gtk_widget_get_state(widget) == GTK_STATE_PRELIGHT) - gtk_paint_box (style, cr, - state_type, - shadow_type, widget, "button", - x, y, width, height); - + state & GTK_STATE_FLAG_PRELIGHT) + { + gtk_render_background (context, cr, + x, y, width, height); + gtk_render_frame (context, cr, + x, y, width, height); + } + if (gtk_widget_has_focus (widget)) { gint child_displacement_x; gint child_displacement_y; gboolean displace_focus; - + gint border_width; + gtk_widget_style_get (widget, "child-displacement-y", &child_displacement_y, "child-displacement-x", &child_displacement_x, "displace-focus", &displace_focus, NULL); + gtk_style_context_get (context, state, + "border-width", &border_width, + NULL); + if (interior_focus) { - x += style->xthickness + focus_pad; - y += style->ythickness + focus_pad; - width -= 2 * (style->xthickness + focus_pad); - height -= 2 * (style->ythickness + focus_pad); + x += border_width + focus_pad; + y += border_width + focus_pad; + width -= 2 * (border_width + focus_pad); + height -= 2 * (border_width + focus_pad); } else { @@ -1629,10 +1647,8 @@ _gtk_button_paint (GtkButton *button, y += child_displacement_y; } - gtk_paint_focus (style, cr, - gtk_widget_get_state (widget), - widget, "button", - x, y, width, height); + gtk_render_focus (context, cr, + x, y, width, height); } } @@ -1913,11 +1929,12 @@ gtk_button_get_size (GtkWidget *widget, gint *natural_size) { GtkButton *button = GTK_BUTTON (widget); - GtkStyle *style; + GtkStyleContext *context; GtkWidget *child; GtkBorder default_border; GtkBorder inner_border; - gint focus_width; + GtkStateFlags state; + gint focus_width, border_width; gint focus_pad; gint minimum, natural; @@ -1927,11 +1944,16 @@ gtk_button_get_size (GtkWidget *widget, "focus-padding", &focus_pad, NULL); - style = gtk_widget_get_style (GTK_WIDGET (widget)); + context = gtk_widget_get_style_context (GTK_WIDGET (widget)); + state = gtk_widget_get_state_flags (GTK_WIDGET (widget)); + + gtk_style_context_get (context, state, + "border-width", &border_width, + NULL); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - minimum = (style->xthickness * 2 + + minimum = (border_width * 2 + inner_border.left + inner_border.right); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) @@ -1939,7 +1961,7 @@ gtk_button_get_size (GtkWidget *widget, } else { - minimum = (style->ythickness * 2 + + minimum = (border_width * 2 + inner_border.top + inner_border.bottom); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) From fb97bd1f0a0ad74137654ccc43f12a18d8a9e322 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Nov 2010 21:48:49 +0100 Subject: [PATCH 427/634] GtkThemingEngine: Document missing class vmethods. --- gtk/gtkthemingengine.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index bc830b37f2..3b45fb0abb 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -62,6 +62,9 @@ struct _GtkThemingEngine * @render_layout: Renders a #PangoLayout * @render_slider: Renders a slider control, as in #GtkScale. * @render_handle: Renders a handle to drag UI elements, as in #GtkPaned. + * @render_activity: Renders an area displaying activity, such as in #GtkSpinner, + * or #GtkProgressBar. + * @render_icon_pixbuf: Renders an icon as a #GdkPixbuf. * * Base class for theming engines. */ From 04fbb743887b90f7cdf20c42dbc416669b6e953e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 19:28:51 +0100 Subject: [PATCH 428/634] Add GtkStyleContext migration docs. --- docs/reference/gtk/Makefile.am | 2 + docs/reference/gtk/gtk-docs.sgml | 1 + .../gtk/migrating-GtkStyleContext.xml | 544 ++++++++++++++++++ 3 files changed, 547 insertions(+) create mode 100644 docs/reference/gtk/migrating-GtkStyleContext.xml diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index c14a42725c..bec0615005 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -125,6 +125,7 @@ content_files = \ migrating-2to3.xml \ migrating-checklist.sgml \ migrating-GtkApplication.xml \ + migrating-GtkStyleContext.xml \ objects_grouped.sgml \ osx.sgml \ question_index.sgml \ @@ -147,6 +148,7 @@ expand_content_files = \ migrating-2to3.xml \ migrating-checklist.sgml \ migrating-GtkApplication.xml \ + migrating-GtkStyleContext.xml \ question_index.sgml \ text_widget.sgml \ tree_widget.sgml diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index 0daebefb01..bb9f0cd7fc 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -342,6 +342,7 @@ + diff --git a/docs/reference/gtk/migrating-GtkStyleContext.xml b/docs/reference/gtk/migrating-GtkStyleContext.xml new file mode 100644 index 0000000000..e0a200e6cf --- /dev/null +++ b/docs/reference/gtk/migrating-GtkStyleContext.xml @@ -0,0 +1,544 @@ + + + + Migrating from GtkStyle to GtkStyleContext + + + In GTK+ 3.0, GTK+ was added GtkStyleContext to replace GtkStyle and + the theming infrastructure available in 2.x. GtkStyleContext is an + object similar in spirit to GtkStyle, as it contains theming information, + although in a more complete and tokenized fashion. Moving to #GtkStyleContext + is twofold, there is themes and theming engines on one + side, and applications, widgets and libraries on the other. + + + + Migrating themes + + + From GTK+ 3.0 on, theme engines must implement #GtkThemingEngine and be installed + in $(libdir)/gtk+-3.0/$(GTK_VERSION)/theming-engines, and + the files containing style information must be written in the CSS format as + parsed by #GtkCssProvider. For a theme named "Clearlooks", the CSS file parsed + by default would be $(sharedir)/themes/Clearlooks/gtk-3.0/gtk.css, + with possible variants such as the dark theme being named as "gtk-dark.css" in + the same directory. + + + + + Migrating theme engines + + + Migrating a #GtkStyle based engine to a #GtkThemingEngine based one should + be straightforward for most of the vmethods. Besides a cleanup in the available + paint methods and a cleanup in the parameters passed (in favor of #GtkStyleContext + containing all the information), the available render methods should resemble + those of #GtkStyle quite evidently, with some differences worth to point out: + + + + + All variations of draw_box(), draw_flat_box(), + draw_shadow(), draw_box_gap() and + draw_shadow_gap() become replaced by render_background(), + render_frame() and render_frame_gap(), where + the first would render frameless backgrounds and the last two would render all frame + variants. + + + draw_resize_grip() disappears in favor of + render_handle() with a #GTK_STYLE_CLASS_GRIP class set in the + style context. + + + draw_spinner() disappears in favor of render_activity() + with a #GTK_STYLE_CLASS_SPINNER class set in the style context. + + + + + The available list of render methods is: + + + + gtk_render_background(): Renders a widget/area background. + + gtk_render_frame(): Renders a frame border around the given rectangle. Usually + the detail of the border depends on the theme information, plus the current widget + state. + + gtk_render_layout(): Renders a #PangoLayout + gtk_render_frame_gap(): Renders a frame border with a gap on one side. + + gtk_render_handle(): Renders all kind of handles and resize grips, + usually depending the rendering on the CSS class. + + + gtk_render_check() and gtk_render_option(): Respectively render checkboxes and + radiobuttons. + + + gtk_render_arrow(): Renders an arrow pointing to a direction + + + gtk_render_expander(): Renders an expander indicator, such as in #GtkExpander + + + gtk_render_focus(): Renders the indication that a widget has the keyboard focus + + + gtk_render_line(): Renders a line from one coordinate to another. + + + gtk_render_slider(): Renders a slider indicator, such as in #GtkScale + + + gtk_render_extension(): Renders and extension to an UI element, such as a + notebook tab. + + + gtk_render_activity(): Renders an area displaying activity, be it a progressbar + or a spinner. + + + gtk_render_icon_pixbuf(): Renders an icon into a #GdkPixbuf. + + + + + One of the main differences to #GtkStyle engines is that the rendered widget is + totally isolated from the theme engine, all style information is meant to be + retrieved from the #GtkThemingEngine API, or from the #GtkWidgetPath obtained + from gtk_theming_engine_get_path(), which fully represents the rendered widget's + hierarchy from a styling point of view. + + + + The detail string available in the old engines is now essentially replaced by + widget regions and CSS classes and widget regions. Regions are a way for + container/complex widgets to classify and add ordering hints to its children. + CSS classes identify are a way to label some content being rendered, both regions + and classes can be identified both in CSS files and theming engines. There are + several predefined classes and regions such as %GTK_STYLE_CLASS_BUTTON or + %GTK_STYLE_REGION_TAB in gtkstylecontext.h, although custom widgets may define + their own, which themes may attempt at handling. + + + + + Extending the CSS parser + + + If there is a need for extending the default CSS parser, #GtkRCStyle has been + replaced by gtk_theming_engine_register_property(), where the theming engine + may register new properties that map to a #GType, even if there is builtin + support for most basic types, it is possible to hook a custom parser for the + property. + + + + The installed properties depend on the #GtkThemeEngine::name property, so they + should be added in the constructed() handler. For example, + if an engine with the name "Clearlooks" installs a "focus-color" property, the + property -Clearlooks-focus-color will be registered and + accepted in CSS. + + + + Widget style properties also follow a similar syntax, with the widget type + name used as a prefix, so for example the #GtkWidget:focus-line-width style property + could be modified in CSS as -GtkWidget-focus-line-width. + + + + + Using the CSS file format + + + The difference in syntax between the RC and CSS file formats is evident, it + actually seems shorter to highlight the similarities, although anyone familiar + with CSS3 should get an idea soon of the new format, to make a more or less + comprehensive example, the following RC data: + + + + Sample RC code + + style "default" { + xthickness = 1 + ythickness = 1 + + GtkButton::child-displacement-x = 1 + GtkButton::child-displacement-y = 1 + GtkCheckButton::indicator-size = 14 + + bg[NORMAL] = @bg_color + bg[PRELIGHT] = shade (1.02, @bg_color) + bg[SELECTED] = @selected_bg_color + bg[INSENSITIVE] = @bg_color + bg[ACTIVE] = shade (0.9, @bg_color) + + fg[NORMAL] = @fg_color + fg[PRELIGHT] = @fg_color + fg[SELECTED] = @selected_fg_color + fg[INSENSITIVE] = darker (@bg_color) + fg[ACTIVE] = @fg_color + + text[NORMAL] = @text_color + text[PRELIGHT] = @text_color + text[SELECTED] = @selected_fg_color + text[INSENSITIVE] = darker (@bg_color) + text[ACTIVE] = @selected_fg_color + + base[NORMAL] = @base_color + base[PRELIGHT] = shade (0.95, @bg_color) + base[SELECTED] = @selected_bg_color + base[INSENSITIVE] = @bg_color + base[ACTIVE] = shade (0.9, @selected_bg_color) + + engine "clearlooks" { + colorize_scrollbar = TRUE + style = CLASSIC + } + } + + style "tooltips" { + xthickness = 4 + ythickness = 4 + + bg[NORMAL] = @tooltip_bg_color + fg[NORMAL] = @tooltip_fg_color + } + + style "button" { + xthickness = 3 + ythickness = 3 + + bg[NORMAL] = shade (1.04, @bg_color) + bg[PRELIGHT] = shade (1.06, @bg_color) + bg[ACTIVE] = shade (0.85, @bg_color) + } + + style "entry" { + xthickness = 3 + ythickness = 3 + + bg[SELECTED] = mix (0.4, @selected_bg_color, @base_color) + fg[SELECTED] = @text_color + + engine "clearlooks" { + focus_color = shade (0.65, @selected_bg_color) + } + } + + style "other" { + bg[NORMAL] = #fff; + } + + class "GtkWidget" style "default" + class "GtkEntry" style "entry" + widget_class "*<GtkButton>" style "button" + widget "gtk-tooltip*" style "tooltips" + widget_class "window-name.*.GtkButton" style "other" + + + + + would roughly translate to this CSS: + + + + CSS translation + + * { + padding: 1; + -GtkButton-child-displacement-x: 1; + -GtkButton-child-displacement-y: 1; + -GtkCheckButton-indicator-size: 14; + + background-color: @bg_color; + color: @fg_color; + + -Clearlooks-colorize-scrollbar: true; + -Clearlooks-style: classic; + } + + *:hover { + background-color: shade (@bg_color, 1.02); + } + + *:selected { + background-color: @selected_bg_color; + color: @selected_fg_color; + } + + *:insensitive { + color: shade (@bg_color, 0.7); + } + + *:active { + background-color: shade (@bg_color, 0.9); + } + + .tooltip { + padding: 4; + + background-color: @tooltip_bg_color; + color: @tooltip_fg_color; + } + + .button { + padding: 3; + background-color: shade (@bg_color, 1.04); + } + + .button:hover { + background-color: shade (@bg_color, 1.06); + } + + .button:active { + background-color: shade (@bg_color, 0.85); + } + + .entry { + padding: 3; + + background-color: @base_color; + color: @text_color; + } + + .entry:selected { + background-color: mix (@selected_bg_color, @base_color, 0.4); + -Clearlooks-focus-color: shade (0.65, @selected_bg_color) + } + + /* The latter selector is an specification of the first, + since any widget may use the same classes or names */ + #window-name .button, + GtkWindow#window-name GtkButton.button { + background-color: #fff; + } + + + + + One notable difference is the reduction from fg/bg/text/base colors to only + foreground/background, in exchange the widget is able to render its various + elements with different CSS classes, so they would be themed independently. + + + + It is worth mentioning that the new file format doesn't support custom + keybindings nor stock icon mappings as the RC format did. + + + + + A checklist for widgets + + + When porting your widgets to use #GtkStyleContext, this is usually + the checklist to follow: + + + + + Replace style_set() calls with style_updated(). + + + + + Try to identify the role of what you're rendering with any number of classes, this will + replace the detail string, there is a predefined set of CSS classes. Note that complex + widgets will probably need rendering different elements with different applying CSS + classes in order to have them styled separatedly. This could result in code like + (simplified examples): + + + + Setting a permanent CSS class + + static void + gtk_button_init (GtkButton *button) + { + GtkStyleContext *context; + + ... + + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + + /* Set the "button" class */ + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); + } + + + + + Or + + + + Using dynamic CSS classes for different elements + + static gboolean + gtk_spin_button_draw (GtkSpinButton *spin, + cairo_t *cr) + { + GtkStyleContext *context; + + ... + + context = gtk_widget_get_style_context (GTK_WIDGET (spin)); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_ENTRY); + + /* Call to entry draw impl with "entry" class */ + parent_class->draw (spin, cr); + + gtk_style_context_restore (context); + gtk_style_context_save (context); + + /* Render up/down buttons with the "button" class */ + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); + draw_up_button (spin, cr); + draw_down_button (spin, cr); + + gtk_style_context_restore (context); + + ... + } + + + + + Note that #GtkStyleContext only provides fg/bg colors, so text/base is done through + distinctive theming of the different classes. For example, An entry would usually + be black on white while a button would usually be black on light grey. + + + + + Replace all gtk_paint_*() calls to use gtk_render_*(), + the most distinctive changes are the use of #GtkStateFlags to represent the widget state and + the lack of #GtkShadowType. For gtk_render_check() and gtk_render_option(), the + shadow_type parameter is replaced by the #GTK_STATE_FLAG_ACTIVE and + #GTK_STATE_FLAG_INCONSISTENT state flags. For things such as pressed/unpressed button states, + #GTK_STATE_FLAG_ACTIVE is used, so the CSS may style normal/active states differently to render + outset/inset borders respectively. + + + + Replace all uses of xthickness/ythickness, #GtkStyleContext uses the CSS box model, so + there is the border-width/padding/margin properties to replace the different applications + of X and Y thickness. Note that all of this is merely a guideline to use, which widgets + may choose to obey or not. + + + + + + Parsing from custom resources + + As a consequence of the RC format going away, calling gtk_rc_parse() or gtk_rc_parse_string() + won't be doing anything to the widget styling, the way to replace these calls is using the CSS + format, which is loaded through a #GtkCssProvider, and inserted as a style resource to an + individual widget through gtk_style_context_add_provider() or to all widgets in a screen through + gtk_style_context_add_provider_for_screen(). + + + + Notice that you can also get style information from custom resources by implementing a + #GtkStyleProvider, where it would be translated to something the widget understands. Although + this is an advanced feature that should be rarely used. + + + + + Bonus points + + + There are some features in #GtkStyleContext that weren't available in + #GtkStyle, or were made available over time for certain widgets through + extending the detail string in obscure ways. UI elements being rendered + may be provided now a lot more information, so going through this list + you'll ensure your widget is the perfect citizen in a fully themable UI + + + + + If your widget renders a series of similar elements, such as tabs + in a #GtkNotebook or rows/column in a #GtkTreeView, consider adding + regions through gtk_style_context_add_region(), these regions can be + referenced in CSS and the :nth-child pseudoclass may be used to match + the elements depending on the flags passed. + + + Theming widget regions + + GtkNotebook tab { + background-color: #f3329d; + } + + GtkTreeView row::nth-child (even) { + background-color: #dddddd; + } + + + + + + + If your container renders child widgets within different regions, make it implement + GtkContainer::get_path_for_child(), This function lets containers + assign special #GtkWidgetPaths to child widgets depending on its role/region, + this is necessary to extend the concept above throughout the widget hierarchy. + + + + For example, a #GtkNotebook would modify the tab labels' #GtkWidgetPath so the + "tab" region is added, doing this so would allow the tab label to be themed through: + + + + Theming a widget within a parent container region + + GtkNotebook tab GtkLabel { + font: Sans 8; + } + + + + + + + If you intend several visual elements to look interconnected, make sure you specify + rendered elements' connection areas through gtk_style_context_set_junction_sides() + + + + + #GtkStyleContext supports implicit animations on state changes for the most simple + cases, widgets with one single animatable area, which are changed state through + gtk_widget_set_state_flags() or gtk_widget_unset_state_flags(). These functions + trigger the animations for the affected state flags. + + + If your widget consists of more than a simple area (such as buttons or entries), + and these different areas may be rendered with different states, make sure to + mark the rendered areas through gtk_style_context_push_animatable_region() and + gtk_style_context_pop_animatable_region(). + + + + gtk_style_context_notify_state_change() may be used to trigger a transition for + a given state, the region ID will determine the animatable region that becomes + affected by this transition. + + + + + \ No newline at end of file From 2fe0a51ed020bcff0b252855122d2367dc3aa400 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 19:31:04 +0100 Subject: [PATCH 429/634] Add gtk_render_icon_pixbuf() function to docs. --- docs/reference/gtk/gtk3-sections.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 6aad760848..529151be5c 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5455,6 +5455,7 @@ gtk_render_option gtk_render_progress gtk_render_slider gtk_render_activity +gtk_render_icon_pixbuf GTK_TYPE_STYLE_CONTEXT From 1fb6cc8d772292929d7c9babca4613cccb6f55ee Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 21:43:13 +0100 Subject: [PATCH 430/634] Use the correct cairo-gobject.h include path. --- gtk/gtkcssprovider.c | 2 +- gtk/gtkstyleproperties.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2a818699a7..99776cf475 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include "gtkanimationdescription.h" #include "gtk9slice.h" diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 2c3a9558a0..4620a0d2cb 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include "gtktypebuiltins.h" #include "gtkstyleprovider.h" From 1487b346798889b93d094928cbc9d4033e3c16aa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 21:44:48 +0100 Subject: [PATCH 431/634] Remove GTK_STATE_LAST. It didn't turn out to be that useful, nor widely used. --- gtk/gtkcssprovider.c | 2 +- gtk/gtkenums.h | 3 +-- gtk/gtkstylecontext.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 99776cf475..69594a1414 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -460,7 +460,7 @@ enum ParserScope { */ enum ParserSymbol { /* Scope: pseudo-class */ - SYMBOL_NTH_CHILD = GTK_STATE_LAST, + SYMBOL_NTH_CHILD = GTK_STATE_FOCUSED + 1, SYMBOL_FIRST_CHILD, SYMBOL_LAST_CHILD, SYMBOL_SORTED_CHILD, diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index cc66e3904c..7393a7a2d1 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -369,8 +369,7 @@ typedef enum GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE, GTK_STATE_INCONSISTENT, - GTK_STATE_FOCUSED, - GTK_STATE_LAST + GTK_STATE_FOCUSED } GtkStateType; /* Style for toolbars */ diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 7554322848..e465a1bd87 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2464,7 +2464,7 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GDK_IS_WINDOW (window)); - g_return_if_fail (state < GTK_STATE_LAST); + g_return_if_fail (state > GTK_STATE_NORMAL && state <= GTK_STATE_FOCUSED); priv = context->priv; g_return_if_fail (priv->widget_path != NULL); From 1be9d6ebc9a804b12e0b3c9d8180731ecc3d33aa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 21:46:55 +0100 Subject: [PATCH 432/634] Document missing GtkStateType values. The documentation has also moved to gtkenums.h. --- docs/reference/gtk/tmpl/gtkenums.sgml | 16 ---------------- gtk/gtkenums.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/docs/reference/gtk/tmpl/gtkenums.sgml b/docs/reference/gtk/tmpl/gtkenums.sgml index 90c5817326..4f37bace74 100644 --- a/docs/reference/gtk/tmpl/gtkenums.sgml +++ b/docs/reference/gtk/tmpl/gtkenums.sgml @@ -313,22 +313,6 @@ Used to change the appearance of an outline typically provided by a #GtkFrame. @GTK_SHADOW_ETCHED_IN: The outline has a sunken 3d appearance. @GTK_SHADOW_ETCHED_OUT: The outline has a raised 3d appearance - - -This type indicates the current state of a widget; the state determines how -the widget is drawn. The #GtkStateType enumeration is also used to -identify different colors in a #GtkStyle for drawing, so states can be -used for subparts of a widget as well as entire widgets. - - -@GTK_STATE_NORMAL: State during normal operation. -@GTK_STATE_ACTIVE: State of a currently active widget, such as a depressed button. -@GTK_STATE_PRELIGHT: State indicating that the mouse pointer is over -the widget and the widget will respond to mouse clicks. -@GTK_STATE_SELECTED: State of a selected item, such the selected row in a list. -@GTK_STATE_INSENSITIVE: State indicating that the widget is -unresponsive to user actions. - Used to customize the appearance of a #GtkToolbar. Note that diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 7393a7a2d1..63cc9ee4f3 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -361,6 +361,27 @@ typedef enum } GtkShadowType; /* Widget states */ + +/** + * GtkStateType: + * + * This type indicates the current state of a widget; the state determines how + * the widget is drawn. The #GtkStateType enumeration is also used to + * identify different colors in a #GtkStyle for drawing, so states can be + * used for subparts of a widget as well as entire widgets. + * + * @GTK_STATE_NORMAL: State during normal operation. + * @GTK_STATE_ACTIVE: State of a currently active widget, such as a depressed button. + * @GTK_STATE_PRELIGHT: State indicating that the mouse pointer is over + * the widget and the widget will respond to mouse clicks. + * @GTK_STATE_SELECTED: State of a selected item, such the selected row in a list. + * @GTK_STATE_INSENSITIVE: State indicating that the widget is + * unresponsive to user actions. + * @GTK_STATE_INCONSISTENT: The widget is inconsistent, such as checkbuttons + * or radiobuttons that aren't either set to %TRUE nor %FALSE, + * or buttons requiring the user attention. + * @GTK_STATE_FOCUSED: The widget has the keyboard focus. + */ typedef enum { GTK_STATE_NORMAL, From 44b1a6c852a41b1235998ac91c92f475c5f46e49 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 22:48:29 +0100 Subject: [PATCH 433/634] GtkStyleContext: Add #define's for the default properties. --- docs/reference/gtk/gtk3-sections.txt | 12 +++++ gtk/gtkstylecontext.h | 78 ++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 529151be5c..d55f623fde 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5374,6 +5374,18 @@ gtk_style_properties_get_type gtkstylecontext GtkStyleContext +GTK_STYLE_PROPERTY_BACKGROUND_COLOR +GTK_STYLE_PROPERTY_COLOR +GTK_STYLE_PROPERTY_FONT +GTK_STYLE_PROPERTY_MARGIN +GTK_STYLE_PROPERTY_PADDING +GTK_STYLE_PROPERTY_BORDER_WIDTH +GTK_STYLE_PROPERTY_BORDER_RADIUS +GTK_STYLE_PROPERTY_BORDER_STYLE +GTK_STYLE_PROPERTY_BORDER_COLOR +GTK_STYLE_PROPERTY_BACKGROUND_IMAGE + + GTK_STYLE_CLASS_BACKGROUND GTK_STYLE_CLASS_BUTTON GTK_STYLE_CLASS_CALENDAR diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index cc83bad00b..05322dd1ae 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -49,6 +49,84 @@ struct _GtkStyleContextClass void (* changed) (GtkStyleContext *context); }; +/* Default set of properties that GtkStyleContext may contain */ + +/** + * GTK_STYLE_PROPERTY_BACKGROUND_COLOR: + * + * A property holding the background color of rendered elements as a #GdkRGBA. + */ +#define GTK_STYLE_PROPERTY_BACKGROUND_COLOR "background-color" + +/** + * GTK_STYLE_PROPERTY_COLOR: + * + * A property holding the foreground color of rendered elements as a #GdkRGBA. + */ +#define GTK_STYLE_PROPERTY_COLOR "color" + +/** + * GTK_STYLE_PROPERTY_FONT: + * + * A property holding the font properties used when rendering text + * as a #PangoFontDescription. + */ +#define GTK_STYLE_PROPERTY_FONT "font" + +/** + * GTK_STYLE_PROPERTY_MARGIN: + * + * A property holding the rendered element's margin as a #GtkBorder. The + * margin is defined as the spacing between the border of the element + * and its surrounding elements. + */ +#define GTK_STYLE_PROPERTY_MARGIN "margin" + +/** + * GTK_STYLE_PROPERTY_PADDING: + * + * A property holding the rendered element's padding as a #GtkBorder. The + * padding is defined as the spacing between the inner part of the element border + * and its child. + */ +#define GTK_STYLE_PROPERTY_PADDING "padding" + +/** + * GTK_STYLE_PROPERTY_BORDER_WIDTH: + * + * A property holding the rendered element's border width in pixels as a #gint. + */ +#define GTK_STYLE_PROPERTY_BORDER_WIDTH "border-width" + +/** + * GTK_STYLE_PROPERTY_BORDER_RADIUS: + * + * A property holding the rendered element's border radius in pixels as a #gint. + */ +#define GTK_STYLE_PROPERTY_BORDER_RADIUS "border-radius" + +/** + * GTK_STYLE_PROPERTY_BORDER_STYLE: + * + * A property holding the element's border style as a #GtkBorderStyle. + */ +#define GTK_STYLE_PROPERTY_BORDER_STYLE "border-style" + +/** + * GTK_STYLE_PROPERTY_BORDER_COLOR: + * + * A property holding the element's border color as a #GdkRGBA. + */ +#define GTK_STYLE_PROPERTY_BORDER_COLOR "border-color" + +/** + * GTK_STYLE_PROPERTY_BACKGROUND_IMAGE: + * + * A property holding the element's background as a #cairo_pattern_t. + */ +#define GTK_STYLE_PROPERTY_BACKGROUND_IMAGE "background-image" + + /* Predefined set of CSS classes */ /** From cb2f9a86e5b191914f8d92c1483af28976d12fa2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 22:59:21 +0100 Subject: [PATCH 434/634] GtkCssProvider: allow color names from rgb.txt when parsing colors. --- gtk/gtkcssprovider.c | 76 +++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 69594a1414..dc407742b2 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1564,39 +1564,7 @@ symbolic_color_parse_str (const gchar *string, str = (gchar *) string; *end_ptr = str; - if (str[0] == '#' || str[0] == 'r') - { - GdkRGBA color; - gchar *color_str; - const gchar *end; - - end = str + 1; - - if (str[0] == '#') - while (g_ascii_isxdigit (*end)) - end++; - else - { - while (*end != ')' && *end != '\0') - end++; - - if (*end == ')') - end++; - } - - color_str = g_strndup (str, end - str); - *end_ptr = (gchar *) end; - - if (!gdk_rgba_parse (&color, color_str)) - { - g_free (color_str); - return NULL; - } - - symbolic_color = gtk_symbolic_color_new_literal (&color); - g_free (color_str); - } - else if (str[0] == '@') + if (str[0] == '@') { const gchar *end; gchar *name; @@ -1747,6 +1715,48 @@ symbolic_color_parse_str (const gchar *string, gtk_symbolic_color_unref (color2); (*end_ptr)++; } + else + { + GdkRGBA color; + gchar *color_str; + const gchar *end; + + end = str + 1; + + if (str[0] == '#') + { + /* Color in hex format */ + while (g_ascii_isxdigit (*end)) + end++; + } + else if (g_str_has_prefix (str, "rgb")) + { + /* color in rgb/rgba format */ + while (*end != ')' && *end != '\0') + end++; + + if (*end == ')') + end++; + } + else + { + /* color name? parse until first whitespace */ + while (*end != ' ' && *end != '\0') + end++; + } + + color_str = g_strndup (str, end - str); + *end_ptr = (gchar *) end; + + if (!gdk_rgba_parse (&color, color_str)) + { + g_free (color_str); + return NULL; + } + + symbolic_color = gtk_symbolic_color_new_literal (&color); + g_free (color_str); + } return symbolic_color; } From 815e3499ae03a6428d2b30396826c7769fd8a2a8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 12 Nov 2010 23:59:22 +0100 Subject: [PATCH 435/634] GtkCssProvider: Add lighter/darker color functions. These behave the same than in GtkStyle. --- gtk/gtkcssprovider.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index dc407742b2..20803a2774 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1582,6 +1582,52 @@ symbolic_color_parse_str (const gchar *string, *end_ptr = (gchar *) end; } + else if (g_str_has_prefix (str, "lighter") || + g_str_has_prefix (str, "darker")) + { + GtkSymbolicColor *param_color; + gboolean is_lighter = FALSE; + + is_lighter = g_str_has_prefix (str, "lighter"); + + if (is_lighter) + str += strlen ("lighter"); + else + str += strlen ("darker"); + + SKIP_SPACES (str); + + if (*str != '(') + { + *end_ptr = (gchar *) str; + return NULL; + } + + str++; + SKIP_SPACES (str); + param_color = symbolic_color_parse_str (str, end_ptr); + + if (!param_color) + return NULL; + + str = *end_ptr; + SKIP_SPACES (str); + *end_ptr = (gchar *) str; + + if (*str != ')') + { + gtk_symbolic_color_unref (param_color); + return NULL; + } + + if (is_lighter) + symbolic_color = gtk_symbolic_color_new_shade (param_color, 1.3); + else + symbolic_color = gtk_symbolic_color_new_shade (param_color, 0.7); + + gtk_symbolic_color_unref (param_color); + (*end_ptr)++; + } else if (g_str_has_prefix (str, "shade") || g_str_has_prefix (str, "alpha")) { From 8b9b9c22e710661b56de4dcf68b5c4fd6ca980a8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 01:24:07 +0100 Subject: [PATCH 436/634] GtkCssProvider: Also parse GdkColor values This is necessary for widget style properties to work. --- gtk/gtkcssprovider.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 20803a2774..d41df05de8 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2313,12 +2313,18 @@ css_provider_parse_value (GtkCssProvider *css_provider, type = G_VALUE_TYPE (value); - if (type == GDK_TYPE_RGBA) + if (type == GDK_TYPE_RGBA || + type == GDK_TYPE_COLOR) { GdkRGBA color; + GdkColor rgb; - if (gdk_rgba_parse (&color, value_str) == TRUE) + if (type == GDK_TYPE_RGBA && + gdk_rgba_parse (&color, value_str)) g_value_set_boxed (value, &color); + else if (type == GDK_TYPE_COLOR && + gdk_color_parse (value_str, &rgb)) + g_value_set_boxed (value, &rgb); else { GtkSymbolicColor *symbolic_color; From d865cf4b38f33d95310289351f9fba044bdc3fb8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 01:25:07 +0100 Subject: [PATCH 437/634] GtkStyleProperties: Handle GdkColor types. Just in case. --- gtk/gtkstyleproperties.c | 53 ++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 4620a0d2cb..d1d339ca48 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -575,10 +575,13 @@ gtk_style_properties_set_property (GtkStyleProperties *props, return; } - if (node->property_type == GDK_TYPE_RGBA) + if (node->property_type == GDK_TYPE_RGBA || + node->property_type == GDK_TYPE_COLOR) { /* Allow GtkSymbolicColor as well */ - g_return_if_fail (value_type == GDK_TYPE_RGBA || value_type == GTK_TYPE_SYMBOLIC_COLOR); + g_return_if_fail (value_type == GDK_TYPE_RGBA || + value_type == GDK_TYPE_COLOR || + value_type == GTK_TYPE_SYMBOLIC_COLOR); } else if (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN) { @@ -727,6 +730,27 @@ resolve_color (GtkStyleProperties *props, return TRUE; } +static gboolean +resolve_color_rgb (GtkStyleProperties *props, + GValue *value) +{ + GdkColor color = { 0 }; + GdkRGBA rgba; + + if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &rgba)) + return FALSE; + + color.red = rgba.red * 65535. + 0.5; + color.green = rgba.green * 65535. + 0.5; + color.blue = rgba.blue * 65535. + 0.5; + + g_value_unset (value); + g_value_init (value, GDK_TYPE_COLOR); + g_value_set_boxed (value, &color); + + return TRUE; +} + static gboolean resolve_gradient (GtkStyleProperties *props, GValue *value) @@ -799,9 +823,17 @@ gtk_style_properties_get_property (GtkStyleProperties *props, if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - g_return_val_if_fail (node->property_type == GDK_TYPE_RGBA, FALSE); - - if (!resolve_color (props, val)) + if (node->property_type == GDK_TYPE_RGBA) + { + if (!resolve_color (props, val)) + return FALSE; + } + else if (node->property_type == GDK_TYPE_COLOR) + { + if (!resolve_color_rgb (props, val)) + return FALSE; + } + else return FALSE; } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) @@ -866,9 +898,16 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - g_return_if_fail (node->property_type == GDK_TYPE_RGBA); + gboolean resolved; - if (!resolve_color (props, val)) + if (node->property_type == GDK_TYPE_RGBA) + resolved = resolve_color (props, val); + else if (node->property_type == GDK_TYPE_COLOR) + resolved = resolve_color_rgb (props, val); + else + resolved = FALSE; + + if (!resolved) val = &node->default_value; } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) From c57fdf4c750932dc837c9df991bdf0a1bcab9f70 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 02:18:11 +0100 Subject: [PATCH 438/634] GtkStyleContext: Resolve symbolic colors for widget style properties. --- gtk/gtkstylecontext.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index e465a1bd87..8023f9b99d 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2018,13 +2018,48 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, { for (list = priv->providers_last; list; list = list->prev) { - GtkStyleProviderData *data; + GtkStyleProviderData *provider_data; - data = list->data; + provider_data = list->data; - if (gtk_style_provider_get_style_property (data->provider, priv->widget_path, + if (gtk_style_provider_get_style_property (provider_data->provider, priv->widget_path, pspec->name, &pcache->value)) - return &pcache->value; + { + /* Resolve symbolic colors to GdkColor/GdkRGBA */ + if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR) + { + GtkSymbolicColor *color; + GdkRGBA rgba; + + color = g_value_get_boxed (&pcache->value); + + if (gtk_symbolic_color_resolve (color, data->store, &rgba)) + { + g_value_unset (&pcache->value); + + if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA) + { + g_value_init (&pcache->value, GDK_TYPE_RGBA); + g_value_set_boxed (&pcache->value, &rgba); + } + else + { + GdkColor rgb; + + rgb.red = rgba.red * 65535. + 0.5; + rgb.green = rgba.green * 65535. + 0.5; + rgb.blue = rgba.blue * 65535. + 0.5; + + g_value_init (&pcache->value, GDK_TYPE_COLOR); + g_value_set_boxed (&pcache->value, &rgb); + } + } + else + g_param_value_set_default (pspec, &pcache->value); + } + + return &pcache->value; + } } } From 65abcb722ecdfbe8180831e78bb3e807238d9e72 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 02:30:53 +0100 Subject: [PATCH 439/634] GtkCssProvider: Handle the "none" keyword to unset properties. --- gtk/gtkcssprovider.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index d41df05de8..6aec774de9 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2644,7 +2644,12 @@ parse_rule (GtkCssProvider *css_provider, val = g_slice_new0 (GValue); g_value_init (val, prop_type); - if (prop_type == G_TYPE_STRING) + if (strcmp (value_str, "none") == 0) + { + /* Remove/unset the current value */ + g_hash_table_remove (priv->cur_properties, prop); + } + else if (prop_type == G_TYPE_STRING) { g_value_set_string (val, value_str); g_hash_table_insert (priv->cur_properties, prop, val); From 5cb6fed0bd6ee4bb22ac75355bbbcba06273d49e Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 03:55:21 +0100 Subject: [PATCH 440/634] GtkCssProvider: Add initial unit parsing logic At the moment only "px" are supported, and such is the default value when no unit is specified. --- gtk/gtkcssprovider.c | 150 +++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 33 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 6aec774de9..3eda11cd2f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2303,6 +2303,120 @@ slice_parse (GtkCssProvider *css_provider, return slice; } +static gdouble +unit_parse_str (const gchar *str, + gchar **end_str) +{ + gdouble unit; + + SKIP_SPACES (str); + unit = g_strtod (str, end_str); + str = *end_str; + + /* Now parse the unit type, if any. We + * don't admit spaces between these. + */ + if (*str != ' ' && *str != '\0') + { + while (**end_str != ' ' && **end_str != '\0') + (*end_str)++; + + /* Only handle pixels at the moment */ + if (strncmp (str, "px", 2) != 0) + { + gchar *type; + + type = g_strndup (str, *end_str - str); + g_warning ("Unknown unit '%s', only pixel units are " + "currently supported in CSS style", type); + g_free (type); + } + } + + return unit; +} + +static GtkBorder * +border_parse_str (const gchar *str, + gchar **end_str) +{ + gdouble first, second, third, fourth; + GtkBorder *border; + + border = gtk_border_new (); + + SKIP_SPACES (str); + if (!g_ascii_isdigit (*str)) + return border; + + first = unit_parse_str (str, end_str); + str = *end_str; + SKIP_SPACES (str); + + if (!g_ascii_isdigit (*str)) + { + border->left = border->right = border->top = border->bottom = (gint) first; + *end_str = (gchar *) str; + return border; + } + + second = unit_parse_str (str, end_str); + str = *end_str; + SKIP_SPACES (str); + + if (!g_ascii_isdigit (*str)) + { + border->top = border->bottom = (gint) first; + border->left = border->right = (gint) second; + *end_str = (gchar *) str; + return border; + } + + third = unit_parse_str (str, end_str); + str = *end_str; + SKIP_SPACES (str); + + if (!g_ascii_isdigit (*str)) + { + border->top = (gint) first; + border->left = border->right = (gint) second; + border->bottom = (gint) third; + *end_str = (gchar *) str; + return border; + } + + fourth = unit_parse_str (str, end_str); + + border->top = (gint) first; + border->right = (gint) second; + border->bottom = (gint) third; + border->left = (gint) fourth; + + return border; +} + +static GtkBorder * +border_parse (const gchar *str) +{ + GtkBorder *border; + gchar *end; + + border = border_parse_str (str, &end); + + if (*end != '\0') + { + g_warning ("Error parsing border \"%s\", stopped at char %ld : '%c'", + str, end - str, *end); + + if (border) + gtk_border_free (border); + + return NULL; + } + + return border; +} + static gboolean css_provider_parse_value (GtkCssProvider *css_provider, const gchar *value_str, @@ -2378,40 +2492,10 @@ css_provider_parse_value (GtkCssProvider *css_provider, } else if (type == GTK_TYPE_BORDER) { - guint first, second, third, fourth; - GtkBorder border; + GtkBorder *border; - /* FIXME: no unit support */ - if (sscanf (value_str, "%d %d %d %d", - &first, &second, &third, &fourth) == 4) - { - border.top = first; - border.right = second; - border.bottom = third; - border.left = fourth; - } - else if (sscanf (value_str, "%d %d %d", - &first, &second, &third) == 3) - { - border.top = first; - border.left = border.right = second; - border.bottom = third; - } - else if (sscanf (value_str, "%d %d", &first, &second) == 2) - { - border.top = border.bottom = first; - border.left = border.right = second; - } - else if (sscanf (value_str, "%d", &first) == 1) - { - border.top = border.bottom = first; - border.left = border.right = first; - } - else - parsed = FALSE; - - if (parsed) - g_value_set_boxed (value, &border); + border = border_parse (value_str); + g_value_take_boxed (value, border); } else if (type == CAIRO_GOBJECT_TYPE_PATTERN) { From 9bb96e271d523c61a9eda6794b5f540b40470304 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 12:36:24 +0100 Subject: [PATCH 441/634] GtkCssProviders: Parse GTypeFlags based values. --- gtk/gtkcssprovider.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 3eda11cd2f..3b112a9102 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2523,6 +2523,52 @@ css_provider_parse_value (GtkCssProvider *css_provider, g_value_set_enum (value, enum_value->value); g_type_class_unref (class); } + else if (G_TYPE_IS_FLAGS (type)) + { + GFlagsClass *flags_class; + GFlagsValue *flag_value; + guint flags = 0; + gchar *ptr; + + flags_class = g_type_class_ref (type); + + /* Parse comma separated values */ + ptr = strchr (value_str, ','); + + while (ptr) + { + gchar *flag_str; + + *ptr = '\0'; + ptr++; + + flag_str = (gchar *) value_str; + flag_value = g_flags_get_value_by_nick (flags_class, + g_strstrip (flag_str)); + + if (!flag_value) + g_warning ("Unknown flag '%s' for type '%s'", + value_str, g_type_name (type)); + else + flags |= flag_value->value; + + value_str = ptr; + ptr = strchr (value_str, ','); + } + + /* Store last/only value */ + flag_value = g_flags_get_value_by_nick (flags_class, value_str); + + if (!flag_value) + g_warning ("Unknown flag '%s' for type '%s'", + value_str, g_type_name (type)); + else + flags |= flag_value->value; + + /* Set parsed flags */ + g_value_set_enum (value, flags); + g_type_class_unref (flags_class); + } else if (type == GTK_TYPE_9SLICE) { Gtk9Slice *slice; From 1123159dc99b7fe792d2bb904bb6f834f4a84b82 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 12:44:55 +0100 Subject: [PATCH 442/634] GtkCssProvider: Handle better wrong enum/flag values. --- gtk/gtkcssprovider.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 3b112a9102..2d1b0f09ab 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2514,14 +2514,22 @@ css_provider_parse_value (GtkCssProvider *css_provider, } else if (G_TYPE_IS_ENUM (type)) { - GEnumClass *class; + GEnumClass *enum_class; GEnumValue *enum_value; - class = g_type_class_ref (type); - enum_value = g_enum_get_value_by_nick (class, value_str); + enum_class = g_type_class_ref (type); + enum_value = g_enum_get_value_by_nick (enum_class, value_str); - g_value_set_enum (value, enum_value->value); - g_type_class_unref (class); + if (!enum_value) + { + g_warning ("Unknown value '%s' for enum type '%s'", + value_str, g_type_name (type)); + parsed = FALSE; + } + else + g_value_set_enum (value, enum_value->value); + + g_type_class_unref (enum_class); } else if (G_TYPE_IS_FLAGS (type)) { @@ -2535,7 +2543,7 @@ css_provider_parse_value (GtkCssProvider *css_provider, /* Parse comma separated values */ ptr = strchr (value_str, ','); - while (ptr) + while (ptr && parsed) { gchar *flag_str; @@ -2547,8 +2555,11 @@ css_provider_parse_value (GtkCssProvider *css_provider, g_strstrip (flag_str)); if (!flag_value) - g_warning ("Unknown flag '%s' for type '%s'", - value_str, g_type_name (type)); + { + g_warning ("Unknown flag '%s' for type '%s'", + value_str, g_type_name (type)); + parsed = FALSE; + } else flags |= flag_value->value; @@ -2560,13 +2571,17 @@ css_provider_parse_value (GtkCssProvider *css_provider, flag_value = g_flags_get_value_by_nick (flags_class, value_str); if (!flag_value) - g_warning ("Unknown flag '%s' for type '%s'", - value_str, g_type_name (type)); + { + g_warning ("Unknown flag '%s' for type '%s'", + value_str, g_type_name (type)); + parsed = FALSE; + } else flags |= flag_value->value; - /* Set parsed flags */ - g_value_set_enum (value, flags); + if (parsed) + g_value_set_enum (value, flags); + g_type_class_unref (flags_class); } else if (type == GTK_TYPE_9SLICE) From bcf81a0e2315ecee055406218b83652ebeb65269 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 13:24:18 +0100 Subject: [PATCH 443/634] Handle looping transition animations. --- gtk/gtkanimationdescription.c | 29 +++++++++++++++++++++-------- gtk/gtkanimationdescription.h | 4 +++- gtk/gtkcssprovider.c | 4 ++-- gtk/gtkstylecontext.c | 20 +++++++++++++++----- gtk/gtkstyleproperties.c | 5 +---- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/gtk/gtkanimationdescription.c b/gtk/gtkanimationdescription.c index a0cc3be533..cef6ade0c8 100644 --- a/gtk/gtkanimationdescription.c +++ b/gtk/gtkanimationdescription.c @@ -25,19 +25,21 @@ struct GtkAnimationDescription { GtkTimelineProgressType progress_type; gdouble duration; - + guint loop : 1; guint ref_count; }; GtkAnimationDescription * gtk_animation_description_new (gdouble duration, - GtkTimelineProgressType progress_type) + GtkTimelineProgressType progress_type, + gboolean loop) { GtkAnimationDescription *desc; desc = g_slice_new (GtkAnimationDescription); desc->duration = duration; desc->progress_type = progress_type; + desc->loop = loop; desc->ref_count = 1; return desc; @@ -55,6 +57,12 @@ gtk_animation_description_get_progress_type (GtkAnimationDescription *desc) return desc->progress_type; } +gboolean +gtk_animation_description_get_loop (GtkAnimationDescription *desc) +{ + return (desc->loop != 0); +} + GtkAnimationDescription * gtk_animation_description_ref (GtkAnimationDescription *desc) { @@ -75,18 +83,23 @@ GtkAnimationDescription * gtk_animation_description_from_string (const gchar *str) { gchar timing_function[16] = { 0, }; - gchar duration_measurement[3] = { 0, }; + gchar duration_unit[3] = { 0, }; GtkTimelineProgressType progress_type; guint duration = 0; + gboolean loop; - if (sscanf (str, "%d%2s %15s", &duration, duration_measurement, timing_function) != 3) + if (sscanf (str, "%d%2s %15s loop", &duration, duration_unit, timing_function) == 3) + loop = TRUE; + else if (sscanf (str, "%d%2s %15s", &duration, duration_unit, timing_function) == 3) + loop = FALSE; + else return NULL; - if (strcmp (duration_measurement, "s") == 0) + if (strcmp (duration_unit, "s") == 0) duration *= 1000; - else if (strcmp (duration_measurement, "ms") != 0) + else if (strcmp (duration_unit, "ms") != 0) { - g_warning ("Unknown duration measurement: %s\n", duration_measurement); + g_warning ("Unknown duration unit: %s\n", duration_unit); return NULL; } @@ -106,7 +119,7 @@ gtk_animation_description_from_string (const gchar *str) return NULL; } - return gtk_animation_description_new ((gdouble) duration, progress_type); + return gtk_animation_description_new ((gdouble) duration, progress_type, loop); } GType diff --git a/gtk/gtkanimationdescription.h b/gtk/gtkanimationdescription.h index 7770df2f02..34fc8fcb95 100644 --- a/gtk/gtkanimationdescription.h +++ b/gtk/gtkanimationdescription.h @@ -32,10 +32,12 @@ typedef struct GtkAnimationDescription GtkAnimationDescription; GType gtk_animation_description_get_type (void) G_GNUC_CONST; GtkAnimationDescription * gtk_animation_description_new (gdouble duration, - GtkTimelineProgressType progress_type); + GtkTimelineProgressType progress_type, + gboolean loop); gdouble gtk_animation_description_get_duration (GtkAnimationDescription *desc); GtkTimelineProgressType gtk_animation_description_get_progress_type (GtkAnimationDescription *desc); +gboolean gtk_animation_description_get_loop (GtkAnimationDescription *desc); GtkAnimationDescription * gtk_animation_description_ref (GtkAnimationDescription *desc); void gtk_animation_description_unref (GtkAnimationDescription *desc); diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2d1b0f09ab..06c866f1b3 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -364,12 +364,12 @@ * * * transition - * duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] + * duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] [loop]? * * * * transition: 150ms ease-in-out; - * transition: 1s linear; + * transition: 1s linear loop; * * * diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 8023f9b99d..2fcabd24ac 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -584,6 +584,7 @@ animation_info_new (GtkStyleContext *context, gpointer region_id, gdouble duration, GtkTimelineProgressType progress_type, + gboolean loop, GtkStateType state, gboolean target_value, GdkWindow *window) @@ -600,8 +601,9 @@ animation_info_new (GtkStyleContext *context, info->region_id = region_id; gtk_timeline_set_progress_type (info->timeline, progress_type); + gtk_timeline_set_loop (info->timeline, loop); - if (!target_value) + if (!loop && !target_value) { gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); gtk_timeline_rewind (info->timeline); @@ -2551,11 +2553,13 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, info = animation_info_lookup (context, region_id, state); - if (info) + if (info && + info->target_value != state_value) { - /* Reverse the animation if target values are the opposite */ - if (info->target_value != state_value) + /* Target values are the opposite */ + if (!gtk_timeline_get_loop (info->timeline)) { + /* Reverse the animation */ if (gtk_timeline_get_direction (info->timeline) == GTK_TIMELINE_DIRECTION_FORWARD) gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD); else @@ -2563,12 +2567,18 @@ gtk_style_context_notify_state_change (GtkStyleContext *context, info->target_value = state_value; } + else + { + /* Take it out of its looping state */ + gtk_timeline_set_loop (info->timeline, FALSE); + } } - else + else if (!info) { info = animation_info_new (context, region_id, gtk_animation_description_get_duration (desc), gtk_animation_description_get_progress_type (desc), + gtk_animation_description_get_loop (desc), state, state_value, window); priv->animations = g_slist_prepend (priv->animations, info); diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index d1d339ca48..d5cc2b73d9 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -102,10 +102,7 @@ gtk_style_properties_class_init (GtkStylePropertiesClass *klass) gtk_style_properties_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); g_value_unset (&val); - g_value_init (&val, GTK_TYPE_ANIMATION_DESCRIPTION); - g_value_take_boxed (&val, gtk_animation_description_new (0, GTK_TIMELINE_PROGRESS_LINEAR)); - gtk_style_properties_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, &val, NULL); - g_value_unset (&val); + gtk_style_properties_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, NULL, NULL); g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate)); } From 1c847d9c21c18f4c7b5297496ee98e1e5a13458a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 13:27:37 +0100 Subject: [PATCH 444/634] GtkCssProvider: Docs fix for -gtk-gradient() syntax. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 06c866f1b3..0f220e3138 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -339,7 +339,7 @@ * * * -gtk-gradient (linear, - * top left, top right, + * left top, right top, * from (#fff), to (#000)); * -gtk-gradient (linear, 0.0 0.5, 0.5 1.0, * from (#fff), From 62ee0956e310a482d53e40258f021a5f9b4a1cec Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 19:53:36 +0100 Subject: [PATCH 445/634] GtkStyleProperties: Use GParamSpec for properties registration. --- gtk/gtkcssprovider.c | 8 +- gtk/gtkstyleproperties.c | 222 ++++++++++++++++++++++++--------------- gtk/gtkstyleproperties.h | 12 +-- gtk/gtkthemingengine.c | 55 +++++----- gtk/gtkthemingengine.h | 10 +- 5 files changed, 176 insertions(+), 131 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 0f220e3138..1b856c36af 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2758,7 +2758,7 @@ parse_rule (GtkCssProvider *css_provider, { const gchar *value_str = NULL; GtkStylePropertyParser parse_func = NULL; - GType prop_type; + GParamSpec *pspec; GError *error = NULL; gchar *prop; @@ -2782,19 +2782,19 @@ parse_rule (GtkCssProvider *css_provider, value_str = g_strstrip (scanner->value.v_identifier); - if (gtk_style_properties_lookup_property (prop, &prop_type, &parse_func)) + if (gtk_style_properties_lookup_property (prop, &parse_func, &pspec)) { GValue *val; val = g_slice_new0 (GValue); - g_value_init (val, prop_type); + g_value_init (val, pspec->value_type); if (strcmp (value_str, "none") == 0) { /* Remove/unset the current value */ g_hash_table_remove (priv->cur_properties, prop); } - else if (prop_type == G_TYPE_STRING) + else if (pspec->value_type == G_TYPE_STRING) { g_value_set_string (val, value_str); g_hash_table_insert (priv->cur_properties, prop, val); diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index d5cc2b73d9..3adad1f373 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -40,8 +40,7 @@ typedef struct ValueData ValueData; struct PropertyNode { GQuark property_quark; - GType property_type; - GValue default_value; + GParamSpec *pspec; GtkStylePropertyParser parse_func; }; @@ -76,33 +75,78 @@ static void gtk_style_properties_class_init (GtkStylePropertiesClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GValue val = { 0 }; object_class->finalize = gtk_style_properties_finalize; /* Initialize default property set */ - gtk_style_properties_register_property ("color", GDK_TYPE_RGBA, NULL, NULL); - gtk_style_properties_register_property ("background-color", GDK_TYPE_RGBA, NULL, NULL); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("color", + "Foreground color", + "Foreground color", + GDK_TYPE_RGBA, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("background-color", + "Background color", + "Background color", + GDK_TYPE_RGBA, 0)); - gtk_style_properties_register_property ("font", PANGO_TYPE_FONT_DESCRIPTION, NULL, NULL); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("font", + "Font Description", + "Font Description", + PANGO_TYPE_FONT_DESCRIPTION, 0)); - gtk_style_properties_register_property ("margin", GTK_TYPE_BORDER, NULL, NULL); - gtk_style_properties_register_property ("padding", GTK_TYPE_BORDER, NULL, NULL); - - gtk_style_properties_register_property ("border-width", G_TYPE_INT, NULL, NULL); - gtk_style_properties_register_property ("border-radius", G_TYPE_INT, NULL, NULL); - gtk_style_properties_register_property ("border-style", GTK_TYPE_BORDER_STYLE, NULL, NULL); - gtk_style_properties_register_property ("border-color", GDK_TYPE_RGBA, NULL, NULL); - - gtk_style_properties_register_property ("background-image", CAIRO_GOBJECT_TYPE_PATTERN, NULL, NULL); - gtk_style_properties_register_property ("border-image", GTK_TYPE_9SLICE, NULL, NULL); - - g_value_init (&val, GTK_TYPE_THEMING_ENGINE); - g_value_set_object (&val, (GObject *) gtk_theming_engine_load (NULL)); - gtk_style_properties_register_property ("engine", GTK_TYPE_THEMING_ENGINE, &val, NULL); - g_value_unset (&val); - - gtk_style_properties_register_property ("transition", GTK_TYPE_ANIMATION_DESCRIPTION, NULL, NULL); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("margin", + "Margin", + "Margin", + GTK_TYPE_BORDER, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("padding", + "Padding", + "Padding", + GTK_TYPE_BORDER, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_int ("border-width", + "Border width", + "Border width, in pixels", + 0, G_MAXINT, 0, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_int ("border-radius", + "Border radius", + "Border radius, in pixels", + 0, G_MAXINT, 0, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_enum ("border-style", + "Border style", + "Border style", + GTK_TYPE_BORDER_STYLE, + GTK_BORDER_STYLE_NONE, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("border-color", + "Border color", + "Border color", + GDK_TYPE_RGBA, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("background-image", + "Background Image", + "Background Image", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("border-image", + "Border Image", + "Border Image", + GTK_TYPE_9SLICE, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_object ("engine", + "Theming Engine", + "Theming Engine", + GTK_TYPE_THEMING_ENGINE, 0)); + gtk_style_properties_register_property (NULL, + g_param_spec_boxed ("transition", + "Transition animation description", + "Transition animation description", + GTK_TYPE_ANIMATION_DESCRIPTION, 0)); g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate)); } @@ -198,7 +242,6 @@ property_data_get_value (PropertyData *data, { ValueData new = { 0 }; - //val_data = &g_array_index (data->values, ValueData, pos); new.state = state; g_array_insert_val (data->values, pos, new); } @@ -333,10 +376,8 @@ property_node_lookup (GQuark quark) /** * gtk_style_properties_register_property: - * @property_name: property name to register - * @type: #GType the property will hold - * @default_value: default value for this property * @parse_func: parsing function to use, or %NULL + * @pspec: the #GParamSpec for the new property * * Registers a property so it can be used in the CSS file format. * This function is the low-level equivalent of @@ -346,42 +387,29 @@ property_node_lookup (GQuark quark) * Since: 3.0 **/ void -gtk_style_properties_register_property (const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func) +gtk_style_properties_register_property (GtkStylePropertyParser parse_func, + GParamSpec *pspec) { PropertyNode *node, new = { 0 }; GQuark quark; gint i; - g_return_if_fail (property_name != NULL); - g_return_if_fail (type != 0); + g_return_if_fail (G_IS_PARAM_SPEC (pspec)); if (G_UNLIKELY (!properties)) properties = g_array_new (FALSE, TRUE, sizeof (PropertyNode)); - quark = g_quark_try_string (property_name); + quark = g_quark_from_string (pspec->name); if ((node = property_node_lookup (quark)) != NULL) { g_warning ("Property \"%s\" was already registered with type %s", - property_name, g_type_name (node->property_type)); + pspec->name, g_type_name (node->pspec->value_type)); return; } - quark = g_quark_from_string (property_name); - new.property_quark = quark; - new.property_type = type; - - if (default_value) - { - g_value_init (&new.default_value, G_VALUE_TYPE (default_value)); - g_value_copy (default_value, &new.default_value); - } - else - g_value_init (&new.default_value, type); + new.pspec = pspec; if (parse_func) new.parse_func = parse_func; @@ -400,11 +428,11 @@ gtk_style_properties_register_property (const gchar *property_name, /** * gtk_style_properties_lookup_property: * @property_name: property name to look up - * @type: (out): return location for the looked up property type - * @parse_func: (out): return value for the parse function + * @parse_func: (out): return location for the parse function + * @pspec: (out): return location for the #GParamSpec * - * Returns %TRUE if a property has been registered, if @type or - * @parse_func are not %NULL, the property #GType and parsing function + * Returns %TRUE if a property has been registered, if @pspec or + * @parse_func are not %NULL, the #GParamSpec and parsing function * will be respectively returned. * * Returns: %TRUE if the property is registered, %FALSE otherwise @@ -412,9 +440,9 @@ gtk_style_properties_register_property (const gchar *property_name, * Since: 3.0 **/ gboolean -gtk_style_properties_lookup_property (const gchar *property_name, - GType *type, - GtkStylePropertyParser *parse_func) +gtk_style_properties_lookup_property (const gchar *property_name, + GtkStylePropertyParser *parse_func, + GParamSpec **pspec) { PropertyNode *node; GtkStylePropertiesClass *klass; @@ -439,8 +467,8 @@ gtk_style_properties_lookup_property (const gchar *property_name, if (node->property_quark == quark) { - if (type) - *type = node->property_type; + if (pspec) + *pspec = node->pspec; if (parse_func) *parse_func = node->parse_func; @@ -572,22 +600,22 @@ gtk_style_properties_set_property (GtkStyleProperties *props, return; } - if (node->property_type == GDK_TYPE_RGBA || - node->property_type == GDK_TYPE_COLOR) + if (node->pspec->value_type == GDK_TYPE_RGBA || + node->pspec->value_type == GDK_TYPE_COLOR) { /* Allow GtkSymbolicColor as well */ g_return_if_fail (value_type == GDK_TYPE_RGBA || value_type == GDK_TYPE_COLOR || value_type == GTK_TYPE_SYMBOLIC_COLOR); } - else if (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN) + else if (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN) { /* Allow GtkGradient as a substitute */ g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN || value_type == GTK_TYPE_GRADIENT); } else - g_return_if_fail (node->property_type == value_type); + g_return_if_fail (node->pspec->value_type == value_type); priv = props->priv; prop = g_hash_table_lookup (priv->properties, @@ -670,7 +698,7 @@ gtk_style_properties_set_valist (GtkStyleProperties *props, if (G_IS_VALUE (val)) g_value_unset (val); - g_value_init (val, node->property_type); + g_value_init (val, node->pspec->value_type); G_VALUE_COLLECT (val, args, 0, &error); if (error) @@ -765,6 +793,18 @@ resolve_gradient (GtkStyleProperties *props, return TRUE; } +static void +lookup_default_value (PropertyNode *node, + GValue *value) +{ + g_value_init (value, node->pspec->value_type); + + if (node->pspec->value_type == GTK_TYPE_THEMING_ENGINE) + g_value_set_object (value, gtk_theming_engine_load (NULL)); + else + g_param_value_set_default (node->pspec, value); +} + /** * gtk_style_properties_get_property: * @props: a #GtkStyleProperties @@ -809,23 +849,18 @@ gtk_style_properties_get_property (GtkStyleProperties *props, if (!prop) return FALSE; - g_value_init (value, node->property_type); + g_value_init (value, node->pspec->value_type); val = property_data_match_state (prop, state); - if (!val) - val = &node->default_value; - - g_return_val_if_fail (G_IS_VALUE (val), FALSE); - - if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) + if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - if (node->property_type == GDK_TYPE_RGBA) + if (node->pspec->value_type == GDK_TYPE_RGBA) { if (!resolve_color (props, val)) return FALSE; } - else if (node->property_type == GDK_TYPE_COLOR) + else if (node->pspec->value_type == GDK_TYPE_COLOR) { if (!resolve_color_rgb (props, val)) return FALSE; @@ -833,15 +868,27 @@ gtk_style_properties_get_property (GtkStyleProperties *props, else return FALSE; } - else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) + else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { - g_return_val_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); + g_return_val_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); if (!resolve_gradient (props, val)) return FALSE; } - g_value_copy (val, value); + if (val) + { + g_param_value_validate (node->pspec, val); + g_value_copy (val, value); + } + else + { + GValue default_value = { 0 }; + + lookup_default_value (node, &default_value); + g_value_copy (&default_value, value); + g_value_unset (&default_value); + } return TRUE; } @@ -890,32 +937,41 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, if (prop) val = property_data_match_state (prop, state); - if (!val) - val = &node->default_value; - - if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) + if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { gboolean resolved; - if (node->property_type == GDK_TYPE_RGBA) + if (node->pspec->value_type == GDK_TYPE_RGBA) resolved = resolve_color (props, val); - else if (node->property_type == GDK_TYPE_COLOR) + else if (node->pspec->value_type == GDK_TYPE_COLOR) resolved = resolve_color_rgb (props, val); else resolved = FALSE; if (!resolved) - val = &node->default_value; + val = NULL; } - else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) + else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { - g_return_if_fail (node->property_type == CAIRO_GOBJECT_TYPE_PATTERN); + g_return_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN); if (!resolve_gradient (props, val)) - val = &node->default_value; + val = NULL; } - G_VALUE_LCOPY (val, args, 0, &error); + if (val) + { + g_param_value_validate (node->pspec, val); + G_VALUE_LCOPY (val, args, 0, &error); + } + else + { + GValue default_value = { 0 }; + + lookup_default_value (node, &default_value); + G_VALUE_LCOPY (&default_value, args, 0, &error); + g_value_unset (&default_value); + } if (error) { diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h index b12c223b1b..ec772338a9 100644 --- a/gtk/gtkstyleproperties.h +++ b/gtk/gtkstyleproperties.h @@ -55,13 +55,11 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar *string, GType gtk_style_properties_get_type (void) G_GNUC_CONST; /* Functions to register style properties */ -void gtk_style_properties_register_property (const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func); -gboolean gtk_style_properties_lookup_property (const gchar *property_name, - GType *type, - GtkStylePropertyParser *parse_func); +void gtk_style_properties_register_property (GtkStylePropertyParser parse_func, + GParamSpec *pspec); +gboolean gtk_style_properties_lookup_property (const gchar *property_name, + GtkStylePropertyParser *parse_func, + GParamSpec **pspec); GtkStyleProperties * gtk_style_properties_new (void); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index c007274ccc..8a29167fc1 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -327,16 +327,15 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, /** * gtk_theming_engine_register_property: * @engine: a #GtkThemingEngine - * @property_name: property name to register - * @type: #GType the property will hold - * @default_value: default value for this property + * @namespace: namespace for the property name * @parse_func: parsing function to use, or %NULL + * @pspec: the #GParamSpec for the new property * * Registers a property so it can be used in the CSS file format, * on the CSS file the property will look like - * "-${engine-object-name}-${@property_name}". being - * ${engine-object-name} either the GtkThemingEngine:name property - * or G_OBJECT_TYPE_NAME(engine) if the property is unset. + * "-${@namespace}-${property_name}". being + * ${property_name} the given to @pspec. @namespace will usually + * be the theme engine name. * * For any type a @parse_func may be provided, being this function * used for turning any property value (between ':' and ';') in @@ -345,18 +344,21 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, * cases. * * - * This function needs to be called only once during theming - * engine object initialization. + * Engines must ensure property registration happens exactly once, + * usually GTK+ deals with theming engines as singletons, so this + * should be guaranteed to happen once, but bear this in mind + * when creating #GtkThemeEngines yourself. * * * * In order to make use of the custom registered properties in - * the CSS file, make sure the engine is loaded first either in - * a previous rule or within the same one. + * the CSS file, make sure the engine is loaded first by specifying + * the engine property, either in a previous rule or within the same + * one. * * * { * engine: someengine; - * SomeEngine-custom-property: 2; + * -SomeEngine-custom-property: 2; * } * * @@ -364,31 +366,22 @@ _gtk_theming_engine_set_context (GtkThemingEngine *engine, * Since: 3.0 **/ void -gtk_theming_engine_register_property (GtkThemingEngine *engine, - const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func) +gtk_theming_engine_register_property (const gchar *namespace, + GtkStylePropertyParser parse_func, + GParamSpec *pspec) { - GtkThemingEnginePrivate *priv; - const gchar *engine_name; gchar *name; - g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); - g_return_if_fail (property_name != NULL); - g_return_if_fail (type != G_TYPE_INVALID); - g_return_if_fail (default_value == NULL || G_IS_VALUE (default_value)); + g_return_if_fail (namespace != NULL); + g_return_if_fail (strchr (namespace, ' ') == NULL); + g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - priv = engine->priv; + /* FIXME: hack hack hack, replacing pspec->name to include namespace */ + name = g_strdup_printf ("-%s-%s", namespace, pspec->name); + g_free (pspec->name); + pspec->name = name; - if (priv->name) - engine_name = priv->name; - else - engine_name = G_OBJECT_TYPE_NAME (engine); - - name = g_strdup_printf ("-%s-%s", engine_name, property_name); - gtk_style_properties_register_property (name, type, default_value, parse_func); - g_free (name); + gtk_style_properties_register_property (parse_func, pspec); } /** diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 3b45fb0abb..784737f2de 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -171,11 +171,9 @@ GType gtk_theming_engine_get_type (void) G_GNUC_CONST; void _gtk_theming_engine_set_context (GtkThemingEngine *engine, GtkStyleContext *context); -void gtk_theming_engine_register_property (GtkThemingEngine *engine, - const gchar *property_name, - GType type, - const GValue *default_value, - GtkStylePropertyParser parse_func); +void gtk_theming_engine_register_property (const gchar *namespace, + GtkStylePropertyParser parse_func, + GParamSpec *pspec); void gtk_theming_engine_get_property (GtkThemingEngine *engine, const gchar *property, @@ -202,7 +200,7 @@ G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *en gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine, const gchar *style_class); gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine, - const gchar *style_class, + const gchar *style_region, GtkRegionFlags *flags); GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine); From 64e798e190dec338410c98c806de18f357b3b4cc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 19:54:37 +0100 Subject: [PATCH 446/634] Do not initialize RC subsystem. --- gtk/gtkmain.c | 1 - gtk/gtkrc.c | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index ceac861d71..ac2bbd05ad 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -796,7 +796,6 @@ do_post_parse_initialization (int *argc, g_type_init (); _gtk_accel_map_init (); - _gtk_rc_init (); /* Set the 'initialized' flag. */ diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 84efc27a06..11918715d6 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -926,6 +926,7 @@ gtk_rc_parse_string (const gchar *rc_string) g_return_if_fail (rc_string != NULL); +#if 0 rc_file = g_new (GtkRcFile, 1); rc_file->is_string = TRUE; rc_file->name = g_strdup (rc_string); @@ -938,6 +939,7 @@ gtk_rc_parse_string (const gchar *rc_string) for (tmp_list = rc_contexts; tmp_list; tmp_list = tmp_list->next) gtk_rc_context_parse_string (tmp_list->data, rc_string); +#endif } static GtkRcFile * @@ -1117,10 +1119,12 @@ gtk_rc_parse (const gchar *filename) g_return_if_fail (filename != NULL); +#if 0 add_to_rc_file_list (&global_rc_files, filename, TRUE); for (tmp_list = rc_contexts; tmp_list; tmp_list = tmp_list->next) gtk_rc_context_parse_file (tmp_list->data, filename, GTK_PATH_PRIO_RC, TRUE); +#endif } /* Handling of RC styles */ @@ -2183,6 +2187,7 @@ gtk_rc_parse_any (GtkRcContext *context, guint i; gboolean done; +#if 0 scanner = gtk_rc_scanner_new (); if (input_fd >= 0) @@ -2264,6 +2269,7 @@ gtk_rc_parse_any (GtkRcContext *context, } g_scanner_destroy (scanner); +#endif } static guint From 9ffaf1122d7598415bed9fd35b4e436b1386d538 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 21:13:13 +0100 Subject: [PATCH 447/634] GtkCssProvider: Accept '%' in value strings. --- gtk/gtkcssprovider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 1b856c36af..a2ba3623c3 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1135,7 +1135,7 @@ scanner_apply_scope (GScanner *scanner, if (scope == SCOPE_VALUE) { scanner->config->cset_identifier_first = G_CSET_a_2_z "@#-_0123456789" G_CSET_A_2_Z; - scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.\t\n" G_CSET_A_2_Z; + scanner->config->cset_identifier_nth = G_CSET_a_2_z "@#-_ 0123456789(),.%\t\n" G_CSET_A_2_Z; scanner->config->scan_identifier_1char = TRUE; } else if (scope == SCOPE_SELECTOR) From 37f9f491d29620898bbfc146ab1bd7e7c8c4596d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 13 Nov 2010 21:19:41 +0100 Subject: [PATCH 448/634] Make testgtk load CSS for custom styling. --- tests/Makefile.am | 4 +- tests/testgtk.c | 54 ++++++----- tests/testgtk.css | 33 +++++++ tests/testgtk2.css | 9 ++ tests/testgtkrc | 228 --------------------------------------------- tests/testgtkrc2 | 21 ----- 6 files changed, 77 insertions(+), 272 deletions(-) create mode 100644 tests/testgtk.css create mode 100644 tests/testgtk2.css delete mode 100644 tests/testgtkrc delete mode 100644 tests/testgtkrc2 diff --git a/tests/Makefile.am b/tests/Makefile.am index a690082b52..75d68170bc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -396,8 +396,8 @@ testswitch_SOURCES = testswitch.c EXTRA_DIST += \ prop-editor.h \ testgtk.1 \ - testgtkrc \ - testgtkrc2 \ + testgtk.css \ + testgtk2.css \ 3DRings.xpm \ FilesQueue.xpm \ Modeller.xpm \ diff --git a/tests/testgtk.c b/tests/testgtk.c index 7e0a7e7cd5..abfd127a1c 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -9985,7 +9985,7 @@ create_main_window (void) int i; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_name (window, "main window"); + gtk_widget_set_name (window, "main_window"); gtk_window_move (GTK_WINDOW (window), 50, 20); gtk_window_set_default_size (GTK_WINDOW (window), -1, 400); @@ -10188,6 +10188,9 @@ usage (void) int main (int argc, char *argv[]) { + GtkCssProvider *provider, *memory_provider; + GdkDisplay *display; + GdkScreen *screen; GtkBindingSet *binding_set; int i; gboolean done_benchmarks = FALSE; @@ -10196,20 +10199,29 @@ main (int argc, char *argv[]) test_init (); - /* Check to see if we are being run from the correct - * directory. - */ - if (file_exists ("testgtkrc")) - gtk_rc_add_default_file ("testgtkrc"); - else if (file_exists ("tests/testgtkrc")) - gtk_rc_add_default_file ("tests/testgtkrc"); - else - g_warning ("Couldn't find file \"testgtkrc\"."); - g_set_application_name ("GTK+ Test Program"); gtk_init (&argc, &argv); + provider = gtk_css_provider_new (); + + /* Check to see if we are being run from the correct + * directory. + */ + if (file_exists ("testgtk.css")) + gtk_css_provider_load_from_path (provider, "testgtk.css", NULL); + else if (file_exists ("tests/testgtkrc")) + gtk_css_provider_load_from_path (provider, "tests/testgtk.css", NULL); + else + g_warning ("Couldn't find file \"testgtk.css\"."); + + display = gdk_display_get_default (); + screen = gdk_display_get_default_screen (display); + + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); + gtk_accelerator_set_default_mod_mask (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | @@ -10268,17 +10280,17 @@ main (int argc, char *argv[]) "debug_msg", 1, G_TYPE_STRING, "GtkWidgetClass 9 test"); - - /* We use gtk_rc_parse_string() here so we can make sure it works across theme - * changes - */ - gtk_rc_parse_string ("style \"testgtk-version-label\" { " - " fg[NORMAL] = \"#ff0000\"\n" - " font = \"Sans 18\"\n" - "}\n" - "widget \"*.testgtk-version-label\" style \"testgtk-version-label\""); - + memory_provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (memory_provider, + "#testgtk-version-label {\n" + " color: #f00;\n" + " font: Sans 18;\n" + "}", + -1, NULL); + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (memory_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1); + create_main_window (); gtk_main (); diff --git a/tests/testgtk.css b/tests/testgtk.css new file mode 100644 index 0000000000..9af02572c2 --- /dev/null +++ b/tests/testgtk.css @@ -0,0 +1,33 @@ +/* testgtk2.css sets all the buttons in the main window to blue by default */ +@import url(testgtk2.css); + +* { + -GtkButton-child-displacement-x: 1; + -GtkButton-child-displacement-y: 1; + + -GtkToolbar-space-size: 10; + -GtkToolbar-space-style: line; + -GtkToolbar-button-relief: none; + -GtkButtonBox-child-min-width: 0; + -GtkButtonBox-child-min-height: 0; + -GtkArrow-arrow-scaling: 1.0; + -GtkEntry-invisible-char: 10046; + + font: Sans 12; + + -Gtest-foo: 47; + -Gtest-bar: 47; +} + +GtkLabel:selected { + background-color: gray; +} + +GtkLabel:prelight { + background-color: mix (#a0a0a0, rgb (75%, 200, 0%), 0.9); +} + +/* override testgtk2, introduce the green color in the button list */ +#main_window GtkScrolledWindow GtkButton:prelight { + background-color: rgb (0%, 75%, 0); +} diff --git a/tests/testgtk2.css b/tests/testgtk2.css new file mode 100644 index 0000000000..a51ec2a100 --- /dev/null +++ b/tests/testgtk2.css @@ -0,0 +1,9 @@ +/* this file gets included from testgtk.css */ + +#main_window GtkButton { + font: Monospace 10; +} + +#main_window GtkButton:hover { + background-color: rgba(0%, 0%, 75%, 0.1); +} diff --git a/tests/testgtkrc b/tests/testgtkrc deleted file mode 100644 index 990a322492..0000000000 --- a/tests/testgtkrc +++ /dev/null @@ -1,228 +0,0 @@ -# pixmap_path ":::..." -# -# include "rc-file" -# -# style [= ] -# { -#
-
-gtksymboliccolor -GtkSymbolicColor -GtkSymbolicColor -GtkGradient -gtk_symbolic_color_new_literal -gtk_symbolic_color_new_mix -gtk_symbolic_color_new_name -gtk_symbolic_color_new_shade -gtk_symbolic_color_new_alpha -gtk_symbolic_color_resolve -gtk_symbolic_color_ref -gtk_symbolic_color_unref -gtk_gradient_new_linear -gtk_gradient_new_radial -gtk_gradient_add_color_stop -gtk_gradient_resolve -gtk_gradient_ref -gtk_gradient_unref - -GTK_TYPE_GRADIENT -GTK_TYPE_SYMBOLIC_COLOR - -gtk_symbolic_color_get_type -gtk_gradient_get_type -
-
gtkstyleproperties GtkStyleProperties @@ -5446,9 +5419,12 @@ gtk_style_context_has_region gtk_style_context_list_regions gtk_style_context_set_screen gtk_style_context_set_state -gtk_style_context_state_transition_start -gtk_style_context_state_transition_stop -gtk_style_context_state_transition_update + + +GtkBorder +gtk_border_new +gtk_border_copy +gtk_border_free gtk_render_arrow @@ -5474,8 +5450,11 @@ GTK_STYLE_CONTEXT_CLASS GTK_STYLE_CONTEXT_GET_CLASS GTK_IS_STYLE_CONTEXT GTK_IS_STYLE_CONTEXT_CLASS +GTK_TYPE_BORDER + gtk_style_context_get_type +gtk_border_get_type
@@ -5531,6 +5510,43 @@ GTK_TYPE_THEMING_ENGINE gtk_theming_engine_get_type
+
+gtksymboliccolor +GtkSymbolicColor +GtkSymbolicColor +gtk_symbolic_color_new_literal +gtk_symbolic_color_new_name +gtk_symbolic_color_new_shade +gtk_symbolic_color_new_alpha +gtk_symbolic_color_new_mix +gtk_symbolic_color_ref +gtk_symbolic_color_unref +gtk_symbolic_color_resolve + + +GTK_TYPE_SYMBOLIC_COLOR + + +gtk_symbolic_color_get_type +
+ +
+gtkgradient +GtkGradient +GtkGradient +gtk_gradient_new_linear +gtk_gradient_new_radial +gtk_gradient_add_color_stop +gtk_gradient_ref +gtk_gradient_unref +gtk_gradient_resolve + + +GTK_TYPE_GRADIENT + +gtk_gradient_get_type +
+
gtkstyle GtkStyle @@ -5570,12 +5586,6 @@ gtk_paint_layout gtk_paint_resize_grip gtk_draw_insertion_cursor - -GtkBorder -gtk_border_new -gtk_border_copy -gtk_border_free - GtkRcProperty GtkRcPropertyParser @@ -5588,10 +5598,8 @@ GTK_TYPE_STYLE GTK_STYLE_CLASS GTK_IS_STYLE_CLASS GTK_STYLE_GET_CLASS -GTK_TYPE_BORDER - + gtk_style_get_type -gtk_border_get_type GtkThemeEngine
@@ -6012,6 +6020,7 @@ gtk_icon_info_get_builtin_pixbuf gtk_icon_info_load_icon gtk_icon_info_load_symbolic gtk_icon_info_load_symbolic_for_style +gtk_icon_info_load_symbolic_for_context gtk_icon_info_set_raw_coordinates gtk_icon_info_get_embedded_rect gtk_icon_info_get_attach_points diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 14bde8ccfd..e69d29337c 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -167,6 +167,7 @@ gtk_public_h_sources = \ gtkbbox.h \ gtkbin.h \ gtkbindings.h \ + gtkborder.h \ gtkbox.h \ gtkbuilder.h \ gtkbuildable.h \ @@ -179,7 +180,7 @@ gtk_public_h_sources = \ gtkcellrenderercombo.h \ gtkcellrendererpixbuf.h \ gtkcellrendererprogress.h \ - gtkcellrendererspin.h \ + gtkcellrendererspin.h \ gtkcellrendererspinner.h\ gtkcellrenderertext.h \ gtkcellrenderertoggle.h \ @@ -194,26 +195,27 @@ gtk_public_h_sources = \ gtkcomboboxtext.h \ gtkcontainer.h \ gtkcssprovider.h \ - gtkdebug.h \ + gtkdebug.h \ gtkdialog.h \ gtkdnd.h \ gtkdrawingarea.h \ - gtkeditable.h \ + gtkeditable.h \ gtkentry.h \ gtkentrybuffer.h \ gtkentrycompletion.h \ gtkenums.h \ gtkeventbox.h \ gtkexpander.h \ - gtkfilechooser.h \ - gtkfilechooserbutton.h \ - gtkfilechooserdialog.h \ - gtkfilechooserwidget.h \ + gtkfilechooser.h \ + gtkfilechooserbutton.h \ + gtkfilechooserdialog.h \ + gtkfilechooserwidget.h \ gtkfilefilter.h \ gtkfixed.h \ gtkfontbutton.h \ gtkfontsel.h \ gtkframe.h \ + gtkgradient.h \ gtkgrid.h \ gtkhandlebox.h \ gtkhbbox.h \ @@ -235,7 +237,7 @@ gtk_public_h_sources = \ gtkinfobar.h \ gtkinvisible.h \ gtklabel.h \ - gtklayout.h \ + gtklayout.h \ gtklinkbutton.h \ gtkliststore.h \ gtkmain.h \ @@ -247,7 +249,7 @@ gtk_public_h_sources = \ gtkmessagedialog.h \ gtkmisc.h \ gtkmodules.h \ - gtkmountoperation.h \ + gtkmountoperation.h \ gtknotebook.h \ gtkoffscreenwindow.h \ gtkorientable.h \ @@ -257,7 +259,7 @@ gtk_public_h_sources = \ gtkplug.h \ gtkprintcontext.h \ gtkprintoperation.h \ - gtkprintoperationpreview.h \ + gtkprintoperationpreview.h \ gtkprintsettings.h \ gtkprogressbar.h \ gtkradioaction.h \ @@ -269,13 +271,13 @@ gtk_public_h_sources = \ gtkrecentaction.h \ gtkrecentchooser.h \ gtkrecentchooserdialog.h \ - gtkrecentchoosermenu.h \ + gtkrecentchoosermenu.h \ gtkrecentchooserwidget.h \ - gtkrecentfilter.h \ + gtkrecentfilter.h \ gtkrecentmanager.h \ gtkscale.h \ gtkscalebutton.h \ - gtkscrollable.h \ + gtkscrollable.h \ gtkscrollbar.h \ gtkscrolledwindow.h \ gtkselection.h \ @@ -299,7 +301,7 @@ gtk_public_h_sources = \ gtkswitch.h \ gtksymboliccolor.h \ gtktable.h \ - gtktearoffmenuitem.h \ + gtktearoffmenuitem.h \ gtktestutils.h \ gtktextbuffer.h \ gtktextbufferrichtext.h \ @@ -461,6 +463,7 @@ gtk_base_c_sources = \ gtkbbox.c \ gtkbin.c \ gtkbindings.c \ + gtkborder.c \ gtkbox.c \ gtkbuildable.c \ gtkbuilder.c \ @@ -490,7 +493,7 @@ gtk_base_c_sources = \ gtkcssprovider.c \ gtkdialog.c \ gtkdrawingarea.c \ - gtkeditable.c \ + gtkeditable.c \ gtkentry.c \ gtkentrybuffer.c \ gtkentrycompletion.c \ @@ -508,9 +511,10 @@ gtk_base_c_sources = \ gtkfilesystem.c \ gtkfilesystemmodel.c \ gtkfixed.c \ - gtkfontbutton.c \ - gtkfontsel.c \ + gtkfontbutton.c \ + gtkfontsel.c \ gtkframe.c \ + gtkgradient.c \ gtkgrid.c \ gtkhandlebox.c \ gtkhbbox.c \ @@ -549,7 +553,7 @@ gtk_base_c_sources = \ gtkmisc.c \ gtkmnemonichash.c \ gtkmodules.c \ - gtkmountoperation.c \ + gtkmountoperation.c \ gtknotebook.c \ gtkoffscreenwindow.c \ gtkorientable.c \ @@ -561,7 +565,7 @@ gtk_base_c_sources = \ gtkplug.c \ gtkprintcontext.c \ gtkprintoperation.c \ - gtkprintoperationpreview.c \ + gtkprintoperationpreview.c \ gtkprintsettings.c \ gtkprintutils.c \ gtkprogressbar.c \ @@ -570,20 +574,20 @@ gtk_base_c_sources = \ gtkradiomenuitem.c \ gtkradiotoolbutton.c \ gtkrange.c \ - gtkrbtree.c \ + gtkrbtree.c \ gtkrc.c \ gtkrecentaction.c \ gtkrecentchooserdefault.c \ - gtkrecentchooserdialog.c \ - gtkrecentchoosermenu.c \ - gtkrecentchooserwidget.c \ + gtkrecentchooserdialog.c\ + gtkrecentchoosermenu.c \ + gtkrecentchooserwidget.c\ gtkrecentchooserutils.c \ gtkrecentchooser.c \ gtkrecentfilter.c \ gtkrecentmanager.c \ gtkscale.c \ gtkscalebutton.c \ - gtkscrollable.c \ + gtkscrollable.c \ gtkscrollbar.c \ gtkscrolledwindow.c \ gtkselection.c \ @@ -607,7 +611,7 @@ gtk_base_c_sources = \ gtkswitch.c \ gtksymboliccolor.c \ gtktable.c \ - gtktearoffmenuitem.c \ + gtktearoffmenuitem.c \ gtktestutils.c \ gtktextbtree.c \ gtktextbuffer.c \ @@ -633,7 +637,7 @@ gtk_base_c_sources = \ gtktoolbar.c \ gtktoolbutton.c \ gtktoolitem.c \ - gtktoolitemgroup.c \ + gtktoolitemgroup.c \ gtktoolpalette.c \ gtktoolshell.c \ gtktooltip.c \ @@ -660,7 +664,7 @@ gtk_base_c_sources = \ gtkvseparator.c \ gtkwidget.c \ gtkwidgetpath.c \ - gtkwindow-decorate.c \ + gtkwindow-decorate.c \ gtkwindow.c \ $(gtk_clipboard_dnd_c_sources) \ $(gtk_appchooser_impl_c_sources) diff --git a/gtk/gtk.h b/gtk/gtk.h index 36d9a33f04..3b1155d7fb 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtkborder.c b/gtk/gtkborder.c new file mode 100644 index 0000000000..6ea466a405 --- /dev/null +++ b/gtk/gtkborder.c @@ -0,0 +1,76 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * 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. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#include "config.h" + +#include "gtkborder.h" + +/** + * gtk_border_new: + * + * Allocates a new #GtkBorder structure and initializes its elements to zero. + * + * Returns: a newly allocated #GtkBorder. Free with gtk_border_free() + * + * Since: 2.14 + */ +GtkBorder * +gtk_border_new (void) +{ + return g_slice_new0 (GtkBorder); +} + +/** + * gtk_border_copy: + * @border_: a #GtkBorder + * + * Copies a #GtkBorder structure. + * + * Returns: a copy of @border_. + */ +GtkBorder * +gtk_border_copy (const GtkBorder *border_) +{ + g_return_val_if_fail (border_ != NULL, NULL); + + return g_slice_dup (GtkBorder, border_); +} + +/** + * gtk_border_free: + * @border_: a #GtkBorder + * + * Frees a #GtkBorder structure. + */ +void +gtk_border_free (GtkBorder *border_) +{ + g_slice_free (GtkBorder, border_); +} + +G_DEFINE_BOXED_TYPE (GtkBorder, gtk_border, + gtk_border_copy, + gtk_border_free) diff --git a/gtk/gtkborder.h b/gtk/gtkborder.h new file mode 100644 index 0000000000..51a5b7bfd6 --- /dev/null +++ b/gtk/gtkborder.h @@ -0,0 +1,68 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * 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. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GTK_BORDER_H__ +#define __GTK_BORDER_H__ + +#include + +G_BEGIN_DECLS + +typedef struct _GtkBorder GtkBorder; + +#define GTK_TYPE_BORDER (gtk_border_get_type ()) + +/** + * GtkBorder: + * @left: The width of the left border. + * @right: The width of the right border. + * @top: The width of the top border. + * @bottom: The width of the bottom border. + * + * A struct that specifies a border around a rectangular area that can + * be of different width on each side. + */ +struct _GtkBorder +{ + gint16 left; + gint16 right; + gint16 top; + gint16 bottom; +}; + +GType gtk_border_get_type (void) G_GNUC_CONST; +GtkBorder *gtk_border_new (void) G_GNUC_MALLOC; +GtkBorder *gtk_border_copy (const GtkBorder *border_); +void gtk_border_free (GtkBorder *border_); + + +G_END_DECLS + +#endif /* __GTK_BORDER_H__ */ diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index b2fde3981c..76fd8665ae 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -36,9 +36,9 @@ * @Title: GtkCssProvider * @See_also: #GtkStyleContext, #GtkStyleProvider * - * #GtkCssProvider is an object implementing #GtkStyleProvider, it is able - * to parse CSS-like input - * in order to style widgets. + * GtkCssProvider is an object implementing the #GtkStyleProvider interface. + * It is able to parse CSS-like + * input in order to style widgets. * * * Default files diff --git a/gtk/gtkgradient.c b/gtk/gtkgradient.c new file mode 100644 index 0000000000..a19b8fe583 --- /dev/null +++ b/gtk/gtkgradient.c @@ -0,0 +1,282 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtkgradient.h" +#include "gtkstyleproperties.h" +#include "gtkintl.h" + +/** + * SECTION:gtkgradient + * @Short_description: Gradients + * @Title: GtkGradient + * + * GtkGradient is a boxed type that represents a gradient. + * It is the result of parsing a + * gradient expression. + * To obtain the gradient represented by a GtkGradient, it has to + * be resolved with gtk_gradient_resolve(), which replaces all + * symbolic color references by the colors they refer to (in a given + * context) and constructs a #cairo_pattern_t value. + * + * It is not normally necessary to deal directly with #GtkGradients, + * since they are mostly used behind the scenes by #GtkStyleContext and + * #GtkCssProvider. + */ + +G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient, + gtk_gradient_ref, gtk_gradient_unref) + +typedef struct ColorStop ColorStop; + +struct ColorStop +{ + gdouble offset; + GtkSymbolicColor *color; +}; + +struct _GtkGradient +{ + gdouble x0; + gdouble y0; + gdouble x1; + gdouble y1; + gdouble radius0; + gdouble radius1; + + GArray *stops; + + guint ref_count; +}; + +/** + * gtk_gradient_new_linear: + * @x0: X coordinate of the starting point + * @y0: Y coordinate of the starting point + * @x1: X coordinate of the end point + * @y1: Y coordinate of the end point + * + * Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient + * a number of stop colors must be added through gtk_gradient_add_color_stop(). + * + * Returns: A newly created #GtkGradient + * + * Since: 3.0 + **/ +GtkGradient * +gtk_gradient_new_linear (gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + GtkGradient *gradient; + + gradient = g_slice_new (GtkGradient); + gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); + + gradient->x0 = x0; + gradient->y0 = y0; + gradient->x1 = x1; + gradient->y1 = y1; + gradient->radius0 = 0; + gradient->radius1 = 0; + + gradient->ref_count = 1; + + return gradient; +} + +/** + * gtk_gradient_new_radial: + * @x0: X coordinate of the start circle + * @y0: Y coordinate of the start circle + * @radius0: radius of the start circle + * @x1: X coordinate of the end circle + * @y1: Y coordinate of the end circle + * @radius1: radius of the end circle + * + * Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and + * (x1, y1, radius1). Before using the gradient a number of stop colors must be added + * through gtk_gradient_add_color_stop(). + * + * Returns: A newly created #GtkGradient + * + * Since: 3.0 + **/ +GtkGradient * +gtk_gradient_new_radial (gdouble x0, + gdouble y0, + gdouble radius0, + gdouble x1, + gdouble y1, + gdouble radius1) +{ + GtkGradient *gradient; + + gradient = g_slice_new (GtkGradient); + gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); + + gradient->x0 = x0; + gradient->y0 = y0; + gradient->x1 = x1; + gradient->y1 = y1; + gradient->radius0 = radius0; + gradient->radius1 = radius1; + + gradient->ref_count = 1; + + return gradient; +} + +/** + * gtk_gradient_add_color_stop: + * @gradient: a #GtkGradient + * @offset: offset for the color stop + * @color: color to use + * + * Adds a stop color to @gradient. + * + * Since: 3.0 + **/ +void +gtk_gradient_add_color_stop (GtkGradient *gradient, + gdouble offset, + GtkSymbolicColor *color) +{ + ColorStop stop; + + g_return_if_fail (gradient != NULL); + + stop.offset = offset; + stop.color = gtk_symbolic_color_ref (color); + + g_array_append_val (gradient->stops, stop); +} + +/** + * gtk_gradient_ref: + * @gradient: a #GtkGradient + * + * Increases the reference count of @gradient. + * + * Returns: The same @gradient + * + * Since: 3.0 + **/ +GtkGradient * +gtk_gradient_ref (GtkGradient *gradient) +{ + g_return_val_if_fail (gradient != NULL, NULL); + + gradient->ref_count++; + + return gradient; +} + +/** + * gtk_gradient_unref: + * @gradient: a #GtkGradient + * + * Decreases the reference count of @gradient, freeing its memory + * if the reference count reaches 0. + * + * Since: 3.0 + **/ +void +gtk_gradient_unref (GtkGradient *gradient) +{ + g_return_if_fail (gradient != NULL); + + gradient->ref_count--; + + if (gradient->ref_count == 0) + { + guint i; + + for (i = 0; i < gradient->stops->len; i++) + { + ColorStop *stop; + + stop = &g_array_index (gradient->stops, ColorStop, i); + gtk_symbolic_color_unref (stop->color); + } + + g_array_free (gradient->stops, TRUE); + g_slice_free (GtkGradient, gradient); + } +} + +/** + * gtk_gradient_resolve: + * @gradient: a #GtkGradient + * @props: #GtkStyleProperties to use when resolving named colors + * @resolved_gradient: (out): return location for the resolved pattern + * + * If @gradient is resolvable, @resolved_gradient will be filled in + * with the resolved gradient as a cairo_pattern_t, and %TRUE will + * be returned. Generally, if @gradient can't be resolved, it is + * due to it being defined on top of a named color that doesn't + * exist in @props. + * + * Returns: %TRUE if the gradient has been resolved + * + * Since: 3.0 + **/ +gboolean +gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleProperties *props, + cairo_pattern_t **resolved_gradient) +{ + cairo_pattern_t *pattern; + guint i; + + g_return_val_if_fail (gradient != NULL, FALSE); + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); + g_return_val_if_fail (resolved_gradient != NULL, FALSE); + + if (gradient->radius0 == 0 && gradient->radius1 == 0) + pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0, + gradient->x1, gradient->y1); + else + pattern = cairo_pattern_create_radial (gradient->x0, gradient->y0, + gradient->radius0, + gradient->x1, gradient->y1, + gradient->radius1); + + for (i = 0; i < gradient->stops->len; i++) + { + ColorStop *stop; + GdkRGBA color; + + stop = &g_array_index (gradient->stops, ColorStop, i); + + if (!gtk_symbolic_color_resolve (stop->color, props, &color)) + { + cairo_pattern_destroy (pattern); + return FALSE; + } + + cairo_pattern_add_color_stop_rgba (pattern, stop->offset, + color.red, color.green, + color.blue, color.alpha); + } + + *resolved_gradient = pattern; + return TRUE; +} diff --git a/gtk/gtkgradient.h b/gtk/gtkgradient.h new file mode 100644 index 0000000000..3e6b70fc78 --- /dev/null +++ b/gtk/gtkgradient.h @@ -0,0 +1,57 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_GRADIENT_H__ +#define __GTK_GRADIENT_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_GRADIENT (gtk_gradient_get_type ()) + +GType gtk_gradient_get_type (void) G_GNUC_CONST; + +GtkGradient * gtk_gradient_new_linear (gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); +GtkGradient * gtk_gradient_new_radial (gdouble x0, + gdouble y0, + gdouble radius0, + gdouble x1, + gdouble y1, + gdouble radius1); + +void gtk_gradient_add_color_stop (GtkGradient *gradient, + gdouble offset, + GtkSymbolicColor *color); + +GtkGradient * gtk_gradient_ref (GtkGradient *gradient); +void gtk_gradient_unref (GtkGradient *gradient); + +gboolean gtk_gradient_resolve (GtkGradient *gradient, + GtkStyleProperties *props, + cairo_pattern_t **resolved_gradient); + +G_END_DECLS + +#endif /* __GTK_GRADIENT_H__ */ diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 8b70038827..58fd2c1f4d 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -31,6 +31,7 @@ #include "gtktypeutils.h" #include "gtkprivate.h" #include "gtkcssprovider.h" +#include "gtksymboliccolor.h" #include "gtkversion.h" #ifdef GDK_WINDOWING_X11 diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 3c8cdc5d9a..a59f1e4bb4 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -41,6 +41,7 @@ #include "gtkintl.h" #include "gtkdebug.h" #include "gtkspinner.h" +#include "gtkborder.h" /** @@ -60,7 +61,9 @@ * Usually applications should not need to use or modify the #GtkStyle of their * widgets. * + * * In GTK+ 3.0, GtkStyle has been deprecated and replaced by #GtkStyleContext. + * */ @@ -4576,53 +4579,6 @@ gtk_paint_spinner (GtkStyle *style, cairo_restore (cr); } -/** - * gtk_border_new: - * - * Allocates a new #GtkBorder structure and initializes its elements to zero. - * - * Returns: a new empty #GtkBorder. The newly allocated #GtkBorder should be - * freed with gtk_border_free() - * - * Since: 2.14 - **/ -GtkBorder * -gtk_border_new (void) -{ - return g_slice_new0 (GtkBorder); -} - -/** - * gtk_border_copy: - * @border_: a #GtkBorder. - * @returns: a copy of @border_. - * - * Copies a #GtkBorder structure. - **/ -GtkBorder * -gtk_border_copy (const GtkBorder *border) -{ - g_return_val_if_fail (border != NULL, NULL); - - return g_slice_dup (GtkBorder, border); -} - -/** - * gtk_border_free: - * @border_: a #GtkBorder. - * - * Frees a #GtkBorder structure. - **/ -void -gtk_border_free (GtkBorder *border) -{ - g_slice_free (GtkBorder, border); -} - -G_DEFINE_BOXED_TYPE (GtkBorder, gtk_border, - gtk_border_copy, - gtk_border_free) - typedef struct _CursorInfo CursorInfo; struct _CursorInfo diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 8bd38ec755..3d44b1ffa7 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -45,12 +45,9 @@ G_BEGIN_DECLS #define GTK_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STYLE)) #define GTK_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STYLE, GtkStyleClass)) -#define GTK_TYPE_BORDER (gtk_border_get_type ()) - /* Some forward declarations needed to rationalize the header * files. */ -typedef struct _GtkBorder GtkBorder; typedef struct _GtkStyle GtkStyle; typedef struct _GtkStyleClass GtkStyleClass; typedef struct _GtkThemeEngine GtkThemeEngine; @@ -383,29 +380,6 @@ struct _GtkStyleClass void (*_gtk_reserved11) (void); }; -/** - * GtkBorder: - * @left: The width of the left border. - * @right: The width of the right border. - * @top: The width of the top border. - * @bottom: The width of the bottom border. - * - * A struct that specifies a border around a rectangular area that can - * be of different width on each side. - */ -struct _GtkBorder -{ - gint16 left; - gint16 right; - gint16 top; - gint16 bottom; -}; - -GType gtk_border_get_type (void) G_GNUC_CONST; -GtkBorder *gtk_border_new (void) G_GNUC_MALLOC; -GtkBorder *gtk_border_copy (const GtkBorder *border_); -void gtk_border_free (GtkBorder *border_); - #if !defined(GTK_DISABLE_DEPRECATED) || defined(GTK_COMPILATION) GType gtk_style_get_type (void) G_GNUC_CONST; diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 61d3b7b5cd..190579d892 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -30,14 +30,14 @@ #include "gtkwidget.h" #include "gtkwindow.h" #include "gtkprivate.h" +#include "gtksymboliccolor.h" #include "gtkanimationdescription.h" #include "gtktimeline.h" /** * SECTION:gtkstylecontext - * @Short_description: rendering UI elements + * @Short_description: Rendering UI elements * @Title: GtkStyleContext - * @See_also: * * #GtkStyleContext is an object that stores styling information affecting * a widget defined by #GtkWidgetPath. diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 43f38939fd..2868c85a8c 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -430,20 +430,6 @@ void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *c gint rel_x, gint rel_y); -/* Animation for state changes */ -void gtk_style_context_state_transition_start (GtkStyleContext *context, - gpointer identifier, - GtkWidget *widget, - GtkStateType state, - gboolean value, - GdkRectangle *rect); -void gtk_style_context_state_transition_update (GtkStyleContext *context, - gpointer identifier, - GdkRectangle *rect, - GtkStateType state); -void gtk_style_context_state_transition_stop (GtkStyleContext *context, - gpointer identifier); - void gtk_style_context_invalidate (GtkStyleContext *context); void gtk_style_context_reset_widgets (GdkScreen *screen); diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 5c54b21da8..49c05d9447 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -19,16 +19,20 @@ #include "config.h" +#include "gtkstyleproperties.h" + #include #include #include #include "gtktypebuiltins.h" #include "gtkstyleprovider.h" -#include "gtkstyleproperties.h" +#include "gtksymboliccolor.h" #include "gtkprivate.h" #include "gtkthemingengine.h" #include "gtkanimationdescription.h" +#include "gtkborder.h" +#include "gtkgradient.h" #include "gtk9slice.h" #include "gtkintl.h" diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h index c419459976..8a243b7f4f 100644 --- a/gtk/gtkstyleproperties.h +++ b/gtk/gtkstyleproperties.h @@ -22,8 +22,7 @@ #include #include -#include "gtkenums.h" -#include "gtksymboliccolor.h" +#include G_BEGIN_DECLS @@ -37,6 +36,9 @@ G_BEGIN_DECLS typedef struct _GtkStyleProperties GtkStyleProperties; typedef struct _GtkStylePropertiesClass GtkStylePropertiesClass; +typedef struct _GtkSymbolicColor GtkSymbolicColor; +typedef struct _GtkGradient GtkGradient; + struct _GtkStyleProperties { GObject parent_object; @@ -101,13 +103,6 @@ void gtk_style_properties_merge (GtkStyleProperties *props, const GtkStyleProperties *props_to_merge, gboolean replace); -gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, - GtkStyleProperties *props, - GdkRGBA *resolved_color); -gboolean gtk_gradient_resolve (GtkGradient *gradient, - GtkStyleProperties *props, - cairo_pattern_t **resolved_gradient); - G_END_DECLS #endif /* __GTK_STYLE_PROPERTIES_H__ */ diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index cb5a9191b0..2345cfa396 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -22,10 +22,27 @@ #include "gtkstyleproperties.h" #include "gtkintl.h" +/** + * SECTION:gtksymboliccolor + * @Short_description: Symbolic colors + * @Title: GtkSymbolicColor + * + * GtkSymbolicColor is a boxed type that represents a symbolic color. + * It is the result of parsing a + * color expression. + * To obtain the color represented by a GtkSymbolicColor, it has to + * be resolved with gtk_symbolic_color_resolve(), which replaces all + * symbolic color references by the colors they refer to (in a given + * context) and evaluates mix, shade and other expressions, resulting + * in a #GdkRGBA value. + * + * It is not normally necessary to deal directly with #GtkSymbolicColors, + * since they are mostly used behind the scenes by #GtkStyleContext and + * #GtkCssProvider. + */ + G_DEFINE_BOXED_TYPE (GtkSymbolicColor, gtk_symbolic_color, - gtk_symbolic_color_ref, gtk_symbolic_color_unref) -G_DEFINE_BOXED_TYPE (GtkGradient, gtk_gradient, - gtk_gradient_ref, gtk_gradient_unref) + gtk_symbolic_color_ref, gtk_symbolic_color_unref) /* Symbolic colors */ typedef enum { @@ -61,28 +78,6 @@ struct _GtkSymbolicColor }; }; -typedef struct ColorStop ColorStop; - -struct ColorStop -{ - gdouble offset; - GtkSymbolicColor *color; -}; - -struct _GtkGradient -{ - gdouble x0; - gdouble y0; - gdouble x1; - gdouble y1; - gdouble radius0; - gdouble radius1; - - GArray *stops; - - guint ref_count; -}; - /** * gtk_symbolic_color_new_literal: * @color: a #GdkRGBA @@ -561,220 +556,3 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, return FALSE; } - -/* GtkGradient */ -/** - * gtk_gradient_new_linear: - * @x0: X coordinate of the starting point - * @y0: Y coordinate of the starting point - * @x1: X coordinate of the end point - * @y1: Y coordinate of the end point - * - * Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient - * a number of stop colors must be added through gtk_gradient_add_color_stop(). - * - * Returns: A newly created #GtkGradient - * - * Since: 3.0 - **/ -GtkGradient * -gtk_gradient_new_linear (gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1) -{ - GtkGradient *gradient; - - gradient = g_slice_new (GtkGradient); - gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); - - gradient->x0 = x0; - gradient->y0 = y0; - gradient->x1 = x1; - gradient->y1 = y1; - gradient->radius0 = 0; - gradient->radius1 = 0; - - gradient->ref_count = 1; - - return gradient; -} - -/** - * gtk_gradient_new_radial: - * @x0: X coordinate of the start circle - * @y0: Y coordinate of the start circle - * @radius0: radius of the start circle - * @x1: X coordinate of the end circle - * @y1: Y coordinate of the end circle - * @radius1: radius of the end circle - * - * Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and - * (x1, y1, radius1). Before using the gradient a number of stop colors must be added - * through gtk_gradient_add_color_stop(). - * - * Returns: A newly created #GtkGradient - * - * Since: 3.0 - **/ -GtkGradient * -gtk_gradient_new_radial (gdouble x0, - gdouble y0, - gdouble radius0, - gdouble x1, - gdouble y1, - gdouble radius1) -{ - GtkGradient *gradient; - - gradient = g_slice_new (GtkGradient); - gradient->stops = g_array_new (FALSE, FALSE, sizeof (ColorStop)); - - gradient->x0 = x0; - gradient->y0 = y0; - gradient->x1 = x1; - gradient->y1 = y1; - gradient->radius0 = radius0; - gradient->radius1 = radius1; - - gradient->ref_count = 1; - - return gradient; -} - -/** - * gtk_gradient_add_color_stop: - * @gradient: a #GtkGradient - * @offset: offset for the color stop - * @color: color to use - * - * Adds a stop color to @gradient. - * - * Since: 3.0 - **/ -void -gtk_gradient_add_color_stop (GtkGradient *gradient, - gdouble offset, - GtkSymbolicColor *color) -{ - ColorStop stop; - - g_return_if_fail (gradient != NULL); - - stop.offset = offset; - stop.color = gtk_symbolic_color_ref (color); - - g_array_append_val (gradient->stops, stop); -} - -/** - * gtk_gradient_ref: - * @gradient: a #GtkGradient - * - * Increases the reference count of @gradient. - * - * Returns: The same @gradient - * - * Since: 3.0 - **/ -GtkGradient * -gtk_gradient_ref (GtkGradient *gradient) -{ - g_return_val_if_fail (gradient != NULL, NULL); - - gradient->ref_count++; - - return gradient; -} - -/** - * gtk_gradient_unref: - * @gradient: a #GtkGradient - * - * Decreases the reference count of @gradient, freeing its memory - * if the reference count reaches 0. - * - * Since: 3.0 - **/ -void -gtk_gradient_unref (GtkGradient *gradient) -{ - g_return_if_fail (gradient != NULL); - - gradient->ref_count--; - - if (gradient->ref_count == 0) - { - guint i; - - for (i = 0; i < gradient->stops->len; i++) - { - ColorStop *stop; - - stop = &g_array_index (gradient->stops, ColorStop, i); - gtk_symbolic_color_unref (stop->color); - } - - g_array_free (gradient->stops, TRUE); - g_slice_free (GtkGradient, gradient); - } -} - -/** - * gtk_gradient_resolve: - * @gradient: a #GtkGradient - * @props: #GtkStyleProperties to use when resolving named colors - * @resolved_gradient: (out): return location for the resolved pattern - * - * If @gradient is resolvable, @resolved_gradient will be filled in - * with the resolved gradient as a cairo_pattern_t, and %TRUE will - * be returned. Generally, if @gradient can't be resolved, it is - * due to it being defined on top of a named color that doesn't - * exist in @props. - * - * Returns: %TRUE if the gradient has been resolved - * - * Since: 3.0 - **/ -gboolean -gtk_gradient_resolve (GtkGradient *gradient, - GtkStyleProperties *props, - cairo_pattern_t **resolved_gradient) -{ - cairo_pattern_t *pattern; - guint i; - - g_return_val_if_fail (gradient != NULL, FALSE); - g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); - g_return_val_if_fail (resolved_gradient != NULL, FALSE); - - if (gradient->radius0 == 0 && gradient->radius1 == 0) - pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0, - gradient->x1, gradient->y1); - else - pattern = cairo_pattern_create_radial (gradient->x0, gradient->y0, - gradient->radius0, - gradient->x1, gradient->y1, - gradient->radius1); - - for (i = 0; i < gradient->stops->len; i++) - { - ColorStop *stop; - GdkRGBA color; - - stop = &g_array_index (gradient->stops, ColorStop, i); - - if (!gtk_symbolic_color_resolve (stop->color, props, &color)) - { - cairo_pattern_destroy (pattern); - return FALSE; - } - - cairo_pattern_add_color_stop_rgba (pattern, stop->offset, - color.red, color.green, - color.blue, color.alpha); - } - - *resolved_gradient = pattern; - return TRUE; -} diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index fdcb915fe4..462f086b09 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -21,49 +21,30 @@ #define __GTK_SYMBOLIC_COLOR_H__ #include +#include G_BEGIN_DECLS -/* Dummy typedefs */ -typedef struct _GtkSymbolicColor GtkSymbolicColor; -typedef struct _GtkGradient GtkGradient; - #define GTK_TYPE_SYMBOLIC_COLOR (gtk_symbolic_color_get_type ()) -#define GTK_TYPE_GRADIENT (gtk_gradient_get_type ()) -GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; -GType gtk_gradient_get_type (void) G_GNUC_CONST; +GType gtk_symbolic_color_get_type (void) G_GNUC_CONST; -GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color); -GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); -GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, - gdouble factor); -GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, - gdouble factor); -GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, - GtkSymbolicColor *color2, - gdouble factor); +GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color); +GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); +GtkSymbolicColor * gtk_symbolic_color_new_shade (GtkSymbolicColor *color, + gdouble factor); +GtkSymbolicColor * gtk_symbolic_color_new_alpha (GtkSymbolicColor *color, + gdouble factor); +GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, + GtkSymbolicColor *color2, + gdouble factor); -GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); -void gtk_symbolic_color_unref (GtkSymbolicColor *color); +GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); +void gtk_symbolic_color_unref (GtkSymbolicColor *color); -GtkGradient * gtk_gradient_new_linear (gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1); -GtkGradient * gtk_gradient_new_radial (gdouble x0, - gdouble y0, - gdouble radius0, - gdouble x1, - gdouble y1, - gdouble radius1); - -void gtk_gradient_add_color_stop (GtkGradient *gradient, - gdouble offset, - GtkSymbolicColor *color); - -GtkGradient * gtk_gradient_ref (GtkGradient *gradient); -void gtk_gradient_unref (GtkGradient *gradient); +gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, + GtkStyleProperties *props, + GdkRGBA *resolved_color); G_END_DECLS diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 324ed3d318..1c0bfee777 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -59,6 +59,7 @@ #include "gtkbuilderprivate.h" #include "gtksizerequest.h" #include "gtkstylecontext.h" +#include "gtksymboliccolor.h" #include "gtkcssprovider.h" #include "gtkanimationdescription.h" #include "gtkversion.h" diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 6240c64338..7f688555df 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include From 2578f4f4c389845aab951fcbf9a1716a89403f06 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 25 Nov 2010 20:48:52 -0500 Subject: [PATCH 593/634] Trivial doc fixes --- docs/reference/gtk/gtk3-sections.txt | 13 ++++++++++++- gtk/gtkwidget.h | 12 ++++++------ gtk/gtkwidgetpath.c | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 71202082f0..00fa6d3764 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4858,7 +4858,6 @@ gtk_widget_modify_text gtk_widget_modify_base gtk_widget_modify_font gtk_widget_modify_cursor -gtk_widget_modify_symbolic_color gtk_widget_create_pango_context gtk_widget_get_pango_context gtk_widget_create_pango_layout @@ -5327,6 +5326,7 @@ gtk_style_properties_lookup_property gtk_style_properties_map_color gtk_style_properties_merge gtk_style_properties_new +GtkStylePropertyParser gtk_style_properties_register_property gtk_style_properties_set gtk_style_properties_set_property @@ -5373,6 +5373,14 @@ GTK_STYLE_CLASS_SCROLLBAR GTK_STYLE_CLASS_SLIDER GTK_STYLE_CLASS_TOOLTIP GTK_STYLE_CLASS_TROUGH +GTK_STYLE_CLASS_ACCELERATOR +GTK_STYLE_CLASS_DOCK +GTK_STYLE_CLASS_GRIP +GTK_STYLE_CLASS_MENUBAR +GTK_STYLE_CLASS_MENUITEM +GTK_STYLE_CLASS_PROGRESSBAR +GTK_STYLE_CLASS_SPINNER +GTK_STYLE_CLASS_TOOLBAR GTK_STYLE_REGION_COLUMN GTK_STYLE_REGION_COLUMN_HEADER GTK_STYLE_REGION_ROW @@ -5467,6 +5475,8 @@ gtk_css_provider_load_from_data gtk_css_provider_load_from_file gtk_css_provider_load_from_path gtk_css_provider_new +GTK_CSS_PROVIDER_ERROR +GtkCssProviderError GTK_TYPE_CSS_PROVIDER GTK_CSS_PROVIDER @@ -5476,6 +5486,7 @@ GTK_IS_CSS_PROVIDER GTK_IS_CSS_PROVIDER_CLASS gtk_css_provider_get_type +gtk_css_provider_error_quark
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 7f688555df..afc03e9d84 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -767,14 +767,14 @@ void gtk_widget_override_background_color (GtkWidget *widget, GtkStateFlags state, const GdkRGBA *color); -void gtk_widget_override_font (GtkWidget *widget, - const PangoFontDescription *font_desc); +void gtk_widget_override_font (GtkWidget *widget, + const PangoFontDescription *font_desc); -void gtk_widget_override_symbolic_color (GtkWidget *widget, - const gchar *name, - const GdkRGBA *color); +void gtk_widget_override_symbolic_color (GtkWidget *widget, + const gchar *name, + const GdkRGBA *color); -void gtk_widget_style_attach (GtkWidget *widget); +void gtk_widget_style_attach (GtkWidget *widget); #if !defined(GTK_DISABLE_DEPRECATED) || defined(GTK_COMPILATION) diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 4bfacc10d9..d25f550975 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -30,7 +30,7 @@ * @Title: GtkWidgetPath * @See_also: #GtkStyleContext * - * #GtkWidgetPath is a boxed type that represents a widget hierarchy from + * GtkWidgetPath is a boxed type that represents a widget hierarchy from * the topmost widget, typically a toplevel, to any child. This widget * path abstraction is used in #GtkStyleContext on behalf of the real * widget in order to query style information. From 5adfe6029de005e538b296c2e6bb0370b87106bd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 25 Nov 2010 21:47:46 -0500 Subject: [PATCH 594/634] Don't add class "scrollbar" for every trough Turns out "trough" as a detail string is used in a variety of widgets, not all of which are scrollbars. --- gtk/gtkscrollbar.c | 4 ++++ gtk/gtkstyle.c | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index d04ed7c387..df4ad75b9c 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -118,6 +118,10 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class) static void gtk_scrollbar_init (GtkScrollbar *scrollbar) { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (GTK_WIDGET (scrollbar)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCROLLBAR); } static void diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index a59f1e4bb4..9fea0d3420 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1805,10 +1805,7 @@ transform_detail_string (const gchar *detail, strcmp (detail, "viewportbin") == 0) gtk_style_context_add_class (context, "viewport"); else if (strncmp (detail, "trough", 6) == 0) - { - gtk_style_context_add_class (context, "scrollbar"); - gtk_style_context_add_class (context, "trough"); - } + gtk_style_context_add_class (context, "trough"); else if (strcmp (detail, "spinbutton") == 0) gtk_style_context_add_class (context, "spinbutton"); else if (strcmp (detail, "spinbutton_up") == 0) From 897c370f5fd7e8869981c8ddfc08c23156fe0540 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 25 Nov 2010 23:46:15 -0500 Subject: [PATCH 595/634] Avoid compiler warnings --- gtk/gtkcssprovider.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 76fd8665ae..408f96c343 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -153,7 +153,8 @@ * * * Refer to the documentation of individual widgets to learn which - * style classes they define. + * style classes they define and see + * for a list of all style classes used by GTK+ widgets. * * * Style classes in selectors @@ -2392,10 +2393,11 @@ gradient_parse (const gchar *str) static gchar * path_parse_str (GtkCssProvider *css_provider, - const gchar *str, - gchar **end_ptr) + const gchar *str, + gchar **end_ptr) { - gchar *path, *chr, *start, *end; + gchar *path, *chr; + const gchar *start, *end; start = str; @@ -2424,7 +2426,7 @@ path_parse_str (GtkCssProvider *css_provider, if (*str == '"' || *str == '\'') { - gchar *p; + const gchar *p; p = str; str++; @@ -2433,25 +2435,25 @@ path_parse_str (GtkCssProvider *css_provider, if (*chr != *p || chr == p) { - *end_ptr = str; + *end_ptr = (gchar *)str; return NULL; } } else { - *end_ptr = str; + *end_ptr = (gchar *)str; return NULL; } path = g_strndup (str, chr - str); g_strstrip (path); - *end_ptr = end; + *end_ptr = (gchar *)end; } else { path = g_strdup (str); - *end_ptr = str + strlen (str); + *end_ptr = (gchar *)str + strlen (str); } /* Always return an absolute path */ @@ -2480,7 +2482,7 @@ path_parse_str (GtkCssProvider *css_provider, g_warning ("File doesn't exist: %s\n", path); g_free (path); path = NULL; - *end_ptr = start; + *end_ptr = (gchar *)start; } return path; @@ -2490,7 +2492,8 @@ static gchar * path_parse (GtkCssProvider *css_provider, const gchar *str) { - gchar *path, *end; + gchar *path; + gchar *end; path = path_parse_str (css_provider, str, &end); From ca143b13034faafd2cfc11712b09ebb12bf6467c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 25 Nov 2010 23:49:07 -0500 Subject: [PATCH 596/634] Add list of classes and regions to the docs --- gtk/gtkcssprovider.c | 4 +- gtk/gtkstylecontext.c | 208 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 408f96c343..689a151b2d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -186,7 +186,9 @@ * * * Refer to the documentation of individual widgets to learn which - * regions and pseudo-classes they define. + * regions and pseudo-classes they define and see + * for a list of all regions + * used by GTK+ widgets. * * * Regions in selectors diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 190579d892..292ab12fa7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -168,6 +168,214 @@ * by the animation. * * + * + * Style classes and regions + * + * Widgets can add style classes to their context, which can be used + * to associate different styles by class (see ). Theme engines can also use style classes to vary their + * rendering. GTK+ has a number of predefined style classes: + * + * + * + * + * Style class + * Macro + * Used by + * + * + * + * + * button + * GTK_STYLE_CLASS_BUTTON + * #GtkButton, #GtkToggleButton, #GtkRadioButton, #GtkCheckButton + * + * + * default + * GTK_STYLE_CLASS_DEFAULT + * #GtkButton + * + * + * check + * GTK_STYLE_CLASS_CHECK + * #GtkCheckButton, #GtkCheckMenuItem, #GtkCellRendererToggle + * + * + * radio + * GTK_STYLE_CLASS_RADIO + * #GtkRadioButton, #GtkRadioMenuItem, #GtkCellRendererToggle + * + * + * arrow + * GTK_STYLE_CLASS_ARROW + * #GtkArrow + * + * + * calendar + * GTK_STYLE_CLASS_CALENDAR + * #GtkCalendar + * + * + * entry + * GTK_STYLE_CLASS_ENTRY + * #GtkEntry + * + * + * cell + * GTK_STYLE_CLASS_CELL + * #GtkCellRendererToggle + * + * + * menu + * GTK_STYLE_CLASS_MENU + * #GtkMenu, #GtkMenuItem, #GtkCheckMenuItem, #GtkRadioMenuItem + * + * + * expander + * GTK_STYLE_CLASS_EXPANDER + * #GtkExpander + * + * + * tooltip + * GTK_STYLE_CLASS_TOOLTIP + * #GtkTooltip + * + * + * frame + * GTK_STYLE_CLASS_FRAME + * #GtkFrame + * + * + * scrolled-window + * + * #GtkScrolledWindow + * + * + * viewport + * + * #GtkViewport + * + * + * trough + * GTK_STYLE_CLASS_TROUGH + * #GtkScrollbar, #GtkProgressBar, #GtkScale + * + * + * progressbar + * GTK_STYLE_CLASS_PROGRESSBAR + * #GtkProgressBar, #GtkCellRendererProgress + * + * + * slider + * GTK_STYLE_CLASS_SLIDER + * #GtkScrollbar, #GtkScale + * + * + * menuitem + * GTK_STYLE_CLASS_MENUITEM + * #GtkMenuItem + * + * + * popup + * + * #GtkMenu + * + * + * accelerator + * GTK_STYLE_CLASS_ACCELERATOR + * #GtkAccelLabel + * + * + * menubar + * GTK_STYLE_CLASS_MENUBAR + * #GtkMenuBar + * + * + * toolbar + * GTK_STYLE_CLASS_TOOLBAR + * #GtkToolbar + * + * + * dock + * GTK_STYLE_CLASS_DOCK + * #GtkHandleBox + * + * + * notebook + * + * #GtkNotebook + * + * + * background + * GTK_STYLE_CLASS_BACKGROUND + * #GtkWindow + * + * + * rubberband + * GTK_STYLE_CLASS_RUBBERBAND + * + * + * + * header + * GTK_STYLE_CLASS_HEADER + * + * + * + * grip + * GTK_STYLE_CLASS_GRIP + * #GtkWindow + * + * + * spinner + * GTK_STYLE_CLASS_SPINNER + * #GtkSpinner + * + * + * + * + * + * + * Widgets can also add regions with flags to their context. + * The regions used by GTK+ widgets are: + * + * + * + * + * Region + * Flags + * Macro + * Used by + * + * + * + * + * row + * even, odd + * GTK_STYLE_REGION_ROW + * #GtkTreeView + * + * + * column + * first, last, sorted + * GTK_STYLE_REGION_COLUMN + * #GtkTreeView + * + * + * column-header + * + * GTK_STYLE_REGION_COLUMN_HEADER + * + * + * + * tab + * even, odd, first, last + * GTK_STYLE_REGION_TAB + * #GtkNotebook + * + * + * + * + * + * * * Custom styling in UI libraries and applications * From f86e8f7512ac1acffca86863ff473601eb5c5734 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Nov 2010 00:43:16 -0500 Subject: [PATCH 597/634] Allow images for background-image In addition to -gtk-gradient(...), allow url(path), and create a pattern from the image. Still to do: allow stretch/repeat options. --- gtk/gtkcssprovider.c | 50 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 689a151b2d..2e5b2a99b7 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -601,7 +601,8 @@ * * * background-image - * gradient (see above) + * gradient (see above) or + * url(@path) * #cairo_pattern_t * -gtk-gradient (linear, * left top, right top, @@ -614,7 +615,8 @@ * center center, 0.2, * center center, 0.8, * color-stop (0.0, #fff), - * color-stop (1.0, #000)); + * color-stop (1.0, #000)); + * url ('background.png'); * * * @@ -2852,7 +2854,49 @@ css_provider_parse_value (GtkCssProvider *css_provider, g_value_take_boxed (value, gradient); } else - parsed = FALSE; + { + gchar *path; + GdkPixbuf *pixbuf; + + path = path_parse (css_provider, value_str); + + if (path) + { + pixbuf = gdk_pixbuf_new_from_file (path, NULL); + g_free (path); + + if (pixbuf) + { + cairo_surface_t *surface; + cairo_pattern_t *pattern; + cairo_t *cr; + cairo_matrix_t matrix; + + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf)); + cr = cairo_create (surface); + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); + cairo_paint (cr); + pattern = cairo_pattern_create_for_surface (surface); + + cairo_matrix_init_scale (&matrix, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf)); + cairo_pattern_set_matrix (pattern, &matrix); + + cairo_surface_destroy (surface); + cairo_destroy (cr); + g_object_unref (pixbuf); + + g_value_take_boxed (value, pattern); + } + else + parsed = FALSE; + } + else + parsed = FALSE; + } } else if (G_TYPE_IS_ENUM (type)) { From 12d6b5889d99c9099a179ca5369c2a0e1641585a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Nov 2010 02:29:56 -0500 Subject: [PATCH 598/634] Add a testcase a problem with style property handling --- gtk/tests/stylecontext.c | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/gtk/tests/stylecontext.c b/gtk/tests/stylecontext.c index e6238353e1..c20203e0e8 100644 --- a/gtk/tests/stylecontext.c +++ b/gtk/tests/stylecontext.c @@ -153,7 +153,6 @@ test_parse_selectors (void) * the last element */ "E:focused tab {}", - "E..bla {}", NULL }; @@ -459,6 +458,56 @@ test_match (void) g_object_unref (context); } +static void +test_style_property (void) +{ + GtkStyleContext *context; + GtkWidgetPath *path; + GtkCssProvider *provider; + GError *error; + const gchar *data; + gint x; + GdkRGBA *color; + GdkRGBA expected; + + error = NULL; + provider = gtk_css_provider_new (); + + context = gtk_style_context_new (); + + path = gtk_widget_path_new (); + gtk_widget_path_append_type (path, GTK_TYPE_WINDOW); + gtk_widget_path_append_type (path, GTK_TYPE_BOX); + gtk_widget_path_append_type (path, GTK_TYPE_BUTTON); + gtk_style_context_set_path (context, path); + gtk_widget_path_free (path); + gtk_style_context_set_state (context, GTK_STATE_FLAG_PRELIGHT); + + data = "GtkButton:insensitive { color: #001; -GtkButton-child-displacement-x: 1 }\n" + "GtkBox GtkButton:selected { color: #002; -GtkButton-child-displacement-x: 2 }\n" + "GtkButton:prelight { color: #003; -GtkButton-child-displacement-x: 3 }\n" + "GtkButton:focused { color: #004; -GtkButton-child-displacement-x: 4 }\n"; + gtk_css_provider_load_from_data (provider, data, -1, &error); + g_assert_no_error (error); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); + + gtk_style_context_invalidate (context); + + gtk_style_context_get (context, GTK_STATE_FLAG_PRELIGHT, "color", &color, NULL); + gdk_rgba_parse (&expected, "#003"); + g_assert (gdk_rgba_equal (color, &expected)); + gdk_rgba_free (color); + + gtk_style_context_get_style (context, "child-displacement-x", &x, NULL); + + g_assert_cmpint (x, ==, 3); + + g_object_unref (provider); + g_object_unref (context); +} + int main (int argc, char *argv[]) { @@ -471,6 +520,7 @@ main (int argc, char *argv[]) g_test_add_func ("/style/parse/declarations", test_parse_declarations); g_test_add_func ("/style/path", test_path); g_test_add_func ("/style/match", test_match); + g_test_add_func ("/style/style-property", test_style_property); return g_test_run (); } From 587c08a15105220a1bcf0cebf2d341c0a8fca071 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Nov 2010 02:35:38 -0500 Subject: [PATCH 599/634] Add explanation to failing test --- gtk/tests/stylecontext.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/tests/stylecontext.c b/gtk/tests/stylecontext.c index c20203e0e8..20b7dadfc9 100644 --- a/gtk/tests/stylecontext.c +++ b/gtk/tests/stylecontext.c @@ -483,6 +483,14 @@ test_style_property (void) gtk_widget_path_free (path); gtk_style_context_set_state (context, GTK_STATE_FLAG_PRELIGHT); + /* Since we set the prelight state on the context, we expect + * only the third selector to match, even though the second one + * has higher specificity, and the fourth one comes later. + * + * In particular, we want to verify that widget style properties and + * CSS properties follow the same matching rules, ie we expect + * color to be #003 and child-displacement-x to be 3. + */ data = "GtkButton:insensitive { color: #001; -GtkButton-child-displacement-x: 1 }\n" "GtkBox GtkButton:selected { color: #002; -GtkButton-child-displacement-x: 2 }\n" "GtkButton:prelight { color: #003; -GtkButton-child-displacement-x: 3 }\n" From 7abf76fbc1da5fb3284c800c9837b7637aadd91f Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 26 Nov 2010 08:59:10 +0100 Subject: [PATCH 600/634] Initialize screen of GtkStyleContext to default screen --- gtk/gtkstylecontext.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 292ab12fa7..2cee5004bc 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -706,6 +706,8 @@ gtk_style_context_init (GtkStyleContext *style_context) priv->direction = GTK_TEXT_DIR_RTL; + priv->screen = gdk_screen_get_default (); + /* Create default info store */ info = style_info_new (); priv->info_stack = g_slist_prepend (priv->info_stack, info); @@ -1232,9 +1234,8 @@ style_provider_remove (GList **list, * gtk_style_context_new: * * Creates a standalone #GtkStyleContext, this style context - * won't be attached to any widget nor screen, so you may want - * to call gtk_style_context_set_path() and - * gtk_style_context_set_screen() yourself. + * won't be attached to any widget, so you may want + * to call gtk_style_context_set_path() yourself. * * * This function is only useful when using the theming layer From 7a5a622998a32ef4e420cddfa5369bd630dc8b30 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 26 Nov 2010 09:01:17 +0100 Subject: [PATCH 601/634] Check screen really changed before notifying it and invalidating the context --- gtk/gtkstylecontext.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 2cee5004bc..7e1dd2c8b1 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2556,8 +2556,12 @@ gtk_style_context_set_screen (GtkStyleContext *context, GtkStyleContextPrivate *priv; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GDK_IS_SCREEN (screen)); priv = context->priv; + if (priv->screen == screen) + return; + priv->screen = screen; g_object_notify (G_OBJECT (context), "screen"); From 4aaf193602b95f56fff4844ab72d133e6064070d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 26 Nov 2010 09:07:41 +0100 Subject: [PATCH 602/634] docs: gtk_style_context_get_screen() always returns a valid screen --- gtk/gtkstylecontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 7e1dd2c8b1..1ec47e2216 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2575,7 +2575,7 @@ gtk_style_context_set_screen (GtkStyleContext *context, * * Returns the #GdkScreen to which @context is attached. * - * Returns: a #GdkScreen, or %NULL. + * Returns: a #GdkScreen. **/ GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context) From 4c1a2426d4f09f28421a595e6e89f77576efbf92 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 26 Nov 2010 01:27:19 +0100 Subject: [PATCH 603/634] GtkStyle: Commit a few typos when translating states. --- gtk/gtkstyle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9fea0d3420..3310ebbf82 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -754,7 +754,7 @@ gtk_style_update_from_context (GtkStyle *style) if (style->font_desc) pango_font_description_free (style->font_desc); - gtk_style_context_get (priv->context, state, + gtk_style_context_get (priv->context, 0, "font", &style->font_desc, "padding", &padding, NULL); @@ -2869,7 +2869,7 @@ gtk_default_draw_shadow_gap (GtkStyle *style, switch (state_type) { case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; + flags |= GTK_STATE_FLAG_ACTIVE; break; case GTK_STATE_PRELIGHT: flags |= GTK_STATE_FLAG_PRELIGHT; @@ -2935,7 +2935,7 @@ gtk_default_draw_box_gap (GtkStyle *style, switch (state_type) { case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; + flags |= GTK_STATE_FLAG_ACTIVE; break; case GTK_STATE_PRELIGHT: flags |= GTK_STATE_FLAG_PRELIGHT; @@ -3005,7 +3005,7 @@ gtk_default_draw_extension (GtkStyle *style, switch (state_type) { case GTK_STATE_ACTIVE: - flags |= GTK_STATE_ACTIVE; + flags |= GTK_STATE_FLAG_ACTIVE; break; case GTK_STATE_PRELIGHT: flags |= GTK_STATE_FLAG_PRELIGHT; From 32c2b139695f0c62d35e95f85cae323252b30e52 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 29 Nov 2010 11:24:04 +0100 Subject: [PATCH 604/634] GtkThemingEngine: split background rendering to a private function. --- gtk/gtkthemingengine.c | 84 ++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index b1db53861f..43444176e6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1284,34 +1284,24 @@ _cairo_round_rectangle_sides (cairo_t *cr, } static void -gtk_theming_engine_render_background (GtkThemingEngine *engine, - cairo_t *cr, - gdouble x, - gdouble y, - gdouble width, - gdouble height) +render_background_internal (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkJunctionSides junction) { GdkRGBA *bg_color; cairo_pattern_t *pattern; GtkStateFlags flags; gboolean running; gdouble progress, alpha = 1; - GtkJunctionSides junction; gint radius, border_width; flags = gtk_theming_engine_get_state (engine); - junction = gtk_theming_engine_get_junction_sides (engine); cairo_save (cr); - if (gtk_theming_engine_has_class (engine, "spinbutton") && - gtk_theming_engine_has_class (engine, "button")) - { - x += 2; - y += 2; - width -= 4; - height -= 4; - } - gtk_theming_engine_get (engine, flags, "background-image", &pattern, "background-color", &bg_color, @@ -1321,18 +1311,6 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); - if (border_width > 0) - { - x += border_width; - y += border_width; - width -= 2 * border_width; - height -= 2 * border_width; - radius -= 2 * border_width; - - if (radius < 0) - radius = 0; - } - _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_ALL, junction); @@ -1502,8 +1480,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, const GdkRGBA *color, *other_color; /* Merge just colors */ - color = bg_color; - other_color = other_bg; + color = bg_color; + other_color = other_bg; new_pattern = cairo_pattern_create_rgba (CLAMP (color->red + ((other_color->red - color->red) * progress), 0, 1), CLAMP (color->green + ((other_color->green - color->green) * progress), 0, 1), @@ -1551,6 +1529,50 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdk_rgba_free (bg_color); } +static void +gtk_theming_engine_render_background (GtkThemingEngine *engine, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height) +{ + GdkRGBA *bg_color; + cairo_pattern_t *pattern; + GtkStateFlags flags; + gboolean running; + gdouble progress, alpha = 1; + GtkJunctionSides junction; + gint radius, border_width; + + junction = gtk_theming_engine_get_junction_sides (engine); + + if (gtk_theming_engine_has_class (engine, "spinbutton") && + gtk_theming_engine_has_class (engine, "button")) + { + x += 2; + y += 2; + width -= 4; + height -= 4; + } + + gtk_theming_engine_get (engine, flags, + "border-width", &border_width, + NULL); + + if (border_width > 0) + { + x += border_width; + y += border_width; + width -= 2 * border_width; + height -= 2 * border_width; + } + + render_background_internal (engine, cr, + x, y, width, height, + junction); +} + /* Renders the small triangle on corners so * frames with 0 radius have a 3D-like effect */ From 64b7d9e5c1f40b8f5bcf416bae8eadfad51e65af Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 29 Nov 2010 11:25:09 +0100 Subject: [PATCH 605/634] GtkThemingEngine: Render gradients in tabs. Background will be actually rotated in tabs, so the "bottom" side coincides with the junction point, this makes gradients work as expected in rotated tabs. --- gtk/gtkthemingengine.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 43444176e6..3f2324bcfd 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -2303,32 +2303,45 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, case GTK_POS_LEFT: junction = GTK_JUNCTION_LEFT; hidden_side = SIDE_LEFT; + + cairo_translate (cr, x + width, y); + cairo_rotate (cr, G_PI / 2); break; case GTK_POS_RIGHT: junction = GTK_JUNCTION_RIGHT; hidden_side = SIDE_RIGHT; + + cairo_translate (cr, x, y + height); + cairo_rotate (cr, - G_PI / 2); break; case GTK_POS_TOP: junction = GTK_JUNCTION_TOP; hidden_side = SIDE_TOP; + + cairo_translate (cr, x + width, y + height); + cairo_rotate (cr, G_PI); break; case GTK_POS_BOTTOM: junction = GTK_JUNCTION_BOTTOM; hidden_side = SIDE_BOTTOM; + + cairo_translate (cr, x, y); break; } - state = gtk_theming_engine_get_state (engine); - gtk_theming_engine_get (engine, state, - "background-color", &bg_color, - "border-radius", &radius, - NULL); + if (gap_side == GTK_POS_TOP || + gap_side == GTK_POS_BOTTOM) + render_background_internal (engine, cr, + 0, 0, width, height, + junction); + else + render_background_internal (engine, cr, + 0, 0, height, width, + junction); - _cairo_round_rectangle_sides (cr, radius, - x, y, width, height, - SIDE_ALL, junction); - gdk_cairo_set_source_rgba (cr, bg_color); - cairo_fill (cr); + cairo_restore (cr); + + cairo_save (cr); render_frame_internal (engine, cr, x, y, width, height, From 46de2130d3bb6ad5dd0ffcefb9662b65d9db2690 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 29 Nov 2010 11:27:43 +0100 Subject: [PATCH 606/634] GtkWidget: unset NULL properties when overriding style. --- gtk/gtkwidget.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 1c0bfee777..d84e9be5e5 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8002,9 +8002,12 @@ gtk_widget_override_color (GtkWidget *widget, properties = _gtk_widget_get_modifier_properties (widget); - gtk_style_properties_set (properties, state, - "color", color, - NULL); + if (color) + gtk_style_properties_set (properties, state, + "color", color, + NULL); + else + gtk_style_properties_unset_property (properties, "color", state); context = gtk_widget_get_style_context (widget); gtk_style_context_invalidate (context); @@ -8039,9 +8042,14 @@ gtk_widget_override_background_color (GtkWidget *widget, properties = _gtk_widget_get_modifier_properties (widget); - gtk_style_properties_set (properties, state, - "background-color", color, - NULL); + if (color) + gtk_style_properties_set (properties, state, + "background-color", color, + NULL); + else + gtk_style_properties_unset_property (properties, + "background-color", + state); context = gtk_widget_get_style_context (widget); gtk_style_context_invalidate (context); @@ -8075,9 +8083,12 @@ gtk_widget_override_font (GtkWidget *widget, properties = _gtk_widget_get_modifier_properties (widget); - gtk_style_properties_set (properties, 0, - "font", font_desc, - NULL); + if (font_desc) + gtk_style_properties_set (properties, 0, + "font", font_desc, + NULL); + else + gtk_style_properties_unset_property (properties, "font", 0); context = gtk_widget_get_style_context (widget); gtk_style_context_invalidate (context); From 2ca905db5ebeeb275e72629b535b8153f0ae9b01 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Nov 2010 02:13:10 +0100 Subject: [PATCH 607/634] GtkStyleContext: Handle directionality when picking next provider. --- gtk/gtkstylecontext.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 1ec47e2216..35d7eee06b 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -977,8 +977,9 @@ gtk_style_context_impl_get_property (GObject *object, } static GList * -find_next_candidate (GList *local, - GList *global) +find_next_candidate (GList *local, + GList *global, + gboolean ascending) { if (local && global) { @@ -988,9 +989,9 @@ find_next_candidate (GList *local, global_data = global->data; if (local_data->priority < global_data->priority) - return local; + return (ascending) ? local : global; else - return global; + return (ascending) ? global : local; } else if (local) return local; @@ -1014,7 +1015,7 @@ build_properties (GtkStyleContext *context, if (priv->screen) global_list = g_object_get_qdata (G_OBJECT (priv->screen), provider_list_quark); - while ((elem = find_next_candidate (list, global_list)) != NULL) + while ((elem = find_next_candidate (list, global_list, TRUE)) != NULL) { GtkStyleProviderData *data; GtkStyleProperties *provider_style; @@ -1053,7 +1054,7 @@ build_icon_factories (GtkStyleContext *context, global_list = g_list_last (global_list); } - while ((elem = find_next_candidate (list, global_list)) != NULL) + while ((elem = find_next_candidate (list, global_list, FALSE)) != NULL) { GtkIconFactory *factory; GtkStyleProviderData *data; @@ -2280,7 +2281,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, list = priv->providers_last; global = global_list; - while ((elem = find_next_candidate (list, global)) != NULL) + while ((elem = find_next_candidate (list, global, FALSE)) != NULL) { GtkStyleProviderData *provider_data; From 297fa7a3dd6f114cecc1c2f1306312599f392e23 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Nov 2010 02:14:00 +0100 Subject: [PATCH 608/634] GtkStyleProvider: Add GtkStateFlags parameter to get_style_property(). Widget style properties can now have different values depending on the current state. --- gtk/gtkcssprovider.c | 5 ++++- gtk/gtkstylecontext.c | 34 +++++++++++++++++++++++----------- gtk/gtkstylecontext.h | 1 + gtk/gtkstyleprovider.c | 4 +++- gtk/gtkstyleprovider.h | 2 ++ gtk/gtkwidget.c | 9 +++++++-- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2e5b2a99b7..bd9633295d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1340,6 +1340,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider, static gboolean gtk_css_provider_get_style_property (GtkStyleProvider *provider, GtkWidgetPath *path, + GtkStateFlags state, GParamSpec *pspec, GValue *value) { @@ -1362,7 +1363,9 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, info = &g_array_index (priority_info, StylePriorityInfo, i); val = g_hash_table_lookup (info->style, prop_name); - if (val) + if (val && + (info->state & state) != 0 && + (info->state & ~(state)) == 0) { const gchar *val_str; diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 35d7eee06b..c458c244b4 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -427,6 +427,7 @@ struct PropertyValue { GType widget_type; GParamSpec *pspec; + GtkStateFlags state; GValue value; }; @@ -2221,15 +2222,22 @@ style_property_values_cmp (gconstpointer bsearch_node1, const PropertyValue *val1 = bsearch_node1; const PropertyValue *val2 = bsearch_node2; - if (val1->widget_type == val2->widget_type) - return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1; - else + if (val1->widget_type != val2->widget_type) return val1->widget_type < val2->widget_type ? -1 : 1; + + if (val1->pspec != val2->pspec) + return val1->pspec < val2->pspec ? -1 : 1; + + if (val1->state != val2->state) + return val1->state < val2->state ? -1 : 1; + + return 0; } const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, + GtkStateFlags state, GParamSpec *pspec) { GtkStyleContextPrivate *priv; @@ -2242,6 +2250,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, data = style_data_lookup (context); key.widget_type = widget_type; + key.state = state; key.pspec = pspec; /* need value cache array */ @@ -2293,8 +2302,8 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context, global = global->prev; if (gtk_style_provider_get_style_property (provider_data->provider, - priv->widget_path, pspec, - &pcache->value)) + priv->widget_path, state, + pspec, &pcache->value)) { /* Resolve symbolic colors to GdkColor/GdkRGBA */ if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR) @@ -2358,6 +2367,7 @@ gtk_style_context_get_style_property (GtkStyleContext *context, { GtkStyleContextPrivate *priv; GtkWidgetClass *widget_class; + GtkStateFlags state; GParamSpec *pspec; const GValue *peek_value; GType widget_type; @@ -2386,9 +2396,9 @@ gtk_style_context_get_style_property (GtkStyleContext *context, return; } - peek_value = _gtk_style_context_peek_style_property (context, - widget_type, - pspec); + state = gtk_style_context_get_state (context); + peek_value = _gtk_style_context_peek_style_property (context, widget_type, + state, pspec); if (G_VALUE_TYPE (value) == G_VALUE_TYPE (peek_value)) g_value_copy (peek_value, value); @@ -2417,6 +2427,7 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, { GtkStyleContextPrivate *priv; const gchar *prop_name; + GtkStateFlags state; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); @@ -2426,6 +2437,8 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, if (!priv->widget_path) return; + state = gtk_style_context_get_state (context); + while (prop_name) { GtkWidgetClass *widget_class; @@ -2449,9 +2462,8 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, continue; } - peek_value = _gtk_style_context_peek_style_property (context, - widget_type, - pspec); + peek_value = _gtk_style_context_peek_style_property (context, widget_type, + state, pspec); G_VALUE_LCOPY (peek_value, args, 0, &error); diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 2868c85a8c..b2dd734d10 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -424,6 +424,7 @@ void gtk_style_context_pop_animatable_region (GtkStyleContext *context); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, + GtkStateFlags state, GParamSpec *pspec); void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context); void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 76257ba5e0..8ed0d975ca 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -86,6 +86,7 @@ gtk_style_provider_get_style (GtkStyleProvider *provider, * gtk_style_provider_get_style_property: * @provider: a #GtkStyleProvider * @path: #GtkWidgetPath to query + * @state: state to query the style property for * @pspec: The #GParamSpec to query * @value: (out): return location for the property value * @@ -97,6 +98,7 @@ gtk_style_provider_get_style (GtkStyleProvider *provider, gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, GtkWidgetPath *path, + GtkStateFlags state, GParamSpec *pspec, GValue *value) { @@ -113,7 +115,7 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider, if (!iface->get_style_property) return FALSE; - return iface->get_style_property (provider, path, pspec, value); + return iface->get_style_property (provider, path, state, pspec, value); } /** diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index a920256d91..31e7b42293 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -97,6 +97,7 @@ struct _GtkStyleProviderIface gboolean (* get_style_property) (GtkStyleProvider *provider, GtkWidgetPath *path, + GtkStateFlags state, GParamSpec *pspec, GValue *value); @@ -111,6 +112,7 @@ GtkStyleProperties *gtk_style_provider_get_style (GtkStyleProvider *provider, gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider, GtkWidgetPath *path, + GtkStateFlags state, GParamSpec *pspec, GValue *value); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d84e9be5e5..7c748c4ceb 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -11372,11 +11372,14 @@ gtk_widget_style_get_property (GtkWidget *widget, { GtkStyleContext *context; const GValue *peek_value; + GtkStateFlags state; context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + peek_value = _gtk_style_context_peek_style_property (context, G_OBJECT_TYPE (widget), - pspec); + state, pspec); /* auto-conversion of the caller's value type */ @@ -11410,12 +11413,14 @@ gtk_widget_style_get_valist (GtkWidget *widget, va_list var_args) { GtkStyleContext *context; + GtkStateFlags state; const gchar *name; g_return_if_fail (GTK_IS_WIDGET (widget)); g_object_ref (widget); context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); name = first_property_name; while (name) @@ -11440,7 +11445,7 @@ gtk_widget_style_get_valist (GtkWidget *widget, peek_value = _gtk_style_context_peek_style_property (context, G_OBJECT_TYPE (widget), - pspec); + state, pspec); G_VALUE_LCOPY (peek_value, var_args, 0, &error); if (error) From daab45565a50b4b07fb5bbdd7a87f3db48ddfe9a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Nov 2010 03:59:39 +0100 Subject: [PATCH 609/634] GtkCssProvider: Fix up state matching when looking up style properties. --- gtk/gtkcssprovider.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index bd9633295d..f9636699ca 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1364,8 +1364,10 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, val = g_hash_table_lookup (info->style, prop_name); if (val && - (info->state & state) != 0 && - (info->state & ~(state)) == 0) + (info->state == 0 || + info->state == state || + (info->state & state) != 0 && + (info->state & ~(state)) == 0)) { const gchar *val_str; From f7e7201f11a4a378eee491bde6ff26bbad558a8b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Nov 2010 04:00:26 +0100 Subject: [PATCH 610/634] Fix docs typo. --- gtk/gtkstyleprovider.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 31e7b42293..1e59989bd1 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -42,7 +42,7 @@ G_BEGIN_DECLS #define GTK_STYLE_PROVIDER_PRIORITY_FALLBACK 1 /** - * GTK_STYLE_PROVIDER_PRIORITY_DEFAULT: + * GTK_STYLE_PROVIDER_PRIORITY_THEME: * * The priority used for style information provided * by themes. From cf0bd12e6caf5cac37d7a25430d638d30fad7f39 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 00:55:14 +0100 Subject: [PATCH 611/634] GtkStyleProperties: Turn border-width into a GtkBorder property. All current users of this CSS property have been updated to deal with a GtkBorder. Also a 0 border width has been set in the default CSS to ensure GtkStyleContext and GtkThemingEngine always provide a non-NULL pointer for this property. --- gtk/gtkbutton.c | 45 +++++----- gtk/gtkcombobox.c | 173 +++++++++++++++++++-------------------- gtk/gtkcssprovider.c | 3 +- gtk/gtkmenu.c | 130 +++++++++++++++++------------ gtk/gtkmenubar.c | 19 +++-- gtk/gtkstyleproperties.c | 8 +- gtk/gtkthemingengine.c | 51 ++++++++---- 7 files changed, 238 insertions(+), 191 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index cbfbdcb072..f0e00dadef 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1448,22 +1448,18 @@ gtk_button_size_allocate (GtkWidget *widget, GtkStateFlags state; GtkWidget *child; - gint xthickness, ythickness; GtkBorder default_border; - GtkBorder inner_border; - gint focus_width, border_width; + GtkBorder inner_border, *border; + gint focus_width; gint focus_pad; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get (context, state, - "border-width", &border_width, + "border-width", &border, NULL); - xthickness = border_width; - ythickness = border_width; - gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL); gtk_widget_style_get (GTK_WIDGET (widget), "focus-line-width", &focus_width, @@ -1482,18 +1478,18 @@ gtk_button_size_allocate (GtkWidget *widget, child = gtk_bin_get_child (GTK_BIN (button)); if (child && gtk_widget_get_visible (child)) { - child_allocation.x = allocation->x + inner_border.left + xthickness; - child_allocation.y = allocation->y + inner_border.top + ythickness; + child_allocation.x = allocation->x + inner_border.left + border->left; + child_allocation.y = allocation->y + inner_border.top + border->top; child_allocation.width = allocation->width - - xthickness * 2 - + (border->left + border->right) - inner_border.left - inner_border.right; child_allocation.height = allocation->height - - ythickness * 2 - + (border->top + border->bottom) - inner_border.top - inner_border.bottom; @@ -1531,6 +1527,8 @@ gtk_button_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (child, &child_allocation); } + + gtk_border_free (border); } void @@ -1614,7 +1612,7 @@ _gtk_button_paint (GtkButton *button, gint child_displacement_x; gint child_displacement_y; gboolean displace_focus; - gint border_width; + GtkBorder *border; gtk_widget_style_get (widget, "child-displacement-y", &child_displacement_y, @@ -1623,15 +1621,15 @@ _gtk_button_paint (GtkButton *button, NULL); gtk_style_context_get (context, state, - "border-width", &border_width, + "border-width", &border, NULL); if (interior_focus) { - x += border_width + focus_pad; - y += border_width + focus_pad; - width -= 2 * (border_width + focus_pad); - height -= 2 * (border_width + focus_pad); + x += border->left + focus_pad; + y += border->top + focus_pad; + width -= (2 * focus_pad) + border->left + border->right; + height -= (2 * focus_pad) + border->top + border->bottom; } else { @@ -1649,6 +1647,8 @@ _gtk_button_paint (GtkButton *button, gtk_render_focus (context, cr, x, y, width, height); + + gtk_border_free (border); } } @@ -1910,7 +1910,8 @@ gtk_button_get_size (GtkWidget *widget, GtkBorder default_border; GtkBorder inner_border; GtkStateFlags state; - gint focus_width, border_width; + GtkBorder *border; + gint focus_width; gint focus_pad; gint minimum, natural; @@ -1924,12 +1925,12 @@ gtk_button_get_size (GtkWidget *widget, state = gtk_widget_get_state_flags (GTK_WIDGET (widget)); gtk_style_context_get (context, state, - "border-width", &border_width, + "border-width", &border, NULL); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - minimum = (border_width * 2 + + minimum = (border->left + border->right + inner_border.left + inner_border.right); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) @@ -1937,7 +1938,7 @@ gtk_button_get_size (GtkWidget *widget, } else { - minimum = (border_width * 2 + + minimum = (border->top + border->bottom + inner_border.top + inner_border.bottom); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) @@ -1966,6 +1967,8 @@ gtk_button_get_size (GtkWidget *widget, if (natural_size) *natural_size = natural; + + gtk_border_free (border); } static void diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 9f884a7a4e..0cf07377b0 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -1739,19 +1739,22 @@ gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, } } -static gint -get_widget_border_thickness (GtkWidget *widget) +static void +get_widget_border (GtkWidget *widget, + GtkBorder *border) { GtkStyleContext *context; - gint thickness; + GtkBorder *border_width; context = gtk_widget_get_style_context (widget); gtk_style_context_get (context, gtk_widget_get_state_flags (widget), - "border-width", &thickness, + "border-width", &border_width, NULL); - return thickness; + + *border = *border_width; + gtk_border_free (border_width); } static void @@ -1769,7 +1772,8 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, GdkScreen *screen; gint monitor_num; GdkRectangle monitor; - + GtkBorder border; + /* FIXME: is using the size request here broken? */ child = gtk_bin_get_child (GTK_BIN (combo_box)); @@ -1785,9 +1789,8 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, gdk_window_get_root_coords (gtk_widget_get_window (child), sx, sy, &sx, &sy); - - if (GTK_SHADOW_NONE != combo_box->priv->shadow_type) - sx -= get_widget_border_thickness (GTK_WIDGET (combo_box)); + get_widget_border (GTK_WIDGET (combo_box), &border); + sx -= border.left; if (combo_box->priv->popup_fixed_width) gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL); @@ -2477,13 +2480,13 @@ gtk_combo_box_update_requested_width (GtkComboBox *combo_box, &req, NULL); \ \ if (is_rtl) \ - child.x = allocation->x + shadow_width; \ + child.x = allocation->x + border.right; \ else \ - child.x = allocation->x + allocation->width - req.width - shadow_width; \ + child.x = allocation->x + allocation->width - req.width - border.left; \ \ - child.y = allocation->y + shadow_height; \ + child.y = allocation->y + border.top; \ child.width = req.width; \ - child.height = allocation->height - 2 * shadow_height; \ + child.height = allocation->height - (border.top + border.bottom); \ child.width = MAX (1, child.width); \ child.height = MAX (1, child.height); \ \ @@ -2496,47 +2499,40 @@ gtk_combo_box_size_allocate (GtkWidget *widget, GtkComboBox *combo_box = GTK_COMBO_BOX (widget); GtkComboBoxPrivate *priv = combo_box->priv; GtkWidget *child_widget; - gint shadow_width, shadow_height; gint focus_width, focus_pad; GtkAllocation child; GtkRequisition req; + GtkBorder border; gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; gtk_widget_set_allocation (widget, allocation); child_widget = gtk_bin_get_child (GTK_BIN (widget)); + get_widget_border (widget, &border); gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - if (GTK_SHADOW_NONE != priv->shadow_type) - shadow_width = shadow_height = get_widget_border_thickness (widget); - else - { - shadow_width = 0; - shadow_height = 0; - } - if (!priv->tree_view) { if (priv->cell_view) { - gint xthickness, ythickness; + GtkBorder button_border; gint width; guint border_width; /* menu mode */ - allocation->x += shadow_width; - allocation->y += shadow_height; - allocation->width -= 2 * shadow_width; - allocation->height -= 2 * shadow_height; + allocation->x += border.left; + allocation->y += border.top; + allocation->width -= border.left + border.right; + allocation->height -= border.top + border.bottom; gtk_widget_size_allocate (priv->button, allocation); /* set some things ready */ border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button)); - xthickness = ythickness = get_widget_border_thickness (priv->button); + get_widget_border (priv->button, &button_border); child.x = allocation->x; child.y = allocation->y; @@ -2545,10 +2541,12 @@ gtk_combo_box_size_allocate (GtkWidget *widget, if (!priv->is_cell_renderer) { - child.x += border_width + xthickness + focus_width + focus_pad; - child.y += border_width + ythickness + focus_width + focus_pad; - width -= 2 * (child.x - allocation->x); - child.height -= 2 * (child.y - allocation->y); + child.x += border_width + button_border.left + focus_width + focus_pad; + child.y += border_width + button_border.top + focus_width + focus_pad; + width -= (2 * (border_width + focus_width + focus_pad)) + + button_border.left + button_border.right; + child.height -= (2 * (border_width + focus_width + focus_pad)) + + button_border.top + button_border.bottom; } @@ -2574,14 +2572,14 @@ gtk_combo_box_size_allocate (GtkWidget *widget, { child.x += req.width; child.width = allocation->x + allocation->width - - (border_width + xthickness + focus_width + focus_pad) + - (border_width + button_border.right + focus_width + focus_pad) - child.x; } else { child.width = child.x; child.x = allocation->x - + border_width + xthickness + focus_width + focus_pad; + + border_width + button_border.left + focus_width + focus_pad; child.width -= child.x; } @@ -2619,11 +2617,11 @@ gtk_combo_box_size_allocate (GtkWidget *widget, GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON if (is_rtl) - child.x = allocation->x + req.width + shadow_width; + child.x = allocation->x + req.width + border.right; else - child.x = allocation->x + shadow_width; - child.y = allocation->y + shadow_height; - child.width = allocation->width - req.width - 2 * shadow_width; + child.x = allocation->x + border.left; + child.y = allocation->y + border.top; + child.width = allocation->width - req.width - (border.left + border.right); child.width = MAX (1, child.width); child.height = MAX (1, child.height); gtk_widget_size_allocate (child_widget, &child); @@ -2632,11 +2630,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget, else { /* list mode */ - - /* Combobox thickness + border-width */ guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - int delta_x = shadow_width + border_width; - int delta_y = shadow_height + border_width; /* button */ GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON @@ -2653,30 +2647,32 @@ gtk_combo_box_size_allocate (GtkWidget *widget, if (priv->cell_view_frame) { - child.x += delta_x; - child.y += delta_y; - child.width = MAX (1, child.width - delta_x * 2); - child.height = MAX (1, child.height - delta_y * 2); + child.x += border.left + border_width; + child.y += border.top + border_width; + child.width = MAX (1, child.width - (2 * border_width) - (border.left + border.right)); + child.height = MAX (1, child.height - (2 * border_width) - (border.top + border.bottom)); gtk_widget_size_allocate (priv->cell_view_frame, &child); /* the sample */ if (priv->has_frame) { - border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); - delta_x = delta_y = border_width + get_widget_border_thickness (priv->cell_view_frame); + GtkBorder frame_border; - child.x += delta_x; - child.y += delta_y; - child.width -= delta_x * 2; - child.height -= delta_y * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); + get_widget_border (priv->cell_view_frame, &frame_border); + + child.x += border_width + frame_border.left; + child.y += border_width + frame_border.right; + child.width -= (2 * border_width) + frame_border.left + frame_border.right; + child.height -= (2 * border_width) + frame_border.top + frame_border.bottom; } } else { - child.x += delta_x; - child.y += delta_y; - child.width -= delta_x * 2; - child.height -= delta_y * 2; + child.x += border.left + border_width; + child.y += border.top + border_width; + child.width -= (2 * border_width) - (border.left + border.right); + child.height -= (2 * border_width) - (border.top + border.bottom); } if (gtk_widget_get_visible (priv->popup_window)) @@ -6430,6 +6426,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget, gint child_min, child_nat; GtkStyleContext *style_context; GtkStateFlags state; + GtkBorder *border; child = gtk_bin_get_child (GTK_BIN (widget)); @@ -6451,6 +6448,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget, gtk_style_context_get (style_context, state, "font", &font_desc, + "border-width", &border, NULL); context = gtk_widget_get_pango_context (GTK_WIDGET (widget)); @@ -6472,15 +6470,17 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget, if (priv->cell_view) { gint sep_width, arrow_width; - gint border_width, xthickness, xpad; + gint border_width, xpad; + GtkBorder button_border; border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box)); - xthickness = get_widget_border_thickness (priv->button); + get_widget_border (priv->button, &button_border); gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL); gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL); - xpad = 2*(border_width + xthickness + focus_width + focus_pad); + xpad = 2 * (border_width + focus_width + focus_pad) + + button_border.left + button_border.right; minimum_width = child_min + sep_width + arrow_width + xpad; natural_width = child_nat + sep_width + arrow_width + xpad; @@ -6512,8 +6512,12 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget, { if (priv->has_frame) { - gint border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); - gint xpad = 2 * (border_width + get_widget_border_thickness (priv->cell_view_frame)); + gint border_width, xpad; + GtkBorder frame_border; + + border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); + get_widget_border (priv->cell_view_frame, &frame_border); + xpad = (2 * border_width) + frame_border.left + frame_border.right; minimum_width += xpad; natural_width += xpad; @@ -6528,14 +6532,9 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget, natural_width += button_nat_width; } - if (GTK_SHADOW_NONE != priv->shadow_type) - { - gint thickness; - - thickness = get_widget_border_thickness (GTK_WIDGET (widget)); - minimum_width += 2 * thickness; - natural_width += 2 * thickness; - } + minimum_width += border->left + border->right; + natural_width += border->left + border->right; + gtk_border_free (border); if (minimum_size) *minimum_size = minimum_width; @@ -6580,16 +6579,15 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget, gint focus_width, focus_pad; gint min_height, nat_height; gint size; + GtkBorder border; gtk_widget_style_get (GTK_WIDGET (widget), "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - size = avail_size; - - if (GTK_SHADOW_NONE != priv->shadow_type) - size -= get_widget_border_thickness (widget); + get_widget_border (widget, &border); + size = avail_size - border.left; if (!priv->tree_view) { @@ -6598,10 +6596,11 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget, { /* calculate x/y padding and separator/arrow size */ gint sep_width, arrow_width, sep_height, arrow_height; - gint border_width, xthickness, ythickness, xpad, ypad; + gint border_width, xpad, ypad; + GtkBorder button_border; border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box)); - xthickness = ythickness = get_widget_border_thickness (priv->button); + get_widget_border (priv->button, &button_border); gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL); gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL); @@ -6610,8 +6609,10 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget, gtk_widget_get_preferred_height_for_width (priv->arrow, arrow_width, &arrow_height, NULL); - xpad = 2*(border_width + xthickness + focus_width + focus_pad); - ypad = 2*(border_width + ythickness + focus_width + focus_pad); + xpad = 2 * (border_width + focus_width + focus_pad) + + button_border.left + button_border.right; + ypad = 2 * (border_width + focus_width + focus_pad) + + button_border.top + button_border.bottom; size -= sep_width + arrow_width + xpad; @@ -6653,14 +6654,14 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget, if (priv->cell_view_frame && priv->has_frame) { + GtkBorder frame_border; gint border_width; - gint thickness; border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); - thickness = get_widget_border_thickness (GTK_WIDGET (priv->cell_view_frame)); + get_widget_border (GTK_WIDGET (priv->cell_view_frame), &frame_border); - xpad = 2 * (border_width + thickness); - ypad = 2 * (border_width + thickness); + xpad = (2 * border_width) + border.left + frame_border.right; + ypad = (2 * border_width) + border.top + frame_border.bottom; } size -= but_width; @@ -6676,14 +6677,8 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget, nat_height += ypad; } - if (GTK_SHADOW_NONE != priv->shadow_type) - { - gint thickness; - - thickness = get_widget_border_thickness (widget); - min_height += 2 * thickness; - nat_height += 2 * thickness; - } + min_height += border.top + border.bottom; + nat_height += border.top + border.bottom; if (minimum_size) *minimum_size = min_height; diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f9636699ca..afc8340c58 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -3501,7 +3501,8 @@ gtk_css_provider_get_default (void) " background-color: @bg_color;\n" " color: @fg_color;\n" " border-color: shade (@bg_color, 0.6);\n" - " padding: 2 2; \n" + " padding: 2;\n" + " border-width: 0;\n" "}\n" "\n" "*:prelight {\n" diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index e9defd327b..e678198a39 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -2363,20 +2363,23 @@ get_arrows_border (GtkMenu *menu, border->left = border->right = 0; } -static gint -get_menu_border_thickness (GtkWidget *widget) +static void +get_menu_border (GtkWidget *widget, + GtkBorder *border) { GtkStyleContext *context; GtkStateFlags state; - gint thickness; + GtkBorder *border_width; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get (context, state, - "border-width", &thickness, + "border-width", &border_width, NULL); - return thickness; + + *border = *border_width; + gtk_border_free (border_width); } static void @@ -2387,14 +2390,14 @@ gtk_menu_realize (GtkWidget *widget) GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; - gint border_width, thickness; + gint border_width; GtkMenu *menu; GtkMenuPrivate *priv; GtkWidget *child; GList *children; guint vertical_padding; guint horizontal_padding; - GtkBorder arrow_border; + GtkBorder arrow_border, border; g_return_if_fail (GTK_IS_MENU (widget)); @@ -2423,7 +2426,7 @@ gtk_menu_realize (GtkWidget *widget) gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &border); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); context = gtk_widget_get_style_context (widget); @@ -2434,16 +2437,21 @@ gtk_menu_realize (GtkWidget *widget) gtk_widget_get_allocation (widget, &allocation); - attributes.x = border_width + thickness + horizontal_padding; - attributes.y = border_width + thickness + vertical_padding; - attributes.width = MAX (1, allocation.width - attributes.x * 2); - attributes.height = MAX (1, allocation.height - attributes.y * 2); + attributes.x = border_width + border.left + horizontal_padding; + attributes.y = border_width + border.top + vertical_padding; + attributes.width = allocation.width - + (2 * (border_width + horizontal_padding)) - border.left - border.right; + attributes.height = allocation.height - + (2 * (border_width + vertical_padding)) - border.top - border.bottom; get_arrows_border (menu, &arrow_border); attributes.y += arrow_border.top; attributes.height -= arrow_border.top; attributes.height -= arrow_border.bottom; + attributes.width = MAX (1, attributes.width); + attributes.height = MAX (1, attributes.height); + menu->view_window = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_user_data (menu->view_window, menu); @@ -2452,8 +2460,13 @@ gtk_menu_realize (GtkWidget *widget) attributes.x = 0; attributes.y = 0; - attributes.width = MAX (1, allocation.width - (border_width + thickness + horizontal_padding) * 2); - attributes.height = MAX (1, priv->requested_height - (border_width + thickness + vertical_padding) * 2); + attributes.width = allocation.width + (2 * (border_width + horizontal_padding)) + + border.left + border.right; + attributes.height = priv->requested_height - (2 * (border_width + vertical_padding)) + + border.top + border.bottom; + + attributes.width = MAX (1, attributes.width); + attributes.height = MAX (1, attributes.height); menu->bin_window = gdk_window_new (menu->view_window, &attributes, attributes_mask); @@ -2641,11 +2654,12 @@ gtk_menu_size_allocate (GtkWidget *widget, GtkAllocation child_allocation; GtkMenuPrivate *priv; GList *children; - gint x, y, i, thickness; + gint x, y, i; gint width, height; guint border_width; guint vertical_padding; guint horizontal_padding; + GtkBorder border; g_return_if_fail (GTK_IS_MENU (widget)); g_return_if_fail (allocation != NULL); @@ -2661,7 +2675,7 @@ gtk_menu_size_allocate (GtkWidget *widget, "horizontal-padding", &horizontal_padding, NULL); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &border); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); g_free (priv->heights); @@ -2672,15 +2686,17 @@ gtk_menu_size_allocate (GtkWidget *widget, NULL); /* refresh our cached height request */ - priv->requested_height = (border_width + vertical_padding + thickness) * 2; + priv->requested_height = (2 * (border_width + vertical_padding)) + + border.top + border.bottom; for (i = 0; i < priv->heights_length; i++) priv->requested_height += priv->heights[i]; - x = border_width + thickness + horizontal_padding; - y = border_width + thickness + vertical_padding; - - width = MAX (1, allocation->width - x * 2); - height = MAX (1, allocation->height - y * 2); + x = border_width + border.left + horizontal_padding; + y = border_width + border.top + vertical_padding; + width = allocation->width - (2 * (border_width + horizontal_padding)) - + border.left - border.right; + height = allocation->height - (2 * (border_width + vertical_padding)) - + border.top - border.bottom; if (menu_shell->active) gtk_menu_scroll_to (menu, menu->scroll_offset); @@ -2695,6 +2711,9 @@ gtk_menu_size_allocate (GtkWidget *widget, height -= arrow_border.bottom; } + width = MAX (1, width); + height = MAX (1, height); + if (gtk_widget_get_realized (widget)) { gdk_window_move_resize (gtk_widget_get_window (widget), @@ -2820,7 +2839,7 @@ get_arrows_visible_area (GtkMenu *menu, guint vertical_padding; guint horizontal_padding; gint scroll_arrow_height; - gint thickness; + GtkBorder menu_border; gtk_widget_style_get (widget, "vertical-padding", &vertical_padding, @@ -2829,10 +2848,10 @@ get_arrows_visible_area (GtkMenu *menu, "arrow-placement", &arrow_placement, NULL); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &menu_border); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - border->x = border_width + thickness + horizontal_padding; - border->y = border_width + thickness + vertical_padding; + border->x = border_width + menu_border.left + horizontal_padding; + border->y = border_width + menu_border.top + vertical_padding; border->width = gdk_window_get_width (gtk_widget_get_window (widget)); border->height = gdk_window_get_height (gtk_widget_get_window (widget)); @@ -2880,7 +2899,7 @@ get_arrows_visible_area (GtkMenu *menu, lower->x = lower->y = lower->width = lower->height = 0; } - *arrow_space = scroll_arrow_height - 2 * thickness; + *arrow_space = scroll_arrow_height - menu_border.top - menu_border.bottom; } static gboolean @@ -2894,8 +2913,9 @@ gtk_menu_draw (GtkWidget *widget, GdkRectangle upper; GdkRectangle lower; GdkWindow *window; - gint arrow_space, thickness; + gint arrow_space; GtkStateFlags state; + GtkBorder menu_border; menu = GTK_MENU (widget); priv = gtk_menu_get_private (menu); @@ -2904,9 +2924,7 @@ gtk_menu_draw (GtkWidget *widget, state = gtk_widget_get_state_flags (widget); get_arrows_visible_area (menu, &border, &upper, &lower, &arrow_space); - gtk_style_context_get (context, state, - "border-width", &thickness, - NULL); + get_menu_border (widget, &menu_border); if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) { @@ -2940,7 +2958,7 @@ gtk_menu_draw (GtkWidget *widget, gtk_render_arrow (context, cr, 0, upper.x + (upper.width - arrow_size) / 2, - upper.y + thickness + (arrow_space - arrow_size) / 2, + upper.y + menu_border.top + (arrow_space - arrow_size) / 2, arrow_size); gtk_style_context_restore (context); @@ -2960,7 +2978,7 @@ gtk_menu_draw (GtkWidget *widget, gtk_render_arrow (context, cr, G_PI, lower.x + (lower.width - arrow_size) / 2, - lower.y + thickness + (arrow_space - arrow_size) / 2, + lower.y + menu_border.top + (arrow_space - arrow_size) / 2, arrow_size); gtk_style_context_restore (context); @@ -3023,9 +3041,10 @@ gtk_menu_get_preferred_width (GtkWidget *widget, guint max_toggle_size; guint max_accel_width; guint horizontal_padding; - guint border_width, thickness; + guint border_width; gint child_min, child_nat; gint min_width, nat_width; + GtkBorder border; menu = GTK_MENU (widget); menu_shell = GTK_MENU_SHELL (widget); @@ -3118,11 +3137,13 @@ gtk_menu_get_preferred_width (GtkWidget *widget, "horizontal-padding", &horizontal_padding, NULL); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &border); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); - min_width += (border_width + horizontal_padding + thickness) * 2; - nat_width += (border_width + horizontal_padding + thickness) * 2; - + min_width += (2 * (border_width + horizontal_padding)) + + border.left + border.right; + nat_width += (2 * (border_width + horizontal_padding)) + + border.top + border.bottom; + menu->toggle_size = max_toggle_size; priv->accel_size = max_accel_width; @@ -4565,10 +4586,10 @@ gtk_menu_position (GtkMenu *menu, gint space_left, space_right, space_above, space_below; gint needed_width; gint needed_height; - gint thickness; + GtkBorder border; gboolean rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &border); /* The placement of popup menus horizontally works like this (with * RTL in parentheses) @@ -4600,7 +4621,7 @@ gtk_menu_position (GtkMenu *menu, /* the amount of space we need to position the menu. Note the * menu is offset "thickness" pixels */ - needed_width = requisition.width - thickness; + needed_width = requisition.width - border.left; if (needed_width <= space_left || needed_width <= space_right) @@ -4609,12 +4630,12 @@ gtk_menu_position (GtkMenu *menu, (!rtl && needed_width > space_right)) { /* position left */ - x = x + thickness - requisition.width + 1; + x = x + border.left - requisition.width + 1; } else { /* position right */ - x = x - thickness; + x = x - border.right; } /* x is clamped on-screen further down */ @@ -4653,15 +4674,15 @@ gtk_menu_position (GtkMenu *menu, /* Position vertically. The algorithm is the same as above, but * simpler because we don't have to take RTL into account. */ - needed_height = requisition.height - thickness; + needed_height = requisition.height - border.top; if (needed_height <= space_above || needed_height <= space_below) { if (needed_height <= space_below) - y = y - thickness; + y = y - border.top; else - y = y + thickness - requisition.height + 1; + y = y + border.bottom - requisition.height + 1; y = CLAMP (y, monitor.y, monitor.y + monitor.height - requisition.height); @@ -4773,11 +4794,11 @@ gtk_menu_scroll_to (GtkMenu *menu, { GtkMenuPrivate *priv; GtkAllocation allocation; - GtkBorder arrow_border; + GtkBorder arrow_border, border; GtkWidget *widget; gint x, y; gint view_width, view_height; - gint border_width, thickness; + gint border_width; gint menu_height; guint vertical_padding; guint horizontal_padding; @@ -4806,17 +4827,18 @@ gtk_menu_scroll_to (GtkMenu *menu, "horizontal-padding", &horizontal_padding, NULL); - thickness = get_menu_border_thickness (widget); + get_menu_border (widget, &border); double_arrows = get_double_arrows (menu); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu)); - view_width -= (border_width + thickness + horizontal_padding) * 2; - view_height -= (border_width + thickness + vertical_padding) * 2; - menu_height = priv->requested_height - (border_width + thickness + vertical_padding) * 2; + view_width -= (2 * (border_width + horizontal_padding)) + border.left + border.right; + view_height -= (2 * (border_width + vertical_padding)) + border.top + border.bottom; + menu_height = priv->requested_height - (2 * (border_width + vertical_padding)) - + border.top - border.bottom; - x = border_width + thickness + horizontal_padding; - y = border_width + thickness + vertical_padding; + x = border_width + border.left + horizontal_padding; + y = border_width + border.top + vertical_padding; if (double_arrows && !menu->tearoff_active) { diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 2add10a5c8..bb482844d7 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -351,16 +351,17 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { GtkStyleContext *context; - gint border_width; + GtkBorder *border; context = gtk_widget_get_style_context (widget); gtk_style_context_get (context, 0, - "border-width", &border_width, + "border-width", &border, NULL); - requisition->width += border_width * 2; - requisition->height += border_width * 2; + requisition->width += border->left + border->right; + requisition->height += border->top + border->bottom; + gtk_border_free (border); } } } @@ -436,15 +437,17 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { GtkStyleContext *context; - gint border_width; + GtkBorder *border; context = gtk_widget_get_style_context (widget); gtk_style_context_get (context, 0, - "border-width", &border_width, + "border-width", &border, NULL); - child_allocation.x += border_width; - child_allocation.y += border_width; + child_allocation.x += border->left; + child_allocation.y += border->top; + + gtk_border_free (border); } if (priv->pack_direction == GTK_PACK_DIRECTION_LTR || diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 49c05d9447..9763716c89 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -130,10 +130,10 @@ gtk_style_properties_class_init (GtkStylePropertiesClass *klass) "Padding", GTK_TYPE_BORDER, 0)); gtk_style_properties_register_property (NULL, - g_param_spec_int ("border-width", - "Border width", - "Border width, in pixels", - 0, G_MAXINT, 0, 0)); + g_param_spec_boxed ("border-width", + "Border width", + "Border width, in pixels", + GTK_TYPE_BORDER, 0)); gtk_style_properties_register_property (NULL, g_param_spec_int ("border-radius", "Border radius", diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 3f2324bcfd..f3d8ab133d 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -876,6 +876,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, GtkStateFlags flags; gint exterior_size, interior_size, thickness, pad; GtkBorderStyle border_style; + GtkBorder *border; gint border_width; flags = gtk_theming_engine_get_state (engine); @@ -886,9 +887,11 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, "background-color", &bg_color, "border-color", &border_color, "border-style", &border_style, - "border-width", &border_width, + "border-width", &border, NULL); + border_width = MIN (MIN (border->top, border->bottom), + MIN (border->left, border->right)); exterior_size = MIN (width, height); if (exterior_size % 2 == 0) /* Ensure odd */ @@ -985,6 +988,7 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine, gdk_rgba_free (fg_color); gdk_rgba_free (bg_color); gdk_rgba_free (border_color); + gtk_border_free (border); } static void @@ -999,6 +1003,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, GdkRGBA *fg_color, *bg_color, *border_color; gint exterior_size, interior_size, pad, thickness, border_width; GtkBorderStyle border_style; + GtkBorder *border; gdouble radius; flags = gtk_theming_engine_get_state (engine); @@ -1011,10 +1016,12 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, "background-color", &bg_color, "border-color", &border_color, "border-style", &border_style, - "border-width", &border_width, + "border-width", &border, NULL); exterior_size = MIN (width, height); + border_width = MIN (MIN (border->top, border->bottom), + MIN (border->left, border->right)); if (exterior_size % 2 == 0) /* Ensure odd */ exterior_size -= 1; @@ -1093,6 +1100,7 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, gdk_rgba_free (fg_color); gdk_rgba_free (bg_color); gdk_rgba_free (border_color); + gtk_border_free (border); } static void @@ -1298,6 +1306,7 @@ render_background_internal (GtkThemingEngine *engine, gboolean running; gdouble progress, alpha = 1; gint radius, border_width; + GtkBorder *border; flags = gtk_theming_engine_get_state (engine); cairo_save (cr); @@ -1305,11 +1314,13 @@ render_background_internal (GtkThemingEngine *engine, gtk_theming_engine_get (engine, flags, "background-image", &pattern, "background-color", &bg_color, - "border-width", &border_width, + "border-width", &border, "border-radius", &radius, NULL); running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); + border_width = MIN (MIN (border->top, border->bottom), + MIN (border->left, border->right)); _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, @@ -1527,6 +1538,7 @@ render_background_internal (GtkThemingEngine *engine, cairo_restore (cr); gdk_rgba_free (bg_color); + gtk_border_free (border); } static void @@ -1543,7 +1555,8 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gboolean running; gdouble progress, alpha = 1; GtkJunctionSides junction; - gint radius, border_width; + GtkBorder *border; + gint radius; junction = gtk_theming_engine_get_junction_sides (engine); @@ -1557,20 +1570,19 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, } gtk_theming_engine_get (engine, flags, - "border-width", &border_width, + "border-width", &border, NULL); - if (border_width > 0) - { - x += border_width; - y += border_width; - width -= 2 * border_width; - height -= 2 * border_width; - } + x += border->left; + y += border->top; + width -= border->left + border->right; + height -= border->top + border->bottom; render_background_internal (engine, cr, x, y, width, height, junction); + + gtk_border_free (border); } /* Renders the small triangle on corners so @@ -1612,16 +1624,19 @@ render_frame_internal (GtkThemingEngine *engine, gint border_width, radius; gdouble progress, d1, d2, m; gboolean running; + GtkBorder *border; state = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, state, "border-color", &border_color, "border-style", &border_style, - "border-width", &border_width, + "border-width", &border, "border-radius", &radius, NULL); running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); + border_width = MIN (MIN (border->top, border->bottom), + MIN (border->left, border->right)); if (running) { @@ -1770,6 +1785,8 @@ render_frame_internal (GtkThemingEngine *engine, if (border_color) gdk_rgba_free (border_color); + + gtk_border_free (border); } static void @@ -2202,14 +2219,18 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, GtkStateFlags state; gint border_width, radius; gdouble x0, y0, x1, y1, xc, yc, wc, hc; + GtkBorder *border; state = gtk_theming_engine_get_state (engine); junction = gtk_theming_engine_get_junction_sides (engine); gtk_theming_engine_get (engine, state, - "border-width", &border_width, + "border-width", &border, "border-radius", &radius, NULL); + border_width = MIN (MIN (border->top, border->bottom), + MIN (border->left, border->right)); + cairo_save (cr); switch (gap_side) @@ -2279,6 +2300,8 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, 0, junction); cairo_restore (cr); + + gtk_border_free (border); } static void From 901af8fec86a3d41406f23c51190b6f157a28786 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 01:19:24 +0100 Subject: [PATCH 612/634] Fix compiler warnings. --- gtk/gtkcssprovider.c | 4 ++-- gtk/gtkicontheme.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index afc8340c58..35e94e8faf 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1366,8 +1366,8 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, if (val && (info->state == 0 || info->state == state || - (info->state & state) != 0 && - (info->state & ~(state)) == 0)) + ((info->state & state) != 0 && + (info->state & ~(state)) == 0))) { const gchar *val_str; diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 1b6f1e5986..c4cefe6abd 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -3275,7 +3275,7 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info, GdkPixbuf *pixbuf; GdkRGBA *color = NULL; GdkRGBA rgba; - gchar *css_fg, *css_success; + gchar *css_fg = NULL, *css_success; gchar *css_warning, *css_error; GtkStateFlags state; From 9bdb7e6945a8850f4796c0d59aa1f89e1bde929a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 01:26:03 +0100 Subject: [PATCH 613/634] GtkThemingEngine: Remove unused variables --- gtk/gtkthemingengine.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f3d8ab133d..124ee51d86 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1549,14 +1549,9 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, gdouble width, gdouble height) { - GdkRGBA *bg_color; - cairo_pattern_t *pattern; - GtkStateFlags flags; - gboolean running; - gdouble progress, alpha = 1; GtkJunctionSides junction; + GtkStateFlags flags; GtkBorder *border; - gint radius; junction = gtk_theming_engine_get_junction_sides (engine); @@ -1569,6 +1564,7 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine, height -= 4; } + flags = gtk_theming_engine_get_state (engine); gtk_theming_engine_get (engine, flags, "border-width", &border, NULL); @@ -2221,6 +2217,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine, gdouble x0, y0, x1, y1, xc, yc, wc, hc; GtkBorder *border; + xc = yc = wc = hc = 0; state = gtk_theming_engine_get_state (engine); junction = gtk_theming_engine_get_junction_sides (engine); gtk_theming_engine_get (engine, state, @@ -2314,10 +2311,7 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, GtkPositionType gap_side) { GtkJunctionSides junction = 0; - GtkStateFlags state; guint hidden_side = 0; - GdkRGBA *bg_color; - gint radius; cairo_save (cr); @@ -2371,9 +2365,6 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, hidden_side, junction); cairo_restore (cr); - - if (bg_color) - gdk_rgba_free (bg_color); } static void From 066f35bf2883edcb394f55bbb24fd2a326b99ddc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 02:55:31 +0100 Subject: [PATCH 614/634] Parse user CSS from $XDG_CONFIG_HOME/gtk-3.0/gtk.css --- gtk/gtkcssprovider.c | 2 +- gtk/gtksettings.c | 17 +++++++++-------- gtk/gtkstylecontext.c | 3 ++- gtk/gtkstyleprovider.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 35e94e8faf..f178905132 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -47,7 +47,7 @@ * calling gtk_css_provider_load_from_file() and adding the provider with * gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen(). * In addition, certain files will be read when GTK+ is initialized. First, - * the file HOME/.gtk-3.0.css + * the file XDG_CONFIG_HOME/gtk-3.0/gtk.css * is loaded if it exists. Then, GTK+ tries to load * HOME/.themes/theme-name/gtk-3.0/gtk.css, * falling back to diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 58fd2c1f4d..f57924b65e 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1354,18 +1354,19 @@ settings_init_style (GtkSettings *settings) /* Add provider for user file */ if (G_UNLIKELY (!css_provider)) { - GFile *home_dir, *css_file; + gchar *css_path; css_provider = gtk_css_provider_new (); + css_path = g_build_filename (g_get_user_config_dir (), + "gtk-3.0", + "gtk.css", + NULL); - home_dir = g_file_new_for_path (g_get_home_dir ()); - css_file = g_file_get_child (home_dir, ".gtk-3.0.css"); + if (g_file_test (css_path, + G_FILE_TEST_IS_REGULAR)) + gtk_css_provider_load_from_path (css_provider, css_path, NULL); - if (g_file_query_exists (css_file, NULL)) - gtk_css_provider_load_from_file (css_provider, css_file, NULL); - - g_object_unref (home_dir); - g_object_unref (css_file); + g_free (css_path); } gtk_style_context_add_provider_for_screen (settings->screen, diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c458c244b4..65255402ff 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -390,7 +390,8 @@ * If you are using custom styling on an applications, you probably want then * to make your style information prevail to the theme's, so you must use * a #GtkStyleProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - * priority, keep in mind that the user settings in $HOME/.gtk-3.0.css will + * priority, keep in mind that the user settings in + * XDG_CONFIG_HOME/gtk-3.0/gtk.css will * still take precedence over your changes, as it uses the * %GTK_STYLE_PROVIDER_PRIORITY_USER priority. * diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 1e59989bd1..731c346007 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -72,7 +72,7 @@ G_BEGIN_DECLS * GTK_STYLE_PROVIDER_PRIORITY_USER: * * The priority used for the style information from - * ~/.gtk-3.0.css. + * XDG_CONFIG_HOME/gtk-3.0/gtk.css * * You should not use priorities higher than this, to * give the user the last word. From afeac82fbdcd169ed06990b3959ca8508551f121 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 19:19:26 +0100 Subject: [PATCH 615/634] GtkThemingEngine: Add gtk_theming_engine_lookup_color() It could also be handy for theme engines... --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtkthemingengine.c | 25 +++++++++++++++++++++++++ gtk/gtkthemingengine.h | 3 +++ 3 files changed, 29 insertions(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 00fa6d3764..8ab7fd76bf 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5507,6 +5507,7 @@ gtk_theming_engine_get_style_valist gtk_theming_engine_get_valist gtk_theming_engine_has_class gtk_theming_engine_has_region +gtk_theming_engine_lookup_color gtk_theming_engine_state_is_running gtk_theming_engine_load gtk_theming_engine_register_property diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 124ee51d86..e5d9e577b3 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -542,6 +542,31 @@ gtk_theming_engine_get_style (GtkThemingEngine *engine, va_end (args); } +/** + * gtk_theming_engine_lookup_color: + * @engine: a #GtkThemingEngine + * @color_name: color name to lookup + * @color: (out) (transfer full): Return location for the looked up color + * + * Looks up and resolves a color name in the current style's color map. + * The returned color must be freed with gdk_rgba_free(). + * + * Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise + **/ +gboolean +gtk_theming_engine_lookup_color (GtkThemingEngine *engine, + const gchar *color_name, + GdkRGBA **color) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE); + g_return_val_if_fail (color_name != NULL, FALSE); + + priv = engine->priv; + return gtk_style_context_lookup_color (priv->context, color_name, color); +} + /** * gtk_theming_engine_get_state: * @engine: a #GtkThemingEngine diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index ee443d67d1..8dc862e296 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -194,6 +194,9 @@ void gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, void gtk_theming_engine_get_style (GtkThemingEngine *engine, ...); +gboolean gtk_theming_engine_lookup_color (GtkThemingEngine *engine, + const gchar *color_name, + GdkRGBA **color); G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); From 0d2d60cf8a93b0599220fb44355d2965c3698852 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Dec 2010 20:25:52 +0100 Subject: [PATCH 616/634] Gtk9Slice: Fix stretch rendering. "Nearest" filter used when scaling the image, so image borders aren't blurred. --- gtk/gtk9slice.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c index 62008998e1..c3e824b4d5 100644 --- a/gtk/gtk9slice.c +++ b/gtk/gtk9slice.c @@ -192,6 +192,7 @@ render_border (cairo_t *cr, gdouble height, GtkSliceSideModifier modifier) { + cairo_pattern_t *pattern; cairo_matrix_t matrix; cairo_save (cr); @@ -199,47 +200,47 @@ render_border (cairo_t *cr, cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); + pattern = cairo_pattern_create_for_surface (surface); + if (modifier == GTK_SLICE_REPEAT) { - cairo_pattern_t *pattern; - - pattern = cairo_pattern_create_for_surface (surface); - cairo_matrix_init_translate (&matrix, - x, - y); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_pattern_set_matrix (pattern, &matrix); cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); } else { - gint d; + /* Use nearest filter so borders aren't blurred */ + cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST); if (side == SIDE_TOP || side == SIDE_BOTTOM) { - d = cairo_image_surface_get_width (surface); + gint w = cairo_image_surface_get_width (surface); cairo_translate (cr, x, y); - cairo_scale (cr, width / d, 1.0); - cairo_set_source_surface (cr, surface, 0.0, 0.0); - cairo_paint (cr); + cairo_scale (cr, width / w, 1.0); } else { - d = cairo_image_surface_get_height (surface); + gint h = cairo_image_surface_get_height (surface); cairo_translate (cr, x, y); - cairo_scale (cr, 1.0, height / d); - cairo_set_source_surface (cr, surface, 0.0, 0.0); - cairo_paint (cr); + cairo_scale (cr, 1.0, height / h); } + + cairo_set_source (cr, pattern); + cairo_rectangle (cr, x, y, width, height); + cairo_paint (cr); } cairo_restore (cr); + + cairo_pattern_destroy (pattern); } static void From b0c87faa50f792b4297dd92c29686eca7f26346f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2010 20:28:09 +0100 Subject: [PATCH 617/634] Add GtkModifierStyle as a private object This object backs up gtk_widget_override_* operations. This object is not meant to be public because any intention to modify widgets' style in a themeable way should involve using regions/classes, so they're modifiable through CSS. As such, the API is really short-scoped. --- gtk/Makefile.am | 2 + gtk/gtkmodifierstyle.c | 287 +++++++++++++++++++++++++++++++++++++++++ gtk/gtkmodifierstyle.h | 74 +++++++++++ gtk/gtkwidget.c | 131 +++++++------------ 4 files changed, 412 insertions(+), 82 deletions(-) create mode 100644 gtk/gtkmodifierstyle.c create mode 100644 gtk/gtkmodifierstyle.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index e69d29337c..d95f3de7d6 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -397,6 +397,7 @@ gtk_private_h_sources = \ gtkkeyhash.h \ gtkmenuprivate.h \ gtkmnemonichash.h \ + gtkmodifierstyle.h \ gtkmountoperationprivate.h \ gtkappchooserprivate.h \ gtkappchoosermodule.h \ @@ -552,6 +553,7 @@ gtk_base_c_sources = \ gtkmessagedialog.c \ gtkmisc.c \ gtkmnemonichash.c \ + gtkmodifierstyle.c \ gtkmodules.c \ gtkmountoperation.c \ gtknotebook.c \ diff --git a/gtk/gtkmodifierstyle.c b/gtk/gtkmodifierstyle.c new file mode 100644 index 0000000000..a8f4d3d729 --- /dev/null +++ b/gtk/gtkmodifierstyle.c @@ -0,0 +1,287 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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 "gtkmodifierstyle.h" +#include "gtkintl.h" + +typedef struct GtkModifierStylePrivate GtkModifierStylePrivate; +typedef struct StylePropertyValue StylePropertyValue; + +struct GtkModifierStylePrivate +{ + GtkStyleProperties *style; + GHashTable *color_properties; +}; + +enum { + CHANGED, + LAST_SIGNAL +}; + +static guint signals [LAST_SIGNAL] = { 0 }; + +static void gtk_modifier_style_provider_init (GtkStyleProviderIface *iface); +static void gtk_modifier_style_finalize (GObject *object); + +G_DEFINE_TYPE_EXTENDED (GtkModifierStyle, gtk_modifier_style, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, + gtk_modifier_style_provider_init)); + +static void +gtk_modifier_style_class_init (GtkModifierStyleClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gtk_modifier_style_finalize; + + signals[CHANGED] = + g_signal_new (I_("changed"), + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_type_class_add_private (object_class, sizeof (GtkModifierStylePrivate)); +} + +static void +gtk_modifier_style_init (GtkModifierStyle *modifier_style) +{ + GtkModifierStylePrivate *priv; + + priv = modifier_style->priv = G_TYPE_INSTANCE_GET_PRIVATE (modifier_style, + GTK_TYPE_MODIFIER_STYLE, + GtkModifierStylePrivate); + + priv->color_properties = g_hash_table_new_full (g_str_hash, + g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gdk_rgba_free); + priv->style = gtk_style_properties_new (); +} + +static GtkStyleProperties * +gtk_modifier_style_get_style (GtkStyleProvider *provider, + GtkWidgetPath *path) +{ + GtkModifierStylePrivate *priv; + + priv = GTK_MODIFIER_STYLE (provider)->priv; + return g_object_ref (priv->style); +} + +static gboolean +gtk_modifier_style_get_style_property (GtkStyleProvider *provider, + GtkWidgetPath *path, + GtkStateFlags state, + GParamSpec *pspec, + GValue *value) +{ + GtkModifierStylePrivate *priv; + GdkColor *color; + gchar *str; + + /* Reject non-color types for now */ + if (pspec->value_type != GDK_TYPE_COLOR) + return FALSE; + + priv = GTK_MODIFIER_STYLE (provider)->priv; + str = g_strdup_printf ("-%s-%s", + g_type_name (pspec->owner_type), + pspec->name); + + color = g_hash_table_lookup (priv->color_properties, str); + g_free (str); + + if (!color) + return FALSE; + + g_value_set_boxed (value, color); + return TRUE; +} + +static void +gtk_modifier_style_provider_init (GtkStyleProviderIface *iface) +{ + iface->get_style = gtk_modifier_style_get_style; + iface->get_style_property = gtk_modifier_style_get_style_property; +} + +static void +gtk_modifier_style_finalize (GObject *object) +{ + GtkModifierStylePrivate *priv; + + priv = GTK_MODIFIER_STYLE (object)->priv; + g_hash_table_destroy (priv->color_properties); + g_object_unref (priv->style); + + G_OBJECT_CLASS (gtk_modifier_style_parent_class)->finalize (object); +} + +GtkModifierStyle * +gtk_modifier_style_new (void) +{ + return g_object_new (GTK_TYPE_MODIFIER_STYLE, NULL); +} + +static void +modifier_style_set_color (GtkModifierStyle *style, + const gchar *prop, + GtkStateFlags state, + const GdkRGBA *color) +{ + GtkModifierStylePrivate *priv; + GdkRGBA *old_color; + + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + + priv = style->priv; + gtk_style_properties_get (priv->style, state, + prop, &old_color, + NULL); + + if ((!color && !old_color) || + (color && old_color && gdk_rgba_equal (color, old_color))) + { + gdk_rgba_free (old_color); + return; + } + + if (color) + gtk_style_properties_set (priv->style, state, + prop, color, + NULL); + else + gtk_style_properties_unset_property (priv->style, prop, state); + + g_signal_emit (style, signals[CHANGED], 0); + gdk_rgba_free (old_color); +} + +void +gtk_modifier_style_set_background_color (GtkModifierStyle *style, + GtkStateFlags state, + const GdkRGBA *color) +{ + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + + modifier_style_set_color (style, "background-color", state, color); +} + +void +gtk_modifier_style_set_color (GtkModifierStyle *style, + GtkStateFlags state, + const GdkRGBA *color) +{ + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + + modifier_style_set_color (style, "color", state, color); +} + +void +gtk_modifier_style_set_font (GtkModifierStyle *style, + const PangoFontDescription *font_desc) +{ + GtkModifierStylePrivate *priv; + PangoFontDescription *old_font; + + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + + priv = style->priv; + gtk_style_properties_get (priv->style, 0, + "font", &old_font, + NULL); + + if ((!old_font && !font_desc) || + (old_font && font_desc && + pango_font_description_equal (old_font, font_desc))) + return; + + if (font_desc) + gtk_style_properties_set (priv->style, 0, + "font", font_desc, + NULL); + else + gtk_style_properties_unset_property (priv->style, "font", 0); + + g_signal_emit (style, signals[CHANGED], 0); +} + +void +gtk_modifier_style_map_color (GtkModifierStyle *style, + const gchar *name, + const GdkRGBA *color) +{ + GtkModifierStylePrivate *priv; + GtkSymbolicColor *symbolic_color = NULL; + + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + g_return_if_fail (name != NULL); + + priv = style->priv; + + if (color) + symbolic_color = gtk_symbolic_color_new_literal (color); + + gtk_style_properties_map_color (priv->style, + name, symbolic_color); + + g_signal_emit (style, signals[CHANGED], 0); +} + +void +gtk_modifier_style_set_color_property (GtkModifierStyle *style, + GType widget_type, + const gchar *prop_name, + const GdkColor *color) +{ + GtkModifierStylePrivate *priv; + const GdkColor *old_color; + gchar *str; + + g_return_if_fail (GTK_IS_MODIFIER_STYLE (style)); + g_return_if_fail (g_type_is_a (widget_type, GTK_TYPE_WIDGET)); + g_return_if_fail (prop_name != NULL); + + priv = style->priv; + str = g_strdup_printf ("-%s-%s", g_type_name (widget_type), prop_name); + + old_color = g_hash_table_lookup (priv->color_properties, str); + + if ((!color && !old_color) || + (color && old_color && gdk_color_equal (color, old_color))) + { + g_free (str); + return; + } + + if (color) + g_hash_table_insert (priv->color_properties, str, + gdk_color_copy (color)); + else + g_hash_table_remove (priv->color_properties, str); + + g_signal_emit (style, signals[CHANGED], 0); + g_free (str); +} diff --git a/gtk/gtkmodifierstyle.h b/gtk/gtkmodifierstyle.h new file mode 100644 index 0000000000..6275b7c657 --- /dev/null +++ b/gtk/gtkmodifierstyle.h @@ -0,0 +1,74 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Carlos Garnacho + * + * 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_MODIFIER_STYLE_H__ +#define __GTK_MODIFIER_STYLE_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GTK_TYPE_MODIFIER_STYLE (gtk_modifier_style_get_type ()) +#define GTK_MODIFIER_STYLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_MODIFIER_STYLE, GtkModifierStyle)) +#define GTK_MODIFIER_STYLE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_MODIFIER_STYLE, GtkModifierStyleClass)) +#define GTK_IS_MODIFIER_STYLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_MODIFIER_STYLE)) +#define GTK_IS_MODIFIER_STYLE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_MODIFIER_STYLE)) +#define GTK_MODIFIER_STYLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_MODIFIER_STYLE, GtkModifierStyleClass)) + +typedef struct _GtkModifierStyle GtkModifierStyle; +typedef struct _GtkModifierStyleClass GtkModifierStyleClass; + +struct _GtkModifierStyle +{ + GObject parent_object; + gpointer priv; +}; + +struct _GtkModifierStyleClass +{ + GObjectClass parent_class; +}; + +GType gtk_modifier_style_get_type (void) G_GNUC_CONST; + +GtkModifierStyle * gtk_modifier_style_new (void); + +void gtk_modifier_style_set_background_color (GtkModifierStyle *style, + GtkStateFlags state, + const GdkRGBA *color); +void gtk_modifier_style_set_color (GtkModifierStyle *style, + GtkStateFlags state, + const GdkRGBA *color); +void gtk_modifier_style_set_font (GtkModifierStyle *style, + const PangoFontDescription *font_desc); + +void gtk_modifier_style_map_color (GtkModifierStyle *style, + const gchar *name, + const GdkRGBA *color); + +void gtk_modifier_style_set_color_property (GtkModifierStyle *style, + GType widget_type, + const gchar *prop_name, + const GdkColor *color); + +G_END_DECLS + +#endif /* __GTK_MODIFIER_STYLE_H__ */ diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7c748c4ceb..1139770048 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -62,6 +62,7 @@ #include "gtksymboliccolor.h" #include "gtkcssprovider.h" #include "gtkanimationdescription.h" +#include "gtkmodifierstyle.h" #include "gtkversion.h" #include "gtkdebug.h" @@ -7925,31 +7926,44 @@ gtk_widget_modify_color_component (GtkWidget *widget, gtk_widget_modify_style (widget, rc_style); } -static GtkStyleProperties * +static void +modifier_style_changed (GtkModifierStyle *style, + GtkWidget *widget) +{ + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_invalidate (context); +} + +static GtkModifierStyle * _gtk_widget_get_modifier_properties (GtkWidget *widget) { - GtkStyleProperties *properties; + GtkModifierStyle *style; - properties = g_object_get_qdata (G_OBJECT (widget), quark_modifier_style); + style = g_object_get_qdata (G_OBJECT (widget), quark_modifier_style); - if (G_UNLIKELY (!properties)) + if (G_UNLIKELY (!style)) { GtkStyleContext *context; - properties = gtk_style_properties_new (); + style = gtk_modifier_style_new (); g_object_set_qdata_full (G_OBJECT (widget), quark_modifier_style, - properties, + style, (GDestroyNotify) g_object_unref); + g_signal_connect (style, "changed", + G_CALLBACK (modifier_style_changed), widget); + context = gtk_widget_get_style_context (widget); gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (properties), + GTK_STYLE_PROVIDER (style), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } - return properties; + return style; } /** @@ -7995,27 +8009,12 @@ gtk_widget_override_color (GtkWidget *widget, GtkStateFlags state, const GdkRGBA *color) { - GtkStyleProperties *properties; - GtkStyleContext *context; + GtkModifierStyle *style; g_return_if_fail (GTK_IS_WIDGET (widget)); - properties = _gtk_widget_get_modifier_properties (widget); - - if (color) - gtk_style_properties_set (properties, state, - "color", color, - NULL); - else - gtk_style_properties_unset_property (properties, "color", state); - - context = gtk_widget_get_style_context (widget); - gtk_style_context_invalidate (context); - - g_signal_emit (widget, - widget_signals[STYLE_SET], - 0, - widget->priv->style); + style = _gtk_widget_get_modifier_properties (widget); + gtk_modifier_style_set_color (style, state, color); } /** @@ -8035,29 +8034,12 @@ gtk_widget_override_background_color (GtkWidget *widget, GtkStateFlags state, const GdkRGBA *color) { - GtkStyleProperties *properties; - GtkStyleContext *context; + GtkModifierStyle *style; g_return_if_fail (GTK_IS_WIDGET (widget)); - properties = _gtk_widget_get_modifier_properties (widget); - - if (color) - gtk_style_properties_set (properties, state, - "background-color", color, - NULL); - else - gtk_style_properties_unset_property (properties, - "background-color", - state); - - context = gtk_widget_get_style_context (widget); - gtk_style_context_invalidate (context); - - g_signal_emit (widget, - widget_signals[STYLE_SET], - 0, - widget->priv->style); + style = _gtk_widget_get_modifier_properties (widget); + gtk_modifier_style_set_background_color (style, state, color); } /** @@ -8076,27 +8058,12 @@ void gtk_widget_override_font (GtkWidget *widget, const PangoFontDescription *font_desc) { - GtkStyleProperties *properties; - GtkStyleContext *context; + GtkModifierStyle *style; g_return_if_fail (GTK_IS_WIDGET (widget)); - properties = _gtk_widget_get_modifier_properties (widget); - - if (font_desc) - gtk_style_properties_set (properties, 0, - "font", font_desc, - NULL); - else - gtk_style_properties_unset_property (properties, "font", 0); - - context = gtk_widget_get_style_context (widget); - gtk_style_context_invalidate (context); - - g_signal_emit (widget, - widget_signals[STYLE_SET], - 0, - widget->priv->style); + style = _gtk_widget_get_modifier_properties (widget); + gtk_modifier_style_set_font (style, font_desc); } /** @@ -8118,27 +8085,12 @@ gtk_widget_override_symbolic_color (GtkWidget *widget, const gchar *name, const GdkRGBA *color) { - GtkStyleProperties *properties; - GtkStyleContext *context; - GtkSymbolicColor *symbolic_color; + GtkModifierStyle *style; g_return_if_fail (GTK_IS_WIDGET (widget)); - properties = _gtk_widget_get_modifier_properties (widget); - symbolic_color = gtk_symbolic_color_new_literal (color); - - gtk_style_properties_map_color (properties, - name, symbolic_color); - - gtk_symbolic_color_unref (symbolic_color); - - context = gtk_widget_get_style_context (widget); - gtk_style_context_invalidate (context); - - g_signal_emit (widget, - widget_signals[STYLE_SET], - 0, - widget->priv->style); + style = _gtk_widget_get_modifier_properties (widget); + gtk_modifier_style_map_color (style, name, color); } /** @@ -8196,6 +8148,11 @@ gtk_widget_modify_fg (GtkWidget *widget, } else gtk_widget_override_color (widget, state, NULL); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); } /** @@ -8261,6 +8218,11 @@ gtk_widget_modify_bg (GtkWidget *widget, } else gtk_widget_override_background_color (widget, state, NULL); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); } /** @@ -8407,6 +8369,11 @@ gtk_widget_modify_font (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); gtk_widget_override_font (widget, font_desc); + + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); } static void From 9aca6c8071e5d00d4d43d2528e79d4eabcab2b9c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2010 22:03:57 +0100 Subject: [PATCH 618/634] GtkWidget: Add gtk_widget_override_cursor(). This function replaces gtk_widget_modify_cursor(). --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtkwidget.c | 50 ++++++++++++++++++++++++---- gtk/gtkwidget.h | 4 +++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 8ab7fd76bf..632b0bc107 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4850,6 +4850,7 @@ gtk_widget_override_background_color gtk_widget_override_color gtk_widget_override_font gtk_widget_override_symbolic_color +gtk_widget_override_cursor gtk_widget_modify_style gtk_widget_get_modifier_style gtk_widget_modify_fg diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 1139770048..1fefb69a73 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8093,6 +8093,42 @@ gtk_widget_override_symbolic_color (GtkWidget *widget, gtk_modifier_style_map_color (style, name, color); } +/** + * gtk_widget_override_cursor: + * @widget: a #GtkWidget + * @primary: the color to use for primary cursor (does not need to be + * allocated), or %NULL to undo the effect of previous calls to + * of gtk_widget_override_cursor(). + * @secondary: the color to use for secondary cursor (does not need to be + * allocated), or %NULL to undo the effect of previous calls to + * of gtk_widget_override_cursor(). + * + * Sets the cursor color to use in a widget, overriding the + * #GtkWidget:cursor-color and #GtkWidget:secondary-cursor-color + * style properties. All other style values are left untouched. + * See also gtk_widget_modify_style(). + * + * Since: 3.0 + **/ +void +gtk_widget_override_cursor (GtkWidget *widget, + const GdkColor *cursor, + const GdkColor *secondary_cursor) +{ + GtkModifierStyle *style; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + style = _gtk_widget_get_modifier_properties (widget); + gtk_modifier_style_set_color_property (style, + GTK_TYPE_WIDGET, + "cursor-color", cursor); + gtk_modifier_style_set_color_property (style, + GTK_TYPE_WIDGET, + "secondary-cursor-color", + secondary_cursor); +} + /** * gtk_widget_modify_fg: * @widget: a #GtkWidget @@ -8333,22 +8369,22 @@ modify_color_property (GtkWidget *widget, * See also gtk_widget_modify_style(). * * Since: 2.12 + * + * Deprecated: 3.0. Use gtk_widget_override_cursor() instead. **/ void gtk_widget_modify_cursor (GtkWidget *widget, const GdkColor *primary, const GdkColor *secondary) { - GtkRcStyle *rc_style; - g_return_if_fail (GTK_IS_WIDGET (widget)); - rc_style = gtk_widget_get_modifier_style (widget); + gtk_widget_override_cursor (widget, primary, secondary); - modify_color_property (widget, rc_style, "cursor-color", primary); - modify_color_property (widget, rc_style, "secondary-cursor-color", secondary); - - gtk_widget_modify_style (widget, rc_style); + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); } /** diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index afc03e9d84..83cdb66270 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -773,6 +773,10 @@ void gtk_widget_override_font (GtkWidget *w void gtk_widget_override_symbolic_color (GtkWidget *widget, const gchar *name, const GdkRGBA *color); +void gtk_widget_override_cursor (GtkWidget *widget, + const GdkColor *cursor, + const GdkColor *secondary_cursor); + void gtk_widget_style_attach (GtkWidget *widget); From 3e8d138ed6310e795c4a9c34cd7e82c232b797ec Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2010 23:37:15 +0100 Subject: [PATCH 619/634] GtkStyleProperties: Refactor color/gradient resolution --- gtk/gtkstyleproperties.c | 92 +++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 9763716c89..99308295be 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -816,12 +816,41 @@ resolve_gradient (GtkStyleProperties *props, return TRUE; } +static gboolean +style_properties_resolve_type (GtkStyleProperties *props, + PropertyNode *node, + GValue *val) +{ + if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) + { + if (node->pspec->value_type == GDK_TYPE_RGBA) + { + if (!resolve_color (props, val)) + return FALSE; + } + else if (node->pspec->value_type == GDK_TYPE_COLOR) + { + if (!resolve_color_rgb (props, val)) + return FALSE; + } + else + return FALSE; + } + else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) + { + g_return_val_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); + + if (!resolve_gradient (props, val)) + return FALSE; + } + + return TRUE; +} + static void lookup_default_value (PropertyNode *node, GValue *value) { - g_value_init (value, node->pspec->value_type); - if (node->pspec->value_type == GTK_TYPE_THEMING_ENGINE) g_value_set_object (value, gtk_theming_engine_load (NULL)); else @@ -873,31 +902,11 @@ gtk_style_properties_get_property (GtkStyleProperties *props, return FALSE; g_value_init (value, node->pspec->value_type); - val = property_data_match_state (prop, state); - if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) - { - if (node->pspec->value_type == GDK_TYPE_RGBA) - { - if (!resolve_color (props, val)) - return FALSE; - } - else if (node->pspec->value_type == GDK_TYPE_COLOR) - { - if (!resolve_color_rgb (props, val)) - return FALSE; - } - else - return FALSE; - } - else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) - { - g_return_val_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE); - - if (!resolve_gradient (props, val)) - return FALSE; - } + if (val && + !style_properties_resolve_type (props, node, val)) + return FALSE; if (val) { @@ -905,13 +914,7 @@ gtk_style_properties_get_property (GtkStyleProperties *props, g_value_copy (val, value); } else - { - GValue default_value = { 0 }; - - lookup_default_value (node, &default_value); - g_value_copy (&default_value, value); - g_value_unset (&default_value); - } + lookup_default_value (node, value); return TRUE; } @@ -960,27 +963,9 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, if (prop) val = property_data_match_state (prop, state); - if (val && G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) - { - gboolean resolved; - - if (node->pspec->value_type == GDK_TYPE_RGBA) - resolved = resolve_color (props, val); - else if (node->pspec->value_type == GDK_TYPE_COLOR) - resolved = resolve_color_rgb (props, val); - else - resolved = FALSE; - - if (!resolved) - val = NULL; - } - else if (val && G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) - { - g_return_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN); - - if (!resolve_gradient (props, val)) - val = NULL; - } + if (val && + !style_properties_resolve_type (props, node, val)) + val = NULL; if (val) { @@ -991,6 +976,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, { GValue default_value = { 0 }; + g_value_init (&default_value, node->pspec->value_type); lookup_default_value (node, &default_value); G_VALUE_LCOPY (&default_value, args, 0, &error); g_value_unset (&default_value); From bacb7906f238c716dac395b923e41897428a263a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2010 23:41:24 +0100 Subject: [PATCH 620/634] Add helper API for getting colors/borders in GtkStyleContext/GtkThemingEngine --- docs/reference/gtk/gtk3-sections.txt | 12 ++ gtk/gtkstylecontext.c | 192 +++++++++++++++++++++++++++ gtk/gtkstylecontext.h | 21 +++ gtk/gtkstyleproperties.c | 37 ++++++ gtk/gtkstyleproperties.h | 5 + gtk/gtkthemingengine.c | 139 +++++++++++++++++++ gtk/gtkthemingengine.h | 22 +++ 7 files changed, 428 insertions(+) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 632b0bc107..bbf8178b16 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5402,6 +5402,12 @@ gtk_style_context_get_style gtk_style_context_get_style_property gtk_style_context_get_style_valist gtk_style_context_get_valist +gtk_style_context_get_color +gtk_style_context_get_background_color +gtk_style_context_get_border_color +gtk_style_context_get_border +gtk_style_context_get_padding +gtk_style_context_get_margin gtk_style_context_invalidate gtk_style_context_state_is_running gtk_style_context_lookup_color @@ -5506,6 +5512,12 @@ gtk_theming_engine_get_style gtk_theming_engine_get_style_property gtk_theming_engine_get_style_valist gtk_theming_engine_get_valist +gtk_theming_engine_get_color +gtk_theming_engine_get_background_color +gtk_theming_engine_get_border_color +gtk_theming_engine_get_border +gtk_theming_engine_get_padding +gtk_theming_engine_get_margin gtk_theming_engine_has_class gtk_theming_engine_has_region gtk_theming_engine_lookup_color diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 65255402ff..d4f5db3dd8 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -3151,6 +3151,198 @@ gtk_style_context_set_background (GtkStyleContext *context, } } +/** + * gtk_style_context_get_color: + * @context: a #GtkStyleContext + * @state: state to retrieve the color for + * @color: (out): return value for the foreground color + * + * Gets the foreground color for a given state. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GdkRGBA *c; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "color", state); + c = g_value_get_boxed (value); + *color = *c; +} + +/** + * gtk_style_context_get_background_color: + * @context: a #GtkStyleContext + * @state: state to retrieve the color for + * @color: (out): return value for the background color + * + * Gets the background color for a given state. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_background_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GdkRGBA *c; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "background-color", state); + c = g_value_get_boxed (value); + *color = *c; +} + +/** + * gtk_style_context_get_border_color: + * @context: a #GtkStyleContext + * @state: state to retrieve the color for + * @color: (out): return value for the border color + * + * Gets the border color for a given state. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_border_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GdkRGBA *c; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "border-color", state); + c = g_value_get_boxed (value); + *color = *c; +} + +/** + * gtk_style_context_get_border: + * @context: a #GtkStyleContext + * @state: state to retrieve the border for + * @color: (out): return value for the border settings + * + * Gets the border for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_border (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *border) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GtkBorder *b; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "border-width", state); + b = g_value_get_boxed (value); + *border = *b; +} + +/** + * gtk_style_context_get_padding: + * @context: a #GtkStyleContext + * @state: state to retrieve the padding for + * @color: (out): return value for the padding settings + * + * Gets the padding for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_padding (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *padding) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GtkBorder *b; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "padding", state); + b = g_value_get_boxed (value); + *padding = *b; +} + +/** + * gtk_style_context_get_margin: + * @context: a #GtkStyleContext + * @state: state to retrieve the border for + * @color: (out): return value for the margin settings + * + * Gets the margin for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_style_context_get_margin (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *margin) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + GtkBorder *b; + + 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); + value = _gtk_style_properties_peek_property (data->store, + "margin", state); + b = g_value_get_boxed (value); + *margin = *b; +} + /* Paint methods */ /** diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index b2dd734d10..be20bf95f6 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -23,6 +23,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -420,6 +421,26 @@ void gtk_style_context_push_animatable_region (GtkStyleContext *context, gpointer region_id); void gtk_style_context_pop_animatable_region (GtkStyleContext *context); +/* Some helper functions to retrieve most common properties */ +void gtk_style_context_get_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color); +void gtk_style_context_get_background_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color); +void gtk_style_context_get_border_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color); + +void gtk_style_context_get_border (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *border); +void gtk_style_context_get_padding (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *padding); +void gtk_style_context_get_margin (GtkStyleContext *context, + GtkStateFlags state, + GtkBorder *margin); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 99308295be..c6592740fc 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -857,6 +857,43 @@ lookup_default_value (PropertyNode *node, g_param_value_set_default (node->pspec, value); } +const GValue * +_gtk_style_properties_peek_property (GtkStyleProperties *props, + const gchar *prop_name, + GtkStateFlags state) +{ + GtkStylePropertiesPrivate *priv; + PropertyNode *node; + PropertyData *prop; + GValue *val; + + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL); + g_return_val_if_fail (prop_name != NULL, NULL); + + node = property_node_lookup (g_quark_try_string (prop_name)); + + if (!node) + { + g_warning ("Style property \"%s\" is not registered", prop_name); + return NULL; + } + + priv = props->priv; + prop = g_hash_table_lookup (priv->properties, + GINT_TO_POINTER (node->property_quark)); + + if (!prop) + return NULL; + + val = property_data_match_state (prop, state); + + if (val && + !style_properties_resolve_type (props, node, val)) + return NULL; + + return val; +} + /** * gtk_style_properties_get_property: * @props: a #GtkStyleProperties diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h index 8a243b7f4f..4ff783a729 100644 --- a/gtk/gtkstyleproperties.h +++ b/gtk/gtkstyleproperties.h @@ -56,6 +56,11 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar *string, GType gtk_style_properties_get_type (void) G_GNUC_CONST; +/* Semi-private API */ +const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props, + const gchar *prop_name, + GtkStateFlags state); + /* Functions to register style properties */ void gtk_style_properties_register_property (GtkStylePropertyParser parse_func, GParamSpec *pspec); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index e5d9e577b3..7469aefc6e 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -737,6 +737,145 @@ gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine) return gtk_style_context_get_junction_sides (priv->context); } +/** + * gtk_theming_engine_get_color: + * @engine: a #GtkThemingEngine + * @state: state to retrieve the color for + * @color: (out): return value for the foreground color + * + * Gets the foreground color for a given state. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_color (priv->context, state, color); +} + +/** + * gtk_theming_engine_get_background_color: + * @engine: a #GtkThemingEngine + * @state: state to retrieve the color for + * @color: (out): return value for the background color + * + * Gets the background color for a given state. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_background_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_background_color (priv->context, state, color); +} + +/** + * gtk_theming_engine_get_border_color: + * @engine: a #GtkThemingEngine + * @state: state to retrieve the color for + * @color: (out): return value for the border color + * + * Gets the border color for a given state. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_border_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_border_color (priv->context, state, color); +} + +/** + * gtk_theming_engine_get_border: + * @engine: a #GtkthemingEngine + * @state: state to retrieve the border for + * @color: (out): return value for the border settings + * + * Gets the border for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_border (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *border) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_border (priv->context, state, border); +} + +/** + * gtk_theming_engine_get_padding: + * @engine: a #GtkthemingEngine + * @state: state to retrieve the padding for + * @color: (out): return value for the padding settings + * + * Gets the padding for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_padding (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *padding) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_padding (priv->context, state, padding); +} + +/** + * gtk_theming_engine_get_margin: + * @engien: a #GtkThemingEngine + * @state: state to retrieve the border for + * @color: (out): return value for the margin settings + * + * Gets the margin for a given state as a #GtkBorder. + * + * Since: 3.0 + **/ +void +gtk_theming_engine_get_margin (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *margin) +{ + GtkThemingEnginePrivate *priv; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + gtk_style_context_get_margin (priv->context, state, margin); +} + + /* GtkThemingModule */ static gboolean diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 8dc862e296..71cd635f80 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -215,6 +215,28 @@ GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine); GtkJunctionSides gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine); +/* Helper functions */ +void gtk_theming_engine_get_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color); +void gtk_theming_engine_get_background_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color); +void gtk_theming_engine_get_border_color (GtkThemingEngine *engine, + GtkStateFlags state, + GdkRGBA *color); + +void gtk_theming_engine_get_border (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *border); +void gtk_theming_engine_get_padding (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *padding); +void gtk_theming_engine_get_margin (GtkThemingEngine *engine, + GtkStateFlags state, + GtkBorder *margin); + + GtkThemingEngine * gtk_theming_engine_load (const gchar *name); GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine); From 47add6c7c3b7055632359f17f1fc7f3fe10f4e3b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2010 23:45:14 +0100 Subject: [PATCH 621/634] Block direct #including in style headers --- gtk/gtkgradient.h | 4 ++++ gtk/gtkstylecontext.h | 4 ++++ gtk/gtkstyleproperties.h | 4 ++++ gtk/gtkstyleprovider.h | 6 +++++- gtk/gtksymboliccolor.h | 4 ++++ gtk/gtkthemingengine.h | 4 ++++ gtk/gtkwidgetpath.h | 4 ++++ 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gtk/gtkgradient.h b/gtk/gtkgradient.h index 3e6b70fc78..f097c40fd0 100644 --- a/gtk/gtkgradient.h +++ b/gtk/gtkgradient.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_GRADIENT_H__ #define __GTK_GRADIENT_H__ diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index be20bf95f6..132a90baf2 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_STYLE_CONTEXT_H__ #define __GTK_STYLE_CONTEXT_H__ diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h index 4ff783a729..113fe44f93 100644 --- a/gtk/gtkstyleproperties.h +++ b/gtk/gtkstyleproperties.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_STYLE_PROPERTIES_H__ #define __GTK_STYLE_PROPERTIES_H__ diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h index 731c346007..d996bb77fe 100644 --- a/gtk/gtkstyleprovider.h +++ b/gtk/gtkstyleprovider.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_STYLE_PROVIDER_H__ #define __GTK_STYLE_PROVIDER_H__ @@ -72,7 +76,7 @@ G_BEGIN_DECLS * GTK_STYLE_PROVIDER_PRIORITY_USER: * * The priority used for the style information from - * XDG_CONFIG_HOME/gtk-3.0/gtk.css + * ~/.gtk-3.0.css. * * You should not use priorities higher than this, to * give the user the last word. diff --git a/gtk/gtksymboliccolor.h b/gtk/gtksymboliccolor.h index 462f086b09..4f4b8137b4 100644 --- a/gtk/gtksymboliccolor.h +++ b/gtk/gtksymboliccolor.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_SYMBOLIC_COLOR_H__ #define __GTK_SYMBOLIC_COLOR_H__ diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 71cd635f80..128070e068 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_THEMING_ENGINE_H__ #define __GTK_THEMING_ENGINE_H__ diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index f6a7d72b89..801906c68f 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __GTK_WIDGET_PATH_H__ #define __GTK_WIDGET_PATH_H__ From a8c8c23c779106a0c45d55d2efbbba516de101b3 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 14:00:16 +0100 Subject: [PATCH 622/634] GtkSettings: add _gtk_settings_get_screen() private method --- gtk/gtksettings.c | 6 ++++++ gtk/gtksettings.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index f57924b65e..2f517587c8 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -2880,3 +2880,9 @@ get_color_scheme (GtkSettings *settings) return g_string_free (string, FALSE); } + +GdkScreen * +_gtk_settings_get_screen (GtkSettings *settings) +{ + return settings->screen; +} diff --git a/gtk/gtksettings.h b/gtk/gtksettings.h index 36fb9a5db9..6958db0f56 100644 --- a/gtk/gtksettings.h +++ b/gtk/gtksettings.h @@ -133,6 +133,8 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParser parser, GParamSpec *pspec, GValue *dest_value); +GdkScreen *_gtk_settings_get_screen (GtkSettings *settings); + G_END_DECLS From 3b3307b946ed3fb7e3669ed98ec154d4b161bb1d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 14:08:33 +0100 Subject: [PATCH 623/634] Use gtk_style_context_reset_widgets() instead of gtk_rc_reset_styles() --- gtk/gtkiconfactory.c | 2 +- gtk/gtkicontheme.c | 5 +---- gtk/gtksettings.c | 6 +++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index 92fea10119..b70a628728 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -796,7 +796,7 @@ icon_size_settings_changed (GtkSettings *settings, { icon_size_set_all_from_settings (settings); - gtk_rc_reset_styles (settings); + gtk_style_context_reset_widgets (_gtk_settings_get_screen (settings)); } static void diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index c4cefe6abd..2f41849967 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -606,10 +606,7 @@ reset_styles_idle (gpointer user_data) priv = icon_theme->priv; if (priv->screen && priv->is_screen_singleton) - { - GtkSettings *settings = gtk_settings_get_for_screen (priv->screen); - gtk_rc_reset_styles (settings); - } + gtk_style_context_reset_widgets (priv->screen); priv->reset_styles_idle = 0; diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 2f517587c8..f84bc9b283 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1572,18 +1572,18 @@ gtk_settings_notify (GObject *object, * widgets with gtk_widget_style_set(), and also causes more * recomputation than necessary. */ - gtk_rc_reset_styles (GTK_SETTINGS (object)); + gtk_style_context_reset_widgets (settings->screen); break; case PROP_XFT_ANTIALIAS: case PROP_XFT_HINTING: case PROP_XFT_HINTSTYLE: case PROP_XFT_RGBA: settings_update_font_options (settings); - gtk_rc_reset_styles (GTK_SETTINGS (object)); + gtk_style_context_reset_widgets (settings->screen); break; case PROP_FONTCONFIG_TIMESTAMP: if (settings_update_fontconfig (settings)) - gtk_rc_reset_styles (GTK_SETTINGS (object)); + gtk_style_context_reset_widgets (settings->screen); break; case PROP_CURSOR_THEME_NAME: case PROP_CURSOR_THEME_SIZE: From f261d56da32418ee6aa534a3fc08c76bb5a67f11 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 14:09:35 +0100 Subject: [PATCH 624/634] GtkStyleContext: invalidate icon caches when resetting widgets --- gtk/gtkstylecontext.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index d4f5db3dd8..b8d8c992e7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -33,6 +33,7 @@ #include "gtksymboliccolor.h" #include "gtkanimationdescription.h" #include "gtktimeline.h" +#include "gtkiconfactory.h" /** * SECTION:gtkstylecontext @@ -1332,6 +1333,8 @@ gtk_style_context_reset_widgets (GdkScreen *screen) { GList *list, *toplevels; + _gtk_icon_set_invalidate_caches (); + toplevels = gtk_window_list_toplevels (); g_list_foreach (toplevels, (GFunc) g_object_ref, NULL); From 15d997d58a306638df0b81a17d60965623fdb774 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 14:10:32 +0100 Subject: [PATCH 625/634] GtkWidget: queue a resize when style context changed --- gtk/gtkwidget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 1fefb69a73..6b78cc1e80 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6342,6 +6342,7 @@ gtk_widget_real_style_updated (GtkWidget *widget) { if (widget->priv->context) gtk_style_context_invalidate (widget->priv->context); + gtk_widget_queue_resize (widget); } static gboolean From ca59b042df53ba792cb33b430c317b68464fa592 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 20:30:13 +0100 Subject: [PATCH 626/634] GtkStyle: make context property readable --- gtk/gtkstyle.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 3310ebbf82..83645560b5 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -99,6 +99,10 @@ static void gtk_style_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void gtk_style_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void gtk_style_realize (GtkStyle *style, GdkVisual *visual); @@ -472,6 +476,7 @@ gtk_style_class_init (GtkStyleClass *klass) object_class->finalize = gtk_style_finalize; object_class->set_property = gtk_style_set_property; + object_class->get_property = gtk_style_get_property; object_class->constructed = gtk_style_constructed; klass->clone = gtk_style_real_clone; @@ -511,7 +516,7 @@ gtk_style_class_init (GtkStyleClass *klass) P_("Style context"), P_("GtkStyleContext to get style from"), GTK_TYPE_STYLE_CONTEXT, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); /** * GtkStyle::realize: @@ -650,6 +655,27 @@ gtk_style_set_property (GObject *object, } } +static void +gtk_style_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkStylePrivate *priv; + + priv = GTK_STYLE_GET_PRIVATE (object); + + switch (prop_id) + { + case PROP_CONTEXT: + g_value_set_object (value, priv->context); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void set_color (GtkStyle *style, GtkStyleContext *context, From b75972d0cea9243f14ed15c98a2e89552cbe560a Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 20:31:13 +0100 Subject: [PATCH 627/634] GtkStyle: set style context state before calling gtk_render_icon_pixbuf() --- gtk/gtkstyle.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 83645560b5..ff7686a6ab 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -1693,6 +1693,7 @@ gtk_default_render_icon (GtkStyle *style, { GtkStyleContext *context; GtkStylePrivate *priv; + GtkStateFlags flags = 0; GdkPixbuf *pixbuf; if (widget) @@ -1711,6 +1712,20 @@ gtk_default_render_icon (GtkStyle *style, if (detail) transform_detail_string (detail, context); + switch (state) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } + + gtk_style_context_set_state (context, flags); + pixbuf = gtk_render_icon_pixbuf (context, source, size); gtk_style_context_restore (context); From 905ba2f1983877bf45bc541cf3aa9a7c5cb0936d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 20:39:58 +0100 Subject: [PATCH 628/634] GtkIconFactory: add gtk_icon_set_render_icon_pixbuf() and deprecate gtk_icon_set_render_icon(). --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtk.symbols | 1 + gtk/gtkiconfactory.c | 222 +++++++++++++++------------ gtk/gtkiconfactory.h | 1 - gtk/gtkstylecontext.h | 3 + 5 files changed, 132 insertions(+), 96 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index bbf8178b16..d8f17b5422 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -6087,6 +6087,7 @@ gtk_icon_set_new gtk_icon_set_new_from_pixbuf gtk_icon_set_ref gtk_icon_set_render_icon +gtk_icon_set_render_icon_pixbuf gtk_icon_set_unref gtk_icon_size_lookup gtk_icon_size_lookup_for_settings diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index d7dc83e19d..411a2e76d8 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1045,6 +1045,7 @@ gtk_icon_set_new gtk_icon_set_new_from_pixbuf gtk_icon_set_ref gtk_icon_set_render_icon +gtk_icon_set_render_icon_pixbuf gtk_icon_set_unref gtk_icon_size_from_name gtk_icon_size_get_name diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index b70a628728..5b21c62fd6 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -1083,12 +1083,12 @@ gtk_icon_size_get_name (GtkIconSize size) static GdkPixbuf *find_in_cache (GtkIconSet *icon_set, - GtkStyle *style, + GtkStyleContext *style_context, GtkTextDirection direction, GtkStateType state, GtkIconSize size); static void add_to_cache (GtkIconSet *icon_set, - GtkStyle *style, + GtkStyleContext *style_context, GtkTextDirection direction, GtkStateType state, GtkIconSize size, @@ -1102,9 +1102,9 @@ static void clear_cache (GtkIconSet *icon_set, static GSList* copy_cache (GtkIconSet *icon_set, GtkIconSet *copy_recipient); static void attach_to_style (GtkIconSet *icon_set, - GtkStyle *style); + GtkStyleContext *style_context); static void detach_from_style (GtkIconSet *icon_set, - GtkStyle *style); + GtkStyleContext *style_context); static void style_dnotify (gpointer data); struct _GtkIconSet @@ -1369,12 +1369,8 @@ ensure_filename_pixbuf (GtkIconSet *icon_set, static GdkPixbuf * render_icon_name_pixbuf (GtkIconSource *icon_source, - GtkStyle *style, - GtkTextDirection direction, - GtkStateType state, - GtkIconSize size, - GtkWidget *widget, - const char *detail) + GtkStyleContext *context, + GtkIconSize size) { GdkPixbuf *pixbuf; GdkPixbuf *tmp_pixbuf; @@ -1386,17 +1382,7 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, gint *sizes, *s, dist; GError *error = NULL; - if (widget && gtk_widget_has_screen (widget)) - screen = gtk_widget_get_screen (widget); - else if (style && style->visual) - screen = gdk_visual_get_screen (style->visual); - else - { - screen = gdk_screen_get_default (); - GTK_NOTE (MULTIHEAD, - g_warning ("Using the default screen for gtk_icon_source_render_icon()")); - } - + screen = gtk_style_context_get_screen (context); icon_theme = gtk_icon_theme_get_for_screen (screen); settings = gtk_settings_get_for_screen (screen); @@ -1487,9 +1473,7 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, tmp_source.type = GTK_ICON_SOURCE_PIXBUF; tmp_source.source.pixbuf = tmp_pixbuf; - pixbuf = gtk_style_render_icon (style, &tmp_source, - direction, state, -1, - widget, detail); + pixbuf = gtk_render_icon_pixbuf (context, &tmp_source, -1); if (!pixbuf) g_warning ("Failed to render icon"); @@ -1501,12 +1485,10 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, static GdkPixbuf * find_and_render_icon_source (GtkIconSet *icon_set, - GtkStyle *style, + GtkStyleContext *context, GtkTextDirection direction, GtkStateType state, - GtkIconSize size, - GtkWidget *widget, - const char *detail) + GtkIconSize size) { GSList *failed = NULL; GdkPixbuf *pixbuf = NULL; @@ -1535,9 +1517,7 @@ find_and_render_icon_source (GtkIconSet *icon_set, break; /* Fall through */ case GTK_ICON_SOURCE_PIXBUF: - pixbuf = gtk_style_render_icon (style, source, - direction, state, size, - widget, detail); + pixbuf = gtk_render_icon_pixbuf (context, source, size); if (!pixbuf) { g_warning ("Failed to render icon"); @@ -1546,9 +1526,7 @@ find_and_render_icon_source (GtkIconSet *icon_set, break; case GTK_ICON_SOURCE_ICON_NAME: case GTK_ICON_SOURCE_STATIC_ICON_NAME: - pixbuf = render_icon_name_pixbuf (source, style, - direction, state, size, - widget, detail); + pixbuf = render_icon_name_pixbuf (source, context, size); if (!pixbuf) failed = g_slist_prepend (failed, source); break; @@ -1565,12 +1543,10 @@ find_and_render_icon_source (GtkIconSet *icon_set, extern GtkIconCache *_builtin_cache; static GdkPixbuf* -render_fallback_image (GtkStyle *style, +render_fallback_image (GtkStyleContext *context, GtkTextDirection direction, GtkStateType state, - GtkIconSize size, - GtkWidget *widget, - const char *detail) + GtkIconSize size) { /* This icon can be used for any direction/state/size */ static GtkIconSource fallback_source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE); @@ -1590,13 +1566,69 @@ render_fallback_image (GtkStyle *style, g_object_unref (pixbuf); } - return gtk_style_render_icon (style, - &fallback_source, - direction, - state, - size, - widget, - detail); + return gtk_render_icon_pixbuf (context, &fallback_source, size); +} + +/** + * gtk_icon_set_render_icon_pixbuf: + * @icon_set: a #GtkIconSet + * @context: a #GtkStyleContext + * @size: (type int): icon size. A size of (GtkIconSize)-1 + * means render at the size of the source and don't scale. + * + * Renders an icon using gtk_render_icon_pixbuf(). In most cases, + * gtk_widget_render_icon() is better, since it automatically provides + * most of the arguments from the current widget settings. This + * function never returns %NULL; if the icon can't be rendered + * (perhaps because an image file fails to load), a default "missing + * image" icon will be returned instead. + * + * Return value: (transfer full): a #GdkPixbuf to be displayed + * + * Since: 3.0 + */ +GdkPixbuf * +gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set, + GtkStyleContext *context, + GtkIconSize size) +{ + GdkPixbuf *icon = NULL; + GtkStateFlags flags = 0; + GtkStateType state; + GtkTextDirection direction; + + g_return_val_if_fail (icon_set != NULL, NULL); + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + + flags = gtk_style_context_get_state (context); + if (flags & GTK_STATE_FLAG_INSENSITIVE) + state = GTK_STATE_INSENSITIVE; + else if (flags & GTK_STATE_FLAG_PRELIGHT) + state = GTK_STATE_PRELIGHT; + else + state = GTK_STATE_NORMAL; + + direction = gtk_style_context_get_direction (context); + + if (icon_set->sources) + { + icon = find_in_cache (icon_set, context, direction, state, size); + if (icon) + { + g_object_ref (icon); + return icon; + } + } + + if (icon_set->sources) + icon = find_and_render_icon_source (icon_set, context, direction, state, size); + + if (icon == NULL) + icon = render_fallback_image (context, direction, state, size); + + add_to_cache (icon_set, context, direction, state, size, icon); + + return icon; } /** @@ -1622,6 +1654,8 @@ render_fallback_image (GtkStyle *style, * image" icon will be returned instead. * * Return value: (transfer full): a #GdkPixbuf to be displayed + * + * Deprecated: 3.0: Use gtk_icon_set_render_icon_pixbuf() instead */ GdkPixbuf* gtk_icon_set_render_icon (GtkIconSet *icon_set, @@ -1633,34 +1667,47 @@ gtk_icon_set_render_icon (GtkIconSet *icon_set, const char *detail) { GdkPixbuf *icon; + GtkStyleContext *context = NULL; + GtkStateFlags flags = 0; g_return_val_if_fail (icon_set != NULL, NULL); g_return_val_if_fail (style == NULL || GTK_IS_STYLE (style), NULL); - if (icon_set->sources == NULL) - return render_fallback_image (style, direction, state, size, widget, detail); - - if (detail == NULL) + if (style && gtk_style_has_context (style)) { - icon = find_in_cache (icon_set, style, direction, - state, size); - - if (icon) - { - g_object_ref (icon); - return icon; - } + g_object_get (style, "context", &context, NULL); + /* g_object_get returns a refed object */ + if (context) + g_object_unref (context); + } + else if (widget) + { + context = gtk_widget_get_style_context (widget); } + if (!context) + return render_fallback_image (context, direction, state, size); - icon = find_and_render_icon_source (icon_set, style, direction, state, size, - widget, detail); + gtk_style_context_save (context); - if (icon == NULL) - icon = render_fallback_image (style, direction, state, size, widget, detail); + switch (state) + { + case GTK_STATE_PRELIGHT: + flags |= GTK_STATE_FLAG_PRELIGHT; + break; + case GTK_STATE_INSENSITIVE: + flags |= GTK_STATE_FLAG_INSENSITIVE; + break; + default: + break; + } - if (detail == NULL) - add_to_cache (icon_set, style, direction, state, size, icon); + gtk_style_context_set_state (context, flags); + gtk_style_context_set_direction (context, direction); + + icon = gtk_icon_set_render_icon_pixbuf (icon_set, context, size); + + gtk_style_context_restore (context); return icon; } @@ -2376,7 +2423,7 @@ struct _CachedIcon /* These must all match to use the cached pixbuf. * If any don't match, we must re-render the pixbuf. */ - GtkStyle *style; + GtkStyleContext *style; GtkTextDirection direction; GtkStateType state; GtkIconSize size; @@ -2398,16 +2445,14 @@ static void cached_icon_free (CachedIcon *icon) { g_object_unref (icon->pixbuf); - - if (icon->style) - g_object_unref (icon->style); + g_object_unref (icon->style); g_free (icon); } static GdkPixbuf * find_in_cache (GtkIconSet *icon_set, - GtkStyle *style, + GtkStyleContext *style_context, GtkTextDirection direction, GtkStateType state, GtkIconSize size) @@ -2423,7 +2468,7 @@ find_in_cache (GtkIconSet *icon_set, { CachedIcon *icon = tmp_list->data; - if (icon->style == style && + if (icon->style == style_context && icon->direction == direction && icon->state == state && (size == (GtkIconSize)-1 || icon->size == size)) @@ -2448,7 +2493,7 @@ find_in_cache (GtkIconSet *icon_set, static void add_to_cache (GtkIconSet *icon_set, - GtkStyle *style, + GtkStyleContext *style_context, GtkTextDirection direction, GtkStateType state, GtkIconSize size, @@ -2460,26 +2505,16 @@ add_to_cache (GtkIconSet *icon_set, g_object_ref (pixbuf); - /* We have to ref the style, since if the style was finalized - * its address could be reused by another style, creating a - * really weird bug - */ - - if (style) - g_object_ref (style); - icon = g_new (CachedIcon, 1); icon_set->cache = g_slist_prepend (icon_set->cache, icon); icon_set->cache_size++; - icon->style = style; + icon->style = g_object_ref (style_context); icon->direction = direction; icon->state = state; icon->size = size; icon->pixbuf = pixbuf; - - if (icon->style) - attach_to_style (icon_set, icon->style); + attach_to_style (icon_set, icon->style); if (icon_set->cache_size >= NUM_CACHED_ICONS) { @@ -2512,7 +2547,7 @@ clear_cache (GtkIconSet *icon_set, gboolean style_detach) { GSList *cache, *tmp_list; - GtkStyle *last_style = NULL; + GtkStyleContext *last_style = NULL; cache = icon_set->cache; icon_set->cache = NULL; @@ -2561,11 +2596,8 @@ copy_cache (GtkIconSet *icon_set, *icon_copy = *icon; - if (icon_copy->style) - { - attach_to_style (copy_recipient, icon_copy->style); - g_object_ref (icon_copy->style); - } + attach_to_style (copy_recipient, icon_copy->style); + g_object_ref (icon_copy->style); g_object_ref (icon_copy->pixbuf); @@ -2580,18 +2612,18 @@ copy_cache (GtkIconSet *icon_set, } static void -attach_to_style (GtkIconSet *icon_set, - GtkStyle *style) +attach_to_style (GtkIconSet *icon_set, + GtkStyleContext *style_context) { GHashTable *table; - table = g_object_get_qdata (G_OBJECT (style), + table = g_object_get_qdata (G_OBJECT (style_context), g_quark_try_string ("gtk-style-icon-sets")); if (table == NULL) { table = g_hash_table_new (NULL, NULL); - g_object_set_qdata_full (G_OBJECT (style), + g_object_set_qdata_full (G_OBJECT (style_context), g_quark_from_static_string ("gtk-style-icon-sets"), table, style_dnotify); @@ -2601,12 +2633,12 @@ attach_to_style (GtkIconSet *icon_set, } static void -detach_from_style (GtkIconSet *icon_set, - GtkStyle *style) +detach_from_style (GtkIconSet *icon_set, + GtkStyleContext *style_context) { GHashTable *table; - table = g_object_get_qdata (G_OBJECT (style), + table = g_object_get_qdata (G_OBJECT (style_context), g_quark_try_string ("gtk-style-icon-sets")); if (table != NULL) diff --git a/gtk/gtkiconfactory.h b/gtk/gtkiconfactory.h index 1019cf6b41..69ab250b0e 100644 --- a/gtk/gtkiconfactory.h +++ b/gtk/gtkiconfactory.h @@ -132,7 +132,6 @@ GdkPixbuf* gtk_icon_set_render_icon (GtkIconSet *icon_set, GtkWidget *widget, const char *detail); - void gtk_icon_set_add_source (GtkIconSet *icon_set, const GtkIconSource *source); diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 132a90baf2..a67e523a83 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -399,6 +399,9 @@ void gtk_style_context_get_style (GtkStyleContext *context, GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id); +GdkPixbuf * gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set, + GtkStyleContext *context, + GtkIconSize size); void gtk_style_context_set_screen (GtkStyleContext *context, GdkScreen *screen); From 07eeae15825403037b7df139acf9bfa104d5559d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Fri, 3 Dec 2010 21:14:48 +0100 Subject: [PATCH 629/634] GtkWidget: add gtk_widget_render_icon_pixbuf() and deprecate gtk_widget_render_icon() --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtk.symbols | 1 + gtk/gtkwidget.c | 76 ++++++++++++++++++---------- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index d8f17b5422..32759d9b21 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4863,6 +4863,7 @@ gtk_widget_create_pango_context gtk_widget_get_pango_context gtk_widget_create_pango_layout gtk_widget_render_icon +gtk_widget_render_icon_pixbuf gtk_widget_pop_composite_child gtk_widget_push_composite_child gtk_widget_queue_draw_area diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 411a2e76d8..e1d9de295f 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3293,6 +3293,7 @@ gtk_widget_region_intersect gtk_widget_remove_accelerator gtk_widget_remove_mnemonic_label gtk_widget_render_icon +gtk_widget_render_icon_pixbuf gtk_widget_reparent gtk_widget_reset_rc_styles gtk_widget_reset_shapes diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 6b78cc1e80..93d5ee4505 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8900,6 +8900,53 @@ gtk_widget_create_pango_layout (GtkWidget *widget, return layout; } +/** + * gtk_widget_render_icon_pixbuf: + * @widget: a #GtkWidget + * @stock_id: a stock ID + * @size: (type int): a stock size. A size of (GtkIconSize)-1 means + * render at the size of the source and don't scale (if there are + * multiple source sizes, GTK+ picks one of the available sizes). + * + * A convenience function that uses the theme engine and style + * settings for @widget to look up @stock_id and render it to + * a pixbuf. @stock_id should be a stock icon ID such as + * #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size should be a size + * such as #GTK_ICON_SIZE_MENU. + * + * The pixels in the returned #GdkPixbuf are shared with the rest of + * the application and should not be modified. The pixbuf should be freed + * after use with g_object_unref(). + * + * Return value: (transfer full): a new pixbuf, or %NULL if the + * stock ID wasn't known + * + * Since: 3.0 + **/ +GdkPixbuf* +gtk_widget_render_icon_pixbuf (GtkWidget *widget, + const gchar *stock_id, + GtkIconSize size) +{ + GtkWidgetPrivate *priv; + GtkIconSet *icon_set; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + g_return_val_if_fail (stock_id != NULL, NULL); + g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL); + + priv = widget->priv; + + gtk_widget_ensure_style (widget); + + icon_set = gtk_style_context_lookup_icon_set (priv->context, stock_id); + + if (icon_set == NULL) + return NULL; + + return gtk_icon_set_render_icon_pixbuf (icon_set, priv->context, size); +} + /** * gtk_widget_render_icon: * @widget: a #GtkWidget @@ -8923,6 +8970,8 @@ gtk_widget_create_pango_layout (GtkWidget *widget, * * Return value: (transfer full): a new pixbuf, or %NULL if the * stock ID wasn't known + * + * Deprecated: 3.0: Use gtk_widget_render_icon_pixbuf() instead. **/ GdkPixbuf* gtk_widget_render_icon (GtkWidget *widget, @@ -8930,32 +8979,7 @@ gtk_widget_render_icon (GtkWidget *widget, GtkIconSize size, const gchar *detail) { - GtkWidgetPrivate *priv; - GtkIconSet *icon_set; - GdkPixbuf *retval; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - g_return_val_if_fail (stock_id != NULL, NULL); - g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL); - - priv = widget->priv; - - gtk_widget_ensure_style (widget); - - icon_set = gtk_style_lookup_icon_set (priv->style, stock_id); - - if (icon_set == NULL) - return NULL; - - retval = gtk_icon_set_render_icon (icon_set, - priv->style, - gtk_widget_get_direction (widget), - gtk_widget_get_state (widget), - size, - widget, - detail); - - return retval; + return gtk_widget_render_icon_pixbuf (widget, stock_id, size); } /** From 06d8676354f7752ce68fe55b2d5b0b14eea0cfe9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 3 Dec 2010 12:25:12 +0100 Subject: [PATCH 630/634] GtkThemingEngine: Be a bit more robust against missing essential properties. --- gtk/gtkthemingengine.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 7469aefc6e..2b9c4ce8dc 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -2278,12 +2278,16 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine, "color", &other_fg, NULL); - fg_color->red = CLAMP (fg_color->red + ((other_fg->red - fg_color->red) * progress), 0, 1); - fg_color->green = CLAMP (fg_color->green + ((other_fg->green - fg_color->green) * progress), 0, 1); - fg_color->blue = CLAMP (fg_color->blue + ((other_fg->blue - fg_color->blue) * progress), 0, 1); - fg_color->alpha = CLAMP (fg_color->alpha + ((other_fg->alpha - fg_color->alpha) * progress), 0, 1); + if (fg_color && other_fg) + { + fg_color->red = CLAMP (fg_color->red + ((other_fg->red - fg_color->red) * progress), 0, 1); + fg_color->green = CLAMP (fg_color->green + ((other_fg->green - fg_color->green) * progress), 0, 1); + fg_color->blue = CLAMP (fg_color->blue + ((other_fg->blue - fg_color->blue) * progress), 0, 1); + fg_color->alpha = CLAMP (fg_color->alpha + ((other_fg->alpha - fg_color->alpha) * progress), 0, 1); + } - gdk_rgba_free (other_fg); + if (other_fg) + gdk_rgba_free (other_fg); } if (matrix) From 0cba2dc726ae91ecf73459ca6d0e40a78707d31d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 3 Dec 2010 21:56:39 +0100 Subject: [PATCH 631/634] GtkCssProvider: Improve error handling and reporting. Nicer error reports are provided, and a GError can be spread from anywhere in parsing, so over time more precise and meaningful messages can be produced. --- gtk/gtkcssprovider.c | 376 ++++++++++++++++++++++++------------------- 1 file changed, 212 insertions(+), 164 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index f178905132..5ab102a85e 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -739,6 +739,9 @@ struct GtkCssProviderPrivate GScanner *scanner; gchar *filename; + const gchar *buffer; + const gchar *value_pos; + GHashTable *symbolic_colors; GPtrArray *selectors_info; @@ -779,14 +782,19 @@ static void gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface); static void scanner_apply_scope (GScanner *scanner, ParserScope scope); -static gboolean css_provider_parse_value (GtkCssProvider *css_provider, - const gchar *value_str, - GValue *value); +static gboolean css_provider_parse_value (GtkCssProvider *css_provider, + const gchar *value_str, + GValue *value, + GError **error); static gboolean gtk_css_provider_load_from_path_internal (GtkCssProvider *css_provider, const gchar *path, gboolean reset, GError **error); +enum { + CSS_PROVIDER_PARSE_ERROR +}; + GQuark gtk_css_provider_error_quark (void) @@ -1374,7 +1382,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, val_str = g_value_get_string (val); found = TRUE; - css_provider_parse_value (GTK_CSS_PROVIDER (provider), val_str, value); + css_provider_parse_value (GTK_CSS_PROVIDER (provider), val_str, value, NULL); break; } } @@ -1521,6 +1529,8 @@ css_provider_reset_parser (GtkCssProvider *css_provider) priv->state = NULL; scanner_apply_scope (priv->scanner, SCOPE_SELECTOR); + priv->scanner->user_data = NULL; + priv->value_pos = NULL; g_slist_foreach (priv->cur_selectors, (GFunc) selector_path_unref, NULL); g_slist_free (priv->cur_selectors); @@ -2121,7 +2131,8 @@ symbolic_color_parse_str (const gchar *string, } static GtkSymbolicColor * -symbolic_color_parse (const gchar *str) +symbolic_color_parse (const gchar *str, + GError **error) { GtkSymbolicColor *color; gchar *end; @@ -2130,8 +2141,10 @@ symbolic_color_parse (const gchar *str) if (*end != '\0') { - g_message ("Error parsing symbolic color \"%s\", stopped at char %ld : '%c'", - str, end - str, *end); + g_set_error_literal (error, + gtk_css_provider_error_quark (), + CSS_PROVIDER_PARSE_ERROR, + "Could not parse symbolic color"); if (color) { @@ -2217,6 +2230,13 @@ gradient_parse_str (const gchar *str, else { coords[i * 3] = g_ascii_strtod (str, &end); + + if (str == end) + { + *end_ptr = (gchar *) str; + return NULL; + } + str = end; } @@ -2240,6 +2260,13 @@ gradient_parse_str (const gchar *str, else { coords[(i * 3) + 1] = g_ascii_strtod (str, &end); + + if (str == end) + { + *end_ptr = (gchar *) str; + return NULL; + } + str = end; } @@ -2377,33 +2404,11 @@ gradient_parse_str (const gchar *str, return gradient; } -static GtkGradient * -gradient_parse (const gchar *str) -{ - GtkGradient *gradient; - gchar *end; - - gradient = gradient_parse_str (str, &end); - - if (*end != '\0') - { - g_message ("Error parsing pattern \"%s\", stopped at char %ld : '%c'", - str, end - str, *end); - - if (gradient) - { - gtk_gradient_unref (gradient); - gradient = NULL; - } - } - - return gradient; -} - static gchar * path_parse_str (GtkCssProvider *css_provider, const gchar *str, - gchar **end_ptr) + gchar **end_ptr, + GError **error) { gchar *path, *chr; const gchar *start, *end; @@ -2488,7 +2493,8 @@ path_parse_str (GtkCssProvider *css_provider, if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - g_warning ("File doesn't exist: %s\n", path); + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_EXIST, + "File doesn't exist: %s", path); g_free (path); path = NULL; *end_ptr = (gchar *)start; @@ -2498,24 +2504,26 @@ path_parse_str (GtkCssProvider *css_provider, } static gchar * -path_parse (GtkCssProvider *css_provider, - const gchar *str) +path_parse (GtkCssProvider *css_provider, + const gchar *str, + GError **error) { gchar *path; gchar *end; - path = path_parse_str (css_provider, str, &end); + path = path_parse_str (css_provider, str, &end, error); + + if (!path) + return NULL; if (*end != '\0') { - g_message ("Error parsing file path \"%s\", stopped at char %ld : '%c'", - str, end - str, *end); - - if (path) - { - g_free (path); - path = NULL; - } + g_set_error_literal (error, + gtk_css_provider_error_quark (), + CSS_PROVIDER_PARSE_ERROR, + "Error parsing path"); + g_free (path); + path = NULL; } return path; @@ -2524,12 +2532,12 @@ path_parse (GtkCssProvider *css_provider, static Gtk9Slice * slice_parse_str (GtkCssProvider *css_provider, const gchar *str, - gchar **end_ptr) + gchar **end_ptr, + GError **error) { gdouble distance_top, distance_bottom; gdouble distance_left, distance_right; GtkSliceSideModifier mods[2]; - GError *error = NULL; GdkPixbuf *pixbuf; Gtk9Slice *slice; gchar *path; @@ -2538,7 +2546,7 @@ slice_parse_str (GtkCssProvider *css_provider, SKIP_SPACES (str); /* Parse image url */ - path = path_parse_str (css_provider, str, end_ptr); + path = path_parse_str (css_provider, str, end_ptr, error); if (!path) return NULL; @@ -2604,13 +2612,11 @@ slice_parse_str (GtkCssProvider *css_provider, mods[1] = mods[0]; } - pixbuf = gdk_pixbuf_new_from_file (path, &error); + pixbuf = gdk_pixbuf_new_from_file (path, error); g_free (path); - if (error) + if (!pixbuf) { - g_warning ("Pixbuf could not be loaded: %s\n", error->message); - g_error_free (error); *end_ptr = (gchar *) str; return NULL; } @@ -2624,30 +2630,6 @@ slice_parse_str (GtkCssProvider *css_provider, return slice; } -static Gtk9Slice * -slice_parse (GtkCssProvider *css_provider, - const gchar *str) -{ - Gtk9Slice *slice; - gchar *end; - - slice = slice_parse_str (css_provider, str, &end); - - if (*end != '\0') - { - g_message ("Error parsing sliced image \"%s\", stopped at char %ld : '%c'", - str, end - str, *end); - - if (slice) - { - gtk_9slice_unref (slice); - slice = NULL; - } - } - - return slice; -} - static gdouble unit_parse_str (const gchar *str, gchar **end_str) @@ -2740,36 +2722,18 @@ border_parse_str (const gchar *str, return border; } -static GtkBorder * -border_parse (const gchar *str) -{ - GtkBorder *border; - gchar *end; - - border = border_parse_str (str, &end); - - if (*end != '\0') - { - g_message ("Error parsing border \"%s\", stopped at char %ld : '%c'", - str, end - str, *end); - - if (border) - gtk_border_free (border); - - return NULL; - } - - return border; -} - static gboolean -css_provider_parse_value (GtkCssProvider *css_provider, - const gchar *value_str, - GValue *value) +css_provider_parse_value (GtkCssProvider *css_provider, + const gchar *value_str, + GValue *value, + GError **error) { + GtkCssProviderPrivate *priv; GType type; gboolean parsed = TRUE; + gchar *end = NULL; + priv = css_provider->priv; type = G_VALUE_TYPE (value); if (type == GDK_TYPE_RGBA || @@ -2788,7 +2752,7 @@ css_provider_parse_value (GtkCssProvider *css_provider, { GtkSymbolicColor *symbolic_color; - symbolic_color = symbolic_color_parse (value_str); + symbolic_color = symbolic_color_parse_str (value_str, &end); if (!symbolic_color) return FALSE; @@ -2843,14 +2807,14 @@ css_provider_parse_value (GtkCssProvider *css_provider, { GtkBorder *border; - border = border_parse (value_str); + border = border_parse_str (value_str, &end); g_value_take_boxed (value, border); } else if (type == CAIRO_GOBJECT_TYPE_PATTERN) { GtkGradient *gradient; - gradient = gradient_parse (value_str); + gradient = gradient_parse_str (value_str, &end); if (gradient) { @@ -2863,7 +2827,8 @@ css_provider_parse_value (GtkCssProvider *css_provider, gchar *path; GdkPixbuf *pixbuf; - path = path_parse (css_provider, value_str); + g_clear_error (error); + path = path_parse_str (css_provider, value_str, &end, error); if (path) { @@ -2979,7 +2944,7 @@ css_provider_parse_value (GtkCssProvider *css_provider, { Gtk9Slice *slice; - slice = slice_parse (css_provider, value_str); + slice = slice_parse_str (css_provider, value_str, &end, error); if (slice) g_value_take_boxed (value, slice); @@ -2992,12 +2957,103 @@ css_provider_parse_value (GtkCssProvider *css_provider, parsed = FALSE; } + if (end && *end) + { + /* Set error position in the scanner + * according to what we've parsed so far + */ + priv->value_pos += (end - value_str); + + if (error && !*error) + g_set_error_literal (error, + gtk_css_provider_error_quark (), + CSS_PROVIDER_PARSE_ERROR, + "Failed to parse value"); + } + return parsed; } +static void +scanner_report_warning (GtkCssProvider *css_provider, + GTokenType expected_token, + GError *error) +{ + GtkCssProviderPrivate *priv; + const gchar *line_end, *line_start; + const gchar *expected_str; + gchar buf[2], *line, *str; + guint pos; + + priv = css_provider->priv; + + if (error) + str = g_strdup (error->message); + else + { + if (priv->scanner->user_data) + expected_str = priv->scanner->user_data; + else + { + switch (expected_token) + { + case G_TOKEN_SYMBOL: + expected_str = "Symbol"; + case G_TOKEN_IDENTIFIER: + expected_str = "Identifier"; + default: + buf[0] = expected_token; + buf[1] = '\0'; + expected_str = buf; + } + } + + str = g_strdup_printf ("Parse error, expecting a %s '%s'", + (expected_str != buf) ? "valid" : "", + expected_str); + } + + if (priv->value_pos) + line_start = priv->value_pos - 1; + else + line_start = priv->scanner->text - 1; + + while (*line_start != '\n' && + line_start != priv->buffer) + line_start--; + + if (*line_start == '\n') + line_start++; + + if (priv->value_pos) + pos = priv->value_pos - line_start + 1; + else + pos = priv->scanner->text - line_start - 1; + + line_end = strchr (line_start, '\n'); + + if (line_end) + line = g_strndup (line_start, (line_end - line_start)); + else + line = g_strdup (line_start); + + g_message ("CSS: %s\n" + "%s, line %d, char %d:\n" + "%*c %s\n" + "%*c ^", + str, priv->scanner->input_name, + priv->scanner->line, priv->scanner->position, + 3, ' ', line, + 3 + pos, ' '); + + g_free (line); + g_free (str); +} + static GTokenType -parse_rule (GtkCssProvider *css_provider, - GScanner *scanner) +parse_rule (GtkCssProvider *css_provider, + GScanner *scanner, + GError **error) { GtkCssProviderPrivate *priv; GTokenType expected_token; @@ -3024,20 +3080,29 @@ parse_rule (GtkCssProvider *css_provider, g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_IDENTIFIER) - return G_TOKEN_IDENTIFIER; + { + scanner->user_data = "Color name"; + return G_TOKEN_IDENTIFIER; + } color_name = g_strdup (scanner->value.v_identifier); css_provider_push_scope (css_provider, SCOPE_VALUE); g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_IDENTIFIER) - return G_TOKEN_IDENTIFIER; + { + scanner->user_data = "Color definition"; + return G_TOKEN_IDENTIFIER; + } color_str = g_strstrip (scanner->value.v_identifier); - color = symbolic_color_parse (color_str); + color = symbolic_color_parse (color_str, error); if (!color) - return G_TOKEN_IDENTIFIER; + { + scanner->user_data = "Color definition"; + return G_TOKEN_IDENTIFIER; + } g_hash_table_insert (priv->symbolic_colors, color_name, color); @@ -3053,9 +3118,8 @@ parse_rule (GtkCssProvider *css_provider, { GScanner *scanner_backup; GSList *state_backup; - GError *error = NULL; gboolean loaded; - gchar *path; + gchar *path = NULL; css_provider_push_scope (css_provider, SCOPE_VALUE); g_scanner_get_next_token (scanner); @@ -3063,15 +3127,18 @@ parse_rule (GtkCssProvider *css_provider, if (scanner->token == G_TOKEN_IDENTIFIER && g_str_has_prefix (scanner->value.v_identifier, "url")) path = path_parse (css_provider, - g_strstrip (scanner->value.v_identifier)); + g_strstrip (scanner->value.v_identifier), + error); else if (scanner->token == G_TOKEN_STRING) path = path_parse (css_provider, - g_strstrip (scanner->value.v_string)); - else - return G_TOKEN_IDENTIFIER; + g_strstrip (scanner->value.v_string), + error); if (path == NULL) - return G_TOKEN_IDENTIFIER; + { + scanner->user_data = "File URL"; + return G_TOKEN_IDENTIFIER; + } css_provider_pop_scope (css_provider); g_scanner_get_next_token (scanner); @@ -3091,7 +3158,7 @@ parse_rule (GtkCssProvider *css_provider, /* FIXME: Avoid recursive importing */ loaded = gtk_css_provider_load_from_path_internal (css_provider, path, - FALSE, &error); + FALSE, error); /* Restore previous state */ css_provider_reset_parser (css_provider); @@ -3103,16 +3170,17 @@ parse_rule (GtkCssProvider *css_provider, if (!loaded) { - g_warning ("Error loading imported file \"%s\": %s", - path, (error) ? error->message : ""); - g_error_free (error); + scanner->user_data = "File URL"; return G_TOKEN_IDENTIFIER; } else return G_TOKEN_NONE; } else - return G_TOKEN_IDENTIFIER; + { + scanner->user_data = "Directive"; + return G_TOKEN_IDENTIFIER; + } } expected_token = parse_selector (css_provider, scanner, &selector); @@ -3120,6 +3188,7 @@ parse_rule (GtkCssProvider *css_provider, if (expected_token != G_TOKEN_NONE) { selector_path_unref (selector); + scanner->user_data = "Selector"; return expected_token; } @@ -3134,6 +3203,7 @@ parse_rule (GtkCssProvider *css_provider, if (expected_token != G_TOKEN_NONE) { selector_path_unref (selector); + scanner->user_data = "Selector"; return expected_token; } @@ -3151,10 +3221,9 @@ parse_rule (GtkCssProvider *css_provider, while (scanner->token == G_TOKEN_IDENTIFIER) { - const gchar *value_str = NULL; + gchar *value_str = NULL; GtkStylePropertyParser parse_func = NULL; GParamSpec *pspec; - GError *error = NULL; gchar *prop; prop = g_strdup (scanner->value.v_identifier); @@ -3166,16 +3235,21 @@ parse_rule (GtkCssProvider *css_provider, return ':'; } + priv->value_pos = priv->scanner->text; + css_provider_push_scope (css_provider, SCOPE_VALUE); g_scanner_get_next_token (scanner); if (scanner->token != G_TOKEN_IDENTIFIER) { g_free (prop); + scanner->user_data = "Property value"; return G_TOKEN_IDENTIFIER; } - value_str = g_strstrip (scanner->value.v_identifier); + value_str = scanner->value.v_identifier; + SKIP_SPACES (value_str); + g_strchomp (value_str); if (gtk_style_properties_lookup_property (prop, &parse_func, &pspec)) { @@ -3197,21 +3271,16 @@ parse_rule (GtkCssProvider *css_provider, g_value_set_string (val, value_str); g_hash_table_insert (priv->cur_properties, prop, val); } - else if ((parse_func && (parse_func) (value_str, val, &error)) || - (!parse_func && css_provider_parse_value (css_provider, value_str, val))) + else if ((parse_func && (parse_func) (value_str, val, error)) || + (!parse_func && css_provider_parse_value (css_provider, value_str, val, error))) g_hash_table_insert (priv->cur_properties, prop, val); else { - if (error) - { - g_message ("Error parsing property value: %s\n", error->message); - g_error_free (error); - } - g_value_unset (val); g_slice_free (GValue, val); g_free (prop); + scanner->user_data = "Property value"; return G_TOKEN_IDENTIFIER; } } @@ -3246,19 +3315,6 @@ parse_rule (GtkCssProvider *css_provider, return G_TOKEN_NONE; } -static void -scanner_msg (GScanner *scanner, - gchar *message, - gboolean is_error) -{ - GError **error = scanner->user_data; - - g_set_error_literal (error, - GTK_CSS_PROVIDER_ERROR, - GTK_CSS_PROVIDER_ERROR_FAILED, - message); -} - static gboolean parse_stylesheet (GtkCssProvider *css_provider, GError **error) @@ -3271,29 +3327,14 @@ parse_stylesheet (GtkCssProvider *css_provider, while (!g_scanner_eof (priv->scanner)) { GTokenType expected_token; + GError *err = NULL; css_provider_reset_parser (css_provider); - expected_token = parse_rule (css_provider, priv->scanner); + expected_token = parse_rule (css_provider, priv->scanner, &err); if (expected_token != G_TOKEN_NONE) { - if (error != NULL) - { - priv->scanner->msg_handler = scanner_msg; - priv->scanner->user_data = error; - } - - g_scanner_unexp_token (priv->scanner, expected_token, - NULL, NULL, NULL, - "Error parsing style resource", FALSE); - - if (error != NULL) - { - priv->scanner->msg_handler = NULL; - priv->scanner->user_data = NULL; - - return FALSE; - } + scanner_report_warning (css_provider, expected_token, err); while (!g_scanner_eof (priv->scanner) && priv->scanner->token != G_TOKEN_RIGHT_CURLY) @@ -3302,6 +3343,7 @@ parse_stylesheet (GtkCssProvider *css_provider, else css_provider_commit (css_provider); + g_clear_error (&err); g_scanner_get_next_token (priv->scanner); } @@ -3340,10 +3382,12 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider, g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len); priv->scanner->input_name = "-"; + priv->buffer = data; g_scanner_input_text (priv->scanner, data, (guint) length); g_free (priv->filename); priv->filename = NULL; + priv->buffer = NULL; return parse_stylesheet (css_provider, error); } @@ -3390,10 +3434,12 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider, priv->filename = g_file_get_path (file); priv->scanner->input_name = priv->filename; + priv->buffer = data; g_scanner_input_text (priv->scanner, data, (guint) length); ret = parse_stylesheet (css_provider, error); + priv->buffer = NULL; g_free (data); return ret; @@ -3438,10 +3484,12 @@ gtk_css_provider_load_from_path_internal (GtkCssProvider *css_provider, } priv->scanner->input_name = priv->filename; + priv->buffer = data; g_scanner_input_text (priv->scanner, data, (guint) length); ret = parse_stylesheet (css_provider, error); + priv->buffer = NULL; g_mapped_file_unref (mapped_file); return ret; From 8c02445bc5192d0cd47e21466e514611fd56e0f7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 4 Dec 2010 14:29:16 +0100 Subject: [PATCH 632/634] testgtk: Fix gdk_rgba_parse() arguments. --- tests/testgtk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testgtk.c b/tests/testgtk.c index ddd5d9011d..76d68387f7 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -411,7 +411,7 @@ create_composited_window (GtkWidget *widget) &window); /* put a red background on the window */ - gdk_rgba_parse ("red", &red); + gdk_rgba_parse (&red, "red"); gtk_widget_override_background_color (window, 0, &red); /* set our event box to have a fully-transparent background From 1c87180d5d22fd52a870d8dcf51cddc146eda2e0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 4 Dec 2010 15:08:35 +0100 Subject: [PATCH 633/634] GtkThemingEngine: Fix parameters for gtk_theming_engine_lookup_color() --- gtk/gtkthemingengine.c | 9 ++++----- gtk/gtkthemingengine.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 2b9c4ce8dc..e254161141 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -546,17 +546,16 @@ gtk_theming_engine_get_style (GtkThemingEngine *engine, * gtk_theming_engine_lookup_color: * @engine: a #GtkThemingEngine * @color_name: color name to lookup - * @color: (out) (transfer full): Return location for the looked up color + * @color: (out): Return location for the looked up color * * Looks up and resolves a color name in the current style's color map. - * The returned color must be freed with gdk_rgba_free(). * * Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise **/ gboolean -gtk_theming_engine_lookup_color (GtkThemingEngine *engine, - const gchar *color_name, - GdkRGBA **color) +gtk_theming_engine_lookup_color (GtkThemingEngine *engine, + const gchar *color_name, + GdkRGBA *color) { GtkThemingEnginePrivate *priv; diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 128070e068..64b39216e2 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -198,9 +198,9 @@ void gtk_theming_engine_get_style_valist (GtkThemingEngine *engine, void gtk_theming_engine_get_style (GtkThemingEngine *engine, ...); -gboolean gtk_theming_engine_lookup_color (GtkThemingEngine *engine, - const gchar *color_name, - GdkRGBA **color); +gboolean gtk_theming_engine_lookup_color (GtkThemingEngine *engine, + const gchar *color_name, + GdkRGBA *color); G_CONST_RETURN GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine); From cd76b057e9693b6919f4ccbe40ce205efc8d3caf Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Sat, 4 Dec 2010 14:55:11 +0100 Subject: [PATCH 634/634] Annotate gdk_window_get_geometry, get_position and get_origin --- gdk/gdkwindow.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 630c3a1b66..4307f34ae9 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2276,8 +2276,8 @@ gdk_window_has_native (GdkWindow *window) /** * gdk_window_get_position: * @window: a #GdkWindow - * @x: X coordinate of window - * @y: Y coordinate of window + * @x: (out) (allow-none): X coordinate of window + * @y: (out) (allow-none): Y coordinate of window * * Obtains the position of the window as reported in the * most-recently-processed #GdkEventConfigure. Contrast with @@ -6805,11 +6805,11 @@ gdk_window_set_device_cursor (GdkWindow *window, /** * gdk_window_get_geometry: * @window: a #GdkWindow - * @x: return location for X coordinate of window (relative to its parent) - * @y: return location for Y coordinate of window (relative to its parent) - * @width: return location for width of window - * @height: return location for height of window - * @depth: return location for bit depth of window + * @x: (out) (allow-none): return location for X coordinate of window (relative to its parent) + * @y: (out) (allow-none): return location for Y coordinate of window (relative to its parent) + * @width: (out) (allow-none): return location for width of window + * @height: (out) (allow-none): return location for height of window + * @depth: (out) (allow-none): return location for bit depth of window * * Any of the return location arguments to this function may be %NULL, * if you aren't interested in getting the value of that field. @@ -6937,8 +6937,8 @@ gdk_window_get_height (GdkWindow *window) /** * gdk_window_get_origin: * @window: a #GdkWindow - * @x: return location for X coordinate - * @y: return location for Y coordinate + * @x: (out) (allow-none): return location for X coordinate + * @y: (out) (allow-none): return location for Y coordinate * * Obtains the position of a window in root window coordinates. * (Compare with gdk_window_get_position() and