File: com_gtk.c

package info (click to toggle)
xoscope 2.0-3.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,764 kB
  • ctags: 1,110
  • sloc: ansic: 9,820; sh: 3,369; makefile: 86; perl: 42
file content (58 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (2)
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
/*
 * @(#)$Id: com_gtk.c,v 2.4 2009/01/07 02:19:03 baccala Exp $
 *
 * Copyright (C) 1996 - 2000 Tim Witham <twitham@quiknet.com>
 *
 * (see the files README and COPYING for more details)
 *
 * This file holds GTK code that is common to xoscope and xy.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

#include "oscope.h"
#include "display.h"
#include "com_gtk.h"

GdkPixmap *pixmap = NULL;
int fixing_widgets = 0;

/* emulate several libsx function in GTK */
int
OpenDisplay(int argc, char *argv[])
{
  gtk_init(&argc, &argv);
  return(argc);
}

/* set up some common event handlers */

void
delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
  gtk_main_quit ();
}

gint
key_press_event(GtkWidget *widget, GdkEventKey *event)
{
  if (event->keyval == GDK_Tab) {
    handle_key('\t');
  } else if (event->length == 1) {
    handle_key(event->string[0]);
  }

  return TRUE;
}

/* simple event callback that emulates the user hitting the given key */
void
hit_key(GtkWidget *w, guint data)
{
  if (fixing_widgets) return;
  handle_key(data);
}