Expand ~ in launcher_item_app
git-svn-id: http://tint2.googlecode.com/svn/trunk@726 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
committed by
mrovi9000@gmail.com
parent
0d1b78d808
commit
ba40b0752f
@@ -603,7 +603,7 @@ void add_entry (char *key, char *value)
|
|||||||
launcher_max_icon_size = atoi(value);
|
launcher_max_icon_size = atoi(value);
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "launcher_item_app") == 0) {
|
else if (strcmp(key, "launcher_item_app") == 0) {
|
||||||
char *app = strdup(value);
|
char *app = expand_tilde(value);
|
||||||
panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app);
|
panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app);
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
||||||
|
|||||||
@@ -1851,6 +1851,10 @@ void create_launcher(GtkWidget *parent)
|
|||||||
|
|
||||||
fprintf(stderr, "Loading .desktop files\n"); fflush(stderr);
|
fprintf(stderr, "Loading .desktop files\n"); fflush(stderr);
|
||||||
load_desktop_files("/usr/share/applications");
|
load_desktop_files("/usr/share/applications");
|
||||||
|
gchar *path = g_build_filename(g_get_home_dir(), ".local/share/applications", NULL);
|
||||||
|
load_desktop_files(path);
|
||||||
|
g_free(path);
|
||||||
|
|
||||||
load_icons(launcher_apps);
|
load_icons(launcher_apps);
|
||||||
load_icons(all_apps);
|
load_icons(all_apps);
|
||||||
fprintf(stderr, "Desktop files loaded\n"); fflush(stderr);
|
fprintf(stderr, "Desktop files loaded\n"); fflush(stderr);
|
||||||
|
|||||||
@@ -409,7 +409,9 @@ void config_write_launcher(FILE *fp)
|
|||||||
gtk_tree_model_get(GTK_TREE_MODEL(launcher_apps), &iter,
|
gtk_tree_model_get(GTK_TREE_MODEL(launcher_apps), &iter,
|
||||||
appsColPath, &app_path,
|
appsColPath, &app_path,
|
||||||
-1);
|
-1);
|
||||||
fprintf(fp, "launcher_item_app = %s\n", app_path);
|
char *contracted = contract_tilde(app_path);
|
||||||
|
fprintf(fp, "launcher_item_app = %s\n", contracted);
|
||||||
|
free(contracted);
|
||||||
g_free(app_path);
|
g_free(app_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1079,8 +1081,10 @@ void add_entry(char *key, char *value)
|
|||||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atoi(value));
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atoi(value));
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "launcher_item_app") == 0) {
|
else if (strcmp(key, "launcher_item_app") == 0) {
|
||||||
load_desktop_file(value, TRUE);
|
char *path = expand_tilde(value);
|
||||||
load_desktop_file(value, FALSE);
|
load_desktop_file(path, TRUE);
|
||||||
|
load_desktop_file(path, FALSE);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
||||||
set_current_icon_theme(value);
|
set_current_icon_theme(value);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <glib.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../server.h"
|
#include "../server.h"
|
||||||
|
|
||||||
@@ -95,6 +95,43 @@ void tint_exec(const char *command)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *expand_tilde(char *s)
|
||||||
|
{
|
||||||
|
const gchar *home = g_get_home_dir();
|
||||||
|
if (home &&
|
||||||
|
(strcmp(s, "~") == 0 ||
|
||||||
|
strstr(s, "~/") == s)) {
|
||||||
|
char *result = calloc(strlen(home) + strlen(s), 1);
|
||||||
|
strcat(result, home);
|
||||||
|
strcat(result, s + 1);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *contract_tilde(char *s)
|
||||||
|
{
|
||||||
|
const gchar *home = g_get_home_dir();
|
||||||
|
if (!home)
|
||||||
|
return strdup(s);
|
||||||
|
|
||||||
|
char *home_slash = calloc(strlen(home) + 1, 1);
|
||||||
|
strcat(home_slash, home);
|
||||||
|
strcat(home_slash, "/");
|
||||||
|
|
||||||
|
if ((strcmp(s, home) == 0 ||
|
||||||
|
strstr(s, home_slash) == s)) {
|
||||||
|
char *result = calloc(strlen(s) - strlen(home) + 1, 1);
|
||||||
|
strcat(result, "~");
|
||||||
|
strcat(result, s + strlen(home));
|
||||||
|
free(home_slash);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
free(home_slash);
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int hex_char_to_int (char c)
|
int hex_char_to_int (char c)
|
||||||
{
|
{
|
||||||
@@ -297,7 +334,6 @@ void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createHeuristicMask(DATA32* data, int w, int h)
|
void createHeuristicMask(DATA32* data, int w, int h)
|
||||||
{
|
{
|
||||||
// first we need to find the mask color, therefore we check all 4 edge pixel and take the color which
|
// first we need to find the mask color, therefore we check all 4 edge pixel and take the color which
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ int parse_line (const char *line, char **key, char **value);
|
|||||||
// execute a command by calling fork
|
// execute a command by calling fork
|
||||||
void tint_exec(const char* command);
|
void tint_exec(const char* command);
|
||||||
|
|
||||||
|
// Returns a copy of s in which "~" is expanded to the path to the user's home directory.
|
||||||
|
// The returned string must be freed by the caller.
|
||||||
|
char *expand_tilde(char *s);
|
||||||
|
|
||||||
|
// The opposite of expand_tilde: replaces the path to the user's home directory with "~".
|
||||||
|
// The returned string must be freed by the caller.
|
||||||
|
char *contract_tilde(char *s);
|
||||||
|
|
||||||
// conversion
|
// conversion
|
||||||
int hex_char_to_int (char c);
|
int hex_char_to_int (char c);
|
||||||
|
|||||||
Reference in New Issue
Block a user