Skip to content

Commit

Permalink
implement mime
Browse files Browse the repository at this point in the history
  • Loading branch information
sstendahl committed Nov 28, 2023
1 parent cd0cde5 commit 71d2722
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ install_data(application_id + '.gschema.xml',
install_mode: 'rwxrwxrwx'
)


install_data(
application_id + '.mime.xml',
install_dir: get_option('datadir') / 'mime/packages',
)

compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file',
Expand Down
1 change: 1 addition & 0 deletions data/se.sjoerd.Graphs.desktop.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Terminal=false
Type=Application
Categories=Education;Science
StartupNotify=true
MimeType=application/graphs
Keywords=Plotting;Graph;Graphing;Science;Mathematics;Math;Equations;Data;Plot;Visualisation;Visualization;Fitting;xrdml;
8 changes: 8 additions & 0 deletions data/se.sjoerd.Graphs.mime.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/graphs">
<comment>Graphs Project</comment>
<glob pattern="*.graphs"/>
<icon name="graphs"/>
</mime-type>
</mime-info>
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
update_desktop_database: true,
update_mime_database: true,
)
16 changes: 14 additions & 2 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
GraphsApplication
"""
import logging
import subprocess

Check failure on line 9 in src/application.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/application.py#L9 <401>

'subprocess' imported but unused
Raw output
./src/application.py:9:1: F401 'subprocess' imported but unused
from gettext import gettext as _

from gi.repository import GLib, Gio, Graphs

from graphs import actions, migrate, styles, ui
from graphs import actions, file_io, migrate, styles, ui
from graphs.data import Data

from matplotlib import font_manager
Expand All @@ -35,7 +36,7 @@ def __init__(self, application_id, **kwargs):
migrate.migrate_config(settings)
super().__init__(
application_id=application_id, settings=settings,
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
flags=Gio.ApplicationFlags.HANDLES_OPEN,
data=Data(self, settings), **kwargs,
)
font_list = font_manager.findSystemFonts(fontpaths=None, fontext="ttf")
Expand Down Expand Up @@ -106,6 +107,17 @@ def __init__(self, application_id, **kwargs):
"items-ignored", ui.on_items_ignored, self,
)


def do_open(self, file, _nfiles, _hint):

Check failure on line 111 in src/application.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/application.py#L111 <303>

too many blank lines (2)
Raw output
./src/application.py:111:5: E303 too many blank lines (2)
self.do_activate()
file = file[0]
try:
project_dict = file_io.parse_json(file)
except UnicodeDecodeError:
project_dict = migrate.migrate_project(file)
self.get_data().load_from_project_dict(project_dict)


def do_activate(self):
"""
Activate the application.
Expand Down

0 comments on commit 71d2722

Please sign in to comment.