Commit ef6f40599108b2e6f18ba2a654abe2045d8bc54a

Authored by Perry Werneck
Committed by GitHub
2 parents 9c59f578 66950f3d
Exists in master and in 1 other branch develop

Merge pull request #40 from PerryWerneck/develop

Updating master with latest changes.
@@ -34,5 +34,9 @@ build() { @@ -34,5 +34,9 @@ build() {
34 package() { 34 package() {
35 cd $pkgname-$pkgver 35 cd $pkgname-$pkgver
36 DESTDIR="$pkgdir" make install 36 DESTDIR="$pkgdir" make install
  37 +
  38 + # Remove compiled schema.
  39 + rm -f $pkgdir/usr/share/glib-2.0/schemas/gschemas.compiled
  40 +
37 } 41 }
38 42
@@ -53,11 +53,11 @@ @@ -53,11 +53,11 @@
53 <param name="outfilename">debian.shlibs</param> 53 <param name="outfilename">debian.shlibs</param>
54 </service --> 54 </service -->
55 55
56 - <service name="extract_file"> 56 + <!-- service name="extract_file">
57 <param name="archive">*.tar</param> 57 <param name="archive">*.tar</param>
58 <param name="files">*/arch/PKGBUILD</param> 58 <param name="files">*/arch/PKGBUILD</param>
59 <param name="outfilename">PKGBUILD</param> 59 <param name="outfilename">PKGBUILD</param>
60 - </service> 60 + </service -->
61 61
62 <service name="recompress"> 62 <service name="recompress">
63 <param name="file">*.tar</param> 63 <param name="file">*.tar</param>
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/main/builder.c
@@ -21,7 +21,8 @@ @@ -21,7 +21,8 @@
21 #include <pw3270/application.h> 21 #include <pw3270/application.h>
22 #include <pw3270/keypad.h> 22 #include <pw3270/keypad.h>
23 23
24 - static GMenu * get_keypad_menu(GApplication *application) { 24 + /*
  25 + static GMenu * keypad_menu_new(GApplication *application) {
25 26
26 GList * keypads = pw3270_application_get_keypad_models(application); 27 GList * keypads = pw3270_application_get_keypad_models(application);
27 28
@@ -41,6 +42,7 @@ @@ -41,6 +42,7 @@
41 return menu; 42 return menu;
42 43
43 } 44 }
  45 + */
44 46
45 GtkBuilder * pw3270_application_builder_new(GApplication *application) { 47 GtkBuilder * pw3270_application_builder_new(GApplication *application) {
46 48
@@ -100,11 +102,13 @@ @@ -100,11 +102,13 @@
100 // 102 //
101 // View options 103 // View options
102 // 104 //
103 - GMenu * keypad_menu = get_keypad_menu(application); 105 + GList * keypads = pw3270_application_get_keypad_models(application);
104 106
105 - if(keypad_menu) { 107 + if(keypads) {
106 108
107 static const gchar * placeholders[] = { 109 static const gchar * placeholders[] = {
  110 + "app-menu-view-placeholder",
  111 + "top-menu-view-placeholder",
108 "view-menu-placeholder", 112 "view-menu-placeholder",
109 "view-when-offline-placeholder", 113 "view-when-offline-placeholder",
110 "view-when-online-placeholder" 114 "view-when-online-placeholder"
@@ -114,13 +118,33 @@ @@ -114,13 +118,33 @@
114 118
115 placeholder = gtk_builder_get_object(builder, placeholders[ix]); 119 placeholder = gtk_builder_get_object(builder, placeholders[ix]);
116 120
117 - if(placeholder && G_IS_MENU(placeholder)) {  
118 - g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(keypad_menu))); 121 + if(placeholder) {
  122 +
  123 + if(G_IS_MENU(placeholder)) {
  124 +
  125 + GMenu * menu = g_menu_new();
  126 +
  127 + // Create keypad items.
  128 + GList *item;
  129 + for(item = keypads; item; item = g_list_next(item)) {
  130 + GObject * model = G_OBJECT(item->data);
  131 + g_autofree gchar * action_name = g_strconcat("win.keypad.",pw3270_keypad_model_get_name(model),NULL);
  132 + g_menu_append(menu,pw3270_keypad_model_get_label(model),action_name);
  133 + }
  134 +
  135 + g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(menu)));
  136 +
  137 + g_object_unref(menu);
  138 +
  139 + } else {
  140 +
  141 + g_message("Placeholder '%s' is invalid",placeholders[ix]);
  142 +
  143 + }
119 } 144 }
120 145
121 } 146 }
122 147
123 - g_object_unref(keypad_menu);  
124 } 148 }
125 149
126 return builder; 150 return builder;
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(),
@@ -482,11 +482,6 @@ void startup(GApplication *application) { @@ -482,11 +482,6 @@ void startup(GApplication *application) {
482 } 482 }
483 483
484 // 484 //
485 - // Setup application menus  
486 - //  
487 - g_autoptr(GtkBuilder) builder = pw3270_application_builder_new(application);  
488 -  
489 - //  
490 // Load keypad models 485 // Load keypad models
491 // 486 //
492 { 487 {
@@ -511,6 +506,11 @@ void startup(GApplication *application) { @@ -511,6 +506,11 @@ void startup(GApplication *application) {
511 } 506 }
512 } 507 }
513 508
  509 + //
  510 + // Setup application menus
  511 + //
  512 + g_autoptr(GtkBuilder) builder = pw3270_application_builder_new(application);
  513 +
514 if(gtk_application_prefers_app_menu(GTK_APPLICATION(application))) 514 if(gtk_application_prefers_app_menu(GTK_APPLICATION(application)))
515 gtk_application_set_app_menu(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "app-menu"))); 515 gtk_application_set_app_menu(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "app-menu")));
516 516
@@ -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);
ui/linux.ui.xml
@@ -330,7 +330,7 @@ @@ -330,7 +330,7 @@
330 330
331 </submenu> 331 </submenu>
332 332
333 - <submenu id="view-menu-placeholder"> 333 + <submenu id="top-menu-view-placeholder">
334 334
335 <attribute name='label' translatable='yes'>_View</attribute> 335 <attribute name='label' translatable='yes'>_View</attribute>
336 336
ui/macos.ui.xml
@@ -330,7 +330,7 @@ @@ -330,7 +330,7 @@
330 330
331 </submenu> 331 </submenu>
332 332
333 - <submenu id="view-menu-placeholder"> 333 + <submenu id="top-menu-view-placeholder">
334 334
335 <attribute name='label' translatable='yes'>_View</attribute> 335 <attribute name='label' translatable='yes'>_View</attribute>
336 336
ui/windows.ui.xml
@@ -330,7 +330,7 @@ @@ -330,7 +330,7 @@
330 330
331 </submenu> 331 </submenu>
332 332
333 - <submenu id="view-menu-placeholder"> 333 + <submenu id="top-menu-view-placeholder">
334 334
335 <attribute name='label' translatable='yes'>_View</attribute> 335 <attribute name='label' translatable='yes'>_View</attribute>
336 336
@@ -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