Skip to content

Commit

Permalink
Added InputPadGtkViewport for many unicode tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwarat committed Sep 12, 2014
1 parent ece093d commit 8f897da
Show file tree
Hide file tree
Showing 6 changed files with 617 additions and 70 deletions.
2 changes: 2 additions & 0 deletions input-pad/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ libinput_pad_1_0_la_SOURCES = \
parse-pad.c \
resources.c \
unicode_block.h \
viewport-gtk.c \
viewport-gtk.h \
window-gtk.c \
$(NULL)

Expand Down
47 changes: 47 additions & 0 deletions input-pad/button-gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct _InputPadGtkButtonPrivate {
gchar *rawtext;
InputPadTableType type;
guint32 timer;
guint32 unicode;
};

static guint signals[LAST_SIGNAL] = { 0 };
Expand Down Expand Up @@ -335,9 +336,55 @@ input_pad_gtk_button_new_with_unicode (guint code)
input_pad_gtk_button_set_table_type (INPUT_PAD_GTK_BUTTON (button),
INPUT_PAD_TABLE_TYPE_CHARS);

INPUT_PAD_GTK_BUTTON (button)->priv->unicode = code;
return button;
}

guint
input_pad_gtk_button_get_unicode (InputPadGtkButton *button)
{
g_return_val_if_fail (button != NULL &&
INPUT_PAD_IS_GTK_BUTTON (button), 0x0);

return button->priv->unicode;
}

void
input_pad_gtk_button_set_unicode (InputPadGtkButton *button, guint code)
{
gchar buff[7];
gchar buff2[35];
gchar *tooltip;
int i;

if (code == '\t') {
buff[0] = ' ';
buff[1] = '\0';
sprintf (buff2, "0x%02X ", (unsigned char) code);
} else {
buff[g_unichar_to_utf8 ((gunichar) code, buff)] = '\0';
for (i = 0; buff[i] && i < 7; i++) {
sprintf (buff2 + i * 5, "0x%02X ", (unsigned char) buff[i]);
}
if (buff[0] == '\0') {
buff2[0] = '0'; buff2[0] = 'x'; buff2[1] = '0'; buff2[2] = '0';
buff2[3] = '\0';
}
}

input_pad_gtk_button_set_label (button, buff);
if (code == '\t') {
input_pad_gtk_button_set_keysym (button,
code);
}
tooltip = g_strdup_printf ("U+%04X\nUTF-8 %s", code, buff2);
gtk_widget_set_tooltip_text (GTK_WIDGET (button), tooltip);
g_free (tooltip);
input_pad_gtk_button_set_table_type (button,
INPUT_PAD_TABLE_TYPE_CHARS);
button->priv->unicode = code;
}

guint
input_pad_gtk_button_get_keycode (InputPadGtkButton *button)
{
Expand Down
5 changes: 5 additions & 0 deletions input-pad/button-gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ GtkWidget * input_pad_gtk_button_new_with_label_size
(const gchar *label,
int icon_size);
GtkWidget * input_pad_gtk_button_new_with_unicode (guint code);
void input_pad_gtk_button_set_unicode
(InputPadGtkButton *button,
guint code);
guint input_pad_gtk_button_get_unicode
(InputPadGtkButton *button);
guint input_pad_gtk_button_get_keycode
(InputPadGtkButton *button);
void input_pad_gtk_button_set_keycode
Expand Down
Loading

0 comments on commit 8f897da

Please sign in to comment.