r3263 - in trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2: . src
abraxa at sita.openmoko.org
abraxa at sita.openmoko.org
Thu Oct 25 03:09:19 CEST 2007
Author: abraxa
Date: 2007-10-25 03:09:17 +0200 (Thu, 25 Oct 2007)
New Revision: 3263
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/openmoko-mediaplayer.schemas
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
Log:
Fix GConf schemas file
Add GConf support, part II
Correct some indenting where tabs were wrongfully used
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/openmoko-mediaplayer.schemas
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/openmoko-mediaplayer.schemas 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/openmoko-mediaplayer.schemas 2007-10-25 01:09:17 UTC (rev 3263)
@@ -8,8 +8,8 @@
<type>bool</type>
<default>FALSE</default>
<locale name="C">
- <short>Shuffle on/off</short>
- <long>Play tracks in random order on/off</long>
+ <short>Shuffle</short>
+ <long>Play tracks in random order?</long>
</locale>
</schema>
@@ -32,7 +32,7 @@
<type>bool</type>
<default>TRUE</default>
<locale name="C">
- <short>Resume playback on startup on/off</short>
+ <short>Resume playback on startup?</short>
<long>Should the media player resume playback where it left off the last time it ran?</long>
</locale>
</schema>
@@ -69,7 +69,7 @@
<default>TRUE</default>
<locale name="C">
<short>Should the cover art be shown or not?</short>
- <long><Should the cover art be shown or not?/long>
+ <long>Should the cover art be shown or not?</long>
</locale>
</schema>
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c 2007-10-25 01:09:17 UTC (rev 3263)
@@ -84,7 +84,7 @@
GTimeVal start_time;
guint x_origin, y_origin;
guint last_x, last_y;
- gboolean cursor_idle; // TRUE if cursor isn't moving
+ gboolean cursor_idle; // TRUE if cursor isn't moving
gint radius, angle;
omp_main_gesture gesture;
@@ -737,9 +737,13 @@
g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_PLAYBACK_VOLUME_CHANGED,
G_CALLBACK(omp_main_update_volume), NULL);
+ // Update UI with current configuration values
+ omp_main_update_shuffle_state(NULL, omp_config_get_shuffle_state(), NULL);
+ omp_main_update_repeat_mode(NULL, omp_config_get_repeat_mode(), NULL);
+
// Set up gesture recognition handlers
gtk_widget_add_events(eventbox,
- GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
main_gesture_data.pressed = FALSE;
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.h 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.h 2007-10-25 01:09:17 UTC (rev 3263)
@@ -42,7 +42,7 @@
typedef enum
{
OMP_MAIN_LABEL_HIDDEN,
- OMP_MAIN_LABEL_EMPTY, // Visible but empty - only makes sense for label #1 as it affects UI layout
+ OMP_MAIN_LABEL_EMPTY, // Visible but empty - only makes sense for label #1 as it affects UI layout
OMP_MAIN_LABEL_ARTIST,
OMP_MAIN_LABEL_TITLE,
OMP_MAIN_LABEL_ALBUM
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c 2007-10-25 01:09:17 UTC (rev 3263)
@@ -46,24 +46,24 @@
/// The literal de-fault configuration, will only be used if gconf is unavailable or schema file wasn't installed
struct _omp_config omp_default_config =
{
- FALSE, // shuffle
- OMP_REPEAT_OFF, // repeat_mode
- TRUE, // resume_playback
- 10000, // prev_track_treshold
- TRUE, // show_numbers_in_pl
- 500000, // pulsesink_buffer_time
- 100000, // pulsesink_latency_time
- TRUE, // main_ui_show_cover
- OMP_MAIN_LABEL_HIDDEN, // main_ui_label1
- OMP_MAIN_LABEL_ARTIST, // main_ui_label2
- OMP_MAIN_LABEL_TITLE, // main_ui_label3
- 15, // main_min_gesture_radius
- 750, // main_gesture_repeat_tresh
- 1000, // main_gesture_repeat_intv
+ FALSE, // shuffle
+ OMP_REPEAT_OFF, // repeat_mode
+ TRUE, // resume_playback
+ 10000, // prev_track_treshold
+ TRUE, // show_numbers_in_pl
+ 500000, // pulsesink_buffer_time
+ 100000, // pulsesink_latency_time
+ TRUE, // main_ui_show_cover
+ OMP_MAIN_LABEL_HIDDEN, // main_ui_label1
+ OMP_MAIN_LABEL_ARTIST, // main_ui_label2
+ OMP_MAIN_LABEL_TITLE, // main_ui_label3
+ 15, // min_gesture_radius
+ 750, // gesture_repeat_tresh
+ 1000, // gesture_repeat_intv
};
-struct _omp_config *omp_config = NULL; ///< Global and persistent configuration data
-struct _omp_session *omp_session = NULL; ///< Global and persistent session data
+struct _omp_config *omp_config = NULL; ///< Global and persistent configuration data
+struct _omp_session *omp_session = NULL; ///< Global and persistent session data
/// The GConf instance we'll use
GConfClient *omp_gconf_client;
@@ -71,6 +71,97 @@
/**
+ * Handler for GConf change notifications
+ */
+static void
+omp_config_gconf_notification(GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+{
+ GConfValue *value;
+ gboolean v_bool;
+
+ value = gconf_entry_get_value(entry);
+
+ switch ((omp_config_options)user_data)
+ {
+ case OMP_CONFIG_SHUFFLE:
+ {
+ // Update value in config struct and submit new state to the UI
+ omp_config->shuffle = gconf_value_get_bool(value);
+ g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_SHUFFLE_STATE_CHANGED, omp_config->shuffle);
+ break;
+ }
+
+ case OMP_CONFIG_REPEAT_MODE:
+ {
+ // Update value in config struct and submit new state to the UI
+ omp_config->repeat_mode = gconf_value_get_int(value);
+ g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_REPEAT_MODE_CHANGED, omp_config->repeat_mode);
+ break;
+ }
+
+ case OMP_CONFIG_RESUME_PLAYBACK:
+ {
+ omp_config->resume_playback = gconf_value_get_bool(value);
+ break;
+ }
+
+ case OMP_CONFIG_PREV_TRACK_TRESHOLD:
+ {
+ omp_config->prev_track_treshold = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_SHOW_NUMBERS_IN_PL:
+ {
+ omp_config->show_numbers_in_pl = gconf_value_get_bool(value);
+ break;
+ }
+
+ case OMP_CONFIG_MAIN_UI_SHOW_COVER:
+ {
+ omp_config->main_ui_show_cover = gconf_value_get_bool(value);
+ break;
+ }
+
+ case OMP_CONFIG_MAIN_UI_LABEL1:
+ {
+ omp_config->main_ui_label1 = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_MAIN_UI_LABEL2:
+ {
+ omp_config->main_ui_label2 = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_MAIN_UI_LABEL3:
+ {
+ omp_config->main_ui_label3 = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_MIN_GESTURE_RADIUS:
+ {
+ omp_config->min_gesture_radius = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_GESTURE_REPEAT_TRESH:
+ {
+ omp_config->gesture_repeat_tresh = gconf_value_get_int(value);
+ break;
+ }
+
+ case OMP_CONFIG_GESTURE_REPEAT_INTV:
+ {
+ omp_config->gesture_repeat_intv = gconf_value_get_int(value);
+ break;
+ }
+ }
+}
+
+/**
* Initalize and load application configuration data
*/
void
@@ -98,53 +189,78 @@
G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL,
g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
- // Fetch values from GConf
+ // Set up GConf, fetch default values and attach notification handler
omp_gconf_client = gconf_client_get_default();
- gconf_client_preload(omp_gconf_client, OMP_GCONF_PATH, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir(omp_gconf_client, OMP_GCONF_PATH, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
omp_config->shuffle =
gconf_client_get_bool(omp_gconf_client, OMP_GCONF_PATH "/shuffle", &error);
if (error)
{
- g_printerr("GConf error: %s\nWill continue execution, though program might behave abnormal.\n", error->message);
+ g_printerr("GConf error: %s\nWill continue execution, though program will have limited functionality.\n", error->message);
g_error_free(error);
return;
}
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/shuffle",
+ (GConfClientNotifyFunc)omp_config_gconf_notification, (gpointer)OMP_CONFIG_SHUFFLE, NULL, &error);
+
omp_config->repeat_mode =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/repeat_mode", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/repeat_mode",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_REPEAT_MODE, NULL, NULL);
omp_config->resume_playback =
gconf_client_get_bool(omp_gconf_client, OMP_GCONF_PATH "/resume_playback", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/resume_playback",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_RESUME_PLAYBACK, NULL, NULL);
omp_config->prev_track_treshold =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/prev_track_treshold", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/prev_track_treshold",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_PREV_TRACK_TRESHOLD, NULL, NULL);
omp_config->show_numbers_in_pl =
gconf_client_get_bool(omp_gconf_client, OMP_GCONF_PATH "/show_numbers_in_playlist", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/show_numbers_in_playlist",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_SHOW_NUMBERS_IN_PL, NULL, NULL);
omp_config->main_ui_show_cover =
gconf_client_get_bool(omp_gconf_client, OMP_GCONF_PATH "/show_cover_art", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/show_cover_art",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_MAIN_UI_SHOW_COVER, NULL, NULL);
omp_config->main_ui_label1 =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/main_label1_type", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/main_label1_type",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_MAIN_UI_LABEL1, NULL, NULL);
omp_config->main_ui_label2 =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/main_label2_type", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/main_label2_type",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_MAIN_UI_LABEL2, NULL, NULL);
omp_config->main_ui_label3 =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/main_label3_type", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/main_label3_type",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_MAIN_UI_LABEL3, NULL, NULL);
- omp_config->main_min_gesture_radius =
+ omp_config->min_gesture_radius =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/min_gesture_radius", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/min_gesture_radius",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_MIN_GESTURE_RADIUS, NULL, NULL);
- omp_config->main_gesture_repeat_tresh =
+ omp_config->gesture_repeat_tresh =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/gesture_repeat_tresh", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/gesture_repeat_tresh",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_GESTURE_REPEAT_TRESH, NULL, NULL);
- omp_config->main_gesture_repeat_intv =
+ omp_config->gesture_repeat_intv =
gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/gesture_repeat_intv", NULL);
+ gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/gesture_repeat_intv",
+ omp_config_gconf_notification, (gpointer)OMP_CONFIG_GESTURE_REPEAT_INTV, NULL, NULL);
}
/**
@@ -158,25 +274,13 @@
}
/**
- * Saves the current application configuration data to persistent storage
- */
-void
-omp_config_save()
-{
-}
-
-/**
* Sets state of shuffle flag
*/
void
omp_config_set_shuffle_state(gboolean state)
{
omp_config->shuffle = state;
- omp_config_save();
-
- // Submit new state to the UI
- g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_SHUFFLE_STATE_CHANGED,
- state);
+ gconf_client_set_bool(omp_gconf_client, OMP_GCONF_PATH "/shuffle", state, NULL);
}
/**
@@ -195,11 +299,7 @@
omp_config_set_repeat_mode(guint mode)
{
omp_config->repeat_mode = mode;
- omp_config_save();
-
- // Submit new state to the UI
- g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_REPEAT_MODE_CHANGED,
- mode);
+ gconf_client_set_int(omp_gconf_client, OMP_GCONF_PATH "/repeat_mode", mode, NULL);
}
/**
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h 2007-10-25 01:09:17 UTC (rev 3263)
@@ -57,33 +57,50 @@
/// @note Update that struct as well if you make changes here!
struct _omp_config
{
- gboolean shuffle; ///< Shuffle on/off
- guint repeat_mode; ///< Repeat mode @see omp_repeat_modes
- gboolean resume_playback; ///< Resume playback on startup where it left off?
- guint prev_track_treshold; ///< Amount of milliseconds a track must have been playing to jump back to track beginning on "prev track" event
- gboolean show_numbers_in_pl; ///< Show numbers in playlist?
- gulong pulsesink_buffer_time; ///< Value to set pulsesink's buffer-time property to
- gulong pulsesink_latency_time; ///< Value to set pulsesink's latency-time property to
- gboolean main_ui_show_cover; ///< Flag determining whether cover is shown or not
- guint main_ui_label1; ///< Contents of main UI's label #1
- guint main_ui_label2; ///< Contents of main UI's label #2
- guint main_ui_label3; ///< Contents of main UI's label #3
- guint main_min_gesture_radius; ///< If a gesture stroke's length is shorter than this the gesture is dismissed
- guint main_gesture_repeat_tresh; ///< If a gesture was made its action will be repeated if the finger is still down after this time (msec)
- guint main_gesture_repeat_intv; ///< Gesture will be repeated every X milliseconds
+ gboolean shuffle; ///< Shuffle on/off
+ guint repeat_mode; ///< Repeat mode @see omp_repeat_modes
+ gboolean resume_playback; ///< Resume playback on startup where it left off?
+ guint prev_track_treshold; ///< Amount of milliseconds a track must have been playing to jump back to track beginning on "prev track" event
+ gboolean show_numbers_in_pl; ///< Show numbers in playlist?
+ gulong pulsesink_buffer_time; ///< Value to set pulsesink's buffer-time property to
+ gulong pulsesink_latency_time; ///< Value to set pulsesink's latency-time property to
+ gboolean main_ui_show_cover; ///< Flag determining whether cover is shown or not
+ guint main_ui_label1; ///< Contents of main UI's label #1
+ guint main_ui_label2; ///< Contents of main UI's label #2
+ guint main_ui_label3; ///< Contents of main UI's label #3
+ guint min_gesture_radius; ///< If a gesture stroke's length is shorter than this the gesture is dismissed
+ guint gesture_repeat_tresh; ///< If a gesture was made its action will be repeated if the finger is still down after this time (msec)
+ guint gesture_repeat_intv; ///< Gesture will be repeated every X milliseconds
};
+/// Enumeration of all configuration options - we use it to distinguish fields on GConf change notifications
+typedef enum
+{
+ OMP_CONFIG_SHUFFLE,
+ OMP_CONFIG_REPEAT_MODE,
+ OMP_CONFIG_RESUME_PLAYBACK,
+ OMP_CONFIG_PREV_TRACK_TRESHOLD,
+ OMP_CONFIG_SHOW_NUMBERS_IN_PL,
+ OMP_CONFIG_MAIN_UI_SHOW_COVER,
+ OMP_CONFIG_MAIN_UI_LABEL1,
+ OMP_CONFIG_MAIN_UI_LABEL2,
+ OMP_CONFIG_MAIN_UI_LABEL3,
+ OMP_CONFIG_MIN_GESTURE_RADIUS,
+ OMP_CONFIG_GESTURE_REPEAT_TRESH,
+ OMP_CONFIG_GESTURE_REPEAT_INTV
+} omp_config_options;
+
/// Session-persistent data
/// @note Default values are set in omp_session_reset()
struct _omp_session
{
- guint volume; ///< Playback volume in percent (0..100)
- guint fade_speed; ///< Volume fading speed in milliseconds
- guint playlist_position; ///< Position within the playlist
- gulong track_position; ///< Position to resume playback from within the last played track
- gboolean was_playing; ///< Set to TRUE of track was being played as the player was closed
- gchar file_chooser_path[256]; ///< Last path used in the file selection dialog
- gchar playlist_file[256]; ///< Path and file name of current (=last used) playlist
+ guint volume; ///< Playback volume in percent (0..100)
+ guint fade_speed; ///< Volume fading speed in milliseconds
+ guint playlist_position; ///< Position within the playlist
+ gulong track_position; ///< Position to resume playback from within the last played track
+ gboolean was_playing; ///< Set to TRUE of track was being played as the player was closed
+ gchar file_chooser_path[256]; ///< Last path used in the file selection dialog
+ gchar playlist_file[256]; ///< Path and file name of current (=last used) playlist
};
extern struct _omp_config *omp_config;
@@ -91,7 +108,6 @@
void omp_config_init();
void omp_config_free();
-void omp_config_save();
void omp_config_set_shuffle_state(gboolean state);
gboolean omp_config_get_shuffle_state();
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h 2007-10-25 01:09:17 UTC (rev 3263)
@@ -49,11 +49,11 @@
/// Modes available for repetitive track playback
enum omp_repeat_modes
{
- OMP_REPEAT_OFF = 0, ///< Repeat off
- OMP_REPEAT_ONCE, ///< Repeat current track once, then proceed with next track
- OMP_REPEAT_CURRENT, ///< Repeat current track forever
- OMP_REPEAT_ALL, ///< Repeat entire playlist
- OMP_REPEAT_COUNT ///< End-of-list marker for mode iteration
+ OMP_REPEAT_OFF = 0, ///< Repeat off
+ OMP_REPEAT_ONCE, ///< Repeat current track once, then proceed with next track
+ OMP_REPEAT_CURRENT, ///< Repeat current track forever
+ OMP_REPEAT_ALL, ///< Repeat entire playlist
+ OMP_REPEAT_COUNT ///< End-of-list marker for mode iteration
};
extern omp_spiff_list *omp_playlist;
Modified: trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c 2007-10-24 10:02:43 UTC (rev 3262)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c 2007-10-25 01:09:17 UTC (rev 3263)
@@ -44,7 +44,7 @@
TYPE_COLUMN,
NAME_COLUMN,
ACT_DELETE_COLUMN,
- FILE_NAME_COLUMN, // This one isn't shown, it's for internal storage only
+ FILE_NAME_COLUMN, // This one isn't shown, it's for internal storage only
COLUMN_COUNT
};
More information about the commitlog
mailing list