[mutter/bilelmoussaoui/drop-zenity: 1/2] x11 SM: Replace zenity with Clutter actors
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/drop-zenity: 1/2] x11 SM: Replace zenity with Clutter actors
- Date: Wed, 20 Apr 2022 12:56:37 +0000 (UTC)
commit 23df0e8d3097e3dc978ca5ea822b8f53da2a38ed
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Tue Apr 19 16:16:33 2022 +0200
x11 SM: Replace zenity with Clutter actors
Removes the 3/3 usage of zenity
src/x11/session.c | 121 +++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 88 insertions(+), 33 deletions(-)
---
diff --git a/src/x11/session.c b/src/x11/session.c
index 5b4879bc00..850b631efc 100644
--- a/src/x11/session.c
+++ b/src/x11/session.c
@@ -30,6 +30,7 @@
#include <X11/Xatom.h>
#include "core/util-private.h"
+#include "meta/compositor-mutter.h"
#include "meta/meta-context.h"
#include "x11/meta-x11-display-private.h"
@@ -69,7 +70,6 @@ meta_window_release_saved_state (const MetaWindowSessionInfo *info)
#include "core/display-private.h"
#include "meta/main.h"
-#include "meta/util.h"
#include "meta/workspace.h"
typedef struct _MetaIceConnection
@@ -1753,14 +1753,35 @@ finish_interact (gboolean shutdown)
}
static void
-dialog_closed (GPid pid, int status, gpointer user_data)
+dialog_closed (int response,
+ ClutterActor *actor)
{
- gboolean shutdown = GPOINTER_TO_INT (user_data);
+ clutter_actor_destroy (actor);
+ /* pressed "OK" has a response of 0 */
+ finish_interact (response == 0);
+}
- if (WIFEXITED (status) && WEXITSTATUS (status) == 0) /* pressed "OK" */
- {
- finish_interact (shutdown);
- }
+static gboolean
+dialog_timeout_closed (ClutterActor *actor)
+{
+ dialog_closed (0, actor);
+ return G_SOURCE_REMOVE;
+}
+
+static void
+dialog_cancel_clicked (ClutterActor *button,
+ ClutterButtonEvent event,
+ ClutterActor *actor)
+{
+ dialog_closed (-1, actor);
+}
+
+static void
+dialog_ok_clicked (ClutterActor *button,
+ ClutterButtonEvent event,
+ ClutterActor *actor)
+{
+ dialog_closed (0, actor);
}
static void
@@ -1768,12 +1789,18 @@ warn_about_lame_clients_and_finish_interact (gboolean shutdown)
{
GSList *lame = NULL;
GSList *windows;
- GSList *lame_details = NULL;
GSList *tmp;
- GSList *columns = NULL;
- GPid pid;
-
- windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT);
+ ClutterActor *main_actor;
+ ClutterActor *title_actor;
+ ClutterActor *ok_button;
+ ClutterActor *cancel_button;
+ ClutterLayoutManager *hlayout;
+ ClutterLayoutManager *vlayout;
+ ClutterActor *actions_actor;
+ ClutterActor *stage;
+ MetaDisplay *display = meta_get_display();
+
+ windows = meta_display_list_windows (display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{
@@ -1800,39 +1827,67 @@ warn_about_lame_clients_and_finish_interact (gboolean shutdown)
return;
}
- columns = g_slist_prepend (columns, (gpointer)"Window");
- columns = g_slist_prepend (columns, (gpointer)"Class");
-
lame = g_slist_sort (lame, (GCompareFunc) windows_cmp_by_title);
+ stage = meta_get_stage_for_display (display);
+
+ main_actor = clutter_actor_new ();
+ clutter_actor_add_child (stage, main_actor);
+
+ title_actor = clutter_text_new ();
+ clutter_text_set_text (CLUTTER_TEXT (title_actor),
+ _("These windows do not support “save current setup” "
+ "and will have to be restarted manually next time "
+ "you log in.")
+ );
+ clutter_actor_add_child (main_actor, title_actor);
+
+ vlayout = clutter_box_layout_new ();
+ clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (vlayout),
+ CLUTTER_ORIENTATION_VERTICAL);
+ clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (vlayout), 6);
+
+ ClutterActor *container = clutter_actor_new ();
+ clutter_actor_set_layout_manager (container, vlayout);
+ clutter_actor_add_child (main_actor, container);
+
tmp = lame;
while (tmp != NULL)
{
MetaWindow *w = tmp->data;
- lame_details = g_slist_prepend (lame_details,
- w->res_class ? w->res_class : (gpointer)"");
- lame_details = g_slist_prepend (lame_details,
- w->title);
+ ClutterActor *window = clutter_text_new ();
+ clutter_text_set_text (CLUTTER_TEXT (window), w->title);
+ clutter_actor_add_child (container, window);
tmp = tmp->next;
}
g_slist_free (lame);
- pid = meta_show_dialog("--list",
- _("These windows do not support “save current setup” "
- "and will have to be restarted manually next time "
- "you log in."),
- "240",
- meta_get_display()->x11_display->screen_name,
- NULL, NULL, NULL,
- None,
- columns,
- lame_details);
-
- g_slist_free (lame_details);
-
- g_child_watch_add (pid, dialog_closed, GINT_TO_POINTER (shutdown));
+ hlayout = clutter_box_layout_new ();
+ clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (hlayout),
+ CLUTTER_ORIENTATION_HORIZONTAL);
+ actions_actor = clutter_actor_new ();
+ clutter_actor_set_layout_manager (actions_actor, hlayout);
+
+ ok_button = clutter_text_new ();
+ clutter_text_set_text (CLUTTER_TEXT (ok_button), _("Ok"));
+ clutter_actor_set_reactive (CLUTTER_ACTOR (ok_button), TRUE);
+ g_signal_connect (ok_button, "button-press-event",
+ G_CALLBACK (dialog_ok_clicked), stage);
+ clutter_actor_add_child (actions_actor, ok_button);
+
+ cancel_button = clutter_text_new ();
+ clutter_text_set_text (CLUTTER_TEXT (cancel_button), _("Cancel"));
+ clutter_actor_set_reactive (CLUTTER_ACTOR (cancel_button), TRUE);
+ g_signal_connect (cancel_button, "button-press-event",
+ G_CALLBACK (dialog_cancel_clicked), stage);
+ clutter_actor_add_child (actions_actor, cancel_button);
+
+ clutter_actor_add_child (main_actor, actions_actor);
+ clutter_actor_add_child (stage, main_actor);
+
+ g_timeout_add_seconds (240, G_SOURCE_FUNC (dialog_timeout_closed), stage);
}
#endif /* HAVE_SM */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]