diff options
| author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-03-04 17:02:39 +0100 |
|---|---|---|
| committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-03-04 17:02:39 +0100 |
| commit | da225529e4c2f2e5b48acb18aa176af2e517a57c (patch) | |
| tree | d58d5b0cfdd3742a1df16628575f6fa6cfeee51b /src | |
| parent | 9e97fe412f38166b9048ef46188ab8e0ea1933be (diff) | |
gui-wizard-gtk: generate real text on previous-to-last page
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui-wizard-gtk/wizard.c | 63 | ||||
| -rw-r--r-- | src/gui-wizard-gtk/wizard.glade | 71 |
2 files changed, 57 insertions, 77 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 388a09d9..07ce4ed7 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -28,10 +28,13 @@ GtkBox *g_box_warning_labels; GtkToggleButton *g_tb_approve_bt; GtkButton *g_btn_refresh; -/* required for search in bt */ -guint g_timeout = 0; -GtkEntry * g_search_entry_bt; +GtkLabel *g_lbl_reporters; +GtkLabel *g_lbl_size; + +/* required for search in bt */ +static guint g_timeout = 0; +static GtkEntry *g_search_entry_bt; static GtkBuilder *builder; static PangoFontDescription *monospace_font; @@ -301,31 +304,56 @@ VERB2 log("adding button '%s' to box %p", event_name, box); return (have_activated_btn ? NULL : first_button); } -static void append_item_to_details_ls(gpointer name, gpointer value, gpointer data) +struct cd_stats { + off_t filesize; + unsigned filecount; +}; + +static void append_item_to_ls_details(gpointer name, gpointer value, gpointer data) { crash_item *item = (crash_item*)value; + struct cd_stats *stats = data; GtkTreeIter iter; gtk_list_store_append(g_ls_details, &iter); + stats->filecount++; //FIXME: use the value representation here /* If text and not multiline... */ - if ((item->flags & CD_FLAG_TXT) && !strchr(item->content, '\n')) + if (item->flags & CD_FLAG_TXT) { - gtk_list_store_set(g_ls_details, &iter, + stats->filesize += strlen(item->content); + if (!strchr(item->content, '\n')) + { + gtk_list_store_set(g_ls_details, &iter, DETAIL_COLUMN_NAME, (char *)name, DETAIL_COLUMN_VALUE, item->content, //DETAIL_COLUMN_PATH, xasprintf("%s%s", g_dump_dir_name, name), -1); + } + else + { + gtk_list_store_set(g_ls_details, &iter, + DETAIL_COLUMN_NAME, (char *)name, + DETAIL_COLUMN_VALUE, _("(click here to view/edit)"), + //DETAIL_COLUMN_PATH, xasprintf("%s%s", g_dump_dir_name, name), + -1); + //WARNING: will leak xasprintf results above if uncommented + } } - else + else if (item->flags & CD_FLAG_BIN) { + struct stat statbuf; + statbuf.st_size = 0; + stat(item->content, &statbuf); + stats->filesize += statbuf.st_size; + char *msg = xasprintf(_("(binary file, %llu bytes)"), (long long)statbuf.st_size); gtk_list_store_set(g_ls_details, &iter, DETAIL_COLUMN_NAME, (char *)name, - DETAIL_COLUMN_VALUE, _("(click here to view/edit)"), + DETAIL_COLUMN_VALUE, msg, //DETAIL_COLUMN_PATH, xasprintf("%s%s", g_dump_dir_name, name), -1); - //WARNING: will leak xasprintf results above if uncommented + free(msg); } } @@ -338,7 +366,11 @@ void update_gui_state_from_crash_data(void) gtk_label_set_text(g_lbl_cd_reason, reason ? reason : _("(no description)")); gtk_list_store_clear(g_ls_details); - g_hash_table_foreach(g_cd, append_item_to_details_ls, NULL); + struct cd_stats stats = { 0 }; + g_hash_table_foreach(g_cd, append_item_to_ls_details, &stats); + char *msg = xasprintf(_("%llu bytes, %u files"), (long long)stats.filesize, stats.filecount); + gtk_label_set_text(g_lbl_size, msg); + free(msg); load_text_to_text_view(g_tv_backtrace, FILENAME_BACKTRACE); load_text_to_text_view(g_tv_comment, FILENAME_COMMENT); @@ -378,9 +410,13 @@ void update_gui_state_from_crash_data(void) add_event_buttons(g_box_reporters, g_report_events, /*callback:*/ G_CALLBACK(report_tb_was_toggled), /*radio:*/ false, /*prev:*/ NULL); /* Re-select new reporters which were selected before we deleted them */ GList *new_reporters = gtk_container_get_children(GTK_CONTAINER(g_box_reporters)); + struct strbuf *reporters_string = strbuf_new(); for (GList *li_new = new_reporters; li_new; li_new = li_new->next) { const char *new_name = gtk_button_get_label(GTK_BUTTON(li_new->data)); + + strbuf_append_strf(reporters_string, "%s%s", (reporters_string->len ? ", " : ""), new_name); + for (GList *li_old = old_reporters; li_old; li_old = li_old->next) { if (strcmp(new_name, li_old->data) == 0) @@ -392,9 +428,12 @@ void update_gui_state_from_crash_data(void) } g_list_free(new_reporters); list_free_with_free(old_reporters); + /* Update "list of reporters" label */ + gtk_label_set_text(g_lbl_reporters, strbuf_free_nobuf(reporters_string)); /* Update readiness state of reporter selector page */ report_tb_was_toggled(NULL, NULL); + /* We can't just do gtk_widget_show_all once in main: * We created new widgets (buttons). Need to make them visible. */ @@ -818,7 +857,7 @@ static void search_timeout(GtkEntry *entry) * if this part is removed, then the search will be started on every * change of the search entry */ - if(g_timeout != 0) + if (g_timeout != 0) g_source_remove(g_timeout); g_timeout = g_timeout_add(500, &highlight_search, (gpointer)entry); } @@ -923,6 +962,8 @@ static void add_pages(void) g_search_entry_bt = GTK_ENTRY( gtk_builder_get_object(builder, "entry_search_bt")); g_container_details1 = GTK_CONTAINER( gtk_builder_get_object(builder, "container_details1")); g_container_details2 = GTK_CONTAINER( gtk_builder_get_object(builder, "container_details2")); + g_lbl_reporters = GTK_LABEL( gtk_builder_get_object(builder, "lbl_reporters")); + g_lbl_size = GTK_LABEL( gtk_builder_get_object(builder, "lbl_size")); gtk_widget_modify_font(GTK_WIDGET(g_tv_analyze_log), monospace_font); gtk_widget_modify_font(GTK_WIDGET(g_tv_report_log), monospace_font); diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade index 2b0512c0..bfa0be67 100644 --- a/src/gui-wizard-gtk/wizard.glade +++ b/src/gui-wizard-gtk/wizard.glade @@ -32,7 +32,7 @@ <property name="visible">True</property> <property name="xalign">0</property> <property name="ypad">5</property> - <property name="label" translatable="yes">Press 'Forward' to proceed with analyzing and reporting this problem.</property> + <property name="label" translatable="yes">Click 'Forward' to proceed with analyzing and reporting this problem.</property> </object> <packing> <property name="expand">False</property> @@ -492,7 +492,7 @@ <property name="width_request">750</property> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Below is the information to be reported, please review it.</property> + <property name="label" translatable="yes">Click 'Forward' to start reporting</property> <property name="justify">fill</property> <property name="wrap">True</property> </object> @@ -505,8 +505,7 @@ <child> <object class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="border_width">10</property> - <property name="n_rows">4</property> + <property name="n_rows">2</property> <property name="n_columns">2</property> <property name="column_spacing">10</property> <child> @@ -527,38 +526,6 @@ </packing> </child> <child> - <object class="GtkLabel" id="label5"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"># files:</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label6"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">ETA to upload:</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> <object class="GtkLabel" id="label8"> <property name="visible">True</property> <property name="xalign">0</property> @@ -574,10 +541,9 @@ </packing> </child> <child> - <object class="GtkLabel" id="label9"> + <object class="GtkLabel" id="lbl_reporters"> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Bugzilla, Logger</property> </object> <packing> <property name="left_attach">1</property> @@ -585,10 +551,9 @@ </packing> </child> <child> - <object class="GtkLabel" id="label10"> + <object class="GtkLabel" id="lbl_size"> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">328kB</property> </object> <packing> <property name="left_attach">1</property> @@ -597,32 +562,6 @@ <property name="bottom_attach">2</property> </packing> </child> - <child> - <object class="GtkLabel" id="label11"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">27</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label12"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">2 minutes</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> |
