static void show_book_details (AcctPeriodInfo *info) { QofBook *currbook; char close_date_str[MAX_DATE_LENGTH]; char prev_close_date_str[MAX_DATE_LENGTH]; const char *period_text; char *str; const char *cstr; int ntrans, nacc; ENTER ("info=%p", info); /* Tell user about how the previous book closing went. */ cstr = get_close_status_str (info); gtk_label_set_text (info->close_results, cstr); info->close_status = -1; /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); qof_print_date_dmy_buff (close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->closing_date), g_date_get_month(&info->closing_date), g_date_get_year(&info->closing_date)); currbook = gnc_get_current_book(); ntrans = get_num_xactions_before_date(currbook, gnc_timet_get_day_end_gdate (&info->closing_date)); nacc = gnc_account_n_descendants (gnc_book_get_root_account (currbook)); /* Display the book info */ period_text = _("You have asked for a book to be created. This book " "will contain all transactions up to midnight %s " "(for a total of %d transactions spread over %d accounts). " "Click on 'Forward' to create this book. " "Click on 'Back' to adjust the dates."); str = g_strdup_printf (period_text, close_date_str, ntrans, nacc); gtk_label_set_text (info->book_details, str); g_free (str); /* Weird bug fix ! */ gtk_widget_show (GTK_WIDGET (info->book_details)); /* Create default settings for the title, notes fields */ qof_print_date_dmy_buff (prev_close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->prev_closing_date), g_date_get_month(&info->prev_closing_date), g_date_get_year(&info->prev_closing_date)); str = g_strdup_printf (_("Period %s - %s"), prev_close_date_str, close_date_str); gtk_entry_set_text (info->book_title, str); xxxgtk_textview_set_text (info->book_notes, str); g_free (str); }
static void notes_area_do_set_project (NotesArea *na, GttProject *proj) { const char * str; GttTask *tsk; if (!na) return; if (na->ignore_events) return; /* Calling gtk_entry_set_text makes 'changed' events happen, * which causes us to get the entry text, which exposes a gtk * bug. So we work around the bug and save cpu time by ignoring * change events during a mass update. */ na->ignore_events = TRUE; /* Note Bene its OK to have the proj be null: this has the * effect of clearing all the fields out. */ na->proj = proj; /* Fetch data from the data engine, stuff it into the GUI. */ str = gtt_project_get_title (proj); if (!str) str = ""; gtk_entry_set_text (na->proj_title, str); str = gtt_project_get_desc (proj); if (!str) str = ""; gtk_entry_set_text (na->proj_desc, str); str = gtt_project_get_notes (proj); if (!str) str = ""; xxxgtk_textview_set_text (na->proj_notes, str); GtkTreeModel *model = build_task_combo_model (proj); gtk_combo_box_set_model (na->task_combo, model); g_object_unref (model); tsk = gtt_project_get_current_task (proj); if (tsk == NULL) tsk = gtt_project_get_first_task (proj); notes_area_choose_task (na, tsk); na->ignore_events = FALSE; }
/* ============================================================== */ static void task_selected_cb (GtkComboBox *combo, gpointer dialog) { GtkTreeIter iter; GtkTreeModel *model = gtk_combo_box_get_model (combo); NotesArea *na = (NotesArea *) dialog; na->ignore_events = TRUE; gtk_combo_box_get_active_iter (combo, &iter); GttTask *task = tasks_model_get_task (model, &iter); GttProject *project = gtt_task_get_parent (task); gtt_project_set_current_task (project, task); const char *str = gtt_task_get_notes (task); if (!str) str = ""; xxxgtk_textview_set_text (na->task_notes, str); na->ignore_events = FALSE; }
static void do_set_project(GttProject *proj, PropDlg *dlg) { GttProjectStatus status; GttRank rank; time_t tval; char buff[132]; time_t now = time(NULL); if (!dlg) return; if (!proj) { /* We null these out, because old values may be left * over from an earlier project */ dlg->proj = NULL; gtk_entry_set_text(dlg->title, ""); gtk_entry_set_text(dlg->desc, ""); xxxgtk_textview_set_text(dlg->notes, ""); gtk_entry_set_text(dlg->regular, "0.0"); gtk_entry_set_text(dlg->overtime, "0.0"); gtk_entry_set_text(dlg->overover, "0.0"); gtk_entry_set_text(dlg->flatfee, "0.0"); gtk_entry_set_text(dlg->minimum, "0"); gtk_entry_set_text(dlg->interval, "0"); gtk_entry_set_text(dlg->gap, "0"); gnome_date_edit_set_time(dlg->start, now); gnome_date_edit_set_time(dlg->end, now); gnome_date_edit_set_time(dlg->due, now+86400); gtk_entry_set_text(dlg->sizing, "0.0"); gtk_entry_set_text(dlg->percent, "0"); return; } /* set all the values. Do this even is new project is same as old * project, since widget may be holding rejected changes. */ dlg->proj = proj; gtk_entry_set_text(dlg->title, gtt_project_get_title(proj)); gtk_entry_set_text(dlg->desc, gtt_project_get_desc(proj)); xxxgtk_textview_set_text(dlg->notes, gtt_project_get_notes (proj)); /* hack alert should use local currencies for this */ g_snprintf (buff, 132, "%.2f", gtt_project_get_billrate(proj)); gtk_entry_set_text(dlg->regular, buff); g_snprintf (buff, 132, "%.2f", gtt_project_get_overtime_rate(proj)); gtk_entry_set_text(dlg->overtime, buff); g_snprintf (buff, 132, "%.2f", gtt_project_get_overover_rate(proj)); gtk_entry_set_text(dlg->overover, buff); g_snprintf (buff, 132, "%.2f", gtt_project_get_flat_fee(proj)); gtk_entry_set_text(dlg->flatfee, buff); g_snprintf (buff, 132, "%d", gtt_project_get_min_interval(proj)); gtk_entry_set_text(dlg->minimum, buff); g_snprintf (buff, 132, "%d", gtt_project_get_auto_merge_interval(proj)); gtk_entry_set_text(dlg->interval, buff); g_snprintf (buff, 132, "%d", gtt_project_get_auto_merge_gap(proj)); gtk_entry_set_text(dlg->gap, buff); rank = gtt_project_get_urgency (proj); if (GTT_UNDEFINED == rank) gtk_option_menu_set_history (dlg->urgency, 0); else if (GTT_LOW == rank) gtk_option_menu_set_history (dlg->urgency, 1); else if (GTT_MEDIUM == rank) gtk_option_menu_set_history (dlg->urgency, 2); else if (GTT_HIGH == rank) gtk_option_menu_set_history (dlg->urgency, 3); rank = gtt_project_get_importance (proj); if (GTT_UNDEFINED == rank) gtk_option_menu_set_history (dlg->importance, 0); else if (GTT_LOW == rank) gtk_option_menu_set_history (dlg->importance, 1); else if (GTT_MEDIUM == rank) gtk_option_menu_set_history (dlg->importance, 2); else if (GTT_HIGH == rank) gtk_option_menu_set_history (dlg->importance, 3); status = gtt_project_get_status (proj); if (GTT_NO_STATUS == status) gtk_option_menu_set_history (dlg->status, 0); else if (GTT_NOT_STARTED == status) gtk_option_menu_set_history (dlg->status, 1); else if (GTT_IN_PROGRESS == status) gtk_option_menu_set_history (dlg->status, 2); else if (GTT_ON_HOLD == status) gtk_option_menu_set_history (dlg->status, 3); else if (GTT_CANCELLED == status) gtk_option_menu_set_history (dlg->status, 4); else if (GTT_COMPLETED == status) gtk_option_menu_set_history (dlg->status, 5); tval = gtt_project_get_estimated_start (proj); if (-1 == tval) tval = now; gnome_date_edit_set_time (dlg->start, tval); tval = gtt_project_get_estimated_end (proj); if (-1 == tval) tval = now+3600; gnome_date_edit_set_time (dlg->end, tval); tval = gtt_project_get_due_date (proj); if (-1 == tval) tval = now+86400; gnome_date_edit_set_time (dlg->due, tval); g_snprintf (buff, 132, "%.2f", ((double) gtt_project_get_sizing(proj))/3600.0); gtk_entry_set_text(dlg->sizing, buff); g_snprintf (buff, 132, "%d", gtt_project_get_percent_complete(proj)); gtk_entry_set_text(dlg->percent, buff); /* set to unmodified as it reflects the current state of the project */ gnome_property_box_set_modified(GNOME_PROPERTY_BOX(dlg->dlg), FALSE); }