(trunk gtk) #2019: HiG: "When there is no interesting status to report, leave a status bar panel blank"

This commit is contained in:
Charles Kerr 2009-05-01 19:39:34 +00:00
parent 00bc015112
commit 4973d95cd3
1 changed files with 43 additions and 27 deletions

View File

@ -83,8 +83,12 @@ typedef struct
GtkWidget * filter; GtkWidget * filter;
GtkWidget * status; GtkWidget * status;
GtkWidget * status_menu; GtkWidget * status_menu;
GtkWidget * ul_hbox;
GtkWidget * dl_hbox;
GtkWidget * ul_lb; GtkWidget * ul_lb;
GtkWidget * ul_image;
GtkWidget * dl_lb; GtkWidget * dl_lb;
GtkWidget * dl_image;
GtkWidget * stats_lb; GtkWidget * stats_lb;
GtkWidget * gutter_lb; GtkWidget * gutter_lb;
GtkWidget * alt_speed_image[2]; /* 0==off, 1==on */ GtkWidget * alt_speed_image[2]; /* 0==off, 1==on */
@ -797,7 +801,7 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core )
const char * pch; const char * pch;
PrivateData * p; PrivateData * p;
GtkWidget *mainmenu, *toolbar, *filter, *list, *status; GtkWidget *mainmenu, *toolbar, *filter, *list, *status;
GtkWidget * vbox, *w, *self, *h, *c, *s, *image, *menu; GtkWidget * vbox, *w, *self, *h, *c, *s, *hbox, *image, *menu;
GtkWindow * win; GtkWindow * win;
GSList * l; GSList * l;
@ -920,31 +924,40 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core )
w = p->gutter_lb = gtk_label_new( "N Torrents" ); w = p->gutter_lb = gtk_label_new( "N Torrents" );
gtk_box_pack_start( GTK_BOX( h ), w, 1, 1, GUI_PAD_BIG ); gtk_box_pack_start( GTK_BOX( h ), w, 1, 1, GUI_PAD_BIG );
w = p->ul_lb = gtk_label_new( NULL ); hbox = p->dl_hbox = gtk_hbox_new( FALSE, GUI_PAD_SMALL );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
w = gtk_image_new_from_stock( GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU ); gtk_widget_set_size_request( w, GUI_PAD, 0u );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
w = p->dl_image = gtk_image_new_from_stock( GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU );
gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
w = p->dl_lb = gtk_label_new( NULL );
gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 );
w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f ); hbox = p->ul_hbox = gtk_hbox_new( FALSE, GUI_PAD_SMALL );
gtk_widget_set_size_request( w, GUI_PAD, 0u ); w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); gtk_widget_set_size_request( w, GUI_PAD, 0u );
w = p->dl_lb = gtk_label_new( NULL ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); w = p->ul_image = gtk_image_new_from_stock( GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU );
gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
w = p->ul_lb = gtk_label_new( NULL );
gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 );
w = gtk_image_new_from_stock( GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU ); hbox = gtk_hbox_new( FALSE, GUI_PAD_SMALL );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f ); gtk_widget_set_size_request( w, GUI_PAD, 0u );
gtk_widget_set_size_request( w, GUI_PAD, 0u ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); w = gtk_image_new_from_stock( GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU );
w = p->stats_lb = gtk_label_new( NULL ); c = gtk_event_box_new( );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 ); gtk_container_add( GTK_CONTAINER( c ), w );
w = c;
g_signal_connect( w, "button-release-event", G_CALLBACK( onYinYangReleased ), p );
gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
w = p->stats_lb = gtk_label_new( NULL );
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 );
gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 );
w = gtk_image_new_from_stock( GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU );
c = gtk_event_box_new( );
gtk_container_add( GTK_CONTAINER( c ), w );
w = c;
gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 );
g_signal_connect( w, "button-release-event", G_CALLBACK( onYinYangReleased ), p );
menu = gtk_menu_new( ); menu = gtk_menu_new( );
l = NULL; l = NULL;
@ -1026,16 +1039,17 @@ updateTorrentCount( PrivateData * p )
const int visibleCount = gtk_tree_model_iter_n_children( const int visibleCount = gtk_tree_model_iter_n_children(
p->filter_model, NULL ); p->filter_model, NULL );
if( torrentCount != visibleCount ) if( !torrentCount )
*buf = '\0';
else if( torrentCount != visibleCount )
g_snprintf( buf, sizeof( buf ), g_snprintf( buf, sizeof( buf ),
ngettext( "%1$'d of %2$'d Torrent", ngettext( "%1$'d of %2$'d Torrent",
"%1$'d of %2$'d Torrents", "%1$'d of %2$'d Torrents",
torrentCount ), torrentCount ),
visibleCount, torrentCount ); visibleCount, torrentCount );
else else
g_snprintf( buf, sizeof( buf ), ngettext( "%'d Torrent", g_snprintf( buf, sizeof( buf ),
"%'d Torrents", ngettext( "%'d Torrent", "%'d Torrents", torrentCount ),
torrentCount ),
torrentCount ); torrentCount );
gtk_label_set_text( GTK_LABEL( p->gutter_lb ), buf ); gtk_label_set_text( GTK_LABEL( p->gutter_lb ), buf );
} }
@ -1101,10 +1115,12 @@ updateSpeeds( PrivateData * p )
d = tr_sessionGetPieceSpeed( session, TR_DOWN ); d = tr_sessionGetPieceSpeed( session, TR_DOWN );
tr_strlspeed( buf, d, sizeof( buf ) ); tr_strlspeed( buf, d, sizeof( buf ) );
gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf ); gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
g_object_set( p->dl_hbox, "visible", d>=0.01, NULL );
d = tr_sessionGetPieceSpeed( session, TR_UP ); d = tr_sessionGetPieceSpeed( session, TR_UP );
tr_strlspeed( buf, d, sizeof( buf ) ); tr_strlspeed( buf, d, sizeof( buf ) );
gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf ); gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
g_object_set( p->ul_hbox, "visible", d>=0.01, NULL );
} }
} }