1 /* Monolith close button class.
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: ml_close_button.c,v 1.3 2002/11/13 21:41:01 rich Exp $
25 #include <pthr_iolib.h>
28 #include "ml_widget.h"
29 #include "ml_close_button.h"
31 static void repaint (void *, ml_session, const char *, io_handle);
32 static struct ml_widget_property properties[];
34 struct ml_widget_operations close_button_ops =
37 properties: properties,
40 struct ml_close_button
42 struct ml_widget_operations *ops;
43 pool pool; /* Pool for allocations. */
44 const char *text; /* HTML printed for the button. */
45 int reload_opener; /* If set, reload the opener window. */
48 static struct ml_widget_property properties[] =
51 offset: ml_offsetof (struct ml_close_button, text),
52 type: ML_PROP_STRING },
53 { name: "button.reload-opener",
54 offset: ml_offsetof (struct ml_close_button, reload_opener),
60 new_ml_close_button (pool pool, const char *text)
62 ml_close_button w = pmalloc (pool, sizeof *w);
64 w->ops = &close_button_ops;
73 repaint (void *vw, ml_session session, const char *windowid, io_handle io)
75 ml_close_button w = (ml_close_button) vw;
81 if (!w->reload_opener)
84 js = "window.opener.location.reload(); top.close()";
87 "<a class=\"ml_button\" href=\"javascript:%s\">%s</a>",