File: mc_fade.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 (86 lines) | stat: -rw-r--r-- 1,448 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
86
/*
 *	$Id$
 */

#include  "mc_fade.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_fade_ratio = NULL;
static char *  old_fade_ratio = NULL;
static int is_changed;


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

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

	return  1 ;
}


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

GtkWidget *
mc_fade_config_widget_new(void)
{
	char *  fade_ratios[] =
	{
		"100" ,
		"90" ,
		"80" ,
		"70" ,
		"60" ,
		"50" ,
		"40" ,
		"30" ,
		"20" ,
		"10" ,
	} ;

	new_fade_ratio = strdup( old_fade_ratio = mc_get_str_value( "fade_ratio")) ;
	is_changed = 0;

	return  mc_combo_new_with_width(_("Fade ratio on unfocus"), fade_ratios,
		sizeof(fade_ratios) / sizeof(fade_ratios[0]),
		new_fade_ratio, 0, fade_ratio_selected, NULL, 80);
}

void
mc_update_fade_ratio(void)
{
	if (strcmp(new_fade_ratio, old_fade_ratio)) is_changed = 1;

	if (is_changed)
	{
		mc_set_str_value( "fade_ratio" , new_fade_ratio) ;
		free( old_fade_ratio) ;
		old_fade_ratio = strdup( new_fade_ratio) ;
	}
}