diff --git a/branding/launcher.desktop.in b/branding/launcher.desktop.in index 69e3101..2707708 100644 --- a/branding/launcher.desktop.in +++ b/branding/launcher.desktop.in @@ -2,6 +2,7 @@ X-SuSE-translate=true GenericName=@PRODUCT_NAME@ Name=3270 Terminal +Name[pt_BR]=Terminal 3270 Comment=@PACKAGE_DESCRIPTION@ Exec=@PRODUCT_NAME@ Icon=@PRODUCT_NAME@ @@ -9,6 +10,20 @@ Terminal=false Type=Application StartupNotify=true +Actions=gnomeui;classicalui + # https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html Categories=System;TerminalEmulator; +[Desktop Action gnomeui] +Name=New window using modern user interface +Name[pt_BR]=Nova janela usando a interface de usuário atualizada + +Exec=@PRODUCT_NAME@ --user-interface=gnome + +[Desktop Action classicalui] +Name=New window using classical user interface +Name[pt_BR]=Nova janela usando a interface de usuário clássica + +Exec=@PRODUCT_NAME@ --user-interface=classic + diff --git a/src/objects/application/application.c b/src/objects/application/application.c index 24ff9f1..4a0161b 100644 --- a/src/objects/application/application.c +++ b/src/objects/application/application.c @@ -171,48 +171,70 @@ } - static void pw3270Application_init(pw3270Application *app) { -#ifdef _WIN32 - app->ui_style = PW3270_UI_STYLE_CLASSICAL; -#else - app->ui_style = PW3270_UI_STYLE_AUTOMATIC; -#endif // _WIN32 + static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { - // Get settings - { - g_autofree gchar * path = g_strconcat("/apps/" PACKAGE_NAME "/", g_get_application_name(),"/",NULL); - debug("path=%s",path); + GApplication * app = g_application_get_default(); -#ifdef DEBUG - GError * error = NULL; - GSettingsSchemaSource * source = - g_settings_schema_source_new_from_directory( - ".", - NULL, - TRUE, - &error - ); + debug("********************* %p",app); + + g_autoptr(GSettings) app_settings = pw3270_application_settings_new(); + g_autoptr(GSettings) win_settings = pw3270_application_window_settings_new(); + + if(!g_ascii_strcasecmp(value,"gnome")) { + + g_settings_set_uint(app_settings,"ui-style",PW3270_UI_STYLE_GNOME); + g_settings_set_boolean(win_settings,"toolbar-visible",TRUE); + g_settings_set_boolean(win_settings,"menubar-visible",FALSE); + + } else if(!g_ascii_strcasecmp(value,"classic")) { + + g_settings_set_uint(app_settings,"ui-style",PW3270_UI_STYLE_CLASSICAL); + g_settings_set_boolean(win_settings,"toolbar-visible",TRUE); + g_settings_set_boolean(win_settings,"menubar-visible",TRUE); + + } else if(!g_ascii_strcasecmp(value,"default")) { - g_assert_no_error(error); + g_settings_set_uint(app_settings,"ui-style",PW3270_UI_STYLE_AUTOMATIC); - GSettingsSchema * schema = - g_settings_schema_source_lookup( - source, - "br.com.bb." PACKAGE_NAME, - TRUE); + } else { - debug("schema %s=%p","br.com.bb." PACKAGE_NAME,schema); + g_set_error( + error, + g_quark_from_static_string(G_STRINGIFY(PRODUCT_NAME)), + EINVAL, + _( "\"%s\" is not a valid user interface name" ), value + ); + + } + + return TRUE; + + } + + static void pw3270Application_init(pw3270Application *app) { - app->settings = g_settings_new_full(schema, NULL, path); + static GOptionEntry cmd_options[] = { - g_settings_schema_source_unref(source); + { "user-interface", 'U', 0, G_OPTION_ARG_CALLBACK, &on_user_interface, N_( "Set the user-interface type" ), NULL }, + { NULL } + }; + + g_application_add_main_option_entries(G_APPLICATION(app), cmd_options); + +#ifdef _WIN32 + app->ui_style = PW3270_UI_STYLE_CLASSICAL; #else + app->ui_style = PW3270_UI_STYLE_AUTOMATIC; +#endif // _WIN32 - app->settings = g_settings_new_with_path("br.com.bb." PACKAGE_NAME, path); + // Get settings + app->settings = pw3270_application_settings_new(); -#endif // DEBUG + // Bind properties + if(app->settings) { + g_object_ref_sink(G_OBJECT(app->settings)); #ifdef _WIN32 { @@ -225,13 +247,6 @@ } #endif // _WIN32 - debug("app->settings=%p",app->settings); - - } - - // Bind properties - if(app->settings) { - g_object_ref_sink(G_OBJECT(app->settings)); g_settings_bind(app->settings, "ui-style", app, "ui-style", G_SETTINGS_BIND_DEFAULT); } @@ -420,6 +435,47 @@ } + GSettings * pw3270_application_settings_new() { + + GSettings *settings = NULL; + + g_autofree gchar * path = g_strconcat("/apps/" PACKAGE_NAME "/", g_get_application_name(),"/",NULL); + debug("path=%s",path); + +#ifdef DEBUG + GError * error = NULL; + GSettingsSchemaSource * source = + g_settings_schema_source_new_from_directory( + ".", + NULL, + TRUE, + &error + ); + + g_assert_no_error(error); + + GSettingsSchema * schema = + g_settings_schema_source_lookup( + source, + "br.com.bb." PACKAGE_NAME, + TRUE); + + debug("schema %s=%p","br.com.bb." PACKAGE_NAME,schema); + + settings = g_settings_new_full(schema, NULL, path); + + g_settings_schema_source_unref(source); + +#else + + settings = g_settings_new_with_path("br.com.bb." PACKAGE_NAME, path); + +#endif // DEBUG + + return settings; + } + + /* void pw3270_application_plugin_foreach(GApplication *app, GFunc func, gpointer user_data) { diff --git a/src/objects/application/private.h b/src/objects/application/private.h index 1aaf19c..4d3ca77 100644 --- a/src/objects/application/private.h +++ b/src/objects/application/private.h @@ -48,6 +48,7 @@ G_GNUC_INTERNAL void pw3270_application_open(GApplication * application, GFile **files, gint n_files, const gchar *hint); G_GNUC_INTERNAL GtkWidget * pw3270_terminal_new(const gchar *session_file); + G_GNUC_INTERNAL GSettings * pw3270_application_settings_new(); // Actions G_GNUC_INTERNAL GAction * pw3270_about_action_new(); -- libgit2 0.21.2