From 8f7d3bde14466bd151d68c0a8c2ea91151a86abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 11 Jul 2019 12:25:01 +0200 Subject: [PATCH 1/5] app: Add close button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emit a 'app-closed' signal when that button is clicked. Signed-off-by: Guido Günther --- src/app.c | 30 ++++++++++++++++++++++++++++++ src/ui/app.ui | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/app.c b/src/app.c index 0b0867b7b..d25dd9a4f 100644 --- a/src/app.c +++ b/src/app.c @@ -24,6 +24,12 @@ // Icons actually sized according to the pixel-size set in the template #define APP_ICON_SIZE -1 +enum { + APP_CLOSED, + N_SIGNALS +}; +static guint signals[N_SIGNALS] = { 0 }; + enum { PROP_0, PROP_APP_ID, @@ -41,6 +47,7 @@ typedef struct GtkWidget *icon; GtkWidget *app_name; GtkWidget *box; + GtkWidget *btn_close; int win_width; int win_height; @@ -142,6 +149,19 @@ phosh_app_get_property (GObject *object, } } + +static void +on_btn_close_clicked (PhoshApp *self, GtkButton *button) +{ + g_return_if_fail (PHOSH_IS_APP (self)); + g_return_if_fail (GTK_IS_BUTTON (button)); + + gtk_widget_destroy (GTK_WIDGET (self)); + + g_signal_emit(self, signals[APP_CLOSED], 0); +} + + static void phosh_app_constructed (GObject *object) { @@ -179,6 +199,11 @@ phosh_app_constructed (GObject *object) APP_ICON_SIZE); } + g_signal_connect_swapped (priv->btn_close, + "clicked", + (GCallback) on_btn_close_clicked, + self); + G_OBJECT_CLASS (phosh_app_parent_class)->constructed (object); } @@ -364,11 +389,16 @@ phosh_app_class_init (PhoshAppClass *klass) g_object_class_install_properties (object_class, LAST_PROP, props); + signals[APP_CLOSED] = g_signal_new ("app-closed", + 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/app.ui"); gtk_widget_class_bind_template_child_private (widget_class, PhoshApp, app_name); gtk_widget_class_bind_template_child_private (widget_class, PhoshApp, icon); gtk_widget_class_bind_template_child_private (widget_class, PhoshApp, box); + gtk_widget_class_bind_template_child_private (widget_class, PhoshApp, btn_close); gtk_widget_class_set_css_name (widget_class, "phosh-app"); } diff --git a/src/ui/app.ui b/src/ui/app.ui index cce2c0c60..323a3bfd2 100644 --- a/src/ui/app.ui +++ b/src/ui/app.ui @@ -2,6 +2,11 @@ + + True + False + edit-delete-symbolic + -- GitLab From 008e8ff40147195dcb0e923ce420c3e611ec674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 11 Jul 2019 12:36:51 +0200 Subject: [PATCH 2/5] Update phosh private protocol to v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- protocol/phosh-private.xml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/protocol/phosh-private.xml b/protocol/phosh-private.xml index 4eede1e58..0312267ce 100644 --- a/protocol/phosh-private.xml +++ b/protocol/phosh-private.xml @@ -1,5 +1,5 @@ - + Private protocol between phosh and the compositor. @@ -23,8 +23,8 @@ - - + + The interface is meant to list xdg surfaces (see the xdg-shell stable wayland protocol) and to raise these surfaces to the top @@ -65,5 +65,13 @@ + + + + + + + + -- GitLab From 012e4ce811a9d5e848ac189a68cf25f8cc3dcb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 11 Jul 2019 12:50:18 +0200 Subject: [PATCH 3/5] fixup! app: Add close button --- src/app.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app.c b/src/app.c index d25dd9a4f..5e338fdd5 100644 --- a/src/app.c +++ b/src/app.c @@ -156,9 +156,8 @@ on_btn_close_clicked (PhoshApp *self, GtkButton *button) g_return_if_fail (PHOSH_IS_APP (self)); g_return_if_fail (GTK_IS_BUTTON (button)); - gtk_widget_destroy (GTK_WIDGET (self)); - g_signal_emit(self, signals[APP_CLOSED], 0); + gtk_widget_destroy (GTK_WIDGET (self)); } -- GitLab From 85a3429b12508eb0e909ba4b6d85adc68388b72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 11 Jul 2019 12:50:23 +0200 Subject: [PATCH 4/5] PhoshFavorites: Close application on 'app-close' signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #67 Signed-off-by: Guido Günther --- src/favorites.c | 26 ++++++++++++++++++++++++++ src/phosh-wayland.c | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/favorites.c b/src/favorites.c index 5c57ff286..916908878 100644 --- a/src/favorites.c +++ b/src/favorites.c @@ -26,6 +26,7 @@ enum { APP_LAUNCHED, APP_RAISED, + APP_CLOSED, SELECTION_ABORTED, N_SIGNALS }; @@ -76,6 +77,26 @@ app_clicked_cb (GtkButton *btn, gpointer user_data) } +static void +on_app_closed (PhoshFavorites *self, PhoshApp *app) +{ + PhoshFavoritesPrivate *priv; + + g_return_if_fail (PHOSH_IS_FAVORITES (self)); + g_return_if_fail (PHOSH_IS_APP (app)); + + priv = phosh_favorites_get_instance_private (self); + g_return_if_fail (priv->xdg_switcher); + + g_debug("Will close %s (%s)", + phosh_app_get_app_id (app), + phosh_app_get_title (app)); + phosh_private_xdg_switcher_close_xdg_surface (priv->xdg_switcher, + phosh_app_get_app_id (app), + phosh_app_get_title (app)); + g_signal_emit(self, signals[APP_CLOSED], 0); +} + static void handle_xdg_switcher_xdg_surface ( @@ -108,6 +129,8 @@ handle_xdg_switcher_xdg_surface ( gtk_widget_show (app); g_signal_connect (app, "clicked", G_CALLBACK (app_clicked_cb), self); + g_signal_connect_swapped (app, "app-closed", G_CALLBACK (on_app_closed), self); + gtk_widget_show (GTK_WIDGET (self)); } @@ -344,6 +367,9 @@ phosh_favorites_class_init (PhoshFavoritesClass *klass) signals[SELECTION_ABORTED] = g_signal_new ("selection-aborted", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + signals[SELECTION_ABORTED] = g_signal_new ("app-closed", + G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, + NULL, G_TYPE_NONE, 0); } diff --git a/src/phosh-wayland.c b/src/phosh-wayland.c index b062a99de..bc9315fdc 100644 --- a/src/phosh-wayland.c +++ b/src/phosh-wayland.c @@ -68,7 +68,7 @@ registry_handle_global (void *data, registry, name, &phosh_private_interface, - 2); + 3); } else if (!strcmp (interface, zwlr_layer_shell_v1_interface.name)) { priv->layer_shell = wl_registry_bind ( registry, -- GitLab From 2d357ed22149272b776af6178dd0e71b9923f618 Mon Sep 17 00:00:00 2001 From: Tobias Bernard Date: Thu, 11 Jul 2019 15:23:51 +0200 Subject: [PATCH 5/5] App Switcher: styling for temporary close button --- src/style.css | 8 ++++++++ src/ui/app.ui | 15 ++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/style.css b/src/style.css index ce4a3b810..184a79fe0 100644 --- a/src/style.css +++ b/src/style.css @@ -68,6 +68,14 @@ phosh-home, .phosh-panel { color: white; } +.phosh-app-close-button { + border-radius: 50%; + min-width: 0; + min-height: 0; + margin: 12px; + padding: 12px; +} + /* Overview (app switcher, favorites) */ .phosh-overview { diff --git a/src/ui/app.ui b/src/ui/app.ui index 323a3bfd2..4b4d9f95d 100644 --- a/src/ui/app.ui +++ b/src/ui/app.ui @@ -2,11 +2,6 @@ - - True - False - edit-delete-symbolic -