Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
squeekboard
Commits
6137b7e1
Commit
6137b7e1
authored
Jan 31, 2011
by
Daiki Ueno
Browse files
Add a sample program eek-example-xml.
parent
a7b276c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/Makefile.am
View file @
6137b7e1
...
...
@@ -19,7 +19,8 @@
INCLUDES
=
-I
$(top_srcdir)
$(GIO2_CFLAGS)
$(GTK_CFLAGS)
$(XKB_CFLAGS)
TESTS
=
eek-simple-test eek-xkb-test eek-xml-test
noinst_PROGRAMS
=
$(TESTS)
SAMPLES
=
eek-example-xml
noinst_PROGRAMS
=
$(TESTS)
$(SAMPLES)
eek_simple_test_SOURCES
=
eek-simple-test.c
eek_simple_test_LDADD
=
$(top_builddir)
/eek/libeek.la
...
...
@@ -29,3 +30,6 @@ eek_xkb_test_LDADD = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xk
eek_xml_test_SOURCES
=
eek-xml-test.c
eek_xml_test_LDADD
=
$(top_builddir)
/eek/libeek.la
$(top_builddir)
/eek/libeek-xkl.la
eek_example_xml_SOURCES
=
eek-example-xml.c
eek_example_xml_LDADD
=
$(top_builddir)
/eek/libeek.la
$(top_builddir)
/eek/libeek-xkl.la
$(top_builddir)
/eek/libeek-gtk.la
tests/eek-example-xml.c
0 → 100644
View file @
6137b7e1
/*
* Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2011 Red Hat, Inc.
*
* This library 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 2 of
* the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* HAVE_CONFIG_H */
#include "eek/eek-xml.h"
#include "eek/eek-xkl.h"
#include "eek/eek-gtk.h"
#define BUFSIZE 8192
static
gchar
*
opt_load
=
NULL
;
static
gboolean
opt_dump
=
FALSE
;
static
const
GOptionEntry
options
[]
=
{
{
"load"
,
'l'
,
0
,
G_OPTION_ARG_STRING
,
&
opt_load
,
"Show the keyboard loaded from an XML file"
},
{
"dump"
,
'd'
,
0
,
G_OPTION_ARG_NONE
,
&
opt_dump
,
"Dump the current layout as XML"
},
{
NULL
}
};
static
void
on_destroy
(
gpointer
user_data
)
{
gtk_main_quit
();
}
int
main
(
int
argc
,
char
**
argv
)
{
GOptionContext
*
context
;
if
(
!
gtk_init_check
(
&
argc
,
&
argv
))
{
g_printerr
(
"Can't init GTK
\n
"
);
exit
(
1
);
}
context
=
g_option_context_new
(
"eek-example-xml"
);
g_option_context_add_main_entries
(
context
,
options
,
NULL
);
g_option_context_parse
(
context
,
&
argc
,
&
argv
,
NULL
);
g_option_context_free
(
context
);
if
(
opt_load
)
{
GFile
*
file
;
GFileInputStream
*
input
;
EekLayout
*
layout
;
EekKeyboard
*
keyboard
;
EekBounds
bounds
;
GtkWidget
*
widget
,
*
window
;
GError
*
error
;
file
=
g_file_new_for_path
(
opt_load
);
error
=
NULL
;
input
=
g_file_read
(
file
,
NULL
,
&
error
);
if
(
error
)
{
g_printerr
(
"Can't read file %s: %s
\n
"
,
opt_load
,
error
->
message
);
exit
(
1
);
}
layout
=
eek_xml_layout_new
(
G_INPUT_STREAM
(
input
));
g_object_unref
(
input
);
keyboard
=
eek_keyboard_new
(
layout
,
640
,
480
);
g_object_unref
(
layout
);
widget
=
eek_gtk_keyboard_new
(
keyboard
);
g_object_unref
(
keyboard
);
eek_element_get_bounds
(
EEK_ELEMENT
(
keyboard
),
&
bounds
);
gtk_widget_set_size_request
(
widget
,
bounds
.
width
,
bounds
.
height
);
window
=
gtk_window_new
(
GTK_WINDOW_TOPLEVEL
);
gtk_container_add
(
GTK_CONTAINER
(
window
),
widget
);
gtk_widget_show_all
(
window
);
g_signal_connect
(
G_OBJECT
(
window
),
"destroy"
,
G_CALLBACK
(
on_destroy
),
NULL
);
gtk_main
();
exit
(
0
);
}
else
if
(
opt_dump
)
{
GString
*
output
;
EekLayout
*
layout
;
EekKeyboard
*
keyboard
;
output
=
g_string_sized_new
(
BUFSIZE
);
layout
=
eek_xkl_layout_new
();
keyboard
=
eek_keyboard_new
(
layout
,
640
,
480
);
g_object_unref
(
layout
);
eek_keyboard_output
(
keyboard
,
output
,
0
);
g_object_unref
(
keyboard
);
fwrite
(
output
->
str
,
sizeof
(
gchar
),
output
->
len
,
stdout
);
g_string_free
(
output
,
TRUE
);
exit
(
0
);
}
else
{
g_printerr
(
"Specify -l or -d option
\n
"
);
exit
(
1
);
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment