1502
infobar_cancel_close( Infobar *infobar )
1504
IM_FREEF( g_source_remove, infobar->close_timeout );
1505
IM_FREEF( g_source_remove, infobar->close_animation_timeout );
1506
gtk_widget_set_size_request( GTK_WIDGET( infobar ), -1, -1 );
1502
1510
infobar_hide( Infobar *infobar )
1504
IM_FREEF( g_source_remove, infobar->close_animation_timeout );
1505
IM_FREEF( g_source_remove, infobar->close_timeout );
1512
infobar_cancel_close( infobar );
1507
1513
gtk_widget_hide( GTK_WIDGET( infobar ) );
1508
gtk_widget_set_size_request( GTK_WIDGET( infobar ), -1, -1 );
1514
gtk_widget_hide( GTK_WIDGET( infobar->sub ) );
1515
gtk_widget_set_sensitive( GTK_WIDGET( infobar->info ), TRUE );
1511
1518
static gboolean
1559
infobar_response_cb( GtkInfoBar *info_bar,
1560
gint response_id, gpointer user_data )
1562
infobar_start_close( INFOBAR( info_bar ) );
1562
infobar_info_cb( GtkWidget *button, Infobar *infobar )
1564
infobar_cancel_close( infobar );
1565
gtk_widget_show( GTK_WIDGET( infobar->sub ) );
1566
gtk_widget_set_sensitive( GTK_WIDGET( infobar->info ), FALSE );
1570
infobar_close_cb( GtkWidget *button, Infobar *infobar )
1572
infobar_start_close( infobar );
1566
1576
infobar_new( void )
1568
1578
Infobar *infobar;
1569
1580
GtkWidget *content_area;
1582
GtkWidget *action_area;
1571
1585
infobar = g_object_new( TYPE_INFOBAR, NULL );
1572
infobar->label = gtk_label_new( "" );
1573
gtk_label_set_justify( GTK_LABEL( infobar->label ), GTK_JUSTIFY_LEFT );
1574
gtk_label_set_selectable( GTK_LABEL( infobar->label ), TRUE );
1575
gtk_label_set_line_wrap( GTK_LABEL( infobar->label ), TRUE );
1587
vbox = gtk_vbox_new( FALSE, 10 );
1576
1588
content_area = gtk_info_bar_get_content_area( GTK_INFO_BAR( infobar ) );
1577
gtk_container_add( GTK_CONTAINER( content_area ), infobar->label );
1578
gtk_widget_show( infobar->label );
1579
gtk_info_bar_add_button( GTK_INFO_BAR( infobar ),
1580
GTK_STOCK_OK, GTK_RESPONSE_OK );
1581
g_signal_connect( infobar, "response",
1582
G_CALLBACK( infobar_response_cb ), NULL );
1589
gtk_container_add( GTK_CONTAINER( content_area ), vbox );
1590
gtk_widget_show( vbox );
1592
infobar->top = gtk_label_new( "" );
1593
gtk_label_set_justify( GTK_LABEL( infobar->top ), GTK_JUSTIFY_LEFT );
1594
gtk_label_set_selectable( GTK_LABEL( infobar->top ), TRUE );
1595
gtk_label_set_line_wrap( GTK_LABEL( infobar->top ), TRUE );
1596
gtk_container_add( GTK_CONTAINER( vbox ), infobar->top );
1597
gtk_widget_show( infobar->top );
1599
infobar->sub = gtk_label_new( "" );
1600
gtk_label_set_justify( GTK_LABEL( infobar->sub ), GTK_JUSTIFY_LEFT );
1601
gtk_label_set_selectable( GTK_LABEL( infobar->sub ), TRUE );
1602
gtk_label_set_line_wrap( GTK_LABEL( infobar->sub ), TRUE );
1603
gtk_container_add( GTK_CONTAINER( vbox ), infobar->sub );
1605
/* We can't use gtk_info_bar_add_button(), we need the buttons
1609
hbox = gtk_hbox_new( FALSE, 2 );
1610
action_area = gtk_info_bar_get_action_area( GTK_INFO_BAR( infobar ) );
1611
gtk_container_add( GTK_CONTAINER( action_area ), hbox );
1612
gtk_widget_show( hbox );
1614
button = gtk_button_new_from_stock( GTK_STOCK_CLOSE );
1615
gtk_box_pack_end( GTK_BOX( hbox ), button, TRUE, TRUE, 2 );
1616
g_signal_connect( button, "clicked",
1617
G_CALLBACK( infobar_close_cb ), infobar );
1618
gtk_widget_show( button );
1620
infobar->info = gtk_button_new_from_stock( GTK_STOCK_INFO );
1621
gtk_box_pack_end( GTK_BOX( hbox ), infobar->info, TRUE, TRUE, 2 );
1622
g_signal_connect( infobar->info, "clicked",
1623
G_CALLBACK( infobar_info_cb ), infobar );
1624
gtk_widget_show( infobar->info );
1584
1626
return( infobar );
1595
1637
#endif /*USE_INFOBAR*/
1639
/* Set the label on an infobar to some marked-up text.
1642
infobar_vset( Infobar *infobar, GtkMessageType type,
1643
const char *top, const char *sub, va_list ap )
1597
1645
#ifdef USE_INFOBAR
1598
/* Mark up a top/sub pair for an infobar.
1601
box_vmarkup_infobar( char *out, const char *top, const char *sub, va_list ap )
1603
1646
char buf1[MAX_DIALOG_TEXT];
1604
1647
char buf2[MAX_DIALOG_TEXT];
1605
char buf3[MAX_DIALOG_TEXT];
1608
1650
escape_markup( top, buf1, MAX_DIALOG_TEXT );
1609
(void) im_vsnprintf( buf2, MAX_DIALOG_TEXT, sub, ap );
1610
escape_markup( buf2, buf3, MAX_DIALOG_TEXT );
1612
(void) im_snprintf( out, MAX_DIALOG_TEXT,
1613
"<b>%s</b>", buf1 );
1614
if( strcmp( buf3, "" ) != 0 ) {
1615
int len = strlen( out );
1617
(void) im_snprintf( out + len, MAX_DIALOG_TEXT - len,
1651
im_snprintf( buf2, MAX_DIALOG_TEXT, "<b>%s</b>", buf1 );
1652
gtk_label_set_markup( GTK_LABEL( infobar->top ), buf2 );
1654
(void) im_vsnprintf( buf1, MAX_DIALOG_TEXT, sub, ap );
1655
escape_markup( buf1, buf2, MAX_DIALOG_TEXT );
1621
1657
/* Remove any trailing newlines, they make infobars rather large.
1623
while( (p = out + strlen( out )) > out && p[-1] == '\n' )
1659
while( (p = buf2 + strlen( buf2 )) > buf2 && p[-1] == '\n' )
1626
#endif /*USE_INFOBAR*/
1628
/* Set the label on an infobar to some marked-up text.
1631
infobar_vset( Infobar *infobar, GtkMessageType type,
1632
const char *top, const char *sub, va_list ap )
1635
char buf[MAX_DIALOG_TEXT];
1637
box_vmarkup_infobar( buf, top, sub, ap );
1638
gtk_label_set_markup( GTK_LABEL( infobar->label ), buf );
1662
gtk_label_set_markup( GTK_LABEL( infobar->sub ), buf2 );
1639
1664
gtk_info_bar_set_message_type( GTK_INFO_BAR( infobar ), type );
1641
1666
infobar_show( infobar );