gjdwebserver-overlay/gui-wm/phosh/files/822.patch
Gerben Jan Dijkman cdac3cd7f0 Added phosh
2021-06-17 15:02:06 +02:00

366 lines
11 KiB
Diff

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