summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2008-12-27 05:59:42 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2008-12-27 05:59:42 +0000
commitfdf0e1a22113099d04d06bcb8a95deb52efd1ce8 (patch)
tree216e272be114c85e86d2bb8970bf29b276869d23 /docs
parentdd21a2d7fbf533047c162e772f5ee23e959eb595 (diff)
downloadgtk+-fdf0e1a22113099d04d06bcb8a95deb52efd1ce8.tar.gz
Add new migration chapter
svn path=/trunk/; revision=21946
Diffstat (limited to 'docs')
-rw-r--r--docs/reference/ChangeLog2
-rw-r--r--docs/reference/gtk/gtk-docs.sgml1
-rw-r--r--docs/reference/gtk/migrating-GtkEntry-icons.sgml88
3 files changed, 91 insertions, 0 deletions
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index d6957205ed..ba0b9c7ca4 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,6 +1,8 @@
2008-12-27 Matthias Clasen <mclasen@redhat.com>
* gtk/migrating-GtkLinkButton.sgml: Mention default hook
+ * gtk/migrating-GtkEntry-icons.sgml: Migration chapter
+ SexyIconEntry -> GtkEntry
2008-12-27 Matthias Clasen <mclasen@redhat.com>
diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml
index e6aa20819c..980de935c8 100644
--- a/docs/reference/gtk/gtk-docs.sgml
+++ b/docs/reference/gtk/gtk-docs.sgml
@@ -425,6 +425,7 @@ that is, GUI components such as #GtkButton or #GtkTextView.
<xi:include href="xml/migrating-GtkLinkButton.sgml" />
<xi:include href="xml/migrating-GtkBuilder.sgml" />
<xi:include href="xml/migrating-GtkTooltip.sgml" />
+ <xi:include href="xml/migrating-GtkEntry-icons.sgml" />
</part>
<part>
diff --git a/docs/reference/gtk/migrating-GtkEntry-icons.sgml b/docs/reference/gtk/migrating-GtkEntry-icons.sgml
new file mode 100644
index 0000000000..4de5917f1b
--- /dev/null
+++ b/docs/reference/gtk/migrating-GtkEntry-icons.sgml
@@ -0,0 +1,88 @@
+<?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-entry-icons">
+
+ <title>Migrating from SexyIconEntry to GtkEntry</title>
+
+ <para>
+ GTK+ 2.16 supports showing icons inside a #GtkEntry, similar to
+ SexyIconEntry. Porting from SexyIconEntry to GtkEntry is relatively
+ straightforward. The main difference between the two APIs is that
+ SexyIconEntry uses #GtkImage widgets in a somewhat awkward way as
+ storage vehicles for icons, while GtkEntry allows to specify icons
+ via pixbufs, stock ids, icon names or #GIcons. So, if your code uses
+ e.g.:
+<informalexample><programlisting>
+image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
+sexy_icon_entry_set_icon (entry, SEXY_ICON_ENTRY_PRIMARY, image);
+</programlisting></informalexample>
+ you can get rid of the @image, and directly write:
+<informalexample><programlisting>
+gtk_entry_set_icon_from_stock (entry, GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_NEW);
+</programlisting></informalexample>
+ </para>
+
+ <para>
+ Another difference is that SexyIconEntry offers manual control of
+ the icon prelighting, via sexy_icon_entry_set_icon_highlight().
+ #GtkEntry prelights automatically when appropriate, depending on
+ whether the icon is activatable and sensitive. You should make
+ sure that your icons are properly marked as activatable or nonactivatable
+ and sensitive or insensitive:
+ <varlist>
+ <varlistentry>
+ <listitem><para>Sensitive, but non-activatable icons are
+ good for purely informational purposes.</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <listitem><para>Icons should be marked as insensitive if the
+ function that they trigger is currently not available.</para></listitem>
+ </varlistentry>
+ </para>
+
+ <para>
+ GtkEntry has no direct equivalent of the special-purpose function
+ sexy_icon_entry_add_clear_button(). If you need this functionality,
+ the following code works:
+<informalexample><programlisting>
+static void
+icon_pressed_cb (GtkEntry *entry,
+ gint position,
+ GdkEventButton *event,
+ gpointer data)
+{
+ if (position == GTK_ENTRY_ICON_SECONDARY)
+ gtk_entry_set_text (entry, "");
+}
+
+static void
+text_changed_cb (GtkEntry *entry,
+ GParamSpec *pspec,
+ GtkWidget *button)
+{
+ gboolean has_text;
+
+ has_text = gtk_entry_get_text_length (entry) > 0;
+ gtk_entry_set_icon_sensitive (entry,
+ GTK_ENTRY_ICON_SECONDARY,
+ has_text);
+}
+
+
+ /* ... */
+
+ /* Set up the clear icon */
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ GTK_STOCK_CLEAR);
+ g_signal_connect (entry, "icon-pressed",
+ G_CALLBACK (icon_pressed_cb), NULL);
+ g_signal_connect (entry, "notify::text",
+ G_CALLBACK (text_changed_cb), find_button);
+
+ /* ... */
+</programlisting></informalexample>
+ </para>
+</chapter>