📄 mfm.c
字号:
5); gtk_widget_show (box); entrydrive = gtk_entry_new_with_max_length (26); gtk_widget_set_usize (entrydrive, 150, 0); gtk_entry_set_text (GTK_ENTRY (entrydrive), drives); gtk_entry_select_region (GTK_ENTRY (entrydrive), 0, strlen (drives)); gtk_box_pack_start (GTK_BOX (box), entrydrive, TRUE, FALSE, 0); gtk_widget_show (entrydrive); /* Display help */ box = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, TRUE, 5); gtk_widget_show (box); label = gtk_label_new (CONFPATH); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); gtk_widget_show (label); /* Create textfield for path */ box = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, TRUE, 5); gtk_widget_show (box); entrympath = gtk_entry_new_with_max_length (255); gtk_widget_set_usize (entrympath, 150, 0); gtk_entry_set_text (GTK_ENTRY (entrympath), mpath);/* gtk_entry_select_region(GTK_ENTRY(entrympath),0,strlen(mpath)); */ gtk_box_pack_start (GTK_BOX (box), entrympath, TRUE, FALSE, 0); gtk_widget_show (entrympath); /* Create buttons */ for (i = 0; i <= 1; i++) { msg[i].mvar = &flag; msg[i].msg = i + 1; button = gtk_button_new_with_label (buttonlabels[i]); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (dialog_event), msg + i); if (!i) { GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_grab_default (button); } gtk_widget_show (button); } gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", GTK_SIGNAL_FUNC (dialogclose_event), msg + 1); gtk_grab_add (dialog);#ifndef OLDGTK gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);#endif gtk_widget_show (dialog);#ifndef NOPIXMAPS gdk_window_set_icon (dialog->window, NULL, mfmpix, mfmmask);#endif while (!flag) { while (gtk_events_pending ()) gtk_main_iteration (); } if (flag == 1) { strcpy (newdrives, gtk_entry_get_text (GTK_ENTRY (entrydrive))); strcpy (drives, ""); for (pos = newdrives; *pos; pos++) if (strchr ("abcdefghijklmnopqrstuvwxyz", *pos)) { drives[strlen (drives) + 1] = '\0'; drives[strlen (drives)] = *pos; } strcpy (mpath, gtk_entry_get_text (GTK_ENTRY (entrympath))); strcpy (mtoolscommand, mpath); strcat (mtoolscommand, "/mtools"); if (!strchr (drives, leftside->drive) && leftside->drive) leftside->drive = '\0'; if (!strchr (drives, leftside->other->drive) && leftside->other->drive) leftside->other->drive = '\0'; set_combo_entries (leftside); set_combo_entries (leftside->other); } gtk_grab_remove (dialog); gtk_widget_destroy (dialog); if (debug) printf ("End config_event()\n");}intask_delete (const char *string1, const char *string2, const char *string3){ GtkWidget *dialog, *button; GtkWidget *label; msgenv msg[4]; int result = 0; int i; char *buttonlabels[] = { "Yes", "Skip", "All", "Cancel" }; if (debug) printf ("In ask_delete()\n"); dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), "Really delete files?"); gtk_widget_set_usize (GTK_WIDGET (dialog), 300, 200); /* Display warning */ label = gtk_label_new (string1); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); gtk_widget_show (label); label = gtk_label_new (string2); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); gtk_widget_show (label); label = gtk_label_new (string3); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); gtk_widget_show (label); /* Create buttons */ for (i = 0; i <= 3; i++) { msg[i].mvar = &result; msg[i].msg = i + 1; button = gtk_button_new_with_label (buttonlabels[i]); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (dialog_event), msg + i); gtk_widget_show (button); } gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", GTK_SIGNAL_FUNC (dialogclose_event), msg + 3); gtk_grab_add (dialog);#ifndef OLDGTK gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);#endif gtk_widget_show (dialog);#ifndef NOPIXMAPS gdk_window_set_icon (dialog->window, NULL, mfmpix, mfmmask);#endif while (!result) { while (gtk_events_pending ()) gtk_main_iteration (); } gtk_grab_remove (dialog); gtk_widget_destroy (dialog); if (debug) printf ("End ask_delete()\n"); return (result);}voidfiledelete_event (GtkWidget * widget, side * whichside){ GList *items; gint row; int allflag = 0; int allrflag = 0; int askresult; int status, dir, lex_result; pid_t childpid; int copypipe[2]; FILE *mcopyout; char *text, *path, *beginfile; if (debug) { printf ("In filedelete_event()\n"); printf (" whichside %p\n", whichside); } getpath (whichside, &path); if (whichside->drive) { shiftstring (path, 2); path[0] = whichside->drive; path[1] = ':'; } if (debug) printf (" path: %s+\n", path); beginfile = path + strlen (path); items = GTK_CLIST (whichside->list)->selection; while (items) { row = (gint) items->data; gtk_clist_get_text (GTK_CLIST (whichside->list), row, 1, &text); strcpy (beginfile, text); askresult = 2; dir = ((dentry *) gtk_clist_get_row_data (GTK_CLIST (whichside->list), row))->dir; if (!allrflag && dir) askresult = ask_delete ("", path, "\nis a directory. Do you want to remove this directory\nrecursively with all its subdirectories\?"); if (!allflag && !dir) askresult = ask_delete ("Deleting file\n\n", path, "\nDo you really want to do this\?"); if ((askresult == 1) || (askresult == 3) || (allrflag && dir) || (allflag && !dir)) { if (whichside->drive) { if (pipe (copypipe) < 0) { printf (" Error with pipe()\n"); gtk_main_quit (); } if ((childpid = fork ()) < 0) { printf (" Error with fork()\n"); exit (-1); } else if (childpid == 0) /* child */ { if (debug) printf (" in child\n"); close (copypipe[0]); if (copypipe[1] != STDERR_FILENO) { if (dup2 (copypipe[1], STDERR_FILENO) != STDERR_FILENO) { printf (" Error with dup2()\n"); gtk_main_quit (); } close (copypipe[1]); } execl (mtoolscommand, dir ? "mdeltree" : "mdel", path, NULL); printf (" error in execl()\n"); printf (" errno:%d\n", errno); _exit (-1); } else /* parent */ { if (debug) printf (" in parent\n"); close (copypipe[1]); if ((mcopyout = fdopen (copypipe[0], "r")) == NULL) { printf (" Error while opening pipe for reading\n"); gtk_main_quit (); } lex_result = er_interface (mcopyout); while (1) { while (gtk_events_pending ()) gtk_main_iteration (); if (waitpid (childpid, &status, WNOHANG) == childpid) { waitpid (childpid, &status, WUNTRACED); break; } } } } else { if (dir) delete_recursive (path); else unlink (path); } if ((askresult == 3) && dir) allrflag = 1; if ((askresult == 3) && !dir) allflag = 1; } if (askresult == 4) break; items = items->next; } free (path); if (debug) printf (" calling refresh_event()\n"); refresh_event (whichside->list, whichside); refresh_event (whichside->other->list, whichside->other); if (debug) printf ("End filedelete_event()\n");}voidfilerename_event (GtkWidget * widget, side * whichside){ GList *items; gint row; int flag, status, lex_result; pid_t childpid; int copypipe[2]; FILE *mcopyout; char *text, *path, *pathren, *hello, *filebegin, *newfile; if (debug) printf ("In filerename_event()\n"); getpath (whichside, &path); if (whichside->drive) { shiftstring (path, 2); path[0] = whichside->drive; path[1] = ':'; } filebegin = path + strlen (path); getpath (whichside, &pathren); if (whichside->drive) { shiftstring (pathren, 2); pathren[0] = whichside->drive; pathren[1] = ':'; } newfile = pathren + strlen (pathren); if (debug) printf (" path: %s+\n", path); hello = malloc ((260 + strlen (path)) * sizeof (char)); items = GTK_CLIST (whichside->list)->selection; while (items) { row = (gint) items->data; gtk_clist_get_text (GTK_CLIST (whichside->list), row, 1, &text); strcpy (filebegin, text); strcpy (newfile, text); strcpy (hello, "Enter new name for \""); strcat (hello, text); strcat (hello, "\" :"); if ((flag = entertext ("Rename file / directory", hello, newfile, 255)) == 1) { if (whichside->drive) { if (pipe (copypipe) < 0) { printf (" Error with pipe()\n"); gtk_main_quit (); } if ((childpid = fork ()) < 0) { printf (" Error with fork()\n"); exit (-1); } else if (childpid == 0) /* child */ { if (debug) printf (" in child\n"); close (copypipe[0]); if (copypipe[1] != STDERR_FILENO) { if (dup2 (copypipe[1], STDERR_FILENO) != STDERR_FILENO) { printf (" Error with dup2()\n"); gtk_main_quit (); } close (copypipe[1]); } execl (mtoolscommand, "mren", path, pathren, NULL); printf (" error in execl()\n"); printf (" errno:%d\n", errno); _exit (-1); } else /* parent */ { if (debug) printf (" in parent\n"); close (copypipe[1]); if ((mcopyout = fdopen (copypipe[0], "r")) == NULL) { printf (" Error while opening pipe for reading\n"); gtk_main_quit (); } lex_result = er_interface (mcopyout); while (1) { while (gtk_events_pending ()) gtk_main_iteration (); if (waitpid (childpid, &status, WNOHANG) == childpid) { waitpid (childpid, &status, WUNTRACED); break; } } } } else rename (path, pathren); } else break; items = items->next; } free (path); free (pathren); refresh_event (whichside->list, whichside); if (debug) printf ("End filerename_event()\n");}voidfileprint_event (GtkWidget * widget, side * whichside){ GList *items; gint row; char *text; char *path; char *command; char lprcommand[21] = "lpr"; if (debug) printf ("In fileprint_event()\n"); if (entertext ("Print files", "Enter printer command", lprcommand, 20) == 1) { getpath (whichside, &path); command = malloc ((strlen (path) + strlen (mpath) + 300) * sizeof (char)); items = GTK_CLIST (whichside->list)->selection; while (items) { row = (gint) items->data; gtk_clist_get_text (GTK_CLIST (whichside->list), row, 1, &text); if (! ((dentry *) gtk_clist_get_row_data (GTK_CLIST (whichside->list), row))->dir) { if (whichside->drive) { strcpy (command, mpath); strcat (command, "/mtype \" :"); command[strlen (mpath) + 8] = whichside->drive; strcat (command, path); strcat (command, text); strcat (command, "\" | "); strcat (command, lprcommand); system (command); } else { strcpy (command, lprcommand); strcat (command, " \""); strcat (command, path); strcat (command, text); strcat (command, "\""); system (command); } } items = items->next; } free (path); free (command); } if (debug) printf ("End fileprint_event()\n");}voidmkdir_event (GtkWidget * widget, side * whichside){ int flag; char *path, *filebegin; pid_t childpid; int copypipe[2]; FILE *mcopyout;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -