Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
random532 authored Jul 30, 2020
1 parent 3eb208c commit bff8f04
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 215 deletions.
50 changes: 27 additions & 23 deletions applyButtonClicked.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void on_edit_clicked(GtkMenuItem *item, gpointer user_data) {
msg("malloc failed.");
return;
}
memset(cmd, 0, 150);
memset(cmd, 0, CMDSIZE);
int error = 0;

/* what did our user choose? */
Expand Down Expand Up @@ -69,11 +69,12 @@ void on_edit_clicked(GtkMenuItem *item, gpointer user_data) {
editor();
}

const char *get_combo_box_disk() {
const char *get_combo_box_disk(int inform) {

const gchar *gdisk = gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT (combo_disks) );
if(gdisk == NULL) {
msg(l.chose_disk);
if(inform == 1)
msg(l.chose_disk);
return NULL;
}
if( (strlen(gdisk) == 0) || (strlen(gdisk) >= 20 ) )
Expand All @@ -94,15 +95,16 @@ const char *get_combo_box_scheme() {
return gscheme;
}

char *get_combo_box_partition() {
char *get_combo_box_partition(int inform) {

/* while we are here: */
/* make it char instead of const char */
/* also format it!! */

const gchar *gpartition = gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT (combo_partitions) );
if(gpartition == NULL) {
msg(l.chose_partition);
if( inform == 1)
msg(l.chose_partition);
return NULL;
}

Expand All @@ -119,11 +121,12 @@ char *get_combo_box_partition() {
return buffer;
}

const char *get_combo_box_type() {
const char *get_combo_box_type(int inform) {

const gchar *gtype = gtk_combo_box_text_get_active_text( GTK_COMBO_BOX_TEXT (combo_types) );
if(gtype == NULL) {
msg(l.chose_type);
if(inform == 1)
msg(l.chose_type);
return NULL;
}

Expand All @@ -145,10 +148,10 @@ char *gpart_create( char *cmd) {
}
const gchar *gentry = gtk_entry_get_text(GTK_ENTRY (text_entries)); /* optional entries */
int i=strlen(gentry);
if( (i != 0) && (i <= 15))
if(gtk_widget_is_visible(GTK_WIDGET (text_entries)) && i > 0 && i <= 15)
entry = 1;

const gchar *gdisk = get_combo_box_disk();
const gchar *gdisk = get_combo_box_disk(1);
if( gdisk == NULL) {
free(cmd);
return NULL;
Expand All @@ -163,7 +166,7 @@ char *gpart_create( char *cmd) {

char *gpart_destroy( char *cmd) {

const gchar *gdisk = get_combo_box_disk();
const gchar *gdisk = get_combo_box_disk(1);
if( gdisk == NULL) {
free(cmd);
return NULL;
Expand All @@ -177,7 +180,7 @@ char *gpart_modify( char *cmd) {
int type = 0;
int label = 0;

char *gpartition = get_combo_box_partition();
char *gpartition = get_combo_box_partition(1);
if(gpartition == NULL) {
free(cmd);
return NULL;
Expand All @@ -188,13 +191,14 @@ char *gpart_modify( char *cmd) {
return NULL;
}

const char *gtype = get_combo_box_type();
const char *gtype = get_combo_box_type(0);
if(gtype != NULL)
type = 1;


const gchar *glabel = gtk_entry_get_text(GTK_ENTRY (text_label));
if( (strlen(glabel) > 0) && (strlen(glabel) <= 20) )
label = 1;
if( (gtk_widget_is_visible (text_label)) && (strlen(glabel) > 0) && (strlen(glabel) <= 20) )
label = 1;

if( (label) && (!type) )
snprintf(cmd, CMDSIZE, "/sbin/gpart modify -l %s -i %i %s", glabel, index, gpartition);
Expand All @@ -214,13 +218,13 @@ char *gpart_modify( char *cmd) {
char *gpart_add( char *cmd) {

int maxlen = ENTRY_MAX+2;
const char *gdisk = get_combo_box_disk();
const char *gdisk = get_combo_box_disk(1);
if( (gdisk == NULL) || (strlen(gdisk) > 25) ) {
free(cmd);
return NULL;
}

const char *gtype = get_combo_box_type();
const char *gtype = get_combo_box_type(1);
if( (gtype == NULL) || (strlen(gtype) > 25) ) {
free(cmd);
return NULL;
Expand All @@ -243,7 +247,7 @@ char *gpart_add( char *cmd) {
}

const gchar *glabel = gtk_entry_get_text(GTK_ENTRY (text_label));
if( (strlen(glabel) > 0) && (strlen(glabel) < maxlen ) ) {
if( gtk_widget_is_visible (text_label) && (strlen(glabel) > 0) && (strlen(glabel) < maxlen ) ) {
strncat(cmd, " -l ", 4);
strncat(cmd, glabel, maxlen);
strncat(cmd, " ", 1);
Expand All @@ -258,7 +262,7 @@ char *gpart_add( char *cmd) {

char *gpart_delete( char *cmd) {

char *gpartition = get_combo_box_partition();
char *gpartition = get_combo_box_partition(1);
if(gpartition == NULL) {
free(cmd);
return NULL;
Expand All @@ -277,7 +281,7 @@ char *gpart_delete( char *cmd) {
char *gpart_resize( char *cmd) {

int a = 0;
char *gpartition = get_combo_box_partition();
char *gpartition = get_combo_box_partition(1);
if(gpartition == NULL) {
free(cmd);
return NULL;
Expand Down Expand Up @@ -322,7 +326,7 @@ char *gpart_set( char *cmd ) {
else if((strncmp(gcmd, "unset", 5)) == 0 )
set = 0;

char *gpartition = get_combo_box_partition();
char *gpartition = get_combo_box_partition(1);
if(gpartition == NULL) {
free(cmd);
return NULL;
Expand Down Expand Up @@ -386,7 +390,7 @@ char *gpart_filesystem( char *cmd) {
strncat(cmd, "newfs_msdos ", 13);
const gchar *glabel = gtk_entry_get_text(GTK_ENTRY (text_label)); /* label */
if( (strlen(glabel) != 0) && (strlen(glabel) <= 20 ) ) {
strncat(cmd, " -l ", 4);
strncat(cmd, " -L ", 4);
strcat(cmd, glabel);
strncat(cmd, " ", 1);
}
Expand Down Expand Up @@ -437,7 +441,7 @@ char *gpart_bootcode( char *cmd ) {
}
if(strncmp(gf, "Partition", 9) == 0) {
i=0;
gpartition = get_combo_box_partition();
gpartition = get_combo_box_partition(1);
if( gpartition == NULL) {
msg(l.chose_partition);
free(cmd);
Expand All @@ -452,7 +456,7 @@ char *gpart_bootcode( char *cmd ) {

else if(strncmp(gf, "Disk", 4) == 0) {
i=1;
gdisk = get_combo_box_disk();
gdisk = get_combo_box_disk(1);
if( gdisk == NULL) {
msg(l.chose_disk);
free(cmd);
Expand Down
9 changes: 9 additions & 0 deletions disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ void create_text_entries();
void create_text_size();
void create_text_alignment();
void grid_attach_all();
void add_types( char *);

/* on_combos_changed.c */
void on_geom_changed();
void on_toplevel_changed();
void on_fs_changed();
void toplevel_entries();
void on_bootcode_changed();
void on_disks_changed();
void on_partitions_changed();
void on_scheme_changed();

/* subroutines.c */
char *get_disks();
Expand Down Expand Up @@ -187,6 +191,7 @@ void fsscan();
void info_cb(GtkMenuItem *, gpointer);
char *get_partition_type(char *);
char *get_type(char *);
char *get_scheme(const gchar *);

/* root.c */
char *sudo(char *, char *, int);
Expand All @@ -206,6 +211,10 @@ void redraw_cb (GtkMenuItem *, gpointer);

/* applyButtonClicked.c */
void on_edit_clicked (GtkMenuItem *, gpointer);
const char *get_combo_box_disk(int);
const char *get_combo_box_scheme();
char *get_combo_box_partition(int);
const char *get_combo_box_type(int);
char *gpart_destroy(char *);
char *gpart_create(char *);
char *gpart_modify(char *);
Expand Down
Loading

0 comments on commit bff8f04

Please sign in to comment.