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
This commit is contained in:
committed by
mrovi@interfete-web-club.com
parent
b3b26e199c
commit
a8b217e071
@@ -37,7 +37,7 @@ int launcher_max_icon_size;
|
|||||||
char *icon_theme_name;
|
char *icon_theme_name;
|
||||||
XSettingsClient *xsettings_client;
|
XSettingsClient *xsettings_client;
|
||||||
|
|
||||||
#define ICON_FALLBACK "exec"
|
#define ICON_FALLBACK "application-x-executable"
|
||||||
|
|
||||||
char *icon_path(Launcher *launcher, const char *icon_name, int size);
|
char *icon_path(Launcher *launcher, const char *icon_name, int size);
|
||||||
void launcher_load_themes(Launcher *launcher);
|
void launcher_load_themes(Launcher *launcher);
|
||||||
@@ -405,7 +405,8 @@ void expand_exec(DesktopEntry *entry, const char *path)
|
|||||||
int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
|
int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[4096];
|
char *line = NULL;
|
||||||
|
size_t line_size;
|
||||||
char *key, *value;
|
char *key, *value;
|
||||||
|
|
||||||
entry->name = entry->icon = entry->exec = NULL;
|
entry->name = entry->icon = entry->exec = NULL;
|
||||||
@@ -415,7 +416,7 @@ int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
while (getline(&line, &line_size, fp) >= 0) {
|
||||||
int len = strlen(line);
|
int len = strlen(line);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -436,6 +437,7 @@ int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
|
|||||||
|
|
||||||
expand_exec(entry, path);
|
expand_exec(entry, path);
|
||||||
|
|
||||||
|
free(line);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +467,8 @@ IconTheme *load_theme(char *name)
|
|||||||
IconTheme *theme;
|
IconTheme *theme;
|
||||||
char *file_name;
|
char *file_name;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char line[2048];
|
char *line = NULL;
|
||||||
|
size_t line_size;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -502,7 +505,7 @@ IconTheme *load_theme(char *name)
|
|||||||
|
|
||||||
IconThemeDir *current_dir = NULL;
|
IconThemeDir *current_dir = NULL;
|
||||||
int inside_header = 1;
|
int inside_header = 1;
|
||||||
while (fgets(line, sizeof(line), f) != NULL) {
|
while (getline(&line, &line_size, f) >= 0) {
|
||||||
char *key, *value;
|
char *key, *value;
|
||||||
|
|
||||||
int line_len = strlen(line);
|
int line_len = strlen(line);
|
||||||
@@ -596,6 +599,8 @@ IconTheme *load_theme(char *name)
|
|||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user