Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (C) 2018 Purism SPC
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*/
#define G_LOG_DOMAIN "phosh-home"
#include "config.h"
#include "home.h"
/**
* SECTION:phosh-home
* @short_description: The ome button at the bottom of the screen
* @Title: PhoshHome
*
* The #PhoshHome is displayed at the bottom of the screen.
*/
enum {
HOME_ACTIVATED,
N_SIGNALS
};
static guint signals[N_SIGNALS] = { 0 };
typedef struct
{
GtkWidget *btn_home;
} PhoshHomePrivate;
struct _PhoshHome
{
PhoshLayerSurface parent;
};
G_DEFINE_TYPE_WITH_PRIVATE(PhoshHome, phosh_home, PHOSH_TYPE_LAYER_SURFACE)
static void
home_clicked_cb (PhoshHome *self, GtkButton *btn)
{
g_return_if_fail (PHOSH_IS_HOME (self));
g_return_if_fail (GTK_IS_BUTTON (btn));
g_signal_emit(self, signals[HOME_ACTIVATED], 0);
}
static void
phosh_home_constructed (GObject *object)
{
PhoshHome *self = PHOSH_HOME (object);
PhoshHomePrivate *priv = phosh_home_get_instance_private (self);
g_signal_connect_object (priv->btn_home,
"clicked",
G_CALLBACK (home_clicked_cb),
self,
G_CONNECT_SWAPPED);
G_OBJECT_CLASS (phosh_home_parent_class)->constructed (object);
}
static void
phosh_home_class_init (PhoshHomeClass *klass)
{
GObjectClass *object_class = (GObjectClass *)klass;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = phosh_home_constructed;
signals[HOME_ACTIVATED] = g_signal_new ("home-activated",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
NULL, G_TYPE_NONE, 0);
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/phosh/ui/home.ui");
gtk_widget_class_bind_template_child_private (widget_class, PhoshHome, btn_home);
}
static void
phosh_home_init (PhoshHome *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget *
phosh_home_new (struct zwlr_layer_shell_v1 *layer_shell,
struct wl_output *wl_output)
{
return g_object_new (PHOSH_TYPE_HOME,
"layer-shell", layer_shell,
"wl-output", wl_output,
"height", PHOSH_HOME_HEIGHT,
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
"layer", ZWLR_LAYER_SHELL_V1_LAYER_TOP,
"kbd-interactivity", FALSE,
"exclusive-zone", PHOSH_HOME_HEIGHT,
"namespace", "phosh home",