Commit 9e45fdfd authored by Guido Gunther's avatar Guido Gunther
Browse files

Add PhoshSplash



Splash screen for launching applications
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 6c0d1625
......@@ -82,6 +82,8 @@ libphosh_tool_sources = [
'overview.h',
'status-icon.c',
'status-icon.h',
'splash.c',
'splash.h',
'system-modal.c',
'system-modal.h',
'thumbnail.c',
......
......@@ -13,6 +13,7 @@
<file preprocess="xml-stripblanks">ui/polkit-auth-prompt.ui</file>
<file preprocess="xml-stripblanks">ui/network-auth-prompt.ui</file>
<file preprocess="xml-stripblanks">ui/settings-menu.ui</file>
<file preprocess="xml-stripblanks">ui/splash.ui</file>
<file preprocess="xml-stripblanks">ui/system-prompt.ui</file>
<file preprocess="xml-stripblanks">ui/top-panel.ui</file>
<file preprocess="xml-stripblanks">ui/quick-setting.ui</file>
......
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#define G_LOG_DOMAIN "phosh-splash"
#include "config.h"
#include "shell.h"
#include "splash.h"
#define PHOSH_APP_UNKNOWN_ICON "app-icon-unknown"
/**
* SECTION:splash
* @short_description: A splash screen
* @Title: PhoshSplash
*
* The #PhoshSplash is a splash screen currently used
* to indicate application startup.
*/
enum {
PROP_0,
PROP_APP_INFO,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
typedef struct {
struct zwlr_layer_shell_v1 *layer_shell;
GAppInfo *info;
GIcon *icon;
GtkWidget *img_app;
GtkWidget *progressbar;
} PhoshSplashPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (PhoshSplash, phosh_splash, PHOSH_TYPE_LAYER_SURFACE);
static void
phosh_splash_set_property (GObject *obj,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PhoshSplash *self = PHOSH_SPLASH (obj);
PhoshSplashPrivate *priv = phosh_splash_get_instance_private (self);
switch (prop_id) {
case PROP_APP_INFO:
g_set_object (&priv->info, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static void
phosh_splash_get_property (GObject *obj,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PhoshSplash *self = PHOSH_SPLASH (obj);
PhoshSplashPrivate *priv = phosh_splash_get_instance_private (self);
switch (prop_id) {
case PROP_APP_INFO:
g_value_set_object (value, priv->info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static void
phosh_splash_dispose (GObject *obj)
{
PhoshSplash *self = PHOSH_SPLASH (obj);
PhoshSplashPrivate *priv = phosh_splash_get_instance_private (self);
g_clear_object (&priv->info);
G_OBJECT_CLASS (phosh_splash_parent_class)->dispose (obj);
}
static void
phosh_splash_constructed (GObject *object)
{
PhoshSplash *self = PHOSH_SPLASH (object);
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshSplashPrivate *priv = phosh_splash_get_instance_private (self);
PhoshMonitor *monitor;
g_debug ("Splash app info for %s", g_app_info_get_id (priv->info));
monitor = phosh_shell_get_primary_monitor (phosh_shell_get_default ());
g_object_set (PHOSH_LAYER_SURFACE (self),
"layer-shell", phosh_wayland_get_zwlr_layer_shell_v1 (wl),
"wl-output", phosh_monitor_get_wl_output (monitor),
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
"layer", ZWLR_LAYER_SHELL_V1_LAYER_TOP,
"kbd-interactivity", TRUE,
"exclusive-zone", -1,
"namespace", "phosh system-modal",
NULL);
G_OBJECT_CLASS (phosh_splash_parent_class)->constructed (object);
}
static void
phosh_splash_show (GtkWidget *widget)
{
gint width, height, size;
PhoshSplash *self = PHOSH_SPLASH (widget);
PhoshSplashPrivate *priv = phosh_splash_get_instance_private (self);
GIcon *icon;
icon = g_app_info_get_icon (priv->info);
if (G_UNLIKELY (icon == NULL)) {
gtk_image_set_from_icon_name (GTK_IMAGE (priv->img_app),
PHOSH_APP_UNKNOWN_ICON,
GTK_ICON_SIZE_DND);
} else {
if (G_IS_THEMED_ICON (icon)) {
g_themed_icon_append_name (G_THEMED_ICON (icon),
PHOSH_APP_UNKNOWN_ICON);
}
gtk_image_set_from_gicon (GTK_IMAGE (priv->img_app),
icon,
GTK_ICON_SIZE_DND);
}
phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL,
&width, &height);
size = MIN (width, height) / 2;
g_object_set (priv->img_app, "pixel-size", size, NULL);
GTK_WIDGET_CLASS (phosh_splash_parent_class)->show (widget);
}
static void
phosh_splash_class_init (PhoshSplashClass *klass)
{
GObjectClass *object_class = (GObjectClass *)klass;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = phosh_splash_get_property;
object_class->set_property = phosh_splash_set_property;
object_class->constructed = phosh_splash_constructed;
object_class->dispose = phosh_splash_dispose;
widget_class->show = phosh_splash_show;
props[PROP_APP_INFO] = g_param_spec_object ("app",
"Application",
"Applicion to splash",
G_TYPE_DESKTOP_APP_INFO,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/phosh/ui/splash.ui");
gtk_widget_class_bind_template_child_private (widget_class, PhoshSplash, img_app);
}
static void
phosh_splash_init (PhoshSplash *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget *
phosh_splash_new (GAppInfo *app)
{
return g_object_new (PHOSH_TYPE_SPLASH, "app", app, NULL);
}
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include "layersurface.h"
#include <gio/gdesktopappinfo.h>
#define PHOSH_TYPE_SPLASH (phosh_splash_get_type ())
G_DECLARE_DERIVABLE_TYPE (PhoshSplash, phosh_splash, PHOSH, SPLASH, PhoshLayerSurface)
/**
* PhoshSplashClass
* @parent_class: The parent class
*/
struct _PhoshSplashClass {
PhoshLayerSurfaceClass parent_class;
};
GtkWidget *phosh_splash_new (GAppInfo *info);
......@@ -365,3 +365,19 @@ phosh-media-player box *:disabled {
color: white;
-gtk-icon-effect: none;
}
/*
* Splash
*/
@keyframes phosh-splash-fade-in-frames {
from {background:rgba(80, 80, 80, 0);}
to {background:rgba(80, 80, 80, 1);}
}
.phosh-splash {
animation-name: phosh-splash-fade-in-frames;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="PhoshSplash" parent="PhoshLayerSurface">
<property name="can_focus">False</property>
<style>
<class name="phosh-splash"/>
</style>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="img_app">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment