From 234ad89592485fbfbae4c9e5b47466a9f57f2cf7 Mon Sep 17 00:00:00 2001 From: nedko Date: Sat, 18 Sep 2004 21:34:35 +0000 Subject: [PATCH] Return media name, media type and media location when searching files. --- gtk/search.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- libdb/libdb.h | 8 +++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/gtk/search.c b/gtk/search.c index ae8d9cf..84a3662 100644 --- a/gtk/search.c +++ b/gtk/search.c @@ -1,7 +1,7 @@ /* -*- Mode: C ; c-basic-offset: 2 -*- */ /***************************************************************************** * - * $Id: search.c,v 1.3 2004/09/01 05:05:43 nedko Exp $ + * $Id: search.c,v 1.4 2004/09/18 21:34:59 nedko Exp $ * * DESCRIPTION: * @@ -39,6 +39,7 @@ enum COL_MEDIAID, COL_MEDIAICON, COL_MEDIANAME, + COL_MEDIALOCATION, NUM_COLS }; @@ -58,6 +59,9 @@ void SearchCallback( void *pUserContext, mediadb_uint nMediaID, + mediadb_mediatype nMediaType, + const char *pszMediaName, + const char *pszMediaLocation, const char *pszPath, const char *pszName, mediadb_filetype Filetype, @@ -66,6 +70,7 @@ SearchCallback( { struct tm tm; GdkPixbuf * pIcon; + GdkPixbuf * pMediaIcon; time_t time = nTime; GtkTreeIter Iter; char strTime[26]; @@ -116,6 +121,23 @@ SearchCallback( error = NULL; } + if (*pszPathToExecutable == 0) + { + snprintf(strIcon, sizeof(strIcon)-1, "icon_cd.png"); + } + else + { + snprintf(strIcon, sizeof(strIcon)-1, "%s/icon_cd.png", pszPathToExecutable); + } + strIcon[sizeof(strIcon)-1] = 0; + pMediaIcon = gdk_pixbuf_new_from_file(strIcon, &error); + if (error) + { + g_warning("Could not load icon: %s\n", error->message); + g_error_free(error); + error = NULL; + } + gtk_list_store_append( GTK_LIST_STORE( g_object_get_data( @@ -133,6 +155,10 @@ SearchCallback( COL_NAME, pszFullPath, COL_SIZE, (Filetype == MEDIADB_FILETYPE_DIR)?NULL:strSize, COL_TIME, strTime, + COL_MEDIAID, (unsigned int)nMediaID, + COL_MEDIAICON, pMediaIcon, + COL_MEDIANAME, pszMediaName, + COL_MEDIALOCATION, pszMediaLocation, -1); g_free(pszFullPath); @@ -810,6 +836,18 @@ ShowSearchWindow() GTK_TREE_VIEW(pChild), pColumn); + /* --- Column #6 --- */ + + pColumn = gtk_tree_view_column_new_with_attributes( + "Location", + pRendererText, + "text", COL_MEDIALOCATION, + NULL); + + gtk_tree_view_append_column( + GTK_TREE_VIEW(pChild), + pColumn); + /* Create the store */ pListStore = gtk_list_store_new( NUM_COLS, @@ -819,7 +857,8 @@ ShowSearchWindow() G_TYPE_STRING, /* COL_TIME */ G_TYPE_UINT, /* COL_MEDIAID */ GDK_TYPE_PIXBUF, /* COL_MEDIAICON */ - G_TYPE_STRING); /* COL_MEDIANAME */ + G_TYPE_STRING, /* COL_MEDIANAME */ + G_TYPE_STRING); /* COL_MEDIALOCATION */ /* Create a new scrolled window, with scrollbars only if needed */ @@ -860,6 +899,9 @@ ShowSearchWindow() * !!! WARNING !!! Following lines are automatically updated by the CVS system. * * $Log: search.c,v $ + * Revision 1.4 2004/09/18 21:34:59 nedko + * Return media name, media type and media location when searching files. + * * Revision 1.3 2004/09/01 05:05:43 nedko * Search partitially works. * diff --git a/libdb/libdb.h b/libdb/libdb.h index 983952c..5f0494e 100644 --- a/libdb/libdb.h +++ b/libdb/libdb.h @@ -1,7 +1,7 @@ /* -*- Mode: C ; c-basic-offset: 2 -*- */ /***************************************************************************** * - * $Id: libdb.h,v 1.8 2004/08/31 22:40:15 nedko Exp $ + * $Id: libdb.h,v 1.9 2004/09/18 21:34:35 nedko Exp $ * * DESCRIPTION: * Unified access to database. @@ -194,6 +194,9 @@ mediadb_get_pattern_match_methods( typedef void (* mediadb_files_search_callback)( void *pUserContext, mediadb_uint nMediaID, + mediadb_mediatype nMediaType, + const char *pszMediaName, + const char *pszMediaLocation, const char *pszPath, const char *pszName, mediadb_filetype Filetype, @@ -221,6 +224,9 @@ mediadb_files_search( * !!! WARNING !!! Following lines are automatically updated by the CVS system. * * $Log: libdb.h,v $ + * Revision 1.9 2004/09/18 21:34:35 nedko + * Return media name, media type and media location when searching files. + * * Revision 1.8 2004/08/31 22:40:15 nedko * Partitally implemented search feature. * -- 2.11.4.GIT