Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv7274/src

Modified Files:
        display.c file_itunesdb.c misc.h misc_confirm.c 
Log Message:
        * src/display.c (on_ipod_directories_new): use new
          gp_ipod_init() function to create directories.

          src/file_itunesdb.c (gp_write_itdb): use new gp_ipod_init()
          function to create directories.

          src/misc.h
          src/misc_confirm.c: Removed old ipod_directories... code.
          code.



Index: display.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- display.c   23 Jun 2006 16:59:23 -0000      1.146
+++ display.c   24 Jun 2006 12:37:45 -0000      1.147
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-24 01:53:45 jcs>
+/* Time-stamp: <2006-06-24 15:56:24 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -34,6 +34,7 @@
 #include "details.h"
 #include "display_private.h"
 #include "info.h"
+#include "ipod_init.h"
 #include "misc.h"
 #include "misc_track.h"
 #include "prefs.h"
@@ -1193,7 +1194,30 @@
     iTunesDB *itdb = gp_get_ipod_itdb ();
     if (itdb)
     {
-       ipod_directories_head (itdb_get_mountpoint (itdb));
+       ExtraiTunesDBData *eitdb = itdb->userdata;
+
+       g_return_if_fail (eitdb);
+
+
+       if (!eitdb->itdb_imported)
+       {
+           gchar *mountpoint = get_itdb_prefs_string (itdb, KEY_MOUNTPOINT);
+           gchar *str = g_strdup_printf (_("iPod at '%s' is not 
loaded.\nPlease load it first."), mountpoint);
+           GtkWidget *dialog = gtk_message_dialog_new (
+               GTK_WINDOW (gtkpod_window),
+               GTK_DIALOG_DESTROY_WITH_PARENT,
+               GTK_MESSAGE_WARNING,
+               GTK_BUTTONS_OK,
+               str);
+           gtk_dialog_run (GTK_DIALOG (dialog));
+           gtk_widget_destroy (dialog);
+           g_free (str);
+           g_free (mountpoint);
+       }
+       else
+       {
+            gp_ipod_init (itdb);
+       }
     }
     else
     {

Index: file_itunesdb.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_itunesdb.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- file_itunesdb.c     23 Jun 2006 16:46:12 -0000      1.96
+++ file_itunesdb.c     24 Jun 2006 12:37:46 -0000      1.97
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-24 01:38:21 jcs>
+/* Time-stamp: <2006-06-24 21:25:02 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -805,7 +805,7 @@
     itunesdb = itdb_get_itunesdb_path (mountpoint);
     if (!itunesdb)
     {
-       gchar *str = g_strdup_printf (_("Could not find iPod directory 
structure at '%s'. If you are sure that the iPod is properly mounted at '%s', 
gtkpod can create the directory structure for you.\n\nDo you want to create the 
directory structure now?\n"), mountpoint, mountpoint);
+       gchar *str = g_strdup_printf (_("Could not find iPod directory 
structure at '%s'.\nIf you are sure that the iPod is properly mounted at '%s', 
gtkpod can create the directory structure for you.\n\nDo you want to create the 
directory structure now?\n"), mountpoint, mountpoint);
        GtkWidget *dialog = gtk_message_dialog_new (
            GTK_WINDOW (gtkpod_window),
            GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1572,7 +1572,7 @@
       /* check if iPod directories are present */
       if (!ipod_dirs_present (mountpoint))
       {   /* no -- create them */
-         ipod_directories_head (mountpoint);
+         gp_ipod_init (itdb);
          /* if still not present abort */
          if (!ipod_dirs_present (mountpoint))
          {

Index: misc.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- misc.h      20 Jun 2006 23:13:35 -0000      1.117
+++ misc.h      24 Jun 2006 12:37:46 -0000      1.118
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-05 00:33:43 jcs>
+/* Time-stamp: <2006-06-24 20:55:40 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -113,7 +113,6 @@
 const gchar *get_t_string (T_item t);
 const gchar *get_t_tooltip (T_item t);
 
-void ipod_directories_head (const gchar *mountpoint);
 void delete_playlist_head (DeleteAction deleteaction);
 void delete_track_head (DeleteAction deleteaction);
 void delete_entry_head (gint entry_inst, DeleteAction deleteaction);

Index: misc_confirm.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc_confirm.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- misc_confirm.c      23 Jun 2006 16:59:23 -0000      1.39
+++ misc_confirm.c      24 Jun 2006 12:37:46 -0000      1.40
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-24 01:59:05 jcs>
+/* Time-stamp: <2006-06-24 20:55:39 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -817,210 +817,6 @@
 
 
 
-/*------------------------------------------------------------------*\
- *                                                                  *
- *             Create iPod directory hierarchy                      *
- *                                                                  *
-\*------------------------------------------------------------------*/
-
-/* deterimine the number of directories that should be created */
-/*
- * <20 GB: 20
- * <30 GB: 30
- * <40 GB: 40
- * <50 GB: 50
- * else:   60
- *
- */
-static gint ipod_directories_number (gchar *mp)
-{
-    const gint default_nr = 20;
-#ifdef HAVE_STATVFS
-    struct statvfs stat;
-    int        status;
-    gdouble size;
-
-    g_return_val_if_fail (mp, default_nr);
-
-    status = statvfs (mp, &stat);
-    if (status != 0)
-    {
-       return default_nr;
-    }
-    /* Get size in GB */
-    size = ((gdouble)stat.f_blocks * stat.f_frsize) / 1024 / 1024 / 1024;
-    if (size < 20) return 20;
-    if (size < 30) return 30;
-    if (size < 40) return 40;
-    if (size < 50) return 50;
-    return 60;
-#else
-    return default_nr;
-#endif
-}
-
-
-/* ok handler for ipod directory creation */
-/* @user_data1 is the mount point of the iPod */
-static void ipod_directories_ok (gchar *mp)
-{
-    gchar *errordir=NULL;
-    gchar *pbuf;
-    gint i, dirnum;
-
-    g_return_if_fail (mp);
-
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "Calendars", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "Contacts", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "iPod_Control", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "iPod_Control", "Music", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "iPod_Control", "iTunes", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    if (!errordir)
-    {
-       pbuf = g_build_filename (mp, "iPod_Control", "Artwork", NULL);
-       if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-       {
-           if((mkdir(pbuf, 0777) != 0))
-               errordir = pbuf;
-       }
-       if (!errordir)
-           g_free (pbuf);
-    }
-    dirnum = ipod_directories_number (mp);
-    for(i = 0; i < dirnum; i++)
-    {
-       if (!errordir)
-       {
-           gchar *num = g_strdup_printf ("F%02d", i);
-           pbuf = g_build_filename (mp,
-                                    "iPod_Control", "Music", num, NULL);
-           if (!g_file_test (pbuf, G_FILE_TEST_EXISTS))
-           {
-               if((mkdir(pbuf, 0777) != 0))
-                   errordir = pbuf;
-               g_free (num);
-           }
-           if (!errordir)
-               g_free (pbuf);
-       }
-    }
-
-    if (errordir)
-       gtkpod_statusbar_message (_("Problem creating iPod directory: '%s'."), 
errordir);
-    else
-       gtkpod_statusbar_message (_("Successfully created iPod directories in 
'%s'."), mp);
-    g_free (errordir);
-}
-
-
-/* Pop up the confirmation window for creation of ipod directory
-   hierarchy. */
-void ipod_directories_head (const gchar *mountpoint)
-{
-    gchar *mp;
-    GString *str;
-    GtkResponseType response;
-
-    g_return_if_fail (mountpoint);
-    mp = g_strdup (mountpoint);
-
-    if (strlen (mp) > 0)
-    { /* make sure the mount point does not end in "/" */
-       if (mp[strlen (mp) - 1] == '/')
-           mp[strlen (mp) - 1] = 0;
-    }
-    else
-    {
-       mp = g_strdup (".");
-    }
-    str = g_string_sized_new (2000);
-    g_string_append_printf (str, "%s/Calendars\n", mp);
-    g_string_append_printf (str, "%s/Contacts\n", mp);
-    g_string_append_printf (str, "%s/iPod_Control\n", mp);
-    g_string_append_printf (str, "%s/iPod_Control/Music\n", mp);
-    g_string_append_printf (str, "%s/iPod_Control/iTunes\n", mp);
-    g_string_append_printf (str, "%s/iPod_Control/Music/F00\n...\n", mp);
-    g_string_append_printf (str, "%s/iPod_Control/Music/F%d\n",
-                           mp, ipod_directories_number (mp)-1);
-
-    response = gtkpod_confirmation (CONF_ID_IPOD_DIR,    /* gint id, */
-                        TRUE,               /* gboolean modal, */
-                        _("Create iPod directories"), /* title */
-                        _("OK to create the following directories?"),
-                        str->str,
-                        NULL, 0, NULL,       /* option 1 */
-                        NULL, 0, NULL,       /* option 2 */
-                        TRUE,                /* gboolean confirm_again, */
-                        NULL, /* ConfHandlerOpt confirm_again_key, */
-                        CONF_NULL_HANDLER,   /* ConfHandler ok_handler,*/
-                        NULL,                /* don't show "Apply" */
-                        CONF_NULL_HANDLER,   /* cancel_handler,*/
-                        NULL,                /* gpointer user_data1,*/
-                        NULL);               /* gpointer
-                                              * user_data2,*/
-    switch (response)
-    {
-    case GTK_RESPONSE_OK:
-       ipod_directories_ok (mp);
-       break;
-    default:
-       break;
-    }
-    g_free (mp);
-    g_string_free (str, TRUE);
-}
-
-
 /* callback for quit menu entry */
 void
 on_quit1_activate                      (GtkMenuItem     *menuitem,


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to