From a9899491dc1ff2cfc3ae3808b8d702d94694e810 Mon Sep 17 00:00:00 2001
From: Derk-Jan Hartman <hartman@videolan.org>
Date: Mon, 17 Feb 2003 10:52:07 +0000
Subject: [PATCH] * Whoops. i forgot to add these files. sorry everyone.

---
 modules/gui/macosx/Modules.am |   2 +
 modules/gui/macosx/info.h     |  48 ++++++++++
 modules/gui/macosx/info.m     | 164 ++++++++++++++++++++++++++++++++++
 3 files changed, 214 insertions(+)
 create mode 100644 modules/gui/macosx/info.h
 create mode 100644 modules/gui/macosx/info.m

diff --git a/modules/gui/macosx/Modules.am b/modules/gui/macosx/Modules.am
index 8f9c1bca80cf..d25cb4a9cb74 100644
--- a/modules/gui/macosx/Modules.am
+++ b/modules/gui/macosx/Modules.am
@@ -3,6 +3,8 @@ SOURCES_macosx = \
 	modules/gui/macosx/controls.m \
 	modules/gui/macosx/intf.m \
 	modules/gui/macosx/intf.h \
+	modules/gui/macosx/info.h \
+	modules/gui/macosx/info.m \
 	modules/gui/macosx/macosx.m \
 	modules/gui/macosx/misc.m \
 	modules/gui/macosx/misc.h \
diff --git a/modules/gui/macosx/info.h b/modules/gui/macosx/info.h
new file mode 100644
index 000000000000..a0b35dee3fc7
--- /dev/null
+++ b/modules/gui/macosx/info.h
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * info.h: MacOS X info panel
+ *****************************************************************************
+ * Copyright (C) 2002 VideoLAN
+ * $Id: info.h,v 1.1 2003/02/17 10:52:07 hartman Exp $
+ *
+ * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+
+#import <Cocoa/Cocoa.h>
+
+
+/*****************************************************************************
+ * VLCInfo interface 
+ *****************************************************************************/
+@interface VLCInfo : NSObject {
+
+    IBOutlet id o_info_window;
+    IBOutlet id o_info_view;
+    IBOutlet id o_info_selector;
+    
+    intf_thread_t *p_intf;
+    NSMutableDictionary *o_info_strings;
+}
+
+- (IBAction)toggleInfoPanel:(id)sender;
+- (IBAction)showCategory:(id)sender;
+- (void)updateInfo;
+- (void)createInfoView:(input_info_category_t *)p_category;
+
+@end
\ No newline at end of file
diff --git a/modules/gui/macosx/info.m b/modules/gui/macosx/info.m
new file mode 100644
index 000000000000..5d36f98bf687
--- /dev/null
+++ b/modules/gui/macosx/info.m
@@ -0,0 +1,164 @@
+/*****************************************************************************
+ * info.m: MacOS X info panel
+ *****************************************************************************
+ * Copyright (C) 2002 VideoLAN
+ * $Id: info.m,v 1.1 2003/02/17 10:52:07 hartman Exp $
+ *
+ * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "intf.h"
+
+#import "info.h"
+
+/*****************************************************************************
+ * VLCInfo implementation 
+ *****************************************************************************/
+@implementation VLCInfo
+
+- (id)init
+{
+    self = [super init];
+
+    if( self != nil )
+    {
+        p_intf = [NSApp getIntf];
+        
+        o_info_strings = [[NSMutableDictionary alloc] init];
+    }
+
+    return( self );
+}
+
+- (void)dealloc
+{
+    [o_info_strings release];
+
+    [super dealloc];
+}
+
+- (IBAction)toggleInfoPanel:(id)sender
+{
+    if ( [o_info_window isVisible] )
+    {
+        [o_info_window orderOut:sender];
+    }
+    else
+    {
+        [o_info_window orderFront:sender];
+        [self updateInfo];
+    }
+}
+
+- (IBAction)showCategory:(id)sender
+{
+    NSString *o_selected = [o_info_selector titleOfSelectedItem];
+    [o_info_view setString:(NSString *)[o_info_strings objectForKey: o_selected]];
+    [o_info_view setNeedsDisplay: YES];
+}
+
+- (void)updateInfo
+{
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+    
+    if( p_playlist == NULL )
+    {
+        [o_info_window orderOut:self];
+        return;
+    }
+    
+    if ( p_playlist->p_input == NULL )
+    {
+        [o_info_window orderOut:self];
+        vlc_object_release( p_playlist );
+        return;
+    }
+
+    [o_info_strings removeAllObjects];
+    [o_info_selector removeAllItems];
+    [o_info_view setDrawsBackground: NO];
+    [[[o_info_view superview] superview] setDrawsBackground: NO];
+    [o_info_window setExcludedFromWindowsMenu:YES];
+    
+    vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
+    input_info_category_t *p_category = p_playlist->p_input->stream.p_info;
+    while ( p_category )
+    {
+        [self createInfoView: p_category ];
+        p_category = p_category->p_next;
+    }
+    vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+    vlc_object_release( p_playlist );
+    
+    [o_info_selector selectItemAtIndex: 0];
+    [self showCategory:o_info_selector];
+}
+
+- (void)createInfoView:(input_info_category_t *)p_category
+{
+    /* Add a catecory */
+    NSString *title = [NSString stringWithCString: p_category->psz_name];
+    [o_info_selector addItemWithTitle: title];
+    
+    /* Create the textfield content */
+    NSMutableString *catString = [NSMutableString string];
+    
+    /* Add the fields */
+    input_info_t *p_info = p_category->p_info;
+    while ( p_info )
+    {
+        [catString appendFormat: @"%s: %s\n\n", p_info->psz_name, p_info->psz_value];
+        p_info = p_info->p_next;
+    }
+    [o_info_strings setObject: catString forKey: title];
+}
+
+@end
+
+@implementation VLCInfo (NSMenuValidation)
+ 
+- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
+{
+    BOOL bEnabled = TRUE;
+
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+
+    if( p_playlist != NULL )
+    {
+        vlc_mutex_lock( &p_playlist->object_lock );
+    }
+
+    if( [[o_mi title] isEqualToString: _NS("Info")] )
+    {
+        if( p_playlist == NULL || p_playlist->p_input == NULL )
+        {
+            bEnabled = FALSE;
+        }
+    }
+    
+    if( p_playlist != NULL )
+    {
+        vlc_mutex_unlock( &p_playlist->object_lock );
+        vlc_object_release( p_playlist );
+    }
+
+    return( bEnabled );
+}
+
+@end
\ No newline at end of file
-- 
GitLab