diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 0f9a3bc4a6..84b3179abb 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -15,6 +15,8 @@ if (is_android) { import("//build/config/mac/rules.gni") } else if (is_ios) { import("//build/config/ios/rules.gni") +} else if (is_linux || is_chromeos) { + import("//build/config/linux/pkg_config.gni") } group("examples") { @@ -660,6 +662,18 @@ if (is_ios || (is_mac && target_cpu != "x86")) { } if (is_linux || is_chromeos || is_win) { + if (is_linux || is_chromeos) { + pkg_config("gtk_config") { + packages = [ + # Gtk requires gmodule, but it does not list it as a dependency in some + # misconfigured systems. + "gmodule-2.0", + "gthread-2.0", + "gtk+-3.0", + ] + } + } + rtc_executable("peerconnection_client") { testonly = true sources = [ @@ -726,7 +740,7 @@ if (is_linux || is_chromeos || is_win) { "Xext", "Xrender", ] - deps += [ "//build/config/linux/gtk" ] + configs += [ ":gtk_config" ] } deps += [ diff --git a/examples/peerconnection/client/linux/main_wnd.cc b/examples/peerconnection/client/linux/main_wnd.cc index e9b6a514b1..2be75d8f8d 100644 --- a/examples/peerconnection/client/linux/main_wnd.cc +++ b/examples/peerconnection/client/linux/main_wnd.cc @@ -264,20 +264,12 @@ void GtkMainWnd::SwitchToConnectUI() { peer_list_ = NULL; } -#if GTK_MAJOR_VERSION == 2 - vbox_ = gtk_vbox_new(FALSE, 5); -#else vbox_ = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); -#endif GtkWidget* valign = gtk_alignment_new(0, 1, 0, 0); gtk_container_add(GTK_CONTAINER(vbox_), valign); gtk_container_add(GTK_CONTAINER(window_), vbox_); -#if GTK_MAJOR_VERSION == 2 - GtkWidget* hbox = gtk_hbox_new(FALSE, 5); -#else GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); -#endif GtkWidget* label = gtk_label_new("Server"); gtk_container_add(GTK_CONTAINER(hbox), label); @@ -386,11 +378,7 @@ void GtkMainWnd::OnClicked(GtkWidget* widget) { void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) { if (key->type == GDK_KEY_PRESS) { switch (key->keyval) { -#if GTK_MAJOR_VERSION == 2 - case GDK_Escape: -#else case GDK_KEY_Escape: -#endif if (draw_area_) { callback_->DisconnectFromCurrentPeer(); } else if (peer_list_) { @@ -398,13 +386,8 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) { } break; -#if GTK_MAJOR_VERSION == 2 - case GDK_KP_Enter: - case GDK_Return: -#else case GDK_KEY_KP_Enter: case GDK_KEY_Return: -#endif if (vbox_) { OnClicked(NULL); } else if (peer_list_) { @@ -490,21 +473,13 @@ void GtkMainWnd::OnRedraw() { } } -#if GTK_MAJOR_VERSION == 2 - gdk_draw_rgb_32_image(draw_area_->window, - draw_area_->style->fg_gc[GTK_STATE_NORMAL], 0, 0, - width_ * 2, height_ * 2, GDK_RGB_DITHER_MAX, - draw_buffer_.get(), (width_ * 2) * 4); -#else gtk_widget_queue_draw(draw_area_); -#endif } gdk_threads_leave(); } void GtkMainWnd::Draw(GtkWidget* widget, cairo_t* cr) { -#if GTK_MAJOR_VERSION != 2 cairo_format_t format = CAIRO_FORMAT_ARGB32; cairo_surface_t* surface = cairo_image_surface_create_for_data( draw_buffer_.get(), format, width_ * 2, height_ * 2, @@ -513,9 +488,6 @@ void GtkMainWnd::Draw(GtkWidget* widget, cairo_t* cr) { cairo_rectangle(cr, 0, 0, width_ * 2, height_ * 2); cairo_fill(cr); cairo_surface_destroy(surface); -#else - RTC_DCHECK_NOTREACHED(); -#endif } GtkMainWnd::VideoRenderer::VideoRenderer(