/[cabestan]/main.c
ViewVC logotype

Annotation of /main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Mon Oct 5 01:58:05 2009 UTC (10 years ago) by ben
File MIME type: text/plain
File size: 2438 byte(s)
version 0.1
1 ben 3 #include <stdlib.h>
2 ben 1 #include <libintl.h>
3     #include <locale.h>
4     #include <gtk/gtk.h>
5     #include <glib.h>
6     #include <jack/jack.h>
7     #include <jack/transport.h>
8     #include "version.h"
9     #include "widgets.h"
10     #include "callbacks.h"
11 ben 3 #include "cabestan.h"
12    
13 ben 1 #define _(string) gettext (string)
14 ben 3 #define TIMERVAL 200 /* msec for refreshing timeline */
15 ben 1 int main (int argc, char* argv[]) {
16     GtkWidget* window; /* main window */
17     GtkWidget* vbox;
18     GtkWidget* hbox;
19 ben 3 GtkWidget* play, * rewind, * stepf, * stepr, * quit; /* buttons */
20     AppData* app_data = NULL;
21     jack_status_t jackd_status;
22    
23     app_data = (AppData*) malloc (sizeof(AppData));
24 ben 1
25 ben 3 app_data->jackd_client = NULL; /* jackd handle */
26     app_data->timeline = NULL; /* the gtk timeline label */
27    
28 ben 1
29     /* internationalization */
30     setlocale ( LC_ALL, "" );
31     bindtextdomain ("cabestan", LOCALEDIR);
32     textdomain ( "cabestan" );
33    
34     /* jack init */
35 ben 3 app_data->jackd_client = jack_client_open("cabestan", JackNullOption, &jackd_status);
36 ben 1 /* gtk init */
37     gtk_init (&argc, &argv);
38    
39     window = window_create("Cabestan");
40     vbox = vbox_create();
41     window_add_vbox(window, vbox);
42 ben 3 app_data->timeline = timeline_create();
43     vbox_pack_widget(vbox, app_data->timeline);
44 ben 1 hbox = hbox_create();
45     vbox_pack_widget(vbox, hbox);
46     rewind = button_create(GTK_STOCK_MEDIA_PREVIOUS);
47     hbox_pack_widget(hbox, rewind);
48     stepr = button_create(GTK_STOCK_MEDIA_REWIND);
49     hbox_pack_widget(hbox, stepr);
50     play = button_create(GTK_STOCK_MEDIA_PLAY);
51     hbox_pack_widget(hbox, play);
52     stepf = button_create(GTK_STOCK_MEDIA_FORWARD);
53     hbox_pack_widget(hbox, stepf);
54 ben 3 quit = button_create(GTK_STOCK_QUIT);
55     hbox_pack_widget(hbox, quit);
56 ben 1
57     /* callback connection */
58 ben 3 g_signal_connect_swapped(G_OBJECT(quit), "clicked", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
59 ben 1 g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
60 ben 3 g_signal_connect(G_OBJECT(play), "clicked", G_CALLBACK(on_play), (gpointer)app_data->jackd_client);
61     g_signal_connect(G_OBJECT(rewind), "clicked", G_CALLBACK(on_rewind), (gpointer)app_data->jackd_client);
62     g_signal_connect(G_OBJECT(stepf), "clicked", G_CALLBACK(on_stepf), (gpointer)app_data->jackd_client);
63     g_signal_connect(G_OBJECT(stepr), "clicked", G_CALLBACK(on_stepr), (gpointer)app_data->jackd_client);
64    
65 ben 1 gtk_widget_show_all(window);
66    
67 ben 3 jack_activate(app_data->jackd_client);
68    
69     g_timeout_add(TIMERVAL, refresh_timeline, app_data);
70 ben 1 gtk_main();
71    
72 ben 3 free(app_data);
73 ben 1 return 0;
74     }

  ViewVC Help
Powered by ViewVC 1.1.26