[maemo-developers] How to get a transparent GtkWindow (fremantle)
From: Luca Donaggio donaggio at gmail.comDate: Thu Oct 29 18:29:17 EET 2009
- Previous message: Maemo5 on Beagle
- Next message: How to get a transparent GtkWindow (fremantle)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm trying to create a transparent, non-decorated popup GtkWindow on top af
my app HildonWindow and draw something on its underlying GdkWindow object
using cairo.
All I was able to obtain so far is a black (or whatever is the background
colour of the selected theme) rectangle -ie it's not transparent and
everything I paint in its GdkWindow with Cairo is not showed at all.
Here is the code I'm using:
void create_image_details(GtkWidget *callerobj,app_data_t *myapp) {
PangoLayout *textbuff;
cairo_t *cr;
gint x0, y0, r, txtwidth, txtheight;
/* For the widget itself let's use a GtkWindow */
if ((myapp->imgparamwin != NULL) & GTK_IS_WINDOW(myapp->imgparamwin))
gtk_widget_destroy(myapp->imgparamwin);
myapp->imgparamwin = gtk_window_new(GTK_WINDOW_POPUP);
gtk_window_set_decorated(GTK_WINDOW (myapp->imgparamwin),FALSE);
gtk_window_set_opacity(GTK_WINDOW (myapp->imgparamwin),0);
gtk_widget_set_app_paintable(myapp->imgparamwin,TRUE);
gtk_widget_realize(myapp->imgparamwin);
/* gdk_window_set_back_pixmap(myapp->imgparamwin->window,NULL,FALSE); */
/* Get the Cairo context */
cr = gdk_cairo_create(GDK_DRAWABLE (myapp->imgparamwin->window));
textbuff = pango_cairo_create_layout(cr);
pango_layout_set_markup(textbuff,myapp->imgparam,-1);
pango_layout_get_pixel_size(textbuff,&txtwidth,&txtheight);
/* Draw a rounded rectangle */
[cairo stuff is here]
cairo_destroy(cr);
g_object_unref(textbuff);
/* Show the widget */
gtk_window_resize(GTK_WINDOW (myapp->imgparamwin),txtwidth + (r *
2),txtheight + (r * 2));
gtk_window_move(GTK_WINDOW (myapp->imgparamwin),30,30);
gdk_window_reparent(myapp->imgparamwin->window,myapp->image->window,30,30);
gtk_widget_show_all(myapp->imgparamwin);
}
The window dimension after the gtk_window_resize() are correct -ie the
dimension of the PangoLayout containing the text to be rendered, so
something is definitely going on under the hood... but nothing is displayed!
If I add some widget to the popoup window (for example a GtkLabel with some
text in it), it's rendered correctly, but, of course it's not transparent!
Any help, as always, is much appreciated!
Luca Donaggio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20091029/a924d7cd/attachment.htm
- Previous message: Maemo5 on Beagle
- Next message: How to get a transparent GtkWindow (fremantle)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
