Cross platform GUI project (debugger for FreeBASIC)

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

Thanks AGS, uploaded!

The system auto-generated the main page using the file ReadMe.md.

Download (requires GIT client software on your system):
  • git clone git://github.com/fbdebugger/fbdebugger
If you want to use the CMake build system, find a short introduction in file src/doc/_preparation.md.


@SARG
I needed signal handler names for the callback SUBs. Here's what I set now:
  • act_clipprocs -> List all procs
  • act_clipselpr -> List selected proc
  • act_copyprocvar -> Copy all proc/var
  • act_copyselprocvar -> Copy selected proc/var
BR
SARG
Posts: 1764
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by SARG »

@TFJ
TJF wrote:I needed signal handler names for the callback SUBs. Here's what I set now:
  • act_clipprocs -> List all procs
  • act_clipselpr -> List selected proc
  • act_copyprocvar -> Copy all proc/var
  • act_copyselprocvar -> Copy selected proc/var
For List all procs and List selected proc, the name are already existing.

Code: Select all

    <child>
      <object class="GtkAction" id="action111">
        <property name="label" translatable="yes">List all proc/var (log)</property>
        <signal name="activate" handler="act_varlistall" swapped="no"/>
      </object>
    </child>
    <child>
      <object class="GtkAction" id="action112">
        <property name="label" translatable="yes">List selected proc/var (log)</property>
        <signal name="activate" handler="act_varlistsel" swapped="no"/>
      </object>
    </child>
For Copy all proc/var and Copy selected proc/var the names are ok.

Thanks you both.
I was able to download the project. What is happening now it's what i was scared : I have to find my way in all the files ;-)

I have compiled directly fbdbg : no compile error but when executed nothing appears.For now I have to leave home. I'll search later but some help is welcome.

EDIT : my fault, I was a bit hurry and I did it too quickly ; I have moved the exe and the ui files were not found....... All is working now.

BR.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

SARG wrote:For List all procs and List selected proc, the name are already existing.
Couldn't find them, because I re-ordered the action and menu numbers. OK now.
SARG wrote:For Copy all proc/var and Copy selected proc/var the names are ok.
I changed them to be closer to your naming scheme
  • act_varclipall -> List all procs
  • act_varclipsel -> List selected proc
SARG wrote:... no compile error ...
Sounds promissing!
SARG wrote:... All is working now.
Also the GtkSourceView and syntax highlighting? This needs a config file to be installed, since GtkSourceView doesn't have an FB file by default.
SARG wrote: I have to find my way in all the files ;-)
So it is ... keep on reporting and asking, so that I know if / how I can help.

I cleaned up the source files, moved all signal handlers from the single files in tobac folder to the gui folder, and grouped them in code files by appearance. Ie. mbar_buttons.bas are toolbar buttons, menu_procvar.bas are menu items in the ProcVar popup menu, ... Signal handlers for actions that poxxies multiple widgets are in multi_action.bas.
SARG wrote:I have compiled directly fbdbg
I use a CMake out-of-source build, so that the source tree is free of binaries and I can generate several build directories for different targets. Anyway, this isn't finished yet. Targets for I18N, documentation and packing are missing.
SARG
Posts: 1764
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by SARG »

TJF wrote:Also the GtkSourceView and syntax highlighting? This needs a config file to be installed, since GtkSourceView doesn't have an FB file by default.
No code displayed only the number "1".
For testing I put exe, dll, ui files in a the same folder. I add also fbdbg.bas. Maybe other elements are missing.

By the way, there are only the 2 first items displayed in the proc/var menu (set watched...).
And the icons seem blurred. What is the best size ?
TJF wrote:So it is ... keep on reporting and asking, so that I know if / how I can help.
Sure I'll not hesitate.
TJF wrote:I cleaned up the source files, moved all signal handlers from the single files in tobac folder to the gui folder, and grouped them in code files by appearance. Ie. mbar_buttons.bas are toolbar buttons, menu_procvar.bas are menu items in the ProcVar popup menu, ... Signal handlers for actions that poxxies multiple widgets are in multi_action.bas.
Where to put all other procs not related to GUI ?
I'll study testing.bas. Some parameters are unclear in the GtK's functions. Need to look at the doc.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

TJF wrote:The system auto-generated the main page using the file ReadMe.md.
Since this is the front page of our repository, I think you (AGS & SARG) should check and adapt the context in file ReadMe.md, which currently is a quick-and-dirty proposal for the documentation mock-up.
SARG wrote:No code displayed only the number "1".
This means the GtkSourceView is working and shows the line number, but no source code is loaded. (I didn't get this working here yet.)

In file testing.bas (line 38 ff.) I load this file (itself) in to the text buffer, if present.
SARG wrote:For testing I put exe, dll, ui files in a the same folder. I add also fbdbg.bas. Maybe other elements are missing.
Put file testing.bas in to the same folder and you should see some source (but no syntax highlighting yet).
SARG wrote:And the icons seem blurred. What is the best size ?
as mentioned:
TJF wrote:Create new icons in 32x32 pixel size and store them in PNG format. Then edit the file src/fbdbg.ui and replace all .bmp by .png. That should be all to use the new icons (old .bmp files can get removed then).
SARG wrote:Where to put all other procs not related to GUI ?
I prepared a folder named core for all source code that isn't related to the gui. The CMake build system is prepared to compile this source as separate modules in to object files and link them to the executable. Uncomment lines 1 to 7 in testing.bas to test this.
SARG wrote:By the way, there are only the 2 first items displayed in the proc/var menu (set watched...).
Another test to see if you're testing everything. Again, you stand the proof ;-)

To be honest: I reordered the object IDs and I've overseen an adaption. That'll be fixed in my next upload. But since this is a good
intruduction to our last lesson on user actions, I recommend that you fix it manually as well. Just do
  • load the file fbdbg.ui near to your executable in an editor
  • search for 'menu_button3_event' (you'll find it several times)
  • in the line
    fbdbg.ui wrote: <signal name="button-press-event" handler="menu_button3_event" object="menu100" swapped="no"/>
    replace 'menu100' by 'menu10'
  • save the file
  • start the executable and check the menu again
Working now? (The program behaviour changed without compiling the executable. It's magic, isn't it?)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

SARG wrote:I can't wait ;-)
Here you are: the last lesson, related to user actions.

We learned how to create a widget by classic coding (snippet[12]) or by using GtkBuilder and XML syntax (snippet3). And we learned that we can change an existent widget by classic coding only. This lessen will show how to get noticed on actions the user performs on our GUI.

As in all modern GUI toolkits, also GTK+ uses a signal system for that purpose. The basis object (GObject) implements that signal system and provides a single signal, named "notify". Like the object properties also the signals get referenced by a name (a string). Each object that gets derived from GObject inherits this signal and can add further signals.

The next object level is the GtkWidget. It implements a bunch of signals (more than 30) for different purposes. You rarly need this signals, they'll give you low-level-access for complex activities. Not all signals get emitted by default, some of them are masked out in oder to gain execution speed. Try to avoid using those signals.

All further GUI objects are derived from GtkWidget, inheriting the signals and adding new ones. This is the signal level that you'll use most often. Ie. a GtkButton implements the "clicked" signal, that gets emitted when the user clicks on that button. Or a GtkAction emits the "activate" signal, that gets emitted when any proxied widget gets activated (like a click on a menu item or a click on a [toolbar] button, but also a keystroke that triggers that action).

By default the signals are either doing nothing (no handler in the signal queue) or are connected to a default GTK handler. Ie. a right click in a GtkTextView triggers the default handler that pops up a menu for clipboard actions. You can connect customized signal handlers, that get executed when the signal gets emitted. (Rarly used: more than one handler can get connected to a queue. In that case the callbacks get called in the order they were connected. At run-time, you can add further callbacks or remove existent from the queue.)

High level signals are (mostly) SUBs with simple signature, using only two parameters (like GtkButton, GtkAction)
  • the widget (GObject PTR) that sends the signal
  • an optional gpionter for user data
In low-level signals you can find more complex signatures. Ie. the "menu_button3_event" callback mentioned in my last post gets connected to the signal "button-press-event" (GtkWidget level). The signal handler returns a gboolean value (and therefor is a FUNCTION) and gets five parameters, in order to make it easy to access additional data on how the triggering event happend.

When you want to get noticed on a user action, you've to connect a signal handler to the related widget signal. Therefor
  • create a callback in FB source (a SUB or FUNCTION) and
  • connect that callback to the widgets signal.
Let's check this in the code. Ie. to connect the callback "menu_button3_event" to the "button-press-event" signal of the GtkTreeView, the later can be done either by classic coding (snippet2 syntax) by

Code: Select all

g_signal_connect(tviewProcVar, "button-press-event", G_CALLBACK(@menu_button3_event), menu10)
or by using a GtkBuilder parsing XML code like

Code: Select all

<object class="GtkTreeView" id="tviewProcVar">
...
  <signal name="button-press-event" handler="menu_button3_event" object="menu10" swapped="no"/>
...
Note: the first syntax is based on the GLib macro g_signal_connect(). This macro isn't in the Gir/Gtk-3.0.bi header, since the header gets auto-translated by GirToBac from an .gir file and those files do not contain macro defines. You'll need an additional header to use this syntax: #INCLUDE ONCE "Gir/_GObjectMacros-2.0.bi".

Since most signal connections wont change at run-time, it's wise not to pollute the source code by that kind of code. I prefer to connect signal handlers by using the XML syntax, whenever possible. Let's analyse the attributes
  • name="button-press-event" -> the name of the signal
  • handler="menu_button3_event" -> the name of the callback (a SUB or FUNCTION in FB code here)
  • object="menu10" -> an optional object ID, that gets passed as last argument in the parameter list (similar to last parameter in g_signal_connect)
  • swapped="no" -> the order of the passed arguments (will get explained later)
When GtkBuilder parses that line, it searches the executables list of exported symbols to find the SUB or FUNCTION "menu_button3_event" and connects that adress to the signal handler (at run-time). Since an object is specified, GtkBuilder stores the adress of that object as parameter for user_data, which is the last argument that gets passed when the signal gets emitted and the callback gets called.

This concept offers a lot of possibilities. Beside FB callbacks, you can also connect GTK+ functions to handle a signal. Ie. in the source there is no code to end the program. Instead in file fbdbg.ui the signal "destroy" from the main window (ID="window1") is connected to the GTK function "gtk_main_quit", like

Code: Select all

  <object class="GtkWindow" id="window1">
...
    <signal name="destroy" handler="gtk_main_quit" swapped="no"/>
...
When the user closes that window (ie. by pressing <Alt>F4), the function gtk_main_quit() gets called and the program ends (and destroys the main window and all subwindows). This function has the signature void(viod) (= SUB()) and therefor doesn't receive any parameter.

Another example is the about dialog. You wont find any FB code to handle that dialog. In the fbdbg.ui XML code the signal "activate" of the related action (ID="action099") gets connected to the function gtk_dialog_run(). This function requires a pointer to the dialog to run as the first parameter. We have to specify that object pointer as user_data when the signal gets emitted

Code: Select all

<object class="GtkAction" id="action099">
...
  <signal name="activate" handler="gtk_dialog_run" object="aboutdialog1" swapped="yes"/>
...
By default the user_data gets passed as the second argument in an GtkAction "activate" signal. The attribute swapped="yes" swappes the first and the last argument for that callback call, so that in this case function gtk_dialog_run gets called with the 'aboutdialog1' pointer as first argument.

To close that dialog, its signal "response" is connected to function gtk_widget_hide(). This signal gets emitted when the user performs a final action on the dialog, ie. by pressing <Alt>F4 or Esc, or by clicking the 'Close' button.

Code: Select all

<object class="GtkAboutDialog" id="aboutdialog1">
...
  <signal name="response" handler="gtk_widget_hide" swapped="no"/>
...
Since the widget should hide itself, we do not swap the arguments here.

A last example, let's enlight the issue with the ProvVar popup menu. The corrected code is

Code: Select all

<signal name="button-press-event" handler="menu_button3_event" object="menu10" swapped="no"/>
Here the signal "button-press-event" (GtkWidget level) gets connected to the FB callback menu_button3_event(), located in file main.bas. This function checks which button is pressed, first. It does nothing (RETURN FALSE), exept when button 3 (=right mouse button) is pressed. In that case it calls the function gtk_menu_popup() and returns TRUE (to stop further signal handling by default handlers). The related menu gets passed as the last argument (user_data). When connecting the signals to the diverse widgets, different popup menus get specified as user_data, so that the same callback can be used to pop up widget specific menus.

Due to my mistake when re-naming the menu widget IDs, the wrong menu was specified for that signal connection. fbdbg.exe showed "menu100", which is the first submenu in the ProcVar popup. Instead, "menu10" should popup, which is the complete menu.


As we see, this signal system is a powerful tool to specify program flow in the GUI designer by XML code. But it also has its limits
  • not for all GTK functions
  • only object pointers from the same GtkBuilder can be used
What you cannot do (and where we need an FB callback) is
  • pass a user_data pointer containing an object from FB source
  • evaluate dialogs user action (like YES NO)
A last note on callbacks:

The FB compiler cannot check the parameter list for a callback (no compiler can). It's up to you to make sure that your signal handler receives the correct parameter argument types (and returns the right type, if required). Find the callback signatures in the documentation, section "signals" of the related widget.

[Edit]Typo fixed[/Edit]
Last edited by TJF on Feb 12, 2015 7:45, edited 1 time in total.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by AGS »

One of the advantages of using GTK is that you can find lots of examples on how to use it on the net. And the gtk+ repository (over at gnome git https://git.gnome.org/browse/gtk+/ ) contains quite a few examples as well (especially the programs in the directory test are most informative).

The GtkSourceView project has some examples on how to work with the widget https://git.gnome.org/browse/gtksourceview/tree/tests/ that you can compile easily (assuming you have GtkSourceView and GTK+ installed).

A tutorial for GTK+ (version 3.x) can be found here
https://python-gtk-3-tutorial.readthedo ... index.html

The tutorial was written for python programmers but I think you'll find it most useful.

@SARG
Would it be an idea (for a future version of fbdebugger perhaps) to change the layout of the main window? Currently it looks like this (not including toolbar)

Code: Select all

Top: information on current line
Middle->left: source code tabbed notebook
Middle->right: tabbed notebook (with variables etc...)
Bottom: other things
The above lay-out could be turned into a set of panels https://developer.gnome.org/gtk3/stable/GtkPaned.html

Using panels the user can minimize whatever he wants minimized. Currently there are three buttons you can use to achieve a similar effect. The panels would allow for more subtle changes in lay - out of the main window (eg smaller source code panel -> bigger variable panel, smaller bottom panel -> bigger panel for code and variables etc...).

@TJF
Off-topic but important: do you have fb bindings for gtk 3.6.x? Not much has changed since 3.4.x so I guess I can use bindings I got when installing the fbc (they are for 3.4.x).
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

AGS wrote:@TJF
Off-topic but important: do you have fb bindings for gtk 3.6.x? Not much has changed since 3.4.x so I guess I can use bindings I got when installing the fbc (they are for 3.4.x).
I've only a working LINUX installation. On wine my binaries don't match. I couldn't get GtkSourceView working yet. (Not sure if it's a wine issue.)

@SARG: What did you install to get it working?
AGS wrote:Using panels the user can minimize whatever he wants minimized. Currently there are three buttons you can use to achieve a similar effect. The panels would allow for more subtle changes in lay - out of the main window (eg smaller source code panel -> bigger variable panel, smaller bottom panel -> bigger panel for code and variables etc...).
In the current solution there's already a paned container between the two notebooks. I didn't implement a vertical paned container, since there are only two lines to change.
SARG
Posts: 1764
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by SARG »

Hi all,

For now at work so a quick reply.

- Adding testing.bas in the folder : no change --> no code displayed.
- No problem replacing 'menu100' by 'menu10', the whole menu appears.
- About GtkSourceView I don't remind, need to be home for answering.

I will study carefully all the information you have given me.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

TJF wrote:
AGS wrote:@TJF
Off-topic but important: do you have fb bindings for gtk 3.6.x? Not much has changed since 3.4.x so I guess I can use bindings I got when installing the fbc (they are for 3.4.x).
I've only a working LINUX installation. On wine my binaries don't match. I couldn't get GtkSourceView working yet. (Not sure if it's a wine issue.)
I just noticed: I misread your post, you're talking about bindings, not binaries.

You'll need the GTK+ bindings from GNOME Header-Satz 1.0 (32/64 bit), since GtkSourceView is available only in this package. The set includes GTK+-3.10 bindings. All are 64-bit compatible, but not (partial?) compatible with the bindings shipped with fbc.
SARG
Posts: 1764
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by SARG »

TJF wrote:@SARG: What did you install to get it working?
Donwload file = mingw32-gtksourceview3-3.4.1-1.fc17.noarch.cpio.gz
used file = libgtksourceview-3.0-0.dll dated : april, 17th 2012
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

Hi all!

I implemented a new file named gui/source.bas which contains a class to handle the notebook for the source code (by moving some code from testing.bas). It's in GIT now.
SARG wrote: --> no code displayed.
Please compile and try to load a file (button with files.bmp). Does it get displayed?
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

Hi!

I got it running under wine now. And I removed a function not available in GTK+-3.6 (updated in GIT).

Here's a screenshot, including syntax highlighting

Image
SARG
Posts: 1764
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by SARG »

Hi,

I got an error :

Code: Select all

fbdbg.o: In function `SRCNOTEBOOK::ADDBAS(char*, char*)@12':
D:\FBDEBUG3\SRC\GUI\SOURCE.BAS:149: undefined reference to `gtk_button_new_from_icon_name'
By the way, I read some docs about git but all is not clear, I have to try and see what is happening.
Regarding GTK I read also docs and tutorials. The problem, here, is to find what I need in all these functions ;-)
More time this WE so I hope to go forward.

Edit : Time to go to sleep I'll test tomorrow, maybe the removed function is that one.
Screenshot looks good.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Cross platform GUI project (debugger for FreeBASIC)

Post by TJF »

SARG wrote:I got an error :

Code: Select all

fbdbg.o: In function `SRCNOTEBOOK::ADDBAS(char*, char*)@12':
D:\FBDEBUG3\SRC\GUI\SOURCE.BAS:149: undefined reference to `gtk_button_new_from_icon_name'
..., maybe the removed function is that one.
Yes, it is! This is a convenient function, introduced in 3.10. I've overseen that. It's already fixed in GIT.
SARG wrote:By the way, I read some docs about git but all is not clear, I have to try and see what is happening.
Sure, trial and error is also my prefered way to learn. For downloading, I use at the command line in the repo folder (once the repo is cloned):
  • git pull
Did you try
  • git gui
to start the GUI (helped a lot for me to comprehend what's going on)
SARG wrote:Regarding GTK I read also docs and tutorials. The problem, here, is to find what I need in all these functions ;-)
More time this WE so I hope to go forward.

Edit : Time to go to sleep I'll test tomorrow ...
Screenshot looks good.
Yes, it's a lot. Unlike QT, in GTK+ I can understand the source code and get additional informations. Don't spend too much time in learning theory. We're a team. I can help to get you started or at least pick out wrong directions, if I know where you want to start and what you're dealing with.

@AGS: What's your state? Did you compile and run the code yet?

My next topics will be
  • A class for the expand dialogs
  • The log windows (screen and file)
  • Learning how to use CSS styles to manipulate the widgets look (button borders)
BR
Post Reply