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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
Finishing Touches
</title>
<meta name="GENERATOR" content=
"Modular DocBook HTML Stylesheet Version 1.45">
<link rel="HOME" title="GTK+ / Gnome Application Development"
href="ggad.html">
<link rel="UP" title="The Main Window: GnomeApp" href=
"cha-main.html">
<link rel="PREVIOUS" title="Online Help" href="sec-help.html">
<link rel="NEXT" title="User Communication: Dialogs" href=
"cha-dialogs.html">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink=
"#840084" alink="#0000FF">
<div class="NAVHEADER">
<table width="100%" border="0" bgcolor="#ffffff" cellpadding=
"1" cellspacing="0">
<tr>
<th colspan="4" align="center">
<font color="#000000" size="2">GTK+ / Gnome Application
Development</font>
</th>
</tr>
<tr>
<td width="25%" bgcolor="#ffffff" align="left">
<a href="sec-help.html"><font color="#0000ff" size="2">
<b><<< Previous</b></font></a>
</td>
<td width="25%" colspan="2" bgcolor="#ffffff" align=
"center">
<font color="#0000ff" size="2"><b><a href="ggad.html">
<font color="#0000ff" size="2"><b>
Home</b></font></a></b></font>
</td>
<td width="25%" bgcolor="#ffffff" align="right">
<a href="cha-dialogs.html"><font color="#0000ff" size=
"2"><b>Next >>></b></font></a>
</td>
</tr>
</table>
</div>
<div class="SECT1">
<h1 class="SECT1">
<a name="Z94">Finishing Touches</a>
</h1>
<p>
Really polished application windows behave well on small
screens, and set hints so the window manager can keep track
of them.
</p>
<div class="SECT2">
<h2 class="SECT2">
<a name="Z95">Adapting to Screen Size</a>
</h2>
<p>
The functions in <a href="z94.html#FL-SCREENSIZE">Figure
12</a> allow you to query the size of the screen in
pixels. You can use this information to adjust the layout
of your application window; for example, if you know your
usual application window is too large for a 640 by 480
display, you could provide an alternative widget layout
for small screens. Applications that automatically adapt
to the screen size are very impressive.
</p>
<p>
Of course, you should leave control in the hands of the
user; users with large screens might want the small
version of your application anyway, and you should always
try to respond sensibly if the user resizes the window.
Use the screen size to select the best default from among
your application's possible configurations.
</p>
<div class="FIGURE">
<a name="FL-SCREENSIZE"></a>
<div class="FUNCSYNOPSIS">
<a name="FL-SCREENSIZE.SYNOPSIS"></a>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="FUNCSYNOPSISINFO">
#include <gdk/gdk.h>
</pre>
</td>
</tr>
</table>
<p>
<code><code class="FUNCDEF">gint <tt class=
"FUNCTION">gdk_screen_width</tt></code>(void);</code>
</p>
<p>
<code><code class="FUNCDEF">gint <tt class=
"FUNCTION">
gdk_screen_height</tt></code>(void);</code>
</p>
</div>
<p>
<b>Figure 12. Querying Screen Size</b>
</p>
</div>
</div>
<div class="SECT2">
<h2 class="SECT2">
<a name="SEC-CLASSHINT">Setting Window Class Hints</a>
</h2>
<p>
The "class hint" is a property of <tt class="CLASSNAME">
GtkWindow</tt> window managers can read to decide how to
treat the window. Most window managers allow you to set
icons and other properties based on the class hint. Two
elements make up the hint. The <span class="STRUCTNAME">
wmclass_name</span> field should be unique for each kind
of toplevel window in an application (such as the main
window or a tools dialog). The <span class="STRUCTNAME">
wmclass_class</span> field is conventionally set to the
name of the application, capitalized. For example: <span
class="STRUCTNAME">xterm</span> windows set these
properties to <span class="STRUCTNAME">xterm</span>
(name) and <span class="STRUCTNAME">XTerm</span> (class).
The GIMP toolbox sets its name to <span class=
"STRUCTNAME">toolbox</span> and its class to <span class=
"STRUCTNAME">Gimp</span>. The <tt class="FUNCTION">
gtk_window_set_wmclass()</tt> function sets these hints
for <tt class="CLASSNAME">GtkWindow</tt>.
</p>
<div class="FIGURE">
<a name="FL-CLASSHINT"></a>
<div class="FUNCSYNOPSIS">
<a name="FL-CLASSHINT.SYNOPSIS"></a>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="FUNCSYNOPSISINFO">
#include <gtk/gtkwindow.h>
</pre>
</td>
</tr>
</table>
<p>
<code><code class="FUNCDEF">void <tt class=
"FUNCTION">
gtk_window_set_wmclass</tt></code>(GtkWindow* <tt
class="PARAMETER"><i>window</i></tt>, const gchar*
<tt class="PARAMETER"><i>wmclass_name</i></tt>, const
gchar* <tt class="PARAMETER"><i>
wmclass_class</i></tt>);</code>
</p>
</div>
<p>
<b>Figure 13. Setting Class Hints</b>
</p>
</div>
</div>
</div>
<div class="NAVFOOTER">
<br>
<br>
<table width="100%" border="0" bgcolor="#ffffff" cellpadding=
"1" cellspacing="0">
<tr>
<td width="25%" bgcolor="#ffffff" align="left">
<a href="sec-help.html"><font color="#0000ff" size="2">
<b><<< Previous</b></font></a>
</td>
<td width="25%" colspan="2" bgcolor="#ffffff" align=
"center">
<font color="#0000ff" size="2"><b><a href="ggad.html">
<font color="#0000ff" size="2"><b>
Home</b></font></a></b></font>
</td>
<td width="25%" bgcolor="#ffffff" align="right">
<a href="cha-dialogs.html"><font color="#0000ff" size=
"2"><b>Next >>></b></font></a>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<font color="#000000" size="2"><b>Online
Help</b></font>
</td>
<td colspan="2" align="right">
<font color="#000000" size="2"><b>User Communication:
Dialogs</b></font>
</td>
</tr>
</table>
</div>
</body>
</html>
|