]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Correzioni varie.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 21 Dec 2010 14:39:31 +0000 (15:39 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 21 Dec 2010 14:39:31 +0000 (15:39 +0100)
Sotto windows non esiste la funzione mkdtemp.
Sotto windows non funzionano solipa_mail_send e solipa_gtktreemodel_to_csv_gui.

configure.ac
data/libsolipa/gui/libsolipa.ui
src/Makefile.am
src/allegato.h
src/mail.c
src/mail.h
src/solipa.c
src/utils.c
src/utils.h

index 67c870faf3cef4c67e535d2cff0e4bc0ef390b3a..c3ccf3c351346cda7b669cda5fa3b904cab0fd42 100644 (file)
@@ -30,7 +30,7 @@ AC_PROG_RANLIB
 PKG_CHECK_MODULES(SOLIPA, [gobject-2.0 >= 2.24.0
                            glib-2.0 >= 2.24.0
                            libgdaex >= 0.2.2
-                           camel-provider-1.2 >= 2.30
+                           camel-provider-1.2 >= 2.24
                            gtk+-2.0 >= 2.20
                            gio-2.0 >= 2.24])
 
index ad6bd4f1f37c67ede00996fa48b744fb69cce187..f738f8d6b34ed9f97656dcc828fa8d3b40d80ec7 100644 (file)
       </object>
     </child>
   </object>
+  <object class="GtkListStore" id="lstore_treemodel_campi">
+    <columns>
+      <!-- column-name selezionato -->
+      <column type="gboolean"/>
+      <!-- column-name id -->
+      <column type="guint"/>
+      <!-- column-name nome -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="diag_gtktreemodel_to_csv">
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Esporta CSV</property>
                       <object class="GtkFileChooserWidget" id="filechooserwidget1">
                         <property name="visible">True</property>
                         <property name="orientation">vertical</property>
+                        <property name="local_only">False</property>
                         <property name="use_preview_label">False</property>
-                        <property name="preview_widget_active">False</property>
                         <property name="action">save</property>
-                        <property name="local_only">False</property>
+                        <property name="preview_widget_active">False</property>
                       </object>
                     </child>
                   </object>
       <action-widget response="-5">button2</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkListStore" id="lstore_treemodel_campi">
-    <columns>
-      <!-- column-name selezionato -->
-      <column type="gboolean"/>
-      <!-- column-name id -->
-      <column type="guint"/>
-      <!-- column-name nome -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
 </interface>
index 880797eecfb3767d52b56efb98ee3ea9bb309f4d..b663c205bcfb2b2dc37b1225487e55a9296197bd 100644 (file)
@@ -3,7 +3,8 @@ guidir = $(datadir)/$(PACKAGE)/gui
 LIBS = $(SOLIPA_LIBS)
 
 AM_CPPFLAGS = $(SOLIPA_CFLAGS) \
-              -DGUIDIR=\""$(guidir)"\"
+              -DGUIDIR=\""$(guidir)"\" \
+              -DG_LOG_DOMAIN=\"Solipa\"
 
 lib_LTLIBRARIES = libsolipa.la
 
index 4d0ba30ccb2b4b923bbaf43c5dcc85faf8c8c9d0..2bae2992fd5205986568626b5d18f0aab5813ec4 100644 (file)
@@ -22,7 +22,7 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include <libsolipa/solipa.h>
+#include "solipa.h"
 
 
 G_BEGIN_DECLS
index 3b922cab75db23d22bd6ca4f104427b28f14ff9b..975ad860a4a0a43d3ce6cd72e2e78b710f5cb980 100644 (file)
@@ -386,8 +386,9 @@ solipa_mail_send (SolipaMail *mail, const gchar *url)
                        g_warning ("Not service: %s", camel_exception_get_description (ex));
                        return;
                }
+
        gboolean ret = camel_service_connect (trans, ex);
-       if (camel_exception_is_set(ex))
+       if (camel_exception_is_set (ex))
                {
                        g_warning ("Not connected: %s", camel_exception_get_description (ex));
                        goto noconnect;
index 1cfbce22f931bae39324fb3c0c4c8a3e2916242d..a61584c7df1e9375bc74085c35952da84900d6ae 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <camel/camel.h>
 
-#include <libsolipa/solipa.h>
+#include "solipa.h"
 
 
 G_BEGIN_DECLS
index 891c4288a7cb3b87738bc2ca0e5baef48e337f2f..4a6a88e65264583403c288f234af2f4843a85a52 100644 (file)
@@ -25,6 +25,7 @@
 #include <gtk/gtk.h>
 
 #include "solipa.h"
+#include "utils.h"
 
 static void solipa_class_init (SolipaClass *class);
 static void solipa_init (Solipa *solipa);
@@ -92,7 +93,7 @@ Solipa
        priv = SOLIPA_GET_PRIVATE (solipa);
 
        /* creo la directory temporanea per camel */
-       camel_tmpdir = mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL));
+       camel_tmpdir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), g_strdup ("solipa-camel-XXXXXX"), NULL));
 
        /* inizializzo camel */
        camel_init (camel_tmpdir, FALSE);
@@ -106,18 +107,18 @@ Solipa
        gchar *moddir;
        gchar *p;
 
-       moddir = g_win32_get_package_installation_directory_of_module (NULL);
+       moddir = g_win32_get_package_installation_directory_of_module (NULL);
 
-       p = strrchr (moddir, G_DIR_SEPARATOR);
-       if (p != NULL
-           && (g_ascii_strcasecmp (p + 1, "src") == 0
-               || g_ascii_strcasecmp (p + 1, ".libs") == 0))
+       p = strrchr (moddir, G_DIR_SEPARATOR);
+       if (p != NULL
+           && (g_ascii_strcasecmp (p + 1, "src") == 0
+               || g_ascii_strcasecmp (p + 1, ".libs") == 0))
                {
-                       solipa->guidir = g_strdup (GUIDIR);
+                       priv->guidir = g_strdup (GUIDIR);
                }
        else
                {
-                       solipa->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL);
+                       priv->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL);
                }
 
 #else
@@ -243,7 +244,7 @@ const gchar
 
        priv = SOLIPA_GET_PRIVATE (solipa);
 
-       return g_strdup (priv->guifile);
+       return (const gchar *)g_strdup (priv->guifile);
 }
 
 GtkBuilder
index e0b9fb7cbc7b80bbf2a97138ed6f7df4e32ede4c..6087e4642d0d6793be457fb1b3514fcef2d4d4d1 100644 (file)
@@ -276,6 +276,12 @@ solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model,
 
        builder = solipa_get_gtkbuilder (solipa);
 
+       if (!GTK_IS_BUILDER (builder))
+               {
+                       g_warning ("GtkBuilder not initialized.");
+                       return;
+               }
+
        error = NULL;
        gtk_builder_add_objects_from_file (builder,
                                           solipa_get_guifile (solipa),
@@ -300,9 +306,9 @@ solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model,
                                           "toggled", G_CALLBACK (solipa_fixed_toggled), (gpointer)store);
 
                        g_signal_connect (gtk_builder_get_object (builder, "button3"),
-                                         "clicked", G_CALLBACK (solipa_on_btn_unselect_all_clicked), (gpointer *)store);
+                                         "clicked", G_CALLBACK (solipa_on_btn_unselect_all_clicked), (gpointer)store);
                        g_signal_connect (gtk_builder_get_object (builder, "button4"),
-                                         "clicked", G_CALLBACK (solipa_on_btn_select_all_clicked), (gpointer *)store);
+                                         "clicked", G_CALLBACK (solipa_on_btn_select_all_clicked), (gpointer)store);
 
                        gtk_list_store_clear (store);
 
@@ -458,3 +464,87 @@ gchar
 
        return ret;
 }
+
+/**
+ * This function is copied from
+ * http://bugzilla.gnome.org/show_bug.cgi?id=524831.
+ *
+ * If/when this function gets added to glib, it can be removed from
+ * sources.
+ *
+ *
+ * g_mkdtemp:
+ * @tmpl: template directory name
+ *
+ * Creates a temporary directory. See the mkdtemp() documentation
+ * on most UNIX-like systems.
+ *
+ * The parameter is a string that should follow the rules for
+ * mkdtemp() templates, i.e. contain the string "XXXXXX".  g_mkdtemp()
+ * is slightly more flexible than mkdtemp() in that the sequence does
+ * not have to occur at the very end of the template. The X string
+ * will be modified to form the name of a directory that didn't
+ * already exist.  The string should be in the GLib file name
+ * encoding. Most importantly, on Windows it should be in UTF-8.
+ *
+  * Return value: If a temporary directory was successfully created,
+ * @tmpl will be returned with the XXXXXX string modified in such a
+ * way as to make the path unique.  In case of errors, %NULL is
+ * returned.
+ */
+gchar *
+g_mkdtemp (gchar *tmpl)
+{
+  static const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+  static const int NLETTERS = sizeof (letters) - 1;
+  static int counter = 0;
+  char *XXXXXX;
+  GTimeVal tv;
+  glong value;
+  int count;
+
+  /* find the last occurrence of "XXXXXX" */
+  XXXXXX = g_strrstr (tmpl, "XXXXXX");
+
+  if (!XXXXXX || strncmp (XXXXXX, "XXXXXX", 6))
+    {
+      errno = EINVAL;
+      return NULL;
+    }
+
+  /* Get some more or less random data.  */
+  g_get_current_time (&tv);
+  value = (tv.tv_usec ^ tv.tv_sec) + counter++;
+
+  for (count = 0; count < 100; value += 7777, ++count)
+    {
+      glong v = value;
+
+      /* Fill in the random bits.  */
+      XXXXXX[0] = letters[v % NLETTERS];
+      v /= NLETTERS;
+      XXXXXX[1] = letters[v % NLETTERS];
+      v /= NLETTERS;
+      XXXXXX[2] = letters[v % NLETTERS];
+      v /= NLETTERS;
+      XXXXXX[3] = letters[v % NLETTERS];
+      v /= NLETTERS;
+      XXXXXX[4] = letters[v % NLETTERS];
+      v /= NLETTERS;
+      XXXXXX[5] = letters[v % NLETTERS];
+
+      /* tmpl is in UTF-8 on Windows, thus use g_mkdir() */
+      if (g_mkdir (tmpl, 0700) == 0)
+        return tmpl;
+
+      if (errno != EEXIST)
+         /* Any other error will apply also to other names we might
+         *  try, and there are 2^32 or so of them, so give up now.
+         */
+         return NULL;
+    }
+
+  /* We got out of the loop because we ran out of combinations to try.  */
+  errno = EEXIST;
+  return NULL;
+}
index 3bac23df19869139813558e0285658e1849aba9c..e73d3073bd1ffe6fac8f84e77e60304b3a0eba43 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <gtk/gtk.h>
 
-#include <libsolipa/solipa.h>
+#include "solipa.h"
 
 
 G_BEGIN_DECLS
@@ -44,6 +44,8 @@ void solipa_gtktreemodel_to_csv_gui (Solipa *solipa, GtkTreeModel *model,
 
 gchar *solipa_format_money (gdouble number, gint decimals, gboolean with_currency_symbol);
 
+gchar *g_mkdtemp (gchar *tmpl);
+
 
 G_END_DECLS