brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · 8ea9589 Raw
59 lines · c
1// SPDX-License-Identifier: GPL-2.02#include "gtk.h"3#include <stdio.h>4#include <string.h>5#include <linux/kernel.h>6 7#include "../ui.h"8#include "../helpline.h"9 10static void gtk_helpline_pop(void)11{12	if (!perf_gtk__is_active_context(pgctx))13		return;14 15	gtk_statusbar_pop(GTK_STATUSBAR(pgctx->statbar),16			  pgctx->statbar_ctx_id);17}18 19static void gtk_helpline_push(const char *msg)20{21	if (!perf_gtk__is_active_context(pgctx))22		return;23 24	gtk_statusbar_push(GTK_STATUSBAR(pgctx->statbar),25			   pgctx->statbar_ctx_id, msg);26}27 28static int gtk_helpline_show(const char *fmt, va_list ap)29{30	int ret;31	char *ptr;32	static int backlog;33 34	ret = vscnprintf(ui_helpline__current + backlog,35			 sizeof(ui_helpline__current) - backlog, fmt, ap);36	backlog += ret;37 38	/* only first line can be displayed */39	ptr = strchr(ui_helpline__current, '\n');40	if (ptr && (ptr - ui_helpline__current) <= backlog) {41		*ptr = '\0';42		ui_helpline__puts(ui_helpline__current);43		backlog = 0;44	}45 46	return ret;47}48 49static struct ui_helpline gtk_helpline_fns = {50	.pop	= gtk_helpline_pop,51	.push	= gtk_helpline_push,52	.show	= gtk_helpline_show,53};54 55void perf_gtk__init_helpline(void)56{57	helpline_fns = &gtk_helpline_fns;58}59