]> Dogcows Code - chaz/tint2/commitdiff
launcher: use the proper fallback icon; use getline (dynamically resized buffer)...
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 13 Feb 2011 11:00:59 +0000 (11:00 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 13 Feb 2011 11:00:59 +0000 (11:00 +0000)
src/launcher/launcher.c

index e03fe22d57b9a99882af65e90e99d113b3c7a92b..1166dc0d7728a66c7e372d3084d16aee50bfe73c 100644 (file)
@@ -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 @@ void expand_exec(DesktopEntry *entry, const char *path)
 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 @@ int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
                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 @@ int launcher_read_desktop_file(const char *path, DesktopEntry *entry)
 
        expand_exec(entry, path);
        
+       free(line);
        return 1;
 }
 
@@ -465,7 +467,8 @@ IconTheme *load_theme(char *name)
        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 @@ IconTheme *load_theme(char *name)
 
        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);
@@ -596,6 +599,8 @@ IconTheme *load_theme(char *name)
        }
        fclose(f);
        
+       free(line);
+       
        return theme;
 }
 
This page took 0.023708 seconds and 4 git commands to generate.