RE: incompatible pointer type?



Kevin et all,
I have mashed the source from this app into one file, and am hoping my
errors become glaringly obvious when the source is viewed as a whole.  Thank
you again,
Shane

/* shane.c -- a sad attempt at understanding
   the GtkCList widget */
   

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

#include <gnome-1.0/gnome.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>

GtkWidget* create_list (void);
void
on_apply_button_clicked                (GtkButton       *button,
                                        gpointer         user_data);

void
on_exit_button_clicked                 (GtkButton       *button,
                                        gpointer         user_data);

// general declarations..........

  gint	row = 1;
  gint	col = 1;
  GtkWidget *list;
  GtkWidget *col1_combo;
  GtkWidget *col2_combo;
  
void
on_apply_button_clicked                (GtkButton       *button,
                                        gpointer         user_data)
{
	gchar 	*text[2];
	gint	  i;
	
	text[0] = gtk_editable_get_chars (GTK_EDITABLE(col1_combo), 1, -1);
	text[1] = gtk_editable_get_chars (GTK_EDITABLE(col2_combo), 1, -1);
	
	for (i = 0; i < 2; i++){
		gtk_clist_set_text (GTK_CLIST(list), row, col, text[i]);
		col++;
		}
	row++;

}


void
on_exit_button_clicked                 (GtkButton       *button,
                                        gpointer         user_data)
{
	gtk_main_quit();
}

int
main (int argc, char *argv[])
{
  GtkWidget *list;

#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);
#endif

  gnome_init ("list", "0.1", argc, argv);

  list = create_list ();
  gtk_widget_show (list);

  gtk_main ();
  return 0;
}



GtkWidget*
create_list (void)
{
  GtkWidget *dock1;
  GtkWidget *vbox1;
  GtkWidget *table1;
  GtkWidget *entry1;
  GtkWidget *entry2;
  GtkWidget *apply_button;
  GtkWidget *exit_button;
  GtkWidget *scrolledwindow1;
  GtkWidget *clist1;
  GtkWidget *col1_label;
  GtkWidget *col2_label;
  GtkWidget *appbar1;
  

  list = gnome_app_new ("List", _("list"));
  gtk_object_set_data (GTK_OBJECT (list), "list", list);
  gtk_window_set_default_size (GTK_WINDOW (list), 400, 400);

  dock1 = GNOME_APP (list)->dock;
  gtk_widget_ref (dock1);
  gtk_object_set_data_full (GTK_OBJECT (list), "dock1", dock1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (dock1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (list), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gnome_app_set_contents (GNOME_APP (list), vbox1);

  table1 = gtk_table_new (2, 2, FALSE);
  gtk_widget_ref (table1);
  gtk_object_set_data_full (GTK_OBJECT (list), "table1", table1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);

  entry1 = gnome_entry_new (NULL);
  gtk_widget_ref (entry1);
  gtk_object_set_data_full (GTK_OBJECT (list), "entry1", entry1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry1);
  gtk_table_attach (GTK_TABLE (table1), entry1, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  col1_combo = gnome_entry_gtk_entry (GNOME_ENTRY (entry1));
  gtk_widget_ref (col1_combo);
  gtk_object_set_data_full (GTK_OBJECT (list), "col1_combo", col1_combo,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (col1_combo);

  entry2 = gnome_entry_new (NULL);
  gtk_widget_ref (entry2);
  gtk_object_set_data_full (GTK_OBJECT (list), "entry2", entry2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry2);
  gtk_table_attach (GTK_TABLE (table1), entry2, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  col2_combo = gnome_entry_gtk_entry (GNOME_ENTRY (entry2));
  gtk_widget_ref (col2_combo);
  gtk_object_set_data_full (GTK_OBJECT (list), "col2_combo", col2_combo,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (col2_combo);

  apply_button = gnome_stock_button (GNOME_STOCK_BUTTON_APPLY);
  gtk_widget_ref (apply_button);
  gtk_object_set_data_full (GTK_OBJECT (list), "apply_button", apply_button,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (apply_button);
  gtk_table_attach (GTK_TABLE (table1), apply_button, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  exit_button = gnome_stock_button (GNOME_STOCK_BUTTON_CLOSE);
  gtk_widget_ref (exit_button);
  gtk_object_set_data_full (GTK_OBJECT (list), "exit_button", exit_button,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (exit_button);
  gtk_table_attach (GTK_TABLE (table1), exit_button, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow1);
  gtk_object_set_data_full (GTK_OBJECT (list), "scrolledwindow1",
scrolledwindow1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);

  clist1 = gtk_clist_new (2);
  gtk_widget_ref (clist1);
  gtk_object_set_data_full (GTK_OBJECT (list), "clist1", clist1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (clist1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 80);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 1, 80);
  gtk_clist_column_titles_show (GTK_CLIST (clist1));

  col1_label = gtk_label_new (_("column one"));
  gtk_widget_ref (col1_label);
  gtk_object_set_data_full (GTK_OBJECT (list), "col1_label", col1_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (col1_label);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, col1_label);

  col2_label = gtk_label_new (_("column two"));
  gtk_widget_ref (col2_label);
  gtk_object_set_data_full (GTK_OBJECT (list), "col2_label", col2_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (col2_label);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 1, col2_label);

  appbar1 = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER);
  gtk_widget_ref (appbar1);
  gtk_object_set_data_full (GTK_OBJECT (list), "appbar1", appbar1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (appbar1);
  gnome_app_set_statusbar (GNOME_APP (list), appbar1);

  gtk_signal_connect (GTK_OBJECT (apply_button), "clicked",
                      GTK_SIGNAL_FUNC (on_apply_button_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (exit_button), "clicked",
                      GTK_SIGNAL_FUNC (on_exit_button_clicked),
                      NULL);

  return list;
}



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