summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@129b00e9-8bf7-0310-bee9-bd51b64996e4>2007-11-26 18:11:32 (GMT)
committer jaromil <jaromil@129b00e9-8bf7-0310-bee9-bd51b64996e4>2007-11-26 18:11:32 (GMT)
commit8bb252ee7e2a2ec9418ce111958ef4e789afc9af (patch)
tree519d85b20ea17293522edd55822b87d1484c5868
parenta963ae9301643a87c7056ed0daf9088abc00fa49 (diff)
fixes to nesting on usb
git-svn-id: svn://dyne.org/dynebolic@263 129b00e9-8bf7-0310-bee9-bd51b64996e4
-rw-r--r--dyneII/taschino2/nest.cpp109
-rw-r--r--dyneII/taschino2/parts.cpp27
-rw-r--r--dyneII/taschino2/taschino.glade23
-rw-r--r--dyneII/taschino2/translatable.c9
4 files changed, 104 insertions, 64 deletions
diff --git a/dyneII/taschino2/nest.cpp b/dyneII/taschino2/nest.cpp
index 85323d1..6885cbe 100644
--- a/dyneII/taschino2/nest.cpp
+++ b/dyneII/taschino2/nest.cpp
@@ -33,14 +33,14 @@
#include <taschino.h>
static GtkOptionMenu *options_hd;
+static GtkOptionMenu *options_usb;
static GtkRange *hscale_hd;
static GtkRange *hscale_usb;
-static GtkLabel *label_usb;
static int selection = -1;
static int selection_usb = -1;
-void select_nest(int *num) {
+void select_nest_hd(int *num) {
int max = 1024; // MAX size for a nest
int available;
@@ -57,45 +57,56 @@ void select_nest(int *num) {
(gtk_adjustment_new(32, 32, max, 1, 0, 0) ) );
}
+void select_nest_usb(int *num) {
+ int max = 1024; // MAX size for a nest
+ int available;
+
+ if(scan_parts()<*num) return;
+ selection_usb = *num;
+ fprintf(stderr,"USB selected %i : %s\n",
+ selection_usb, parts[selection_usb].label);
+
+ available = ( parts[selection_usb].fs.f_bavail * (parts[selection_usb].fs.f_bsize/1024) ) /1000;
+ if(available<max) max = available;
+
+ gtk_range_set_adjustment
+ (hscale_usb,GTK_ADJUSTMENT
+ (gtk_adjustment_new(32, 32, max, 1, 0, 0) ) );
+}
+
void scan_nest_usb() {
+ GtkMenu *menu;
+ GtkWidget *item;
int c = 0;
- /* take only the first usb partition
- anyway only /rem/usb is checked, hardcoded in parts.cpp */
- label_usb = (GtkLabel*)glade_xml_get_widget(gui, "label_usb");
-
-
- for(c=0;c<=scan_parts();c++) {
- if(parts[c].support != USB) continue;
-
- selection_usb = c;
- if(parts[c].no_space) {
- gtk_label_set_text(label_usb,"you don't have enough space (minimum 32MB)");
- break;
- }
- if(parts[c].no_write) {
- gtk_label_set_text(label_usb,"can't write on usb storage device");
- break;
- }
- if(parts[c].has_nest) {
- gtk_label_set_text(label_usb,"device allready contains a nest!");
- break;
- }
- if(parts[c].has_error) {
- gtk_label_set_text(label_usb,parts[c].error);
- break;
- }
- // debug_parts(c);
- gtk_label_set_text(label_usb,parts[c].label);
- hscale_usb = (GtkRange*)glade_xml_get_widget(gui,"hscale_nest_usb_size");
- gtk_range_set_adjustment
- (hscale_usb,GTK_ADJUSTMENT
- (gtk_adjustment_new(32,32,
- (parts[c].fs.f_bavail *
- (parts[c].fs.f_bsize/1024))/1000,1,0,0)));
- break;
+ int avail = 0;
+ options_usb = (GtkOptionMenu*)glade_xml_get_widget(gui,"option_nest_usb");
+ hscale_usb = (GtkRange*)glade_xml_get_widget(gui,"hscale_nest_usb_size");
+ menu = (GtkMenu*)gtk_menu_new();
+ gtk_menu_set_title(menu,"choose from available usb storage");
+
+ for(c=0;c<scan_parts();c++) {
+ if( parts[c].has_error
+ || parts[c].no_space
+ || parts[c].no_write
+ || parts[c].support != USB) continue;
+ item = gtk_menu_item_new_with_label(parts[c].label);
+ gtk_widget_show(item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
+ g_signal_connect_swapped(G_OBJECT(item), "activate",
+ G_CALLBACK(select_nest_usb),
+ (gpointer)&parts[c].num);
+ avail++;
+ // default selection on first entry
+ if(avail==1) select_nest_usb(&c);
+ }
+ if(!avail) {
+ item = gtk_menu_item_new_with_label("no available partitions found");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
}
+ gtk_option_menu_set_menu(options_usb,(GtkWidget*)menu);
+
}
void scan_nest_hd() {
@@ -117,11 +128,11 @@ void scan_nest_hd() {
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
g_signal_connect_swapped(G_OBJECT(item), "activate",
- G_CALLBACK(select_nest),
+ G_CALLBACK(select_nest_hd),
(gpointer)&parts[c].num);
avail++;
// default selection on first entry
- if(avail==1) select_nest(&c);
+ if(avail==1) select_nest_hd(&c);
}
if(!avail) {
item = gtk_menu_item_new_with_label("no available partitions found");
@@ -143,7 +154,6 @@ void apply_nest(int sel) {
char mesg[512];
pid_t proc;
- int res;
debug_parts(sel);
@@ -187,14 +197,21 @@ void apply_nest(int sel) {
exit(1);
}
void apply_nest_usb(GtkWidget *widget, gpointer *data) {
- if(selection_usb<0)
+ if(selection_usb<0) {
error("no USB device detected");
- else if(parts[selection_usb].no_space
- || parts[selection_usb].no_write
- || parts[selection_usb].has_error
- || parts[selection_usb].has_nest)
- error("%s",gtk_label_get_text(label_usb));
- else {
+ } else if(parts[selection_usb].no_space) {
+ error("you don't have enough space (minimum 32MB)");
+ return;
+ } else if(parts[selection_usb].no_write) {
+ error("can't write on harddisk partition (NT filesystem?)");
+ return;
+ } else if(parts[selection_usb].has_error) {
+ error("%s",parts[selection_usb].error);
+ return;
+ } else if(parts[selection_usb].has_nest) {
+ error("the harddisk allready contains a nest!");
+ return;
+ } else {
sprintf(nest_size,"hscale_nest_usb_size");
sprintf(nest_crypt,"usb_encrypt_toggle");
apply_nest(selection_usb);
diff --git a/dyneII/taschino2/parts.cpp b/dyneII/taschino2/parts.cpp
index 0f3b6bc..19d5775 100644
--- a/dyneII/taschino2/parts.cpp
+++ b/dyneII/taschino2/parts.cpp
@@ -194,14 +194,27 @@ int scan_parts() {
if(usbfound<0) perror("can't scan /mnt");
for(c=0;c<usbfound;c++) {
-
- snprintf(parts[parts_found].path,255,"/mnt/%s",hdlist[c]->d_name);
- parts[parts_found].num = parts_found;
- parts[parts_found].support = USB;
- analyze(parts_found);
- parts_found++;
- } // to cycle thru partitions found by scandir
+ snprintf(tmp,255,"/mnt/%s",hdlist[c]->d_name);
+ partfound = scandir(tmp,&partlist,part_selector,alphasort);
+
+ if(partfound<0) perror("error scanning usb partitions");
+
+ for(cc=0;cc<partfound;cc++) { // cycle thru partitions
+
+ snprintf(parts[parts_found].path,255,"/mnt/%s/%s",
+ hdlist[c]->d_name,
+ partlist[cc]->d_name);
+
+ parts[parts_found].num = parts_found;
+
+ parts[parts_found].support = USB;
+
+ analyze(parts_found);
+
+ parts_found++;
+ } // to cycle thru partitions found by scandir
+ } // for cycle thru usb
scanned = true;
return parts_found;
diff --git a/dyneII/taschino2/taschino.glade b/dyneII/taschino2/taschino.glade
index 7f19384..abdbc5d 100644
--- a/dyneII/taschino2/taschino.glade
+++ b/dyneII/taschino2/taschino.glade
@@ -733,13 +733,14 @@ you want to create the NEST</property>
<property name="spacing">0</property>
<child>
- <widget class="GtkLabel" id="label_usb">
+ <widget class="GtkLabel" id="label30">
<property name="visible">True</property>
- <property name="label" translatable="yes">no usb storage device found</property>
+ <property name="label" translatable="yes">Select where
+you want to create the NEST</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
+ <property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
@@ -752,7 +753,21 @@ you want to create the NEST</property>
</widget>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkOptionMenu" id="option_nest_usb">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="history">-1</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
diff --git a/dyneII/taschino2/translatable.c b/dyneII/taschino2/translatable.c
index 26e11a7..cc1f6c6 100644
--- a/dyneII/taschino2/translatable.c
+++ b/dyneII/taschino2/translatable.c
@@ -22,16 +22,11 @@ gchar *s = N_("taschino :: nest on HARDDISK storage");
gchar *s = N_("Select the partition where\n"
"you want to create the NEST");
gchar *s = N_("how many MEGABYTES should your nest occupy?");
-gchar *s = N_("By securing you will generate an encrypted\n"
- "nest and you will need to set a passphrase\n"
- "20 characters long, to be used at every boot.");
gchar *s = N_("Nest your home and settings on a harddisk partition");
gchar *s = N_("taschino :: nest on USB storage");
-gchar *s = N_("no usb storage device found");
+gchar *s = N_("Select where\n"
+ "you want to create the NEST");
gchar *s = N_("how many MEGABYTES should your nest occupy?");
-gchar *s = N_("By securing you will generate an encrypted\n"
- "nest and you will need to set a passphrase\n"
- "20 characters long, to be used at every boot.");
gchar *s = N_("Nest your home and settings on a usb storage key");
gchar *s = N_("taschino :: an error occurred!");
gchar *s = N_("a mysterious error occurred\n"