void
delete_custom_theme_dir (void)
{
        char *dir;
        GFile *file;

        dir = custom_theme_dir_path (NULL);
        file = g_file_new_for_path (dir);
        g_free (dir);
        capplet_file_delete_recursive (file, NULL);
        g_object_unref (file);

        g_debug ("deleted the custom theme dir");
}
static void
delete_one_file (const char *sound_name, const char *pattern)
{
        GFile *file;
        char *name, *filename;

        name = g_strdup_printf (pattern, sound_name);
        filename = custom_theme_dir_path (name);
        g_free (name);
        file = g_file_new_for_path (filename);
        g_free (filename);
        capplet_file_delete_recursive (file, NULL);
        g_object_unref (file);
}
Ejemplo n.º 3
0
gboolean theme_delete (const gchar *name, ThemeType type)
{
  gboolean rc;
  GtkDialog *dialog;
  gchar *theme_dir;
  gint response;
  MateThemeCommonInfo *theme;
  GFile *dir;
  gboolean del_empty_parent;

  dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
						 GTK_DIALOG_MODAL,
						 GTK_MESSAGE_QUESTION,
						 GTK_BUTTONS_CANCEL,
						 _("Would you like to delete this theme?"));
#if GTK_CHECK_VERSION (3, 10, 0)
  gtk_dialog_add_button (dialog, _("_Delete"), GTK_RESPONSE_ACCEPT);
#else
  gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
#endif
  response = gtk_dialog_run (dialog);
  gtk_widget_destroy (GTK_WIDGET (dialog));
  if (response != GTK_RESPONSE_ACCEPT)
    return FALSE;

  /* Most theme types are put into separate subdirectories. For those
     we want to delete those directories as well. */
  del_empty_parent = TRUE;

  switch (type) {
    case THEME_TYPE_GTK:
      theme = (MateThemeCommonInfo *) mate_theme_info_find (name);
      theme_dir = g_build_filename (theme->path, "gtk-2.0", NULL);
      break;

    case THEME_TYPE_ICON:
      theme = (MateThemeCommonInfo *) mate_theme_icon_info_find (name);
      theme_dir = g_path_get_dirname (theme->path);
      del_empty_parent = FALSE;
      break;

    case THEME_TYPE_WINDOW:
      theme = (MateThemeCommonInfo *) mate_theme_info_find (name);
      theme_dir = g_build_filename (theme->path, "marco-1", NULL);
      break;

    case THEME_TYPE_META:
      theme = (MateThemeCommonInfo *) mate_theme_meta_info_find (name);
      theme_dir = g_strdup (theme->path);
      break;

    case THEME_TYPE_CURSOR:
      theme = (MateThemeCommonInfo *) mate_theme_cursor_info_find (name);
      theme_dir = g_build_filename (theme->path, "cursors", NULL);
      break;

    default:
      return FALSE;
  }

  dir = g_file_new_for_path (theme_dir);
  g_free (theme_dir);

  if (!capplet_file_delete_recursive (dir, NULL)) {
    GtkWidget *info_dialog = gtk_message_dialog_new (NULL,
						     GTK_DIALOG_MODAL,
						     GTK_MESSAGE_ERROR,
						     GTK_BUTTONS_OK,
						     _("Theme cannot be deleted"));
    gtk_dialog_run (GTK_DIALOG (info_dialog));
    gtk_widget_destroy (info_dialog);
    rc = FALSE;
  } else {
    if (del_empty_parent) {
      /* also delete empty parent directories */
      GFile *parent = g_file_get_parent (dir);
      g_file_delete (parent, NULL, NULL);
      g_object_unref (parent);
    }
    rc = TRUE;
  }

  g_object_unref (dir);
  return rc;
}