


GTK3.0 uses CSS to set the background color of the control_html/css_WEB-ITnose
Jun 24, 2016 am 11:51 AM
************************************************ *************************************************** **********************
I have participated in the 2014 "Blog Star" selection. I think my article is helpful to you. Please cast your precious vote
************************************ *************************************************** *********************************
GTK 2.0 When running in windows, a text box will appear Unable to enter problem. I searched a lot of information and found that this is a problem with version 2.0, but no good solution has been found yet. But using GTK3.0 has no effect. However, GTK3.0 did not find a suitable method for setting the background image of the control. Refer to the examples given online and use CSS to implement it (see the reference materials for details). However, it does not take effect when running under Windows. The specific reason is unknown:
/* Compile with: gcc -Wall -o backimage `pkg-config --cflags --libs gtk+-3.0` backimage.c */#include <gtk/gtk.h>int main(int argc, char *argv[]){ GtkWidget *window;/*----- CSS ----------- */ GtkCssProvider *provider; GdkDisplay *display; GdkScreen *screen;/*-----------------------*/ gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);/* gtk_window_set_default_size (GTK_WINDOW(window), 500, 300);*/ g_signal_connect (GTK_WIDGET(window), "destroy", G_CALLBACK (gtk_main_quit), NULL);/*------------- CSS --------------------------------------------------------------------------------------------------*/ provider = gtk_css_provider_new (); display = gdk_display_get_default (); screen = gdk_display_get_default_screen (display); gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_USER); gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), " GtkWindow {\n" " background-image: url('abstract-blue-02.jpg');\n" "}\n", -1, NULL); g_object_unref (provider);/*----------------------------------------------------------------------------------------------------------------------*/ gtk_widget_show_all (window); gtk_main ();return(0);}
GTK3.0Ubunスtu The installation command under the system is as follows:
apt-get install gtk3.0
References:
http://www.gtkforums.com/viewtopic.php?f=3&t=988&sid=b63d18d182917efd7e2b04eb8c5e50c1&start=15

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?

How do I use HTML5 form validation attributes to validate user input?

What is the purpose of the <iframe> tag? What are the security considerations when using it?

How to efficiently add stroke effects to PNG images on web pages?

What is the purpose of the <meter> element?

What are the best practices for cross-browser compatibility in HTML5?

What is the purpose of the <datalist> element?

What is the purpose of the <progress> element?
