在简单的功能上显示响应时间似乎太慢

时间:2012-05-08 14:03:44

标签: c gtk gtk2

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

我希望也许某人对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;

}
}

0 个答案:

没有答案