File: test-interactive-multi.c

package info (click to toggle)
gtkhotkey 0.2.1-6
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch
  • size: 2,024 kB
  • ctags: 570
  • sloc: sh: 10,126; ansic: 3,013; xml: 1,035; makefile: 132
file content (85 lines) | stat: -rw-r--r-- 2,374 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * This file is part of GtkHotkey.
 * Copyright Mikkel Kamstrup Erlandsen, March, 2008
 *
 *   GtkHotkey is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   GtkHotkey 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 Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with GtkHotkey.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>

#include "src/gtk-hotkey-info.h"

static void
hotkey_activated_cb (GtkHotkeyInfo *hotkey, guint event_time, gpointer data)
{
	GError	*error;
	
	g_return_if_fail (GTK_HOTKEY_IS_INFO(hotkey));
	
	g_printf ("Hotkey %s activated with event time %d\n",
			  gtk_hotkey_info_get_signature(hotkey), event_time);
}

int
main (int argc, char *argv[])
{
	GError *error;
	GtkHotkeyInfo   *hot;
	
	gtk_init (&argc, &argv);
	
	/* Hotkey 1 */
	hot = gtk_hotkey_info_new ("gtkhotkey-test", "gtkhotkey-test-key-1",
							   "<Super>1", NULL);
	error = NULL;
	gtk_hotkey_info_bind (hot, &error);
	if (error) {
		g_critical ("Got error: %s", error->message);
		g_error_free (error);
	}	
	g_signal_connect (hot, "activated", G_CALLBACK(hotkey_activated_cb), NULL);
	
	/* Hotkey 2 */
	hot = gtk_hotkey_info_new ("gtkhotkey-test", "gtkhotkey-test-key-2",
							   "<Super>2", NULL);
	error = NULL;
	gtk_hotkey_info_bind (hot, &error);
	if (error) {
		g_critical ("Got error: %s", error->message);
		g_error_free (error);
	}	
	g_signal_connect (hot, "activated", G_CALLBACK(hotkey_activated_cb), NULL);
	
	/* Hotkey 3 */
	hot = gtk_hotkey_info_new ("gtkhotkey-test", "gtkhotkey-test-key-3",
							   "<Super>3", NULL);
	error = NULL;
	gtk_hotkey_info_bind (hot, &error);
	if (error) {
		g_critical ("Got error: %s", error->message);
		g_error_free (error);
	}	
	g_signal_connect (hot, "activated", G_CALLBACK(hotkey_activated_cb), NULL);
	
	g_printf ("Interactive test ready\n");
	
	gtk_main();
	
	return 0;
}