summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/callbacks.c39
-rw-r--r--gtk/src/ghb.ui41
-rw-r--r--gtk/src/hb-backend.c15
-rw-r--r--gtk/src/internal_defaults.xml4
-rw-r--r--gtk/src/main.c5
5 files changed, 92 insertions, 12 deletions
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 <string.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <time.h>
#if !defined(_WIN32)
#include <poll.h>
@@ -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</property>
<object class="GtkVBox" id="vbox42">
<property name="visible">True</property>
<child>
- <object class="GtkCheckButton" id="check_updates">
+ <object class="GtkAlignment" id="alignment60">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text">Check for updates to HandBrake at startup.</property>
- <property name="label" translatable="yes">Check for Updates</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="pref_changed_cb"/>
+ <property name="left_padding">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox80">
+ <property name="spacing">4</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkComboBox" id="check_updates">
+ <property name="visible">True</property>
+ <property name="tooltip_text">Frequency to poll for HandBrake updates.</property>
+ <signal name="changed" handler="pref_changed_cb"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label74">
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Check For Updates</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
@@ -3610,6 +3636,7 @@ non-hidef screens. </property>
<property name="left_padding">4</property>
<child>
<object class="GtkHBox" id="hbox66">
+ <property name="spacing">4</property>
<property name="visible">True</property>
<child>
<object class="GtkSpinButton" id="preview_count">
@@ -3634,7 +3661,7 @@ increases scan duration.</property>
<object class="GtkLabel" id="label77">
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="visible">True</property>
- <property name="label" translatable="yes"> Number of previews </property>
+ <property name="label" translatable="yes">Number of previews</property>
<property name="use_markup">True</property>
</object>
<packing>
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 @@
<false />
<key>title_no_in_destination</key>
<false />
+ <key>last_update_check</key>
+ <integer>0</integer>
<key>check_updates</key>
- <true />
+ <string>weekly</string>
<key>chapters_in_destination</key>
<false />
<key>default_source</key>
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);