Xdialog

Check-in [5f6e0487dd]
Login

Check-in [5f6e0487dd]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add fixed-font support for gtk2 version (01micko, original patch here: [http://murga-linux.com/puppy/viewtopic.php?p=859972#859972]
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5f6e0487ddfb9cfbc30232c2db4f97f195b78a25
User & Date: jamesbond 2015-08-11 12:28:43
Context
2016-12-17
17:42
Fix treeview crash when printable character is typed (reported by Jake SFR) check-in: a0995ae454 user: jamesbond tags: trunk
2015-08-11
12:28
add fixed-font support for gtk2 version (01micko, original patch here: [http://murga-linux.com/puppy/viewtopic.php?p=859972#859972] check-in: 5f6e0487dd user: jamesbond tags: trunk
2013-12-26
16:10
fix editable combobox (previously not working under gtk2) check-in: ec30703399 user: jamesbond tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/interface.c.

35
36
37
38
39
40
41



42

43
44
45
46
47
48
49

/* Global structure and variables */
extern Xdialog_data Xdialog;
extern gboolean dialog_compat;

/* Fixed font loading and character size (in pixels) initialisation */




static GdkFont *fixed_font;

static gint xmult = XSIZE_MULT;
static gint ymult = YSIZE_MULT;
static gint ffxmult = XSIZE_MULT;
static gint ffymult = YSIZE_MULT;

/* Parsing of the GTK+ rc file (if any) */








>
>
>
|
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

/* Global structure and variables */
extern Xdialog_data Xdialog;
extern gboolean dialog_compat;

/* Fixed font loading and character size (in pixels) initialisation */

#ifdef USE_GTK2
	static PangoFontDescription *fixed_font;
#else
	static GdkFont *fixed_font;
#endif
static gint xmult = XSIZE_MULT;
static gint ymult = YSIZE_MULT;
static gint ffxmult = XSIZE_MULT;
static gint ffymult = YSIZE_MULT;

/* Parsing of the GTK+ rc file (if any) */

63
64
65
66
67
68
69
70






71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

static void font_init(void)
{
	GtkWidget *window;
	GtkStyle  *style;
	GdkFont *font;
	gint width, ascent, descent, lbearing, rbearing;







	fixed_font = gdk_font_load(FIXED_FONT);

	if (fixed_font != NULL) {
		gdk_string_extents(fixed_font, ALPHANUM_CHARS, &lbearing,
				   &rbearing, &width, &ascent, &descent);
		ffxmult = width / 62;			/* 62 = strlen(ALPHANUM_CHARS) */
		ffymult = ascent + descent + 2;		/*  2 = spacing pixel lines */
	}

	if (dialog_compat) {
		xmult = ffxmult;
		ymult = ffymult;
	} else {
		/* We must open and realize a window IOT get the GTK+ theme font... */
		parse_rc_file();
		window = gtk_window_new(GTK_WINDOW_TOPLEVEL);







|
>
>
>
>
>
>








|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

static void font_init(void)
{
	GtkWidget *window;
	GtkStyle  *style;
	GdkFont *font;
	gint width, ascent, descent, lbearing, rbearing;
#ifdef USE_GTK2
	/* fixed font support by 01micko */
	fixed_font = pango_font_description_new ();
	pango_font_description_set_family (fixed_font, FIXED_FONT);
	pango_font_description_set_weight (fixed_font, PANGO_WEIGHT_MEDIUM);
	pango_font_description_set_size (fixed_font, 10*PANGO_SCALE);
#else
	fixed_font = gdk_font_load(FIXED_FONT);

	if (fixed_font != NULL) {
		gdk_string_extents(fixed_font, ALPHANUM_CHARS, &lbearing,
				   &rbearing, &width, &ascent, &descent);
		ffxmult = width / 62;			/* 62 = strlen(ALPHANUM_CHARS) */
		ffymult = ascent + descent + 2;		/*  2 = spacing pixel lines */
	}
#endif
	if (dialog_compat) {
		xmult = ffxmult;
		ymult = ffymult;
	} else {
		/* We must open and realize a window IOT get the GTK+ theme font... */
		parse_rc_file();
		window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
561
562
563
564
565
566
567

568
569
570
571
572
573
574
575
576



577
578
579
580
581
582
583
584
585
}

#ifdef USE_GTK2
static GtkWidget *set_scrollable_text(void)
{
	GtkWidget *text;
	GtkWidget *scrollwin;


	scrollwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show (scrollwin);
	gtk_box_pack_start (GTK_BOX(Xdialog.vbox), scrollwin, TRUE, TRUE, 0);

	text = gtk_text_view_new();
#if 0
	/* TODO: implement fixed font style support... */
	if (Xdialog.fixed_font) {



	}
#endif
	gtk_widget_show(text);
	gtk_container_add(GTK_CONTAINER (scrollwin), text);
	return text;
}
#else
static GtkWidget *set_scrollable_text(void)
{







>
|





|
|

>
>
>

|







571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
}

#ifdef USE_GTK2
static GtkWidget *set_scrollable_text(void)
{
	GtkWidget *text;
	GtkWidget *scrollwin;
	GtkStyle  *style;
	
	scrollwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show (scrollwin);
	gtk_box_pack_start (GTK_BOX(Xdialog.vbox), scrollwin, TRUE, TRUE, 0);

	text = gtk_text_view_new();

	/* fixed font support by 01micko */
	if (Xdialog.fixed_font) {
		style = gtk_style_new();
		style->font_desc = fixed_font;
		gtk_widget_modify_font(text, style->font_desc);
	}

	gtk_widget_show(text);
	gtk_container_add(GTK_CONTAINER (scrollwin), text);
	return text;
}
#else
static GtkWidget *set_scrollable_text(void)
{

Changes to src/interface.h.

33
34
35
36
37
38
39



40

41
42
43
44
45
46
47

/* The following defines should be changed via the "configure" options, type:
 *    ./configure --help
 * to learn more about these options.
 */

#ifndef FIXED_FONT



#define FIXED_FONT "-*-*-medium-r-normal-*-*-*-*-*-m-70-*-*"

#endif

#ifndef PRINTER_CMD
#define PRINTER_CMD "lpr" 		/* Command to be used IOT print text */
#endif
#ifndef PRINTER_CMD_OPTION
#define PRINTER_CMD_OPTION "-P"		/* The option to specify the prt queue */







>
>
>
|
>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

/* The following defines should be changed via the "configure" options, type:
 *    ./configure --help
 * to learn more about these options.
 */

#ifndef FIXED_FONT
#ifdef USE_GTK2
#	define FIXED_FONT "mono"
#else
#	define FIXED_FONT "-*-*-medium-r-normal-*-*-*-*-*-m-70-*-*"
#endif
#endif

#ifndef PRINTER_CMD
#define PRINTER_CMD "lpr" 		/* Command to be used IOT print text */
#endif
#ifndef PRINTER_CMD_OPTION
#define PRINTER_CMD_OPTION "-P"		/* The option to specify the prt queue */