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.

gtkitemfactory.h 7.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * GtkItemFactory: Flexible item factory with automatic rc handling
  5. * Copyright (C) 1998 Tim Janik
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. /*
  23. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  24. * file for a list of people on the GTK+ Team. See the ChangeLog
  25. * files for a list of changes. These files are distributed with
  26. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  27. */
  28. #ifndef GTK_DISABLE_DEPRECATED
  29. #ifndef __GTK_ITEM_FACTORY_H__
  30. #define __GTK_ITEM_FACTORY_H__
  31. #include <gtk/gtk.h>
  32. G_BEGIN_DECLS
  33. typedef void (*GtkPrintFunc) (gpointer func_data,
  34. const gchar *str);
  35. /* We use () here to mean unspecified arguments. This is deprecated
  36. * as of C99, but we can't change it without breaking compatibility.
  37. * (Note that if we are included from a C++ program () will mean
  38. * (void) so an explicit cast will be needed.)
  39. */
  40. typedef void (*GtkItemFactoryCallback) ();
  41. typedef void (*GtkItemFactoryCallback1) (gpointer callback_data,
  42. guint callback_action,
  43. GtkWidget *widget);
  44. #define GTK_TYPE_ITEM_FACTORY (gtk_item_factory_get_type ())
  45. #define GTK_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ITEM_FACTORY, GtkItemFactory))
  46. #define GTK_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass))
  47. #define GTK_IS_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ITEM_FACTORY))
  48. #define GTK_IS_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM_FACTORY))
  49. #define GTK_ITEM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass))
  50. typedef struct _GtkItemFactory GtkItemFactory;
  51. typedef struct _GtkItemFactoryClass GtkItemFactoryClass;
  52. typedef struct _GtkItemFactoryEntry GtkItemFactoryEntry;
  53. typedef struct _GtkItemFactoryItem GtkItemFactoryItem;
  54. struct _GtkItemFactory
  55. {
  56. GtkObject object;
  57. gchar *path;
  58. GtkAccelGroup *accel_group;
  59. GtkWidget *widget;
  60. GSList *items;
  61. GtkTranslateFunc translate_func;
  62. gpointer translate_data;
  63. GDestroyNotify translate_notify;
  64. };
  65. struct _GtkItemFactoryClass
  66. {
  67. GtkObjectClass object_class;
  68. GHashTable *item_ht;
  69. /* Padding for future expansion */
  70. void (*_gtk_reserved1) (void);
  71. void (*_gtk_reserved2) (void);
  72. void (*_gtk_reserved3) (void);
  73. void (*_gtk_reserved4) (void);
  74. };
  75. struct _GtkItemFactoryEntry
  76. {
  77. gchar *path;
  78. gchar *accelerator;
  79. GtkItemFactoryCallback callback;
  80. guint callback_action;
  81. /* possible values:
  82. * NULL -> "<Item>"
  83. * "" -> "<Item>"
  84. * "<Title>" -> create a title item
  85. * "<Item>" -> create a simple item
  86. * "<ImageItem>" -> create an item holding an image
  87. * "<StockItem>" -> create an item holding a stock image
  88. * "<CheckItem>" -> create a check item
  89. * "<ToggleItem>" -> create a toggle item
  90. * "<RadioItem>" -> create a radio item
  91. * <path> -> path of a radio item to link against
  92. * "<Separator>" -> create a separator
  93. * "<Tearoff>" -> create a tearoff separator
  94. * "<Branch>" -> create an item to hold sub items
  95. * "<LastBranch>" -> create a right justified item to hold sub items
  96. */
  97. gchar *item_type;
  98. /* Extra data for some item types:
  99. * ImageItem -> pointer to inlined pixbuf stream
  100. * StockItem -> name of stock item
  101. */
  102. gconstpointer extra_data;
  103. };
  104. struct _GtkItemFactoryItem
  105. {
  106. gchar *path;
  107. GSList *widgets;
  108. };
  109. GType gtk_item_factory_get_type (void) G_GNUC_CONST;
  110. /* `container_type' must be of GTK_TYPE_MENU_BAR, GTK_TYPE_MENU,
  111. * or GTK_TYPE_OPTION_MENU.
  112. */
  113. GtkItemFactory* gtk_item_factory_new (GType container_type,
  114. const gchar *path,
  115. GtkAccelGroup *accel_group);
  116. void gtk_item_factory_construct (GtkItemFactory *ifactory,
  117. GType container_type,
  118. const gchar *path,
  119. GtkAccelGroup *accel_group);
  120. /* These functions operate on GtkItemFactoryClass basis.
  121. */
  122. void gtk_item_factory_add_foreign (GtkWidget *accel_widget,
  123. const gchar *full_path,
  124. GtkAccelGroup *accel_group,
  125. guint keyval,
  126. GdkModifierType modifiers);
  127. GtkItemFactory* gtk_item_factory_from_widget (GtkWidget *widget);
  128. G_CONST_RETURN gchar* gtk_item_factory_path_from_widget (GtkWidget *widget);
  129. GtkWidget* gtk_item_factory_get_item (GtkItemFactory *ifactory,
  130. const gchar *path);
  131. GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory,
  132. const gchar *path);
  133. GtkWidget* gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory,
  134. guint action);
  135. GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory,
  136. guint action);
  137. void gtk_item_factory_create_item (GtkItemFactory *ifactory,
  138. GtkItemFactoryEntry *entry,
  139. gpointer callback_data,
  140. guint callback_type);
  141. void gtk_item_factory_create_items (GtkItemFactory *ifactory,
  142. guint n_entries,
  143. GtkItemFactoryEntry *entries,
  144. gpointer callback_data);
  145. void gtk_item_factory_delete_item (GtkItemFactory *ifactory,
  146. const gchar *path);
  147. void gtk_item_factory_delete_entry (GtkItemFactory *ifactory,
  148. GtkItemFactoryEntry *entry);
  149. void gtk_item_factory_delete_entries (GtkItemFactory *ifactory,
  150. guint n_entries,
  151. GtkItemFactoryEntry *entries);
  152. void gtk_item_factory_popup (GtkItemFactory *ifactory,
  153. guint x,
  154. guint y,
  155. guint mouse_button,
  156. guint32 time_);
  157. void gtk_item_factory_popup_with_data(GtkItemFactory *ifactory,
  158. gpointer popup_data,
  159. GDestroyNotify destroy,
  160. guint x,
  161. guint y,
  162. guint mouse_button,
  163. guint32 time_);
  164. gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory);
  165. gpointer gtk_item_factory_popup_data_from_widget (GtkWidget *widget);
  166. void gtk_item_factory_set_translate_func (GtkItemFactory *ifactory,
  167. GtkTranslateFunc func,
  168. gpointer data,
  169. GDestroyNotify notify);
  170. /* Compatibility functions for deprecated GtkMenuFactory code
  171. */
  172. /* Used by gtk_item_factory_create_menu_entries () */
  173. typedef void (*GtkMenuCallback) (GtkWidget *widget,
  174. gpointer user_data);
  175. typedef struct {
  176. gchar *path;
  177. gchar *accelerator;
  178. GtkMenuCallback callback;
  179. gpointer callback_data;
  180. GtkWidget *widget;
  181. } GtkMenuEntry;
  182. /* Used by gtk_item_factory_callback_marshal () */
  183. typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget,
  184. gpointer callback_data,
  185. guint callback_action);
  186. /* Used by gtk_item_factory_create_items () */
  187. void gtk_item_factory_create_items_ac (GtkItemFactory *ifactory,
  188. guint n_entries,
  189. GtkItemFactoryEntry *entries,
  190. gpointer callback_data,
  191. guint callback_type);
  192. GtkItemFactory* gtk_item_factory_from_path (const gchar *path);
  193. void gtk_item_factory_create_menu_entries (guint n_entries,
  194. GtkMenuEntry *entries);
  195. void gtk_item_factories_path_delete (const gchar *ifactory_path,
  196. const gchar *path);
  197. G_END_DECLS
  198. #endif /* !GTK_DISABLE_DEPRECATED */
  199. #endif /* __GTK_ITEM_FACTORY_H__ */