mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
1999-09-20 Federico Mena Quintero <federico@redhat.com>
The following is a patch from Volker Braun <volker.braun@physik.hu-berlin.de> to fix column resizing in the file panels. * gcustom-layout.c (custom_layout_apply): Set the default_user_format to the new format. * gscreen.c (panel_fill_panel_list): Set the column widths according to the previously stored values. Nuked the old and hideous panel_file_list_configure_contents(). (panel_file_list_configure): Connect to resize_column in the clist. (panel_create_file_list): Do not connect to size_allocate. (x_create_panel): Set the column width array for this panel. Set the user format from the default one if it exists. * gsession.c (PanelInfo): Added information about column widths and the user format. (save_panel_info): Save the complete information. (load_panel_info): Load the complete information. (free_panel_info): Free the user format. (idle_create_panels): Set the user format and column widths. 1999-09-20 Federico Mena Quintero <federico@redhat.com> The following is a patch from Volker Braun <volker.braun@physik.hu-berlin.de> to fix column resizing in the file panels. * setup.c (options): Declare the column width option values. (save_configure): Save the default user format. (load_setup): Load the default user format. * panel.h (WPanel): Added a field for the column widths.
This commit is contained in:
parent
0045150f92
commit
248d2ef5cc
@ -1,3 +1,27 @@
|
||||
1999-09-20 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
The following is a patch from Volker Braun
|
||||
<volker.braun@physik.hu-berlin.de> to fix column resizing in the
|
||||
file panels.
|
||||
|
||||
* gcustom-layout.c (custom_layout_apply): Set the
|
||||
default_user_format to the new format.
|
||||
|
||||
* gscreen.c (panel_fill_panel_list): Set the column widths
|
||||
according to the previously stored values.
|
||||
Nuked the old and hideous panel_file_list_configure_contents().
|
||||
(panel_file_list_configure): Connect to resize_column in the clist.
|
||||
(panel_create_file_list): Do not connect to size_allocate.
|
||||
(x_create_panel): Set the column width array for this panel. Set
|
||||
the user format from the default one if it exists.
|
||||
|
||||
* gsession.c (PanelInfo): Added information about column widths
|
||||
and the user format.
|
||||
(save_panel_info): Save the complete information.
|
||||
(load_panel_info): Load the complete information.
|
||||
(free_panel_info): Free the user format.
|
||||
(idle_create_panels): Set the user format and column widths.
|
||||
|
||||
1999-09-20 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* gdesktop.c (desktop_rescan_devices): Call gmount_setup_devices().
|
||||
@ -23,7 +47,7 @@
|
||||
1999-09-16 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmount.c: Remove the HAVE_MAGICDEV conditional.
|
||||
|
||||
|
||||
* Makefile.in magicdev.idl: Add the magicdev.idl file
|
||||
here to avoid creating dependency loops.
|
||||
|
||||
|
@ -63,7 +63,7 @@ custom_layout_add_clicked (GtkWidget *widget, GCustomLayout *layout)
|
||||
|
||||
tmp_name = gettext (info->name);
|
||||
new_row = gtk_clist_append (GTK_CLIST (layout->destList), &tmp_name);
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->destList),
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->destList),
|
||||
new_row,
|
||||
info);
|
||||
gtk_clist_select_row (GTK_CLIST (layout->destList), new_row, 0);
|
||||
@ -105,7 +105,7 @@ custom_layout_select_row (GtkWidget *widget, gint row, gint col, GdkEvent *event
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gtk_widget_set_sensitive (layout->addButton, TRUE);
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ custom_layout_create(GCustomLayout *layout, ColumnInfo *columns, gint ncolumns)
|
||||
GTK_SELECTION_BROWSE);
|
||||
gtk_clist_set_column_auto_resize(GTK_CLIST(layout->srcList), 0, 1);
|
||||
gtk_table_attach(GTK_TABLE(layout->table), vbox2, 0, 1, 0, 1,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
|
||||
|
||||
/* make list of currently displayed column types */
|
||||
@ -176,9 +176,9 @@ custom_layout_create(GCustomLayout *layout, ColumnInfo *columns, gint ncolumns)
|
||||
gtk_clist_set_reorderable (GTK_CLIST (layout->destList), TRUE);
|
||||
|
||||
gtk_table_attach(GTK_TABLE(layout->table), vbox2, 2, 3, 0, 1,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
||||
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
|
||||
|
||||
|
||||
/* add add/remove buttons in center */
|
||||
layout->addButton = gtk_button_new_with_label(_("Add"));
|
||||
layout->delButton = gtk_button_new_with_label(_("Remove"));
|
||||
@ -195,23 +195,23 @@ custom_layout_create(GCustomLayout *layout, ColumnInfo *columns, gint ncolumns)
|
||||
for (i = 0; i < ncolumns; i++) {
|
||||
tmp_name = gettext(columns[i].name);
|
||||
gtk_clist_append (GTK_CLIST (layout->srcList), &tmp_name);
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->srcList),
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->srcList),
|
||||
i,
|
||||
&columns[i]);
|
||||
|
||||
|
||||
g_hash_table_insert (layout->hash,
|
||||
columns[i].value,
|
||||
&columns[i]);
|
||||
}
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(layout->addButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(custom_layout_add_clicked),
|
||||
GTK_SIGNAL_FUNC(custom_layout_add_clicked),
|
||||
layout);
|
||||
gtk_signal_connect(GTK_OBJECT(layout->delButton), "clicked",
|
||||
GTK_SIGNAL_FUNC(custom_layout_del_clicked),
|
||||
GTK_SIGNAL_FUNC(custom_layout_del_clicked),
|
||||
layout);
|
||||
gtk_signal_connect(GTK_OBJECT(layout->srcList), "select_row",
|
||||
GTK_SIGNAL_FUNC(custom_layout_select_row),
|
||||
GTK_SIGNAL_FUNC(custom_layout_select_row),
|
||||
layout);
|
||||
gtk_signal_connect(GTK_OBJECT(layout->destList), "row_move",
|
||||
GTK_SIGNAL_FUNC(custom_layout_row_move),
|
||||
@ -231,7 +231,7 @@ custom_layout_set (GCustomLayout *layout, gchar *string)
|
||||
gchar **strings;
|
||||
ColumnInfo *info;
|
||||
gchar *tmp_name;
|
||||
|
||||
|
||||
gtk_clist_clear (GTK_CLIST (layout->destList));
|
||||
|
||||
/* skip over initial half or full */
|
||||
@ -239,15 +239,15 @@ custom_layout_set (GCustomLayout *layout, gchar *string)
|
||||
string++;
|
||||
while (*string && isspace(*string))
|
||||
string++;
|
||||
|
||||
|
||||
strings = g_strsplit (string, ",", -1);
|
||||
|
||||
|
||||
for (i=0; strings[i]; i++) {
|
||||
info = g_hash_table_lookup (layout->hash, strings[i]);
|
||||
if (info) {
|
||||
tmp_name = gettext (info->name);
|
||||
new_row = gtk_clist_append (GTK_CLIST (layout->destList), &tmp_name);
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->destList),
|
||||
gtk_clist_set_row_data (GTK_CLIST (layout->destList),
|
||||
new_row, info);
|
||||
}
|
||||
}
|
||||
@ -273,9 +273,9 @@ custom_layout_get (GCustomLayout *layout)
|
||||
GString *result;
|
||||
gchar *string;
|
||||
ColumnInfo *info;
|
||||
|
||||
|
||||
result = g_string_new ("full ");
|
||||
|
||||
|
||||
for (i=0; i<GTK_CLIST (layout->destList)->rows; i++) {
|
||||
if (i != 0)
|
||||
g_string_append_c (result, ',');
|
||||
@ -298,7 +298,7 @@ custom_layout_create_page (GnomePropertyBox *prop_box, WPanel *panel)
|
||||
custom_layout_create (layout, possible_columns, n_possible_columns);
|
||||
layout->prop_box = prop_box;
|
||||
layout->panel = panel;
|
||||
|
||||
|
||||
gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_box),
|
||||
layout->table,
|
||||
gtk_label_new (_("Custom View")));
|
||||
@ -308,7 +308,7 @@ custom_layout_create_page (GnomePropertyBox *prop_box, WPanel *panel)
|
||||
return layout;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
custom_layout_apply (GCustomLayout *layout)
|
||||
{
|
||||
gchar *format;
|
||||
@ -324,8 +324,11 @@ custom_layout_apply (GCustomLayout *layout)
|
||||
g_free (container->panel->user_format);
|
||||
container->panel->user_format = g_strdup (format);
|
||||
|
||||
g_free (default_user_format);
|
||||
default_user_format = g_strdup (format);
|
||||
|
||||
set_panel_formats (container->panel);
|
||||
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
|
174
gnome/gscreen.c
174
gnome/gscreen.c
@ -45,6 +45,21 @@
|
||||
# define MAX(a,b) ((a) > (b) ? a : b)
|
||||
#endif
|
||||
|
||||
/* Offsets within the default_column_width array for the different listing types */
|
||||
static const int column_width_pos[LIST_TYPES] = {
|
||||
GMC_COLUMNS_BRIEF,
|
||||
0,
|
||||
-1,
|
||||
GMC_COLUMNS_BRIEF + GMC_COLUMNS_DETAILED,
|
||||
-1
|
||||
};
|
||||
|
||||
/* Default column widths for file listings */
|
||||
int default_column_width[GMC_COLUMNS];
|
||||
|
||||
/* default format for custom view */
|
||||
char* default_user_format = NULL;
|
||||
|
||||
/* Whether to display the tree view on the left */
|
||||
int tree_panel_visible = -1;
|
||||
|
||||
@ -184,9 +199,10 @@ panel_fill_panel_list (WPanel *panel)
|
||||
const int selected = panel->selected;
|
||||
GtkCList *cl = CLIST_FROM_SW (panel->list);
|
||||
int i, col, type_col, color;
|
||||
int width, p;
|
||||
char **texts;
|
||||
|
||||
texts = g_new (char *, items+1);
|
||||
texts = g_new (char *, items + 1);
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (cl));
|
||||
gtk_clist_clear (GTK_CLIST (cl));
|
||||
@ -241,6 +257,16 @@ panel_fill_panel_list (WPanel *panel)
|
||||
/* This is needed as the gtk_clist_append changes selected under us :-( */
|
||||
panel->selected = selected;
|
||||
|
||||
p = column_width_pos[panel->list_type]; /* offset in column_width */
|
||||
g_assert (p >= 0);
|
||||
for (i = 0; i < items; i++) {
|
||||
width = panel->column_width[p + i];
|
||||
if (width == 0)
|
||||
width = gtk_clist_optimal_column_width (cl, i);
|
||||
|
||||
gtk_clist_set_column_width (cl, i, width);
|
||||
}
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (cl));
|
||||
}
|
||||
|
||||
@ -391,104 +417,6 @@ x_adjust_top_file (WPanel *panel)
|
||||
/* gtk_clist_moveto (GTK_CLIST (panel->list), panel->top_file, 0, 0.0, 0.0); */
|
||||
}
|
||||
|
||||
/*
|
||||
* These two constants taken from Gtk sources, hack to figure out how much
|
||||
* of the clist is visible
|
||||
*/
|
||||
#define COLUMN_INSET 3
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/*
|
||||
* Configures the columns title sizes for the panel->list CList widget
|
||||
*/
|
||||
static void
|
||||
panel_file_list_configure_contents (GtkWidget *sw, WPanel *panel, int main_width, int height)
|
||||
{
|
||||
GtkCList *clist;
|
||||
format_e *format = panel->format;
|
||||
int i, used_columns, expandables, items;
|
||||
int char_width, usable_pixels, extra_pixels, width;
|
||||
int total_columns, extra_columns;
|
||||
int expand_space, extra_space, shrink_space;
|
||||
int lost_pixels, display_the_mini_info;
|
||||
|
||||
/* Pass 1: Count minimum columns,
|
||||
* set field_len to default to the requested_field_len
|
||||
* and compute how much space we lost to the column decorations
|
||||
*/
|
||||
lost_pixels = used_columns = expandables = items = 0;
|
||||
char_width = gdk_string_width (sw->style->font, "xW") / 2;
|
||||
for (format = panel->format; format; format = format->next) {
|
||||
format->field_len = format->requested_field_len;
|
||||
if (!format->use_in_gui)
|
||||
continue;
|
||||
|
||||
if (format->use_in_gui == 2)
|
||||
used_columns += 2;
|
||||
else
|
||||
used_columns += format->field_len;
|
||||
|
||||
items++;
|
||||
if (format->expand)
|
||||
expandables++;
|
||||
lost_pixels += CELL_SPACING + (2 * COLUMN_INSET);
|
||||
}
|
||||
|
||||
/* The left scrollbar might take some space from us, use this information */
|
||||
if (GTK_WIDGET_VISIBLE (GTK_SCROLLED_WINDOW (sw)->vscrollbar)) {
|
||||
int scrollbar_width = GTK_WIDGET (GTK_SCROLLED_WINDOW (sw)->vscrollbar)->requisition.width;
|
||||
int scrollbar_space = GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (sw)->klass)->scrollbar_spacing;
|
||||
|
||||
lost_pixels += scrollbar_space + scrollbar_width;
|
||||
}
|
||||
|
||||
width = main_width - lost_pixels;
|
||||
|
||||
extra_pixels = width % char_width;
|
||||
usable_pixels = width - extra_pixels;
|
||||
total_columns = usable_pixels / char_width;
|
||||
extra_columns = total_columns - used_columns;
|
||||
if (extra_columns > 0 && expandables > 0) {
|
||||
expand_space = extra_columns / expandables;
|
||||
extra_space = extra_columns % expandables;
|
||||
} else
|
||||
extra_space = expand_space = 0;
|
||||
|
||||
/*
|
||||
* Hack: the default mini-info display only gets displayed
|
||||
* if panel->estimated_total is not zero, ie, if this has been
|
||||
* initialized for the first time.
|
||||
*/
|
||||
|
||||
display_the_mini_info = (panel->estimated_total == 0);
|
||||
panel->estimated_total = total_columns;
|
||||
|
||||
if (display_the_mini_info)
|
||||
display_mini_info (panel);
|
||||
|
||||
/* If we dont have enough space, shorten the fields */
|
||||
if (used_columns > total_columns) {
|
||||
expand_space = 0;
|
||||
shrink_space = (used_columns - total_columns) / items;
|
||||
} else
|
||||
shrink_space = 0;
|
||||
|
||||
clist = CLIST_FROM_SW (sw);
|
||||
|
||||
gtk_clist_freeze (clist);
|
||||
|
||||
for (i = 0, format = panel->format; format; format = format->next) {
|
||||
if (!format->use_in_gui)
|
||||
continue;
|
||||
|
||||
format->field_len += (format->expand ? expand_space : 0) - shrink_space;
|
||||
gtk_clist_set_column_width (clist, i, format->field_len * char_width);
|
||||
i++;
|
||||
}
|
||||
|
||||
gtk_clist_thaw (clist);
|
||||
}
|
||||
|
||||
static void
|
||||
panel_file_list_select_row (GtkWidget *file_list, gint row, gint column,
|
||||
GdkEvent *event, gpointer data)
|
||||
@ -516,28 +444,19 @@ panel_file_list_unselect_row (GtkWidget *widget, int row, int columns, GdkEvent
|
||||
panel->selected = 0;
|
||||
}
|
||||
|
||||
/* Figure out the number of visible lines in the panel */
|
||||
static void
|
||||
panel_file_list_compute_lines (GtkScrolledWindow *sw, WPanel *panel, int height)
|
||||
panel_file_list_resize_callback (GtkCList *clist, gint column, gint width, WPanel *panel)
|
||||
{
|
||||
int lost_pixels = 0;
|
||||
if (GTK_WIDGET_VISIBLE (sw->hscrollbar)) {
|
||||
int scrollbar_width = GTK_WIDGET (sw->hscrollbar)->requisition.width;
|
||||
int scrollbar_space = GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (sw)->klass)->scrollbar_spacing;
|
||||
format_e *format = panel->format;
|
||||
int i, p;
|
||||
|
||||
lost_pixels = scrollbar_space + scrollbar_width;
|
||||
}
|
||||
panel->widget.lines = (height-lost_pixels) / (CLIST_FROM_SW (sw)->row_height + CELL_SPACING);
|
||||
}
|
||||
p = column_width_pos[panel->list_type]; /* offset in column_width */
|
||||
g_assert (p >= 0);
|
||||
|
||||
static void
|
||||
panel_file_list_size_allocate_hook (GtkWidget *sw, GtkAllocation *allocation, WPanel *panel)
|
||||
{
|
||||
gtk_signal_handler_block_by_data (GTK_OBJECT (sw), panel);
|
||||
panel_file_list_configure_contents (sw, panel, allocation->width, allocation->height);
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (sw), panel);
|
||||
panel->column_width[p + column] = width;
|
||||
|
||||
panel_file_list_compute_lines (GTK_SCROLLED_WINDOW (sw), panel, allocation->height);
|
||||
/* make this default */
|
||||
memcpy (default_column_width, panel->column_width, sizeof (default_column_width));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -620,6 +539,10 @@ panel_file_list_configure (WPanel *panel, GtkWidget *sw, GtkWidget *file_list)
|
||||
gtk_signal_connect (GTK_OBJECT (file_list), "click_column",
|
||||
GTK_SIGNAL_FUNC (panel_file_list_column_callback), panel);
|
||||
|
||||
/* Set column resize callback */
|
||||
gtk_signal_connect (GTK_OBJECT (file_list), "resize_column",
|
||||
GTK_SIGNAL_FUNC (panel_file_list_resize_callback), panel);
|
||||
|
||||
/* Avoid clist's broken focusing behavior */
|
||||
GTK_WIDGET_UNSET_FLAGS (file_list, GTK_CAN_FOCUS);
|
||||
|
||||
@ -1309,10 +1232,6 @@ panel_create_file_list (WPanel *panel)
|
||||
panel_file_list_configure (panel, sw, file_list);
|
||||
g_free (titles);
|
||||
|
||||
gtk_signal_connect_after (GTK_OBJECT (sw), "size_allocate",
|
||||
GTK_SIGNAL_FUNC (panel_file_list_size_allocate_hook),
|
||||
panel);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (file_list), "select_row",
|
||||
GTK_SIGNAL_FUNC (panel_file_list_select_row),
|
||||
panel);
|
||||
@ -2384,6 +2303,7 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
panel->icons = panel_create_icon_display (panel);
|
||||
gtk_widget_show (panel->icons);
|
||||
|
||||
memcpy (panel->column_width, default_column_width, sizeof (default_column_width));
|
||||
panel->list = panel_create_file_list (panel);
|
||||
gtk_widget_ref (panel->icons);
|
||||
gtk_widget_ref (panel->list);
|
||||
@ -2471,8 +2391,8 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
dock = gnome_dock_item_new ("gmc-toolbar1",
|
||||
(GNOME_DOCK_ITEM_BEH_EXCLUSIVE
|
||||
| GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL));
|
||||
gtk_container_add (GTK_CONTAINER(dock), status_line);
|
||||
gnome_dock_add_item (GNOME_DOCK(GNOME_APP (panel->xwindow)->dock),
|
||||
gtk_container_add (GTK_CONTAINER (dock), status_line);
|
||||
gnome_dock_add_item (GNOME_DOCK (GNOME_APP (panel->xwindow)->dock),
|
||||
GNOME_DOCK_ITEM (dock), GNOME_DOCK_TOP, 1, 0, 0, FALSE);
|
||||
|
||||
gtk_widget_show_all (dock);
|
||||
@ -2484,14 +2404,14 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
* The status bar.
|
||||
*/
|
||||
ministatus_box = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME(ministatus_box), GTK_SHADOW_IN);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (ministatus_box), GTK_SHADOW_IN);
|
||||
|
||||
panel->status = gtk_label_new (_("Show all files"));
|
||||
gtk_misc_set_alignment (GTK_MISC (panel->status), 0.0, 0.0);
|
||||
gtk_misc_set_padding (GTK_MISC (panel->status), 2, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (panel->ministatus), ministatus_box, FALSE, FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER(ministatus_box), panel->status);
|
||||
gtk_container_add (GTK_CONTAINER (ministatus_box), panel->status);
|
||||
|
||||
gtk_widget_show (ministatus_box);
|
||||
gtk_widget_show (panel->status);
|
||||
@ -2562,6 +2482,12 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
panel->estimated_total = 0;
|
||||
|
||||
panel->timer_id = -1;
|
||||
|
||||
/* re-set the user_format explicitly */
|
||||
if (default_user_format != NULL) {
|
||||
g_free (panel->user_format);
|
||||
panel->user_format = g_strdup (default_user_format);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -24,6 +24,8 @@ static GnomeClient *master_client;
|
||||
/* Structure to hold information for a panel to be created */
|
||||
typedef struct {
|
||||
char *cwd;
|
||||
int column_width[GMC_COLUMNS];
|
||||
char *user_format;
|
||||
} PanelInfo;
|
||||
|
||||
|
||||
@ -31,16 +33,27 @@ typedef struct {
|
||||
static void
|
||||
save_panel_info (WPanel *panel)
|
||||
{
|
||||
char section[50];
|
||||
char *key;
|
||||
char section[50];
|
||||
char key[50];
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
sprintf (section, "panel %d", panel->id);
|
||||
g_snprintf (section, sizeof (section), "panel %d", panel->id);
|
||||
|
||||
key = g_strconcat (section, "/cwd", NULL);
|
||||
gnome_config_set_string (key, panel->cwd);
|
||||
g_free (key);
|
||||
path = g_strconcat (section, "/cwd", NULL);
|
||||
gnome_config_set_string (path, panel->cwd);
|
||||
g_free (path);
|
||||
|
||||
/* FIXME: save information about list column sizes, etc. */
|
||||
path = g_strconcat (section, "/user_format", NULL);
|
||||
gnome_config_set_string (path, panel->user_format);
|
||||
g_free (path);
|
||||
|
||||
for (i = 0; i < GMC_COLUMNS; i++) {
|
||||
g_snprintf (key, sizeof (key), "/column_width_%i", i);
|
||||
path = g_strconcat (section, key, NULL);
|
||||
gnome_config_set_int (path, panel->column_width[i]);
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
/* Loads a panel from the information in the specified gnome-config file/section */
|
||||
@ -49,7 +62,9 @@ load_panel_info (char *file, char *section)
|
||||
{
|
||||
PanelInfo *pi;
|
||||
char *prefix;
|
||||
char *cwd;
|
||||
char *cwd, *user_format;
|
||||
char key[50];
|
||||
int i;
|
||||
|
||||
pi = NULL;
|
||||
|
||||
@ -59,10 +74,25 @@ load_panel_info (char *file, char *section)
|
||||
|
||||
cwd = gnome_config_get_string ("cwd");
|
||||
if (cwd) {
|
||||
pi = g_new (PanelInfo, 1);
|
||||
pi->cwd = cwd;
|
||||
} else
|
||||
g_warning ("Could not read panel data for \"%s\"", prefix);
|
||||
gnome_config_pop_prefix ();
|
||||
g_free (prefix);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pi = g_new (PanelInfo, 1);
|
||||
pi->cwd = cwd;
|
||||
|
||||
user_format = gnome_config_get_string ("user_format");
|
||||
if (!user_format)
|
||||
user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||
|
||||
pi->user_format = user_format;
|
||||
|
||||
for (i = 0; i < GMC_COLUMNS; i++) {
|
||||
g_snprintf (key, sizeof (key), "column_width_%i=0", i);
|
||||
pi->column_width[i] = gnome_config_get_int_with_default (key, NULL);
|
||||
}
|
||||
|
||||
gnome_config_pop_prefix ();
|
||||
g_free (prefix);
|
||||
@ -75,6 +105,7 @@ static void
|
||||
free_panel_info (PanelInfo *pi)
|
||||
{
|
||||
g_free (pi->cwd);
|
||||
g_free (pi->user_format);
|
||||
g_free (pi);
|
||||
}
|
||||
|
||||
@ -84,12 +115,18 @@ idle_create_panels (gpointer data)
|
||||
{
|
||||
GSList *panels, *p;
|
||||
PanelInfo *pi;
|
||||
WPanel *panel;
|
||||
|
||||
panels = data;
|
||||
|
||||
for (p = panels; p; p = p->next) {
|
||||
pi = p->data;
|
||||
new_panel_at (pi->cwd);
|
||||
panel = new_panel_at (pi->cwd);
|
||||
|
||||
g_free (panel->user_format);
|
||||
panel->user_format = g_strdup (pi->user_format);
|
||||
memcpy (panel->column_width, pi->column_width, sizeof (pi->column_width));
|
||||
|
||||
free_panel_info (pi);
|
||||
}
|
||||
|
||||
@ -149,7 +186,7 @@ create_default_panel (const char *startup_dir)
|
||||
mc_get_current_wd (buf, MC_MAXPATHLEN);
|
||||
else
|
||||
dir = startup_dir;
|
||||
|
||||
|
||||
gtk_idle_add_priority (GTK_PRIORITY_DEFAULT + 1, idle_create_default_panel, g_strdup (dir));
|
||||
}
|
||||
|
||||
@ -194,7 +231,7 @@ session_die (GnomeClient *client, gpointer data)
|
||||
/**
|
||||
* session_init:
|
||||
* @void:
|
||||
*
|
||||
*
|
||||
* Initializes session management. Contacts the master client and
|
||||
* connects the appropriate signals.
|
||||
**/
|
||||
@ -217,8 +254,8 @@ session_init ()
|
||||
|
||||
/**
|
||||
* session_load:
|
||||
* @void:
|
||||
*
|
||||
* @void:
|
||||
*
|
||||
* Loads the saved session.
|
||||
**/
|
||||
void
|
||||
@ -237,7 +274,7 @@ session_load (void)
|
||||
* session_set_restart:
|
||||
* @restart: TRUE if it should restart immediately, FALSE if it should restart
|
||||
* never.
|
||||
*
|
||||
*
|
||||
* Sets the restart style of the session-managed client.
|
||||
**/
|
||||
void
|
||||
|
@ -1,3 +1,15 @@
|
||||
1999-09-20 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
The following is a patch from Volker Braun
|
||||
<volker.braun@physik.hu-berlin.de> to fix column resizing in the
|
||||
file panels.
|
||||
|
||||
* setup.c (options): Declare the column width option values.
|
||||
(save_configure): Save the default user format.
|
||||
(load_setup): Load the default user format.
|
||||
|
||||
* panel.h (WPanel): Added a field for the column widths.
|
||||
|
||||
1999-09-19 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* user.c (check_patterns): char* is used instead of char [] in sizeof
|
||||
@ -10,7 +22,7 @@
|
||||
to mad.[ch]
|
||||
|
||||
* option.c: Include files reordered in order to make it compile with
|
||||
--with-debug
|
||||
--with-debug
|
||||
|
||||
* mad.c (mad_init): New function. Initialize debug FILE pointer to
|
||||
stderr (moved to a function because not on every system stderr is
|
||||
|
19
src/panel.h
19
src/panel.h
@ -9,6 +9,22 @@
|
||||
|
||||
#define LIST_TYPES 5
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
/* Keep the following in sync with setup.c */
|
||||
|
||||
/* Number of columns that each mode requires */
|
||||
#define GMC_COLUMNS_BRIEF 2 /* brief view */
|
||||
#define GMC_COLUMNS_DETAILED 4 /* detailed view */
|
||||
#define GMC_COLUMNS_CUSTOM 15 /* custom view */
|
||||
#define GMC_COLUMNS (GMC_COLUMNS_BRIEF + GMC_COLUMNS_DETAILED + GMC_COLUMNS_CUSTOM)
|
||||
|
||||
/* Default column widths */
|
||||
extern int default_column_width[GMC_COLUMNS];
|
||||
|
||||
/* custom listing format */
|
||||
extern char *default_user_format;
|
||||
#endif
|
||||
|
||||
enum list_types {
|
||||
list_full, /* Name, size, perm/date */
|
||||
list_brief, /* Name */
|
||||
@ -144,6 +160,9 @@ typedef struct {
|
||||
void *current_dir; /* A WInput* */
|
||||
int estimated_total;
|
||||
|
||||
/* default column layout */
|
||||
int column_width[GMC_COLUMNS];
|
||||
|
||||
/* navigation buttons */
|
||||
void *back_b;
|
||||
void *fwd_b;
|
||||
|
84
src/setup.c
84
src/setup.c
@ -1,11 +1,11 @@
|
||||
/* Setup loading/saving.
|
||||
Copyright (C) 1994 Miguel de Icaza
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ -134,7 +134,7 @@ static struct {
|
||||
{ "tree", view_tree },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
static struct {
|
||||
char *opt_name;
|
||||
int *opt_addr;
|
||||
@ -226,7 +226,7 @@ static struct {
|
||||
(follow links, stable symlinks) -Norbert */
|
||||
{ "tree_navigation_flag", &tree_navigation_flag },
|
||||
#endif
|
||||
#ifdef USE_VFS
|
||||
#ifdef USE_VFS
|
||||
{ "vfs_timeout", &vfs_timeout },
|
||||
#ifdef USE_NETCODE
|
||||
{ "ftpfs_directory_timeout", &ftpfs_directory_timeout },
|
||||
@ -264,6 +264,29 @@ static struct {
|
||||
{ "desktop_arr_rows", &desktop_arr_rows },
|
||||
{ "tree_panel_visible", &tree_panel_visible },
|
||||
{ "we_can_afford_the_speed", &we_can_afford_the_speed },
|
||||
|
||||
/* Keep the following in sync with panel.h */
|
||||
{ "column_width_brief_icon", &default_column_width[0] },
|
||||
{ "column_width_brief_filename", &default_column_width[1] },
|
||||
{ "column_width_detailed_icon", &default_column_width[2] },
|
||||
{ "column_width_detailed_filename", &default_column_width[3] },
|
||||
{ "column_width_detailed_size", &default_column_width[4] },
|
||||
{ "column_width_detailed_mtime", &default_column_width[5] },
|
||||
{ "column_width_custom_0", &default_column_width[6] },
|
||||
{ "column_width_custom_1", &default_column_width[7] },
|
||||
{ "column_width_custom_2", &default_column_width[8] },
|
||||
{ "column_width_custom_3", &default_column_width[9] },
|
||||
{ "column_width_custom_4", &default_column_width[10] },
|
||||
{ "column_width_custom_5", &default_column_width[11] },
|
||||
{ "column_width_custom_6", &default_column_width[12] },
|
||||
{ "column_width_custom_7", &default_column_width[13] },
|
||||
{ "column_width_custom_8", &default_column_width[14] },
|
||||
{ "column_width_custom_9", &default_column_width[15] },
|
||||
{ "column_width_custom_10", &default_column_width[16] },
|
||||
{ "column_width_custom_11", &default_column_width[17] },
|
||||
{ "column_width_custom_12", &default_column_width[18] },
|
||||
{ "column_width_custom_13", &default_column_width[19] },
|
||||
{ "column_width_custom_14", &default_column_width[20] },
|
||||
#else
|
||||
{ "nice_rotating_dash", &nice_rotating_dash },
|
||||
{ "horizontal_split", &horizontal_split },
|
||||
@ -276,7 +299,7 @@ panel_save_setup (WPanel *panel, char *section)
|
||||
{
|
||||
char buffer [BUF_TINY];
|
||||
int i;
|
||||
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->reverse);
|
||||
save_string (section, "reverse", buffer, profile_name);
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->case_sensitive);
|
||||
@ -293,16 +316,16 @@ panel_save_setup (WPanel *panel, char *section)
|
||||
save_string (section, PORT_LIST_MODE_NAME, list_types [i].key, profile_name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
save_string (section, "user_format",
|
||||
panel->user_format, profile_name);
|
||||
|
||||
|
||||
for (i = 0; i < LIST_TYPES; i++){
|
||||
g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
|
||||
save_string (section, buffer,
|
||||
save_string (section, buffer,
|
||||
panel->user_status_format [i], profile_name);
|
||||
}
|
||||
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->user_mini_status);
|
||||
save_string (section, "user_mini_status", buffer,
|
||||
profile_name);
|
||||
@ -338,6 +361,10 @@ save_configure (void)
|
||||
for (i = 0; options [i].opt_name; i++)
|
||||
set_int (profile, options [i].opt_name, *options [i].opt_addr);
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
save_string (app_text, "default_user_format", default_user_format, profile_name);
|
||||
#endif
|
||||
|
||||
g_free (profile);
|
||||
}
|
||||
|
||||
@ -345,7 +372,7 @@ static void
|
||||
panel_save_type (char *section, int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; panel_types [i].opt_name; i++)
|
||||
if (panel_types [i].opt_type == type){
|
||||
save_string (section, "display", panel_types [i].opt_name,
|
||||
@ -396,7 +423,7 @@ save_setup (void)
|
||||
save_panelize ();
|
||||
save_panel_types ();
|
||||
/* directory_history_save (); */
|
||||
|
||||
|
||||
#ifdef USE_VFS
|
||||
#ifdef USE_NETCODE
|
||||
WritePrivateProfileString ("Misc", "ftpfs_password",
|
||||
@ -415,10 +442,10 @@ panel_load_setup (WPanel *panel, char *section)
|
||||
{
|
||||
int i;
|
||||
char buffer [BUF_TINY];
|
||||
|
||||
|
||||
panel->reverse = load_int (section, "reverse", 0);
|
||||
panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
|
||||
|
||||
|
||||
/* Load sort order */
|
||||
load_string (section, "sort_order", "name", buffer, sizeof (buffer));
|
||||
panel->sort_type = (sortfn *) sort_name;
|
||||
@ -456,7 +483,7 @@ panel_load_setup (WPanel *panel, char *section)
|
||||
g_strdup (get_profile_string (section, buffer,
|
||||
DEFAULT_USER_FORMAT, profile_name));
|
||||
}
|
||||
|
||||
|
||||
panel->user_mini_status =
|
||||
load_int (section, "user_mini_status", 0);
|
||||
|
||||
@ -466,7 +493,7 @@ static void
|
||||
load_layout (char *profile_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; layout [i].opt_name; i++)
|
||||
*layout [i].opt_addr =
|
||||
load_int ("Layout", layout [i].opt_name,
|
||||
@ -478,9 +505,9 @@ load_mode (char *section)
|
||||
{
|
||||
char buffer [20];
|
||||
int i;
|
||||
|
||||
|
||||
int mode = view_listing;
|
||||
|
||||
|
||||
/* Load the display mode */
|
||||
load_string (section, "display", "listing", buffer, sizeof (buffer));
|
||||
|
||||
@ -498,7 +525,7 @@ do_load_string (char *s, char *ss, char *def)
|
||||
{
|
||||
char *buffer = g_malloc (128);
|
||||
char *p;
|
||||
|
||||
|
||||
load_string (s, ss, def, buffer, 128);
|
||||
|
||||
p = g_strdup (buffer);
|
||||
@ -515,7 +542,7 @@ setup_init (void)
|
||||
|
||||
if (profile_name)
|
||||
return profile_name;
|
||||
|
||||
|
||||
buffer = concat_dir_and_file (home_dir, PROFILE_NAME);
|
||||
inifile = concat_dir_and_file (mc_home, "mc.ini");
|
||||
if (exist_file (buffer)){
|
||||
@ -527,7 +554,7 @@ setup_init (void)
|
||||
profile = buffer;
|
||||
}
|
||||
g_free (inifile);
|
||||
|
||||
|
||||
profile_name = profile;
|
||||
|
||||
return profile;
|
||||
@ -537,7 +564,7 @@ void
|
||||
load_setup (void)
|
||||
{
|
||||
char *profile;
|
||||
|
||||
|
||||
int i;
|
||||
#ifdef USE_NETCODE
|
||||
extern char *ftpfs_proxy_host;
|
||||
@ -549,6 +576,11 @@ load_setup (void)
|
||||
*options [i].opt_addr =
|
||||
get_int (profile, options [i].opt_name, *options [i].opt_addr);
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
g_free (default_user_format);
|
||||
default_user_format = do_load_string (app_text, "default_user_format", DEFAULT_USER_FORMAT);
|
||||
#endif
|
||||
|
||||
load_layout (profile);
|
||||
|
||||
load_panelize ();
|
||||
@ -559,10 +591,10 @@ load_setup (void)
|
||||
/* At least one of the panels is a listing panel */
|
||||
if (startup_left_mode != view_listing && startup_right_mode!=view_listing)
|
||||
startup_left_mode = view_listing;
|
||||
|
||||
|
||||
if (!other_dir){
|
||||
char *buffer;
|
||||
|
||||
|
||||
buffer = (char*) g_malloc (MC_MAXPATHLEN);
|
||||
load_string ("Dirs", "other_dir", ".", buffer,
|
||||
MC_MAXPATHLEN);
|
||||
@ -576,12 +608,12 @@ load_setup (void)
|
||||
#endif
|
||||
boot_current_is_left =
|
||||
GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile);
|
||||
|
||||
|
||||
load_string ("Misc", "find_ignore_dirs", "", setup_color_string,
|
||||
sizeof (setup_color_string));
|
||||
if (setup_color_string [0])
|
||||
find_ignore_dirs = g_strconcat (":", setup_color_string, ":", NULL);
|
||||
|
||||
|
||||
/* The default color and the terminal dependent color */
|
||||
load_string ("Colors", "base_color", "", setup_color_string,
|
||||
sizeof (setup_color_string));
|
||||
@ -643,7 +675,7 @@ load_keys_from_section (char *terminal, char *profile_name)
|
||||
g_free (section_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
key_code = lookup_key (key);
|
||||
|
Loading…
Reference in New Issue
Block a user