| 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 |
#include <glib.h> |
| 22 |
#include <glib/gi18n.h> |
| 23 |
#include <gtk/gtk.h> |
| 24 |
|
| 25 |
#include "configurator.h" |
| 26 |
#include "dialog.h" |
| 27 |
|
| 28 |
gboolean status_icon_enabled; |
| 29 |
gboolean launch_to_tray; |
| 30 |
gboolean use_fsid; |
| 31 |
static gboolean status_icon_enabled_by_default; |
| 32 |
static gboolean launch_to_tray_by_default; |
| 33 |
static gboolean use_fsid_by_default; |
| 34 |
GHashTable *openconnect_fsid_table; |
| 35 |
GSettings *settings; |
| 36 |
|
| 37 |
#ifdef HAVE_CONFIG_SETTINGS |
| 38 |
|
| 39 |
void config_load(GtkApplication *app) |
| 40 |
{ |
| 41 |
settings = g_settings_new("net.connman.gtk"); |
| 42 |
g_settings_delay(settings); |
| 43 |
openconnect_fsid_table = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 44 |
g_free, NULL); |
| 45 |
|
| 46 |
status_icon_enabled_by_default = g_settings_get_boolean(settings, |
| 47 |
"status-icon-enabled"); |
| 48 |
status_icon_enabled = status_icon_enabled_by_default; |
| 49 |
|
| 50 |
launch_to_tray_by_default = g_settings_get_boolean(settings, |
| 51 |
"launch-to-tray"); |
| 52 |
launch_to_tray = launch_to_tray_by_default; |
| 53 |
|
| 54 |
use_fsid_by_default = g_settings_get_boolean(settings, |
| 55 |
"openconnect-use-fsid-by-default"); |
| 56 |
use_fsid = use_fsid_by_default; |
| 57 |
} |
| 58 |
|
| 59 |
void config_window_open(GtkApplication *ignored, gpointer user_data) |
| 60 |
{ |
| 61 |
GPtrArray *entries; |
| 62 |
struct token_element *element; |
| 63 |
int index = 0; |
| 64 |
|
| 65 |
entries = g_ptr_array_new_full(1, (GDestroyNotify)free_token_element); |
| 66 |
#ifdef USE_OPENCONNECT |
| 67 |
g_ptr_array_add(entries, |
| 68 |
token_new_checkbox(_("Use fsid with openconnect"), |
| 69 |
use_fsid_by_default)); |
| 70 |
#endif |
| 71 |
#ifdef USE_STATUS_ICON |
| 72 |
g_ptr_array_add(entries, |
| 73 |
token_new_checkbox(_("Use status icon"), |
| 74 |
status_icon_enabled_by_default)); |
| 75 |
g_ptr_array_add(entries, |
| 76 |
token_new_checkbox(_("Launch to tray by default"), |
| 77 |
launch_to_tray_by_default)); |
| 78 |
#endif |
| 79 |
|
| 80 |
if(!dialog_ask_tokens(_("Settings"), entries)) { |
| 81 |
g_ptr_array_free(entries, TRUE); |
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
#ifdef USE_OPENCONNECT |
| 86 |
element = entries->pdata[index]; |
| 87 |
use_fsid_by_default = !!element->value; |
| 88 |
index++; |
| 89 |
g_settings_set_boolean(settings, "openconnect-use-fsid-by-default", |
| 90 |
use_fsid_by_default); |
| 91 |
#endif |
| 92 |
#ifdef USE_STATUS_ICON |
| 93 |
element = entries->pdata[index]; |
| 94 |
status_icon_enabled_by_default = !!element->value; |
| 95 |
index++; |
| 96 |
g_settings_set_boolean(settings, "status-icon-enabled", |
| 97 |
status_icon_enabled_by_default); |
| 98 |
|
| 99 |
element = entries->pdata[index]; |
| 100 |
launch_to_tray_by_default = !!element->value; |
| 101 |
index++; |
| 102 |
g_settings_set_boolean(settings, "launch-to-tray", |
| 103 |
launch_to_tray_by_default); |
| 104 |
#endif |
| 105 |
|
| 106 |
g_ptr_array_free(entries, TRUE); |
| 107 |
|
| 108 |
g_settings_apply(settings); |
| 109 |
} |
| 110 |
|
| 111 |
#else |
| 112 |
|
| 113 |
void config_load(GtkApplication *app) {} |
| 114 |
void config_window_open(gpointer *ignored, gpointer user_data) {} |
| 115 |
|
| 116 |
#endif /* HAVE_CONFIG_SETTINGS */ |