Toc Gallery Index Tree Gtk.Status_Bar

Screenshot

No screeshot

Hierarchy

Description

A status bar is a special widget in which you can display messages. This type of widget is generally found at the bottom of application windows, and is used to display help or error messages.

This widget works as a stack of messages, ie all older messages are kept when a new one is inserted. It is of course possible to remove the most recent message from the stack. This stack behavior is especially useful when messages can be displayed from several places in your application. Thus, each one subprogram that needs to print a message can simply push it on the stack, and does not need to make sure that the user has had enough time to read the previous message (a timeout can be set to automatically remove the message after a specific delay)

Each message is associated with a specific Context_Id. Each of this context can have a special name, and these context can be used to organize the messages into categories (for instance one for help messages and one for error messages). You can then selectively remove the most recent message of each category.

Types

  • type Context_Id is new Guint;
  • type Gtk_Status_Bar is access all Gtk_Status_Bar_Record'Class;
  • type Gtk_Status_Bar_Record is new Gtk.Box.Gtk_Box_Record with private;
  • type Gtk_Statusbar is Gtk_Status_Bar;
    This is needed by Gate since the C name is GtkStatusbar
  • type Message_Id is new Guint;
  • type Status_Bar_Msg is record Text : Interfaces.C.Strings.chars_ptr;

Subprograms

  • function Convert (Msg : Status_Bar_Msg) return System.Address;
    function Convert (Msg : System.Address) return Status_Bar_Msg;
  • procedure Gtk_New (Statusbar : out Gtk_Status_Bar);
    Create a new status bar, in which messages will be displayed.
  • procedure Initialize (Statusbar : access Gtk_Status_Bar_Record'Class);
    Internal initialization function.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Status_Bar.
  • function Get_Context_Id (Statusbar : access Gtk_Status_Bar_Record; Context_Description : String) return Context_Id;
    Create the context id associated with a special name. If no context is currently associated with Context_Description, then a new context is created.
  • function Get_Messages (Statusbar : access Gtk_Status_Bar_Record) return Messages_List.GSlist;
    Return a list of all the messages currently stored in the queue. The first item in the list is the most recent message.
  • function Push (Statusbar : access Gtk_Status_Bar_Record; Context : Context_Id; Text : UTF8_String) return Message_Id;
    Push a new message on the queue, associated with a specific context. This message is directly displayed in the status bar. A new unique message id is associated with this message.
  • procedure Pop (Statusbar : access Gtk_Status_Bar_Record; Context : Context_Id);
    Remove the most recent message from a specific context. All other contexts are ignored, and no error is raised if there is no message in Context.
  • procedure Remove (Statusbar : access Gtk_Status_Bar_Record; Context : Context_Id; Message : Message_Id);
    Remove a message from the list. The message is only removed if it is in a specific context. Nothing happens if no matching message is found.
  • procedure Set_Has_Resize_Grip (Statusbar : access Gtk_Status_Bar_Record; Setting : Boolean);
    function Get_Has_Resize_Grip (Statusbar : access Gtk_Status_Bar_Record) return Boolean;
    Set or gets the value of the resize_grip attribute for a given status bar. This indicates whether the status bar has a handle that, when dragged, will resize the toplevel window that contains the status bar.

Signals

  • text_popped
    procedure Handler (Status_Bar : access Gtk_Status_Bar_Record'Class; Context : Context_Id; Text : Interfaces.C.Strings.chars_ptr);
    Emitted when a message has been removed from the queue.
  • text_pushed
    procedure Handler (Status_Bar : access Gtk_Status_Bar_Record'Class; Context : Context_Id; Text : Interfaces.C.Strings.chars_ptr);
    Emitted when a new message has been in the queue.

Properties

  • Has_Resize_Grip_Property
    Boolean
    Whether the statusbar has a grip for resizing the toplevel

Style Properties

  • Shadow_Type_Property
    Enum
    Style of bevel around the statusbar text

Testgtk source code

This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
----------------------------------------------------------------------- -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 1998-1999 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- ----------------------------------------------------------------------- with Glib; use Glib; with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Handlers; use Gtk.Handlers; with Gtk.Status_Bar; use Gtk.Status_Bar; with Gtk; use Gtk; with Ada.Text_IO; with Interfaces.C.Strings; package body Create_Status is package Status_Cb is new Handlers.Callback (Gtk_Status_Bar_Record); Counter : Gint := 1; ---------- -- Help -- ---------- function Help return String is begin return "A @bGtk_Status_Bar@B is generally found at the bottom of" & " application windows. It displays some help text, generally" & " depending on the current context in the application." & ASCII.LF & "In GtkAda, @bGtk_Status_Bar@B are organized as stacks: you push" & " some text onto the stack, and the top of the stack is always" & " displayed. You can then pop part of the stak to display the older" & " content of the @bGtk_Status_Bar@B. This behavior is especially" & " for temporarily displaying help in the status bar, but still being" & " able to show some other informations."; end Help; ---------- -- Push -- ---------- procedure Push (Status : access Gtk_Status_Bar_Record'Class) is Id : Message_Id; pragma Unreferenced (Id); begin Id := Push (Status, 1, "Something" & Gint'Image (Counter)); Counter := Counter + 1; end Push; --------- -- Pop -- --------- procedure Pop (Status : access Gtk_Status_Bar_Record'Class) is begin Pop (Status, 1); end Pop; ------------ -- Popped -- ------------ procedure Popped (Status : access Gtk_Status_Bar_Record'Class) is use type Messages_List.GSlist; begin if Get_Messages (Status) = Messages_List.Null_List then Counter := 1; end if; end Popped; ----------- -- Steal -- ----------- procedure Steal (Status : access Gtk_Status_Bar_Record'Class) is begin Remove (Status, 1, 4); end Steal; -------------- -- Contexts -- -------------- procedure Contexts (Status : access Gtk_Status_Bar_Record'Class) is begin Ada.Text_IO.Put_Line ("Status_Bar : Context : " & "any context" & " Id=" & Context_Id'Image (Get_Context_Id (Status, "any context"))); Ada.Text_IO.Put_Line ("Status_Bar : Context : " & "idle messages" & " Id=" & Context_Id'Image (Get_Context_Id (Status, "idle message"))); Ada.Text_IO.Put_Line ("Status_Bar : Context : " & "some text" & " Id=" & Context_Id'Image (Get_Context_Id (Status, "some text"))); Ada.Text_IO.Put_Line ("Status_Bar : Context : " & "hit the mouse" & " Id=" & Context_Id'Image (Get_Context_Id (Status, "hit the mouse"))); Ada.Text_IO.Put_Line ("Status_Bar : Context : " & "hit the mouse2" & " Id=" & Context_Id'Image (Get_Context_Id (Status, "hit the mouse2"))); end Contexts; ---------- -- Dump -- ---------- procedure Dump (Status : access Gtk_Status_Bar_Record'Class) is List : Messages_List.GSlist := Get_Messages (Status); use type Messages_List.GSlist; begin while List /= Messages_List.Null_List loop declare Msg : constant Status_Bar_Msg := Messages_List.Get_Data (List); begin Ada.Text_IO.Put_Line ("Context Id = " & Context_Id'Image (Msg.Context) & " Message_Id = " & Message_Id'Image (Msg.Message) & " Text = " & Interfaces.C.Strings.Value (Msg.Text)); end; List := Messages_List.Next (List); end loop; end Dump; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Box1, Box2 : Gtk_Box; Status : Gtk_Status_Bar; Button : Gtk_Button; begin Set_Label (Frame, "Status Bar"); Gtk_New_Vbox (Box1, False, 0); Add (Frame, Box1); Gtk_New_Vbox (Box2, False, 10); Set_Border_Width (Box2, 10); Pack_Start (Box1, Box2, False, False, 0); Gtk_New (Status); Pack_End (Box1, Status, False, False, 0); Status_Cb.Object_Connect (Status, "text_popped", Status_Cb.To_Marshaller (Popped'Access), Slot_Object => Status); Gtk_New (Button, "Push Something"); Pack_Start (Box2, Button, False, False, 0); Status_Cb.Object_Connect (Button, "clicked", Status_Cb.To_Marshaller (Push'Access), Slot_Object => Status); Gtk_New (Button, "Pop"); Pack_Start (Box2, Button, False, False, 0); Status_Cb.Object_Connect (Button, "clicked", Status_Cb.To_Marshaller (Pop'Access), Slot_Object => Status); Gtk_New (Button, "Steal Message_Id #4"); Pack_Start (Box2, Button, False, False, 0); Status_Cb.Object_Connect (Button, "clicked", Status_Cb.To_Marshaller (Steal'Access), Slot_Object => Status); Gtk_New (Button, "Dump stack"); Pack_Start (Box2, Button, False, False, 0); Status_Cb.Object_Connect (Button, "clicked", Status_Cb.To_Marshaller (Dump'Access), Slot_Object => Status); Gtk_New (Button, "Test contexts"); Pack_Start (Box2, Button, False, False, 0); Status_Cb.Object_Connect (Button, "clicked", Status_Cb.To_Marshaller (Contexts'Access), Slot_Object => Status); Show_All (Frame); end Run; end Create_Status;

Alphabetical Index