Re: [gtk-list] dialog
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] dialog
- Date: Sun, 11 Oct 1998 06:42:39 +0200 (CEST)
On Sat, 10 Oct 1998, Pauli Virtanen wrote:
> Two days ago
>
> I asked:
>
> >I have some ten dialogs, too.
> >They work separately just perfect,
> >when the dialog is created by gtk_dialog_new();
>
> >What I want, is to have a dialog on my scrolled window
> >without window manager decoration. Just like this:
>
> -------------------------------------------------
> | scrolled window |
> | |
> | --------------------------------- |
> | | dialog | |
> | | | |
> | --------------------------------- |
> | |
> -------------------------------------------------
>
> >I want to pop them up by pulldown menu calls.
> Now I have what I wwant, but still one problem remains:
> ** WARNING **: file gtkcontainer.c: line 346 (gtk_container_add): "widget->parent == NULL"
> The essentials are:
> void luo_dialogi(
> GtkWidget *isa) // isa = top_level_window
> {
> GtkWidget *vbox;
> GtkWidget *table, *hbox;
>
> dialog = gtk_dialog_new();
> dialog->parent = isa;
oh, oh, don't ever do this!
widget contents are never write-access fields!
also a toplevel *must* have its ->parent pointer set to NULL and
can not get added to another container (it is a *toplevel* widget).
> gtk_container_border_width(GTK_CONTAINER(dialog), 5);
> [snip]
> gtk_widget_realize(dialog);
> gtk_widget_reparent(dialog, scroll); // scroll public
> }
> To get just what I want, I must reparent to scrolled window.
> Everything works just fine, but I don't like that warning message.
> Could someone with more experience help me.
what you want is something like (off head):
GtkWidget*
popup_sole_dialog (gchar *string)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *label;
g_return_val_if_fail (string != NULL, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 5);
label = gtk_label_new (string);
gtk_container_add (GTK_CONTAINER (vbox), label);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (label);
gtk_widget_show (vbox);
gtk_widget_show (window);
return window;
}
GtkWidget*
add_contained_dialog (gchar *string,
GtkWidget *parent /* e.g. a scrolled window */)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *label;
g_return_val_if_fail (string != NULL, NULL);
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (GTK_IS_CONTAINER (parent), NULL);
vbox = gtk_vbox_new (FALSE, 5);
label = gtk_label_new (string);
gtk_container_add (GTK_CONTAINER (vbox), label);
gtk_container_add (GTK_CONTAINER (parent), label);
gtk_widget_show (label);
gtk_widget_show (vbox);
}
void
embed_dialog (GtkWidget *window /* e.g. a dialog from popup_sole_dialog() */,
GtkWidget *parent /* e.g. a scrolled window */)
{
GtkWidget *child;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (GTK_IS_CONTAINER (parent), NULL);
child = GTK_BIN (window)->child;
if (child)
gtk_widget_reparent (child, parent);
gtk_widget_destroy (window);
}
>
> Thanks in advance
>
> pauli
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]