Exemple #1
0
static int update_switcher_positions(int ox, struct desktop *desktops)
{
	struct desktop *iter, *prev;
	switcher_pos = ox;
	switcher_width = 0;

	if (!desktops)
		return 0;

	int lastw = 0, w = 0, state, textw;
	iter = prev = desktops;
	state = iter->focused ? BSTATE_PRESSED : BSTATE_IDLE;
	w += theme->switcher.space_gap;
	ox += w; lastw = w;
	w += get_image_width(theme->switcher.left_corner_img[state]);
	get_text_dimensions(theme->switcher.font, iter->name, &textw, 0);
	w += textw + theme->switcher.text_padding;

	while (iter->next) {
		prev = iter;
		iter = iter->next;
		state = iter->focused ? BSTATE_PRESSED : BSTATE_IDLE;
		get_text_dimensions(theme->switcher.font, iter->name, &textw, 0);
		w += get_image_width(theme->switcher.right_img[state]);
		prev->posx = ox;
		prev->width = w - lastw;
		w += get_image_width(theme->switcher.separator_img);
		ox += w - lastw; lastw = w;
		w += get_image_width(theme->switcher.left_img[state]);
		w += textw + theme->switcher.text_padding;
	}
	w += get_image_width(theme->switcher.right_corner_img[state]);
	iter->posx = ox;
	iter->width = w - lastw;
	w += theme->switcher.space_gap;

	switcher_width = w;
	return w;
}
Exemple #2
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);
}
Exemple #3
0
static int update_clock_positions(int ox)
{
	clock_pos = ox;
	int w = 0;
	w += theme->clock.space_gap * 2;
	w += get_image_width(theme->clock.left_img);
	w += get_image_width(theme->clock.right_img);
	
	char buftime[128];
	time_t current_time;
	memset(&current_time, 0, sizeof(time_t));
	strftime(buftime, sizeof(buftime), theme->clock.format, localtime(&current_time));

	int fontw;
	get_text_dimensions(theme->clock.font, buftime, &fontw, 0);
	w += fontw + theme->clock.text_padding;
	clock_width = w;
	return w;
}