User Tools

Site Tools


k11:k11.10:start

11.10.0 Passing on a Gambas program - Installation package

Often there is a desire to pass on a Gambas program. Two approaches are possible:

  • Passing on the Gambas project in a source code archive. Required prerequisite: Gambas is also completely installed on the target computer in a relevant version.
  • Transfer of the program as an installation package (archive) for selected Linux distributions. An installation package consists of several files. Required prerequisite: On the target computer, the Gambas packages can be installed in a version whose version number is equal to or greater than that on the development computer.

Gambas provides suitable export dialogs for both variants in the IDE. This → chapter 11.10 explains how to generate an installation package for a target distribution.

11.10.0.1 Base

The description of how to put together an installation package and install it on a target computer is based on a concrete objective with narrowly defined boundary conditions - implemented in the StructDB project. In my opinion, the note is necessary because there will be no general, promising description for every Linux distribution and for every (stable) version of Gambas.

Objective:

  • Developer E develops and tests the StructDB project (StructDB program as a simple database application) under Ubuntu 12.04 LTS (support until 2017), deploys a stable Gambas from the project sources and finally shuts down the Gambas installation package for the target distribution Ubuntu/Mint.
  • User B uses Mint 17.1 (Rebecca) on the target computer and all Gambas packages from the (stable) Ubuntu-PPA can be installed. The Gambas development environment (IDE) is not installed there because it is not needed to install the Gambas installation package - stored in the ~/IP_StructDB folder on the target computer - from B (with root privileges) and to use the StructDB program.

Figure 11.10.0.1.1: GUI for the program StructDB

11.10.0.2 Previews

These previews are the result of many attempts to successfully compile an installation package and reflect the experience with the wizard for generating an installation package (? packer wizard). Success is considered successful if the installation package can be installed by user B with root privileges on the target computer without any problems and user B can use the installed program as specified in the program specification.

As soon as you create the project whose program you want to pass on, you should be sure about the type of project and the options to be selected, and choose the type and the appropriate options. For programs with a GUI, you can choose:

  • Graphic application
  • QT-GUI application
  • GTK+ Graphic application

If you select 'Graphical application', the component gb.gui will be loaded at development time and the Packer Wizard will load both the gb.gtk packages and the gb.qt4 packages to the dependencies list. As a result, you will find 3 different *.deb files in the package:

  • StructDB_1.2.12-0ubuntu1_all.deb.
  • StructDB_gtk_1.2.12-0ubuntu1_all.deb.
  • StructDB_qt4_1.2.12-0ubuntu1_all.deb

and leads to the question: Which Debian package is used on the target machine?

You can install the StructDB_gtk_1.2.12-0ubuntu1_all.deb package or the StructDB_qt4_1.2.12-0ubuntu1_all.deb package, or both. However, since these two packages depend on the Debian package StructDB_1.2.12-0ubuntu1_all.deb, which is the project without GUI dependencies, the StructDB_1.2.12-0ubuntu1_all.deb package is also installed in any case.

  • When creating a new project, select the same names for the project name and the project title in the project information. For example, if you select' StructDB' as the project name and' StructDataBase' as the project title, then the project title' StructDataBase' appears in the menu on the target computer, while you have to call the program in the console with' StructDB'.
  • Since later on the development computer in the packer wizard in step 1 essential information from the basic settings of Gambas are automatically transferred into the installation package and are also displayed on the target computer during the program installation, you should enter the information about the editor in time under Tools> Settings> Identity.
  • In step 9, the Packer Wizard prompts you to specify the folder in which the wizard should store the generated installation package. Here it is advantageous if this (empty) folder already exists.

11.10.0.3 Project description

(F1) Defining program configurations (configuration file)
(F2) Multilingual application
(F3) Using a program help ( → function key F1)
(F4) Sharing of files that can only be read by all users
(F5) Sharing of files that require a user's write and read rights
(F6) Starting the program with and without argument
(F7) Creating your own MIME type for program-specific data files

The following sections and further chapters describe how to successfully implement the above requirements using the StructDB project as an example. At suitable places, some extracts from the source code of the project support the description.

11.10.0.4 Defining Program Configurations

The component gb.settings is used to define program configurations in a configuration file (→ Chapter 19.1). The window coordinates of the program window are stored in the configuration file in the standard path in the StructDB project.

Only at the first start the program window is centered. The values that were saved in the configuration file when the program window was closed then apply:

Public Sub Form_Open()If IsNull(structSettings["Window/Top"]) And IsNull(structSettings["Window/Left"]) Then 
     FMain.Center
  Else
     FMain.Top = structSettings["Window/Top", FMain.Top] 
     FMain.Left = structSettings["Window/Left", FMain.Left] 
  EndifEnd ' Form_Open()
Public Sub Form_Close()
  structSettings["Window/Top"] = FMain.Top 
  structSettings["Window/Left"] = FMain.Left 
  If FHelp.Closed = False Then FHelp.Close
End ' Form_Close()

11.10.0.5 Multilingual application

In the Options tab of the project settings, the default language English (UK) is selected in the Options tab after the Project can be translated question has been answered with Yes. Further information on the internationalization (I18N) of a project can be found in? chapter 20.1.3 Message and I18N and in? chapter 11.11 Project I18N.

The quickest way to start the translation of the individual texts into the German language is to use CTRL+T or start it in the menu under Project> Translate - you only have to translate it yourself.

11.10.0.6 Program Help

Give the program StructDB and all future users a program help. The help in the main program is called with the function key F1 and the event Form_KeyPress() is evaluated in the main program. In response, a further form - FHelp in this case - is displayed with the help text which is closed with the escape key (ESC):

Public Sub Form_KeyPress()
  If Key.Code = Key.F1 Then 
     FHelp.Show
  Endif 
  If Key.Code = Key.ESC And FHelp.Closed = False Then 
     FHelp.Delete
  Endif 
End ' Form_KeyPress()
 
Public Sub Form_Show()
  FHelp.Border = 1
  FHelp.Arrangement = Arrange.Fill
  TextArea1.Background = &H00FFFFDF&
  TextArea1.Text = File.Load("help.txt") ' → Relative path!
End ' Form_Show()

The help text is only read from a file help.txt, since it does not have to be changed for the current program version. The help file is located in the IDE in the logical folder “Data”, which corresponds to the physical project folder.

Note: All files in the physical project directory are included in the “Gambas executable” when the StructDB.gambas executable file is generated. You can't find them anywhere in the file system of the target computer; but you can't reach them under “Application. Path” either! Details about this freely selected classification of folders (logical/physical) in a Gambas project can be found in the next paragraph.

11.10.0.7 Directory paths

The following explanations are generally necessary - also for understanding the transfer of files in the installation project:

On a data carrier, which will often be the computer hard disk, the Gambas project StructDB is located in a certain directory structure. If you switch on the display of hidden files/folders in your file browser, you will see some hidden folders that Gambas uses for control files as well as files and folders (marked red) that you have copied or created into the project directory.

Struktur

Figure 11.10.0.7.7.1: Directory structure project directory (file browser)

If you edit the StructDB project in the Gambas IDE, you will surely notice the difference to the directory structure in → figure 11.10.0.7.1:

IDE

Figure 11.10.0.7.7.2: Directory Structure (Project Folder) Gambas IDE

11.10.0.8 Sharing files that can only be read by all users

If you also want to use the installation package to install files system-wide on the target computer, but to protect files from writing access by regular (non-root) users, then copy these files to the physical folder. hidden at the time of development or create them in the logical folder “Project” in the IDE, for example!

Hidden

Figure 11.10.0.8.8.1: Files in hidden folder.hidden

  • For example, select /usr/share/doc/StructDB as the destination folder in step 8 of the Packer Wizard, under usr/share/doc/StructDB you will normally find the read-only (data) files of installed programs.
  • When installing the installation package on the target computer, the selected files from the logical folder “Project” are automatically copied to the specified target paths!
  • Note that you must define the paths in good time, as they will not be used when coding and testing the application. Therefore, make sure that the program. txt file is also located in the logical folder “Data”. This is necessary if you test the program on the development computer. You should separate from the idea to create a folder /usr/share/doc/StructDB and copy the program. txt file there, because you need root privileges to create the folder in the specified system path!
  • In addition to the (short) documentation program. txt, the icon file structdb_dfi.png in the project StructDB is also exported from the folder 'Symbol' and the file structdb.xml from the folder 'XML'.

11.10.0.9 Sharing files that require read and write permissions from the user

User-specific files, on the other hand, are stored in user B's home directory on the target computer. Here, the content can only be read and edited by user B, unlike all other users. These user-specific files must be located in the IDE folder structure in the logical folder “Data” - that is, in the physical project folder. Such a file is in the project StructDB example. sdb (→ Figure 11.10.0.7.1), which is given to the program StructDB as a sample database and requires read and write permissions from user B. This file is called StructDB example. sdb (→ Figure 11.10.0.7.1).

But pay attention: You cannot install the user-specific file example.sdb with a Debian package, because the Debian Installer will always start as root and cannot recognize that you are, for example, the system user B with the sonorous name gambanix. Therefore, when the program is started for the first time, the selected user-specific file example. sdb is copied to the StructDB folder in user B's home directory. The folder whose name you can freely choose will be created if it does not exist - which is to be checked:

Public Sub Form_Open()If Not Exist(User.Home &/ "StructDB") Then
     Try Mkdir User.Home &/ "StructDB"
 
     If Error Then 
        Message.Error(Subst$(("Couldn't create the directory &1"), User.Home &/ "StructDB" & Error.Code))
        Quit
     Else
        Try Copy "example.sdb" To User.Home &/ "StructDB/example.sdb"
        If Error Then
           Message.Error(Subst$(("Couldn't copy the file &1"), User.Home &/ "StructDB/example.sdb"))
        Endif
        Wait
     Endif
 
  Endif ' Not Exist(User.Home &/ "StructDB")
…
 
End ' Form_Open()

11.10.0.10 Program start with and without argument

The program start of StructDB on a target computer (Mint 17.1 with German language package) is done either via the menu or by a created starter on the desktop or by calling it in the console - in the first case without argument:

hans@linuxmint:~$ /usr/bin/StructDB 
hans@linuxmint:~$ StructDB 

B1

Figure 11.10.0.10.1: Program start without argument

In the second case, the (pseudo) database file example.sdb is passed as argument at program startup:

hans@linuxmint:~$ StructDB -- ~/Kursdaten/example.sdb

2

B2

Figure 11.10.0.10.10.2: Program start with file as argument

In the source code there is a small section in the procedure Form_Open(), which opens the program safely with and without argument when starting the program:

Public sOpenProjectPath As String
 
Dim sArgsString As String
Dim bOpenByArgs As Boolean
 
  Args.Begin()
  Args.End()
  For Each sArgsString In Args.End()
    If Not IsNull(sArgsString) Then
       sOpenProjectPath = sArgsString
       Import(sOpenProjectPath)
       tlblRecords.Foreground = Color.Red
       bOpenByArgs = True
    Endif
  Next
 
  If bOpenByArgs = False Then
     cmbDWC1.Text = cmbDWC1[0].Text  
     cmbDWC2.Text = cmbDWC2[1].Text
     tlblRecords.Visible = False
     tlblRecords.Foreground = Color.Red
     Status(False)
     btnUpdate.Enabled = False
     btnSave.Enabled = False
     txbLastname.SetFocus    
  Endif ' bOpenByArgs = False ?

2 methods of the component gb.args are used. A detailed description of this component can be found in chapter 5.8.0 Gambas programs with options and arguments.

11.10.0.11 MIME type for the data files

More elegant would be the possibility that after double-clicking on a *.sdb file, the database program StructDB opens, the records from the selected *.sdb file are read and displayed. To achieve this, you must

  • either explore the MIME type of the *.sdb files and pass this MIME type to the installation package in the 6th step of the Packer Wizard or
  • of the installation package to create and register a program-specific MIME type on the target computer → chapter 11.10.1. This requires entries in steps 6 and 8 in the Packer Wizard.

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k11/k11.10/start.txt · Last modified: 23.09.2023 by honsek

Page Tools