summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-06-30 23:53:04 +0000
committerjstebbins <[email protected]>2008-06-30 23:53:04 +0000
commit1b44faba8af642f4892958b464309a94e52c8760 (patch)
tree1050b65785fd2d94a792ddd9a1f3e111d3e0aed9
parent19c8a9d6099bfadbc72bfd9d5c09814597ac3ffe (diff)
LinGui: clean up temporary file turds upon exit
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1546 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/callbacks.c6
-rw-r--r--gtk/src/hb-backend.c37
-rw-r--r--gtk/src/hb-backend.h2
3 files changed, 45 insertions, 0 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 3a16386ea..ce40e2998 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -303,11 +303,13 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud)
{
if (cancel_encode("Closing HandBrake will terminate encoding.\n"))
{
+ ghb_hb_cleanup();
gtk_main_quit();
return;
}
return;
}
+ ghb_hb_cleanup();
gtk_main_quit();
}
@@ -774,6 +776,7 @@ gboolean
window_destroy_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *ud)
{
g_debug("window_destroy_event_cb ()\n");
+ ghb_hb_cleanup();
gtk_main_quit();
return FALSE;
}
@@ -786,11 +789,13 @@ window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *u
{
if (cancel_encode("Closing HandBrake will terminate encoding.\n"))
{
+ ghb_hb_cleanup();
gtk_main_quit();
return FALSE;
}
return TRUE;
}
+ ghb_hb_cleanup();
gtk_main_quit();
return FALSE;
}
@@ -2613,6 +2618,7 @@ ghb_timer_cb(gpointer data)
current_id = -1;
if (ghb_autostart)
{
+ ghb_hb_cleanup();
gtk_main_quit();
}
} break;
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 01f841999..c5c9b6285 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -27,6 +27,7 @@
#include "hb.h"
#include "hbversion.h"
#include <gtk/gtk.h>
+#include <glib/gstdio.h>
#include "hb-backend.h"
#include "settings.h"
#include "callbacks.h"
@@ -407,6 +408,31 @@ static const iso639_lang_t language_table[] =
};
#define LANG_TABLE_SIZE (sizeof(language_table)/ sizeof(iso639_lang_t))
+static void
+del_tree(const gchar *name)
+{
+ const gchar *file;
+
+ if (g_file_test(name, G_FILE_TEST_IS_DIR))
+ {
+ GDir *gdir = g_dir_open(name, 0, NULL);
+ file = g_dir_read_name(gdir);
+ while (file)
+ {
+ gchar *path;
+ path = g_strdup_printf("%s/%s", name, file);
+ del_tree(path);
+ g_free(path);
+ file = g_dir_read_name(gdir);
+ }
+ g_rmdir(name);
+ }
+ else
+ {
+ g_unlink(name);
+ }
+}
+
const gchar*
ghb_version()
{
@@ -462,6 +488,17 @@ get_amix_value(gint val)
// Handle for libhb. Gets set by ghb_backend_init()
static hb_handle_t * h = NULL;
+extern void hb_get_tempory_directory(hb_handle_t *h, char path[512]);
+
+void
+ghb_hb_cleanup()
+{
+ char dir[512];
+
+ hb_get_tempory_directory(h, dir);
+ del_tree(dir);
+}
+
static hb_audio_config_t*
get_hb_audio(gint titleindex, gint track)
{
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 7a2b13aa8..0c8a021a8 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -92,4 +92,6 @@ gint ghb_guess_bitrate(GHashTable *settings);
gboolean ghb_validate_vquality(GHashTable *settings);
gboolean ghb_validate_audio(signal_user_data_t *ud);
gboolean ghb_validate_video(signal_user_data_t *ud);
+void ghb_hb_cleanup();
+
#endif // _HBBACKEND_H_