Commit 9b7064fea49b1e3d041dcdbf9a24acedca63e3c3
1 parent
f94606ed
Exists in
master
and in
1 other branch
Adding convenience method to getting booleans from GSettings.
Showing
5 changed files
with
41 additions
and
24 deletions
Show diff stats
src/include/pw3270/application.h
@@ -72,6 +72,10 @@ void pw3270_application_open_file(GtkApplication *application, GtkWindow **w | @@ -72,6 +72,10 @@ void pw3270_application_open_file(GtkApplication *application, GtkWindow **w | ||
72 | /// @return The internal settings object (Do not unref it). | 72 | /// @return The internal settings object (Do not unref it). |
73 | GSettings * pw3270_application_settings_new(); | 73 | GSettings * pw3270_application_settings_new(); |
74 | GSettings * pw3270_application_get_settings(GApplication *app); | 74 | GSettings * pw3270_application_get_settings(GApplication *app); |
75 | + | ||
76 | +/// @brief Get boolean from gsettings. | ||
77 | +gboolean pw3270_application_get_boolean(GApplication *app, const gchar *option_name, gboolean def); | ||
78 | + | ||
75 | GList * pw3270_application_get_keypad_models(GApplication *app); | 79 | GList * pw3270_application_get_keypad_models(GApplication *app); |
76 | 80 | ||
77 | void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type); | 81 | void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type); |
src/objects/application/application.c
@@ -427,7 +427,7 @@ void startup(GApplication *application) { | @@ -427,7 +427,7 @@ void startup(GApplication *application) { | ||
427 | 427 | ||
428 | G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application); | 428 | G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application); |
429 | 429 | ||
430 | - GSettings *settings = pw3270_application_get_settings(application); | 430 | +// GSettings *settings = pw3270_application_get_settings(application); |
431 | 431 | ||
432 | // | 432 | // |
433 | // Common actions | 433 | // Common actions |
@@ -445,14 +445,14 @@ void startup(GApplication *application) { | @@ -445,14 +445,14 @@ void startup(GApplication *application) { | ||
445 | // | 445 | // |
446 | // Open session actions. | 446 | // Open session actions. |
447 | // | 447 | // |
448 | - if(g_settings_get_boolean(settings,"allow-open-session-actions")) { | 448 | + if(pw3270_application_get_boolean(application,"allow-open-session-actions",TRUE)) { |
449 | g_action_map_add_action(G_ACTION_MAP(application),pw3270_open_session_action_new()); | 449 | g_action_map_add_action(G_ACTION_MAP(application),pw3270_open_session_action_new()); |
450 | } | 450 | } |
451 | 451 | ||
452 | // | 452 | // |
453 | // New tab actions | 453 | // New tab actions |
454 | // | 454 | // |
455 | - if(g_settings_get_boolean(settings,"allow-new-tab-actions")) { | 455 | + if(pw3270_application_get_boolean(application,"allow-new-tab-actions",TRUE)) { |
456 | 456 | ||
457 | GAction * new_tab_actions[] = { | 457 | GAction * new_tab_actions[] = { |
458 | pw3270_open_tab_action_new(), | 458 | pw3270_open_tab_action_new(), |
@@ -468,7 +468,7 @@ void startup(GApplication *application) { | @@ -468,7 +468,7 @@ void startup(GApplication *application) { | ||
468 | // | 468 | // |
469 | // New window actions | 469 | // New window actions |
470 | // | 470 | // |
471 | - if(g_settings_get_boolean(settings,"allow-new-window-actions")) { | 471 | + if(pw3270_application_get_boolean(application,"allow-new-window-actions",TRUE)) { |
472 | 472 | ||
473 | GAction * new_window_actions[] = { | 473 | GAction * new_window_actions[] = { |
474 | pw3270_open_window_action_new(), | 474 | pw3270_open_window_action_new(), |
@@ -557,10 +557,13 @@ PW3270_UI_STYLE pw3270_application_get_ui_style(GApplication *app) { | @@ -557,10 +557,13 @@ PW3270_UI_STYLE pw3270_application_get_ui_style(GApplication *app) { | ||
557 | } | 557 | } |
558 | 558 | ||
559 | GSettings * pw3270_application_get_settings(GApplication *app) { | 559 | GSettings * pw3270_application_get_settings(GApplication *app) { |
560 | - | ||
561 | g_return_val_if_fail(PW3270_IS_APPLICATION(app),NULL); | 560 | g_return_val_if_fail(PW3270_IS_APPLICATION(app),NULL); |
562 | return PW3270_APPLICATION(app)->settings; | 561 | return PW3270_APPLICATION(app)->settings; |
562 | +} | ||
563 | 563 | ||
564 | +gboolean pw3270_application_get_boolean(GApplication *app, const gchar *option_name, gboolean def) { | ||
565 | + g_return_val_if_fail(PW3270_IS_APPLICATION(app),def); | ||
566 | + return g_settings_get_boolean(PW3270_APPLICATION(app)->settings,option_name); | ||
564 | } | 567 | } |
565 | 568 | ||
566 | GSList * pw3270_application_get_plugins(GApplication *app) { | 569 | GSList * pw3270_application_get_plugins(GApplication *app) { |
src/objects/window/actions/sessionproperties.c
@@ -43,29 +43,35 @@ GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { | @@ -43,29 +43,35 @@ GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { | ||
43 | 43 | ||
44 | size_t ix; | 44 | size_t ix; |
45 | 45 | ||
46 | - GSettings *settings = pw3270_application_get_settings(g_application_get_default()); | 46 | + GApplication *application = g_application_get_default(); |
47 | +// GSettings *settings = pw3270_application_get_settings(g_application_get_default()); | ||
47 | 48 | ||
48 | GtkWidget * dialog = v3270_settings_dialog_new(); | 49 | GtkWidget * dialog = v3270_settings_dialog_new(); |
49 | gtk_window_set_title(GTK_WINDOW(dialog), action->label); | 50 | gtk_window_set_title(GTK_WINDOW(dialog), action->label); |
50 | 51 | ||
51 | - // Add settings pages. | ||
52 | - GtkWidget * elements[] = { | ||
53 | - v3270_color_settings_new(), | ||
54 | - v3270_font_settings_new(), | ||
55 | - v3270_accelerator_settings_new(), | ||
56 | - v3270_clipboard_settings_new() | ||
57 | - }; | ||
58 | - | ||
59 | - if(g_settings_get_boolean(settings,"allow-host-settings")) { | 52 | + // Host settings is conditional. |
53 | + if(pw3270_application_get_boolean(application,"allow-host-settings",TRUE)) { | ||
60 | gtk_container_add(GTK_CONTAINER(dialog), v3270_host_settings_new()); | 54 | gtk_container_add(GTK_CONTAINER(dialog), v3270_host_settings_new()); |
61 | } | 55 | } |
62 | 56 | ||
63 | - for(ix = 0; ix < G_N_ELEMENTS(elements); ix++) { | ||
64 | - gtk_container_add(GTK_CONTAINER(dialog), elements[ix]); | 57 | + // Add commom settings. |
58 | + { | ||
59 | + | ||
60 | + GtkWidget * elements[] = { | ||
61 | + v3270_color_settings_new(), | ||
62 | + v3270_font_settings_new(), | ||
63 | + v3270_accelerator_settings_new(), | ||
64 | + v3270_clipboard_settings_new() | ||
65 | + }; | ||
66 | + | ||
67 | + for(ix = 0; ix < G_N_ELEMENTS(elements); ix++) { | ||
68 | + gtk_container_add(GTK_CONTAINER(dialog), elements[ix]); | ||
69 | + } | ||
70 | + | ||
65 | } | 71 | } |
66 | 72 | ||
67 | pw3270_application_plugin_call( | 73 | pw3270_application_plugin_call( |
68 | - g_application_get_default(), | 74 | + application, |
69 | "pw3270_plugin_set_session_properties", | 75 | "pw3270_plugin_set_session_properties", |
70 | dialog | 76 | dialog |
71 | ); | 77 | ); |
src/objects/window/keyfile.c
@@ -216,16 +216,20 @@ V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, G | @@ -216,16 +216,20 @@ V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, G | ||
216 | 216 | ||
217 | if(!*error) { | 217 | if(!*error) { |
218 | 218 | ||
219 | - GSettings * settings = pw3270_application_get_settings(g_application_get_default()); | 219 | + GApplication *application = g_application_get_default(); |
220 | 220 | ||
221 | - if(settings && g_settings_get_boolean(settings,"update-default-session-file")) { | 221 | + if(pw3270_application_get_boolean(application,"update-default-session-file",TRUE)) { |
222 | 222 | ||
223 | - g_message("Updating default session file to '%s'",filename); | ||
224 | - g_settings_set_string(settings,"default-session-file",filename); | 223 | + GSettings * settings = pw3270_application_get_settings(application); |
224 | + | ||
225 | + if(settings) { | ||
226 | + g_message("Updating default session file to '%s'",filename); | ||
227 | + g_settings_set_string(settings,"default-session-file",filename); | ||
228 | + } | ||
225 | 229 | ||
226 | } | 230 | } |
227 | 231 | ||
228 | - if(settings && g_settings_get_boolean(settings,"add-session-to-recent-manager")) { | 232 | + if(pw3270_application_get_boolean(application,"add-session-to-recent-manager",TRUE)) { |
229 | 233 | ||
230 | // new_session->key_file | 234 | // new_session->key_file |
231 | g_autofree gchar * display_name = g_key_file_get_string(new_session->key_file,"terminal","session-name",NULL); | 235 | g_autofree gchar * display_name = g_key_file_get_string(new_session->key_file,"terminal","session-name",NULL); |
win/pack.sh
@@ -170,7 +170,7 @@ configure() | @@ -170,7 +170,7 @@ configure() | ||
170 | if [ -x ./autogen.sh ]; then | 170 | if [ -x ./autogen.sh ]; then |
171 | NOCONFIGURE=1 ./autogen.sh | 171 | NOCONFIGURE=1 ./autogen.sh |
172 | if [ "$?" != "0" ]; then | 172 | if [ "$?" != "0" ]; then |
173 | - failed "Erro em autogen.sh" | 173 | + failed "autogen.sh has failed" |
174 | fi | 174 | fi |
175 | fi | 175 | fi |
176 | done | 176 | done |