2016-02-06 08:52:03 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2001, 2002 Havoc Pennington
|
|
|
|
* Copyright (C) 2002, 2003 Red Hat Inc.
|
|
|
|
* Some ICCCM manager selection code derived from fvwm2,
|
|
|
|
* Copyright (C) 2001 Dominik Vogt, Matthias Clasen, and fvwm2 team
|
|
|
|
* Copyright (C) 2003 Rob Adams
|
|
|
|
* Copyright (C) 2004-2006 Elijah Newren
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "config.h"
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "core/display-private.h"
|
|
|
|
#include "core/startup-notification-private.h"
|
2018-08-22 14:57:04 -04:00
|
|
|
#include "core/util-private.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "meta/meta-x11-errors.h"
|
2017-08-26 12:26:30 -04:00
|
|
|
#include "x11/meta-x11-display-private.h"
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
/* This should be fairly long, as it should never be required unless
|
|
|
|
* apps or .desktop files are buggy, and it's confusing if
|
|
|
|
* OpenOffice or whatever seems to stop launching - people
|
|
|
|
* might decide they need to launch it again.
|
|
|
|
*/
|
|
|
|
#define STARTUP_TIMEOUT 15000000
|
|
|
|
|
|
|
|
enum {
|
2018-08-22 14:57:04 -04:00
|
|
|
PROP_0,
|
|
|
|
PROP_DISPLAY,
|
|
|
|
N_PROPS
|
2016-02-06 08:52:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_SEQ_0,
|
|
|
|
PROP_SEQ_ID,
|
|
|
|
PROP_SEQ_TIMESTAMP,
|
2018-08-22 15:14:31 -04:00
|
|
|
PROP_SEQ_ICON_NAME,
|
|
|
|
PROP_SEQ_APPLICATION_ID,
|
|
|
|
PROP_SEQ_WMCLASS,
|
|
|
|
PROP_SEQ_WORKSPACE,
|
|
|
|
PROP_SEQ_NAME,
|
2016-02-06 08:52:03 -05:00
|
|
|
N_SEQ_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2018-08-22 14:57:04 -04:00
|
|
|
CHANGED,
|
|
|
|
N_SIGNALS
|
2016-02-06 08:52:03 -05:00
|
|
|
};
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
static guint sn_signals[N_SIGNALS];
|
|
|
|
static GParamSpec *sn_props[N_PROPS];
|
2016-02-06 08:52:03 -05:00
|
|
|
static GParamSpec *seq_props[N_SEQ_PROPS];
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
gint64 now;
|
|
|
|
} CollectTimedOutData;
|
|
|
|
|
|
|
|
struct _MetaStartupNotification
|
|
|
|
{
|
|
|
|
GObject parent_instance;
|
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
|
|
|
|
GSList *startup_sequences;
|
|
|
|
guint startup_sequence_timeout;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
2018-08-22 15:14:31 -04:00
|
|
|
char *wmclass;
|
|
|
|
char *name;
|
|
|
|
char *application_id;
|
|
|
|
char *icon_name;
|
|
|
|
char *id;
|
|
|
|
uint64_t timestamp;
|
|
|
|
int workspace;
|
2018-08-22 13:06:13 -04:00
|
|
|
} MetaStartupSequencePrivate;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaStartupNotification,
|
|
|
|
meta_startup_notification,
|
|
|
|
G_TYPE_OBJECT)
|
2018-08-22 13:06:13 -04:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaStartupSequence,
|
|
|
|
meta_startup_sequence,
|
2016-02-06 08:52:03 -05:00
|
|
|
G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
|
|
static void meta_startup_notification_ensure_timeout (MetaStartupNotification *sn);
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_update_feedback (MetaStartupNotification *sn)
|
|
|
|
{
|
2017-08-26 12:37:29 -04:00
|
|
|
MetaDisplay *display = sn->display;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
if (sn->startup_sequences != NULL)
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STARTUP,
|
|
|
|
"Setting busy cursor\n");
|
2017-08-26 12:37:29 -04:00
|
|
|
meta_display_set_cursor (display, META_CURSOR_BUSY);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_STARTUP,
|
|
|
|
"Setting default cursor\n");
|
2017-08-26 12:37:29 -04:00
|
|
|
meta_display_set_cursor (display, META_CURSOR_DEFAULT);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_init (MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_finalize (GObject *object)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *seq;
|
|
|
|
MetaStartupSequencePrivate *priv;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
seq = META_STARTUP_SEQUENCE (object);
|
|
|
|
priv = meta_startup_sequence_get_instance_private (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
g_free (priv->id);
|
2018-08-22 15:14:31 -04:00
|
|
|
g_free (priv->wmclass);
|
|
|
|
g_free (priv->name);
|
|
|
|
g_free (priv->application_id);
|
|
|
|
g_free (priv->icon_name);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
G_OBJECT_CLASS (meta_startup_sequence_parent_class)->finalize (object);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *seq;
|
|
|
|
MetaStartupSequencePrivate *priv;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
seq = META_STARTUP_SEQUENCE (object);
|
|
|
|
priv = meta_startup_sequence_get_instance_private (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SEQ_ID:
|
|
|
|
priv->id = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_TIMESTAMP:
|
2018-08-22 15:14:31 -04:00
|
|
|
priv->timestamp = g_value_get_uint64 (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_ICON_NAME:
|
|
|
|
priv->icon_name = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_APPLICATION_ID:
|
|
|
|
priv->application_id = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_WMCLASS:
|
|
|
|
priv->wmclass = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_WORKSPACE:
|
|
|
|
priv->workspace = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_NAME:
|
|
|
|
priv->name = g_value_dup_string (value);
|
2016-02-06 08:52:03 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *seq;
|
|
|
|
MetaStartupSequencePrivate *priv;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
seq = META_STARTUP_SEQUENCE (object);
|
|
|
|
priv = meta_startup_sequence_get_instance_private (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SEQ_ID:
|
|
|
|
g_value_set_string (value, priv->id);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_TIMESTAMP:
|
2018-08-22 15:14:31 -04:00
|
|
|
g_value_set_uint64 (value, priv->timestamp);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_ICON_NAME:
|
|
|
|
g_value_set_string (value, priv->icon_name);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_APPLICATION_ID:
|
|
|
|
g_value_set_string (value, priv->application_id);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_WMCLASS:
|
|
|
|
g_value_set_string (value, priv->wmclass);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_WORKSPACE:
|
|
|
|
g_value_set_int (value, priv->workspace);
|
|
|
|
break;
|
|
|
|
case PROP_SEQ_NAME:
|
|
|
|
g_value_set_string (value, priv->name);
|
2016-02-06 08:52:03 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_class_init (MetaStartupSequenceClass *klass)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2018-08-22 13:06:13 -04:00
|
|
|
object_class->finalize = meta_startup_sequence_finalize;
|
|
|
|
object_class->set_property = meta_startup_sequence_set_property;
|
|
|
|
object_class->get_property = meta_startup_sequence_get_property;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
seq_props[PROP_SEQ_ID] =
|
|
|
|
g_param_spec_string ("id",
|
|
|
|
"ID",
|
|
|
|
"ID",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_TIMESTAMP] =
|
2018-08-22 15:14:31 -04:00
|
|
|
g_param_spec_uint64 ("timestamp",
|
|
|
|
"Timestamp",
|
|
|
|
"Timestamp",
|
|
|
|
0, G_MAXUINT64, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_ICON_NAME] =
|
|
|
|
g_param_spec_string ("icon-name",
|
|
|
|
"Icon name",
|
|
|
|
"Icon name",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_APPLICATION_ID] =
|
|
|
|
g_param_spec_string ("application-id",
|
|
|
|
"Application ID",
|
|
|
|
"Application ID",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_WMCLASS] =
|
|
|
|
g_param_spec_string ("wmclass",
|
|
|
|
"WM class",
|
|
|
|
"WM class",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_WORKSPACE] =
|
|
|
|
g_param_spec_int ("workspace",
|
|
|
|
"Workspace",
|
|
|
|
"Workspace",
|
|
|
|
G_MININT, G_MAXINT, -1,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
seq_props[PROP_SEQ_NAME] =
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
"Name",
|
|
|
|
"Name",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, N_SEQ_PROPS, seq_props);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_get_id (MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequencePrivate *priv;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
priv = meta_startup_sequence_get_instance_private (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
return priv->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint64
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_get_timestamp (MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequencePrivate *priv;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
priv = meta_startup_sequence_get_instance_private (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
return priv->timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_complete (MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequenceClass *klass;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
klass = META_STARTUP_SEQUENCE_GET_CLASS (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
if (klass->complete)
|
|
|
|
klass->complete (seq);
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
void
|
|
|
|
meta_startup_notification_add_sequence (MetaStartupNotification *sn,
|
|
|
|
MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
|
|
|
sn->startup_sequences = g_slist_prepend (sn->startup_sequences,
|
|
|
|
g_object_ref (seq));
|
|
|
|
|
|
|
|
meta_startup_notification_ensure_timeout (sn);
|
|
|
|
meta_startup_notification_update_feedback (sn);
|
2018-08-22 14:57:04 -04:00
|
|
|
|
|
|
|
g_signal_emit (sn, sn_signals[CHANGED], 0, seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
collect_timed_out_foreach (void *element,
|
|
|
|
void *data)
|
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *sequence = element;
|
2016-02-06 08:52:03 -05:00
|
|
|
CollectTimedOutData *ctod = data;
|
|
|
|
gint64 elapsed, timestamp;
|
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
timestamp = meta_startup_sequence_get_timestamp (sequence);
|
2016-02-06 08:52:03 -05:00
|
|
|
elapsed = ctod->now - timestamp;
|
|
|
|
|
|
|
|
meta_topic (META_DEBUG_STARTUP,
|
2016-07-04 16:34:31 -04:00
|
|
|
"Sequence used %" G_GINT64_FORMAT " ms vs. %d max: %s\n",
|
2016-02-06 08:52:03 -05:00
|
|
|
elapsed, STARTUP_TIMEOUT,
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_get_id (sequence));
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
if (elapsed > STARTUP_TIMEOUT)
|
|
|
|
ctod->list = g_slist_prepend (ctod->list, sequence);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
startup_sequence_timeout (void *data)
|
|
|
|
{
|
|
|
|
MetaStartupNotification *sn = data;
|
|
|
|
CollectTimedOutData ctod;
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
ctod.list = NULL;
|
|
|
|
ctod.now = g_get_monotonic_time ();
|
|
|
|
g_slist_foreach (sn->startup_sequences,
|
|
|
|
collect_timed_out_foreach,
|
|
|
|
&ctod);
|
|
|
|
|
|
|
|
for (l = ctod.list; l != NULL; l = l->next)
|
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *sequence = l->data;
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
meta_topic (META_DEBUG_STARTUP,
|
|
|
|
"Timed out sequence %s\n",
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_get_id (sequence));
|
2016-02-06 08:52:03 -05:00
|
|
|
|
2018-08-22 13:06:13 -04:00
|
|
|
meta_startup_sequence_complete (sequence);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (ctod.list);
|
|
|
|
|
|
|
|
if (sn->startup_sequences != NULL)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* remove */
|
|
|
|
sn->startup_sequence_timeout = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_ensure_timeout (MetaStartupNotification *sn)
|
|
|
|
{
|
|
|
|
if (sn->startup_sequence_timeout != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* our timeout just polls every second, instead of bothering
|
|
|
|
* to compute exactly when we may next time out
|
|
|
|
*/
|
|
|
|
sn->startup_sequence_timeout = g_timeout_add_seconds (1,
|
|
|
|
startup_sequence_timeout,
|
|
|
|
sn);
|
|
|
|
g_source_set_name_by_id (sn->startup_sequence_timeout,
|
|
|
|
"[mutter] startup_sequence_timeout");
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
void
|
|
|
|
meta_startup_notification_remove_sequence (MetaStartupNotification *sn,
|
|
|
|
MetaStartupSequence *seq)
|
2016-02-06 08:52:03 -05:00
|
|
|
{
|
|
|
|
sn->startup_sequences = g_slist_remove (sn->startup_sequences, seq);
|
|
|
|
meta_startup_notification_update_feedback (sn);
|
|
|
|
|
|
|
|
if (sn->startup_sequences == NULL &&
|
|
|
|
sn->startup_sequence_timeout != 0)
|
|
|
|
{
|
|
|
|
g_source_remove (sn->startup_sequence_timeout);
|
|
|
|
sn->startup_sequence_timeout = 0;
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
g_signal_emit (sn, sn_signals[CHANGED], 0, seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
g_object_unref (seq);
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
MetaStartupSequence *
|
2016-02-06 08:52:03 -05:00
|
|
|
meta_startup_notification_lookup_sequence (MetaStartupNotification *sn,
|
|
|
|
const gchar *id)
|
|
|
|
{
|
2018-08-22 13:06:13 -04:00
|
|
|
MetaStartupSequence *seq;
|
2016-02-06 08:52:03 -05:00
|
|
|
const gchar *seq_id;
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
for (l = sn->startup_sequences; l; l = l->next)
|
|
|
|
{
|
|
|
|
seq = l->data;
|
2018-08-22 13:06:13 -04:00
|
|
|
seq_id = meta_startup_sequence_get_id (seq);
|
2016-02-06 08:52:03 -05:00
|
|
|
|
|
|
|
if (g_str_equal (seq_id, id))
|
|
|
|
return l->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_init (MetaStartupNotification *sn)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
|
|
|
|
|
|
|
if (sn->startup_sequence_timeout)
|
|
|
|
g_source_remove (sn->startup_sequence_timeout);
|
|
|
|
|
|
|
|
g_slist_foreach (sn->startup_sequences, (GFunc) g_object_unref, NULL);
|
|
|
|
g_slist_free (sn->startup_sequences);
|
|
|
|
sn->startup_sequences = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_startup_notification_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2018-08-22 14:57:04 -04:00
|
|
|
case PROP_DISPLAY:
|
2016-02-06 08:52:03 -05:00
|
|
|
sn->display = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2018-08-22 14:57:04 -04:00
|
|
|
case PROP_DISPLAY:
|
2016-02-06 08:52:03 -05:00
|
|
|
g_value_set_object (value, sn->display);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-26 16:35:18 -04:00
|
|
|
static void
|
|
|
|
meta_startup_notification_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
|
|
|
|
|
|
|
|
g_assert (sn->display != NULL);
|
|
|
|
|
2016-02-06 08:52:03 -05:00
|
|
|
sn->startup_sequences = NULL;
|
|
|
|
sn->startup_sequence_timeout = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_startup_notification_class_init (MetaStartupNotificationClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->constructed = meta_startup_notification_constructed;
|
|
|
|
object_class->finalize = meta_startup_notification_finalize;
|
|
|
|
object_class->set_property = meta_startup_notification_set_property;
|
|
|
|
object_class->get_property = meta_startup_notification_get_property;
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
sn_props[PROP_DISPLAY] =
|
2016-02-06 08:52:03 -05:00
|
|
|
g_param_spec_object ("display",
|
|
|
|
"Display",
|
|
|
|
"Display",
|
|
|
|
META_TYPE_DISPLAY,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
sn_signals[CHANGED] =
|
2016-02-06 08:52:03 -05:00
|
|
|
g_signal_new ("changed",
|
|
|
|
META_TYPE_STARTUP_NOTIFICATION,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
|
|
|
|
2018-08-22 14:57:04 -04:00
|
|
|
g_object_class_install_properties (object_class, N_PROPS, sn_props);
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaStartupNotification *
|
|
|
|
meta_startup_notification_get (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
static MetaStartupNotification *notification = NULL;
|
|
|
|
|
|
|
|
if (!notification)
|
|
|
|
notification = g_object_new (META_TYPE_STARTUP_NOTIFICATION,
|
|
|
|
"display", display,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return notification;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
meta_startup_notification_get_sequences (MetaStartupNotification *sn)
|
|
|
|
{
|
2018-08-22 14:57:04 -04:00
|
|
|
return sn->startup_sequences;
|
2016-02-06 08:52:03 -05:00
|
|
|
}
|