GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Tools

Files

file  dialog-bi-import-gui.h
 GUI handling for bi-import plugin.
 
file  dialog-bi-import.h
 core import functions for invoice import plugin
 
file  gnc-plugin-bi-import.h
 Plugin registration of the bi-import module.
 
file  dialog-customer-import-gui.h
 GUI handling for customer import plugin.
 
file  dialog-customer-import.h
 core import functions for customer import plugin
 
file  gnc-plugin-customer_import.h
 Plugin registration of the customer_import module.
 

Data Structures

struct  _bi_import_stats
 
struct  GncPluginbi_import
 
struct  GncPluginbi_importClass
 
struct  _customer_import_stats
 
struct  GncPlugincustomer_import
 
struct  GncPlugincustomer_importClass
 
struct  GncPluginexample
 
struct  GncPluginexampleClass
 

Macros

#define GNC_TYPE_PLUGIN_BI_IMPORT   (gnc_plugin_bi_import_get_type())
 
#define GNC_PLUGIN_BI_IMPORT(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_BI_IMPORT, GncPluginbi_import))
 
#define GNC_PLUGIN_BI_IMPORT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_BI_IMPORT, GncPluginbi_importClass))
 
#define GNC_IS_PLUGIN_BI_IMPORT(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_BI_IMPORT))
 
#define GNC_IS_PLUGIN_BI_IMPORT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_BI_IMPORT))
 
#define GNC_PLUGIN_BI_IMPORT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_BI_IMPORT, GncPluginbi_importClass))
 
#define GNC_PLUGIN_BI_IMPORT_NAME   "gnc-plugin-bi_import"
 
#define GNC_TYPE_PLUGIN_customer_import   (gnc_plugin_customer_import_get_type())
 
#define GNC_PLUGIN_customer_import(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_customer_import, GncPlugincustomer_import))
 
#define GNC_PLUGIN_customer_import_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_customer_import, GncPlugincustomer_importClass))
 
#define GNC_IS_PLUGIN_customer_import(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_customer_import))
 
#define GNC_IS_PLUGIN_customer_import_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_customer_import))
 
#define GNC_PLUGIN_customer_import_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_customer_import, GncPlugincustomer_importClass))
 
#define GNC_PLUGIN_customer_import_NAME   "gnc-plugin-customer_import"
 
#define GNC_TYPE_PLUGIN_example   (gnc_plugin_example_get_type())
 
#define GNC_PLUGIN_example(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_example, GncPluginexample))
 
#define GNC_PLUGIN_example_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_example, GncPluginexampleClass))
 
#define GNC_IS_PLUGIN_example(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_example))
 
#define GNC_IS_PLUGIN_example_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_example))
 
#define GNC_PLUGIN_example_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_example, GncPluginexampleClass))
 
#define GNC_PLUGIN_example_NAME   "gnc-plugin-example"
 

Typedefs

typedef typedefG_BEGIN_DECLS
struct _bi_import_gui 
BillImportGui
 
typedef enum _bi_import_result bi_import_result
 
typedef struct _bi_import_stats bi_import_stats
 
typedef typedefG_BEGIN_DECLS
struct _customer_import_gui 
CustomerImportGui
 
typedef enum
_customer_import_result 
customer_import_result
 
typedef struct
_customer_import_stats 
customer_import_stats
 

Enumerations

enum  bi_import_model_columns {
  ID, DATE_OPENED, OWNER_ID, BILLING_ID,
  NOTES, DATE, DESC, ACTION,
  ACCOUNT, QUANTITY, PRICE, DISC_TYPE,
  DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED,
  TAX_TABLE, DATE_POSTED, DUE_DATE, ACCOUNT_POSTED,
  MEMO_POSTED, ACCU_SPLITS, N_COLUMNS
}
 
enum  _bi_import_result { RESULT_OK, RESULT_OPEN_FAILED, RESULT_ERROR_IN_REGEXP }
 
enum  customer_import_model_columns {
  CI_ID, CI_COMPANY, CI_NAME, CI_ADDR1,
  CI_ADDR2, CI_ADDR3, CI_ADDR4, CI_PHONE,
  CI_FAX, CI_EMAIL, CI_NOTES, CI_SHIPNAME,
  CI_SHIPADDR1, CI_SHIPADDR2, CI_SHIPADDR3, CI_SHIPADDR4,
  CI_SHIPPHONE, CI_SHIPFAX, CI_SHIPEMAIL, CI_N_COLUMNS
}
 
enum  _customer_import_result { CI_RESULT_OK, CI_RESULT_OPEN_FAILED, CI_RESULT_ERROR_IN_REGEXP }
 

Functions

BillImportGui * gnc_plugin_bi_import_showGUI (void)
 
bi_import_result gnc_bi_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows, bi_import_stats *stats)
 
void gnc_bi_import_fix_bis (GtkListStore *store, guint *fixed, guint *deleted, GString *info, gchar *type)
 try to fix some common errors in the csv representation of invoices More...
 
void gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated, gchar *type, gchar *open_mode, GString *info)
 
GType gnc_plugin_bi_import_get_type (void)
 
GncPlugingnc_plugin_bi_import_new (void)
 
void gnc_plugin_bi_import_create_plugin (void)
 
CustomerImportGui * gnc_plugin_customer_import_showGUI (void)
 
customer_import_result gnc_customer_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows, customer_import_stats *stats)
 
void gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *deleted, gchar *type)
 
void gnc_customer_import_create_customers (GtkListStore *store, QofBook *book, guint *n_customers_created, guint *n_customers_updated, gchar *type)
 
GType gnc_plugin_customer_import_get_type (void)
 
GncPlugingnc_plugin_customer_import_new (void)
 
void gnc_plugin_customer_import_create_plugin (void)
 
GType gnc_plugin_example_get_type (void)
 
GncPlugingnc_plugin_example_new (void)
 
void gnc_plugin_example_create_plugin (void)
 

Detailed Description

Function Documentation

void gnc_bi_import_fix_bis ( GtkListStore *  store,
guint *  fixed,
guint *  deleted,
GString *  info,
gchar *  type 
)

try to fix some common errors in the csv representation of invoices

  • corrects the date format
  • corrects ambigous values in multi line invoices
  • ensures customer exists
  • if quantity is unset, set to 1
  • if price is unset, delete row

Definition at line 231 of file dialog-bi-import.c.

233 {
234  GtkTreeIter iter;
235  gboolean valid, row_deleted, row_fixed;
236  gchar *id, *date_opened, *date_posted, *due_date, *owner_id, *date, *quantity, *price;
237  GString *prev_id, *prev_date_opened, *prev_date_posted, *prev_owner_id, *prev_date; // needed to fix multi line invoices
238  guint dummy;
239  gint row = 1;
240  const gchar* date_format_string = qof_date_format_get_string (qof_date_format_get()); // Get the user set date format string
241 
242 
243  //date_format_string = qof_date_format_get_string (qof_date_format_get());
244 
245  DEBUG("date_format_string: %s",date_format_string);
246  // allow the call to this function with only GtkListeStore* specified
247  if (!fixed)
248  fixed = &dummy;
249  if (!deleted)
250  deleted = &dummy;
251 
252  *fixed = 0;
253  *deleted = 0;
254 
255  // init strings
256  prev_id = g_string_new ("");
257  prev_date_opened = g_string_new ("");
258  prev_date_posted = g_string_new ("");
259  prev_owner_id = g_string_new ("");
260  prev_date = g_string_new ("");
261 
262  valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
263  while (valid)
264  {
265  row_deleted = FALSE;
266  row_fixed = FALSE;
267 
268  // Walk through the list, reading each row
269  gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
270  ID, &id,
271  DATE_OPENED, &date_opened,
272  DATE_POSTED, &date_posted,
273  DUE_DATE, &due_date,
274  OWNER_ID, &owner_id,
275  DATE, &date,
276  QUANTITY, &quantity, PRICE, &price, -1);
277 
278  if (strlen (price) == 0)
279  {
280  // invalid row (no price given)
281  // no fix possible -> delete row
282  valid = gtk_list_store_remove (store, &iter);
283  row_deleted = TRUE;
284  g_string_append_printf (info,
285  _("ROW %d DELETED, PRICE_NOT_SET: id=%s\n"),
286  row, id);
287  }
288  // TODO: QTY get set to 1 later if field is empty. Delete this section?
289  else if (strlen (quantity) == 0)
290  {
291  // invalid row (no quantity given)
292  // no fix possible -> delete row
293  valid = gtk_list_store_remove (store, &iter);
294  row_deleted = TRUE;
295  g_string_append_printf (info, _("ROW %d DELETED, QTY_NOT_SET: id=%s\n"),
296  row, id);
297  }
298  else
299  { // TODO: If id is empty get the next one in the series. Bug 731105
300  if (strlen (id) == 0)
301  {
302  // no invoice id specified
303  if (prev_id->len == 0)
304  {
305  // cannot fix -> delete row
306  valid = gtk_list_store_remove (store, &iter);
307  row_deleted = TRUE;
308  g_string_append_printf (info,
309  _("ROW %d DELETED, ID_NOT_SET\n"), row);
310  }
311  else
312  {
313  // this is a fixable multi line invoice
314  gtk_list_store_set (store, &iter, ID, prev_id->str, -1);
315  row_fixed = TRUE;
316  }
317  }
318  else
319  {
320  // remember invoice id (to be able to fix multi line invoices)
321  g_string_assign (prev_id, id);
322  // new invoice => reset all other fixable entries
323  g_string_assign (prev_date_opened, "");
324  g_string_assign (prev_date_posted, "");
325  g_string_assign (prev_owner_id, "");
326  g_string_assign (prev_date, "");
327  }
328  }
329 
330  if (!row_deleted)
331  {
332  // the row is valid (price and id are valid)
333 
334  if(!isDateValid(date_opened))
335  {
336  if (prev_date_opened->len == 0)
337  {
338  // fix this by using the current date
339  gchar temp[20];
340  GDate date;
341  g_date_clear (&date, 1);
342  gnc_gdate_set_today (&date);
343  g_date_strftime (temp, 20, date_format_string, &date); // Create a user specified date string.
344  g_string_assign (prev_date_opened, temp);
345  }
346  // fix this by using the previous date_opened value (multi line invoice)
347  gtk_list_store_set (store, &iter, DATE_OPENED,
348  prev_date_opened->str, -1);
349  row_fixed = TRUE;
350  }
351  else
352  {
353  // remember date_opened (to be able to fix multi line invoices)
354  g_string_assign (prev_date_opened, date_opened);
355  }
356 
357  // date_opened is valid
358 
359  if(!isDateValid(date_posted))
360  {
361  if (prev_date_posted->len == 0)
362  {
363  // this invoice will have to get posted manually
364  }
365  else
366  {
367  // multi line invoice => fix it
368  gtk_list_store_set (store, &iter, DATE_POSTED,
369  prev_date_posted->str, -1);
370  row_fixed = TRUE;
371  }
372  }
373  else
374  {
375  // remember date_opened (to be able to fix multi line invoices)
376  g_string_assign (prev_date_posted, date_posted);
377  }
378 
379  // date_posted is valid
380  /*
381  // Check if due date is valid. Set it to date_posted if not valid or missing.
382  if(!isDateValid(due_date))
383  {
384  gtk_list_store_set (store, &iter, DUE_DATE,
385  date_posted, -1);
386  row_fixed = TRUE;
387 
388  }
389 
390  // due_date is valid
391  */
392  if (strlen (quantity) == 0)
393  {
394  // quantity is unset => set to 1
395  gtk_list_store_set (store, &iter, QUANTITY, "1", -1);
396  row_fixed = TRUE;
397  }
398 
399 
400  // quantity is valid
401 
402  if (strlen (owner_id) == 0)
403  {
404  if (prev_owner_id->len == 0)
405  {
406  // no customer given and not fixable => delete row
407  valid = gtk_list_store_remove (store, &iter);
408  row_deleted = TRUE;
409  g_string_append_printf (info,
410  _("ROW %d DELETED, OWNER_NOT_SET: id=%s\n"),
411  row, id);
412  }
413  else
414  {
415  gtk_list_store_set (store, &iter, owner_id,
416  prev_owner_id->str, -1);
417  row_fixed = TRUE;
418  }
419  }
420  else
421  {
422  // remember owner_id
423  g_string_assign (prev_owner_id, owner_id);
424  }
425  if (g_ascii_strcasecmp (type, "BILL") == 0)
426  {
427  // BILL: check, if vendor exists
428  if (!gnc_search_vendor_on_id
429  (gnc_get_current_book (), prev_owner_id->str))
430  {
431  // vendor not found => delete row
432  valid = gtk_list_store_remove (store, &iter);
433  row_deleted = TRUE;
434  g_string_append_printf (info,
435  _("ROW %d DELETED, VENDOR_DOES_NOT_EXIST: id=%s\n"),
436  row, id);
437  }
438  }
439  else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
440  {
441  // INVOICE: check, if customer exists
442  if (!gnc_search_customer_on_id
443  (gnc_get_current_book (), prev_owner_id->str))
444  {
445  // customer not found => delete row
446  valid = gtk_list_store_remove (store, &iter);
447  row_deleted = TRUE;
448  g_string_append_printf (info,
449  _("ROW %d DELETED, CUSTOMER_DOES_NOT_EXIST: id=%s\n"),
450  row, id);
451  }
452  }
453 
454  // owner_id is valid
455  }
456 
457  g_free (id);
458  g_free (date_opened);
459  g_free (date_posted);
460  g_free (owner_id);
461  g_free (date);
462  g_free (quantity);
463  g_free (price);
464  if (row_deleted)
465  {
466  (*deleted)++;
467  // reset all remembered values
468  g_string_assign (prev_id, "");
469  g_string_assign (prev_date_opened, "");
470  g_string_assign (prev_date_posted, "");
471  g_string_assign (prev_owner_id, "");
472  g_string_assign (prev_date, "");
473  }
474  else if (row_fixed)
475  (*fixed)++;
476 
477  if (!row_deleted)
478  valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
479 
480  row++;
481  }
482 
483  // deallocate strings
484  g_string_free (prev_id, TRUE);
485  g_string_free (prev_date_opened, TRUE);
486  g_string_free (prev_date_posted, TRUE);
487  g_string_free (prev_owner_id, TRUE);
488  g_string_free (prev_date, TRUE);
489 
490  if (info && (info->len > 0))
491  {
492  g_string_prepend (info, "\n\n");
493  g_string_prepend (info, _("These rows were deleted:"));
494  }
495 }
void gnc_gdate_set_today(GDate *gd)
#define DEBUG(format, args...)
Definition: qoflog.h:255
const gchar * qof_date_format_get_string(QofDateFormat df)
QofDateFormat qof_date_format_get(void)
void gnc_plugin_bi_import_create_plugin ( void  )

Create a new GncPluginbi_import object and register it.

GType gnc_plugin_bi_import_get_type ( void  )
Returns
The glib runtime type of an bi_import plugin page
GncPlugin* gnc_plugin_bi_import_new ( void  )
Returns
A new GncPluginbi_import object

Definition at line 69 of file gnc-plugin-bi-import.c.

70 {
71  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_BI_IMPORT, (gchar*) NULL));
72 }
BillImportGui* gnc_plugin_bi_import_showGUI ( void  )

File chooser

Definition at line 81 of file dialog-bi-import-gui.c.

82 {
83  BillImportGui *gui;
84  GtkBuilder *builder;
85  GList *glist;
86  GtkCellRenderer *renderer;
87  GtkTreeViewColumn *column;
88 
89  // if window exists already, activate it
90  glist = gnc_find_gui_components ("dialog-bi-import-gui", NULL, NULL);
91  if (glist)
92  {
93  // window found
94  gui = g_list_nth_data (glist, 0);
95  g_list_free (glist);
96  gtk_window_present (GTK_WINDOW(gui->dialog));
97  return gui;
98  }
99 
100  // create new window
101  gui = g_new0 (BillImportGui, 1);
102  gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
103  gui->open_mode = "ALL";
104 
105  builder = gtk_builder_new();
106  gnc_builder_add_from_file (builder, "dialog-bi-import-gui.glade", "bi-import Dialog");
107  gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "bi-import Dialog"));
108  gui->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview1"));
109  gui->entryFilename = GTK_WIDGET(gtk_builder_get_object (builder, "entryFilename"));
110 
111  gui->book = gnc_get_current_book();
112 
113  gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billing_id>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)$");
114 
115  // create model and bind to view
116  gui->store = gtk_list_store_new (N_COLUMNS,
117  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
118  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
119  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
120  gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
121 #define CREATE_COLUMN(description,column_id) \
122  renderer = gtk_cell_renderer_text_new (); \
123  column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
124  gtk_tree_view_column_set_resizable (column, TRUE); \
125  gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
126  CREATE_COLUMN ("id", ID);
127  CREATE_COLUMN ("date__opened", DATE_OPENED);
128  CREATE_COLUMN ("owner__id", OWNER_ID);
129  CREATE_COLUMN ("billing__id", BILLING_ID);
130  CREATE_COLUMN ("notes", NOTES);
131 
132  CREATE_COLUMN ("date", DATE);
133  CREATE_COLUMN ("desc", DESC);
134  CREATE_COLUMN ("action", ACTION);
135  CREATE_COLUMN ("account", ACCOUNT);
136  CREATE_COLUMN ("quantity", QUANTITY);
137  CREATE_COLUMN ("price", PRICE);
138  CREATE_COLUMN ("disc__type", DISC_TYPE);
139  CREATE_COLUMN ("disc__how", DISC_HOW);
140  CREATE_COLUMN ("discount", DISCOUNT);
141  CREATE_COLUMN ("taxable", TAXABLE);
142  CREATE_COLUMN ("taxincluded", TAXINCLUDED);
143  CREATE_COLUMN ("tax__table", TAX_TABLE);
144 
145  CREATE_COLUMN ("date__posted", DATE_POSTED);
146  CREATE_COLUMN ("due__date", DUE_DATE);
147  CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
148  CREATE_COLUMN ("memo__posted", MEMO_POSTED);
149  CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
150 
151  gui->component_id = gnc_register_gui_component ("dialog-bi-import-gui",
152  NULL,
153  gnc_bi_import_gui_close_handler,
154  gui);
155 
156  /* Setup signals */
157  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, gui);
158 
159  gtk_widget_show_all ( gui->dialog );
160 
161  g_object_unref(G_OBJECT(builder));
162 
163  return gui;
164 }
void gnc_plugin_customer_import_create_plugin ( void  )

Create a new GncPlugincustomer_import object and register it.

GType gnc_plugin_customer_import_get_type ( void  )
Returns
The glib runtime type of an customer_import plugin page
GncPlugin* gnc_plugin_customer_import_new ( void  )
Returns
A new GncPlugincustomer_import object

Definition at line 69 of file gnc-plugin-customer_import.c.

70 {
71  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_customer_import, (gchar*) NULL));
72 }
CustomerImportGui* gnc_plugin_customer_import_showGUI ( void  )

File chooser

Definition at line 77 of file dialog-customer-import-gui.c.

78 {
79  CustomerImportGui *gui;
80  //gktbuilderXML *xml;
81  GtkBuilder *builder;
82  GList *glist;
83  GtkCellRenderer *renderer;
84  GtkTreeViewColumn *column;
85 
86  // if window exists already, activate it
87  glist = gnc_find_gui_components ("dialog-customer_import_gui", NULL, NULL);
88  if (glist)
89  {
90  // window found
91  gui = g_list_nth_data (glist, 0);
92  g_list_free (glist);
93  gtk_window_present (GTK_WINDOW(gui->dialog));
94  return gui;
95  }
96 
97  // create new window
98  gui = g_new0 (CustomerImportGui, 1);
99 
100  builder = gtk_builder_new();
101  gnc_builder_add_from_file (builder, "dialog-customer-import-gui.glade", "customer_import Dialog");
102  gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "customer_import Dialog"));
103  gui->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview1"));
104  gui->entryFilename = GTK_WIDGET(gtk_builder_get_object (builder, "entryFilename"));
105  gui->type = "CUSTOMER"; // Set a default type to import
106 
107  gui->regexp = g_string_new ( "^(?<id>[^;]+);(?<company>[^;]*);(?<name>[^;]+);(?<addr1>[^;]+);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipaddr4>[^;]*);?(?<shipphone>[^;]*);?(?<shipfax>[^;]*);?(?<shipemail>[^;]*)");
108  gui->book = gnc_get_current_book();
109 
110  // create model and bind to view
111  gui->store = gtk_list_store_new (CI_N_COLUMNS,
112  G_TYPE_STRING, G_TYPE_STRING,
113  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
114  G_TYPE_STRING,
115  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
116  gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
117 #define CREATE_COLUMN(description,column_id) \
118  renderer = gtk_cell_renderer_text_new (); \
119  column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
120  gtk_tree_view_column_set_resizable (column, TRUE); \
121  gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
122  CREATE_COLUMN ("id", CI_ID);
123  CREATE_COLUMN ("company", CI_COMPANY);
124  CREATE_COLUMN ("name", CI_NAME);
125  CREATE_COLUMN ("addr1", CI_ADDR1);
126  CREATE_COLUMN ("addr2", CI_ADDR2);
127  CREATE_COLUMN ("addr3", CI_ADDR3);
128  CREATE_COLUMN ("addr4", CI_ADDR4);
129  CREATE_COLUMN ("phone", CI_PHONE);
130  CREATE_COLUMN ("fax", CI_FAX);
131  CREATE_COLUMN ("email", CI_EMAIL);
132  CREATE_COLUMN ("notes", CI_NOTES);
133  CREATE_COLUMN ("shipname", CI_SHIPNAME);
134  CREATE_COLUMN ("shipaddr1", CI_SHIPADDR1);
135  CREATE_COLUMN ("shipaddr2", CI_SHIPADDR2);
136  CREATE_COLUMN ("shipaddr3", CI_SHIPADDR3);
137  CREATE_COLUMN ("shipaddr4", CI_SHIPADDR4);
138  CREATE_COLUMN ("shipphone", CI_SHIPPHONE);
139  CREATE_COLUMN ("shipfax", CI_SHIPFAX);
140  CREATE_COLUMN ("shipemail", CI_SHIPEMAIL);
141 
142  gui->component_id = gnc_register_gui_component ("dialog-customer_import_gui",
143  NULL,
144  gnc_customer_import_gui_close_handler,
145  gui);
146 
147  /* Setup signals */
148  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, gui);
149  gtk_widget_show_all ( gui->dialog );
150  return gui;
151 }
void gnc_plugin_example_create_plugin ( void  )

Create a new GncPluginexample object and register it.

GType gnc_plugin_example_get_type ( void  )
Returns
The glib runtime type of an example plugin page
GncPlugin* gnc_plugin_example_new ( void  )
Returns
A new GncPluginexample object

Definition at line 64 of file gnc-plugin.example.c.

65 {
66  return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_example, (gchar*) NULL));
67 }