Commit 163c01d5 authored by Guido Gunther's avatar Guido Gunther

Merge branch 'wip/system-prompter' into 'master'

implement system prompter

Closes #19

See merge request !67
parents 86dede8c db80381b
......@@ -4,6 +4,7 @@ Priority: optional
Maintainer: Guido Günther <agx@sigxcpu.org>
Build-Depends:
debhelper (>= 10),
libgcr-3-dev,
libgnome-desktop-3-dev,
libgtk-3-dev,
libhandy-0.0-dev (>= 0.0.1),
......@@ -26,8 +27,11 @@ Depends:
Recommends:
gnome-session,
Description: Simple Wayland shell
Phosh is a simple shell for wayland compositors speaking the
weston-desktop-shell protocol.
Phosh is a simple shell for Wayland compositors speaking the
layer-surface protocol. It currently supports
.
If you're not working on a wayland compositor then this package
is not very useful for you.
* enough of org.gnome.Mutter.DisplayConfig to make gnome-settings-daemon happy
* the gcr system-prompter interface
.
If you're not working on a Wayland compositor then this package
is likely not very useful for you.
......@@ -14,6 +14,9 @@ if [ "${PHOSH_VALGRIND}" = 1 ]; then
--log-file=vgdump \
--suppressions=${ABS_SRCDIR}/data/valgrind.suppressions \
"
elif [ "${PHOSH_GDB}" = 1 ]; then
echo "Running phosh under gdb"
WRAPPER="gdb"
fi
# Start up g-s-d, etc.
......
......@@ -55,6 +55,10 @@ phosh_sources = [
'lockshield.h',
'monitor-manager.c',
'monitor-manager.h',
'system-prompt.c',
'system-prompt.h',
'system-prompter.c',
'system-prompter.h',
'panel.c',
'panel.h',
'phosh.c',
......@@ -73,6 +77,7 @@ phosh_sources = [
]
phosh_deps = [
dependency('gcr-3', version: '>= 3.7.5'),
dependency('gnome-desktop-3.0', version: '>=3.26'),
dependency('gtk+-3.0', version: '>=3.22'),
dependency('gtk+-wayland-3.0', version: '>=3.22'),
......
......@@ -31,6 +31,7 @@
#include "home.h"
#include "favorites.h"
#include "settings.h"
#include "system-prompter.h"
enum {
......@@ -467,6 +468,8 @@ phosh_shell_dispose (GObject *object)
g_clear_pointer (&priv->panel, gtk_widget_destroy);
g_clear_object (&priv->lockscreen_manager);
g_clear_object (&priv->monitor_manager);
phosh_system_prompter_unregister ();
G_OBJECT_CLASS (phosh_shell_parent_class)->dispose (object);
}
......@@ -498,6 +501,7 @@ phosh_shell_constructed (GObject *object)
/* Create background after panel since it needs the panel's size */
background_create (self);
priv->lockscreen_manager = phosh_lockscreen_manager_new ();
phosh_system_prompter_register ();
}
......
......@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">ui/home.ui</file>
<file preprocess="xml-stripblanks">ui/lockscreen.ui</file>
<file preprocess="xml-stripblanks">ui/settings-menu.ui</file>
<file preprocess="xml-stripblanks">ui/system-prompt.ui</file>
<file preprocess="xml-stripblanks">ui/top-panel.ui</file>
<file compressed="true">style.css</file>
</gresource>
......
This diff is collapsed.
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*/
#pragma once
#include <gtk/gtk.h>
#include "layersurface.h"
#define PHOSH_TYPE_SYSTEM_PROMPT (phosh_system_prompt_get_type())
G_DECLARE_FINAL_TYPE (PhoshSystemPrompt, phosh_system_prompt, PHOSH, SYSTEM_PROMPT, PhoshLayerSurface)
GtkWidget *phosh_system_prompt_new (gpointer layer_shell,
gpointer wl_output);
/*
* Copyright (C) 2018 Purism SPC
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*/
#define G_LOG_DOMAIN "phosh-system-prompter"
#include "config.h"
#include "system-prompt.h"
#include "system-prompter.h"
#include "phosh.h"
#include "phosh-wayland.h"
/**
* SECTION:phosh-system_prompter
* @short_description: Manages system prompter registration
* @Title: PhoshSystemPrompter
*
* The #PhoshSystemPrompter is responsible for displaying system
* wide modal #PhoshSystemPrompt dialogs
*/
static GcrSystemPrompter *_prompter;
static ulong owner_id;
static gboolean registered_prompter;
static gboolean acquired_prompter;
static GcrPrompt *
new_prompt_cb (GcrSystemPrompter *prompter,
gpointer user_data)
{
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshShell *shell = phosh_shell_get_default ();
g_debug ("Building new system prompt");
g_return_val_if_fail (GCR_IS_SYSTEM_PROMPTER (prompter), NULL);
return GCR_PROMPT (phosh_system_prompt_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl),
phosh_shell_get_primary_monitor (shell)));
}
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
g_debug ("bus acquired for %s", name);
if (!registered_prompter) {
gcr_system_prompter_register (_prompter, connection);
g_debug ("registered prompter");
}
registered_prompter = TRUE;
}
static void
on_name_lost (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
g_debug ("lost name: %s", name);
/* Called like so when no connection can be made */
if (connection == NULL) {
g_warning ("couldn't connect to session bus");
phosh_system_prompter_unregister ();
}
}
static void
on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
g_debug ("acquired name: %s", name);
acquired_prompter = TRUE;
}
GcrSystemPrompter *
phosh_system_prompter_register ()
{
_prompter = gcr_system_prompter_new (GCR_SYSTEM_PROMPTER_SINGLE, 0);
g_signal_connect (_prompter, "new-prompt",
G_CALLBACK (new_prompt_cb), NULL);
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
"org.gnome.keyring.SystemPrompter",
G_BUS_NAME_OWNER_FLAGS_REPLACE,
on_bus_acquired,
on_name_acquired,
on_name_lost,
NULL,
NULL);
return _prompter;
}
void
phosh_system_prompter_unregister()
{
if (_prompter) {
gcr_system_prompter_unregister (_prompter, TRUE);
_prompter = NULL;
}
if (acquired_prompter) {
g_bus_unown_name (owner_id);
owner_id = 0;
acquired_prompter = FALSE;
}
}
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*/
#pragma once
#define GCR_API_SUBJECT_TO_CHANGE
#include <gcr/gcr-base.h>
GcrSystemPrompter *phosh_system_prompter_register();
void phosh_system_prompter_unregister();
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkGrid" id="grid_system_prompt">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
<property name="row_spacing">12</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="lbl_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_bottom">4</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_password">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
<property name="invisible_char"></property>
<property name="activates_default">True</property>
<property name="primary_icon_sensitive">False</property>
<property name="secondary_icon_sensitive">False</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_confirm">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Confirm:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_confirm">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
<property name="invisible_char"></property>
<property name="activates_default">True</property>
<property name="primary_icon_sensitive">False</property>
<property name="secondary_icon_sensitive">False</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="pbar_quality">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_warning">
<property name="visible">True</property>
<property name="can_focus">False</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkbtn_choice">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_continue">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="is_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="use_stock">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_cancel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_message">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_bottom">8</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<attributes>
<attribute name="scale" value="1.2"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="icon_name">dialog-password-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>
......@@ -13,7 +13,7 @@ VGDUMP="./vgdump"
TIMEOUT=5
function cleanup () {
[ ! -f core ] || echo bt | gdb -c core _build/src/phosh | tee >& ${OUTDIR}/backtrace.log
[ ! -f core ] || echo bt | gdb -c core _build/src/phosh | tee >& "${OUTDIR}"/backtrace.log
[ ! -f "${WLROOTS_LOG}" ] || cat "${WLROOTS_LOG}" || true
[ ! -f "${PHOSH_LOG}" ] || cat "${PHOSH_LOG}" || true
[ -z "${XVFB_PID}" ] || kill -9 "${XVFB_PID}" >& /dev/null || true
......@@ -64,9 +64,6 @@ mode = 768x1024
mode = 1280x800
EOF
# Provide output for the interesting parts
set -x
XVFB_OPTS="-screen 0 768x1024x24 -ac +extension GLX +render -noreset"
export WLR_BACKENDS=x11
export XDG_RUNTIME_DIR="${WORKDIR}"
......@@ -77,6 +74,7 @@ xvfb-run -s "${XVFB_OPTS}" -a /usr/lib/wlroots/rootston \
XVFB_PID=$!
echo "xvfb PID is $XVFB_PID"
echo -n "Waiting for rootston to start..."
# Wait for startup
WAIT=5
while [ ${WAIT} -gt 0 ]; do
......@@ -84,25 +82,50 @@ while [ ${WAIT} -gt 0 ]; do
sleep 1
((WAIT-=1))
done
echo "done."
. "${WORKDIR}"/wl-info
export WAYLAND_DISPLAY
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
echo -n "No DBUS session bus found, spawning it..."
eval "$(dbus-launch --sh-syntax)"
fi
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
echo "DBUS failed to start." 2>&1
exit 1
else
echo "done."
fi
echo "weston-info output:"
weston-info
echo "Starting phosh..."
_build/run >& "${PHOSH_LOG}" &
PHOSH_PID=$!
echo "Phosh's PID is $PHOSH_PID"
sleep "${TIMEOUT}" # give it some time to start
echo -n "Waiting ${TIMEOUT} seconds for phosh to start..."
sleep "${TIMEOUT}"
echo "done."
echo -n "Checking if phosh is alive..."
kill -0 $PHOSH_PID
if ! kill -0 $PHOSH_PID; then
echo "Phosh did not start in time" 1>&2
exit 2
fi
echo "yes."
echo "Checking if phosh shuts down..."
kill -15 $PHOSH_PID
echo -n "Checking if phosh shutted down..."
echo -n "Waiting ${TIMEOUT} seconds for phosh to stop..."
sleep "${TIMEOUT}"
! kill -0 $PHOSH_PID >&/dev/null
if kill -0 $PHOSH_PID >&/dev/null; then
echo "Phosh did not terminate in time." 1>&2
exit 2
fi
echo "yes."
echo "Started/stopped phosh successfully"
......
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