added colorsupport to mklabel in Util.h and replaced self-made widget with UTF-8 block in VBox_VisualDisk.cc/.h

This commit is contained in:
Bart Hakvoort 2004-10-07 14:12:34 +00:00
parent bd3152788f
commit 4d47390878
4 changed files with 49 additions and 52 deletions

View File

@ -1,3 +1,9 @@
2004-10-07 Bart Hakvoort <gparted@users.sf.net>
* include/Utils.h: added support for colored text to mk_label
* include/VBox_VisualDisk.h,
include/VBox_VisualDisk.cc: use UTF-8 character ██ instead of some self-forged widget.
2004-10-06 Bart Hakvoort <gparted@users.sf.net>
* implemented mk_label wherever possible (means less code, improved readability)

View File

@ -63,7 +63,7 @@ inline Sector Abs( Sector sectors )
return sectors < 0 ? sectors - 2*sectors : sectors ;
}
inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true, bool align_left = true, bool wrap = false )
inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true, bool align_left = true, bool wrap = false, const Glib::ustring & text_color = "black" )
{
Gtk::Label * label = manage( new Gtk::Label( text ) ) ;
@ -74,6 +74,12 @@ inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true
label ->set_line_wrap( wrap ) ;
if ( text_color != "black" )
{
Gdk::Color color( text_color ) ;
label ->modify_fg( label ->get_state(), color ) ;
}
return label ;
}

View File

@ -25,8 +25,6 @@
#include <gtkmm/frame.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/tooltips.h>
#include <gtkmm/label.h>
#include <gtkmm/entry.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/drawingarea.h>
@ -67,7 +65,6 @@ public:
private:
void Build_Visual_Disk( int ) ; //i still dream of some fully resizeable visualdisk....
void Build_Legend( ) ;
void Add_Legend_Item( const Glib::ustring & filesystem, const Gdk::Color & color );
//signal handlers
void drawingarea_on_realize( Visual_Partition * );
@ -90,7 +87,6 @@ private:
Glib::ustring str_temp ;
int temp,selected_partition;
Gtk::Entry *entry_temp;
};
} //GParted

View File

@ -111,7 +111,7 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
partitions[i] .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
if ( partitions[i].inside_extended )
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 10 ; }
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 9 ; }
else
{ visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; }
@ -171,27 +171,27 @@ void VBox_VisualDisk::Build_Legend( )
this ->pack_start( hbox_legend_main );
std::vector<Glib::ustring> legende;
bool legende_allow = true, only_unallocated = true;
bool only_unallocated = true;
for ( unsigned int i=0;i<partitions.size();i++ )
{
if ( partitions[i].type != GParted::UNALLOCATED && partitions[i].type != GParted::EXTENDED )
only_unallocated = false;
//check if filesystem is already in legende
for ( unsigned int t=0;t<legende.size();t++) //not very nice, but very effective :P
if ( partitions[i].filesystem == legende[t] )
{ legende_allow = false; break; }
if ( legende_allow )
if ( std::find( legende .begin(), legende .end(), partitions[i] .filesystem ) == legende .end() )
{
Add_Legend_Item( partitions[ i ] .filesystem + " " , partitions[ i ] .color ) ;
if ( legende .size() )
hbox_legend ->pack_start( * mk_label( " " ), Gtk::PACK_SHRINK );
else
hbox_legend ->pack_start( * mk_label( " " ), Gtk::PACK_SHRINK );
//make sure this color isn't added to the legende again.
hbox_legend ->pack_start( * mk_label( "██ ", false, false, false, partitions[i] .color_string ), Gtk::PACK_SHRINK );
hbox_legend ->pack_start( * mk_label( partitions[i] .filesystem + " " ), Gtk::PACK_SHRINK );
//make sure this color isn't added to the legend again.
legende .push_back( partitions[i] .filesystem );
}
legende_allow = true;
}
//if there are any partitions add used/unused
@ -203,25 +203,14 @@ void VBox_VisualDisk::Build_Legend( )
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) _( "unused") + " ", color_unused ) ;
hbox_legend ->pack_start( * mk_label( " ██ ", false, false, false, "#F8F8BA" ), Gtk::PACK_SHRINK );
hbox_legend ->pack_start( * mk_label( "used " ), Gtk::PACK_SHRINK );
hbox_legend ->pack_start( * mk_label( "██ ", false, false, false, "white" ), Gtk::PACK_SHRINK );
hbox_legend ->pack_start( * mk_label( "unused " ), Gtk::PACK_SHRINK );
}
}
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 );
hbox_legend ->pack_start( *entry_temp, Gtk::PACK_SHRINK );
//and the label
hbox_legend ->pack_start( * mk_label( " " + filesystem, false, false ), Gtk::PACK_SHRINK );
}
void VBox_VisualDisk::Set_Selected( const Partition & partition )
{
//clean previously selected one