Re: help on gtk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

gtk_combo_set_popdown_strings() is deprecated and should not be used  
in newly written code.  you should replace both the combo box  
creation and population with the following:

gtk_combo_box_new_text()

followed by:

gtk_combo_box_insert_text() for each of the strings in your items array.

furthermore, why are you using g_object*() functions to retrieve  
values held by widgets?

there are gtk*() specific routines for what you are trying to  
achieve, namely:

gtk_entry_get_text(), and
gtk_comb_box_get_active_text()

use these and your problems will magically disappear!

cheers,

richard

On Oct 20, 2006, at 7:29 AM, sameer tandra wrote:

> Hi I am sameer.
>
>            I am using Gtk and Mysql in that i am using combobox for  
> insertion into the database.
> There i am getting error gtkcombo have no property named text.
> are there any solutions for this.
> I am also using spin buttons for inserting data.for this also the  
> same error i am getting.
>
> The version which i am using is gtk 1.2.
>
> I am sending my code which i have done also with error.
>
> please help me.
>
> #include <gtk/gtk.h>
> #include <glib.h>
> #include <stdio.h>
> #include <mysql/mysql.h>
> #include <string.h>
>
>  char *p,*q;
>  MYSQL mysql;
>  GtkWidget *entry1,*entry2;
>  GtkWidget *box1;
>  GtkWidget *window;
>  GtkWidget *button;
>  GtkWidget *combo;
>  GList *items = NULL;
>
> gint destroyapp (GtkWidget *widget, gpointer gdata)
> {
>   gtk_main_quit();
>   return (FALSE);
> }
> doSQL(MYSQL *conn,char *command)
> {
>   printf("%s\n",command);
>   mysql_query(conn,command);
>   printf("result: %s\n",mysql_error(conn));
> }
> a()
> {
>   MYSQL *conn;
>   conn=mysql_init(NULL);
>   if(mysql_real_connect(conn,"localhost",NULL,NULL,"mysql",0,NULL,0))
>   {
>    printf("connection made\n");
>    g_object_get(entry1,"text",&p,NULL);
>
>     g_object_get(combo,"text",&q);
>    printf("%s \n",q);
>    char *sql = g_strdup_printf ("INSERT INTO sample(no,name)VALUES 
> ('%s','%s')", p,q);
>    doSQL (conn,sql);
>    g_free (sql);
>   }
> }
>
> int main (int argc, char *argv[])
> {
>   const gchar *value;
>   gtk_init (&argc, &argv);
>   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>   box1 = gtk_hbox_new (FALSE, 0);
>   gtk_container_add (GTK_CONTAINER (window), box1);
>   gtk_widget_show (box1);
>   button = gtk_button_new_with_label(" Insert ");
>   gtk_signal_connect(GTK_OBJECT(window), "delete_event",  
> GTK_SIGNAL_FUNC(destroyapp), NULL);
>   gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC 
> (a), NULL);
>   gtk_box_pack_start (GTK_BOX (box1), button, TRUE, TRUE, 0);
>   entry1 = gtk_entry_new_with_max_length (50);
>   gtk_box_pack_start (GTK_BOX (box1), entry1, TRUE, TRUE, 0);
>   gtk_widget_show (entry1);
>   items = g_list_append (items, "Banana");
>   items = g_list_append (items, "Orange");
>   items = g_list_append (items, "Peach");
>   items = g_list_append (items, "Strawberry");
>     combo = gtk_combo_new();
>     gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);
>     gtk_box_pack_start (GTK_BOX (box1), combo, TRUE, TRUE, 0);
>     gtk_widget_show (combo);
>     gtk_container_border_width (GTK_CONTAINER_Window), 15);
>     gtk_widget_show(button);
>     gtk_widget_show(window);
>     gtk_main();
>     return 0;
> }
>
> The Error I am getting is
>
> connection made
>
> (button1:6266): GLib-GObject-WARNING **: gobject.c:946: object  
> class `GtkCombo' has no property named `text'
> (null)
> INSERT INTO sample(no,name) VALUES('32432','(null)')
> result:
>
> In the place of that combo box null value is being inserted.
>
>
> regards
> sameer.
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux