Moving to cairo and misc other fixes - getting there.
authorAlexander Koenig <alex@lisas.de>
Tue, 21 Jan 2014 22:03:42 +0000 (23:03 +0100)
committerAlexander Koenig <alex@lisas.de>
Tue, 21 Jan 2014 22:03:42 +0000 (23:03 +0100)
src/tX_dial.c
src/tX_dialog.cc
src/tX_flash.c
src/tX_flash.h
src/tX_glade_interface.cc
src/tX_global.c
src/tX_vtt.cc
src/tX_vttgui.cc
src/tX_widget.c
src/tX_widget.h

index 0396b417648e16f33e57d26d31ba55fa7cde08a1..69e88f80ad47755f54d8253dccf8d2958d2bbb77 100644 (file)
@@ -274,6 +274,11 @@ inline void gtk_tx_dial_draw (GtkTxDial *tx_dial, GtkWidget *widget)
 //                             knob_pixmaps[tx_dial->old_image],
 //                             0, 0, tx_dial->xofs, tx_dial->yofs,
 //                                             KNOB_SIZE, KNOB_SIZE, GDK_RGB_DITHER_NORMAL, 0, 0);
+
+               cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
+               gdk_cairo_set_source_pixbuf (cr, knob_pixmaps[tx_dial->old_image], 0, 0);
+               cairo_paint (cr);
+               cairo_destroy (cr);
        }                
 }
 
index b7d324a86333ad1e788af53dc23318ba6b4024d4..8876b009e05504d6cead696516df60a64091f5f8 100644 (file)
@@ -80,13 +80,19 @@ void apply_options(GtkWidget *dialog) {
        globals.use_realtime=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "use_realtime")));
        
        /* Audio: OSS */
-       strcpy(globals.oss_device, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_audio_device"))));
+       char *oss_device = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_audio_device")));
+       if (oss_device) {
+               strcpy(globals.oss_device, oss_device);
+       }
        globals.oss_buff_no=(int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")));
        globals.oss_buff_size=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")));
        globals.oss_samplerate=atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_samplerate"))));
        
        /* Audio: ALSA */
-       strcpy(globals.alsa_device_id, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "alsa_audio_device"))));
+       char *alsa_device = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "alsa_audio_device")));
+       if (alsa_device) {
+               strcpy(globals.alsa_device_id, alsa_device);
+       }
        globals.alsa_buffer_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")));
        globals.alsa_buffer_time*=1000;
        globals.alsa_period_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")));
@@ -99,7 +105,10 @@ void apply_options(GtkWidget *dialog) {
        
        /* Input */
        globals.xinput_enable=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")))==TRUE);
-       strcpy(globals.xinput_device, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "xinput_device"))));
+       char *xinput_device = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "xinput_device")));
+       if (xinput_device) {
+               strcpy(globals.xinput_device, xinput_device);
+       }
        globals.mouse_speed=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")));
        globals.sense_cycles=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")));
        globals.vtt_inertia=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vtt_inertia")));
index a967b99bd819e76c534000370a3f05f03940bdc3..e7ab5654a6ce7fbf310998d8fa92c7ef04bbff83 100644 (file)
@@ -153,6 +153,7 @@ static void gtk_tx_flash_init (GtkTxFlash *tx_flash)
 {
        GdkColormap *priv;
        
+       tx_flash->surface = NULL;
        tx_flash->colors_allocated=0;
        priv=gdk_colormap_new(gtk_widget_get_visual(GTK_WIDGET(tx_flash)), 6);
 
@@ -180,12 +181,15 @@ static void gtk_tx_flash_destroy (GtkObject *object)
 
 static void gtk_tx_flash_realize (GtkWidget *widget)
 {
+       GtkTxFlash *tx_flash;
        GdkWindowAttr attributes;
        gint attributes_mask;
        
        g_return_if_fail (widget != NULL);
        g_return_if_fail (GTK_IS_TX_FLASH (widget));
        
+       tx_flash=GTK_TX_FLASH(widget);
+
        gtk_widget_set_realized(widget, TRUE);
        GtkAllocation allocation;
        gtk_widget_get_allocation(widget, &allocation);
@@ -207,6 +211,12 @@ static void gtk_tx_flash_realize (GtkWidget *widget)
        
        gdk_window_set_user_data (gtk_widget_get_window(widget), widget);
        gtk_style_set_background (gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL);
+       
+               if (tx_flash->surface) {
+               cairo_surface_destroy (tx_flash->surface);
+       }
+       
+       tx_flash->surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, allocation.width, allocation.height);
 }
 
 static void gtk_tx_flash_size_request(GtkWidget *widget, GtkRequisition *requisition)
@@ -236,16 +246,16 @@ static void gtk_tx_flash_prepare(GtkWidget *widget)
        tx_flash->red_level=(RED_BORDER/tx_flash->level_value);
        
        tx_flash->channel[0].x1=DMINIX+S_MINIX+2;
-       tx_flash->channel[1].x2=allocation.width-tx_flash->channel[0].x1-1;
+       tx_flash->channel[1].x2=allocation.width-tx_flash->channel[0].x1;
                
        if (allocation.width%2>0) {
                // odd
                tx_flash->center_expand=0;
-               tx_flash->channel[0].x2=allocation.width/2-2;
+               tx_flash->channel[0].x2=allocation.width/2-1;
        } else {
                // even
                tx_flash->center_expand=1;
-               tx_flash->channel[0].x2=allocation.width/2-3;
+               tx_flash->channel[0].x2=allocation.width/2-2;
        }
        tx_flash->channel[1].x1=allocation.width/2+2;
        
@@ -273,6 +283,7 @@ static void gtk_tx_flash_paint_yourself(GtkWidget *widget)
 {
        GtkTxFlash *tx_flash;
        GtkAllocation allocation;
+       cairo_t *cr;
        
        gint i, x11, x12,x21, x22, y, middle;
        int long_level;
@@ -280,11 +291,19 @@ static void gtk_tx_flash_paint_yourself(GtkWidget *widget)
        tx_flash = GTK_TX_FLASH (widget);
        gtk_widget_get_allocation(widget, &allocation);
        
-       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_BG]);
-       
-       gdk_draw_rectangle(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], 1, 0, 0, allocation.width, allocation.height); 
+       cr = gdk_cairo_create (gtk_widget_get_window(widget));
+       cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+       cairo_set_source_surface (cr, tx_flash->surface, 0, 0);
+
+       gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_BG]);
+
+       //printf("%i, %i, %i, %i\n", area->x, area->y, area->width, area->height);
+
+       cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
+       cairo_fill(cr);
        
-       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_NORM_HALF]);
+       cairo_set_line_width(cr,1);
+       gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_NORM_HALF]);      
        
        x12=DMINIX+S_MINIX;
        x21=allocation.width-1-x12;
@@ -297,7 +316,7 @@ static void gtk_tx_flash_paint_yourself(GtkWidget *widget)
                        long_level=1;
                } else if (i==tx_flash->red_level) {
                        long_level=1;
-                       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_LOUD_HALF]);
+                       gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_LOUD_HALF]);      
                } else if (i==tx_flash->levels) {
                        long_level=1;
                } else long_level=0;
@@ -310,15 +329,23 @@ static void gtk_tx_flash_paint_yourself(GtkWidget *widget)
                        x22=x21+S_MINIX;                
                }
                
-               gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], x11, y, x12, y);
-               gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], x21, y, x22, y);
+               cairo_move_to (cr, x11, y);
+               cairo_line_to (cr, x12+1, y);
                
+               cairo_move_to (cr, x21, y);
+               cairo_line_to (cr, x22+1, y);
+
                if (tx_flash->center_expand) {
-                       gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], middle-1, y, middle, y);                        
+                       cairo_move_to (cr, middle-1, y);
+                       cairo_line_to (cr, middle+1, y);
                } else {
-                       gdk_draw_point(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], middle, y);
+                       cairo_move_to (cr, middle, y);
+                       cairo_line_to (cr, middle+1, y);
                }
+               cairo_stroke (cr);
        }
+       
+       cairo_destroy (cr);
 }
 
 static gint gtk_tx_flash_expose (GtkWidget *widget, GdkEventExpose *event)
@@ -356,6 +383,7 @@ static void gtk_tx_flash_set_channel_level(GtkTxFlash *tx_flash, f_prec new_valu
 {
        GtkWidget *widget=GTK_WIDGET(tx_flash);
        GtkAllocation allocation;
+       cairo_t *cr;
        gint i, y;
        int new_level;
        int red=0;
@@ -363,6 +391,12 @@ static void gtk_tx_flash_set_channel_level(GtkTxFlash *tx_flash, f_prec new_valu
        new_level=(int) (new_value/tx_flash->level_value);
        gtk_widget_get_allocation(widget, &allocation);
        
+       cr = gdk_cairo_create (gtk_widget_get_window(widget));
+       cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+       cairo_set_source_surface (cr, tx_flash->surface, 0, 0);
+
+       gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_BG]);
+
        // tX_msg("setting level: %5d for widget %08x channel %08x\n", new_level, tx_flash, channel);
        
        if (new_level>tx_flash->levels) 
@@ -377,19 +411,23 @@ static void gtk_tx_flash_set_channel_level(GtkTxFlash *tx_flash, f_prec new_valu
        
        if (tx_flash->max_cycles <= 0) {
                y=allocation.height-(DY+(channel->max)*DLEVEL);
-               gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_BG]);
-               gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], channel->x1, y, channel->x2, y);
+               gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_BG]);
+               cairo_move_to (cr, channel->x1, y);
+               cairo_line_to (cr, channel->x2, y);
+               cairo_stroke (cr);
                
                if (channel->max>0) {
                        channel->max--;
                        y+=DLEVEL;
                        if (channel->max>tx_flash->red_level) {
-                               gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_LOUD]);
+                               gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_LOUD]);
                        } else {
-                               gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_NORM]);
+                               gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_NORM]);
                        }
                        
-                       gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], channel->x1, y, channel->x2, y);
+                       cairo_move_to (cr, channel->x1, y);
+                       cairo_line_to (cr, channel->x2, y);
+                       cairo_stroke (cr);
                }
        }
        
@@ -401,19 +439,21 @@ static void gtk_tx_flash_set_channel_level(GtkTxFlash *tx_flash, f_prec new_valu
        }
        
        if (new_level>channel->last_level) {
-               gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_NORM]);
+               gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_NORM]);
                
                for (i=channel->last_level, y=allocation.height-(DY+channel->last_level*DLEVEL); i<=new_level; y-=DLEVEL, i++) {
                        if (!red) {
                                if (i>=tx_flash->red_level) {
-                                       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_LOUD]);
+                                       gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_LOUD]);
                                        red=1;
                                }
                        }
-                       gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], channel->x1, y, channel->x2, y);
+                       cairo_move_to (cr, channel->x1, y);
+                       cairo_line_to (cr, channel->x2, y);
+                       cairo_stroke (cr);
                }
        } else {
-               gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], &tx_flash->colors[COL_BG]);
+               gdk_cairo_set_source_color (cr, &tx_flash->colors[COL_BG]);
                
                if (channel->last_level==channel->max) {
                        i=channel->last_level-1;
@@ -422,10 +462,14 @@ static void gtk_tx_flash_set_channel_level(GtkTxFlash *tx_flash, f_prec new_valu
                }
                
                for (y=allocation.height-(DY+i*DLEVEL); i>new_level; y+=DLEVEL, i--) {
-                       gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], channel->x1, y, channel->x2, y);
+                       cairo_move_to (cr, channel->x1, y);
+                       cairo_line_to (cr, channel->x2, y);
+                       cairo_stroke (cr);
                }
        }
        channel->last_level=new_level;
+       
+       cairo_destroy(cr);
 }
 
 void
index 37d2fdcd55c3581a273f3e664d188e35e66f359f..5ff64b2dd6d4ea4830c3a0819d5b41abaf78d6d5 100644 (file)
@@ -58,6 +58,7 @@ struct _GtkTxFlash {
        int max_cycles;
        int center_expand;
        struct flash_channel channel[2];
+       cairo_surface_t* surface;
 };
 
 struct _GtkTxFlashClass {
index c845b982e906f319cf2798f09584c9f511d2c906..12d20a982a3b74d6677a2400d93d894c0ba6cba5 100644 (file)
@@ -100,7 +100,6 @@ create_tx_adjust (void)
 
   dialog_action_area2 = gtk_dialog_get_action_area(GTK_DIALOG (tx_adjust));
   gtk_widget_show (dialog_action_area2);
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END);
 
   cancel = gtk_button_new_from_stock ("gtk-cancel");
   gtk_widget_show (cancel);
@@ -975,7 +974,6 @@ create_tx_options (void)
 
   dialog_action_area3 = gtk_dialog_get_content_area(GTK_DIALOG (tx_options));
   gtk_widget_show (dialog_action_area3);
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area3), GTK_BUTTONBOX_END);
 
   pref_reset = gtk_button_new_from_stock ("gtk-revert-to-saved");
   gtk_widget_show (pref_reset);
@@ -1220,7 +1218,6 @@ create_tx_del_mode (void)
 
   dialog_action_area4 = gtk_dialog_get_action_area(GTK_DIALOG (tx_del_mode));
   gtk_widget_show (dialog_action_area4);
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area4), GTK_BUTTONBOX_END);
 
   cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
   gtk_widget_show (cancelbutton1);
@@ -1283,7 +1280,6 @@ create_tX_midilearn (void)
 
   dialog_action_area5 = gtk_dialog_get_action_area(GTK_DIALOG (tX_midilearn));
   gtk_widget_show (dialog_action_area5);
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area5), GTK_BUTTONBOX_END);
 
   cancel = gtk_button_new_from_stock ("gtk-cancel");
   gtk_widget_show (cancel);
@@ -1309,19 +1305,24 @@ create_tX_color_selection (void)
   GtkWidget *cancel_button1;
   GtkWidget *help_button1;
   GtkWidget *color_selection;
+  GValue value = { 0, };
+  g_value_init(&value, GTK_TYPE_WIDGET);
 
   tX_color_selection = gtk_color_selection_dialog_new ("Select Color");
   gtk_window_set_resizable (GTK_WINDOW (tX_color_selection), FALSE);
 
-  g_object_get_property(G_OBJECT(tX_color_selection), "ok-button", (GValue *) &ok_button1);
+  g_object_get_property(G_OBJECT(tX_color_selection), "ok-button", &value);
+  ok_button1 = GTK_WIDGET(g_value_get_object(&value));
   gtk_widget_show (ok_button1);
   gtk_widget_set_can_default(ok_button1, TRUE);
 
-  g_object_get_property(G_OBJECT(tX_color_selection), "cancel-button", (GValue *) &cancel_button1);
+  g_object_get_property(G_OBJECT(tX_color_selection), "cancel-button", &value);
+  cancel_button1 = GTK_WIDGET(g_value_get_object(&value));
   gtk_widget_show (cancel_button1);
   gtk_widget_set_can_default(cancel_button1, TRUE);
 
-  g_object_get_property(G_OBJECT(tX_color_selection), "help-button", (GValue *) &help_button1);
+  g_object_get_property(G_OBJECT(tX_color_selection), "help-button", &value);
+  help_button1 = GTK_WIDGET(g_value_get_object(&value));
   gtk_widget_show (help_button1);
   gtk_widget_set_can_default(help_button1, TRUE);
 
index a9618448049c2e186f47c082f8f51ce39d810f7d..f6ddb6f7469d6682ac5bd26d9463bc1a4706a69f 100644 (file)
@@ -118,11 +118,11 @@ void set_global_defaults() {
        strcpy(globals.record_filename, "tX_record.wav");
        strcpy(globals.file_editor, "");
                
-#ifdef USE_OSS
-       globals.audiodevice_type=OSS;           
-#else
 #ifdef USE_ALSA
        globals.audiodevice_type=ALSA;
+#else
+#ifdef USE_OSS
+       globals.audiodevice_type=OSS;
 #endif 
 #endif         
        globals.use_stdout_cmdline=0;
index b2df0f51f337b673e4c69c8606adc7c43fb23199..cbcb7578465d281900357b87eec77756deacbcb9 100644 (file)
@@ -1388,18 +1388,13 @@ int vtt_class :: load(xmlDocPtr doc, xmlNodePtr node) {
                                
                                for (xmlNodePtr cur=fx->xmlChildrenNode; cur != NULL; cur = cur->next) {
                                        if (cur->type == XML_ELEMENT_NODE) {
-                                               int elementFound=0;
-                                               
                                                if ((xmlStrcmp(cur->name, (xmlChar *) "cutoff")==0) && !stereo) {
                                                        for (unsigned int t=0; t<fx_list.size(); t++) effect_down(lp_fx);
-                                                       elementFound=1;
                                                } else if ((xmlStrcmp(cur->name, (xmlChar *) "lowpass")==0) && !stereo) {
                                                        for (unsigned int t=0; t<fx_list.size(); t++) effect_down(ec_fx);
-                                                       elementFound=1;                                                         
                                                } else if (xmlStrcmp(cur->name, (xmlChar *) "ladspa_plugin")==0) {
                                                        xmlNodePtr pluginNode=cur;
                                                        int ladspa_id=-1;
-                                                       elementFound=1;
                                                        
                                                        for (xmlNodePtr cur=pluginNode->xmlChildrenNode; cur!=NULL; cur = cur->next) {
                                                                int elementFound;
index 6d8bd52594f15b4f1215d773b3bf63b4aae5090a..0142240b2b256d4d5a4e5e3288f5b944f7d46ece 100644 (file)
@@ -369,7 +369,9 @@ void edit_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
                tx_note("No audiofile loaded - so there's nothing to edit.", true);
        } else if (strlen(globals.file_editor)>0) {
                sprintf(command, "%s \"%s\" &", globals.file_editor, vtt->filename);
-               int res = system(command); /*) tx_note("Failed to run the soundfile editor."); */
+               if (system(command) < 0) {
+                       tx_note("Error running the soundfile editor.");
+               }
        } else {
                tx_note("No soundfile editor has been configured - to do so enter the soundfile editor of your choice in the options dialog.", true);
        }
index 56c369331e759c3bca6dc57e86ada8a8d225a435..3185ff6f2b03e1bb2945e64c00a6dfd259e15feb 100644 (file)
@@ -159,6 +159,8 @@ static void gtk_tx_init(GtkTx * tx) {
        tx->zoom=0;
        tx->cursor_pos=0;
        tx->cursor_x_pos=0;
+       
+       tx->surface = NULL;
 }
 
 GtkWidget *gtk_tx_new(int16_t * wavdata, int wavsamples) {
@@ -207,10 +209,12 @@ void gtk_tx_set_data(GtkTx * tx, int16_t * wavdata, int wavsamples) {
 static void gtk_tx_realize(GtkWidget * widget) {
        GdkWindowAttr attributes;
        gint attributes_mask;
-
+       GtkTx *tx;
+       
        g_return_if_fail(widget != NULL);
        g_return_if_fail(GTK_IS_TX(widget));
 
+       tx = GTK_TX(widget);
        gtk_widget_set_realized(widget, TRUE);
 
        GtkAllocation allocation;
@@ -232,6 +236,12 @@ static void gtk_tx_realize(GtkWidget * widget) {
        gdk_window_set_user_data(gtk_widget_get_window(widget), widget);
 
        gtk_style_set_background(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL);
+       
+       if (tx->surface) {
+               cairo_surface_destroy (tx->surface);
+       }
+       
+       tx->surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, allocation.width, allocation.height);
 }
 
 static void gtk_tx_size_request(GtkWidget * widget, GtkRequisition * requisition) {
@@ -245,7 +255,7 @@ static void gtk_tx_prepare(GtkWidget * widget) {
        f_prec value;
        GtkTx *tx;
        int avg_pos;
-       
+
        g_return_if_fail(widget != NULL);
        g_return_if_fail(GTK_IS_TX(widget));
 
@@ -349,6 +359,7 @@ static gint gtk_tx_expose(GtkWidget * widget, GdkEventExpose * event) {
        GtkTx *tx;
        gint x;
        GdkRectangle *area;
+       cairo_t *cr;
        
        g_return_val_if_fail(widget != NULL, FALSE);
        g_return_val_if_fail(GTK_IS_TX(widget), FALSE);
@@ -362,31 +373,36 @@ static gint gtk_tx_expose(GtkWidget * widget, GdkEventExpose * event) {
        area=&event->area;
 
        tx = GTK_TX(widget);
+       cr = gdk_cairo_create (gtk_widget_get_window(widget));
+       cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+       cairo_set_source_surface (cr, tx->surface, 0, 0);
 
-       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], tx->current_bg);
+       gdk_cairo_set_source_color (cr, tx->current_bg);
 
-       gdk_draw_rectangle(gtk_widget_get_window(widget),
-               gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], 1, 
-               area->x, area->y,
-               area->width, area->height);
+       //printf("%i, %i, %i, %i\n", area->x, area->y, area->width, area->height);
 
-       gdk_gc_set_foreground(gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], tx->current_fg);
+       cairo_rectangle(cr, area->x, area->y, area->width, area->height);
+       cairo_fill(cr);
+       
+       cairo_set_line_width(cr,1);
+       
+       gdk_cairo_set_source_color (cr, tx->current_fg);
 
        if (tx->disp_data) {
                int max_x=area->x+area->width;
 
            for (x =area->x; x < max_x; x++) {
-                       gdk_draw_line(gtk_widget_get_window(widget),
-                               gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)], x,
-                               tx->yc - tx->disp_data[tx->display_x_offset+x], x,
-                               tx->yc + tx->disp_data[tx->display_x_offset+x]);
+                       cairo_move_to (cr, x, tx->yc - tx->disp_data[tx->display_x_offset+x]);
+                       cairo_line_to (cr, x, tx->yc + tx->disp_data[tx->display_x_offset+x]+1);
            }
        } else {
                GtkAllocation allocation;
                gtk_widget_get_allocation(widget, &allocation);
-           gdk_draw_line(gtk_widget_get_window(widget), gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
-                        0, tx->yc, allocation.width, tx->yc);
+               cairo_move_to (cr, 0, tx->yc);
+               cairo_line_to (cr, allocation.width, tx->yc);
        }
+       cairo_stroke (cr);
+       cairo_destroy (cr);
 
        return FALSE;
 }
@@ -409,8 +425,8 @@ static void gtk_tx_update(GtkTx * tx) {
 void gtk_tx_update_pos_display(GtkTx * tx, int sample, int mute) {
        GtkWidget *widget;
        GdkWindow *window;
-       GdkGC *gc;
-
+       cairo_t *cr;
+       
        int x, y, yc, ymax, tmp;
        int current_pos, current_pos_x, x_offset;
        int force_draw=0;
@@ -429,7 +445,7 @@ void gtk_tx_update_pos_display(GtkTx * tx, int sample, int mute) {
        widget = GTK_WIDGET(tx);
        window = gtk_widget_get_window(widget);
 
-       gc = gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)];
+
        yc = tx->yc;
        GtkAllocation allocation;
        gtk_widget_get_allocation(widget, &allocation);
@@ -439,13 +455,23 @@ void gtk_tx_update_pos_display(GtkTx * tx, int sample, int mute) {
        
        x = tx->cursor_x_pos;
        
+       cr = gdk_cairo_create (gtk_widget_get_window(widget));
+       cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+       cairo_set_source_surface (cr, tx->surface, 0, 0);
+       
        if (x >= 0) {
-           gdk_gc_set_foreground(gc, tx->current_bg);
-           gdk_draw_line(window, gc, x, 0, x, ymax);
-
-           gdk_gc_set_foreground(gc, tx->current_fg);
+               gdk_cairo_set_source_color (cr, tx->current_bg);
+               
+               cairo_move_to (cr, x, 0);
+               cairo_line_to (cr, x, ymax);
+               cairo_stroke (cr);
+               
+               gdk_cairo_set_source_color (cr, tx->current_fg);
+               
            y = tx->disp_data[x+tx->display_x_offset];
-           gdk_draw_line(window, gc, x, yc + y, x, yc - y);
+               cairo_move_to (cr, x, yc + y);
+               cairo_line_to (cr, x, yc - y+1);
+               cairo_stroke (cr);
        }
        
        /* compute new position */
@@ -490,11 +516,15 @@ void gtk_tx_update_pos_display(GtkTx * tx, int sample, int mute) {
 
        x = current_pos_x;
 
-       if (mute) gdk_gc_set_foreground(gc, &tx->colors[COL_CURSOR_MUTE]);
-       else gdk_gc_set_foreground(gc, &tx->colors[COL_CURSOR]);
+       if (mute) gdk_cairo_set_source_color(cr, &tx->colors[COL_CURSOR_MUTE]);
+       else gdk_cairo_set_source_color(cr, &tx->colors[COL_CURSOR]);
 
-       gdk_draw_line(window, gc, x, 0, x, ymax);
+       cairo_move_to (cr, x, 0);
+       cairo_line_to (cr, x, ymax);
+       cairo_stroke (cr);
        
+       cairo_destroy(cr);
+               
        if (force_draw) {
                gtk_widget_queue_draw_area(widget, 0, 0, allocation.width, allocation.height);
        }
index dfc34bb3fd7a04ef5592aec4f31062996be48cc2..03169c9117e398ee8e8499ee33f0d418868b94e1 100644 (file)
@@ -80,6 +80,8 @@ struct _GtkTx {
 #ifdef USE_DISPLAY_NORMALIZE
        f_prec max_value;
 #endif 
+
+       cairo_surface_t* surface;
 };
 
 struct _GtkTxClass {