Hello Linux

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

Moderator: Rathinagiri

Post Reply
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Hello Linux

Post by Rathinagiri »

This is Roberto's post:

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:

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&#46;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!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply