Quantcast
Channel: MobileRead Forums - Kindle Developer's Corner
Viewing all articles
Browse latest Browse all 4414

gtkcolorbutton GtkColorSelection gtk_window_set_transient_for () seems incorrect

$
0
0
As I understand it:

I invoke a https://developer.gnome.org/gtk2/2.2...lorButton.html GtkColorButton

clicking this creates for me a GtkColorSelection dialog

Which automatically sets the gtk_window_set_transient_for () as the parent that invoked the dialog.

this works great when there is only ONE window in the mix.


But...

invoke two windows:

one from the other... then put the button on the second page... and the gtk_window_set_transient_for () will always put the dialog BEHIND the second window...


test.c
Code:

#include <gtk/gtk.h>

static gboolean delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer  data )
{  g_print ("delete event occurred\n");
    return TRUE;
}

/* Another callback */
static void destroy( GtkWidget *widget,
                    gpointer  data )
{
    gtk_main_quit ();
}

/* return us a window */

GtkWidget* create_simple_window (GtkWidget *thewindow)
{
        GtkWidget *window;

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        gtk_window_set_title(GTK_WINDOW(window), "L:A_N:application_ID:twobob.second.layer_PC:N");

        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
        gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (thewindow));

        return window;
}


int main( int  argc,
          char *argv[] )
{

    GtkWidget *window;
          GtkWidget *window2;
            GtkWidget *button;

    gtk_init (&argc, &argv);
   
    /* create a new window on the application layer */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

        gtk_window_set_title (GTK_WINDOW (window), "L:A_N:application_ID:twobob.osmo_PC:N");

    g_signal_connect (window, "delete-event",
                      G_CALLBACK (delete_event), NULL);

    g_signal_connect (window, "destroy",
                      G_CALLBACK (destroy), NULL);
   
    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   
    button = gtk_color_button_new();
    gtk_color_button_set_title(GTK_COLOR_BUTTON(button), "L:D_ID:twobob.color");

  /* create a new window  ALSO on the application layer */
    window2 = create_simple_window(window);

    gtk_container_add (GTK_CONTAINER (window2), button);

    gtk_widget_show (window);

    gtk_widget_show (button);
   
    /* and the second window - WITH THE BUTTON */
  gtk_widget_show (window2);

    gtk_main ();
   
    return 0;
}

press the button? nothing appears.
(well it does but on the wrong layer)

swap
gtk_container_add (GTK_CONTAINER (window2), button);

for
gtk_container_add (GTK_CONTAINER (window), button);


and elide
gtk_widget_show (window2);

like
// gtk_widget_show (window2);


and it all works as expected...

so... am I going to have to derive a widget from GtkColorSelection ???

or is this as a result of using the awesome layers????

Any clues?

I was trying to port "osmo" but this has me stumped.
and short of rewriting the entire "PREFERENCES" gtknotebook layout... I am out of ideas.

Hence the simple to test "THIS DONT WORK" example I have made here...

Viewing all articles
Browse latest Browse all 4414

Trending Articles