GTK+2 panel 

GTK+2 panel Git Source Tree

Root/libgpwidgets/gpw-show-desktop.c

1/* Gtk2Panel - A bleeding edge Gtk+2 panel
2 * Copyright (C) 2009 Nicola Fontana <ntd at entidi.it>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21/**
22 * SECTION:gpw-show-desktop
23 * @title: GpwShowDesktop
24 * @short_description: A #GtkToggleAction based on libwnck providing
25 * the ability to show / hide the windows on the screen
26 *
27 * GpwShowDesktop is a GtkToggleAction that provides the ability to show
28 * or hide the desktop using the libwnck APIs.
29 **/
30
31/**
32 * GpwShowDesktop:
33 *
34 * All fields are private and should not be used directly.
35 * Use its public methods instead.
36 **/
37
38
39#include "gpw-wnck.h"
40#include "gpw-show-desktop.h"
41#include "gpw-show-desktop-private.h"
42
43
44static void toggled (GtkToggleAction *toggle_action);
45
46
47G_DEFINE_TYPE(GpwShowDesktop, gpw_show_desktop, GTK_TYPE_TOGGLE_ACTION);
48
49
50static void
51gpw_show_desktop_class_init(GpwShowDesktopClass *klass)
52{
53 GtkToggleActionClass *toggle_action_class;
54
55 toggle_action_class = (GtkToggleActionClass *) klass;
56
57 g_type_class_add_private(klass, sizeof(GpwShowDesktopPrivate));
58
59 toggle_action_class->toggled = toggled;
60}
61
62static void
63gpw_show_desktop_init(GpwShowDesktop *show_desktop)
64{
65 GpwShowDesktopPrivate *data;
66
67 data = G_TYPE_INSTANCE_GET_PRIVATE(show_desktop, GPW_TYPE_SHOW_DESKTOP,
68 GpwShowDesktopPrivate);
69
70 data->dummy = 0;
71
72 show_desktop->data = data;
73}
74
75static void
76toggled(GtkToggleAction *toggle_action)
77{
78 WnckScreen *screen;
79 gboolean to_hide;
80
81 screen = wnck_screen_get_default();
82 wnck_screen_force_update(screen);
83 to_hide = gtk_toggle_action_get_active(toggle_action);
84
85 /* TODO: make a per-desktop flag and use the last state as default */
86 wnck_screen_toggle_showing_desktop(screen, to_hide);
87}

Archive Download this file

Branches

Tags