/*============================================================================== * - yaffs_tab() * * - auto complete the command with <prefix> initial, store in <cmd_line> */ int yaffs_tab (const char *prefix, char *cmd_line) { static char last_prefix[PATH_LEN_MAX] = ""; static char last_path[PATH_LEN_MAX] = ""; static DL_NODE *pLast = NULL; char abs_path[PATH_LEN_MAX]; char file_name[20]; char *pSlash = strrchr (prefix, '/'); /* get path and name */ _make_abs_path(abs_path, prefix); /* get <abs_path> */ _dispatch_name(abs_path, file_name); /* get <path>, <name> */ if (strcmp (last_prefix, prefix) != 0) { /* if user change prefix */ strcpy (last_prefix, prefix); if (strcmp (last_path, abs_path) != 0) { strcpy (last_path, abs_path); _list_dir (abs_path, &_G_dir_list); } pLast = (DL_NODE *)DL_FIRST(&_G_dir_list); } else { /* use last prefix */ if (pLast == NULL) { pLast = (DL_NODE *)DL_FIRST(&_G_dir_list); } else { pLast = (DL_NODE *)DL_NEXT(pLast); } } /* store path */ if (pSlash != NULL) { /* there is some path */ strlcpy (cmd_line, prefix, pSlash - prefix + 2); } else { cmd_line[0] = '\0'; } /* find matched file name */ while (pLast != NULL) { if (strncmp (file_name, ((DIR_LIST_NODE *)pLast)->name, strlen(file_name)) == 0) { strcat (cmd_line, ((DIR_LIST_NODE *)pLast)->name); break; } pLast = (DL_NODE *)DL_NEXT(pLast); } if (pLast == NULL) { strcat (cmd_line, file_name); } return strlen (cmd_line); }
static void _init_fill_menu_from_dir (CDQuickBrowserItem *pItem) { const gchar *cDirPath = pItem->cPath; GtkWidget *pMenu = pItem->pSubMenu; GldiModuleInstance *myApplet = pItem->pApplet; //\______________ On recupere les items du repertoire. GList *pLocalItemList = _list_dir (cDirPath, myApplet); //\______________ On rajoute en premier une entree pour ouvrir le repertoire. CDQuickBrowserItem *pOpenDirItem = g_new0 (CDQuickBrowserItem, 1); pOpenDirItem->cPath = g_strdup (cDirPath); pOpenDirItem->pApplet = myApplet; pItem->pLocalItemList = g_list_prepend (pLocalItemList, pOpenDirItem); pItem->pCurrentItem = pItem->pLocalItemList->next; // on la rajoute au menu ici, pas en meme temps que les autres. //\______________ On ajoute cette entree dans le menu des maintenant. GtkWidget *pMenuItem = gldi_menu_add_item (pMenu, D_("Open this folder"), myConfig.bHasIcons ? GLDI_ICON_NAME_OPEN : NULL, G_CALLBACK(_on_activate_item), pOpenDirItem); // right click (e.g. open Bonobo or another file mgr) g_signal_connect (G_OBJECT (pMenuItem), "button-release-event", G_CALLBACK(_on_click_item), pOpenDirItem); }