From 9ec1aea54a4f8e6883f6d85627df66197b7487b4 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 10 Nov 2014 11:14:15 +0000 Subject: [PATCH] Update to work with vte 2.91 as well as 2.90 --- cmake/FindVTE.cmake | 10 ++++++++-- remmina/CMakeLists.txt | 25 +++++++++++++++++-------- remmina/src/remmina_ssh_plugin.c | 22 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/cmake/FindVTE.cmake b/cmake/FindVTE.cmake index cbbe956819..914bd31068 100644 --- a/cmake/FindVTE.cmake +++ b/cmake/FindVTE.cmake @@ -21,11 +21,17 @@ if(NOT _VTE_VERSION_NUM) set(_VTE_LIB_NAME vte) set(_VTE_VERSION vte) else() - set(_VTE_LIB_NAME vte${_VTE_VERSION_NUM}) + if(${_VTE_VERSION_NUM} VERSION_LESS 2.91) + set(_VTE_LIB_NAME vte${_VTE_VERSION_NUM}) + else() + set(_VTE_LIB_NAME vte-${_VTE_VERSION_NUM}) + endif() set(_VTE_VERSION vte-${_VTE_VERSION_NUM}) endif() -string(REPLACE . _ _VTE_LIB_NAME ${_VTE_LIB_NAME}) +if(${_VTE_VERSION_NUM} VERSION_LESS 2.91) + string(REPLACE . _ _VTE_LIB_NAME ${_VTE_LIB_NAME}) +endif() pkg_check_modules(PC_VTE ${_VTE_VERSION}) diff --git a/remmina/CMakeLists.txt b/remmina/CMakeLists.txt index 42f516acc8..e7494f699b 100644 --- a/remmina/CMakeLists.txt +++ b/remmina/CMakeLists.txt @@ -137,17 +137,26 @@ if(AVAHI_FOUND) target_link_libraries(remmina ${AVAHI_LIBRARIES}) endif() -if(GTK3_FOUND) - set(_VTE_VERSION_NUM 2.90) -else() +option(WITH_VTE "Build with support for VTE" ON) +if(GTK3_FOUND AND WITH_VTE) + set(_VTE_VERSION_NUMS 2.91 2.90) + foreach(__VTE_VERSION ${_VTE_VERSION_NUMS}) + set(_VTE_VERSION_NUM ${__VTE_VERSION}) + find_package(VTE) + if(VTE_FOUND) + break() + endif() + message(STATUS "VTE ${__VTE_VERSION} not found") + endforeach(__VTE_VERSION) +elseif(WITH_VTE) set(_VTE_VERSION_NUM) + find_package(VTE) endif() -find_suggested_package(VTE _VTE_VERSION_NUM) -if(VTE_FOUND) - add_definitions(-DHAVE_LIBVTE) - include_directories(${VTE_INCLUDE_DIRS}) - target_link_libraries(remmina ${VTE_LIBRARIES}) +if (VTE_FOUND) + add_definitions(-DHAVE_LIBVTE) + include_directories(${VTE_INCLUDE_DIRS}) + target_link_libraries(remmina ${VTE_LIBRARIES}) endif() if(GTK3_FOUND) diff --git a/remmina/src/remmina_ssh_plugin.c b/remmina/src/remmina_ssh_plugin.c index 43e42d4a64..e1261c65a2 100644 --- a/remmina/src/remmina_ssh_plugin.c +++ b/remmina/src/remmina_ssh_plugin.c @@ -136,9 +136,18 @@ remmina_plugin_ssh_main_thread (gpointer data) THREADS_ENTER if (charset && charset[0] != '\0') { +#if !VTE_CHECK_VERSION(0,38,0) vte_terminal_set_encoding (VTE_TERMINAL (gpdata->vte), charset); +#else + vte_terminal_set_encoding (VTE_TERMINAL (gpdata->vte), charset, NULL); +#endif } +#if !VTE_CHECK_VERSION(0,38,0) vte_terminal_set_pty (VTE_TERMINAL (gpdata->vte), shell->slave); +#else + vte_terminal_set_pty (VTE_TERMINAL (gpdata->vte), + vte_pty_new_foreign_sync (shell->slave, NULL, NULL)); +#endif THREADS_LEAVE remmina_plugin_service->protocol_plugin_emit_signal (gp, "connect"); @@ -183,7 +192,12 @@ remmina_plugin_ssh_set_vte_pref (RemminaProtocolWidget *gp) gpdata = (RemminaPluginSshData*) g_object_get_data (G_OBJECT(gp), "plugin-data"); if (remmina_pref.vte_font && remmina_pref.vte_font[0]) { +#if !VTE_CHECK_VERSION(0,38,0) vte_terminal_set_font_from_string (VTE_TERMINAL (gpdata->vte), remmina_pref.vte_font); +#else + vte_terminal_set_font (VTE_TERMINAL (gpdata->vte), + pango_font_description_from_string (remmina_pref.vte_font)); +#endif } vte_terminal_set_allow_bold (VTE_TERMINAL (gpdata->vte), remmina_pref.vte_allow_bold_text); if (remmina_pref.vte_lines > 0) @@ -224,9 +238,17 @@ remmina_plugin_ssh_init (RemminaProtocolWidget *gp) remmina_plugin_service->protocol_plugin_register_hostkey (gp, vte); #if GTK_VERSION == 3 +#if VTE_CHECK_VERSION(0, 38, 0) + vscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (vte))); +#else vscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, vte_terminal_get_adjustment (VTE_TERMINAL (vte))); +#endif #elif GTK_VERSION == 2 +#if VTE_CHECK_VERSION(0, 38, 0) + vscrollbar = gtk_vscrollbar_new (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE_TERMINAL (vte))); +#else vscrollbar = gtk_vscrollbar_new (vte_terminal_get_adjustment (VTE_TERMINAL (vte))); +#endif #endif gtk_widget_show(vscrollbar); gtk_box_pack_start (GTK_BOX (hbox), vscrollbar, FALSE, TRUE, 0);