Skip to content

Commit

Permalink
21.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vl-nix committed Aug 19, 2021
1 parent 2800b59 commit 03af636
Show file tree
Hide file tree
Showing 587 changed files with 96,497 additions and 0 deletions.
1 change: 1 addition & 0 deletions LICENSE → License
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,4 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

25 changes: 25 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### GRecovery

* Data Recovery Utility
* Base in [PhotoRec](https://www.cgsecurity.org)


#### Dependencies

* gcc, meson
* libz ( & dev )
* ext2fs ( & dev )
* libjpeg ( & dev )
* libntfs-3g ( & dev )
* libgtk 3.0 ( & dev )


#### Build

1. Configure: meson build --prefix /usr --strip

2. Build: ninja -C build

3. Install: sudo ninja -C build install

4. Uninstall: sudo ninja -C build uninstall
8 changes: 8 additions & 0 deletions data/desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=GRecovery
Comment=Data Recovery Utility
Exec=grecovery-pkexec
Icon=image
Terminal=false
Type=Application
Categories=GTK;Utility;
3 changes: 3 additions & 0 deletions data/grecovery-pkexec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "/usr/bin/grecovery" $@
Binary file added data/icons/apply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions data/icons/gresource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<gresources>
<gresource prefix="/gres">
<file preprocess="to-pixdata">info.png</file>
<file preprocess="to-pixdata">close.png</file>
<file preprocess="to-pixdata">image.png</file>
<file preprocess="to-pixdata">folder.png</file>
<file preprocess="to-pixdata">search.png</file>
<file preprocess="to-pixdata">recovery.png</file>
<file preprocess="to-pixdata">apply.png</file>
<file preprocess="to-pixdata">clear.png</file>
<file preprocess="to-pixdata">reload.png</file>
</gresource>
</gresources>
Binary file added data/icons/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/recovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/reload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
195 changes: 195 additions & 0 deletions gtk/src/formats-win.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
* Copyright 2021 Stepan Perun
* This program is free software.
*
* License: Gnu General Public License GPL-2
* file:///usr/share/common-licenses/GPL-2
* http://www.gnu.org/licenses/gpl-2.0.html
*/

#include "formats-win.h"

enum cols_n
{
COL_NUM,
COL_SET,
COL_FTP,
COL_ALL
};

struct _FormatsWin
{
GtkWindow parent_instance;

GtkTreeView *treeview;
};

G_DEFINE_TYPE ( FormatsWin, formats_win, GTK_TYPE_WINDOW )

void formats_win_treeview_append ( uint ind, gboolean set, const char *descr, FormatsWin *win )
{
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model ( win->treeview );

gtk_list_store_append ( GTK_LIST_STORE ( model ), &iter );
gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
COL_NUM, ind,
COL_SET, set,
COL_FTP, descr,
-1 );
}

static void formats_win_toggled ( G_GNUC_UNUSED GtkCellRendererToggle *toggle, char *path_str, FormatsWin *win )
{
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model ( win->treeview );

GtkTreePath *path = gtk_tree_path_new_from_string ( path_str );
gtk_tree_model_get_iter ( model, &iter, path );

gboolean toggle_item;
gtk_tree_model_get ( model, &iter, COL_SET, &toggle_item, -1 );
gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter, COL_SET, !toggle_item, -1 );

gtk_tree_path_free ( path );
}

static GtkScrolledWindow * formats_win_create_treeview_scroll ( FormatsWin *win )
{
GtkScrolledWindow *scroll = (GtkScrolledWindow *)gtk_scrolled_window_new ( NULL, NULL );
gtk_scrolled_window_set_policy ( scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
gtk_widget_set_visible ( GTK_WIDGET ( scroll ), TRUE );

GtkListStore *store = gtk_list_store_new ( COL_ALL, G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_STRING );

win->treeview = (GtkTreeView *)gtk_tree_view_new_with_model ( GTK_TREE_MODEL ( store ) );
gtk_widget_set_visible ( GTK_WIDGET ( win->treeview ), TRUE );

GtkCellRenderer *renderer;
GtkTreeViewColumn *column;

struct Column { const char *name; const char *type; uint8_t num; } column_n[] =
{
{ "Num", "text", COL_NUM },
{ "Set", "active", COL_SET },
{ "Type", "text", COL_FTP }
};

uint8_t c = 0; for ( c = 0; c < COL_ALL; c++ )
{
if ( c == COL_SET )
renderer = gtk_cell_renderer_toggle_new ();
else
renderer = gtk_cell_renderer_text_new ();

if ( c == COL_SET ) g_signal_connect ( renderer, "toggled", G_CALLBACK ( formats_win_toggled ), win );

column = gtk_tree_view_column_new_with_attributes ( column_n[c].name, renderer, column_n[c].type, column_n[c].num, NULL );
gtk_tree_view_append_column ( win->treeview, column );
}

gtk_container_add ( GTK_CONTAINER ( scroll ), GTK_WIDGET ( win->treeview ) );
g_object_unref ( G_OBJECT (store) );

return scroll;
}

static void formats_win_save ( G_GNUC_UNUSED GtkButton *button, FormatsWin *win )
{
g_signal_emit_by_name ( win, "formats-set-data", SG_SAVE, G_OBJECT ( win->treeview ) );

gtk_widget_destroy ( GTK_WIDGET ( win ) );
}

static void formats_win_reset ( G_GNUC_UNUSED GtkButton *button, FormatsWin *win )
{
g_signal_emit_by_name ( win, "formats-set-data", SG_RESET, G_OBJECT ( win->treeview ) );
}

static void formats_win_restore ( G_GNUC_UNUSED GtkButton *button, FormatsWin *win )
{
g_signal_emit_by_name ( win, "formats-set-data", SG_RESTORE, G_OBJECT ( win->treeview ) );
}

static void formats_win_create_buttons ( GtkBox *h_box, FormatsWin *win )
{
// const char *labels[] = { "Reset", "Restore", "Ok" };
const char *labels[] = { "/gres/clear.png", "/gres/reload.png", "/gres/apply.png" };
const void *funcs[] = { formats_win_reset, formats_win_restore, formats_win_save };

uint8_t c = 0; for ( c = 0; c < G_N_ELEMENTS ( labels ); c++ )
{
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource ( labels[c], NULL );
GdkPixbuf *pixbuf_scale = gdk_pixbuf_scale_simple ( pixbuf, 16, 16, GDK_INTERP_BILINEAR );
GtkImage *image = (GtkImage *)gtk_image_new_from_pixbuf ( pixbuf_scale );

GtkButton *button = (GtkButton *)gtk_button_new (); // gtk_button_new_with_label ( labels[c] );
gtk_button_set_image ( button, GTK_WIDGET ( image ) );

if ( pixbuf ) g_object_unref ( pixbuf );
if ( pixbuf ) g_object_unref ( pixbuf_scale );

g_signal_connect ( button, "clicked", G_CALLBACK ( funcs[c] ), win );

gtk_widget_set_visible ( GTK_WIDGET ( button ), TRUE );
gtk_box_pack_start ( h_box, GTK_WIDGET ( button ), TRUE, TRUE, 0 );
}
}

static void formats_win_create ( FormatsWin *win )
{
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource ( "/gres/recovery.png", NULL );

GtkWindow *window = GTK_WINDOW ( win );
// gtk_window_set_title ( window, "Formats" );
gtk_window_set_default_size ( window, 500, 300 );
gtk_window_set_icon ( window, pixbuf );

if ( pixbuf ) g_object_unref ( pixbuf );

GtkBox *v_box = (GtkBox *)gtk_box_new ( GTK_ORIENTATION_VERTICAL, 0 );
GtkBox *h_box = (GtkBox *)gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, 0 );

gtk_box_set_spacing ( v_box, 10 );
gtk_box_set_spacing ( h_box, 10 );

gtk_widget_set_visible ( GTK_WIDGET ( v_box ), TRUE );
gtk_widget_set_visible ( GTK_WIDGET ( h_box ), TRUE );

gtk_box_pack_start ( v_box, GTK_WIDGET ( formats_win_create_treeview_scroll ( win ) ), TRUE, TRUE, 0 );

formats_win_create_buttons ( h_box, win );

gtk_box_pack_start ( v_box, GTK_WIDGET ( h_box ), FALSE, FALSE, 0 );

gtk_container_set_border_width ( GTK_CONTAINER ( v_box ), 10 );
gtk_container_add ( GTK_CONTAINER ( window ), GTK_WIDGET ( v_box ) );

gtk_window_present ( GTK_WINDOW ( win ) );
}

static void formats_win_init ( FormatsWin *win )
{
formats_win_create ( win );
}

static void formats_win_finalize ( GObject *object )
{
G_OBJECT_CLASS ( formats_win_parent_class )->finalize ( object );
}

static void formats_win_class_init ( FormatsWinClass *class )
{
GObjectClass *oclass = G_OBJECT_CLASS (class);

oclass->finalize = formats_win_finalize;

g_signal_new ( "formats-set-data", G_TYPE_FROM_CLASS ( class ), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_OBJECT );
}

FormatsWin * formats_win_new ( void )
{
FormatsWin *win = g_object_new ( FORMATS_TYPE_WIN, NULL );

return win;
}
28 changes: 28 additions & 0 deletions gtk/src/formats-win.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2021 Stepan Perun
* This program is free software.
*
* License: Gnu General Public License GPL-2
* file:///usr/share/common-licenses/GPL-2
* http://www.gnu.org/licenses/gpl-2.0.html
*/

#pragma once

#include <gtk/gtk.h>

#define FORMATS_TYPE_WIN formats_win_get_type ()

enum res_n
{
SG_SAVE,
SG_RESET,
SG_RESTORE,
SG_ALL
};

G_DECLARE_FINAL_TYPE ( FormatsWin, formats_win, FORMATS, WIN, GtkWindow )

FormatsWin * formats_win_new ( void );

void formats_win_treeview_append ( uint , gboolean , const char *, FormatsWin * );
48 changes: 48 additions & 0 deletions gtk/src/grecovery-app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2021 Stepan Perun
* This program is free software.
*
* License: Gnu General Public License GPL-2
* file:///usr/share/common-licenses/GPL-2
* http://www.gnu.org/licenses/gpl-2.0.html
*/

#include "grecovery-app.h"
#include "grecovery-win.h"

struct _GRecoveryApp
{
GtkApplication parent_instance;
};

G_DEFINE_TYPE ( GRecoveryApp, grecovery_app, GTK_TYPE_APPLICATION )

static void grecovery_app_activate ( GApplication *app )
{
grecovery_win_new ( GRECOVERY_APP ( app ) );
}

static void grecovery_app_init ( G_GNUC_UNUSED GRecoveryApp *app )
{

}

static void grecovery_app_finalize ( GObject *object )
{
G_OBJECT_CLASS ( grecovery_app_parent_class )->finalize ( object );
}

static void grecovery_app_class_init ( GRecoveryAppClass *class )
{
GObjectClass *object_class = G_OBJECT_CLASS (class);

G_APPLICATION_CLASS (class)->activate = grecovery_app_activate;

object_class->finalize = grecovery_app_finalize;
}

GRecoveryApp * grecovery_app_new ( void )
{
return g_object_new ( GRECOVERY_TYPE_APP, "application-id", "org.gtk.grecovery", "flags", G_APPLICATION_NON_UNIQUE, NULL );
}

19 changes: 19 additions & 0 deletions gtk/src/grecovery-app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2021 Stepan Perun
* This program is free software.
*
* License: Gnu General Public License GPL-2
* file:///usr/share/common-licenses/GPL-2
* http://www.gnu.org/licenses/gpl-2.0.html
*/

#pragma once

#include <gtk/gtk.h>

#define GRECOVERY_TYPE_APP grecovery_app_get_type ()

G_DECLARE_FINAL_TYPE ( GRecoveryApp, grecovery_app, GRECOVERY, APP, GtkApplication )

GRecoveryApp * grecovery_app_new ( void );

Loading

0 comments on commit 03af636

Please sign in to comment.