Re: [gtk-list] Re: return of the MDI



> >I agree with this (and most of the arguments against WiW MDI), but I
> >was wondering how hard it would be to implement what Photoshop calls
> >pallettes. Little tool windows that float on top within the MDI. The way
> >I would love these things is to be "float on top" whenever a normal
> >window of the app is raised, and also be 'sticky' (visible on all
> >desktops).
>
> Sticky? God, no!
>
> I make *intensive* use of multiple desktops. Any program that insisted on
> making its popups sticky would get binned, instantly (and there have been

I actually don't think 'sticky' is the right term here .... what Rogier
is asking for, is a small toolbox window, which stays on top of the
application's edit window(s).

This code should demo what I think is being asked for. Move one of the top
level windows onto another virtual desktop. Whenever you click the 'Show'
button, the 'toolbox' window appears over the top level window.

Instead of clicking a button, of course, the 'toolbox' would be exposed
on a top level window's expose event.

It's up to the application to manage the positioning of the 'toolbox' and
remember the coordinates relative to each top level window. Not a GTK
issue, really :-)

Allan

------------------------------------------------------------------------
#include <gtk/gtk.h>

GtkWidget       *toolbox;

static void clicked(GtkWidget *widget, GtkWidget *topwin)
{
        gint x, y;

        gtk_window_set_transient_for(GTK_WINDOW(toolbox), GTK_WINDOW(topwin));
        gdk_window_get_position(topwin->window, &x, &y);
        gtk_widget_set_uposition(toolbox, x, y);
        gtk_widget_show(toolbox);
}

main(int argc, char **argv)
{
        GtkWidget *win1, *win2, *b;

        gtk_init(&argc, &argv);

        win1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(win1), 30);
        b = gtk_button_new_with_label("Show");
        gtk_container_add(GTK_CONTAINER(win1), b);
        gtk_signal_connect(GTK_OBJECT(b), "clicked",
                                GTK_SIGNAL_FUNC(clicked), win1);

        win2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(win2), 30);
        b = gtk_button_new_with_label("Show");
        gtk_container_add(GTK_CONTAINER(win2), b);
        gtk_signal_connect(GTK_OBJECT(b), "clicked",
                                GTK_SIGNAL_FUNC(clicked), win2);

        toolbox = gtk_window_new(GTK_WINDOW_TOPLEVEL);

        gtk_widget_show_all(win1);
        gtk_widget_show_all(win2);
        gtk_main();
}
------------------------------------------------------------------------

FYI:

------------------------------------------------------------------------
CC=             gcc

INCLUDES=       `gtk-config --cflags`

CFLAGS=         $(INCLUDES) -c -g
LDFLAGS=        `gtk-config --libs`

tbtest: tbtest.o
        $(CC) -o tbtest tbtest.o $(LDFLAGS)
------------------------------------------------------------------------

ARB



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]