/[cabestan]/main.c
ViewVC logotype

Diff of /main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by ben, Sun Oct 4 20:55:30 2009 UTC revision 3 by ben, Mon Oct 5 01:58:05 2009 UTC
# Line 1  Line 1 
1    #include <stdlib.h>
2  #include <libintl.h>  #include <libintl.h>
3  #include <locale.h>  #include <locale.h>
4  #include <gtk/gtk.h>  #include <gtk/gtk.h>
# Line 7  Line 8 
8  #include "version.h"  #include "version.h"
9  #include "widgets.h"  #include "widgets.h"
10  #include "callbacks.h"  #include "callbacks.h"
11  #define _(string) gettext (string)  #include "cabestan.h"
12    
13    #define _(string) gettext (string)
14    #define TIMERVAL 200 /* msec for refreshing timeline */
15  int main (int argc, char* argv[]) {  int main (int argc, char* argv[]) {
16          GtkWidget* window; /* main window */          GtkWidget* window; /* main window */
         GtkWidget* timeline; /* time display */  
17          GtkWidget* vbox;          GtkWidget* vbox;
18          GtkWidget* hbox;          GtkWidget* hbox;
19          GtkWidget* play, * rewind, * forward, * stepf, * stepr; /* buttons */          GtkWidget* play, * rewind, * stepf, * stepr, * quit; /* buttons */
20          jack_client_t* jackd_client; /* jackd handle */          AppData* app_data = NULL;
21          jack_status_t jackd_status; /* jackd status */          jack_status_t jackd_status;
22    
23            app_data = (AppData*) malloc (sizeof(AppData));
24            
25            app_data->jackd_client = NULL; /* jackd handle */
26            app_data->timeline = NULL; /* the gtk timeline label */
27                    
28    
29          /*  internationalization */          /*  internationalization */
# Line 25  int main (int argc, char* argv[]) { Line 32  int main (int argc, char* argv[]) {
32          textdomain ( "cabestan" );          textdomain ( "cabestan" );
33    
34          /* jack init */          /* jack init */
35          jackd_client = jack_client_open("cabestan", JackNullOption, &jackd_status);          app_data->jackd_client = jack_client_open("cabestan", JackNullOption, &jackd_status);
         jack_activate(jackd_client);  
   
36          /* gtk init */          /* gtk init */
37          gtk_init (&argc, &argv);          gtk_init (&argc, &argv);
38                    
39          window = window_create("Cabestan");          window = window_create("Cabestan");
40          vbox = vbox_create();          vbox = vbox_create();
41          window_add_vbox(window, vbox);          window_add_vbox(window, vbox);
42          timeline = timeline_create();          app_data->timeline = timeline_create();
43          vbox_pack_widget(vbox, timeline);          vbox_pack_widget(vbox, app_data->timeline);
44          hbox = hbox_create();          hbox = hbox_create();
45          vbox_pack_widget(vbox, hbox);          vbox_pack_widget(vbox, hbox);
46          rewind = button_create(GTK_STOCK_MEDIA_PREVIOUS);          rewind = button_create(GTK_STOCK_MEDIA_PREVIOUS);
# Line 46  int main (int argc, char* argv[]) { Line 51  int main (int argc, char* argv[]) {
51          hbox_pack_widget(hbox, play);          hbox_pack_widget(hbox, play);
52          stepf = button_create(GTK_STOCK_MEDIA_FORWARD);          stepf = button_create(GTK_STOCK_MEDIA_FORWARD);
53          hbox_pack_widget(hbox, stepf);          hbox_pack_widget(hbox, stepf);
54          forward = button_create(GTK_STOCK_MEDIA_NEXT);          quit = button_create(GTK_STOCK_QUIT);
55          hbox_pack_widget(hbox, forward);          hbox_pack_widget(hbox, quit);
56    
57          /* callback connection */          /* callback connection */
58            g_signal_connect_swapped(G_OBJECT(quit), "clicked", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
59          g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), (gpointer)NULL);          g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), (gpointer)NULL);
60          g_signal_connect(G_OBJECT(play), "clicked", G_CALLBACK(on_play), (gpointer)jackd_client);          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)jackd_client);          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)jackd_client);          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)jackd_client);          g_signal_connect(G_OBJECT(stepr), "clicked", G_CALLBACK(on_stepr), (gpointer)app_data->jackd_client);
64            
65          gtk_widget_show_all(window);          gtk_widget_show_all(window);
66                    
67            jack_activate(app_data->jackd_client);
68    
69            g_timeout_add(TIMERVAL, refresh_timeline, app_data);
70          gtk_main();          gtk_main();
71    
72            free(app_data);
73          return 0;          return 0;
74  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26