glade-gtk-activatable.c 5.37 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
26
27
28
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * 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>
#include <gladeui/glade.h>

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

	glade_widget_property_get (widget, "related-action", &related_action);
	if (related_action == NULL)
		glade_widget_property_set (widget, "use-action-appearance", FALSE);
}

void
glade_gtk_evaluate_activatable_property_sensitivity (GObject *object,
                                                     const gchar *id,
                                                     const GValue *value)
{
  GladeWidget *gwidget = glade_widget_get_from_gobject (object);

  if (!strcmp (id, "related-action"))
    {
      GtkAction *action = g_value_get_object (value);
      
      if (action)
        {
          glade_widget_property_set_sensitive (gwidget, "visible", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "sensitive", FALSE,
                                               ACTION_APPEARANCE_MSG);

          glade_widget_property_set_sensitive (gwidget, "accel-group", FALSE,
                                               ACTION_APPEARANCE_MSG);
        }
      else
        {
          glade_widget_property_set_sensitive (gwidget, "visible", TRUE, NULL);
          glade_widget_property_set_sensitive (gwidget, "sensitive", TRUE,
                                               NULL);

          glade_widget_property_set_sensitive (gwidget, "accel-group", TRUE,
                                               NULL);
        }

    }
  else if (!strcmp (id, "use-action-appearance"))
    {
      gboolean use_appearance = g_value_get_boolean (value);


      if (use_appearance)
        {
          glade_widget_property_set_sensitive (gwidget, "label", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "use-underline", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "stock", FALSE,
                                               ACTION_APPEARANCE_MSG);
          //glade_widget_property_set_sensitive (gwidget, "use-stock", FALSE, ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "image", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "custom-child", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "stock-id", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "label-widget", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "icon-widget", FALSE,
                                               ACTION_APPEARANCE_MSG);
          glade_widget_property_set_sensitive (gwidget, "icon", FALSE,
                                               ACTION_APPEARANCE_MSG);
        }
      else
        {
          glade_widget_property_set_sensitive (gwidget, "label", TRUE, NULL);
          glade_widget_property_set_sensitive (gwidget, "use-underline", TRUE,
                                               NULL);
          glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
          //glade_widget_property_set_sensitive (gwidget, "use-stock", TRUE, NULL);
          glade_widget_property_set_sensitive (gwidget, "image", TRUE, NULL);
          glade_widget_property_set_sensitive (gwidget, "custom-child", TRUE,
                                               NULL);
          glade_widget_property_set_sensitive (gwidget, "stock-id", TRUE, NULL);
          glade_widget_property_set_sensitive (gwidget, "label-widget", TRUE,
                                               NULL);
          glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE,
                                               NULL);
          glade_widget_property_set_sensitive (gwidget, "icon-widget", TRUE,
                                               NULL);
          glade_widget_property_set_sensitive (gwidget, "icon", TRUE, NULL);
        }
    }
}