File: control.c

package info (click to toggle)
gxanim 0.50-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 212 kB
  • ctags: 301
  • sloc: ansic: 1,910; makefile: 64
file content (124 lines) | stat: -rw-r--r-- 2,635 bytes parent folder | download
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
	GXAnim : A GTK frontend to XAnim
	by Robert Warren
	(c) 1999

	This program is covered under the General Public License.
	See COPYING file for licensing information.
	
	===============================================

	control.c

	control frontends to the functions located in runxanim.c

*/

#include "header.h"


void play_event(xcontrol *control)
{
	FILE *file = _NULL;

	char *tempname = _NULL;
	char *shortname = _NULL;
	char *savename = _NULL;
	char playname[50];
	
	raise_window(control->main->window);

	tempname = strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(control->main->combo)->entry)));
		
	if (file = fopen(tempname, "rb")) {
		
		fclose(file);
		control->movie->name = tempname;
		savename = dalloc(savename, strlen(tempname));
		sprintf(savename, "%s\0", tempname);

		shortname = file_only(control->movie->name);
		sprintf(playname, "  Playing %s...\0", shortname);
		control->play->playset = NOOP;
		
		if (val_xanim_file(control)) {
				
			control->main->history_list = g_list_first(save_history(control->main->history_list,
				(gpointer) savename));

			gtk_combo_set_popdown_strings(GTK_COMBO(control->main->combo),control->main->history_list);
			gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(control->main->combo)->entry), tempname);

			gtk_statusbar_push(GTK_STATUSBAR(control->main->statbar), control->main->context_id, playname);
			
			runxanim(control);
		} 

		dfree(savename);
		dfree(shortname);
		
	} 
	
	return;
}

void stopxanim (GtkWidget *widget, xcontrol *control) 
{
	control->play->playset = NOOP;
	setxanim(control, "q");
	return;
}

void set_volume (GtkWidget *widget, xcontrol *control) 
{
	I8 oldvolume;
	
	oldvolume = control->movie->volume;
	control->movie->volume = (I8) ((GtkAdjustment *) control->main->voladjust )->value;

	if (oldvolume != control->movie->volume && control->play->playing == PLAYING) {
				
		if (control->movie->volume > oldvolume) {
			for (; oldvolume < control->movie->volume; oldvolume++) {
				setxanim(control, "3");
			}
		} else {
			for (; oldvolume > control->movie->volume; oldvolume--) {
				setxanim(control, "2");
			}
		}	
	}

	return;
}

void pause_frame (GtkWidget *widget, xcontrol *control) 
{
	setxanim(control, " ");
	return;
}

void frame_up (GtkWidget *widget, xcontrol *control) 
{
	setxanim(control, "/");
	return;
}

void frame_back (GtkWidget *widget, xcontrol *control) 
{
	setxanim(control, "m");
	return;
}

void mute_sound (GtkWidget *widget, xcontrol *control) 
{
	setxanim(control, "s");
	return;
}

void set_play (GtkWidget *widget, xcontrol *control) 
{
	stopxanim(_NULL, control);
	control->play->playset = AUTOPLAY; 
	return;
}