/[cabestan]/main.c
ViewVC logotype

Annotation of /main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Mon Oct 5 19:15:42 2009 UTC (9 years, 9 months ago) by ben
File MIME type: text/plain
File size: 3402 byte(s)
variable speed step forward/backward
1 ben 3 #include <stdlib.h>
2 ben 5 #include <unistd.h>
3     #if 0
4 ben 1 #include <libintl.h>
5     #include <locale.h>
6 ben 5 #endif
7 ben 1 #include <gtk/gtk.h>
8     #include <glib.h>
9     #include <jack/jack.h>
10     #include <jack/transport.h>
11     #include "version.h"
12     #include "widgets.h"
13     #include "callbacks.h"
14 ben 3 #include "cabestan.h"
15    
16 ben 1 #define _(string) gettext (string)
17     int main (int argc, char* argv[]) {
18     GtkWidget* window; /* main window */
19     GtkWidget* vbox;
20 ben 7 /* GtkWidget* hbox1; */
21     GtkWidget* hbox2;
22 ben 3 GtkWidget* play, * rewind, * stepf, * stepr, * quit; /* buttons */
23     AppData* app_data = NULL;
24     jack_status_t jackd_status;
25 ben 5 const gchar* const * data_dirs;
26     gchar* icon_path = NULL;
27     int i;
28 ben 3
29     app_data = (AppData*) malloc (sizeof(AppData));
30 ben 1
31 ben 3 app_data->jackd_client = NULL; /* jackd handle */
32     app_data->timeline = NULL; /* the gtk timeline label */
33 ben 7 app_data->frame_check = NULL; /* the gtk frame check */
34 ben 3
35 ben 5 #if 0
36 ben 1 /* internationalization */
37     setlocale ( LC_ALL, "" );
38     bindtextdomain ("cabestan", LOCALEDIR);
39     textdomain ( "cabestan" );
40 ben 5 #endif
41 ben 1 /* jack init */
42 ben 3 app_data->jackd_client = jack_client_open("cabestan", JackNullOption, &jackd_status);
43 ben 1 /* gtk init */
44     gtk_init (&argc, &argv);
45    
46 ben 7 /* look for icon */
47 ben 5 data_dirs = g_get_system_data_dirs();
48     for (i = 0; data_dirs[i]; ++i) {
49     icon_path = g_strconcat(data_dirs[i],"/icons/cabestan.png", NULL);
50     if (!access(icon_path,F_OK)) {
51     break;
52     }
53     g_free(icon_path);
54     icon_path = NULL;
55     }
56     if (icon_path) {
57     /* default wm icon (for subsequent windows) */
58     gtk_window_set_default_icon_from_file(icon_path, NULL);
59     g_free(icon_path);
60     }
61    
62 ben 1 window = window_create("Cabestan");
63     vbox = vbox_create();
64     window_add_vbox(window, vbox);
65 ben 7
66 ben 3 app_data->timeline = timeline_create();
67     vbox_pack_widget(vbox, app_data->timeline);
68 ben 7 #if 0
69     hbox1 = hbox_create();
70     vbox_pack_widget(vbox, hbox1);
71     app_data->frame_check = frame_check_create();
72     hbox_pack_widget(hbox1, app_data->frame_check);
73     #endif
74     hbox2 = hbox_create();
75     vbox_pack_widget(vbox, hbox2);
76 ben 1 rewind = button_create(GTK_STOCK_MEDIA_PREVIOUS);
77 ben 7 hbox_pack_widget(hbox2, rewind);
78 ben 1 stepr = button_create(GTK_STOCK_MEDIA_REWIND);
79 ben 7 hbox_pack_widget(hbox2, stepr);
80 ben 1 play = button_create(GTK_STOCK_MEDIA_PLAY);
81 ben 7 hbox_pack_widget(hbox2, play);
82 ben 1 stepf = button_create(GTK_STOCK_MEDIA_FORWARD);
83 ben 7 hbox_pack_widget(hbox2, stepf);
84 ben 3 quit = button_create(GTK_STOCK_QUIT);
85 ben 7 hbox_pack_widget(hbox2, quit);
86 ben 1
87     /* callback connection */
88 ben 3 g_signal_connect_swapped(G_OBJECT(quit), "clicked", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
89 ben 1 g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
90 ben 3 g_signal_connect(G_OBJECT(play), "clicked", G_CALLBACK(on_play), (gpointer)app_data->jackd_client);
91     g_signal_connect(G_OBJECT(rewind), "clicked", G_CALLBACK(on_rewind), (gpointer)app_data->jackd_client);
92 ben 7 g_signal_connect(G_OBJECT(stepf), "pressed", G_CALLBACK(on_stepf_pressed), (gpointer)app_data->jackd_client);
93     g_signal_connect(G_OBJECT(stepf), "released", G_CALLBACK(on_stepf_released), (gpointer)app_data->jackd_client);
94     g_signal_connect(G_OBJECT(stepr), "pressed", G_CALLBACK(on_stepr_pressed), (gpointer)app_data->jackd_client);
95     g_signal_connect(G_OBJECT(stepr), "released", G_CALLBACK(on_stepr_released), (gpointer)app_data->jackd_client);
96 ben 3
97 ben 1 gtk_widget_show_all(window);
98    
99 ben 3 jack_activate(app_data->jackd_client);
100    
101     g_timeout_add(TIMERVAL, refresh_timeline, app_data);
102 ben 1 gtk_main();
103    
104 ben 3 free(app_data);
105 ben 1 return 0;
106     }

  ViewVC Help
Powered by ViewVC 1.1.26