[grisbi-cvs] grisbi/src affichage_liste.c, 1.117, 1.118 gsb_data_fyear.c, 1.19, 1.20 gsb_form.c, 1.141, 1.142 gsb_form_transaction.c, 1.52, 1.53 gtk_combofix.c, 1.66, 1.67 import_csv.c, 1.62, 1.63 qif.c, 1.142, 1.143 utils_files.c, 1.47, 1.48 utils_files.h, 1.24, 1.25
Pierre Biava
pbiava at users.sourceforge.net
Sun Jan 3 12:21:29 CET 2010
- Previous message: [grisbi-cvs] grisbi/po cs.po, 1.76, 1.77 da.po, 1.83, 1.84 de.po, 1.149, 1.150 el.po, 1.47, 1.48 eo.po, 1.40, 1.41 es.po, 1.143, 1.144 fa.po, 1.70, 1.71 fr.po, 1.212, 1.213 grisbi.pot, 1.118, 1.119 he.po, 1.76, 1.77 it.po, 1.76, 1.77 nl.po, 1.75, 1.76 pl.po, 1.81, 1.82 pt_BR.po, 1.78, 1.79 ro.po, 1.77, 1.78 ru.po, 1.75, 1.76 zh_CN.po, 1.71, 1.72
- Next message: [grisbi-cvs] grisbi/help/tips de.po,1.9,1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv16359/src
Modified Files:
affichage_liste.c gsb_data_fyear.c gsb_form.c
gsb_form_transaction.c gtk_combofix.c import_csv.c qif.c
utils_files.c utils_files.h
Log Message:
correcting bugs 823 and 827 and other minor bugs
Index: gtk_combofix.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gtk_combofix.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- gtk_combofix.c 24 Nov 2009 05:18:30 -0000 1.66
+++ gtk_combofix.c 3 Jan 2010 11:21:26 -0000 1.67
@@ -29,6 +29,7 @@
#include "gtk_combofix.h"
#include "./dialog.h"
#include "./gsb_form_widget.h"
+#include "./structures.h"
#include "./utils_str.h"
#include "./erreur.h"
/*END_INCLUDE*/
@@ -1254,33 +1255,32 @@
case GDK_Return :
if (combofix -> enter_function)
{
- /* we keep the current completion */
- gtk_combofix_hide_popup (combofix);
- gtk_editable_select_region ( GTK_EDITABLE (combofix -> entry),
- 0,
- 0 );
- return TRUE;
+ if ( strlen ( gtk_combofix_get_text ( combofix ) ) == 0 )
+ gtk_combofix_choose_selection ( combofix );
+ else
+ {
+ /* we keep the current completion */
+ gtk_combofix_hide_popup (combofix);
+ gtk_editable_select_region ( GTK_EDITABLE (combofix -> entry), 0, 0 );
+ }
}
else
{
- /* we get the current selection */
- if ( GTK_WIDGET_VISIBLE ( combofix -> popup ))
- {
- if (gtk_combofix_choose_selection (combofix))
- return TRUE;
- else
- {
- /* here we did entry key, but no selection... so
- * keep the current completion */
- gtk_combofix_hide_popup (combofix);
- gtk_editable_select_region ( GTK_EDITABLE (combofix -> entry),
- 0,
- 0 );
- /* important to return TRUE else grisbi will finish the transaction */
- return TRUE;
- }
- }
+ /* we get the current selection */
+ if ( GTK_WIDGET_VISIBLE ( combofix -> popup ))
+ {
+ if ( ! gtk_combofix_choose_selection ( combofix ) )
+ {
+ /* here we did entry key, but no selection... so
+ * keep the current completion */
+ gtk_combofix_hide_popup ( combofix );
+ gtk_editable_select_region ( GTK_EDITABLE (combofix -> entry), 0, 0 );
+ }
+ }
}
+ /* le traitement de ENTER est fait dans le formulaire */
+ return FALSE;
+ break;
case GDK_Escape:
if ( GTK_WIDGET_VISIBLE ( combofix -> popup ))
Index: qif.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/qif.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- qif.c 9 Nov 2009 14:08:57 -0000 1.142
+++ qif.c 3 Jan 2010 11:21:26 -0000 1.143
@@ -1,8 +1,9 @@
/* ************************************************************************** */
/* */
-/* Copyright (C) 2000-2008 Cédric Auger (cedric at grisbi.org) */
-/* 2005-2008 Benjamin Drieu (bdrieu at april.org) */
-/* http://www.grisbi.org */
+/* Copyright (C) 2000-2008 Cédric Auger (cedric at grisbi.org) */
+/* 2005-2008 Benjamin Drieu (bdrieu at april.org) */
+/* 2008-2010 Pierre Biava (grisbi at pierre.biava.name) */
+/* http://www.grisbi.org */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
@@ -45,8 +46,7 @@
/*END_INCLUDE*/
/*START_STATIC*/
-static GDate *gsb_qif_get_date ( gchar *date_string,
- gint order );
+static GDate *gsb_qif_get_date ( gchar *date_string, gint order );
static gchar **gsb_qif_get_date_content ( gchar *date_string );
static gint gsb_qif_get_date_order ( GSList *transactions_list );
/*END_STATIC*/
@@ -56,6 +56,7 @@
extern GSList *liste_comptes_importes_error;
/*END_EXTERN*/
+
enum
{
ORDER_DD_MM_YY = 0,
@@ -67,6 +68,8 @@
ORDER_MAX,
};
+
+
static gchar *order_names[] = {
"day-month-year",
"day-year-month",
@@ -88,7 +91,7 @@
*
* \return TRUE on success.
*/
-gboolean recuperation_donnees_qif ( GtkWidget * assistant, struct imported_file * imported )
+gboolean recuperation_donnees_qif ( GtkWidget *assistant, struct imported_file *imported )
{
gchar *tmp_str;
struct struct_compte_importation *imported_account;
@@ -98,7 +101,7 @@
if ( ! qif_file )
{
- return FALSE;
+ return FALSE;
}
/* qif_file pointe sur le qif_file qui a été reconnu comme qif */
@@ -346,7 +349,29 @@
}
if ( tmp_str[0] == 'T' )
- imported_transaction -> montant = gsb_real_get_from_string (tmp_str + 1);
+ {
+ gchar *ptr_1, *ptr_2;
+ gchar *locale = gtk_set_locale ();
+
+ if ( g_strrstr ( locale, "en" ) == NULL
+ &&
+ g_strrstr ( locale, "US" ) == NULL
+ &&
+ ( ptr_1 = g_strstr_len ( tmp_str, -1, "," ) )
+ &&
+ ( ptr_2 = g_strrstr ( tmp_str, "." ) )
+ && ( ptr_2 - tmp_str ) > ( ptr_1 - tmp_str ) )
+ {
+ gchar **tab;
+
+ tab = g_strsplit ( tmp_str + 1, ",", 0 );
+ imported_transaction -> montant = gsb_real_get_from_string (
+ g_strjoinv ( "", tab ) );
+ g_strfreev ( tab );
+ }
+ else
+ imported_transaction -> montant = gsb_real_get_from_string (tmp_str + 1);
+ }
/* récupération du chèque */
if ( tmp_str[0] == 'N' )
@@ -756,8 +781,7 @@
*
* \return a newly allocated GDate
* */
-static GDate *gsb_qif_get_date ( gchar *date_string,
- gint order )
+static GDate *gsb_qif_get_date ( gchar *date_string, gint order )
{
gchar **array;
GDate *date;
@@ -840,7 +864,7 @@
* \return TRUE ok, FALSE pb
* */
gboolean gsb_qif_export_archive ( const gchar *filename,
- gint archive_number )
+ gint archive_number )
{
GSList *tmp_list;
GSList *name_list = NULL;
@@ -931,8 +955,8 @@
* \return TRUE ok, FALSE pb
*/
gboolean qif_export ( const gchar *filename,
- gint account_nb,
- gint archive_number )
+ gint account_nb,
+ gint archive_number )
{
FILE * fichier_qif;
GSList *list_tmp_transactions;
@@ -1215,7 +1239,6 @@
}
-
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
Index: gsb_data_fyear.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_fyear.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gsb_data_fyear.c 29 Nov 2009 18:53:39 -0000 1.19
+++ gsb_data_fyear.c 3 Jan 2010 11:21:26 -0000 1.20
@@ -712,7 +712,7 @@
* \param struct_fyear *fyear_1
* \param struct_fyear *fyear_2
*
- * \return -1 if fyear 1 is before 2 ; +1 if fyear 1 is after 2 ; 0 if problem
+ * \return -1 if fyear 2 is before 1 ; +1 if fyear 2 is after 1 ; 0 if problem
* */
gint gsb_data_fyear_compare_from_struct ( struct_fyear *fyear_1,
struct_fyear *fyear_2 )
@@ -726,8 +726,8 @@
return -1;
if (g_date_compare (fyear_1 -> beginning_date, fyear_2 -> end_date) >= 0)
- return 1;
- if (g_date_compare (fyear_2 -> beginning_date, fyear_1 -> end_date) >= 0)
return -1;
+ if (g_date_compare (fyear_2 -> beginning_date, fyear_1 -> end_date) >= 0)
+ return 1;
return 0;
}
Index: gsb_form_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_transaction.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- gsb_form_transaction.c 13 Dec 2009 20:08:31 -0000 1.52
+++ gsb_form_transaction.c 3 Jan 2010 11:21:26 -0000 1.53
@@ -97,6 +97,8 @@
if ( element -> element_number
&&
+ element -> element_number < TRANSACTION_FORM_MAX_WIDGETS
+ &&
element -> element_number != TRANSACTION_FORM_DATE
&&
element -> element_number != TRANSACTION_FORM_PARTY
@@ -114,6 +116,7 @@
/* get the payee_number */
payee_number = gsb_data_payee_get_number_by_name ( payee_name, FALSE );
+
/* if it's a new payee, go away */
if ( !payee_number )
return TRUE;
Index: affichage_liste.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/affichage_liste.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- affichage_liste.c 12 Dec 2009 18:14:39 -0000 1.117
+++ affichage_liste.c 3 Jan 2010 11:21:26 -0000 1.118
@@ -525,11 +525,11 @@
G_CALLBACK ( gsb_transactions_list_display_update_combofix), NULL),
FALSE, FALSE, 0 );
- gtk_box_pack_start ( GTK_BOX (vbox_pref),
- gsb_automem_checkbutton_new (_("Enter keeps current completion"),
- &etat.combofix_enter_select_completion,
- G_CALLBACK ( gsb_transactions_list_display_update_combofix), NULL),
- FALSE, FALSE, 0 );
+ //~ gtk_box_pack_start ( GTK_BOX (vbox_pref),
+ //~ gsb_automem_checkbutton_new (_("Enter keeps current completion"),
+ //~ &etat.combofix_enter_select_completion,
+ //~ G_CALLBACK ( gsb_transactions_list_display_update_combofix), NULL),
+ //~ FALSE, FALSE, 0 );
gtk_box_pack_start ( GTK_BOX (vbox_pref),
gsb_automem_checkbutton_new (_("Don't allow new payee creation"),
Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- gsb_form.c 26 Dec 2009 16:57:13 -0000 1.141
+++ gsb_form.c 3 Jan 2010 11:21:26 -0000 1.142
@@ -3164,7 +3164,6 @@
* in reports... so, erase here budget and financial year, if ever they are defined */
gsb_data_mix_set_budgetary_number (transaction_number, 0, is_transaction);
gsb_data_mix_set_sub_budgetary_number (transaction_number, 0, is_transaction);
- gsb_data_mix_set_financial_year_number (transaction_number, 0, is_transaction);
gsb_data_mix_set_voucher (transaction_number, NULL, is_transaction);
}
g_free ( string );
Index: utils_files.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- utils_files.h 3 Nov 2009 17:32:07 -0000 1.24
+++ utils_files.h 3 Jan 2010 11:21:26 -0000 1.25
@@ -32,6 +32,10 @@
gint utf8_remove(const gchar* utf8filename);
gboolean utils_files_create_XDG_dir (void);
GtkWidget *utils_files_create_file_chooser ( GtkWidget *parent, gchar * titre );
+gchar *utils_files_create_sel_charset ( GtkWidget *assistant,
+ const gchar *tmp_str,
+ const gchar *charmap_imported,
+ gchar *filename );
/*END_DECLARATION*/
#endif
Index: import_csv.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import_csv.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- import_csv.c 1 Jan 2010 13:21:31 -0000 1.62
+++ import_csv.c 3 Jan 2010 11:21:26 -0000 1.63
@@ -197,7 +197,7 @@
*
*/
GtkTreeModel * csv_import_create_model ( GtkTreeView * tree_preview, gchar * contents,
- gchar * separator )
+ gchar * separator )
{
GtkWidget * assistant;
GtkTreeStore * model;
@@ -290,7 +290,7 @@
* \param tree_preview GtkTreeView triggering event.
*/
void skip_line_toggled ( GtkCellRendererToggle * cell, gchar * path_str,
- GtkTreeView * tree_preview )
+ GtkTreeView * tree_preview )
{
GtkTreeIter iter;
gboolean toggle_item;
@@ -320,7 +320,7 @@
* \return FALSE
*/
gboolean csv_import_header_on_click ( GtkWidget * button, GdkEventButton * ev,
- gint *no_column )
+ gint *no_column )
{
GtkWidget * menu, * col;
@@ -751,7 +751,7 @@
* \return FALSE
*/
gboolean csv_import_change_separator ( GtkEntry * entry,
- GtkWidget *assistant )
+ GtkWidget *assistant )
{
gchar * separator = (gchar *) gtk_entry_get_text ( GTK_ENTRY (entry) );
/* GtkWidget * assistant = g_object_get_data ( G_OBJECT(entry), "assistant" ); */
@@ -959,7 +959,7 @@
* \return A newly-created GtkMenu.
*/
GtkWidget * csv_import_fields_menu ( GtkTreeViewColumn * col, gint field,
- GtkWidget * assistant )
+ GtkWidget * assistant )
{
GtkWidget * menu, * item;
int i;
@@ -1073,7 +1073,7 @@
contents = g_convert_with_fallback ( tmp_str, -1, "UTF-8", imported -> coding_system,
"?", &size, &bytes_written, &error );
- if ( bytes_written == 0 )
+ if ( contents == NULL )
{
error = NULL;
size = 0;
Index: utils_files.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- utils_files.c 10 Dec 2009 10:50:53 -0000 1.47
+++ utils_files.c 3 Jan 2010 11:21:26 -0000 1.48
@@ -4,6 +4,7 @@
/* Copyright (C) 2000-2007 Cédric Auger (cedric at grisbi.org) */
/* 2003-2007 Benjamin Drieu (bdrieu at april.org) */
/* 2003-2004 Alain Portal (aportal at univ-montp2.fr) */
+/* 2008-2010 Pierre Biava (grisbi at pierre.biava.name) */
/* http://www.grisbi.org */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -31,7 +32,9 @@
#include "./utils_file_selection.h"
#include "./utils_dates.h"
#include "./gsb_file.h"
+#include "./utils.h"
#include "./utils_str.h"
+#include "./go-charmap-sel.h"
#include "./gsb_file_config.h"
#include "./utils_file_selection.h"
#include "./include.h"
@@ -41,6 +44,15 @@
/*START_STATIC*/
static void browse_file ( GtkButton *button, gpointer data );
static void utils_files_file_chooser_cancel ( GtkWidget *bouton, GtkWidget *chooser);
+static gboolean utils_files_charmap_active_toggled ( GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer model );
+static void utils_files_go_charmap_sel_changed ( GtkWidget *go_charmap_sel,
+ const gchar *encoding,
+ GtkWidget *dialog );
+static GSList *utils_files_check_UTF8_validity ( const gchar *contents,
+ const gchar *coding_system );
+
/*END_STATIC*/
@@ -49,6 +61,29 @@
/*END_EXTERN*/
+struct struc_check_encoding
+{
+ gchar *charset;
+ gchar *result;
+};
+
+
+/* liste des colonnes charmap */
+enum {
+ IMPORT_CHARMAP_SELECTED = 0,
+ IMPORT_CHARMAP_ENCODING,
+ IMPORT_CHARMAP_RESULT,
+ IMPORT_CHARMAP_NB,
+};
+
+
+static gchar *charset_array[] = {
+"ISO-8859-1",
+"ISO-8859-15",
+"windows-1252",
+"IBM850"};
+
+
/**
* Handler triggered by clicking on the button of a "print to file"
* combo. Pop ups a file selector.
@@ -241,8 +276,6 @@
}
-
-
/**
* Make a GtkEntry that will contain a file name, a GtkButton that
* will pop up a file selector, pack them in a GtkHbox and return it.
@@ -396,72 +429,334 @@
}
-/* comment by pbiava 24/01/2009 */
/**
- * create a full path backup name from the filename
- * using the backup repertory and add the date and .bak
- *
- * \param filename
+ * Test if converting a string to UTF8 is correct with different character sets
+ *
+ * \param contents
+ * \param coding_system
*
- * \return a newly allocated string
+ * \return a GSList of correct string
* */
-/*gchar *utils_files_create_backup_name ( const gchar *filename )
+GSList *utils_files_check_UTF8_validity ( const gchar *contents,
+ const gchar *coding_system )
{
- gchar *string;
- gchar *tmp_name;
- GDate *today;
- gchar **split;
- gchar *inserted_string;
+ GSList *list = NULL;
+ struct struc_check_encoding *result;
+ gchar *string = NULL;
+ gint long_str = 0;
+ gsize size = 0;
+ gsize bytes_written = 0;
+ GError * error = NULL;
+ gint i = 0;
+ gchar *ptr;
- !* get the filename *!
- tmp_name = g_path_get_basename (filename);
+ ptr = (gchar *) contents;
+
+ while ( strlen ( ptr ) > 0 )
+ {
+ gchar *ptr_tmp;
- !* create the string to insert into the backup name *!
- today = gdate_today ();
- inserted_string = g_strdup_printf ( "-%d_%d_%d-backup",
- g_date_year (today),
- g_date_month (today),
- g_date_day (today));
- g_date_free (today);
+ ptr_tmp = g_strstr_len ( ptr, strlen ( ptr ), "\n" );
+ if ( ptr_tmp )
+ {
+ gchar *ptr_r;
- !* insert the date and backup before .gsb if it exists *!
- split = g_strsplit ( tmp_name,
- ".",
- 0 );
- g_free (tmp_name);
+ string = g_strndup ( ptr, ( ( ptr_tmp - 1 ) - ptr ) );
+ if ( ( ptr_r = g_strrstr ( string, "\r" ) ) )
+ ptr_r = '\0';
- if (split[1])
+ if ( g_convert ( string, -1, "UTF-8", coding_system, NULL, NULL, NULL ) == NULL )
+ {
+ gchar *tmp_str;
+
+ long_str = strlen ( string );
+ result = g_malloc0 ( sizeof ( struct struc_check_encoding ) );
+ result -> charset = "";
+ result -> result = string;
+ list = g_slist_append ( list, result );
+ do
+ {
+ tmp_str = g_convert ( string, long_str, "UTF-8", charset_array[i],
+ &size, &bytes_written, &error );
+ if ( tmp_str )
+ {
+ result = g_malloc0 ( sizeof ( struct struc_check_encoding ) );
+ result -> charset = charset_array[i];
+ result -> result = tmp_str;
+ list = g_slist_append ( list, result );
+ }
+ i++;
+ } while ( charset_array[i] );
+
+ return list;
+ }
+ g_free ( string );
+ ptr = ptr_tmp + 1;
+ }
+ else
+ break;
+ }
+
+ return NULL;
+}
+
+
+/**
+ * creates a box for selecting a character sets
+ *
+ * \param assistant GsbAssistant
+ * \param content of file
+ * \param charmap_imported
+ *
+ * \return A charmap.
+ */
+gchar * utils_files_create_sel_charset ( GtkWidget *assistant,
+ const gchar *tmp_str,
+ const gchar *charmap_imported,
+ gchar *filename )
+{
+ GtkWidget *dialog, *vbox, *sw, *tree_view;
+ GtkWidget *hbox, *warn, *label;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeModel *model;
+ GSList *list;
+ GtkTreeIter iter;
+ gchar* tmpstr;
+ GtkWidget *go_charmap_sel;
+ gint result;
+
+ dialog = gtk_dialog_new_with_buttons ( _("Select a charmap"),
+ GTK_WINDOW ( assistant ),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL, 0,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL );
+ gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_widget_set_size_request ( dialog, 600, -1 );
+ gtk_dialog_set_response_sensitive ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, FALSE );
+
+ vbox = gtk_vbox_new ( FALSE, 6 );
+ gtk_container_set_border_width ( GTK_CONTAINER(vbox), 12 );
+ gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) -> vbox ), vbox );
+
+ /* Warning label */
+ hbox = gtk_hbox_new ( FALSE, 6 );
+ gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
+
+ warn = gtk_image_new_from_stock ( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON );
+ gtk_box_pack_start ( GTK_BOX ( hbox ), warn, FALSE, FALSE, 0 );
+
+ label = gtk_label_new ( NULL );
+ tmpstr = g_strdup_printf ( _("You are here because your file"
+ " can't be imported directly into grisbi.\n%s"),
+ filename );
+ gtk_label_set_markup ( GTK_LABEL ( label ),
+ make_pango_attribut ( "weight=\"bold\"",tmpstr ) );
+ gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+ gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+ gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 0 );
+ g_free ( tmpstr );
+
+ /*scrolled windows */
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_size_request ( sw, 480, 150 );
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start ( GTK_BOX ( vbox ), sw, TRUE, TRUE, 6 );
+
+ /* Tree view and model. */
+ model = GTK_TREE_MODEL ( gtk_list_store_new ( IMPORT_CHARMAP_NB, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_STRING ) );
+ tree_view = gtk_tree_view_new_with_model ( model );
+ gtk_container_add ( GTK_CONTAINER ( sw ), tree_view );
+ g_object_set_data ( G_OBJECT ( model ), "dialog", dialog );
+ g_object_set_data ( G_OBJECT ( dialog ), "charset_model", model );
+ g_object_set_data ( G_OBJECT ( dialog ), "charset_tree_view", tree_view );
+
+ /* Toggle column. */
+ renderer = gtk_cell_renderer_toggle_new ( );
+ g_signal_connect ( renderer,
+ "toggled",
+ G_CALLBACK (utils_files_charmap_active_toggled),
+ model );
+ column = gtk_tree_view_column_new_with_attributes ( _("Import"), renderer,
+ "active", IMPORT_CHARMAP_SELECTED,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );
+
+ /* Codage column. */
+ renderer = gtk_cell_renderer_text_new ( );
+ column = gtk_tree_view_column_new_with_attributes ( _("Encoding"), renderer,
+ "text", IMPORT_CHARMAP_ENCODING,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );
+
+ /* Result column. */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ( _("Result"), renderer,
+ "text", IMPORT_CHARMAP_RESULT,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), column );
+
+ /* select an other encoding */
+ label = gtk_label_new ( _("If no proposals above are correct you can choose a "
+ "different charset") );
+ gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+ gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+ gtk_box_pack_start ( GTK_BOX ( vbox ), label, TRUE, TRUE, 0 );
+
+ hbox = gtk_hbox_new ( FALSE, 6 );
+ gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
+
+ go_charmap_sel = go_charmap_sel_new (GO_CHARMAP_SEL_TO_UTF8);
+ g_signal_connect ( go_charmap_sel,
+ "charmap_changed",
+ G_CALLBACK (utils_files_go_charmap_sel_changed),
+ dialog );
+ g_object_set_data ( G_OBJECT ( dialog ), "charset_cs", go_charmap_sel );
+ gtk_box_pack_start ( GTK_BOX ( hbox ), go_charmap_sel, FALSE, FALSE, 0 );
+
+ label = gtk_label_new ( _("Select a charset") );
+ gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5);
+ gtk_label_set_justify ( GTK_LABEL ( label ), GTK_JUSTIFY_LEFT );
+ gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 0 );
+ g_object_set_data ( G_OBJECT ( dialog ), "charset_label", label );
+
+ /* on remplit le model */
+ list = utils_files_check_UTF8_validity (tmp_str, charmap_imported );
+ if ( list )
{
- !* have extension *!
- gchar *tmpstr, *tmp_end;
+ GSList *tmp_list;
+ struct struc_check_encoding *result;
+
+ tmp_list = list;
+ result = tmp_list -> data;
+ g_object_set_data_full ( G_OBJECT ( dialog ), "charset_str",
+ g_strdup ( result -> result ), g_free );
+ tmp_list = tmp_list -> next;
+ while ( tmp_list )
+ {
+ struct struc_check_encoding *result;
+
+ result = tmp_list -> data;
+
+ gtk_list_store_append ( GTK_LIST_STORE ( model ), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
+ IMPORT_CHARMAP_ENCODING, result -> charset,
+ IMPORT_CHARMAP_RESULT, result -> result,
+ -1);
+ tmp_list = tmp_list -> next;
+ }
+ }
- tmp_end = g_strconcat ( inserted_string,
- ".",
- split[g_strv_length (split) - 1],
- NULL );
- split[g_strv_length (split) - 1] = NULL;
+ gtk_widget_show_all ( dialog );
- tmpstr = g_strjoinv ( ".",
- split );
- tmp_name = g_strconcat ( tmpstr,
- tmp_end,
- NULL );
- g_free (tmpstr);
- g_free (tmp_end);
+ result = gtk_dialog_run ( GTK_DIALOG ( dialog ));
+
+ if ( result == GTK_RESPONSE_OK )
+ {
+ gchar *charset;
+
+ charset = g_strdup ( g_object_get_data ( G_OBJECT ( dialog ), "charset") );
+ gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
+ return charset;
}
else
- tmp_name = g_strconcat ( split[0],
- inserted_string,
- NULL );
+ {
+ gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
+ return g_strdup ( "UTF8" );
+ }
+}
- g_strfreev (split);
+/**
+ *
+ *
+ *
+ */
+gboolean utils_files_charmap_active_toggled ( GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer model )
+{
+ GtkWidget *dialog;
+ GtkTreePath *path = gtk_tree_path_new_from_string ( path_str );
+ GtkTreePath *tmp_path;
+ GtkTreeIter iter;
+ gchar *enc;
+ gboolean toggle_item;
- string = g_build_filename ( gsb_file_get_backup_path (),
- tmp_name,
- NULL );
- g_free (tmp_name);
- return string;
-}*/
+ /* on commence par initialiser les données */
+ dialog = g_object_get_data ( G_OBJECT ( model ), "dialog" );
+
+ gtk_dialog_set_response_sensitive ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, FALSE );
+ tmp_path = gtk_tree_path_new_first ( );
+ gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter );
+ do
+ {
+ gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
+ IMPORT_CHARMAP_SELECTED, &toggle_item,
+ IMPORT_CHARMAP_ENCODING, &enc, -1 );
+
+ tmp_path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( model ), &iter );
+ if ( gtk_tree_path_compare ( path, tmp_path ) == 0 )
+ {
+ gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
+ IMPORT_CHARMAP_SELECTED, !toggle_item, -1 );
+ if ( toggle_item == 0 )
+ {
+ GOCharmapSel *cs;
+
+ cs = g_object_get_data ( G_OBJECT ( dialog ), "charset_cs" );
+ go_charmap_sel_set_encoding (cs, enc);
+ g_object_set_data ( G_OBJECT ( dialog ), "charset", enc );
+ gtk_dialog_set_response_sensitive ( GTK_DIALOG ( dialog ),
+ GTK_RESPONSE_OK, TRUE );
+ }
+ }
+ else
+ gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
+ IMPORT_CHARMAP_SELECTED, FALSE, -1 );
+ }
+ while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
+
+ return FALSE;
+}
+
+
+void utils_files_go_charmap_sel_changed ( GtkWidget *go_charmap_sel,
+ const gchar *encoding,
+ GtkWidget *dialog )
+{
+ GtkWidget *label;
+ gchar *contents;
+ gchar *string;
+
+ label = g_object_get_data ( G_OBJECT ( dialog ), "charset_label" );
+
+ if ( strcmp ( encoding, "UTF-8" ) == 0 )
+ {
+ gtk_label_set_text ( GTK_LABEL ( label ), _("Select a charset") );
+ return;
+ }
+
+ contents = g_object_get_data ( G_OBJECT ( dialog ), "charset_str" );
+ string = g_convert ( contents, -1, "UTF-8", encoding, NULL, NULL, NULL );
+ if ( string )
+ {
+ gtk_label_set_text ( GTK_LABEL ( label ), "");
+ gtk_label_set_markup ( GTK_LABEL ( label ), make_blue ( string ) );
+ g_object_set_data ( G_OBJECT ( dialog ), "charset", (gchar *) encoding );
+ gtk_dialog_set_response_sensitive ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, TRUE );
+ }
+ else
+ {
+ gtk_label_set_text ( GTK_LABEL ( label ), "");
+ gtk_label_set_markup ( GTK_LABEL ( label ),
+ make_red ( _("The conversion failed try another set of characters") ) );
+ gtk_dialog_set_response_sensitive ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, FALSE );
+ }
+}
/* Local Variables: */
- Previous message: [grisbi-cvs] grisbi/po cs.po, 1.76, 1.77 da.po, 1.83, 1.84 de.po, 1.149, 1.150 el.po, 1.47, 1.48 eo.po, 1.40, 1.41 es.po, 1.143, 1.144 fa.po, 1.70, 1.71 fr.po, 1.212, 1.213 grisbi.pot, 1.118, 1.119 he.po, 1.76, 1.77 it.po, 1.76, 1.77 nl.po, 1.75, 1.76 pl.po, 1.81, 1.82 pt_BR.po, 1.78, 1.79 ro.po, 1.77, 1.78 ru.po, 1.75, 1.76 zh_CN.po, 1.71, 1.72
- Next message: [grisbi-cvs] grisbi/help/tips de.po,1.9,1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cvs
mailing list