Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aliereny committed Aug 15, 2021
1 parent 7e1c71b commit 530b5f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ install(
WORLD_READ WORLD_EXECUTE)

install(
FILESCheatsheet
FILES
${CMAKE_BINARY_DIR}/org.ccextractor.FastFingers.desktop
${CMAKE_BINARY_DIR}/org.ccextractor.Cheatsheet.desktop
DESTINATION
Expand Down
1 change: 0 additions & 1 deletion src/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ static void card_click_cb(FFCard *card, GdkEvent *event, gpointer user_data) {
GList *children = gtk_container_get_children(GTK_CONTAINER(card->box));
GtkWidget *title = (GtkWidget *)(g_list_nth(children, 1)->data);
const char *title_str = gtk_label_get_text(GTK_LABEL(title));
ff_error("(Info) App card %s choosed\n", title_str);

GtkWidget *stack = ff_get_stack();

Expand Down
27 changes: 21 additions & 6 deletions src/ff-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void ff_init_css(void) {
g_object_unref(provider);
}

cJSON *ff_find_shortcut_by_id(cJSON *app, int id){
cJSON *ff_find_shortcut_by_id(cJSON *app, int id) {
cJSON *group = cJSON_GetObjectItemCaseSensitive(app, "group");
for (int i = 0; i < cJSON_GetArraySize(group); ++i) {
cJSON *category = cJSON_GetArrayItem(group, i);
Expand Down Expand Up @@ -86,7 +86,8 @@ cJSON *ff_read_json(const char *path) {

file = fopen(path, "rb");
if (!file) {
ff_error("Couldn't open file %s: %s\n", path,
ff_error("Couldn't read file %s: %s\n"
"Trying to fetch...\n", path,
strerror(errno));

return NULL;
Expand Down Expand Up @@ -166,10 +167,9 @@ void ff_prepare_appdata(void) {
if (stat(path, &st) == -1) {
mkdir(path, 0777);
}

cJSON *appdata = ff_get_application("appdata");
if (!appdata) {
appdata = cJSON_CreateObject();
sprintf(path, "%s/.fastfingers/applications/appdata.json", homedir);
if (stat(path, &st) == -1) {
cJSON *appdata = cJSON_CreateObject();
cJSON_AddArrayToObject(appdata, "recent");

sprintf(path, "%s/.fastfingers/applications/appdata.json", homedir);
Expand All @@ -192,6 +192,21 @@ void ff_prepare_appdata(void) {
ff_fetch_application_data(name);
}
}
closedir(d);
}
sprintf(path, "/usr/share/fastfingers/applications");
d = opendir(path);
if (d) {
while ((dir = readdir(d))) {
if (!g_str_has_suffix(dir->d_name, ".json"))
continue;
char *name = g_strndup(dir->d_name, strlen(dir->d_name) - 5);
sprintf(path, "%s/.fastfingers/applications/%s.json", homedir, name);
if (stat(path, &st) == -1) {
ff_fetch_application_data(name);
}
}
closedir(d);
}
}

Expand Down

0 comments on commit 530b5f5

Please sign in to comment.