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

Child Arguments

GtkBox implements child arguments, which were briefly described in the section called Using Object Arguments in Your Own GtkObject Subclass in the chapter called The GTK+ Object and Type System. Child arguments represent a property of a pair of objects. In this case, the box-packing flags for each child can be read and written using the object argument system.

Here's how GtkBox registers its child arguments, in gtk_box_class_init():


  gtk_container_add_child_arg_type ("GtkBox::expand", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_EXPAND);
  gtk_container_add_child_arg_type ("GtkBox::fill", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FILL);
  gtk_container_add_child_arg_type ("GtkBox::padding", GTK_TYPE_ULONG, GTK_ARG_READWRITE, CHILD_ARG_PADDING);
  gtk_container_add_child_arg_type ("GtkBox::pack_type", GTK_TYPE_PACK_TYPE, GTK_ARG_READWRITE, CHILD_ARG_PACK_TYPE);
  gtk_container_add_child_arg_type ("GtkBox::position", GTK_TYPE_LONG, GTK_ARG_READWRITE, CHILD_ARG_POSITION);

      

GtkBox then implements the get_child_arg and set_child_arg methods from GtkContainerClass. Here's gtk_box_get_child_arg(); the gtk_box_set_child_arg() is analagous.


static void
gtk_box_get_child_arg (GtkContainer   *container,
                       GtkWidget      *child,
                       GtkArg         *arg,
                       guint           arg_id)
{
  gboolean expand = 0;
  gboolean fill = 0;
  guint padding = 0;
  GtkPackType pack_type = 0;
  GList *list;

  if (arg_id != CHILD_ARG_POSITION)
    gtk_box_query_child_packing (GTK_BOX (container),
                                 child,
                                 &expand,
                                 &fill,
                                 &padding,
                                 &pack_type);
  
  switch (arg_id)
    {
    case CHILD_ARG_EXPAND:
      GTK_VALUE_BOOL (*arg) = expand;
      break;
    case CHILD_ARG_FILL:
      GTK_VALUE_BOOL (*arg) = fill;
      break;
    case CHILD_ARG_PADDING:
      GTK_VALUE_ULONG (*arg) = padding;
      break;
    case CHILD_ARG_PACK_TYPE:
      GTK_VALUE_ENUM (*arg) = pack_type;
      break;
    case CHILD_ARG_POSITION:
      GTK_VALUE_LONG (*arg) = 0;
      for (list = GTK_BOX (container)->children; list; list = list->next)
        {
          GtkBoxChild *child_entry;

          child_entry = list->data;
          if (child_entry->widget == child)
            break;
          GTK_VALUE_LONG (*arg)++;
        }
      if (!list)
        GTK_VALUE_LONG (*arg) = -1;
      break;
    default:
      arg->type = GTK_TYPE_INVALID;
      break;
    }
}
      
Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire