From: John Stebbins Date: Tue, 7 Nov 2017 15:48:44 +0000 (-0800) Subject: LinGui: fix build with glib older than 2.44 X-Git-Tag: 1.1.0~318 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05b36baaa192c3bbbc0ccf4eb10acae887c6b0a1;p=handbrake LinGui: fix build with glib older than 2.44 --- diff --git a/gtk/src/ghbcompat.h b/gtk/src/ghbcompat.h index cb27f307b..17cb125e2 100644 --- a/gtk/src/ghbcompat.h +++ b/gtk/src/ghbcompat.h @@ -26,6 +26,7 @@ #include #include +#include static inline PangoFontDescription* ghb_widget_get_font(GtkWidget *widget) { @@ -83,6 +84,28 @@ static inline void ghb_monitor_get_size(GdkWindow *window, gint *w, gint *h) #endif } +static inline gboolean ghb_strv_contains(const char ** strv, const char * str) +{ +#if GLIB_CHECK_VERSION(2, 44, 0) + return g_strv_contains(strv, str); +#else + int ii; + + if (strv == NULL) + { + return FALSE; + } + for (ii = 0; strv[ii] != NULL; ii++) + { + if (!strcmp(strv[ii], str)) + { + return TRUE; + } + } + return FALSE; +#endif +} + #if !GTK_CHECK_VERSION(3, 10, 0) #define gtk_image_set_from_icon_name gtk_image_set_from_stock #define GHB_PLAY_ICON "gtk-media-play" diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 3f7b1fd68..c2a2e556e 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -1945,7 +1945,7 @@ preset_category_opts_set(signal_user_data_t *ud, const gchar *name, continue; } - if (g_strv_contains((const char**)categories, name)) + if (ghb_strv_contains((const char**)categories, name)) { // Category is already in the list continue; diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 31fa26d7c..89e6cb8f2 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -1237,7 +1237,7 @@ ghb_presets_menu_init(signal_user_data_t *ud) free(detail_action); } if (type == 1 && - g_strv_contains((const char**)official_names, folder_name)) + ghb_strv_contains((const char**)official_names, folder_name)) { menu_item_name = g_strdup_printf("My %s", folder_name); }