Commit 11c7ab0eb6ec85c2ef46c84d36a93e748abf7f7a
Committed by
GitHub
Exists in
master
and in
2 other branches
Merge pull request #32 from PerryWerneck/macos
Updates for macos build.
Showing
17 changed files
with
732 additions
and
104 deletions
Show diff stats
Makefile.in
| @@ -55,8 +55,8 @@ SOURCES= \ | @@ -55,8 +55,8 @@ SOURCES= \ | ||
| 55 | $(wildcard $(srcdir)/src/main/@OSNAME@/*.rc) | 55 | $(wildcard $(srcdir)/src/main/@OSNAME@/*.rc) |
| 56 | 56 | ||
| 57 | SCHEMAS= \ | 57 | SCHEMAS= \ |
| 58 | - $(wildcard $(srcdir)/schemas/@OSNAME@/*.gschema.xml) \ | ||
| 59 | - $(wildcard $(srcdir)/schemas/common/*.gschema.xml) | 58 | + $(wildcard schemas/@OSNAME@/*.gschema.xml) \ |
| 59 | + $(wildcard schemas/common/*.gschema.xml) | ||
| 60 | 60 | ||
| 61 | #---[ Tools ]---------------------------------------------------------------------------- | 61 | #---[ Tools ]---------------------------------------------------------------------------- |
| 62 | 62 | ||
| @@ -138,6 +138,8 @@ $(OBJDBG)/%.o: \ | @@ -138,6 +138,8 @@ $(OBJDBG)/%.o: \ | ||
| 138 | gschemas.compiled: \ | 138 | gschemas.compiled: \ |
| 139 | $(foreach SCHEMA, $(notdir $(SCHEMAS)), $(OBJDIR)/schemas/$(SCHEMA)) | 139 | $(foreach SCHEMA, $(notdir $(SCHEMAS)), $(OBJDIR)/schemas/$(SCHEMA)) |
| 140 | 140 | ||
| 141 | + @$(MKDIR) $(OBJDIR)/schemas | ||
| 142 | + | ||
| 141 | @glib-compile-schemas \ | 143 | @glib-compile-schemas \ |
| 142 | --targetdir=$(@D) \ | 144 | --targetdir=$(@D) \ |
| 143 | $(OBJDIR)/schemas | 145 | $(OBJDIR)/schemas |
| @@ -205,7 +207,7 @@ $(POTDIR)/%.pot: \ | @@ -205,7 +207,7 @@ $(POTDIR)/%.pot: \ | ||
| 205 | @touch $@ | 207 | @touch $@ |
| 206 | 208 | ||
| 207 | $(OBJDIR)/schemas/%.xml: \ | 209 | $(OBJDIR)/schemas/%.xml: \ |
| 208 | - $(srcdir)/schemas/@OSNAME@/%.xml | 210 | + schemas/@OSNAME@/%.xml |
| 209 | 211 | ||
| 210 | @$(MKDIR) $(@D) | 212 | @$(MKDIR) $(@D) |
| 211 | @cp "$^" "$@" | 213 | @cp "$^" "$@" |
| @@ -301,6 +303,15 @@ install-linux-application: \ | @@ -301,6 +303,15 @@ install-linux-application: \ | ||
| 301 | $(BINRLS)/$(PACKAGE_NAME)@EXEEXT@ \ | 303 | $(BINRLS)/$(PACKAGE_NAME)@EXEEXT@ \ |
| 302 | $(DESTDIR)$(bindir)/$(PRODUCT_NAME)@EXEEXT@ | 304 | $(DESTDIR)$(bindir)/$(PRODUCT_NAME)@EXEEXT@ |
| 303 | 305 | ||
| 306 | +install-macos-application: \ | ||
| 307 | + $(BINRLS)/$(PACKAGE_NAME)@EXEEXT@ | ||
| 308 | + | ||
| 309 | + @$(MKDIR) \ | ||
| 310 | + $(DESTDIR)$(bindir) | ||
| 311 | + | ||
| 312 | + @$(INSTALL_PROGRAM) \ | ||
| 313 | + $(BINRLS)/$(PACKAGE_NAME)@EXEEXT@ \ | ||
| 314 | + $(DESTDIR)$(bindir)/$(PRODUCT_NAME)@EXEEXT@ | ||
| 304 | 315 | ||
| 305 | install-windows-application: \ | 316 | install-windows-application: \ |
| 306 | strip | 317 | strip |
README.md
| @@ -86,7 +86,9 @@ Updated windows installers are available on Dropbox, google drive and one drive. | @@ -86,7 +86,9 @@ Updated windows installers are available on Dropbox, google drive and one drive. | ||
| 86 | ``` | 86 | ``` |
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | -## Building for macOS (using homebrew) | 89 | +## Building for macOS |
| 90 | + | ||
| 91 | +### Using homebrew | ||
| 90 | 92 | ||
| 91 | 1. Build and install [libv3270](../../../libv3270) | 93 | 1. Build and install [libv3270](../../../libv3270) |
| 92 | 94 | ||
| @@ -109,4 +111,17 @@ Updated windows installers are available on Dropbox, google drive and one drive. | @@ -109,4 +111,17 @@ Updated windows installers are available on Dropbox, google drive and one drive. | ||
| 109 | $ cd macos | 111 | $ cd macos |
| 110 | $ ./bundle | 112 | $ ./bundle |
| 111 | ```` | 113 | ```` |
| 114 | + | ||
| 115 | +### Using jhbuild | ||
| 116 | + | ||
| 117 | +1. Install jhbuild and GTK-OSX | ||
| 118 | + | ||
| 119 | + https://wiki.gnome.org/Projects/GTK/OSX/Building | ||
| 120 | + | ||
| 121 | +2. build | ||
| 122 | + | ||
| 123 | + ```shell | ||
| 124 | + jhbuild --moduleset=https://raw.githubusercontent.com/PerryWerneck/pw3270/macos/mac/pw3270.modules build pw3270 | ||
| 125 | + ``` | ||
| 126 | + | ||
| 112 | 127 |
branding/Makefile.in
| @@ -153,6 +153,10 @@ install-linux: \ | @@ -153,6 +153,10 @@ install-linux: \ | ||
| 153 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/icons/$(PRODUCT_NAME)-symbolic.svg \ | 153 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/icons/$(PRODUCT_NAME)-symbolic.svg \ |
| 154 | $(DESTDIR)$(datarootdir)/icons/$(APPLICATION_ID)-symbolic.svg | 154 | $(DESTDIR)$(datarootdir)/icons/$(APPLICATION_ID)-symbolic.svg |
| 155 | 155 | ||
| 156 | +install-macos: \ | ||
| 157 | + $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME).svg \ | ||
| 158 | + $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME)-logo.svg | ||
| 159 | + | ||
| 156 | install-windows: \ | 160 | install-windows: \ |
| 157 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME).svg \ | 161 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME).svg \ |
| 158 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME)-logo.svg \ | 162 | $(DESTDIR)$(datarootdir)/$(PRODUCT_NAME)/$(PRODUCT_NAME)-logo.svg \ |
configure.ac
| @@ -40,6 +40,9 @@ AC_CONFIG_HEADER([src/include/config.h]) | @@ -40,6 +40,9 @@ AC_CONFIG_HEADER([src/include/config.h]) | ||
| 40 | dnl Initialise automake stuff. | 40 | dnl Initialise automake stuff. |
| 41 | AM_INIT_AUTOMAKE | 41 | AM_INIT_AUTOMAKE |
| 42 | 42 | ||
| 43 | +dnl Set gettext version | ||
| 44 | +AM_GNU_GETTEXT_VERSION([0.14]) | ||
| 45 | + | ||
| 43 | dnl Checks for programs. | 46 | dnl Checks for programs. |
| 44 | AC_PROG_CC | 47 | AC_PROG_CC |
| 45 | AC_PROG_SED | 48 | AC_PROG_SED |
| @@ -91,6 +94,17 @@ case "$host" in | @@ -91,6 +94,17 @@ case "$host" in | ||
| 91 | 94 | ||
| 92 | ;; | 95 | ;; |
| 93 | 96 | ||
| 97 | + *-apple-darwin*) | ||
| 98 | + app_cv_osname="macos" | ||
| 99 | + app_rls_ldflags="" | ||
| 100 | + | ||
| 101 | + CFLAGS="$CFLAGS -pthread" | ||
| 102 | + LDFLAGS="$LDFLAGS -pthread" | ||
| 103 | + | ||
| 104 | + AC_CONFIG_FILES(schemas/macos/application.gschema.xml) | ||
| 105 | + AC_CONFIG_FILES(schemas/macos/window.gschema.xml) | ||
| 106 | + ;; | ||
| 107 | + | ||
| 94 | *) | 108 | *) |
| 95 | app_cv_osname="linux" | 109 | app_cv_osname="linux" |
| 96 | app_rls_ldflags="" | 110 | app_rls_ldflags="" |
| @@ -98,9 +112,6 @@ case "$host" in | @@ -98,9 +112,6 @@ case "$host" in | ||
| 98 | CFLAGS="$CFLAGS -pthread -DLIBDIR=\$(libdir)" | 112 | CFLAGS="$CFLAGS -pthread -DLIBDIR=\$(libdir)" |
| 99 | LDFLAGS="$LDFLAGS -pthread" | 113 | LDFLAGS="$LDFLAGS -pthread" |
| 100 | 114 | ||
| 101 | - app_cv_static='no' | ||
| 102 | - | ||
| 103 | - # Windows and linux doesn't use the same window defaults. | ||
| 104 | AC_CONFIG_FILES(schemas/linux/application.gschema.xml) | 115 | AC_CONFIG_FILES(schemas/linux/application.gschema.xml) |
| 105 | AC_CONFIG_FILES(schemas/linux/window.gschema.xml) | 116 | AC_CONFIG_FILES(schemas/linux/window.gschema.xml) |
| 106 | 117 | ||
| @@ -224,7 +235,19 @@ dnl --------------------------------------------------------------------------- | @@ -224,7 +235,19 @@ dnl --------------------------------------------------------------------------- | ||
| 224 | 235 | ||
| 225 | GLIB_GSETTINGS | 236 | GLIB_GSETTINGS |
| 226 | 237 | ||
| 227 | -PKG_CHECK_MODULES( [GTK], [gtk+-3.0 glib-2.0 gmodule-2.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) | 238 | +case "$host" in |
| 239 | + *-mingw32|*-pc-msys) | ||
| 240 | + PKG_CHECK_MODULES( [GTK], [gtk+-3.0 glib-2.0 gmodule-2.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) | ||
| 241 | + ;; | ||
| 242 | + | ||
| 243 | + *-apple-darwin*) | ||
| 244 | + PKG_CHECK_MODULES( [GTK], [gtk+-3.0 glib-2.0 gmodule-2.0 gtk-mac-integration-gtk3], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) | ||
| 245 | + ;; | ||
| 246 | + | ||
| 247 | + *) | ||
| 248 | + PKG_CHECK_MODULES( [GTK], [gtk+-3.0 glib-2.0 gmodule-2.0], AC_DEFINE(HAVE_GTK), AC_MSG_ERROR([GTK not present.])) | ||
| 249 | + | ||
| 250 | +esac | ||
| 228 | 251 | ||
| 229 | AC_SUBST(GTK_LIBS) | 252 | AC_SUBST(GTK_LIBS) |
| 230 | AC_SUBST(GTK_CFLAGS) | 253 | AC_SUBST(GTK_CFLAGS) |
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +<?xml version="1.0"?> | ||
| 2 | +<!DOCTYPE moduleset SYSTEM "moduleset.dtd"> | ||
| 3 | +<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?> | ||
| 4 | +<moduleset> | ||
| 5 | + | ||
| 6 | + <include href="https://gitlab.gnome.org/GNOME/gtk-osx/raw/master/modulesets-stable/gtk-osx.modules" /> | ||
| 7 | + <include href="https://raw.githubusercontent.com/PerryWerneck/libv3270/macos/mac/libv3270.modules" /> | ||
| 8 | + | ||
| 9 | + <repository type="git" name="github.com" href="git://github.com/"/> | ||
| 10 | + | ||
| 11 | + <autotools id="pw3270"> | ||
| 12 | + <branch repo="github.com" module="PerryWerneck/pw3270" revision="macos" /> | ||
| 13 | + <dependencies> | ||
| 14 | + <dep package="meta-gtk-osx-bootstrap" /> | ||
| 15 | + <dep package="glib" /> | ||
| 16 | + <dep package="gtk+-3.0" /> | ||
| 17 | + <dep package="gdk-pixbuf" /> | ||
| 18 | + <dep package="gtk-mac-integration" /> | ||
| 19 | + <dep package="adwaita-icon-theme" /> | ||
| 20 | + <dep package="hicolor-icon-theme" /> | ||
| 21 | + <dep package="lib3270"/> | ||
| 22 | + <dep package="libv3270"/> | ||
| 23 | + </dependencies> | ||
| 24 | + </autotools> | ||
| 25 | + | ||
| 26 | +</moduleset> | ||
| 27 | + |
pw3270.cbp
| @@ -139,6 +139,12 @@ | @@ -139,6 +139,12 @@ | ||
| 139 | <Unit filename="src/objects/os/linux/savedesktopicon.c"> | 139 | <Unit filename="src/objects/os/linux/savedesktopicon.c"> |
| 140 | <Option compilerVar="CC" /> | 140 | <Option compilerVar="CC" /> |
| 141 | </Unit> | 141 | </Unit> |
| 142 | + <Unit filename="src/objects/os/macos/open.c"> | ||
| 143 | + <Option compilerVar="CC" /> | ||
| 144 | + </Unit> | ||
| 145 | + <Unit filename="src/objects/os/macos/savedesktopicon.c"> | ||
| 146 | + <Option compilerVar="CC" /> | ||
| 147 | + </Unit> | ||
| 142 | <Unit filename="src/objects/os/windows/open.c"> | 148 | <Unit filename="src/objects/os/windows/open.c"> |
| 143 | <Option compilerVar="CC" /> | 149 | <Option compilerVar="CC" /> |
| 144 | </Unit> | 150 | </Unit> |
| @@ -0,0 +1,87 @@ | @@ -0,0 +1,87 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + | ||
| 4 | + Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 5 | + (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 6 | + aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 7 | + | ||
| 8 | + Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 9 | + | ||
| 10 | + Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 11 | + os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 12 | + Free Software Foundation. | ||
| 13 | + | ||
| 14 | + Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 15 | + GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 16 | + A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 17 | + obter mais detalhes. | ||
| 18 | + | ||
| 19 | + Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 20 | + programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 21 | + St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + Contatos: | ||
| 25 | + | ||
| 26 | + perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 27 | + erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 28 | + | ||
| 29 | +--> | ||
| 30 | + | ||
| 31 | +<schemalist> | ||
| 32 | + | ||
| 33 | + <schema path="/br/com/bb/@PRODUCT_NAME@/" id="br.com.bb.@PRODUCT_NAME@"> | ||
| 34 | + | ||
| 35 | + <key name="ui-style" type="u"> | ||
| 36 | + <default>2</default> | ||
| 37 | + <summary>UI Style</summary> | ||
| 38 | + <description>The ID of the current user interface style</description> | ||
| 39 | + </key> | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + <key name="allow-host-settings" type="b"> | ||
| 43 | + <default>true</default> | ||
| 44 | + <summary>Allow host settings</summary> | ||
| 45 | + <description>Allow changing of host session properties</description> | ||
| 46 | + </key> | ||
| 47 | + | ||
| 48 | + <key name="allow-open-session-actions" type="b"> | ||
| 49 | + <default>true</default> | ||
| 50 | + <summary>Enable open session actions actions</summary> | ||
| 51 | + <description>Enable open session actions</description> | ||
| 52 | + </key> | ||
| 53 | + | ||
| 54 | + <key name="allow-new-tab-actions" type="b"> | ||
| 55 | + <default>true</default> | ||
| 56 | + <summary>Enable new tab actions</summary> | ||
| 57 | + <description>Enable new tab actions</description> | ||
| 58 | + </key> | ||
| 59 | + | ||
| 60 | + <key name="allow-new-window-actions" type="b"> | ||
| 61 | + <default>true</default> | ||
| 62 | + <summary>Enable new window actions</summary> | ||
| 63 | + <description>Enable new window actions</description> | ||
| 64 | + </key> | ||
| 65 | + | ||
| 66 | + <key name="default-session-file" type="s"> | ||
| 67 | + <default>'~/.config/default.3270'</default> | ||
| 68 | + <summary>Path of the default session file</summary> | ||
| 69 | + <description></description> | ||
| 70 | + </key> | ||
| 71 | + | ||
| 72 | + <key name="update-default-session-file" type="b"> | ||
| 73 | + <default>false</default> | ||
| 74 | + <summary>Update default session time from command line</summary> | ||
| 75 | + <description></description> | ||
| 76 | + </key> | ||
| 77 | + | ||
| 78 | + <key name="add-session-to-recent-manager" type="b"> | ||
| 79 | + <default>true</default> | ||
| 80 | + <summary>Add session file to recent file list</summary> | ||
| 81 | + <description></description> | ||
| 82 | + </key> | ||
| 83 | + | ||
| 84 | + </schema> | ||
| 85 | + | ||
| 86 | +</schemalist> | ||
| 87 | + |
| @@ -0,0 +1,121 @@ | @@ -0,0 +1,121 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + | ||
| 4 | + Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 5 | + (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 6 | + aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 7 | + | ||
| 8 | + Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 9 | + | ||
| 10 | + Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 11 | + os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 12 | + Free Software Foundation. | ||
| 13 | + | ||
| 14 | + Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 15 | + GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 16 | + A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 17 | + obter mais detalhes. | ||
| 18 | + | ||
| 19 | + Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 20 | + programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 21 | + St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + Contatos: | ||
| 25 | + | ||
| 26 | + perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 27 | + erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 28 | + | ||
| 29 | +--> | ||
| 30 | + | ||
| 31 | +<schemalist> | ||
| 32 | + | ||
| 33 | + <schema path="/br/com/bb/@PRODUCT_NAME@/window/" id="br.com.bb.@PRODUCT_NAME@.window"> | ||
| 34 | + | ||
| 35 | + <key name="width" type="i"> | ||
| 36 | + <default>-1</default> | ||
| 37 | + <summary>The window width.</summary> | ||
| 38 | + <description></description> | ||
| 39 | + </key> | ||
| 40 | + | ||
| 41 | + <key name="height" type="i"> | ||
| 42 | + <default>-1</default> | ||
| 43 | + <summary>The window height.</summary> | ||
| 44 | + <description></description> | ||
| 45 | + </key> | ||
| 46 | + | ||
| 47 | + <key name="is-maximized" type="b"> | ||
| 48 | + <default>false</default> | ||
| 49 | + <summary>Is the window maximized?</summary> | ||
| 50 | + <description></description> | ||
| 51 | + </key> | ||
| 52 | + | ||
| 53 | + <key name="is-fullscreen" type="b"> | ||
| 54 | + <default>false</default> | ||
| 55 | + <summary>Is the window in full screen mode?</summary> | ||
| 56 | + <description></description> | ||
| 57 | + </key> | ||
| 58 | + | ||
| 59 | + <key name="has-subtitle" type="b"> | ||
| 60 | + <default>false</default> | ||
| 61 | + <summary>Enable top window subtitle</summary> | ||
| 62 | + <description>If TRUE, reserve space for a subtitle, even if none is currently set.</description> | ||
| 63 | + </key> | ||
| 64 | + | ||
| 65 | + <key name="toolbar-visible" type="b"> | ||
| 66 | + <default>false</default> | ||
| 67 | + <summary>The toolbar visible state</summary> | ||
| 68 | + <description></description> | ||
| 69 | + </key> | ||
| 70 | + | ||
| 71 | + <key name="toolbar-style" type="i"> | ||
| 72 | + <default>-1</default> | ||
| 73 | + <summary>How to draw the toolbar.</summary> | ||
| 74 | + <description></description> | ||
| 75 | + </key> | ||
| 76 | + | ||
| 77 | + <key name="toolbar-icon-size" type="i"> | ||
| 78 | + <default>0</default> | ||
| 79 | + <summary>The size of the toolbar icons</summary> | ||
| 80 | + <description></description> | ||
| 81 | + </key> | ||
| 82 | + | ||
| 83 | + <key name="toolbar-icon-type" type="i"> | ||
| 84 | + <default>0</default> | ||
| 85 | + <summary>Use symbolic icons on toolbar</summary> | ||
| 86 | + <description></description> | ||
| 87 | + </key> | ||
| 88 | + | ||
| 89 | + <key name="header-icon-type" type="i"> | ||
| 90 | + <default>0</default> | ||
| 91 | + <summary>Use symbolic icons on title bar</summary> | ||
| 92 | + <description></description> | ||
| 93 | + </key> | ||
| 94 | + | ||
| 95 | + <key name="toolbar-position" type="i"> | ||
| 96 | + <default>0</default> | ||
| 97 | + <summary>The toolbar position</summary> | ||
| 98 | + <description></description> | ||
| 99 | + </key> | ||
| 100 | + | ||
| 101 | + <key name="toolbar-action-names" type="s"> | ||
| 102 | + <default>'win.copy,win.paste,win.select-all,separator,win.clear,win.erase-input,separator,win.print,separator,win.zoom-out,win.zoom-fit-best,win.zoom-in'</default> | ||
| 103 | + <summary>The toolbar action list</summary> | ||
| 104 | + <description></description> | ||
| 105 | + </key> | ||
| 106 | + | ||
| 107 | + <key name="header-action-names" type="s"> | ||
| 108 | + <default>'app.tab.new:menu.open-menu,win.disconnect,win.reconnect'</default> | ||
| 109 | + <summary>The title bar action list</summary> | ||
| 110 | + <description></description> | ||
| 111 | + </key> | ||
| 112 | + | ||
| 113 | + <key name="default-session-file" type="s"> | ||
| 114 | + <default>''</default> | ||
| 115 | + <summary>Path of the default session file</summary> | ||
| 116 | + <description></description> | ||
| 117 | + </key> | ||
| 118 | + | ||
| 119 | + </schema> | ||
| 120 | + | ||
| 121 | +</schemalist> |
src/objects/application/application.c
| @@ -34,26 +34,15 @@ enum { | @@ -34,26 +34,15 @@ enum { | ||
| 34 | 34 | ||
| 35 | static GParamSpec * props[NUM_PROPERTIES]; | 35 | static GParamSpec * props[NUM_PROPERTIES]; |
| 36 | 36 | ||
| 37 | -struct _pw3270ApplicationClass { | ||
| 38 | - GtkApplicationClass parent_class; | ||
| 39 | -}; | ||
| 40 | - | ||
| 41 | -struct _pw3270Application { | ||
| 42 | - GtkApplication parent; | ||
| 43 | - | ||
| 44 | - GSettings * settings; | ||
| 45 | - GList * keypads; | ||
| 46 | - gchar * logfile; | ||
| 47 | - GSList * plugins; ///< @brief Handlers of the loaded plugins. | ||
| 48 | - PW3270_UI_STYLE ui_style; | ||
| 49 | - | ||
| 50 | -}; | ||
| 51 | - | ||
| 52 | static void startup(GApplication * application); | 37 | static void startup(GApplication * application); |
| 53 | static void activate(GApplication * application); | 38 | static void activate(GApplication * application); |
| 54 | static void finalize(GObject *object); | 39 | static void finalize(GObject *object); |
| 55 | 40 | ||
| 56 | -G_DEFINE_TYPE(pw3270Application, pw3270Application, GTK_TYPE_APPLICATION); | 41 | +#ifdef __APPLE__ |
| 42 | + G_DEFINE_TYPE(pw3270Application, pw3270Application, GTKOSX_TYPE_APPLICATION); | ||
| 43 | +#else | ||
| 44 | + G_DEFINE_TYPE(pw3270Application, pw3270Application, GTK_TYPE_APPLICATION); | ||
| 45 | +#endif // __APPLE__ | ||
| 57 | 46 | ||
| 58 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) { | 47 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) { |
| 59 | 48 | ||
| @@ -186,6 +175,7 @@ static void pw3270Application_class_init(pw3270ApplicationClass *klass) { | @@ -186,6 +175,7 @@ static void pw3270Application_class_init(pw3270ApplicationClass *klass) { | ||
| 186 | 175 | ||
| 187 | } | 176 | } |
| 188 | 177 | ||
| 178 | +#ifndef __APPLE__ | ||
| 189 | static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { | 179 | static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { |
| 190 | 180 | ||
| 191 | g_autoptr(GSettings) app_settings = pw3270_application_settings_new(); | 181 | g_autoptr(GSettings) app_settings = pw3270_application_settings_new(); |
| @@ -230,6 +220,7 @@ static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gcha | @@ -230,6 +220,7 @@ static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gcha | ||
| 230 | return TRUE; | 220 | return TRUE; |
| 231 | 221 | ||
| 232 | } | 222 | } |
| 223 | +#endif // __APPLE__ | ||
| 233 | 224 | ||
| 234 | static gboolean on_logfile(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError G_GNUC_UNUSED(**error)) { | 225 | static gboolean on_logfile(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError G_GNUC_UNUSED(**error)) { |
| 235 | pw3270_application_set_log_filename(g_application_get_default(),value); | 226 | pw3270_application_set_log_filename(g_application_get_default(),value); |
| @@ -239,7 +230,7 @@ static gboolean on_logfile(const gchar G_GNUC_UNUSED(*option), const gchar *valu | @@ -239,7 +230,7 @@ static gboolean on_logfile(const gchar G_GNUC_UNUSED(*option), const gchar *valu | ||
| 239 | static void pw3270Application_init(pw3270Application *app) { | 230 | static void pw3270Application_init(pw3270Application *app) { |
| 240 | 231 | ||
| 241 | static GOptionEntry cmd_options[] = { | 232 | static GOptionEntry cmd_options[] = { |
| 242 | - | 233 | +#ifndef __APPLE__ |
| 243 | { | 234 | { |
| 244 | "user-interface", | 235 | "user-interface", |
| 245 | 'U', | 236 | 'U', |
| @@ -249,6 +240,7 @@ static void pw3270Application_init(pw3270Application *app) { | @@ -249,6 +240,7 @@ static void pw3270Application_init(pw3270Application *app) { | ||
| 249 | N_( "Set the user-interface type" ), | 240 | N_( "Set the user-interface type" ), |
| 250 | NULL | 241 | NULL |
| 251 | }, | 242 | }, |
| 243 | +#endif // __APPLE__ | ||
| 252 | { | 244 | { |
| 253 | "logfile", | 245 | "logfile", |
| 254 | 'l', | 246 | 'l', |
| @@ -266,41 +258,61 @@ static void pw3270Application_init(pw3270Application *app) { | @@ -266,41 +258,61 @@ static void pw3270Application_init(pw3270Application *app) { | ||
| 266 | 258 | ||
| 267 | g_application_add_main_option_entries(G_APPLICATION(app), cmd_options); | 259 | g_application_add_main_option_entries(G_APPLICATION(app), cmd_options); |
| 268 | 260 | ||
| 269 | -#ifdef _WIN32 | 261 | + app->settings = pw3270_application_settings_new(); |
| 262 | + | ||
| 263 | +#if defined(_WIN32) | ||
| 264 | + // | ||
| 265 | + // Setup windows UI | ||
| 266 | + // | ||
| 270 | app->ui_style = PW3270_UI_STYLE_CLASSICAL; | 267 | app->ui_style = PW3270_UI_STYLE_CLASSICAL; |
| 268 | + { | ||
| 269 | + // https://stackoverflow.com/questions/37035936/how-to-get-native-windows-decorations-on-gtk3-on-windows-7-and-msys2 | ||
| 270 | + int gtk_csd = g_settings_get_int(app->settings,"gtk-csd"); | ||
| 271 | + if(gtk_csd != -1) { | ||
| 272 | + g_autofree gchar * env = g_strdup_printf("GTK_CSD=%d",gtk_csd); | ||
| 273 | + putenv(env); | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + if(app->settings) { | ||
| 278 | + g_object_ref_sink(G_OBJECT(app->settings)); | ||
| 279 | + g_settings_bind(app->settings, "ui-style", app, "ui-style", G_SETTINGS_BIND_DEFAULT); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + { | ||
| 283 | + lib3270_autoptr(char) plugin_path = lib3270_build_data_filename("plugins",NULL); | ||
| 284 | + pw3270_load_plugins_from_path(app, plugin_path); | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | +#elif defined(__APPLE__) | ||
| 288 | + // | ||
| 289 | + // Setup Apple UI | ||
| 290 | + // | ||
| 291 | + { | ||
| 292 | + lib3270_autoptr(char) plugin_path = lib3270_build_data_filename("plugins",NULL); | ||
| 293 | + pw3270_load_plugins_from_path(app, plugin_path); | ||
| 294 | + } | ||
| 271 | #else | 295 | #else |
| 296 | + // | ||
| 297 | + // Setup linux UI | ||
| 298 | + // | ||
| 272 | app->ui_style = PW3270_UI_STYLE_AUTOMATIC; | 299 | app->ui_style = PW3270_UI_STYLE_AUTOMATIC; |
| 273 | -#endif // _WIN32 | ||
| 274 | - | ||
| 275 | - // Get settings | ||
| 276 | app->settings = pw3270_application_settings_new(); | 300 | app->settings = pw3270_application_settings_new(); |
| 277 | - | ||
| 278 | - // Bind properties | ||
| 279 | if(app->settings) { | 301 | if(app->settings) { |
| 280 | - | ||
| 281 | g_object_ref_sink(G_OBJECT(app->settings)); | 302 | g_object_ref_sink(G_OBJECT(app->settings)); |
| 303 | + g_settings_bind(app->settings, "ui-style", app, "ui-style", G_SETTINGS_BIND_DEFAULT); | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + pw3270_load_plugins_from_path(app, G_STRINGIFY(LIBDIR) G_DIR_SEPARATOR_S G_STRINGIFY(PRODUCT_NAME) "-plugins"); | ||
| 282 | 307 | ||
| 283 | -#ifdef _WIN32 | ||
| 284 | - { | ||
| 285 | - // https://stackoverflow.com/questions/37035936/how-to-get-native-windows-decorations-on-gtk3-on-windows-7-and-msys2 | ||
| 286 | - int gtk_csd = g_settings_get_int(app->settings,"gtk-csd"); | ||
| 287 | - if(gtk_csd != -1) { | ||
| 288 | - g_autofree gchar * env = g_strdup_printf("GTK_CSD=%d",gtk_csd); | ||
| 289 | - putenv(env); | ||
| 290 | - } | ||
| 291 | - } | ||
| 292 | #endif // _WIN32 | 308 | #endif // _WIN32 |
| 293 | 309 | ||
| 294 | - g_settings_bind(app->settings, "ui-style", app, "ui-style", G_SETTINGS_BIND_DEFAULT); | ||
| 295 | - } | 310 | + /* |
| 311 | + | ||
| 312 | + FIX-ME: Move to other place. | ||
| 296 | 313 | ||
| 297 | // Get plugins. | 314 | // Get plugins. |
| 298 | { | 315 | { |
| 299 | -#ifdef _WIN32 | ||
| 300 | - lib3270_autoptr(char) path = lib3270_build_data_filename("plugins",NULL); | ||
| 301 | -#else | ||
| 302 | - const gchar * path = G_STRINGIFY(LIBDIR) G_DIR_SEPARATOR_S G_STRINGIFY(PRODUCT_NAME) "-plugins"; | ||
| 303 | -#endif // _WIN32 | ||
| 304 | 316 | ||
| 305 | if(g_file_test(path,G_FILE_TEST_IS_DIR)) { | 317 | if(g_file_test(path,G_FILE_TEST_IS_DIR)) { |
| 306 | 318 | ||
| @@ -349,17 +361,19 @@ static void pw3270Application_init(pw3270Application *app) { | @@ -349,17 +361,19 @@ static void pw3270Application_init(pw3270Application *app) { | ||
| 349 | 361 | ||
| 350 | } | 362 | } |
| 351 | 363 | ||
| 352 | - // Initialize plugins | ||
| 353 | - { | ||
| 354 | - GSList * item; | ||
| 355 | - void (*call)(GtkApplication *application); | ||
| 356 | 364 | ||
| 357 | - for(item = app->plugins; item; item = g_slist_next(item)) { | ||
| 358 | - if(g_module_symbol((GModule *) item->data, "pw3270_plugin_set_application", (gpointer *) &call)) { | ||
| 359 | - call(GTK_APPLICATION(app)); | ||
| 360 | - } | ||
| 361 | - } | 365 | + } |
| 366 | + */ | ||
| 367 | + | ||
| 368 | + // Initialize plugins | ||
| 369 | + { | ||
| 370 | + GSList * item; | ||
| 371 | + void (*call)(GtkApplication *application); | ||
| 362 | 372 | ||
| 373 | + for(item = app->plugins; item; item = g_slist_next(item)) { | ||
| 374 | + if(g_module_symbol((GModule *) item->data, "pw3270_plugin_set_application", (gpointer *) &call)) { | ||
| 375 | + call(GTK_APPLICATION(app)); | ||
| 376 | + } | ||
| 363 | } | 377 | } |
| 364 | 378 | ||
| 365 | } | 379 | } |
| @@ -520,6 +534,7 @@ void activate(GApplication *application) { | @@ -520,6 +534,7 @@ void activate(GApplication *application) { | ||
| 520 | 534 | ||
| 521 | void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) { | 535 | void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) { |
| 522 | 536 | ||
| 537 | +#ifndef __APPLE__ | ||
| 523 | g_return_if_fail(PW3270_IS_APPLICATION(app)); | 538 | g_return_if_fail(PW3270_IS_APPLICATION(app)); |
| 524 | 539 | ||
| 525 | pw3270Application * application = PW3270_APPLICATION(app); | 540 | pw3270Application * application = PW3270_APPLICATION(app); |
| @@ -530,12 +545,18 @@ void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) { | @@ -530,12 +545,18 @@ void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) { | ||
| 530 | application->ui_style = type; | 545 | application->ui_style = type; |
| 531 | g_object_notify_by_pspec(G_OBJECT(app), props[PROP_UI_STYLE]); | 546 | g_object_notify_by_pspec(G_OBJECT(app), props[PROP_UI_STYLE]); |
| 532 | 547 | ||
| 548 | +#endif // !__APPLE | ||
| 549 | + | ||
| 533 | } | 550 | } |
| 534 | 551 | ||
| 535 | PW3270_UI_STYLE pw3270_application_get_ui_style(GApplication *app) { | 552 | PW3270_UI_STYLE pw3270_application_get_ui_style(GApplication *app) { |
| 536 | 553 | ||
| 554 | +#ifdef __APPLE__ | ||
| 555 | + return PW3270_UI_STYLE_GNOME; | ||
| 556 | +#else | ||
| 537 | g_return_val_if_fail(PW3270_IS_APPLICATION(app),PW3270_UI_STYLE_CLASSICAL); | 557 | g_return_val_if_fail(PW3270_IS_APPLICATION(app),PW3270_UI_STYLE_CLASSICAL); |
| 538 | return PW3270_APPLICATION(app)->ui_style; | 558 | return PW3270_APPLICATION(app)->ui_style; |
| 559 | +#endif // __APPLE__ | ||
| 539 | 560 | ||
| 540 | } | 561 | } |
| 541 | 562 |
| @@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
| 1 | +/* SPDX-License-Identifier: LGPL-3.0-or-later */ | ||
| 2 | + | ||
| 3 | +/* | ||
| 4 | + * Copyright (C) 2008 Banco do Brasil S.A. | ||
| 5 | + * | ||
| 6 | + * This program is free software: you can redistribute it and/or modify | ||
| 7 | + * it under the terms of the GNU Lesser General Public License as published | ||
| 8 | + * by the Free Software Foundation, either version 3 of the License, or | ||
| 9 | + * (at your option) any later version. | ||
| 10 | + * | ||
| 11 | + * This program is distributed in the hope that it will be useful, | ||
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | + * GNU General Public License for more details. | ||
| 15 | + * | ||
| 16 | + * You should have received a copy of the GNU Lesser General Public License | ||
| 17 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | +#include "private.h" | ||
| 21 | + | ||
| 22 | +void pw3270_load_plugins_from_path(pw3270Application *app, const char *path) { | ||
| 23 | + | ||
| 24 | + if(g_file_test(path,G_FILE_TEST_IS_DIR)) { | ||
| 25 | + | ||
| 26 | + g_message("Loading plugins from %s",path); | ||
| 27 | + | ||
| 28 | + GError * err = NULL; | ||
| 29 | + GDir * dir = g_dir_open(path,0,&err); | ||
| 30 | + | ||
| 31 | + if(dir) { | ||
| 32 | + | ||
| 33 | + const gchar *name; | ||
| 34 | + while((name = g_dir_read_name(dir)) != NULL) { | ||
| 35 | + | ||
| 36 | + g_autofree gchar *filename = g_build_filename(path,name,NULL); | ||
| 37 | + | ||
| 38 | + if(g_str_has_suffix(filename,G_MODULE_SUFFIX)) { | ||
| 39 | + | ||
| 40 | + g_message("Loading %s",filename); | ||
| 41 | + | ||
| 42 | + GModule *handle = g_module_open(filename,G_MODULE_BIND_LOCAL); | ||
| 43 | + | ||
| 44 | + if(handle) { | ||
| 45 | + | ||
| 46 | + app->plugins = g_slist_append(app->plugins,handle); | ||
| 47 | + | ||
| 48 | + } else { | ||
| 49 | + | ||
| 50 | + g_warning("Can't load %s: %s",filename,g_module_error()); | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + g_dir_close(dir); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + if(err) { | ||
| 62 | + | ||
| 63 | + g_warning("Can't load plugins from %s: %s",path,err->message); | ||
| 64 | + g_error_free(err); | ||
| 65 | + | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | +} |
src/objects/application/private.h
| @@ -46,10 +46,38 @@ | @@ -46,10 +46,38 @@ | ||
| 46 | #include <lib3270.h> | 46 | #include <lib3270.h> |
| 47 | #include <lib3270/log.h> | 47 | #include <lib3270/log.h> |
| 48 | 48 | ||
| 49 | +#ifdef __APPLE__ | ||
| 50 | + #include <gtkosxapplication.h> | ||
| 51 | +#endif // __APPLE__ | ||
| 52 | + | ||
| 53 | +#include <pw3270/application.h> | ||
| 54 | + | ||
| 55 | +struct _pw3270Application { | ||
| 56 | +#ifdef __APPLE__ | ||
| 57 | + GtkosxApplication parent; | ||
| 58 | +#else | ||
| 59 | + GtkApplication parent; | ||
| 60 | + PW3270_UI_STYLE ui_style; | ||
| 61 | +#endif // __APPLE__ | ||
| 62 | + | ||
| 63 | + GSettings * settings; | ||
| 64 | + GList * keypads; | ||
| 65 | + gchar * logfile; | ||
| 66 | + GSList * plugins; ///< @brief Handlers of the loaded plugins. | ||
| 67 | + | ||
| 68 | +}; | ||
| 69 | + | ||
| 70 | +struct _pw3270ApplicationClass { | ||
| 71 | + GtkApplicationClass parent_class; | ||
| 72 | +}; | ||
| 73 | + | ||
| 74 | + | ||
| 49 | G_GNUC_INTERNAL void pw3270_application_open(GApplication * application, GFile **files, gint n_files, const gchar *hint); | 75 | G_GNUC_INTERNAL void pw3270_application_open(GApplication * application, GFile **files, gint n_files, const gchar *hint); |
| 50 | 76 | ||
| 51 | G_GNUC_INTERNAL GtkWidget * pw3270_terminal_new(const gchar *session_file); | 77 | G_GNUC_INTERNAL GtkWidget * pw3270_terminal_new(const gchar *session_file); |
| 52 | 78 | ||
| 79 | +G_GNUC_INTERNAL void pw3270_load_plugins_from_path(pw3270Application *app, const char *path); | ||
| 80 | + | ||
| 53 | // Actions | 81 | // Actions |
| 54 | G_GNUC_INTERNAL GAction * pw3270_about_action_new(); | 82 | G_GNUC_INTERNAL GAction * pw3270_about_action_new(); |
| 55 | G_GNUC_INTERNAL GAction * pw3270_preferences_action_new(); | 83 | G_GNUC_INTERNAL GAction * pw3270_preferences_action_new(); |
src/objects/os/linux/savedesktopicon.c
| @@ -105,7 +105,7 @@ static const struct _entry { | @@ -105,7 +105,7 @@ static const struct _entry { | ||
| 105 | 105 | ||
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | -GAction * pw3270_action_save_desktop_icon_new(void) { | 108 | +GAction * pw3270_action_save_session_shortcut_new(void) { |
| 109 | 109 | ||
| 110 | V3270SimpleAction * action = v3270_dialog_action_new(factory); | 110 | V3270SimpleAction * action = v3270_dialog_action_new(factory); |
| 111 | 111 | ||
| @@ -117,40 +117,6 @@ GAction * pw3270_action_save_desktop_icon_new(void) { | @@ -117,40 +117,6 @@ GAction * pw3270_action_save_desktop_icon_new(void) { | ||
| 117 | 117 | ||
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | -/* | ||
| 121 | -static gchar * get_filename(GtkWidget *terminal) { | ||
| 122 | - | ||
| 123 | - g_autofree gchar * defname = v3270_keyfile_get_default_filename(); | ||
| 124 | -const gchar * current = v3270_key_file_get_filename(terminal); | ||
| 125 | - | ||
| 126 | -// If is not the default name, return it. | ||
| 127 | -if(strcmp(defname,current)) { | ||
| 128 | - return g_strdup(current); | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -// It's the default one, create a new one on the user_config dir | ||
| 132 | -g_autofree gchar * config_path = v3270_key_file_get_default_path(terminal); | ||
| 133 | - | ||
| 134 | -// Use the hostname | ||
| 135 | -const char * hostname = lib3270_host_get_name(v3270_get_session(terminal)); | ||
| 136 | -if(!hostname) { | ||
| 137 | - hostname = G_STRINGIFY(PRODUCT_NAME); | ||
| 138 | -} | ||
| 139 | - | ||
| 140 | -// Build the filename | ||
| 141 | -gchar *filename = g_strconcat(config_path,G_DIR_SEPARATOR_S,hostname,".3270",NULL); | ||
| 142 | - | ||
| 143 | -unsigned int index = 0; | ||
| 144 | -while(g_file_test(filename,G_FILE_TEST_EXISTS)) { | ||
| 145 | - g_free(filename); | ||
| 146 | - filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s.%u.3270",config_path,hostname,++index); | ||
| 147 | -} | ||
| 148 | - | ||
| 149 | -return filename; | ||
| 150 | - | ||
| 151 | -} | ||
| 152 | -*/ | ||
| 153 | - | ||
| 154 | GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { | 120 | GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { |
| 155 | 121 | ||
| 156 | size_t ix; | 122 | size_t ix; |
| @@ -0,0 +1,163 @@ | @@ -0,0 +1,163 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | +#include <config.h> | ||
| 31 | + | ||
| 32 | +#include <lib3270.h> | ||
| 33 | +#include <lib3270/log.h> | ||
| 34 | +#include <pw3270/application.h> | ||
| 35 | +#include <pw3270/window.h> | ||
| 36 | +#include <v3270.h> | ||
| 37 | +#include <v3270/keyfile.h> | ||
| 38 | + | ||
| 39 | +static gchar * v3270_keyfile_find(const gchar *name) { | ||
| 40 | + // | ||
| 41 | + // It can be a session file, scans for it | ||
| 42 | + // | ||
| 43 | + const gchar * paths[] = { | ||
| 44 | + g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS), | ||
| 45 | + g_get_user_config_dir() | ||
| 46 | + }; | ||
| 47 | + | ||
| 48 | + static const gchar *subdirs[] = { | ||
| 49 | + "3270", | ||
| 50 | + G_STRINGIFY(PRODUCT_NAME), | ||
| 51 | + PACKAGE_NAME | ||
| 52 | + }; | ||
| 53 | + | ||
| 54 | + size_t path, subdir; | ||
| 55 | + | ||
| 56 | + g_autofree gchar * filename = g_strconcat(name,".3270",NULL); | ||
| 57 | + | ||
| 58 | + for(path = 0; path < G_N_ELEMENTS(paths); path++) { | ||
| 59 | + | ||
| 60 | + // Try subdirs. | ||
| 61 | + for(subdir = 0; subdir < G_N_ELEMENTS(subdirs); subdir++) { | ||
| 62 | + | ||
| 63 | + gchar * fullpath = g_build_filename(paths[path],subdirs[subdir],filename,NULL); | ||
| 64 | + | ||
| 65 | + debug("Searching for \"%s\"",fullpath); | ||
| 66 | + | ||
| 67 | + if(g_file_test(fullpath,G_FILE_TEST_IS_REGULAR)) { | ||
| 68 | + return fullpath; | ||
| 69 | + } | ||
| 70 | + g_free(fullpath); | ||
| 71 | + | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + // Try path. | ||
| 75 | + { | ||
| 76 | + gchar * fullpath = g_build_filename(paths[path],filename,NULL); | ||
| 77 | + | ||
| 78 | + debug("Searching for \"%s\"",fullpath); | ||
| 79 | + | ||
| 80 | + if(g_file_test(fullpath,G_FILE_TEST_IS_REGULAR)) { | ||
| 81 | + return fullpath; | ||
| 82 | + } | ||
| 83 | + g_free(fullpath); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return NULL; | ||
| 89 | + | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +/// @brief Open session file | ||
| 93 | +static void open(GtkApplication *application, GtkWindow **window, const gchar *filename) { | ||
| 94 | + | ||
| 95 | + g_message("Opening '%s'",filename); | ||
| 96 | + | ||
| 97 | + if(*window) { | ||
| 98 | + | ||
| 99 | + // Already open a window, open in new tab. | ||
| 100 | + pw3270_application_window_new_tab(GTK_WIDGET(*window), filename); | ||
| 101 | + | ||
| 102 | + } else { | ||
| 103 | + // It's a new window | ||
| 104 | + *window = GTK_WINDOW(pw3270_application_window_new(application, filename)); | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +void pw3270_application_open_file(GtkApplication *application, GtkWindow **window, GFile *file) { | ||
| 111 | + | ||
| 112 | + g_autofree gchar * scheme = g_file_get_uri_scheme(file); | ||
| 113 | + | ||
| 114 | + if(g_ascii_strcasecmp(scheme,"file") == 0) { | ||
| 115 | + | ||
| 116 | + // It's a file scheme. | ||
| 117 | + if(g_file_query_exists(file,NULL)) { | ||
| 118 | + | ||
| 119 | + // The file exists, load it. | ||
| 120 | + g_autofree gchar *filename = g_file_get_path(file); | ||
| 121 | + open(application,window,filename); | ||
| 122 | + | ||
| 123 | + } else { | ||
| 124 | + | ||
| 125 | + // Search for file. | ||
| 126 | + g_autofree gchar * basename = g_file_get_basename(file); | ||
| 127 | + g_autofree gchar * filename = v3270_keyfile_find(basename); | ||
| 128 | + | ||
| 129 | + if(filename) { | ||
| 130 | + open(application,window,filename); | ||
| 131 | + } else { | ||
| 132 | + g_warning("Cant find session '%s'",basename); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + } else if(g_ascii_strcasecmp(scheme,"tn3270") == 0 || g_ascii_strcasecmp(scheme,"tn3270s") == 0) { | ||
| 138 | + | ||
| 139 | + g_autofree gchar * uri = g_file_get_uri(file); | ||
| 140 | + size_t sz = strlen(uri); | ||
| 141 | + | ||
| 142 | + if(sz > 0 && uri[sz-1] == '/') | ||
| 143 | + uri[sz-1] = 0; | ||
| 144 | + | ||
| 145 | + g_message("Opening '%s' with default settings",uri); | ||
| 146 | + | ||
| 147 | + if(!*window) { | ||
| 148 | + *window = GTK_WINDOW(pw3270_application_window_new(application, NULL)); | ||
| 149 | + } else { | ||
| 150 | + pw3270_application_window_new_tab(GTK_WIDGET(*window), NULL); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + GtkWidget * terminal = pw3270_application_window_get_active_terminal(GTK_WIDGET(*window)); | ||
| 154 | + v3270_set_default_session(terminal); | ||
| 155 | + v3270_set_url(terminal,uri); | ||
| 156 | + | ||
| 157 | + } else { | ||
| 158 | + | ||
| 159 | + g_warning("Don't know how to handle '%s' scheme",scheme); | ||
| 160 | + | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | +} |
| @@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * @brief Implement MacOS version of the save desktop icon action. | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | +#include <v3270.h> | ||
| 36 | +#include <pw3270.h> | ||
| 37 | +#include <pw3270/application.h> | ||
| 38 | +#include <v3270/actions.h> | ||
| 39 | +#include <v3270/keyfile.h> | ||
| 40 | +#include <v3270/settings.h> | ||
| 41 | +#include <lib3270.h> | ||
| 42 | +#include <lib3270/log.h> | ||
| 43 | +#include <lib3270/properties.h> | ||
| 44 | +#include <v3270/tools.h> | ||
| 45 | + | ||
| 46 | +static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal); | ||
| 47 | + | ||
| 48 | +GAction * pw3270_action_save_session_shortcut_new(void) { | ||
| 49 | + | ||
| 50 | + V3270SimpleAction * action = v3270_dialog_action_new(factory); | ||
| 51 | + | ||
| 52 | + action->name = "save.launcher"; | ||
| 53 | + action->label = _("Save session shortcut"); | ||
| 54 | + action->tooltip = _("Create shortcut for the current session"); | ||
| 55 | + | ||
| 56 | + return G_ACTION(action); | ||
| 57 | + | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { | ||
| 61 | + | ||
| 62 | + GtkWidget * dialog = | ||
| 63 | + gtk_message_dialog_new( | ||
| 64 | + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), | ||
| 65 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
| 66 | + GTK_MESSAGE_ERROR, | ||
| 67 | + GTK_BUTTONS_OK, | ||
| 68 | + _("This action is not available in this platform") | ||
| 69 | + ); | ||
| 70 | + | ||
| 71 | + g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); | ||
| 72 | + g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); | ||
| 73 | + | ||
| 74 | + return dialog; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +static void apply(GtkWidget *dialog, GtkWidget *terminal) { | ||
| 78 | + | ||
| 79 | +} | ||
| 80 | + |
src/objects/os/windows/savedesktopicon.c
| @@ -98,7 +98,7 @@ static const struct _entry { | @@ -98,7 +98,7 @@ static const struct _entry { | ||
| 98 | 98 | ||
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | -GAction * pw3270_action_save_desktop_icon_new(void) { | 101 | +GAction * pw3270_action_save_session_shortcut_new(void) { |
| 102 | 102 | ||
| 103 | V3270SimpleAction * action = v3270_dialog_action_new(factory); | 103 | V3270SimpleAction * action = v3270_dialog_action_new(factory); |
| 104 | 104 |
src/objects/window/private.h
| @@ -91,7 +91,7 @@ G_GNUC_INTERNAL GAction * pw3270_file_transfer_action_new(void); | @@ -91,7 +91,7 @@ G_GNUC_INTERNAL GAction * pw3270_file_transfer_action_new(void); | ||
| 91 | G_GNUC_INTERNAL GAction * pw3270_action_window_close_new(void); | 91 | G_GNUC_INTERNAL GAction * pw3270_action_window_close_new(void); |
| 92 | G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); | 92 | G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); |
| 93 | G_GNUC_INTERNAL GAction * pw3270_action_save_session_preferences_new(void); | 93 | G_GNUC_INTERNAL GAction * pw3270_action_save_session_preferences_new(void); |
| 94 | -G_GNUC_INTERNAL GAction * pw3270_action_save_desktop_icon_new(void); | 94 | +G_GNUC_INTERNAL GAction * pw3270_action_save_session_shortcut_new(void); |
| 95 | 95 | ||
| 96 | GAction * pw3270_action_session_properties_new(void); | 96 | GAction * pw3270_action_session_properties_new(void); |
| 97 | 97 |
src/objects/window/window.c
| @@ -501,22 +501,18 @@ static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | @@ -501,22 +501,18 @@ static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | ||
| 501 | size_t ix; | 501 | size_t ix; |
| 502 | 502 | ||
| 503 | GAction * actions[] = { | 503 | GAction * actions[] = { |
| 504 | -// pw3270_action_host_properties_new(), | ||
| 505 | pw3270_action_session_properties_new(), | 504 | pw3270_action_session_properties_new(), |
| 506 | -// pw3270_set_color_action_new(), | ||
| 507 | - | ||
| 508 | pw3270_action_save_session_preferences_new(), | 505 | pw3270_action_save_session_preferences_new(), |
| 509 | - | ||
| 510 | pw3270_file_transfer_action_new(), | 506 | pw3270_file_transfer_action_new(), |
| 511 | - | ||
| 512 | pw3270_action_window_close_new(), | 507 | pw3270_action_window_close_new(), |
| 513 | - | ||
| 514 | pw3270_action_connect_new(), | 508 | pw3270_action_connect_new(), |
| 515 | 509 | ||
| 516 | v3270_pfkey_action_new(), | 510 | v3270_pfkey_action_new(), |
| 517 | v3270_pakey_action_new(), | 511 | v3270_pakey_action_new(), |
| 518 | 512 | ||
| 519 | - pw3270_action_save_desktop_icon_new(), | 513 | +#ifndef __APPLE__ |
| 514 | + pw3270_action_save_session_shortcut_new(), | ||
| 515 | +#endif // __APPLE__ | ||
| 520 | 516 | ||
| 521 | }; | 517 | }; |
| 522 | 518 | ||
| @@ -535,10 +531,14 @@ static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | @@ -535,10 +531,14 @@ static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | ||
| 535 | // | 531 | // |
| 536 | // Bind properties | 532 | // Bind properties |
| 537 | // | 533 | // |
| 534 | +#ifdef __APPLE__ | ||
| 535 | + gtk_application_window_set_show_menubar(GTK_APPLICATION_WINDOW(widget),TRUE); | ||
| 536 | +#else | ||
| 538 | g_action_map_add_action( | 537 | g_action_map_add_action( |
| 539 | G_ACTION_MAP(widget), | 538 | G_ACTION_MAP(widget), |
| 540 | G_ACTION(g_property_action_new("menubar", widget, "show-menubar")) | 539 | G_ACTION(g_property_action_new("menubar", widget, "show-menubar")) |
| 541 | ); | 540 | ); |
| 541 | +#endif // !__APPLE__ | ||
| 542 | 542 | ||
| 543 | g_settings_bind( | 543 | g_settings_bind( |
| 544 | settings, | 544 | settings, |
| @@ -639,15 +639,19 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | @@ -639,15 +639,19 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | ||
| 639 | #endif // DEBUG | 639 | #endif // DEBUG |
| 640 | 640 | ||
| 641 | if(style == PW3270_UI_STYLE_AUTOMATIC) { | 641 | if(style == PW3270_UI_STYLE_AUTOMATIC) { |
| 642 | - | ||
| 643 | -#ifdef G_OS_UNIX | 642 | +#if defined(__APPLE__) |
| 643 | + style = PW3270_UI_STYLE_GNOME; | ||
| 644 | + g_settings_set_int(settings,"header-icon-type",1); | ||
| 645 | +#elif defined( G_OS_UNIX ) | ||
| 644 | style = PW3270_UI_STYLE_GNOME; | 646 | style = PW3270_UI_STYLE_GNOME; |
| 645 | g_settings_set_boolean(settings,"menubar-visible",FALSE); | 647 | g_settings_set_boolean(settings,"menubar-visible",FALSE); |
| 646 | g_settings_set_int(settings,"header-icon-type",1); | 648 | g_settings_set_int(settings,"header-icon-type",1); |
| 647 | -#else | 649 | +#elif defined( G_OS_WIN32 ) |
| 648 | style = PW3270_UI_STYLE_CLASSICAL; | 650 | style = PW3270_UI_STYLE_CLASSICAL; |
| 649 | g_settings_set_boolean(settings,"menubar-visible",TRUE); | 651 | g_settings_set_boolean(settings,"menubar-visible",TRUE); |
| 650 | g_settings_set_int(settings,"header-icon-type",0); | 652 | g_settings_set_int(settings,"header-icon-type",0); |
| 653 | +#else | ||
| 654 | + #error Unsupported platform | ||
| 651 | #endif // G_OS_UNIX | 655 | #endif // G_OS_UNIX |
| 652 | 656 | ||
| 653 | g_settings_set_boolean(settings,"toolbar-visible",TRUE); | 657 | g_settings_set_boolean(settings,"toolbar-visible",TRUE); |
| @@ -691,6 +695,7 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | @@ -691,6 +695,7 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | ||
| 691 | 695 | ||
| 692 | } | 696 | } |
| 693 | 697 | ||
| 698 | +#ifndef __APPLE__ | ||
| 694 | g_settings_bind( | 699 | g_settings_bind( |
| 695 | settings, | 700 | settings, |
| 696 | "menubar-visible", | 701 | "menubar-visible", |
| @@ -698,6 +703,7 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | @@ -698,6 +703,7 @@ GtkWidget * pw3270_application_window_new(GtkApplication * application, const gc | ||
| 698 | "show-menubar", | 703 | "show-menubar", |
| 699 | G_SETTINGS_BIND_DEFAULT | 704 | G_SETTINGS_BIND_DEFAULT |
| 700 | ); | 705 | ); |
| 706 | +#endif // !__APPLE__ | ||
| 701 | 707 | ||
| 702 | } | 708 | } |
| 703 | 709 |