summaryrefslogtreecommitdiffstats
path: root/src/gui-wizard-gtk
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-02-17 16:58:52 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-02-17 16:58:52 +0100
commitd5aba6754da8f0f43223e5110d500e6d8c612ff8 (patch)
treef57b6c993124da4a11078659f2d35bef47193811 /src/gui-wizard-gtk
parentf4cb4ccf25a88f9201df6d76d00e9bdec2b45df4 (diff)
downloadabrt-d5aba6754da8f0f43223e5110d500e6d8c612ff8.tar.gz
abrt-d5aba6754da8f0f43223e5110d500e6d8c612ff8.tar.xz
abrt-d5aba6754da8f0f43223e5110d500e6d8c612ff8.zip
gui-wizard-gtk: analyze step now sort-of-works....
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/gui-wizard-gtk')
-rw-r--r--src/gui-wizard-gtk/main.c47
-rw-r--r--src/gui-wizard-gtk/wizard.c37
-rw-r--r--src/gui-wizard-gtk/wizard.h6
3 files changed, 74 insertions, 16 deletions
diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c
index 4f54ff2b..2ddff27d 100644
--- a/src/gui-wizard-gtk/main.c
+++ b/src/gui-wizard-gtk/main.c
@@ -7,8 +7,22 @@
char *g_glade_file = NULL;
+char *g_dump_dir_name = NULL;
+
+char *g_analyze_label_selected = NULL;
+
static crash_data_t *cd;
+static void analyze_rb_was_toggled(GtkToggleButton *button, gpointer user_data)
+{
+ const char *label = gtk_button_get_label(GTK_BUTTON(button));
+ if (label)
+ {
+ free(g_analyze_label_selected);
+ g_analyze_label_selected = xstrdup(label);
+ }
+}
+
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
@@ -35,11 +49,13 @@ int main(int argc, char **argv)
if (!argv[0] || argv[1]) /* zero or >1 arguments */
show_usage_and_die(program_usage_string, program_options);
- struct dump_dir *dd = dd_opendir(argv[0], 0);
+ g_dump_dir_name = argv[0];
+
+ struct dump_dir *dd = dd_opendir(g_dump_dir_name, 0);
if (!dd)
return 1;
cd = create_crash_data_from_dump_dir(dd);
- char *analyze_events = list_possible_events(dd, /*dump_dir_name*/ NULL, "analyze");
+ char *analyze_events = list_possible_events(dd, g_dump_dir_name, "analyze");
dd_close(dd);
GtkWidget *assistant = create_assistant();
@@ -52,15 +68,24 @@ int main(int argc, char **argv)
if (analyze_events[0])
{
char *event_name = analyze_events;
- char *event_name_end = strchr(event_name, '\n');
- *event_name_end = '\0';
- GtkWidget *rb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_rb), event_name);
- *event_name_end = '\n';
- event_name = event_name_end + 1;
-
- if (!first_rb)
- first_rb = rb;
- gtk_box_pack_start(GTK_BOX(g_vb_analyzers), rb, /*expand*/ false, /*fill*/ false, /*padding*/ 0);
+ while (event_name[0])
+ {
+ char *event_name_end = strchr(event_name, '\n');
+ *event_name_end = '\0';
+ GtkWidget *rb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_rb), event_name);
+ if (!first_rb)
+ {
+ first_rb = rb;
+ free(g_analyze_label_selected);
+ g_analyze_label_selected = xstrdup(event_name);
+ }
+ *event_name_end = '\n';
+ event_name = event_name_end + 1;
+
+ gtk_box_pack_start(GTK_BOX(g_vb_analyzers), rb, /*expand*/ false, /*fill*/ false, /*padding*/ 0);
+
+ g_signal_connect(G_OBJECT(rb), "toggled", G_CALLBACK(analyze_rb_was_toggled), NULL);
+ }
}
else { /*???*/ }
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 0ac56ee7..74c24bf5 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -25,6 +25,7 @@
GtkLabel *g_lbl_cd_reason;
GtkVBox *g_vb_analyzers;
+GtkTextView *g_analyze_log;
static const gchar *const page_names[] =
{
@@ -51,7 +52,7 @@ static const gchar *const page_titles[] =
static const GtkAssistantPageType page_types[] =
{
- GTK_ASSISTANT_PAGE_INTRO,
+ GTK_ASSISTANT_PAGE_CONFIRM, /* need this type to get "apply" signal */
GTK_ASSISTANT_PAGE_PROGRESS,
GTK_ASSISTANT_PAGE_CONTENT,
GTK_ASSISTANT_PAGE_CONTENT,
@@ -101,22 +102,52 @@ static void add_pages()
gtk_assistant_set_page_title(GTK_ASSISTANT(assistant), page, page_titles[i]);
gtk_assistant_set_page_type(GTK_ASSISTANT(assistant), page, page_types[i]);
- g_print("added page: %s\n", page_names[i]);
+ log("added page: %s", page_names[i]);
}
/* Set pointer to fields we might need to change */
g_lbl_cd_reason = GTK_LABEL(gtk_builder_get_object(builder, "lbl_cd_reason"));
-
g_vb_analyzers = GTK_VBOX(gtk_builder_get_object(builder, "vb_analyzers"));
+ g_analyze_log = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "analyze_log"));
+}
+
+static char *add_log_to_analyze_log(char *log_line, void *param)
+{
+ GtkTextBuffer *tb = gtk_text_view_get_buffer(g_analyze_log);
+
+ gtk_text_buffer_insert_at_cursor(tb, log_line, -1);
+ gtk_text_buffer_insert_at_cursor(tb, "\n", 1);
+
+ return log_line;
+}
+
+static void next_page(GtkAssistant *assistant, gpointer user_data)
+{
+ int page_no = gtk_assistant_get_current_page(assistant);
+ log("page_no:%d", page_no);
+
+ if (g_analyze_label_selected != NULL)
+ {
+ struct run_event_state *run_state = new_run_event_state();
+ run_state->logging_callback = add_log_to_analyze_log;
+// Need async version of run_event_on_dir_name() here! This one will freeze GUI until completion:
+ log("running event '%s' on '%s'", g_analyze_label_selected, g_dump_dir_name);
+ int res = run_event_on_dir_name(run_state, g_dump_dir_name, g_analyze_label_selected);
+ free_run_event_state(run_state);
+ log("done running event '%s' on '%s': %d", g_analyze_label_selected, g_dump_dir_name, res);
+ }
}
GtkWidget *create_assistant()
{
assistant = gtk_assistant_new();
gtk_window_set_default_size(GTK_WINDOW(assistant), DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ gtk_window_set_title(GTK_WINDOW(assistant), g_dump_dir_name);
+ gtk_window_set_icon_name(GTK_WINDOW(assistant), "abrt");
g_signal_connect(G_OBJECT(assistant), "cancel", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(assistant), "close", G_CALLBACK(gtk_main_quit), NULL);
+ g_signal_connect(G_OBJECT(assistant), "apply", G_CALLBACK(next_page), NULL);
builder = gtk_builder_new();
add_pages();
diff --git a/src/gui-wizard-gtk/wizard.h b/src/gui-wizard-gtk/wizard.h
index 2633351a..634b6b94 100644
--- a/src/gui-wizard-gtk/wizard.h
+++ b/src/gui-wizard-gtk/wizard.h
@@ -1,6 +1,8 @@
-GtkWidget *create_assistant(void);
-
extern GtkLabel *g_lbl_cd_reason;
extern GtkVBox *g_vb_analyzers;
+GtkWidget *create_assistant(void);
+
extern char *g_glade_file;
+extern char *g_analyze_label_selected;
+extern char *g_dump_dir_name;