Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv12308/src
Modified Files:
file_convert.c file_convert.h main.c misc.c misc.h
misc_confirm.c
Log Message:
* src/main.c
src/misc.c
src/misc.h
src/misc_confirm.c: moved gtkpod_main_quit() from
misc_confirm.c to misc.c and renamed to
gtkpod_shutdown(). Added ok_to_close_gtkpod().
Moved initialization from main.c to misc.c in gtkpod_init().
* src/file_convert.c
src/file_convert.h: added header information.
Index: file_convert.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_convert.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- file_convert.c 6 Feb 2007 14:42:48 -0000 1.4
+++ file_convert.c 9 Apr 2007 13:33:50 -0000 1.5
@@ -1,3 +1,34 @@
+/*
+| File conversion started by Simon Naunton <snaunton gmail.com> in 2007
+|
+| Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users.sourceforge.net>
+| Part of the gtkpod project.
+|
+| URL: http://gtkpod.sourceforge.net/
+| URL: http://www.gtkpod.org
+|
+| This program is free software; you can redistribute it and/or modify
+| it under the terms of the GNU General Public License as published by
+| the Free Software Foundation; either version 2 of the License, or
+| (at your option) any later version.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; if not, write to the Free Software
+| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+| $Id$
+*/
+
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -604,3 +635,56 @@
return argv;
}
#endif
+
+
+
+/* ----------------------------------------------------------------
+ *
+ * Functions for threaded background conversion
+ *
+ * ---------------------------------------------------------------- */
+
+typedef struct _Conversion Conversion;
+
+struct _Conversion
+{
+ GList *scheduled;
+ GList *finished;
+ GMutex *mutex;
+};
+
+static Conversion *conversion;
+
+
+/* Set up conversion infrastructure. Must only be called once. */
+void conversion_init ()
+{
+ g_return_if_fail (conversion==NULL);
+
+ conversion = g_new0 (Conversion, 1);
+ conversion->mutex = g_mutex_new ();
+}
+
+
+/* Shut down conversion infrastructure */
+void conversion_shutdown ()
+{
+ g_return_if_fail (conversion);
+
+ /* nothing to do so far */
+}
+
+#if 0
+static void conversion_lock ()
+{
+ g_return_if_fail (conversion);
+ g_mutex_lock (conversion->mutex);
+}
+
+
+static void conversion_unlock ()
+{
+ g_return_if_fail (conversion);
+ g_mutex_unlock (conversion->mutex);
+}
+#endif
Index: file_convert.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_convert.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- file_convert.h 5 Feb 2007 08:46:00 -0000 1.3
+++ file_convert.h 9 Apr 2007 13:33:50 -0000 1.4
@@ -1,3 +1,34 @@
+/*
+| File conversion started by Simon Naunton <snaunton gmail.com> in 2007
+|
+| Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users.sourceforge.net>
+| Part of the gtkpod project.
+|
+| URL: http://gtkpod.sourceforge.net/
+| URL: http://www.gtkpod.org
+|
+| This program is free software; you can redistribute it and/or modify
+| it under the terms of the GNU General Public License as published by
+| the Free Software Foundation; either version 2 of the License, or
+| (at your option) any later version.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; if not, write to the Free Software
+| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+| $Id$
+*/
+
+
#ifndef __FILE_CONVERT_H_
#define __FILE_CONVERT_H_
@@ -30,4 +61,7 @@
/* extern gchar **cmdline_to_argv(const gchar *cmdline, Track *track); */
+void conversion_init (void);
+void conversion_shutdown (void);
+
#endif
Index: main.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/main.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- main.c 9 Apr 2007 11:58:00 -0000 1.62
+++ main.c 9 Apr 2007 13:33:50 -0000 1.63
@@ -34,11 +34,7 @@
#include <time.h>
#include "display.h"
-#include "clientserver.h"
-#include "display_coverart.h"
-#include "prefs.h"
#include "misc.h"
-#include "file.h"
/* path to gtkpod.glade */
gchar *xml_file = NULL;
@@ -46,104 +42,30 @@
int
main (int argc, char *argv[])
{
- gchar *progname;
-
-
-
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
#endif
#ifdef G_THREADS_ENABLED
- /* this must be called before gtk_init () */
- g_thread_init (NULL);
- /* FIXME: this call causes gtkpod to freeze as soon as tracks should be
- displayed */
+ /* this must be called before gtk_init () */
+ g_thread_init (NULL);
+ /* FIXME: this call causes gtkpod to freeze as soon as tracks should be
+ displayed */
/* gdk_threads_init (); */
#endif
- gtk_init (&argc, &argv);
-
- srand(time(NULL));
-
- /* initialize xml_file: if gtkpod is called in the build directory
- (".../src/gtkpod") use the local gtkpod.glade (the symlink in the
- pixmaps directory), otherwise use
- "PACKAGE_DATA_DIR/PACKAGE/pixmaps/gtkpod.glade" */
-
- progname = g_find_program_in_path (argv[0]);
- if (progname)
- {
- static const gchar *SEPsrcSEPgtkpod = G_DIR_SEPARATOR_S "src"
G_DIR_SEPARATOR_S "gtkpod";
-
- if (!g_path_is_absolute (progname))
- {
- gchar *cur_dir = g_get_current_dir ();
- gchar *prog_absolute;
-
- if (g_str_has_prefix (progname, "." G_DIR_SEPARATOR_S))
- prog_absolute = g_build_filename (cur_dir,progname+2,NULL);
- else
- prog_absolute = g_build_filename (cur_dir,progname,NULL);
- g_free (progname);
- g_free (cur_dir);
- progname = prog_absolute;
- }
-
- if (g_str_has_suffix (progname, SEPsrcSEPgtkpod))
- {
- gchar *suffix = g_strrstr (progname, SEPsrcSEPgtkpod);
- if (suffix)
- {
- *suffix = 0;
- xml_file = g_build_filename (progname, "pixmaps", "gtkpod.glade",
NULL);
- }
- }
- g_free (progname);
- if (xml_file && !g_file_test (xml_file, G_FILE_TEST_EXISTS))
- {
- g_free (xml_file);
- xml_file = NULL;
- }
- }
- if (!xml_file)
- xml_file = g_build_filename (PACKAGE_DATA_DIR, PACKAGE, "pixmaps",
"gtkpod.glade", NULL);
- else
- {
- printf ("Using local gtkpod.glade file since program was started from
source directory:\n%s\n", xml_file);
- }
-
- main_window_xml = glade_xml_new (xml_file, "gtkpod", NULL);
-
- glade_xml_signal_autoconnect (main_window_xml);
-
- gtkpod_window = gtkpod_xml_get_widget (main_window_xml, "gtkpod");
-
- prefs_init (argc, argv);
-
- init_default_file (argv[0]);
-
- display_create ();
-
- gtk_widget_show (gtkpod_window);
-
- init_data (gtkpod_window); /* setup base data, importing all local
- * repositories */
-
- /* stuff to be done before starting gtkpod */
- call_script ("gtkpod.in", NULL);
+ gtk_init (&argc, &argv);
- if(prefs_get_int("autoimport") || prefs_get_int("autoimport_commandline"))
- gp_load_ipods ();
+ srand(time(NULL));
- server_setup (); /* start server to accept playcount updates */
+ gtkpod_init (argc, argv);
/* gdk_threads_enter (); */
- gtk_main ();
+ gtk_main ();
/* gdk_threads_leave (); */
- /* all the cleanup is already done in gtkpod_main_quit() in misc.c */
- return 0;
+ /* all the cleanup is already done in gtkpod_main_shutdown () in misc.c */
+ return 0;
}
Index: misc.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -d -r1.217 -r1.218
--- misc.c 26 Mar 2007 12:33:50 -0000 1.217
+++ misc.c 9 Apr 2007 13:33:50 -0000 1.218
@@ -1,5 +1,5 @@
/* -*- coding: utf-8; -*-
-| Time-stamp: <2007-03-26 21:23:31 jcs>
+| Time-stamp: <2007-04-09 22:20:05 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -40,6 +40,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include "charset.h"
+#include "clientserver.h"
#include "misc.h"
#include "prefs.h"
#include "misc_track.h"
@@ -1616,3 +1617,132 @@
};
return gui;
}
+
+/* ----------------------------------------------------------------
+ *
+ * Main program init and shutdown
+ *
+ * ---------------------------------------------------------------- */
+
+/**
+ * gtkpod_init
+ *
+ * initialize prefs and other services as well as display
+ */
+void gtkpod_init (int argc, char *argv[])
+{
+ gchar *progname;
+
+ /* initialize xml_file: if gtkpod is called in the build directory
+ (".../src/gtkpod") use the local gtkpod.glade (the symlink in the
+ pixmaps directory), otherwise use
+ "PACKAGE_DATA_DIR/PACKAGE/pixmaps/gtkpod.glade" */
+
+ progname = g_find_program_in_path (argv[0]);
+ if (progname)
+ {
+ static const gchar *SEPsrcSEPgtkpod = G_DIR_SEPARATOR_S "src"
G_DIR_SEPARATOR_S "gtkpod";
+
+ if (!g_path_is_absolute (progname))
+ {
+ gchar *cur_dir = g_get_current_dir ();
+ gchar *prog_absolute;
+
+ if (g_str_has_prefix (progname, "." G_DIR_SEPARATOR_S))
+ prog_absolute = g_build_filename (cur_dir,progname+2,NULL);
+ else
+ prog_absolute = g_build_filename (cur_dir,progname,NULL);
+ g_free (progname);
+ g_free (cur_dir);
+ progname = prog_absolute;
+ }
+
+ if (g_str_has_suffix (progname, SEPsrcSEPgtkpod))
+ {
+ gchar *suffix = g_strrstr (progname, SEPsrcSEPgtkpod);
+ if (suffix)
+ {
+ *suffix = 0;
+ xml_file = g_build_filename (progname, "pixmaps",
"gtkpod.glade", NULL);
+ }
+ }
+ g_free (progname);
+ if (xml_file && !g_file_test (xml_file, G_FILE_TEST_EXISTS))
+ {
+ g_free (xml_file);
+ xml_file = NULL;
+ }
+ }
+ if (!xml_file)
+ xml_file = g_build_filename (PACKAGE_DATA_DIR, PACKAGE, "pixmaps",
"gtkpod.glade", NULL);
+ else
+ {
+ printf ("Using local gtkpod.glade file since program was started from
source directory:\n%s\n", xml_file);
+ }
+
+ main_window_xml = glade_xml_new (xml_file, "gtkpod", NULL);
+
+ glade_xml_signal_autoconnect (main_window_xml);
+
+ gtkpod_window = gtkpod_xml_get_widget (main_window_xml, "gtkpod");
+
+ prefs_init (argc, argv);
+
+ init_default_file (argv[0]);
+
+ conversion_init ();
+
+ display_create ();
+
+ gtk_widget_show (gtkpod_window);
+
+ init_data (gtkpod_window); /* setup base data, importing all local
+ * repositories */
+
+ /* stuff to be done before starting gtkpod */
+ call_script ("gtkpod.in", NULL);
+
+ if(prefs_get_int("autoimport") || prefs_get_int("autoimport_commandline"))
+ gp_load_ipods ();
+
+ server_setup (); /* start server to accept playcount updates */
+}
+
+
+
+/**
+ * gtkpod_shutdown
+ *
+ * free memory, shutdown services and call gtk_main_quit ()
+ */
+void gtkpod_shutdown ()
+{
+ /* stop accepting requests for playcount updates */
+ server_shutdown ();
+
+ /* Sort column order needs to be stored */
+ tm_store_col_order();
+
+ /* Update default sizes */
+ display_update_default_sizes();
+
+ /* shut down conversion infrastructure */
+ conversion_shutdown ();
+
+ /* Save prefs */
+ prefs_save ();
+
+/* FIXME: release memory in a clean way */
+#if 0
+ remove_all_playlists (); /* first remove playlists, then tracks!
+ * (otherwise non-existing *tracks may
+ * be accessed) */
+ remove_all_tracks ();
+#endif
+ display_cleanup ();
+
+ prefs_shutdown ();
+
+ call_script ("gtkpod.out", NULL);
+ gtk_main_quit ();
+}
Index: misc.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.h,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- misc.h 18 Mar 2007 14:27:19 -0000 1.122
+++ misc.h 9 Apr 2007 13:33:50 -0000 1.123
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-03-18 21:34:23 jcs>
+/* Time-stamp: <2007-04-09 22:13:55 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -105,10 +105,11 @@
gint get_sort_tab_number (gchar *text);
void open_about_window (void);
void close_about_window (void);
-gboolean parse_tracks_from_string(gchar **s, Track **track);
-gboolean gtkpod_main_quit(void);
+gboolean parse_tracks_from_string (gchar **s, Track **track);
+void gtkpod_init (int argc, char *argv[]);
+void gtkpod_shutdown (void);
-gchar *get_allowed_percent_char(void);
+gchar *get_allowed_percent_char (void);
T_item TM_to_T (TM_item sm);
T_item char_to_T (char c);
T_item ST_to_T (ST_CAT_item st);
Index: misc_confirm.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc_confirm.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- misc_confirm.c 9 Apr 2007 11:58:01 -0000 1.49
+++ misc_confirm.c 9 Apr 2007 13:33:50 -0000 1.50
@@ -33,7 +33,6 @@
#include <gtk/gtk.h>
#include <string.h>
#include <sys/stat.h>
-#include "clientserver.h"
#include "confirmation.h"
#include "misc.h"
#include "prefs.h"
@@ -825,35 +824,13 @@
-/* callback for quit menu entry */
-void
-on_quit1_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- if (!widgets_blocked) gtkpod_main_quit ();
-}
-
-
-/* callback for gtkpod window's close button */
-gboolean
-on_gtkpod_delete_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- if (!widgets_blocked)
- {
- return gtkpod_main_quit ();
- }
- return TRUE; /* don't quit -- would cause numerous error messages */
-}
-
/**
- * gtkpod_main_quit
+ * gtkpod_shutdown
*
- * return value: FALSE if it's OK to quit.
+ * return value: TRUE if it's OK to quit.
*/
-gboolean
-gtkpod_main_quit(void)
+static gboolean
+ok_to_close_gtkpod (void)
{
gint result = GTK_RESPONSE_YES;
@@ -871,30 +848,40 @@
if (result == GTK_RESPONSE_YES)
{
- server_shutdown (); /* stop accepting requests for playcount updates */
+ return TRUE;
+ }
+ return FALSE;
+}
- /* Sort column order needs to be stored */
- tm_store_col_order();
-
- /* Update default sizes */
- display_update_default_sizes();
- prefs_save ();
-
-/* FIXME: release memory in a clean way */
-#if 0
- remove_all_playlists (); /* first remove playlists, then
- * tracks! (otherwise non-existing
- *tracks may be accessed) */
- remove_all_tracks ();
-#endif
- display_cleanup ();
+/* callback for gtkpod window's close button */
+gboolean
+on_gtkpod_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ if (!widgets_blocked)
+ {
+ if (ok_to_close_gtkpod ())
+ {
+ gtkpod_shutdown ();
+ return FALSE;
+ }
+ }
+ return TRUE; /* don't quit -- would cause numerous error messages */
+}
- prefs_shutdown ();
- call_script ("gtkpod.out", NULL);
- gtk_main_quit ();
- return FALSE;
+/* callback for quit menu entry */
+void
+on_quit1_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ if (!widgets_blocked)
+ {
+ if (ok_to_close_gtkpod ())
+ {
+ gtkpod_shutdown ();
+ }
}
- return TRUE;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2