f284492006-08-03Lance Dillon /* -*- C -*- */
d007812006-10-31Martin Nilsson require gtk210;
f284492006-08-03Lance Dillon class GTK2.RecentChooserDialog; inherit GTK2.Dialog; inherit GTK2.RecentChooser; void create(mapping(string:mixed)|string title, GTK2.Window|int|void parent, array(mapping(string:int)) buttons, GTK2.RecentManager|void manager) //! Creates a new RecentChooserDialog. Analogous to //! GTK2.Dialog->create(). { pgtk2_verify_not_inited(); pgtk2_verify_setup(); if (args) { if (Pike_sp[-args].type==PIKE_T_MAPPING) { INIT_WITH_PROPS(GTK_TYPE_RECENT_CHOOSER_DIALOG); } else { struct pike_string *title; struct object *o1,*o2=NULL; struct array *a; GtkWidget *gr; int i; get_all_args("create",args,"%t%O%A.%O",&title,&o1,&a,&o2);
a853ad2007-10-14Lance Dillon  if (a==NULL) Pike_error("Invalid number of buttons");
f284492006-08-03Lance Dillon  ref_push_string(title); f_string_to_utf8(1); if (o2) gr=gtk_recent_chooser_dialog_new_for_manager(CGSTR0(Pike_sp[-1].u.string), GTK_WINDOW(get_gobject(o1)),
a853ad2007-10-14Lance Dillon  GTK_RECENT_MANAGER(get_gobject(o2)),NULL,NULL);
f284492006-08-03Lance Dillon  else gr=gtk_recent_chooser_dialog_new(CGSTR0(Pike_sp[-1].u.string),
a853ad2007-10-14Lance Dillon  GTK_WINDOW(get_gobject(o1)),NULL,NULL);
f284492006-08-03Lance Dillon  pop_stack();
ce5d552007-10-09Lance Dillon  THIS->obj=G_OBJECT(gr);
f284492006-08-03Lance Dillon  if (a) { for (i=0; i<a->size; i++) { struct pike_string *text;
d2bf182008-01-19Henrik Grubbström (Grubba)  int response_id = 0;
f284492006-08-03Lance Dillon  struct svalue *sv; struct mapping *m;
ce5d552007-10-09Lance Dillon  if (ITEM(a)[i].type!=PIKE_T_MAPPING)
f284492006-08-03Lance Dillon  continue;
09db892007-10-10Martin Nilsson  m=ITEM(a)[i].u.mapping;
f284492006-08-03Lance Dillon  sv=low_mapping_string_lookup(m,_STR("text")); if (sv==NULL) continue;
2feed02007-10-15Lance Dillon  ref_push_string(sv->u.string);
f284492006-08-03Lance Dillon  f_string_to_utf8(1); sv=low_mapping_string_lookup(m,_STR("id"));
d2bf182008-01-19Henrik Grubbström (Grubba)  if (sv) response_id=PGTK_GETINT(sv);
f284492006-08-03Lance Dillon  gtk_dialog_add_button(GTK_DIALOG(THIS->obj),CGSTR0(Pike_sp[-1].u.string),response_id); pop_stack(); } } } pgtk2_pop_n_elems(args); } else { GtkWidget *gw; gw=gtk_recent_chooser_dialog_new(NULL,NULL,NULL,NULL); THIS->obj=G_OBJECT(gw); } pgtk2__init_this_object(); } endrequire;