X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fmain.c;h=6d0d81441808bbed31ea64dc93d8d8e1f8837aa6;hb=0884cb45aeeb60a46effe1d1056a61fe68300ea7;hp=fc52e2a1aea1fc5fe89691542ac0bf1eb810fc68;hpb=0ded29a1ddbc331774314e5407a322e8f059538b;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/main.c b/gtk/src/main.c index fc52e2a1..6d0d8144 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -37,10 +37,10 @@ #if !defined(_WIN32) #include #include +#include #else #include #include -//#include #define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) #endif @@ -521,6 +521,7 @@ bind_presets_tree_model (signal_user_data_t *ud) static void clean_old_logs() { +#if !defined(_WIN32) const gchar *file; gchar *config; @@ -543,7 +544,7 @@ clean_old_logs() path = g_strdup_printf("%s/ghb.pid.%d", config, pid); if (g_file_test(path, G_FILE_TEST_EXISTS)) { - fd = g_open(path, O_RDWR); + fd = open(path, O_RDWR); if (fd >= 0) { lock = lockf(fd, F_TLOCK, 0); @@ -570,6 +571,60 @@ clean_old_logs() g_dir_close(gdir); } g_free(config); +#else + const gchar *file; + gchar *config; + + config = ghb_get_user_config_dir(NULL); + + if (g_file_test(config, G_FILE_TEST_IS_DIR)) + { + GDir *gdir = g_dir_open(config, 0, NULL); + file = g_dir_read_name(gdir); + while (file) + { + if (strncmp(file, "Activity.log.", 13) == 0) + { + gchar *path; + int pid; + + sscanf(file, "Activity.log.%d", &pid); + +#if 0 + int fd, lock = 1; + + path = g_strdup_printf("%s/ghb.pid.%d", config, pid); + if (g_file_test(path, G_FILE_TEST_EXISTS)) + { + fd = open(path, O_RDWR); + if (fd >= 0) + { + lock = lockf(fd, F_TLOCK, 0); + } + g_free(path); + close(fd); + if (lock == 0) + { + path = g_strdup_printf("%s/%s", config, file); + g_unlink(path); + g_free(path); + } + } + else +#endif + { + //g_free(path); + path = g_strdup_printf("%s/%s", config, file); + g_unlink(path); + g_free(path); + } + } + file = g_dir_read_name(gdir); + } + g_dir_close(gdir); + } + g_free(config); +#endif } static void @@ -603,7 +658,12 @@ IoRedirect(signal_user_data_t *ud) // Set encoding to raw. g_io_channel_set_encoding (ud->activity_log, NULL, NULL); // redirect stderr to the writer end of the pipe +#if defined(_WIN32) + // dup2 doesn't work on windows for some stupid reason + stderr->_file = pfd[1]; +#else dup2(pfd[1], /*stderr*/2); +#endif setvbuf(stderr, NULL, _IONBF, 0); channel = g_io_channel_unix_new (pfd[0]); // I was getting an this error: @@ -722,11 +782,6 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); #endif -#ifdef PTW32_STATIC_LIB - pthread_win32_process_attach_np(); - pthread_win32_thread_attach_np(); -#endif - if (!g_thread_supported()) g_thread_init(NULL); context = g_option_context_new ("- Rip and encode DVD or MPEG file"); @@ -751,8 +806,9 @@ main (int argc, char *argv[]) ghb_load_icons(); #if !defined(_WIN32) - ghb_hal_init(); + dbus_g_thread_init(); #endif + ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); @@ -771,6 +827,11 @@ main (int argc, char *argv[]) // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; +#if defined(_NO_UPDATE_CHECK) + widget = GHB_WIDGET(ud->builder, "check_updates_box"); + gtk_widget_hide(widget); +#endif + widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); @@ -921,9 +982,6 @@ main (int argc, char *argv[]) notify_uninit(); #endif g_free(ud); -#ifdef PTW32_STATIC_LIB - pthread_win32_thread_detach_np(); - pthread_win32_process_detach_np(); -#endif + return 0; }