/**
 * gimp_plug_in_manager_ignore_plugin_basename:
 * @basename: Basename to test with
 *
 * Checks the environment variable
 * GIMP_TESTING_PLUGINDIRS_BASENAME_IGNORES for file basenames.
 *
 * Returns: %TRUE if @basename was in GIMP_TESTING_PLUGINDIRS_BASENAME_IGNORES
 **/
static gboolean
gimp_plug_in_manager_ignore_plugin_basename (const gchar *plugin_basename)
{
  const gchar *ignore_basenames_string;
  GList       *ignore_basenames;
  GList       *iter;
  gboolean     ignore = FALSE;

  ignore_basenames_string = g_getenv("GIMP_TESTING_PLUGINDIRS_BASENAME_IGNORES");
  ignore_basenames        = gimp_path_parse (ignore_basenames_string,
                                             256 /*max_paths*/,
                                             FALSE /*check*/,
                                             NULL /*check_failed*/);

  for (iter = ignore_basenames; iter; iter = g_list_next (iter))
    {
      const gchar *ignore_basename = iter->data;

      if (g_ascii_strcasecmp (ignore_basename, plugin_basename) == 0)
        {
          ignore = TRUE;
          break;
        }
    }
  
  gimp_path_free (ignore_basenames);

  return ignore;
}
Пример #2
0
void
gimp_path_editor_set_writable_path (GimpPathEditor *editor,
                                    const gchar    *path)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;
  gboolean      iter_valid;
  GList        *path_list;
  gboolean      writable_changed = FALSE;

  g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));

  gtk_tree_view_column_set_visible (editor->writable_column, TRUE);

  path_list = gimp_path_parse (path, 16, TRUE, NULL);

  model = GTK_TREE_MODEL (editor->dir_list);

  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
       iter_valid;
       iter_valid = gtk_tree_model_iter_next (model, &iter))
    {
      gchar    *dir;
      gboolean  dir_writable;
      gboolean  new_writable = FALSE;

      gtk_tree_model_get (model, &iter,
                          COLUMN_DIRECTORY, &dir,
                          COLUMN_WRITABLE,  &dir_writable,
                          -1);

      if (g_list_find_custom (path_list, dir, (GCompareFunc) strcmp))
        new_writable = TRUE;

      g_free (dir);

      if (dir_writable != new_writable)
        {
          gtk_list_store_set (editor->dir_list, &iter,
                              COLUMN_WRITABLE, new_writable,
                              -1);

          writable_changed = TRUE;
        }
    }

  gimp_path_free (path_list);

  if (writable_changed)
    g_signal_emit (editor, gimp_path_editor_signals[WRITABLE_CHANGED], 0);
}
Пример #3
0
/**
 * gimp_path_editor_set_path:
 * @editor: The path editor you want to set the search path from.
 * @path:   The new path to set.
 *
 * The elements of the initial search path must be separated with the
 * #G_SEARCHPATH_SEPARATOR character.
 **/
void
gimp_path_editor_set_path (GimpPathEditor *editor,
                           const gchar    *path)
{
  gchar *old_path;
  GList *path_list;
  GList *list;

  g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));

  old_path = gimp_path_editor_get_path (editor);

  if (old_path && path && strcmp (old_path, path) == 0)
    {
      g_free (old_path);
      return;
    }

  g_free (old_path);

  path_list = gimp_path_parse (path, 16, TRUE, NULL);

  gtk_list_store_clear (editor->dir_list);

  for (list = path_list; list; list = g_list_next (list))
    {
      gchar       *directory = list->data;
      gchar       *utf8;
      GtkTreeIter  iter;

      utf8 = g_filename_to_utf8 (directory, -1, NULL, NULL, NULL);

      gtk_list_store_append (editor->dir_list, &iter);
      gtk_list_store_set (editor->dir_list, &iter,
                          COLUMN_UTF8,      utf8,
                          COLUMN_DIRECTORY, directory,
                          COLUMN_WRITABLE,  FALSE,
                          -1);

      g_free (utf8);

      editor->num_items++;
    }

  gimp_path_free (path_list);

  g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
}
Пример #4
0
static void
gimp_fonts_add_directories (FcConfig    *config,
                            const gchar *path_str)
{
  GList *path;
  GList *list;

  g_return_if_fail (config != NULL);
  g_return_if_fail (path_str != NULL);

  path = gimp_path_parse (path_str, 256, TRUE, NULL);

  for (list = path; list; list = list->next)
    FcConfigAppFontAddDir (config, (const guchar *) list->data);

  gimp_path_free (path);
}
Пример #5
0
static void
scan_search_path (void)
{
  GList *path_list;
  GList *list; 

  /* Scan search_path looking for PS plug-ins */
  path_list = gimp_path_parse (search_path, 99, TRUE, NULL);

  list = path_list;
  while (list != NULL)
    {
      gchar *path = list->data;
      list = list->next;

      my_ftw (path, scan_filter);
    }
}
Пример #6
0
/* This function is memoized. Once it finds the value it permanently
 * caches it
 * */
GList *
parsepath (void)
{
  gchar *rc_path, *path;

  if (parsepath_cached_path)
    return parsepath_cached_path;

  path = gimp_gimprc_query ("gimpressionist-path");
  if (path)
    {
      rc_path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
      g_free (path);
    }
  else
    {
      gchar *gimprc    = gimp_personal_rc_file ("gimprc");
      gchar *full_path = gimp_config_build_data_path ("gimpressionist");
      gchar *esc_path  = g_strescape (full_path, NULL);

      g_message (_("No %s in gimprc:\n"
                   "You need to add an entry like\n"
                   "(%s \"%s\")\n"
                   "to your %s file."),
                 "gflare-path", "gflare-path",
                 esc_path, gimp_filename_to_utf8 (gimprc));

      g_free (gimprc);
      g_free (esc_path);

      rc_path = gimp_config_path_expand (full_path, TRUE, NULL);
      g_free (full_path);
    }

  parsepath_cached_path = gimp_path_parse (rc_path, 16, FALSE, NULL);

  g_free (rc_path);

  return parsepath_cached_path;
}
Пример #7
0
void
fontsel_configure (GtkWidget *fontsel,
		   gboolean   init)
{
  gchar        *path;
  GList        *list;
  GList        *dirs;
  GtkWidget    *parent;
  GtkWidget    *clist;
  ProgressData *pdata;

  g_return_if_fail (fontsel != NULL);

  parent = gtk_widget_get_toplevel (fontsel);
  path   = gimp_gimprc_query (FONTPATH_TOKEN);

  if (init)
    {
      if (path == NULL || !*path)
	{
	  path = g_strdup (DEFAULT_FONTPATH);

	  fontsel_directories_dialog
            (parent, _("You seem to be running the FreeType plug-in for the "
                       "first time. You need to specify a list of folders "
                       "where font files can be found on your system."),
             &path);
	}
    }
  else
    {
      init = fontsel_directories_dialog (parent, NULL, &path);
    }

  if (init)
    {
      pdata = g_object_get_data (G_OBJECT (fontsel), "progress_data");
      start_progress (pdata);

      if (families)
	{
	  g_tree_foreach (families,
                          (GTraverseFunc) fontsel_remove_family,
                          NULL);
	  g_tree_destroy (families);
	}

      families = g_tree_new ((GCompareFunc)strcmp);

      dirs = gimp_path_parse (path, 128, TRUE, NULL);

      for (list = dirs; list; list = g_list_next (list))
        fontsel_scan_directory (list->data);

      clist = g_object_get_data (G_OBJECT (fontsel), "family_list");
      gtk_clist_freeze (GTK_CLIST (clist));
      gtk_clist_clear (GTK_CLIST (clist));
      g_tree_foreach (families,
                      (GTraverseFunc) fontsel_family_list_insert,
                      clist);
      gtk_clist_thaw (GTK_CLIST (clist));

      stop_progress (pdata);
    }
}
Пример #8
0
void
datafiles_read_directories (gchar                  *path_str,
                            GimpDataFileLoaderFunc  loader_func,
                            GimpDataFileFlags       flags)
{
    gchar *local_path;
    GList *path;
    GList *list;
    gchar *filename;
    gint   err;
    DIR   *dir;
    struct dirent *dir_ent;

    if (path_str == NULL)
        return;

    local_path = g_strdup (path_str);

#ifdef __EMX__
    /*
     *  Change drive so opendir works.
     */
    if (local_path[1] == ':')
    {
        _chdrive (local_path[0]);
    }
#endif

    path = gimp_path_parse (local_path, 16, TRUE, NULL);

    for (list = path; list; list = g_list_next (list))
    {
        /* Open directory */
        dir = opendir ((gchar *) list->data);

        if (!dir)
        {
            g_message ("error reading datafiles directory \"%s\"",
                       (gchar *) list->data);
        }
        else
        {
            while ((dir_ent = readdir (dir)))
            {
                filename = g_strdup_printf ("%s%s",
                                            (gchar *) list->data,
                                            dir_ent->d_name);

                /* Check the file and see that it is not a sub-directory */
                err = stat (filename, &filestat);

                if (!err && S_ISREG (filestat.st_mode) &&
                        (!(flags & MODE_EXECUTABLE) ||
                         (filestat.st_mode & S_IXUSR)))
                {
                    filestat_valid = TRUE;
                    (*loader_func) (filename);
                    filestat_valid = FALSE;
                }

                g_free (filename);
            }

            closedir (dir);
        }
    }

    gimp_path_free (path);
    g_free (local_path);
}
Пример #9
0
void
gimp_datafiles_read_directories (const gchar            *path_str,
                                 GFileTest               flags,
                                 GimpDatafileLoaderFunc  loader_func,
                                 gpointer                user_data)
{
  gchar *local_path;
  GList *path;
  GList *list;

  g_return_if_fail (path_str != NULL);
  g_return_if_fail (loader_func != NULL);

  local_path = g_strdup (path_str);

  path = gimp_path_parse (local_path, 256, TRUE, NULL);

  for (list = path; list; list = g_list_next (list))
    {
      const gchar *dirname = list->data;
      GDir        *dir;

      dir = g_dir_open (dirname, 0, NULL);

      if (dir)
        {
          const gchar *dir_ent;

          while ((dir_ent = g_dir_read_name (dir)))
            {
              struct stat  filestat;
              gchar       *filename;

              if (is_hidden (dir_ent))
                continue;

              filename = g_build_filename (dirname, dir_ent, NULL);

              if (! g_stat (filename, &filestat))
                {
                  GimpDatafileData  file_data;

                  file_data.filename = filename;
                  file_data.dirname  = dirname;
                  file_data.basename = dir_ent;
                  file_data.atime    = filestat.st_atime;
                  file_data.mtime    = filestat.st_mtime;
                  file_data.ctime    = filestat.st_ctime;

                  if (flags & G_FILE_TEST_EXISTS)
                    {
                      (* loader_func) (&file_data, user_data);
                    }
                  else if ((flags & G_FILE_TEST_IS_REGULAR) &&
                           S_ISREG (filestat.st_mode))
                    {
                      (* loader_func) (&file_data, user_data);
                    }
                  else if ((flags & G_FILE_TEST_IS_DIR) &&
                           S_ISDIR (filestat.st_mode))
                    {
                      (* loader_func) (&file_data, user_data);
                    }
#ifndef G_OS_WIN32
                  else if ((flags & G_FILE_TEST_IS_SYMLINK) &&
                           S_ISLNK (filestat.st_mode))
                    {
                      (* loader_func) (&file_data, user_data);
                    }
#endif
                  else if ((flags & G_FILE_TEST_IS_EXECUTABLE) &&
                           (((filestat.st_mode & S_IXUSR) &&
                             !S_ISDIR (filestat.st_mode)) ||
                            (S_ISREG (filestat.st_mode) &&
                             is_script (filename))))
                    {
                      (* loader_func) (&file_data, user_data);
                    }
                }

              g_free (filename);
            }

          g_dir_close (dir);
        }
    }

  gimp_path_free (path);
  g_free (local_path);
}