--- panelfm.c.debug 2006-11-15 21:29:26.000000000 +0900 +++ panelfm.c 2010-04-09 15:34:25.000000000 +0900 @@ -61,6 +61,8 @@ BONOBO_UI_VERB_END }; +static const char list_too_large[] = + "List too large, not showing anymore"; /******************************************************************/ void dbg (char *msg) @@ -171,6 +173,8 @@ GtkWidget *smenu, *menu_item, *tmp; GnomeVFSFileInfo *finfo; GList *f, *lst = NULL; + int list_too_large_p = 0; + size_t len_list_too_large = strlen (list_too_large) + 1; if (gnome_vfs_directory_list_load (&lst, (gchar *) selection, GNOME_VFS_FILE_INFO_DEFAULT | @@ -212,19 +216,29 @@ f = g_list_sort (lst, (GCompareFunc) cmp_finfo); while (f) { + size_t len; + finfo = f->data; f = f->next; if (finfo->name[0] == '.') // don't show dot-files continue; - sprintf (buf, "%s/%s", (char *)selection, finfo->name); - strcpy (menubufptr, buf); + + // sanity check + if (list_too_large_p) break; + + snprintf (buf, MAX_BUF - 1, "%s/%s", (char *)selection, finfo->name); + len = strlen (buf) + 1; + if (menubufptr + len + len_list_too_large + 2 > menubuf + MEM_SIZE) // Cannot add anymore + list_too_large_p = 1; + + strcpy (menubufptr, (list_too_large_p ? list_too_large : buf)); p = menubufptr; - menubufptr += strlen (buf) + 1; + if (! list_too_large_p) menubufptr += len; /*** * create submenu for directory entries ***/ - if (finfo->type == GNOME_VFS_FILE_TYPE_DIRECTORY) + if ((finfo->type == GNOME_VFS_FILE_TYPE_DIRECTORY) && (!list_too_large_p)) { menu_item = gtk_image_menu_item_new_with_label (finfo->name); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), @@ -247,7 +261,11 @@ } else // normal files are just menu items { - menu_item = gtk_image_menu_item_new_with_label (finfo->name); + const char *new_entry = list_too_large_p ? list_too_large : finfo->name; + menu_item = gtk_image_menu_item_new_with_label (new_entry); + + if (! list_too_large_p) + { gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), gtk_image_new_from_icon_name (gnome_icon_lookup (gtk_icon_theme_get_default (), @@ -262,7 +280,8 @@ g_signal_connect_after (GTK_OBJECT (menu_item), "activate", GTK_SIGNAL_FUNC (display_file_dir), (gpointer) p); - gtk_menu_shell_append (GTK_MENU_SHELL (smenu), menu_item); + } + gtk_menu_shell_append (GTK_MENU_SHELL (smenu), menu_item); } gtk_widget_show (smenu); gtk_widget_show (menu_item);