61 lines
4.3 KiB
HTML
61 lines
4.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
<title>Parsing of custom resources: GTK+ 3 Reference Manual</title>
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||
<link rel="home" href="index.html" title="GTK+ 3 Reference Manual">
|
||
<link rel="up" href="gtk-migrating-GtkStyleContext.html" title="Theming changes">
|
||
<link rel="prev" href="gtk-migrating-GtkStyleContext-checklist.html" title="A checklist for widgets">
|
||
<link rel="next" href="gtk-migrating-GtkStyleContext-bonus-points.html" title="Bonus points">
|
||
<meta name="generator" content="GTK-Doc V1.25 (XML mode)">
|
||
<link rel="stylesheet" href="style.css" type="text/css">
|
||
</head>
|
||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
|
||
<td width="100%" align="left" class="shortcuts"></td>
|
||
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
|
||
<td><a accesskey="u" href="gtk-migrating-GtkStyleContext.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
|
||
<td><a accesskey="p" href="gtk-migrating-GtkStyleContext-checklist.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
|
||
<td><a accesskey="n" href="gtk-migrating-GtkStyleContext-bonus-points.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
|
||
</tr></table>
|
||
<div class="section">
|
||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||
<a name="gtk-migrating-GtkStyleContext-parsing"></a>Parsing of custom resources</h2></div></div></div>
|
||
<p>
|
||
As a consequence of the RC format going away, calling <a class="link" href="gtk3-Resource-Files.html#gtk-rc-parse" title="gtk_rc_parse ()"><code class="function">gtk_rc_parse()</code></a> or
|
||
<a class="link" href="gtk3-Resource-Files.html#gtk-rc-parse-string" title="gtk_rc_parse_string ()"><code class="function">gtk_rc_parse_string()</code></a> won't have any effect on a widgets appearance.
|
||
The way to replace these calls is using a custom <a class="link" href="GtkStyleProvider.html" title="GtkStyleProvider"><span class="type">GtkStyleProvider</span></a>,
|
||
either for an individual widget through <a class="link" href="GtkStyleContext.html#gtk-style-context-add-provider" title="gtk_style_context_add_provider ()"><code class="function">gtk_style_context_add_provider()</code></a>
|
||
or for all widgets on a screen through <a class="link" href="GtkStyleContext.html#gtk-style-context-add-provider-for-screen" title="gtk_style_context_add_provider_for_screen ()"><code class="function">gtk_style_context_add_provider_for_screen()</code></a>.
|
||
Typically, the provider will be a <a class="link" href="GtkCssProvider.html" title="GtkCssProvider"><span class="type">GtkCssProvider</span></a>, which parse CSS
|
||
information from a file or from a string.
|
||
</p>
|
||
<div class="example">
|
||
<a name="id-1.6.4.8.3"></a><p class="title"><b>Example 49. Using a custom GtkStyleProvider</b></p>
|
||
<div class="example-contents"><pre class="programlisting">
|
||
GtkStyleContext *context;
|
||
GtkCssProvider *provider;
|
||
|
||
context = gtk_widget_get_style_context (widget);
|
||
provider = gtk_css_provider_new ();
|
||
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
|
||
".frame1 {\n"
|
||
" border-image: url('gradient1.png') 10 10 10 10 stretch;\n"
|
||
"}\n", -1, NULL);
|
||
gtk_style_context_add_provider (context,
|
||
GTK_STYLE_PROVIDER (provider),
|
||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||
g_object_unref (provider);
|
||
</pre></div>
|
||
</div>
|
||
<br class="example-break"><p>
|
||
Notice that you can also get style information from custom resources
|
||
by implementing the <a class="link" href="GtkStyleProvider.html" title="GtkStyleProvider"><span class="type">GtkStyleProvider</span></a> interface yourself. This is
|
||
an advanced feature that should be rarely used.
|
||
</p>
|
||
</div>
|
||
<div class="footer">
|
||
<hr>Generated by GTK-Doc V1.25</div>
|
||
</body>
|
||
</html> |