1
1

1999-02-06 Federico Mena Quintero <federico@nuclecu.unam.mx>

* treestore.h: Replaced TreeStore.check_name_list by a GSList, for
	minimal memory savings.

	* treestore.c (tree_store_remove_entry): Removed unused code for
	base_sublevel computation.

1999-02-06  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* gtkdtree.c (gtk_dtree_insert_node): This function was never
	returning the newly-created sibling.
Этот коммит содержится в:
Miguel de Icaza 1999-02-07 05:04:09 +00:00
родитель 36a7fa63d7
Коммит 0108bdba8f
5 изменённых файлов: 70 добавлений и 63 удалений

@ -1,3 +1,8 @@
1999-02-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtkdtree.c (gtk_dtree_insert_node): This function was never
returning the newly-created sibling.
Sun Feb 7 05:29:17 1999 Timur Bakeyev <mc@bat.ru> Sun Feb 7 05:29:17 1999 Timur Bakeyev <mc@bat.ru>
* Makefile.in: Remove references and dependences to/from libslang - * Makefile.in: Remove references and dependences to/from libslang -

@ -15,6 +15,7 @@
#include <unistd.h> #include <unistd.h>
#include "dir-open.xpm" #include "dir-open.xpm"
#include "dir-close.xpm" #include "dir-close.xpm"
#include "main.h"
#include "treestore.h" #include "treestore.h"
#include "gtkdtree.h" #include "gtkdtree.h"
@ -101,19 +102,17 @@ gtk_dtree_contains (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
static GtkCTreeNode * static GtkCTreeNode *
gtk_dtree_insert_node (GtkDTree *dtree, GtkCTreeNode *parent, char *text) gtk_dtree_insert_node (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
{ {
GtkCTreeNode *sibling;
char *texts [1]; char *texts [1];
texts [0] = text; texts [0] = text;
sibling = gtk_ctree_insert_node ( return gtk_ctree_insert_node (GTK_CTREE (dtree), parent, NULL,
GTK_CTREE (dtree), parent, NULL, texts, TREE_SPACING,
texts, TREE_SPACING, dtree->pixmap_close,
dtree->pixmap_close, dtree->bitmap_close,
dtree->bitmap_close, dtree->pixmap_open,
dtree->pixmap_open, dtree->bitmap_open,
dtree->bitmap_open, FALSE, FALSE);
FALSE, FALSE);
} }
static gboolean static gboolean
@ -136,12 +135,12 @@ gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int leve
for (; (dirent = tree_store_readdir (dir)) != NULL; ){ for (; (dirent = tree_store_readdir (dir)) != NULL; ){
GtkCTreeNode *sibling; GtkCTreeNode *sibling;
char *text; char *text;
text = x_basename (dirent->name); text = x_basename (dirent->name);
/* Do not insert duplicates */ /* Do not insert duplicates */
sibling = gtk_dtree_contains (dtree, parent, text); sibling = gtk_dtree_contains (dtree, parent, text);
if (sibling == NULL) if (sibling == NULL)
sibling = gtk_dtree_insert_node (dtree, parent, text); sibling = gtk_dtree_insert_node (dtree, parent, text);
@ -333,7 +332,7 @@ gtk_dtree_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{ {
GtkDTree *dtree = GTK_DTREE (widget); GtkDTree *dtree = GTK_DTREE (widget);
char *request; char *request;
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
if (allocation->width != 0 && allocation->height != 0) if (allocation->width != 0 && allocation->height != 0)
dtree->visible = TRUE; dtree->visible = TRUE;
@ -348,7 +347,7 @@ gtk_dtree_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
if (!dtree->requested_path) if (!dtree->requested_path)
return; return;
if (strcmp (dtree->current_path, dtree->requested_path) == 0){ if (strcmp (dtree->current_path, dtree->requested_path) == 0){
g_free (dtree->requested_path); g_free (dtree->requested_path);
dtree->requested_path = NULL; dtree->requested_path = NULL;

@ -1,3 +1,11 @@
1999-02-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
* treestore.h: Replaced TreeStore.check_name_list by a GSList, for
minimal memory savings.
* treestore.c (tree_store_remove_entry): Removed unused code for
base_sublevel computation.
Sun Feb 7 06:11:48 1999 Timur Bakeyev <mc@bat.ru> Sun Feb 7 06:11:48 1999 Timur Bakeyev <mc@bat.ru>
* Makefile.in: Change calls to xmkdir to mkinstalldirs - this is more * Makefile.in: Change calls to xmkdir to mkinstalldirs - this is more

@ -85,10 +85,10 @@ static int str_common (char *s1, char *s2)
/etc.old/X11 /etc.old/X11
/etc.old/rc.d /etc.old/rc.d
/usr /usr
i.e. the required collating sequence when comparing two directory names is i.e. the required collating sequence when comparing two directory names is
'\0' < PATH_SEP < all-other-characters-in-encoding-order '\0' < PATH_SEP < all-other-characters-in-encoding-order
Since strcmp doesn't fulfil this requirement we use pathcmp when Since strcmp doesn't fulfil this requirement we use pathcmp when
inserting directory names into the list. The meaning of the return value inserting directory names into the list. The meaning of the return value
of pathcmp and strcmp are the same (an integer less than, equal to, or of pathcmp and strcmp are the same (an integer less than, equal to, or
@ -129,12 +129,12 @@ tree_store_whereis (char *name)
return NULL; return NULL;
} }
TreeStore * TreeStore *
tree_store_init (void) tree_store_init (void)
{ {
ts.tree_first = 0; ts.tree_first = 0;
ts.tree_last = 0; ts.tree_last = 0;
ts.check_name_stack = 0;
ts.refcount++; ts.refcount++;
return &ts; return &ts;
@ -466,9 +466,9 @@ remove_entry (tree_entry *entry)
tree_entry *current = entry->prev; tree_entry *current = entry->prev;
long submask = 0; long submask = 0;
tree_entry *ret = NULL; tree_entry *ret = NULL;
tree_store_notify_remove (entry); tree_store_notify_remove (entry);
/* Correct the submasks of the previous entries */ /* Correct the submasks of the previous entries */
if (entry->next) if (entry->next)
submask = entry->next->submask; submask = entry->next->submask;
@ -478,17 +478,18 @@ remove_entry (tree_entry *entry)
current->submask = submask; current->submask = submask;
current = current->prev; current = current->prev;
} }
/* Unlink the entry from the list */ /* Unlink the entry from the list */
if (entry->prev) if (entry->prev)
entry->prev->next = entry->next; entry->prev->next = entry->next;
else else
ts.tree_first = entry->next; ts.tree_first = entry->next;
if (entry->next) if (entry->next)
entry->next->prev = entry->prev; entry->next->prev = entry->prev;
else else
ts.tree_last = entry->prev; ts.tree_last = entry->prev;
/* Free the memory used by the entry */ /* Free the memory used by the entry */
g_free (entry->name); g_free (entry->name);
g_free (entry); g_free (entry);
@ -500,11 +501,11 @@ void
tree_store_remove_entry (char *name) tree_store_remove_entry (char *name)
{ {
tree_entry *current, *base, *old; tree_entry *current, *base, *old;
int len, base_sublevel; int len;
char *check_name; char *check_name;
g_return_if_fail (name != NULL); g_return_if_fail (name != NULL);
g_return_if_fail (ts.check_name_list != NULL); g_return_if_fail (ts.check_name_stack != NULL);
/* Miguel Ugly hack */ /* Miguel Ugly hack */
if (name [0] == PATH_SEP && name [1] == 0) if (name [0] == PATH_SEP && name [1] == 0)
@ -515,17 +516,13 @@ tree_store_remove_entry (char *name)
if (!base) if (!base)
return; /* Doesn't exist */ return; /* Doesn't exist */
check_name = ts.check_name_list->data; check_name = ts.check_name_stack->data;
if (check_name [0] == PATH_SEP && check_name [1] == 0)
base_sublevel = base->sublevel;
else
base_sublevel = base->sublevel + 1;
len = strlen (base->name); len = strlen (base->name);
current = base->next; current = base->next;
while (current while (current
&& strncmp (current->name, base->name, len) == 0 && strncmp (current->name, base->name, len) == 0
&& (current->name[len] == '\0' || current->name[len] == PATH_SEP)){ && (current->name[len] == '\0' || current->name[len] == PATH_SEP)) {
old = current; old = current;
current = current->next; current = current->next;
remove_entry (old); remove_entry (old);
@ -544,15 +541,14 @@ tree_store_mark_checked (const char *subname)
tree_entry *current, *base; tree_entry *current, *base;
int flag = 1, len; int flag = 1, len;
char *check_name; char *check_name;
if (!ts.loaded) if (!ts.loaded)
return; return;
if (ts.check_name_list == NULL) g_return_if_fail (ts.check_name_stack != NULL);
return;
check_name = ts.check_name_stack->data;
check_name = ts.check_name_list->data;
/* Calculate the full name of the subdirectory */ /* Calculate the full name of the subdirectory */
if (subname [0] == '.' && if (subname [0] == '.' &&
(subname [1] == 0 || (subname [1] == '.' && subname [2] == 0))) (subname [1] == 0 || (subname [1] == '.' && subname [2] == 0)))
@ -561,19 +557,19 @@ tree_store_mark_checked (const char *subname)
name = g_strconcat (PATH_SEP_STR, subname, NULL); name = g_strconcat (PATH_SEP_STR, subname, NULL);
else else
name = concat_dir_and_file (check_name, subname); name = concat_dir_and_file (check_name, subname);
/* Search for the subdirectory */ /* Search for the subdirectory */
current = ts.check_start; current = ts.check_start;
while (current && (flag = pathcmp (current->name, name)) < 0) while (current && (flag = pathcmp (current->name, name)) < 0)
current = current->next; current = current->next;
if (flag != 0){ if (flag != 0){
/* Doesn't exist -> add it */ /* Doesn't exist -> add it */
current = tree_store_add_entry (name); current = tree_store_add_entry (name);
tree_store_notify_add (current); tree_store_notify_add (current);
} }
g_free (name); g_free (name);
/* Clear the deletion mark from the subdirectory and its children */ /* Clear the deletion mark from the subdirectory and its children */
base = current; base = current;
if (base){ if (base){
@ -601,7 +597,7 @@ tree_store_start_check (char *path)
return NULL; return NULL;
ts.check_start = NULL; ts.check_start = NULL;
/* Search for the start of subdirectories */ /* Search for the start of subdirectories */
current = tree_store_whereis (path); current = tree_store_whereis (path);
if (!current){ if (!current){
@ -612,22 +608,22 @@ tree_store_start_check (char *path)
if (!S_ISDIR (s.st_mode)) if (!S_ISDIR (s.st_mode))
return NULL; return NULL;
current = tree_store_add_entry (path); current = tree_store_add_entry (path);
ts.check_name_list = g_list_prepend (ts.check_name_list, g_strdup (path)); ts.check_name_stack = g_slist_prepend (ts.check_name_stack, g_strdup (path));
return current; return current;
} }
ts.check_name_list = g_list_prepend (ts.check_name_list, g_strdup (path)); ts.check_name_stack = g_slist_prepend (ts.check_name_stack, g_strdup (path));
retval = current; retval = current;
/* Mark old subdirectories for delete */ /* Mark old subdirectories for delete */
ts.check_start = current->next; ts.check_start = current->next;
check_name = ts.check_name_list->data; check_name = ts.check_name_stack->data;
len = strlen (check_name); len = strlen (check_name);
current = ts.check_start; current = ts.check_start;
while (current while (current
&& strncmp (current->name, check_name, len) == 0 && strncmp (current->name, check_name, len) == 0
@ -655,17 +651,17 @@ tree_store_end_check (void)
tree_entry *current, *old; tree_entry *current, *old;
int len; int len;
char *check_name; char *check_name;
GList *list_head; GSList *stack_head;
if (!ts.loaded) if (!ts.loaded)
return; return;
g_return_if_fail (ts.check_name_list); g_return_if_fail (ts.check_name_stack != NULL);
/* Check delete marks and delete if found */ /* Check delete marks and delete if found */
check_name = ts.check_name_list->data; check_name = ts.check_name_stack->data;
len = strlen (check_name); len = strlen (check_name);
current = ts.check_start; current = ts.check_start;
while (current while (current
&& strncmp (current->name, check_name, len) == 0 && strncmp (current->name, check_name, len) == 0
@ -676,10 +672,10 @@ tree_store_end_check (void)
remove_entry (old); remove_entry (old);
} }
g_free (ts.check_name_list->data); g_free (ts.check_name_stack->data);
list_head = ts.check_name_list; stack_head = ts.check_name_stack;
ts.check_name_list = list_head->next; ts.check_name_stack = g_slist_remove_link (ts.check_name_stack, stack_head);
g_list_free_1 (list_head); g_slist_free_1 (stack_head);
} }
tree_entry * tree_entry *
@ -765,9 +761,8 @@ tree_store_notify_add (tree_entry *entry)
{ {
Hook *p = add_entry_hooks; Hook *p = add_entry_hooks;
tree_store_add_fn r; tree_store_add_fn r;
while (p){ while (p) {
r = (tree_store_add_fn) p->hook_fn; r = (tree_store_add_fn) p->hook_fn;
r (entry, p->hook_data); r (entry, p->hook_data);
p = p->next; p = p->next;
@ -781,7 +776,7 @@ tree_store_opendir (char *path)
tree_scan *scan; tree_scan *scan;
entry = tree_store_whereis (path); entry = tree_store_whereis (path);
if (!entry || (entry && !entry->scanned)){ if (!entry || (entry && !entry->scanned)) {
entry = tree_store_rescan (path); entry = tree_store_rescan (path);
if (!entry) if (!entry)
@ -790,12 +785,12 @@ tree_store_opendir (char *path)
if (entry->next == NULL) if (entry->next == NULL)
return NULL; return NULL;
scan = g_new (tree_scan, 1); scan = g_new (tree_scan, 1);
scan->base = entry; scan->base = entry;
scan->current = entry->next; scan->current = entry->next;
scan->sublevel = entry->next->sublevel; scan->sublevel = entry->next->sublevel;
scan->base_dir_len = strlen (path); scan->base_dir_len = strlen (path);
return scan; return scan;
} }

@ -24,7 +24,7 @@ typedef struct {
tree_entry *tree_first; /* First entry in the list */ tree_entry *tree_first; /* First entry in the list */
tree_entry *tree_last; /* Last entry in the list */ tree_entry *tree_last; /* Last entry in the list */
tree_entry *check_start; /* Start of checked subdirectories */ tree_entry *check_start; /* Start of checked subdirectories */
GList *check_name_list; GSList *check_name_stack;
unsigned int loaded : 1; unsigned int loaded : 1;
unsigned int dirty : 1; unsigned int dirty : 1;
} TreeStore; } TreeStore;