Skip to content

Commit

Permalink
Port to Adw.Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Jan 27, 2024
1 parent 561495b commit 2d1d2bb
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 66 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ jobs:
uses: flatpak/flatpak-github-actions/flatpak-builder@v6.3
with:
bundle: hu.kramo.Hyperplane.Devel.flatpak
manifest-path: hu.kramo.Hyperplane.Devel.json
manifest-path: hu.kramo.Hyperplane.Devel.json
repository-url: https://nightly.gnome.org/gnome-nightly.flatpakrepo
repository-name: gnome-nightly

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The problem is that current methods for tagging files are OS-, file system- or a

The app was primarily built as a proof of concept for a non-hierarchical file manager whose storage can still be conveniently browsed via conventional file managers.

It is also a playground for design ideas like file extension badges or a symbolic grid view.
It is also a playground for design ideas like file extension badges or a symbolic grid view.

## The concept

Expand Down Expand Up @@ -48,6 +48,8 @@ If you want to test without risking data loss, please set the `$HYPHOME` environ

You can download the latest beta from the [Releases page](https://github.com/kra-mo/hyperplane/releases) or the latest in-development version from [here](https://nightly.link/kra-mo/hyperplane/workflows/ci/main/hu.kramo.Hyperplane.Devel-x86_64.zip).

You will need the [GNOME Nightly](https://nightly.gnome.org/) runtime installed to be able to test the app.

Please report any and all issues you find!

UX suggestions and missing feature reports are also welcome, even if it seems obvious.
Expand Down Expand Up @@ -95,4 +97,4 @@ Strings are not final yet, I will set up translations closer to an initial relea

The project follows the [GNOME Code of Conduct](https://wiki.gnome.org/Foundation/CodeOfConduct).

See [CODE_OF_CONDUCT.md](https://github.com/kra-mo/hyperplane/blob/main/CODE_OF_CONDUCT.md).
See [CODE_OF_CONDUCT.md](https://github.com/kra-mo/hyperplane/blob/main/CODE_OF_CONDUCT.md).
2 changes: 1 addition & 1 deletion hu.kramo.Hyperplane.Devel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id" : "hu.kramo.Hyperplane.Devel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "45",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "hyperplane",
"finish-args" : [
Expand Down
7 changes: 3 additions & 4 deletions hyperplane/file_manager_dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from gi.repository import Gio, GLib

from hyperplane import shared
from hyperplane.properties import HypPropertiesWindow
from hyperplane.properties import HypPropertiesDialog

INTERFACE_DESC = """
<node xmlns:doc="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
Expand Down Expand Up @@ -122,9 +122,8 @@ def __on_method_call(

win = shared.app.do_activate(parent)

properties = HypPropertiesWindow(gfile)
properties.set_transient_for(win)
properties.present()
properties = HypPropertiesDialog(gfile)
properties.present(win)

case "Introspect":
variant = GLib.Variant("(s)", (INTERFACE_DESC,))
Expand Down
6 changes: 3 additions & 3 deletions hyperplane/gtk/guide.blp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Gtk 4.0;
using Adw 1;

template $HypGuide : Adw.Window {
template $HypGuide : Adw.Dialog {
title: _("Welcome to Hyperplane");
default-height: 520;
default-width: 700;
content-height: 520;
content-width: 700;
WindowHandle {
Adw.ToolbarView {
[top]
Expand Down
12 changes: 2 additions & 10 deletions hyperplane/gtk/new-file-dialog.blp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Gtk 4.0;
using Adw 1;

template $HypNewFileDialog : Adw.Window {
modal: true;
template $HypNewFileDialog : Adw.Dialog {
title: _("New File");
default-width: 450;
default-height: 450;
content-width: 450;

Adw.NavigationView navigation_view {
Adw.NavigationPage {
Expand Down Expand Up @@ -33,12 +31,6 @@ template $HypNewFileDialog : Adw.Window {
}
}
}
ShortcutController {
Shortcut {
trigger: "Escape";
action: "action(window.close)";
}
}
}

Adw.PreferencesPage files_page {
Expand Down
2 changes: 1 addition & 1 deletion hyperplane/gtk/preferences.blp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Gtk 4.0;
using Adw 1;

template $HypPreferencesWindow : Adw.PreferencesWindow {
template $HypPreferencesDialog : Adw.PreferencesDialog {

Adw.PreferencesPage {
Adw.PreferencesGroup {
Expand Down
2 changes: 1 addition & 1 deletion hyperplane/gtk/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ menu view {
}

template $HypWindow : Adw.ApplicationWindow {
width-request: 234;
width-request: 360;
height-request: 176;
content:
Adw.TabOverview tab_overview {
Expand Down
2 changes: 1 addition & 1 deletion hyperplane/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@Gtk.Template(resource_path=shared.PREFIX + "/gtk/guide.ui")
class HypGuide(Adw.Window):
class HypGuide(Adw.Dialog):
"""A window showcasing the features of the app."""

__gtype_name__ = "HypGuide"
Expand Down
3 changes: 1 addition & 2 deletions hyperplane/items_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ def __new_file(self, *_args: Any) -> None:
dst = self.get_dst()

dialog = HypNewFileDialog(dst)
dialog.set_transient_for(self.get_root())
dialog.present()
dialog.present(self.get_root())

def __new_folder(self, *_args: Any) -> None:
dst = self.get_dst()
Expand Down
31 changes: 9 additions & 22 deletions hyperplane/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from hyperplane.file_manager_dbus import FileManagerDBusServer
from hyperplane.guide import HypGuide
from hyperplane.logging.logging_config import logging_config
from hyperplane.preferences import HypPreferencesWindow
from hyperplane.preferences import HypPreferencesDialog
from hyperplane.window import HypWindow


Expand Down Expand Up @@ -166,10 +166,9 @@ def do_activate(
if shared.state_schema.get_boolean("first-run"):
shared.state_schema.set_boolean("first-run", False)
guide = HypGuide()
guide.present()
guide.connect("close-request", lambda *_: win.present())
else:
win.present()
guide.present(win)

win.present()

return win

Expand Down Expand Up @@ -208,23 +207,12 @@ def create_action(
def __guide(self, *_args: Any) -> None:
guide = HypGuide()

guide.set_modal(True)
guide.set_transient_for(self.get_active_window())
guide.add_controller(shortcut_controller := Gtk.ShortcutController())
shortcut_controller.add_shortcut(
Gtk.Shortcut.new(
Gtk.ShortcutTrigger.parse_string("Escape"),
Gtk.NamedAction.new("window.close"),
),
)

guide.present()
guide.present(self.get_active_window())

def __about(self, *_args: Any) -> None:
about = Adw.AboutWindow.new_from_appdata(
about = Adw.AboutDialog.new_from_appdata(
shared.PREFIX + "/" + shared.APP_ID + ".metainfo.xml", shared.VERSION
)
about.set_transient_for(self.get_active_window())
about.set_developers(
(
"kramo https://kramo.hu",
Expand All @@ -235,12 +223,11 @@ def __about(self, *_args: Any) -> None:
about.set_copyright("© 2023-2024 kramo")
# Translators: Replace this with your name for it to show up in the about window
about.set_translator_credits = (_("translator_credits"),)
about.present()
about.present(self.get_active_window())

def __preferences(self, *_args: Any) -> None:
prefs = HypPreferencesWindow()
prefs.set_transient_for(self.get_active_window())
prefs.present()
prefs = HypPreferencesDialog()
prefs.present(self.get_active_window())

def __show_hidden(self, action: Gio.SimpleAction, _state: GLib.Variant) -> None:
value = not action.props.state.get_boolean()
Expand Down
4 changes: 2 additions & 2 deletions hyperplane/new_file_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@Gtk.Template(resource_path=shared.PREFIX + "/gtk/new-file-dialog.ui")
class HypNewFileDialog(Adw.Window):
class HypNewFileDialog(Adw.Dialog):
"""A dialog for creating a new file based on a template."""

__gtype_name__ = "HypNewFileDialog"
Expand Down Expand Up @@ -160,7 +160,7 @@ def __get_template_children(

def __open_templates(self, *_args: Any) -> None:
self.close()
self.get_transient_for().new_page(self.templates_dir)
self.get_root().new_page(self.templates_dir)

def __copy_active_gfile(self, *_args: Any) -> None:
if not self.can_create:
Expand Down
4 changes: 2 additions & 2 deletions hyperplane/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@


@Gtk.Template(resource_path=shared.PREFIX + "/gtk/preferences.ui")
class HypPreferencesWindow(Adw.PreferencesWindow):
class HypPreferencesDialog(Adw.PreferencesDialog):
"""The main preferences window."""

__gtype_name__ = "HypPreferencesWindow"
__gtype_name__ = "HypPreferencesDialog"

folders_switch_row = Gtk.Template.Child()
single_click_open_switch_row = Gtk.Template.Child()
Expand Down
14 changes: 7 additions & 7 deletions hyperplane/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

"""The item properties window."""
"""The item properties dialog."""
import logging
from stat import S_IEXEC
from typing import Any
Expand All @@ -30,11 +30,11 @@
from hyperplane.utils.tags import path_represents_tags


class HypPropertiesWindow(Adw.Window):
"""The item properties window."""
class HypPropertiesDialog(Adw.Dialog):
"""The item properties dialog."""

def __init__(self, gfile: Gio.File, **kwargs) -> None:
super().__init__(default_width=480, modal=True, title=_("Properties"), **kwargs)
super().__init__(content_width=480, title=_("Properties"), **kwargs)

self.add_controller(shortcut_controller := Gtk.ShortcutController())
shortcut_controller.add_shortcut(
Expand Down Expand Up @@ -97,11 +97,11 @@ def __init__(self, gfile: Gio.File, **kwargs) -> None:
navigation_view = Adw.NavigationView()
navigation_view.add(Adw.NavigationPage.new(toolbar_view, _("Properties")))

self.set_content(navigation_view)
self.set_child(navigation_view)

# Stop threads after the window is closed
# Stop threads after the dialog is closed
self.stop = False
self.connect("close-request", self.__stop)
self.connect("closed", self.__stop)

if gicon or thumbnail_path:
page.add(icon_group := Adw.PreferencesGroup())
Expand Down
12 changes: 5 additions & 7 deletions hyperplane/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from hyperplane.navigation_bin import HypNavigationBin
from hyperplane.path_bar import HypPathBar
from hyperplane.path_entry import HypPathEntry
from hyperplane.properties import HypPropertiesWindow
from hyperplane.properties import HypPropertiesDialog
from hyperplane.tag_row import HypTagRow
from hyperplane.utils.create_message_dialog import create_message_dialog
from hyperplane.utils.files import (
Expand Down Expand Up @@ -454,9 +454,8 @@ def __properties(self, *_args: Any) -> None:
return

# TODO: Allow viewing properties of multiple files
properties = HypPropertiesWindow(gfiles[0])
properties.set_transient_for(self)
properties.present()
properties = HypPropertiesDialog(gfiles[0])
properties.present(self)

def __update_tags(self, *_args: Any) -> None:
for tag_row in self.sidebar_tag_rows:
Expand Down Expand Up @@ -695,9 +694,8 @@ def __open_new_window_sidebar(self, *_args: Any) -> None:
self.new_window(shared.right_clicked_file)

def __properties_sidebar(self, *_args: Any) -> None:
properties = HypPropertiesWindow(shared.right_clicked_file)
properties.set_transient_for(self)
properties.present()
properties = HypPropertiesDialog(shared.right_clicked_file)
properties.present(self)

def __open_tag(self, *_args: Any) -> None:
self.new_page(tag=self.right_clicked_tag)
Expand Down

0 comments on commit 2d1d2bb

Please sign in to comment.