3 (c) 2010 Gregor Riepl <onitake@gmail.com>
5 Tethering utility for Maemo
7 This program 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.
12 This program 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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/types.h>
27 #include <hildon/hildon.h>
31 #define MTETHERD_STATUS_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginPrivate))
33 struct _MTetherDStatusPluginPrivate {
38 HD_DEFINE_PLUGIN_MODULE(MTetherDStatusPlugin, mtetherd_status_plugin, HD_TYPE_STATUS_MENU_ITEM);
40 static void mtetherd_status_plugin_class_finalize(MTetherDStatusPluginClass *klass) { }
42 static void mtetherd_status_plugin_class_init(MTetherDStatusPluginClass *klass) {
43 g_type_class_add_private(klass, sizeof(MTetherDStatusPluginPrivate));
46 static void set_button_text(GtkWidget *button, gboolean enabled) {
48 gtk_button_set_label(GTK_BUTTON(button), "Disable USB Networking");
50 gtk_button_set_label(GTK_BUTTON(button), "Enable USB Networking");
54 static void enable_usb_net_clicked(GtkWidget *button, gpointer user) {
55 MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(user);
57 if (button == plugin->priv->button) {
58 plugin->priv->neton = !plugin->priv->neton;
59 set_button_text(plugin->priv->button, plugin->priv->neton);
60 if (plugin->priv->neton) {
68 static void mtetherd_status_plugin_init(MTetherDStatusPlugin *plugin) {
69 plugin->priv = MTETHERD_STATUS_PLUGIN_GET_PRIVATE(plugin);
71 plugin->priv->neton = FALSE;
72 plugin->priv->button = gtk_button_new();
73 set_button_text(plugin->priv->button, plugin->priv->neton);
74 g_signal_connect(plugin->priv->button, "clicked", G_CALLBACK(enable_usb_net_clicked), plugin);
75 gtk_container_add(GTK_CONTAINER(plugin), plugin->priv->button);
76 gtk_widget_show_all(plugin->priv->button);
77 gtk_widget_show(GTK_WIDGET(plugin));