[mutter] core: Add MetaCloseDialog



commit b47de58eddcbcf8c7dcfc8754a34ef6928499936
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 11 13:07:46 2016 +0200

    core: Add MetaCloseDialog
    
    This is an interface that can be used to implement the "application
    is not responding" dialog. One instance is created per window, which
    is initially hidden, and can be shown/hidden on demand.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711619

 src/Makefile.am              |    3 +
 src/core/meta-close-dialog.c |  103 ++++++++++++++++++++++++++++++++++++++++++
 src/meta/meta-close-dialog.h |   53 +++++++++++++++++++++
 3 files changed, 159 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a154b2..ac5786a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -222,6 +222,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES =      \
        core/constraints.c                      \
        core/constraints.h                      \
        core/core.c                             \
+       core/meta-close-dialog.c                \
+       meta/meta-close-dialog.h                \
        core/delete.c                           \
        core/display.c                          \
        core/display-private.h                  \
@@ -435,6 +437,7 @@ libmutterinclude_headers =                  \
        meta/meta-background-actor.h            \
        meta/meta-background-image.h            \
        meta/meta-background-group.h            \
+       meta/meta-close-dialog.h                \
        meta/meta-cursor-tracker.h              \
        meta/meta-dnd.h                 \
        meta/meta-idle-monitor.h                \
diff --git a/src/core/meta-close-dialog.c b/src/core/meta-close-dialog.c
new file mode 100644
index 0000000..9bb708f
--- /dev/null
+++ b/src/core/meta-close-dialog.c
@@ -0,0 +1,103 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2016 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#include "config.h"
+#include "window-private.h"
+#include "meta/meta-close-dialog.h"
+#include "meta/meta-enum-types.h"
+
+enum {
+  RESPONSE,
+  N_SIGNALS
+};
+
+guint dialog_signals[N_SIGNALS] = { 0 };
+
+G_DEFINE_INTERFACE (MetaCloseDialog, meta_close_dialog, G_TYPE_OBJECT)
+
+static void
+meta_close_dialog_default_init (MetaCloseDialogInterface *iface)
+{
+  g_object_interface_install_property (iface,
+                                       g_param_spec_object ("window",
+                                                            "Window",
+                                                            "Window",
+                                                            META_TYPE_WINDOW,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_CONSTRUCT_ONLY));
+  dialog_signals[RESPONSE] =
+    g_signal_new ("response",
+                  G_TYPE_FROM_INTERFACE (iface),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 1, META_TYPE_CLOSE_DIALOG_RESPONSE);
+}
+
+/**
+ * meta_close_dialog_show:
+ * @dialog: a #MetaCloseDialog
+ *
+ * Shows the close dialog.
+ **/
+void
+meta_close_dialog_show (MetaCloseDialog *dialog)
+{
+  MetaCloseDialogInterface *iface;
+
+  g_return_if_fail (META_IS_CLOSE_DIALOG (dialog));
+
+  iface = META_CLOSE_DIALOG_GET_IFACE (dialog);
+  iface->show (dialog);
+}
+
+/**
+ * meta_close_dialog_hide:
+ * @dialog: a #MetaCloseDialog
+ *
+ * Hides the close dialog.
+ **/
+void
+meta_close_dialog_hide (MetaCloseDialog *dialog)
+{
+  MetaCloseDialogInterface *iface;
+
+  g_return_if_fail (META_IS_CLOSE_DIALOG (dialog));
+
+  iface = META_CLOSE_DIALOG_GET_IFACE (dialog);
+  iface->hide (dialog);
+}
+
+/**
+ * meta_close_dialog_response:
+ * @dialog: a #MetaCloseDialog
+ * @response: a #MetaCloseDialogResponse
+ *
+ * Responds and closes the dialog. To be called by #MetaCloseDialog
+ * implementations.
+ **/
+void
+meta_close_dialog_response (MetaCloseDialog         *dialog,
+                            MetaCloseDialogResponse  response)
+{
+  g_signal_emit (dialog, dialog_signals[RESPONSE], 0, response);
+  meta_close_dialog_hide (dialog);
+}
diff --git a/src/meta/meta-close-dialog.h b/src/meta/meta-close-dialog.h
new file mode 100644
index 0000000..d9a5fa5
--- /dev/null
+++ b/src/meta/meta-close-dialog.h
@@ -0,0 +1,53 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2016 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifndef META_CLOSE_DIALOG_H
+#define META_CLOSE_DIALOG_H
+
+#include <glib-object.h>
+#include <meta/window.h>
+
+#define META_TYPE_CLOSE_DIALOG (meta_close_dialog_get_type ())
+
+G_DECLARE_INTERFACE (MetaCloseDialog, meta_close_dialog,
+                    META, CLOSE_DIALOG, GObject)
+
+typedef enum
+{
+  META_CLOSE_DIALOG_RESPONSE_WAIT,
+  META_CLOSE_DIALOG_RESPONSE_FORCE_CLOSE,
+} MetaCloseDialogResponse;
+
+struct _MetaCloseDialogInterface
+{
+  GTypeInterface parent_iface;
+
+  void (* show) (MetaCloseDialog *dialog);
+  void (* hide) (MetaCloseDialog *dialog);
+};
+
+void              meta_close_dialog_show (MetaCloseDialog *dialog);
+void              meta_close_dialog_hide (MetaCloseDialog *dialog);
+
+void              meta_close_dialog_response (MetaCloseDialog         *dialog,
+                                              MetaCloseDialogResponse  response);
+
+#endif /* META_CLOSE_DIALOG_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]