File: migrating-GtkLinkButton.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 (81 lines) | stat: -rw-r--r-- 2,457 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
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
<?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-GtkLinkButton">

  <title>Migrating from GnomeHRef to GtkLinkButton</title>

  <para>
    Since version 2.10, GTK+ provides the #GtkLinkButton widget as a
    replacement for the <structname>GnomeHRef</structname> widget
    in the libgnomeui library.
  </para>

  <para>
    Porting an application from <structname>GnomeHRef</structname> to
    #GtkLinkButton is very simple. #GtkLinkButton does not have a
    default action for #GtkButton::clicked signal. So instead of simply 
    creating the widget
    <informalexample><programlisting>
      GtkWidget *button;

      button = gnome_href_new (url, "");
    </programlisting></informalexample>
    you will have to handle the activation of the #GtkLinkButton, using
    the ::clicked signal for instance
    <informalexample><programlisting>
      static void
      link_button_clicked_cb (GtkWidget *widget,
                              gpointer   data)
      {
        const gchar *link;

	link = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
	open_browser_at_url (link);
      }

      /* ... */
      
        GtkWidget *button;

	button = gtk_link_button_new (url);
	g_signal_connect (button, "clicked",
	                  G_CALLBACK (link_button_clicked_cb), NULL);
     </programlisting></informalexample>
    If you have more than one #GtkLinkButton instead of connecting
    a signal to each one, you can use a "hook function" which will be
    called whenever a user activates a link button
    <informalexample><programlisting>
      static void
      link_button_hook (GtkLinkButton *button,
                        const gchar   *link,
			gpointer       user_data)
      
      {
        open_browser_at_url (link);
      }
      
      /* ... */
      
        GtkWidget *button1 = gtk_link_button_new (uri1);
	GtkWidget *button2 = gtk_link_button_new (uri2);

        gtk_link_button_set_uri_hook (link_button_hook, NULL, NULL);
    </programlisting></informalexample>

  </para>

  <para>
    Starting with GTK+ 2.16, it is no longer necessary to set up a uri hook
    manually, since GTK+ now defaults to calling gtk_show_uri() if no uri
    hook has been set.
  </para>
</chapter>

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