Hello Linux!!!

HMG announcements; Latest HMG-related news, releases, fixes and updates.

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Hello Linux!!!

Post by Roberto Lopez »

Hi All,

For those finding interesting the experimentation, here are some tips:

1. Install Ubuntu 10.04.

2. Download and install Harbour compiler for Ubuntu: http://sourceforge.net/projects/harbour ... b/download

3. Install Development files for the GTK+ library. You can do it with Synaptic Package Manager (libgtk2.0-dev).

4. Create a file called test.prg (with the code below) and build it with hbmk test `pkg-config --cflags --libs gtk+-2.0` command . Run it with ./test

test.prg:

Code: Select all

function main()

	PUBLIC bButtonAction := { || GTK_MSGINFO('Click!!!') }

	GTK_INIT()

	aRet := GTK_DEFINEWINDOW( 100 , 100 , 400 , 200 , "hello Linux!!!!" )

	GTK_DEFINEBUTTON ( aRet [2] , 50 , 50 , 'Click Me!!' )

	GTK_ACTIVATEWINDOW()

return nil

*----------------------------------------------------------------------------------------------*
PROCEDURE HMG_BUTTON_CALLBACK ( HANDLE )
*----------------------------------------------------------------------------------------------*
	EVAL ( bButtonAction )
RETURN
*----------------------------------------------------------------------------------------------*
#pragma BEGINDUMP
#include <gtk/gtk.h>
// BUTTON ONCLICK EVENT HANDLER ////////////////////////////////////
static long button_clicked ( GtkWidget *handle )
{
	static PHB_DYNS Dyns = 0 ;
	long int r;
	if( ! Dyns )
	{
		Dyns = hb_dynsymFindName( "HMG_BUTTON_CALLBACK" );
	}
	hb_vmPushSymbol( hb_dynsymSymbol( Dyns ) );
	hb_vmPushNil();
	hb_vmPushLong( (long) handle );
	hb_vmPushLong( 0 );
	hb_vmPushLong( 0 );
	hb_vmPushLong( 0 );
	hb_vmDo( 4 );

	r = hb_parnl( -1 );

	return r;
}
static gboolean delete_event( GtkWidget *widget,GdkEvent  *event, gpointer   data )
{
    g_print ("delete event occurred\n");
    return FALSE;
}
static void destroy( GtkWidget *widget, gpointer   data )
{
    gtk_main_quit ();
}
//--------------------------------------------------------------------------------------------//
HB_FUNC ( GTK_INIT )
//--------------------------------------------------------------------------------------------//
{
    gtk_init ( 0 , 0 );
}
//--------------------------------------------------------------------------------------------//
HB_FUNC ( GTK_DEFINEWINDOW )
//--------------------------------------------------------------------------------------------//
{
	GtkWidget *window;
	GtkWidget *fixed;
	char* cTitle = (gchar*) hb_parc(5);
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (window, "delete-event",G_CALLBACK (delete_event), NULL);
	g_signal_connect (window, "destroy",G_CALLBACK (destroy), NULL);
	gtk_window_move( GTK_WINDOW(window) , hb_parni(2), hb_parni(1) );
	gtk_widget_set_size_request( GTK_WIDGET(window) , hb_parni(3) , hb_parni(4) );
	gtk_window_set_title( GTK_WINDOW(window) , cTitle );
	/* Create a Fixed Container */
	fixed = gtk_fixed_new ();
	gtk_container_add (GTK_CONTAINER (window), fixed);
	gtk_widget_show (fixed);
	gtk_widget_show  (window);
	hb_reta(2);
	hb_storvnl( window , -1 , 1 );
	hb_storvnl( fixed , -1 , 2 );
}
//--------------------------------------------------------------------------------------------//
HB_FUNC ( GTK_DEFINEBUTTON )
//--------------------------------------------------------------------------------------------//
{
	GtkWidget *button;
	button = gtk_button_new_with_label ( (gchar*) hb_parc(4));
	gtk_fixed_put (GTK_FIXED ((long) hb_parnl(1)), button, hb_parni(2), hb_parni(3) );
	gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (button_clicked), (gpointer) button );
}
//--------------------------------------------------------------------------------------------//
HB_FUNC ( GTK_ACTIVATEWINDOW )
//--------------------------------------------------------------------------------------------//
{
	gtk_main ();
}
//--------------------------------------------------------------------------------------------//
HB_FUNC ( GTK_MSGINFO )
//--------------------------------------------------------------------------------------------//
{
GtkWidget *dialog;
	dialog = gtk_message_dialog_new ( 0 ,
                                  GTK_DIALOG_MODAL,
                                  GTK_MESSAGE_INFO,
                                  GTK_BUTTONS_OK,
                                  (gchar*) hb_parc (1) ,"Hi1" );

	gtk_dialog_run (GTK_DIALOG (dialog));
	gtk_widget_destroy (dialog);
}
#pragma ENDDUMP 
Enjoy!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hello Linux!!!

Post by Rathinagiri »

Aha! Super!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Hello Linux!!!

Post by Roberto Lopez »

rathinagiri wrote:Aha! Super!
GTK is amazing.

As I've already pointed sometimes, it is the foundation used by GNOME (the Ubuntu default desktop).

GTK is compact, simple and fast. It is extremely easy compared with Windows API.

So, for those wanting GUI support on Linux, it appeared a good idea to show how much easily, the things can be done.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Hello Linux!!!

Post by jparada »

Hi,

This is my first test and this is the result, please take a look.
javier@javier:~/testhmg$ hbmk test `pkg-config --cflags --libs gtk+-2.0`
Harbour 2.1.0beta1 (Rev. 14450)
Copyright (c) 1999-2010, http://www.harbour-project.org/
Compiling 'test.prg' and generating preprocessed output to 'thread'...
Lines 111, Functions/Procedures 2
Generating C source output to 'test.c'... Done.
test.prg: In function ‘button_clicked’:
test.prg:30: warning: assignment makes pointer from integer without a cast
test.prg: In function ‘HB_FUN_GTK_MSGINFO’:
test.prg:109: error: expected declaration or statement at end of input
javier@javier:~/testhmg$
Any help is welcome.

Thanks

PS: Under VM Ubuntu 10.4

Best Regards
Javier
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Hello Linux!!!

Post by Roberto Lopez »

jparada wrote:Hi,

This is my first test and this is the result, please take a look.
javier@javier:~/testhmg$ hbmk test `pkg-config --cflags --libs gtk+-2.0`
Harbour 2.1.0beta1 (Rev. 14450)
Copyright (c) 1999-2010, http://www.harbour-project.org/
Compiling 'test.prg' and generating preprocessed output to 'thread'...
Lines 111, Functions/Procedures 2
Generating C source output to 'test.c'... Done.
test.prg: In function ‘button_clicked’:
test.prg:30: warning: assignment makes pointer from integer without a cast
test.prg: In function ‘HB_FUN_GTK_MSGINFO’:
test.prg:109: error: expected declaration or statement at end of input
javier@javier:~/testhmg$
Any help is welcome.

Thanks

PS: Under VM Ubuntu 10.4

Best Regards
Javier
At copypasting I've missed a right bracket before #pragma ENDDUMP.

Please add it and it should work.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Hello Linux!!!

Post by sudip »

Great News! Roberto, thank you very much :)
Regards.
Sudip
With best regards,
Sudip
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Hello Linux!!!

Post by jparada »

Hi,

Thanks a lot Roberto, now works fine

I attached picture, please take a look

Thanks

Best Regards
Javier
Attachments
testhmg.png
testhmg.png (21.17 KiB) Viewed 4859 times
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Hello Linux!!!

Post by Roberto Lopez »

jparada wrote:Hi,

Thanks a lot Roberto, now works fine

I attached picture, please take a look

Thanks

Best Regards
Javier
Congratulations!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Hello Linux!!!

Post by l3whmg »

Hi Roberto,
you are SIMPLY THE ...GREAT!!

And now I must find a PC to install Linux, learn this SysOp, etc., etc., etc. :lol:

I always say to you: MANY THANKS!

Best Regards
Luigi from Italy
www.L3W.it
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Hello Linux!!!

Post by Rathinagiri »

Since this is cross platform, this can be compiled in Windows too. Isn't it?!

What are the tools to be installed in windows?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply