Mercurial > dwindows
comparison gtk3/dw.c @ 1575:58ed65820baf
Eliminate even more deprecated APIs for GTK3... still more to go.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 23 Jan 2012 12:30:53 +0000 |
parents | 035bc006afbe |
children | 85fa989dc833 |
comparison
equal
deleted
inserted
replaced
1574:ae5e322584cd | 1575:58ed65820baf |
---|---|
682 child = children->data; | 682 child = children->data; |
683 children = children->next; | 683 children = children->next; |
684 | 684 |
685 if(gtk_widget_get_visible(child->widget)) | 685 if(gtk_widget_get_visible(child->widget)) |
686 { | 686 { |
687 gtk_widget_get_child_requisition (child->widget, &child_requisition); | 687 gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition); |
688 child_allocation.x = 0; | 688 child_allocation.x = 0; |
689 child_allocation.y = 0; | 689 child_allocation.y = 0; |
690 switch (child->state) | 690 switch (child->state) |
691 { | 691 { |
692 case CHILD_NORMAL: | 692 case CHILD_NORMAL: |
833 case GDK_BUTTON_PRESS: | 833 case GDK_BUTTON_PRESS: |
834 if (child->state == CHILD_MAXIMIZED) | 834 if (child->state == CHILD_MAXIMIZED) |
835 return FALSE; | 835 return FALSE; |
836 if (mdi->drag_button < 0) | 836 if (mdi->drag_button < 0) |
837 { | 837 { |
838 if (gdk_pointer_grab (event->button.window, | 838 if (gdk_device_grab (gdk_event_get_device(event), |
839 event->button.window, | |
840 GDK_OWNERSHIP_WINDOW, | |
839 FALSE, | 841 FALSE, |
840 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | | 842 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | |
841 GDK_BUTTON_RELEASE_MASK, | 843 GDK_BUTTON_RELEASE_MASK, |
842 NULL, | 844 NULL, |
843 NULL, | |
844 event->button.time) != GDK_GRAB_SUCCESS) | 845 event->button.time) != GDK_GRAB_SUCCESS) |
845 return FALSE; | 846 return FALSE; |
846 | 847 |
847 mdi->drag_button = event->button.button; | 848 mdi->drag_button = event->button.button; |
848 | 849 |
857 | 858 |
858 if (mdi->drag_button == event->button.button) | 859 if (mdi->drag_button == event->button.button) |
859 { | 860 { |
860 int x, y; | 861 int x, y; |
861 | 862 |
862 gdk_pointer_ungrab (event->button.time); | 863 gdk_device_ungrab (gdk_event_get_device(event), event->button.time); |
863 mdi->drag_button = -1; | 864 mdi->drag_button = -1; |
864 | 865 |
865 x = event->button.x + child->x - mdi->drag_start.x; | 866 x = event->button.x + child->x - mdi->drag_start.x; |
866 y = event->button.y + child->y - mdi->drag_start.y; | 867 y = event->button.y + child->y - mdi->drag_start.y; |
867 | 868 |
874 int x, y; | 875 int x, y; |
875 | 876 |
876 if (mdi->drag_button < 0) | 877 if (mdi->drag_button < 0) |
877 return FALSE; | 878 return FALSE; |
878 | 879 |
879 gdk_window_get_pointer (gtk_widget_get_window(widget), &x, &y, NULL); | 880 gdk_window_get_device_position (gtk_widget_get_window(widget), gdk_event_get_device(event), &x, &y, NULL); |
880 | 881 |
881 | 882 |
882 x = x - mdi->drag_start.x + child->x; | 883 x = x - mdi->drag_start.x + child->x; |
883 y = y - mdi->drag_start.y + child->y; | 884 y = y - mdi->drag_start.y + child->y; |
884 | 885 |
908 switch (event->type) | 909 switch (event->type) |
909 { | 910 { |
910 case GDK_BUTTON_PRESS: | 911 case GDK_BUTTON_PRESS: |
911 if (mdi->drag_button < 0) | 912 if (mdi->drag_button < 0) |
912 { | 913 { |
913 if (gdk_pointer_grab (event->button.window, | 914 if (gdk_device_grab (gdk_event_get_device(event), |
915 event->button.window, | |
916 GDK_OWNERSHIP_WINDOW, | |
914 FALSE, | 917 FALSE, |
915 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | | 918 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | |
916 GDK_BUTTON_RELEASE_MASK, | 919 GDK_BUTTON_RELEASE_MASK, |
917 NULL, | |
918 NULL, | 920 NULL, |
919 event->button.time) != GDK_GRAB_SUCCESS) | 921 event->button.time) != GDK_GRAB_SUCCESS) |
920 return FALSE; | 922 return FALSE; |
921 | 923 |
922 mdi->drag_button = event->button.button; | 924 mdi->drag_button = event->button.button; |
942 if (mdi->drag_button == event->button.button) | 944 if (mdi->drag_button == event->button.button) |
943 { | 945 { |
944 int width, height; | 946 int width, height; |
945 GtkAllocation allocation; | 947 GtkAllocation allocation; |
946 | 948 |
947 gdk_pointer_ungrab (event->button.time); | 949 gdk_device_ungrab (gdk_event_get_device(event), event->button.time); |
948 mdi->drag_button = -1; | 950 mdi->drag_button = -1; |
949 | 951 |
950 gtk_widget_get_allocation(widget, &allocation); | 952 gtk_widget_get_allocation(widget, &allocation); |
951 width = event->button.x + allocation.x; | 953 width = event->button.x + allocation.x; |
952 height = event->button.y + allocation.y; | 954 height = event->button.y + allocation.y; |
966 GtkAllocation allocation; | 968 GtkAllocation allocation; |
967 | 969 |
968 if (mdi->drag_button < 0) | 970 if (mdi->drag_button < 0) |
969 return FALSE; | 971 return FALSE; |
970 | 972 |
971 gdk_window_get_pointer (gtk_widget_get_window(widget), &x, &y, NULL); | 973 gdk_window_get_device_position (gtk_widget_get_window(widget), gdk_event_get_device(event), &x, &y, NULL); |
972 | 974 |
973 gtk_widget_get_allocation(widget, &allocation); | 975 gtk_widget_get_allocation(widget, &allocation); |
974 width = x + allocation.x; | 976 width = x + allocation.x; |
975 height = y + allocation.y; | 977 height = y + allocation.y; |
976 | 978 |
1217 | 1219 |
1218 if(work.window) | 1220 if(work.window) |
1219 { | 1221 { |
1220 int (*motionfunc)(HWND, int, int, int, void *) = work.func; | 1222 int (*motionfunc)(HWND, int, int, int, void *) = work.func; |
1221 int keys = 0, x, y; | 1223 int keys = 0, x, y; |
1222 GdkModifierType state; | 1224 GdkModifierType state = 0; |
1223 | 1225 |
1224 if (event->is_hint) | 1226 if (event->is_hint) |
1225 gdk_window_get_pointer (event->window, &x, &y, &state); | 1227 gdk_window_get_device_position (event->window, gdk_event_get_device((GdkEvent *)event), &x, &y, &state); |
1226 else | 1228 else |
1227 { | 1229 { |
1228 x = event->x; | 1230 x = event->x; |
1229 y = event->y; | 1231 y = event->y; |
1230 state = event->state; | 1232 state = event->state; |
1835 } | 1837 } |
1836 /* If that failed... just get the current directory */ | 1838 /* If that failed... just get the current directory */ |
1837 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) | 1839 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) |
1838 _dw_share_path[0] = '/'; | 1840 _dw_share_path[0] = '/'; |
1839 | 1841 |
1840 #if !GLIB_CHECK_VERSION(2,32,0) | 1842 #if !GLIB_CHECK_VERSION(2,31,0) |
1841 g_thread_init(NULL); | 1843 g_thread_init(NULL); |
1842 #endif | 1844 #endif |
1843 gdk_threads_init(); | 1845 gdk_threads_init(); |
1844 | 1846 |
1845 gtk_init(argc, argv); | 1847 gtk_init(argc, argv); |
2850 { | 2852 { |
2851 /* TODO */ | 2853 /* TODO */ |
2852 return 0; | 2854 return 0; |
2853 } | 2855 } |
2854 | 2856 |
2857 static GdkDeviceManager *manager = NULL; | |
2858 | |
2855 /* | 2859 /* |
2856 * Captures the mouse input to this window. | 2860 * Captures the mouse input to this window. |
2857 * Parameters: | 2861 * Parameters: |
2858 * handle: Handle to receive mouse input. | 2862 * handle: Handle to receive mouse input. |
2859 */ | 2863 */ |
2860 void dw_window_capture(HWND handle) | 2864 void dw_window_capture(HWND handle) |
2861 { | 2865 { |
2862 int _locked_by_me = FALSE; | 2866 int _locked_by_me = FALSE; |
2863 | 2867 |
2864 DW_MUTEX_LOCK; | 2868 DW_MUTEX_LOCK; |
2865 gdk_pointer_grab(gtk_widget_get_window(handle), TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, NULL, NULL, GDK_CURRENT_TIME); | 2869 manager = gdk_display_get_device_manager(gtk_widget_get_display(handle)); |
2870 gdk_device_grab(gdk_device_manager_get_client_pointer(manager), | |
2871 gtk_widget_get_window(handle), | |
2872 GDK_OWNERSHIP_WINDOW, | |
2873 FALSE, | |
2874 GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, | |
2875 NULL, | |
2876 GDK_CURRENT_TIME); | |
2866 DW_MUTEX_UNLOCK; | 2877 DW_MUTEX_UNLOCK; |
2867 } | 2878 } |
2868 | 2879 |
2869 /* | 2880 /* |
2870 * Changes the appearance of the mouse pointer. | 2881 * Changes the appearance of the mouse pointer. |
2888 else | 2899 else |
2889 cursor = gdk_cursor_new(pointertype); | 2900 cursor = gdk_cursor_new(pointertype); |
2890 if(handle && gtk_widget_get_window(handle)) | 2901 if(handle && gtk_widget_get_window(handle)) |
2891 gdk_window_set_cursor(gtk_widget_get_window(handle), cursor); | 2902 gdk_window_set_cursor(gtk_widget_get_window(handle), cursor); |
2892 if(cursor) | 2903 if(cursor) |
2893 gdk_cursor_unref(cursor); | 2904 g_object_unref(cursor); |
2894 DW_MUTEX_UNLOCK; | 2905 DW_MUTEX_UNLOCK; |
2895 } | 2906 } |
2896 | 2907 |
2897 /* | 2908 /* |
2898 * Releases previous mouse capture. | 2909 * Releases previous mouse capture. |
2900 void dw_window_release(void) | 2911 void dw_window_release(void) |
2901 { | 2912 { |
2902 int _locked_by_me = FALSE; | 2913 int _locked_by_me = FALSE; |
2903 | 2914 |
2904 DW_MUTEX_LOCK; | 2915 DW_MUTEX_LOCK; |
2905 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 2916 gdk_device_ungrab(gdk_device_manager_get_client_pointer(manager), GDK_CURRENT_TIME); |
2917 manager = NULL; | |
2906 DW_MUTEX_UNLOCK; | 2918 DW_MUTEX_UNLOCK; |
2907 } | 2919 } |
2908 | 2920 |
2909 /* | 2921 /* |
2910 * Create a new Window Frame. | 2922 * Create a new Window Frame. |
3564 * x: Pointer to variable to store X coordinate. | 3576 * x: Pointer to variable to store X coordinate. |
3565 * y: Pointer to variable to store Y coordinate. | 3577 * y: Pointer to variable to store Y coordinate. |
3566 */ | 3578 */ |
3567 void dw_pointer_query_pos(long *x, long *y) | 3579 void dw_pointer_query_pos(long *x, long *y) |
3568 { | 3580 { |
3569 GdkModifierType state; | 3581 GdkModifierType state = 0; |
3570 int gx, gy; | 3582 int gx, gy; |
3571 int _locked_by_me = FALSE; | 3583 int _locked_by_me = FALSE; |
3584 GdkDisplay *display; | |
3585 GdkDeviceManager *manager; | |
3572 | 3586 |
3573 DW_MUTEX_LOCK; | 3587 DW_MUTEX_LOCK; |
3574 #ifdef GDK_WINDOWING_X11 | 3588 #ifdef GDK_WINDOWING_X11 |
3575 gdk_window_get_pointer (gdk_x11_window_lookup_for_display(gdk_display_get_default(), GDK_ROOT_WINDOW()), &gx, &gy, &state); | 3589 display = gdk_display_get_default(); |
3590 manager = gdk_display_get_device_manager(display); | |
3591 gdk_window_get_device_position (gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW()), | |
3592 gdk_device_manager_get_client_pointer(manager), &gx, &gy, &state); | |
3576 #endif | 3593 #endif |
3577 if(x) | 3594 if(x) |
3578 *x = gx; | 3595 *x = gx; |
3579 if(y) | 3596 if(y) |
3580 *y = gy; | 3597 *y = gy; |
3588 * y: Y coordinate. | 3605 * y: Y coordinate. |
3589 */ | 3606 */ |
3590 void dw_pointer_set_pos(long x, long y) | 3607 void dw_pointer_set_pos(long x, long y) |
3591 { | 3608 { |
3592 int _locked_by_me = FALSE; | 3609 int _locked_by_me = FALSE; |
3610 GdkDisplay *display; | |
3611 GdkDeviceManager *manager; | |
3593 | 3612 |
3594 DW_MUTEX_LOCK; | 3613 DW_MUTEX_LOCK; |
3595 #ifdef GDK_WINDOWING_X11 | 3614 #ifdef GDK_WINDOWING_X11 |
3596 gdk_display_warp_pointer( gdk_display_get_default(), gdk_screen_get_default(), x, y ); | 3615 display = gdk_display_get_default(); |
3616 manager = gdk_display_get_device_manager(display); | |
3617 gdk_device_warp( gdk_device_manager_get_client_pointer(manager), gdk_screen_get_default(), x, y ); | |
3597 #endif | 3618 #endif |
3598 DW_MUTEX_UNLOCK; | 3619 DW_MUTEX_UNLOCK; |
3599 } | 3620 } |
3600 | 3621 |
3601 #define _DW_TREE_CONTAINER 1 | 3622 #define _DW_TREE_CONTAINER 1 |
3932 int _locked_by_me = FALSE; | 3953 int _locked_by_me = FALSE; |
3933 | 3954 |
3934 DW_MUTEX_LOCK; | 3955 DW_MUTEX_LOCK; |
3935 | 3956 |
3936 /* Create box for image and label */ | 3957 /* Create box for image and label */ |
3937 box = gtk_hbox_new (FALSE, 0); | 3958 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); |
3938 gtk_container_set_border_width (GTK_CONTAINER (box), 2); | 3959 gtk_container_set_border_width (GTK_CONTAINER (box), 2); |
3939 | 3960 |
3940 /* Create a new button */ | 3961 /* Create a new button */ |
3941 button = gtk_button_new(); | 3962 button = gtk_button_new(); |
3942 /* Now on to the image stuff */ | 3963 /* Now on to the image stuff */ |
4069 GtkAdjustment *adjustment; | 4090 GtkAdjustment *adjustment; |
4070 int _locked_by_me = FALSE; | 4091 int _locked_by_me = FALSE; |
4071 | 4092 |
4072 DW_MUTEX_LOCK; | 4093 DW_MUTEX_LOCK; |
4073 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); | 4094 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); |
4074 if(vertical) | 4095 tmp = gtk_scale_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment); |
4075 tmp = gtk_vscale_new(adjustment); | |
4076 else | |
4077 tmp = gtk_hscale_new(adjustment); | |
4078 gtk_widget_show(tmp); | 4096 gtk_widget_show(tmp); |
4079 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0); | 4097 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0); |
4080 gtk_scale_set_digits(GTK_SCALE(tmp), 0); | 4098 gtk_scale_set_digits(GTK_SCALE(tmp), 0); |
4081 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); | 4099 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); |
4082 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp); | 4100 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp); |
4098 GtkAdjustment *adjustment; | 4116 GtkAdjustment *adjustment; |
4099 int _locked_by_me = FALSE; | 4117 int _locked_by_me = FALSE; |
4100 | 4118 |
4101 DW_MUTEX_LOCK; | 4119 DW_MUTEX_LOCK; |
4102 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1); | 4120 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1); |
4103 if(vertical) | 4121 tmp = gtk_scrollbar_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment); |
4104 tmp = gtk_vscrollbar_new(adjustment); | |
4105 else | |
4106 tmp = gtk_hscrollbar_new(adjustment); | |
4107 gtk_widget_set_can_focus(tmp, FALSE); | 4122 gtk_widget_set_can_focus(tmp, FALSE); |
4108 gtk_widget_show(tmp); | 4123 gtk_widget_show(tmp); |
4109 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); | 4124 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); |
4110 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); | 4125 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); |
4111 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 4126 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
6254 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); | 6269 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); |
6255 | 6270 |
6256 /* Make sure it is the correct tree type */ | 6271 /* Make sure it is the correct tree type */ |
6257 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) | 6272 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) |
6258 { | 6273 { |
6259 GtkAdjustment *adjust = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(cont)); | 6274 GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(cont)); |
6260 | 6275 |
6261 if(adjust) | 6276 if(adjust) |
6262 { | 6277 { |
6263 gint rowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount")); | 6278 gint rowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount")); |
6264 gdouble currpos = gtk_adjustment_get_value(adjust); | 6279 gdouble currpos = gtk_adjustment_get_value(adjust); |
9005 if((vert & 0xf) == DW_GRAV_CENTER) | 9020 if((vert & 0xf) == DW_GRAV_CENTER) |
9006 newy += ((gdk_screen_height() / 2) - (height / 2)); | 9021 newy += ((gdk_screen_height() / 2) - (height / 2)); |
9007 else if((vert & 0xf) == DW_GRAV_BOTTOM) | 9022 else if((vert & 0xf) == DW_GRAV_BOTTOM) |
9008 newy = gdk_screen_height() - height - y; | 9023 newy = gdk_screen_height() - height - y; |
9009 | 9024 |
9010 #if GTK_CHECK_VERSION(3,4,0) | 9025 #if GTK_CHECK_VERSION(3,3,8) |
9011 /* Adjust the values to avoid Gnome bar if requested */ | 9026 /* Adjust the values to avoid Gnome bar if requested */ |
9012 if((horz | vert) & DW_GRAV_OBSTACLES) | 9027 if((horz | vert) & DW_GRAV_OBSTACLES) |
9013 { | 9028 { |
9014 GdkRectangle rect; | 9029 GdkRectangle rect; |
9015 GdkScreen *screen = gdk_screen_get_default(); | 9030 GdkScreen *screen = gdk_screen_get_default(); |
10043 GtkWidget *tmp = NULL; | 10058 GtkWidget *tmp = NULL; |
10044 int _locked_by_me = FALSE; | 10059 int _locked_by_me = FALSE; |
10045 float *percent = malloc(sizeof(float)); | 10060 float *percent = malloc(sizeof(float)); |
10046 | 10061 |
10047 DW_MUTEX_LOCK; | 10062 DW_MUTEX_LOCK; |
10048 if(type == DW_HORZ) | 10063 tmp = gtk_paned_new(type == DW_HORZ ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); |
10049 tmp = gtk_hpaned_new(); | |
10050 else | |
10051 tmp = gtk_vpaned_new(); | |
10052 gtk_paned_pack1(GTK_PANED(tmp), topleft, TRUE, FALSE); | 10064 gtk_paned_pack1(GTK_PANED(tmp), topleft, TRUE, FALSE); |
10053 gtk_paned_pack2(GTK_PANED(tmp), bottomright, TRUE, FALSE); | 10065 gtk_paned_pack2(GTK_PANED(tmp), bottomright, TRUE, FALSE); |
10054 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 10066 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
10055 *percent = 50.0; | 10067 *percent = 50.0; |
10056 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent); | 10068 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent); |