|
|
发表于 2006-1-5 09:29:25
|
显示全部楼层
Post by zlbruce
patch 如下:
[php]--- src/data.c 2006-01-04 22:13:42.000000000 +0800
+++ src/data.c 2006-01-04 22:08:00.000000000 +0800
@@ -55,7 +55,6 @@
fprintf(fp,"play_port=%d\n",iPlayPort);
fclose(fp);
- loadconfig();
return TRUE;
}
@@ -72,12 +71,15 @@
fp=fopen(strPath,"rt");
- if(!fp && !saveconfig())
+ if(!fp)
{
-// saveconfig();
-// loadconfig();
- fprintf(stderr,"Warning: You can not use the `config' file! \n");
- return FALSE;
+ if(!saveconfig())
+ {
+ fprintf(stderr,"Warning: You can not use the `config' file! \n");
+ return FALSE;
+ }
+ loadconfig();
+ return TRUE;
}
while(1)
[/php]
如果没有.sopcast/config文件,在data.c的函数
[php]
gint init( )
{
。。。
strcpy(strPlayer,"/usr/bin/mplayer");
iCnnPort=8000;
iPlayPort=9000;
loadconfig();
initWindow();
return 0;
}
[/php]
已经有初始化strPlayer=/usr/bin/mplayer,iCnnPort,iPlayPort功能。如果strPlayer值不对,点“保存”后,callback.c的函数
[php]
void
on_button_save_clicked (GtkButton *button,
gpointer user_data)
{
iCnnPort = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
lookup_widget(window_main,"spinbutton_cnn_port")));
iPlayPort = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
lookup_widget(window_main,"spinbutton_play_port")));
char *tmp = (char *) gtk_entry_get_text(GTK_ENTRY(lookup_widget(window_main,"player_addr")));
strcpy(strPlayer,tmp);
。。。
}
[/php]
将更新strPlayer,iCnnPort,iPlayPort的值。因此我觉得data.c中的
[php]
gboolean loadconfig()
{
。。。
+ if(!fp)
{
+ 。。。
+ loadconfig();
+ 。。。
}
。。。
}
[/php]
将属多余 |
|