summaryrefslogtreecommitdiffstats
path: root/subprojects/libhandy/src/hdy-combo-row.h
blob: 68657a0d7b06ef5436fa9509ce65b03a4d55ad25 (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
/*
 * Copyright (C) 2018 Purism SPC
 *
 * SPDX-License-Identifier: LGPL-2.1+
 */

#pragma once

#if !defined(_HANDY_INSIDE) && !defined(HANDY_COMPILATION)
#error "Only <handy.h> can be included directly."
#endif

#include "hdy-version.h"

#include <gtk/gtk.h>
#include "hdy-enum-value-object.h"
#include "hdy-action-row.h"

G_BEGIN_DECLS

#define HDY_TYPE_COMBO_ROW (hdy_combo_row_get_type())

HDY_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (HdyComboRow, hdy_combo_row, HDY, COMBO_ROW, HdyActionRow)

/**
 * HdyComboRowGetNameFunc:
 * @item: (type GObject): the item from the model from which to get a name
 * @user_data: (closure): user data
 *
 * Called for combo rows that are bound to a #GListModel with
 * hdy_combo_row_bind_name_model() for each item that gets added to the model.
 *
 * Returns: (transfer full): a newly allocated displayable name that represents @item
 */
typedef gchar * (*HdyComboRowGetNameFunc) (gpointer item,
                                           gpointer user_data);

/**
 * HdyComboRowGetEnumValueNameFunc:
 * @value: the value from the enum from which to get a name
 * @user_data: (closure): user data
 *
 * Called for combo rows that are bound to an enumeration with
 * hdy_combo_row_set_for_enum() for each value from that enumeration.
 *
 * Returns: (transfer full): a newly allocated displayable name that represents @value
 */
typedef gchar * (*HdyComboRowGetEnumValueNameFunc) (HdyEnumValueObject *value,
                                                    gpointer            user_data);

/**
 * HdyComboRowClass
 * @parent_class: The parent class
 */
struct _HdyComboRowClass
{
  HdyActionRowClass parent_class;

  /*< private >*/
  gpointer padding[4];
};

HDY_AVAILABLE_IN_ALL
GtkWidget *hdy_combo_row_new (void);

HDY_AVAILABLE_IN_ALL
GListModel *hdy_combo_row_get_model (HdyComboRow *self);

HDY_AVAILABLE_IN_ALL
void hdy_combo_row_bind_model      (HdyComboRow                *self,
                                    GListModel                 *model,
                                    GtkListBoxCreateWidgetFunc  create_list_widget_func,
                                    GtkListBoxCreateWidgetFunc  create_current_widget_func,
                                    gpointer                    user_data,
                                    GDestroyNotify              user_data_free_func);
HDY_AVAILABLE_IN_ALL
void hdy_combo_row_bind_name_model (HdyComboRow            *self,
                                    GListModel             *model,
                                    HdyComboRowGetNameFunc  get_name_func,
                                    gpointer                user_data,
                                    GDestroyNotify          user_data_free_func);
HDY_AVAILABLE_IN_ALL
void hdy_combo_row_set_for_enum    (HdyComboRow                     *self,
                                    GType                            enum_type,
                                    HdyComboRowGetEnumValueNameFunc  get_name_func,
                                    gpointer                         user_data,
                                    GDestroyNotify                   user_data_free_func);

HDY_AVAILABLE_IN_ALL
gint hdy_combo_row_get_selected_index (HdyComboRow *self);
HDY_AVAILABLE_IN_ALL
void hdy_combo_row_set_selected_index (HdyComboRow *self,
                                       gint         selected_index);

HDY_AVAILABLE_IN_ALL
gboolean hdy_combo_row_get_use_subtitle (HdyComboRow *self);
HDY_AVAILABLE_IN_ALL
void     hdy_combo_row_set_use_subtitle (HdyComboRow *self,
                                         gboolean     use_subtitle);

HDY_AVAILABLE_IN_ALL
void hdy_combo_row_set_get_name_func (HdyComboRow            *self,
                                      HdyComboRowGetNameFunc  get_name_func,
                                      gpointer                user_data,
                                      GDestroyNotify          user_data_free_func);

HDY_AVAILABLE_IN_ALL
gchar *hdy_enum_value_row_name (HdyEnumValueObject *value,
                                gpointer            user_data);

G_END_DECLS