 0985a94891
			
		
	
	
	0985a94891
	
	
	
		
			
			Use helpline for printing error/debug messages. The code resembles a TUI counter part and only print the first line of the message. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1345104894-14205-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
		
			
				
	
	
		
			56 lines
		
	
	
	
		
			1.1 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
	
		
			1.1 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <stdio.h>
 | |
| #include <string.h>
 | |
| 
 | |
| #include "gtk.h"
 | |
| #include "../ui.h"
 | |
| #include "../helpline.h"
 | |
| #include "../../util/debug.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 struct ui_helpline gtk_helpline_fns = {
 | |
| 	.pop	= gtk_helpline_pop,
 | |
| 	.push	= gtk_helpline_push,
 | |
| };
 | |
| 
 | |
| void perf_gtk__init_helpline(void)
 | |
| {
 | |
| 	helpline_fns = >k_helpline_fns;
 | |
| }
 | |
| 
 | |
| int perf_gtk__show_helpline(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;
 | |
| }
 |