1 /* gjacktransport - .rc interface
2 * Copyright (C) 2007, 2010 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "gjacktransport.h"
30 #include "framerate.h"
32 extern FrameRate
*fffr
;
33 extern FrameRate
*uffr
;
34 extern FrameRate
*jffr
;
36 extern gint key_cfg
[MAX_KEYBINDING
];
41 extern GtkWidget
*window1
;
43 extern char *smpte_font
;
45 extern int want_quiet
;
47 extern gint my_root_x
, my_root_y
, my_width
, my_height
;
49 /* restore config functions - see callbacks.c */
50 void select_mem (int newmem
);
51 void showhide (char *togglebtn
, char *widget
, gboolean display
);
52 gboolean
ishidden (char *widget
); //toggle-btn name
53 void dothejack (gboolean onoff
);
54 int realloc_mem (int newmax
);
56 int parse_rc(const char*key
, const char *value
) {
57 if (!strncmp(key
,"memory_",7)) {
58 int mymem
= atoi(key
+7);
59 if (mymem
< 1) return -1;
60 if (mymem
> max_mem
) {
61 if (realloc_mem(mymem
)) return 0;
64 if (!strcmp(key
+9,"_start")) {
65 stg
[mymem
].start
=strtod(value
, NULL
);
66 } else if (!strcmp(key
+9,"_end")) {
67 stg
[mymem
].end
=strtod(value
, NULL
);
68 } else if (!strcmp(key
+9,"_unit")) {
69 stg
[mymem
].unit
=atoi(value
);
70 } else if (!strcmp(key
+9,"_name")) {
71 if (stg
[mymem
].name
) free(stg
[mymem
].name
);
72 stg
[mymem
].name
=strdup(value
);
75 printf("Warning: unhandled mem: %s=%f\n",key
+7,strtod(value
, NULL
));
78 } else if (!strncmp(key
,"keybinding_",11)) {
79 int mykey
= atoi(key
+11);
80 if (mykey
< 1 || mykey
> MAX_KEYBINDING
) return -1;
82 key_cfg
[mykey
]=atoi(value
);
83 } else if (!strcmp(key
,"syncsource")) {
84 dothejack(atoi(value
));
85 } else if (!strcmp(key
,"cur_mem")) {
86 select_mem(atoi(value
)-1);
87 } else if (!strcmp(key
,"seek_stride")) {
88 stride
=strtod(value
, NULL
);
89 } else if (!strcmp(key
,"tb_status")) {
90 showhide("checkbutton5","statusbar1",atoi(value
));
91 } else if (!strcmp(key
,"tb_zoom")) {
92 showhide("checkbutton3","handlebox3",atoi(value
));
93 } else if (!strcmp(key
,"tb_memory")) {
94 showhide("checkbutton7","handlebox4",atoi(value
));
95 } else if (!strcmp(key
,"tb_all")) {
96 showhide("checkbutton6","table1",atoi(value
));
97 } else if (!strcmp(key
,"tb_transport")) {
98 showhide("checkbutton4","handlebox1",atoi(value
));
99 } else if (!strcmp(key
,"tb_unit")) {
100 showhide("checkbutton2","handlebox2",atoi(value
));
101 } else if (!strcmp(key
,"tb_timelabels")) {
102 showhide("checkbutton8","hbox_labels",atoi(value
));
103 } else if (!strcmp(key
,"FR_mode")) {
104 if (atoi(value
)) fffr
=jffr
; // XXX
106 } else if (!strcmp(key
,"FR_flags")) {
107 uffr
->flags
=atoi(value
);
108 } else if (!strcmp(key
,"win_x")) {
109 my_root_x
=atoi(value
);
110 } else if (!strcmp(key
,"win_y")) {
111 my_root_y
=atoi(value
);
112 } else if (!strcmp(key
,"win_w")) {
113 my_width
=atoi(value
);
114 } else if (!strcmp(key
,"win_h")) {
115 my_height
=atoi(value
);
116 } else if (!strcmp(key
,"no_lash")) {
117 no_lash
=atoi(value
)?1:0;
118 } else if (!strcmp(key
,"smpte_font")) {
119 if (smpte_font
) free(smpte_font
);
120 smpte_font
= strdup(value
);
123 fprintf (stderr
, "WARNING: unhandled Config parameter Key = '%s' \n", key
);
129 void write_rc(const char *fn
) {
132 if (!(fp
= fopen(fn
, "w"))) {
134 fprintf(stderr
,"writing configfile failed: %s (%s)\n",fn
,strerror(errno
));
137 gtk_window_get_size (GTK_WINDOW(window1
), &my_width
, &my_height
);
138 gtk_window_get_position (GTK_WINDOW(window1
), &my_root_x
, &my_root_y
);
140 fprintf(fp
, "# config file for gjacktransport\n#\n# lines beginning with '#' or ';' are ignored.\n#\n");
141 fprintf(fp
, "# Config files are parsed in the following order, the last read values\n# take precedence.\n#\n");
142 fprintf(fp
, "# @sysconfdir@/gjacktransportrc\n# $HOME/.gjacktransportrc\n# ./gjacktransportrc\n#\n");
143 fprintf(fp
, "# -command-line args-\n# rc-file specified with --config <rc-file>\n#\n");
144 fprintf(fp
, "# NOTE: @sysconfdir@/gjackclockrc is overwritten by 'make install'\n#\n");
146 fprintf(fp
, "\n## PRESET/MEMORY ##\n# load-memory preset: 01..99\n");
147 fprintf(fp
, "cur_mem=%02i\n", mem
+1);
149 fprintf(fp
, "\n# mem-id 01..99\n"
150 "# 01..last-found-id presets are created - but at least 6\n"
151 "# start/end values are in seconds\n"
152 "# unit: hour:0, min:1, sec:2, audio-frames:3 - used for display not config\n"
153 "# name: must not be empty but may contain whitespaces\n"
155 for (i
=0; i
< max_mem
; i
++) {
157 fprintf(fp
, "memory_%02i_name=%s\n", i
+1, stg
[i
].name
);
158 fprintf(fp
, "memory_%02i_start=%f\n", i
+1, stg
[i
].start
);
159 fprintf(fp
, "memory_%02i_end=%f\n", i
+1, stg
[i
].end
);
160 fprintf(fp
, "memory_%02i_unit=%i\n\n", i
+1, stg
[i
].unit
);
163 fprintf(fp
, "\n## KEYBINDINGS ##\n");
164 const char *kbc
[MAX_KEYBINDING
] = {
165 /* TODO : sync w/ callbacks.c -> .h*/
166 "play/pause", "fast-rew", "fast-ffw", "play", "pause", "rewind", "skip-start", "skip-end"
169 for (i
=0; i
< MAX_KEYBINDING
; i
++) {
170 fprintf(fp
,"# %s\n", kbc
[i
]);
171 fprintf(fp
,"keybinding_%i=%i\n",i
+1, key_cfg
[i
]);
174 fprintf(fp
, "\n\n## SHOW/HIDE TOOL-BARS ##\n");
175 fprintf(fp
, "tb_all=%i\n", ishidden("checkbutton6")?1:0);
176 fprintf(fp
, "tb_status=%i\n", ishidden("checkbutton5")?1:0);
177 fprintf(fp
, "tb_zoom=%i\n", ishidden("checkbutton3")?1:0);
178 fprintf(fp
, "tb_memory=%i\n", ishidden("checkbutton7")?1:0);
179 fprintf(fp
, "tb_transport=%i\n", ishidden("checkbutton4")?1:0);
180 fprintf(fp
, "tb_unit=%i\n", ishidden("checkbutton2")?1:0);
181 fprintf(fp
, "tb_timelabels=%i\n", ishidden("checkbutton8")?1:0);
183 fprintf(fp
, "\n\n## WINDOW POSITION/SIZE ##\n");
184 fprintf(fp
, "win_x=%i\n", my_root_x
);
185 fprintf(fp
, "win_y=%i\n", my_root_y
);
186 fprintf(fp
, "win_w=%i\n", my_width
);
187 fprintf(fp
, "win_h=%i\n", my_height
);
189 fprintf(fp
, "\n\n## MISC ##\n");
190 fprintf(fp
, "# set to 1 to auto-connect to JACK\n");
191 fprintf(fp
, "syncsource=%i\n", jack_connected()?1:0);
192 fprintf(fp
, "\n# 1: use JACK video-framerate (if set by time-master)\n");
193 fprintf(fp
, "FR_mode=%i\n", (jffr
==fffr
)?1:0);
194 fprintf(fp
, "\n# seek-stride (in seconds)\n");
195 fprintf(fp
, "seek_stride=%f\n", stride
);
196 fprintf(fp
, "\n# do not try to use LASH\n");
197 fprintf(fp
, "no_lash=%i\n", no_lash
?1:0);
200 fprintf(fp
, "\n# SMPTE display font and optional size\n");
201 fprintf(fp
, "smpte_font=%s\n", smpte_font
);
207 fprintf(stderr
,"written config: %s\n",fn
);
210 /* vi:set ts=8 sts=2 sw=2: */