Improve icons and branding
diff --git a/src/corrupt.c b/src/corrupt.c
index 00920f5..e044a13 100644
--- a/src/corrupt.c
+++ b/src/corrupt.c
@@ -21,11 +21,9 @@
#include
#include "corrupt.h"
+// The size of this array is how many times the file will be overwritten.
const char* steps[] = {"\x77\x77\x77", "\x76\x76\x76",
- "\x33\x33\x33", "\x35\x35\x35",
- "\x55\x55\x55", "\xAA\xAA\xAA",
- "\x44\x44\x44", "\x55\x55\x55",
- "\x66\x66\x66", "\x77\x77\x77"};
+ "\x33\x33\x33", "\x35\x35\x35", "\x55\x55\x55"};
struct _RaiderCorrupt
{
@@ -47,6 +45,7 @@ uint8_t corrupt_unlink_file(const char *filename);
uint8_t corrupt_unlink_folder(const char *filename);
off_t corrupt_check_file(const char *filename);
static uint8_t corrupt_step(GTask* task, const char* filename, const off_t filesize, const char *pattern, int loop_num);
+void shredding_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable);
static void raider_corrupt_init(RaiderCorrupt *self)
@@ -67,6 +66,17 @@ RaiderCorrupt *raider_corrupt_new(GFile* file, RaiderFileRow* row)
return corrupt;
}
+GCancellable* raider_corrupt_start_shredding(RaiderCorrupt* self, GAsyncReadyCallback func)
+{
+ self->cancel = g_cancellable_new();
+ self->task = g_task_new(self, self->cancel, func, NULL);
+ g_task_set_task_data (self->task, self->row, NULL);
+ g_task_run_in_thread(self->task, shredding_thread);
+ g_object_unref(self->task);
+
+ return self->cancel;
+}
+
void shredding_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable)
{
RaiderCorrupt* corrupt = RAIDER_CORRUPT(source_object);
@@ -84,39 +94,6 @@ void shredding_thread (GTask *task, gpointer source_object, gpointer task_data,
}
}
-GCancellable* raider_corrupt_start_shredding(RaiderCorrupt* self, GAsyncReadyCallback func)
-{
- self->cancel = g_cancellable_new();
- self->task = g_task_new(self, self->cancel, func, NULL);
- g_task_set_task_data (self->task, self->row, NULL);
- g_task_run_in_thread(self->task, shredding_thread);
- g_object_unref(self->task);
-
- return self->cancel;
-}
-
-/* Your standard recursive file listing algorithm. */
-static void list_files(const char *directory, GPtrArray* files) {
- const gchar *file_name;
-
- GDir *dir = g_dir_open(directory, 0, NULL);
- if (dir != NULL) {
- while ((file_name = g_dir_read_name(dir)) != NULL) {
- gchar *file_path = g_build_filename(directory, file_name, NULL);
- // If it is another directory, recurse.
- if (g_file_test(file_path, G_FILE_TEST_IS_DIR)) {
- // Make sure it is not the current or parent directories.
- if (strcmp(file_name, ".") != 0 && strcmp(file_name, "..") != 0) {
- list_files(file_path, files);
- }
- } else {
- g_ptr_array_add(files, file_path);
- }
- }
- g_dir_close(dir);
- }
-}
-
int corrupt_folder(RaiderCorrupt* corrupt)
{
char* folder = g_file_get_path(corrupt->file);
@@ -169,13 +146,13 @@ uint8_t corrupt_file(RaiderCorrupt* corrupt)
raider_file_row_set_progress_num(corrupt->row, corrupt->progress);
g_main_context_invoke (NULL, raider_file_row_set_progress, corrupt->row);
- // Shred the file by overwriting it many times.
off_t filesize = corrupt_check_file(filename);
if (filesize == -1)
{
return -1;
}
+ // Shred the file by overwriting it many times.
uint8_t i;
for (i = 0; i < steps_num; i++)
{
@@ -221,30 +198,6 @@ static uint8_t corrupt_step(GTask* task, const char* filename, const off_t files
return ret;
}
-off_t corrupt_check_file(const char *filename)
-{
- struct stat st;
-
- // Run some checks on the file.
- if(lstat(filename, &st) != 0)
- {
- fprintf(stderr, "corrupt: current file not found\n");
- return -1;
- }
- if (S_ISLNK(st.st_mode) == 1)
- {
- /* Quietly deal with symbolic links. */
- corrupt_unlink_file(filename);
- return -1;
- }
- if (S_ISREG(st.st_mode) == 0)
- {
- fprintf(stderr, "corrupt: current file is not a regular file\n");
- return -1;
- }
- return st.st_size;
-}
-
uint8_t corrupt_unlink_file(const char *filename)
{
uint8_t ret = 0;
@@ -289,3 +242,49 @@ uint8_t corrupt_unlink_folder(const char *directory)
return 0;
}
+
+off_t corrupt_check_file(const char *filename)
+{
+ struct stat st;
+
+ // Run some checks on the file.
+ if(lstat(filename, &st) != 0)
+ {
+ fprintf(stderr, "corrupt: current file not found\n");
+ return -1;
+ }
+ if (S_ISLNK(st.st_mode) == 1)
+ {
+ /* Quietly deal with symbolic links. */
+ corrupt_unlink_file(filename);
+ return -1;
+ }
+ if (S_ISREG(st.st_mode) == 0)
+ {
+ fprintf(stderr, "corrupt: current file is not a regular file\n");
+ return -1;
+ }
+ return st.st_size;
+}
+
+// Standard directory scanner.
+static void list_files(const char *directory, GPtrArray* files) {
+ const gchar *file_name;
+
+ GDir *dir = g_dir_open(directory, 0, NULL);
+ if (dir != NULL) {
+ while ((file_name = g_dir_read_name(dir)) != NULL) {
+ gchar *file_path = g_build_filename(directory, file_name, NULL);
+ // If it is another directory, recurse.
+ if (g_file_test(file_path, G_FILE_TEST_IS_DIR)) {
+ // Make sure it is not the current or parent directories.
+ if (strcmp(file_name, ".") != 0 && strcmp(file_name, "..") != 0) {
+ list_files(file_path, files);
+ }
+ } else {
+ g_ptr_array_add(files, file_path);
+ }
+ }
+ g_dir_close(dir);
+ }
+}
diff --git a/src/raider-file-row.blp b/src/raider-file-row.blp
index 20e9abe..8be3ce1 100644
--- a/src/raider-file-row.blp
+++ b/src/raider-file-row.blp
@@ -1,7 +1,7 @@
using Gtk 4.0;
using Adw 1;
-template RaiderFileRow : Adw.ActionRow {
+template $RaiderFileRow : Adw.ActionRow {
selectable: false;
activatable: true;
diff --git a/src/raider-progress-info-popover.blp b/src/raider-progress-info-popover.blp
index 20b5e09..5e066d2 100644
--- a/src/raider-progress-info-popover.blp
+++ b/src/raider-progress-info-popover.blp
@@ -1,7 +1,7 @@
using Gtk 4.0;
using Adw 1;
-template RaiderProgressInfoPopover : Gtk.Popover {
+template $RaiderProgressInfoPopover : Gtk.Popover {
Gtk.Box popover_box {
Gtk.ProgressBar progress_bar {
show-text: true;
diff --git a/src/raider-progress-info-popover.c b/src/raider-progress-info-popover.c
index a65677d..fdfa319 100644
--- a/src/raider-progress-info-popover.c
+++ b/src/raider-progress-info-popover.c
@@ -53,7 +53,7 @@ void raider_progress_info_popover_set_progress(RaiderProgressInfoPopover *popove
if (percentage == 0)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(popover->progress_bar), _("Starting…"));
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(popover->progress_bar));
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(popover->progress_bar), 1);
}
else if (percentage < 100)
{
@@ -72,6 +72,6 @@ void raider_progress_info_popover_set_progress(RaiderProgressInfoPopover *popove
/* This is used when the spinner is shown instead of the progress icon. */
void raider_progress_info_popover_pulse(RaiderProgressInfoPopover *popover)
{
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(popover->progress_bar), _("Estimating..."));
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(popover->progress_bar), _("Estimating…"));
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(popover->progress_bar));
}
diff --git a/src/raider-window.blp b/src/raider-window.blp
index 230530e..17464c0 100644
--- a/src/raider-window.blp
+++ b/src/raider-window.blp
@@ -1,7 +1,7 @@
using Gtk 4.0;
using Adw 1;
-template RaiderWindow : Adw.ApplicationWindow {
+template $RaiderWindow : Adw.ApplicationWindow {
default-width: 800;
default-height: 600;
width-request: 360;
diff --git a/src/raider-window.c b/src/raider-window.c
index 438252a..9433650 100644
--- a/src/raider-window.c
+++ b/src/raider-window.c
@@ -148,16 +148,15 @@ gboolean raider_window_exit(RaiderWindow *win, gpointer data)
{
if (win->status)
{
- GtkWidget *dialog = adw_message_dialog_new(GTK_WINDOW(win), _("Stop Shredding?"), NULL);
- adw_message_dialog_set_body(ADW_MESSAGE_DIALOG(dialog), _("Are you sure that you want to exit?"));
+ AdwDialog *dialog = adw_alert_dialog_new(_("Stop Shredding?"), _("Are you sure that you want to exit?"));
g_signal_connect(dialog, "response", G_CALLBACK(raider_window_exit_response), win);
- adw_message_dialog_add_responses(ADW_MESSAGE_DIALOG(dialog), "cancel", _("_Cancel"), "exit", _("_Exit"), NULL);
- adw_message_dialog_set_response_appearance(ADW_MESSAGE_DIALOG(dialog), "exit", ADW_RESPONSE_DESTRUCTIVE);
- adw_message_dialog_set_default_response(ADW_MESSAGE_DIALOG(dialog), "cancel");
- adw_message_dialog_set_close_response(ADW_MESSAGE_DIALOG(dialog), "cancel");
+ adw_alert_dialog_add_responses(ADW_ALERT_DIALOG(dialog), "cancel", _("_Cancel"), "exit", _("_Exit"), NULL);
+ adw_alert_dialog_set_response_appearance(ADW_ALERT_DIALOG(dialog), "exit", ADW_RESPONSE_DESTRUCTIVE);
+ adw_alert_dialog_set_default_response(ADW_ALERT_DIALOG(dialog), "cancel");
+ adw_alert_dialog_set_close_response(ADW_ALERT_DIALOG(dialog), "cancel");
- gtk_window_present(GTK_WINDOW(dialog));
+ adw_dialog_present (dialog, GTK_WIDGET(win));
}
// Based on the value of this, the window will exit or will not.