More work on the tree. It is duplicating entries, you have been warned -mig

This commit is contained in:
Miguel de Icaza 1998-12-01 06:12:34 +00:00
parent 6422f0f64d
commit deec804b4a
3 changed files with 64 additions and 20 deletions

View File

@ -286,7 +286,12 @@ x_fill_panel (WPanel *panel)
else
panel_fill_panel_list (panel);
/* gtk_dtree_do_select_dir (GTK_DTREE (panel->tree), panel->cwd); */
gtk_signal_handler_block_by_data (GTK_OBJECT (panel->tree), panel);
printf ("Solicitando: %s\n", panel->cwd);
gtk_dtree_do_select_dir (GTK_DTREE (panel->tree), panel->cwd);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (panel->tree), panel);
}
static void
@ -602,7 +607,7 @@ create_popup_submenu (WPanel *panel, desktop_icon_t *di, int row, char *filename
submenu_translated = 1;
}
menu = gtk_menu_new ();
/* menu = gtk_menu_new (); */
for (i = 0; file_actions [i].text; i++){
GtkWidget *item;
@ -2019,6 +2024,13 @@ 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)
{
@ -2085,6 +2097,8 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
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);
gtk_container_add (GTK_CONTAINER (tree_scrolled_window), panel->tree);
gtk_widget_show_all (tree_scrolled_window);

View File

@ -53,6 +53,13 @@ gtk_dtree_get_row_path (GtkCTree *ctree, GtkCTreeNode *row, gint column)
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;
}
printf ("get: %s\n", path);
return path;
}
@ -109,10 +116,15 @@ gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int leve
dtree->pixmap_open,
dtree->bitmap_open,
FALSE, FALSE);
if (level)
if (level){
gtk_dtree_load_path (dtree, full_name, sibling, level-1);
}
g_free (full_name);
if (level == 0)
break;
}
mc_closedir (dir);
@ -137,7 +149,6 @@ gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column)
gtk_clist_freeze (GTK_CLIST (ctree));
path = gtk_dtree_get_row_path (ctree, row, 0);
printf ("Selected: %s\n", path);
if (dtree->current_path)
g_free (dtree->current_path);
@ -146,8 +157,10 @@ gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column)
gtk_signal_emit (GTK_OBJECT (ctree), gtk_dtree_signals [DIRECTORY_CHANGED], path);
last_node = GTK_CTREE_ROW (row)->children;
while (last_node){
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 (
@ -157,10 +170,9 @@ gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column)
np = g_concat_dir_and_file (path, text);
gtk_dtree_load_path (dtree, np, last_node, 0);
g_free (np);
last_node = GTK_CTREE_NODE_NEXT (last_node);
}
#endif
gtk_clist_thaw (GTK_CLIST (ctree));
}
@ -196,6 +208,13 @@ 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);
@ -204,18 +223,20 @@ gtk_dtree_do_select_dir (GtkDTree *dtree, char *path)
s++;
npath = g_strdup ("/");
printf ("Original %s\n", s);
while ((current = strtok (s, "/")) != NULL){
char *comp, *full_path;
GtkCTreeNode *node;
s = NULL;
printf ("Attempting component: %p, %s\n", current, current);
full_path = g_concat_dir_and_file (npath, current);
g_free (npath);
/* g_free (npath); */
npath = full_path;
node = gtk_dtree_lookup_dir (dtree, current_node, current);
if (!node){
printf ("Cargando: [%s]\n", current);
gtk_dtree_load_path (dtree, full_path, current_node, 2);
gtk_dtree_load_path (dtree, full_path, current_node, 1);
node = gtk_dtree_lookup_dir (dtree, current_node, current);
}
@ -225,14 +246,11 @@ gtk_dtree_do_select_dir (GtkDTree *dtree, char *path)
current_node = node;
} else
break;
s = NULL;
}
g_free (npath);
if (current_node){
if (!gtk_ctree_node_is_visible (GTK_CTREE (dtree), current_node)){
printf ("moviendo!\n");
gtk_ctree_node_moveto (GTK_CTREE (dtree), current_node, 0, 0.5, 0.0);
}
@ -427,14 +445,25 @@ gtk_dtree_init (GtkDTree *dtree)
void
gtk_dtree_construct (GtkDTree *dtree)
{
GtkCList *clist;
GtkCTree *ctree;
g_return_if_fail (dtree != NULL);
g_return_if_fail (GTK_IS_DTREE (dtree));
gtk_ctree_construct (GTK_CTREE (dtree), 1, 0, NULL);
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);
gtk_ctree_set_line_style (GTK_CTREE (dtree), GTK_CTREE_LINES_DOTTED);
gtk_ctree_set_reorderable (GTK_CTREE (dtree), TRUE);
gtk_clist_set_selection_mode(GTK_CLIST (dtree), GTK_SELECTION_BROWSE);
gdk_dtree_load_pixmaps (dtree);
gtk_dtree_load_root_tree (dtree);

View File

@ -16,6 +16,7 @@ typedef struct {
char *requested_path;
int visible;
int expanding;
GtkCTreeNode *root_node; /* root node */
GtkCTreeNode *last_node; /* last visited node */