Commit 285fb0c0 authored by Guido Gunther's avatar Guido Gunther
Browse files

Add home button

Just the button to spawn the favorites. Favorites, top anel rework will
be done separately (See #24, #29)

Closes: #27
parent 14e8f175
Pipeline #396 passed with stages
in 16 minutes and 2 seconds
/*
* 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", "home",
NULL);
}
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0+
*/
#pragma once
#include <gtk/gtk.h>
#include "layersurface.h"
#define PHOSH_TYPE_HOME (phosh_home_get_type())
#define PHOSH_HOME_HEIGHT 40
G_DECLARE_FINAL_TYPE (PhoshHome, phosh_home, PHOSH, HOME, PhoshLayerSurface)
GtkWidget * phosh_home_new (struct zwlr_layer_shell_v1 *layer_shell,
struct wl_output *wl_output);
......@@ -43,6 +43,8 @@ phosh_sources = [
'batteryinfo.h',
'favorites.c',
'favorites.h',
'home.c',
'home.h',
'layersurface.c',
'layersurface.h',
'lockscreen.c',
......
......@@ -28,6 +28,7 @@
#include "lockscreen-manager.h"
#include "monitor-manager.h"
#include "panel.h"
#include "home.h"
#include "favorites.h"
#include "settings.h"
......@@ -52,6 +53,7 @@ typedef struct
gint rotation;
PhoshLayerSurface *panel;
PhoshLayerSurface *home;
PhoshLayerSurface *background;
struct popup *favorites;
struct popup *settings;
......@@ -323,7 +325,7 @@ phosh_shell_set_locked (PhoshShell *self, gboolean state)
static void
panel_create (PhoshShell *self)
panels_create (PhoshShell *self)
{
PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
PhoshMonitor *monitor;
......@@ -334,6 +336,8 @@ panel_create (PhoshShell *self)
priv->panel = PHOSH_LAYER_SURFACE(phosh_panel_new (phosh_wayland_get_zwlr_layer_shell_v1(wl),
monitor->wl_output));
priv->home = PHOSH_LAYER_SURFACE(phosh_home_new (phosh_wayland_get_zwlr_layer_shell_v1(wl),
monitor->wl_output));
g_signal_connect_swapped (
priv->panel,
"favorites-activated",
......@@ -345,8 +349,14 @@ panel_create (PhoshShell *self)
"settings-activated",
G_CALLBACK(settings_activated_cb),
self);
}
g_signal_connect_swapped (
priv->home,
"home-activated",
G_CALLBACK(favorites_activated_cb),
self);
}
static void
......@@ -484,7 +494,7 @@ phosh_shell_constructed (GObject *object)
"/sm/puri/phosh/icons");
env_setup ();
css_setup (self);
panel_create (self);
panels_create (self);
/* Create background after panel since it needs the panel's size */
background_create (self);
priv->lockscreen_manager = phosh_lockscreen_manager_new ();
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/sm/puri/phosh">
<file preprocess="xml-stripblanks">ui/home.ui</file>
<file preprocess="xml-stripblanks">ui/lockscreen.ui</file>
<file preprocess="xml-stripblanks">ui/settings-menu.ui</file>
<file preprocess="xml-stripblanks">ui/top-panel.ui</file>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-up-symbolic</property>
</object>
<template class="PhoshHome" parent="PhoshLayerSurface">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_homogeneous">True</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkButton" id="btn_home">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image1</property>
<property name="image_position">top</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment