Text Widget



This problem seems related to some others I have been hearing about on
this list lately, but I think it's my fault.  The code below, seems to
produce a text window, with no way of being edited.  I just can't seem
to work it out.

  RECORD rec;
  char str[] = "Life is a Note.\n  Deal with it!";
  rec.sptr = New(char, strlen(str) + 1);
  (void) strcpy(rec.sptr, str);
  rec.header.size = strlen(str);
  (void) EditANote(&rec);

void EditANote(RECORD *note)
{
  GtkWidget *window = NULL;
  GtkWidget *text = NULL;
  GtkWidget *table = NULL;
  GtkWidget *hscrollbar = NULL;
  GtkWidget *vscrollbar = NULL;

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  (void) gtk_signal_connect_object(GTK_OBJECT(window), "delete_event",
                            (GtkSignalFunc) gtk_widget_destroy,
                            GTK_OBJECT(window));
  (void) gtk_widget_set_usize(window, 500, 250);
  (void) gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
  (void) gtk_window_set_title(GTK_WINDOW (window), "PinfoMan: Note
System");
  table = gtk_table_new (2, 2, FALSE);
  (void) gtk_container_add(GTK_CONTAINER(window), table);
  (void) gtk_widget_show (table);

  text = gtk_text_new(NULL, NULL);
  (void) gtk_table_attach(GTK_TABLE(table), text, 0, 1, 0, 1,
                        GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                        GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 /*  (void) gtk_text_set_editable(GTK_TEXT(text), TRUE); */
  (void) gtk_widget_realize(text);

  hscrollbar = gtk_hscrollbar_new(GTK_TEXT(text)->hadj);
  (void) gtk_table_attach(GTK_TABLE(table), hscrollbar, 0, 1, 1, 2,
                          GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL,
0, 0);
  (void) gtk_widget_show(hscrollbar);

  vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
  (void) gtk_table_attach(GTK_TABLE(table), vscrollbar, 1, 2, 0, 1,
                          GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL,
0, 0);
  (void) gtk_widget_show (vscrollbar);

  (void) gtk_text_insert(GTK_TEXT(text), NULL, NULL,
                         NULL, note->sptr, note->header.size);
  (void) gtk_text_insert(GTK_TEXT(text), NULL, NULL,
                         NULL, "\n", -1);
  (void) gtk_text_set_editable(GTK_TEXT(text), TRUE);
  (void) gtk_widget_show (text);
  (void) gtk_widget_show(window);
}
-- 
Lawrence Sim
http://www.tne.net.au/wanderer/
mailto:lasim@earthling.net




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