implemented mk_label wherever possible

This commit is contained in:
Bart Hakvoort 2004-10-06 19:06:43 +00:00
parent e26341f862
commit bd3152788f
13 changed files with 85 additions and 116 deletions

View File

@ -1,3 +1,7 @@
2004-10-06 Bart Hakvoort <gparted@users.sf.net>
* implemented mk_label wherever possible (means less code, improved readability)
2004-10-06 David Lodge <dave@cirt.net>
* configure.in (ALL_LINGUAS): Added "en_GB" (British English).

View File

@ -24,13 +24,16 @@
#define DIALOG_ABOUT
#include "../include/i18n.h"
#include "../include/Utils.h"
#include <gtkmm/dialog.h>
#include <gtkmm/button.h>
#include <gtkmm/label.h>
#include <gtkmm/stock.h>
#include <gtkmm/notebook.h>
namespace GParted
{
class Dialog_About : public Gtk::Dialog
{
public:
@ -40,9 +43,10 @@ public:
private:
void Show_Credits() ;
Gtk::Label *label_temp ;
Gtk::Button button_credits;
};
} //GParted
#endif

View File

@ -42,24 +42,23 @@ namespace GParted
class Dialog_Partition_Info : public Gtk::Dialog
{
public:
Dialog_Partition_Info( const Partition & );
Dialog_Partition_Info( const Partition & partition );
~Dialog_Partition_Info();
private:
void init_drawingarea() ;
void Display_Info();
Glib::ustring Find_Status() ;
void init_drawingarea( ) ;
void Display_Info( );
Glib::ustring Find_Status( ) ;
//signalhandlers
void drawingarea_on_realize( );
bool drawingarea_on_expose( GdkEventExpose * );
void drawingarea_on_realize( );
bool drawingarea_on_expose( GdkEventExpose *ev );
Partition partition ;
Gtk::HBox *hbox ;
Gtk::DrawingArea drawingarea ;
Gtk::Frame *frame ;
Gtk::Label *label ;
Gtk::Image *image;
Gtk::Table *table;

View File

@ -19,32 +19,37 @@
#define DIALOG_PARTITION_PROGRESS
#include "../include/i18n.h"
#include "../include/Utils.h"
#include <gtkmm/dialog.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/stock.h>
#include <gtkmm/label.h>
namespace GParted
{
class Dialog_Progress : public Gtk::Dialog
{
public:
Dialog_Progress( int, const Glib::ustring & );
~Dialog_Progress();
~Dialog_Progress( );
void Set_Next_Operation( );
void Set_Progress_Current_Operation();
void Set_Progress_Current_Operation( );
Glib::ustring current_operation;
float fraction_current;
int time_left ;
private:
Gtk::Label label_all_operations, label_current, *label_temp;
Gtk::Label label_current ;
Gtk::ProgressBar progressbar_all, progressbar_current ;
double fraction;
int count_operations, current_operation_number;
};
}//GParted
#endif //DIALOG_PARTITION_PROGRESS

View File

@ -63,11 +63,17 @@ inline Sector Abs( Sector sectors )
return sectors < 0 ? sectors - 2*sectors : sectors ;
}
inline Gtk::Label * mk_label( const Glib::ustring & text )
inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true, bool align_left = true, bool wrap = false )
{
Gtk::Label * label = manage( new Gtk::Label() ) ;
label ->set_markup( text ) ;
label ->set_alignment( Gtk::ALIGN_LEFT ) ;
Gtk::Label * label = manage( new Gtk::Label( text ) ) ;
label ->set_use_markup( use_markup ) ;
if ( align_left )
label ->set_alignment( Gtk::ALIGN_LEFT ) ;
label ->set_line_wrap( wrap ) ;
return label ;
}

View File

@ -91,8 +91,6 @@ private:
Glib::ustring str_temp ;
int temp,selected_partition;
Gtk::Entry *entry_temp;
Gtk::Label *label_temp;
};
} //GParted

View File

@ -17,6 +17,9 @@
#include "../include/Device.h"
namespace GParted
{
/*
* This is ridiculous!, if i use this one as a member function realpath starts complaining and won't compile :-S
*/
@ -58,41 +61,31 @@ PedExceptionOption PedException_Handler (PedException* ex)
if ( show_libparted_message )
{
Gtk::Label *label_temp;
Gtk::HBox *hbox_filler;
Glib::ustring message = "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Libparted message" ) + "</span>\n\n" ;
message += (Glib::ustring) _( "This message directly comes from libparted and has little to do with GParted. However, the message might contain useful information, so you might decide to read it.") + "\n";
message += _( "If you don't want to see these messages any longer, it's safe to disable them.") ;
Gtk::MessageDialog dialog( message,true,Gtk::MESSAGE_WARNING , Gtk::BUTTONS_OK, true);
Gtk::MessageDialog dialog( message, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
Gtk::Frame frame_libparted_message ;
frame_libparted_message .set_size_request( 400, -1 );
label_temp = manage( new Gtk::Label("<b>" + (Glib::ustring) _( "Libparted message") + ": </b>" ) ) ;
label_temp ->set_use_markup( true ) ;
frame_libparted_message .set_label_widget( *label_temp ) ;
frame_libparted_message .set_label_widget( * mk_label("<b>" + (Glib::ustring) _( "Libparted message") + ": </b>" ) ) ;
frame_libparted_message .set_border_width( 5 ) ;
label_temp = manage( new Gtk::Label( ) ) ;
label_temp ->set_size_request( 55, -1 ) ; //used like a simple filler ( remember this html cursus :-P )
hbox_filler = manage( new Gtk::HBox() ) ;
hbox_filler ->pack_start ( *label_temp, Gtk::PACK_SHRINK ) ;
hbox_filler ->pack_start ( * mk_label( "\t\t" ), Gtk::PACK_SHRINK ) ; //filler
hbox_filler ->pack_start ( frame_libparted_message, Gtk::PACK_SHRINK ) ;
dialog .get_vbox() ->pack_start( *hbox_filler, Gtk::PACK_SHRINK ) ;
Gtk::Label label_libparted_message( "<i>" + error_message + "</i>" ) ;
label_libparted_message .set_selectable( true ) ;
label_libparted_message .set_use_markup( true ) ;
label_libparted_message .set_line_wrap( true ) ;
frame_libparted_message.add ( label_libparted_message ) ;
frame_libparted_message.add ( * mk_label( "<i>" + error_message + "</i>", true, false, true ) ) ;
Gtk::CheckButton checkbutton_message( _( "Hide libparted messages for this session" ) ) ;
checkbutton_message .set_border_width( 5 ) ;
label_temp = manage( new Gtk::Label( ) ) ;
label_temp ->set_size_request( 55, -1 ) ;
hbox_filler = manage( new Gtk::HBox() ) ;
hbox_filler ->pack_start ( *label_temp, Gtk::PACK_SHRINK ) ;
hbox_filler ->pack_start ( * mk_label( "\t\t" ), Gtk::PACK_SHRINK ) ;
hbox_filler ->pack_start ( checkbutton_message, Gtk::PACK_SHRINK ) ;
dialog .get_vbox() ->pack_start( *hbox_filler, Gtk::PACK_SHRINK ) ;
@ -106,10 +99,7 @@ PedExceptionOption PedException_Handler (PedException* ex)
return PED_EXCEPTION_UNHANDLED ;
}
namespace GParted
{
//--------------Device----------------------------------------------
Device::Device()
{
}

View File

@ -17,6 +17,9 @@
#include "../include/Dialog_About.h"
namespace GParted
{
Dialog_About::Dialog_About()
{
/*TO TRANSLATORS: this is the dialog title */
@ -25,26 +28,11 @@ Dialog_About::Dialog_About()
this ->set_resizable( false );
this ->set_has_separator( false ) ;
label_temp = manage( new Gtk::Label() ) ;
label_temp -> set_markup( "\n<span size='small'>logo here ;)</span>\n" ) ;
this ->get_vbox()->pack_start( *label_temp ,Gtk::PACK_SHRINK );
label_temp = manage( new Gtk::Label() ) ;
label_temp -> set_markup( "<span size='xx-large'><b>" + (Glib::ustring) _( "GParted" ) + " " + VERSION + "</b></span>" ) ;
this ->get_vbox()->pack_start( *label_temp ,Gtk::PACK_SHRINK );
label_temp = manage( new Gtk::Label() ) ;
label_temp -> set_text( "\n" + (Glib::ustring) _( "Gnome Partition Editor based on libparted" ) + "\n" ) ;
this ->get_vbox()->pack_start( *label_temp ,Gtk::PACK_SHRINK );
label_temp = manage( new Gtk::Label() ) ;
label_temp -> set_markup( "<span size='small'>" + (Glib::ustring) _( "Copyright (c)" ) + " 2004 Bart Hakvoort</span>" ) ;
this ->get_vbox()->pack_start( *label_temp ,Gtk::PACK_SHRINK );
label_temp = manage( new Gtk::Label() ) ;
label_temp -> set_markup( "<span size='small'>http://gparted.sourceforge.net</span>" ) ;
label_temp -> set_selectable( true ) ;
this ->get_vbox()->pack_start( *label_temp ,Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * mk_label( "\n<span size='small'>logo here ;)</span>\n", true, false ), Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * mk_label( "<span size='xx-large'><b>" + (Glib::ustring) _( "GParted" ) + " " + VERSION + "</b></span>", true, false ) ,Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * mk_label( "\n" + (Glib::ustring) _( "Gnome Partition Editor based on libparted" ) + "\n", false, false ) ,Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * mk_label( "<span size='small'>" + (Glib::ustring) _( "Copyright (c)" ) + " 2004 Bart Hakvoort</span>", true, false ) ,Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * mk_label( "<span size='small'>http://gparted.sourceforge.net</span>", true, false ) ,Gtk::PACK_SHRINK );
button_credits.add_pixlabel( "/usr/share/icons/hicolor/16x16/stock/generic/stock_about.png", "Credits", 0, 0.5 ) ;
button_credits.signal_clicked() .connect( sigc::mem_fun( this, &Dialog_About::Show_Credits ) ) ;
@ -54,7 +42,6 @@ Dialog_About::Dialog_About()
this ->add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE );
this ->show_all_children() ;
}
void Dialog_About::Show_Credits()
@ -62,34 +49,30 @@ void Dialog_About::Show_Credits()
Gtk::Dialog dialog( _("Credits"), *this ) ;
Gtk::Notebook notebook_credits;
Gtk::VBox vbox_written, vbox_translators ;
Gtk::Label label_writers, label_translators ;
//written by
vbox_written .set_border_width( 5 ) ;
label_writers .set_text( "Bart Hakvoort <gparted@users.sf.net>");
label_writers .set_selectable( true );
label_writers .set_alignment( Gtk::ALIGN_LEFT ) ;
vbox_written .pack_start( label_writers, Gtk::PACK_SHRINK ) ;
vbox_written .pack_start( * mk_label( "Bart Hakvoort <gparted@users.sf.net>", false ), Gtk::PACK_SHRINK ) ;
notebook_credits .set_size_request( -1, 200 ) ;
/*TO TRANSLATORS: tablabel in aboutdialog */
notebook_credits .append_page( vbox_written, _("Written by") ) ;
/*TO TRANSLATORS: your name(s) here please, if there are more translators put newlines (\n) between the names */
label_translators .set_text( _( "translator-credits") ) ;
label_translators .set_selectable( true );
if ( label_translators .get_text() != "translator-credits" )
Glib::ustring str_credits = _("translator-credits") ;
if ( str_credits != "translator-credits" )
{
label_translators .set_alignment( Gtk::ALIGN_LEFT ) ;
vbox_translators .pack_start( label_translators, Gtk::PACK_SHRINK ) ;
vbox_translators .pack_start( * mk_label( str_credits ), Gtk::PACK_SHRINK ) ;
/*TO TRANSLATORS: tablabel in aboutdialog */
notebook_credits .append_page( vbox_translators, _("Translated by") ) ;
}
dialog .get_vbox()->pack_start( notebook_credits, Gtk::PACK_SHRINK );
dialog .get_vbox() ->pack_start( notebook_credits, Gtk::PACK_SHRINK );
dialog .add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE );
dialog .set_resizable( false );
dialog .show_all_children() ;
dialog .run() ;
}
}//GParted

View File

@ -85,7 +85,7 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
//pack warning about small differences in values..
this ->get_vbox() ->pack_start( * mk_label( "\n <i>" + (Glib::ustring) _( "NOTE: values on disk may differ slightly from the values entered here.") + "</i>" ), Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( *( manage( new Gtk::Label( "") ) ), Gtk::PACK_SHRINK ); //filler :-P
this ->get_vbox() ->pack_start( * mk_label( "" ), Gtk::PACK_SHRINK ); //filler :-P
this->add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
this ->show_all_children() ;

View File

@ -22,9 +22,9 @@ namespace GParted
Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
{
this -> partition = partition ;
this ->partition = partition ;
this->set_resizable( false );
this ->set_resizable( false );
/*TO TRANSLATORS: dialogtitle, looks like Information about /dev/hda3 */
this->set_title( String::ucompose( _( "Information about %1"), partition.partition ) );
@ -41,20 +41,13 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
frame ->set_border_width( 10 );
image = manage( new Gtk::Image( Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_BUTTON ) );
label = manage( new Gtk::Label( ) ) ;
label ->set_markup( "<b> " + (Glib::ustring) _( "Libparted message:" ) + " </b>" ) ;
hbox = manage( new Gtk::HBox() );
hbox ->pack_start( *image, Gtk::PACK_SHRINK ) ;
hbox ->pack_start( *label, Gtk::PACK_SHRINK ) ;
hbox ->pack_start( * mk_label( "<b> " + (Glib::ustring) _( "Libparted message:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
frame ->set_label_widget( *hbox ) ;
label = manage( new Gtk::Label( ) ) ;
label ->set_markup( "<i>" + partition.error + "</i>") ;
label ->set_selectable( true ) ;
label ->set_line_wrap( true ) ;
frame ->add( *label );
frame ->add( * mk_label( "<i>" + partition.error + "</i>", true, true, true ) );
this ->get_vbox() ->pack_start( *frame, Gtk::PACK_SHRINK ) ;
}

View File

@ -17,6 +17,9 @@
#include "../include/Dialog_Progress.h"
namespace GParted
{
Dialog_Progress::Dialog_Progress( int count_operations, const Glib::ustring & first_operation )
{
this ->set_size_request( 500, 275 ) ;
@ -30,8 +33,6 @@ Dialog_Progress::Dialog_Progress( int count_operations, const Glib::ustring & fi
fraction = (double) 1 / count_operations ;
fraction -= 1E-8 ; //minus 1E-8 is to prevent fraction from ever reaching >=1, it needs to be 0.0 < fraction < 1.0
label_temp = manage( new Gtk::Label() ) ;
label_temp ->set_alignment( Gtk::ALIGN_LEFT );
Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Applying pending operations" ) ;
str_temp += "</span>\n\n" ;
@ -39,8 +40,7 @@ Dialog_Progress::Dialog_Progress( int count_operations, const Glib::ustring & fi
str_temp += "\n";
str_temp += _("Clicking Cancel will prevent the next operations from being applied.") ;
str_temp += "\n";
label_temp ->set_markup( str_temp ) ;
this->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK );
this->get_vbox() ->pack_start( * mk_label( str_temp ), Gtk::PACK_SHRINK );
progressbar_current.set_text( _("initializing...") );
this->get_vbox() ->pack_start( progressbar_current , Gtk::PACK_SHRINK);
@ -49,9 +49,7 @@ Dialog_Progress::Dialog_Progress( int count_operations, const Glib::ustring & fi
label_current.set_markup( "<i>" + first_operation + "</i>" ) ;
this->get_vbox() ->pack_start( label_current, Gtk::PACK_SHRINK );
label_all_operations.set_alignment( Gtk::ALIGN_LEFT );
label_all_operations.set_markup( "<b>\n" + (Glib::ustring) _( "Completed Operations" ) + ":</b>");
this->get_vbox() ->pack_start( label_all_operations, Gtk::PACK_SHRINK );
this->get_vbox() ->pack_start( * mk_label( "<b>\n" + (Glib::ustring) _( "Completed Operations" ) + ":</b>" ), Gtk::PACK_SHRINK );
progressbar_all.set_text( String::ucompose( _("%1 of %2 operations completed"), 0, count_operations ) ) ;
@ -88,3 +86,5 @@ void Dialog_Progress::Set_Progress_Current_Operation( )
else
progressbar_current.set_text( String::ucompose( _("about %1 minutes and %2 seconds left"), time_left/60, time_left % 60 ) ) ;
}
}//GParted

View File

@ -186,7 +186,7 @@ void VBox_VisualDisk::Build_Legend( )
if ( legende_allow )
{
Add_Legend_Item( partitions[ i ] .filesystem + " " , partitions[ i ] .color ) ;
//make sure this color isn't added to the legende again.
legende.push_back( partitions[i].filesystem );
}
@ -194,21 +194,16 @@ void VBox_VisualDisk::Build_Legend( )
legende_allow = true;
}
//remove trailing whitespaces of last label_temp...
if ( label_temp )
label_temp ->set_text( label_temp ->get_text() .substr( 0, label_temp ->get_text() .length() -3) ) ;
//if there are any partitions add used/unused
if ( ! only_unallocated )
{
frame_disk_legend = manage( new Gtk::Frame() ) ;
hbox_legend_main.pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING );
hbox_legend_main.pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING );
hbox_legend = manage( new Gtk::HBox() );
frame_disk_legend ->add( *hbox_legend );
Add_Legend_Item( (Glib::ustring) _( "used" ) + " ", color_used ) ;
Add_Legend_Item( (Glib::ustring) _( "used" ) + " ", color_used ) ;
Add_Legend_Item( (Glib::ustring) _( "unused") + " ", color_unused ) ;
}
@ -217,15 +212,14 @@ void VBox_VisualDisk::Build_Legend( )
void VBox_VisualDisk::Add_Legend_Item( const Glib::ustring & filesystem, const Gdk::Color & color )
{
//the colored square
entry_temp = manage ( new Gtk::Entry() );
entry_temp->set_sensitive( false );
entry_temp->set_size_request( 15,15);
entry_temp->modify_base( entry_temp->get_state(), color );
entry_temp = manage ( new Gtk::Entry() );
entry_temp ->set_sensitive( false );
entry_temp ->set_size_request( 15,15);
entry_temp ->modify_base( entry_temp->get_state(), color );
hbox_legend ->pack_start( *entry_temp, Gtk::PACK_SHRINK );
//and the label
label_temp = manage( new Gtk::Label( " " + filesystem ) );
hbox_legend ->pack_start( *label_temp, Gtk::PACK_SHRINK );
hbox_legend ->pack_start( * mk_label( " " + filesystem, false, false ), Gtk::PACK_SHRINK );
}
void VBox_VisualDisk::Set_Selected( const Partition & partition )

View File

@ -202,10 +202,7 @@ void Win_GParted::init_device_info()
int top =0, bottom = 1;
//title
label = manage( new Gtk::Label() ) ;
label ->set_alignment( Gtk::ALIGN_LEFT ) ;
label ->set_markup( " <b>" + (Glib::ustring) _( "Harddisk Information" ) + ":</b>" ) ;
vbox_info .pack_start( *label, Gtk::PACK_SHRINK );
vbox_info .pack_start( * mk_label( " <b>" + (Glib::ustring) _( "Harddisk Information" ) + ":</b>" ), Gtk::PACK_SHRINK );
//GENERAL DEVICE INFO
table = manage( new Gtk::Table() ) ;
@ -400,10 +397,7 @@ void Win_GParted::Find_Devices()
hbox ->pack_start( *image, Gtk::PACK_SHRINK );
//the label...
label = manage( new Gtk::Label( " " + devices[i] ->Get_Path() + "\t(" + String::ucompose( _("%1 MB"), Sector_To_MB( devices[i] ->Get_Length() ) ) + ")" ) ) ;
label ->set_alignment( Gtk::ALIGN_LEFT );
hbox ->pack_start( *label, Gtk::PACK_SHRINK );
hbox ->pack_start( *mk_label( " " + devices[i] ->Get_Path() + "\t(" + String::ucompose( _("%1 MB"), Sector_To_MB( devices[i] ->Get_Length() ) ) + ")" ), Gtk::PACK_SHRINK );
menu_item = manage( new Gtk::MenuItem( *hbox ) ) ;
menu_devices .items().push_back( *menu_item );
@ -789,11 +783,10 @@ void Win_GParted::activate_resize()
//pffff this whole mess only for this f*cked up filesystem :-(
Gtk::Button button_resize_move ;
Gtk::HBox hbox_resize_move;
Gtk::Label label_resize_move( _("Resize/Move") );
image = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
hbox_resize_move .pack_start( *image, Gtk::PACK_SHRINK ) ;
hbox_resize_move .pack_start( label_resize_move, Gtk::PACK_SHRINK ) ;
hbox_resize_move .pack_start( * mk_label( _("Resize/Move") ), Gtk::PACK_SHRINK ) ;
button_resize_move .add( hbox_resize_move ) ;
dialog .add_action_widget ( button_resize_move,Gtk::RESPONSE_OK ) ;