GCC Code Coverage Report


Directory: ./
File: shell/cc-shell.c
Date: 2024-05-04 07:58:27
Exec Total Coverage
Lines: 8 27 29.6%
Functions: 3 6 50.0%
Branches: 12 48 25.0%

Line Branch Exec Source
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *
3 * Copyright (c) 2010 Intel, Inc.
4 *
5 * The Control Center is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * The Control Center is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with the Control Center; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Author: Thomas Wood <thos@gnome.org>
20 */
21
22 /**
23 * SECTION:cc-shell
24 * @short_description: Interface representing the Control Center shell
25 *
26 * CcShell is an interface that represents an instance of a control
27 * center shell. It provides access to some of the properties of the shell
28 * that panels will need to read or change. When a panel is created it has an
29 * instance of CcShell available that represents the current shell.
30 */
31
32
33 #include "cc-shell.h"
34 #include "cc-panel.h"
35
36
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 45 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 45 times.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
46 G_DEFINE_INTERFACE (CcShell, cc_shell, GTK_TYPE_WIDGET)
37
38 static void
39 1 cc_shell_default_init (CcShellInterface *iface)
40 {
41 1 g_object_interface_install_property (iface,
42 g_param_spec_object ("active-panel",
43 "active panel",
44 "The currently active Panel",
45 CC_TYPE_PANEL,
46 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
47 1 }
48
49 /**
50 * cc_shell_get_active_panel:
51 * @shell: A #CcShell
52 *
53 * Get the current active panel
54 *
55 * Returns: a #CcPanel or NULL if no panel is active
56 */
57 CcPanel *
58 cc_shell_get_active_panel (CcShell *shell)
59 {
60 CcPanel *panel = NULL;
61
62 g_return_val_if_fail (CC_IS_SHELL (shell), NULL);
63
64 g_object_get (shell, "active-panel", &panel, NULL);
65
66 return panel;
67 }
68
69 /**
70 * cc_shell_set_active_panel:
71 * @shell: A #CcShell
72 * @panel: A #CcPanel
73 *
74 * Set the current active panel. If @panel is NULL, then the shell is returned
75 * to a state where no panel is being displayed (for example, the list of panels
76 * may be shown instead).
77 *
78 */
79 void
80 11 cc_shell_set_active_panel (CcShell *shell,
81 CcPanel *panel)
82 {
83
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
11 g_return_if_fail (CC_IS_SHELL (shell));
84
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
11 g_return_if_fail (panel == NULL || CC_IS_PANEL (panel));
85
86 11 g_object_set (shell, "active-panel", panel, NULL);
87 }
88
89 /**
90 * cc_shell_set_active_panel_from_id:
91 * @shell: A #CcShell
92 * @id: The ID of the panel to set as active
93 * @parameters: A #GVariant with additional parameters
94 * @error: A #GError
95 *
96 * Find a panel corresponding to the specified id and set it as active.
97 *
98 * Returns: #TRUE if the panel was found and set as the active panel
99 */
100 gboolean
101 cc_shell_set_active_panel_from_id (CcShell *shell,
102 const gchar *id,
103 GVariant *parameters,
104 GError **error)
105 {
106 CcShellInterface *iface;
107
108 g_return_val_if_fail (CC_IS_SHELL (shell), FALSE);
109
110 iface = CC_SHELL_GET_IFACE (shell);
111
112 if (!iface->set_active_panel_from_id)
113 {
114 g_warning ("Object of type \"%s\" does not implement required interface"
115 " method \"set_active_panel_from_id\",",
116 G_OBJECT_TYPE_NAME (shell));
117 return FALSE;
118 }
119 else
120 {
121 return iface->set_active_panel_from_id (shell, id, parameters, error);
122 }
123 }
124
125 /**
126 * cc_shell_get_toplevel:
127 * @shell: A #CcShell
128 *
129 * Gets the toplevel window of the shell.
130 *
131 * Returns: The #GtkWidget of the shell window, or #NULL on error.
132 */
133 GtkWidget *
134 cc_shell_get_toplevel (CcShell *shell)
135 {
136 CcShellInterface *iface;
137
138 g_return_val_if_fail (CC_IS_SHELL (shell), NULL);
139
140 iface = CC_SHELL_GET_IFACE (shell);
141
142 if (iface->get_toplevel)
143 {
144 return iface->get_toplevel (shell);
145 }
146
147 g_warning ("Object of type \"%s\" does not implement required interface"
148 " method \"get_toplevel\",",
149 G_OBJECT_TYPE_NAME (shell));
150
151 return NULL;
152 }
153