gtklistbox.h 10.6 KB
Newer Older
Alexander Larsson's avatar
Alexander Larsson committed
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
/*
 * Copyright (c) 2013 Red Hat, Inc.
 *
 * This program 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; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program 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 program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Author: Alexander Larsson <alexl@redhat.com>
 *
 */

#ifndef __GTK_LIST_BOX_H__
#define __GTK_LIST_BOX_H__

#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

Matthias Clasen's avatar
Matthias Clasen committed
29
#include <gtk/gtkbin.h>
Alexander Larsson's avatar
Alexander Larsson committed
30 31 32 33 34 35 36 37 38 39 40

G_BEGIN_DECLS


#define GTK_TYPE_LIST_BOX (gtk_list_box_get_type ())
#define GTK_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX, GtkListBox))
#define GTK_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX, GtkListBoxClass))
#define GTK_IS_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX))
#define GTK_IS_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX))
#define GTK_LIST_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX, GtkListBoxClass))

Matthias Clasen's avatar
Matthias Clasen committed
41 42
typedef struct _GtkListBox        GtkListBox;
typedef struct _GtkListBoxClass   GtkListBoxClass;
Alexander Larsson's avatar
Alexander Larsson committed
43

Matthias Clasen's avatar
Matthias Clasen committed
44 45
typedef struct _GtkListBoxRow        GtkListBoxRow;
typedef struct _GtkListBoxRowClass   GtkListBoxRowClass;
Alexander Larsson's avatar
Alexander Larsson committed
46 47 48 49 50 51

struct _GtkListBox
{
  GtkContainer parent_instance;
};

52 53 54 55 56 57 58 59 60
/**
 * GtkListBoxClass:
 * @parent_class: The parent class.
 * @row_selected: Signal emitted when a new row is selected.
 * @row_activated: Signal emitted when a row has been activated by the user.
 * @activate_cursor_row: 
 * @toggle_cursor_row: 
 * @move_cursor: 
 */
Alexander Larsson's avatar
Alexander Larsson committed
61 62 63 64
struct _GtkListBoxClass
{
  GtkContainerClass parent_class;

65 66
  /*< public >*/

Matthias Clasen's avatar
Matthias Clasen committed
67 68 69 70 71 72 73 74 75
  void (*row_selected)        (GtkListBox      *list_box,
                               GtkListBoxRow   *row);
  void (*row_activated)       (GtkListBox      *list_box,
                               GtkListBoxRow   *row);
  void (*activate_cursor_row) (GtkListBox      *list_box);
  void (*toggle_cursor_row)   (GtkListBox      *list_box);
  void (*move_cursor)         (GtkListBox      *list_box,
                               GtkMovementStep  step,
                               gint             count);
Alexander Larsson's avatar
Alexander Larsson committed
76

77 78
  /*< private >*/

Alexander Larsson's avatar
Alexander Larsson committed
79 80 81 82 83 84 85 86 87
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
};

Matthias Clasen's avatar
Matthias Clasen committed
88 89 90 91
#define GTK_TYPE_LIST_BOX_ROW            (gtk_list_box_row_get_type ())
#define GTK_LIST_BOX_ROW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRow))
#define GTK_LIST_BOX_ROW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass))
#define GTK_IS_LIST_BOX_ROW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX_ROW))
Alexander Larsson's avatar
Alexander Larsson committed
92
#define GTK_IS_LIST_BOX_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX_ROW))
Matthias Clasen's avatar
Matthias Clasen committed
93
#define GTK_LIST_BOX_ROW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass))
Alexander Larsson's avatar
Alexander Larsson committed
94 95 96 97 98 99

struct _GtkListBoxRow
{
  GtkBin parent_instance;
};

100 101 102 103 104
/**
 * GtkListBoxRowClass:
 * @parent_class: The parent class.
 * @activate: 
 */
Alexander Larsson's avatar
Alexander Larsson committed
105 106 107 108
struct _GtkListBoxRowClass
{
  GtkBinClass parent_class;

109 110
  /*< public >*/

111 112
  void (* activate) (GtkListBoxRow *row);

113 114
  /*< private >*/

Alexander Larsson's avatar
Alexander Larsson committed
115 116 117 118 119
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
};

Alexander Larsson's avatar
Alexander Larsson committed
120 121
/**
 * GtkListBoxFilterFunc:
Matthias Clasen's avatar
Matthias Clasen committed
122 123
 * @row: the row that may be filtered
 * @user_data: (closure): user data
Alexander Larsson's avatar
Alexander Larsson committed
124 125 126 127 128 129 130 131
 *
 * Will be called whenever the row changes or is added and lets you control
 * if the row should be visible or not.
 *
 * Returns: %TRUE if the row should be visible, %FALSE otherwise
 *
 * Since: 3.10
 */
Matthias Clasen's avatar
Matthias Clasen committed
132 133 134
typedef gboolean (*GtkListBoxFilterFunc) (GtkListBoxRow *row,
                                          gpointer       user_data);

Alexander Larsson's avatar
Alexander Larsson committed
135 136
/**
 * GtkListBoxSortFunc:
Matthias Clasen's avatar
Matthias Clasen committed
137 138 139
 * @row1: the first row
 * @row2: the second row
 * @user_data: (closure): user data
Alexander Larsson's avatar
Alexander Larsson committed
140
 *
Matthias Clasen's avatar
Matthias Clasen committed
141
 * Compare two rows to determine which should be first.
Alexander Larsson's avatar
Alexander Larsson committed
142
 *
Matthias Clasen's avatar
Matthias Clasen committed
143 144
 * Returns: < 0 if @row1 should be before @row2, 0 if they are
 *     equal and > 0 otherwise
Alexander Larsson's avatar
Alexander Larsson committed
145 146 147 148 149 150
 *
 * Since: 3.10
 */
typedef gint (*GtkListBoxSortFunc) (GtkListBoxRow *row1,
                                    GtkListBoxRow *row2,
                                    gpointer       user_data);
Matthias Clasen's avatar
Matthias Clasen committed
151

Alexander Larsson's avatar
Alexander Larsson committed
152
/**
153
 * GtkListBoxUpdateHeaderFunc:
Matthias Clasen's avatar
Matthias Clasen committed
154
 * @row: the row to update
155
 * @before: (allow-none): the row before @row, or %NULL if it is first
Matthias Clasen's avatar
Matthias Clasen committed
156
 * @user_data: (closure): user data
Alexander Larsson's avatar
Alexander Larsson committed
157
 *
Matthias Clasen's avatar
Matthias Clasen committed
158 159 160 161
 * Whenever @row changes or which row is before @row changes this
 * is called, which lets you update the header on @row. You may
 * remove or set a new one via gtk_list_box_row_set_header() or
 * just change the state of the current header widget.
Alexander Larsson's avatar
Alexander Larsson committed
162 163 164
 *
 * Since: 3.10
 */
165 166 167
typedef void (*GtkListBoxUpdateHeaderFunc) (GtkListBoxRow *row,
                                            GtkListBoxRow *before,
                                            gpointer       user_data);
Alexander Larsson's avatar
Alexander Larsson committed
168 169 170 171 172 173

GDK_AVAILABLE_IN_3_10
GType      gtk_list_box_row_get_type      (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_10
GtkWidget* gtk_list_box_row_new           (void);
GDK_AVAILABLE_IN_3_10
174
GtkWidget* gtk_list_box_row_get_header    (GtkListBoxRow *row);
Alexander Larsson's avatar
Alexander Larsson committed
175
GDK_AVAILABLE_IN_3_10
176 177
void       gtk_list_box_row_set_header    (GtkListBoxRow *row,
                                           GtkWidget     *header);
Alexander Larsson's avatar
Alexander Larsson committed
178
GDK_AVAILABLE_IN_3_10
179 180
gint       gtk_list_box_row_get_index     (GtkListBoxRow *row);
GDK_AVAILABLE_IN_3_10
Alexander Larsson's avatar
Alexander Larsson committed
181 182 183 184 185 186
void       gtk_list_box_row_changed       (GtkListBoxRow *row);


GDK_AVAILABLE_IN_3_10
GType          gtk_list_box_get_type                     (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_10
Paolo Borelli's avatar
Paolo Borelli committed
187 188 189
void           gtk_list_box_prepend                      (GtkListBox                    *list_box,
                                                          GtkWidget                     *child);
GDK_AVAILABLE_IN_3_10
190 191 192 193
void           gtk_list_box_insert                       (GtkListBox                    *list_box,
                                                          GtkWidget                     *child,
                                                          gint                           position);
GDK_AVAILABLE_IN_3_10
Alexander Larsson's avatar
Alexander Larsson committed
194 195 196
GtkListBoxRow* gtk_list_box_get_selected_row             (GtkListBox                    *list_box);
GDK_AVAILABLE_IN_3_10
GtkListBoxRow* gtk_list_box_get_row_at_index             (GtkListBox                    *list_box,
Matthias Clasen's avatar
Matthias Clasen committed
197
                                                          gint                           index_);
Alexander Larsson's avatar
Alexander Larsson committed
198 199 200 201 202 203 204
GDK_AVAILABLE_IN_3_10
GtkListBoxRow* gtk_list_box_get_row_at_y                 (GtkListBox                    *list_box,
                                                          gint                           y);
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_select_row                   (GtkListBox                    *list_box,
                                                          GtkListBoxRow                 *row);
GDK_AVAILABLE_IN_3_10
205 206 207
void           gtk_list_box_set_placeholder              (GtkListBox                    *list_box,
                                                          GtkWidget                     *placeholder);
GDK_AVAILABLE_IN_3_10
Alexander Larsson's avatar
Alexander Larsson committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
void           gtk_list_box_set_adjustment               (GtkListBox                    *list_box,
                                                          GtkAdjustment                 *adjustment);
GDK_AVAILABLE_IN_3_10
GtkAdjustment *gtk_list_box_get_adjustment               (GtkListBox                    *list_box);
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_set_selection_mode           (GtkListBox                    *list_box,
                                                          GtkSelectionMode               mode);
GDK_AVAILABLE_IN_3_10
GtkSelectionMode gtk_list_box_get_selection_mode         (GtkListBox                    *list_box);
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_set_filter_func              (GtkListBox                    *list_box,
                                                          GtkListBoxFilterFunc           filter_func,
                                                          gpointer                       user_data,
                                                          GDestroyNotify                 destroy);
GDK_AVAILABLE_IN_3_10
223 224
void           gtk_list_box_set_header_func              (GtkListBox                    *list_box,
                                                          GtkListBoxUpdateHeaderFunc     update_header,
Alexander Larsson's avatar
Alexander Larsson committed
225 226 227
                                                          gpointer                       user_data,
                                                          GDestroyNotify                 destroy);
GDK_AVAILABLE_IN_3_10
228
void           gtk_list_box_invalidate_filter            (GtkListBox                    *list_box);
Alexander Larsson's avatar
Alexander Larsson committed
229
GDK_AVAILABLE_IN_3_10
230
void           gtk_list_box_invalidate_sort              (GtkListBox                    *list_box);
Alexander Larsson's avatar
Alexander Larsson committed
231
GDK_AVAILABLE_IN_3_10
232
void           gtk_list_box_invalidate_headers           (GtkListBox                    *list_box);
Alexander Larsson's avatar
Alexander Larsson committed
233 234 235 236 237 238 239 240 241
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_set_sort_func                (GtkListBox                    *list_box,
                                                          GtkListBoxSortFunc             sort_func,
                                                          gpointer                       user_data,
                                                          GDestroyNotify                 destroy);
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_set_activate_on_single_click (GtkListBox                    *list_box,
                                                          gboolean                       single);
GDK_AVAILABLE_IN_3_10
242 243
gboolean       gtk_list_box_get_activate_on_single_click (GtkListBox                    *list_box);
GDK_AVAILABLE_IN_3_10
Alexander Larsson's avatar
Alexander Larsson committed
244 245 246 247 248 249 250 251 252 253 254
void           gtk_list_box_drag_unhighlight_row         (GtkListBox                    *list_box);
GDK_AVAILABLE_IN_3_10
void           gtk_list_box_drag_highlight_row           (GtkListBox                    *list_box,
                                                          GtkListBoxRow                 *row);
GDK_AVAILABLE_IN_3_10
GtkWidget*     gtk_list_box_new                          (void);


G_END_DECLS

#endif