Lots of changes:
- GNOME edition now compiles without any trace of the text mode dependencies. - We no longer link with libraries we do not use (crypt, gpm), this fixes the recent bug reports. - More tree updates, enhancements. Miguel.
Этот коммит содержится в:
родитель
af1a952ea0
Коммит
aaa7b5e9a2
@ -1,3 +1,8 @@
|
||||
1998-12-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* configure.in (slang_use_system_installed_lib): Define slang
|
||||
here, to avoid having this on LIBS.
|
||||
|
||||
1998-11-26 Herbert Valerio Riedel <hvr@hvrlab.ml.org>
|
||||
|
||||
* gtkedit.c: changed occurence of 'va_list *ap' to 'va_list ap'
|
||||
|
16
configure.in
16
configure.in
@ -220,12 +220,14 @@ dnl
|
||||
AC_CHECK_HEADERS(sys/select.h)
|
||||
|
||||
dnl
|
||||
dnl On SCO, crypt is on libcrypt.a
|
||||
dnl On SCO and some SVR4, crypt is on libcrypt.a
|
||||
dnl grantpt in libpt.a
|
||||
dnl
|
||||
LCRYPT=""
|
||||
AC_CHECK_FUNCS(crypt, , [
|
||||
AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt",[
|
||||
AC_CHECK_LIB(crypt_i, crypt, LIBS="$LIBS -lcrypt_i")])])
|
||||
AC_CHECK_LIB(crypt, crypt, LCRYPT="-lcrypt",[
|
||||
AC_CHECK_LIB(crypt_i, crypt, LCRYPT="-lcrypt_i")])])
|
||||
AC_SUBST(LCRYPT)
|
||||
|
||||
dnl This is the correct version
|
||||
dnl AC_CHECK_FUNCS(grantpt, , AC_CHECK_LIB(pt, grantpt))
|
||||
@ -518,6 +520,7 @@ AC_ARG_WITH(vcurses,
|
||||
)
|
||||
|
||||
mouse_lib="xterm only"
|
||||
LGPM=""
|
||||
AC_ARG_WITH(gpm-mouse,
|
||||
[--with-gpm-mouse[=base-dir] Compile with gpm mouse support],[
|
||||
if test x$withval != xno
|
||||
@ -529,13 +532,13 @@ AC_ARG_WITH(gpm-mouse,
|
||||
fi
|
||||
AC_DEFINE(HAVE_LIBGPM)
|
||||
mouse_lib="GPM and xterm"
|
||||
LIBS="$LIBS -lgpm"
|
||||
LGPM="-lgpm"
|
||||
fi
|
||||
],[
|
||||
AC_CHECK_LIB(gpm, Gpm_Repeat,[
|
||||
AC_DEFINE(HAVE_LIBGPM)
|
||||
mouse_lib="GPM and xterm"
|
||||
LIBS="$LIBS -lgpm"],[
|
||||
LGPM="-lgpm"],[
|
||||
if test $system = Linux
|
||||
then
|
||||
AC_MSG_WARN("libgpm.a is missing or older than 0.18")
|
||||
@ -543,6 +546,7 @@ AC_ARG_WITH(gpm-mouse,
|
||||
], $LIBS)
|
||||
]
|
||||
)
|
||||
AC_SUBST(LGPM)
|
||||
|
||||
AC_ARG_WITH(ncurses,
|
||||
[--with-ncurses[=base-dir] Compile with ncurses/locate base dir],
|
||||
@ -1029,7 +1033,7 @@ AC_DEFUN(AC_WITH_SLANG,
|
||||
if $slang_use_system_installed_lib
|
||||
then
|
||||
AC_DEFINE(HAVE_SYSTEM_SLANG)
|
||||
LIBS="$LIBS -lslang"
|
||||
LSLANG="-lslang"
|
||||
screen_manager="SLang (using system-installed library)"
|
||||
AC_MSG_RESULT(Using system installed SLang library)
|
||||
else
|
||||
|
@ -9,7 +9,7 @@ CPPFLAGS = $(XCPPFLAGS) -I$(vfsdir) -I$(slangdir) -DHAVE_X -DHAVE_GNOME @GNOME_I
|
||||
LDFLAGS = $(XLDFLAGS) @GNOME_LIBDIR@ @GNOMEUI_LIBS@
|
||||
DEFS = $(XDEFS)
|
||||
LIBS = @X_EXTRA_LIBS@ -lX11 @X_PRE_LIBS@ $(XLIBS) $(XLIB) @TERMNET@
|
||||
EXTRALIBS = @LVFS@ @LSLANG@ -lgtkedit @LINTL@
|
||||
EXTRALIBS = @LVFS@ -lgtkedit @LINTL@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
@ -36,6 +36,7 @@ GNOMESRCS = \
|
||||
gdialogs.c \
|
||||
gscreen.c \
|
||||
gtools.c \
|
||||
gtkdtree.c \
|
||||
gtree.c \
|
||||
gutil.c \
|
||||
gview.c \
|
||||
@ -58,6 +59,7 @@ GNOMEHDRS = \
|
||||
gprop.h \
|
||||
gdialogs.h \
|
||||
gscreen.h \
|
||||
gtkree.h \
|
||||
gtree.h \
|
||||
gwidget.h
|
||||
|
||||
@ -82,12 +84,12 @@ LOBJS = mad.o
|
||||
# These objects from ../src do depend on HAVE_GNOME
|
||||
#
|
||||
OOBJS = main.o dlg.o screen.o widget.o wtools.o info.o boxes.o \
|
||||
file.o find.o dialog.o help.o key.o chmod.o chown.o view.o \
|
||||
panelize.o hotlist.o listmode.o background.o dir.o util.o \
|
||||
win.o color.o profile.o user.o ext.o setup.o tree.o \
|
||||
file.o find.o dialog.o key.o chmod.o chown.o view.o \
|
||||
panelize.o hotlist.o background.o dir.o util.o \
|
||||
win.o color.o profile.o user.o ext.o setup.o \
|
||||
subshell.o terms.o achown.o fsusage.o mountlist.o \
|
||||
@XCURSES@ @REGEX_O@ complete.o command.o \
|
||||
option.o cmd.o utilunix.o xslint.o gdialogs.o
|
||||
option.o cmd.o utilunix.o xslint.o filegui.o filenot.o
|
||||
|
||||
OBJS = $(LOBJS) $(OOBJS) \
|
||||
gblist.o \
|
||||
@ -96,6 +98,7 @@ OBJS = $(LOBJS) $(OOBJS) \
|
||||
gcmd.o \
|
||||
gdesktop-icon.o \
|
||||
gdesktop.o \
|
||||
gdialogs.o \
|
||||
gdnd.o \
|
||||
ghelp.o \
|
||||
ginfo.o \
|
||||
@ -113,6 +116,7 @@ OBJS = $(LOBJS) $(OOBJS) \
|
||||
gtree.o \
|
||||
gutil.o \
|
||||
gview.o \
|
||||
gtkdtree.o \
|
||||
gwidget.o
|
||||
|
||||
#
|
||||
@ -179,10 +183,6 @@ cleansourcelinks:
|
||||
check:
|
||||
@echo no tests are supplied.
|
||||
|
||||
cross:
|
||||
$(MAKE) CC=gcc-linux CPP="gcc-linux -E" \
|
||||
CPPFLAGS="$(CPPFLAGS) -I/usr/local/lib/gcc-lib/i386-linux-linux/include/ncurses "
|
||||
|
||||
TAGS: $(GNOMESRCS)
|
||||
etags $(GNOMESRCS)
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#define PORT_HAS_RADIO_FOCUS_ITEM 1
|
||||
#define PORT_HAS_DIALOG_STOP 1
|
||||
#define PORT_HAS_DISPLAY_MINI_INFO 1
|
||||
/* #define PORT_WANTS_ARGP 0 */
|
||||
#define PORT_WIDGET_WANTS_HISTORY 0
|
||||
#define PORT_HAS_UPDATE_MARKS 1
|
||||
#define PORT_HAS_RADIO_TOGGLE 1
|
||||
|
@ -92,9 +92,6 @@ gmc_color_init (void)
|
||||
int
|
||||
xtoolkit_init (int *argc, char *argv [])
|
||||
{
|
||||
LINES = 40;
|
||||
COLS = 80;
|
||||
|
||||
printf (
|
||||
"The GNOME file manager is going trough a massive code\n"
|
||||
"rewrite, so many problems are known to exist due to a major\n"
|
||||
@ -108,6 +105,18 @@ xtoolkit_init (int *argc, char *argv [])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
interactive_display (char *filename, char *node)
|
||||
{
|
||||
/* FIXME: Implement gnome version */
|
||||
}
|
||||
|
||||
int
|
||||
beep (void)
|
||||
{
|
||||
gdk_beep ();
|
||||
}
|
||||
|
||||
int
|
||||
xtoolkit_end (void)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "dialog.h"
|
||||
#include "gdesktop.h"
|
||||
#include "gdnd.h"
|
||||
#include "gtree.h"
|
||||
#include "gtkdtree.h"
|
||||
#include "gpageprop.h"
|
||||
#include "gpopup.h"
|
||||
#include "gcliplabel.h"
|
||||
@ -443,7 +443,8 @@ panel_file_list_configure_contents (GtkWidget *sw, WPanel *panel, int main_width
|
||||
} else
|
||||
extra_space = expand_space = 0;
|
||||
|
||||
/* Hack: the default mini-info display only gets displayed
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@ -507,6 +508,7 @@ panel_file_list_select_row (GtkWidget *file_list, int row, int column, GdkEvent
|
||||
case 1:
|
||||
if (!(event->button.state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
|
||||
break;
|
||||
|
||||
/* fallback if shift-click is pressed */
|
||||
do_file_mark_range (panel, row, current_selection);
|
||||
break;
|
||||
@ -824,6 +826,26 @@ panel_clist_drag_data_received (GtkWidget *widget,
|
||||
panel_update_contents (panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* panel_tree_drag_data_received:
|
||||
*
|
||||
* Invoked on the target side when a drop has been received in the Tree
|
||||
*/
|
||||
static void
|
||||
panel_tree_drag_data_received (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint32 time,
|
||||
WPanel *panel)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (widget);
|
||||
|
||||
printf ("Drop received on tree\n");
|
||||
}
|
||||
|
||||
#ifdef OLD_DND
|
||||
/*
|
||||
* Handler for text/plain and url:ALL drag types
|
||||
@ -1118,9 +1140,10 @@ panel_create_file_list (WPanel *panel)
|
||||
gtk_signal_connect (GTK_OBJECT (file_list), "drag_data_received",
|
||||
GTK_SIGNAL_FUNC (panel_clist_drag_data_received), panel);
|
||||
|
||||
/* These implement our drag-start activation code. We need to manually activate the drag as
|
||||
* the DnD code in Gtk+ will make the scrollbars in the CList activate drags when they are
|
||||
* moved.
|
||||
/* These implement our drag-start activation code. We need to
|
||||
* manually activate the drag as the DnD code in Gtk+ will
|
||||
* make the scrollbars in the CList activate drags when they
|
||||
* are moved.
|
||||
*/
|
||||
gtk_signal_connect (GTK_OBJECT (file_list), "button_press_event",
|
||||
GTK_SIGNAL_FUNC (panel_clist_button_press), panel);
|
||||
@ -1681,6 +1704,38 @@ panel_create_filter (Dlg_head *h, WPanel *panel, void **filter_w)
|
||||
return fhbox;
|
||||
}
|
||||
|
||||
/* Signal handler for DTree's "directory_changed" signal */
|
||||
static void
|
||||
panel_chdir (GtkDTree *dtree, char *path, WPanel *panel)
|
||||
{
|
||||
do_panel_cd (panel, path, cd_exact);
|
||||
}
|
||||
|
||||
/**
|
||||
* panel_create_tree_view:
|
||||
*
|
||||
* Create and initializes the GtkDTree widget for being used in the
|
||||
* Panel
|
||||
*/
|
||||
static GtkWidget *
|
||||
panel_create_tree_view (WPanel *panel)
|
||||
{
|
||||
GtkWidget *tree;
|
||||
|
||||
tree = gtk_dtree_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (tree), "directory_changed",
|
||||
GTK_SIGNAL_FUNC (panel_chdir), panel);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (tree), GTK_DEST_DEFAULT_ALL,
|
||||
drop_types, ELEMENTS (drop_types),
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (tree), "drag_data_received",
|
||||
GTK_SIGNAL_FUNC (panel_tree_drag_data_received), panel);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
static void
|
||||
panel_back (GtkWidget *button, WPanel *panel)
|
||||
{
|
||||
@ -1699,13 +1754,6 @@ panel_up (GtkWidget *button, WPanel *panel)
|
||||
do_panel_cd (panel, "..", cd_exact);
|
||||
}
|
||||
|
||||
/* Signal handler for DTree's "directory_changed" signal */
|
||||
static void
|
||||
panel_chdir (GtkDTree *dtree, char *path, WPanel *panel)
|
||||
{
|
||||
do_panel_cd (panel, path, cd_exact);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
button_switch_to (char **icon, GtkSignalFunc fn, void *closure)
|
||||
{
|
||||
@ -1771,9 +1819,7 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
gtk_scrolled_window_set_policy (
|
||||
GTK_SCROLLED_WINDOW (tree_scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
panel->tree = gtk_dtree_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (panel->tree), "directory_changed",
|
||||
GTK_SIGNAL_FUNC (panel_chdir), panel);
|
||||
panel->tree = panel_create_tree_view (panel);
|
||||
gtk_container_add (GTK_CONTAINER (tree_scrolled_window), panel->tree);
|
||||
gtk_widget_show_all (tree_scrolled_window);
|
||||
|
||||
|
548
gnome/gtkdtree.c
Обычный файл
548
gnome/gtkdtree.c
Обычный файл
@ -0,0 +1,548 @@
|
||||
/*
|
||||
* GtkDTree: A directory tree view
|
||||
*
|
||||
* Original version by Daniel Lacroix (LACROIX@wanadoo.fr)
|
||||
*
|
||||
* Adapted to the Midnight Commander by Miguel.
|
||||
*
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <gnome.h>
|
||||
#include "gtkdtree.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "../vfs/vfs.h"
|
||||
#include "dir-open.xpm"
|
||||
#include "dir-close.xpm"
|
||||
|
||||
#ifdef HACK
|
||||
# define mc_opendir opendir
|
||||
# define mc_closedir closedir
|
||||
# define mc_stat stat
|
||||
# define mc_readdir readdir
|
||||
#endif
|
||||
|
||||
#define TREE_SPACING 3
|
||||
|
||||
static GtkCTreeClass *parent_class = NULL;
|
||||
|
||||
enum {
|
||||
DIRECTORY_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint gtk_dtree_signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
static char *
|
||||
gtk_dtree_get_row_path (GtkCTree *ctree, GtkCTreeNode *row, gint column)
|
||||
{
|
||||
char *node_text, *path;
|
||||
|
||||
path = g_strdup ("");
|
||||
do {
|
||||
char *new_path;
|
||||
int val;
|
||||
|
||||
val = gtk_ctree_node_get_pixtext (
|
||||
ctree, row, column,
|
||||
&node_text, NULL, NULL, NULL);
|
||||
|
||||
if (!val)
|
||||
return path;
|
||||
|
||||
new_path = g_concat_dir_and_file (node_text, path);
|
||||
g_free (path);
|
||||
path = new_path;
|
||||
|
||||
row = GTK_CTREE_ROW (row)->parent;
|
||||
} while (row);
|
||||
|
||||
if (path [0] && path [1]){
|
||||
int l = strlen (path);
|
||||
|
||||
if (path [l-1] == '/')
|
||||
path [l-1] = 0;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static GtkCTreeNode *
|
||||
gtk_dtree_contains (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
|
||||
{
|
||||
GtkCTreeNode *node;
|
||||
char *s;
|
||||
|
||||
g_assert (dtree);
|
||||
g_assert (parent);
|
||||
g_assert (text);
|
||||
|
||||
node = GTK_CTREE_ROW (parent)->children;
|
||||
|
||||
for (; node && GTK_CTREE_ROW (node)->parent == parent;){
|
||||
char *s;
|
||||
|
||||
gtk_ctree_node_get_pixtext (GTK_CTREE (dtree), node, 0, &s, NULL, NULL, NULL);
|
||||
|
||||
if (strcmp (s, text) == 0)
|
||||
return node;
|
||||
|
||||
node = GTK_CTREE_ROW (node)->sibling;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int level)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
char *full_name;
|
||||
int stats = 0;
|
||||
|
||||
g_assert (path);
|
||||
g_assert (parent);
|
||||
g_assert (dtree);
|
||||
|
||||
printf ("OPEN: %s\n", path);
|
||||
dir = mc_opendir (path);
|
||||
if (!dir)
|
||||
return FALSE;
|
||||
|
||||
for (; (dirent = mc_readdir (dir)) != NULL; ){
|
||||
GtkCTreeNode *sibling;
|
||||
struct stat s;
|
||||
char *full_name;
|
||||
char *text [1];
|
||||
int res;
|
||||
|
||||
if (dirent->d_name [0] == '.'){
|
||||
if (dirent->d_name [1] == '.'){
|
||||
if (dirent->d_name [2] == 0)
|
||||
continue;
|
||||
} else if (dirent->d_name [1] == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
full_name = g_concat_dir_and_file (path, dirent->d_name);
|
||||
printf ("Stating: %s\n", full_name);
|
||||
res = mc_stat (full_name, &s);
|
||||
|
||||
if (res == -1){
|
||||
g_free (full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (s.st_mode)){
|
||||
g_free (full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
text [0] = dirent->d_name;
|
||||
|
||||
/* Do not insert duplicates */
|
||||
sibling = gtk_dtree_contains (dtree, parent, text [0]);
|
||||
|
||||
if (sibling == NULL){
|
||||
sibling = gtk_ctree_insert_node (
|
||||
GTK_CTREE (dtree), parent, NULL,
|
||||
text, TREE_SPACING,
|
||||
dtree->pixmap_close,
|
||||
dtree->bitmap_close,
|
||||
dtree->pixmap_open,
|
||||
dtree->bitmap_open,
|
||||
FALSE, FALSE);
|
||||
|
||||
}
|
||||
|
||||
if (level)
|
||||
gtk_dtree_load_path (dtree, full_name, sibling, level-1);
|
||||
|
||||
g_free (full_name);
|
||||
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (ctree);
|
||||
GtkCTreeNode *last_node;
|
||||
char *path;
|
||||
|
||||
parent_class->tree_select_row (ctree, row, column);
|
||||
|
||||
while (row == dtree->root_node)
|
||||
return;
|
||||
|
||||
if (row == dtree->last_node)
|
||||
return;
|
||||
|
||||
dtree->last_node = row;
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (ctree));
|
||||
path = gtk_dtree_get_row_path (ctree, row, 0);
|
||||
|
||||
if (dtree->current_path)
|
||||
g_free (dtree->current_path);
|
||||
|
||||
dtree->current_path = path;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (ctree), gtk_dtree_signals [DIRECTORY_CHANGED], path);
|
||||
|
||||
gtk_dtree_load_path (dtree, path, row, 1);
|
||||
#if 0
|
||||
last_node = GTK_CTREE_ROW (row)->children;
|
||||
for (; last_node; last_node = GTK_CTREE_ROW (last_node)->sibling){
|
||||
char *np, *text;
|
||||
|
||||
gtk_ctree_node_get_pixtext (
|
||||
ctree, last_node, column, &text,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
np = g_concat_dir_and_file (path, text);
|
||||
gtk_dtree_load_path (dtree, np, last_node, 0);
|
||||
g_free (np);
|
||||
}
|
||||
#endif
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (ctree));
|
||||
}
|
||||
|
||||
static GtkCTreeNode *
|
||||
gtk_dtree_lookup_dir (GtkDTree *dtree, GtkCTreeNode *parent, char *dirname)
|
||||
{
|
||||
GtkCTreeNode *node;
|
||||
|
||||
g_assert (dtree);
|
||||
g_assert (parent);
|
||||
g_assert (dirname);
|
||||
|
||||
node = GTK_CTREE_ROW (parent)->children;
|
||||
|
||||
while (node && GTK_CTREE_ROW (node)->parent == parent){
|
||||
char *text;
|
||||
|
||||
gtk_ctree_node_get_pixtext (
|
||||
GTK_CTREE (dtree), node, 0, &text,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (strcmp (dirname, text) == 0)
|
||||
return node;
|
||||
|
||||
node = GTK_CTREE_NODE_NEXT (node);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_dtree_do_select_dir (GtkDTree *dtree, char *path)
|
||||
{
|
||||
GtkCTreeNode *current_node;
|
||||
char *s, *current, *npath;
|
||||
|
||||
g_return_val_if_fail (dtree != NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_DTREE (dtree), FALSE);
|
||||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
|
||||
if (strcmp (path, dtree->current_path) == 0)
|
||||
return TRUE;
|
||||
|
||||
s = alloca (strlen (path)+1);
|
||||
strcpy (s, path);
|
||||
current_node = dtree->root_node;
|
||||
|
||||
s++;
|
||||
npath = g_strdup ("/");
|
||||
|
||||
while ((current = strtok (s, "/")) != NULL){
|
||||
char *comp, *full_path;
|
||||
GtkCTreeNode *node;
|
||||
|
||||
s = NULL;
|
||||
full_path = g_concat_dir_and_file (npath, current);
|
||||
g_free (npath);
|
||||
npath = full_path;
|
||||
|
||||
node = gtk_dtree_lookup_dir (dtree, current_node, current);
|
||||
if (!node){
|
||||
gtk_dtree_load_path (dtree, full_path, current_node, 1);
|
||||
|
||||
node = gtk_dtree_lookup_dir (dtree, current_node, current);
|
||||
}
|
||||
|
||||
if (node){
|
||||
gtk_ctree_expand (GTK_CTREE (dtree), node);
|
||||
current_node = node;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
g_free (npath);
|
||||
|
||||
if (current_node){
|
||||
if (!gtk_ctree_node_is_visible (GTK_CTREE (dtree), current_node)){
|
||||
gtk_ctree_node_moveto (GTK_CTREE (dtree), current_node, 0, 0.5, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
if (dtree->current_path){
|
||||
g_free (dtree->current_path);
|
||||
dtree->current_path = g_strdup (path);
|
||||
}
|
||||
|
||||
if (dtree->requested_path){
|
||||
g_free (dtree->requested_path);
|
||||
dtree->requested_path = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_dtree_select_dir:
|
||||
* @dtree: the tree
|
||||
* @path: The path we want loaded into the tree
|
||||
*
|
||||
* Attemps to open all of the tree notes until
|
||||
* path is reached. It takes a fully qualified
|
||||
* pathname.
|
||||
*
|
||||
* Returns: TRUE if it succeeded, otherwise, FALSE
|
||||
*/
|
||||
gboolean
|
||||
gtk_dtree_select_dir (GtkDTree *dtree, char *path)
|
||||
{
|
||||
g_return_if_fail (dtree != NULL);
|
||||
g_return_if_fail (GTK_IS_DTREE (dtree));
|
||||
g_return_if_fail (path != NULL);
|
||||
g_return_if_fail (*path == '/');
|
||||
|
||||
if (dtree->visible)
|
||||
gtk_dtree_do_select_dir (dtree, path);
|
||||
else {
|
||||
if (dtree->requested_path){
|
||||
g_free (dtree->requested_path);
|
||||
dtree->requested_path = g_strdup (path);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||
if (allocation->width != 0 && allocation->height != 0)
|
||||
dtree->visible = TRUE;
|
||||
else
|
||||
dtree->visible = FALSE;
|
||||
|
||||
if (!(dtree->visible && dtree->requested_path))
|
||||
return;
|
||||
|
||||
if (strcmp (dtree->current_path, dtree->requested_path) != 0)
|
||||
return;
|
||||
|
||||
gtk_dtree_do_select_dir (dtree, dtree->requested_path);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_expand (GtkCTree *ctree, GtkCTreeNode *node)
|
||||
{
|
||||
parent_class->tree_expand (ctree, node);
|
||||
gtk_dtree_select_row (ctree, node, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_destroy (GtkObject *object)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (object);
|
||||
|
||||
gdk_pixmap_unref (dtree->pixmap_open);
|
||||
gdk_pixmap_unref (dtree->pixmap_close);
|
||||
gdk_bitmap_unref (dtree->bitmap_open);
|
||||
gdk_bitmap_unref (dtree->bitmap_close);
|
||||
|
||||
(GTK_OBJECT_CLASS (parent_class))->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_class_init (GtkDTreeClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class = (GtkObjectClass *) klass;
|
||||
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
|
||||
GtkCTreeClass *ctree_class = (GtkCTreeClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GTK_TYPE_CTREE);
|
||||
|
||||
gtk_dtree_signals [DIRECTORY_CHANGED] =
|
||||
gtk_signal_new (
|
||||
"directory_changed",
|
||||
GTK_RUN_FIRST, object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GtkDTreeClass, directory_changed),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gtk_dtree_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gtk_dtree_destroy;
|
||||
|
||||
widget_class->size_allocate = gtk_dtree_size_allocate;
|
||||
|
||||
ctree_class->tree_select_row = gtk_dtree_select_row;
|
||||
ctree_class->tree_expand = gtk_dtree_expand;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_load_root_tree (GtkDTree *dtree)
|
||||
{
|
||||
char *root_dir [1] = { "/" };
|
||||
|
||||
g_assert (dtree);
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (dtree));
|
||||
gtk_clist_clear (GTK_CLIST (dtree));
|
||||
|
||||
dtree->root_node = gtk_ctree_insert_node (
|
||||
GTK_CTREE (dtree), NULL, NULL,
|
||||
root_dir, TREE_SPACING,
|
||||
dtree->pixmap_close,
|
||||
dtree->bitmap_close,
|
||||
dtree->pixmap_open,
|
||||
dtree->bitmap_open,
|
||||
FALSE, TRUE);
|
||||
|
||||
gtk_dtree_load_path (dtree, "/", dtree->root_node, 1);
|
||||
|
||||
dtree->last_node = dtree->root_node;
|
||||
|
||||
if (dtree->current_path != NULL)
|
||||
g_free (dtree->current_path);
|
||||
|
||||
/* Set current_path to "/" */
|
||||
dtree->current_path = g_malloc (2);
|
||||
dtree->current_path [0] = '/';
|
||||
dtree->current_path [1] = 0;
|
||||
|
||||
/* Select root node */
|
||||
gtk_ctree_select (GTK_CTREE (dtree), dtree->root_node);
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (dtree));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_load_pixmap (char *pix [], GdkPixmap **pixmap, GdkBitmap **bitmap)
|
||||
{
|
||||
GdkImlibImage *image;
|
||||
|
||||
g_assert (pix);
|
||||
g_assert (pixmap);
|
||||
g_assert (bitmap);
|
||||
|
||||
image = gdk_imlib_create_image_from_xpm_data (pix);
|
||||
gdk_imlib_render (image, image->rgb_width, image->rgb_height);
|
||||
*pixmap = gdk_imlib_move_image (image);
|
||||
*bitmap = gdk_imlib_move_mask (image);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This uses the current colormap and pixmap.
|
||||
* This means that at widget *creation* time the proper
|
||||
* colormap and visual should be set, dont wait till
|
||||
* realize for that
|
||||
*/
|
||||
static void
|
||||
gdk_dtree_load_pixmaps (GtkDTree *dtree)
|
||||
{
|
||||
g_assert (dtree);
|
||||
|
||||
gtk_dtree_load_pixmap (
|
||||
DIRECTORY_OPEN_XPM,
|
||||
&dtree->pixmap_open, &dtree->bitmap_open);
|
||||
gtk_dtree_load_pixmap (
|
||||
DIRECTORY_CLOSE_XPM,
|
||||
&dtree->pixmap_close, &dtree->bitmap_close);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_init (GtkDTree *dtree)
|
||||
{
|
||||
dtree->current_path = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dtree_construct (GtkDTree *dtree)
|
||||
{
|
||||
GtkCList *clist;
|
||||
GtkCTree *ctree;
|
||||
|
||||
g_return_if_fail (dtree != NULL);
|
||||
g_return_if_fail (GTK_IS_DTREE (dtree));
|
||||
|
||||
clist = GTK_CLIST (dtree);
|
||||
ctree = GTK_CTREE (dtree);
|
||||
|
||||
gtk_ctree_construct (ctree, 1, 0, NULL);
|
||||
|
||||
gtk_clist_set_selection_mode(clist, GTK_SELECTION_BROWSE);
|
||||
gtk_clist_set_auto_sort (clist, TRUE);
|
||||
gtk_clist_set_sort_type (clist, GTK_SORT_ASCENDING);
|
||||
gtk_clist_set_selection_mode (clist, GTK_SELECTION_BROWSE);
|
||||
|
||||
gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
|
||||
gtk_ctree_set_reorderable (ctree, TRUE);
|
||||
|
||||
gdk_dtree_load_pixmaps (dtree);
|
||||
gtk_dtree_load_root_tree (dtree);
|
||||
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_dtree_new (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_type_new (GTK_TYPE_DTREE);
|
||||
gtk_dtree_construct (GTK_DTREE (widget));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gtk_dtree_get_type (void)
|
||||
{
|
||||
static GtkType dtree_type = 0;
|
||||
|
||||
if (!dtree_type)
|
||||
{
|
||||
GtkTypeInfo dtree_info =
|
||||
{
|
||||
"GtkDTree",
|
||||
sizeof (GtkDTree),
|
||||
sizeof (GtkDTreeClass),
|
||||
(GtkClassInitFunc) gtk_dtree_class_init,
|
||||
(GtkObjectInitFunc) gtk_dtree_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
dtree_type = gtk_type_unique (GTK_TYPE_CTREE, &dtree_info);
|
||||
}
|
||||
|
||||
return dtree_type;
|
||||
}
|
48
gnome/gtkdtree.h
Обычный файл
48
gnome/gtkdtree.h
Обычный файл
@ -0,0 +1,48 @@
|
||||
#ifndef _GTK_DTREE_H
|
||||
#define _GTK_DTREE_H
|
||||
|
||||
#include <gtk/gtkctree.h>
|
||||
|
||||
#define GTK_TYPE_DTREE (gtk_dtree_get_type ())
|
||||
#define GTK_DTREE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_DTREE, GtkDTree))
|
||||
#define GTK_DTREE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_DTREE, GtkDTreeClass))
|
||||
#define GTK_IS_DTREE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_DTREE))
|
||||
#define GTK_IS_DTREE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DTREE))
|
||||
|
||||
typedef struct {
|
||||
GtkCTree ctree;
|
||||
|
||||
char *current_path;
|
||||
char *requested_path;
|
||||
|
||||
int visible;
|
||||
int expanding;
|
||||
|
||||
GtkCTreeNode *root_node; /* root node */
|
||||
GtkCTreeNode *last_node; /* last visited node */
|
||||
|
||||
/* Pixmaps for showing directories */
|
||||
GdkPixmap *pixmap_open;
|
||||
GdkPixmap *pixmap_close;
|
||||
|
||||
/* Masks */
|
||||
GdkBitmap *bitmap_open;
|
||||
GdkBitmap *bitmap_close;
|
||||
} GtkDTree;
|
||||
|
||||
typedef struct {
|
||||
GtkCTreeClass parent_class;
|
||||
|
||||
void (* directory_changed) (GtkDTree *dtree, char *directory);
|
||||
} GtkDTreeClass;
|
||||
|
||||
guint gtk_dtree_get_type (void);
|
||||
GtkWidget *gtk_dtree_new ();
|
||||
void gtk_dtree_select_parent (GtkDTree *dtree,
|
||||
char *directory);
|
||||
void gtk_dtree_select_child (GtkDTree *dtree);
|
||||
void gtk_dtree_remove_dir_by_name (GtkDTree *dtree,
|
||||
char *directory);
|
||||
gboolean gtk_dtree_select_dir (GtkDTree *dtree,
|
||||
char *directory);
|
||||
#endif
|
541
gnome/gtree.c
541
gnome/gtree.c
@ -1,545 +1,36 @@
|
||||
/*
|
||||
* GtkDTree: A directory tree view
|
||||
*
|
||||
* Original version by Daniel Lacroix (LACROIX@wanadoo.fr)
|
||||
*
|
||||
* Adapted to the Midnight Commander by Miguel.
|
||||
* gtree: utility routines to use the GtkDTree widget in gmc.
|
||||
*
|
||||
* Miguel de Icaza
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <sys/types.h>
|
||||
#include "tree.h"
|
||||
#include <gnome.h>
|
||||
#include "gtree.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "../vfs/vfs.h"
|
||||
#include "dir-open.xpm"
|
||||
#include "dir-close.xpm"
|
||||
|
||||
#ifdef HACK
|
||||
# define mc_opendir opendir
|
||||
# define mc_closedir closedir
|
||||
# define mc_stat stat
|
||||
# define mc_readdir readdir
|
||||
#endif
|
||||
|
||||
#define TREE_SPACING 3
|
||||
|
||||
static GtkCTreeClass *parent_class = NULL;
|
||||
|
||||
enum {
|
||||
DIRECTORY_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint gtk_dtree_signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
static char *
|
||||
gtk_dtree_get_row_path (GtkCTree *ctree, GtkCTreeNode *row, gint column)
|
||||
void
|
||||
sync_tree (char *pathname)
|
||||
{
|
||||
char *node_text, *path;
|
||||
|
||||
path = g_strdup ("");
|
||||
do {
|
||||
char *new_path;
|
||||
int val;
|
||||
|
||||
val = gtk_ctree_node_get_pixtext (
|
||||
ctree, row, column,
|
||||
&node_text, NULL, NULL, NULL);
|
||||
|
||||
if (!val)
|
||||
return path;
|
||||
|
||||
new_path = g_concat_dir_and_file (node_text, path);
|
||||
g_free (path);
|
||||
path = new_path;
|
||||
|
||||
row = GTK_CTREE_ROW (row)->parent;
|
||||
} while (row);
|
||||
|
||||
if (path [0] && path [1]){
|
||||
int l = strlen (path);
|
||||
|
||||
if (path [l-1] == '/')
|
||||
path [l-1] = 0;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static GtkCTreeNode *
|
||||
gtk_dtree_contains (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
|
||||
{
|
||||
GtkCTreeNode *node;
|
||||
char *s;
|
||||
|
||||
g_assert (dtree);
|
||||
g_assert (parent);
|
||||
g_assert (text);
|
||||
|
||||
node = GTK_CTREE_ROW (parent)->children;
|
||||
|
||||
for (; node && GTK_CTREE_ROW (node)->parent == parent;){
|
||||
char *s;
|
||||
|
||||
gtk_ctree_node_get_pixtext (GTK_CTREE (dtree), node, 0, &s, NULL, NULL, NULL);
|
||||
|
||||
if (strcmp (s, text) == 0)
|
||||
return node;
|
||||
|
||||
node = GTK_CTREE_ROW (node)->sibling;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int level)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
char *full_name;
|
||||
|
||||
g_assert (path);
|
||||
g_assert (parent);
|
||||
g_assert (dtree);
|
||||
|
||||
dir = mc_opendir (path);
|
||||
if (!dir)
|
||||
return FALSE;
|
||||
|
||||
for (; (dirent = mc_readdir (dir)) != NULL; ){
|
||||
GtkCTreeNode *sibling;
|
||||
struct stat s;
|
||||
char *full_name;
|
||||
char *text [1];
|
||||
int res;
|
||||
|
||||
if (dirent->d_name [0] == '.'){
|
||||
if (dirent->d_name [1] == '.'){
|
||||
if (dirent->d_name [2] == 0)
|
||||
continue;
|
||||
} else if (dirent->d_name [1] == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
full_name = g_concat_dir_and_file (path, dirent->d_name);
|
||||
res = mc_stat (full_name, &s);
|
||||
|
||||
if (res == -1){
|
||||
g_free (full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (s.st_mode)){
|
||||
g_free (full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
text [0] = dirent->d_name;
|
||||
|
||||
/* Do not insert duplicates */
|
||||
sibling = gtk_dtree_contains (dtree, parent, text [0]);
|
||||
|
||||
if (sibling == NULL){
|
||||
sibling = gtk_ctree_insert_node (
|
||||
GTK_CTREE (dtree), parent, NULL,
|
||||
text, TREE_SPACING,
|
||||
dtree->pixmap_close,
|
||||
dtree->bitmap_close,
|
||||
dtree->pixmap_open,
|
||||
dtree->bitmap_open,
|
||||
FALSE, FALSE);
|
||||
|
||||
}
|
||||
|
||||
if (level)
|
||||
gtk_dtree_load_path (dtree, full_name, sibling, level-1);
|
||||
|
||||
g_free (full_name);
|
||||
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (ctree);
|
||||
GtkCTreeNode *last_node;
|
||||
char *path;
|
||||
|
||||
parent_class->tree_select_row (ctree, row, column);
|
||||
|
||||
while (row == dtree->root_node)
|
||||
return;
|
||||
|
||||
if (row == dtree->last_node)
|
||||
return;
|
||||
|
||||
dtree->last_node = row;
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (ctree));
|
||||
path = gtk_dtree_get_row_path (ctree, row, 0);
|
||||
|
||||
if (dtree->current_path)
|
||||
g_free (dtree->current_path);
|
||||
|
||||
dtree->current_path = path;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (ctree), gtk_dtree_signals [DIRECTORY_CHANGED], path);
|
||||
|
||||
gtk_dtree_load_path (dtree, path, row, 1);
|
||||
#if 0
|
||||
last_node = GTK_CTREE_ROW (row)->children;
|
||||
for (; last_node; last_node = GTK_CTREE_ROW (last_node)->sibling){
|
||||
char *np, *text;
|
||||
|
||||
gtk_ctree_node_get_pixtext (
|
||||
ctree, last_node, column, &text,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
np = g_concat_dir_and_file (path, text);
|
||||
gtk_dtree_load_path (dtree, np, last_node, 0);
|
||||
g_free (np);
|
||||
}
|
||||
#endif
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (ctree));
|
||||
}
|
||||
|
||||
static GtkCTreeNode *
|
||||
gtk_dtree_lookup_dir (GtkDTree *dtree, GtkCTreeNode *parent, char *dirname)
|
||||
{
|
||||
GtkCTreeNode *node;
|
||||
|
||||
g_assert (dtree);
|
||||
g_assert (parent);
|
||||
g_assert (dirname);
|
||||
|
||||
node = GTK_CTREE_ROW (parent)->children;
|
||||
|
||||
while (node && GTK_CTREE_ROW (node)->parent == parent){
|
||||
char *text;
|
||||
|
||||
gtk_ctree_node_get_pixtext (
|
||||
GTK_CTREE (dtree), node, 0, &text,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (strcmp (dirname, text) == 0)
|
||||
return node;
|
||||
|
||||
node = GTK_CTREE_NODE_NEXT (node);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_dtree_do_select_dir (GtkDTree *dtree, char *path)
|
||||
{
|
||||
GtkCTreeNode *current_node;
|
||||
char *s, *current, *npath;
|
||||
|
||||
g_return_val_if_fail (dtree != NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_DTREE (dtree), FALSE);
|
||||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
|
||||
if (strcmp (path, dtree->current_path) == 0)
|
||||
return TRUE;
|
||||
|
||||
s = alloca (strlen (path)+1);
|
||||
strcpy (s, path);
|
||||
current_node = dtree->root_node;
|
||||
|
||||
s++;
|
||||
npath = g_strdup ("/");
|
||||
|
||||
while ((current = strtok (s, "/")) != NULL){
|
||||
char *comp, *full_path;
|
||||
GtkCTreeNode *node;
|
||||
|
||||
s = NULL;
|
||||
full_path = g_concat_dir_and_file (npath, current);
|
||||
g_free (npath);
|
||||
npath = full_path;
|
||||
|
||||
node = gtk_dtree_lookup_dir (dtree, current_node, current);
|
||||
if (!node){
|
||||
gtk_dtree_load_path (dtree, full_path, current_node, 1);
|
||||
|
||||
node = gtk_dtree_lookup_dir (dtree, current_node, current);
|
||||
}
|
||||
|
||||
if (node){
|
||||
gtk_ctree_expand (GTK_CTREE (dtree), node);
|
||||
current_node = node;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
g_free (npath);
|
||||
|
||||
if (current_node){
|
||||
if (!gtk_ctree_node_is_visible (GTK_CTREE (dtree), current_node)){
|
||||
gtk_ctree_node_moveto (GTK_CTREE (dtree), current_node, 0, 0.5, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
if (dtree->current_path){
|
||||
g_free (dtree->current_path);
|
||||
dtree->current_path = g_strdup (path);
|
||||
}
|
||||
|
||||
if (dtree->requested_path){
|
||||
g_free (dtree->requested_path);
|
||||
dtree->requested_path = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_dtree_select_dir:
|
||||
* @dtree: the tree
|
||||
* @path: The path we want loaded into the tree
|
||||
*
|
||||
* Attemps to open all of the tree notes until
|
||||
* path is reached. It takes a fully qualified
|
||||
* pathname.
|
||||
*
|
||||
* Returns: TRUE if it succeeded, otherwise, FALSE
|
||||
*/
|
||||
gboolean
|
||||
gtk_dtree_select_dir (GtkDTree *dtree, char *path)
|
||||
{
|
||||
g_return_if_fail (dtree != NULL);
|
||||
g_return_if_fail (GTK_IS_DTREE (dtree));
|
||||
g_return_if_fail (path != NULL);
|
||||
g_return_if_fail (*path == '/');
|
||||
|
||||
if (dtree->visible)
|
||||
gtk_dtree_do_select_dir (dtree, path);
|
||||
else {
|
||||
if (dtree->requested_path){
|
||||
g_free (dtree->requested_path);
|
||||
dtree->requested_path = g_strdup (path);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||
if (allocation->width != 0 && allocation->height != 0)
|
||||
dtree->visible = TRUE;
|
||||
else
|
||||
dtree->visible = FALSE;
|
||||
|
||||
if (!(dtree->visible && dtree->requested_path))
|
||||
return;
|
||||
|
||||
if (strcmp (dtree->current_path, dtree->requested_path) != 0)
|
||||
return;
|
||||
|
||||
gtk_dtree_do_select_dir (dtree, dtree->requested_path);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_expand (GtkCTree *ctree, GtkCTreeNode *node)
|
||||
{
|
||||
parent_class->tree_expand (ctree, node);
|
||||
gtk_dtree_select_row (ctree, node, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_destroy (GtkObject *object)
|
||||
{
|
||||
GtkDTree *dtree = GTK_DTREE (object);
|
||||
|
||||
gdk_pixmap_unref (dtree->pixmap_open);
|
||||
gdk_pixmap_unref (dtree->pixmap_close);
|
||||
gdk_bitmap_unref (dtree->bitmap_open);
|
||||
gdk_bitmap_unref (dtree->bitmap_close);
|
||||
|
||||
(GTK_OBJECT_CLASS (parent_class))->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_class_init (GtkDTreeClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class = (GtkObjectClass *) klass;
|
||||
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
|
||||
GtkCTreeClass *ctree_class = (GtkCTreeClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GTK_TYPE_CTREE);
|
||||
|
||||
gtk_dtree_signals [DIRECTORY_CHANGED] =
|
||||
gtk_signal_new (
|
||||
"directory_changed",
|
||||
GTK_RUN_FIRST, object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GtkDTreeClass, directory_changed),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE,
|
||||
1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, gtk_dtree_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gtk_dtree_destroy;
|
||||
|
||||
widget_class->size_allocate = gtk_dtree_size_allocate;
|
||||
|
||||
ctree_class->tree_select_row = gtk_dtree_select_row;
|
||||
ctree_class->tree_expand = gtk_dtree_expand;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_load_root_tree (GtkDTree *dtree)
|
||||
{
|
||||
char *root_dir [1] = { "/" };
|
||||
|
||||
g_assert (dtree);
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (dtree));
|
||||
gtk_clist_clear (GTK_CLIST (dtree));
|
||||
|
||||
dtree->root_node = gtk_ctree_insert_node (
|
||||
GTK_CTREE (dtree), NULL, NULL,
|
||||
root_dir, TREE_SPACING,
|
||||
dtree->pixmap_close,
|
||||
dtree->bitmap_close,
|
||||
dtree->pixmap_open,
|
||||
dtree->bitmap_open,
|
||||
FALSE, TRUE);
|
||||
|
||||
gtk_dtree_load_path (dtree, "/", dtree->root_node, 1);
|
||||
|
||||
dtree->last_node = dtree->root_node;
|
||||
|
||||
if (dtree->current_path != NULL)
|
||||
g_free (dtree->current_path);
|
||||
|
||||
/* Set current_path to "/" */
|
||||
dtree->current_path = g_malloc (2);
|
||||
dtree->current_path [0] = '/';
|
||||
dtree->current_path [1] = 0;
|
||||
|
||||
/* Select root node */
|
||||
gtk_ctree_select (GTK_CTREE (dtree), dtree->root_node);
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (dtree));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_load_pixmap (char *pix [], GdkPixmap **pixmap, GdkBitmap **bitmap)
|
||||
{
|
||||
GdkImlibImage *image;
|
||||
|
||||
g_assert (pix);
|
||||
g_assert (pixmap);
|
||||
g_assert (bitmap);
|
||||
|
||||
image = gdk_imlib_create_image_from_xpm_data (pix);
|
||||
gdk_imlib_render (image, image->rgb_width, image->rgb_height);
|
||||
*pixmap = gdk_imlib_move_image (image);
|
||||
*bitmap = gdk_imlib_move_mask (image);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This uses the current colormap and pixmap.
|
||||
* This means that at widget *creation* time the proper
|
||||
* colormap and visual should be set, dont wait till
|
||||
* realize for that
|
||||
*/
|
||||
static void
|
||||
gdk_dtree_load_pixmaps (GtkDTree *dtree)
|
||||
{
|
||||
g_assert (dtree);
|
||||
|
||||
gtk_dtree_load_pixmap (
|
||||
DIRECTORY_OPEN_XPM,
|
||||
&dtree->pixmap_open, &dtree->bitmap_open);
|
||||
gtk_dtree_load_pixmap (
|
||||
DIRECTORY_CLOSE_XPM,
|
||||
&dtree->pixmap_close, &dtree->bitmap_close);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dtree_init (GtkDTree *dtree)
|
||||
{
|
||||
dtree->current_path = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dtree_construct (GtkDTree *dtree)
|
||||
tree_check (const char *dir)
|
||||
{
|
||||
GtkCList *clist;
|
||||
GtkCTree *ctree;
|
||||
|
||||
g_return_if_fail (dtree != NULL);
|
||||
g_return_if_fail (GTK_IS_DTREE (dtree));
|
||||
}
|
||||
|
||||
clist = GTK_CLIST (dtree);
|
||||
ctree = GTK_CTREE (dtree);
|
||||
|
||||
gtk_ctree_construct (ctree, 1, 0, NULL);
|
||||
|
||||
gtk_clist_set_selection_mode(clist, GTK_SELECTION_BROWSE);
|
||||
gtk_clist_set_auto_sort (clist, TRUE);
|
||||
gtk_clist_set_sort_type (clist, GTK_SORT_ASCENDING);
|
||||
gtk_clist_set_selection_mode (clist, GTK_SELECTION_BROWSE);
|
||||
|
||||
gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
|
||||
gtk_ctree_set_reorderable (ctree, TRUE);
|
||||
|
||||
gdk_dtree_load_pixmaps (dtree);
|
||||
gtk_dtree_load_root_tree (dtree);
|
||||
|
||||
void
|
||||
start_tree_check (WTree *tree)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_dtree_new (void)
|
||||
void
|
||||
do_tree_check (WTree *tree, const char *subname)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_type_new (GTK_TYPE_DTREE);
|
||||
gtk_dtree_construct (GTK_DTREE (widget));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gtk_dtree_get_type (void)
|
||||
void
|
||||
end_tree_check (WTree *tree)
|
||||
{
|
||||
static GtkType dtree_type = 0;
|
||||
|
||||
if (!dtree_type)
|
||||
{
|
||||
GtkTypeInfo dtree_info =
|
||||
{
|
||||
"GtkDTree",
|
||||
sizeof (GtkDTree),
|
||||
sizeof (GtkDTreeClass),
|
||||
(GtkClassInitFunc) gtk_dtree_class_init,
|
||||
(GtkObjectInitFunc) gtk_dtree_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
dtree_type = gtk_type_unique (GTK_TYPE_CTREE, &dtree_info);
|
||||
}
|
||||
|
||||
return dtree_type;
|
||||
}
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
#ifndef _GNOME_TREE_H
|
||||
#define _GNOME_TREE_H
|
||||
|
||||
#include <gtk/gtkctree.h>
|
||||
|
||||
#define GTK_TYPE_DTREE (gtk_dtree_get_type ())
|
||||
#define GTK_DTREE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_DTREE, GtkDTree))
|
||||
#define GTK_DTREE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_DTREE, GtkDTreeClass))
|
||||
#define GTK_IS_DTREE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_DTREE))
|
||||
#define GTK_IS_DTREE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DTREE))
|
||||
|
||||
typedef struct {
|
||||
GtkCTree ctree;
|
||||
|
||||
char *current_path;
|
||||
char *requested_path;
|
||||
|
||||
int visible;
|
||||
int expanding;
|
||||
|
||||
GtkCTreeNode *root_node; /* root node */
|
||||
GtkCTreeNode *last_node; /* last visited node */
|
||||
|
||||
/* Pixmaps for showing directories */
|
||||
GdkPixmap *pixmap_open;
|
||||
GdkPixmap *pixmap_close;
|
||||
|
||||
/* Masks */
|
||||
GdkBitmap *bitmap_open;
|
||||
GdkBitmap *bitmap_close;
|
||||
} GtkDTree;
|
||||
|
||||
typedef struct {
|
||||
GtkCTreeClass parent_class;
|
||||
|
||||
void (* directory_changed) (GtkDTree *dtree, char *directory);
|
||||
} GtkDTreeClass;
|
||||
|
||||
guint gtk_dtree_get_type (void);
|
||||
GtkWidget *gtk_dtree_new ();
|
||||
void gtk_dtree_select_parent (GtkDTree *dtree,
|
||||
char *directory);
|
||||
void gtk_dtree_select_child (GtkDTree *dtree);
|
||||
void gtk_dtree_remove_dir_by_name (GtkDTree *dtree,
|
||||
char *directory);
|
||||
gboolean gtk_dtree_select_dir (GtkDTree *dtree,
|
||||
char *directory);
|
||||
#endif
|
@ -141,6 +141,11 @@ view_add_character (WView *view, int c)
|
||||
gmc_color_pairs [view->color].back, c);
|
||||
}
|
||||
|
||||
void
|
||||
view_add_one_vline ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
view_add_string (WView *view, char *s)
|
||||
{
|
||||
|
@ -1,3 +1,14 @@
|
||||
1998-12-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* main.c (main): Removed crufty init_sigfatal code.
|
||||
|
||||
* cmd.c (do_link): More slang dependecies are fixed for the X
|
||||
ports.
|
||||
|
||||
* keys.h (enum): Moved key definitions here.
|
||||
|
||||
* tty.h: MOve towards slang freedom for the GNOME port.
|
||||
|
||||
1998-12-01 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* file.c (panel_operate_generate_prompt): moved from filegui.c
|
||||
|
@ -10,7 +10,7 @@ CPPFLAGS = $(XCPPFLAGS) -DREGEX_MALLOC
|
||||
LDFLAGS = $(XLDFLAGS)
|
||||
DEFS = $(XDEFS)
|
||||
LIBS = $(XLIBS) @TERMNET@ $(XLIB) @TERMNET@
|
||||
OURLIBS = @LVFS@ @LSLANG@ @LEDIT@ @LINTL@
|
||||
OURLIBS = @LVFS@ @LSLANG@ @LEDIT@ @LGPM@ @LINTL@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
@ -25,7 +25,7 @@ SRCS = dir.c util.c main.c screen.c dialog.c key.c keyxdef.c menu.c \
|
||||
complete.c slint.c command.c cmd.c panelize.c learn.c \
|
||||
listmode.c utilunix.c background.c rxvt.c \
|
||||
text.c popt.c findme.c poptparse.c poptconfig.c popthelp.c \
|
||||
filegui.c
|
||||
filegui.c filenot.c
|
||||
|
||||
HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
|
||||
util.h dir.h global.h menu.h panel.h win.h mem.h \
|
||||
@ -35,7 +35,7 @@ HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
|
||||
hotlist.h layout.h fsusage.h mountlist.h regex.h complete.h \
|
||||
myslang.h command.h cmd.h tty.h fs.h panelize.h achown.h \
|
||||
learn.h listmode.h features.inc background.h \
|
||||
x.h textconf.h i18n.h findme.h popt.h filegui.h
|
||||
x.h textconf.h i18n.h findme.h popt.h filegui.h keys.h xtty.h
|
||||
|
||||
OBJS = dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o \
|
||||
file.o win.o color.o help.o find.o profile.o user.o view.o \
|
||||
@ -45,7 +45,7 @@ OBJS = dir.o util.o screen.o dialog.o key.o keyxdef.o menu.o \
|
||||
mountlist.o @XCURSES@ @REGEX_O@ complete.o slint.o command.o \
|
||||
cmd.o main.o panelize.o learn.o listmode.o utilunix.o \
|
||||
background.o rxvt.o text.o popt.o findme.o poptparse.o \
|
||||
poptconfig.o popthelp.o filegui.o
|
||||
poptconfig.o popthelp.o filegui.o filenot.o
|
||||
|
||||
#
|
||||
# Distribution variables
|
||||
@ -96,10 +96,6 @@ libedit.a:
|
||||
@PCENTRULE@ -$(RMF) libedit.a
|
||||
@PCENTRULE@ $(LN_S) ../edit/libedit.a .
|
||||
|
||||
cross:
|
||||
$(MAKE) CC=gcc-linux CPP="gcc-linux -E" \
|
||||
CPPFLAGS="$(CPPFLAGS) -I/usr/local/lib/gcc-lib/i386-linux-linux/include/ncurses "
|
||||
|
||||
$(srcdir)/mc.hlp: $(docdir)/mc.1.in $(mclibdir)/xnc.hlp $(srcdir)/gindex.pl
|
||||
$(MAKE) man2hlp
|
||||
./man2hlp 58 $(docdir)/mc.1.in | cat - $(mclibdir)/xnc.hlp | \
|
||||
|
20
src/achown.c
20
src/achown.c
@ -182,6 +182,15 @@ static umode_t get_mode ()
|
||||
return m;
|
||||
}
|
||||
|
||||
#ifdef HAVE_X
|
||||
static void update_mode (Dlg_head *h)
|
||||
{
|
||||
}
|
||||
static void print_flags (void)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
static void print_flags (void)
|
||||
{
|
||||
int i;
|
||||
@ -225,6 +234,7 @@ static void update_mode (Dlg_head * h)
|
||||
printw ("%12o", get_mode ());
|
||||
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
|
||||
static int l_call (void *data)
|
||||
{
|
||||
@ -235,9 +245,11 @@ static int chl_callback (Dlg_head * h, int Par, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
#ifndef HAVE_X
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 0, 0, 13, 17);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DLG_KEY:
|
||||
@ -339,6 +351,7 @@ static void do_enter_key (Dlg_head *h, int f_pos)
|
||||
} while (chl_end);
|
||||
}
|
||||
|
||||
#ifndef HAVE_X
|
||||
static void chown_refresh (void)
|
||||
{
|
||||
attrset (COLOR_NORMAL);
|
||||
@ -395,6 +408,7 @@ static void chown_info_update ()
|
||||
set_perm (b_att[1]->text, sf_stat->st_mode >> 3);
|
||||
set_perm (b_att[2]->text, sf_stat->st_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void b_setpos (int f_pos) {
|
||||
b_att[0]->hotpos=-1;
|
||||
@ -409,8 +423,10 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg)
|
||||
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
#ifndef HAVE_X
|
||||
chown_refresh ();
|
||||
chown_info_update ();
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
case DLG_POST_KEY:
|
||||
@ -671,8 +687,10 @@ void chown_advanced_cmd (void)
|
||||
}
|
||||
ch_cmode = sf_stat->st_mode;
|
||||
|
||||
#ifndef HAVE_X
|
||||
chown_refresh ();
|
||||
|
||||
#endif
|
||||
|
||||
get_ownership ();
|
||||
|
||||
/* game can begin */
|
||||
|
@ -530,10 +530,12 @@ void display_bits_box ()
|
||||
|
||||
eight_bit_clean = new_mode < 2;
|
||||
full_eight_bits = new_mode == 0;
|
||||
#ifndef HAVE_X
|
||||
#ifndef HAVE_SLANG
|
||||
meta (stdscr, eight_bit_clean);
|
||||
#else
|
||||
SLsmg_Display_Eight_Bit = full_eight_bits ? 128 : 160;
|
||||
#endif
|
||||
#endif
|
||||
use_8th_bit_as_meta = !new_meta;
|
||||
}
|
||||
@ -562,6 +564,7 @@ static int tree_callback (struct Dlg_head *h, int id, int msg)
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
char *tree (char *current_dir)
|
||||
{
|
||||
WTree *mytree;
|
||||
@ -591,6 +594,8 @@ char *tree (char *current_dir)
|
||||
destroy_dlg (dlg);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_VFS
|
||||
#ifdef USE_NETCODE
|
||||
#undef USE_NETCODE
|
||||
|
10
src/cmd.c
10
src/cmd.c
@ -708,9 +708,11 @@ void quick_chdir_cmd (void)
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
if (get_current_type () == view_tree)
|
||||
tree_chdir (the_tree, target);
|
||||
else
|
||||
#endif
|
||||
if (!do_cd (target, cd_exact))
|
||||
message (1, MSG_ERROR, _("Could not change directory") );
|
||||
free (target);
|
||||
@ -944,8 +946,10 @@ view_other_cmd (void)
|
||||
reset_shell_mode ();
|
||||
noecho ();
|
||||
#endif
|
||||
#ifndef HAVE_X
|
||||
keypad(stdscr, FALSE);
|
||||
endwin ();
|
||||
#endif
|
||||
if (!status_using_ncurses)
|
||||
do_exit_ca_mode ();
|
||||
mc_raw_mode ();
|
||||
@ -973,9 +977,9 @@ view_other_cmd (void)
|
||||
if (!status_using_ncurses)
|
||||
do_enter_ca_mode ();
|
||||
|
||||
#ifndef HAVE_X
|
||||
reset_prog_mode ();
|
||||
keypad(stdscr, TRUE);
|
||||
#ifndef HAVE_X
|
||||
if (use_mouse_p)
|
||||
init_mouse ();
|
||||
if (alternate_plus_minus)
|
||||
@ -993,8 +997,10 @@ view_other_cmd (void)
|
||||
LINES-keybar_visible-1);
|
||||
}
|
||||
#endif
|
||||
#ifndef HAVE_X
|
||||
touchwin (stdscr);
|
||||
|
||||
#endif
|
||||
|
||||
/* prevent screen flash when user did 'exit' or 'logout' within
|
||||
subshell */
|
||||
if (!quit)
|
||||
|
@ -251,7 +251,6 @@ init_colors (void)
|
||||
int i;
|
||||
|
||||
use_colors = 1;
|
||||
start_color ();
|
||||
configure_colors ();
|
||||
for (i = 0; i < ELEMENTS (color_map); i++)
|
||||
init_pair (i+1, color_map_fg(i), color_map_bg(i));
|
||||
@ -269,7 +268,9 @@ void init_colors (void)
|
||||
}
|
||||
|
||||
if (use_colors){
|
||||
#ifndef HAVE_X
|
||||
start_color ();
|
||||
#endif
|
||||
configure_colors ();
|
||||
|
||||
#ifndef HAVE_SLANG
|
||||
|
@ -149,23 +149,23 @@ void do_cd_command (char *cmd)
|
||||
|
||||
if (get_current_type () == view_tree){
|
||||
if (cmd [0] == 0){
|
||||
tree_chdir (the_tree, home_dir);
|
||||
sync_tree (home_dir);
|
||||
} else if (strcmp (cmd+3, "..") == 0){
|
||||
char *dir = cpanel->cwd;
|
||||
int len = strlen (dir);
|
||||
while (len && dir [--len] != PATH_SEP);
|
||||
dir [len] = 0;
|
||||
if (len)
|
||||
tree_chdir (the_tree, dir);
|
||||
sync_tree (dir);
|
||||
else
|
||||
tree_chdir (the_tree, PATH_SEP_STR);
|
||||
sync_tree (PATH_SEP_STR);
|
||||
} else if (cmd [3] == PATH_SEP){
|
||||
tree_chdir (the_tree, cmd+3);
|
||||
sync_tree (cmd+3);
|
||||
} else {
|
||||
char *old = cpanel->cwd;
|
||||
char *new;
|
||||
new = concat_dir_and_file (old, cmd+3);
|
||||
tree_chdir (the_tree, new);
|
||||
sync_tree (new);
|
||||
free (new);
|
||||
}
|
||||
} else
|
||||
|
@ -858,9 +858,11 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
#ifndef HAVE_X
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 0, 0, query_height, query_width);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DLG_KEY:
|
||||
|
13
src/dialog.c
13
src/dialog.c
@ -90,17 +90,4 @@ void do_refresh (void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Poor man's window puts, it doesn't handle auto-wrap */
|
||||
void my_wputs (int y, int x, char *text)
|
||||
{
|
||||
char p;
|
||||
|
||||
move (y, x);
|
||||
while ((p = *text++) != 0){
|
||||
if (p == '\n')
|
||||
move (++y, x);
|
||||
else
|
||||
addch ((unsigned char)p);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
src/dlg.c
22
src/dlg.c
@ -59,6 +59,15 @@ Hook *idle_hook = 0;
|
||||
# define x_dialog_stop(d)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X
|
||||
void widget_erase (Widget *w)
|
||||
{
|
||||
}
|
||||
|
||||
void dlg_erase (Dlg_head *h)
|
||||
{
|
||||
}
|
||||
#else
|
||||
static void slow_box (Dlg_head *h, int y, int x, int ys, int xs)
|
||||
{
|
||||
move (h->y+y, h->x+x);
|
||||
@ -130,6 +139,7 @@ void dlg_erase (Dlg_head *h)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
|
||||
void init_widget (Widget *w, int y, int x, int lines, int cols,
|
||||
int (*callback)(Dlg_head *, void *, int, int),
|
||||
@ -216,10 +226,13 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
{
|
||||
Dlg_head *new_d;
|
||||
|
||||
#ifndef HAVE_X
|
||||
if (flags & DLG_CENTER){
|
||||
y1 = (LINES-lines)/2;
|
||||
x1 = (COLS-cols)/2;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((flags & DLG_TRYUP) && (y1 > 3))
|
||||
y1 -= 2;
|
||||
|
||||
@ -607,7 +620,8 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
|
||||
case XCTRL('z'):
|
||||
suspend_cmd ();
|
||||
/* Fall through */
|
||||
|
||||
|
||||
#ifndef HAVE_X
|
||||
case XCTRL('l'):
|
||||
#ifndef HAVE_SLANG
|
||||
/* Use this if the refreshes fail */
|
||||
@ -618,6 +632,7 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
|
||||
#endif
|
||||
mc_refresh ();
|
||||
doupdate ();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
@ -784,10 +799,15 @@ void init_dlg (Dlg_head *h)
|
||||
(*h->callback) (h, 0, DLG_INIT);
|
||||
dlg_broadcast_msg (h, WIDGET_INIT, 0);
|
||||
|
||||
#ifdef HAVE_X
|
||||
refresh_mode = REFRESH_COVERS_PART;
|
||||
#else
|
||||
if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES)
|
||||
refresh_mode = REFRESH_COVERS_ALL;
|
||||
else
|
||||
refresh_mode = REFRESH_COVERS_PART;
|
||||
|
||||
#endif
|
||||
push_refresh (dlg_refresh, h, refresh_mode);
|
||||
h->refresh_pushed = 1;
|
||||
|
||||
|
@ -245,12 +245,16 @@ int default_dlg_callback (Dlg_head *h, int id, int msg);
|
||||
int std_callback (Dlg_head *h, int Msg, int Par);
|
||||
int default_proc (Dlg_head *h, int Msg, int Par);
|
||||
|
||||
#ifdef HAVE_X
|
||||
#define widget_move(w,y,x)
|
||||
#define dlg_move(h,y,x)
|
||||
#else
|
||||
#define real_widget_move(w, _y, _x) move((w)->y + _y, (w)->x + _x)
|
||||
#define dlg_move(h, _y, _x) move(((Dlg_head *) h)->y + _y, \
|
||||
((Dlg_head *) h)->x + _x)
|
||||
|
||||
#define widget_move(w,y,x) real_widget_move((Widget*)w,y,x)
|
||||
|
||||
#endif
|
||||
|
||||
extern Dlg_head *current_dlg;
|
||||
extern Hook *idle_hook;
|
||||
|
103
src/filenot.c
Обычный файл
103
src/filenot.c
Обычный файл
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* filenot.c: wrapper for routines to notify the
|
||||
* tree about the changes made to the directory
|
||||
* structure.
|
||||
*
|
||||
* Author:
|
||||
* Janne Kukonlehto
|
||||
* Miguel de Icaza
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "util.h"
|
||||
#include <errno.h>
|
||||
#include "../vfs/vfs.h"
|
||||
|
||||
static char *get_absolute_name (char *file)
|
||||
{
|
||||
char dir [MC_MAXPATHLEN];
|
||||
|
||||
if (file [0] == PATH_SEP)
|
||||
return strdup (file);
|
||||
mc_get_current_wd (dir, MC_MAXPATHLEN);
|
||||
return get_full_name (dir, file);
|
||||
}
|
||||
|
||||
static int
|
||||
my_mkdir_rec (char *s, mode_t mode)
|
||||
{
|
||||
char *p, *q;
|
||||
int result;
|
||||
|
||||
if (!mc_mkdir (s, mode))
|
||||
return 0;
|
||||
|
||||
/* FIXME: should check instead if s is at the root of that filesystem */
|
||||
if (!vfs_file_is_local (s))
|
||||
return -1;
|
||||
|
||||
if (!strcmp (s, PATH_SEP_STR))
|
||||
return ENOTDIR;
|
||||
|
||||
p = concat_dir_and_file (s, "..");
|
||||
|
||||
|
||||
free (p);
|
||||
|
||||
if (!(result = my_mkdir_rec (q, mode)))
|
||||
result = mc_mkdir (s, mode);
|
||||
|
||||
free (q);
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
my_mkdir (char *s, mode_t mode)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = mc_mkdir (s, mode);
|
||||
#ifdef OS2_NT
|
||||
/* .ado: it will be disabled in OS/2 and NT */
|
||||
/* otherwise crash if directory already exists. */
|
||||
return result;
|
||||
#endif
|
||||
if (result) {
|
||||
char *p = vfs_canon (s);
|
||||
|
||||
result = my_mkdir_rec (p, mode);
|
||||
free (p);
|
||||
}
|
||||
if (result == 0){
|
||||
s = get_absolute_name (s);
|
||||
|
||||
#if FIXME
|
||||
tree_add_entry (tree, s);
|
||||
#endif
|
||||
|
||||
free (s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int my_rmdir (char *s)
|
||||
{
|
||||
int result;
|
||||
#if FIXME
|
||||
WTree *tree = 0;
|
||||
#endif
|
||||
|
||||
/* FIXME: Should receive a Wtree! */
|
||||
result = mc_rmdir (s);
|
||||
if (result == 0){
|
||||
s = get_absolute_name (s);
|
||||
|
||||
#if FIXME
|
||||
tree_remove_entry (tree, s);
|
||||
#endif
|
||||
|
||||
free (s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
14
src/find.c
14
src/find.c
@ -231,9 +231,14 @@ find_par_start:
|
||||
add_widgetl (find_dlg, label_new (3, 3, labs[0], "label-start"), XV_WLAY_NEXTCOLUMN);
|
||||
|
||||
run_dlg (find_dlg);
|
||||
if (find_dlg->ret_value == B_CANCEL)
|
||||
|
||||
switch (find_dlg->ret_value){
|
||||
case B_CANCEL:
|
||||
return_value = 0;
|
||||
else if (find_dlg->ret_value == B_TREE){
|
||||
break;
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
case B_TREE:
|
||||
temp_dir = strdup (in_start->buffer);
|
||||
destroy_dlg (find_dlg);
|
||||
free (in_start_dir);
|
||||
@ -248,7 +253,10 @@ find_par_start:
|
||||
in_start_dir = temp_dir;
|
||||
/* Warning: Dreadful goto */
|
||||
goto find_par_start;
|
||||
} else {
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return_value = 1;
|
||||
*start_dir = strdup (in_start->buffer);
|
||||
*pattern = strdup (in_name->buffer);
|
||||
|
@ -41,6 +41,10 @@
|
||||
# include "tkinfo.h"
|
||||
#endif
|
||||
|
||||
#ifndef VERSION
|
||||
# define VERSION "undefined"
|
||||
#endif
|
||||
|
||||
/* Have we called the init_my_statfs routine? */
|
||||
static int initialized;
|
||||
struct my_statfs myfs_stats;
|
||||
@ -50,6 +54,7 @@ static int info_event (Gpm_Event *event, WInfo *info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_X
|
||||
static void info_box (Dlg_head *h, WInfo *info)
|
||||
{
|
||||
standend ();
|
||||
@ -59,9 +64,6 @@ static void info_box (Dlg_head *h, WInfo *info)
|
||||
draw_double_box (h, info->widget.y, info->widget.x,
|
||||
info->widget.lines, info->widget.cols);
|
||||
}
|
||||
|
||||
#ifndef VERSION
|
||||
# define VERSION "undefined"
|
||||
#endif
|
||||
|
||||
void info_show_info (WInfo *info)
|
||||
|
17
src/key.c
17
src/key.c
@ -676,13 +676,13 @@ static int getch_with_delay (void)
|
||||
|
||||
extern int max_dirt_limit;
|
||||
|
||||
#ifndef HAVE_X
|
||||
/* Returns a character read from stdin with appropriate interpretation */
|
||||
/* Also takes care of generated mouse events */
|
||||
/* Returns EV_MOUSE if it is a mouse event */
|
||||
/* Returns EV_NONE if non-blocking or interrupt set and nothing was done */
|
||||
int get_event (Gpm_Event *event, int redo_event, int block)
|
||||
{
|
||||
#ifndef HAVE_X
|
||||
int c;
|
||||
static int flag; /* Return value from select */
|
||||
#ifdef HAVE_LIBGPM
|
||||
@ -791,9 +791,8 @@ int get_event (Gpm_Event *event, int redo_event, int block)
|
||||
flag = is_wintouched(stdscr);
|
||||
untouchwin (stdscr);
|
||||
# endif
|
||||
|
||||
c = block ? getch_with_delay () : get_key_code(1);
|
||||
|
||||
|
||||
# ifndef HAVE_SLANG
|
||||
if (flag)
|
||||
touchwin (stdscr);
|
||||
@ -805,10 +804,14 @@ int get_event (Gpm_Event *event, int redo_event, int block)
|
||||
}
|
||||
|
||||
return c;
|
||||
#else
|
||||
return EV_NONE;
|
||||
#endif /* HAVE_X */
|
||||
}
|
||||
#else
|
||||
/* X11 version of the get_event routine */
|
||||
int get_event (Gpm_Event *event, int redo_event, int block)
|
||||
{
|
||||
return EV_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PORT_HAS_GETCH
|
||||
/* Returns a key press, mouse events are discarded */
|
||||
@ -822,7 +825,6 @@ int mi_getch ()
|
||||
;
|
||||
return key;
|
||||
}
|
||||
#endif
|
||||
|
||||
int xgetch_second (void)
|
||||
{
|
||||
@ -848,6 +850,7 @@ int xgetch_second (void)
|
||||
#endif
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_X
|
||||
void learn_store_key (char *buffer, char **p, int c)
|
||||
|
15
src/keys.h
Обычный файл
15
src/keys.h
Обычный файл
@ -0,0 +1,15 @@
|
||||
/* Key constants as used by mc for non-curses ports */
|
||||
|
||||
enum {
|
||||
KEY_BACKSPACE = 400,
|
||||
KEY_END, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
|
||||
KEY_HOME, KEY_A1, KEY_C1, KEY_NPAGE, KEY_PPAGE, KEY_IC,
|
||||
KEY_ENTER, KEY_DC, KEY_SCANCEL, KEY_BTAB
|
||||
};
|
||||
|
||||
#define KEY_KP_ADD 4001
|
||||
#define KEY_KP_SUBTRACT 4002
|
||||
#define KEY_KP_MULTIPLY 4003
|
||||
|
||||
|
||||
#define KEY_F(x) 1000+x
|
212
src/main.c
212
src/main.c
@ -131,7 +131,7 @@
|
||||
#include "../vfs/vfs.h"
|
||||
#include "../vfs/extfs.h"
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
#include "popt.h"
|
||||
|
||||
/* "$Id$" */
|
||||
@ -290,6 +290,12 @@ char *home_dir;
|
||||
char *other_dir = 0;
|
||||
char *this_dir = 0;
|
||||
|
||||
/* If this is true, then when browsing the tree the other window will
|
||||
* automatically reload it's directory with the contents of the currently
|
||||
* selected directory.
|
||||
*/
|
||||
int xtree_mode = 0;
|
||||
|
||||
/* If true, then print on stdout the last directory we were at */
|
||||
static int print_last_wd = 0;
|
||||
static char *last_wd_string;
|
||||
@ -1161,6 +1167,7 @@ sort_cmd (void)
|
||||
do_re_sort (p);
|
||||
}
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
static void
|
||||
tree_box (void)
|
||||
{
|
||||
@ -1172,6 +1179,7 @@ tree_box (void)
|
||||
free (sel_dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOMEDAY_WE_WILL_FINISH_THIS_CODE
|
||||
static void
|
||||
@ -1264,7 +1272,9 @@ static menu_entry CmdMenu [] = {
|
||||
* as a panel still has some problems, I have not yet finished
|
||||
* the WTree widget port, sorry.
|
||||
*/
|
||||
#ifndef HAVE_GNOME
|
||||
{ ' ', N_("&Directory tree"), 'D', tree_box },
|
||||
#endif
|
||||
{ ' ', N_("&Find file M-?"), 'F', find_cmd },
|
||||
#ifndef HAVE_XVIEW
|
||||
{ ' ', N_("s&Wap panels C-u"), 'W', swap_cmd },
|
||||
@ -2407,61 +2417,6 @@ sigchld_handler_no_subshell (int sig)
|
||||
#endif /* ! HAVE_X */
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
mc_fatal_signal (int signum)
|
||||
{
|
||||
volatile int x;
|
||||
char cmd;
|
||||
pid_t pid;
|
||||
char *args [4] = { "gdb", NULL, NULL, NULL };
|
||||
char pid [20];
|
||||
|
||||
sprintf (buf, "%d", getpid ());
|
||||
fprintf (stderr,
|
||||
"Midnight Commander fatal error, PID=%d\n"
|
||||
"What to do: [e]xit, [s]tack trace, [a]ttach to process\n", getpid ());
|
||||
|
||||
read (1, &cmd, 1);
|
||||
if (cmd == 'a'){
|
||||
for (x = 1; x;)
|
||||
;
|
||||
}
|
||||
if (cmd == 's'){
|
||||
args [1] = program_name;
|
||||
args [2] = buf;
|
||||
pid = fork ();
|
||||
if (pid == -1){
|
||||
fprintf (stderr, "Could not fork, exiting\n");
|
||||
exit (0);
|
||||
}
|
||||
if (pid == 0){
|
||||
stack_trace (args);
|
||||
} else {
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
void
|
||||
init_sigfatals (void)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_hanlder = mc_fatal_signal;
|
||||
sa.sa_mask = 0;
|
||||
sa.sa_flags = 0;
|
||||
|
||||
sigaction (SIGSEGV, &sa, NULL);
|
||||
sigaction (SIGBUS, &sa, NULL);
|
||||
sigaction (SIGFPE, &sa, NULL);
|
||||
}
|
||||
#else
|
||||
#define init_sigfatals()
|
||||
#endif
|
||||
|
||||
void
|
||||
init_sigchld (void)
|
||||
{
|
||||
@ -2486,11 +2441,12 @@ init_sigchld (void)
|
||||
|
||||
#endif /* _OS_NT, __os2__, UNIX */
|
||||
|
||||
#ifndef HAVE_X
|
||||
#if defined(HAVE_SLANG) && !defined(OS2_NT)
|
||||
extern int SLtt_Try_Termcap;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PORT_WANTS_ARGP
|
||||
static void
|
||||
print_mc_usage (void)
|
||||
{
|
||||
@ -2540,7 +2496,6 @@ print_mc_usage (void)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif /* PORT_WANTS_ARGP */
|
||||
|
||||
static void
|
||||
print_color_usage (void)
|
||||
@ -2660,133 +2615,6 @@ process_args (int c, char *option_arg)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PORT_WANTS_ARGP
|
||||
static struct argp_option argp_options [] = {
|
||||
#ifdef WITH_BACKGROUND
|
||||
{ "background", 'B', NULL, 0, N_("[DEVEL-ONLY: Debug the background code]"), 0 },
|
||||
#endif
|
||||
#if defined(HAVE_SLANG) && defined(OS2_NT)
|
||||
{ "createcmdfile", 'S', "CMDFILE", , 0, N_("Create command file to set default directory upon exit."), 1 },
|
||||
#endif
|
||||
{ "color", 'c', NULL, 0, N_("Force color mode."), 0 },
|
||||
{ "colors", 'C', "COLORS", 0, N_("Specify colors (use --help-colors to get a list)."), 1 },
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
{ "dbgsubshell", 'X', NULL, 0, N_("[DEVEL-ONLY: Debug the subshell]"), 0 },
|
||||
#endif
|
||||
{ "edit", 'e', "EDIT", 0, N_("Startup the internal editor."), 1 },
|
||||
{ "help", 'h', NULL, 0, N_("Shows this help message."), 0 },
|
||||
{ "help-colors", 'H', NULL, 0, N_("Help on how to specify colors."), 0 },
|
||||
#ifdef USE_NETCODE
|
||||
{ "ftplog", 'l', "FTPLOG", 0, N_("Log ftpfs commands to the file."), 1 },
|
||||
#endif
|
||||
{ "libdir", 'f', NULL, 0, N_("Prints out the configured paths."), 0 },
|
||||
{ NULL, 'm', NULL, OPTION_HIDDEN, NULL, 0 },
|
||||
{ "nocolor", 'b', NULL, 0, N_("Force black and white display."), 0 },
|
||||
{ "nomouse", 'd', NULL, 0, N_("Disable mouse support."), 0 },
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
{ "subshell", 'U', NULL, 0, N_("Force the concurrent subshell mode"), 0 },
|
||||
{ "nosubshell", 'u', NULL, 0, N_("Disable the concurrent subshell mode."), 0 },
|
||||
{ "forceexec", 'r', NULL, 0, N_("Force subshell execution."), 0 },
|
||||
#endif
|
||||
{ "printwd", 'P', NULL, 0, N_("At exit, print the last working directory."), 0 },
|
||||
{ "resetsoft", 'k', NULL, 0, N_("Reset softkeys (HP terminals only) to their terminfo/termcap default."), 0},
|
||||
{ "slow", 's', NULL, 0, N_("Disables verbose operation (for slow terminals)."), 0 },
|
||||
#if defined(HAVE_SLANG) && !defined(OS2_NT)
|
||||
{ "stickchars", 'a', NULL, 0, N_("Use simple symbols for line drawing."), 0 },
|
||||
#endif
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
#endif
|
||||
#if defined(HAVE_SLANG) && !defined(OS2_NT)
|
||||
{ "termcap", 't', NULL, 0, N_("Activate support for the TERMCAP variable."), 0 },
|
||||
#endif
|
||||
{ "version", 'V', NULL, 0, N_("Report version and configuration options."), 0 },
|
||||
{ "view", 'v', NULL, 0, N_("Start up into the viewer mode."), 0 },
|
||||
{ "xterm", 'x', NULL, 0, N_("Force xterm mouse support and screen save/restore"), 0 },
|
||||
{ "geometry", GEOMETRY_KEY, "GEOMETRY", 0, N_("Geometry for the window"), 0 },
|
||||
{ "nowindows", NOWIN_KEY, NULL, 0, N_("No windows opened at startup"), 0 },
|
||||
{ NULL, 0, NULL, 0, NULL },
|
||||
};
|
||||
|
||||
GList *directory_list = 0;
|
||||
GList *geometry_list = 0;
|
||||
int nowindows;
|
||||
|
||||
static error_t
|
||||
parse_an_arg (int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
switch (key){
|
||||
#ifdef WITH_BACKGROUND
|
||||
case 'B':
|
||||
background_wait = 1;
|
||||
return 0;
|
||||
#endif
|
||||
case 'b':
|
||||
disable_colors = 1;
|
||||
return 0;
|
||||
|
||||
case 'P':
|
||||
print_last_wd = 1;
|
||||
return 0;
|
||||
|
||||
case 'k':
|
||||
reset_hp_softkeys = 1;
|
||||
return 0;
|
||||
|
||||
case 's':
|
||||
slow_terminal = 1;
|
||||
return 0;
|
||||
|
||||
case 'a':
|
||||
force_ugly_line_drawing = 1;
|
||||
return 0;
|
||||
|
||||
case 'x':
|
||||
force_xterm = 1;
|
||||
return 0;
|
||||
|
||||
#if defined(HAVE_SLANG) && !defined(OS2_NT)
|
||||
case 't':
|
||||
SLtt_Try_Termcap = 1;
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
case GEOMETRY_KEY:
|
||||
geometry_list = g_list_append (geometry_list, arg);
|
||||
return 0;
|
||||
|
||||
case NOWIN_KEY:
|
||||
nowindows = 1;
|
||||
|
||||
case ARGP_KEY_ARG:
|
||||
break;
|
||||
|
||||
case ARGP_KEY_INIT:
|
||||
case ARGP_KEY_FINI:
|
||||
return 0;
|
||||
|
||||
default:
|
||||
process_args (key, arg);
|
||||
}
|
||||
|
||||
if (arg){
|
||||
if (edit_one_file)
|
||||
edit_one_file = strdup (arg);
|
||||
else if (view_one_file)
|
||||
view_one_file = strdup (arg);
|
||||
else
|
||||
directory_list = g_list_append (directory_list, arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct argp mc_argp_parser = {
|
||||
argp_options, parse_an_arg, N_("[this dir] [other dir]"), NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
char *cmdline_geometry = NULL;
|
||||
int nowindows = 0;
|
||||
char **directory_list = NULL;
|
||||
@ -2829,8 +2657,10 @@ static struct poptOption argumentTable[] = {
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
{ "subshell", 'U', POPT_ARG_NONE, NULL, 'U' },
|
||||
#endif
|
||||
#if !defined(HAVE_X)
|
||||
#if defined(HAVE_SLANG) && !defined(OS2_NT)
|
||||
{ "termcap", 't', 0, &SLtt_Try_Termcap, 0 },
|
||||
#endif
|
||||
#endif
|
||||
{ "version", 'V', POPT_ARG_NONE, NULL, 'V'},
|
||||
{ "view", 'v', POPT_ARG_STRING, &view_one_file, 0 },
|
||||
@ -2857,10 +2687,12 @@ handle_args (int argc, char *argv [])
|
||||
optCon = poptGetContext ("mc", argc, argv, argumentTable, 0);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_X
|
||||
#ifdef USE_TERMCAP
|
||||
SLtt_Try_Termcap = 1;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
while ((c = poptGetNextOpt (optCon)) > 0) {
|
||||
option_arg = poptGetOptArg(optCon);
|
||||
|
||||
@ -2905,7 +2737,6 @@ handle_args (int argc, char *argv [])
|
||||
|
||||
poptFreeContext(optCon);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The compatibility_move_mc_files routine is intended to
|
||||
@ -3016,11 +2847,13 @@ int main (int argc, char *argv [])
|
||||
exit (1);
|
||||
#endif /* HAVE_X */
|
||||
|
||||
|
||||
|
||||
#ifndef HAVE_X
|
||||
#ifdef HAVE_SLANG
|
||||
SLtt_Ignore_Beep = 1;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* NOTE: This has to be called before slang_init or whatever routine
|
||||
calls any define_sequence */
|
||||
init_key ();
|
||||
@ -3069,7 +2902,6 @@ int main (int argc, char *argv [])
|
||||
|
||||
/* Install the SIGCHLD handler; must be done before init_subshell() */
|
||||
init_sigchld ();
|
||||
init_sigfatals ();
|
||||
|
||||
/* This variable is used by the subshell */
|
||||
home_dir = getenv ("HOME");
|
||||
|
@ -7,14 +7,7 @@
|
||||
# include "slang.h"
|
||||
#endif
|
||||
|
||||
enum {
|
||||
KEY_BACKSPACE = 400,
|
||||
KEY_END, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
|
||||
KEY_HOME, KEY_A1, KEY_C1, KEY_NPAGE, KEY_PPAGE, KEY_IC,
|
||||
KEY_ENTER, KEY_DC, KEY_SCANCEL, KEY_BTAB
|
||||
};
|
||||
|
||||
#define KEY_F(x) 1000+x
|
||||
#include "keys.h"
|
||||
|
||||
#define ACS_VLINE SLSMG_VLINE_CHAR
|
||||
#define ACS_HLINE SLSMG_HLINE_CHAR
|
||||
|
@ -155,6 +155,7 @@ delete_format (format_e *format)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_X
|
||||
/* This code relies on the default justification!!! */
|
||||
void
|
||||
add_permission_string (char *dest, int width, file_entry *fe, int attr, int color, int is_octal)
|
||||
@ -185,6 +186,7 @@ add_permission_string (char *dest, int width, file_entry *fe, int attr, int colo
|
||||
addch (dest[i]);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
|
||||
int
|
||||
file_entry_color (file_entry *fe)
|
||||
|
93
src/tree.c
93
src/tree.c
@ -68,12 +68,6 @@ extern int command_prompt;
|
||||
/* Specifies the display mode: 1d or 2d */
|
||||
int tree_navigation_flag;
|
||||
|
||||
/* If this is true, then when browsing the tree the other window will
|
||||
* automatically reload it's directory with the contents of the currently
|
||||
* selected directory.
|
||||
*/
|
||||
int xtree_mode = 0;
|
||||
|
||||
/* Forwards */
|
||||
static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par);
|
||||
#define tcallback (callback_fn) tree_callback
|
||||
@ -950,6 +944,11 @@ void tree_chdir (WTree *tree, char *dir)
|
||||
}
|
||||
}
|
||||
|
||||
void sync_tree (char *path)
|
||||
{
|
||||
tree_chdir (the_tree, path);
|
||||
}
|
||||
|
||||
/* Handle mouse click */
|
||||
void tree_event (WTree *tree, int y)
|
||||
{
|
||||
@ -1509,87 +1508,5 @@ WTree *tree_new (int is_panel, int y, int x, int lines, int cols)
|
||||
return tree;
|
||||
}
|
||||
|
||||
static char *get_absolute_name (char *file)
|
||||
{
|
||||
char dir [MC_MAXPATHLEN];
|
||||
|
||||
if (file [0] == PATH_SEP)
|
||||
return strdup (file);
|
||||
mc_get_current_wd (dir, MC_MAXPATHLEN);
|
||||
return get_full_name (dir, file);
|
||||
}
|
||||
|
||||
static int my_mkdir_rec (char *s, mode_t mode)
|
||||
{
|
||||
char *p, *q;
|
||||
int result;
|
||||
|
||||
if (!mc_mkdir (s, mode))
|
||||
return 0;
|
||||
|
||||
/* FIXME: should check instead if s is at the root of that filesystem */
|
||||
if (!vfs_file_is_local (s))
|
||||
return -1;
|
||||
if (!strcmp (s, PATH_SEP_STR))
|
||||
return ENOTDIR;
|
||||
p = concat_dir_and_file (s, "..");
|
||||
q = vfs_canon (p);
|
||||
free (p);
|
||||
if (!(result = my_mkdir_rec (q, mode))) {
|
||||
result = mc_mkdir (s, mode);
|
||||
}
|
||||
free (q);
|
||||
return result;
|
||||
}
|
||||
|
||||
int my_mkdir (char *s, mode_t mode)
|
||||
{
|
||||
int result;
|
||||
#if FIXME
|
||||
WTree *tree = 0;
|
||||
#endif
|
||||
|
||||
result = mc_mkdir (s, mode);
|
||||
#ifdef OS2_NT
|
||||
/* .ado: it will be disabled in OS/2 and NT */
|
||||
/* otherwise crash if directory already exists. */
|
||||
return result;
|
||||
#endif
|
||||
if (result) {
|
||||
char *p = vfs_canon (s);
|
||||
|
||||
result = my_mkdir_rec (p, mode);
|
||||
free (p);
|
||||
}
|
||||
if (result == 0){
|
||||
s = get_absolute_name (s);
|
||||
#if FIXME
|
||||
/* FIXME: Should receive a Wtree! */
|
||||
|
||||
tree_add_entry (tree, s);
|
||||
#endif
|
||||
free (s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int my_rmdir (char *s)
|
||||
{
|
||||
int result;
|
||||
#if FIXME
|
||||
WTree *tree = 0;
|
||||
#endif
|
||||
|
||||
/* FIXME: Should receive a Wtree! */
|
||||
result = mc_rmdir (s);
|
||||
if (result == 0){
|
||||
s = get_absolute_name (s);
|
||||
#if FIXME
|
||||
tree_remove_entry (tree, s);
|
||||
#endif
|
||||
free (s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +59,8 @@ void tree_move_to_child (WTree *tree);
|
||||
void tree_move_to_top (WTree *tree);
|
||||
void tree_move_to_bottom (WTree *tree);
|
||||
|
||||
void sync_tee (char *pathname);
|
||||
|
||||
extern int tree_navigation_flag;
|
||||
extern int xtree_mode;
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
int got_interrupt (void);
|
||||
void mc_refresh (void);
|
||||
|
||||
#ifdef HAVE_X
|
||||
#include "xtty.h"
|
||||
#else /* HAVE_X */
|
||||
|
||||
#ifdef HAVE_SLANG
|
||||
# include "myslang.h"
|
||||
|
||||
@ -139,3 +143,4 @@ int init_pair (int, int, int);
|
||||
#define KEY_KP_SUBTRACT 4002
|
||||
#define KEY_KP_MULTIPLY 4003
|
||||
|
||||
#endif /* HAVE_X */
|
||||
|
@ -728,6 +728,7 @@ view_display_clean (WView *view, int height, int width)
|
||||
}
|
||||
|
||||
#define view_add_character(view,c) addch (c)
|
||||
#define view_add_one_vline() one_vline()
|
||||
#define view_add_string(view,s) addstr (s)
|
||||
#define view_gotoyx(v,r,c) widget_move (v,r,c)
|
||||
#endif
|
||||
@ -881,9 +882,9 @@ display (WView *view)
|
||||
|
||||
/* Hex numbers are printed in the groups of four */
|
||||
/* Groups are separated by a vline */
|
||||
|
||||
|
||||
view_add_character (view, ' ');
|
||||
one_vline ();
|
||||
view_add_one_vline ();
|
||||
view_gotoyx (view, row, col + 1);
|
||||
col += 2;
|
||||
|
||||
|
14
src/widget.c
14
src/widget.c
@ -138,6 +138,7 @@ button_callback (Dlg_head *h, WButton *b, int Msg, int Par)
|
||||
case WIDGET_UNFOCUS:
|
||||
case WIDGET_FOCUS:
|
||||
case WIDGET_DRAW:
|
||||
#ifndef HAVE_X
|
||||
if (Msg==WIDGET_UNFOCUS)
|
||||
b->selected = 0;
|
||||
else if (Msg==WIDGET_FOCUS)
|
||||
@ -174,6 +175,7 @@ button_callback (Dlg_head *h, WButton *b, int Msg, int Par)
|
||||
widget_move (&b->widget, 0, b->hotpos+off);
|
||||
addch ((unsigned char)b->text [b->hotpos]);
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
if (Msg == WIDGET_FOCUS)
|
||||
break;
|
||||
else
|
||||
@ -788,6 +790,7 @@ gauge_new (int y, int x, int shown, int max, int current, char *tkname)
|
||||
#define should_show_history_button(in) \
|
||||
(in->history && in->field_len > HISTORY_BUTTON_WIDTH * 2 + 1 && in->widget.parent)
|
||||
|
||||
#ifndef HAVE_X
|
||||
static void draw_history_button (WInput * in)
|
||||
{
|
||||
char c;
|
||||
@ -814,7 +817,8 @@ static void draw_history_button (WInput * in)
|
||||
addch (c);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* }}} history button */
|
||||
|
||||
|
||||
@ -1748,6 +1752,13 @@ input_new (int y, int x, int color, int len, char *def_text, char *tkname)
|
||||
*/
|
||||
static int listbox_cdiff (WLEntry *s, WLEntry *e);
|
||||
|
||||
#ifdef HAVE_X
|
||||
static void
|
||||
listbox_draw (WListbox *l, Dlg_head *h, int focused)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
#else
|
||||
static void
|
||||
listbox_drawscroll (WListbox *l)
|
||||
{
|
||||
@ -1829,6 +1840,7 @@ listbox_draw (WListbox *l, Dlg_head *h, int focused)
|
||||
attrset (normalc);
|
||||
listbox_drawscroll (l);
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
|
||||
/* Returns the number of items between s and e,
|
||||
must be on the same linked list */
|
||||
|
12
src/win.c
12
src/win.c
@ -47,6 +47,7 @@ typedef struct Fkey_Table_List {
|
||||
|
||||
static Fkey_Table_List *fkey_table_list = NULL;
|
||||
|
||||
#ifndef HAVE_X
|
||||
/* Width of output is always seven characters */
|
||||
void sprint_bytesize (char *buffer, int size, int scale)
|
||||
{
|
||||
@ -71,6 +72,7 @@ void print_bytesize (int size, int scale)
|
||||
sprint_bytesize (buffer, size, scale);
|
||||
printw (buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return values: 0 = not a fkey, other = was a fkey */
|
||||
int check_fkeys (int c)
|
||||
@ -184,6 +186,15 @@ int check_movement_keys (int c, int additional, int page_size, void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_X
|
||||
void mc_raw_mode (void)
|
||||
{
|
||||
}
|
||||
|
||||
void mc_noraw_mode (void)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void mc_raw_mode (void)
|
||||
{
|
||||
raw ();
|
||||
@ -193,6 +204,7 @@ void mc_noraw_mode (void)
|
||||
{
|
||||
noraw ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Classification routines */
|
||||
int is_abort_char (int c)
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "menu.h"
|
||||
#include "wtools.h"
|
||||
#include "key.h" /* For mi_getch() */
|
||||
#include "dialog.h" /* For do_refresh() and my_wputs() */
|
||||
#include "dialog.h" /* For do_refresh() */
|
||||
#include "complete.h" /* INPUT_COMPLETE_CD */
|
||||
#include "x.h"
|
||||
|
||||
|
17
src/xtty.h
Обычный файл
17
src/xtty.h
Обычный файл
@ -0,0 +1,17 @@
|
||||
#include "keys.h"
|
||||
|
||||
#define LINES 0
|
||||
#define COLS 0
|
||||
#define ERR -1
|
||||
|
||||
enum {
|
||||
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
|
||||
COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
|
||||
};
|
||||
|
||||
#define A_NORMAL 0
|
||||
#define A_BOLD 0x40
|
||||
#define A_UNDERLINE 0x40
|
||||
#define A_REVERSE 0x20
|
||||
#define A_BOLD_REVERSE 0x21
|
||||
|
@ -11,7 +11,7 @@ CFLAGS = $(XCFLAGS)
|
||||
CPPFLAGS = $(XCPPFLAGS)
|
||||
LDFLAGS = $(XLDFLAGS)
|
||||
DEFS = $(XDEFS)
|
||||
LIBS = @LINTL@ @SHADOWLIB@ $(XLIBS) @TERMNET@ @PAMLIBS@ $(XLIB)
|
||||
LIBS = @LINTL@ @SHADOWLIB@ $(XLIBS) @TERMNET@ @PAMLIBS@ @LCRYPT@ $(XLIB)
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ -m 755
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user