Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
icon-lookup.c File Reference
#include "icon-lookup.h"
#include <glib.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include "ini.h"
#include "utils.h"
#include "log.h"
+ Include dependency graph for icon-lookup.c:

Go to the source code of this file.

Functions

int get_icon_theme (char *name)
 
int load_icon_theme_from_dir (const char *icon_dir, const char *subdir_theme)
 Load a theme from a directory.
 
void get_theme_path (void)
 
int load_icon_theme (char *name)
 Load a theme with given name from a standard icon directory.
 
void finish_icon_theme_dir (struct icon_theme_dir *dir)
 
void finish_icon_theme (struct icon_theme *theme)
 
void free_all_themes (void)
 Free all icon themes.
 
void add_default_theme (int theme_index)
 Add theme to the list of default themes.
 
char * find_icon_in_theme (const char *name, int theme_index, int size)
 Find icon of specified size in selected theme.
 
char * find_icon_in_theme_with_inherit (const char *name, int theme_index, int size)
 
char * find_icon_path (const char *name, int size)
 Find icon of specified size in the default theme or an inherited theme.
 

Variables

struct icon_themeicon_themes = NULL
 
int icon_themes_count = 0
 
int * default_themes_index = NULL
 
int default_themes_count = 0
 
GPtrArray * theme_path = NULL
 

Detailed Description

License
BSD-3-Clause

Definition in file icon-lookup.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 8 of file icon-lookup.c.

Function Documentation

◆ add_default_theme()

void add_default_theme ( int theme_index)

Add theme to the list of default themes.

The theme that's added first will be used first for lookup. After that the inherited themes will be used and only after that the next default theme will be used.

Parameters
theme_indexThe index of the theme as returned by load_icon_theme

Definition at line 234 of file icon-lookup.c.

◆ find_icon_in_theme()

char * find_icon_in_theme ( const char * name,
int theme_index,
int size )

Find icon of specified size in selected theme.

This function will not return icons that cannot be scaled to size according to index.theme.

Parameters
nameName of the icon or full path to it.
theme_indexIndex of the theme to use.
sizeSize of the icon.
Returns
The full path to the icon.
Return values
NULLif the icon cannot be found or is not readable.

Definition at line 251 of file icon-lookup.c.

◆ find_icon_in_theme_with_inherit()

char * find_icon_in_theme_with_inherit ( const char * name,
int theme_index,
int size )

Definition at line 290 of file icon-lookup.c.

◆ find_icon_path()

char * find_icon_path ( const char * name,
int size )

Find icon of specified size in the default theme or an inherited theme.

This function will not return icons that cannot be scaled to size according to index.theme.

Parameters
nameName of the icon or full path to it.
sizeSize of the icon.
Returns
The full path to the icon.
Return values
NULLif the icon cannot be found or is not readable.

Definition at line 308 of file icon-lookup.c.

◆ finish_icon_theme()

void finish_icon_theme ( struct icon_theme * theme)

Definition at line 205 of file icon-lookup.c.

◆ finish_icon_theme_dir()

void finish_icon_theme_dir ( struct icon_theme_dir * dir)

Definition at line 199 of file icon-lookup.c.

◆ free_all_themes()

void free_all_themes ( void )

Free all icon themes.

Definition at line 218 of file icon-lookup.c.

◆ get_icon_theme()

int get_icon_theme ( char * name)

Definition at line 25 of file icon-lookup.c.

◆ get_theme_path()

void get_theme_path ( void )

Definition at line 167 of file icon-lookup.c.

◆ load_icon_theme()

int load_icon_theme ( char * name)

Load a theme with given name from a standard icon directory.

Don't call this function if the theme is already loaded.

Parameters
nameName of the directory in which the theme is located. Note that it is NOT the name of the theme as specified in index.theme.
Returns
The index of the theme, which can be used to set it as default.
Return values
-1if the icon theme cannot be loaded.

Definition at line 184 of file icon-lookup.c.

◆ load_icon_theme_from_dir()

int load_icon_theme_from_dir ( const char * icon_dir,
const char * subdir_theme )

Load a theme from a directory.

Don't call this function if the theme is already loaded. It also loads the inherited themes. If there are no inherited themes, the theme "hicolor" is inherited.

If it succeeds loading the theme, it adds theme to the list "icon_themes".

Parameters
icon_dirA directory where icon themes are stored
subdir_themeThe subdirectory in which the theme is located
Returns
the index to the theme that was loaded
Return values
-1means no index was found

Definition at line 47 of file icon-lookup.c.

Variable Documentation

◆ default_themes_count

int default_themes_count = 0

Definition at line 23 of file icon-lookup.c.

◆ default_themes_index

int* default_themes_index = NULL

Definition at line 22 of file icon-lookup.c.

◆ icon_themes

struct icon_theme* icon_themes = NULL

Definition at line 20 of file icon-lookup.c.

◆ icon_themes_count

int icon_themes_count = 0

Definition at line 21 of file icon-lookup.c.

◆ theme_path

GPtrArray* theme_path = NULL

Definition at line 165 of file icon-lookup.c.