Solved

gtk program using glade

Posted on 2004-08-09
2
787 Views
Last Modified: 2008-01-09
Hello
    I am new to gtk programming  in c using glade.

 I have written a basic program which is as follows
/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  g_object_set_data_full (G_OBJECT (component), name, \
    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  g_object_set_data (G_OBJECT (component), name, widget)

 void on_cmdHello_clicked( GtkWidget *widget, gpointer data)
{
    g_print ("Hello World\n");
}

GtkWidget*
create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *vbox1;
  GtkWidget *hbox2;
  GtkWidget *txtHelloWorld;
  GtkWidget *hbox1;
  GtkWidget *cmdHello;

  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window1), _("window1"));

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (window1), vbox1);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox2, TRUE, TRUE, 0);

  txtHelloWorld = gtk_entry_new ();
  gtk_widget_show (txtHelloWorld);
  gtk_box_pack_start (GTK_BOX (hbox2), txtHelloWorld, TRUE, TRUE, 0);
  gtk_widget_set_size_request (txtHelloWorld, 158, 24);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);

  cmdHello = gtk_button_new_with_mnemonic (_("Hello World"));
  gtk_widget_show (cmdHello);
  gtk_box_pack_start (GTK_BOX (hbox1), cmdHello, FALSE, FALSE, 0);
  gtk_widget_set_size_request (cmdHello, 76, 26);

  g_signal_connect ((gpointer) cmdHello, "clicked",
                    G_CALLBACK (on_cmdHello_clicked),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
  GLADE_HOOKUP_OBJECT (window1, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (window1, hbox2, "hbox2");
  GLADE_HOOKUP_OBJECT (window1, txtHelloWorld, "txtHelloWorld");
  GLADE_HOOKUP_OBJECT (window1, hbox1, "hbox1");
  GLADE_HOOKUP_OBJECT (window1, cmdHello, "cmdHello");

  return window1;
}

on compiling it gives error  
interface.c:30: conflicting types for `on_cmdHello_clicked' at line 30

i cant under stand it. can anybody help
thanks in advance

0
Comment
Question by:rajneesh75
2 Comments
 
LVL 8

Accepted Solution

by:
akshayxx earned 50 total points
ID: 11769742
most likely, you are having conflicting types for the function

on_cmdHello_clicked'
check the way you have declared it in the other .c/.h files..
it should match with the definition of the function in the file u have listed in here
good luck
akshay
0
 
LVL 1

Author Comment

by:rajneesh75
ID: 11770445
thanks . I solved the problem by putting the code of  signal handler in callbacks.c file instead of interface.c

looking for support in future
thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now