[grisbi-cvs] grisbi/src Makefile.am, 1.152, 1.153 accueil.c, 1.191, 1.192 affichage.c, 1.149, 1.150 gsb_file_config.c, 1.61, 1.62 gsb_file_config.h, 1.6, 1.7 gsb_file_load.c, 1.145, 1.146 gsb_file_save.c, 1.108, 1.109 gsb_select_icon.c, 1.5, 1.6 gsb_select_icon.h, 1.1, 1.2 help.c, 1.82, 1.83 include.h, 1.36, 1.37 main.c, 1.134, 1.135 traitement_variables.c, 1.162, 1.163 utils_files.c, 1.33, 1.34 utils_files.h, 1.20, 1.21
Pierre Biava
pbiava at users.sourceforge.net
Sat Jan 17 08:23:55 CET 2009
Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14371/src
Modified Files:
Makefile.am accueil.c affichage.c gsb_file_config.c
gsb_file_config.h gsb_file_load.c gsb_file_save.c
gsb_select_icon.c gsb_select_icon.h help.c include.h main.c
traitement_variables.c utils_files.c utils_files.h
Log Message:
Incorporation of the logo in the file *.gsb
Index: help.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/help.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- help.c 8 Dec 2008 18:37:57 -0000 1.82
+++ help.c 17 Jan 2009 07:23:53 -0000 1.83
@@ -25,6 +25,7 @@
/*START_INCLUDE*/
#include "help.h"
#include "./gsb_plugins.h"
+#include "./gsb_select_icon.h"
#include "./utils.h"
#include "./utils_str.h"
#include "./include.h"
@@ -36,7 +37,6 @@
/*START_EXTERN*/
-extern gchar *chemin_logo ;
extern GtkWidget *window ;
/*END_EXTERN*/
@@ -68,6 +68,7 @@
gint data )
{
GdkPixbuf * logo;
+ gchar *chemin_logo ;
#define CSUFFIX "\n"
@@ -76,7 +77,7 @@
"Benjamin Drieu (bdrieu[at]april.org)",
"Cedric Auger (cedric[at]grisbi.org)",
"Francois Terrot (grisbi[at]terrot.net)",
-"Pierre Bavia ([at]terrot.net)",
+"Pierre Biava ([at]nerim.net)",
"",
_("Packaging"),
@@ -139,10 +140,12 @@
GtkWidget * about;
/* Logo */
- if ( !chemin_logo || !strlen ( chemin_logo ))
- chemin_logo = my_strdup ( LOGO_PATH );
- logo = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
-
+ logo = gsb_select_icon_get_logo_pixbuf ( );
+ if (logo == NULL )
+ {
+ chemin_logo = my_strdup ( LOGO_PATH );
+ logo = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
+ }
about = gtk_about_dialog_new ( );
gtk_about_dialog_set_url_hook (launch_url, NULL, NULL);
gtk_about_dialog_set_name ( GTK_ABOUT_DIALOG (about), "Grisbi" );
Index: gsb_select_icon.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_select_icon.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gsb_select_icon.h 4 Jan 2009 18:36:28 -0000 1.1
+++ gsb_select_icon.h 17 Jan 2009 07:23:53 -0000 1.2
@@ -6,6 +6,10 @@
/* END_INCLUDE_H */
/* START_DECLARATION */
+gchar * gsb_select_icon_create_chaine_base64_from_pixbuf ( GdkPixbuf *pixbuf );
+void gsb_select_icon_create_pixbuf_from_chaine_base64 ( gchar *str_base64 );
gchar * gsb_select_icon_create_window ( gchar * name_icon );
+GdkPixbuf *gsb_select_icon_get_logo_pixbuf ( void );
+void gsb_select_icon_set_logo_pixbuf ( GdkPixbuf *pixbuf );
/* END_DECLARATION */
#endif
Index: traitement_variables.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/traitement_variables.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- traitement_variables.c 23 Nov 2008 13:16:41 -0000 1.162
+++ traitement_variables.c 17 Jan 2009 07:23:53 -0000 1.163
@@ -138,7 +138,6 @@
extern gint affichage_echeances;
extern gint affichage_echeances_perso_nb_libre;
extern GtkTreeModel *bank_list_model ;
-extern gchar *chemin_logo ;
extern gint current_tree_view_width ;
extern gint display_one_line;
extern gint display_three_lines;
@@ -273,10 +272,6 @@
solde_label = NULL;
solde_label_pointe = NULL;
- if ( chemin_logo )
- g_free ( chemin_logo);
- chemin_logo = NULL;
-
affichage_echeances = SCHEDULER_PERIODICITY_ONCE_VIEW;
affichage_echeances_perso_nb_libre = 0;
affichage_echeances_perso_j_m_a = PERIODICITY_DAYS;
Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- gsb_file_save.c 4 Jan 2009 18:31:54 -0000 1.108
+++ gsb_file_save.c 17 Jan 2009 07:23:53 -0000 1.109
@@ -55,6 +55,7 @@
#include "./navigation.h"
#include "./gsb_plugins.h"
#include "./gsb_real.h"
+#include "./gsb_select_icon.h"
#include "./utils_str.h"
#include "./structures.h"
#include "./custom_list.h"
@@ -97,6 +98,9 @@
static gulong gsb_file_save_import_rule_part ( gulong iterator,
gulong *length_calculated,
gchar **file_content );
+static gulong gsb_file_save_logo_part ( gulong iterator,
+ gulong *length_calculated,
+ gchar **file_content );
static gulong gsb_file_save_party_part ( gulong iterator,
gulong *length_calculated,
gchar **file_content );
@@ -127,7 +131,6 @@
extern gint affichage_echeances_perso_nb_libre;
extern GdkColor archive_background_color;
extern GdkColor calendar_entry_color;
-extern gchar *chemin_logo ;
extern GdkColor couleur_fond[2];
extern GdkColor couleur_grise;
extern GdkColor couleur_selection;
@@ -187,6 +190,7 @@
gint reconcile_part;
gint report_part;
gint import_rule_part;
+ gint logo_part;
struct stat buf;
@@ -231,6 +235,7 @@
reconcile_part = 50;
report_part = 2500;
import_rule_part = 50;
+ logo_part = 65536;
length_calculated = general_part
+ account_part * gsb_data_account_get_accounts_amount ()
@@ -245,12 +250,13 @@
+ archive_part * g_slist_length (gsb_data_archive_get_archives_list ())
+ reconcile_part * g_list_length (gsb_data_reconcile_get_reconcile_list ())
+ report_part * g_slist_length ( gsb_data_report_get_report_list ())
- + import_rule_part * g_slist_length ( gsb_data_import_rule_get_list ());
+ + import_rule_part * g_slist_length ( gsb_data_import_rule_get_list ())
+ + logo_part;
iterator = 0;
file_content = g_malloc0 ( length_calculated );
- /* begin the file whit xml markup */
+ /* begin the file whith xml markup */
iterator = gsb_file_save_append_part ( iterator,
&length_calculated,
&file_content,
@@ -332,10 +338,15 @@
&length_calculated,
&file_content );
- iterator = gsb_file_save_report_part ( iterator,
+ iterator = gsb_file_save_report_part ( iterator,
&length_calculated,
&file_content,
FALSE );
+
+ iterator = gsb_file_save_logo_part ( iterator,
+ &length_calculated,
+ &file_content );
+
/* finish the file */
iterator = gsb_file_save_append_part ( iterator,
&length_calculated,
@@ -587,7 +598,6 @@
"\t\tImport_interval_search=\"%d\"\n"
"\t\tImport_fyear_by_value_date=\"%d\"\n"
"\t\tUse_logo=\"%d\"\n"
- "\t\tPath_logo=\"%s\"\n"
"\t\tRemind_display_per_account=\"%d\"\n"
"\t\tTransactions_view=\"%s\"\n"
"\t\tOne_line_showed=\"%d\"\n"
@@ -621,7 +631,6 @@
valeur_echelle_recherche_date_import,
etat.get_fyear_by_value_date,
etat.utilise_logo,
- chemin_logo,
etat.retient_affichage_par_compte,
transactions_view,
display_one_line,
@@ -2375,5 +2384,35 @@
}
+/**
+ * save the logo
+ *
+ * \param iterator the current iterator
+ * \param length_calculated a pointer to the variable lengh_calculated
+ * \param file_content a pointer to the variable file_content
+ *
+ * \return the new iterator
+ * */
+gulong gsb_file_save_logo_part ( gulong iterator,
+ gulong *length_calculated,
+ gchar **file_content )
+{
+ gchar *new_string;
+ gchar * str64;
+
+ str64 = gsb_select_icon_create_chaine_base64_from_pixbuf (
+ gsb_select_icon_get_logo_pixbuf ( ) );
+
+ new_string = g_markup_printf_escaped ( "\t<Logo\n"
+ "\t\tImage=\"%s\" />\n",
+ str64 );
+
+ iterator = gsb_file_save_append_part ( iterator,
+ length_calculated,
+ file_content,
+ new_string );
+
+ return iterator;
+}
Index: gsb_select_icon.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_select_icon.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gsb_select_icon.c 6 Jan 2009 13:54:58 -0000 1.5
+++ gsb_select_icon.c 17 Jan 2009 07:23:53 -0000 1.6
@@ -47,13 +47,14 @@
/*END_STATIC*/
/*START_EXTERN*/
-extern GtkWidget *window;
+extern GtkWidget *window ;
/*END_EXTERN*/
static GtkWidget * dialog;
static GtkWidget * bouton_OK;
static GtkWidget * entry_text;
static GtkWidget * icon_view;
+static GdkPixbuf * pixbuf_logo = NULL;
static GtkListStore *store = NULL;
@@ -182,6 +183,11 @@
devel_debug ( "combo n'existe pas" );
store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT );
gtk_list_store_append (store, &iter);
+ if ( g_strcmp0 ( PIXMAPS_DIR, path_icon ) != 0 )
+ {
+ gtk_list_store_set (store, &iter, 0, PIXMAPS_DIR, -1);
+ gtk_list_store_prepend (store, &iter);
+ }
gtk_list_store_set (store, &iter, 0, path_icon, -1);
}
@@ -510,3 +516,54 @@
return TRUE;
}
+
+/**
+ * Convertit un pixbuf en chaine codéé en base 64
+ *
+ * \param pixbuf
+ *
+* */
+gchar * gsb_select_icon_create_chaine_base64_from_pixbuf ( GdkPixbuf *pixbuf )
+{
+ GdkPixdata pixdata;
+ guint8 *str;
+ guint longueur;
+ gchar * str64;
+
+ gdk_pixdata_from_pixbuf ( &pixdata, pixbuf, FALSE );
+ str = gdk_pixdata_serialize ( &pixdata, &longueur );
+ str64 = g_base64_encode(str, longueur);
+ g_free(str);
+ return str64;
+}
+
+
+/**
+ * Convertit une chaine codée en base 64 en pixbuf
+ *
+ * \param str_base64
+ *
+* */
+void gsb_select_icon_create_pixbuf_from_chaine_base64 ( gchar *str_base64 )
+{
+ guchar *data;
+ gsize longueur;
+ GdkPixdata pixdata;
+
+ data = g_base64_decode ( str_base64, &longueur );
+ gdk_pixdata_deserialize( &pixdata, longueur, data, NULL );
+ pixbuf_logo = gdk_pixbuf_from_pixdata( &pixdata, TRUE, NULL );
+}
+
+
+GdkPixbuf *gsb_select_icon_get_logo_pixbuf ( void )
+{
+ return pixbuf_logo;
+}
+
+void gsb_select_icon_set_logo_pixbuf ( GdkPixbuf *pixbuf )
+{
+ if ( pixbuf_logo != NULL )
+ g_object_unref ( G_OBJECT ( pixbuf_logo ) );
+ pixbuf_logo = pixbuf ;
+}
Index: affichage.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/affichage.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- affichage.c 7 Jan 2009 21:18:55 -0000 1.149
+++ affichage.c 17 Jan 2009 07:23:53 -0000 1.150
@@ -31,6 +31,7 @@
#include "./gsb_file.h"
#include "./barre_outils.h"
#include "./gsb_scheduler_list.h"
+#include "./gsb_select_icon.h"
#include "./main.h"
#include "./traitement_variables.h"
#include "./utils_str.h"
@@ -71,7 +72,6 @@
extern gchar *adresse_secondaire ;
extern GdkColor archive_background_color;
extern GdkColor calendar_entry_color;
-extern gchar *chemin_logo ;
extern GdkColor couleur_fond[2];
extern GdkColor couleur_grise;
extern GdkColor couleur_selection;
@@ -145,10 +145,7 @@
G_CALLBACK ( gtk_widget_destroyed), &logo_button );
gtk_button_set_relief ( GTK_BUTTON ( logo_button ), GTK_RELIEF_NONE );
- if ( chemin_logo )
- {
- pixbuf = gdk_pixbuf_new_from_file (chemin_logo, NULL);
- }
+ pixbuf = gsb_select_icon_get_logo_pixbuf ( );
if (!pixbuf)
{
@@ -268,26 +265,21 @@
if ( etat.utilise_logo )
{
- /* on recharge l'ancien logo */
-
- if ( !chemin_logo ||
- !strlen ( g_strstrip ( chemin_logo )) )
- {
- chemin_logo = NULL;
- if ( logo_accueil && GTK_IS_WIDGET ( logo_accueil ))
- gtk_widget_hide ( logo_accueil );
- }
- else
- {
- /* Update homepage logo */
+ /* on recharge l'ancien logo */
- logo_accueil = gtk_image_new_from_file ( chemin_logo );
- gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 0 );
- gtk_widget_show ( logo_accueil );
- }
+ if ( GTK_IS_WIDGET ( logo_accueil ) )
+ gtk_widget_hide ( logo_accueil );
+ else
+ {
+ /* Update homepage logo */
+ logo_accueil = gtk_image_new_from_pixbuf (
+ gsb_select_icon_get_logo_pixbuf ( ) );
+ gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 0 );
+ gtk_widget_show ( logo_accueil );
+ }
}
else
- gtk_widget_destroy ( logo_accueil );
+ gtk_widget_destroy ( logo_accueil );
modification_fichier ( TRUE );
@@ -426,64 +418,73 @@
void change_logo_accueil ( GtkWidget * file_selector )
{
GdkPixbuf * pixbuf;
+
const gchar *selected_filename;
selected_filename = file_selection_get_filename (GTK_FILE_CHOOSER (file_selector));
if ( gsb_data_account_get_accounts_amount () )
{
- /* on change le logo */
- if ( chemin_logo )
- g_free ( chemin_logo );
- chemin_logo = my_strdup ( (gchar *) selected_filename );
-
- if ( !chemin_logo ||
- !strlen ( g_strstrip ( chemin_logo )) )
- {
- chemin_logo = NULL;
- if ( logo_accueil && GTK_IS_WIDGET ( logo_accueil ))
- gtk_widget_hide ( logo_accueil );
- }
- else
- {
- /* Update homepage logo */
- gtk_widget_destroy ( logo_accueil );
-
- logo_accueil = gtk_image_new_from_file ( chemin_logo );
- gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 0 );
- gtk_widget_show ( logo_accueil );
- }
-
- /* Update preview */
- pixbuf = gdk_pixbuf_new_from_file (chemin_logo, NULL);
- gtk_container_remove (GTK_CONTAINER(logo_button), preview);
- if (!pixbuf)
- {
- preview = gtk_image_new_from_stock ( GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_BUTTON );
- }
- else
- {
- if ( gdk_pixbuf_get_width(pixbuf) > 64 ||
- gdk_pixbuf_get_height(pixbuf) > 64)
- {
- GdkPixbuf * tmp;
- tmp = gdk_pixbuf_new ( GDK_COLORSPACE_RGB, TRUE, 8,
- gdk_pixbuf_get_width(pixbuf)/2,
- gdk_pixbuf_get_height(pixbuf)/2 );
- gdk_pixbuf_scale ( pixbuf, tmp, 0, 0,
- gdk_pixbuf_get_width(pixbuf)/2,
- gdk_pixbuf_get_height(pixbuf)/2,
- 0, 0, 0.5, 0.5, GDK_INTERP_HYPER );
- pixbuf = tmp;
- }
- preview = gtk_image_new_from_pixbuf (pixbuf);
- }
- gtk_widget_show ( preview );
- gtk_container_add ( GTK_CONTAINER(logo_button), preview );
-
- /* Mark file as modified */
- modification_fichier ( TRUE );
+ /* on change le logo */
+ gchar * chemin_logo;
+
+ chemin_logo = my_strdup ( (gchar *) selected_filename );
+
+ if ( !chemin_logo ||
+ !strlen ( g_strstrip ( chemin_logo )) )
+ {
+ if ( logo_accueil && GTK_IS_WIDGET ( logo_accueil ))
+ gtk_widget_hide ( logo_accueil );
+ preview = gtk_image_new_from_stock ( GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_BUTTON );
+ }
+ else
+ {
+ /* Update preview */
+ pixbuf = gdk_pixbuf_new_from_file (chemin_logo, NULL);
+ gtk_container_remove (GTK_CONTAINER(logo_button), preview);
+ if (!pixbuf)
+ {
+ if ( logo_accueil && GTK_IS_WIDGET ( logo_accueil ))
+ gtk_widget_hide ( logo_accueil );
+ preview = gtk_image_new_from_stock ( GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_BUTTON );
+ }
+ else
+ {
+ if ( gdk_pixbuf_get_width(pixbuf) > 64 ||
+ gdk_pixbuf_get_height(pixbuf) > 64)
+ {
+ GdkPixbuf * tmp;
+ tmp = gdk_pixbuf_new ( GDK_COLORSPACE_RGB, TRUE, 8,
+ gdk_pixbuf_get_width(pixbuf)/2,
+ gdk_pixbuf_get_height(pixbuf)/2 );
+ gdk_pixbuf_scale ( pixbuf, tmp, 0, 0,
+ gdk_pixbuf_get_width(pixbuf)/2,
+ gdk_pixbuf_get_height(pixbuf)/2,
+ 0, 0, 0.5, 0.5, GDK_INTERP_HYPER );
+ pixbuf = tmp;
+ }
+ gsb_select_icon_set_logo_pixbuf ( pixbuf );
+ preview = gtk_image_new_from_pixbuf ( pixbuf );
+
+ /* Update homepage logo */
+ gtk_widget_destroy ( logo_accueil );
+
+ logo_accueil = gtk_image_new_from_pixbuf (
+ gsb_select_icon_get_logo_pixbuf ( ) );
+ gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 0 );
+ gtk_widget_show ( logo_accueil );
+ /* modify the icon of grisbi (set in the panel of gnome or other) */
+ gtk_window_set_default_icon (
+ gsb_select_icon_get_logo_pixbuf ( ) );
+ }
+ }
+ gtk_widget_show ( preview );
+ gtk_container_add ( GTK_CONTAINER(logo_button), preview );
+
+ /* Mark file as modified */
+ modification_fichier ( TRUE );
}
}
/* **************************************************************************************************************************** */
Index: include.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/include.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- include.h 10 Jan 2009 18:53:54 -0000 1.36
+++ include.h 17 Jan 2009 07:23:53 -0000 1.37
@@ -31,6 +31,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
#ifndef NOSSL
# include <openssl/des.h>
Index: utils_files.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- utils_files.h 22 Oct 2008 11:18:54 -0000 1.20
+++ utils_files.h 17 Jan 2009 07:23:53 -0000 1.21
@@ -23,6 +23,7 @@
gchar **string,
const gchar *coding_system );
GtkWidget * my_file_chooser ();
+gchar* my_get_XDG_grisbirc_dir(void);
gchar* my_get_grisbirc_dir(void);
gchar* my_get_gsb_file_default_dir(void);
gchar * safe_file_name ( gchar* filename );
Index: accueil.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/accueil.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- accueil.c 10 Jan 2009 19:04:54 -0000 1.191
+++ accueil.c 17 Jan 2009 07:23:53 -0000 1.192
@@ -37,10 +37,10 @@
#include "./gsb_real.h"
#include "./gsb_scheduler.h"
#include "./gsb_scheduler_list.h"
+#include "./gsb_select_icon.h"
#include "./gsb_transactions_list.h"
#include "./main.h"
#include "./utils.h"
-#include "./utils_str.h"
#include "./structures.h"
#include "./fenetre_principale.h"
#include "./gsb_data_account.h"
@@ -80,7 +80,6 @@
extern GtkWidget *window ;
/*END_EXTERN*/
-gchar *chemin_logo = NULL;
GtkWidget *logo_accueil = NULL;
GtkWidget *hbox_title = NULL;
GtkWidget *label_titre_fichier = NULL;
@@ -113,6 +112,8 @@
{
GtkWidget *paddingbox, *base, *base_scroll;
+ devel_debug ( NULL );
+
/* on crée à ce niveau base_scroll qui est aussi une vbox mais qui peut
scroller verticalement */
@@ -128,13 +129,6 @@
gtk_widget_show ( base_scroll );
gtk_widget_show ( base );
- if ( !chemin_logo || !strlen ( chemin_logo ))
- {
- if ( chemin_logo )
- g_free ( chemin_logo );
- chemin_logo = my_strdup ( LOGO_PATH );
- }
-
/* en dessous, on met le titre du fichier s'il existe */
if ( titre_fichier )
{
@@ -157,9 +151,10 @@
gtk_label_set_markup ( GTK_LABEL ( label_titre_fichier ), tmpstr);
g_free ( tmpstr );
- if ( etat.utilise_logo && chemin_logo )
+ if ( etat.utilise_logo )
{
- logo_accueil = gtk_image_new_from_file ( chemin_logo );
+ logo_accueil = gtk_image_new_from_pixbuf (
+ gsb_select_icon_get_logo_pixbuf ( ) );
g_signal_connect ( G_OBJECT ( logo_accueil ), "destroy",
G_CALLBACK( gtk_widget_destroyed ), &logo_accueil);
gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 20 );
Index: Makefile.am
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/Makefile.am,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- Makefile.am 4 Jan 2009 18:31:54 -0000 1.152
+++ Makefile.am 17 Jan 2009 07:23:53 -0000 1.153
@@ -104,6 +104,7 @@
gsb_report.c \
gsb_scheduler.c \
gsb_scheduler_list.c \
+ gsb_select_icon.c \
gsb_status.c \
gsb_transactions_list.c \
gsb_transactions_list_sort.c \
@@ -144,8 +145,7 @@
utils_str.c \
balance_estimate_tab.c
-grisbi_SOURCES = $(sources) $(sources_config) \
- gsb_select_icon.c
+grisbi_SOURCES = $(sources) $(sources_config)
grisbi_INCLUDES = \
$(include_config) \
@@ -232,6 +232,7 @@
gsb_reconcile_sort_config.h \
gsb_report.h \
gsb_status.h \
+ gsb_select_icon.h \
gsb_scheduler.h \
gsb_scheduler_list.h \
gsb_transactions_list.h \
Index: gsb_file_config.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_config.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gsb_file_config.h 6 Apr 2008 10:05:34 -0000 1.6
+++ gsb_file_config.h 17 Jan 2009 07:23:53 -0000 1.7
@@ -8,7 +8,10 @@
#define ETAT_WWW_BROWSER "firefox"
#ifndef _WIN32
-#define C_GRISBIRC (g_strconcat ( "/.", PACKAGE, "rc", NULL))
+#define C_GRISBIRC (g_strconcat ( "/", PACKAGE, ".conf", NULL))
+#define C_OLD_GRISBIRC (g_strconcat ( "/.", PACKAGE, "rc", NULL))
+#define C_PATH_CONFIG (g_strconcat (g_get_user_config_dir ( ), G_DIR_SEPARATOR_S,\
+ "grisbi", NULL))
#else
/* Some old Windows version have difficulties with dat starting file names */
#define C_GRISBIRC (g_strconcat ( "\\", PACKAGE, "rc", NULL))
@@ -16,6 +19,7 @@
/* START_DECLARATION */
+gboolean gsb_file_config_create_config_rep ( void );
gboolean gsb_file_config_load_config ( void );
gboolean gsb_file_config_save_config ( void );
/* END_DECLARATION */
Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- gsb_file_load.c 4 Jan 2009 18:31:54 -0000 1.145
+++ gsb_file_load.c 17 Jan 2009 07:23:53 -0000 1.146
@@ -54,6 +54,7 @@
#include "./gsb_file_util.h"
#include "./gsb_plugins.h"
#include "./gsb_real.h"
+#include "./gsb_select_icon.h"
#include "./utils_str.h"
#include "./traitement_variables.h"
#include "./custom_list.h"
@@ -101,6 +102,8 @@
gint payment_number );
static void gsb_file_load_import_rule ( const gchar **attribute_names,
const gchar **attribute_values );
+static void gsb_file_load_logo_accueil ( const gchar **attribute_names,
+ const gchar **attribute_values );
static void gsb_file_load_party ( const gchar **attribute_names,
const gchar **attribute_values );
static void gsb_file_load_payment_part ( const gchar **attribute_names,
@@ -143,7 +146,6 @@
extern gint affichage_echeances_perso_nb_libre;
extern GdkColor archive_background_color;
extern GdkColor calendar_entry_color;
-extern gchar *chemin_logo ;
extern GdkColor couleur_fond[2];
extern GdkColor couleur_grise;
extern GdkColor couleur_selection;
@@ -151,6 +153,7 @@
extern gint display_three_lines;
extern gint display_two_lines;
extern struct iso_4217_currency iso_4217_currencies[] ;
+extern GtkWidget *logo_accueil ;
extern gint no_devise_totaux_categ;
extern gint no_devise_totaux_ib;
extern gint no_devise_totaux_tiers;
@@ -579,6 +582,13 @@
attribute_values);
return;
}
+ if ( !strcmp ( element_name,
+ "Logo" ))
+ {
+ gsb_file_load_logo_accueil ( attribute_names,
+ attribute_values );
+ return;
+ }
/* the first time we come here, we check if it's a grisbi file */
}
@@ -734,12 +744,16 @@
else if ( !strcmp ( attribute_names[i],
"Path_logo" ))
{
- if ( chemin_logo )
- g_free ( chemin_logo );
+ GdkPixbuf *pixbuf;
+ gchar *chemin_logo;
+
chemin_logo = my_strdup (attribute_values[i]);
+ pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
+ gsb_select_icon_set_logo_pixbuf ( pixbuf );
/* modify the icon of grisbi (set in the panel of gnome or other) */
if (g_file_test ( chemin_logo, G_FILE_TEST_EXISTS ) && etat.utilise_logo)
gtk_window_set_default_icon_from_file ( chemin_logo, NULL );
+ g_free ( chemin_logo );
}
else if ( !strcmp ( attribute_names[i],
@@ -4277,7 +4291,43 @@
}
+/**
+ * load the logo_accueil in the grisbi file
+ *
+ * \param attribute_names
+ * \param attribute_values
+ *
+ * */
+void gsb_file_load_logo_accueil ( const gchar **attribute_names,
+ const gchar **attribute_values )
+{
+ gint i=0;
+
+ do
+ {
+ /* we test at the beginning if the attribute_value is NULL, if yes, */
+ /* go to the next */
+ if ( !strcmp (attribute_values[i],
+ "(null)"))
+ {
+ i++;
+ continue;
+ }
+ if ( !strcmp ( attribute_names[i],
+ "Image" ))
+ {
+ gsb_select_icon_create_pixbuf_from_chaine_base64 ( (gchar *)
+ attribute_values[i] );
+ gtk_window_set_default_icon (
+ gsb_select_icon_get_logo_pixbuf ( ) );
+ devel_debug ("Chargement du logo");
+ i++;
+ continue;
+ }
+ }
+ while ( attribute_names[i] );
+}
void gsb_file_load_start_element_before_0_6 ( GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
@@ -5560,10 +5610,17 @@
if ( !strcmp ( element_name,
"Chemin_logo" ))
{
- if ( chemin_logo )
- g_free ( chemin_logo );
- chemin_logo = my_strdup (text);
- return;
+ GdkPixbuf *pixbuf;
+ gchar *chemin_logo;
+
+ chemin_logo = my_strdup (text);
+ pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
+ gsb_select_icon_set_logo_pixbuf ( pixbuf );
+ /* modify the icon of grisbi (set in the panel of gnome or other) */
+ if (g_file_test ( chemin_logo, G_FILE_TEST_EXISTS ) && etat.utilise_logo)
+ gtk_window_set_default_icon_from_file ( chemin_logo, NULL );
+ g_free ( chemin_logo );
+ return;
}
if ( !strcmp ( element_name,
@@ -7516,21 +7573,19 @@
/* general stuff for all versions */
/* if no logo, set it */
- if ( !chemin_logo
- ||
- !strlen ( chemin_logo )
- ||
- ( chemin_logo
- &&
- strlen ( chemin_logo )
- &&
- !g_file_test (chemin_logo, G_FILE_TEST_EXISTS)))
+ if ( gsb_select_icon_get_logo_pixbuf ( ) == NULL )
{
- if ( chemin_logo )
- g_free ( chemin_logo );
+ GdkPixbuf *pixbuf;
+ gchar *chemin_logo;
+
chemin_logo = my_strdup ( LOGO_PATH );
+ pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
+ gsb_select_icon_set_logo_pixbuf ( pixbuf );
+ /* modify the icon of grisbi (set in the panel of gnome or other) */
+ if (g_file_test ( chemin_logo, G_FILE_TEST_EXISTS ) && etat.utilise_logo)
+ gtk_window_set_default_icon_from_file ( chemin_logo, NULL );
+ g_free ( chemin_logo );
}
-
/* mark the file as opened */
gsb_file_util_modify_lock ( TRUE );
Index: utils_files.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_files.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- utils_files.c 22 Oct 2008 11:18:54 -0000 1.33
+++ utils_files.c 17 Jan 2009 07:23:53 -0000 1.34
@@ -32,6 +32,7 @@
#include "./utils_dates.h"
#include "./gsb_file.h"
#include "./utils_str.h"
+#include "./gsb_file_config.h"
#include "./utils_file_selection.h"
#include "./include.h"
#include "./erreur.h"
@@ -94,7 +95,25 @@
gchar* my_get_grisbirc_dir(void)
{
#ifndef _WIN32
- return (gchar *) g_get_home_dir();
+ return (gchar *) g_get_home_dir ();
+#else
+ return win32_get_grisbirc_folder_path();
+#endif
+}
+
+
+/**
+ * return the absolute path of where the configuration file should be located
+ * On UNIX platforms this is determined using the mechanisms described
+ * in the XDG Base Directory Specification
+ * on Windows based systems return APPDATA\Grisbi
+ *
+ * \return the absolute path of the configuration file directory
+ */
+gchar* my_get_XDG_grisbirc_dir(void)
+{
+#ifndef _WIN32
+ return (gchar *) C_PATH_CONFIG;
#else
return win32_get_grisbirc_folder_path();
#endif
Index: main.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/main.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- main.c 11 Dec 2008 19:52:51 -0000 1.134
+++ main.c 17 Jan 2009 07:23:53 -0000 1.135
@@ -51,6 +51,7 @@
#include "./parse_cmdline.h"
#include "./import.h"
#include "./parse_cmdline.h"
+#include "./gsb_file_config.h"
#include "./include.h"
#include "./erreur.h"
#include "./structures.h"
@@ -171,9 +172,11 @@
init_variables ();
register_import_formats ();
+ /* on crée ici le nouveau répertoire de conf */
if ( ! gsb_file_config_load_config () )
{
- first_use = TRUE;
+ gsb_file_config_create_config_rep ( );
+ first_use = TRUE;
}
/* create the toplevel window */
@@ -218,7 +221,8 @@
menus_sensitifs ( FALSE );
/* charge les raccourcis claviers */
- path = g_strconcat (g_get_home_dir (), "/.gnome2/accels/", PACKAGE, NULL);
+ path = g_strconcat ( C_PATH_CONFIG, G_DIR_SEPARATOR_S,
+ "grisbi-accels", NULL );
gtk_accel_map_load (path);
/* set the last opened files */
Index: gsb_file_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_config.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- gsb_file_config.c 1 Nov 2008 08:08:56 -0000 1.61
+++ gsb_file_config.c 17 Jan 2009 07:23:53 -0000 1.62
@@ -95,7 +95,7 @@
gsb_file_config_clean_config ();
- filename = g_strconcat ( my_get_grisbirc_dir(), C_GRISBIRC, NULL );
+ filename = g_strconcat ( my_get_XDG_grisbirc_dir(), C_GRISBIRC, NULL );
config = g_key_file_new ();
result = g_key_file_load_from_file ( config,
@@ -103,13 +103,27 @@
G_KEY_FILE_KEEP_COMMENTS,
NULL );
/* if key_file couldn't load the conf, it's because it's the last
- * conf (xml) or no conf... try the xml conf */
+ * conf (HOME or xml) or no conf... try the HOME conf and the xml conf */
if (!result)
{
- result = gsb_file_config_load_last_xml_config (filename);
- g_free (filename);
- g_key_file_free (config);
- return result;
+ /* On recherche le fichier dans HOME */
+ filename = g_strconcat ( my_get_grisbirc_dir(), C_OLD_GRISBIRC, NULL );
+ config = g_key_file_new ();
+
+ result = g_key_file_load_from_file ( config,
+ filename,
+ G_KEY_FILE_KEEP_COMMENTS,
+ NULL );
+ /* si on ne le trouve pas on recherche le fichier au format xml */
+ if (!result)
+ {
+ result = gsb_file_config_load_last_xml_config (filename);
+ g_free (filename);
+ g_key_file_free (config);
+ return result;
+ }
+ else
+ g_remove ( filename );
}
/* get the geometry */
@@ -406,7 +420,7 @@
devel_debug (NULL);
- filename = g_strconcat ( my_get_grisbirc_dir(), C_GRISBIRC, NULL );
+ filename = g_strconcat ( my_get_XDG_grisbirc_dir(), C_GRISBIRC, NULL );
config = g_key_file_new ();
/* get the geometry */
@@ -1207,6 +1221,22 @@
}
+/**
+ * create the config repertory
+ * using the mechanisms described in the XDG Base Directory Specification
+ *
+ * \param
+ *
+ * \return TRUE if ok
+ * */
+gboolean gsb_file_config_create_config_rep ( void )
+{
+ /* permissions = 450 trouvé au pif */
+ if ( g_mkdir_with_parents ( C_PATH_CONFIG, 450 ) == 0 )
+ return TRUE;
+ else
+ return FALSE;
+}
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
More information about the cvs
mailing list