--- Begin Message ---
Author: chris
Date: 2007-08-29 16:05:06 +0200 (Wed, 29 Aug 2007)
New Revision: 2850
Modified:
trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog
trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-finger-scroll.c
Log:
Add a style property 'indicator-width' to MokoFingerScroll, to set the
width of the scroll indicators.
Modified: trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog 2007-08-29
13:43:15 UTC (rev 2849)
+++ trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog 2007-08-29
14:05:06 UTC (rev 2850)
@@ -1,3 +1,11 @@
+2007-08-29 Chris Lord,,, <[EMAIL PROTECTED]>
+
+ * libmokoui/moko-finger-scroll.c: (moko_finger_scroll_refresh),
+ (moko_finger_scroll_expose_event), (moko_finger_scroll_style_set),
+ (moko_finger_scroll_class_init), (moko_finger_scroll_init):
+ Add a style property 'indicator-width' to set the width of the scroll
+ indicators.
+
2007-08-28 Chris Lord,,, <[EMAIL PROTECTED]>
* configure.ac:
Modified:
trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-finger-scroll.c
===================================================================
---
trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-finger-scroll.c
2007-08-29 13:43:15 UTC (rev 2849)
+++
trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-finger-scroll.c
2007-08-29 14:05:06 UTC (rev 2850)
@@ -24,8 +24,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((o), MOKO_TYPE_FINGER_SCROLL,
MokoFingerScrollPrivate))
typedef struct _MokoFingerScrollPrivate MokoFingerScrollPrivate;
-#define SCROLL_WIDTH 6
-
struct _MokoFingerScrollPrivate {
MokoFingerScrollMode mode;
gdouble x;
@@ -49,6 +47,7 @@
gboolean vscroll;
GdkRectangle hscroll_rect;
GdkRectangle vscroll_rect;
+ guint scroll_width;
GtkAdjustment *hadjust;
GtkAdjustment *vadjust;
@@ -135,28 +134,28 @@
*/
if ((priv->vscroll != vscroll) || (priv->hscroll != hscroll)) {
gtk_alignment_set_padding (GTK_ALIGNMENT (priv->align), 0,
- hscroll ? SCROLL_WIDTH : 0, 0,
- vscroll ? SCROLL_WIDTH : 0);
+ hscroll ? priv->scroll_width : 0, 0,
+ vscroll ? priv->scroll_width : 0);
}
/* Store the vscroll/hscroll areas for redrawing */
if (vscroll) {
GtkAllocation *allocation = >K_WIDGET (scroll)->allocation;
priv->vscroll_rect.x = allocation->x + allocation->width -
- SCROLL_WIDTH;
+ priv->scroll_width;
priv->vscroll_rect.y = allocation->y;
- priv->vscroll_rect.width = SCROLL_WIDTH;
+ priv->vscroll_rect.width = priv->scroll_width;
priv->vscroll_rect.height = allocation->height -
- (hscroll ? SCROLL_WIDTH : 0);
+ (hscroll ? priv->scroll_width : 0);
}
if (hscroll) {
GtkAllocation *allocation = >K_WIDGET (scroll)->allocation;
priv->hscroll_rect.y = allocation->y + allocation->height -
- SCROLL_WIDTH;
+ priv->scroll_width;
priv->hscroll_rect.x = allocation->x;
- priv->hscroll_rect.height = SCROLL_WIDTH;
+ priv->hscroll_rect.height = priv->scroll_width;
priv->hscroll_rect.width = allocation->width -
- (vscroll ? SCROLL_WIDTH : 0);
+ (vscroll ? priv->scroll_width : 0);
}
priv->vscroll = vscroll;
@@ -442,12 +441,14 @@
y = widget->allocation.y +
((priv->vadjust->value/priv->vadjust->upper)*
(widget->allocation.height -
- (priv->hscroll ? SCROLL_WIDTH : 0)));
+ (priv->hscroll ? priv->scroll_width : 0)));
height = (widget->allocation.y +
- (((priv->vadjust->value +
priv->vadjust->page_size)/
+ (((priv->vadjust->value +
+ priv->vadjust->page_size)/
priv->vadjust->upper)*
(widget->allocation.height -
- (priv->hscroll ? SCROLL_WIDTH : 0)))) - y;
+ (priv->hscroll ? priv->scroll_width : 0)))) -
+ y;
gdk_draw_rectangle (widget->window,
widget->style->base_gc[GTK_STATE_SELECTED],
@@ -467,12 +468,14 @@
x = widget->allocation.x +
((priv->hadjust->value/priv->hadjust->upper)*
(widget->allocation.width -
- (priv->vscroll ? SCROLL_WIDTH : 0)));
+ (priv->vscroll ? priv->scroll_width : 0)));
width = (widget->allocation.x +
- (((priv->hadjust->value +
priv->hadjust->page_size)/
+ (((priv->hadjust->value +
+ priv->hadjust->page_size)/
priv->hadjust->upper)*
(widget->allocation.width -
- (priv->vscroll ? SCROLL_WIDTH : 0)))) - x;
+ (priv->vscroll ? priv->scroll_width : 0)))) -
+ x;
gdk_draw_rectangle (widget->window,
widget->style->base_gc[GTK_STATE_SELECTED],
@@ -617,6 +620,18 @@
}
static void
+moko_finger_scroll_style_set (GtkWidget *widget, GtkStyle *previous_style)
+{
+ MokoFingerScrollPrivate *priv = FINGER_SCROLL_PRIVATE (widget);
+
+ GTK_WIDGET_CLASS (moko_finger_scroll_parent_class)->
+ style_set (widget, previous_style);
+
+ gtk_widget_style_get (widget, "indicator-width", &priv->scroll_width,
+ NULL);
+}
+
+static void
moko_finger_scroll_class_init (MokoFingerScrollClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -635,6 +650,7 @@
widget_class->size_request = moko_finger_scroll_size_request;
widget_class->expose_event = moko_finger_scroll_expose_event;
+ widget_class->style_set = moko_finger_scroll_style_set;
container_class->add = moko_finger_scroll_add;
@@ -701,6 +717,15 @@
"Amount of scroll events to generate per second.",
0, G_MAXUINT, 15,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ gtk_widget_class_install_style_property (
+ widget_class,
+ g_param_spec_uint (
+ "indicator-width",
+ "Width of the scroll indicators",
+ "Pixel width used to draw the scroll indicators.",
+ 0, G_MAXUINT, 6,
+ G_PARAM_READWRITE));
}
static void
@@ -713,6 +738,7 @@
priv->last_time = 0;
priv->vscroll = TRUE;
priv->hscroll = TRUE;
+ priv->scroll_width = 6;
gtk_event_box_set_above_child (GTK_EVENT_BOX (self), TRUE);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), FALSE);
@@ -721,7 +747,7 @@
GTK_CONTAINER_CLASS (moko_finger_scroll_parent_class)->add (
GTK_CONTAINER (self), priv->align);
gtk_alignment_set_padding (GTK_ALIGNMENT (priv->align),
- 0, SCROLL_WIDTH, 0, SCROLL_WIDTH);
+ 0, priv->scroll_width, 0, priv->scroll_width);
gtk_widget_show (priv->align);
gtk_widget_add_events (GTK_WIDGET (self), GDK_POINTER_MOTION_HINT_MASK);
--- End Message ---
--- Begin Message ---
Author: abraxa
Date: 2007-08-30 08:19:25 +0200 (Thu, 30 Aug 2007)
New Revision: 2854
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
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/playback.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.h
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
Log:
Cleared dialog titles
Added fade-in on session resume
Improved gstreamer error handling
Various minor improvements/bugfixes
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -193,8 +193,6 @@
renderer = gtk_cell_renderer_pixbuf_new();
g_object_set(G_OBJECT(renderer), "pixbuf", track_icon, NULL);
column = gtk_tree_view_column_new_with_attributes("", renderer, NULL);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width(column, BUTTON_PIXMAP_SIZE);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
renderer = gtk_cell_renderer_text_new();
@@ -252,7 +250,7 @@
hbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(hbox));
- image = gtk_image_new_from_icon_name("gtk-file", BUTTON_PIXMAP_SIZE);
+ image = gtk_image_new_from_icon_name("gtk-file", GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(image), TRUE, TRUE, 0);
alignment = label_create(&label, "Sans 6", "black", 0, 0, 0, 0, 0);
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -24,6 +24,8 @@
* Various helper functions to aid with GUI creation and handling
*/
+#include <gtk/gtk.h>
+
#include "guitools.h"
/// Absolute path to the UI pixmaps
@@ -129,6 +131,25 @@
}
/**
+ * Presents a simple modal error dialog to the user
+ */
+void
+error_dialog(gchar *message)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new(0,
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
+ "%s", message);
+
+ // We don't want a title of "<unnamed>"
+ gtk_window_set_title(GTK_WINDOW(dialog), " ");
+
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+}
+
+/**
* Loads an image from disk and adds it to a given container, returning a
reference to the image as well
*/
void
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.h
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.h
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.h
2007-08-30 06:19:25 UTC (rev 2854)
@@ -39,6 +39,8 @@
gfloat xalign, gfloat yalign, gfloat xscale, gfloat yscale, gint
max_char_count);
GtkWidget *button_create_with_image(gchar *image_name, GtkWidget **image,
GCallback callback);
+void error_dialog(gchar *message);
+
void container_add_image_with_ref(GtkContainer *container, gchar *image_name,
GtkWidget **image);
void container_add_image(GtkContainer *container, gchar *image_name);
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
2007-08-29 23:17:36 UTC (rev 2853)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -64,13 +64,17 @@
// Forces the window to the native size of the Neo1973's screen area if enabled
//define EMULATE_SIZE
-GtkWidget *omp_window = NULL;
///< Application's main window
-GtkWidget *omp_notebook = NULL;
///< GtkNotebook containing the
pages making up the UI
-struct _omp_notebook_tab_ids *omp_notebook_tab_ids = NULL; ///< Holds
numerical IDs of the notebook tabs, used for gtk_notebook_set_current_page()
-struct _omp_notebook_tabs *omp_notebook_tabs = NULL; ///< Holds the
GtkWidget handles of the notebook tabs so they can be hidden/shown
+/// Application's main window
+GtkWidget *omp_window = NULL;
+/// GtkNotebook containing the pages making up the UI
+GtkWidget *omp_notebook = NULL;
+/// Holds the tab widgets of the GtkNotebook
+GtkWidget *omp_notebook_tabs[OMP_TABS];
+
+
/**
* Terminate the entire program normally
*/
@@ -177,10 +181,11 @@
/**
* Makes sure only one instance of the media player is running at a time
+ * @return TRUE if lock is in place, FALSE if it wasn't
* @todo Single-instance mechanism needs to be improved
*/
-void
-handle_locking()
+gboolean
+check_lock()
{
gchar *lock_file = "/tmp/mediaplayer.lock";
pid_t pid;
@@ -190,10 +195,11 @@
{
g_printf(_("Already running an instance of the Media Player,
bringing that to the front instead.\n"));
kill(pid, SIGUSR1);
- return;
+ return TRUE;
}
set_lock(lock_file);
+ return FALSE;
}
/**
@@ -219,7 +225,7 @@
g_signal_connect(G_OBJECT(omp_window), "destroy",
G_CALLBACK(omp_close), NULL);
#ifdef EMULATE_SIZE
- gtk_widget_set_size_request(GTK_WIDGET(omp_window), 480, 620);
+ gtk_widget_set_size_request(GTK_WIDGET(omp_window), 480, 600);
#endif
}
@@ -231,7 +237,6 @@
omp_window_create_pages()
{
GtkWidget *page;
- guint page_id = 0;
// Create and set up the notebook that contains the individual UI pages
omp_notebook = gtk_notebook_new();
@@ -240,47 +245,59 @@
gtk_container_add(GTK_CONTAINER(omp_window), GTK_WIDGET(omp_notebook));
gtk_widget_show(omp_notebook);
- omp_notebook_tab_ids = g_new0(struct _omp_notebook_tab_ids, 1);
- omp_notebook_tabs = g_new0(struct _omp_notebook_tabs, 1);
-
// Add main page
page = omp_main_page_create();
notebook_add_page_with_icon(omp_notebook, page, MOKO_STOCK_SPEAKER, 0);
- omp_notebook_tab_ids->main = page_id++;
- omp_notebook_tabs->main = page;
+ omp_notebook_tabs[OMP_TAB_MAIN] = page;
// Add playlist page
page = omp_playlist_page_create();
notebook_add_page_with_icon(omp_notebook, page, MOKO_STOCK_VIEW, 0);
- omp_notebook_tab_ids->playlists = page_id++;
- omp_notebook_tabs->playlists = page;
+ omp_notebook_tabs[OMP_TAB_PLAYLISTS] = page;
// Add playlist editor page
page = omp_editor_page_create();
notebook_add_page_with_icon(omp_notebook, page, "gtk-index", 0);
- omp_notebook_tab_ids->editor = page_id++;
- omp_notebook_tabs->editor = page;
+ omp_notebook_tabs[OMP_TAB_PLAYLIST_EDITOR] = page;
+ gtk_widget_hide(page); // We show the page once a playlist was loaded
}
/**
- * Frees all resources used by the main window
+ * Displays the main window and all widgets it contains
*/
void
-omp_window_free()
+omp_window_show()
{
- g_free(omp_notebook_tab_ids);
+ gtk_widget_show(omp_window);
}
/**
- * Displays the main window and all widgets it contains
+ * Makes one of the UI tabs visible on the notebook
+ * @param tab_id An ID taken from the omp_notebook_tabs enum
+ * @see omp_notebook_tabs
*/
void
-omp_window_show()
+omp_show_tab(guint tab_id)
{
- gtk_widget_show(omp_window);
+ g_return_if_fail(tab_id < OMP_TABS);
+
+ gtk_widget_show(GTK_WIDGET(omp_notebook_tabs[tab_id]));
}
/**
+ * Hides one of the UI tabs from the notebook
+ * @param tab_id An ID taken from the omp_notebook_tabs enum
+ * @see omp_notebook_tabs
+ */
+void
+omp_hide_tab(guint tab_id)
+{
+ g_return_if_fail(tab_id < OMP_TABS);
+
+ gtk_widget_hide(GTK_WIDGET(omp_notebook_tabs[tab_id]));
+}
+
+/**
* If only I knew what this is
*/
gint
@@ -330,7 +347,7 @@
}
// Make sure we have only one instance running
- handle_locking();
+ if (check_lock()) return EXIT_SUCCESS;
// Initialize gstreamer, must be last in the chain of command line
parameter processors
if (!gst_init_check(&argc, &argv, &error))
@@ -354,7 +371,7 @@
// Initialize playback, playlist and UI handling
omp_config_init();
omp_window_create();
- omp_playback_init();
+ if (!omp_playback_init()) return EXIT_FAILURE;
omp_playlist_init();
omp_window_create_pages();
@@ -370,7 +387,6 @@
omp_playback_save_state();
omp_playback_free();
omp_playlist_free();
- omp_window_free();
gst_deinit();
g_free(ui_image_path);
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
2007-08-29 23:17:36 UTC (rev 2853)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
2007-08-30 06:19:25 UTC (rev 2854)
@@ -29,9 +29,6 @@
#include <gtk/gtk.h>
-// This size is valid for the entire application and determines the size of
the button's icons
-#define BUTTON_PIXMAP_SIZE 36
-
// Where to find application-specific images relative to $DATA_DIR
(/usr/share/openmoko-mediaplayer)?
#define RELATIVE_UI_IMAGE_PATH "/images"
@@ -41,22 +38,20 @@
// What file to save/load session data to/from? File name is relative to
user's home directory
#define SESSION_FILE_NAME "/.openmoko-mediaplayer"
-
-struct _omp_notebook_tab_ids
+enum omp_notebook_tabs
{
- guint main, playlists, editor, files;
+ OMP_TAB_MAIN = 0,
+ OMP_TAB_PLAYLISTS,
+ OMP_TAB_PLAYLIST_EDITOR,
+ OMP_TABS
};
-struct _omp_notebook_tabs
-{
- GtkWidget *main, *playlists, *editor, *files;
-};
-
-extern struct _omp_notebook_tab_ids *omp_notebook_tab_ids;
-extern struct _omp_notebook_tabs *omp_notebook_tabs;
extern GtkWidget *omp_notebook;
extern GtkWidget *omp_window;
void omp_application_terminate();
+void omp_show_tab(guint tab_id);
+void omp_hide_tab(guint tab_id);
+
#endif
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-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -92,7 +92,7 @@
g_object_set(G_OBJECT(button), "xalign", (gfloat)0.37, "yalign",
(gfloat)0.37, NULL);
- *image = gtk_image_new_from_icon_name(image_name, BUTTON_PIXMAP_SIZE);
+ *image = gtk_image_new_from_icon_name(image_name, GTK_ICON_SIZE_BUTTON);
gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(*image));
return button;
@@ -744,12 +744,12 @@
if (omp_playback_get_state() == OMP_PLAYBACK_STATE_PAUSED)
{
gtk_image_set_from_icon_name(GTK_IMAGE(main_widgets.play_pause_button_image),
- "gtk-media-play-ltr", BUTTON_PIXMAP_SIZE);
+ "gtk-media-play-ltr", GTK_ICON_SIZE_BUTTON);
} else {
gtk_image_set_from_icon_name(GTK_IMAGE(main_widgets.play_pause_button_image),
- "gtk-media-pause", BUTTON_PIXMAP_SIZE);
+ "gtk-media-pause", GTK_ICON_SIZE_BUTTON);
}
}
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-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -332,3 +332,12 @@
omp_session->volume = volume;
omp_session_save();
}
+
+/**
+ * Returns the number of milliseconds defining the duration of a volume fade
+ */
+guint
+omp_session_get_fade_speed()
+{
+ return omp_session->fade_speed;
+}
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-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
2007-08-30 06:19:25 UTC (rev 2854)
@@ -85,4 +85,6 @@
void omp_session_set_track_id(guint track_id);
void omp_session_set_volume(guint volume);
+guint omp_session_get_fade_speed();
+
#endif
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -24,19 +24,34 @@
* Playback engine interface
*/
+#include <glib/gi18n.h>
#include <gst/gst.h>
-
#include <uriparser/Uri.h>
#include "playback.h"
+#include "guitools.h"
+#include "main.h"
#include "persistent.h"
-#include "main.h"
-GstElement *omp_gst_playbin = NULL;
///< Our ticket to the gstreamer world
-guint omp_playback_ui_timeout = 0;
///< Handle of the UI-updating timeout
-gboolean omp_playback_ui_timeout_halted; ///< Flag that
tells the UI-updating timeout to exit if set
-gulong omp_playback_pending_position = 0; ///< Since we
can't set a new position if element is not paused or playing we store the
position here and set it when it reached either state
+/// Our ticket to the gstreamer world
+GstElement *omp_gst_playbin = NULL;
+/// Handle of the UI-updating timeout
+guint omp_playback_ui_timeout = 0;
+
+/// Flag that tells the UI-updating timer to exit if set
+gboolean omp_playback_ui_timeout_halted;
+
+/// Since we can't set a new position if element is not paused or playing we
+/// store the position here and set it when it reached either state
+gulong omp_playback_pending_position = 0;
+
+/// Contains the final volume when fading (-1 means "not fading")
+guint omp_playback_fade_final_vol = -1;
+
+/// Holds the volume increment per UI-update timer call
+guint omp_playback_fade_increment = 0;
+
// Some private forward declarations
static gboolean omp_gst_message_eos(GstBus *bus, GstMessage *message, gpointer
data);
static gboolean omp_gst_message_state_changed(GstBus *bus, GstMessage
*message, gpointer data);
@@ -48,8 +63,9 @@
/**
* Initializes gstreamer by setting up pipe, message hooks and bins
+ * @return TRUE on success, FAIL if an error occured
*/
-void
+gboolean
omp_playback_init()
{
GstBus *bus;
@@ -57,7 +73,7 @@
// Bail if everything is already set up
if (omp_gst_playbin)
{
- return;
+ return TRUE;
}
// Create the signals we'll emit
@@ -92,6 +108,13 @@
// Set up gstreamer pipe and bins
omp_gst_playbin = gst_element_factory_make("playbin", "play");
+ if (!omp_gst_playbin)
+ {
+ error_dialog(_("Error: gstreamer failed to initialize.\nPlease
make sure gstreamer and its modules are properly installed."));
+
+ return FALSE;
+ }
+
// Set up message hooks
bus = gst_pipeline_get_bus(GST_PIPELINE(omp_gst_playbin));
@@ -103,6 +126,8 @@
g_signal_connect(bus, "message::tag",
G_CALLBACK(omp_gst_message_tag), NULL);
gst_object_unref(bus);
+
+ return TRUE;
}
/**
@@ -179,6 +204,24 @@
static gboolean
omp_playback_ui_timeout_callback(gpointer data)
{
+ guint volume;
+
+ // Fade in if needed
+ if (omp_playback_fade_final_vol != -1)
+ {
+ volume = omp_playback_get_volume()+omp_playback_fade_increment;
+
+ if (volume > omp_playback_fade_final_vol)
+ {
+ omp_playback_set_volume(omp_playback_fade_final_vol);
+ omp_playback_fade_final_vol = -1;
+
+ } else {
+
+ omp_playback_set_volume(volume);
+ }
+ }
+
g_signal_emit_by_name(G_OBJECT(omp_window),
OMP_EVENT_PLAYBACK_POSITION_CHANGED);
if (omp_playback_ui_timeout_halted)
@@ -367,9 +410,13 @@
// Set playbin volume which ranges from 0.0 to 1.0
g_object_set(G_OBJECT(omp_gst_playbin), "volume", volume/100.0, NULL);
- omp_session_set_volume(volume);
+ // Volume fading shouldn't be visible to the user
+ if (omp_playback_fade_final_vol == -1)
+ {
+ omp_session_set_volume(volume);
- g_signal_emit_by_name(G_OBJECT(omp_window),
OMP_EVENT_PLAYBACK_VOLUME_CHANGED);
+ g_signal_emit_by_name(G_OBJECT(omp_window),
OMP_EVENT_PLAYBACK_VOLUME_CHANGED);
+ }
}
/**
@@ -391,6 +438,14 @@
void
omp_playback_fade_volume()
{
+ omp_playback_fade_final_vol = omp_playback_get_volume();
+ omp_playback_set_volume(0);
+
+ omp_playback_fade_increment =
+ omp_playback_fade_final_vol /
(omp_session_get_fade_speed()/PLAYBACK_UI_UPDATE_INTERVAL);
+
+ if (omp_playback_fade_increment == 0)
+ omp_playback_fade_increment = 1;
}
/**
@@ -445,13 +500,18 @@
static gboolean
omp_gst_message_error(GstBus *bus, GstMessage *message, gpointer data)
{
- #ifdef DEBUG
- GError *error;
- gst_message_parse_error(message, &error, NULL);
- g_printerr("gstreamer error: %s\n", error->message);
- g_error_free(error);
- #endif
+ GError *error;
+ gchar *text;
+ gst_message_parse_error(message, &error, NULL);
+ g_printerr("gstreamer error: %s\n", error->message);
+
+ text = g_strdup_printf("gstreamer error:\n%s", error->message);
+ error_dialog(text);
+ g_free(text);
+
+ g_error_free(error);
+
return TRUE;
}
@@ -461,13 +521,18 @@
static gboolean
omp_gst_message_warning(GstBus *bus, GstMessage *message, gpointer data)
{
- #ifdef DEBUG
- GError *error;
- gst_message_parse_warning(message, &error, NULL);
- g_printerr("gstreamer warning: %s\n", error->message);
- g_error_free(error);
- #endif
+ GError *error;
+ gchar *text;
+ gst_message_parse_warning(message, &error, NULL);
+ g_printerr("gstreamer warning: %s\n", error->message);
+
+ text = g_strdup_printf("gstreamer warning:\n%s", error->message);
+ error_dialog(text);
+ g_free(text);
+
+ g_error_free(error);
+
return TRUE;
}
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.h
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.h
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.h
2007-08-30 06:19:25 UTC (rev 2854)
@@ -44,7 +44,7 @@
// The UI will be updated at this interval when a track is playing (in ms)
#define PLAYBACK_UI_UPDATE_INTERVAL 1000
-void omp_playback_init();
+gboolean omp_playback_init();
void omp_playback_free();
void omp_playback_save_state();
void omp_playback_reset();
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
===================================================================
---
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
2007-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -33,6 +33,7 @@
#include <string.h>
#include "playlist.h"
+#include "guitools.h"
#include "omp_spiff_c.h"
#include "main.h"
#include "playback.h"
@@ -138,8 +139,7 @@
gboolean
omp_playlist_load(gchar *playlist_file, gboolean do_state_reset)
{
- GtkWidget *dialog;
- gchar *title;
+ gchar *title, *text;
// Free the track history's memory by deleting the first element until
the list is empty
while (omp_track_history)
@@ -188,6 +188,9 @@
g_signal_emit_by_name(G_OBJECT(omp_window),
OMP_EVENT_PLAYLIST_LOADED, title);
g_free(title);
+ // Show playlist editor
+ omp_show_tab(OMP_TAB_PLAYLIST_EDITOR);
+
} else {
omp_playlist_current_track_id = -1;
@@ -198,12 +201,9 @@
#endif
// Notify user
- dialog = gtk_message_dialog_new(0,
- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
- _("\nCould not load playlist '%s'"), playlist_file);
-
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ text = g_strdup_printf(_("\nCould not load playlist '%s'"),
playlist_file);
+ error_dialog(text);
+ g_free(text);
}
return omp_playlist ? TRUE : FALSE;
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-08-29 23:17:36 UTC (rev 2853)
+++
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
2007-08-30 06:19:25 UTC (rev 2854)
@@ -29,6 +29,8 @@
#include <libmokoui2/moko-finger-scroll.h>
#include <libmokoui2/moko-stock.h>
+#include <string.h>
+
#include "playlist_page.h"
#include "main.h"
#include "guitools.h"
@@ -71,17 +73,15 @@
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("Load playlist '%s'?"), playlist_name);
+ // We don't want a title of "<unnamed>"
+ gtk_window_set_title(GTK_WINDOW(dialog), " ");
+
dialog_result = gtk_dialog_run(GTK_DIALOG(dialog));
if (dialog_result == GTK_RESPONSE_YES)
{
// Load playlist with state reset to have sane playlist values
- if (omp_playlist_load(playlist_file_abs, TRUE))
- {
- // Switch back to main UI page
-/*
gtk_notebook_set_current_page(GTK_NOTEBOOK(omp_notebook),
- omp_notebook_tab_ids->main); */
- }
+ omp_playlist_load(playlist_file_abs, TRUE);
}
// Clean up
@@ -104,6 +104,9 @@
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("Delete playlist '%s'?"), playlist_name);
+ // We don't want a title of "<unnamed>"
+ gtk_window_set_title(GTK_WINDOW(dialog), " ");
+
dialog_result = gtk_dialog_run(GTK_DIALOG(dialog));
if (dialog_result == GTK_RESPONSE_YES)
@@ -191,7 +194,7 @@
gchar *path, *file_name;
const gchar *name =
gtk_entry_get_text(GTK_ENTRY(omp_playlist_page_entry));
- g_return_if_fail(name);
+ g_return_if_fail(strcmp(name, "") != 0);
// Playlist path is relative to user's home dir
path = g_build_path("/", g_get_home_dir(), RELATIVE_PLAYLIST_PATH,
NULL);
@@ -285,8 +288,6 @@
renderer = gtk_cell_renderer_pixbuf_new();
g_object_set(G_OBJECT(renderer), "stock-id", MOKO_STOCK_VIEW, NULL);
column = gtk_tree_view_column_new_with_attributes("", renderer, NULL);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width(column, BUTTON_PIXMAP_SIZE);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
renderer = gtk_cell_renderer_text_new();
@@ -300,8 +301,6 @@
renderer = gtk_cell_renderer_pixbuf_new();
g_object_set(G_OBJECT(renderer), "stock-id", "gtk-delete", NULL);
column = gtk_tree_view_column_new_with_attributes("", renderer, NULL);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width(column, 1*BUTTON_PIXMAP_SIZE);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
// Add playlist view to container
@@ -342,7 +341,7 @@
input_box = gtk_hbox_new(FALSE, 0);
omp_playlist_page_entry = gtk_entry_new();
button = gtk_button_new();
- image = gtk_image_new_from_icon_name("gtk-add", BUTTON_PIXMAP_SIZE);
+ image = gtk_image_new_from_icon_name("gtk-add", GTK_ICON_SIZE_BUTTON);
gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(image));
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(omp_playlist_page_add_list), NULL);
--- End Message ---