mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	sfdo: add sfdo_desktop_entry_name_lookup()
This commit is contained in:
		
							parent
							
								
									f69576f8a6
								
							
						
					
					
						commit
						57aee700f7
					
				
					 2 changed files with 46 additions and 5 deletions
				
			
		| 
						 | 
					@ -6,7 +6,18 @@ struct server;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void desktop_entry_init(struct server *server);
 | 
					void desktop_entry_init(struct server *server);
 | 
				
			||||||
void desktop_entry_finish(struct server *server);
 | 
					void desktop_entry_finish(struct server *server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct lab_data_buffer *desktop_entry_icon_lookup(struct server *server,
 | 
					struct lab_data_buffer *desktop_entry_icon_lookup(struct server *server,
 | 
				
			||||||
	const char *app_id, int size, float scale);
 | 
						const char *app_id, int size, float scale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * desktop_entry_name_lookup() - return the application name
 | 
				
			||||||
 | 
					 * from the sfdo desktop entry database based on app_id
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * The lifetime of the returned value is the same as that
 | 
				
			||||||
 | 
					 * of sfdo_desktop_db (from `struct sfdo.desktop_db`)
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const char *desktop_entry_name_lookup(struct server *server,
 | 
				
			||||||
 | 
						const char *app_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* LABWC_DESKTOP_ENTRY_H */
 | 
					#endif /* LABWC_DESKTOP_ENTRY_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -255,6 +255,18 @@ get_db_entry_by_id_fuzzy(struct sfdo_desktop_db *db, const char *app_id)
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct sfdo_desktop_entry *
 | 
				
			||||||
 | 
					get_desktop_entry(struct sfdo *sfdo, const char *app_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct sfdo_desktop_entry *entry = sfdo_desktop_db_get_entry_by_id(
 | 
				
			||||||
 | 
							sfdo->desktop_db, app_id, SFDO_NT);
 | 
				
			||||||
 | 
						if (!entry) {
 | 
				
			||||||
 | 
							entry = get_db_entry_by_id_fuzzy(sfdo->desktop_db, app_id);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return entry;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct lab_data_buffer *
 | 
					struct lab_data_buffer *
 | 
				
			||||||
desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
 | 
					desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
 | 
				
			||||||
		float scale)
 | 
							float scale)
 | 
				
			||||||
| 
						 | 
					@ -265,11 +277,7 @@ desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *icon_name = NULL;
 | 
						const char *icon_name = NULL;
 | 
				
			||||||
	struct sfdo_desktop_entry *entry = sfdo_desktop_db_get_entry_by_id(
 | 
						struct sfdo_desktop_entry *entry = get_desktop_entry(sfdo, app_id);
 | 
				
			||||||
		sfdo->desktop_db, app_id, SFDO_NT);
 | 
					 | 
				
			||||||
	if (!entry) {
 | 
					 | 
				
			||||||
		entry = get_db_entry_by_id_fuzzy(sfdo->desktop_db, app_id);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (entry) {
 | 
						if (entry) {
 | 
				
			||||||
		icon_name = sfdo_desktop_entry_get_icon(entry, NULL);
 | 
							icon_name = sfdo_desktop_entry_get_icon(entry, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -321,3 +329,25 @@ desktop_entry_icon_lookup(struct server *server, const char *app_id, int size,
 | 
				
			||||||
	free(ctx.path);
 | 
						free(ctx.path);
 | 
				
			||||||
	return icon_buffer;
 | 
						return icon_buffer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *
 | 
				
			||||||
 | 
					desktop_entry_name_lookup(struct server *server, const char *app_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct sfdo *sfdo = server->sfdo;
 | 
				
			||||||
 | 
						if (!sfdo) {
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct sfdo_desktop_entry *entry = get_desktop_entry(sfdo, app_id);
 | 
				
			||||||
 | 
						if (!entry) {
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size_t len;
 | 
				
			||||||
 | 
						const char *name = sfdo_desktop_entry_get_name(entry, &len);
 | 
				
			||||||
 | 
						if (!len) {
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return name;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue