{"id":1302,"date":"2013-10-07T18:36:31","date_gmt":"2013-10-07T18:36:31","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=1302"},"modified":"2015-10-29T21:32:34","modified_gmt":"2015-10-29T21:32:34","slug":"timers","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/gui-programming-in-c\/gtk\/timers\/timers","title":{"rendered":".Timers General"},"content":{"rendered":"<h4>\nImplementing A Timer To Callback From gtk_main()<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n#include &lt;gtk\/gtk.h&gt;\r\n#include &lt;time.h&gt;\r\n<\/code><\/pre>\n<h5>\nCreate the timer<br \/>\n<\/h5>\n<pre>\r\n<code>\r\n  g_timeout_add(1000, (GSourceFunc) timer_event, (gpointer) MainWindow);  \/\/Register the timer and set time in mS. The timer_event() function is called repeatedly until it returns FALSE. \r\n  gtk_widget_show_all(MainWindow);\r\n  timer_event(MainWindow);\t\t\t\t\/\/Call the timer function now if you don&#39;t want to wait for the first time period triggered call \r\n\r\n  gtk_main();\r\n<\/code><\/pre>\n<h5>\nThe function called<br \/>\n<\/h5>\n<pre>\r\n<code>\r\n\r\n\/\/*********************************\r\n\/\/*********************************\r\n\/\/********** TIMER EVENT **********\r\n\/\/*********************************\r\n\/\/*********************************\r\nstatic gboolean timer_event(GtkWidget *widget)\r\n{\r\n\r\n\r\n  \r\n\r\n  return TRUE;\r\n}\r\n\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Implementing A Timer To Callback From gtk_main() #include &lt;gtk\/gtk.h&gt; #include &lt;time.h&gt; Create the timer g_timeout_add(1000, (GSourceFunc) timer_event, (gpointer) MainWindow); \/\/Register the timer and set time in mS. The timer_event() function is called repeatedly until it returns FALSE. gtk_widget_show_all(MainWindow); timer_event(MainWindow); \/\/Call the timer function now if you don&#39;t want to wait for the first time period [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[113],"tags":[],"class_list":["post-1302","post","type-post","status-publish","format-standard","hentry","category-timers"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=1302"}],"version-history":[{"count":9,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1302\/revisions"}],"predecessor-version":[{"id":2284,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1302\/revisions\/2284"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=1302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=1302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=1302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}