You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

86 lines
2.2 KiB

  1. %%
  2. headers
  3. #define NO_IMPORT_PYGOBJECT
  4. #define NO_IMPORT_PYGTK
  5. #include <pygobject.h>
  6. #include <pygtk/pygtk.h>
  7. #include "xed-utils.h"
  8. void pyxedutils_register_classes (PyObject *d);
  9. void pyxedutils_add_constants (PyObject *module, const gchar *strip_prefix);
  10. %%
  11. modulename xed.utils
  12. %%
  13. import gtk.Widget as PyGtkWidget_Type
  14. import gtk.TreeView as PyGtkTreeView_Type
  15. import gtk.Menu as PyGtkMenu_Type
  16. %%
  17. ignore-glob
  18. _*
  19. %%
  20. override xed_utils_menu_position_under_widget kwargs
  21. static PyObject *
  22. _wrap_xed_utils_menu_position_under_widget (PyObject *self,
  23. PyObject *args,
  24. PyObject *kwargs)
  25. {
  26. static char *kwlist[] = { "menu", "widget", NULL };
  27. PyObject *py_menu, *py_widget;
  28. GtkMenu *menu;
  29. GtkWidget *widget;
  30. gint x, y;
  31. gboolean push_in;
  32. PyObject *tuple;
  33. if (!PyArg_ParseTupleAndKeywords (args, kwargs,
  34. "O!O!", kwlist,
  35. &PyGtkMenu_Type, &py_menu,
  36. &PyGtkWidget_Type, &py_widget))
  37. return NULL;
  38. menu = GTK_MENU (pygobject_get (py_menu));
  39. widget = GTK_WIDGET (pygobject_get (py_widget));
  40. xed_utils_menu_position_under_widget (menu, &x, &y, &push_in, widget);
  41. tuple = PyTuple_New (3);
  42. PyTuple_SetItem (tuple, 0, PyInt_FromLong (x));
  43. PyTuple_SetItem (tuple, 1, PyInt_FromLong (y));
  44. PyTuple_SetItem (tuple, 2, PyBool_FromLong (push_in));
  45. return tuple;
  46. }
  47. %%
  48. override xed_utils_menu_position_under_tree_view kwargs
  49. static PyObject *
  50. _wrap_xed_utils_menu_position_under_tree_view (PyObject *self,
  51. PyObject *args,
  52. PyObject *kwargs)
  53. {
  54. static char *kwlist[] = { "menu", "tree_view", NULL };
  55. PyObject *py_menu, *py_view;
  56. GtkMenu *menu;
  57. GtkTreeView *view;
  58. gint x, y;
  59. gboolean push_in;
  60. PyObject *tuple;
  61. if (!PyArg_ParseTupleAndKeywords (args, kwargs,
  62. "O!O!", kwlist,
  63. &PyGtkMenu_Type, &py_menu,
  64. &PyGtkTreeView_Type, &py_view))
  65. return NULL;
  66. menu = GTK_MENU (pygobject_get (py_menu));
  67. view = GTK_TREE_VIEW (pygobject_get (py_view));
  68. xed_utils_menu_position_under_widget (menu, &x, &y, &push_in, view);
  69. tuple = PyTuple_New (3);
  70. PyTuple_SetItem (tuple, 0, PyInt_FromLong (x));
  71. PyTuple_SetItem (tuple, 1, PyInt_FromLong (y));
  72. PyTuple_SetItem (tuple, 2, PyBool_FromLong (push_in));
  73. return tuple;
  74. }