add shortcut to save current uri to a file

This commit is contained in:
NunoSempere 2024-07-24 12:58:54 -04:00
parent c3ac0c0333
commit 20a0c15caa
3 changed files with 17 additions and 1 deletions

View File

@ -97,6 +97,7 @@ typedef enum {
rebig_window,
prettify,
save_uri_to_txt,
} func;
static struct {
@ -134,5 +135,6 @@ static struct {
{ CTRL, KEY(N), finder_prev },
{ CTRL, KEY(Left), halve_window },
{ CTRL, KEY(Right), rebig_window },
{ CTRL, KEY(p), prettify }
{ CTRL, KEY(p), prettify },
{ CTRL, KEY(s), save_uri_to_txt }
};

View File

@ -88,6 +88,8 @@ runtime_files:
sudo mkdir -p /opt/rosenrot/
sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/
sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/
sudo touch /opt/rosenrot/uris.txt
sudo chmod a+rw /opt/rosenrot/uris.txt
sudo cp -r images/flower-imgs /opt/rosenrot/
sudo cp plugins/style/style.js /opt/rosenrot/
sudo cp plugins/readability/readability.js /opt/rosenrot/

View File

@ -367,6 +367,18 @@ int handle_shortcut(func id)
}
break;
}
case save_uri_to_txt: {
const char* uri = webkit_web_view_get_uri(view);
FILE *f = fopen("/opt/rosenrot/uris.txt", "a");
if (f == NULL) {
printf("Error opening /opt/rosenrot/uris.txt");
} else {
fprintf(f, "%s", uri);
fclose(f);
webkit_web_view_evaluate_javascript(view, "alert('Saved current uri to /opt/rosenrot/uris.txt')", -1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
}
}
}
return 1;