]> git.sur5r.net Git - glabels/blob - src/ui-util.c
Imported Upstream version 3.0.0
[glabels] / src / ui-util.c
1 /*
2  *  ui-util.c
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
7  *  gLabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  gLabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "ui-util.h"
24
25 #include <gtk/gtk.h>
26
27 #include "debug.h"
28
29
30 /*==========================================================================*/
31 /* Private macros and constants.                                            */
32 /*==========================================================================*/
33
34
35 /*==========================================================================*/
36 /* Private types.                                                           */
37 /*==========================================================================*/
38
39
40 /*==========================================================================*/
41 /* Private globals                                                          */
42 /*==========================================================================*/
43
44
45 /*==========================================================================*/
46 /* Local function prototypes                                                */
47 /*==========================================================================*/
48
49
50 /*****************************************************************************/
51 /** Set sensitivity of verb.                                                 */
52 /*****************************************************************************/
53 void
54 gl_ui_util_set_verb_sensitive (GtkUIManager  *ui,
55                                gchar         *cname,
56                                gboolean       sensitive)
57 {
58         GtkAction *action;
59
60         gl_debug (DEBUG_UI, "START");
61
62         g_return_if_fail (cname != NULL);
63         g_return_if_fail (GTK_IS_UI_MANAGER (ui));
64
65         action = gtk_ui_manager_get_action (ui, cname);
66
67         if (action) {
68                 gl_debug (DEBUG_UI, "Set action \"%s\" sensitive = %d", cname, sensitive);
69                 gtk_action_set_sensitive (action, sensitive);
70         }
71
72         gl_debug (DEBUG_UI, "END");
73 }
74
75
76 /*****************************************************************************/
77 /** Set sensitivity of a list of verbs.                                      */
78 /*****************************************************************************/
79 void
80 gl_ui_util_set_verb_list_sensitive (GtkUIManager  *ui,
81                                     gchar        **vlist,
82                                     gboolean       sensitive)
83 {
84         GtkAction *action;
85
86         gl_debug (DEBUG_UI, "START");
87
88         g_return_if_fail (vlist != NULL);
89         g_return_if_fail (GTK_IS_UI_MANAGER (ui));
90
91         for ( ; *vlist; ++vlist)
92         {
93                 action = gtk_ui_manager_get_action (ui, *vlist);
94
95                 if (action) {
96                         gtk_action_set_sensitive (action, sensitive);
97                 }
98         }
99
100         gl_debug (DEBUG_UI, "END");
101 }
102
103
104 /*****************************************************************************/
105 /** Set state of a verb.                                                     */
106 /*****************************************************************************/
107 void
108 gl_ui_util_set_verb_state (GtkUIManager  *ui,
109                            gchar         *cname,
110                            gboolean       state)
111 {
112         GtkToggleAction *action;
113
114         gl_debug (DEBUG_UI, "START");
115
116         g_return_if_fail (cname != NULL);
117         g_return_if_fail (GTK_IS_UI_MANAGER (ui));
118
119         action = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui, cname));
120
121         if (action) {
122                 gtk_toggle_action_set_active (action, state);
123         }
124
125         gl_debug (DEBUG_UI, "END");
126 }
127
128
129
130 /*
131  * Local Variables:       -- emacs
132  * mode: C                -- emacs
133  * c-basic-offset: 8      -- emacs
134  * tab-width: 8           -- emacs
135  * indent-tabs-mode: nil  -- emacs
136  * End:                   -- emacs
137  */