In this section I would like to show you a simple example of dynamically reloaded GtkHTML content. Real applications typically use more complicated HTML source, which will go outside the scope of this paper. So please take this just as a weak image.
For better image run RedCarpet and observe how dynamically created User Interfaces could work and look.
My intention is to show you how dynamically created content and User Interfaces could work and to call your attention to possible problems which is explained in the next section. On http://peabody.ximian.com/~rodo/gtkhtml/tutorial/ you can find more examples, which I have found too long to include in this document.
Lets extend example 2 using this code:
static gboolean
load_content (GtkWidget *html)
{
GString *padding_nbsps;
gchar *dynamic_source;
static gint pos = 0, direction = 1;
gint i;
padding_nbsps = g_string_new (NULL);
for (i = 0; i < pos; i ++)
g_string_append (padding_nbsps, " ");
pos += direction;
if (pos == 30 || pos == 0)
direction = - direction;
dynamic_source = g_strdup_printf (html_source, padding_nbsps->str);
gtk_html_load_from_string (GTK_HTML (html), dynamic_source, -1);
g_free (dynamic_source);
g_string_free (padding_nbsps, TRUE);
gtk_timeout_add (50, (GtkFunction) load_content, html);
return FALSE;
}
|
and replace the gtk_html_load_from_string call with load_content.
The following picture illustrates Example 4 running (smiley picture is shown in different positions related to different time).
| <<< Previous | Home | Next >>> |
| Embedded widgets | How to avoid flickering |