[Goodies-commits] r7888 - in parole/trunk: . parole
Ali Abdallah
aliov at xfce.org
Tue Aug 4 18:00:12 CEST 2009
Author: aliov
Date: 2009-08-04 16:00:12 +0000 (Tue, 04 Aug 2009)
New Revision: 7888
Modified:
parole/trunk/ChangeLog
parole/trunk/parole/parole-medialist.c
parole/trunk/parole/parole-medialist.h
parole/trunk/parole/parole-player.c
parole/trunk/parole/parole-rc-utils.c
parole/trunk/parole/parole-rc-utils.h
Log:
* Added option to remember the currently loaded media
files in the playlist view.
Modified: parole/trunk/ChangeLog
===================================================================
--- parole/trunk/ChangeLog 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/ChangeLog 2009-08-04 16:00:12 UTC (rev 7888)
@@ -1,3 +1,7 @@
+2009-08-04: 18:00 Ali aliov at xfce.org
+ * Added option to remember the currently loaded media
+ files in the playlist view.
+
2009-07-31: 11:30 Ali aliov at xfce.org
* Support for Recent played media files.
* Better configuration loading based GValues.
Modified: parole/trunk/parole/parole-medialist.c
===================================================================
--- parole/trunk/parole/parole-medialist.c 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/parole/parole-medialist.c 2009-08-04 16:00:12 UTC (rev 7888)
@@ -46,8 +46,11 @@
#include "parole-filters.h"
#include "parole-pl-parser.h"
#include "parole-utils.h"
+#include "parole-rc-utils.h"
#include "parole-dbus.h"
+#define PAROLE_AUTO_SAVED_PLAYLIST "xfce4/parole/auto-saved-playlist.m3u"
+
typedef struct
{
GtkWidget *chooser;
@@ -645,12 +648,40 @@
}
static void
+save_list_activated_cb (GtkWidget *mi)
+{
+ gboolean active;
+
+ active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (mi));
+
+ parole_rc_write_entry_bool ("SAVE_LIST_ON_EXIT", PAROLE_RC_GROUP_GENERAL, active);
+}
+
+static void
parole_media_list_show_menu (ParoleMediaList *list, guint button, guint activate_time)
{
GtkWidget *menu, *mi;
menu = gtk_menu_new ();
+ mi = gtk_check_menu_item_new_with_label (_("Remember playlist"));
+ gtk_widget_set_sensitive (mi, TRUE);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
+ parole_rc_read_entry_bool ("SAVE_LIST_ON_EXIT",
+ PAROLE_RC_GROUP_GENERAL,
+ FALSE));
+ g_signal_connect (mi, "activate",
+ G_CALLBACK (save_list_activated_cb), NULL);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+ gtk_widget_show (mi);
+
+ mi = gtk_separator_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+
/* Clear */
mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLEAR, NULL);
gtk_widget_set_sensitive (mi, TRUE);
@@ -798,6 +829,8 @@
{
GtkBuilder *builder;
GtkWidget *box;
+ gboolean load_saved_list;
+ GSList *fileslist = NULL;
list->priv = PAROLE_MEDIA_LIST_GET_PRIVATE (list);
@@ -822,6 +855,33 @@
gtk_widget_show_all (GTK_WIDGET (list));
parole_media_list_dbus_init (list);
+
+ load_saved_list = parole_rc_read_entry_bool ("SAVE_LIST_ON_EXIT", PAROLE_RC_GROUP_GENERAL, FALSE);
+
+ if ( load_saved_list )
+ {
+ gchar *playlist_file;
+ playlist_file = xfce_resource_save_location (XFCE_RESOURCE_DATA,
+ PAROLE_AUTO_SAVED_PLAYLIST,
+ FALSE);
+ if ( playlist_file )
+ {
+ fileslist = parole_pl_parser_load_file (playlist_file);
+ g_free (playlist_file);
+ if ( fileslist )
+ {
+ guint i, len;
+ len = g_slist_length (fileslist);
+ for ( i = 0; i < len; i++)
+ {
+ ParoleFile *file;
+ file = g_slist_nth_data (fileslist, i);
+ parole_media_list_add (list, file, FALSE);
+ }
+ g_slist_free (fileslist);
+ }
+ }
+ }
}
GtkWidget *
@@ -978,6 +1038,35 @@
parole_media_list_add_by_path (list, filenames[i], i == 0 ? TRUE : FALSE);
}
+void parole_media_list_save_list (ParoleMediaList *list)
+{
+ gboolean save;
+
+ save = parole_rc_read_entry_bool ("SAVE_LIST_ON_EXIT", PAROLE_RC_GROUP_GENERAL, FALSE);
+
+ if ( save )
+ {
+ GSList *fileslist;
+ gchar *history;
+
+ history = xfce_resource_save_location (XFCE_RESOURCE_DATA, PAROLE_AUTO_SAVED_PLAYLIST , TRUE);
+
+ if ( !history )
+ {
+ g_warning ("Failed to save playlist");
+ return;
+ }
+
+ fileslist = parole_media_list_get_files (list);
+ if ( g_slist_length (fileslist) > 0 )
+ {
+ parole_pl_parser_save_file (fileslist, history, PAROLE_PL_FORMAT_M3U);
+ g_slist_foreach (fileslist, (GFunc) g_object_unref, NULL);
+ }
+ g_slist_free (fileslist);
+ }
+}
+
static gboolean parole_media_list_dbus_add_files (ParoleMediaList *list,
gchar **in_files,
GError **error);
Modified: parole/trunk/parole/parole-medialist.h
===================================================================
--- parole/trunk/parole/parole-medialist.h 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/parole/parole-medialist.h 2009-08-04 16:00:12 UTC (rev 7888)
@@ -90,6 +90,8 @@
void parole_media_list_add_files (ParoleMediaList *list,
gchar **filenames);
+void parole_media_list_save_list (ParoleMediaList *list);
+
G_END_DECLS
#endif /* __PAROLE_MEDIA_LIST_H */
Modified: parole/trunk/parole/parole-player.c
===================================================================
--- parole/trunk/parole/parole-player.c 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/parole/parole-player.c 2009-08-04 16:00:12 UTC (rev 7888)
@@ -533,6 +533,7 @@
static void
parole_player_quit (ParolePlayer *player)
{
+ parole_media_list_save_list (player->priv->list);
gtk_widget_destroy (player->priv->window);
g_object_unref (player);
gtk_main_quit ();
Modified: parole/trunk/parole/parole-rc-utils.c
===================================================================
--- parole/trunk/parole/parole-rc-utils.c 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/parole/parole-rc-utils.c 2009-08-04 16:00:12 UTC (rev 7888)
@@ -135,14 +135,14 @@
return ret_val;
}
-gchar **parole_get_history (void)
+gchar **parole_get_history_full (const gchar *relpath)
{
gchar **lines = NULL;
gchar *history = NULL;
gchar *contents = NULL;
gsize length = 0;
- history = xfce_resource_lookup (XFCE_RESOURCE_CACHE, PAROLE_HISTORY_FILE);
+ history = xfce_resource_lookup (XFCE_RESOURCE_CACHE, relpath);
if (history && g_file_get_contents (history, &contents, &length, NULL))
{
@@ -155,11 +155,21 @@
return lines;
}
+gchar **parole_get_history (void)
+{
+ return parole_get_history_full (PAROLE_HISTORY_FILE);
+}
+
void parole_insert_line_history (const gchar *line)
{
+ parole_insert_line_history_full (PAROLE_HISTORY_FILE, line);
+}
+
+void parole_insert_line_history_full (const gchar *relpath, const gchar *line)
+{
gchar *history = NULL;
- history = xfce_resource_save_location (XFCE_RESOURCE_CACHE, PAROLE_HISTORY_FILE, TRUE);
+ history = xfce_resource_save_location (XFCE_RESOURCE_CACHE, relpath, TRUE);
if ( history )
{
@@ -167,9 +177,28 @@
f = fopen (history, "a");
fprintf (f, "%s\n", line);
fclose (f);
+ g_free (history);
}
else
g_warning ("Unable to open cache file");
-
- g_free (history);
}
+
+void parole_clear_history_file (void)
+{
+ parole_clear_history_file_full (PAROLE_HISTORY_FILE);
+}
+
+void parole_clear_history_file_full (const gchar *relpath)
+{
+ gchar *history = NULL;
+
+ history = xfce_resource_save_location (XFCE_RESOURCE_CACHE, relpath, FALSE);
+
+ if ( history )
+ {
+ FILE *f;
+ f = fopen (history, "w");
+ fclose (f);
+ g_free (history);
+ }
+}
Modified: parole/trunk/parole/parole-rc-utils.h
===================================================================
--- parole/trunk/parole/parole-rc-utils.h 2009-08-03 06:40:38 UTC (rev 7887)
+++ parole/trunk/parole/parole-rc-utils.h 2009-08-04 16:00:12 UTC (rev 7888)
@@ -65,6 +65,15 @@
gchar **parole_get_history (void);
+gchar **parole_get_history_full (const gchar *relpath);
+
void parole_insert_line_history (const gchar *line);
-
+
+void parole_insert_line_history_full (const gchar *relpath,
+ const gchar *line);
+
+void parole_clear_history_file (void);
+
+void parole_clear_history_file_full (const gchar *relpath);
+
#endif /* __RC_UTILS_ */
More information about the Goodies-commits
mailing list