static void ide_application_unload_plugin_resources (IdeApplication *self, PeasPluginInfo *plugin_info, PeasEngine *engine) { g_autofree gchar *path = NULL; const gchar *data_dir; const gchar *module_name; g_assert (IDE_IS_APPLICATION (self)); g_assert (plugin_info != NULL); g_assert (PEAS_IS_ENGINE (engine)); module_name = peas_plugin_info_get_module_name (plugin_info); data_dir = peas_plugin_info_get_data_dir (plugin_info); /* Remove embedded gresources */ path = g_strdup_printf ("resource:///org/gnome/builder/plugins/%s/", module_name); dzl_application_remove_resources (DZL_APPLICATION (self), path); /* Remove on disk resources */ if (!g_str_has_prefix (data_dir, "resource://")) dzl_application_remove_resources (DZL_APPLICATION (self), data_dir); ide_application_plugins_unload_plugin_gresources (self, plugin_info, engine); }
/** * peas_extension_set_new_valist: (skip) * @engine: A #PeasEngine, or %NULL. * @exten_type: the extension #GType. * @first_property: the name of the first property. * @var_args: the value of the first property, followed optionally by more * name/value pairs, followed by %NULL. * * Create a new #PeasExtensionSet for the @exten_type extension type. * * If @engine is %NULL, then the default engine will be used. * * See peas_extension_set_new() for more information. * * Returns: a new instance of #PeasExtensionSet. */ PeasExtensionSet * peas_extension_set_new_valist (PeasEngine *engine, GType exten_type, const gchar *first_property, va_list var_args) { gpointer type_struct; GParameter *parameters; guint n_parameters; PeasExtensionSet *set; g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type), NULL); type_struct = _g_type_struct_ref (exten_type); if (!_valist_to_parameter_list (exten_type, type_struct, first_property, var_args, ¶meters, &n_parameters)) { /* Already warned */ _g_type_struct_unref (exten_type, type_struct); return NULL; } set = peas_extension_set_newv (engine, exten_type, n_parameters, parameters); while (n_parameters-- > 0) g_value_unset (¶meters[n_parameters].value); g_free (parameters); _g_type_struct_unref (exten_type, type_struct); return set; }
static void ide_keybindings_load_plugin (IdeKeybindings *self, PeasPluginInfo *plugin_info, PeasEngine *engine) { g_autofree gchar *path = NULL; const gchar *module_name; g_autoptr(GBytes) bytes = NULL; g_autoptr(GtkCssProvider) provider = NULL; g_assert (IDE_IS_KEYBINDINGS (self)); g_assert (plugin_info != NULL); g_assert (PEAS_IS_ENGINE (engine)); if (!self->mode || !self->plugin_providers) return; module_name = peas_plugin_info_get_module_name (plugin_info); path = g_strdup_printf ("/org/gnome/builder/plugins/%s/keybindings/%s.css", module_name, self->mode); bytes = g_resources_lookup_data (path, 0, NULL); if (bytes == NULL) return; IDE_TRACE_MSG ("Loading %s keybindings for \"%s\" plugin", self->mode, module_name); provider = gtk_css_provider_new (); gtk_css_provider_load_from_resource (provider, path); gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1); g_hash_table_insert (self->plugin_providers, g_strdup (module_name), g_steal_pointer (&provider)); }
/** * peas_extension_set_newv: * @engine: (allow-none): A #PeasEngine, or %NULL. * @exten_type: the extension #GType. * @n_parameters: the length of the @parameters array. * @parameters: (array length=n_parameters): an array of #GParameter. * * Create a new #PeasExtensionSet for the @exten_type extension type. * * If @engine is %NULL, then the default engine will be used. * * See peas_extension_set_new() for more information. * * Returns: (transfer full): a new instance of #PeasExtensionSet. * * Rename to: peas_extension_set_new */ PeasExtensionSet * peas_extension_set_newv (PeasEngine *engine, GType exten_type, guint n_parameters, GParameter *parameters) { PeasParameterArray construct_properties = { n_parameters, parameters }; g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type), NULL); return PEAS_EXTENSION_SET (g_object_new (PEAS_TYPE_EXTENSION_SET, "engine", engine, "extension-type", exten_type, "construct-properties", &construct_properties, NULL)); }
/** * peas_extension_set_new: (skip) * @engine: A #PeasEngine, or %NULL. * @exten_type: the extension #GType. * @first_property: the name of the first property. * @...: the value of the first property, followed optionally by more * name/value pairs, followed by %NULL. * * Create a new #PeasExtensionSet for the @exten_type extension type. * * At any moment, the #PeasExtensionSet will contain an extension instance for * each loaded plugin which implements the @exten_type extension type. It does * so by connecting to the relevant signals from #PeasEngine. * * The property values passed to peas_extension_set_new() will be used for the * construction of new extension instances. * * If @engine is %NULL, then the default engine will be used. * * See peas_engine_create_extension() for more information. * * Returns: a new instance of #PeasExtensionSet. */ PeasExtensionSet * peas_extension_set_new (PeasEngine *engine, GType exten_type, const gchar *first_property, ...) { va_list var_args; PeasExtensionSet *set; g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type), NULL); va_start (var_args, first_property); set = peas_extension_set_new_valist (engine, exten_type, first_property, var_args); va_end (var_args); return set; }
static void ide_application_plugins_unload_plugin_gresources (IdeApplication *self, PeasPluginInfo *plugin_info, PeasEngine *engine) { const gchar *module_name; GResource *resources; g_assert (IDE_IS_APPLICATION (self)); g_assert (plugin_info != NULL); g_assert (PEAS_IS_ENGINE (engine)); module_name = peas_plugin_info_get_module_name (plugin_info); resources = g_hash_table_lookup (self->plugin_gresources, module_name); if (resources != NULL) { g_resources_unregister (resources); g_hash_table_remove (self->plugin_gresources, module_name); } }
static void ide_keybindings_unload_plugin (IdeKeybindings *self, PeasPluginInfo *plugin_info, PeasEngine *engine) { GtkStyleProvider *provider; const gchar *module_name; g_assert (IDE_IS_KEYBINDINGS (self)); g_assert (plugin_info != NULL); g_assert (PEAS_IS_ENGINE (engine)); if (self->plugin_providers == NULL) return; module_name = peas_plugin_info_get_module_name (plugin_info); provider = g_hash_table_lookup (self->plugin_providers, module_name); if (provider == NULL) return; gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (), provider); g_hash_table_remove (self->plugin_providers, module_name); }
static void ide_application_plugins_load_plugin_gresources (IdeApplication *self, PeasPluginInfo *plugin_info, PeasEngine *engine) { g_autofree gchar *gresources_path = NULL; g_autofree gchar *gresources_basename = NULL; const gchar *module_dir; const gchar *module_name; g_assert (IDE_IS_APPLICATION (self)); g_assert (plugin_info != NULL); g_assert (PEAS_IS_ENGINE (engine)); module_dir = peas_plugin_info_get_module_dir (plugin_info); module_name = peas_plugin_info_get_module_name (plugin_info); gresources_basename = g_strdup_printf ("%s.gresource", module_name); gresources_path = g_build_filename (module_dir, gresources_basename, NULL); if (g_file_test (gresources_path, G_FILE_TEST_IS_REGULAR)) { g_autoptr(GError) error = NULL; GResource *resource; resource = g_resource_load (gresources_path, &error); if (resource == NULL) { g_warning ("Failed to load gresources: %s", error->message); return; } g_hash_table_insert (self->plugin_gresources, g_strdup (module_name), resource); g_resources_register (resource); } }