2009-11-05 11:08:32 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
2010-08-10 11:36:10 -06:00
|
|
|
* Copyright (C) 2008, 2009, 2010 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
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2004-09-19 14:24:53 -06:00
|
|
|
*/
|
2013-05-27 05:20:16 -06:00
|
|
|
|
|
|
|
#ifndef GPARTED_WIN_GPARTED_H
|
|
|
|
#define GPARTED_WIN_GPARTED_H
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2016-10-18 16:45:28 -06:00
|
|
|
#include "Device.h"
|
|
|
|
#include "DrawingAreaVisualDisk.h"
|
|
|
|
#include "Partition.h"
|
|
|
|
#include "PartitionVector.h"
|
|
|
|
#include "TreeView_Detail.h"
|
|
|
|
#include "GParted_Core.h"
|
|
|
|
#include "HBoxOperations.h"
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
#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
|
|
|
|
{
|
2015-09-15 08:34:12 -06:00
|
|
|
|
|
|
|
enum MergeType
|
|
|
|
{
|
|
|
|
MERGE_LAST_WITH_PREV = 0,
|
|
|
|
MERGE_LAST_WITH_ANY = 1,
|
|
|
|
MERGE_ALL_ADJACENT = 2
|
|
|
|
};
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
class Win_GParted : public Gtk::Window
|
|
|
|
{
|
|
|
|
public:
|
2006-02-02 06:50:37 -07:00
|
|
|
Win_GParted( const std::vector<Glib::ustring> & user_devices ) ;
|
2015-09-10 05:44:48 -06:00
|
|
|
~Win_GParted();
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
private:
|
2015-09-10 05:44:48 -06:00
|
|
|
Win_GParted( const Win_GParted & src ); // Not implemented copy constructor
|
|
|
|
Win_GParted & operator=( const Win_GParted & rhs ); // Not implemented copy assignment operator
|
|
|
|
|
2006-02-22 15:05:15 -07:00
|
|
|
void init_menubar() ;
|
|
|
|
void init_toolbar() ;
|
|
|
|
void init_partition_menu() ;
|
|
|
|
Gtk::Menu * create_format_menu() ;
|
2018-01-02 10:44:01 -07:00
|
|
|
void create_format_menu_add_item( FSType filesystem, bool activate );
|
2006-02-22 15:05:15 -07:00
|
|
|
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 ) ;
|
2013-02-21 17:57:33 -07:00
|
|
|
void hide_pulsebar();
|
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
|
|
|
|
2017-04-21 01:30:39 -06:00
|
|
|
void Add_Operation( const Device & device, Operation * operation );
|
2015-09-15 07:30:03 -06:00
|
|
|
bool merge_two_operations( unsigned int first, unsigned int second );
|
2015-09-15 08:34:12 -06:00
|
|
|
void merge_operations( MergeType mergetype );
|
2006-02-22 15:05:15 -07:00
|
|
|
void Refresh_Visual();
|
2015-09-15 07:30:03 -06:00
|
|
|
bool valid_display_partition_ptr( const Partition * partition_ptr );
|
2006-02-22 15:05:15 -07:00
|
|
|
bool Quit_Check_Operations();
|
2006-02-08 13:36:18 -07:00
|
|
|
void set_valid_operations() ;
|
2013-05-17 10:01:42 -06:00
|
|
|
void show_operationslist() ;
|
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 ) ; }
|
2012-06-17 05:26:49 -06:00
|
|
|
|
2016-10-25 03:47:38 -06:00
|
|
|
void allow_toggle_crypt_busy_state( bool state ) {
|
|
|
|
toggle_item( state, MENU_TOGGLE_CRYPT_BUSY ); }
|
|
|
|
|
2016-10-25 05:05:47 -06:00
|
|
|
void allow_toggle_fs_busy_state( bool state ) {
|
|
|
|
toggle_item( state, MENU_TOGGLE_FS_BUSY ); }
|
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 ) ; }
|
|
|
|
|
2014-12-18 15:18:33 -07:00
|
|
|
void allow_label_filesystem( bool state ) {
|
2008-04-07 13:41:18 -06:00
|
|
|
toggle_item( state, MENU_LABEL_PARTITION ) ; }
|
|
|
|
|
2014-12-12 00:00:02 -07:00
|
|
|
void allow_name_partition( bool state ) {
|
|
|
|
toggle_item( state, MENU_NAME_PARTITION ); }
|
|
|
|
|
2012-01-22 13:49:52 -07:00
|
|
|
void allow_change_uuid( bool state ) {
|
|
|
|
toggle_item( state, MENU_CHANGE_UUID ) ; }
|
|
|
|
|
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 ) ;
|
|
|
|
}
|
2016-09-10 12:34:10 -06:00
|
|
|
|
|
|
|
static bool unmount_partition( const Partition & partition, Glib::ustring & error );
|
|
|
|
|
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() ;
|
2016-09-21 06:49:02 -06:00
|
|
|
|
|
|
|
static gboolean initial_device_refresh( gpointer data );
|
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
|
|
|
|
2015-05-16 10:06:22 -06:00
|
|
|
void on_partition_selected( const Partition * partition_ptr, bool src_is_treeview );
|
2005-12-23 17:06:05 -07:00
|
|
|
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();
|
2018-01-02 10:44:01 -07:00
|
|
|
void activate_format( FSType new_fs );
|
2018-02-11 14:07:00 -07:00
|
|
|
bool open_encrypted_partition( const Partition & partition, const char * password, Glib::ustring & message );
|
2016-10-25 03:47:38 -06:00
|
|
|
void toggle_crypt_busy_state();
|
2016-09-11 07:52:47 -06:00
|
|
|
bool check_toggle_busy_allowed( const Glib::ustring & disallowed_msg );
|
|
|
|
void show_toggle_failure_dialog( const Glib::ustring & failure_summary,
|
|
|
|
const Glib::ustring & marked_up_error );
|
2016-10-25 05:05:47 -06:00
|
|
|
void toggle_fs_busy_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() ;
|
2011-01-28 11:09:21 -07:00
|
|
|
void activate_attempt_rescue_data();
|
2006-03-31 03:49:27 -07:00
|
|
|
void activate_manage_flags() ;
|
2006-11-26 07:27:16 -07:00
|
|
|
void activate_check() ;
|
2012-01-22 13:49:52 -07:00
|
|
|
void activate_change_uuid() ;
|
2014-12-18 15:18:33 -07:00
|
|
|
void activate_label_filesystem();
|
2014-12-12 00:00:02 -07:00
|
|
|
void activate_name_partition();
|
2014-12-18 15:18:33 -07: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 ) ;
|
2010-08-09 13:33:28 -06:00
|
|
|
int partition_in_operation_queue_count( const Partition & partition ) ;
|
2010-08-10 12:52:59 -06:00
|
|
|
int active_partitions_on_device_count( const Device & device ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
void activate_apply();
|
2012-07-05 16:33:04 -06:00
|
|
|
bool remove_non_empty_lvm2_pv_dialog( const OperationType optype ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//private variables
|
2004-11-17 06:00:25 -07:00
|
|
|
unsigned int current_device ;
|
2015-05-23 13:22:37 -06:00
|
|
|
PartitionVector display_partitions; // Copy of current device's partitions with any pending
|
2015-05-15 08:51:26 -06:00
|
|
|
// operations applied, as currently being shown in the GUI.
|
2015-05-17 07:01:48 -06:00
|
|
|
const Partition * selected_partition_ptr; // Pointer to the selected partition. (Alias to element
|
|
|
|
// in Win_GParted::display_partitions[] vector).
|
2015-09-10 05:44:48 -06:00
|
|
|
const Partition * copied_partition; // NULL or copy of source partition object.
|
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::Tooltips tooltips ;
|
|
|
|
Gtk::Table *table ;
|
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 ;
|
Prevent flashing redraw of the devices combobox (#696149)
The device combobox was getting drawn blank, then getting drawn again
with the selected device. This was happening because at the start of
Win_GParted::refresh_combo_devices() the GTK model behind the combobox,
liststore_devices, was cleared, changing the active item, causing the
combobox to get redrawn empty. After the GTK model had been repopulated
the active item was reset causing the comboxbox to get redrawn again,
now showing the selected device. Call flow:
Win_GParted::refresh_combo_devices()
liststore_devices->clear()
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
...
combo_devices.set_active(current_device);
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
This has always been the case, since the device combobox was first added
to GParted before version 0.1 by commit:
3a4b43e0adb3974dea656fcbe90d5e191e0e9784
replaced deprecated OptionMenu with ComboBox ...
Fix by temporarily blocking the devices comboxbox from emitting
signal_changed while the GTK model behind the combobox is recreated.
However, since automatic selection of the largest free space was added
[1] in GParted 0.15.0, a more noticeable flashing redraw issue was
caused in which the partition graphic and partition list were both drawn
blank then redrawn fully populated. Some distributions were not
affected by this at all, some only experienced a single flash and others
suffered from two or more flashing redraws. Some affected
distributions: CentOS 5.10, 6.5, 7.0, Debian 6, Fedora 14, 19, 20,
Ubuntu 13.10, Xubuntu 14.04 LTS. Did not occur on Kubuntu 12.04 LTS.
[1] 5b53c12f6ee12312a9bacb44b8b05b12a540d3d6
Select largest unallocated partition by default (#667365)
Bug #696149 - Double refresh of display introduced with default
unallocated space
2014-08-22 04:35:39 -06:00
|
|
|
sigc::connection combo_devices_changed_connection;
|
2005-12-29 16:35:37 -07:00
|
|
|
|
|
|
|
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,
|
2016-10-25 03:47:38 -06:00
|
|
|
MENU_TOGGLE_CRYPT_BUSY,
|
2016-10-25 05:05:47 -06:00
|
|
|
MENU_TOGGLE_FS_BUSY,
|
2006-08-20 10:51:18 -06:00
|
|
|
MENU_MOUNT,
|
2014-12-12 00:00:02 -07:00
|
|
|
MENU_NAME_PARTITION,
|
2006-08-20 10:51:18 -06:00
|
|
|
MENU_FLAGS,
|
2008-04-07 13:41:18 -06:00
|
|
|
MENU_CHECK,
|
2012-01-22 13:49:52 -07:00
|
|
|
MENU_LABEL_PARTITION,
|
|
|
|
MENU_CHANGE_UUID,
|
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...
|
2004-10-02 03:39:16 -06:00
|
|
|
unsigned short new_count;//new_count keeps track of the new created partitions
|
2006-02-22 15:05:15 -07:00
|
|
|
bool OPERATIONSLIST_OPEN ;
|
2016-12-16 00:31:49 -07: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
|
2013-01-14 19:20:49 -07:00
|
|
|
bool pulsebar_pulse();
|
2013-02-21 17:57:33 -07:00
|
|
|
sigc::connection pulsetimer;
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
|
|
|
|
2013-05-27 05:20:16 -06:00
|
|
|
#endif /* GPARTED_WIN_GPARTED_H */
|