From faa685b6d7a9118c29a0b08e85096afc35c8b5ae Mon Sep 17 00:00:00 2001 From: jstebbins Date: Wed, 17 Jun 2009 19:19:04 +0000 Subject: LinGui: add preference for update check frequency Options are Never, Daily, Weekly, and Monthly. Default is Weekly. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2561 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 39 +++++++++++++++++++++++++++++++++++++++ gtk/src/ghb.ui | 41 ++++++++++++++++++++++++++++++++++------- gtk/src/hb-backend.c | 15 +++++++++++++++ gtk/src/internal_defaults.xml | 4 +++- gtk/src/main.c | 5 +---- 5 files changed, 92 insertions(+), 12 deletions(-) (limited to 'gtk/src') diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 09a213e57..aa44aef28 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -18,6 +18,7 @@ #include #include #include +#include #if !defined(_WIN32) #include @@ -60,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. @@ -2256,6 +2259,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; } @@ -3487,6 +3521,7 @@ done: g_free(ud->appcast); ud->appcast_len = 0; ud->appcast = NULL; + appcast_busy = FALSE; } void @@ -3544,6 +3579,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; } @@ -3556,12 +3592,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); @@ -3581,6 +3619,7 @@ ghb_check_update(signal_user_data_t *ud) GError *gerror = NULL; g_debug("ghb_check_update"); + appcast_busy = TRUE; if (hb_get_build(NULL) % 100) { query = diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 233d583fd..5e64ed54b 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -3496,16 +3496,42 @@ no-dct-decimate=0:cabac=1 True - + True - True - Check for updates to HandBrake at startup. - Check for Updates - True - + 0 + + + 4 + True + + + True + Frequency to poll for HandBrake updates. + + + + False + 0 + + + + + GTK_JUSTIFY_LEFT + True + Check For Updates + True + + + False + 1 + + + + False + 0 @@ -3610,6 +3636,7 @@ non-hidef screens. 4 + 4 True @@ -3634,7 +3661,7 @@ increases scan duration. GTK_JUSTIFY_LEFT True - Number of previews + Number of previews True diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index ed0d54db0..4a2589c78 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -107,6 +107,19 @@ combo_opts_t logging_opts = d_logging_opts }; +static options_map_t d_appcast_update_opts[] = +{ + {"Never", "never", 0, "never"}, + {"Daily", "daily", 1, "daily"}, + {"Weekly", "weekly", 2, "weekly"}, + {"Monthly", "monthly", 3, "monthly"}, +}; +combo_opts_t appcast_update_opts = +{ + sizeof(d_appcast_update_opts)/sizeof(options_map_t), + d_appcast_update_opts +}; + static options_map_t d_vqual_granularity_opts[] = { {"0.2", "0.2", 0.2, "0.2"}, @@ -322,6 +335,7 @@ combo_name_map_t combo_name_map[] = {"PicturePAR", &par_opts}, {"PictureModulus", &alignment_opts}, {"LoggingLevel", &logging_opts}, + {"check_updates", &appcast_update_opts}, {"VideoQualityGranularity", &vqual_granularity_opts}, {"FileFormat", &container_opts}, {"PictureDeinterlace", &deint_opts}, @@ -2196,6 +2210,7 @@ ghb_update_ui_combo_box( generic_opts_set(ud->builder, "PicturePAR", &par_opts); generic_opts_set(ud->builder, "PictureModulus", &alignment_opts); generic_opts_set(ud->builder, "LoggingLevel", &logging_opts); + generic_opts_set(ud->builder, "check_updates", &appcast_update_opts); generic_opts_set(ud->builder, "FileFormat", &container_opts); generic_opts_set(ud->builder, "PictureDeinterlace", &deint_opts); generic_opts_set(ud->builder, "PictureDetelecine", &detel_opts); diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index e845e59ef..9bb7651a6 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -107,8 +107,10 @@ title_no_in_destination + last_update_check + 0 check_updates - + weekly chapters_in_destination default_source diff --git a/gtk/src/main.c b/gtk/src/main.c index 043c4c6b3..0b3eb09a5 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -783,10 +783,7 @@ main (int argc, char *argv[]) } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); - if (ghb_settings_get_boolean(ud->settings, "check_updates")) - { - g_thread_create((GThreadFunc)ghb_check_update, ud, FALSE, NULL); - } + // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); -- cgit v1.2.3