1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 */
23
24 #include "config.h"
25
26 #include <stdlib.h>
27
28 #include <glib/gi18n.h>
29 #include <gtk/gtk.h>
30
31 #include "msd-media-keys-window.h"
32
33 static gboolean
update_state(GtkWidget * window)34 update_state (GtkWidget *window)
35 {
36 static int count = 0;
37
38 count++;
39
40 switch (count) {
41 case 1:
42 msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (window),
43 50);
44 msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (window),
45 MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
46
47 gtk_widget_show (window);
48 break;
49 case 2:
50 msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (window),
51 100);
52 msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (window),
53 MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
54
55 gtk_widget_show (window);
56 break;
57 case 3:
58 msd_media_keys_window_set_volume_muted (MSD_MEDIA_KEYS_WINDOW (window),
59 TRUE);
60 msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (window),
61 MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
62
63 gtk_widget_show (window);
64 break;
65 case 4:
66 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
67 "media-eject",
68 NULL);
69
70 gtk_widget_show (window);
71 break;
72 case 5:
73 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
74 "touchpad-disabled",
75 _("Touchpad disabled"));
76
77 gtk_widget_show (window);
78 break;
79 case 6:
80 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
81 "input-touchpad",
82 _("Touchpad enabled"));
83
84 gtk_widget_show (window);
85 break;
86 case 7:
87 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
88 "bluetooth-disabled-symbolic",
89 _("Bluetooth disabled"));
90
91 gtk_widget_show (window);
92 break;
93 case 8:
94 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
95 "bluetooth-active-symbolic",
96 _("Bluetooth enabled"));
97
98 gtk_widget_show (window);
99 break;
100 case 9:
101 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
102 "airplane-mode-symbolic",
103 _("Airplane mode enabled"));
104
105 gtk_widget_show (window);
106 break;
107 case 10:
108 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
109 "network-wireless-signal-excellent-symbolic",
110 _("Airplane mode disabled"));
111
112 gtk_widget_show (window);
113 break;
114 case 11:
115 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
116 "video-single-display-symbolic",
117 _("No External Display"));
118
119 gtk_widget_show (window);
120 break;
121 case 12:
122 msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window),
123 "video-joined-displays-symbolic",
124 _("Changing Screen Layout"));
125
126 gtk_widget_show (window);
127 break;
128 default:
129 gtk_main_quit ();
130 break;
131 }
132
133 return TRUE;
134 }
135
136 static void
test_window(void)137 test_window (void)
138 {
139 GtkWidget *window;
140
141 window = msd_media_keys_window_new ();
142 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
143
144 msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (window),
145 0);
146 msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (window),
147 MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
148
149 gtk_widget_show (window);
150
151 g_timeout_add (3000, (GSourceFunc) update_state, window);
152 }
153
154 int
main(int argc,char ** argv)155 main (int argc,
156 char **argv)
157 {
158 GError *error = NULL;
159
160 #ifdef ENABLE_NLS
161 bindtextdomain (GETTEXT_PACKAGE, MATE_SETTINGS_LOCALEDIR);
162 # ifdef HAVE_BIND_TEXTDOMAIN_CODESET
163 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
164 # endif
165 textdomain (GETTEXT_PACKAGE);
166 #endif
167
168 if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error)) {
169 fprintf (stderr, "%s", error->message);
170 g_error_free (error);
171 exit (1);
172 }
173
174 test_window ();
175
176 gtk_main ();
177
178 return 0;
179 }
180