How to create an interrupt or background task in C - c

I am trying to figure out how to make a background process in C, I haven't found anything online. I think the reason I haven't found much is that I may not be asking the right question.
I am working on a school project using ARM assembly and C with Raspberry Pi using the Raspbian Operating System and the GCC compiler.
For my project, I decided to do a simple alarm system. The idea is simple, I have 3 PIR sensors that detect motion, and set off a buzzer when motion is detected.
Instead of using hardware for the keypad, I chose to do a GUI where you can arm/disarm the system as well as change the password and turn on/off certain sensors. For example, if you wanted to turn off motion sensors 1 and 2, there will be buttons on the GUI to do that.
The problem I am having is that the GUI Library I'm using, (GTK3 and Glade) is event-driven, so unless a button is pressed it won't do anything. This would be fine if I only wanted to set the buzzer to on when motion is detected because I could make my own loop to watch for motion, but I really want to play some type of pattern repeatedly (example: 3 short beeps continuously until the alarm is disarmed). At the same time, I still want to have access to the GUI buttons so I can turn off the alarm. This makes me think I need an interrupt or a background process.
I'm sure there are many ways to solve this problem, but I really wanted to create sort of a background routine that could run parallel to the main task once the user's arms' the system. I have asked my professor about how to multi-thread in ARM, but he said that we do not cover this in the class. I have read that the C standard library doesn't support multi-threading, but I am sure there is a way that this can be done. If someone could just point me in the right direction I would be grateful.
Here is the GUI code I have written, along with another module I have finished to get a working prototype before I start wiring the sensors. None of this contains any assembly code because I haven't got to that yet, I wanted to get it working at a higher level and then break certain parts down to assembly. If you need all of the files I will gladly provide them, but I think this should be enough for you all to understand what I'm trying to do.
The GUI code:
/*****************************************************
* Title: User Interface
* Author:
* Date: 2/15/20
* Class: CISP 2410
*
* Description:
* ! This header file contains all of the function
* ! Declarations and definitions for the GUI
* ! Everything involving the GUI will be in
* --> this header
*
*****************************************************/
#include <gtk/gtk.h> // For gtk stuff
#include <stdlib.h> // Standard Library
#include "GUI_Ctrl.h" // Prototypes
#include "Alarm.h" // Alarm Functions
/* Private Functions */
static void UpdateLcdDisplay(char keyPadValue);
static void ClearLcdDisplay(void);
static void UpdateDisplay(void);
/***********************************/
// Global Variables
GtkWidget *g_Lbl_Lcd;
GtkWidget *g_Lbl_SysStat;
GtkWidget *g_Lbl_LogStat;
char inputBuffer[6] = {0x0};
int charCounter = 0;
const int INPUT_LIMIT = 6;
/*****************************************************
* ! Initializes all of the GUI elements
* ! Adds CSS attributes to GUI elements
* ! Also handles the formatting of text
*****************************************************/
void GUI_INIT(int argc, char* argv[])
{
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *g_Lbl_Lbl1;
GtkWidget *g_Lbl_Lbl2;
// Get pointer to css file
GtkCssProvider *cssProvider = gtk_css_provider_new ();
gtk_css_provider_load_from_path(cssProvider,"UI/style.css",NULL);
gtk_init(&argc, &argv);
// get pointer to xml dat file
builder = gtk_builder_new_from_file("UI/HelloWorld.glade");
// Get pointer to main window
window = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));
gtk_builder_connect_signals(builder, NULL);
// Get pointer to labels
g_Lbl_Lcd = GTK_WIDGET(gtk_builder_get_object(builder, "Lbl_Lcd"));
g_Lbl_SysStat = GTK_WIDGET(gtk_builder_get_object(builder, "Lbl_SysStat"));
g_Lbl_LogStat = GTK_WIDGET(gtk_builder_get_object(builder, "Lbl_LogStat"));
g_Lbl_Lbl1 = GTK_WIDGET(gtk_builder_get_object(builder, "Lbl1"));
g_Lbl_Lbl2 = GTK_WIDGET(gtk_builder_get_object(builder, "Lbl2"));
// Align Text Right
gtk_label_set_xalign (GTK_LABEL(g_Lbl_Lcd), 1);
// Align Text Left
gtk_label_set_xalign (GTK_LABEL(g_Lbl_SysStat), 0);
gtk_label_set_xalign (GTK_LABEL(g_Lbl_LogStat), 0);
gtk_label_set_xalign (GTK_LABEL(g_Lbl_Lbl1), 0);
gtk_label_set_xalign (GTK_LABEL(g_Lbl_Lbl2), 0);
// Add CSS
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
// Finish setup and start GUI
g_object_unref(builder);
gtk_widget_show(window);
UpdateDisplay();
gtk_main();
return;
}
// called when window is closed
void on_window_main_destroy()
{
gtk_main_quit();
}
/*------------------END SECTION------------------*/
static void UpdateDisplay(void)
{
ClearLcdDisplay();
gtk_label_set_text(GTK_LABEL(g_Lbl_SysStat), GetSysStat());
gtk_label_set_text(GTK_LABEL(g_Lbl_LogStat), GetLogStat());
return;
}
static void UpdateLcdDisplay(char keyPadValue)
{
if (charCounter >= INPUT_LIMIT)
ClearLcdDisplay();
else
{
inputBuffer[charCounter] = keyPadValue;
charCounter++;
}
gtk_label_set_text(GTK_LABEL(g_Lbl_Lcd), inputBuffer);
return;
}
static void ClearLcdDisplay(void)
{
memset(inputBuffer, 0, 6);
charCounter = 0;
gtk_label_set_text(GTK_LABEL(g_Lbl_Lcd), inputBuffer);
return;
}
/*------------------ EVENT HANDLERS ------------------*/
void on_btn0_clicked(void) {UpdateLcdDisplay('0');}
void on_btn1_clicked(void) {UpdateLcdDisplay('1');}
void on_btn2_clicked(void) {UpdateLcdDisplay('2');}
void on_btn3_clicked(void) {UpdateLcdDisplay('3');}
void on_btn4_clicked(void) {UpdateLcdDisplay('4');}
void on_btn5_clicked(void) {UpdateLcdDisplay('5');}
void on_btn6_clicked(void) {UpdateLcdDisplay('6');}
void on_btn7_clicked(void) {UpdateLcdDisplay('7');}
void on_btn8_clicked(void) {UpdateLcdDisplay('8');}
void on_btn9_clicked(void) {UpdateLcdDisplay('9');}
void on_btnClear_clicked(void) {ClearLcdDisplay();}
void on_btnEnter_clicked(void) {UpdateDisplay();}
void on_btnLogin_clicked(void)
{
LoginLogout(inputBuffer);
UpdateDisplay();
return;
}
void on_btnArm_clicked(void)
{
ArmDisarm();
UpdateDisplay();
return;
}
Here is the code for the alarm. Note, this is just a prototype, I will be using the wiringPi library once I get this interrupt thing figured out.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Alarm.h"
// Private Function Prototypes
static int PasswordIsCorrect(char* pswAttempt);
// Global Variables
static int armed = 0;
static int loggedIn = 0;
static int PasswordIsCorrect(char* pswAttempt)
{
const char PASSWORD[] = "123";
if (!strcmp(pswAttempt, PASSWORD))
return 1;
else
return 0;
}
/*
* Returns a string,
* Used to update label
*/
char* GetSysStat(void)
{
if(armed)
return "Armed";
else
return "Disarmed";
}
/*
* Returns a string,
* Used to update label
*/
char* GetLogStat(void)
{
if(loggedIn)
return "Logged In";
else
return "Logged Out";
}
void ArmDisarm(void)
{
if (loggedIn && armed)
armed = 0;
else if(loggedIn && !armed)
armed = 1;
return;
}
void LoginLogout(char* pswAttempt)
{
if(PasswordIsCorrect(pswAttempt))
loggedIn = 1;
else
loggedIn = 0;
return;
}
Thank you all for your time!

Related

gtk3 on macos: window does not restore from the dock

Using GTK3 on MacOS, after minimizing the window, the dock icon does not restore the window. I have to use the "Show All Windows" selection from the dock icon menu.
Does anyone have a work-around or know something to make the dock icons work?
I would be happy with some simple objective-c code that would make the dock icons work.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <getopt.h>
#include <unistd.h>
#include <gtk/gtk.h>
static void testBuildUI (void);
gboolean testMainLoop (void);
int
main (int argc, char *argv[])
{
gtk_init (&argc, NULL);
testBuildUI ();
testMainLoop ();
return 0;
}
static void
testBuildUI (void)
{
GtkWidget *window;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
assert (window != NULL);
gtk_widget_show_all (window);
}
int
testMainLoop (void)
{
while (1) {
gtk_main_iteration_do (FALSE);
while (gtk_events_pending ()) {
gtk_main_iteration_do (FALSE);
}
sleep (1);
}
return 0;
}
There is no special code or Objective-C needed if you use gtk_application_new instead of gtk_init and start your main loop with g_application_run.
The documentation states the following:
Currently, GtkApplication handles GTK+ initialization, application uniqueness, session management, provides some basic scriptability and desktop shell integration by exporting actions and menus and manages a list of toplevel windows whose life-cycle is automatically tied to the life-cycle of your application.
see https://docs.gtk.org/gtk3/class.Application.html
Self contained test program
Your code slightly adapted to the above points might look like the following:
#include <gtk/gtk.h>
#include <assert.h>
static void testBuildUI(GApplication *app, gpointer data);
int main(int argc, char *argv[]) {
printf("gtk version: %d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
GtkApplication *app = gtk_application_new("com.example.MyApp",G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(testBuildUI), NULL);
g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return 0;
}
static void testBuildUI(GApplication *app, gpointer data) {
GtkWidget *window;
window = gtk_application_window_new(GTK_APPLICATION(app));
assert (window != NULL);
gtk_widget_show_all(GTK_WIDGET(window));
}
If you click on the dock icon of this test program, the window will restore as expected.
Alternative solution
If you want to avoid GApplication/GtkApplication, you could also use the gtk-mac-integration library instead, see https://github.com/jralls/gtk-mac-integration.
The library is rather small, only a few thousand lines of C code, so you can also easily take a look at how it works internally.
There is an important hint:
Older Gtk applications that aren't based around GApplication can be adapted to use the macOS menu bar and to integrate with the Dock using GtkOSXApplication. The Gtk API that GtkOSXApplication uses is deprecated in Gtk3 and has been removed from Gtk4. Since macOS integration is available directly in Gtk using GApplication GtkOSXIntegration will not be updated for the new menu API and is deprecated. Application maintainers are strongly encouraged to redesign their programs around GApplication, particularly before migrating to Gtk4.
see https://wiki.gnome.org/Projects/GTK/OSX/Integration
The integration is easy: after gtk_init create an application object. After setting up the window call gtkosx_application_ready with the application object.
As a side note, there is also a slightly more complex example in the src folder called test-integration.c under the Github link mentioned above that shows a more advanced menu and dock integration.
Finally, your program only minimally changed to work with the gtk-mac-integration lib:
#include <gtk/gtk.h>
#include <gtkosxapplication.h>
#include <assert.h>
static void testBuildUI(void);
static void testMainLoop(void);
static void
testBuildUI(void) {
GtkWidget *window;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
assert (window != NULL);
gtk_widget_show_all(window);
}
void
testMainLoop(void) {
while (1) {
gtk_main_iteration_do(FALSE);
while (gtk_events_pending()) {
gtk_main_iteration_do(FALSE);
}
sleep(1);
}
}
int
main(int argc, char *argv[]) {
printf("gtk version: %d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
gtk_init(&argc, &argv);
GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
testBuildUI();
gtkosx_application_ready(theApp);
testMainLoop();
g_object_unref(theApp);
return 0;
}
I installed the library using brew install gtk-mac-integration and linked the C program with libgtkmacintegration-gtk3.dylib. Also in this variant, the window is restored as expected. when you click on the dock icon of the program.

How can I "pause" app for user to press a button? GTK

I am making an card game in C using GTK 3.0. I have two functions for two windows, openMenu() to open the menu and newGame() to create a new window with a card table. The player is playing against two bots which will choose their cards randomly. I need the player to start the game with choosing one card.
Open Menu:
static void openMenu(int argc, char *argv[]){
GtkBuilder *builder;
GtkWidget *window;
GObject *button;
GError *error = NULL;
gtk_init(&argc, &argv);
builder = gtk_builder_new_from_file("menu_window_glade.glade");
window = GTK_WIDGET(gtk_builder_get_object(builder, "menu_window"));
gtk_builder_connect_signals(builder, NULL);
gtk_widget_show(window);
gtk_main();
}
New Game:
void newGame(){
GtkBuilder *builder;
GtkWidget *window;
GtkImage *image;
widgetsPtrs *widgets = malloc(sizeof(widgetsPtrs));
char imageStr[] = "image00";
char aImgstr[] = "A0";
char dImgstr[] = "D0";
builder = gtk_builder_new_from_file("game_glade.glade");
window = GTK_WIDGET(gtk_builder_get_object(builder, "game_glade_window"));
gtk_builder_connect_signals(builder, NULL);
gtk_widget_show(window);
shuffleTheDeck();
printAll(Deck);
card *player = malloc(sizeof(card));
card *leftBot = malloc(sizeof(card));
card *rightBot = malloc(sizeof(card));
deal(player, 0);
deal(leftBot, 0);
deal(rightBot, 0);
/***************Puts images into buttons***********/
tmpCard = player;
for (size_t i = 0; i < 6; i++)
{
tmpCard = tmpCard->next;
imgPath[20] = zero + tmpCard->rank;
imgPath[21] = zero + tmpCard->suit;
gtk_image_set_from_file(GTK_IMAGE(widgets->w_playersHandPtr[i]), imgPath);
}
int a = firstTurnCheck();
playersTurn(player, leftBot, rightBot);
}
The problem comes from here: I've come with an idea of a loop, which can be broken only if the global bool is changed, which is changed in a function serving on click events. However, the window with a game table doesn't show, therefore I am never able to click a button, so the app freezes.
void playersTurn(card *player, card *leftBot, card *rightBot){
bool DEFENDERTOOKTHECARDS = false;
bool RBHASMORE = true;
PLAYERCHOOSING = true;
int attackCounter = 0;
int *appearedRanks = calloc(9, sizeof(int));
card *cardsOnTheTable = malloc(sizeof(card)); //cardsOnTheTable[0] is a pointer to the table
char answer;
puts("Player's Turn");
puts("Choose a card.");
/*****************The spot where the mistake might be****************/
while(PLAYERCHOOSING);//PLAYERCHOOSING is a global bool.
puts("You've chosen a card.");
}
On_card_click function:
void on_card_clicked(GtkButton *button, gpointer *data){
gtk_widget_hide(GTK_WIDGET(data));
PLAYERCHOOSING = false;
}
Among other things, this line is a problem: (as you guessed in your comment.)
while(PLAYERCHOOSING);//PLAYERCHOOSING is a global bool.
It will enter and never leave.
At the very least it should have the ability to check a flag to see if a button has been pressed:
while(PLAYERCHOOSING)
{
if(buttonToggled)//define as another global boolean value, and set when button is pressed
{
PLAYERCHOOSING = false;
buttonToggled = false;
}
else Sleep(1000); //sleep for 1 second
}
A better approach is to run the user interface in the primary thread, then put the housekeeping (button press detection and handling ) in a second thread. A callback function could be defined as a button press handler.
(void on_card_clicked(GtkButton *button, gpointer *data) appears to be a callback.)
I don't understand why so many people like using threads for anything. GTK has a main loop, use it (see this answer for more on this). You can't use sleep, infinite loops, or any other blocking calls, otherwise you block the main loop that processes the UI events.
So wouldn't just putting:
PLAYERCHOOSING = true;
in playersTurn, and
PLAYERCHOOSING = false;
in on_card_clicked be enough?
Thanks a lot #ryyker for the advice he's given.
The solution is based on threading. As I said, I've never worked with them before, but it took me like 15 mins to figure out everything I needed, so there is nothing to be afraid of :) There is my solution:
'#include < pthread.h >',
declare pthread_t thread in newGame(),
add pthread_create(&thread, NULL, playersTurn, NULL); into newGame()
you can leave 'while(PLAYERCHOOSING)' loop as it is.
compile with -lpthread flag.
Voila, you are amazing.

How to refresh a GTK image?

Hi people from Stackoverflow, I have some knowledge of programming, but not very much. My idea is to program something like a video-game or visualizer in c, to do so I make and process somehow an array that represents an image and it has to be visualized and always being refreshed, like a video-game. I have the algorithm already done, I need to optimize it, I mean I know how to create the array representing an image at anytime, what I need now is to visualize it like an animation and later optimize with opencl.
The program that I want to make has to do something like this:
"create the image"
"render it",
"create the image"
"render it",
...
For that reason I know that I could start easily from a very simple example and I don't have to learn everything of GTK. I have been intensively searching for simple examples and trying to understand how it works but it didn't help, I need just to do that simple action, refresh it. A command somewhere should be enough.
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <glib.h>
const int Width = 1200, Height = 800;
char *buffer;
int i = 0;
GdkPixbuf *pixbuf;
GtkWidget *window;
GtkWidget* image;
void delay(int number_of_seconds){
int milli_seconds = 1000 * number_of_seconds;
clock_t start_time = clock();
while (clock() < start_time + milli_seconds);
}
int main (int argc, char *argv[]){
buffer = (char*)malloc(3 * Width * Height);
// CREATE AN IMAGE IN BUFFER SOMEHOW
// buffer = something;
//
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pixbuf = gdk_pixbuf_new_from_data (buffer, GDK_COLORSPACE_RGB, FALSE, 8, Width, Height, (Width)*3, NULL, NULL);
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_container_add(GTK_CONTAINER (window), image);
gtk_window_set_title (GTK_WINDOW (window), "Visualizador");
gtk_widget_show_all (window);
delay(0.04);
gtk_main ();
free (buffer);
return 0;
}
The program is really simple, when I create/load the image there it shows a picture, but I would like to put the function already programmed there, to return a "buffer" and then refresh the displayed image.
I read that gtk_widget_queue_draw has something to do, or gdk_pixbuf_simple_anim_add_frame or g_timeout_add but I have no idea how they work and what to put in this program.
Thank you in advance!
If you want a moving image or something that needs to get refreshed a lot then I would suggest using a GtkDrawingArea and implement it's draw signal, for that you'll need to use cairo. It should look something like this:
static gboolean
your_draw_cb(GtkWidget *widget, cairo_t *context, gpointer data)
{
// Do your drawing
return FALSE;
}
int main()
{
// Some code before ...
GtkWidget *area = gtk_drawing_area_new();
g_signal_connect(G_OBJECT(area), "draw", G_CALLBACK(your_draw_cb), your_data);
gtk_container_add(GTK_CONTAINER(your_container), area);
// More code ...
}
Each time you want to refresh it you should call
gtk_widget_queue_draw(area);
to get the draw signal called.
You won't need to store a buffer as that comes inside the cairo context.
But you may want to use other libraries for this purpose, like SDL2 or OpenGL as they are designed for videogames.
I hope this helps.

updating interface in GTK

I want to make an application that displays the time (ultimately I am trying to hack together my own simple smart mirror without using the existing smart mirror APIs). I am using GTK3 for the UI however I am having trouble figuring out a solution to make the UI update the time (I am not experienced in front end or GTK so bear with me).
I have tried placing loops around parts of the view3 code shown below however I have discovered that once gtk_main() is called I can't get out of the gtk main loop so that the while loop starts over and recalls the time function I wrote.
I have tried using functions like gtk_main_iteration_do(gtk_false()) (false so that it doesn't block) but I clearly don't understand enough about these functions because it's not working. If I leave gtk_main() out of the loop obviously gtk_main() never gets called and my application window won't even open up.
I have shown the relevant code in main below and following that the definition of the get_time_string() function I wrote.
int
main (int argc,
char *argv[])
{
// initialization and setting up window, packing widgets, etc
// view3
// populate buffer with time string
// and insert into text view
view3 = gtk_text_view_new();
gtk_widget_set_name(view3, "view3");
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view3));
gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
gtk_text_buffer_insert(buffer, &iter, get_time_string(), -1);
gtk_text_view_set_editable(GTK_TEXT_VIEW(view3), FALSE);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view3), FALSE);
// More widget packing, setting up UI
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Definition of get_time_string()
char* get_time_string(){
time_t time_var = time(NULL);
struct tm *info;
char *time_string = calloc(100, sizeof(char));
info = localtime( &time_var );
strftime(time_string, 100, "%I:%M %p", info);
return time_string;
}
You should not play with mainloop iterations unless you really need or know what to do.
The trick is to use g_timeout_add or g_idle_add and their variants. As you want the time to update at regular intervals (for minute resolution you will update every 60 seconds) then you can use g_timeout_add_seconds.
For illustration purposes, i'll add the seconds to your time string and update every second, using your get_time_string function but creating a very simple window to show just a time label:
#include <time.h>
#include <stdlib.h>
#include <gtk/gtk.h>
char* get_time_string(){
time_t time_var = time(NULL);
struct tm *info;
char *time_string = calloc(100, sizeof(char));
info = localtime( &time_var );
strftime(time_string, 100, "%I:%M:%S %p", info);
return time_string;
}
gboolean update_label_time (gpointer user_data) {
gchar *t = get_time_string();
gtk_label_set_text(GTK_LABEL(user_data), t);
g_free (t);
return G_SOURCE_CONTINUE;
}
int main (int argc, char *argv[])
{
gchar *t;
GtkWidget *window;
GtkWidget *label_time;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW(window), 300, 200);
t = get_time_string();
label_time = gtk_label_new (t);
g_free (t);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_container_add (GTK_CONTAINER(window), label_time);
g_timeout_add_seconds(0.5, update_label_time, label_time);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
The result should be a window with a label updating every second:
GLib has its own time functions which you should use.

compiling a simple gtk program with glade

i hav downloaded glade3 and i cant find any glade.h in it when i extract it so when i compile the following program
#include <stdio.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
GladeXML *xml;
GtkWidget *widget;
GtkWidget *display;
G_MODULE_EXPORT void on_displayButton_clicked(GtkButton *button,gpointer *data)
{
/* Find the Glade XML tree containing widget. */
xml = glade_get_widget_tree(GTK_WIDGET( widget ));
/* Pull the widgets out of the tree */
display= glade_xml_get_widget(xml, "displayLabel");
gtk_label_set_text(GTK_LABEL(display),"Hello World!\n gihansblog.com");
}
G_MODULE_EXPORT void on_exitButton_clicked(GtkButton *button,gpointer *data)
{
gtk_main_quit();
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
/*import glade file*/
xml = glade_xml_new("hello.glade", NULL, NULL);
/* get a widget (useful if you want to change something) */
widget = glade_xml_get_widget(xml, "mainWindow");
/* connect signal handlers */
glade_xml_signal_autoconnect(xml);
/*show widget*/
gtk_widget_show (widget);
gtk_main();
return 0;
}
i get an error saying glade.h not found,i have been working on it from past 5 hours but cant find a solution.
Have you tried by giving the full directory to your
"hello.glade" file.
Where it is in your system???
Otherwise you may have to convert your .glade file to .xml
Anyway in which Gtk version aru you in?

Resources