]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkaction.c
Change FSF Address
[~andy/gtk] / gtk / gtkaction.c
index 4425696e197f2ee6a6996a4b059938029942a6ef..fe5336228dbd152eed03eabb2637e324850bd1c8 100644 (file)
@@ -14,9 +14,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with the Gnome Library; see the file COPYING.LIB.  If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -32,7 +30,7 @@
  * SECTION:gtkaction
  * @Short_description: An action which can be triggered by a menu or toolbar item
  * @Title: GtkAction
- * @See_also: #GtkActionGroup, #GtkUIManager
+ * @See_also: #GtkActionGroup, #GtkUIManager, #GtkActivatable
  *
  * Actions represent operations that the user can be perform, along with
  * some information how it should be presented in the interface. Each action
  * can be in the "active" state. Other actions can be implemented as #GtkAction
  * subclasses.
  *
- * Each action can have one or more proxy menu item, toolbar button or
- * other proxy widgets.  Proxies mirror the state of the action (text
- * label, tooltip, icon, visible, sensitive, etc), and should change when
- * the action's state changes. When the proxy is activated, it should
- * activate its action.
+ * Each action can have one or more proxy widgets. To act as an action proxy,
+ * widget needs to implement #GtkActivatable interface. Proxies mirror the state
+ * of the action and should change when the action's state changes. Properties
+ * that are always mirrored by proxies are #GtkAction:sensitive and
+ * #GtkAction:visible. #GtkAction:gicon, #GtkAction:icon-name, #GtkAction:label,
+ * #GtkAction:short-label and #GtkAction:stock-id properties are only mirorred
+ * if proxy widget has #GtkActivatable:use-action-appearance property set to
+ * %TRUE.
+ *
+ * When the proxy is activated, it should activate its action.
  */
 
 #include "config.h"
 #include "gtkmarshalers.h"
 #include "gtkmenuitem.h"
 #include "gtkstock.h"
-#include "gtktearoffmenuitem.h"
+#include "deprecated/gtktearoffmenuitem.h"
 #include "gtktoolbutton.h"
 #include "gtktoolbar.h"
 #include "gtkprivate.h"
 #include "gtkbuildable.h"
 #include "gtkactivatable.h"
-#include "gtkalias.h"
-
 
-#define GTK_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ACTION, GtkActionPrivate))
 
 struct _GtkActionPrivate 
 {
@@ -437,7 +437,9 @@ gtk_action_class_init (GtkActionClass *klass)
 static void
 gtk_action_init (GtkAction *action)
 {
-  action->private_data = GTK_ACTION_GET_PRIVATE (action);
+  action->private_data = G_TYPE_INSTANCE_GET_PRIVATE (action,
+                                                      GTK_TYPE_ACTION,
+                                                      GtkActionPrivate);
 
   action->private_data->name = NULL;
   action->private_data->label = NULL;
@@ -502,10 +504,11 @@ gtk_action_buildable_get_name (GtkBuildable *buildable)
 /**
  * gtk_action_new:
  * @name: A unique name for the action
- * @label: (allow-none): the label displayed in menu items and on buttons, or %NULL
+ * @label: (allow-none): the label displayed in menu items and on buttons,
+ *         or %NULL
  * @tooltip: (allow-none): a tooltip for the action, or %NULL
- * @stock_id: the stock icon to display in widgets representing the
- *   action, or %NULL
+ * @stock_id: (allow-none): the stock icon to display in widgets representing
+ *            the action, or %NULL
  *
  * Creates a new #GtkAction object. To add the action to a
  * #GtkActionGroup and set the accelerator for the action,
@@ -711,6 +714,7 @@ static void
 remove_proxy (GtkAction *action,
              GtkWidget *proxy)
 {
+  g_object_unref (proxy);
   action->private_data->proxies = g_slist_remove (action->private_data->proxies, proxy);
 }
 
@@ -720,6 +724,8 @@ connect_proxy (GtkAction *action,
 {
   action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);
 
+  g_object_ref_sink (proxy);
+
   if (action->private_data->action_group)
     _gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);
 
@@ -869,7 +875,7 @@ gtk_action_unblock_activate (GtkAction *action)
  * This function is intended for use by action implementations to
  * create icons displayed in the proxy widgets.
  *
- * Returns: a widget that displays the icon for this action.
+ * Returns: (transfer none): a widget that displays the icon for this action.
  *
  * Since: 2.4
  */
@@ -895,7 +901,7 @@ gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size)
  *
  * Creates a menu item widget that proxies for the given action.
  *
- * Returns: a menu item connected to the action.
+ * Returns: (transfer none): a menu item connected to the action.
  *
  * Since: 2.4
  */
@@ -920,7 +926,7 @@ gtk_action_create_menu_item (GtkAction *action)
  *
  * Creates a toolbar item widget that proxies for the given action.
  *
- * Returns: a toolbar item connected to the action.
+ * Returns: (transfer none): a toolbar item connected to the action.
  *
  * Since: 2.4
  */
@@ -990,7 +996,7 @@ gtk_action_get_proxies (GtkAction *action)
  *
  * Since: 2.4
  **/
-G_CONST_RETURN gchar *
+const gchar *
 gtk_action_get_name (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1287,7 +1293,7 @@ gtk_action_set_label (GtkAction     *action,
  *
  * Since: 2.16
  */
-G_CONST_RETURN gchar * 
+const gchar *
 gtk_action_get_label (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1333,7 +1339,7 @@ gtk_action_set_short_label (GtkAction   *action,
  *
  * Since: 2.16
  */
-G_CONST_RETURN gchar * 
+const gchar *
 gtk_action_get_short_label (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1465,7 +1471,7 @@ gtk_action_set_tooltip (GtkAction   *action,
  *
  * Since: 2.16
  */
-G_CONST_RETURN gchar * 
+const gchar *
 gtk_action_get_tooltip (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1523,7 +1529,7 @@ gtk_action_set_stock_id (GtkAction   *action,
  *
  * Since: 2.16
  */
-G_CONST_RETURN gchar * 
+const gchar *
 gtk_action_get_stock_id (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1565,7 +1571,7 @@ gtk_action_set_icon_name (GtkAction   *action,
  *
  * Since: 2.16
  */
-G_CONST_RETURN gchar * 
+const gchar *
 gtk_action_get_icon_name (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1605,7 +1611,7 @@ gtk_action_set_gicon (GtkAction *action,
  *
  * Gets the gicon of @action.
  *
- * Returns: The action's #GIcon if one is set.
+ * Returns: (transfer none): The action's #GIcon if one is set.
  *
  * Since: 2.16
  */
@@ -1682,7 +1688,7 @@ gtk_action_set_accel_path (GtkAction   *action,
  *   if none is set. The returned string is owned by GTK+ 
  *   and must not be freed or modified.
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_action_get_accel_path (GtkAction *action)
 {
   g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
@@ -1701,8 +1707,9 @@ gtk_action_get_accel_path (GtkAction *action)
  *
  * Since: 2.8
  *
- * Returns: the accel closure for this action. The returned closure is
- *          owned by GTK+ and must not be unreffed or modified.
+ * Returns: (transfer none): the accel closure for this action. The
+ *          returned closure is owned by GTK+ and must not be unreffed
+ *          or modified.
  */
 GClosure *
 gtk_action_get_accel_closure (GtkAction *action)
@@ -1807,7 +1814,8 @@ gtk_action_disconnect_accelerator (GtkAction *action)
  * item or the toolbar item it creates, this function returns an
  * instance of that menu.
  *
- * Return value: the menu item provided by the action, or %NULL.
+ * Return value: (transfer none): the menu item provided by the
+ *               action, or %NULL.
  *
  * Since: 2.12
  */
@@ -1821,6 +1829,3 @@ gtk_action_create_menu (GtkAction *action)
 
   return NULL;
 }
-
-#define __GTK_ACTION_C__
-#include "gtkaliasdef.c"