Commit bc2198f6 authored by Guido Gunther's avatar Guido Gunther
Browse files

PhoshHome: Show favorites on home screen



Instead of making PhoshFavorites a separate layer surface popup show the
widget on the home screen by deriving from GtkBox instead of GtkWindow.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent d414ada3
......@@ -49,10 +49,10 @@ typedef struct
struct _PhoshFavorites
{
GtkWindowClass parent;
GtkBoxClass parent;
};
G_DEFINE_TYPE_WITH_PRIVATE(PhoshFavorites, phosh_favorites, GTK_TYPE_WINDOW)
G_DEFINE_TYPE_WITH_PRIVATE(PhoshFavorites, phosh_favorites, GTK_TYPE_BOX)
static void
......@@ -278,17 +278,9 @@ phosh_favorites_constructed (GObject *object)
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
PhoshToplevelManager *toplevel_manager =
phosh_shell_get_toplevel_manager (phosh_shell_get_default ());
gint width, height;
G_OBJECT_CLASS (phosh_favorites_parent_class)->constructed (object);
/* window properties */
phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL, &width, &height);
gtk_window_set_title (GTK_WINDOW (self), "phosh favorites");
gtk_window_set_decorated (GTK_WINDOW (self), FALSE);
gtk_window_resize (GTK_WINDOW (self), width, height);
gtk_widget_realize(GTK_WIDGET (self));
/* Close on click */
g_signal_connect_swapped (priv->evbox_favorites, "button_press_event",
G_CALLBACK (evbox_button_press_event_cb),
......@@ -316,6 +308,7 @@ phosh_favorites_constructed (GObject *object)
"size-allocate",
G_CALLBACK (running_activities_resized),
self);
gtk_widget_show_all (GTK_WIDGET(self));
}
......
......@@ -10,6 +10,6 @@
#define PHOSH_TYPE_FAVORITES (phosh_favorites_get_type())
G_DECLARE_FINAL_TYPE (PhoshFavorites, phosh_favorites, PHOSH, FAVORITES, GtkWindow)
G_DECLARE_FINAL_TYPE (PhoshFavorites, phosh_favorites, PHOSH, FAVORITES, GtkBox)
GtkWidget * phosh_favorites_new (void);
......@@ -7,6 +7,7 @@
#define G_LOG_DOMAIN "phosh-home"
#include "config.h"
#include "favorites.h"
#include "home.h"
#include "shell.h"
#include "phosh-enums.h"
......@@ -42,6 +43,7 @@ struct _PhoshHome
GtkWidget *btn_home;
GtkWidget *btn_osk;
GtkWidget *favorites;
PhoshHomeState state;
};
......@@ -106,6 +108,17 @@ osk_clicked_cb (PhoshHome *self, GtkButton *btn)
}
static void
fold_cb (PhoshHome *self, PhoshFavorites *favorites)
{
g_return_if_fail (PHOSH_IS_HOME (self));
g_return_if_fail (PHOSH_IS_FAVORITES (favorites));
phosh_home_set_state (self, PHOSH_HOME_STATE_FOLDED);
}
static void
phosh_home_constructed (GObject *object)
{
......@@ -123,6 +136,19 @@ phosh_home_constructed (GObject *object)
self,
G_CONNECT_SWAPPED);
g_signal_connect_swapped (self->favorites,
"activity-launched",
G_CALLBACK(fold_cb),
self);
g_signal_connect_swapped (self->favorites,
"activity-raised",
G_CALLBACK(fold_cb),
self);
g_signal_connect_swapped (self->favorites,
"selection-aborted",
G_CALLBACK(fold_cb),
self);
G_OBJECT_CLASS (phosh_home_parent_class)->constructed (object);
}
......@@ -153,10 +179,12 @@ phosh_home_class_init (PhoshHomeClass *klass)
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
PHOSH_TYPE_OSK_BUTTON;
PHOSH_TYPE_FAVORITES;
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/phosh/ui/home.ui");
gtk_widget_class_bind_template_child (widget_class, PhoshHome, btn_home);
gtk_widget_class_bind_template_child (widget_class, PhoshHome, btn_osk);
gtk_widget_class_bind_template_child (widget_class, PhoshHome, favorites);
gtk_widget_class_set_css_name (widget_class, "phosh-home");
}
......@@ -197,6 +225,8 @@ phosh_home_new (struct zwlr_layer_shell_v1 *layer_shell,
void
phosh_home_set_state (PhoshHome *self, PhoshHomeState state)
{
int width, height;
g_return_if_fail (PHOSH_IS_HOME (self));
if (self->state == state)
......@@ -205,15 +235,14 @@ phosh_home_set_state (PhoshHome *self, PhoshHomeState state)
self->state = state;
g_debug ("Setting state to %s", g_enum_to_string (PHOSH_TYPE_HOME_STATE, state));
phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL, &width, &height);
/* We don't change the exclusive zone since we don't want to push all clients upward */
if (state == PHOSH_HOME_STATE_UNFOLDED) {
int height;
if (state == PHOSH_HOME_STATE_UNFOLDED)
height = PHOSH_HOME_BUTTON_HEIGHT + height;
else
height = PHOSH_HOME_BUTTON_HEIGHT;
phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL, NULL, &height);
phosh_layer_surface_set_size (PHOSH_LAYER_SURFACE (self), -1, PHOSH_HOME_BUTTON_HEIGHT + height);
} else {
phosh_layer_surface_set_size (PHOSH_LAYER_SURFACE (self), -1, PHOSH_HOME_BUTTON_HEIGHT);
}
phosh_layer_surface_set_size (PHOSH_LAYER_SURFACE (self), width, height);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HOME_STATE]);
}
......@@ -24,7 +24,6 @@
#include "batteryinfo.h"
#include "background-manager.h"
#include "favorites.h"
#include "home.h"
#include "idle-manager.h"
#include "lockscreen-manager.h"
......@@ -62,7 +61,6 @@ typedef struct
{
PhoshLayerSurface *panel;
PhoshLayerSurface *home;
struct popup *favorites;
struct popup *settings;
PhoshBackgroundManager *background_manager;
......@@ -94,11 +92,10 @@ get_popup_from_xdg_popup (PhoshShell *self, struct xdg_popup *xdg_popup)
g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
priv = phosh_shell_get_instance_private (self);
if (priv->favorites && xdg_popup == priv->favorites->popup) {
popup = &priv->favorites;
} else if (priv->settings && xdg_popup == priv->settings->popup) {
if (priv->settings && xdg_popup == priv->settings->popup)
popup = &priv->settings;
}
g_return_val_if_fail (popup, NULL);
return popup;
}
......@@ -117,17 +114,6 @@ close_menu (struct popup **popup)
}
static void
close_favorites_menu_cb (PhoshShell *self,
PhoshFavorites *favorites)
{
PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
g_return_if_fail (priv->favorites);
close_menu (&priv->favorites);
}
static void
xdg_surface_handle_configure(void *data,
struct xdg_surface *xdg_surface,
......@@ -171,74 +157,6 @@ static const struct xdg_popup_listener xdg_popup_listener = {
};
static void
home_activated_cb (PhoshShell *self,
PhoshPanel *window)
{
PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
GdkWindow *gdk_window;
struct popup *favorites;
struct xdg_surface *xdg_surface;
struct xdg_positioner *xdg_positioner;
gint width, height;
PhoshWayland *wl = phosh_wayland_get_default();
struct xdg_wm_base* xdg_wm_base = phosh_wayland_get_xdg_wm_base (wl);
struct zwlr_layer_surface_v1 *panel_surface;
close_menu (&priv->settings);
if (priv->favorites) {
close_menu (&priv->favorites);
return;
}
phosh_osk_manager_set_visible (priv->osk_manager, FALSE);
favorites = calloc (1, sizeof *favorites);
favorites->window = phosh_favorites_new ();
gdk_window = gtk_widget_get_window (favorites->window);
gdk_wayland_window_set_use_custom_surface (gdk_window);
favorites->wl_surface = gdk_wayland_window_get_wl_surface (gdk_window);
xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base, favorites->wl_surface);
g_return_if_fail (xdg_surface);
xdg_positioner = xdg_wm_base_create_positioner(xdg_wm_base);
gtk_window_get_size (GTK_WINDOW (favorites->window), &width, &height);
xdg_positioner_set_size(xdg_positioner, width, height);
xdg_positioner_set_offset(xdg_positioner, 0, PHOSH_PANEL_HEIGHT-1);
xdg_positioner_set_anchor_rect(xdg_positioner, 0, 0, 1, 1);
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_LEFT);
xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
favorites->popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner);
g_return_if_fail (favorites->popup);
priv->favorites = favorites;
panel_surface = phosh_layer_surface_get_layer_surface(priv->panel);
/* TODO: how to get meaningful serial from gdk? */
xdg_popup_grab(favorites->popup, phosh_wayland_get_wl_seat (wl), 1);
zwlr_layer_surface_v1_get_popup(panel_surface, favorites->popup);
xdg_surface_add_listener(xdg_surface, &xdg_surface_listener, NULL);
xdg_popup_add_listener(favorites->popup, &xdg_popup_listener, self);
wl_surface_commit(favorites->wl_surface);
xdg_positioner_destroy(xdg_positioner);
g_signal_connect_swapped (priv->favorites->window,
"activity-launched",
G_CALLBACK(close_favorites_menu_cb),
self);
g_signal_connect_swapped (priv->favorites->window,
"activity-raised",
G_CALLBACK(close_favorites_menu_cb),
self);
g_signal_connect_swapped (priv->favorites->window,
"selection-aborted",
G_CALLBACK(close_favorites_menu_cb),
self);
}
static void
setting_done_cb (PhoshShell *self,
PhoshSettings *settings)
......@@ -264,7 +182,6 @@ settings_activated_cb (PhoshShell *self,
gpointer xdg_wm_base = phosh_wayland_get_xdg_wm_base(wl);
struct zwlr_layer_surface_v1 *panel_surface;
close_menu (&priv->favorites);
if (priv->settings) {
close_menu (&priv->settings);
return;
......@@ -358,12 +275,6 @@ panels_create (PhoshShell *self)
"settings-activated",
G_CALLBACK(settings_activated_cb),
self);
g_signal_connect_swapped (
priv->home,
"home-activated",
G_CALLBACK(home_activated_cb),
self);
}
......
......@@ -2,110 +2,103 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="PhoshFavorites" parent="GtkWindow">
<template class="PhoshFavorites" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<object class="GtkEventBox" id="evbox_running_activities">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEventBox" id="evbox_running_activities">
<object class="GtkScrolledWindow" id="sw_running_activities">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="vscrollbar_policy">never</property>
<child>
<object class="GtkScrolledWindow" id="sw_running_activities">
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vscrollbar_policy">never</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkViewport">
<object class="GtkBox" id="box_running_activities">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_start">24</property>
<property name="margin_end">24</property>
<property name="vexpand">True</property>
<property name="spacing">18</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="box_running_activities">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="spacing">18</property>
<property name="margin-start">24</property>
<property name="margin-end">24</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<style>
<class name="phosh-running-activities-flowbox"/>
</style>
</object>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<style>
<class name="phosh-running-activities-flowbox"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="evbox_favorites">
<property name="name">evbox</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
<child>
<object class="GtkEventBox" id="evbox_favorites">
<property name="name">evbox</property>
<object class="GtkScrolledWindow" id="sw_favorites">
<property name="name">sw_favorites</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hscrollbar_policy">never</property>
<property name="propagate_natural_height">True</property>
<child>
<object class="GtkScrolledWindow" id="sw_favorites">
<property name="name">sw_favorites</property>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
<property name="hscrollbar_policy">never</property>
<property name="propagate_natural_height">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkViewport">
<object class="GtkFlowBox" id="fb_favorites">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkFlowBox" id="fb_favorites">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="homogeneous">True</property>
<property name="min_children_per_line">4</property>
<property name="max_children_per_line">4</property>
<property name="selection_mode">none</property>
<property name="activate_on_single_click">False</property>
<style>
<class name="phosh-favorites-flowbox"/>
</style>
</object>
</child>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="homogeneous">True</property>
<property name="min_children_per_line">4</property>
<property name="max_children_per_line">4</property>
<property name="selection_mode">none</property>
<property name="activate_on_single_click">False</property>
<style>
<class name="phosh-favorites-flowbox"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="phosh-overview"/>
......
......@@ -2,6 +2,12 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="img_home">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">24</property>
<property name="icon_name">swipe-arrow-symbolic</property>
</object>
<template class="PhoshHome" parent="PhoshLayerSurface">
<property name="can_focus">False</property>
<child>
......@@ -11,47 +17,69 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child type="center">
<object class="GtkButton" id="btn_home">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="image">img_home</property>
<property name="image_position">top</property>
<property name="always_show_image">True</property>
<style>
<class name="phosh-panel-btn"/>
</style>
<property name="can_focus">False</property>
<child type="center">
<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="hexpand">True</property>
<property name="image">img_home</property>
<property name="image_position">top</property>
<property name="always_show_image">True</property>
<style>
<class name="phosh-panel-btn"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="PhoshOskButton" id="btn_osk">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_right">6</property>
<property name="receives_default">True</property>
<style>
<class name="phosh-osk-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="expand">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="PhoshOskButton" id="btn_osk">
<object class="PhoshFavorites" id="favorites">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_right">6</property>
<property name="receives_default">True</property>
<style>
<class name="phosh-osk-button"/>
</style>
<property name="can_focus">False</property>
</object>
<packing>
<property name="pack_type">end</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</template>
<object class="GtkImage" id="img_home">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">swipe-arrow-symbolic</property>
<property name="pixel_size">24</property>
</object>
</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