2
/* Ekiga -- A VoIP and Video-Conferencing application
3
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20
* Ekiga is licensed under the GPL license and as a special exception,
21
* you have permission to link or otherwise combine this program with the
22
* programs OPAL, OpenH323 and PWLIB, and distribute the combination,
23
* without applying the requirements of the GNU GPL to the OPAL, OpenH323
24
* and PWLIB programs, as long as you do follow the requirements of the
25
* GNU GPL for all the rest of the software thus combined.
30
* optional-buttons-gtk.cpp - description
31
* ------------------------------------------
32
* begin : written in 2009 by Julien Puydt
33
* copyright : (c) 2009 by Julien Puydt
34
* description : implementation of a gtk+ optional buttons group
38
#include "optional-buttons-gtk.h"
40
/* here is some pretty simple stuff to keep data around correctly in a GObject,
41
* (and react correctly to clicks on the buttons)
44
struct OptionalButtonsGtkHelper
46
boost::function0<void> callback;
50
optional_buttons_gtk_helper_destroy (struct OptionalButtonsGtkHelper* helper)
56
on_optional_buttons_gtk_clicked (gpointer object,
57
G_GNUC_UNUSED gpointer data)
59
struct OptionalButtonsGtkHelper* helper =
60
(struct OptionalButtonsGtkHelper*)g_object_get_data (G_OBJECT (object),
61
"ekiga-optional-buttons-gtk-helper");
65
// here comes the implementation of the public interface :
67
OptionalButtonsGtk::OptionalButtonsGtk (): nbr_elements(0)
71
OptionalButtonsGtk::~OptionalButtonsGtk ()
73
for (buttons_type::iterator iter = buttons.begin ();
74
iter != buttons.end ();
77
g_object_unref (iter->second);
82
OptionalButtonsGtk::add_button (const std::string label,
85
g_return_if_fail (GTK_IS_BUTTON (button));
86
g_return_if_fail (buttons[label] == 0);
88
g_object_ref (button);
89
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
90
buttons[label] = button;
91
struct OptionalButtonsGtkHelper* helper = new struct OptionalButtonsGtkHelper;
92
g_object_set_data_full (G_OBJECT (button), "ekiga-optional-buttons-gtk-helper",
93
(gpointer)helper,(GDestroyNotify)optional_buttons_gtk_helper_destroy);
94
g_signal_connect (button, "clicked",
95
G_CALLBACK (on_optional_buttons_gtk_clicked), NULL);
99
OptionalButtonsGtk::reset ()
101
for (buttons_type::iterator iter = buttons.begin ();
102
iter != buttons.end ();
105
gtk_widget_set_sensitive (GTK_WIDGET (iter->second), FALSE);
106
struct OptionalButtonsGtkHelper* helper =
107
(struct OptionalButtonsGtkHelper*)g_object_get_data (G_OBJECT (iter->second),
108
"ekiga-optional-buttons-gtk-helper");
109
helper->callback = boost::function0<void> ();
115
OptionalButtonsGtk::add_action (const std::string icon,
116
G_GNUC_UNUSED const std::string label,
117
const boost::function0<void> callback)
119
buttons_type::iterator iter = buttons.find (icon);
121
if (iter != buttons.end ()) {
123
struct OptionalButtonsGtkHelper* helper =
124
(struct OptionalButtonsGtkHelper*)g_object_get_data (G_OBJECT (iter->second),
125
"ekiga-optional-buttons-gtk-helper");
126
helper->callback = callback;
127
gtk_widget_set_sensitive (GTK_WIDGET (iter->second), TRUE);