Fix GSEAL_ENABLE errors for src/pianokeyboard.c.

This commit is contained in:
Johannes Maibaum 2016-09-11 21:15:13 +02:00
parent 6d5bbaca0a
commit f57e31dba5
2 changed files with 16 additions and 10 deletions

View File

@ -38,7 +38,7 @@ project(jack-keyboard)
add_executable(jack-keyboard src/jack-keyboard src/pianokeyboard) add_executable(jack-keyboard src/jack-keyboard src/pianokeyboard)
find_package(GTK2 2.18 REQUIRED gtk) find_package(GTK2 2.20 REQUIRED gtk)
include_directories(${GTK2_INCLUDE_DIRS}) include_directories(${GTK2_INCLUDE_DIRS})
target_link_libraries(jack-keyboard ${GTK2_LIBRARIES}) target_link_libraries(jack-keyboard ${GTK2_LIBRARIES})

View File

@ -89,6 +89,7 @@ draw_note(PianoKeyboard *pk, int note)
GdkColor white = {0, 65535, 65535, 65535}; GdkColor white = {0, 65535, 65535, 65535};
GtkWidget *widget; GtkWidget *widget;
GtkAllocation allocation;
is_white = pk->notes[note].white; is_white = pk->notes[note].white;
@ -129,9 +130,10 @@ draw_note(PianoKeyboard *pk, int note)
* that didn't work. * that didn't work.
*/ */
widget = GTK_WIDGET(pk); widget = GTK_WIDGET(pk);
gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, gtk_widget_get_allocation(widget, &allocation);
widget, NULL, pk->widget_margin, 0, widget->allocation.width - pk->widget_margin * 2 + 1, gtk_paint_shadow(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
widget->allocation.height); widget, NULL, pk->widget_margin, 0, allocation.width - pk->widget_margin * 2 + 1,
allocation.height);
} }
static int static int
@ -328,8 +330,10 @@ static int
get_note_for_xy(PianoKeyboard *pk, int x, int y) get_note_for_xy(PianoKeyboard *pk, int x, int y)
{ {
int height, note; int height, note;
GtkAllocation allocation;
height = GTK_WIDGET(pk)->allocation.height; gtk_widget_get_allocation(GTK_WIDGET(pk), &allocation);
height = allocation.height;
if (y <= ((height * 2) / 3)) { /* might be a black key */ if (y <= ((height * 2) / 3)) { /* might be a black key */
for (note = 0; note <= pk->max_note; ++note) { for (note = 0; note <= pk->max_note; ++note) {
@ -469,6 +473,7 @@ recompute_dimensions(PianoKeyboard *pk)
{ {
int number_of_white_keys = 0, skipped_white_keys = 0, key_width, black_key_width, useful_width, note, int number_of_white_keys = 0, skipped_white_keys = 0, key_width, black_key_width, useful_width, note,
white_key, width, height; white_key, width, height;
GtkAllocation allocation;
for (note = pk->min_note; note <= pk->max_note; ++note) for (note = pk->min_note; note <= pk->max_note; ++note)
if (!is_black(note)) if (!is_black(note))
@ -477,8 +482,9 @@ recompute_dimensions(PianoKeyboard *pk)
if (!is_black(note)) if (!is_black(note))
++skipped_white_keys; ++skipped_white_keys;
width = GTK_WIDGET(pk)->allocation.width; gtk_widget_get_allocation(GTK_WIDGET(pk), &allocation);
height = GTK_WIDGET(pk)->allocation.height; width = allocation.width;
height = allocation.height;
key_width = width / number_of_white_keys; key_width = width / number_of_white_keys;
black_key_width = key_width * 0.8; black_key_width = key_width * 0.8;
@ -514,12 +520,12 @@ piano_keyboard_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
g_return_if_fail(widget != NULL); g_return_if_fail(widget != NULL);
g_return_if_fail(allocation != NULL); g_return_if_fail(allocation != NULL);
widget->allocation = *allocation; gtk_widget_set_allocation(widget, allocation);
recompute_dimensions(PIANO_KEYBOARD(widget)); recompute_dimensions(PIANO_KEYBOARD(widget));
if (GTK_WIDGET_REALIZED(widget)) if (gtk_widget_get_realized(widget))
gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); gdk_window_move_resize (gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height);
} }
static void static void