Debian Codegraph @

src/settings_content.h

raw
1 /*
2 * ConnMan GTK GUI
3 *
4 * Copyright (C) 2015 Intel Corporation. All rights reserved.
5 * Author: Jaakko Hannikainen <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _CONNMAN_GTK_SETTINGS_CONTENT_H
22 #define _CONNMAN_GTK_SETTINGS_CONTENT_H
23
24 #include <glib.h>
25
26 #include "settings.h"
27
28 struct settings_content;
29
30 typedef gboolean (*settings_entry_validator)(GtkWidget *entry);
31 typedef gboolean (*settings_writable)(struct settings_content *content);
32 typedef GVariant *(*settings_field_value)(struct settings_content *content);
33
34 struct settings_content {
35 GtkWidget *data;
36 struct settings *sett;
37
38 settings_field_value value;
39 settings_writable writable;
40 void (*free)(void *ptr);
41 const gchar *key;
42 const gchar *subkey;
43 const gchar *secondary_key;
44 };
45
46 gboolean never_write(struct settings_content *content);
47 gboolean always_write(struct settings_content *content);
48 gboolean write_if_selected(struct settings_content *content);
49 gboolean always_valid(GtkWidget *entry);
50
51 void settings_add_content(struct settings_page *page,
52 struct settings_content *content);
53
54 GtkWidget *settings_add_static_text(struct settings_page *page,
55 const gchar *label, const gchar *text);
56 GtkWidget *settings_add_text(struct settings_page *page, const gchar *label,
57 const gchar *key, const gchar *subkey);
58 GtkWidget *settings_add_entry(struct settings *sett, struct settings_page *page,
59 settings_writable writable, const gchar *label,
60 const gchar *key, const gchar *subkey,
61 const gchar *secondary_key,
62 settings_entry_validator valid);
63 GtkWidget *settings_add_switch(struct settings *sett,
64 struct settings_page *page,
65 settings_writable writable, const gchar *label,
66 const gchar *key, const gchar *subkey);
67 GtkWidget *settings_add_combo_box(struct settings *sett,
68 struct settings_page *page,
69 settings_writable writable,
70 const gchar *label,
71 const gchar *key, const gchar *subkey,
72 const gchar *secondary_key);
73 GtkWidget *settings_add_entry_list(struct settings *sett,
74 struct settings_page *page,
75 settings_writable writable,
76 const gchar *label,
77 const gchar *key, const gchar *subkey,
78 const gchar *secondary_key,
79 settings_entry_validator valid);
80 GtkWidget *settings_add_route_list(struct settings *sett,
81 struct settings_page *page,
82 const gchar *key, gboolean labels,
83 settings_writable writable);
84 GtkWidget *settings_add_prefix_entry(struct settings *sett,
85 struct settings_page *page,
86 settings_writable writable);
87
88 void content_add_entry_to_list(GtkWidget *list, const gchar *value);
89
90 void free_content(GtkWidget *widget, gpointer user_data);
91
92 enum content_callback_type {
93 CONTENT_CALLBACK_TYPE_UNKNOWN,
94 CONTENT_CALLBACK_TYPE_TEXT,
95 CONTENT_CALLBACK_TYPE_LIST,
96 CONTENT_CALLBACK_TYPE_ENTRY_LIST,
97 CONTENT_CALLBACK_TYPE_ROUTE_LIST,
98 CONTENT_CALLBACK_TYPE_PREFIX_ENTRY,
99 };
100
101 struct content_callback {
102 enum content_callback_type type;
103 void *data;
104 };
105
106 struct content_callback *create_callback(GtkWidget *label,
107 enum content_callback_type type);
108 void handle_content_callback(GVariant *value, const gchar *key,
109 const gchar *subkey, struct content_callback *cb);
110 void content_callback_free(void *cb);
111
112 #endif /* _CONNMAN_GTK_SETTINGS_CONTENT_H */