~ubuntu-branches/debian/sid/guake/sid

« back to all changes in this revision

Viewing changes to src/guake/globalhotkeys/testbinding.c

  • Committer: Package Import Robot
  • Author(s): Daniel Echeverry
  • Date: 2015-04-26 19:15:06 UTC
  • mfrom: (1.1.7)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20150426191506-mo8037vk6pueer5b
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
18
 */
 
19
 
 
20
#include <stdio.h>
 
21
#include <stdlib.h>
 
22
#include <string.h>
 
23
#include "keybinder.h"
 
24
 
 
25
#include <gtk/gtk.h>
 
26
 
 
27
typedef struct _BindedKey BindedKey;
 
28
struct _BindedKey
 
29
{
 
30
  char *key;
 
31
  void *callback;
 
32
};
 
33
 
 
34
void
 
35
handler (char *keystring, gpointer user_data)
 
36
{
 
37
  printf ("binded key: %s\n", keystring);
 
38
}
 
39
 
 
40
void
 
41
unbind (GtkWidget *bnt, BindedKey *b)
 
42
{
 
43
  keybinder_unbind (b->key, b->callback);
 
44
  printf ("unbinded\n");
 
45
}
 
46
 
 
47
int
 
48
main (int argc, char **argv)
 
49
{
 
50
  GtkWidget *window;
 
51
  GtkWidget *label;
 
52
  GtkWidget *vbox;
 
53
  GtkWidget *button;
 
54
  BindedKey *binded = malloc (sizeof (BindedKey *));
 
55
 
 
56
  gtk_init (&argc, &argv);
 
57
 
 
58
  binded->key = strdup ("<Ctrl><Alt>e");
 
59
  binded->callback = handler;
 
60
 
 
61
  keybinder_bind ("<Ctrl><Alt>e", handler, NULL);
 
62
  keybinder_init ();
 
63
 
 
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);
 
69
 
 
70
  label = gtk_label_new (NULL);
 
71
  gtk_label_set_markup (GTK_LABEL (label),
 
72
      "<big>Pres <b>&lt;Ctrl&gt;&lt;Alt&gt;e</b> and "
 
73
      "see what is happening in your terminal =D</big>");
 
74
 
 
75
  button = gtk_button_new_with_label ("Unbind Key!");
 
76
  g_signal_connect (G_OBJECT (button), "clicked",  G_CALLBACK (unbind),
 
77
      binded);
 
78
 
 
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);
 
82
 
 
83
  gtk_container_add (GTK_CONTAINER (window), vbox);
 
84
 
 
85
  gtk_widget_show_all (window);
 
86
  gtk_main ();
 
87
 
 
88
  return 0;
 
89
}