File: mc_alpha.c

package info (click to toggle)
mlterm 3.1.2-1.3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 23,168 kB
  • sloc: ansic: 102,795; sh: 9,676; java: 2,018; perl: 1,601; makefile: 1,595; cpp: 771; sed: 16
file content (85 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 *	$Id$
 */

#include  "mc_alpha.h"

#include  <kiklib/kik_str.h>
#include  <kiklib/kik_mem.h>		/* free */
#include  <kiklib/kik_debug.h>
#include  <glib.h>
#include  <c_intl.h>

#include  "mc_combo.h"
#include  "mc_io.h"


#if  0
#define  __DEBUG
#endif


/* --- static variables --- */

static char *  new_alpha = NULL;
static char *  old_alpha = NULL;
static int is_changed;


/* --- static functions --- */

static gint
alpha_selected(
	GtkWidget *  widget ,
	gpointer  data
	)
{
	g_free( new_alpha);
	new_alpha = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1) ;
	
#ifdef  __DEBUG
	kik_debug_printf( KIK_DEBUG_TAG " %s alpha is selected.\n" , new_alpha) ;
#endif

	return  1 ;
}


/* --- global functions --- */

GtkWidget *
mc_alpha_config_widget_new(void)
{
	char *  alphas[] =
	{
		"255" ,
		"223" ,
		"191" ,
		"159" ,
		"127" ,
		"95" ,
		"63" ,
		"31" ,
		"0" ,
	} ;

	new_alpha = strdup( old_alpha = mc_get_str_value( "alpha")) ;
	is_changed = 0;

	return  mc_combo_new_with_width(_("Alpha"), alphas,
		sizeof(alphas) / sizeof(alphas[0]), 
		new_alpha, 0, alpha_selected , NULL , 50);
}

void
mc_update_alpha(void)
{
	if (strcmp(new_alpha, old_alpha)) is_changed = 1;

	if (is_changed)
	{
		mc_set_str_value( "alpha" , new_alpha) ;
		free( old_alpha) ;
		old_alpha = strdup( new_alpha) ;
	}
}