1
1

Make the mkdir command actually work.

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

Miguel
Этот коммит содержится в:
Miguel de Icaza 1999-01-16 03:01:35 +00:00
родитель 7da96495dc
Коммит 09bfb9e7de
8 изменённых файлов: 256 добавлений и 386 удалений

Просмотреть файл

@ -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> 1999-01-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gtkdtree.c (gtk_dtree_do_select_dir): Select the node, and test * gtkdtree.c (gtk_dtree_do_select_dir): Select the node, and test

Просмотреть файл

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

Просмотреть файл

@ -1,22 +1,23 @@
#ifndef __GCMD_H #ifndef __GCMD_H
#define __GCMD_H #define __GCMD_H
void gnome_listing_cmd (GtkWidget *widget, WPanel *panel); void gnome_listing_cmd (GtkWidget *widget, WPanel *panel);
void gnome_compare_panels (void); void gnome_compare_panels (void);
void gnome_open_terminal (void); void gnome_open_terminal (void);
void gnome_about_cmd (void); void gnome_about_cmd (void);
void gnome_quit_cmd (void); void gnome_quit_cmd (void);
void gnome_open_panel (GtkWidget *widget, WPanel *panel); void gnome_open_panel (GtkWidget *widget, WPanel *panel);
int gnome_close_panel (GtkWidget *widget, WPanel *panel); int gnome_close_panel (GtkWidget *widget, WPanel *panel);
void gnome_icon_view_cmd (GtkWidget *widget, WPanel *panel); void gnome_icon_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_partial_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_full_view_cmd (GtkWidget *widget, WPanel *panel);
void gnome_custom_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_sort_cmd (GtkWidget *widget, WPanel *panel);
void gnome_select_all_cmd (GtkWidget *widget, WPanel *panel); void gnome_select_all_cmd (GtkWidget *widget, WPanel *panel);
void gnome_filter_cmd (GtkWidget *widget, WPanel *panel); void gnome_filter_cmd (GtkWidget *widget, WPanel *panel);
void gnome_external_panelize (GtkWidget *widget, WPanel *panel); void gnome_external_panelize (GtkWidget *widget, WPanel *panel);
void gnome_open_files (GtkWidget *widget, WPanel *panel); void gnome_open_files (GtkWidget *widget, WPanel *panel);
void gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde); void gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde);
void gnome_mkdir_cmd (GtkWidget *widget, WPanel *panel);
#endif /* __GCMD_H */ #endif /* __GCMD_H */

Просмотреть файл

@ -282,7 +282,7 @@ GtkCheckMenuItem *gnome_toggle_snap (void);
GnomeUIInfo gnome_panel_new_menu [] = { GnomeUIInfo gnome_panel_new_menu [] = {
{ GNOME_APP_UI_ITEM, N_("_Terminal"), N_("Launch a new terminal in the current directory"), NULL}, { 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. */ /* 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 } { GNOME_APP_UI_ENDOFINFO, 0, 0 }
}; };
@ -441,72 +441,77 @@ static TbItems tb_items[] =
static GtkWidget *create_toolbar (GtkWidget * window, GtkWidget *widget) static GtkWidget *create_toolbar (GtkWidget * window, GtkWidget *widget)
{ {
GtkWidget *toolbar; GtkWidget *toolbar;
TbItems *t; TbItems *t;
toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
for (t = &tb_items[0]; t->text; t++) { toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
t->widget = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
t->text, for (t = &tb_items[0]; t->text; t++){
t->widget = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
t->text,
t->tooltip, t->tooltip,
0, 0,
gnome_stock_pixmap_widget (window, t->icon), gnome_stock_pixmap_widget (window, t->icon),
t->cb, t->cb,
t->cb ? widget : 0); t->cb ? widget : 0);
} }
return toolbar; return toolbar;
} }
static void static void
create_new_menu (GnomeApp *app, WPanel *panel) create_new_menu_from (GnomeApp *app, WPanel *panel, char *file)
{ {
gint pos; gint pos;
GtkWidget *shell = NULL; GtkWidget *shell = NULL;
gchar *file, *file2, *test;
DIR *dir; DIR *dir;
struct stat filedata; struct stat filedata;
struct dirent *dirstruc; struct dirent *dirstruc;
GnomeDesktopEntry *gde; GnomeDesktopEntry *gde;
GtkWidget *menu; 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); dir = opendir (file);
if (dir == NULL) { if (dir == NULL)
g_free (file);
return; return;
}
shell = gnome_app_find_menu_pos (app->menubar, _("File/New/Directory..."), &pos); shell = gnome_app_find_menu_pos (app->menubar, _("File/New/Directory..."), &pos);
menu = gtk_menu_item_new (); menu = gtk_menu_item_new ();
gtk_widget_show (menu); gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++); gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
if (shell == NULL) if (shell == NULL){
closedir (dir);
return; return;
while ((dirstruc = readdir (dir)) != NULL) { }
while ((dirstruc = readdir (dir)) != NULL){
if (dirstruc->d_name[0] == '.') if (dirstruc->d_name[0] == '.')
continue; continue;
file2 = g_concat_dir_and_file (file, dirstruc->d_name); 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); gde = gnome_desktop_entry_load (file2);
test = rindex(dirstruc->d_name, '.'); test = rindex(dirstruc->d_name, '.');
if (test == NULL || gde == NULL || strcmp (test, ".desktop")) {
if (test == NULL || gde == NULL || strcmp (test, ".desktop")){
g_free (file2); g_free (file2);
continue; continue;
} }
if (!gnome_is_program_in_path (gde->tryexec)) {
if (!gnome_is_program_in_path (gde->tryexec)){
g_free (file2); g_free (file2);
g_print ("yes!\n"); g_print ("yes!\n");
continue; continue;
} }
menu = gtk_menu_item_new_with_label (gde->name); menu = gtk_menu_item_new_with_label (gde->name);
gtk_widget_show (menu); gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++); gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
/* This is really bad, but it works. */ /* This is really bad, but it works. */
if (gde->comment) if (gde->comment)
gtk_object_set_data (GTK_OBJECT (menu), "apphelper_statusbar_hint", gtk_object_set_data (GTK_OBJECT (menu), "apphelper_statusbar_hint",
@ -517,6 +522,29 @@ create_new_menu (GnomeApp *app, WPanel *panel)
g_free (file2); 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 * WPanel *
create_container (Dlg_head *h, char *name, char *geometry) create_container (Dlg_head *h, char *name, char *geometry)
{ {

Просмотреть файл

@ -79,7 +79,7 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); 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_slist_free (allocated);
g_free (buttons); g_free (buttons);

482
po/mc.pot

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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> Thu Jan 14 13:18:58 1999 Timur Bakeyev <mc@bat.ru>
* screen.c (string_file_[owner|group]): Workaround the fact, that some * screen.c (string_file_[owner|group]): Workaround the fact, that some

Просмотреть файл

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