2
* Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program 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
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301 USA
23
#include "keybinder.h"
27
typedef struct _BindedKey BindedKey;
35
handler (char *keystring, gpointer user_data)
37
printf ("binded key: %s\n", keystring);
41
unbind (GtkWidget *bnt, BindedKey *b)
43
keybinder_unbind (b->key, b->callback);
44
printf ("unbinded\n");
48
main (int argc, char **argv)
54
BindedKey *binded = malloc (sizeof (BindedKey *));
56
gtk_init (&argc, &argv);
58
binded->key = strdup ("<Ctrl><Alt>e");
59
binded->callback = handler;
61
keybinder_bind ("<Ctrl><Alt>e", handler, NULL);
64
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
65
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
66
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
67
g_signal_connect (G_OBJECT (window), "delete_event",
68
G_CALLBACK (exit), 0);
70
label = gtk_label_new (NULL);
71
gtk_label_set_markup (GTK_LABEL (label),
72
"<big>Pres <b><Ctrl><Alt>e</b> and "
73
"see what is happening in your terminal =D</big>");
75
button = gtk_button_new_with_label ("Unbind Key!");
76
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (unbind),
79
vbox = gtk_vbox_new (1, 10);
80
gtk_box_pack_start (GTK_BOX (vbox), label, 1, 1, 0);
81
gtk_box_pack_start (GTK_BOX (vbox), button, 1, 1, 0);
83
gtk_container_add (GTK_CONTAINER (window), vbox);
85
gtk_widget_show_all (window);