Home >Web Front-end >HTML Tutorial >GTK3.0 uses CSS to set the background color of the control_html/css_WEB-ITnose

GTK3.0 uses CSS to set the background color of the control_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:51:121875browse

************************************************ *************************************************** **********************

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn