Added phosh

This commit is contained in:
Gerben Jan Dijkman 2021-06-17 15:02:06 +02:00
parent 576dc84d35
commit cdac3cd7f0
32 changed files with 7321 additions and 0 deletions

View File

@ -0,0 +1,174 @@
From 3a1f2f4fd7448ce1093bc08b1167ece63121371c Mon Sep 17 00:00:00 2001
From: Danct12 <danct12@disroot.org>
Date: Thu, 29 Oct 2020 16:00:28 +0700
Subject: [PATCH] Revert "home: Bind key to show overview"
This reverts commit f70af466ff57763bc94548e3086a3caa50c8eacc.
---
src/home.c | 108 -----------------------------------------------------
1 file changed, 108 deletions(-)
diff --git a/src/home.c b/src/home.c
index b8fc99e..9b3b722 100644
--- a/src/home.c
+++ b/src/home.c
@@ -18,10 +18,6 @@
#include <handy.h>
-#define KEYBINDINGS_SCHEMA_ID "org.gnome.shell.keybindings"
-#define KEYBINDING_KEY_TOGGLE_OVERVIEW "toggle-overview"
-#define KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW "toggle-application-view"
-
/**
* SECTION:home
* @short_description: The home surface contains the overview and
@@ -65,10 +61,6 @@ struct _PhoshHome
PhoshHomeState state;
- /* Keybinding */
- GArray *actions;
- GSettings *settings;
-
/* osk button */
gboolean osk_enabled;
};
@@ -207,77 +199,6 @@ key_press_event_cb (PhoshHome *self, GdkEventKey *event, gpointer data)
}
-static void
-toggle_overview_action (GSimpleAction *action, GVariant *param, gpointer data)
-{
- PhoshHome *self = PHOSH_HOME (data);
- PhoshHomeState state;
-
- g_return_if_fail (PHOSH_IS_HOME (self));
-
- state = self->state == PHOSH_HOME_STATE_UNFOLDED ?
- PHOSH_HOME_STATE_FOLDED : PHOSH_HOME_STATE_UNFOLDED;
- phosh_home_set_state (self, state);
-}
-
-
-static void
-toggle_application_view_action (GSimpleAction *action, GVariant *param, gpointer data)
-{
- PhoshHome *self = PHOSH_HOME (data);
- PhoshHomeState state;
-
- g_return_if_fail (PHOSH_IS_HOME (self));
-
- state = self->state == PHOSH_HOME_STATE_UNFOLDED ?
- PHOSH_HOME_STATE_FOLDED : PHOSH_HOME_STATE_UNFOLDED;
- phosh_home_set_state (self, state);
- phosh_overview_focus_app_search (PHOSH_OVERVIEW (self->overview));
-}
-
-
-static void
-add_keybindings (PhoshHome *self)
-{
- g_auto (GStrv) bindings = NULL;
- g_autoptr (GSettings) settings = g_settings_new (KEYBINDINGS_SCHEMA_ID);
-
- bindings = g_settings_get_strv (settings, KEYBINDING_KEY_TOGGLE_OVERVIEW);
- for (int i = 0; i < g_strv_length (bindings); i++) {
- GActionEntry entry = { bindings[i],
- toggle_overview_action, };
- g_array_append_val (self->actions, entry);
- }
-
- bindings = g_settings_get_strv (settings, KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW);
- for (int i = 0; i < g_strv_length (bindings); i++) {
- GActionEntry entry = { bindings[i],
- toggle_application_view_action, };
- g_array_append_val (self->actions, entry);
- }
-
- phosh_shell_add_global_keyboard_action_entries (phosh_shell_get_default (),
- (GActionEntry*)self->actions->data,
- self->actions->len,
- self);
-}
-
-
-static void
-on_keybindings_changed (PhoshHome *self,
- gchar *key,
- GSettings *settings)
-{
- /* For now just redo all keybindings */
- g_debug ("Updating keybindings");
- phosh_shell_remove_global_keyboard_action_entries (phosh_shell_get_default (),
- (GActionEntry*)self->actions->data,
- self->actions->len);
- g_array_set_size (self->actions, 0);
- add_keybindings (self);
-}
-
-
static gboolean
on_idle (PhoshOskButton *self)
{
@@ -332,14 +253,6 @@ phosh_home_constructed (GObject *object)
G_CALLBACK (key_press_event_cb),
NULL);
- g_object_connect (self->settings,
- "swapped-signal::changed::" KEYBINDING_KEY_TOGGLE_OVERVIEW,
- on_keybindings_changed, self,
- "swapped-signal::changed::" KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW,
- on_keybindings_changed, self,
- NULL);
- add_keybindings (self);
-
phosh_connect_feedback (self->btn_home);
g_idle_add ((GSourceFunc) on_idle, self);
@@ -348,24 +261,6 @@ phosh_home_constructed (GObject *object)
}
-static void
-phosh_home_dispose (GObject *object)
-{
- PhoshHome *self = PHOSH_HOME (object);
-
- g_clear_object (&self->settings);
-
- if (self->actions) {
- phosh_shell_remove_global_keyboard_action_entries (phosh_shell_get_default (),
- (GActionEntry*)self->actions->data,
- self->actions->len);
- g_clear_pointer (&self->actions, g_array_unref);
- }
-
- G_OBJECT_CLASS (phosh_home_parent_class)->dispose (object);
-}
-
-
static void
phosh_home_class_init (PhoshHomeClass *klass)
{
@@ -373,7 +268,6 @@ phosh_home_class_init (PhoshHomeClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = phosh_home_constructed;
- object_class->dispose = phosh_home_dispose;
object_class->set_property = phosh_home_set_property;
object_class->get_property = phosh_home_get_property;
@@ -419,8 +313,6 @@ phosh_home_init (PhoshHome *self)
{
self->state = PHOSH_HOME_STATE_FOLDED;
self->animation.progress = 1.0;
- self->actions = g_array_new (FALSE, TRUE, sizeof (GActionEntry));
- self->settings = g_settings_new (KEYBINDINGS_SCHEMA_ID);
gtk_widget_init_template (GTK_WIDGET (self));
}
--
2.29.2

View File

@ -0,0 +1,49 @@
From e88f5dee0cbb7fa0851b43a5ded5d94256c756d2 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@gmail.com>
Date: Sat, 21 Mar 2020 03:00:34 +0100
Subject: [PATCH] system-prompt: allow blank passwords
---
src/system-prompt.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/system-prompt.c b/src/system-prompt.c
index 30aa3f1..bd06ee0 100644
--- a/src/system-prompt.c
+++ b/src/system-prompt.c
@@ -256,8 +256,6 @@ phosh_system_prompt_password_async (GcrPrompt *prompt,
priv->task = g_task_new (self, NULL, callback, user_data);
g_task_set_source_tag (priv->task, phosh_system_prompt_password_async);
- if (!gtk_entry_get_text_length (GTK_ENTRY (priv->entry_password)))
- gtk_widget_set_sensitive (priv->btn_continue, FALSE);
gtk_widget_set_sensitive (priv->grid, TRUE);
obj = G_OBJECT (self);
@@ -315,7 +313,6 @@ phosh_system_prompt_confirm_async (GcrPrompt *prompt,
priv->task = g_task_new (self, NULL, callback, user_data);
g_task_set_source_tag (priv->task, phosh_system_prompt_confirm_async);
- gtk_widget_set_sensitive (priv->btn_continue, TRUE);
gtk_widget_set_sensitive (priv->grid, TRUE);
obj = G_OBJECT (self);
@@ -392,7 +389,6 @@ prompt_complete (PhoshSystemPrompt *self)
g_task_return_pointer (res, (gpointer)password, NULL);
g_object_unref (res);
- gtk_widget_set_sensitive (priv->btn_continue, FALSE);
gtk_widget_set_sensitive (priv->grid, FALSE);
return TRUE;
@@ -451,7 +447,6 @@ on_password_changed (PhoshSystemPrompt *self,
if (!gtk_entry_get_text_length (GTK_ENTRY (editable)))
return;
- gtk_widget_set_sensitive (priv->btn_continue, TRUE);
password = gtk_entry_get_text (GTK_ENTRY (editable));
/*
--
2.24.1

View File

@ -0,0 +1,32 @@
diff --git a/src/proximity.c b/src/proximity.c
index 0beca69..8e93b21 100644
--- a/src/proximity.c
+++ b/src/proximity.c
@@ -148,8 +155,9 @@ on_proximity_near_changed (PhoshProximity *self,
PhoshSensorProxyManager *sensor)
{
gboolean near;
- int ps_mode;
+ int ps_mode;
PhoshShell *shell = phosh_shell_get_default ();
+ PhoshWayland *wl = phosh_wayland_get_default ();
PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell);
near = phosh_dbus_sensor_proxy_get_proximity_near (
@@ -157,8 +165,15 @@ on_proximity_near_changed (PhoshProximity *self,
g_debug ("Proximity near changed: %d", near);
if (near) {
- ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF;
+ if (!self->fader) {
+ self->fader = phosh_fader_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl),
+ monitor->wl_output);
+ gtk_widget_show (GTK_WIDGET (self->fader));
+ }
+ g_timeout_add_seconds (5, continue, self);
+ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF;
} else {
+ g_clear_pointer (&self->fader, phosh_cp_widget_destroy);
ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_ON;
}
phosh_monitor_set_power_save_mode (monitor, ps_mode);

View File

@ -0,0 +1,14 @@
diff -Npur a/data/phosh.in b/data/phosh.in
--- a/data/phosh.in 2021-03-20 13:53:32.367786000 +0100
+++ b/data/phosh.in 2021-03-20 13:55:19.327789721 +0100
@@ -56,6 +56,10 @@ elif [ -f /etc/phosh/rootston.ini ]; th
PHOC_INI=/etc/phosh/rootston.ini
fi
+# Set proper locale according to /etc/locale.conf
+source /etc/locale.conf
+export LANG=$LANG
+
# Run gnome-session through a login shell so it picks
# variables from /etc/profile.d (XDG_*)
[ -n "$WLR_BACKENDS" ] || WLR_BACKENDS=drm,libinput

View File

@ -0,0 +1,26 @@
diff --git a/src/shell.c b/src/shell.c
index 324b261..4a66866 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -535,15 +535,18 @@ static void
on_builtin_monitor_power_mode_changed (PhoshShell *self, GParamSpec *pspec, PhoshMonitor *monitor)
{
PhoshMonitorPowerSaveMode mode;
+ PhoshSensorProxyManager *sensor_proxy_manager;
+ gboolean near;
+
+ near = phosh_dbus_sensor_proxy_get_proximity_near (
+ PHOSH_DBUS_SENSOR_PROXY (sensor_proxy_manager));
g_return_if_fail (PHOSH_IS_SHELL (self));
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
g_object_get (monitor, "power-mode", &mode, NULL);
-#if 0
- if (mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF)
+ if (!near && mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF)
phosh_shell_lock (self);
-#endif
phosh_shell_set_state (self, PHOSH_STATE_BLANKED, mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF);
}

View File

@ -0,0 +1,30 @@
From a85bf76c9c19a8f54657b7973a4b1ec50176f395 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 23 Oct 2020 13:40:44 +0200
Subject: [PATCH 44/47] shell: honor configured rotation
Resetting the default transform causes the user-configured rotation to
be ignored. In cases where the transform needs to be reset, this is
already done in lockscreen manager.
---
src/shell.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index 42893d4..19a41fb 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -484,10 +484,6 @@ setup_idle_cb (PhoshShell *self)
phosh_session_register (PHOSH_APP_ID);
- /* If we start rotated, fix this up */
- if (phosh_shell_get_transform (self) != PHOSH_MONITOR_TRANSFORM_NORMAL)
- phosh_shell_set_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL);
-
priv->startup_finished = TRUE;
return FALSE;
--
2.28.0

View File

@ -0,0 +1,57 @@
--- a/src/proximity.c 2021-03-04 10:51:32.765179000 +0100
+++ b/src/proximity.c 2021-03-04 12:01:32.618475761 +0100
@@ -148,24 +148,24 @@ on_proximity_near_changed (PhoshProximit
PhoshSensorProxyManager *sensor)
{
gboolean near;
+ int ps_mode;
+ PhoshShell *shell = phosh_shell_get_default ();
+ PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell);
near = phosh_dbus_sensor_proxy_get_proximity_near (
PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager));
g_debug ("Proximity near changed: %d", near);
+
if (near) {
- PhoshShell *shell = phosh_shell_get_default ();
- PhoshWayland *wl = phosh_wayland_get_default ();
- PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell);
-
- if (!self->fader) {
- self->fader = phosh_fader_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl),
- monitor->wl_output);
- gtk_widget_show (GTK_WIDGET (self->fader));
- }
+ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF;
+ g_object_set(monitor, "proximity", TRUE, NULL);
} else {
- g_clear_pointer (&self->fader, phosh_cp_widget_destroy);
+ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_ON;
+ g_object_set(monitor, "proximity", FALSE, NULL);
}
+
+ phosh_monitor_set_power_save_mode (monitor, ps_mode);
}
static void
--- a/src/shell.c 2021-03-04 15:50:24.291677177 +0100
+++ b/src/shell.c 2021-03-04 15:50:54.228343514 +0100
@@ -529,13 +533,15 @@ static void
on_builtin_monitor_power_mode_changed (PhoshShell *self, GParamSpec *pspec, PhoshMonitor *monitor)
{
PhoshMonitorPowerSaveMode mode;
+ gboolean proximity;
g_return_if_fail (PHOSH_IS_SHELL (self));
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
+ g_object_get (monitor, "proximity", &proximity, NULL);
g_object_get (monitor, "power-mode", &mode, NULL);
- if (mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF)
- phosh_shell_lock (self);
+ if (!proximity && mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF)
+ //phosh_shell_lock (self);
phosh_shell_set_state (self, PHOSH_STATE_BLANKED, mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF);
}

View File

@ -0,0 +1,22 @@
From: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
Date: Wed, 17 Mar 2021 17:38:58 +0100
Subject: Fix locale issue in Service file
* data/phosh.service (Environment): do not override user language
setting.
---
data/phosh.service | 1 -
1 file changed, 1 deletion(-)
diff --git a/data/phosh.service b/data/phosh.service
index fa18137..a585696 100644
--- a/data/phosh.service
+++ b/data/phosh.service
@@ -25,7 +25,6 @@ Before=graphical.target
ConditionPathExists=/dev/tty0
[Service]
-Environment=LANG=C.UTF-8
Environment=XDG_CURRENT_DESKTOP=GNOME
Environment=XDG_SESSION_DESKTOP=phosh
Environment=XDG_SESSION_TYPE=wayland

View File

@ -0,0 +1,50 @@
From 50cffaa899230af7ac3d24c7e76f3a7e4dbac519 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Tue, 27 Oct 2020 15:07:37 +0100
Subject: [PATCH 45/47] shell: add an accessor for the mode manager
Other modules should be able to query the device type too.
---
src/shell.c | 13 +++++++++++++
src/shell.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/src/shell.c b/src/shell.c
index 19a41fb..48dd4c2 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -815,6 +815,19 @@ phosh_shell_get_lockscreen_manager (PhoshShell *self)
}
+PhoshModeManager *
+phosh_shell_get_mode_manager (PhoshShell *self)
+{
+ PhoshShellPrivate *priv;
+
+ g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
+ priv = phosh_shell_get_instance_private (self);
+
+ g_return_val_if_fail (PHOSH_IS_MODE_MANAGER (priv->mode_manager), NULL);
+ return priv->mode_manager;
+}
+
+
PhoshMonitorManager *
phosh_shell_get_monitor_manager (PhoshShell *self)
{
diff --git a/src/shell.h b/src/shell.h
index 65680a5..541203d 100644
--- a/src/shell.h
+++ b/src/shell.h
@@ -47,6 +47,7 @@ void phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMon
PhoshMonitor *phosh_shell_get_primary_monitor (PhoshShell *self);
PhoshMonitor *phosh_shell_get_builtin_monitor (PhoshShell *self);
PhoshLockscreenManager *phosh_shell_get_lockscreen_manager (PhoshShell *self);
+PhoshModeManager *phosh_shell_get_mode_manager (PhoshShell *self);
PhoshMonitorManager *phosh_shell_get_monitor_manager (PhoshShell *self);
PhoshOskManager *phosh_shell_get_osk_manager (PhoshShell *self);
PhoshToplevelManager *phosh_shell_get_toplevel_manager (PhoshShell *self);
--
2.28.0

View File

@ -0,0 +1,44 @@
From 29f0773b1e60736c193b6e3118b5f93030a52bc5 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Tue, 27 Oct 2020 17:14:07 +0100
Subject: [PATCH 46/47] lockscreen-manager: undo transform only for phones
If the display is large enough to make the keypad usable even when
rotated, we should not try to rotate it back to the default orientation.
---
src/lockscreen-manager.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index dac21e8..cc09026 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -146,6 +146,7 @@ on_monitor_added (PhoshLockscreenManager *self,
static void
lockscreen_lock (PhoshLockscreenManager *self)
{
+ PhoshModeManager *mode_manager;
PhoshMonitor *primary_monitor;
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshShell *shell = phosh_shell_get_default ();
@@ -156,9 +157,16 @@ lockscreen_lock (PhoshLockscreenManager *self)
primary_monitor = phosh_shell_get_primary_monitor (shell);
g_return_if_fail (primary_monitor);
- /* Undo any transform on the primary display so the keypad becomes usable */
+ mode_manager = phosh_shell_get_mode_manager(shell);
self->transform = phosh_shell_get_transform (shell);
- phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
+
+ /*
+ * The lockscreen won't likely fit on phones, so we have to undo any transform
+ * on the primary display to make the keypad usable on such devices
+ */
+ if (phosh_mode_manager_get_device_type(mode_manager) == PHOSH_MODE_DEVICE_TYPE_PHONE) {
+ phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
+ }
/* Listen for monitor changes */
g_signal_connect_object (monitor_manager, "monitor-added",
--
2.28.0

View File

@ -0,0 +1,18 @@
diff --git a/src/rotation-manager.c b/src/rotation-manager.c
index 9fa8abd..a627935 100644
--- a/src/rotation-manager.c
+++ b/src/rotation-manager.c
@@ -110,11 +110,11 @@ match_orientation (PhoshRotationManager *self)
if (!g_strcmp0 ("normal", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
} else if (!g_strcmp0 ("right-up", orient)) {
- transform = PHOSH_MONITOR_TRANSFORM_270;
+ transform = PHOSH_MONITOR_TRANSFORM_90;
} else if (!g_strcmp0 ("bottom-up", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_180;
} else if (!g_strcmp0 ("left-up", orient)) {
- transform = PHOSH_MONITOR_TRANSFORM_90;
+ transform = PHOSH_MONITOR_TRANSFORM_270;
} else if (!g_strcmp0 ("undefined", orient)) {
return; /* just leave as is */
} else {

View File

@ -0,0 +1,27 @@
--- a/src/lockscreen.c 2020-11-13 14:57:08.191840783 +0100
+++ b/src/lockscreen.c 2020-11-13 14:55:38.355171909 +0100
@@ -21,6 +21,8 @@
#include <math.h>
#include <time.h>
+#include <shell.h>
+
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
@@ -402,6 +404,7 @@ carousel_position_notified_cb (PhoshLock
GParamSpec *pspec,
HdyCarousel *carousel)
{
+ PhoshShell *shell = phosh_shell_get_default ();
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
double position;
@@ -418,6 +421,7 @@ carousel_position_notified_cb (PhoshLock
priv->idle_timer = g_timeout_add_seconds (LOCKSCREEN_IDLE_SECONDS,
(GSourceFunc) keypad_check_idle,
self);
+ phosh_shell_set_transform (shell, 0);
}
return;

1395
gui-wm/phosh/files/777.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,211 @@
From c11bddfedd9d62410cd64720be91b1a3a5096231 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 29 Sep 2020 16:30:24 +0200
Subject: [PATCH] settings: Add torch brightness slider
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This adds brightness slider when the torch is enabled.
Closes: #386
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/settings.c | 65 +++++++++++++++++++++++++++++++++++++++++
src/ui/settings-menu.ui | 49 +++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+)
diff --git a/src/settings.c b/src/settings.c
index 5dd823b8..bcfbe6f9 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -16,6 +16,8 @@
#include "quick-setting.h"
#include "settings/brightness.h"
#include "settings/gvc-channel-bar.h"
+#include "torch-info.h"
+#include "torch-manager.h"
#include "wwan/phosh-wwan-mm.h"
#include "feedback-manager.h"
#include "notifications/notify-manager.h"
@@ -64,6 +66,11 @@ typedef struct _PhoshSettings
GtkWidget *list_notifications;
GtkWidget *sw_notifications;
LfbEvent *notify_event;
+
+ /* Torch */
+ PhoshTorchManager *torch_manager;
+ GtkWidget *scale_torch;
+ gboolean setting_torch;
} PhoshSettings;
@@ -401,6 +408,41 @@ end_notify_feedback (PhoshSettings *self)
}
+static void
+on_torch_scale_value_changed (PhoshSettings *self, GtkScale *scale_torch)
+{
+ double value;
+
+ g_return_if_fail (PHOSH_IS_SETTINGS (self));
+ g_return_if_fail (PHOSH_IS_TORCH_MANAGER (self->torch_manager));
+
+ /* Only react to scale changes when torch is enabled */
+ if (!phosh_torch_manager_get_enabled (self->torch_manager))
+ return;
+
+ self->setting_torch = TRUE;
+ value = gtk_range_get_value (GTK_RANGE (self->scale_torch));
+ g_debug ("Setting torch brightness to %.2f", value);
+ phosh_torch_manager_set_scaled_brightness (self->torch_manager, value / 100.0);
+}
+
+
+static void
+on_torch_brightness_changed (PhoshSettings *self, GParamSpec *pspec, PhoshTorchManager *manager)
+{
+ g_return_if_fail (PHOSH_IS_SETTINGS (self));
+ g_return_if_fail (PHOSH_IS_TORCH_MANAGER (manager));
+
+ if (self->setting_torch) {
+ self->setting_torch = FALSE;
+ return;
+ }
+
+ gtk_range_set_value (GTK_RANGE (self->scale_torch),
+ 100.0 * phosh_torch_manager_get_scaled_brightness (self->torch_manager));
+}
+
+
static void
on_notifcation_items_changed (PhoshSettings *self,
guint position,
@@ -441,6 +483,24 @@ setup_brightness_range (PhoshSettings *self)
}
+static void
+setup_torch (PhoshSettings *self)
+{
+ PhoshShell *shell = phosh_shell_get_default ();
+
+ self->torch_manager = g_object_ref(phosh_shell_get_torch_manager (shell));
+
+ gtk_range_set_range (GTK_RANGE (self->scale_torch), 40, 100);
+ gtk_range_set_value (GTK_RANGE (self->scale_torch),
+ phosh_torch_manager_get_scaled_brightness (self->torch_manager) * 100.0);
+ g_signal_connect_object (self->torch_manager,
+ "notify::brightness",
+ G_CALLBACK(on_torch_brightness_changed),
+ self,
+ G_CONNECT_SWAPPED);
+}
+
+
static void
setup_volume_bar (PhoshSettings *self)
{
@@ -477,6 +537,7 @@ phosh_settings_constructed (GObject *object)
setup_brightness_range (self);
setup_volume_bar (self);
+ setup_torch (self);
g_signal_connect (self->quick_settings,
"child-activated",
@@ -515,6 +576,8 @@ phosh_settings_dispose (GObject *object)
g_clear_object (&self->notify_event);
}
+ g_clear_object (&self->torch_manager);
+
G_OBJECT_CLASS (phosh_settings_parent_class)->dispose (object);
}
@@ -552,6 +615,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass)
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, list_notifications);
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, quick_settings);
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, scale_brightness);
+ gtk_widget_class_bind_template_child (widget_class, PhoshSettings, scale_torch);
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, sw_notifications);
gtk_widget_class_bind_template_callback (widget_class, battery_setting_clicked_cb);
@@ -568,6 +632,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass)
gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, wifi_setting_long_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_torch_scale_value_changed);
}
diff --git a/src/ui/settings-menu.ui b/src/ui/settings-menu.ui
index 38aa0d97..ba549be0 100644
--- a/src/ui/settings-menu.ui
+++ b/src/ui/settings-menu.ui
@@ -200,6 +200,52 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkRevealer" id="revealer">
+ <property name="visible">True</property>
+ <property name="reveal-child" bind-source="torchinfo" bind-property="enabled" bind-flags="sync-create"/>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">5</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">6</property>
+ <property name="icon_name">torch-enabled-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScale" id="scale_torch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adj_torch</property>
+ <property name="round_digits">0</property>
+ <property name="draw_value">False</property>
+ <signal name="value-changed" handler="on_torch_scale_value_changed" object="PhoshSettings" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
<child>
<object class="GtkScrolledWindow" id="sw_notifications">
<property name="visible">False</property>
@@ -234,4 +280,7 @@
<class name="phosh-settings-menu"/>
</style>
</template>
+ <object class="GtkAdjustment" id="adj_torch">
+ <property name="step-increment">1</property>
+ </object>
</interface>
--
GitLab

View File

@ -0,0 +1,365 @@
From 77913a24fc709cdbc1f2a91da7cf81834f1239a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 19 May 2021 17:40:12 +0200
Subject: [PATCH 1/6] hacking: Fix property function names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We always use the singular form
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
HACKING.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/HACKING.md b/HACKING.md
index 242cceba..bd9fdd52 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -106,8 +106,8 @@ individual C files should be structured as (top to bottom of file):
```
- private methods and callbacks (these can also go at convenient
places above `phosh_thing_constructed ()`
- - `phosh_thing_set_properties ()`
- - `phosh_thing_get_properties ()`
+ - `phosh_thing_set_property ()`
+ - `phosh_thing_get_property ()`
- `phosh_thing_constructed ()`
- `phosh_thing_dispose ()`
- `phosh_thing_finalize ()`
--
GitLab
From e5dc0790c0a265b4a30ad4cc04e306c31a05da3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 19 May 2021 17:20:28 +0200
Subject: [PATCH 2/6] batteryinfo: Drop superfluous NULL checks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
g_clear_object() does this for us.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/batteryinfo.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/batteryinfo.c b/src/batteryinfo.c
index a03cac8d..d8f02158 100644
--- a/src/batteryinfo.c
+++ b/src/batteryinfo.c
@@ -91,11 +91,8 @@ phosh_battery_info_dispose (GObject *object)
{
PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object);
- if (self->device)
- g_clear_object (&self->device);
-
- if (self->upower)
- g_clear_object (&self->upower);
+ g_clear_object (&self->device);
+ g_clear_object (&self->upower);
G_OBJECT_CLASS (phosh_battery_info_parent_class)->dispose (object);
}
--
GitLab
From 2e0db016397b0737f5abc2ec9f4c0289412c6fa3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 19 May 2021 18:00:49 +0200
Subject: [PATCH 3/6] panel: Always use bold font
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
So far all labels set this expicitly
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/style.css | 2 +-
src/ui/top-panel.ui | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/style.css b/src/style.css
index caa845fd..2e707ae4 100644
--- a/src/style.css
+++ b/src/style.css
@@ -3,6 +3,7 @@
*/
.phosh-panel {
font: 15px Cantarell;
+ font-weight: bold;
}
.phosh-panel-btn {
@@ -11,7 +12,6 @@
}
.phosh-topbar-clock {
- font-weight: bold;
font-feature-settings: "tnum";
}
diff --git a/src/ui/top-panel.ui b/src/ui/top-panel.ui
index 26338b6f..e03c537e 100644
--- a/src/ui/top-panel.ui
+++ b/src/ui/top-panel.ui
@@ -168,9 +168,6 @@
<property name="margin_right">8</property>
<property name="margin_top">2</property>
<property name="justify">center</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
</object>
<packing>
<property name="expand">False</property>
--
GitLab
From 40a57d77346d2447e349a1a215fc9897fc9309ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 19 May 2021 17:40:44 +0200
Subject: [PATCH 4/6] batteryinfo: Add optional label with battery percentage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/batteryinfo.c | 100 ++++++++++++++++++++++++++++++++++++++++++++--
src/batteryinfo.h | 2 +
2 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/src/batteryinfo.c b/src/batteryinfo.c
index d8f02158..abd518d2 100644
--- a/src/batteryinfo.c
+++ b/src/batteryinfo.c
@@ -22,16 +22,63 @@
* @Title: PhoshBatteryInfo
*/
+enum {
+ PROP_0,
+ PROP_SHOW_DETAIL,
+ PROP_LAST_PROP
+};
+static GParamSpec *props[PROP_LAST_PROP];
+
+
typedef struct _PhoshBatteryInfo {
- PhoshStatusIcon parent;
- UpClient *upower;
- UpDevice *device;
+ PhoshStatusIcon parent;
+ UpClient *upower;
+ UpDevice *device;
+ gboolean show_detail;
} PhoshBatteryInfo;
G_DEFINE_TYPE (PhoshBatteryInfo, phosh_battery_info, PHOSH_TYPE_STATUS_ICON)
+static void
+phosh_battery_info_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object);
+
+ switch (property_id) {
+ case PROP_SHOW_DETAIL:
+ phosh_battery_info_set_show_detail (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
+phosh_battery_info_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object);
+
+ switch (property_id) {
+ case PROP_SHOW_DETAIL:
+ g_value_set_boolean (value, self->show_detail);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
static void
setup_display_device (PhoshBatteryInfo *self)
{
@@ -82,6 +129,11 @@ phosh_battery_info_constructed (GObject *object)
NULL,
NULL,
NULL);
+ g_object_bind_property (self,
+ "info",
+ phosh_status_icon_get_extra_widget (PHOSH_STATUS_ICON (self)),
+ "label",
+ G_BINDING_SYNC_CREATE);
}
}
@@ -105,12 +157,32 @@ phosh_battery_info_class_init (PhoshBatteryInfoClass *klass)
object_class->constructed = phosh_battery_info_constructed;
object_class->dispose = phosh_battery_info_dispose;
+ object_class->get_property = phosh_battery_info_get_property;
+ object_class->set_property = phosh_battery_info_set_property;
+
+ props[PROP_SHOW_DETAIL] =
+ g_param_spec_boolean (
+ "show-detail",
+ "",
+ "",
+ FALSE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
static void
phosh_battery_info_init (PhoshBatteryInfo *self)
{
+ GtkWidget *percentage = gtk_label_new (NULL);
+ phosh_status_icon_set_extra_widget (PHOSH_STATUS_ICON (self), percentage);
+
+ g_object_bind_property (self,
+ "show-detail",
+ percentage,
+ "visible",
+ G_BINDING_SYNC_CREATE);
}
@@ -119,3 +191,25 @@ phosh_battery_info_new (void)
{
return g_object_new (PHOSH_TYPE_BATTERY_INFO, NULL);
}
+
+
+void
+phosh_battery_info_set_show_detail (PhoshBatteryInfo *self, gboolean show)
+{
+ g_return_if_fail (PHOSH_IS_BATTERY_INFO (self));
+
+ if (self->show_detail == show)
+ return;
+
+ self->show_detail = !!show;
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SHOW_DETAIL]);
+}
+
+
+gboolean
+phosh_battery_info_get_show_detail (PhoshBatteryInfo *self)
+{
+ g_return_val_if_fail (PHOSH_IS_BATTERY_INFO (self), FALSE);
+
+ return self->show_detail;
+}
diff --git a/src/batteryinfo.h b/src/batteryinfo.h
index 6d0114b6..6aef37bb 100644
--- a/src/batteryinfo.h
+++ b/src/batteryinfo.h
@@ -17,5 +17,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PhoshBatteryInfo, phosh_battery_info, PHOSH, BATTERY_INFO, PhoshStatusIcon)
GtkWidget * phosh_battery_info_new (void);
+void phosh_battery_info_set_show_detail (PhoshBatteryInfo *self, gboolean show);
+gboolean phosh_battery_info_get_show_detail (PhoshBatteryInfo *self);
G_END_DECLS
--
GitLab
From ff137645c53a9ff9125acb4a6bc8d10731e71b26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 19 May 2021 17:48:09 +0200
Subject: [PATCH 5/6] panel: Honor show-battery-percentage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows to show the battery percentage in the top bar
Closes: https://source.puri.sm/Librem5/phosh/-/issues/268
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/panel.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/panel.c b/src/panel.c
index 71319352..c9aaeada 100644
--- a/src/panel.c
+++ b/src/panel.c
@@ -50,10 +50,12 @@ typedef struct {
GtkWidget *lbl_clock;
GtkWidget *lbl_lang;
GtkWidget *settings; /* settings menu */
+ GtkWidget *batteryinfo;
GnomeWallClock *wall_clock;
GnomeXkbInfo *xkbinfo;
GSettings *input_settings;
+ GSettings *interface_settings;
GdkSeat *seat;
GSimpleActionGroup *actions;
@@ -344,6 +346,13 @@ phosh_panel_constructed (GObject *object)
"logout");
g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
}
+
+ priv->interface_settings = g_settings_new ("org.gnome.desktop.interface");
+ g_settings_bind (priv->interface_settings,
+ "show-battery-percentage",
+ priv->batteryinfo,
+ "show-detail",
+ G_SETTINGS_BIND_GET);
}
@@ -356,6 +365,7 @@ phosh_panel_dispose (GObject *object)
g_clear_object (&priv->wall_clock);
g_clear_object (&priv->xkbinfo);
g_clear_object (&priv->input_settings);
+ g_clear_object (&priv->interface_settings);
g_clear_object (&priv->actions);
priv->seat = NULL;
@@ -380,6 +390,7 @@ phosh_panel_class_init (PhoshPanelClass *klass)
"/sm/puri/phosh/ui/top-panel.ui");
gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, menu_power);
gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, btn_top_panel);
+ gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, batteryinfo);
gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, lbl_clock);
gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, lbl_lang);
gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, box);
--
GitLab

View File

@ -0,0 +1,35 @@
From 1bdbfb9e3c1a86f659476017cb6210227c01d601 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 21 May 2021 12:41:41 +0200
Subject: [PATCH 1/2] po: Drop string from from jp translation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The translation switches %s and %d causing a crash.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
po/ja.po | 7 -------
1 file changed, 7 deletions(-)
diff --git a/po/ja.po b/po/ja.po
index a87bf11c..19710623 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -63,13 +63,6 @@ msgstr "ドック外"
msgid "Log Out"
msgstr "ログアウト"
-#: src/end-session-dialog.c:165
-#, c-format
-msgid "%s will be logged out automatically in %d second."
-msgid_plural "%s will be logged out automatically in %d seconds."
-msgstr[0] "%d秒後、%sさんは自動でログアウトされます。"
-msgstr[1] "%d秒後、%sさんは自動でログアウトされます。"
-
#: src/end-session-dialog.c:172
#, c-format
msgid "The system will power off automatically in %d second."
--
GitLab

View File

@ -0,0 +1,31 @@
From 078854ae6b15fce4d817772de521d9a226a52704 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sun, 30 May 2021 20:37:31 +0200
Subject: [PATCH] data: Add gsd-wwan to required components
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This makes sure it's also started in systemd mode so the PIN request
happens.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
data/meson.build | 1 +
1 file changed, 1 insertion(+)
diff --git a/data/meson.build b/data/meson.build
index 64f1cdec..a60eb7db 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -14,6 +14,7 @@ gsd_required_components = [
'org.gnome.SettingsDaemon.Sound',
'org.gnome.SettingsDaemon.UsbProtection',
'org.gnome.SettingsDaemon.Wacom',
+ 'org.gnome.SettingsDaemon.Wwan',
'org.gnome.SettingsDaemon.XSettings',
]
--
GitLab

View File

@ -0,0 +1,16 @@
--- a/src/rotation-manager.c 2020-08-06 13:39:48.934458000 +0200
+++ b/src/rotation-manager.c 2020-08-06 13:40:52.711124361 +0200
@@ -79,11 +79,11 @@ match_orientation (PhoshRotationManager
if (!g_strcmp0 ("normal", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
- } else if (!g_strcmp0 ("right-up", orient)) {
+ } else if (!g_strcmp0 ("left-up", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_270;
} else if (!g_strcmp0 ("bottom-up", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_180;
- } else if (!g_strcmp0 ("left-up", orient)) {
+ } else if (!g_strcmp0 ("right-up", orient)) {
transform = PHOSH_MONITOR_TRANSFORM_90;
} else if (!g_strcmp0 ("undefined", orient)) {
return; /* just leave as is */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
From 1477bce780cd693614c5714103e84f6c1897b2c7 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 23 Oct 2020 13:40:44 +0200
Subject: [PATCH] shell: honor configured rotation
Resetting the default transform causes the user-configured rotation to
be ignored. In cases where the transform needs to be reset, this is
already done in lockscreen manager.
---
src/shell.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index f38bdab4..48dd4c2b 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -484,10 +484,6 @@ setup_idle_cb (PhoshShell *self)
phosh_session_register (PHOSH_APP_ID);
- /* If we start rotated, fix this up */
- if (phosh_shell_get_transform (self) != PHOSH_MONITOR_TRANSFORM_NORMAL)
- phosh_shell_set_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL);
-
priv->startup_finished = TRUE;
return FALSE;
--
2.26.2

View File

@ -0,0 +1,303 @@
From fa9abd53328b8a1f6d1fcab39aa0fa0de3af99b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 10 Nov 2020 20:13:29 +0100
Subject: [PATCH 1/4] layer-surface: Add debugging when a surface goes away
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This helps tracing the order of events
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/layersurface.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/layersurface.c b/src/layersurface.c
index 0cde3c35..5cf177fc 100644
--- a/src/layersurface.c
+++ b/src/layersurface.c
@@ -109,6 +109,7 @@ layer_surface_closed (void *data,
PhoshLayerSurfacePrivate *priv = phosh_layer_surface_get_instance_private (self);
g_return_if_fail (priv->layer_surface == surface);
+ g_debug ("Destroying layer surface '%s'", priv->namespace);
zwlr_layer_surface_v1_destroy (priv->layer_surface);
priv->layer_surface = NULL;
gtk_widget_destroy (GTK_WIDGET (self));
--
2.26.2
From 3f15d7658ca9dfc2e21d660ccf5620fff1bd1b89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 11 Nov 2020 14:05:06 +0100
Subject: [PATCH 2/4] lockscreen-manager: Explain purpose
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/lockscreen-manager.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index dac21e86..52c58bb4 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -23,6 +23,10 @@
* SECTION:lockscreen-manager
* @short_description: The singleton that manages screen locking
* @Title: PhoshLockscreenManager
+ *
+ * The #PhoshLockscreenManager is responsible for putting the #PhoshLockscreen
+ * on the primary output and a #PhoshLockshield on other outputs when the session
+ * becomes idle or when invoked explicitly via phosh_lockscreen_manager_set_locked().
*/
/* See https://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html#org.gnome.SessionManager.Presence:status */
--
2.26.2
From e7c139c704231619ef28c93ae91bd5cc2fb82373 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 10 Nov 2020 20:39:23 +0100
Subject: [PATCH 3/4] lockscreen-manager: No need to disconnect signals from
lockscreen
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We're about to destroy the lockscreen object a couple of lines later
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/lockscreen-manager.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index 52c58bb4..bfd3da24 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -79,7 +79,6 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen)
g_return_if_fail (PHOSH_IS_LOCKSCREEN (lockscreen));
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (self->lockscreen));
- g_signal_handlers_disconnect_by_data (lockscreen, self);
g_signal_handlers_disconnect_by_data (monitor_manager, self);
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
@@ -265,10 +264,7 @@ phosh_lockscreen_manager_dispose (GObject *object)
PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object);
g_clear_pointer (&self->shields, g_ptr_array_unref);
- if (self->lockscreen) {
- g_signal_handlers_disconnect_by_data (self->lockscreen, self);
- g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
- }
+ g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
g_clear_object (&self->settings);
G_OBJECT_CLASS (phosh_lockscreen_manager_parent_class)->dispose (object);
--
2.26.2
From 3e5e2c4a7f12b1e7bfb6fb6ea3e36b28b887cba1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 7 Oct 2020 16:25:36 +0200
Subject: [PATCH 4/4] lockscreen-manager: Move lock screen when output goes
away
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We move the lock screen in case the monitor it's on goes away.
Closes: #385
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/lockscreen-manager.c | 99 +++++++++++++++++++++++++++++++---------
1 file changed, 78 insertions(+), 21 deletions(-)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index bfd3da24..781d131b 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -80,6 +80,7 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen)
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (self->lockscreen));
g_signal_handlers_disconnect_by_data (monitor_manager, self);
+ g_signal_handlers_disconnect_by_data (shell, self);
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
/* Unlock all other outputs */
@@ -102,7 +103,7 @@ lockscreen_wakeup_output_cb (PhoshLockscreenManager *self, PhoshLockscreen *lock
}
-/* Lock a particular monitor bringing up a shield */
+/* Lock a non primary monitor bringing up a shield */
static void
lock_monitor (PhoshLockscreenManager *self,
PhoshMonitor *monitor)
@@ -114,22 +115,44 @@ lock_monitor (PhoshLockscreenManager *self,
phosh_wayland_get_zwlr_layer_shell_v1 (wl),
monitor->wl_output);
+ g_object_set_data (G_OBJECT (shield), "phosh-monitor", monitor);
+
g_ptr_array_add (self->shields, shield);
gtk_widget_show (shield);
}
+static void
+remove_shield_by_monitor (PhoshLockscreenManager *self,
+ PhoshMonitor *monitor)
+{
+ for (int i = 0; i < self->shields->len; i++) {
+ PhoshMonitor *shield_monitor;
+ PhoshLockshield *shield = g_ptr_array_index (self->shields, i);
+
+ shield_monitor = g_object_get_data (G_OBJECT (shield), "phosh-monitor");
+ g_return_if_fail (PHOSH_IS_MONITOR (shield_monitor));
+ if (shield_monitor == monitor) {
+ g_debug ("Removing shield %p", shield);
+ g_ptr_array_remove (self->shields, shield);
+ break;
+ }
+ }
+}
+
+
static void
on_monitor_removed (PhoshLockscreenManager *self,
PhoshMonitor *monitor,
PhoshMonitorManager *monitormanager)
{
+
+
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self));
- g_debug ("Monitor removed");
- /* TODO: We just leave the widget dangling, it will be destroyed on
- * unlock */
+ g_debug ("Monitor '%s' removed", monitor->name);
+ remove_shield_by_monitor (self, monitor);
}
@@ -141,28 +164,67 @@ on_monitor_added (PhoshLockscreenManager *self,
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self));
- g_debug ("Monitor added");
+ g_debug ("Monitor '%s' added", monitor->name);
lock_monitor (self, monitor);
}
static void
-lockscreen_lock (PhoshLockscreenManager *self)
+lock_primary_monitor (PhoshLockscreenManager *self)
{
PhoshMonitor *primary_monitor;
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshShell *shell = phosh_shell_get_default ();
- PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
-
- g_return_if_fail (!self->locked);
primary_monitor = phosh_shell_get_primary_monitor (shell);
- g_return_if_fail (primary_monitor);
/* Undo any transform on the primary display so the keypad becomes usable */
self->transform = phosh_shell_get_transform (shell);
phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
+ /* The primary output gets the clock, keypad, ... */
+ self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
+ phosh_wayland_get_zwlr_layer_shell_v1 (wl),
+ primary_monitor->wl_output));
+
+ g_object_connect (
+ self->lockscreen,
+ "swapped-object-signal::lockscreen-unlock", G_CALLBACK (lockscreen_unlock_cb), self,
+ "swapped-object-signal::wakeup-output", G_CALLBACK (lockscreen_wakeup_output_cb), self,
+ NULL);
+
+ gtk_widget_show (GTK_WIDGET (self->lockscreen));
+ /* Old lockscreen gets remove due to `layer_surface_closed` */
+}
+
+
+static void
+on_primary_monitor_changed (PhoshLockscreenManager *self,
+ GParamSpec *pspec,
+ PhoshShell *shell)
+{
+ g_return_if_fail (PHOSH_IS_SHELL (shell));
+ g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self));
+
+ g_debug ("primary monitor changed, need to move lockscreen");
+ lock_primary_monitor (self);
+ /* We don't remove a shield that might exist to avoid the screen
+ content flickering in. The shield will be removed on unlock */
+}
+
+
+static void
+lockscreen_lock (PhoshLockscreenManager *self)
+{
+ PhoshMonitor *primary_monitor;
+ PhoshShell *shell = phosh_shell_get_default ();
+ PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
+
+ g_return_if_fail (!self->locked);
+
+ primary_monitor = phosh_shell_get_primary_monitor (shell);
+ g_return_if_fail (primary_monitor);
+
/* Listen for monitor changes */
g_signal_connect_object (monitor_manager, "monitor-added",
G_CALLBACK (on_monitor_added),
@@ -174,12 +236,13 @@ lockscreen_lock (PhoshLockscreenManager *self)
self,
G_CONNECT_SWAPPED);
- /* The primary output gets the clock, keypad, ... */
- self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
- phosh_wayland_get_zwlr_layer_shell_v1 (wl),
- primary_monitor->wl_output));
- gtk_widget_show (GTK_WIDGET (self->lockscreen));
+ g_signal_connect_object (shell,
+ "notify::primary-monitor",
+ G_CALLBACK (on_primary_monitor_changed),
+ self,
+ G_CONNECT_SWAPPED);
+ lock_primary_monitor (self);
/* Lock all other outputs */
self->shields = g_ptr_array_new_with_free_func ((GDestroyNotify) (gtk_widget_destroy));
@@ -191,12 +254,6 @@ lockscreen_lock (PhoshLockscreenManager *self)
lock_monitor (self, monitor);
}
- g_object_connect (
- self->lockscreen,
- "swapped-object-signal::lockscreen-unlock", G_CALLBACK (lockscreen_unlock_cb), self,
- "swapped-object-signal::wakeup-output", G_CALLBACK (lockscreen_wakeup_output_cb), self,
- NULL);
-
self->locked = TRUE;
self->active_time = g_get_monotonic_time ();
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED]);
--
2.26.2

View File

@ -0,0 +1,261 @@
From 721d073ebbcb2ba973b21f8213af3d4cd7781110 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Tue, 27 Oct 2020 15:07:37 +0100
Subject: [PATCH 1/5] shell: add an accessor for the mode manager
Other modules should be able to query the device type too.
---
src/shell.c | 13 +++++++++++++
src/shell.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/src/shell.c b/src/shell.c
index 42893d44..f38bdab4 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -819,6 +819,19 @@ phosh_shell_get_lockscreen_manager (PhoshShell *self)
}
+PhoshModeManager *
+phosh_shell_get_mode_manager (PhoshShell *self)
+{
+ PhoshShellPrivate *priv;
+
+ g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
+ priv = phosh_shell_get_instance_private (self);
+
+ g_return_val_if_fail (PHOSH_IS_MODE_MANAGER (priv->mode_manager), NULL);
+ return priv->mode_manager;
+}
+
+
PhoshMonitorManager *
phosh_shell_get_monitor_manager (PhoshShell *self)
{
diff --git a/src/shell.h b/src/shell.h
index 65680a57..541203db 100644
--- a/src/shell.h
+++ b/src/shell.h
@@ -47,6 +47,7 @@ void phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMon
PhoshMonitor *phosh_shell_get_primary_monitor (PhoshShell *self);
PhoshMonitor *phosh_shell_get_builtin_monitor (PhoshShell *self);
PhoshLockscreenManager *phosh_shell_get_lockscreen_manager (PhoshShell *self);
+PhoshModeManager *phosh_shell_get_mode_manager (PhoshShell *self);
PhoshMonitorManager *phosh_shell_get_monitor_manager (PhoshShell *self);
PhoshOskManager *phosh_shell_get_osk_manager (PhoshShell *self);
PhoshToplevelManager *phosh_shell_get_toplevel_manager (PhoshShell *self);
--
2.26.2
From bb69665789137e9ee3391d55cd86ad7f01122790 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 13 Nov 2020 18:00:49 +0100
Subject: [PATCH 2/5] monitor: Add phosh_monitor_get_power_save_mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Simple getter
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/monitor/monitor.c | 12 ++++++++++++
src/monitor/monitor.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c7199ea8..8379c944 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -572,3 +572,15 @@ phosh_monitor_set_power_save_mode (PhoshMonitor *self, PhoshMonitorPowerSaveMode
zwlr_output_power_v1_set_mode (self->wlr_output_power, wl_mode);
}
+
+/**
+ * phosh_monitor_get_power_save_mode:
+ * @self: A #PhoshMonitor
+ *
+ * Returns: The current power save mode
+ */
+PhoshMonitorPowerSaveMode
+phosh_monitor_get_power_save_mode (PhoshMonitor *self)
+{
+ return self->power_mode;
+}
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index 7fbd4570..d7fea9cf 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -149,5 +149,6 @@ gboolean phosh_monitor_is_flipped (PhoshMonitor *self);
guint phosh_monitor_get_transform (PhoshMonitor *self);
void phosh_monitor_set_power_save_mode (PhoshMonitor *self,
PhoshMonitorPowerSaveMode mode);
+PhoshMonitorPowerSaveMode phosh_monitor_get_power_save_mode (PhoshMonitor *self);
G_END_DECLS
--
2.26.2
From 9f409166802e032b4f37586f88936ef9c8082d1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 13 Nov 2020 17:01:06 +0100
Subject: [PATCH 3/5] lockscreen-manager: Handle transform only on power mode
changes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This makes sure we rotate correctly when the screen unblanks and
we don't operate on disabled outputs which trips up phoc.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/lockscreen-manager.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index 781d131b..81f562cb 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -72,14 +72,17 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen)
{
PhoshShell *shell = phosh_shell_get_default ();
PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
-
- phosh_shell_set_transform (shell, self->transform);
- self->transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
+ PhoshMonitor *primary_monitor = phosh_shell_get_primary_monitor (shell);
g_return_if_fail (PHOSH_IS_LOCKSCREEN (lockscreen));
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (self->lockscreen));
+ /* Fixup transform in case the lockscreen needed to rotate to unlock */
+ g_debug ("Restoring transform %d", self->transform);
+ phosh_shell_set_transform (shell, self->transform);
+
g_signal_handlers_disconnect_by_data (monitor_manager, self);
+ g_signal_handlers_disconnect_by_data (primary_monitor, self);
g_signal_handlers_disconnect_by_data (shell, self);
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
@@ -168,6 +171,23 @@ on_monitor_added (PhoshLockscreenManager *self,
lock_monitor (self, monitor);
}
+static void
+on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
+ GParamSpec *pspec,
+ PhoshMonitor *monitor)
+{
+ PhoshShell *shell = phosh_shell_get_default ();
+
+ switch (phosh_monitor_get_power_save_mode (monitor)) {
+ case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
+ phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
+ break;
+ case PHOSH_MONITOR_POWER_SAVE_MODE_OFF:
+ break;
+ default:
+ g_warn_if_reached ();
+ }
+}
static void
lock_primary_monitor (PhoshLockscreenManager *self)
@@ -177,10 +197,7 @@ lock_primary_monitor (PhoshLockscreenManager *self)
PhoshShell *shell = phosh_shell_get_default ();
primary_monitor = phosh_shell_get_primary_monitor (shell);
-
- /* Undo any transform on the primary display so the keypad becomes usable */
self->transform = phosh_shell_get_transform (shell);
- phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
/* The primary output gets the clock, keypad, ... */
self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
@@ -193,6 +210,10 @@ lock_primary_monitor (PhoshLockscreenManager *self)
"swapped-object-signal::wakeup-output", G_CALLBACK (lockscreen_wakeup_output_cb), self,
NULL);
+ g_signal_connect_swapped (primary_monitor, "notify::power-mode",
+ G_CALLBACK(on_primary_monitor_power_mode_changed),
+ self);
+
gtk_widget_show (GTK_WIDGET (self->lockscreen));
/* Old lockscreen gets remove due to `layer_surface_closed` */
}
--
2.26.2
From 6abda174169c3257230cfa5d9253e4ab83985572 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Tue, 27 Oct 2020 15:09:39 +0100
Subject: [PATCH 4/5] lockscreen-manager: undo transform only for phones
If the display is large enough to make the keypad usable even when
rotated, we should not try to rotate it back to the default orientation.
---
src/lockscreen-manager.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index 81f562cb..2dbc3111 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -177,6 +177,14 @@ on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
PhoshMonitor *monitor)
{
PhoshShell *shell = phosh_shell_get_default ();
+ PhoshModeManager *mode_manager = phosh_shell_get_mode_manager(shell);
+
+ /*
+ * Only phones need to switch orientation so that the lock screen fits
+ * https://source.puri.sm/Librem5/phosh/-/issues/388
+ */
+ if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE)
+ return;
switch (phosh_monitor_get_power_save_mode (monitor)) {
case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
--
2.26.2
From f2ab3ffd704ad4600ad254116829714029591ba4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sat, 14 Nov 2020 11:32:15 +0100
Subject: [PATCH 5/5] lockscreen-manager: Don't rotate external screens
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We keep the transform there as well assuming the lock screen fits.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/lockscreen-manager.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
index 2dbc3111..c731dae5 100644
--- a/src/lockscreen-manager.c
+++ b/src/lockscreen-manager.c
@@ -186,6 +186,10 @@ on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE)
return;
+ /* Don't mess with transforms on external screens either */
+ if (!phosh_monitor_is_builtin (monitor))
+ return;
+
switch (phosh_monitor_get_power_save_mode (monitor)) {
case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
--
2.26.2

View File

@ -0,0 +1,281 @@
From 3669f5caa68e026056dfc5359e373dbe193d4d32 Mon Sep 17 00:00:00 2001
From: Alexander Mikhaylenko <alexm@gnome.org>
Date: Mon, 16 Nov 2020 18:46:08 +0500
Subject: [PATCH 1/2] Slide back windows that failed to close
Fixes https://source.puri.sm/Librem5/phosh/-/issues/429
---
src/activity.c | 28 ++++++++++++++++++++++++++++
src/swipe-away-bin.c | 12 ++++++++++++
src/swipe-away-bin.h | 1 +
3 files changed, 41 insertions(+)
diff --git a/src/activity.c b/src/activity.c
index 0d61aa79..96cbe38c 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -67,6 +67,7 @@ typedef struct
PhoshThumbnail *thumbnail;
gboolean hovering;
+ guint remove_timeout_id;
} PhoshActivityPrivate;
@@ -171,9 +172,31 @@ closed_cb (PhoshActivity *self)
}
+static gboolean
+remove_timeout_cb (PhoshActivity *self)
+{
+ PhoshActivityPrivate *priv = phosh_activity_get_instance_private (self);
+
+ phosh_swipe_away_bin_undo (PHOSH_SWIPE_AWAY_BIN (priv->swipe_bin));
+
+ priv->remove_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+
static void
removed_cb (PhoshActivity *self)
{
+ PhoshActivityPrivate *priv = phosh_activity_get_instance_private (self);
+
+ if (priv->remove_timeout_id)
+ g_source_remove (priv->remove_timeout_id);
+
+ priv->remove_timeout_id =
+ g_timeout_add_seconds (1, (GSourceFunc) remove_timeout_cb, self);
+ g_source_set_name_by_id (priv->remove_timeout_id, "[phosh] remove_timeout_id");
+
g_signal_emit (self, signals[CLOSED], 0);
}
@@ -276,6 +299,11 @@ phosh_activity_dispose (GObject *object)
g_clear_object (&priv->thumbnail);
g_clear_object (&priv->info);
+ if (priv->remove_timeout_id) {
+ g_source_remove (priv->remove_timeout_id);
+ priv->remove_timeout_id = 0;
+ }
+
G_OBJECT_CLASS (phosh_activity_parent_class)->dispose (object);
}
diff --git a/src/swipe-away-bin.c b/src/swipe-away-bin.c
index f38f6585..ff8be768 100644
--- a/src/swipe-away-bin.c
+++ b/src/swipe-away-bin.c
@@ -270,3 +270,15 @@ phosh_swipe_away_bin_remove (PhoshSwipeAwayBin *self)
animate (self, 200, 1);
}
+
+
+void
+phosh_swipe_away_bin_undo (PhoshSwipeAwayBin *self)
+{
+ g_return_if_fail (PHOSH_IS_SWIPE_AWAY_BIN (self));
+
+ if (self->animation)
+ phosh_animation_stop (self->animation);
+
+ animate (self, 200, 0);
+}
diff --git a/src/swipe-away-bin.h b/src/swipe-away-bin.h
index ea618c3d..67930046 100644
--- a/src/swipe-away-bin.h
+++ b/src/swipe-away-bin.h
@@ -14,3 +14,4 @@
G_DECLARE_FINAL_TYPE (PhoshSwipeAwayBin, phosh_swipe_away_bin, PHOSH, SWIPE_AWAY_BIN, GtkEventBox)
void phosh_swipe_away_bin_remove (PhoshSwipeAwayBin *self);
+void phosh_swipe_away_bin_undo (PhoshSwipeAwayBin *self);
--
2.26.2
From 852326dcccbf9ad5ec59f6ecb93d23e1cce4f9e3 Mon Sep 17 00:00:00 2001
From: Alexander Mikhaylenko <alexm@gnome.org>
Date: Mon, 16 Nov 2020 19:29:45 +0500
Subject: [PATCH 2/2] Use easeOutBounce interpolator for the slide back
animation
Make it a little fancier.
---
src/animation.c | 48 +++++++++++++++++++++++++++++++++++++++++++-
src/animation.h | 13 ++++++++++++
src/swipe-away-bin.c | 10 +++++----
3 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/src/animation.c b/src/animation.c
index 6ba2f7ae..5770672b 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -24,6 +24,7 @@ struct _PhoshAnimation
double value_from;
double value_to;
gint64 duration;
+ PhoshAnimationType type;
gint64 start_time;
guint tick_cb_id;
@@ -43,6 +44,49 @@ set_value (PhoshAnimation *self,
#define LERP(a, b, t) (a) * (1.0 - (t)) + (b) * (t)
+/* Adapted from https://github.com/janrembold/es6-easings/blob/master/src/index.ts#L135 */
+/* TODO: Move to libhandy at some point */
+static double
+ease_out_bounce (double t)
+{
+ double p;
+
+ if (t < 1.0 / 2.75)
+ return 7.5625 * t * t;
+
+ if (t < 2.0 / 2.75) {
+ p = t - (1.5 / 2.75);
+
+ return 7.5625 * p * p + 0.75;
+ }
+
+ if (t < 2.5 / 2.75) {
+ p = t - (2.25 / 2.75);
+
+ return 7.5625 * p * p + 0.9375;
+ }
+
+ p = t - (2.625 / 2.75);
+
+ return 7.5625 * p * p + 0.984375;
+}
+
+static inline double
+interpolate (PhoshAnimationType type,
+ double t)
+{
+ switch (type) {
+ case PHOSH_ANIMATION_TYPE_EASE_OUT_CUBIC:
+ return hdy_ease_out_cubic (t);
+
+ case PHOSH_ANIMATION_TYPE_EASE_OUT_BOUNCE:
+ return ease_out_bounce (t);
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
static gboolean
tick_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
@@ -63,7 +107,7 @@ tick_cb (GtkWidget *widget,
return G_SOURCE_REMOVE;
}
- set_value (self, LERP (self->value_from, self->value_to, hdy_ease_out_cubic (t)));
+ set_value (self, LERP (self->value_from, self->value_to, interpolate (self->type, t)));
return G_SOURCE_CONTINUE;
}
@@ -81,6 +125,7 @@ phosh_animation_new (GtkWidget *widget,
double from,
double to,
gint64 duration,
+ PhoshAnimationType type,
PhoshAnimationValueCallback value_cb,
PhoshAnimationDoneCallback done_cb,
gpointer user_data)
@@ -99,6 +144,7 @@ phosh_animation_new (GtkWidget *widget,
self->value_from = from;
self->value_to = to;
self->duration = duration;
+ self->type = type;
self->value_cb = value_cb;
self->done_cb = done_cb;
self->user_data = user_data;
diff --git a/src/animation.h b/src/animation.h
index 1e13791d..f474704e 100644
--- a/src/animation.h
+++ b/src/animation.h
@@ -13,6 +13,18 @@ G_BEGIN_DECLS
#define PHOSH_TYPE_ANIMATION (phosh_animation_get_type())
+/**
+ * PhoshAnimationType:
+ * @PHOSH_ANIMATION_TYPE_EASE_OUT_CUBIC: Use easeOutCubic interpolation.
+ * @PHOSH_ANIMATION_TYPE_EASE_OUT_BOUNCE: Use easeOutBounce interpolation.
+ *
+ * The animation type of #PhoshAnimationType.
+ */
+typedef enum {
+ PHOSH_ANIMATION_TYPE_EASE_OUT_CUBIC,
+ PHOSH_ANIMATION_TYPE_EASE_OUT_BOUNCE,
+} PhoshAnimationType;
+
typedef struct _PhoshAnimation PhoshAnimation;
typedef void (*PhoshAnimationValueCallback) (double value,
@@ -25,6 +37,7 @@ PhoshAnimation *phosh_animation_new (GtkWidget *widget,
double from,
double to,
gint64 duration,
+ PhoshAnimationType type,
PhoshAnimationValueCallback value_cb,
PhoshAnimationDoneCallback done_cb,
gpointer user_data);
diff --git a/src/swipe-away-bin.c b/src/swipe-away-bin.c
index ff8be768..dca4723c 100644
--- a/src/swipe-away-bin.c
+++ b/src/swipe-away-bin.c
@@ -76,13 +76,15 @@ animation_done_cb (PhoshSwipeAwayBin *self)
static void
animate (PhoshSwipeAwayBin *self,
gint64 duration,
- double to)
+ double to,
+ PhoshAnimationType type)
{
self->animation =
phosh_animation_new (GTK_WIDGET (self),
self->progress,
to,
duration,
+ type,
(PhoshAnimationValueCallback) animation_value_cb,
(PhoshAnimationDoneCallback) animation_done_cb,
self);
@@ -112,7 +114,7 @@ end_swipe_cb (PhoshSwipeAwayBin *self,
gint64 duration,
double to)
{
- animate (self, duration, to);
+ animate (self, duration, to, PHOSH_ANIMATION_TYPE_EASE_OUT_CUBIC);
}
@@ -268,7 +270,7 @@ phosh_swipe_away_bin_remove (PhoshSwipeAwayBin *self)
if (self->animation)
phosh_animation_stop (self->animation);
- animate (self, 200, 1);
+ animate (self, 200, 1, PHOSH_ANIMATION_TYPE_EASE_OUT_CUBIC);
}
@@ -280,5 +282,5 @@ phosh_swipe_away_bin_undo (PhoshSwipeAwayBin *self)
if (self->animation)
phosh_animation_stop (self->animation);
- animate (self, 200, 0);
+ animate (self, 600, 0, PHOSH_ANIMATION_TYPE_EASE_OUT_BOUNCE);
}
--
2.26.2

View File

@ -0,0 +1,392 @@
From e91c0b36899a05dfb9c95e60ccd0e28313b68e75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sun, 6 Dec 2020 18:46:37 +0100
Subject: [PATCH 1/2] notification: Fix phosh_notification_expires docstring
---
src/notifications/notification.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/notifications/notification.c b/src/notifications/notification.c
index 19ce8be8..8e5239f7 100644
--- a/src/notifications/notification.c
+++ b/src/notifications/notification.c
@@ -934,8 +934,8 @@ expired (gpointer data)
*
* Set @self to expire after @timeout (from this call)
*
- * Note doesn't close the notification, for that call
- * phosh_notification_close() is response to #PhoshNotification::expired
+ * Note: doesn't close the notification, for that call
+ * phosh_notification_close() in response to #PhoshNotification::expired
*/
void
phosh_notification_expires (PhoshNotification *self,
--
2.26.2
From 8abbd9ae7efa99553a40f24da02d5e2d9c1de9f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sun, 6 Dec 2020 16:41:31 +0100
Subject: [PATCH 2/2] notification-content: Add close button on hover
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This adds a close button when hovering with the mouse. Modeled like
176354a2e0b27b2508213a22bc0029eeda4dde93.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/notifications/notification-content.c | 91 ++++++++++++
src/style.css | 7 +
src/ui/notification-content.ui | 180 ++++++++++++++---------
3 files changed, 212 insertions(+), 66 deletions(-)
diff --git a/src/notifications/notification-content.c b/src/notifications/notification-content.c
index 3ea3dd2a..6cfa8ccc 100644
--- a/src/notifications/notification-content.c
+++ b/src/notifications/notification-content.c
@@ -35,12 +35,92 @@ struct _PhoshNotificationContent {
GtkWidget *lbl_body;
GtkWidget *img_image;
GtkWidget *box_actions;
+ GtkWidget *revealer;
+ GtkWidget *ev_box;
+
+ gboolean hovering;
};
typedef struct _PhoshNotificationContent PhoshNotificationContent;
G_DEFINE_TYPE (PhoshNotificationContent, phosh_notification_content, GTK_TYPE_LIST_BOX_ROW)
+static void
+closed_cb (PhoshNotificationContent *self)
+{
+ phosh_notification_close (self->notification, PHOSH_NOTIFICATION_REASON_CLOSED);
+}
+
+static void
+set_hovering (PhoshNotificationContent *self,
+ gboolean hovering)
+{
+ if (hovering == self->hovering)
+ return;
+
+ self->hovering = hovering;
+
+ /* Revealer won't animate if not mapped, show it preemptively */
+ if (hovering)
+ gtk_widget_show (self->revealer);
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), hovering);
+}
+
+
+static gboolean
+on_enter_notify_event (PhoshNotificationContent *self,
+ GdkEventCrossing *event,
+ GtkEventBox *box)
+{
+ if (event->window != gtk_widget_get_window (self->ev_box) ||
+ event->detail == GDK_NOTIFY_INFERIOR)
+ return GDK_EVENT_PROPAGATE;
+
+ /* enter-notify never happens on touch, so we don't need to check it */
+ set_hovering (self, TRUE);
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+
+static gboolean
+on_leave_notify_event (PhoshNotificationContent *self,
+ GdkEventCrossing *event,
+ GtkEventBox *box)
+{
+ if (event->window != gtk_widget_get_window (self->ev_box) ||
+ event->detail == GDK_NOTIFY_INFERIOR)
+ return GDK_EVENT_PROPAGATE;
+
+ set_hovering (self, FALSE);
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+
+static gboolean
+on_motion_notify_event (PhoshNotificationContent *self,
+ GdkEventMotion *event,
+ GtkEventBox *box)
+{
+ GdkDevice *source_device = gdk_event_get_source_device ((GdkEvent *) event);
+ GdkInputSource input_source = gdk_device_get_source (source_device);
+
+ if (input_source != GDK_SOURCE_TOUCHSCREEN)
+ set_hovering (self, TRUE);
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+
+static void
+phosh_notification_content_unmap (GtkWidget *widget)
+{
+ set_hovering (PHOSH_NOTIFICATION_CONTENT (widget), FALSE);
+
+ GTK_WIDGET_CLASS (phosh_notification_content_parent_class)->unmap (widget);
+}
static gboolean
set_image (GBinding *binding,
@@ -248,6 +328,8 @@ phosh_notification_content_class_init (PhoshNotificationContentClass *klass)
object_class->set_property = phosh_notification_content_set_property;
object_class->get_property = phosh_notification_content_get_property;
+ widget_class->unmap = phosh_notification_content_unmap;
+
/**
* PhoshNotificationContent:notification:
* @self: the #PhoshNotificationContent
@@ -271,6 +353,12 @@ phosh_notification_content_class_init (PhoshNotificationContentClass *klass)
gtk_widget_class_bind_template_child (widget_class, PhoshNotificationContent, lbl_body);
gtk_widget_class_bind_template_child (widget_class, PhoshNotificationContent, img_image);
gtk_widget_class_bind_template_child (widget_class, PhoshNotificationContent, box_actions);
+ gtk_widget_class_bind_template_child (widget_class, PhoshNotificationContent, revealer);
+ gtk_widget_class_bind_template_child (widget_class, PhoshNotificationContent, ev_box);
+ gtk_widget_class_bind_template_callback (widget_class, closed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_enter_notify_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_leave_notify_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_motion_notify_event);
gtk_widget_class_set_css_name (widget_class, "phosh-notification-content");
}
@@ -312,6 +400,9 @@ phosh_notification_content_init (PhoshNotificationContent *self)
G_ACTION_GROUP (map));
gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtk_widget_add_events (GTK_WIDGET (self->ev_box),
+ GDK_ENTER_NOTIFY | GDK_LEAVE_NOTIFY | GDK_MOTION_NOTIFY);
}
diff --git a/src/style.css b/src/style.css
index c279e946..4b0d6021 100644
--- a/src/style.css
+++ b/src/style.css
@@ -273,6 +273,13 @@ phosh-notification-content {
background: transparent;
}
+phosh-notification-content .close-button {
+ border-radius: 50%;
+ min-width: 24px;
+ min-height: 24px;
+ padding: 0;
+}
+
phosh-notification-content .message-area {
padding: 12px;
}
diff --git a/src/ui/notification-content.ui b/src/ui/notification-content.ui
index 0abe6249..db1b86e5 100644
--- a/src/ui/notification-content.ui
+++ b/src/ui/notification-content.ui
@@ -4,77 +4,125 @@
<template class="PhoshNotificationContent" parent="GtkListBoxRow">
<property name="visible">True</property>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="valign">start</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox">
+
+ <object class="GtkEventBox" id="ev_box">
+ <property name="visible">True</property>
+ <property name="valign">fill</property>
+ <property name="above-child">True</property>
+ <signal name="enter-notify-event" handler="on_enter_notify_event" swapped="true"/>
+ <signal name="leave-notify-event" handler="on_leave_notify_event" swapped="true"/>
+ <signal name="motion-notify-event" handler="on_motion_notify_event" swapped="true"/>
+ <child>
+ <object class="GtkOverlay">
<property name="visible">True</property>
- <property name="spacing">12</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkImage" id="img_image">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="valign">start</property>
- <property name="pixel_size">32</property>
- <property name="icon_name">dialog-information</property>
- <style>
- <class name="notification-image"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkLabel" id="lbl_summary">
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="label">Title</property>
- <property name="justify">center</property>
- <property name="ellipsize">end</property>
- <property name="single_line_mode">True</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="lbl_body">
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkImage" id="img_image">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="pixel_size">32</property>
+ <property name="icon_name">dialog-information</property>
+ <style>
+ <class name="notification-image"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkLabel" id="lbl_summary">
+ <property name="visible">True</property>
+ <property name="label">Title</property>
+ <property name="justify">center</property>
+ <property name="ellipsize">end</property>
+ <property name="single_line_mode">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="lbl_body">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="label">Message</property>
+ <property name="use-markup">True</property>
+ <property name="justify">left</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <property name="ellipsize">end</property>
+ <property name="lines">3</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="message-area"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="box_actions">
<property name="visible">True</property>
- <property name="valign">center</property>
- <property name="label">Message</property>
- <property name="use-markup">True</property>
- <property name="justify">left</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="ellipsize">end</property>
- <property name="lines">3</property>
- <property name="xalign">0</property>
- </object>
- </child>
- </object>
+ <property name="orientation">vertical</property>
+ <property name="valign">end</property>
+ <style>
+ <class name="linked"/>
+ <class name="actions-area"/>
+ </style>
+ </object>
+ </child>
+ </object>
</child>
- <style>
- <class name="message-area"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="box_actions">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="valign">end</property>
- <style>
- <class name="linked"/>
- <class name="actions-area"/>
- </style>
- </object>
- </child>
+ <child type="overlay">
+ <object class="GtkRevealer" id="revealer">
+ <property name="transition-type">crossfade</property>
+ <property name="visible" bind-source="revealer" bind-property="child-revealed" bind-flags="sync-create"/>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="margin">12</property>
+ <child>
+ <object class="GtkButton" id="btn_close">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <signal name="clicked" handler="closed_cb" swapped="true"/>
+ <child>
+ <object class="GtkImage" id="img_close_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">window-close-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="close-button"/>
+ <class name="osd"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pass_through">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
--
2.26.2

View File

@ -0,0 +1,347 @@
From 849e8e5f450d5ba1fae9d8ee65b60ac693679cfd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 8 Dec 2020 17:40:49 +0100
Subject: [PATCH 1/4] util: Add helper to munge app-id
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/util.c | 33 +++++++++++++++++++++++++++++++++
src/util.h | 1 +
2 files changed, 34 insertions(+)
diff --git a/src/util.c b/src/util.c
index dd7ad50a..501179d9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -58,3 +58,36 @@ phosh_clear_handler (gulong *handler, gpointer object)
*handler = 0;
}
}
+
+/**
+ * phosh_munge_app_id:
+ * @app_id: the app_id
+ *
+ * Munges an app_id according to the rules used by
+ * gnome-shell, feedbackd and phoc:
+ *
+ * Returns: The munged_app id
+ */
+char *
+phosh_munge_app_id (const char *app_id)
+{
+ char *id = g_strdup (app_id);
+ int i;
+
+ if (g_str_has_suffix (id, ".desktop")) {
+ char *c = g_strrstr (id, ".desktop");
+ if (c)
+ *c = '\0';
+ }
+
+ g_strcanon (id,
+ "0123456789"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "-",
+ '-');
+ for (i = 0; id[i] != '\0'; i++)
+ id[i] = g_ascii_tolower (id[i]);
+
+ return id;
+}
diff --git a/src/util.h b/src/util.h
index 55f79eec..266eeef6 100644
--- a/src/util.h
+++ b/src/util.h
@@ -12,3 +12,4 @@
void phosh_cp_widget_destroy (void *widget);
char *phosh_fix_app_id (const char *app_id);
void phosh_clear_handler (gulong *handler, gpointer object);
+gchar *phosh_munge_app_id (const gchar *app_id);
--
2.26.2
From aecd9cdd2ae1b25b5ee4ef8490fa36b64a6c975f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 8 Dec 2020 17:41:11 +0100
Subject: [PATCH 2/4] notification-manager: Add helper to determine if banners
should be shown
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/notifications/notify-manager.c | 43 ++++++++++++++++++++++++++++++
src/notifications/notify-manager.h | 4 +++
2 files changed, 47 insertions(+)
diff --git a/src/notifications/notify-manager.c b/src/notifications/notify-manager.c
index 0911a3d6..4b380856 100644
--- a/src/notifications/notify-manager.c
+++ b/src/notifications/notify-manager.c
@@ -18,6 +18,7 @@
#include "notify-manager.h"
#include "shell.h"
#include "phosh-enums.h"
+#include "util.h"
#define NOTIFICATION_DEFAULT_TIMEOUT 5000 /* ms */
#define NOTIFICATIONS_SPEC_VERSION "1.2"
@@ -25,6 +26,10 @@
#define NOTIFICATIONS_SCHEMA_ID "org.gnome.desktop.notifications"
#define NOTIFICATIONS_KEY_SHOW_BANNERS "show-banners"
+#define NOTIFICATIONS_APP_SCHEMA_ID NOTIFICATIONS_SCHEMA_ID ".application"
+#define NOTIFICATIONS_APP_PREFIX "/org/gnome/desktop/notifications/application"
+#define NOTIFICATIONS_APP_KEY_SHOW_BANNERS "show-banners"
+
/**
* SECTION:notify-manager
* @short_description: Manages notifications
@@ -693,3 +698,41 @@ phosh_notify_manager_close_notification_by_id (PhoshNotifyManager *self,
phosh_notification_close (notification, reason);
return TRUE;
}
+
+/**
+ * phosh_notify_manager_get_show_notfication_banner:
+ * @self: the #PhoshNotifyManager
+ * @notification: the #PhoshNotification in question
+ *
+ * Checks whether a #PhoshNotificationBanner should be displayed
+ * for the given #PhoshNotification according to current policy.
+ *
+ * Returns: %TRUE if the banner should be shown, otherwise %FALSE
+ */
+gboolean
+phosh_notify_manager_get_show_notification_banner (PhoshNotifyManager *self,
+ PhoshNotification *notification)
+{
+ g_autoptr (GSettings) settings = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *munged_id = NULL;
+ GAppInfo *app_info;
+ gboolean show;
+
+ g_return_val_if_fail (PHOSH_IS_NOTIFY_MANAGER (self), FALSE);
+
+ if (!self->show_banners)
+ return FALSE;
+
+ app_info = phosh_notification_get_app_info (notification);
+ if (!app_info)
+ return TRUE;
+
+ munged_id = phosh_munge_app_id (g_app_info_get_id(app_info));
+ path = g_strconcat (NOTIFICATIONS_APP_PREFIX, "/", munged_id, "/", NULL);
+ settings = g_settings_new_with_path (NOTIFICATIONS_APP_SCHEMA_ID, path);
+ show = g_settings_get_boolean (settings, NOTIFICATIONS_APP_KEY_SHOW_BANNERS);
+
+ g_debug ("Show banners for %s: %d", munged_id, show);
+ return show;
+}
diff --git a/src/notifications/notify-manager.h b/src/notifications/notify-manager.h
index 0f75107f..9282b685 100644
--- a/src/notifications/notify-manager.h
+++ b/src/notifications/notify-manager.h
@@ -30,4 +30,8 @@ void phosh_notify_manager_add_notification (PhoshNotifyManager
gboolean phosh_notify_manager_close_notification_by_id (PhoshNotifyManager *self,
int id,
PhoshNotificationReason reason);
+gboolean
+ phosh_notify_manager_get_show_notification_banner (
+ PhoshNotifyManager *self,
+ PhoshNotification *notification);
G_END_DECLS
--
2.26.2
From 1d8c7b2892dd80600f0cdabf6a86849309b9ee1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 8 Dec 2020 18:53:42 +0100
Subject: [PATCH 3/4] notification-manager: Keep a list of applications around
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows users to configure their notification properties in
g-c-c.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/notifications/notify-manager.c | 68 +++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 2 deletions(-)
diff --git a/src/notifications/notify-manager.c b/src/notifications/notify-manager.c
index 4b380856..14c0c6b5 100644
--- a/src/notifications/notify-manager.c
+++ b/src/notifications/notify-manager.c
@@ -25,10 +25,12 @@
#define NOTIFICATIONS_SCHEMA_ID "org.gnome.desktop.notifications"
#define NOTIFICATIONS_KEY_SHOW_BANNERS "show-banners"
+#define NOTIFICATIONS_KEY_APP_CHILDREN "application-children"
#define NOTIFICATIONS_APP_SCHEMA_ID NOTIFICATIONS_SCHEMA_ID ".application"
#define NOTIFICATIONS_APP_PREFIX "/org/gnome/desktop/notifications/application"
#define NOTIFICATIONS_APP_KEY_SHOW_BANNERS "show-banners"
+#define NOTIFICATIONS_APP_KEY_APP_ID "application-id"
/**
* SECTION:notify-manager
@@ -53,6 +55,7 @@ typedef struct _PhoshNotifyManager
guint next_id;
guint unknown_source;
gboolean show_banners;
+ GStrv app_children;
GSettings *settings;
@@ -277,6 +280,36 @@ parse_icon_string (const char *string)
}
+static void
+phosh_notify_manager_add_application (PhoshNotifyManager *self, GAppInfo *info)
+{
+ g_autofree char *munged_id = NULL;
+ g_autofree char *path = NULL;
+ g_autoptr (GSettings) settings = NULL;
+ g_autoptr(GPtrArray) new_apps = NULL;
+ const gchar *id;
+
+ id = g_app_info_get_id(info);
+ munged_id = phosh_munge_app_id (id);
+ if (g_strv_contains ((const gchar * const *)self->app_children, munged_id))
+ return;
+
+ g_debug ("Adding new application: %s/%s", id, munged_id);
+ new_apps = g_ptr_array_sized_new (g_strv_length (self->app_children) + 1);
+ for (int i = 0; i < g_strv_length (self->app_children); i++) {
+ g_ptr_array_add (new_apps, self->app_children[i]);
+ }
+ g_ptr_array_add (new_apps, munged_id);
+ g_ptr_array_add (new_apps, NULL);
+
+ path = g_strconcat (NOTIFICATIONS_APP_PREFIX, "/", munged_id, "/", NULL);
+ settings = g_settings_new_with_path (NOTIFICATIONS_APP_SCHEMA_ID, path);
+ g_settings_set_string (settings, NOTIFICATIONS_APP_KEY_APP_ID, id);
+ g_settings_set_strv (self->settings, NOTIFICATIONS_KEY_APP_CHILDREN,
+ (const gchar * const *)new_apps->pdata);
+}
+
+
static gboolean
handle_notify (PhoshNotifyDBusNotifications *skeleton,
GDBusMethodInvocation *invocation,
@@ -409,8 +442,10 @@ handle_notify (PhoshNotifyDBusNotifications *skeleton,
} else {
PhoshDBusNotification *dbus_notification;
- id = phosh_notify_manager_get_notification_id (self);
+ if (info)
+ phosh_notify_manager_add_application (self, info);
+ id = phosh_notify_manager_get_notification_id (self);
dbus_notification = phosh_dbus_notification_new (id,
app_name,
info,
@@ -460,6 +495,19 @@ on_notifications_setting_changed (PhoshNotifyManager *self,
}
+static void
+on_notification_apps_setting_changed (PhoshNotifyManager *self,
+ const char *key,
+ GSettings *settings)
+{
+ g_return_if_fail (PHOSH_IS_NOTIFY_MANAGER (self));
+ g_return_if_fail (G_IS_SETTINGS (settings));
+
+ g_strfreev (self->app_children);
+ self->app_children = g_settings_get_strv (settings, NOTIFICATIONS_KEY_APP_CHILDREN);
+}
+
+
static void
on_name_acquired (GDBusConnection *connection,
const char *name,
@@ -508,6 +556,18 @@ phosh_notify_manager_dispose (GObject *object)
}
+static void
+phosh_notify_manager_finalize (GObject *object)
+{
+ PhoshNotifyManager *self = PHOSH_NOTIFY_MANAGER (object);
+
+ g_strfreev (self->app_children);
+
+ G_OBJECT_CLASS (phosh_notify_manager_parent_class)->finalize (object);
+}
+
+
+
static void
phosh_notify_manager_constructed (GObject *object)
{
@@ -528,6 +588,10 @@ phosh_notify_manager_constructed (GObject *object)
g_signal_connect_swapped (self->settings, "changed::" NOTIFICATIONS_KEY_SHOW_BANNERS,
G_CALLBACK (on_notifications_setting_changed), self);
on_notifications_setting_changed (self, NULL, self->settings);
+
+ g_signal_connect_swapped (self->settings, "changed::" NOTIFICATIONS_KEY_APP_CHILDREN,
+ G_CALLBACK (on_notification_apps_setting_changed), self);
+ on_notification_apps_setting_changed (self, NULL, self->settings);
}
@@ -538,7 +602,7 @@ phosh_notify_manager_class_init (PhoshNotifyManagerClass *klass)
object_class->constructed = phosh_notify_manager_constructed;
object_class->dispose = phosh_notify_manager_dispose;
-
+ object_class->finalize = phosh_notify_manager_finalize;
/**
* PhoshNotifyManager::new-notification:
--
2.26.2
From e86ce9f9706c3824c1ae3f3cd42c68f6306eacf6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 8 Dec 2020 18:54:22 +0100
Subject: [PATCH 4/4] shell: Only show banners for apps with show-banners
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/shell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shell.c b/src/shell.c
index 34833e6f..96152af9 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -417,7 +417,7 @@ on_new_notification (PhoshShell *self,
gtk_widget_destroy (priv->notification_banner);
}
- if (phosh_notify_manager_get_show_banners (manager) &&
+ if (phosh_notify_manager_get_show_notification_banner (manager, notification) &&
!phosh_lockscreen_manager_get_locked (priv->lockscreen_manager) &&
phosh_panel_get_state (PHOSH_PANEL (priv->panel)) == PHOSH_PANEL_STATE_FOLDED) {
g_set_weak_pointer (&priv->notification_banner,
--
2.26.2

View File

@ -0,0 +1,376 @@
From 88af8783a80be0871c8050a49e173d65727f2533 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 5 Mar 2021 11:30:41 +0100
Subject: [PATCH 1/5] wwan-iface: Add 'enabled' property
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This indicates if the modem is enabled.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/wwan/phosh-wwan-iface.c | 21 +++++++++++++++++++++
src/wwan/phosh-wwan-iface.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/src/wwan/phosh-wwan-iface.c b/src/wwan/phosh-wwan-iface.c
index b2ee12d8..1fd96e6a 100644
--- a/src/wwan/phosh-wwan-iface.c
+++ b/src/wwan/phosh-wwan-iface.c
@@ -64,6 +64,14 @@ phosh_wwan_default_init (PhoshWWanInterface *iface)
FALSE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_boolean ("enabled",
+ "Modem enabled",
+ "Whether there modem is enabled",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
+
g_object_interface_install_property (
iface,
g_param_spec_string ("operator",
@@ -140,6 +148,19 @@ phosh_wwan_is_present (PhoshWWan *self)
}
+gboolean
+phosh_wwan_is_enabled (PhoshWWan *self)
+{
+ PhoshWWanInterface *iface;
+
+ g_return_val_if_fail (PHOSH_IS_WWAN (self), FALSE);
+
+ iface = PHOSH_WWAN_GET_IFACE (self);
+ g_return_val_if_fail (iface->is_enabled != NULL, FALSE);
+ return iface->is_enabled (self);
+}
+
+
const char *
phosh_wwan_get_operator (PhoshWWan *self)
{
diff --git a/src/wwan/phosh-wwan-iface.h b/src/wwan/phosh-wwan-iface.h
index eae9f55c..1e5fd201 100644
--- a/src/wwan/phosh-wwan-iface.h
+++ b/src/wwan/phosh-wwan-iface.h
@@ -20,6 +20,7 @@ G_DECLARE_INTERFACE (PhoshWWan, phosh_wwan, PHOSH, WWAN, GObject)
* @is_unlocked: whether the SIM in the modem is locked
* @has_sim: Whether there's a sim in the modem
* @is_present: whether a modem is present at all
+ * @is_enabled: whether a modem is enabled
* @get_operator: Get the current network operator name
*
* Provides an interface for interacting with a modem
@@ -34,6 +35,7 @@ struct _PhoshWWanInterface
gboolean (*is_unlocked) (PhoshWWan *self);
gboolean (*has_sim) (PhoshWWan *self);
gboolean (*is_present) (PhoshWWan *self);
+ gboolean (*is_enabled) (PhoshWWan *self);
const char* (*get_operator) (PhoshWWan *self);
};
@@ -42,4 +44,5 @@ const char* phosh_wwan_get_access_tec (PhoshWWan* self);
gboolean phosh_wwan_is_unlocked (PhoshWWan* self);
gboolean phosh_wwan_has_sim (PhoshWWan* self);
gboolean phosh_wwan_is_present (PhoshWWan* self);
+gboolean phosh_wwan_is_enabled (PhoshWWan *self);
const char *phosh_wwan_get_operator (PhoshWWan *self);
--
2.26.2
From fb5a00e994fb2103193a7dff26788efde9e3096d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 5 Mar 2021 11:31:08 +0100
Subject: [PATCH 2/5] wwan-mm: Complete PhoshMMModemState
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This matches MMModemState
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/wwan/phosh-wwan-mm.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/wwan/phosh-wwan-mm.c b/src/wwan/phosh-wwan-mm.c
index a5589419..ca0b1c45 100644
--- a/src/wwan/phosh-wwan-mm.c
+++ b/src/wwan/phosh-wwan-mm.c
@@ -55,7 +55,15 @@ typedef enum { /*< underscore_name=mm_modem_state >*/
MM_MODEM_STATE_UNKNOWN = 0,
MM_MODEM_STATE_INITIALIZING = 1,
MM_MODEM_STATE_LOCKED = 2,
- /* ... */
+ MM_MODEM_STATE_DISABLED = 3,
+ MM_MODEM_STATE_DISABLING = 4,
+ MM_MODEM_STATE_ENABLING = 5,
+ MM_MODEM_STATE_ENABLED = 6,
+ MM_MODEM_STATE_SEARCHING = 7,
+ MM_MODEM_STATE_REGISTERED = 8,
+ MM_MODEM_STATE_DISCONNECTING = 9,
+ MM_MODEM_STATE_CONNECTING = 10,
+ MM_MODEM_STATE_CONNECTED = 11,
} PhoshMMModemState;
enum {
--
2.26.2
From 1a75bcb4806897c1995dc2eebe599d3e8f1dba78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 5 Mar 2021 11:32:45 +0100
Subject: [PATCH 3/5] wwan-mm: Handle 'enabled' property
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/wwan/phosh-wwan-mm.c | 43 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/wwan/phosh-wwan-mm.c b/src/wwan/phosh-wwan-mm.c
index ca0b1c45..ec52e838 100644
--- a/src/wwan/phosh-wwan-mm.c
+++ b/src/wwan/phosh-wwan-mm.c
@@ -73,6 +73,7 @@ enum {
PHOSH_WWAN_MM_PROP_UNLOCKED,
PHOSH_WWAN_MM_PROP_SIM,
PHOSH_WWAN_MM_PROP_PRESENT,
+ PHOSH_WWAN_MM_PROP_ENABLED,
PHOSH_WWAN_MM_PROP_OPERATOR,
PHOSH_WWAN_MM_PROP_LAST_PROP,
};
@@ -96,6 +97,7 @@ typedef struct _PhoshWWanMM {
gboolean unlocked;
gboolean sim;
gboolean present;
+ gboolean enabled;
char *operator;
} PhoshWWanMM;
@@ -236,6 +238,25 @@ phosh_wwan_mm_update_present (PhoshWWanMM *self, gboolean present)
}
+static void
+phosh_wwan_mm_update_enabled (PhoshWWanMM *self)
+{
+ PhoshMMModemState state;
+ gboolean enabled;
+
+ g_return_if_fail (self);
+
+ state = phosh_mm_dbus_modem_get_state (self->proxy);
+
+ enabled = (state > MM_MODEM_STATE_ENABLING) ? TRUE : FALSE;
+ g_debug ("Modem is %senabled, state: %d", enabled ? "" : "not ", state);
+ if (self->enabled != enabled) {
+ self->enabled = enabled;
+ g_object_notify (G_OBJECT (self), "enabled");
+ }
+}
+
+
static void
phosh_wwan_mm_dbus_props_changed_cb (PhoshMMDBusModem *proxy,
GVariant *changed_properties,
@@ -256,6 +277,7 @@ phosh_wwan_mm_dbus_props_changed_cb (PhoshMMDBusModem *proxy,
phosh_wwan_mm_update_lock_status (self);
} else if (g_strcmp0 (property, "State") == 0) {
phosh_wwan_mm_update_lock_status (self);
+ phosh_wwan_mm_update_enabled (self);
} else if (g_strcmp0 (property, "Sim") == 0) {
phosh_wwan_mm_update_sim_status (self);
}
@@ -330,6 +352,9 @@ phosh_wwan_mm_destroy_modem (PhoshWWanMM *self)
phosh_wwan_mm_update_present (self, FALSE);
+ self->enabled = FALSE;
+ g_object_notify (G_OBJECT (self), "enabled");
+
self->signal_quality = 0;
g_object_notify (G_OBJECT (self), "signal-quality");
@@ -397,6 +422,7 @@ phosh_wwan_mm_on_proxy_new_for_bus_finish (GObject *source_object,
phosh_wwan_mm_update_lock_status (self);
phosh_wwan_mm_update_sim_status (self);
phosh_wwan_mm_update_present (self, TRUE);
+ phosh_wwan_mm_update_enabled (self);
g_object_unref (self);
}
@@ -566,6 +592,9 @@ phosh_wwan_mm_class_init (PhoshWWanMMClass *klass)
g_object_class_override_property (object_class,
PHOSH_WWAN_MM_PROP_PRESENT,
"present");
+ g_object_class_override_property (object_class,
+ PHOSH_WWAN_MM_PROP_ENABLED,
+ "enabled");
g_object_class_override_property (object_class,
PHOSH_WWAN_MM_PROP_OPERATOR,
"operator");
@@ -637,6 +666,19 @@ phosh_wwan_mm_is_present (PhoshWWan *phosh_wwan)
}
+static gboolean
+phosh_wwan_mm_is_enabled (PhoshWWan *phosh_wwan)
+{
+ PhoshWWanMM *self;
+
+ g_return_val_if_fail (PHOSH_IS_WWAN_MM (phosh_wwan), FALSE);
+
+ self = PHOSH_WWAN_MM (phosh_wwan);
+
+ return self->enabled;
+}
+
+
static const char *
phosh_wwan_mm_get_operator (PhoshWWan *phosh_wwan)
{
@@ -658,6 +700,7 @@ phosh_wwan_mm_interface_init (PhoshWWanInterface *iface)
iface->is_unlocked = phosh_wwan_mm_is_unlocked;
iface->has_sim = phosh_wwan_mm_has_sim;
iface->is_present = phosh_wwan_mm_is_present;
+ iface->is_enabled = phosh_wwan_mm_is_enabled;
iface->get_operator = phosh_wwan_mm_get_operator;
}
--
2.26.2
From ecc3a8bff11b92f7a3608cf33913a4809533b851 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 5 Mar 2021 11:33:04 +0100
Subject: [PATCH 4/5] wwan-ofono: Handle enabled property
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We always return TRUE here to not break existing users.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/wwan/phosh-wwan-ofono.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/wwan/phosh-wwan-ofono.c b/src/wwan/phosh-wwan-ofono.c
index 923d73aa..547590f8 100644
--- a/src/wwan/phosh-wwan-ofono.c
+++ b/src/wwan/phosh-wwan-ofono.c
@@ -30,6 +30,7 @@ enum {
PHOSH_WWAN_OFONO_PROP_UNLOCKED,
PHOSH_WWAN_OFONO_PROP_SIM,
PHOSH_WWAN_OFONO_PROP_PRESENT,
+ PHOSH_WWAN_OFONO_PROP_ENABLED,
PHOSH_WWAN_OFONO_PROP_OPERATOR,
PHOSH_WWAN_OFONO_PROP_LAST_PROP,
};
@@ -622,6 +623,9 @@ phosh_wwan_ofono_class_init (PhoshWWanOfonoClass *klass)
g_object_class_override_property (object_class,
PHOSH_WWAN_OFONO_PROP_PRESENT,
"present");
+ g_object_class_override_property (object_class,
+ PHOSH_WWAN_OFONO_PROP_ENABLED,
+ "enabled");
g_object_class_override_property (object_class,
PHOSH_WWAN_OFONO_PROP_OPERATOR,
"operator");
@@ -693,6 +697,15 @@ phosh_wwan_ofono_is_present (PhoshWWan *phosh_wwan)
}
+static gboolean
+phosh_wwan_ofono_is_enabled (PhoshWWan *phosh_wwan)
+{
+ g_return_val_if_fail (PHOSH_IS_WWAN_OFONO (phosh_wwan), FALSE);
+
+ return TRUE;
+}
+
+
static const char *
phosh_wwan_ofono_get_operator (PhoshWWan *phosh_wwan)
{
@@ -714,6 +727,7 @@ phosh_wwan_ofono_interface_init (PhoshWWanInterface *iface)
iface->is_unlocked = phosh_wwan_ofono_is_unlocked;
iface->has_sim = phosh_wwan_ofono_has_sim;
iface->is_present = phosh_wwan_ofono_is_present;
+ iface->is_enabled = phosh_wwan_ofono_is_enabled;
iface->get_operator = phosh_wwan_ofono_get_operator;
}
--
2.26.2
From 8a56699ceb46e06c94061d5988c0968817ba0058 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 5 Mar 2021 11:33:36 +0100
Subject: [PATCH 5/5] wwaninfo: Correctly indicate disabled state
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
So far we used the signal-strength 0 icon which is confusing.
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
src/wwaninfo.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/wwaninfo.c b/src/wwaninfo.c
index 1abe4d2a..d473af18 100644
--- a/src/wwaninfo.c
+++ b/src/wwaninfo.c
@@ -110,7 +110,7 @@ update_icon_data(PhoshWWanInfo *self, GParamSpec *psepc, PhoshWWan *wwan)
guint quality;
const char *icon_name = NULL;
const char *access_tec;
- gboolean present;
+ gboolean present, enabled;
g_return_if_fail (PHOSH_IS_WWAN_INFO (self));
present = phosh_wwan_is_present (self->wwan);
@@ -122,13 +122,15 @@ update_icon_data(PhoshWWanInfo *self, GParamSpec *psepc, PhoshWWan *wwan)
access_tec_widget = phosh_status_icon_get_extra_widget (PHOSH_STATUS_ICON (self));
+ enabled = phosh_wwan_is_enabled (self->wwan);
if (!present) {
- icon_name = ("network-cellular-disabled-symbolic");
- } else if (!phosh_wwan_has_sim (self->wwan)) /* SIM missing */
+ icon_name = "network-cellular-disabled-symbolic";
+ } else if (!phosh_wwan_has_sim (self->wwan)) {
icon_name = "auth-sim-missing-symbolic";
- else { /* SIM unlock required */
- if (!phosh_wwan_is_unlocked (self->wwan))
+ } else if (!phosh_wwan_is_unlocked (self->wwan)) {
icon_name = "auth-sim-locked-symbolic";
+ } else if (!enabled) {
+ icon_name = "network-cellular-disabled-symbolic";
}
if (icon_name) {
@@ -191,6 +193,7 @@ phosh_wwan_info_constructed (GObject *object)
"notify::unlocked",
"notify::sim",
"notify::present",
+ "notify::enabled",
NULL,
};
--
2.26.2

View File

@ -0,0 +1,39 @@
From 41867cdcb20661ae11ac7f85eb367685978fcf59 Mon Sep 17 00:00:00 2001
From: Mohammed Sadiq <sadiq@sadiqpk.org>
Date: Wed, 28 Apr 2021 12:30:49 +0530
Subject: [PATCH] top-panel: Update power button and popover styles to match
design
---
src/ui/top-panel.ui | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/ui/top-panel.ui b/src/ui/top-panel.ui
index 5dd7ca7a..9135b053 100644
--- a/src/ui/top-panel.ui
+++ b/src/ui/top-panel.ui
@@ -3,6 +3,9 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopoverMenu" id="menu_power">
+ <style>
+ <class name="osd"/>
+ </style>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@@ -260,8 +263,11 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">menu_power</property>
+ <property name="width-request">32</property>
+ <property name="height-request">32</property>
<style>
<class name="phosh-power-button"/>
+ <class name="circular"/>
</style>
<child>
<object class="GtkImage">
--
GitLab

View File

@ -0,0 +1,234 @@
diff -Npur phosh.orig/src/flashlightinfo.c phosh/src/flashlightinfo.c
--- phosh.orig/src/flashlightinfo.c 1970-01-01 01:00:00.000000000 +0100
+++ phosh/src/flashlightinfo.c 2020-10-18 18:07:27.590688070 +0200
@@ -0,0 +1,86 @@
+/*
+ * Author: clover <m.alexanderrobinson@yahoo.com>
+ */
+
+#define G_LOG_DOMAIN "phosh-flashlightinfo"
+
+#include "config.h"
+
+#include "flashlightinfo.h"
+#include "shell.h"
+#include <fcntl.h>
+
+#define FLASH_SYSFS_PATH "/sys/devices/platform/led-controller/leds/white:flash/brightness"
+
+/**
+ * SECTION:flashlightinfo
+ * @short_description: A widget to display the flashlight status
+ * @Title: PhoshFlashlightInfo
+ *
+ * Flashlight Info widget
+ */
+
+ typedef struct _PhoshFlashlightInfo {
+ PhoshStatusIcon parent;
+} PhoshFlashlightInfo;
+
+int flashlight_status;
+G_DEFINE_TYPE (PhoshFlashlightInfo, phosh_flashlight_info, PHOSH_TYPE_STATUS_ICON)
+
+static void
+toggle_flashlight(int status)
+{
+ int fd = open(FLASH_SYSFS_PATH, O_WRONLY);
+ if (fd < 0)
+ {
+ // Unable to open file
+ return;
+ }
+ write(fd, status ? "1" : "0", 1);
+}
+
+void
+set_flashlight_status(int new_status)
+{
+ toggle_flashlight(new_status);
+ flashlight_status = new_status;
+}
+
+int
+get_flashlight_status(void)
+{
+ return flashlight_status;
+}
+
+
+static void
+phosh_flashlight_info_finalize (GObject *object)
+{
+ PhoshFlashlightInfo *self = PHOSH_FLASHLIGHT_INFO(object);
+
+ // possibly can remove
+ g_signal_handlers_disconnect_by_data (phosh_shell_get_default (), self);
+
+ G_OBJECT_CLASS (phosh_flashlight_info_parent_class)->finalize (object);
+}
+
+static void
+phosh_flashlight_info_class_init (PhoshFlashlightInfoClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = phosh_flashlight_info_finalize;
+}
+
+static void
+phosh_flashlight_info_init (PhoshFlashlightInfo *self)
+{
+ phosh_status_icon_set_icon_name (PHOSH_STATUS_ICON (self), "torch-disabled-symbolic");
+ phosh_status_icon_set_info (PHOSH_STATUS_ICON (self), "Off");
+ set_flashlight_status(0);
+}
+
+GtkWidget *
+phosh_flashlight_info_new (void)
+{
+ return g_object_new (PHOSH_TYPE_FLASHLIGHT_INFO, NULL);
+}
\ No newline at end of file
diff -Npur phosh.orig/src/flashlightinfo.h phosh/src/flashlightinfo.h
--- phosh.orig/src/flashlightinfo.h 1970-01-01 01:00:00.000000000 +0100
+++ phosh/src/flashlightinfo.h 2020-10-18 18:07:12.934021548 +0200
@@ -0,0 +1,20 @@
+/*
+ *
+ * SPDX-License-Identifier: GPL-3.0+
+ */
+#pragma once
+
+#include <gtk/gtk.h>
+#include "status-icon.h"
+
+G_BEGIN_DECLS
+
+#define PHOSH_TYPE_FLASHLIGHT_INFO (phosh_flashlight_info_get_type())
+
+G_DECLARE_FINAL_TYPE (PhoshFlashlightInfo, phosh_flashlight_info, PHOSH, FLASHLIGHT_INFO, PhoshStatusIcon)
+
+GtkWidget * phosh_flashlight_info_new (void);
+void set_flashlight_status (int);
+int get_flashlight_status (void);
+
+G_END_DECLS
\ No newline at end of file
diff -Npur phosh.orig/src/meson.build phosh/src/meson.build
--- phosh.orig/src/meson.build 2020-10-18 18:06:42.687355000 +0200
+++ phosh/src/meson.build 2020-10-18 18:07:18.194021496 +0200
@@ -126,6 +126,8 @@ libphosh_sources = [
'proximity.c',
'sensor-proxy-manager.c',
'sensor-proxy-manager.h',
+ 'flashlightinfo.c',
+ 'flashlightinfo.h',
'rotateinfo.c',
'rotateinfo.h',
'screen-saver-manager.c',
diff -Npur phosh.orig/src/settings.c phosh/src/settings.c
--- phosh.orig/src/settings.c 2020-10-18 18:06:42.690688000 +0200
+++ phosh/src/settings.c 2020-10-18 18:07:23.400688118 +0200
@@ -23,10 +23,12 @@
#include "rotateinfo.h"
#include "feedbackinfo.h"
#include "feedback-manager.h"
+#include "flashlightinfo.h"
#include "notifications/notify-manager.h"
#include "notifications/notification-frame.h"
#include "media-player.h"
#include "keyboard-events.h"
+#include <stdbool.h>
#include <pulse/pulseaudio.h>
#include "gvc-mixer-control.h"
@@ -72,6 +74,9 @@ typedef struct _PhoshSettings
GtkWidget *list_notifications;
GtkWidget *sw_notifications;
LfbEvent *notify_event;
+
+ /* Flashlight */
+ GtkWidget *flashlightinfo;
} PhoshSettings;
@@ -123,6 +128,26 @@ feedback_setting_clicked_cb (PhoshSettin
}
static void
+flashlight_setting_clicked_cb (PhoshSettings *self)
+{
+ bool currently_on = get_flashlight_status() == 1;
+ bool currently_off = get_flashlight_status() == 0;
+
+ if (currently_on)
+ {
+ phosh_status_icon_set_icon_name(PHOSH_STATUS_ICON (self->flashlightinfo), "torch-disabled-symbolic");
+ phosh_status_icon_set_info (PHOSH_STATUS_ICON (self->flashlightinfo), "Off");
+ set_flashlight_status(0);
+ }
+ if (currently_off)
+ {
+ phosh_status_icon_set_icon_name(PHOSH_STATUS_ICON (self->flashlightinfo), "torch-enabled-symbolic");
+ phosh_status_icon_set_info (PHOSH_STATUS_ICON (self->flashlightinfo), "On");
+ set_flashlight_status(1);
+ }
+}
+
+static void
wifi_setting_clicked_cb (PhoshSettings *self)
{
phosh_quick_setting_open_settings_panel ("wifi");
@@ -499,7 +524,6 @@ phosh_settings_finalize (GObject *object
}
-
static void
phosh_settings_class_init (PhoshSettingsClass *klass)
{
@@ -520,6 +544,7 @@ phosh_settings_class_init (PhoshSettings
g_type_ensure (PHOSH_TYPE_BT_INFO);
g_type_ensure (PHOSH_TYPE_DOCKED_INFO);
g_type_ensure (PHOSH_TYPE_FEEDBACK_INFO);
+ g_type_ensure (PHOSH_TYPE_FLASHLIGHT_INFO);
g_type_ensure (PHOSH_TYPE_MEDIA_PLAYER);
g_type_ensure (PHOSH_TYPE_QUICK_SETTING);
g_type_ensure (PHOSH_TYPE_ROTATE_INFO);
@@ -530,6 +555,7 @@ phosh_settings_class_init (PhoshSettings
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, quick_settings);
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, scale_brightness);
gtk_widget_class_bind_template_child (widget_class, PhoshSettings, sw_notifications);
+ gtk_widget_class_bind_template_child (widget_class, PhoshSettings, flashlightinfo);
gtk_widget_class_bind_template_callback (widget_class, battery_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, bt_setting_clicked_cb);
@@ -538,6 +564,7 @@ phosh_settings_class_init (PhoshSettings
gtk_widget_class_bind_template_callback (widget_class, feedback_setting_long_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_media_player_raised);
gtk_widget_class_bind_template_callback (widget_class, rotation_setting_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, flashlight_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, torch_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb);
diff -Npur phosh.orig/src/ui/settings-menu.ui phosh/src/ui/settings-menu.ui
--- phosh.orig/src/ui/settings-menu.ui 2020-10-18 18:06:42.700688000 +0200
+++ phosh/src/ui/settings-menu.ui 2020-10-18 18:07:23.400688118 +0200
@@ -120,13 +120,13 @@
</object>
</child>
<child>
- <object class="PhoshQuickSetting" id="torch_quick_setting">
+ <object class="PhoshQuickSetting">
<property name="visible">True</property>
- <property name="sensitive" bind-source="torchinfo" bind-property="present" bind-flags="sync-create"/>
<property name="can_focus">False</property>
- <signal name="clicked" handler="torch_setting_clicked_cb" object="PhoshSettings" swapped="yes"/>
+ <signal name="clicked" handler="flashlight_setting_clicked_cb" object="PhoshSettings" swapped="yes"/>
+
<child>
- <object class="PhoshTorchInfo" id="torchinfo">
+ <object class="PhoshFlashlightInfo" id="flashlightinfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon-size">GTK_ICON_SIZE_LARGE_TOOLBAR</property>

View File

@ -0,0 +1,5 @@
#%PAM-1.0
auth include system-local-login
account include system-local-login
session include system-local-login

View File

@ -0,0 +1,52 @@
[Unit]
Description=Phosh, a shell for mobile phones
Documentation=https://source.puri.sm/Librem5/phosh
# Make sure we are started after logins are permitted.
After=systemd-user-sessions.service
# If Plymouth is used, we want to start when it is on its way out.
After=plymouth-quit-wait.service
# D-Bus is necessary for contacting logind. Logind is required.
Wants=dbus.socket
After=dbus.socket
# This scope is created by pam_systemd when logging in as the user.
# This directive is a workaround to a systemd bug, where the setup of the
# user session by PAM has some race condition, possibly leading to a failure.
# See README for more details.
After=session-c1.scope
# Since we are part of the graphical session, make sure we are started before
# it is complete.
Before=graphical.target
# Prevent starting on systems without virtual consoles
ConditionPathExists=/dev/tty0
[Service]
ExecStart=/usr/bin/phosh
TimeoutStartSec=30
User=1000
PAMName=login
WorkingDirectory=~
Restart=on-failure
RestartSec=5s
# A virtual terminal is needed.
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
# Fail to start if not controlling the tty.
StandardInput=tty-fail
StandardOutput=journal
StandardError=journal
# Log this user with utmp, letting it show up with commands 'w' and 'who'.
UtmpIdentifier=tty7
UtmpMode=user
[Install]
WantedBy=graphical.target

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Name=On-screen keyboard
Comment=Default on-screen keyboard
Exec=/usr/bin/osk-wayland
Categories=GNOME;Core;
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-Autostart-Phase=Panel
X-GNOME-Provides=inputmethod
X-GNOME-Autostart-Notify=true
X-GNOME-AutoRestart=true

View File

@ -0,0 +1,79 @@
# Copyright 2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit pam vala meson git-r3 gnome2-utils systemd readme.gentoo-r1 xdg
KEYWORDS="~amd64 ~arm64"
EGIT_REPO_URI="https://source.puri.sm/Librem5/phosh.git"
if [[ ${PV} != 9999 ]]; then
#EGIT_COMMIT="tags/v${PV}"
EGIT_COMMIT="2ca82ddbe6d08524d9153be7275db983c78a1053"
else
KEYWORDS=""
fi
EGIT_SUBMODULES=("subprojects/gvc")
DESCRIPTION="A pure Wayland shell prototype for GNOME on mobile devices"
HOMEPAGE="https://source.puri.sm/Librem5/phosh"
LICENSE="GPL-3"
SLOT="0"
DEPEND="
app-crypt/gcr
dev-libs/feedbackd
media-sound/pulseaudio
>=gui-libs/libhandy-1.1.90
net-misc/networkmanager
gnome-base/gnome-desktop
gnome-base/gnome-session
x11-themes/gnome-backgrounds
x11-wm/phoc
sys-apps/systemd
sys-power/upower
"
RDEPEND="${DEPEND}"
BDEPEND="
dev-util/ctags
dev-util/meson
"
PATCHES=(
${FILESDIR}/0001-system-prompt-allow-blank-passwords.patch
${FILESDIR}/0002-fix-locale-issue.patch
${FILESDIR}/0003-fix-locale-issue-in-service-file.patch
${FILESDIR}/777.patch
)
src_prepare() {
default
eapply_user
}
src_install() {
default
meson_src_install
newpamd "${FILESDIR}"/pam_phosh 'phosh'
systemd_newunit "${FILESDIR}"/phosh.service 'phosh.service'
insinto /usr/share/applications/
doins "${FILESDIR}"/sm.puri.OSK0.desktop
DOC_CONTENTS="To amend the existing password policy please see the man 5 passwdqc.conf
page and then edit the /etc/security/passwdqc.conf file to change enforce=none
to allow use digit only password as phosh only support passcode for now"
readme.gentoo_create_doc
}
pkg_postinst() {
xdg_pkg_postinst
gnome2_schemas_update
readme.gentoo_print_elog
}
pkg_postrm() {
xdg_pkg_postrm
gnome2_schemas_update
}