On Sun, May 14, 2000 at 01:53:06PM +0000, Dermot Musgrove wrote:
> Hi, is it really necessary to copy and edit the Gtk methods - I am probably
> missing something but I don't see the need for a new constructor.
> 
> Why is it not possible to do (eg in Perl)?
> 
>   $rb = new Gtk::RadioButton(_('ra_diobutton5'), $rb-group );
>   $key = $rb->child->parse_uline(_('ra_diobutton5') );
>   $rb->add_accelerator('clicked', $accelgroup}, $key, 'mod1_mask',
>       ['visible', 'locked'] );

It's doable, but, in C (which is what Ethereal is written in) it's
fairly different in detail:

typedef struct {
        GtkWidget *button;
        GtkAccelGroup *accel_group;
} fix_label_args_t;

static void
dlg_fix_label(GtkWidget *label_widget, gpointer data)
{
  fix_label_args_t *args = data;
  gchar *label;
  guint accel_key;

  gtk_label_get(GTK_LABEL(label_widget), &label);
  accel_key = gtk_label_parse_uline(GTK_LABEL(label_widget), label);
  if (accel_key != GDK_VoidSymbol) {
    /* Yes, we have a mnemonic. */
    gtk_widget_add_accelerator(args->button, "clicked", args->accel_group,
                                accel_key, 0, GTK_ACCEL_LOCKED);
    gtk_widget_add_accelerator(args->button, "clicked", args->accel_group,
                                accel_key, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
  }
}

GtkWidget *
dlg_radio_button_new_with_label_with_mnemonic(GSList *group,
                const gchar *label, GtkAccelGroup *accel_group)
{
  GtkWidget *radio_button;
  fix_label_args_t args;

  radio_button = gtk_radio_button_new_with_label (group, label);
  args.button = radio_button;
  args.accel_group = accel_group;
  gtk_container_foreach(GTK_CONTAINER(radio_button), dlg_fix_label, &args);

  return radio_button;
}

GtkWidget *
dlg_check_button_new_with_label_with_mnemonic(const gchar *label,
                        GtkAccelGroup *accel_group)
{
  GtkWidget *check_button;
  fix_label_args_t args;
                 
  check_button = gtk_check_button_new_with_label (label);
  args.button = check_button;
  args.accel_group = accel_group;
  gtk_container_foreach(GTK_CONTAINER(check_button), dlg_fix_label, &args);
                           
  return check_button;
}

-- 
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to