File: migrating-GtkColorButton.sgml

package info (click to toggle)
gtk%2B2.0 2.24.33-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates, trixie-updates
  • size: 124,860 kB
  • sloc: ansic: 574,091; makefile: 5,171; sh: 4,618; xml: 1,193; python: 1,117; perl: 749; awk: 49; cpp: 34
file content (54 lines) | stat: -rw-r--r-- 2,008 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<chapter id="gtk-migrating-GtkColorButton">

  <title>Migrating from GnomeColorPicker to GtkColorButton</title>

  <para>
    Since version 2.6, GTK+ provides the #GtkColorButton
    widget as a replacement for the <structname>GnomeColorPicker</structname> 
    widget in the libgnomeui library.
  </para>

  <para>
   Porting an application from <structname>GnomeColorPicker</structname> to 
   <structname>GtkColorButton</structname> is very simple. 
   <structname>GtkColorButton</structname> doesn't support dithering 
   (since it is rarely needed on modern hardware), and it doesn't have 
   setters and getters to set the color from floating point or integer 
    components. So instead of
   <informalexample><programlisting>
   guint red, green, blue, alpha;
   /* ... */
   gnome_color_picker_set_i8 (color_picker, red, green, blue, alpha);
   </programlisting></informalexample>   
   you have to write
   <informalexample><programlisting>
   GdkColor color;

   color.red = red &lt;&lt; 8;
   color.green = green &lt;&lt; 8;
   color.blue = blue &lt;&lt; 8;
   gtk_color_button_set_color (color_picker, &amp;color);
   gtk_color_button_set_alpha (color_picker, alpha &lt;&lt; 8);
   </programlisting></informalexample>   
  and similarly for the setters taking other number formats. For 
  <function>gnome_color_picker_set_i16()</function> no conversion is needed, 
  for <function>gnome_color_picker_set_d()</function>, you need to convert 
  the color components like this:
   <informalexample><programlisting>  
   color.red = (guint16) (red * 65535.0 + 0.5);
   color.green = (guint16) (green * 65535.0 + 0.5);
   color.blue = (guint16) (blue * 65535.0 + 0.5);
   </programlisting></informalexample>   
  </para>
</chapter>

<!--
Local variables:
mode: sgml
sgml-parent-document: ("gtk-docs.sgml" "book" "part" "chapter")
End:
-->