Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv14178/src
Modified Files:
file_itunesdb.c ipod_init.c ipod_init.h repository.c
Log Message:
* src/ipod_init.[ch]...: renamed init_model_number_combo()
and init_ipod() to gp_...()
* src/file_itunesdb (gp_load_ipod): ask for model number of
the iPod if none is available. If one is available from
SysInfo file, store that information in the prefs system.
* ipod_init.[ch]: new: gp_ipod_init_set_model() asking for a
model number string and storing it.
Index: file_itunesdb.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_itunesdb.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- file_itunesdb.c 6 Jun 2006 00:47:06 -0000 1.90
+++ file_itunesdb.c 10 Jun 2006 10:38:58 -0000 1.91
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-06 00:42:56 jcs>
+/* Time-stamp: <2006-06-10 18:20:19 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -847,7 +847,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, gtkpod
can create the directory structure for you.\n\nDo you want to create the
directory structure now?\n"), mountpoint);
+ 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);
GtkWidget *dialog = gtk_message_dialog_new (
GTK_WINDOW (gtkpod_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -860,7 +860,7 @@
if (result == GTK_RESPONSE_YES)
{
- load = ipod_init (itdb);
+ load = gp_ipod_init (itdb);
}
else
{
@@ -873,6 +873,40 @@
if (load)
{
new_itdb = gp_merge_itdb (itdb);
+ if (new_itdb)
+ {
+ gchar *old_model = get_itdb_prefs_string (new_itdb,
+ KEY_IPOD_MODEL);
+ gchar *new_model = itdb_device_get_sysinfo (new_itdb->device,
+ "ModelNumStr");
+
+ if (!old_model && new_model)
+ {
+ set_itdb_prefs_string (new_itdb, KEY_IPOD_MODEL, new_model);
+ }
+ else if (old_model && !new_model)
+ {
+ gp_ipod_init_set_model (new_itdb, old_model);
+ }
+ else if (!old_model && !new_model)
+ {
+ gp_ipod_init_set_model (new_itdb, NULL);
+ }
+ else
+ { /* old_model && new_model are set */
+#if 0
+ const gchar *old_ptr = old_model;
+ const gchar *new_ptr = new_model;
+ /* Normalize model number */
+ if (isalpha (old_model[0])) ++old_ptr;
+ if (isalpha (new_model[0])) ++new_ptr;
+ if (strcmp (old_ptr, new_ptr) != 0)
+ { /* Model number has changed -- confirm */
+ }
+#endif
+ set_itdb_prefs_string (new_itdb, KEY_IPOD_MODEL, new_model);
+ }
+ }
}
return new_itdb;
}
@@ -1869,5 +1903,3 @@
}
return !changed;
}
-
-
Index: ipod_init.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/ipod_init.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ipod_init.c 8 Jun 2006 15:40:16 -0000 1.4
+++ ipod_init.c 10 Jun 2006 10:38:58 -0000 1.5
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-09 00:16:50 jcs>
+/* Time-stamp: <2006-06-10 19:21:29 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -60,7 +60,7 @@
};
-/* shortcut to reference widgets when repwin->xml is already set */
+/* shortcut to reference widgets when ii->xml is already set */
#define GET_WIDGET(a) gtkpod_xml_get_widget (ii->xml,a)
/* mountpoint browse button was clicked -> open a directory browser
@@ -140,14 +140,14 @@
/**
- * init_model_number_combo:
+ * gp_init_model_number_combo:
*
* Set up the the model for a model_number combo with all iPod models
* known to libgpod.
*
* @cb: the combobox that should be set up with a model.
*/
-void init_model_number_combo (GtkComboBox *cb)
+void gp_init_model_number_combo (GtkComboBox *cb)
{
const IpodInfo *table;
Itdb_IpodGeneration generation;
@@ -219,8 +219,16 @@
}
-
-gboolean ipod_init (iTunesDB *itdb)
+/**
+ * gp_ipod_init:
+ *
+ * Ask for the iPod model and mountpoint and then create the directory
+ * structure on the iPod.
+ *
+ * @itdb: itdb from where to extract the mountpoint. After
+ * initialisation the model number is set.
+ */
+gboolean gp_ipod_init (iTunesDB *itdb)
{
IpodInit *ii;
gint response;
@@ -257,7 +265,7 @@
/* Setup model number combo */
cb = GTK_COMBO_BOX (GET_WIDGET (MODEL_COMBO));
- init_model_number_combo (cb);
+ gp_init_model_number_combo (cb);
/* If available set current model number, otherwise indicate that
none is available */
@@ -316,7 +324,8 @@
GTK_COMBO_BOX (GET_WIDGET (MODEL_COMBO)));
if (strcmp (model, gettext(SELECT_OR_ENTER_YOUR_MODEL)) == 0)
{ /* User didn't choose a model */
- model[0] = 0;
+ g_free (model);
+ model = NULL;
}
/* Set model in the prefs system */
@@ -354,3 +363,84 @@
return result;
}
+
+
+/* Redefine shortcut to reference widgets.*/
+#undef GET_WIDGET
+#define GET_WIDGET(a) gtkpod_xml_get_widget (xml,a)
+
+
+/**
+ * gp_ipod_init_set_model:
+ *
+ * Ask for the iPod model, pre-select @old_model, set the selected
+ * model in the preferences.
+ *
+ * @itdb: the itdb to set
+ * @old_model: the model number string to initially propose.
+ */
+void gp_ipod_init_set_model (iTunesDB *itdb, const gchar *old_model)
+{
+ GladeXML *xml;
+ GtkWidget *window;
+ gint response;
+ gchar *model;
+ GtkEntry *entry;
+ gchar buf[PATH_MAX];
+ GtkComboBox *cb;
+ const IpodInfo *info;
+
+ g_return_if_fail (itdb);
+
+ /* Create window */
+ xml = glade_xml_new (xml_file, "set_ipod_model_dialog", NULL);
+ window = GET_WIDGET ("set_ipod_model_dialog");
+ g_return_if_fail (window);
+
+ /* Setup model number combo */
+ cb = GTK_COMBO_BOX (GET_WIDGET (MODEL_COMBO));
+ gp_init_model_number_combo (cb);
+
+ /* If available set current model number, otherwise indicate that
+ none is available */
+ info = itdb_device_get_ipod_info (itdb->device);
+ if (info && (info->ipod_generation != ITDB_IPOD_GENERATION_UNKNOWN))
+ {
+ g_snprintf (buf, PATH_MAX, "x%s", info->model_number);
+ }
+ else
+ {
+ g_snprintf (buf, PATH_MAX, "%s", gettext (SELECT_OR_ENTER_YOUR_MODEL));
+ }
+ entry = GTK_ENTRY (gtk_bin_get_child(GTK_BIN (cb)));
+ gtk_entry_set_text (entry, buf);
+
+
+ response = gtk_dialog_run (GTK_DIALOG (window));
+
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ model = gtk_combo_box_get_active_text (
+ GTK_COMBO_BOX (GET_WIDGET (MODEL_COMBO)));
+ if (strcmp (model, gettext(SELECT_OR_ENTER_YOUR_MODEL)) == 0)
+ { /* User didn't choose a model */
+ g_free (model);
+ model = NULL;
+ }
+ if (model)
+ {
+ /* Set model in the prefs system */
+ set_itdb_prefs_string (itdb, KEY_IPOD_MODEL, model);
+ /* Set the model on the iPod */
+ itdb_device_set_sysinfo (itdb->device, "ModelNumStr", model);
+ g_free (model);
+ }
+ break;
+ default:
+ /* canceled -- do nothing */
+ break;
+ }
+
+ gtk_widget_destroy (window);
+}
Index: ipod_init.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/ipod_init.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ipod_init.h 8 Jun 2006 15:40:16 -0000 1.2
+++ ipod_init.h 10 Jun 2006 10:38:59 -0000 1.3
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-09 00:31:54 jcs>
+/* Time-stamp: <2006-06-10 18:20:18 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -40,6 +40,7 @@
extern const gchar *SELECT_OR_ENTER_YOUR_MODEL;
-gboolean ipod_init (iTunesDB *itdb);
-void init_model_number_combo (GtkComboBox *cb);
+gboolean gp_ipod_init (iTunesDB *itdb);
+void gp_init_model_number_combo (GtkComboBox *cb);
+void gp_ipod_init_set_model (iTunesDB *itdb, const gchar *old_model);
#endif
Index: repository.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/repository.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- repository.c 8 Jun 2006 15:40:16 -0000 1.12
+++ repository.c 10 Jun 2006 10:38:59 -0000 1.13
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-09 00:36:22 jcs>
+/* Time-stamp: <2006-06-10 15:39:52 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -1930,7 +1930,7 @@
/* Setup model number combo */
cb = GTK_COMBO_BOX (GET_WIDGET (IPOD_MODEL_COMBO));
- init_model_number_combo (cb);
+ gp_init_model_number_combo (cb);
/* Window control */
g_signal_connect (GET_WIDGET ("apply_button"), "clicked",
@@ -2480,7 +2480,7 @@
/* Setup model number combo */
cb = GTK_COMBO_BOX (GET_WIDGET (IPOD_MODEL_COMBO));
- init_model_number_combo (cb);
+ gp_init_model_number_combo (cb);
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET (IPOD_MODEL_ENTRY)),
gettext (SELECT_OR_ENTER_YOUR_MODEL));
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2