Revision: 1588
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1588&view=rev
Author: jcsjcs
Date: 2007-06-24 09:02:51 -0700 (Sun, 24 Jun 2007)
Log Message:
-----------
* src/misc_input.c: removed calls to dirbrowser_block() and
dirbrowser_release() (obsolete because dirbrowser became
modal)
* src/fileselection.c
src/fileselection.h
data/gtkpod.glade: (adding of tracks, directories and
playlist files): do not allow adding of tracks if no
playlist is selected or if the iPod is not loaded into the
selected repository. Better names for file chooser
directories, dirbrowser modal, separate functions for glade
callback.
* src/file.c (copy_new_info): removed unused variables.
Modified Paths:
--------------
gtkpod/trunk/ChangeLog_detailed
gtkpod/trunk/TODOandBUGS.txt
gtkpod/trunk/data/gtkpod.glade
gtkpod/trunk/src/file.c
gtkpod/trunk/src/fileselection.c
gtkpod/trunk/src/fileselection.h
gtkpod/trunk/src/misc_input.c
Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/ChangeLog_detailed 2007-06-24 16:02:51 UTC (rev 1588)
@@ -1,3 +1,20 @@
+2007-06-24 Jorg Schuler <jcsjcs at users.sourceforge.net>
+
+ * src/misc_input.c: removed calls to dirbrowser_block() and
+ dirbrowser_release() (obsolete because dirbrowser became
+ modal)
+
+ * src/fileselection.c
+ src/fileselection.h
+ data/gtkpod.glade: (adding of tracks, directories and
+ playlist files): do not allow adding of tracks if no
+ playlist is selected or if the iPod is not loaded into the
+ selected repository. Better names for file chooser
+ directories, dirbrowser modal, separate functions for glade
+ callback.
+
+ * src/file.c (copy_new_info): removed unused variables.
+
2007-06-23 Todd Zullinger <tmzullinger at users.sourceforge.net>
* configure.in:
Modified: gtkpod/trunk/TODOandBUGS.txt
===================================================================
--- gtkpod/trunk/TODOandBUGS.txt 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/TODOandBUGS.txt 2007-06-24 16:02:51 UTC (rev 1588)
@@ -4,7 +4,8 @@
- move part of free-space-update to file_convert.c
-- make it impossible to add tracks to an iPod that's not loaded.
+- make it impossible to add tracks to an iPod that's not loaded (TODO:
+ drag and drop!)
- when creating new repository: make sure backup repository filename isn't
already used.
Modified: gtkpod/trunk/data/gtkpod.glade
===================================================================
--- gtkpod/trunk/data/gtkpod.glade 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/data/gtkpod.glade 2007-06-24 16:02:51 UTC (rev 1588)
@@ -51,7 +51,7 @@
<signal name="activate" handler="on_load_ipods_mi"
last_modification_time="Sat, 20 May 2006 14:21:46 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3926">
+ <widget class="GtkImage" id="image3992">
<property name="visible">True</property>
<property name="pixbuf">gtkpod-read.png</property>
<property name="xalign">0.5</property>
@@ -71,7 +71,7 @@
<signal name="activate" handler="on_save_changes_mi"
last_modification_time="Sat, 20 May 2006 14:22:12 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3927">
+ <widget class="GtkImage" id="image3993">
<property name="visible">True</property>
<property name="stock">gtk-save</property>
<property name="icon_size">1</property>
@@ -89,10 +89,10 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Add
_Files</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="create_add_files_dialog"
last_modification_time="Sun, 05 Jun 2005 13:03:47 GMT"/>
+ <signal name="activate"
handler="create_add_files_callback" last_modification_time="Sun, 24 Jun 2007
14:43:18 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3928">
+ <widget class="GtkImage" id="image3994">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@@ -110,10 +110,10 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Add
_Directory</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="dirbrowser_create"
last_modification_time="Sun, 05 Jun 2005 13:09:31 GMT"/>
+ <signal name="activate"
handler="dirbrowser_create_callback" last_modification_time="Sun, 24 Jun 2007
15:25:37 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3929">
+ <widget class="GtkImage" id="image3995">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@@ -131,10 +131,10 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Add
_Playlist</property>
<property name="use_underline">True</property>
- <signal name="activate"
handler="create_add_playlists_dialog" last_modification_time="Sun, 05 Jun 2005
13:14:57 GMT"/>
+ <signal name="activate"
handler="create_add_playlists_callback" last_modification_time="Sun, 24 Jun
2007 15:42:46 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3930">
+ <widget class="GtkImage" id="image3996">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@@ -160,7 +160,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3931">
+ <widget class="GtkImage" id="image3997">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@@ -212,7 +212,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3932">
+ <widget class="GtkImage" id="image3998">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@@ -265,7 +265,7 @@
<signal name="activate"
handler="on_sync_playlist_activate" last_modification_time="Mon, 15 May 2006
15:39:05 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3933">
+ <widget class="GtkImage" id="image3999">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@@ -291,7 +291,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3934">
+ <widget class="GtkImage" id="image4000">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
<property name="icon_size">1</property>
@@ -343,7 +343,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3935">
+ <widget class="GtkImage" id="image4001">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
<property name="icon_size">1</property>
@@ -402,7 +402,7 @@
<signal name="activate"
handler="on_ipod_directories_menu" last_modification_time="Sat, 18 Jan 2003
02:10:39 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3936">
+ <widget class="GtkImage" id="image4002">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">1</property>
@@ -460,7 +460,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3937">
+ <widget class="GtkImage" id="image4003">
<property name="visible">True</property>
<property name="stock">gtk-edit</property>
<property name="icon_size">1</property>
@@ -521,7 +521,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3938">
+ <widget class="GtkImage" id="image4004">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">1</property>
@@ -672,7 +672,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3939">
+ <widget class="GtkImage" id="image4005">
<property name="visible">True</property>
<property name="stock">gtk-copy</property>
<property name="icon_size">1</property>
@@ -864,7 +864,7 @@
<accelerator key="s" modifiers="GDK_CONTROL_MASK"
signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3940">
+ <widget class="GtkImage" id="image4006">
<property name="visible">True</property>
<property name="stock">gtk-sort-ascending</property>
<property name="icon_size">1</property>
@@ -895,7 +895,7 @@
<accelerator key="s" modifiers="GDK_CONTROL_MASK |
GDK_SHIFT_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3941">
+ <widget class="GtkImage" id="image4007">
<property name="visible">True</property>
<property name="stock">gtk-justify-fill</property>
<property name="icon_size">1</property>
@@ -922,7 +922,7 @@
<signal name="activate"
handler="on_edit_repository_options_activate" last_modification_time="Sun, 21
May 2006 03:40:14 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3942">
+ <widget class="GtkImage" id="image4008">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@@ -944,7 +944,7 @@
<accelerator key="p" modifiers="GDK_CONTROL_MASK"
signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3943">
+ <widget class="GtkImage" id="image4009">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@@ -1019,7 +1019,7 @@
<signal name="activate"
handler="on_more_sort_tabs_activate" last_modification_time="Fri, 14 Mar 2003
11:57:43 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3944">
+ <widget class="GtkImage" id="image4010">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@@ -1040,7 +1040,7 @@
<signal name="activate"
handler="on_less_sort_tabs_activate" last_modification_time="Fri, 14 Mar 2003
11:57:43 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3945">
+ <widget class="GtkImage" id="image4011">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
@@ -1082,7 +1082,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3946">
+ <widget class="GtkImage" id="image4012">
<property name="visible">True</property>
<property name="stock">gtk-cdrom</property>
<property name="icon_size">1</property>
@@ -1134,7 +1134,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image3947">
+ <widget class="GtkImage" id="image4013">
<property name="visible">True</property>
<property name="stock">gtk-cdrom</property>
<property name="icon_size">1</property>
@@ -1316,7 +1316,7 @@
<signal name="activate" handler="open_about_window"
last_modification_time="Sun, 05 Jun 2005 13:09:31 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image3948">
+ <widget class="GtkImage" id="image4014">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">1</property>
@@ -1394,7 +1394,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
- <signal name="clicked" handler="create_add_files_dialog"
last_modification_time="Sun, 05 Jun 2005 13:09:54 GMT"/>
+ <signal name="clicked" handler="create_add_files_callback"
last_modification_time="Sun, 24 Jun 2007 14:43:28 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -1412,7 +1412,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
- <signal name="clicked" handler="dirbrowser_create"
last_modification_time="Sun, 05 Jun 2005 13:10:20 GMT"/>
+ <signal name="clicked" handler="dirbrowser_create_callback"
last_modification_time="Sun, 24 Jun 2007 15:25:22 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -1430,7 +1430,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
- <signal name="clicked" handler="create_add_playlists_dialog"
last_modification_time="Sun, 05 Jun 2005 13:13:11 GMT"/>
+ <signal name="clicked" handler="create_add_playlists_callback"
last_modification_time="Sun, 24 Jun 2007 15:42:57 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
Modified: gtkpod/trunk/src/file.c
===================================================================
--- gtkpod/trunk/src/file.c 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/src/file.c 2007-06-24 16:02:51 UTC (rev 1588)
@@ -791,10 +791,8 @@
g_return_if_fail (efrom);
g_return_if_fail (eto);
-
for (item=0; item<T_ITEM_NUM; ++item)
{
- gchar **fromcp, **tocp;
switch (item)
{
case T_ALBUM:
Modified: gtkpod/trunk/src/fileselection.c
===================================================================
--- gtkpod/trunk/src/fileselection.c 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/src/fileselection.c 2007-06-24 16:02:51 UTC (rev 1588)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-23 23:59:03 jcs>
+/* Time-stamp: <2007-06-25 00:56:37 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users.sourceforge.net>
| Part of the gtkpod project.
@@ -59,61 +59,62 @@
* Data global to this module only
*/
-static iTunesDB *fc_active_itdb = NULL; /* the active iTunesDB, if any */
+static Playlist *db_active_pl = NULL; /* playlist for dirbrowser */
-/* Cleans up the GSList of filenames returned by the file chooser */
-static void delete_file_list(GSList* list)
+static void error_dialog (const gchar *str)
{
- GSList* current; /* Current node in list */
-
- /* Delete the string contained in each node */
- current = list;
-
- while (current != NULL)
- {
- g_free(current->data);
- current = current->next;
- }
-
- g_slist_free(list);
+ GtkWidget *dialog;
+
+ g_return_if_fail (str);
+
+ 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);
}
+
/* OK button */
-static void add_files_ok(GtkFileChooser* filechooser)
+static void add_files_ok(GtkFileChooser* filechooser, Playlist *playlist)
{
GSList* names; /* List of selected names */
- GSList* current; /* Current node in list */
- Playlist* playlist; /* Playlist to add songs to */
+ GSList* gsl; /* Current node in list */
gboolean result = TRUE; /* Result of file adding */
/* If we don't have a playlist to add to, don't add anything */
- g_return_if_fail(fc_active_itdb);
+ g_return_if_fail (playlist);
block_widgets ();
- playlist = pm_get_selected_playlist();
+ names = gtk_file_chooser_get_filenames (filechooser);
- names = gtk_file_chooser_get_filenames(filechooser);
- current = names;
-
- if (current)
+ if (names)
{
gchar *dirname = gtk_file_chooser_get_current_folder (filechooser);
prefs_set_string ("last_dir_browsed", dirname);
g_free (dirname);
}
+ block_widgets ();
+
/* Get the filenames and add them */
- while (current != NULL)
+ for (gsl=names; gsl; gsl=gsl->next)
{
- result &= add_track_by_filename(fc_active_itdb,
- (gchar*)current->data,
+ result &= add_track_by_filename(playlist->itdb,
+ gsl->data,
playlist,
- prefs_get_int("add_recursively"),
+ prefs_get_int ("add_recursively"),
NULL, NULL);
- current = current->next;
+ g_free (gsl->data);
}
-
+ g_slist_free (names);
+ names = NULL;
+
+ release_widgets ();
+
/* clear log of non-updated tracks */
display_non_updated ((void *)-1, NULL);
@@ -129,11 +130,7 @@
else
gtkpod_statusbar_message (_("Some files were not added successfully"));
- /* Clean up the names list */
- delete_file_list(names);
release_widgets ();
-
-
}
/*
@@ -142,22 +139,57 @@
/* ATTENTION: directly used as callback in gtkpod.glade -- if you
change the arguments of this function make sure you define a
separate callback for gtkpod.glade */
-void create_add_files_dialog (void)
+void create_add_files_callback (void)
{
+ Playlist *pl;
+
+ pl = pm_get_selected_playlist ();
+
+ create_add_files_dialog (pl);
+}
+
+
+/* Open a modal file selection dialog for adding individual files */
+void create_add_files_dialog (Playlist *pl)
+{
GtkWidget* fc; /* The file chooser dialog */
gint response; /* The response of the filechooser */
- gchar *last_dir;
-
- /* Grab the current playlist to add songs to */
- fc_active_itdb = gp_get_selected_itdb ();
- if (!fc_active_itdb)
+ gchar *last_dir, *str;
+ iTunesDB *itdb;
+ ExtraiTunesDBData *eitdb;
+ Playlist *mpl;
+
+ if (!pl)
{
- message_sb_no_itdb_selected ();
+ error_dialog (_("Please select a playlist or repository before adding
tracks."));
return;
}
-
- /* Create the file chooser, and handle the response */
- fc = gtk_file_chooser_dialog_new (_("Add Files"),
+
+ itdb = pl->itdb;
+ g_return_if_fail (itdb);
+ eitdb = itdb->userdata;
+ g_return_if_fail (eitdb);
+
+ if (!eitdb->itdb_imported)
+ {
+ error_dialog (_("Please load the iPod before adding tracks."));
+ return;
+ }
+
+ mpl = itdb_playlist_mpl (itdb);
+ g_return_if_fail (mpl);
+
+ /* Create window title */
+ if (mpl == pl)
+ {
+ str = g_strdup_printf (_("Add files to '%s'"), mpl->name);
+ }
+ else
+ {
+ str = g_strdup_printf (_("Add files to '%s/%s'"), mpl->name, pl->name);
+ }
+ /* Create the file chooser */
+ fc = gtk_file_chooser_dialog_new (str,
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
@@ -165,8 +197,12 @@
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
+ g_free (str);
+ /* allow multiple selection of files */
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (fc), TRUE);
+
+ /* set same directory as last time */
last_dir = prefs_get_string ("last_dir_browsed");
if (last_dir)
{
@@ -175,57 +211,67 @@
g_free (last_dir);
}
- response = gtk_dialog_run(GTK_DIALOG(fc));
-
+ /* Run the dialog */
+ response = gtk_dialog_run (GTK_DIALOG(fc));
+
+ /* Handle the response */
switch (response)
{
case GTK_RESPONSE_ACCEPT:
- add_files_ok(GTK_FILE_CHOOSER(fc));
+ add_files_ok (GTK_FILE_CHOOSER (fc), pl);
break;
case GTK_RESPONSE_CANCEL:
break;
default: /* Fall through */
break;
- }
- gtk_widget_destroy(fc);
+ }
+ gtk_widget_destroy (fc);
}
/* OK Button */
-static void add_playlists_ok(GtkFileChooser* filechooser)
+static void add_playlists_ok (GtkFileChooser* filechooser, iTunesDB *itdb)
{
GSList* names; /* List of selected names */
- GSList* current; /* Current node in names list */
+ GSList* gsl;
/* Get the names of the playlist(s) and add them */
- /* If we don't have a playlist to add to, return */
- g_return_if_fail(fc_active_itdb);
+ g_return_if_fail (itdb);
- block_widgets ();
-
names = gtk_file_chooser_get_filenames(filechooser);
- current = names;
- if (current)
+ if (names)
{
gchar *dirname = gtk_file_chooser_get_current_folder (filechooser);
prefs_set_string ("last_dir_browsed", dirname);
g_free (dirname);
}
- while (current != NULL)
+ block_widgets ();
+
+ for (gsl=names; gsl; gsl=gsl->next)
{
- add_playlist_by_filename (fc_active_itdb,
- (gchar*)current->data, NULL,
+ add_playlist_by_filename (itdb,
+ gsl->data, NULL,
-1, NULL, NULL);
- current = current->next;
+ g_free (gsl->data);
}
-
- gtkpod_tracks_statusbar_update();
- delete_file_list(names);
+ g_slist_free (names);
+ names = NULL;
release_widgets ();
+
+ /* clear log of non-updated tracks */
+ display_non_updated ((void *)-1, NULL);
+
+ /* display log of updated tracks */
+ display_updated (NULL, NULL);
+
+ /* display log of detected duplicates */
+ gp_duplicate_remove (NULL, NULL);
+
+ gtkpod_tracks_statusbar_update();
}
@@ -235,22 +281,48 @@
/* ATTENTION: directly used as callback in gtkpod.glade -- if you
change the arguments of this function make sure you define a
separate callback for gtkpod.glade */
-void create_add_playlists_dialog(void)
+void create_add_playlists_callback (void)
{
+ iTunesDB *itdb;
+
+ itdb = gp_get_selected_itdb ();
+
+ create_add_playlists_dialog (itdb);
+}
+
+
+/* Open a modal file selection dialog for adding playlist files */
+void create_add_playlists_dialog (iTunesDB *itdb)
+{
GtkWidget* fc ; /* The file chooser dialog */
gint response; /* The response of the filechooser */
- gchar *last_dir;
-
- /* Grab the current playlist to add songs to */
- fc_active_itdb = gp_get_selected_itdb ();
- if (!fc_active_itdb)
+ gchar *last_dir, *str;
+ ExtraiTunesDBData *eitdb;
+ Playlist *mpl;
+
+ if (!itdb)
{
- message_sb_no_itdb_selected ();
+ error_dialog (_("Please select a playlist or repository before adding
tracks."));
return;
}
-
- /* Create the file chooser, and handle the response */
- fc = gtk_file_chooser_dialog_new (_("Add Playlists"),
+
+ eitdb = itdb->userdata;
+ g_return_if_fail (eitdb);
+
+ if (!eitdb->itdb_imported)
+ {
+ error_dialog (_("Please load the iPod before adding tracks."));
+ return;
+ }
+
+ mpl = itdb_playlist_mpl (itdb);
+ g_return_if_fail (mpl);
+
+ /* Create window title */
+ str = g_strdup_printf (_("Add playlist files to '%s'"), mpl->name);
+
+ /* Create the file chooser */
+ fc = gtk_file_chooser_dialog_new (str,
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
@@ -258,8 +330,12 @@
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
+ g_free (str);
+ /* allow multiple selection of files */
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (fc), TRUE);
+
+ /* set same directory as last time */
last_dir = prefs_get_string ("last_dir_browsed");
if (last_dir)
{
@@ -268,12 +344,14 @@
g_free (last_dir);
}
- response = gtk_dialog_run(GTK_DIALOG(fc));
+ /* Run the dialog */
+ response = gtk_dialog_run (GTK_DIALOG(fc));
+ /* Handle the response */
switch (response)
{
case GTK_RESPONSE_ACCEPT:
- add_playlists_ok(GTK_FILE_CHOOSER(fc));
+ add_playlists_ok(GTK_FILE_CHOOSER (fc), itdb);
break;
case GTK_RESPONSE_CANCEL:
break;
@@ -639,11 +717,12 @@
static GdkPixmap *db_folder_pixmap = NULL, *db_ofolder_pixmap;
static GdkBitmap *db_folder_mask, *db_ofolder_mask;
static GtkWidget *dirbrowser = NULL;
-static iTunesDB *db_active_itdb = NULL;
+static GtkWidget *xmms_create_dir_browser(const gchar *title,
+ const gchar *current_path,
+ GtkSelectionMode mode,
+ void (*handler) (gchar *));
-static GtkWidget *xmms_create_dir_browser(const gchar * title, const gchar *
current_path, GtkSelectionMode mode, void (*handler) (gchar *));
-
struct dirnode
{
unsigned int scanned : 1;
@@ -656,33 +735,18 @@
* functions added for gtkpod *
* ------------------------------------------------------------ */
-/* turn the dirbrowser insensitive (if it's open) */
-void dirbrowser_block (void)
-{
- if (dirbrowser)
- gtk_widget_set_sensitive (dirbrowser, FALSE);
-}
-
-/* turn the dirbrowser sensitive (if it's open) */
-void dirbrowser_release (void)
-{
- if (dirbrowser)
- gtk_widget_set_sensitive (dirbrowser, TRUE);
-}
-
/* Callback after one directory has been added */
static void add_dir_selected (gchar *dir)
{
- g_return_if_fail (db_active_itdb);
+ g_return_if_fail (db_active_pl);
if (dir)
{
- Playlist *plitem = pm_get_selected_playlist ();
- add_directory_by_name (db_active_itdb, dir, plitem,
- prefs_get_int("add_recursively"),
+ add_directory_by_name (db_active_pl->itdb, dir, db_active_pl,
+ prefs_get_int ("add_recursively"),
NULL, NULL);
prefs_set_string ("last_dir_browsed", dir);
- gtkpod_tracks_statusbar_update();
+ gtkpod_tracks_statusbar_update ();
}
else
{
@@ -699,30 +763,71 @@
/* ATTENTION: directly used as callback in gtkpod.glade -- if you
change the arguments of this function make sure you define a
separate callback for gtkpod.glade */
-void dirbrowser_create (void)
+void dirbrowser_create_callback (void)
{
- gchar *cur_dir;
+ Playlist *pl;
- if (dirbrowser)
- { /* file selector already open -- raise to the top */
- gdk_window_raise (dirbrowser->window);
+ pl = pm_get_selected_playlist ();
+
+ dirbrowser_create (pl);
+}
+
+
+
+
+
+void dirbrowser_create (Playlist *pl)
+{
+ gchar *cur_dir, *str;
+ iTunesDB *itdb;
+ ExtraiTunesDBData *eitdb;
+ Playlist *mpl;
+
+ /* we only allow one modal dirbrowser */
+ g_return_if_fail (dirbrowser==NULL);
+
+
+ if (!pl)
+ {
+ error_dialog (_("Please select a playlist or repository before adding
tracks."));
return;
}
- db_active_itdb = gp_get_selected_itdb ();
- if (!db_active_itdb)
+ itdb = pl->itdb;
+ g_return_if_fail (itdb);
+ eitdb = itdb->userdata;
+ g_return_if_fail (eitdb);
+
+ if (!eitdb->itdb_imported)
{
- message_sb_no_itdb_selected ();
+ error_dialog (_("Please load the iPod before adding tracks."));
return;
}
+ /* FIXME: I don't like global variables */
+ db_active_pl = pl;
+
+ mpl = itdb_playlist_mpl (itdb);
+ g_return_if_fail (mpl);
+
+ /* Create window title */
+ if (mpl == pl)
+ {
+ str = g_strdup_printf (_("Add directories to '%s'"), mpl->name);
+ }
+ else
+ {
+ str = g_strdup_printf (_("Add directories to '%s/%s'"), mpl->name,
pl->name);
+ }
+
cur_dir = prefs_get_string ("last_dir_browsed");
- dirbrowser = xmms_create_dir_browser (
- _("Select directory to add recursively"),
- cur_dir,
- GTK_SELECTION_MULTIPLE,
- add_dir_selected);
+ dirbrowser = xmms_create_dir_browser (str,
+ cur_dir,
+ GTK_SELECTION_MULTIPLE,
+ add_dir_selected);
g_free (cur_dir);
+ g_free (str);
+ gtk_window_set_modal (GTK_WINDOW (dirbrowser), TRUE);
gtk_widget_show (dirbrowser);
}
Modified: gtkpod/trunk/src/fileselection.h
===================================================================
--- gtkpod/trunk/src/fileselection.h 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/src/fileselection.h 2007-06-24 16:02:51 UTC (rev 1588)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-05-22 23:18:47 jcs>
+/* Time-stamp: <2007-06-25 00:53:20 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -41,8 +41,8 @@
#include "prefs.h"
-void create_add_files_dialog(void);
-void create_add_playlists_dialog(void);
+void create_add_files_dialog (Playlist *pl);
+void create_add_playlists_dialog (iTunesDB *itdb);
gchar *fileselection_get_cover_filename(void);
gchar *fileselection_get_file_or_dir (const gchar *title,
const gchar *cur_file,
@@ -53,7 +53,5 @@
const gchar *additional_text);
/* dirbrowser */
-void dirbrowser_block (void);
-void dirbrowser_release (void);
-void dirbrowser_create (void);
+void dirbrowser_create (Playlist *pl);
#endif
Modified: gtkpod/trunk/src/misc_input.c
===================================================================
--- gtkpod/trunk/src/misc_input.c 2007-06-23 11:40:53 UTC (rev 1587)
+++ gtkpod/trunk/src/misc_input.c 2007-06-24 16:02:51 UTC (rev 1588)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-05-10 00:39:18 jcs>
+/* Time-stamp: <2007-06-25 00:53:20 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -316,7 +316,6 @@
}
sort_window_block ();
prefs_window_block ();
- dirbrowser_block ();
widgets_blocked = TRUE;
}
break;
@@ -334,7 +333,6 @@
}
sort_window_release ();
prefs_window_release ();
- dirbrowser_release ();
widgets_blocked = FALSE;
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2