[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: Tue, 19 Apr 2022 14:33:12 +0000 (UTC)
commit 3abd22a2f105ec05bbd9916d7a3d46c887756985
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 | 118 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 87 insertions(+), 31 deletions(-)
---
diff --git a/src/x11/session.c b/src/x11/session.c
index 5b4879bc00..21deebab41 100644
--- a/src/x11/session.c
+++ b/src/x11/session.c
@@ -69,7 +69,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 +1752,34 @@ 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,10 +1787,15 @@ 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;
+ ClutterActor *main_actor;
+ ClutterActor *title_actor;
+ ClutterActor *ok_button;
+ ClutterActor *cancel_button;
+ ClutterLayoutManager *hlayout;
+ ClutterLayoutManager *vlayout;
+ ClutterActor *actions_actor;
+ ClutterActor *stage;
windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT);
tmp = windows;
@@ -1800,39 +1824,71 @@ 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 = g_object_new (CLUTTER_TYPE_STAGE,
+ "width", 600,
+ "height", 600,
+ NULL);
+ clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightGray);
+
+ 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]