]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/iteminfo.cpp
* src/playlist/* && Makefile.am
[vlc] / modules / gui / wxwindows / iteminfo.cpp
index 9a69dfbe1ce526fb4b2d7cd3380f2e2756bd7ae7..f870abda896df0c7a814feed875fad6a3fd584d5 100644 (file)
@@ -2,7 +2,7 @@
  * iteminfo.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: iteminfo.cpp,v 1.2 2003/10/06 17:41:47 gbazin Exp $
+ * $Id: iteminfo.cpp,v 1.3 2003/10/29 17:32:54 zorglub Exp $
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *
@@ -66,14 +66,15 @@ enum
     Name_Event,
     Author_Event,
     Enabled_Event,
+    New_Event,
 };
 
 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
     /* Button events */
     EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
     EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
-
     /* Events generated by the panels */
+    EVT_BUTTON( New_Event, ItemInfoDialog::OnNewGroup)
 
 END_EVENT_TABLE()
 
@@ -213,41 +214,60 @@ wxPanel *ItemInfoDialog::GroupPanel( wxWindow* parent )
 {
     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                   wxDefaultSize );
-
     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
                                    wxU(_("Group Info")) );
-
     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
                                                          wxVERTICAL);
-
     wxBoxSizer *subpanel_sizer;
-
     group_subpanel = new wxPanel( panel, -1 );
-
     subpanel_sizer = new wxBoxSizer( wxVERTICAL) ;
-
     enabled_checkbox = new wxCheckBox( group_subpanel,
-                                     -1,
-                                     wxU(_("Item enabled")) );
+                                     -1, wxU(_("Item enabled")) );
 
     enabled_checkbox->SetValue( p_item->b_enabled);
 
     wxStaticText *group_label = new wxStaticText( group_subpanel,
                                         -1, wxU(_("Group")) );
-    group_spin = new wxSpinCtrl( group_subpanel,
-                                             -1 );
-    group_spin->SetValue( p_item->i_group > 0 ? p_item->i_group : 0);
+
+    playlist_t *p_playlist =
+                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                       FIND_ANYWHERE );
+    if( p_playlist == NULL )
+    {
+        return NULL;
+    }
+
+    group_combo = new wxComboBox( group_subpanel, -1,
+                                 wxT(""),wxDefaultPosition, wxDefaultSize,
+                                 0, NULL,
+                                 wxCB_READONLY );
+
+    wxButton *newgroup_button = new wxButton( group_subpanel, New_Event,
+                                    wxT(_("New Group")));
+
+    for( int i=0; i< p_playlist->i_groups ; i++)
+    {
+        group_combo->Append( wxT( p_playlist->pp_groups[i]->psz_name));
+    }
+
+    vlc_object_release ( p_playlist );
 
     subpanel_sizer->Add( enabled_checkbox, 0, wxALIGN_RIGHT|
                          wxALIGN_CENTER_VERTICAL );
     subpanel_sizer->Add( group_label, 0, wxALIGN_LEFT |
                          wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( group_spin, 0, wxALIGN_RIGHT );
+
+    wxBoxSizer *group_sizer = new wxBoxSizer( wxHORIZONTAL);
+    group_sizer->Add(group_combo, 0, wxALIGN_LEFT|wxRIGHT, 5);
+    group_sizer->Add( newgroup_button, 0, wxALIGN_RIGHT|wxLEFT, 5);
+    group_sizer->Layout();
+
+    subpanel_sizer->Add( group_sizer, 0, wxALIGN_RIGHT );
 
     group_subpanel->SetSizerAndFit( subpanel_sizer );
 
     /* Stuff everything into the main panel */
-     panel_sizer->Add( group_subpanel, 0,
+    panel_sizer->Add( group_subpanel, 0,
                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
 
     panel->SetSizerAndFit( panel_sizer );
@@ -276,11 +296,20 @@ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
         else if( b_old_enabled == VLC_TRUE && !enabled_checkbox->IsChecked() )
             p_playlist->i_enabled --;
 
+        for (int i=0 ; i< p_playlist->i_groups ; i++)
+        {
+           if( !strcasecmp( p_playlist->pp_groups[i]->psz_name,
+                           group_combo->GetValue() ))
+           {
+               p_item->i_group = p_playlist->pp_groups[i]->i_id;
+               break;
+           }
+        }
+
         vlc_object_release( p_playlist );
     }
 
     p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ;
-    p_item->i_group = group_spin->GetValue();
     EndModal( wxID_OK );
 }
 
@@ -289,6 +318,18 @@ void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
     EndModal( wxID_CANCEL );
 }
 
-/******************************************************************************
- * Info panel event methods.
- *****************************************************************************/
+void ItemInfoDialog::OnNewGroup( wxCommandEvent& WXUNUSED(event) )
+{
+    NewGroup *p_newgroup = NULL;
+
+    p_newgroup = new NewGroup( p_intf, this );
+
+    if( p_newgroup)
+    {
+        if( p_newgroup->ShowModal() == wxID_OK && p_newgroup->psz_name)
+        {
+            group_combo->Append( wxT( p_newgroup->psz_name));
+        }
+        delete( p_newgroup );
+    }
+}