Merge branch 'mr-origin-718' into dos

parents 3729a462 cc46cb23
Pipeline #63457 passed with stages
in 36 minutes and 40 seconds
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<g fill="#2e3436">
<path d="m 238,249.99999 c -0.54996,0 -1,0.45004 -1,1 v 1 h -3 c -0.55201,0 -1,0.45004 -1,1 v 2 h 3.55469 c 0.6929,-1.1906 1.96849,-2 3.44531,-2 1.47682,0 2.75241,0.8094 3.44531,2 H 247 v -2 c 0,-0.54996 -0.44799,-1 -1,-1 h -3 v -1 c 0,-0.54996 -0.45004,-1 -1,-1 z m -5,10 v 1 c 0,0.54996 0.44799,1 1,1 h 12 c 0.55201,0 1,-0.45004 1,-1 v -1 h -4.38086 c -0.70322,0.61442 -1.61196,1 -2.61914,1 -1.00718,0 -1.91592,-0.38558 -2.61914,-1 z" style="marker:none" color="#bebebe" overflow="visible" fill-opacity=".349" transform="translate(-232 -248)"/>
<path d="m 232,255.99999 h 16 v 3 h -16 z" transform="translate(-232 -248)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<g fill="#2e3436">
<path d="m 220,248 c -1.662,0 -3,1.338 -3,3 v 4 h 6 v -4 c 0,-1.662 -1.338,-3 -3,-3 z m -6,6 v 1 h 1.5 v -1 z m 10.5,0 v 1 h 1.5 v -1 z m -8.95312,6 c 0.88748,0.98341 2.08853,1.68073 3.45312,1.91016 V 264 h 2 v -2.08984 c 1.36459,-0.22943 2.56564,-0.92675 3.45312,-1.91016 h -2.41406 c -0.61304,0.30957 -1.29807,0.5 -2.03906,0.5 -0.74099,0 -1.42602,-0.19043 -2.03906,-0.5 z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000;solid-opacity:1" color="#000" font-weight="400" font-family="sans-serif" overflow="visible" opacity=".35" transform="translate(-212 -248)"/>
<path d="m 212,256.00012 h 16.00001 V 259 H 212 Z" transform="translate(-212 -248)"/>
</g>
</svg>
......@@ -60,6 +60,8 @@
<xi:include href="xml/gnome-shell-manager.xml"/>
<xi:include href="xml/head.xml"/>
<xi:include href="xml/home.xml"/>
<xi:include href="xml/hks-info.xml"/>
<xi:include href="xml/hks-manager.xml"/>
<xi:include href="xml/idle-manager.xml"/>
<xi:include href="xml/keyboard-events.xml"/>
<xi:include href="xml/layersurface.xml"/>
......
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#define G_LOG_DOMAIN "phosh-hks-info"
#include "config.h"
#include "shell.h"
#include "hks-info.h"
#include "hks-manager.h"
/**
* SECTION:hks-info
* @short_description: A widget to display the HKS status of a device
* @Title: PhoshHksInfo
*
* #PhoshHksInfo displays whether a device is disabled via a hardware
* kill switch (HKS).
*/
enum {
PROP_0,
PROP_DEV_TYPE,
PROP_BLOCKED,
PROP_PRESENT,
PROP_LAST_PROP
};
static GParamSpec *props[PROP_LAST_PROP];
struct _PhoshHksInfo {
PhoshStatusIcon parent;
char *dev_type;
gboolean blocked;
gboolean present;
PhoshHksManager *manager;
};
G_DEFINE_TYPE (PhoshHksInfo, phosh_hks_info, PHOSH_TYPE_STATUS_ICON);
static void
phosh_hks_info_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PhoshHksInfo *self = PHOSH_HKS_INFO (object);
switch (property_id) {
case PROP_BLOCKED:
g_value_set_boolean (value, self->blocked);
break;
case PROP_PRESENT:
g_value_set_boolean (value, self->present);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
phosh_hks_info_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PhoshHksInfo *self = PHOSH_HKS_INFO (object);
switch (prop_id) {
case PROP_DEV_TYPE:
/* construct only */
self->dev_type = g_value_dup_string (value);
break;
case PROP_BLOCKED:
self->blocked = g_value_get_boolean (value);
break;
case PROP_PRESENT:
self->present = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
phosh_hks_info_constructed (GObject *object)
{
PhoshHksInfo *self = PHOSH_HKS_INFO (object);
PhoshShell *shell;
g_autofree gchar *propname = NULL;
G_OBJECT_CLASS (phosh_hks_info_parent_class)->constructed (object);
shell = phosh_shell_get_default ();
self->manager = g_object_ref (phosh_shell_get_hks_manager (shell));
if (self->manager == NULL) {
g_warning ("Failed to get hks manager");
return;
}
propname = g_strdup_printf ("%s-present", self->dev_type);
g_object_bind_property (self->manager,
propname,
self,
"present",
G_BINDING_SYNC_CREATE);
g_free (propname);
propname = g_strdup_printf ("%s-blocked", self->dev_type);
g_object_bind_property (self->manager,
propname,
self,
"blocked",
G_BINDING_SYNC_CREATE);
g_free (propname);
propname = g_strdup_printf ("%s-icon-name", self->dev_type);
g_object_bind_property (self->manager,
propname,
self,
"icon-name",
G_BINDING_SYNC_CREATE);
}
static void
phosh_hks_info_dispose (GObject *object)
{
PhoshHksInfo *self = PHOSH_HKS_INFO (object);
g_clear_object (&self->manager);
G_OBJECT_CLASS (phosh_hks_info_parent_class)->dispose (object);
}
static void
phosh_hks_info_finalize (GObject *object)
{
PhoshHksInfo *self = PHOSH_HKS_INFO (object);
g_clear_pointer (&self->dev_type, g_free);
G_OBJECT_CLASS (phosh_hks_info_parent_class)->finalize (object);
}
static void
phosh_hks_info_class_init (PhoshHksInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = phosh_hks_info_constructed;
object_class->dispose = phosh_hks_info_dispose;
object_class->finalize = phosh_hks_info_finalize;
object_class->get_property = phosh_hks_info_get_property;
object_class->set_property = phosh_hks_info_set_property;
props[PROP_DEV_TYPE] =
g_param_spec_string ("device-type",
"Device type",
"The moniored device type",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_CONSTRUCT_ONLY);
props[PROP_BLOCKED] =
g_param_spec_boolean ("blocked",
"blocked",
"Whether the device is blocked",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
props[PROP_PRESENT] =
g_param_spec_boolean ("present",
"Present",
"Whether hks hardware is present",
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
static void
phosh_hks_info_init (PhoshHksInfo *self)
{
phosh_status_icon_set_info (PHOSH_STATUS_ICON (self), "HKS");
}
GtkWidget *
phosh_hks_info_new (void)
{
return g_object_new (PHOSH_TYPE_HKS_INFO, NULL);
}
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include "status-icon.h"
G_BEGIN_DECLS
#define PHOSH_TYPE_HKS_INFO (phosh_hks_info_get_type ())
G_DECLARE_FINAL_TYPE (PhoshHksInfo, phosh_hks_info, PHOSH, HKS_INFO, PhoshStatusIcon)
GtkWidget * phosh_hks_info_new (void);
G_END_DECLS
This diff is collapsed.
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
/**
* PhoshHksDeviceType:
* @PHOSH_HKS_TYPE_MIC: Microphone hardware kill switch
*
* Keep in sync with kernels rfkill types
*/
typedef enum {
PHOSH_HKS_TYPE_MIC = 10,
} PhoshHksDeviceType;
#define PHOSH_TYPE_HKS_MANAGER (phosh_hks_manager_get_type ())
G_DECLARE_FINAL_TYPE (PhoshHksManager, phosh_hks_manager, PHOSH, HKS_MANAGER, GObject)
PhoshHksManager *phosh_hks_manager_new (void);
G_END_DECLS
......@@ -57,6 +57,10 @@ libphosh_tool_sources = [
'background.h',
'connectivity-info.c',
'connectivity-info.h',
'hks-info.c',
'hks-info.h',
'hks-manager.c',
'hks-manager.h',
'docked-info.c',
'docked-info.h',
'docked-manager.c',
......
......@@ -38,5 +38,7 @@
<file alias="swipe-arrow-symbolic.svg">../data/swipe-arrow-symbolic.svg</file>
<file alias="torch-disabled-symbolic.svg">../data/torch-disabled-symbolic.svg</file>
<file alias="torch-enabled-symbolic.svg">../data/torch-enabled-symbolic.svg</file>
<file alias="camera-hardware-disabled-symbolic.svg">../data/camera-hardware-disabled-symbolic.svg</file>
<file alias="microphone-hardware-disabled-symbolic.svg">../data/microphone-hardware-disabled-symbolic.svg</file>
</gresource>
</gresources>
......@@ -36,6 +36,7 @@
#include "feedbackinfo.h"
#include "feedback-manager.h"
#include "gnome-shell-manager.h"
#include "hks-info.h"
#include "home.h"
#include "idle-manager.h"
#include "keyboard-events.h"
......@@ -117,6 +118,7 @@ typedef struct
PhoshTorchManager *torch_manager;
PhoshModeManager *mode_manager;
PhoshDockedManager *docked_manager;
PhoshHksManager *hks_manager;
PhoshKeyboardEvents *keyboard_events;
PhoshGnomeShellManager *gnome_shell_manager;
......@@ -335,6 +337,7 @@ phosh_shell_dispose (GObject *object)
g_clear_object (&priv->keyboard_events);
/* dispose managers in opposite order of declaration */
g_clear_object (&priv->hks_manager);
g_clear_object (&priv->docked_manager);
g_clear_object (&priv->mode_manager);
g_clear_object (&priv->torch_manager);
......@@ -511,6 +514,7 @@ type_setup (void)
g_type_ensure (PHOSH_TYPE_CONNECTIVITY_INFO);
g_type_ensure (PHOSH_TYPE_DOCKED_INFO);
g_type_ensure (PHOSH_TYPE_FEEDBACK_INFO);
g_type_ensure (PHOSH_TYPE_HKS_INFO);
g_type_ensure (PHOSH_TYPE_MEDIA_PLAYER);
g_type_ensure (PHOSH_TYPE_QUICK_SETTING);
g_type_ensure (PHOSH_TYPE_ROTATE_INFO);
......@@ -995,6 +999,22 @@ phosh_shell_get_docked_manager (PhoshShell *self)
}
PhoshHksManager *
phosh_shell_get_hks_manager (PhoshShell *self)
{
PhoshShellPrivate *priv;
g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
priv = phosh_shell_get_instance_private (self);
if (!priv->hks_manager)
priv->hks_manager = phosh_hks_manager_new ();
g_return_val_if_fail (PHOSH_IS_HKS_MANAGER (priv->hks_manager), NULL);
return priv->hks_manager;
}
PhoshSessionManager *
phosh_shell_get_session_manager (PhoshShell *self)
{
......
......@@ -11,6 +11,7 @@
#include "bt-manager.h"
#include "docked-manager.h"
#include "feedback-manager.h"
#include "hks-manager.h"
#include "lockscreen-manager.h"
#include "monitor-manager.h"
#include "monitor/monitor.h"
......@@ -60,6 +61,7 @@ PhoshWWan *phosh_shell_get_wwan (PhoshShell *self);
PhoshRotationManager *phosh_shell_get_rotation_manager (PhoshShell *self);
PhoshTorchManager *phosh_shell_get_torch_manager (PhoshShell *self);
PhoshDockedManager *phosh_shell_get_docked_manager (PhoshShell *self);
PhoshHksManager * phosh_shell_get_hks_manager (PhoshShell *self);
PhoshSessionManager *phosh_shell_get_session_manager (PhoshShell *self);
void phosh_shell_fade_out (PhoshShell *self, guint timeout);
void phosh_shell_enable_power_save (PhoshShell *self, gboolean enable);
......
......@@ -177,6 +177,34 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="PhoshHksInfo" id="hks_info_mic">
<property name="device-type">mic</property>
<property name="visible" bind-source="hks_info_mic" bind-property="blocked" bind-flags="sync-create"/>
<property name="can_focus">False</property>
<property name="icon-size">GTK_ICON_SIZE_SMALL_TOOLBAR</property>
<property name="margin-right">8</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="PhoshHksInfo" id="hks_info_camera">
<property name="device-type">camera</property>
<property name="visible" bind-source="hks_info_camera" bind-property="blocked" bind-flags="sync-create"/>
<property name="can_focus">False</property>
<property name="icon-size">GTK_ICON_SIZE_SMALL_TOOLBAR</property>
<property name="margin-right">8</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="PhoshBatteryInfo" id="batteryinfo">
<property name="visible">True</property>
......@@ -187,7 +215,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">4</property>
</packing>
</child>
</object>
......
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