Exemple #1
0
void
edit_mc_menu_cmd (void)
{
    vfs_path_t *buffer_vpath;
    vfs_path_t *menufile_vpath;
    int dir = 0;

    query_set_sel (1);
    dir = query_dialog (_("Menu edit"),
                        _("Which menu file do you want to edit?"),
                        D_NORMAL, geteuid ()? 2 : 3, _("&Local"), _("&User"), _("&System Wide"));

    menufile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, NULL);

    if (!exist_file (vfs_path_get_last_path_str (menufile_vpath)))
    {
        vfs_path_free (menufile_vpath);
        menufile_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, NULL);
    }

    switch (dir)
    {
    case 0:
        buffer_vpath = vfs_path_from_str (MC_LOCAL_MENU);
        check_for_default (menufile_vpath, buffer_vpath);
        chmod (vfs_path_get_last_path_str (buffer_vpath), 0600);
        break;

    case 1:
        buffer_vpath = mc_config_get_full_vpath (MC_USERMENU_FILE);
        check_for_default (menufile_vpath, buffer_vpath);
        break;

    case 2:
        buffer_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_MENU, NULL);
        if (!exist_file (vfs_path_get_last_path_str (buffer_vpath)))
        {
            vfs_path_free (buffer_vpath);
            buffer_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_GLOBAL_MENU, NULL);
        }
        break;

    default:
        vfs_path_free (menufile_vpath);
        return;
    }

    do_edit (buffer_vpath);

    vfs_path_free (buffer_vpath);
    vfs_path_free (menufile_vpath);
}
Exemple #2
0
void
edit_mc_menu_cmd (void)
{
    char *buffer;
    char *menufile;
    int dir = 0;

    dir = query_dialog (_("Menu edit"),
                        _("Which menu file do you want to edit?"),
                        D_NORMAL, geteuid ()? 2 : 3, _("&Local"), _("&User"), _("&System Wide"));

    menufile = concat_dir_and_file (mc_global.sysconfig_dir, MC_GLOBAL_MENU);

    if (!exist_file (menufile))
    {
        g_free (menufile);
        menufile = concat_dir_and_file (mc_global.share_data_dir, MC_GLOBAL_MENU);
    }

    switch (dir)
    {
    case 0:
        buffer = g_strdup (MC_LOCAL_MENU);
        check_for_default (menufile, buffer);
        chmod (buffer, 0600);
        break;

    case 1:
        buffer = mc_config_get_full_path (MC_USERMENU_FILE);
        check_for_default (menufile, buffer);
        break;

    case 2:
        buffer = concat_dir_and_file (mc_global.sysconfig_dir, MC_GLOBAL_MENU);
        if (!exist_file (buffer))
        {
            g_free (buffer);
            buffer = concat_dir_and_file (mc_global.share_data_dir, MC_GLOBAL_MENU);
        }
        break;

    default:
        g_free (menufile);
        return;
    }

    do_edit (buffer);

    g_free (buffer);
    g_free (menufile);
}
Exemple #3
0
void
ext_cmd (void)
{
    char *buffer;
    char *extdir;
    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Extension file edit"),
                            _("Which extension file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_global.sysconfig_dir, MC_LIB_EXT);

    if (dir == 0)
    {
        buffer = mc_config_get_full_path (MC_FILEBIND_FILE);
        check_for_default (extdir, buffer);
        do_edit (buffer);
        g_free (buffer);
    }
    else if (dir == 1)
    {
        if (!exist_file (extdir))
        {
            g_free (extdir);
            extdir = concat_dir_and_file (mc_global.share_data_dir, MC_LIB_EXT);
        }
        do_edit (extdir);
    }
    g_free (extdir);
    flush_extension_file ();
}
Exemple #4
0
/* edit syntax file for mcedit */
void
edit_syntax_cmd (void)
{
    char *buffer;
    char *extdir;
    int dir = 0;

    if (geteuid () == 0) {
	dir =
	    query_dialog (_("Syntax file edit"),
			  _(" Which syntax file you want to edit? "), 0, 2,
			  _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");

    if (dir == 0) {
	buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);
	check_for_default (extdir, buffer);
	do_edit (buffer);
	g_free (buffer);
    } else if (dir == 1)
	do_edit (extdir);

    g_free (extdir);
}
Exemple #5
0
void ext_cmd (void)
{
    char *buffer;
    char *extdir;
    int  dir;

    dir = 0;
    if (geteuid () == 0){
	dir = query_dialog (_("Extension file edit"),
			    _(" Which extension file you want to edit? "), 0, 2,
			    _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_home, MC_LIB_EXT);

    if (dir == 0){
	buffer = concat_dir_and_file (home_dir, MC_USER_EXT);
	check_for_default (extdir, buffer);
	do_edit (buffer);
	g_free (buffer);
    } else if (dir == 1)
	do_edit (extdir);

   g_free (extdir);
   flush_extension_file ();
}
Exemple #6
0
/* where  = 1 - do edit file menu for mcedit */
static void
menu_edit_cmd (int where)
{
    char *buffer;
    char *menufile;
    int dir = 0;
    
    dir = query_dialog (
	_(" Menu edit "),
	_(" Which menu file do you want to edit? "), 
	0, geteuid() ? 2 : 3,
	_("&Local"), _("&Home"), _("&System Wide")
    );

    menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);

    switch (dir) {
	case 0:
	    buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
	    check_for_default (menufile, buffer);
	    break;

	case 1:
	    buffer = concat_dir_and_file (home_dir, where ? CEDIT_HOME_MENU : MC_HOME_MENU);
	    check_for_default (menufile, buffer);
	    break;
	
	case 2:
	    buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
	    break;

	default:
	   g_free (menufile);
	    return;
    }
    do_edit (buffer);
	if (dir == 0)
		chmod(buffer, 0600);
    g_free (buffer);
    g_free (menufile);
}
Exemple #7
0
void
edit_fhl_cmd (void)
{
    vfs_path_t *fhlfile_vpath = NULL;

    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Highlighting groups file edit"),
                            _("Which highlighting file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    fhlfile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL);

    if (dir == 0)
    {
        vfs_path_t *buffer_vpath;

        buffer_vpath = mc_config_get_full_vpath (MC_FHL_INI_FILE);
        check_for_default (fhlfile_vpath, buffer_vpath);
        do_edit (buffer_vpath);
        vfs_path_free (buffer_vpath);
    }
    else if (dir == 1)
    {
        if (!exist_file (vfs_path_get_last_path_str (fhlfile_vpath)))
        {
            vfs_path_free (fhlfile_vpath);
            fhlfile_vpath =
                vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL);
        }
        do_edit (fhlfile_vpath);
    }
    vfs_path_free (fhlfile_vpath);

    /* refresh highlighting rules */
    mc_fhl_free (&mc_filehighlight);
    mc_filehighlight = mc_fhl_new (TRUE);
}
Exemple #8
0
void
edit_fhl_cmd (void)
{
    char *buffer = NULL;
    char *fhlfile = NULL;

    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Highlighting groups file edit"),
                            _("Which highlighting file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE);

    if (dir == 0)
    {
        buffer = mc_config_get_full_path (MC_FHL_INI_FILE);
        check_for_default (fhlfile, buffer);
        do_edit (buffer);
        g_free (buffer);
    }
    else if (dir == 1)
    {
        if (!exist_file (fhlfile))
        {
            g_free (fhlfile);
            fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE);
        }
        do_edit (fhlfile);
    }
    g_free (fhlfile);

    /* refresh highlighting rules */
    mc_fhl_free (&mc_filehighlight);
    mc_filehighlight = mc_fhl_new (TRUE);
}
Exemple #9
0
void
ext_cmd (void)
{
    vfs_path_t *extdir_vpath;
    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Extension file edit"),
                            _("Which extension file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    extdir_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_LIB_EXT, NULL);

    if (dir == 0)
    {
        vfs_path_t *buffer_vpath;

        buffer_vpath = mc_config_get_full_vpath (MC_FILEBIND_FILE);
        check_for_default (extdir_vpath, buffer_vpath);
        do_edit (buffer_vpath);
        vfs_path_free (buffer_vpath);
    }
    else if (dir == 1)
    {
        if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
        {
            vfs_path_free (extdir_vpath);
            extdir_vpath = vfs_path_build_filename (mc_global.share_data_dir, MC_LIB_EXT, NULL);
        }
        do_edit (extdir_vpath);
    }
    vfs_path_free (extdir_vpath);
    flush_extension_file ();
}