1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include "npconfig.h"
void address_buttons_callback( GtkWidget *widget, gpointer data )
{
NP_Config *config =
( NP_Config *)gtk_object_get_data( GTK_OBJECT( widget->parent ),
"config" );
GtkWidget *clist =
( GtkWidget *)gtk_object_get_data( GTK_OBJECT( widget->parent ),
"clist" );
int i;
if (( i = config->subscription[ ( const char *)data ] ) < 0 )
{
config->subscription.print_error();
return;
}
config->current_server = i;
int total = config->subscription.get_total_groups( i );
if ( total < 0 )
{
config->subscription.print_error();
return;
}
gtk_clist_clear( GTK_CLIST( clist ));
gtk_clist_freeze( GTK_CLIST( clist ));
char buffer[ 256 ];
snprintf( buffer, sizeof buffer, "%d Subscribed Newsgroups", total );
gtk_clist_set_column_title( GTK_CLIST( clist ), 0, buffer );
config->group_clist_lines = 0;
if ( total )
for( int j = 0; j < total; ++j )
{
char *lines[ 2 ];
if (( lines[ 0 ] = ( char *)config->subscription.get_group( i, j ))
== NULL )
{
config->subscription.print_error();
return;
}
if (( lines[ 1 ] =
( char *)config->subscription.get_article_no( i, j ))
== NULL )
{
config->subscription.print_error();
return;
}
gtk_clist_append( GTK_CLIST( clist ), lines );
++config->group_clist_lines;
}
gtk_clist_thaw( GTK_CLIST( clist ));
return;
}
|