~elementary-os/ubuntu-package-imports/mutter-bionic

« back to all changes in this revision

Viewing changes to src/core/meta-inhibit-shortcuts-dialog-default.c

  • Committer: RabbitBot
  • Date: 2018-04-11 14:49:36 UTC
  • Revision ID: rabbitbot@elementary.io-20180411144936-hgymqa9d8d1xfpbh
Initial import, version 3.28.0-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001, 2002 Havoc Pennington
 
3
 * Copyright (C) 2004 Elijah Newren
 
4
 * Copyright (C) 2017 Red Hat
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License as
 
8
 * published by the Free Software Foundation; either version 2 of the
 
9
 * License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
 
 
23
#include "util-private.h"
 
24
#include "window-private.h"
 
25
#include "meta/meta-inhibit-shortcuts-dialog.h"
 
26
#include "meta-inhibit-shortcuts-dialog-default-private.h"
 
27
 
 
28
typedef struct _MetaInhibitShortcutsDialogDefaultPrivate MetaInhibitShortcutsDialogDefaultPrivate;
 
29
 
 
30
struct _MetaInhibitShortcutsDialogDefault
 
31
{
 
32
  GObject parent_instance;
 
33
  MetaWindow *window;
 
34
};
 
35
 
 
36
enum {
 
37
  PROP_0,
 
38
  PROP_WINDOW,
 
39
  N_PROPS
 
40
};
 
41
 
 
42
static void meta_inhibit_shortcuts_dialog_iface_init (MetaInhibitShortcutsDialogInterface *iface);
 
43
 
 
44
G_DEFINE_TYPE_WITH_CODE (MetaInhibitShortcutsDialogDefault, meta_inhibit_shortcuts_dialog_default,
 
45
                         G_TYPE_OBJECT,
 
46
                         G_IMPLEMENT_INTERFACE (META_TYPE_INHIBIT_SHORTCUTS_DIALOG,
 
47
                                                meta_inhibit_shortcuts_dialog_iface_init))
 
48
 
 
49
static void
 
50
meta_inhibit_shortcuts_dialog_default_show (MetaInhibitShortcutsDialog *dialog)
 
51
{
 
52
  /* Default to allow shortcuts inhibitor, but complain that no dialog is implemented */
 
53
  g_warning ("No MetaInhibitShortcutDialog implementation, falling back on allowing");
 
54
  meta_inhibit_shortcuts_dialog_response (dialog, META_INHIBIT_SHORTCUTS_DIALOG_RESPONSE_ALLOW);
 
55
}
 
56
 
 
57
static void
 
58
meta_inhibit_shortcuts_dialog_default_hide (MetaInhibitShortcutsDialog *dialog)
 
59
{
 
60
}
 
61
 
 
62
static void
 
63
meta_inhibit_shortcuts_dialog_iface_init (MetaInhibitShortcutsDialogInterface *iface)
 
64
{
 
65
  iface->show = meta_inhibit_shortcuts_dialog_default_show;
 
66
  iface->hide = meta_inhibit_shortcuts_dialog_default_hide;
 
67
}
 
68
 
 
69
static void
 
70
meta_inhibit_shortcuts_dialog_default_set_property (GObject      *object,
 
71
                                                    guint         prop_id,
 
72
                                                    const GValue *value,
 
73
                                                    GParamSpec   *pspec)
 
74
{
 
75
  MetaInhibitShortcutsDialogDefault *dialog;
 
76
 
 
77
  dialog = META_INHIBIT_SHORTCUTS_DIALOG_DEFAULT (object);
 
78
 
 
79
  switch (prop_id)
 
80
    {
 
81
    case PROP_WINDOW:
 
82
      dialog->window = g_value_get_object (value);
 
83
      break;
 
84
    default:
 
85
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
86
    }
 
87
}
 
88
 
 
89
static void
 
90
meta_inhibit_shortcuts_dialog_default_get_property (GObject    *object,
 
91
                                                    guint       prop_id,
 
92
                                                    GValue     *value,
 
93
                                                    GParamSpec *pspec)
 
94
{
 
95
  MetaInhibitShortcutsDialogDefault *dialog;
 
96
 
 
97
  dialog = META_INHIBIT_SHORTCUTS_DIALOG_DEFAULT (object);
 
98
 
 
99
  switch (prop_id)
 
100
    {
 
101
    case PROP_WINDOW:
 
102
      g_value_set_object (value, dialog->window);
 
103
      break;
 
104
    default:
 
105
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
106
    }
 
107
}
 
108
 
 
109
static void
 
110
meta_inhibit_shortcuts_dialog_default_class_init (MetaInhibitShortcutsDialogDefaultClass *klass)
 
111
{
 
112
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
113
 
 
114
  object_class->set_property = meta_inhibit_shortcuts_dialog_default_set_property;
 
115
  object_class->get_property = meta_inhibit_shortcuts_dialog_default_get_property;
 
116
 
 
117
  g_object_class_override_property (object_class, PROP_WINDOW, "window");
 
118
}
 
119
 
 
120
static void
 
121
meta_inhibit_shortcuts_dialog_default_init (MetaInhibitShortcutsDialogDefault *dialog)
 
122
{
 
123
}
 
124
 
 
125
MetaInhibitShortcutsDialog *
 
126
meta_inhibit_shortcuts_dialog_default_new (MetaWindow *window)
 
127
{
 
128
  return g_object_new (META_TYPE_INHIBIT_SHORTCUTS_DIALOG_DEFAULT,
 
129
                       "window", window,
 
130
                       NULL);
 
131
}