Commit c698b96f authored by Jean-Paul Saman's avatar Jean-Paul Saman

Changes in familiar interface:

- added GtkCList instead of GtkList.
- added first column sorting order by clicking on column header
- selecting item from list works
- reading entire directory list is displayed in GtkCList widget
parent 005be138
......@@ -2,7 +2,7 @@
* callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: callbacks.c,v 1.3 2002/08/12 20:38:19 jpsaman Exp $
* $Id: callbacks.c,v 1.4 2002/08/14 21:50:01 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -46,9 +46,9 @@
#include "support.h"
#include "familiar.h"
//#include "netutils.h"
/*#include "netutils.h"*/
static void MediaURLOpenChanged( GtkEditable *editable, gpointer user_data );
static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url );
static void PreferencesURLOpenChanged( GtkEditable *editable, gpointer user_data );
/*****************************************************************************
......@@ -88,15 +88,12 @@ void * __GtkGetIntf( GtkWidget * widget )
/*****************************************************************************
* Helper functions for URL changes in Media and Preferences notebook pages.
****************************************************************************/
static void MediaURLOpenChanged( GtkEditable *editable, gpointer user_data )
static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
{
intf_thread_t *p_intf = GtkGetIntf( editable );
intf_thread_t *p_intf = GtkGetIntf( widget );
playlist_t *p_playlist;
gchar * psz_url;
psz_url = gtk_entry_get_text(GTK_ENTRY(editable));
g_print( "%s\n",psz_url );
// p_url = gtk_editable_get_chars(editable,0,-1);
// Add p_url to playlist .... but how ?
if (p_intf)
......@@ -115,42 +112,46 @@ static void MediaURLOpenChanged( GtkEditable *editable, gpointer user_data )
static void PreferencesURLOpenChanged( GtkEditable *editable, gpointer user_data )
{
gchar * p_url;
// GtkWidget * item;
p_url = gtk_entry_get_text(GTK_ENTRY(editable) );
g_print( "%s\n",p_url );
// p_url = gtk_editable_get_chars(editable,0,-1);
// item = gtk_list_item_new();
// gtk_widget_show (item);
// gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), p_url);
// /* Now we simply add the item to the combo's list. */
// gtk_container_add (GTK_CONTAINER (GTK_COMBO (combo)->list), item);
}
/*****************************************************************
* Read directory helper function.
****************************************************************/
static void ReadDirectory( GtkWidget *widget, char *psz_dir)
void ReadDirectory( GtkCList *clist, char *psz_dir)
{
struct dirent **namelist;
int n;
int n,i;
if (psz_dir)
n = scandir(psz_dir, &namelist, 0, alphasort);
n = scandir(psz_dir, &namelist, 0, NULL);
else
n = scandir(".", &namelist, 0, alphasort);
n = scandir(".", &namelist, 0, NULL);
if (n<0)
perror("scandir");
else
{
while(n--) /* reverse printed list */
gchar *ppsz_text[2];
gtk_clist_freeze( clist );
gtk_clist_clear( clist );
for (i=0; i<n; i++)
{
/* add list to listMedia widget */
g_print("%s\n",namelist[n]->d_name);
free(namelist[n]);
/* This is a list of strings. */
ppsz_text[0] = namelist[i]->d_name;
if (namelist[i]->d_type)
ppsz_text[1] = "dir";
else
ppsz_text[1] = "file";
gtk_clist_insert( clist, i, ppsz_text );
free(namelist[i]);
}
free(namelist);
gtk_clist_thaw( clist );
}
}
......@@ -186,8 +187,17 @@ on_toolbar_open_clicked (GtkButton *button,
gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( button );
GtkCList *clistmedia = NULL;
if (p_intf)
{
/* Testing routine */
clistmedia = GTK_CLIST( lookup_widget( p_intf->p_sys->p_window,
"clistmedia") );
if (GTK_CLIST(clistmedia))
{
ReadDirectory(clistmedia, ".");
}
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
gdk_window_raise( p_intf->p_sys->p_window->window );
}
......@@ -252,7 +262,7 @@ on_toolbar_play_clicked (GtkButton *button,
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
gdk_window_raise( p_intf->p_sys->p_window->window );
}
// Display open page
/* Display open page */
}
/* If the playlist is empty, open a file requester instead */
......@@ -268,7 +278,7 @@ on_toolbar_play_clicked (GtkButton *button,
{
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
// Display open page
/* Display open page */
}
}
......@@ -314,10 +324,10 @@ on_toolbar_about_clicked (GtkButton *button,
{// Toggle notebook
if (p_intf->p_sys->p_notebook)
{
// if ( gtk_get_data( GTK_WIDGET(p_intf->p_sys->p_notebook), "visible" ) )
// gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
// else
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
/* if ( gtk_get_data( GTK_WIDGET(p_intf->p_sys->p_notebook), "visible" ) )
* gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
* else
*/ gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
}
gdk_window_raise( p_intf->p_sys->p_window->window );
}
......@@ -329,10 +339,12 @@ on_comboURL_entry_changed (GtkEditable *editable,
gpointer user_data)
{
intf_thread_t * p_intf = GtkGetIntf( editable );
gchar * psz_url;
if (p_intf)
{
MediaURLOpenChanged( editable, NULL );
psz_url = gtk_entry_get_text(GTK_ENTRY(editable));
MediaURLOpenChanged( GTK_WIDGET(editable), psz_url );
}
}
......@@ -349,3 +361,68 @@ on_comboPrefs_entry_changed (GtkEditable *editable,
}
}
void
on_clistmedia_click_column (GtkCList *clist,
gint column,
gpointer user_data)
{
static GtkSortType sort_type = GTK_SORT_ASCENDING;
switch(sort_type)
{
case GTK_SORT_ASCENDING:
sort_type = GTK_SORT_DESCENDING;
break;
case GTK_SORT_DESCENDING:
sort_type = GTK_SORT_ASCENDING;
break;
}
gtk_clist_freeze( clist );
gtk_clist_set_sort_type( clist, sort_type );
gtk_clist_sort( clist );
gtk_clist_thaw( clist );
}
void
on_clistmedia_select_row (GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data)
{
gchar *text[2];
gint ret;
ret = gtk_clist_get_text (clist, row, 0, text);
if (ret)
{
MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// /* DO NOT TRY THIS CODE IT SEGFAULTS */
// g_print( "dir\n");
// /* should be a gchar compare function */
// if (strlen(text[1])>0)
// {
// g_print( "checking dir\n");
// /* should be a gchar compare function */
// if (strncmp(text[1],"dir",3)==0)
// {
// g_print( "dir: %s\n", text[0]);
// ReadDirectory(clist, text[0]);
// }
// else
// {
// g_print( "playing file\n");
// MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// }
// }
// else
// {
// g_print( "playing filer\n");
// MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// }
}
}
......@@ -2,7 +2,7 @@
* callbacks.h : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: callbacks.h,v 1.3 2002/08/12 20:38:19 jpsaman Exp $
* $Id: callbacks.h,v 1.4 2002/08/14 21:50:01 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -25,7 +25,7 @@
gboolean GtkExit ( GtkWidget *, gpointer );
static void ReadDirectory( GtkWidget *widget, char *psz_dir);
void ReadDirectory(GtkCList *clist, char *psz_dir);
gboolean
on_familiar_destroy_event (GtkWidget *widget,
......@@ -72,3 +72,15 @@ void
on_comboPrefs_entry_changed (GtkEditable *editable,
gpointer user_data);
void
on_clistmedia_click_column (GtkCList *clist,
gint column,
gpointer user_data);
void
on_clistmedia_select_row (GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data);
......@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.2 2002/08/12 20:38:19 jpsaman Exp $
* $Id: familiar.c,v 1.3 2002/08/14 21:50:01 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -188,18 +188,12 @@ static void Run( intf_thread_t *p_intf )
GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );
// gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
p_intf->p_sys->p_file_list = GTK_LIST( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_notebook), "listMedia") );
/* Store p_intf to keep an eye on it */
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
"p_intf", p_intf );
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
/* Testing routine */
// ReadDirectory( GTK_WIDGET(p_intf->p_sys->p_file_list), ".");
/* Enter Gtk mode */
gtk_main();
......
......@@ -238,21 +238,73 @@
</widget>
<widget>
<class>GtkList</class>
<name>listMedia</name>
<x>8</x>
<y>40</y>
<width>220</width>
<height>200</height>
<tooltip>Select multimedia file.</tooltip>
<selection_mode>GTK_SELECTION_MULTIPLE</selection_mode>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
<x>0</x>
<y>32</y>
<width>240</width>
<height>208</height>
<hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<widget>
<class>GtkCList</class>
<name>clistmedia</name>
<width>216</width>
<height>208</height>
<tooltip>Select files to play</tooltip>
<can_focus>True</can_focus>
<signal>
<name>click_column</name>
<handler>on_clistmedia_click_column</handler>
<last_modification_time>Wed, 14 Aug 2002 20:26:18 GMT</last_modification_time>
</signal>
<signal>
<name>select_row</name>
<handler>on_clistmedia_select_row</handler>
<last_modification_time>Wed, 14 Aug 2002 20:30:36 GMT</last_modification_time>
</signal>
<columns>2</columns>
<column_widths>145,54</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>labelname</name>
<label>Name</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>labeltype</name>
<label>Type</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkCombo</class>
<name>comboURL</name>
<x>46</x>
<y>6</y>
<x>40</x>
<y>4</y>
<width>185</width>
<height>24</height>
<value_in_list>False</value_in_list>
......@@ -261,9 +313,10 @@
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://localhost
http://localhost
udpstream://@localhost:1234/
ftp://
http://
udp://:1234
udpstream://@:1234
</items>
<widget>
......@@ -365,9 +418,10 @@ udpstream://@localhost:1234/
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://localhost
http://localhost
udpstream://@localhost:1234/
ftp://
http://
udpstream://@:1234
udp://:1234
</items>
<widget>
......
......@@ -2,7 +2,7 @@
* familiar.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: familiar.h,v 1.2 2002/08/12 20:38:19 jpsaman Exp $
* $Id: familiar.h,v 1.3 2002/08/14 21:50:01 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -34,7 +34,6 @@ struct intf_sys_t
// GtkWidget * p_notebook_about;
// GtkWidget * p_notebook_open;
// GtkWidget * p_notebook_preferences;
GtkWidget * p_file_list;
/* The input thread */
input_thread_t * p_input;
......
......@@ -37,7 +37,10 @@ create_familiar (void)
GtkWidget *notebook;
GtkWidget *fixedMedia;
GtkWidget *labelUrl;
GtkWidget *listMedia;
GtkWidget *scrolledwindow1;
GtkWidget *clistmedia;
GtkWidget *labelname;
GtkWidget *labeltype;
GtkWidget *comboURL;
GList *comboURL_items = NULL;
GtkWidget *comboURL_entry;
......@@ -235,17 +238,46 @@ create_familiar (void)
gtk_widget_set_uposition (labelUrl, 4, 8);
gtk_widget_set_usize (labelUrl, 38, 18);
listMedia = gtk_list_new ();
gtk_widget_set_name (listMedia, "listMedia");
gtk_widget_ref (listMedia);
gtk_object_set_data_full (GTK_OBJECT (familiar), "listMedia", listMedia,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (listMedia);
gtk_fixed_put (GTK_FIXED (fixedMedia), listMedia, 8, 40);
gtk_widget_set_uposition (listMedia, 8, 40);
gtk_widget_set_usize (listMedia, 220, 200);
gtk_tooltips_set_tip (tooltips, listMedia, _("Select multimedia file."), NULL);
gtk_list_set_selection_mode (GTK_LIST (listMedia), GTK_SELECTION_MULTIPLE);
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
gtk_widget_ref (scrolledwindow1);
gtk_object_set_data_full (GTK_OBJECT (familiar), "scrolledwindow1", scrolledwindow1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (scrolledwindow1);
gtk_fixed_put (GTK_FIXED (fixedMedia), scrolledwindow1, 0, 32);
gtk_widget_set_uposition (scrolledwindow1, 0, 32);
gtk_widget_set_usize (scrolledwindow1, 240, 208);
clistmedia = gtk_clist_new (2);
gtk_widget_set_name (clistmedia, "clistmedia");
gtk_widget_ref (clistmedia);
gtk_object_set_data_full (GTK_OBJECT (familiar), "clistmedia", clistmedia,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (clistmedia);
gtk_container_add (GTK_CONTAINER (scrolledwindow1), clistmedia);
gtk_widget_set_usize (clistmedia, 216, 208);
gtk_tooltips_set_tip (tooltips, clistmedia, _("Select files to play"), NULL);
gtk_clist_set_column_width (GTK_CLIST (clistmedia), 0, 145);
gtk_clist_set_column_width (GTK_CLIST (clistmedia), 1, 54);
gtk_clist_column_titles_show (GTK_CLIST (clistmedia));
labelname = gtk_label_new (_("Name"));
gtk_widget_set_name (labelname, "labelname");
gtk_widget_ref (labelname);
gtk_object_set_data_full (GTK_OBJECT (familiar), "labelname", labelname,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (labelname);
gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 0, labelname);
gtk_label_set_justify (GTK_LABEL (labelname), GTK_JUSTIFY_LEFT);
labeltype = gtk_label_new (_("Type"));
gtk_widget_set_name (labeltype, "labeltype");
gtk_widget_ref (labeltype);
gtk_object_set_data_full (GTK_OBJECT (familiar), "labeltype", labeltype,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (labeltype);
gtk_clist_set_column_widget (GTK_CLIST (clistmedia), 1, labeltype);
gtk_label_set_justify (GTK_LABEL (labeltype), GTK_JUSTIFY_LEFT);
comboURL = gtk_combo_new ();
gtk_widget_set_name (comboURL, "comboURL");
......@@ -253,13 +285,14 @@ create_familiar (void)
gtk_object_set_data_full (GTK_OBJECT (familiar), "comboURL", comboURL,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (comboURL);
gtk_fixed_put (GTK_FIXED (fixedMedia), comboURL, 46, 6);
gtk_widget_set_uposition (comboURL, 46, 6);
gtk_fixed_put (GTK_FIXED (fixedMedia), comboURL, 40, 4);
gtk_widget_set_uposition (comboURL, 40, 4);
gtk_widget_set_usize (comboURL, 185, 24);
comboURL_items = g_list_append (comboURL_items, (gpointer) _("file://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("ftp://localhost"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("http://localhost"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udpstream://@localhost:1234/"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("ftp://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("http://"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udp://:1234"));
comboURL_items = g_list_append (comboURL_items, (gpointer) _("udpstream://@:1234"));
gtk_combo_set_popdown_strings (GTK_COMBO (comboURL), comboURL_items);
g_list_free (comboURL_items);
......@@ -345,9 +378,10 @@ create_familiar (void)
gtk_widget_set_uposition (comboDefaultURL, 8, 8);
gtk_widget_set_usize (comboDefaultURL, 200, 24);
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("file://"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("ftp://localhost"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("http://localhost"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("udpstream://@localhost:1234/"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("ftp://"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("http://"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("udpstream://@:1234"));
comboDefaultURL_items = g_list_append (comboDefaultURL_items, (gpointer) _("udp://:1234"));
gtk_combo_set_popdown_strings (GTK_COMBO (comboDefaultURL), comboDefaultURL_items);
g_list_free (comboDefaultURL_items);
......@@ -508,6 +542,12 @@ create_familiar (void)
gtk_signal_connect (GTK_OBJECT (toolbar_about), "clicked",
GTK_SIGNAL_FUNC (on_toolbar_about_clicked),
NULL);
gtk_signal_connect (GTK_OBJECT (clistmedia), "click_column",
GTK_SIGNAL_FUNC (on_clistmedia_click_column),
NULL);
gtk_signal_connect (GTK_OBJECT (clistmedia), "select_row",
GTK_SIGNAL_FUNC (on_clistmedia_select_row),
NULL);
gtk_signal_connect (GTK_OBJECT (comboURL_entry), "changed",
GTK_SIGNAL_FUNC (on_comboURL_entry_changed),
NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment