[BACKUP] Add Progress Bar

main
Joaquin 2 years ago
parent 6402ea4abc
commit a564e1a071
Signed by: puly
GPG Key ID: 9E9299CD96C65EC6
  1. 244
      HeaderBar.c
  2. 59
      Main.c
  3. 130
      Nostalgia.c
  4. 1965
      Window.c
  5. 130
      Window.vala
  6. BIN
      listbox
  7. 53
      listbox.vala
  8. BIN
      nostalgia

@ -0,0 +1,244 @@
/* HeaderBar.c generated by valac 0.56.13, the Vala compiler
* generated from HeaderBar.vala, do not modify */
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif
#define MY_APP_TYPE_HEADER_BAR (my_app_header_bar_get_type ())
#define MY_APP_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_APP_TYPE_HEADER_BAR, MyAppHeaderBar))
#define MY_APP_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_APP_TYPE_HEADER_BAR, MyAppHeaderBarClass))
#define MY_APP_IS_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_APP_TYPE_HEADER_BAR))
#define MY_APP_IS_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_APP_TYPE_HEADER_BAR))
#define MY_APP_HEADER_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_APP_TYPE_HEADER_BAR, MyAppHeaderBarClass))
typedef struct _MyAppHeaderBar MyAppHeaderBar;
typedef struct _MyAppHeaderBarClass MyAppHeaderBarClass;
typedef struct _MyAppHeaderBarPrivate MyAppHeaderBarPrivate;
enum {
MY_APP_HEADER_BAR_0_PROPERTY,
MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY,
MY_APP_HEADER_BAR_NUM_PROPERTIES
};
static GParamSpec* my_app_header_bar_properties[MY_APP_HEADER_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _MyAppHeaderBar {
GtkHeaderBar parent_instance;
MyAppHeaderBarPrivate * priv;
};
struct _MyAppHeaderBarClass {
GtkHeaderBarClass parent_class;
};
struct _MyAppHeaderBarPrivate {
GtkStack* _window_stack;
};
static gint MyAppHeaderBar_private_offset;
static gpointer my_app_header_bar_parent_class = NULL;
VALA_EXTERN GType my_app_header_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MyAppHeaderBar, g_object_unref)
VALA_EXTERN MyAppHeaderBar* my_app_header_bar_new (GtkStack* stack);
VALA_EXTERN MyAppHeaderBar* my_app_header_bar_construct (GType object_type,
GtkStack* stack);
VALA_EXTERN GtkStack* my_app_header_bar_get_window_stack (MyAppHeaderBar* self);
static void my_app_header_bar_set_window_stack (MyAppHeaderBar* self,
GtkStack* value);
static GObject * my_app_header_bar_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam * construct_properties);
static void my_app_header_bar_finalize (GObject * obj);
static GType my_app_header_bar_get_type_once (void);
static void _vala_my_app_header_bar_get_property (GObject * object,
guint property_id,
GValue * value,
GParamSpec * pspec);
static void _vala_my_app_header_bar_set_property (GObject * object,
guint property_id,
const GValue * value,
GParamSpec * pspec);
static inline gpointer
my_app_header_bar_get_instance_private (MyAppHeaderBar* self)
{
return G_STRUCT_MEMBER_P (self, MyAppHeaderBar_private_offset);
}
MyAppHeaderBar*
my_app_header_bar_construct (GType object_type,
GtkStack* stack)
{
MyAppHeaderBar * self = NULL;
g_return_val_if_fail (stack != NULL, NULL);
self = (MyAppHeaderBar*) g_object_new (object_type, "window-stack", stack, NULL);
return self;
}
MyAppHeaderBar*
my_app_header_bar_new (GtkStack* stack)
{
return my_app_header_bar_construct (MY_APP_TYPE_HEADER_BAR, stack);
}
GtkStack*
my_app_header_bar_get_window_stack (MyAppHeaderBar* self)
{
GtkStack* result;
GtkStack* _tmp0_;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = self->priv->_window_stack;
result = _tmp0_;
return result;
}
static gpointer
_g_object_ref0 (gpointer self)
{
return self ? g_object_ref (self) : NULL;
}
static void
my_app_header_bar_set_window_stack (MyAppHeaderBar* self,
GtkStack* value)
{
GtkStack* old_value;
g_return_if_fail (self != NULL);
old_value = my_app_header_bar_get_window_stack (self);
if (old_value != value) {
GtkStack* _tmp0_;
_tmp0_ = _g_object_ref0 (value);
_g_object_unref0 (self->priv->_window_stack);
self->priv->_window_stack = _tmp0_;
g_object_notify_by_pspec ((GObject *) self, my_app_header_bar_properties[MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY]);
}
}
static GObject *
my_app_header_bar_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam * construct_properties)
{
GObject * obj;
GObjectClass * parent_class;
MyAppHeaderBar * self;
GtkStackSwitcher* stack_switcher = NULL;
GtkStackSwitcher* _tmp0_;
GtkStackSwitcher* _tmp1_;
GtkStack* _tmp2_;
GtkStackSwitcher* _tmp3_;
parent_class = G_OBJECT_CLASS (my_app_header_bar_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = G_TYPE_CHECK_INSTANCE_CAST (obj, MY_APP_TYPE_HEADER_BAR, MyAppHeaderBar);
gtk_header_bar_set_show_close_button ((GtkHeaderBar*) self, TRUE);
_tmp0_ = (GtkStackSwitcher*) gtk_stack_switcher_new ();
g_object_ref_sink (_tmp0_);
stack_switcher = _tmp0_;
_tmp1_ = stack_switcher;
_tmp2_ = self->priv->_window_stack;
gtk_stack_switcher_set_stack (_tmp1_, _tmp2_);
_tmp3_ = stack_switcher;
gtk_header_bar_set_custom_title ((GtkHeaderBar*) self, (GtkWidget*) _tmp3_);
_g_object_unref0 (stack_switcher);
return obj;
}
static void
my_app_header_bar_class_init (MyAppHeaderBarClass * klass,
gpointer klass_data)
{
my_app_header_bar_parent_class = g_type_class_peek_parent (klass);
g_type_class_adjust_private_offset (klass, &MyAppHeaderBar_private_offset);
G_OBJECT_CLASS (klass)->get_property = _vala_my_app_header_bar_get_property;
G_OBJECT_CLASS (klass)->set_property = _vala_my_app_header_bar_set_property;
G_OBJECT_CLASS (klass)->constructor = my_app_header_bar_constructor;
G_OBJECT_CLASS (klass)->finalize = my_app_header_bar_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY, my_app_header_bar_properties[MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY] = g_param_spec_object ("window-stack", "window-stack", "window-stack", gtk_stack_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void
my_app_header_bar_instance_init (MyAppHeaderBar * self,
gpointer klass)
{
self->priv = my_app_header_bar_get_instance_private (self);
}
static void
my_app_header_bar_finalize (GObject * obj)
{
MyAppHeaderBar * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, MY_APP_TYPE_HEADER_BAR, MyAppHeaderBar);
_g_object_unref0 (self->priv->_window_stack);
G_OBJECT_CLASS (my_app_header_bar_parent_class)->finalize (obj);
}
static GType
my_app_header_bar_get_type_once (void)
{
static const GTypeInfo g_define_type_info = { sizeof (MyAppHeaderBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) my_app_header_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MyAppHeaderBar), 0, (GInstanceInitFunc) my_app_header_bar_instance_init, NULL };
GType my_app_header_bar_type_id;
my_app_header_bar_type_id = g_type_register_static (gtk_header_bar_get_type (), "MyAppHeaderBar", &g_define_type_info, 0);
MyAppHeaderBar_private_offset = g_type_add_instance_private (my_app_header_bar_type_id, sizeof (MyAppHeaderBarPrivate));
return my_app_header_bar_type_id;
}
GType
my_app_header_bar_get_type (void)
{
static volatile gsize my_app_header_bar_type_id__once = 0;
if (g_once_init_enter (&my_app_header_bar_type_id__once)) {
GType my_app_header_bar_type_id;
my_app_header_bar_type_id = my_app_header_bar_get_type_once ();
g_once_init_leave (&my_app_header_bar_type_id__once, my_app_header_bar_type_id);
}
return my_app_header_bar_type_id__once;
}
static void
_vala_my_app_header_bar_get_property (GObject * object,
guint property_id,
GValue * value,
GParamSpec * pspec)
{
MyAppHeaderBar * self;
self = G_TYPE_CHECK_INSTANCE_CAST (object, MY_APP_TYPE_HEADER_BAR, MyAppHeaderBar);
switch (property_id) {
case MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY:
g_value_set_object (value, my_app_header_bar_get_window_stack (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
_vala_my_app_header_bar_set_property (GObject * object,
guint property_id,
const GValue * value,
GParamSpec * pspec)
{
MyAppHeaderBar * self;
self = G_TYPE_CHECK_INSTANCE_CAST (object, MY_APP_TYPE_HEADER_BAR, MyAppHeaderBar);
switch (property_id) {
case MY_APP_HEADER_BAR_WINDOW_STACK_PROPERTY:
my_app_header_bar_set_window_stack (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

@ -0,0 +1,59 @@
/* Main.c generated by valac 0.56.13, the Vala compiler
* generated from Main.vala, do not modify */
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif
#define TYPE_NOSTALGIA (nostalgia_get_type ())
#define NOSTALGIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NOSTALGIA, Nostalgia))
#define NOSTALGIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NOSTALGIA, NostalgiaClass))
#define IS_NOSTALGIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NOSTALGIA))
#define IS_NOSTALGIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NOSTALGIA))
#define NOSTALGIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NOSTALGIA, NostalgiaClass))
typedef struct _Nostalgia Nostalgia;
typedef struct _NostalgiaClass NostalgiaClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
static gint _vala_main (gchar** args,
gint args_length1);
VALA_EXTERN GType nostalgia_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Nostalgia, g_object_unref)
VALA_EXTERN Nostalgia* nostalgia_new (void);
VALA_EXTERN Nostalgia* nostalgia_construct (GType object_type);
static gint
_vala_main (gchar** args,
gint args_length1)
{
Nostalgia* nostalgia = NULL;
Nostalgia* _tmp0_;
gint result;
_tmp0_ = nostalgia_new ();
nostalgia = _tmp0_;
result = g_application_run ((GApplication*) nostalgia, (gint) args_length1, args);
_g_object_unref0 (nostalgia);
return result;
}
int
main (int argc,
char ** argv)
{
return _vala_main (argv, argc);
}

@ -0,0 +1,130 @@
/* Nostalgia.c generated by valac 0.56.13, the Vala compiler
* generated from Nostalgia.vala, do not modify */
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif
#define TYPE_NOSTALGIA (nostalgia_get_type ())
#define NOSTALGIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NOSTALGIA, Nostalgia))
#define NOSTALGIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NOSTALGIA, NostalgiaClass))
#define IS_NOSTALGIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NOSTALGIA))
#define IS_NOSTALGIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NOSTALGIA))
#define NOSTALGIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NOSTALGIA, NostalgiaClass))
typedef struct _Nostalgia Nostalgia;
typedef struct _NostalgiaClass NostalgiaClass;
typedef struct _NostalgiaPrivate NostalgiaPrivate;
enum {
NOSTALGIA_0_PROPERTY,
NOSTALGIA_NUM_PROPERTIES
};
static GParamSpec* nostalgia_properties[NOSTALGIA_NUM_PROPERTIES];
#define MY_APP_TYPE_WINDOW (my_app_window_get_type ())
#define MY_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_APP_TYPE_WINDOW, MyAppWindow))
#define MY_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_APP_TYPE_WINDOW, MyAppWindowClass))
#define MY_APP_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_APP_TYPE_WINDOW))
#define MY_APP_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_APP_TYPE_WINDOW))
#define MY_APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_APP_TYPE_WINDOW, MyAppWindowClass))
typedef struct _MyAppWindow MyAppWindow;
typedef struct _MyAppWindowClass MyAppWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _Nostalgia {
GtkApplication parent_instance;
NostalgiaPrivate * priv;
};
struct _NostalgiaClass {
GtkApplicationClass parent_class;
};
static gpointer nostalgia_parent_class = NULL;
VALA_EXTERN GType nostalgia_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Nostalgia, g_object_unref)
VALA_EXTERN Nostalgia* nostalgia_new (void);
VALA_EXTERN Nostalgia* nostalgia_construct (GType object_type);
static void nostalgia_real_activate (GApplication* base);
VALA_EXTERN GType my_app_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MyAppWindow, g_object_unref)
VALA_EXTERN MyAppWindow* my_app_window_new (Nostalgia* application);
VALA_EXTERN MyAppWindow* my_app_window_construct (GType object_type,
Nostalgia* application);
static GType nostalgia_get_type_once (void);
Nostalgia*
nostalgia_construct (GType object_type)
{
Nostalgia * self = NULL;
self = (Nostalgia*) g_object_new (object_type, "application-id", "com.github.konickss.nostalgia", "flags", G_APPLICATION_FLAGS_NONE, NULL);
return self;
}
Nostalgia*
nostalgia_new (void)
{
return nostalgia_construct (TYPE_NOSTALGIA);
}
static void
nostalgia_real_activate (GApplication* base)
{
Nostalgia * self;
MyAppWindow* window = NULL;
MyAppWindow* _tmp0_;
self = (Nostalgia*) base;
_tmp0_ = my_app_window_new (self);
g_object_ref_sink (_tmp0_);
window = _tmp0_;
gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) window);
_g_object_unref0 (window);
}
static void
nostalgia_class_init (NostalgiaClass * klass,
gpointer klass_data)
{
nostalgia_parent_class = g_type_class_peek_parent (klass);
((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) nostalgia_real_activate;
}
static void
nostalgia_instance_init (Nostalgia * self,
gpointer klass)
{
}
static GType
nostalgia_get_type_once (void)
{
static const GTypeInfo g_define_type_info = { sizeof (NostalgiaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) nostalgia_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Nostalgia), 0, (GInstanceInitFunc) nostalgia_instance_init, NULL };
GType nostalgia_type_id;
nostalgia_type_id = g_type_register_static (gtk_application_get_type (), "Nostalgia", &g_define_type_info, 0);
return nostalgia_type_id;
}
GType
nostalgia_get_type (void)
{
static volatile gsize nostalgia_type_id__once = 0;
if (g_once_init_enter (&nostalgia_type_id__once)) {
GType nostalgia_type_id;
nostalgia_type_id = nostalgia_get_type_once ();
g_once_init_leave (&nostalgia_type_id__once, nostalgia_type_id);
}
return nostalgia_type_id__once;
}

1965
Window.c

File diff suppressed because it is too large Load Diff

@ -66,6 +66,8 @@ For when you need them the most</span>");
blue_color.parse("#0860F2");
var green_color = new Gdk.RGBA();
green_color.parse("#59C837");
var black_color = new Gdk.RGBA();
black_color.parse("#15161E");
button1.override_background_color(Gtk.StateFlags.NORMAL, green_color);
var gridfb = new Gtk.Grid();
gridfb.attach(button1, 1, 1);
@ -135,7 +137,7 @@ so please be patient and let us get your system back and running"), true, false,
}
});
cr12.pack_start(crbackbutton, false, false, 10);
var packhome = new Gtk.Switch();
/*var packhome = new Gtk.Switch();
packhome.set_state(true);
var cr14 = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
cr14.pack_start(new Gtk.Label(""), true, true, 10);
@ -145,6 +147,37 @@ so please be patient and let us get your system back and running"), true, false,
cr14.pack_start(packhome, false, false, 10);
cr14.pack_start(new Gtk.Label(""), true, true, 10);
cr1.pack_start(cr14, false, false, 0);
*/
var cr15 = new Gtk.Box(Gtk.Orientation.VERTICAL, 20);
var ExcludePanel = new Gtk.ScrolledWindow(null, null);
var ExcludeListLabel = new Gtk.Label("Type Every Folder to be EXCLUDED from the Backup, using ABSOLUTE paths, one per line");
var ExcludeList = new Gtk.TextView();
ExcludeList.set_editable(true);
ExcludeList.set_cursor_visible(true);
ExcludeList.override_background_color(Gtk.StateFlags.NORMAL, black_color);
ExcludePanel.set_border_width(10);
ExcludePanel.set_max_content_height(50);
ExcludePanel.add(ExcludeList);
cr15.pack_start(ExcludeListLabel);
var cr151 = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 20);
cr151.pack_start(new Gtk.Label(null), false, false, 5);
cr151.pack_start(ExcludePanel);
cr151.pack_start(new Gtk.Label(null), false, false, 5);
cr15.pack_start(cr151, false, false ,0);
cr1.pack_start(cr15, false, false, 0);
var finbutcr = new Gtk.Button.with_label("✔ Make snapshot");
finbutcr.override_background_color(Gtk.StateFlags.NORMAL, green_color);
cr12.pack_end(finbutcr, false, false, 10);
@ -153,6 +186,7 @@ so please be patient and let us get your system back and running"), true, false,
print(crloc1.get_filename());
string loc = crloc1.get_filename();
print("\n");
print(crloc1.get_filename());
if (crloc1.get_filename() == null){
var ibl = new Gtk.Dialog.with_buttons("Invaild backup location", this, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.USE_HEADER_BAR, null);
var iblca = ibl.get_content_area();
@ -176,13 +210,24 @@ so please be patient and let us get your system back and running"), true, false,
var lbl = new Gtk.TextView();
lbl.set_wrap_mode (Gtk.WrapMode.WORD);
lbl.set_monospace(true);
//lbl.set_monospace(true);
lbl.override_background_color(Gtk.StateFlags.NORMAL, black_color);
var lblScroll = new Gtk.ScrolledWindow(null, null);
lblScroll.add(lbl);
lblScroll.set_max_content_height(100);
lblScroll.set_max_content_height(600);
progresscr.pack_start(lblScroll);
var ProgBar = new Gtk.ProgressBar();
progresscr.pack_end(ProgBar);
var ProgLabel = new Gtk.Label("Nostalgia Progress: 0%");
progresscr.pack_end(ProgLabel);
//The length will never be the same if the file is not found
if(isfile.char_count() != isft.char_count()){
print("\n root backup \n");
@ -199,7 +244,12 @@ so please be patient and let us get your system back and running"), true, false,
int dum;
bool lop=true;
string[] backup_command = {"/usr/bin/rsync", "-av", "/home/ioachim/Music", "/home/ioachim/Music2", "--no-i-r", "--info=progress2", null};
string[] backup_command_template = {"/usr/bin/pkexec", "/usr/bin/rsync", "-ahv", "/home/ioachim/Music", "/home/ioachim/Music2", "--no-i-r", "--info=progress2", "--fsync", null};
var ExcludeFolders = ExcludeList.get_text().split('\n');
var ChildProcessBackup = new Subprocess.newv(backup_command, SubprocessFlags.STDOUT_PIPE);
@ -215,16 +265,41 @@ so please be patient and let us get your system back and running"), true, false,
notification.set_timeout(0);
notification.show();
print("\nREMOVING CHILDREN FROM PAGE\n");
var progresscrChildren = progresscr.get_children();
foreach (Gtk.Widget element in progresscrChildren)
progresscr.remove(element);
}catch(Error err){
print("\n\n------ERROR!!!------\n%s\n\n", err.message);
createstack.set_visible_child(cr1);
var ibl = new Gtk.Dialog.with_buttons("Error Spawning Process", this, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.USE_HEADER_BAR, null);
var iblca = ibl.get_content_area();
iblca.add(new Gtk.Label("
"));
iblca.add(new Gtk.Label(" Make sure /usr/bin/rsync is installed, up to date and that you have root privileges and have inputed your correct user password "));
iblca.add(new Gtk.Label("
"));
ibl.show_all();
print("\nREMOVING CHILDREN FROM PAGE\n");
var progresscrChildren = progresscr.get_children();
foreach (Gtk.Widget element in progresscrChildren)
progresscr.remove(element);
ssnap = false;
}
});
var OutputPipeBackup = ChildProcessBackup.get_stdout_pipe();
update_label_from_istream.begin(OutputPipeBackup, lbl);
update_label_from_istream.begin(OutputPipeBackup, lbl, ProgBar, ProgLabel);
}
}
@ -241,19 +316,58 @@ so please be patient and let us get your system back and running"), true, false,
set_resizable(false);
show_all();
print("Hey, thanks for choosing nostalgia! \n");
print("If you're looking at the debug output most probably you're having some trouble with this program, so feel free to email me at [ioachim.radu@protonmail.com] and I'll see if I can help \n");
print("If you're looking at the debug output most probably you're having some trouble with this program, so feel free to contact me and I'll see if I can help \n");
print("\n\n");
print("email: [ioachim.radu@protonmail.com]\n");
print("webpage: [ioachim.eu.org]\n");
print("pgp: [C2462D5103FA6059E1E3279C9E9299CD96C65EC6]\n");
print("\n\n");
}
}
int timer = 0;
async void update_label_from_istream (InputStream istream, Gtk.TextView label) {
async void update_label_from_istream (InputStream istream, Gtk.TextView label, Gtk.ProgressBar ProgBar, Gtk.Label ProgLabel) {
try {
var dis = new DataInputStream (istream);
var line = yield dis.read_line_async ();
while (line != null) {
if(timer == 5){
label.buffer.text = "";
timer = 0;
}
label.buffer.text += line + "\n";
print(line);
print("\n");
var words = line.split(" ");
foreach(unowned string word in words){
if(word[word.length - 1] == '%'){
var word_trimmed = word.substring(0, word.length - 1);
double procDone = (double)StrToInt(word_trimmed) / (double)100;
ProgBar.set_fraction(procDone);
ProgBar.set_text(word_trimmed);
ProgLabel.set_text(word_trimmed + "%");
print(procDone.to_string() + " ");
}
}
timer++;
line = yield dis.read_line_async ();
}
} catch (Error err) {}
}
int StrToInt(string str){
int ret = 0;
for(int i = 0; i < str.length; i++){
ret *= 10;
ret += (str[i] - '0'); //get char code offset to zero of digit
}
return ret;
}

Binary file not shown.

@ -0,0 +1,53 @@
/*
* A Notebook can be used to provide tabulated pages on which different content
* can be added.
*
* Compile using:
* valac notebook.vala --pkg gtk+-3.0
*
* Author: Andrew Steele
*/
using Gtk;
public class Example : Window
{
private Notebook notebook;
public Example()
{
this.title = "Notebook";
this.set_default_size(200, 200);
this.destroy.connect(Gtk.main_quit);
notebook = new Notebook();
this.add(notebook);
int count;
for (count = 1; count <= 3; count++)
{
var text1 = "Tab %i".printf(count);
var label = new Label(null);
label.set_label(text1);
var text2 = "Button %i in Tab %i".printf(count, count);
var button = new Button.with_label(text2);
notebook.append_page(button, label);
}
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}

Binary file not shown.
Loading…
Cancel
Save