~ubuntu-branches/ubuntu/utopic/rhythmbox/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/rb-bonobo-helpers.c

Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  arch-tag: Implementation of various utility functions for using Bonobo
3
 
 *
4
 
 *  Copyright (C) 2002 Jorn Baayen
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2, or (at your option)
9
 
 *  any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
 
 *
20
 
 */
21
 
 
22
 
#include <stdlib.h>
23
 
 
24
 
#include "rb-bonobo-helpers.h"
25
 
#include <bonobo/bonobo-ui-util.h>
26
 
#include <bonobo/bonobo-ui-component.h>
27
 
#include <bonobo/bonobo-window.h>
28
 
#include <gtk/gtk.h>
29
 
 
30
 
void
31
 
rb_bonobo_set_label (BonoboUIComponent *component,
32
 
                     const char *path,
33
 
                     const char *label)
34
 
{
35
 
        bonobo_ui_component_set_prop (component, path, "label", label, NULL);
36
 
}
37
 
 
38
 
void
39
 
rb_bonobo_set_tip (BonoboUIComponent *component,
40
 
                   const char *path,
41
 
                   const char *tip)
42
 
{
43
 
        bonobo_ui_component_set_prop (component, path, "tip", tip, NULL);
44
 
}
45
 
 
46
 
void
47
 
rb_bonobo_set_icon (BonoboUIComponent *component,
48
 
                    const char *path,
49
 
                    const char *stock_icon)
50
 
{
51
 
        bonobo_ui_component_set_prop (component, path, "pixname", stock_icon, NULL);
52
 
}
53
 
 
54
 
void
55
 
rb_bonobo_set_verb (BonoboUIComponent *component,
56
 
                    const char *path,
57
 
                    const char *verb)
58
 
{
59
 
        bonobo_ui_component_set_prop (component, path, "verb", verb, NULL);
60
 
}
61
 
 
62
 
void
63
 
rb_bonobo_set_sensitive (BonoboUIComponent *component,
64
 
                         const char *path,
65
 
                         gboolean sensitive)
66
 
{
67
 
        bonobo_ui_component_set_prop (component, path, "sensitive",
68
 
                                      sensitive ? "1" : "0", NULL);
69
 
}
70
 
 
71
 
gboolean
72
 
rb_bonobo_get_sensitive (BonoboUIComponent *component,
73
 
                         const char *path)
74
 
{
75
 
        gboolean ret = FALSE;
76
 
        char *prop;
77
 
 
78
 
        prop = bonobo_ui_component_get_prop (component, path, "sensitive", NULL);
79
 
        if (prop != NULL)
80
 
                ret = atoi (prop);
81
 
        g_free (prop);
82
 
 
83
 
        return ret;
84
 
}
85
 
 
86
 
void
87
 
rb_bonobo_set_active (BonoboUIComponent *component,
88
 
                      const char *path,
89
 
                      gboolean active)
90
 
{
91
 
        bonobo_ui_component_set_prop (component, path, "state",
92
 
                                      active ? "1" : "0", NULL);
93
 
}
94
 
 
95
 
gboolean
96
 
rb_bonobo_get_active (BonoboUIComponent *component,
97
 
                      const char *path)
98
 
{
99
 
        gboolean ret = FALSE;
100
 
        char *prop;
101
 
 
102
 
        prop = bonobo_ui_component_get_prop (component, path, "state", NULL);
103
 
        if (prop != NULL)
104
 
                ret = atoi (prop);
105
 
        g_free (prop);
106
 
 
107
 
        return ret;
108
 
}
109
 
 
110
 
void
111
 
rb_bonobo_set_visible (BonoboUIComponent *component,
112
 
                       const char *path,
113
 
                       gboolean visible)
114
 
{
115
 
        bonobo_ui_component_set_prop (component, path, "hidden",
116
 
                                      visible ? "0" : "1", NULL);
117
 
}
118
 
 
119
 
gboolean
120
 
rb_bonobo_get_visible (BonoboUIComponent *component,
121
 
                       const char *path)
122
 
{
123
 
        gboolean ret = FALSE;
124
 
        char *prop;
125
 
 
126
 
        prop = bonobo_ui_component_get_prop (component, path, "hidden", NULL);
127
 
        if (prop != NULL)
128
 
                ret = atoi (prop);
129
 
        g_free (prop);
130
 
 
131
 
        return ret;
132
 
}
133
 
 
134
 
void
135
 
rb_bonobo_set_look (BonoboUIComponent *component,
136
 
                    const char *path,
137
 
                    const char *look)
138
 
{
139
 
        bonobo_ui_component_set_prop (component, path, "look",
140
 
                                      look, NULL);
141
 
}
142
 
 
143
 
void
144
 
rb_bonobo_add_listener_list_with_data (BonoboUIComponent *component,
145
 
                                       const RBBonoboUIListener *list,
146
 
                                       gpointer user_data)
147
 
{
148
 
        const RBBonoboUIListener *l;
149
 
 
150
 
        g_return_if_fail (list != NULL);
151
 
        g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));
152
 
 
153
 
        bonobo_object_ref (BONOBO_OBJECT (component));
154
 
 
155
 
        for (l = list; l != NULL && l->cname != NULL; l++)
156
 
        {
157
 
                bonobo_ui_component_add_listener (component,
158
 
                                                  l->cname,
159
 
                                                  l->cb,
160
 
                                                  user_data);
161
 
        }
162
 
        
163
 
        bonobo_object_unref (BONOBO_OBJECT (component));
164
 
}
165
 
 
166
 
 
167
 
void
168
 
rb_bonobo_show_popup (GtkWidget *source, const char *path)
169
 
{
170
 
        GtkWidget *menu;
171
 
        GtkWidget *window;
172
 
        
173
 
        window = gtk_widget_get_ancestor (GTK_WIDGET (source), 
174
 
                                          BONOBO_TYPE_WINDOW);
175
 
        menu = gtk_menu_new ();
176
 
        gtk_widget_show (menu);
177
 
        
178
 
        bonobo_window_add_popup (BONOBO_WINDOW (window), GTK_MENU (menu), 
179
 
                                 path);
180
 
                
181
 
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
182
 
                        3, gtk_get_current_event_time ());
183
 
 
184
 
        gtk_object_sink (GTK_OBJECT (menu));
185
 
}