Commit f2feed05 authored by Guido Gunther's avatar Guido Gunther

Add GcrSystemPrompter implementation

This gives us system modal dialogs for all important pin entries (if
they use Gcr as they should).

Based on gnome-shell's shell-keyring-prompt.c as well as Gcr's
own ui/gcr-prompt-dialog.c

Closes: #19
parent 638247fb
......@@ -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),
......
......@@ -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>
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