1 /*****************************************************************************
2 * familiar.c : familiar plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: familiar.c,v 1.10 2002/10/14 16:46:55 sam Exp $
7 * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
37 #include "callbacks.h"
38 #include "interface.h"
42 /*****************************************************************************
44 *****************************************************************************/
45 static int Open ( vlc_object_t
* );
46 static void Close ( vlc_object_t
* );
48 static void Run ( intf_thread_t
* );
50 /*****************************************************************************
52 *****************************************************************************/
54 set_description( _("Familiar Linux Gtk+ interface module") );
55 set_capability( "interface", 70 );
56 set_callbacks( Open
, Close
);
59 /*****************************************************************************
60 * Open: initialize and create window
61 *****************************************************************************/
62 static int Open( vlc_object_t
*p_this
)
64 intf_thread_t
*p_intf
= (intf_thread_t
*)p_this
;
66 /* Allocate instance and initialize some members */
67 p_intf
->p_sys
= malloc( sizeof( intf_sys_t
) );
68 if( p_intf
->p_sys
== NULL
)
70 msg_Err( p_intf
, "out of memory" );
74 p_intf
->p_sys
->p_gtk_main
= module_Need( p_this
, "gtk_main", "gtk" );
75 if( p_intf
->p_sys
->p_gtk_main
== NULL
)
77 free( p_intf
->p_sys
);
81 /* Initialize Gtk+ thread */
82 p_intf
->p_sys
->p_input
= NULL
;
84 p_intf
->p_sys
->b_autoplayfile
= 1;
91 /*****************************************************************************
92 * Close: destroy interface window
93 *****************************************************************************/
94 static void Close( vlc_object_t
*p_this
)
96 intf_thread_t
*p_intf
= (intf_thread_t
*)p_this
;
98 if( p_intf
->p_sys
->p_input
)
100 vlc_object_release( p_intf
->p_sys
->p_input
);
103 module_Unneed( p_intf
, p_intf
->p_sys
->p_gtk_main
);
105 /* Destroy structure */
106 free( p_intf
->p_sys
);
109 /*****************************************************************************
111 *****************************************************************************
112 * this part of the interface is in a separate thread so that we can call
113 * gtk_main() from within it without annoying the rest of the program.
114 *****************************************************************************/
115 static void Run( intf_thread_t
*p_intf
)
119 /* Create some useful widgets that will certainly be used */
121 add_pixmap_directory("share");
122 p_intf
->p_sys
->p_window
= create_familiar();
123 if (p_intf
->p_sys
->p_window
== NULL
)
125 msg_Err( p_intf
, "unable to create familiar interface" );
128 /* Set the title of the main window */
129 gtk_window_set_title( GTK_WINDOW(p_intf
->p_sys
->p_window
),
130 VOUT_TITLE
" (Familiar Linux interface)");
132 p_intf
->p_sys
->p_notebook
= GTK_NOTEBOOK( gtk_object_get_data(
133 GTK_OBJECT( p_intf
->p_sys
->p_window
), "notebook" ) );
134 // gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
136 p_intf
->p_sys
->p_progess
= GTK_PROGRESS_BAR( gtk_object_get_data(
137 GTK_OBJECT( p_intf
->p_sys
->p_window
), "progress" ) );
138 gtk_widget_hide( GTK_WIDGET(p_intf
->p_sys
->p_progess
) );
140 p_intf
->p_sys
->p_clist
= GTK_CLIST( gtk_object_get_data(
141 GTK_OBJECT( p_intf
->p_sys
->p_window
), "clistmedia" ) );
142 gtk_clist_set_column_visibility (GTK_CLIST (p_intf
->p_sys
->p_clist
), 2, FALSE
);
143 gtk_clist_set_column_visibility (GTK_CLIST (p_intf
->p_sys
->p_clist
), 3, FALSE
);
144 gtk_clist_set_column_visibility (GTK_CLIST (p_intf
->p_sys
->p_clist
), 4, FALSE
);
145 gtk_clist_column_titles_show (GTK_CLIST (p_intf
->p_sys
->p_clist
));
147 /* Store p_intf to keep an eye on it */
148 gtk_object_set_data( GTK_OBJECT(p_intf
->p_sys
->p_window
),
150 /* Show the control window */
151 gtk_widget_show( p_intf
->p_sys
->p_window
);
152 ReadDirectory(p_intf
->p_sys
->p_clist
, ".");
154 /* Sleep to avoid using all CPU - since some interfaces need to
155 * access keyboard events, a 100ms delay is a good compromise */
156 while( !p_intf
->b_die
)
159 msleep( INTF_IDLE_SLEEP
);
163 gtk_object_destroy( GTK_OBJECT(p_intf
->p_sys
->p_window
) );