7.6. Label Functions - set_label, table_labeler

These are convenience functions that facilitate creating labels. The first is called by the toggle_sym function to change the label on the Auto mode button. The second simplifies putting a label into a table.

   /*--------------------------------------------------------------------
    * Function:    set_label
    * Returns:     t or nil
    * Description: Sets the label of a button according to
    *              the value of a database point.
    *------------------------------------------------------------------*/
   function set_label(button, sym, onvalue, offvalue)
   {
     if (eval(sym) != 0)
       button.label = onvalue;
     else
       button.label = offvalue;
   }
   
   /*--------------------------------------------------------------------
    * Function:    table_labeler
    * Returns:     t or nil
    * Description: Creates a label and puts it into a table.
    *------------------------------------------------------------------*/
   function table_labeler(table, txt, left, right, top, bottom)
   {
     local label;
     
     label = new(GtkLabel);
     label.set_text(txt);
     table.attach_defaults(label, left, right, top, bottom);
   }
   
[Note]

The set_justify method on the GtkLabel apparently has no effect, at least not in this context. As a work-around, we justify our labels by adding space as necessary in the text string that is passed as the txt parameter.