Files | |
| file | dialog-commodity.c |
| "select" and "new" commodity windows | |
| file | dialog-commodity.h |
| "select" and "new" commodity windows | |
Data Structures | |
| struct | select_commodity_window |
| struct | commodity_window |
Commodity Selection | |
| gnc_commodity * | gnc_ui_select_commodity_modal_full (gnc_commodity *orig_sel, GtkWidget *parent, dialog_commodity_mode mode, const char *user_message, const char *code, const char *fullname, const char *mnemonic) |
| gnc_commodity * | gnc_ui_select_commodity_modal (gnc_commodity *orig_sel, GtkWidget *parent, dialog_commodity_mode mode) |
Auxiliary Dialog Functions | |
| void | gnc_ui_update_commodity_picker (GtkWidget *combobox, const char *namespace, const char *init_string) |
| void | gnc_ui_update_namespace_picker (GtkWidget *combobox, const char *init_string, dialog_commodity_mode mode) |
| const char * | gnc_ui_namespace_picker_ns (GtkWidget *combobox) |
Commodity Creation or Modification | |
| gnc_commodity * | gnc_ui_new_commodity_modal_full (const char *namespace, GtkWidget *parent, const char *exchange_code, const char *fullname, const char *mnemonic, int fraction) |
| gnc_commodity * | gnc_ui_new_commodity_modal (const char *default_namespace, GtkWidget *parent) |
| gboolean | gnc_ui_edit_commodity_modal (gnc_commodity *commodity, GtkWidget *parent) |
Typedefs | |
| typedef select_commodity_window | SelectCommodityWindow |
| typedef commodity_window | CommodityWindow |
| typedef void(* | gnc_commodity_help_callback )(void) |
Enumerations | |
| enum | dialog_commodity_mode { DIAG_COMM_CURRENCY, DIAG_COMM_NON_CURRENCY, DIAG_COMM_ALL } |
Functions | |
| void | gnc_ui_select_commodity_new_cb (GtkButton *button, gpointer user_data) |
| void | gnc_ui_select_commodity_changed_cb (GtkEditable *entry, gpointer user_data) |
| void | gnc_ui_select_commodity_namespace_changed_cb (GtkEditable *entry, gpointer user_data) |
| void | gnc_ui_commodity_changed_cb (GtkWidget *dummy, gpointer user_data) |
| void | gnc_ui_commodity_quote_info_cb (GtkWidget *w, gpointer data) |
| gboolean | gnc_ui_commodity_dialog_to_object (CommodityWindow *w) |
| void | gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb) |
|
|
The dialog commodity types are used to determine what commodity namespaces the currency dialog will present to a user. These values can be safely changed from one release to the next. Note that if values are added, the routines in dialog-commodity.c will need to be updated to match.
Definition at line 47 of file dialog-commodity.h. 00047 { 00048 DIAG_COMM_CURRENCY, 00050 DIAG_COMM_NON_CURRENCY, 00052 DIAG_COMM_ALL, 00054 } dialog_commodity_mode;
|
|
|
This function is used to set the action routine for the help button in the commodity dialog windows. If the action routine is unset, the help button will not be visible to the user.
Definition at line 117 of file dialog-commodity.c.
|
|
||||||||||||
|
Given an existing commodity, uses the gnc_ui_new_commodity_dialog() routine to build a basic edit dialog, then fills in the price quote information at the bottom of the dialog. Definition at line 1028 of file dialog-commodity.c. 01030 { 01031 gnc_commodity *result; 01032 01033 ENTER(" "); 01034 result = gnc_ui_common_commodity_modal(commodity, parent, NULL, NULL, 01035 NULL, NULL, 0); 01036 LEAVE(" "); 01037 return result != NULL; 01038 }
|
|
|
Given a combo box, return the currently selected namespaces.
Definition at line 576 of file dialog-commodity.c. 00577 { 00578 const char *namespace; 00579 00580 g_return_val_if_fail (combobox != NULL, NULL); 00581 g_return_val_if_fail (GTK_IS_COMBO (combobox), NULL); 00582 00583 namespace = gtk_entry_get_text (GTK_ENTRY(GTK_COMBO (combobox)->entry)); 00584 00585 if (safe_strcmp (namespace, "CURRENCY") == 0) 00586 return GNC_COMMODITY_NS_ISO; 00587 else 00588 return namespace; 00589 }
|
|
||||||||||||
|
External routine for popping up the new commodity dialog box. Definition at line 1006 of file dialog-commodity.c. 01008 { 01009 gnc_commodity *result; 01010 01011 ENTER(" "); 01012 result = gnc_ui_common_commodity_modal(NULL, parent, default_namespace, NULL, 01013 NULL, NULL, 0); 01014 LEAVE(" "); 01015 return result; 01016 }
|
|
||||||||||||||||||||||||||||
|
Create and run the new/edit commodity dialog. Definition at line 987 of file dialog-commodity.c. 00993 { 00994 gnc_commodity *result; 00995 00996 ENTER(" "); 00997 result = gnc_ui_common_commodity_modal(NULL, parent, namespace, fullname, 00998 mnemonic, exchange_code, 10000); 00999 LEAVE(" "); 01000 return result; 01001 }
|
|
||||||||||||
|
This function is called whenever the commodity combo box is changed. Its function is to determine if a valid commodity has been selected, record the selection, and update the OK button.
Definition at line 331 of file dialog-commodity.c. 00333 { 00334 SelectCommodityWindow * w = user_data; 00335 const char * namespace; 00336 const char * fullname; 00337 gboolean ok; 00338 00339 ENTER("entry=%p, user_data=%p", entry, user_data); 00340 namespace = gnc_ui_namespace_picker_ns (w->namespace_combo); 00341 fullname = gtk_entry_get_text(GTK_ENTRY(w->commodity_entry)); 00342 DEBUG("namespace=%s, name=%s", namespace, fullname); 00343 w->selection = gnc_commodity_table_find_full(gnc_get_current_commodities(), 00344 namespace, fullname); 00345 00346 ok = (w->selection != NULL); 00347 gtk_widget_set_sensitive(w->ok_button, ok); 00348 gtk_dialog_set_default_response(GTK_DIALOG(w->dialog), ok ? 0 : 2); 00349 LEAVE("sensitive=%d, default = %d", ok, ok ? 0 : 2); 00350 }
|
|
||||||||||||||||
|
Ask the user to select a commodity from the existing set of commodities. The user will also have the option of creating a new commodity from this dialog box.. If the user decides to create a new one, those provided values are used as default values for the new commodity.
Definition at line 200 of file dialog-commodity.c. 00203 { 00204 return gnc_ui_select_commodity_modal_full(orig_sel, 00205 parent, 00206 mode, 00207 NULL, 00208 NULL, 00209 NULL, 00210 NULL); 00211 }
|
|
||||||||||||||||||||||||||||||||
|
Ask the user to select a commodity from the existing set of commodities. Arguments to this function determine the message placed at the top of the dialog but force no restriction on the commodities that may be chosen. The user will also have the option of creating a new commodity from this dialog box.. If the user decides to create a new one, those provided values are used as default values for the new commodity.
Definition at line 127 of file dialog-commodity.c. 00134 { 00135 gnc_commodity * retval = NULL; 00136 const gchar *initial; 00137 gchar *user_prompt_text; 00138 SelectCommodityWindow * win; 00139 gboolean done; 00140 gint value; 00141 00142 win = gnc_ui_select_commodity_create(orig_sel, mode); 00143 win->default_exchange_code=code; 00144 win->default_fullname=fullname; 00145 win->default_mnemonic=mnemonic; 00146 00147 if (parent) 00148 gtk_window_set_transient_for (GTK_WINDOW (win->dialog), GTK_WINDOW (parent)); 00149 00150 if (user_message != NULL) 00151 initial = user_message; 00152 else if ((code != NULL) || (fullname != NULL) || (mnemonic != NULL)) 00153 initial = _("\nPlease select a commodity to match:"); 00154 else 00155 initial = ""; 00156 00157 user_prompt_text = 00158 g_strdup_printf("%s%s%s%s%s%s%s", 00159 initial, 00160 fullname ? _("\nCommodity: ") : "", 00161 fullname ? fullname : "", 00162 code ? _("\nExchange code (CUSIP or similar): ") : "", 00163 code ? code : "", 00164 mnemonic ? _("\nMnemonic(Ticker symbol or similar): ") : "", 00165 mnemonic ? mnemonic : ""); 00166 gtk_label_set_text ((GtkLabel *)(win->select_user_prompt), 00167 user_prompt_text); 00168 00169 /* Run the dialog, handling the terminal conditions. */ 00170 done = FALSE; 00171 while (!done) { 00172 switch (value = gtk_dialog_run(GTK_DIALOG(win->dialog))) { 00173 case GTK_RESPONSE_OK: 00174 DEBUG("case OK"); 00175 retval = win->selection; 00176 done = TRUE; 00177 break; 00178 case GNC_RESPONSE_NEW: 00179 DEBUG("case NEW"); 00180 gnc_ui_select_commodity_new_cb(NULL, win); 00181 break; 00182 default: /* Cancel, Escape, Close, etc. */ 00183 DEBUG("default: %d", value); 00184 retval = NULL; 00185 done = TRUE; 00186 break; 00187 } 00188 } 00189 gtk_widget_destroy (GTK_WIDGET (win->dialog)); /* Close and destroy */ 00190 g_free(win); 00191 00192 return retval; 00193 }
|
|
||||||||||||
|
This function is called whenever the commodity namespace combo box is changed. Its function is to update the commodity name combo box with the strings that are appropriate to the selected namespace.
Definition at line 370 of file dialog-commodity.c. 00372 { 00373 SelectCommodityWindow * w = user_data; 00374 const char * namespace; 00375 00376 ENTER("entry=%p, user_data=%p", entry, user_data); 00377 namespace = gnc_ui_namespace_picker_ns (w->namespace_combo); 00378 DEBUG("namespace=%s", namespace); 00379 gnc_ui_update_commodity_picker(w->commodity_combo, namespace, NULL); 00380 LEAVE(" "); 00381 }
|
|
||||||||||||
|
This function is called whenever the user clicks on the "New" button in the commodity picker. Its function is pop up a new dialog alling the user to create a new commodity.
Definition at line 290 of file dialog-commodity.c. 00292 { 00293 SelectCommodityWindow * w = user_data; 00294 00295 const char * namespace = gnc_ui_namespace_picker_ns (w->namespace_combo); 00296 00297 const gnc_commodity * new_commodity = 00298 gnc_ui_new_commodity_modal_full(namespace, 00299 w->dialog, 00300 w->default_exchange_code, 00301 w->default_fullname, 00302 w->default_mnemonic, 00303 w->default_fraction); 00304 if(new_commodity) { 00305 gnc_ui_update_namespace_picker(w->namespace_combo, 00306 gnc_commodity_get_namespace(new_commodity), 00307 DIAG_COMM_ALL); 00308 gnc_ui_update_commodity_picker(w->commodity_combo, 00309 gnc_commodity_get_namespace(new_commodity), 00310 gnc_commodity_get_printname(new_commodity)); 00311 } 00312 }
|
|
||||||||||||||||
|
Given a combo box, fill in all the known commodities for the specified namespace, and then select one.
Definition at line 395 of file dialog-commodity.c. 00398 { 00399 GList * commodities; 00400 GList * iterator = NULL; 00401 GList * commodity_items = NULL; 00402 gnc_commodity_table *table; 00403 const char * current; 00404 00405 table = gnc_book_get_commodity_table (gnc_get_current_book ()); 00406 commodities = gnc_commodity_table_get_commodities(table, namespace); 00407 00408 for(iterator = commodities; iterator; iterator = iterator->next) { 00409 commodity_items = 00410 g_list_append(commodity_items, 00411 (gpointer) gnc_commodity_get_printname(iterator->data)); 00412 } 00413 commodity_items = g_list_sort(commodity_items, g_strcmp); 00414 00415 if(!commodity_items) { 00416 commodity_items = g_list_append(commodity_items, ""); 00417 } 00418 gtk_combo_set_popdown_strings(GTK_COMBO(combobox), 00419 commodity_items); 00420 00421 if(init_string) { 00422 current = init_string; 00423 } 00424 else { 00425 current = commodity_items->data; 00426 } 00427 00428 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combobox)->entry), current); 00429 00430 /* free the lists */ 00431 g_list_free(commodities); 00432 g_list_free(commodity_items); 00433 }
|
|
||||||||||||||||
|
Given a combo box, fill in the known commodity namespaces and then select one.
Definition at line 512 of file dialog-commodity.c. 00515 { 00516 GList * namespaces, *node; 00517 const char * active; 00518 00519 /* fetch a list of the namespaces */ 00520 switch (mode) { 00521 case DIAG_COMM_ALL: 00522 namespaces = 00523 gnc_commodity_table_get_namespaces (gnc_get_current_commodities()); 00524 break; 00525 00526 case DIAG_COMM_NON_CURRENCY: 00527 namespaces = 00528 gnc_commodity_table_get_namespaces (gnc_get_current_commodities()); 00529 node = g_list_find_custom (namespaces, GNC_COMMODITY_NS_ISO, g_strcmp); 00530 if (node) { 00531 namespaces = g_list_remove_link (namespaces, node); 00532 g_list_free_1 (node); 00533 } 00534 00535 if (gnc_commodity_namespace_is_iso (init_string)) 00536 init_string = NULL; 00537 break; 00538 00539 case DIAG_COMM_CURRENCY: 00540 default: 00541 namespaces = g_list_prepend (NULL, "CURRENCY"); 00542 break; 00543 } 00544 00545 /* Legacy namespace should never be seen */ 00546 node = g_list_find_custom (namespaces, GNC_COMMODITY_NS_LEGACY, g_strcmp); 00547 if (node) { 00548 namespaces = g_list_remove_link (namespaces, node); 00549 g_list_free_1 (node); 00550 } 00551 00552 /* stick them in the combobox */ 00553 namespaces = g_list_sort(namespaces, g_strcmp); 00554 gtk_combo_set_popdown_strings (GTK_COMBO (combobox), namespaces); 00555 00556 /* set the entry text */ 00557 if (init_string) 00558 active = init_string; 00559 else if (namespaces) 00560 active = namespaces->data; 00561 else 00562 active = ""; 00563 00564 if (safe_strcmp (active, GNC_COMMODITY_NS_ISO) == 0 || 00565 safe_strcmp (active, "CURRENCY") == 0 || 00566 safe_strcmp (init_string, "CURRENCY") == 0) 00567 { 00568 active = "CURRENCY"; 00569 } 00570 00571 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combobox)->entry), active); 00572 g_list_free(namespaces); 00573 }
|
1.4.3-20050530