Solved

gtk program using glade

Posted on 2004-08-09
2
788 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

863 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

19 Experts available now in Live!

Get 1:1 Help Now