Re: displaying 2 images



On Mon, Mar 12, 2007 at 02:03:57PM -0700, lucks wrote:

here is the code that am using for the combobox signal:

When you post code, please make it possible to read...

void
on_cbo_pickobject_changed              (GtkComboBox     *combobox,
                                        gpointer         user_data)
{

        gchar *mystr; 
      
      mystr = gtk_combo_box_get_active_text (combobox);

         if (strcmp (mystr, "Chair 1") == 0)  
      {

/*****this will display the first image(Chair 1.jpg) in the
img_objectpreview when Chair 1is selected from the
combobox*******************/
            
        GtkWidget *myimage_object = lookup_widget(GTK_WIDGET(combobox),
"img_objectpreview");                         gtk_image_set_from_file
(GTK_IMAGE(myimage_object), "Pictures/Chair 1.jpg"); 

...because this makes very hard to find where one statement
ends and another starts.  And when it is hard even to find
the end of one statement and the start of another, how you
can hope to find bugs there (or ask others to find them for
you)?

/*****i added this piece of code for a second image(Chair 1.gif) to be
displayed in img_patternpreview********/
                
       GtkWidget *myimage_pattern = lookup_widget(GTK_WIDGET(combobox),
"img_patternpreview");                                gtk_image_set_from_file
(GTK_IMAGE(myimage_pattern), "Pictures/Chair 1.gif"); 

        }
      
        else
      {
              ......./* show default image */
      }
     
      g_free (mystr);

}

here is the error i got when compiled:

callbacks.c(162) : error C2275: 'GtkWidget' : illegal use of this type as an
expression
callbacks.c(162) : error C2065: 'myimage_pattern' : undeclared identifier

Also either include the complete file or note which line is
the one referenced in the error message (162 here).  Without
that it is impossible to tell not only which line of the
snippet is 162 but also whether the included code contains
line 162 at all.

Now, the problem is -- probably, as no one knows what is
actually on line 162 -- still the same it was five days ago
when you asked the first time:  You cannot mix declarations
and code in C.  This is mixed:

declaration->      GtkWidget *myimage_object = ...
code       ->      gtk_image_set_from_file(...
declaration->      GtkWidget *myimage_pattern = ...
code       ->      gtk_image_set_from_file(...

This is in the proper order declaration(s), then code:

declaration->      GtkWidget *myimage;
code       ->      myimage = lookup_widget(...
code       ->      gtk_image_set_from_file(...
code       ->      myimage = lookup_widget(...
code       ->      gtk_image_set_from_file(...

Yeti




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