Skip to content

Commit

Permalink
Merge pull request #38 from t00m/0.0.22
Browse files Browse the repository at this point in the history
0.0.22
  • Loading branch information
t00m authored May 10, 2024
2 parents ba3cf4a + 9538b2a commit 5221e05
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 90 deletions.
53 changes: 39 additions & 14 deletions MiAZ/frontend/desktop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def _on_activate(self, app):
self.win.set_default_icon_name('MiAZ')
self.theme = self.add_service('theme', Gtk.IconTheme.get_for_display(self.win.get_display()))
self.theme.add_search_path(ENV['GPATH']['ICONS'])
self.log.debug("Setting up Widget Factory")
self.factory = self.add_service('factory', MiAZFactory(self))
self.log.debug("Setting up MiAZ Actions")
self.actions = self.add_service('actions', MiAZActions(self))
self.log.debug("Setting up Widget GUI")
self._setup_gui()
self._setup_event_listener()
self._setup_plugin_manager()
Expand All @@ -91,11 +94,10 @@ def _on_window_close_request(self, window):
def _update_repo_settings(self, *args):
self.log.debug("Repo switched. Configuration switched")
widget_settings_repo = self.get_widget('settings-repo')
# ~ label_repo = self.get_widget('label_repo')
if widget_settings_repo is not None:
self.stack.remove(widget_settings_repo)
self.remove_widget('settings-repo')
# ~ self._setup_page_repo_settings()
# ~ #self._setup_page_repo_settings()
repo_active = self.conf['App'].get('current')

# ~ label_repo.set_markup(' [<b>%s</b>] ' % repo_active.replace('_', ' '))
Expand Down Expand Up @@ -313,20 +315,21 @@ def show_repo_settings(self, *args):

def show_app_about(self, *args):
self.show_stack_page_by_name('about')
self.message('About MiAZ app')

def show_workspace(self, *args):
self.show_stack_page_by_name('workspace')

def _setup_headerbar_left_menu(self):
# System menu
hbox = self.factory.create_box_horizontal(margin=0, spacing=0)
hbox.get_style_context().add_class(class_name='linked')
menubutton = self.get_widget('headerbar-button-menu-system')
menubutton.get_style_context().add_class(class_name='flat')
menubutton.set_valign(Gtk.Align.CENTER)
hbox.append(menubutton)
headerbar = self.get_widget('headerbar')
headerbar.pack_start(hbox)
# ~ def _setup_headerbar_left_menu(self):
# ~ # System menu
# ~ hbox = self.factory.create_box_horizontal(margin=0, spacing=0)
# ~ hbox.get_style_context().add_class(class_name='linked')
# ~ menubutton = self.get_widget('headerbar-button-menu-system')
# ~ menubutton.get_style_context().add_class(class_name='flat')
# ~ menubutton.set_valign(Gtk.Align.CENTER)
# ~ hbox.append(menubutton)
# ~ headerbar = self.get_widget('headerbar')
# ~ headerbar.pack_start(hbox)

def _setup_headerbar_left(self):
# System menu
Expand Down Expand Up @@ -357,24 +360,33 @@ def _setup_headerbar_center(self):
def _setup_gui(self):
# Widgets
## HeaderBar
self.log.debug("Setting up HeaderBar")
headerbar = self.add_widget('headerbar', Gtk.HeaderBar())
self.win.set_titlebar(headerbar)

## Central Box
self.log.debug("Setting up the main box")
self.mainbox = self.factory.create_box_vertical(vexpand=True)
self.win.set_child(self.mainbox)

## Stack & Stack.Switcher
self.log.debug("Setting up stack")
stack = self._setup_stack()
self.mainbox.append(stack)

# Setup system menu
self.log.debug("Setting up menues")
self._setup_menu_app()

# Setup headerbar
self._setup_headerbar_left_menu()
# Setup headerbar widgets
self.log.debug("Setting up headerbar")
self.log.debug("\tmenu")
# ~ self._setup_headerbar_left_menu()
self.log.debug("\tleft")
self._setup_headerbar_left()
self.log.debug("\tcenter")
self._setup_headerbar_center()
self.log.debug("\tright")
self._setup_headerbar_right()

# Create system pages
Expand All @@ -383,6 +395,7 @@ def _setup_gui(self):
self._setup_page_help()

# Statusbar
self.log.debug("Setting up Statusbar")
statusbar = self.add_widget('statusbar', MiAZStatusbar(self))
self.mainbox.append(statusbar)

Expand All @@ -393,14 +406,22 @@ def check_repository(self):
self.log.debug("Repo? '%s'", dir_repo)
if self.backend.repo_validate(dir_repo):
self.backend.repo_load(dir_repo)
self.log.debug("Setting up workspace")
if self.get_widget('workspace') is None:
self._setup_page_workspace()
if not self.plugins_loaded:
self.log.debug("Rloading plugins")
self.load_plugins()
self.log.debug("Setting up Rename widget")
if self.get_widget('rename') is None:
self._setup_page_rename()
self.log.debug("Setting up Repository settings widget")
if self.get_widget('settings-repo') is None:
self._setup_page_repo_settings()

workspace = self.get_widget('workspace')
workspace.initialize_caches()

self.show_stack_page_by_name('workspace')
valid = True
statusbar = self.get_widget('statusbar')
Expand Down Expand Up @@ -512,3 +533,7 @@ def remove_widget(self, name: str):
self.log.error("Widget '%s' doesn't exists", name)
return deleted

def message(self, message: str):
"""Statusbar message"""
statusbar = self.get_widget('statusbar')
statusbar.message(message)
10 changes: 7 additions & 3 deletions MiAZ/frontend/desktop/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ def create_button_content(self, icon_name='', title='', callback=None, width=16,

return hbox

def create_button(self, icon_name='', title='', callback=None, width=16, height=16, css_classes=[], data=None):
def create_button(self, icon_name='', title='', tooltip='', callback=None, width=16, height=16, css_classes=[], data=None):
button = Gtk.Button(css_classes=css_classes)

# ~ button.get_style_context().add_class(class_name='flat')
hbox = self.create_box_horizontal()
hbox = self.create_box_horizontal(spacing=0, margin=0)
if len(icon_name.strip()) > 0:
icon = self.icons.get_image_by_name(icon_name)
icon.set_pixel_size(width)
Expand All @@ -134,6 +135,9 @@ def create_button(self, icon_name='', title='', callback=None, width=16, height=
label.set_valign(Gtk.Align.CENTER)
hbox.append(label)

if len(tooltip) > 0:
button.set_tooltip_markup(tooltip)

button.set_child(hbox)

if callback is not None:
Expand All @@ -143,7 +147,7 @@ def create_button(self, icon_name='', title='', callback=None, width=16, height=

def create_button_toggle(self, icon_name: str = '', title: str = '', callback=None, css_classes=[], data=None) -> Gtk.ToggleButton:
button = Gtk.ToggleButton(css_classes=css_classes)
hbox = self.create_box_horizontal()
hbox = self.create_box_horizontal(spacing=0, margin=0)
if len(icon_name.strip()) == 0:
icon = Gtk.Image()
else:
Expand Down
2 changes: 2 additions & 0 deletions MiAZ/frontend/desktop/widgets/configview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def _setup_view(self):
frmView.set_child(self.view)
return selector

def _on_config_import(self, *args):
self.log.debug("Import configuration for '%s'", self.config.config_for)

class MiAZRepositories(MiAZConfigView):
"""Manage Repositories"""
Expand Down
7 changes: 4 additions & 3 deletions MiAZ/frontend/desktop/widgets/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def __init__(self, app) -> Gtk.Widget:
frmMain.set_child(self.boxMain)
self.append(frmMain)

self.btnAccept = self.factory.create_button('miaz-ok', _('Rename'), self.on_rename_accept, css_classes=['opaque'])
self.btnAccept = self.factory.create_button(icon_name='miaz-ok', title=_('Rename'), callback=self.on_rename_accept, css_classes=['opaque'])
self.btnAccept.set_sensitive(True)
# ~ self.btnAccept.get_style_context ().add_class('suggested-action')

self.btnAccept.set_can_focus(True)
self.btnAccept.set_focusable(True)
self.btnAccept.set_receives_default(True)
self.btnCancel = self.factory.create_button('miaz-cancel', _('Cancel'), self.on_rename_cancel)
self.btnCancel = self.factory.create_button(icon_name='miaz-cancel', title=_('Cancel'), callback=self.on_rename_cancel)
# ~ self.btnCancel.get_style_context ().add_class ('destructive-action')
self.btnPreview = self.factory.create_button('miaz-preview', _('Preview'))
self.btnPreview.connect('clicked', self._on_document_display)
Expand Down Expand Up @@ -188,6 +188,7 @@ def __create_field_0_date(self):
self.label_date = Gtk.Label()
self.label_date.get_style_context().add_class(class_name='caption')
self.entry_date = Gtk.Entry()
self.entry_date.set_visible(False)
self.entry_date.set_max_length(8)
self.entry_date.set_max_width_chars(8)
self.entry_date.set_width_chars(8)
Expand Down Expand Up @@ -242,7 +243,7 @@ def __create_field_6_concept(self):
button.set_has_frame(False)
self.entry_concept = Gtk.Entry()
self.entry_concept.set_width_chars(41)
self.entry_concept.set_alignment(1.0)
# ~ self.entry_concept.set_alignment(1.0)
self.entry_concept.set_placeholder_text(_('Type anything here...'))
boxValue.append(self.entry_concept)
boxValue.append(button)
Expand Down
11 changes: 9 additions & 2 deletions MiAZ/frontend/desktop/widgets/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, app, edit=True):
self.boxOper.set_margin_bottom(6)
self.boxOper.set_margin_start(0)
self.boxOper.set_margin_end(0)
self.boxOper.set_hexpand(True)
self.boxOper.set_vexpand(False)
boxEntry = Gtk.Box(spacing=0, orientation=Gtk.Orientation.HORIZONTAL)
boxEntry.set_hexpand(False)
Expand All @@ -56,10 +57,12 @@ def __init__(self, app, edit=True):
boxEntry.append(self.entry)
self.boxOper.append(boxEntry)
if edit:
self.boxButtons = Gtk.Box(spacing=3, orientation=Gtk.Orientation.HORIZONTAL)
self.boxButtons.set_hexpand(False)
self.boxButtons = Gtk.Box(spacing=0, orientation=Gtk.Orientation.HORIZONTAL)
self.boxButtons.get_style_context().add_class(class_name='linked')
self.boxButtons.set_hexpand(True)
self.boxButtons.append(self.factory.create_button(icon_name='miaz-list-add', title='', callback=self.on_item_available_add, data=self.config_for))
self.boxButtons.append(self.factory.create_button(icon_name='miaz-list-remove', title='', callback=self._on_item_available_remove))
self.boxButtons.append(self.factory.create_button(icon_name='miaz-import-config', tooltip='Import configuration', callback=self._on_config_import))
self.boxOper.append(self.boxButtons)
self.append(self.boxOper)
boxViews = self.factory.create_box_horizontal(spacing=0, hexpand=True, vexpand=True)
Expand Down Expand Up @@ -274,5 +277,9 @@ def _do_filter_view(self, item, filter_list_model):
def _on_entrysearch_delete(self, *args):
self.entry.set_text("")


def _on_config_import(self, *args):
pass

def get_search_entry(self):
return self.entry
5 changes: 5 additions & 0 deletions MiAZ/frontend/desktop/widgets/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def __init__(self, app):
self.set_margin_bottom(margin=6)
self.set_margin_start(margin=6)
self.set_margin_end(margin=6)
self.get_style_context().add_class(class_name='linked')
self.get_style_context().add_class(class_name='osd')
self.get_style_context().add_class(class_name='monospace')
self.get_style_context().add_class(class_name='toolbar')
self.get_style_context().add_class(class_name='linked')

# Separator
# ~ separator = Gtk.Separator.new(orientation=Gtk.Orientation.HORIZONTAL)
Expand Down
5 changes: 3 additions & 2 deletions MiAZ/frontend/desktop/widgets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _on_factory_bind_icon_type(self, factory, list_item):
mimetype, val = Gio.content_type_guess('filename=%s' % item.id)
gicon = self.srvicm.get_mimetype_icon(mimetype)
icon.set_from_gicon(gicon)
icon.set_pixel_size(24)
icon.set_pixel_size(48)

def _on_factory_setup_country(self, factory, list_item):
box = ColLabel()
Expand Down Expand Up @@ -244,12 +244,13 @@ def _on_factory_setup_flag(self, factory, list_item):

def _on_factory_bind_flag(self, factory, list_item):
box = list_item.get_child()
box.set_halign(Gtk.Align.CENTER)
item = list_item.get_item()
icon = box.get_first_child()
code = item.country
paintable = self.srvicm.get_flag_icon(code)
icon.set_from_paintable(paintable)
icon.set_pixel_size(24)
icon.set_pixel_size(48)

def _on_factory_setup_flag(self, factory, list_item):
box = ColIcon()
Expand Down
Loading

0 comments on commit 5221e05

Please sign in to comment.