diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 28d337c..3dbe648 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-28 16:00-0300\n" -"PO-Revision-Date: 2020-08-28 16:02-0300\n" +"POT-Creation-Date: 2020-09-15 14:25-0300\n" +"PO-Revision-Date: 2020-09-15 14:26-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português <>\n" "Language: pt_BR\n" @@ -20,7 +20,7 @@ msgstr "" "11) ? 2 : 3;\n" "X-Generator: Gtranslator 2.91.7\n" -#: src/objects/application/application.c:208 +#: src/objects/application/application.c:206 #, c-format msgid "\"%s\" is not a valid user interface name" msgstr "\"%s\" não é um nome válido para interface de usuário" @@ -46,7 +46,7 @@ msgstr "Linux 64 bits" msgid "64 bits Windows" msgstr "Windows 64 bits" -#: src/objects/application/actions/about.c:182 ui/application.xml:39 +#: src/objects/application/actions/about.c:188 ui/application.xml:39 #: ui/application.xml:537 msgid "About PW3270" msgstr "Sobre o PW3270" @@ -55,7 +55,7 @@ msgstr "Sobre o PW3270" msgid "Action Name" msgstr "Nome da ação" -#: src/objects/window/window.c:163 src/objects/toolbar/toolbar.c:135 +#: src/objects/window/window.c:164 src/objects/toolbar/toolbar.c:135 msgid "Action Names" msgstr "Nome das ações" @@ -83,7 +83,7 @@ msgstr "Aplicação" msgid "Application preferences" msgstr "Preferências da aplicação" -#: src/objects/window/page.c:263 +#: src/objects/window/page.c:264 msgid "Apply" msgstr "Aplicar" @@ -111,17 +111,22 @@ msgstr "Cursor piscante" msgid "Bold" msgstr "Negrito" -#: src/objects/window/terminal.c:197 +#: src/objects/actions/save.c:110 src/objects/window/terminal.c:171 +msgid "Can't load session file" +msgstr "Não foi possível carregar arquivo de sessão" + +#: src/objects/actions/save.c:105 #, c-format -msgid "Can't save file \"%s\"" -msgstr "Não foi possível salvar arquivo \"%s\"" +msgid "Can't open \"%s\"" +msgstr "Não foi possível abrir %s" -#: src/objects/window/terminal.c:202 -msgid "Can't save session file" -msgstr "Não foi possível salvar arquivo de sessão" +#: src/objects/window/terminal.c:166 +#, c-format +msgid "Can't use \"%s\"" +msgstr "Não posso usar %s" -#: src/objects/actions/save.c:65 src/objects/application/actions/open.c:49 -#: src/objects/window/page.c:264 +#: src/objects/actions/save.c:66 src/objects/application/actions/open.c:49 +#: src/objects/window/page.c:265 msgid "Cancel" msgstr "_Cancelar" @@ -155,10 +160,6 @@ msgstr "Fechar janela" msgid "Colors" msgstr "Cores" -#: src/objects/linux/savedesktopicon.c:93 -msgid "Comment" -msgstr "Comentário" - #: src/objects/window/actions/connect.c:59 msgid "Connect" msgstr "Conectar" @@ -171,7 +172,7 @@ msgstr "Conectar ao iniciar" msgid "Connect to host" msgstr "Conectar ao servidor" -#: src/objects/window/window.c:702 src/objects/window/page.c:217 +#: src/objects/window/window.c:703 src/objects/window/page.c:218 msgid "Connected to host" msgstr "Conectado no servidor" @@ -191,7 +192,7 @@ msgstr "Copiar como tabela" msgid "Copy as text" msgstr "Copiar como texto" -#: src/objects/linux/savedesktopicon.c:106 +#: src/objects/windows/savedesktopicon.c:85 msgid "Create a desktop icon for the current session" msgstr "Criar ícone da área de trabalho para a sessão atual." @@ -219,6 +220,10 @@ msgstr "Recortar" msgid "Delete Field" msgstr "Apagar campo" +#: src/objects/windows/savedesktopicon.c:73 +msgid "Description" +msgstr "Descrição" + #: ui/window.xml:93 ui/application.xml:158 msgid "Desktop icon" msgstr "Ícone da área de trabalho" @@ -227,8 +232,8 @@ msgstr "Ícone da área de trabalho" msgid "Disconnect" msgstr "Desconectar" -#: src/objects/window/window.c:702 src/objects/window/window.c:729 -#: src/objects/window/page.c:206 +#: src/objects/window/window.c:703 src/objects/window/window.c:730 +#: src/objects/window/page.c:207 msgid "Disconnected from host" msgstr "Desconectado do servidor" @@ -272,10 +277,6 @@ msgstr "Apagar até o final da linha" msgid "Field attributes" msgstr "Mostra atributos de campo" -#: src/objects/linux/savedesktopicon.c:72 -msgid "File name" -msgstr "Nome do arquivo" - #: ui/application.xml:454 msgid "Full Screen" msgstr "Tela cheia" @@ -288,10 +289,6 @@ msgstr "Tela cheia" msgid "Function bar" msgstr "Barra de funções" -#: src/objects/linux/savedesktopicon.c:86 -msgid "Generic name" -msgstr "Nome genérico" - #: ui/application.xml:36 ui/application.xml:534 msgid "Help" msgstr "Ajuda" @@ -300,7 +297,7 @@ msgstr "Ajuda" msgid "Host properties" msgstr "Propriedades do Servidor" -#: src/objects/window/window.c:469 +#: src/objects/window/window.c:470 src/objects/windows/savedesktopicon.c:213 msgid "IBM 3270 Terminal emulator" msgstr "Emulador 3270" @@ -368,8 +365,7 @@ msgstr "Largura do painel em colunas" msgid "Keypads" msgstr "Painéis" -#: src/objects/application/actions/about.c:138 -msgctxt "LicenseFileName" +#: src/objects/application/actions/about.c:140 msgid "LICENSE" msgstr "LICENCA" @@ -381,7 +377,7 @@ msgstr "Etiqueta" msgid "Large" msgstr "Grande" -#: src/objects/linux/savedesktopicon.c:79 +#: src/objects/windows/savedesktopicon.c:68 msgid "Launcher name" msgstr "Nome do lançador" @@ -433,7 +429,7 @@ msgstr "Só Maiúsculas" msgid "Network keep alive" msgstr "Network keep alive" -#: src/objects/window/page.c:274 +#: src/objects/window/page.c:275 msgid "New session name" msgstr "Novo nome de sessão" @@ -530,7 +526,7 @@ msgstr "Propriedade \"%s\" é inválida para este objeto" msgid "Quit" msgstr "Sair" -#: src/objects/window/page.c:261 +#: src/objects/window/page.c:262 msgid "Rename Session" msgstr "Renomear sessão" @@ -550,15 +546,15 @@ msgstr "Painel direito" msgid "S_tyle" msgstr "E_stilo" -#: src/objects/actions/save.c:64 ui/window.xml:69 ui/application.xml:134 +#: src/objects/actions/save.c:65 ui/window.xml:69 ui/application.xml:134 msgid "Save" msgstr "Salvar" -#: src/objects/actions/save.c:49 +#: src/objects/actions/save.c:50 msgid "Save As" msgstr "Salvar Como" -#: src/objects/linux/savedesktopicon.c:105 +#: src/objects/windows/savedesktopicon.c:84 msgid "Save desktop icon" msgstr "Salvar ícone da área de trabalho" @@ -570,7 +566,7 @@ msgstr "Salvar tela" msgid "Save selected" msgstr "Salvar seleção" -#: src/objects/actions/save.c:51 +#: src/objects/actions/save.c:52 msgid "Save session properties" msgstr "Salvar propriedades da sessão" @@ -637,7 +633,7 @@ msgstr "Sessão em nova janela" msgid "Session properties" msgstr "Propriedades da sessão" -#: src/objects/application/application.c:221 +#: src/objects/application/application.c:219 msgid "Set the user-interface type" msgstr "Define o tipo de interface do usuário" @@ -729,7 +725,7 @@ msgstr "A etiqueta da ação" msgid "The name of associated action" msgstr "Nome da ação associada" -#: src/objects/window/window.c:164 +#: src/objects/window/window.c:165 msgid "The name of the actions in the header bar" msgstr "O nome das ações na barra de título" @@ -820,7 +816,7 @@ msgstr "Versão %s-%s" msgid "View" msgstr "Exibir" -#: src/objects/application/actions/about.c:157 +#: src/objects/application/actions/about.c:163 msgid "View this project on github" msgstr "Portal do Software Público Brasileiro" @@ -832,11 +828,11 @@ msgstr "Janela com sessão padrão" msgid "_Apply" msgstr "_Aplicar" -#: src/objects/settings/dialog.c:78 src/objects/linux/savedesktopicon.c:132 +#: src/objects/settings/dialog.c:78 src/objects/windows/savedesktopicon.c:110 msgid "_Cancel" msgstr "_Cancelar" -#: src/objects/window/page.c:394 +#: src/objects/window/page.c:395 msgid "_Close session" msgstr "_Fechar sessão" @@ -872,11 +868,11 @@ msgstr "_Abrir" msgid "_Properties" msgstr "_Propriedades" -#: src/objects/window/page.c:388 +#: src/objects/window/page.c:389 msgid "_Rename session" msgstr "Renomear sessão" -#: src/objects/linux/savedesktopicon.c:133 +#: src/objects/windows/savedesktopicon.c:111 msgid "_Save" msgstr "_Salvar" @@ -884,11 +880,11 @@ msgstr "_Salvar" msgid "_View" msgstr "_Exibir" -#: src/objects/application/actions/about.c:156 +#: src/objects/application/actions/about.c:162 msgid "https://github.com/PerryWerneck/pw3270" msgstr "https://portal.softwarepublico.gov.br/social/pw3270/" -#: src/objects/application/actions/about.c:159 +#: src/objects/application/actions/about.c:165 msgid "translator-credits" msgstr "translator-credits" @@ -1323,9 +1319,6 @@ msgstr "translator-credits" #~ msgid "Can't load plugin %s" #~ msgstr "Não foi possível carregar plugin %s" -#~ msgid "Can't open %s" -#~ msgstr "Não foi possível abrir %s" - #~ msgid "Can't open CRL File" #~ msgstr "Não foi possível abrir arquivo CRL" @@ -1371,9 +1364,6 @@ msgstr "translator-credits" #~ msgid "Can't save \"%s\": %s" #~ msgstr "Não foi possível salvar %s: %s" -#~ msgid "Can't save %s" -#~ msgstr "Não foi possível salvar arquivo %s" - #~ msgid "" #~ "Can't save copy to file\n" #~ "%s" @@ -1381,6 +1371,9 @@ msgstr "translator-credits" #~ "Não foi possível salvar cópia para o arquivo\n" #~ "%s" +#~ msgid "Can't save file \"%s\"" +#~ msgstr "Não foi possível salvar arquivo \"%s\"" + #~ msgid "" #~ "Can't save screen to file\n" #~ "%s" @@ -1544,6 +1537,9 @@ msgstr "translator-credits" #~ msgid "Command to execute" #~ msgstr "Comando a executar" +#~ msgid "Comment" +#~ msgstr "Comentário" + #~ msgid "Complete" #~ msgstr "Completo" @@ -1799,6 +1795,9 @@ msgstr "translator-credits" #~ msgid "File _Format" #~ msgstr "_Formato do arquivo" +#~ msgid "File name" +#~ msgstr "Nome do arquivo" + #~ msgid "File transfer complete" #~ msgstr "Transferência completa" @@ -1869,6 +1868,9 @@ msgstr "translator-credits" #~ msgid "GTK Version mismatch" #~ msgstr "Divergência de versão GTK" +#~ msgid "Generic name" +#~ msgstr "Nome genérico" + #~ msgid "Get transfer queue from an external XML file" #~ msgstr "Obtém a fila de transferência de um arquivo XML externo" diff --git a/locale/pw3270.pot b/locale/pw3270.pot index c8c7c7a..b174e4d 100644 --- a/locale/pw3270.pot +++ b/locale/pw3270.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-28 16:00-0300\n" +"POT-Creation-Date: 2020-09-15 14:25-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/objects/application/application.c:208 +#: src/objects/application/application.c:206 #, c-format msgid "\"%s\" is not a valid user interface name" msgstr "" @@ -43,7 +43,7 @@ msgstr "" msgid "64 bits Windows" msgstr "" -#: src/objects/application/actions/about.c:182 ui/application.xml:39 +#: src/objects/application/actions/about.c:188 ui/application.xml:39 #: ui/application.xml:537 msgid "About PW3270" msgstr "" @@ -52,7 +52,7 @@ msgstr "" msgid "Action Name" msgstr "" -#: src/objects/window/window.c:163 src/objects/toolbar/toolbar.c:135 +#: src/objects/window/window.c:164 src/objects/toolbar/toolbar.c:135 msgid "Action Names" msgstr "" @@ -80,7 +80,7 @@ msgstr "" msgid "Application preferences" msgstr "" -#: src/objects/window/page.c:263 +#: src/objects/window/page.c:264 msgid "Apply" msgstr "" @@ -108,17 +108,22 @@ msgstr "" msgid "Bold" msgstr "" -#: src/objects/window/terminal.c:197 +#: src/objects/actions/save.c:110 src/objects/window/terminal.c:171 +msgid "Can't load session file" +msgstr "" + +#: src/objects/actions/save.c:105 #, c-format -msgid "Can't save file \"%s\"" +msgid "Can't open \"%s\"" msgstr "" -#: src/objects/window/terminal.c:202 -msgid "Can't save session file" +#: src/objects/window/terminal.c:166 +#, c-format +msgid "Can't use \"%s\"" msgstr "" -#: src/objects/actions/save.c:65 src/objects/application/actions/open.c:49 -#: src/objects/window/page.c:264 +#: src/objects/actions/save.c:66 src/objects/application/actions/open.c:49 +#: src/objects/window/page.c:265 msgid "Cancel" msgstr "" @@ -152,10 +157,6 @@ msgstr "" msgid "Colors" msgstr "" -#: src/objects/linux/savedesktopicon.c:93 -msgid "Comment" -msgstr "" - #: src/objects/window/actions/connect.c:59 msgid "Connect" msgstr "" @@ -168,7 +169,7 @@ msgstr "" msgid "Connect to host" msgstr "" -#: src/objects/window/window.c:702 src/objects/window/page.c:217 +#: src/objects/window/window.c:703 src/objects/window/page.c:218 msgid "Connected to host" msgstr "" @@ -188,7 +189,7 @@ msgstr "" msgid "Copy as text" msgstr "" -#: src/objects/linux/savedesktopicon.c:106 +#: src/objects/windows/savedesktopicon.c:85 msgid "Create a desktop icon for the current session" msgstr "" @@ -216,6 +217,10 @@ msgstr "" msgid "Delete Field" msgstr "" +#: src/objects/windows/savedesktopicon.c:73 +msgid "Description" +msgstr "" + #: ui/window.xml:93 ui/application.xml:158 msgid "Desktop icon" msgstr "" @@ -224,8 +229,8 @@ msgstr "" msgid "Disconnect" msgstr "" -#: src/objects/window/window.c:702 src/objects/window/window.c:729 -#: src/objects/window/page.c:206 +#: src/objects/window/window.c:703 src/objects/window/window.c:730 +#: src/objects/window/page.c:207 msgid "Disconnected from host" msgstr "" @@ -269,10 +274,6 @@ msgstr "" msgid "Field attributes" msgstr "" -#: src/objects/linux/savedesktopicon.c:72 -msgid "File name" -msgstr "" - #: ui/application.xml:454 msgid "Full Screen" msgstr "" @@ -285,10 +286,6 @@ msgstr "" msgid "Function bar" msgstr "" -#: src/objects/linux/savedesktopicon.c:86 -msgid "Generic name" -msgstr "" - #: ui/application.xml:36 ui/application.xml:534 msgid "Help" msgstr "" @@ -297,7 +294,7 @@ msgstr "" msgid "Host properties" msgstr "" -#: src/objects/window/window.c:469 +#: src/objects/window/window.c:470 src/objects/windows/savedesktopicon.c:213 msgid "IBM 3270 Terminal emulator" msgstr "" @@ -365,8 +362,7 @@ msgstr "" msgid "Keypads" msgstr "" -#: src/objects/application/actions/about.c:138 -msgctxt "LicenseFileName" +#: src/objects/application/actions/about.c:140 msgid "LICENSE" msgstr "" @@ -378,7 +374,7 @@ msgstr "" msgid "Large" msgstr "" -#: src/objects/linux/savedesktopicon.c:79 +#: src/objects/windows/savedesktopicon.c:68 msgid "Launcher name" msgstr "" @@ -430,7 +426,7 @@ msgstr "" msgid "Network keep alive" msgstr "" -#: src/objects/window/page.c:274 +#: src/objects/window/page.c:275 msgid "New session name" msgstr "" @@ -527,7 +523,7 @@ msgstr "" msgid "Quit" msgstr "" -#: src/objects/window/page.c:261 +#: src/objects/window/page.c:262 msgid "Rename Session" msgstr "" @@ -547,15 +543,15 @@ msgstr "" msgid "S_tyle" msgstr "" -#: src/objects/actions/save.c:64 ui/window.xml:69 ui/application.xml:134 +#: src/objects/actions/save.c:65 ui/window.xml:69 ui/application.xml:134 msgid "Save" msgstr "" -#: src/objects/actions/save.c:49 +#: src/objects/actions/save.c:50 msgid "Save As" msgstr "" -#: src/objects/linux/savedesktopicon.c:105 +#: src/objects/windows/savedesktopicon.c:84 msgid "Save desktop icon" msgstr "" @@ -567,7 +563,7 @@ msgstr "" msgid "Save selected" msgstr "" -#: src/objects/actions/save.c:51 +#: src/objects/actions/save.c:52 msgid "Save session properties" msgstr "" @@ -634,7 +630,7 @@ msgstr "" msgid "Session properties" msgstr "" -#: src/objects/application/application.c:221 +#: src/objects/application/application.c:219 msgid "Set the user-interface type" msgstr "" @@ -726,7 +722,7 @@ msgstr "" msgid "The name of associated action" msgstr "" -#: src/objects/window/window.c:164 +#: src/objects/window/window.c:165 msgid "The name of the actions in the header bar" msgstr "" @@ -817,7 +813,7 @@ msgstr "" msgid "View" msgstr "" -#: src/objects/application/actions/about.c:157 +#: src/objects/application/actions/about.c:163 msgid "View this project on github" msgstr "" @@ -829,11 +825,11 @@ msgstr "" msgid "_Apply" msgstr "" -#: src/objects/settings/dialog.c:78 src/objects/linux/savedesktopicon.c:132 +#: src/objects/settings/dialog.c:78 src/objects/windows/savedesktopicon.c:110 msgid "_Cancel" msgstr "" -#: src/objects/window/page.c:394 +#: src/objects/window/page.c:395 msgid "_Close session" msgstr "" @@ -869,11 +865,11 @@ msgstr "" msgid "_Properties" msgstr "" -#: src/objects/window/page.c:388 +#: src/objects/window/page.c:389 msgid "_Rename session" msgstr "" -#: src/objects/linux/savedesktopicon.c:133 +#: src/objects/windows/savedesktopicon.c:111 msgid "_Save" msgstr "" @@ -881,10 +877,10 @@ msgstr "" msgid "_View" msgstr "" -#: src/objects/application/actions/about.c:156 +#: src/objects/application/actions/about.c:162 msgid "https://github.com/PerryWerneck/pw3270" msgstr "" -#: src/objects/application/actions/about.c:159 +#: src/objects/application/actions/about.c:165 msgid "translator-credits" msgstr "" diff --git a/pw3270.cbp b/pw3270.cbp index 54fc1aa..cb5a956 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -53,6 +53,7 @@ + @@ -169,6 +170,9 @@ + + diff --git a/src/include/pw3270.h b/src/include/pw3270.h index 7645b9a..73a61db 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -68,13 +68,6 @@ void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser); - const gchar * v3270_get_session_filename(GtkWidget *widget); - void v3270_set_session_filename(GtkWidget *widget, const gchar *filename); - GKeyFile * v3270_get_session_keyfile(GtkWidget *widget); - - /// @brief Check if the terminal has a customized session file. - gboolean v3270_allow_custom_settings(GtkWidget *widget); - G_END_DECLS #endif // PW3270_H_INCLUDED diff --git a/src/include/v3270/keyfile.h b/src/include/v3270/keyfile.h new file mode 100644 index 0000000..3add18e --- /dev/null +++ b/src/include/v3270/keyfile.h @@ -0,0 +1,58 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +/** + * @brief Declares the v3270 keyfile object. + * + */ + +#ifndef V3270_KEYFILE_H_INCLUDED + + #define V3270_KEYFILE_H_INCLUDED + + #include + + G_BEGIN_DECLS + + typedef struct _V3270KeyFile V3270KeyFile; + + V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *name, GError **error); + void v3270_key_file_close(GtkWidget *terminal); + void v3270_key_file_save(GtkWidget *terminal); + const gchar * v3270_key_file_get_file_name(GtkWidget *terminal); + + GKeyFile * v3270_key_file_get(GtkWidget *terminal); + + gboolean v3270_key_file_can_write(GtkWidget *widget); + + void v3270_key_file_set_boolean(GtkWidget *terminal, const gchar *group_name, const gchar *key, gboolean value); + + G_END_DECLS + +#endif // PW3270_H_INCLUDED diff --git a/src/objects/actions/save.c b/src/objects/actions/save.c index a492aab..e647394 100644 --- a/src/objects/actions/save.c +++ b/src/objects/actions/save.c @@ -34,6 +34,7 @@ #include "private.h" #include + #include #include #include @@ -70,9 +71,10 @@ gtk_file_chooser_set_pw3270_filters(GTK_FILE_CHOOSER(dialog)); if(terminal) { - const gchar * current_file = v3270_get_session_filename(terminal); - if(current_file && g_file_test(current_file,G_FILE_TEST_IS_REGULAR) && !g_str_has_prefix(current_file,g_get_user_config_dir())) + const gchar * current_file = v3270_key_file_get_file_name(terminal); + if(current_file && g_file_test(current_file,G_FILE_TEST_IS_REGULAR) && !g_str_has_prefix(current_file,g_get_user_config_dir())) { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),current_file); + } } g_signal_connect(dialog,"response",G_CALLBACK(response),terminal); @@ -90,7 +92,31 @@ gtk_widget_destroy(dialog); if(response_id == GTK_RESPONSE_OK) { - v3270_set_session_filename(terminal, filename); + GError * error = NULL; + v3270_key_file_open(terminal,filename,&error); + + if(error) { + + GtkWidget * dialog = gtk_message_dialog_new_with_markup( + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + _("Can't open \"%s\""),filename + ); + + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); + + gtk_window_set_title(GTK_WINDOW(dialog),_("Can't load session file")); + + gtk_widget_show_all(dialog); + + g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); + g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); + + g_error_free(error); + } + } } diff --git a/src/objects/keypad/load.c b/src/objects/keypad/load.c index 4f8e3e7..1f99be5 100644 --- a/src/objects/keypad/load.c +++ b/src/objects/keypad/load.c @@ -82,7 +82,7 @@ } - static void element_end(GMarkupParseContext *context, const gchar *element_name, GList **keypads, GError **error) { + static void element_end(GMarkupParseContext *context, const gchar *element_name, GList G_GNUC_UNUSED(**keypads), GError G_GNUC_UNUSED(**error)) { debug("%s(%s)",__FUNCTION__,element_name); diff --git a/src/objects/linux/savedesktopicon.c b/src/objects/linux/savedesktopicon.c index 162755f..bb7631d 100644 --- a/src/objects/linux/savedesktopicon.c +++ b/src/objects/linux/savedesktopicon.c @@ -36,6 +36,7 @@ #include #include #include + #include #include #include @@ -278,7 +279,7 @@ X-Desktop-File-Install-Version=0.23 if(bytes >= 0) buffer[bytes] = '\0'; - g_autofree gchar * exec_line = g_strdup_printf("%s \"%s\"",buffer,v3270_get_session_filename(terminal)); + g_autofree gchar * exec_line = g_strdup_printf("%s \"%s\"",buffer,v3270_key_file_get_file_name(terminal)); g_key_file_set_string(keyfile,"Desktop Entry","Exec",exec_line); } diff --git a/src/objects/window/keyfile.c b/src/objects/window/keyfile.c new file mode 100644 index 0000000..b714eaa --- /dev/null +++ b/src/objects/window/keyfile.c @@ -0,0 +1,247 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + struct _V3270KeyFile + { + gboolean changed; ///< @brief Save file? + GKeyFile * key_file; + gchar filename[1]; + }; + + static V3270KeyFile * v3270_get_session_descriptor(GtkWidget *terminal) { + + return (V3270KeyFile *) g_object_get_data(G_OBJECT(terminal),"session-descriptor"); + + } + + static void close_keyfile(V3270KeyFile * session) { + + if(session->key_file) { + + if(session->changed) { + g_message("Saving file %s",session->filename); + g_key_file_save_to_file(session->key_file,session->filename,NULL); + session->changed = FALSE; + } else { + g_message("Closing file %s",session->filename); + } + + g_key_file_free(session->key_file); + session->key_file = NULL; + } + + g_free(session); + } + + V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, GError **error) { + + g_return_val_if_fail(GTK_IS_V3270(terminal),FALSE); + g_return_val_if_fail(*error == NULL,FALSE); + + V3270KeyFile * new_session = (V3270KeyFile *) g_malloc0(sizeof(struct _V3270KeyFile) + strlen(filename)); + V3270KeyFile * old_session = g_object_get_data(G_OBJECT(terminal),"session-descriptor"); + + // Clone session + if(old_session) { + *new_session = *old_session; + } + + strcpy(new_session->filename,filename); + new_session->key_file = g_key_file_new(); + + // Load file + if(g_file_test(new_session->filename,G_FILE_TEST_IS_REGULAR)) { + + // Found session file, open it. + if(!g_key_file_load_from_file(new_session->key_file,new_session->filename,G_KEY_FILE_NONE,error)) { + g_warning("Can't load \"%s\"",new_session->filename); + } else { + g_message("Loading session properties from %s",new_session->filename); + } + + } else { + + // No session file, load the defaults (if available) and save file + lib3270_autoptr(char) default_settings = lib3270_build_data_filename("defaults.conf",NULL); + + if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { + if(!g_key_file_load_from_file(new_session->key_file,default_settings,G_KEY_FILE_NONE,error)) { + g_warning("Can't load \"%s\"",default_settings); + } else { + g_message("Loading session properties from %s",default_settings); + } + } else { +#ifdef DEBUG + g_message("Can't find default settings file \"%s\"",default_settings); +#else + g_warning("Can't find default settings file \"%s\"",default_settings); +#endif // DEBUG + } + + new_session->changed = TRUE; + + } + + g_object_set_data_full(G_OBJECT(terminal),"session-descriptor",new_session,(GDestroyNotify) close_keyfile); + if(new_session->changed) { + v3270_key_file_save(terminal); + } + + if(!*error) { + + // Got key file, load it. + v3270_load_key_file(terminal,new_session->key_file,NULL); + v3270_accelerator_map_load_key_file(terminal,new_session->key_file,NULL); + + if(g_key_file_has_group(new_session->key_file,"environment")) { + + // Has environment group, set values. + gchar **keys = g_key_file_get_keys(new_session->key_file,"environment",NULL,NULL); + + if(keys) { + size_t ix; + for(ix=0;keys[ix];ix++) { + g_autofree gchar * value = g_key_file_get_string(new_session->key_file,"environment",keys[ix],NULL); + if(value) { +#ifdef _WIN32 + g_autofree gchar * env = g_strconcat(keys[ix],"=",value,NULL); + putenv(env); +#else + if(setenv(keys[ix],value,1)) { + g_warning("Can't set \"%s\" to \"%s\"",keys[ix],value); + } +#endif // _WIN32 + } + } + + g_strfreev(keys); + } + } + + } + + return new_session; +} + +void v3270_key_file_close(GtkWidget *terminal) { + + V3270KeyFile *session = g_object_get_data(G_OBJECT(terminal),"session-descriptor"); + + if(session->key_file) { + + if(session->changed) { + g_message("Saving file %s",session->filename); + g_key_file_save_to_file(session->key_file,session->filename,NULL); + session->changed = FALSE; + } else { + g_message("Closing file %s",session->filename); + } + + g_key_file_free(session->key_file); + session->key_file = NULL; + } + + } + + GKeyFile * v3270_key_file_get(GtkWidget *terminal) { + return v3270_get_session_descriptor(terminal)->key_file; + } + + void v3270_key_file_save(GtkWidget *terminal) { + + V3270KeyFile *session = v3270_get_session_descriptor(terminal); + + session->changed = FALSE; + + debug("%s: terminal=%p session=%p key-file=%p)",__FUNCTION__,terminal,session,session->key_file); + + v3270_to_key_file(terminal,session->key_file,"terminal"); + v3270_accelerator_map_to_key_file(terminal, session->key_file, "accelerators"); + + g_key_file_save_to_file(session->key_file,session->filename,NULL); + + } + + const gchar * v3270_key_file_get_file_name(GtkWidget *terminal) { + + V3270KeyFile *session = v3270_get_session_descriptor(terminal); + + if(session && *session->filename) + return session->filename; + + return NULL; + + } + + void v3270_key_file_set_boolean(GtkWidget *terminal, const gchar *group_name, const gchar *key, gboolean value) { + + V3270KeyFile *session = v3270_get_session_descriptor(terminal); + g_key_file_set_boolean(session->key_file,group_name ? group_name : "terminal",key,value); + session->changed = TRUE; + +} + + gboolean v3270_key_file_can_write(GtkWidget *widget) { + +#if defined(DEBUG) + + return TRUE; + +#else + + const struct SessionDescriptor * descriptor = v3270_get_session_descriptor(widget); + + if(!(descriptor && *descriptor->filename)) + return FALSE; + + if(g_access(descriptor->filename,W_OK)) + return FALSE; + +#ifdef _WIN32 + return TRUE; +#else + return !g_str_has_prefix(descriptor->filename,g_get_user_config_dir()); +#endif // _WIN32 + +#endif // DEBUG + + } + + + diff --git a/src/objects/window/page.c b/src/objects/window/page.c index 75eccad..5b62d6c 100644 --- a/src/objects/window/page.c +++ b/src/objects/window/page.c @@ -35,6 +35,7 @@ #include #include #include + #include #include //---[ Gtk Label with customized popup-menu ]--------------------------------------------------------------------------------------- @@ -387,7 +388,7 @@ { .label = N_("_Rename session"), .callback = G_CALLBACK(rename_session), - .check_permission = v3270_allow_custom_settings + .check_permission = v3270_key_file_can_write }, { diff --git a/src/objects/window/terminal.c b/src/objects/window/terminal.c index 9ffe95f..92cedc7 100644 --- a/src/objects/window/terminal.c +++ b/src/objects/window/terminal.c @@ -40,60 +40,24 @@ #include #include #include + #include #include #include - struct SessionDescriptor - { - gboolean changed; ///< @brief Save file? - GKeyFile * key_file; - gchar filename[1]; - }; - - static void destroy(GtkWidget G_GNUC_UNUSED(*terminal), struct SessionDescriptor * session) { - - if(session->changed) { - - session->changed = FALSE; - - GError * error = NULL; - g_key_file_save_to_file(session->key_file,session->filename,&error); - - if(error) { - - g_warning("Can't save \"%s\": %s",session->filename,error->message); - g_error_free(error); - - } else { - - g_message("Session was saved to %s",session->filename); - - } - - } - + static void destroy(GtkWidget *terminal, gpointer GNUC_UNUSED(dunno)) { + v3270_key_file_close(terminal); } - static void save_settings(GtkWidget *terminal, struct SessionDescriptor * session) { - - session->changed = FALSE; - - debug("%s(%p,%p)",__FUNCTION__,terminal,session); - - v3270_to_key_file(terminal,session->key_file,"terminal"); - v3270_accelerator_map_to_key_file(terminal, session->key_file, "accelerators"); - - g_key_file_save_to_file(session->key_file,session->filename,NULL); - + static void toggle_changed(GtkWidget *widget, G_GNUC_UNUSED LIB3270_TOGGLE_ID toggle_id, gboolean toggle_state, const gchar *toggle_name, gpointer GNUC_UNUSED(dunno)) { + debug("%s(%s)=%s",__FUNCTION__,toggle_name,toggle_state ? "ON" : "OFF"); + v3270_key_file_set_boolean(widget,"terminal",toggle_name,toggle_state); } - static void toggle_changed(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED LIB3270_TOGGLE_ID toggle_id, gboolean toggle_state, const gchar *toggle_name, struct SessionDescriptor * session) { - debug("%s(%s)=%s",__FUNCTION__,toggle_name,toggle_state ? "ON" : "OFF"); - g_key_file_set_boolean(session->key_file,"terminal",toggle_name,toggle_state); - session->changed = TRUE; + static void save_settings(GtkWidget *terminal, gpointer G_GNUC_UNUSED(dunno)) { + v3270_key_file_save(terminal); } - static void print_done(G_GNUC_UNUSED GtkWidget *widget, GtkPrintOperation *operation, GtkPrintOperationResult result, struct SessionDescriptor * session) { + static void print_done(GtkWidget *widget, GtkPrintOperation *operation, GtkPrintOperationResult result, gpointer G_GNUC_UNUSED(dunno)) { debug("%s(%u)",__FUNCTION__,(unsigned int) result); if(result != GTK_PRINT_OPERATION_RESULT_APPLY) @@ -101,166 +65,72 @@ debug("%s: Saving print settings",__FUNCTION__); - v3270_print_operation_to_key_file(operation,session->key_file); + v3270_print_operation_to_key_file(operation,v3270_key_file_get(widget)); + v3270_emit_save_settings(widget,NULL); - g_key_file_save_to_file(session->key_file,session->filename,NULL); - session->changed = FALSE; } - static void print_setup(G_GNUC_UNUSED GtkWidget *widget, GtkPrintOperation *operation, struct SessionDescriptor * session) { + static void print_setup(G_GNUC_UNUSED GtkWidget *widget, GtkPrintOperation *operation, gpointer G_GNUC_UNUSED(dunno) ) { debug("%s(%p)",__FUNCTION__,operation); - v3270_print_operation_load_key_file(operation,session->key_file); - - } - - static void close_settings(struct SessionDescriptor * session) { - - if(session->key_file) { - - if(session->changed) { - g_message("Saving file %s",session->filename); - g_key_file_save_to_file(session->key_file,session->filename,NULL); - session->changed = FALSE; - } else { - g_message("Closing file %s",session->filename); - } - - g_key_file_free(session->key_file); - session->key_file = NULL; - } - - g_free(session); - } - - const gchar * v3270_get_session_filename(GtkWidget *widget) { - - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); - - const struct SessionDescriptor * descriptor = (const struct SessionDescriptor *) g_object_get_data(G_OBJECT(widget),"session-descriptor"); - - if(descriptor) - return descriptor->filename; - - return NULL; - } - - void v3270_set_session_filename(GtkWidget *terminal, const gchar *filename) { - - struct SessionDescriptor * old_session = (struct SessionDescriptor *) g_object_get_data(G_OBJECT(terminal),"session-descriptor"); - struct SessionDescriptor * new_session = (struct SessionDescriptor *) g_malloc0(sizeof(struct SessionDescriptor) + strlen(filename)); - - if(old_session) { - memcpy(new_session,old_session,sizeof(struct SessionDescriptor)); - } - - strcpy(new_session->filename,filename); - new_session->key_file = g_key_file_new(); - - v3270_to_key_file(terminal,new_session->key_file,NULL); - v3270_accelerator_map_to_key_file(terminal,new_session->key_file,NULL); - - GError *error = NULL; - g_key_file_save_to_file(new_session->key_file,new_session->filename,&error); - - if(error) { - - g_message("Can't save file \"%s\": %s",new_session->filename,error->message); - - GtkWidget * dialog = gtk_message_dialog_new_with_markup( - GTK_WINDOW(gtk_widget_get_toplevel(terminal)), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CANCEL, - _("Can't save file \"%s\""),new_session->filename - ); - - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); - - gtk_window_set_title(GTK_WINDOW(dialog),_("Can't save session file")); - - gtk_widget_show_all(dialog); - - g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); - g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); - - g_error_free(error); - g_key_file_free(new_session->key_file); - g_free(new_session); - - } else { - - new_session->changed = FALSE; - g_object_set_data_full(G_OBJECT(terminal),"session-descriptor",new_session,(GDestroyNotify) close_settings); - - } - + v3270_print_operation_load_key_file(operation,v3270_key_file_get(widget)); } - GKeyFile * v3270_get_session_keyfile(GtkWidget *widget) { + static GtkResponseType load_popup_response(GtkWidget *widget, const gchar *popup_name, gpointer G_GNUC_UNUSED(dunno)) { - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); - - const struct SessionDescriptor * descriptor = (const struct SessionDescriptor *) g_object_get_data(G_OBJECT(widget),"session-descriptor"); - - if(descriptor) - return descriptor->key_file; - - return NULL; - } + GKeyFile * key_file = v3270_key_file_get(widget); - static GtkResponseType load_popup_response(v3270 G_GNUC_UNUSED(*widget), const gchar *popup_name, struct SessionDescriptor * session) { - - if(session->key_file && g_key_file_has_key(session->key_file,"dialogs",popup_name,NULL)) - return (GtkResponseType) g_key_file_get_integer(session->key_file,"dialogs",popup_name,NULL); + if(key_file && g_key_file_has_key(key_file,"dialogs",popup_name,NULL)) + return (GtkResponseType) g_key_file_get_integer(key_file,"dialogs",popup_name,NULL); #ifdef _WIN32 - { - // Windows - Check predefined responses on system registry. - lib3270_auto_cleanup(HKEY) hKey; + { + // Windows - Check predefined responses on system registry. + lib3270_auto_cleanup(HKEY) hKey; - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,G_STRINGIFY(PRODUCT_NAME)"\\dialogs",0,KEY_READ,&hKey) == ERROR_SUCCESS) { + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,G_STRINGIFY(PRODUCT_NAME)"\\dialogs",0,KEY_READ,&hKey) == ERROR_SUCCESS) { - DWORD val = 0; - DWORD cbData = sizeof(DWORD); - - if(RegQueryValueEx(hKey, popup_name, NULL, NULL, (LPBYTE) &val, &cbData) == ERROR_SUCCESS) { - return (GtkResponseType) val; - } + DWORD val = 0; + DWORD cbData = sizeof(DWORD); + if(RegQueryValueEx(hKey, popup_name, NULL, NULL, (LPBYTE) &val, &cbData) == ERROR_SUCCESS) { + return (GtkResponseType) val; } + } + } #endif // _WIN32 - return session->key_file ? GTK_RESPONSE_NONE : 0; + return key_file ? GTK_RESPONSE_NONE : 0; } - static gboolean save_popup_response(GtkWidget *widget, const gchar *popup_name, GtkResponseType response, struct SessionDescriptor * session) { - debug("%s(%s)",__FUNCTION__,popup_name); + static gboolean save_popup_response(GtkWidget *widget, const gchar *popup_name, GtkResponseType response, gpointer G_GNUC_UNUSED(dunno)) { + + GKeyFile * key_file = v3270_key_file_get(widget); - if(!session->key_file) - return FALSE; + debug("%s(%s)",__FUNCTION__,popup_name); - g_key_file_set_integer(session->key_file,"dialogs",popup_name,(gint) response); - v3270_emit_save_settings(widget,NULL); + if(!key_file) + return FALSE; - return TRUE; + g_key_file_set_integer(key_file,"dialogs",popup_name,(gint) response); + v3270_emit_save_settings(widget,NULL); + + return TRUE; } GtkWidget * pw3270_terminal_new(const gchar *session_file) { - GtkWidget * terminal = v3270_new(); + GtkWidget * terminal = v3270_new(); + GError * error = NULL; gtk_widget_show_all(terminal); - struct SessionDescriptor * descriptor = NULL; - if(session_file) { // Use the supplied session file - descriptor = g_malloc0(sizeof(struct SessionDescriptor) + strlen(session_file)); - strcpy(descriptor->filename,session_file); + v3270_key_file_open(terminal,session_file,&error); } else { @@ -273,93 +143,41 @@ g_rename(compatible,filename); } - descriptor = g_malloc0(sizeof(struct SessionDescriptor) + strlen(filename)); - strcpy(descriptor->filename,filename); + v3270_key_file_open(terminal,filename,&error); } - // Setup session file; - GError *error = NULL; - g_object_set_data_full(G_OBJECT(terminal),"session-descriptor",descriptor,(GDestroyNotify) close_settings); - - descriptor->key_file = g_key_file_new(); + // Setup signals. + g_signal_connect(G_OBJECT(terminal),"save-settings",G_CALLBACK(save_settings),NULL); + g_signal_connect(G_OBJECT(terminal),"toggle_changed",G_CALLBACK(toggle_changed),NULL); + g_signal_connect(G_OBJECT(terminal),"print-done",G_CALLBACK(print_done),NULL); + g_signal_connect(G_OBJECT(terminal),"print-setup",G_CALLBACK(print_setup),NULL); + g_signal_connect(G_OBJECT(terminal),"destroy", G_CALLBACK(destroy),NULL); + g_signal_connect(G_OBJECT(terminal),"load-popup-response",G_CALLBACK(load_popup_response),NULL); + g_signal_connect(G_OBJECT(terminal),"save-popup-response",G_CALLBACK(save_popup_response),NULL); - if(g_file_test(descriptor->filename,G_FILE_TEST_IS_REGULAR)) { + if(error) { - // Found session file, open it. - if(!g_key_file_load_from_file(descriptor->key_file,descriptor->filename,G_KEY_FILE_NONE,&error)) { - g_warning("Can't load \"%s\"",descriptor->filename); - } else { - g_message("Loading session properties from %s",descriptor->filename); - } + GtkWidget * dialog = gtk_message_dialog_new_with_markup( + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + _("Can't use \"%s\""),session_file + ); - } else { + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); - // No session file, load the defaults (if available). - lib3270_autoptr(char) default_settings = lib3270_build_data_filename("defaults.conf",NULL); - if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { - if(!g_key_file_load_from_file(descriptor->key_file,default_settings,G_KEY_FILE_NONE,&error)) { - g_warning("Can't load \"%s\"",default_settings); - } else { - g_message("Loading session properties from %s",default_settings); - } - } else { -#ifdef DEBUG - g_message("Can't find default settings file \"%s\"",default_settings); -#else - g_warning("Can't find default settings file \"%s\"",default_settings); -#endif // DEBUG - } + gtk_window_set_title(GTK_WINDOW(dialog),_("Can't load session file")); - } + gtk_widget_show_all(dialog); - if(error) { + g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); + g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); - g_warning(error->message); g_error_free(error); - error = NULL; - - } else { - - // Got key file, load it. - v3270_load_key_file(terminal,descriptor->key_file,NULL); - v3270_accelerator_map_load_key_file(terminal,descriptor->key_file,NULL); - - if(g_key_file_has_group(descriptor->key_file,"environment")) { - - // Has environment group, set values. - gchar **keys = g_key_file_get_keys(descriptor->key_file,"environment",NULL,NULL); - - if(keys) { - size_t ix; - for(ix=0;keys[ix];ix++) { - g_autofree gchar * value = g_key_file_get_string(descriptor->key_file,"environment",keys[ix],NULL); - if(value) { -#ifdef _WIN32 - g_autofree gchar * env = g_strconcat(keys[ix],"=",value,NULL); - putenv(env); -#else - if(setenv(keys[ix],value,1)) { - g_warning("Can't set \"%s\" to \"%s\"",keys[ix],value); - } -#endif // _WIN32 - } - } - - g_strfreev(keys); - } - } } - // Setup signals. - g_signal_connect(G_OBJECT(terminal),"save-settings",G_CALLBACK(save_settings),descriptor); - g_signal_connect(G_OBJECT(terminal),"toggle_changed",G_CALLBACK(toggle_changed),descriptor); - g_signal_connect(G_OBJECT(terminal),"print-done",G_CALLBACK(print_done),descriptor); - g_signal_connect(G_OBJECT(terminal),"print-setup",G_CALLBACK(print_setup),descriptor); - g_signal_connect(G_OBJECT(terminal),"destroy", G_CALLBACK(destroy),descriptor); - g_signal_connect(G_OBJECT(terminal),"load-popup-response",G_CALLBACK(load_popup_response),descriptor); - g_signal_connect(G_OBJECT(terminal),"save-popup-response",G_CALLBACK(save_popup_response),descriptor); - return terminal; } @@ -375,30 +193,4 @@ } - gboolean v3270_allow_custom_settings(GtkWidget *widget) { - -#if defined(DEBUG) - - return TRUE; - -#else - - const struct SessionDescriptor * descriptor = (const struct SessionDescriptor *) g_object_get_data(G_OBJECT(widget),"session-descriptor"); - - if(!(descriptor && *descriptor->filename)) - return FALSE; - - if(g_access(descriptor->filename,W_OK)) - return FALSE; - -#ifdef _WIN32 - return TRUE; -#else - return !g_str_has_prefix(descriptor->filename,g_get_user_config_dir()); -#endif // _WIN32 - -#endif // DEBUG - - } - diff --git a/src/objects/window/window.c b/src/objects/window/window.c index 32878e4..1822d23 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -34,6 +34,7 @@ #include #include #include + #include static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); @@ -191,8 +192,8 @@ if(!terminal) return; - GKeyFile * keyfile = v3270_get_session_keyfile(terminal); - if(!terminal) + GKeyFile * keyfile = v3270_key_file_get(terminal); + if(!keyfile) return; g_key_file_set_boolean( @@ -704,7 +705,7 @@ // Setup keypads if(window->keypads) { - GKeyFile * keyfile = v3270_get_session_keyfile(terminal); + GKeyFile * keyfile = v3270_key_file_get(terminal); if(keyfile) { diff --git a/src/objects/windows/savedesktopicon.c b/src/objects/windows/savedesktopicon.c index 260d4b2..ca45051 100644 --- a/src/objects/windows/savedesktopicon.c +++ b/src/objects/windows/savedesktopicon.c @@ -256,10 +256,10 @@ GtkWidget ** inputs = g_object_get_data(G_OBJECT(dialog),"inputs"); HRESULT hRes = CreateShortCut( - NULL, // LPSTR pszTargetfile, - v3270_get_session_filename(terminal), // LPSTR pszTargetargs, - gtk_entry_get_text(GTK_ENTRY(inputs[0])), // LPSTR pszLinkfile, - gtk_entry_get_text(GTK_ENTRY(inputs[1])), //LPSTR pszDescription, + NULL, // LPSTR pszTargetfile, + v3270_key_file_get_file_name(terminal), // LPSTR pszTargetargs, + gtk_entry_get_text(GTK_ENTRY(inputs[0])), // LPSTR pszLinkfile, + gtk_entry_get_text(GTK_ENTRY(inputs[1])), //LPSTR pszDescription, 0, NULL, NULL, -- libgit2 0.21.2