Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

GnomeMessageBox

A GnomeMessageBox is a GnomeDialog subclass that conveys a short message or asks a simple question. Gnome provides several "types" of message box; they have different icons next to the text, and corresponding titles. The icons look nice, and allow users to quickly classify the message being presented.

The API is very simple; there are no functions specific to GnomeMessageBox other than the constructor, in Figure 10. The first argument is the message to display; the second is a string encoding the message box type. Then you can list any buttons, just as you would with gnome_dialog_new(). Unlike the unadorned GnomeDialog, GnomeMessageBox closes on any button click by default. Of course you can change this behavior using gnome_dialog_set_close().

       #include <libgnomeui/gnome-messagebox.h>
      

GtkWidget* gnome_message_box_new (const gchar* message, const gchar* messagebox_type, ...);

Figure 10. Message Box Constructor

Macros are provided for the available message box types.

  • GNOME_MESSAGE_BOX_INFO should be used for "FYI" messages.

  • GNOME_MESSAGE_BOX_WARNING should be used for nonfatal errors.

  • GNOME_MESSAGE_BOX_ERROR should be used if an operation fails entirely.

  • GNOME_MESSAGE_BOX_QUESTION should be used if your dialog asks a question.

  • GNOME_MESSAGE_BOX_GENERIC should be used if none of the other types apply.

Here's how you might use GnomeMessageBox:


  GtkWidget * mbox;

  mbox = gnome_message_box_new (message, 
                                GNOME_MESSAGE_BOX_INFO,
                                GNOME_STOCK_BUTTON_OK, 
                                NULL);
  
  gtk_widget_show (mbox);
      

Notice that GnomeMessageBox, like most GnomeDialog subclasses but not GnomeDialog itself, automatically closes when clicked. So there is no need to destroy it by hand.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire