OSDN Git Service

LinGui: fix more mingw breakage
[handbrake-jp/handbrake-jp-git.git] / gtk / src / callbacks.c
index f2d9642..8fd2b7a 100644 (file)
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <time.h>
 
 #if !defined(_WIN32)
 #include <poll.h>
@@ -27,7 +28,7 @@
 
 #include <netinet/in.h>
 #include <netdb.h>
-#include <gtkhtml/gtkhtml.h>
+#include <webkit/webkit.h>
 #include <libnotify/notify.h>
 #else
 #define WINVER 0x0500
@@ -44,6 +45,7 @@
 #include "callbacks.h"
 #include "queuehandler.h"
 #include "audiohandler.h"
+#include "subtitlehandler.h"
 #include "resources.h"
 #include "settings.h"
 #include "presets.h"
@@ -59,6 +61,8 @@ static void update_chapter_list(signal_user_data_t *ud);
 static GList* dvd_device_list();
 static void prune_logs(signal_user_data_t *ud);
 void ghb_notify_done(signal_user_data_t *ud);
+gpointer ghb_check_update(signal_user_data_t *ud);
+static gboolean appcast_busy = FALSE;
 
 // This is a dependency map used for greying widgets
 // that are dependent on the state of another widget.
@@ -361,47 +365,70 @@ get_dvd_device_name(GDrive *gd)
 }
 #endif
 
+static GHashTable *volname_hash = NULL;
+static GMutex     *volname_mutex = NULL;
+
+static void
+free_volname_key(gpointer data)
+{
+       if (data != NULL)
+               g_free(data);
+}
+
+static void
+free_volname_value(gpointer data)
+{
+       if (data != NULL)
+               g_free(data);
+}
+
 #if defined(_WIN32)
 static gchar*
-get_dvd_volume_name(const gchar *drive)
+get_direct_dvd_volume_name(const gchar *drive)
 {
-       gchar *result;
+       gchar *result = NULL;
        gchar vname[51], fsname[51];
+
        if (GetVolumeInformation(drive, vname, 50, NULL, NULL, NULL, fsname, 51))
        {
-               result = g_strdup_printf("%s (%s)", vname, drive);
-       }
-       else
-       {
-               result = g_strdup_printf("%s", drive);
+               result = g_strdup_printf("%s", vname);
        }
        return result;
 }
 #else
 static gchar*
-get_dvd_volume_name(GDrive *gd)
+get_direct_dvd_volume_name(const gchar *drive)
+{
+       gchar *result;
+
+       result = ghb_dvd_volname (drive);
+       return result;
+}
+#endif
+
+static gchar*
+get_dvd_volume_name(gpointer gd)
 {
-       gchar *label;
+       gchar *label = NULL;
        gchar *result;
        gchar *drive;
 
-       drive = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
-       if (g_drive_has_media (gd))
+       drive = get_dvd_device_name(gd);
+       g_mutex_lock(volname_mutex);
+       label = g_strdup(g_hash_table_lookup(volname_hash, drive));
+       g_mutex_unlock(volname_mutex);
+       if (label != NULL)
        {
-               label = ghb_dvd_volname (drive);
-               if (label != NULL)
+               if (uppers_and_unders(label))
                {
-                       if (uppers_and_unders(label))
-                       {
-                               camel_convert(label);
-                       }
-                       result = g_strdup_printf("%s - %s", drive, label);
-                       g_free(label);
-               }
-               else
-               {
-                       result = g_strdup_printf("%s", drive);
+                       camel_convert(label);
                }
+#if defined(_WIN32)
+               result = g_strdup_printf("%s (%s)", label, drive);
+#else
+               result = g_strdup_printf("%s - %s", drive, label);
+#endif
+               g_free(label);
        }
        else
        {
@@ -410,8 +437,75 @@ get_dvd_volume_name(GDrive *gd)
        g_free(drive);
        return result;
 }
+
+void
+ghb_volname_cache_init(void)
+{
+       volname_mutex = g_mutex_new();
+       volname_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                                                               free_volname_key, free_volname_value);
+}
+
+static void
+free_drive(gpointer drive)
+{
+#if defined(_WIN32)
+               g_free(drive);
+#else
+               g_object_unref(drive);
+#endif
+}
+
+gpointer
+ghb_cache_volnames(signal_user_data_t *ud)
+{
+       GList *link, *drives;
+
+       g_debug("ghb_cache_volnames()");
+       link = drives = dvd_device_list();
+       if (drives == NULL)
+               return NULL;
+
+       g_mutex_lock(volname_mutex);
+       g_hash_table_remove_all(volname_hash);
+       while (link != NULL)
+       {
+               gchar *name, *drive;
+
+#if !defined(_WIN32)
+               if (!g_drive_has_media (link->data))
+               {
+                       g_object_unref(link->data);
+                       link = link->next;
+                       continue;
+               }
 #endif
+               drive = get_dvd_device_name(link->data);
+               name = get_direct_dvd_volume_name(drive);
+
+               if (drive != NULL && name != NULL)
+               {
+                       g_hash_table_insert(volname_hash, drive, name);
+               }
+               else
+               {
+                       if (drive != NULL)
+                               g_free(drive);
+                       if (name != NULL)
+                               g_free(name);
+               }
+       
+               free_drive(link->data);
+               link = link->next;
+       }
+       g_mutex_unlock(volname_mutex);
+
+       g_list_free(drives);
+
+       g_idle_add((GSourceFunc)ghb_file_menu_add_dvd, ud);
 
+       return NULL;
+}
 
 static void
 set_destination(signal_user_data_t *ud)
@@ -713,7 +807,7 @@ source_dialog_extra_widgets(
                gchar *name = get_dvd_device_name(link->data);
                gtk_combo_box_append_text(combo, name);
                g_free(name);
-               g_object_unref(link->data);
+               free_drive(link->data);
                link = link->next;
        }
        g_list_free(drives);
@@ -739,6 +833,7 @@ ghb_do_scan(
                        jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
                        ghb_settings_to_ui(ud, ghb_queue_edit_settings);
                        ghb_set_audio(ud, ghb_queue_edit_settings);
+                       ghb_reset_subtitles(ud, ghb_queue_edit_settings);
                        if (jstatus == GHB_QUEUE_PENDING)
                        {
                                ghb_value_free(ghb_queue_edit_settings);
@@ -1118,6 +1213,7 @@ container_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                }
                g_free(container);
        }
+       ghb_subtitle_prune(ud);
 }
 
 static gchar*
@@ -1254,10 +1350,9 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        ghb_check_dependency(ud, widget);
 
        titleindex = ghb_settings_combo_int(ud->settings, "title");
-       ghb_update_ui_combo_box (ud->builder, "AudioTrack", titleindex, FALSE);
-       ghb_update_ui_combo_box (ud->builder, "Subtitles", titleindex, FALSE);
+       ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
+       ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
 
-       ghb_update_from_preset(ud, "Subtitles");
        if (ghb_get_title_info (&tinfo, titleindex))
        {
                show_title_info(ud, &tinfo);
@@ -1265,6 +1360,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        update_chapter_list (ud);
        ghb_adjust_audio_rate_combos(ud);
        ghb_set_pref_audio(titleindex, ud);
+       ghb_set_pref_subtitle(titleindex, ud);
        if (ghb_settings_get_boolean(ud->settings, "vquality_type_target"))
        {
                gint bitrate = ghb_calculate_target_bitrate (ud->settings, titleindex);
@@ -1545,22 +1641,10 @@ display_width_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        if (GTK_WIDGET_SENSITIVE(widget))
                ghb_set_scale (ud, GHB_PIC_KEEP_DISPLAY_WIDTH);
 
-       gint pic_par;
-
-       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
-       if (pic_par == 3)
-       {
-               gint par_width, par_height;
-
-               par_width = ghb_settings_get_int(ud->settings, "par_width");
-               par_height = ghb_settings_get_int(ud->settings, "par_height");
-               ghb_settings_set_int(ud->settings, "PicturePARWidth", par_width);
-               ghb_settings_set_int(ud->settings, "PicturePARHeight", par_height);
-       }
        update_preview = TRUE;
 }
 
-void
+G_MODULE_EXPORT void
 display_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("display_height_changed_cb ()");
@@ -1571,22 +1655,24 @@ display_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        if (GTK_WIDGET_SENSITIVE(widget))
                ghb_set_scale (ud, GHB_PIC_KEEP_DISPLAY_HEIGHT);
 
-       gint pic_par;
+       update_preview = TRUE;
+}
 
-       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
-       if (pic_par == 3)
-       {
-               gint par_width, par_height;
+G_MODULE_EXPORT void
+par_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("par_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_PAR);
 
-               par_width = ghb_settings_get_int(ud->settings, "par_width");
-               par_height = ghb_settings_get_int(ud->settings, "par_height");
-               ghb_settings_set_int(ud->settings, "PicturePARWidth", par_width);
-               ghb_settings_set_int(ud->settings, "PicturePARHeight", par_height);
-       }
        update_preview = TRUE;
 }
 
-void
+G_MODULE_EXPORT void
 scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("scale_changed_cb ()");
@@ -1629,6 +1715,18 @@ scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 }
 
 G_MODULE_EXPORT void
+show_crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("show_crop_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, 0);
+       update_preview = TRUE;
+}
+
+G_MODULE_EXPORT void
 generic_entry_changed_cb(GtkEntry *entry, signal_user_data_t *ud)
 {
        // Normally (due to user input) I only want to process the entry
@@ -2019,7 +2117,7 @@ ghb_backend_events(signal_user_data_t *ud)
 
                ghb_title_info_t tinfo;
                        
-               ghb_update_ui_combo_box(ud->builder, "title", 0, FALSE);
+               ghb_update_ui_combo_box(ud, "title", 0, FALSE);
                titleindex = ghb_longest_title();
                ghb_ui_update(ud, "title", ghb_int64_value(titleindex));
 
@@ -2040,6 +2138,7 @@ ghb_backend_events(signal_user_data_t *ud)
                        jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
                        ghb_settings_to_ui(ud, ghb_queue_edit_settings);
                        ghb_set_audio(ud, ghb_queue_edit_settings);
+                       ghb_reset_subtitles(ud, ghb_queue_edit_settings);
                        if (jstatus == GHB_QUEUE_PENDING)
                        {
                                ghb_value_free(ghb_queue_edit_settings);
@@ -2146,6 +2245,12 @@ ghb_backend_events(signal_user_data_t *ud)
                        ghb_settings_set_int(js, "job_status", qstatus);
                ghb_save_queue(ud->queue);
                ud->cancel_encode = FALSE;
+#if !GTK_CHECK_VERSION(2, 16, 0)
+               GtkStatusIcon *si;
+
+               si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+               gtk_status_icon_set_tooltip(si, "HandBrake");
+#endif
        }
        else if (status.queue.state & GHB_STATE_MUXING)
        {
@@ -2192,6 +2297,12 @@ ghb_backend_events(signal_user_data_t *ud)
                status_str = working_status_string(ud, &status.queue);
                label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status"));
                gtk_label_set_text (label, status_str);
+#if !GTK_CHECK_VERSION(2, 16, 0)
+               GtkStatusIcon *si;
+
+               si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+               gtk_status_icon_set_tooltip(si, status_str);
+#endif
                g_free(status_str);
        }
        if (status.scan.state & GHB_STATE_WORKING)
@@ -2221,6 +2332,34 @@ ghb_backend_events(signal_user_data_t *ud)
        }
 }
 
+#if GTK_CHECK_VERSION(2, 16, 0)
+G_MODULE_EXPORT gboolean
+status_icon_query_tooltip_cb(
+       GtkStatusIcon *si,
+       gint           x,
+       gint           y,
+       gboolean       kbd_mode,
+       GtkTooltip    *tt,
+       signal_user_data_t *ud)
+{
+       ghb_status_t status;
+       gchar *status_str;
+
+       ghb_get_status(&status);
+       if (status.queue.state & GHB_STATE_WORKING)
+               status_str = working_status_string(ud, &status.queue);
+       else if (status.queue.state & GHB_STATE_WORKDONE)
+               status_str = g_strdup("Encode Complete");
+       else
+               status_str = g_strdup("HandBrake");
+
+       gtk_tooltip_set_text(tt, status_str);
+       gtk_tooltip_set_icon_from_icon_name(tt, "hb-icon", GTK_ICON_SIZE_BUTTON);
+       g_free(status_str);
+       return TRUE;
+}
+#endif
+
 G_MODULE_EXPORT gboolean
 ghb_timer_cb(gpointer data)
 {
@@ -2250,6 +2389,37 @@ ghb_timer_cb(gpointer data)
                ghb_set_preview_image (ud);
                update_preview = FALSE;
        }
+
+       if (!appcast_busy)
+       {
+               gchar *updates;
+               updates = ghb_settings_get_string(ud->settings, "check_updates");
+               gint64 duration = 0;
+               if (strcmp(updates, "daily") == 0)
+                       duration = 60 * 60 * 24;
+               else if (strcmp(updates, "weekly") == 0)
+                       duration = 60 * 60 * 24 * 7;
+               else if (strcmp(updates, "monthly") == 0)
+                       duration = 60 * 60 * 24 * 7;
+
+               g_free(updates);
+               if (duration != 0)
+               {
+                       gint64 last;
+                       time_t tt;
+
+                       last = ghb_settings_get_int64(ud->settings, "last_update_check");
+                       time(&tt);
+                       if (last + duration < tt)
+                       {
+                               ghb_settings_set_int64(ud->settings, 
+                                                                               "last_update_check", tt);
+                               ghb_pref_save(ud->settings, "last_update_check");
+                               g_thread_create((GThreadFunc)ghb_check_update, ud, 
+                                                               FALSE, NULL);
+                       }
+               }
+       }
        return TRUE;
 }
 
@@ -2396,7 +2566,7 @@ ghb_log(gchar *log, ...)
 
        _now = time(NULL);
        now = localtime( &_now );
-       snprintf(fmt, 362, "[%02d:%02d:%02d] lingui: %s\n", 
+       snprintf(fmt, 362, "[%02d:%02d:%02d] gtkgui: %s\n", 
                        now->tm_hour, now->tm_min, now->tm_sec, log);
        va_start(args, log);
        vfprintf(stderr, fmt, args);
@@ -2752,6 +2922,21 @@ pref_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 }
 
 G_MODULE_EXPORT void
+skip_taskbar_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("pref_changed_cb");
+       ghb_widget_to_setting (ud->settings, widget);
+       ghb_check_dependency(ud, widget);
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+
+       GtkWindow *window;
+       window = GTK_WINDOW(GHB_WIDGET (ud->builder, "hb_window"));
+       gtk_window_set_skip_taskbar_hint(window, 
+                       ghb_settings_get_boolean(ud->settings, "skip_taskbar"));
+}
+
+G_MODULE_EXPORT void
 vqual_granularity_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("vqual_granularity_changed_cb");
@@ -2806,6 +2991,7 @@ ghb_file_menu_add_dvd(signal_user_data_t *ud)
        static GtkActionGroup *agroup = NULL;
        static gint merge_id;
 
+       g_debug("ghb_file_menu_add_dvd()");
        link = drives = dvd_device_list();
        if (drives != NULL)
        {
@@ -2852,7 +3038,7 @@ ghb_file_menu_add_dvd(signal_user_data_t *ud)
                                (GCallback)dvd_source_activate_cb, ud);
                        g_free(name);
                        g_free(drive);
-                       g_object_unref(link->data);
+                       free_drive(link->data);
                        link = link->next;
                }
                g_list_free(drives);
@@ -2958,7 +3144,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud
                ins_count++;
                if (ins_count == 2)
                {
-                       ghb_file_menu_add_dvd(ud);
+                       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
                        if (ud->current_dvd_device != NULL &&
                                strcmp(device, ud->current_dvd_device) == 0)
                        {
@@ -2979,7 +3165,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud
                rem_count++;
                if (rem_count == 2)
                {
-                       ghb_file_menu_add_dvd(ud);
+                       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
                        if (ud->current_dvd_device != NULL &&
                                strcmp(device, ud->current_dvd_device) == 0)
                        {
@@ -3053,7 +3239,7 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud)
        gint state;
 
        g_debug("drive_changed_cb()");
-       ghb_file_menu_add_dvd(ud);
+       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
 
        state = ghb_get_scan_state();
        device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
@@ -3116,7 +3302,7 @@ ghb_inhibit_gpm()
        conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
        if (error != NULL)
        {
-               g_debug("DBUS cannot connect: %s", error->message);
+               g_warning("DBUS cannot connect: %s", error->message);
                g_error_free(error);
                return;
        }
@@ -3124,7 +3310,7 @@ ghb_inhibit_gpm()
                                                        GPM_DBUS_INHIBIT_PATH, GPM_DBUS_INHIBIT_INTERFACE);
        if (proxy == NULL)
        {
-               g_debug("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
                dbus_g_connection_unref(conn);
                return;
        }
@@ -3134,18 +3320,20 @@ ghb_inhibit_gpm()
                                                        G_TYPE_INVALID,
                                                        G_TYPE_UINT, &gpm_cookie,
                                                        G_TYPE_INVALID);
+       gpm_inhibited = TRUE;
        if (!res)
        {
-               g_warning("Inhibit method failed");
-               gpm_cookie = -1;
-       }
-       if (error != NULL)
-       {
-               g_warning("Inhibit problem: %s", error->message);
-               g_error_free(error);
+               if (error != NULL)
+               {
+                       g_warning("Inhibit failed: %s", error->message);
+                       g_error_free(error);
+                       gpm_cookie = -1;
+               }
+               else
+                       g_warning("Inhibit failed");
                gpm_cookie = -1;
+               gpm_inhibited = FALSE;
        }
-       gpm_inhibited = TRUE;
        g_object_unref(G_OBJECT(proxy));
        dbus_g_connection_unref(conn);
 #endif
@@ -3170,7 +3358,7 @@ ghb_uninhibit_gpm()
        conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
        if (error != NULL)
        {
-               g_debug("DBUS cannot connect: %s", error->message);
+               g_warning("DBUS cannot connect: %s", error->message);
                g_error_free(error);
                return;
        }
@@ -3178,7 +3366,7 @@ ghb_uninhibit_gpm()
                                                        GPM_DBUS_INHIBIT_PATH, GPM_DBUS_INHIBIT_INTERFACE);
        if (proxy == NULL)
        {
-               g_debug("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SERVICE);
                dbus_g_connection_unref(conn);
                return;
        }
@@ -3188,12 +3376,13 @@ ghb_uninhibit_gpm()
                                                        G_TYPE_INVALID);
        if (!res)
        {
-               g_warning("UnInhibit method failed");
-       }
-       if (error != NULL)
-       {
-               g_warning("UnInhibit problem: %s", error->message);
-               g_error_free(error);
+               if (error != NULL)
+               {
+                       g_warning("UnInhibit failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("UnInhibit failed");
        }
        gpm_inhibited = FALSE;
        dbus_g_connection_unref(conn);
@@ -3391,7 +3580,6 @@ format_vquality_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
                                return g_strdup_printf("QP: %.4g (%.0f%%)", val, percent);
                } break;
 
-               case HB_VCODEC_XVID:
                case HB_VCODEC_FFMPEG:
                {
                        percent = 100. * (30 - (val - 1)) / 30.;
@@ -3412,23 +3600,13 @@ format_vquality_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
        return g_strdup_printf("QP: %.1f / %.1f%%", val, percent);
 }
 
-#if !defined(_WIN32)
-G_MODULE_EXPORT void
-html_link_cb(GtkHTML *html, const gchar *url, signal_user_data_t *ud)
-{
-       browse_url(url);
-}
-#endif
-
-static gpointer check_stable_update(signal_user_data_t *ud);
-static gboolean stable_update_lock = FALSE;
-
 static void
 process_appcast(signal_user_data_t *ud)
 {
        gchar *description = NULL, *build = NULL, *version = NULL, *msg;
 #if !defined(_WIN32)
-       GtkWidget *html, *window;
+       GtkWidget *window;
+       static GtkWidget *html = NULL;
 #endif
        GtkWidget *dialog, *label;
        gint    response, ibuild = 0, skip;
@@ -3436,8 +3614,6 @@ process_appcast(signal_user_data_t *ud)
        if (ud->appcast == NULL || ud->appcast_len < 15 || 
                strncmp(&(ud->appcast[9]), "200 OK", 6))
        {
-               if (!stable_update_lock && hb_get_build(NULL) % 100)
-                       g_idle_add((GSourceFunc)check_stable_update, ud);
                goto done;
        }
        ghb_appcast_parse(ud->appcast, &description, &build, &version);
@@ -3447,29 +3623,28 @@ process_appcast(signal_user_data_t *ud)
        if (description == NULL || build == NULL || version == NULL 
                || ibuild <= hb_get_build(NULL) || skip == ibuild)
        {
-               if (!stable_update_lock && hb_get_build(NULL) % 100)
-                       g_thread_create((GThreadFunc)check_stable_update, ud, FALSE, NULL);
                goto done;
        }
        msg = g_strdup_printf("HandBrake %s/%s is now available (you have %s/%d).",
                        version, build, hb_get_version(NULL), hb_get_build(NULL));
        label = GHB_WIDGET(ud->builder, "update_message");
        gtk_label_set_text(GTK_LABEL(label), msg);
+
 #if !defined(_WIN32)
-       html = gtk_html_new_from_string(description, -1);
-       g_signal_connect(html, "link_clicked", G_CALLBACK(html_link_cb), ud);
-       window = GHB_WIDGET(ud->builder, "update_scroll");
-       gtk_container_add(GTK_CONTAINER(window), html);
-       // Show it
-       gtk_widget_set_size_request(html, 420, 240);
-       gtk_widget_show(html);
+       if (html == NULL)
+       {
+               html = webkit_web_view_new();
+               window = GHB_WIDGET(ud->builder, "update_scroll");
+               gtk_container_add(GTK_CONTAINER(window), html);
+               // Show it
+               gtk_widget_set_size_request(html, 420, 240);
+               gtk_widget_show(html);
+       }
+       webkit_web_view_open(WEBKIT_WEB_VIEW(html), description);
 #endif
        dialog = GHB_WIDGET(ud->builder, "update_dialog");
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
-#if !defined(_WIN32)
-       gtk_widget_destroy(html);
-#endif
        if (response == GTK_RESPONSE_OK)
        {
                // Skip
@@ -3485,6 +3660,7 @@ done:
        g_free(ud->appcast);
        ud->appcast_len = 0;
        ud->appcast = NULL;
+       appcast_busy = FALSE;
 }
 
 void
@@ -3542,6 +3718,7 @@ ghb_net_open(signal_user_data_t *ud, gchar *address, gint port)
        if( !( host = gethostbyname( address ) ) )
        {
                g_warning( "gethostbyname failed (%s)", address );
+               appcast_busy = FALSE;
                return NULL;
        }
 
@@ -3554,12 +3731,14 @@ ghb_net_open(signal_user_data_t *ud, gchar *address, gint port)
        if( fd < 0 )
        {
                g_debug( "socket failed" );
+               appcast_busy = FALSE;
                return NULL;
        }
 
        if(connect(fd, (struct sockaddr*)&sock, sizeof(struct sockaddr_in )) < 0 )
        {
                g_debug( "connect failed" );
+               appcast_busy = FALSE;
                return NULL;
        }
        ioc = g_io_channel_unix_new(fd);
@@ -3577,48 +3756,38 @@ ghb_check_update(signal_user_data_t *ud)
        gsize len;
        GIOChannel *ioc;
        GError *gerror = NULL;
+       GRegex *regex;
+       GMatchInfo *mi;
+       gchar *host, *appcast;
 
        g_debug("ghb_check_update");
-       if (hb_get_build(NULL) % 100)
-       {
-               query = 
-               "GET /appcast_unstable.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-       }
-       else
+       appcast_busy = TRUE;
+       regex = g_regex_new("^http://(.+)/(.+)$", 0, 0, NULL);
+       if (!g_regex_match(regex, HB_PROJECT_URL_APPCAST, 0, &mi))
        {
-               stable_update_lock = TRUE;
-               query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-       }
-       ioc = ghb_net_open(ud, "handbrake.fr", 80);
-       if (ioc == NULL)
                return NULL;
+       }
 
-       g_io_channel_write_chars(ioc, query, strlen(query), &len, &gerror);
-       g_io_channel_flush(ioc, &gerror);
-       // This function is initiated by g_idle_add.  Must return false
-       // so that it is not called again
-       return NULL;
-}
+       host = g_match_info_fetch(mi, 1);
+       appcast = g_match_info_fetch(mi, 2);
 
-static gpointer
-check_stable_update(signal_user_data_t *ud)
-{
-       gchar *query;
-       gsize len;
-       GIOChannel *ioc;
-       GError *gerror = NULL;
+       if (host == NULL || appcast == NULL)
+               return NULL;
+
+       query = g_strdup_printf( "GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
+                                                       appcast, host);
 
-       g_debug("check_stable_update");
-       stable_update_lock = TRUE;
-       query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-       ioc = ghb_net_open(ud, "handbrake.fr", 80);
+       ioc = ghb_net_open(ud, host, 80);
        if (ioc == NULL)
                return NULL;
 
        g_io_channel_write_chars(ioc, query, strlen(query), &len, &gerror);
        g_io_channel_flush(ioc, &gerror);
-       // This function is initiated by g_idle_add.  Must return false
-       // so that it is not called again
+       g_free(query);
+       g_free(host);
+       g_free(appcast);
+       g_match_info_free(mi);
+       g_regex_unref(regex);
        return NULL;
 }
 
@@ -3645,7 +3814,6 @@ ghb_notify_done(signal_user_data_t *ud)
        GtkStatusIcon *si;
 
        si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
-       gtk_status_icon_set_from_icon_name(si, "hb-status-empty");
 
 #if !defined(_WIN32)
        NotifyNotification *notification;