aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-bread-crumb.c
blob: d59bddf608ad44a9320093c92254d8f2f6afd2cb (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * This file is a part of hildon
 *
 * Copyright (C) 2007 Nokia Corporation, all rights reserved.
 *
 * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
 * Author: Xan Lopez <xan.lopez@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/**
 * SECTION:hildon-bread-crumb
 * @short_description: Interface for elements in a #HildonBreadCrumbTrail
 *
 * #HildonBreadCrumb is an interface for creating new types of items
 * for the #HildonBreadCrumbTrail widget.
 *
 * #HildonBreadCrumb is deprecated since hildon 2.2. You should instead use
 * #HildonStackableWindow to represent hierarchical structure in
 * applications.
 */

#undef HILDON_DISABLE_DEPRECATED

#include "hildon-bread-crumb.h"

static void hildon_bread_crumb_base_init (gpointer g_class);

GType
hildon_bread_crumb_get_type (void)
{
  static GType bread_crumb_type = 0;

  if (G_UNLIKELY (bread_crumb_type == 0))
    {
      const GTypeInfo bread_crumb_info =
        {
          sizeof (HildonBreadCrumbIface), /* class_size */
          hildon_bread_crumb_base_init, /* base_init */
          NULL, /* base_finalize */
          NULL,
          NULL, /* class_finalize */
          NULL, /* class_data */
          0,
          0,
          NULL
        };
      
      bread_crumb_type =
        g_type_register_static (G_TYPE_INTERFACE, "HildonBreadCrumb",
                                &bread_crumb_info, 0);

      g_type_interface_add_prerequisite (bread_crumb_type, GTK_TYPE_WIDGET);
    }

  return bread_crumb_type;
}

static void
hildon_bread_crumb_base_init (gpointer g_class)
{
  static gboolean initialized = FALSE;

  if (initialized == FALSE)
    {
      g_signal_new ("crumb-activated",
                    HILDON_TYPE_BREAD_CRUMB,
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (HildonBreadCrumbIface, crumb_activated),
                    NULL, NULL,
                    g_cclosure_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);

      initialized = TRUE;
    }
}

/**
 * hildon_bread_crumb_get_natural_size:
 * @bread_crumb: A #HildonBreadCrumb
 * @width: location to store the natural width request of the @bread_crumb
 * @height: location to store the natural height request of the @bread_crumb
 *
 * Function to ask the @bread_crumb its preferred width and height requisition.
 * Natural size is different to size_request in that it's not the minimum space
 * the widget needs, but the ideal space it'd like to be allocated. For example,
 * in the case of a label the natural size would be the width and height needed
 * to show the full label without line breaks.
 *
 **/

void
hildon_bread_crumb_get_natural_size (HildonBreadCrumb *bread_crumb,
                                     gint *width,
                                     gint *height)
{
  g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));

  (* HILDON_BREAD_CRUMB_GET_IFACE (bread_crumb)->get_natural_size) (bread_crumb, width, height);
}

/**
 * hildon_bread_crumb_activated:
 * @bread_crumb: a #HildonBreadCrumb
 *
 * Emits the "crumb-activated" signal. The signal is meant to indicate that
 * the user has interacted with the bread crumb.
 **/

void
hildon_bread_crumb_activated (HildonBreadCrumb *bread_crumb)
{
  g_return_if_fail (HILDON_IS_BREAD_CRUMB (bread_crumb));

  g_signal_emit_by_name (bread_crumb, "crumb-activated");
}