Add logo to status bar.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
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.handlers import handlers
|
||||||
from dsst_gtk3 import util, reload, client
|
from dsst_gtk3 import util, reload, client
|
||||||
|
|
||||||
@@ -17,6 +17,10 @@ class GtkUi:
|
|||||||
]
|
]
|
||||||
for path in glade_resources:
|
for path in glade_resources:
|
||||||
self.ui.add_from_string(util.load_ui_resource_string(path))
|
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
|
# Connect signal handlers to UI
|
||||||
self.handlers = handlers.Handlers(self)
|
self.handlers = handlers.Handlers(self)
|
||||||
self.ui.connect_signals(self.handlers)
|
self.ui.connect_signals(self.handlers)
|
||||||
|
|||||||
@@ -2505,7 +2505,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">2</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2519,7 +2519,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">3</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2531,7 +2531,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">4</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2542,6 +2542,18 @@
|
|||||||
<attribute name="weight" value="semibold"/>
|
<attribute name="weight" value="semibold"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="status_bar_logo">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stock">gtk-missing-image</property>
|
||||||
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
|||||||
BIN
dsst/dsst_gtk3/resources/images/dd.png
Normal file
BIN
dsst/dsst_gtk3/resources/images/dd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -4,7 +4,7 @@ This modules contains general utilities for the GTK application to use.
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk, GdkPixbuf
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from dsst_gtk3 import gtk_ui
|
from dsst_gtk3 import gtk_ui
|
||||||
from zipfile import ZipFile
|
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:
|
def load_ui_resource_from_file(resource_path: list) -> str:
|
||||||
project_base_dir = os.path.dirname(os.path.dirname(__file__))
|
project_base_dir = os.path.dirname(os.path.dirname(__file__))
|
||||||
full_path = os.path.join(project_base_dir, *resource_path)
|
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()
|
return file.read()
|
||||||
|
|
||||||
|
|
||||||
@@ -93,10 +93,35 @@ def load_ui_resource_string(resource_path: list) -> str:
|
|||||||
if os.path.isdir(os.path.dirname(__file__)):
|
if os.path.isdir(os.path.dirname(__file__)):
|
||||||
return load_ui_resource_from_file(resource_path)
|
return load_ui_resource_from_file(resource_path)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
return load_ui_resource_from_archive(resource_path)
|
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:
|
def load_config(config_path: str) -> dict:
|
||||||
with open(config_path) as config_file:
|
with open(config_path) as config_file:
|
||||||
return json.load(config_file)
|
return json.load(config_file)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from dsst_server.write_functions import WriteFunctions
|
from dsst_server.func_write import WriteFunctions
|
||||||
from dsst_server.read_functions import ReadFunctions
|
from dsst_server.func_read import ReadFunctions
|
||||||
|
|
||||||
|
|
||||||
class FunctionProxy(WriteFunctions, ReadFunctions):
|
class FunctionProxy(WriteFunctions, ReadFunctions):
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from common import util, models
|
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.func_proxy import FunctionProxy
|
||||||
from dsst_server.data_access import sql, sql_func
|
from dsst_server.data_access import sql, sql_func
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ class DsstServer:
|
|||||||
print('Database initialized ({})'.format(sql.db.database))
|
print('Database initialized ({})'.format(sql.db.database))
|
||||||
|
|
||||||
# Load access tokens and map them to their allowed methods
|
# Load access tokens and map them to their allowed methods
|
||||||
read_actions = util.list_class_methods(read_functions.ReadFunctions)
|
read_actions = util.list_class_methods(func_read.ReadFunctions)
|
||||||
write_actions = util.list_class_methods(write_functions.WriteFunctions)
|
write_actions = util.list_class_methods(func_write.WriteFunctions)
|
||||||
parm_access = {
|
parm_access = {
|
||||||
'r': read_actions,
|
'r': read_actions,
|
||||||
'rw': read_actions + write_actions
|
'rw': read_actions + write_actions
|
||||||
|
|||||||
Reference in New Issue
Block a user