-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from livMatS/17072023_ContentsPerPage
Version window
- Loading branch information
Showing
13 changed files
with
729 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import logging | ||
import os | ||
import dtoolcore | ||
from gi.repository import Gio, GLib, Gtk, Gdk | ||
from dtool_lookup_api.core.config import Config | ||
from ..utils.about import pretty_version_text | ||
from ..utils.logging import _log_nested | ||
from .settings_dialog import SettingsDialog | ||
|
||
# Initialize logging | ||
logger = logging.getLogger(__name__) | ||
|
||
@Gtk.Template(filename=f'{os.path.dirname(__file__)}/login_window.ui') | ||
class LoginWindow(Gtk.Window): | ||
__gtype_name__ = 'LoginWindow' | ||
|
||
# Map GTK Template Child widgets to Python attributes | ||
username_entry = Gtk.Template.Child() | ||
password_entry = Gtk.Template.Child() | ||
login_button = Gtk.Template.Child() | ||
skip_button = Gtk.Template.Child() | ||
settings_button = Gtk.Template.Child() | ||
|
||
# Initialize the LoginWindow instance | ||
def __init__(self, follow_up_action=None, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.application = self.get_application() | ||
self.settings_dialog = SettingsDialog(application=self.application) | ||
self._follow_up_action = follow_up_action | ||
|
||
# Set the default values from the Config, ensuring they are not None | ||
if Config.username is not None: | ||
self.username_entry.set_text(Config.username) | ||
if Config.password is not None: # Consider security implications | ||
self.password_entry.set_text(Config.password) | ||
|
||
|
||
|
||
# Handle the 'Login' button click event | ||
@Gtk.Template.Callback() | ||
def on_login_button_clicked(self, widget): | ||
|
||
|
||
|
||
# Fetch entered username and password | ||
username = self.username_entry.get_text() | ||
password = self.password_entry.get_text() | ||
|
||
# Create a GLib Variant tuple for authentication | ||
user_pass_auth_variant = GLib.Variant.new_tuple( | ||
GLib.Variant.new_string(username), | ||
GLib.Variant.new_string(password), | ||
GLib.Variant.new_string(Config.auth_url) | ||
) | ||
|
||
# Trigger the 'renew-token' action for authentication | ||
self.get_action_group("app").activate_action('renew-token', user_pass_auth_variant) | ||
|
||
if self._follow_up_action is not None: | ||
self._follow_up_action() | ||
|
||
self.close() | ||
|
||
# Handle the 'Skip' button click event | ||
@Gtk.Template.Callback() | ||
def on_skip_button_clicked(self, widget): | ||
# Close the login window | ||
self.close() | ||
|
||
@Gtk.Template.Callback() | ||
def settings_button_clicked_cb(self, widget): | ||
logger.info("Settings button clicked. Opening settings dialog.") | ||
self.settings_dialog.show() | ||
|
||
# Handle the window close event | ||
@Gtk.Template.Callback() | ||
def on_delete(self, widget, event): | ||
# Hide the window instead of deleting it | ||
return self.hide_on_delete() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Generated with glade 3.38.2 --> | ||
<interface> | ||
<requires lib="gtk+" version="3.24"/> | ||
<template class="LoginWindow" parent="GtkWindow"> | ||
<property name="can-focus">False</property> | ||
<property name="default-width">400</property> | ||
<property name="default-height">300</property> | ||
<signal name="delete-event" handler="on_delete" swapped="no"/> | ||
<child> | ||
<!-- n-columns=3 n-rows=3 --> | ||
<object class="GtkGrid"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<child> | ||
<object class="GtkBox"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="halign">center</property> | ||
<property name="valign">center</property> | ||
<property name="margin-start">50</property> | ||
<property name="margin-end">50</property> | ||
<property name="margin-top">50</property> | ||
<property name="margin-bottom">50</property> | ||
<property name="orientation">vertical</property> | ||
<child> | ||
<!-- n-columns=3 n-rows=3 --> | ||
<object class="GtkGrid"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="row-spacing">12</property> | ||
<property name="column-spacing">12</property> | ||
<child> | ||
<object class="GtkLabel"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="halign">end</property> | ||
<property name="label" translatable="yes">User Name</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">0</property> | ||
<property name="top-attach">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkEntry" id="username_entry"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="hexpand">True</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">1</property> | ||
<property name="top-attach">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkLabel"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="halign">end</property> | ||
<property name="label" translatable="yes">Password</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">0</property> | ||
<property name="top-attach">1</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkEntry" id="password_entry"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="hexpand">True</property> | ||
<property name="visibility">False</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">1</property> | ||
<property name="top-attach">1</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkButtonBox"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="layout-style">end</property> | ||
<child> | ||
<object class="GtkButton" id="skip_button"> | ||
<property name="label" translatable="yes">Skip</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="receives-default">True</property> | ||
<signal name="clicked" handler="on_skip_button_clicked" swapped="no"/> | ||
</object> | ||
<packing> | ||
<property name="expand">True</property> | ||
<property name="fill">True</property> | ||
<property name="position">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkButton" id="login_button"> | ||
<property name="label" translatable="yes">Login</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="receives-default">True</property> | ||
<signal name="clicked" handler="on_login_button_clicked" swapped="no"/> | ||
</object> | ||
<packing> | ||
<property name="expand">True</property> | ||
<property name="fill">True</property> | ||
<property name="position">1</property> | ||
</packing> | ||
</child> | ||
</object> | ||
<packing> | ||
<property name="left-attach">0</property> | ||
<property name="top-attach">2</property> | ||
<property name="width">2</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
</object> | ||
<packing> | ||
<property name="expand">False</property> | ||
<property name="fill">True</property> | ||
<property name="position">1</property> | ||
</packing> | ||
</child> | ||
</object> | ||
<packing> | ||
<property name="left-attach">0</property> | ||
<property name="top-attach">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
<child> | ||
<placeholder/> | ||
</child> | ||
</object> | ||
</child> | ||
<child type="titlebar"> | ||
<object class="GtkHeaderBar"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="title" translatable="yes">Login</property> | ||
<property name="show-close-button">True</property> | ||
<child> | ||
<object class="GtkButton" id="settings_button"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="receives-default">True</property> | ||
<property name="halign">end</property> | ||
<signal name="clicked" handler="settings_button_clicked_cb" swapped="no"/> | ||
<child> | ||
<object class="GtkImage"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="icon-name">preferences-system-symbolic</property> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
Oops, something went wrong.