Esempio n. 1
0
GtkWidget *
do_entry_buffer (GtkWidget *do_widget)
{
  GtkWidget *content_area;
  GtkWidget *vbox;
  GtkWidget *label;
  GtkWidget *entry;
  GtkEntryBuffer *buffer;

  if (!window)
  {
    window = gtk_dialog_new_with_buttons ("GtkEntryBuffer",
                                          GTK_WINDOW (do_widget),
                                          0,
                                          _("_Close"),
                                          GTK_RESPONSE_NONE,
                                          NULL);
    gtk_window_set_resizable (GTK_WINDOW (window), FALSE);

    g_signal_connect (window, "response",
                      G_CALLBACK (gtk_widget_destroy), NULL);
    g_signal_connect (window, "destroy",
                      G_CALLBACK (gtk_widget_destroyed), &window);

    content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
    gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);

    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), "Entries share a buffer. Typing in one is reflected in the other.");
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    /* Create a buffer */
    buffer = gtk_entry_buffer_new (NULL, 0);

    /* Create our first entry */
    entry = gtk_entry_new_with_buffer (buffer);
    gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

    /* Create the second entry */
    entry = gtk_entry_new_with_buffer (buffer);
    gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
    gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);

    g_object_unref (buffer);
  }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show_all (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Esempio n. 2
0
GtkWidget *
do_entry_buffer (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;
  GtkWidget *vbox;
  GtkWidget *label;
  GtkWidget *entry;
  GtkEntryBuffer *buffer;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Entry Buffer");
      gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
      g_object_set (vbox, "margin", 5, NULL);
      gtk_container_add (GTK_CONTAINER (window), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "Entries share a buffer. Typing in one is reflected in the other.");
      gtk_box_pack_start (GTK_BOX (vbox), label);

      /* Create a buffer */
      buffer = gtk_entry_buffer_new (NULL, 0);

      /* Create our first entry */
      entry = gtk_entry_new_with_buffer (buffer);
      gtk_box_pack_start (GTK_BOX (vbox), entry);

      /* Create the second entry */
      entry = gtk_entry_new_with_buffer (buffer);
      gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
      gtk_box_pack_start (GTK_BOX (vbox), entry);

      g_object_unref (buffer);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Esempio n. 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);
}
Esempio n. 4
0
void stworz_obj(GtkWidget *widget, gpointer data)
{
    nr = GPOINTER_TO_INT(data);
    if(nr < 0 || nr > 3) // w zasadzie to sie chyba nigdy nie zdarzy
        return;          // ale przezorny zawsze ubezpieczony :)

    GtkWidget *dialog, *obszar, *label_i;
    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_size_request (dialog, 330, 75+25*nr);
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
    gtk_window_set_title(GTK_WINDOW(dialog), (gchar*)nazw_obj[nr]);
    obszar = gtk_fixed_new();
    char lit1 = 'A', lit2 = 'x';
    for(int i = 0; i <= nr; i++)
    {
        char temp[4]; temp[0] = lit1 + i; temp[1] = ' '; temp[2] = ':'; temp[3] = '\0';
        label_i = gtk_label_new((gchar*)temp);
        gtk_fixed_put(GTK_FIXED(obszar), label_i, 5, 10+25*i);
        gtk_widget_show(label_i);
        for(int j = 0; j < 3; j++)
        {
            temp[0] = lit2 + j; temp[1] = '\0';
            label_i = gtk_label_new((gchar*)temp);
            gtk_fixed_put(GTK_FIXED(obszar), label_i, 100*j+40, 10+25*i);
            gtk_widget_show(label_i);
            wsp_new_obj_buf[i][j] = gtk_entry_buffer_new("", -1);
            wsp_new_obj[i][j] = gtk_entry_new_with_buffer(wsp_new_obj_buf[i][j]);
            gtk_fixed_put(GTK_FIXED(obszar), wsp_new_obj[i][j], 100*j+55, 10+25*i);
            gtk_widget_set_size_request(wsp_new_obj[i][j], 50, 20);
            gtk_widget_show(wsp_new_obj[i][j]);
        }
    }
    GtkWidget *ok, *anuluj;
    ok = gtk_button_new_with_label("OK");
    gtk_widget_set_size_request(ok, 60, 30);
    g_signal_connect(G_OBJECT(ok), "clicked", G_CALLBACK(stworz_obj_et2), dialog);
    gtk_fixed_put(GTK_FIXED(obszar), ok, 70, 40+25*nr);
    gtk_widget_show(ok);
    anuluj = gtk_button_new_with_label("Anuluj");
    gtk_widget_set_size_request(anuluj, 60, 30);
    g_signal_connect(G_OBJECT(anuluj), "clicked", G_CALLBACK(kill), dialog);
    gtk_fixed_put(GTK_FIXED(obszar), anuluj, 200, 40+25*nr);
    gtk_widget_show(anuluj);
    gtk_container_add(GTK_CONTAINER(dialog), obszar);
	gtk_widget_show(obszar);
	gtk_widget_show(dialog);
}
Esempio n. 5
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);
}
Esempio n. 6
0
File: gui.cpp Progetto: dynbit/TFOS
void GUI::setup_left_box(){
	// create label
	GtkWidget * cpu_frame;
	cpu_frame = gtk_frame_new ("CPU");
	
	// create cpu box
	GtkWidget * cpu_box;
	cpu_box = gtk_vbox_new (FALSE, 0);

	/*	IC REGISTER */	
	// ic box
	GtkWidget * ic_box;
	ic_box = gtk_hbox_new (FALSE, 0);
	// ic label 
	GtkWidget * ic_label;
	ic_label = gtk_label_new ("IC");
	gtk_widget_set_usize (ic_label, 80, 28);
	// create ic
        this->ic_buffer = gtk_entry_buffer_new (NULL, -1);
	this->ic = gtk_entry_new_with_buffer (this->ic_buffer);
	gtk_entry_set_editable (GTK_ENTRY(this->ic), FALSE);
	gtk_widget_set_can_focus (this->ic, FALSE);
	// add content to ic_box
	gtk_box_pack_start (GTK_BOX (ic_box), ic_label, FALSE, FALSE, 20);
	gtk_box_pack_start (GTK_BOX (ic_box), this->ic, FALSE, FALSE, 5);
	
	/*	ST REGISTER */
	// st box 
	GtkWidget * st_box;
	st_box = gtk_hbox_new (FALSE, 0);
	// ic label 
	GtkWidget * st_label;
	st_label = gtk_label_new ("ST");
	gtk_widget_set_usize (st_label, 80, 28);
	// create ic
        this->st_buffer = gtk_entry_buffer_new (NULL, -1);
	this->st = gtk_entry_new_with_buffer (this->st_buffer);
	gtk_entry_set_editable (GTK_ENTRY(this->st), FALSE);
	gtk_widget_set_can_focus (this->st, FALSE);
	// add content to ic_box
	gtk_box_pack_start (GTK_BOX (st_box), st_label, FALSE, FALSE, 20);
	gtk_box_pack_end (GTK_BOX (st_box), this->st, FALSE, FALSE, 5);
	
	// add ic_box to cpu box
	gtk_box_pack_start (GTK_BOX (cpu_box), ic_box, FALSE, FALSE, 5);
	gtk_box_pack_end (GTK_BOX (cpu_box), st_box, FALSE, FALSE, 5);
	
	// put cpu_box in cpu_frame
	gtk_container_add (GTK_CONTAINER (cpu_frame), cpu_box);

	// left top box
	GtkWidget * left_top_box;
	left_top_box = gtk_hbox_new (FALSE, 5);
	gtk_box_pack_start (GTK_BOX (left_top_box), cpu_frame, FALSE, FALSE, 0);
	this->left_box = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (this->left_box), left_top_box, FALSE, FALSE, 0);


        // CHANNELS

        // channels frame
	GtkWidget * channels_frame;
	channels_frame = gtk_frame_new ("CHANNELS");

        GtkWidget * channels_vbox;
        channels_vbox = gtk_vbox_new (FALSE, 5);


        // keyboard
        GtkWidget * kb_box;
	kb_box = gtk_hbox_new (FALSE, 0);
        GtkWidget * kb_label;
	kb_label = gtk_label_new ("KEYBOARD");
        gtk_widget_set_usize (kb_label, 80, 28);
        this->keyboard_channel = gtk_entry_new ();
	gtk_entry_set_editable (GTK_ENTRY(this->keyboard_channel), FALSE);
	gtk_widget_set_can_focus (this->keyboard_channel, FALSE);
        gtk_box_pack_start (GTK_BOX (kb_box), kb_label, FALSE, FALSE, 20);
	gtk_box_pack_end (GTK_BOX (kb_box), this->keyboard_channel, FALSE, FALSE, 5);

        gtk_box_pack_start (GTK_BOX (channels_vbox ), kb_box, FALSE, FALSE, 0);


        // monitor
        GtkWidget * mn_box;
	mn_box = gtk_hbox_new (FALSE, 0);
        GtkWidget * mn_label;
	mn_label = gtk_label_new ("MONITOR");
        gtk_widget_set_usize (mn_label, 80, 28);
        this->monitor_channel = gtk_entry_new ();
	gtk_entry_set_editable (GTK_ENTRY(this->monitor_channel), FALSE);
	gtk_widget_set_can_focus (this->monitor_channel, FALSE);
        gtk_box_pack_start (GTK_BOX (mn_box), mn_label, FALSE, FALSE, 20);
	gtk_box_pack_end (GTK_BOX (mn_box), this->monitor_channel, FALSE, FALSE, 5);
        gtk_box_pack_start (GTK_BOX (channels_vbox), mn_box, FALSE, FALSE, 0);

        // hdd
        GtkWidget * hdd_box;
	hdd_box = gtk_hbox_new (FALSE, 0);
        GtkWidget * hdd_label;
	hdd_label = gtk_label_new ("HDD");
        gtk_widget_set_usize (hdd_label, 80, 28);
        this->hdd_channel = gtk_entry_new ();
	gtk_entry_set_editable (GTK_ENTRY(this->hdd_channel), FALSE);
	gtk_widget_set_can_focus (this->hdd_channel, FALSE);
        gtk_box_pack_start (GTK_BOX (hdd_box), hdd_label, FALSE, FALSE, 20);
	gtk_box_pack_end (GTK_BOX (hdd_box), this->hdd_channel, FALSE, FALSE, 5);
        gtk_box_pack_start (GTK_BOX (channels_vbox), hdd_box, FALSE, FALSE, 0);


        gtk_container_add (GTK_CONTAINER (channels_frame), channels_vbox);
        gtk_box_pack_start (GTK_BOX (this->left_box), channels_frame, FALSE, FALSE, 0);
        
        GtkWidget * control_buttons;
        control_buttons = gtk_vbutton_box_new ();

        this->rm_mem_show_button = gtk_button_new_with_label("Show RM memory");
        g_signal_connect (this->rm_mem_show_button, "clicked", G_CALLBACK (GUI::rm_mem_show_button_clicked), gpointer(this));

        gtk_box_pack_start (GTK_BOX (control_buttons), this->rm_mem_show_button, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (this->left_box), control_buttons, FALSE, FALSE, 0);

}
Esempio n. 7
0
int main(int argc, char **argv)
{
#ifdef ENABLE_NLS
	gtk_set_locale();
	textdomain(GETTEXT_PACKAGE);
#endif

	GtkWidget *window; /* 主窗口 */
	GtkWidget *vbox; /* 垂直盒子 */
	GtkWidget *hbox; /* 水平盒子 */
	GtkWidget *label; /* 静态标签 */
	GtkWidget *table; /* 表布局 */
	GtkWidget *entry; /* 文本框 */
	GtkWidget *checkButton; /* 复选项 */
	GtkWidget *button; /* 按键 */
	GtkEntryBuffer *buffer; /* 文本框缓存 */

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);

	gtk_container_set_border_width(GTK_CONTAINER(window), 10);

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	label = gtk_label_new(_("欢迎使用 Mentohust 认证程序"));
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	/* 开始主体表布局 */
	table = gtk_table_new(2, 1, FALSE);
	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);

	label = gtk_label_new(_("用户名"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

	label = gtk_label_new(_("密码"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

	/* 用户名文本框 */
	buffer = gtk_entry_buffer_new (NULL, 0);
	entry = gtk_entry_new_with_buffer(buffer);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 0, 1);

	/* 密码文本框 */
	buffer = gtk_entry_buffer_new (NULL, 0);
	entry = gtk_entry_new_with_buffer(buffer);
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 1, 2);
	/* 完成主体表布局 */

	hbox = gtk_hbox_new(FALSE, 5);

	checkButton = gtk_check_button_new_with_label(_("保存密码"));
	gtk_box_pack_end(GTK_BOX(hbox), checkButton, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	/* 开始底部按键组 */
	hbox = gtk_hbox_new(FALSE, 5);

	button = gtk_button_new_with_label(_("连接"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label(_("退出"));
	g_signal_connect (button, "clicked", G_CALLBACK (destroy), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	
	button = gtk_button_new_with_label(_("消息记录"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	button = gtk_button_new_with_label(_("高级设置"));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	/* 完成底部按键组 */

	gtk_widget_show_all(window);

	gtk_main();

	return 0;
}
Esempio n. 8
0
void janela_cadastro_de_filmes()
{
    GtkWidget *window, *vbox, *nomeEntry, *generoEntry, *anoEntry, *button, *fixed, *label;
    GtkEntryBuffer *nomeBuffer, *generoBuffer, *anoBuffer;
    gint tmp_pos;

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (window, FALSE);
    gtk_window_set_position(GTK_WINDOW (window), GTK_WIN_POS_CENTER);
    gtk_widget_set_size_request(GTK_WIDGET (window), 400, 250);
    gtk_window_set_title(GTK_WINDOW (window), "Cadastro de Filmes");
    gtk_container_set_border_width(GTK_CONTAINER (window), 10);

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

    label = gtk_label_new ("Insira abaixo o nome do filme");
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

    nomeBuffer = gtk_entry_buffer_new("Ex.: Star Wars", 14);
    nomeEntry = gtk_entry_new_with_buffer(nomeBuffer);
    gtk_entry_set_max_length(GTK_ENTRY(nomeEntry), 100);
    g_signal_connect(nomeEntry, "changed", G_CALLBACK(enter_nome_filme), nomeEntry);
    tmp_pos = GTK_ENTRY(nomeEntry)->text_length;
    gtk_editable_select_region(GTK_EDITABLE(nomeEntry), 0, GTK_ENTRY(nomeEntry)->text_length);
    gtk_box_pack_start(GTK_BOX(vbox), nomeEntry, TRUE, TRUE, 0);
    gtk_widget_show(nomeEntry);

    label = gtk_label_new ("Insira abaixo o genero do filme");
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

    generoBuffer = gtk_entry_buffer_new("Ex.: Acao", 9);
    generoEntry = gtk_entry_new_with_buffer(generoBuffer);
    gtk_entry_set_max_length(GTK_ENTRY(generoEntry), 100);
    g_signal_connect(generoEntry, "changed", G_CALLBACK(enter_genero_filme), generoEntry);
    tmp_pos = GTK_ENTRY(generoEntry)->text_length;
    gtk_editable_select_region(GTK_EDITABLE(generoEntry), 0, GTK_ENTRY(generoEntry)->text_length);
    gtk_box_pack_start(GTK_BOX(vbox), generoEntry, TRUE, TRUE, 0);
    gtk_widget_show(generoEntry);

    label = gtk_label_new ("Insira abaixo o ano do filme");
    gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

    anoBuffer = gtk_entry_buffer_new("Ex.: 1998", 9);
    anoEntry = gtk_entry_new_with_buffer(anoBuffer);
    gtk_entry_set_max_length(GTK_ENTRY(anoEntry), 100);
    g_signal_connect(anoEntry, "changed", G_CALLBACK(enter_ano_filme), anoEntry);
    tmp_pos = GTK_ENTRY(anoEntry)->text_length;
    gtk_editable_select_region(GTK_EDITABLE(anoEntry), 0, GTK_ENTRY(anoEntry)->text_length);
    gtk_box_pack_start(GTK_BOX(vbox), anoEntry, TRUE, TRUE, 0);
    gtk_widget_show(anoEntry);

    fixed = gtk_fixed_new();
    gtk_container_add(GTK_CONTAINER(vbox), fixed);
    gtk_widget_show (fixed);

    button = gtk_button_new_with_label ("Concluir");
    g_signal_connect (button, "clicked", G_CALLBACK (cadastro_de_filmes), window);
    gtk_fixed_put(GTK_FIXED(fixed), button, 230, 15);
    gtk_widget_set_size_request(button, 150, 35);
    gtk_widget_show(button);

    gtk_widget_show_all (window);
}
static void
setup_main (BastileWidget *swidget)
{
	BastileObject *object;
	GtkEntryBuffer *buffer;
	GtkWidget *widget;
	GtkWidget *box;

	object = BASTILE_OBJECT_WIDGET (swidget)->object;

	/* Setup the image properly */
	bastile_bind_property ("icon", object, "stock", 
	                        bastile_widget_get_widget (swidget, "key-image"));
	
	/* Setup the label properly */
	bastile_bind_property ("label", object, "text", 
	                        bastile_widget_get_widget (swidget, "description-field") );
	
	/* Window title */
	bastile_bind_property ("label", object, "title", 
	                        bastile_widget_get_toplevel (swidget));
	
	/* Usage */
	bastile_bind_property_full ("use", object, transform_item_use, "label", 
	                             bastile_widget_get_widget (swidget, "use-field"), NULL);
	
	/* Item Type */
	bastile_bind_property_full ("use", object, transform_item_type, "label", 
	                             bastile_widget_get_widget (swidget, "type-field"), NULL);
	
	/* Network field visibility */
	bastile_bind_property_full ("use", object, transform_network_visible, "visible",
	                             bastile_widget_get_widget (swidget, "server-label"),
	                             bastile_widget_get_widget (swidget, "server-field"),
	                             bastile_widget_get_widget (swidget, "login-label"),
	                             bastile_widget_get_widget (swidget, "login-field"), NULL);

	/* Server name */
	bastile_bind_property_full ("item-attributes", object, transform_attributes_server, "label", 
	                             bastile_widget_get_widget (swidget, "server-field"), NULL);
	
	/* User name */
	bastile_bind_property_full ("item-attributes", object, transform_attributes_user, "label", 
	                             bastile_widget_get_widget (swidget, "login-field"), NULL);

	/* Create the password entry */
	buffer = bastile_secure_buffer_new ();
	widget = gtk_entry_new_with_buffer (buffer);
	g_object_unref (buffer);

	box = bastile_widget_get_widget (swidget, "password-box-area");
	g_return_if_fail (box != NULL);
	gtk_container_add (GTK_CONTAINER (box), widget);
	g_object_set_data (G_OBJECT (swidget), "secure-password-entry", widget);
	gtk_widget_show (widget);
	        
	/* Now watch for changes in the password */
	g_signal_connect (widget, "activate", G_CALLBACK (password_activate), swidget);
	g_signal_connect (widget, "changed", G_CALLBACK (password_changed), swidget);
	g_signal_connect_after (widget, "focus-out-event", G_CALLBACK (password_focus_out), swidget);

	/* Sensitivity of the password entry */
	bastile_bind_property ("has-secret", object, "sensitive", widget);

	/* Updating of the password entry */
	bastile_bind_objects ("has-secret", object, (BastileTransfer)transfer_password, swidget);

	widget = bastile_widget_get_widget (swidget, "show-password-check");
	on_item_show_password_toggled (GTK_TOGGLE_BUTTON (widget), swidget);
}
Esempio n. 10
0
GtkDialog*
seahorse_passphrase_prompt_show (const gchar *title, const gchar *description, 
                                 const gchar *prompt, const gchar *check,
                                 gboolean confirm)
{
    GtkEntryBuffer *buffer;
    GtkEntry *entry;
    GtkDialog *dialog;
    GtkWidget *w;
    GtkWidget *box;
    GtkTable *table;
    GtkWidget *wvbox;
    GtkWidget *chbox;
    gchar *msg;
    
    if (!title)
        title = _("Passphrase");

    if (!prompt)
        prompt = _("Password:"******"size-request", G_CALLBACK (constrain_size), NULL);
    g_signal_connect (G_OBJECT (dialog), "map-event", G_CALLBACK (grab_keyboard), NULL);
    g_signal_connect (G_OBJECT (dialog), "unmap-event", G_CALLBACK (ungrab_keyboard), NULL);
    g_signal_connect (G_OBJECT (dialog), "window-state-event", G_CALLBACK (window_state_changed), NULL); 

    wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2);
    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), wvbox);
    gtk_container_set_border_width (GTK_CONTAINER (wvbox), HIG_LARGE);

    chbox = gtk_hbox_new (FALSE, HIG_LARGE);
    gtk_box_pack_start (GTK_BOX (wvbox), chbox, FALSE, FALSE, 0);

    /* The image */
    w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
    gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
    gtk_box_pack_start (GTK_BOX (chbox), w, FALSE, FALSE, 0);

    box = gtk_vbox_new (FALSE, HIG_SMALL);
    gtk_box_pack_start (GTK_BOX (chbox), box, TRUE, TRUE, 0);

    /* The description text */
    if (description) {
        msg = utf8_validate (description);
        w = gtk_label_new (msg);
        g_free (msg);

        gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
        gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
        gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0);
    }

    /* Two entries (usually on is hidden)  in a vbox */
    table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
    gtk_table_set_row_spacings (table, HIG_SMALL);
    gtk_table_set_col_spacings (table, HIG_LARGE);
    gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (table), FALSE, FALSE, 0);

    /* The first entry if we have one */
    if (confirm) {
        msg = utf8_validate (prompt);
        w = gtk_label_new (msg);
        g_free (msg);
        gtk_table_attach (table, w, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);

        buffer = seahorse_secure_buffer_new ();
        entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer));
        g_object_unref (buffer);
        gtk_entry_set_visibility (entry, FALSE);
        gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1);
        g_object_set_data (G_OBJECT (dialog), "confirm-entry", entry);
        g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (confirm_callback), dialog);
        g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog);
        gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 0, 1);
        gtk_widget_grab_focus (GTK_WIDGET (entry));
    }

    /* The second and main entry */
    msg = utf8_validate (confirm ? _("Confirm:") : prompt);
    w = gtk_label_new (msg);
    g_free (msg);
    gtk_table_attach (table, w, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);

    buffer = seahorse_secure_buffer_new ();
    entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer));
    g_object_unref (buffer);
    gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1);
    gtk_entry_set_visibility (entry, FALSE);
    g_object_set_data (G_OBJECT (dialog), "secure-entry", entry);
    g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), dialog);
    gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 1, 2);
    if (!confirm)
        gtk_widget_grab_focus (GTK_WIDGET (entry));
    else
        g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog);

    /* The checkbox */
    if (check) {
        w = gtk_check_button_new_with_mnemonic (check);
        gtk_table_attach_defaults (table, w, 1, 2, 2, 3);
        g_object_set_data (G_OBJECT (dialog), "check-option", w);
    }

    gtk_widget_show_all (GTK_WIDGET (table));
    
    w = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
    gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_REJECT);
    gtk_widget_set_can_default (w, TRUE);

    w = gtk_button_new_from_stock (GTK_STOCK_OK);
    gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_ACCEPT);
    gtk_widget_set_can_default (w, TRUE);
    g_signal_connect_object (G_OBJECT (entry), "focus_in_event",
                             G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0);
    gtk_widget_grab_default (w);
    
    g_signal_connect (dialog, "key_press_event", G_CALLBACK (key_press), NULL);

    gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);    
    gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL);
    gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
    gtk_widget_show_all (GTK_WIDGET (dialog));
    gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (dialog)), GDK_CURRENT_TIME);

    if (confirm)
        entry_changed (NULL, dialog);
    
    return dialog;
}
Esempio n. 11
0
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;
}