Skip to content

Export and import feature for WebApps #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

JW-CodeArt
Copy link

This PR adds a graphical and user-friendly import and export feature. It exports the ".desktop" files and the custom icons to an archive, which can then be imported again. If the browser is missing, it takes the most similar alternative.

Issues related to the feature:
#292
#338
#347
#22
#232

Note: I tried to include the profiles directories, but it was unstable. For example, Firefox couldn't use a profile directory created with a newer version.

There are new menu buttons:
menu

The new shortcuts are also documented in the shortcuts window:
shortcuts

After clicking the "Export" menu button, a file chooser dialog will appear:
export_file_chooser

Once the process has finished, a new dialog will appear. Users can open the containing directory directly from the dialog.
export_success_dialog
import_success_dialog

The archive contains two folders:
/applications/* with all the desktop files
/ice/icons/* with all the icons
archive

- import and export menu entry
- new shortcuts for the import and the export tool
- a new tool window (ei_tool.ui)
- import and export handler in common.py
- remove unnecessary code and simplify it
- remove the unstable profile directory export and import functionality
- remove the abort function and button, as the process is so quick that they are completely unnecessary.
- define gladefiles constants at the beginning of webapp-manager.py
- update text and function names
- removed the ei_task class as it is no longer needed
- created a get_codename() function as this is used twice in common.py
- removed the tool window and the progress tracking because they are not needed
- removed the browser profile export feature because it is unstable. It takes extremely long and does not work with different browser versions
- implemented a function which checks during the import process whether the browser is installed on the device. If not, it searches an alternative browser on the device.
- declared gladefiles paths as constants at the beginning of webapp-manager.py
- removed all trailing spaces
- applied the maximum line length
- bug fix:
application crash
It now uses GLib.idle_add() to prevent the "Segmentation fault (core dumped)" error in GTK3
- try  catch in update_imported_desktop()
@JW-CodeArt JW-CodeArt force-pushed the feature_import_export branch from 58fd0d9 to 8f38735 Compare June 13, 2025 20:46
@clefebvre
Copy link
Member

Very nice. I like it, though the first thing that comes to mind, is if we really want to support this additional set of features.

Looking at the number of requests, we probably do, but I'd like it to be more minimalist.

  • There's no need for keyboard shortcuts for import/export
  • "Import" should be "Import..." to indicate a file path dialog follows. This is common practice for "Open...", "Save as..." etc.
  • You could hardcode the path for the export and skip straight to the result dialog. ~/web-apps-YYY-MM-DD.tar.
  • Do you handle collisions? What happens if you edit a webapp, reexport, reimport. Does it update it or create a duplicate?

@JW-CodeArt
Copy link
Author

Thanks for your feedback, Clefebvre. I will modify the code according your recommendations.
Regards,
Jannik

- revert unnecessary changes
- remove the keyboard shortcuts
- hardcoded the export path
- implemented better collision handling for re-export and re-import
- improved the browser check functionality when importing
- implemented draft for Suggestion:
Store custom icons automatically in the /ice/icons/ directory
@JW-CodeArt
Copy link
Author

JW-CodeArt commented Aug 2, 2025

I tried to reduce the code:
• Removed the keyboard shortcuts
• Renamed "Import" to "Import..."
• The export path is now hardcoded to "~/web-apps-YYYY-MM-DD.tar.gz", which makes the import_select_location() function much easier to read
• Collisions:
When re-exporting, the code adds suffixes such as "(1)", "(2)", and so on to the file name
When re-importing, the code skips files that already exist. It will overwrite web apps, except when the codename differs. In this case, it will create a duplicate.

To improve the stability of function "imported_desktop_update", it now handles the case where the browser name is not found in the supported browsers list.

Some thoughts about the custom icons.
Problem 1:
If they are not stored in the "/ice/icons/" directory, they will not be exported. My suggestion is to store all custom icons in the "/ice/icons/" directory. In my opinion, it is risky to create a link to an icon stored in the Downloads directory, for example. We could automatically move all icons into the directory which will then be handled by function "on_ok_button()"

Problem 2:
Web apps created in an earlier version do not necessarily have stored their icons in the "/ice/icons" directory. Therefore the user would have to edit all the affected web apps and press the OK button to store them in the correct directory. I suggest automatically moving all the icons to "/ice/icons" just before the export.

However, implementing these icon handling changes results in more code and might miss the goal of keeping it minimalistic but makes it more user-friendly.
See common.py prepare_export and webapp-manager.py on_ok_button

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants