[fpc-pascal]problems with gtk

enzo - Eduardo Garcia enzo at compunet.net.co
Wed Jan 2 15:59:56 CET 2002


Hello list

I have the following problem.

 It is doing an aplicacion in windows for the project gcafe http://gcafe.es.gnome.org with gtk. and has had the following problems 

1. When I try to open a new window comes out with an exitcode 206.
 2. not it can create the element gtk_clock_new 

I expect that they can help me.

add the code source of the aplicacion. 

thanks


_____________________
enzo
Eduardo Garcia
Medellin - Colombia
Web site: www.geocities.com/netenzo
icq: 6985612
Messenger : jegarto at hotmail.com

---------------------------------------
Este mensaje fue enviado usando Compunet Webmail. (http://www.compunet.net.co)
-------------- next part --------------
program gcafe;

{$mode objfpc}

uses
 glib,gtk;

var
  Window       : PGtkWidget;
  WinBox       : PGtkWidget;
  HBox1        : PGtkWidget;
  HBox2        : PGtkWidget;
  HBox3        : PGtkWidget;
  HBox4        : PGtkWidget;
  MenuBar      : PGtkWidget;
  Label1       : PGtkWidget;
  Label2       : PGtkWidget;
  Label3       : PGtkWidget;
  Label4       : PGtkWidget;
  Label5       : PGtkWidget;
  Login        : PGtkWidget;
  Password     : PGtkWidget;
  HButton      : PGtkWidget;
  Button       : PGtkWidget;
  Clock        : PGtkWidget;

procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
begin
  gtk_main_quit();
end;

procedure menu(Data : GPointer; Action : Guint; Widget : pGtkWidget); cdecl;

Var
  TheLabel : PgtkWidget;
  LabelText : Pchar;
  S : AnsiString;

begin
  TheLabel  := g_list_nth_data(gtk_container_children(GTK_CONTAINER(Widget)),0);
  gtk_label_get(gtk_Label(theLabel), at LabelText);
  S := 'Chosen menu : ' + Strpas(Labeltext);
  gtk_label_set_text(GTK_LABEL(Label1),pchar(S));
end;

Procedure AcercaDe;

Var
  WAcercaDe       : PGtkWidget;
begin
  wacercade := gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(Window),'Acerca de ...');
  gtk_widget_set_usize (Window, 300, 200);
  gtk_widget_show (wacercade);

end;



Type
  FC = TGtkItemFactoryCallback;

Const
  NrMenuItems = 9;
  TheMenu : Array[1..NrMenuItems] of TGtkItemFactoryEntry = (
    (path:'/_Tarjeta';Accelerator:Nil;Callback:Nil;Callback_action:1;item_type:'<Branch>'),
    (path:'/Tarjeta/_Adicionar Tarjeta';Accelerator:'<ctrl>A';Callback:FC(@Menu);Callback_action:1;item_type:Nil),
    (path:'/Tarjeta/_Detener Tarjeta';Accelerator:'<control>D';Callback:FC(@Menu);Callback_action:1;item_type:Nil),
    (path:'/Tarjeta/_Ver Tiempo Tarjeta';Accelerator:'<control>V';Callback:FC(@Menu);Callback_action:1;item_type:Nil),
    (path:'/Tarjeta/sep1';Accelerator:Nil;Callback:Nil;Callback_action:1;item_type:'<Separator>'),
    (path:'/Tarjeta/E_xit';Accelerator:'<alt>X';Callback:FC(@destroy);Callback_action:1;item_type:Nil),
    (path:'/Ay_uda';Accelerator:Nil;Callback:Nil;Callback_action:1;item_type:'<LastBranch>'),
    (path:'/Ayuda/Manual';Accelerator:'F1';Callback:FC(@Menu);Callback_action:1;item_type:Nil),
    (path:'/Ayuda/Acerca de';Accelerator:'<mod1>A';Callback:FC(@Acercade);Callback_action:1;item_type:Nil)
    );


Procedure MakeMenu;

Var
  Factory : PGtkItemFactory;
  Accel  : PGtkAccelGroup;

begin
  accel:=gtk_accel_group_new;
  factory :=gtk_item_factory_new(GTK_MENU_BAR_TYPE,'<main>',accel);
  gtk_item_factory_create_items(Factory,NrMenuItems, at TheMenu,Nil);
  gtk_window_add_accel_group(GTK_Window(Window),accel);
  MenuBar:=gtk_item_factory_get_widget (Factory, '<main>');
end;



begin
  gtk_init (@argc, @argv);
  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(Window),'gcafe');
  gtk_widget_set_usize (Window, 300, 200);
  gtk_signal_connect (PGTKOBJECT (window), 'destroy',
                      GTK_SIGNAL_FUNC (@destroy), NULL);
  WinBox := gtk_vbox_new(False,0);
  gtk_widget_show(WinBox);
  Gtk_container_add(GTK_CONTAINER(Window),WinBox);
  MakeMenu;
  gtk_widget_show(MenuBar);
  Gtk_box_pack_start(GTK_BOX(Winbox),MenuBar,False,False,2);

  HBox1 := gtk_hbox_new(FALSE,0);
  gtk_widget_show(HBox1);
  Gtk_box_pack_start(GTK_BOX(WinBox),HBox1,TRUE,TRUE,0);

  Label1 := gtk_label_new('Tarjeta : ');
  gtk_widget_show(Label1);
  Gtk_box_pack_start(GTK_BOX(HBox1),Label1,TRUE,TRUE,10);
  Login :=  gtk_entry_new_with_max_length(15);
  gtk_widget_show(Login);
  Gtk_box_pack_start(GTK_BOX(HBox1),Login,TRUE,TRUE,10);

  HBox2 := gtk_hbox_new(FALSE,0);
  gtk_widget_show(HBox2);
  Gtk_box_pack_start(GTK_BOX(WinBox),HBox2,TRUE,TRUE,0);

  Label2 := gtk_label_new('Clave   : ');
  gtk_widget_show(Label2);
  Gtk_box_pack_start(GTK_BOX(HBox2),Label2,TRUE,TRUE,10);
  Password :=  gtk_entry_new_with_max_length(15);
  gtk_widget_show(Password);
  Gtk_box_pack_start(GTK_BOX(HBox2),Password,TRUE,TRUE,10);

  HButton := gtk_hbutton_box_new();
  gtk_widget_show(HButton);
  Gtk_box_pack_start(GTK_BOX(WinBox),HButton,TRUE,TRUE,10);

  Button := gtk_button_new_with_label('Aceptar');
  gtk_widget_show(Button);
  Gtk_container_add(GTK_CONTAINER(HButton),Button);

  Label3 := gtk_label_new('Horario de Atencion al Publico');
  gtk_widget_show(Label3);
  Gtk_box_pack_start(GTK_BOX(WinBox),Label3,TRUE,TRUE,0);

  Label4 := gtk_label_new('Lunes a Viernes 9:00 am. a 8:00 pm');
  gtk_widget_show(Label4);
  Gtk_box_pack_start(GTK_BOX(WinBox),Label4,TRUE,TRUE,0);

  Label5 := gtk_label_new('Domingos y Festivos 9:00 am. a 1:00 pm.');
  gtk_widget_show(Label5);
  Gtk_box_pack_start(GTK_BOX(WinBox),Label5,TRUE,TRUE,0);

  { Clock := gtk_clock_new(GTK_CLOCK_DECREASING);
  gtk_widget_show(Clock);
  Gtk_box_pack_start(GTK_BOX(WinBox),Clock,TRUE,TRUE,0);}

  gtk_widget_show (window);
  gtk_main ();
end.



More information about the fpc-pascal mailing list