pike.git / src / post_modules / GTK2 / source / gtkbutton.pre

version» Context lines:

pike.git/src/post_modules/GTK2/source/gtkbutton.pre:33:   //! Called when the button is pressed   signal released;   //! Called when the button is released   signal clicked;   //! Called when the button is pressed, and then released   signal enter;   //! Called when the mouse enters the button   signal leave;   //! Called when the mouse leaves the button    - void create(?string label_text) + void create(string|mapping|void label_or_props)   //! If a string is supplied, a W(Label) is created and added to the button.   {    pgtk_verify_not_inited();    pgtk_verify_setup(); -  if(args) { -  gchar *s=PGTK_GETSTR(Pike_sp-args); -  if (s) { - /* THIS->obj=G_OBJECT(gtk_button_new_with_label(s)); */ - /* Add a stock button if we can, otherwise add mnemonic button */ -  THIS->obj=G_OBJECT(gtk_button_new_from_stock(s)); -  PGTK_FREESTR(s); +  if (args) { +  if (Pike_sp[-args].type==PIKE_T_STRING) { +  struct pike_string *t; +  GtkWidget *gb; +  get_all_args("create",args,"%T",&t); +  if (t) { +  if (g_utf8_validate((char *)STR0(t),t->len,NULL)) +  gb=gtk_button_new_from_stock((char *)STR0(t)); +  else +  gb=gtk_button_new();    } else -  THIS->obj=G_OBJECT(gtk_button_new()); +  gb=gtk_button_new(); +  THIS->obj=G_OBJECT(gb); +  } else { +  INIT_WITH_PROPS(GTK_TYPE_BUTTON); +  }    my_pop_n_elems(args);    } else { -  THIS->obj=G_OBJECT(gtk_button_new()); +  GtkWidget *gb; +  gb=gtk_button_new(); +  THIS->obj=G_OBJECT(gb);    }    pgtk__init_this_object(); - /* fprintf(stderr,"gtk.button: obj==%p\n",THIS->obj); */ +    }      void pressed();   //! Emulate a 'press' event.      void released();   //! Emulate a 'release' event.      void clicked();   //! Emulate a 'clicked' event (press followed by release).