From: Clément Stenac Date: Sat, 26 Aug 2006 16:51:55 +0000 (+0000) Subject: * Allow service discoveries to state whether they prefer being displayed as tree X-Git-Tag: 0.9.0-test0~10564 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=6a42cf33fbe64397e701a930057bac60b2835185;p=vlc * Allow service discoveries to state whether they prefer being displayed as tree * Start putting together all interface strings (Refs:#703) --- diff --git a/include/vlc_input.h b/include/vlc_input.h index 75d2e642f2..44e68a399e 100644 --- a/include/vlc_input.h +++ b/include/vlc_input.h @@ -62,6 +62,7 @@ struct input_item_t mtime_t i_duration; /**< Duration in milliseconds*/ uint8_t i_type; /**< Type (file, disc, ...) */ + vlc_bool_t b_prefers_tree; /**< Do we prefer being displayed as tree*/ int i_categories; /**< Number of info categories */ info_category_t **pp_categories; /**< Pointer to the first info category */ diff --git a/include/vlc_intf_strings.h b/include/vlc_intf_strings.h new file mode 100644 index 0000000000..03eb65b4ea --- /dev/null +++ b/include/vlc_intf_strings.h @@ -0,0 +1,42 @@ +/***************************************************************************** + * vlc_intf_strings.h : Strings for main interfaces + ***************************************************************************** + * Copyright (C) 2003 the VideoLAN team + * $Id: vlc_config_cat.h 16001 2006-07-09 15:01:13Z dionoea $ + * + * Authors: Clément Stenac + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef _VLC_ISTRINGS_H +#define _VLC_ISTRINGS_H 1 + +/*************** Open dialogs **************/ + +#define I_POP_SEL_FILES N_("Select one or more files to open") + +/******************* Menus *****************/ + +/* Playlist popup */ +#define I_POP_PLAY N_("Play") +#define I_POP_PREPARSE N_("Fetch information") +#define I_POP_DEL N_("Delete") +#define I_POP_INFO N_("Information") +#define I_POP_SORT N_("Sort") +#define I_POP_ADD N_("Add node") + + +#endif diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index 51c6a8d9f2..f49fdeb56a 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -135,6 +135,9 @@ struct playlist_t playlist_item_t * p_local_onelevel; /** < "Playlist" in ONELEVEL view */ playlist_item_t * p_ml_onelevel; /** < "Library" in ONELEVEL iew */ + vlc_bool_t b_always_tree;/**< Always display as tree */ + vlc_bool_t b_never_tree;/**< Never display as tree */ + /* Runtime */ input_thread_t * p_input; /**< the input thread associated * with the current item */ @@ -410,6 +413,7 @@ VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, cons VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, vlc_bool_t , vlc_bool_t ) ); VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, vlc_bool_t ) ); VLC_EXPORT( void, playlist_NodesCreateForSD, (playlist_t *, char *, playlist_item_t **, playlist_item_t ** ) ); +VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playlist, playlist_item_t *p_node ) ); /* Tree walking - These functions are only for playlist, not plugins */ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist, diff --git a/include/vlc_symbols.h b/include/vlc_symbols.h index a3659b5ab8..023d4ed543 100644 --- a/include/vlc_symbols.h +++ b/include/vlc_symbols.h @@ -530,6 +530,7 @@ struct module_symbols_t int (*vlc_DictLookup_inner) (dict_t *, int, const char *); void (*vlc_DictClear_inner) (dict_t *); dict_t * (*vlc_DictNew_inner) (void); + playlist_item_t * (*playlist_GetPreferredNode_inner) (playlist_t *p_playlist, playlist_item_t *p_node); }; # if defined (__PLUGIN__) # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner @@ -995,6 +996,7 @@ struct module_symbols_t # define vlc_DictLookup (p_symbols)->vlc_DictLookup_inner # define vlc_DictClear (p_symbols)->vlc_DictClear_inner # define vlc_DictNew (p_symbols)->vlc_DictNew_inner +# define playlist_GetPreferredNode (p_symbols)->playlist_GetPreferredNode_inner # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) /****************************************************************** * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. @@ -1463,6 +1465,7 @@ struct module_symbols_t ((p_symbols)->vlc_DictLookup_inner) = vlc_DictLookup; \ ((p_symbols)->vlc_DictClear_inner) = vlc_DictClear; \ ((p_symbols)->vlc_DictNew_inner) = vlc_DictNew; \ + ((p_symbols)->playlist_GetPreferredNode_inner) = playlist_GetPreferredNode; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->__playlist_ItemNew_deprecated = NULL; \ (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 8f306ebb4c..1a9724206e 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -132,6 +132,8 @@ void StandardPLPanel::setRoot( int i_root_id ) { playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id ); assert( p_item ); + p_item = playlist_GetPreferredNode( THEPL, p_item ); + assert( p_item ); model->rebuild( p_item ); } diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp index 916b858b6e..6511497dd4 100644 --- a/modules/gui/qt4/dialogs_provider.cpp +++ b/modules/gui/qt4/dialogs_provider.cpp @@ -30,6 +30,7 @@ #include #include #include "menus.hpp" +#include DialogsProvider* DialogsProvider::instance = NULL; @@ -198,9 +199,7 @@ void DialogsProvider::simpleOpenDialog() FileTypes.replace(QString(";*"), QString(" *")); QStringList fileList = QFileDialog::getOpenFileNames( - NULL, - qtr("Select one or more files to open"), - p_intf->p_vlc->psz_homedir, + NULL, qfu(I_POP_SEL_FILES ), p_intf->p_vlc->psz_homedir, FileTypes); QStringList files = fileList; diff --git a/modules/gui/qt4/playlist_model.cpp b/modules/gui/qt4/playlist_model.cpp index df871269ae..5852ac979d 100644 --- a/modules/gui/qt4/playlist_model.cpp +++ b/modules/gui/qt4/playlist_model.cpp @@ -28,6 +28,7 @@ #include "playlist_model.hpp" #include #include +#include #include "pixmaps/type_unknown.xpm" #include "pixmaps/type_afile.xpm" @@ -110,7 +111,7 @@ void PLItem::remove( PLItem *removed ) int PLItem::row() const { - if (parentItem) + if( parentItem ) return parentItem->children.indexOf(const_cast(this)); return 0; } @@ -285,7 +286,8 @@ QModelIndex PLModel::index( PLItem *item, int column ) const if( !item ) return QModelIndex(); const PLItem *parent = item->parent(); if( parent ) - return createIndex( parent->children.lastIndexOf( item ), column, item ); + return createIndex( parent->children.lastIndexOf( item ), + column, item ); return QModelIndex(); } @@ -297,6 +299,11 @@ QModelIndex PLModel::parent(const QModelIndex &index) const if( !childItem ) { msg_Err( p_playlist, "NULL CHILD \n" ); return QModelIndex(); } PLItem *parentItem = childItem->parent(); if( !parentItem || parentItem == rootItem ) return QModelIndex(); + if( ! parentItem->parentItem ) + { + msg_Err( p_playlist, "No parent parent, trying row 0 ----- PLEASE REPORT THIS ------" ); + return createIndex( 0, 0, parentItem ); + } QModelIndex ind = createIndex(parentItem->row(), 0, parentItem); return ind; } @@ -642,16 +649,15 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) PL_UNLOCK; current_selection = list; QMenu *menu = new QMenu; - menu->addAction( qtr("Play"), this, SLOT( popupPlay() ) ); - menu->addAction( qtr("Fetch information"), this, - SLOT( popupPreparse() ) ); - menu->addAction( qtr("Delete"), this, SLOT( popupDel() ) ); - menu->addAction( qtr("Information"), this, SLOT( popupInfo() ) ); + menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) ); + menu->addAction( qfu(I_POP_PREPARSE), this, SLOT( popupPreparse() ) ); + menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) ); + menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) ); if( p_item->i_children > -1 ) { menu->addSeparator(); - menu->addAction( qtr("Sort"), this, SLOT( popupSort() ) ); - menu->addAction( qtr("Add node"), this, SLOT( popupAdd() ) ); + menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) ); + menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) ); } menu->popup( point ); } diff --git a/modules/services_discovery/shout.c b/modules/services_discovery/shout.c index 9038d70d04..c6321aab37 100644 --- a/modules/services_discovery/shout.c +++ b/modules/services_discovery/shout.c @@ -154,6 +154,7 @@ static int Open( vlc_object_t *p_this, int i_type ) 0, NULL, -1 ); break; } + p_sys->p_input->b_prefers_tree = VLC_TRUE; p_sys->p_node_cat = playlist_NodeAddInput( p_playlist, p_sys->p_input, p_playlist->p_root_category, PLAYLIST_APPEND, PLAYLIST_END ); diff --git a/src/input/item.c b/src/input/item.c index 6443d5964f..40fb6d5acb 100644 --- a/src/input/item.c +++ b/src/input/item.c @@ -256,6 +256,7 @@ input_item_t *input_ItemNewWithType( vlc_object_t *p_obj, const char *psz_uri, p_input->psz_name = strdup ( p_input->psz_uri ); p_input->i_type = i_type; + p_input->b_prefers_tree = VLC_FALSE; if( p_input->i_type == ITEM_TYPE_UNKNOWN ) GuessType( p_input ); diff --git a/src/playlist/tree.c b/src/playlist/tree.c index 387a17e3b5..90b3e5283b 100644 --- a/src/playlist/tree.c +++ b/src/playlist/tree.c @@ -304,6 +304,34 @@ void playlist_NodesCreateForSD( playlist_t *p_playlist, char *psz_name, (*pp_node_one)->p_input->i_id = (*pp_node_cat)->p_input->i_id; } +playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist, + playlist_item_t *p_node ) +{ + int i; + if( p_node->p_parent == p_playlist->p_root_category ) + { + if( p_playlist->b_always_tree || + p_node->p_input->b_prefers_tree ) return p_node; + for( i = 0 ; i< p_playlist->p_root_onelevel->i_children; i++ ) + { + if( p_playlist->p_root_onelevel->pp_children[i]->p_input->i_id == + p_node->p_input->i_id ) + return p_playlist->p_root_onelevel->pp_children[i]; + } + } + else if( p_node->p_parent == p_playlist->p_root_onelevel ) + { + if( p_playlist->b_never_tree || !p_node->p_input->b_prefers_tree ) + return p_node; + for( i = 0 ; i< p_playlist->p_root_category->i_children; i++ ) + { + if( p_playlist->p_root_category->pp_children[i]->p_input->i_id == + p_node->p_input->i_id ) + return p_playlist->p_root_category->pp_children[i]; + } + } + return NULL; +} /********************************************************************** * Tree walking functions