528e3496ec57fe73b283779349596ad73fcdea47
[hildon] / src / 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: Michael Dominic Kostrzewa <michael.kostrzewa@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
34 #include "hildon-bread-crumb.h"
35
36 static void hildon_bread_crumb_base_init (gpointer g_class);
37
38 GType
39 hildon_bread_crumb_get_type (void)
40 {
41   static GType bread_crumb_type = 0;
42
43   if (G_UNLIKELY (bread_crumb_type == 0))
44     {
45       const GTypeInfo bread_crumb_info =
46         {
47           sizeof (HildonBreadCrumbIface), /* class_size */
48           hildon_bread_crumb_base_init, /* base_init */
49           NULL, /* base_finalize */
50           NULL,
51           NULL, /* class_finalize */
52           NULL, /* class_data */
53           0,
54           0,
55           NULL
56         };
57       
58       bread_crumb_type =
59         g_type_register_static (G_TYPE_INTERFACE, "HildonBreadCrumb",
60                                 &bread_crumb_info, 0);
61
62       g_type_interface_add_prerequisite (bread_crumb_type, GTK_TYPE_WIDGET);
63     }
64
65   return bread_crumb_type;
66 }
67
68 static void
69 hildon_bread_crumb_base_init (gpointer g_class)
70 {
71   static gboolean initialized = FALSE;
72
73   if (initialized == FALSE)
74     {
75       g_signal_new ("crumb-activated",
76                     HILDON_TYPE_BREAD_CRUMB,
77                     G_SIGNAL_RUN_LAST,
78                     G_STRUCT_OFFSET (HildonBreadCrumbIface, crumb_activated),
79                     NULL, NULL,
80                     g_cclosure_marshal_VOID__VOID,
81                     G_TYPE_NONE, 0);
82
83       initialized = TRUE;
84     }
85 }
86
87 /**
88  * hildon_bread_crumb_get_natural_size:
89  * @bread_crumb: A #HildonBreadCrumb
90  * @width: location to store the natural width request of the @bread_crumb
91  * @height: location to store the natural height request of the @bread_crumb
92  *
93  * Function to ask the @bread_crumb its preferred width and height requisition.
94  * Natural size is different to size_request in that it's not the minimum space
95  * the widget needs, but the ideal space it'd like to be allocated. For example,
96  * in the case of a label the natural size would be the width and height needed
97  * to show the full label without line breaks.
98  *
99  **/
100
101 void
102 hildon_bread_crumb_get_natural_size (HildonBreadCrumb *bread_crumb,
103                                      gint *width,
104                                      gint *height)
105 {
106   g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));
107
108   (* HILDON_BREAD_CRUMB_GET_IFACE (bread_crumb)->get_natural_size) (bread_crumb, width, height);
109 }
110
111 /**
112  * hildon_bread_crumb_activated:
113  * @bread_crumb: a #HildonBreadCrumb
114  *
115  * Emits the "crumb-activated" signal. The signal is meant to indicate that
116  * the user has interacted with the bread crumb.
117  **/
118
119 void
120 hildon_bread_crumb_activated (HildonBreadCrumb *bread_crumb)
121 {
122   g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));
123
124   g_signal_emit_by_name (bread_crumb, "crumb-activated");
125 }
126
127