Commit 2fae538c7c377b844b384ca92159d5010fe7f113

Authored by Perry Werneck
1 parent 4aabe9be

Looks like ubuntu doesn't support the application menu (too bad). Changing the

windows settings to update the ui model on the first run based on the
presence of the application menu.
schemas/linux/application.gschema.xml.in
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 <schema id="br.com.bb.@PACKAGE_NAME@"> 33 <schema id="br.com.bb.@PACKAGE_NAME@">
34 34
35 <key name="ui-style" type="u"> 35 <key name="ui-style" type="u">
36 - <default>1</default> 36 + <default>2</default>
37 <summary>UI Style</summary> 37 <summary>UI Style</summary>
38 <description>The ID of the current user interface style</description> 38 <description>The ID of the current user interface style</description>
39 </key> 39 </key>
src/include/pw3270/application.h
@@ -55,6 +55,7 @@ @@ -55,6 +55,7 @@
55 typedef enum _pw3270_ui_style { 55 typedef enum _pw3270_ui_style {
56 PW3270_UI_STYLE_CLASSICAL, ///< @brief Interface "classica", com menu e toolbar. 56 PW3270_UI_STYLE_CLASSICAL, ///< @brief Interface "classica", com menu e toolbar.
57 PW3270_UI_STYLE_GNOME, ///< @brief Interface padrão gnome. 57 PW3270_UI_STYLE_GNOME, ///< @brief Interface padrão gnome.
  58 + PW3270_UI_STYLE_AUTOMATIC, ///< @brief Auto defined UI-Style
58 } PW3270_UI_STYLE; 59 } PW3270_UI_STYLE;
59 60
60 61
src/objects/application/application.c
@@ -157,11 +157,11 @@ @@ -157,11 +157,11 @@
157 _("UI Type"), 157 _("UI Type"),
158 _("The code of the User interface type"), 158 _("The code of the User interface type"),
159 PW3270_UI_STYLE_CLASSICAL, 159 PW3270_UI_STYLE_CLASSICAL,
160 - PW3270_UI_STYLE_GNOME, 160 + PW3270_UI_STYLE_AUTOMATIC,
161 #ifdef _WIN32 161 #ifdef _WIN32
162 PW3270_UI_STYLE_CLASSICAL, 162 PW3270_UI_STYLE_CLASSICAL,
163 #else 163 #else
164 - PW3270_UI_STYLE_GNOME, 164 + PW3270_UI_STYLE_AUTOMATIC,
165 #endif // _WIN32 165 #endif // _WIN32
166 G_PARAM_READABLE|G_PARAM_WRITABLE 166 G_PARAM_READABLE|G_PARAM_WRITABLE
167 ); 167 );
@@ -176,7 +176,7 @@ @@ -176,7 +176,7 @@
176 #ifdef _WIN32 176 #ifdef _WIN32
177 app->ui_style = PW3270_UI_STYLE_CLASSICAL; 177 app->ui_style = PW3270_UI_STYLE_CLASSICAL;
178 #else 178 #else
179 - app->ui_style = PW3270_UI_STYLE_GNOME; 179 + app->ui_style = PW3270_UI_STYLE_AUTOMATIC;
180 #endif // _WIN32 180 #endif // _WIN32
181 181
182 // Get settings 182 // Get settings
src/objects/window/window.c
@@ -346,7 +346,22 @@ @@ -346,7 +346,22 @@
346 { 346 {
347 g_autoptr(GSettings) settings = pw3270_application_window_settings_new(); 347 g_autoptr(GSettings) settings = pw3270_application_window_settings_new();
348 348
349 - if(pw3270_application_get_ui_style(G_APPLICATION(application)) == PW3270_UI_STYLE_GNOME) { 349 + PW3270_UI_STYLE style = pw3270_application_get_ui_style(G_APPLICATION(application));
  350 +
  351 + if(style == PW3270_UI_STYLE_AUTOMATIC) {
  352 +
  353 + if(gtk_application_get_app_menu(application)) {
  354 + style = PW3270_UI_STYLE_GNOME;
  355 + } else {
  356 + style = PW3270_UI_STYLE_CLASSICAL;
  357 + g_settings_set_boolean(settings,"menubar-visible",TRUE);
  358 + g_settings_set_boolean(settings,"toolbar-visible",TRUE);
  359 + }
  360 +
  361 + pw3270_application_set_ui_style(G_APPLICATION(application),style);
  362 + }
  363 +
  364 + if(style == PW3270_UI_STYLE_GNOME) {
350 365
351 // Create header bar 366 // Create header bar
352 367