Mercurial > dwindows
comparison gtk4/dw.c @ 2310:5df7b1431d1a
GTK4: Moved the rest of the menu functions into thread safety to try to fix
a X error with popup menus, but it did not work... will have to keep
looking.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 10 Feb 2021 10:18:10 +0000 |
parents | e238178186ff |
children | f6a6ea6b28fe |
comparison
equal
deleted
inserted
replaced
2309:e238178186ff | 2310:5df7b1431d1a |
---|---|
2554 * Create a menu object to be popped up. | 2554 * Create a menu object to be popped up. |
2555 * Parameters: | 2555 * Parameters: |
2556 * id: An ID to be used for getting the resource from the | 2556 * id: An ID to be used for getting the resource from the |
2557 * resource file. | 2557 * resource file. |
2558 */ | 2558 */ |
2559 HMENUI dw_menu_new(unsigned long id) | 2559 DW_FUNCTION_DEFINITION(dw_menu_new, HMENUI, ULONG cid) |
2560 DW_FUNCTION_ADD_PARAM1(cid) | |
2561 DW_FUNCTION_RETURN(dw_menu_new, HMENUI) | |
2562 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) | |
2560 { | 2563 { |
2561 GMenu *tmp = g_menu_new(); | 2564 GMenu *tmp = g_menu_new(); |
2562 /* Create the initial section and add it to the menu */ | 2565 /* Create the initial section and add it to the menu */ |
2563 GMenu *section = g_menu_new(); | 2566 GMenu *section = g_menu_new(); |
2564 GMenuItem *item = g_menu_item_new_section(NULL, G_MENU_MODEL(section)); | 2567 GMenuItem *item = g_menu_item_new_section(NULL, G_MENU_MODEL(section)); |
2566 | 2569 |
2567 g_menu_append_item(tmp, item); | 2570 g_menu_append_item(tmp, item); |
2568 | 2571 |
2569 g_object_set_data(G_OBJECT(tmp), "_dw_menugroup", GINT_TO_POINTER(++_dw_menugroup)); | 2572 g_object_set_data(G_OBJECT(tmp), "_dw_menugroup", GINT_TO_POINTER(++_dw_menugroup)); |
2570 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group); | 2573 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group); |
2571 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 2574 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid)); |
2572 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section); | 2575 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section); |
2573 return tmp; | 2576 DW_FUNCTION_RETURN_THIS(tmp); |
2574 } | 2577 } |
2575 | 2578 |
2576 /* | 2579 /* |
2577 * Create a menubar on a window. | 2580 * Create a menubar on a window. |
2578 * Parameters: | 2581 * Parameters: |
2836 * Parameters: | 2839 * Parameters: |
2837 * menu: The handle the the existing menu. | 2840 * menu: The handle the the existing menu. |
2838 * id: Menuitem id. | 2841 * id: Menuitem id. |
2839 * state: TRUE for checked FALSE for not checked. | 2842 * state: TRUE for checked FALSE for not checked. |
2840 */ | 2843 */ |
2841 void dw_menu_item_set_state(HMENUI menu, unsigned long id, unsigned long state) | 2844 DW_FUNCTION_DEFINITION(dw_menu_item_set_state, void, HMENUI menu, ULONG cid, ULONG state) |
2845 DW_FUNCTION_ADD_PARAM3(menu, cid, state) | |
2846 DW_FUNCTION_NO_RETURN(dw_menu_item_set_state) | |
2847 DW_FUNCTION_RESTORE_PARAM3(menu, HMENUI, cid, ULONG, state, ULONG) | |
2842 { | 2848 { |
2843 char numbuf[25] = {0}; | 2849 char numbuf[25] = {0}; |
2844 GMenuItem *tmphandle; | 2850 GMenuItem *tmphandle; |
2845 | 2851 |
2846 if(!menu) | 2852 if(menu) |
2847 return; | 2853 { |
2848 | 2854 snprintf(numbuf, 24, "%lu", cid); |
2849 snprintf(numbuf, 24, "%lu", id); | 2855 tmphandle = _dw_find_submenu_id(menu, numbuf); |
2850 tmphandle = _dw_find_submenu_id(menu, numbuf); | 2856 |
2851 | 2857 if(tmphandle && G_IS_MENU_ITEM(tmphandle)) |
2852 if(tmphandle && G_IS_MENU_ITEM(tmphandle)) | 2858 { |
2853 { | 2859 GSimpleAction *action = g_object_get_data(G_OBJECT(tmphandle), "_dw_action"); |
2854 GSimpleAction *action = g_object_get_data(G_OBJECT(tmphandle), "_dw_action"); | 2860 |
2855 | 2861 #if 0 |
2856 #if 0 | 2862 if((state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED)) |
2857 if((state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED)) | 2863 { |
2858 { | 2864 int check = 0; |
2859 int check = 0; | 2865 |
2860 | 2866 if(state & DW_MIS_CHECKED) |
2861 if(state & DW_MIS_CHECKED) | 2867 check = 1; |
2862 check = 1; | 2868 |
2863 | 2869 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(tmphandle)) != check) |
2864 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(tmphandle)) != check) | 2870 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check); |
2865 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check); | 2871 } |
2866 } | 2872 #endif |
2867 #endif | 2873 if((state & DW_MIS_ENABLED) || (state & DW_MIS_DISABLED)) |
2868 if((state & DW_MIS_ENABLED) || (state & DW_MIS_DISABLED)) | 2874 { |
2869 { | 2875 if(state & DW_MIS_ENABLED) |
2870 if(state & DW_MIS_ENABLED) | 2876 g_simple_action_set_enabled(action, TRUE); |
2871 g_simple_action_set_enabled(action, TRUE); | 2877 else |
2872 else | 2878 g_simple_action_set_enabled(action, FALSE); |
2873 g_simple_action_set_enabled(action, FALSE); | 2879 } |
2874 } | 2880 } |
2875 } | 2881 } |
2882 DW_FUNCTION_RETURN_NOTHING; | |
2876 } | 2883 } |
2877 | 2884 |
2878 /* | 2885 /* |
2879 * Deletes the menu item specified. | 2886 * Deletes the menu item specified. |
2880 * Parameters: | 2887 * Parameters: |
2881 * menu: The handle to the menu in which the item was appended. | 2888 * menu: The handle to the menu in which the item was appended. |
2882 * id: Menuitem id. | 2889 * id: Menuitem id. |
2883 * Returns: | 2890 * Returns: |
2884 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. | 2891 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. |
2885 */ | 2892 */ |
2886 int API dw_menu_delete_item(HMENUI menu, unsigned long id) | 2893 DW_FUNCTION_DEFINITION(dw_menu_delete_item, int, HMENUI menu, ULONG cid) |
2894 DW_FUNCTION_ADD_PARAM2(menu, cid) | |
2895 DW_FUNCTION_RETURN(dw_menu_delete_item, int) | |
2896 DW_FUNCTION_RESTORE_PARAM2(menu, HMENUI, cid, ULONG) | |
2887 { | 2897 { |
2888 int ret = DW_ERROR_UNKNOWN; | 2898 int ret = DW_ERROR_UNKNOWN; |
2889 char numbuf[25] = {0}; | 2899 char numbuf[25] = {0}; |
2890 GMenuItem *tmphandle; | 2900 GMenuItem *tmphandle; |
2891 | 2901 |
2892 if(!menu) | 2902 if(menu) |
2893 return ret; | 2903 { |
2894 | 2904 snprintf(numbuf, 24, "%lu", cid); |
2895 snprintf(numbuf, 24, "%lu", id); | 2905 tmphandle = _dw_find_submenu_id(menu, numbuf); |
2896 tmphandle = _dw_find_submenu_id(menu, numbuf); | 2906 |
2897 | 2907 if(tmphandle && G_IS_MENU_ITEM(tmphandle)) |
2898 if(tmphandle && G_IS_MENU_ITEM(tmphandle)) | 2908 { |
2899 { | 2909 /* g_menu_remove(menu, position); */ |
2900 /* g_menu_remove(menu, position); */ | 2910 g_object_unref(G_OBJECT(tmphandle)); |
2901 g_object_unref(G_OBJECT(tmphandle)); | 2911 g_object_set_data(G_OBJECT(menu), numbuf, NULL); |
2902 g_object_set_data(G_OBJECT(menu), numbuf, NULL); | 2912 ret = DW_ERROR_NONE; |
2903 ret = DW_ERROR_NONE; | 2913 } |
2904 } | 2914 } |
2905 return ret; | 2915 DW_FUNCTION_RETURN_THIS(ret); |
2906 } | 2916 } |
2907 | 2917 |
2908 /* Delayed unparent of the popup menu from the parent */ | 2918 /* Delayed unparent of the popup menu from the parent */ |
2909 gboolean _dw_idle_popover_unparent(gpointer data) | 2919 gboolean _dw_idle_popover_unparent(gpointer data) |
2910 { | 2920 { |