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