├── flatpak ├── polkit-autogen └── polkit-build-Add-option-to-build-without-polkitd.patch ├── AUTHORS ├── po ├── ChangeLog ├── meson.build ├── LINGUAS └── POTFILES.in ├── data ├── screenshots │ ├── disks-main.png │ ├── disks-format.png │ └── disks-smart.png ├── org.gnome.DiskUtility.service.in ├── gnome-disk-image-mounter.desktop.in ├── org.gnome.DiskUtility.desktop.in ├── org.gnome.Disks.gschema.xml ├── meson.build ├── org.gnome.DiskUtility.metainfo.xml.in └── icons │ └── hicolor │ └── scalable │ └── apps │ ├── org.gnome.DiskUtility-symbolic.svg │ └── gnome-disks-state-standby-symbolic.svg ├── src ├── libgdu │ ├── lib.rs │ ├── config.rs.in │ ├── libgdu.h │ ├── libgdutypes.h │ ├── libgduenums.h │ ├── libgduenumtypes.h.template │ ├── Cargo.toml │ ├── libgduenumtypes.c.template │ ├── enums.rs │ ├── gettext.rs │ └── meson.build ├── disks │ ├── lib.rs │ ├── config.rs.in │ ├── gdu-rust.h │ ├── ui │ │ ├── gdu-drive-row.ui │ │ ├── style-dark.css │ │ ├── gdu-create-other-page.ui │ │ ├── style.css │ │ ├── gdu-format-volume-dialog.ui │ │ ├── gdu-edit-filesystem-dialog.ui │ │ ├── gdu-create-confirm-page.ui │ │ ├── gdu-take-ownership-dialog.ui │ │ ├── gdu-create-password-page.ui │ │ ├── gdu-create-disk-image-dialog.ui │ │ ├── erase-multiple-disks-dialog.ui │ │ ├── gdu-restore-disk-image-dialog.ui │ │ ├── gdu-encryption-options-dialog.ui │ │ ├── shortcuts-dialog.ui │ │ ├── gdu-create-partition-page.ui │ │ ├── gdu-drive-view.ui │ │ └── gdu-change-passphrase-dialog.ui │ ├── gdu-unlock-dialog.h │ ├── gdu-new-disk-image-dialog.h │ ├── gdu-drive-row.h │ ├── gduenumtypes.h.template │ ├── gdu-benchmark-dialog.h │ ├── gdu-edit-partition-dialog.h │ ├── gdu-resize-volume-dialog.h │ ├── gdu-edit-filesystem-dialog.h │ ├── gdu-drive-view.h │ ├── gdu-disk-settings-dialog.h │ ├── gdu-create-confirm-page.h │ ├── Cargo.toml │ ├── gdu-change-passphrase-dialog.h │ ├── gdu-create-disk-image-dialog.h │ ├── gdu-block-row.h │ ├── gdu-encryption-options-dialog.h │ ├── main.c │ ├── gdu-mount-options-dialog.h │ ├── gdu-space-allocation-bar.h │ ├── gdu-ata-smart-dialog.h │ ├── gdu-format-volume-dialog.h │ ├── gdu-window.h │ ├── gdudvdsupport.h │ ├── gdutypes.h │ ├── gdu-format-disk-dialog.h │ ├── gdu-drive-header.h │ ├── gduenums.h │ ├── gduenumtypes.c.template │ ├── gduestimator.h │ ├── gdu-create-partition-page.h │ ├── gdu-create-other-page.h │ ├── gdulocaljob.h │ ├── gdu-manager.h │ ├── gdu-create-filesystem-page.h │ ├── gdu-application.h │ ├── gduxzdecompressor.h │ ├── localjob.rs │ ├── gnome-disks.gresource.xml │ ├── page_aligned_buffer.rs │ ├── gdu-drive-row.c │ ├── gdu-block.h │ ├── gdu-item.h │ ├── ffi │ │ └── mod.rs │ ├── gdu-log.h │ ├── gdu-drive.h │ ├── gdu-item.c │ ├── gdu-create-password-page.h │ ├── estimator.rs │ ├── gdu-edit-filesystem-dialog.c │ └── gdu-create-password-page.c ├── notify │ ├── org.gnome.SettingsDaemon.DiskUtilityNotify.desktop.in │ ├── meson.build │ ├── gdusdmonitor.h │ ├── gdusdmanager.h │ ├── main.c │ └── gdusdmanager.c └── disk-image-mounter │ ├── config.rs.in │ ├── Cargo.toml │ ├── main.rs │ ├── meson.build │ └── application.rs ├── .gitignore ├── .dir-locals.el ├── meson_options.txt ├── doc └── man │ ├── meson.build │ ├── gnome-disk-image-mounter.xml │ └── gnome-disks.xml ├── README.md ├── Cargo.toml ├── .gitlab-ci.yml ├── gnome-disk-utility.doap ├── TODO ├── release └── HACKING /flatpak/polkit-autogen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | gtkdocize --flavour no-tmpl 4 | autoreconf -if 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | David Zeuthen 2 | and the GNOME Project https://www.gnome.org/ 3 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-11-27 Adi Roiban 2 | 3 | * ro.po: Updated Romanian translation 4 | 5 | 6 | -------------------------------------------------------------------------------- /data/screenshots/disks-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GNOME/gnome-disk-utility/HEAD/data/screenshots/disks-main.png -------------------------------------------------------------------------------- /data/screenshots/disks-format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GNOME/gnome-disk-utility/HEAD/data/screenshots/disks-format.png -------------------------------------------------------------------------------- /data/screenshots/disks-smart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GNOME/gnome-disk-utility/HEAD/data/screenshots/disks-smart.png -------------------------------------------------------------------------------- /data/org.gnome.DiskUtility.service.in: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.gnome.DiskUtility 3 | Exec=@bindir@/gnome-disks --gapplication-service 4 | -------------------------------------------------------------------------------- /po/meson.build: -------------------------------------------------------------------------------- 1 | i18n.gettext( 2 | gdu_name, 3 | args: [ 4 | '--keyword=gettext_f', 5 | '--keyword=pgettext_f', 6 | ], 7 | preset: 'glib', 8 | ) 9 | -------------------------------------------------------------------------------- /src/libgdu/lib.rs: -------------------------------------------------------------------------------- 1 | mod config; 2 | 3 | mod enums; 4 | mod gduutils; 5 | pub mod gettext; 6 | pub use enums::{ResizeFlags, UnitSize}; 7 | pub use gduutils::*; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /subprojects/libhandy/ 2 | app/ 3 | builddir/ 4 | org.gnome.DiskUtility.flatpak 5 | repo/ 6 | _build/ 7 | .flatpak-builder/ 8 | target/ 9 | src/*/config.rs 10 | .cache/clangd/index 11 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((nil . ((indent-tabs-mode . nil) 2 | (fill-column . 100))) 3 | (c-mode . ((c-file-style . "gnu") 4 | (c-file-offsets 5 | (brace-list-intro . +)))) 6 | (c-ts-mode . ((c-ts-mode-style . gnu))) 7 | ) 8 | -------------------------------------------------------------------------------- /src/disks/lib.rs: -------------------------------------------------------------------------------- 1 | mod config; 2 | 3 | mod estimator; 4 | mod ffi; 5 | mod gdu_combo_row; 6 | mod localjob; 7 | mod page_aligned_buffer; 8 | mod restore_disk_image_dialog; 9 | pub use restore_disk_image_dialog::GduRestoreDiskImageDialog; 10 | -------------------------------------------------------------------------------- /src/notify/org.gnome.SettingsDaemon.DiskUtilityNotify.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=gnome-disk-utility notification plugin for GNOME Settings Daemon 4 | Exec=@libexecdir@/gsd-disk-utility-notify 5 | OnlyShowIn=GNOME; 6 | NoDisplay=true 7 | X-GNOME-AutoRestart=true 8 | -------------------------------------------------------------------------------- /src/disks/config.rs.in: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; 3 | pub const LOCALEDIR: &str = @LOCALEDIR@; 4 | pub const PKGDATADIR: &str = @PKGDATADIR@; 5 | pub const PROFILE: &str = @PROFILE@; 6 | pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); 7 | pub const VERSION: &str = @VERSION@; 8 | -------------------------------------------------------------------------------- /src/libgdu/config.rs.in: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; 3 | pub const LOCALEDIR: &str = @LOCALEDIR@; 4 | pub const PKGDATADIR: &str = @PKGDATADIR@; 5 | pub const PROFILE: &str = @PROFILE@; 6 | pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); 7 | pub const VERSION: &str = @VERSION@; 8 | -------------------------------------------------------------------------------- /src/disk-image-mounter/config.rs.in: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | pub const APP_ID: &str = @APP_ID@; 3 | pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; 4 | pub const LOCALEDIR: &str = @LOCALEDIR@; 5 | pub const PKGDATADIR: &str = @PKGDATADIR@; 6 | pub const PROFILE: &str = @PROFILE@; 7 | pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); 8 | pub const VERSION: &str = @VERSION@; 9 | -------------------------------------------------------------------------------- /src/libgdu/libgdu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __LIB_GDU_H__ 10 | #define __LIB_GDU_H__ 11 | 12 | #include "libgdutypes.h" 13 | #include "libgduenums.h" 14 | #include "libgduenumtypes.h" 15 | #include "gduutils.h" 16 | 17 | #endif /* __LIB_GDU_H__ */ 18 | -------------------------------------------------------------------------------- /src/disks/gdu-rust.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern void 6 | gdu_rs_restore_disk_image_dialog_show(GtkWindow *parent_window, 7 | const gchar *object_path, 8 | const gchar *disk_image_filename); 9 | 10 | extern gboolean 11 | gdu_rs_has_local_jobs (); 12 | 13 | extern void 14 | gdu_rs_local_jobs_clear (); 15 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-drive-row.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | -------------------------------------------------------------------------------- /src/libgdu/libgdutypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __LIB_GDU_TYPES_H__ 10 | #define __LIB_GDU_TYPES_H__ 11 | 12 | #include 13 | #include 14 | 15 | #include "libgduenums.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | G_END_DECLS 20 | 21 | #endif /* __LIB_GDU_TYPES_H__ */ 22 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('logind', type: 'combo', choices: ['libsystemd', 'libelogind', 'none'], value: 'libsystemd', description: 'build with logind') 2 | option('gsd_plugin', type: 'boolean', value: true, description: 'build gnome-settings-daemon plug-in') 3 | option('man', type: 'boolean', value: true, description: 'generate man pages') 4 | option('profile', type: 'combo', choices: ['release', 'development'], value: 'release', description: 'rust build profile') 5 | -------------------------------------------------------------------------------- /data/gnome-disk-image-mounter.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Disk Image Mounter 3 | Comment=Mount/Write Disk Images 4 | Exec=gnome-disk-image-mounter %U 5 | # Translators: Do NOT translate or transliterate this text (this is an icon file name)! 6 | Icon=drive-removable-media 7 | MimeType=application/x-cd-image;application/x-raw-disk-image;application/x-raw-disk-image-xz-compressed; 8 | Terminal=false 9 | StartupNotify=false 10 | Type=Application 11 | NoDisplay=true 12 | X-Purism-FormFactor=Workstation;Mobile; 13 | -------------------------------------------------------------------------------- /src/disks/ui/style-dark.css: -------------------------------------------------------------------------------- 1 | .grey { 2 | --main-color: #808080; 3 | } 4 | 5 | .blue { 6 | --main-color: var(--blue-5); 7 | } 8 | 9 | .green { 10 | --main-color: var(--green-5); 11 | } 12 | 13 | .yellow { 14 | --main-color: var(--yellow-5); 15 | } 16 | 17 | .orange { 18 | --main-color: var(--orange-5); 19 | } 20 | 21 | .red { 22 | --main-color: var(--red-5); 23 | } 24 | 25 | .purple { 26 | --main-color: var(--purple-5); 27 | } 28 | 29 | .brown { 30 | --main-color: var(--brown-5); 31 | } 32 | -------------------------------------------------------------------------------- /doc/man/meson.build: -------------------------------------------------------------------------------- 1 | xsltproc_cmd = [ 2 | find_program('xsltproc'), 3 | '--output', '@OUTPUT@', 4 | '--nonet', 5 | 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', 6 | '@INPUT@', 7 | ] 8 | 9 | mans = [ 10 | 'gnome-disks', 11 | 'gnome-disk-image-mounter', 12 | ] 13 | 14 | foreach man: mans 15 | output = man + '.1' 16 | 17 | custom_target( 18 | output, 19 | input: man + '.xml', 20 | output: output, 21 | command: xsltproc_cmd, 22 | install: true, 23 | install_dir: gdu_mandir / 'man1', 24 | ) 25 | endforeach 26 | -------------------------------------------------------------------------------- /src/disks/gdu-unlock-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_UNLOCK_DIALOG (gdu_unlock_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduUnlockDialog, gdu_unlock_dialog, GDU, UNLOCK_DIALOG, AdwDialog) 18 | 19 | void gdu_unlock_dialog_show (GtkWindow *parent_window, 20 | UDisksObject *object); 21 | 22 | G_END_DECLS 23 | -------------------------------------------------------------------------------- /src/libgdu/libgduenums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __LIB_GDU_ENUMS_H__ 10 | #define __LIB_GDU_ENUMS_H__ 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | typedef enum 17 | { 18 | GDU_FORMAT_DURATION_FLAGS_NONE = 0, 19 | GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION = (1<<0), 20 | GDU_FORMAT_DURATION_FLAGS_NO_SECONDS = (1<<1) 21 | } GduFormatDurationFlags; 22 | 23 | G_END_DECLS 24 | 25 | #endif /* __LIB_GDU_ENUMS_H__ */ 26 | -------------------------------------------------------------------------------- /src/disks/gdu-new-disk-image-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_NEW_DISK_IMAGE_DIALOG (gdu_new_disk_image_dialog_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GduNewDiskImageDialog, gdu_new_disk_image_dialog, GDU, NEW_DISK_IMAGE_DIALOG, AdwDialog) 19 | 20 | void gdu_new_disk_image_dialog_show (UDisksClient *client, GtkWindow *window); 21 | 22 | G_END_DECLS 23 | -------------------------------------------------------------------------------- /src/disks/gdu-drive-row.h: -------------------------------------------------------------------------------- 1 | /* gdu-drive-row.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "gdu-drive.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | #define GDU_TYPE_DRIVE_ROW (gdu_drive_row_get_type ()) 20 | G_DECLARE_FINAL_TYPE (GduDriveRow, gdu_drive_row, GDU, DRIVE_ROW, AdwActionRow) 21 | 22 | GduDriveRow *gdu_drive_row_new (GduDrive *drive); 23 | GduDrive *gdu_drive_row_get_drive (GduDriveRow *self); 24 | 25 | G_END_DECLS 26 | -------------------------------------------------------------------------------- /src/disks/gduenumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #ifndef __GDU_ENUM_TYPES_H__ 3 | #define __GDU_ENUM_TYPES_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | /*** END file-header ***/ 9 | 10 | /*** BEGIN file-production ***/ 11 | 12 | /* enumerations from "@filename@" */ 13 | /*** END file-production ***/ 14 | 15 | /*** BEGIN value-header ***/ 16 | GType @enum_name@_get_type (void) G_GNUC_CONST; 17 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 18 | /*** END value-header ***/ 19 | 20 | /*** BEGIN file-tail ***/ 21 | G_END_DECLS 22 | 23 | #endif /* __GDU_ENUM_TYPES_H__ */ 24 | /*** END file-tail ***/ 25 | -------------------------------------------------------------------------------- /src/notify/meson.build: -------------------------------------------------------------------------------- 1 | sources = files( 2 | 'gdusdmonitor.c', 3 | 'main.c', 4 | ) 5 | 6 | deps = [ 7 | gmodule_dep, 8 | gtk_dep, 9 | libnotify_dep, 10 | udisk_dep, 11 | ] 12 | 13 | executable( 14 | 'gsd-disk-utility-notify', 15 | sources, 16 | include_directories: top_inc, 17 | dependencies: deps, 18 | install: true, 19 | install_dir: gdu_libexecdir, 20 | ) 21 | 22 | 23 | configure_file( 24 | input: 'org.gnome.SettingsDaemon.DiskUtilityNotify.desktop.in', 25 | output: '@BASENAME@', 26 | configuration: {'libexecdir': gdu_prefix / gdu_libexecdir}, 27 | install: true, 28 | install_dir: gdu_sysconfdir / 'xdg/autostart', 29 | ) 30 | -------------------------------------------------------------------------------- /src/libgdu/libgduenumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #ifndef __LIB_GDU_ENUM_TYPES_H__ 3 | #define __LIB_GDU_ENUM_TYPES_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | /*** END file-header ***/ 9 | 10 | /*** BEGIN file-production ***/ 11 | 12 | /* enumerations from "@filename@" */ 13 | /*** END file-production ***/ 14 | 15 | /*** BEGIN value-header ***/ 16 | GType @enum_name@_get_type (void) G_GNUC_CONST; 17 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 18 | /*** END value-header ***/ 19 | 20 | /*** BEGIN file-tail ***/ 21 | G_END_DECLS 22 | 23 | #endif /* __LIB_GDU_ENUM_TYPES_H__ */ 24 | /*** END file-tail ***/ 25 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | ab 2 | ar 3 | as 4 | ast 5 | be 6 | bg 7 | bn 8 | bn_IN 9 | bs 10 | ca 11 | ca@valencia 12 | cs 13 | da 14 | de 15 | el 16 | en_GB 17 | en@shaw 18 | eo 19 | es 20 | et 21 | eu 22 | fa 23 | fi 24 | fr 25 | fur 26 | ga 27 | gd 28 | gl 29 | gu 30 | he 31 | hi 32 | hr 33 | hu 34 | hy 35 | id 36 | ie 37 | is 38 | it 39 | ja 40 | ka 41 | kab 42 | kk 43 | km 44 | kn 45 | ko 46 | ku 47 | lt 48 | lv 49 | mai 50 | mjw 51 | mk 52 | ml 53 | mr 54 | ms 55 | nb 56 | ne 57 | nl 58 | oc 59 | or 60 | pa 61 | pl 62 | pt 63 | pt_BR 64 | ro 65 | ru 66 | sk 67 | sl 68 | sr 69 | sr@latin 70 | sv 71 | ta 72 | te 73 | tg 74 | th 75 | tr 76 | ug 77 | uk 78 | uz 79 | vi 80 | zh_CN 81 | zh_HK 82 | zh_TW 83 | -------------------------------------------------------------------------------- /src/disks/gdu-benchmark-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_BENCHMARK_DIALOG (gdu_benchmark_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduBenchmarkDialog, gdu_benchmark_dialog, GDU, BENCHMARK_DIALOG, AdwDialog) 18 | 19 | void gdu_benchmark_dialog_show (GtkWindow *window, 20 | UDisksObject *object, 21 | UDisksClient *client); 22 | 23 | G_END_DECLS 24 | -------------------------------------------------------------------------------- /src/disks/gdu-edit-partition-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | G_BEGIN_DECLS 12 | 13 | #define GDU_TYPE_EDIT_PARTITION_DIALOG (gdu_edit_partition_dialog_get_type ()) 14 | G_DECLARE_FINAL_TYPE (GduEditPartitionDialog, gdu_edit_partition_dialog, GDU, EDIT_PARTITION_DIALOG, AdwDialog) 15 | 16 | void gdu_edit_partition_dialog_show (GtkWindow *parent_window, 17 | UDisksObject *object, 18 | UDisksClient *client); 19 | 20 | G_END_DECLS 21 | -------------------------------------------------------------------------------- /src/disks/gdu-resize-volume-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_RESIZE_VOLUME_DIALOG (gdu_resize_volume_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduResizeVolumeDialog, gdu_resize_volume_dialog, GDU, RESIZE_VOLUME_DIALOG, AdwDialog) 18 | 19 | void gdu_resize_dialog_show (GtkWindow *parent_window, 20 | UDisksObject *object, 21 | UDisksClient *client); 22 | 23 | G_END_DECLS 24 | -------------------------------------------------------------------------------- /src/disks/gdu-edit-filesystem-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | #include "gdu-block.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_EDIT_FILESYSTEM_DIALOG (gdu_edit_filesystem_dialog_get_type ()) 18 | 19 | G_DECLARE_FINAL_TYPE (GduEditFilesystemDialog, gdu_edit_filesystem_dialog, GDU, EDIT_FILESYSTEM_DIALOG, AdwDialog) 20 | 21 | void gdu_edit_filesystem_dialog_show (GtkWindow *parent_window, 22 | GduBlock *block); 23 | 24 | G_END_DECLS 25 | -------------------------------------------------------------------------------- /src/disks/gdu-drive-view.h: -------------------------------------------------------------------------------- 1 | /* gdu-drive-view.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "gdu-drive.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | #define GDU_TYPE_DRIVE_VIEW (gdu_drive_view_get_type ()) 20 | G_DECLARE_FINAL_TYPE (GduDriveView, gdu_drive_view, GDU, DRIVE_VIEW, AdwBin) 21 | 22 | void gdu_drive_view_set_drive (GduDriveView *self, 23 | GduDrive *drive); 24 | GduDrive *gdu_drive_view_get_drive (GduDriveView *self); 25 | 26 | G_END_DECLS 27 | -------------------------------------------------------------------------------- /src/disks/gdu-disk-settings-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_DISK_SETTINGS_DIALOG_H__ 10 | #define __GDU_DISK_SETTINGS_DIALOG_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | void gdu_disk_settings_dialog_show (GtkWindow *window, 18 | UDisksObject *object, 19 | UDisksClient *client); 20 | 21 | gboolean gdu_disk_settings_dialog_should_show (UDisksObject *object); 22 | 23 | G_END_DECLS 24 | 25 | #endif /* __GDU_DISK_SETTINGS_DIALOG_H__ */ 26 | -------------------------------------------------------------------------------- /data/org.gnome.DiskUtility.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Disks 3 | Comment=Manage Drives and Media 4 | # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! 5 | Keywords=disk;drive;volume;harddisk;hdd;disc;cdrom;dvd;partition;iso;image;backup;restore;benchmark;raid;luks;encryption;S.M.A.R.T.;smart; 6 | Exec=gnome-disks 7 | # Translators: Do NOT translate or transliterate this text (this is an icon file name)! 8 | Icon=org.gnome.DiskUtility 9 | Terminal=false 10 | Type=Application 11 | StartupNotify=true 12 | Categories=GNOME;GTK;Utility; 13 | DBusActivatable=true 14 | X-Purism-FormFactor=Workstation;Mobile; 15 | X-GNOME-UsesNotifications=true 16 | -------------------------------------------------------------------------------- /src/disks/gdu-create-confirm-page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_CREATE_CONFIRM_PAGE gdu_create_confirm_page_get_type () 17 | G_DECLARE_FINAL_TYPE (GduCreateConfirmPage, gdu_create_confirm_page, GDU, CREATE_CONFIRM_PAGE, AdwBin) 18 | 19 | GduCreateConfirmPage *gdu_create_confirm_page_new (UDisksClient *client, 20 | UDisksObject *object, 21 | UDisksBlock *block); 22 | 23 | G_END_DECLS 24 | -------------------------------------------------------------------------------- /src/disks/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gnome-disks" 3 | version = "0.1.0" 4 | edition.workspace = true 5 | license.workspace = true 6 | homepage.workspace = true 7 | repository.workspace = true 8 | rust-version.workspace = true 9 | 10 | [lib] 11 | path = "lib.rs" 12 | crate-type = ["rlib", "cdylib"] 13 | 14 | [dependencies] 15 | log.workspace = true 16 | env_logger.workspace = true 17 | udisks.workspace = true 18 | gtk.workspace = true 19 | gettext-rs.workspace = true 20 | adw.workspace = true 21 | libgdu = { path = "../libgdu", version = "0.1.0" } 22 | libc = "0.2" 23 | itertools = "0.14" 24 | liblzma = "0.4" 25 | async-std = "1.13.0" 26 | futures = "0.3.31" 27 | nix = { version = "0.30", default-features = false, features = ["ioctl"] } 28 | -------------------------------------------------------------------------------- /src/disk-image-mounter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gnome-disk-image-mounter" 3 | version = "0.1.0" 4 | edition.workspace = true 5 | license.workspace = true 6 | homepage.workspace = true 7 | repository.workspace = true 8 | rust-version.workspace = true 9 | 10 | [[bin]] 11 | name = 'gnome-disk-image-mounter' 12 | path = "main.rs" 13 | 14 | [dependencies] 15 | log.workspace = true 16 | env_logger.workspace = true 17 | udisks.workspace = true 18 | gtk.workspace = true 19 | gettext-rs.workspace = true 20 | adw.workspace = true 21 | async-recursion = "1.1.1" 22 | async-channel = "2.3.1" 23 | anyhow = "1.0.86" 24 | libgdu = { path = "../libgdu", version = "0.1.0" } 25 | # disk restore dialog 26 | gnome-disks = { path = "../disks", version = "0.1.0" } 27 | -------------------------------------------------------------------------------- /src/disks/gdu-change-passphrase-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_CHANGE_PASSPHRASE_DIALOG (gdu_change_passphrase_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduChangePassphraseDialog, gdu_change_passphrase_dialog, GDU, CHANGE_PASSPHRASE_DIALOG, AdwDialog) 18 | 19 | void gdu_change_passphrase_dialog_show (GtkWindow *window, 20 | UDisksObject *object, 21 | UDisksClient *client); 22 | 23 | G_END_DECLS 24 | -------------------------------------------------------------------------------- /src/disks/gdu-create-disk-image-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | #pragma once 9 | 10 | #include 11 | #include "gdutypes.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GDU_TYPE_CREATE_DISK_IMAGE_DIALOG (gdu_create_disk_image_dialog_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GduCreateDiskImageDialog, gdu_create_disk_image_dialog, GDU, CREATE_DISK_IMAGE_DIALOG, AdwDialog) 17 | 18 | void gdu_create_disk_image_dialog_show (GtkWindow *parent_window, 19 | UDisksObject *object, 20 | UDisksClient *client); 21 | 22 | G_END_DECLS 23 | -------------------------------------------------------------------------------- /src/disks/gdu-block-row.h: -------------------------------------------------------------------------------- 1 | /* gdu-drive-partition-row.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "gdu-block.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | #define GDU_TYPE_BLOCK_ROW (gdu_block_row_get_type ()) 20 | G_DECLARE_FINAL_TYPE (GduBlockRow, gdu_block_row, GDU, BLOCK_ROW, AdwExpanderRow) 21 | 22 | GduBlockRow *gdu_block_row_new (GduBlock *block); 23 | 24 | void 25 | on_recursive_switch_cb (GObject *source_object, 26 | GParamSpec *pspec, 27 | gpointer user_data); 28 | G_END_DECLS 29 | -------------------------------------------------------------------------------- /src/disks/gdu-encryption-options-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_ENCRYPTION_OPTIONS_DIALOG (gdu_encryption_options_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduEncryptionOptionsDialog, gdu_encryption_options_dialog, GDU, ENCRYPTION_OPTIONS_DIALOG, AdwDialog) 18 | 19 | void gdu_encryption_options_dialog_show (GtkWindow *parent_window, 20 | UDisksClient *client, 21 | UDisksObject *object); 22 | 23 | G_END_DECLS 24 | -------------------------------------------------------------------------------- /src/disks/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #include "config.h" 10 | #include 11 | 12 | #include 13 | 14 | #include "gdu-application.h" 15 | #include "gdu-log.h" 16 | 17 | int 18 | main (int argc, char *argv[]) 19 | { 20 | g_autoptr(GtkApplication) app = NULL; 21 | 22 | gdu_log_init (); 23 | 24 | /* Initialize gettext support */ 25 | bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); 26 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 27 | textdomain (GETTEXT_PACKAGE); 28 | 29 | app = gdu_application_new (); 30 | 31 | return g_application_run (G_APPLICATION (app), argc, argv); 32 | } 33 | -------------------------------------------------------------------------------- /src/disks/gdu-mount-options-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_FSTAB_DIALOG_H_H__ 10 | #define __GDU_FSTAB_DIALOG_H_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_MOUNT_OPTIONS_DIALOG (gdu_mount_options_dialog_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GduMountOptionsDialog, gdu_mount_options_dialog, GDU, MOUNT_OPTIONS_DIALOG, AdwDialog) 19 | 20 | void gdu_mount_options_dialog_show (GtkWindow *parent_window, 21 | UDisksObject *object, 22 | UDisksClient *client); 23 | 24 | G_END_DECLS 25 | 26 | #endif /* __GDU_FSTAB_DIALOG_H__ */ 27 | -------------------------------------------------------------------------------- /src/libgdu/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libgdu" 3 | version = "0.1.0" 4 | edition.workspace = true 5 | license.workspace = true 6 | homepage.workspace = true 7 | repository.workspace = true 8 | rust-version.workspace = true 9 | 10 | [lib] 11 | path = "lib.rs" 12 | 13 | [features] 14 | # enabled via meson with `HAVE_LOGIND` 15 | logind = ["dep:systemd"] 16 | 17 | [dependencies] 18 | log.workspace = true 19 | env_logger.workspace = true 20 | udisks.workspace = true 21 | gtk.workspace = true 22 | gettext-rs.workspace = true 23 | adw.workspace = true 24 | #TODO: currently only used for async Mutex, maybe replace? 25 | tokio = { version = "1.39.2", features = ["full"] } 26 | systemd = { version = "0.10.0", optional = true } 27 | async-recursion = "1.1.1" 28 | libc = "0.2.155" 29 | itertools = "0.13.0" 30 | futures = "0.3.31" 31 | -------------------------------------------------------------------------------- /src/disks/gdu-space-allocation-bar.h: -------------------------------------------------------------------------------- 1 | /* gdu-space-allocation-bar.c 2 | * 3 | * Copyright (C) 2008-2013 Red Hat, Inc. 4 | * Copyright 2024 Inam Ul Haq 5 | * 6 | * Licensed under GPL version 2 or later. 7 | * 8 | * Author(s): 9 | * Inam Ul Haq 10 | * 11 | * SPDX-License-Identifier: GPL-2.0-or-later 12 | */ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | G_BEGIN_DECLS 20 | 21 | #define GDU_TYPE_SPACE_ALLOCATION_BAR (gdu_space_allocation_bar_get_type ()) 22 | G_DECLARE_FINAL_TYPE (GduSpaceAllocationBar, gdu_space_allocation_bar, GDU, SPACE_ALLOCATION_BAR, GtkWidget) 23 | 24 | void 25 | gdu_space_allocation_bar_set_drive (GduSpaceAllocationBar *self, 26 | GduDrive *drive); 27 | 28 | G_END_DECLS 29 | -------------------------------------------------------------------------------- /src/disk-image-mounter/main.rs: -------------------------------------------------------------------------------- 1 | use application::ImageMounterApplication; 2 | use config::{GETTEXT_PACKAGE, LOCALEDIR}; 3 | use gettextrs::{gettext, LocaleCategory}; 4 | use gtk::glib; 5 | 6 | pub mod application; 7 | mod config; 8 | pub mod window; 9 | 10 | fn main() -> glib::ExitCode { 11 | env_logger::Builder::from_default_env() 12 | .format_timestamp_millis() 13 | .init(); 14 | 15 | // Prepare i18n 16 | gettextrs::setlocale(LocaleCategory::LcAll, ""); 17 | gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); 18 | gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain"); 19 | 20 | glib::set_application_name(&gettext("GNOME Disk Image Mounter")); 21 | 22 | let app = ImageMounterApplication::default(); 23 | app.run() 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gnome-disk-utility 2 | 3 | This gnome-disk-utility repository provides libraries and applications for 4 | dealing with storage devices. 5 | 6 | Development location: https://gitlab.gnome.org/GNOME/gnome-disk-utility 7 | 8 | ## GNOME Disks 9 | 10 | View, modify and configure disks and media 11 | 12 | Homepage: https://apps.gnome.org/DiskUtility/ 13 | 14 | ## gnome-disk-image-mounter 15 | 16 | Attach and mount disk images 17 | 18 | ## gsd-disk-utility-notify 19 | 20 | gnome-disk-utility notification plugin for GNOME Settings Daemon 21 | Disk health failure notification (SMART status) 22 | 23 | ## Development 24 | 25 | For building and running the local build, read the `INSTALL` file, in 26 | particular the Flatpak instructions which help you to run a 27 | development version of UDisks as well. 28 | 29 | The release is done with the `./release` script. 30 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["src/disk-image-mounter", "src/libgdu", "src/disks"] 4 | 5 | [workspace.package] 6 | edition = "2024" 7 | rust-version = "1.85" 8 | license = "GPL-2.0-or-later" 9 | homepage = "https://apps.gnome.org/DiskUtility/" 10 | repository = "https://gitlab.gnome.org/GNOME/gnome-disk-utility/" 11 | 12 | [profile.release] 13 | lto = true 14 | codegen-units = 1 15 | 16 | [workspace.dependencies] 17 | log = "0.4" 18 | env_logger = "0.11.2" 19 | gettext-rs = { version = "0.7", features = ["gettext-system"] } 20 | gtk = { version = "0.8", package = "gtk4", features = [ 21 | "v4_12", 22 | "xml_validation", 23 | ] } 24 | adw = { package = "libadwaita", version = "0.6", features = ["v1_5"] } 25 | udisks = { package = "udisks2", git = "https://github.com/FineFindus/udisks-rs.git", rev = "001e0c02830a4a229adb99207250b275c79261a2" } 26 | -------------------------------------------------------------------------------- /src/disks/gdu-ata-smart-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_ATA_SMART_DIALOG_H_H__ 10 | #define __GDU_ATA_SMART_DIALOG_H_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | void gdu_ata_smart_dialog_show (GtkWindow *parent_window, 18 | UDisksObject *object, 19 | UDisksClient *client); 20 | 21 | gchar *gdu_ata_smart_get_one_liner_assessment (UDisksDriveAta *ata, 22 | gboolean *out_smart_is_supported, 23 | gboolean *out_warn); 24 | 25 | G_END_DECLS 26 | 27 | #endif /* __GDU_ATA_SMART_DIALOG_H__ */ 28 | -------------------------------------------------------------------------------- /src/notify/gdusdmonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_SD_MONITOR_H__ 10 | #define __GDU_SD_MONITOR_H__ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | G_BEGIN_DECLS 17 | 18 | #define GDU_TYPE_SD_MONITOR (gdu_sd_monitor_get_type ()) 19 | #define GDU_SD_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_SD_MONITOR, GduSdMonitor)) 20 | #define GDU_IS_SD_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_SD_MONITOR)) 21 | 22 | struct GduSdMonitor; 23 | typedef struct GduSdMonitor GduSdMonitor; 24 | 25 | GType gdu_sd_monitor_get_type (void) G_GNUC_CONST; 26 | GduSdMonitor *gdu_sd_monitor_new (void); 27 | 28 | G_END_DECLS 29 | 30 | #endif /* __GDU_SD_MONITOR_H__ */ 31 | -------------------------------------------------------------------------------- /src/disks/gdu-format-volume-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_FORMAT_VOLUME_DIALOG (gdu_format_volume_dialog_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduFormatVolumeDialog, gdu_format_volume_dialog, GDU, FORMAT_VOLUME_DIALOG, AdwDialog) 18 | 19 | void gdu_create_format_show (UDisksClient *client, 20 | GtkWindow *parent_window, 21 | UDisksObject *object, 22 | gboolean add_partition, 23 | guint64 add_partition_offset, 24 | guint64 add_partition_maxsize); 25 | 26 | G_END_DECLS 27 | -------------------------------------------------------------------------------- /src/disks/gdu-window.h: -------------------------------------------------------------------------------- 1 | /* gdu-window.c 2 | * 3 | * Copyright (C) 2008-2013 Red Hat, Inc. 4 | * Copyright 2023 Mohammed Sadiq 5 | * 6 | * Licensed under GPL version 2 or later. 7 | * 8 | * Author(s): 9 | * David Zeuthen 10 | * Mohammed Sadiq 11 | * 12 | * SPDX-License-Identifier: GPL-2.0-or-later 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include "gdu-manager.h" 20 | 21 | G_BEGIN_DECLS 22 | 23 | #define GDU_TYPE_WINDOW (gdu_window_get_type ()) 24 | G_DECLARE_FINAL_TYPE (GduWindow, gdu_window, GDU, WINDOW, AdwApplicationWindow) 25 | 26 | GduWindow *gdu_window_new (GApplication *application, 27 | GduManager *manager); 28 | void gdu_window_show_attach_disk_image (GduWindow *self); 29 | 30 | G_END_DECLS 31 | -------------------------------------------------------------------------------- /src/disks/gdudvdsupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_DVD_SUPPORT_H__ 10 | #define __GDU_DVD_SUPPORT_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | GduDVDSupport *gdu_dvd_support_new (const gchar *device_file, 18 | guint64 device_size); 19 | 20 | void gdu_dvd_support_free (GduDVDSupport *support); 21 | 22 | gssize gdu_dvd_support_read (GduDVDSupport *support, 23 | int fd, 24 | guchar *buffer, 25 | guint64 offset, 26 | guint64 size); 27 | 28 | G_END_DECLS 29 | 30 | #endif /* __GDU_DVD_SUPPORT_H__ */ 31 | -------------------------------------------------------------------------------- /src/disks/gdutypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_TYPES_H__ 10 | #define __GDU_TYPES_H__ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "gduenums.h" 18 | 19 | G_BEGIN_DECLS 20 | 21 | struct _GduCreateFilesystemWidget; 22 | typedef struct _GduCreateFilesystemWidget GduCreateFilesystemWidget; 23 | 24 | struct _GduEstimator; 25 | typedef struct _GduEstimator GduEstimator; 26 | 27 | struct GduDVDSupport; 28 | typedef struct GduDVDSupport GduDVDSupport; 29 | 30 | struct GduLocalJob; 31 | typedef struct GduLocalJob GduLocalJob; 32 | 33 | struct GduXzDecompressor; 34 | typedef struct GduXzDecompressor GduXzDecompressor; 35 | 36 | G_END_DECLS 37 | 38 | #endif /* __GDU_TYPES_H__ */ 39 | -------------------------------------------------------------------------------- /src/notify/gdusdmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_SD_PLUGIN_H__ 10 | #define __GDU_SD_PLUGIN_H__ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | G_BEGIN_DECLS 17 | 18 | #define GDU_TYPE_SD_MANAGER (gdu_sd_manager_get_type ()) 19 | #define GDU_SD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_SD_MANAGER, GduSdManager)) 20 | #define GDU_IS_SD_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_SD_MANAGER)) 21 | 22 | struct GduSdManager; 23 | typedef struct GduSdManager GduSdManager; 24 | 25 | GType gdu_sd_manager_get_type (void) G_GNUC_CONST; 26 | 27 | /* All the plugins must implement this function */ 28 | G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module); 29 | 30 | G_END_DECLS 31 | 32 | #endif /* __GDU_SD_PLUGIN_H__ */ 33 | -------------------------------------------------------------------------------- /src/disks/gdu-format-disk-dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_FORMAT_DISK_DIALOG (gdu_format_disk_dialog_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GduFormatDiskDialog, gdu_format_disk_dialog, GDU, FORMAT_DISK_DIALOG, AdwDialog) 19 | 20 | GType gdu_partitioning_type_get_type (void) G_GNUC_CONST; 21 | #define GDU_TYPE_PARTITIONING_TYPE (gdu_partitioning_type_get_type ()) 22 | 23 | typedef enum 24 | { 25 | GDU_PARTITIONING_TYPE_GPT, 26 | GDU_PARTITIONING_TYPE_DOS, 27 | GDU_PARTITIONING_TYPE_EMPTY, 28 | } GduPartitioningType; 29 | 30 | void gdu_format_disk_dialog_show (GtkWindow *parent, 31 | UDisksObject *object, 32 | UDisksClient *client); 33 | 34 | G_END_DECLS 35 | -------------------------------------------------------------------------------- /src/disks/gdu-drive-header.h: -------------------------------------------------------------------------------- 1 | /* gdu-drive-header.h 2 | * 3 | * Copyright 2024 Christopher Davis 4 | * 5 | * Author(s) 6 | * Christopher Davis 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_DRIVE_HEADER (gdu_drive_header_get_type()) 18 | 19 | G_DECLARE_FINAL_TYPE (GduDriveHeader, gdu_drive_header, GDU, DRIVE_HEADER, AdwBin) 20 | 21 | void gdu_drive_header_set_layout_name (GduDriveHeader *self, 22 | const char *name); 23 | 24 | void gdu_drive_header_set_icon (GduDriveHeader *self, 25 | GIcon *icon); 26 | 27 | void gdu_drive_header_set_drive_name (GduDriveHeader *self, 28 | const char *name); 29 | 30 | void gdu_drive_header_set_drive_path (GduDriveHeader *self, 31 | const char *path); 32 | 33 | G_END_DECLS 34 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-create-other-page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | 26 | -------------------------------------------------------------------------------- /src/disks/gduenums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_ENUMS_H__ 10 | #define __GDU_ENUMS_H__ 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | typedef enum 17 | { 18 | GDU_POWER_STATE_FLAGS_NONE = 0, 19 | GDU_POWER_STATE_FLAGS_STANDBY = (1<<0), 20 | GDU_POWER_STATE_FLAGS_CHECKING = (1<<1), 21 | GDU_POWER_STATE_FLAGS_FAILED = (1<<2) 22 | } GduPowerStateFlags; 23 | 24 | typedef enum 25 | { 26 | GDU_DEVICE_TREE_MODEL_FLAGS_NONE = 0, 27 | GDU_DEVICE_TREE_MODEL_FLAGS_FLAT = (1<<0), 28 | GDU_DEVICE_TREE_MODEL_FLAGS_UPDATE_POWER_STATE = (1<<1), 29 | GDU_DEVICE_TREE_MODEL_FLAGS_UPDATE_PULSE = (1<<2), 30 | GDU_DEVICE_TREE_MODEL_FLAGS_ONE_LINE_NAME = (1<<3), 31 | GDU_DEVICE_TREE_MODEL_FLAGS_INCLUDE_DEVICE_NAME = (1<<4), 32 | GDU_DEVICE_TREE_MODEL_FLAGS_INCLUDE_NONE_ITEM = (1<<5), 33 | } GduDeviceTreeModelFlags; 34 | 35 | G_END_DECLS 36 | 37 | #endif /* __GDU_ENUMS_H__ */ 38 | -------------------------------------------------------------------------------- /src/disks/gduenumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #include "gduenums.h" 3 | #include "gduenumtypes.h" 4 | 5 | /*** END file-header ***/ 6 | 7 | /*** BEGIN file-production ***/ 8 | /* enumerations from "@filename@" */ 9 | /*** END file-production ***/ 10 | 11 | /*** BEGIN value-header ***/ 12 | GType 13 | @enum_name@_get_type (void) 14 | { 15 | static gsize g_define_type_id__volatile = 0; 16 | 17 | if (g_once_init_enter (&g_define_type_id__volatile)) 18 | { 19 | static const G@Type@Value values[] = { 20 | /*** END value-header ***/ 21 | 22 | /*** BEGIN value-production ***/ 23 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 24 | /*** END value-production ***/ 25 | 26 | /*** BEGIN value-tail ***/ 27 | { 0, NULL, NULL } 28 | }; 29 | GType g_define_type_id = 30 | g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); 31 | g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); 32 | } 33 | 34 | return g_define_type_id__volatile; 35 | } 36 | 37 | /*** END value-tail ***/ 38 | 39 | /*** BEGIN file-tail ***/ 40 | /*** END file-tail ***/ 41 | -------------------------------------------------------------------------------- /src/disks/gduestimator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_ESTIMATOR_H__ 10 | #define __GDU_ESTIMATOR_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_ESTIMATOR (gdu_estimator_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GduEstimator, gdu_estimator, GDU, ESTIMATOR, GObject) 19 | 20 | GduEstimator *gdu_estimator_new (guint64 target_bytes); 21 | void gdu_estimator_add_sample (GduEstimator *estimator, 22 | guint64 completed_bytes); 23 | guint64 gdu_estimator_get_target_bytes (GduEstimator *estimator); 24 | guint64 gdu_estimator_get_completed_bytes (GduEstimator *estimator); 25 | 26 | guint64 gdu_estimator_get_bytes_per_sec (GduEstimator *estimator); 27 | guint64 gdu_estimator_get_usec_remaining (GduEstimator *estimator); 28 | 29 | G_END_DECLS 30 | 31 | #endif /* __GDU_ESTIMATOR_H__ */ 32 | -------------------------------------------------------------------------------- /src/libgdu/libgduenumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #include "libgduenums.h" 3 | #include "libgduenumtypes.h" 4 | 5 | /*** END file-header ***/ 6 | 7 | /*** BEGIN file-production ***/ 8 | /* enumerations from "@filename@" */ 9 | /*** END file-production ***/ 10 | 11 | /*** BEGIN value-header ***/ 12 | GType 13 | @enum_name@_get_type (void) 14 | { 15 | static gsize g_define_type_id__volatile = 0; 16 | 17 | if (g_once_init_enter (&g_define_type_id__volatile)) 18 | { 19 | static const G@Type@Value values[] = { 20 | /*** END value-header ***/ 21 | 22 | /*** BEGIN value-production ***/ 23 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 24 | /*** END value-production ***/ 25 | 26 | /*** BEGIN value-tail ***/ 27 | { 0, NULL, NULL } 28 | }; 29 | GType g_define_type_id = 30 | g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); 31 | g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); 32 | } 33 | 34 | return g_define_type_id__volatile; 35 | } 36 | 37 | /*** END value-tail ***/ 38 | 39 | /*** BEGIN file-tail ***/ 40 | /*** END file-tail ***/ 41 | -------------------------------------------------------------------------------- /src/disks/gdu-create-partition-page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_CREATE_PARTITION_PAGE gdu_create_partition_page_get_type () 17 | G_DECLARE_FINAL_TYPE (GduCreatePartitionPage, gdu_create_partition_page, GDU, CREATE_PARTITION_PAGE, AdwBin) 18 | 19 | GduCreatePartitionPage *gdu_create_partition_page_new (UDisksClient *client, 20 | UDisksPartitionTable *table, 21 | guint64 max_size, 22 | guint64 offset); 23 | 24 | gboolean gdu_create_partition_page_is_extended (GduCreatePartitionPage *page); 25 | 26 | guint64 gdu_create_partition_page_get_size (GduCreatePartitionPage *page); 27 | 28 | guint64 gdu_create_partition_page_get_offset (GduCreatePartitionPage *page); 29 | 30 | G_END_DECLS 31 | -------------------------------------------------------------------------------- /src/disks/ui/style.css: -------------------------------------------------------------------------------- 1 | .explanation-label { 2 | font-size: small; 3 | } 4 | 5 | levelbar .strength-weak { 6 | background-color: #cc0000; 7 | border-color: #cc0000; 8 | } 9 | 10 | levelbar .strength-low { 11 | background-color: #f5ce00; 12 | border-color: #f5ce00; 13 | } 14 | 15 | levelbar .strength-medium, 16 | levelbar .strength-good, 17 | levelbar .strength-high { 18 | background-color: #73d216; 19 | border-color: #73d216; 20 | } 21 | 22 | .space-allocation-bar { 23 | border-radius: 6px; 24 | } 25 | 26 | .partition-row { 27 | background: var(--main-color); 28 | border-radius: 100%; 29 | } 30 | 31 | .partition-bin { 32 | background: linear-gradient(to top, var(--main-color), oklch(from var(--main-color) calc(l + 0.1) c h)); 33 | } 34 | 35 | .grey { 36 | --main-color: #afafaf; 37 | } 38 | 39 | .blue { 40 | --main-color: var(--blue-4); 41 | } 42 | 43 | .green { 44 | --main-color: var(--green-4); 45 | } 46 | 47 | .yellow { 48 | --main-color: var(--yellow-4); 49 | } 50 | 51 | .orange { 52 | --main-color: var(--orange-4); 53 | } 54 | 55 | .red { 56 | --main-color: var(--red-4); 57 | } 58 | 59 | .purple { 60 | --main-color: var(--purple-4); 61 | } 62 | 63 | .brown { 64 | --main-color: var(--brown-4); 65 | } 66 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 'https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml' 2 | 3 | stages: 4 | - build 5 | - test 6 | 7 | variables: 8 | DEPENDENCIES: glib-devel libdvdread-devel gtk4-devel libadwaita-devel 9 | libnotify-devel libsecret-devel libpwquality-devel 10 | libudisks2-devel xz-devel systemd-devel meson gcc 11 | glibc-devel libhandy1-devel gettext git gobject-introspection-devel 12 | vala desktop-file-utils gtk4-devel libadwaita-devel rust cargo 13 | OPTIONS: -Dman=false 14 | 15 | flatpak: 16 | image: quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master 17 | variables: 18 | BUNDLE: "org.gnome.DiskUtility.flatpak" 19 | MANIFEST_PATH: "flatpak/org.gnome.DiskUtility.json" 20 | FLATPAK_MODULE: "gnome-disk-utility" 21 | APP_ID: "org.gnome.DiskUtility" 22 | RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo" 23 | extends: .flatpak 24 | 25 | 26 | build: 27 | image: fedora:rawhide 28 | stage: build 29 | before_script: 30 | - dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES 31 | script: 32 | - meson . _build $OPTIONS 33 | - ninja -C _build 34 | - ninja -C _build install 35 | -------------------------------------------------------------------------------- /src/disks/gdu-create-other-page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #ifndef __GDU_CREATE_OTHER_PAGE_H__ 10 | #define __GDU_CREATE_OTHER_PAGE_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_CREATE_OTHER_PAGE gdu_create_other_page_get_type () 18 | G_DECLARE_FINAL_TYPE (GduCreateOtherPage, gdu_create_other_page, GDU, CREATE_OTHER_PAGE, AdwBin) 19 | 20 | GType gdu_other_fs_type_get_type (void) G_GNUC_CONST; 21 | #define GDU_TYPE_OTHER_FS_TYPE (gdu_other_fs_type_get_type ()) 22 | 23 | typedef enum 24 | { 25 | GDU_OTHER_FS_TYPE_XFS, 26 | GDU_OTHER_FS_TYPE_SWAP, 27 | GDU_OTHER_FS_TYPE_BTRFS, 28 | GDU_OTHER_FS_TYPE_F2FS, 29 | GDU_OTHER_FS_TYPE_EXFAT, 30 | GDU_OTHER_FS_TYPE_UDF, 31 | GDU_OTHER_FS_TYPE_EMPTY, 32 | N_OTHER_FS 33 | } GduOtherFsType; 34 | 35 | GduCreateOtherPage *gdu_create_other_page_new (UDisksClient *client); 36 | 37 | gboolean gdu_create_other_page_is_encrypted (GduCreateOtherPage *page); 38 | 39 | const gchar * gdu_create_other_page_get_fs (GduCreateOtherPage *page); 40 | 41 | G_END_DECLS 42 | 43 | #endif /* __GDU_CREATE_OTHER_PAGE_H__ */ 44 | -------------------------------------------------------------------------------- /src/libgdu/enums.rs: -------------------------------------------------------------------------------- 1 | use gtk::glib; 2 | 3 | #[glib::flags(name = "MyFlags")] 4 | pub enum GduFormatDurationFlags { 5 | None = 0, 6 | SubSecondPrecision = (1 << 0), 7 | NoSeconds = (1 << 1), 8 | } 9 | 10 | // from libblockdev 11 | #[glib::flags(name = "MyFlags")] 12 | pub enum ResizeFlags { 13 | OfflineShrink = 1 << 1, 14 | OfflineGrow = 1 << 2, 15 | OnlineShrink = 1 << 3, 16 | OnlineGrow = 1 << 4, 17 | } 18 | 19 | #[derive(Debug, Clone, Copy)] 20 | #[repr(u32)] 21 | pub enum UnitSize { 22 | Byte, 23 | KByte, 24 | MByte, 25 | GByte, 26 | TByte, 27 | PByte, 28 | KiByte, 29 | MiByte, 30 | GiByte, 31 | TiByte, 32 | PiByte, 33 | } 34 | 35 | impl UnitSize { 36 | // Keep in sync with Glade file 37 | pub fn size_in_bytes(self) -> u64 { 38 | match self { 39 | UnitSize::Byte => 1, 40 | UnitSize::KByte => 1_000, 41 | UnitSize::MByte => 1_000_000, 42 | UnitSize::GByte => 1_000_000_000, 43 | UnitSize::TByte => 1_000_000_000_000, 44 | UnitSize::PByte => 1_000_000_000_000_000, 45 | UnitSize::KiByte => 1 << 10, 46 | UnitSize::MiByte => 1 << 20, 47 | UnitSize::GiByte => 1 << 30, 48 | UnitSize::TiByte => 1 << 40, 49 | UnitSize::PiByte => 1 << 50, 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /data/org.gnome.Disks.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | '' 6 | Default location for the Create/Restore disk image dialogs 7 | Default location for the Create/Restore disk image dialogs. If blank the ~/Documents folder is used. 8 | 9 | 10 | 11 | 12 | 100 13 | The number of samples the benchmark will include for the read/write test. 14 | 15 | 16 | 10 17 | The number of MiB (1048576 bytes) to read/write for each sample. 18 | 19 | 20 | true 21 | To enable or disable the write test. 22 | 23 | 24 | 1000 25 | The number of samples the benchmark will do for the access time test. 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/disks/gdulocaljob.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_LOCAL_JOB_H__ 10 | #define __GDU_LOCAL_JOB_H__ 11 | 12 | #include 13 | #include "gdutypes.h" 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_LOCAL_JOB (gdu_local_job_get_type()) 18 | #define GDU_LOCAL_JOB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_LOCAL_JOB, GduLocalJob)) 19 | #define GDU_IS_LOCAL_JOB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_LOCAL_JOB)) 20 | 21 | GType gdu_local_job_get_type (void) G_GNUC_CONST; 22 | GduLocalJob *gdu_local_job_new (UDisksObject *object); 23 | UDisksObject *gdu_local_job_get_object (GduLocalJob *job); 24 | void gdu_local_job_set_description (GduLocalJob *job, 25 | const gchar *description); 26 | const gchar *gdu_local_job_get_description (GduLocalJob *job); 27 | void gdu_local_job_set_extra_markup (GduLocalJob *job, 28 | const gchar *markup); 29 | const gchar *gdu_local_job_get_extra_markup (GduLocalJob *job); 30 | void gdu_local_job_canceled (GduLocalJob *job); 31 | 32 | G_END_DECLS 33 | 34 | #endif /* __GDU_LOCAL_JOB_H__ */ 35 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | install_subdir( 2 | 'icons/hicolor', 3 | install_dir: gdu_datadir / 'icons', 4 | ) 5 | 6 | desktops = [ 7 | 'org.gnome.DiskUtility.desktop', 8 | 'gnome-disk-image-mounter.desktop', 9 | ] 10 | 11 | foreach desktop: desktops 12 | i18n.merge_file ( 13 | type: 'desktop', 14 | input: desktop + '.in', 15 | output: desktop, 16 | po_dir: po_dir, 17 | install: true, 18 | install_dir: gdu_datadir / 'applications', 19 | ) 20 | endforeach 21 | 22 | 23 | configure_file( 24 | input: 'org.gnome.DiskUtility.service.in', 25 | output: '@BASENAME@', 26 | configuration: {'bindir': gdu_prefix / gdu_bindir}, 27 | install: true, 28 | install_dir: gdu_datadir / 'dbus-1/services', 29 | ) 30 | 31 | install_data( 32 | 'org.gnome.Disks.gschema.xml', 33 | install_dir: join_paths(gdu_datadir, 'glib-2.0', 'schemas') 34 | ) 35 | 36 | info = 'org.gnome.DiskUtility.metainfo.xml' 37 | 38 | metainfo_file = i18n.merge_file( 39 | input: info + '.in', 40 | output: info, 41 | po_dir: po_dir, 42 | install: true, 43 | install_dir: gdu_datadir / 'metainfo', 44 | ) 45 | 46 | # Validate AppStream metadata 47 | appstreamcli = find_program('appstreamcli', required: false) 48 | if (appstreamcli.found()) 49 | test('validate-metainfo', 50 | appstreamcli, 51 | args: ['validate', '--no-net', '--explain', metainfo_file], 52 | workdir: meson.current_build_dir() 53 | ) 54 | endif 55 | -------------------------------------------------------------------------------- /src/disks/gdu-manager.h: -------------------------------------------------------------------------------- 1 | /* gdu-manager.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GDU_TYPE_MANAGER (gdu_manager_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GduManager, gdu_manager, GDU, MANAGER, GObject) 19 | 20 | GduManager *gdu_manager_get_default (GError **error); 21 | GListModel *gdu_manager_get_drives (GduManager *self); 22 | void gdu_manager_open_loop_async (GduManager *self, 23 | GFile *file, 24 | gboolean read_only, 25 | GAsyncReadyCallback callback, 26 | gpointer user_data); 27 | gboolean gdu_manager_open_loop_finish (GduManager *self, 28 | GAsyncResult *result, 29 | GError **error); 30 | 31 | 32 | 33 | /* xxx: to be removed once dust settles */ 34 | 35 | #include 36 | 37 | UDisksClient *gdu_manager_get_client (GduManager *self); 38 | 39 | G_END_DECLS 40 | -------------------------------------------------------------------------------- /src/disks/gdu-create-filesystem-page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GDU_TYPE_CREATE_FILESYSTEM_PAGE (gdu_create_filesystem_page_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GduCreateFilesystemPage, gdu_create_filesystem_page, GDU, CREATE_FILESYSTEM_PAGE, AdwBin) 18 | 19 | GType gdu_fs_type_get_type (void) G_GNUC_CONST; 20 | #define GDU_TYPE_FS_TYPE (gdu_fs_type_get_type ()) 21 | 22 | typedef enum 23 | { 24 | GDU_FS_TYPE_EXT4, 25 | GDU_FS_TYPE_NTFS, 26 | GDU_FS_TYPE_FAT, 27 | GDU_FS_TYPE_OTHER 28 | } GduFsType; 29 | 30 | GduCreateFilesystemPage *gdu_create_filesystem_page_new (UDisksClient *client, 31 | UDisksDrive *drive); 32 | 33 | const gchar * gdu_create_filesystem_page_get_name (GduCreateFilesystemPage *page); 34 | 35 | const gchar * gdu_create_filesystem_page_get_fs (GduCreateFilesystemPage *page); 36 | 37 | gboolean gdu_create_filesystem_page_is_other (GduCreateFilesystemPage *page); 38 | 39 | gboolean gdu_create_filesystem_page_is_encrypted (GduCreateFilesystemPage *page); 40 | 41 | const gchar * gdu_create_filesystem_page_get_erase (GduCreateFilesystemPage *page); 42 | 43 | G_END_DECLS 44 | 45 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-format-volume-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | 37 | -------------------------------------------------------------------------------- /src/disks/gdu-application.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #ifndef __GDU_APPLICATION_H__ 10 | #define __GDU_APPLICATION_H__ 11 | 12 | #include 13 | #include 14 | #include "gdutypes.h" 15 | 16 | G_BEGIN_DECLS 17 | 18 | #define GDU_TYPE_APPLICATION (gdu_application_get_type ()) 19 | 20 | G_DECLARE_FINAL_TYPE (GduApplication, gdu_application, GDU, APPLICATION, AdwApplication) 21 | 22 | GtkApplication *gdu_application_new (void); 23 | UDisksClient *gdu_application_get_client (GduApplication *application); 24 | GObject *gdu_application_new_widget (GduApplication *application, 25 | const gchar *ui_file, 26 | const gchar *name, 27 | GtkBuilder **out_builder); 28 | gboolean gdu_application_should_exit (GduApplication *application); 29 | GduLocalJob *gdu_application_create_local_job (GduApplication *application, 30 | UDisksObject *object); 31 | void gdu_application_destroy_local_job (GduApplication *application, 32 | GduLocalJob *job); 33 | 34 | 35 | G_END_DECLS 36 | 37 | #endif /* __GDU_APPLICATION_H__ */ 38 | -------------------------------------------------------------------------------- /src/disks/gduxzdecompressor.h: -------------------------------------------------------------------------------- 1 | /* XZ Decompressor - based on GLib's GZLibDecompressor 2 | * 3 | * Copyright (C) 2013 David Zeuthen 4 | * Copyright (C) 2009 Red Hat, Inc. 5 | * 6 | * Licensed under GPL version 2 or later. 7 | * 8 | * Author: David Zeuthen 9 | * Alexander Larsson 10 | */ 11 | 12 | #ifndef __GDU_XZ_DECOMPRESSOR_H__ 13 | #define __GDU_XZ_DECOMPRESSOR_H__ 14 | 15 | #include "gdutypes.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | #define GDU_TYPE_XZ_DECOMPRESSOR (gdu_xz_decompressor_get_type ()) 20 | #define GDU_XZ_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_XZ_DECOMPRESSOR, GduXzDecompressor)) 21 | #define GDU_XZ_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDU_TYPE_XZ_DECOMPRESSOR, GduXzDecompressorClass)) 22 | #define GDU_IS_XZ_DECOMPRESSOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_XZ_DECOMPRESSOR)) 23 | #define GDU_IS_XZ_DECOMPRESSOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_XZ_DECOMPRESSOR)) 24 | #define GDU_XZ_DECOMPRESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDU_TYPE_XZ_DECOMPRESSOR, GduXzDecompressorClass)) 25 | 26 | typedef struct GduXzDecompressorClass GduXzDecompressorClass; 27 | 28 | struct GduXzDecompressorClass 29 | { 30 | GObjectClass parent_class; 31 | }; 32 | 33 | GType gdu_xz_decompressor_get_type (void) G_GNUC_CONST; 34 | GduXzDecompressor *gdu_xz_decompressor_new (void); 35 | 36 | gsize gdu_xz_decompressor_get_uncompressed_size (GFile *compressed_file); 37 | 38 | G_END_DECLS 39 | 40 | #endif /* __GDU_XZ_DECOMPRESSOR_H__ */ 41 | -------------------------------------------------------------------------------- /src/libgdu/gettext.rs: -------------------------------------------------------------------------------- 1 | // Utility from https://github.com/FineFindus/udisks-rs/blob/feat/gettext/src/gettext.rs 2 | 3 | /// Similar to [`gettextrs::pgettext`], but with support for formatted strings. 4 | /// 5 | /// Unlike the provided macro, this function is compatible with gettext string extraction tools. 6 | /// 7 | /// # Example 8 | /// 9 | /// ```rust, compile_fail 10 | /// let formatted_string = pgettext_f("hello-world", "Hello, {}!", ["world"]); 11 | /// assert_eq!(formatted_string, "Hello, world!"); 12 | /// ``` 13 | pub fn pgettext_f( 14 | msgctxt: &str, 15 | format: &str, 16 | args: impl IntoIterator>, 17 | ) -> String { 18 | // map Rust style string formatting to C style formatting 19 | let s = gettextrs::pgettext(msgctxt, format.replace("{}", "%s")); 20 | arg_replace(s, args) 21 | } 22 | 23 | /// Similar to [`gettextrs::gettext`], but with support for formatted strings. 24 | /// 25 | /// Unlike the provided macro, this function is compatible with gettext string extraction tools. 26 | /// 27 | /// # Example 28 | /// 29 | /// ```rust, compile_fail 30 | /// let formatted_string = gettext_f("Hello, {}!", ["world"]); 31 | /// assert_eq!(formatted_string, "Hello, world!"); 32 | /// ``` 33 | pub fn gettext_f(format: &str, args: impl IntoIterator>) -> String { 34 | // map Rust style string formatting to C style formatting 35 | let s = gettextrs::gettext(format.replace("{}", "%s")); 36 | arg_replace(s, args) 37 | } 38 | 39 | fn arg_replace(mut s: String, args: impl IntoIterator>) -> String { 40 | for arg in args { 41 | s = s.replacen("%s", arg.as_ref(), 1); 42 | } 43 | s 44 | } 45 | -------------------------------------------------------------------------------- /gnome-disk-utility.doap: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Disks 9 | Disk Management Utility for GNOME 10 | Disk Management Utility for GNOME 11 | 12 | 13 | 14 | C 15 | 16 | 18 | 20 | 22 | 24 | 25 | 26 | 27 | Kai Lüke 28 | 29 | kailueke 30 | 31 | 32 | 33 | 34 | 35 | Inam Ul Haq 36 | 37 | cyberphantom52 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/disk-image-mounter/meson.build: -------------------------------------------------------------------------------- 1 | name = 'gnome-disk-image-mounter' 2 | 3 | mounter_conf = configuration_data() 4 | mounter_conf.merge_from(conf_rs) 5 | mounter_conf.set_quoted('APP_ID', 'org.gnome.DiskImageMounter') 6 | configure_file( 7 | input: 'config.rs.in', 8 | output: 'config.rs', 9 | configuration: mounter_conf, 10 | ) 11 | 12 | build_root = meson.project_build_root() 13 | source_root = meson.project_source_root() 14 | 15 | # Copy the config.rs output to the source directory. 16 | run_command( 17 | 'cp', 18 | build_root / 'src/disk-image-mounter' / 'config.rs', 19 | source_root / 'src/disk-image-mounter' / 'config.rs', 20 | check: true 21 | ) 22 | 23 | cargo_options = [ '--manifest-path', source_root / 'Cargo.toml' ] 24 | cargo_options += [ '--target-dir', build_root / 'src' ] 25 | cargo_options += [ '--bin', name ] 26 | 27 | if get_option('profile') != 'release' 28 | rust_target = 'debug' 29 | message('Building in debug mode') 30 | else 31 | cargo_options += [ '--release' ] 32 | rust_target = 'release' 33 | message('Building in release mode') 34 | endif 35 | 36 | cargo_env = { 'CARGO_HOME': build_root / 'cargo-home' } 37 | 38 | cargo_build = custom_target( 39 | 'cargo-build', 40 | build_by_default: true, 41 | build_always_stale: true, 42 | output: 'src', 43 | console: true, 44 | env: cargo_env, 45 | command: [ 46 | cargo, 'build', 47 | cargo_options, 48 | ] 49 | ) 50 | 51 | copy_binary = custom_target( 52 | 'cp-binary', 53 | depends: cargo_build, 54 | build_by_default: true, 55 | build_always_stale: true, 56 | install: true, 57 | install_dir: get_option('bindir'), 58 | output: name, 59 | command: [ 60 | 'cp', 61 | 'src' / rust_target / name, 62 | '@OUTPUT@', 63 | ], 64 | ) 65 | 66 | cargo_doc = custom_target( 67 | 'cargo-doc', 68 | build_by_default: false, 69 | build_always_stale: true, 70 | output: 'doc', 71 | console: true, 72 | command: [ 73 | cargo, 'doc', 74 | cargo_options + ['--no-deps', '--document-private-items'], 75 | ], 76 | ) 77 | -------------------------------------------------------------------------------- /src/notify/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #include "config.h" 10 | 11 | #include 12 | #include 13 | 14 | #include "gdusdmonitor.h" 15 | 16 | static void 17 | name_acquired_handler (GDBusConnection *connection, 18 | const gchar *name, 19 | gpointer user_data) 20 | { 21 | GduSdMonitor **monitor = user_data; 22 | 23 | g_warn_if_fail (*monitor == NULL); 24 | g_clear_object (monitor); 25 | *monitor = gdu_sd_monitor_new (); 26 | } 27 | 28 | static void 29 | name_lost_handler (GDBusConnection *connection, 30 | const gchar *name, 31 | gpointer user_data) 32 | { 33 | GduSdMonitor **monitor = user_data; 34 | 35 | g_clear_object (monitor); 36 | } 37 | 38 | int 39 | main (int argc, char *argv[]) 40 | { 41 | GMainLoop *loop = NULL; 42 | guint name_owner_id = 0; 43 | GduSdMonitor *monitor = NULL; 44 | 45 | notify_init ("org.gnome.SettingsDaemon.DiskUtilityNotify"); 46 | 47 | loop = g_main_loop_new (NULL, FALSE); 48 | 49 | /* The reason for claiming a unique name is so it's easier to test 50 | * code changes - it helps ensure that only one instance of 51 | * GduSdMonitor is running at any one time. See also 52 | * gdusdplugin.c:impl_activate(). 53 | */ 54 | name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, 55 | "org.gnome.Disks.NotificationMonitor", 56 | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | 57 | G_BUS_NAME_OWNER_FLAGS_REPLACE, 58 | NULL, /* bus_acquired_handler */ 59 | name_acquired_handler, 60 | name_lost_handler, 61 | &monitor, 62 | NULL); /* GDestroyNotify */ 63 | 64 | g_main_loop_run (loop); 65 | 66 | g_bus_unown_name (name_owner_id); 67 | g_main_loop_unref (loop); 68 | g_object_unref (monitor); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /src/disks/localjob.rs: -------------------------------------------------------------------------------- 1 | use glib::Object; 2 | use glib::prelude::*; 3 | use glib::subclass::prelude::*; 4 | use gtk::glib; 5 | 6 | /// Wrapper type around [`udisks::Object`] to allow using it in G-OBJECT code. 7 | #[derive(Clone, Debug, glib::Boxed)] 8 | #[boxed_type(name = "BoxedUdisksObject", nullable)] 9 | pub struct BoxedUdisksObject(pub udisks::Object); 10 | 11 | mod imp { 12 | use std::{ 13 | cell::{Cell, RefCell}, 14 | sync::OnceLock, 15 | }; 16 | 17 | use glib::subclass::{prelude::ObjectImpl, types::ObjectSubclass}; 18 | use gtk::glib::subclass::Signal; 19 | 20 | use super::*; 21 | 22 | #[derive(Default, Debug, glib::Properties)] 23 | #[properties(wrapper_type = super::LocalJob)] 24 | pub struct LocalJob { 25 | #[property(get, set)] 26 | description: RefCell, 27 | #[property(get, set)] 28 | extra_markup: RefCell, 29 | #[property(get, set, nullable)] 30 | object: RefCell>, 31 | 32 | // UDisksJob properties 33 | #[property(get, set)] 34 | operation: RefCell, 35 | #[property(get, set)] 36 | bytes: Cell, 37 | #[property(get, set)] 38 | progress_valid: Cell, 39 | #[property(get, set)] 40 | cancelable: Cell, 41 | #[property(get, set)] 42 | expected_end_time: Cell, 43 | #[property(get, set)] 44 | progress: Cell, 45 | #[property(get, set)] 46 | rate: Cell, 47 | #[property(get, set)] 48 | start_time: Cell, 49 | } 50 | 51 | #[glib::object_subclass] 52 | impl ObjectSubclass for LocalJob { 53 | const NAME: &'static str = "LocalJob"; 54 | type Type = super::LocalJob; 55 | } 56 | 57 | #[glib::derived_properties] 58 | impl ObjectImpl for LocalJob { 59 | fn signals() -> &'static [Signal] { 60 | static SIGNALS: OnceLock> = OnceLock::new(); 61 | SIGNALS.get_or_init(|| vec![Signal::builder("canceled").build()]) 62 | } 63 | } 64 | } 65 | 66 | glib::wrapper! { 67 | pub struct LocalJob(ObjectSubclass); 68 | } 69 | 70 | impl LocalJob { 71 | pub fn new(object: udisks::Object) -> Self { 72 | Object::builder() 73 | .property("object", BoxedUdisksObject(object)) 74 | .build() 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/disks/gnome-disks.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ui/gdu-ata-smart-dialog.ui 5 | ui/gdu-benchmark-dialog.ui 6 | ui/gdu-change-passphrase-dialog.ui 7 | ui/gdu-create-confirm-page.ui 8 | ui/gdu-create-disk-image-dialog.ui 9 | ui/gdu-create-filesystem-page.ui 10 | ui/gdu-format-volume-dialog.ui 11 | ui/gdu-create-other-page.ui 12 | ui/gdu-create-partition-page.ui 13 | ui/gdu-create-password-page.ui 14 | ui/gdu-block-row.ui 15 | ui/gdu-disk-settings-dialog.ui 16 | ui/gdu-drive-header.ui 17 | ui/gdu-drive-row.ui 18 | ui/gdu-drive-view.ui 19 | ui/gdu-encryption-options-dialog.ui 20 | ui/gdu-edit-filesystem-dialog.ui 21 | ui/gdu-mount-options-dialog.ui 22 | ui/gdu-edit-partition-dialog.ui 23 | ui/erase-multiple-disks-dialog.ui 24 | ui/gdu-format-disk-dialog.ui 25 | ui/gdu-window.ui 26 | ui/gdu-new-disk-image-dialog.ui 27 | ui/gdu-resize-volume-dialog.ui 28 | ui/gdu-restore-disk-image-dialog.ui 29 | ui/gdu-take-ownership-dialog.ui 30 | ui/shortcuts-dialog.ui 31 | ui/gdu-unlock-dialog.ui 32 | ui/style.css 33 | ui/style-dark.css 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-edit-filesystem-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-create-confirm-page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 63 | 64 | -------------------------------------------------------------------------------- /src/libgdu/meson.build: -------------------------------------------------------------------------------- 1 | enum_headers = files('libgduenums.h') 2 | 3 | sources = files('gduutils.c') 4 | 5 | enum = 'libgduenumtypes' 6 | 7 | enum_sources = gnome.mkenums( 8 | enum, 9 | sources: enum_headers, 10 | c_template: enum + '.c.template', 11 | h_template: enum + '.h.template', 12 | ) 13 | 14 | private_deps = [m_dep] 15 | 16 | deps = [ 17 | gtk_dep, 18 | libadwaita_dep, 19 | udisk_dep, 20 | ] 21 | 22 | if enable_logind 23 | private_deps += logind_dep 24 | endif 25 | 26 | cflags = [ 27 | '-DG_LOG_DOMAIN="libgdu"', 28 | '-DGNOMELOCALEDIR="@0@"'.format(gdu_prefix / gdu_localedir), 29 | ] 30 | 31 | libgdu = static_library( 32 | 'gdu', 33 | sources: sources + enum_sources, 34 | include_directories: top_inc, 35 | dependencies: deps + private_deps, 36 | c_args: cflags, 37 | ) 38 | 39 | libgdu_dep = declare_dependency( 40 | sources: enum_sources[1], 41 | link_with: libgdu, 42 | include_directories: '.', 43 | dependencies: deps, 44 | ) 45 | 46 | # Build a Rust version 47 | 48 | configure_file( 49 | input: 'config.rs.in', 50 | output: 'config.rs', 51 | configuration: conf_rs, 52 | ) 53 | 54 | build_root = meson.project_build_root() 55 | source_root = meson.project_source_root() 56 | 57 | # Copy the config.rs output to the source directory. 58 | run_command( 59 | 'cp', 60 | build_root / 'src/libgdu' / 'config.rs', 61 | source_root / 'src/libgdu' / 'config.rs', 62 | check: true, 63 | ) 64 | 65 | cargo_options = ['--manifest-path', source_root / 'Cargo.toml'] 66 | cargo_options += ['--target-dir', build_root / 'src'] 67 | cargo_options += ['--lib'] 68 | 69 | if enable_logind 70 | cargo_options += ['--features', 'logind'] 71 | endif 72 | 73 | if get_option('profile') != 'release' 74 | rust_target = 'debug' 75 | message('Building in debug mode') 76 | else 77 | cargo_options += ['--release'] 78 | rust_target = 'release' 79 | message('Building in release mode') 80 | endif 81 | 82 | cargo_env = {'CARGO_HOME': build_root / 'cargo-home'} 83 | 84 | cargo_build = custom_target( 85 | 'cargo-build', 86 | build_by_default: true, 87 | build_always_stale: true, 88 | output: 'src', 89 | console: true, 90 | env: cargo_env, 91 | command: [ 92 | cargo, 93 | 'build', 94 | cargo_options, 95 | ], 96 | ) 97 | 98 | test( 99 | 'cargo-test', 100 | cargo, 101 | args: [ 102 | 'test', 103 | cargo_options, 104 | '--', 105 | '--test-threads=1', 106 | ], 107 | is_parallel: false, 108 | timeout: 1800, 109 | ) 110 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files containing translatable strings. 2 | # Please keep this file sorted alphabetically. 3 | data/gnome-disk-image-mounter.desktop.in 4 | data/org.gnome.Disks.gschema.xml 5 | data/org.gnome.DiskUtility.desktop.in 6 | data/org.gnome.DiskUtility.metainfo.xml.in 7 | src/disk-image-mounter/application.rs 8 | src/disk-image-mounter/main.rs 9 | src/disk-image-mounter/window.rs 10 | src/disk-image-mounter/window.ui 11 | src/disks/gdu-application.c 12 | src/disks/gdu-ata-smart-dialog.c 13 | src/disks/gdu-benchmark-dialog.c 14 | src/disks/gdu-block.c 15 | src/disks/gdu-block-row.c 16 | src/disks/gdu-change-passphrase-dialog.c 17 | src/disks/gdu-create-confirm-page.c 18 | src/disks/gdu-create-disk-image-dialog.c 19 | src/disks/gdu-create-filesystem-page.c 20 | src/disks/gdu-create-other-page.c 21 | src/disks/gdu-create-partition-page.c 22 | src/disks/gdu-create-password-page.h 23 | src/disks/gdu-disk-settings-dialog.c 24 | src/disks/gdu-drive-view.c 25 | src/disks/gdu-edit-filesystem-dialog.c 26 | src/disks/gdu-edit-partition-dialog.c 27 | src/disks/gdu-encryption-options-dialog.c 28 | src/disks/gduestimator.c 29 | src/disks/gdu-format-disk-dialog.c 30 | src/disks/gdu-format-volume-dialog.c 31 | src/disks/gdu-mount-options-dialog.c 32 | src/disks/gdu-new-disk-image-dialog.c 33 | src/disks/gdu-resize-volume-dialog.c 34 | src/disks/gdu-unlock-dialog.c 35 | src/disks/gdu-window.c 36 | src/disks/gduxzdecompressor.c 37 | src/disks/main.c 38 | src/disks/restore_disk_image_dialog.rs 39 | src/disks/ui/erase-multiple-disks-dialog.ui 40 | src/disks/ui/gdu-ata-smart-dialog.ui 41 | src/disks/ui/gdu-benchmark-dialog.ui 42 | src/disks/ui/gdu-block-row.ui 43 | src/disks/ui/gdu-change-passphrase-dialog.ui 44 | src/disks/ui/gdu-create-confirm-page.ui 45 | src/disks/ui/gdu-create-disk-image-dialog.ui 46 | src/disks/ui/gdu-create-filesystem-page.ui 47 | src/disks/ui/gdu-create-other-page.ui 48 | src/disks/ui/gdu-create-partition-page.ui 49 | src/disks/ui/gdu-create-password-page.ui 50 | src/disks/ui/gdu-disk-settings-dialog.ui 51 | src/disks/ui/gdu-drive-header.ui 52 | src/disks/ui/gdu-drive-view.ui 53 | src/disks/ui/gdu-edit-filesystem-dialog.ui 54 | src/disks/ui/gdu-edit-partition-dialog.ui 55 | src/disks/ui/gdu-encryption-options-dialog.ui 56 | src/disks/ui/gdu-format-disk-dialog.ui 57 | src/disks/ui/gdu-mount-options-dialog.ui 58 | src/disks/ui/gdu-new-disk-image-dialog.ui 59 | src/disks/ui/gdu-resize-volume-dialog.ui 60 | src/disks/ui/gdu-restore-disk-image-dialog.ui 61 | src/disks/ui/gdu-take-ownership-dialog.ui 62 | src/disks/ui/gdu-unlock-dialog.ui 63 | src/disks/ui/gdu-window.ui 64 | src/disks/ui/shortcuts-dialog.ui 65 | src/libgdu/gduutils.c 66 | src/libgdu/gduutils.rs 67 | src/notify/gdusdmonitor.c 68 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-take-ownership-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Take Ownership? 5 | cancel 6 | cancel 7 | 8 | 9 | 10 | 11 | _Recursive Mode 12 | true 13 | recursive_switch 14 | 15 | 16 | center 17 | More Information 18 | help-about-symbolic 19 | info_popover 20 | 23 | 24 | 25 | 26 | 27 | center 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | _Cancel 37 | _Take Ownership 38 | 39 | 40 | 41 | 42 | 43 | 6 44 | 6 45 | 6 46 | 6 47 | true 48 | 50 49 | left 50 | Recursive mode changes the ownership of subdirectories and files. This can cause problems if files are owned by other users. 51 | 0 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/disks/page_aligned_buffer.rs: -------------------------------------------------------------------------------- 1 | /// An RAII buffer that is aligned to the page size of the system. 2 | pub struct PageAlignedBuffer { 3 | /// Memory layout of the buffer. 4 | layout: std::alloc::Layout, 5 | /// Pointer to the page aligned memory. 6 | buffer_ptr: *mut u8, 7 | /// Size of the allocated memory in bytes. 8 | size: usize, 9 | } 10 | 11 | impl PageAlignedBuffer { 12 | /// Allocates a new buffer with aligned to the page size of the operating system. 13 | /// 14 | /// The allocated memory will be zeroed. 15 | /// 16 | /// # Panics 17 | /// 18 | /// This function panics, the memory required for the buffer could not be allocated. 19 | /// 20 | /// # Examples 21 | /// ```ignore 22 | /// # use gnome_disks::page_aligned_buffer::PageAlignedBuffer; 23 | /// let mut buffer = PageAlignedBuffer::new(42); 24 | /// assert_eq!(buffer.as_mut_slice().len(), 42); 25 | /// ``` 26 | #[must_use] 27 | pub fn new(size: usize) -> Self { 28 | unsafe { 29 | let page_size = libc::sysconf(libc::_SC_PAGESIZE) as usize; 30 | let layout = std::alloc::Layout::from_size_align(size, page_size) 31 | .expect("Failed to create layout for buffer"); 32 | assert!(layout.size() >= size, "Layout is smaller than requested"); 33 | 34 | let buffer_ptr = std::alloc::alloc_zeroed(layout); 35 | assert!(!buffer_ptr.is_null(), "Failed to allocate buffer memory"); 36 | 37 | Self { 38 | layout, 39 | buffer_ptr, 40 | size, 41 | } 42 | } 43 | } 44 | 45 | /// Returns a mutable slice of the allocated buffer. 46 | /// 47 | /// # Examples 48 | /// ```ignore 49 | /// # use gnome_disks::page_aligned_buffer::PageAlignedBuffer; 50 | /// let mut buffer = PageAlignedBuffer::new(42); 51 | /// let slice = buffer.as_mut_slice(); 52 | /// slice[0] = 12; 53 | /// assert_eq!(slice[0], 12); 54 | /// ``` 55 | pub fn as_mut_slice(&mut self) -> &mut [u8] { 56 | // SAFETY: we know that the pointer is valid, correctly aligned and can hold at least 57 | // [`self.size`] bytes 58 | unsafe { std::slice::from_raw_parts_mut(self.buffer_ptr, self.size) } 59 | } 60 | } 61 | 62 | impl Drop for PageAlignedBuffer { 63 | fn drop(&mut self) { 64 | unsafe { 65 | // SAFETY: as we only ever give out an exclusive reference to the buffer and it's not 66 | // possible to clone, we can be sure that there exists no other reference to the 67 | // buffer. 68 | // As the buffer cannot be swapped out, it was created from self.layout. 69 | std::alloc::dealloc(self.buffer_ptr, self.layout); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /data/org.gnome.DiskUtility.metainfo.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.gnome.DiskUtility 5 | CC0-1.0 6 | GPL-2.0+ 7 | Disks 8 | Disk management utility for GNOME 9 | 10 |

11 | Disks provides an easy way to inspect, format, partition, and configure disks 12 | and block devices. 13 |

14 |

15 | Using Disks, you can view SMART data, manage devices, benchmark physical 16 | disks, and image USB sticks. 17 |

18 |
19 | 20 | 21 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/raw/HEAD/data/screenshots/disks-format.png 22 | Partition and format disks 23 | 24 | 25 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/raw/HEAD/data/screenshots/disks-smart.png 26 | Inspect drive speed and health status 27 | 28 | 29 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/raw/HEAD/data/screenshots/disks-main.png 30 | Manage your storage devices 31 | 32 | 33 | kailueke@riseup.net 34 | GNOME 35 | 36 | AppMenu 37 | HiDpiIcon 38 | ModernToolkit 39 | 40 | 41 | gnome-disk-utility 42 | org.gnome.DiskUtility.desktop 43 | 44 | The GNOME Project 45 | 46 | The GNOME Project 47 | 48 | https://apps.gnome.org/DiskUtility/ 49 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/issues 50 | https://welcome.gnome.org/app/DiskUtility/ 51 | https://www.gnome.org/donate/ 52 | https://help.gnome.org/users/gnome-help/stable/disk.html 53 | https://l10n.gnome.org/module/gnome-disk-utility/ 54 | https://gitlab.gnome.org/GNOME/gnome-disk-utility 55 | 56 | touch 57 | keyboard 58 | pointing 59 | 60 | 61 | 360 62 | 63 |
64 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-create-password-page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 59 | 60 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | This list is old and not updated, first take a look at 2 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/-/issues/ 3 | 4 | - For optical drives, replace "Create Disk Image…" with "Burn Image to Disc…" 5 | - Also wanted: "Blank Disc…" dialog 6 | - Part of this involves deciding on library / command-line tools to use 7 | 8 | - Btrfs support 9 | - https://bugzilla.gnome.org/show_bug.cgi?id=608204 10 | 11 | - badblocks(8) functionality 12 | - Menu item: "Test Disk…" dialog 13 | - Basically, a way to do a burn-in test when you buy new disks 14 | - e.g. badblocks -wsv /dev/sdb 15 | - Avoid modal dialogs so multiple tests can run in parallel 16 | - After confirmation (and explanation of the feature), launches a local 17 | job that runs forever. Output of the job would be 18 | 19 | [===============>--- Testing Disk: 23.1% complete ------------------] [X] 20 | Pass 33: Testing with pattern 0xaa — 0 errors — 2 days, 5 hours elapsed 21 | 22 | - When a new pass is over, the progress bar starts at 0% again 23 | 24 | - Integrate with systemd's journal 25 | - make it possible to easily view all log messages related to a device 26 | - e.g. journalctl /dev/sda 27 | - does this also cover messages in layers below the block layer? 28 | - show exclamation icon in device tree-view and a cluebar if there are 29 | _important_ and _unread_ messages 30 | - define "important" (warning and above?) 31 | - define "unread" (does the systemd journal have such a concept?) 32 | - Disks will consume the journal APIs through (page-based?) D-Bus 33 | interfaces in udisks so maybe we can put the concept of "unread" 34 | into that 35 | - make udisks log messages to the systemd journal 36 | - with this in place, we can completely do away with modal error dialogs 37 | - why? because udisksd will have logged an error message to the journal 38 | - huge win 39 | 40 | - Historical SMART values 41 | - Like http://people.freedesktop.org/~david/smart-graph-temperature.png 42 | - rightmost third is linear (covering 24 hours) 43 | - leftmost two thirds are logarithmic (covering 100 days) 44 | - We also want small arrows in the list-view to convey the trend of 45 | a value over, say, the last week, e.g. 46 | 47 | | Value | Normalized | Worst | Threshold 48 | Reallocated Sector Count | ↑ 2 sectors | ↓ 99 | 99 | 50 49 | - See also https://plus.google.com/110773474140772402317/posts/T4pqft6pP9c 50 | 51 | - Encryption Recovery Key 52 | - When setting up an encrypted device, it should be possible to create 53 | a "recovery key" that the user can either print or store in a safe 54 | place somewhere 55 | - LUKS already supports multiple keys 56 | - for a similar OS X feature see: 57 | http://macs.about.com/od/LionTipsNtricks/ss/Filevault-2-Using-Disk-Encryption-With-Os-X-Lion.htm 58 | -------------------------------------------------------------------------------- /src/disks/gdu-drive-row.c: -------------------------------------------------------------------------------- 1 | /* gdu-drive-row.c 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #define G_LOG_DOMAIN "gdu-drive-row" 12 | 13 | #ifdef HAVE_CONFIG_H 14 | # include "config.h" 15 | #endif 16 | 17 | #include "gdu-drive-row.h" 18 | 19 | struct _GduDriveRow 20 | { 21 | AdwActionRow parent_instance; 22 | 23 | GtkImage *drive_image; 24 | GduDrive *drive; 25 | }; 26 | 27 | 28 | G_DEFINE_TYPE (GduDriveRow, gdu_drive_row, ADW_TYPE_ACTION_ROW) 29 | 30 | static void 31 | update_drive_row (GduDriveRow *self) 32 | { 33 | const char *description, *name; 34 | GIcon *icon; 35 | 36 | g_assert (GDU_IS_DRIVE_ROW (self)); 37 | 38 | description = gdu_item_get_description (GDU_ITEM (self->drive)); 39 | name = gdu_drive_get_name (self->drive); 40 | icon = gdu_item_get_icon (GDU_ITEM (self->drive)); 41 | 42 | adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), description); 43 | adw_action_row_set_subtitle (ADW_ACTION_ROW (self), name); 44 | gtk_image_set_from_gicon (self->drive_image, icon); 45 | } 46 | 47 | static void 48 | gdu_drive_row_finalize (GObject *object) 49 | { 50 | GduDriveRow *self = (GduDriveRow *)object; 51 | 52 | g_clear_object (&self->drive); 53 | 54 | G_OBJECT_CLASS (gdu_drive_row_parent_class)->finalize (object); 55 | } 56 | 57 | static void 58 | gdu_drive_row_class_init (GduDriveRowClass *klass) 59 | { 60 | GObjectClass *object_class = G_OBJECT_CLASS (klass); 61 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); 62 | 63 | object_class->finalize = gdu_drive_row_finalize; 64 | 65 | gtk_widget_class_set_template_from_resource (widget_class, 66 | "/org/gnome/DiskUtility/ui/" 67 | "gdu-drive-row.ui"); 68 | 69 | gtk_widget_class_bind_template_child (widget_class, GduDriveRow, drive_image); 70 | } 71 | 72 | static void 73 | gdu_drive_row_init (GduDriveRow *self) 74 | { 75 | gtk_widget_init_template (GTK_WIDGET (self)); 76 | } 77 | 78 | GduDriveRow * 79 | gdu_drive_row_new (GduDrive *drive) 80 | { 81 | GduDriveRow *self; 82 | 83 | g_return_val_if_fail (GDU_IS_DRIVE (drive), NULL); 84 | 85 | self = g_object_new (GDU_TYPE_DRIVE_ROW, NULL); 86 | self->drive = g_object_ref (drive); 87 | 88 | g_signal_connect_object (self->drive, 89 | "changed", 90 | G_CALLBACK (update_drive_row), 91 | self, G_CONNECT_SWAPPED); 92 | update_drive_row (self); 93 | 94 | return self; 95 | } 96 | 97 | GduDrive * 98 | gdu_drive_row_get_drive (GduDriveRow *self) 99 | { 100 | g_return_val_if_fail (GDU_IS_DRIVE_ROW (self), NULL); 101 | 102 | return self->drive; 103 | } 104 | -------------------------------------------------------------------------------- /src/disks/gdu-block.h: -------------------------------------------------------------------------------- 1 | /* gdu-block.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | #include 15 | 16 | #include "gdu-item.h" 17 | 18 | G_BEGIN_DECLS 19 | 20 | #define GDU_TYPE_BLOCK (gdu_block_get_type ()) 21 | G_DECLARE_FINAL_TYPE (GduBlock, gdu_block, GDU, BLOCK, GduItem) 22 | 23 | GduBlock *gdu_block_new (gpointer udisk_client, 24 | gpointer udisk_object, 25 | GduItem *parent); 26 | GduBlock *gdu_block_sized_new (gpointer udisk_client, 27 | guint64 start_offset, 28 | guint64 size, 29 | GduItem *parent); 30 | guint64 gdu_block_get_offset (GduBlock *self); 31 | guint64 gdu_block_get_number (GduBlock *self); 32 | guint64 gdu_block_get_unused_size (GduBlock *self); 33 | bool gdu_block_is_extended (GduBlock *self); 34 | char *gdu_block_get_size_str (GduBlock *self); 35 | const char *gdu_block_get_uuid (GduBlock *self); 36 | const char *gdu_block_get_device_id (GduBlock *self); 37 | const char *gdu_block_get_fs_label (GduBlock *self); 38 | const char *gdu_block_get_fs_type (GduBlock *self); 39 | const char *const *gdu_block_get_mount_points (GduBlock *self); 40 | bool gdu_block_needs_unmount (GduBlock *self); 41 | void gdu_block_set_fs_label_async (GduBlock *self, 42 | const char *label, 43 | GAsyncReadyCallback callback, 44 | gpointer user_data); 45 | gboolean gdu_block_set_fs_label_finish (GduBlock *self, 46 | GAsyncResult *result, 47 | GError **error); 48 | void gdu_block_emit_updated (GduBlock *self); 49 | 50 | /* xxx: to be removed once the dust settles */ 51 | gpointer gdu_block_get_object (GduBlock *self); 52 | 53 | G_END_DECLS 54 | -------------------------------------------------------------------------------- /doc/man/gnome-disk-image-mounter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | gnome-disk-utility 4 | March 2013 5 | GNOME 6 | 7 | 8 | 9 | gnome-disk-image-mounter 10 | Attach and mount disk images 11 | 12 | 13 | SYNOPSIS 14 | 15 | gnome-disk-image-mounter 16 | --writable 17 | URI 18 | 19 | 20 | 21 | DESCRIPTION 22 | 23 | gnome-disk-image-mounter can be used to set 24 | up disk images. Both regular files and GVfs 25 | URIs (such as smb://filer/media/file.iso) 26 | can be used in the URI parameter. If no 27 | URIs are given and a window server is 28 | running, a graphical file chooser will be presented. 29 | 30 | 31 | Note that gnome-disk-image-mounter will not 32 | mount filesystems or unlock encrypted volumes in the disk image 33 | - this responsibility is left to the automounter in GNOME Shell 34 | to ensure that the same interactions happen as if the disk image 35 | was a regular physical device or disc. 36 | 37 | 38 | By default the disk images are attached read-only, use 39 | the option to change this. 40 | 41 | 42 | 43 | RETURN VALUE 44 | 45 | gnome-disk-image-mounter returns 0 on success 46 | and non-zero on failure. 47 | 48 | 49 | 50 | AUTHOR 51 | 52 | Written by David Zeuthen zeuthen@gmail.com with 53 | a lot of help from many others. 54 | 55 | 56 | 57 | 58 | BUGS 59 | 60 | Please send bug reports to either the distribution bug tracker 61 | or the upstream bug tracker at 62 | . 63 | 64 | 65 | 66 | 67 | SEE ALSO 68 | 69 | gnome-shell1, 70 | gnome-disks1, 71 | udisks8, 72 | losetup8 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/disks/gdu-item.h: -------------------------------------------------------------------------------- 1 | /* gdu-item.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | typedef enum GduFeature { 18 | GDU_FEATURE_NONE = 0, 19 | GDU_FEATURE_FORMAT = 1 << 0, 20 | GDU_FEATURE_CREATE_IMAGE = 1 << 1, 21 | GDU_FEATURE_RESTORE_IMAGE = 1 << 2, 22 | GDU_FEATURE_CREATE_PARTITION = 1 << 3, 23 | GDU_FEATURE_EDIT_PARTITION = 1 << 4, 24 | GDU_FEATURE_DELETE_PARTITION = 1 << 5, 25 | GDU_FEATURE_RESIZE_PARTITION = 1 << 6, 26 | GDU_FEATURE_CHECK_FILESYSTEM = 1 << 7, 27 | GDU_FEATURE_REPAIR_FILESYSTEM = 1 << 8, 28 | GDU_FEATURE_EDIT_LABEL = 1 << 9, 29 | GDU_FEATURE_CAN_SWAPON = 1 << 10, 30 | GDU_FEATURE_CAN_SWAPOFF = 1 << 11, 31 | GDU_FEATURE_CAN_MOUNT = 1 << 12, 32 | GDU_FEATURE_CAN_UNMOUNT = 1 << 13, 33 | GDU_FEATURE_CAN_LOCK = 1 << 14, 34 | GDU_FEATURE_CAN_UNLOCK = 1 << 15, 35 | GDU_FEATURE_CHANGE_PASSPHRASE = 1 << 16, 36 | GDU_FEATURE_TAKE_OWNERSHIP = 1 << 17, 37 | GDU_FEATURE_BENCHMARK = 1 << 18, 38 | GDU_FEATURE_CONFIGURE_FSTAB = 1 << 19, 39 | GDU_FEATURE_CONFIGURE_CRYPTTAB = 1 << 20, 40 | GDU_FEATURE_SMART = 1 << 21, 41 | GDU_FEATURE_SETTINGS = 1 << 22, 42 | GDU_FEATURE_STANDBY = 1 << 23, 43 | GDU_FEATURE_WAKEUP = 1 << 24, 44 | GDU_FEATURE_POWEROFF = 1 << 25, 45 | GDU_FEATURE_EJECT = 1 << 26, 46 | } GduFeature; 47 | 48 | #define GDU_TYPE_ITEM (gdu_item_get_type ()) 49 | G_DECLARE_DERIVABLE_TYPE (GduItem, gdu_item, GDU, ITEM, GObject) 50 | 51 | struct _GduItemClass 52 | { 53 | GObjectClass parent_class; 54 | 55 | const char *(*get_description) (GduItem *self); 56 | const char *(*get_partition_type) (GduItem *self); 57 | GIcon *(*get_icon) (GduItem *self); 58 | guint64 (*get_size) (GduItem *self); 59 | GListModel *(*get_partitions) (GduItem *self); 60 | GduItem *(*get_parent) (GduItem *self); 61 | GduFeature (*get_features) (GduItem *self); 62 | 63 | void (*changed) (GduItem *self); 64 | }; 65 | 66 | const char *gdu_item_get_description (GduItem *self); 67 | const char *gdu_item_get_partition_type (GduItem *self); 68 | GIcon *gdu_item_get_icon (GduItem *self); 69 | guint64 gdu_item_get_size (GduItem *self); 70 | GListModel *gdu_item_get_partitions (GduItem *self); 71 | GduItem *gdu_item_get_parent (GduItem *self); 72 | GduFeature gdu_item_get_features (GduItem *self); 73 | 74 | void gdu_item_changed (GduItem *self); 75 | 76 | G_END_DECLS 77 | -------------------------------------------------------------------------------- /src/disks/ffi/mod.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | collections::HashMap, 3 | ffi::c_char, 4 | rc::Rc, 5 | sync::{LazyLock, Mutex}, 6 | }; 7 | 8 | use gtk::glib::{self, translate::FromGlibPtrBorrow}; 9 | use udisks::zbus::zvariant::OwnedObjectPath; 10 | 11 | use crate::{GduRestoreDiskImageDialog, localjob::LocalJob}; 12 | 13 | //FIXME: move this to Gdu application once ported 14 | // GTK is single threaded 15 | thread_local! { 16 | static GLOBAL_MAP: LazyLock>>> = 17 | LazyLock::new(|| Mutex::new(HashMap::new())); 18 | } 19 | 20 | pub fn create_local_job(object: &udisks::Object) -> Rc { 21 | let local_job = Rc::new(LocalJob::new(object.clone())); 22 | GLOBAL_MAP.with(|map| { 23 | let mut map = map.lock().expect("poisoned lock"); 24 | map.entry(object.object_path().clone()) 25 | .or_insert_with(|| local_job) 26 | .clone() 27 | }) 28 | } 29 | 30 | pub fn destroy_local_job(job: Rc) { 31 | GLOBAL_MAP.with(|map| { 32 | let mut map = map.lock().expect("poisoned lock"); 33 | let _ = map.remove(job.object().unwrap().0.object_path()); 34 | }) 35 | } 36 | 37 | #[unsafe(no_mangle)] 38 | pub extern "C" fn gdu_rs_has_local_jobs() -> bool { 39 | GLOBAL_MAP.with(|map| { 40 | let map = map.lock().expect("poisoned lock"); 41 | map.is_empty() 42 | }) 43 | } 44 | 45 | #[unsafe(no_mangle)] 46 | pub extern "C" fn gdu_rs_local_jobs_clear() { 47 | GLOBAL_MAP.with(|map| { 48 | let mut map = map.lock().expect("poisoned lock"); 49 | map.clear(); 50 | }) 51 | } 52 | 53 | /// Reads a C string and converts it to a Rust String. 54 | /// 55 | /// Opposed to using [CStr], this also handles `NULL`. 56 | fn read_nullable_cstr(cstr_ptr: *const c_char) -> Option { 57 | if cstr_ptr.is_null() { 58 | return None; 59 | } 60 | //SAFETY: we ensure that the pointer is non-null and otherwise assume that it is a valid c 61 | //string 62 | let cstr = unsafe { std::ffi::CStr::from_ptr(cstr_ptr) }.to_owned(); 63 | Some(cstr.to_str().ok()?.to_string()) 64 | } 65 | 66 | #[unsafe(no_mangle)] 67 | pub extern "C" fn gdu_rs_restore_disk_image_dialog_show( 68 | window_ptr: *mut gtk::ffi::GtkWindow, 69 | object_path: *const c_char, 70 | disk_image_filename: *const c_char, 71 | ) { 72 | assert!(!window_ptr.is_null(), "`window_ptr` must be non-null"); 73 | 74 | //SAFETY: the C side has already initialized GTK 75 | unsafe { gtk::set_initialized() } 76 | let parent_window = unsafe { gtk::Window::from_glib_borrow(window_ptr) }; 77 | let disk_image_filename = read_nullable_cstr(disk_image_filename); 78 | let object_path = read_nullable_cstr(object_path); 79 | 80 | glib::MainContext::default().spawn_local(async move { 81 | let client = udisks::Client::new() 82 | .await 83 | .expect("Failed to create udisks client"); 84 | let object = object_path.and_then(|p| client.object(p).ok()); 85 | 86 | GduRestoreDiskImageDialog::show( 87 | parent_window.as_ref(), 88 | object.as_ref(), 89 | client, 90 | disk_image_filename.as_deref(), 91 | ) 92 | .await; 93 | }); 94 | } 95 | -------------------------------------------------------------------------------- /src/disks/gdu-log.h: -------------------------------------------------------------------------------- 1 | /* gdu-log.h 2 | * 3 | * Copyright 2024 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #ifndef GDU_LOG_LEVEL_TRACE 16 | # define GDU_LOG_LEVEL_TRACE ((GLogLevelFlags)(1 << G_LOG_LEVEL_USER_SHIFT)) 17 | # define GDU_LOG_DETAILED ((GLogLevelFlags)(1 << (G_LOG_LEVEL_USER_SHIFT + 1))) 18 | #endif 19 | 20 | #define GDU_TRACE_MSG(fmt, ...) \ 21 | gdu_log (G_LOG_DOMAIN, GDU_LOG_LEVEL_TRACE, \ 22 | NULL, __FILE__, G_STRINGIFY (__LINE__), \ 23 | G_STRFUNC, fmt, ##__VA_ARGS__) 24 | #define GDU_TRACE(value, fmt, ...) \ 25 | gdu_log (G_LOG_DOMAIN, \ 26 | GDU_LOG_LEVEL_TRACE, \ 27 | value, __FILE__, G_STRINGIFY (__LINE__), \ 28 | G_STRFUNC, fmt, ##__VA_ARGS__) 29 | #define GDU_TRACE_DETAILED(value, fmt, ...) \ 30 | gdu_log (G_LOG_DOMAIN, \ 31 | GDU_LOG_LEVEL_TRACE | GDU_LOG_DETAILED, \ 32 | value, __FILE__, G_STRINGIFY (__LINE__), \ 33 | G_STRFUNC, fmt, ##__VA_ARGS__) 34 | #define GDU_DEBUG_MSG(fmt, ...) \ 35 | gdu_log (G_LOG_DOMAIN, \ 36 | G_LOG_LEVEL_DEBUG | GDU_LOG_DETAILED, \ 37 | NULL, __FILE__, G_STRINGIFY (__LINE__), \ 38 | G_STRFUNC, fmt, ##__VA_ARGS__) 39 | #define GDU_DEBUG(value, fmt, ...) \ 40 | gdu_log (G_LOG_DOMAIN, \ 41 | G_LOG_LEVEL_DEBUG | GDU_LOG_DETAILED, \ 42 | value, __FILE__, G_STRINGIFY (__LINE__), \ 43 | G_STRFUNC, fmt, ##__VA_ARGS__) 44 | #define GDU_WARNING(value, fmt, ...) \ 45 | gdu_log (G_LOG_DOMAIN, \ 46 | G_LOG_LEVEL_WARNING | GDU_LOG_DETAILED, \ 47 | value, __FILE__, G_STRINGIFY (__LINE__), \ 48 | G_STRFUNC, fmt, ##__VA_ARGS__) 49 | 50 | void gdu_log_init (void); 51 | void gdu_log_increase_verbosity (void); 52 | int gdu_log_get_verbosity (void); 53 | void gdu_log_to_file (const char *file_path, 54 | gboolean append); 55 | const char *gdu_log_bool_str (gboolean value, 56 | gboolean use_success); 57 | void gdu_log (const char *domain, 58 | GLogLevelFlags log_level, 59 | const char *value, 60 | const char *file, 61 | const char *line, 62 | const char *func, 63 | const char *message_format, 64 | ...) G_GNUC_PRINTF (7, 8); 65 | void gdu_log_anonymize_value (GString *str, 66 | const char *value); 67 | -------------------------------------------------------------------------------- /src/disk-image-mounter/application.rs: -------------------------------------------------------------------------------- 1 | use gtk::prelude::*; 2 | use gtk::subclass::prelude::*; 3 | use gtk::{gio, glib}; 4 | 5 | use crate::config; 6 | 7 | mod imp { 8 | use super::*; 9 | use crate::window::ImageMounterWindow; 10 | use adw::subclass::prelude::AdwApplicationImpl; 11 | 12 | #[derive(Debug, Default)] 13 | pub struct ImageMounterApplication {} 14 | 15 | #[glib::object_subclass] 16 | impl ObjectSubclass for ImageMounterApplication { 17 | const NAME: &'static str = "ImageMounterApplication"; 18 | type Type = super::ImageMounterApplication; 19 | type ParentType = adw::Application; 20 | } 21 | 22 | impl ObjectImpl for ImageMounterApplication {} 23 | 24 | impl ApplicationImpl for ImageMounterApplication { 25 | fn activate(&self) { 26 | log::debug!("AdwApplication::activate"); 27 | } 28 | 29 | fn open(&self, files: &[gio::File], _hint: &str) { 30 | for file in files { 31 | if !file.query_exists(gio::Cancellable::NONE) { 32 | log::error!( 33 | "File {:?} does not exists", 34 | file.path().as_ref().map(|path| path.display()) 35 | ); 36 | continue; 37 | } 38 | ImageMounterWindow::new(&self.obj(), file).present(); 39 | } 40 | } 41 | 42 | fn startup(&self) { 43 | log::debug!("AdwApplication::startup"); 44 | self.parent_startup(); 45 | let app = self.obj(); 46 | 47 | gtk::Window::set_default_icon_name("drive-removable-media"); 48 | 49 | app.setup_gactions(); 50 | app.setup_accels(); 51 | app.activate(); 52 | } 53 | } 54 | 55 | impl GtkApplicationImpl for ImageMounterApplication {} 56 | impl AdwApplicationImpl for ImageMounterApplication {} 57 | } 58 | 59 | glib::wrapper! { 60 | pub struct ImageMounterApplication(ObjectSubclass) 61 | @extends gio::Application, gtk::Application, adw::Application, 62 | @implements gio::ActionMap, gio::ActionGroup; 63 | } 64 | 65 | #[gtk::template_callbacks] 66 | impl ImageMounterApplication { 67 | fn setup_gactions(&self) { 68 | let action_quit = gio::ActionEntry::builder("quit") 69 | .activate(move |app: &Self, _, _| { 70 | app.quit(); 71 | }) 72 | .build(); 73 | 74 | self.add_action_entries([action_quit]); 75 | } 76 | 77 | fn setup_accels(&self) { 78 | self.set_accels_for_action("app.quit", &["q"]); 79 | self.set_accels_for_action("window.close", &["w"]); 80 | } 81 | 82 | pub fn run(&self) -> glib::ExitCode { 83 | log::info!("Disk Image Mounter"); 84 | log::info!("Version: {} ({})", config::VERSION, config::PROFILE); 85 | log::info!("Datadir: {}", config::PKGDATADIR); 86 | 87 | ApplicationExtManual::run(self) 88 | } 89 | } 90 | 91 | impl Default for ImageMounterApplication { 92 | fn default() -> Self { 93 | glib::Object::builder() 94 | .property("application-id", config::APP_ID) 95 | .property( 96 | "flags", 97 | gio::ApplicationFlags::HANDLES_OPEN | gio::ApplicationFlags::NON_UNIQUE, 98 | ) 99 | .build() 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-create-disk-image-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | DRY="${DRY:-0}" 5 | KEYNAME="${KEYNAME:-id_gnome}" 6 | GNOMEUSERNAME="${GNOMEUSERNAME:-kailueke}" 7 | KEY="${HOME}/.ssh/${KEYNAME}" 8 | 9 | ARG="${1-}" 10 | if [ "${ARG}" = "" ] || [ "${ARG}" = "-h" ] || [ "${ARG}" = "--help" ]; then 11 | echo "Usage: [GNOMEUSERNAME=mygnomeuser] [KEYNAME=id_rsa] [DRY=1] $0 VERSION" 12 | echo "Pulls the current branch, generates the NEWS entries, bumps meson version," 13 | echo "then tags and pushes the commit and uploads the tar ball" 14 | exit 1 15 | fi 16 | 17 | if ! echo "${ARG}" | grep "\." -q; then 18 | echo "No minor version given" 19 | exit 1 20 | fi 21 | MAJOR=$(echo "${ARG}" | cut -d . -f 1) 22 | MINOR=$(echo "${ARG}" | cut -d . -f 2) 23 | if [ "${MAJOR}" = "" ] || [ "${MINOR}" = "" ]; then 24 | echo "Major '${MAJOR}' or minor '${MINOR}' version empty" 25 | exit 1 26 | fi 27 | BRANCH=$(git rev-parse --abbrev-ref HEAD) 28 | if [ "${BRANCH}" != "main" ] && [ "${BRANCH}" != "gnome-${MAJOR}" ]; then 29 | echo "Branch ${BRANCH} does not match the expected 'main' or 'gnome-${MAJOR}' branch" 30 | exit 1 31 | fi 32 | 33 | REMOTE=$(git remote -v | grep "ssh://git@gitlab.gnome.org" | grep -m 1 push | cut -f 1) 34 | 35 | git pull "${REMOTE}" "${BRANCH}" 36 | 37 | LAST_TAG=$(git describe --tags --abbrev=0) 38 | if [ "${LAST_TAG}" = "${ARG}" ]; then 39 | echo "Last tag is ${ARG}" 40 | exit 1 41 | fi 42 | 43 | { 44 | DATE=$(LC_ALL=C date '+%B %d, %Y') 45 | HEADER="${ARG} - ${DATE}" 46 | echo "${HEADER}" 47 | echo "${HEADER}" | tr '[:print:]' '=' 48 | echo 49 | git shortlog "${LAST_TAG}..HEAD" -- ':!po/*.po' ':!release' | sed 's/ ([0-9]*):$/:/' | sed 's/^ [ ]*/ \* /' 50 | if [ "$(git log "${LAST_TAG}..HEAD" -- po/*.po)" != "" ]; then 51 | echo "Updated translations:" 52 | { 53 | echo -n ' * ' 54 | git log "${LAST_TAG}..HEAD" --pretty=format:%an --name-only -- po/*.po | sed -e :a -e '$!N;s|\npo/\(.*\)\.po| \(\1\)|;ta' | sort -u | sed '$!N;s/^\n//' | python3 -c 'print(", ".join(open("/dev/stdin").read().strip().split("\n")))' 55 | } | fold -s -w 75 | sed -e '2,$s/^/ /' | sed -e 's/[[:space:]]*$//' 56 | echo 57 | fi 58 | } | { 59 | if [ "${DRY}" = "0" ]; then 60 | cat - NEWS | sponge NEWS 61 | else 62 | cat 63 | fi 64 | } 65 | 66 | if [ "${DRY}" = "0" ]; then 67 | SEDARG="-i" 68 | PASS="meson.build" 69 | else 70 | SEDARG="" 71 | PASS="-" 72 | fi 73 | echo "Meson version:" 74 | sed ${SEDARG} -e "3,\$s/^ version: '${LAST_TAG}',\$/ version: '${ARG}',/" meson.build | grep -m 1 version "${PASS}" 75 | if [ "${DRY}" = "0" ]; then 76 | PASS="data/org.gnome.DiskUtility.metainfo.xml.in" 77 | else 78 | PASS="-" 79 | fi 80 | echo "Metainfo URLs:" 81 | sed ${SEDARG} -e "s,/raw/[^/]*,/raw/${BRANCH},g" data/org.gnome.DiskUtility.metainfo.xml.in | grep raw/ "${PASS}" 82 | 83 | if [ "${DRY}" = "0" ]; then 84 | git add NEWS meson.build data/org.gnome.DiskUtility.metainfo.xml.in 85 | git commit -m "Prepare ${ARG}" 86 | git tag -a -m "GNOME Disks ${ARG}" "${ARG}" 87 | rm -r builddir 88 | meson builddir 89 | ninja -C builddir dist 90 | git push "${REMOTE}" 91 | git push "${REMOTE}" "${ARG}" 92 | scp -i "${KEY}" "${PWD}/builddir/meson-dist/gnome-disk-utility-${ARG}.tar.xz" "${GNOMEUSERNAME}@master.gnome.org:" 93 | ssh -t -i "${KEY}" "${GNOMEUSERNAME}@master.gnome.org" ftpadmin install "gnome-disk-utility-${ARG}.tar.xz" 94 | echo "Success" 95 | else 96 | echo "GNOME Disks ${ARG} (dry run)" 97 | fi 98 | if [ "${MINOR}" = "0" ]; then 99 | echo "If this is a stable release, create the branch:" 100 | echo "git branch gnome-${MAJOR} && git checkout gnome-${MAJOR} && git push ${REMOTE} && echo Success" 101 | fi 102 | -------------------------------------------------------------------------------- /src/disks/gdu-drive.h: -------------------------------------------------------------------------------- 1 | /* gdu-drive.h 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | #include "gdu-item.h" 16 | 17 | G_BEGIN_DECLS 18 | 19 | #define GDU_TYPE_DRIVE (gdu_drive_get_type ()) 20 | G_DECLARE_FINAL_TYPE (GduDrive, gdu_drive, GDU, DRIVE, GduItem) 21 | 22 | GduDrive *gdu_drive_new (gpointer udisk_client, 23 | gpointer udisk_object, 24 | GduItem *parent); 25 | gboolean gdu_drive_matches_object (GduDrive *self, 26 | gpointer udrive_object); 27 | const char *gdu_drive_get_name (GduDrive *self); 28 | const char *gdu_drive_get_model (GduDrive *self); 29 | const char *gdu_drive_get_serial (GduDrive *self); 30 | GList *gdu_drive_get_siblings (GduDrive *self); 31 | void gdu_drive_set_child (GduDrive *self, 32 | gpointer udisk_object); 33 | 34 | void gdu_drive_standby_async (GduDrive *self, 35 | GCancellable *cancellable, 36 | GAsyncReadyCallback callback, 37 | gpointer user_data); 38 | gboolean gdu_drive_standby_finish (GduDrive *self, 39 | GAsyncResult *result, 40 | GError **error); 41 | void gdu_drive_wakeup_async (GduDrive *self, 42 | GCancellable *cancellable, 43 | GAsyncReadyCallback callback, 44 | gpointer user_data); 45 | gboolean gdu_drive_wakeup_finish (GduDrive *self, 46 | GAsyncResult *result, 47 | GError **error); 48 | void gdu_drive_power_off_async (GduDrive *self, 49 | gpointer parent_window, 50 | GCancellable *cancellable, 51 | GAsyncReadyCallback callback, 52 | gpointer user_data); 53 | gboolean gdu_drive_power_off_finish (GduDrive *self, 54 | GAsyncResult *result, 55 | GError **error); 56 | void gdu_drive_block_changed (GduDrive *self, 57 | gpointer block); 58 | 59 | /* xxx: to be removed once the dust settles */ 60 | gpointer gdu_drive_get_object (GduDrive *self); 61 | gpointer gdu_drive_get_object_for_format (GduDrive *self); 62 | 63 | G_END_DECLS 64 | -------------------------------------------------------------------------------- /src/notify/gdusdmanager.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Red Hat, Inc. 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: David Zeuthen 7 | */ 8 | 9 | #include "config.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "gdusdmanager.h" 16 | #include "gdusdmonitor.h" 17 | 18 | #include 19 | 20 | struct GduSdManagerClass; 21 | typedef struct GduSdManagerClass GduSdManagerClass; 22 | 23 | struct GduSdManager 24 | { 25 | GObject parent_instance; 26 | GduSdMonitor *monitor; 27 | guint name_owner_id; 28 | }; 29 | 30 | struct GduSdManagerClass 31 | { 32 | GObjectClass parent_class; 33 | }; 34 | 35 | static gboolean gdu_sd_manager_start (GduSdManager *, GError **); 36 | static void gdu_sd_manager_stop (GduSdManager *); 37 | 38 | static GduSdManager *gdu_sd_manager_new (void); 39 | 40 | G_DEFINE_TYPE (GduSdManager, gdu_sd_manager, G_TYPE_OBJECT) 41 | GNOME_SETTINGS_PLUGIN_REGISTER (GduSd, gdu_sd) 42 | 43 | static void 44 | name_acquired_handler (GDBusConnection *connection, 45 | const gchar *name, 46 | gpointer user_data) 47 | { 48 | GduSdManager *manager = GDU_SD_MANAGER (user_data); 49 | g_warn_if_fail (manager->monitor == NULL); 50 | g_clear_object (&manager->monitor); 51 | manager->monitor = gdu_sd_monitor_new (); 52 | } 53 | 54 | static void 55 | name_lost_handler (GDBusConnection *connection, 56 | const gchar *name, 57 | gpointer user_data) 58 | { 59 | GduSdManager *manager = GDU_SD_MANAGER (user_data); 60 | g_clear_object (&manager->monitor); 61 | } 62 | 63 | static void 64 | gdu_sd_manager_init (GduSdManager *manager) 65 | { 66 | } 67 | 68 | static void 69 | gdu_sd_manager_finalize (GObject *object) 70 | { 71 | GduSdManager *manager = GDU_SD_MANAGER (object); 72 | 73 | gdu_sd_manager_stop (manager); 74 | 75 | G_OBJECT_CLASS (gdu_sd_manager_parent_class)->finalize (object); 76 | } 77 | 78 | static gboolean 79 | gdu_sd_manager_start (GduSdManager *manager, 80 | GError **error) 81 | { 82 | /* The reason for claiming a unique name is so it's easier to test 83 | * code changes - it helps ensure that only one instance of 84 | * GduSdMonitor is running at any one time. See also testplugin.c. 85 | */ 86 | if (manager->name_owner_id == 0) 87 | { 88 | manager->name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, 89 | "org.gnome.Disks.NotificationMonitor", 90 | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | 91 | G_BUS_NAME_OWNER_FLAGS_REPLACE, 92 | NULL, /* bus_acquired_handler */ 93 | name_acquired_handler, 94 | name_lost_handler, 95 | manager, 96 | NULL); /* GDestroyNotify */ 97 | } 98 | 99 | return TRUE; 100 | } 101 | 102 | static void 103 | gdu_sd_manager_stop (GduSdManager *manager) 104 | { 105 | if (manager->name_owner_id == 0) 106 | { 107 | g_bus_unown_name (manager->name_owner_id); 108 | manager->name_owner_id = 0; 109 | } 110 | 111 | g_clear_object (&manager->monitor); 112 | } 113 | 114 | static void 115 | gdu_sd_manager_class_init (GduSdManagerClass *klass) 116 | { 117 | GObjectClass *object_class = G_OBJECT_CLASS (klass); 118 | 119 | object_class->finalize = gdu_sd_manager_finalize; 120 | } 121 | 122 | static GduSdManager * 123 | gdu_sd_manager_new (void) 124 | { 125 | return g_object_new (GDU_TYPE_SD_MANAGER, NULL); 126 | } 127 | -------------------------------------------------------------------------------- /src/disks/gdu-item.c: -------------------------------------------------------------------------------- 1 | /* gdu-item.c 2 | * 3 | * Copyright 2023 Mohammed Sadiq 4 | * 5 | * Author(s): 6 | * Mohammed Sadiq 7 | * 8 | * SPDX-License-Identifier: GPL-2.0-or-later 9 | */ 10 | 11 | #undef G_LOG_DOMAIN 12 | #define G_LOG_DOMAIN "gdu-item" 13 | 14 | #ifdef HAVE_CONFIG_H 15 | # include "config.h" 16 | #endif 17 | 18 | #include "gdu-item.h" 19 | 20 | G_DEFINE_ABSTRACT_TYPE (GduItem, gdu_item, G_TYPE_OBJECT) 21 | 22 | enum { 23 | CHANGED, 24 | N_SIGNALS 25 | }; 26 | 27 | static guint signals[N_SIGNALS]; 28 | 29 | static const char * 30 | gdu_item_real_get_description (GduItem *self) 31 | { 32 | g_assert (GDU_IS_ITEM (self)); 33 | 34 | return "—"; 35 | } 36 | 37 | static const char * 38 | gdu_item_real_get_partition_type (GduItem *self) 39 | { 40 | g_assert (GDU_IS_ITEM (self)); 41 | 42 | return "—"; 43 | } 44 | 45 | static GIcon * 46 | gdu_item_real_get_icon (GduItem *self) 47 | { 48 | g_assert_not_reached (); 49 | } 50 | 51 | static guint64 52 | gdu_item_real_get_size (GduItem *self) 53 | { 54 | return 0; 55 | } 56 | 57 | static GduItem * 58 | gdu_item_real_get_parent (GduItem *self) 59 | { 60 | return NULL; 61 | } 62 | 63 | static GListModel * 64 | gdu_item_real_get_partitions (GduItem *self) 65 | { 66 | return NULL; 67 | } 68 | 69 | static GduFeature 70 | gdu_item_real_get_features (GduItem *self) 71 | { 72 | return GDU_FEATURE_NONE; 73 | } 74 | 75 | static void 76 | gdu_item_real_changed (GduItem *self) 77 | { 78 | g_signal_emit_by_name (self, "changed", 0); 79 | } 80 | 81 | static void 82 | gdu_item_class_init (GduItemClass *klass) 83 | { 84 | GduItemClass *item_class = GDU_ITEM_CLASS (klass); 85 | 86 | item_class->get_description = gdu_item_real_get_description; 87 | item_class->get_partition_type = gdu_item_real_get_partition_type; 88 | item_class->get_icon = gdu_item_real_get_icon; 89 | item_class->get_size = gdu_item_real_get_size; 90 | item_class->get_parent = gdu_item_real_get_parent; 91 | item_class->get_partitions = gdu_item_real_get_partitions; 92 | item_class->get_features = gdu_item_real_get_features; 93 | item_class->changed = gdu_item_real_changed; 94 | 95 | signals [CHANGED] = 96 | g_signal_new ("changed", 97 | G_TYPE_FROM_CLASS (klass), 98 | G_SIGNAL_RUN_LAST, 99 | 0, NULL, NULL, NULL, 100 | G_TYPE_NONE, 0); 101 | } 102 | 103 | static void 104 | gdu_item_init (GduItem *self) 105 | { 106 | } 107 | 108 | const char * 109 | gdu_item_get_description (GduItem *self) 110 | { 111 | g_return_val_if_fail (GDU_IS_ITEM (self), NULL); 112 | 113 | return GDU_ITEM_GET_CLASS (self)->get_description (self); 114 | } 115 | 116 | const char * 117 | gdu_item_get_partition_type (GduItem *self) 118 | { 119 | g_return_val_if_fail (GDU_IS_ITEM (self), NULL); 120 | 121 | return GDU_ITEM_GET_CLASS (self)->get_partition_type (self); 122 | } 123 | 124 | GIcon * 125 | gdu_item_get_icon (GduItem *self) 126 | { 127 | g_return_val_if_fail (GDU_IS_ITEM (self), NULL); 128 | 129 | return GDU_ITEM_GET_CLASS (self)->get_icon (self); 130 | } 131 | 132 | guint64 133 | gdu_item_get_size (GduItem *self) 134 | { 135 | g_return_val_if_fail (GDU_IS_ITEM (self), 0); 136 | 137 | return GDU_ITEM_GET_CLASS (self)->get_size (self); 138 | } 139 | 140 | GduItem * 141 | gdu_item_get_parent (GduItem *self) 142 | { 143 | g_return_val_if_fail (GDU_IS_ITEM (self), NULL); 144 | 145 | return GDU_ITEM_GET_CLASS (self)->get_parent (self); 146 | } 147 | 148 | GListModel * 149 | gdu_item_get_partitions (GduItem *self) 150 | { 151 | g_return_val_if_fail (GDU_IS_ITEM (self), NULL); 152 | 153 | return GDU_ITEM_GET_CLASS (self)->get_partitions (self); 154 | } 155 | 156 | GduFeature 157 | gdu_item_get_features (GduItem *self) 158 | { 159 | g_return_val_if_fail (GDU_IS_ITEM (self), GDU_FEATURE_NONE); 160 | 161 | return GDU_ITEM_GET_CLASS (self)->get_features (self); 162 | } 163 | 164 | void 165 | gdu_item_changed (GduItem *self) 166 | { 167 | GDU_ITEM_GET_CLASS (self)->changed (self); 168 | } 169 | -------------------------------------------------------------------------------- /src/disks/ui/erase-multiple-disks-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | False 6 | 5 7 | Erase Multiple Disks 8 | False 9 | True 10 | dialog 11 | 12 | 13 | False 14 | vertical 15 | 2 16 | 17 | 18 | False 19 | end 20 | 21 | 22 | gtk-cancel 23 | True 24 | True 25 | True 26 | True 27 | 28 | 29 | 30 | 31 | _Erase… 32 | True 33 | True 34 | True 35 | True 36 | True 37 | 38 | 39 | 40 | 41 | 42 | 43 | True 44 | False 45 | 10 46 | 10 47 | 48 | 49 | True 50 | False 51 | 1 52 | Erase _Type 53 | True 54 | erase-combobox 55 | 58 | 59 | 60 | 0 61 | 0 62 | 1 63 | 1 64 | 65 | 66 | 67 | 68 | True 69 | False 70 | 0 71 | 72 | 73 | 1 74 | 0 75 | 1 76 | 1 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | button1 85 | button2 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/disks/gdu-create-password-page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include "gdutypes.h" 13 | 14 | #include 15 | 16 | G_BEGIN_DECLS 17 | 18 | #define GDU_TYPE_CREATE_PASSWORD_PAGE gdu_create_password_page_get_type () 19 | G_DECLARE_FINAL_TYPE (GduCreatePasswordPage, gdu_create_password_page, GDU, CREATE_PASSWORD_PAGE, AdwBin) 20 | 21 | GduCreatePasswordPage *gdu_create_password_page_new (void); 22 | 23 | const gchar * gdu_create_password_page_get_password (GduCreatePasswordPage *page); 24 | 25 | G_END_DECLS 26 | 27 | static const gchar * 28 | pw_error_hint (gint error) 29 | { 30 | switch (error) 31 | { 32 | case PWQ_ERROR_CASE_CHANGES_ONLY: 33 | return C_("Password hint", "Try changing some letters and numbers."); 34 | case PWQ_ERROR_TOO_SIMILAR: 35 | return C_("Password hint", "Try changing the password a bit more."); 36 | case PWQ_ERROR_BAD_WORDS: 37 | return C_("Password hint", "Try to avoid some of the words included in the password."); 38 | case PWQ_ERROR_ROTATED: 39 | return C_("Password hint", "Try changing the password a bit more."); 40 | case PWQ_ERROR_CRACKLIB_CHECK: 41 | return C_("Password hint", "Try to avoid common words."); 42 | case PWQ_ERROR_PALINDROME: 43 | return C_("Password hint", "Try to avoid reordering existing words."); 44 | case PWQ_ERROR_MIN_DIGITS: 45 | return C_("Password hint", "Try to use more numbers."); 46 | case PWQ_ERROR_MIN_UPPERS: 47 | return C_("Password hint", "Try to use more uppercase letters."); 48 | case PWQ_ERROR_MIN_LOWERS: 49 | return C_("Password hint", "Try to use more lowercase letters."); 50 | case PWQ_ERROR_MIN_OTHERS: 51 | return C_("Password hint", "Try to use more special characters, like punctuation."); 52 | case PWQ_ERROR_MIN_CLASSES: 53 | return C_("Password hint", "Try to use a mixture of letters, numbers and punctuation."); 54 | case PWQ_ERROR_MAX_CONSECUTIVE: 55 | return C_("Password hint", "Try to avoid repeating the same character."); 56 | case PWQ_ERROR_MAX_CLASS_REPEAT: 57 | return C_("Password hint", "Try to avoid repeating the same type of character: you need to mix up letters, numbers and punctuation."); 58 | case PWQ_ERROR_MAX_SEQUENCE: 59 | return C_("Password hint", "Try to avoid sequences like 1234 or abcd."); 60 | case PWQ_ERROR_EMPTY_PASSWORD: 61 | return C_("Password hint", "Mix uppercase and lowercase and try to use a number or two."); 62 | default: 63 | return C_("Password hint", "Adding more letters, numbers and punctuation will make the password stronger."); 64 | } 65 | } 66 | 67 | static pwquality_settings_t * 68 | get_pwq (void) 69 | { 70 | static pwquality_settings_t *settings = NULL; 71 | 72 | if (settings == NULL) 73 | { 74 | gchar *err = NULL; 75 | settings = pwquality_default_settings (); 76 | if (pwquality_read_config (settings, NULL, (gpointer)&err) < 0) 77 | { 78 | g_error ("Failed to read pwquality configuration: %s\n", err); 79 | } 80 | } 81 | 82 | return settings; 83 | } 84 | 85 | static gdouble 86 | pw_strength (const gchar *password, 87 | const gchar **hint, 88 | gint *strength_level) 89 | { 90 | gint rv, level, length = 0; 91 | gdouble strength = 0.0; 92 | void *auxerror; 93 | 94 | rv = pwquality_check (get_pwq (), 95 | password, 96 | NULL, /* old_password */ 97 | NULL, /* username */ 98 | &auxerror); 99 | 100 | if (password != NULL) 101 | length = strlen (password); 102 | 103 | strength = CLAMP (0.01 * rv, 0.0, 1.0); 104 | if (rv < 0) { 105 | level = (length > 0) ? 1 : 0; 106 | } else if (strength < 0.50) { 107 | level = 2; 108 | } else if (strength < 0.75) { 109 | level = 3; 110 | } else if (strength < 0.90) { 111 | level = 4; 112 | } else { 113 | level = 5; 114 | } 115 | 116 | 117 | *hint = pw_error_hint (rv); 118 | 119 | if (strength_level) 120 | *strength_level = level; 121 | 122 | return strength; 123 | } 124 | -------------------------------------------------------------------------------- /src/disks/estimator.rs: -------------------------------------------------------------------------------- 1 | use glib::Object; 2 | use gtk::glib; 3 | use gtk::prelude::*; 4 | use gtk::subclass::prelude::*; 5 | 6 | const MAX_SAMPLES: usize = 50; 7 | 8 | #[derive(Debug, Default, Clone, Copy)] 9 | pub struct Sample { 10 | pub time_usec: u64, 11 | pub value: u64, 12 | } 13 | 14 | mod imp { 15 | use std::cell::{Cell, RefCell}; 16 | 17 | use gtk::glib::ffi::G_USEC_PER_SEC; 18 | use itertools::Itertools; 19 | 20 | use super::*; 21 | 22 | #[derive(Debug, glib::Properties)] 23 | #[properties(wrapper_type = super::Estimator)] 24 | pub struct GduEstimator { 25 | #[property(get, construct_only)] 26 | target_bytes: Cell, 27 | #[property(get)] 28 | completed_bytes: Cell, 29 | #[property(get)] 30 | bytes_per_sec: Cell, 31 | #[property(get)] 32 | usec_remaining: Cell, 33 | samples: RefCell>, 34 | } 35 | 36 | impl Default for GduEstimator { 37 | fn default() -> Self { 38 | Self { 39 | target_bytes: Default::default(), 40 | completed_bytes: Default::default(), 41 | bytes_per_sec: Default::default(), 42 | usec_remaining: Default::default(), 43 | samples: RefCell::new(Vec::with_capacity(MAX_SAMPLES)), 44 | } 45 | } 46 | } 47 | 48 | #[glib::object_subclass] 49 | impl ObjectSubclass for GduEstimator { 50 | const NAME: &'static str = "GduEstimator"; 51 | type Type = super::Estimator; 52 | } 53 | 54 | #[glib::derived_properties] 55 | impl ObjectImpl for GduEstimator {} 56 | 57 | impl GduEstimator { 58 | pub fn add_sample(&self, completed_bytes: u64) { 59 | if completed_bytes >= self.completed_bytes.get() { 60 | return; 61 | } 62 | self.completed_bytes.set(completed_bytes); 63 | let mut samples = self.samples.borrow_mut(); 64 | if samples.len() == MAX_SAMPLES { 65 | samples.rotate_left(1); 66 | samples.pop(); 67 | } 68 | samples.push(Sample { 69 | time_usec: std::time::SystemTime::now() 70 | .duration_since(std::time::UNIX_EPOCH) 71 | .expect("`now()` should be after `UNIX_EPOCH`") 72 | .as_secs(), 73 | value: completed_bytes, 74 | }); 75 | self.update(); 76 | } 77 | 78 | fn update(&self) { 79 | let (num_speeds, sum_of_speeds) = self.samples.borrow().iter().tuple_windows().fold( 80 | (0, 0.0), 81 | |(num_speeds, sum_of_speeds), (a, b)| { 82 | let speed = (b.value - a.value) as f64 83 | / ((b.time_usec - a.time_usec) as f64 / glib::ffi::G_USEC_PER_SEC as f64); 84 | (num_speeds + 1, sum_of_speeds + speed) 85 | }, 86 | ); 87 | 88 | self.bytes_per_sec.set(0); 89 | self.usec_remaining.set(0); 90 | if num_speeds > 0 { 91 | let speed = (sum_of_speeds / num_speeds as f64) as u64; 92 | self.bytes_per_sec.set(speed); 93 | if speed > 0 { 94 | let remaining_bytes = self.target_bytes.get() - self.completed_bytes.get(); 95 | self.usec_remaining 96 | .set(G_USEC_PER_SEC as u64 * remaining_bytes / self.bytes_per_sec.get()); 97 | } 98 | } 99 | 100 | { 101 | // freezes notifications until the guard is dropped at the end of the scope 102 | let _notify_guard = self.obj().freeze_notify(); 103 | self.obj().notify("bytes-per-sec"); 104 | self.obj().notify("usec-remaining"); 105 | } 106 | } 107 | } 108 | } 109 | 110 | glib::wrapper! { 111 | pub struct Estimator(ObjectSubclass); 112 | } 113 | impl Estimator { 114 | pub fn new(target_bytes: u64) -> Self { 115 | Object::builder() 116 | .property("target-bytes", target_bytes) 117 | .build() 118 | } 119 | } 120 | impl Estimator { 121 | pub fn add_sample(&self, completed_bytes: u64) { 122 | self.imp().add_sample(completed_bytes); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /data/icons/hicolor/scalable/apps/org.gnome.DiskUtility-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | image/svg+xml 9 | 10 | Gnome Symbolic Icon Theme 11 | 12 | 13 | 14 | 15 | 16 | 17 | Gnome Symbolic Icon Theme 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /doc/man/gnome-disks.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | gnome-disk-utility 4 | March 2013 5 | GNOME 6 | 7 | 8 | 9 | gnome-disks 10 | the GNOME Disks application 11 | 12 | 13 | SYNOPSIS 14 | 15 | gnome-disks 16 | OPTIONS 17 | 18 | 19 | 20 | DESCRIPTION 21 | 22 | gnome-disks is the command to launch the 23 | GNOME Disks application. Disks provides a way to inspect, 24 | format, partition and configure disks and block devices. 25 | 26 | 27 | The Disks application is 28 | single-instance. What this means is that if 29 | the application is not already running when the 30 | gnome-disks command is invoked, it will get 31 | launched and the command invocation will block until the 32 | application exits. Otherwise the existing application instance 33 | will be used and the gnome-disks command will 34 | exit immediately. 35 | 36 | 37 | 38 | OPTIONS 39 | 40 | The following options are understood: 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Switches to the Disks application and selects the block 49 | device given by DEVICE (for 50 | example, /dev/sda). 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Shows the “Format Volume” dialog for the block device 64 | given by DEVICE (for example, 65 | /dev/sdb1). If 66 | WINDOW-ID is given, makes the 67 | dialog transient to the given XID. 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Shows the “Restore Disk Image” dialog for the file given 79 | by FILE (for example, 80 | /home/user/Downloads/SuperOS.iso) and 81 | prompts the user to choose a disk to restore the image 82 | unto. 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | Prints a short help text and exits. 92 | 93 | 94 | 95 | 96 | 97 | 98 | AUTHOR 99 | 100 | Written by David Zeuthen zeuthen@gmail.com with 101 | a lot of help from many others. 102 | 103 | 104 | 105 | 106 | BUGS 107 | 108 | Please send bug reports to either the distribution bug tracker 109 | or the upstream bug tracker at 110 | . 111 | 112 | 113 | 114 | 115 | SEE ALSO 116 | 117 | gnome-disk-image-mounter1, 118 | udisks8 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-restore-disk-image-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 93 | 94 | -------------------------------------------------------------------------------- /flatpak/polkit-build-Add-option-to-build-without-polkitd.patch: -------------------------------------------------------------------------------- 1 | From 1073a44277316348d40d86ecec908f1d4812f360 Mon Sep 17 00:00:00 2001 2 | From: Christian Hergert 3 | Date: Mon, 27 May 2019 11:49:09 -0700 4 | Subject: [PATCH] flatpak: make polkit suitable for use within flatpak 5 | 6 | This is based on patches from Patrick Griffis with additional fixes 7 | to allow us to disable use of PAM within Flaptak. 8 | --- 9 | configure.ac | 20 ++++++++++++++++---- 10 | src/Makefile.am | 6 +++++- 11 | src/polkitagent/Makefile.am | 5 +++++ 12 | test/Makefile.am | 6 +++++- 13 | 4 files changed, 31 insertions(+), 6 deletions(-) 14 | 15 | diff --git a/configure.ac b/configure.ac 16 | index 5cedb4e..729d78d 100644 17 | --- a/configure.ac 18 | +++ b/configure.ac 19 | @@ -79,11 +79,13 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0]) 20 | AC_SUBST(GLIB_CFLAGS) 21 | AC_SUBST(GLIB_LIBS) 22 | 23 | -PKG_CHECK_MODULES(LIBJS, [mozjs-60]) 24 | +AS_IF([test x${enable_polkitd} = yes], [ 25 | + PKG_CHECK_MODULES(LIBJS, [mozjs-60]) 26 | 27 | -AC_SUBST(LIBJS_CFLAGS) 28 | -AC_SUBST(LIBJS_CXXFLAGS) 29 | -AC_SUBST(LIBJS_LIBS) 30 | + AC_SUBST(LIBJS_CFLAGS) 31 | + AC_SUBST(LIBJS_CXXFLAGS) 32 | + AC_SUBST(LIBJS_LIBS) 33 | +]) 34 | 35 | EXPAT_LIB="" 36 | AC_ARG_WITH(expat, [ --with-expat= Use expat from here], 37 | @@ -236,6 +238,15 @@ if test "x$with_systemdsystemunitdir" != "xno"; then 38 | fi 39 | AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir"]) 40 | 41 | +dnl --------------------------------------------------------------------------- 42 | +dnl - Disable polkitd when using library alone 43 | +dnl --------------------------------------------------------------------------- 44 | + 45 | +AC_ARG_ENABLE([polkitd], 46 | + [AS_HELP_STRING([--disable-polkitd], [Do not build polkitd])], 47 | + [enable_polkitd=$enableval], [enable_polkitd=yes]) 48 | +AM_CONDITIONAL(BUILD_POLKITD, [test x${enable_polkitd} = yes]) 49 | + 50 | dnl --------------------------------------------------------------------------- 51 | dnl - User for running polkitd 52 | dnl --------------------------------------------------------------------------- 53 | @@ -579,6 +590,7 @@ echo " 54 | Session tracking: ${SESSION_TRACKING} 55 | PAM support: ${have_pam} 56 | systemdsystemunitdir: ${systemdsystemunitdir} 57 | + polkitd: ${enable_polkitd} 58 | polkitd user: ${POLKITD_USER}" 59 | 60 | if test "$have_pam" = yes ; then 61 | diff --git a/src/Makefile.am b/src/Makefile.am 62 | index 09fc7b3..c6fe91b 100644 63 | --- a/src/Makefile.am 64 | +++ b/src/Makefile.am 65 | @@ -1,5 +1,9 @@ 66 | 67 | -SUBDIRS = polkit polkitbackend polkitagent programs 68 | +SUBDIRS = polkit polkitagent programs 69 | + 70 | +if BUILD_POLKITD 71 | +SUBDIRS += polkitbackend 72 | +endif 73 | 74 | if BUILD_EXAMPLES 75 | SUBDIRS += examples 76 | diff --git a/src/polkitagent/Makefile.am b/src/polkitagent/Makefile.am 77 | index 49720db..633f9d4 100644 78 | --- a/src/polkitagent/Makefile.am 79 | +++ b/src/polkitagent/Makefile.am 80 | @@ -79,6 +79,7 @@ libpolkit_agent_1_la_LIBADD = \ 81 | 82 | libpolkit_agent_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)' 83 | 84 | +if !POLKIT_AUTHFW_NONE 85 | libprivdir = $(prefix)/lib/polkit-1 86 | libpriv_PROGRAMS = polkit-agent-helper-1 87 | 88 | @@ -113,6 +114,8 @@ polkit_agent_helper_1_LDFLAGS = \ 89 | $(AM_LDFLAGS) \ 90 | $(NULL) 91 | 92 | +endif # !POLKIT_AUTHFW_NONE 93 | + 94 | if HAVE_INTROSPECTION 95 | 96 | girdir = $(INTROSPECTION_GIRDIR) 97 | @@ -142,6 +145,7 @@ include $(INTROSPECTION_MAKEFILE) 98 | 99 | endif # HAVE_INTROSPECTION 100 | 101 | +if !POLKIT_AUTHFW_NONE 102 | # polkit-agent-helper-1 need to be setuid root because it's used to 103 | # authenticate not only the invoking user, but possibly also root 104 | # and/or other users. 105 | @@ -149,6 +153,7 @@ endif # HAVE_INTROSPECTION 106 | install-data-hook: 107 | -chown root $(DESTDIR)$(libprivdir)/polkit-agent-helper-1 108 | -chmod 4755 $(DESTDIR)$(libprivdir)/polkit-agent-helper-1 109 | +endif # !POLKIT_AUTHFW_NONE 110 | 111 | EXTRA_DIST = polkitagentmarshal.list polkitagentenumtypes.h.template polkitagentenumtypes.c.template 112 | CLEANFILES = $(gir_DATA) $(typelibs_DATA) 113 | diff --git a/test/Makefile.am b/test/Makefile.am 114 | index 59d0680..d43b0fe 100644 115 | --- a/test/Makefile.am 116 | +++ b/test/Makefile.am 117 | @@ -1,7 +1,11 @@ 118 | 119 | -SUBDIRS = mocklibc . polkit polkitbackend 120 | +SUBDIRS = mocklibc . polkit 121 | AM_CFLAGS = $(GLIB_CFLAGS) 122 | 123 | +if BUILD_POLKITD 124 | +SUBDIRS += polkitbackend 125 | +endif 126 | + 127 | noinst_LTLIBRARIES = libpolkit-test-helper.la 128 | libpolkit_test_helper_la_SOURCES = polkittesthelper.c polkittesthelper.h 129 | libpolkit_test_helper_la_LIBADD = $(GLIB_LIBS) 130 | -- 131 | 2.21.0 132 | 133 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-encryption-options-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 93 | 94 | -------------------------------------------------------------------------------- /HACKING: -------------------------------------------------------------------------------- 1 | 2 | gnome-disk-utility development happens at in the GNOME git repository 3 | 4 | https://gitlab.gnome.org/GNOME/gnome-disk-utility 5 | 6 | Send feedback and/or file bugs in the GNOME GitLab instance at 7 | 8 | https://gitlab.gnome.org/GNOME/gnome-disk-utility/issues 9 | 10 | COMMIT MESSAGES 11 | =============== 12 | 13 | - Commit messages should be of the form (the five lines between the 14 | lines starting with ===) 15 | 16 | === begin example commit === 17 | Short explanation of the commit 18 | 19 | Longer explanation explaining exactly what's changed, whether any 20 | external or private interfaces changed, what bugs were fixed (with bug 21 | tracker reference if applicable) and so forth. Be concise but not too brief. 22 | === end example commit === 23 | 24 | - Always add a brief description of the commit to the _first_ line of 25 | the commit and terminate by two newlines (it will work without the 26 | second newline, but that is not nice for the interfaces). 27 | 28 | - First line (the brief description) must only be one sentence and 29 | must start with a capital letter. Don't use a trailing period 30 | either. Don't exceed 72 characters. 31 | 32 | - The main description (the body) is normal prose and should use normal 33 | punctuation and capital letters where appropriate. Normally, for patches 34 | sent to a mailing list it's copied from there. 35 | 36 | - When committing code on behalf of others use the --author option, e.g. 37 | git commit -a --author "Joe Coder " and --signoff. 38 | 39 | TERMINOLOGY 40 | =========== 41 | 42 | Dealing with and managing storage devices often involves a lot of 43 | techno-babble that only advanced computer-litterate users are familiar 44 | with. The goal of the gnome-disk-utility project is two-fold 45 | 46 | 1. To provide plug-ins and programs that enhance the core GNOME desktop 47 | experience for dealing with and managing storage devices 48 | - Simple formatting tool 49 | - GIO/GVfs volume monitor 50 | - Notification icon displayed when a device is failing 51 | 52 | 2. To provide a simple yet powerful disk utility app (Palimpsest) 53 | suitable for both every-day use (formatting/configuring a USB stick), 54 | intermediate use (setting up RAID, checking disk health) and also 55 | capable enough to be useful for things like configuring storage when 56 | installing the OS. 57 | 58 | In a nutshell, the audience is different for 1. and 2. The audience 59 | for the former includes all GNOME users while the audience for the 60 | latter mostly includes system administrators and enthusiasts. As such 61 | different terminology is used. 62 | 63 | In Palimpsest the following terminology is used 64 | 65 | - Partition/Partition Table 66 | - Avoid using terms that are used for other concepts; e.g. 67 | use "Partition Label" instead of "Label" 68 | 69 | - Filesystem 70 | - Use the spelling "Filesystem" 71 | - http://en.wiktionary.org/wiki/filesystem 72 | - Use the word "Label" when referring to a filesystem label 73 | - Generally refer to a filesystem by it's label 74 | - Don't show/reference the UUID (might be shown in a "Details" dialog) 75 | 76 | - Disk: Only to be used when referring to the entirety of a 77 | device; e.g. avoid using it for individual things 78 | like a partition. 79 | 80 | - Media: Only to be used on disks with removable media and 81 | preferably only when media is missing. Media in 82 | optical drives should be referred to as "Disc". 83 | 84 | - Array/Component: Use these terms when dealing with RAID. 85 | 86 | - Device: A generic catch all word that simply is short for "Block 87 | Device". It should only be used when any of the above 88 | terms are not suitable. 89 | 90 | - In particular avoid words like "Drive" and "Volume". 91 | 92 | - Power-of-ten ("1 MB" = 1,000,000 bytes), power-of-two ("1 MiB" = 1,048,576 93 | bytes) and the raw size, e.g. "1,048,576 bytes" should be used to classify 94 | sizes. If space it tight, use MB, not MiB or the full size. 95 | 96 | In the plug-ins/programs a simpler terminology is to be used 97 | 98 | - Volume: Something that contains data 99 | 100 | - Drive: A drive is a container of volumes 101 | 102 | - Media: Only to be used on disks with removable media and 103 | preferably only when media is missing. Media in 104 | optical drives should be referred to as "Disc". 105 | 106 | - In general terms like "mounting" and "unmounting" should be 107 | avoided. The word (and icon) "Eject" should be used in scenarios 108 | where the user wants to remove the device. Mounting a device 109 | should happen on insertion and/or when the user tries to access 110 | the device. 111 | 112 | - Only power-of-ten ("1 MB" = 1,000,000 bytes) should be used to classify 113 | sizes of devices. 114 | 115 | - Avoid words like: Device, File system, Partition, Partition Table, Array, 116 | Component, Label, UUID 117 | 118 | CODING STYLE 119 | ============ 120 | 121 | TODO: write me 122 | -------------------------------------------------------------------------------- /src/disks/ui/shortcuts-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | General 7 | 8 | 9 | Help 10 | F1 11 | 12 | 13 | 14 | 15 | Open the application menu 16 | F10 17 | 18 | 19 | 20 | 21 | Keyboard shortcuts 22 | <Primary>question 23 | 24 | 25 | 26 | 27 | Quit 28 | <Primary>q 29 | 30 | 31 | 32 | 33 | 34 | 35 | Disks 36 | 37 | 38 | Create a new empty disk image 39 | <Primary>n 40 | 41 | 42 | 43 | 44 | Attach an existing disk image 45 | <Primary>a 46 | 47 | 48 | 49 | 50 | Unselect current disk 51 | Escape 52 | 53 | 54 | 55 | 56 | 57 | 58 | Drive 59 | 60 | 61 | Open the drive menu 62 | F9 63 | 64 | 65 | 66 | 67 | Format the drive 68 | <Primary>d 69 | 70 | 71 | 72 | 73 | Restore an image to the disk 74 | <Primary>r 75 | 76 | 77 | 78 | 79 | SMART data 80 | <Primary>s 81 | 82 | 83 | 84 | 85 | Drive settings 86 | <Primary>e 87 | 88 | 89 | 90 | 91 | 92 | 93 | Partition 94 | 95 | 96 | Open the volume menu 97 | <Shift>F9 98 | 99 | 100 | 101 | 102 | Format the selected volume 103 | <Primary>p 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-create-partition-page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 107 | 108 | -------------------------------------------------------------------------------- /src/disks/gdu-edit-filesystem-dialog.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2013 Red Hat, Inc. 3 | * Copyright (C) 2022 Purism SPC 4 | * 5 | * Licensed under GPL version 2 or later. 6 | * 7 | * Author(s): 8 | * David Zeuthen 9 | * Mohammed Sadiq 10 | */ 11 | 12 | #include "config.h" 13 | 14 | #include 15 | 16 | #include "gduutils.h" 17 | #include "gdu-edit-filesystem-dialog.h" 18 | 19 | struct _GduEditFilesystemDialog 20 | { 21 | AdwDialog parent_instance; 22 | 23 | GtkWidget *change_button; 24 | GtkWidget *warning_banner; 25 | GtkWidget *fs_label_row; 26 | 27 | GduBlock *drive_block; 28 | }; 29 | 30 | G_DEFINE_TYPE (GduEditFilesystemDialog, gdu_edit_filesystem_dialog, ADW_TYPE_DIALOG) 31 | 32 | static gpointer 33 | gdu_edit_filesystem_dialog_get_window (GduEditFilesystemDialog *self) 34 | { 35 | return gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW); 36 | } 37 | 38 | static void 39 | change_filesystem_label_cb (GObject *object, 40 | GAsyncResult *result, 41 | gpointer user_data) 42 | { 43 | g_autoptr(GduEditFilesystemDialog) self = user_data; 44 | g_autoptr(GError) error = NULL; 45 | 46 | g_assert (GDU_IS_EDIT_FILESYSTEM_DIALOG (self)); 47 | 48 | if (!gdu_block_set_fs_label_finish (self->drive_block, result, &error)) 49 | { 50 | gdu_utils_show_error (gdu_edit_filesystem_dialog_get_window (self), 51 | _("Error setting label"), 52 | error); 53 | } 54 | 55 | adw_dialog_close (ADW_DIALOG (self)); 56 | } 57 | 58 | static void 59 | on_change_button_clicked (GduEditFilesystemDialog *self) 60 | { 61 | const char *label; 62 | 63 | label = gtk_editable_get_text (GTK_EDITABLE (self->fs_label_row)); 64 | 65 | gdu_block_set_fs_label_async (self->drive_block, 66 | label, 67 | change_filesystem_label_cb, 68 | g_object_ref (self)); 69 | } 70 | 71 | static void 72 | on_fs_label_row_changed_cb (GduEditFilesystemDialog *self) 73 | { 74 | g_assert (GDU_IS_EDIT_FILESYSTEM_DIALOG (self)); 75 | 76 | if (g_strcmp0 (gtk_editable_get_text (GTK_EDITABLE (self->fs_label_row)), 77 | gdu_block_get_fs_label (self->drive_block)) == 0) 78 | { 79 | gtk_widget_add_css_class (GTK_WIDGET (self->fs_label_row), "error"); 80 | gtk_widget_set_sensitive (GTK_WIDGET (self->change_button), FALSE); 81 | /* gtk4 todo: Notify the user that the label is the same as the current one */ 82 | } 83 | else 84 | { 85 | gtk_widget_remove_css_class (GTK_WIDGET (self->fs_label_row), "error"); 86 | gtk_widget_set_sensitive (GTK_WIDGET (self->change_button), TRUE); 87 | } 88 | } 89 | 90 | static void 91 | gdu_edit_filesystem_dialog_finalize (GObject *object) 92 | { 93 | GduEditFilesystemDialog *self = (GduEditFilesystemDialog *)object; 94 | 95 | g_clear_object (&self->drive_block); 96 | 97 | G_OBJECT_CLASS (gdu_edit_filesystem_dialog_parent_class)->finalize (object); 98 | } 99 | 100 | static void 101 | gdu_edit_filesystem_dialog_class_init (GduEditFilesystemDialogClass *klass) 102 | { 103 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); 104 | GObjectClass *object_class = G_OBJECT_CLASS (klass); 105 | 106 | object_class->finalize = gdu_edit_filesystem_dialog_finalize; 107 | 108 | gtk_widget_class_set_template_from_resource (widget_class, 109 | "/org/gnome/DiskUtility/ui/" 110 | "gdu-edit-filesystem-dialog.ui"); 111 | 112 | gtk_widget_class_bind_template_child (widget_class, GduEditFilesystemDialog, change_button); 113 | gtk_widget_class_bind_template_child (widget_class, GduEditFilesystemDialog, warning_banner); 114 | gtk_widget_class_bind_template_child (widget_class, GduEditFilesystemDialog, fs_label_row); 115 | 116 | gtk_widget_class_bind_template_callback (widget_class, on_change_button_clicked); 117 | gtk_widget_class_bind_template_callback (widget_class, on_fs_label_row_changed_cb); 118 | } 119 | 120 | static void 121 | gdu_edit_filesystem_dialog_init (GduEditFilesystemDialog *self) 122 | { 123 | gtk_widget_init_template (GTK_WIDGET (self)); 124 | } 125 | 126 | void 127 | gdu_edit_filesystem_dialog_show (GtkWindow *parent_window, 128 | GduBlock *block) 129 | { 130 | GduEditFilesystemDialog *self; 131 | guint max_len; 132 | GtkText *text; 133 | const char *label; 134 | const char *fs_type; 135 | 136 | g_return_if_fail (GDU_IS_BLOCK (block)); 137 | 138 | self = g_object_new (GDU_TYPE_EDIT_FILESYSTEM_DIALOG, NULL); 139 | 140 | self->drive_block = block; 141 | 142 | label = gdu_block_get_fs_label (self->drive_block); 143 | fs_type = gdu_block_get_fs_type (self->drive_block); 144 | max_len = gdu_utils_get_max_label_length (fs_type); 145 | 146 | gtk_editable_set_text (GTK_EDITABLE (self->fs_label_row), label); 147 | text = GTK_TEXT (gtk_editable_get_delegate ( GTK_EDITABLE (self->fs_label_row))); 148 | gtk_text_set_max_length (text, max_len); 149 | 150 | adw_banner_set_revealed (ADW_BANNER (self->warning_banner), 151 | gdu_block_needs_unmount (self->drive_block)); 152 | 153 | adw_dialog_present (ADW_DIALOG (self), GTK_WIDGET (parent_window)); 154 | } 155 | -------------------------------------------------------------------------------- /src/disks/gdu-create-password-page.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Kai Lüke 3 | * 4 | * Licensed under GPL version 2 or later. 5 | * 6 | * Author: Kai Lüke 7 | */ 8 | 9 | #include "config.h" 10 | 11 | #include 12 | 13 | #include "gdu-create-password-page.h" 14 | 15 | enum 16 | { 17 | PROP_0, 18 | PROP_COMPLETE 19 | }; 20 | 21 | struct _GduCreatePasswordPage 22 | { 23 | AdwBin parent_instance; 24 | 25 | GtkWidget *password_entry; 26 | GtkWidget *confirm_password_entry; 27 | GtkWidget *strength_indicator; 28 | GtkWidget *confirm_password_label; 29 | GtkWidget *strength_hint_label; 30 | 31 | gboolean complete; 32 | }; 33 | 34 | G_DEFINE_TYPE (GduCreatePasswordPage, gdu_create_password_page, ADW_TYPE_BIN); 35 | 36 | const gchar * 37 | gdu_create_password_page_get_password (GduCreatePasswordPage *self) 38 | { 39 | return gtk_editable_get_text (GTK_EDITABLE (self->password_entry)); 40 | } 41 | 42 | static void 43 | update_password_strength (GduCreatePasswordPage *self) 44 | { 45 | gint strength_level; 46 | const gchar *hint; 47 | const gchar *password; 48 | const gchar *verify; 49 | 50 | password = gtk_editable_get_text (GTK_EDITABLE (self->password_entry)); 51 | 52 | pw_strength (password, &hint, &strength_level); 53 | 54 | gtk_level_bar_set_value (GTK_LEVEL_BAR (self->strength_indicator), strength_level); 55 | gtk_label_set_label (GTK_LABEL (self->strength_hint_label), hint); 56 | 57 | if (strength_level > 0) 58 | { 59 | gtk_widget_remove_css_class (self->password_entry, "error"); 60 | } 61 | else 62 | { 63 | gtk_widget_add_css_class (self->password_entry, "error"); 64 | } 65 | 66 | verify = gtk_editable_get_text (GTK_EDITABLE (self->confirm_password_entry)); 67 | if (strlen (verify) == 0) 68 | { 69 | gtk_widget_set_sensitive (self->confirm_password_entry, strength_level > 0); 70 | } 71 | } 72 | 73 | static void 74 | on_password_changed (GduCreatePasswordPage *self) 75 | { 76 | gboolean can_proceed = FALSE; 77 | const gchar *password = NULL; 78 | const gchar *verify = NULL; 79 | 80 | password = gtk_editable_get_text (GTK_EDITABLE (self->password_entry)); 81 | verify = gtk_editable_get_text (GTK_EDITABLE (self->confirm_password_entry)); 82 | 83 | gtk_widget_add_css_class (self->password_entry, "error"); 84 | 85 | if (strlen (password) > 0) 86 | { 87 | if (g_strcmp0 (password, verify) == 0) 88 | { 89 | gtk_widget_remove_css_class (self->confirm_password_entry, "error"); 90 | gtk_widget_set_visible (self->confirm_password_label, FALSE); 91 | can_proceed = TRUE; 92 | } 93 | else if (strlen (verify) > 0) 94 | { 95 | gtk_widget_add_css_class (self->confirm_password_entry, "error"); 96 | gtk_widget_set_visible (self->confirm_password_label, TRUE); 97 | } 98 | } 99 | update_password_strength (self); 100 | 101 | self->complete = can_proceed; 102 | g_object_notify (G_OBJECT (self), "complete"); 103 | } 104 | 105 | static void 106 | gdu_create_password_page_get_property (GObject *object, 107 | guint property_id, 108 | GValue *value, 109 | GParamSpec *pspec) 110 | { 111 | GduCreatePasswordPage *self = GDU_CREATE_PASSWORD_PAGE (object); 112 | 113 | switch (property_id) 114 | { 115 | case PROP_COMPLETE: 116 | g_value_set_boolean (value, self->complete); 117 | break; 118 | 119 | default: 120 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); 121 | break; 122 | } 123 | } 124 | 125 | static void 126 | gdu_create_password_page_init (GduCreatePasswordPage *self) 127 | { 128 | gtk_widget_init_template (GTK_WIDGET (self)); 129 | } 130 | 131 | static void 132 | gdu_create_password_page_class_init (GduCreatePasswordPageClass *klass) 133 | { 134 | GObjectClass *object_class = G_OBJECT_CLASS (klass); 135 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); 136 | 137 | object_class->get_property = gdu_create_password_page_get_property; 138 | 139 | gtk_widget_class_set_template_from_resource (widget_class, 140 | "/org/gnome/DiskUtility/ui/" 141 | "gdu-create-password-page.ui"); 142 | 143 | gtk_widget_class_bind_template_child (widget_class, GduCreatePasswordPage, password_entry); 144 | gtk_widget_class_bind_template_child (widget_class, GduCreatePasswordPage, confirm_password_entry); 145 | gtk_widget_class_bind_template_child (widget_class, GduCreatePasswordPage, strength_indicator); 146 | gtk_widget_class_bind_template_child (widget_class, GduCreatePasswordPage, confirm_password_label); 147 | gtk_widget_class_bind_template_child (widget_class, GduCreatePasswordPage, strength_hint_label); 148 | 149 | gtk_widget_class_bind_template_callback (widget_class, on_password_changed); 150 | 151 | g_object_class_install_property (object_class, PROP_COMPLETE, 152 | g_param_spec_boolean ("complete", 153 | NULL, NULL, FALSE, 154 | G_PARAM_READABLE | 155 | G_PARAM_STATIC_STRINGS)); 156 | } 157 | 158 | GduCreatePasswordPage * 159 | gdu_create_password_page_new (void) 160 | { 161 | return g_object_new (GDU_TYPE_CREATE_PASSWORD_PAGE, NULL); 162 | } 163 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-drive-view.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37 | 38 | Drive Information 39 | 480 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Model 54 | True 55 | 56 | 57 | Copy 58 | edit-copy-symbolic 59 | center 60 | 61 | 64 | 65 | 66 | 69 | 70 | 71 | 72 | 73 | Serial 74 | True 75 | 76 | 77 | Copy 78 | edit-copy-symbolic 79 | center 80 | 81 | 84 | 85 | 86 | 89 | 90 | 91 | 92 | 93 | Partitioning 94 | True 95 | 98 | 99 | 100 | 101 | 102 | Size 103 | True 104 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/disks/ui/gdu-change-passphrase-dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 106 | 107 | -------------------------------------------------------------------------------- /data/icons/hicolor/scalable/apps/gnome-disks-state-standby-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | Gnome Symbolic Icon Theme 27 | 28 | 29 | 30 | 62 | 71 | 72 | Gnome Symbolic Icon Theme 74 | 76 | 82 | 87 | Z 98 | Z 109 | Z 120 | 121 | 126 | 131 | 136 | 141 | 146 | 152 | 158 | 159 | --------------------------------------------------------------------------------