Commit 3d235ec9 authored by Zander Brown's avatar Zander Brown Committed by Guido Gunther
Browse files

overview: rename PhoshFavorites now it's funcation has changed

The overview is the widget that contains the

 - activities (running applications)
 - the favorites
 - the app drawer
parent f76a255d
......@@ -4,7 +4,7 @@ src/activity.c
src/auth.c
src/background.c
src/batteryinfo.c
src/favorites.c
src/overview.c
src/home.c
src/idle-manager.c
src/layersurface.c
......@@ -30,7 +30,7 @@ src/util.c
src/wifiinfo.c
src/wifimanager.c
src/wwaninfo.c
src/ui/favorites.ui
src/ui/overview.ui
src/ui/home.ui
src/ui/lockscreen.ui
src/ui/polkit-auth-prompt.ui
......
......@@ -17,8 +17,7 @@
* @short_description: An app in the faovorites overview
* @Title: PhoshActivity
*
* The #PhoshActivity is used to select a running application
* in the favorites overview.
* The #PhoshActivity is used to select a running application in the overview.
*/
// Icons actually sized according to the pixel-size set in the template
......
......@@ -7,7 +7,7 @@
#define G_LOG_DOMAIN "phosh-home"
#include "config.h"
#include "favorites.h"
#include "overview.h"
#include "home.h"
#include "shell.h"
#include "phosh-enums.h"
......@@ -44,7 +44,7 @@ struct _PhoshHome
GtkWidget *btn_home;
GtkWidget *img_home;
GtkWidget *btn_osk;
GtkWidget *favorites;
GtkWidget *overview;
struct {
gdouble progress;
......@@ -147,10 +147,10 @@ osk_clicked_cb (PhoshHome *self, GtkButton *btn)
static void
fold_cb (PhoshHome *self, PhoshFavorites *favorites)
fold_cb (PhoshHome *self, PhoshOverview *overview)
{
g_return_if_fail (PHOSH_IS_HOME (self));
g_return_if_fail (PHOSH_IS_FAVORITES (favorites));
g_return_if_fail (PHOSH_IS_OVERVIEW (overview));
phosh_home_set_state (self, PHOSH_HOME_STATE_FOLDED);
}
......@@ -174,15 +174,15 @@ phosh_home_constructed (GObject *object)
self,
G_CONNECT_SWAPPED);
g_signal_connect_swapped (self->favorites,
g_signal_connect_swapped (self->overview,
"activity-launched",
G_CALLBACK(fold_cb),
self);
g_signal_connect_swapped (self->favorites,
g_signal_connect_swapped (self->overview,
"activity-raised",
G_CALLBACK(fold_cb),
self);
g_signal_connect_swapped (self->favorites,
g_signal_connect_swapped (self->overview,
"selection-aborted",
G_CALLBACK(fold_cb),
self);
......@@ -221,14 +221,15 @@ phosh_home_class_init (PhoshHomeClass *klass)
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
PHOSH_TYPE_OSK_BUTTON;
PHOSH_TYPE_FAVORITES;
g_type_ensure (PHOSH_TYPE_OSK_BUTTON);
g_type_ensure (PHOSH_TYPE_OVERVIEW);
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, img_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_bind_template_child (widget_class, PhoshHome, overview);
gtk_widget_class_set_css_name (widget_class, "phosh-home");
}
......
......@@ -35,8 +35,8 @@ libphosh_sources = [
'app-grid-button.h',
'app-list-model.c',
'app-list-model.h',
'favorites.c',
'favorites.h',
'overview.c',
'overview.h',
phosh_resources,
wl_proto_sources,
phosh_gtk_list_models_sources,
......
......@@ -3,16 +3,16 @@
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*
* Based on maynard's favorites whish is
* Based on maynard's favorites which is
* Copyright (C) 2013 Collabora Ltd.
* Author: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
*/
#define G_LOG_DOMAIN "phosh-favorites"
#define G_LOG_DOMAIN "phosh-overview"
#include "config.h"
#include "favorites.h"
#include "overview.h"
#include "activity.h"
#include "app-grid-button.h"
#include "shell.h"
......@@ -23,7 +23,7 @@
#include <gio/gdesktopappinfo.h>
#define FAVORITES_ICON_SIZE 64
#define OVERVIEW_ICON_SIZE 64
enum {
ACTIVITY_LAUNCHED,
......@@ -37,33 +37,33 @@ static guint signals[N_SIGNALS] = { 0 };
typedef struct
{
/* Favorites */
GtkWidget *evbox_favorites;
GtkWidget *fb_favorites;
GtkWidget *evbox_overview;
GtkWidget *fb_overview;
GSettings *settings;
/* Running activities */
GtkWidget *evbox_running_activities;
GtkWidget *box_running_activities;
} PhoshFavoritesPrivate;
} PhoshOverviewPrivate;
struct _PhoshFavorites
struct _PhoshOverview
{
GtkBoxClass parent;
};
G_DEFINE_TYPE_WITH_PRIVATE(PhoshFavorites, phosh_favorites, GTK_TYPE_BOX)
G_DEFINE_TYPE_WITH_PRIVATE (PhoshOverview, phosh_overview, GTK_TYPE_BOX)
static void
on_activity_clicked (PhoshFavorites *self, PhoshActivity *activity)
on_activity_clicked (PhoshOverview *self, PhoshActivity *activity)
{
PhoshToplevel *toplevel;
g_return_if_fail (PHOSH_IS_FAVORITES (self));
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
g_return_if_fail (PHOSH_IS_ACTIVITY (activity));
toplevel = g_object_get_data(G_OBJECT (activity), "toplevel");
toplevel = g_object_get_data (G_OBJECT (activity), "toplevel");
g_return_if_fail (PHOSH_IS_TOPLEVEL (toplevel));
g_debug("Will raise %s (%s)",
......@@ -71,26 +71,26 @@ on_activity_clicked (PhoshFavorites *self, PhoshActivity *activity)
phosh_activity_get_title (activity));
phosh_toplevel_raise (toplevel, phosh_wayland_get_wl_seat (phosh_wayland_get_default ()));
g_signal_emit(self, signals[ACTIVITY_RAISED], 0);
g_signal_emit (self, signals[ACTIVITY_RAISED], 0);
}
static void
on_activity_close_clicked (PhoshFavorites *self, PhoshActivity *activity)
on_activity_close_clicked (PhoshOverview *self, PhoshActivity *activity)
{
PhoshToplevel *toplevel;
g_return_if_fail (PHOSH_IS_FAVORITES (self));
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
g_return_if_fail (PHOSH_IS_ACTIVITY (activity));
toplevel = g_object_get_data(G_OBJECT (activity), "toplevel");
toplevel = g_object_get_data (G_OBJECT (activity), "toplevel");
g_return_if_fail (PHOSH_IS_TOPLEVEL (toplevel));
g_debug("Will close %s (%s)",
phosh_activity_get_app_id (activity),
phosh_activity_get_title (activity));
g_debug ("Will close %s (%s)",
phosh_activity_get_app_id (activity),
phosh_activity_get_title (activity));
phosh_toplevel_close (toplevel);
g_signal_emit(self, signals[ACTIVITY_CLOSED], 0);
g_signal_emit (self, signals[ACTIVITY_CLOSED], 0);
}
static void
......@@ -101,15 +101,16 @@ on_toplevel_closed (PhoshToplevel *toplevel, PhoshActivity *activity)
gtk_widget_destroy (GTK_WIDGET (activity));
}
static void add_activity (PhoshFavorites *self, PhoshToplevel *toplevel)
static void
add_activity (PhoshOverview *self, PhoshToplevel *toplevel)
{
PhoshMonitor *monitor = phosh_shell_get_primary_monitor (phosh_shell_get_default ());
PhoshFavoritesPrivate *priv;
PhoshOverviewPrivate *priv;
GtkWidget *activity;
const gchar *app_id, *title;
g_return_if_fail (PHOSH_IS_FAVORITES (self));
priv = phosh_favorites_get_instance_private (self);
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
priv = phosh_overview_get_instance_private (self);
app_id = phosh_toplevel_get_app_id (toplevel);
title = phosh_toplevel_get_title (toplevel);
......@@ -120,7 +121,7 @@ static void add_activity (PhoshFavorites *self, PhoshToplevel *toplevel)
"win-width", monitor->width, // TODO: Get the real size somehow
"win-height", monitor->height,
NULL);
g_object_set_data (G_OBJECT(activity), "toplevel", toplevel);
g_object_set_data (G_OBJECT (activity), "toplevel", toplevel);
gtk_box_pack_end (GTK_BOX (priv->box_running_activities), activity, FALSE, FALSE, 0);
gtk_widget_show (activity);
......@@ -132,7 +133,7 @@ static void add_activity (PhoshFavorites *self, PhoshToplevel *toplevel)
}
static void
get_running_activities (PhoshFavorites *self)
get_running_activities (PhoshOverview *self)
{
PhoshToplevelManager *toplevel_manager = phosh_shell_get_toplevel_manager (phosh_shell_get_default ());
guint toplevels_num = phosh_toplevel_manager_get_num_toplevels (toplevel_manager);
......@@ -144,49 +145,52 @@ get_running_activities (PhoshFavorites *self)
}
static void
toplevel_added_cb (PhoshFavorites *self, PhoshToplevel *toplevel, PhoshToplevelManager *manager)
toplevel_added_cb (PhoshOverview *self,
PhoshToplevel *toplevel,
PhoshToplevelManager *manager)
{
g_return_if_fail (PHOSH_IS_FAVORITES (self));
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
g_return_if_fail (PHOSH_IS_TOPLEVEL (toplevel));
g_return_if_fail (PHOSH_IS_TOPLEVEL_MANAGER (manager));
add_activity (self, toplevel);
}
static void
phosh_favorites_size_allocate (GtkWidget *widget,
GtkAllocation *alloc)
phosh_overview_size_allocate (GtkWidget *widget,
GtkAllocation *alloc)
{
PhoshFavorites *self = PHOSH_FAVORITES (widget);
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
PhoshOverview *self = PHOSH_OVERVIEW (widget);
PhoshOverviewPrivate *priv = phosh_overview_get_instance_private (self);
GList *children, *l;
children = gtk_container_get_children (GTK_CONTAINER (priv->box_running_activities));
for (l = children; l; l = l->next)
for (l = children; l; l = l->next) {
g_object_set (l->data,
"win-width", alloc->width,
"win-height", alloc->height,
NULL);
}
g_list_free (children);
GTK_WIDGET_CLASS (phosh_favorites_parent_class)->size_allocate (widget, alloc);
GTK_WIDGET_CLASS (phosh_overview_parent_class)->size_allocate (widget, alloc);
}
static void
app_launched_cb (PhoshFavorites *self,
GAppInfo *info,
GtkWidget *widget)
app_launched_cb (PhoshOverview *self,
GAppInfo *info,
GtkWidget *widget)
{
g_return_if_fail (PHOSH_IS_FAVORITES (self));
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
g_signal_emit (self, signals[ACTIVITY_LAUNCHED], 0);
}
static GtkWidget*
create_favorite (PhoshFavorites *self,
const gchar *favorite)
create_favorite (PhoshOverview *self,
const gchar *favorite)
{
GDesktopAppInfo *info;
GtkWidget *btn;
......@@ -205,23 +209,23 @@ create_favorite (PhoshFavorites *self,
static void
favorites_changed (GSettings *settings,
const gchar *key,
PhoshFavorites *self)
favorites_changed (GSettings *settings,
const gchar *key,
PhoshOverview *self)
{
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
PhoshOverviewPrivate *priv = phosh_overview_get_instance_private (self);
g_auto(GStrv) favorites = g_settings_get_strv (settings, key);
GtkWidget *btn;
/* Remove all favorites first */
gtk_container_foreach (GTK_CONTAINER (priv->fb_favorites),
gtk_container_foreach (GTK_CONTAINER (priv->fb_overview),
(GtkCallback) gtk_widget_destroy, NULL);
for (gint i = 0; i < g_strv_length (favorites); i++) {
gchar *fav = favorites[i];
btn = create_favorite (self, fav);
if (btn) {
gtk_flow_box_insert (GTK_FLOW_BOX (priv->fb_favorites), btn, -1);
gtk_flow_box_insert (GTK_FLOW_BOX (priv->fb_overview), btn, -1);
gtk_widget_show (btn);
}
}
......@@ -229,28 +233,28 @@ favorites_changed (GSettings *settings,
static gboolean
evbox_button_press_event_cb (PhoshFavorites *self, GdkEventButton *event)
evbox_button_press_event_cb (PhoshOverview *self, GdkEventButton *event)
{
g_signal_emit(self, signals[SELECTION_ABORTED], 0);
g_signal_emit (self, signals[SELECTION_ABORTED], 0);
return FALSE;
}
static void
phosh_favorites_constructed (GObject *object)
phosh_overview_constructed (GObject *object)
{
PhoshFavorites *self = PHOSH_FAVORITES (object);
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
PhoshOverview *self = PHOSH_OVERVIEW (object);
PhoshOverviewPrivate *priv = phosh_overview_get_instance_private (self);
PhoshToplevelManager *toplevel_manager =
phosh_shell_get_toplevel_manager (phosh_shell_get_default ());
G_OBJECT_CLASS (phosh_favorites_parent_class)->constructed (object);
G_OBJECT_CLASS (phosh_overview_parent_class)->constructed (object);
/* Close on click */
g_signal_connect_swapped (priv->evbox_favorites, "button_press_event",
g_signal_connect_swapped (priv->evbox_overview, "button_press_event",
G_CALLBACK (evbox_button_press_event_cb),
self);
gtk_widget_set_events (priv->evbox_favorites, GDK_BUTTON_PRESS_MASK);
gtk_widget_set_events (priv->evbox_overview, GDK_BUTTON_PRESS_MASK);
priv->settings = g_settings_new ("sm.puri.phosh");
g_signal_connect (priv->settings, "changed::favorites",
......@@ -273,34 +277,35 @@ phosh_favorites_constructed (GObject *object)
static void
phosh_favorites_dispose (GObject *object)
phosh_overview_dispose (GObject *object)
{
PhoshFavorites *self = PHOSH_FAVORITES (object);
PhoshFavoritesPrivate *priv = phosh_favorites_get_instance_private (self);
PhoshOverview *self = PHOSH_OVERVIEW (object);
PhoshOverviewPrivate *priv = phosh_overview_get_instance_private (self);
g_clear_object (&priv->settings);
G_OBJECT_CLASS (phosh_favorites_parent_class)->dispose (object);
G_OBJECT_CLASS (phosh_overview_parent_class)->dispose (object);
}
static void
phosh_favorites_class_init (PhoshFavoritesClass *klass)
phosh_overview_class_init (PhoshOverviewClass *klass)
{
GObjectClass *object_class = (GObjectClass *)klass;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = phosh_favorites_dispose;
object_class->constructed = phosh_favorites_constructed;
widget_class->size_allocate = phosh_favorites_size_allocate;
object_class->dispose = phosh_overview_dispose;
object_class->constructed = phosh_overview_constructed;
widget_class->size_allocate = phosh_overview_size_allocate;
gtk_widget_class_set_css_name (widget_class, "phosh-overview");
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/phosh/ui/favorites.ui");
"/sm/puri/phosh/ui/overview.ui");
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, evbox_favorites);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, fb_favorites);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, evbox_running_activities);
gtk_widget_class_bind_template_child_private (widget_class, PhoshFavorites, box_running_activities);
gtk_widget_class_bind_template_child_private (widget_class, PhoshOverview, evbox_overview);
gtk_widget_class_bind_template_child_private (widget_class, PhoshOverview, fb_overview);
gtk_widget_class_bind_template_child_private (widget_class, PhoshOverview, evbox_running_activities);
gtk_widget_class_bind_template_child_private (widget_class, PhoshOverview, box_running_activities);
signals[ACTIVITY_LAUNCHED] = g_signal_new ("activity-launched",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
......@@ -318,14 +323,14 @@ phosh_favorites_class_init (PhoshFavoritesClass *klass)
static void
phosh_favorites_init (PhoshFavorites *self)
phosh_overview_init (PhoshOverview *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget *
phosh_favorites_new (void)
phosh_overview_new (void)
{
return g_object_new (PHOSH_TYPE_FAVORITES, NULL);
return g_object_new (PHOSH_TYPE_OVERVIEW, NULL);
}
......@@ -8,8 +8,8 @@
#include <gtk/gtk.h>
#define PHOSH_TYPE_FAVORITES (phosh_favorites_get_type())
#define PHOSH_TYPE_OVERVIEW (phosh_overview_get_type())
G_DECLARE_FINAL_TYPE (PhoshFavorites, phosh_favorites, PHOSH, FAVORITES, GtkBox)
G_DECLARE_FINAL_TYPE (PhoshOverview, phosh_overview, PHOSH, OVERVIEW, GtkBox)
GtkWidget * phosh_favorites_new (void);
GtkWidget * phosh_overview_new (void);
......@@ -3,7 +3,7 @@
<gresource prefix="/sm/puri/phosh">
<file preprocess="xml-stripblanks">ui/activity.ui</file>
<file preprocess="xml-stripblanks">ui/app-grid-button.ui</file>
<file preprocess="xml-stripblanks">ui/favorites.ui</file>
<file preprocess="xml-stripblanks">ui/overview.ui</file>
<file preprocess="xml-stripblanks">ui/home.ui</file>
<file preprocess="xml-stripblanks">ui/lockscreen.ui</file>
<file preprocess="xml-stripblanks">ui/polkit-auth-prompt.ui</file>
......
......@@ -73,7 +73,7 @@
</packing>
</child>
<child>
<object class="PhoshFavorites" id="favorites">
<object class="PhoshOverview" id="overview">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
......
......@@ -2,7 +2,7 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="PhoshFavorites" parent="GtkBox">
<template class="PhoshOverview" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
......@@ -58,14 +58,14 @@
</packing>
</child>
<child>
<object class="GtkEventBox" id="evbox_favorites">
<object class="GtkEventBox" id="evbox_overview">
<property name="name">evbox</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
<child>
<object class="GtkScrolledWindow" id="sw_favorites">
<property name="name">sw_favorites</property>
<object class="GtkScrolledWindow" id="sw_overview">
<property name="name">sw_overview</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">end</property>
......@@ -76,7 +76,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkFlowBox" id="fb_favorites">
<object class="GtkFlowBox" id="fb_overview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
......@@ -89,7 +89,7 @@
<property name="selection_mode">none</property>
<property name="activate_on_single_click">False</property>
<style>
<class name="phosh-favorites-flowbox"/>
<class name="phosh-overview-flowbox"/>
</style>
</object>
</child>
......
......@@ -32,7 +32,7 @@ tests = [
'activity',
'app-grid-button',
'app-list-model',
'favorites',
'overview',
]
# Unit tests
......
......@@ -4,12 +4,12 @@
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "favorites.h"
#include "overview.h"
static void
test_phosh_favorites_new(void)
test_phosh_overview_new(void)
{
GtkWidget *window = phosh_favorites_new ();
GtkWidget *window = phosh_overview_new ();
g_assert (window);
gtk_widget_destroy (window);
}
......@@ -21,6 +21,6 @@ main (gint argc,
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func("/phosh/favorites/new", test_phosh_favorites_new);
g_test_add_func("/phosh/overview/new", test_phosh_overview_new);
return g_test_run();
}
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