Commit c5649751 authored by Maxime Doyen's avatar Maxime Doyen

5.1 beta2

parent 4b1fac02
......@@ -40,9 +40,9 @@ da_asg_free(Assign *item)
DB( g_print("da_asg_free\n") );
if(item != NULL)
{
DB( g_print(" => %d, %s\n", item->key, item->name) );
DB( g_print(" => %d, %s\n", item->key, item->text) );
g_free(item->name);
g_free(item->text);
g_free(item);
}
}
......@@ -80,9 +80,9 @@ static void da_asg_max_key_ghfunc(gpointer key, Assign *item, guint32 *max_key)
static gboolean da_asg_name_grfunc(gpointer key, Assign *item, gchar *name)
{
if( name && item->name )
if( name && item->text )
{
if(!strcasecmp(name, item->name))
if(!strcasecmp(name, item->text))
return TRUE;
}
return FALSE;
......@@ -154,12 +154,12 @@ guint32 *new_key;
DB( g_print("da_asg_append\n") );
DB( g_print(" -> try append: %s\n", item->name) );
DB( g_print(" -> try append: %s\n", item->text) );
if( item->name != NULL )
if( item->text != NULL )
{
/* ensure no duplicate */
existitem = da_asg_get_by_name( item->name );
existitem = da_asg_get_by_name( item->text );
if( existitem == NULL )
{
new_key = g_new0(guint32, 1);
......@@ -173,7 +173,7 @@ guint32 *new_key;
}
}
DB( g_print(" -> %s already exist: %d\n", item->name, item->key) );
DB( g_print(" -> %s already exist: %d\n", item->text, item->key) );
return FALSE;
}
......@@ -263,7 +263,7 @@ da_asg_debug_list_ghfunc(gpointer key, gpointer value, gpointer user_data)
guint32 *id = key;
Assign *item = value;
DB( g_print(" %d :: %s\n", *id, item->name) );
DB( g_print(" %d :: %s\n", *id, item->text) );
}
......
......@@ -29,17 +29,23 @@ struct _assign
guint32 key;
gushort flags;
gushort field;
gchar *name;
gchar *text;
guint32 kpay;
guint32 kcat;
gushort paymode;
};
#define ASGF_EXACT (1<<0)
#define ASGF_DOPAY (1<<1)
#define ASGF_DOCAT (1<<2)
#define ASGF_OVWPAY (1<<3)
#define ASGF_OVWCAT (1<<4)
#define ASGF_DOMOD (1<<3)
#define ASGF_REGEX (1<<8)
#define ASGF_OVWPAY (1<<9)
#define ASGF_OVWCAT (1<<10)
#define ASGF_OVWMOD (1<<11)
void
da_asg_free(Assign *item);
......
......@@ -347,8 +347,8 @@ guint cnt, i;
if(item->key != 0)
{
g_free(item->name);
item->name = g_strdup_printf("assign %d", item->key);
g_free(item->text);
item->text = g_strdup_printf("assign %d", item->key);
GLOBALS->changes_count++;
}
list = g_list_next(list);
......
......@@ -50,6 +50,8 @@ void hb_string_strip_crlf(gchar *str);
void hb_string_replace_char(gchar c, gchar *str);
gchar* hb_strdup_nobrackets (const gchar *str);
gchar *hb_sprint_date(gchar *outstr, guint32 julian);
gboolean hb_string_csv_valid(gchar *str, guint nbcolumns, gint *csvtype);
guint32 hb_date_get_julian(gchar *string, gint datefmt);
......
......@@ -942,6 +942,22 @@ gboolean match = FALSE;
return match;
}
static gboolean misc_regex_match(gchar *text, gchar *searchtext, gboolean exact)
{
gboolean match = FALSE;
if(text == NULL)
return FALSE;
DB( g_print("match RE %s in %s\n", searchtext, text) );
if( searchtext != NULL )
{
match = g_regex_match_simple(searchtext, text, ((exact == TRUE)?0:G_REGEX_CASELESS) | G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY );
if (match == TRUE) { DB( g_print(" found pattern '%s'\n", searchtext) ); }
}
return match;
}
static Assign *transaction_auto_assign_eval_txn(GList *l_rul, Transaction *txn)
{
......@@ -963,8 +979,17 @@ GList *list;
if(pay)
text = pay->name;
}
if( misc_text_match(text, rul->name, rul->flags & ASGF_EXACT))
rule = rul;
if( !(rul->flags & ASGF_REGEX) )
{
if( misc_text_match(text, rul->text, rul->flags & ASGF_EXACT) )
rule = rul;
}
else
{
if( misc_regex_match(text, rul->text, rul->flags & ASGF_EXACT) )
rule = rul;
}
list = g_list_next(list);
}
......@@ -987,8 +1012,16 @@ GList *list;
if( rul->field == 0 ) //memo
{
if( misc_text_match(text, rul->name, rul->flags & ASGF_EXACT))
rule = rul;
if( !(rul->flags & ASGF_REGEX) )
{
if( misc_text_match(text, rul->text, rul->flags & ASGF_EXACT) )
rule = rul;
}
else
{
if( misc_regex_match(text, rul->text, rul->flags & ASGF_EXACT) )
rule = rul;
}
}
list = g_list_next(list);
}
......@@ -1037,6 +1070,17 @@ gint changes = 0;
ope->kcat = rul->kcat;
}
}
if( (ope->paymode == 0 || (rul->flags & ASGF_OVWMOD)) && (rul->flags & ASGF_DOMOD) )
{
//ugly hack - don't allow modify intxfer
if(ope->paymode != PAYMODE_INTXFER && rul->paymode != PAYMODE_INTXFER)
{
if(ope->paymode != rul->paymode) { changed = TRUE; }
ope->paymode = rul->paymode;
}
}
}
if( ope->flags & OF_SPLIT )
......
......@@ -439,10 +439,10 @@ gint i;
if(!strcmp (attribute_names[i], "key" )) { entry->key = atoi(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "flags" )) { entry->flags = atoi(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "field" )) { entry->field = atoi(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "name" )) { if(strcmp(attribute_values[i],"(null)") && attribute_values[i] != NULL) entry->name = g_strdup(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "name" )) { if(strcmp(attribute_values[i],"(null)") && attribute_values[i] != NULL) entry->text = g_strdup(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "payee" )) { entry->kpay = atoi(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "category")) { entry->kcat = atoi(attribute_values[i]); }
//else if(!strcmp (attribute_names[i], "paymode" )) { entry->paymode = atoi(attribute_values[i]); }
else if(!strcmp (attribute_names[i], "paymode" )) { entry->paymode = atoi(attribute_values[i]); }
// prior v08
else if(!strcmp (attribute_names[i], "exact" )) { exact = atoi(attribute_values[i]); }
}
......@@ -1347,10 +1347,10 @@ GError *error = NULL;
hb_xml_append_int(node, "key" , item->key);
hb_xml_append_int(node, "flags" , item->flags);
hb_xml_append_int(node, "field" , item->field);
hb_xml_append_txt(node, "name" , item->name);
hb_xml_append_txt(node, "name" , item->text);
hb_xml_append_int(node, "payee" , item->kpay);
hb_xml_append_int(node, "category", item->kcat);
//hb_xml_append_int(node, "paymode" , item->paymode);
hb_xml_append_int(node, "paymode" , item->paymode);
g_string_append(node, "/>\n");
......
......@@ -1296,6 +1296,8 @@ gint w, h, row;
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin), GTK_SHADOW_ETCHED_IN);
gtk_container_add (GTK_CONTAINER (scrollwin), widget);
gtk_widget_set_hexpand (scrollwin, TRUE);
gtk_widget_set_vexpand (scrollwin, TRUE);
data.TB_notes = widget;
gtk_grid_attach (GTK_GRID (group_grid), scrollwin, 2, row, 1, 1);
......
This diff is collapsed.
......@@ -58,15 +58,26 @@ struct ui_asg_manage_data
GtkWidget *BT_add, *BT_rem;
GtkWidget *GR_condition;
GtkWidget *GR_assignment;
GtkWidget *CY_field;
GtkWidget *ST_text;
GtkWidget *ST_name;
GtkWidget *CM_exact;
GtkWidget *CM_pay, *PO_pay;
GtkWidget *CM_cat, *PO_cat;
GtkWidget *CM_re;
GtkWidget *GR_assignment;
GtkWidget *GR_pay;
GtkWidget *RA_pay;
GtkWidget *LB_pay;
GtkWidget *PO_pay;
GtkWidget *GR_cat;
GtkWidget *RA_cat;
GtkWidget *LB_cat;
GtkWidget *PO_cat;
GtkWidget *GR_mod;
GtkWidget *RA_mod;
GtkWidget *LB_mod;
GtkWidget *NU_mod;
};
......
......@@ -871,7 +871,7 @@ gint crow;
data->showtemplate = TRUE;
crow = 1;
crow++;
expander = gtk_expander_new (_("Fill in with a template"));
gtk_expander_set_expanded (GTK_EXPANDER(expander), TRUE);
gtk_grid_attach (GTK_GRID (content_grid), expander, 0, crow, 2, 1);
......@@ -890,7 +890,7 @@ gint crow;
gtk_widget_show_all(expander);
}
crow = 2;
crow++;
bar = gtk_info_bar_new ();
data->IB_warnsign = bar;
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_WARNING);
......
......@@ -861,34 +861,65 @@ gchar *get_paymode_icon_name(gint index)
/*
** Make a paymode combobox widget
*/
GtkWidget *make_paymode(GtkWidget *label)
static void
paymode_set_sensitive (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
GtkListStore *store;
GtkTreeIter iter;
GtkTreePath *path;
gint *indices;
gboolean sensitive;
path = gtk_tree_model_get_path (tree_model, iter);
indices = gtk_tree_path_get_indices (path);
sensitive = (indices[0] == PAYMODE_INTXFER) ? FALSE : TRUE;
gtk_tree_path_free (path);
g_object_set (cell, "sensitive", sensitive, NULL);
}
static GtkWidget *make_paymode_internal(GtkWidget *label, gboolean intxfer)
{
GtkListStore *store;
GtkTreeIter iter;
GtkWidget *combobox;
GtkCellRenderer *renderer;
GtkCellRenderer *renderer, *r1, *r2;
guint i;
//store
store = gtk_list_store_new (
NUM_LST_PAYMODE,
G_TYPE_STRING,
G_TYPE_STRING
);
//combobox
combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
//column 1
renderer = gtk_cell_renderer_pixbuf_new();
renderer = r1 = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), renderer, FALSE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combobox), renderer, "icon-name", LST_PAYMODE_ICONNAME);
renderer = gtk_cell_renderer_text_new();
renderer = r2 = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), renderer, FALSE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combobox), renderer, "text", LST_PAYMODE_LABEL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
if( intxfer == FALSE )
{
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
r1,
paymode_set_sensitive,
NULL, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
r2,
paymode_set_sensitive,
NULL, NULL);
}
//populate our combobox model
for(i=0;i<NUM_PAYMODE_MAX;i++)
......@@ -908,6 +939,20 @@ guint i;
return combobox;
}
GtkWidget *make_paymode(GtkWidget *label)
{
return make_paymode_internal(label, TRUE);
}
GtkWidget *make_paymode_nointxfer(GtkWidget *label)
{
return make_paymode_internal(label, FALSE);
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
#define NUM_NAINEX_MAX 3
......
......@@ -69,6 +69,7 @@ GtkWidget *make_popcategory(GtkWidget *label);
gchar *get_paymode_icon_name(gint index);
GtkWidget *make_paymode(GtkWidget *label);
GtkWidget *make_paymode_nointxfer(GtkWidget *label);
GtkWidget *make_nainex(GtkWidget *label);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment