/** Initialize an edit field that will display a number in the users * local currency. * * @param edit A pointer to the edit widget. */ static void fincalc_init_commodity_gae (GNCAmountEdit *edit) { GNCPrintAmountInfo print_info; gnc_commodity *commodity; gint fraction; commodity = gnc_default_currency(); fraction = gnc_commodity_get_fraction(commodity); print_info = gnc_commodity_print_info (commodity, FALSE); gnc_amount_edit_set_print_info (edit, print_info); gnc_amount_edit_set_fraction (edit, fraction); gnc_amount_edit_set_evaluate_on_enter (edit, TRUE); gtk_entry_set_alignment (GTK_ENTRY(edit), 1.0); }
/** Initialize an edit field that will display a general number. * * @param edit A pointer to the edit widget. * * @param min_places The minimum number of places after the decimal * point. * * @param max_places The maximum number of places after the decimal * point. * * @param fraction The fraction used to maintain numbers internally. */ static void fincalc_init_gae (GNCAmountEdit *edit, gint min_places, gint max_places, gint fraction) { GNCPrintAmountInfo print_info; print_info = gnc_integral_print_info (); print_info.min_decimal_places = min_places; print_info.max_decimal_places = max_places; gnc_amount_edit_set_print_info (edit, print_info); gnc_amount_edit_set_fraction (edit, fraction); gnc_amount_edit_set_evaluate_on_enter (edit, TRUE); gtk_entry_set_alignment (GTK_ENTRY(edit), 1.0); }
static void refresh_details_page (StockSplitInfo *info) { GNCPrintAmountInfo print_info; gnc_commodity *commodity, *currency; Account *account; QofBook *book; GNCPriceDB *db; GList *prices; account = info->acct; g_return_if_fail (account != NULL); print_info = gnc_account_print_info (account, FALSE); gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (info->distribution_edit), print_info); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (info->distribution_edit), xaccAccountGetCommoditySCU (account)); commodity = xaccAccountGetCommodity (account); book = gnc_account_get_book (account); db = gnc_pricedb_get_db(book); prices = gnc_pricedb_lookup_latest_any_currency(db, commodity); if (prices) { /* Use the first existing price */ if (gnc_commodity_equiv (commodity, gnc_price_get_currency(prices->data))) currency = gnc_price_get_commodity(prices->data); else currency = gnc_price_get_currency(prices->data); } else { /* Take a wild guess. */ currency = gnc_default_currency (); } gnc_price_list_destroy(prices); gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT (info->price_currency_edit), currency); }
static CustomerWindow * gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) { CustomerWindow *cw; GtkBuilder *builder; GtkWidget *hbox, *edit; gnc_commodity *currency; GNCPrintAmountInfo print_info; /* * Find an existing window for this customer. If found, bring it to * the front. */ if (cust) { GncGUID customer_guid; customer_guid = *gncCustomerGetGUID(cust); cw = gnc_find_first_gui_component (DIALOG_EDIT_CUSTOMER_CM_CLASS, find_handler, &customer_guid); if (cw) { gtk_window_present (GTK_WINDOW(cw->dialog)); return(cw); } } /* Find the default currency */ if (cust) currency = gncCustomerGetCurrency (cust); else currency = gnc_default_currency (); /* * No existing customer window found. Build a new one. */ cw = g_new0 (CustomerWindow, 1); cw->book = bookp; /* Find the dialog */ builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-customer.glade", "terms_store"); gnc_builder_add_from_file (builder, "dialog-customer.glade", "tax_included_store"); gnc_builder_add_from_file (builder, "dialog-customer.glade", "taxtable_store"); gnc_builder_add_from_file (builder, "dialog-customer.glade", "Customer Dialog"); cw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Customer Dialog")); g_object_set_data (G_OBJECT (cw->dialog), "dialog_info", cw); /* Get entry points */ cw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder, "id_entry")); cw->company_entry = GTK_WIDGET (gtk_builder_get_object (builder, "company_entry")); cw->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry")); cw->addr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr1_entry")); cw->addr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr2_entry")); cw->addr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr3_entry")); cw->addr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr4_entry")); cw->phone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "phone_entry")); cw->fax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fax_entry")); cw->email_entry = GTK_WIDGET (gtk_builder_get_object (builder, "email_entry")); cw->shipname_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipname_entry")); cw->shipaddr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr1_entry")); cw->shipaddr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr2_entry")); cw->shipaddr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr3_entry")); cw->shipaddr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr4_entry")); cw->shipphone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipphone_entry")); cw->shipfax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipfax_entry")); cw->shipemail_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipemail_entry")); cw->active_check = GTK_WIDGET (gtk_builder_get_object (builder, "active_check")); cw->taxincluded_menu = GTK_WIDGET (gtk_builder_get_object (builder, "tax_included_menu")); cw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder, "notes_text")); cw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder, "terms_menu")); cw->taxtable_check = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_button")); cw->taxtable_menu = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_menu")); /* Currency */ edit = gnc_currency_edit_new(); gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(edit), currency); cw->currency_edit = edit; hbox = GTK_WIDGET (gtk_builder_get_object (builder, "currency_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* DISCOUNT: Percentage Value */ edit = gnc_amount_edit_new(); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE); print_info = gnc_integral_print_info (); print_info.max_decimal_places = 5; gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000); cw->discount_amount = edit; gtk_widget_show (edit); hbox = GTK_WIDGET (gtk_builder_get_object (builder, "discount_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* CREDIT: Monetary Value */ edit = gnc_amount_edit_new(); print_info = gnc_commodity_print_info (currency, FALSE); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE); gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), gnc_commodity_get_fraction (currency)); cw->credit_amount = edit; gtk_widget_show (edit); hbox = GTK_WIDGET (gtk_builder_get_object (builder, "credit_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* Setup signals */ gtk_builder_connect_signals_full( builder, gnc_builder_connect_full_func, cw); /* Setup initial values */ if (cust != NULL) { GtkTextBuffer* text_buffer; GncAddress *addr, *shipaddr; const char *string; cw->dialog_type = EDIT_CUSTOMER; cw->customer_guid = *gncCustomerGetGUID (cust); addr = gncCustomerGetAddr (cust); shipaddr = gncCustomerGetShipAddr (cust); gtk_entry_set_text (GTK_ENTRY (cw->id_entry), gncCustomerGetID (cust)); gtk_entry_set_text (GTK_ENTRY (cw->company_entry), gncCustomerGetName (cust)); /* Setup Address */ gtk_entry_set_text (GTK_ENTRY (cw->name_entry), gncAddressGetName (addr)); gtk_entry_set_text (GTK_ENTRY (cw->addr1_entry), gncAddressGetAddr1 (addr)); gtk_entry_set_text (GTK_ENTRY (cw->addr2_entry), gncAddressGetAddr2 (addr)); gtk_entry_set_text (GTK_ENTRY (cw->addr3_entry), gncAddressGetAddr3 (addr)); gtk_entry_set_text (GTK_ENTRY (cw->addr4_entry), gncAddressGetAddr4 (addr)); gtk_entry_set_text (GTK_ENTRY (cw->phone_entry), gncAddressGetPhone (addr)); gtk_entry_set_text (GTK_ENTRY (cw->fax_entry), gncAddressGetFax (addr)); gtk_entry_set_text (GTK_ENTRY (cw->email_entry), gncAddressGetEmail (addr)); /* Setup Ship-to Address */ gtk_entry_set_text (GTK_ENTRY (cw->shipname_entry), gncAddressGetName (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipaddr1_entry), gncAddressGetAddr1 (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipaddr2_entry), gncAddressGetAddr2 (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipaddr3_entry), gncAddressGetAddr3 (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipaddr4_entry), gncAddressGetAddr4 (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipphone_entry), gncAddressGetPhone (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipfax_entry), gncAddressGetFax (shipaddr)); gtk_entry_set_text (GTK_ENTRY (cw->shipemail_entry), gncAddressGetEmail (shipaddr)); /* Set toggle buttons */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->active_check), gncCustomerGetActive (cust)); string = gncCustomerGetNotes (cust); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(cw->notes_text)); gtk_text_buffer_set_text (text_buffer, string, -1); cw->component_id = gnc_register_gui_component (DIALOG_EDIT_CUSTOMER_CM_CLASS, gnc_customer_window_refresh_handler, gnc_customer_window_close_handler, cw); cw->terms = gncCustomerGetTerms (cust); } else { cust = gncCustomerCreate (bookp); cw->customer_guid = *gncCustomerGetGUID (cust); cw->dialog_type = NEW_CUSTOMER; cw->component_id = gnc_register_gui_component (DIALOG_NEW_CUSTOMER_CM_CLASS, gnc_customer_window_refresh_handler, gnc_customer_window_close_handler, cw); /* XXX: get the global-default terms */ cw->terms = NULL; } /* I know that cust exists here -- either passed in or just created */ cw->taxincluded = gncCustomerGetTaxIncluded (cust); gnc_taxincluded_combo (GTK_COMBO_BOX(cw->taxincluded_menu), cw->taxincluded); gnc_billterms_combo (GTK_COMBO_BOX(cw->terms_menu), bookp, TRUE, cw->terms); cw->taxtable = gncCustomerGetTaxTable (cust); gnc_taxtables_combo (GTK_COMBO_BOX(cw->taxtable_menu), bookp, TRUE, cw->taxtable); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxtable_check), gncCustomerGetTaxTableOverride (cust)); gnc_customer_taxtable_check_cb (GTK_TOGGLE_BUTTON (cw->taxtable_check), cw); /* Set up the addr line quickfill */ cw->addr2_quickfill = gnc_get_shared_address_addr2_quickfill(cw->book, ADDR_QUICKFILL); cw->addr3_quickfill = gnc_get_shared_address_addr3_quickfill(cw->book, ADDR_QUICKFILL); cw->addr4_quickfill = gnc_get_shared_address_addr4_quickfill(cw->book, ADDR_QUICKFILL); /* Set the Discount, and Credit amounts */ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount), gncCustomerGetDiscount (cust)); gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->credit_amount), gncCustomerGetCredit (cust)); gnc_gui_component_watch_entity_type (cw->component_id, GNC_CUSTOMER_MODULE_NAME, QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); gtk_widget_show_all (cw->dialog); g_object_unref(G_OBJECT(builder)); return cw; }
GncABTransDialog * gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates) { GncABTransDialog *td; GtkBuilder *builder; const gchar *ab_ownername; const gchar *ab_accountnumber; const gchar *ab_bankname; const gchar *ab_bankcode; GtkWidget *heading_label; GtkWidget *recp_name_heading; GtkWidget *recp_account_heading; GtkWidget *recp_bankcode_heading; GtkWidget *amount_hbox; GtkWidget *orig_name_heading; GtkWidget *orig_name_label; GtkWidget *orig_account_heading; GtkWidget *orig_account_label; GtkWidget *orig_bankname_heading; GtkWidget *orig_bankname_label; GtkWidget *orig_bankcode_heading; GtkWidget *orig_bankcode_label; GtkCellRenderer *renderer; GtkTreeViewColumn *column; g_return_val_if_fail(ab_acc, NULL); ab_ownername = AB_Account_GetOwnerName(ab_acc); if (!ab_ownername) ab_ownername = ""; ab_accountnumber = AB_Account_GetAccountNumber(ab_acc); ab_bankcode = AB_Account_GetBankCode(ab_acc); ab_bankname = AB_Account_GetBankName(ab_acc); if (!ab_bankname || !*ab_bankname) ab_bankname = _("(unknown)"); td = g_new0(GncABTransDialog, 1); td->parent = parent; td->ab_acc = ab_acc; td->trans_type = trans_type; #if HAVE_KTOBLZCHECK_H td->blzcheck = AccountNumberCheck_new(); #endif builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog"); td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog")); if (parent) gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent)); /* Extract widgets */ heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label")); recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading")); td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry")); recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading")); td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry")); recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading")); td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry")); td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label")); amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox")); td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry")); td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry")); td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry")); td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry")); orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading")); orig_name_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label")); orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading")); orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label")); orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading")); orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label")); orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading")); orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label")); td->template_gtktreeview = GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list")); /* Amount edit */ td->amount_edit = gnc_amount_edit_new(); gtk_box_pack_start_defaults(GTK_BOX(amount_hbox), td->amount_edit); gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit), TRUE); gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit), commodity_scu); /* Check for what kind of transaction this should be, and change the * labels accordingly */ switch (trans_type) { case SINGLE_TRANSFER: case SINGLE_INTERNAL_TRANSFER: /* all labels are already set */ break; case SINGLE_DEBITNOTE: gtk_label_set_text(GTK_LABEL (heading_label), /* Translators: Strings from this file are * needed only in countries that have one of * aqbanking's Online Banking techniques * available. This is 'OFX DirectConnect' * (U.S. and others), 'HBCI' (in Germany), * or 'YellowNet' (Switzerland). If none of * these techniques are available in your * country, you may safely ignore strings * from the import-export/hbci * subdirectory. */ _("Enter an Online Direct Debit Note")); gtk_label_set_text(GTK_LABEL(recp_name_heading), _("Debited Account Owner")); gtk_label_set_text(GTK_LABEL(recp_account_heading), _("Debited Account Number")); gtk_label_set_text(GTK_LABEL(recp_bankcode_heading), _("Debited Account Bank Code")); gtk_label_set_text(GTK_LABEL(orig_name_heading), _("Credited Account Owner")); gtk_label_set_text(GTK_LABEL(orig_account_heading), _("Credited Account Number")); gtk_label_set_text(GTK_LABEL(orig_bankcode_heading), _("Credited Account Bank Code")); break; default: g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d", trans_type); break; } gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername); gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber); gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname); gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode); /* Fill list for choosing a transaction template */ td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); g_list_foreach(templates, fill_templ_helper, td->template_list_store); gtk_tree_view_set_model(td->template_gtktreeview, GTK_TREE_MODEL(td->template_list_store)); td->templ_changed = FALSE; /* Keep a reference to the store */ /* Show this list */ renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes( "Template Name", renderer, "text", TEMPLATE_NAME, NULL); gtk_tree_view_append_column(td->template_gtktreeview, column); /* Connect the Signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, td); g_object_unref(G_OBJECT(builder)); return td; }
static GncTaxTable * new_tax_table_dialog (TaxTableWindow *ttw, gboolean new_table, GncTaxTableEntry *entry, const char *name) { GncTaxTable *created_table = NULL; NewTaxTable *ntt; GtkBuilder *builder; GtkWidget *box, *widget, *combo; gboolean done; gint response, index; if (!ttw) return NULL; if (new_table && entry) return NULL; ntt = g_new0 (NewTaxTable, 1); ntt->ttw = ttw; ntt->entry = entry; ntt->new_table = new_table; if (entry) ntt->type = gncTaxTableEntryGetType (entry); else ntt->type = GNC_AMT_TYPE_PERCENT; /* Open and read the Glade File */ builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-tax-table.glade", "type_liststore"); gnc_builder_add_from_file (builder, "dialog-tax-table.glade", "New Tax Table Dialog"); ntt->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "New Tax Table Dialog")); ntt->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry")); if (name) gtk_entry_set_text (GTK_ENTRY (ntt->name_entry), name); /* Create the menu */ combo = GTK_WIDGET(gtk_builder_get_object (builder, "type_combobox")); index = ntt->type ? ntt->type : GNC_AMT_TYPE_VALUE; gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index - 1); g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), ntt); /* Attach our own widgets */ box = GTK_WIDGET(gtk_builder_get_object (builder, "amount_box")); ntt->amount_entry = widget = gnc_amount_edit_new (); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (widget), TRUE); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (widget), 100000); gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE, 0); box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_window")); ntt->acct_tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE)); gtk_container_add (GTK_CONTAINER (box), ntt->acct_tree); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(ntt->acct_tree), FALSE); /* Make 'enter' do the right thing */ gtk_entry_set_activates_default(GTK_ENTRY (gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (ntt->amount_entry))), TRUE); /* Fix mnemonics for generated target widgets */ widget = GTK_WIDGET(gtk_builder_get_object (builder, "value_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), ntt->amount_entry); widget = GTK_WIDGET(gtk_builder_get_object (builder, "account_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), ntt->acct_tree); /* Fill in the widgets appropriately */ if (entry) { gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ntt->amount_entry), gncTaxTableEntryGetAmount (entry)); gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT (ntt->acct_tree), gncTaxTableEntryGetAccount (entry)); } /* Set our parent */ gtk_window_set_transient_for (GTK_WINDOW(ntt->dialog), GTK_WINDOW(ttw->dialog)); /* Setup signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ntt); /* Show what we should */ gtk_widget_show_all (ntt->dialog); if (new_table == FALSE) { gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "table_title"))); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "table_name"))); gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "spacer"))); gtk_widget_hide (ntt->name_entry); /* Tables are great for layout, but a pain when you hide widgets */ widget = GTK_WIDGET(gtk_builder_get_object (builder, "ttd_table")); gtk_table_set_row_spacing (GTK_TABLE(widget), 0, 0); gtk_table_set_row_spacing (GTK_TABLE(widget), 1, 0); gtk_table_set_row_spacing (GTK_TABLE(widget), 2, 0); gtk_widget_grab_focus (gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (ntt->amount_entry))); } else gtk_widget_grab_focus (ntt->name_entry); /* Display the dialog now that we're done manipulating it */ gtk_widget_show (ntt->dialog); done = FALSE; while (!done) { response = gtk_dialog_run (GTK_DIALOG (ntt->dialog)); switch (response) { case GTK_RESPONSE_OK: if (new_tax_table_ok_cb (ntt)) { created_table = ntt->created_table; done = TRUE; } break; default: done = TRUE; break; } } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(ntt->dialog); g_free(ntt); return created_table; }
static EmployeeWindow * gnc_employee_new_window (QofBook *bookp, GncEmployee *employee) { EmployeeWindow *ew; GtkBuilder *builder; GtkWidget *hbox, *edit; gnc_commodity *currency; GNCPrintAmountInfo print_info; GList *acct_types; Account *ccard_acct; /* * Find an existing window for this employee. If found, bring it to * the front. */ if (employee) { GncGUID employee_guid; employee_guid = *gncEmployeeGetGUID (employee); ew = gnc_find_first_gui_component (DIALOG_EDIT_EMPLOYEE_CM_CLASS, find_handler, &employee_guid); if (ew) { gtk_window_present (GTK_WINDOW(ew->dialog)); return(ew); } } /* Find the default currency */ if (employee) currency = gncEmployeeGetCurrency (employee); else currency = gnc_default_currency (); /* * No existing employee window found. Build a new one. */ ew = g_new0 (EmployeeWindow, 1); ew->book = bookp; /* Find the dialog */ builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-employee.glade", "Employee Dialog"); ew->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Employee Dialog")); g_object_set_data (G_OBJECT (ew->dialog), "dialog_info", ew); /* Get entry points */ ew->id_entry = GTK_WIDGET(gtk_builder_get_object (builder, "id_entry")); ew->username_entry = GTK_WIDGET(gtk_builder_get_object (builder, "username_entry")); ew->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry")); ew->addr1_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr1_entry")); ew->addr2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr2_entry")); ew->addr3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr3_entry")); ew->addr4_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr4_entry")); ew->phone_entry = GTK_WIDGET(gtk_builder_get_object (builder, "phone_entry")); ew->fax_entry = GTK_WIDGET(gtk_builder_get_object (builder, "fax_entry")); ew->email_entry = GTK_WIDGET(gtk_builder_get_object (builder, "email_entry")); ew->language_entry = GTK_WIDGET(gtk_builder_get_object (builder, "language_entry")); ew->active_check = GTK_WIDGET(gtk_builder_get_object (builder, "active_check")); /* Currency */ edit = gnc_currency_edit_new(); gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(edit), currency); ew->currency_edit = edit; hbox = GTK_WIDGET(gtk_builder_get_object (builder, "currency_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* WORKDAY: Value */ edit = gnc_amount_edit_new(); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE); print_info = gnc_integral_print_info (); print_info.max_decimal_places = 5; gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000); ew->workday_amount = edit; gtk_widget_show (edit); hbox = GTK_WIDGET(gtk_builder_get_object (builder, "hours_hbox")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* RATE: Monetary Value */ edit = gnc_amount_edit_new(); print_info = gnc_commodity_print_info (currency, FALSE); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE); gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info); gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), gnc_commodity_get_fraction (currency)); ew->rate_amount = edit; gtk_widget_show (edit); hbox = GTK_WIDGET(gtk_builder_get_object (builder, "rate_hbox")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* CCard Account Selection */ ew->ccard_acct_check = GTK_WIDGET(gtk_builder_get_object (builder, "ccard_check")); edit = gnc_account_sel_new(); acct_types = g_list_prepend(NULL, (gpointer)ACCT_TYPE_CREDIT); gnc_account_sel_set_acct_filters (GNC_ACCOUNT_SEL(edit), acct_types, NULL); g_list_free (acct_types); ew->ccard_acct_sel = edit; gtk_widget_show (edit); hbox = GTK_WIDGET(gtk_builder_get_object (builder, "ccard_acct_hbox")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* Setup signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ew); /* Setup initial values */ if (employee != NULL) { GncAddress *addr; ew->dialog_type = EDIT_EMPLOYEE; ew->employee_guid = *gncEmployeeGetGUID (employee); addr = gncEmployeeGetAddr (employee); gtk_entry_set_text (GTK_ENTRY (ew->id_entry), gncEmployeeGetID (employee)); gtk_entry_set_text (GTK_ENTRY (ew->username_entry), gncEmployeeGetUsername (employee)); /* Setup Address */ gtk_entry_set_text (GTK_ENTRY (ew->name_entry), gncAddressGetName (addr)); gtk_entry_set_text (GTK_ENTRY (ew->addr1_entry), gncAddressGetAddr1 (addr)); gtk_entry_set_text (GTK_ENTRY (ew->addr2_entry), gncAddressGetAddr2 (addr)); gtk_entry_set_text (GTK_ENTRY (ew->addr3_entry), gncAddressGetAddr3 (addr)); gtk_entry_set_text (GTK_ENTRY (ew->addr4_entry), gncAddressGetAddr4 (addr)); gtk_entry_set_text (GTK_ENTRY (ew->phone_entry), gncAddressGetPhone (addr)); gtk_entry_set_text (GTK_ENTRY (ew->fax_entry), gncAddressGetFax (addr)); gtk_entry_set_text (GTK_ENTRY (ew->email_entry), gncAddressGetEmail (addr)); gtk_entry_set_text (GTK_ENTRY (ew->language_entry), gncEmployeeGetLanguage (employee)); /* Set toggle buttons */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->active_check), gncEmployeeGetActive (employee)); ew->component_id = gnc_register_gui_component (DIALOG_EDIT_EMPLOYEE_CM_CLASS, gnc_employee_window_refresh_handler, gnc_employee_window_close_handler, ew); } else { employee = gncEmployeeCreate (bookp); ew->employee_guid = *gncEmployeeGetGUID (employee); ew->dialog_type = NEW_EMPLOYEE; ew->component_id = gnc_register_gui_component (DIALOG_NEW_EMPLOYEE_CM_CLASS, gnc_employee_window_refresh_handler, gnc_employee_window_close_handler, ew); } /* I know that employee exists here -- either passed in or just created */ /* Set the workday and rate values */ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->workday_amount), gncEmployeeGetWorkday (employee)); gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->rate_amount), gncEmployeeGetRate (employee)); ccard_acct = gncEmployeeGetCCard (employee); if (ccard_acct == NULL) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), FALSE); gtk_widget_set_sensitive (ew->ccard_acct_sel, FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), TRUE); gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct, FALSE); } /* XXX: Set the ACL */ gnc_gui_component_watch_entity_type (ew->component_id, GNC_EMPLOYEE_MODULE_NAME, QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); gtk_widget_show_all (ew->dialog); if (ccard_acct == NULL) gtk_widget_hide (ew->ccard_acct_sel); g_object_unref(G_OBJECT(builder)); return ew; }