glade-gtk-activatable.c 3.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * glade-gtk-activatable.c
 *
 * Copyright (C) 2010 Tristan Van Berkom.
 *
 * Author:
 *   Tristan Van Berkom <tvb@gnome.org>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include <config.h>
26
#include "glade-gtk-activatable.h"
27
28

/* ----------------------------- GtkActivatable ------------------------------ */
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
static void
update_use_action_appearance (GladeWidget *gwidget,
                              gboolean related_action,
                              gboolean use_appearance)
{
  gboolean sensitivity;
  gchar *msg;
  
  if (use_appearance)
    {
      sensitivity = FALSE;
      msg = ACTION_APPEARANCE_MSG;
    }
  else
    {
      sensitivity = TRUE;
      msg = NULL;
    }

  glade_widget_property_set_sensitive (gwidget, "label", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "use-underline", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "stock", sensitivity, msg);
  //glade_widget_property_set_sensitive (gwidget, "use-stock", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "image", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "image-position", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "custom-child", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "stock-id", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "label-widget", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "icon-name", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "icon-widget", sensitivity, msg);
  glade_widget_property_set_sensitive (gwidget, "icon", sensitivity, msg);

  if (related_action)
    {
      glade_widget_property_set_sensitive (gwidget, "visible", sensitivity, msg);
      glade_widget_property_set_sensitive (gwidget, "sensitive", sensitivity, msg);
      glade_widget_property_set_sensitive (gwidget, "accel-group", sensitivity, msg);
      glade_widget_property_set_sensitive (gwidget, "use-action-appearance",
                                           !sensitivity, sensitivity ? msg : NULL);
    }
}

71
void
72
glade_gtk_activatable_evaluate_property_sensitivity (GObject *object,
73
74
75
76
77
78
79
                                                     const gchar *id,
                                                     const GValue *value)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);

  if (!strcmp (id, "related-action"))
    {
Juan Pablo Ugarte's avatar
Juan Pablo Ugarte committed
80
81
      update_use_action_appearance (gwidget, TRUE, 
                                    g_value_get_object (value) != NULL);
82
83
84
    }
  else if (!strcmp (id, "use-action-appearance"))
    {
85
86
      GtkAction *action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (object));
      gboolean use_appearance = g_value_get_boolean (value);
87
      
88
      update_use_action_appearance (gwidget, FALSE, action && use_appearance);
89
90
    }
}