linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: port perf ui from GTK 2 to GTK 3
@ 2022-04-15  5:00 Matt Turner
  2022-04-16 14:55 ` Ian Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Matt Turner @ 2022-04-15  5:00 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa, Matt Turner

From: Jelle van der Waa <jvanderwaa@redhat.com>

GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
API functions. gtk_tree_view_set_rules_hint is no longer required since
theme's are now responsible to handle this, gtk_vbox_new is deprecated
and replaced by passing the orientation to gtk_box_new. Apart from these
changes the accessing of the screen changed in GTK which requires using
new functions for getting geometry. Lastly the GTK_STOCK_OK define is
deprecated in GTK 3.

Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
Originally sent in 2019. I've rebased it and given it a test.

One problem I've noticed is that C++ symbol names are often broken.
E.g.:

(perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
markup due to error parsing markup: Error on line 1 char 95:
“std::char_traits<char” is not a valid name: “<”

Presumably we need to call g_markup_escape_text() somewhere, but I
struggled to find the right place.

Without the patch, the GTK-2 version repeatedly segfaults, so this is an
improvement regardless.

 tools/build/Makefile.feature                  |  5 +++--
 tools/build/feature/Makefile                  | 12 +++++-----
 tools/build/feature/test-all.c                | 10 +++++++++
 ...est-gtk2-infobar.c => test-gtk3-infobar.c} |  0
 .../feature/{test-gtk2.c => test-gtk3.c}      |  0
 tools/perf/Documentation/perf-report.txt      |  2 +-
 tools/perf/Makefile                           |  2 +-
 tools/perf/Makefile.config                    | 22 +++++++++----------
 tools/perf/Makefile.perf                      |  6 ++---
 tools/perf/builtin-report.c                   |  2 +-
 tools/perf/builtin-version.c                  |  1 +
 tools/perf/tests/make                         | 12 +++++-----
 tools/perf/ui/gtk/annotate.c                  |  2 +-
 tools/perf/ui/gtk/browser.c                   | 16 ++++++++------
 tools/perf/ui/gtk/hists.c                     |  6 +----
 tools/perf/ui/gtk/progress.c                  |  2 +-
 tools/perf/ui/setup.c                         |  2 +-
 17 files changed, 56 insertions(+), 46 deletions(-)
 rename tools/build/feature/{test-gtk2-infobar.c => test-gtk3-infobar.c} (100%)
 rename tools/build/feature/{test-gtk2.c => test-gtk3.c} (100%)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index ae61f464043a..4ce9c514f30b 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -79,8 +79,8 @@ FEATURE_TESTS_EXTRA :=                  \
          compile-32                     \
          compile-x32                    \
          cplus-demangle                 \
-         gtk2                           \
-         gtk2-infobar                   \
+         gtk3                           \
+         gtk3-infobar                   \
          hello                          \
          libbabeltrace                  \
          libbfd-liberty                 \
@@ -113,6 +113,7 @@ FEATURE_DISPLAY ?=              \
          dwarf                  \
          dwarf_getlocations     \
          glibc                  \
+         gtk3                   \
          libbfd                 \
          libbfd-buildid		\
          libcap                 \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index de66e1cc0734..82e2cc182c57 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -11,8 +11,8 @@ FILES=                                          \
          test-fortify-source.bin                \
          test-get_current_dir_name.bin          \
          test-glibc.bin                         \
-         test-gtk2.bin                          \
-         test-gtk2-infobar.bin                  \
+         test-gtk3.bin                          \
+         test-gtk3-infobar.bin                  \
          test-hello.bin                         \
          test-libaudit.bin                      \
          test-libbfd.bin                        \
@@ -205,11 +205,11 @@ $(OUTPUT)test-libtracefs.bin:
 $(OUTPUT)test-libcrypto.bin:
 	$(BUILD) -lcrypto
 
-$(OUTPUT)test-gtk2.bin:
-	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
+$(OUTPUT)test-gtk3.bin:
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
 
-$(OUTPUT)test-gtk2-infobar.bin:
-	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
+$(OUTPUT)test-gtk3-infobar.bin:
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
 
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 5ffafb967b6e..5ec093498cfc 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -70,6 +70,14 @@
 # include "test-libslang.c"
 #undef main
 
+#define main main_test_gtk3
+# include "test-gtk3.c"
+#undef main
+
+#define main main_test_gtk3_infobar
+# include "test-gtk3-infobar.c"
+#undef main
+
 #define main main_test_libbfd
 # include "test-libbfd.c"
 #undef main
@@ -187,6 +195,8 @@ int main(int argc, char *argv[])
 	main_test_libelf_getshdrstrndx();
 	main_test_libunwind();
 	main_test_libslang();
+	main_test_gtk3(argc, argv);
+	main_test_gtk3_infobar(argc, argv);
 	main_test_libbfd();
 	main_test_libbfd_buildid();
 	main_test_backtrace();
diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk3-infobar.c
similarity index 100%
rename from tools/build/feature/test-gtk2-infobar.c
rename to tools/build/feature/test-gtk3-infobar.c
diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk3.c
similarity index 100%
rename from tools/build/feature/test-gtk2.c
rename to tools/build/feature/test-gtk3.c
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 24efc0583c93..e4a7c99c7853 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -314,7 +314,7 @@ OPTIONS
 	requires a tty, if one is not present, as when piping to other
 	commands, the stdio interface is used.
 
---gtk:: Use the GTK2 interface.
+--gtk:: Use the GTK3 interface.
 
 -k::
 --vmlinux=<file>::
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f3fe360a35c6..ea3fb4657a91 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -100,7 +100,7 @@ clean:
 # make -C tools/perf -f tests/make
 #
 build-test:
-	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk2 out
+	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk3 out
 
 build-test-tarball:
 	@$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index f3bf9297bcc0..3bb755fb7676 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -755,20 +755,20 @@ ifndef NO_SLANG
   endif
 endif
 
-ifdef GTK2
-  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
-  $(call feature_check,gtk2)
-  ifneq ($(feature-gtk2), 1)
-    msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
-    NO_GTK2 := 1
+ifdef GTK3
+  FLAGS_GTK3=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
+  $(call feature_check,gtk3)
+  ifneq ($(feature-gtk3), 1)
+    msg := $(warning GTK3 not found, disables GTK3 support. Please install gtk3-devel or libgtk3.0-dev);
+    NO_GTK3 := 1
   else
-    $(call feature_check,gtk2-infobar)
-    ifeq ($(feature-gtk2-infobar), 1)
+    $(call feature_check,gtk3-infobar)
+    ifeq ($(feature-gtk3-infobar), 1)
       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
     endif
-    CFLAGS += -DHAVE_GTK2_SUPPORT
-    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
-    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
+    CFLAGS += -DHAVE_GTK3_SUPPORT
+    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-3.0 2>/dev/null)
+    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0 2>/dev/null)
     EXTLIBS += -ldl
   endif
 endif
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 69473a836bae..0211a20242fe 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -48,7 +48,7 @@ include ../scripts/utilities.mak
 #
 # Define NO_SLANG if you do not want TUI support.
 #
-# Define GTK2 if you want GTK+ GUI support.
+# Define GTK3 if you want GTK+ GUI support.
 #
 # Define NO_DEMANGLE if you do not want C++ symbol demangling.
 #
@@ -404,7 +404,7 @@ ifneq ($(OUTPUT),)
   CFLAGS += -I$(OUTPUT)
 endif
 
-ifdef GTK2
+ifdef GTK3
   ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
   GTK_IN := $(OUTPUT)gtk-in.o
 endif
@@ -930,7 +930,7 @@ check: $(OUTPUT)common-cmds.h
 
 ### Installation rules
 
-ifdef GTK2
+ifdef GTK3
 install-gtk: $(OUTPUT)libperf-gtk.so
 	$(call QUIET_INSTALL, 'GTK UI') \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1ad75c7ba074..c3ad5e8e3098 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1213,7 +1213,7 @@ int cmd_report(int argc, const char **argv)
 #ifdef HAVE_SLANG_SUPPORT
 	OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
 #endif
-	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
+	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK3 interface"),
 	OPT_BOOLEAN(0, "stdio", &report.use_stdio,
 		    "Use the stdio interface"),
 	OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 9cd074a3d825..63c7e66bbc83 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -60,6 +60,7 @@ static void library_status(void)
 	STATUS(HAVE_DWARF_SUPPORT, dwarf);
 	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
 	STATUS(HAVE_GLIBC_SUPPORT, glibc);
+	STATUS(HAVE_GTK3_SUPPORT, gtk3);
 #ifndef HAVE_SYSCALL_TABLE_SUPPORT
 	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
 #endif
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index da013e90a945..cb959dccbe9d 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -72,8 +72,8 @@ make_no_libpython   := NO_LIBPYTHON=1
 make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
 make_no_newt        := NO_NEWT=1
 make_no_slang       := NO_SLANG=1
-make_no_gtk2        := NO_GTK2=1
-make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
+make_no_gtk3        := NO_GTK3=1
+make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK3=1
 make_no_demangle    := NO_DEMANGLE=1
 make_no_libelf      := NO_LIBELF=1
 make_no_libunwind   := NO_LIBUNWIND=1
@@ -93,7 +93,7 @@ make_no_sdt	    := NO_SDT=1
 make_no_syscall_tbl := NO_SYSCALL_TABLE=1
 make_with_clangllvm := LIBCLANGLLVM=1
 make_with_libpfm4   := LIBPFM4=1
-make_with_gtk2      := GTK2=1
+make_with_gtk3      := GTK3=1
 make_tags           := tags
 make_cscope         := cscope
 make_help           := help
@@ -113,7 +113,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
 make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
 
 # all the NO_* variable combined
-make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
+make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK3=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
@@ -138,7 +138,7 @@ run += make_no_libpython
 run += make_no_scripts
 run += make_no_newt
 run += make_no_slang
-run += make_no_gtk2
+run += make_no_gtk3
 run += make_no_ui
 run += make_no_demangle
 run += make_no_libelf
@@ -312,7 +312,7 @@ $(run):
 	$(call test,$@) && \
 	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
 
-make_with_gtk2:
+make_with_gtk3:
 	$(call clean)
 	@TMP_DEST=$$(mktemp -d); \
 	cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 0a50e962f9a3..efd380f124aa 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -208,7 +208,7 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
 		if (!pgctx)
 			return -1;
 
-		vbox = gtk_vbox_new(FALSE, 0);
+		vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 		notebook = gtk_notebook_new();
 		pgctx->notebook = notebook;
 
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index 8f3e43d148a8..6fd85b5325ba 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -13,19 +13,21 @@ void perf_gtk__signal(int sig)
 	psignal(sig, "perf");
 }
 
-void perf_gtk__resize_window(GtkWidget *window)
+void perf_gtk__resize_window(GtkWidget *widget)
 {
 	GdkRectangle rect;
-	GdkScreen *screen;
-	int monitor;
+	GdkMonitor *monitor;
+	GdkDisplay *display;
+	GdkWindow *window;
 	int height;
 	int width;
 
-	screen = gtk_widget_get_screen(window);
+	display = gdk_display_get_default();
+	window = gtk_widget_get_window(widget);
 
-	monitor = gdk_screen_get_monitor_at_window(screen, window->window);
+	monitor = gdk_display_get_monitor_at_window(display, window);
 
-	gdk_screen_get_monitor_geometry(screen, monitor, &rect);
+	gdk_monitor_get_geometry(monitor, &rect);
 
 	width	= rect.width * 3 / 4;
 	height	= rect.height * 3 / 4;
@@ -58,7 +60,7 @@ GtkWidget *perf_gtk__setup_info_bar(void)
 	content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
 	gtk_container_add(GTK_CONTAINER(content_area), label);
 
-	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
+	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), "_OK",
 				GTK_RESPONSE_OK);
 	g_signal_connect(info_bar, "response",
 			 G_CALLBACK(gtk_widget_hide), NULL);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index c83be2d57f7e..5aa2655c7a0a 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -395,8 +395,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 		}
 	}
 
-	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
-
 	g_signal_connect(view, "row-activated",
 			 G_CALLBACK(on_row_activated), NULL);
 	gtk_container_add(GTK_CONTAINER(window), view);
@@ -583,8 +581,6 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
 	perf_gtk__add_hierarchy_entries(hists, &hists->entries, store,
 					NULL, &hpp, min_pcnt);
 
-	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
-
 	g_signal_connect(view, "row-activated",
 			 G_CALLBACK(on_row_activated), NULL);
 	gtk_container_add(GTK_CONTAINER(window), view);
@@ -616,7 +612,7 @@ int evlist__gtk_browse_hists(struct evlist *evlist, const char *help,
 	if (!pgctx)
 		return -1;
 
-	vbox = gtk_vbox_new(FALSE, 0);
+	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 
 	notebook = gtk_notebook_new();
 
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index eea6fcde518a..aaa7e7f6e4aa 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -13,7 +13,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
 	char buf[1024];
 
 	if (dialog == NULL) {
-		GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
+		GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
 		GtkWidget *label = gtk_label_new(p->title);
 
 		dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 700335cde618..1d35e3ad4576 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -14,7 +14,7 @@ int use_browser = -1;
 
 #define PERF_GTK_DSO "libperf-gtk.so"
 
-#ifdef HAVE_GTK2_SUPPORT
+#ifdef HAVE_GTK3_SUPPORT
 
 static int setup_gtk_browser(void)
 {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] tools: port perf ui from GTK 2 to GTK 3
  2022-04-15  5:00 [PATCH] tools: port perf ui from GTK 2 to GTK 3 Matt Turner
@ 2022-04-16 14:55 ` Ian Rogers
  2022-04-20 17:08 ` Arnaldo Carvalho de Melo
  2022-10-19 23:29 ` [PATCH v2] " Matt Turner
  2 siblings, 0 replies; 11+ messages in thread
From: Ian Rogers @ 2022-04-16 14:55 UTC (permalink / raw)
  To: Matt Turner
  Cc: linux-perf-users, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa

On Fri, Apr 15, 2022 at 1:08 AM Matt Turner <mattst88@gmail.com> wrote:
>
> From: Jelle van der Waa <jvanderwaa@redhat.com>
>
> GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> API functions. gtk_tree_view_set_rules_hint is no longer required since
> theme's are now responsible to handle this, gtk_vbox_new is deprecated
> and replaced by passing the orientation to gtk_box_new. Apart from these
> changes the accessing of the screen changed in GTK which requires using
> new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> deprecated in GTK 3.

This is super super awesome, thanks for doing it! Does it make sense
or do you know what it would take for GTK4 support? I'm trying to test
this on Debian but see missing includes on gtk/gtk.h - good news that
it applies cleanly to Arnaldo's tree. I'm suspecting something wrong
on my end and so will try harder later.

Thanks,
Ian

> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
> Originally sent in 2019. I've rebased it and given it a test.
>
> One problem I've noticed is that C++ symbol names are often broken.
> E.g.:
>
> (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> markup due to error parsing markup: Error on line 1 char 95:
> “std::char_traits<char” is not a valid name: “<”
>
> Presumably we need to call g_markup_escape_text() somewhere, but I
> struggled to find the right place.
>
> Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> improvement regardless.
>
>  tools/build/Makefile.feature                  |  5 +++--
>  tools/build/feature/Makefile                  | 12 +++++-----
>  tools/build/feature/test-all.c                | 10 +++++++++
>  ...est-gtk2-infobar.c => test-gtk3-infobar.c} |  0
>  .../feature/{test-gtk2.c => test-gtk3.c}      |  0
>  tools/perf/Documentation/perf-report.txt      |  2 +-
>  tools/perf/Makefile                           |  2 +-
>  tools/perf/Makefile.config                    | 22 +++++++++----------
>  tools/perf/Makefile.perf                      |  6 ++---
>  tools/perf/builtin-report.c                   |  2 +-
>  tools/perf/builtin-version.c                  |  1 +
>  tools/perf/tests/make                         | 12 +++++-----
>  tools/perf/ui/gtk/annotate.c                  |  2 +-
>  tools/perf/ui/gtk/browser.c                   | 16 ++++++++------
>  tools/perf/ui/gtk/hists.c                     |  6 +----
>  tools/perf/ui/gtk/progress.c                  |  2 +-
>  tools/perf/ui/setup.c                         |  2 +-
>  17 files changed, 56 insertions(+), 46 deletions(-)
>  rename tools/build/feature/{test-gtk2-infobar.c => test-gtk3-infobar.c} (100%)
>  rename tools/build/feature/{test-gtk2.c => test-gtk3.c} (100%)
>
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index ae61f464043a..4ce9c514f30b 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -79,8 +79,8 @@ FEATURE_TESTS_EXTRA :=                  \
>           compile-32                     \
>           compile-x32                    \
>           cplus-demangle                 \
> -         gtk2                           \
> -         gtk2-infobar                   \
> +         gtk3                           \
> +         gtk3-infobar                   \
>           hello                          \
>           libbabeltrace                  \
>           libbfd-liberty                 \
> @@ -113,6 +113,7 @@ FEATURE_DISPLAY ?=              \
>           dwarf                  \
>           dwarf_getlocations     \
>           glibc                  \
> +         gtk3                   \
>           libbfd                 \
>           libbfd-buildid                \
>           libcap                 \
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index de66e1cc0734..82e2cc182c57 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -11,8 +11,8 @@ FILES=                                          \
>           test-fortify-source.bin                \
>           test-get_current_dir_name.bin          \
>           test-glibc.bin                         \
> -         test-gtk2.bin                          \
> -         test-gtk2-infobar.bin                  \
> +         test-gtk3.bin                          \
> +         test-gtk3-infobar.bin                  \
>           test-hello.bin                         \
>           test-libaudit.bin                      \
>           test-libbfd.bin                        \
> @@ -205,11 +205,11 @@ $(OUTPUT)test-libtracefs.bin:
>  $(OUTPUT)test-libcrypto.bin:
>         $(BUILD) -lcrypto
>
> -$(OUTPUT)test-gtk2.bin:
> -       $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
> +$(OUTPUT)test-gtk3.bin:
> +       $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
>
> -$(OUTPUT)test-gtk2-infobar.bin:
> -       $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> +$(OUTPUT)test-gtk3-infobar.bin:
> +       $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
>
>  grep-libs  = $(filter -l%,$(1))
>  strip-libs = $(filter-out -l%,$(1))
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index 5ffafb967b6e..5ec093498cfc 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -70,6 +70,14 @@
>  # include "test-libslang.c"
>  #undef main
>
> +#define main main_test_gtk3
> +# include "test-gtk3.c"
> +#undef main
> +
> +#define main main_test_gtk3_infobar
> +# include "test-gtk3-infobar.c"
> +#undef main
> +
>  #define main main_test_libbfd
>  # include "test-libbfd.c"
>  #undef main
> @@ -187,6 +195,8 @@ int main(int argc, char *argv[])
>         main_test_libelf_getshdrstrndx();
>         main_test_libunwind();
>         main_test_libslang();
> +       main_test_gtk3(argc, argv);
> +       main_test_gtk3_infobar(argc, argv);
>         main_test_libbfd();
>         main_test_libbfd_buildid();
>         main_test_backtrace();
> diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk3-infobar.c
> similarity index 100%
> rename from tools/build/feature/test-gtk2-infobar.c
> rename to tools/build/feature/test-gtk3-infobar.c
> diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk3.c
> similarity index 100%
> rename from tools/build/feature/test-gtk2.c
> rename to tools/build/feature/test-gtk3.c
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index 24efc0583c93..e4a7c99c7853 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -314,7 +314,7 @@ OPTIONS
>         requires a tty, if one is not present, as when piping to other
>         commands, the stdio interface is used.
>
> ---gtk:: Use the GTK2 interface.
> +--gtk:: Use the GTK3 interface.
>
>  -k::
>  --vmlinux=<file>::
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index f3fe360a35c6..ea3fb4657a91 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -100,7 +100,7 @@ clean:
>  # make -C tools/perf -f tests/make
>  #
>  build-test:
> -       @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk2 out
> +       @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk3 out
>
>  build-test-tarball:
>         @$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index f3bf9297bcc0..3bb755fb7676 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -755,20 +755,20 @@ ifndef NO_SLANG
>    endif
>  endif
>
> -ifdef GTK2
> -  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> -  $(call feature_check,gtk2)
> -  ifneq ($(feature-gtk2), 1)
> -    msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
> -    NO_GTK2 := 1
> +ifdef GTK3
> +  FLAGS_GTK3=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
> +  $(call feature_check,gtk3)
> +  ifneq ($(feature-gtk3), 1)
> +    msg := $(warning GTK3 not found, disables GTK3 support. Please install gtk3-devel or libgtk3.0-dev);
> +    NO_GTK3 := 1
>    else
> -    $(call feature_check,gtk2-infobar)
> -    ifeq ($(feature-gtk2-infobar), 1)
> +    $(call feature_check,gtk3-infobar)
> +    ifeq ($(feature-gtk3-infobar), 1)
>        GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
>      endif
> -    CFLAGS += -DHAVE_GTK2_SUPPORT
> -    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
> -    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
> +    CFLAGS += -DHAVE_GTK3_SUPPORT
> +    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-3.0 2>/dev/null)
> +    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0 2>/dev/null)
>      EXTLIBS += -ldl
>    endif
>  endif
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 69473a836bae..0211a20242fe 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -48,7 +48,7 @@ include ../scripts/utilities.mak
>  #
>  # Define NO_SLANG if you do not want TUI support.
>  #
> -# Define GTK2 if you want GTK+ GUI support.
> +# Define GTK3 if you want GTK+ GUI support.
>  #
>  # Define NO_DEMANGLE if you do not want C++ symbol demangling.
>  #
> @@ -404,7 +404,7 @@ ifneq ($(OUTPUT),)
>    CFLAGS += -I$(OUTPUT)
>  endif
>
> -ifdef GTK2
> +ifdef GTK3
>    ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
>    GTK_IN := $(OUTPUT)gtk-in.o
>  endif
> @@ -930,7 +930,7 @@ check: $(OUTPUT)common-cmds.h
>
>  ### Installation rules
>
> -ifdef GTK2
> +ifdef GTK3
>  install-gtk: $(OUTPUT)libperf-gtk.so
>         $(call QUIET_INSTALL, 'GTK UI') \
>                 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 1ad75c7ba074..c3ad5e8e3098 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1213,7 +1213,7 @@ int cmd_report(int argc, const char **argv)
>  #ifdef HAVE_SLANG_SUPPORT
>         OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
>  #endif
> -       OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
> +       OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK3 interface"),
>         OPT_BOOLEAN(0, "stdio", &report.use_stdio,
>                     "Use the stdio interface"),
>         OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
> diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
> index 9cd074a3d825..63c7e66bbc83 100644
> --- a/tools/perf/builtin-version.c
> +++ b/tools/perf/builtin-version.c
> @@ -60,6 +60,7 @@ static void library_status(void)
>         STATUS(HAVE_DWARF_SUPPORT, dwarf);
>         STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
>         STATUS(HAVE_GLIBC_SUPPORT, glibc);
> +       STATUS(HAVE_GTK3_SUPPORT, gtk3);
>  #ifndef HAVE_SYSCALL_TABLE_SUPPORT
>         STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
>  #endif
> diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> index da013e90a945..cb959dccbe9d 100644
> --- a/tools/perf/tests/make
> +++ b/tools/perf/tests/make
> @@ -72,8 +72,8 @@ make_no_libpython   := NO_LIBPYTHON=1
>  make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
>  make_no_newt        := NO_NEWT=1
>  make_no_slang       := NO_SLANG=1
> -make_no_gtk2        := NO_GTK2=1
> -make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
> +make_no_gtk3        := NO_GTK3=1
> +make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK3=1
>  make_no_demangle    := NO_DEMANGLE=1
>  make_no_libelf      := NO_LIBELF=1
>  make_no_libunwind   := NO_LIBUNWIND=1
> @@ -93,7 +93,7 @@ make_no_sdt       := NO_SDT=1
>  make_no_syscall_tbl := NO_SYSCALL_TABLE=1
>  make_with_clangllvm := LIBCLANGLLVM=1
>  make_with_libpfm4   := LIBPFM4=1
> -make_with_gtk2      := GTK2=1
> +make_with_gtk3      := GTK3=1
>  make_tags           := tags
>  make_cscope         := cscope
>  make_help           := help
> @@ -113,7 +113,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
>  make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
>
>  # all the NO_* variable combined
> -make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
> +make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK3=1
>  make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
>  make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
>  make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
> @@ -138,7 +138,7 @@ run += make_no_libpython
>  run += make_no_scripts
>  run += make_no_newt
>  run += make_no_slang
> -run += make_no_gtk2
> +run += make_no_gtk3
>  run += make_no_ui
>  run += make_no_demangle
>  run += make_no_libelf
> @@ -312,7 +312,7 @@ $(run):
>         $(call test,$@) && \
>         rm -rf $@ $$TMP_DEST || (cat $@ ; false)
>
> -make_with_gtk2:
> +make_with_gtk3:
>         $(call clean)
>         @TMP_DEST=$$(mktemp -d); \
>         cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \
> diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
> index 0a50e962f9a3..efd380f124aa 100644
> --- a/tools/perf/ui/gtk/annotate.c
> +++ b/tools/perf/ui/gtk/annotate.c
> @@ -208,7 +208,7 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
>                 if (!pgctx)
>                         return -1;
>
> -               vbox = gtk_vbox_new(FALSE, 0);
> +               vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
>                 notebook = gtk_notebook_new();
>                 pgctx->notebook = notebook;
>
> diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
> index 8f3e43d148a8..6fd85b5325ba 100644
> --- a/tools/perf/ui/gtk/browser.c
> +++ b/tools/perf/ui/gtk/browser.c
> @@ -13,19 +13,21 @@ void perf_gtk__signal(int sig)
>         psignal(sig, "perf");
>  }
>
> -void perf_gtk__resize_window(GtkWidget *window)
> +void perf_gtk__resize_window(GtkWidget *widget)
>  {
>         GdkRectangle rect;
> -       GdkScreen *screen;
> -       int monitor;
> +       GdkMonitor *monitor;
> +       GdkDisplay *display;
> +       GdkWindow *window;
>         int height;
>         int width;
>
> -       screen = gtk_widget_get_screen(window);
> +       display = gdk_display_get_default();
> +       window = gtk_widget_get_window(widget);
>
> -       monitor = gdk_screen_get_monitor_at_window(screen, window->window);
> +       monitor = gdk_display_get_monitor_at_window(display, window);
>
> -       gdk_screen_get_monitor_geometry(screen, monitor, &rect);
> +       gdk_monitor_get_geometry(monitor, &rect);
>
>         width   = rect.width * 3 / 4;
>         height  = rect.height * 3 / 4;
> @@ -58,7 +60,7 @@ GtkWidget *perf_gtk__setup_info_bar(void)
>         content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
>         gtk_container_add(GTK_CONTAINER(content_area), label);
>
> -       gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
> +       gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), "_OK",
>                                 GTK_RESPONSE_OK);
>         g_signal_connect(info_bar, "response",
>                          G_CALLBACK(gtk_widget_hide), NULL);
> diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
> index c83be2d57f7e..5aa2655c7a0a 100644
> --- a/tools/perf/ui/gtk/hists.c
> +++ b/tools/perf/ui/gtk/hists.c
> @@ -395,8 +395,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
>                 }
>         }
>
> -       gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
> -
>         g_signal_connect(view, "row-activated",
>                          G_CALLBACK(on_row_activated), NULL);
>         gtk_container_add(GTK_CONTAINER(window), view);
> @@ -583,8 +581,6 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
>         perf_gtk__add_hierarchy_entries(hists, &hists->entries, store,
>                                         NULL, &hpp, min_pcnt);
>
> -       gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
> -
>         g_signal_connect(view, "row-activated",
>                          G_CALLBACK(on_row_activated), NULL);
>         gtk_container_add(GTK_CONTAINER(window), view);
> @@ -616,7 +612,7 @@ int evlist__gtk_browse_hists(struct evlist *evlist, const char *help,
>         if (!pgctx)
>                 return -1;
>
> -       vbox = gtk_vbox_new(FALSE, 0);
> +       vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
>
>         notebook = gtk_notebook_new();
>
> diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
> index eea6fcde518a..aaa7e7f6e4aa 100644
> --- a/tools/perf/ui/gtk/progress.c
> +++ b/tools/perf/ui/gtk/progress.c
> @@ -13,7 +13,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
>         char buf[1024];
>
>         if (dialog == NULL) {
> -               GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
> +               GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
>                 GtkWidget *label = gtk_label_new(p->title);
>
>                 dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
> index 700335cde618..1d35e3ad4576 100644
> --- a/tools/perf/ui/setup.c
> +++ b/tools/perf/ui/setup.c
> @@ -14,7 +14,7 @@ int use_browser = -1;
>
>  #define PERF_GTK_DSO "libperf-gtk.so"
>
> -#ifdef HAVE_GTK2_SUPPORT
> +#ifdef HAVE_GTK3_SUPPORT
>
>  static int setup_gtk_browser(void)
>  {
> --
> 2.35.1
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] tools: port perf ui from GTK 2 to GTK 3
  2022-04-15  5:00 [PATCH] tools: port perf ui from GTK 2 to GTK 3 Matt Turner
  2022-04-16 14:55 ` Ian Rogers
@ 2022-04-20 17:08 ` Arnaldo Carvalho de Melo
  2022-04-21 21:02   ` Matt Turner
  2022-10-19 23:29 ` [PATCH v2] " Matt Turner
  2 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-04-20 17:08 UTC (permalink / raw)
  To: Matt Turner
  Cc: linux-perf-users, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Jelle van der Waa

Em Thu, Apr 14, 2022 at 10:00:03PM -0700, Matt Turner escreveu:
> From: Jelle van der Waa <jvanderwaa@redhat.com>
> 
> GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> API functions. gtk_tree_view_set_rules_hint is no longer required since
> theme's are now responsible to handle this, gtk_vbox_new is deprecated
> and replaced by passing the orientation to gtk_box_new. Apart from these
> changes the accessing of the screen changed in GTK which requires using
> new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> deprecated in GTK 3.
> 
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
> Originally sent in 2019. I've rebased it and given it a test.
> 
> One problem I've noticed is that C++ symbol names are often broken.
> E.g.:
> 
> (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> markup due to error parsing markup: Error on line 1 char 95:
> “std::char_traits<char” is not a valid name: “<”
> 
> Presumably we need to call g_markup_escape_text() somewhere, but I
> struggled to find the right place.
> 
> Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> improvement regardless.

I'm trying to test build this but failing:

1. uninstalled gtk2-devel, which removed several other packages

2. installed gtk3-devel, which installed several other packages

3.: 

Auto-detecting system features:
...                         dwarf: [ on  ]
...            dwarf_getlocations: [ on  ]
...                         glibc: [ on  ]
...                          gtk3: [ OFF ]
...                        libbfd: [ on  ]
...                libbfd-buildid: [ on  ]
 
Looking at how that OFF is deduced:

⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-
Display all 150 possibilities? (y or n)
⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-all.make.output
In file included from test-all.c:74:
test-gtk3.c:3:10: fatal error: gtk/gtk.h: No such file or directory
    3 | #include <gtk/gtk.h>
      |          ^~~~~~~~~~~
compilation terminated.
⬢[acme@toolbox perf]$

⬢[acme@toolbox perf]$ find /usr/include -name gtk.h
/usr/include/gtk-3.0/gtk/gtk.h
⬢[acme@toolbox perf]$ rpm -qf /usr/include/gtk-3.0/gtk/gtk.h
gtk3-devel-3.24.31-2.fc35.x86_64
⬢[acme@toolbox perf]$

And that pkg-config line produces:

⬢[acme@toolbox perf]$ pkg-config --libs --cflags gtk+-3.0
-I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
⬢[acme@toolbox perf]$

I'm testing this on fedora 35 silverblue, in a perf build container:

⬢[acme@toolbox perf]$ rpm -qa | grep gtk
gtk-update-icon-cache-3.24.31-2.fc35.x86_64
libcanberra-gtk3-0.30-27.fc35.x86_64
gtk3-3.24.31-2.fc35.x86_64
libcanberra-gtk2-0.30-27.fc35.x86_64
gtk2-2.24.33-7.fc35.x86_64
gtk3-devel-3.24.31-2.fc35.x86_64
⬢[acme@toolbox perf]$

Ideas?

- Arnaldo

>  tools/build/Makefile.feature                  |  5 +++--
>  tools/build/feature/Makefile                  | 12 +++++-----
>  tools/build/feature/test-all.c                | 10 +++++++++
>  ...est-gtk2-infobar.c => test-gtk3-infobar.c} |  0
>  .../feature/{test-gtk2.c => test-gtk3.c}      |  0
>  tools/perf/Documentation/perf-report.txt      |  2 +-
>  tools/perf/Makefile                           |  2 +-
>  tools/perf/Makefile.config                    | 22 +++++++++----------
>  tools/perf/Makefile.perf                      |  6 ++---
>  tools/perf/builtin-report.c                   |  2 +-
>  tools/perf/builtin-version.c                  |  1 +
>  tools/perf/tests/make                         | 12 +++++-----
>  tools/perf/ui/gtk/annotate.c                  |  2 +-
>  tools/perf/ui/gtk/browser.c                   | 16 ++++++++------
>  tools/perf/ui/gtk/hists.c                     |  6 +----
>  tools/perf/ui/gtk/progress.c                  |  2 +-
>  tools/perf/ui/setup.c                         |  2 +-
>  17 files changed, 56 insertions(+), 46 deletions(-)
>  rename tools/build/feature/{test-gtk2-infobar.c => test-gtk3-infobar.c} (100%)
>  rename tools/build/feature/{test-gtk2.c => test-gtk3.c} (100%)
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index ae61f464043a..4ce9c514f30b 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -79,8 +79,8 @@ FEATURE_TESTS_EXTRA :=                  \
>           compile-32                     \
>           compile-x32                    \
>           cplus-demangle                 \
> -         gtk2                           \
> -         gtk2-infobar                   \
> +         gtk3                           \
> +         gtk3-infobar                   \
>           hello                          \
>           libbabeltrace                  \
>           libbfd-liberty                 \
> @@ -113,6 +113,7 @@ FEATURE_DISPLAY ?=              \
>           dwarf                  \
>           dwarf_getlocations     \
>           glibc                  \
> +         gtk3                   \
>           libbfd                 \
>           libbfd-buildid		\
>           libcap                 \
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index de66e1cc0734..82e2cc182c57 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -11,8 +11,8 @@ FILES=                                          \
>           test-fortify-source.bin                \
>           test-get_current_dir_name.bin          \
>           test-glibc.bin                         \
> -         test-gtk2.bin                          \
> -         test-gtk2-infobar.bin                  \
> +         test-gtk3.bin                          \
> +         test-gtk3-infobar.bin                  \
>           test-hello.bin                         \
>           test-libaudit.bin                      \
>           test-libbfd.bin                        \
> @@ -205,11 +205,11 @@ $(OUTPUT)test-libtracefs.bin:
>  $(OUTPUT)test-libcrypto.bin:
>  	$(BUILD) -lcrypto
>  
> -$(OUTPUT)test-gtk2.bin:
> -	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
> +$(OUTPUT)test-gtk3.bin:
> +	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
>  
> -$(OUTPUT)test-gtk2-infobar.bin:
> -	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> +$(OUTPUT)test-gtk3-infobar.bin:
> +	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
>  
>  grep-libs  = $(filter -l%,$(1))
>  strip-libs = $(filter-out -l%,$(1))
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index 5ffafb967b6e..5ec093498cfc 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -70,6 +70,14 @@
>  # include "test-libslang.c"
>  #undef main
>  
> +#define main main_test_gtk3
> +# include "test-gtk3.c"
> +#undef main
> +
> +#define main main_test_gtk3_infobar
> +# include "test-gtk3-infobar.c"
> +#undef main
> +
>  #define main main_test_libbfd
>  # include "test-libbfd.c"
>  #undef main
> @@ -187,6 +195,8 @@ int main(int argc, char *argv[])
>  	main_test_libelf_getshdrstrndx();
>  	main_test_libunwind();
>  	main_test_libslang();
> +	main_test_gtk3(argc, argv);
> +	main_test_gtk3_infobar(argc, argv);
>  	main_test_libbfd();
>  	main_test_libbfd_buildid();
>  	main_test_backtrace();
> diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk3-infobar.c
> similarity index 100%
> rename from tools/build/feature/test-gtk2-infobar.c
> rename to tools/build/feature/test-gtk3-infobar.c
> diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk3.c
> similarity index 100%
> rename from tools/build/feature/test-gtk2.c
> rename to tools/build/feature/test-gtk3.c
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index 24efc0583c93..e4a7c99c7853 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -314,7 +314,7 @@ OPTIONS
>  	requires a tty, if one is not present, as when piping to other
>  	commands, the stdio interface is used.
>  
> ---gtk:: Use the GTK2 interface.
> +--gtk:: Use the GTK3 interface.
>  
>  -k::
>  --vmlinux=<file>::
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index f3fe360a35c6..ea3fb4657a91 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -100,7 +100,7 @@ clean:
>  # make -C tools/perf -f tests/make
>  #
>  build-test:
> -	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk2 out
> +	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk3 out
>  
>  build-test-tarball:
>  	@$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index f3bf9297bcc0..3bb755fb7676 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -755,20 +755,20 @@ ifndef NO_SLANG
>    endif
>  endif
>  
> -ifdef GTK2
> -  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
> -  $(call feature_check,gtk2)
> -  ifneq ($(feature-gtk2), 1)
> -    msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
> -    NO_GTK2 := 1
> +ifdef GTK3
> +  FLAGS_GTK3=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
> +  $(call feature_check,gtk3)
> +  ifneq ($(feature-gtk3), 1)
> +    msg := $(warning GTK3 not found, disables GTK3 support. Please install gtk3-devel or libgtk3.0-dev);
> +    NO_GTK3 := 1
>    else
> -    $(call feature_check,gtk2-infobar)
> -    ifeq ($(feature-gtk2-infobar), 1)
> +    $(call feature_check,gtk3-infobar)
> +    ifeq ($(feature-gtk3-infobar), 1)
>        GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
>      endif
> -    CFLAGS += -DHAVE_GTK2_SUPPORT
> -    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
> -    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
> +    CFLAGS += -DHAVE_GTK3_SUPPORT
> +    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-3.0 2>/dev/null)
> +    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0 2>/dev/null)
>      EXTLIBS += -ldl
>    endif
>  endif
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 69473a836bae..0211a20242fe 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -48,7 +48,7 @@ include ../scripts/utilities.mak
>  #
>  # Define NO_SLANG if you do not want TUI support.
>  #
> -# Define GTK2 if you want GTK+ GUI support.
> +# Define GTK3 if you want GTK+ GUI support.
>  #
>  # Define NO_DEMANGLE if you do not want C++ symbol demangling.
>  #
> @@ -404,7 +404,7 @@ ifneq ($(OUTPUT),)
>    CFLAGS += -I$(OUTPUT)
>  endif
>  
> -ifdef GTK2
> +ifdef GTK3
>    ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
>    GTK_IN := $(OUTPUT)gtk-in.o
>  endif
> @@ -930,7 +930,7 @@ check: $(OUTPUT)common-cmds.h
>  
>  ### Installation rules
>  
> -ifdef GTK2
> +ifdef GTK3
>  install-gtk: $(OUTPUT)libperf-gtk.so
>  	$(call QUIET_INSTALL, 'GTK UI') \
>  		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 1ad75c7ba074..c3ad5e8e3098 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1213,7 +1213,7 @@ int cmd_report(int argc, const char **argv)
>  #ifdef HAVE_SLANG_SUPPORT
>  	OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
>  #endif
> -	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
> +	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK3 interface"),
>  	OPT_BOOLEAN(0, "stdio", &report.use_stdio,
>  		    "Use the stdio interface"),
>  	OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
> diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
> index 9cd074a3d825..63c7e66bbc83 100644
> --- a/tools/perf/builtin-version.c
> +++ b/tools/perf/builtin-version.c
> @@ -60,6 +60,7 @@ static void library_status(void)
>  	STATUS(HAVE_DWARF_SUPPORT, dwarf);
>  	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
>  	STATUS(HAVE_GLIBC_SUPPORT, glibc);
> +	STATUS(HAVE_GTK3_SUPPORT, gtk3);
>  #ifndef HAVE_SYSCALL_TABLE_SUPPORT
>  	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
>  #endif
> diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> index da013e90a945..cb959dccbe9d 100644
> --- a/tools/perf/tests/make
> +++ b/tools/perf/tests/make
> @@ -72,8 +72,8 @@ make_no_libpython   := NO_LIBPYTHON=1
>  make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
>  make_no_newt        := NO_NEWT=1
>  make_no_slang       := NO_SLANG=1
> -make_no_gtk2        := NO_GTK2=1
> -make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
> +make_no_gtk3        := NO_GTK3=1
> +make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK3=1
>  make_no_demangle    := NO_DEMANGLE=1
>  make_no_libelf      := NO_LIBELF=1
>  make_no_libunwind   := NO_LIBUNWIND=1
> @@ -93,7 +93,7 @@ make_no_sdt	    := NO_SDT=1
>  make_no_syscall_tbl := NO_SYSCALL_TABLE=1
>  make_with_clangllvm := LIBCLANGLLVM=1
>  make_with_libpfm4   := LIBPFM4=1
> -make_with_gtk2      := GTK2=1
> +make_with_gtk3      := GTK3=1
>  make_tags           := tags
>  make_cscope         := cscope
>  make_help           := help
> @@ -113,7 +113,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
>  make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
>  
>  # all the NO_* variable combined
> -make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
> +make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK3=1
>  make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
>  make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
>  make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
> @@ -138,7 +138,7 @@ run += make_no_libpython
>  run += make_no_scripts
>  run += make_no_newt
>  run += make_no_slang
> -run += make_no_gtk2
> +run += make_no_gtk3
>  run += make_no_ui
>  run += make_no_demangle
>  run += make_no_libelf
> @@ -312,7 +312,7 @@ $(run):
>  	$(call test,$@) && \
>  	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
>  
> -make_with_gtk2:
> +make_with_gtk3:
>  	$(call clean)
>  	@TMP_DEST=$$(mktemp -d); \
>  	cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \
> diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
> index 0a50e962f9a3..efd380f124aa 100644
> --- a/tools/perf/ui/gtk/annotate.c
> +++ b/tools/perf/ui/gtk/annotate.c
> @@ -208,7 +208,7 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
>  		if (!pgctx)
>  			return -1;
>  
> -		vbox = gtk_vbox_new(FALSE, 0);
> +		vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
>  		notebook = gtk_notebook_new();
>  		pgctx->notebook = notebook;
>  
> diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
> index 8f3e43d148a8..6fd85b5325ba 100644
> --- a/tools/perf/ui/gtk/browser.c
> +++ b/tools/perf/ui/gtk/browser.c
> @@ -13,19 +13,21 @@ void perf_gtk__signal(int sig)
>  	psignal(sig, "perf");
>  }
>  
> -void perf_gtk__resize_window(GtkWidget *window)
> +void perf_gtk__resize_window(GtkWidget *widget)
>  {
>  	GdkRectangle rect;
> -	GdkScreen *screen;
> -	int monitor;
> +	GdkMonitor *monitor;
> +	GdkDisplay *display;
> +	GdkWindow *window;
>  	int height;
>  	int width;
>  
> -	screen = gtk_widget_get_screen(window);
> +	display = gdk_display_get_default();
> +	window = gtk_widget_get_window(widget);
>  
> -	monitor = gdk_screen_get_monitor_at_window(screen, window->window);
> +	monitor = gdk_display_get_monitor_at_window(display, window);
>  
> -	gdk_screen_get_monitor_geometry(screen, monitor, &rect);
> +	gdk_monitor_get_geometry(monitor, &rect);
>  
>  	width	= rect.width * 3 / 4;
>  	height	= rect.height * 3 / 4;
> @@ -58,7 +60,7 @@ GtkWidget *perf_gtk__setup_info_bar(void)
>  	content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
>  	gtk_container_add(GTK_CONTAINER(content_area), label);
>  
> -	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
> +	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), "_OK",
>  				GTK_RESPONSE_OK);
>  	g_signal_connect(info_bar, "response",
>  			 G_CALLBACK(gtk_widget_hide), NULL);
> diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
> index c83be2d57f7e..5aa2655c7a0a 100644
> --- a/tools/perf/ui/gtk/hists.c
> +++ b/tools/perf/ui/gtk/hists.c
> @@ -395,8 +395,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
>  		}
>  	}
>  
> -	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
> -
>  	g_signal_connect(view, "row-activated",
>  			 G_CALLBACK(on_row_activated), NULL);
>  	gtk_container_add(GTK_CONTAINER(window), view);
> @@ -583,8 +581,6 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
>  	perf_gtk__add_hierarchy_entries(hists, &hists->entries, store,
>  					NULL, &hpp, min_pcnt);
>  
> -	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
> -
>  	g_signal_connect(view, "row-activated",
>  			 G_CALLBACK(on_row_activated), NULL);
>  	gtk_container_add(GTK_CONTAINER(window), view);
> @@ -616,7 +612,7 @@ int evlist__gtk_browse_hists(struct evlist *evlist, const char *help,
>  	if (!pgctx)
>  		return -1;
>  
> -	vbox = gtk_vbox_new(FALSE, 0);
> +	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
>  
>  	notebook = gtk_notebook_new();
>  
> diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
> index eea6fcde518a..aaa7e7f6e4aa 100644
> --- a/tools/perf/ui/gtk/progress.c
> +++ b/tools/perf/ui/gtk/progress.c
> @@ -13,7 +13,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
>  	char buf[1024];
>  
>  	if (dialog == NULL) {
> -		GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
> +		GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
>  		GtkWidget *label = gtk_label_new(p->title);
>  
>  		dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
> index 700335cde618..1d35e3ad4576 100644
> --- a/tools/perf/ui/setup.c
> +++ b/tools/perf/ui/setup.c
> @@ -14,7 +14,7 @@ int use_browser = -1;
>  
>  #define PERF_GTK_DSO "libperf-gtk.so"
>  
> -#ifdef HAVE_GTK2_SUPPORT
> +#ifdef HAVE_GTK3_SUPPORT
>  
>  static int setup_gtk_browser(void)
>  {
> -- 
> 2.35.1

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] tools: port perf ui from GTK 2 to GTK 3
  2022-04-20 17:08 ` Arnaldo Carvalho de Melo
@ 2022-04-21 21:02   ` Matt Turner
  2022-04-22 19:01     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 11+ messages in thread
From: Matt Turner @ 2022-04-21 21:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-perf-users, LKML, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Jelle van der Waa

On Wed, Apr 20, 2022 at 10:08 AM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
> Em Thu, Apr 14, 2022 at 10:00:03PM -0700, Matt Turner escreveu:
> > From: Jelle van der Waa <jvanderwaa@redhat.com>
> >
> > GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> > API functions. gtk_tree_view_set_rules_hint is no longer required since
> > theme's are now responsible to handle this, gtk_vbox_new is deprecated
> > and replaced by passing the orientation to gtk_box_new. Apart from these
> > changes the accessing of the screen changed in GTK which requires using
> > new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> > deprecated in GTK 3.
> >
> > Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > ---
> > Originally sent in 2019. I've rebased it and given it a test.
> >
> > One problem I've noticed is that C++ symbol names are often broken.
> > E.g.:
> >
> > (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> > markup due to error parsing markup: Error on line 1 char 95:
> > “std::char_traits<char” is not a valid name: “<”
> >
> > Presumably we need to call g_markup_escape_text() somewhere, but I
> > struggled to find the right place.
> >
> > Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> > improvement regardless.
>
> I'm trying to test build this but failing:
>
> 1. uninstalled gtk2-devel, which removed several other packages
>
> 2. installed gtk3-devel, which installed several other packages
>
> 3.:
>
> Auto-detecting system features:
> ...                         dwarf: [ on  ]
> ...            dwarf_getlocations: [ on  ]
> ...                         glibc: [ on  ]
> ...                          gtk3: [ OFF ]
> ...                        libbfd: [ on  ]
> ...                libbfd-buildid: [ on  ]
>
> Looking at how that OFF is deduced:
>
> ⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-
> Display all 150 possibilities? (y or n)
> ⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-all.make.output
> In file included from test-all.c:74:
> test-gtk3.c:3:10: fatal error: gtk/gtk.h: No such file or directory
>     3 | #include <gtk/gtk.h>
>       |          ^~~~~~~~~~~
> compilation terminated.
> ⬢[acme@toolbox perf]$
>
> ⬢[acme@toolbox perf]$ find /usr/include -name gtk.h
> /usr/include/gtk-3.0/gtk/gtk.h
> ⬢[acme@toolbox perf]$ rpm -qf /usr/include/gtk-3.0/gtk/gtk.h
> gtk3-devel-3.24.31-2.fc35.x86_64
> ⬢[acme@toolbox perf]$
>
> And that pkg-config line produces:
>
> ⬢[acme@toolbox perf]$ pkg-config --libs --cflags gtk+-3.0
> -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
> ⬢[acme@toolbox perf]$
>
> I'm testing this on fedora 35 silverblue, in a perf build container:
>
> ⬢[acme@toolbox perf]$ rpm -qa | grep gtk
> gtk-update-icon-cache-3.24.31-2.fc35.x86_64
> libcanberra-gtk3-0.30-27.fc35.x86_64
> gtk3-3.24.31-2.fc35.x86_64
> libcanberra-gtk2-0.30-27.fc35.x86_64
> gtk2-2.24.33-7.fc35.x86_64
> gtk3-devel-3.24.31-2.fc35.x86_64
> ⬢[acme@toolbox perf]$
>
> Ideas?

Just to be clear, are you building with 'GTK3=1 make'? Since commit
4751bddd3f98 ("perf tools: Make GTK2 support opt-in") it's required to
enable GTK support explicitly. (IMO, leaving it disabled by default
makes sense to me, given some of the problems)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] tools: port perf ui from GTK 2 to GTK 3
  2022-04-21 21:02   ` Matt Turner
@ 2022-04-22 19:01     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-04-22 19:01 UTC (permalink / raw)
  To: Matt Turner
  Cc: Arnaldo Carvalho de Melo, linux-perf-users, LKML, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Jelle van der Waa

Em Thu, Apr 21, 2022 at 02:02:49PM -0700, Matt Turner escreveu:
> On Wed, Apr 20, 2022 at 10:08 AM Arnaldo Carvalho de Melo
> <arnaldo.melo@gmail.com> wrote:
> >
> > Em Thu, Apr 14, 2022 at 10:00:03PM -0700, Matt Turner escreveu:
> > > From: Jelle van der Waa <jvanderwaa@redhat.com>
> > >
> > > GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> > > API functions. gtk_tree_view_set_rules_hint is no longer required since
> > > theme's are now responsible to handle this, gtk_vbox_new is deprecated
> > > and replaced by passing the orientation to gtk_box_new. Apart from these
> > > changes the accessing of the screen changed in GTK which requires using
> > > new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> > > deprecated in GTK 3.
> > >
> > > Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> > > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > > ---
> > > Originally sent in 2019. I've rebased it and given it a test.
> > >
> > > One problem I've noticed is that C++ symbol names are often broken.
> > > E.g.:
> > >
> > > (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> > > markup due to error parsing markup: Error on line 1 char 95:
> > > “std::char_traits<char” is not a valid name: “<”
> > >
> > > Presumably we need to call g_markup_escape_text() somewhere, but I
> > > struggled to find the right place.
> > >
> > > Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> > > improvement regardless.
> >
> > I'm trying to test build this but failing:
> >
> > 1. uninstalled gtk2-devel, which removed several other packages
> >
> > 2. installed gtk3-devel, which installed several other packages
> >
> > 3.:
> >
> > Auto-detecting system features:
> > ...                         dwarf: [ on  ]
> > ...            dwarf_getlocations: [ on  ]
> > ...                         glibc: [ on  ]
> > ...                          gtk3: [ OFF ]
> > ...                        libbfd: [ on  ]
> > ...                libbfd-buildid: [ on  ]
> >
> > Looking at how that OFF is deduced:
> >
> > ⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-
> > Display all 150 possibilities? (y or n)
> > ⬢[acme@toolbox perf]$ cat /tmp/build/perf/feature/test-all.make.output
> > In file included from test-all.c:74:
> > test-gtk3.c:3:10: fatal error: gtk/gtk.h: No such file or directory
> >     3 | #include <gtk/gtk.h>
> >       |          ^~~~~~~~~~~
> > compilation terminated.
> > ⬢[acme@toolbox perf]$
> >
> > ⬢[acme@toolbox perf]$ find /usr/include -name gtk.h
> > /usr/include/gtk-3.0/gtk/gtk.h
> > ⬢[acme@toolbox perf]$ rpm -qf /usr/include/gtk-3.0/gtk/gtk.h
> > gtk3-devel-3.24.31-2.fc35.x86_64
> > ⬢[acme@toolbox perf]$
> >
> > And that pkg-config line produces:
> >
> > ⬢[acme@toolbox perf]$ pkg-config --libs --cflags gtk+-3.0
> > -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
> > ⬢[acme@toolbox perf]$
> >
> > I'm testing this on fedora 35 silverblue, in a perf build container:
> >
> > ⬢[acme@toolbox perf]$ rpm -qa | grep gtk
> > gtk-update-icon-cache-3.24.31-2.fc35.x86_64
> > libcanberra-gtk3-0.30-27.fc35.x86_64
> > gtk3-3.24.31-2.fc35.x86_64
> > libcanberra-gtk2-0.30-27.fc35.x86_64
> > gtk2-2.24.33-7.fc35.x86_64
> > gtk3-devel-3.24.31-2.fc35.x86_64
> > ⬢[acme@toolbox perf]$
> >
> > Ideas?
> 
> Just to be clear, are you building with 'GTK3=1 make'? Since commit

No, I'm not, as I first test without enabling it, and in that case
test-all.c is now failing, since these lines were added there:

diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 5ffafb967b6e..5ec093498cfc 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -70,6 +70,14 @@
 # include "test-libslang.c"
 #undef main

+#define main main_test_gtk3
+# include "test-gtk3.c"
+#undef main
+
+#define main main_test_gtk3_infobar
+# include "test-gtk3-infobar.c"
+#undef main
+
 #define main main_test_libbfd
 # include "test-libbfd.c"
 #undef main
@@ -187,6 +195,8 @@ int main(int argc, char *argv[])
        main_test_libelf_getshdrstrndx();
        main_test_libunwind();
        main_test_libslang();
+	main_test_gtk3(argc, argv);
+	main_test_gtk3_infobar(argc, argv);
        main_test_libbfd();
        main_test_libbfd_buildid();
        main_test_backtrace();
diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk3-infobar.c

------------

test-all.c is what we expect to be enabled in most places, i.e. that it
will build successfully and we then don't have to test the features one
by one, speeding up the process.

So please don't add those entries in tools/build/feature/test-all.c.

After the common case is tested and doesn't regress, we can move on to
test with explicitely enabling the GTK code, ok?

- Arnaldo


> 4751bddd3f98 ("perf tools: Make GTK2 support opt-in") it's required to
> enable GTK support explicitly. (IMO, leaving it disabled by default
> makes sense to me, given some of the problems)

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2022-04-15  5:00 [PATCH] tools: port perf ui from GTK 2 to GTK 3 Matt Turner
  2022-04-16 14:55 ` Ian Rogers
  2022-04-20 17:08 ` Arnaldo Carvalho de Melo
@ 2022-10-19 23:29 ` Matt Turner
  2022-10-31 14:02   ` Matt Turner
  2022-10-31 19:03   ` Namhyung Kim
  2 siblings, 2 replies; 11+ messages in thread
From: Matt Turner @ 2022-10-19 23:29 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa, Matt Turner

From: Jelle van der Waa <jvanderwaa@redhat.com>

GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
API functions. gtk_tree_view_set_rules_hint is no longer required since
theme's are now responsible to handle this, gtk_vbox_new is deprecated
and replaced by passing the orientation to gtk_box_new. Apart from these
changes the accessing of the screen changed in GTK which requires using
new functions for getting geometry. Lastly the GTK_STOCK_OK define is
deprecated in GTK 3.

Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
Originally sent in 2019. I've rebased it and given it a test.

One problem I've noticed is that C++ symbol names are often broken.
E.g.:

(perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
markup due to error parsing markup: Error on line 1 char 95:
“std::char_traits<char” is not a valid name: “<”

Presumably we need to call g_markup_escape_text() somewhere, but I
struggled to find the right place.

Without the patch, the GTK-2 version repeatedly segfaults, so this is an
improvement regardless.

v2: Dropped changes to test-all.c. I don't know how to build that
    apparently.

 tools/build/Makefile.feature                  |  5 +++--
 tools/build/feature/Makefile                  | 12 +++++-----
 ...est-gtk2-infobar.c => test-gtk3-infobar.c} |  0
 .../feature/{test-gtk2.c => test-gtk3.c}      |  0
 tools/perf/Documentation/perf-report.txt      |  2 +-
 tools/perf/Makefile                           |  2 +-
 tools/perf/Makefile.config                    | 22 +++++++++----------
 tools/perf/Makefile.perf                      |  6 ++---
 tools/perf/builtin-report.c                   |  2 +-
 tools/perf/builtin-version.c                  |  1 +
 tools/perf/tests/make                         | 12 +++++-----
 tools/perf/ui/gtk/annotate.c                  |  2 +-
 tools/perf/ui/gtk/browser.c                   | 16 ++++++++------
 tools/perf/ui/gtk/hists.c                     |  6 +----
 tools/perf/ui/gtk/progress.c                  |  2 +-
 tools/perf/ui/setup.c                         |  2 +-
 16 files changed, 46 insertions(+), 46 deletions(-)
 rename tools/build/feature/{test-gtk2-infobar.c => test-gtk3-infobar.c} (100%)
 rename tools/build/feature/{test-gtk2.c => test-gtk3.c} (100%)

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 57619f240b56..967b8be96b65 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -80,8 +80,8 @@ FEATURE_TESTS_EXTRA :=                  \
          compile-32                     \
          compile-x32                    \
          cplus-demangle                 \
-         gtk2                           \
-         gtk2-infobar                   \
+         gtk3                           \
+         gtk3-infobar                   \
          hello                          \
          libbabeltrace                  \
          libbfd-liberty                 \
@@ -119,6 +119,7 @@ FEATURE_DISPLAY ?=              \
          dwarf                  \
          dwarf_getlocations     \
          glibc                  \
+         gtk3                   \
          libbfd                 \
          libbfd-buildid		\
          libcap                 \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 04b07ff88234..bd96b0628836 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -11,8 +11,8 @@ FILES=                                          \
          test-fortify-source.bin                \
          test-get_current_dir_name.bin          \
          test-glibc.bin                         \
-         test-gtk2.bin                          \
-         test-gtk2-infobar.bin                  \
+         test-gtk3.bin                          \
+         test-gtk3-infobar.bin                  \
          test-hello.bin                         \
          test-libaudit.bin                      \
          test-libbfd.bin                        \
@@ -214,11 +214,11 @@ $(OUTPUT)test-libtracefs.bin:
 $(OUTPUT)test-libcrypto.bin:
 	$(BUILD) -lcrypto
 
-$(OUTPUT)test-gtk2.bin:
-	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
+$(OUTPUT)test-gtk3.bin:
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
 
-$(OUTPUT)test-gtk2-infobar.bin:
-	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
+$(OUTPUT)test-gtk3-infobar.bin:
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
 
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk3-infobar.c
similarity index 100%
rename from tools/build/feature/test-gtk2-infobar.c
rename to tools/build/feature/test-gtk3-infobar.c
diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk3.c
similarity index 100%
rename from tools/build/feature/test-gtk2.c
rename to tools/build/feature/test-gtk3.c
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 4533db2ee56b..2df20623943f 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -315,7 +315,7 @@ OPTIONS
 	requires a tty, if one is not present, as when piping to other
 	commands, the stdio interface is used.
 
---gtk:: Use the GTK2 interface.
+--gtk:: Use the GTK3 interface.
 
 -k::
 --vmlinux=<file>::
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f3fe360a35c6..ea3fb4657a91 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -100,7 +100,7 @@ clean:
 # make -C tools/perf -f tests/make
 #
 build-test:
-	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk2 out
+	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg make_static make_with_gtk3 out
 
 build-test-tarball:
 	@$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 6fd4b1384b97..281fbcb97b58 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -808,20 +808,20 @@ ifndef NO_SLANG
   endif
 endif
 
-ifdef GTK2
-  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
-  $(call feature_check,gtk2)
-  ifneq ($(feature-gtk2), 1)
-    msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
-    NO_GTK2 := 1
+ifdef GTK3
+  FLAGS_GTK3=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-3.0 2>/dev/null)
+  $(call feature_check,gtk3)
+  ifneq ($(feature-gtk3), 1)
+    msg := $(warning GTK3 not found, disables GTK3 support. Please install gtk3-devel or libgtk3.0-dev);
+    NO_GTK3 := 1
   else
-    $(call feature_check,gtk2-infobar)
-    ifeq ($(feature-gtk2-infobar), 1)
+    $(call feature_check,gtk3-infobar)
+    ifeq ($(feature-gtk3-infobar), 1)
       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
     endif
-    CFLAGS += -DHAVE_GTK2_SUPPORT
-    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
-    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
+    CFLAGS += -DHAVE_GTK3_SUPPORT
+    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-3.0 2>/dev/null)
+    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0 2>/dev/null)
     EXTLIBS += -ldl
   endif
 endif
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index a432e59afc42..056f29ecaef1 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -48,7 +48,7 @@ include ../scripts/utilities.mak
 #
 # Define NO_SLANG if you do not want TUI support.
 #
-# Define GTK2 if you want GTK+ GUI support.
+# Define GTK3 if you want GTK+ GUI support.
 #
 # Define NO_DEMANGLE if you do not want C++ symbol demangling.
 #
@@ -403,7 +403,7 @@ ifneq ($(OUTPUT),)
   CFLAGS += -I$(OUTPUT)
 endif
 
-ifdef GTK2
+ifdef GTK3
   ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
   GTK_IN := $(OUTPUT)gtk-in.o
 endif
@@ -928,7 +928,7 @@ check: $(OUTPUT)common-cmds.h
 
 ### Installation rules
 
-ifdef GTK2
+ifdef GTK3
 install-gtk: $(OUTPUT)libperf-gtk.so
 	$(call QUIET_INSTALL, 'GTK UI') \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 8361890176c2..4e0caf3d3061 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1247,7 +1247,7 @@ int cmd_report(int argc, const char **argv)
 	OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
 #endif
 #ifdef HAVE_GTK2_SUPPORT
-	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
+	OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK3 interface"),
 #endif
 	OPT_BOOLEAN(0, "stdio", &report.use_stdio,
 		    "Use the stdio interface"),
diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index a71f491224da..a35e06ca449d 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -60,6 +60,7 @@ static void library_status(void)
 	STATUS(HAVE_DWARF_SUPPORT, dwarf);
 	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
 	STATUS(HAVE_GLIBC_SUPPORT, glibc);
+	STATUS(HAVE_GTK3_SUPPORT, gtk3);
 #ifndef HAVE_SYSCALL_TABLE_SUPPORT
 	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
 #endif
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index da013e90a945..cb959dccbe9d 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -72,8 +72,8 @@ make_no_libpython   := NO_LIBPYTHON=1
 make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
 make_no_newt        := NO_NEWT=1
 make_no_slang       := NO_SLANG=1
-make_no_gtk2        := NO_GTK2=1
-make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
+make_no_gtk3        := NO_GTK3=1
+make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK3=1
 make_no_demangle    := NO_DEMANGLE=1
 make_no_libelf      := NO_LIBELF=1
 make_no_libunwind   := NO_LIBUNWIND=1
@@ -93,7 +93,7 @@ make_no_sdt	    := NO_SDT=1
 make_no_syscall_tbl := NO_SYSCALL_TABLE=1
 make_with_clangllvm := LIBCLANGLLVM=1
 make_with_libpfm4   := LIBPFM4=1
-make_with_gtk2      := GTK2=1
+make_with_gtk3      := GTK3=1
 make_tags           := tags
 make_cscope         := cscope
 make_help           := help
@@ -113,7 +113,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
 make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
 
 # all the NO_* variable combined
-make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
+make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK3=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
@@ -138,7 +138,7 @@ run += make_no_libpython
 run += make_no_scripts
 run += make_no_newt
 run += make_no_slang
-run += make_no_gtk2
+run += make_no_gtk3
 run += make_no_ui
 run += make_no_demangle
 run += make_no_libelf
@@ -312,7 +312,7 @@ $(run):
 	$(call test,$@) && \
 	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
 
-make_with_gtk2:
+make_with_gtk3:
 	$(call clean)
 	@TMP_DEST=$$(mktemp -d); \
 	cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 0a50e962f9a3..efd380f124aa 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -208,7 +208,7 @@ static int symbol__gtk_annotate(struct map_symbol *ms, struct evsel *evsel,
 		if (!pgctx)
 			return -1;
 
-		vbox = gtk_vbox_new(FALSE, 0);
+		vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 		notebook = gtk_notebook_new();
 		pgctx->notebook = notebook;
 
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index 8f3e43d148a8..6fd85b5325ba 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -13,19 +13,21 @@ void perf_gtk__signal(int sig)
 	psignal(sig, "perf");
 }
 
-void perf_gtk__resize_window(GtkWidget *window)
+void perf_gtk__resize_window(GtkWidget *widget)
 {
 	GdkRectangle rect;
-	GdkScreen *screen;
-	int monitor;
+	GdkMonitor *monitor;
+	GdkDisplay *display;
+	GdkWindow *window;
 	int height;
 	int width;
 
-	screen = gtk_widget_get_screen(window);
+	display = gdk_display_get_default();
+	window = gtk_widget_get_window(widget);
 
-	monitor = gdk_screen_get_monitor_at_window(screen, window->window);
+	monitor = gdk_display_get_monitor_at_window(display, window);
 
-	gdk_screen_get_monitor_geometry(screen, monitor, &rect);
+	gdk_monitor_get_geometry(monitor, &rect);
 
 	width	= rect.width * 3 / 4;
 	height	= rect.height * 3 / 4;
@@ -58,7 +60,7 @@ GtkWidget *perf_gtk__setup_info_bar(void)
 	content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
 	gtk_container_add(GTK_CONTAINER(content_area), label);
 
-	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
+	gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), "_OK",
 				GTK_RESPONSE_OK);
 	g_signal_connect(info_bar, "response",
 			 G_CALLBACK(gtk_widget_hide), NULL);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index c83be2d57f7e..5aa2655c7a0a 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -395,8 +395,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
 		}
 	}
 
-	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
-
 	g_signal_connect(view, "row-activated",
 			 G_CALLBACK(on_row_activated), NULL);
 	gtk_container_add(GTK_CONTAINER(window), view);
@@ -583,8 +581,6 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
 	perf_gtk__add_hierarchy_entries(hists, &hists->entries, store,
 					NULL, &hpp, min_pcnt);
 
-	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
-
 	g_signal_connect(view, "row-activated",
 			 G_CALLBACK(on_row_activated), NULL);
 	gtk_container_add(GTK_CONTAINER(window), view);
@@ -616,7 +612,7 @@ int evlist__gtk_browse_hists(struct evlist *evlist, const char *help,
 	if (!pgctx)
 		return -1;
 
-	vbox = gtk_vbox_new(FALSE, 0);
+	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 
 	notebook = gtk_notebook_new();
 
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index eea6fcde518a..aaa7e7f6e4aa 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -13,7 +13,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
 	char buf[1024];
 
 	if (dialog == NULL) {
-		GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
+		GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
 		GtkWidget *label = gtk_label_new(p->title);
 
 		dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 25ded88801a3..cbcadf4cb288 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -13,7 +13,7 @@ int use_browser = -1;
 
 #define PERF_GTK_DSO "libperf-gtk.so"
 
-#ifdef HAVE_GTK2_SUPPORT
+#ifdef HAVE_GTK3_SUPPORT
 
 static int setup_gtk_browser(void)
 {
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2022-10-19 23:29 ` [PATCH v2] " Matt Turner
@ 2022-10-31 14:02   ` Matt Turner
  2022-12-02 21:11     ` Matt Turner
  2022-10-31 19:03   ` Namhyung Kim
  1 sibling, 1 reply; 11+ messages in thread
From: Matt Turner @ 2022-10-31 14:02 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa

On Wed, Oct 19, 2022 at 7:30 PM Matt Turner <mattst88@gmail.com> wrote:
>
> From: Jelle van der Waa <jvanderwaa@redhat.com>
>
> GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> API functions. gtk_tree_view_set_rules_hint is no longer required since
> theme's are now responsible to handle this, gtk_vbox_new is deprecated
> and replaced by passing the orientation to gtk_box_new. Apart from these
> changes the accessing of the screen changed in GTK which requires using
> new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> deprecated in GTK 3.
>
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
> Originally sent in 2019. I've rebased it and given it a test.
>
> One problem I've noticed is that C++ symbol names are often broken.
> E.g.:
>
> (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> markup due to error parsing markup: Error on line 1 char 95:
> “std::char_traits<char” is not a valid name: “<”
>
> Presumably we need to call g_markup_escape_text() somewhere, but I
> struggled to find the right place.
>
> Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> improvement regardless.
>
> v2: Dropped changes to test-all.c. I don't know how to build that
>     apparently.


Arnaldo, does this work better for you?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2022-10-19 23:29 ` [PATCH v2] " Matt Turner
  2022-10-31 14:02   ` Matt Turner
@ 2022-10-31 19:03   ` Namhyung Kim
  1 sibling, 0 replies; 11+ messages in thread
From: Namhyung Kim @ 2022-10-31 19:03 UTC (permalink / raw)
  To: Matt Turner
  Cc: linux-perf-users, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Jelle van der Waa

Hello,

On Wed, Oct 19, 2022 at 4:30 PM Matt Turner <mattst88@gmail.com> wrote:
>
> From: Jelle van der Waa <jvanderwaa@redhat.com>
>
> GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> API functions. gtk_tree_view_set_rules_hint is no longer required since
> theme's are now responsible to handle this, gtk_vbox_new is deprecated
> and replaced by passing the orientation to gtk_box_new. Apart from these
> changes the accessing of the screen changed in GTK which requires using
> new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> deprecated in GTK 3.
>
> Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
> Originally sent in 2019. I've rebased it and given it a test.
>
> One problem I've noticed is that C++ symbol names are often broken.
> E.g.:
>
> (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> markup due to error parsing markup: Error on line 1 char 95:
> “std::char_traits<char” is not a valid name: “<”
>
> Presumably we need to call g_markup_escape_text() somewhere, but I
> struggled to find the right place.
>
> Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> improvement regardless.

Thanks for working on this.

>
> v2: Dropped changes to test-all.c. I don't know how to build that
>     apparently.
>
>  tools/build/Makefile.feature                  |  5 +++--
>  tools/build/feature/Makefile                  | 12 +++++-----
>  ...est-gtk2-infobar.c => test-gtk3-infobar.c} |  0
>  .../feature/{test-gtk2.c => test-gtk3.c}      |  0
>  tools/perf/Documentation/perf-report.txt      |  2 +-
>  tools/perf/Makefile                           |  2 +-
>  tools/perf/Makefile.config                    | 22 +++++++++----------
>  tools/perf/Makefile.perf                      |  6 ++---
>  tools/perf/builtin-report.c                   |  2 +-
>  tools/perf/builtin-version.c                  |  1 +
>  tools/perf/tests/make                         | 12 +++++-----
>  tools/perf/ui/gtk/annotate.c                  |  2 +-
>  tools/perf/ui/gtk/browser.c                   | 16 ++++++++------
>  tools/perf/ui/gtk/hists.c                     |  6 +----
>  tools/perf/ui/gtk/progress.c                  |  2 +-
>  tools/perf/ui/setup.c                         |  2 +-
>  16 files changed, 46 insertions(+), 46 deletions(-)
>  rename tools/build/feature/{test-gtk2-infobar.c => test-gtk3-infobar.c} (100%)
>  rename tools/build/feature/{test-gtk2.c => test-gtk3.c} (100%)
>
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 57619f240b56..967b8be96b65 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -80,8 +80,8 @@ FEATURE_TESTS_EXTRA :=                  \
>           compile-32                     \
>           compile-x32                    \
>           cplus-demangle                 \
> -         gtk2                           \
> -         gtk2-infobar                   \
> +         gtk3                           \
> +         gtk3-infobar                   \

I don't think gtk3-inforbar check is necessary anymore.  IIRC the infobar
was introduced in the middle of gtk2 so it needs to check if the current
version supports it or not.  But I guess gtk3 should support it by default.

Thanks,
Namhyung


>           hello                          \
>           libbabeltrace                  \
>           libbfd-liberty                 \
> @@ -119,6 +119,7 @@ FEATURE_DISPLAY ?=              \
>           dwarf                  \
>           dwarf_getlocations     \
>           glibc                  \
> +         gtk3                   \
>           libbfd                 \
>           libbfd-buildid                \
>           libcap                 \

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2022-10-31 14:02   ` Matt Turner
@ 2022-12-02 21:11     ` Matt Turner
  2023-01-13 17:45       ` Matt Turner
  0 siblings, 1 reply; 11+ messages in thread
From: Matt Turner @ 2022-12-02 21:11 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa

On Mon, Oct 31, 2022 at 10:02 AM Matt Turner <mattst88@gmail.com> wrote:
>
> On Wed, Oct 19, 2022 at 7:30 PM Matt Turner <mattst88@gmail.com> wrote:
> >
> > From: Jelle van der Waa <jvanderwaa@redhat.com>
> >
> > GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> > API functions. gtk_tree_view_set_rules_hint is no longer required since
> > theme's are now responsible to handle this, gtk_vbox_new is deprecated
> > and replaced by passing the orientation to gtk_box_new. Apart from these
> > changes the accessing of the screen changed in GTK which requires using
> > new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> > deprecated in GTK 3.
> >
> > Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > ---
> > Originally sent in 2019. I've rebased it and given it a test.
> >
> > One problem I've noticed is that C++ symbol names are often broken.
> > E.g.:
> >
> > (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> > markup due to error parsing markup: Error on line 1 char 95:
> > “std::char_traits<char” is not a valid name: “<”
> >
> > Presumably we need to call g_markup_escape_text() somewhere, but I
> > struggled to find the right place.
> >
> > Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> > improvement regardless.
> >
> > v2: Dropped changes to test-all.c. I don't know how to build that
> >     apparently.
>
>
> Arnaldo, does this work better for you?

Ping²

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2022-12-02 21:11     ` Matt Turner
@ 2023-01-13 17:45       ` Matt Turner
  2023-01-13 18:20         ` Ian Rogers
  0 siblings, 1 reply; 11+ messages in thread
From: Matt Turner @ 2023-01-13 17:45 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa

On Fri, Dec 2, 2022 at 4:11 PM Matt Turner <mattst88@gmail.com> wrote:
>
> On Mon, Oct 31, 2022 at 10:02 AM Matt Turner <mattst88@gmail.com> wrote:
> >
> > On Wed, Oct 19, 2022 at 7:30 PM Matt Turner <mattst88@gmail.com> wrote:
> > >
> > > From: Jelle van der Waa <jvanderwaa@redhat.com>
> > >
> > > GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> > > API functions. gtk_tree_view_set_rules_hint is no longer required since
> > > theme's are now responsible to handle this, gtk_vbox_new is deprecated
> > > and replaced by passing the orientation to gtk_box_new. Apart from these
> > > changes the accessing of the screen changed in GTK which requires using
> > > new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> > > deprecated in GTK 3.
> > >
> > > Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> > > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > > ---
> > > Originally sent in 2019. I've rebased it and given it a test.
> > >
> > > One problem I've noticed is that C++ symbol names are often broken.
> > > E.g.:
> > >
> > > (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> > > markup due to error parsing markup: Error on line 1 char 95:
> > > “std::char_traits<char” is not a valid name: “<”
> > >
> > > Presumably we need to call g_markup_escape_text() somewhere, but I
> > > struggled to find the right place.
> > >
> > > Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> > > improvement regardless.
> > >
> > > v2: Dropped changes to test-all.c. I don't know how to build that
> > >     apparently.
> >
> >
> > Arnaldo, does this work better for you?
>
> Ping²

Ping³

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] tools: port perf ui from GTK 2 to GTK 3
  2023-01-13 17:45       ` Matt Turner
@ 2023-01-13 18:20         ` Ian Rogers
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Rogers @ 2023-01-13 18:20 UTC (permalink / raw)
  To: Matt Turner
  Cc: linux-perf-users, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jelle van der Waa

On Fri, Jan 13, 2023 at 9:53 AM Matt Turner <mattst88@gmail.com> wrote:
>
> On Fri, Dec 2, 2022 at 4:11 PM Matt Turner <mattst88@gmail.com> wrote:
> >
> > On Mon, Oct 31, 2022 at 10:02 AM Matt Turner <mattst88@gmail.com> wrote:
> > >
> > > On Wed, Oct 19, 2022 at 7:30 PM Matt Turner <mattst88@gmail.com> wrote:
> > > >
> > > > From: Jelle van der Waa <jvanderwaa@redhat.com>
> > > >
> > > > GTK 2 is a legacy API and the newer version is GTK 3 which changes a few
> > > > API functions. gtk_tree_view_set_rules_hint is no longer required since
> > > > theme's are now responsible to handle this, gtk_vbox_new is deprecated
> > > > and replaced by passing the orientation to gtk_box_new. Apart from these
> > > > changes the accessing of the screen changed in GTK which requires using
> > > > new functions for getting geometry. Lastly the GTK_STOCK_OK define is
> > > > deprecated in GTK 3.
> > > >
> > > > Signed-off-by: Jelle van der Waa <jvanderwaa@redhat.com>
> > > > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > > > ---
> > > > Originally sent in 2019. I've rebased it and given it a test.
> > > >
> > > > One problem I've noticed is that C++ symbol names are often broken.
> > > > E.g.:
> > > >
> > > > (perf:3254940): Gtk-WARNING **: 21:47:46.663: Failed to set text from
> > > > markup due to error parsing markup: Error on line 1 char 95:
> > > > “std::char_traits<char” is not a valid name: “<”
> > > >
> > > > Presumably we need to call g_markup_escape_text() somewhere, but I
> > > > struggled to find the right place.
> > > >
> > > > Without the patch, the GTK-2 version repeatedly segfaults, so this is an
> > > > improvement regardless.
> > > >
> > > > v2: Dropped changes to test-all.c. I don't know how to build that
> > > >     apparently.
> > >
> > >
> > > Arnaldo, does this work better for you?
> >
> > Ping²
>
> Ping³

Hi Matt,

did you see Namhyung's comment? It looks possible that we can drop the
infobar feature check for GTK3, which would help simplify the builds.
It seems to make sense to fold that into this change, or to have it as
a patch on top of this. Wdyt?

Thanks,
Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-01-13 18:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  5:00 [PATCH] tools: port perf ui from GTK 2 to GTK 3 Matt Turner
2022-04-16 14:55 ` Ian Rogers
2022-04-20 17:08 ` Arnaldo Carvalho de Melo
2022-04-21 21:02   ` Matt Turner
2022-04-22 19:01     ` Arnaldo Carvalho de Melo
2022-10-19 23:29 ` [PATCH v2] " Matt Turner
2022-10-31 14:02   ` Matt Turner
2022-12-02 21:11     ` Matt Turner
2023-01-13 17:45       ` Matt Turner
2023-01-13 18:20         ` Ian Rogers
2022-10-31 19:03   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).