[totem] Fix video list rendering and related video playback for the YouTube plugin
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Subject: [totem] Fix video list rendering and related video playback for the YouTube plugin
- Date: Sun, 14 Jun 2009 09:26:05 -0400 (EDT)
commit 49aca5e2058f9b50b2fc82efdee563ab26ce8a5e
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Jun 14 14:25:32 2009 +0100
Fix video list rendering and related video playback for the YouTube plugin
2009-06-14 Philip Withnall <philip tecnocode co uk>
* src/plugins/youtube/totem-youtube.c (set_up_tree_view),
(resolve_t_param_cb), (starting_video_cb):
* src/plugins/youtube/youtube.ui:
* src/totem-cell-renderer-video.c (get_size),
(totem_cell_renderer_video_get_size),
(totem_cell_renderer_video_render):
* src/totem-video-list.c (totem_video_list_class_init),
(row_activated_cb), (show_popup_menu):
* src/totemvideolist-marshal.list: Fix video list rendering for the
YouTube plugin, as well as playback of related videos.
ChangeLog | 13 ++++++++
src/plugins/youtube/totem-youtube.c | 19 ++++++++++--
src/plugins/youtube/youtube.ui | 24 +++------------
src/totem-cell-renderer-video.c | 54 ++++++++++++----------------------
src/totem-video-list.c | 34 ++++++++++++---------
src/totemvideolist-marshal.list | 2 +-
6 files changed, 73 insertions(+), 73 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 79b5576..0ae34d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2009-06-14 Philip Withnall <philip tecnocode co uk>
+ * src/plugins/youtube/totem-youtube.c (set_up_tree_view),
+ (resolve_t_param_cb), (starting_video_cb):
+ * src/plugins/youtube/youtube.ui:
+ * src/totem-cell-renderer-video.c (get_size),
+ (totem_cell_renderer_video_get_size),
+ (totem_cell_renderer_video_render):
+ * src/totem-video-list.c (totem_video_list_class_init),
+ (row_activated_cb), (show_popup_menu):
+ * src/totemvideolist-marshal.list: Fix video list rendering for the
+ YouTube plugin, as well as playback of related videos.
+
+2009-06-14 Philip Withnall <philip tecnocode co uk>
+
* src/plugins/youtube/totem-youtube.c (resolve_t_param_cb),
(resolve_t_param), (query_progress_cb),
(open_in_web_browser_activate_cb): Update YouTube plugin to use
diff --git a/src/plugins/youtube/totem-youtube.c b/src/plugins/youtube/totem-youtube.c
index b0fa5f2..f014af7 100644
--- a/src/plugins/youtube/totem-youtube.c
+++ b/src/plugins/youtube/totem-youtube.c
@@ -35,6 +35,7 @@
#include "totem-video-list.h"
#include "totem-interface.h"
#include "backend/bacon-video-widget.h"
+#include "totem-cell-renderer-video.h"
/* Notebook pages */
enum {
@@ -100,7 +101,7 @@ gboolean button_press_event_cb (GtkWidget *widget, GdkEventButton *event, TotemY
gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *event, TotemYouTubePlugin *self);
void open_in_web_browser_activate_cb (GtkAction *action, TotemYouTubePlugin *self);
void value_changed_cb (GtkAdjustment *adjustment, TotemYouTubePlugin *self);
-gboolean starting_video_cb (TotemVideoList *video_list, GtkTreeView *tree_view, GtkTreePath *path, TotemYouTubePlugin *self);
+gboolean starting_video_cb (TotemVideoList *video_list, GtkTreePath *path, TotemYouTubePlugin *self);
TOTEM_PLUGIN_REGISTER (TotemYouTubePlugin, totem_youtube_plugin)
@@ -277,6 +278,16 @@ set_up_tree_view (TotemYouTubePlugin *self, GtkBuilder *builder, guint key)
GtkActionGroup *action_group;
GtkAction *action, *menu_item;
GtkWidget *vscroll, *tree_view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ /* Add the cell renderer. This can't be done with GtkBuilder, because it unavoidably sets the expand parameter to FALSE */
+ /* TODO: Depends on bug #453692 */
+ renderer = GTK_CELL_RENDERER (totem_cell_renderer_video_new (TRUE));
+ column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder,
+ (key == SEARCH_TREE_VIEW) ? "yt_treeview_search_column" : "yt_treeview_related_column"));
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer, "thumbnail", 0, "title", 1, NULL);
/* Give the video lists a handle to Totem and connect their scrollbar signals */
if (key == SEARCH_TREE_VIEW) {
@@ -521,7 +532,8 @@ resolve_t_param_cb (GObject *source_object, GAsyncResult *result, TParamData *da
GDataMediaContent *content;
/* We don't have a match, which is odd; fall back to the FLV URI as advertised by the YouTube API */
- content = GDATA_MEDIA_CONTENT (gdata_youtube_video_look_up_content (GDATA_YOUTUBE_VIDEO (data->entry), "application/x-shockwave-flash"));
+ content = GDATA_MEDIA_CONTENT (gdata_youtube_video_look_up_content (GDATA_YOUTUBE_VIDEO (data->entry),
+ "application/x-shockwave-flash"));
if (content != NULL) {
video_uri = g_strdup (gdata_media_content_get_uri (content));
g_debug ("Couldn't find the t param of entry %s; falling back to its FLV URI (\"%s\")", video_id, video_uri);
@@ -973,7 +985,7 @@ button_release_event_cb (GtkWidget *widget, GdkEventButton *event, TotemYouTubeP
}
gboolean
-starting_video_cb (TotemVideoList *video_list, GtkTreeView *tree_view, GtkTreePath *path, TotemYouTubePlugin *self)
+starting_video_cb (TotemVideoList *video_list, GtkTreePath *path, TotemYouTubePlugin *self)
{
GtkTreeIter iter;
GDataYouTubeVideo *video_entry;
@@ -982,6 +994,7 @@ starting_video_cb (TotemVideoList *video_list, GtkTreeView *tree_view, GtkTreePa
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (self->list_store[self->current_tree_view]), &iter, path) == FALSE)
return FALSE;
gtk_tree_model_get (GTK_TREE_MODEL (self->list_store[self->current_tree_view]), &iter, 3, &video_entry, -1);
+g_message ("starting_video_cb: model: %lu, path: %lu, current tv: %u", self->list_store[self->current_tree_view], path, self->current_tree_view);
if (self->playing_video != NULL)
g_object_unref (self->playing_video);
diff --git a/src/plugins/youtube/youtube.ui b/src/plugins/youtube/youtube.ui
index 26c18d5..c3ac711 100644
--- a/src/plugins/youtube/youtube.ui
+++ b/src/plugins/youtube/youtube.ui
@@ -76,7 +76,7 @@
<property name="spacing">4</property>
<child>
<object class="GtkScrolledWindow" id="yt_scrolled_window_search">
- <property name="hscrollbar-policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="hscrollbar-policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar-policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow-type">GTK_SHADOW_IN</property>
<property name="window-placement">GTK_CORNER_TOP_LEFT</property>
@@ -91,15 +91,8 @@
<child>
<object class="GtkTreeViewColumn" id="yt_treeview_search_column">
<property name="title" translatable="yes">Videos</property>
- <child>
- <object class="TotemCellRendererVideo" id="yt_treeview_search_renderer">
- <property name="use-placeholder">True</property>
- </object>
- <attributes>
- <attribute name="thumbnail">0</attribute>
- <attribute name="title">1</attribute>
- </attributes>
- </child>
+ <property name="expand">True</property>
+ <!-- Placeholder -->
</object>
</child>
</object>
@@ -143,15 +136,8 @@
<child>
<object class="GtkTreeViewColumn" id="yt_treeview_related_column">
<property name="title" translatable="yes">Videos</property>
- <child>
- <object class="TotemCellRendererVideo" id="yt_treeview_related_renderer">
- <property name="use-placeholder">True</property>
- </object>
- <attributes>
- <attribute name="thumbnail">0</attribute>
- <attribute name="title">1</attribute>
- </attributes>
- </child>
+ <property name="expand">True</property>
+ <!-- Placeholder -->
</object>
</child>
</object>
diff --git a/src/totem-cell-renderer-video.c b/src/totem-cell-renderer-video.c
index f130a42..d7b7b77 100644
--- a/src/totem-cell-renderer-video.c
+++ b/src/totem-cell-renderer-video.c
@@ -242,7 +242,7 @@ get_size (GtkCellRenderer *cell,
GdkRectangle *title_area,
GdkRectangle *thumbnail_area)
{
- TotemCellRendererVideoPrivate *priv = TOTEM_CELL_RENDERER_VIDEO_GET_PRIVATE (cell);
+ TotemCellRendererVideoPrivate *priv = TOTEM_CELL_RENDERER_VIDEO (cell)->priv;
guint pixbuf_width = 0;
guint pixbuf_height = 0;
guint title_width, title_height;
@@ -293,8 +293,7 @@ get_size (GtkCellRenderer *cell,
if (draw_area) {
if (cell_area && calc_width > 0 && calc_height > 0) {
draw_area->x = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
- (1.0 - cell->xalign) : cell->xalign) *
- (cell_area->width - calc_width));
+ (1.0 - cell->xalign) : cell->xalign) * (cell_area->width - calc_width));
draw_area->x = MAX (draw_area->x, 0);
draw_area->y = (cell->yalign * (cell_area->height - calc_height));
draw_area->y = MAX (draw_area->y, 0);
@@ -303,15 +302,11 @@ get_size (GtkCellRenderer *cell,
draw_area->y = 0;
}
+ draw_area->x += cell->xpad;
+ draw_area->y += cell->ypad;
draw_area->width = calc_width;
draw_area->height = calc_height;
- /*if (cell_area) {
- g_debug ("Cell area: X: %i, Y: %i, W: %i, H: %i", cell_area->x, cell_area->y, cell_area->width, cell_area->height);
- g_debug ("X-align: %f, Y-align: %f", cell->xalign, cell->yalign);
- }
- g_debug ("Draw area: X: %i, Y: %i, W: %i, H: %i", draw_area->x, draw_area->y, draw_area->width, draw_area->height);*/
-
if (title_area) {
if (cell_area) {
title_area->width = cell_area->width;
@@ -326,8 +321,6 @@ get_size (GtkCellRenderer *cell,
title_area->y = draw_area->y + pixbuf_height + cell->ypad;
else
title_area->y = draw_area->y;
-
- /*g_debug ("Title area: X: %i, Y: %i, W: %i, H: %i", title_area->x, title_area->y, title_area->width, title_area->height);*/
}
if (pixbuf_height > 0 && thumbnail_area) {
@@ -338,11 +331,7 @@ get_size (GtkCellRenderer *cell,
thumbnail_area->y = draw_area->y;
thumbnail_area->width = cell->xpad * 2 + pixbuf_width;
thumbnail_area->height = pixbuf_height;
-
- /*g_debug ("Thumbnail area: X: %i, Y: %i, W: %i, H: %i", thumbnail_area->x, thumbnail_area->y, thumbnail_area->width, thumbnail_area->height);*/
}
-
- /*g_debug ("---");*/
}
}
@@ -356,6 +345,7 @@ totem_cell_renderer_video_get_size (GtkCellRenderer *cell,
gint *height)
{
GdkRectangle draw_area;
+
get_size (cell, widget, cell_area, &draw_area, NULL, NULL);
if (x_offset)
@@ -377,7 +367,7 @@ totem_cell_renderer_video_render (GtkCellRenderer *cell,
GdkRectangle *expose_area,
GtkCellRendererState flags)
{
- TotemCellRendererVideoPrivate *priv = TOTEM_CELL_RENDERER_VIDEO_GET_PRIVATE (cell);
+ TotemCellRendererVideoPrivate *priv = TOTEM_CELL_RENDERER_VIDEO (cell)->priv;
GdkPixbuf *pixbuf;
GdkRectangle draw_rect;
GdkRectangle draw_area;
@@ -385,13 +375,12 @@ totem_cell_renderer_video_render (GtkCellRenderer *cell,
GdkRectangle thumbnail_area;
cairo_t *cr;
PangoLayout *layout;
- PangoFontDescription *desc;
GtkStateType state;
get_size (cell, widget, cell_area, &draw_area, &title_area, &thumbnail_area);
- draw_area.x += cell_area->x + cell->xpad;
- draw_area.y += cell_area->y + cell->ypad;
+ draw_area.x += cell_area->x;
+ draw_area.y += cell_area->y;
draw_area.width -= cell->xpad * 2;
draw_area.height -= cell->ypad * 2;
@@ -430,34 +419,29 @@ totem_cell_renderer_video_render (GtkCellRenderer *cell,
/* Draw the title */
layout = gtk_widget_create_pango_layout (widget, priv->title);
- desc = pango_font_description_copy_static (widget->style->font_desc);
- if (pixbuf != NULL)
+ if (pixbuf != NULL) {
+ PangoFontDescription *desc = pango_font_description_copy_static (widget->style->font_desc);
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+ }
- pango_layout_set_font_description (layout, desc);
pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
pango_layout_set_width (layout, title_area.width * PANGO_SCALE);
pango_layout_set_alignment (layout, priv->alignment);
- gtk_paint_layout (widget->style,
- window,
- state,
- TRUE,
- expose_area,
- widget,
- "cellrenderervideotitle",
- cell_area->x + title_area.x + cell->xpad,
- cell_area->y + title_area.y + cell->ypad,
- layout);
-
- pango_font_description_free (desc);
+ gtk_paint_layout (widget->style, window, state, TRUE, expose_area, widget, "cellrenderervideotitle",
+ cell_area->x + title_area.x,
+ cell_area->y + title_area.y,
+ layout);
+
g_object_unref (layout);
/* Draw the thumbnail */
if (pixbuf != NULL) {
cr = gdk_cairo_create (window);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, cell_area->x + thumbnail_area.x + cell->xpad, cell_area->y + thumbnail_area.y + cell->ypad);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, cell_area->x + thumbnail_area.x, cell_area->y + thumbnail_area.y);
gdk_cairo_rectangle (cr, &draw_rect);
cairo_fill (cr);
diff --git a/src/totem-video-list.c b/src/totem-video-list.c
index facade5..716b4d4 100644
--- a/src/totem-video-list.c
+++ b/src/totem-video-list.c
@@ -168,9 +168,9 @@ totem_video_list_class_init (TotemVideoListClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TotemVideoListClass, starting_video),
NULL, NULL,
- totemvideolist_marshal_BOOLEAN__OBJECT_OBJECT,
- G_TYPE_BOOLEAN, 2,
- TOTEM_TYPE_VIDEO_LIST, GTK_TYPE_TREE_PATH);
+ totemvideolist_marshal_BOOLEAN__BOXED,
+ G_TYPE_BOOLEAN, 1,
+ GTK_TYPE_TREE_PATH);
}
static void
@@ -336,23 +336,27 @@ row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *
if (self->priv->mrl_column == -1)
return;
- g_signal_emit (G_OBJECT (tree_view), totem_video_list_table_signals[STARTING_VIDEO], 0,
- self,
- path,
- &play_video);
-
- if (play_video == FALSE)
- return;
-
+ /* Get the MRL and display name before emitting the signal, since the signal handler
+ * could clear the tree model */
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
self->priv->mrl_column, &mrl,
self->priv->tooltip_column, &display_name,
-1);
+ /* Emit the starting-video signal, to allow video playback to be cancelled */
+ g_signal_emit (tree_view, totem_video_list_table_signals[STARTING_VIDEO], 0,
+ path,
+ &play_video);
+
+ if (play_video == FALSE)
+ goto finish;
+g_message ("row_activated_cb: model: %lu, path: %lu, MRL col: %u, tt col: %u", model, path, self->priv->mrl_column, self->priv->tooltip_column);
+
if (mrl != NULL)
totem_add_to_playlist_and_play (self->priv->totem, mrl, display_name, FALSE);
+finish:
g_free (mrl);
g_free (display_name);
}
@@ -368,7 +372,7 @@ static gboolean
show_popup_menu (TotemVideoList *self, GdkEventButton *event)
{
guint button = 0;
- guint32 time;
+ guint32 _time;
GtkTreePath *path;
gint count;
GtkWidget *menu;
@@ -381,7 +385,7 @@ show_popup_menu (TotemVideoList *self, GdkEventButton *event)
if (event != NULL) {
button = event->button;
- time = event->time;
+ _time = event->time;
if (gtk_tree_view_get_path_at_pos (tree_view,
event->x, event->y, &path, NULL, NULL, NULL)) {
@@ -394,7 +398,7 @@ show_popup_menu (TotemVideoList *self, GdkEventButton *event)
gtk_tree_selection_unselect_all (selection);
}
} else {
- time = gtk_get_current_event_time ();
+ _time = gtk_get_current_event_time ();
}
count = gtk_tree_selection_count_selected_rows (selection);
@@ -432,7 +436,7 @@ show_popup_menu (TotemVideoList *self, GdkEventButton *event)
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- button, time);
+ button, _time);
return TRUE;
}
diff --git a/src/totemvideolist-marshal.list b/src/totemvideolist-marshal.list
index 1d1280d..70e7616 100644
--- a/src/totemvideolist-marshal.list
+++ b/src/totemvideolist-marshal.list
@@ -1 +1 @@
-BOOLEAN:OBJECT,OBJECT
+BOOLEAN:BOXED
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]