diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-01-31 23:09:30 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-01-31 23:09:30 +0900 |
commit | 2d187a02033d7980202b44d9f6b4b0a4d185a60b (patch) | |
tree | d4963d45c84a2c5cb7705c69bdcc71a40acce107 /gtk | |
parent | 3dd0c134f0f0d1dcf467897fc23de4e072878dcb (diff) |
added color palette support (ctrl-f1 - ctrl-f10)
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -425,6 +425,20 @@ static void destroynothing(gpointer p) { (void)p; } +static gboolean key_press_cb(GtkWidget *w, + GdkEvent *e, + gpointer ptr) { + (void)w; + (void)ptr; + if (GDK_KEY_F1 <= e->key.keyval && e->key.keyval <= GDK_KEY_F10) { + if (e->key.state & GDK_CONTROL_MASK) { + fmdsp_palette_set(&g.fmdsp, e->key.keyval - GDK_KEY_F1); + return TRUE; + } + } + return FALSE; +} + int main(int argc, char **argv) { load_fontrom(); gtk_init(&argc, &argv); @@ -472,7 +486,9 @@ int main(int argc, char **argv) { fmdsp_vram_init(&g.fmdsp, &g.work, g.vram); g.vram32_stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, PC98_W); g.vram32 = malloc((g.vram32_stride*PC98_H)*4); - + + g_signal_connect(w, "key-press-event", G_CALLBACK(key_press_cb), 0); + gtk_widget_add_events(w, GDK_KEY_PRESS_MASK); gtk_widget_show_all(w); gtk_widget_add_tick_callback(w, tick_cb, drawarea, destroynothing); gtk_main(); |