playing with set of characters.



Hello,

Maybe it's not a trivial question... but I'm trying to solve the
problem and I don't know the next steps to get it.

(Questions are inserted in code below commentaries).

Any suggestions would be apreciated.

Thanks,

David

---

#include <stdlib.h>
#include <gtk/gtk.h>

/* Write in console the definitive text and exit programm */
void sayexit (GtkWidget *widget, gpointer data)
{
  const gchar *sText;

  sText = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
  g_printf ("%s\n",sText);
  gtk_main_quit();
}


int main (int argc, char **argv)
{
  GtkWidget *pWindow;
  GtkWidget *pVBox;
  GtkWidget *pLabel;
  GtkWidget *pEntry;
  GtkWidget *pHBox;
  GtkWidget *pComboBox;

  GList *glist = NULL;

  gtk_init (&argc, &argv);


  pWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  /* Basic configuration of toplevel gtk window */
  gtk_container_set_border_width (GTK_CONTAINER (pWindow), 5);
  g_signal_connect (G_OBJECT(pWindow),"delete-event",
                    G_CALLBACK(gtk_main_quit),0);


  pVBox = gtk_vbox_new (TRUE,0);
  gtk_container_add (GTK_CONTAINER (pWindow), pVBox);

  /* The nucleous of the programm... Has to write according to
   * the set of characters of selected language.
   * How can I do it ? (1st. Question)                        */

  pEntry = gtk_entry_new ();
  /* On return key pressed in pEntry...
   *                  go to sayexit function to exit programm */
  g_signal_connect (G_OBJECT (pEntry), "activate",
                    G_CALLBACK(sayexit),0);
  gtk_box_pack_start (GTK_BOX (pVBox), pEntry, TRUE, TRUE, 0);

  pHBox = gtk_hbox_new (FALSE, 0);

  pLabel = gtk_label_new ("Select Language:  ");
  gtk_box_pack_start (GTK_BOX (pHBox), pLabel, FALSE, FALSE, 0);


  /* Chained list of different languages
   * 2nd. Question:
   * Is there any way to construct this list automatically
   * (I mean..., from available ones) ??                      */

  glist = g_list_append (glist, "English");
  glist = g_list_append (glist, "Greek");
  glist = g_list_append (glist, "Russian");
  glist = g_list_append (glist, "Hebrew");

  pComboBox = gtk_combo_new ();
  gtk_combo_set_popdown_strings (GTK_COMBO (pComboBox), glist);
  gtk_entry_set_editable (GTK_ENTRY(GTK_COMBO(pComboBox) -> entry), FALSE);
  gtk_box_pack_start (GTK_BOX (pHBox), pComboBox, FALSE, FALSE, 0);
  g_list_free (glist);

  gtk_box_pack_start (GTK_BOX (pVBox), pHBox, TRUE, TRUE, 0);

  gtk_widget_show_all(pWindow);
  gtk_main();

  return EXIT_SUCCESS;
}
----



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