~ubuntu-branches/ubuntu/trusty/unity-control-center/trusty

« back to all changes in this revision

Viewing changes to panels/wacom/test-wacom.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-01-08 16:29:18 UTC
  • Revision ID: package-import@ubuntu.com-20140108162918-g29dd08tr913y2qh
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "config.h"
 
3
 
 
4
#include <glib/gi18n.h>
 
5
 
 
6
#include "cc-wacom-page.h"
 
7
#include "gsd-wacom-device.h"
 
8
 
 
9
#define FIXED_WIDTH 675
 
10
 
 
11
void
 
12
cc_wacom_panel_switch_to_panel (CcWacomPanel *self, const char *panel)
 
13
{
 
14
        g_message ("Should launch display preferences here");
 
15
}
 
16
 
 
17
static void
 
18
add_page (GList *devices,
 
19
          GtkWidget *notebook)
 
20
{
 
21
        GtkWidget *widget;
 
22
        GsdWacomDevice *stylus, *eraser, *pad;
 
23
        GList *l;
 
24
 
 
25
        if (devices == NULL)
 
26
                return;
 
27
 
 
28
        stylus = eraser = pad = NULL;
 
29
        for (l = devices; l ; l = l->next) {
 
30
                switch (gsd_wacom_device_get_device_type (l->data)) {
 
31
                case WACOM_TYPE_ERASER:
 
32
                        eraser = l->data;
 
33
                        break;
 
34
                case WACOM_TYPE_STYLUS:
 
35
                        stylus = l->data;
 
36
                        break;
 
37
                case WACOM_TYPE_PAD:
 
38
                        pad = l->data;
 
39
                        break;
 
40
                default:
 
41
                        /* Nothing */
 
42
                        ;
 
43
                }
 
44
        }
 
45
        g_list_free (devices);
 
46
 
 
47
        widget = cc_wacom_page_new (NULL, stylus, eraser, pad);
 
48
        cc_wacom_page_set_navigation (CC_WACOM_PAGE (widget), GTK_NOTEBOOK (notebook), FALSE);
 
49
        gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, NULL);
 
50
        gtk_widget_show (widget);
 
51
}
 
52
 
 
53
static gboolean
 
54
delete_event_cb (GtkWidget *widget,
 
55
                 GdkEvent  *event,
 
56
                 gpointer   user_data)
 
57
{
 
58
        gtk_main_quit ();
 
59
 
 
60
        return FALSE;
 
61
}
 
62
 
 
63
int main (int argc, char **argv)
 
64
{
 
65
        GtkWidget *window, *notebook;
 
66
        GList *devices;
 
67
 
 
68
        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
69
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
70
        textdomain (GETTEXT_PACKAGE);
 
71
 
 
72
        gtk_init (&argc, &argv);
 
73
 
 
74
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
75
        gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
 
76
        gtk_widget_set_size_request (window, FIXED_WIDTH, -1);
 
77
        g_signal_connect (G_OBJECT (window), "delete-event",
 
78
                          G_CALLBACK (delete_event_cb), NULL);
 
79
        notebook = gtk_notebook_new ();
 
80
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
 
81
        gtk_widget_set_vexpand (notebook, TRUE);
 
82
        gtk_container_set_border_width (GTK_CONTAINER (notebook), 24);
 
83
        gtk_container_add (GTK_CONTAINER (window), notebook);
 
84
        gtk_widget_show (notebook);
 
85
 
 
86
        devices = gsd_wacom_device_create_fake_intuos4 ();
 
87
        add_page (devices, notebook);
 
88
 
 
89
        devices = gsd_wacom_device_create_fake_cintiq ();
 
90
        add_page (devices, notebook);
 
91
 
 
92
        devices = gsd_wacom_device_create_fake_bt ();
 
93
        add_page (devices, notebook);
 
94
 
 
95
        devices = gsd_wacom_device_create_fake_x201 ();
 
96
        add_page (devices, notebook);
 
97
 
 
98
        gtk_widget_show (window);
 
99
 
 
100
        gtk_main ();
 
101
 
 
102
        return 0;
 
103
}