diff --git a/dsst/dsst_gtk3/gtk_ui.py b/dsst/dsst_gtk3/gtk_ui.py
index 6f9494a..7105ee3 100644
--- a/dsst/dsst_gtk3/gtk_ui.py
+++ b/dsst/dsst_gtk3/gtk_ui.py
@@ -1,7 +1,7 @@
import os
import gi
gi.require_version('Gtk', '3.0')
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
from dsst_gtk3.handlers import handlers
from dsst_gtk3 import util, reload, client
@@ -17,6 +17,10 @@ class GtkUi:
]
for path in glade_resources:
self.ui.add_from_string(util.load_ui_resource_string(path))
+ # Set the status bar logo
+ dd_logo = ['dsst_gtk3', 'resources', 'images', 'dd.png']
+ logo_pixbuf = util.load_image_resource(dd_logo, 60, 13)
+ logo = self.ui.get_object('status_bar_logo').set_from_pixbuf(logo_pixbuf)
# Connect signal handlers to UI
self.handlers = handlers.Handlers(self)
self.ui.connect_signals(self.handlers)
diff --git a/dsst/dsst_gtk3/resources/glade/window.glade b/dsst/dsst_gtk3/resources/glade/window.glade
index 02d2131..9dc74e5 100644
--- a/dsst/dsst_gtk3/resources/glade/window.glade
+++ b/dsst/dsst_gtk3/resources/glade/window.glade
@@ -2505,7 +2505,7 @@
False
True
- 2
+ 1
@@ -2519,7 +2519,7 @@
False
True
- 3
+ 2
@@ -2531,7 +2531,7 @@
False
True
- 4
+ 3
@@ -2542,6 +2542,18 @@
+
+ False
+ True
+ 4
+
+
+
+
False
True
diff --git a/dsst/dsst_gtk3/resources/images/dd.png b/dsst/dsst_gtk3/resources/images/dd.png
new file mode 100644
index 0000000..b455b2e
Binary files /dev/null and b/dsst/dsst_gtk3/resources/images/dd.png differ
diff --git a/dsst/dsst_gtk3/util.py b/dsst/dsst_gtk3/util.py
index 25d5142..55c480f 100644
--- a/dsst/dsst_gtk3/util.py
+++ b/dsst/dsst_gtk3/util.py
@@ -4,7 +4,7 @@ This modules contains general utilities for the GTK application to use.
import json
import os
from contextlib import contextmanager
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
from typing import Callable
from dsst_gtk3 import gtk_ui
from zipfile import ZipFile
@@ -75,7 +75,7 @@ def get_index_of_combo_model(widget, column: int, value: int):
def load_ui_resource_from_file(resource_path: list) -> str:
project_base_dir = os.path.dirname(os.path.dirname(__file__))
full_path = os.path.join(project_base_dir, *resource_path)
- with open(full_path, 'r') as file:
+ with open(full_path, 'r', encoding='utf8') as file:
return file.read()
@@ -93,10 +93,35 @@ def load_ui_resource_string(resource_path: list) -> str:
if os.path.isdir(os.path.dirname(__file__)):
return load_ui_resource_from_file(resource_path)
else:
-
return load_ui_resource_from_archive(resource_path)
+def load_image_resource_file(resource_path: list, width: int, height: int) -> GdkPixbuf:
+ project_base_dir = os.path.dirname(os.path.dirname(__file__))
+ full_path = os.path.join(project_base_dir, *resource_path)
+ return GdkPixbuf.Pixbuf.new_from_file_at_scale(full_path, width=width, height=height, preserve_aspect_ratio=False)
+
+
+def load_image_resource_archive(resource_path: list, width: int, height: int) -> GdkPixbuf:
+ resource_path = os.path.join(*resource_path)
+ zip_path = os.path.dirname(os.path.dirname(__file__))
+ with ZipFile(zip_path, 'r') as archive:
+ with archive.open(resource_path) as data:
+ loader = GdkPixbuf.PixbufLoader()
+ loader.write(data.read())
+ pixbuf = loader.get_pixbuf() # type: GdkPixbuf.Pixbuf
+ pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
+ loader.close()
+ return pixbuf
+
+
+def load_image_resource(resource_path: list, width: int, height: int) -> GdkPixbuf:
+ if os.path.isdir(os.path.dirname(__file__)):
+ return load_image_resource_file(resource_path, width, height)
+ else:
+ return load_image_resource_archive(resource_path, width, height)
+
+
def load_config(config_path: str) -> dict:
with open(config_path) as config_file:
return json.load(config_file)
diff --git a/dsst/dsst_server/func_proxy.py b/dsst/dsst_server/func_proxy.py
index 754ca0d..326f1a2 100644
--- a/dsst/dsst_server/func_proxy.py
+++ b/dsst/dsst_server/func_proxy.py
@@ -1,5 +1,5 @@
-from dsst_server.write_functions import WriteFunctions
-from dsst_server.read_functions import ReadFunctions
+from dsst_server.func_write import WriteFunctions
+from dsst_server.func_read import ReadFunctions
class FunctionProxy(WriteFunctions, ReadFunctions):
diff --git a/dsst/dsst_server/read_functions.py b/dsst/dsst_server/func_read.py
similarity index 100%
rename from dsst/dsst_server/read_functions.py
rename to dsst/dsst_server/func_read.py
diff --git a/dsst/dsst_server/write_functions.py b/dsst/dsst_server/func_write.py
similarity index 100%
rename from dsst/dsst_server/write_functions.py
rename to dsst/dsst_server/func_write.py
diff --git a/dsst/dsst_server/server.py b/dsst/dsst_server/server.py
index 5a0794d..0a2793c 100644
--- a/dsst/dsst_server/server.py
+++ b/dsst/dsst_server/server.py
@@ -7,7 +7,7 @@ import sys
import os
from common import util, models
-from dsst_server import read_functions, write_functions, tokens
+from dsst_server import func_read, func_write, tokens
from dsst_server.func_proxy import FunctionProxy
from dsst_server.data_access import sql, sql_func
@@ -31,8 +31,8 @@ class DsstServer:
print('Database initialized ({})'.format(sql.db.database))
# Load access tokens and map them to their allowed methods
- read_actions = util.list_class_methods(read_functions.ReadFunctions)
- write_actions = util.list_class_methods(write_functions.WriteFunctions)
+ read_actions = util.list_class_methods(func_read.ReadFunctions)
+ write_actions = util.list_class_methods(func_write.WriteFunctions)
parm_access = {
'r': read_actions,
'rw': read_actions + write_actions