1

我使用 GTK 2.0 用 C 语言编写了一个应用程序,用于带有运行 debian linux 的 ARM 处理器的触摸屏面板。这是一个非常基本的应用程序,在屏幕上显示了一些可以单击的按钮(事件框)。在一个页面上,我有 4 个字段来呈现一个“列表”,可以通过单击向上箭头和向下箭头(也是事件框)滚动浏览。我的滚动功能(下面的代码)非常基本......它只是用数组中的下一个项目更新每个字段。一切正常,但我看到的问题是,如果您反复单击滚动按钮有点太快,它会跳到一些列表项太远。我对正在发生的事情的猜测是,当点击太快时,计数器的前进速度超过了屏幕的更新速度,这样当您再次单击时,它实际上正在使用当时太高的计数器进行更新。如果它仅在真正快速单击时发生,我不会担心,但我认为对于这样一个以相当快的速度重复的简单功能来说,缓慢的响应似乎有些不合时宜。

我希望也许有人对我在使用 GTK 的屏幕刷新方面可能遗漏的东西有一些意见?

提前感谢您的任何想法或建议!

这是我的“提高音量”功能和“向上滚动”功能的代码,它们都有同样的问题。有相应的“向下滚动”和“降低音量”功能具有相同的问题:

static void sr_vol_up_clicked (GtkWidget *fakewidget, GdkEvent *fakeevent, gpointer number)
{

g_timer_start(lock_timer);
gtk_image_set_from_file (GTK_IMAGE(sr_vol_up_button),"./images/Admin/navigation_up_arrow_DOWN.png");

if (sr_current_level < 100)
{
    sr_current_level = sr_current_level + 1;
    gtk_label_set_text (GTK_LABEL(sr_current_level_label), (g_strdup_printf("%i", sr_current_level)));
    set_sr_volume(sr_current_level);
}

gtk_image_set_from_file (GTK_IMAGE(sr_vol_up_button),"./images/Admin/navigation_up_arrow_UP.png");

}

和另一个:

static void scroll_show_up ()
{
g_timer_start(lock_timer);
if (show_scroll_count > 0)
{

    if (show_one_displayed - 1 < 0)
    {
        show_one_displayed = (show_loop_list->len -1);
    }

    else
    {
        show_one_displayed = show_one_displayed - 1;
    }

    gtk_label_set_text (GTK_LABEL(upcoming_show_1_label), get_show_name((char *)g_ptr_array_index(show_loop_list, show_one_displayed)));

    if (show_two_displayed - 1 < 0)
    {
        show_two_displayed = (show_loop_list->len -1);
    }

    else
    {       
        show_two_displayed = show_two_displayed - 1;
    }

    gtk_label_set_text (GTK_LABEL(upcoming_show_2_label), get_show_name((char *)g_ptr_array_index(show_loop_list, show_two_displayed)));

    if (show_three_displayed - 1 < 0)
    {
        show_three_displayed = (show_loop_list->len -1);
    }

    else
    {
        show_three_displayed = show_three_displayed - 1;
    }

    gtk_label_set_text (GTK_LABEL(upcoming_show_3_label), get_show_name((char *)g_ptr_array_index(show_loop_list, show_three_displayed)));

    if (show_four_displayed - 1 < 0)
    {
        show_four_displayed = (show_loop_list->len -1);
    }

    else
    {
        show_four_displayed = show_four_displayed - 1;
    }

    gtk_label_set_text (GTK_LABEL(upcoming_show_4_label), get_show_name((char *)g_ptr_array_index(show_loop_list, show_four_displayed)));

    show_scroll_count = show_scroll_count - 1;

}
}
4

0 回答 0