Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark inactive "create" button as gray #244

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ ENV/
*.swp

*.~undo-tree~

# GTK glade temporary files
*.glade~
*.glade#
6 changes: 3 additions & 3 deletions qubes_config/new_qube.glade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path qubes-new-qube-light.css -->
Expand Down Expand Up @@ -424,10 +424,10 @@
<object class="GtkEntry" id="qube_name">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">The name of the qube can contain letters from a to z and underscore.</property>
<property name="tooltip-text" translatable="yes">Qube name can have up to 63 characters: A-Z, a-z, numbers and underscores</property>
<property name="max-length">64</property>
<property name="width-chars">32</property>
<property name="placeholder-text" translatable="yes">enter qube name</property>
<property name="placeholder-text" translatable="yes">enter qube name (required)</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down
8 changes: 7 additions & 1 deletion qubes_config/new_qube/new_qube_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
)

self.qube_name.connect("changed", self._name_changed)
self.qube_name.connect("focus-out-event", self._name_changed)

self.progress_bar_dialog.update_progress(0.1)

Expand Down Expand Up @@ -218,6 +219,8 @@
self.progress_bar_dialog.update_progress(1)
self.progress_bar_dialog.hide()

self.main_window.set_focus(self.qube_name)

def _quit(self, *_args):
self.quit()

Expand All @@ -232,11 +235,14 @@
(str,),
)

def _name_changed(self, entry: Gtk.Entry):
def _name_changed(self, entry: Gtk.Entry, event=None):
# pylint: disable=unused-argument
if not entry.get_text():
self.create_button.set_sensitive(False)
self.qube_name.get_style_context().add_class("invalid_entry")

Check warning on line 242 in qubes_config/new_qube/new_qube_app.py

View check run for this annotation

Codecov / codecov/patch

qubes_config/new_qube/new_qube_app.py#L242

Added line #L242 was not covered by tests
else:
self.create_button.set_sensitive(True)
self.qube_name.get_style_context().remove_class("invalid_entry")

def _type_selected(self, button: Gtk.RadioButton):
button_name = button.get_name()
Expand Down
12 changes: 12 additions & 0 deletions qubes_config/qubes-new-qube-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ radiobutton:checked radio {
color: @text-color;
}

.flat_button:disabled {
background: @dark-gray;
}

.invalid_entry {
border-color: red;
}

.invalid_entry:focus {
box-shadow: none;
}

#applications {
background: @top-background;
margin-top: 10px;
Expand Down