2019-11-30 00:17:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2019 Benjamin Otte
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Benjamin Otte <otte@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GTK_BUILDER_SCOPE_H__
|
|
|
|
#define __GTK_BUILDER_SCOPE_H__
|
|
|
|
|
|
|
|
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
|
|
|
#error "Only <gtk/gtk.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtktypes.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GTK_TYPE_BUILDER_SCOPE (gtk_builder_scope_get_type ())
|
|
|
|
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
G_DECLARE_INTERFACE (GtkBuilderScope, gtk_builder_scope, GTK, BUILDER_SCOPE, GObject)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkBuilderClosureFlags:
|
|
|
|
* @GTK_BUILDER_CLOSURE_SWAPPED: The closure should be created swapped. See
|
|
|
|
* g_cclosure_new_swap() for details.
|
|
|
|
*
|
2020-08-05 01:17:49 +00:00
|
|
|
* The list of flags that can be passed to gtk_builder_create_closure().
|
2021-02-18 18:17:56 +00:00
|
|
|
*
|
2019-11-30 00:17:10 +00:00
|
|
|
* New values may be added in the future for new features, so external
|
2021-05-23 01:21:10 +00:00
|
|
|
* implementations of [iface@Gtk.BuilderScope] should test the flags
|
2021-02-18 18:17:56 +00:00
|
|
|
* for unknown values and raise a %GTK_BUILDER_ERROR_INVALID_ATTRIBUTE error
|
|
|
|
* when they encounter one.
|
2019-11-30 00:17:10 +00:00
|
|
|
*/
|
2020-12-01 17:26:34 +00:00
|
|
|
typedef enum { /*< prefix=GTK_BUILDER_CLOSURE >*/
|
2019-11-30 00:17:10 +00:00
|
|
|
GTK_BUILDER_CLOSURE_SWAPPED = (1 << 0)
|
|
|
|
} GtkBuilderClosureFlags;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkBuilderScopeInterface:
|
2021-05-20 13:17:04 +00:00
|
|
|
* @get_type_from_name: Try to lookup a `GType` via the its name. See
|
2021-05-18 21:05:26 +00:00
|
|
|
* gtk_builder_get_type_from_name() for more details.
|
|
|
|
* The C implementation will use g_type_from_name() and if that fails try to guess the
|
|
|
|
* correct function name for registering the type and then use dlsym() to load it.
|
|
|
|
* The default implementation just tries g_type_from_name() and otherwise fails.
|
2021-05-20 13:17:04 +00:00
|
|
|
* @get_type_from_function: Try to lookup a `GType` via the given function name, specified
|
2023-01-15 06:17:07 +00:00
|
|
|
* explicitly in a GtkBuilder file, like via the "type-func" attribute in the `<object>` tag.
|
2021-05-18 21:05:26 +00:00
|
|
|
* This function is very rarely used.
|
2021-05-20 13:17:04 +00:00
|
|
|
* The C implementation will use dlsym() and call the resulting function as a `GTypeFunc`.
|
2021-05-18 21:05:26 +00:00
|
|
|
* The default implementation will fail and just return %G_TYPE_INVALID.
|
2019-11-30 00:17:10 +00:00
|
|
|
* @create_closure: Create a closure with the given arguments. See gtk_builder_create_closure()
|
2021-05-18 21:05:26 +00:00
|
|
|
* for more details on those.
|
|
|
|
* The C implementation will try to use dlsym() to locate the function name and then
|
|
|
|
* g_cclosure_new() to create a closure for the symbol.
|
|
|
|
* The default implementation just fails and returns %NULL.
|
2019-11-30 00:17:10 +00:00
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
* The virtual function table to implement for `GtkBuilderScope` implementations.
|
2019-11-30 00:17:10 +00:00
|
|
|
* Default implementations for each function do exist, but they usually just fail,
|
|
|
|
* so it is suggested that implementations implement all of them.
|
|
|
|
*/
|
|
|
|
struct _GtkBuilderScopeInterface
|
|
|
|
{
|
|
|
|
/*< private >*/
|
|
|
|
GTypeInterface g_iface;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
GType (* get_type_from_name) (GtkBuilderScope *self,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const char *type_name);
|
2019-12-03 04:41:42 +00:00
|
|
|
GType (* get_type_from_function) (GtkBuilderScope *self,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const char *function_name);
|
2019-11-30 00:17:10 +00:00
|
|
|
|
|
|
|
GClosure * (* create_closure) (GtkBuilderScope *self,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const char *function_name,
|
|
|
|
GtkBuilderClosureFlags flags,
|
|
|
|
GObject *object,
|
|
|
|
GError **error);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct _GtkBuilderCScopeClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GTK_TYPE_BUILDER_CSCOPE (gtk_builder_cscope_get_type ())
|
|
|
|
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
G_DECLARE_DERIVABLE_TYPE (GtkBuilderCScope, gtk_builder_cscope, GTK, BUILDER_CSCOPE, GObject)
|
|
|
|
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
GtkBuilderScope * gtk_builder_cscope_new (void);
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
void gtk_builder_cscope_add_callback_symbol (GtkBuilderCScope *self,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *callback_name,
|
2019-11-30 00:17:10 +00:00
|
|
|
GCallback callback_symbol);
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
void gtk_builder_cscope_add_callback_symbols (GtkBuilderCScope *self,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *first_callback_name,
|
2019-11-30 00:17:10 +00:00
|
|
|
GCallback first_callback_symbol,
|
2022-06-30 20:13:17 +00:00
|
|
|
...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
|
|
#define gtk_builder_cscope_add_callback(scope, callback) \
|
|
|
|
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), #callback, G_CALLBACK (callback))
|
|
|
|
|
2019-11-30 00:17:10 +00:00
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
GCallback gtk_builder_cscope_lookup_callback_symbol(GtkBuilderCScope *self,
|
2022-06-30 20:13:17 +00:00
|
|
|
const char *callback_name);
|
2019-11-30 00:17:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GTK_BUILDER_SCOPE_H__ */
|