Mercurial > geeqie
diff src/editors.c @ 1479:d062522699dc
added simple desktop file editor
author | nadvornik |
---|---|
date | Fri, 27 Mar 2009 08:05:14 +0000 |
parents | 3cc98d5c6907 |
children | 1b2ddc6b2b27 |
line wrap: on
line diff
--- a/src/editors.c Thu Mar 26 21:49:20 2009 +0000 +++ b/src/editors.c Fri Mar 27 08:05:14 2009 +0000 @@ -67,6 +67,8 @@ */ GHashTable *editors = NULL; +GtkListStore *desktop_file_list; + #ifdef G_KEY_FILE_DESKTOP_GROUP #define DESKTOP_GROUP G_KEY_FILE_DESKTOP_GROUP @@ -183,6 +185,7 @@ const gchar *key = filename_from_path(path); gchar **categories, **only_show_in, **not_show_in; gchar *try_exec; + GtkTreeIter iter; if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */ @@ -229,12 +232,12 @@ found = TRUE; break; } - if (!found) editor->hidden = TRUE; + if (!found) editor->ignored = TRUE; g_strfreev(categories); } else { - editor->hidden = TRUE; + editor->ignored = TRUE; } only_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "OnlyShowIn", NULL, NULL); @@ -248,7 +251,7 @@ found = TRUE; break; } - if (!found) editor->hidden = TRUE; + if (!found) editor->ignored = TRUE; g_strfreev(only_show_in); } @@ -263,23 +266,23 @@ found = TRUE; break; } - if (found) editor->hidden = TRUE; + if (found) editor->ignored = TRUE; g_strfreev(not_show_in); } try_exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "TryExec", NULL); - if (try_exec && !editor->hidden) + if (try_exec && !editor->hidden && !editor->ignored) { gchar *try_exec_res = g_find_program_in_path(try_exec); if (!try_exec_res) editor->hidden = TRUE; g_free(try_exec_res); g_free(try_exec); } - - if (editor->hidden) + + if (editor->ignored) { - /* hidden editors will be deleted, no need to parse the rest */ + /* ignored editors will be deleted, no need to parse the rest */ g_key_file_free(key_file); return TRUE; } @@ -337,6 +340,16 @@ editor->flags |= editor_command_parse(editor, NULL, NULL); g_key_file_free(key_file); + + if (editor->ignored) return TRUE; + + gtk_list_store_append(desktop_file_list, &iter); + gtk_list_store_set(desktop_file_list, &iter, + DESKTOP_FILE_COLUMN_KEY, key, + DESKTOP_FILE_COLUMN_NAME, editor->name, + DESKTOP_FILE_COLUMN_HIDDEN, editor->hidden, + DESKTOP_FILE_COLUMN_WRITABLE, access_file(path, W_OK), + DESKTOP_FILE_COLUMN_PATH, path, -1); return TRUE; } @@ -344,7 +357,7 @@ static gboolean editor_remove_desktop_file_cb(gpointer key, gpointer value, gpointer user_data) { EditorDescription *editor = value; - return editor->hidden; + return editor->hidden || editor->ignored; } static void editor_read_desktop_dir(const gchar *path) @@ -385,6 +398,14 @@ gchar **split_dirs; gint i; + if (desktop_file_list) + { + gtk_list_store_clear(desktop_file_list); + } + else + { + desktop_file_list = gtk_list_store_new(DESKTOP_FILE_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING); + } if (editors) { g_hash_table_destroy(editors);