all repos — tint2 @ a8b217e0710f825a15850ebb888a73839db070d8

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

launcher: use the proper fallback icon; use getline (dynamically resized buffer) instead of fgets

git-svn-id: http://tint2.googlecode.com/svn/trunk@624 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
o9000 o9000
commit

a8b217e0710f825a15850ebb888a73839db070d8

parent

b3b26e199cdfc46f238c5fe796fbc4446c3155b8

1 files changed, 10 insertions(+), 5 deletions(-)

jump to
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -37,7 +37,7 @@ int launcher_max_icon_size;

char *icon_theme_name; XSettingsClient *xsettings_client; -#define ICON_FALLBACK "exec" +#define ICON_FALLBACK "application-x-executable" char *icon_path(Launcher *launcher, const char *icon_name, int size); void launcher_load_themes(Launcher *launcher);

@@ -405,7 +405,8 @@ //TODO Use UTF8 when parsing the file

int launcher_read_desktop_file(const char *path, DesktopEntry *entry) { FILE *fp; - char line[4096]; + char *line = NULL; + size_t line_size; char *key, *value; entry->name = entry->icon = entry->exec = NULL;

@@ -415,7 +416,7 @@ fprintf(stderr, "Could not open file %s\n", path);

return 0; } - while (fgets(line, sizeof(line), fp) != NULL) { + while (getline(&line, &line_size, fp) >= 0) { int len = strlen(line); if (len == 0) continue;

@@ -436,6 +437,7 @@ // entry->name, entry->icon, entry->exec will never be empty strings (can be NULL though)

expand_exec(entry, path); + free(line); return 1; }

@@ -465,7 +467,8 @@

IconTheme *theme; char *file_name; FILE *f; - char line[2048]; + char *line = NULL; + size_t line_size; if (name == NULL) return NULL;

@@ -502,7 +505,7 @@ theme->list_directories = NULL;

IconThemeDir *current_dir = NULL; int inside_header = 1; - while (fgets(line, sizeof(line), f) != NULL) { + while (getline(&line, &line_size, f) >= 0) { char *key, *value; int line_len = strlen(line);

@@ -595,6 +598,8 @@ }

} } fclose(f); + + free(line); return theme; }