Support for launcher_apps_dir
git-svn-id: http://tint2.googlecode.com/svn/trunk@727 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
ba40b0752f
commit
da7efb27a9
5 changed files with 60 additions and 2 deletions
24
src/config.c
24
src/config.c
|
@ -149,6 +149,25 @@ int config_get_monitor(char* monitor)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void load_launcher_app_dir(const char *path)
|
||||
{
|
||||
GDir *d = g_dir_open(path, 0, NULL);
|
||||
if (d) {
|
||||
const gchar *name;
|
||||
while ((name = g_dir_read_name(d))) {
|
||||
gchar *file = g_build_filename(path, name, NULL);
|
||||
if (!g_file_test(file, G_FILE_TEST_IS_DIR) &&
|
||||
g_str_has_suffix(file, ".desktop")) {
|
||||
panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, (char *)strdup(file));
|
||||
} else if (g_file_test(file, G_FILE_TEST_IS_DIR)) {
|
||||
load_launcher_app_dir(file);
|
||||
}
|
||||
g_free(file);
|
||||
}
|
||||
g_dir_close(d);
|
||||
}
|
||||
}
|
||||
|
||||
void add_entry (char *key, char *value)
|
||||
{
|
||||
char *value1=0, *value2=0, *value3=0;
|
||||
|
@ -606,6 +625,11 @@ void add_entry (char *key, char *value)
|
|||
char *app = expand_tilde(value);
|
||||
panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app);
|
||||
}
|
||||
else if (strcmp(key, "launcher_apps_dir") == 0) {
|
||||
char *path = expand_tilde(value);
|
||||
load_launcher_app_dir(path);
|
||||
free(path);
|
||||
}
|
||||
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
||||
// if XSETTINGS manager running, tint2 use it.
|
||||
if (!icon_theme_name)
|
||||
|
|
|
@ -428,7 +428,7 @@ IconThemeWrapper *load_themes(const char *icon_theme_name)
|
|||
while ((name = g_dir_read_name(d))) {
|
||||
gchar *file_name = g_build_filename(path, name, "index.theme", NULL);
|
||||
if (g_file_test(file_name, G_FILE_TEST_EXISTS) &&
|
||||
g_file_test(file_name, G_FILE_TEST_IS_REGULAR)) {
|
||||
!g_file_test(file_name, G_FILE_TEST_IS_DIR)) {
|
||||
load_themes_helper(name, &wrapper->themes_fallback, &queued);
|
||||
}
|
||||
g_free(file_name);
|
||||
|
|
|
@ -102,6 +102,7 @@ GtkWidget *tooltip_background;
|
|||
|
||||
GtkListStore *launcher_apps, *all_apps;
|
||||
GtkWidget *launcher_apps_view, *all_apps_view;
|
||||
GtkWidget *launcher_apps_dirs;
|
||||
|
||||
GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing;
|
||||
GtkWidget *margin_x, *margin_y;
|
||||
|
@ -1538,7 +1539,7 @@ void load_desktop_files(const gchar *path)
|
|||
const gchar *name;
|
||||
while ((name = g_dir_read_name(d))) {
|
||||
gchar *file = g_build_filename(path, name, NULL);
|
||||
if (g_file_test(file, G_FILE_TEST_IS_REGULAR) &&
|
||||
if (!g_file_test(file, G_FILE_TEST_IS_DIR) &&
|
||||
g_str_has_suffix(file, ".desktop")) {
|
||||
load_desktop_file(file, FALSE);
|
||||
} else if (g_file_test(file, G_FILE_TEST_IS_DIR)) {
|
||||
|
@ -1762,6 +1763,16 @@ void create_launcher(GtkWidget *parent)
|
|||
|
||||
change_paragraph(parent);
|
||||
|
||||
label = gtk_label_new(_("<b>Additional application directories</b>"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
|
||||
gtk_widget_show(label);
|
||||
gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0);
|
||||
|
||||
launcher_apps_dirs = gtk_entry_new();
|
||||
gtk_widget_show(launcher_apps_dirs);
|
||||
gtk_box_pack_start(GTK_BOX(parent), launcher_apps_dirs, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new(_("<b>Appearance</b>"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
|
||||
|
|
|
@ -115,6 +115,7 @@ enum {
|
|||
|
||||
extern GtkListStore *launcher_apps, *all_apps;
|
||||
extern GtkWidget *launcher_apps_view, *all_apps_view;
|
||||
extern GtkWidget *launcher_apps_dirs;
|
||||
|
||||
extern GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing;
|
||||
extern GtkWidget *margin_x, *margin_y;
|
||||
|
|
|
@ -415,6 +415,18 @@ void config_write_launcher(FILE *fp)
|
|||
g_free(app_path);
|
||||
}
|
||||
|
||||
gchar **app_dirs = g_strsplit(gtk_entry_get_text(GTK_ENTRY(launcher_apps_dirs)), ",", 0);
|
||||
for (index = 0; app_dirs[index]; index++) {
|
||||
gchar *dir = app_dirs[index];
|
||||
g_strstrip(dir);
|
||||
if (strlen(dir) > 0) {
|
||||
char *contracted = contract_tilde(dir);
|
||||
fprintf(fp, "launcher_item_app = %s\n", contracted);
|
||||
free(contracted);
|
||||
}
|
||||
}
|
||||
g_strfreev(app_dirs);
|
||||
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
|
@ -1086,6 +1098,16 @@ void add_entry(char *key, char *value)
|
|||
load_desktop_file(path, FALSE);
|
||||
free(path);
|
||||
}
|
||||
else if (strcmp(key, "launcher_apps_dir") == 0) {
|
||||
char *path = expand_tilde(value);
|
||||
|
||||
if (gtk_entry_get_text_length(GTK_ENTRY(launcher_apps_dirs)) > 0) {
|
||||
gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), ",");
|
||||
}
|
||||
gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), path);
|
||||
|
||||
free(path);
|
||||
}
|
||||
else if (strcmp(key, "launcher_icon_theme") == 0) {
|
||||
set_current_icon_theme(value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue