Add HildonAppMenu::changed signal
[hildon] / hildon / hildon-bread-crumb.c
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2007 Nokia Corporation, all rights reserved.
5  *
6  * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
7  * Author: Xan Lopez <xan.lopez@nokia.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; version 2.1 of
12  * the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  *
24  */
25
26 /**
27  * SECTION:hildon-bread-crumb
28  * @short_description: Interface for elements in a #HildonBreadCrumbTrail
29  *
30  * #HildonBreadCrumb is an interface for creating new types of items
31  * for the #HildonBreadCrumbTrail widget.
32  *
33  * #HildonBreadCrumb is deprecated since hildon 2.2. You should instead use
34  * #HildonStackableWindow to represent hierarchical structure in
35  * applications.
36  */
37
38 #undef HILDON_DISABLE_DEPRECATED
39
40 #include "hildon-bread-crumb.h"
41
42 static void hildon_bread_crumb_base_init (gpointer g_class);
43
44 GType
45 hildon_bread_crumb_get_type (void)
46 {
47   static GType bread_crumb_type = 0;
48
49   if (G_UNLIKELY (bread_crumb_type == 0))
50     {
51       const GTypeInfo bread_crumb_info =
52         {
53           sizeof (HildonBreadCrumbIface), /* class_size */
54           hildon_bread_crumb_base_init, /* base_init */
55           NULL, /* base_finalize */
56           NULL,
57           NULL, /* class_finalize */
58           NULL, /* class_data */
59           0,
60           0,
61           NULL
62         };
63       
64       bread_crumb_type =
65         g_type_register_static (G_TYPE_INTERFACE, "HildonBreadCrumb",
66                                 &bread_crumb_info, 0);
67
68       g_type_interface_add_prerequisite (bread_crumb_type, GTK_TYPE_WIDGET);
69     }
70
71   return bread_crumb_type;
72 }
73
74 static void
75 hildon_bread_crumb_base_init (gpointer g_class)
76 {
77   static gboolean initialized = FALSE;
78
79   if (initialized == FALSE)
80     {
81       g_signal_new ("crumb-activated",
82                     HILDON_TYPE_BREAD_CRUMB,
83                     G_SIGNAL_RUN_LAST,
84                     G_STRUCT_OFFSET (HildonBreadCrumbIface, crumb_activated),
85                     NULL, NULL,
86                     g_cclosure_marshal_VOID__VOID,
87                     G_TYPE_NONE, 0);
88
89       initialized = TRUE;
90     }
91 }
92
93 /**
94  * hildon_bread_crumb_get_natural_size:
95  * @bread_crumb: A #HildonBreadCrumb
96  * @width: location to store the natural width request of the @bread_crumb
97  * @height: location to store the natural height request of the @bread_crumb
98  *
99  * Function to ask the @bread_crumb its preferred width and height requisition.
100  * Natural size is different to size_request in that it's not the minimum space
101  * the widget needs, but the ideal space it'd like to be allocated. For example,
102  * in the case of a label the natural size would be the width and height needed
103  * to show the full label without line breaks.
104  *
105  **/
106
107 void
108 hildon_bread_crumb_get_natural_size (HildonBreadCrumb *bread_crumb,
109                                      gint *width,
110                                      gint *height)
111 {
112   g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));
113
114   (* HILDON_BREAD_CRUMB_GET_IFACE (bread_crumb)->get_natural_size) (bread_crumb, width, height);
115 }
116
117 /**
118  * hildon_bread_crumb_activated:
119  * @bread_crumb: a #HildonBreadCrumb
120  *
121  * Emits the "crumb-activated" signal. The signal is meant to indicate that
122  * the user has interacted with the bread crumb.
123  **/
124
125 void
126 hildon_bread_crumb_activated (HildonBreadCrumb *bread_crumb)
127 {
128   g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));
129
130   g_signal_emit_by_name (bread_crumb, "crumb-activated");
131 }
132
133