Beispiel #1
0
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);
}
Beispiel #2
0
/**
 * rb_find_plugin_data_file:
 * @plugin: the plugin object
 * @name: name of the file to find
 *
 * Locates a file under the plugin's data directory.
 *
 * Returns: allocated string containing the location of the file
 */
char *
rb_find_plugin_data_file (GObject *object, const char *name)
{
    PeasPluginInfo *info;
    char *ret = NULL;
    const char *plugin_name = "<unknown>";

    g_object_get (object, "plugin-info", &info, NULL);
    if (info != NULL) {
        char *tmp;

        tmp = g_build_filename (peas_plugin_info_get_data_dir (info), name, NULL);
        if (g_file_test (tmp, G_FILE_TEST_EXISTS)) {
            ret = tmp;
        } else {
            g_free (tmp);
        }

        plugin_name = peas_plugin_info_get_name (info);
    }

    if (ret == NULL) {
        const char *f;
        f = rb_file (name);
        if (f != NULL) {
            ret = g_strdup (f);
        }
    }

    rb_debug ("found '%s' when searching for file '%s' for plugin '%s'",
              ret, name, plugin_name);

    /* ensure it's an absolute path */
    if (ret != NULL && ret[0] != '/') {
        char *pwd = g_get_current_dir ();
        char *path = g_strconcat (pwd, G_DIR_SEPARATOR_S, ret, NULL);
        g_free (ret);
        g_free (pwd);
        ret = path;
    }

    return ret;
}