]> Dogcows Code - chaz/tint2/blobdiff - src/launcher/launcher.c
fixed multi_desktop switching
[chaz/tint2] / src / launcher / launcher.c
index ea456546318be4fd5414353e4388fcae089fc6fa..54b6639f4b50be961427dc063e8ab95b5cbcde68 100644 (file)
@@ -76,16 +76,7 @@ void init_launcher_panel(void *p)
                return;
 
        launcher->area.on_screen = 1;
-       if (panel_horizontal) {
-               // panel horizonal => fixed height and posy
-               launcher->area.posy = panel->area.bg->border.width + panel->area.paddingy;
-               launcher->area.height = panel->area.height - (2 * launcher->area.posy);
-       }
-       else {
-               // panel vertical => fixed width, height, posy and posx
-               launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr;
-               launcher->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
-       }
+       panel_refresh = 1;
 
        fprintf(stderr, "Loading themes...\n");
        launcher_load_themes(launcher);
@@ -174,6 +165,7 @@ int resize_launcher(void *obj)
                LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
                if (launcherIcon->icon_size != icon_size || !launcherIcon->icon_original) {
                        launcherIcon->icon_size = icon_size;
+
                        // Get the path for an icon file with the new size
                        char *new_icon_path = icon_path(launcher, launcherIcon->icon_name, launcherIcon->icon_size);
                        if (!new_icon_path) {
@@ -482,29 +474,33 @@ IconTheme *load_theme(char *name)
        if (name == NULL)
                return NULL;
 
-       fprintf(stderr, "Loading icon theme %s\n", name);
-
-       file_name = malloc(100 + strlen(name));
-       sprintf(file_name, "~/.icons/%s/index.theme", name);
+       file_name = g_build_filename(g_get_home_dir(), ".icons", name, "index.theme", NULL);
        if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) {
-               sprintf(file_name, "/usr/share/icons/%s/index.theme", name);
+               g_free (file_name);
+               file_name = g_build_filename("/usr/share/icons", name, "index.theme", NULL);
                if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) {
-                       sprintf(file_name, "/usr/share/pixmaps/%s/index.theme", name);
+                       g_free (file_name);
+                       file_name = g_build_filename("/usr/share/pixmaps", name, "index.theme", NULL);
                        if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) {
-                               free(file_name);
+                               g_free (file_name);
                                file_name = NULL;
                        }
                }
        }
+
        if (!file_name) {
-               fprintf(stderr, "Could not load theme %s\n", name);
+               fprintf(stderr, "Could not found theme '%s'\n", name);
                return NULL;
        }
 
-       if ((f = fopen(file_name, "rt")) == NULL)
+       if ((f = fopen(file_name, "rt")) == NULL) {
+               fprintf(stderr, "Could not open theme '%s'\n", file_name);
                return NULL;
+       }
+       else
+               fprintf(stderr, "Loading icon theme '%s'\n", file_name);
 
-       free(file_name);
+       g_free (file_name);
 
        theme = calloc(1, sizeof(IconTheme));
        theme->name = strdup(name);
@@ -573,13 +569,13 @@ IconTheme *load_theme(char *name)
                                        // value is like 2
                                        sscanf(value, "%d", &current_dir->threshold);
                                } else if (strcmp(key, "Type") == 0) {
-                                       // value is Fixed, Scalable or Threshold
+                                       // value is Fixed, Scalable or Threshold : default to scalable for unknown Type.
                                        if (strcmp(value, "Fixed") == 0) {
                                                current_dir->type = ICON_DIR_TYPE_FIXED;
-                                       } else if (strcmp(value, "Scalable") == 0) {
-                                               current_dir->type = ICON_DIR_TYPE_SCALABLE;
                                        } else if (strcmp(value, "Threshold") == 0) {
                                                current_dir->type = ICON_DIR_TYPE_THRESHOLD;
+                                       } else {
+                                               current_dir->type = ICON_DIR_TYPE_SCALABLE;
                                        }
                                } else if (strcmp(key, "Context") == 0) {
                                        // usual values: Actions, Applications, Devices, FileSystems, MimeTypes
@@ -789,7 +785,8 @@ char *icon_path(Launcher *launcher, const char *icon_name, int size)
        }
 
        GSList *basenames = NULL;
-       basenames = g_slist_append(basenames, "~/.icons");
+       char *file_name = g_build_filename(g_get_home_dir(), ".icons", NULL);
+       basenames = g_slist_append(basenames, file_name);
        basenames = g_slist_append(basenames, "/usr/share/icons");
        basenames = g_slist_append(basenames, "/usr/share/pixmaps");
 
@@ -829,6 +826,7 @@ char *icon_path(Launcher *launcher, const char *icon_name, int size)
                        }
                }
        }
+       g_free (file_name);
 
        // Stage 2: best size match
        // Contrary to the freedesktop spec, we are not choosing the closest icon in size, but the next larger icon
This page took 0.030665 seconds and 4 git commands to generate.