comparison gtk3/dw.c @ 1597:ed09531b7f0e

Removed deprecated GtkColorSelectionDialog in 3.4 and higher switching to GtkColorChooser.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 25 Feb 2012 01:50:25 +0000
parents 525c4c9d04c6
children c3e08322b8f6
comparison
equal deleted inserted replaced
1596:ae90d440b2a4 1597:ed09531b7f0e
116 pthread_key_t _dw_bg_color_key; 116 pthread_key_t _dw_bg_color_key;
117 pthread_key_t _dw_mutex_key; 117 pthread_key_t _dw_mutex_key;
118 118
119 GtkWidget *last_window = NULL, *popup = NULL; 119 GtkWidget *last_window = NULL, *popup = NULL;
120 120
121 static int _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; 121 static int _dw_ignore_click = 0, _dw_ignore_expand = 0;
122 static pthread_t _dw_thread = (pthread_t)-1; 122 static pthread_t _dw_thread = (pthread_t)-1;
123 123
124 #define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && !pthread_getspecific(_dw_mutex_key)) { gdk_threads_enter(); pthread_setspecific(_dw_mutex_key, (void *)1); _locked_by_me = TRUE; } } 124 #define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && !pthread_getspecific(_dw_mutex_key)) { gdk_threads_enter(); pthread_setspecific(_dw_mutex_key, (void *)1); _locked_by_me = TRUE; } }
125 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); pthread_setspecific(_dw_mutex_key, NULL); _locked_by_me = FALSE; } } 125 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); pthread_setspecific(_dw_mutex_key, NULL); _locked_by_me = FALSE; } }
126 126
6693 } 6693 }
6694 *background = color; 6694 *background = color;
6695 } 6695 }
6696 } 6696 }
6697 6697
6698 #if GTK_CHECK_VERSION(3,3,11)
6699 /* Allows the user to choose a color using the system's color chooser dialog.
6700 * Parameters:
6701 * value: current color
6702 * Returns:
6703 * The selected color or the current color if cancelled.
6704 */
6705 unsigned long API dw_color_choose(unsigned long value)
6706 {
6707 GtkColorChooser *cd;
6708 GdkRGBA color = _internal_color(value);
6709 int _locked_by_me = FALSE;
6710 unsigned long retcolor = value;
6711
6712 DW_MUTEX_LOCK;
6713 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL);
6714 gtk_color_chooser_set_use_alpha(cd, FALSE);
6715 gtk_color_chooser_set_rgba(cd, &color);
6716
6717 gtk_widget_show(GTK_WIDGET(cd));
6718
6719 if(gtk_dialog_run(GTK_DIALOG(cd)) == GTK_RESPONSE_OK)
6720 {
6721 gtk_color_chooser_get_rgba(cd, &color);
6722 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255));
6723 }
6724 gtk_widget_destroy(GTK_WIDGET(cd));
6725 DW_MUTEX_UNLOCK;
6726 return retcolor;
6727 }
6728 #else
6729 static int _dw_color_active = 0;
6730
6698 /* Internal function to handle the color OK press */ 6731 /* Internal function to handle the color OK press */
6699 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait) 6732 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait)
6700 { 6733 {
6701 GdkRGBA color; 6734 GdkRGBA color;
6702 unsigned long dw_color; 6735 unsigned long dw_color;
6772 dw_color = (unsigned long)dw_dialog_wait(dwwait); 6805 dw_color = (unsigned long)dw_dialog_wait(dwwait);
6773 if ((unsigned long)dw_color == -1) 6806 if ((unsigned long)dw_color == -1)
6774 dw_color = value; 6807 dw_color = value;
6775 DW_MUTEX_UNLOCK; 6808 DW_MUTEX_UNLOCK;
6776 return (unsigned long)dw_color; 6809 return (unsigned long)dw_color;
6777 /* 6810 }
6778 dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); 6811 #endif
6779 return value;
6780 */
6781 }
6782 6812
6783 /* Draw a point on a window (preferably a render window). 6813 /* Draw a point on a window (preferably a render window).
6784 * Parameters: 6814 * Parameters:
6785 * handle: Handle to the window. 6815 * handle: Handle to the window.
6786 * pixmap: Handle to the pixmap. (choose only one of these) 6816 * pixmap: Handle to the pixmap. (choose only one of these)