glade-gtk-activatable.c 3.36 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
29
30
31
32

/* ----------------------------- GtkActivatable ------------------------------ */
void
glade_gtk_activatable_parse_finished (GladeProject *project, 
                                      GladeWidget  *widget)
{
33
  GObject *related_action = NULL;
34

35
36
37
  glade_widget_property_get (widget, "related-action", &related_action);
  if (related_action == NULL)
    glade_widget_property_set (widget, "use-action-appearance", FALSE);
38
39
40
}

void
41
glade_gtk_activatable_evaluate_property_sensitivity (GObject *object,
42
43
44
45
                                                     const gchar *id,
                                                     const GValue *value)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
46
47
  gboolean sensitivity;
  gchar *msg;
48
49
50
51
52
53
54

  if (!strcmp (id, "related-action"))
    {
      GtkAction *action = g_value_get_object (value);
      
      if (action)
        {
55
56
          sensitivity = FALSE;
          msg = ACTION_APPEARANCE_MSG;
57
58
59
        }
      else
        {
60
61
          sensitivity = TRUE;
          msg = NULL;
62
63
        }

64
65
66
      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);
67
68
69
    }
  else if (!strcmp (id, "use-action-appearance"))
    {
70
      if (g_value_get_boolean (value))
71
        {
72
73
          sensitivity = FALSE;
          msg = ACTION_APPEARANCE_MSG;
74
75
76
        }
      else
        {
77
78
          sensitivity = TRUE;
          msg = NULL;
79
        }
80
81
82
83
84
85
86
87
88
89
90
91
      
      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, "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);
92
93
    }
}