Commit bb3d32cb authored by Maxime Doyen's avatar Maxime Doyen

4.5.6 release

parent 791a70d1
2014-02-28 Maxime Doyen
2014-03-01 Maxime Doyen
Made 4.5.6 release.
......
......@@ -280,7 +280,7 @@ gboolean usermode = TRUE;
static void account_export_csv(GtkWidget *widget, gpointer user_data)
{
struct account_data *data;
gchar *filename = NULL, *tmp;
gchar *filename = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean valid;
......@@ -292,10 +292,7 @@ GIOChannel *io;
if( ui_file_chooser_csv(GTK_WINDOW(data->window), GTK_FILE_CHOOSER_ACTION_SAVE, &filename, NULL) == TRUE )
{
tmp = hb_filepath_ensure_extension(filename, ".csv");
g_free(filename);
filename = tmp;
DB( g_print(" + filename is %s\n", filename) );
io = g_io_channel_new_file(filename, "w", NULL);
......
......@@ -360,11 +360,10 @@ gint result;
if( result == 1)
{
DB( g_print(" - should revert\n") );
hbfile_change_filepath(homebank_filepath_with_extention(GLOBALS->xhb_filepath, "xhb~"));
hbfile_change_filepath(hb_filename_new_with_extention(GLOBALS->xhb_filepath, "xhb~"));
ui_mainwindow_open_internal(widget, NULL);
//todo: error here after, we must set the filename bak to .xhb
hbfile_change_filepath(hb_filename_new_with_extention(GLOBALS->xhb_filepath, "xhb"));
}
......@@ -762,10 +761,13 @@ static void ui_mainwindow_action_about(void)
static void ui_mainwindow_action_export(void)
{
test_qif_export();
gchar *filename;
//create_import_window();
if( ui_file_chooser_qif(NULL, &filename) == TRUE )
{
hb_export_qif_account_all(filename);
g_free( filename );
}
}
static void ui_mainwindow_action_help(void)
......@@ -1528,7 +1530,6 @@ gint r = XML_UNSET;
homebank_file_ensure_xhb();
r = homebank_save_xml(GLOBALS->xhb_filepath);
GLOBALS->hbfile_is_new = FALSE;
}
else
return;
......
......@@ -21,7 +21,7 @@
#include "gtk-chart-colors.h"
const char *chart_colors[] =
char *chart_colors[] =
{
"HomeBank",
"Money",
......
......@@ -66,7 +66,7 @@ enum colmap
CHART_COLMAP_ANALYTICS,
};
extern const char *chart_colors[];
extern char *chart_colors[];
extern struct rgbcol global_colors[];
extern struct rgbcol money_colors[];
......
......@@ -195,14 +195,11 @@ gchar *type;
void hb_export_qif_account_single(gchar *filename, Account *acc)
{
GIOChannel *io;
gchar *newname;
newname = homebank_filepath_with_extention(filename, "qif");
io = g_io_channel_new_file(newname, "w", NULL);
io = g_io_channel_new_file(filename, "w", NULL);
if(io == NULL)
{
g_message("file error on: %s", newname);
g_message("file error on: %s", filename);
//retval = XML_IO_ERROR;
}
else
......@@ -211,24 +208,18 @@ gchar *newname;
hb_export_qif_elt_txn(io, acc);
g_io_channel_unref (io);
}
g_free(newname);
}
void hb_export_qif_account_all(gchar *filename)
{
GIOChannel *io;
gchar *newname;
GList *lacc, *list;
newname = homebank_filepath_with_extention(filename, "qif");
io = g_io_channel_new_file(newname, "w", NULL);
io = g_io_channel_new_file(filename, "w", NULL);
if(io == NULL)
{
g_message("file error on: %s", newname);
g_message("file error on: %s", filename);
//retval = XML_IO_ERROR;
}
else
......@@ -251,25 +242,9 @@ GList *lacc, *list;
g_io_channel_unref (io);
}
g_free(newname);
}
void test_qif_export (void)
{
gchar *filename;
DB( g_print("(qif) test qif export\n\n") );
if( ui_file_chooser_qif(NULL, &filename) == TRUE )
{
hb_export_qif_account_all(filename);
g_free( filename );
}
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
......@@ -24,8 +24,6 @@
void hb_export_qif_account_all(gchar *filename);
void hb_export_qif_account_single(gchar *filename, Account *acc);
void test_qif_export (void);
#endif
......@@ -43,7 +43,7 @@ gboolean hbfile_file_hasbackup(gchar *filepath)
{
gchar *bakfilepath;
bakfilepath = homebank_filepath_with_extention(GLOBALS->xhb_filepath, "xhb~");
bakfilepath = hb_filename_new_with_extention(GLOBALS->xhb_filepath, "xhb~");
GLOBALS->xhb_hasbak = g_file_test(bakfilepath, G_FILE_TEST_EXISTS);
g_free(bakfilepath);
//todo check here if need to return something
......
......@@ -609,6 +609,7 @@ gchar **str_array;
return retval;
}
guint32 hb_date_get_julian(gchar *string, gint datefmt)
{
GDate *date;
......@@ -668,42 +669,54 @@ guint32 julian = 0;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
gchar *hb_filepath_ensure_extension(gchar *filepath, const gchar *ext)
gchar *hb_filename_new_with_extention(gchar *filename, const gchar *extension)
{
gchar *dirname;
gchar *basename;
gchar *newfilepath = NULL;
gchar *newbasename;
gchar *newfilename;
gchar **str_array;
DB( g_print("hb_filepath_ensure_extension\n") );
dirname = g_path_get_dirname (filename);
basename = g_path_get_basename(filename);
str_array = g_strsplit(basename, ".", 0);
newbasename = g_strdup_printf("%s.%s", str_array[0], extension);
newfilename = g_build_filename(dirname, newbasename, NULL);
dirname = g_path_get_dirname (filepath);
basename = g_path_get_basename(filepath);
g_strfreev(str_array);
g_free(basename);
g_free(dirname);
g_free(newbasename);
DB( g_print("- ensure '%s' for '%s'\n", ext, basename) );
return newfilename;
}
if( !(g_str_has_suffix(basename, ext)))
{
gchar **str_array;
gchar *filename;
str_array = g_strsplit(basename, ".", 0);
filename = g_strdup_printf("%s%s", str_array[0], ext);
g_strfreev(str_array);
newfilepath = g_build_filename(dirname, filename, NULL);
}
else
newfilepath = filepath;
/* file backup, qif export */
DB( g_print("- out: '%s'\n", newfilepath) );
g_free(basename);
g_free(dirname);
/*gchar *homebank_filename_without_extention(gchar *path)
{
gchar *basename;
gchar *newname;
gchar **str_array;
return newfilepath;
}
basename = g_path_get_basename(path);
str_array = g_strsplit(basename, ".", 0);
newname = g_strdup(str_array[0]);
g_strfreev(str_array);
g_free(basename);
return newname;
}*/
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
static gboolean hb_string_isdate(gchar *str)
......
......@@ -32,7 +32,7 @@ gint mystrfmon(gchar *outstr, gint outlen, gdouble value, gboolean minor);
//gint hb_strfmon(gchar *outstr, gint outlen, gdouble value, gboolean minor);
gint mystrfmon_int(gchar *outstr, gint outlen, gdouble value, gboolean minor);
gchar *hb_filepath_ensure_extension(gchar *filepath, const gchar *ext);
gchar *hb_filename_new_with_extention(gchar *filename, const gchar *extension);
gchar *get_normal_color_amount(gdouble value);
gchar *get_minimum_color_amount(gdouble value, gdouble minvalue);
......
......@@ -183,49 +183,7 @@ static gint csvtype[7] = {
/* = = = = = = = = = = = = = = = = = = = = */
/* file backup, qif export */
gchar *homebank_filepath_with_extention(gchar *path, gchar *extension)
{
gchar *basename;
gchar *dirname;
gchar *filename;
gchar *newname;
gchar **str_array;
basename = g_path_get_basename(path);
dirname = g_path_get_dirname (path);
str_array = g_strsplit(basename, ".", 0);
filename = g_strdup_printf("%s.%s", str_array[0], extension);
newname = g_build_filename(dirname, filename, NULL);
g_strfreev(str_array);
g_free(basename);
g_free(dirname);
g_free(filename);
return newname;
}
gchar *homebank_filename_without_extention(gchar *path)
{
gchar *basename;
gchar *newname;
gchar **str_array;
basename = g_path_get_basename(path);
str_array = g_strsplit(basename, ".", 0);
newname = g_strdup(str_array[0]);
g_strfreev(str_array);
g_free(basename);
return newname;
}
......@@ -238,7 +196,7 @@ gchar *newfilepath;
DB( g_print("\n[homebank] file_ensure_xhb\n") );
newfilepath = hb_filepath_ensure_extension(GLOBALS->xhb_filepath, ".xhb");
newfilepath = hb_filename_new_with_extention(GLOBALS->xhb_filepath, ".xhb");
hbfile_change_filepath(newfilepath);
DB( g_print("- out: %s\n", GLOBALS->xhb_filepath) );
......
......@@ -45,6 +45,16 @@ extern GdkPixbuf *paymode_icons[];
/* This is not pretty. Of course you can also use a
* separate compare function for each sort ID value */
static gint ope_sort_iter_compare_strings(gchar *s1, gchar *s2)
{
gint ret = 0;
ret = g_utf8_collate(s1 != NULL ? s1 : "", s2 != NULL ? s2 : "");
return ret;
}
static gint
ope_sort_iter_compare_func (GtkTreeModel *model,
GtkTreeIter *a,
......@@ -75,28 +85,27 @@ static gint
tmpval = ope1->pos - ope2->pos;
ret = tmpval > 0 ? 1 : -1;
}
//g_print("ret=%d\n", ret);
break;
case LST_DSPOPE_ACCOUNT:
{
Account *p1, *p2;
p1 = da_acc_get(ope1->kacc);
p2 = da_acc_get(ope2->kacc);
Account *a1, *a2;
if( p1->name && p2->name )
ret = g_utf8_collate(p1->name, p2->name);
a1 = da_acc_get(ope1->kacc);
a2 = da_acc_get(ope2->kacc);
if( a1 != NULL && a2 != NULL )
{
ret = ope_sort_iter_compare_strings(a1->name, a2->name);
}
}
break;
case LST_DSPOPE_INFO:
if(!(ret = ope1->paymode - ope2->paymode))
{
if(ope1->info != NULL && ope2->info != NULL)
ret = g_utf8_collate(ope1->info, ope2->info);
ret = ope_sort_iter_compare_strings(ope1->info, ope2->info);
}
break;
......@@ -108,15 +117,13 @@ static gint
p2 = da_pay_get(ope2->kpay);
if( p1 != NULL && p2 != NULL )
{
if( p1->name && p2->name )
ret = g_utf8_collate(p1->name, p2->name);
ret = ope_sort_iter_compare_strings(p1->name, p2->name);
}
}
break;
case LST_DSPOPE_WORDING:
if(ope1->wording != NULL && ope2->wording != NULL)
ret = g_utf8_collate(ope1->wording, ope2->wording);
ret = ope_sort_iter_compare_strings(ope1->wording, ope2->wording);
break;
case LST_DSPOPE_AMOUNT:
......@@ -137,10 +144,7 @@ static gint
{
name1 = da_cat_get_fullname(c1);
name2 = da_cat_get_fullname(c2);
if(name1 != NULL && name2 != NULL)
ret = g_utf8_collate(name1, name2);
ret = ope_sort_iter_compare_strings(name1, name2);
g_free(name2);
g_free(name1);
}
......@@ -153,10 +157,7 @@ static gint
t1 = transaction_tags_tostring(ope1);
t2 = transaction_tags_tostring(ope2);
if( t1 != NULL && t2 != NULL )
{
ret = g_utf8_collate(t1, t2);
}
ret = ope_sort_iter_compare_strings(t1, t2);
g_free(t1);
g_free(t2);
}
......@@ -167,7 +168,7 @@ static gint
}
return ret;
}
}
/*
** date cell function
......
......@@ -134,7 +134,7 @@ gboolean ui_file_chooser_qif(GtkWindow *parent, gchar **storage_ptr)
GtkWidget *chooser;
gboolean retval;
DB( g_print("(homebank) chooser open qif\n") );
DB( g_print("(homebank) chooser save qif\n") );
chooser = gtk_file_chooser_dialog_new (
_("Export as QIF"),
......@@ -144,7 +144,7 @@ gboolean retval;
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
//todo chnage this ?
//todo: change this ?
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser), PREFS->path_export);
ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), _("QIF files"), "*.[Qq][Ii][Ff]");
ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), _("All files"), "*");
......@@ -152,7 +152,10 @@ gboolean retval;
retval = FALSE;
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
{
*storage_ptr = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
gchar *tmpfilename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
*storage_ptr = hb_filename_new_with_extention(tmpfilename, "qif");
g_free(tmpfilename);
retval = TRUE;
}
......@@ -174,7 +177,7 @@ gchar *button;
gboolean retval;
gchar *path;
DB( g_print("(hombank) csvfile chooser %d\n", action) );
DB( g_print("(hombank) csvfile chooser csv %d\n", action) );
if( action == GTK_FILE_CHOOSER_ACTION_OPEN )
{
......@@ -207,7 +210,17 @@ gchar *path;
retval = FALSE;
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
{
*storage_ptr = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
gchar *tmpfilename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
if( action == GTK_FILE_CHOOSER_ACTION_SAVE )
{
*storage_ptr = hb_filename_new_with_extention(tmpfilename, "csv");
g_free(tmpfilename);
}
else
{
*storage_ptr = tmpfilename;
}
retval = TRUE;
}
......@@ -226,7 +239,7 @@ gchar *title;
gchar *button;
gboolean retval;
DB( g_print("(ui-dialog) file chooser %d\n", action) );
DB( g_print("(ui-dialog) file chooser xhb %d\n", action) );
if( action == GTK_FILE_CHOOSER_ACTION_OPEN )
{
......
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