/[cabestan]/main.c
ViewVC logotype

Contents of /main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations)
Mon Oct 5 19:15:42 2009 UTC (8 years ago) by ben
File MIME type: text/plain
File size: 3402 byte(s)
variable speed step forward/backward
1 #include <stdlib.h>
2 #include <unistd.h>
3 #if 0
4 #include <libintl.h>
5 #include <locale.h>
6 #endif
7 #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 #include "cabestan.h"
15
16 #define _(string) gettext (string)
17 int main (int argc, char* argv[]) {
18 GtkWidget* window; /* main window */
19 GtkWidget* vbox;
20 /* GtkWidget* hbox1; */
21 GtkWidget* hbox2;
22 GtkWidget* play, * rewind, * stepf, * stepr, * quit; /* buttons */
23 AppData* app_data = NULL;
24 jack_status_t jackd_status;
25 const gchar* const * data_dirs;
26 gchar* icon_path = NULL;
27 int i;
28
29 app_data = (AppData*) malloc (sizeof(AppData));
30
31 app_data->jackd_client = NULL; /* jackd handle */
32 app_data->timeline = NULL; /* the gtk timeline label */
33 app_data->frame_check = NULL; /* the gtk frame check */
34
35 #if 0
36 /* internationalization */
37 setlocale ( LC_ALL, "" );
38 bindtextdomain ("cabestan", LOCALEDIR);
39 textdomain ( "cabestan" );
40 #endif
41 /* jack init */
42 app_data->jackd_client = jack_client_open("cabestan", JackNullOption, &jackd_status);
43 /* gtk init */
44 gtk_init (&argc, &argv);
45
46 /* look for icon */
47 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 window = window_create("Cabestan");
63 vbox = vbox_create();
64 window_add_vbox(window, vbox);
65
66 app_data->timeline = timeline_create();
67 vbox_pack_widget(vbox, app_data->timeline);
68 #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 rewind = button_create(GTK_STOCK_MEDIA_PREVIOUS);
77 hbox_pack_widget(hbox2, rewind);
78 stepr = button_create(GTK_STOCK_MEDIA_REWIND);
79 hbox_pack_widget(hbox2, stepr);
80 play = button_create(GTK_STOCK_MEDIA_PLAY);
81 hbox_pack_widget(hbox2, play);
82 stepf = button_create(GTK_STOCK_MEDIA_FORWARD);
83 hbox_pack_widget(hbox2, stepf);
84 quit = button_create(GTK_STOCK_QUIT);
85 hbox_pack_widget(hbox2, quit);
86
87 /* callback connection */
88 g_signal_connect_swapped(G_OBJECT(quit), "clicked", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
89 g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
90 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 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
97 gtk_widget_show_all(window);
98
99 jack_activate(app_data->jackd_client);
100
101 g_timeout_add(TIMERVAL, refresh_timeline, app_data);
102 gtk_main();
103
104 free(app_data);
105 return 0;
106 }

  ViewVC Help
Powered by ViewVC 1.1.26