예제 #1
0
int main (int argc, char *argv[]) {

  /*FIXME  Clean this main */

  GtkWidget *window, *entry, *grid, *frame, *combo1, *combo2, *combo3;
  gtk_init(&argc, &argv);

  /* Creates main window */
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  initialize_window(window);
  
  /* Creates a grid */
  grid = gtk_grid_new ();
  gtk_container_add(GTK_CONTAINER(window), grid);

  /* Creates a text entry and attaches to grid */
  entry = new_entry_with_buffer(NULL, 0); 
  GtkEntryBuffer *buffer = gtk_entry_get_buffer((GtkEntry *)entry);
  gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 3, 1);

  /*FIXME Regulate paramaters via xml */
  /* Creates favorite bands' combo and attaches to grid */
  combo1 = new_combo_box_with_text("Velvet Underground", "Joy Division", "My Bloody Valentine");

  g_signal_connect( G_OBJECT(combo1), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer));
  frame = gtk_frame_new("Favorite Bands");
  gtk_container_add(GTK_CONTAINER(frame), combo1);
  gtk_grid_attach(GTK_GRID(grid), frame, 0, 1, 1, 1);

  /* Creates favorite foods' combo and attaches to grid */
  combo2 = new_combo_box_with_text("Mexican", "Japanese", "Italian");
  g_signal_connect( G_OBJECT(combo2), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer));
  frame = gtk_frame_new("Favorite Foods");
  gtk_container_add(GTK_CONTAINER(frame), combo2);
  gtk_grid_attach(GTK_GRID(grid), frame, 1, 1, 1, 1);

  /* Creates favorite movies' combo and attaches to grid */
  combo3 = new_combo_box_with_text("Dekalog", "Acossado", "Magnolia");
  g_signal_connect( G_OBJECT(combo3), "changed", G_CALLBACK( cb_changed ), GTK_ENTRY_BUFFER(buffer));
  frame = gtk_frame_new("Favorite Movies");
  gtk_container_add(GTK_CONTAINER(frame), combo3);
  gtk_grid_attach(GTK_GRID(grid), frame, 2, 1, 1, 1);

  /* Shows all widgets recursively */
  gtk_widget_show_all(window); 
  gtk_main();
  return 0;
}
예제 #2
0
파일: gui.c 프로젝트: oreoPanda/chatnut
/*open up a dialog for adding a contact.*/
extern void popup_add_contact(void)
{
    GtkWidget *dialog_content_area = NULL,
                *contact_entry_field = NULL;
    GtkEntryBuffer *field_buffer = NULL;
    
	/*dialog*/
	dialog_add_contact = gtk_dialog_new();
	gtk_window_set_transient_for(GTK_WINDOW(dialog_add_contact), GTK_WINDOW(window) );
	dialog_content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_add_contact));

	/*entry*/
	contact_entry_field = gtk_entry_new();
	field_buffer = gtk_entry_buffer_new( NULL, 0 );
	gtk_entry_set_buffer( GTK_ENTRY(contact_entry_field), GTK_ENTRY_BUFFER(field_buffer) );

	/*start packing (buttons emit the "response" signal when clicked since they are in the action area)*/
	gtk_box_pack_start( GTK_BOX(dialog_content_area), contact_entry_field, FALSE, FALSE, 0 );
	gtk_dialog_add_button( GTK_DIALOG(dialog_add_contact), "Cancel", GTK_RESPONSE_CANCEL );
	gtk_dialog_add_button( GTK_DIALOG(dialog_add_contact), "OK/Add...", GTK_RESPONSE_OK );

	/*connect the "response" signal*/
	g_signal_connect(GTK_DIALOG(dialog_add_contact), "response", G_CALLBACK(add_contact_cb), NULL);
	g_signal_connect_swapped(GTK_DIALOG(dialog_add_contact), "response", G_CALLBACK(gtk_widget_destroy), dialog_add_contact);

	/*I forgot it again... show the widgets*/
	gtk_widget_show(dialog_add_contact);
	gtk_widget_show(contact_entry_field);

    return;
}
예제 #3
0
static void add_password_entry (KaPwDialogPrivate *priv)
{
    KaEntryBuffer *buffer = ka_entry_buffer_new ();

    priv->pw_entry =
        GTK_WIDGET (gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER (buffer)));
    gtk_entry_set_visibility (GTK_ENTRY (priv->pw_entry), FALSE);
    g_object_unref (buffer);

    gtk_container_add (GTK_CONTAINER (priv->entry_hbox), priv->pw_entry);
    gtk_entry_set_activates_default (GTK_ENTRY (priv->pw_entry), TRUE);
    gtk_widget_show (priv->pw_entry);
}
예제 #4
0
파일: gtkentrybuffer.c 프로젝트: Pfiver/gtk
static void
gtk_entry_buffer_finalize (GObject *obj)
{
  GtkEntryBuffer *buffer = GTK_ENTRY_BUFFER (obj);
  GtkEntryBufferPrivate *pv = buffer->priv;

  if (pv->normal_text)
    {
      trash_area (pv->normal_text, pv->normal_text_size);
      g_free (pv->normal_text);
      pv->normal_text = NULL;
      pv->normal_text_bytes = pv->normal_text_size = 0;
      pv->normal_text_chars = 0;
    }

  G_OBJECT_CLASS (gtk_entry_buffer_parent_class)->finalize (obj);
}
예제 #5
0
파일: gtkentrybuffer.c 프로젝트: Pfiver/gtk
static void
gtk_entry_buffer_set_property (GObject      *obj,
                               guint         prop_id,
                               const GValue *value,
                               GParamSpec   *pspec)
{
  GtkEntryBuffer *buffer = GTK_ENTRY_BUFFER (obj);

  switch (prop_id)
    {
    case PROP_TEXT:
      gtk_entry_buffer_set_text (buffer, g_value_get_string (value), -1);
      break;
    case PROP_MAX_LENGTH:
      gtk_entry_buffer_set_max_length (buffer, g_value_get_int (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
      break;
    }
}
예제 #6
0
void  callback_auto_dim_popup ( GtkWidget *widget, gpointer data ){
   GtkWidget *dialog, *label, *content_area;
   GtkWidget *button_ok;
   GtkWidget *entry_dim_frames_value;

   GtkEntryBuffer* buffer_dim_frames_value;

   if((gboolean)data && frame_header->current_frame->next_frame == NULL){
	   window_popup_warning("Can't dim to the frame after when there is none after!");
	   return;
   }
   if(!(gboolean)data && frame_header->current_frame->prev_frame == NULL){
	   window_popup_warning("Can't dim to the frame before when there is none before!");
	   return;
   }


   dialog = gtk_dialog_new_with_buttons ("Dimmer", (GtkWindow*)window, GTK_DIALOG_DESTROY_WITH_PARENT, NULL, NULL);
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   label = gtk_label_new ("Number of deciseconds");

   button_ok = gtk_dialog_add_button ((GtkDialog*)dialog, "DIM", (gint)GTK_STOCK_OK);

   buffer_dim_frames_value = gtk_entry_buffer_new("0", -1);

   entry_dim_frames_value = gtk_entry_new_with_buffer(GTK_ENTRY_BUFFER(buffer_dim_frames_value));

   gpointer* data_array = malloc(sizeof(gpointer[2]));
   data_array[0] = data;
   data_array[1] = (gpointer)buffer_dim_frames_value;

   g_signal_connect (button_ok, "clicked", G_CALLBACK (callback_auto_dim_run), data_array);
   g_signal_connect_swapped (button_ok, "clicked", G_CALLBACK (gtk_widget_destroy), dialog);

   gtk_container_add (GTK_CONTAINER (content_area), label);
   gtk_container_add (GTK_CONTAINER (content_area), entry_dim_frames_value);

   gtk_widget_show_all (dialog);
}
예제 #7
0
파일: gtk_glue.c 프로젝트: Emerentius/gtk
GtkEntryBuffer *cast_GtkEntryBuffer(GObject* obj) {
    return GTK_ENTRY_BUFFER(obj);
}
예제 #8
0
파일: interface.c 프로젝트: Akuan1994/gchat
GtkWidget* create_Authen (void)
{
        GtkWidget *Authen;
        GtkWidget *vbox;
        GtkWidget *hbox1, *hbox2, *hbox3, *hbox4;
        GtkWidget *label1, *label2, *label3;
        GtkWidget *entServip, *entUserid, *entPass;
        GtkWidget *butCancel,*butClear,*butOk;
        GtkTooltips *tooltips;

        Authen = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size(GTK_WINDOW(Authen),400,300);
        gtk_window_set_position(GTK_WINDOW(Authen),GTK_WIN_POS_CENTER);

        tooltips = gtk_tooltips_new ();

        vbox = gtk_vbox_new (FALSE, 0);
        gtk_widget_show (vbox);
        gtk_container_add(GTK_CONTAINER(Authen) , vbox);

        hbox1 = gtk_hbox_new (FALSE, 0);
        gtk_widget_show (hbox1);
        gtk_box_pack_start (GTK_BOX (vbox), hbox1, TRUE, TRUE, 0);

        label1 = gtk_label_new ("Server Ip");
        gtk_widget_show (label1);
        gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0);
        gtk_widget_set_usize (label1, 60, -2);
        gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);


        GtkEntryBuffer *entryBuffer = gtk_entry_buffer_new("127.0.0.1",-1);
        entServip = gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER(entryBuffer));
        gtk_widget_show (entServip);
        gtk_box_pack_start (GTK_BOX (hbox1), entServip, TRUE, TRUE, 0);
        gtk_tooltips_set_tip (tooltips, entServip, "Enter server ip", NULL);

        hbox2 = gtk_hbox_new (FALSE, 0);
        gtk_widget_show (hbox2);
        gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0);

        label2 = gtk_label_new ("User Id");
        gtk_widget_show (label2);
        gtk_box_pack_start (GTK_BOX (hbox2), label2, FALSE, FALSE, 0);
        gtk_widget_set_usize (label2, 60, -2);
        gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT);

        entryBuffer = gtk_entry_buffer_new("jiangxin",-1);
        entUserid = gtk_entry_new_with_buffer (entryBuffer);
        gtk_widget_show (entUserid);
        gtk_box_pack_start (GTK_BOX (hbox2), entUserid, TRUE, TRUE, 0);
        gtk_tooltips_set_tip (tooltips, entUserid, "Enter user id", NULL);

        hbox3 = gtk_hbox_new (FALSE, 0);
        gtk_widget_show (hbox3);
        gtk_box_pack_start (GTK_BOX (vbox), hbox3, TRUE, TRUE, 0);

        label3 = gtk_label_new ("Password");
        gtk_widget_show (label3);
        gtk_box_pack_start (GTK_BOX (hbox3), label3, FALSE, FALSE, 0);
        gtk_widget_set_usize (label3, 60, -2);
        gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT);

        entryBuffer = gtk_entry_buffer_new("123456",-1);
        entPass = gtk_entry_new_with_buffer (entryBuffer);
        gtk_widget_show (entPass);
        gtk_box_pack_start (GTK_BOX (hbox3), entPass, TRUE, TRUE, 0);
        gtk_tooltips_set_tip (tooltips, entPass, "Enter password", NULL);
        gtk_entry_set_visibility (GTK_ENTRY (entPass), FALSE);

        hbox4 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(hbox4);
        gtk_box_pack_start(GTK_BOX(vbox), hbox4, TRUE, TRUE, 0);

        butCancel = gtk_button_new_with_label("Cancel");
        gtk_widget_show(butCancel);
        gtk_tooltips_set_tip(tooltips,butCancel,"Cancel window", NULL);
        gtk_box_pack_start(GTK_BOX(hbox4),butCancel,TRUE,TRUE,0);

        butClear = gtk_button_new_with_label("Clear");
        gtk_widget_show(butClear);
        gtk_tooltips_set_tip(tooltips,butClear,"Clear ALL", NULL);
        gtk_box_pack_start(GTK_BOX(hbox4),butClear,TRUE,TRUE,0);

        butOk = gtk_button_new_with_label("OK");
        gtk_widget_show(butOk);
        gtk_tooltips_set_tip(tooltips,butOk,"Connect", NULL);
        gtk_box_pack_start(GTK_BOX(hbox4),butOk,TRUE,TRUE,0);

        gtk_signal_connect (GTK_OBJECT (butCancel), "clicked", G_CALLBACK (on_butCancel_clicked), NULL);
        gtk_signal_connect (GTK_OBJECT (butClear), "clicked", G_CALLBACK (on_butClear_clicked), NULL);
        gtk_signal_connect (GTK_OBJECT (butOk), "clicked", G_CALLBACK (on_butOk_clicked), NULL);

        /* Store pointers to all widgets, for use by lookup_widget(). */
        GLADE_HOOKUP_OBJECT_NO_REF (Authen, Authen, "Authen");
        GLADE_HOOKUP_OBJECT (Authen, hbox1, "hbox1");
        GLADE_HOOKUP_OBJECT (Authen, label1, "label1");
        GLADE_HOOKUP_OBJECT (Authen, entServip, "entServip");
        GLADE_HOOKUP_OBJECT (Authen, hbox2, "hbox2");
        GLADE_HOOKUP_OBJECT (Authen, label2, "label2");
        GLADE_HOOKUP_OBJECT (Authen, entUserid, "entUserid");
        GLADE_HOOKUP_OBJECT (Authen, hbox3, "hbox3");
        GLADE_HOOKUP_OBJECT (Authen, label3, "label3");
        GLADE_HOOKUP_OBJECT (Authen, entPass, "entPass");
        GLADE_HOOKUP_OBJECT (Authen, hbox4, "hbox4");
        GLADE_HOOKUP_OBJECT (Authen, butCancel, "butCancel");
        GLADE_HOOKUP_OBJECT (Authen, butClear, "butClear");
        GLADE_HOOKUP_OBJECT (Authen, butOk, "butOk");
        GLADE_HOOKUP_OBJECT_NO_REF (Authen, tooltips, "tooltips");

        return Authen;
}