Exemplo n.º 1
0
GtkWidget *tip_window_new_autocomp (gchar *tip)
{
	GtkWidget *win;
	GtkWidget *label;
	GtkWidget *eb;
	PangoFontDescription *pfd;

	win = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_container_set_border_width (GTK_CONTAINER (win), 0);

	eb = gtk_event_box_new ();
	gtk_container_set_border_width (GTK_CONTAINER (eb), 1);
	gtk_container_add (GTK_CONTAINER (win), eb);

	label = gtk_label_new (tip);  
	gtk_container_add (GTK_CONTAINER (eb), label);

	pfd = pango_font_description_from_string ("courier");
	gtk_widget_modify_font (label, pfd);

	return win;
}
Exemplo n.º 2
0
static void
draw_text (cairo_t *cr)
{
#define RADIUS 150
#define N_WORDS 10
#define FONT "Sans Bold 27"
  PangoLayout *layout;
  PangoFontDescription *desc;
  int i;
  /* Center coordinates on the middle of the region we are drawing
   */
  cairo_translate (cr, RADIUS, RADIUS);
  /* Create a PangoLayout, set the font and text */
  layout = pango_cairo_create_layout (cr);
  pango_layout_set_text (layout, "Text", -1);
  desc = pango_font_description_from_string (FONT);
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc);
  /* Draw the layout N_WORDS times in a circle */
  for (i = 0; i < N_WORDS; i++)
    {
      int width, height;
      double angle = (360. * i) / N_WORDS;
      double red;
      cairo_save (cr);
      /* Gradient from red at angle == 60 to blue at angle == 240 */
      red   = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
      cairo_set_source_rgb (cr, red, 0, 1.0 - red);
      cairo_rotate (cr, angle * G_PI / 180.);
      /* Inform Pango to re-layout the text with the new transformation */
      pango_cairo_update_layout (cr, layout);
      pango_layout_get_size (layout, &width, &height);
      cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
      pango_cairo_show_layout (cr, layout);
      cairo_restore (cr);
    }
  /* free the layout object */
  g_object_unref (layout);
}
Exemplo n.º 3
0
static GtkCssValue *
gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
{
  GValue value = G_VALUE_INIT;
  GtkCssValue *result;

  g_value_init (&value, pspec->value_type);


G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
    g_value_set_object (&value, gtk_theming_engine_load (NULL));
  else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
    g_value_take_boxed (&value, pango_font_description_from_string ("Sans 10"));
  else if (pspec->value_type == GDK_TYPE_RGBA)
    {
      GdkRGBA color;
      gdk_rgba_parse (&color, "pink");
      g_value_set_boxed (&value, &color);
    }
  else if (pspec->value_type == g_type_from_name ("GdkColor"))
    {
      GdkColor color;
      gdk_color_parse ("pink", &color);
      g_value_set_boxed (&value, &color);
    }
  else if (pspec->value_type == GTK_TYPE_BORDER)
    {
      g_value_take_boxed (&value, gtk_border_new ());
    }
  else
    g_param_value_set_default (pspec, &value);
G_GNUC_END_IGNORE_DEPRECATIONS

  result = _gtk_css_typed_value_new (&value);
  g_value_unset (&value);

  return result;
}
Exemplo n.º 4
0
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text,
		int32_t scale, bool markup) {
	PangoLayout *layout = pango_cairo_create_layout(cairo);
	PangoAttrList *attrs;
	if (markup) {
		char *buf;
		pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL);
		pango_layout_set_markup(layout, buf, -1);
		free(buf);
	} else {
		attrs = pango_attr_list_new();
		pango_layout_set_text(layout, text, -1);
	}
	pango_attr_list_insert(attrs, pango_attr_scale_new(scale));
	PangoFontDescription *desc = pango_font_description_from_string(font);
	pango_layout_set_font_description(layout, desc);
	pango_layout_set_single_paragraph_mode(layout, 1);
	pango_layout_set_attributes(layout, attrs);
	pango_attr_list_unref(attrs);
	pango_font_description_free(desc);
	return layout;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
  (JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
  const char *font_name;
  void *ptr;
  GtkWidget *button;
  GtkWidget *label;
  PangoFontDescription *font_desc;

  ptr = NSA_GET_PTR (env, obj);

  button = GTK_WIDGET (ptr);
  label = gtk_bin_get_child (GTK_BIN(button));

  if (!label)
      return;

  font_name = (*env)->GetStringUTFChars (env, name, NULL);

  gdk_threads_enter();

  font_desc = pango_font_description_from_string (font_name);
  pango_font_description_set_size (font_desc, size * dpi_conversion_factor);

  if (style & AWT_STYLE_BOLD)
    pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);

  if (style & AWT_STYLE_ITALIC)
    pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
  
  gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
  
  pango_font_description_free (font_desc);
  
  gdk_threads_leave();
  
  (*env)->ReleaseStringUTFChars (env, name, font_name);
}
GtTextWidthCalculator* gt_text_width_calculator_cairo_new(cairo_t *context,
                                                          GtStyle *style,
                                                          GtError *err)
{
  GtTextWidthCalculatorCairo *twcc;
  GtTextWidthCalculator *twc;
  double theight = TEXT_SIZE_DEFAULT;
  char buf[64];
  twc = gt_text_width_calculator_create(gt_text_width_calculator_cairo_class());
  twcc = gt_text_width_calculator_cairo_cast(twc);
  if (style)
    twcc->style = gt_style_ref(style);
  if (!context)
  {
    twcc->mysurf = cairo_image_surface_create(GT_TWC_FORMAT, GT_TWC_WIDTH,
                                              GT_TWC_HEIGHT);
    twcc->context = cairo_create(twcc->mysurf);
    twcc->own_context = true;
  } else {
    twcc->context = context;
    twcc->own_context = false;
  }
  if (twcc->style)
  {
    if (gt_style_get_num(twcc->style,
                         "format", "block_caption_font_size",
                         &theight, NULL, err) == GT_STYLE_QUERY_ERROR) {
      gt_text_width_calculator_delete(twc);
      return NULL;
    }
    cairo_save(twcc->context);
  }
  twcc->layout = pango_cairo_create_layout(twcc->context);
  snprintf(buf, 64, "Sans %d", (int) theight);
  twcc->desc = pango_font_description_from_string(buf);
  pango_layout_set_font_description(twcc->layout, twcc->desc);
  pango_font_description_free(twcc->desc);
  return twc;
}
Exemplo n.º 7
0
int main (int argc,
          char *argv[])
{
    GtkWidget *window, *vbox, *button, *label;
    PangoFontDescription *initial_font;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Font Button");
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (destroy), NULL);

    label = gtk_label_new ("Look at the font!");
    initial_font = pango_font_description_from_string ("Sans Bold 12");
    gtk_widget_modify_font (label, initial_font);

    /* Create a new font selection button with the given default font. */
    button = gtk_font_button_new_with_font ("Sans Bold 12");
    gtk_font_button_set_title (GTK_FONT_BUTTON (button), "Choose a Font");

    /* Monitor for changes to the font chosen in the font button. */
    g_signal_connect (G_OBJECT (button), "font_set",
                      G_CALLBACK (font_changed),
                      (gpointer) label);

    vbox= gtk_vbox_new (FALSE, 5);
    gtk_box_pack_start_defaults (GTK_BOX (vbox), button);
    gtk_box_pack_start_defaults (GTK_BOX (vbox), label);

    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show_all (window);

    gtk_main ();
    return 0;
}
Exemplo n.º 8
0
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
	DocInfo *dinfo = user_data;
	PangoFontDescription *desc;

	if (dinfo == NULL)
		return;

	gtk_widget_show(main_widgets.progressbar);

	/* init dinfo fields */

	/* setup printing scintilla object */
	dinfo->sci = editor_create_widget(dinfo->doc->editor);
	scintilla_send_message(dinfo->sci, SCI_SETDOCPOINTER, 0,
			scintilla_send_message(dinfo->doc->editor->sci, SCI_GETDOCPOINTER, 0, 0));
	highlighting_set_styles(dinfo->sci, dinfo->doc->file_type);
	sci_set_line_numbers(dinfo->sci, printing_prefs.print_line_numbers, 0);
	scintilla_send_message(dinfo->sci, SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETVIEWEOL, FALSE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETEDGEMODE, EDGE_NONE, 0);
	scintilla_send_message(dinfo->sci, SCI_SETPRINTMAGNIFICATION, (uptr_t) -2, 0); /* WTF? */
	scintilla_send_message(dinfo->sci, SCI_SETPRINTCOLOURMODE, SC_PRINT_COLOURONWHITE, 0);

	dinfo->pages = g_array_new(FALSE, FALSE, sizeof(gint));

	dinfo->print_time = time(NULL);
	/* create a PangoLayout to be commonly used in add_page_header() and draw_page() */
	desc = pango_font_description_from_string(interface_prefs.editor_font);
	dinfo->layout = setup_pango_layout(context, desc);
	pango_font_description_free(desc);
	get_text_dimensions(dinfo->layout, "|XMfjgq_" /* reasonably representative character set */,
		NULL, &dinfo->line_height);
	get_text_dimensions(dinfo->layout, "99999 " /* Scintilla resets the margin to the width of "99999" when printing */,
		&dinfo->margin_width, NULL);
	/* setup dinfo->fr */
	setup_range(dinfo, context);
}
Exemplo n.º 9
0
static void
vte_config(VteTerminal* vte)
{
    GRegex* regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);

    vte_terminal_search_set_gregex(vte, regex, G_REGEX_MATCH_NOTEMPTY);
    vte_terminal_search_set_wrap_around     (vte, TINYTERM_SEARCH_WRAP_AROUND);
    vte_terminal_set_audible_bell           (vte, TINYTERM_AUDIBLE_BELL);
    vte_terminal_set_cursor_shape           (vte, TINYTERM_CURSOR_SHAPE);
    vte_terminal_set_cursor_blink_mode      (vte, TINYTERM_CURSOR_BLINK);
    vte_terminal_set_word_char_exceptions   (vte, TINYTERM_WORD_CHARS);
    vte_terminal_set_scrollback_lines       (vte, TINYTERM_SCROLLBACK_LINES);
    PangoFontDescription *font = pango_font_description_from_string(TINYTERM_FONT);
    vte_terminal_set_font(vte, font);

    GdkRGBA color_fg, color_bg;
    GdkRGBA color_palette[16];
    gdk_rgba_parse(&color_fg, TINYTERM_COLOR_FOREGROUND);
    gdk_rgba_parse(&color_bg, TINYTERM_COLOR_BACKGROUND);
    gdk_rgba_parse(&color_palette[0], TINYTERM_COLOR00);
    gdk_rgba_parse(&color_palette[1], TINYTERM_COLOR01);
    gdk_rgba_parse(&color_palette[2], TINYTERM_COLOR02);
    gdk_rgba_parse(&color_palette[3], TINYTERM_COLOR03);
    gdk_rgba_parse(&color_palette[4], TINYTERM_COLOR04);
    gdk_rgba_parse(&color_palette[5], TINYTERM_COLOR05);
    gdk_rgba_parse(&color_palette[6], TINYTERM_COLOR06);
    gdk_rgba_parse(&color_palette[7], TINYTERM_COLOR07);
    gdk_rgba_parse(&color_palette[8], TINYTERM_COLOR08);
    gdk_rgba_parse(&color_palette[9], TINYTERM_COLOR09);
    gdk_rgba_parse(&color_palette[10], TINYTERM_COLOR0A);
    gdk_rgba_parse(&color_palette[11], TINYTERM_COLOR0B);
    gdk_rgba_parse(&color_palette[12], TINYTERM_COLOR0C);
    gdk_rgba_parse(&color_palette[13], TINYTERM_COLOR0D);
    gdk_rgba_parse(&color_palette[14], TINYTERM_COLOR0E);
    gdk_rgba_parse(&color_palette[15], TINYTERM_COLOR0F);

    vte_terminal_set_colors(vte, &color_fg, &color_bg, &color_palette, 16);
}
Exemplo n.º 10
0
bool wxNativeFontInfo::FromString(const wxString& s)
{
    if (description)
        pango_font_description_free( description );

    // there is a bug in at least pango <= 1.13 which makes it (or its backends)
    // segfault for very big point sizes and for negative point sizes.
    // To workaround that bug for pango <= 1.13
    // (see http://bugzilla.gnome.org/show_bug.cgi?id=340229)
    // we do the check on the size here using same (arbitrary) limits used by
    // pango > 1.13. Note that the segfault could happen also for pointsize
    // smaller than this limit !!
    wxString str(s);
    const size_t pos = str.find_last_of(_T(" "));
    double size;
    if ( pos != wxString::npos && wxString(str, pos + 1).ToDouble(&size) )
    {
        wxString sizeStr;
        if ( size < 1 )
            sizeStr = _T("1");
        else if ( size >= 1E6 )
            sizeStr = _T("1E6");

        if ( !sizeStr.empty() )
        {
            // replace the old size with the adjusted one
            str = wxString(s, 0, pos) + sizeStr;
        }
    }

    description = pango_font_description_from_string(wxPANGO_CONV(str));

    // ensure a valid facename is selected
    if (!wxFontEnumerator::IsValidFacename(GetFaceName()))
        SetFaceName(wxNORMAL_FONT->GetFaceName());

    return true;
}
Exemplo n.º 11
0
static GogPlot *
setup_page (GtkNotebook *notebook, const gchar *service_id)
{
	GtkWidget *child, *w;
	GogChart *chart;
	GogGraph *graph;
	GogLabel *label;
	GogPlot *plot;
	GOData *data;
	GOStyle *style;
	PangoFontDescription *desc;

	child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_notebook_append_page (notebook, child, gtk_label_new (service_id));
	/* Create a graph widget and add it to the GtkVBox */
	w = go_graph_widget_new (NULL);
	gtk_box_pack_end (GTK_BOX (child), w, TRUE, TRUE, 0);
	/* Get the embedded graph */
	graph = go_graph_widget_get_graph (GO_GRAPH_WIDGET (w));
	/* Add a title */
	label = (GogLabel *) g_object_new (GOG_TYPE_LABEL, NULL);
	data = go_data_scalar_str_new (service_id, FALSE);
	gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
	gog_object_add_by_name (GOG_OBJECT (graph), "Title", GOG_OBJECT (label));
	/* Change the title font */
	style = go_styled_object_get_style (GO_STYLED_OBJECT (label));
	desc = pango_font_description_from_string ("Sans bold 16");
	go_style_set_font_desc (style, desc);
	/* Get the chart created by the widget initialization */
	chart = go_graph_widget_get_chart (GO_GRAPH_WIDGET (w));
	/* Create a plot and add it to the chart */
	plot = (GogPlot *) gog_plot_new_by_name (service_id);
	gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (plot));
	/* Add a legend to the chart */
	gog_object_add_by_name (GOG_OBJECT (chart), "Legend", NULL);

	return plot;
}
Exemplo n.º 12
0
static void
_draw_footer(GtkHTML * html, GtkPrintOperation * operation,
	     GtkPrintContext * context,
	     gint page_nr, PangoRectangle * rec, EDITOR * e)
{
	PangoFontDescription *desc;
	PangoLayout *layout;
	gdouble x, y;
	gint n_pages;
	gchar *text;
	cairo_t *cr;

	g_object_get(operation, "n-pages", &n_pages, NULL);
	text = g_strdup_printf(_("Page %d of %d"), page_nr + 1, n_pages);

	desc = pango_font_description_from_string("Sans Regular 10");
	layout = gtk_print_context_create_pango_layout(context);
	pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
	pango_layout_set_font_description(layout, desc);
	pango_layout_set_text(layout, text, -1);
	pango_layout_set_width(layout, rec->width);

	x = pango_units_to_double(rec->x);
	y = pango_units_to_double(rec->y);

	cr = gtk_print_context_get_cairo_context(context);

	cairo_save(cr);
	cairo_set_source_rgb(cr, .0, .0, .0);
	cairo_move_to(cr, x, y);
	pango_cairo_show_layout(cr, layout);
	cairo_restore(cr);

	g_object_unref(layout);
	pango_font_description_free(desc);

	g_free(text);
}
Exemplo n.º 13
0
//!
//! @brief To be written
//!
void gw_kanjipadwindow_initialize_candidates (GwKanjipadWindow *window)
{
    //Declarations
    GwKanjipadWindowPrivate *priv;
    gint mask;
    PangoFontDescription *desc;

    //Initializations
    priv = window->priv;
    mask = (GDK_EXPOSURE_MASK  | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
    desc = pango_font_description_from_string ("Sans 18");

    g_signal_connect (priv->candidates, "configure_event", G_CALLBACK (gw_kanjipadwindow_candidatearea_configure_event_cb), window);
    g_signal_connect (priv->candidates, "draw", G_CALLBACK (gw_kanjipadwindow_candidatearea_draw_cb), window);
    g_signal_connect (priv->candidates, "button_press_event", G_CALLBACK (gw_kanjipadwindow_candidatearea_button_press_event_cb), window);
    gtk_widget_add_events (GTK_WIDGET (priv->candidates), mask);

    if (desc != NULL)
    {
      gtk_widget_override_font (GTK_WIDGET (priv->candidates), desc);
      pango_font_description_free (desc);
    }
}
Exemplo n.º 14
0
void write_chars(term_data* td, int x, int y, int n, byte a, const char* text)
{
	PangoLayout *layout;
	PangoFontDescription* font;
	cairo_t *cr;
	
	clear_chars(td, x, y, n);
	
	cr = cairo_create(td->surface);
	set_foreground_color(cr, a);
	
	layout = pango_cairo_create_layout(cr);
	font = pango_font_description_from_string(td->font.name);
	pango_layout_set_font_description (layout, font);
	pango_layout_set_text (layout, text, n);
	
	cairo_move_to(cr, x * td->font.w, y * td->font.h);
	pango_cairo_show_layout (cr, layout);

	g_object_unref (layout);
	pango_font_description_free(font);
	cairo_destroy(cr);
}
Exemplo n.º 15
0
Arquivo: main.c Projeto: 4179e1/misc
void select_font(GtkWidget *widget, gpointer label)
{
	GtkResponseType result;

	GtkWidget *dialog = gtk_font_selection_dialog_new("Select Font");
	result = gtk_dialog_run(GTK_DIALOG(dialog));

	if( result == GTK_RESPONSE_OK || result == GTK_RESPONSE_APPLY)
	{
		PangoFontDescription *font_desc;
		gchar *fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));

		g_printf("%s\n", fontname);

		font_desc = pango_font_description_from_string(fontname);

		gtk_widget_modify_font(GTK_WIDGET(label), font_desc);

		g_free(fontname);
	}

	gtk_widget_destroy(dialog);
}
Exemplo n.º 16
0
static void
chat_text_view_system_font_update (EmpathyChatTextView *view)
{
	EmpathyChatTextViewPriv *priv = GET_PRIV (view);
	PangoFontDescription *font_description = NULL;
	gchar                *font_name;

	font_name = g_settings_get_string (priv->gsettings_desktop,
			EMPATHY_PREFS_DESKTOP_INTERFACE_DOCUMENT_FONT_NAME);

	if (font_name != NULL) {
		font_description = pango_font_description_from_string (font_name);
		g_free (font_name);
	} else {
		font_description = NULL;
	}

	gtk_widget_override_font (GTK_WIDGET (view), font_description);

	if (font_description) {
		pango_font_description_free (font_description);
	}
}
Exemplo n.º 17
0
static void prepare_file_view(void)
{
	GtkCellRenderer *text_renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	PangoFontDescription *pfd;

	file_store = gtk_list_store_new(FILEVIEW_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);

	gtk_tree_view_set_model(GTK_TREE_VIEW(file_view), GTK_TREE_MODEL(file_store));

	text_renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new();
	gtk_tree_view_column_pack_start(column, text_renderer, TRUE);
	gtk_tree_view_column_set_attributes(column, text_renderer, "text", FILEVIEW_COLUMN_NAME,
					    NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(file_view), column);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(file_view), FALSE);

	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(file_view), TRUE);
	gtk_tree_view_set_search_column(GTK_TREE_VIEW(file_view), FILEVIEW_COLUMN_NAME);

	pfd = pango_font_description_from_string(geany_data->interface_prefs->tagbar_font);
	gtk_widget_modify_font(file_view, pfd);
	pango_font_description_free(pfd);

	/* selection handling */
	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(file_view));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	g_signal_connect(G_OBJECT(file_view), "button-release-event",
			 G_CALLBACK(on_button_release), NULL);
	g_signal_connect(G_OBJECT(file_view), "button-press-event",
			 G_CALLBACK(on_button_press), NULL);

	g_signal_connect(G_OBJECT(file_view), "key-press-event", G_CALLBACK(on_key_press), NULL);
}
Exemplo n.º 18
0
static void create_gui(struct application_info *app)
{
	PangoFontDescription *font_desc = NULL;

	/* Main window. */
	app->gui.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(app->gui.window), "delete_event",
	                 G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(app->gui.window), "destroy",
	                 G_CALLBACK(gtk_main_quit), NULL);
	gtk_window_set_has_resize_grip(GTK_WINDOW(app->gui.window), FALSE);
	gtk_window_set_title(GTK_WINDOW(app->gui.window), "stopclock");

	/* The layout box. */
	app->gui.box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);

	/* Create two labels and adjust their font. */
	app->gui.clock = gtk_label_new("00:00");
	app->gui.timer = gtk_label_new("00:00:00");
	update_labels(app);

	font_desc = pango_font_description_from_string(LABEL_FONT);
	gtk_widget_modify_font(app->gui.clock, font_desc);
	gtk_widget_modify_font(app->gui.timer, font_desc);
	pango_font_description_free(font_desc);

	/* Timeout callback. */
	g_timeout_add(500, (GSourceFunc)update_labels, app);

	/* Connect all the containers and show the window. */
	gtk_box_pack_start(GTK_BOX(app->gui.box), app->gui.clock,
	                   TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(app->gui.box), app->gui.timer,
	                   TRUE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(app->gui.window), app->gui.box);
	gtk_widget_show_all(app->gui.window);
}
Exemplo n.º 19
0
Arquivo: style.c Projeto: Guff/lualock
void style_set(const gchar *font, gint x, gint y, gint off_x, gint off_y,
               gint width, gint height, gdouble r, gdouble g, gdouble b,
               gdouble a, const gchar *bg, const gchar *border,
               gdouble border_width) {
    if (font) {
        pango_font_description_free(lualock.style.font_desc);
        lualock.style.font_desc = pango_font_description_from_string(font);
    }
    
    lualock.style.x = x;
    lualock.style.y = y;
    lualock.style.off_x = off_x;
    lualock.style.off_y = off_y;
    lualock.style.width = width;
    lualock.style.height = height;
    lualock.style.r = r;
    lualock.style.g = g;
    lualock.style.b = b;
    lualock.style.a = a;
    
    GdkRGBA bg_color, border_color;
    
    gdk_rgba_parse(&bg_color, bg ? bg : "white");
    
    lualock.style.bg_color = bg_color;
    
    gdk_rgba_parse(&border_color, border ? border : "rgba(0, 0, 0, 0.6)");
    
    lualock.style.border_color = border_color;
    
    lualock.style.border_width = border_width;
    
    cairo_surface_t *old_pw_surface = lualock.pw_surface;
    lualock.pw_surface = create_surface(width, height);
    cairo_surface_destroy(old_pw_surface);
}
Exemplo n.º 20
0
static void init_ui( squidge_t *sq )
{
	GtkBuilder *builder;
	PangoFontDescription *pf;
	GtkAdjustment *v;

	builder = gtk_builder_new();
	g_assert( gtk_builder_add_from_string( builder, squidge_gtkbuilder, -1, NULL ) );

	obj( GTK_WINDOW, win );
	obj( GTK_NOTEBOOK, notebook );
	obj( GTK_IMAGE, splash );
	obj( GTK_TEXT_VIEW, log_textview );
	obj( GTK_SCROLLED_WINDOW, log_scroll );

	sq->ui.text_buffer = gtk_text_view_get_buffer(sq->ui.log_textview);
	load_splash(sq);
	camview_init( &sq->camview, builder );

	/* We want a monospace font */
	pf = pango_font_description_from_string("Monospace 10");
	g_assert( pf != NULL );
	gtk_widget_modify_font( GTK_WIDGET(sq->ui.log_textview), pf );
	pango_font_description_free( pf );

	/* We want the value-changed signal so we can stop following the bottom */
	v = gtk_scrolled_window_get_vadjustment( sq->ui.log_scroll );
	g_signal_connect( v, "value-changed",
			  G_CALLBACK(vert_value_changed), sq );
	g_signal_connect( v, "changed",
			  G_CALLBACK(vert_changed), sq );

	gtk_builder_connect_signals( builder, sq );
	g_object_unref( G_OBJECT(builder) );
	gtk_widget_show( GTK_WIDGET(sq->ui.win) );
}
Exemplo n.º 21
0
static void
mosaic_search_box_paint (MosaicSearchBox *box, cairo_t *cr, gint width, gint height)
{
  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
  cairo_rectangle (cr, 0, 0, width, height);
  cairo_fill (cr);

  PangoLayout *pl;
  PangoFontDescription *pfd;
  pl = pango_cairo_create_layout (cr);
  pango_layout_set_text (pl, MOSAIC_BOX (box)->name, -1);
  pfd = pango_font_description_from_string (MOSAIC_BOX (box)->font);
  pango_layout_set_font_description (pl, pfd);
  pango_font_description_free (pfd);

  int pwidth, pheight;
  pango_layout_get_pixel_size (pl, &pwidth, &pheight);

  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);

  if ((width-pwidth) < 10)
    cairo_move_to (cr, width-pwidth-5, (height-pheight)/2);
  else
    cairo_move_to (cr, 5, (height-pheight)/2);

  pango_cairo_show_layout (cr, pl);
  g_object_unref (pl);

  if ((width-pwidth) < 10)
    cairo_rectangle (cr, width-4, 5, 2, height-10);
  else
    cairo_rectangle (cr, pwidth+6, 5, 2, height-10);
  cairo_fill (cr);

  mosaic_box_paint (MOSAIC_BOX (box), cr, width, height);
}
Exemplo n.º 22
0
struct point ui_get_text_size(const char *str, const char *fontdesc)
{
	cairo_surface_t *cs;
	cairo_t *c;
	PangoLayout *layout;
	PangoFontDescription *font;
	struct point point;

	cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 120, 120);
	c = cairo_create(cs);
	layout = pango_cairo_create_layout(c);
	font = pango_font_description_from_string(fontdesc);
	pango_layout_set_font_description(layout, font);
	pango_layout_set_markup(layout, str, -1);
	cairo_set_source_rgba(c, 0, 0, 0, 1.0);
	pango_cairo_update_layout(c, layout);
	pango_layout_get_pixel_size(layout, &point.x, &point.y);
	cairo_surface_destroy(cs);
	cairo_destroy(c);
	pango_font_description_free(font);
	g_object_unref(layout);

	return point;
}
Exemplo n.º 23
0
void pango_render_text(char* message)
{
	cairo_surface_t *surface;
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 640, 480);

	cairo_t *context;
	context = cairo_create(surface);

	cairo_set_source_rgb(context, 1.0, 0.8, 0.4);
	cairo_paint(context);

	PangoLayout *layout;
	layout = pango_cairo_create_layout(context);

	pango_layout_set_text(layout, message, -1);

	PangoFontDescription *desc;
	desc = pango_font_description_from_string("Arial Bold 36");
	pango_layout_set_font_description(layout, desc);
	pango_font_description_free(desc);

	pango_layout_set_width(layout, 600 * PANGO_SCALE);
	pango_layout_set_height(layout, 400 * PANGO_SCALE);

	pango_cairo_update_layout(context, layout);

	//pango_render_text_simple(context, layout);
	//pango_render_text_border(context, layout);
	pango_render_text_shadow(context, layout);

	cairo_status_t status = cairo_surface_write_to_png(surface, "pango-text-effects.png");

	g_object_unref(layout);
	cairo_destroy(context);
	cairo_surface_destroy(surface);
}
Exemplo n.º 24
0
static void
mail_printer_draw_footer_cb (GtkPrintOperation *operation,
                             GtkPrintContext *context,
                             gint page_nr)
{
    PangoFontDescription *desc;
    PangoLayout *layout;
    gint n_pages;
    gdouble width, height;
    gchar *text;
    cairo_t *cr;

    cr = gtk_print_context_get_cairo_context (context);
    width = gtk_print_context_get_width (context);
    height = gtk_print_context_get_height (context);

    g_object_get (operation, "n-pages", &n_pages, NULL);
    text = g_strdup_printf (_("Page %d of %d"), page_nr + 1, n_pages);

    cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
    cairo_fill (cr);

    desc = pango_font_description_from_string ("Sans Regular 10");
    layout = gtk_print_context_create_pango_layout (context);
    pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
    pango_layout_set_font_description (layout, desc);
    pango_layout_set_text (layout, text, -1);
    pango_layout_set_width (layout, width * PANGO_SCALE);
    pango_font_description_free (desc);

    cairo_move_to (cr, 0, height + 5);
    pango_cairo_show_layout (cr, layout);

    g_object_unref (layout);
    g_free (text);
}
Exemplo n.º 25
0
static void
webkit_pref_callback_font_size (GSettings  *settings,
                                const char *key,
                                gpointer    data)
{
  char *webkit_pref = data;
  char *value = NULL;
  int size = 9; /* FIXME: What to use here? */

  char *schema = NULL;
  g_object_get (settings, "schema-id", &schema, NULL);

  /* If we are changing a GNOME font value and we are not using GNOME fonts in
   * Epiphany, return. */
  if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
      g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE) {
    g_free (schema);
    return;
  }
  g_free (schema);

  value = g_settings_get_string (settings, key);

  if (value) {
    PangoFontDescription *desc;

    desc = pango_font_description_from_string (value);
    size = pango_font_description_get_size (desc);
    if (pango_font_description_get_size_is_absolute (desc) == FALSE)
      size /= PANGO_SCALE;
    pango_font_description_free (desc);
  }

  g_object_set (webkit_settings, webkit_pref, webkit_settings_font_size_to_pixels (size), NULL);
  g_free (value);
}
Exemplo n.º 26
0
void
gimp_text_editor_set_font_name (GimpTextEditor *editor,
                                const gchar    *font_name)
{
  g_return_if_fail (GIMP_IS_TEXT_EDITOR (editor));

  if (editor->font_name)
    g_free (editor->font_name);

  editor->font_name = g_strdup (font_name);

  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->font_toggle)))
    {
      PangoFontDescription *font_desc = NULL;

      if (font_name)
        font_desc = pango_font_description_from_string (font_name);

      gtk_widget_override_font (editor->view, font_desc);

      if (font_desc)
        pango_font_description_free (font_desc);
    }
}
Exemplo n.º 27
0
static gboolean 
font_description_value_parse (GtkCssParser *parser,
                              GValue       *value)
{
  PangoFontDescription *font_desc;
  guint mask;
  char *str;

  str = _gtk_css_parser_read_value (parser);
  if (str == NULL)
    return FALSE;

  font_desc = pango_font_description_from_string (str);
  mask = pango_font_description_get_set_fields (font_desc);
  /* These values are not really correct,
   * but the fields must be set, so we set them to something */
  if ((mask & PANGO_FONT_MASK_FAMILY) == 0)
    pango_font_description_set_family_static (font_desc, "Sans");
  if ((mask & PANGO_FONT_MASK_SIZE) == 0)
    pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
  g_free (str);
  g_value_take_boxed (value, font_desc);
  return TRUE;
}
Exemplo n.º 28
0
static void freq_knob (cairo_t* cr, FilterFreq const * const f)
{
	float xlp, ylp;
	char tfq[8];

	PangoFontDescription* font = pango_font_description_from_string("Mono 9px");

	print_hz(tfq, dial_to_freq(f, 0));
	RESPLABLEL(0.00); write_text_full(cr, tfq, font, xlp, ylp, 0, 1, c_dlf);

	print_hz(tfq, dial_to_freq(f, .25));
	RESPLABLEL(0.25); write_text_full(cr, tfq, font, xlp, ylp, 0, 1, c_dlf);

	print_hz(tfq, dial_to_freq(f, .50));
	RESPLABLEL(0.50); write_text_full(cr, tfq, font, xlp, ylp, 0, 2, c_dlf);

	print_hz(tfq, dial_to_freq(f, .75));
	RESPLABLEL(0.75); write_text_full(cr, tfq, font, xlp-2, ylp, 0, 3, c_dlf);

	print_hz(tfq, dial_to_freq(f, 1.0));
	RESPLABLEL(1.00); write_text_full(cr, tfq, font, xlp-2, ylp, 0, 3, c_dlf);

	pango_font_description_free (font);
}
Exemplo n.º 29
0
static void
update_buttons (void)
{
	PangoFontDescription *pfd;

	if (!active_flag)
		return;

	switch (tmp_pref_crypto)
	{
	case GRG_AES:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rij1_but),
					      TRUE);
		break;
	case GRG_SERPENT:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ser_but),
					      TRUE);
		break;
	case GRG_TWOFISH:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (twof_but),
					      TRUE);
		break;
	case GRG_CAST_256:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cast_but),
					      TRUE);
		break;
	case GRG_SAFERPLUS:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (safer_but),
					      TRUE);
		break;
	case GRG_LOKI97:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (loki_but),
					      TRUE);
		break;
	case GRG_3DES:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tdes_but),
					      TRUE);
		break;
	case GRG_RIJNDAEL_256:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rij2_but),
					      TRUE);
		break;
	default:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ser_but),
					      TRUE);
		tmp_pref_crypto = GRG_SERPENT;
	}

	update_crypto_label ();

	switch (tmp_pref_hash)
	{
	case GRG_SHA1:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sha_but),
					      TRUE);
		break;
	case GRG_RIPEMD_160:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ripe_but),
					      TRUE);
		break;
	default:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ripe_but),
					      TRUE);
		tmp_pref_hash = GRG_RIPEMD_160;
	}

	switch (tmp_pref_comp)
	{
	case GRG_ZLIB:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (zlib_but),
					      TRUE);
		break;
	case GRG_BZIP:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bz_but),
					      TRUE);
		break;
	default:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (zlib_but),
					      TRUE);
		tmp_pref_comp = GRG_ZLIB;
	}

	switch (tmp_pref_ratio)
	{
	case GRG_LVL_NONE:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r0_but),
					      TRUE);
		break;
	case GRG_LVL_FAST:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r3_but),
					      TRUE);
		break;
	case GRG_LVL_GOOD:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r6_but),
					      TRUE);
		break;
	case GRG_LVL_BEST:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r9_but),
					      TRUE);
		break;
	default:
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (r9_but),
					      TRUE);
		tmp_pref_ratio = GRG_LVL_BEST;
	}

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (xpire_check),
				      grg_prefs_xpire > 0);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (xpire_spin),
				   abs (grg_prefs_xpire));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bak_check),
				      grg_prefs_bak_files);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (over_check),
				      grg_prefs_warn4overwrite);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (splash_check),
				      grg_prefs_splash);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cclip_check),
				      grg_prefs_clip_clear_on_close);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (qclip_check),
				      grg_prefs_clip_clear_on_quit);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (passes_spin),
				   abs (grg_prefs_wipe_passes));

	gtk_widget_set_sensitive (qclip_check,
				  !grg_prefs_clip_clear_on_close);

	pfd = pango_font_description_from_string (grg_prefs_editor_font);
	gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (but_font)), pfd);
	pango_font_description_free (pfd);
}
Exemplo n.º 30
0
void
grg_pref_dialog (GtkWidget * parent)
{
	GtkWidget *prefs, *notebook, *tab1, *tab2, *tab3;
	GtkWidget *frame1, *frame2, *frame3;
	GtkWidget *crypt_box, *hash_box, *comp_box;
	GtkWidget *frame_font;
	GtkWidget *frame_file, *but_file, *box_file, *but_file_clear;
	GtkWidget *frame_save, *box_save;
	GtkWidget *frame_misc, *box_misc;
	GtkWidget *frame_xpire, *box_xpire, *xpire_lbl;
	GtkWidget *frame_passes, *box_passes, *lbl_passes;
	GtkWidget *frame_clip, *box_clip;
	gint response;

	PangoFontDescription *fdesc;

	if (active_flag)
		return;

	prefs = gtk_dialog_new_with_buttons (_("Preferences"),
					     GTK_WINDOW (parent),
					     GTK_DIALOG_DESTROY_WITH_PARENT,
					     GTK_STOCK_OK, GTK_RESPONSE_OK,
					     GTK_STOCK_APPLY,
					     GTK_RESPONSE_APPLY,
					     GTK_STOCK_CANCEL,
					     GTK_RESPONSE_CANCEL, NULL);

	//first page: algorithms
	tab1 = gtk_table_new (3, 2, FALSE);

	frame1 = gtk_frame_new (_("Encryption"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame1, 0, 1, 0, 3);

	crypt_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame1), crypt_box);

	NEW_RADIO_BUTTON (rij1_but, NULL, modify_crypto, GRG_AES,
			  "AES (Rijndael 128)", crypt_box);
	NEW_RADIO_BUTTON (ser_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_SERPENT, "Serpent", crypt_box);
	NEW_RADIO_BUTTON (twof_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_TWOFISH, "Twofish", crypt_box);
	NEW_RADIO_BUTTON (cast_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_CAST_256, "Cast 256", crypt_box);
	NEW_RADIO_BUTTON (safer_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_SAFERPLUS, "Safer+", crypt_box);
	NEW_RADIO_BUTTON (loki_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_LOKI97, "Loki97", crypt_box);
	NEW_RADIO_BUTTON (tdes_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_3DES, "3-DES", crypt_box);
	NEW_RADIO_BUTTON (rij2_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (rij1_but)),
			  modify_crypto, GRG_RIJNDAEL_256, "Rijndael 256",
			  crypt_box);

	NEW_ROW_SEPARATOR (crypt_box);

	NEW_LABEL (crypto_block_lbl, crypt_box, "");
	NEW_LABEL (crypto_key_lbl, crypt_box, "");

	update_crypto_label ();

	frame2 = gtk_frame_new (_("Hashing"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame2, 1, 2, 0, 1);

	hash_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame2), hash_box);

	NEW_RADIO_BUTTON (sha_but, NULL, modify_hash, GRG_SHA1, "SHA1",
			  hash_box);
	NEW_RADIO_BUTTON (ripe_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (sha_but)), modify_hash,
			  GRG_RIPEMD_160, "RIPEMD 160", hash_box);

	frame3 = gtk_frame_new (_("Compression"));
	gtk_table_attach_defaults (GTK_TABLE (tab1), frame3, 1, 2, 1, 2);

	comp_box = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame3), comp_box);

	NEW_RADIO_BUTTON (zlib_but, NULL, modify_comp, GRG_ZLIB, "ZLib",
			  comp_box);
	NEW_RADIO_BUTTON (bz_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (zlib_but)),
			  modify_comp, GRG_BZIP, "BZip2", comp_box);

	NEW_ROW_SEPARATOR (comp_box);

	NEW_RADIO_BUTTON (r0_but, NULL, modify_ratio, GRG_LVL_NONE, _("None"),
			  comp_box);
	NEW_RADIO_BUTTON (r3_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_FAST, _("Fast"), comp_box);
	NEW_RADIO_BUTTON (r6_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_GOOD, _("Good"), comp_box);
	NEW_RADIO_BUTTON (r9_but,
			  gtk_radio_button_get_group (GTK_RADIO_BUTTON
						      (r0_but)), modify_ratio,
			  GRG_LVL_BEST, _("Best"), comp_box);

	notebook = gtk_notebook_new ();
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab1,
				  gtk_label_new (_("Algorithms")));
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (prefs)->vbox), notebook,
			    TRUE, TRUE, GRG_PAD);

	//second page: General options
	tab2 = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab2,
				  gtk_label_new (_("General options")));

	frame_font = gtk_frame_new (_("Editor font"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_font, FALSE, TRUE, 1);

	but_font =
		gtk_button_new_with_label (_
					   ("Click to change the editor font"));
	gtk_container_add (GTK_CONTAINER (frame_font), but_font);

	fdesc = pango_font_description_from_string (grg_prefs_editor_font);
	gtk_widget_modify_font (but_font, fdesc);
	g_free (fdesc);

	g_signal_connect (G_OBJECT (but_font), "clicked",
			  G_CALLBACK (modify_font), prefs);

	frame_misc = gtk_frame_new (_("Decorations"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_misc, FALSE, TRUE, 1);

	box_misc = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_misc), box_misc);

	NEW_ROW_SEPARATOR (tab2);

	splash_check = gtk_check_button_new_with_label (_("Splash screen"));
	g_signal_connect (G_OBJECT (splash_check), "toggled",
			  G_CALLBACK (modify_splash), NULL);
	gtk_box_pack_start (GTK_BOX (box_misc), splash_check, FALSE, TRUE, 1);

	frame_file = gtk_frame_new (_("File to open at startup"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_file, FALSE, TRUE, 1);

	box_file = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_file), box_file);

	file_entry = gtk_entry_new ();
	gtk_box_pack_start (GTK_BOX (box_file), file_entry, FALSE, TRUE, 1);
	but_file = gtk_button_new_from_stock (GTK_STOCK_OPEN);
	gtk_box_pack_start (GTK_BOX (box_file), but_file, FALSE, TRUE, 1);
	g_signal_connect (G_OBJECT (but_file), "clicked",
			  G_CALLBACK (meta_open_startup_file),
			  (gpointer) prefs);
	but_file_clear = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
	gtk_box_pack_start (GTK_BOX (box_file), but_file_clear, FALSE, TRUE,
			    1);
	g_signal_connect (G_OBJECT (but_file_clear), "clicked",
			  G_CALLBACK (clear_file), NULL);

	frame_save = gtk_frame_new (_("File saving"));
	gtk_box_pack_start (GTK_BOX (tab2), frame_save, FALSE, TRUE, 1);

	box_save = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_save), box_save);

	bak_check =
		gtk_check_button_new_with_label (_("Make backups of files"));
	g_signal_connect (G_OBJECT (bak_check), "toggled",
			  G_CALLBACK (modify_bak), NULL);
	gtk_box_pack_start (GTK_BOX (box_save), bak_check, FALSE, TRUE, 1);
	over_check =
		gtk_check_button_new_with_label (_
						 ("Ask when overwriting files"));
	g_signal_connect (G_OBJECT (over_check), "toggled",
			  G_CALLBACK (modify_over), NULL);
	gtk_box_pack_start (GTK_BOX (box_save), over_check, FALSE, TRUE, 1);

	//third page: Security
	tab3 = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab3,
				  gtk_label_new (_("Security")));

	frame_xpire = gtk_frame_new (_("Password expiration"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_xpire, FALSE, TRUE, 1);

	box_xpire = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_xpire), box_xpire);

	xpire_check =
		gtk_check_button_new_with_label (_("Password expires in"));
	xpire_spin =
		gtk_spin_button_new_with_range (EXP_TIME_MIN, EXP_TIME_MAX,
						1);
	xpire_lbl = gtk_label_new (_("days"));

	g_signal_connect (G_OBJECT (xpire_check), "toggled",
			  G_CALLBACK (modify_xpire), xpire_spin);
	g_signal_connect (G_OBJECT (xpire_spin), "value-changed",
			  G_CALLBACK (modify_xpin), xpire_check);

	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_check, FALSE, TRUE, 1);
	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_spin, FALSE, TRUE, 1);
	gtk_box_pack_start (GTK_BOX (box_xpire), xpire_lbl, FALSE, TRUE, 1);

	//this means "passes in wiping a file", not "wipe the passes" :)
	frame_passes = gtk_frame_new (_("Wipe passes"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_passes, FALSE, TRUE, 1);

	box_passes = gtk_hbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_passes), box_passes);

	lbl_passes = gtk_label_new (_("Number of overwritings with random\n"
				      "data, when wiping a file:"));
	gtk_box_pack_start (GTK_BOX (box_passes), lbl_passes, FALSE, TRUE, 1);

	passes_spin =
		gtk_spin_button_new_with_range (WIPE_PASSES_MIN,
						WIPE_PASSES_MAX, 1);
	gtk_box_pack_start (GTK_BOX (box_passes), passes_spin, FALSE, TRUE,
			    1);

	g_signal_connect (G_OBJECT (passes_spin), "value-changed",
			  G_CALLBACK (modify_passes), NULL);

	frame_clip = gtk_frame_new (_("Clipboard"));
	gtk_box_pack_start (GTK_BOX (tab3), frame_clip, FALSE, TRUE, 1);

	box_clip = gtk_vbox_new (FALSE, GRG_PAD);
	gtk_container_add (GTK_CONTAINER (frame_clip), box_clip);

	cclip_check =
		gtk_check_button_new_with_label (_
						 ("Clear clipboard on closing file"));
	g_signal_connect (G_OBJECT (cclip_check), "toggled",
			  G_CALLBACK (modify_cclip), NULL);
	gtk_box_pack_start (GTK_BOX (box_clip), cclip_check, FALSE, TRUE, 1);

	qclip_check =
		gtk_check_button_new_with_label (_
						 ("Clear clipboard on exit"));
	g_signal_connect (G_OBJECT (qclip_check), "toggled",
			  G_CALLBACK (modify_qclip), NULL);
	gtk_box_pack_start (GTK_BOX (box_clip), qclip_check, FALSE, TRUE, 1);

	//end of last tab
	active_flag = TRUE;
	reset_values (prefs);
	update_buttons ();

	gtk_widget_show_all (prefs);

	while (TRUE)
	{
		gboolean exit = TRUE;
		response = gtk_dialog_run (GTK_DIALOG (prefs));

		switch (response)
		{
		case GTK_RESPONSE_OK:
			apply_values ();
			break;
		case GTK_RESPONSE_APPLY:
			apply_values ();
			exit = FALSE;
			break;
		case GTK_RESPONSE_CANCEL:
		default:
			break;
		}

		if (exit)
		{
			gtk_widget_destroy (prefs);
			active_flag = FALSE;
			break;
		}
	}
}