1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
2  *
3  * This file is part of GtkSourceView
4  *
5  * Copyright (C) 2014 - Ignacio Casal Quinteiro
6  *
7  * GtkSourceView is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * GtkSourceView is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with GtkSourceView. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 
25 #include "gtksourcestyleschemechooser.h"
26 #include "gtksourcestylescheme.h"
27 
28 /**
29  * SECTION:styleschemechooser
30  * @Short_description: Interface implemented by widgets for choosing style schemes
31  * @Title: GtkSourceStyleSchemeChooser
32  * @See_also: #GtkSourceStyleSchemeChooserWidget, #GtkSourceStyleSchemeChooserButton
33  *
34  * #GtkSourceStyleSchemeChooser is an interface that is implemented by widgets
35  * for choosing style schemes.
36  *
37  * In GtkSourceView, the main widgets that implement this interface are
38  * #GtkSourceStyleSchemeChooserWidget and #GtkSourceStyleSchemeChooserButton.
39  *
40  * Since: 3.16
41  */
42 
43 G_DEFINE_INTERFACE (GtkSourceStyleSchemeChooser, gtk_source_style_scheme_chooser, G_TYPE_OBJECT);
44 
45 static void
gtk_source_style_scheme_chooser_default_init(GtkSourceStyleSchemeChooserInterface * iface)46 gtk_source_style_scheme_chooser_default_init (GtkSourceStyleSchemeChooserInterface *iface)
47 {
48 	/**
49 	 * GtkSourceStyleSchemeChooser:style-scheme:
50 	 *
51 	 * The :style-scheme property contains the currently selected style
52 	 * scheme. The property can be set to change
53 	 * the current selection programmatically.
54 	 *
55 	 * Since: 3.16
56 	 */
57 	g_object_interface_install_property (iface,
58 		g_param_spec_object ("style-scheme",
59 		                     "Style Scheme",
60 		                     "Current style scheme",
61 		                     GTK_SOURCE_TYPE_STYLE_SCHEME,
62 		                     G_PARAM_READWRITE));
63 }
64 
65 /**
66  * gtk_source_style_scheme_chooser_get_style_scheme:
67  * @chooser: a #GtkSourceStyleSchemeChooser
68  *
69  * Gets the currently-selected scheme.
70  *
71  * Returns: (transfer none): the currently-selected scheme.
72  *
73  * Since: 3.16
74  */
75 GtkSourceStyleScheme *
gtk_source_style_scheme_chooser_get_style_scheme(GtkSourceStyleSchemeChooser * chooser)76 gtk_source_style_scheme_chooser_get_style_scheme (GtkSourceStyleSchemeChooser *chooser)
77 {
78 	g_return_val_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_CHOOSER (chooser), NULL);
79 
80 	return GTK_SOURCE_STYLE_SCHEME_CHOOSER_GET_IFACE (chooser)->get_style_scheme (chooser);
81 }
82 
83 /**
84  * gtk_source_style_scheme_chooser_set_style_scheme:
85  * @chooser: a #GtkSourceStyleSchemeChooser
86  * @scheme: a #GtkSourceStyleScheme
87  *
88  * Sets the scheme.
89  *
90  * Since: 3.16
91  */
92 void
gtk_source_style_scheme_chooser_set_style_scheme(GtkSourceStyleSchemeChooser * chooser,GtkSourceStyleScheme * scheme)93 gtk_source_style_scheme_chooser_set_style_scheme (GtkSourceStyleSchemeChooser *chooser,
94                                                   GtkSourceStyleScheme        *scheme)
95 {
96 	g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_CHOOSER (chooser));
97 	g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme));
98 
99 	GTK_SOURCE_STYLE_SCHEME_CHOOSER_GET_IFACE (chooser)->set_style_scheme (chooser, scheme);
100 }
101