/src/wrappers/gtk/library/gtk_accel_label.e

http://github.com/tybor/Liberty · Specman e · 168 lines · 65 code · 33 blank · 70 comment · 3 complexity · cd225b39bca1b0cbcad4e8f6cd6804af MD5 · raw file

  1. indexing
  2. description: "GtkAccelLabel — A label which displays an accelerator key on the right of the text."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class GTK_ACCEL_LABEL
  19. -- The GtkAccelLabel widget is a subclass of GtkLabel that also
  20. -- displays an accelerator key on the right of the label text,
  21. -- e.g. 'Ctl+S'. It is commonly used in menus to show the keyboard
  22. -- short-cuts for commands.
  23. -- The accelerator key to display is not set explicitly. Instead,
  24. -- the GtkAccelLabel displays the accelerators which have been
  25. -- added to a particular widget. This widget is set by calling
  26. -- gtk_accel_label_set_accel_widget().
  27. -- For example, a GtkMenuItem widget may have an accelerator added
  28. -- to emit the "activate" signal when the 'Ctl+S' key combination
  29. -- is pressed. A GtkAccelLabel is created and added to the
  30. -- GtkMenuItem, and gtk_accel_label_set_accel_widget() is called
  31. -- with the GtkMenuItem as the second argument. The GtkAccelLabel
  32. -- will now display 'Ctl+S' after its label.
  33. -- Note that creating a GtkMenuItem with
  34. -- gtk_menu_item_new_with_label() (or one of the similar functions
  35. -- for GtkCheckMenuItem and GtkRadioMenuItem) automatically adds a
  36. -- GtkAccelLabel to the GtkMenuItem and calls
  37. -- gtk_accel_label_set_accel_widget() to set it up for you.
  38. -- A GtkAccelLabel will only display accelerators which have
  39. -- GTK_ACCEL_VISIBLE set (see GtkAccelFlags). A GtkAccelLabel
  40. -- can display multiple accelerators and even signal names,
  41. -- though it is almost always used to display just one
  42. -- accelerator key.
  43. -- Example 1. Creating a simple menu item with an accelerator key.
  44. -- GtkWidget *save_item;
  45. -- GtkAccelGroup *accel_group;
  46. -- /* Create a GtkAccelGroup and add it to the window. */
  47. -- accel_group = gtk_accel_group_new ();
  48. -- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  49. -- /* Create the menu item using the convenience function. */
  50. -- save_item = gtk_menu_item_new_with_label ("Save");
  51. -- gtk_widget_show (save_item);
  52. -- gtk_container_add (GTK_CONTAINER (menu), save_item);
  53. -- /* Now add the accelerator to the GtkMenuItem. Note that
  54. -- since we called gtk_menu_item_new_with_label() to create
  55. -- the GtkMenuItem the GtkAccelLabel is automatically set
  56. -- up to display the GtkMenuItem accelerators. We just need
  57. -- to make sure we use GTK_ACCEL_VISIBLE here. */
  58. -- gtk_widget_add_accelerator (save_item, "activate",
  59. -- accel_group, GDK_s, GDK_CONTROL_MASK,
  60. -- GTK_ACCEL_VISIBLE);
  61. inherit
  62. GTK_LABEL
  63. redefine
  64. struct_size
  65. end
  66. -- TODO: GtkAccelLabel implements AtkImplementorIface.
  67. insert
  68. GTK_ACCEL_LABEL_EXTERNALS
  69. G_OBJECT_FACTORY [GTK_WIDGET]
  70. creation make, from_external_pointer
  71. feature {} -- Creation
  72. make (a_label: STRING) is
  73. -- Creates a new GtkAccelLabel with `a_label'.
  74. require label_not_void: a_label /= Void
  75. do
  76. from_external_pointer(gtk_accel_label_new(a_label.to_external))
  77. end
  78. feature
  79. -- TODO: void gtk_accel_label_set_accel_closure (GtkAccelLabel
  80. -- *accel_label, GClosure *accel_closure);
  81. -- Sets the closure to be monitored by this accelerator label. The closure must be connected to an accelerator group; see gtk_accel_group_connect().
  82. -- accel_label : a GtkAccelLabel
  83. -- accel_closure : the closure to monitor for accelerator
  84. -- changes.
  85. accel_widget: GTK_WIDGET is
  86. -- Fetches the widget monitored by this accelerator
  87. -- label. Can be Void. See `set_accel_widget'.
  88. local ptr: POINTER
  89. do
  90. ptr:=gtk_accel_label_get_accel_widget(handle)
  91. if ptr.is_not_null then
  92. Result:=wrapper(ptr)
  93. end
  94. end
  95. set_accel_widget (a_widget: GTK_WIDGET) is
  96. -- Sets the widget to be monitored by this accelerator label.
  97. do
  98. gtk_accel_label_set_accel_widget (handle, a_widget.handle)
  99. end
  100. accel_width: INTEGER is
  101. -- the width needed to display the accelerator key(s). This
  102. -- is used by menus to align all of the GtkMenuItem widgets,
  103. -- and shouldn't be needed by applications.
  104. do
  105. Result:=gtk_accel_label_get_accel_width (handle)
  106. end
  107. refetch is
  108. -- Recreates the string representing the accelerator
  109. -- keys. This should not be needed since the string is
  110. -- automatically updated whenever accelerators are added or
  111. -- removed from the associated widget.
  112. local int: INTEGER
  113. do
  114. int:=gtk_accel_label_refetch(handle)
  115. check
  116. -- gtk_accel_label_refetch always returns FALSE.
  117. int=0
  118. end
  119. end
  120. feature -- TODO, if necessary: Properties
  121. -- "accel-closure" GClosure : Read / Write
  122. -- "accel-widget" GtkWidget : Read / Write
  123. -- Property Details
  124. -- The "accel-closure" property
  125. -- "accel-closure" GClosure : Read / Write
  126. -- The closure to be monitored for accelerator changes.
  127. -- The "accel-widget" property
  128. -- "accel-widget" GtkWidget : Read / Write
  129. -- The widget to be monitored for accelerator changes.
  130. feature -- size
  131. struct_size: INTEGER is
  132. external "C inline use <gtk/gtk.h>"
  133. alias "sizeof(GtkAccelLabel)"
  134. end
  135. end -- GTK_ACCEL_LABEL