Ejemplo n.º 1
0
/* return list type */
int
display_box (WPanel * panel, char **userp, char **minip, int *use_msformat, int num)
{
    int result = -1;
    Dlg_head *dd;
    char *section = NULL;
    size_t i;

    if (panel == NULL)
    {
        const char *p = get_nth_panel_name (num);
        panel = g_new (WPanel, 1);
        panel->list_type = list_full;
        panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
        panel->user_mini_status = 0;
        for (i = 0; i < LIST_TYPES; i++)
            panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
        section = g_strconcat ("Temporal:", p, (char *) NULL);
        if (!mc_config_has_group (mc_main_config, section))
        {
            g_free (section);
            section = g_strdup (p);
        }
        panel_load_setup (panel, section);
        g_free (section);
    }

    dd = display_init (panel->list_type, panel->user_format,
                       panel->user_mini_status, panel->user_status_format);

    if (run_dlg (dd) != B_CANCEL)
    {
        result = display_radio->sel;
        *userp = g_strdup (display_user_format->buffer);
        *minip = g_strdup (display_mini_status->buffer);
        *use_msformat = display_check_status->state & C_BOOL;
    }

    if (section != NULL)
    {
        g_free (panel->user_format);
        for (i = 0; i < LIST_TYPES; i++)
            g_free (panel->user_status_format[i]);
        g_free (panel);
    }

    destroy_dlg (dd);

    return result;
}
Ejemplo n.º 2
0
int
display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int num)
{
    int result, i;
    char *section = NULL;
    const char *p;

    if (!panel) {
        p = get_nth_panel_name (num);
        panel = g_new (WPanel, 1);
        panel->list_type = list_full;
        panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
        panel->user_mini_status = 0;
	for (i = 0; i < LIST_TYPES; i++)
    	    panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
        section = g_strconcat ("Temporal:", p, (char *) NULL);
        if (!profile_has_section (section, profile_name)) {
            g_free (section);
            section = g_strdup (p);
        }
        panel_load_setup (panel, section);
        g_free (section);
    }

    current_mode = panel->list_type;
    display_init (current_mode, panel->user_format, 
	panel->user_mini_status, panel->user_status_format);
		  
    run_dlg (dd);

    result = -1;
    
    if (section) {
        g_free (panel->user_format);
	for (i = 0; i < LIST_TYPES; i++)
	   g_free (panel->user_status_format [i]);
        g_free (panel);
    }
    
    if (dd->ret_value != B_CANCEL){
	result = my_radio->sel;
	*userp = g_strdup (user->buffer);
	*minip = g_strdup (status->buffer);
	*use_msformat = check_status->state & C_BOOL;
    }
    destroy_dlg (dd);

    return result;
}
Ejemplo n.º 3
0
Archivo: layout.c Proyecto: artzub/mc
static Widget *
restore_into_right_dir_panel (int idx, Widget * from_widget)
{
    Widget *new_widget = NULL;
    const char *saved_dir = panels[idx].last_saved_dir;
    gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing);
    const char *p_name = get_nth_panel_name (idx);

    if (last_was_panel)
        new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir);
    else
        new_widget = (Widget *) panel_new (p_name);

    return new_widget;
}
Ejemplo n.º 4
0
Archivo: layout.c Proyecto: m32/mc
static Widget *
restore_into_right_dir_panel (int idx, Widget * from_widget)
{
    WPanel *new_widget;
    const char *saved_dir = panels[idx].last_saved_dir;
    gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing);
    const char *p_name = get_nth_panel_name (idx);

    if (last_was_panel)
    {
        vfs_path_t *saved_dir_vpath;

        saved_dir_vpath = vfs_path_from_str (saved_dir);
        new_widget = panel_new_with_dir (p_name, saved_dir_vpath);
        vfs_path_free (saved_dir_vpath);
    }
    else
        new_widget = panel_new (p_name);

    return WIDGET (new_widget);
}
Ejemplo n.º 5
0
/* since a lot of routines depend on the current_panel variable */
void set_display_type (int num, int type)
{
    int x, y, cols, lines;
    int    the_other;		/* Index to the other panel */
    char   *file_name = 0;	/* For Quick view */
    Widget *new_widget, *old_widget;
    WPanel  *the_other_panel;

    x =y = cols = lines = 0;
    old_widget = 0;
    if (num >= MAX_VIEWS){
	fprintf (stderr, "Could not allocate more that %d views\n", MAX_VIEWS);
	abort ();
    }

    /* Check that we will have a WPanel * at least */
    the_other = 0;
    if (type != view_listing){
	the_other = num == 0 ? 1 : 0;

	if (panels [the_other].type != view_listing)
	    return;

    }
    
    /* Get rid of it */
    if (panels [num].widget){
	Widget *w = panels [num].widget;
	WPanel *panel = (WPanel *) panels [num].widget;
	
	x = w->x;
	y = w->y;
	cols  = w->cols;
	lines = w->lines;
	old_widget = panels [num].widget;

	if (panels [num].type == view_listing){
	    if (panel->frame_size == frame_full && type != view_listing){
		cols = COLS - first_panel_size;
		if (num == 1)
		    x = first_panel_size;
	    }
	}
#ifdef HAVE_TK
	tk_evalf ("container_clean %s", panel->widget.wcontainer);
#endif
    }

    new_widget = 0;
    
    switch (type){
    case view_listing:
	new_widget = (Widget *) panel_new (get_nth_panel_name (num));
	break;
	
    case view_info:
	new_widget = (Widget *) info_new ();
	
	break;

    case view_tree:
	new_widget = (Widget *) tree_new (1, 0, 0, 0, 0);
	break;

    case view_quick:
	new_widget = (Widget *) view_new (0, 0, 0, 0, 1);
	the_other_panel = (WPanel *) panels [the_other].widget;
	if (the_other_panel)
	    file_name =
		the_other_panel->dir.list[the_other_panel->selected].fname;
	else
	    file_name = "";
	
	view_init ((WView *) new_widget, 0, file_name, 0);
	break;
    }
    panels [num].type = type;
    panels [num].widget = (Widget *) new_widget;
    
    /* We set the same size the old widget had */
    widget_set_size ((Widget *) new_widget, y, x, lines, cols);
    
    /* We wanna the new widget at the same position */
    /* XView sets wcontainer to !0 <- Not XView, but we, when we create it */
    /* Ok, the XView support code does it */
    if (old_widget && old_widget->wcontainer){
	new_widget->wcontainer = old_widget->wcontainer;
	new_widget->area = old_widget->area;
    }

    /* We use replace to keep the circular list of the dialog in the */
    /* same state.  Maybe we could just kill it and then replace it  */
    if (midnight_dlg && old_widget){
	dlg_replace_widget (midnight_dlg, old_widget, panels [num].widget);
    }
    if (type == view_listing){
	if (num == 0)
	    left_panel = (WPanel *) new_widget;
	else
	    right_panel = (WPanel *) new_widget;
    }

    if (type == view_tree)
	the_tree = (WTree *) new_widget;

    /* Prevent current_panel's value from becoming invalid.
     * It's just a quick hack to prevent segfaults. Comment out and
     * try following:
     * - select left panel
     * - invoke menue left/tree
     * - as long as you stay in the left panel almost everything that uses
     *   cpanel causes segfault, e.g. C-Enter, C-x c, ...
     */

    if (type != view_listing)
	if (cpanel == (WPanel *) old_widget)
	    current_panel = num == 0 ? right_panel : left_panel;
}
Ejemplo n.º 6
0
/* This routine is deeply sticked to the two panels idea.
   What should it do in more panels. ANSWER - don't use it
   in any multiple panels environment. */
void swap_panels ()
{
    Widget tmp;
    Widget *tmp_widget;
    WPanel panel;
    WPanel *panel1, *panel2;
    int tmp_type;
    
#if 0
#ifdef HAVE_PORTABLE_TOKEN_PASTING
#define panelswap(e) panel.##e = panel1->##e; panel1->##e = panel2->##e; panel2->##e = panel.##e;
#define panelswapstr(e) strcpy (panel.##e, panel1->##e); strcpy (panel1->##e, panel2->##e); strcpy (panel2->##e, panel.##e);
#else
#define panelswap(e) panel./**/e = panel1->/**/e; panel1->/**/e = panel2->/**/e; panel2->/**/e = panel./**/e;
#define panelswapstr(e) strcpy (panel./**/e, panel1->/**/e); strcpy (panel1->/**/e, panel2->/**/e); strcpy (panel2->/**/e, panel./**/e);
#endif
#endif

#define panelswap(x) panel. x = panel1-> x; panel1-> x = panel2-> x; panel2-> x = panel. x;

#define panelswapstr(e) strcpy (panel. e, panel1-> e); \
                        strcpy (panel1-> e, panel2-> e); \
                        strcpy (panel2-> e, panel. e);
    panel1 = (WPanel *) panels [0].widget;
    panel2 = (WPanel *) panels [1].widget;
    if (panels [0].type == view_listing && panels [1].type == view_listing) {
        /* Change everything except format/sort/panel_name etc. */
        panelswap (dir);
        panelswap (active);
        panelswapstr (cwd);
        panelswapstr (lwd);
        panelswap (count);
        panelswap (marked);
        panelswap (dirs_marked);
        panelswap (total);
        panelswap (top_file);
        panelswap (selected);
        panelswap (is_panelized);
        panelswap (dir_stat);
	
        panel1->searching = 0;
        panel2->searching = 0;
        if (cpanel == panel1)
            current_panel = panel2;
        else
            current_panel = panel1;
        if (midnight_dlg->current->widget == panels [0].widget)
            dlg_select_widget (midnight_dlg, (void *) panels [1].widget);
        else if (midnight_dlg->current->widget == panels [1].widget)
            dlg_select_widget (midnight_dlg, (void *) panels [0].widget);
    } else {
	WPanel *tmp_panel;
	
	tmp_panel=right_panel;
	right_panel=left_panel;
	left_panel=tmp_panel;
	
	if (panels [0].type == view_listing) {
            if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) {
                free (panel1->panel_name);
                panel1->panel_name = strdup (get_nth_panel_name (1));
            }
        }
        if (panels [1].type == view_listing) {
            if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) {
                free (panel2->panel_name);
                panel2->panel_name = strdup (get_nth_panel_name (0));
            }
        }
        
        tmp.x = panels [0].widget->x;
        tmp.y = panels [0].widget->y;
        tmp.cols = panels [0].widget->cols;
        tmp.lines = panels [0].widget->lines;

        panels [0].widget->x = panels [1].widget->x;
        panels [0].widget->y = panels [1].widget->y;
        panels [0].widget->cols = panels [1].widget->cols;
        panels [0].widget->lines = panels [1].widget->lines;

        panels [1].widget->x = tmp.x;
        panels [1].widget->y = tmp.y;
        panels [1].widget->cols = tmp.cols;
        panels [1].widget->lines = tmp.lines;
        
        tmp_widget = panels [0].widget;
        panels [0].widget = panels [1].widget;
        panels [1].widget = tmp_widget;
        tmp_type = panels [0].type;
        panels [0].type = panels [1].type;
        panels [1].type = tmp_type;
    }
}
Ejemplo n.º 7
0
/* return list type */
int
panel_listing_box (WPanel * panel, int num, char **userp, char **minip, int *use_msformat,
                   int *brief_cols)
{
    int result = -1;
    char *section = NULL;

    if (panel == NULL)
    {
        const char *p;
        size_t i;

        p = get_nth_panel_name (num);
        panel = g_new (WPanel, 1);
        panel->list_type = list_full;
        panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
        panel->user_mini_status = 0;
        for (i = 0; i < LIST_TYPES; i++)
            panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
        section = g_strconcat ("Temporal:", p, (char *) NULL);
        if (!mc_config_has_group (mc_main_config, section))
        {
            g_free (section);
            section = g_strdup (p);
        }
        panel_load_setup (panel, section);
        g_free (section);
    }

    {
        int mini_user_status;
        char panel_brief_cols_in[BUF_TINY];
        char *panel_brief_cols_out = NULL;
        char *panel_user_format = NULL;
        char *mini_user_format = NULL;
        const char *cp;

        /* Controls whether the array strings have been translated */
        const char *list_types[LIST_TYPES] = {
            N_("&Full file list"),
            N_("&Brief file list:"),
            N_("&Long file list"),
            N_("&User defined:")
        };

        quick_widget_t quick_widgets[] = {
            /* *INDENT-OFF* */
            QUICK_START_COLUMNS,
                QUICK_RADIO (LIST_TYPES, list_types, &result, &panel_listing_types_id),
            QUICK_NEXT_COLUMN,
                QUICK_SEPARATOR (FALSE),
                QUICK_LABELED_INPUT (_ ("columns"), input_label_right, panel_brief_cols_in,
                                     "panel-brief-cols-input", &panel_brief_cols_out,
                                     &panel_brief_cols_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
            QUICK_STOP_COLUMNS,
            QUICK_INPUT (panel->user_format, "user-fmt-input", &panel_user_format,
                         &panel_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
            QUICK_SEPARATOR (TRUE),
            QUICK_CHECKBOX (N_("User &mini status"), &mini_user_status, &mini_user_status_id),
            QUICK_INPUT (panel->user_status_format[panel->list_type], "mini_input",
                         &mini_user_format, &mini_user_format_id, FALSE, FALSE, INPUT_COMPLETE_NONE),
            QUICK_BUTTONS_OK_CANCEL,
            QUICK_END
            /* *INDENT-ON* */
        };

        quick_dialog_t qdlg = {
            -1, -1, 48,
            N_("Listing mode"), "[Listing Mode...]",
            quick_widgets, panel_listing_callback, NULL
        };

        /* get hotkey of user-defined format string */
        cp = strchr (_(list_types[panel_listing_user_idx]), '&');
        if (cp != NULL && *++cp != '\0')
            listing_user_hotkey = g_ascii_tolower (*cp);

        mini_user_status = panel->user_mini_status;
        result = panel->list_type;
        status_format = panel->user_status_format;

        g_snprintf (panel_brief_cols_in, sizeof (panel_brief_cols_in), "%d", panel->brief_cols);

        if ((int) panel->list_type != panel_listing_brief_idx)
            quick_widgets[4].options = W_DISABLED;

        if ((int) panel->list_type != panel_listing_user_idx)
            quick_widgets[6].options = W_DISABLED;

        if (!mini_user_status)
            quick_widgets[9].options = W_DISABLED;

        if (quick_dialog (&qdlg) == B_CANCEL)
            result = -1;
        else
        {
            int cols;
            char *error = NULL;

            *userp = panel_user_format;
            *minip = mini_user_format;
            *use_msformat = mini_user_status;

            cols = strtol (panel_brief_cols_out, &error, 10);
            if (*error == '\0')
                *brief_cols = cols;
            else
                *brief_cols = panel->brief_cols;

            g_free (panel_brief_cols_out);
        }
    }

    if (section != NULL)
    {
        int i;

        g_free (panel->user_format);
        for (i = 0; i < LIST_TYPES; i++)
            g_free (panel->user_status_format[i]);
        g_free (panel);
    }

    return result;
}
Ejemplo n.º 8
0
Archivo: layout.c Proyecto: m32/mc
void
swap_panels (void)
{
    WPanel *panel1, *panel2;
    Widget *tmp_widget;

    panel1 = PANEL (panels[0].widget);
    panel2 = PANEL (panels[1].widget);

    if (panels[0].type == view_listing && panels[1].type == view_listing &&
            !mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE))
    {
        WPanel panel;

#define panelswap(x) panel.x = panel1->x; panel1->x = panel2->x; panel2->x = panel.x;

#define panelswapstr(e) strcpy (panel.e, panel1->e); \
                        strcpy (panel1->e, panel2->e); \
                        strcpy (panel2->e, panel.e);
        /* Change content and related stuff */
        panelswap (dir);
        panelswap (active);
        panelswap (cwd_vpath);
        panelswap (lwd_vpath);
        panelswap (marked);
        panelswap (dirs_marked);
        panelswap (total);
        panelswap (top_file);
        panelswap (selected);
        panelswap (is_panelized);
        panelswap (dir_stat);
#undef panelswapstr
#undef panelswap

        panel1->searching = FALSE;
        panel2->searching = FALSE;

        if (current_panel == panel1)
            current_panel = panel2;
        else
            current_panel = panel1;

        /* if sort options are different -> resort panels */
        if (memcmp (&panel1->sort_info, &panel2->sort_info, sizeof (dir_sort_options_t)) != 0)
        {
            panel_re_sort (other_panel);
            panel_re_sort (current_panel);
        }

        if (widget_is_active (panels[0].widget))
            dlg_select_widget (panels[1].widget);
        else if (widget_is_active (panels[1].widget))
            dlg_select_widget (panels[0].widget);
    }
    else
    {
        WPanel *tmp_panel;
        int x, y, cols, lines;
        int tmp_type;

        tmp_panel = right_panel;
        right_panel = left_panel;
        left_panel = tmp_panel;

        if (panels[0].type == view_listing)
        {
            if (strcmp (panel1->panel_name, get_nth_panel_name (0)) == 0)
            {
                g_free (panel1->panel_name);
                panel1->panel_name = g_strdup (get_nth_panel_name (1));
            }
        }
        if (panels[1].type == view_listing)
        {
            if (strcmp (panel2->panel_name, get_nth_panel_name (1)) == 0)
            {
                g_free (panel2->panel_name);
                panel2->panel_name = g_strdup (get_nth_panel_name (0));
            }
        }

        x = panels[0].widget->x;
        y = panels[0].widget->y;
        cols = panels[0].widget->cols;
        lines = panels[0].widget->lines;

        panels[0].widget->x = panels[1].widget->x;
        panels[0].widget->y = panels[1].widget->y;
        panels[0].widget->cols = panels[1].widget->cols;
        panels[0].widget->lines = panels[1].widget->lines;

        panels[1].widget->x = x;
        panels[1].widget->y = y;
        panels[1].widget->cols = cols;
        panels[1].widget->lines = lines;

        tmp_widget = panels[0].widget;
        panels[0].widget = panels[1].widget;
        panels[1].widget = tmp_widget;
        tmp_type = panels[0].type;
        panels[0].type = panels[1].type;
        panels[1].type = tmp_type;

        /* force update formats because of possible changed sizes */
        if (panels[0].type == view_listing)
            set_panel_formats (PANEL (panels[0].widget));
        if (panels[1].type == view_listing)
            set_panel_formats (PANEL (panels[1].widget));
    }
}