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

Contributor update #2652

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
151 changes: 151 additions & 0 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,157 @@ generate_logo() { #display colorized Pi-Apps logo in terminal
${darkgreen} ${black} ${darkgreen} ${black} ${darkgreen} ${default}"
fi
}

generate_splashscreen() { # input is newline separated list of action;appname;status (the queue format) and a message to show as a grid to the user on completion of the manage daemon
local apps="$1"
local message="$2"

# return from function non-fatally if missing required input
[ -z "$apps" ] && return 0
[ -z "$message" ] && return 0

# Pass the app queue output to Python via a pipe
echo "$apps" | python3 -c "
import gi
import sys
import os
gi.require_version('Gtk', '3.0')
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import Gtk, GdkPixbuf

class ImageGridWindow(Gtk.Window):
def __init__(self, app_names):
super().__init__(title='Pi-Apps Actions Complete')

# Create a main vertical box to hold the label and grid
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)

# Create a frame to act as a border around the content
frame = Gtk.Frame()
frame.set_border_width(10) # Set the border width
frame.set_shadow_type(Gtk.ShadowType.NONE) # Hide the border color
frame.add(vbox) # Add the main vertical box to the frame

self.add(frame) # Add the frame to the window

# Create and add the label
label = Gtk.Label(label='$message')
label.set_line_wrap(True)
vbox.pack_start(label, False, False, 0)

# Create a Grid to hold the images and labels
grid = Gtk.Grid()
vbox.pack_start(grid, True, True, 0)

# Get the window size
self.set_default_size(400, 400)

# Add the images and app names to the grid
rows = 0
cols = 0
num_cols = 3 # Number of columns in the grid
for app_line in app_names:
action, app_name, status = app_line.split(';') # Split line into action, app name, and status
app_name = app_name.strip() # Remove any extra whitespace
action = action.strip() # Remove any extra whitespace
status = status.strip() # Remove any extra whitespace

# Generate the image path based on the app name
image_path = os.path.join('$DIRECTORY', 'apps', app_name, 'icon-64.png')

# Set action icon path based on the action
if action == 'install':
action_icon_path = os.path.join('$DIRECTORY', 'icons', 'install.png')
elif action == 'uninstall':
action_icon_path = os.path.join('$DIRECTORY', 'icons', 'uninstall.png')
elif action == 'update':
action_icon_path = os.path.join('$DIRECTORY', 'icons', 'update.png')
else:
action_icon_path = os.path.join('$DIRECTORY', 'icons', 'exit.png')

# Set status icon path based on the status
if status == '0':
status_icon_path = os.path.join('$DIRECTORY', 'icons', 'success.png')
else:
status_icon_path = os.path.join('$DIRECTORY', 'icons', 'failure.png')

# Create the app icon
app_image = Gtk.Image.new_from_file(image_path)

# Create and resize the action icon using GdkPixbuf
action_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(action_icon_path, -1, 32)
action_image = Gtk.Image.new_from_pixbuf(action_pixbuf)

# Create and resize the status icon using GdkPixbuf
status_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(status_icon_path, -1, 24)
status_image = Gtk.Image.new_from_pixbuf(status_pixbuf)

# Get the window's width and height
width, height = self.get_default_size()

# Set the size of the app image to fit proportionally within the grid cell
app_image.set_size_request(width // num_cols, height // 3) # Adjust the size of the app icon

# Create a fixed container to overlay action and status icons on top of the app icon
overlay = Gtk.Fixed()
overlay.set_size_request(width // num_cols, height // 3) # Set overlay size to match app icon size
overlay.put(app_image, 0, 0) # Place app image in the overlay

# Adjust the position of the action icon for more overlap
overlay.put(action_image, 6, 12) # Position action icon on top of the app image

# Get the width of the action image for positioning the status icon
action_image_width = action_pixbuf.get_width()

# Position status icon next to the action icon based on the width of the action icon
overlay.put(status_image, 10 + action_image_width, 18)


# Create a label for the app name
app_label = Gtk.Label(label=app_name)

# Add overlay and label to the grid at the current row and column
grid.attach(overlay, cols, rows, 1, 1)
grid.attach(app_label, cols, rows + 1, 1, 1) # Place label below the image

# Increment columns, and start a new row if the column count reaches 3
cols += 1
if cols == num_cols:
cols = 0
rows += 2 # Increment rows by 2 for the label

# Create an "Ok" button
ok_button = Gtk.Button(label='Ok')
ok_button.connect('clicked', Gtk.main_quit) # Connect the button to close the window

# Create a horizontal box to center the button
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
hbox.pack_start(Gtk.Label(), True, True, 0) # Add a spacer
hbox.pack_start(ok_button, False, False, 0) # Add the button
hbox.pack_start(Gtk.Label(), True, True, 0) # Add a spacer

# Pack the button box at the bottom of the vertical box
vbox.pack_start(hbox, False, False, 0)

# Set window properties
self.connect('destroy', Gtk.main_quit)

if __name__ == '__main__':
# The app names are read from stdin (piped from the bash script)
app_names = sys.stdin.read().splitlines()
print('Received apps:', app_names)
if app_names:
# Create and show the window with the grid of images
win = ImageGridWindow(app_names)
win.show_all()

# Start the GTK main loop
Gtk.main()
else:
print('No app names provided.')
"
}

#end of output functions

add_english() { #add en_US locale for more accurate error
Expand Down
89 changes: 89 additions & 0 deletions icons/vector/splashscreen-original.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion manage
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ $app"
[ -z "$geometry2" ] && geometry2='--center'

tail -f --retry "${DIRECTORY}/data/manage-daemon/yadlist" 2>/dev/null | yad --class Pi-Apps --name "Pi-Apps" --width=330 --height=400 "$geometry2" --title='Monitor Progress' \
--text="We are always looking for fresh ideas and new contributors to join our team: <a href="\""https://pi-apps.io/#get-involved"\"">https://pi-apps.io/#get-involved</a>" \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this I want to make a dedicated webpage for "new contributors" to link to that goes over the things we discussed in the discord, attempting to welcome users into the "family" of pi-apps contributors.

--list --tail --no-headers --column=:IMG --column=:IMG --column=Text --column=:IMG --column=Text \
--separator='\n' --window-icon="${DIRECTORY}/icons/logo.png" \
--dclick-action=true --select-action=true \
Expand Down Expand Up @@ -536,9 +537,17 @@ ${DIRECTORY}/icons/none-1.png
(sleep 5; kill $yadpid 2>/dev/null) &

#diagnose every failed app's logfile - list item format is $action;$app;$exitcode
failed_apps="$(echo "$queue" | grep ';1$' | awk -F';' '{print $2}')"
failed_apps="$(echo "$queue" | grep ';[0-9]\+$' | grep -v ';0$' | awk -F';' '{print $2}')"
diagnose_apps "$failed_apps"

successful_apps="$(echo "$queue" | grep ';0$' | awk -F';' '{print $2}')"

if [ ! -z "${successful_apps}" ]; then
generate_splashscreen "$queue" 'Thanks for using Pi-Apps! The following apps completed:'
else
generate_splashscreen "$queue" 'Thanks for using Pi-Apps! We are sorry but all app actions failed. Consider opening an issue on GitHub or joining our Discord as this likely indicates a larger issue with your system.'
fi

# if update refresh or update-file actions were run then update the .git folder
if [ "$sourced_updater" == 1 ]; then
update_git
Expand Down