void remove_desktop(monitor_t *m, desktop_t *d) { put_status(SBSC_MASK_DESKTOP_REMOVE, "desktop_remove %s %s\n", m->name, d->name); bool was_focused = (mon != NULL && d == mon->desk); bool was_active = (d == m->desk); history_remove(d, NULL, false); unlink_desktop(m, d); empty_desktop(m, d); free(d); ewmh_update_current_desktop(); ewmh_update_number_of_desktops(); ewmh_update_desktop_names(); if (mon != NULL && m->desk != NULL) { if (was_focused) { update_focused(); } else if (was_active) { activate_node(m, m->desk, m->desk->focus); } } put_status(SBSC_MASK_REPORT); }
/** * @param cmd The command to remove from history * * Remove command from history. */ static void delete_entry ( const char *cmd ) { char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL ); history_remove ( path, cmd ); g_free ( path ); }
/** * @param entry The command entry to remove from history * * Remove command from history. */ static void delete_entry_history ( const DRunModeEntry *entry ) { char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL ); char *key = g_strdup_printf ( "%s:::%s", entry->root, entry->path ); history_remove ( path, key ); g_free ( key ); g_free ( path ); }
/** * @param entry The command entry to remove from history * * Remove command from history. */ static void delete_entry_history ( const DRunModeEntry *entry ) { char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL ); history_remove ( path, entry->path ); g_free ( path ); }
/** * @param host The host to remove from history * * Remove host from history. */ static void delete_ssh ( const char *host ) { if ( !host || !host[0] ) { return; } char *path = g_build_filename ( cache_dir, SSH_CACHE_FILE, NULL ); history_remove ( path, host ); g_free ( path ); }
static void delete_ssh ( const char *cmd ) { if ( !cmd || !cmd[0] ) { return; } char *path = NULL; path = g_strdup_printf ( "%s/%s", cache_dir, SSH_CACHE_FILE ); history_remove ( path, cmd ); g_free ( path ); }
int main(){ history_remove(); history_load(); history_add(__T("abcd")); assert( _tcscmp(history_get(0),__T("abcd"))==0 ); history_add(__T("qwerrr")); assert( _tcscmp(history_get(0),__T("qwerrr"))==0 ); history_add(__T("zxcv")); assert( _tcscmp(history_get(0),__T("zxcv"))==0 ); history_save(); history_load(); history_add(__T("zxcv1")); assert( _tcscmp(history_get(0),__T("zxcv1"))==0 ); assert( _tcscmp(history_get(1),__T("zxcv"))==0 ); assert( _tcscmp(history_get(2),__T("qwerrr"))==0 ); assert( _tcscmp(history_get(3),__T("abcd"))==0 ); history_delete(1); history_save(); history_load(); assert( _tcscmp(history_get(0),__T("zxcv1"))==0 ); assert( _tcscmp(history_get(1),__T("zxcv"))!=0 ); assert( _tcscmp(history_get(2),__T("qwerrr"))==0 ); assert( _tcscmp(history_get(3),__T("abcd"))==0 ); history_pin(2); check_ni_wi(); history_add(__T("asdff")); history_add(__T("asdfff")); history_add(__T("asdffff")); assert( _tcscmp(history_get(0),__T("asdffff"))==0 ); assert( _tcscmp(history_get(1),__T("asdfff"))==0 ); assert( _tcscmp(history_get(2),__T("qwerrr"))==0 ); assert( _tcscmp(history_get(3),__T("asdff"))==0 ); history_pin(3); check_ni_wi(); history_unpin(2); check_ni_wi(); history_pin(11); history_pin(13); check_ni_wi(); history_pin(5); history_pin(6); check_ni_wi(); history_delete(4); history_delete(5); check_ni_wi(); { TCHAR buffer[VIEW_HISTORY*MAX_PATH]; int len = history_to_json(buffer); buffer[len+1] = __T('\0'); _tprintf(__T("\n%d,%s\n"),len,buffer); } return 0; }
// execute sub-process static void delete_entry ( const char *cmd ) { /** * This happens in non-critical time (After launching app) * It is allowed to be a bit slower. */ char *path = g_strdup_printf ( "%s/%s", cache_dir, RUN_CACHE_FILE ); history_remove ( path, cmd ); g_free ( path ); }
void remove_desktop(monitor_t *m, desktop_t *d) { PRINTF("remove desktop %s\n", d->name); unlink_desktop(m, d); history_remove(d, NULL); empty_desktop(d); free(d); num_desktops--; ewmh_update_number_of_desktops(); ewmh_update_desktop_names(); put_status(); }
// execute sub-process static void delete_entry ( const char *cmd ) { /** * This happens in non-critical time (After launching app) * It is allowed to be a bit slower. */ char *path = NULL; if ( asprintf ( &path, "%s/%s", cache_dir, RUN_CACHE_FILE ) == -1 ) { return; } history_remove ( path, cmd ); free ( path ); }
static void get_apps_history ( DRunModePrivateData *pd ) { unsigned int length = 0; gchar *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL ); gchar **retv = history_get_list ( path, &length ); for ( unsigned int index = 0; index < length; index++ ) { char **st = g_strsplit ( retv[index], ":::", 2 ); if ( st && st[0] && st[1] ) { if ( !read_desktop_file ( pd, st[0], st[1] ) ) { history_remove ( path, retv[index] ); } } g_strfreev ( st ); } g_strfreev ( retv ); g_free ( path ); pd->history_length = pd->cmd_list_length; }
void remove_desktop(monitor_t *m, desktop_t *d) { put_status(SBSC_MASK_DESKTOP_REMOVE, "desktop_remove 0x%08X 0x%08X\n", m->id, d->id); remove_node(m, d, d->root); unlink_desktop(m, d); history_remove(d, NULL, false); free(d); ewmh_update_current_desktop(); ewmh_update_number_of_desktops(); ewmh_update_desktop_names(); if (mon != NULL && m->desk == NULL) { if (m == mon) { focus_node(m, NULL, NULL); } else { activate_node(m, NULL, NULL); } } put_status(SBSC_MASK_REPORT); }
static void history_test ( void ) { unlink ( file ); // Empty list. unsigned int length = 0; char **retv = history_get_list ( file, &length ); TASSERT ( retv == NULL ); TASSERT ( length == 0 ); // 1 item history_set ( file, "aap" ); retv = history_get_list ( file, &length ); TASSERT ( retv != NULL ); TASSERT ( length == 1 ); TASSERT ( strcmp ( retv[0], "aap" ) == 0 ); g_strfreev ( retv ); // Remove entry history_remove ( file, "aap" ); length = 0; retv = history_get_list ( file, &length ); TASSERT ( retv == NULL ); TASSERT ( length == 0 ); // 2 items history_set ( file, "aap" ); history_set ( file, "aap" ); retv = history_get_list ( file, &length ); TASSERT ( retv != NULL ); TASSERT ( length == 1 ); TASSERT ( strcmp ( retv[0], "aap" ) == 0 ); g_strfreev ( retv ); for ( unsigned int in = length + 1; in < 26; in++ ) { char *p = g_strdup_printf ( "aap%i", in ); printf ( "%s- %d\n", p, in ); history_set ( file, p ); retv = history_get_list ( file, &length ); TASSERT ( retv != NULL ); TASSERT ( length == ( in ) ); g_strfreev ( retv ); g_free ( p ); } // Max 25 entries. history_set ( file, "blaat" ); retv = history_get_list ( file, &length ); TASSERT ( retv != NULL ); TASSERT ( length == 25 ); g_strfreev ( retv ); }