2009-11-05 11:08:32 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
* Copyright (C) 2008, 2009 Curtis Gedak
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WIN_GPARTED
|
|
|
|
#define WIN_GPARTED
|
|
|
|
|
|
|
|
#include "../include/Device.h"
|
2006-03-09 06:12:44 -07:00
|
|
|
#include "../include/DrawingAreaVisualDisk.h"
|
2004-09-19 14:24:53 -06:00
|
|
|
#include "../include/Partition.h"
|
|
|
|
#include "../include/TreeView_Detail.h"
|
2004-11-17 06:00:25 -07:00
|
|
|
#include "../include/GParted_Core.h"
|
2006-09-17 07:23:47 -06:00
|
|
|
#include "../include/HBoxOperations.h"
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
#include <sigc++/class_slot.h>
|
|
|
|
#include <gtkmm/paned.h>
|
|
|
|
#include <gtkmm/toolbar.h>
|
|
|
|
#include <gtkmm/separatortoolitem.h>
|
|
|
|
#include <gtkmm/menubar.h>
|
|
|
|
#include <gtkmm/statusbar.h>
|
2005-12-29 16:35:37 -07:00
|
|
|
#include <gtkmm/combobox.h>
|
2006-01-24 05:31:58 -07:00
|
|
|
#include <gtkmm/progressbar.h>
|
2006-01-26 13:58:55 -07:00
|
|
|
#include <gtkmm/window.h>
|
|
|
|
#include <gtkmm/table.h>
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
class Win_GParted : public Gtk::Window
|
|
|
|
{
|
|
|
|
public:
|
2006-02-02 06:50:37 -07:00
|
|
|
Win_GParted( const std::vector<Glib::ustring> & user_devices ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
private:
|
2006-02-22 15:05:15 -07:00
|
|
|
void init_menubar() ;
|
|
|
|
void init_toolbar() ;
|
|
|
|
void init_partition_menu() ;
|
|
|
|
Gtk::Menu * create_format_menu() ;
|
|
|
|
void init_device_info() ;
|
|
|
|
void init_hpaned_main() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-12-29 16:35:37 -07:00
|
|
|
void refresh_combo_devices() ;
|
2006-01-08 08:20:14 -07:00
|
|
|
void show_pulsebar( const Glib::ustring & status_message ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//Fill txtview_device_info_buffer with some information about the selected device
|
2005-02-01 10:04:03 -07:00
|
|
|
void Fill_Label_Device_Info( bool clear = false );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-08-01 14:19:17 -06:00
|
|
|
void Add_Operation( Operation * operation, int index = -1 ) ;
|
2006-02-22 15:05:15 -07:00
|
|
|
void Refresh_Visual();
|
|
|
|
bool Quit_Check_Operations();
|
2006-02-08 13:36:18 -07:00
|
|
|
void set_valid_operations() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//convenience functions
|
2006-08-20 10:51:18 -06:00
|
|
|
void toggle_item( bool state, int menu_item, int toolbar_item = -1 )
|
|
|
|
{
|
|
|
|
if ( menu_item >= 0 && menu_item < static_cast<int>( menu_partition .items() .size() ) )
|
|
|
|
menu_partition .items()[ menu_item ] .set_sensitive( state ) ;
|
|
|
|
|
|
|
|
if ( toolbar_item >= 0 && toolbar_item < toolbar_main .get_n_items() )
|
|
|
|
toolbar_main .get_nth_item( toolbar_item ) ->set_sensitive( state ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void allow_new( bool state ) {
|
|
|
|
toggle_item( state, MENU_NEW, TOOLBAR_NEW ) ; }
|
2004-11-06 12:48:24 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_delete( bool state ) {
|
|
|
|
toggle_item( state, MENU_DEL, TOOLBAR_DEL ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_resize( bool state ) {
|
|
|
|
toggle_item( state, MENU_RESIZE_MOVE, TOOLBAR_RESIZE_MOVE ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_copy( bool state ) {
|
|
|
|
toggle_item( state, MENU_COPY, TOOLBAR_COPY ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_paste( bool state ) {
|
|
|
|
toggle_item( state, MENU_PASTE, TOOLBAR_PASTE ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_format( bool state ) {
|
|
|
|
toggle_item( state, MENU_FORMAT ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_toggle_swap_mount_state( bool state ) {
|
|
|
|
toggle_item( state, MENU_TOGGLE_MOUNT_SWAP ) ; }
|
2006-03-31 03:49:27 -07:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_manage_flags( bool state ) {
|
|
|
|
toggle_item( state, MENU_FLAGS ) ; }
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-11-26 07:27:16 -07:00
|
|
|
void allow_check( bool state ) {
|
|
|
|
toggle_item( state, MENU_CHECK ) ; }
|
|
|
|
|
2008-04-07 13:41:18 -06:00
|
|
|
void allow_label_partition( bool state ) {
|
|
|
|
toggle_item( state, MENU_LABEL_PARTITION ) ; }
|
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
void allow_info( bool state ) {
|
|
|
|
toggle_item( state, MENU_INFO ) ; }
|
2006-09-16 05:27:05 -06:00
|
|
|
|
|
|
|
void allow_undo_clear_apply( bool state )
|
|
|
|
{
|
2006-08-20 10:51:18 -06:00
|
|
|
toggle_item( state, -1, TOOLBAR_UNDO ) ;
|
2006-02-22 15:05:15 -07:00
|
|
|
static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 0 ] )
|
2006-09-16 05:27:05 -06:00
|
|
|
->set_sensitive( state ) ;
|
|
|
|
|
2006-02-22 15:05:15 -07:00
|
|
|
static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 1 ] )
|
2006-09-16 05:27:05 -06:00
|
|
|
->set_sensitive( state ) ;
|
|
|
|
|
|
|
|
toggle_item( state, -1, TOOLBAR_APPLY ) ;
|
|
|
|
static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 2 ] )
|
|
|
|
->set_sensitive( state ) ;
|
|
|
|
}
|
2005-11-27 12:48:00 -07:00
|
|
|
|
2006-01-08 08:20:14 -07:00
|
|
|
//threads..
|
|
|
|
void thread_refresh_devices() ;
|
2006-02-15 09:05:26 -07:00
|
|
|
void thread_unmount_partition( bool * succes, Glib::ustring * error ) ;
|
2006-03-16 10:09:17 -07:00
|
|
|
void thread_mount_partition( Glib::ustring mountpoint, bool * succes, Glib::ustring * error ) ;
|
2006-02-15 09:05:26 -07:00
|
|
|
void thread_toggle_swap( bool * succes, Glib::ustring * error ) ;
|
2006-01-08 08:20:14 -07:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//signal handlers
|
2006-02-22 15:05:15 -07:00
|
|
|
void open_operationslist() ;
|
|
|
|
void close_operationslist() ;
|
|
|
|
void clear_operationslist() ;
|
|
|
|
void combo_devices_changed();
|
2006-02-02 03:59:44 -07:00
|
|
|
void radio_devices_changed( unsigned int item ) ;
|
2006-03-24 12:08:41 -07:00
|
|
|
bool on_delete_event( GdkEventAny* ) ;
|
2006-04-02 08:04:44 -06:00
|
|
|
void on_show() ;
|
2004-09-27 14:12:47 -06:00
|
|
|
|
2006-02-22 15:05:15 -07:00
|
|
|
void menu_gparted_refresh_devices();
|
2006-04-05 03:33:04 -06:00
|
|
|
void menu_gparted_features();
|
2006-02-22 15:05:15 -07:00
|
|
|
void menu_gparted_quit();
|
|
|
|
void menu_view_harddisk_info();
|
|
|
|
void menu_view_operations();
|
2009-10-24 14:16:40 -06:00
|
|
|
void show_disklabel_unrecognized( Glib::ustring device_name );
|
2009-11-03 10:27:35 -07:00
|
|
|
void show_help_dialog( const Glib::ustring & filename, const Glib::ustring & link_id );
|
2006-02-22 15:05:15 -07:00
|
|
|
void menu_help_contents();
|
|
|
|
void menu_help_about();
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-12-23 17:06:05 -07:00
|
|
|
void on_partition_selected( const Partition & partition, bool src_is_treeview ) ;
|
|
|
|
void on_partition_activated() ;
|
|
|
|
void on_partition_popup_menu( unsigned int button, unsigned int time ) ;
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
bool max_amount_prim_reached() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-07 14:23:09 -07:00
|
|
|
void activate_resize();
|
|
|
|
void activate_copy();
|
|
|
|
void activate_paste();
|
|
|
|
void activate_new();
|
|
|
|
void activate_delete();
|
|
|
|
void activate_info();
|
2006-01-02 08:18:29 -07:00
|
|
|
void activate_format( GParted::FILESYSTEM new_fs );
|
2006-03-09 12:37:50 -07:00
|
|
|
void toggle_swap_mount_state() ;
|
2006-03-16 10:09:17 -07:00
|
|
|
void activate_mount_partition( unsigned int index ) ;
|
2006-01-07 14:23:09 -07:00
|
|
|
void activate_disklabel() ;
|
2006-03-31 03:49:27 -07:00
|
|
|
void activate_manage_flags() ;
|
2006-11-26 07:27:16 -07:00
|
|
|
void activate_check() ;
|
2008-04-07 13:41:18 -06:00
|
|
|
void activate_label_partition() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
void activate_undo();
|
2006-03-24 12:08:41 -07:00
|
|
|
void remove_operation( int index = -1, bool remove_all = false ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
void activate_apply();
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//private variables
|
2004-11-17 06:00:25 -07:00
|
|
|
unsigned int current_device ;
|
2004-09-19 14:24:53 -06:00
|
|
|
Partition selected_partition, copied_partition;
|
2006-01-02 08:18:29 -07:00
|
|
|
std::vector<Device> devices;
|
2006-03-24 12:08:41 -07:00
|
|
|
std::vector<Operation *> operations;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//gui stuff
|
|
|
|
Gtk::HPaned hpaned_main;
|
|
|
|
Gtk::VPaned vpaned_main;
|
2006-09-16 05:27:05 -06:00
|
|
|
Gtk::VBox vbox_main,vbox_info ;
|
2006-09-17 07:23:47 -06:00
|
|
|
Gtk::HBox hbox_toolbar, *hbox;
|
2004-09-19 14:24:53 -06:00
|
|
|
Gtk::Toolbar toolbar_main;
|
|
|
|
Gtk::MenuBar menubar_main;
|
2005-12-29 16:35:37 -07:00
|
|
|
Gtk::ComboBox combo_devices ;
|
2006-01-02 08:18:29 -07:00
|
|
|
Gtk::Menu menu_partition, *menu ;
|
2004-09-19 14:24:53 -06:00
|
|
|
Gtk::ToolButton *toolbutton;
|
|
|
|
Gtk::Statusbar statusbar;
|
|
|
|
Gtk::Image *image ;
|
|
|
|
Gtk::ScrolledWindow *scrollwindow;
|
|
|
|
Gtk::Label label_device_info1, label_device_info2, *label;
|
|
|
|
Gtk::Tooltips tooltips ;
|
|
|
|
Gtk::Table *table ;
|
|
|
|
Gtk::MenuItem *menu_item;
|
2006-01-07 14:23:09 -07:00
|
|
|
Gtk::ProgressBar pulsebar ;
|
2005-12-29 16:35:37 -07:00
|
|
|
Gtk::TreeRow treerow;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
DrawingAreaVisualDisk drawingarea_visualdisk ;
|
2004-09-19 14:24:53 -06:00
|
|
|
TreeView_Detail treeview_detail;
|
2006-09-17 07:23:47 -06:00
|
|
|
HBoxOperations hbox_operations ;
|
2005-12-29 16:35:37 -07:00
|
|
|
|
|
|
|
//device combo
|
|
|
|
Glib::RefPtr<Gtk::ListStore> liststore_devices ;
|
|
|
|
|
|
|
|
struct treeview_devices_Columns : public Gtk::TreeModelColumnRecord
|
|
|
|
{
|
|
|
|
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > icon ;
|
|
|
|
Gtk::TreeModelColumn<Glib::ustring> device ;
|
|
|
|
Gtk::TreeModelColumn<Glib::ustring> size ;
|
|
|
|
|
|
|
|
treeview_devices_Columns()
|
|
|
|
{
|
|
|
|
add( icon ) ;
|
|
|
|
add( device ) ;
|
|
|
|
add( size ) ;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
treeview_devices_Columns treeview_devices_columns ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-08-20 10:51:18 -06:00
|
|
|
//indices for partitionmenu and toolbar
|
|
|
|
int
|
|
|
|
MENU_NEW, TOOLBAR_NEW,
|
|
|
|
MENU_DEL, TOOLBAR_DEL,
|
|
|
|
MENU_RESIZE_MOVE, TOOLBAR_RESIZE_MOVE,
|
|
|
|
MENU_COPY, TOOLBAR_COPY,
|
|
|
|
MENU_PASTE, TOOLBAR_PASTE,
|
|
|
|
MENU_FORMAT,
|
|
|
|
MENU_TOGGLE_MOUNT_SWAP,
|
|
|
|
MENU_MOUNT,
|
|
|
|
MENU_FLAGS,
|
2008-04-07 13:41:18 -06:00
|
|
|
MENU_CHECK,
|
|
|
|
MENU_LABEL_PARTITION,
|
2006-08-20 10:51:18 -06:00
|
|
|
MENU_INFO,
|
|
|
|
TOOLBAR_UNDO,
|
|
|
|
TOOLBAR_APPLY ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//usefull variables which are used by many different functions...
|
2006-03-24 12:08:41 -07:00
|
|
|
int index_extended ; //position of the extended partition (-1 means there isn't one)
|
2004-10-02 03:39:16 -06:00
|
|
|
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
|
|
|
|
unsigned short new_count;//new_count keeps track of the new created partitions
|
2004-12-13 06:58:51 -07:00
|
|
|
FS fs ;
|
2006-02-22 15:05:15 -07:00
|
|
|
bool OPERATIONSLIST_OPEN ;
|
2004-10-02 03:39:16 -06:00
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
GParted_Core gparted_core ;
|
2005-12-29 16:35:37 -07:00
|
|
|
std::vector<Gtk::Label *> device_info ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2004-10-16 09:42:08 -06:00
|
|
|
//stuff for progress overview and pulsebar
|
2004-10-11 04:23:24 -06:00
|
|
|
Glib::Thread *thread ;
|
2006-01-19 12:15:15 -07:00
|
|
|
bool pulse ;
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
|
|
|
|
|
|
|
#endif //WIN_GPARTED
|