diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2011-02-16 16:12:53 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2011-02-21 20:42:06 -0500 |
| commit | 2f6c27bb3bd10f49bc37c8a7c8775920a401c7be (patch) | |
| tree | d7481fc033cd8f92997359641c73f8f5ed4c8afd | |
| parent | 2f535934aa9313a755323816810e1ef25a331484 (diff) | |
kernelshark: Add methods to change the parent window gui
Add trace_set_cursor() and trace_put_cursor() to set and unset
the cursor of the parent window.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-dialog.c | 32 | ||||
| -rw-r--r-- | trace-gui.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/trace-dialog.c b/trace-dialog.c index c585277..53e75d5 100644 --- a/trace-dialog.c +++ b/trace-dialog.c | |||
| @@ -38,6 +38,7 @@ static GtkWidget *statuspix; | |||
| 38 | static GString *statusstr; | 38 | static GString *statusstr; |
| 39 | 39 | ||
| 40 | static GtkWidget *parent_window; | 40 | static GtkWidget *parent_window; |
| 41 | static GdkCursor *parent_cursor; | ||
| 41 | 42 | ||
| 42 | static void (*alt_warning)(const char *fmt, va_list ap); | 43 | static void (*alt_warning)(const char *fmt, va_list ap); |
| 43 | 44 | ||
| @@ -88,6 +89,37 @@ void trace_dialog_register_window(GtkWidget *window) | |||
| 88 | parent_window = window; | 89 | parent_window = window; |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 92 | void trace_set_cursor(GdkCursorType type) | ||
| 93 | { | ||
| 94 | GdkWindow *window = GTK_WIDGET(parent_window)->window; | ||
| 95 | GdkCursor *cursor; | ||
| 96 | |||
| 97 | if (!parent_cursor) | ||
| 98 | parent_cursor = gdk_window_get_cursor(window); | ||
| 99 | else { | ||
| 100 | /* destroy the old one */ | ||
| 101 | cursor = gdk_window_get_cursor(window); | ||
| 102 | if (cursor && cursor != parent_cursor) | ||
| 103 | gdk_cursor_unref(cursor); | ||
| 104 | } | ||
| 105 | |||
| 106 | cursor = gdk_cursor_new(type); | ||
| 107 | if (!cursor) | ||
| 108 | die("Can't create cursor"); | ||
| 109 | gdk_window_set_cursor(window, cursor); | ||
| 110 | } | ||
| 111 | |||
| 112 | void trace_put_cursor(void) | ||
| 113 | { | ||
| 114 | GdkWindow *window = GTK_WIDGET(parent_window)->window; | ||
| 115 | GdkCursor *cursor; | ||
| 116 | |||
| 117 | cursor = gdk_window_get_cursor(window); | ||
| 118 | if (cursor && cursor != parent_cursor) | ||
| 119 | gdk_cursor_unref(cursor); | ||
| 120 | gdk_window_set_cursor(window, parent_cursor); | ||
| 121 | } | ||
| 122 | |||
| 91 | /** | 123 | /** |
| 92 | * trace_dialog_register_alt_warning - register an alternate function for warning() | 124 | * trace_dialog_register_alt_warning - register an alternate function for warning() |
| 93 | * @alt: the function to be called instead of warning. | 125 | * @alt: the function to be called instead of warning. |
diff --git a/trace-gui.h b/trace-gui.h index 6766f9d..c55940e 100644 --- a/trace-gui.h +++ b/trace-gui.h | |||
| @@ -52,6 +52,9 @@ gchar *trace_get_file_dialog_filter(const gchar *title, const char *open, | |||
| 52 | gchar *trace_get_file_dialog(const gchar *title, const char *open, | 52 | gchar *trace_get_file_dialog(const gchar *title, const char *open, |
| 53 | gboolean warn); | 53 | gboolean warn); |
| 54 | 54 | ||
| 55 | void trace_set_cursor(GdkCursorType type); | ||
| 56 | void trace_put_cursor(void); | ||
| 57 | |||
| 55 | GtkWidget * | 58 | GtkWidget * |
| 56 | trace_create_combo_box(GtkWidget *hbox, const gchar *text, | 59 | trace_create_combo_box(GtkWidget *hbox, const gchar *text, |
| 57 | GtkTreeModel *(*combo_model_create)(gpointer data), | 60 | GtkTreeModel *(*combo_model_create)(gpointer data), |
