Can I make GtkPlug transparent?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can I make GtkPlug transparent?

李浩
Hi, I encountered a problem when using GtkPlug and GtkSocket.


I use CSS to set the background of GtkSocket to red and then use CSS to make GtkPlug transparent. I think I can see the red color because GtkPlug has been set to transparent, but it's actually black. I can't figure out why the effect is not correct. Could someone help me out? My Gtk version is Gtk 3.18.


The CSS files are as follows.


/* socket.css */
GtkSocket {
        background-color:rgba(233,23,34,1);
}


/* plug.css */
GtkPlug {
        background-color: transparent;
}



The code is here:
[socket.c]  https://pastebin.com/68XLqFUF
[plug.c]  https://pastebin.com/Cp3BPHFh
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I make GtkPlug transparent?

Gtk+ - Apps Dev mailing list

 
Hi Lihao,

If you set the socket color you will be OK. You won't have to worry about the transparency of the plug, in that case.

For setting the transparency for the different windows you can try setting the window, socket and plug widgets with the following. It worked on GTK3.18. Couldn't get the transparency to work with CSS though. I don't know why that is.

Eric

...
static gboolean draw_background(GtkWidget *widget, cairo_t *cr, gpointer data)
  {
    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.5);
    cairo_paint(cr);
    return FALSE;
  }
...
gtk_widget_set_app_paintable("widget", TRUE);
if(gtk_widget_is_composited("widget"))
  {
    GdkScreen *screen=gtk_widget_get_screen("widget");  
    GdkVisual *visual=gdk_screen_get_rgba_visual(screen);
    gtk_widget_set_visual("widget", visual);
  }
else g_print("Can't set window transparency.\n");
g_signal_connect("widget", "draw", G_CALLBACK(draw_background), NULL);
...

 


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I make GtkPlug transparent?

李浩
In reply to this post by 李浩
Hi Eric,

Thanks for your reply! I'm sorry I didn't express the problem clearly.
I want to make GtkPlug transparent, so I can see the background of GtkSocket. In other words, if I set a background image on GtkSocket, I hope I can see the image even if I embed a GtkPlug on it. Is there any way to prevent the GtkPlug covering the image.Thanks.

Regards,
LiHao.
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can I make GtkPlug transparent?

Gtk+ - Apps Dev mailing list

 
It looks like both the plug and socket draw to the same window. That would mean that you would have to draw your window background in both the plug and socket "draw" callback functions. There is a plug2.c and socket2.c in the following folder that sets the transparency on the different windows to try to figure out how it could work. With cairo you can draw or load an image. You would just have to do it twice in this case.

Might be stretching GTK a little here. Should work.

https://github.com/cecashon/OrderedSetVelociRaptor/tree/master/Misc/Csamples

Eric

 


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

回复: Can I make GtkPlug transparent?

李浩
Thanks you Eric.
I will keep trying on it.


Regards,
Lihao
 
 
------------------ 原始邮件 ------------------
发件人: "cecashon";
发送时间: 2017年6月27日(星期二) 中午12:22
收件人: "lihao";
抄送: "gtk-app-devel-list";
主题: Re: Can I make GtkPlug transparent?

 

 
 It looks like both the plug and socket draw to the same window. That would mean that you would have to draw your window background in both the plug and socket "draw" callback functions. There is a plug2.c and socket2.c in the following folder that sets the transparency on the different windows to try to figure out how it could work. With cairo you can draw or load an image. You would just have to do it twice in this case.
 
 Might be stretching GTK a little here. Should work.
 
 https://github.com/cecashon/OrderedSetVelociRaptor/tree/master/Misc/Csamples
 
 Eric
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...