diff --git a/configure.ac b/configure.ac index a798c31..c5fbe8a 100644 --- a/configure.ac +++ b/configure.ac @@ -4,8 +4,8 @@ AC_PREREQ(2.63.2) m4_define(peas_major_version, 0) m4_define(peas_minor_version, 5) -m4_define(peas_micro_version, 5) -m4_define(peas_interface_age, 3) +m4_define(peas_micro_version, 6) +m4_define(peas_interface_age, 4) m4_define(peas_binary_age, [m4_eval(100 * peas_minor_version + peas_micro_version)]) m4_define(peas_version, [peas_major_version.peas_minor_version.peas_micro_version]) @@ -72,7 +72,7 @@ PKG_CHECK_MODULES(PEAS, [ glib-2.0 >= 2.18.0 gobject-2.0 >= 2.23.6 gmodule-2.0 >= 2.18.0 - gobject-introspection-1.0 >= 0.9.0 + gobject-introspection-1.0 >= 0.9.6 ]) dnl ================================================================ diff --git a/docs/reference/libpeas-sections.txt b/docs/reference/libpeas-sections.txt index d801468..ab88799 100644 --- a/docs/reference/libpeas-sections.txt +++ b/docs/reference/libpeas-sections.txt @@ -112,6 +112,7 @@ PeasExtensionSetClass PeasParameterArray peas_extension_set_call peas_extension_set_call_valist +peas_extension_set_callv peas_extension_set_get_extension peas_extension_set_new peas_extension_set_newv diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c index b0d736e..5494a04 100644 --- a/libpeas-gtk/peas-gtk-plugin-manager.c +++ b/libpeas-gtk/peas-gtk-plugin-manager.c @@ -139,6 +139,25 @@ show_about_cb (GtkWidget *widget, gtk_widget_show (pm->priv->about); } +#if !GTK_CHECK_VERSION(2,22,0) +static gboolean +gtk_window_has_group (GtkWindow *window) +{ + GtkWindowGroup *wg; + static GtkWindowGroup *default_wg = NULL; + + if (!default_wg) + { + GtkWidget *temp_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + default_wg = gtk_window_get_group (GTK_WINDOW (temp_window)); + gtk_widget_destroy (temp_window); + } + + wg = gtk_window_get_group (window); + return wg != NULL && wg != default_wg; +} +#endif + static void help_button_cb (GtkWidget *button, PeasPluginInfo *info) @@ -221,7 +240,7 @@ show_configure_cb (GtkWidget *widget, exten = peas_engine_create_extension (pm->priv->engine, info, PEAS_GTK_TYPE_CONFIGURABLE, NULL); g_return_if_fail (PEAS_IS_EXTENSION (exten)); - peas_extension_call (exten, "create_configure_widget", &conf_widget); + conf_widget = peas_gtk_configurable_create_configure_widget (PEAS_GTK_CONFIGURABLE (exten)); g_object_unref (exten); g_return_if_fail (GTK_IS_WIDGET (conf_widget)); @@ -231,7 +250,11 @@ show_configure_cb (GtkWidget *widget, conf_dlg = gtk_dialog_new_with_buttons (peas_plugin_info_get_name (info), toplevel, +#if !GTK_CHECK_VERSION(2,90,7) GTK_DIALOG_NO_SEPARATOR, +#else + 0, +#endif GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); diff --git a/libpeas/Makefile.am b/libpeas/Makefile.am index c0861ab..f7c96db 100644 --- a/libpeas/Makefile.am +++ b/libpeas/Makefile.am @@ -26,28 +26,30 @@ INST_H_FILES = \ peas-engine.h \ peas.h -NOINST_H_FILES = \ - peas-debug.h \ - peas-dirs.h \ - peas-helpers.h \ - peas-i18n.h \ - peas-introspection.h \ - peas-plugin-info-priv.h \ +NOINST_H_FILES = \ + peas-debug.h \ + peas-dirs.h \ + peas-extension-subclasses.h \ + peas-helpers.h \ + peas-i18n.h \ + peas-introspection.h \ + peas-plugin-info-priv.h \ peas-plugin-loader.h -C_FILES = \ - peas-debug.c \ - peas-dirs.c \ - peas-helpers.c \ - peas-i18n.c \ - peas-object-module.c \ - peas-introspection.c \ - peas-plugin-info.c \ - peas-plugin-loader.c \ - peas-extension-base.c \ - peas-extension.c \ - peas-extension-set.c \ - peas-activatable.c \ +C_FILES = \ + peas-debug.c \ + peas-dirs.c \ + peas-helpers.c \ + peas-i18n.c \ + peas-object-module.c \ + peas-introspection.c \ + peas-plugin-info.c \ + peas-plugin-loader.c \ + peas-extension-base.c \ + peas-extension.c \ + peas-extension-set.c \ + peas-extension-subclasses.c \ + peas-activatable.c \ peas-engine.c BUILT_SOURCES = \ diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c index d2e6418..195d7fa 100644 --- a/libpeas/peas-extension-set.c +++ b/libpeas/peas-extension-set.c @@ -29,6 +29,7 @@ #include "peas-plugin-info.h" #include "peas-marshal.h" #include "peas-helpers.h" +#include "peas-introspection.h" /** * SECTION:peas-extension-set @@ -308,17 +309,17 @@ peas_extension_set_finalize (GObject *object) static gboolean peas_extension_set_call_real (PeasExtensionSet *set, - const gchar *method, - va_list args) + const gchar *method_name, + GIArgument *args) { gboolean ret = TRUE; GList *l; - va_list args_copy; + GIArgument dummy; for (l = set->priv->extensions; l; l = l->next) { - G_VA_COPY (args_copy, args); - ret = peas_extension_call_valist (((ExtensionItem *) l->data)->exten, method, args_copy) && ret; + ExtensionItem *item = (ExtensionItem *) l->data; + ret = peas_extension_callv (item->exten, method_name, args, &dummy) && ret; } return ret; @@ -481,7 +482,7 @@ peas_extension_set_call (PeasExtensionSet *set, * peas_extension_set_call_valist: * @set: A #PeasExtensionSet. * @method_name: the name of the method that should be called. - * @args: the arguments for the method. + * @va_args: the arguments for the method. * * Call a method on all the #PeasExtension instances contained in @set. * @@ -492,7 +493,37 @@ peas_extension_set_call (PeasExtensionSet *set, gboolean peas_extension_set_call_valist (PeasExtensionSet *set, const gchar *method_name, - va_list args) + va_list va_args) +{ + GICallableInfo *callable_info; + GIArgument *args; + + g_return_val_if_fail (PEAS_IS_EXTENSION_SET (set), FALSE); + g_return_val_if_fail (method_name != NULL, FALSE); + + callable_info = peas_gi_get_method_info (set->priv->exten_type, method_name); + args = g_newa (GIArgument, g_callable_info_get_n_args (callable_info)); + peas_gi_valist_to_arguments (callable_info, va_args, args, NULL); + + return peas_extension_set_callv (set, method_name, args); +} + +/** + * peas_extension_set_callv: + * @set: A #PeasExtensionSet. + * @method_name: the name of the method that should be called. + * @args: the arguments for the method. + * + * Call a method on all the #PeasExtension instances contained in @set. + * + * See peas_extension_callv() for more information. + * + * Return value: %TRUE on successful call. + */ +gboolean +peas_extension_set_callv (PeasExtensionSet *set, + const gchar *method_name, + GIArgument *args) { PeasExtensionSetClass *klass; diff --git a/libpeas/peas-extension-set.h b/libpeas/peas-extension-set.h index 33c3bf4..a8d3c5d 100644 --- a/libpeas/peas-extension-set.h +++ b/libpeas/peas-extension-set.h @@ -59,7 +59,7 @@ struct _PeasExtensionSetClass { /* Virtual public methods */ gboolean (*call) (PeasExtensionSet *set, const gchar *method, - va_list args); + GIArgument *args); /* Signals */ void (*extension_added) (PeasExtensionSet *set, @@ -93,7 +93,10 @@ gboolean peas_extension_set_call (PeasExtensionSet *set, ...); gboolean peas_extension_set_call_valist (PeasExtensionSet *set, const gchar *method_name, - va_list args); + va_list va_args); +gboolean peas_extension_set_callv (PeasExtensionSet *set, + const gchar *method_name, + GIArgument *args); PeasExtension *peas_extension_set_get_extension (PeasExtensionSet *set, PeasPluginInfo *info); diff --git a/libpeas/peas-extension-subclasses.c b/libpeas/peas-extension-subclasses.c new file mode 100644 index 0000000..9231eca --- /dev/null +++ b/libpeas/peas-extension-subclasses.c @@ -0,0 +1,296 @@ +/* + * peas-extension-subclasses.h + * This file is part of libpeas + * + * Copyright (C) 2010 - Steve Frécinaux + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include "peas-extension.h" +#include "peas-extension-subclasses.h" +#include "peas-introspection.h" + +typedef struct _MethodImpl { + GICallableInfo *info; + gchar *method_name; + ffi_cif cif; + ffi_closure *closure; + guint struct_offset; +} MethodImpl; + +static GQuark +method_impl_quark (void) +{ + static GQuark quark = 0; + + if (quark == 0) + quark = g_quark_from_static_string ("PeasExtensionInterfaceImplementation"); + + return quark; +} + +static void +handle_method_impl (ffi_cif *cif, + gpointer result, + gpointer *args, + gpointer data) +{ + MethodImpl *impl = (MethodImpl *) data; + GIArgInfo *arg_info; + GITypeInfo *type_info; + GITypeInfo *return_type_info; + guint n_args, i; + PeasExtension *instance; + GIArgument *arguments; + GIArgument return_value; + + instance = *((PeasExtension **) args[0]); + g_assert (PEAS_IS_EXTENSION (instance)); + + n_args = g_callable_info_get_n_args (impl->info); + arguments = g_newa (GIArgument, n_args-1); + + for (i = 1; i < n_args; i++) + { + arg_info = g_callable_info_get_arg (impl->info, i); + type_info = g_arg_info_get_type (arg_info); + + peas_gi_pointer_to_argument (type_info, args[i], &arguments[i-1]); + + g_base_info_unref (type_info); + g_base_info_unref (arg_info); + } + + peas_extension_callv (instance, impl->method_name, arguments, &return_value); + + for (i = 1; i < n_args; i++) + { + GIDirection direction; + + arg_info = g_callable_info_get_arg (impl->info, i); + direction = g_arg_info_get_direction (arg_info); + + if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) + { + type_info = g_arg_info_get_type (arg_info); + peas_gi_argument_to_pointer (type_info, &arguments[i-1], args[i]); + g_base_info_unref (type_info); + } + + g_base_info_unref (arg_info); + } + + return_type_info = g_callable_info_get_return_type (impl->info); + + if (g_type_info_get_tag (return_type_info) != GI_TYPE_TAG_VOID) + peas_gi_argument_to_pointer (return_type_info, &return_value, result); + + g_base_info_unref (return_type_info); +} + +static void +create_native_closure (GIInterfaceInfo *iface_info, + GIVFuncInfo *vfunc_info, + MethodImpl *impl) +{ + GIFunctionInfo *invoker_info; + GIStructInfo *struct_info; + GIFieldInfo *field_info; + GITypeInfo *type_info; + GICallbackInfo *callback_info; + guint n_fields, i; + gboolean found_field_info; + + invoker_info = g_vfunc_info_get_invoker (vfunc_info); + if (invoker_info == NULL) + { + g_debug ("No invoker for VFunc '%s.%s'", + g_base_info_get_name (iface_info), + g_base_info_get_name (vfunc_info)); + g_base_info_unref (vfunc_info); + return; + } + + struct_info = g_interface_info_get_iface_struct (iface_info); + n_fields = g_struct_info_get_n_fields (struct_info); + + found_field_info = FALSE; + for (i = 0; i < n_fields; i++) + { + field_info = g_struct_info_get_field (struct_info, i); + + if (strcmp (g_base_info_get_name (field_info), + g_base_info_get_name (vfunc_info)) == 0) + { + found_field_info = TRUE; + break; + } + + g_base_info_unref (field_info); + } + + if (!found_field_info) + { + g_debug ("No struct field for VFunc '%s.%s'", + g_base_info_get_name (iface_info), + g_base_info_get_name (vfunc_info)); + g_base_info_unref (struct_info); + g_base_info_unref (invoker_info); + return; + } + + type_info = g_field_info_get_type (field_info); + g_assert (g_type_info_get_tag (type_info) == GI_TYPE_TAG_INTERFACE); + + callback_info = g_type_info_get_interface (type_info); + g_assert (g_base_info_get_type (callback_info) == GI_INFO_TYPE_CALLBACK); + + impl->info = g_base_info_ref (callback_info); + impl->method_name = g_strdup (g_base_info_get_name (invoker_info)); + impl->closure = g_callable_info_prepare_closure (callback_info, &impl->cif, + handle_method_impl, impl); + impl->struct_offset = g_field_info_get_offset (field_info); + + g_base_info_unref (callback_info); + g_base_info_unref (type_info); + g_base_info_unref (field_info); + g_base_info_unref (struct_info); + g_base_info_unref (invoker_info); +} + +static void +implement_interface_methods (gpointer iface, + GType proxy_type) +{ + GType exten_type = G_TYPE_FROM_INTERFACE (iface); + GIInterfaceInfo *iface_info; + guint n_vfuncs, i; + MethodImpl *impls; + + g_debug ("Implementing interface '%s' for proxy type '%s'", + g_type_name (exten_type), g_type_name (proxy_type)); + + iface_info = g_irepository_find_by_gtype (NULL, exten_type); + g_return_if_fail (g_base_info_get_type (iface_info) == GI_INFO_TYPE_INTERFACE); + + n_vfuncs = g_interface_info_get_n_vfuncs (iface_info); + + impls = g_type_get_qdata (exten_type, method_impl_quark ()); + + if (impls == NULL) + { + impls = g_new0 (MethodImpl, n_vfuncs); + + for (i = 0; i < n_vfuncs; i++) + { + GIVFuncInfo *vfunc_info; + vfunc_info = g_interface_info_get_vfunc (iface_info, i); + create_native_closure (iface_info, vfunc_info, &impls[i]); + } + + g_type_set_qdata (exten_type, method_impl_quark (), impls); + } + + for (i = 0; i < n_vfuncs; i++) + { + gpointer *method_ptr; + + if (impls[i].closure == NULL) + continue; + + method_ptr = G_STRUCT_MEMBER_P (iface, impls[i].struct_offset); + *method_ptr = impls[i].closure; + + g_debug ("Implemented '%s.%s' at %d (%p) with %p", + g_type_name (exten_type), impls[i].method_name, + impls[i].struct_offset, method_ptr, impls[i].closure); + } + + g_base_info_unref (iface_info); + + g_debug ("Implemented interface '%s' for '%s' proxy", + g_type_name (exten_type), g_type_name (proxy_type)); +} + +static void +extension_subclass_init (GObjectClass *klass) +{ + g_debug ("Initializing class '%s'", G_OBJECT_CLASS_NAME (klass)); +} + +static void +extension_subclass_instance_init (GObject *instance) +{ + g_debug ("Initializing new instance of '%s'", G_OBJECT_TYPE_NAME (instance)); +} + +GType +peas_extension_register_subclass (GType parent_type, + GType extension_type) +{ + gchar *type_name; + GType the_type; + + type_name = g_strdup_printf ("%s+%s", + g_type_name (parent_type), + g_type_name (extension_type)); + + the_type = g_type_from_name (type_name); + + if (the_type == G_TYPE_INVALID) + { + GTypeQuery query; + GTypeInfo type_info = { + 0, + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) extension_subclass_init, + (GClassFinalizeFunc) NULL, + NULL, + 0, + 0, + (GInstanceInitFunc) extension_subclass_instance_init + }; + GInterfaceInfo iface_info = { + (GInterfaceInitFunc) implement_interface_methods, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + g_debug ("Registering new type '%s'", type_name); + + g_type_query (parent_type, &query); + type_info.class_size = query.class_size; + type_info.instance_size = query.instance_size; + + the_type = g_type_register_static (parent_type, type_name, &type_info, 0); + + iface_info.interface_data = GSIZE_TO_POINTER (the_type); + + g_type_add_interface_static (the_type, extension_type, &iface_info); + } + + g_free (type_name); + + return the_type; +} diff --git a/libpeas/peas-extension-subclasses.h b/libpeas/peas-extension-subclasses.h new file mode 100644 index 0000000..e3fac1e --- /dev/null +++ b/libpeas/peas-extension-subclasses.h @@ -0,0 +1,34 @@ +/* + * peas-extension-subclasses.h + * This file is part of libpeas + * + * Copyright (C) 2010 - Steve Frécinaux + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __PEAS_EXTENSION_SUBCLASSES_H__ +#define __PEAS_EXTENSION_SUBCLASSES_H__ + +#include + +G_BEGIN_DECLS + +GType peas_extension_register_subclass (GType parent_type, + GType extension_type); + +G_END_DECLS + +#endif /* __PEAS_EXTENSION_SUBCLASSES_H__ */ diff --git a/libpeas/peas-extension.c b/libpeas/peas-extension.c index 9deb1a5..83f0e5f 100644 --- a/libpeas/peas-extension.c +++ b/libpeas/peas-extension.c @@ -213,8 +213,8 @@ peas_extension_call_valist (PeasExtension *exten, { GICallableInfo *callable_info; GITypeInfo *retval_info; - GArgument *gargs; - GArgument retval; + GIArgument *gargs; + GIArgument retval; gpointer retval_ptr; gboolean ret; @@ -222,7 +222,10 @@ peas_extension_call_valist (PeasExtension *exten, g_return_val_if_fail (method_name != NULL, FALSE); callable_info = peas_gi_get_method_info (exten->priv->exten_type, method_name); - gargs = g_new (GArgument, g_callable_info_get_n_args (callable_info)); + if (callable_info == NULL) + return FALSE; + + gargs = g_newa (GIArgument, g_callable_info_get_n_args (callable_info)); peas_gi_valist_to_arguments (callable_info, args, gargs, &retval_ptr); ret = peas_extension_callv (exten, method_name, gargs, &retval); @@ -234,16 +237,14 @@ peas_extension_call_valist (PeasExtension *exten, g_base_info_unref ((GIBaseInfo *) retval_info); } - g_free (gargs); - return ret; } gboolean peas_extension_callv (PeasExtension *exten, const gchar *method_name, - GArgument *args, - GArgument *return_value) + GIArgument *args, + GIArgument *return_value) { PeasExtensionClass *klass; diff --git a/libpeas/peas-extension.h b/libpeas/peas-extension.h index 8a2b89a..d47639e 100644 --- a/libpeas/peas-extension.h +++ b/libpeas/peas-extension.h @@ -67,8 +67,8 @@ struct _PeasExtensionClass { /*< private >*/ gboolean (*call) (PeasExtension *exten, const gchar *method, - GArgument *args, - GArgument *return_value); + GIArgument *args, + GIArgument *return_value); }; /* @@ -87,8 +87,8 @@ gboolean peas_extension_call_valist (PeasExtension *exten, va_list args); gboolean peas_extension_callv (PeasExtension *exten, const gchar *method_name, - GArgument *args, - GArgument *return_value); + GIArgument *args, + GIArgument *return_value); G_END_DECLS diff --git a/libpeas/peas-introspection.c b/libpeas/peas-introspection.c index 1ef4689..e93ec51 100644 --- a/libpeas/peas-introspection.c +++ b/libpeas/peas-introspection.c @@ -28,14 +28,14 @@ void peas_gi_valist_to_arguments (GICallableInfo *callable_info, va_list va_args, - GArgument *arguments, + GIArgument *arguments, gpointer *return_value) { guint i, n_args; GIArgInfo *arg_info; GITypeInfo *arg_type_info; GITypeInfo *retval_info; - GArgument *cur_arg; + GIArgument *cur_arg; n_args = g_callable_info_get_n_args (callable_info); @@ -138,10 +138,10 @@ peas_gi_valist_to_arguments (GICallableInfo *callable_info, static void peas_gi_split_in_and_out_arguments (GICallableInfo *callable_info, - GArgument *args, - GArgument *in_args, + GIArgument *args, + GIArgument *in_args, guint *n_in_args, - GArgument *out_args, + GIArgument *out_args, guint *n_out_args) { guint n_args, i; @@ -173,7 +173,7 @@ peas_gi_split_in_and_out_arguments (GICallableInfo *callable_info, void peas_gi_argument_to_pointer (GITypeInfo *type_info, - GArgument *arg, + GIArgument *arg, gpointer ptr) { switch (g_type_info_get_tag (type_info)) @@ -233,6 +233,70 @@ peas_gi_argument_to_pointer (GITypeInfo *type_info, } } +void +peas_gi_pointer_to_argument (GITypeInfo *type_info, + gpointer ptr, + GIArgument *arg) +{ + g_return_if_fail (ptr != NULL); + + switch (g_type_info_get_tag (type_info)) + { + case GI_TYPE_TAG_VOID: + case GI_TYPE_TAG_BOOLEAN: + arg->v_boolean = *((gboolean *) ptr); + break; + case GI_TYPE_TAG_INT8: + arg->v_int8 = *((gint8 *) ptr); + break; + case GI_TYPE_TAG_UINT8: + arg->v_uint8 = *((guint8 *) ptr); + break; + case GI_TYPE_TAG_INT16: + arg->v_int16 = *((gint16 *) ptr); + break; + case GI_TYPE_TAG_UINT16: + arg->v_uint16 = *((guint16 *) ptr); + break; + case GI_TYPE_TAG_INT32: + arg->v_int32 = *((gint32 *) ptr); + break; + case GI_TYPE_TAG_UINT32: + arg->v_uint32 = *((guint32 *) ptr); + break; + case GI_TYPE_TAG_INT64: + arg->v_int64 = *((gint64 *) ptr); + break; + case GI_TYPE_TAG_UINT64: + arg->v_uint64 = *((guint64 *) ptr); + break; + case GI_TYPE_TAG_FLOAT: + arg->v_float = *((gfloat *) ptr); + break; + case GI_TYPE_TAG_DOUBLE: + arg->v_double = *((gdouble *) ptr); + break; + case GI_TYPE_TAG_GTYPE: + /* apparently, GType is meant to be a gsize, from gobject/gtype.h in glib */ + arg->v_size = *((gsize *) ptr); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + arg->v_string = *((gchar **) ptr); + break; + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + arg->v_pointer = *((gpointer **) ptr); + break; + default: + g_return_if_reached (); + } +} + GICallableInfo * peas_gi_get_method_info (GType iface_type, const gchar *method_name) @@ -279,12 +343,12 @@ gboolean peas_method_apply (GObject *instance, GType iface_type, const gchar *method_name, - GArgument *args, - GArgument *return_value) + GIArgument *args, + GIArgument *return_value) { GICallableInfo *func_info; guint n_args, n_in_args, n_out_args; - GArgument *in_args, *out_args; + GIArgument *in_args, *out_args; gboolean ret = TRUE; GError *error = NULL; @@ -296,8 +360,8 @@ peas_method_apply (GObject *instance, n_in_args = 0; n_out_args = 0; - in_args = g_new0 (GArgument, n_args + 1); - out_args = g_new0 (GArgument, n_args); + in_args = g_newa (GIArgument, n_args + 1); + out_args = g_newa (GIArgument, n_args); peas_gi_split_in_and_out_arguments (func_info, args, in_args+1, &n_in_args, @@ -321,8 +385,6 @@ peas_method_apply (GObject *instance, } out: - g_free (in_args); - g_free (out_args); g_base_info_unref ((GIBaseInfo *) func_info); return ret; diff --git a/libpeas/peas-introspection.h b/libpeas/peas-introspection.h index 679f9cf..7e63537 100644 --- a/libpeas/peas-introspection.h +++ b/libpeas/peas-introspection.h @@ -32,16 +32,19 @@ GICallableInfo *peas_gi_get_method_info (GType iface_type, void peas_gi_valist_to_arguments (GICallableInfo *callable_info, va_list va_args, - GArgument *arguments, + GIArgument *arguments, gpointer *return_value); void peas_gi_argument_to_pointer (GITypeInfo *type_info, - GArgument *arg, + GIArgument *arg, gpointer ptr); +void peas_gi_pointer_to_argument (GITypeInfo *type_info, + gpointer ptr, + GIArgument *arg); gboolean peas_method_apply (GObject *instance, GType iface_type, const gchar *method_name, - GArgument *args, - GArgument *return_value); + GIArgument *args, + GIArgument *return_value); G_END_DECLS diff --git a/loaders/c/peas-extension-c.c b/loaders/c/peas-extension-c.c index 0fe4815..1f628fe 100644 --- a/loaders/c/peas-extension-c.c +++ b/loaders/c/peas-extension-c.c @@ -25,15 +25,10 @@ #include #include +#include #include "peas-extension-c.h" -G_DEFINE_DYNAMIC_TYPE (PeasExtensionC, peas_extension_c, PEAS_TYPE_EXTENSION); - -void -peas_extension_c_register (GTypeModule *module) -{ - peas_extension_c_register_type (module); -} +G_DEFINE_TYPE (PeasExtensionC, peas_extension_c, PEAS_TYPE_EXTENSION); static void peas_extension_c_init (PeasExtensionC *cexten) @@ -43,8 +38,8 @@ peas_extension_c_init (PeasExtensionC *cexten) static gboolean peas_extension_c_call (PeasExtension *exten, const gchar *method_name, - GArgument *args, - GArgument *retval) + GIArgument *args, + GIArgument *retval) { PeasExtensionC *cexten = PEAS_EXTENSION_C (exten); GType gtype; @@ -76,18 +71,15 @@ peas_extension_c_class_init (PeasExtensionCClass *klass) extension_class->call = peas_extension_c_call; } -static void -peas_extension_c_class_finalize (PeasExtensionCClass *klass) -{ -} - PeasExtension * peas_extension_c_new (GType gtype, GObject *instance) { PeasExtensionC *cexten; + GType real_type; - cexten = PEAS_EXTENSION_C (g_object_new (PEAS_TYPE_EXTENSION_C, + real_type = peas_extension_register_subclass (PEAS_TYPE_EXTENSION_C, gtype); + cexten = PEAS_EXTENSION_C (g_object_new (real_type, "extension-type", gtype, NULL)); cexten->instance = instance; diff --git a/loaders/c/peas-extension-c.h b/loaders/c/peas-extension-c.h index 71dd045..a2f75f7 100644 --- a/loaders/c/peas-extension-c.h +++ b/loaders/c/peas-extension-c.h @@ -47,7 +47,6 @@ struct _PeasExtensionCClass { }; GType peas_extension_c_get_type (void) G_GNUC_CONST; -void peas_extension_c_register (GTypeModule *module); PeasExtension *peas_extension_c_new (GType gtype, GObject *instance); diff --git a/loaders/c/peas-plugin-loader-c.c b/loaders/c/peas-plugin-loader-c.c index 4f15b1e..1a20a47 100644 --- a/loaders/c/peas-plugin-loader-c.c +++ b/loaders/c/peas-plugin-loader-c.c @@ -36,14 +36,11 @@ struct _PeasPluginLoaderCPrivate GHashTable *loaded_plugins; }; -G_DEFINE_DYNAMIC_TYPE (PeasPluginLoaderC, peas_plugin_loader_c, PEAS_TYPE_PLUGIN_LOADER); +G_DEFINE_TYPE (PeasPluginLoaderC, peas_plugin_loader_c, PEAS_TYPE_PLUGIN_LOADER); G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module) { - peas_plugin_loader_c_register_type (G_TYPE_MODULE (module)); - peas_extension_c_register (G_TYPE_MODULE (module)); - peas_object_module_register_extension_type (module, PEAS_TYPE_PLUGIN_LOADER, PEAS_TYPE_PLUGIN_LOADER_C); @@ -231,8 +228,3 @@ peas_plugin_loader_c_class_init (PeasPluginLoaderCClass *klass) g_type_class_add_private (object_class, sizeof (PeasPluginLoaderCPrivate)); } - -static void -peas_plugin_loader_c_class_finalize (PeasPluginLoaderCClass *klass) -{ -} diff --git a/loaders/python/peas-extension-python.c b/loaders/python/peas-extension-python.c index a667933..461b864 100644 --- a/loaders/python/peas-extension-python.c +++ b/loaders/python/peas-extension-python.c @@ -30,15 +30,10 @@ #include #include #include +#include #include "peas-extension-python.h" -G_DEFINE_DYNAMIC_TYPE (PeasExtensionPython, peas_extension_python, PEAS_TYPE_EXTENSION); - -void -peas_extension_python_register (GTypeModule *module) -{ - peas_extension_python_register_type (module); -} +G_DEFINE_TYPE (PeasExtensionPython, peas_extension_python, PEAS_TYPE_EXTENSION); static void peas_extension_python_init (PeasExtensionPython *pyexten) @@ -48,8 +43,8 @@ peas_extension_python_init (PeasExtensionPython *pyexten) static gboolean peas_extension_python_call (PeasExtension *exten, const gchar *method_name, - GArgument *args, - GArgument *retval) + GIArgument *args, + GIArgument *retval) { PeasExtensionPython *pyexten = PEAS_EXTENSION_PYTHON (exten); GType gtype; @@ -85,18 +80,15 @@ peas_extension_python_class_init (PeasExtensionPythonClass *klass) extension_class->call = peas_extension_python_call; } -static void -peas_extension_python_class_finalize (PeasExtensionPythonClass *klass) -{ -} - PeasExtension * peas_extension_python_new (GType gtype, PyObject *instance) { PeasExtensionPython *pyexten; + GType real_type; - pyexten = PEAS_EXTENSION_PYTHON (g_object_new (PEAS_TYPE_EXTENSION_PYTHON, + real_type = peas_extension_register_subclass (PEAS_TYPE_EXTENSION_PYTHON, gtype); + pyexten = PEAS_EXTENSION_PYTHON (g_object_new (real_type, "extension-type", gtype, NULL)); pyexten->instance = instance; diff --git a/loaders/python/peas-extension-python.h b/loaders/python/peas-extension-python.h index d8699e0..476ae69 100644 --- a/loaders/python/peas-extension-python.h +++ b/loaders/python/peas-extension-python.h @@ -52,7 +52,6 @@ struct _PeasExtensionPythonClass { }; GType peas_extension_python_get_type (void) G_GNUC_CONST; -void peas_extension_python_register (GTypeModule *module); PeasExtension *peas_extension_python_new (GType gtype, PyObject *instance); diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c index 10c35b1..7f956bc 100644 --- a/loaders/python/peas-plugin-loader-python.c +++ b/loaders/python/peas-plugin-loader-python.c @@ -57,14 +57,11 @@ static PyObject *PyGObject_Type; static gboolean peas_plugin_loader_python_add_module_path (PeasPluginLoaderPython *self, const gchar *module_path); -G_DEFINE_DYNAMIC_TYPE (PeasPluginLoaderPython, peas_plugin_loader_python, PEAS_TYPE_PLUGIN_LOADER); +G_DEFINE_TYPE (PeasPluginLoaderPython, peas_plugin_loader_python, PEAS_TYPE_PLUGIN_LOADER); G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module) { - peas_plugin_loader_python_register_type (G_TYPE_MODULE (module)); - peas_extension_python_register (G_TYPE_MODULE (module)); - peas_object_module_register_extension_type (module, PEAS_TYPE_PLUGIN_LOADER, PEAS_TYPE_PLUGIN_LOADER_PYTHON); @@ -593,8 +590,3 @@ peas_plugin_loader_python_class_init (PeasPluginLoaderPythonClass *klass) g_type_class_add_private (object_class, sizeof (PeasPluginLoaderPythonPrivate)); } - -static void -peas_plugin_loader_python_class_finalize (PeasPluginLoaderPythonClass *klass) -{ -} diff --git a/loaders/seed/peas-extension-seed.c b/loaders/seed/peas-extension-seed.c index 71094e7..e5327bb 100644 --- a/loaders/seed/peas-extension-seed.c +++ b/loaders/seed/peas-extension-seed.c @@ -25,9 +25,10 @@ #include "peas-extension-seed.h" #include +#include #include -G_DEFINE_DYNAMIC_TYPE (PeasExtensionSeed, peas_extension_seed, PEAS_TYPE_EXTENSION); +G_DEFINE_TYPE (PeasExtensionSeed, peas_extension_seed, PEAS_TYPE_EXTENSION); enum { PROP_0, @@ -38,7 +39,7 @@ enum { typedef struct { GITypeInfo *type_info; - GArgument *ptr; + GIArgument *ptr; } OutArg; static void @@ -89,7 +90,7 @@ peas_extension_seed_finalize (GObject *object) static SeedValue get_argument (SeedContext ctx, - GArgument *arg, + GIArgument *arg, GITypeInfo *arg_type_info, SeedException *exc) { @@ -226,8 +227,8 @@ set_return_value (OutArg *arg, static gboolean peas_extension_seed_call (PeasExtension *exten, const gchar *method_name, - GArgument *args, - GArgument *retval) + GIArgument *args, + GIArgument *retval) { PeasExtensionSeed *sexten = PEAS_EXTENSION_SEED (exten); GType exten_type; @@ -394,26 +395,18 @@ peas_extension_seed_class_init (PeasExtensionSeedClass *klass) G_PARAM_CONSTRUCT_ONLY)); } -static void -peas_extension_seed_class_finalize (PeasExtensionSeedClass *klass) -{ -} - -void -peas_extension_seed_register (GTypeModule *type_module) -{ - peas_extension_seed_register_type (type_module); -} - PeasExtension * peas_extension_seed_new (GType exten_type, SeedContext js_context, SeedObject js_object) { + GType real_type; + g_return_val_if_fail (js_context != NULL, NULL); g_return_val_if_fail (js_object != NULL, NULL); - return PEAS_EXTENSION (g_object_new (PEAS_TYPE_EXTENSION_SEED, + real_type = peas_extension_register_subclass (PEAS_TYPE_EXTENSION_SEED, exten_type); + return PEAS_EXTENSION (g_object_new (real_type, "extension-type", exten_type, "js-context", js_context, "js-object", js_object, diff --git a/loaders/seed/peas-extension-seed.h b/loaders/seed/peas-extension-seed.h index 862831f..43082a6 100644 --- a/loaders/seed/peas-extension-seed.h +++ b/loaders/seed/peas-extension-seed.h @@ -49,7 +49,6 @@ struct _PeasExtensionSeedClass { }; GType peas_extension_seed_get_type (void) G_GNUC_CONST; -void peas_extension_seed_register (GTypeModule *type_module); PeasExtension *peas_extension_seed_new (GType exten_type, SeedContext js_context, diff --git a/loaders/seed/peas-plugin-loader-seed.c b/loaders/seed/peas-plugin-loader-seed.c index 5a184ad..73a303e 100644 --- a/loaders/seed/peas-plugin-loader-seed.c +++ b/loaders/seed/peas-plugin-loader-seed.c @@ -32,7 +32,7 @@ SeedValue seed_value_from_gvalue (SeedContext ctx, #include "peas-plugin-loader-seed.h" #include "peas-extension-seed.h" -G_DEFINE_DYNAMIC_TYPE (PeasPluginLoaderSeed, peas_plugin_loader_seed, PEAS_TYPE_PLUGIN_LOADER); +G_DEFINE_TYPE (PeasPluginLoaderSeed, peas_plugin_loader_seed, PEAS_TYPE_PLUGIN_LOADER); typedef struct { SeedContext context; @@ -140,7 +140,7 @@ peas_plugin_loader_seed_provides_extension (PeasPluginLoader *loader, { PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader); SeedInfo *sinfo; - SeedObject *extension; + SeedValue extension; sinfo = (SeedInfo *) g_hash_table_lookup (sloader->loaded_plugins, info); if (!sinfo) @@ -149,7 +149,7 @@ peas_plugin_loader_seed_provides_extension (PeasPluginLoader *loader, extension = seed_object_get_property (sinfo->context, sinfo->extensions, g_type_name (exten_type)); - return extension != NULL; + return extension && seed_value_is_object (sinfo->context, extension); } static PeasExtension * @@ -173,7 +173,7 @@ peas_plugin_loader_seed_create_extension (PeasPluginLoader *loader, extension_methods = seed_object_get_property (sinfo->context, sinfo->extensions, g_type_name (exten_type)); - if (!extension_methods) + if (!extension_methods || seed_value_is_undefined (sinfo->context, extension_methods) || seed_value_is_null (sinfo->context, extension_methods)) return NULL; if (!seed_value_is_object (sinfo->context, extension_methods)) @@ -277,17 +277,9 @@ peas_plugin_loader_seed_class_init (PeasPluginLoaderSeedClass *klass) loader_class->garbage_collect = peas_plugin_loader_seed_garbage_collect; } -static void -peas_plugin_loader_seed_class_finalize (PeasPluginLoaderSeedClass *klass) -{ -} - G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module) { - peas_plugin_loader_seed_register_type (G_TYPE_MODULE (module)); - peas_extension_seed_register (G_TYPE_MODULE (module)); - peas_object_module_register_extension_type (module, PEAS_TYPE_PLUGIN_LOADER, PEAS_TYPE_PLUGIN_LOADER_SEED); diff --git a/peas-demo/peas-demo-window.c b/peas-demo/peas-demo-window.c index 9efd57c..35cc2cb 100644 --- a/peas-demo/peas-demo-window.c +++ b/peas-demo/peas-demo-window.c @@ -47,7 +47,7 @@ on_extension_added (PeasExtensionSet *set, PeasExtension *exten, DemoWindow *dw) { - peas_extension_call (exten, "activate", dw); + peas_activatable_activate (PEAS_ACTIVATABLE (exten)); } static void @@ -56,7 +56,7 @@ on_extension_removed (PeasExtensionSet *set, PeasExtension *exten, DemoWindow *dw) { - peas_extension_call (exten, "deactivate"); + peas_activatable_deactivate (PEAS_ACTIVATABLE (exten)); } static gboolean diff --git a/po/cs.po b/po/cs.po index edea3cd..2e1083a 100644 --- a/po/cs.po +++ b/po/cs.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: libpeas master\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-07-19 18:51+0000\n" -"PO-Revision-Date: 2010-07-19 21:33+0200\n" +"POT-Creation-Date: 2010-08-18 18:50+0000\n" +"PO-Revision-Date: 2010-07-22 22:35+0200\n" "Last-Translator: Marek Černocký \n" "Language-Team: Czech \n" "MIME-Version: 1.0\n" @@ -19,14 +19,47 @@ msgstr "" "X-Poedit-Language: Czech\n" "X-Poedit-SourceCharset: utf-8\n" -#: ../libpeasui/peas-ui-plugin-manager.c:253 +#: ../libpeas-gtk/peas-gtk-plugin-manager.c:177 +msgid "There was an error displaying the help." +msgstr "Vyskytla se chyba při zobrazení nápovědy." + +#: ../libpeas-gtk/peas-gtk-plugin-manager.c:335 msgid "C_onfigure" msgstr "Na_stavit" -#: ../libpeasui/peas-ui-plugin-manager.c:261 +#: ../libpeas-gtk/peas-gtk-plugin-manager.c:343 msgid "_About" msgstr "O _aplikaci" -#: ../libpeasui/peas-ui-plugin-manager.c:282 +#: ../libpeas-gtk/peas-gtk-plugin-manager.c:364 msgid "_Plugins:" msgstr "Zásuvné _moduly:" + +#: ../libpeas-gtk/peas-gtk-plugin-manager-view.c:295 +msgid "_Enabled" +msgstr "Povol_en" + +#: ../libpeas-gtk/peas-gtk-plugin-manager-view.c:306 +msgid "E_nable All" +msgstr "Po_volit vše" + +#: ../libpeas-gtk/peas-gtk-plugin-manager-view.c:310 +msgid "_Disable All" +msgstr "Za_kázat vše" + +#: ../libpeas-gtk/peas-gtk-plugin-manager-view.c:467 +msgid "Enabled" +msgstr "Povolen" + +#: ../libpeas-gtk/peas-gtk-plugin-manager-view.c:488 +msgid "Plugin" +msgstr "Zásuvný modul" + +#: ../peas-demo/peas-demo.c:39 +msgid "Run from build directory" +msgstr "Spustit ze složky, ve které bylo sestaveno" + +#: ../peas-demo/peas-demo.c:130 +msgid "- libpeas demo application" +msgstr "- ukázková aplikace libpeas" + diff --git a/po/fr.po b/po/fr.po index 1badd30..7fcfad1 100644 --- a/po/fr.po +++ b/po/fr.po @@ -2,13 +2,14 @@ # Copyright (C) 2010 Listed translators # This file is distributed under the same license as the libpeas package. # Nicolas Repentin , 2010. +# Claude Paroz , 2010. # msgid "" msgstr "" "Project-Id-Version: libpeas master\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-07-19 18:51+0000\n" -"PO-Revision-Date: 2010-07-20 20:52+0200\n" +"POT-Creation-Date: 2010-07-22 11:00+0000\n" +"PO-Revision-Date: 2010-08-29 19:52+0200\n" "Last-Translator: Claude Paroz \n" "Language-Team: GNOME French Team \n" "MIME-Version: 1.0\n" @@ -16,29 +17,52 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: ../libpeasui/peas-ui-plugin-manager.c:253 +#: ../libpeasui/peas-ui-plugin-manager.c:177 +msgid "There was an error displaying the help." +msgstr "Une erreur s'est produite durant l'affichage de l'aide." + +#: ../libpeasui/peas-ui-plugin-manager.c:335 msgid "C_onfigure" msgstr "C_onfigurer" -#: ../libpeasui/peas-ui-plugin-manager.c:261 +#: ../libpeasui/peas-ui-plugin-manager.c:343 msgid "_About" msgstr "À _propos" -#: ../libpeasui/peas-ui-plugin-manager.c:282 +#: ../libpeasui/peas-ui-plugin-manager.c:364 msgid "_Plugins:" msgstr "_Greffons :" -#~ msgid "Enabled" -#~ msgstr "Activé" +#: ../libpeasui/peas-ui-plugin-manager-view.c:295 +msgid "_Enabled" +msgstr "_Activé" -#~ msgid "A_ctivate" -#~ msgstr "A_ctiver" +#: ../libpeasui/peas-ui-plugin-manager-view.c:306 +msgid "E_nable All" +msgstr "_Tout activer" + +#: ../libpeasui/peas-ui-plugin-manager-view.c:310 +msgid "_Disable All" +msgstr "Tout _désactiver" + +#: ../libpeasui/peas-ui-plugin-manager-view.c:467 +msgid "Enabled" +msgstr "Activé" -#~ msgid "Ac_tivate All" -#~ msgstr "_Tout activer" +#: ../libpeasui/peas-ui-plugin-manager-view.c:488 +msgid "Plugin" +msgstr "Greffon" -#~ msgid "_Deactivate All" -#~ msgstr "Tout _désactiver" +#: ../peas-demo/peas-demo.c:39 +msgid "Run from build directory" +msgstr "Lancer à partir du répertoire de compilation" + +#: ../peas-demo/peas-demo.c:130 +msgid "- libpeas demo application" +msgstr "- application démo libpeas" + +#~ msgid "A_ctivate" +#~ msgstr "A_ctiver" #~ msgid "Active _Plugins:" #~ msgstr "_Greffons actifs :"