2007-06-06 00:30:13 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2007-06-06 00:30:13 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
2007-06-18 03:40:41 +00:00
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2007-06-18 03:40:41 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2008-09-23 19:11:04 +00:00
|
|
|
*
|
2007-08-18 17:19:49 +00:00
|
|
|
* $Id$
|
2007-06-06 00:30:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "hig.h"
|
|
|
|
|
|
|
|
GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_create( void )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * t = gtk_table_new( 1, 2, FALSE );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-02-14 17:18:00 +00:00
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( t ), GUI_PAD_BIG );
|
|
|
|
gtk_table_set_col_spacing( GTK_TABLE( t ), 0, GUI_PAD_BIG );
|
|
|
|
gtk_table_set_row_spacings( GTK_TABLE( t ), GUI_PAD );
|
2008-02-12 16:56:44 +00:00
|
|
|
return t;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_section_divider( GtkWidget * t,
|
|
|
|
int * row )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
gtk_widget_set_size_request( w, 0u, 6u );
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_table_attach( GTK_TABLE( t ), w, 0, 2, *row, *row + 1, 0, 0, 0, 0 );
|
|
|
|
++ * row;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2008-06-02 04:41:55 +00:00
|
|
|
void
|
|
|
|
hig_workarea_add_section_title_widget( GtkWidget * t,
|
2008-09-23 19:11:04 +00:00
|
|
|
int * row,
|
2008-06-02 04:41:55 +00:00
|
|
|
GtkWidget * w )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_table_attach( GTK_TABLE( t ), w, 0, 2, *row, *row + 1, ~0, 0, 0, 0 );
|
|
|
|
++ * row;
|
2008-06-02 04:41:55 +00:00
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_section_title( GtkWidget * t,
|
|
|
|
int * row,
|
|
|
|
const char * section_title )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
char buf[512];
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * l;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ), "<b>%s</b>", section_title );
|
2008-02-12 16:56:44 +00:00
|
|
|
l = gtk_label_new( buf );
|
|
|
|
gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f );
|
|
|
|
gtk_label_set_use_markup( GTK_LABEL( l ), TRUE );
|
2008-06-02 04:41:55 +00:00
|
|
|
hig_workarea_add_section_title_widget( t, row, l );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
static GtkWidget*
|
2008-02-14 17:18:00 +00:00
|
|
|
rowNew( GtkWidget * w )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * a;
|
|
|
|
GtkWidget * h = gtk_hbox_new( FALSE, 0 );
|
|
|
|
|
|
|
|
/* spacer */
|
|
|
|
a = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
|
|
|
|
gtk_widget_set_size_request( a, 18u, 0u );
|
|
|
|
gtk_box_pack_start( GTK_BOX( h ), a, FALSE, FALSE, 0 );
|
|
|
|
|
|
|
|
/* lhs widget */
|
|
|
|
if( GTK_IS_MISC( w ) )
|
|
|
|
gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.5f );
|
|
|
|
if( GTK_IS_LABEL( w ) )
|
|
|
|
gtk_label_set_use_markup( GTK_LABEL( w ), TRUE );
|
|
|
|
gtk_box_pack_start( GTK_BOX( h ), w, TRUE, TRUE, 0 );
|
|
|
|
|
|
|
|
return h;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-02-12 16:56:44 +00:00
|
|
|
hig_workarea_add_wide_control( GtkWidget * t,
|
2008-09-23 19:11:04 +00:00
|
|
|
int * row,
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * w )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-14 17:18:00 +00:00
|
|
|
GtkWidget * r = rowNew( w );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-28 16:47:01 +00:00
|
|
|
gtk_table_attach( GTK_TABLE( t ), r, 0, 2, *row, *row + 1, GTK_FILL, 0, 0, 0 );
|
2008-09-23 19:11:04 +00:00
|
|
|
++ * row;
|
2007-12-13 19:54:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 03:54:36 +00:00
|
|
|
void
|
|
|
|
hig_workarea_add_wide_tall_control( GtkWidget * t,
|
|
|
|
int * row,
|
|
|
|
GtkWidget * w )
|
|
|
|
{
|
|
|
|
GtkWidget * r = rowNew( w );
|
|
|
|
|
|
|
|
gtk_table_attach( GTK_TABLE( t ), r, 0, 2, *row, *row + 1,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0 );
|
|
|
|
|
|
|
|
++ * row;
|
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
GtkWidget *
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_wide_checkbutton( GtkWidget * t,
|
|
|
|
int * row,
|
|
|
|
const char * mnemonic_string,
|
|
|
|
gboolean is_active )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * w = gtk_check_button_new_with_mnemonic( mnemonic_string );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), is_active );
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_wide_control( t, row, w );
|
2008-02-12 16:56:44 +00:00
|
|
|
return w;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_label_w( GtkWidget * t,
|
|
|
|
int row,
|
|
|
|
GtkWidget * l )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-14 17:18:00 +00:00
|
|
|
GtkWidget * w = rowNew( l );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_table_attach( GTK_TABLE( t ), w, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0 );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_label( GtkWidget * t,
|
|
|
|
int row,
|
|
|
|
const char * mnemonic_string )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * l = gtk_label_new_with_mnemonic( mnemonic_string );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
hig_workarea_add_label_w( t, row, l );
|
|
|
|
return l;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 01:21:49 +00:00
|
|
|
static void
|
|
|
|
hig_workarea_add_tall_control( GtkWidget * t,
|
|
|
|
int row,
|
|
|
|
GtkWidget * control )
|
|
|
|
{
|
|
|
|
if( GTK_IS_MISC( control ) )
|
|
|
|
gtk_misc_set_alignment( GTK_MISC( control ), 0.0f, 0.5f );
|
|
|
|
|
|
|
|
gtk_table_attach( GTK_TABLE( t ), control,
|
|
|
|
1, 2, row, row + 1,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
|
|
0, 0 );
|
|
|
|
}
|
|
|
|
|
2010-12-21 17:22:37 +00:00
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_control( GtkWidget * t,
|
|
|
|
int row,
|
|
|
|
GtkWidget * control )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
if( GTK_IS_MISC( control ) )
|
2008-02-14 17:18:00 +00:00
|
|
|
gtk_misc_set_alignment( GTK_MISC( control ), 0.0f, 0.5f );
|
2007-06-07 17:53:54 +00:00
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
gtk_table_attach( GTK_TABLE( t ), control,
|
2008-09-23 19:11:04 +00:00
|
|
|
1, 2, row, row + 1,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0 );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_row_w( GtkWidget * t,
|
|
|
|
int * row,
|
|
|
|
GtkWidget * label,
|
|
|
|
GtkWidget * control,
|
|
|
|
GtkWidget * mnemonic )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_label_w( t, *row, label );
|
|
|
|
hig_workarea_add_control( t, *row, control );
|
|
|
|
if( GTK_IS_LABEL( label ) )
|
|
|
|
gtk_label_set_mnemonic_widget( GTK_LABEL( label ),
|
|
|
|
mnemonic ? mnemonic : control );
|
|
|
|
++ * row;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_add_row( GtkWidget * t,
|
|
|
|
int * row,
|
|
|
|
const char * mnemonic_string,
|
|
|
|
GtkWidget * control,
|
|
|
|
GtkWidget * mnemonic )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
GtkWidget * l = gtk_label_new_with_mnemonic( mnemonic_string );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-02-12 16:56:44 +00:00
|
|
|
hig_workarea_add_row_w( t, row, l, control, mnemonic );
|
|
|
|
return l;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 01:21:49 +00:00
|
|
|
GtkWidget*
|
|
|
|
hig_workarea_add_tall_row( GtkWidget * table,
|
|
|
|
int * row,
|
|
|
|
const char * mnemonic_string,
|
|
|
|
GtkWidget * control,
|
|
|
|
GtkWidget * mnemonic )
|
|
|
|
{
|
|
|
|
GtkWidget * l = gtk_label_new_with_mnemonic( mnemonic_string );
|
|
|
|
GtkWidget * h = gtk_hbox_new( FALSE, 0 );
|
|
|
|
GtkWidget * v = gtk_vbox_new( FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( h ), l, FALSE, FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( v ), h, FALSE, FALSE, GUI_PAD_SMALL );
|
|
|
|
|
|
|
|
hig_workarea_add_label_w( table, *row, v );
|
|
|
|
hig_workarea_add_tall_control( table, *row, control );
|
|
|
|
|
|
|
|
if( GTK_IS_LABEL( l ) )
|
|
|
|
gtk_label_set_mnemonic_widget( GTK_LABEL( l ),
|
|
|
|
mnemonic ? mnemonic : control );
|
|
|
|
|
|
|
|
++ * row;
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
void
|
2008-09-23 19:11:04 +00:00
|
|
|
hig_workarea_finish( GtkWidget * t,
|
|
|
|
int * row )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-02-12 16:56:44 +00:00
|
|
|
gtk_table_resize( GTK_TABLE( t ), *row, 2 );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|