コード例 #1
0
void
seahorse_gpgme_add_subkey_new (SeahorseGpgmeKey *pkey, GtkWindow *parent)
{
	SeahorseWidget *swidget;
	GtkComboBox* combo;
	GtkTreeModel *model;
	GtkTreeIter iter;
	GtkCellRenderer *renderer;
	GtkWidget *widget, *datetime;

	swidget = seahorse_object_widget_new ("add-subkey", parent, G_OBJECT (pkey));
	g_return_if_fail (swidget != NULL);
	
	gtk_window_set_title (GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)),
		g_strdup_printf (_("Add subkey to %s"), seahorse_object_get_label (SEAHORSE_OBJECT (pkey))));
    
    combo = GTK_COMBO_BOX (seahorse_widget_get_widget (swidget, "type"));
    model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT));
    
    gtk_combo_box_set_model (combo, model);
        
    gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
    renderer = gtk_cell_renderer_text_new ();
    
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer,
                                    "text", COMBO_STRING);
                                    
    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("DSA (sign only)"),
                        COMBO_INT, 0,
                        -1);
                        
    gtk_combo_box_set_active_iter (combo, &iter);
    
    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("ElGamal (encrypt only)"),
                        COMBO_INT, 1,
                        -1);
                        
	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("RSA (sign only)"),
                        COMBO_INT, 2,
                        -1);
    
	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("RSA (encrypt only)"),
                        COMBO_INT, 3,
                        -1);
    
	widget = seahorse_widget_get_widget (swidget, "datetime-placeholder");
	g_return_if_fail (widget != NULL);

	datetime = egg_datetime_new ();
	gtk_container_add (GTK_CONTAINER (widget), datetime);
	gtk_widget_show (datetime);
	gtk_widget_set_sensitive (datetime, FALSE);
	g_object_set_data (G_OBJECT (swidget), "expires-datetime", datetime);
}
コード例 #2
0
ファイル: test-datetime.c プロジェクト: GNOME/libegg
static void
gui (int argc, char *argv[], GMainLoop *main_loop)
{
	GtkWidget *win;
	GtkWidget *main_box, *hbox, *vbox;
	GtkWidget *label, *check;
	GtkWidget *edt;
	PangoAttrList *attrs;
	PangoAttribute *attr;

	gtk_init (&argc, &argv);

	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (win), _("EggDateTime Test"));
	gtk_container_set_border_width (GTK_CONTAINER (win), 6);
	g_signal_connect_swapped (G_OBJECT (win), "delete_event",
				  G_CALLBACK (g_main_loop_quit), main_loop);

	main_box = gtk_vbox_new (FALSE, 6);
	gtk_widget_show (main_box);
	gtk_container_add (GTK_CONTAINER (win), main_box);

	/* Date/Time widget */

	hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox);
	gtk_box_pack_start (GTK_BOX (main_box), hbox, FALSE, FALSE, 0);

	edt = egg_datetime_new ();
	gtk_widget_show (edt);
	gtk_box_pack_start (GTK_BOX (hbox), edt, FALSE, FALSE, 0);

	/* Options */

	attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
	attr->start_index = 0;
	attr->end_index   = G_MAXUINT;
	attrs = pango_attr_list_new ();
	pango_attr_list_insert (attrs, attr);

	label = gtk_label_new (_("Options"));
	gtk_label_set_attributes (GTK_LABEL (label), attrs);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_widget_show (label);
	gtk_box_pack_start (GTK_BOX (main_box), label, FALSE, FALSE, 6);

	hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox);
	gtk_box_pack_start (GTK_BOX (main_box), hbox, FALSE, FALSE, 0);

	label = gtk_label_new ("");
	gtk_widget_set_size_request (label, 12, -1);
	gtk_widget_show (label);
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

	vbox = gtk_vbox_new (TRUE, 6);
	gtk_widget_show (vbox);
	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);

	check = gtk_check_button_new_with_mnemonic (_("Show _date"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
	gtk_widget_show (check);
	g_signal_connect (G_OBJECT (check), "toggled",
			  G_CALLBACK (show_date_toggled_cb), edt);
	gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);

	check = gtk_check_button_new_with_mnemonic (_("Show _time"));
	gtk_widget_show (check);
	g_signal_connect (G_OBJECT (check), "toggled",
			  G_CALLBACK (show_time_toggled_cb), edt);
	gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);

	check = gtk_check_button_new_with_mnemonic (_("_Lazy mode"));
	gtk_widget_show (check);
	g_signal_connect (G_OBJECT (check), "toggled",
			  G_CALLBACK (lazy_mode_toggled_cb), edt);
	gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);

	gtk_widget_show (win);
}