]> git.sur5r.net Git - glabels/blob - src/ui-util.c
Imported Upstream version 2.2.8
[glabels] / src / ui-util.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (GLABELS) Label and Business Card Creation program for GNOME
5  *
6  *  ui-util.c:  GLabels ui utilities module
7  *
8  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  */
24 #include <config.h>
25
26 #include "ui-util.h"
27
28 #include <gtk/gtkaction.h>
29 #include <gtk/gtktoggleaction.h>
30
31 #include "debug.h"
32
33 /*==========================================================================*/
34 /* Private macros and constants.                                            */
35 /*==========================================================================*/
36
37 /*==========================================================================*/
38 /* Private types.                                                           */
39 /*==========================================================================*/
40
41 /*==========================================================================*/
42 /* Private globals                                                          */
43 /*==========================================================================*/
44
45 /*==========================================================================*/
46 /* Local function prototypes                                                */
47 /*==========================================================================*/
48
49
50 \f
51 /*****************************************************************************/
52 /** Set sensitivity of verb.                                                 */
53 /*****************************************************************************/
54 void
55 gl_ui_util_set_verb_sensitive (GtkUIManager  *ui,
56                                gchar         *cname,
57                                gboolean       sensitive)
58 {
59         GtkAction *action;
60
61         gl_debug (DEBUG_UI, "START");
62
63         g_return_if_fail (cname != NULL);
64         g_return_if_fail (GTK_IS_UI_MANAGER (ui));
65
66         action = gtk_ui_manager_get_action (ui, cname);
67
68         if (action) {
69                 gl_debug (DEBUG_UI, "Set action \"%s\" sensitive = %d", cname, sensitive);
70                 gtk_action_set_sensitive (action, sensitive);
71         }
72
73         gl_debug (DEBUG_UI, "END");
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 /** Set state of a verb.                                                     */
105 /*****************************************************************************/
106 void
107 gl_ui_util_set_verb_state (GtkUIManager  *ui,
108                            gchar         *cname,
109                            gboolean       state)
110 {
111         GtkToggleAction *action;
112
113         gl_debug (DEBUG_UI, "START");
114
115         g_return_if_fail (cname != NULL);
116         g_return_if_fail (GTK_IS_UI_MANAGER (ui));
117
118         action = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui, cname));
119
120         if (action) {
121                 gtk_toggle_action_set_active (action, state);
122         }
123
124         gl_debug (DEBUG_UI, "END");
125 }
126