Re: draw applet without theme

interesting ...

smth. like this works for me:
void position_popup_menu (GtkMenu *menu, gint *x, gint *y, gboolean
*push_in, gpointer user_data)
    GtkWidget *applet;

    applet = GTK_WIDGET(user_data);
    g_assert (applet);
    g_assert (x);
    g_assert (y);

    gdk_window_get_origin (GDK_WINDOW (applet->window), x, y);
    *y += applet->allocation.height;
and then using that in the popup
gtk_menu_popup (GTK_MENU (applet->dropdown_menu), NULL, NULL,
position_popup_menu, applet, event->button, event->time);

I'm wondering how much that'll be worth.
This does not address that other people might not have the applet in a
panel at the top of the screen. The above algo always puts the menu below
the applet. Now, while GTK does not seem to put the menu off-screen in a
horizontal direction (I'm setting x, but with my panel there's not enough
space right of the applet and the menu gets moved to the left) it does
paint it off-screen vertically (or not paint it at all perhaps). If I move
the panel to the bottom of the screen, the above will not show the menu
where not meddling with positioning will let GTK (or metacity, or whoever)
do smth. smart. Have the impression you wouldn't reimplement that


On Wed, December 28, 2005 12:39 pm, Predatory Kangaroo said:
> I just noticed a useful tidbit for you, then... I was hacking on
gnome-power-manager and noticed that the Notification tooltip is aligned
exactly to the icon in the tray.
> It does this by embedding an image in a libegg tray widget, then finding
> desired x and y positions of the tooltip by using the following code (taken
> from src/gmp-common.c:73)
> gboolean
> get_widget_position (GtkWidget *widget, gint *x, gint *y)
> {
>         GdkPixbuf* pixbuf = NULL;
>         /* assertion checks */
>         g_assert (widget);
>         g_assert (x);
>         g_assert (y);
>         gdk_window_get_origin (GDK_WINDOW (widget->window), x, y);
pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (widget));
>         *x += (gdk_pixbuf_get_width (pixbuf) / 2);
>         *y += gdk_pixbuf_get_height (pixbuf);
>         g_debug ("widget position x=%i, y=%i", *x, *y);
>         return TRUE;
> }
> Altering that to remove the x offset (we don't need the tooltip aligned
to the center of the icon, as the notification item does) should provide
the desired effect.

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