diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-03-30 14:43:09 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-04-09 11:56:17 -0400 |
| commit | 7f5dd7b6e1aa1ea12b8d4d802b8aadd501876ba5 (patch) | |
| tree | cd149883622003c246a44ee781f9f921c036e054 | |
| parent | f609f9171ef951c18e01f88ce72b9c58995f7996 (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-- | Makefile | 13 | ||||
| -rw-r--r-- | trace-compat.c | 9 | ||||
| -rw-r--r-- | trace-compat.h | 2 | ||||
| -rw-r--r-- | trace-dialog.c | 79 | ||||
| -rw-r--r-- | trace-gui.h | 38 |
5 files changed, 134 insertions, 7 deletions
| @@ -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 | ||
| 216 | TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-hash.o trace-dialog.o | ||
| 216 | TRACE_CMD_OBJS = trace-cmd.o trace-usage.o trace-read.o trace-split.o trace-listen.o | 217 | TRACE_CMD_OBJS = trace-cmd.o trace-usage.o trace-read.o trace-split.o trace-listen.o |
| 217 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o trace-filter.o trace-compat.o \ | 218 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o |
| 218 | trace-hash.o | 219 | TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o |
| 219 | TRACE_GRAPH_OBJS = trace-graph.o trace-compat.o trace-hash.o trace-filter.o \ | 220 | TRACE_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 | 221 | TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) |
| 221 | TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) | 222 | KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) kernel-shark.o |
| 222 | TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) | ||
| 223 | KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) kernel-shark.o | ||
| 224 | 223 | ||
| 225 | PEVENT_LIB_OBJS = parse-events.o trace-seq.o parse-filter.o | 224 | PEVENT_LIB_OBJS = parse-events.o trace-seq.o parse-filter.o |
| 226 | TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \ | 225 | TCMD_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 | ||
| 76 | gboolean 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); | |||
| 43 | gdouble gtk_adjustment_get_page_size(GtkAdjustment *adj); | 43 | gdouble gtk_adjustment_get_page_size(GtkAdjustment *adj); |
| 44 | gdouble gtk_adjustment_get_upper(GtkAdjustment *adj); | 44 | gdouble gtk_adjustment_get_upper(GtkAdjustment *adj); |
| 45 | gdouble gtk_adjustment_get_lower(GtkAdjustment *adj); | 45 | gdouble gtk_adjustment_get_lower(GtkAdjustment *adj); |
| 46 | gboolean 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 | |||
| 33 | void 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 | |||
| 47 | void 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 | |||
| 26 | enum trace_dialog_type { | ||
| 27 | TRACE_GUI_INFO, | ||
| 28 | TRACE_GUI_WARNING, | ||
| 29 | TRACE_GUI_ERROR, | ||
| 30 | }; | ||
| 31 | |||
| 32 | void trace_show_help(GtkWidget *window, const gchar *link, GError **error); | ||
| 33 | |||
| 34 | void trace_dialog(GtkWindow *parent, enum trace_dialog_type type, | ||
| 35 | gchar *message, ...); | ||
| 36 | |||
| 37 | |||
| 38 | #endif /* _TRACE_GUI */ | ||
