]> git.sesse.net Git - vlc/commitdiff
* Allow service discoveries to state whether they prefer being displayed as tree
authorClément Stenac <zorglub@videolan.org>
Sat, 26 Aug 2006 16:51:55 +0000 (16:51 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 26 Aug 2006 16:51:55 +0000 (16:51 +0000)
* Start putting together all interface strings (Refs:#703)

include/vlc_input.h
include/vlc_intf_strings.h [new file with mode: 0644]
include/vlc_playlist.h
include/vlc_symbols.h
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/playlist_model.cpp
modules/services_discovery/shout.c
src/input/item.c
src/playlist/tree.c

index 75d2e642f27d2d51ae7c70af1bd13da0f9fdfec0..44e68a399e7a8e4ca9c1097dd8e5526906cdb36d 100644 (file)
@@ -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 (file)
index 0000000..03eb65b
--- /dev/null
@@ -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 <zorglub@videolan.org>
+ *
+ * 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
index 51c6a8d9f2a0a3e291050a70c0f35d77df7ecd27..f49fdeb56a669290c378b54e52f055d8b8c0c4f3 100644 (file)
@@ -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,
index a3659b5ab811ca0cdb81cda5e1d27df07073cddc..023d4ed5433fa852e55ef67da9982b1d67e794cb 100644 (file)
@@ -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; \
index 8f306ebb4ce4b0b97d4cdb6af75d1007b851b569..1a9724206ed8e34e49d5f0c4dd56f2935e67ac8a 100644 (file)
@@ -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 );
 }
 
index 916b858b6eef81b256d112a1c1c2a812cfb711c2..6511497dd4b1d9fd8d8160673063d931a7089a07 100644 (file)
@@ -30,6 +30,7 @@
 #include <QApplication>
 #include <QSignalMapper>
 #include "menus.hpp"
+#include <vlc_intf_strings.h>
 
 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;
index df871269ae378a4f50584a53903cc8689403e86e..5852ac979dc7c2d7aa5360b270afce1e8854ae26 100644 (file)
@@ -28,6 +28,7 @@
 #include "playlist_model.hpp"
 #include <assert.h>
 #include <QMenu>
+#include <vlc_intf_strings.h>
 
 #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<PLItem*>(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 );
     }
index 9038d70d0406096d4e07e6d4bd534e91d3313508..c6321aab37531e62aeee9aad37caaeb413470111 100644 (file)
@@ -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 );
index 6443d5964f3f5ed8e05395481d4d1355df9d57b2..40fb6d5acb87519bd2bd2f8bf9004f607e9a4b1e 100644 (file)
@@ -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 );
index 387a17e3b5ee6d5b2a4392aa90f00eca05dfddeb..90b3e5283bb23031111635769950f6fb7c36390c 100644 (file)
@@ -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