.rc loader extensions (gjc & gjt);
[gjacktransport.git] / src / main.c
blobe66bb493bf2ad62d6404feb5109c5b6ab357e07b
1 /* gjacktransport - jack transport slider
2 * Copyright (C) 2006 Robin Gareus <robin AT 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 of the License, or
7 * (at your option) any later version.
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
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
23 #include <stdio.h>
24 #include <gtk/gtk.h>
25 #include <getopt.h>
26 #include <libintl.h>
28 #include "interface.h"
29 #include "support.h"
30 #include "gjack.h"
31 #include "gjacktransport.h"
32 #include "framerate.h"
34 char *program_name;
35 GtkWidget *window1;
36 FrameRate *jffr; //< jack video FPS
37 FrameRate *uffr; //< user set FPS
38 FrameRate *fffr; //< pointer to currently used.
40 gjtdata stg[MAX_MEM]; // settings
41 int mem = 0; // current mem
42 double stride = 10; // seek stride (in seconds)
43 int want_quiet = 0;
44 int no_lash = 0; // don't try to use LASH
46 #ifdef HAVE_LASH
47 # include <lash/lash.h>
48 void lash_setup(void); //< prototype - fn defined in lash.c
49 lash_client_t *lash_client = NULL;
50 #endif
51 void lash_process(void);
53 // prototypes - defined in callbacks.c
54 gboolean gpolljack (gpointer data);
55 void initialize_gjt (void);
56 void update_spinbtns(void);
58 // prototypes - defined in resourceconfig.c
59 void load_rc (void);
60 void try_load_rc_file (char *filename);
62 static GdkPixmap *gjt_icon_pixmap;
63 static GdkBitmap *gjt_icon_mask;
64 #include "gjt_icon.xpm"
67 static void usage (int status) {
68 printf("%s - JACK transport slider.\n",program_name);
69 printf("usage: %s [Options] [start-marker [end-marker]]\n",program_name);
70 printf (""
71 "Options:\n"
72 " -h, --help display this help and exit\n"
73 " -V, --version print version information and exit\n"
74 " -q, --quiet, --silent inhibit usual output\n"
76 "unit for start/end markers: seconds. (eg 10 60.5)\n"
78 exit(status);
81 static void printversion (void) {
82 printf ("gjacktransport %s\n (C) GPL 2007, 2010 Robin Gareus <robin@gareus.org>\n", VERSION);
85 gboolean glashproc (gpointer data) {
86 lash_process();
87 return(TRUE);
91 static struct option const long_options[] =
93 {"help", no_argument, 0, 'h'},
94 {"quiet", no_argument, 0, 'q'},
95 {"silent", no_argument, 0, 'q'},
96 {"version", no_argument, 0, 'V'},
97 {NULL, 0, NULL, 0}
101 static int
102 decode_switches (int argc, char **argv)
104 int c;
105 while ((c = getopt_long (argc, argv,
106 "q" /* quiet or silent */
107 "L" /* no lash */
108 "h" /* help */
109 "V", /* version */
110 long_options, (int *) 0)) != EOF)
112 switch (c) {
113 case 'q': /* --quiet, --silent */
114 want_quiet = 1;
115 break;
116 case 'L': /* --nolash */
117 no_lash = 1;
118 break;
119 case 'V':
120 printversion();
121 exit(0);
122 case 'h':
123 usage (0);
124 default:
125 usage (EXIT_FAILURE);
128 return optind;
132 int main (int argc, char *argv[]) {
133 GtkWidget *w;
134 program_name = argv[0];
136 #ifdef ENABLE_NLS
137 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
138 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
139 textdomain (GETTEXT_PACKAGE);
140 #endif
142 gtk_init(&argc, &argv);
143 #ifdef HAVE_LASH
144 lash_args_t *lash_args = lash_extract_args(&argc, &argv);
145 #endif
147 initialize_gjt();
149 int i = decode_switches (argc, argv);
150 if (argc > i+2 ) usage(1);
152 window1 = create_window1();
154 w = lookup_widget(window1,"combobox1");
155 gtk_combo_box_set_active (GTK_COMBO_BOX(w),6);
156 w = lookup_widget(window1,"combobox2");
157 gtk_combo_box_set_active (GTK_COMBO_BOX(w),2);
158 w = lookup_widget(window1,"combobox3");
159 gtk_combo_box_set_active (GTK_COMBO_BOX(w),0);
160 w = lookup_widget(window1,"combobox4");
161 gtk_combo_box_set_active (GTK_COMBO_BOX(w),0);
162 w = lookup_widget(window1,"combobox5");
163 gtk_combo_box_set_active (GTK_COMBO_BOX(w),0);
165 load_rc();
167 if (argc-i == 2) {
168 /* set start end end marker */
169 mem=0;
170 stg[0].unit=UNIT_SEC;
171 stg[0].start=strtod(argv[i],NULL); //* unit_table[stg[0].unit];
172 stg[0].end=strtod(argv[i+1],NULL); //* unit_table[stg[0].unit];
173 } else if (argc-i == 1) {
174 /* set end marker only */
175 mem=0;
176 stg[0].unit=UNIT_SEC;
177 stg[0].end=strtod(argv[i],NULL);; //* unit_table[stg[0].unit];
180 update_spinbtns();
182 #ifdef HAVE_LASH
183 if (!no_lash) {
184 lash_client = lash_init (lash_args, PACKAGE_NAME, 0 | LASH_Config_Data_Set ,LASH_PROTOCOL (2,0));
185 if (!lash_client) {
186 fprintf(stderr, "could not initialise LASH!\n");
187 } else {
188 lash_setup();
189 if (!want_quiet) printf("Connected to LASH.\n");
191 //lash_args_destroy(lash_args);
193 #endif
195 gtk_widget_show (window1);
196 gjt_icon_pixmap = gdk_pixmap_create_from_xpm_d (window1->window, &gjt_icon_mask, NULL, gjt_icon_xpm);
198 gdk_window_set_icon(window1->window, NULL, gjt_icon_pixmap, gjt_icon_mask);
199 //gdk_pixbuf_unref (window1_icon_pixbuf);
200 g_timeout_add(40,gpolljack,NULL);
201 #ifdef HAVE_LASH
202 if (!no_lash) {
203 g_timeout_add(250,glashproc,NULL);
205 #endif
206 gtk_main ();
208 FR_free(uffr);
209 FR_free(jffr);
210 return 0;
212 /* vi:set ts=8 sts=2 sw=2: */