aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-03-30 14:43:09 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-04-09 11:56:17 -0400
commit7f5dd7b6e1aa1ea12b8d4d802b8aadd501876ba5 (patch)
treecd149883622003c246a44ee781f9f921c036e054
parentf609f9171ef951c18e01f88ce72b9c58995f7996 (diff)
kernelshark: Add dialog helper
Add trace-dialog.c to include a trace_show_help() and trace_dialog() helpers. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--Makefile13
-rw-r--r--trace-compat.c9
-rw-r--r--trace-compat.h2
-rw-r--r--trace-dialog.c79
-rw-r--r--trace-gui.h38
5 files changed, 134 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index d13edec..7402ae1 100644
--- a/Makefile
+++ b/Makefile
@@ -213,14 +213,13 @@ $(obj)/%.o: $(src)/%.c
213%.o: $(src)/%.c 213%.o: $(src)/%.c
214 $(Q)$(call check_gui) 214 $(Q)$(call check_gui)
215 215
216TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-hash.o trace-dialog.o
216TRACE_CMD_OBJS = trace-cmd.o trace-usage.o trace-read.o trace-split.o trace-listen.o 217TRACE_CMD_OBJS = trace-cmd.o trace-usage.o trace-read.o trace-split.o trace-listen.o
217TRACE_VIEW_OBJS = trace-view.o trace-view-store.o trace-filter.o trace-compat.o \ 218TRACE_VIEW_OBJS = trace-view.o trace-view-store.o
218 trace-hash.o 219TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o
219TRACE_GRAPH_OBJS = trace-graph.o trace-compat.o trace-hash.o trace-filter.o \ 220TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS)
220 trace-plot.o trace-plot-cpu.o trace-plot-task.o 221TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS)
221TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) 222KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) kernel-shark.o
222TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS)
223KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) kernel-shark.o
224 223
225PEVENT_LIB_OBJS = parse-events.o trace-seq.o parse-filter.o 224PEVENT_LIB_OBJS = parse-events.o trace-seq.o parse-filter.o
226TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \ 225TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \
diff --git a/trace-compat.c b/trace-compat.c
index 5082757..a1f2113 100644
--- a/trace-compat.c
+++ b/trace-compat.c
@@ -22,6 +22,9 @@
22 * Linux Kernel that were written by Frederic Weisbecker. 22 * Linux Kernel that were written by Frederic Weisbecker.
23 */ 23 */
24#include "trace-compat.h" 24#include "trace-compat.h"
25#include "trace-gui.h"
26
27#include <gdk/gdk.h>
25 28
26#if GTK_VERSION < CALC_GTK_VERSION(2,18,0) 29#if GTK_VERSION < CALC_GTK_VERSION(2,18,0)
27 30
@@ -70,6 +73,12 @@ gdouble gtk_adjustment_get_lower(GtkAdjustment *adj)
70 return adj->lower; 73 return adj->lower;
71} 74}
72 75
76gboolean gtk_show_uri(GdkScreen *screen, const gchar *uri,
77 guint32 timestamp, GError **error)
78{
79 return FALSE;
80}
81
73#endif /* version < 2.14.0 */ 82#endif /* version < 2.14.0 */
74 83
75#if GTK_VERSION < CALC_GTK_VERSION(2,12,0) 84#if GTK_VERSION < CALC_GTK_VERSION(2,12,0)
diff --git a/trace-compat.h b/trace-compat.h
index 1c9126d..2eed192 100644
--- a/trace-compat.h
+++ b/trace-compat.h
@@ -43,6 +43,8 @@ void gtk_menu_item_set_label(GtkMenuItem *menu_item, const gchar *label);
43gdouble gtk_adjustment_get_page_size(GtkAdjustment *adj); 43gdouble gtk_adjustment_get_page_size(GtkAdjustment *adj);
44gdouble gtk_adjustment_get_upper(GtkAdjustment *adj); 44gdouble gtk_adjustment_get_upper(GtkAdjustment *adj);
45gdouble gtk_adjustment_get_lower(GtkAdjustment *adj); 45gdouble gtk_adjustment_get_lower(GtkAdjustment *adj);
46gboolean gtk_show_uri(GdkScreen *screen, const gchar *uri,
47 guint32 timestamp, GError **error);
46 48
47#endif /* version < 2.14.0 */ 49#endif /* version < 2.14.0 */
48 50
diff --git a/trace-dialog.c b/trace-dialog.c
new file mode 100644
index 0000000..65d184d
--- /dev/null
+++ b/trace-dialog.c
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 *
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License (not later!)
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21#include <gtk/gtk.h>
22#include <stdlib.h>
23#include <string.h>
24#include <stdarg.h>
25#include <ctype.h>
26
27#include "trace-compat.h"
28#include "trace-gui.h"
29
30#define DIALOG_WIDTH 400
31#define DIALOG_HEIGHT 600
32
33void trace_show_help(GtkWidget *window, const gchar *link, GError **error)
34{
35#if GTK_VERSION < CALC_GTK_VERSION(2,14,0)
36 trace_dialog(GTK_WINDOW(window), TRACE_GUI_WARNING,
37 "This version of GTK+ does not implement gtk_show_uri.\n"
38 "Please upgrade your GTK and recompile");
39#else
40 gtk_show_uri(gtk_widget_get_screen(GTK_WIDGET(window)),
41 link,
42 GDK_CURRENT_TIME,
43 error);
44#endif
45}
46
47void trace_dialog(GtkWindow *parent, enum trace_dialog_type type,
48 gchar *message, ...)
49{
50 GtkWidget *dialog;
51 GtkMessageType mtype;
52 gchar *str;
53 va_list ap;
54
55 switch (type) {
56 case TRACE_GUI_INFO:
57 mtype = GTK_MESSAGE_INFO;
58 break;
59 case TRACE_GUI_WARNING:
60 mtype = GTK_MESSAGE_WARNING;
61 break;
62 case TRACE_GUI_ERROR:
63 mtype = GTK_MESSAGE_ERROR;
64 break;
65 }
66
67 va_start(ap, message);
68 str = g_strdup_vprintf(message, ap);
69 va_end(ap);
70
71 dialog = gtk_message_dialog_new(parent,
72 GTK_DIALOG_DESTROY_WITH_PARENT,
73 mtype,
74 GTK_BUTTONS_CLOSE,
75 "%s", str);
76 g_free(str);
77 gtk_dialog_run(GTK_DIALOG(dialog));
78 gtk_widget_destroy(dialog);
79}
diff --git a/trace-gui.h b/trace-gui.h
new file mode 100644
index 0000000..97b8e41
--- /dev/null
+++ b/trace-gui.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 *
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License (not later!)
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21#ifndef _TRACE_GUI
22#define _TRACE_GUI
23
24#include <gtk/gtk.h>
25
26enum trace_dialog_type {
27 TRACE_GUI_INFO,
28 TRACE_GUI_WARNING,
29 TRACE_GUI_ERROR,
30};
31
32void trace_show_help(GtkWidget *window, const gchar *link, GError **error);
33
34void trace_dialog(GtkWindow *parent, enum trace_dialog_type type,
35 gchar *message, ...);
36
37
38#endif /* _TRACE_GUI */