[totem] grilo: Use GdMainIconView for search results
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] grilo: Use GdMainIconView for search results
- Date: Thu, 13 Dec 2012 20:14:01 +0000 (UTC)
commit 5ad709a803b6b78fc9d6d153a66e406ee75e51f8
Author: Bastien Nocera <hadess hadess net>
Date: Thu Dec 13 21:13:23 2012 +0100
grilo: Use GdMainIconView for search results
configure.ac | 1 +
src/plugins/grilo/grilo.ui | 63 +++++++++++---------
src/plugins/grilo/totem-grilo.c | 125 +++++++++++++++++----------------------
3 files changed, 89 insertions(+), 100 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2bdbf37..776f679 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,6 +310,7 @@ PKG_CHECK_MODULES(PROPERTIES, gtk+-3.0 >= $GTK_REQS)
LIBGD_INIT([
tagged-entry
+ main-icon-view
static
])
diff --git a/src/plugins/grilo/grilo.ui b/src/plugins/grilo/grilo.ui
index ef3edc6..dd08028 100644
--- a/src/plugins/grilo/grilo.ui
+++ b/src/plugins/grilo/grilo.ui
@@ -19,18 +19,27 @@
</object>
<object class="GtkTreeStore" id="gw_browse_store_results">
<columns>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name uri -->
+ <column type="gchararray"/>
+ <!-- column-name primary_text -->
+ <column type="gchararray"/>
+ <!-- column-name secondary_text -->
+ <column type="gchararray"/>
+ <!-- column-name icon -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name mtime -->
+ <column type="gchararray"/>
+ <!-- column-name selected -->
+ <column type="gboolean"/>
+
<!-- column-name source -->
<column type="GObject"/>
<!-- column-name content -->
<column type="GObject"/>
- <!-- column-name thumbnail -->
- <column type="GdkPixbuf"/>
<!-- column-name is_prethumbnail -->
<column type="gboolean"/>
- <!-- column-name description -->
- <column type="gchararray"/>
- <!-- column-name duration -->
- <column type="gchararray"/>
<!-- column-name page -->
<column type="gint"/>
<!-- column-name remaining -->
@@ -57,19 +66,19 @@
<child>
<object class="GtkCellRendererPixbuf" id="gw_browse_col_render_pix"/>
<attributes>
- <attribute name="pixbuf">2</attribute>
+ <attribute name="pixbuf">4</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="gw_browse_col_render_desc"/>
<attributes>
- <attribute name="markup">4</attribute>
+ <attribute name="markup">2</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="gw_browse_col_render_dur"/>
<attributes>
- <attribute name="text">5</attribute>
+ <attribute name="text">3</attribute>
</attributes>
</child>
</object>
@@ -123,25 +132,10 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkIconView" id="gw_search_results_view">
+ <object class="GdMainIconView" id="gw_search_results_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">gw_search_store_results</property>
- <child>
- <object class="GtkCellRendererPixbuf" id="gw_search_result_thumbnail"/>
- <attributes>
- <attribute name="pixbuf">2</attribute>
- </attributes>
- </child>
- <child>
- <object class="GtkCellRendererText" id="gw_search_result_description">
- <property name="ellipsize">end</property>
- <property name="scale">0.75</property>
- </object>
- <attributes>
- <attribute name="markup">4</attribute>
- </attributes>
- </child>
</object>
</child>
</object>
@@ -154,16 +148,27 @@
</object>
<object class="GtkListStore" id="gw_search_store_results">
<columns>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name uri -->
+ <column type="gchararray"/>
+ <!-- column-name primary_text -->
+ <column type="gchararray"/>
+ <!-- column-name secondary_text -->
+ <column type="gchararray"/>
+ <!-- column-name icon -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name mtime -->
+ <column type="gchararray"/>
+ <!-- column-name selected -->
+ <column type="gboolean"/>
+
<!-- column-name source -->
<column type="GObject"/>
<!-- column-name content -->
<column type="GObject"/>
- <!-- column-name thumbnail -->
- <column type="GdkPixbuf"/>
<!-- column-name is_prethumbnail -->
<column type="gboolean"/>
- <!-- column-name description -->
- <column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="gw_search_store_sources">
diff --git a/src/plugins/grilo/totem-grilo.c b/src/plugins/grilo/totem-grilo.c
index 4272c93..c5da8d2 100644
--- a/src/plugins/grilo/totem-grilo.c
+++ b/src/plugins/grilo/totem-grilo.c
@@ -47,6 +47,7 @@
#include <totem-time-helpers.h>
#include "totem-search-entry.h"
+#include <libgd/gd.h>
#define TOTEM_TYPE_GRILO_PLUGIN \
(totem_grilo_plugin_get_type ())
@@ -147,12 +148,9 @@ enum {
};
enum {
- MODEL_RESULTS_SOURCE = 0,
+ MODEL_RESULTS_SOURCE = GD_MAIN_COLUMN_LAST,
MODEL_RESULTS_CONTENT,
- MODEL_RESULTS_THUMBNAIL,
MODEL_RESULTS_IS_PRETHUMBNAIL,
- MODEL_RESULTS_DESCRIPTION,
- MODEL_RESULTS_DURATION,
MODEL_RESULTS_PAGE,
MODEL_RESULTS_REMAINING,
};
@@ -163,23 +161,18 @@ static void play (TotemGriloPlugin *self,
gboolean resolve_url);
static gchar *
-get_description (GrlMedia *media)
+get_secondary_text (GrlMedia *media)
{
- const gchar *author;
-
- author = grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_AUTHOR);
- if (author == NULL) {
- author = grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_ARTIST);
- }
-
- if (author != NULL) {
- return g_markup_printf_escaped ("<b>%s</b>\n%s",
- grl_media_get_title (media),
- author);
- } else {
- return g_markup_printf_escaped ("<b>%s</b>",
- grl_media_get_title (media));
- }
+ const char *artist;
+ int duration;
+
+ artist = grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_ARTIST);
+ if (artist != NULL)
+ return g_strdup (artist);
+ duration = grl_media_get_duration (media);
+ if (duration > 0)
+ return totem_time_to_string (duration * 1000);
+ return NULL;
}
static GList *
@@ -285,7 +278,7 @@ get_stream_thumbnail_cb (GObject *source_object,
if (thumbnail) {
gtk_list_store_set (GTK_LIST_STORE (thumb_data->totem_grilo->priv->search_results_model),
&iter,
- MODEL_RESULTS_THUMBNAIL, thumbnail,
+ GD_MAIN_COLUMN_ICON, thumbnail,
-1);
/* Cache it */
g_hash_table_insert (thumb_data->totem_grilo->priv->cache_thumbnails,
@@ -332,7 +325,7 @@ set_thumbnail_async (TotemGriloPlugin *self, GrlMedia *media, GtkTreePath *path,
gtk_tree_model_get_iter (self->priv->search_results_model, &iter, path);
gtk_list_store_set (GTK_LIST_STORE (self->priv->search_results_model),
&iter,
- MODEL_RESULTS_THUMBNAIL, thumbnail,
+ GD_MAIN_COLUMN_ICON, thumbnail,
-1);
}
} else {
@@ -413,8 +406,8 @@ show_sources (TotemGriloPlugin *self)
&iter,
MODEL_RESULTS_SOURCE, source->data,
MODEL_RESULTS_CONTENT, NULL,
- MODEL_RESULTS_DESCRIPTION, name,
- MODEL_RESULTS_THUMBNAIL, icon,
+ GD_MAIN_COLUMN_PRIMARY_TEXT, name,
+ GD_MAIN_COLUMN_ICON, icon,
MODEL_RESULTS_IS_PRETHUMBNAIL, FALSE,
-1);
if (icon != NULL) {
@@ -432,9 +425,6 @@ browse_cb (GrlSource *source,
gpointer user_data,
const GError *error)
{
- gchar *description;
- gchar *pretty_duration;
- gint duration;
GtkTreeIter iter;
GdkPixbuf *thumbnail;
BrowseUserData *bud;
@@ -466,31 +456,26 @@ browse_cb (GrlSource *source,
-1);
/* Filter images */
if (GRL_IS_MEDIA_IMAGE (media) == FALSE) {
+ char *secondary;
+
thumbnail = get_icon (self, media, THUMB_BROWSE_SIZE);
- description = get_description (media);
- duration = grl_media_get_duration (media);
- if (duration > 0) {
- pretty_duration = totem_time_to_string (duration * 1000);
- } else {
- pretty_duration = NULL;
- }
+ secondary = get_secondary_text (media);
gtk_tree_store_append (GTK_TREE_STORE (self->priv->browser_model), &iter, &parent);
gtk_tree_store_set (GTK_TREE_STORE (self->priv->browser_model),
&iter,
MODEL_RESULTS_SOURCE, source,
MODEL_RESULTS_CONTENT, media,
- MODEL_RESULTS_THUMBNAIL, thumbnail,
+ GD_MAIN_COLUMN_ICON, thumbnail,
MODEL_RESULTS_IS_PRETHUMBNAIL, TRUE,
- MODEL_RESULTS_DESCRIPTION, description,
- MODEL_RESULTS_DURATION, pretty_duration,
+ GD_MAIN_COLUMN_PRIMARY_TEXT, grl_media_get_title (media),
+ GD_MAIN_COLUMN_SECONDARY_TEXT, secondary,
-1);
if (thumbnail != NULL) {
g_object_unref (thumbnail);
}
- g_free (description);
- g_free (pretty_duration);
+ g_free (secondary);
path = gtk_tree_model_get_path (self->priv->browser_model, &parent);
gtk_tree_view_expand_row (GTK_TREE_VIEW (self->priv->browser), path, FALSE);
@@ -608,8 +593,6 @@ search_cb (GrlSource *source,
gpointer user_data,
const GError *error)
{
- gchar *description;
- GtkTreeIter iter;
GdkPixbuf *thumbnail;
GtkWindow *window;
TotemGriloPlugin *self;
@@ -628,23 +611,24 @@ search_cb (GrlSource *source,
self->priv->search_remaining--;
/* Filter images */
if (GRL_IS_MEDIA_IMAGE (media) == FALSE) {
+ char *secondary;
thumbnail = get_icon (self, media, THUMB_SEARCH_SIZE);
- description = get_description (media);
-
- gtk_list_store_append (GTK_LIST_STORE (self->priv->search_results_model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (self->priv->search_results_model),
- &iter,
- MODEL_RESULTS_SOURCE, source,
- MODEL_RESULTS_CONTENT, media,
- MODEL_RESULTS_THUMBNAIL, thumbnail,
- MODEL_RESULTS_IS_PRETHUMBNAIL, TRUE,
- MODEL_RESULTS_DESCRIPTION, description,
- -1);
+ secondary = get_secondary_text (media);
+
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (self->priv->search_results_model),
+ NULL, -1,
+ MODEL_RESULTS_SOURCE, source,
+ MODEL_RESULTS_CONTENT, media,
+ GD_MAIN_COLUMN_ICON, thumbnail,
+ MODEL_RESULTS_IS_PRETHUMBNAIL, TRUE,
+ GD_MAIN_COLUMN_PRIMARY_TEXT, grl_media_get_title (media),
+ GD_MAIN_COLUMN_SECONDARY_TEXT, secondary,
+ -1);
if (thumbnail != NULL) {
g_object_unref (thumbnail);
}
- g_free (description);
+ g_free (secondary);
}
g_object_unref (media);
@@ -864,10 +848,7 @@ source_added_cb (GrlRegistry *registry,
gpointer user_data)
{
const gchar *name;
- gchar *description;
- GdkPixbuf *icon;
TotemGriloPlugin *self;
- GtkTreeIter iter;
GrlSupportedOps ops;
if (source_is_blacklisted (source)) {
@@ -878,34 +859,36 @@ source_added_cb (GrlRegistry *registry,
}
self = TOTEM_GRILO_PLUGIN (user_data);
- icon = load_icon (self, ICON_BOX, THUMB_BROWSE_SIZE);
name = grl_source_get_name (source);
ops = grl_source_supported_operations (source);
if (ops & GRL_OP_BROWSE) {
+ GdkPixbuf *icon;
+ char *description;
+
+ icon = load_icon (self, ICON_BOX, THUMB_BROWSE_SIZE);
+
description = g_markup_printf_escaped ("<b>%s</b>", name);
- gtk_tree_store_append (GTK_TREE_STORE (self->priv->browser_model), &iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (self->priv->browser_model),
- &iter,
- MODEL_RESULTS_SOURCE, source,
- MODEL_RESULTS_CONTENT, NULL,
- MODEL_RESULTS_DESCRIPTION, description,
- MODEL_RESULTS_THUMBNAIL, icon,
- MODEL_RESULTS_IS_PRETHUMBNAIL, TRUE,
- -1);
+ gtk_tree_store_insert_with_values (GTK_TREE_STORE (self->priv->browser_model),
+ NULL, NULL, -1,
+ MODEL_RESULTS_SOURCE, source,
+ MODEL_RESULTS_CONTENT, NULL,
+ GD_MAIN_COLUMN_PRIMARY_TEXT, description,
+ GD_MAIN_COLUMN_ICON, icon,
+ MODEL_RESULTS_IS_PRETHUMBNAIL, TRUE,
+ -1);
g_free (description);
+ if (icon != NULL) {
+ g_object_unref (icon);
+ }
}
if (ops & GRL_OP_SEARCH) {
/* FIXME:
* Handle tracker/filesystem specifically, so that we have a "local" entry here */
totem_search_entry_add_source (TOTEM_SEARCH_ENTRY (self->priv->search_entry),
grl_source_get_id (source),
- grl_source_get_name (source),
+ name,
0); /* FIXME: Use correct priority */
}
-
- if (icon != NULL) {
- g_object_unref (icon);
- }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]