Make the mkdir command actually work.

Fix all of the broken stuff that was done with the poor code.

Miguel
This commit is contained in:
Miguel de Icaza 1999-01-16 03:01:35 +00:00
parent 7da96495dc
commit 09bfb9e7de
8 changed files with 256 additions and 386 deletions

View File

@ -1,3 +1,8 @@
1999-01-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
* glayout.c (create_new_menu_from): Handle both the system dir and
the locally installed directory.
1999-01-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gtkdtree.c (gtk_dtree_do_select_dir): Select the node, and test

View File

@ -615,6 +615,7 @@ gnome_filter_cmd (GtkWidget *widget, WPanel *panel)
}
gtk_widget_destroy (filter_dlg);
}
void
gnome_open_files (GtkWidget *widget, WPanel *panel)
{
@ -647,8 +648,16 @@ gnome_open_files (GtkWidget *widget, WPanel *panel)
g_list_free (later);
}
void
gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde)
{
gnome_desktop_entry_launch (gde);
}
void
gnome_mkdir_cmd (GtkWidget *widget, WPanel *panel)
{
mkdir_cmd (panel);
}

View File

@ -1,22 +1,23 @@
#ifndef __GCMD_H
#define __GCMD_H
void gnome_listing_cmd (GtkWidget *widget, WPanel *panel);
void gnome_compare_panels (void);
void gnome_open_terminal (void);
void gnome_about_cmd (void);
void gnome_quit_cmd (void);
void gnome_open_panel (GtkWidget *widget, WPanel *panel);
int gnome_close_panel (GtkWidget *widget, WPanel *panel);
void gnome_icon_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_partial_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_full_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_custom_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_sort_cmd (GtkWidget *widget, WPanel *panel);
void gnome_select_all_cmd (GtkWidget *widget, WPanel *panel);
void gnome_filter_cmd (GtkWidget *widget, WPanel *panel);
void gnome_listing_cmd (GtkWidget *widget, WPanel *panel);
void gnome_compare_panels (void);
void gnome_open_terminal (void);
void gnome_about_cmd (void);
void gnome_quit_cmd (void);
void gnome_open_panel (GtkWidget *widget, WPanel *panel);
int gnome_close_panel (GtkWidget *widget, WPanel *panel);
void gnome_icon_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_partial_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_full_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_custom_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_sort_cmd (GtkWidget *widget, WPanel *panel);
void gnome_select_all_cmd (GtkWidget *widget, WPanel *panel);
void gnome_filter_cmd (GtkWidget *widget, WPanel *panel);
void gnome_external_panelize (GtkWidget *widget, WPanel *panel);
void gnome_open_files (GtkWidget *widget, WPanel *panel);
void gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde);
void gnome_open_files (GtkWidget *widget, WPanel *panel);
void gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde);
void gnome_mkdir_cmd (GtkWidget *widget, WPanel *panel);
#endif /* __GCMD_H */

View File

@ -282,7 +282,7 @@ GtkCheckMenuItem *gnome_toggle_snap (void);
GnomeUIInfo gnome_panel_new_menu [] = {
{ GNOME_APP_UI_ITEM, N_("_Terminal"), N_("Launch a new terminal in the current directory"), NULL},
/* If this ever changes, make sure you update create_new_menu accordingly. */
{ GNOME_APP_UI_ITEM, N_("_Directory..."), N_("Creates a new directory"), mkdir_cmd },
{ GNOME_APP_UI_ITEM, N_("_Directory..."), N_("Creates a new directory"), gnome_mkdir_cmd },
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
@ -441,72 +441,77 @@ static TbItems tb_items[] =
static GtkWidget *create_toolbar (GtkWidget * window, GtkWidget *widget)
{
GtkWidget *toolbar;
TbItems *t;
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
for (t = &tb_items[0]; t->text; t++) {
t->widget = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
t->text,
GtkWidget *toolbar;
TbItems *t;
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
for (t = &tb_items[0]; t->text; t++){
t->widget = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
t->text,
t->tooltip,
0,
gnome_stock_pixmap_widget (window, t->icon),
t->cb,
t->cb ? widget : 0);
}
return toolbar;
0,
gnome_stock_pixmap_widget (window, t->icon),
t->cb,
t->cb ? widget : 0);
}
return toolbar;
}
static void
create_new_menu (GnomeApp *app, WPanel *panel)
create_new_menu_from (GnomeApp *app, WPanel *panel, char *file)
{
gint pos;
GtkWidget *shell = NULL;
gchar *file, *file2, *test;
DIR *dir;
struct stat filedata;
struct dirent *dirstruc;
GnomeDesktopEntry *gde;
GtkWidget *menu;
char *file2;
/* what do we insert??? We check ${PREFIX}/share/gmc/templates for all .desktop files.
* We then add them to the menu, calling their exec script to launch the new app. */
file = gnome_datadir_file ("mc/templates");
if (file == NULL) {
return;
}
dir = opendir (file);
if (dir == NULL) {
g_free (file);
if (dir == NULL)
return;
}
shell = gnome_app_find_menu_pos (app->menubar, _("File/New/Directory..."), &pos);
menu = gtk_menu_item_new ();
gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
if (shell == NULL)
if (shell == NULL){
closedir (dir);
return;
while ((dirstruc = readdir (dir)) != NULL) {
}
while ((dirstruc = readdir (dir)) != NULL){
if (dirstruc->d_name[0] == '.')
continue;
file2 = g_concat_dir_and_file (file, dirstruc->d_name);
if ((stat (file2, &filedata) != -1) && (S_ISREG (filedata.st_mode))) {
if ((stat (file2, &filedata) != -1) && (S_ISREG (filedata.st_mode))){
char *test;
gde = gnome_desktop_entry_load (file2);
test = rindex(dirstruc->d_name, '.');
if (test == NULL || gde == NULL || strcmp (test, ".desktop")) {
if (test == NULL || gde == NULL || strcmp (test, ".desktop")){
g_free (file2);
continue;
}
if (!gnome_is_program_in_path (gde->tryexec)) {
if (!gnome_is_program_in_path (gde->tryexec)){
g_free (file2);
g_print ("yes!\n");
continue;
}
menu = gtk_menu_item_new_with_label (gde->name);
gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
/* This is really bad, but it works. */
if (gde->comment)
gtk_object_set_data (GTK_OBJECT (menu), "apphelper_statusbar_hint",
@ -517,6 +522,29 @@ create_new_menu (GnomeApp *app, WPanel *panel)
g_free (file2);
}
}
/**
* create_new_menu:
*
* Creates the child New menu items
*/
static void
create_new_menu (GnomeApp *app, WPanel *panel)
{
gchar *file, *file2;
file = gnome_unconditional_datadir_file ("mc/templates");
create_new_menu_from (app, panel, file);
file2 = gnome_datadir_file ("mc/templates");
if (file2 != NULL){
if (strcmp (file, file2) != 0)
create_new_menu_from (app, panel, file2);
}
g_free (file);
g_free (file2);
}
WPanel *
create_container (Dlg_head *h, char *name, char *geometry)
{

View File

@ -79,7 +79,7 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
g_slist_foreach (allocated, g_free, NULL);
g_slist_foreach (allocated, (GFunc) g_free, NULL);
g_slist_free (allocated);
g_free (buttons);

482
po/mc.pot

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,7 @@
1999-01-15 Miguel de Icaza <miguel@nuclecu.unam.mx>
* cmd.c (mkdir_cmd): Please, check your pointer usage.
Thu Jan 14 13:18:58 1999 Timur Bakeyev <mc@bat.ru>
* screen.c (string_file_[owner|group]): Workaround the fact, that some

View File

@ -386,7 +386,7 @@ void copymove_cmd_with_default (int copy, char *thedefault)
void mkdir_cmd (WPanel *panel)
{
char tempdir[MC_MAXPATHLEN];
char *tempdir;
char *dir;
panel = get_a_panel (panel);
@ -394,14 +394,13 @@ void mkdir_cmd (WPanel *panel)
if (!dir)
return;
if (dir[0] && (dir[0] == '/' || dir[0] == '~'))
strncat (tempdir, dir, MC_MAXPATHLEN);
else {
strncat (tempdir, panel->cwd, MC_MAXPATHLEN - strlen (dir) - 1);
strcat (tempdir, "/");
strcat (tempdir, dir);
}
printf ("%s\n", tempdir);
if (dir [0] && (dir [0] == '/' || dir [0] == '~'))
tempdir = strdup (dir);
else
tempdir = concat_dir_and_file (panel->cwd, dir);
free (dir);
save_cwds_stat ();
if (my_mkdir (tempdir, 0777) == 0){
update_panels (UP_OPTIMIZE, tempdir);